1import{j as e}from"./vendor-query-CTPr7COe.js";import{r as o}from"./vendor-react-CWBOl209.js";import{supabase as B}from"./client-DfMaFnao.js";import{B as l}from"./index-BwVwZTqu.js";import{I as P}from"./input-e78583lc.js";import{B as w}from"./badge-txOk_X55.js";import{T as Z,a as ee,b as _,c as C}from"./tabs-CLJ6Xe8z.js";import{u as b}from"./index-B7XEVw87.js";import{d as U,_ as se,a6 as q,f as te,ap as ae,n as re,a1 as j,c as ne,a4 as oe,ai as ie,aj as le,a5 as ce,y as O,q as D,ae as de,T as me,aA as ue}from"./vendor-icons-3o8Kmjow.js";import{m as c}from"./proxy-EGdRh4XT.js";import{A as H}from"./index-DfawMrCs.js";import"./vendor-supabase-C_wNBzRW.js";import"./vendor-router-Tzw_FyRy.js";import"./vendor-helmet-CH9LKosZ.js";import"./index-DCdkj2k6.js";import"./index-C8087njY.js";import"./index-DjOZ8nEF.js";import"./index-DOWC6dku.js";import"./index-BOBH645Q.js";import"./index-B3aQLB-B.js";import"./index-TQfL9S1F.js";const k={pending:"bg-muted text-muted-foreground",contacted:"bg-blue-500/20 text-blue-400",responded:"bg-green-500/20 text-green-400",meeting_scheduled:"bg-purple-500/20 text-purple-400",interested:"bg-primary/20 text-primary",passed:"bg-destructive/20 text-destructive",committed:"bg-emerald-500/20 text-emerald-400"},N=[{id:"intro",name:"Initial Outreach",subject:"Quick intro: {startup_name} - {sector}",body:`Hi {investor_name}, 2 3I came across your portfolio at {firm} and noticed your focus on {sector} companies. I'm the founder of {startup_name}, and I believe our solution aligns well with your investment thesis. 4 5{executive_summary} 6 7We're currently raising {funding_amount} to {funding_use}. I'd love to schedule a brief call to share more about our traction and vision. 8 9Would you have 20 minutes this week? 10 11Best, 12{founder_name}`},{id:"follow_up",name:"Follow-up #1",subject:"Re: {startup_name} - Quick follow-up",body:`Hi {investor_name}, 13 14I wanted to follow up on my previous email about {startup_name}. Since my last note, we've: 15 16⢠{recent_milestone_1} 17⢠{recent_milestone_2} 18 19I understand you're busy, but I'd really value the opportunity to share our story. Even a 15-minute call would be great. 20 21Best, 22{founder_name}`},{id:"warm_intro",name:"Warm Introduction",subject:"{mutual_connection} suggested I reach out - {startup_name}",body:`Hi {investor_name}, 23 24{mutual_connection} suggested I reach out to you given your expertise in {sector}. I'm building {startup_name}, and {mutual_connection} thought you might find our approach interesting. 25 26{elevator_pitch} 27 28Would you be open to a brief conversation? 29 30Best, 31{founder_name}`},{id:"meeting_request",name:"Meeting Request",subject:"Meeting request: {startup_name} investment opportunity",body:`Dear {investor_name}, 32 33Thank you for your interest in {startup_name}. I'd like to schedule a meeting to dive deeper into our opportunity. 34 35Agenda: 361. Market opportunity and timing 372. Product demo and roadmap 383. Traction and metrics deep-dive 394. Team and execution capability 405. Investment terms and next steps 41 42Please let me know your availability for a 45-minute meeting. 43 44Best regards, 45{founder_name}`}];function $e({startup:u,campaignId:x}){const[r,S]=o.useState([]),[Q,W]=o.useState(!0),[i,I]=o.useState(null),[G,V]=o.useState("pipeline"),[g,J]=o.useState(""),[p,T]=o.useState(null),[K,h]=o.useState(!1),[xe,M]=o.useState(N[0]),[E,R]=o.useState(""),[v,F]=o.use
45State("");o.useEffect(()=>{x&&L()},[x]);const L=async()=>{if(x)try{const{data:s,error:t}=await B.from("campaign_investors").select(` 46 *, 47 investor:investors(*) 48 `).eq("campaign_id",x).order("fit_score",{ascending:!1});if(t)throw t;S(s||[])}catch(s){console.error("Error loading CRM data:",s)}finally{W(!1)}},$=async(s,t)=>{try{const{error:a}=await B.from("campaign_investors").update({status:t,updated_at:new Date().toISOString()}).eq("id",s);if(a)throw a;S(d=>d.map(m=>m.id===s?{...m,status:t}:m)),b.success(`Status updated to ${t.replace("_"," ")}`)}catch{b.error("Failed to update status")}},y=(s,t)=>{const a={"{investor_name}":s.investor.name?.split(" ")[0]||"there","{firm}":s.investor.firm||"your firm","{startup_name}":u.name,"{sector}":u.sector?.[0]||"technology","{executive_summary}":u.executive_summary?.substring(0,200)||"","{funding_amount}":u.funding_ask_amount?`$${(u.funding_ask_amount/1e6).toFixed(1)}M`:"our target round","{funding_use}":"scale our go-to-market and product development","{founder_name}":"The Founder","{recent_milestone_1}":"Achieved significant user growth","{recent_milestone_2}":"Launched key product features","{mutual_connection}":"[Mutual Connection]","{elevator_pitch}":u.solution||""};let d=t.subject,m=t.body;Object.entries(a).forEach(([z,A])=>{d=d.replace(new RegExp(z,"g"),A),m=m.replace(new RegExp(z,"g"),A)}),R(d),F(m),M(t),I(s),h(!0)},X=s=>{navigator.clipboard.writeText(s),b.success("Copied to clipboard")},Y=()=>{if(i?.investor.email){const s=`mailto:${i.investor.email}?subject=${encodeURIComponent(E)}&body=${encodeURIComponent(v)}`;window.open(s,"_blank"),$(i.id,"contacted"),h(!1)}else b.error("No email address available")},f=r.filter(s=>{const t=!g||s.investor.name?.toLowerCase().includes(g.toLowerCase())||s.investor.firm?.toLowerCase().includes(g.toLowerCase()),a=!p||s.status===p;return t&&a}),n={total:r.length,pending:r.filter(s=>s.status==="pending").length,contacted:r.filter(s=>s.status==="contacted").length,responded:r.filter(s=>s.status==="responded").length,meetings:r.filter(s=>s.status==="meeting_scheduled").length,interested:r.filter(s=>s.status==="interested").length,committed:r.filter(s=>s.status==="committed").length};return x?e.jsxs("section",{className:"relative overflow-hidden rounded-2xl border border-border/50 bg-card/50 backdrop-blur",children:[e.jsxs("div",{className:"p-6 border-b border-border/50",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl bg-gradient-to-br from-primary/20 to-purple-500/20 flex items-center justify-center",children:e.jsx(se,{className:"w-6 h-6 text-primary"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold font-mono",children:"Investor CRM"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Pipeline & Outreach Management"})]})]}),e.jsxs(l,{variant:"outline",size:"sm",onClick:L,className:"gap-2",children:[e.jsx(q,{className:"w-4 h-4"}),"Refresh"]})]}),e.jsx("div",{className:"grid grid-cols-7 gap-3",children:[{label:"Total",value:n.total,color:"bg-muted"},{label:"Pending",value:n.pending,color:"bg-muted"},{label:"Contacted",value:n.contacted,color:"bg-blue-500/20"},{label:"Responded",value:n.responded,color:"bg-green-500/20"},{label:"Meetings",value:n.meetings,color:"bg-purple-500/20"},{label:"Interested",value:n.interested,color:"bg-primary/20"},{label:"Committed",value:n.committed,color:"bg-emerald-500/20"}].map((s,t)=>e.jsxs(c.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:t*.05},className:`${s.color} rounded-lg p-3 text-center cursor-pointer hover:scale-105 transition-transform`,onClick:()=>T(s.label.toLowerCase().replace(" ","_")==="total"?null:s.label.toLowerCase().replace(" ","_")),children:[e.jsx("p",{className:"text-2xl font-bold font-mono",children:s.value}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s.label})]},s.label))})]}),e.jsxs("div",{className:"p-4 border-b border-border/50 flex gap-4",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(te,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(P,{placeholder:"Search investors...",value:g,onChange:s=>J(s.target.value),className:"pl-10 bg-secondary/50"})]}),e.jsxs(l,{variant:p?"default":"outline",size:"sm",onClick:()=>T(null),className:"gap-2",children:[e.jsx(ae,{className:"w-4 h-4"}),p?`Filter: ${p}`:"All Status"]})]}),e.jsxs(Z,{value:G,onValueChange:V,className:"p-6",children:[e.jsxs(ee,{className:"grid grid-cols-3 w-full max-w-md mb-6",children:[e.jsxs(_,{value:"pipeline",className:"gap-2",children:[e.jsx(re,{className:"w-4 h-4"}),"Pipeline"]}),e.jsxs(_,{value:"outreach",className:"gap-2",children:[e.jsx(j,{className:"w-4 h-4"}),"Outreach"]}),e.jsxs(_,{value:"analytics",className:"gap-2",children:[e.jsx(ne,{className:"w-4 h-4"}),"Analytics"]})]}),e.jsx(C,{value:"pipeline",className:"space-y-4",children:Q?e.jsxs("div",{className:"text-center py-12",children:[e.jsx(q,{className:"w-8 h-8 animate-spin mx-auto text-primary"}),e.jsx("p",{className:"mt-4 text-muted-foreground",children:"Loading pipeline..."})]}):f.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx(U,{className:"w-12 h-12 text-muted-foreground mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"No investors found"})]}):e.jsx("div",{className:"space-y-3",children:f.map((s,t)=>e.jsxs(c.div,{initial:{opacity:0,x:-20}
48,animate:{opacity:1,x:0},transition:{delay:t*.03},className:"group p-4 rounded-xl bg-secondary/30 hover:bg-secondary/50 transition-all cursor-pointer border border-transparent hover:border-primary/20",onClick:()=>I(i?.id===s.id?null:s),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-gradient-to-br from-primary/30 to-purple-500/30 flex items-center justify-center font-bold text-primary",children:s.investor.name?.charAt(0)||"?"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h4",{className:"font-semibold",children:s.investor.name}),s.fit_score>=.8&&e.jsx(oe,{className:"w-4 h-4 text-yellow-500 fill-yellow-500"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s.investor.firm||"Independent"})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"text-right",children:[e.jsxs("p",{className:"text-sm font-mono text-primary",children:[Math.round(s.fit_score*100),"% fit"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s.investor.geography||"Global"})]}),e.jsx(w,{className:k[s.status]||k.pending,children:s.status.replace("_"," ")}),i?.id===s.id?e.jsx(ie,{className:"w-4 h-4"}):e.jsx(le,{className:"w-4 h-4"})]})]}),e.jsx(H,{children:i?.id===s.id&&e.jsxs(c.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"mt-4 pt-4 border-t border-border/50 overflow-hidden",onClick:a=>a.stopPropagation(),children:[e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mb-4",children:[e.jsxs("div",{className:"p-3 rounded-lg bg-background/50",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Ticket Size"}),e.jsxs("p",{className:"font-mono text-sm",children:["$",((s.investor.ticket_size_min||0)/1e6).toFixed(1),"M - $",((s.investor.ticket_size_max||0)/1e6).toFixed(1),"M"]})]}),e.jsxs("div",{className:"p-3 rounded-lg bg-background/50",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Stage Focus"}),e.jsx("p",{className:"font-mono text-sm",children:s.investor.stage_focus?.slice(0,2).join(", ")||"Various"})]}),e.jsxs("div",{className:"p-3 rounded-lg bg-background/50",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Sector Focus"}),e.jsx("p",{className:"font-mono text-sm",children:s.investor.sector_focus?.slice(0,2).join(", ")||"Generalist"})]}),e.jsxs("div",{className:"p-3 rounded-lg bg-background/50",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Engagement"}),e.jsxs("p",{className:"font-mono text-sm",children:[Math.round((s.engagement_score||.75)*100),"%"]})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 mb-4",children:[s.investor.email&&e.jsxs(l,{size:"sm",variant:"outline",className:"gap-2",onClick:()=>y(s,N[0]),children:[e.jsx(j,{className:"w-3 h-3"}),"Email"]}),s.investor.linkedin_url&&e.jsxs(l,{size:"sm",variant:"outline",className:"gap-2",onClick:()=>window.open(s.investor.linkedin_url,"_blank"),children:[e.jsx(ce,{className:"w-3 h-3"}),"LinkedIn"]}),e.jsxs(l,{size:"sm",variant:"outline",className:"gap-2",onClick:()=>y(s,N[3]),children:[e.jsx(O,{className:"w-3 h-3"}),"Schedule Meeting"]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground mr-2 self-center",children:"Update status:"}),["pending","contacted","responded","meeting_scheduled","interested","passed","committed"].map(a=>e.jsx(w,{className:`cursor-pointer transition-all ${s.status===a?k[a]:"bg-muted/50 text-muted-foreground hover:bg-muted"}`,onClick:()=>$(s.id,a),children:a.replace("_"," ")},a))]})]})})]},s.id))})}),e.jsxs(C,{value:"outreach",className:"space-y-6",children:[e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:N.map(s=>e.jsxs(c.div,{whileHover:{scale:1.02},className:"p-4 rounded-xl bg-secondary/30 border border-border/50 hover:border-primary/30 cursor-pointer",onClick:()=>{M(s),f[0]&&y(f[0],s)},children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-primary/20 flex items-center justify-center",children:e.jsx(j,{className:"w-4 h-4 text-primary"})}),e.jsx("h4",{className:"font-semibold",children:s.name})]}),e.jsxs("p",{className:"text-sm text-muted-foreground line-clamp-2",children:[s.body.substring(0,100),"..."]})]},s.id))}),e.jsxs("div",{className:"grid grid-cols-4 gap-4 mt-6",children:[e.jsxs("div",{className:"p-4 rounded-xl bg-secondary/30 text-center",children:[e.jsx(D,{className:"w-6 h-6 mx-auto mb-2 text-blue-400"}),e.jsx("p",{className:"text-2xl font-bold font-mono",children:n.contacted}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Emails Sent"})]}),e.jsxs("div",{className:"p-4 rounded-xl bg-secondary/30 text-center",children:[e.jsx(de,{className:"w-6 h-6 mx-auto mb-2 text-green-400"}),e.jsx("p",{className:"text-2xl font-bold font-mono",children:n.responded}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Responses"})]}),e.jsxs("div",{className:"p-4 rounded-xl bg-secondary/30 text-center",children:[e.jsx(O,{className:"w-6 h-6 mx-auto mb-2 text-purple-400"}),e.jsx("p",{className:"text-2xl font-bold font-mono",children:n.meetings}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Meetings"})]}),e.jsxs("div",{className:"p-4 rounded-xl bg-secondary/30 text-center",children:[e.jsx(me,{className:"w-6 h-6 mx-auto mb-2 text-primary"}),e.jsxs("p",{className:"text-2xl font-bold font-mono",children:[n.contacted>0?Math.round(n.responded/n.contacted*100):0,"%"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Response Rate"})]})]})]}),e.jsx(C,{value:"analytics",className:"space-y-6",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"p-6 rounded-xl bg-secondary/30",children:[e.jsx("h4",{className:"font-semibold mb-4",children:"Fit Score Distribution"}),e.jsx("div",{className:"space-y-3",children:[{range:"90-100%",count:r.filter(s=>s.fit_score>=.9).length},{range:"80-89%",count:r.filter(s=>s.fit_score>=.8&&s.fit_score<.9).length},{range:"70-79%",count:r.filter(s=>s.fit_score>=.7&&s.fit_score<.8).length},{range:"60-69%",count:r.filter(s=>s.fit_score>=.6&&s.fit_score<.7).length},{range:"<60%",count:r.filter(s=>s.fit_score<.6).length}].map((s,t)=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-sm text-muted-foreground w-16",children:s.range}),e.jsx("div",{className:"flex-1 h-6 bg-background rounded-full overflow-hidden",children:e.jsx(c.div,{initial:{width:0},animate:{width:`${s.count/(r.length||1)*100}%`},transition:{delay:t*.1,duration:.5},className:"h-full bg-gradient-to-r from-primary to-primary/50"})}),e.jsx("span",{className:"text-sm font-mono w-8",children:s.count})]},s.range))})]}),e.jsxs("div",{className:"p-6 rounded-xl bg-secondary/30",children:[e.jsx("h4",{className:"font-semibold mb-4",children:"Geographic Coverage"}),e.jsx("div",{className:"grid grid-cols-2 gap-3",children:Array.from(new Set(r.map(s=>s.investor.geography||"Unknown"))).slice(0,6).map((s,t)=>{const a=r.filter(d=>d.investor.geography===s).length;return e.jsxs(c.div,{initial:{opacity:0,scale:.8}
48,animate:{opacity:1,scale:1},transition:{delay:t*.05},className:"p-3 rounded-lg bg-background/50 text-center",children:[e.jsx("p",{className:"text-lg font-bold font-mono text-primary",children:a}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:s})]},s)})})]})]})})]}),e.jsx(H,{children:K&&i&&e.jsx(c.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 bg-background/80 backdrop-blur-sm z-50 flex items-center justify-center p-4",onClick:()=>h(!1),children:e.jsxs(c.div,{initial:{scale:.9,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.9,opacity:0},className:"w-full max-w-2xl bg-card rounded-2xl border border-border/50 shadow-2xl overflow-hidden",onClick:s=>s.stopPropagation(),children:[e.jsxs("div",{className:"p-4 border-b border-border/50 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(j,{className:"w-5 h-5 text-primary"}),e.jsx("span",{className:"font-semibold",children:"Compose Email"})]}),e.jsx(l,{variant:"ghost",size:"sm",onClick:()=>h(!1),children:"â"})]}),e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 p-3 rounded-lg bg-secondary/30",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"To:"}),e.jsx("span",{className:"font-medium",children:i.investor.name}),e.jsx(w,{variant:"outline",children:i.investor.email||"No email"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:"Subject"}),e.jsx(P,{value:E,onChange:s=>R(s.target.value),className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm text-muted-foreground",children:"Message"}),e.jsx("textarea",{value:v,onChange:s=>F(s.target.value),className:"w-full mt-1 p-3 rounded-lg bg-secondary/30 border border-border/50 min-h-[200px] text-sm resize-none focus:outline-none focus:ring-2 focus:ring-primary/50"})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsxs(l,{variant:"outline",onClick:()=>X(v),className:"gap-2",children:[e.jsx(ue,{className:"w-4 h-4"}),"Copy"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(l,{variant:"ghost",onClick:()=>h(!1),children:"Cancel"}),e.jsxs(l,{onClick:Y,className:"gap-2",children:[e.jsx(D,{className:"w-4 h-4"}),"Send Email"]})]})]})]})]})})})]}):e.jsx("section",{className:"relative overflow-hidden rounded-2xl border border-border/50 bg-card/50 backdrop-blur p-8",children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx(U,{className:"w-16 h-16 text-muted-foreground mx-auto mb-4"}),e.jsx("h3",{className:"text-xl font-bold mb-2",children:"No Campaign Active"}),e.jsx("p",{className:"text-muted-foreground",children:"Run investor matching first to access CRM"})]})})}export{$e as InvestorCRM};
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.