1import{t as e,w as j,G as I,H as _}from"./chunk-4N6VE7H7-DCXb7SYf.js";import{b as P,f as R,e as G,d as U}from"./getAnalyticsQueryOptions-8Wq9Raoc.js";import{u as K}from"./getDailySessionQueryOptions-BIeL7l0i.js";import{D,T as V,a as O}from"./DailyTimelineHeader-D4OW7q7s.js";import{C as H}from"./chevron-left-DlG8RhzE.js";import{C as B}from"./chevron-right-iU340f0p.js";import{b as Y,a as q,s as z,f as J,F as Q,S as X,A as Z}from"./SortDropdown-DD9JwTLm.js";import{G as W,L as ee}from"./layers-_494yshC.js";import{S as te}from"./StatsCard-BwJenAod.js";import{L as se}from"./Loader-DaWkP5KD.js";import"./axiosConfig-DFKm4Hre.js";import"./logger-DuBIU0n2.js";import"./queryOptions-BzsPG9Pm.js";import"./query-BeBT5m4y.js";import"./focusSessionApi-D6yfmLso.js";import"./createLucideIcon-5ma6jv8o.js";import"./chevron-down-Bb-4PQyI.js";import"./check-DEpplTjH.js";import"./index-Dst8F71e.js";import"./iconBase-9W0e38Fc.js";const ae={"Far Better":{dot:"bg-purple-500",halo:"bg-purple-400",pulse:!0,fact:"Well above your recent average",nudge:"an outstanding day."},Better:{dot:"bg-green-500",fact:"Above your recent average",nudge:"you're on the right track."},"Not Different":{dot:"bg-gray-400",fact:"Right at your usual pace",nudge:"consistency counts."},Worse:{dot:"bg-amber-500",fact:"A little below your recent average",nudge:"one focus session gets you back."},"Far Worse":{dot:"bg-red-500",halo:"bg-red-400",pulse:!0,fact:"Well below your recent average",nudge:"a focus session would help."},"No Data":{dot:"bg-blue-500",fact:"No focus sessions yet today",nudge:"start one to set the tone."}};function re(){const{data:t}=P();if(!(t!=null&&t.data)||!(t!=null&&t.performance))return null;const r=ae[t.performance];return r?e.jsxs("div",{className:"mb-4 lg:mb-6 flex items-center gap-2.5 px-1",children:[e.jsxs("span",{className:"relative flex w-2 h-2 shrink-0","aria-hidden":"true",children:[r.pulse&&e.jsx("span",{className:`absolute inline-flex h-full w-full rounded-full opacity-60 animate-ping motion-reduce:hidden ${r.halo}`}),e.jsx("span",{className:`relative inline-flex w-2 h-2 rounded-full ${r.dot}`})]}),e.jsxs("p",{className:"text-sm leading-snug min-w-0",children:[e.jsx("span",{className:"font-semibold text-gray-700",children:r.fact}),e.jsxs("span",{className:"text-gray-400",children:[" â ",r.nudge]})]})]}):null}const oe=(t,r)=>{switch(t){case"focus":return`Focus Session ${r}`;case"shortBreak":return"Short Break";case"longBreak":return"Long Break";default:return t}};function ne(t){if(!t||!Array.isArray(t))return[];const r=[];return t.forEach(s=>{s.session.forEach(n=>{var o,i,l;const f=new Date(n.createdAt),p=new Date(n.updatedAt),h=f.getHours()+f.getMinutes()/60,u=p.getHours()+p.getMinutes()/60,a=u-h;a>=3e-4&&n.type==="focus"&&r.push({start:h,end:u,type:n.type,label:oe(n.type,n.sessionNumber),duration:a,reflection:((o=s.reflection)==null?void 0:o.label)||"No reflection",tasks:((i=n.tasks)==null?void 0:i.length)||0,interruptions:((l=n.interruptions)==null?void 0:l.length)||0,sessionId:s._id})})}),r.sort((s,n)=>s.start-n.start)}const A="grid place-items-center w-[30px] h-[30px] rounded-[9px] border border-gray-200 bg-white text-gray-500 transition-colors hover:enabled:bg-gray-100 hover:enabled:text-gray-900 disabled:opacity-40 disabled:cursor-not-allowed";function le({selectedDate:t="today"}){const{data:r,isLoading:s,error:n}=K(),[f,p]=j.useState(1),h=4,u=j.useMemo(()=>r!=null&&r.data?ne(r.data):[],[r]),a=u.length,o=Math.ceil(a/h),i=(f-1)*h,l=i+h,b=u.slice(i,l),x=d=>{p(d)},g="bg-white rounded-2xl shadow-sm border border-gray-200/60 p-4 sm:p-5 lg:p-6 h-full flex flex-col overflow-hidden";return s?e.jsxs("div",{className:g,children:[e.jsx(D,{totalItems:0,selectedDate:t}),e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"animate-pulse w-full",children:[e.jsx("div",{className:"h-[54px] bg-gray-100 rounded-xl mb-5"}),e.jsx("div",{className:"space-y-3",children:[0,1,2].map(d=>e.jsx("div",{className:"h-8 bg-gray-100 rounded-lg"},d))})]})})]}):n?e.jsxs("div",{className:g,children:[e.jsx(D,{totalItems:0,selectedDate:t}),e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-center gap-1",children:[e.jsx("p",{className:"text-sm font-semibold text-gray-900",children:"Couldn't load the timeline"}),e.jsx("p",{className:"text-xs text-gray-400",children:"Refresh the page to try again."})]})]}):e.jsxs("div",{className:g,children:[e.jsx(D,{totalItems:a,selectedDate:t}),e.jsx(V,{timelineData:u,currentPageData:b,selectedDate:t,startIndex:i}),e.jsx("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:a>
10?e.jsx("div",{className:"flex-1 overflow-y-auto pr-1 lg:pr-2",children:b.map((d,m)=>e.jsx(O,{item:d},`desc-${i+m}`))}):e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsx("p",{className:"text-sm font-semibold text-gray-400",children:"No focus sessions for this day"})})}),a>0&&e.jsxs("div",{className:"shrink-0 flex items-center justify-between gap-3 pt-3.5 mt-3.5 border-t border-gray-100",children:[e.jsxs("span",{className:"text-xs font-semibold text-gray-400 whitespace-nowrap",children:["Showing ",i+1,"â",Math.min(l,a)," of"," ",a]}),o>1&&e.jsxs("div",{className:"inline-flex items-center gap-1",children:[e.jsxs("span",{className:"mr-1.5 text-xs font-semibold text-gray-400",children:["Page ",f," of ",o]}),e.jsx("button",{className:A,disabled:f===1,onClick:()=>x(Math.max(1,f-1)),"aria-label":"Previous page",children:e.jsx(H,{className:"w-4 h-4",strokeWidth:2.2})}),e.jsx("button",{className:A,disabled:f>=o,onClick:()=>x(Math.min(o,f+1)),"aria-label":"Next page",children:e.jsx(B,{className:"w-4 h-4",strokeWidth:2.2})})]})]})]})}const T="#7857ff",k=5,L=["#7857ff"];function ie(t=""){let r=0;for(let s=0;s<t.length;s++)r=r*31+t.charCodeAt(s)>>>0;return L[r%L.length]}function F(t){const r=Math.floor(t/6e4),s=Math.floor(r/60),n=r%60;return s&&n?`${s}h ${n}m`:s?`${s}h`:`${n}m`}const C="inline-flex items-center gap-1.5 h-8 px-3.5 rounded-lg text-[13.5px] font-bold whitespace-nowrap transition-colors",E="grid place-items-center w-[30px] h-[30px] rounded-[9px] border border-gray-200 bg-white text-gray-500 transition-colors disabled:opacity-40 disabled:cursor-not-allowed";function ce(){const{data:t,isLoading:r}=R(),[s,n]=I(),[f,p]=j.useState(1),h=s.get("view")||"site",u=s.get("filter")||"all",a=s.get("sort")||"time-desc";if(r)return null;const o=h==="site",i=o?t.websites:t.categories,l=i.reduce((c,y)=>c+y.time,0),x=(o?Y(q(t.websites,u),a):z(J(t.categories,u),a)).map(c=>{const y=o?c.domain:c.category;return{name:y,formattedTime:F(c.time),usage:l?Math.round(c.time/l*100):0,time:c.time,color:ie(y),chip:o?c.category:null}}),g=Math.max(...x.map(c=>c.time),1),d=Math.max(1,Math.ceil(x.length/k)),m=Math.min(f,d),v=(m-1)*k,w=x.slice(v,v+k),N=(c,y)=>{s.set(c,y),n(s),p(1)};return e.jsxs("div",{className:"bg-white rounded-2xl shadow-md border border-gray-200/60 p-5 lg:p-6 mb-4 lg:mb-6",children:[e.jsxs("div",{className:"flex flex-col gap-4 lg:flex-row lg:items-start lg:justify-between mb-4 lg:mb-5",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("span",{className:"grid place-items-center w-[30px] h-[30px] rounded-[9px]",style:{background:"color-mix(in srgb, #7857ff 10%, transparent)",color:T},children:e.jsx(W,{className:"w-[17px] h-[17px]",strokeWidth:1.8})}),e.jsx("h3",{className:"text-lg lg:text-xl font-bold tracking-tight text-gray-900",children:"Domains"})]}),e.jsxs("p",{className:"mt-2 text-xs font-semibold text-gray-400",children:[F(l)," tracked today · ",i.length," ",o?"sites":"categories"]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2.5",children:[e.jsxs("div",{className:"inline-flex p-[3px] bg-gray-100 rounded-[11px] gap-0.5",children:[e.jsxs("button",{onClick:()=>N("view","site"),className:o?`${C} bg-white text-gray-900 shadow-sm`:`${C} text-gray-600 hover:text-gray-900`,style:o?{color:T}:void 0,children:[e.jsx(W,{className:"w-[15px] h-[15px]",strokeWidth:1.8})," By site"]}),e.jsxs("button",{onClick:()=>N("view","category"),className:o?`${C} text-gray-600 hover:text-gray-900`:`${C} bg-white text-gray-900 shadow-sm`,style:o?void 0:{color:T},children:[e.jsx(ee,{className:"w-[15px] h-[15px]",strokeWidth:1.8})," By category"]})]}),e.jsx(Q,{currentFilter:u,onFilterChange:c=>N("filter",c)}),e.jsx(X,{currentSort:a,onSortChange:c=>N("sort",c)})]})]}),e.jsxs("div",{className:"flex flex-col",children:[w.length===0&&e.jsxs("div",{className:"py-8 text-center text-[13.5px] font-semibold text-gray-400",children:["No ",u!=="all"?"matching ":"","activity to show."]}),w.map((c,y)=>e.jsx(Z,{rank:v+y+1,row:c,isSite:o,barWidth:c.time/g*100,isLast:y===w.length-1},`${c.name}-${y}`))]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 mt-4 pt-3.5 border-t border-gray-100",children:[e.jsxs("span",{className:"text-xs font-semibold text-gray-400 whitespace-nowrap",children:["Showing ",x.length===0?0:v+1,"â",Math.min(v+k,x.length)," of ",x.length," ",o?"sites":"categories"]}),e.jsxs("div",{className:"inline-flex items-center gap-1",children:[e.jsxs("span",{className:"mr-1.5 text-xs font-semibold text-gray-400",children:["Page ",m," of ",d]}),e.jsx("button",{className:E,disabled:m===1,onClick:()=>p(c=>Math.max(1,c-1)),"aria-label":"Previous page",children:e.jsx(H,{className:"w-4 h-4",strokeWidth:2.2})}),e.jsx("button",{className:E,disabled:m>=d,onClick:()=>p(c=>Math.min(d,c+1)),"aria-label":"Next page",children:e.jsx(B,{className:"w-4 h-4",strokeWidth:2.2})})]})]})]})}const S="#7857ff";function de(){const{data:t}=G(),r=a=>new Date(a).toLocaleDateString("en-US",{weekday:"short"}),s=j.useMemo(()=>!t||!t.data||t.data.length===0?["Sun","Mon","Tue","Wed","Thu","Fri","Sat"].map(o=>({day:o,hours:0,focusSeconds:0,focusTime:"0h 0m"})):t.data.map(a=>({day:r(a.date),date:a.date,hours:+(a.focusSeconds/3600).toFixed(2),focusSeconds:a.focusSeconds,focusTime:a.focusTime})),[t]),n=(t==null?void 0:t.totalFocusSeconds)||0,f=(t==null?void 0:t.totalFocusTime)||"0h 0m",p=Math.max(...s.map(a=>a.hours),1),h=s.reduce((a,o,i,l)=>o.hours>l[a].hours?i:a,0),u=new Date().toDateString();return e.jsxs("div",{className:"bg-white rounded-2xl shadow-sm border border-gray-200/60 p-4 sm:p-5 lg:p-6 h-full flex flex-col",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2 mb-4 lg:mb-5 shrink-0",children:[e.jsx("div",{className:"flex items-center gap-2.5",children:e.jsx("h3",{className:"text-lg lg:text-xl font-extrabold tracking-tight text-gray-900",children:"Weekly Focus"})}),e.jsxs("div",{className:"flex items-baseline gap-1.5",children:[e.jsx("b",{className:"text-[15px] font-extrabold text-gray-900 tabular-nums",children:f}),e.jsx("span",{className:"text-xs font-semibold text-gray-400",children:"this week"})]})]}),e.jsx("div",{className:"flex items-end gap-2.5 h-[184px] pt-2 shrink-0",children:s.map((a,o)=>{const i=a.hours/p*100,l=o===h&&a.hours>0,b=a.date&&new Date(a.date).toDateString()===u,x=a.hours===0,g=l?"opacity-100 translate-y-0":"opacity-0 translate-y-1 group-hover:opacity-100 group-hover:translate-y-0";let d="text-gray-400",m;return b&&(d="",m={color:S}),l&&(d="text-gray-900",m=void 0),e.jsxs("div",{className:"group flex-1 flex flex-col items-center h-full justify-end cursor-default",children:[e.jsx("div",{className:`text-[11.5px] font-extrabold tabular-nums mb-2 text-gray-900 transition-all duration-150 ${g}`,style:l?{color:S}:void 0,children:a.focusTime}),e.jsx("div",{className:"w-full flex-1 flex items-end justify-center relative",children:e.jsx("div",{className:"relative w-[60%] max-w-[30px] min-h-[4px] rounded-t-[7px] rounded-b-[4px] bg-gray-100 transition-[filter] duration-150 group-hover:brightness-[1.04]",style:{height:x?6:"100%"},children:!x&&e.jsx("div",{className:`absolute inset-x-0 bottom-0 rounded-t-[7px] rounded-b-[4px] bg-[#7857ff] transition-[height] duration-500 ${l?"shadow-[0_4px_14px_-4px_#7857ff]":""}`,style:{height:`${i}%`}})})}),e.jsx("div",{className:`text-xs font-bold mt-[11px] ${d}`,style:m,children:a.day}),l?e.jsx("div",{className:"text-[10px] font-extrabold uppercase tracking-wide",style:{color:S},children:"Best"}):e.jsx("div",{className:"h-[13px]"})]},a.day+o)})}),e.jsxs("div",{className:"flex-1 min-h-0 mt-5 pt-4 border-t border-gray-100 flex flex-col",children:[e.jsx("div",{className:"text-[11px] font-bold uppercase tracking-wide text-gray-400 mb-3 shrink-0",children:"Daily breakdown"}),e.jsx("div",{className:"flex-1 space-y-2 lg:space-y-3 overflow-y-auto min-h-0",children:s.map((a,o)=>{const i=n?Math.min(a.focusSeconds/n*100,100):0;return e.jsxs("div",{className:"flex items-center gap-3 lg:gap-4",children:[e.jsx("div",{className:"w-8 sm:w-10 lg:w-12 text-sm font-medium text-gray-600 shrink-0",children:a.day}),e.jsx("div",{className:"flex-1 bg-gray-100 rounded-full h-1.5 lg:h-2 overflow-hidden",children:e.jsx("div",{className:"h-1.5 lg:h-2 rounded-full transition-all duration-500",style:{width:`${i}%`,maxWidth:"100%",background:S}})}),e.jsx("div",{className:"w-12 sm:w-14 lg:w-16 text-xs sm:text-sm text-gray-500 text-right shrink-0",children:a.focusTime})]},o)})})]})]})}const xe={yesterday:"from yesterday",lastWeek:"from last week",thisWeek:"from this week"};function me(){const{data:t}=P(),r=(t==null?void 0:t.data)||[];return e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4 lg:gap-6 mb-6 lg:mb-8",children:r.map((s,n)=>e.jsx(te,{title:s.label,value:s.value,trendValue:s.displayChange??"",trendDirection:s.trend,trendSentiment:s.sentiment,trendText:xe[s.comparisonReference]||"",hasComparison:s.hasComparison},s.type+n))})}const he=["#f3f0ff","#d9ceff","#b8a2ff","#916aff","#7857ff"],fe=["#eefdfb","#c8f5ee","#8fe6da","#4fd3bf","#0d9488"],ue=["Mon","","Wed","","Fri","",""],ge=7*14+6*3;function $(t){return new Date(`${t}T00:00:00`)}function M(t){return $(t).toLocaleDateString("en-US",{weekday:"short",month:"short",day:"numeric"})}function pe(t,r,s){if(!t)return"#f3f4f6";const n=t/r;return n>.8?s[4]:n>.55?s[3]:n>.3?s[2]:n>.05?s[1]:s[0]}function be(t){if(!t.length)return{weeks:[],monthLabels:[]};const s=($(t[0].date).getDay()+6)%7,n=s+t.length,f=Math.ceil(n/7),p=[],h=[];let u=null;for(let a=0;a<f;a++){const o=[];let i=null;for(let l=0;l<7;l++){const b=a*7+l-s,x=b>=0&&b<t.length?t[b]:null;o.push({dateStr:(x==null?void 0:x.date)??null,rec:x}),x&&i===null&&(i=$(x.date).getMonth())}p.push(o),i!==null&&i!==u?(h.push(new Date(2e3,i,1).toLocaleDateString("en-US",{month:"short"})),u=i):h.push("")}return{weeks:p,monthLabels:h}}function ye(){const{data:t,isLoading:r}=U(),[s,n]=j.useState("focus"),[f,p]=j.useState(null),h=(t==null?void 0:t.days)||[],{weeks:u,monthLabels:a}=j.useMemo(()=>be(h),[h]),o=j.useMemo(()=>{const g=h.map(d=>s==="focus"?d.focusHours:d.tasksCompleted);return Math.max(...g,1)},[h,s]),i=s==="focus"?he:fe,l=f?h.find(g=>g.date===f):null,b=l?`${M(l.date)} · ${l.focusTime} focus · ${l.tasksCompleted} task${l.tasksCompleted===1?"":"s"}`:"Hover a day to see focus time and tasks completed.",x=t!=null&&t.bestProductivityDay?`${t.currentStreak}-day streak · best day: ${M(t.bestProductivityDay.date)} (${t.bestProductivityDay.focusTime})`:`${(t==null?void 0:t.currentStreak)||0}-day streak`;return r?e.jsx("div",{className:"bg-white rounded-2xl shadow-sm border border-gray-200/60 p-4 sm:p-5 lg:p-6 mb-4 lg:mb-6 h-[280px] animate-pulse"}):e.jsxs("div",{className:"bg-white rounded-2xl shadow-sm border border-gray-200/60 p-4 sm:p-5 lg:p-6 mb-4 lg:mb-6",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[e.jsx("div",{className:"flex items-center gap-2.5",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg lg:text-xl font-extrabold tracking-tight text-gray-900",children:"Consistency"}),e.jsx("p",{className:"text-xs font-semibold text-gray-400",children:"How your productivity changes over time"})]})}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx("button",{onClick:()=>n("focus"),className:`h-8 px-3 rounded-lg text-[12.5px] font-bold border transition-colors ${s==="focus"?"border-[#ddd6fe] bg-[#f5f3ff] text-[#7857ff]":"border-gray-200 bg-white text-gray-400 hover:text-gray-600"}`,children:"Focus"}),e.jsx("button",{onClick:()=>n("tasks"),className:`h-8 px-3 rounded-lg text-[12.5px] font-bold border transition-colors ${s==="tasks"?"border-teal-200 bg-teal-50 text-teal-600":"border-gray-200 bg-white text-gray-400 hover:text-gray-600"}`,children:"Tasks"})]})]}),e.jsxs("div",{className:"flex gap-2.5 mt-3.5 overflow-x-auto",children:[e.jsx("div",{className:"flex flex-col justify-between shrink-0 pt-4",style:{height:ge},children:ue.map((g,d)=>e.jsx("span",{className:"text-[10px] font-bold text-gray-300 h-[14px] leading-[14px]",children:g},d))}),e.jsxs("div",{className:"flex-1 min-w-[480px]",children:[e.jsx("div",{className:"flex gap-[3px] mb-1",children:a.map((g,d)=>e.jsx("span",{className:"flex-1 min-w-0 overflow-visible whitespace-nowrap text-[10.5px] font-bold text-gray-400",children:g},d))}),e.jsx("div",{className:"flex gap-[3px]",children:u.map((g,d)=>e.jsx("div",{className:"flex flex-1 min-w-0 flex-col gap-[3px]",children:g.map((m,v)=>{const w=m.rec?s==="focus"?m.rec.focusHours:m.rec.tasksCompleted:0;return e.jsx("div",{onMouseEnter:m.rec?()=>p(m.dateStr):void 0,title:m.rec?`${M(m.dateStr)} · ${m.rec.focusTime} focus · ${m.rec.tasksCompleted}
1 tasks`:void 0,className:"w-full h-[14px] rounded-[4px] cursor-default",style:{background:m.rec?pe(w,o,i):"transparent"}},v)})},d))})]})]}),e.jsx("div",{className:"mt-3.5 pt-3 border-t border-gray-100 text-[13px] font-semibold text-gray-500",children:b}),e.jsx("div",{className:"mt-1 text-xs font-semibold text-gray-400",children:x})]})}function je(){const{isLoading:t}=P();return t?e.jsx(se,{}):e.jsx(e.Fragment,{children:e.jsx("div",{className:"col-span-14",children:e.jsx("div",{className:"flex flex-col items-center",children:e.jsxs("div",{className:"w-full",children:[e.jsx(me,{}),e.jsx(re,{}),e.jsx(ye,{}),e.jsxs("div",{className:"flex flex-col lg:flex-row gap-4 lg:gap-6 mb-4 lg:mb-6",children:[e.jsx("div",{className:"w-full lg:flex-1 h-[615px] lg:h-[600px]",children:e.jsx(de,{})}),e.jsx("div",{className:"w-full lg:flex-1 h-[615px] lg:h-[600px]",children:e.jsx(le,{selectedDate:"today"})})]}),e.jsx(ce,{})]})})})})}const Re=_(je);export{Re as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.