PageSourceSearch

https://deepinsights.pro/assets/index-COp2XnoJ.js

js deepinsights.pro collected 2026-10-09 21:20:55 UTC 232,386 bytes, 36 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/GoalsView-BLgUtpJF.js","assets/index-NrhgnKM2.js","assets/index-CFgxsoD2.css","assets/card-CpYsnecR.js","assets/collapsible-CjgedjOe.js","assets/useJourneys-CMDnfFj-.js","assets/natalDreamBridge-C-5qkCxy.js","assets/index-c869O74J.js","assets/progress-BIvvFgy9.js","assets/minus-Bxsd02Jk.js","assets/repeat-C7kh1RMR.js","assets/rotate-ccw-BW-MK5OC.js","assets/trash-2-DGp5sdRr.js","assets/archive-nOb98132.js","assets/pencil-SqDOLIAB.js","assets/dialog-DvLekE7p.js","assets/index-vJJlaGnO.js","assets/popover-D9yxq5jT.js","assets/input-CbcqdLY9.js","assets/label-DnKSbcYk.js","assets/textarea-B4Aa9k_s.js","assets/heart-lLALTiB8.js","assets/compass-BFRTo7Ux.js","assets/bell-C3zUkV9Y.js","assets/target-CCu04NFr.js","assets/chevron-down-BOkNy-PH.js","assets/isToday-vVbriFa5.js","assets/differenceInCalendarDays-CW8Zr1T3.js","assets/constructNow-D7RnJa-O.js","assets/subDays-ATbTChiM.js","assets/isYesterday-DeCyPna9.js","assets/format-Dv5NrfM3.js","assets/en-US-BuQiL2Rf.js","assets/Layout-BsTUDy1T.js","assets/Navigation-B3EJNwa5.js","assets/deep-insights-mark-DKdNDTAS.js","assets/CosmicBackground-rZ4j20PW.js","assets/alert-dialog-BZJMh9Nt.js","assets/optInEvents-XNFqfXuK.js","assets/skeleton-B2eA3LAZ.js","assets/exercises-C0kzO3v3.js","assets/useTodaysSchedule-0psm9_R5.js","assets/isAfter-B-LqVuBh.js","assets/addMinutes-DXkTBw4D.js","assets/useFeatureUnlock-tyaG83Vk.js","assets/endOfWeek-ZDBfWsiu.js","assets/calendar-Cvp91RbG.js","assets/clock-C7ugPfmn.js","assets/award-D0f3g6SA.js","assets/trending-up-BUJ3MQuW.js","assets/circle-check-big-4PjclZtg.js","assets/external-link-B9lXGbF8.js","assets/activity-BInW3Fyq.js","assets/circle-COW2nTW4.js","assets/arrow-right-jZJhC7nb.js","assets/badge-CD8_Q4LX.js","assets/useExerciseData-CUIqzs15.js","assets/flame-Cz161-bc.js","assets/lightbulb-TTouwUng.js","assets/circle-check-D9bn7KrW.js","assets/moon-CpdcbyiL.js","assets/search-BCUzTZpM.js","assets/useChapterProgress-CWreQedw.js","assets/firstActionActivation-Bdv_xgmQ.js","assets/useExerciseCache-dBM_iHU0.js","assets/exerciseMedia-Db6nLaIW.js","assets/useFeatureTracking-DucAumal.js","assets/useTriggerAchievementCheck-D-ykp9FH.js","assets/useAuthenticatedFunction-Clfh9Dc7.js","assets/dropdown-menu-Daq1ZBHh.js","assets/index-SF0UBlGb.js","assets/index-DMdsWmDT.js","assets/ShareMenu-CW4MVqi5.js","assets/mail-Bjxo_Vxo.js","assets/network-yTQqe8mK.js","assets/scroll-area-CQqIifit.js","assets/index-BdQq_4o_.js","assets/tabs-BPjkxcD3.js","assets/useTakeaways-D2_f93iz.js","assets/loader-circle-1Bx4RXXa.js","assets/checkbox-Cfmm6H11.js","assets/slider-CCOiAVVm.js","assets/pause-gwqaV14C.js","assets/volume-2-XjlqVQna.js","assets/play-DE4Y1dwb.js","assets/audioConfig-CIF8aJ5H.js","assets/useExerciseUnlock-CUbYfnmx.js","assets/index-G3mBfB5K.js","assets/sheet-BXudfGqI.js","assets/separator-CCSMXAVa.js","assets/chevron-up-CFktBm-Y.js","assets/tag-C7uC9k-z.js","assets/grip-vertical-WAovdFe3.js","assets/circle-x-CMydH5nH.js","assets/credit-card-CpJ_TOoH.js","assets/formatDistanceToNow-B6PLL45-.js","assets/differenceInCalendarMonths-J4e-Wy77.js","assets/endOfMonth-DUe1Is3P.js","assets/message-square-BXXFe5gc.js","assets/useBooks-FXO34e6t.js","assets/library-Dk4TD-qo.js","assets/useJournalPrompts--UZk5RQh.js","assets/useJournalEntries-CmDJ8AW9.js","assets/moonPhase-DC7JNr3X.js","assets/safetyScreen-BzQlmoP5.js","assets/useDreamPatterns-D2Ol7xHY.js","assets/file-text-C_yHLUb1.js","assets/parseJourneyEntry-B5EpUkML.js","assets/footprints-iHCd6DI8.js","assets/usePathways-CKM4F2Ui.js","assets/useCancelPathway-DgA04eNp.js","assets/accents-DgHhV-8h.js","assets/useWeeklyGoal-DuuYEKqs.js","assets/starterPathways-C-lL1DqX.js","assets/scheduleItemNavigation-CueqjKl_.js","assets/calendar-days-DIddMvKi.js","assets/useDreamThreads-DR1ORy_r.js","assets/nextThreadStep-CY6zofig.js","assets/todayEvents-BjQBNCby.js","assets/useInnerMapArcs-CCEkS02P.js","assets/ContextualHint-BG0XBWyH.js","assets/log-out-DScj85iP.js","assets/crown-DIo5wO80.js","assets/AchievementsGrid-CJEGhLFe.js","assets/shield-CwaoLt83.js"])))=>i.map(i=>d[i]);
2import{c as ns,r as v,u as Se,s as S,l as re,j as e,T as Oe,S as P,a as L,C as De,B as E,g as ls,b as se,L as Fe,d as B,e as oe,f as Ae,h as ce,i as Y,k as we,m as te,n as fa,o as $e,X as Me,D as ae,p as os,R as wa,q as st,P as ja,t as cs,J as Z,v as ee,E as va,w as le,x as _e,y as ya,z as Na,A as _a,F as Ee,_ as ds,G as ms,H as ot,I as ka,K as Ca,M as at,N as Sa}from"./index-NrhgnKM2.js";import{u as us,L as xs}from"./Layout-BsTUDy1T.js";import{C as $,a as T,b as z,c as G}from"./card-CpYsnecR.js";import{S as _}from"./skeleton-B2eA3LAZ.js";import{e as Da,g as ct,a as Aa}from"./exercises-C0kzO3v3.js";import{u as Ge,Z as $a}from"./useTodaysSchedule-0psm9_R5.js";import{u as gt,a as Ma}from"./useFeatureUnlock-tyaG83Vk.js";import{D as hs,a as ps,b as gs,c as bs}from"./dialog-DvLekE7p.js";import{s as Be,f as me}from"./format-Dv5NrfM3.js";import{e as Ue}from"./endOfWeek-ZDBfWsiu.js";import{e as Ia,i as Ta,a as fs}from"./isYesterday-DeCyPna9.js";import{C as ye}from"./calendar-Cvp91RbG.js";import{T as ue}from"./target-CCu04NFr.js";import{C as be}from"./clock-C7ugPfmn.js";import{A as dt}from"./award-D0f3g6SA.js";import{T as fe}from"./trending-up-BUJ3MQuW.js";import{C as mt}from"./circle-check-big-4PjclZtg.js";import{E as ie}from"./external-link-B9lXGbF8.js";import{A as ut}from"./activity-BInW3Fyq.js";import{C as Ea}from"./circle-COW2nTW4.js";import{A as R}from"./arrow-right-jZJhC7nb.js";import{B as bt}from"./badge-CD8_Q4LX.js";import{u as Pa}from"./useExerciseData-CUIqzs15.js";import{H as ws}from"./heart-lLALTiB8.js";import{F as Ie}from"./flame-Cz161-bc.js";import{L as ge}from"./lightbulb-TTouwUng.js";import{P as Ce}from"./progress-BIvvFgy9.js";import{C as Ne}from"./circle-check-D9bn7KrW.js";import{M as ft}from"./moon-CpdcbyiL.js";import{G as Pe}from"./differenceInCalendarDays-CW8Zr1T3.js";import{S as Ra}from"./search-BCUzTZpM.js";import{C as Re}from"./compass-BFRTo7Ux.js";import{u as wt,a as za,b as qa,L as La,A as Oa}from"./useChapterProgress-CWreQedw.js";import{C as Fa}from"./credit-card-CpJ_TOoH.js";import{f as Ga}from"./formatDistanceToNow-B6PLL45-.js";import{M as Ba}from"./message-square-BXXFe5gc.js";import{u as Ua}from"./useBooks-FXO34e6t.js";import{L as Jt}from"./library-Dk4TD-qo.js";import{B as js}from"./bell-C3zUkV9Y.js";import{u as vs,a as Ye,b as Ya,c as Ka}from"./useJournalPrompts--UZk5RQh.js";import{u as Ha}from"./useJournalEntries-CmDJ8AW9.js";
2import{F as jt}from"./file-text-C_yHLUb1.js";import{M as Ja}from"./index-G3mBfB5K.js";import{i as vt}from"./isToday-vVbriFa5.js";import{u as ys}from"./useJourneys-CMDnfFj-.js";import{g as Ns}from"./index-c869O74J.js";import{p as _s,f as ks}from"./parseJourneyEntry-B5EpUkML.js";import{F as pe}from"./footprints-iHCd6DI8.js";import{d as Wa,S as Qa}from"./Navigation-B3EJNwa5.js";import{D as Va,a as Xa,b as Za,c as Wt}from"./dropdown-menu-Daq1ZBHh.js";import{A as Cs,a as Ss,b as Ds,c as As,d as $s,e as Ms,f as Is,g as Ts,h as er}from"./alert-dialog-BZJMh9Nt.js";import{u as Es,a as yt}from"./usePathways-CKM4F2Ui.js";import{u as tr}from"./useCancelPathway-DgA04eNp.js";import{g as Ps}from"./accents-DgHhV-8h.js";import{u as Nt}from"./useDreamPatterns-D2Ol7xHY.js";import{C as _t}from"./chevron-up-CFktBm-Y.js";import{C as Ke}from"./chevron-down-BOkNy-PH.js";import{u as sr}from"./useWeeklyGoal-DuuYEKqs.js";import{D as ar}from"./starterPathways-C-lL1DqX.js";import{g as rr}from"./scheduleItemNavigation-CueqjKl_.js";import{C as ir}from"./calendar-days-DIddMvKi.js";import{S as kt,a as Ct,b as St,c as Dt,d as nr}from"./sheet-BXudfGqI.js";import{r as Rs}from"./optInEvents-XNFqfXuK.js";import{u as lr}from"./useDreamThreads-DR1ORy_r.js";import{g as or}from"./nextThreadStep-CY6zofig.js";import{u as cr}from"./useExerciseUnlock-CUbYfnmx.js";import{R as At}from"./rotate-ccw-BW-MK5OC.js";import{t as zs,a as dr,b as mr,c as ur,d as Qt}from"./todayEvents-BjQBNCby.js";import{u as xr,a as hr,b as pr,c as gr,I as br}from"./useInnerMapArcs-CCEkS02P.js";import{C as fr}from"./ContextualHint-BG0XBWyH.js";import{b as wr}from"./audioConfig-CIF8aJ5H.js";import{L as jr}from"./log-out-DScj85iP.js";import{C as vr}from"./crown-DIo5wO80.js";import{P as yr}from"./pause-gwqaV14C.js";import{P as Nr}from"./pencil-SqDOLIAB.js";/**
3 * @license lucide-react v0.462.0 - ISC
4 *
5 * This source code is licensed under the ISC license.
6 * See the LICENSE file in the root directory of this source tree.
7 */const _r=ns("BookOpenCheck",[["path",{d:"M12 21V7",key:"gj6g52"}],["path",{d:"m16 12 2 2 4-4",key:"mdajum"}],["path",{d:"M22 6V4a1 1 0 0 0-1-1h-5a4 4 0 0 0-4 4 4 4 0 0 0-4-4H3a1 1 0 0 0-1 1v13a1 1 0 0 0 1 1h6a3 3 0 0 1 3 3 3 3 0 0 1 3-3h6a1 1 0 0 0 1-1v-1.3",key:"8arnkb"}]]);/**
8 * @license lucide-react v0.462.0 - ISC
9 *
10 * This source code is licensed under the ISC license.
11 * See the LICENSE file in the root directory of this source tree.
12 */const qs=ns("Scroll",[["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]]),Ls=()=>{const[t,s]=v.useState(null),[l,a]=v.useState(!0),{toast:n}=Se(),i=(c,m)=>({"pelvic-floor-lifting":["art-of-standing"],"sacral-chakra-processing":["art-of-standing","pelvic-floor-lifting"],"heart-chakra-opening":["art-of-standing","pelvic-floor-lifting","sacral-chakra-processing"],"throat-chakra-yawn":["art-of-standing","pelvic-floor-lifting"],"pineal-pressurization":["art-of-standing","pelvic-floor-lifting"],"third-eye-training":["art-of-standing","pelvic-floor-lifting"],"aura-gazing":["art-of-standing","pelvic-floor-lifting","third-eye-training"]}[c]||[]).every(x=>m.some(g=>g.exercise_id===x)),r=async()=>{var u;const{data:{user:c}}=await S.auth.getUser();if(!c)return{avgDuration:0,preferredTimeOfDay:null,recentExercises:[]};const m=new Date;m.setDate(m.getDate()-30);const{data:f}=await S.from("practice_sessions").select("exercise_id, duration_seconds, completed_at").eq("user_id",c.id).gte("completed_at",m.toISOString()).order("completed_at",{ascending:!1}).limit(20);if(!f||f.length===0)return{avgDuration:0,preferredTimeOfDay:null,recentExercises:[]};const h=f.reduce((b,w)=>b+w.duration_seconds,0)/f.length,x={morning:0,afternoon:0,evening:0};f.forEach(b=>{const w=new Date(b.completed_at).getHours();w<12?x.morning++:w<18?x.afternoon++:x.evening++});const g=(u=Object.entries(x).sort(([,b],[,w])=>w-b)[0])==null?void 0:u[0],o=f.slice(0,5).map(b=>b.exercise_id);return{avgDuration:h,preferredTimeOfDay:g,recentExercises:o}},p=(c,m,f,h)=>{let x=0,g=[];const o=m.find(y=>y.exercise_id===c.id),u=new Date;if(!o)return x+=100,g.push("New exercise to explore"),{score:x,reason:g.join(" • "),priority:"high"};const b=Math.floor((u.getTime()-new Date(o.last_completed).getTime())/(24*60*60*1e3));b>=30?(x+=80,g.push(`It's been ${b} days`)):b>=14?(x+=60,g.push(`Not practiced in ${b} days`)):b>=7&&(x+=40,g.push(`Last done ${b} days ago`)),o.times_completed<3?(x+=30,g.push("Build consistency")):o.times_completed<10&&(x+=20,g.pu
12sh("Deepen your practice")),f.includes(c.id)&&(x-=40);const w=parseInt(c.duration.split(" ")[0])||10,k=h/60;Math.abs(w-k)<=5&&(x+=15,g.push("Matches your typical session length")),c.category==="Foundation"&&(x+=10),m.length<5&&c.difficulty==="Beginner"&&(x+=25,g.push("Perfect for building your foundation"));let j="low";return x>=80?j="high":x>=50&&(j="medium"),{score:x,reason:g.join(" • ")||"Continue your practice journey",priority:j}},d=async c=>{const m=Da,{avgDuration:f,preferredTimeOfDay:h,recentExercises:x}=await r(),o=m.filter(b=>i(b.id,c)).map(b=>({exercise:b,...p(b,c,x,f)}));if(o.sort((b,w)=>w.score-b.score),o.length>0){const b=o[0];return{exercise:b.exercise,reason:b.reason,priority:b.priority}}return{exercise:ct("art-of-standing")||m[0],reason:"Perfect for today's practice",priority:"medium"}};return v.useEffect(()=>{const c=async()=>{try{const{data:{user:f}}=await S.auth.getUser();if(!f){a(!1);return}const{data:h,error:x}=await S.from("user_progress").select("*").eq("user_id",f.id);if(x)re.error("Error fetching user progress:",x),n({title:"Error",description:"Failed to load practice recommendation",variant:"destructive"});else{const g=await d(h||[]);s(g)}}catch(f){re.error("Error in fetchRecommendation:",f)}finally{a(!1)}};c();const m=()=>c();return window.addEventListener("user-progress-changed",m),()=>{window.removeEventListener("user-progress-changed",m)}},[n]),{recommendation:t,loading:l}},kr=({open:t,onOpenChange:s,weeklyGoal:l,sessionsThisWeek:a})=>{const[n,i]=v.useState([]),[r,p]=v.useState(0),[d,c]=v.useState(""),[m,f]=v.useState(0),[h,x]=v.useState(!0);v.useEffect(()=>{t&&g()},[t]);const g=async()=>{var K;const{data:{user:u}}=await S.auth.getUser();if(!u)return;const b=Be(new Date),w=Ue(new Date),{data:k,error:N}=await S.from("practice_sessions").select("exercise_id, completed_at, duration_seconds").eq("user_id",u.id).gte("completed_at",b.toISOString()).lte("completed_at",w.toISOString());if(N){re.error("Error fetching weekly stats:",N),x(!1);return}const y=Ia({start:b,end:w}).map(A=>{const U=new Date(A);U.setHours(0,0,0,0);const W=new Date(A);W.setHours(23,59,59,999);const H=(k==null?void 0:k.filter(V=>{const je=new Date(V.completed_at);return je>=U&&je<=W}))||[];return{date:A,count:H.length,totalMinutes:H.reduce((V,je)=>V+je.duration_seconds/60,0),exercises:H.map(V=>V.exercise_id)}});i(y);const D=(k==null?void 0:k.reduce((A,U)=>A+U.duration_seconds/60,0))||0;p(Math.round(D));const C={};k==null||k.forEach(A=>{C[A.exercise_id]=(C[A.exercise_id]||0)+1});const I=((K=Object.entries(C).sort(([,A],[,U])=>U-A)[0])==null?void 0:K[0])||"";c(I);let M=0;for(let A=y.length-1;A>=0;A--)if(y[A].count>0)M++;else if(new Date(y[A].date)<new Date)break;f(M),x(!1)},o=u=>u===0?"bg-white/5":u===1?"bg-green-400/30":u===2?"bg-green-400/60":"bg-green-400/90";return e.jsx(hs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"bg-slate-900/95 backdrop-blur-xl border-white/10 text-white max-w-2xl",children:[e.jsx(gs,{children:e.jsxs(bs,{className:"text-2xl bg-gradient-to-r from-purple-400 to-cyan-400 bg-clip-text text-transparent flex items-center gap-2",children:[e.jsx(ye,{className:"w-6 h-6 text-purple-400"}),"Weekly Practice Overview"]})}),h?e.jsx("div",{className:"py-8 text-center text-white/50",children:"Loading stats..."}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx($,{className:"bg-white/5 border-white/10",children:e.jsxs(T,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-white/60 text-sm mb-1",children:[e.jsx(ue,{className:"w-4 h-4"}),"Progress"]}),e.jsxs("div",{className:"text-2xl font-bold text-white",children:[a," / ",l]}),e.jsxs("div",{className:"text-xs text-white/50 mt-1",children:[Math.round(a/l*100),"% complete"]})]})}),e.jsx($,{className:"bg-white/5 border-white/10",children:e.jsxs(T,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-white/60 text-sm mb-1",children:[e.jsx(be,{className:"w-4 h-4"}),"Total Time"]}),e.jsxs("div",{className:"text-2xl font-bold text-white",children:[r,"m"]}),e.jsxs("div",{className:"text-xs text-white/50 mt-1",children:[Math.round(r/7),"m average/day"]})]})}),e.jsx($,{className:"bg-white/5 border-white/10",children:e.jsxs(T,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-white/60 text-sm mb-1",children:[e.jsx(Oe,{className:"w-4 h-4"}),"Current Streak"]}),e.jsxs("div",{className:"text-2xl font-bold text-white",children:[m," days"]}),e.jsx("div",{className:"text-xs text-white/50 mt-1",children:m>=3?"Keep it going! 🔥":"Build momentum"})]})}),e.jsx($,{className:"bg-white/5 border-white/10",children:e.jsxs(T,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-white/60 text-sm mb-1",children:[e.jsx(dt,{className:"w-4 h-4"}),"Most Practiced"]}),e.jsx("div",{className:"text-sm font-semibold text-white mt-1 truncate",children:d?d.replace(/-/g," ").replace(/\b\w/g,u=>u.toUpperCase()):"None yet"})]})})]}),e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-semibold text-white/80 mb-3 flex items-center gap-2",children:[e.jsx(fe,{className:"w-4 h-4"}),"Daily Activity"]}),e.jsx("div",{className:"grid grid-cols-7 gap-2",children:n.map((u,b)=>{const w=me(u.date,"yyyy-MM-dd")===me(new Date,"yyyy-MM-dd");return e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-xs text-white/50 mb-2",children:me(u.date,"EEE")}),e.jsxs("div",{className:`
13                          h-16 rounded-lg ${o(u.count)} 
14                          border ${w?"border-purple-400":"border-white/10"}
15                          flex flex-col items-center justify-center
16                          transition-all duration-200 hover:scale-105
17                        `,children:[e.jsx("div",{className:"text-lg font-bold text-white",children:u.count}),u.totalMinutes>0&&e.jsxs("div",{className:"text-[10px] text-white/50",children:[Math.round(u.totalMinutes),"m"]})]})]},b)})})]}),e.jsx($,{className:"bg-gradient-to-br from-purple-500/10 to-cyan-500/10 border-purple-400/20",children:e.jsx(T,{className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(P,{className:"w-5 h-5 text-yellow-400 flex-shrink-0 mt-0.5"}),e.jsx("div",{children:e.jsx("p",{className:"text-sm text-white/80",children:a>=l?"🎉 Amazing work! You've reached your weekly goal. Consider increasing it for next week!":a>=l*.75?"You're so close! Just a few more sessions to reach your goal.":a>0?`Great start! ${l-a} more sessions to reach your goal.`:"Every journey begins with a single step. Start your first session today!"})})]})})})]})]})})},Cr=({weeklyGoal:t,sessionsThisWeek:s,progress:l,weeklyLoading:a})=>{const{recommendation:n,loading:i}=Ls(),{isUnlocked:r,isLoading:p}=gt(),d=Ge(),c=L(),[m,f]=v.useState(!1),h=()=>{n!=null&&n.exercise&&c(`/exercises/${n.exercise.id}`)},x=N=>{if(N.item_type==="reminder"){const j=N.title.toLowerCase();j.includes("reading")?c("/learn?view=reference"):j.includes("study")?c("/learn?view=plans"):j.includes("practice")&&c("/exercises");return}if(N.item_id)switch(N.item_type){case"exercise":c(`/exercises/${N.item_id}`);break;case"article":let j={};try{N.description&&(j=JSON.parse(N.description))}catch{}j.isCategory?c(`/learn?categoryId=${encodeURIComponent(N.item_id)}`):c(`/learn?articleId=${N.item_id}`);break;case"chapter":let y={};try{N.description&&(y=JSON.parse(N.description))}catch{}if(y.isBook&&y.bookId)c(`/learn?view=reference&bookId=${y.bookId}`);else if(y.isCategory&&y.bookId&&y.categoryName){const D=y.categoryName.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"");c(`/learn?view=reference&bookId=${y.bookId}&scrollToCategory=${encodeURIComponent(D)}`)}else y.bookId?c(`/learn?view=reference&bookId=${y.bookId}&chapterId=${N.item_id}`):c(`/learn?view=reference&chapterId=${N.item_id}`);break;case"study":c(`/learn?view=plans&activateStudy=${N.item_id}`);break}},g=()=>{const N=new Date().getDay();return N===0?7:7-N},o=l>=100,u=g(),b=a||i||p,w=r&&d.hasScheduledItems,k=N=>{if(!N)return null;const[j,y]=N.split(":").map(Number),D=j>=12?"PM":"AM";return`${j%12||12}:${y.toString().padStart(2,"0")} ${D}`};return e.jsxs(e.Fragment,{children:[e.jsxs($,{variant:"glass-medium",sparkle:!1,glow:o?"green":w?"golden":"purple",className:"cosmic-surface-strip text-white hover:shadow-2xl hover:shadow-
17purple-500/20 transition-all duration-300 relative overflow-hidden group",children:[e.jsx("div",{className:`absolute inset-0 bg-gradient-to-br ${o?"from-green-500/8 via-purple-500/5 to-emerald-500/8":w?"from-amber-500/8 via-orange-500/5 to-yellow-500/8":"from-purple-500/8 via-cyan-500/5 to-pink-500/8"} opacity-0 group-hover:opacity-100 transition-opacity duration-500`}),o&&!a&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"absolute top-4 right-4 animate-bounce",style:{animationDelay:"0s"},children:e.jsx(P,{size:12,className:"text-green-400/60"})}),e.jsx("div",{className:"absolute top-8 right-8 animate-bounce",style:{animationDelay:"0.5s"},children:e.jsx(P,{size:8,className:"text-emerald-400/40"})})]}),e.jsx("div",{className:"absolute top-2 right-2 opacity-30 group-hover:opacity-60 transition-opacity",children:e.jsx(P,{size:14,className:w?"text-amber-400":"text-purple-400"})}),e.jsx(z,{className:"p-3 pb-2 md:p-6 md:pb-4 relative",children:e.jsxs("div",{className:"flex items-center gap-2 md:gap-3",children:[e.jsx("div",{className:"md:hidden",children:w?e.jsx(ye,{className:"text-amber-400 w-5 h-5"}):o?e.jsx(mt,{className:"h-5 w-5 text-green-400"}):e.jsx(ue,{className:"text-cyan-400 w-5 h-5"})}),e.jsxs("div",{className:"relative hidden md:block mr-1",children:[e.jsx("div",{className:`p-2.5 rounded-xl ${w?"bg-gradient-to-br from-amber-400/20 to-orange-400/20 border border-amber-400/30":o?"bg-gradient-to-br from-green-400/20 to-emerald-400/20 border border-green-400/30":"bg-gradient-to-br from-purple-400/20 to-cyan-400/20 border border-purple-400/30"} backdrop-blur-sm`,children:w?e.jsx(ye,{className:"text-amber-400 w-5 h-5"}):o?e.jsx(mt,{className:"h-5 w-5 text-green-400"}):e.jsx(ue,{className:"text-cyan-400 w-5 h-5"})}),e.jsx("div",{className:`absolute inset-0 rounded-xl ${w?"bg-amber-400/20":o?"bg-green-400/20":"bg-purple-400/20"} blur-xl`})]}),e.jsxs("div",{className:"flex-1",children:[e.jsxs(G,{className:`text-base md:text-lg bg-gradient-to-r ${w?"from-amber-400 to-orange-400":o?"from-green-400 to-emerald-400":"from-purple-400 via-cyan-400 to-pink-400"} bg-clip-text text-transparent flex items-center gap-2 cursor-pointer hover:opacity-80 transition-opacity group/title`,onClick:()=>c(w?"/exercises?view=schedule":"/exercises"),children:[w?"Today's Schedule":"Weekly Practice",e.jsx(ie,{size:14,className:"text-white/40 group-hover/title:text-white/60 transition-colors opacity-0 group-hover/title:opacity-100"}),o&&!w&&e.jsx("span",{className:"text-green-400 text-sm",children:"✓"})]}),e.jsxs("div",{className:"flex items-center justify-between mt-1",children:[e.jsx("p",{className:"text-sm text-white/60 flex items-center gap-2",children:b?e.jsx("span",{className:"animate-pulse",children:"Loading..."}):w?e.jsxs(e.Fragment,{children:[e.jsx(ut,{size:12,className:"text-white/40"}),e.jsx("span",{className:"font-medium text-white/80",children:d.completedCount}),e.jsx("span",{children:"of"}),e.jsx("span",{className:"font-medium text-white/80",children:d.totalCount}),e.jsx("span",{children:"completed"})]}):e.jsxs(e.Fragment,{children:[e.jsx(fe,{size:12,className:"text-white/40"}),e.jsx("span",{className:"font-medium text-white/80",children:s}),e.jsx("span",{children:"of"}),e.jsx("span",{className:"font-medium text-white/80",children:t}),e.jsx("span",{children:"sessions"})]})}),!b&&w&&d.upcomingItem&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(be,{size:12,className:"text-amber-400"}),e.jsx("span",{className:"text-xs text-amber-400",children:d.minutesUntilNext!==null&&d.minutesUntilNext>0?`in ${d.minutesUntilNext}m`:"Now"})]}),!b&&!w&&n&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(ut,{size:12,className:"text-purple-400"}),e.jsx("span",{className:"text-xs text-purple-400",children:"Ready"})]})]})]})]})}),e.jsx(T,{className:"p-3 md:p-6 space-y-2 md:space-y-4 relative",children:w?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2",children:[d.items.slice(0,4).map(N=>{var j,y;return e.jsxs("div",{onClick:()=>x(N),className:`flex items-center gap-3 p-2.5 rounded-lg border transition-all duration-200 cursor-pointer ${N.is_completed?"bg-green-400/10 border-green-400/20 opacity-70":N.id===((j=d.upcomingItem)==null?void 0:j.id)?"bg-amber-400/15 border-amber-400/30 ring-1 ring-amber-400/20":"bg-white/5 border-white/10 hover:bg-white/10"}`,children:[e.jsx("div",{className:"flex-shrink-0",children:N.is_completed?e.jsx("div",{className:"w-5 h-5 rounded-full bg-green-400/20 flex items-center justify-center",children:e.jsx(De,{size:12,className:"text-green-400"})}):N.id===((y=d.upcomingItem)==null?void 0:y.id)?e.jsx("div",{className:"w-5 h-5 rounded-full bg-amber-400/20 flex items-center justify-center animate-pulse",children:e.jsx(Oe,{size:12,className:"text-amber-400"})}):e.jsx("div",{className:"w-5 h-5 rounded-full border border-white/20 flex items-center justify-center",children:e.jsx(Ea,{size:10,
17className:"text-white/30"})})}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("p",{className:`text-sm font-medium truncate ${N.is_completed?"text-white/50 line-through":"text-white/90"}`,children:[e.jsx("span",{className:"mr-1.5",children:N.icon}),N.title]})}),N.scheduled_time&&e.jsx("span",{className:"text-xs text-white/50 flex-shrink-0",children:k(N.scheduled_time)})]},N.id)}),d.items.length>4&&e.jsxs(E,{variant:"ghost",size:"sm",className:"w-full text-amber-400/70 hover:text-amber-400 hover:bg-amber-400/10",onClick:()=>c("/exercises?view=schedule"),children:["+",d.items.length-4," more items",e.jsx(R,{size:14,className:"ml-1"})]})]}),e.jsxs("div",{className:"space-y-2 pt-2",children:[e.jsx("div",{className:"h-2 bg-white/5 rounded-full overflow-hidden backdrop-blur-sm border border-white/10",children:e.jsx("div",{className:"h-full rounded-full transition-all duration-700 ease-out bg-gradient-to-r from-amber-400 via-orange-400 to-yellow-400 relative overflow-hidden",style:{width:`${d.totalCount>0?d.completedCount/d.totalCount*100:0}%`},children:e.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-transparent via-white/30 to-transparent animate-shimmer"})})}),e.jsxs("div",{className:"flex justify-between text-xs",children:[e.jsx("span",{className:"text-white/50",children:"Today's progress"}),e.jsxs("span",{className:"text-amber-400 font-medium",children:[Math.round(d.completedCount/Math.max(d.totalCount,1)*100),"%"]})]})]}),e.jsx("div",{className:"flex gap-2 pt-2",children:e.jsx(E,{className:"flex-1 h-9 bg-gradient-to-r from-amber-500 to-orange-500 hover:from-amber-600 hover:to-orange-600 text-white border-0 shadow-lg shadow-amber-500/25 hover:shadow-amber-500/40 transition-all duration-300 text-sm",onClick:()=>c("/exercises?view=schedule"),children:"View Full Schedule"})})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2 cursor-pointer group/progress",onClick:()=>f(!0),title:"Click to view detailed stats",children:[e.jsx("div",{className:"relative",children:e.jsx("div",{className:"h-2.5 bg-white/5 rounded-full overflow-hidden backdrop-blur-sm border border-white/10 group-hover/progress:border-white/20 transition-all duration-200",children:e.jsx("div",{className:`h-full rounded-full transition-all duration-700 ease-out relative overflow-hidden ${o?"bg-gradient-to-r from-green-400 via-emerald-400 to-green-400":"bg-gradient-to-r from-purple-400 via-cyan-400 to-pink-400"}`,style:{width:`${a?0:Math.min(l,100)}%`},children:e.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-transparent via-white/30 to-transparent animate-shimmer"})})})}),e.jsxs("div",{className:"flex justify-between items-center text-xs group-hover/progress:text-white/70 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ye,{size:10,className:"text-white/40"}),e.jsx("span",{className:"text-white/50",children:"This week"}),!a&&!o&&e.jsxs("span",{className:"text-white/40",children:["• ",u," day",u!==1?"s":""," left"]}),e.jsx("span",{className:"text-white/30 ml-1 opacity-0 group-hover/progress:opacity-100 transition-opacity",children:"(click for details)"})]}),e.jsx("span",{className:`font-bold ${o?"text-green-400":l>=75?"text-cyan-400":l>=50?"text-purple-400":"text-white/70"}`,children:a?"...":`${Math.round(l)}%`})]})]}),i?e.jsxs("div",{className:"space-y-3 p-3 bg-white/5 rounded-xl border border-white/10",children:[e.jsx(_,{className:"h-4 w-3/4 bg-white/10"}),e.jsx(_,{className:"h-3 w-full bg-white/10"}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(_,{className:"h-4 w-16 bg-white/10"}),e.jsx(_,{className:"h-5 w-20 rounded-full bg-white/10"})]})]}):n?e.jsxs("div",{className:"bg-white/5 backdrop-blur-sm rounded-xl p-3 border border-white/10 hover:bg-white/8 transition-all duration-200",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("h3",{className:"font-medium text-sm flex items-center gap-2 text-white/90",children:[e.jsx("span",{className:"text-lg",children:n.exercise.icon}),e.jsx("span",{className:"bg-gradient-to-r from-white/90 to-white/70 bg-clip-text text-transparent",children:n.exercise.title})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(be,{size:12,className:"text-blue-400"}),e.jsx("span",{className:"text-xs text-white/70",children:n.exercise.duration})]})]}),e.jsx("p",{className:"text-xs text-white/60 mb-2 leading-relaxed line-clamp-2",children:n.exercise.description}),e.jsx("div",{className:"bg-purple-400/10 backdrop-blur-sm rounded-lg p-2 border border-purple-400/20 mb-3",children:e.jsxs("p",{className:"text-xs text-purple-300 flex items-start gap-2",children:[e.jsx(P,{size:12,className:"text-purple-400 mt-0.5 flex-shrink-0"}),e.jsx("span",{className:"italic",children:n.reason})]})}),e.jsxs(E,{className:"w-full h-9 bg-gradient-to-r from-purple-500 to-pink-500 hover:from-purple-600 hover:to-pink-600 text-white border-0 shadow-lg shadow-purple-500/25 hover:shadow-
17purple-500/40 transition-all duration-300 group/btn relative overflow-hidden text-sm",onClick:h,children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-transparent via-white/20 to-transparent -translate-x-full group-hover/btn:translate-x-full transition-transform duration-700"}),e.jsxs("span",{className:"relative flex items-center justify-center gap-2 font-medium",children:["Start Practice",e.jsx(R,{size:14,className:"group-hover/btn:translate-x-1 transition-transform"})]})]})]}):e.jsx("div",{className:"bg-white/5 rounded-xl p-3 border border-white/10 text-center",children:e.jsx("p",{className:"text-xs text-white/50",children:"No practice recommendation available"})}),!a&&e.jsx("div",{className:`rounded-lg p-2 border text-center ${o?"bg-green-400/10 border-green-400/30":l>=50?"bg-purple-400/10 border-purple-400/30":"bg-white/5 border-white/10"} backdrop-blur-sm`,children:o?e.jsxs("p",{className:"text-xs font-medium text-green-400 flex items-center justify-center gap-2",children:[e.jsx("span",{children:"🎉"}),"Goal completed! Keep the momentum!",e.jsx("span",{children:"🎉"})]}):l>=75?e.jsxs("p",{className:"text-xs text-cyan-400",children:["Almost there! Just ",t-s," more session",t-s!==1?"s":""," to go!"]}):l>=50?e.jsx("p",{className:"text-xs text-purple-400",children:"Great progress! Today's practice will get you closer!"}):e.jsx("p",{className:"text-xs text-white/60",children:s===0?"Start your first exercise session today!":`${t-s} sessions to reach your goal`})})]})})]}),e.jsx(kr,{open:m,onOpenChange:f,weeklyGoal:t,sessionsThisWeek:s})]})},Sr=()=>{const{sessions:t,loading:s}=Pa(2),l=i=>{const r=Math.floor(i/60),p=i%60;return r>0?`${r}m ${p}s`:`${p}s`},a=i=>{const r=new Date(i),d=Math.floor((new Date().getTime()-r.getTime())/(1e3*60*60));return d<24?`${d}h ago`:`${Math.floor(d/24)}d ago`},n=i=>["😞","😐","😊","😁","😍"][i-1]||"😊";return s?e.jsxs($,{variant:"glass-medium",sparkle:!0,glow:"blue",className:"bg-slate-900/40 backdrop-blur-md border-white/10 text-white hover:shadow-2xl hover:shadow-blue-500/20 transition-all duration-300",children:[e.jsx(z,{className:"p-3 pb-2 md:p-6 md:pb-4",children:e.jsx(G,{className:"text-base md:text-lg bg-gradient-to-r from-blue-400 to-cyan-400 bg-clip-text text-transparent",children:"Recent Progress"})}),e.jsx(T,{className:"p-3 md:p-6",children:e.jsx("div",{className:"space-y-3",children:[1,2].map(i=>e.jsx("div",{className:"bg-white/5 animate-pulse rounded-lg h-16 backdrop-blur-sm"},i))})})]}):e.jsxs($,{variant:"glass-medium",sparkle:!0,glow:"blue",className:"bg-slate-900/40 backdrop-blur-md border-white/10 text-white hover:shadow-2xl hover:shadow-blue-500/20 transition-all duration-300",children:[e.jsx(z,{className:"p-3 pb-2 md:p-6 md:pb-4",children:e.jsx(G,{className:"text-base md:text-lg bg-gradient-to-r from-blue-400 to-cyan-400 bg-clip-text text-transparent",children:"Recent Progress"})}),e.jsx(T,{className:"p-3 md:p-6",children:t.length===0?e.jsxs("div",{className:"text-center py-6",children:[e.jsx("p",{className:"text-white/70",children:"No practice sessions yet"}),e.jsx("p",{className:"text-sm text-white/50 mt-1",children:"Start your first practice to see your progress here"})]}):e.jsx("div",{className:"space-y-3",children:t.map(i=>e.jsxs("div",{className:"bg-white/5 backdrop-blur-sm rounded-lg p-3 border border-white/10 hover:bg-white/10 hover:border-white/20 transition-all duration-200 group",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("h4",{className:"font-medium text-sm capitalize text-white/90 group-hover:text-white transition-colors",children:i.exercise_id.replace(/[-_]/g," ")}),e.jsx("span",{className:"text-xs text-white/50",children:a(i.completed_at)})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3 text-xs text-white/60",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(be,{size:12,className:"text-blue-400"}),l(i.duration_seconds)]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ws,{size:12,className:"text-pink-400"}),n(i.mood_rating)]})]}),e.jsx(bt,{variant:"secondary",className:"text-xs bg-green-500/20 text-green-400 border-green-400/30 backdrop-blur-sm",children:"Completed"})]}),i.notes&&e.jsxs("p",{className:"text-xs text-white/40 mt-2 italic border-l-2 border-white/20 pl-2",children:['"',i.notes,'"']})]},i.id))})})]})},Dr=({streak:t})=>{const s=t>10?"#f1c40f":"#3498db";return e.jsx("div",{className:"w-16 h-16 rounded-full flex items-center justify-center text-white font-bold text-xl",style:{background:`radial-gradient(circle, ${s} 0%, transparent 70%)`,boxShadow:`0 0 15px ${s}`},children:t})},He=({sessions:t})=>{const l=(()=>{const a=ls("Resources/");return t>=100?{badgeUrl:`${a}Master_badge.svg`,title:"Master",color:"#f59e0b",numberPosition:{top:"43%"}}:t>=50?{badgeUrl:`${a}Expert_badge.svg`,title:"Expert",color:"#8b5cf6",numberPosition:{top:"44%"}}:t>=20?{badgeUrl:`${a}Advanced_badge (1).svg`,title:"Advanced",color:"#06b6d4",numberPosition:{top:"44%"}}:t>=10?{badgeUrl:`${a}Intermediate_badge.svg`,title:"Intermediate",color:"#10b981",numberPosition:{top:"42%"}}:{badgeUrl:`${a}Beginner_badge.svg`,title:"Beginner",color:"#84cc16",numberPosition:{top:"42%"}}})();return e.jsxs("div",{className:"relative w-20 h-20 flex items-center justify-center",children:[e.jsx("img",{src:l.badgeUrl,alt:`${l.t
17itle} Badge`,style:{width:"96px",height:"96px",transform:"scale(2.2)",filter:`drop-shadow(0 4px 8px ${l.color}40)`,background:`radial-gradient(circle, ${l.color} 0%, transparent 32%)`}}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-white font-bold text-xl",style:{...l.numberPosition,left:"50%",transform:"translate(-50%, -50%)",textShadow:"1px 1px 2px rgba(0,0,0,0.8)"},children:t})]})},Ar=({categoryProgress:t,loading:s,onTitleClick:l,onCategoryClick:a,currentStreak:n=0,totalSessions:i=0,statsLoading:r=!1,nextUnlockHint:p,emotionalMinutes:d=0,requiredEmotionalMinutes:c=120})=>{if(s)return e.jsxs($,{variant:"glass-medium",sparkle:!0,glow:"purple",className:"bg-slate-900/40 backdrop-blur-md border-white/10 text-white",children:[e.jsx(z,{className:"p-3 pb-2 md:p-6 md:pb-4",children:e.jsxs("div",{className:"flex items-start justify-between mb-4",children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("div",{className:"flex items-center gap-2 md:gap-3 mb-2",children:[e.jsx(_,{className:"h-5 w-5 rounded bg-white/10 md:hidden"}),e.jsx(_,{className:"hidden md:block h-10 w-10 rounded-xl bg-white/10"}),e.jsx(_,{className:"h-5 w-36 bg-white/10 rounded"})]}),e.jsx(_,{className:"h-6 w-28 bg-white/5 rounded-full"})]}),e.jsxs("div",{className:"flex items-end gap-6",children:[e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx(_,{className:"w-16 h-16 rounded-full bg-white/10 mb-1"}),e.jsx(_,{className:"h-3 w-16 bg-white/10 rounded"})]}),e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx(_,{className:"w-20 h-20 rounded-full bg-white/10 mb-1"}),e.jsx(_,{className:"h-3 w-16 bg-white/10 rounded"})]})]})]})}),e.jsxs(T,{className:"p-4 md:p-6",children:[e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3 md:gap-4",children:[1,2,3,4].map(x=>e.jsxs("div",{className:"bg-white/5 rounded-lg p-3 border border-white/10",children:[e.jsx(_,{className:"h-4 w-20 bg-white/10 rounded mb-2"}),e.jsx(_,{className:"h-5 w-12 bg-white/10 rounded mb-2"}),e.jsx(_,{className:"h-1 w-full bg-white/10 rounded-full"})]},x))}),e.jsx("div",{className:"mt-4 pt-4 border-t border-white/10",children:e.jsx(_,{className:"h-2 w-full bg-white/10 rounded-full"})})]})]});const m=t.reduce((x,g)=>x+g.total,0),f=t.reduce((x,g)=>x+g.completed,0),h=m>0?Math.round(f/m*100):0;return e.jsxs($,{variant:"glass-medium",sparkle:!0,glow:"purple",className:"bg-slate-900/40 backdrop-blur-md border-white/10 text-white hover:shadow-2xl hover:shadow-purple-500/20 transition-all duration-300 animate-fade-in",children:[e.jsx(z,{className:"p-3 pb-2 md:p-6 md:pb-4",children:e.jsxs("div",{className:"flex items-start justify-between mb-4",children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("div",{className:"flex items-center gap-2 md:gap-3 mb-2",children:[e.jsx(fe,{className:"text-purple-400 md:hidden",size:20}),e.jsxs("div",{className:"relative hidden md:block",children:[e.jsx("div",{className:"p-2.5 rounded-xl bg-gradient-to-br from-purple-400/20 to-pink-400/20 border border-purple-400/30 backdrop-blur-sm",children:e.jsx(fe,{className:"text-purple-400",size:20})}),e.jsx("div",{className:"absolute inset-0 rounded-xl bg-purple-400/20 blur-xl"})]}),e.jsxs(G,{className:`text-base md:text-lg bg-gradient-to-r from-purple-400 to-pink-400 bg-clip-text text-transparent flex items-center gap-2 ${l?"cursor-pointer hover:opacity-80 transition-opacity group":""}`,onClick:l,children:["Exercise Progress",l&&e.jsx(ie,{size:14,className:"text-white/40 group-hover:text-white/60 transition-colors opacity-0 group-hover:opacity-100"})]})]}),e.jsxs("span",{className:"text-sm font-normal text-white/70 bg-white/5 px-3 py-1 rounded-full w-fit",children:[h,"% Complete"]})]}),e.jsxs("div",{className:"flex items-end gap-6",children:[e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx("div",{className:"h-20 flex items-center justify-center mb-1",children:r?e.jsx(_,{className:"w-16 h-16 rounded-full bg-white/10"}):e.jsx(Dr,{streak:n})}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Ie,{size:12,className:"text-orange-400"}),e.jsx("span",{className:"text-xs text-white/60 font-medium",children:"Current Streak"})]})]}),e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx("div",{className:"h-20 flex items-center justify-center mb-1",children:r?e.jsx(_,{className:"w-20 h-20 rounded-full bg-white/10"}):e.jsx(He,{sessions:i})}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(se,{size:12,className:"text-yellow-400"}),e.jsx("span",{className:"text-xs text-white/60 font-medium",children:"Total Sessions"})]})]})]})]})}),e.jsxs(T,{className:"p-4 md:p-6",children:[e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3 md:gap-4",children:t.map(x=>e.jsxs("div",{className:`
18                relative bg-white/5 backdrop-blur-sm rounded-lg p-3 border 
19                ${x.percentage===100?"border-green-400/30 bg-green-400/5":"border-white/10 hover:bg-white/10"} 
20                transition-all duration-200 group
21                ${a?"cursor-pointer":""}
22              `,onClick:()=>a==null?void 0:a(x.category),children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"font-medium text-sm text-white/90 capitalize",children:x.category}),x.percentage===100?e.jsx(mt,{size:16,className:"text-green-400"}):e.jsx($a,{size:16,className:"text-yellow-400 opacity-50 group-hover:opacity-100 transition-opacity"})]}),e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("span",{className:`text-lg font-semibold ${x.percentage===100?"text-green-400":"text-white/80"}`,children:[x.completed,"/",x.total]}),e.jsxs("span",{className:"text-xs text-white/50",children:[x.percentage,"%"]})]}),e.jsx("div",{className:"h-1 bg-white/10 rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full transition-all duration-500 ${x.percentage===100?"bg-gradient-to-r from-green-400 to-emerald-400":"bg-gradient-to-r from-purple-400 to-pink-400"}`,style:{width:`${x.percentage}%`}})}),x.percentage===100&&e.jsx("div",{className:"absolute -top-1 -right-1",children:e.jsx("div",{className:"bg-green-400 text-black text-xs font-bold px-2 py-0.5 rounded-full shadow-lg shadow-green-400/50",children:"✓"})})]},x.category))}),e.jsxs("div",{className:"mt-4 pt-4 border-t border-white/10",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-xs text-white/60",children:"Overall Progress"}),e.jsxs("span",{className:"text-xs text-white/80 font-medium",children:[f," of ",m," exercises"]})]}),e.jsx("div",{className:"h-2 bg-white/10 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-gradient-to-r from-purple-400 via-pink-400 to-purple-400 rounded-full transition-all duration-700 animate-pulse",style:{width:`${h}%`}})})]}),p&&!p.complete&&p.requirements&&(()=>{const x=p.requirements.find(o=>!o.complete),g=x?`Complete ${x.required-x.current} more ${x.name.toLowerCase()} to reach ${p.tierName}`:p.specialRequirement&&!p.specialRequirementComplete?`${p.specialRequirement} to reach ${p.tierName}`:null;return g?e.jsx("div",{className:"mt-3 pt-3 border-t border-white/10",children:e.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded-lg bg-amber-400/5 border border-amber-400/10",children:[e.jsx(Fe,{size:12,className:"text-amber-400 shrink-0"}),e.jsxs("span",{className:"text-xs text-amber-200/80",children:["Next: ",g]}),e.jsx(P,{size:10,className:"text-amber-400/50 shrink-0 ml-auto"})]})}):null})(),d<c&&e.jsx("div",{className:"mt-3 pt-3 border-t border-white/10",children:e.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded-lg bg-pink-400/5 border border-pink-400/10",children:[e.jsx(ws,{size:12,className:"text-pink-400 shrink-0"}),e.jsxs("span",{className:"text-xs text-pink-300/80",children:["Advanced: Complete ",c-d," more emotional exercise minutes (",d,"/",c,")"]})]})}),(p==null?void 0:p.complete)&&d>=c&&e.jsx("div",{className:"mt-3 pt-3 border-t border-white/10",children:e.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded-lg bg-green-400/5 border border-green-400/10",children:[e.jsx(P,{size:12,className:"text-green-400 shrink-0"}),e.jsx("span",{className:"text-xs text-green-300/80",children:"All exercises unlocked!"})]})})]})]})},$r={schedule:{from:"from-cyan-400/20",to:"to-blue-400/20",ring:"border-cyan-400/30",text:"text-cyan-300"},journal:{from:"from-emerald-400/20",to:"to-teal-400/20",ring:"border-emerald-400/30",text:"text-emerald-300"},goal:{from:"from-orange-400/20",to:"to-red-400/20",ring:"border-orange-400/30",text:"text-orange-300"},natal:{from:"from-violet-400/20",to:"to-purple-400/20",ring:"border-violet-400/30",text:"text-violet-300"},dream:{from:"from-indigo-400/20",to:"to-purple-400/20",ring:"border-indigo-400/30",text:"text-indigo-300"},practice:{from:"from-rose-400/20",to:"to-pink-400/20",ring:"border-rose-400/30",text:"text-rose-300"}
22,reading:{from:"from-sky-400/20",to:"to-cyan-400/20",ring:"border-sky-400/30",text:"text-sky-300"},tier:{from:"from-amber-400/20",to:"to-yellow-400/20",ring:"border-amber-400/30",text:"text-amber-300"},general:{from:"from-yellow-400/20",to:"to-orange-400/20",ring:"border-yellow-400/30",text:"text-yellow-400"}},Mr=({suggestedNextStep:t,motivationalMessage:s,loading:l,category:a="general",action:n})=>{const i=L(),r=$r[a];return l?e.jsx($,{variant:"glass-medium",sparkle:!0,glow:"golden",className:"bg-slate-900/40 backdrop-blur-md border-white/10",children:e.jsx(T,{className:"p-3 md:p-6",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(_,{className:"w-12 h-12 rounded-full bg-white/10"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx(_,{className:"h-5 w-24 bg-white/10"}),e.jsx(_,{className:"h-4 w-full bg-white/10"}),e.jsx(_,{className:"h-3 w-3/4 bg-white/10"})]})]})})}):e.jsxs($,{variant:"glass-medium",sparkle:!0,glow:"golden",className:"bg-slate-900/40 backdrop-blur-md border-white/10 hover:shadow-2xl hover:shadow-yellow-500/20 transition-all duration-300 relative overflow-hidden group",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-yellow-500/5 via-transparent to-orange-500/5 opacity-0 group-hover:opacity-100 transition-opacity duration-500"}),e.jsxs(T,{className:"p-3 md:p-6 relative",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"relative",children:e.jsxs("div",{className:"relative w-12 h-12 flex items-center justify-center",children:[e.jsxs("div",{className:`absolute inset-0 rounded-full border ${r.ring} animate-spin`,style:{animationDuration:"10s"},children:[e.jsx("div",{className:`absolute w-1 h-1 ${r.text.replace("text-","bg-")} rounded-full -top-0.5 left-1/2 -translate-x-1/2`}),e.jsx("div",{className:`absolute w-1 h-1 ${r.text.replace("text-","bg-")} rounded-full -bottom-0.5 left-1/2 -translate-x-1/2 opacity-70`})]}),e.jsxs("div",{className:"absolute inset-1 animate-spin",style:{animationDuration:"7s",animationDirection:"reverse"},children:[e.jsx(P,{size:8,className:`absolute ${r.text} opacity-60`,style:{top:"2px",right:"2px"}}),e.jsx(P,{size:6,className:`absolute ${r.text} opacity-50`,style:{bottom:"2px",left:"2px"}})]}),e.jsx("div",{className:`relative z-10 p-2.5 rounded-full bg-gradient-to-br ${r.from} ${r.to} backdrop-blur-sm border ${r.ring}`,children:e.jsx(ge,{size:18,className:`${r.text} drop-shadow-lg`})}),e.jsx("div",{className:`absolute inset-0 rounded-full bg-gradient-to-r ${r.from} ${r.to} blur-xl animate-pulse`})]})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("h3",{className:"text-sm font-semibold bg-gradient-to-r from-yellow-400 to-orange-400 bg-clip-text text-transparent mb-2 flex items-center gap-1",children:["Smart Tip",e.jsx(R,{size:14,className:"text-yellow-400/60 animate-pulse"})]}),e.jsx("div",{className:"bg-white/5 backdrop-blur-sm rounded-lg p-2.5 border border-white/10 mb-2 group-hover:bg-white/10 transition-all duration-200",children:e.jsx("p",{className:"text-sm font-medium text-white/90 leading-relaxed",children:t})}),e.jsxs("div",{className:"flex items-start gap-1.5",children:[e.jsx("span",{className:"text-xs",children:"✨"}),e.jsx("p",{className:"text-xs text-white/60 italic leading-relaxed",children:s})]}),n&&e.jsxs(E,{size:"sm",variant:"ghost",onClick:()=>i(n.route),className:`mt-3 h-7 px-2 text-xs ${r.text} hover:text-white hover:bg-white/10`,children:[n.label,e.jsx(R,{size:12,className:"ml-1"})]})]})]}),e.jsx("div",{className:"absolute -bottom-1 -right-1 w-16 h-16 bg-gradient-to-tl from-yellow-400/10 to-transparent rounded-tl-full pointer-events-none"})]})]})},Ir=({totalArticles:t,readArticles:s,overallProgress:l,categoryProgress:a,articlesReadThisWeek:n,learningStreak:i,loading:r=!1})=>{const p=L(),d=a.filter(f=>f.percentage===100).length,c=()=>{p("/learn")},m=(f,h)=>{p(`/learn?categoryId=${encodeURIComponent(f)}`)};return r?e.jsxs($,{variant:"glass-medium",sparkle:!0,glow:"blue",className:"bg-slate-900/40 backdrop-blur-md border-white/10 text-white",children:[e.jsx(z,{className:"p-3 pb-2 md:p-6 md:pb-4",children:e.jsxs("div",{className:"flex items-center gap-2 md:gap-3",children:[e.jsx(B,{size:20,className:"text-indigo-400 md:hidden"}),e.jsxs("div",{className:"relative hidden md:block",children:[e.jsx("div",{className:"p-2.5 rounded-xl bg-gradient-to-br from-indigo-400/20 to-purple-400/20 border border-indigo-400/30 backdrop-blur-sm",children:e.jsx(B,{size:20,className:"text-indigo-400"})}),e.jsx("div",{className:"absolute inset-0 rounded-xl bg-indigo-400/20 blur-xl"})]}),e.jsx(G,{className:"text-base md:text-lg bg-gradient-to-r from-indigo-400 to-purple-400 bg-clip-text text-transparent flex items-center gap-2",children:"Article Progress"})]})}),e.jsx(T,{className:"p-3 md:p-6",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(_,{className:"h-4 w-full"}),e.jsx(_,{className:"h-3 w-3/4"}),e.jsx(_,{className:"h-20 w-full"})]})})]}):e.jsxs($,{variant:"glass-medium",sparkle:!0,glow:"blue",className:"bg-slate-900/40 backdrop-blur-md border-white/10 text-white hover:shadow-2xl hover:shadow-blue-500/20 transition-all duration-300",children:[e.jsx(z,{className:"p-3 pb-2 md:p-6 md:pb-4",children:e.jsxs("div",{className:"flex items-start justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 md:gap-3",children:[e.jsx(B,{size:20,className:"text-indigo-400 md:hidden"}),e.jsxs("div",{className:"relative hidden md:block",children:[e.jsx("div",{className:"p-2.5 rounded-xl bg-gradient-to-br from-indigo-400/20 to-purple-400/20 border border-indigo-400/30 backdrop-blur-sm",children:e.jsx(B,{size:20,className:"text-indigo-400"})}),e.jsx("div",{className:"absolute inset-0 rounded-xl bg-indigo-400/20 blur-xl"})]}),e.jsxs(G,{className:"text-base md:text-lg bg-gradient-to-r from-indigo-400 to-purple-400 bg-clip-text text-transparent flex items-center gap-2 cursor-pointer hover:from-indigo-300 hover:to-purple-300 transition-all duration-200 group",onClick:c,children:["Article Progress",e.jsx(ie,{size:14,className:"text-white/40 group-hover:text-white/60 transition-colors opacity-0 group-hover:opacity-100"})]})]}),e.jsxs("div",{className:"flex items-end gap-6",children:[e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx("div",{className:"h-20 flex items-center justify-center mb-1",children:e.jsx("div",{className:"w-16 h-16 rounded-full flex items-center justify-center text-white font-bold text-xl",style:{background:"radial-gradient(circle, #10b981 0%, transparent 70%)",boxShadow:"0 0 15px #10b98160"},children:d})}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Ne,{size:12,className:"text-emerald-400"}),e.jsx("span",{className:"text-xs text-white/60 font-medium",children:"Categories"})]})]}),e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx("div",{className:"h-20 flex items-center justify-center mb-1",children:e.jsx(He,{sessions:s})}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(B,{size:12,className:"text-indigo-400"}),e.jsx("span",{className:"text-xs text-white/60 font-medium",children:"Articles"})]})]})]})]})}),e.jsx(T,{className:"p-3 md:p-6",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-white/60",children:"Overall Completion"}),e.jsxs("span",{className:"text-lg font-semibold text-white/90",children:[s,"/",t]})]}),e.jsx(Ce,{value:l,className:"h-2 bg-white/10"}),e.jsxs("div",{className:"text-xs text-white/50 text-center",children:[l,"% complete"]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"bg-white/5 backdrop-blur-sm rounded-lg p-3 border border-white/10",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(fe,{size:14,className:"text-green-400"}),e.jsx("span",{className:"text-xs text-white/60",children:"This Week"})]}),e.jsx("div",{className:"text-lg font-semibold text-white/90",children:n})]}),e.jsxs("div",{className:"bg-white/5 backdrop-blur-sm rounded-lg p-3 border border-white/10",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(Ie,{size:14,className:"text-orange-400"}),e.jsx("span",{className:"text-xs text-white/60",children:"Streak"})]}),e.jsxs("div",{className:"text-lg font-semibold text-white/90",children:[i," days"]})]})]}),a.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("h4",{className:"text-sm font-medium text-white/70",children:"Categories"}),e.jsx("div",{className:"space-y-2",children:[...a].sort((f,h)=>{const x=f.percentage===100?1:0,g=h.percentage===100?1:0;return x-g}).slice(0,3).map(f=>e.jsxs("div",{className:"space-y-1 p-2 rounded-lg hover:bg-white/5 transition-all duration-200 cursor-pointer group",onClick:()=>m(f.categoryId,f.categoryName),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs text-white/60 truncate group-hover:text-white/80 transition-colors flex items-center gap-1",children:[f.categoryName,e.jsx(ie,{size:10,
22className:"opacity-0 group-hover:opacity-60 transition-opacity"})]}),e.jsxs("span",{className:"text-xs text-white/50 group-hover:text-white/70 transition-colors",children:[f.readArticles,"/",f.totalArticles]})]}),e.jsx(Ce,{value:f.percentage,className:"h-1 bg-white/10 group-hover:bg-white/15 transition-colors"})]},f.categoryId))}),a.length>3&&e.jsx("button",{onClick:c,className:"text-xs text-indigo-400 hover:text-indigo-300 transition-colors w-full text-center pt-2 border-t border-white/10",children:"View all categories →"})]})]})})]})},Tr=t=>{switch(t){case"article":return{icon:B,label:"Article",color:"bg-purple-400/20 text-purple-300",iconColor:"text-purple-400"};case"ai_study":return{icon:Ae,label:"AI Study",color:"bg-cyan-400/20 text-cyan-300",iconColor:"text-cyan-400"};case"lookup":return{icon:Ra,label:"Lookup",color:"bg-amber-400/20 text-amber-300",iconColor:"text-amber-400"};case"guided_study":return{icon:Pe,label:"Guided Study",color:"bg-emerald-400/20 text-emerald-300",iconColor:"text-emerald-400"};case"dream_interpretation":return{icon:ft,label:"Dream",color:"bg-indigo-400/20 text-indigo-300",iconColor:"text-indigo-400"};default:return{icon:ge,label:"Insight",color:"bg-white/10 text-white/70",iconColor:"text-white/60"}}},Er=t=>{if(t.source_type!=="article"&&t.ai_response)try{const s=JSON.parse(t.ai_response);if(s.symbolicInterpretation)return s.symbolicInterpretation;if(s.summary)return s.summary;if(s.response)return s.response;if(s.answer)return s.answer;if(typeof s=="string")return s}catch{if(typeof t.ai_response=="string"&&t.ai_response.length>0)return t.ai_response}return t.key_takeaway??void 0},Pr=({highlights:t,loading:s=!1})=>{const l=L();return s?e.jsxs($,{variant:"glass-medium",sparkle:!0,glow:"purple",className:"bg-slate-900/40 backdrop-blur-md border-white/10 text-white",children:[e.jsx(z,{className:"p-3 pb-2 md:p-6 md:pb-4",children:e.jsxs(G,{className:"text-base md:text-lg bg-gradient-to-r from-purple-400 to-pink-400 bg-clip-text text-transparent flex items-center gap-2",children:[e.jsx(ge,{size:20,className:"text-purple-400"}),"Recent Insights"]})}),e.jsx(T,{className:"p-3 md:p-6",children:e.jsx("div",{className:"space-y-3",children:[1,2,3].map(a=>e.jsxs("div",{className:"space-y-2",children:[e.jsx(_,{className:"h-4 w-full"}),e.jsx(_,{className:"h-3 w-3/4"})]},a))})})]}):t.length===0?e.jsxs($,{variant:"glass-medium",sparkle:!0,glow:"purple",className:"bg-slate-900/40 backdrop-blur-md border-white/10 text-white",children:[e.jsx(z,{className:"p-3 pb-2 md:p-6 md:pb-4",children:e.jsxs(G,{className:"text-base md:text-lg bg-gradient-to-r from-purple-400 to-pink-400 bg-clip-text text-transparent flex items-center gap-2",children:[e.jsx(ge,{size:20,className:"text-purple-400"}),"Recent Insights"]})}),e.jsx(T,{className:"p-3 md:p-6",children:e.jsxs("div",{className:"text-center py-4",children:[e.jsx("p",{className:"text-white/60 text-sm mb-3",children:"No insights captured yet"}),e.jsx(E,{size:"sm",className:"bg-gradient-to-r from-purple-500 to-pink-500 hover:from-purple-600 hover:to-pink-600 text-white border-0",onClick:()=>l("/learn"),children:"Start Reading"})]})})]}):e.jsxs($,{variant:"glass-medium",sparkle:!0,glow:"purple",className:"bg-slate-900/40 backdrop-blur-md border-white/10 text-white hover:shadow-2xl hover:shadow-purple-500/20 transition-all duration-300",children:[e.jsx(z,{className:"p-3 pb-2 md:p-6 md:pb-4",children:e.jsxs(G,{className:"text-base md:text-lg bg-gradient-to-r from-purple-400 to-pink-400 bg-clip-text text-transparent flex items-center gap-2",children:[e.jsx(ge,{size:20,className:"text-purple-400"}),"Recent Insights"]})}),e.jsxs(T,{className:"p-3 md:p-6",children:[e.jsx("div",{className:"space-y-3",children:t.map(a=>{var r,p,d;const n=Tr(a.source_type),i=n.icon;return e.jsxs("div",{className:"bg-white/5 backdrop-blur-sm rounded-lg p-3 border border-white/10 hover:bg-white/10 hover:border-purple-400/30 transition-all duration-200 cursor-pointer",onClick:()=>l(`/learn?view=insights&highlightId=${a.id}`),children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs(bt,{variant:"secondary",className:`${n.color} text-xs flex items-center gap-1`,children:[e.jsx(i,{size:10}),a.source_type==="article"&&((p=(r=a.article)==null?void 0:r.category)!=null&&p.title)?a.article.category.title:n.label]}),a.starred&&e.jsx(oe,{size:12,className:"text-yellow-400 fill-yellow-400"})]}),a.source_type==="article"&&((d=a.article)==null?void 0:d.title)&&e.jsx("h4",{className:"text-sm font-medium text-white/80 mb-2 line-clamp-1",children:a.article.title}),(()=>{const c=Er(a);return c?e.jsx("p",{className:"text-xs text-white/60 line-clamp-2 mb-2",children:c}):null})(),e.jsx("div",{className:"flex items-center justify-between",children:e.jsx("span",{className:"text-xs text-white/40",children:new Date(a.created_at).toLocaleDateString()})})]},a.id)})}),e.jsxs(E,{variant:"ghost",size:"sm",className:"w-full mt-3 text-purple-400 hover:text-white hover:bg-purple-500/20",onClick:()=>l("/learn?view=insights"),children:["View All Insights",e.jsx(R,{size:14,className:"ml-1"})]})]})]})},Rr=({articles:t,loading:s=!1,onArticleClick:l})=>{const a=L(),n=i=>{l?l(i):a("/learn")};return s?e.jsxs($,{variant:"glass-medium",sparkle:!0,glow:"green",className:"bg-slate-900/40 backdrop-blur-md border-white/10 text-white",children:[e.jsx(z,{className:"p-3 pb-2 md:p-6 md:pb-4",children:e.jsxs(G,{className:"text-base md:text-lg bg-gradient-to-r from-emerald-400 to-cyan-400 bg-clip-text text-transparent flex items-center gap-2",children:[e.jsx(Re,{size:20,className:"text-emerald-400"}),"Suggested Reading"]})}),e.jsx(T,{className:"p-3 md:p-6",children:e.jsx("div",{className:"space-y-3",children:[1,2,3].map(i=>e.jsxs("div",{className:"space-y-2",children:[e.jsx(_,{className:"h-4 w-full"}),e.jsx(_,{className:"h-3 w-2/3"}),e.jsx(_,{className:"h-8 w-full"})]},i))})})]}):t.length===0?e.jsxs($,{variant:"glass-medium",sparkle:!0,glow:"green",className:"bg-slate-900/40 backdrop-blur-md border-white/10 text-white",children:[e.jsx(z,{className:"p-3 pb-2 md:p-6 md:pb-4",children:e.jsxs(G,{className:"text-base md:text-lg bg-gradient-to-r from-emerald-400 to-cyan-400 bg-clip-text text-transparent flex items-center gap-2",children:[e.jsx(_r,{size:20,className:"text-emerald-400"}),"Reading Complete!"]})}),e.jsx(T,{className:"p-3 md:p-6",children:e.jsxs("div",{className:"text-center py-4",children:[e.jsx("div",{className:"text-4xl mb-2",children:"🎉"}),e.jsx("p",{className:"text-white/80 text-sm mb-2",children:"Amazing! You've read all available articles."}),e.jsx("p",{className:"text-white/60 text-xs",children:"Check back soon for new content!"})]})})]}):e.jsxs($,{variant:"glass-medium",sparkle:!0,glow:"green",className:"bg-slate-900/40 backdrop-blur-md border-white/10 text-white hover:shadow-2xl hover:shadow-green-500/20 transition-all duration-300",children:[e.jsx(z,{className:"p-3 pb-2 md:p-6 md:pb-4",children:e.jsxs(G,{className:"text-base md:text-lg bg-gradient-to-r from-emerald-400 to-cyan-400 bg-clip-text text-transparent flex items-center gap-2",children:[e.jsx(Re,{size:20,className:"text-emerald-400"}),"Suggested Reading"]})}),e.jsxs(T,{className:"p-3 md:p-6",children:[e.jsxs("div",{className:"space-y-3",children:[t.slice(0,2).map(i=>e.jsxs("div",{className:"bg-white/5 backdrop-blur-sm rounded-lg p-3 border border-white/10 hover:bg-white/10 transition-all duration-200 cursor-pointer",onClick:()=>n(i),children:[e.jsx(bt,{variant:"secondary",className:"bg-emerald-500/20 text-emerald-400 text-xs mb-2",children:i.category.title}),e.jsx("h4",{className:"text-sm font-medium text-white/90 mb-2 line-clamp-2",children:i.title}),i.excerpt&&e.jsx("p",{className:"text-xs text-white/60 line-clamp-2 mb-3",children:i.excerpt}),e.jsxs(E,{size:"sm",className:"w-full bg-gradient-to-r from-emerald-500 to-cyan-500 hover:from-emerald-600 hover:to-cyan-600 text-white border-0",children:["Read Article",e.jsx(R,{size:12,className:"ml-1"})]})]},i.id)),t.length>2&&e.jsx("div",{className:"text-center pt-2",children:e.jsxs("span",{className:"text-xs text-white/50",children:["+",t.length-2," more suggestions"]})})]}),e.jsxs(E,{variant:"ghost",size:"sm",className:"w-full mt-3 text-emerald-400 hover:text-white hover:bg-emerald-500/20",onClick:()=>a("/learn"),children:["Explore All Articles",e.jsx(R,{size:14,className:"ml-1"})]})]})]})},zr=t=>{const[s,l]=v.useState({totalCompletedSessions:0,quizCount:0}),[a,n]=v.useState(!0);return v.useEffect(()=>{(async()=>{try{const{data:{user:r}}=await S.auth.getUser();if(!r){n(!1);return}const{count:p}=await S.from("guided_study_sessions").select("*",{count:"exact",head:!0}).eq("user_id",r.id).not("completed_at","is",null),{data:d}=await S.from("user_quiz_stats").select("total_quizzes_taken").eq("user_id",r.id).single(),c=(d==null?void 0:d.total_quizzes_taken)||0;l({totalCompletedSessions:p||0,quizCount:c}
22)}catch(r){re.error("Error fetching guided study stats:",r)}finally{n(!1)}})()},[t]),{stats:s,loading:a}},qr=({count:t})=>{const s=t>5?"#a855f7":"#8b5cf6";return e.jsx("div",{className:"w-16 h-16 rounded-full flex items-center justify-center text-white font-bold text-xl",style:{background:`radial-gradient(circle, ${s} 0%, transparent 70%)`,boxShadow:`0 0 15px ${s}`},children:t})},Lr=()=>{const t=L(),{guidedSessions:s,loading:l}=wt(),a=s[0],{stats:n,loading:i}=zr(a==null?void 0:a.sessionId),{currentTier:r,rawTier:p,isSubscribed:d}=ce(),{toast:c}=Se(),m=()=>{const b=p>=2&&!d;return{title:b?"Subscription Required":"Feature Locked",description:b?"Subscribe to unlock Study Paths":"Reach Tier 2 to unlock Study Paths",variant:"destructive"}},f=async()=>{if(r<2){c(m());return}if(a){re.log("🎯 [ActiveStudySessionCard] Continuing session:",{sessionId:a.sessionId,articleTitle:a.articleTitle,currentSection:a.currentSection,progressPercentage:a.progressPercentage});try{re.log("📝 [ActiveStudySessionCard] Updating session timestamp"),await S.from("guided_study_sessions").update({last_accessed:new Date().toISOString()}).eq("id",a.sessionId),re.log("✅ [ActiveStudySessionCard] Session timestamp updated")}catch(b){console.error("❌ [ActiveStudySessionCard] Error updating session timestamp:",b)}re.log("🚀 [ActiveStudySessionCard] Navigating to:",`/learn?view=active-session&sessionId=${a.sessionId}`),t(`/learn?view=active-session&sessionId=${a.sessionId}`)}},h=()=>{if(r<2){c(m());return}t("/learn?view=plans")},x=()=>{if(r<2){c(m());return}t("/learn?view=plans")};if(l)return e.jsxs($,{variant:"glass-medium",glow:"blue",className:"bg-slate-900/40 backdrop-blur-md border-white/10 text-white",children:[e.jsx(z,{className:"p-3 pb-2 md:p-6 md:pb-4",children:e.jsxs("div",{className:"flex items-start justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 md:gap-3",children:[e.jsx(_,{className:"h-5 w-5 rounded bg-white/10 md:hidden"}),e.jsx(_,{className:"hidden md:block h-10 w-10 rounded-xl bg-white/10"}),e.jsx(_,{className:"h-5 w-40 bg-white/10 rounded"})]}),e.jsxs("div",{className:"flex items-end gap-6",children:[e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx(_,{className:"w-16 h-16 rounded-full bg-white/10 mb-1"}),e.jsx(_,{className:"h-3 w-12 bg-white/10 rounded"})]}),e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx(_,{className:"w-16 h-16 rounded-full bg-white/10 mb-1"}),e.jsx(_,{className:"h-3 w-12 bg-white/10 rounded"})]})]})]})}),e.jsxs(T,{className:"p-3 md:p-6 space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_,{className:"h-4 w-full bg-white/10 rounded"}),e.jsx(_,{className:"h-2.5 w-full bg-white/10 rounded-full"})]}),e.jsx(_,{className:"h-16 w-full bg-white/5 rounded-lg"}),e.jsx(_,{className:"h-10 w-full bg-white/10 rounded-md"})]})]});if(!a)return e.jsxs($,{variant:"glass-medium",sparkle:!1,glow:"purple",className:"bg-slate-900/40 backdrop-blur-md border-white/10 text-white hover:shadow-2xl hover:shadow-purple-500/20 transition-all duration-300 relative overflow-hidden group animate-fade-in",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-purple-500/5 via-blue-500/5 to-cyan-500/5 opacity-0 group-hover:opacity-100 transition-opacity duration-500"}),e.jsx("div",{className:"absolute top-2 right-2 opacity-30 group-hover:opacity-60 transition-opacity",children:e.jsx(P,{size:14,className:"text-purple-400"})}),e.jsx(z,{className:"p-3 pb-2 md:p-6 md:pb-4 relative",children:e.jsxs("div",{className:"flex items-center gap-2 md:gap-3",children:[e.jsx(B,{className:"h-5 w-5 text-purple-400 md:hidden"}),e.jsxs("div",{className:"relative hidden md:block",children:[e.jsx("div",{className:"p-2.5 rounded-xl bg-gradient-to-br from-purple-400/20 to-blue-400/20 border border-purple-400/30 backdrop-blur-sm",children:e.jsx(B,{className:"h-5 w-5 text-purple-400"})}),e.jsx("div",{className:"absolute inset-0 rounded-xl bg-purple-400/20 blur-xl"})]}),e.jsxs(G,{className:"text-base md:text-lg bg-gradient-to-r from-purple-400 via-blue-400 to-cyan-400 bg-clip-text text-transparent cursor-pointer hover:opacity-80 transition-opacity group/title flex items-center gap-2",onClick:h,children:["Active Study Session",e.jsx(ie,{size:14,className:"text-white/40 group-hover/title:text-white/60 transition-colors opacity-0 group-hover/title:opacity-100"})]})]})}),e.jsxs(T,{className:"p-3 md:p-6 relative",children:[e.jsx("p",{className:"text-sm text-white/70 mb-4 leading-relaxed",children:"No active study sessions. Start a guided study to see your progress here."}),e.jsxs(E,{onClick:x,className:`w-full bg-gradient-to-r from-purple-500 to-blue-500 hover:from-purple-600 hover:to-blue-600 text-white border-0 shadow-lg shadow-purple-500/25 hover:shadow-
22purple-500/40 transition-all duration-300 group/btn relative overflow-hidden ${r<2?"opacity-70":""}`,children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-transparent via-white/20 to-transparent -translate-x-full group-hover/btn:translate-x-full transition-transform duration-700"}),e.jsxs("span",{className:"relative flex items-center justify-center gap-2 font-medium",children:[r<2&&(p>=2&&!d?e.jsx(Fa,{className:"h-4 w-4 text-blue-400"}):e.jsx(Fe,{className:"h-4 w-4 text-amber-400"})),"Browse Study Paths",e.jsx(R,{className:"h-4 w-4 group-hover/btn:translate-x-1 transition-transform"})]})]})]})]});const g=Ga(new Date(a.lastAccessed),{addSuffix:!0}),o=a.progressPercentage,u=o>=75;return e.jsxs($,{variant:"glass-medium",sparkle:!0,glow:u?"green":"blue",className:"bg-slate-900/40 backdrop-blur-md border-white/10 text-white hover:shadow-2xl hover:shadow-blue-500/20 transition-all duration-300 relative overflow-hidden group animate-fade-in",children:[e.jsx("div",{className:`absolute inset-0 bg-gradient-to-br ${u?"from-green-500/8 via-blue-500/5 to-emerald-500/8":"from-blue-500/8 via-cyan-500/5 to-purple-500/8"} opacity-0 group-hover:opacity-100 transition-opacity duration-500`}),u&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"absolute top-4 right-4 animate-bounce",style:{animationDelay:"0s"},children:e.jsx(P,{size:12,className:"text-green-400/60"})}),e.jsx("div",{className:"absolute top-8 right-8 animate-bounce",style:{animationDelay:"0.5s"},children:e.jsx(P,{size:8,className:"text-emerald-400/40"})})]}),e.jsx("div",{className:"absolute top-2 right-2 opacity-30 group-hover:opacity-60 transition-opacity",children:e.jsx(P,{size:14,className:"text-blue-400"})}),e.jsx(z,{className:"p-3 pb-2 md:p-6 md:pb-4 relative",children:e.jsxs("div",{className:"flex items-start justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 md:gap-3",children:[e.jsx(Pe,{className:`h-5 w-5 md:hidden ${u?"text-green-400":"text-blue-400"}`}),e.jsxs("div",{className:"relative hidden md:block",children:[e.jsx("div",{className:`p-2.5 rounded-xl ${u?"bg-gradient-to-br from-green-400/20 to-emerald-400/20 border border-green-400/30":"bg-gradient-to-br from-blue-400/20 to-cyan-400/20 border border-blue-400/30"} backdrop-blur-sm`,children:e.jsx(Pe,{className:`h-5 w-5 ${u?"text-green-400":"text-blue-400"}`})}),e.jsx("div",{className:`absolute inset-0 rounded-xl ${u?"bg-green-400/20":"bg-blue-400/20"} blur-xl`})]}),e.jsxs(G,{className:`text-base md:text-lg bg-gradient-to-r ${u?"from-green-400 via-emerald-400 to-cyan-400":"from-blue-400 via-cyan-400 to-purple-400"} bg-clip-text text-transparent cursor-pointer hover:opacity-80 transition-opacity group/title flex items-center gap-2`,onClick:h,children:["Active Study Session",e.jsx(ie,{size:14,className:"text-white/40 group-hover/title:text-white/60 transition-colors opacity-0 group-hover/title:opacity-100"})]})]}),e.jsxs("div",{className:"flex items-end gap-6",children:[e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx("div",{className:"h-20 flex items-center justify-center mb-1",children:i?e.jsx(_,{className:"w-16 h-16 rounded-full bg-white/10"}):e.jsx(qr,{count:n.quizCount})}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Ae,{size:12,className:"text-purple-400"}),e.jsx("span",{className:"text-xs text-white/60 font-medium",children:"Quizzes"})]})]}),e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx("div",{className:"h-20 flex items-center justify-center mb-1",children:i?e.jsx(_,{className:"w-16 h-16 rounded-full bg-white/10"}):e.jsx(He,{sessions:n.totalCompletedSessions})}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(se,{size:12,className:"text-yellow-400"}),e.jsx("span",{className:"text-xs text-white/60 font-medium",children:"Mastery"})]})]})]})]})}),e.jsxs(T,{className:"p-3 md:p-6 space-y-4 relative",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(fe,{size:14,className:"text-white/40"}),e.jsx("span",{className:"text-white/70",children:"Progress"})]}),e.jsxs("span",{className:`font-bold ${u?"text-green-400":o>=50?"text-cyan-400":"text-white/70"}`,children:[o,"%"]})]}),e.jsx("div",{className:"relative",children:e.jsx("div",{className:"h-2.5 bg-white/5 rounded-full overflow-hidden backdrop-blur-sm border border-white/10",children:e.jsx("div",{className:`h-full rounded-full transition-all duration-700 ease-out relative overflow-hidden ${u?"bg-gradient-to-r from-green-400 via-emerald-400 to-green-400":"bg-gradient-to-r from-blue-400 via-cyan-400 to-purple-400"}`,style:{width:`${o}%`},children:e.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-transparent via-white/30 to-transparent animate-shimmer"})})})}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-white/50",children:[e.jsx(be,{className:"h-3 w-3"}),"Last accessed ",g]})]}),a.articleTitle&&e.jsxs("div",{className:"bg-white/5 backdrop-blur-sm rounded-lg p-3 border border-white/10 hover:bg-white/8 transition-all duration-200",children:[e.jsx("p",{className:"text-xs text-white/60 mb-1",children:"Currently studying"}),e.jsx("p",{className:"text-sm font-semibold text-white/90 line-clamp-2",children:a.articleTitle})]}),e.jsxs("div",{className:"bg-white/5 backdrop-blur-sm rounded-lg p-3 border border-white/10 hover:bg-white/8 transition-all duration-200",children:[e.jsx("p",{className:"text-xs text-white/60 mb-1",children:"Sections completed"}),e.jsxs("p",{className:"text-sm font-semibold text-white/90",children:[a.sectionsCompleted.length," section",a.sectionsCompleted.length!==1?"s":""]})]}),e.jsxs(E,{onClick:f,className:"w-full bg-gradient-to-r from-blue-500 to-cyan-500 hover:from-blue-600 hover:to-cyan-600 text-white border-0 shadow-lg shadow-blue-500/25 hover:shadow-blue-500/40 transition-all duration-300 group/btn relative overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 -translate-x-full group-hover/btn:translate-x-full transition-transform duration-1000 bg-gradient-to-r from-transparent via-white/20 to-transparent"}),e.jsxs("span",{className:"relative flex items-center gap-2",children:["Continue Studying",e.jsx(R,{className:"h-4 w-4 group-hover/btn:translate-x-1 transition-transform"})]})]}),u&&e.jsxs("div",{className:"flex items-center gap-2 bg-gradient-to-r from-green-500/20 to-emerald-500/20 border border-green-400/30 rounded-lg px-3 py-2 backdrop-blur-sm",children:[e.jsx(P,{className:"h-4 w-4 text-green-400 animate-pulse"}),e.jsx("p",{className:"text-xs text-green-300 font-medium",children:"Almost there! You're making great progress!"})]})]})]})}
22,Or=["Knowledge Depth","Practice & Journal","Pathways","Guided Study Mastery","Insight Collector","Book Explorer","Book Reading Streaks","Learning Consistency","Knowledge Testing","Multi-Modal Learner","AI Study","Category Completion","Special Badges","Community","Natal Chart","Journey Taker","Dream Incubation","Ego Dissolution"],Fr=["Book Reading Streaks","Knowledge Depth","Guided Study Mastery","Insight Collector","Learning Consistency","Knowledge Testing","Community","Dream Incubation"],Os=t=>({queryKey:["achievements",t],queryFn:async()=>{const[s,l,a]=await Promise.all([S.from("achievement_definitions").select("*").eq("active",!0).order("category, order_index"),S.from("user_achievements").select("*, achievement:achievement_definitions(*)"),S.rpc("get_user_achievement_stats",{p_user_id:t})]);if(s.error)throw s.error;if(l.error&&l.error.code!=="PGRST116")throw l.error;return{achievements:s.data||[],userAchievements:l.data||[],userStats:a.data||{}}},staleTime:10*60*1e3,gcTime:30*60*1e3}),$t=({autoCheck:t=!0}={})=>{const{user:s}=Y(),{toast:l}=Se(),a=we(),n=v.useRef(!1),{data:i,isLoading:r,refetch:p}=te({...Os((s==null?void 0:s.id)??""),enabled:!!(s!=null&&s.id)}),d=(i==null?void 0:i.achievements)||[],c=(i==null?void 0:i.userAchievements)||[],m=(i==null?void 0:i.userStats)||{},f=v.useCallback(async b=>{try{const{error:w}=await S.rpc("check_and_unlock_achievements",{p_user_id:b});if(w)throw w;re.log("Achievement check completed successfully"),a.invalidateQueries({queryKey:["achievements"]})}catch{}},[a]),h=v.useCallback(b=>c.some(w=>w.achievement_id===b),[c]),x=v.useCallback(()=>Or.map(b=>({category:b,achievements:d.filter(w=>w.category===b)})),[d]),g=v.useCallback(b=>{const w=b.criteria;if(!w)return null;const k=w.type,N=w.count||w.days||w.score||0;if(!k||N===0)return null;const j={chapters_read:"chapters_read",articles_read:"articles_read",quizzes_completed:"quizzes_completed",takeaways:"takeaways",reading_streak:"current_streak",consecutive_days:"current_streak",guided_sessions:"guided_sessions",bookmarks:"bookmarks",conversations:"conversations",starred_insights:"starred_insights",perfect_quiz:"perfect_quizzes",exercises_completed:"exercises_completed",practice_sessions:"practice_sessions",custom_study_paths:"custom_study_paths",deep_reflections:"deep_reflections",weekend_reading:"weekend_reading",early_morning_reading:"early_morning_reading",study_duration:"hour_long_sessions",tts_usage:"tts_usage",mind_maps_generated:"mind_maps_generated",practice_streak:"practice_streak",journal_entries:"journal_entries_count",journal_streak:"journal_streak",dream_entries:"dream_entries",morning_entries:"morning_entries",evening_entries:"evening_entries",first_ai_question:"conversations",cited_responses:"cited_responses",total_questions:"total_questions",speed_quiz:"speed_quizzes",all_features_used:"features_used",weekend_warrior:"weekend_days",questions_submitted:"questions_submitted",question_answered:"questions_answered",question_votes_cast:"question_votes_cast",question_votes:"question_votes_received",time_based:"time_based_sessions",natal_chart_generated:"natal_chart_generated",planets_tapped:"planets_tapped",natal_articles_read:"natal_articles_read",soul_contracts_added:"soul_contracts_added",natal_pdf_exported:"natal_pdf_exported",natal_full_spectrum:"natal_full_spectrum",journey_started:"journeys_started",journeys_completed:"journeys_completed",journey_domains:"journey_domains",journey_dark_night:"journey_dark_night",journey_shadow:"journey_shadow",dream_threads:"dream_threads",thread_dreams_logged:"thread_dreams_logged",thread_max_dreams:"thread_max_dreams",thread_reflections:"thread_reflections",thread_readings:"thread_readings",dream_pattern_reports:"dream_pattern_reports",dream_symbols_collected:"dream_symbols_collected",ego_layers:"ego_layers",ego_layers_used:"ego_layers_used"};if(k==="pathway_completed"){const C=`pathway_${String(w.slug??"").replace(/-/g,"_")}_completed`;return m[C]===void 0?null:{current:m[C],required:N}}const y=j[k];return!y||m[y]===void 0?null:{current:m[y],required:N}},[m]),o=v.useCallback(()=>{const b={};return Fr.forEach(w=>{const N=c.filter(j=>{var y;return((y=j.achievement)==null?void 0:y.category)===w}).reduce((j,y)=>y.achievement?j!=null&&j.achievement?(y.achievement.order_index??0)>(j.achievement.order_index??0)?y:j:y:j,null);b[w]=N}),b},[c]);v.useEffect(()=>{if(!t||!i||n.current||!(s!=null&&s.id))return;n.current=!0;const b=setTimeout(()=>f(s.id),1e3);return()=>clearTimeout(b)},[t,i,s==null?void 0:s.id,f]);const u=v.useCallback(async()=>{try{s&&(re.log("Force refreshing achievements for user:",s.id),await f(s.id))}catch(b){console.error("Error refreshing achievements:",b),fa(b,{context:"achievements.forceRefresh"}),l({title:"Error",description:"Failed to refresh achievements",variant:"destructive"})}},[f,l,s]);return{achievements:d,userAchievements:c,loading:r,checkAchievements:f,isAchievementUnlocked:h,getAchievementsByCategory:x,getProgress:g,getHighestUnlockedAchievements:o,refreshAchievements:p,forceRefreshAllAchievements:u,userStats:m}},Gr=()=>{const t=L(),{achievements:s,userAchievements:l,loading:a}=$t();if(a)return e.jsxs($,{variant:"glass-medium",glow:"golden",className:"bg-slate-900/40 backdrop-blur-md border-white/10 text-white",children:[e.jsx(z,{className:"p-3 pb-2 md:p-6 md:pb-4",children:e.jsx(_,{className:"h-6 w-48 bg-white/10"})}),e.jsxs(T,{className:"p-3 md:p-6 space-y-4",children:[e.jsx(_,{className:"h-4 w-full bg-white/10"}),e.jsx(_,{className:"h-4 w-full bg-white/10"}),e.jsx(_,{className:"h-4 w-full bg-white/10"})]})]});const n=new Set(l.map(h=>h.achievement_id)),i=s.filter(h=>!n.has(h.id)).slice(0,3),r=s.length,p=l.length,d=r>0?Math.round(p/r*100):0,c=p===r&&r>0,m=h=>{switch(h.toLowerCase()){case"study":return B;case"engagement":return Ba;case"mastery":return oe;default:return se}},f=h=>{switch(h.toLowerCase()){case"study":return"from-blue-400 to-cyan-400";case"engagement":return"from-purple-400 to-pink-400";case"mastery":return"from-yellow-400 to-orange-400";default:return"from-amber-400 to-yellow-400"}};return e.jsxs($,{variant:"glass-medium",sparkle:c,glow:c?"golden":"purple",className:"bg-slate-900/40 backdrop-blur-md border-white/10 text-white hover:shadow-2xl hover:shadow-amber-500/20 transition-all duration-300 relative overflow-hidden group",children:[e.jsx("div",{className:`absolute inset-0 bg-gradient-to-br ${c?"from-yellow-500/10 via-orange-500/5 to-amber-500/10":"from-
22amber-500/8 via-yellow-500/5 to-orange-500/8"} opacity-0 group-hover:opacity-100 transition-opacity duration-500`}),c&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"absolute top-4 right-4 animate-bounce",style:{animationDelay:"0s"},children:e.jsx(se,{size:12,className:"text-yellow-400/60"})}),e.jsx("div",{className:"absolute top-8 right-8 animate-bounce",style:{animationDelay:"0.5s"},children:e.jsx(oe,{size:8,className:"text-amber-400/40"})})]}),e.jsx("div",{className:"absolute top-2 right-2 opacity-30 group-hover:opacity-60 transition-opacity",children:e.jsx(P,{size:14,className:"text-amber-400"})}),e.jsx(z,{className:"p-3 pb-2 md:p-6 md:pb-4 relative",children:e.jsxs("div",{className:"flex items-center gap-2 md:gap-3",children:[e.jsx("div",{className:"md:hidden",children:c?e.jsx(dt,{className:"h-5 w-5 text-yellow-400"}):e.jsx(se,{className:"h-5 w-5 text-amber-400"})}),e.jsxs("div",{className:"relative hidden md:block",children:[e.jsx("div",{className:`p-2.5 rounded-xl ${c?"bg-gradient-to-br from-yellow-400/20 to-amber-400/20 border border-yellow-400/30":"bg-gradient-to-br from-amber-400/20 to-orange-400/20 border border-amber-400/30"} backdrop-blur-sm`,children:c?e.jsx(dt,{className:"h-5 w-5 text-yellow-400"}):e.jsx(se,{className:"h-5 w-5 text-amber-400"})}),e.jsx("div",{className:`absolute inset-0 rounded-xl ${c?"bg-yellow-400/20":"bg-amber-400/20"} blur-xl`})]}),e.jsxs(G,{onClick:()=>t("/learn?view=achievements"),className:`text-base md:text-lg bg-gradient-to-r ${c?"from-yellow-400 via-amber-400 to-orange-400":"from-amber-400 via-orange-400 to-yellow-400"} bg-clip-text text-transparent flex items-center gap-2 cursor-pointer group/title`,children:["Achievement Progress",c&&e.jsx("span",{className:"text-yellow-400 text-sm",children:"✓"}),e.jsx(ie,{size:14,className:"text-white/40 opacity-0 group-hover/title:opacity-100 transition-opacity"})]})]})}),e.jsxs(T,{className:"p-3 md:p-6 space-y-4 relative",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(fe,{size:14,className:"text-white/40"}),e.jsx("span",{className:"text-white/70",children:"Overall Progress"})]}),e.jsxs("span",{className:"text-white/60",children:[p," / ",r]})]}),e.jsx("div",{className:"relative",children:e.jsx("div",{className:"h-2.5 bg-white/5 rounded-full overflow-hidden backdrop-blur-sm border border-white/10",children:e.jsx("div",{className:`h-full rounded-full transition-all duration-700 ease-out relative overflow-hidden ${c?"bg-gradient-to-r from-yellow-400 via-amber-400 to-orange-400":"bg-gradient-to-r from-amber-400 via-orange-400 to-yellow-400"}`,style:{width:`${d}%`},children:e.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-transparent via-white/30 to-transparent animate-shimmer"})})})}),e.jsx("div",{className:"flex justify-end",children:e.jsxs("span",{className:`text-xs font-bold ${c?"text-yellow-400":d>=75?"text-amber-400":d>=50?"text-orange-400":"text-white/70"}`,children:[d,"%"]})})]}),i.length>0?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{className:"text-xs font-medium text-white/50 uppercase tracking-wide flex items-center gap-2",children:[e.jsx(oe,{size:12,className:"text-amber-400"}),"Next to Unlock"]}),e.jsx("div",{className:"space-y-2",children:i.map(h=>{const x=m(h.category),g=f(h.category);return e.jsxs("div",{className:"relative group/item bg-white/5 backdrop-blur-sm rounded-lg p-3 border border-white/10 hover:bg-white/8 hover:border-white/20 transition-all duration-200",children:[e.jsx("div",{className:`absolute inset-0 bg-gradient-to-r ${g} opacity-0 group-hover/item:opacity-5 rounded-lg transition-opacity`}),e.jsxs("div",{className:"relative flex items-start gap-3",children:[e.jsx("div",{className:`p-1.5 rounded-lg bg-gradient-to-br ${g} bg-opacity-10 backdrop-blur-sm border border-white/10 shrink-0`,children:e.jsx(x,{className:"h-3.5 w-3.5 text-white/80"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-semibold text-white/90 truncate",children:h.name}),e.jsx("p",{className:"text-[10px] text-white/60 line-clamp-1 mt-0.5",children:h.description})]})]})]}
22,h.id)})})]}):e.jsxs("div",{className:"relative bg-gradient-to-br from-yellow-500/10 to-amber-500/10 backdrop-blur-sm rounded-xl p-6 border border-yellow-400/30",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-yellow-500/20 to-amber-500/20 blur-xl opacity-50"}),e.jsxs("div",{className:"relative text-center space-y-3",children:[e.jsxs("div",{className:"relative inline-block",children:[e.jsx(se,{className:"h-12 w-12 text-yellow-400 mx-auto animate-bounce"}),e.jsx("div",{className:"absolute inset-0 bg-yellow-400/30 rounded-full blur-xl animate-pulse"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-bold text-yellow-400 mb-1",children:"All achievements unlocked!"}),e.jsx("p",{className:"text-xs text-white/70",children:"You're a true master! 🎉"})]})]})]}),e.jsxs(E,{onClick:()=>t("/learn?view=achievements"),className:"w-full bg-gradient-to-r from-amber-500 to-orange-500 hover:from-amber-600 hover:to-orange-600 text-white border-0 shadow-lg shadow-amber-500/25 hover:shadow-amber-500/40 transition-all duration-300 group/btn relative overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-transparent via-white/20 to-transparent -translate-x-full group-hover/btn:translate-x-full transition-transform duration-700"}),e.jsxs("span",{className:"relative flex items-center justify-center gap-2 font-medium text-sm",children:["View All Achievements",e.jsx(P,{className:"h-3.5 w-3.5 opacity-70 group-hover/btn:opacity-100 transition-opacity"})]})]})]})]})},Br=()=>{const{books:t,loading:s}
22=Ua(),{progressData:l,readChapters:a}=za(),{user:n}=Y(),{rawTier:i}=ce(),r=v.useMemo(()=>t.filter(d=>(d.unlock_tier??0)<=i),[t,i]);return{...v.useMemo(()=>{if(!r.length||!l)return{booksInProgress:[],completedBooks:0,totalBooks:r.length,totalChaptersRead:0,currentlyReading:null,overallPercentage:0};const d=r.map(b=>{const w=l.filter(D=>D.text_id===b.id),k=w.length,N=b.total_chunks||0,j=N>0?Math.round(k/N*100):0,y=w.length>0?w.reduce((D,C)=>new Date(C.read_at)>new Date(D.read_at)?C:D).read_at:void 0;return{book:b,chaptersRead:k,totalChapters:N,percentage:j,lastReadDate:y}}),c=d.filter(b=>b.chaptersRead>0&&b.percentage<100).sort((b,w)=>b.lastReadDate?w.lastReadDate?new Date(w.lastReadDate).getTime()-new Date(b.lastReadDate).getTime():-1:1),m=d.filter(b=>b.percentage===100).length,f=new Set(r.map(b=>b.id)),x=l?l.filter(b=>f.has(b.text_id)).length:0,g=c[0]||null,o=r.reduce((b,w)=>b+(w.total_chunks||0),0),u=o>0?Math.round(x/o*100):0;return{booksInProgress:c,completedBooks:m,totalBooks:r.length,totalChaptersRead:x,currentlyReading:g,overallPercentage:u}},[r,l,a,i]),loading:s}},Ur=()=>{const t=L(),s=we(),{booksInProgress:l,completedBooks:a,totalBooks:n,totalChaptersRead:i,currentlyReading:r,overallPercentage:p,loading:d}=Br(),c=()=>{t("/learn?view=reference")},m=x=>{t(`/learn?view=reference&bookId=${x}`)},f=()=>{t("/learn?view=reference")},h=x=>{s.prefetchQuery({queryKey:["spiritual-text-chunks",x],queryFn:async()=>{const{data:g,error:o}=await S.from("spiritual_text_chunks").select("*").eq("text_id",x).order("chunk_index");if(o)throw o;return g}})};return d?e.jsxs($,{variant:"glass-medium",glow:"cyan",sparkle:!0,className:"bg-slate-900/40 backdrop-blur-md border-white/10 text-white",children:[e.jsxs(z,{className:"p-3 pb-2 md:p-6 md:pb-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4 mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 md:gap-3",children:[e.jsx(_,{className:"w-5 h-5 rounded bg-white/10 md:hidden"}),e.jsx("div",{className:"hidden md:block w-10 h-10 rounded-lg bg-white/10 animate-pulse"}),e.jsx(_,{className:"h-5 w-28 bg-white/10 rounded"})]}),e.jsxs("div",{className:"flex items-end gap-6",children:[e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx("div",{className:"h-20 flex items-center justify-center mb-1",children:e.jsx(_,{className:"w-16 h-16 rounded-full bg-white/10"})}),e.jsx(_,{className:"h-3 w-16 bg-white/10 rounded"})]}),e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx("div",{className:"h-20 flex items-center justify-center mb-1",children:e.jsx(_,{className:"w-16 h-16 rounded-full bg-white/10"})}),e.jsx(_,{className:"h-3 w-16 bg-white/10 rounded"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(_,{className:"h-4 w-24 bg-white/10 rounded"}),e.jsx(_,{className:"h-4 w-10 bg-white/10 rounded"})]}),e.jsx(_,{className:"h-2 w-full bg-white/10 rounded-full"}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(_,{className:"h-3 w-32 bg-white/10 rounded"}),e.jsx(_,{className:"h-3 w-24 bg-white/10 rounded"})]})]})]}),e.jsxs(T,{className:"p-3 md:p-6 space-y-4",children:[e.jsx(_,{className:"h-24 w-full bg-white/10 rounded-lg"}),e.jsx(_,{className:"h-10 w-full bg-white/10 rounded-lg"})]})]}):e.jsxs($,{variant:"glass-medium",className:"cosmic-surface-feature text-white hover:shadow-2xl hover:shadow-cyan-500/20 transition-all duration-300 group animate-fade-in",children:[e.jsxs(z,{className:"p-3 pb-2 md:p-6 md:pb-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4 mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 md:gap-3",children:[e.jsx(Jt,{className:"w-5 h-5 text-cyan-400 md:hidden"}),e.jsxs("div",{className:"relative hidden md:block",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-gradient-to-br from-cyan-500/20 to-teal-500/20 flex items-center justify-center border border-cyan-400/30",children:e.jsx(Jt,{className:"w-5 h-5 text-cyan-400"})}),e.jsx("div",{className:"absolute inset-0 rounded-lg bg-cyan-400/20 blur-lg animate-pulse"})]}),e.jsxs(G,{className:"text-base md:text-lg bg-gradient-to-r from-cyan-400 to-teal-400 bg-clip-text text-transparent cursor-pointer hover:opacity-80 transition-opacity group/title flex items-center gap-2",onClick:f,children:["Books Progress",e.jsx(ie,{size:14,className:"text-white/40 group-hover/title:text-white/60 transition-colors opacity-0 group-hover/title:opacity-100"})]})]}),e.jsxs("div",{className:"flex items-end gap-6",children:[e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx("div",{className:"h-20 flex items-center justify-center mb-1",children:e.jsx("div",{className:"w-16 h-16 rounded-full flex items-center justify-center text-white font-bold text-xl",style:{background:"radial-gradient(circle, rgb(34, 211, 238) 0%, transparent 70%)",boxShadow:"0 0 15px rgb(34, 211, 238)"},children:i})}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(B,{size:12,className:"text-cyan-400"}),e.jsx("span",{className:"text-xs text-white/60",children:"Chapters"})]})]}),e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx("div",{className:"h-20 flex items-center justify-center mb-1",children:e.jsx(He,{sessions:a})}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(se,{size:12,className:"text-yellow-400"}),e.jsx("span",{className:"text-xs text-white/60",children:"Completed"})]})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{className:"text-white/70",children:"Overall Progress"}),e.jsxs("span",{className:"text-cyan-400 font-semibold",children:[p,"%"]})]}),e.jsx("div",{className:"cosmic-track h-2",children:e.jsx("div",{className:"h-full bg-gradient-to-r from-cyan-400 to-teal-400 rounded-full transition-all duration-500",style:{width:`${p}%`}})}),e.jsxs("div",{className:"flex items-center justify-between text-xs text-white/50",children:[e.jsxs("span",{children:[a," of ",n," books completed"]}),e.jsxs("span",{children:[i," chapters read"]})]})]})]}),e.jsxs(T,{className:"p-3 md:p-6 space-y-4",children:[r&&e.jsx("div",{className:"cosmic-surface-strip p-4 border-cyan-400/20 hover:border-cyan-400/40 transition-all duration-200 cursor-pointer",onMouseEnter:()=>
22h(r.book.id),onClick:x=>{x.stopPropagation(),m(r.book.id)},children:e.jsxs("div",{className:"flex items-start gap-3 sm:gap-4",children:[r.book.cover_image_url&&e.jsx("div",{className:"w-14 h-18 sm:w-16 sm:h-20 rounded-md overflow-hidden flex-shrink-0 border border-cyan-400/30",children:e.jsx("img",{src:r.book.cover_image_url,alt:r.book.title,className:"w-full h-full object-cover"})}),e.jsxs("div",{className:"flex-1 min-w-0 overflow-hidden",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-start sm:justify-between gap-1 sm:gap-2 mb-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("p",{className:"text-xs text-cyan-400",children:"Currently Reading"}),e.jsxs("span",{className:"text-xs text-white/60 flex-shrink-0 sm:hidden",children:[r.percentage,"%"]})]}),e.jsx("h3",{className:"text-sm font-semibold text-white/90 truncate pr-1",children:r.book.title})]}),e.jsxs("span",{className:"text-xs text-white/60 flex-shrink-0 hidden sm:block",children:[r.percentage,"%"]})]}),e.jsx("div",{className:"cosmic-track h-1.5 mb-2",children:e.jsx("div",{className:"h-full bg-gradient-to-r from-cyan-400 to-teal-400 rounded-full transition-all duration-500",style:{width:`${r.percentage}%`}})}),e.jsxs("p",{className:"text-xs text-white/50",children:[r.chaptersRead," of ",r.totalChapters," chapters"]})]})]})}),l.length>1&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs text-white/50 font-medium",children:"Other Books in Progress"}),e.jsx("div",{className:"space-y-2",children:l.slice(1,4).map(x=>e.jsxs("div",{className:"cosmic-surface-strip p-3 hover:border-white/20 transition-all duration-200 cursor-pointer",onMouseEnter:()=>h(x.book.id),onClick:g=>{g.stopPropagation(),m(x.book.id)},children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("h4",{className:"text-sm text-white/80 truncate flex-1",children:x.book.title}),e.jsxs("span",{className:"text-xs text-white/60 ml-2",children:[x.percentage,"%"]})]}),e.jsx("div",{className:"cosmic-track h-1",children:e.jsx("div",{className:"h-full bg-gradient-to-r from-cyan-400/60 to-teal-400/60 rounded-full transition-all duration-500",style:{width:`${x.percentage}%`}})})]},x.book.id))})]}),e.jsxs(E,{variant:"ghost",className:"w-full bg-cyan-400/10 hover:bg-cyan-400/20 text-cyan-400 border border-cyan-400/30 hover:border-cyan-400/50 transition-all duration-200",onClick:x=>{x.stopPropagation(),c()},children:[e.jsx("span",{children:"View All Books"}),e.jsx(R,{size:16,className:"ml-2"})]})]})]})},Vt=({sessionsThisWeek:t,weeklyGoal:s})=>{const{profile:l}=$e(),a=L(),{isUnlocked:n,isLoading:i}=gt(),r=Ge(),[p,d]=v.useState(!1),[c,m]=v.useState(""),[f,h]=v.useState("goal");v.useEffect(()=>{if(i||r.loading)return;const u=()=>{const w=new Date,k=w.getHours(),N=w.getDay(),j=localStorage.getItem("reminderLastDismissed");if(j){const W=new Date(j),H=new Date;if(H.setHours(0,0,0,0),W>=H)return}if(n&&r.hasScheduledItems){let W=!1,H="";if(r.upcomingItem&&r.minutesUntilNext!==null&&r.minutesUntilNext>0&&r.minutesUntilNext<=30&&(W=!0,H=`"${r.upcomingItem.title}" starts in ${r.minutesUntilNext} minutes!`),!W&&r.completedCount===0&&r.totalCount>0&&k>=10&&k<=14){W=!0;const V=r.totalCount;H=`You have ${V} item${V!==1?"s":""} scheduled for today. Ready to start?`}if(!W&&k>=18&&k<=21){const V=r.totalCount-r.completedCount;V>0&&(W=!0,H=`${V} scheduled item${V!==1?"s":""} still remaining today. You've got this!`)}if(W){m(H),h("schedule"),d(!0);return}}const y=(l==null?void 0:l.preferred_practice_time)||"09:00",[D]=y.split(":").map(Number),C=Math.abs(k-D)<=1,I=N===0?7:7-N,M=s-t,K=t<Math.floor((7-I)*(s/7));let A=!1,U="";C&&M>0?(A=!0,U=`It's your usual practice time! ${M} session${M!==1?"s":""} left this week.`):K&&k>=18&&k<=21?(A=!0,U="You're a bit behind pace this week. A quick session now can help you catch up!"):N===0&&M>0&&k>=10&&k<=20?(A=!0,U=`Last day of the week! ${M} more session${M!==1?"s":""} to reach your goal.`):N===3&&k>=18&&t===0&&(A=!0,U="It's Wednesday - time for your first session this week?"),A&&(m(U),h("goal"),d(!0))};u();const b=setInterval(u,60*60*1e3);return()=>clearInterval(b)}
22,[l,t,s,n,i,r]);const x=()=>{localStorage.setItem("reminderLastDismissed",new Date().toISOString()),d(!1)},g=()=>{if(x(),f==="schedule"&&r.upcomingItem){const u=r.upcomingItem;if(u.item_type==="reminder"){const b=u.title.toLowerCase();b.includes("reading")?a("/learn?view=reference"):b.includes("study")?a("/learn?view=plans"):b.includes("practice")&&a("/exercises");return}if(!u.item_id){a("/exercises?view=schedule");return}switch(u.item_type){case"exercise":a(`/exercises/${u.item_id}`);break;case"article":let b={};try{u.description&&(b=JSON.parse(u.description))}catch{}b.isCategory?a(`/learn?categoryId=${encodeURIComponent(u.item_id)}`):a(`/learn?articleId=${u.item_id}`);break;case"chapter":let w={};try{u.description&&(w=JSON.parse(u.description))}catch{}if(w.isBook&&w.bookId)a(`/learn?view=reference&bookId=${w.bookId}`);else if(w.isCategory&&w.bookId&&w.categoryName){const k=w.categoryName.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"");a(`/learn?view=reference&bookId=${w.bookId}&scrollToCategory=${encodeURIComponent(k)}`)}else w.bookId?a(`/learn?view=reference&bookId=${w.bookId}&chapterId=${u.item_id}`):a(`/learn?view=reference&chapterId=${u.item_id}`);break;case"study":a(`/learn?view=plans&activateStudy=${u.item_id}`);break;default:a("/exercises?view=schedule");break}}else a("/exercises")};if(!p)return null;const o=f==="schedule";return e.jsxs($,{className:"bg-slate-900/40 backdrop-blur-md border-white/10 overflow-hidden relative group animate-in fade-in-0 slide-in-from-top-4 duration-500",children:[e.jsx("div",{className:`absolute inset-0 bg-gradient-to-br ${o?"from-amber-500/10 via-orange-500/8 to-yellow-500/10":"from-purple-500/10 via-pink-500/8 to-cyan-500/10"} opacity-0 group-hover:opacity-100 transition-opacity duration-500`}),e.jsx("div",{className:`absolute -top-24 -right-24 w-48 h-48 ${o?"bg-amber-500/20":"bg-purple-500/20"}
22 rounded-full blur-3xl opacity-50 animate-pulse`}),e.jsx("div",{className:`absolute -bottom-24 -left-24 w-48 h-48 ${o?"bg-orange-500/20":"bg-pink-500/20"} rounded-full blur-3xl opacity-50 animate-pulse`,style:{animationDelay:"1s"}}),e.jsx("div",{className:"absolute top-4 right-16 opacity-30 animate-pulse",children:e.jsx(P,{size:12,className:o?"text-amber-400":"text-yellow-400"})}),e.jsx("div",{className:"absolute top-8 right-24 opacity-20 animate-pulse",style:{animationDelay:"0.5s"},children:e.jsx(P,{size:8,className:o?"text-orange-400":"text-purple-400"})}),e.jsxs(T,{className:"p-4 md:p-5 relative",children:[e.jsxs("div",{className:"flex items-start gap-3 md:gap-4",children:[e.jsxs("div",{className:"relative flex-shrink-0",children:[e.jsx("div",{className:`p-2.5 rounded-xl bg-gradient-to-br ${o?"from-amber-400/20 to-orange-400/20 border border-amber-400/30":"from-purple-400/20 to-pink-400/20 border border-purple-400/30"} backdrop-blur-sm`,children:o?e.jsx(ye,{className:"w-5 h-5 text-amber-400"}):e.jsx(js,{className:"w-5 h-5 text-purple-400"})}),e.jsx("div",{className:`absolute inset-0 rounded-xl ${o?"bg-amber-400/20":"bg-purple-400/20"} blur-xl animate-pulse`})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("h3",{className:"font-semibold text-white mb-2 flex items-center gap-2",children:[o?e.jsx(be,{className:"w-4 h-4 text-amber-400 animate-pulse"}):e.jsx(P,{className:"w-4 h-4 text-yellow-400 animate-pulse"}),e.jsx("span",{className:`bg-gradient-to-r ${o?"from-amber-400 via-orange-400 to-yellow-400":"from-purple-400 via-pink-400 to-cyan-400"} bg-clip-text text-transparent`,children:o?"Scheduled Activity":"Practice Reminder"})]}),e.jsx("p",{className:"text-sm text-white/80 mb-4 leading-relaxed",children:c}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(E,{size:"sm",onClick:g,className:`${o?"bg-gradient-to-r from-amber-500 to-orange-500 hover:from-amber-600 hover:to-orange-600 shadow-amber-500/25 hover:shadow-amber-500/40":"bg-gradient-to-r from-purple-500 to-pink-500 hover:from-purple-600 hover:to-pink-600 shadow-purple-500/25 hover:shadow-purple-500/40"} text-white border-0 shadow-lg transition-all duration-300 group/btn relative overflow-hidden`,children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-transparent via-white/20 to-transparent -translate-x-full group-hover/btn:translate-x-full transition-transform duration-700"}),e.jsxs("span",{className:"relative flex items-center gap-1.5",children:[e.jsx(Oe,{size:14,className:"group-hover/btn:scale-110 transition-transform"}),o?"Start Now":"Start Practice"]})]}),o&&e.jsx(E,{size:"sm",variant:"ghost",onClick:()=>{x(),a("/exercises?view=schedule")},className:"text-amber-400/70 hover:text-amber-400 hover:bg-amber-400/10 border border-amber-400/20 hover:border-amber-400/30 backdrop-blur-sm transition-all duration-200",children:e.jsxs("span",{className:"flex items-center gap-1",children:["View Schedule",e.jsx(R,{size:14})]})}),e.jsx(E,{size:"sm",variant:"ghost",onClick:x,className:"text-white/70 hover:text-white hover:bg-white/10 border border-white/10 hover:border-white/20 backdrop-blur-sm transition-all duration-200",children:"Maybe Later"})]})]}),e.jsx(E,{size:"icon",variant:"ghost",onClick:x,className:"text-white/50 hover:text-white hover:bg-white/10 h-8 w-8 rounded-lg border border-white/10 hover:border-white/20 backdrop-blur-sm transition-all duration-200 flex-shrink-0",children:e.jsx(Me,{className:"w-4 h-4"})})]}),e.jsxs("div",{className:"mt-4 pt-4 border-t border-white/10",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs text-white/50",children:[e.jsx("span",{children:o?"Today's Progress":"Weekly Progress"}),e.jsx("span",{className:"font-semibold text-white/70",children:o?`${r.completedCount} / ${r.totalCount} items`:`${t} / ${s} sessions`})]}),e.jsx("div",{className:"mt-2 h-1.5 bg-white/10 rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full ${o?"bg-gradient-to-r from-amber-400 via-orange-400 to-yellow-400":"bg-gradient-to-r from-purple-400 via-pink-400 to-cyan-400"} rounded-full transition-all duration-700 relative overflow-hidden`,style:{width:`${Math.min(o?r.completedCount/Math.max(r.totalCount,1)*100:t/s*100,100)}%`},children:e.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-transparent via-white/30 to-transparent animate-shimmer"})})})]})]}),e.jsx("div",{className:`absolute bottom-0 left-0 right-0 h-[1px] bg-gradient-to-r from-transparent ${o?"via-amber-400/50":"via-purple-400/50"} to-transparent`})]})};function Mt(t,s="/learn?view=plans"){return{Articles:{path:"/learn?view=explore"},Chapters:{path:"/learn?view=reference"},Exercises:{path:"/exercises?view=exercises"},Insights:{path:"/learn?view=insights"},Quizzes:{path:s},"Emotional & Heart Work exercises":{path:"/exercises?view=exercises"},"Journal Entries":{path:"/journal"}
22,"Natal Chart":{path:"/learn?view=natal"},"Advanced Exercises":{path:"/exercises?view=exercises",state:{scrollTo:"Advanced"}},"Practice Advanced Consciousness minutes":{path:"/exercises?view=exercises",state:{scrollTo:"Advanced"}}}[t]??null}const Fs={Articles:B,Chapters:qs,Exercises:ae,Insights:ge,Quizzes:Ae,"Emotional & Heart Work exercises":ae,"Journal Entries":B,"Natal Chart":oe,"Advanced Exercises":ae,"Practice Advanced Consciousness minutes":ae};function Gs(t,s="/learn?view=plans"){var d;if(!t||t.complete)return null;const l=(d=t.requirements)==null?void 0:d.find(c=>!c.complete);if(!l)return t.specialRequirement?{text:t.specialRequirement,route:{path:"/exercises?view=exercises",state:{scrollTo:"Advanced"}},icon:ae}:null;const a=Math.max(1,l.required-l.current),n=a>1,i=Mt(l.name,s)??{path:"/learn"},r=Fs[l.name]??oe;return{text:(()=>{switch(l.name){case"Articles":return`Read ${a} more article${n?"s":""}`;case"Chapters":return`Read ${a} more chapter${n?"s":""}`;case"Exercises":return`Complete ${a} more exercise${n?"s":""}`;case"Insights":return`Save ${a} more insight${n?"s":""}`;case"Quizzes":return`Complete ${a} more qui${n?"zzes":"z"}`;case"Journal Entries":return`Write ${a} more journal entr${n?"ies":"y"}`;case"Emotional & Heart Work exercises":return`Practice ${a} more emotional minute${n?"s":""}`;case"Advanced Exercises":return`Complete ${a} more advanced exercise${n?"s":""}`;case"Practice Advanced Consciousness minutes":return`Practice ${a} more advanced minute${n?"s":""}`;case"Natal Chart":return"Create your natal chart";default:return`${l.name}: ${l.current}/${l.required}`}})(),route:i,icon:r}}const Xt=()=>{const t=L(),{currentTier:s,rawTier:l,isSubscribed:a,nextTierProgress:n,isLoading:i}=ce(),{guidedSessions:r}=wt(),p=r[0],d=os.find(u=>u.tier===l),[c,m]=wa.useState(()=>localStorage.getItem("maxTierMessageDismissed")==="true"),f=()=>{m(!0),localStorage.setItem("maxTierMessageDismissed","true")};if(i)return e.jsx("div",{className:"h-28 bg-slate-900/40 backdrop-blur-xl border border-white/10 rounded-2xl animate-pulse relative overflow-hidden",children:e.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-transparent via-white/5 to-transparent -translate-x-full animate-[shimmer_2s_infinite]"})});const h=n==null?void 0:n.complete;if(h&&c)return null;const x=()=>p?`/learn?view=active-session&sessionId=${p.sessionId}`:"/learn?view=plans",g=u=>Mt(u,x()),o=h?null:Gs(n,x());return e.jsxs("div",{id:"tier-progress",className:`group relative overflow-hidden flex flex-col gap-3 p-4 rounded-2xl backdrop-blur-xl border transition-all duration-500 ${h?"bg-slate-900/40 border-amber-400/30 hover:border-amber-400/50 hover:shadow-xl hover:shadow-amber-500/20":"bg-slate-900/40 border-white/10 hover:border-purple-400/30 hover:shadow-xl hover:shadow-purple-500/20"} scroll-mt-24`,children:[e.jsx("div",{className:`absolute inset-0 bg-gradient-to-br opacity-0 group-hover:opacity-100 transition-opacity duration-500 ${h?"from-amber-600/10 via-yellow-600/5 to-orange-600/10":"from-purple-600/10 via-blue-600/5 to-cyan-600/10"}`}),e.jsx("div",{className:`absolute top-3 right-6 w-1.5 h-1.5 rounded-full opacity-20 animate-pulse ${h?"bg-amber-400":"bg-cyan-400"}`}),e.jsx("div",{className:`absolute bottom-3 right-10 w-1 h-1 rounded-full opacity-30 animate-pulse ${h?"bg-yellow-400":"bg-purple-400"}`,style:{animationDelay:"1s"}}),h&&e.jsx("button",{onClick:f,className:"absolute top-3 right-3 z-20 p-1 rounded-lg bg-white/5 hover:bg-white/10 border border-white/10 hover:border-white/20 transition-all duration-200 group/close","aria-label":"Dismiss message",children:e.jsx(Me,{className:"h-4 w-4 text-white/50 group-hover/close:text-white/80 transition-colors"})}),e.jsxs("div",{className:"flex items-center gap-3 relative z-10",children:[e.jsxs(st.div,{className:"relative",whileHover:{scale:1.05},transition:{type:"spring",stiffness:400},children:[e.jsxs("div",{className:`flex items-center gap-2 px-3 py-1.5 rounded-full backdrop-blur-sm border relative overflow-hidden ${h?"bg-gradient-to-r from-amber-500/20 to-yellow-500/20 border-amber-400/40":"bg-gradient-to-r from-purple-500/20 to-blue-500/20 border-purple-400/40"} ${!a&&l>0?"opacity-50":""}`,children:[e.jsx(oe,{className:`h-4 w-4 ${h?"text-amber-400 fill-amber-400":"text-purple-400 fill-purple-400"}`}),e.jsxs("span",{className:`text-sm font-bold ${h?"text-amber-300":"text-purple-300"} ${!a&&l>0?"line-through":""}`,children:["Tier ",l]}),e.jsx("div",{className:`absolute inset-0 rounded-full blur-md animate-pulse ${h?"bg-amber-400/30":"bg-purple-400/30"}`})]}),e.jsx("div",{className:`absolute inset-0 rounded-full blur-lg opacity-0 group-hover:opacity-100 transition-opacity duration-300 ${h?"bg-amber-400/40":"bg-purple-400/40"}`})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-base font-semibold truncate text-white/90",children:h?e.jsx("span",{className:"bg-gradient-to-r from-amber-400 to-yellow-400 bg-clip-text text-transparent",children:"Master Access"}):d==null?void 0:d.name}),!h&&e.jsxs("p",{className:"text-xs text-white/50 font-medium mt
22-0.5",children:[n==null?void 0:n.progress,"% to unlock next tier"]})]}),h&&e.jsx(P,{className:"h-5 w-5 text-amber-400 animate-pulse"})]}),!h&&e.jsx("div",{className:"h-2 bg-white/10 rounded-full overflow-hidden backdrop-blur-sm border border-white/10 relative z-10",children:e.jsx(st.div,{className:"h-full bg-gradient-to-r from-purple-500 via-blue-500 to-cyan-500 rounded-full relative",initial:{width:0},animate:{width:`${(n==null?void 0:n.progress)??0}%`},transition:{duration:.8,ease:"easeOut"},children:e.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-transparent via-white/30 to-transparent -translate-x-full animate-[shimmer_2s_infinite]"})})}),!h&&(n==null?void 0:n.requirements)&&e.jsxs("div",{className:"space-y-1.5 relative z-10",children:[n.requirements.map(u=>{const b={Articles:e.jsx(B,{className:"h-3 w-3"}),Chapters:e.jsx(qs,{className:"h-3 w-3"}),Exercises:e.jsx(ae,{className:"h-3 w-3"}),Insights:e.jsx(ge,{className:"h-3 w-3"}),Quizzes:e.jsx(Ae,{className:"h-3 w-3"}),"Emotional & Heart Work exercises":e.jsx(ae,{className:"h-3 w-3"}),"Journal Entries":e.jsx(B,{className:"h-3 w-3"}),"Advanced Exercises":e.jsx(ae,{className:"h-3 w-3"}),"Practice Advanced Consciousness minutes":e.jsx(ae,{className:"h-3 w-3"})};return e.jsxs("button",{type:"button",onClick:()=>{const w=g(u.name);w&&t(w.path,w.state?{state:w.state}:void 0)},className:`w-full flex items-center justify-between text-xs px-3 py-2 rounded-lg backdrop-blur-sm border transition-all duration-200 cursor-pointer hover:scale-[1.02] focus-visible:ring-2 focus-visible:ring-purple-400/50 focus-visible:outline-none ${u.complete?"bg-green-500/10 border-green-500/30 text-green-300 hover:bg-green-500/20":"bg-white/5 border-white/10 text-white/70 hover:bg-white/10 hover:border-white/20"}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[u.complete?e.jsx(Ne,{className:"h-3 w-3 text-green-400"}):e.jsx("span",{className:"text-white/50",children:b[u.name]||e.jsx(oe,{className:"h-3 w-3"})}),e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:gap-1.5",children:[e.jsx("span",{className:"font-medium text-left",children:u.name}),u.name==="Journal Entries"&&e.jsx("span",{className:"text-[10px] text-white/40",children:"(Meditation entries excluded)"})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("span",{className:`font-mono text-[10px] font-semibold ${u.complete?"text-green-300":"text-white/50"}`,children:[u.current,"/",u.required,u.name.includes("Emotional")?" mins":""]}),e.jsx(R,{className:"h-3 w-3 text-white/30"})]})]},u.name)}),n.specialRequirement&&!n.specialRequirementComplete&&e.jsxs("button",{type:"button",onClick:()=>t("/exercises?view=exercises",{state:{scrollTo:"Advanced"}}),className:"w-full flex items-center gap-2 text-xs px-3 py-2 rounded-lg bg-amber-500/10 border border-amber-500/30 text-amber-300 cursor-pointer hover:bg-amber-500/20 transition-all duration-200 hover:scale-[1.02] focus-visible:ring-2 focus-visible:ring-amber-400/50 focus-visible:outline-none",children:[e.jsx(ae,{className:"h-3 w-3 text-amber-400"}),e.jsx("span",{className:"font-medium flex-1 text-left",children:n.specialRequirement}),e.jsx(R,{className:"h-3 w-3 text-amber-400/50"})]}),n.specialRequirement&&n.specialRequirementComplete&&e.jsxs("button",{type:"button",onClick:()=>t("/exercises?view=exercises",{state:{scrollTo:"Advanced"}}),className:"w-full flex items-center gap-2 text-xs px-3 py-2 rounded-lg bg-green-500/10 border border-green-500/30 text-green-300 cursor-pointer hover:bg-green-500/20 transition-all duration-200 hover:scale-[1.02] focus-visible:ring-2 focus-visible:ring-green-400/50 focus-visible:outline-none",children:[e.jsx(Ne,{className:"h-3 w-3 text-green-400"}),e.jsxs("span",{className:"font-medium flex-1 text-left",children:[n.specialRequirement," ✓"]}),e.jsx(R,{className:"h-3 w-3 text-green-400/50"})]})]}),o&&e.jsxs(st.button,{onClick:()=>t(o.route.path,o.route.state?{state:o.route.state}:void 0),whileHover:{scale:1.02},whileTap:{scale:.98},className:"relative z-10 flex items-center justify-center gap-2 px-4 py-3 rounded-xl bg-gradient-to-r from-purple-500 to-blue-500 hover:from-purple-600 hover:to-blue-600 text-white font-medium text-sm border-0 shadow-lg shadow-purple-500/25 hover:shadow-
22purple-500/40 transition-all duration-300 overflow-hidden group/btn",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-transparent via-white/20 to-transparent -translate-x-full group-hover/btn:translate-x-full transition-transform duration-700"}),e.jsx(o.icon,{className:"h-4 w-4 relative z-10"}),e.jsx("span",{className:"relative z-10",children:o.text}),e.jsx(R,{className:"h-4 w-4 relative z-10 group-hover/btn:translate-x-1 transition-transform duration-300"})]}),h&&e.jsx("div",{className:"relative z-10 text-center py-2",children:e.jsx("p",{className:"text-sm text-white/70",children:"🎉 All features unlocked!"})}),e.jsx("div",{className:`absolute bottom-0 left-0 right-0 h-[1px] bg-gradient-to-r from-transparent to-transparent opacity-0 group-hover:opacity-100 transition-opacity duration-500 ${h?"via-amber-400/50":"via-purple-400/30"}`})]})},Bs=v.memo(()=>{const t=L(),{currentStreak:s,longestStreak:l,totalEntries:a,isLoading:n}=vs(),{shouldShowPrompt:i}=Ye(),{hasUnviewedReports:r}=Ya(),p=v.useMemo(()=>Be(new Date,{weekStartsOn:1}),[]),d=v.useMemo(()=>Ue(new Date,{weekStartsOn:1}),[]),{entries:c,isLoading:m}=Ha({startDate:p,endDate:d}),f=n||m,h=7,x=c.length,g=Math.min(x/h*100,100),o=c[0],u=j=>{const y=new Date(j);return vt(y)?"Today":Ta(y)?"Yesterday":me(y,"EEE")},b=j=>({daily_morning:"Morning",daily_evening:"Evening",meditation:"Meditation",dream:"Dream",guided:"Self-Development",freeform:"Free-form"})[j]||j,w=j=>{if(!j)return"";const y=j.content||"",D=80;return y.length<=D?y:y.substring(0,D).trim()+"..."},N=n?null:s===0?{text:"Start your journaling streak today! ✨",color:"text-purple-300"}:s===1?{text:"Great start! Come back tomorrow to build your streak 🔥",color:"text-orange-300"}:s<4?{text:`You're on a ${s}-day streak, keep going! 🔥`,color:"text-orange-300"}:s<7?{text:`${s} days strong! A full week is within reach 💪`,color:"text-yellow-300"}:s<14?{text:`${s}-day streak! You're building a real habit 🌟`,color:"text-yellow-300"}:s<30?{text:`${s} days! You're on fire — incredible dedication 🏆`,color:"text-amber-300"}:{text:`${s}-day streak! You're a journaling master 👑`,color:"text-amber-300"};return f?e.jsxs($,{variant:"glass-medium",className:"bg-slate-900/40 backdrop-blur-md border-white/10",children:[e.jsx(z,{className:"pb-2",children:e.jsx(_,{className:"h-6 w-40 bg-white/10"})}),e.jsxs(T,{className:"space-y-4",children:[e.jsx(_,{className:"h-16 w-full bg-white/5 rounded-xl"}),e.jsx(_,{className:"h-20 w-full bg-white/5 rounded-xl"})]})]}):e.jsxs($,{variant:"glass-medium",className:"bg-slate-900/40 backdrop-blur-md border-white/10 text-white overflow-hidden",children:[e.jsx(z,{className:"p-3 pb-2 md:p-6 md:pb-4",children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-2 md:gap-3",children:[e.jsx(B,{className:"w-5 h-5 text-purple-400 md:hidden"}),e.jsxs("div",{className:"relative hidden md:block",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-gradient-to-br from-purple-500/20 to-pink-500/20 flex items-center justify-center border border-purple-400/30",children:e.jsx(B,{className:"w-5 h-5 text-purple-400"})}),e.jsx("div",{className:"absolute inset-0 rounded-lg bg-purple-400/20 blur-lg animate-pulse"})]}),e.jsxs(G,{className:"text-base md:text-lg bg-gradient-to-r from-purple-400 to-pink-400 bg-clip-text text-transparent cursor-pointer hover:opacity-80 transition-opacity group/title flex items-center gap-2",onClick:()=>t("/journal"),children:["Journal Activity",e.jsx(ie,{size:14,className:"text-white/40 opacity-0 group-hover/title:opacity-100 transition-opacity"})]})]})})}),e.jsxs(T,{className:"space-y-4",children:[N&&e.jsx("div",{className:"px-3 py-2 bg-white/5 rounded-xl border border-white/5",children:e.jsx("p",{className:`text-xs font-medium ${N.color}`,children:N.text})}),i&&e.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5 bg-indigo-500/10 rounded-xl border border-indigo-400/20 cursor-pointer hover:bg-indigo-500/20 transition-colors group",onClick:()=>t("/journal"),children:[e.jsxs("div",{className:"relative",children:[e.jsx(jt,{className:"w-4 h-4 text-indigo-400"}),e.jsx("div",{className:"absolute -top-0.5 -right-0.5 w-2 h-2 rounded-full bg-indigo-400 animate-pulse"})]}),e.jsx("span",{className:"text-xs font-medium text-indigo-300 group-hover:text-indigo-200 transition-colors",children:"Weekly Summary ready to generate ✨"})]}),r&&e.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5 bg-purple-500/10 rounded-xl border border-purple-400/20 cursor-pointer hover:bg-purple-500/20 transition-colors group",onClick:()=>t("/journal?tab=dreams"),children:[e.jsxs("div",{className:"relative",children:[e.jsx(ft,{className:"w-4 h-4 text-purple-400"}),e.jsx("div",{className:"absolute -top-0.5 -right-0.5 w-2 h-2 rounded-full bg-purple-400 animate-pulse"})]}),e.jsx("span",{className:"text-xs font-medium text-purple-300 group-hover:text-purple-200 transition-colors",children:"New Dream Pattern Report available 🌙"})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{className:"flex flex-col items-center p-3 bg-white/5 rounded-xl",children:[e.jsx("div",{className:"p-1.5 rounded-lg bg-orange-400/20 mb-1.5",children:e.jsx(Ie,{className:"w-4 h-4 text-orange-400"})}),e.jsx("span",{className:"text-lg font-bold bg-gradient-to-r from-orange-400 to-red-400 bg-clip-text text-transparent",children:s}),e.jsx("span",{className:"text-[10px] text-white/50",children:"Streak"})]}),e.jsxs("div",{className:"flex flex-col items-center p-3 bg-white/5 rounded-xl",children:[e.jsx("div",{className:"p-1.5 rounded-lg bg-yellow-400/20 mb-1.5",children:e.jsx(se,{className:"w-4 h-4 text-yellow-400"})}),e.jsx("span",{className:"text-lg font-bold bg-gradient-to-r from-yellow-400 to-amber-400 bg-clip-text text-transparent",children:l}),e.jsx("span",{className:"text-[10px] text-white/50",children:"Best"})]}),e.jsxs("div",{className:"flex flex-col items-center p-3 bg-white/5 rounded-xl",children:[e.jsx("div",{className:"p-1.5 rounded-lg bg-purple-400/20 mb-1.5",children:e.jsx(B,{className:"w-4 h-4 text-purple-400"})}),e.jsx("span",{className:"text-lg font-bold bg-gradient-to-r from-purple-400 to-pink-400 bg-clip-text text-transparent",children:a}),e.jsx("span",{className:"text-[10px] text-white/50",children:"Total"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsx("span",{className:"text-white/60",children:"This Week"}),e.jsxs("span",{className:"text-white/80 font-medium",children:[x,"/",h," entries"]})]}),e.jsx(Ce,{value:g,className:"h-2 bg-white/10"})]}),o?e.jsxs("div",{className:"p-3 bg-white/5 rounded-xl border border-white/5 cursor-pointer hover:bg-white/10 transition-colors",onClick:()=>t("/journal?tab=entries"),children:[e.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[e.jsx("span",{className:"text-xs font-medium text-white/80",children:b(o.entry_type)}),e.jsx("span",{className:"text-[10px] text-white/40",children:u(o.created_at)})]}),e.jsx("div",{className:"text-xs text-white/60 line-clamp-2 leading-relaxed prose prose-invert prose-sm max-w-none prose-p:m-0 prose-strong:text-white/80",children:e.jsx(Ja,{children:w(o)})})]}):e.jsxs("div",{className:"p-4 bg-white/5 rounded-xl border border-dashed border-white/10 text-center",children:[e.jsx(P,{className:"w-5 h-5 text-purple-400/60 mx-auto mb-2"}),e.jsx("p",{className:"text-xs text-white/50",children:"No entries this week yet"})]}),e.jsxs(E,{className:"w-full bg-gradient-to-r from-purple-600 to-pink-600 hover:from-purple-500 hover:to-pink-500 text-white border-0 gap-2",onClick:()=>t("/journal?tab=new"),children:[e.jsx(ja,{className:"w-4 h-4"}),"New Journal Entry"]})]})]})});Bs.displayName="JournalActivityCard";function Us(t){const{user:s}=Y();return te({queryKey:["journey-last-entry",s==null?void 0:s.id,t],enabled:!!(s!=null&&s.id)&&!!t,queryFn:async()=>{const{data:l,error:a}=await S.from("journal_entries").select("content, created_at, journey_step").eq("journey_id",t).order("created_at",{ascending:!1}).limit(1).maybeSingle();if(a)throw a;return l??null}})}const Ys=v.memo(()=>{const t=L(),{isAdmin:s}=cs(),{journeys:l,isLoading:a,setCommitmentStatus:n}=ys(),i=v.useMemo(()=>
22{if(!s)return null;const g=l.filter(o=>o.status==="active");return g.length===0?null:[...g].sort((o,u)=>new Date(u.updated_at).getTime()-new Date(o.updated_at).getTime())[0]},[l,s]),{data:r}=Us((i==null?void 0:i.id)??null),p=v.useMemo(()=>{if(!i)return null;const g=Ns(i.template_id);if(!g)return null;const o=g.steps.find(w=>w.step===i.current_step);if(!o)return null;const u=!!r&&r.journey_step===i.current_step,b=g.steps.find(w=>w.step===i.current_step+1);return u&&b?{label:"Up next",intent:b.intent}:i.current_step>=i.total_steps?{label:"Final step",intent:o.intent}:{label:"Next",intent:o.intent}},[i,r]),d=v.useMemo(()=>{var w,k,N;const g=(w=r==null?void 0:r.content)==null?void 0:w.trim();if(!g)return null;const o=_s(g),u=(N=(k=ks(o,"response"))==null?void 0:k.value)==null?void 0:N.trim(),b=(u&&u.length>0?u:g).replace(/\*\*([^*]+):\*\*/g,"").replace(/\*\*/g,"").replace(/\s+/g," ").trim();return b?b.length>110?`${b.slice(0,110).trimEnd()}…`:b:null},[r]),c=v.useMemo(()=>!s||i?null:l.filter(o=>{var u;return o.status==="completed"&&((u=o.completion_forward_question)==null?void 0:u.trim())}).sort((o,u)=>new Date(u.updated_at).getTime()-new Date(o.updated_at).getTime())[0]??null,[l,i,s]),m=v.useMemo(()=>{if(!s)return[];const g=[];for(const o of l)(Array.isArray(o.behavioural_commitments)?o.behavioural_commitments:[]).forEach((b,w)=>{b.completed||g.push({journeyId:o.id,journeyTitle:o.title,index:w,text:b.text,dueAt:b.due_at,notify:b.notify===!0})});return g.sort((o,u)=>Date.parse(o.dueAt)-Date.parse(u.dueAt)).slice(0,2)},[l,s]),f=g=>{const o=new Date(g);return Number.isNaN(o.getTime())?"":vt(o)?"Today":fs(o)?"Tomorrow":me(o,"EEE MMM d")},h=v.useMemo(()=>i?Wa(new Date,new Date(i.updated_at))>=3:!1,[i]),x=i?Math.min((i.current_step-1)/i.total_steps*100,100):0;return a?e.jsxs($,{variant:"glass-medium",className:"bg-slate-900/40 backdrop-blur-md border-white/10",children:[e.jsx(z,{className:"pb-2",children:e.jsx(_,{className:"h-6 w-40 bg-white/10"})}),e.jsxs(T,{className:"space-y-4",children:[e.jsx(_,{className:"h-16 w-full bg-white/5 rounded-xl"}),e.jsx(_,{className:"h-10 w-full bg-white/5 rounded-xl"})]})]}):e.jsxs($,{variant:"glass-medium",className:"bg-slate-900/40 backdrop-blur-md border-white/10 text-white overflow-hidden",children:[e.jsx(z,{className:"p-3 pb-2 md:p-6 md:pb-4",children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-2 md:gap-3",children:[e.jsx(pe,{className:"w-5 h-5 text-violet-300 md:hidden"}),e.jsxs("div",{className:"relative hidden md:block",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-gradient-to-br from-violet-500/20 to-fuchsia-500/20 flex items-center justify-center border border-violet-400/30",children:e.jsx(pe,{className:"w-5 h-5 text-violet-300"})}),e.jsx("div",{className:"absolute inset-0 rounded-lg bg-violet-400/20 blur-lg animate-pulse"})]}),e.jsxs(G,{className:"text-base md:text-lg bg-gradient-to-r from-violet-300 to-fuchsia-300 bg-clip-text text-transparent cursor-pointer hover:opacity-80 transition-opacity group/title flex items-center gap-2",onClick:()=>t("/exercises?view=journeys"),children:["Journeys",e.jsx(ie,{size:14,className:"text-white/40 opacity-0 group-hover/title:opacity-100 transition-opacity"})]})]})})}),e.jsx(T,{className:"space-y-4",children:i?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"px-3 py-2.5 bg-gradient-to-br from-violet-500/10 via-indigo-500/5 to-transparent rounded-xl border border-violet-400/20 cursor-pointer hover:border-violet-400/40 hover:bg-violet-500/10 transition-colors group",onClick:()=>t(`/exercises?view=journeys&journeyId=${i.id}`),children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[e.jsx(pe,{className:"w-3.5 h-3.5 text-violet-300 shrink-0"}),e.jsx("span",{className:"text-[10px] uppercase tracking-wider text-violet-300/80",children:"Journey"}),e.jsx("span",{className:"text-xs text-white/80 font-medium truncate flex-1 min-w-0",children:i.title}),e.jsxs("span",{className:"text-[10px] text-white/50 shrink-0",children:[i.current_step,"/",i.total_steps]})]}),e.jsx("div",{className:"h-1 w-full overflow-hidden rounded-full bg-white/10",children:e.jsx("div",{className:"h-full bg-gradient-to-r from-violet-400 to-fuchsia-400 transition-all",style:{width:`${x}%`}})})]}),p&&e.jsxs("div",{className:"px-1 space-y-1",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-[10px] uppercase tracking-wider text-violet-300/80 shrink-0 mt-0.5",children:p.label}),e.jsx("p",{className:"text-xs italic text-violet-200/80 leading-relaxed flex-1",children:p.intent})]}),d&&e.jsxs("p",{className:"text-xs italic text-violet-200/60 leading-relaxed pl-1 border-l-2 border-violet-400/30 ml-1",children:[e.jsx("span",{className:"text-violet-300/70 mr-1",children:"“"}),d]})]}),m.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5 px-1",children:[e.jsx(ue,{className:"w-3 h-3 text-emerald-300"}),e.jsxs("span",{className:"text-[10px] uppercase tracking-wider text-emerald-300/80",children:["Your commitment",m.length>
221?"s":""]})]}),m.map(g=>{const o=new Date(g.dueAt),u=!Number.isNaN(o.getTime())&&o.getTime()<Date.now()-6*60*60*1e3;return e.jsxs("div",{className:"px-3 py-2 bg-emerald-500/10 rounded-xl border border-emerald-400/20 cursor-pointer hover:bg-emerald-500/15 transition-colors",onClick:()=>t(`/exercises?view=journeys&journeyId=${g.journeyId}`),children:[e.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[e.jsx("span",{className:"text-[10px] text-emerald-200/70 truncate flex-1 min-w-0",children:g.journeyTitle}),g.notify&&e.jsx(js,{className:"w-3 h-3 text-emerald-300/80 shrink-0","aria-label":"Reminder on"}),e.jsxs("span",{className:`text-[10px] shrink-0 ${u?"text-amber-300":"text-emerald-200/80"}`,children:[u?"Overdue · ":"",f(g.dueAt)]}),e.jsx("button",{type:"button",onClick:b=>{b.stopPropagation(),n.mutate({journeyId:g.journeyId,index:g.index,completed:!0},{onSuccess:()=>Z.success("Commitment complete ✓"),onError:()=>Z.error("Could not update commitment")})},"aria-label":"Mark commitment complete",className:"shrink-0 w-5 h-5 rounded-full border border-emerald-300/40 text-emerald-200 hover:bg-emerald-400/30 hover:text-white flex items-center justify-center transition-colors",children:e.jsx(De,{className:"w-3 h-3"})})]}),e.jsx("p",{className:"text-xs text-emerald-50/90 line-clamp-2 leading-snug",children:g.text})]},`${g.journeyId}-${g.dueAt}-${g.text.slice(0,12)}`)})]}),h&&e.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5 bg-violet-500/10 rounded-xl border border-violet-400/20 cursor-pointer hover:bg-violet-500/20 transition-colors group",onClick:()=>t(`/exercises?view=journeys&journeyId=${i.id}`),children:[e.jsxs("div",{className:"relative",children:[e.jsx(pe,{className:"w-4 h-4 text-violet-300"}),e.jsx("div",{className:"absolute -top-0.5 -right-0.5 w-2 h-2 rounded-full bg-violet-300 animate-pulse"})]}),e.jsxs("span",{className:"text-xs font-medium text-violet-200 group-hover:text-violet-100 transition-colors truncate",children:["Continue ",i.title," — Step ",i.current_step,"/",i.total_steps]})]}),e.jsxs(E,{className:"w-full bg-gradient-to-r from-violet-600 to-fuchsia-600 hover:from-violet-500 hover:to-fuchsia-500 text-white border-0 gap-2",onClick:()=>t(`/exercises?view=journeys&journeyId=${i.id}`),children:[e.jsx(pe,{className:"w-4 h-4"}),"Continue Journey"]})]}):e.jsxs(e.Fragment,{children:[c?e.jsxs("div",{className:"p-4 bg-gradient-to-br from-violet-500/10 via-indigo-500/5 to-transparent rounded-xl border border-violet-400/20",children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[e.jsx(P,{className:"w-3.5 h-3.5 text-violet-300"}),e.jsxs("span",{className:"text-[10px] uppercase tracking-wider text-violet-300/80",children:["Sit with this from ",c.title]})]}),e.jsx("p",{className:"text-sm italic text-violet-100/90 leading-relaxed line-clamp-2",children:c.completion_forward_question})]}):e.jsxs("div",{className:"p-4 bg-white/5 rounded-xl border border-dashed border-white/10 text-center",children:[e.jsx(P,{className:"w-5 h-5 text-violet-300/70 mx-auto mb-2"}),e.jsx("p",{className:"text-xs text-white/60 leading-relaxed",children:"Guided multi-step reflections — slower than a single prompt, designed to build over a series of entries."})]}),e.jsxs(E,{className:"w-full bg-gradient-to-r from-violet-600 to-fuchsia-600 hover:from-violet-500 hover:to-fuchsia-500 text-white border-0 gap-2",onClick:()=>t("/exercises?view=journeys"),children:[e.jsx(pe,{className:"w-4 h-4"}),"Start a Journey"]})]})})]})});Ys.displayName="JourneysCard";const Te=v.memo(()=>{const t=L(),{data:s,isLoading:l}=Es(),{data:a}=yt(),n=tr(),[i,r]=v.useState(null);if(l)return null;if(!s||s.length===0)return!a||a.length===0?null:e.jsxs($,{variant:"glass-medium",className:"relative bg-slate-900/40 backdrop-blur-md border-white/10 text-white p-5 overflow-hidden cursor-pointer hover:border-white/20 transition-all",onClick:()=>t("/pathways"),children:[e.jsx("div",{className:"absolute inset-x-0 top-0 h-0.5 bg-gradient-to-r from-violet-500 via-fuchsia-500 to-cyan-500"}),e.jsxs("div",{className:"flex items-center gap-2 text-xs uppercase tracking-wider text-white/50 mb-1.5",children:[e.jsx(Re,{className:"h-3.5 w-3.5 text-violet-300"}),"Pathways"]}),e.jsx("h3",{className:"text-base md:text-lg font-semibold bg-gradient-to-r from-violet-300 via-fuchsia-300 to-cyan-300 bg-clip-text text-transparent leading-snug",children:"Choose an outcome to work toward"}),e.jsx("p",{className:"mt-1 text-xs md:text-sm text-white/60 leading-relaxed",children:"Guided sequences for healing, grief, daily practice, and more."}),e.jsxs(E,{variant:"ghost",size:"sm",className:"mt-3 -ml-2 text-cyan-300 hover:text-cyan-200 hover:bg-white/5",onClick:d=>{d.stopPropagation(),t("/pathways")},children:["Browse pathways ",e.jsx(R,{className:"h-3.5 w-3.5 ml-1"})]})]});const p=async()=>
22{if(i)try{await n.mutateAsync(i.id),Z.success("Pathway reset")}catch{Z.error("Couldn't reset pathway")}finally{r(null)}};return e.jsxs(e.Fragment,{children:[e.jsxs($,{variant:"glass-medium",className:"bg-slate-900/40 backdrop-blur-md border-white/10 text-white p-5 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs uppercase tracking-wider text-white/50 mb-3",children:[e.jsx(P,{className:"h-3.5 w-3.5 text-violet-300"}),s.length===1?"Your pathway":"Your pathways"]}),e.jsx("div",{className:ee("space-y-3",s.length===1&&"space-y-0"),children:s.map(({pathway:d,progress:c})=>{const m=Ps(d),f=(c.completed_at??null)!==null,h=!f&&d.estimated_minutes?Math.max(1,Math.round(d.estimated_minutes*(1-c.progress_percentage/100))):null;return e.jsxs("div",{className:ee("relative rounded-xl border border-white/10 bg-white/[0.03] p-3.5 cursor-pointer hover:border-white/20 hover:bg-white/[0.05] transition-all overflow-hidden"),onClick:()=>t(`/pathways/${d.slug}`),children:[e.jsx("div",{className:ee("absolute inset-x-0 top-0 h-0.5 bg-gradient-to-r",m.from,m.via,m.to)}),e.jsxs("div",{className:"flex items-start gap-3",children:[d.cover_url?e.jsxs("div",{className:"relative flex-shrink-0 w-12 h-16 rounded-xl overflow-hidden ring-1 ring-white/10 shadow-lg",children:[e.jsx("img",{src:d.cover_url,alt:"",className:"w-full h-full object-cover",style:{objectPosition:"50% 35%"},loading:"lazy"}),e.jsx("div",{className:"pointer-events-none absolute inset-0 bg-gradient-to-t from-slate-950/70 via-slate-950/10 to-transparent"})]}):e.jsx("div",{className:ee("flex-shrink-0 w-12 h-16 rounded-xl flex items-center justify-center bg-gradient-to-br shadow-lg",m.from,m.to),children:e.jsx(P,{className:"h-5 w-5 text-white drop-shadow"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-sm md:text-base font-semibold text-white leading-snug truncate",children:d.title}),h!==null&&e.jsxs("div",{className:"mt-0.5 text-[10px] text-white/40 tabular-nums",children:["~",h," min remaining"]}),e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsx(Ce,{value:c.progress_percentage,className:"h-1 bg-white/5 flex-1"}),e.jsx("span",{className:ee("text-[10px] tabular-nums font-medium",m.text),children:f?"Done":`${c.progress_percentage}%`}),f&&e.jsx(De,{className:"h-3 w-3 text-emerald-300"})]})]}),e.jsx("div",{className:"flex items-center -mr-1",onClick:x=>x.stopPropagation(),children:e.jsxs(Va,{children:[e.jsx(Xa,{asChild:!0,children:e.jsx(E,{variant:"ghost",size:"icon",className:"h-7 w-7 text-white/40 hover:text-white hover:bg-white/10",children:e.jsx(va,{className:"h-4 w-4"})})}),e.jsxs(Za,{align:"end",className:"bg-slate-900 border-white/10 text-white",children:[e.jsx(Wt,{onClick:()=>t(`/pathways/${d.slug}`),className:"focus:bg-white/10",children:"Open"}),e.jsx(Wt,{onClick:()=>r({id:d.id,title:d.title}),className:"text-rose-300 focus:bg-rose-500/15 focus:text-rose-200",children:"Reset progress"})]})]})})]})]},d.id)})}),e.jsxs(E,{variant:"ghost",size:"sm",className:"mt-3 -ml-2 text-cyan-300 hover:text-cyan-200 hover:bg-white/5",onClick:()=>t("/pathways"),children:["Browse pathways ",e.jsx(R,{className:"h-3.5 w-3.5 ml-1"})]})]}),e.jsx(Cs,{open:!!i,onOpenChange:d=>!d&&r(null),children:e.jsxs(Ss,{className:"bg-slate-900 border-white/10 text-white",children:[e.jsxs(Ds,{children:[e.jsx(As,{children:"Reset this pathway?"}),e.jsx($s,{className:"text-white/60",children:i!=null&&i.title?`"${i.title}" will be removed from your active pathways. Articles and exercises you've already completed elsewhere stay marked — only your reflection notes for this pathway are cleared.`:""})]}),e.jsxs(Ms,{children:[e.jsx(Is,{className:"bg-white/5 border-white/10 text-white hover:bg-white/10",children:"Keep it"}),e.jsx(Ts,{onClick:p,className:"bg-rose-500 hover:bg-rose-400 text-white",children:"Reset"})]})]})})]})});Te.displayName="YourPathwayCard";const Yr=()=>{const t=new Date,s=t.getDay(),l=t.getDate()-s+(s===0?-6:1),a=new Date(t.setDate(l));return a.setHours(0,0,0,0),a},Kr=t=>{const s=new Date;if(t==="daily"){const l=new Date(s.getFullYear(),s.getMonth(),s.getDate()),a=new Date(l);return a.setDate(a.getDate()+1),{start:l.toISOString().split("T")[0],end:a.toISOString().split("T")[0]}}if(t==="weekly"){const l=Yr(),a=new Date(l);return a.setDate(a.getDate()+6),{start:l.toISOString().split("T")[0],end:a.toISOString().split("T")[0]}}if(t==="monthly"){const l=new Date(s.getFullYear(),s.getMonth(),1),a=new Date(s.getFullYear(),s.getMonth()+1,0);return{start:l.toISOString().split("T")[0],end:a.toISOString().split("T")[0]}}return null},Ks=t=>{const{user:s}=Y(),{toast:l}=Se(),a=we(),{data:n=[],isLoading:i}=te({queryKey:["user-goals",s==null?void 0:s.id,t],queryFn:async()=>{let o=S.from("user_goals").select("*").eq("user_id",s.id).order("created_at",{ascending:!1});t&&(o=o.eq("timeframe",t));const{data:u,error:b}=await o;
22if(b)throw b;return u||[]},enabled:!!(s!=null&&s.id),staleTime:2*60*1e3}),r=le({mutationFn:async o=>{const u=o.period_start?null:Kr(o.timeframe),{data:b,error:w}=await S.from("user_goals").insert({user_id:s.id,category:o.category,timeframe:o.timeframe,title:o.title,description:o.description||null,target_value:o.target_value||null,unit:o.unit||null,tracking_type:o.tracking_type||"manual",source:"user",period_start:o.period_start||(u==null?void 0:u.start)||null,period_end:o.period_end||(u==null?void 0:u.end)||null,is_recurring:o.is_recurring||!1}).select().single();if(w)throw w;return b},onSuccess:()=>{a.invalidateQueries({queryKey:["user-goals"]}),l({title:"Goal created",description:"Your new goal has been added"})},onError:o=>{var u;(u=o.message)!=null&&u.includes("Goal limit reached")?l({title:"Limit Reached",description:"Maximum 5 active goals for this timeframe. Complete or remove one first.",variant:"destructive"}):l({title:"Error",description:"Failed to create goal",variant:"destructive"})}}),p=le({mutationFn:async({id:o,updates:u})=>{const{error:b}=await S.from("user_goals").update({...u,updated_at:new Date().toISOString()}).eq("id",o).eq("user_id",s.id);if(b)throw b},onSuccess:()=>{a.invalidateQueries({queryKey:["user-goals"]})}}),d=le({mutationFn:async({id:o,completed:u})=>{const{error:b}=await S.from("user_goals").update({is_completed:u,completed_at:u?new Date().toISOString():null,updated_at:new Date().toISOString()}).eq("id",o).eq("user_id",s.id);if(b)throw b},onSuccess:(o,{completed:u})=>{a.invalidateQueries({queryKey:["user-goals"]}),u&&l({title:"🎉 Goal completed!",description:"Great work on achieving your goal!"})}}),c=le({mutationFn:async o=>{const{error:u}=await S.from("user_goals").delete().eq("id",o).eq("user_id",s.id);if(u)throw u},onSuccess:()=>{a.invalidateQueries({queryKey:["user-goals"]}),l({title:"Goal permanently deleted"})}}),m=le({mutationFn:async o=>{const{error:u}=await S.from("user_goals").update({is_archived:!0,updated_at:new Date().toISOString()}).eq("id",o).eq("user_id",s.id);if(u)throw u},onSuccess:()=>{a.invalidateQueries({queryKey:["user-goals"]}),l({title:"Goal archived"})}}),f=le({mutationFn:async o=>{const{error:u}=await S.from("user_goals").update({is_archived:!1,updated_at:new Date().toISOString()}).eq("id",o).eq("user_id",s.id);if(u)throw u},onSuccess:()=>{a.invalidateQueries({queryKey:["user-goals"]}),l({title:"Goal restored"})}}),h=n.filter(o=>!o.is_completed&&!o.is_archived),x=n.filter(o=>o.is_completed&&!o.is_archived),g=n.filter(o=>o.is_archived);return{goals:n,activeGoals:h,completedGoals:x,archivedGoals:g,isLoading:i,createGoal:r.mutate,updateGoal:p.mutate,toggleComplete:d.mutate,deleteGoal:c.mutate,archiveGoal:m.mutate,restoreGoal:f.mutate,isCreating:r.
22isPending}},Hs={practice:{label:"Practice",gradient:"from-green-400 to-emerald-400",icon:"TreePine",color:"text-green-400"},learning:{label:"Learning",gradient:"from-blue-400 to-cyan-400",icon:"BookOpen",color:"text-blue-400"},emotional:{label:"Emotional",gradient:"from-pink-400 to-rose-400",icon:"Heart",color:"text-pink-400"},consciousness:{label:"Consciousness",gradient:"from-purple-400 to-violet-400",icon:"Brain",color:"text-purple-400"},personal_vision:{label:"Personal Vision",gradient:"from-amber-400 to-yellow-400",icon:"Star",color:"text-amber-400"}},hl={daily:{label:"Daily",description:"Resets each day"},weekly:{label:"Weekly",description:"Monday to Sunday"},monthly:{label:"Monthly",description:"Calendar month"},milestone:{label:"Milestones",description:"No deadline"}},pl={daily:5,weekly:5,monthly:5,milestone:null},gl={practice:{daily:[{title:"Meditate today",target_value:1,unit:"session",tracking_type:"practice_sessions"},{title:"Complete 1 exercise session",target_value:1,unit:"session",tracking_type:"practice_sessions"}],weekly:[{title:"Practice 5x this week",target_value:5,unit:"sessions",tracking_type:"practice_sessions"},{title:"120 minutes total practice",target_value:120,unit:"minutes",tracking_type:"exercise_minutes"}],monthly:[{title:"Complete 20 sessions",target_value:20,unit:"sessions",tracking_type:"practice_sessions"},{title:"Try 3 new exercises",target_value:3,unit:"exercises",tracking_type:"practice_sessions"}],milestone:[{title:"Master all Foundation exercises",tracking_type:"manual"},{title:"30-day meditation streak",target_value:30,unit:"days",tracking_type:"practice_sessions"}]},learning:{daily:[{title:"Read 1 article today",target_value:1,unit:"article",tracking_type:"articles_read"},{title:"Complete 2 chapters",target_value:2,unit:"chapters",tracking_type:"articles_read"}],weekly:[{title:"Read 5 articles",target_value:5,unit:"articles",tracking_type:"articles_read"},{title:"Finish 10 chapters",target_value:10,unit:"chapters",tracking_type:"articles_read"}],monthly:[{title:"Read 15 articles",target_value:15,unit:"articles",tracking_type:"articles_read"},{title:"Complete 2 guided study courses",target_value:2,unit:"courses",tracking_type:"manual"}],milestone:[{title:"Complete Infinite Energy Series Book 1",tracking_type:"manual"},{title:"Earn Library Scholar achievement",tracking_type:"manual"}]},emotional:{daily:[{title:"Morning journal reflection",target_value:1,unit:"entry",tracking_type:"journal_entries"},{title:"Evening gratitude entry",target_value:1,unit:"entry",tracking_type:"journal_entries"}],weekly:[{title:"Journal 5 times",target_value:5,unit:"entries",tracking_type:"journal_entries"},{title:"60 minutes emotional exercises",target_value:60,unit:"minutes",tracking_type:"exercise_minutes"}],monthly:[{title:"Journal daily for the month",target_value:30,unit:"entries",tracking_type:"journal_entries"},{title:"complete 8 guided journals",target_value:8,unit:"entries",tracking_type:"journal_entries"}],milestone:[{title:"30-day journaling streak",target_value:30,unit:"days",tracking_type:"journal_entries"},{title:"Complete all emotional exercises",tracking_type:"manual"}]},consciousness:{daily:[{title:"Record 1 dream",target_value:1,unit:"entry",tracking_type:"journal_entries"},{title:"Lucid dream practice",target_value:1,unit:"session",tracking_type:"practice_sessions"}],weekly:[{title:"Record 5 dreams",target_value:5,unit:"entries",tracking_type:"journal_entries"},{title:"Interpret 5 dreams",target_value:5,unit:"entries",tracking_type:"journal_entries"}],monthly:[{title:"Record 20 dreams",target_value:20,unit:"entries",tracking_type:"journal_entries"},{title:"Achieve 1 lucid dream",target_value:1,unit:"dream",tracking_type:"manual"}],milestone:[{title:"First lucid dream",tracking_type:"manual"},{title:"Dream journal for 100 days",target_value:100,unit:"days",tracking_type:"journal_entries"}]},personal_vision:{}},Zt={daily:0,weekly:1,monthly:2,milestone:3},Hr=()=>{const{activeGoals:t,isLoading:s}=Ks(),l=L(),a=[...t].sort((n,i)=>{const r=(Zt[n.timeframe]??3)-(Zt[i.timeframe]??3);if(r!==0)return r;const p=n.target_value?n.current_value/n.target_value:0;return(i.target_value?i.current_value/i.target_value:0)-p}).slice(0,3);return s?e.jsxs($,{variant:"glass",className:"animate-pulse",children:[e.jsx(z,{className:"p-3 pb-2",children:e.jsx("div",{className:"h-5 w-20 bg-white/10 rounded"})}),e.jsx(T,{className:"p-3 pt-0 space-y-2",children:[1,2].map(n=>e.jsx("div",{className:"h-8 bg-white/5 rounded"},n))})]}):e.jsxs($,{variant:"glass",className:"hover:shadow-lg transition-all duration-300",children:[e.jsx(z,{className:"p-3 pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(G,{className:"text-sm font-semibold bg-gradient-to-r from-green-400 to-emerald-400 bg-clip-text text-transparent flex items-center gap-1.5 cursor-pointer hover:from-green-300 hover:to-emerald-300 transition-all duration-200 group/title",onClick:()=>l("/exercises?view=goals"),children:[e.jsx(ue,{size:14,className:"text-green-400"}),"Goals",e.jsx(ie,{size:12,className:"text-white/40 group-hover/title:text-white/60 transition-colors opacity-0 group-hover/title:opacity-100"})]}),e.jsxs(E,{variant:"ghost",size:"sm",onClick:()=>l("/exercises?view=goals"),className:"h-6 px-2 text-[10px] text-emerald-400/80 hover:text-emerald-300 hover:bg-emerald-500/10 gap-0.5 transition-all",children:["View All ",e.jsx(_e,{size:12})]})]})}),e.jsx(T,{className:"p-3 pt-0",children:a.length===0?e.jsxs("div",{className:"text-center py-3",children:[e.jsx("p",{className:"text-xs text-white/40 mb-2",children:"No active goals yet"}),e.jsx(E,{size:"sm",onClick:()=>l("/exercises?view=goals"),className:"bg-gradient-to-r from-green-500 to-emerald-500 text-white border-0 text-xs h-7",children:"Set your first goal"})]}):e.jsx("div",{className:"space-y-2.5",children:a.map(n=>{const i=Hs[n.category],r=n.target_value!=null&&n.target_value>0,p=r?Math.min(Math.round(n.current_value/n.target_value*100),100):0;return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:`w-1.5 h-1.5 rounded-full bg-gradient-to-r ${i.gradient} flex-shrink-0`}),e.jsx("span",{className:"text-xs text-white/80 truncate flex-1",children:n.title}),r&&e.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[e.jsx(Ce,{value:p,className:"w-12 h-1"}),e.jsxs("span",{className:"text-[10px] text-white/40 w-8 text-right",children:[n.current_value,"/",n.target_value]})]})]},n.id)})})})]})},Jr=v.memo(Hr),rt=2,Js=v.memo(()=>{const{latestReport:t}
22=Nt(),{summaries:s}=Ye(),[l,a]=v.useState(!1),n=v.useMemo(()=>{var m;return((m=t==null?void 0:t.report_content)==null?void 0:m.integrationPractices)??[]},[t]),i=v.useMemo(()=>{var m,f;return((f=(m=s[0])==null?void 0:m.summary_content)==null?void 0:f.integrationPractices)??[]},[s]),r=n.length+i.length;if(r===0)return null;const p=n.length>0?n.slice(0,1):[],d=i.length>0?i.slice(0,rt-p.length):[],c=r>rt;return e.jsxs($,{variant:"glass-medium",sparkle:!0,glow:"purple",className:"bg-slate-900/40 backdrop-blur-md border-white/10 text-white",children:[e.jsx(z,{className:"p-3 pb-2 md:p-6 md:pb-4",children:e.jsxs(G,{className:"text-base md:text-lg bg-gradient-to-r from-purple-400 to-cyan-400 bg-clip-text text-transparent flex items-center gap-2",children:[e.jsx(P,{className:"h-4 w-4 text-purple-400 shrink-0"}),"Integration Practices"]})}),e.jsxs(T,{className:"p-3 pt-0 md:p-6 md:pt-0 space-y-3",children:[n.length>0&&e.jsx(xt,{icon:e.jsx(ft,{className:"h-3.5 w-3.5 text-indigo-400"}),label:"Dream Patterns",items:l?n:p,accentClass:"text-indigo-400"}),i.length>0&&e.jsx(xt,{icon:e.jsx(B,{className:"h-3.5 w-3.5 text-cyan-400"}),label:"Weekly Summary",items:l?i:d,accentClass:"text-cyan-400"}),c&&e.jsx(E,{variant:"ghost",size:"sm",onClick:()=>a(m=>!m),className:"w-full text-white/50 hover:text-white/80 hover:bg-white/5 text-sm",children:l?e.jsxs(e.Fragment,{children:["Show less ",e.jsx(_t,{className:"ml-1 h-3 w-3"})]}):e.jsxs(e.Fragment,{children:["Show more (",r-rt," more) ",e.jsx(Ke,{className:"ml-1 h-3 w-3"})]})})]})]})}),xt=v.memo(({icon:t,label:s,items:l,accentClass:a})=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[t,e.jsx("span",{className:"text-xs text-white/50 uppercase tracking-wider",children:s})]}),e.jsx("ul",{className:"space-y-1",children:l.map((n,i)=>e.jsxs("li",{className:"text-sm text-white/80 flex items-start gap-2",children:[e.jsx("span",{className:`${a} mt-0.5`,children:"→"}),n]},i))})]}));xt.displayName="PracticeSection";Js.displayName="IntegrationPracticesCard";const it=({children:t,editMode:s,index:l,total:a,onMoveUp:n,onMoveDown:i})=>e.jsxs("div",{className:`relative transition-all duration-200 ${s?"ring-1 ring-white/20 rounded-xl":""}`,children:[s&&e.jsxs("div",{className:"absolute -right-1 -top-1 z-10 flex flex-col gap-0.5",children:[e.jsx("button",{onClick:n,disabled:l===0,"aria-label":"Move card up",className:"w-6 h-6 flex items-center justify-center rounded-full bg-white/10 hover:bg-white/25 disabled:opacity-20 disabled:cursor-not-allowed text-white/80 hover:text-white transition-all duration-150 backdrop-blur-sm border border-white/10",children:e.jsx(_t,{size:14})}),e.jsx("button",{onClick:i,disabled:l===a-1,"aria-label":"Move card down",className:"w-6 h-6 flex items-center justify-center rounded-full bg-white/10 hover:bg-white/25 disabled:opacity-20 disabled:cursor-not-allowed text-white/80 hover:text-white transition-all duration-150 backdrop-blur-sm border border-white/10",children:e.jsx(Ke,{size:14})})]}),t]}),Wr=t=>{const s=Object.entries(Aa).map(([m,f])=>{const h=f.filter(x=>t.some(g=>g.exercise_id===x.id)).length;return{category:m,completed:h,total:f.length,percentage:f.length>0?Math.round(h/f.length*100):0}}),l=s.find(m=>m.category==="Foundation"),a=s.find(m=>m.category==="Emotional"),n=s.find(m=>m.category==="Advanced");let i="",r="";const p=new Date,d=new Date(p.getTime()-7*24*60*60*1e3),c=t.filter(m=>new Date(m.last_completed)>d);if(l.percentage===100&&a.percentage===100&&n.completed>0)Math.random()<.3?(i="Consider revisiting foundation exercises for grounding",r="Even advanced practitioners benefit from returning to the fundamentals!"):(i="Continue exploring advanced practices",r="You're on an incredible journey of self-discovery!");else if(l.percentage===100&&a.percentage<100)i="Begin exploring emotional practices",r="You're ready to dive deeper into emotional awareness!";else if(l.percentage===100&&a.percentage===100)i="You're ready for advanced practices",r="Your foundation is solid - time to explore the depths!";else if(l.completed===0)i="Start with foundation exercises",r="Every master was once a beginner - you've got this!";else if(c.length===0&&t.length>0){const m=t.reduce((h,x)=>new Date(x.last_completed)>new Date(h.last_completed)?x:h),f=Math.floor((p.getTime()-new Date(m.last_completed).getTime())/(24*60*60*1e3));i="Try revisiting your last exercise",r=`Welcome back! It's been ${f} days - let's reconnect with your practice.`}else l.percentage<100?(i="Continue building your foundation",r="Strong foundations create lasting transformation!"):(i="Explore the next level of practices",r="You're making excellent progress!");
22return{categoryProgress:s,suggestedNextStep:i,motivationalMessage:r}},Ws=()=>{const{user:t}=Y();we();const{data:s,isLoading:l}=te({queryKey:["exercise-progress",t==null?void 0:t.id],queryFn:async()=>{const{data:a,error:n}=await S.from("user_progress").select("*").eq("user_id",t.id);if(n)throw n;return Wr(a||[])},enabled:!!(t!=null&&t.id),staleTime:5*60*1e3});return{progressData:s??null,loading:l}},Qr={totalArticles:0,readArticles:0,overallProgress:0,categoryProgress:[],recentHighlights:[],suggestedArticles:[],articlesReadThisWeek:0,learningStreak:0};async function Vr(t,s){const[{data:l,error:a},{data:n,error:i},{data:r,error:p},{data:d,error:c}]=await Promise.all([S.from("learn_articles").select(`
23        id, title, excerpt, category_id,
24        learn_categories ( id, title, color_scheme, icon, unlock_tier )
25      `).eq("published",!0).order("order_index"),S.from("article_progress").select("article_id, read_at").eq("user_id",t),S.from("user_takeaways").select(`
26        id, key_takeaway, deep_reflection, starred, created_at,
27        article:learn_articles ( title, learn_categories ( title, color_scheme ) )
28      `).eq("user_id",t).order("created_at",{ascending:!1}).limit(5),S.from("ai_study_insights").select("id, insight_text, insight_type, starred, created_at, tags, ai_response").eq("user_id",t).order("created_at",{ascending:!1}).limit(5)]);if(a)throw a;if(i)throw i;if(p)throw p;if(c)throw c;const m=(l==null?void 0:l.filter(j=>{var D;return(((D=j.learn_categories)==null?void 0:D.unlock_tier)??0)<=s}))||[],f=new Map;m.forEach(j=>{const y=j.learn_categories;if(!y)return;f.has(y.id)||f.set(y.id,{categoryId:y.id,categoryName:y.title,totalArticles:0,readArticles:0,percentage:0,colorScheme:y.color_scheme||"indigo",icon:y.icon});const D=f.get(y.id);D.totalArticles++,n!=null&&n.some(C=>C.article_id===j.id)&&D.readArticles++});const h=Array.from(f.values()).map(j=>({...j,percentage:j.totalArticles>0?Math.round(j.readArticles/j.totalArticles*100):0})),x=m.filter(j=>!(n!=null&&n.some(y=>y.article_id===j.id))).map(j=>{var y,D,C,I,M;return{id:j.id,title:j.title,excerpt:j.excerpt,category:{id:((y=j.learn_categories)==null?void 0:y.id)||"",title:((D=j.learn_categories)==null?void 0:D.title)||"Uncategorized",colorScheme:((C=j.learn_categories)==null?void 0:C.color_scheme)||"indigo",icon:(I=j.learn_categories)==null?void 0:I.icon},_catProgress:((M=h.find(K=>K.categoryId===j.category_id))==null?void 0:M.percentage)||0}}).sort((j,y)=>j._catProgress-y._catProgress).slice(0,3).map(({_catProgress:j,...y})=>y),g=new Date;g.setDate(g.getDate()-7);const o=(n==null?void 0:n.filter(j=>new Date(j.read_at)>=g).length)||0,u=(n==null?void 0:n.sort((j,y)=>new Date(y.read_at).getTime()-new Date(j.read_at).getTime()))||[];let b=0;const w=new Date;w.setHours(0,0,0,0);for(let j=0;j<30;j++){const y=new Date(w);if(y.setDate(y.getDate()-j),u.some(C=>{const I=new Date(C.read_at);return I.setHours(0,0,0,0),I.getTime()===y.getTime()}))b++;else if(j>0)break}const k=m.length,N=(n==null?void 0:n.filter(j=>m.some(y=>y.id===j.article_id)).length)||0;return{totalArticles:k,readArticles:N,overallProgress:k>0?Math.round(N/k*100):0,categoryProgress:h,recentHighlights:[...(r==null?void 0:r.map(j=>{var y,D,C,I,M;return{id:j.id,key_takeaway:j.key_takeaway,deep_reflection:j.deep_reflection,starred:j.starred,created_at:j.created_at,source_type:"article",article:{title:((y=j.article)==null?void 0:y.title)||"",category:{title:((C=(D=j.article)==null?void 0:D.learn_categories)==null?void 0:C.title)||"",colorScheme:((M=(I=j.article)==null?void 0:I.learn_categories)==null?void 0:M.color_scheme)||"indigo"}}}}))||[],...(d==null?void 0:d.map(j=>{const y=j.insight_type==="lookup"?"lookup":j.insight_type==="guided_study"?"guided_study":j.insight_type==="dream_interpretation"?"dream_interpretation":"ai_study";return{id:j.id,key_takeaway:j.insight_text,ai_response:j.ai_response,starred:j.starred||!1,created_at:j.created_at,source_type:y,insight_type:j.insight_type}}))||[]].sort((j,y)=>new Date(y.created_at).getTime()-new Date(j.created_at).getTime()).slice(0,3),suggestedArticles:x,articlesReadThisWeek:o,learningStreak:b}}const It=()=>{const{user:t}=Y(),{currentTier:s}=ce(),{data:l,isLoading:a,error:n,refetch:i}=te({queryKey:["home-learning-data",t==null?void 0:t.id,s],queryFn:()=>Vr(t.id,s),enabled:!!(t!=null&&t.id),staleTime:2*60*1e3});return{data:l??Qr,loading:a,error:(n==null?void 0:n.message)??null,refetch:i}};async function Xr(t,s){var w,k,N,j,y;const l=me(new Date,"yyyy-MM-dd"),a=new Date;a.setHours(0,0,0,0);const[n,i,r,p,d,c,m,f]=await Promise.all([S.from("user_schedule_items").select("title, item_type, scheduled_time").eq("user_id",t).eq("scheduled_date",l).eq("is_completed",!1).order("scheduled_time",{nullsFirst:!1}).limit(1),S.from("journal_streaks").select("current_streak, last_entry_date").eq("user_id",t).maybeSingle(),S.from("journal_entries").select("id",{count:"exact",head:!0}).eq("user_id",t).eq("is_draft",!1).gte("created_at",a.toISOString()),S.from("user_goals").select("title, target_value, current_value, unit").eq("user_id",t).eq("is_completed",!1).not("target_value","is",null).gt("target_value",0),S.from("user_natal_charts").select("id").eq("user_id",t).maybeSingle(),S.from("dream_pattern_reports").select("created_at").eq("user_id",t).order("created_at",{ascending:!1}).limit(1).maybeSingle(),S.from("practice_sessions").select("completed_at").eq("user_id",t).order("completed_at",{ascending:!1}).limit(1).maybeSingle(),S.from("chapter_reading_positions").select("chunk_id, scroll_percentage, updated_at").eq("user_id",t).gt("scroll_percentage",5).lt("scroll_percentage",95).order("updated_at",{ascending:!1}).limit(1).maybeSingle()]);let h=0;const x=((w=c.data)==null?void 0:w.created_at)??null,g=S.from("journal_entries").select("id",{count:"exact",head:!0}).eq("user_id",t).eq("entry_type","dream").eq("is_draft",!1);x&&g.gt("created_at",x),h=(await g).count??0;let u=null;if((k=m.data)!=null&&k.completed_at){const D=new Date(m.data.completed_at);u=Math.floor((Date.now()-D.getTime())/(24*60*60*1e3))}let b=null;if(p.data&&p.data.length>0){const D=p.data.map(C=>{const I=C.target_value??0,M=C.current_value??0,K=Math.max(I-M,0),A=I>0?M/I:0;return{...C,remaining:K,ratio:A}}).filter(C=>C.remaining>0&&C.remaining<=3&&C.ratio>=.5).sort((C,I)=>I.ratio-C.ratio);D[0]&&(b={title:D[0].title,remaining:D[0].remaining,unit:D[0].unit})}return{scheduleItemToday:(N=n.data)!=null&&N[0]?{title:n.data[0].title,item_type:n.data[0].item_type}:null,journalStreak:((j=i.data)==null?void 0:j.current_streak)??0,hasJournalEntryToday:(r.count??0)>0,nearlyCompleteGoal:b,hasNatalChart:!!d.data,dreamsSinceLastReport:h,daysSinceLastPractice:u,inProgressChunkId:((y=f.data)==null?void 0:y.chunk_id)??null,currentTier:s}}function Zr(t,s,l){const{scheduleItemToday:a,journalStreak:n,hasJournalEntryToday:i,nearlyCompleteGoal:r,hasNatalChart:p,dreamsSinceLastReport:d,daysSinceLastPractice:c,inProgressChunkId:m,currentTier:f}=t;if(a)return{category:"schedule",suggestedNextStep:`You have "${a.title}
28" scheduled today`,motivationalMessage:"A small consistent action compounds into deep change.",action:{label:"Open schedule",route:"/exercises?view=schedule"}};if(n>=3&&!i)return{category:"journal",suggestedNextStep:`Don't break your ${n}-day journal streak`,motivationalMessage:"A few minutes of reflection keeps the inner thread alive.",action:{label:"Open journal",route:"/journal"}};if(r){const h=r.unit?` ${r.unit}`:"",x=r.remaining;return{category:"goal",suggestedNextStep:x===1?`Just one more${h} to complete "${r.title}"`:`${x} more${h} to complete "${r.title}"`,motivationalMessage:"You're right at the edge — finish strong.",action:{label:"View goals",route:"/exercises?view=goals"}}}return!p&&f>=1?{category:"natal",suggestedNextStep:"Generate your natal chart for personalized insights",motivationalMessage:"Your chart is a map of the energies you came in with.",action:{label:"Open natal chart",route:"/learn?view=natal"}}:d>=7?{category:"dream",suggestedNextStep:`You have ${d} new dreams — generate a pattern report`,motivationalMessage:"Patterns surface when enough dreams gather.",action:{label:"Open journal",route:"/journal"}}:c!==null&&c>=3?{category:"practice",suggestedNextStep:`It's been ${c} days — reconnect with a practice`,motivationalMessage:"Even a short session re-tunes the body and mind.",action:{label:"Open practice",route:"/exercises"}}:l?{category:"reading",suggestedNextStep:`Continue your learning: "${l}"`,motivationalMessage:"A single article can shift your week.",action:{label:"Open library",route:"/learn"}}:m?{category:"reading",suggestedNextStep:"Pick up where you left off in your last chapter",motivationalMessage:"Momentum is the easiest thing to keep, the hardest to rebuild.",action:{label:"Continue reading",route:"/learn"}}:{category:"general",suggestedNextStep:s.suggestedNextStep,motivationalMessage:s.motivationalMessage}}const ei=()=>{var m;const{user:t}=Y(),{currentTier:s}=ce(),{progressData:l,loading:a}=Ws(),{data:n,loading:i}=It(),{data:r,isLoading:p}=te({queryKey:["smart-tip-signals",t==null?void 0:t.id,s],queryFn:()=>Xr(t.id,s),enabled:!!(t!=null&&t.id),staleTime:5*60*1e3}),d=p||a||i;return{tip:r?Zr(r,{suggestedNextStep:(l==null?void 0:l.suggestedNextStep)??"Start with foundation exercises",motivationalMessage:(l==null?void 0:l.motivationalMessage)??"Every master was once a beginner."},((m=n.suggestedArticles[0])==null?void 0:m.title)??null):null,loading:d}},ti=()=>{const{user:t}=Y(),s=me(Be(new Date,{weekStartsOn:1}),"yyyy-MM-dd"),l=me(Ue(new Date,{weekStartsOn:1}),"yyyy-MM-dd"),{data:a,isLoading:n}=te({queryKey:["weekly-schedule-stats",t==null?void 0:t.id,s],queryFn:async()=>{if(!(t!=null&&t.id))return{completed:0,total:0};const{data:i,error:r}=await S.from("user_schedule_items").select("id, is_completed").eq("user_id",t.id).gte("scheduled_date",s).lte("scheduled_date",l);if(r)throw r;const p=(i==null?void 0:i.length)||0;return{completed:(i==null?void 0:i.filter(c=>c.is_completed).length)||0,total:p}},enabled:!!(t!=null&&t.id),staleTime:2*60*1e3});return{completedItems:(a==null?void 0:a.completed)??0,totalItems:(a==null?void 0:a.total)??0,loading:n}},si={totalStudySessions:0,totalQuizzes:0,averageQuizScore:0,totalAIQuestions:0,studyStreak:0},ai=()=>{const{user:t}=Y(),{data:s,isLoading:l}=te({queryKey:["study-stats",t==null?void 0:t.id],queryFn:async()=>{var d,c,m,f;const[a,n,i,r]=await Promise.all([S.from("guided_study_sessions").select("*",{count:"exact",head:!0}).eq("user_id",t.id).not("completed_at","is",null),S.from("user_quiz_stats").select("total_quizzes_taken, average_score").eq("user_id",t.id).maybeSingle(),S.from("study_conversations").select("messages").eq("user_id",t.id),S.from("user_profiles").select("current_streak").eq("id",t.id).maybeSingle()]),p=((d=i.data)==null?void 0:d.reduce((h,x)=>{const g=x.messages;return h+Math.floor(((g==null?void 0:g.length)||0)/2)},0))||0;return{totalStudySessions:a.count||0,totalQuizzes:((c=n.data)==null?void 0:c.total_quizzes_taken)||0,averageQuizScore:((m=n.data)==null?void 0:m.average_score)||0,totalAIQuestions:p,studyStreak:((f=r.data)==null?void 0:f.current_streak)||0}},enabled:!!(t!=null&&t.id),staleTime:5*60*1e3});return{stats:s??si,loading:l}},ht="home-card-order",ri={"journal-activity":0,journeys:2,"weekly-practice":0,"exercise-progress":0,"integration-practices":0,goals:1,achievements:0,"smart-tip":0,"recent-progress":0,"meditation-insights":0,"learning-progress":1,"recent-highlights":1,"suggested-reading":1,"books-progress":1,"active-study":1},ze=["learning-progress","journal-activity","journeys","weekly-practice","active-study","exercise-progress","books-progress"],qe=["integration-practices","goals","achievements","smart-tip","re
28cent-highlights","suggested-reading","meditation-insights","recent-progress"],pt=["learning-progress","journal-activity","journeys","goals","smart-tip","achievements","recent-highlights","weekly-practice","active-study","exercise-progress","books-progress","integration-practices","suggested-reading","meditation-insights","recent-progress"],nt=6,ii=[...ze,...qe];function ni(){try{const t=localStorage.getItem(ht);if(t){const s=JSON.parse(t),l=h=>h.filter(x=>x!=="your-pathway");let a=l(Array.isArray(s.mainCards)?[...s.mainCards]:[]),n=l(Array.isArray(s.sidebarCards)?[...s.sidebarCards]:[]);n.includes("journal-activity")&&(n=n.filter(h=>h!=="journal-activity"),a.includes("journal-activity")||(a=["journal-activity",...a]));const i=h=>{if(h.includes("journeys"))return h;const x=h.indexOf("journal-activity");if(x===-1)return[...h,"journeys"];const g=[...h];return g.splice(x+1,0,"journeys"),g};a=i(a);let r=l(Array.isArray(s.mobileCards)?[...s.mobileCards]:[]);r=i(r);const p=h=>{const x=h.filter(o=>o!=="learning-progress"),g=x.indexOf("journal-activity");return g===-1?[...x,"learning-progress"]:(x.splice(g,0,"learning-progress"),x)};a=p(a),r=p(r);const d=h=>{const x=h.filter(o=>o!=="exercise-progress"),g=x.indexOf("books-progress");return g===-1?[...x,"exercise-progress"]:(x.splice(g,0,"exercise-progress"),x)};a=d(a),r=d(r);const c=lt(a,ze),m=lt(n,qe),f=lt(r,pt,ii);return{mainCards:c,sidebarCards:m,mobileCards:f}}}catch{}return{mainCards:[...ze],sidebarCards:[...qe],mobileCards:[...pt]}}function lt(t,s,l){if(!Array.isArray(t))return[...s];const a=new Set(l||s),n=t.filter(i=>a.has(i));for(const i of l||s)n.includes(i)||n.push(i);return n}function li(t,s,l,a){const n={...t,mainCards:[...t.mainCards],sidebarCards:[...t.sidebarCards],mobileCards:[...t.mobileCards]};if(s==="mobile")for(const i of["mainCards","sidebarCards"]){const r=n[i].indexOf(l),p=n[i].indexOf(a);r!==-1&&p!==-1&&([n[i][r],n[i][p]]=[n[i][p],n[i][r]])}else{const i=n.mobileCards.indexOf(l),r=n.mobileCards.indexOf(a);i!==-1&&r!==-1&&([n.mobileCards[i],n.mobileCards[r]]=[n.mobileCards[r],n.mobileCards[i]])}return n}function oi(t){return ci(t)}function ci(t){const[s,l]=v.useState(ni),a=v.useCallback((r,p,d)=>{l(c=>{const m=r==="main"?"mainCards":r==="sidebar"?"sidebarCards":"mobileCards",f=[...c[m]],h=d==="up"?p-1:p+1;if(h<0||h>=f.length)return c;const x=f[p],g=f[h];[f[p],f[h]]=[f[h],f[p]];const o={...c,[m]:f},u=li(o,r,x,g);return localStorage.setItem(ht,JSON.stringify(u)),u})},[]),n=v.useCallback(()=>{const r={mainCards:[...ze],sidebarCards:[...qe],mobileCards:[...pt]};localStorage.removeItem(ht),l(r)},[]),i=r=>r.filter(p=>{const d=ri[p];return d===void 0?!0:t>=d});return{mainCards:i(s.mainCards),sidebarCards:i(s.sidebarCards),mobileCards:i(s.mobileCards),moveCard:a,resetOrder:n}}function Qs(){const{profile:t,loading:s}=$e(),{currentTier:l,isLoading:a}=ce(),{data:n}=yt(),i=s||a,r=(l??0)===0,p=!!(t!=null&&t.guided_mode_opt_out),d=!i&&r&&!p,c=!i&&!p,m=ya(t==null?void 0:t.onboarding_stage),f=_a(m),h=(t==null?void 0:t.starter_pathway_slug)??null,x=v.useMemo(()=>{var o,u;if(!n)return null;if(h){const b=n.find(w=>w.slug===h);return b?b.slug:(Na(h),null)}return((o=n.find(b=>b.slug===ar))==null?void 0:o.slug)??((u=n[0])==null?void 0:u.slug)??null},[n,h]);return{loading:i,isGuided:d,showTodayHome:c,optedOut:p,stage:m,onboardingComplete:f,needsIntake:!i&&!!t&&m!=="complete"&&!p,recommendedPathwaySlug:x}}function di(){const{user:t}=Y();return te({queryKey:["active-pathway",t==null?void 0:t.id],enabled:!!(t!=null&&t.id),staleTime:60*1e3,queryFn:async()=>{if(!(t!=null&&t.id))return null;const{data:s,error:l}=await S.from("user_pathway_progress").select("*").eq("user_id",t.id).is("completed_at",null).order("last_accessed",{ascending:!1}).limit(1);if(l)throw l;const a=(s??[])[0];if(!a)return null;const{data:n,error:i}=await S.from("pathways").select("*").eq("id",a.pathway_id).maybeSingle();if(i)throw i;if(!n)return null;let r=a;try{const{data:p,error:d}=await S.rpc("get_pathway_progress",{p_pathway_id:a.pathway_id,p_user_id:t.id});if(!d){const c=Array.isArray(p)?p[0]:p;if(c){const m=Number(c.progress_percentage??0),f=c.current_step_id??null,h=c.completed_at??null;(m!==a.progress_percentage||f!==a.current_step_id||h!==a.completed_at)&&await S.from("user_pathway_progress").upsert({user_id:t.id,pathway_id:a.pathway_id,current_step_id:f,progress_percentage:m,last_accessed:a.last_accessed,completed_at:h},{onConflict:"user_id,pathway_id"}),r={...a,current_step_id:f,progress_percentage:m,completed_at:h}}}}catch{}return{progress:r,pathway:n}}})}function mi(){const t=L(),s=we(),{items:l,completedCount:a,totalCount:n,hasScheduledItems:i,loading:r}=Ge(),p=le({mutationFn:async c=>{const{error:m}=await S.from("user_schedule_items").update({is_completed:!c.is_completed,completed_at:c.is_completed?null:new Date().toISOString(),updated_at:new Date().toISOString()}).eq("id",c.id);if(m)throw m;return!c.is_completed},onSuccess:async c=>{c&&Ee("today_schedule_item_completed"),await Promise.all([s.invalidateQueries({queryKey:["todays-schedule"]}),s.invalidateQueries({queryKey:["schedule-items"]})])}});if(r||!i)return null;const d=l.slice(0,3);return e.jsxs("div",{className:"today-strip today-strip-indigo p-4 text-white",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2.5 text-xs text-white/70",children:[e.jsx("span",{className:"h-7 w-7 flex-shrink-0 rounded-lg border border-indigo-300/25 bg-indigo-400/10 flex items-center justify-center",children:e.jsx(ir,{className:"h-3.5 w-3.5 text-indigo-300"})}),e.jsxs("span",{children:[e.jsx("span",{className:"today-eyebrow block text-indigo-200/70",children:"Scheduled today"}),e.jsxs("span",{className:"tabular-nums text-white/85",children:[a,"/",n," done"]})]})]}),e.jsxs("button",{type:"button",onClick:()=>t("/exercises?view=schedule"),className:"text-[11px] text-white/50 hover:text-white transition-colors flex items-center gap-1",children:["Full schedule ",e.jsx(R,{className:"h-3 w-3"})]})]}),e.jsx("ul",{className:"mt-3 space-y-1",children:d.map(c=>{const m=rr(c);return e.jsxs("li",{className:"flex items-center gap-3",children:[e.jsx("button",{type:"button","aria-label":c.is_completed?`Mark ${c.title} incomplete`:`Mark ${c.title} complete`,onClick:f=>{f.stopPropagation(),p.mutate(c)},disabled:p.isPending,className:ee("h-6 w-6 flex-shrink-0 rounded-md border flex items-center justify-center transition-all",c.is_completed?"bg-emerald-500/25 border-emerald-400/50 text-emerald-200":"border-white/20 text-transparent hover:border-white/40"),children:e.jsx(De,{className:"h-3.5 w-3.5"})}),m?e.jsxs("button",{type:"button",onClick:()=>{Ee("today_schedule_item_opened"),t(m)},className:ee("flex-1 min-w-0 text-left text-sm min-h-[44px] flex items-center gap-1.5 transition-colors group",c.is_completed?"text-white/40 line-through hover:text-white/60":"text-white/80 hover:text-white"),children:[e.jsx("span",{className:"truncate",children:c.title}),e.jsx(_e,{className:"h-3.5 w-3.5 flex-shrink-0 text-white/30 group-hover:text-white/60 transition-colors"})]}):e.jsx("span",{className:ee("text-sm truncate min-h-[44px] flex items-center",c.is_completed?"text-white/40 line-through":"text-white/80"),children:c.title})]},c.id)})}),n>d.length&&e.jsxs("div",{className:"text-[11px] text-white/40 mt-1",children:["+",n-d.length," more today"]})]})}const ui=()=>{const{user:t}=Y(),s=we(),{data:l=[],isLoading:a}=te({queryKey:["goal-suggestions",t==null?void 0:t.id],queryFn:async()=>{const d=new Date;d.setDate(d.getDate()-7);const{data:c,error:m}=await S.from("goal_suggestions").select("*").eq("user_id",t.id).eq("status","pen
28ding").gte("created_at",d.toISOString()).order("created_at",{ascending:!1});if(m)throw m;return c||[]},enabled:!!(t!=null&&t.id),staleTime:60*1e3}),n=l.length,i=le({mutationFn:async d=>{const c=new Date;let m=null,f=null;if(d.timeframe==="daily"){m=c.toISOString().split("T")[0];const g=new Date(c);g.setDate(g.getDate()+1),f=g.toISOString().split("T")[0]}else if(d.timeframe==="weekly"){const g=c.getDay(),o=c.getDate()-g+(g===0?-6:1),u=new Date(c);u.setDate(o);const b=new Date(u);b.setDate(b.getDate()+6),m=u.toISOString().split("T")[0],f=b.toISOString().split("T")[0]}else d.timeframe==="monthly"&&(m=new Date(c.getFullYear(),c.getMonth(),1).toISOString().split("T")[0],f=new Date(c.getFullYear(),c.getMonth()+1,0).toISOString().split("T")[0]);const{error:h}=await S.from("user_goals").insert({user_id:t.id,category:d.category,timeframe:d.timeframe,title:d.title,description:d.description,target_value:d.target_value,unit:d.unit,tracking_type:d.tracking_type||"manual",is_ai_suggested:!0,source:d.source,period_start:m,period_end:f});if(h)throw h;const{error:x}=await S.from("goal_suggestions").update({status:"accepted"}).eq("id",d.id);if(x)throw x},onSuccess:()=>{s.invalidateQueries({queryKey:["goal-suggestions"]}),s.invalidateQueries({queryKey:["user-goals"]}),Z.success("Goal accepted and created!")},onError:d=>{var c;(c=d.message)!=null&&c.includes("Goal limit reached")?Z.error("Goal limit reached for this timeframe. Complete or remove a goal first."):Z.error("Failed to accept suggestion")}}),r=le({mutationFn:async d=>{const{error:c}=await S.from("goal_suggestions").update({status:"dismissed"}).eq("id",d);if(c)throw c},onSuccess:()=>{s.invalidateQueries({queryKey:["goal-suggestions"]})}}),p=le({mutationFn:async()=>{const{data:d,error:c}=await S.functions.invoke("ai-tools",{body:{action:"suggest-goals"}});if(c)throw c;if(d!=null&&d.error)throw new Error(d.error);return d},onSuccess:()=>{s.invalidateQueries({queryKey:["goal-suggestions"]}),Z.success("New goal suggestions generated!")},onError:d=>{var c,m;(c=d.message)!=null&&c.includes("Rate limit")||(m=d.message)!=null&&m.includes("rate_limit")?Z.error("Rate limit exceeded. Please try again later."):Z.error("Failed to generate suggestions")}});return{suggestions:l,pendingCount:n,isLoading:a,acceptSuggestion:i.mutate,dismissSuggestion:r.mutate,requestSuggestions:p.mutate,isRequesting:p.isPending,isAccepting:i.isPending}},xi=v.lazy(()=>ds(()=>import("./GoalsView-BLgUtpJF.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122]))),es={daily:0,weekly:1,monthly:2,milestone:3};function hi({open:t,onOpenChange:s}){const{currentTier:l}=ce(),{activeGoals:a,completedGoals:n,isLoading:i}=Ks(),{pendingCount:r}=ui(),p=a.length+n.length,d=(l??0)<1||i||p===0&&r===0,c=[...a].sort((m,f)=>{const h=(es[m.timeframe]??3)-(es[f.timeframe]??3);if(h!==0)return h;const x=m.target_value?m.current_value/m.target_value:0;return(f.target_value?f.current_value/f.target_value:0)-x}).slice(0,3);return e.jsxs(e.Fragment,{children:[!d&&e.jsxs("div",{className:"rounded-lg border border-white/10 bg-white/[0.02] overflow-hidden",children:[e.jsxs("button",{type:"button",onClick:()=>{Ee("today_goals_opened",{total:p}),s(!0)},className:"w-full min-h-[44px] flex items-center justify-between gap-3 px-3 text-white/60 hover:text-white hover:bg-white/[0.04] transition-all",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm min-w-0",children:[e.jsx(ue,{className:"h-3.5 w-3.5 text-emerald-300"}),e.jsxs("span",{className:"truncate",children:["Goals: ",n.length," of ",p," complete"]}),r>0&&e.jsxs("span",{className:"flex-shrink-0 px-2 py-0.5 rounded-full border border-emerald-400/30 bg-emerald-400/10 text-[10px] text-emerald-200",children:[r," new suggested"]})]}),e.jsx(R,{className:"h-3.5 w-3.5"})]}),c.length>0&&e.jsx("div",{className:"px-3 pb-2.5 space-y-2",children:c.map(m=>{const f=Hs[m.category],h=m.target_value!=null&&m.target_value>0,x=h?Math.min(Math.round(m.current_value/m.target_value*100),100):0;return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:`w-1.5 h-1.5 rounded-full flex-shrink-0 bg-gradient-to-r ${(f==null?void 0:f.gradient)??"from-emerald-400 to-cyan-400"}`}),e.jsx("span",{className:"text-xs text-white/75 truncate flex-1",children:m.title}),h&&e.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[e.jsx("div",{className:"w-12 h-1 rounded-full bg-white/10 overflow-hidden",children:e.jsx("div",{className:"h-full bg-gradient-to-r from-emerald-400 to-cyan-400",style:{width:`${x}%`}})}),e.jsxs("span",{className:"text-[10px] text-white/40 w-9 text-right tabular-nums",children:[m.current_value,"/",m.target_value]})]})]},m.id)})})]}),e.jsx(kt,{open:t,onOpenChange:s,children:e.jsxs(Ct,{side:"bottom",className:"h-[85vh] overflow-y-auto scrollbar-cosmic bg-slate-950/95 backdrop-blur-xl border-white/10 text-white",children:[e.jsx(St,{children:e.jsx(Dt,{className:"text-white",children:"Your goals"})}),e.jsx("div",{className:"mt-4",children:e.jsx(v.Suspense,{fallback:e.jsx(_,{className:"h-64 bg-white/5"}),children:t&&e.jsx(xi,{})})})]})})]})}const Vs=()=>ds(()=>import("./AchievementsGrid-CJEGhLFe.js"),__vite__mapDeps([123,1,2,124,48,122,3,39,55,24,33,34,27,17,35,36,37,16,38,23,40,41,31,32,42,43,44,15,45,30,29,28,46,47,49,50,51,52,53,54,56,21,57,58,8,59,60,61,22,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,20,78,11,79,80,81,82,83,84,25,85,86,87,88,18,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,26,5,6,7,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,14])).then(t=>({default:t.AchievementsGrid})),pi=v.lazy(Vs),gi=()=>{Vs()};function bi({open:t,onOpenChange:s,focusAchievementId:l=null}){const a=ms();v.useEffect(()=>{t&&Ee("today_achievements_opened")},[t]);const n=e.jsx(v.Suspense,{fallback:e.jsx(_,{className:"h-64 bg-white/5"}),children:t&&e.jsx(pi,{focusAchievementId:l})});return a?e.jsx(kt,{open:t,onOpenChange:s,children:e.jsxs(Ct,{side:"bottom",className:"h-[88vh] overflow-y-auto scrollbar-cosmic bg-slate-950/95 backdrop-blur-xl border-white/10 text-white",children:[e.jsx(St,{children:e.jsx(Dt,{className:"text-white",children:"Achievements"})}),e.jsx("div",{className:"mt-4",children:n})]})}):e.jsx(hs,{open:t,onOpenChange:s,children:e.jsxs(ps,{className:"max-w-3xl max-h-[85vh] overflow-y-auto scrollbar-cosmic bg-slate-950/95 backdrop-blur-xl border-white/10 text-white",children:[e.jsx(gs,{children:e.jsx(bs,{className:"text-white",children:"Achievements"})}),e.jsx("div",{className:"mt-2",children:n})]})})}const Tt=()=>{const{user:t}=Y(),{availableReportType:s,nextMilestone:l}=Nt(),{shouldShowPrompt:a,weekStartDate:n}=Ye(),i=s?`report-dismissed:${t==null?void 0:t.id}:patterns:${s}:${l??0}`:null,r=a?`report-dismissed:${t==null?void 0:t.id}:summary:${n}`:null;return{hasPatterns:!!s,hasSummary:!!a,patternsKey:i,summaryKey:r}},Le=t=>{if(!t||typeof window>"u")return!1;try{return localStorage.getItem(t)==="true"}catch{return!1}},fi=()=>{const{hasPatterns:t,hasSummary:s,patternsKey:l,summaryKey:a}=Tt();return t&&Le(l)||s&&Le(a)},wi=v.memo(()=>{const t=L(),{user:s}=Y(),{hasPatterns:l,hasSummary:a,patternsKey:n,summaryKey:i}=Tt(),{canAsk:r,record:p}=us(),[d,c]=v.useState(0),m=v.useMemo(()=>l?{key:n,label:"Dream pattern report ready",to:"/journal?tab=patterns"}:a?{key:i,label:"Weekly summary ready",to:"/journal?tab=summaries"}:null,[l,a,n,i]),f=l&&a,h=v.useCallback(()=>
28{if(m!=null&&m.key){try{localStorage.setItem(m.key,"true")}catch{}c(o=>o+1)}},[m]),x=v.useCallback(o=>{h(),t(o)},[h,t]),g=!!m&&!Le(m.key);return v.useEffect(()=>{if(!g||!(s!=null&&s.id)||typeof window>"u"||typeof Notification<"u"&&Notification.permission==="granted")return;const o=`report-optin-asked:${s.id}`;try{if(localStorage.getItem(o)==="true")return}catch{return}if(r()){try{localStorage.setItem(o,"true")}catch{}Rs("dream_saved"),p({asked:!0})}},[g,s==null?void 0:s.id,r,p]),!g||!m?null:e.jsxs($,{variant:"glass-medium",className:"bg-amber-400/[0.07] border-amber-400/25 p-3 text-white",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>x(m.to),className:"flex-1 min-h-[40px] flex items-center gap-2 text-left text-sm text-amber-200 hover:text-amber-100 transition-colors",children:[e.jsx(jt,{className:"h-4 w-4 flex-shrink-0"}),e.jsx("span",{className:"font-medium flex-1",children:m.label}),e.jsx(_e,{className:"h-4 w-4 flex-shrink-0 text-amber-200/50"})]}),e.jsx("button",{type:"button","aria-label":"Dismiss",onClick:h,className:"h-9 w-9 flex-shrink-0 flex items-center justify-center rounded-lg text-white/40 hover:text-white/80 hover:bg-white/[0.06] transition-colors",children:e.jsx(Me,{className:"h-4 w-4"})})]}),f&&e.jsx("button",{type:"button",onClick:()=>x("/journal?tab=summaries"),className:"mt-1 ml-6 text-xs text-amber-200/70 hover:text-amber-100 transition-colors",children:"Your weekly summary is ready too"})]})});wi.displayName="TodayReportReadyRow";const ji=()=>{const t=new Date;return t.setHours(0,0,0,0),t.toISOString()},Xs=()=>{const{user:t}=Y(),{data:s,isLoading:l}=te({queryKey:["today-completions",t==null?void 0:t.id],enabled:!!(t!=null&&t.id),staleTime:0,refetchOnMount:"always",refetchOnWindowFocus:!0,queryFn:async()=>{const a=ji(),[n,i]=await Promise.all([S.from("journal_entries").select("prompt_id, created_at").eq("user_id",t.id).gte("created_at",a),S.from("practice_sessions").select("exercise_id, completed_at").eq("user_id",t.id).gte("completed_at",a).order("completed_at",{ascending:!0})]);if(n.error)throw n.error;if(i.error)throw i.error;return{promptIds:(n.data||[]).map(r=>r.prompt_id).filter(Boolean),journalCount:(n.data||[]).length,exerciseIds:(i.data||[]).map(r=>r.exercise_id).filter(Boolean)}}});return{answeredPromptIds:new Set((s==null?void 0:s.promptIds)??[]),journaledToday:((s==null?void 0:s.journalCount)??0)>0,doneExerciseIds:(s==null?void 0:s.exerciseIds)??[],loading:l}},ts=()=>{const t=new Date,s=new Date(t.getFullYear(),0,0);return Math.floor((t.getTime()-s.getTime())/864e5)},ss={self_discovery:"Self-discovery",spiritual:"Spiritual",gratitude:"Gratitude",progress:"Progress",financial:"Financial",shadow:"Shadow",relationships:"Relationships"},Zs=v.memo(()=>{const t=L(),{user:s}=Y(),{data:l=[]}=Ka(),{hasPatterns:a,hasSummary:n,patternsKey:i,summaryKey:r}=Tt(),{canAsk:p,record:d}=us(),[c,m]=v.useState(0),{answeredPromptIds:f,journaledToday:h}=Xs(),[x,g]=v.useState(!1),o=v.useMemo(()=>l.filter(M=>M.category!=="ai_personalised"),[l]),u=o.length?o[ts()%o.length]:null,b=!!u&&f.has(u.id),w=v.useMemo(()=>{if(!o.length)return null;const M=ts()%o.length;for(let K=1;K<=o.length;K++){const A=o[(M+K)%o.length];if(!f.has(A.id))return A}return null},[o,f]),k=b&&x&&w?w:u,N=b&&!(x&&w),j=v.useMemo(()=>a?{key:i,label:"Dream pattern report ready",to:"/journal?tab=patterns"}:n?{key:r,label:"Weekly summary ready",to:"/journal?tab=summaries"}:null,[a,n,i,r]),y=v.useCallback(()=>{if(j!=null&&j.key){try{localStorage.setItem(j.key,"true")}catch{}m(M=>M+1)}},[j]),D=v.useCallback(M=>{y(),t(M)},[y,t]),C=!!j&&!Le(j.key);v.useEffect(()=>{if(!C||!(s!=null&&s.id)||typeof window>"u"||typeof Notification<"u"&&Notification.permission==="granted")return;const M=`report-optin-asked:${s.id}`;try{if(localStorage.getItem(M)==="true")return}catch{return}if(p()){try{localStorage.setItem(M,"true")}catch{}Rs("dream_saved"),d({asked:!0})}},[C,s==null?void 0:s.id,p,d]);const I=N?"/journal":k?`/journal?tab=new&entryType=guided&promptId=${k.id}`:"/journal?tab=new";return e.jsxs($,{className:"today-editorial p-5 text-white cursor-pointer transition-transform active:scale-[0.99]",onClick:()=>t(I),children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ot,{className:"h-3.5 w-3.5 text-pink-300"}),e.jsx("span",{className:"today-eyebrow text-pink-200/75",children:"Journal"}),k&&ss[k.category]&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-white/25",children:"·"}),e.jsx("span",{className:"today-eyebrow text-white/45",children:ss[k.c
28ategory]})]})]}),k?e.jsxs(e.Fragment,{children:[N&&e.jsxs("div",{className:"mt-2 flex items-center gap-1.5 text-sm font-medium text-emerald-200",children:[e.jsx(Ne,{className:"h-4 w-4 text-emerald-300"}),"Answered today — nice work"]}),e.jsxs("div",{className:`mt-2 font-serif italic text-lg md:text-xl leading-snug ${N?"text-white/45 line-through decoration-white/20":"text-white/95"}`,children:["“",k.prompt_text,"”"]}),N?w&&e.jsx("button",{type:"button",onClick:M=>{M.stopPropagation(),g(!0)},className:"mt-2 min-h-[36px] text-xs text-pink-200/80 hover:text-pink-100 underline-offset-2 hover:underline",children:"Another question"}):e.jsxs("div",{className:"text-[11px] text-white/45 mt-2",children:[h?"You journaled today · ":"","Tap to answer this in your journal."]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mt-2 font-serif text-lg md:text-xl",children:"New entry"}),e.jsx("div",{className:"text-[11px] text-white/45 mt-1",children:"Capture a dream or reflection."})]})]}),e.jsx("button",{type:"button","aria-label":"Open journal",title:"Open journal",onClick:M=>{M.stopPropagation(),t("/journal")},className:"h-11 w-11 flex-shrink-0 rounded-full border border-pink-300/30 bg-pink-400/10 shadow-[0_0_18px_-6px_hsl(330_90%_65%/0.7)] flex items-center justify-center text-pink-200 hover:bg-pink-400/20 transition-all",children:e.jsx(ot,{className:"h-4 w-4"})})]}),C&&j&&e.jsxs("div",{className:"mt-3 rounded-lg border border-amber-400/30 bg-amber-400/10",onClick:M=>M.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center gap-1 px-2 py-1.5",children:[e.jsxs("button",{type:"button",onClick:()=>D(j.to),className:"flex-1 min-h-[40px] flex items-center gap-2 px-1 text-left text-xs md:text-sm text-amber-200 hover:text-amber-100 transition-colors",children:[e.jsx(jt,{className:"h-4 w-4 flex-shrink-0 hidden md:block"}),e.jsx("span",{className:"font-medium flex-1 block md:truncate whitespace-normal md:whitespace-nowrap",children:j.label}),e.jsx(_e,{className:"h-4 w-4 flex-shrink-0 text-amber-200/50 hidden md:block"})]}),e.jsx("button",{type:"button","aria-label":"Dismiss",onClick:y,className:"h-9 w-9 flex-shrink-0 flex items-center justify-center rounded-lg text-white/40 hover:text-white/80 hover:bg-white/[0.06] transition-colors",children:e.jsx(Me,{className:"h-4 w-4"})})]}),a&&n&&e.jsx("button",{type:"button",onClick:()=>D("/journal?tab=summaries"),className:"mb-2 ml-3 text-xs text-amber-200/70 hover:text-amber-100 transition-colors",children:"Your weekly summary is ready too"})]})]})});Zs.displayName="TodayJournalTile";const as=(t,s)=>t.length>s?`${t.slice(0,s).trimEnd()}…`:t,ea=v.memo(()=>{const t=L(),{journeys:s,isLoading:l,setCommitmentStatus:a}=ys(),{currentTier:n,isLoading:i}=ce(),r=v.useMemo(()=>{const g=s.filter(o=>o.status==="active");return g.length===0?null:[...g].sort((o,u)=>new Date(u.updated_at).getTime()-new Date(o.updated_at).getTime())[0]},[s]),{data:p}=Us((r==null?void 0:r.id)??null),d=v.useMemo(()=>{if(!r)return null;const g=Ns(r.template_id);if(!g)return null;const o=g.steps.find(w=>w.step===r.current_step);if(!o)return null;const u=!!p&&p.journey_step===r.current_step,b=g.steps.find(w=>w.step===r.current_step+1);return u&&b?{label:"Up next",intent:b.intent}:r.current_step>=r.total_steps?{label:"Final step",intent:o.intent}:{label:"Next",intent:o.intent}},[r,p]),c=v.useMemo(()=>{var w,k,N;const g=(w=p==null?void 0:p.content)==null?void 0:w.trim();if(!g)return null;const o=_s(g),u=(N=(k=ks(o,"response"))==null?void 0:k.value)==null?void 0:N.trim(),b=(u&&u.length>0?u:g).replace(/\*\*([^*]+):\*\*/g,"").replace(/\*\*/g,"").replace(/\s+/g," ").trim();return b?as(b,110):null},[p]),m=v.useMemo(()=>r?null:s.filter(g=>{var o;return g.status==="completed"&&((o=g.completion_forward_question)==null?void 0:o.trim())}).sort((g,o)=>new Date(o.updated_at).getTime()-new Date(g.updated_at).getTime())[0]??null,[s,r]),f=v.useMemo(()=>{const g=[];for(const o of s)(Array.isArray(o.behavioural_commitments)?o.behavioural_commitments:[]).forEach((b,w)=>{b.completed||g.push({journeyId:o.id,journeyTitle:o.title,index:w,text:b.text,dueAt:b.due_at})});return g.sort((o,u)=>Date.parse(o.dueAt)-Date.parse(u.dueAt))[0]??null},[s]),h=g=>{const o=new Date(g);return Number.isNaN(o.getTime())?"":vt(o)?"Today":fs(o)?"Tomorrow":me(o,"EEE MMM d")};if(l||i||n<1)return null;const x=r?Math.min((r.current_step-1)/r.total_steps*100,100):0;return e.jsxs("div",{className:"rounded-lg border border-white/10 bg-white/[0.02] overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 pt-2.5 pb-1 text-[11px] uppercase tracking-widest text-white/45",children:[e.jsx(pe,{className:"h-3.5 w-3.5 text-violet-300"}),"Journey"]}),r?e.jsxs("button",{type:"button",onClick:()=>t(`/exercises?view=journeys&journeyId=${r.id}`),className:"w-full text-left px-3 py-2 hover:bg-white/[0.04] transition-all",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-white/85 font-medium truncate flex-1 min-w-0",children:r.title}),e.jsxs("span",{className:"text-[11px] tabular-nums text-white/45 flex-shrink-0",children:[r.current_step,"/",r.total_steps]}),e.jsx(R,{className:"h-3.5 w-3.5 flex-shrink-0 text-white/40"})]}),e.jsx("div",{className:"mt-1.5 h-1 w-full overflow-hidden rounded-full bg-white/10",children:e.jsx("div",{className:"h-full bg-gradient-to-r from-violet-400 to-fuchsia-400 transition-all",style:{width:`${x}%`}})}),d&&e.jsxs("p",{className:"mt-2 text-xs italic text-violet-200/80 leading-relaxed",children:[e.jsx("span",{className:"not-italic uppercase tracking-wider text-violet-300/70 mr-1.5 text-[10px]",children:d.label}),as(d.intent,140)]}),c&&e.jsxs("p",{className:"mt-1.5 text-xs italic text-violet-200/55 leading-relaxed pl-2 border-l-2 border-violet-400/25",children:["“",c,"”"]}
28)]}):m?e.jsxs("button",{type:"button",onClick:()=>t("/exercises?view=journeys"),className:"w-full text-left px-3 py-2 hover:bg-white/[0.04] transition-all",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] uppercase tracking-wider text-violet-300/75",children:[e.jsx(P,{className:"h-3 w-3"}),"Sit with this from ",m.title]}),e.jsx("p",{className:"mt-1 text-sm italic text-violet-100/85 leading-relaxed",children:m.completion_forward_question}),e.jsxs("div",{className:"mt-2 flex items-center gap-1.5 text-xs text-violet-300",children:["Start a journey ",e.jsx(R,{className:"h-3.5 w-3.5"})]})]}):e.jsxs("button",{type:"button",onClick:()=>t("/exercises?view=journeys"),className:"w-full min-h-[44px] flex items-center justify-between gap-3 px-3 py-2 text-left text-sm text-white/70 hover:text-white hover:bg-white/[0.04] transition-all",children:[e.jsx("span",{children:"Start a guided multi-step reflection"}),e.jsx(R,{className:"h-3.5 w-3.5 flex-shrink-0 text-white/40"})]}),f&&e.jsxs("div",{className:"flex items-start gap-2 px-3 py-2 border-t border-white/5",children:[e.jsx(ue,{className:"h-3.5 w-3.5 text-emerald-300 flex-shrink-0 mt-0.5"}),e.jsxs("button",{type:"button",onClick:()=>t(`/exercises?view=journeys&journeyId=${f.journeyId}`),className:"flex-1 min-w-0 text-left",children:[e.jsx("p",{className:"text-xs text-emerald-50/85 line-clamp-2 leading-snug",children:f.text}),e.jsx("span",{className:"text-[10px] text-emerald-200/70",children:h(f.dueAt)})]}),e.jsx("button",{type:"button","aria-label":"Mark commitment complete",onClick:()=>a.mutate({journeyId:f.journeyId,index:f.index,completed:!0},{onSuccess:()=>Z.success("Commitment complete ✓"),onError:()=>Z.error("Could not update commitment")}),className:"flex-shrink-0 w-6 h-6 rounded-full border border-emerald-300/40 text-emerald-200 hover:bg-emerald-400/30 hover:text-white flex items-center justify-center transition-colors",children:e.jsx(De,{className:"h-3 w-3"})})]})]})});ea.displayName="TodayJourneyRow";const ta=v.memo(()=>{var p,d,c;const t=L(),{latestReport:s}=Nt(),{summaries:l}=Ye(),a=((p=s==null?void 0:s.report_content)==null?void 0:p.integrationPractices)??[],n=((c=(d=l==null?void 0:l[0])==null?void 0:d.summary_content)==null?void 0:c.integrationPractices)??[],i=[...a.slice(0,1).map(m=>({text:m,to:"/journal?tab=patterns&section=integration"})),...n.slice(0,1).map(m=>({text:m,to:"/journal?tab=summaries"}))].slice(0,2),r=i.length===2?i:[...i,...a.length>1?[{text:a[1],to:"/journal?tab=patterns&section=integration"}]:n.length>1?[{text:n[1],to:"/journal?tab=summaries"}]:[]].slice(0,2);return r.length===0?null:e.jsxs("div",{className:"rounded-lg border border-white/10 bg-white/[0.02] overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 pt-2.5 pb-1 text-[11px] uppercase tracking-widest text-white/45",children:[e.jsx(P,{className:"h-3.5 w-3.5 text-purple-300"}),"Integration practice"]}),r.map((m,f)=>e.jsxs("button",{type:"button",onClick:()=>t(m.to),className:"w-full min-h-[44px] flex items-center justify-between gap-3 px-3 py-2 text-left text-sm text-white/75 hover:text-white hover:bg-white/[0.04] transition-all",children:[e.jsx("span",{className:"line-clamp-2",children:m.text}),e.jsx(R,{className:"h-3.5 w-3.5 flex-shrink-0 text-white/40"})]},f))]})});ta.displayName="TodayIntegrationRow";const vi="morning-meditation-ascending-short",yi="evening-meditation-returning-current",Ni=18,_i=t=>{const{user:s}=Y();return te({queryKey:["today-pathway-exercise-step",t],enabled:!!(s!=null&&s.id)&&!!t,staleTime:60*1e3,queryFn:async()=>{const{data:l,error:a}=await S.from("pathway_steps").select("id, resource_type, resource_id, title_override").eq("id",t).maybeSingle();if(a)throw a;return!l||l.resource_type!=="exercise"||!l.resource_id?null:{exerciseId:l.resource_id}}})},ki=()=>{const{doneExerciseIds:t,loading:s}=Xs(),l=new Set(t),a=lr(),{data:n,isLoading:i}=Es(),r=(n||[]).find(j=>!j.progress.completed_at)||null,{data:p,isLoading:d}=_i(r==null?void 0:r.progress.current_step_id),{items:c,loading:m}=Ge(),{recommendation:f,loading:h}=Ls(),{getExerciseUnlockStatus:x,isLoading:g}=cr(),o=a.isLoading||i||d||m||h||g||s,u=(j,y)=>{const D=ct(j);
28return!D||l.has(j)||!x(j).isUnlocked?null:{exerciseId:j,title:D.title,reason:y,duration:D.duration||null,route:`/exercises/${j}`}},b=()=>{if(a.activeThread){const C=or({dreams:a.dreams||[],reflections:a.reflections||[]});if(C.id!=="log-dream"){const I=u(C.id,"Continue your dream thread");if(I)return I}if(C.alternative){const I=u(C.alternative.id,"Continue your dream thread");if(I)return I}}if(p!=null&&p.exerciseId&&r){const C=u(p.exerciseId,`${r.pathway.title} — next in your arc`);if(C)return C}const j=(c||[]).find(C=>C.item_type==="exercise"&&!C.is_completed&&C.item_id);if(j!=null&&j.item_id){const C=u(j.item_id,"On your schedule today");if(C)return C}const D=new Date().getHours()>=Ni?u(yi,"Wind down with the returning current"):u(vi,"Start the day grounded");if(D)return D;if(f!=null&&f.exercise){const C=u(f.exercise.id,f.reason||"Continue your practice");if(C)return C}return null},w=t[0],k=w?ct(w):null,N=k?{exerciseId:w,title:k.title}:null;return{suggestion:o?null:b(),completedToday:N,loading:o}},sa=v.memo(()=>{const t=L(),{profile:s}=$e(),{suggestion:l,completedToday:a}=ki(),n=(s==null?void 0:s.current_streak)??0,i=(l==null?void 0:l.route)??"/exercises";return e.jsxs($,{role:"button",tabIndex:0,"aria-label":l?`Open ${l.title}`:"Open Exercise",onClick:()=>t(i),onKeyDown:r=>{(r.key==="Enter"||r.key===" ")&&(r.preventDefault(),t(i))},className:"today-hero p-5 md:p-6 text-white cursor-pointer transition-transform active:scale-[0.99]",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ae,{className:"h-3.5 w-3.5 text-fuchsia-300"}),e.jsx("span",{className:"today-eyebrow text-fuchsia-200/80",children:"Practice today"})]}),e.jsxs("div",{className:"flex items-center gap-1.5 rounded-full border border-orange-400/25 bg-orange-400/10 px-2.5 py-1 text-[11px] text-orange-200",children:[e.jsx(Ie,{className:"h-3 w-3 text-orange-400"}),e.jsx("span",{className:"font-medium",children:n}),e.jsx("span",{className:"text-orange-200/70",children:n===1?"day":"days"})]})]}),a&&e.jsxs("div",{className:"mt-3 flex items-center gap-2 rounded-lg border border-emerald-400/30 bg-emerald-400/10 px-3 py-2 text-sm text-emerald-200",children:[e.jsx(Ne,{className:"h-4 w-4 flex-shrink-0 text-emerald-300"}),e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"font-medium",children:"Practice done today — well done."})," ",e.jsx("span",{className:"text-emerald-200/70",children:a.title})]})]}),a&&l&&e.jsx("div",{className:"mt-3 today-eyebrow text-white/45",children:"Up next"}),e.jsx("h2",{className:"mt-3 font-serif text-2xl md:text-3xl leading-tight tracking-tight text-white",children:l?l.title:"Choose a practice"}),e.jsxs("div",{className:"mt-1.5 text-sm text-white/65 flex items-center gap-2 flex-wrap",children:[e.jsx("span",{children:l?l.reason:n>0?"Keep it alive — do a practice today.":"Do a practice today to start."}),(l==null?void 0:l.duration)&&e.jsxs("span",{className:"flex items-center gap-1 text-white/50",children:[e.jsx(be,{className:"h-3 w-3"}),l.duration]})]}),e.jsxs("div",{className:"mt-5 flex items-center gap-3",children:[e.jsxs("span",{className:"today-cta inline-flex h-11 items-center gap-2 rounded-full px-5 text-sm font-semibold text-white",children:[l?"Begin practice":"Open Exercise",e.jsx(R,{className:"h-4 w-4"})]}),l&&e.jsx("button",{type:"button",onClick:r=>{r.stopPropagation(),t("/exercises")},className:"h-11 px-3 text-xs text-white/60 hover:text-white transition-colors",children:"Browse all"})]})]})});sa.displayName="TodayPracticeTile";function Ci({read:t,total:s}){const l=s>0?Math.min(t/s,1):0,a=15,n=2*Math.PI*a;return e.jsxs("svg",{viewBox:"0 0 36 36",className:"h-9 w-9 flex-shrink-0","aria-hidden":"true",children:[e.jsx("circle",{cx:"18",cy:"18",r:a,fill:"none",stroke:"currentColor",strokeWidth:"3",className:"text-white/10"}),e.jsx("circle",{cx:"18",cy:"18",r:a,fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeDasharray:`${n*l} ${n}`,transform:"rotate(-90 18 18)",className:"text-emerald-400 transition-all"}),e.jsx("text",{x:"18",y:"21.5",textAnchor:"middle",className:"fill-white/80",style:{fontSize:"11px",fontWeight:600},children:t})]})}const aa=v.memo(()=>{var n;const t=L(),{data:s,loading:l}=It(),a=(n=s.suggestedArticles)==null?void 0:n[0];return l||!a?null:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>t(`/learn?articleId=${a.id}`),className:"flex-1 min-w-0 min-h-[44px] flex items-center gap-2 px-3 rounded-lg border border-white/10 bg-white/[0.02] text-left text-white/70 hover:text-white hover:bg-white/[0.05] transition-all",children:[e.jsx(B,{className:"h-3.5 w-3.5 flex-shrink-0 text-emerald-300"}),e.jsx("span",{className:"text-[11px] uppercase tracking-widest text-white/45 flex-shrink-0",children:"Read next"}),e.jsx("span",{className:"text-sm truncate",children:a.title})]}),e.jsx("button",{type:"button","aria-label":`${s.readArticles} of ${s.totalArticles} articles read`,title:`${s.readArticles} of ${s.totalArticles} articles read`,onClick:()=>t("/learn"),className:"h-11 w-11 rounded-lg border border-white/10 bg-white/[0.02] flex items-center justify-center hover:bg-white/[0.06] transition-all",children:e.jsx(Ci,{read:s.readArticles,total:s.totalArticles})})]})});aa.displayName="TodayReadingRow";function Si(){const t=L(),[s,l]=v.useState(!1),{currentTier:a,rawTier:n,isSubscribed:i,nextTierProgress:r,isLoading:p}=ce(),{guidedSessions:d}=wt(),c=d==null?void 0:d[0],m=c?`/learn?view=active-session&sessionId=${c.sessionId}`:"/learn?view=plans";if(p)return e.jsx("div",{className:"h-[74px] rounded-xl border border-white/10 bg-white/[0.03] animate-pulse"});const f=!!(r!=null&&r.complete),h=os.find(w=>w.tier===a),x=!i,g=(r==null?void 0:r.progress)??0,o=(r==null?void 0:r.requirements)??[],u=Gs(r,m),b=w=>{l(!1),t(w.path,w.state?{state:w.state}:void 0)};return f?e.jsxs("div",{className:"today-strip today-strip-amber flex items-center gap-2 px-3 py-2.5 text-xs text-amber-200/90",children:[e.jsx(P,{className:"h-3.5 w-3.5 text-amber-300"}),"Tier ",n," · all features unlocked"]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"today-strip",children:[e.jsxs("button",{type:"button",onClick:()=>l(!0),className:"w-full px-3 pt-3 pb-3 text-left hover:bg-white/[0.03] transition-colors","aria-label":"View your tier progress",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"flex items-center gap-1.5 rounded-full border border-violet-400/35 bg-violet-500/20 px-2.5 py-1 text-[11px] font-semibold text-violet-100 shadow-[0_0_18px_-6px_hsl(270_90%_65%/0.8)]",children:[e.jsx(oe,{className:"h-3 w-3 fill-violet-300 text-violet-300"}),"Tier ",a]}),e.jsx("span",{className:"text-sm text-white/85 truncate",children:h==null?void 0:h.name}),e.jsxs("span",{className:"ml-auto flex items-center gap-1 text-[11px] text-white/50 whitespace-nowrap",children:[a<=1?"Next unlock":`${g}% to Tier ${a+1}`,e.jsx(_e,{className:"h-3.5 w-3.5"})]})]}),e.jsx("div",{className:"today-track mt-2.5 h-1.5",children:e.jsx("div",{className:"h-full rounded-full bg-gradient-to-r from-violet-500 via-fuchsia-500 to-cyan-400 transition-all shadow-[0_0_12px_hsl(285_90%_60%/0.6)]",style:{width:`${g}%`}})})]}),u?e.jsxs("button",{type:"button",onClick:()=>b(u.route),className:"w-full flex items-center gap-2.5 px-3 py-2.5 border-t border-white/[0.06] text-xs md:text-sm text-white/75 hover:text-white hover:bg-white/[0.05] transition-colors",children:[e.jsx("span",{className:"h-6 w-6 flex-shrink-0 rounded-md border border-violet-300/25 bg-vi
28olet-400/10 flex items-center justify-center",children:e.jsx(u.icon,{className:"h-3.5 w-3.5 text-violet-300"})}),e.jsxs("span",{className:"flex-1 text-left",children:[e.jsx("span",{className:"text-white/45",children:"Next: "}),u.text]}),e.jsx(R,{className:"h-3.5 w-3.5 text-violet-300/60 flex-shrink-0"})]}):null,x&&e.jsxs("button",{type:"button",onClick:()=>t("/profile?view=subscription"),className:"w-full flex items-center gap-2 px-3 py-2 border-t border-white/[0.07] text-[11px] md:text-xs text-white/45 hover:text-white/70 hover:bg-white/[0.04] transition-colors",children:[e.jsx(Fe,{className:"h-3 w-3 text-white/35 flex-shrink-0"}),e.jsx("span",{className:"flex-1 text-left",children:"AI features (interpretations, reports, study chat) need a subscription"}),e.jsx(R,{className:"h-3 w-3 text-white/25 flex-shrink-0"})]})]}),e.jsx(kt,{open:s,onOpenChange:l,children:e.jsxs(Ct,{side:"bottom",className:"bg-slate-900/95 backdrop-blur-xl border-white/10 text-white max-h-[80vh] overflow-y-auto scrollbar-cosmic",children:[e.jsxs(St,{className:"text-left",children:[e.jsx(Dt,{className:"text-white",children:"Your progress"}),e.jsxs(nr,{className:"text-white/55",children:[g,"% of the way to Tier ",a+1,r!=null&&r.tierName?` · ${r.tierName}`:""]})]}),e.jsxs("div",{className:"mt-4 space-y-2 pb-4",children:[o.map(w=>{const k=Fs[w.name]??oe,N=Mt(w.name,m);return e.jsxs("button",{type:"button",onClick:()=>N&&b(N),className:ee("w-full flex items-center gap-2 px-3 py-2.5 rounded-lg border text-xs transition-colors",w.complete?"border-emerald-500/25 bg-emerald-500/10 text-emerald-200":"border-white/10 bg-white/[0.03] text-white/75 hover:bg-white/[0.07]"),children:[w.complete?e.jsx(Ne,{className:"h-3.5 w-3.5 text-emerald-400"}):e.jsx(k,{className:"h-3.5 w-3.5 text-white/45"}),e.jsx("span",{className:"flex-1 text-left font-medium",children:w.name}),e.jsxs("span",{className:"font-mono text-[11px] text-white/50",children:[w.current,"/",w.required,w.name.includes("Emotional")?" mins":""]}),N&&e.jsx(R,{className:"h-3.5 w-3.5 text-white/25"})]},w.name)}),(r==null?void 0:r.specialRequirement)&&e.jsxs("button",{type:"button",onClick:()=>b({path:"/exercises?view=exercises",state:{scrollTo:"Advanced"}}),className:ee("w-full flex items-center gap-2 px-3 py-2.5 rounded-lg border text-xs transition-colors",r.specialRequirementComplete?"border-emerald-500/25 bg-emerald-500/10 text-emerald-200":"border-amber-500/25 bg-amber-500/10 text-amber-200 hover:bg-amber-500/15"),children:[e.jsx(P,{className:"h-3.5 w-3.5"}),e.jsxs("span",{className:"flex-1 text-left font-medium",children:[r.specialRequirement,r.specialRequirementComplete?" ✓":""]}),e.jsx(R,{className:"h-3.5 w-3.5 opacity-50"})]})]})]})})]})}const rs="rotate-tip-dismissed",is="rotate-tip-shows",Di=3,Ai="(max-width: 639px) and (orientation: portrait)";function $i(){const[t,s]=v.useState(!1),[l,a]=v.useState(!1);if(v.useEffect(()=>{try{if(localStorage.getItem(rs)==="1")return;const i=parseInt(localStorage.getItem(is)||"0",10),r=isNaN(i)?0:i;if(r>=Di)return;localStorage.setItem(is,String(r+1))}catch{}s(!0)},[]),v.useEffect(()=>{if(!t||typeof window>"u")return;const i=window.matchMedia(Ai),r=()=>a(i.matches);return r(),i.addEventListener("change",r),()=>i.removeEventListener("change",r)},[t]),!t||!l)return null;const n=()=>{try{localStorage.setItem(rs,"1")}catch{}s(!1)};return e.jsxs("div",{className:"relative rounded-xl border border-white/10 bg-slate-900/60 backdrop-blur-xl p-3 pr-10 shadow-lg",children:[e.jsx("div",{className:"absolute inset-0 rounded-xl bg-gradient-to-r from-purple-600/15 via-blue-600/10 to-cyan-600/15 pointer-events-none"}),e.jsxs("div",{className:"relative flex items-start gap-3",children:[e.jsx("div",{className:"flex-shrink-0 rounded-lg bg-cyan-500/20 p-2",children:e.jsx(At,{className:"h-4 w-4 text-cyan-300"})}),e.jsx("p",{className:"text-xs text-white/85 leading-relaxed pt-0.5",children:"Turn your phone sideways for a wider, tablet-style view."})]}),e.jsx("button",{onClick:n,"aria-label":"Don't show again",className:"absolute top-2 right-2 rounded-full p-1 text-white/60 hover:text-white hover:bg-white/10 transition-colors",children:e.jsx(Me,{className:"h-4 w-4"})})]})}function Mi({onOpen:t}){const{achievements:s,isAchievementUnlocked:l,getProgress:a,loading:n}=$t({autoCheck:!1}),i=v.useMemo(()=>{let p=null;for(const d of s){if(l(d.id))continue;const c=a(d);if(!c||c.required<=0||c.current<=0||c.current>=c.required)continue;const m=c.current/c.required;(!p||m>p.ratio)&&(p={id:d.id,name:d.name,current:c.current,required:c.required,ratio:m})}return p},[s,l,a]);if(n||!i)return null;const r=Math.min(100,Math.round(i.ratio*100));return e.jsxs("button",{type:"button",onClick:()=>t(i.id),className:"today-strip today-strip-amber w-full text-left px-3 py-3 hover:brightness-125 transition-all",children:[e.jsxs("div",{className:"flex items-center gap-2.5 text-xs text-white/60",children:[e.jsx("span",{className:"h-7 w-7 flex-shrink-0 rounded-lg border border-amber-300/25 bg-amber-300/10 flex items-center justify-center shadow-[0_0_16px_
28-6px_hsl(45_95%_60%/0.7)]",children:e.jsx(se,{className:"h-3.5 w-3.5 text-amber-300"})}),e.jsxs("span",{className:"flex-1 truncate",children:[e.jsx("span",{className:"today-eyebrow block text-amber-200/70",children:"Closest badge"}),e.jsx("span",{className:"text-white/85",children:i.name})]}),e.jsxs("span",{className:"tabular-nums text-white/45",children:[i.current,"/",i.required]})]}),e.jsx("div",{className:"today-track mt-2.5 h-1",children:e.jsx("div",{className:"h-full rounded-full bg-gradient-to-r from-amber-400 to-yellow-300 shadow-[0_0_10px_hsl(45_95%_60%/0.6)]",style:{width:`${r}%`}})})]})}function Ii(){const{user:t}=Y(),{data:s,isLoading:l}=te({queryKey:["continue-where-left-off",t==null?void 0:t.id],queryFn:async()=>{var r;const{data:a,error:n}=await S.from("guided_study_sessions").select("id, last_accessed, current_section, study_path:study_paths(title)").eq("user_id",t.id).is("completed_at",null).order("last_accessed",{ascending:!1}).limit(1).maybeSingle();if(n)throw n;return a?{kind:"guided_study",label:((r=a.study_path)==null?void 0:r.title)??"Guided study",detail:a.current_section!=null?`Section ${a.current_section}`:null,href:`/learn?view=active-session&sessionId=${a.id}`,lastAt:a.last_accessed}:null},enabled:!!(t!=null&&t.id),staleTime:1e3*60*5});return{resumePoint:s??null,loading:l}}const ra=v.memo(()=>{const t=L(),{resumePoint:s,loading:l}=Ii();return l||!s?null:e.jsxs("button",{type:"button",onClick:()=>{zs("resume_"+s.kind),t(s.href)},className:"today-chip w-full min-h-[46px] flex items-center gap-2.5 px-3 text-left text-white/70 hover:text-white",children:[e.jsx("span",{className:"h-7 w-7 flex-shrink-0 rounded-lg border border-violet-300/25 bg-violet-400/10 flex items-center justify-center",children:e.jsx(At,{className:"h-3.5 w-3.5 text-violet-300"})}),e.jsx("span",{className:"today-eyebrow text-white/45 flex-shrink-0",children:"Pick up"}),e.jsxs("span",{className:"text-sm truncate flex-1 min-w-0",children:[s.label,s.detail&&e.jsxs("span",{className:"text-white/45",children:[" · ",s.detail]})]}),e.jsx(R,{className:"h-3.5 w-3.5 flex-shrink-0 text-white/40"})]})});ra.displayName="ContinueRow";function Ti(){const t=L(),{themes:s,clusters:l,hasEnoughData:a,loading:n,responses:i}=xr(),{landmarks:r,loading:p}=hr(),{namedThreads:d}=pr(l),{isAdmin:c,loading:m}=cs(),f=gr({themes:s,clusters:l,namedThreads:d,landmarks:r,responses:i}),h=v.useMemo(()=>f.filter(u=>u.lifecycleState!=="past_chapter").slice(0,br),[f]),x=h[0],g=!n&&!p&&a&&c,o=v.useRef(!1);return v.useEffect(()=>{!g||o.current||(o.current=!0,dr(h.length))},[g,h.length]),m||!c||n||!a||!x?null:e.jsx($,{variant:"glass-medium",className:"bg-slate-900/40 border-white/10 p-4 md:p-5 text-white",children:e.jsxs("button",{type:"button",onClick:()=>{mr(),t("/inner-map")},className:"w-full text-left group",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[11px] uppercase tracking-widest text-white/50",children:[e.jsx(P,{className:"h-3.5 w-3.5 text-cyan-300"}),"Your inner map"]}),e.jsx("p",{className:"text-xs text-white/45 mt-2",children:h.length===1?"1 thing keeps coming back in what you recorded.":`${h.length} things keep coming back in what you recorded.`}),e.jsxs("div",{className:"mt-3",children:[e.jsx("p",{className:"text-sm font-medium text-white/90 capitalize leading-snug",children:x.heading}),e.jsx("p",{className:"text-[11px] text-white/50 leading-relaxed mt-0.5 line-clamp-2",children:x.line})]}),e.jsxs("span",{className:"mt-3 inline-flex items-center gap-1 text-xs text-cyan-200/80 group-hover:text-cyan-100 transition-colors",children:["Open your inner map",e.jsx(_e,{className:"h-3.5 w-3.5"})]})]})})}function Ei(){var K;const t=L(),[s,l]=ka(),{profile:a,updateGuidedPrefs:n}=$e(),{data:i,isLoading:r}=di(),{data:p}=yt(),{recommendedPathwaySlug:d}=Qs(),[c,m]=v.useState(!1),[f,h]=v.useState(!1),[x,g]=v.useState(!1),[o,u]=v.useState(null),b=we(),{user:w}=Y(),k=fi(),N=v.useCallback(()=>{gi(),w!=null&&w.id&&b.prefetchQuery(Os(w.id))},[b,w==null?void 0:w.id]);v.useEffect(()=>{const A=window.requestIdleCallback;if(A){const W=A(N);return()=>{var H;return(H=window.cancelIdleCallback)==null?void 0:H.call(window,W)}}const U=setTimeout(N,1500);return()=>clearTimeout(U)},[N]),v.useEffect(()=>{const A=s.get("open");if(A!=="goals"&&A!=="achievements")return;A==="goals"?h(!0):g(!0);const U=new URLSearchParams(s);U.delete("open"),l(U,{replace:!0})},[s,l]);const j=d?p==null?void 0:p.find(A=>A.slug===d):void 0,y=(i==null?void 0:i.pathway)??j??null,D=((K=i==null?void 0:i.progress)==null?void 0:K.progress_percentage)??0,C=!!i,I=y?Ps(y):null;v.useEffect(()=>{r||!y||ur(C?"pathway_continue":"pathway_begin",y.slug)},[r,y,C]);const M=()=>{y&&(zs(C?"pathway_continue":"pathway_begin",y.slug),t(`/pathways/${y.slug}`))};return e.jsx(xs,{children:e.jsxs("div",{className:"mx-auto max-w-2xl px-3 md:px-4 py-4 md:py-8 space-y-4 md:space-y-6",children:[e.jsx($i,{}),e.jsxs("div",{className:"px-1 flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"font-serif text-2xl md:text-3xl text-white tracking-tight",children:["Welcome",a!=null&&a.username?`, ${a.username}`:""]}),e.jsx("p",{className:"text-sm text-white/55 mt-1",children:"One step at a time. Here's your next thing."})]}),e.jsx("button",{type:"button","aria-label":"Achievements",title:"Achievements",onClick:()=>{u(null),g(!0)},onMouseEnter:N,onPointerDown:N,className:"flex-shrink-0 h-11 w-11 rounded-2xl border border-yellow-300/25 bg-yellow-300/[0.06] shadow-[0_0_20px_-6px_hsl(45_95%_60%/0.6)] flex items-center justify-center text-yellow-300 hover:text-yellow-200 hover:bg-yellow-300/10 transition-all",children:e.jsx(se,{className:"h-5 w-5"})})]}),e.jsx(Si,{}),e.jsx(sa,{}),e.jsx(Zs,{}),r?e.jsx("div",{className:"today-feature h-44 animate-pulse"}):y&&I?e.jsxs("div",{className:"today-feature text-white p-5 md:p-6 cursor-pointer transition-all",onClick:M,children:[e.jsx("div",{className:ee("absolute inset-x-0 top-0 h-[2px] bg-gradient-to-r opacity-90",I.from,I.via,I.to)}),e.jsxs("div",{className:"inline-flex items-center gap-1.5 today-eyebrow rounded-full border border-indigo-300/25 bg-indigo-400/10 px-2.5 py-1 text-indigo-200/90 mb-3",children:[e.jsx(Re,{className:"h-3 w-3"}),"Your next step"]}),e.jsx("h2",{className:"font-serif text-2xl md:text-3xl leading-snug tracking-tight",children:y.title}),y.description&&e.jsx("p",{className:"text-sm text-white/60 mt-2 leading-relaxed",children:y.description}),C&&e.jsxs("div",{className:"mt-5 flex items-center gap-3",children:[e.jsx("div",{className:"today-track flex-1 h-1.5",children:e.jsx("div",{className:ee("h-full rounded-full bg-gradient-to-r transition-all",I.from,I.to),style:{width:`${D}%`}})}),e.jsxs("span",{className:ee("text-[11px] tabular-nums font-semibold rounded-full border border-white/10 bg-white/[0.06] px-2 py-0.5",I.text),children:[D,"%"]})]}),e.jsxs(E,{size:"lg",className:"today-cta mt-5 w-full text-base text-white border-0 hover:brightness-110",onClick:A=>{A.stopPropagation(),M()},children:[C?"Continue where you left off":"Begin",e.jsx(R,{className:"h-4 w-4 ml-1"})]}),e.jsxs("button",{type:"button",onClick:A=>{A.stopPropagation(),t("/pathways")},className:"today-chip mt-3 -mb-1 w-full min-h-[40px] flex items-center justify-between gap-2 px-3 text-xs text-white/55 hover:text-white",children:[e.jsx("span",{children:"See all pathways"}),e.jsx(R,{className:"h-3.5 w-3.5"})]})]}):e.jsxs("div",{className:"today-feature p-6 text-white",children:[e.jsx("div",{className:"text-sm text-white/70 mb-3",children:"Browse pathways to pick y
28our starting arc."}),e.jsxs(E,{onClick:()=>t("/pathways"),className:"today-cta text-white border-0 hover:brightness-110",children:["Browse pathways ",e.jsx(R,{className:"h-4 w-4 ml-1"})]})]}),e.jsx(ra,{}),e.jsx(mi,{}),e.jsxs(fr,{id:"today_anchor",className:"mt-1",children:["Everything else lives under ",e.jsx("strong",{children:"Something else today"})," — the card above is the only thing you need to do next."]}),e.jsx(Mi,{onOpen:A=>{u(A??null),g(!0)}}),e.jsx(Ti,{}),e.jsx(hi,{open:f,onOpenChange:h}),e.jsx(bi,{open:x,onOpenChange:g,focusAchievementId:o}),e.jsxs("div",{children:[e.jsxs("button",{type:"button",onClick:()=>{const A=!c;m(A),A&&Qt("something_else_opened")},className:"today-chip w-full flex items-center justify-between gap-3 px-3 py-2.5 text-white/60 hover:text-white",children:[e.jsxs("span",{className:"text-xs uppercase tracking-wider flex items-center gap-2",children:["Something else today",k&&e.jsx("span",{"aria-label":"A report is ready",className:"h-1.5 w-1.5 rounded-full bg-amber-400"})]}),e.jsx(Ke,{className:ee("h-4 w-4 transition-transform",c&&"rotate-180")})]}),c&&e.jsxs("div",{className:"mt-3 space-y-4",children:[e.jsx(ea,{}),e.jsx(ta,{}),e.jsx(aa,{}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:[{label:"Learn",to:"/learn"},{label:"Grow",to:"/exercises"},{label:"Community",to:"/community"},{label:"Takeaways",to:"/takeaways"},{label:"All pathways",to:"/pathways"},{label:"Schedule",to:"/exercises?view=schedule"},{label:"Profile",to:"/profile"}].map(A=>e.jsx("button",{onClick:()=>{Qt(A.to),t(A.to)},className:"today-chip text-left px-3 py-2.5 text-sm text-white/75 hover:text-white",children:A.label},A.to))})]}),e.jsx("div",{className:"text-center mt-3",children:e.jsxs(Cs,{children:[e.jsx(er,{asChild:!0,children:e.jsx("button",{type:"button",className:"text-[11px] text-white/35 hover:text-white/60 transition-colors",children:"Show me everything (classic dashboard)"})}),e.jsxs(Ss,{children:[e.jsxs(Ds,{children:[e.jsx(As,{children:"Switch to the classic dashboard?"}),e.jsx($s,{children:`You'll see every card at once instead of today's single next step. You can come back any time with the "Simplified Today view" link at the bottom of the dashboard, or from Profile.`})]}),e.jsxs(Ms,{children:[e.jsx(Is,{children:"Cancel"}),e.jsx(Ts,{onClick:()=>{n({guided_mode_opt_out:!0}),Z("Switched to classic dashboard")},children:"Show everything"})]})]})]})})]}),e.jsx("div",{className:"pt-2 pb-6 text-center",children:e.jsx(P,{className:"h-4 w-4 text-white/20 inline-block"})})]})})}const Pi=v.memo(Cr),Ri=v.memo(Ur),zi=v.memo(Ir),qi=v.memo(Lr),Li=v.memo(Ar),Oi=v.memo(Gr),Fi=v.memo(Mr),Gi=v.memo(Pr),Bi=v.memo(Rr),Ui=v.memo(Sr),Yi=()=>{const t=L(),{profile:s,loading:l,updateGuidedPrefs:a}=$e(),{weeklyGoal:n,sessionsThisWeek:i,progress:r,loading:p}=sr(),{progressData:d,loading:c}=Ws(),{tip:m,loading:f}=ei(),{data:h,loading:x}=It();qa();const{signOut:g}=Y(),{toast:o}=Se(),{getHighestUnlockedAchievements:u}=$t(),{currentTier:b,rawTier:w,isLoading:k,isSubscribed:N,isPaused:j,nextTierProgress:y,unlockStatus:D}=ce();u();const{stats:C,loading:I}=ai(),{longestStreak:M,isLoading:K}=vs(),{isUnlocked:A,isLoading:U}=gt(),{isUnlocked:W}=Ma(),{completedItems:H,totalItems:V,loading:je}=ti(),[Et,Je]=v.useState(null),[Pt,We]=v.useState(!1),[xe,Rt]=v.useState(!1),[zt,ia]=v.useState(!1),{mainCards:qt,sidebarCards:Lt,mobileCards:Qe,moveCard:ve,resetOrder:na}=oi(b),la=Qs(),oa=ms(),ca=Ca(),da=oa||ca,ma=ls("Resources/IES%20Book1.svg"),ua=async()=>{const{error:O}=await g();O&&o({title:"Error",description:"Failed to sign out",variant:"destructive"})},Ot=v.useCallback(async O=>{try{if(!O.content&&!O.learn_categories){const{data:q,error:F}=await S.from("learn_articles").select(`
29            *,
30            learn_categories (
31              id,
32              title,
33              color_scheme,
34              icon
35            )
36          `).eq("id",O.id).single();if(F){o({title:"Error loading article",description:"Could not load the full article content.",variant:"destructive"});return}Je(q)}else Je(O);We(!0)}catch(q){re.error("Error loading article:",q),o({title:"Error loading article",description:"Could not load the article content.",variant:"destructive"})}},[o]);v.useCallback(()=>{We(!1),Je(null)},[]);const[Ve,xa]=v.useState(0),[Ft,ha]=v.useState(null),[ke,pa]=v.useState(null),Gt=v.useCallback(()=>{t("/exercises")},[t]),Bt=v.useCallback(O=>{const F={"open meditation":"Meditation",meditation:"Meditation","ego dissolution":"Ego Dissolution","infinite energy system":"InfiniteEnergySystem",foundation:"Foundation",emotional:"Emotional",advanced:"Advanced"}[O.toLowerCase()]||O;t("/exercises",{state:{scrollTo:F}})},[t]);v.useEffect(()=>{let O=!0;return(async()=>{var Yt,Kt,Ht;const{data:{user:q}}=await S.auth.getUser();if(!q)return;const F=Be(new Date).toISOString(),X=Ue(new Date).toISOString(),[J,Q]=await Promise.all([S.from("practice_sessions").select("duration_seconds").eq("user_id",q.id).gte("completed_at",F).lte("completed_at",X),S.from("practice_sessions").select("audio_used, completed_at").eq("user_id",q.id).order("completed_at",{ascending:!1})]);if(!O)return;const de=(J.data||[]).reduce((ne,tt)=>ne+tt.duration_seconds,0)/60;xa(de);const he=Q.data||[];pa((Yt=he[0])!=null&&Yt.completed_at?new Date(he[0].completed_at):null);const et={};for(const ne of he)ne.audio_used&&ne.audio_used!=="none"&&(et[ne.audio_used]=(et[ne.audio_used]||0)+1);const Ut=((Kt=Object.entries(et).sort((ne,tt)=>tt[1]-ne[1])[0])==null?void 0:Kt[0])||null,ba=Ut&&((Ht=wr.find(ne=>ne.id===Ut))==null?void 0:Ht.name)||null;ha(ba)})(),()=>{O=!1}},[]);const Xe=v.useMemo(()=>({"journal-activity":e.jsx(Bs,{}),journeys:e.jsx(Ys,{}),"your-pathway":e.jsx(Te,{}),"books-progress":e.jsx(Ri,{}),"weekly-practice":e.jsx(Pi,{weeklyGoal:n,sessionsThisWeek:i,progress:r,weeklyLoading:p}),"learning-progress":e.jsx(zi,{totalArticles:h.totalArticles,readArticles:h.readArticles,overallProgress:h.overallProgress,categoryProgress:h.categoryProgress,articlesReadThisWeek:h.articlesReadThisWeek,learningStreak:h.learningStreak,loading:x}),"active-study":e.jsx(qi,{}),"exercise-progress":e.jsx(Li,{categoryProgress:(()=>{const O=(d==null?void 0:d.categoryProgress)||[],q=Q=>O.find(de=>de.category===Q),F=q("Meditation"),X=q("Ego Dissolution"),J=["Foundation","Emotional","Advanced"].reduce((Q,de)=>{const he=q(de);return he&&(Q.completed+=he.completed,Q.total+=he.total),Q},{completed:0,total:0});return[{category:"Open Meditation",completed:(F==null?void 0:F.completed)??0,total:(F==null?void 0:F.total)??0,percentage:(F==null?void 0:F.percentage)??0},{category:"Ego Dissolution",completed:(X==null?void 0:X.completed)??0,total:(X==null?void 0:X.total)??0,percentage:(X==null?void 0:X.percentage)??0},{category:"Infinite Energy System",completed:J.completed,total:J.total,percentage:J.total>0?Math.round(J.completed/J.total*100):0}
36]})(),loading:c,onTitleClick:Gt,onCategoryClick:Bt,currentStreak:(s==null?void 0:s.current_streak)||0,totalSessions:(s==null?void 0:s.total_sessions)||0,statsLoading:l,nextUnlockHint:y,emotionalMinutes:(D==null?void 0:D.emotional_exercise_minutes)??0,requiredEmotionalMinutes:120})}),[n,i,r,p,h,x,d,c,Gt,Bt,s,l,y,D]),Ze=v.useMemo(()=>({"integration-practices":e.jsx(Js,{}),goals:e.jsx(Jr,{}),achievements:e.jsx(Oi,{}),"smart-tip":e.jsx(Fi,{suggestedNextStep:(m==null?void 0:m.suggestedNextStep)??"",motivationalMessage:(m==null?void 0:m.motivationalMessage)??"",category:m==null?void 0:m.category,action:m==null?void 0:m.action,loading:f||!m}),"recent-highlights":e.jsx(Gi,{highlights:h.recentHighlights,loading:x}),"suggested-reading":e.jsx(Bi,{articles:h.suggestedArticles,loading:x,onArticleClick:Ot}),"meditation-insights":e.jsxs($,{variant:"glass-medium",sparkle:!0,glow:"cyan",className:"bg-slate-900/40 backdrop-blur-md border-white/10 text-white hover:shadow-2xl hover:shadow-cyan-500/20 transition-all duration-300",children:[e.jsx(z,{className:"p-3 pb-2 md:p-6 md:pb-4",children:e.jsxs(G,{className:"text-base md:text-lg bg-gradient-to-r from-cyan-400 to-blue-400 bg-clip-text text-transparent flex items-center gap-2",children:[e.jsx("span",{className:"text-cyan-400",children:"✨"}),"Meditation Insights"]})}),e.jsxs(T,{className:"p-3 md:p-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"bg-white/5 backdrop-blur-sm rounded-lg p-3 border border-white/10 hover:bg-white/10 transition-all duration-200",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-white/60",children:"This Week"}),e.jsxs("span",{className:"text-lg font-semibold text-white/90",children:[Math.round(Ve),e.jsx("span",{className:"text-sm font-normal text-white/50 ml-1",children:"minutes"})]})]}),e.jsx("div",{className:"mt-2 h-1.5 bg-white/10 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-gradient-to-r from-cyan-400 to-blue-400 rounded-full transition-all duration-500",style:{width:`${Math.min(Ve/60*100,100)}%`}})})]}),e.jsxs("div",{className:"bg-white/5 backdrop-blur-sm rounded-lg p-3 border border-white/10 hover:bg-white/10 transition-all duration-200",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"text-2xl",children:"🎵"}),e.jsx("span",{className:"text-sm text-white/60",children:"Favorite Audio"})]}),e.jsx("p",{className:"text-white/90 font-medium",children:Ft||"No favorite yet"})]}),ke&&e.jsxs("div",{className:"text-xs text-white/50 text-center",children:["Last meditation: ",new Date(ke).toLocaleDateString()]})]}),(!ke||Date.now()-ke.getTime()>7*24*60*60*1e3)&&e.jsxs(E,{className:"mt-4 w-full bg-gradient-to-r from-cyan-500 to-blue-500 hover:from-cyan-600 hover:to-blue-600 text-white border-0 shadow-lg shadow-cyan-500/25 hover:shadow-cyan-500/40 transition-all duration-300",onClick:()=>t("/exercises/organic-Meditation"),children:[e.jsx(P,{className:"mr-2 h-4 w-4"}),"Try Organic Meditation"]})]})]}),"recent-progress":e.jsx(Ui,{})}),[d,c,m,f,h,x,Ot,Ve,Ft,ke,t]),ga=v.useMemo(()=>({...Xe,...Ze}),[Xe,Ze]);return la.showTodayHome?e.jsx(Ei,{}):e.jsx(xs,{children:e.jsxs("div",{className:"overflow-x-hidden",children:[e.jsxs("div",{className:"relative mb-6 overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-purple-600/20 via-blue-600/15 to-cyan-600/20 blur-3xl"}),e.jsxs("div",{className:"relative bg-slate-900/40 backdrop-blur-xl border border-white/10 rounded-b-3xl p-6",children:[e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"hidden md:flex flex-col items-center gap-0.5 flex-shrink-0",children:[e.jsx(at,{to:"/learn","aria-label":"Learn",className:"p-1.5 rounded-lg hover:bg-white/10 transition-colors",children:e.jsx(Pe,{size:16,className:"text-white/40 hover:text-white/70 transition-colors"})}),e.jsx(at,{to:"/exercises","aria-label":"Exercises",className:"p-1.5 rounded-lg hover:bg-white/10 transition-colors",children:e.jsx(Oe,{size:16,className:"text-white/40 hover:text-white/70 transition-colors"})}),e.jsx(at,{to:"/community","aria-label":"Community",className:"p-1.5 rounded-lg hover:bg-white/10 transition-colors",children:e.jsx(Sa,{size:16,className:"text-white/40 hover:text-white/70 transition-colors"})})]}),e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"w-16 h-16 flex items-center justify-center",children:[e.jsx("img",{src:ma,alt:"Deep Insights",onError:O=>{var q;O.currentTarget.style.display="none",(q=O.currentTarget.nextElementSibling)==null||q.classList.remove("hidden")},className:"w-full h-full drop-shadow-lg hover:scale-105 transition-transform duration-300 object-cover"}),e.jsx(P,{size:24,className:"text-blue-400 drop-shadow-lg hidden"})]}),e.jsx("div",{className:"absolute inset-0 rounded-xl bg-blue-400/20 blur-xl animate-pulse"})]}),e.jsx("h1",{className:"text-xl md:text-2xl lg:text-3xl font-bold leading-tight md:leading-normal bg-gradient-to-r from-blue-400 via-purple-400 to-cyan-400 bg-clip-text text-transparent py-[4px]",children:"Deep Insights - Your Personal Dashboard"})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-center gap-2",children:[e.jsxs(E,{variant:"ghost",size:"icon",onClick:()=>t("/profile#preferences"),"aria-label":"Settings",className:"sm:hidden relative text-white/70 hover:text-white hover:bg-white/10 backdrop-blur-sm border border-white/10 rounded-xl transition-all duration-300",children:[e.jsx(Qa,{size:20}),e.jsx("div",{className:"absolute inset-0 rounded-xl bg-gradient-to-r from-cyan-400 to-teal-400 opacity-0 hover:opacity-20 blur-xl transition-opacity"})]}),e.jsxs(E,{variant:"ghost",size:"icon",className:"relative text-white/70 hover:text-white hover:bg-white/10 backdrop-blur-sm border border-white/10 rounded-xl transition-all duration-300",onClick:ua,"aria-label":"Sign out",children:[e.jsx(jr,{size:20}),e.jsx("div",{className:"absolute inset-0 rounded-xl bg-gradient-to-r from-red-400 to-pink-400 opacity-0 hover:opacity-20 blur-xl transition-opacity"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h2",{className:"text-base md:text-lg lg:text-xl font-semibold leading-tight md:leading-normal text-white/90 flex items-center gap-2",children:["Welcome back",s!=null&&s.username?`, ${s.username}`:"","!",e.jsx("span",{className:"text-sm md:text-base animate-bounce",style:{animationDuration:"2s"},children:"👋🏽"})]}),e.jsxs("p",{className:"text-xs md:text-sm lg:text-base text-white/60 leading-relaxed md:leading-loose flex items-center gap-2",children:[e.jsx(ut,{className:"w-3 h-3 md:w-4 md:h-4"}),"Ready to continue building your spiritual routine?"]})]}),e.jsxs("div",{className:"flex items-center gap-3 md:gap-6 mt-4 pt-4 border-t border-white/10 flex-wrap",children:[e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsx("div",{className:`px-2 py-0.5 rounded-full text-[10px] sm:text-xs font-semibold ${w>=4?"bg-gradient-to-r from-amber-500 to-yellow-400 text-black":w>=3?"bg-gradient-to-r from-purple-500 to-pink-500 text-white":w>=2?"bg-gradient-to-r from-blue-500 to-cyan-500 text-white":w>=1?"bg-gradient-to-r from-green-500 to-emerald-500 text-white":"bg-white/20 text-white/70"} ${!N&&w>0?"opacity-50":""}`,children:e.jsx("span",{className:!N&&w>0?"line-through":"text-xs",children:k?"...":`Tier ${w}`})})}),N?e.jsxs("div",{className:"flex items-center gap-1 px-2 py-0.5 rounded-full text-[10px] sm:text-xs font-semibold bg-green-500/20 text-green-400 border border-green-500/30",children:[e.jsx(vr,{className:"w-3 h-3"}),e.jsx("span",{className:"text-xs",children:"Subscribed"})]}
36):j?e.jsxs("button",{onClick:()=>t("/profile"),className:"flex items-center gap-1 px-2 py-0.5 rounded-full text-[10px] sm:text-xs font-semibold bg-amber-500/20 text-amber-400 border border-amber-500/30 hover:bg-amber-500/30 transition-colors cursor-pointer",children:[e.jsx(yr,{className:"w-3 h-3"}),e.jsx("span",{className:"text-xs",children:"Paused"})]}):e.jsxs("button",{onClick:()=>t("/profile"),className:"flex items-center gap-1 px-2 py-0.5 rounded-full text-[10px] sm:text-xs font-semibold bg-amber-500/20 text-amber-400 border border-amber-500/30 hover:bg-amber-500/30 transition-colors cursor-pointer",children:[e.jsx(Fe,{className:"w-3 h-3"}),e.jsx("span",{className:"text-xs",children:"Subscribe"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ie,{className:"w-3 h-3 md:w-4 md:h-4 text-orange-400"}),e.jsx("span",{className:"sm:text-xs md:text-sm text-white/50 text-xs",children:l?"...":`${(s==null?void 0:s.current_streak)||0} ${((s==null?void 0:s.current_streak)||0)===1?"day":"days"} exercise streak`})]}),b>=1&&e.jsx("div",{className:"flex items-center gap-2",children:A?e.jsxs(e.Fragment,{children:[e.jsx(ye,{className:"w-3 h-3 md:w-4 md:h-4 text-green-400"}),e.jsxs("span",{className:"sm:text-xs md:text-sm text-white/50 text-xs",children:[je||U?"...":`${H}/${V}`," ","schedule"]})]}):e.jsxs(e.Fragment,{children:[e.jsx(ue,{className:"w-3 h-3 md:w-4 md:h-4 text-green-400"}),e.jsxs("span",{className:"sm:text-xs md:text-sm text-white/50 text-xs",children:[p?"...":`${i}/${n}`," weekly"]})]})}),b>=1&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(B,{className:"w-3 h-3 md:w-4 md:h-4 text-primary"}),e.jsx("span",{className:"sm:text-xs md:text-sm text-white/50 text-xs",children:I?"...":`${C.totalStudySessions} ${C.totalStudySessions===1?"study":"studies"}`})]}),W&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ae,{className:"w-3 h-3 md:w-4 md:h-4 text-accent"}),e.jsx("span",{className:"sm:text-xs md:text-sm text-white/50 text-xs",children:I?"...":`${C.totalQuizzes} ${C.totalQuizzes===1?"quiz":"quizzes"}`})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ot,{className:"w-3 h-3 md:w-4 md:h-4 text-pink-400"}),e.jsx("span",{className:"sm:text-xs md:text-sm text-white/50 text-xs",children:K?"...":`${M} ${M===1?"day":"days"} best journal streak`})]}),!xe&&b>=1&&e.jsxs(E,{variant:"ghost",size:"sm",onClick:()=>Rt(!0),className:"h-7 px-2 !text-[10px] text-white/40 hover:text-white/70 hover:bg-white/10 gap-0.5 ml-auto",children:[e.jsx(Nr,{className:"!w-3 !h-3"}),"Edit Layout"]})]})]}),e.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-[1px] bg-gradient-to-r from-transparent via-white/20 to-transparent"})]})]}),xe&&e.jsx("div",{className:"flex items-center justify-end px-2 md:px-4 mb-2",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-white/50",children:"Tap arrows to reorder"}),e.jsxs(E,{variant:"ghost",size:"sm",onClick:na,className:"h-7 px-2 text-xs text-white/60 hover:text-white hover:bg-white/10 gap-1",children:[e.jsx(At,{size:12}),"Reset"]}),e.jsx(E,{variant:"ghost",size:"sm",onClick:()=>Rt(!1),className:"h-7 px-3 text-xs bg-white/10 text-white/90 hover:bg-white/20 border border-white/20",children:"Done"})]})}),e.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-2 md:gap-4 lg:gap-6 p-2 md:p-4",children:da?e.jsxs("section",{className:"col-span-1 space-y-2 md:space-y-4",children:[e.jsx(Xt,{}),e.jsx(Vt,{sessionsThisWeek:i,weeklyGoal:n}),e.jsx(Te,{}),(()=>{const O=Qe.slice(0,nt),q=Qe.slice(nt),F=(J,Q)=>{const de=ga[J];return de==null?null:e.jsx(it,{editMode:xe,index:Q,total:Qe.length,onMoveUp:()=>ve("mobile",Q,"up"),onMoveDown:()=>ve("mobile",Q,"down"),children:de},J)},X=zt||xe;return e.jsxs(e.Fragment,{children:[O.map((J,Q)=>F(J,Q)),q.length>0&&e.jsxs(e.Fragment,{children:[X&&e.jsxs("div",{className:"flex items-center gap-3 pt-2 pb-1",children:[e.jsx("div",{className:"h-px flex-1 bg-white/10"}),e.jsx("span",{className:"text-[10px] uppercase tracking-wider text-white/40",children:"Secondary"}),e.jsx("div",{className:"h-px flex-1 bg-white/10"})]}),X&&q.map((J,Q)=>F(J,nt+Q)),!xe&&e.jsx(E,{variant:"ghost",onClick:()=>ia(J=>!J),className:"w-full mt-2 text-xs text-white/60 hover:text-white hover:bg-white/10 border border-white/10 gap-1.5",children:zt?e.jsxs(e.Fragment,{children:[e.jsx(_t,{className:"w-3.5 h-3.5"}),"Show less"]}):e.jsxs(e.Fragment,{children:[e.jsx(Ke,{className:"w-3.5 h-3.5"}),"Show ",q.length," more"]})})]})]})})()]}):e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"lg:col-span-2 space-y-2 md:space-y-4 lg:space-y-6",children:[e.jsx(Xt,{}),e.jsx(Vt,{sessionsThisWeek:i,weeklyGoal:n}),e.jsx(Te,{}),qt.map((O,q)=>{const F=Xe[O];return F?e.jsx(it,{editMode:xe,index:q,total:qt.length,onMoveUp:()=>ve("main",q,"up"),onMoveDown:()=>ve("main",q,"down"),children:F},O):null})]}),e.jsx("aside",{className:"lg:col-span-1 space-y-2 md:space-y-4 lg:space-y-6",children:Lt.map((O,q)=>{const F=Ze[O];return F==null?null:e.jsx(it,{editMode:xe,index:q,total:Lt.length,onMoveUp:()=>ve("sidebar",q,"up"),onMoveDown:()=>ve("sidebar",q,"down"),children:F},O)})})]})}),e.jsx("div",{className:"text-center py-6",children:e.jsx("button",{type:"button",onClick:()=>{a({guided_mode_opt_out:!1}),Z("Back to Today view")},className:"text-[11px] text-white/35 hover:text-white/60 transition-colors",children:"Simplified Today view"})}),Pt&&Et&&e.jsx(La,{children:e.jsx(Oa,{article:Et,open:Pt,onOpenChange:We})})]})})},bl=Object.freeze(Object.defineProperty({__proto__:null,Home:Yi},Symbol.toStringTag,{value:"Module"}));
36export{Hs as C,pl as G,hl as T,gl as a,Ks as b,$t as c,bl as i,ui as u};

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.