PageSourceSearch

https://gigaboost.ai/assets/phase-2-email-CLTqzbVe.js

js gigaboost.ai collected 2026-10-05 12:01:00 UTC 44,914 bytes, 3 lines download raw bytes

1import{u as $,a as y,c as I,j as e}from"./vendor-query-DhjOgUDD.js";import{u as de,L as U}from"./vendor-router-BMMoSqdB.js";import{ai as ie,q as P,g as E,e as q,a as z,aj as le,B as R,T as oe,x as ce,y as me,z as ue,I as ee,P as xe}from"./index-4ZDWxsof.js";import{B as pe}from"./badge-joxsXedy.js";import{S as fe}from"./switch-BWLVYv-K.js";import{M as H}from"./mission-nav-bar-B0_dxSbj.js";import{g as K,S as Q,p as B,r as M,T as te,h as W,H as se,L as he,e as G,aE as ae,U as ge,J as be,f as _,ab as je,X as ve,aG as Ne,E as ye,a4 as we}from"./vendor-icons-443ez2nG.js";import{I as ke}from"./investor-portrait-DW_ZGX_h.js";import"./vendor-radix-Bi3hcZEw.js";import"./vendor-motion-BL_E91F5.js";function Se(t){return t.split(/\s+/).filter(Boolean).slice(0,2).map(n=>n[0]?.toUpperCase()??"").join("")||"IN"}function Ce(t){let n=0;for(const a of t)n=(n*31+a.charCodeAt(0))%360;return n}function ne(t){if(!t)return"soon";const n=new Date(t),a=n.getTime()-Date.now();if(a<0)return"now";const p=Math.round(a/864e5);return p===0?"today":p===1?"tomorrow":n.toLocaleDateString(void 0,{weekday:"long",month:"short",day:"numeric"})}function De(t,n){const[a,p]=y.useState(null),l=y.useRef(0);return y.useEffect(()=>{if(!n||t.length===0){p(null);return}let f=!1;const d=m=>new Promise(u=>setTimeout(u,m));return(async()=>{for(;!f;){const m=t[l.current%t.length];l.current+=1;const u=g=>!f&&p(i=>({scene:m,subjectTyped:"",bodyTyped:"",step:"",done:!1,...i?.scene===m?i:{},...g}));u({scene:m,step:`Writing to ${m.investorName.split(" ")[0]}`}),await d(900);let N="";for(const g of m.subject){if(f)return;N+=g,u({subjectTyped:N}),await d(28+Math.random()*30)}await d(400);let h="";for(const g of m.body.slice(0,420)){if(f)return;h+=g,u({bodyTyped:h}),await d(14+Math.random()*22+(/[.!?]/.test(g)?90:0))}u({step:m.scheduledDate&&new Date(m.scheduledDate).getTime()>Date.now()?`Scheduled — sends ${ne(m.scheduledDate)}`:"Ready to send",done:!0}),await d(3200)}})(),()=>{f=!0}},[n,t]),a}function Ee({className:t}){const[,n]=de(),a=ie(),{data:p}=$({queryKey:["/api/cadence/active"],staleTime:3e4}),{data:l}=$({queryKey:["/api/email/logs",{limit:30}],queryFn:()=>E("GET","/api/email/logs?limit=30").then(c=>c.json()),staleTime:3e4}),{data:f}=$({queryKey:["/api/email/sending-method"],staleTime:6e4}),{data:d}=$({queryKey:["/api/linkedin/warming/auto-approve-status"],staleTime:3e4}),m=!!f?.method&&f.method!=="none",u=!!d?.enabled,N=y.useMemo(()=>{const c=[];for(const v of p??[]){if(v.status!=="active"&&v.status!=="paused")continue;const T=v.steps.filter(D=>(D.channel==="email"||D.type==="email")&&D.status==="pending"&&D.subject&&D.content).sort((D,re)=>new Date(D.scheduledDate||0).getTime()-new Date(re.scheduledDate||0).getTime())[0];T&&c.push({cadenceId:v.id,investorName:v.investorName,investorCompany:v.investorCompany,subject:T.subject,body:T.content.replace(/<[^>]+>/g,""),scheduledDate:T.scheduledDate})}return c.sort((v,T)=>new Date(v.scheduledDate||0).getTime()-new Date(T.scheduledDate||0).getTime()).slice(0,12)},[p]),[h,g]=y.useState(null);y.useEffect(()=>a.on("email_sent",c=>{g({email:c?.recipientEmail||"",at:Date.now()}),P.invalidateQueries({queryKey:["/api/email/logs",{limit:30}]}),setTimeout(()=>g(null),8e3)}),[a.on]);const i=De(N,!h),w=(l??[]).filter(c=>c.status==="sent"),j=new Date;j.setHours(0,0,0,0);const S=w.filter(c=>c.sentAt&&new Date(c.sentAt)>=j).length,k=N.length,o=N[0]?.scheduledDate??null,C=I({mutationFn:async()=>{await E("POST","/api/linkedin/warming/auto-approve-all",{enabled:!0}),await E("POST","/api/approve/bulk-approve",{resumePaused:!1}).catch(()=>{})},onSuccess:()=>{P.invalidateQueries({queryKey:["/api/linkedin/warming/auto-approve-status"]}),P.invalidateQueries({queryKey:["/api/cadence/active"]})}}),s=h?`Sent to ${h.email}`:m?u?"Your email agent is running":"Drafts written — waiting for your go":"Your email agent, before you connect a sender",b=m?u?o?`Next one ${ne(o)}.`:"Nothing due yet.":`${k} ready.`:"Preview of the real drafts.",r=i?.scene,x=Ce(r?.investorName||"x");return e.jsxs("section",{className:q("rounded-3xl overflow-hidden bg-card border border-border/60",t),"data-testid":"email-stage",children:[e.jsxs("div",{className:"px-6 md:px-8 pt-6 flex flex-wrap items-center gap-x-4 gap-y-2",children:[e.jsx("span",{className:q("h-2.5 w-2.5 rounded-full",h?"bg-red-500 animate-pulse":m&&u?"bg-emerald-400 animate-pulse":"bg-muted-foreground
1/50")}),e.jsx("p",{className:"text-foreground font-semibold text-[15px]",children:s}),e.jsx("p",{className:"text-sm text-muted-foreground",children:b}),e.jsxs("div",{className:"ml-auto flex items-center gap-4 text-foreground/80 text-xs tabular-nums",children:[e.jsxs("span",{children:[e.jsx("b",{className:"text-foreground text-sm",children:S})," sent today"]}),e.jsxs("span",{children:[e.jsx("b",{className:"text-foreground text-sm",children:k})," scheduled"]})]})]}),e.jsx("div",{className:"px-4 md:px-8 pt-5",children:e.jsxs("div",{className:"rounded-xl bg-white text-[#191919] border border-black/10 shadow-sm overflow-hidden","data-testid":"email-screen",children:[e.jsxs("div",{className:"h-9 bg-[#f3f2ef] border-b border-black/10 flex items-center px-4 gap-3 text-xs text-black/50",children:[e.jsx(K,{className:"h-3.5 w-3.5"})," New message",e.jsx("span",{className:q("ml-auto text-[10px] font-semibold tracking-wider px-2 py-0.5 rounded-full",h?"bg-red-500 text-white":"bg-black/5 text-black/50"),children:h?"● LIVE":"PREVIEW"})]}),r?e.jsxs("div",{className:"p-5 md:p-6 space-y-3 text-[14px]",children:[e.jsxs("div",{className:"flex items-center gap-3 border-b border-black/10 pb-3",children:[e.jsx("span",{className:"text-black/45 w-14 shrink-0",children:"To"}),e.jsx("span",{className:"h-7 w-7 rounded-full text-foreground text-[11px] font-bold flex items-center justify-center",style:{background:`hsl(${x} 45% 45%)`},children:Se(r.investorName)}),e.jsx("span",{className:"font-medium",children:r.investorName}),r.investorCompany&&e.jsxs("span",{className:"text-black/50",children:["· ",r.investorCompany]})]}),e.jsxs("div",{className:"flex items-center gap-3 border-b border-black/10 pb-3",children:[e.jsx("span",{className:"text-black/45 w-14 shrink-0",children:"Subject"}),e.jsxs("span",{className:"font-medium",children:[i?.subjectTyped,i&&!i.done&&i.subjectTyped.length<r.subject.length&&e.jsx("span",{className:"inline-block w-[2px] h-[1em] align-middle bg-black/70 ml-0.5 animate-pulse"})]})]}),e.jsxs("div",{className:"min-h-[120px] max-h-52 overflow-hidden whitespace-pre-wrap leading-relaxed text-black/85",children:[i?.bodyTyped,i&&!i.done&&i.subjectTyped.length>=r.subject.length&&e.jsx("span",{className:"inline-block w-[2px] h-[1em] align-middle bg-black/70 ml-0.5 animate-pulse"})]}),e.jsxs("div",{className:"flex items-center gap-3 pt-1",children:[e.jsxs("span",{className:q("rounded-full px-4 py-1.5 text-sm font-semibold",i?.done?"bg-black/10 text-black/40":"bg-[#0a66c2] text-white"),children:[e.jsx(Q,{className:"inline h-3.5 w-3.5 mr-1.5 -mt-0.5"}),"Send"]}),e.jsxs("span",{className:q("text-sm flex items-center gap-1.5",i?.done?"text-emerald-700 font-medium":"text-black/60"),children:[i?.done?e.jsx(B,{className:"h-4 w-4"}):e.jsx("span",{className:"h-2 w-2 rounded-full bg-[#0a66c2] animate-pulse"}),i?.step]})]})]}):e.jsx("div",{className:"p-8 text-center text-sm text-black/50",children:h?`Sent to ${h.email}.`:"No emails drafted yet. They appear once an investor's LinkedIn run goes quiet."})]})}),e.jsxs("div",{className:"px-6 md:px-8 py-5 flex flex-col md:flex-row md:items-center gap-3 md:justify-between",children:[e.jsx("p",{className:"text-sm text-muted-foreground max-w-xl",children:m?u?"Sends on schedule from your address. Stops on reply.":"Say the word once. Every draft sends on its day, and stops the moment an investor replies.":"Connect a sender and these go out on schedule, from your address."}),m?u?null:e.jsxs("button",{onClick:()=>C.mutate(),disabled:C.isPending,className:"inline-flex items-center gap-2 rounded-full font-bold px-6 py-3 text-[15px] disabled:opacity-60",style:{background:"#0b1220",color:"#ffffff"},"data-testid":"button-email-let-it-send",children:[e.jsx(Q,{className:"h-4 w-4"})," ",C.isPending?"Starting…":"Let it send"]}):e.jsxs("button",{onClick:()=>n("/agent-setup"),className:"inline-flex items-center gap-2 rounded-full font-bold px-6 py-3 text-[15px]",style:{background:"#0b1220",color:"#ffffff"},"data-testid":"button-email-connect",children:[e.jsx(K,{className:"h-4 w-4"})," Connect email"]})]}),w.length>0&&e.jsxs("div",{className:"mx-4 md:mx-8 mb-6 rounded-2xl bg-muted/40 border border-border/60 px-4 py-3",children:[e.jsx("p",{className:"text-[11px] font-semibold tracking-widest uppercase text-muted-foreground mb-2",children:"Sent so far"}),e.jsx("ul",{className:"space-y-1.5",children:w.slice(0,6).map(c=>
1e.jsxs("li",{className:"text-xs text-foreground/80 flex items-center gap-2",children:[e.jsx(B,{className:"h-3.5 w-3.5 shrink-0",style:{color:"#16a34a"}}),e.jsx("span",{className:"font-medium truncate",children:c.recipientName||c.recipientEmail}),e.jsxs("span",{className:"text-muted-foreground truncate",children:["· ",c.subject]}),e.jsx("span",{className:"ml-auto text-muted-foreground/60 tabular-nums shrink-0",children:c.sentAt?new Date(c.sentAt).toLocaleDateString(void 0,{month:"short",day:"numeric"}):""})]},c.id))})]})]})}const Te=t=>t.channel==="email"||t.channel==="follow_up_email"||t.type==="email",O=t=>["completed","sent","skipped"].includes(t.status),J=t=>(t||"").replace(/<br\s*\/?>/gi,`
2`).replace(/<[^>]+>/g,"").replace(/&nbsp;/g," ").trim(),qe=t=>t.replace(/^\s*(hi|hello|dear|hey)?\s*[^\n,]{0,40},\s*\n+/i,"").replace(/\s*\n+\s*/g," ").trim(),Pe=t=>t?new Date(t).toDateString():"unscheduled",$e=t=>{if(!t)return"Not scheduled yet";const n=new Date(t),a=new Date;a.setHours(0,0,0,0);const p=Math.round((new Date(n).setHours(0,0,0,0)-a.getTime())/864e5),l=n.toLocaleDateString(void 0,{weekday:"long",month:"short",day:"numeric"});return p===0?`Today · ${l}`:p===1?`Tomorrow · ${l}`:p<0?`Due · ${l}`:l},L=t=>t?new Date(t).toLocaleDateString(void 0,{weekday:"short",month:"short",day:"numeric"}):"";function Ae(){const{toast:t}=z(),{project:n}=le(),a=n?.id,{data:p,isLoading:l}=$({queryKey:["/api/cadence/active"],refetchInterval:3e4}),{data:f}=$({queryKey:["/api/deck-uploads",String(a),"results"],queryFn:()=>E("GET",`/api/deck-uploads/${a}/results`).then(r=>r.json()),enabled:!!a,staleTime:6e4}),{data:d}=$({queryKey:["/api/email/sending-method"],staleTime:3e4}),{data:m}=$({queryKey:["/api/email/settings"],staleTime:3e4}),{data:u}=$({queryKey:["/api/linkedin/warming/auto-approve-status"],staleTime:3e4}),N=y.useMemo(()=>new Map((f?.matches??[]).map(r=>[r.investorId,r])),[f]),h=y.useMemo(()=>(p??[]).filter(r=>(r.status==="active"||r.status==="paused")&&(!a||r.deckUploadId===a)).map(r=>{const x=r.steps.filter(v=>Te(v)&&v.subject&&v.content).sort((v,T)=>v.dayOffset-T.dayOffset||v.stepNumber-T.stepNumber),c=x.find(v=>!O(v))??null;return{c:r,emails:x,next:c,m:N.get(r.investorId)}}).filter(r=>r.emails.length>0),[p,a,N]),g=!!d?.method&&d.method!=="none",i=!g&&!!m?.resendPending,w=!!u?.enabled,j=h.reduce((r,x)=>r+x.emails.filter(c=>!O(c)).length,0),S=h.reduce((r,x)=>r+x.emails.filter(O).length,0),k=h.map(r=>r.next?.scheduledDate).filter(Boolean).sort()[0],o=g?w?"active":"ready":i?"dns":"blocked",C=y.useMemo(()=>{const r=new Map,x=[...h].sort((c,v)=>{const T=c.next?.scheduledDate?new Date(c.next.scheduledDate).getTime():1/0,D=v.next?.scheduledDate?new Date(v.next.scheduledDate).getTime():1/0;return T-D||(v.c.fitScore??0)-(c.c.fitScore??0)});for(const c of x){const v=c.next?Pe(c.next.scheduledDate):"done";r.has(v)||r.set(v,{title:c.next?$e(c.next.scheduledDate):"Sequence complete",at:c.next?.scheduledDate??null,rows:[]}),r.get(v).rows.push(c)}return[...r.values()]},[h]),s=I({mutationFn:async()=>{await E("POST","/api/linkedin/warming/auto-approve-all",{enabled:!0}),await E("POST","/api/approve/bulk-approve",{resumePaused:!1}).catch(()=>{})},onSuccess:()=>{P.invalidateQueries({queryKey:["/api/linkedin/warming/auto-approve-status"]}),P.invalidateQueries({queryKey:["/api/cadence/active"]}),t({title:"Email automation active",description:"Every email sends on its day and stops the moment an investor replies."})},onError:()=>t({title:"Couldn't start sending",description:"Try again in a moment.",variant:"destructive"})}),b={blocked:{title:"Email Automation Paused",sub:`${j} personalized ${j===1?"draft is":"drafts are"} queued and waiting for your sending domain.`},dns:{title:"Email Automation Paused",sub:`${j} personalized ${j===1?"draft is":"drafts are"} queued. Your sending domain is waiting on DNS.`},ready:{title:"Email Automation Ready",sub:`${j} ${j===1?"draft is":"drafts are"} written and ready to send from ${d?.fromEmail||"your domain"}.`},active:{title:"Email Automation Active",sub:`Sending from ${d?.fromEmail||"your domain"}. Each sequence stops the moment an investor replies.`}}[o];return l?e.jsxs("div",{className:"flex items-center justify-center gap-3 py-24 text-muted-foreground",children:[e.jsx(M,{className:"h-5 w-5 animate-spin"}),e.jsx("span",{className:"text-sm",children:"Loading the queue…"})]}):e.jsxs("div",{className:"mx-auto max-w-4xl px-5 pt-8 pb-16","data-testid":"email-queue",children:[e.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-x-8 gap-y-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"inline-flex items-center gap-2 text-[11px] font-bold uppercase tracking-[0.1em] text-muted-foreground",children:[e.jsx("span",{className:q("h-2 w-2 rounded-full",o==="active"?"bg-emerald-500":o==="ready"?"bg-[#007aff]":o==="dns"?"bg-amber-500":"bg-red-500")}),"AI Email Automation",n?.companyName?` · ${n.companyName}`:""]}),e.jsx("h1",{className:"mt-2 text-[30px] md:text-[36px] font-bold tracking-[-0.02em] leading-tight","data-testid":"email-queue-title",children:b.title}),e.jsx("p",{className:"mt-2 text-[15px] text-muted-foreground max-w-[58ch]",children:b.sub})]}),e.jsxs("dl",{className:"flex items-end gap-8",children:[e.jsx(V,{label:"Dispatched",value:S}),e.jsx(V,{label:"Queued",value:j}),k&&e.jsxs("div",{className:"text-right",children:[e.jsx("dt",{className:"text-[11px] font-semibold uppercase tracking-[0.08em] text-muted-foreground",children:"Next send"}),e.jsx("dd",{className:"mt-1 text-[15px] font-semibold",children:L(k)})]})]})]}),o!=="active"&&e.jsxs("div",{className:q("mt-7 rounded-2xl border px-6 py-5 flex flex-col md:flex-row md:items-center gap-4",o==="ready"?"border-border bg-card":"border-amber-300/70 bg-amber-50/70 dark:bg-amber-500/10"),"data-testid":"email-queue-action",children:[e.jsx("div",{className:"min-w-0 flex-1",children:o==="ready"?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-[16px] font-bold tracking-[-0.01em]",children:"Approve the queue to start sending"}),e.jsxs("p",{className:"mt-1 text-[14px] text-muted-foreground",children:["Each email goes out on its day from ",d?.fromEmail||"your domain",". Or approve them one at a time below."]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"inline-flex items-center gap-2 text-[16px] font-bold tracking-[-0.01em] text-red-700 dark:text-red-400",children:[e.jsx(te,{className:"h-4 w-4"}),"Action required: ",o==="dns"?"finish your DNS records":"connect your sending domain"]}
2),e.jsx("p",{className:"mt-1 text-[14px] text-foreground/75",children:o==="dns"?"Your domain is added. Emails dispatch as soon as its DNS records verify.":"Emails can't be dispatched until a verified sender address is linked."})]})}),o==="ready"?e.jsxs("button",{type:"button",onClick:()=>s.mutate(),disabled:s.isPending,className:"shrink-0 inline-flex items-center justify-center gap-2 rounded-full bg-foreground text-background font-bold px-6 py-3 text-[15px] disabled:opacity-60","data-testid":"email-queue-start",children:[s.isPending?e.jsx(M,{className:"h-4 w-4 animate-spin"}):e.jsx(Q,{className:"h-4 w-4"}),"Approve all & start sending"]}):e.jsxs(U,{href:"/agent-setup",className:"shrink-0 inline-flex items-center justify-center gap-2 rounded-full bg-foreground text-background font-bold px-6 py-3 text-[15px]","data-testid":"email-queue-connect",children:[e.jsx(K,{className:"h-4 w-4"}),o==="dns"?"Finish DNS setup":"Connect sending domain",e.jsx(W,{className:"h-4 w-4"})]})]}),h.length===0?e.jsxs("div",{className:"mt-10 rounded-2xl border border-border bg-card px-6 py-12 text-center",children:[e.jsx("p",{className:"text-[16px] font-semibold",children:"No emails drafted for this project yet"}),e.jsx("p",{className:"mt-1.5 text-[14px] text-muted-foreground",children:"They're written when you generate the acquisition strategy."}),e.jsxs(U,{href:a?`/agent/${a}`:"/agent",className:"mt-5 inline-flex items-center gap-2 rounded-full bg-foreground text-background font-semibold px-5 py-2.5 text-[14px]",children:["Open the AI Agent ",e.jsx(W,{className:"h-4 w-4"})]})]}):e.jsx("div",{className:"mt-10 space-y-9",children:C.map(r=>e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-3 border-b border-border pb-2.5",children:[e.jsx("h2",{className:"text-[12px] font-bold uppercase tracking-[0.1em] text-muted-foreground",children:r.title}),e.jsxs("span",{className:"text-[12px] text-muted-foreground tabular-nums",children:[r.rows.length," ",r.rows.length===1?"investor":"investors"]})]}),e.jsx("div",{className:"mt-4 space-y-3",children:r.rows.map(x=>e.jsx(Ie,{row:x,mode:o},x.c.id))})]},r.title))})]})}function V({label:t,value:n}){return e.jsxs("div",{className:"text-right",children:[e.jsx("dt",{className:"text-[11px] font-semibold uppercase tracking-[0.08em] text-muted-foreground",children:t}),e.jsx("dd",{className:"mt-0.5 text-[26px] font-bold tabular-nums leading-none",children:n})]})}function Ie({row:t,mode:n}){const{c:a,emails:p,next:l,m:f}=t,[d,m]=y.useState(!1),u=n==="blocked"||n==="dns",N=f?.investor,h=N?.name||a.investorName,g=[N?.title,N?.companyName||a.investorCompany].filter(Boolean).join(" · "),i=f?.fitScore??a.fitScore,w=l??p[p.length-1],j=p.filter(o=>o.id!==w.id),S=o=>O(o)?{icon:B,text:`Sent · ${L(o.completedAt||o.scheduledDate)}`,cls:"border-emerald-600/30 bg-emerald-50 text-emerald-800 dark:bg-emerald-500/10 dark:text-emerald-300"}:u?{icon:he,text:`Queued · Day ${o.dayOffset+1}`,cls:"border-border bg-muted/50 text-muted-foreground"}:o.status==="approved"||n==="active"?{icon:G,text:`Scheduled · ${L(o.scheduledDate)}`,cls:"border-[#007aff]/25 bg-[#007aff]/[0.06] text-[#0b5cc4]"}:{icon:G,text:`Awaiting approval · ${L(o.scheduledDate)}`,cls:"border-amber-400/50 bg-amber-50 text-amber-800 dark:bg-amber-500/10 dark:text-amber-300"},k=S(w);return e.jsxs("article",{className:"rounded-2xl border border-border bg-card px-5 py-5","data-testid":`email-queue-card-${a.investorId}`,children:[e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx(ke,{name:h,src:N?.photoUrl,kind:N?.photoKind,size:48,className:u?"opacity-90":void 0}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2.5 gap-y-1",children:[e.jsx("p",{className:"text-[16px] font-bold tracking-[-0.01em] truncate",children:h}),i!=null&&e.jsx("span",{className:"rounded-full bg-emerald-50 dark:bg-emerald-500/10 px-2 py-0.5 text-[11px] font-bold tabular-nums text-emerald-700 dark:text-emerald-300",children:i})]}),g&&e.jsx("p",{className:"text-[13.5px] text-muted-foreground truncate",children:g})]}),e.jsxs("span",{className:q("shrink-0 inline-flex items-center gap-1.5 rounded-full border px-3 py-1 text-[11px] font-bold uppercase tracking-[0.06em]",k.cls),children:[e.jsx(k.icon,{className:"h-3 w-3"}),k.text]})]}),e.jsx(X,{step:w,open:d,locked:u}),j.length>0&&e.jsx("ul",{className:"mt-3 space-y-1.5",children:j.map(o=>{const C=S(o);return e.jsxs("li",{className:"flex items-center gap-2 text-[13px] text-muted-foreground",children:[e.jsx(C.icon,{className:"h-3.5 w-3.5 shrink-0"}
2),e.jsx("span",{className:"font-medium text-foreground/80",children:o.dayOffset>w.dayOffset?"Follow-up":"Intro"}),e.jsxs("span",{children:["· Day ",o.dayOffset+1,o.scheduledDate&&!O(o)?` · ${L(o.scheduledDate)}`:""]}),e.jsxs("span",{className:"truncate",children:["· ",o.subject]})]},o.id)})}),d&&j.map(o=>e.jsx(X,{step:o,open:!0,locked:u,label:`Follow-up · Day ${o.dayOffset+1}`},o.id)),e.jsxs("div",{className:"mt-4 flex flex-wrap items-center gap-2.5",children:[e.jsxs("button",{type:"button",onClick:()=>m(o=>!o),className:"inline-flex items-center gap-1 text-[13px] font-semibold text-foreground/80 hover:text-foreground","data-testid":`email-queue-read-${a.investorId}`,children:[d?"Hide":j.length?`Read ${p.length} emails`:"Read email",e.jsx(se,{className:q("h-3.5 w-3.5 transition-transform",d&&"rotate-180")})]}),u&&d&&e.jsx("span",{className:"text-[12.5px] text-muted-foreground",children:"Editing unlocks once your sending domain is connected."})]})]})}function X({step:t,open:n,locked:a,label:p}){const{toast:l}=z(),[f,d]=y.useState(!1),[m,u]=y.useState(t.subject||""),[N,h]=y.useState(J(t.content)),g=J(t.content),i=O(t),w=!a&&!i,j=I({mutationFn:()=>E("PATCH",`/api/cadence/step/${t.id}`,{subject:m.trim(),content:N.trim()}).then(k=>k.json()),onSuccess:()=>{P.invalidateQueries({queryKey:["/api/cadence/active"]}),d(!1),l({title:"Email updated"})},onError:()=>l({title:"Couldn't save",description:"Try again.",variant:"destructive"})}),S=I({mutationFn:()=>E("POST",`/api/cadence/step/${t.id}/approve-schedule`,{}).then(k=>k.json()),onSuccess:()=>{P.invalidateQueries({queryKey:["/api/cadence/active"]}),l({title:"Approved",description:`Sends ${L(t.scheduledDate)||"on schedule"}.`})},onError:()=>l({title:"Couldn't approve",description:"Try again.",variant:"destructive"})});return e.jsxs("div",{className:q("mt-4 rounded-xl border border-border px-4 py-4",a?"bg-muted/40":"bg-background"),children:[p&&e.jsx("p",{className:"mb-2 text-[11px] font-bold uppercase tracking-[0.08em] text-muted-foreground",children:p}),f?e.jsxs(e.Fragment,{children:[e.jsx("input",{value:m,onChange:k=>u(k.target.value),className:"w-full rounded-lg border border-border bg-card px-3 py-2 text-[14px] font-semibold"}),e.jsx("textarea",{value:N,onChange:k=>h(k.target.value),rows:9,className:"mt-2 w-full rounded-lg border border-border bg-card px-3 py-2 text-[14px] leading-relaxed"}),e.jsxs("div",{className:"mt-3 flex gap-2",children:[e.jsx("button",{type:"button",onClick:()=>j.mutate(),disabled:j.isPending,className:"rounded-full bg-foreground text-background font-bold px-4 py-2 text-[13px] disabled:opacity-60",children:j.isPending?"Saving…":"Save"}),e.jsx("button",{type:"button",onClick:()=>{d(!1),u(t.subject||""),h(g)},className:"rounded-full border border-border px-4 py-2 text-[13px] font-semibold",children:"Cancel"})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:q("text-[14.5px] font-semibold",a&&"text-foreground/85"),children:[e.jsx("span",{className:"text-muted-foreground font-medium",children:"Subject:"})," ",t.subject]}),e.jsx("p",{className:q("mt-2 text-[14px] leading-relaxed",n&&"whitespace-pre-wrap",a?"text-muted-foreground":"text-foreground/85",!n&&"line-clamp-2"),children:n?g:qe(g)}),n&&w&&e.jsxs("div",{className:"mt-4 flex gap-2",children:[t.status!=="approved"&&e.jsxs("button",{type:"button",onClick:()=>S.mutate(),disabled:S.isPending,className:"inline-flex items-center gap-1.5 rounded-full bg-foreground text-background font-bold px-4 py-2 text-[13px] disabled:opacity-60","data-testid":`email-approve-${t.id}`,children:[S.isPending?e.jsx(M,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(B,{className:"h-3.5 w-3.5"}),"Approve"]}),e.jsxs("button",{type:"button",onClick:()=>d(!0),className:"inline-flex items-center gap-1.5 rounded-full border border-border px-4 py-2 text-[13px] font-semibold",children:[e.jsx(ae,{className:"h-3.5 w-3.5"}),"Edit"]})]})]})]})}const Fe=new Set(["email","follow_up_email"]);function A(t){return Fe.has(t.channel)}function F(t,n){return n?"paused":t.status==="completed"||t.status==="sent"?"sent":t.status==="failed"?"failed":t.status==="skipped"?"sent":t.autoSend&&t.status==="pending"?"approved":t.status==="awaiting_approval"?"needs_review":t.status==="pending"?t.scheduledDate?new Date(t.scheduledDate)<=new Date?"needs_review":"scheduled":"needs_review":"pending"}function Z(t){if(!t)return"";const n=new Date(t),a=new Date,p=n.getTime()-a.getTime(),l=Math.round(p/864e5);return l===0?"today":l===1?"tomorrow":l===-1?"yesterday":l>0?`in ${l}d`:`${Math.abs(l)}d ago`}function Me(t,n){const a=(t.title||"").toLowerCase();return a.includes("intro")||a.includes("pattern")||n===0?"Intro email":a.includes("traction")?"Traction update":a.includes("final")||a.includes("door")?"Final email":`Follow-up #${n}`}function Y(t,n){const a=t.filter(f=>["sent","skipped"].includes(f.status)||f.status==="completed").length,p=t.filter(f=>F(f,n)==="needs_review").length,l=t.filter(f=>{const d=F(f,n);return d==="scheduled"||d==="approved"}).length;return{sent:a,needsReview:p,scheduled:l,total:t.length}}function Re({status:t}){const n={sent:{label:"Sent",className:"bg-emerald-100 text-emerald-700 dark:bg-emerald-900/30 dark:text-emerald-400"},approved:{label:"Queued",className:"bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400"},needs_review:{label:"Needs review",className:"bg-amber-100 text-amber-700 dark:bg-amber-900/30 dark:text-amber-400"}
2,scheduled:{label:"Scheduled",className:"bg-foreground/[0.06] text-muted-foreground"},pending:{label:"Pending",className:"bg-foreground/[0.06] text-muted-foreground"},failed:{label:"Failed",className:"bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400"},paused:{label:"Paused",className:"bg-amber-100 text-amber-700 dark:bg-amber-900/30 dark:text-amber-400"}},a=n[t]??n.pending;return e.jsx("span",{className:`inline-flex items-center text-[10px] font-semibold uppercase tracking-wider px-2 py-0.5 rounded-full ${a.className}`,children:a.label})}function Le({step:t,emailIndex:n,cadencePaused:a,cadenceId:p}){const[l,f]=y.useState(!1),[d,m]=y.useState(!1),[u,N]=y.useState(t.subject??""),[h,g]=y.useState(t.content?.replace(/<[^>]+>/g,"")??""),{toast:i}=z(),w=F(t,a);y.useEffect(()=>{d||(N(t.subject??""),g(t.content?.replace(/<[^>]+>/g,"")??""))},[t.subject,t.content,d]);const j=I({mutationFn:()=>E("POST",`/api/cadence/step/${t.id}/approve-schedule`,{}).then(x=>x.json()),onSuccess:()=>{P.invalidateQueries({queryKey:["/api/cadence/active"]}),i({title:"Email queued",description:"Will send on the scheduled date."})},onError:x=>i({title:"Failed to queue email",description:x?.message||"Try again.",variant:"destructive"})}),S=I({mutationFn:()=>E("POST",`/api/cadence/step/${t.id}/approve-send`,{}).then(x=>x.json()),onSuccess:()=>{P.invalidateQueries({queryKey:["/api/cadence/active"]}),i({title:"Email sent"})},onError:x=>i({title:"Failed to send",description:x?.message||"Check email settings.",variant:"destructive"})}),k=I({mutationFn:()=>E("PATCH",`/api/cadence/step/${t.id}`,{subject:u.trim(),content:h.trim()}).then(x=>x.json()),onSuccess:()=>{P.invalidateQueries({queryKey:["/api/cadence/active"]}),m(!1),i({title:"Email updated"})},onError:x=>i({title:"Failed to save",description:x?.message||"Try again.",variant:"destructive"})}),o=Me(t,n),C=w==="needs_review",s=w==="sent",b=w==="failed",r=!s;return e.jsxs("div",{className:`rounded-lg border ${s?"border-border/40 opacity-70":C?"border-amber-300 dark:border-amber-700/60 shadow-sm":"border-border/60"} bg-card overflow-hidden`,children:[e.jsxs("div",{className:"flex items-start gap-3 px-4 py-3",children:[e.jsx("div",{className:`mt-0.5 h-7 w-7 rounded-full flex items-center justify-center shrink-0 text-xs font-bold
3          ${s?"bg-emerald-100 text-emerald-600 dark:bg-emerald-900/30 dark:text-emerald-400":C?"bg-amber-100 text-amber-600 dark:bg-amber-900/30 dark:text-amber-400":"bg-foreground
3/[0.06] text-foreground/50"}`,children:s?e.jsx(_,{className:"h-3.5 w-3.5"}):n+1}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("p",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wider",children:o}),e.jsx(Re,{status:w}),t.scheduledDate&&!s&&e.jsxs("span",{className:`text-[10px] ${w==="needs_review"&&new Date(t.scheduledDate)<=new Date?"text-amber-600 font-medium":"text-muted-foreground"}`,children:["· ",Z(t.scheduledDate)]}),s&&t.completedAt&&e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["· sent ",Z(t.completedAt)]})]}),!d&&e.jsxs(e.Fragment,{children:[t.subject&&e.jsx("p",{className:"text-sm font-medium text-foreground mt-0.5 truncate",children:t.subject}),t.content&&!l&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1 line-clamp-2 leading-relaxed",children:t.content.replace(/<[^>]+>/g,"").slice(0,200)}),l&&t.content&&e.jsx("div",{className:"mt-2 text-sm text-foreground leading-relaxed whitespace-pre-wrap border-t border-border/50 pt-2",children:t.content.replace(/<[^>]+>/g,"")})]}),d&&e.jsxs("div",{className:"mt-2 space-y-2",children:[e.jsx(ee,{value:u,onChange:x=>N(x.target.value),placeholder:"Subject line",className:"h-8 text-sm font-medium"}),e.jsx(xe,{value:h,onChange:x=>g(x.target.value),placeholder:"Email body",className:"text-sm leading-relaxed min-h-[180px] resize-y"})]})]}),e.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[r&&!d&&e.jsx("button",{onClick:()=>{m(!0),f(!1)},className:"p-1 text-muted-foreground hover:text-foreground rounded transition-colors",title:"Edit email",children:e.jsx(ae,{className:"h-3.5 w-3.5"})}),d&&e.jsx("button",{onClick:()=>m(!1),className:"p-1 text-muted-foreground hover:text-foreground rounded transition-colors",title:"Cancel edit",children:e.jsx(ve,{className:"h-3.5 w-3.5"})}),!d&&t.content&&e.jsx("button",{onClick:()=>f(x=>!x),className:"p-1 text-muted-foreground hover:text-foreground rounded transition-colors",children:l?e.jsx(Ne,{className:"h-3.5 w-3.5"}):e.jsx(ye,{className:"h-3.5 w-3.5"})})]})]}),d&&e.jsxs("div",{className:"px-4 pb-3 flex items-center gap-2 border-t border-border/50 bg-foreground
3/[0.02]",children:[e.jsxs(R,{size:"sm",className:"gap-1.5 h-7 text-xs",onClick:()=>k.mutate(),disabled:k.isPending,children:[k.isPending?e.jsx(M,{className:"h-3 w-3 animate-spin"}):e.jsx(_,{className:"h-3 w-3"}),"Save changes"]}),e.jsx(R,{size:"sm",variant:"ghost",className:"h-7 text-xs",onClick:()=>m(!1),disabled:k.isPending,children:"Cancel"})]}),C&&!a&&!d&&e.jsxs("div",{className:"px-4 pb-3 flex items-center gap-2 border-t border-amber-200/60 dark:border-amber-700/30 bg-amber-50/50 dark:bg-amber-900/10",children:[e.jsxs(R,{size:"sm",className:"gap-1.5 h-7 text-xs",onClick:()=>j.mutate(),disabled:j.isPending||S.isPending,children:[j.isPending?e.jsx(M,{className:"h-3 w-3 animate-spin"}):e.jsx(_,{className:"h-3 w-3"}),"Approve & queue"]}),e.jsxs(R,{size:"sm",variant:"outline",className:"gap-1.5 h-7 text-xs",onClick:()=>S.mutate(),disabled:j.isPending||S.isPending,children:[S.isPending?e.jsx(M,{className:"h-3 w-3 animate-spin"}):e.jsx(Q,{className:"h-3 w-3"}),"Send now"]})]}),b&&!d&&e.jsxs("div",{className:"px-4 pb-3 flex items-center gap-2 border-t border-red-200/60 dark:border-red-700/30 bg-red-50/50 dark:bg-red-900/10",children:[e.jsx(te,{className:"h-3.5 w-3.5 text-red-500 shrink-0"}),e.jsx("span",{className:"text-xs text-red-600 dark:text-red-400",children:"Send failed — check email settings"}),e.jsxs(R,{size:"sm",variant:"outline",className:"gap-1.5 h-7 text-xs ml-auto",onClick:()=>S.mutate(),disabled:S.isPending,children:[e.jsx(we,{className:"h-3 w-3"}),"Retry"]})]})]})}function Oe({cadence:t}){const n=t.steps.filter(A).sort((m,u)=>m.dayOffset-u.dayOffset),a=t.status==="paused",{sent:p,needsReview:l,scheduled:f,total:d}=Y(n,a);return e.jsxs("div",{className:"h-full overflow-y-auto px-5 py-4 space-y-4",children:[e.jsx("div",{className:"flex items-start justify-between gap-3",children:e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold text-foreground",children:t.investorName}),t.investorCompany&&e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:t.investorCompany}),e.jsxs("div",{className:"flex items-center gap-3 mt-2",children:[e.jsxs("span",{className:"text-xs text-muted-foreground",children:[p,"/",d," sent"]}),l>0&&e.jsxs("span",{className:"text-xs font-medium text-amber-600",children:[l," need",l!==1?"":"s"," review"]}),f>0&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:[f," scheduled"]}),t.fitScore&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:[t.fitScore,"% fit"]}),a&&e.jsx(pe,{variant:"outline",className:"text-amber-600 border-amber-300 text-[10px]",children:"Paused"})]})]})}),n.length===0?e.jsxs("div",{className:"text-center py-10",children:[e.jsx(G,{className:"h-8 w-8 text-muted-foreground/40 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Email sequence not generated yet."}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Emails are drafted on Day 8 of the cadence."})]}):e.jsx("div",{className:"space-y-2",children:n.map((m,u)=>e.jsx(Le,{step:m,emailIndex:u,cadencePaused:a,cadenceId:t.id},m.id))})]})}function Ke({cadence:t,selected:n,onClick:a}){const p=t.status==="paused",l=t.steps.filter(A),{sent:f,needsReview:d,scheduled:m,total:u}=Y(l,p),N=d>0;return e.jsxs("button",{onClick:a,className:`w-full text-left px-3 py-2.5 rounded-lg transition-colors border ${n?"bg-primary/10 border-primary/30":"bg-transparent border-transparent hover:bg-foreground
3/[0.04]"}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-7 w-7 rounded-full bg-foreground/[0.06] flex items-center justify-center shrink-0 text-[10px] font-bold text-foreground/70",children:t.investorName.split(/\s+/).map(h=>h[0]).filter(Boolean).slice(0,2).join("").toUpperCase()}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-semibold text-foreground truncate",children:t.investorName}),t.investorCompany&&e.jsx("p",{className:"text-[10px] text-muted-foreground truncate",children:t.investorCompany})]}),N&&e.jsx("span",{className:"shrink-0 h-4 w-4 rounded-full bg-amber-500 text-white text-[8px] font-bold flex items-center justify-center",children:d})]}),e.jsxs("div",{className:"flex items-center gap-1.5 mt-1.5 ml-9",children:[f>0&&e.jsxs("span",{className:"text-[9px] font-medium px-1.5 py-0.5 rounded-full bg-emerald-100 text-emerald-700 dark:bg-emerald-900/20 dark:text-emerald-400",children:[f," sent"]}),d>0&&e.jsxs("span",{className:"text-[9px] font-medium px-1.5 py-0.5 rounded-full bg-amber-100 text-amber-700 dark:bg-amber-900/20 dark:text-amber-400",children:[d," to review"]}),m>0&&e.jsxs("span",{className:"text-[9px] font-medium px-1.5 py-0.5 rounded-full bg-foreground
3/[0.06] text-muted-foreground",children:[m," queued"]}),u===0&&e.jsx("span",{className:"text-[9px] text-muted-foreground",children:"No emails yet"}),p&&e.jsx("span",{className:"text-[9px] font-medium px-1.5 py-0.5 rounded-full bg-amber-100 text-amber-600",children:"Paused"})]})]})}function Ve(){return e.jsx(Ae,{})}function Xe(){const[t,n]=y.useState(!1),[a,p]=y.useState(""),[l,f]=y.useState("all"),[d,m]=y.useState(null),{toast:u}=z(),{data:N=[],isLoading:h}=$({queryKey:["/api/cadence/active"],refetchInterval:3e4}),g=y.useMemo(()=>N.filter(s=>(s.status==="active"||s.status==="paused")&&(s.steps.some(A)||s.status==="active")),[N]),i=y.useMemo(()=>{let s=0,b=0,r=0,x=0;for(const c of g){const v=c.steps.filter(A),T=c.status==="paused",D=Y(v,T);s+=D.needsReview,b+=D.scheduled,r+=D.sent,x+=D.total}return{needsReview:s,scheduled:b,sent:r,total:x,investors:g.length}},[g]),w=y.useMemo(()=>g.filter(s=>{if(a){const b=a.toLowerCase();if(!s.investorName.toLowerCase().includes(b)&&!(s.investorCompany||"").toLowerCase().includes(b))return!1}return l==="needs_review"?s.steps.filter(A).some(r=>F(r,s.status==="paused")==="needs_review"):l==="scheduled"?s.steps.filter(A).some(r=>["scheduled","approved"].includes(F(r,s.status==="paused"))):l==="sent"?s.steps.some(b=>A(b)&&(b.status==="completed"||b.status==="sent"||b.status==="skipped")):l==="paused"?s.status==="paused":!0}).sort((s,b)=>{const r=s.steps.filter(A).some(c=>F(c,s.status==="paused")==="needs_review"),x=b.steps.filter(A).some(c=>F(c,b.status==="paused")==="needs_review");return r&&!x?-1:!r&&x?1:(b.fitScore??0)-(s.fitScore??0)}),[g,a,l]),j=y.useMemo(()=>w.find(s=>s.id===d)??w[0]??null,[w,d]),S=I({mutationFn:async()=>{const s=g.flatMap(b=>b.steps.filter(r=>A(r)&&F(r,b.status==="paused")==="needs_review"));return await Promise.all(s.map(b=>E("POST",`/api/cadence/step/${b.id}/approve-schedule`,{}))),{count:s.length}},onSuccess:({count:s})=>{P.invalidateQueries({queryKey:["/api/cadence/active"]}),u({title:`${s} email${s!==1?"s":""} queued`})},onError:()=>u({title:"Bulk approve failed",variant:"destructive"})}),{data:k,refetch:o}=$({queryKey:["/api/linkedin/warming/auto-approve-status"]}),C=I({mutationFn:async s=>{await E("POST","/api/linkedin/warming/auto-approve-all",{enabled:s}),s&&await E("POST","/api/approve/bulk-approve",{resumePaused:!1})},onSuccess:(s,b)=>{o(),P.invalidateQueries({queryKey:["/api/cadence/active"]}),u({title:b?"Auto-approve enabled":"Auto-approve disabled",description:b?"All pending emails queued. Future emails will send automatically.":"Emails will require manual approval before sending."})},onError:()=>u({title:"Failed to update auto-approve",variant:"destructive"})});return h?e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsx("div",{className:"px-5 pt-5 pb-0",children:e.jsx(H,{activeTab:"email"})}),e.jsxs("div",{className:"flex-1 flex items-center justify-center gap-3 text-muted-foreground",children:[e.jsx(M,{className:"h-5 w-5 animate-spin"}),e.jsx("span",{className:"text-sm",children:"Loading sequences…"})]})]}):g.length===0?e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsx("div",{className:"px-5 pt-5 pb-0",children:e.jsx(H,{activeTab:"email"})}),e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-4 px-6 text-center",children:[e.jsx("div",{className:"h-14 w-14 rounded-2xl bg-foreground
3/[0.06] flex items-center justify-center",children:e.jsx(K,{className:"h-6 w-6 text-foreground/50"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-semibold",children:"No email sequences yet"}),e.jsxs("p",{className:"text-sm text-muted-foreground mt-1 max-w-sm leading-relaxed",children:["Email sequences are generated when you launch outreach from ",e.jsx("strong",{children:"Investors Matched"}),". LinkedIn warming runs first (Days 1–7), then emails kick off on Day 8."]})]}),e.jsx(U,{href:"/agent",children:e.jsxs(R,{className:"gap-2 mt-1",children:[e.jsx(ge,{className:"h-4 w-4"}),"Go to Investors Matched"]})})]})]}):e.jsxs("div",{className:"flex flex-col h-full","data-testid":"phase-2-email",children:[e.jsx("div",{className:"px-5 pt-5 pb-0",children:e.jsx(H,{activeTab:"email",emailCount:i.needsReview})}),e.jsxs("div",{className:"px-5 pt-5 space-y-4",children:[e.jsx(Ee,{}),e.jsxs("button",{type:"button",onClick:()=>n(s=>!s),className:"w-full rounded-2xl border border-border/60 bg-card px-5 py-4 flex items-center gap-3 text-sm font-medium text-left","data-testid":"email-sequences-toggle",children:[e.jsx(se,{className:`h-4 w-4 transition-transform ${t?"":"-rotate-90"}`}),t?"Hide sequences & drafts":"All sequences & drafts",e.jsxs("span",{className:"text-muted-foreground font-normal",children:["· ",i.investors," investor",i.investors===1?"":"s",i.needsReview?` · ${i.needsReview} to review`:""]})]})]}),t&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"bg-card border-b px-5 pt-5 pb-0 mt-6",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4 mb-4 flex-wrap",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-widest text-muted-foreground mb-0.5",children:"Phase 2 of 3 · Multi-touchpoint Acquisition Strategy"}),e.jsxs("h1",{className:"text-xl font-semibold tracking-tight flex items-center gap-2",children:[e.jsx(K,{className:"h-5 w-5 text-foreground"}),"Email Sequences"]})]}),e.jsxs("div",{className:"flex items-center gap-3 shrink-0 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-2 border rounded-lg px-3 py-2 bg-card",children:[e.jsx(fe,{id:"email-auto-approve",checked:k?.enabled??!1,onCheckedChange:s=>C.mutate(s),disabled:C.isPending}),e.jsx("label",{htmlFor:"email-auto-approve",className:"text-sm font-medium cursor-pointer select-none whitespace-nowrap",children:"Auto-approve & send"}),e.jsx(oe,{delayDuration:100,children:e.jsxs(ce,{children:[e.jsx(me,{asChild:!0,children:e.jsx(be,{className:"h-3.5 w-3.5 text-muted-foreground cursor-help shrink-0"})}),e.jsxs(ue,{side:"bottom",className:"max-w-xs text-xs leading-relaxed",children:[e.jsx("p",{className:"font-semibold mb-1",children:"How it works"}),e.jsxs("ul",{className:"space-y-0.5 list-disc list-inside",children:[e.jsx("li",{children:"AI drafts personalised emails for each investor"}),e.jsx("li",{children:"Emails send automatically on the scheduled day"}),e.jsxs("li",{children:["Max ",e.jsx("strong",{children:"50 emails/day"})," — resets at midnight"]}),e.jsx("li",{children:"Stops automatically on investor reply"}),e.jsx("li",{children:"Disable at any time to switch to manual review"})]})]})]})})]}),i.needsReview>0&&!k?.enabled&&e.jsxs(R,{className:"gap-2",onClick:()=>S.mutate(),disabled:S.isPending,children:[S.isPending?e.jsx(M,{className:"h-4 w-4 animate-spin"}):e.jsx(_,{className:"h-4 w-4"}),"Approve all ",i.needsReview]})]})]}),e.jsxs("div",{className:"grid grid-cols-4 divide-x border-t -mx-5",children:[e.jsxs("div",{className:"px-5 py-3",children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-widest text-muted-foreground mb-1",children:"Needs review"}),e.jsx("p",{className:`text-2xl font-bold leading-none ${i.needsReview>0?"text-amber-600":"text-foreground"}`,children:i.needsReview}),e.jsx("p",{className:"text-[10px] text-muted-foreground mt-1",children:"awaiting approval"})]}),e.jsxs("div",{className:"px-5 py-3",children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-widest text-muted-foreground mb-1",children:"Queued"}),e.jsx("p",{className:"text-2xl font-bold leading-none text-foreground",children:i.scheduled}),e.jsx("p",{className:"text-[10px] text-muted-foreground mt-1",children:"approved, scheduled to send"})]}),e.jsxs("div",{className:"px-5 py-3",children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-widest text-muted-foreground mb-1",children:"Sent"}),e.jsx("p",{className:"text-2xl font-bold leading-none text-foreground",children:i.sent}),e.jsx("p",{className:"text-[10px] text-muted-foreground mt-1",children:"emails delivered"})]}),e.jsxs("div",{className:"px-5 py-3",children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-widest text-muted-foreground mb-1",children:"Investors"}),e.jsx("p",{className:"text-2xl font-bold leading-none text-foreground",children:i.investors}),e.jsx("p",{className:"text-[10px] text-muted-foreground mt-1",children:"in email pipeline"})]})]})]}),e.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[e.jsxs("div",{className:"w-72 shrink-0 border-r flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-3 py-2 border-b space-y-2",children:[e.jsxs("div",{className:"relative",children:[e.jsx(je,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-3 w-3 text-muted-foreground"}),e.jsx(ee,{value:a,onChange:s=>p(s.target.value),placeholder:"Search investor…",className:"pl-7 h-7 text-xs"})]}),e.jsx("div",{className:"flex gap-1 flex-wrap",children:["all","needs_review","scheduled","sent","paused"].map(s=>e.jsx("button",{onClick:()=>f(s),className:`text-[10px] font-medium px-2 py-0.5 rounded-full transition-colors ${l===s?"bg-foreground text-background":"bg-foreground
3/[0.06] text-muted-foreground hover:text-foreground"}`,children:s==="needs_review"?`Review ${i.needsReview>0?`(${i.needsReview})`:""}`:s==="scheduled"?"Queued":s.charAt(0).toUpperCase()+s.slice(1)},s))})]}),e.jsx("div",{className:"flex-1 overflow-y-auto py-1 px-1",children:w.length===0?e.jsx("p",{className:"text-xs text-muted-foreground text-center py-8",children:"No investors match this filter."}):w.map(s=>e.jsx(Ke,{cadence:s,selected:s.id===(j?.id??null),onClick:()=>m(s.id)},s.id))}),e.jsxs("div",{className:"px-3 py-2 border-t text-[10px] text-muted-foreground text-center",children:[w.length," of ",g.length," investors"]})]}),e.jsx("div",{className:"flex-1 overflow-hidden",children:j?e.jsx(Oe,{cadence:j}):e.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground",children:e.jsx("p",{className:"text-sm",children:"Select an investor to view their sequence."})})})]})]})]})}export{Xe as LegacyPhase2Email,Ve 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.