1import{u as js,r as m,j as e,cB as ws,cC as Jn,a as ea,y as ta,b as Is,z as na,c as sa,E as Qn,cD as aa,cE as Xn,bn as hn,bu as pn,aQ as ra,A as oa,bw as ia,B as ca,S as la,bo as fn,cF as da,aC as gn,P as Cs,ac as ma,cG as Zn,cH as ua,cI as ha,h as es,m as ks,cJ as Ss,a9 as pa,aw as Us,as as ts,t as fa,ag as ga,ah as Tt,ai as Nn,ap as Na,al as ya,cK as va,cL as xa,cM as ba,cN as ja,cO as wa,az as Ia,cP as Ca,co as ka,cQ as Sa,a7 as Ua,aF as Pa,cR as ns}from"./index-BVpny5eT.js";import{a as gt,c as $a,b as Ta,t as Ea,d as Jt,e as ss,f as as,C as rs,g as Aa,D as Ra,I as Ma}from"./DrawerExpandCaret-Bwq1QXMJ.js";import{i as La,a as Da,g as Oa}from"./accounts-Dp-x2CHJ.js";import{O as _a,b as Fa,a as Ba}from"./OfferIntroModal-ZNidNxrZ.js";import{u as qa}from"./use-resolved-title-company-D550X39m.js";import{a as Ps,P as Wa}from"./ProfileNameTrigger-BwlTTwP1.js";import{d as Ga,I as Ha,e as za}from"./InviteContactModal-1V0C4a3t.js";import{F as Et,A as Ya,a as Va}from"./AddAccountsModal-DJodSIDG.js";import{c as Zr,l as eo,p as to}from"./AddAccountsModal-DJodSIDG.js";import{N as Ka}from"./GemAI-D96-3JBK.js";import{q as Ja,s as Qa,t as Xa,u as Za,v as bn,w as er}from"./home-checkin-people-DWmgmAZd.js";import"./index-CryiGmSX.js";import"./Combination-Dr9KM_H-.js";import"./index-u7baw35J.js";import"./chevron-right-boUotD-7.js";import"./external-link-D8whGH5x.js";import"./IntegrationsModal-CmDwjz79.js";function os(t){return(t||"").trim().toLowerCase().replace(/[.,]+/g," ").replace(/\s+/g," ")}function tr(t,r){const n=os(t),d=os(r);if(!n||!d)return!1;if(n===d)return!0;const o=n.split(" ").filter(Boolean),c=d.split(" ").filter(Boolean);if(o.length>=2&&c.length>=2){const h=o[0],g=o[o.length-1],x=c[0],C=c[c.length-1];if(g===C&&h.charAt(0)===x.charAt(0))return!0}return!1}function $s(t){if(t.offer)return t.offer;const r=t._memberAccounts;if(!(r!=null&&r.length))return null;for(const n of r)if(n.isMine===!1&&n.offer)return n.offer;for(const n of r)if(n.offer)return n.offer;return null}function Nt(t,r){if(!t)return!1;const n=t.contactUserId,d=r.contactUserId;return n!=null&&n>0&&d!=null&&d>0?n===d:tr(t.contactName,r.name)}function nr(t){const r=(t._memberAccounts??[]).filter(n=>n.isMine===!1);return r.length?r:t.isMine===!1?[t]:[]}function sr(t,r,n){var d;if(!Nt(t,r))return{label:"Offer intro",disabled:!1};if((t==null?void 0:t.status)==="accepted")return{label:"Request intro",disabled:!1};if((t==null?void 0:t.status)==="requested"){const o=(d=t.contactName)==null?void 0:d.trim();return{label:`Intro sent${o?` · ${n.firstName(o)||o}`:""}`,disabled:!0}}return(t==null?void 0:t.status)==="offered"?{label:`Offered · ${n.relativeAgo(t.createdAt)}`,disabled:!0}:{label:"Offer intro",disabled:!1}}function ar(t,r,n,d,o=[],c){const h=nr(t);if(!h.length||!(!!n||o.length>0||!!(c!=null&&c.length)))return null;const x=h[0],C=$s(x);return{teammateAccount:x,offer:C,action:sr(C,r,d)}}const rr=["CO-INVESTOR","INVESTOR","LP TARGET","FOUNDER TO BACK","PORTFOLIO","CUSTOMER"],or={"CO-INVESTOR":{color:"#3C3489",bg:"#ece9fb"},INVESTOR:{color:"#0F6E56",bg:"#E1F5EE"},"LP TARGET":{color:"#9b2335",bg:"#fce8eb"},"FOUNDER TO BACK":{color:"#8a5a10",bg:"#faeeda"},PORTFOLIO:{color:"#1a5276",bg:"#e8f4fc"},CUSTOMER:{color:"#5c4033",bg:"#f5ebe0"}};function Qt(t){const r=t.trim().toUpperCase(),n=or[r];return n?{label:r,...n}:{label:r,color:"#3a3a3a",bg:"#f0ece0"}}function Xt(t){const r=new Set,n=[];for(const d of t){const o=String(d??"").trim().toUpperCase();!o||r.has(o)||(r.add(o),n.push(o))}return n.slice(0,10)}function ir(t,r){const n=Xt(t),d=Xt(r);return n.length===d.length&&n.every((o,c)=>o===d[c])}function cr(t){const r=t.toLowerCase(),n=["investor","partner","principal","associate","gp","general partner","managing partner","venture partner","founding partner","scout"],d=["founder","ceo","cto","co-founder","cofounder","managing director","chief"];return["lp","endowment","family office","fund of funds","limited partner"].some(c=>r.includes(c))?Qt("LP TARGET"):d.some(c=>r.includes(c))?Qt("FOUNDER TO BACK"):n.some(c=>r.includes(c))?Qt("CO-INVESTOR"):null}function lr(t,r){const n=t.targetRole||r;if(!n)return[];const d=cr(n);return d?[d.label]:[n.trim().toUpperCase()]}function at(t){if(t==null)return[];if(Array.isArray(t))return t.map(r=>
1String(r??"").trim()).filter(Boolean);if(typeof t=="string"){const r=t.trim();if(!r)return[];try{const n=JSON.parse(r);if(Array.isArray(n))return at(n)}catch{}return[r]}return[]}function is(t){return t.accountTags!=null?Xt(at(t.accountTags)):lr(t)}function yn({values:t,onChange:r,placeholder:n,disabled:d,normalizeValue:o}){const c=Array.isArray(t)?t:at(t),[h,g]=m.useState(""),x=()=>{const N=o?o(h):h.trim();if(!N)return;(o?c.some(S=>S.toUpperCase()===N.toUpperCase()):c.includes(N))||r([...c,N]),g("")},C=N=>{(N.key==="Enter"||N.key===",")&&h.trim()?(N.preventDefault(),x()):N.key==="Backspace"&&h===""&&c.length&&r(c.slice(0,-1))},v=h.trim().length>0;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"icp-input-row",onClick:N=>{const I=N.currentTarget.querySelector("input.icp-chip-input");I==null||I.focus()},children:[c.map((N,I)=>e.jsxs("span",{className:"icp-chip",children:[N,e.jsx("button",{type:"button",className:"icp-chip-x",onClick:S=>{S.stopPropagation(),r(c.filter((R,H)=>H!==I))},disabled:d,"aria-label":`Remove ${N}`,children:"Ã"})]},`${N}-${I}`)),e.jsx("input",{type:"text",className:"icp-chip-input",placeholder:n,value:h,onChange:N=>g(N.target.value),onKeyDown:C,onBlur:x,disabled:d}),v?e.jsx("button",{type:"button",className:"icp-chip-add",onMouseDown:N=>{N.preventDefault(),x()},disabled:d,"aria-label":"Add tag",children:"+ Add"}):null]}),e.jsx("div",{className:`icp-chip-hint${v?" active":""}`,children:v?e.jsxs(e.Fragment,{children:["Press ",e.jsx("kbd",{children:"Enter"})," to add ",e.jsxs("strong",{children:['"',h.trim(),'"']})]}):e.jsxs(e.Fragment,{children:["Tip: type a tag and press ",e.jsx("kbd",{children:"Enter"})," to add it."]})})]})}const vn={width:"100%",padding:"8px 10px",borderRadius:9,border:"1px solid #e0dbd0",fontFamily:"inherit",fontSize:13,boxSizing:"border-box",background:"#faf8f4",color:"#1a1a1a",outline:"none"};function dr({open:t,onClose:r,account:n,defaultIcp:d,onSaved:o}){const{user:c}=js(),h=(c==null?void 0:c.accessToken)||"",g=(c==null?void 0:c.userId)||0,[x,C]=m.useState(""),[v,N]=m.useState(""),[I,S]=m.useState(""),[R,H]=m.useState(""),[Z,oe]=m.useState([]),[z,P]=m.useState([]),V=m.useRef(null),ee=m.useRef(null),[ge,U]=m.useState([]),[q,pe]=m.useState(""),[Ae,Re]=m.useState([]),[Me,Ie]=m.useState([]),[_,Ue]=m.useState(!1),[Ne,ye]=m.useState(null);if(m.useEffect(()=>{if(!t||!n)return;C(n.companyName??""),N(n.companyUrl??""),S(n.targetContactName??""),H(n.targetRole??"");const A=Array.isArray(n.intents)&&n.intents.length?n.intents.map(de=>de.name).filter(Boolean):n.targetContactName?[n.targetContactName]:[];oe(A),P(is(n));const se=n.icp??null;se?(U(at(se.persona)),pe(typeof se.notes=="string"?se.notes:""),Re(at(se.firmo)),Ie(at(se.signal))):(U([]),pe(""),Re([]),Ie([])),Ue(!1),ye(null)},[t,n]),!t||!n)return null;const qe=()=>{_||r()},rt=async()=>{var A,se;if(!h||!g){ye("Please sign in again.");return}Ue(!0),ye(null);try{const de=(A=V.current)==null?void 0:A.querySelector("input.icp-chip-input"),ve=((de==null?void 0:de.value)||"").trim(),_e=(ve&&!Z.includes(ve)?[...Z,ve]:Z).map(ae=>ae.trim()).filter(Boolean),te=(Array.isArray(n.intents)&&n.intents.length?n.intents.map(ae=>ae.name):n.targetContactName?[n.targetContactName]:[]).map(ae=>ae.trim()).filter(Boolean),W=_e.length===te.length&&_e.every((ae,We)=>ae===te[We]),Ce=(se=ee.current)==null?void 0:se.querySelector("input.icp-chip-input"),xe=((Ce==null?void 0:Ce.value)||"").trim(),Q=xe&&!z.some(ae=>ae.toUpperCase()===xe.toUpperCase())?[...z,xe]:z,ne=Xt(at(Q)),ot=is(n),ie=!ir(ne,ot),B=x!==(n.companyName??"")||(v.trim()||null)!==(n.companyUrl??null)||(n.targetContactName??null)!==null||(n.targetRole??null)!==null||!W||ie;let Pe;if(B){const ae=await ws(h,g,n.id,{companyName:x,companyUrl:v.trim()||null,contactName:null,targetRole:null,intents:_e.map(We=>({name:We})),accountTags:ne});Pe={...ae,accountTags:ae.accountTags??ne}}const fe=await Jn(h,g,n.id,{firmo:Ae,persona:ge,signal:Me,notes:q.trim()});o==null||o(n.id,fe.icp,Pe),r()}catch(de){ye(de instanceof Error?de.message:"Failed to save")}finally{Ue(!1)}},Xe=async()=>{if(!(!h||!g||_)){Ue(!0),ye(null);try{const A=await Jn(h,g,n.id,null);o==null||o(n.id,A.icp),r()}catch(A){ye(A instanceof Error?A.message:"Failed to reset account ICP")}finally{Ue(!1)}}},Ze=!!n.icp;return e.jsx("div",{className:"modal-overlay open request-intro-portal",onClick:qe,children:e.jsxs("div",{className:"modal",onClick:A=>A.stopPropagation(),children:[e.jsxs("div",{className:"modal-head",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"mod-title",children:["Edit ",n.companyName]}),e.jsx("div",{className:"mod-sub",children:"Update account details and customize the ICP for this company."})]}),e.jsx("button",{className:"mod-close",onClick:qe,"aria-label":"Close",children:"Ã"})]}),e.jsxs("div",{className:"modal-body",style:{maxHeight:"65vh",overflowY:"auto"},children:[e.jsxs("div",{className:"icp-edit-section",children:[e.jsx("div",{className:"icp-edit-lbl",children:"Company name"}),e.jsx("input",{type:"text",value:x,onChange:A=>C(A.target.value),placeholder:"e.g. Acme Corp",disabled:_,style:vn})]}),e.jsxs("div",{className:"icp-edit-section",children:[e.jsx("div",{className:"icp-edit-lbl",children:"Website URL"}),e.jsx("div",{className:"icp-edit-help",children:"Used to anchor the web-search fallback â when no one in your network matches, we search Gemini for people at this exact domain so results are deterministic. Optional but recommended."}
1),e.jsx("input",{type:"url",value:v,onChange:A=>N(A.target.value),placeholder:"e.g. https://acme.com",disabled:_,style:vn})]}),e.jsxs("div",{className:"icp-edit-section",ref:V,children:[e.jsx("div",{className:"icp-edit-lbl",children:"People"}),e.jsx("div",{className:"icp-edit-help",children:"Specific names you want to reach at this account. Each one is deterministically resolved against your network first; if no warm path exists, we'll surface them from the web."}),e.jsx(yn,{values:Z,onChange:oe,placeholder:"Add a name (e.g. Jane Smith)â¦",disabled:_})]}),e.jsxs("div",{className:"icp-edit-section",ref:ee,children:[e.jsx("div",{className:"icp-edit-lbl",children:"Account tags"}),e.jsx("div",{className:"icp-edit-help",children:"Labels like CO-INVESTOR or INVESTOR shown on this row. Add, remove, or customize â type a tag and press Enter, or pick a preset below."}),e.jsx(yn,{values:z,onChange:P,placeholder:"Add a tag (e.g. CO-INVESTOR, INVESTOR)â¦",disabled:_,normalizeValue:A=>A.trim().toUpperCase()}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6,marginTop:8},children:rr.map(A=>{const se=Qt(A),de=z.some(ve=>ve.toUpperCase()===A);return e.jsx("button",{type:"button",disabled:_,onClick:()=>{P(de?z.filter(ve=>ve.toUpperCase()!==A):[...z,A])},style:{fontSize:9.5,fontWeight:700,letterSpacing:"0.06em",color:se.color,background:se.bg,padding:"4px 10px",borderRadius:20,border:de?`2px solid ${se.color}`:"2px solid transparent",cursor:_?"default":"pointer",opacity:_?.6:1},children:A},A)})})]}),e.jsxs("div",{className:"icp-edit-section",style:{marginTop:8},children:[e.jsx("div",{className:"icp-edit-lbl",children:"Roles"}),e.jsx("div",{className:"icp-edit-help",children:"Roles or personas to find at this account (e.g. Partner, Head of Eng). We search your network for each role; if no warm path matches a given role, we run one web search for it."}),e.jsx(yn,{values:ge,onChange:U,placeholder:"Add a role (e.g. Partner, Head of Eng)â¦",disabled:_})]}),e.jsxs("div",{className:"icp-edit-section",children:[e.jsx("div",{className:"icp-edit-lbl",children:"Notes (optional)"}),e.jsx("div",{className:"icp-edit-help",children:"Anything specific to this account â relationship history, why this is a fit, what to lead with."}),e.jsx("textarea",{value:q,onChange:A=>pe(A.target.value),placeholder:"e.g. Met their VP of Data at Saastr 2025 â pre-disposed to our stack.",disabled:_,rows:3,style:{...vn,resize:"vertical"}})]}),Ne?e.jsx("div",{className:"portco-error",children:Ne}):null]}),e.jsxs("div",{className:"modal-foot",style:{justifyContent:"space-between",alignItems:"center"},children:[e.jsx("button",{className:"btn-foot",onClick:Xe,disabled:_||!Ze,title:Ze?"Clear this account's override and use your main ICP":"This account is already using your main ICP",style:{flex:"0 0 auto",padding:"11px 18px"},children:"Use my main ICP"}),e.jsxs("div",{style:{display:"flex",gap:8,flex:"0 0 auto"},children:[e.jsx("button",{className:"btn-foot",onClick:qe,disabled:_,style:{flex:"0 0 auto",padding:"11px 22px"},children:"Cancel"}),e.jsx("button",{className:"btn-foot primary",onClick:rt,disabled:_,style:{flex:"0 0 auto",padding:"11px 28px"},children:_?"Savingâ¦":"Save"})]})]})]})})}const cs=!1,mr=new Set(["portfolio","default","onboarding"]);function ls(t){return!mr.has(String(t.source||"").trim().toLowerCase())}function ds(t){return(t.contacts||[]).filter(r=>r.pct!=null&&r.pct>0).length}function ur(t){var r,n;return t.contactUserId&&t.contactUserId>0?`user:${t.contactUserId}`:(r=t.contactEmail)!=null&&r.trim()?`email:${t.contactEmail.trim().toLowerCase()}`:(n=t.linkedinUrl)!=null&&n.trim()?`linkedin:${t.linkedinUrl.trim().toLowerCase().replace(/\/+$/,"")}`:`name:${t.name.trim().toLowerCase()}|${t.companyName.trim().toLowerCase()}`}function hr(t){const r=new Map;for(const n of t){const d=ur(n),o=r.get(d);if(!o){r.set(d,n);continue}const c=[{pct:o.pct,source:o.source,viaUserId:o.viaUserId,viaName:o.viaName,warmthTier:o.warmthTier},...o.altPaths||[]],h=[{pct:n.pct,source:n.source,viaUserId:n.viaUserId,viaName:n.viaName,warmthTier:n.warmthTier},...n.altPaths||[]],g=new Map;
1for(const v of[...c,...h]){const N=`${v.viaUserId||0}|${(v.viaName||"").toLowerCase()}|${v.source}`,I=g.get(N);(!I||(v.pct??-1)>(I.pct??-1))&&g.set(N,v)}const x=(n.pct??-1)>(o.pct??-1)?{...o,...n}:{...n,...o},C=`${x.viaUserId||0}|${(x.viaName||"").toLowerCase()}|${x.source}`;g.delete(C),r.set(d,{...x,altPaths:[...g.values()]})}return[...r.values()]}function Oe(t){return t&&t.trim().split(/\s+/)[0]||""}function ms(t){const r=(t||"").trim().replace(/^[\u2014\u2013-]\s*(\u00b7\s*)?/,"").trim();return r==="â"||r==="â"||r==="-"?"":r}function Je(t){return t!=null&&t.trim()?t.trim().split(/\s+/).map(r=>r&&r.charAt(0).toUpperCase()+r.slice(1).toLowerCase()).join(" "):""}function jn(t,r,n){if(!(t!=null&&t.length))return null;if(r){const d=t.find(o=>o.userId===r);if(d)return d}if(n){const d=n.trim().toLowerCase(),o=t.find(c=>{const h=(c.fullname||"").trim().toLowerCase(),g=Oe(c.fullname).toLowerCase();return h===d||g===d||h.startsWith(`${d} `)});if(o)return o}return null}function ft(t,r,n,d,o){return er(t,r,d)}function xn(t,r){return Za(t.contacts,r)}function us(t){return t.kind!=="company"?!1:t.source==="role"?!0:!!(t.targetRole&&t.companyName&&t.targetRole.trim().toLowerCase()===t.companyName.trim().toLowerCase())}function pr(t){if(!t)return"just now";const r=new Date(t).getTime();if(!Number.isFinite(r))return"just now";const n=Math.max(1,Math.floor((Date.now()-r)/1e3));return n<60?"just now":n<3600?`${Math.floor(n/60)}m`:n<86400?`${Math.floor(n/3600)}h`:`${Math.floor(n/86400)}d`}const fr={firstName:Oe,relativeAgo:pr};function Yt(t,r,n,d=[],o){return ar(t,r,n,fr,d,o)}function gr(t){return{id:t.id,companyName:t.companyName,source:t.source,targetRole:t.targetRole??null}}function hs({contact:t,directSynth:r,teammateIntroCtx:n,onMessage:d,onTeamTargetIntro:o,onTeamTargetRequestAfterAccept:c}){const h=Je(t.name),g=Oe(t.name)||h;if(n){const{teammateAccount:x,offer:C,action:v}=n,N=At(x),I=()=>{(C==null?void 0:C.status)==="accepted"&&Nt(C,r)?c(x,r,C):o(x,r)};return e.jsxs("div",{className:"contact-direct-panel",children:[e.jsxs("span",{className:"contact-direct-msg",children:["You're connected to ",h," â offer an intro to ",N," or message them directly."]}),e.jsxs("div",{className:"contact-direct-actions",children:[e.jsx("button",{type:"button",className:"contact-direct-btn",disabled:v.disabled,onClick:S=>{S.stopPropagation(),I()},children:v.label}),e.jsxs("button",{type:"button",className:"contact-direct-btn contact-direct-btn--secondary",onClick:S=>{S.stopPropagation(),d()},children:["Message ",g]})]})]})}return e.jsxs("div",{className:"contact-direct-panel",children:[e.jsxs("span",{className:"contact-direct-msg",children:["You're connected to ",h," â no intro needed."]}),e.jsxs("button",{type:"button",className:"contact-direct-btn",onClick:x=>{x.stopPropagation(),d()},children:["Message ",g]})]})}function Mt(t){return(t||"?").split(" ").map(r=>r[0]).filter(Boolean).slice(0,2).join("").toUpperCase()||"?"}function ps({contacts:t,pathCount:r}){const n=t.filter(o=>{var c;return(c=o.name)==null?void 0:c.trim()}).slice(0,4);if(r===0&&n.length===0)return e.jsx("div",{className:"acc-row-stack acc-row-stack--empty","aria-hidden":!0});const d=n.length>0?n:[{name:"?"}];return e.jsxs("div",{className:"acc-row-stack",children:[e.jsx("div",{className:"acc-stack-avatars",children:d.map((o,c)=>e.jsx("div",{className:"acc-stack-av",style:{zIndex:9-c,marginLeft:c===0?0:-9},children:Mt(o.name)},`stack-${o.name}-${c}`))}),r>0?e.jsxs("span",{className:"acc-stack-count",children:[r," path",r===1?"":"s"]}):null]})}function Nr({pct:t}){const r=t>=90?4:t>=65?3:t>=45?2:t>0?1:0;return e.jsx("span",{className:"warmth-meter","aria-hidden":"true",children:[0,1,2,3].map(n=>e.jsx("span",{className:`warmth-seg${n<r?" on":""}`},n))})}const yr=["zero","one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen","twenty"];function fs(t){return yr[t]??String(t)}function gs(t){return t&&t.charAt(0).toUpperCase()+t.slice(1)}function Ts(t,r){return r&&t.contacts.length>0?t.contacts.length:t.contactCount>0?t.contactCount:t.contacts.filter(n=>n.pct!=null&&n.pct>0).length}function vr(t,r){const n=[],d=r??Ts(t,t.contacts.length>0);return d>0&&n.push(`${d} contact${d!==1?"s":""}
1`),t.industry?n.push(t.industry):t.isF500&&n.push("F500"),n.join(" · ")}function At(t){var n,d;const r=t;return(n=r._owners)!=null&&n.length?r._owners.map(o=>o.name).join(", "):t.isMine!==!1?"You":((d=t.ownerName)==null?void 0:d.trim())||"Teammate"}function xr(t){var d;const r=o=>(o||"").trim().split(/\s+/)[0]||"",n=t;return(d=n._owners)!=null&&d.length?`added by ${n._owners.map(c=>c.isMine?"you":r(c.name)||"a teammate").join(", ")}`:t.isMine!==!1?"added by you":`added by ${r(t.ownerName)||"a teammate"}`}function br(t){if(t.kind!=="company")return null;const r=!t.companyUrl,n=Array.isArray(t.intents)&&t.intents.length>0,d=!!(t.targetRole&&t.targetRole.trim()),o=!!(t.icp&&Array.isArray(t.icp.persona)&&t.icp.persona.length>0),c=!n&&!d&&!o;return!r&&!c?null:{label:r&&c?"Add URL & target":r?"Add website URL":"Add a target",tip:r&&c?"Click Edit to add the company's website and a target person or role â without either, we can't surface suggestions.":r?"Click Edit to add the company's website â anchors web search against the real team page.":"Click Edit to add a target â a specific person, role, or ICP persona to reach."}}function jr(t,r){if(!t.contactUserId)return!1;const n=d=>({...t,pct:d.pct??t.pct,source:d.source,viaUserId:d.viaUserId,viaName:d.viaName});return r.some(d=>!Qe(n(d)))||r.length===0}function wn(t){return t.source==="direct_gem"||t.viaName==="you"}function Vt(t){return(t.contacts||[]).some(n=>[{pct:n.pct,source:n.source,viaUserId:n.viaUserId,viaName:n.viaName},...n.altPaths||[]].some(wn))?"direct":gt(t)?"hop":"none"}function wr(t,r){const n=Number(r),d=Number(t.viaUserId);return Number.isInteger(n)&&n>0&&Number.isInteger(d)&&d===n}function Ir(t,r){const n=Number(r),d=Number(t.viaUserId);return Number.isInteger(n)&&n>0&&Number.isInteger(d)&&d===n}function Kt(t,r){const n=[{pct:t.pct,source:t.source,viaUserId:t.viaUserId,viaName:t.viaName},...t.altPaths||[]],d=n.find(wn)||null;let o=n.filter(c=>!wn(c)).filter(c=>!wr(c,t.contactUserId)).filter(c=>!Ir(c,r));return d&&(o=[]),{directPath:d,warmPaths:o}}function Cr(t,r,n){const d=g=>({...t,pct:g.pct??t.pct,source:g.source,viaUserId:g.viaUserId,viaName:g.viaName}),o=r.filter(g=>Qe(d(g))),c=new Set(o.map(g=>g.viaUserId).filter(g=>!!g));if(jr(t,r)){if(!n)return null;const g=n.filter(x=>!c.has(x.userId));return o.length+g.length}return r.length}function Ns(t,r,n,d,o){if(t&&r.length>0)return{label:"2 paths",variant:"multi"};if(t)return{label:"Direct",variant:"direct"};const c=n?Cr(n,r,d):r.length;if(c===null)return o?{label:"Checking pathsâ¦",variant:"multi"}:null;if(c>1)return{label:`${c} paths`,variant:"multi"};if(c===1){const h=r[0];if(n&&h&&Qe({...n,pct:h.pct??n.pct,source:h.source,viaUserId:h.viaUserId,viaName:h.viaName})){const g=h.viaName;if(g&&g.toLowerCase()!=="you")return{label:`via ${Je(g)}`,variant:"via"}}return{label:"1 path",variant:"multi"}}return null}function ys({direct:t,warmPaths:r,connectors:n,chip:d}){const o=d?e.jsx("span",{className:`contact-path-count contact-path-count--${d.variant}`,children:d.label}):null;if(t&&r.length>0){const h=r.slice(0,3).map((g,x)=>{const C=jn(n,g.viaUserId,g.viaName),v=(C==null?void 0:C.fullname)||g.viaName||"?";return{key:`${x}-${v}`,initials:Mt(v),primary:!1}});return e.jsxs("div",{className:"contact-row-connectors",children:[e.jsxs("div",{className:"acc-stack-avatars",children:[e.jsx("div",{className:"acc-stack-av acc-stack-av--expanded acc-stack-av--you",children:"YOU"}),h.map((g,x)=>e.jsx("div",{className:"acc-stack-av acc-stack-av--expanded",style:{zIndex:8-x,marginLeft:-9},children:g.initials},g.key))]}),o]})}if(t)return e.jsxs("div",{className:"contact-row-connectors",children:[e.jsx("div",{className:"acc-stack-av acc-stack-av--expanded acc-stack-av--you",children:"YOU"}),o]});const c=r.slice(0,4).map((h,g)=>{const x=jn(n,h.viaUserId,h.viaName),C=(x==null?void 0:x.fullname)||h.viaName||"?";return{key:`${g}-${C}`,initials:Mt(C),primary:g===0}});return c.length?e.jsxs("div",{className:"contact-row-connectors",children:[e.jsx("div",{className:"acc-stack-avatars",children:c.map((h,g)=>e.jsx("div",{className:`acc-stack-av acc-stack-av--expanded${h.primary?" acc-stack-av--primary":""}`,style:{zIndex:9-g,marginLeft:g===0?0:-9},children:h.initials},h.key))}),o]}):e.jsx("div",{className:"contact-row-connectors",children:o})}function vs(t){const r=(t.title||"").trim();return t.role===1&&t.companyName?{title:r,company:t.companyName.trim()}:t.role===2&&t.fundName?{title:r,company:t.fundName.trim()}:{title:r,company:(t.companyName||t.fundName||"").trim()}}function xs({connectorName:t,connectorTitle:r,connectorCompany:n,connectorUserId:d,connectorPhoto:o,pathT
1ier:c,actionLabel:h,onAction:g,onOpenWebContactProfile:x,onOpenInvite:C}){const{openProfile:v}=Is(),{title:N,company:I}=qa(d,r,n),S=e.jsx("div",{className:"intro-path-av",children:Mt(t)});return e.jsxs("div",{className:"intro-path-row",children:[e.jsx(Wa,{userId:d,name:t,photo:o,role:N,companyName:I,className:"profile-popup-trigger intro-path-av-btn",avatarClassName:"intro-path-av",initials:Mt(t),onOpen:v,onOpenWebProfile:x,onOpenInvite:C,children:S}),e.jsx("div",{className:"intro-path-name-col",children:e.jsx(Ps,{userId:d,name:t,photo:o,className:"intro-path-name",role:N,companyName:I,onOpen:v,onOpenWebProfile:x,onOpenInvite:C})}),e.jsx("span",{className:"intro-path-role",children:N}),e.jsx("span",{className:"intro-path-company",children:I}),e.jsxs("div",{className:"intro-path-actions",children:[c?e.jsx(ka,{tier:c,className:"intro-path-tier"}):null,e.jsx("button",{type:"button",className:"intro-path-btn",onClick:g,children:h})]})]})}function Es({contact:t,companyName:r,warmthCtx:n,warmPaths:d,targetConnectors:o,synthForPath:c}){const h=d.filter(N=>Qe(c(N))).sort((N,I)=>{const S=ft(t,n,r,N),R=ft(t,n,r,I);return Zn({tier:S,score:N.pct??void 0},{tier:R,score:I.pct??void 0})}),g=new Set(h.map(N=>N.viaUserId).filter(N=>!!N)),x=!!t.contactUserId&&(d.some(N=>!Qe(c(N)))||d.length===0),C=(o||[]).filter(N=>!g.has(N.userId)).sort((N,I)=>{const S=ft(t,n,r,void 0),R=ft(t,n,r,void 0),H=Zn({tier:S},{tier:R});return H!==0?H:Number(I.isMutual)-Number(N.isMutual)}),v=[];if(h.forEach((N,I)=>{const S=jn(o,N.viaUserId,N.viaName),R=S?vs(S):{title:"",company:""};v.push({key:`specific-${I}`,name:Je((S==null?void 0:S.fullname)||N.viaName||"Connector"),title:R.title,company:R.company,userId:N.viaUserId??(S==null?void 0:S.userId),photo:S==null?void 0:S.profilePhoto,tier:ft(t,n,r,N),synth:c(N)})}),x)for(const N of C){const I=vs(N);v.push({key:`connector-${N.userId}`,name:Je(N.fullname||"Connector"),title:I.title,company:I.company,userId:N.userId,photo:N.profilePhoto,tier:ft(t,n,r,void 0),synth:{...t,source:t.source==="direct_gem"?"gem_at_company":t.source,viaUserId:N.userId,viaName:N.fullname||t.viaName||null},connector:N})}return{candidates:v,needsConnectorList:x,fetchDone:!x||o!==void 0}}function kr(t){return{key:t.key,name:t.name,title:t.title,company:t.company,userId:t.userId,photo:t.photo,strengthLabel:t.tier?Jt(bn(t.tier)):""}}function bs({contact:t,companyName:r,warmthCtx:n,warmPaths:d,targetConnectors:o,connectorLoading:c,connectorError:h,synthForPath:g,onRequestIntro:x,onPickConnector:C,onOpenWebContactProfile:v,onOpenInvite:N,introActionLabel:I,onIntroAction:S,introActionDisabled:R}){const{candidates:H,needsConnectorList:Z,fetchDone:oe}=Es({contact:t,companyName:r,warmthCtx:n,warmPaths:d,targetConnectors:o,synthForPath:g}),z=H.filter(U=>!U.connector),P=H.filter(U=>!!U.connector),V=oe||!!h,ee=I||"Request intro",ge=U=>{S?S(U):x(U)};return e.jsxs("div",{className:"contact-paths-panel",children:[e.jsxs("div",{className:"contact-paths-header",children:["Intro paths to"," ",e.jsx(Ps,{userId:t.contactUserId,name:Je(t.name),photo:t.profilePhoto,linkedinUrl:t.linkedinUrl,companyName:r||t.companyName,role:t.role,onOpenWebProfile:v,onOpenInvite:N})]}),z.map(U=>e.jsx(xs,{connectorName:U.name,connectorTitle:U.title,connectorCompany:U.company,connectorUserId:U.userId,connectorPhoto:U.photo,pathTier:U.tier,actionLabel:ee,onAction:q=>{q.stopPropagation(),!R&&ge(U.synth)},onOpenWebContactProfile:v,onOpenInvite:N},U.key)),Z&&c?e.jsx(Cs,{variant:"section",message:"Searching their Gemphere networkâ¦"}):null,Z&&h&&!c?e.jsx("div",{className:"contact-paths-empty",children:h}):null,!c&&P.map(U=>e.jsx(xs,{connectorName:U.name,connectorTitle:U.title,connectorCompany:U.company,connectorUserId:U.userId,connectorPhoto:U.photo,pathTier:U.tier,actionLabel:ee,onAction:q=>{q.stopPropagation(),!R&&(S?S(U.synth):C(t,U.connector))},onOpenWebContactProfile:v,onOpenInvite:N},U.key)),Z&&V&&!c&&!h&&H.length===0?e.jsx("div",{className:"contact-paths-empty",children:"No connectors found in their Gemphere network yet"}):null,!Z&&z.length===0?e.jsx("div",{className:"contact-paths-empty",children:"No warm path foun
1d yet"}):null]})}async function Rt(t,r){if(!t||!r||r<=0)return null;try{const n=await Oa(r,t),d=(n==null?void 0:n.users)??(n==null?void 0:n.data)??[],o=Array.isArray(d)?d.find(h=>Number(h.id??h.Id)===r):null;return String((o==null?void 0:o.email)??(o==null?void 0:o.Email)??"").trim()||null}catch{return null}}function Qe(t){return!(t.source==="direct_gem"||t.viaName==="you"||!t.viaUserId||!t.viaName||t.viaName.toLowerCase()==="team")}function Sr({viewerFullName:t,viewerFirst:r,viewerEmail:n,account:d,contact:o,askerOverride:c}){const h=o.name,g=o.role||"",x=o.companyName||d.companyName||"",C=Oe(h)||h,v=r||t,N=o.source==="direct_gem"||o.viaName==="you",I=Qe(o);if(c){const P=c.name,V=Oe(P)||P,ee=c.companyName||"",ge=ee?`${P} from ${ee}`:P;if(N){const pe=`Quick intro â ${V} <> ${C}`,Ae=`Hi ${C}, 2 3I'd love to introduce you to ${ge}.${g?` Given your work as ${g}${x?` at ${x}`:""}, `:" "}I think there's a real fit worth exploring. 4 5Happy to make the email intro if you're open to it â just let me know. 6 7${v}`;return{subject1:pe,message1:Ae,subject2:"",message2:""}}if(I){const pe=o.viaName,Ae=t||v,Re=`${v} would like your help reaching ${h||C}`,Me=`Hey ${pe}, 8 9${Ae} is helping out one of their portfolio founders, ${P}, and it looks like you're connected to ${h}${x?` at ${x}`:""}${g?` (${g})`:""}. 10 11Would you be open to a warm intro? Attached below is the email you'd send to ${C} in one click, or you can draft your own. 12 13Thanks either way, 14Gem`,Ie=`Intro: ${P} / ${h}`,_=Sa(ge);return{subject1:Re,message1:Me,subject2:Ie,message2:_}}const U=`Intro: ${P} / ${h}`,q=`Hi ${C}, 15 16I'd like to introduce you to ${ge}. There's strong overlap with what you're working on${x?` at ${x}`:""}, and I thought a brief chat could be worthwhile. 17 18If now isn't a good time, no worries at all. 19 20${v}`;return{subject1:U,message1:q,subject2:"",message2:""}}if(N){const{subject:P,body:V}=za(v,C);return{subject1:P,message1:V,subject2:"",message2:""}}if(!I){const P=`Intro: ${v}${x?` / ${x}`:""}`,V=`Hi ${C}, 21 22I'm ${t||v}.${x?` I'm reaching out about ${x}`:""}${g?` â saw you're a ${g}`:""} and thought a quick chat could be worthwhile. 23 24If the timing isn't right, no worries at all. 25 26${v}`;return{subject1:P,message1:V,subject2:"",message2:""}}const S=Us(o.viaName),R=Ua(h),H=`Would you be open to introducing me to ${R}?`,Z=`Hi ${S}, 27 28Hope you're doing well. I noticed you're connected to ${R} â I'd love an intro if you're open to it. 29 30I've drafted a short blurb below you can forward as-is, or edit however you like. Totally understand if the timing isn't right. 31 32Thanks either way. 33 34${t||"Me"}`,oe=`Intro: ${t||"Me"} â ${R}`,z=Pa(t,n);return{subject1:H,message1:Z,subject2:oe,message2:z}}function Ur({open:t,account:r,contact:n,viewerFullName:d,viewerUserId:o,viewerEmail:c,viewerToken:h,founderUserId:g,connectorUserId:x,markedConnectorUserIds:C,askerOverride:v,onClose:N,onBack:I,onSend:S,sending:R,error:H}){const Z=Oe(d),oe=m.useMemo(()=>!t||!r||!n?null:Sr({viewerFullName:d,viewerFirst:Z,viewerEmail:c,account:r,contact:n,askerOverride:v}),[t,r,n,d,Z,c,v]),[z,P]=m.useState(""),[V,ee]=m.useState(""),[ge,U]=m.useState(""),[q,pe]=m.useState(""),[Ae,Re]=m.useState("double"),[Me,Ie]=m.useState(""),[_,Ue]=m.useState(""),[Ne,ye]=m.useState(""),[qe,rt]=m.useState(null),[Xe,Ze]=m.useState(""),[A,se]=m.useState(""),[de,ve]=m.useState(""),[yt,_e]=m.useState("");if(m.useEffect(()=>{if(!t||!oe)return;P(oe.subject1),ee(oe.message1),U(oe.subject2),pe(oe.message2),Ie(""),Ue(""),ye(((n==null?void 0:n.contactEmail)||"").trim());const T=x||(n!=null&&n.viaUserId&&n.viaUserId>0?n.viaUserId:null)||(v?o:null),ce=T&&T>0&&(C==null?void 0:C.has(T));Re(ce?"single":ua(T?{userId:T}:null,{userIds:C??new Set,contactIds:new Set}))},[t,oe,x,n==null?void 0:n.viaUserId,n==null?void 0:n.contactEmail,v,o,C]),m.useEffect(()=>{if(!t||!h||!o||v||!n)return;const T=n.source==="direct_gem"||n.viaName==="you",ce=n.contactUserId;if(!T||!ce||ce<=0)return;let K=!1;return ha(h,o,{contactUserId:ce}).then(le=>{K||(P(le.defaults.subject),ee(le.defaults.body))}).catch(()=>{}),()=>{K=!0}},[t,h,o,v,n==null?void 0:n.contactUserId,n==null?void 0:n.source,n==null?void 0:n.viaName]),m.useEffect(()=>{if(!t||!h)return;let T=!1;return(async()=>{const ce=await es(h,o,ns());T||(Ze(ce.title),se(ce.company));const K=x||(n!=null&&n.viaUserId&&n.viaUserId>0?n.viaUserId:null)||(v?o:null);if(K&&K>0){const le=await es(h,K,ns());T||(ve(le.title),_e(le.company))}else T||(ve(""),_e(""))})(),()=>{T=!0}},[t,h,o,x,n==null?void 0:n.viaUserId,v]),m.useEffect(()=>{if(!t||!h)return;let T=!1;return(async()=>{const ce=x||(n!=null&&n.viaUserId&&n.viaUserId>0?n.viaUserId:null)||(v?o:null),[K,le]=await Promise.all([Rt(h,ce),Rt(h,g??null)]);T||(K&&Ie(K),le&&Ue(le))})(),()=>{T=!0}},[t,h,x,n==null?void 0:n.viaUserId,v,g,o]),m.useEffect(()=>{if(!t||!h)return;const T=v&&g?g:o;if(!T)return;const ce=v?v.companyName?`${v.name} from ${v.companyName}`:v.name:null;let K=!1;return ks(h,T).then(le=>{if(K)return;const Te=(le||"").trim();Te&&(rt(Te),pe(ke=>v?Ss(ke,ce)?Te:ke:pa(ke,d,c)?Te:ke))}).catch(()=>{}),()=>{K=!0}},[t,h,o,g,v,oe==null?void 0:oe.message2,d,c]),!t||!r||!n)return null;const te=n.source==="direct_gem"||n.viaName==="you",W=Qe(n),Ce=!n.contactUserId||n.contactUserId===0,xe=Ne.trim(),Q=Me.trim(),ne=_.trim(),ot=n.companyName||r.companyName,ie=Oe(n.name)||n.name,B=!!v,Pe=(v==null?void 0:v.name)||"",fe=Oe(Pe)||Pe,ae=(v==null?void 0:v.companyName)||"",We=B&&r.source==="role"&&!!r.targetRole,Ge=te&&!B&&!W,$e=W&&!B&&!te,it=Us(n.viaName||"",Me),ct=R?null:W&&!Q?`Add ${it||n.viaName||"your connector"}'s email before sending.`:W&&Ce&&!xe?`Add ${ie}'s email before sending.`:null,be=[];if(B&&te)be.push(`You're directly connected to ${ie} â fastest possible bridge for ${fe}`);else if(B&&W){be.push(`${n.viaName} can bridge ${fe} to ${ie}`);const T=n.warmthTier?bn(n.warmthTier):"solid";T&&be.push(`<strong>${ts(T)} relationship</strong>`)}else if(te)be.push("Direct connection · fastest possible path");else if(W){be.push(`${n.viaName} is connected to ${ie}`);const T=n.warmthTier?bn(n.warmthTier):"solid";T&&be.push(`<strong>${ts(T)} relationship</strong>`)}else n.source==="imported"&&be.push("Imported contact · known via LinkedIn");return r.aiReason&&be.push(r.aiReason),fa.createPortal(e.jsx("div",{className:"modal-overlay open request-intro-portal",onClick:N,role:"presentation",children:e.jsxs("div",{className:`modal req-modal req-modal--wide${Ge?" req-modal-direct":""}${B?" req-modal-portco":""}`,onClick:T=>T.stopPropagation(),children:[e.jsxs("div",{className:"modal-head",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"req-step-kicker",children:[e.jsx("span",{children:W?"Step 2 of 2 · What Gem sends":"What Gem sends"}),e.jsx("span",{className:"req-step-kicker-note",children:W?"Double opt-in · Nothing sends yet":"Nothing sends yet"})]}),e.jsx("div",{className:"mod-title",children:We?te?`Reach out to ${n.name}.`:`Reach out via ${n.viaName||"your connector"}.`:B?`Offer ${fe||Pe} an intro to ${n.name}.`:te?`Send a message to ${n.name}.`:`Request an intro to ${n.name}.`}),e.jsx("div",{className:"mod-sub",children:We?te?`Message ${ie} about ${fe}'s ${r.targetRole} search${ae?` at ${ae}`:""}. Edit the note below before sending.`:`Ask ${n.viaName||"your connector"} to intro ${n.name} to ${fe} for their ${r.targetRole} search. Edit the email below before sending.`:B&&te?`You're directly connected to ${ie} â message them to put ${fe} in touch.`:B&&W?`Ask ${n.viaName||"your connector"} to bridge ${fe} to ${ie}. You can edit the forwarded blurb.`:te?"You're directly connected â we'll send a message straight to them.":""})]}),e.jsx("button",{className:"mod-close",onClick:N,"aria-label":"Close",children:"Ã"})]}),e.jsxs(ga,{children:[B?e.jsx(Tt,{name:Pe||"Founder",role:r.targetRole||"Founder",company:ae||void 0,badge:"founder",avatarTone:"green",compactName:!1}):e.jsx(Tt,{name:d||"You",role:Xe||void 0,company:A||void 0,badge:"you",badgeLabel:$e?"Asker":void 0,avatarTone:"green",compactName:!1}),B&&te?e.jsxs(e.Fragment,{children:[e.jsx(Nn,{}),e.jsx(Tt,{name:d||"You",role:Xe||void 0,company:A||void 0,kindLabel:"You",badge:"you",badgeLabel:"You",avatarTone:"green",compactName:!1})]}):W?e.jsxs(e.Fragment,{children:[e.jsx(Nn,{}),e.jsx(Tt,{name:n.viaName||"Connector",role:de||void 0,company:yt||void 0,kindLabel:"Connector",badge:"connector",badgeLabel:$e?"Connector":void 0,avatarTone:"green",compactName:!1})]}):null,e.jsx(Nn,{}),e.jsx(Tt,{name:n.name,photo:n.profilePhoto,role:n.role||void 0,company:ot,kindLabel:"Target",badge:"target",badgeLabel:$e?"Target":void 0,avatarTone:"green",compactName:!1})]}),e.jsxs("div",{className:"req-body",children:[!$e&&be.length>0&&e.jsxs("div",{className:"req-reasoning",children:[e.jsx("div",{className:"req-r-lbl",children:te?"Why this works":W?`Why ${n.viaName} is a strong connector`:"Why this path works"}),e.jsx("div",{className:"req-r-txt",dangerouslySetInnerHTML:{__html:be.join(" · ")}})]}),W?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"req-sec-lbl",children:["What Gem sends",e.jsxs("span",{className:"req-sec-note",children:["Two emails. The second only exists if"," ",it||n.viaName||"your connector"," says yes."]})]}),e.jsx(Na,{connectorName:B&&te?d||"You":n.viaName||"your connector",connectorEmail:Q||null,...$e&&Q?{}:{onConnectorEmailChange:Ie},askerName:B?Pe||"Founder":d||"Me",askerEmail:B?ne||null:c||null,onAskerEmailChange:B?Ue:void 0,targetName:n.name,targetEmail:xe||null,...$e&&!Ce?{}:{onTargetEmailChange:ye},blurb:q,onBlurbChange:pe,...$e?{}:{connectorSubject:z,connectorCoverMessage:V,onConnectorSubjectChange:P,onConnectorCoverMessageChange:ee},meta:$e?`${c?" - copy sent to you":""}`:c?"Edit delivery addresses and full copy below":void 0,layout:"split",disabled:R})]}):e.jsxs("div",{className:"req-email",children:[Ce?e.jsx("div",{className:"req-email-missing",children:e.jsx(ya,{personName:n.name,value:Ne,onChange:ye,message:`${n.name} isn't on Gemphere â add their email below.`})}):null,e.jsxs("div",{className:"req-email-head",children:[e.jsx("div",{children:e.jsx("strong",{children:"Email"})}),e.jsx("span",{children:Ce&&xe?`To: ${xe}`:Ce?"Add their email above":Ge?"Sending from [email protected] on your behalf":"Sent from you"})]}),e.jsx("div",{className:"req-email-label",children:"Subject"}),e.jsx("input",{className:"req-email-subject",type:"text",value:z,onChange:T=>P(T.target.value),disabled:R}),e.jsx("div",{className:"req-email-label",children:"Message"}),e.jsx("textarea",{className:"req-email-textarea",value:V,onChange:T=>ee(T.target.value),disabled:R}),Ge&&e.jsxs("div",{style:{fontSize:13,color:"#2a2820",marginTop:12,lineHeight:1.55},children:[e.jsx("div",{children:"Best,"}),e.jsx("div",{style:{fontWeight:600},children:"Gem"}),d?e.jsxs("div",{style:{fontSize:12,color:"#9a8a70",marginTop:2},children:["Ecosystem analyst to ",d]}):null]})]}),W&&!Ge&&!$e?e.jsx(va,{mode:Ae,onChange:Re,disabled:R,compact:!0}):null,H&&e.jsx("div",{className:"req-error",children:H})]}),e.jsxs("div",{className:"modal-foot req-modal-foot--steps",children:[e.jsx("button",{className:"btn-foot primary",disabled:R||W&&!Q||W&&Ce&&!xe,onClick:()=>S({account:r,contact:n,subject1:z,message1:V,subject2:ge,message2:q,targetEmail:xe,connectorEmail:Q,founderEmail:ne,optInMode:Ae}),children:R?"Sendingâ¦":W?`Send to ${it||n.viaName||"connector"}`:te&&!B?`Send message to ${ie}`:`Send email to ${ie}`}),ct?e.jsx("span",{className:"intro-foot-warning",role:"status",children:ct}
34):null,I?e.jsx("button",{type:"button",className:"btn-foot req-foot-back",onClick:I,disabled:R,children:"â Back"}):null,W&&!ct?e.jsxs("span",{className:"req-foot-note",children:[Je(n.name)," hears nothing until"," ",it||n.viaName||"your connector"," accepts."]}):null,e.jsx("button",{className:"btn-foot req-foot-cancel",onClick:N,disabled:R,children:"Cancel"})]})]})}),document.body)}async function Pr(t,r,n={}){const d=(n.note||"").trim(),o={email:r,...n.name?{name:n.name}:{},...n.resend?{resend:!0}:{},...d?{note:d}:{}},c=await La(o,t);if(!c.ok){let h=`Failed to send invite (${c.status})`;try{const g=await c.json();typeof(g==null?void 0:g.message)=="string"?h=g.message:typeof(g==null?void 0:g.error)=="string"&&(h=g.error)}catch{}throw new Error(h)}}function $r(){const[t,r]=m.useState(()=>typeof window>"u"?!1:window.matchMedia("(max-width: 900px)").matches);return m.useEffect(()=>{const n=window.matchMedia("(max-width: 900px)"),d=()=>r(n.matches);return n.addEventListener("change",d),r(n.matches),()=>n.removeEventListener("change",d)},[]),t}const Tr=4e3,Er=30;function Jr(){const{user:t}=js();ea();const{openUpgrade:r,needsUpgrade:n}=ta(),{openProfile:d}=Is();na();const o=t==null?void 0:t.accessToken,c=(t==null?void 0:t.userId)??0,h=(t==null?void 0:t.fullName)||"",[g,x]=m.useState(null),[C,v]=m.useState(null),[N,I]=m.useState([]),[S,R]=m.useState(!0),[H,Z]=m.useState(null),[oe,z]=m.useState(new Set),[P,V]=m.useState(new Set);sa(!S);const[ee,ge]=m.useState({}),U=$r(),[q,pe]=m.useState(null),[Ae,Re]=m.useState({}),[Me,Ie]=m.useState({}),[_,Ue]=m.useState({}),[Ne,ye]=m.useState({}),[qe,rt]=m.useState({}),[Xe,Ze]=m.useState({}),[A,se]=m.useState({}),[de,ve]=m.useState({}),[yt,_e]=m.useState({}),[te,W]=m.useState(Qn),[Ce,xe]=m.useState(new Set),[Q]=m.useState("all"),[ne,ot]=m.useState("all"),[ie,B]=m.useState(!1),Pe=m.useRef(null),[fe,ae]=m.useState(""),[We,Ge]=m.useState(!1),[$e,it]=m.useState({firmo:[],persona:[],signal:[]}),[ct,be]=m.useState(!1),[T,ce]=m.useState(null),[K,le]=m.useState(null);m.useEffect(()=>{if(!K)return;const a=document.body.style.overflow;document.body.style.overflow="hidden";const s=i=>{i.key==="Escape"&&le(null)};return window.addEventListener("keydown",s),()=>{document.body.style.overflow=a,window.removeEventListener("keydown",s)}},[K]);const[Te,ke]=m.useState(null),[lt,In]=m.useState(!1),[M,vt]=m.useState(null),[Cn,kn]=m.useState(!1),[Sn,Un]=m.useState(null),Zt=m.useMemo(()=>N.filter(ls).length,[N]),Pn=m.useCallback(()=>{Ge(!0)},[]),[As,et]=m.useState(!1),[Rs,en]=m.useState(null),[xt,tn]=m.useState(null),[Le,nn]=m.useState(null),[sn,an]=m.useState(null),[Lt,$n]=m.useState(null),[Dt,Tn]=m.useState(null),[rn,En]=m.useState(!1),[Ms,bt]=m.useState(null),[An,jt]=m.useState(null),[tt,on]=m.useState(null),[Ot,_t]=m.useState(""),[cn,Rn]=m.useState(""),[Mn,Ln]=m.useState(!1),dt=m.useCallback(a=>{jt({name:a.name||"",fullname:a.name||"",title:a.title||"",companyName:a.companyName||"",linkedinUrl:a.linkedinUrl||null,isNonGem:!0,source:a.linkedinUrl?"linkedin":"import"})},[]);m.useCallback((a,s)=>{const i=a.contactUserId&&a.contactUserId>0?a.contactUserId:null;if(i){d(i,{name:a.name,photo:a.profilePhoto??null});return}dt({name:a.name,title:a.role,companyName:s||a.companyName,linkedinUrl:a.linkedinUrl})},[d,dt]);const G=a=>{Un(a),setTimeout(()=>Un(null),3e3)},wt=m.useCallback((a,s)=>{Rn(Ga(h||"You")),_t((s||"").trim()),on({name:(a||"").trim()||"This contact",email:(s||"").trim()})},[h]),Ls=m.useCallback(async()=>{if(!o||!tt)return;const a=Ot.trim();if(a){Ln(!0);try{await Pr(o,a,{name:tt.name,note:cn}),on(null),_t(""),G(`Invite sent to ${a}.`)}catch(s){G(s instanceof Error?s.message:"Failed to send invite")}finally{Ln(!1)}}},[o,tt,Ot,cn]),Dn=m.useCallback(a=>
34{if(!a.length)return;const s=a.filter(l=>!l.pending),i=new Map(s.map(l=>[l.id,l]));I(l=>{if(!l.length)return a;const f=new Set,u=l.map(p=>{const j=i.get(p.id);return f.add(p.id),j??p});for(const p of a)f.has(p.id)||u.push(p);return u}),V(l=>{const f=new Set(l);for(const u of s)f.add(u.id);return f}),z(l=>{const f=new Set(l);for(const u of s)f.add(u.id);return f})},[]),ln=m.useRef(!1),It=m.useCallback(async()=>{if(!(!o||!c)&&!ln.current){ln.current=!0;try{for(let a=0;a<Er;a++){const{accounts:s,pendingAccountIds:i}=await aa(o,c);if(Dn(s),!i.length)return;await new Promise(l=>setTimeout(l,Tr))}}catch(a){console.warn("[Accounts] batch warm-path hydrate failed:",a)}finally{ln.current=!1}}},[o,c,Dn]),On=m.useCallback(async()=>{var i,l,f;if(!o||!c)return;const a=Xn(`target-accounts-list:${c}`),s=Xn(`target-accounts-list-only:${c}`);if((i=a==null?void 0:a.accounts)!=null&&i.length){I(a.accounts),V(new Set(a.accounts.map(u=>u.id))),z(new Set(a.accounts.map(u=>u.id))),R(!1),Z(null),hn(o,c).then(({accounts:u})=>{I(p=>{const j=new Map(p.map($=>[$.id,$]));return u.map($=>j.get($.id)??$)})}).catch(()=>{}),It();return}(l=s==null?void 0:s.accounts)!=null&&l.length?(I(s.accounts),R(!1),Z(null)):(R(!0),Z(null)),It();try{const{accounts:u}=await hn(o,c);I(p=>{const j=new Map(p.map($=>[$.id,$]));return u.map($=>{const E=j.get($.id);return E?{...$,contacts:E.contacts,contactCount:E.contactCount,bestPathPct:E.bestPathPct,bestPathVia:E.bestPathVia,pathLabel:E.pathLabel,pathStroke:E.pathStroke,person:E.person??$.person}:$})})}catch(u){(f=s==null?void 0:s.accounts)!=null&&f.length||Z(u instanceof Error?u.message:"Failed to load accounts")}finally{R(!1)}},[o,c,It]),Ds=m.useCallback(async()=>{if(!(!o||!c)){pn(c);try{const{accounts:a}=await hn(o,c);I(s=>{const i=new Map(s.map(l=>[l.id,l]));return a.map(l=>{const f=i.get(l.id);return f?{...l,contacts:f.contacts,contactCount:f.contactCount,bestPathPct:f.bestPathPct,bestPathVia:f.bestPathVia,pathLabel:f.pathLabel,pathStroke:f.pathStroke,person:f.person??l.person}:l})})}catch{}It()}},[o,c,It]);m.useEffect(()=>{On()},[On]),m.useEffect(()=>{if(!o)return;let a=!1;return ra(o).then(s=>{a||it(s||{firmo:[],persona:[],signal:[]})}).catch(()=>{}),()=>{a=!0}},[o]),m.useEffect(()=>{if(!o||!c)return;let a=!1;return Promise.all([oa(o,c),ia(o,c)]).then(([s,i])=>{if(a)return;const l=Ja(s.connections||[],s.contacts||[]);se(s.signalTiersByEmail??{}),W(ca(s.strongRelationships)),ve(l.emailByUserId),_e(l.emailByImportId),Ze(Qa(i));const f=la((s.contacts||[]).map(u=>({id:Number(u.id||0),connectedUserId:Number(u.connectedUserId||u.connected_user_id||0)||null,strengthLabel:u.strengthLabel??u.strength_label})));xe(f.userIds)}).catch(()=>{a||(se({}),W(Qn),ve({}),_e({}),Ze({}),xe(new Set))}),()=>{a=!0}},[o,c]);const me=m.useMemo(()=>({emailSignals:Xe,signalTiersByEmail:A,emailByUserId:de,emailByImportId:yt,strongRelationships:te}),[Xe,A,de,yt,te]),dn=m.useCallback((a,s)=>{if(!o||!c)return;let i=!1;z(l=>{if(l.has(a))return l;i=!0;const f=new Set(l);return f.add(a),f}),i&&fn(o,c,a).then(l=>{const f=()=>{I(u=>u.map(p=>p.id===a?l:p)),V(u=>{const p=new Set(u);return p.add(a),p})};s!=null&&s.urgent?f():m.startTransition(f)}).catch(l=>{z(f=>{const u=new Set(f);return u.delete(a),u}),console.warn("[Accounts] hydrate failed for id="+a,l)})},[o,c]),Ct=a=>{const s=a.id;ge(l=>(!!l[s]&&(Ie(u=>{const p={...u};for(const j of Object.keys(p))j.startsWith(`${s}-`)&&delete p[j];return p}),Re(u=>{if(!u[s])return u;const p={...u};return delete p[s],p})),{...l,[s]:!l[s]}));const i=a._memberAccounts;if(i!=null&&i.length)for(const l of i)dn(l.id,{urgent:!0});else s>0&&dn(s,{urgent:!0})},_n=(a,s,i)=>{i.stopPropagation();const l=!Me[a];Ie(f=>({...f,[a]:!f[a]})),l&&s&&o&&c&&Ft(s)},Ft=m.useCallback(async a=>{if(!(!o||!c||_[a]||Ne[a])){ye(s=>({...s,[a]:!0})),rt(s=>{const i={...s};return delete i[a],i});try{const s=await da(o,a,c);Ue(i=>({...i,[a]:s.connectors}))}catch(s){rt(i=>({...i,[a]:s instanceof Error?s.message:"Failed to load connectors"}))}finally{ye(s=>({...s,[a]:!1}))}}},[o,c,_,Ne]),Os=m.useCallback((a,s)=>{ge(p=>({...p,[a.id]:!0}));const i=a.contacts.filter(p=>p.isPinned),l=a.contacts.filter(p=>!p.isPinned),u=[...i,...l.filter(p=>p.source!=="web"),...l.filter(p=>p.source==="web")].findIndex(p=>s.contactUserId&&p.contactUserId===s.contactUserId||p.name===s.name&&p.role===s.role);if(u>=0){const p=`${a.id}-row-${u}-${u}`;Ie(j=>({...j,[p]:!0}))}s.contactUserId&&Ft(s.contactUserId)},[Ft]),je=m.useMemo(()=>{var l,f,u;
34const a=new Map,s=p=>{const j=xa(p)||p.trim().toLowerCase();let $=a.get(j);return $||($=[],a.set(j,$)),$};for(const p of N)p.kind!=="company"&&p.kind!=="person"||us(p)||!ls(p)||s(p.companyName).push(p);const i=[];for(const p of a.values()){const j=[...p].sort((k,w)=>+(w.isMine!==!1)-+(k.isMine!==!1));if(!j.length)continue;const $=j[0],E=new Map;for(const k of j){const w={userId:k.ownerUserId??null,name:k.isMine!==!1?"You":((l=k.ownerName)==null?void 0:l.trim())||"Teammate",isMine:k.isMine!==!1,source:"team"};E.set(`${w.source}:${w.userId||w.name.toLowerCase()}`,w)}const O=[...E.values()].sort((k,w)=>Number(w.isMine)-Number(k.isMine)||k.name.localeCompare(w.name)),b=hr(j.flatMap(k=>k.contacts||[])),L=b.filter(k=>k.pct!=null).sort((k,w)=>(w.pct??-1)-(k.pct??-1))[0],Y=j.find(k=>k.isMine!==!1),re=Y||$;i.push({...re,kind:"company",person:null,companyName:$.companyName,companyUrl:((f=j.find(k=>k.companyUrl))==null?void 0:f.companyUrl)||null,industry:((u=j.find(k=>k.industry))==null?void 0:u.industry)||null,ownerUserId:O.length===1?O[0].userId:null,ownerName:O.map(k=>k.name).join(", "),isMine:Y?!0:$.isMine,contacts:b,contactCount:b.length,bestPathPct:(L==null?void 0:L.pct)??null,bestPathVia:(L==null?void 0:L.viaName)??null,_memberAccounts:j,_owners:O})}return i},[N]),mt=m.useMemo(()=>N.filter(a=>us(a)),[N]),Se=m.useMemo(()=>{let a=je.length,s=0,i=0,l=0,f=0;for(const u of je){if(!P.has(u.id))continue;const p=ds(u);f+=p,gt(u)?(s++,gn(xn(u,me),"strong")&&i++):l++}return{total:a,withPath:s,strong:i,noPath:l,pathsTotal:f}},[je,P,me]),Bt=m.useMemo(()=>je.reduce((a,s)=>a+(s.contactCount||0),0),[je]),Fn=Se.withPath+Se.noPath,kt=Fn===0?0:Math.round(Se.withPath/Fn*100),Fe=m.useMemo(()=>{const a=fe.trim().toLowerCase();return je.filter(i=>{const l=i._memberAccounts.every(f=>P.has(f.id));return!(ne!=="all"&&!i._owners.some(f=>Number(f.userId)===ne)||Q==="hasPath"&&(!l||!gt(i))||Q==="strong"&&(!l||!gn(xn(i,me),"strong"))||Q==="canIntro"&&(!l||Vt(i)!=="direct")||Q==="oneHop"&&(!l||Vt(i)!=="hop")||Q==="noPath"&&(!l||gt(i))||a&&![i.companyName,i.industry||"",i.bestPathVia||"",...i.contacts.map(u=>`${u.name} ${u.role} ${u.companyName}`)].join(" ").toLowerCase().includes(a))}).sort((i,l)=>$a(i,l,me,P.has(i.id),P.has(l.id)))},[je,Q,ne,fe,P,me]),qt=m.useMemo(()=>{const a=new Map;for(const s of je)for(const i of s._owners){const l=Number(i.userId);if(!Number.isInteger(l)||l<1)continue;const f=a.get(l);f?f.count+=1:a.set(l,{userId:l,name:i.name,isMine:i.isMine,count:1})}for(const s of mt){const i=Number(s.ownerUserId);if(!Number.isInteger(i)||i<1)continue;const l=a.get(i);l?l.count+=1:a.set(i,{userId:i,name:s.ownerName||"Teammate",isMine:s.isMine!==!1,count:1})}return[...a.values()].sort((s,i)=>(i.isMine?1:0)-(s.isMine?1:0)||i.count-s.count)},[je,mt]);m.useEffect(()=>{if(!ie)return;const a=i=>{var l;(l=Pe.current)!=null&&l.contains(i.target)||B(!1)},s=i=>{i.key==="Escape"&&B(!1)};return document.addEventListener("mousedown",a),document.addEventListener("keydown",s),()=>{document.removeEventListener("mousedown",a),document.removeEventListener("keydown",s)}},[ie]);const ut=qt.length>1,Wt=ne==="all"?null:qt.find(a=>a.userId===ne)||null,_s=m.useMemo(()=>[{key:"all",label:null,accounts:Fe}],[Fe]),Bn=Fe.length>0&&Fe.every(a=>!!ee[a.id]),Fs=()=>{for(const a of Fe)!!ee[a.id]===Bn&&Ct(a)},qn=a=>{const s=!!ee[a.id];s||Ct(a),pe({id:a.id,weOpened:!s})},Wn=()=>{const a=q;if(pe(null),!(a!=null&&a.weOpened))return;const s=je.find(i=>i.id===a.id)??mt.find(i=>i.id===a.id);s&&Ct(s)},St=m.useMemo(()=>{const a=fe.trim().toLowerCase();return mt.filter(i=>{const l=P.has(i.id);return!(ne!=="all"&&Number(i.ownerUserId)!==ne||Q==="hasPath"&&(!l||!gt(i))||Q==="strong"&&(!l||!gn(xn(i,me),"strong"))||Q==="canIntro"&&(!l||Vt(i)!=="direct")||Q==="oneHop"&&(!l||Vt(i)!=="hop")||Q==="noPath"&&(!l||gt(i))||a&&![i.targetRole||i.companyName||"",i.industry||"",i.bestPathVia||"",...i.contacts.map(p=>`${p.name} ${p.role} ${p.companyName}`)].join(" ").toLowerCase().includes(a))}).sort((i,l)=>Ta(i,l,me,P.has(i.id),P.has(l.id)))},[mt,Q,ne,fe,P,me]);m.useEffect(()=>{if(!q)return;(!(Fe.some(s=>s.id===q.id)||St.some(s=>s.id===q.id))||!U)&&pe(null)},[q,Fe,St,U]);const Bs=async(a,s=[])=>{if(!o||!c||a.length===0&&s.length===0)return;const i=a.length+s.length;if(n&&Zt+i>Et){G(`Free Starter includes up to ${Et} target accounts. Upgrade to add more.`);return}be(!0);try{const l=Va(a),f=await Da({viewerUserId:c,companies:l,people:s,source:"manual"},o),u=await f.json().catch(()=>({}));if(!f.ok){if((u==null?void 0:u.code)==="free_target_account_limit_exceeded"){G(`Free Starter includes up to ${Et} target accounts. Upgrade to add more.`);return}throw new Error((u==null?void 0:u.error)||(u==null?void 0:u.message)||"Failed to add accounts")}const p=Number(u.added||0);Ge(!1),G(cs?`Added ${p} account${p===1?"":"s"} to your list.`:`Added ${p} account${p===1?"":"s"} · finding warm pathsâ¦`),Ds()}catch(l){G(l instanceof Error?l.message:"Failed to add accounts")}finally{be(!1)}},Ut=async a=>{if(!(!o||!c))try{await ba(o,c,a),I(s=>s.filter(i=>i.id!==a)),G("Account removed")}catch(s){G(s instanceof Error?s.message:"Failed to delete")}},Gn=async()=>
34{if(!Te||!o||!c)return;const a=Te.text.trim();if(a.length<2)return;const s=Te.account.id;In(!0);try{await ws(o,c,s,{companyName:a,targetRole:a}),I(i=>i.map(l=>l.id===s?{...l,companyName:a,targetRole:a,contacts:[],contactCount:0,bestPathPct:null,bestPathVia:null,pathLabel:null,pathStroke:null}:l)),z(i=>{const l=new Set(i);return l.delete(s),l}),V(i=>{const l=new Set(i);return l.delete(s),l}),ke(null),G("Role updated â finding matchesâ¦"),dn(s)}catch(i){G(i instanceof Error?i.message:"Failed to update role")}finally{In(!1)}},qs=(a,s,i)=>{if(I(f=>f.map(u=>u.id===a?{...u,icp:s,_recomputing:!0,...i&&{companyName:i.companyName,companyUrl:i.companyUrl,targetContactName:i.targetContactName,targetRole:i.targetRole,...i.accountTags!==void 0?{accountTags:i.accountTags}:{}}}:u)),V(f=>{const u=new Set(f);return u.delete(a),u}),G(s?"Account saved â recomputing suggestionsâ¦":"Reset to your main ICP â recomputingâ¦"),!o||!c)return;const l=setTimeout(()=>{I(f=>f.map(u=>u.id===a&&u._recomputing?{...u,_recomputing:!1}:u))},6e4);fn(o,c,a,{bypassCache:!0}).then(f=>{clearTimeout(l),I(u=>u.map(p=>p.id===a?{...f,_recomputing:!1}:p)),V(u=>{const p=new Set(u);return p.add(a),p})}).catch(f=>{clearTimeout(l),console.warn("per-account refetch failed:",f),I(u=>u.map(p=>p.id===a?{...p,_recomputing:!1}:p)),G("Saved, but couldn't refresh suggestions â reload the page if needed.")})},Pt=(a,s)=>{var b;if(n){r("accounts");return}if(a.isMine!==!1){He(a,s);return}const i=$s(a),l=Nt(i,s)?i:null;if((l==null?void 0:l.status)==="accepted"){ht(a,s,l);return}if((l==null?void 0:l.status)==="offered"){G(`Waiting on ${At(a)} to respond to your offer.`);return}if((l==null?void 0:l.status)==="requested"){G("Intro request already sent for this contact.");return}if((l==null?void 0:l.status)==="declined"){G(l.declineReason==="already_in_touch"?`${At(a)} is already in touch with this contact.`:`${At(a)} declined this intro offer.`);return}const f=s.source==="direct_gem"||s.viaName==="you",u=((b=a.ownerName)==null?void 0:b.trim())||"Teammate",p=a.ownerUserId??null,j={contactName:s.name,contactRole:s.role||null,contactCompanyName:s.companyName||a.companyName,contactUserId:s.contactUserId??null,contactProfilePhoto:s.profilePhoto??null,contactLinkedin:s.linkedinUrl??null,via:f?"you":s.viaName,viaUserId:f?null:s.viaUserId,pct:s.pct,isDirect:f},$=Fa({founderName:u,investorName:h||"Your teammate",targetName:j.contactName||a.companyName,targetCompany:j.contactCompanyName||a.companyName,targetRole:j.contactRole,pct:j.pct,isDirect:j.isDirect,viaName:j.isDirect?null:j.via,variant:"team_target"}),E=Ba({investorName:h||"Your teammate",investorFirst:Oe(h)||"Your teammate",founderName:u,targetName:j.contactName||a.companyName,targetRole:j.contactRole,targetCompany:j.contactCompanyName||a.companyName,connectorName:j.isDirect?h||"You":j.via||"Connector",variant:"team_target"}),O=u;vt({kind:"team_target",targetAccountId:a.id,target:gr(a),founderName:u,founderCompanyName:null,founderUserId:p,chosen:j,note:"",emailSubject:$.subject,emailMessage:$.message,founderEmail:"",investorEmail:(t==null?void 0:t.email)||"",connectorEmail:j.isDirect&&(t==null?void 0:t.email)||"",targetEmail:"",connectorSubject:E.subject,connectorMessage:E.message,forwardBlurb:E.forwardBlurb}),(async()=>{if(!o)return;const L=j.isDirect?c:j.viaUserId,[Y,re,k,w]=await Promise.all([Rt(o,p),Rt(o,L),Rt(
34o,j.contactUserId),p?ks(o,p):Promise.resolve("")]);vt(F=>{if(!F||F.kind!=="team_target"||F.targetAccountId!==a.id)return F;const we=j.isDirect?(t==null?void 0:t.email)||re||"":re,ze=(w||"").trim(),Ye=ze&&Ss(F.forwardBlurb,O)?ze:F.forwardBlurb;return{...F,founderEmail:Y||F.founderEmail,connectorEmail:we||F.connectorEmail,targetEmail:k||F.targetEmail,investorEmail:F.investorEmail||(t==null?void 0:t.email)||"",forwardBlurb:Ye}})})()},ht=(a,s,i)=>{var u;if(n){r("accounts");return}const l=!i.viaName||i.viaName.toLowerCase()==="you",f={name:i.contactName||s.name||"Target",role:i.contactRole||s.role||"",companyName:i.targetCompanyName||s.companyName||a.companyName,contactUserId:i.contactUserId??s.contactUserId??null,viaName:l?"you":i.viaName||s.viaName||null,viaUserId:l?null:i.viaUserId??s.viaUserId??null,pct:i.pct??s.pct??null,source:l?"direct_gem":"gem_at_company",profilePhoto:s.profilePhoto??null,linkedinUrl:s.linkedinUrl??null};Tn({targetAccountId:a.id,companyName:a.companyName}),nn({name:((u=a.ownerName)==null?void 0:u.trim())||"Teammate",companyName:null}),an(i.ownerUserId??i.founderUserId??a.ownerUserId??null),$n(i.id),en(a),tn(f),bt(null),et(!0)},Ws=async()=>{if(!(!M||!o||!c)){kn(!0);try{const a={targetAccountId:M.target.id,contactName:M.chosen.contactName,contactUserId:M.chosen.contactUserId,contactRole:M.chosen.contactRole,contactLinkedin:M.chosen.contactLinkedin,viaName:M.chosen.via,viaUserId:M.chosen.viaUserId,pct:M.chosen.pct,targetCompanyName:M.chosen.contactCompanyName||M.target.companyName,emailSubject:M.emailSubject.trim(),emailMessage:M.emailMessage.trim(),founderEmail:M.founderEmail.trim()||null,ownerEmail:M.founderEmail.trim()||null,investorEmail:M.investorEmail.trim()||null,connectorEmail:M.connectorEmail.trim()||null,targetEmail:M.targetEmail.trim()||null,connectorSubject:M.connectorSubject.trim()||null,connectorCoverMessage:M.connectorMessage.trim()||null,forwardBlurb:M.forwardBlurb.trim()||null},s=await ja(o,c,M.targetAccountId??M.target.id,a),i=M.targetAccountId??M.target.id;I(l=>l.map(f=>f.id===i?{...f,offer:{...s,offerKind:"team_target"}}:f)),pn(c),s.emailSent===!1&&s.emailError?G(`Offer saved but email to ${M.founderName} failed: ${s.emailError}`):s.emailSent===!1?G(`Offer saved â the heads-up email to ${M.founderName} may not have delivered.`):G(`Offer sent to ${M.founderName} â they'll decide if it goes further.`),vt(null)}catch(a){G(a instanceof Error?a.message:"Failed to send offer")}finally{kn(!1)}}},He=(a,s)=>{const i=s||a.contacts[0]||null;if(!i){G("No contact to intro to yet");return}if(!(i.source==="direct_gem"||i.viaName==="you")&&!Qe(i)&&i.contactUserId){Os(a,i),G(`Choose an intro path under ${Oe(i.name)||i.name}`);return}en(a),tn(i),bt(null),et(!0)},Gs=async({account:a,contact:s,subject1:i,message1:l,subject2:f,message2:u,targetEmail:p,connectorEmail:j,founderEmail:$,optInMode:E})=>{if(!(!o||!c)){En(!0),bt(null);try{const O=s.source==="direct_gem"||s.viaName==="you";if(O&&!Le&&!Dt){const ue=(p||"").trim(),he=s.contactUserId&&s.contactUserId>0?s.contactUserId:0;await wa(o,{...he>0?{toUserID:he}:{},toName:s.name,...ue?{toEmail:ue}:{},subject:i.trim(),message:l.trim()}),et(!1),G(`Message sent to ${s.name}`);return}let L=!O&&s.viaUserId?s.viaUserId:void 0;O&&Lt&&c&&(L=c);const Y=s.contactUserId&&s.source!=="imported"?s.contactUserId:0,k={fromUserID:Le&&sn?sn:c,toUserID:Y,note:l.trim()||"I'd love an intro!",connectorMessage:l.trim(),blurb:u.trim(),fromName:(Le==null?void 0:Le.name)||h,connectorSubject:i.trim(),blurbSubject:f.trim()};L&&(k.connectorUserID=L),Lt&&(k.teamTargetIntroOfferId=Lt);const w=(j||"").trim(),F=($||"").trim();if(w&&(k.connectorEmail=w),F&&(k.fromEmail=F),!Y||Y===0){k.toName=s.name;const ue=(p||"").trim();ue&&(k.toEmail=ue)}Object.assign(k,Ia(E)),await Ca(o,k);const we=!!Lt,ze=(Le==null?void 0:Le.name)||"your teammate",Ye=Dt==null?void 0:Dt.targetAccountId;we&&Ye&&(pn(c),fn(o,c,Ye,{bypassCache:!0}).then(ue=>{I(he=>he.map(Ve=>Ve.id===ue.id?ue:Ve))}).catch(()=>{})),Tn(null),$n(null),an(null),nn(null),et(!1),G(we?`Intro request sent on behalf of ${ze}`:L?`Asked ${s.viaName||"connector"} to intro you to ${s.name}`:`Intro request sent to ${s.name}`)}catch(O){bt(O instanceof Error?O.message:"Failed to send intro request")}finally{En(!1)}}},mn=(a,s,i)=>{const l=String(i.fullname||"").trim()||null,f={...s,viaUserId:i.userId,viaName:l,pct:i.isMutual?Math.max(s.pct||0,80):Math.max(s.pct||0,50)};en(a),tn(f),bt(null),et(!0)},Hn=!S&&!H&&je.length===0&&mt.length===0,Hs=ut?"One shared pipeline for the firm. Open an account to see everyone who can make the introduction, strongest first. Each account line says who added it.":"One pipeline for the companies you want to reach. Open an account to see everyone who can make the introduction, strongest first.";return e.jsxs("div",{className:"page active page-accounts",children:[e.jsxs("div",{className:"top-header pipe-hero",children:[e.jsxs("div",{className:"header-left pipe-hero-left",children:[!S&&!H&&N.length>0?e.jsx("div",{className:"acc-m-only acc-m-hero-eyebrow",children:`${Se.total.toLocaleStr
34ing()} account${Se.total===1?"":"s"} · ${Bt.toLocaleString()} ${Bt===1?"person":"people"} reachable · ${kt}% warm`}):null,e.jsx("h1",{className:"page-h pipe-hero-title",children:"Target accounts"}),n&&e.jsx("div",{className:"page-sub",children:`${Zt}/${Et} target accounts on Free Starter.`})]}),e.jsx("div",{className:"header-right pipe-hero-right",children:e.jsx("div",{className:"pipe-hero-actions",children:e.jsxs("button",{className:"make-intro-btn",onClick:Pn,children:[e.jsx("span",{children:"+"})," Add accounts"]})})})]}),Hn&&e.jsxs("div",{className:"explainer-card",children:[e.jsx("div",{className:"explainer-title",children:"How accounts work on Gemphere"}),e.jsx("div",{className:"explainer-desc",children:"Upload the companies you want to sell to. We match each against your team's combined network to find warm paths â so you skip cold outreach and get intro'd."}),e.jsxs("div",{className:"explainer-steps",children:[e.jsxs("div",{className:"exp-step",children:[e.jsx("div",{className:"exp-step-num",children:"1"}),e.jsxs("div",{className:"exp-step-txt",children:[e.jsx("strong",{children:"Add accounts"}),e.jsx("br",{}),"Paste the company names you want to reach"]})]}),e.jsxs("div",{className:"exp-step",children:[e.jsx("div",{className:"exp-step-num",children:"2"}),e.jsxs("div",{className:"exp-step-txt",children:[e.jsx("strong",{children:"We find warm paths"}),e.jsx("br",{}),"Cross-referenced with your team's network"]})]}),e.jsxs("div",{className:"exp-step",children:[e.jsx("div",{className:"exp-step-num",children:"3"}),e.jsxs("div",{className:"exp-step-txt",children:[e.jsx("strong",{children:"Request the intro"}),e.jsx("br",{}),"Through the teammate who knows them"]})]})]})]}),S&&e.jsx(Cs,{variant:"page",message:"Loading target accountsâ¦"}),H&&!S&&e.jsx("div",{style:{background:"#fff4f0",border:"1px solid #f3c9b8",borderRadius:10,padding:14,color:"#a84a1e",fontSize:13},children:H}),Hn&&e.jsx(e.Fragment,{children:e.jsxs("div",{className:"empty-state",children:[e.jsx("div",{className:"es-icon",children:"ð¯"}),e.jsx("div",{className:"es-title",children:"Upload your target accounts to get started"}),e.jsx("div",{className:"es-desc",children:"The companies your team is trying to close. We'll cross-reference each against your team's combined network and tell you which ones you can reach warmly."}),e.jsx("div",{className:"es-actions",children:e.jsxs("button",{className:"es-btn-primary",onClick:Pn,children:[e.jsx("span",{children:"âï¸"})," Paste company names"]})}),e.jsx("div",{className:"es-sources",children:e.jsx("div",{className:"es-source",children:"â¡ Warm paths typically map within a few seconds"})})]})}),!S&&!H&&N.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"hero-metrics-4 ta-metrics",children:[e.jsxs("div",{className:"ta-metric ta-metric-reach",children:[e.jsx("div",{className:"ta-reach-ring",style:{background:`conic-gradient(#1F4034 0turn ${kt/100}turn, rgba(20,35,28,0.14) ${kt/100}turn 1turn)`},"aria-label":`${kt}% of accounts reachable`,children:e.jsxs("div",{className:"ta-reach-ring-inner",children:[kt,"%"]})}),e.jsxs("span",{className:"ta-reach-label",children:["Of accounts",e.jsx("br",{}),"reachable"]})]}),e.jsxs("div",{className:"ta-metric acc-m-restated",children:[e.jsx("div",{className:"ta-metric-lbl",children:"Target accounts"}),e.jsx("div",{className:"ta-metric-num",children:Se.total})]}),e.jsxs("div",{className:"ta-metric",children:[e.jsx("div",{className:"ta-metric-lbl",children:"Total paths"}),e.jsx("div",{className:"ta-metric-num ta-metric-num--green",children:Se.pathsTotal??0})]}),e.jsxs("div",{className:"ta-metric",children:[e.jsx("div",{className:"ta-metric-lbl",children:"Warm paths"}),e.jsx("div",{className:"ta-metric-num ta-metric-num--green",children:Se.withPath})]}),e.jsxs("div",{className:"ta-metric",children:[e.jsx("div",{className:"ta-metric-lbl",children:"Strong paths"}),e.jsx("div",{className:"ta-metric-num ta-metric-num--green",children:Se.strong})]}),e.jsxs("div",{className:"ta-metric acc-m-restated",children:[e.jsx("div",{className:"ta-metric-lbl",children:"People reachable"}),e.jsx("div",{className:"ta-metric-num",children:Bt})]})]}),cs,e.jsxs("div",{className:"ta-section",children:[e.jsx("div",{className:"ta-toolbar",children:e.jsxs("div",{className:"filters-row",children:[qt.length>1?e.jsx("div",{className:"filters owner-filters",children:e.jsxs("div",{className:"acc-owner-picker",ref:Pe,children:[e.jsxs("button",{type:"button",className:`filt acc-owner-trigger${ie?" open":""}`,"aria-haspopup":"menu","aria-expanded":ie,onClick:()=>B(a=>!a),children:[Wt?e.jsxs(e.Fragment,{children:[Wt.isMine?"Mine":Wt.name,e.jsx("span",{className:"cnt",children:Wt.count})]}):e.jsxs(e.Fragment,{children:["Everyone",e.jsx("span",{className:"cnt",children:je.length})]}),e.jsx(ma,{className:"acc-owner-caret",size:13,strokeWidth:2})]}),ie?e.jsxs("div",{className:"acc-owner-menu",role:"menu",children:[e.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":ne==="all",className:`acc-owner-menu-item${ne==="all"?" active":""}`,onClick:()=>{ot("all"),B(!1)},children:[e.jsx("span",{className:"acc-owner-menu-label",children:"Everyone"}),e.jsx("span",{className:"acc-owner-menu-count",children:je.length})]}),qt.map(a=>e.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":ne===a.userId,className:`acc-owner-menu-item${ne===a.userId?" active":""}`,onClick:()=>{ot(a.userId),B(!1)},children:[e.jsx("span",{className:"acc-owner-menu-label",children:a.isMine?"Mine":a.name}),e.jsx("span",{className:"acc-owner-menu-count",children:a.count})]},a.userId))]}):null]})}):e.jsx("div",{className:"filters"}),e.jsxs("div",{className:"ta-toolbar-right",children:[e.jsx("button",{type:"button",className:"pipe-expand-all",onClick:Fs,children:Bn?"Collapse all":"Expand all"}),e.jsxs("div",{className:"search-box",children:[e.jsx("span",{className:"search-ico",children:"â"}),e.jsx("input",{type:"text",placeholder:"Search accounts",value:fe,onChange:a=>ae(a.target.value)})]})]})]})}),e.jsxs("div",{className:"acc-list-card acc-list-card--targets",children:[e.jsxs("div",{className:"acc-panel-head",children:[e.jsxs("div",{className:"acc-panel-head-left",children:[e.jsx("div",{className:"acc-panel-kicker",children:"Pipeline"}),e.jsx("h2",{className:"acc-panel-title",children:"Target accounts"}),e.jsx("p",{className:"acc-panel-desc",children:Hs})]}),e.jsxs("div",{className:"acc-panel-head-stats",children:[e.jsxs("div",{className:"acc-panel-stat",children:[e.jsx("div",{className:"acc-panel-stat-num acc-
34panel-stat-num--green",children:Se.pathsTotal??0}),e.jsx("div",{className:"acc-panel-stat-lbl",children:"Paths"})]}),e.jsxs("div",{className:"acc-panel-stat",children:[e.jsx("div",{className:"acc-panel-stat-num acc-panel-stat-num--green",children:Se.withPath}),e.jsx("div",{className:"acc-panel-stat-lbl",children:"With a path"})]}),e.jsxs("div",{className:"acc-panel-stat",children:[e.jsx("div",{className:"acc-panel-stat-num",children:Se.total}),e.jsx("div",{className:"acc-panel-stat-lbl",children:"Accounts"})]})]})]}),e.jsxs("div",{className:"acc-list",children:[Fe.length===0&&e.jsx("div",{className:"acc-list-empty",children:"No accounts match this filter."}),Fe.length>0?e.jsxs("div",{className:"acc-targets-head","aria-hidden":"true",children:[e.jsx("span",{className:"acc-targets-head-rank",children:"#"}),e.jsx("span",{className:"acc-targets-head-account",children:"Account"}),e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"acc-targets-head-path",children:"How warm"}),e.jsx("span",{className:"acc-targets-head-network",children:"Who can introduce you"})]}),e.jsx("span",{className:"acc-targets-head-actions"})]}):null,_s.map(a=>e.jsxs(m.Fragment,{children:[a.label?e.jsx("div",{className:"acc-owner-group-head",children:a.label}):null,a.accounts.map((s,i)=>{var re,k;const l=!!ee[s.id],f=s.kind==="company"||s.contacts.length>0,u=s.kind==="person",p=u&&s.person?s.person.name:s.companyName,j=P.has(s.id),$=Ts(s,j),E=vr(s,$),O=br(s),b=s.contacts.filter(w=>w.pct!=null&&w.pct>0),L=j?ds(s):0,Y=(q==null?void 0:q.id)===s.id;return e.jsxs("div",{className:`acc-row-v2-wrap ${l?"open":""}${Y?" acc-m-detail":""}`,children:[Y?e.jsxs("div",{className:"acc-m-only acc-m-detail-nav",children:[e.jsx("button",{type:"button",className:"acc-m-back","aria-label":"Back to target accounts",onClick:w=>{w.stopPropagation(),Wn()},children:"â¹"}),e.jsxs("div",{className:"acc-m-detail-heading",children:[e.jsxs("div",{className:"acc-m-detail-eyebrow",children:[String(i+1).padStart(2,"0")," ·"," ",u?"target person":"target account"]}),e.jsx("div",{className:"acc-m-detail-title",children:u&&((re=s.person)!=null&&re.userId)?e.jsx("button",{type:"button",className:"profile-popup-trigger acc-m-detail-name-trigger",onClick:w=>{w.stopPropagation(),d(s.person.userId,{name:s.person.name,photo:s.person.profilePhoto})},children:p}):p})]})]}):null,e.jsxs("div",{className:"acc-row-v2",onClick:()=>{if(U){qn(s);return}f&&Ct(s)},style:{cursor:U||f?"pointer":"default"},children:[e.jsx("div",{className:"acc-row-rank","aria-hidden":"true",children:String(i+1).padStart(2,"0")}),e.jsxs("div",{className:"acc-row-info",children:[e.jsxs("div",{className:"acc-row-name-line",children:[e.jsx("span",{className:`acc-row-toggle${f?"":" acc-row-toggle--empty"}${l?" open":""}`,"aria-hidden":"true",children:l?"â":"+"}),u&&((k=s.person)!=null&&k.userId)?e.jsx("button",{type:"button",className:"profile-popup-trigger acc-name-trigger",onClick:w=>{w.stopPropagation(),d(s.person.userId,{name:s.person.name,photo:s.person.profilePhoto})},children:e.jsx("span",{className:"acc-name-v2",children:p})}):e.jsx("div",{className:"acc-name-v2",children:p}),ut?e.jsx("span",{className:"acc-row-added-by",children:xr(s)}):null]}),E?e.jsx("div",{className:"acc-row-meta",children:E}):null]}),(()=>{if((s.kind==="company"||s.kind==="person")&&!j)return e.jsxs("div",{className:"acc-row-strength acc-row-strength-loading",children:[e.jsx("span",{className:"acc-row-strength-spinner","aria-hidden":"true"}),"Checking your networkâ¦"]});const w=Ea(s,me,!0),F=w!=="no_path"&&w!=="pending";return e.jsxs("div",{className:"acc-row-strength",children:[e.jsx("span",{className:`acc-row-tier-label${F?"":" muted"}`,children:Jt(w)}),O?e.jsx("span",{className:"acc-chip-warn",title:O.tip,children:O.label}):null]})})(),e.jsx(ps,{contacts:b,pathCount:L}),e.jsxs("div",{className:"acc-row-actions",children:[s.isMine!==!1?e.jsxs("span",{className:"acc-row-owner-tools",children:[e.jsxs("button",{type:"button",className:"acc-edit-btn",onClick:w=>{w.stopPropagation(),ce(s)},title:s.icp?"Edit custom ICP":"Add custom ICP",children:[e.jsx("span",{children:"â"}),e.jsx("span",{className:"acc-edit-btn-text",children:"Edit"})]}),e.jsx("button",{onClick:w=>{w.stopPropagation(),Ut(s.id)},title:"Remove",className:"acc-remove-btn",children:"â"})]}):null,f?e.jsxs("span",{className:"acc-row-cta",children:[U||!l?"See paths":"Hide paths",e.jsx("span",{"aria-hidden":"true",children:" â"})]}):e.jsx("span",{className:"acc-row-cta acc-row-cta--muted",children:"Watching"})]})]}),l&&s.isMine!==!1&&e.jsxs("div",{className:"acc-row-manage",children:[e.jsxs("button",{type:"button",className:"acc-edit-btn",onClick:w=>{w.stopPropagation(),ce(s)},title:s.icp?"Edit custom ICP":"Add custom ICP",children:[e.jsx("span",{children:"â"})," Edit"]}),e.jsx("button",{type:"button",className:"acc-remove-btn",onClick:w=>{w.stopPropagation(),Ut(s.id)},title:"Remove",children:"Remove"}),e.jsx("button",{type:"button",className:"acc-m-only acc-kebab","aria-haspopup":"dialog","aria-label":`Manage ${s.companyName}`,onClick:w=>{w.stopPropagation(),le(s)},children:e.jsx("span",{"aria-hidden":"true",children:"â¯"})})]}),l&&s.contacts.length===0&&!s._recomputing&&(P.has(s.id)?e.jsxs("div",{className:"acc-expanded",children:[e.jsxs("div",{className:"acc-expanded-header",children:["People at ",s.companyName," in your network · 0"]}),e.jsx("div",{className:"acc-expanded-empty",children:"We didn't find a warm path in your network or anyone matching this ICP on the web."})]}):e.jsxs("div",{className:"acc-expanded",children:[e.jsxs("div",{className:"acc-expanded-header",children:["Fetching your targets at ",s.companyName,"â¦"]}),e.jsxs("div",{className:"acc-expanded-loading",children:[e.jsx("span",{className:"acc-row-strength-spinner","aria-hidden":"true"}),"Resolving warm paths in your network â if none, we'll surface suggestions from the web."]})]})),l&&s.contacts.length>0&&s._recomputing&&e.jsxs("div",{className:"acc-expanded",children:[e.jsxs("div",{className:"acc-expanded-header",children:["Recomputing for ",s.companyName,"â¦"]}),e.jsxs("div",{className:"acc-expanded-loading",children:[e.jsx("span",{className:"acc-row-strength-spinner","aria-hidden":"true"}),"Recomputing warm paths from your new ICP â usually a few seconds."]})]}),l&&s.contacts.length>0&&!s._recomputing&&(()=>{const w=s.contacts.filter(y=>y.isPinned),F=s.contacts.filter(y=>!y.isPinned),we=w.filter(y=>y.source==="pinned_unresolved"),ze=w.filter(y=>!Xa(y)),Ye=F.filter(y=>y.source!=="web"),ue=F.filter(y=>y.source==="web"),he=[...ze,...Ye].sort((y,J)=>ss(y,J,me)),Ve=(y,J,Gt)=>{const zn=`${s.id}-${Gt}-${J}`,Ht=!!Me[zn],zs=D=>{_n(zn,y.contactUserId,D)},Yn=D=>{D.stopPropagation();const{directPath:Ee,warmPaths:st}=Kt(y,s.isMine===!1?s.ownerUserId:null);if(Ee){if(Yt(s,y,Ee,st,y.contactUserId?_[y.contactUserId]:void 0)){zs(D);return}He(s,{...y,pct:Ee.pct??y.pct,source:Ee.source,viaUserId:Ee.viaUserId,viaName:Ee.viaName});return}y.contactUserId&&o&&c&&Ft(y.contactUserId),x({account:s,contact:y})},un=e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"contact-row-spacer","aria-hidden":!0}),e.jsx(rs,{userId:y.contactUserId,name:Je(y.name),photo:y.profilePhoto,linkedinUrl:y.linkedinUrl,companyName:s.companyName||y.companyName,role:y.role,onOpenWebProfile:dt,onOpenInvite:wt,personChildren:e.jsx("div",{className:"contact-title",children:(U?ms(y.role):y.role)||(y.source==="pinned_unresolved"?"Couldn't find a profile â confirm the name or add a LinkedIn URL.":"")})})]});if(y.source==="pinned_unresolved")return e.jsx("div",{className:"acc-contact-group",children:e.jsxs("div",{className:"contact-row contact-row--static",children:[un,e.jsxs("div",{className:"contact-row-chips",children:[e.jsx("span",{className:"path-chip path-chip--muted",children:"No match"}),y.linkedinUrl?e.jsx("a",{href:y.linkedinUrl,target:"_blank",rel:"noreferrer",className:"contact-inline-link",onClick:D=>D.stopPropagation(),children:"LinkedIn"}):null]}),e.jsx("div",{className:"contact-row-connectors","aria-hidden":!0})]})},`${Gt}-${J}`);if(y.source==="web")return e.jsx("div",{className:"acc-contact-group",children:e.jsxs("div",{className:"contact-row contact-row--static contact-row--clickable",role:"button",tabIndex:0,onClick:()=>{jt({name:y.name||"",fullname:y.name||"",title:y.role||"",companyName:s.companyName||"",linkedinUrl:y.linkedinUrl||null,isNonGem:!0,source:"google_search"})},onKeyDown:D=>
34{(D.key==="Enter"||D.key===" ")&&(D.preventDefault(),jt({name:y.name||"",fullname:y.name||"",title:y.role||"",companyName:s.companyName||"",linkedinUrl:y.linkedinUrl||null,isNonGem:!0,source:"google_search"}))},children:[un,e.jsx("div",{className:"contact-row-chips",children:e.jsx("span",{className:"path-chip path-chip--via",children:y.isPinned?"Pinned · Found online":"Suggested"})}),e.jsx("div",{className:"contact-row-connectors","aria-hidden":!0})]})},`${Gt}-${J}`);const Ys=s.isMine===!1?s.ownerUserId:null,{directPath:De,warmPaths:$t}=Kt(y,Ys),Vn=De?{...y,pct:De.pct??y.pct,source:De.source,viaUserId:De.viaUserId,viaName:De.viaName}:null,Vs=D=>({...y,pct:D.pct??y.pct,source:D.source,viaUserId:D.viaUserId,viaName:D.viaName}),zt=y.contactUserId?_[y.contactUserId]:void 0,Ks=Ns(De,$t,y,zt,!!(y.contactUserId&&Ne[y.contactUserId])),Kn=as(y,me),Js=Kn!=="no_path",Qs=Jt(Kn),Xs=Ht&&!!De,Zs=Ht&&$t.length>0,nt=Yt(s,y,De,$t,zt),pt=(nt==null?void 0:nt.action)??null;return e.jsxs("div",{className:`acc-contact-group${Ht?" open":""}`,children:[e.jsxs("div",{className:"contact-row",onClick:Yn,role:"button",tabIndex:0,onKeyDown:D=>{(D.key==="Enter"||D.key===" ")&&(D.preventDefault(),Yn(D))},children:[un,e.jsx("div",{className:"contact-row-chips",children:e.jsx("span",{className:`acc-row-tier-label${Js?"":" muted"}`,children:Qs})}),e.jsx(ys,{direct:!!De,warmPaths:$t,connectors:zt,chip:Ks}),e.jsxs("span",{className:"acc-row-cta contact-row-cta",children:[De&&!nt?"Message":Ht?"Hide paths":"See paths",e.jsx("span",{"aria-hidden":"true",children:" â"})]})]}),Xs?e.jsx(hs,{contact:y,directSynth:Vn,teammateIntroCtx:nt,onMessage:()=>He(s,Vn),onTeamTargetIntro:Pt,onTeamTargetRequestAfterAccept:ht}):null,Zs?e.jsx(bs,{contact:y,companyName:s.companyName,warmthCtx:me,warmPaths:$t,targetConnectors:zt,connectorLoading:!!(y.contactUserId&&Ne[y.contactUserId]),connectorError:y.contactUserId?qe[y.contactUserId]:null,synthForPath:Vs,onRequestIntro:D=>He(s,D),onPickConnector:(D,Ee)=>mn(s,D,Ee),onOpenWebContactProfile:dt,onOpenInvite:wt,introActionLabel:pt==null?void 0:pt.label,introActionDisabled:pt==null?void 0:pt.disabled,onIntroAction:nt?D=>{const{teammateAccount:Ee,offer:st}=nt;(st==null?void 0:st.status)==="accepted"&&Nt(st,D)?ht(Ee,D,st):Pt(Ee,D)}:void 0}):null]},`${Gt}-${J}`)},Ke=we.length>0||he.length>0||ue.length>0,Be=we.length+he.length+ue.length,X=Math.max(0,$-Be);return e.jsxs("div",{className:"acc-expanded",children:[e.jsxs("div",{className:"acc-m-only acc-m-detail-stats","aria-hidden":"true",children:[e.jsxs("div",{className:"acc-m-stat",children:[e.jsx("div",{className:"acc-m-stat-num",children:$}),e.jsx("div",{className:"acc-m-stat-lbl",children:"contacts"})]}),e.jsxs("div",{className:"acc-m-stat",children:[e.jsx("div",{className:"acc-m-stat-num",children:L}),e.jsx("div",{className:"acc-m-stat-lbl",children:"paths"})]}),e.jsxs("div",{className:"acc-m-stat",children:[e.jsx("div",{className:"acc-m-stat-num acc-m-stat-num--green",children:Be}),e.jsx("div",{className:"acc-m-stat-lbl",children:"reachable"})]})]}),e.jsxs("div",{className:"acc-expanded-header",children:[gs(fs(Be))," ",Be===1?"person":"people"," reachable"]}),Ke?e.jsxs("div",{className:"acc-expanded-scroll",children:[we.map((y,J)=>Ve(y,J,`pinned-${J}`)),he.map((y,J)=>Ve(y,J,`net-${J}`)),ue.map((y,J)=>Ve(y,J,`web-${J}`))]}):e.jsxs("div",{className:"acc-expanded-empty",children:["No one in your network at ",s.companyName," yet."]}),X>0?e.jsxs("div",{className:"acc-expanded-tail",children:[gs(fs(X))," more"," ",X===1?"person":"people"," inside"," ",X===1?"has":"have"," no route Gem would rate above weak."]}):null]})})()]},s.id)})]},a.key))]})]})]})]}),!S&&!H&&St.length>0&&e.jsxs("div",{className:`acc-list-card acc-list-card--coverage${ut?" acc-list-card--with-owner":""}`,children:[e.jsxs("div",{className:"acc-panel-head",children:[e.jsxs("div",{className:"acc-panel-head-left",children:[e.jsx("div",{className:"acc-panel-kicker",children:"Coverage"}),e.jsx("h2",{className:"acc-panel-title",children:"Target roles"}),e.jsx("p",{className:"acc-panel-desc",children:ut?"Role-based targets from across your firm â owner shows who added each one.":"Titles worth reaching, ranked by how deep your network runs."})]}),e.jsxs("div",{className:"acc-panel-head-stats",children:[e.jsxs("div",{className:"acc-panel-stat",children:[e.jsx("div",{className:"acc-panel-stat-num",children:Bt}),e.jsx("div",{className:"acc-panel-stat-lbl",children:"People reachable"})]}),e.jsxs("div",{className:"acc-panel-stat",children:[e.jsx("div",{className:"acc-panel-stat-num acc-
34panel-stat-num--green",children:St.length}),e.jsx("div",{className:"acc-panel-stat-lbl",children:"Roles tracked"})]})]})]}),e.jsxs("div",{className:"acc-list acc-list--roles",children:[ut?e.jsxs("div",{className:"acc-targets-head acc-targets-head--roles","aria-hidden":"true",children:[e.jsx("span",{className:"acc-targets-head-rank",children:"#"}),e.jsx("span",{className:"acc-targets-head-account",children:"Role"}),e.jsx("span",{className:"acc-targets-head-owner",children:"Owner"}),e.jsx("span",{className:"acc-targets-head-path",children:"Best path"}),e.jsx("span",{className:"acc-targets-head-network",children:"Network"}),e.jsx("span",{className:"acc-targets-head-actions",children:"Actions"})]}):null,St.map((a,s)=>{const i=!!ee[a.id],l=P.has(a.id),f=a.targetRole||a.companyName,u=a.contacts.filter(b=>b.pct!=null&&b.pct>0),p=[...u].sort((b,L)=>ss(b,L,me)),j=!!Ae[a.id],$=j?p:p.slice(0,8),E=l?`${u.length} match${u.length===1?"":"es"} in your network`:"",O=(q==null?void 0:q.id)===a.id;return e.jsxs("div",{className:`acc-role-card ${i?"open":""}${O?" acc-m-detail":""}`,children:[O?e.jsxs("div",{className:"acc-m-only acc-m-detail-nav",children:[e.jsx("button",{type:"button",className:"acc-m-back","aria-label":"Back to target roles",onClick:b=>{b.stopPropagation(),Wn()},children:"â¹"}),e.jsxs("div",{className:"acc-m-detail-heading",children:[e.jsxs("div",{className:"acc-m-detail-eyebrow",children:[String(s+1).padStart(2,"0")," · target role"]}),e.jsx("div",{className:"acc-m-detail-title",children:f})]})]}):null,e.jsxs("div",{className:"acc-row-v2 acc-role-row-v2",onClick:()=>{U?qn(a):Ct(a)},children:[e.jsx("div",{className:"acc-row-rank","aria-hidden":"true",children:String(s+1).padStart(2,"0")}),e.jsxs("div",{className:"acc-row-info",children:[e.jsx("div",{className:"acc-name-v2",children:f}),E?e.jsx("div",{className:"acc-row-meta",children:E}):null]}),ut?e.jsx("div",{className:"acc-row-owner",children:e.jsx("span",{className:`acc-owner-label${a.isMine!==!1?" acc-owner-label--mine":""}`,children:At(a)})}):null,e.jsx("div",{className:`acc-row-strength${l?" acc-row-strength--empty":""}`,children:l?null:e.jsxs("div",{className:"acc-row-strength-loading",children:[e.jsx("span",{className:"acc-row-strength-spinner","aria-hidden":"true"}),"Checkingâ¦"]})}),e.jsx(ps,{contacts:p,pathCount:u.length}),a.isMine!==!1?e.jsxs("div",{className:"acc-row-actions",onClick:b=>b.stopPropagation(),children:[e.jsx("button",{type:"button",className:"acc-edit-btn",onClick:()=>ke({account:a,text:a.targetRole||a.companyName}),title:"Rename this role",children:e.jsx("span",{children:"â"})}),e.jsx("button",{onClick:()=>void Ut(a.id),title:"Remove",className:"acc-remove-btn",children:"â"})]}):e.jsx("div",{className:"acc-row-actions"}),e.jsx("div",{className:"acc-row-caret","aria-hidden":"true",children:i?"â":"+"})]}),i&&a.isMine!==!1&&e.jsxs("div",{className:"acc-row-manage",children:[e.jsxs("button",{type:"button",className:"acc-edit-btn",onClick:()=>ke({account:a,text:a.targetRole||a.companyName}),children:[e.jsx("span",{children:"â"})," Rename"]}),e.jsx("button",{type:"button",className:"acc-remove-btn",onClick:()=>void Ut(a.id),children:"Remove"})]}),i&&l&&e.jsx("div",{className:"acc-expanded acc-expanded--role",children:u.length===0?e.jsx("div",{className:"acc-expanded-empty",children:"No one matching this role in your network yet â we'll keep scanning as your network grows."}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"acc-expanded-scroll",children:$.map((b,L)=>{const Y=`role-${a.id}-${L}`,re=!!Me[Y],k=a.isMine===!1?a.ownerUserId:null,{directPath:w,warmPaths:F}=Kt(b,k),we=b.contactUserId?_[b.contactUserId]:void 0,ze=Ns(w,F,b,we,!!(b.contactUserId&&Ne[b.contactUserId])),Ye=X=>({...b,pct:X.pct??b.pct,source:X.source,viaUserId:X.viaUserId,viaName:X.viaName}),ue=w?{...b,pct:w.pct??b.pct,source:w.source,viaUserId:w.viaUserId,viaName:w.viaName}:null,he=Yt(a,b,w,F,we),Ve=X=>{if(X.stopPropagation(),w&&!he){He(a,ue||b);return}_n(Y,b.contactUserId,X)},Ke=(he==null?void 0:he.action)??null,Be=as(b,me);return e.jsxs("div",{className:`acc-contact-group${re?" open":""}`,children:[e.jsxs("div",{className:"contact-row",onClick:Ve,role:"button",tabIndex:0,children:[e.jsx("div",{className:"contact-row-spacer","aria-hidden":!0}),e.jsx(rs,{userId:b.contactUserId,name:Je(b.name),photo:b.profilePhoto,linkedinUrl:b.linkedinUrl,companyName:a.companyName||b.companyName,role:b.role,onOpenWebProfile:dt,onOpenInvite:wt,personChildren:e.jsx("div",{className:"contact-title",children:[U?ms(b.role):b.role,b.companyName].filter(
34Boolean).join(" · ")})}),e.jsxs("div",{className:"contact-row-chips",children:[e.jsx(Nr,{pct:Be==="no_path"?0:Aa(Be)}),e.jsx("span",{className:`acc-row-tier-label${Be==="no_path"?" muted":""}`,children:Jt(Be)})]}),e.jsx(ys,{direct:!!w,warmPaths:F,connectors:we,chip:ze}),e.jsx(Ra,{open:re})]}),re&&F.length>0?e.jsx(bs,{contact:b,companyName:a.companyName||b.companyName,warmthCtx:me,warmPaths:F,targetConnectors:we,connectorLoading:!!(b.contactUserId&&Ne[b.contactUserId]),connectorError:b.contactUserId?qe[b.contactUserId]:null,synthForPath:Ye,onRequestIntro:X=>He(a,X),onPickConnector:(X,y)=>mn(a,X,y),onOpenWebContactProfile:dt,onOpenInvite:wt,introActionLabel:Ke==null?void 0:Ke.label,introActionDisabled:Ke==null?void 0:Ke.disabled,onIntroAction:he?X=>{const{teammateAccount:y,offer:J}=he;(J==null?void 0:J.status)==="accepted"&&Nt(J,X)?ht(y,X,J):Pt(y,X)}:void 0}):null,re&&w?e.jsx(hs,{contact:b,directSynth:ue||b,teammateIntroCtx:he,onMessage:()=>He(a,ue||b),onTeamTargetIntro:Pt,onTeamTargetRequestAfterAccept:ht}):null]},`prt-${a.id}-${L}`)})}),u.length>8?e.jsx("div",{className:"role-expanded-footer",children:e.jsx("button",{type:"button",className:"role-see-all-btn",onClick:b=>{b.stopPropagation(),Re(L=>({...L,[a.id]:!j}))},children:j?"Show fewer matches":`See all ${u.length} matches`})}):null]})})]},a.id)})]})]}),e.jsx(Ya,{open:We,onClose:()=>!ct&&Ge(!1),onAdd:Bs,busy:ct,freeTier:n?{used:Zt,limit:Et}:null}),e.jsx(dr,{open:!!T,onClose:()=>ce(null),account:T,defaultIcp:$e,onSaved:qs}),K?e.jsx("div",{className:"mnet-sheet-overlay",role:"presentation",onClick:()=>le(null),children:e.jsxs("div",{className:"mnet-sheet",role:"dialog","aria-modal":"true","aria-label":K.companyName,onClick:a=>a.stopPropagation(),children:[e.jsx("span",{className:"mnet-sheet-grab","aria-hidden":!0}),e.jsxs("div",{className:"mnet-sheet-head",children:[e.jsx("div",{className:"mnet-sheet-eyebrow",children:"Target account"}),e.jsx("div",{className:"mnet-sheet-title",children:K.companyName})]}),e.jsxs("div",{className:"mnet-sheet-group",children:[e.jsx("button",{type:"button",className:"mnet-sheet-item",onClick:()=>{const a=K;le(null),ce(a)},children:e.jsxs("span",{className:"mnet-sheet-item-main",children:[e.jsx("span",{className:"mnet-sheet-item-name",children:K.icp?"Edit custom ICP":"Add custom ICP"}),e.jsx("span",{className:"mnet-sheet-item-desc",children:"Who counts as the right person inside this company."})]})}),e.jsx("button",{type:"button",className:"mnet-sheet-item mnet-sheet-item--danger",onClick:()=>{const a=K.id;le(null),Ut(a)},children:e.jsxs("span",{className:"mnet-sheet-item-main",children:[e.jsx("span",{className:"mnet-sheet-item-name",children:"Remove account"}),e.jsx("span",{className:"mnet-sheet-item-desc",children:"Takes it off your list. The people stay in your network."})]})})]}),e.jsx("button",{type:"button",className:"mnet-sheet-cancel",onClick:()=>le(null),children:"Cancel"})]})}):null,g?(()=>{var b;const a=g.account,s=g.contact,i=a.isMine===!1?a.ownerUserId:null,{warmPaths:l}=Kt(s,i),f=s.contactUserId?_[s.contactUserId]:void 0,u=L=>({...s,pct:L.pct??s.pct,source:L.source,viaUserId:L.viaUserId,viaName:L.viaName}),{candidates:p,needsConnectorList:j,fetchDone:$}=Es({contact:s,companyName:a.companyName,warmthCtx:me,warmPaths:l,targetConnectors:f,synthForPath:u}),E=Yt(a,s,null,l,f),O=(E==null?void 0:E.action)??null;return e.jsx(Ma,{target:{name:s.name,photo:s.profilePhoto,userId:s.contactUserId,title:s.role,company:s.companyName||a.companyName},viewer:{name:h||"You",userId:c},mode:E?"offer":"request",options:p.map(kr),loading:!!(j&&s.contactUserId&&Ne[s.contactUserId]),error:s.contactUserId?qe[s.contactUserId]:null,fetchDone:$,actionLabel:(O==null?void 0:O.label)||"Read what Gem sends",actionDisabled:O==null?void 0:O.disabled,owner:E?{name:((b=E.teammateAccount.ownerName)==null?void 0:b.trim())||"Teammate",userId:E.teammateAccount.ownerUserId??null}:null,onClose:()=>x(null),onPick:L=>{const Y=p.find(re=>re.key===L.key);if(Y){if(x(null),v({account:a,contact:s}),E){const{teammateAccount:re,offer:k}=E;(k==null?void 0:k.status)==="accepted"&&Nt(k,Y.synth)?ht(re,Y.synth,k):Pt(re,Y.synth);return}Y.connector?mn(a,s,Y.connector):He(a,Y.synth)}}})})():null,e.jsx(Ur,{open:As,account:Rs,contact:xt,viewerFullName:h,viewerUserId:c,viewerEmail:t==null?void 0:t.email,viewerToken:o,askerOverride:Le,founderUserId:sn,connectorUserId:Le&&xt?xt.viaName==="you"||xt.source==="direct_gem"?c:xt.viaUserId??null:null,markedConnectorUserIds:Ce,onClose:()=>{rn||(et(!1),v(null),nn(null),an(null))},onBack:C?()=>{rn||(et(!1),x(C),v(null))}:void 0,onSend:Gs,sending:rn,error:Ms}),An&&e.jsx(Ka,{profile:An,onClose:()=>jt(null),onInvite:(a,s)=>{jt(null),wt(a,s)}}),e.jsx(Ha,{open:tt!=null,name:(tt==null?void 0:tt.name)||"",email:Ot,onEmailChange:_t,mode:Ot.trim()?"send":"no_email",inviterName:h||"You",personalNote:cn,onPersonalNoteChange:Rn,sending:Mn,onClose:()=>{Mn||(on(null),_t(""))},onSendInvite:Ls}),Te&&e.jsx("div",{className:"modal-overlay open request-intro-portal",onClick:()=>!lt&&ke(null),children:e.jsxs("div",{className:"modal",style:{maxWidth:440},onClick:a=>a.stopPropagation(),children:[e.jsxs("div",{className:"modal-head",children:[e.jsxs("div",{children:[e.jsx("div",{className:"mod-title",children:"Edit role"}),e.jsx("div",{className:"mod-sub",children:"We'll re-scan your network for people matching the updated role."})]}),e.jsx("button",{className:"mod-close",onClick:()=>!lt&&ke(null),"aria-label":"Close",children:"Ã"})]}),e.jsxs("div",{className:"modal-body",children:[e.jsxs("label",{style:{fontSize:11,fontWeight:600,color:"#666",display:"block",marginBottom:4},children:["Role / title you're looking for ",e.jsx("span",{style:{color:"#e05"},children:"*"})]}),e.jsx("input",{type:"text",value:Te.text,autoFocus:!0,onChange:a=>ke(s=>s&&{...s,text:a.target.value}),onKeyDown:a=>{a.key==="Enter"&&Gn()},disabled:lt,placeholder:"e.g. General Partner, Senior AI Engineerâ¦",style:{width:"100%",boxSizing:"border-box",padding:"9px 11px",border:"1px solid #ddd8cc",borderRadius:7,fontSize:13,outline:"none",background:"#fff"}})]}),e.jsxs("div",{className:"modal-foot",children:[e.jsx("button",{type:"button",className:"btn-foot",onClick:()=>ke(null),disabled:lt,children:"Cancel"}),e.jsx("button",{type:"button",className:"btn-foot primary",disabled:lt||Te.text.trim().length<2,onClick:()=>void Gn(),children:lt?"Savingâ¦":"Save"})]})]})}),M?e.jsx(_a,{state:M,onChange:vt,viewerFullName:h,sending:Cn,onClose:()=>!Cn&&vt(null),onSend:()=>void Ws()}):null,Sn&&e.jsx("div",{style:{position:"fixed",bottom:24,left:"50%",transform:"translateX(-50%)",background:"#2a2820",color:"#fff",padding:"10px 18px",borderRadius:10,fontSize:13,fontWeight:600,zIndex:400,boxShadow:"0 6px 18px rgba(0,0,0,0.2)"},children:Sn})]})}export{Zr as csvRowsToEntries,Jr as default,eo as looksLikeUrl,to as parseCsvText};
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.