1import{p as ye,j as e,aw as Me,k as Ie,u as Pe,q as Be,r,f as Ue,g as _,a2 as v,h as G,n as Oe,R as me,A as b,m as i,I as m,T as We,s as pe,a3 as ge,X as V,o as Re,Z as Ye,C as Z,aA as qe,aB as Ke}from"./index-Dmv3B40E.js";import{M as k}from"./MarkdownRenderer-DqMp9C37.js";import{T as X}from"./trophy-BN-OHolZ.js";import{S as J}from"./sparkles-YZTAn2eh.js";import{C as Qe}from"./chevron-up-Cp7k0zn1.js";import{C as ue}from"./clock-CYl0Lmnv.js";import{C as ze}from"./calendar-BjDayUZi.js";import{E as He}from"./ellipsis-C8hoQdGI.js";import{M as _e}from"./message-square-BpJnIzVp.js";import{P as he}from"./pencil-B8gsIW41.js";/** 2 * @license lucide-react v0.453.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const be=ye("Hourglass",[["path",{d:"M5 22h14",key:"ehvnwv"}],["path",{d:"M5 2h14",key:"pdyrp9"}],["path",{d:"M17 22v-4.172a2 2 0 0 0-.586-1.414L12 12l-4.414 4.414A2 2 0 0 0 7 17.828V22",key:"1d314k"}],["path",{d:"M7 2v4.172a2 2 0 0 0 .586 1.414L12 12l4.414-4.414A2 2 0 0 0 17 6.172V2",key:"1vvvr6"}]]);/** 7 * @license lucide-react v0.453.0 - ISC 8 * 9 * This source code is licensed under the ISC license. 10 * See the LICENSE file in the root directory of this source tree. 11 */const Ge=ye("Star",[["polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2",key:"8f66p6"}]]);function lt({onBack:y,onOpenChat:g}){return e.jsx(Me,{featureName:"Loops",featureDescription:`Loops turn good intentions into follow-through. 12 13Save a commitment in one tap. Come back to it when you're ready. Mark it done, reschedule it, or talk it through with me.`,onBack:y,children:e.jsx(Ve,{onBack:y,onOpenChat:g})})}function Ve({onBack:y,onOpenChat:g}){Ie("#0A5852");const{theme:fe}=Pe(),l=fe==="dark",{toast:u}=Be(),[o,ee]=r.useState("open"),[te,C]=r.useState(null),[D,h]=r.useState(null),[ae,S]=r.useState(!1),[E,L]=r.useState(""),[T,$]=r.useState(""),[M,I]=r.useState(""),[P,B]=r.useState(""),[U,O]=r.useState(""),[W,we]=r.useState(null),[R,Y]=r.useState(!1),[q,je]=r.useState(""),[Fe,Ne]=r.useState(0),[K,f]=r.useState(null),[A,se]=r.useState(""),[ne,re]=r.useState(""),[Q,ie]=r.useState(""),ke=r.useMemo(()=>Array.from({length:20}).map((t,s)=>({id:s,x:(Math.random()-.5)*400,y:(Math.random()-.5)*400,delay:Math.random()*.5,isOrange:s%2===0})),[Fe]);r.useEffect(()=>{if(!R)return;const t=setTimeout(()=>{Y(!1)},2500);return()=>clearTimeout(t)},[R]);const{data:d,isLoading:Ae,error:le}=Ue({queryKey:["/api/loops",o==="all"?void 0:o],queryFn:async()=>{const t=o==="all"?"/api/loops":`/api/loops?status=${o}`,s=await fetch(t,{headers:Ke()});if(!s.ok){const n=await s.json().catch(()=>({}));throw new Error(n.error||n.message||"Failed to fetch loops")}const a=await s.json();return Array.isArray(a)?a:[]},retry:!1}),w=_({mutationFn:async({id:t,status:s,followUpAt:a})=>G("PATCH",`/api/loops/${t}`,{status:s,followUpAt:a}),onSuccess:()=>{v.invalidateQueries({queryKey:["/api/loops"]})}}),z=_({mutationFn:async t=>G("POST","/api/loops",t),onSuccess:()=>{v.invalidateQueries({queryKey:["/api/loops"]}),S(!1),L(""),$(""),I(""),B(""),O(""),ee("open"),u({title:"Loop added",description:"Added to your open loops."})},onError:t=>{u({title:"Couldn't add loop",description:t.message||"Please try again.",variant:"destructive"})}}),H=_({mutationFn:async({id:t,title:s,nextAction:a,followUpAt:n,whyItMatters:x})=>G("PATCH",`/api/loops/${t}`,{title:s,nextAction:a,followUpAt:n,whyItMatters:x}),onSuccess:()=>{v.invalidateQueries({queryKey:["/api/loops"]}),f(null),u({title:"Loop updated",description:"Your changes have been saved."})},onError:t=>{u({title:"Couldn't update loop",description:t.message||"Please try again.",variant:"destructive"})}}),[oe,de]=r.useState(""),ve=t=>{se(t.title),re(t.nextAction||""),de(t.whyItMatters||""),ie(t.followUpAt?new Date(t.followUpAt).toISOString().split("T")[0]:""),f(t)},Ce=()=>{!K||!A.trim()||H.mutate({id:K.id,title:A.trim(),nextAction:ne.trim()||void 0,followUpAt:Q?new Date(Q).toISOString():null,whyItMatters:oe.trim()||void 0})},De=()=>{const t=E.trim();if(!t)return;const s={title:t};T.trim()&&(s.whyItMatters=T.trim()),M.trim()&&(s.definitionOfDone=M.split(` 14`).map(a=>
14a.trim()).filter(Boolean)),P.trim()&&(s.nextAction=P.trim()),U.trim()&&(s.fasterPath=U.trim()),z.mutate(s)},[j,Se]=r.useState(0),Ee=t=>{const s=d==null?void 0:d.find(n=>n.id===t);w.mutate({id:t,status:"done"}),je((s==null?void 0:s.title)||"Your loop");const a=s!=null&&s.createdAt?Math.floor((Date.now()-new Date(s.createdAt).getTime())/(1e3*60*60*24)):0;Se(a),Ne(n=>n+1),Y(!0)},Le=t=>{w.mutate({id:t,status:"dropped"}),u({title:"Loop dropped",description:"No longer tracking this."})},ce=(t,s)=>{let a;const n=new Date;if(s==="tomorrow")a=new Date(n.setDate(n.getDate()+1));else if(s==="next_week")a=new Date(n.setDate(n.getDate()+7));else{C(null);return}w.mutate({id:t,followUpAt:a.toISOString()}),C(null),u({title:"Follow-up scheduled",description:`I'll remind you ${s==="tomorrow"?"tomorrow":"next week"}.`})},Te=t=>{const s=t.createdAt?Math.floor((Date.now()-new Date(t.createdAt).getTime())/864e5):0;let a=`I want to work through this open loop: "${t.title}"`;t.whyItMatters&&(a+=` 15 16Why it matters: ${t.whyItMatters}`),t.definitionOfDone&&t.definitionOfDone.length>0&&(a+=` 17 18Done when: 19${t.definitionOfDone.map(n=>`⢠${n}`).join(` 20`)}`),t.nextAction&&(a+=` 21 22Next action: ${t.nextAction}`),t.fasterPath&&(a+=` 23 24Faster path: ${t.fasterPath}`),t.followUpAt&&(a+=` 25 26Due: ${new Date(t.followUpAt).toLocaleDateString("en-US",{month:"long",day:"numeric"})}`),a+=` 27 28It's been open for ${s} day${s!==1?"s":""}.`,g==null||g(a)},$e=t=>{var xe;const s=t.followUpAt?new Date(t.followUpAt):new Date,a=p=>String(p).padStart(2,"0"),n=p=>`${p.getFullYear()}${a(p.getMonth()+1)}${a(p.getDate())}`,x=new Date(s);x.setDate(x.getDate()+1);let N="";return t.whyItMatters&&(N+=`Why it matters: ${t.whyItMatters} 29 30`),t.nextAction&&(N+=`Next action: ${t.nextAction} 31 32`),(xe=t.definitionOfDone)!=null&&xe.length&&(N+=`Done when: 33${t.definitionOfDone.map(p=>`⢠${p}`).join(` 34`)} 35 36`),N+="Tracked in AloYou Loops.",`https://calendar.google.com/calendar/render?action=TEMPLATE&text=${encodeURIComponent(t.title)}&dates=${n(s)}/${n(x)}&details=${encodeURIComponent(N.trim())}`},F=(d==null?void 0:d.filter(t=>t.status==="open"))||[],c=(d==null?void 0:d.filter(t=>t.status==="done"))||[];return e.jsxs("div",{className:"min-h-screen flex flex-col",style:{background:l?"linear-gradient(180deg, #051C19 0%, #0A3D38 8%, #0E1714 35%, #0E1714 100%)":"linear-gradient(180deg, #0A5852 0%, #0F6F68 8%, #F6EDC8 35%, #F8F5EE 100%)"},children:[e.jsx("header",{className:"relative z-20 sticky top-0",style:{background:"linear-gradient(180deg, rgba(8, 72, 67, 0.98) 0%, rgba(10, 88, 82,
360.97) 60%, rgba(15, 111, 104, 0.95) 100%)",backdropFilter:"blur(20px)",WebkitBackdropFilter:"blur(20px)",paddingTop:"max(0.85rem, env(safe-area-inset-top, 0px))",paddingBottom:"0.65rem",borderBottom:"1px solid rgba(255, 255, 255, 0.07)"},children:e.jsxs("div",{className:"max-w-lg lg:max-w-3xl mx-auto px-3 flex items-center gap-2.5",children:[y&&e.jsx("button",{onClick:y,className:"w-9 h-9 rounded-2xl flex items-center justify-center flex-shrink-0 active:scale-95 transition-transform",style:{background:"rgba(255,255,255,0.08)",border:"1px solid rgba(255,255,255,0.1)"},"data-testid":"button-back",children:e.jsx(Oe,{className:"w-4 h-4",style:{color:"rgba(246,237,200,0.85)"}})}),e.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[e.jsx("div",{className:"w-9 h-9 rounded-2xl flex items-center justify-center shrink-0",style:{background:"linear-gradient(145deg, rgba(255, 162, 76, 0.25) 0%, rgba(230, 126, 34, 0.15) 100%)",border:"1px solid rgba(255, 162, 76, 0.3)",boxShadow:"0 3px 10px rgba(255, 162, 76, 0.2)"},children:e.jsx(me,{className:"w-4 h-4",style:{color:"#FFA24C"}})}),e.jsxs("div",{className:"leading-tight min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-bold text-[15px] tracking-tight",style:{color:"#FFFFFF"},children:"Loops"}),F.length>0&&e.jsxs("span",{className:"text-[10px] font-bold px-1.5 py-0.5 rounded-full",style:{background:"rgba(255, 162, 76, 0.22)",color:"#FFA24C",border:"1px solid rgba(255, 162, 76, 0.3)"},children:[F.length," open"]})]}),e.jsx("span",{className:"text-[11px]",style:{color:"rgba(255, 255, 255, 0.55)"},children:"Open commitments"})]})]}),e.jsx("div",{className:"flex rounded-full p-0.5 shrink-0",style:{background:"rgba(255, 255, 255, 0.09)",border:"1px solid rgba(255, 255, 255, 0.08)"},children:["open","done","all"].map(t=>e.jsx("button",{onClick:()=>ee(t),className:"px-2.5 py-1 rounded-full text-[11px] font-semibold capitalize transition-all",style:{background:o===t?"#FFFFFF":"transparent",color:o===t?"#0F6F68":"rgba(255, 255, 255, 0.65)",boxShadow:o===t?"0 1px 4px rgba(0,0,0,0.15)":"none"},"data-testid":`filter-${t}`,children:t},t))})]})}),e.jsx(b,{children:ae&&e.jsx(i.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"overflow-hidden",children:e.jsx("div",{className:"max-w-lg lg:max-w-3xl mx-auto px-4 py-4",children:e.jsxs("div",{className:"p-4 rounded-2xl space-y-3",style:{background:l?"linear-gradient(145deg, #1C2E2A 0%, #162820 100%)":"linear-gradient(145deg, #FFFFFF 0%, #F8FAF9 100%)",border:`1px solid ${l?"rgba(255,162,76,0.15)":"rgba(255, 162, 76, 0.2)"}`,boxShadow:"0 8px 32px rgba(15, 111, 104, 0.08)"},children:[e.jsx(m,{placeholder:"What do you want to track?",value:E,onChange:t=>L(t.target.value),className:"border-0 font-medium",style:{background:"rgba(15, 111, 104, 0.04)",border:"1px solid rgba(15, 111, 104, 0.1)"},"data-testid":"input-new-loop",autoFocus:!0}),e.jsx(m,{placeholder:"Why it matters (optional)",value:T,onChange:t=>$(t.target.value),className:"border-0 text-sm",style:{background:"rgba(15, 111, 104, 0.04)",border:"1px solid rgba(15, 111, 104, 0.1)"},"data-testid":"input-loop-why"}),e.jsx(We,{placeholder:"Done when... (one per line, optional)",value:M,onChange:t=>I(t.target.value),className:"border-0 text-sm min-h-[60px] resize-none",style:{background:"rgba(15, 111, 104, 0.04)",border:"1px solid rgba(15, 111, 104, 0.1)"},"data-testid":"input-loop-done"}),e.jsx(m,{placeholder:"Next action (optional)",value:P,onChange:t=>B(t.target.value),className:"border-0 text-sm",style:{background:"rgba(15, 111, 104, 0.04)",border:"1px solid rgba(15, 111, 104, 0.1)"},"data-testid":"input-loop-next"}),e.jsx(m,{placeholder:"Faster path (optional)",value:U,onChange:t=>O(t.target.value),className:"border-0 text-sm",style:{background:"rgba(15, 111, 104, 0.04)",border:"1px solid rgba(15, 111, 104, 0.1)"},"data-testid":"input-loop-faster"}),e.jsxs("div",{className:"flex gap-2 pt-1",children:[e.jsxs("button",{onClick:De,disabled:!E.trim()||z.isPending,className:"flex items-center gap-1 px-4 py-2 rounded-2xl text-[13px] font-semibold active:scale-95 transition-transform disabled:opacity-50",style:{background:"linear-gradient(135deg, #FFA24C 0%, #E88A30 100%)",color:"#FFFFFF",border:"none",boxShadow:"0 4px 12px rgba(255,162,76,0.3)"}
36,"data-testid":"button-confirm-add-loop",children:[z.isPending?e.jsx(pe,{className:"w-4 h-4 animate-spin"}):e.jsx(ge,{className:"w-4 h-4"}),"Add Loop"]}),e.jsx("button",{onClick:()=>{S(!1),L(""),$(""),I(""),B(""),O("")},className:"px-4 py-2 rounded-2xl text-[13px] font-medium active:scale-95 transition-transform",style:{color:"#5A6B64",background:"rgba(75,82,78,0.06)",border:"1px solid rgba(75,82,78,0.12)"},"data-testid":"button-cancel-add-loop",children:"Cancel"})]})]})})})}),!ae&&e.jsx(i.div,{initial:{scale:.9,opacity:0},animate:{scale:1,opacity:1},className:"fixed bottom-24 right-4 z-50",children:e.jsxs("button",{onClick:()=>S(!0),className:"flex items-center gap-1.5 px-5 py-3 rounded-2xl text-[14px] font-semibold active:scale-95 transition-transform",style:{background:"linear-gradient(135deg, #FFA24C 0%, #E88A30 100%)",boxShadow:"0 4px 20px rgba(255, 162, 76, 0.4)",color:"#FFFFFF",border:"none"},"data-testid":"button-add-loop",children:[e.jsx(ge,{className:"w-5 h-5"}),"Add Loop"]})}),e.jsx("main",{className:"flex-1 pb-24",children:e.jsx("div",{className:"max-w-lg lg:max-w-3xl mx-auto px-4 py-4 space-y-3",children:Ae?e.jsx("div",{className:"space-y-3",children:[1,2,3].map(t=>e.jsx("div",{className:"rounded-2xl p-5 animate-pulse",style:{background:l?"linear-gradient(145deg, #1C2E2A 0%, #162820 100%)":"linear-gradient(145deg, #FFFFFF 0%, #F8FAF9 100%)",border:`1px solid ${l?"rgba(15,111,104,0.2)":"rgba(15, 111, 104, 0.08)"}`,boxShadow:"0 8px 32px rgba(15, 111, 104, 0.06)"},children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl",style:{background:"rgba(15, 111, 104, 0.08)"}}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx("div",{className:"h-4 rounded w-2/3",style:{background:"rgba(15, 111, 104, 0.1)"}}),e.jsx("div",{className:"h-3 rounded w-1/2",style:{background:"rgba(15, 111, 104, 0.06)"}})]})]})},t))}):le?e.jsxs(i.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:"text-center py-12",children:[e.jsx("div",{className:"w-16 h-16 rounded-2xl mx-auto mb-4 flex items-center justify-center",style:{background:"rgba(217, 124, 64, 0.12)"},children:e.jsx(V,{className:"w-7 h-7",style:{color:"#D97C40"}})}),e.jsx("h3",{className:"text-base font-semibold mb-1",style:{color:l?"#E8E4DC":"#1A1A1A"},children:"Couldn't load loops"}),e.jsx("p",{className:"text-sm mb-4",style:{color:l?"#9CA6A0":"#4B524E"},children:le.message||"Something went wrong. Please try again."}),e.jsx("button",{onClick:()=>v.invalidateQueries({queryKey:["/api/loops"]}),className:"px-5 py-2.5 rounded-2xl text-sm font-semibold active:scale-95 transition-transform",style:{background:"linear-gradient(135deg, #0F6F68 0%, #3D9A8C 100%)",color:"#FFFFFF",border:"none",boxShadow:"0 4px 12px rgba(15,111,104,0.25)"},"data-testid":"button-retry-loops",children:"Try Again"})]}):d!=null&&d.length?e.jsxs(e.Fragment,{children:[o==="done"&&c.length>0&&e.jsx(i.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},className:"rounded-2xl overflow-hidden",style:{background:"linear-gradient(135deg, #0F6F68 0%, #0A5852 100%)",boxShadow:"0 8px 32px rgba(15, 111, 104, 0.25)"},children:e.jsxs("div",{className:"p-5 text-center",children:[e.jsxs("div",{className:"flex justify-center items-center gap-2 mb-3",children:[e.jsx(X,{className:"w-6 h-6",style:{color:"#FFA24C"}}),e.jsxs("h3",{className:"text-lg font-bold text-white",children:[c.length," ",c.length===1?"Loop":"Loops"," Closed"]}),e.jsx(X,{className:"w-6 h-6",style:{color:"#FFA24C"}})]}),e.jsx("p",{className:"text-sm",style:{color:"rgba(255, 255, 255, 0.8)"},children:c.length===1?"You did it! Every closed loop is proof you follow through.":c.length<5?"Building momentum! Keep closing those loops.":c.length<10?"You're on fire! Your commitment game is strong.":"Legend status! You're a loop-closing machine."}),e.jsxs("div",{className:"flex justify-center gap-1 mt-3",children:[Array.from({length:Math.min(c.length,7)}).map((t,s)=>e.jsx(i.div,{initial:{scale:0},animate:{scale:1},transition:{delay:s*.1},children:e.jsx(Ge,{className:"w-4 h-4",style:{color:"#FFA24C",fill:"#FFA24C"}})}
36,s)),c.length>7&&e.jsxs("span",{className:"text-sm font-medium ml-1",style:{color:"#FFA24C"},children:["+",c.length-7]})]})]})}),e.jsx(b,{mode:"popLayout",children:d.map((t,s)=>e.jsxs(i.div,{layout:!0,initial:{opacity:0,y:8},animate:{opacity:1,y:0},exit:{opacity:0,scale:.95},transition:{delay:s*.03},className:"rounded-2xl overflow-hidden",style:{background:t.status==="done"?l?"linear-gradient(150deg, #1C2E2A 0%, rgba(20,40,36,0.8) 100%)":"linear-gradient(150deg, #FFFFFF 0%, rgba(240, 253, 249, 0.8) 100%)":l?"linear-gradient(150deg, #1C2E2A 0%, rgba(22,40,36,0.9) 100%)":"linear-gradient(150deg, #FFFFFF 0%, rgba(247, 252, 251, 0.9) 100%)",border:t.status==="done"?"1px solid rgba(45, 188, 122, 0.15)":"1px solid rgba(15, 111, 104, 0.09)",boxShadow:"0 4px 16px rgba(15, 111, 104, 0.07), 0 1px 4px rgba(0,0,0,0.03)",borderLeft:t.status==="open"?(()=>{const a=t.createdAt?Math.floor((Date.now()-new Date(t.createdAt).getTime())/864e5):0;return t.followUpAt&&new Date(t.followUpAt)<new Date?"3px solid #D97706":a>=14?"3px solid rgba(255, 162, 76, 0.5)":a>=7?"3px solid rgba(15, 111, 104, 0.3)":"3px solid #0F6F68"})():void 0},"data-testid":`loop-${t.id}`,children:[e.jsxs("div",{className:"px-5 pt-4 pb-2",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("p",{className:`text-[15px] font-semibold leading-snug flex-1 ${t.status==="done"?"line-through opacity-50":""}`,style:{color:l?"#E8E4DC":"#1A2E28"},children:t.title}),(t.whyItMatters||t.definitionOfDone&&t.definitionOfDone.length>0||t.nextAction||t.fasterPath||t.attempts&&t.attempts.length>0||t.currentThinking||t.stuckReason)&&e.jsx("button",{onClick:()=>{we(W===t.id?null:t.id),h(null)},className:"p-1 shrink-0","data-testid":`button-expand-${t.id}`,children:W===t.id?e.jsx(Qe,{className:"w-4 h-4",style:{color:"#8B9A91"}}):e.jsx(Re,{className:"w-4 h-4",style:{color:"#8B9A91"}})})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-1.5 flex-wrap",children:[(()=>{const a=t.createdAt?Math.floor((Date.now()-new Date(t.createdAt).getTime())/864e5):0,n=t.followUpAt&&new Date(t.followUpAt)<new Date&&t.status==="open",x=a>=14&&t.status==="open";return e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-[11px]",style:{color:n?"#D97706":x?"rgba(217, 119, 6, 0.7)":"rgba(75, 82, 78, 0.45)"},children:[t.createdAt?new Date(t.createdAt).toLocaleDateString("en-US",{month:"short",day:"numeric"}):"",t.status==="open"&&a>0&&` · ${a}d`]}),n&&e.jsxs("span",{className:"flex items-center gap-0.5 text-[10px] font-bold uppercase tracking-wider px-2 py-0.5 rounded-md",style:{background:"rgba(217, 119, 6, 0.12)",color:"#D97706"},children:[e.jsx(ue,{className:"w-2.5 h-2.5"}),"Overdue"]}),!n&&t.followUpAt&&t.status==="open"&&e.jsxs("span",{className:"flex items-center gap-0.5 text-[10px] font-bold uppercase tracking-wider px-2 py-0.5 rounded-md",style:{background:"rgba(255, 162, 76, 0.08)",color:"#D97706"},children:[e.jsx(ue,{className:"w-2.5 h-2.5"}),new Date(t.followUpAt).toLocaleDateString("en-US",{month:"short",day:"numeric"})]}),a>=7&&a<14&&!n&&t.status==="open"&&e.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider px-2 py-0.5 rounded-md",style:{background:"rgba(15, 111, 104, 0.07)",color:"rgba(15, 111, 104, 0.55)"},children:"Week+"}),x&&!n&&e.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider px-2 py-0.5 rounded-md",style:{background:"rgba(255, 162, 76, 0.06)",color:"rgba(217, 119, 6, 0.6)"},children:"Stale"})]})})(),t.status==="open"&&t.stuckReason&&e.jsxs("span",{className:"flex items-center gap-0.5 text-[10px] font-medium px-2 py-0.5 rounded-md",style:{background:"rgba(139, 154, 145, 0.1)",color:"rgba(75, 82, 78, 0.6)"},"data-testid":`badge-stuck-${t.id}`,children:[e.jsx(be,{className:"w-2.5 h-2.5"}),"Quiet a while"]}),t.status==="done"&&t.completedAt&&e.jsxs("span",{className:"text-[10px] font-bold uppercase tracking-wider px-2 py-0.5 rounded-md",style:{background:"rgba(45, 188, 122, 0.08)",color:"#2DBC7A"},children:["Closed ",new Date(t.completedAt).toLocaleDateString("en-US",{month:"short",day:"numeric"})]})]}),e.jsx(b,{children:W===t.id&&(t.whyItMatters||t.definitionOfDone&&t.definitionOfDone.length>0||t.nextAction||t.fasterPath||t.attempts&&t.attempts.length>0||t.currentThinking||t.stuckReason)&&e.jsxs(i.div,{initial:{opacity:0,height:0}
36,animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},className:"mt-3 pt-3 space-y-3",style:{borderTop:"1px solid rgba(15, 111, 104, 0.08)"},children:[t.whyItMatters&&e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] font-bold uppercase tracking-[0.1em] block mb-1",style:{color:"#FFA24C"},children:"Why it matters"}),e.jsx(k,{className:"text-sm leading-relaxed prose prose-sm max-w-none prose-p:my-1 prose-strong:font-bold",style:{color:l?"#9CA6A0":"#4B524E"},children:t.whyItMatters})]}),t.definitionOfDone&&t.definitionOfDone.length>0&&e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] font-bold uppercase tracking-[0.1em] block mb-1",style:{color:"#0F6F68"},children:"Definition of done"}),e.jsx("ul",{className:"space-y-1",children:t.definitionOfDone.map((a,n)=>e.jsxs("li",{className:"text-sm flex items-start gap-2",style:{color:l?"#E8E4DC":"#1A1A1A"},children:[e.jsx("span",{style:{color:"#0F6F68"},children:"â¢"}),a]},n))})]}),t.nextAction&&e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] font-bold uppercase tracking-[0.1em] block mb-1",style:{color:"#0F6F68"},children:"Next action"}),e.jsx(k,{className:"text-sm font-medium leading-relaxed prose prose-sm max-w-none prose-p:my-1 prose-strong:font-bold",style:{color:l?"#E8E4DC":"#1A1A1A"},children:t.nextAction})]}),t.fasterPath&&e.jsxs("div",{className:"p-3 rounded-xl",style:{background:"rgba(255, 162, 76, 0.06)",border:"1px solid rgba(255, 162, 76, 0.12)"},children:[e.jsxs("div",{className:"flex items-center gap-1 mb-1",children:[e.jsx(Ye,{className:"w-3 h-3",style:{color:"#FFA24C"}}),e.jsx("label",{className:"text-[11px] font-bold uppercase tracking-[0.1em]",style:{color:"#D97706"},children:"Faster path"})]}),e.jsx(k,{className:"text-sm leading-relaxed prose prose-sm max-w-none prose-p:my-1 prose-strong:font-bold",style:{color:l?"#9CA6A0":"#4B524E"},children:t.fasterPath})]}),Array.isArray(t.attempts)&&t.attempts.length>0&&e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] font-bold uppercase tracking-[0.1em] block mb-1.5",style:{color:"#0F6F68"},children:"The journey"}),e.jsx("ul",{className:"space-y-2.5",children:t.attempts.map((a,n)=>e.jsxs("li",{className:"relative pl-4","data-testid":`attempt-${t.id}-${n}`,children:[e.jsx("span",{className:"absolute left-0 top-[7px] w-1.5 h-1.5 rounded-full",style:{background:"rgba(15, 111, 104, 0.4)"}}),e.jsx("p",{className:"text-sm font-medium leading-snug",style:{color:l?"#E8E4DC":"#1A1A1A"},children:a.action}),a.outcome&&e.jsx("p",{className:"text-[13px] leading-snug mt-0.5",style:{color:"#6B726E"},children:a.outcome}),a.date&&e.jsx("p",{className:"text-[10px] mt-0.5",style:{color:"rgba(75, 82, 78, 0.45)"},children:new Date(a.date).toLocaleDateString("en-US",{month:"short",day:"numeric"})})]},n))})]}),t.currentThinking&&e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] font-bold uppercase tracking-[0.1em] block mb-1",style:{color:"#0F6F68"},children:"Where you are now"}),e.jsx(k,{className:"text-sm leading-relaxed prose prose-sm max-w-none prose-p:my-1 prose-strong:font-bold",style:{color:l?"#9CA6A0":"#4B524E"},children:t.currentThinking})]}),t.stuckReason&&e.jsxs("div",{className:"p-3 rounded-xl",style:{background:"rgba(15, 111, 104, 0.04)",border:"1px solid rgba(15, 111, 104, 0.1)"},"data-testid":`stuck-reason-${t.id}`,children:[e.jsxs("div",{className:"flex items-center gap-1 mb-1",children:[e.jsx(be,{className:"w-3 h-3",style:{color:"#0F6F68"}}),e.jsx("label",{className:"text-[11px] font-bold uppercase tracking-[0.1em]",style:{color:"#0F6F68"},children:"What might be keeping it open"})]}),e.jsx(k,{className:"text-sm leading-relaxed prose prose-sm max-w-none prose-p:my-1 prose-strong:font-bold",style:{color:l?"#9CA6A0":"#4B524E"},children:t.stuckReason})]})]})})]}),t.status==="open"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative px-3 py-2",style:{borderTop:"1px solid rgba(15, 111, 104, 0.05)"},children:[e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsxs("button",{onClick:()=>Ee(t.id),disabled:w.isPending,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[12px] font-medium whitespace-nowrap shrink-0",style:{color:"#2DBC
367A"},"data-testid":`button-done-${t.id}`,children:[e.jsx(Z,{className:"w-3.5 h-3.5"}),"Done"]}),e.jsxs("button",{onClick:()=>C(te===t.id?null:t.id),className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[12px] font-medium whitespace-nowrap shrink-0",style:{color:"#6B7C74"},"data-testid":`button-notyet-${t.id}`,children:[e.jsx(ze,{className:"w-3.5 h-3.5"}),"Not yet"]}),e.jsxs("button",{onClick:()=>h(D===t.id?null:t.id),className:"flex items-center gap-1 px-2.5 py-1.5 rounded-lg text-[12px] font-medium whitespace-nowrap shrink-0 ml-auto",style:{color:"#6B7C74",background:D===t.id?"rgba(15, 111, 104, 0.08)":"transparent"},"data-testid":`button-more-${t.id}`,children:[e.jsx(He,{className:"w-3.5 h-3.5"}),"More"]})]}),D===t.id&&e.jsxs("div",{className:"mt-1 rounded-xl overflow-hidden",style:{background:"rgba(248, 245, 238, 0.95)",border:"1px solid rgba(15, 111, 104, 0.12)"},children:[g&&e.jsxs("button",{onClick:()=>{h(null),Te(t)},className:"w-full flex items-center gap-3 px-4 py-2.5 text-[13px] font-medium text-left",style:{color:"#0F6F68",borderBottom:"1px solid rgba(15, 111, 104, 0.08)"},"data-testid":`button-talk-${t.id}`,children:[e.jsx(_e,{className:"w-4 h-4 shrink-0"}),"Talk it through"]}),e.jsxs("button",{onClick:()=>{h(null),ve(t)},className:"w-full flex items-center gap-3 px-4 py-2.5 text-[13px] font-medium text-left",style:{color:"#4B524E",borderBottom:"1px solid rgba(15, 111, 104, 0.08)"},"data-testid":`button-edit-${t.id}`,children:[e.jsx(he,{className:"w-4 h-4 shrink-0"}),"Edit loop"]}),t.followUpAt&&e.jsxs("a",{href:$e(t),target:"_blank",rel:"noopener noreferrer",onClick:()=>h(null),className:"w-full flex items-center gap-3 px-4 py-2.5 text-[13px] font-medium",style:{color:"#4B524E",borderBottom:"1px solid rgba(15, 111, 104, 0.08)",display:"flex"},"data-testid":`button-gcal-${t.id}`,children:[e.jsx(qe,{className:"w-4 h-4 shrink-0"}),"Add to Google Calendar"]}),e.jsxs("button",{onClick:()=>{h(null),Le(t.id)},disabled:w.isPending,className:"w-full flex items-center gap-3 px-4 py-2.5 text-[13px] font-medium text-left",style:{color:"#D97C40"},"data-testid":`button-drop-${t.id}`,children:[e.jsx(V,{className:"w-4 h-4 shrink-0"}),"Drop loop"]})]})]}),e.jsx(b,{children:te===t.id&&e.jsxs(i.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},className:"px-4 py-2.5 flex items-center gap-2",style:{background:"rgba(255, 162, 76, 0.04)",borderTop:"1px solid rgba(255, 162, 76, 0.1)"},children:[e.jsx("span",{className:"text-xs font-medium",style:{color:"#5A6B64"},children:"Check back:"}),e.jsx("button",{onClick:()=>ce(t.id,"tomorrow"),className:"px-3 py-1.5 rounded-lg text-[11px] font-semibold",style:{background:"linear-gradient(135deg, rgba(255, 162, 76, 0.12) 0%, rgba(255, 162, 76, 0.06) 100%)",color:"#D97706"},children:"Tomorrow"}),e.jsx("button",{onClick:()=>ce(t.id,"next_week"),className:"px-3 py-1.5 rounded-lg text-[11px] font-semibold",style:{background:"linear-gradient(135deg, rgba(255, 162, 76, 0.12) 0%, rgba(255, 162, 76, 0.06) 100%)",color:"#D97706"},children:"Next week"})]})})]})]},t.id))}),o==="open"&&F.length>0&&e.jsxs(i.div,{initial:{opacity:0}
36,animate:{opacity:1},className:"rounded-2xl px-4 py-3 text-center mt-2",style:{background:"linear-gradient(145deg, #FFFFFF 0%, #F8FAF9 100%)",border:"1px solid rgba(45, 188, 122, 0.15)",boxShadow:"0 4px 16px rgba(15, 111, 104, 0.04)"},children:[e.jsxs("p",{className:"text-xs font-semibold",style:{color:"#2DBC7A"},children:[F.length," open ",F.length===1?"loop":"loops"]}),e.jsx("p",{className:"text-[11px] mt-0.5",style:{color:"#5A6B64"},children:"Closing these will show up in your monthly capsule"})]})]}):e.jsxs(i.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:"text-center py-12",children:[e.jsxs("div",{className:"w-20 h-20 rounded-2xl mx-auto mb-5 flex items-center justify-center relative",style:{background:l?"linear-gradient(145deg, #1C2E2A 0%, #162820 100%)":"linear-gradient(145deg, #FFFFFF 0%, #F8FAF9 100%)",border:`1px solid ${l?"rgba(15,111,104,0.3)":"rgba(15, 111, 104, 0.15)"}`,boxShadow:"0 8px 32px rgba(15, 111, 104, 0.1)"},children:[o==="done"?e.jsx(X,{className:"w-9 h-9",style:{color:"#FFA24C"}}):e.jsx(me,{className:"w-9 h-9",style:{color:"#3D9A8C"}}),e.jsx("div",{className:"absolute -top-1 -right-1 w-6 h-6 rounded-full flex items-center justify-center",style:{background:"linear-gradient(135deg, #FFA24C 0%, #E88A30 100%)"},children:e.jsx(J,{className:"w-3 h-3 text-white"})})]}),e.jsx("h3",{className:"text-xl font-bold mb-2",style:{color:"#0F6F68"},children:o==="open"?"No open loops":o==="done"?"Your trophy case awaits":"No loops yet"}),e.jsx("p",{className:"text-sm mb-6 max-w-xs mx-auto leading-relaxed",style:{color:"#4B524E"},children:o==="open"?"Loops track things you've committed to. When you mention something you'll do in chat, I'll offer to add it here.":o==="done"?"Every loop you close is a promise you kept to yourself. Start completing loops and watch this space fill with your wins.":"Loops you complete will show up here."}),o!=="done"&&e.jsxs("div",{className:"p-5 rounded-2xl max-w-xs mx-auto text-left",style:{background:"linear-gradient(145deg, #FFFFFF 0%, #F8FAF9 100%)",border:"1px solid rgba(15, 111, 104, 0.12)",boxShadow:"0 8px 32px rgba(15, 111, 104, 0.06)"},children:[e.jsxs("p",{className:"text-sm font-bold uppercase tracking-[0.1em] mb-3 flex items-center gap-2",style:{color:"#0F6F68"},children:[e.jsx(J,{className:"w-3.5 h-3.5",style:{color:"#FFA24C"}}),"How to get started"]}),e.jsxs("ul",{className:"text-sm space-y-2.5",style:{color:"#4B524E"},children:[e.jsxs("li",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"w-5 h-5 rounded-full flex items-center justify-center text-[11px] font-bold text-white flex-shrink-0 mt-0.5",style:{background:"linear-gradient(135deg, #0F6F68 0%, #3D9A8C 100%)"},children:"1"}),e.jsx("span",{children:'Tap "Add Loop" to add one manually'})]}),e.jsxs("li",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"w-5 h-5 rounded-full flex items-center justify-center text-[11px] font-bold text-white flex-shrink-0 mt-0.5",style:{background:"linear-gradient(135deg, #0F6F68 0%, #3D9A8C 100%)"},children:"2"}),e.jsx("span",{children:"Or tell me something you plan to do in chat"})]}),e.jsxs("li",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"w-5 h-5 rounded-full flex items-center justify-center text-[11px] font-bold text-white flex-shrink-0 mt-0.5",style:{background:"linear-gradient(135deg, #0F6F68 0%, #3D9A8C 100%)"},children:"3"}),e.jsx("span",{children:"Mark loops Done when you complete them"})]})]})]})]})})}),e.jsx(b,{children:K&&e.jsx(i.div,{initial:{opacity:0}
36,animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 z-[90] flex items-end justify-center",style:{background:"rgba(0, 0, 0, 0.5)"},onClick:()=>f(null),"data-testid":"edit-loop-overlay",children:e.jsxs(i.div,{initial:{y:100,opacity:0},animate:{y:0,opacity:1},exit:{y:100,opacity:0},transition:{type:"spring",damping:25},className:"w-full max-w-lg rounded-t-2xl p-5 space-y-4",style:{background:"linear-gradient(145deg, #FFFFFF 0%, #F8FAF9 100%)",boxShadow:"0 -8px 32px rgba(15, 111, 104, 0.12)"},onClick:t=>t.stopPropagation(),"data-testid":"edit-loop-modal",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(he,{className:"w-4 h-4",style:{color:"#0F6F68"}}),e.jsx("h3",{className:"text-sm font-bold",style:{color:"#1A1A1A"},children:"Edit Loop"})]}),e.jsx("button",{onClick:()=>f(null),className:"p-1.5 rounded-lg",style:{background:"rgba(15, 111, 104, 0.06)"},"data-testid":"button-close-edit",children:e.jsx(V,{className:"w-4 h-4",style:{color:"#5A6B64"}})})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] font-bold uppercase tracking-[0.1em] block mb-1.5",style:{color:"#0F6F68"},children:"Title"}),e.jsx(m,{value:A,onChange:t=>se(t.target.value),className:"border-0 font-medium text-sm",style:{background:"rgba(15, 111, 104, 0.04)",border:"1px solid rgba(15, 111, 104, 0.1)"},"data-testid":"input-edit-title"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] font-bold uppercase tracking-[0.1em] block mb-1.5",style:{color:"#FFA24C"},children:"Why it matters"}),e.jsx(m,{value:oe,onChange:t=>de(t.target.value),placeholder:"Why this matters to you",className:"border-0 text-sm",style:{background:"rgba(255, 162, 76, 0.04)",border:"1px solid rgba(255, 162, 76, 0.1)"},"data-testid":"input-edit-why"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] font-bold uppercase tracking-[0.1em] block mb-1.5",style:{color:"#0F6F68"},children:"Next action"}),e.jsx(m,{value:ne,onChange:t=>re(t.target.value),placeholder:"What's the next step?",className:"border-0 text-sm",style:{background:"rgba(15, 111, 104, 0.04)",border:"1px solid rgba(15, 111, 104, 0.1)"},"data-testid":"input-edit-next-action"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] font-bold uppercase tracking-[0.1em] block mb-1.5",style:{color:"#FFA24C"},children:"Follow-up date"}),e.jsx(m,{type:"date",value:Q,onChange:t=>ie(t.target.value),className:"border-0 text-sm",style:{background:"rgba(15, 111, 104, 0.04)",border:"1px solid rgba(15, 111, 104, 0.1)"},"data-testid":"input-edit-follow-up"})]})]}),e.jsxs("div",{className:"flex gap-2 pt-1",children:[e.jsxs("button",{onClick:Ce,disabled:!A.trim()||H.isPending,className:"flex items-center px-4 py-2 rounded-2xl text-sm font-semibold active:scale-95 transition-transform disabled:opacity-60",style:{background:"linear-gradient(135deg, #0F6F68 0%, #3D9A8C 100%)",color:"#FFFFFF",border:"none"},"data-testid":"button-save-edit",children:[H.isPending?e.jsx(pe,{className:"w-4 h-4 animate-spin mr-1"}):e.jsx(Z,{className:"w-4 h-4 mr-1"}),"Save changes"]}),e.jsx("button",{onClick:()=>f(null),className:"px-4 py-2 rounded-2xl text-sm font-medium active:scale-95 transition-transform",style:{color:"#5A6B64",background:"rgba(75,82,78,0.06)",border:"1px solid rgba(75,82,78,0.1)"},"data-testid":"button-cancel-edit",children:"Cancel"})]})]})})}),e.jsx(b,{children:R&&e.jsxs(i.div,{initial:{opacity:0}
36,animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 z-[100] flex items-center justify-center cursor-pointer",style:{background:"rgba(10, 88, 82, 0.95)"},onClick:()=>Y(!1),"data-testid":"celebration-overlay",children:[ke.map(t=>e.jsx(i.div,{initial:{opacity:0,scale:0,x:0,y:0},animate:{opacity:[0,1,0],scale:[0,1,.5],x:t.x,y:t.y},transition:{duration:2,delay:t.delay,ease:"easeOut"},className:"absolute pointer-events-none",style:{left:"50%",top:"50%"},children:e.jsx(J,{className:"w-6 h-6",style:{color:t.isOrange?"#FFA24C":"#FFFFFF",filter:"drop-shadow(0 0 8px rgba(255, 162, 76, 0.5))"}})},t.id)),e.jsxs(i.div,{initial:{scale:.5,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.8,opacity:0},transition:{type:"spring",damping:15},className:"text-center px-8",onClick:t=>t.stopPropagation(),children:[e.jsx(i.div,{initial:{scale:0},animate:{scale:1},transition:{delay:.2,type:"spring"},className:"w-24 h-24 rounded-full mx-auto mb-6 flex items-center justify-center",style:{background:"linear-gradient(135deg, #FFA24C 0%, #E88A30 100%)",boxShadow:"0 8px 40px rgba(255, 162, 76, 0.4)"},children:e.jsx(Z,{className:"w-12 h-12 text-white",style:{strokeWidth:3}})}),e.jsx(i.h2,{initial:{y:20,opacity:0},animate:{y:0,opacity:1},transition:{delay:.3},className:"text-3xl font-bold text-white mb-3",children:"Loop Closed!"}),e.jsxs(i.p,{initial:{y:20,opacity:0},animate:{y:0,opacity:1},transition:{delay:.4},className:"text-base max-w-xs mx-auto mb-4",style:{color:"rgba(255, 255, 255, 0.85)"},children:['"',q.length>50?q.substring(0,50)+"...":q,'"']}),e.jsx(i.p,{initial:{y:20,opacity:0},animate:{y:0,opacity:1},transition:{delay:.5},className:"text-sm font-medium mb-4",style:{color:"#FFA24C"},children:j>=21?`${j} days. You came back and finished it. That takes real resolve.`:j>=14?"Two weeks of carrying this. Now it's done. That's weight off your mind.":j>=7?"A week from intention to completion. Solid follow-through.":j>=3?"Quick turnaround. You said it and you did it.":"You followed through. That's rare."}),e.jsx(i.p,{initial:{opacity:0}
36,animate:{opacity:1},transition:{delay:1},className:"text-sm",style:{color:"rgba(255, 255, 255, 0.5)"},children:"Tap anywhere to continue"})]})]})})]})}export{lt as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.