PageSourceSearch

https://twocuriousminds.com/assets/WelcomePage.CaFiI0G5.js

js twocuriousminds.com collected 2026-10-02 01:48:54 UTC 37,180 bytes, 1 lines download raw bytes

1import{j as e}from"./ui.C-TpFEx-.js";import{r as N,f as At,b as i,N as st,L as W}from"./router.b4tCI-Sp.js";import{u as Pe,a as lt,s as q,t as Ot,e as Re,b as ct,q as Ce,L as Ft,C as Se,p as Dt,W as rt,B as $,A as K,l as nt,n as ke,v as Wt,$ as $t,h as at,o as qt,a4 as Bt}from"./index.Cx-ip9x_.js";import{u as Yt}from"./useEdgePeople.B4ugvfvw.js";import{u as dt}from"./useGmailConnection.C4a9BBTd.js";import{u as Ht}from"./useSearchPeople.Cl5iwDdo.js";import{u as Ut}from"./useSelfMirror.CHJeGCIG.js";import{u as zt}from"./useGmailHistoryJob.DKfIbojM.js";import{u as Kt,d as Ne,a as oe,i as Qt}from"./useDossier.Bq8007DR.js";import{u as Jt}from"./useGoogleCalendarConnection.CXSscVer.js";import{i as Vt,C as Xt}from"./extensionDetection.DLP_MS8b.js";import{T as ut}from"./target.DKVtX9fd.js";import{L as Zt}from"./LinkedInImportCard.BRwY5PiE.js";import{E as es}from"./eye.8fQO2vcA.js";import{C as ts}from"./chrome.D2zEoVEC.js";import"./vendor.CL6-1M4B.js";import"./supabase.BbAAlgwC.js";import"./upload.CNCavfSJ.js";const ss=3;function rs(){const{user:s}=Pe(),r=lt({queryKey:["gmail-history-insights",s?.id],queryFn:async()=>{const{data:C,error:_}=await q.rpc("top_outbound_counterparts",{p_limit:ss});if(_){const y=_.code??"";if(["42883","PGRST202","42P01","42703","PGRST204"].includes(y))return[];throw _}return(C??[]).map(y=>({externalPersonId:y.external_person_id,name:Ot(y.name||y.email)||"Unknown",collectionId:y.collection_id??null,patternCount:Number(y.outbound_count)||0,topPatternTypes:[],lastSeenAt:y.last_seen_at??null}))},enabled:!!s?.id,staleTime:2*60*1e3,retry:!1});return{insights:r.data??[],isLoading:r.isLoading,hasInsights:(r.data?.length??0)>0}}const ns=12,as=new Set(["gmail.com","googlemail.com","yahoo.com","hotmail.com","outlook.com","icloud.com","me.com","mac.com","aol.com","proton.me","protonmail.com","pm.me","fastmail.com","duck.com","live.com","msn.com"]);function Ie(s){if(!s)return null;const r=s.lastIndexOf("@");return r<0||r===s.length-1?null:s.slice(r+1).toLowerCase().trim()}function os(s){return s?!as.has(s):!1}function is(s){return{name:s.name,email:null,receiptCount:s.patternCount,edgeType:"You have a usable read on them",tags:s.topPatternTypes,externalPersonId:s.externalPersonId,collectionId:s.collectionId,bestReceiptLine:null}}const ls=5,cs=10,ds=4;function us(s,r,C){let _=0;const b=C.get(s.externalPersonId);if(b&&b.outbound>b.inbound&&(_+=3),r.size>0){const S=Ie(s.email);S&&r.has(S)&&(_+=2)}const y=b?b.outbound+b.inbound:s.receiptCount;return _+=Math.min(ds,Math.floor(y/cs)),{score:_,bossSignalFired:_>=ls}}function ms(){const{user:s}=Pe(),{edges:r,isLoading:C}=Yt(),{insights:_,isLoading:b}=rs(),{status:y}=dt(),S=y?.connectedEmail??null,P=N.useMemo(()=>{const m=r??[],w=(_??[]).map(is);return m.length>0?m:w},[r,_]),R=N.useMemo(()=>P.map(m=>m.externalPersonId).filter(m=>!!m),[P]),u=N.useMemo(()=>[...R].sort().join(","),[R]),{data:c,isLoading:k}=lt({queryKey:["top-counterpart-direction",s?.id,u],queryFn:async()=>{if(!s?.id||R.length===0)return new Map;try{const{data:m,error:w}=await q.from("email_thread_turns").select("external_person_id, direction").eq("user_id",s.id).in("external_person_id",R);if(w||!m)return new Map;const l=new Map;for(const f of m){const x=f.external_person_id;if(!x)continue;const d=l.get(x)??{outbound:0,inbound:0};f.direction==="outbound"?d.outbound++:f.direction==="inbound"&&d.inbound++,l.set(x,d)}return l}catch{return new Map}},enabled:!!s?.id&&R.length>0,staleTime:5*60*1e3});return N.useMemo(()=>{const m=C||b||k;if(P.length===0)return{primary:null,alternates:[],isLiteCorpus:!0,isBossBestGuess:!1,isLoading:m};const w=new Set([Ie(s?.email),Ie(S)].filter(p=>!!p).filter(os)),l=c??new Map,f=P.map(p=>({edge:p,signal:us(p,w,l)})).sort((p,g)=>g.signal.score!==p.signal.score?g.signal.score-p.signal.score:g.edge.receiptCount-p.edge.receiptCount),x=f[0]?.edge??null,d=f.slice(1,3).map(p=>p.edge),B=!x||x.receiptCount<ns,j=f[0]?.signal.bossSignalFired??!1;return{primary:x,alternates:d,isLiteCorpus:B,isBossBestGuess:j,isLoading:m}},[P,C,b,k,c,s?.email,S])}
1const ot={detail:["Get a faster yes","Be trusted to decide","Show I’ve done the work"],vision:["Get buy-in on the why","Be seen as strategic","Align on direction"],conflict_avoidant:["Get their real opinion","Make the ask land","Cut the back-and-forth"],fallback:["Get a yes","Be trusted with more","Repair the relationship","Just understand them"]},xs=500,it="rounded-xl border border-primary/20 bg-primary/[0.04] p-5 mb-6",ps=({collectionId:s,externalPersonId:r,firstName:C,archetype:_="fallback",bossBestGuess:b,onDone:y})=>{const{posthog:S}=Re(),P=ct(),[R,u]=N.useState(null),[c,k]=N.useState(!1),[m,w]=N.useState(!1),[l,f]=N.useState(""),x=N.useRef(!1);N.useEffect(()=>{if(!x.current){x.current=!0;try{S?.capture("welcome_coach_turn_shown",{external_person_id:r,collection_id:s,boss_best_guess:b,archetype:_})}catch{}}},[]);const d=async(g,Y)=>{const H=g.trim();if(!H||c)return;k(!0);const{error:a}=await q.from("insight_collections").update({relationship_goal:H}).eq("id",s);if(k(!1),!a){u(H),w(!1),P.invalidateQueries({queryKey:["next-move-for-relationship",s]});try{S?.capture("welcome_relationship_goal_set",{external_person_id:r,collection_id:s,method:Y,boss_best_guess:b})}catch{}y?.()}},B=()=>{try{S?.capture("welcome_coach_turn_skipped",{external_person_id:r,collection_id:s})}catch{}y?.()},j=g=>{g.key==="Enter"?(g.preventDefault(),d(l,"freetext")):g.key==="Escape"&&w(!1)};if(R)return e.jsx("div",{className:it,"data-testid":"welcome-coach-turn",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"rounded-full bg-primary/10 p-1.5 flex-shrink-0",children:e.jsx(ut,{className:"w-3.5 h-3.5 text-primary","aria-hidden":"true"})}),e.jsxs("div",{className:"flex-1 min-w-0 space-y-1",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-primary/80",children:"Your goal"}),e.jsxs("p",{className:"text-sm text-foreground leading-snug",children:["Got it. Every read on ",C," now points at"," ",e.jsxs("span",{className:"font-medium",children:["“",R,"”"]})," — and I’ll flag it before your next conversation with them."]})]})]})});const p=ot[_]??ot.fallback;return e.jsx("div",{className:it,"data-testid":"welcome-coach-turn",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"rounded-full bg-primary/10 p-1.5 flex-shrink-0",children:e.jsx(Ce,{className:"w-3.5 h-3.5 text-primary","aria-hidden":"true"})}),e.jsxs("div",{className:"flex-1 min-w-0 space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-primary/80",children:"Your goal"}),e.jsxs("p",{className:"text-sm text-foreground leading-snug",children:["I can see how you come across to ",C," — and what they don’t say. Tell me what you’re going for, and I’ll work it into every read before you talk to them."]})]}
1),m?e.jsx("input",{autoFocus:!0,type:"text",value:l,onChange:g=>f(g.target.value),onKeyDown:j,onBlur:()=>l.trim()?void d(l,"freetext"):w(!1),maxLength:xs,placeholder:'e.g. "Get her sign-off on the proposal"',disabled:c,className:"w-full text-sm bg-background border border-border rounded-md px-3 py-2 text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-primary/40","data-testid":"welcome-coach-turn-input"}):e.jsxs("div",{className:"flex flex-wrap gap-2",children:[p.map(g=>e.jsx("button",{type:"button",disabled:c,onClick:()=>void d(g,"chip"),className:"inline-flex items-center rounded-full border border-primary/30 bg-background px-3 py-1.5 text-xs font-medium text-foreground hover:bg-primary/10 disabled:opacity-50 transition-colors",children:g},g)),e.jsx("button",{type:"button",disabled:c,onClick:()=>w(!0),className:"inline-flex items-center rounded-full px-3 py-1.5 text-xs text-muted-foreground hover:text-foreground disabled:opacity-50 transition-colors","data-testid":"welcome-coach-turn-freetype",children:"Something else…"}),e.jsx("button",{type:"button",disabled:c,onClick:B,className:"inline-flex items-center px-2 py-1.5 text-xs text-muted-foreground/70 hover:text-foreground disabled:opacity-50 transition-colors","data-testid":"welcome-coach-turn-skip",children:"Skip"}),c&&e.jsx(Ft,{className:"w-3.5 h-3.5 animate-spin text-primary self-center"})]})]})]})})},hs=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;function fs({senderUserId:s,senderEmail:r}){const{posthog:C}=Re(),[_,b]=N.useState(!1),[y,S]=N.useState(""),[P,R]=N.useState(""),[u,c]=N.useState(""),[k,m]=N.useState(!1),[w,l]=N.useState(!1);if(w)return e.jsxs("p",{className:"mt-4 text-xs text-muted-foreground flex items-center justify-center gap-1.5",children:[e.jsx(Se,{className:"w-3.5 h-3.5 text-primary","aria-hidden":"true"}),"Invite sent — they’ll see how they come across."]});if(!_)return e.jsxs("div",{className:"mt-4",children:[e.jsxs("button",{type:"button",onClick:()=>{b(!0);try{C?.capture("welcome_invite_beat_opened")}catch{}},className:"text-sm text-primary font-medium inline-flex items-center gap-1.5 hover:underline",children:[e.jsx(Dt,{className:"w-3.5 h-3.5","aria-hidden":"true"}),"Show someone how they come across"]}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Invite someone you work with — they’ll get their own read."})]});const f=async()=>{c("");const x=y.trim();if(!x){c("Email is required");return}if(!hs.test(x)){c("Enter a valid email address");return}m(!0);try{const{error:d}=await q.functions.invoke("send-insights-invite",{body:{recipientEmail:x,recipientFirstName:P.trim()||void 0,senderId:s,senderEmail:r??void 0}});if(d){nt.warn("welcome invite send failed",{error:d}),ke({title:"Couldn't send the invite",description:"Try again in a moment.",variant:"destructive"});return}try{C?.capture("welcome_invite_beat_sent")}catch{}l(!0)}catch(d){nt.error("welcome invite send threw",{err:d}),ke({title:"Couldn't send the invite",description:"Try again in a moment.",variant:"destructive"})}finally{m(!1)}};return e.jsxs("div",{className:"mt-4 rounded-xl border border-primary/20 bg-primary/[0.04] p-4 text-left",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"Show someone how they come across"}),e.jsx("p",{className:"mt-1 text-xs text-foreground/70",children:"They’ll get their own read — how they come across to the people who matter. Your notes stay yours."}),e.jsxs("div",{className:"mt-3 space-y-2",children:[e.jsx(rt,{type:"email",placeholder:"[email protected]",value:y,onChange:x=>{S(x.target.value),c("")},disabled:k,className:u?"border-destructive":"",autoComplete:"off"}),u&&e.jsx("p",{className:"text-xs text-destructive",children:u}),e.jsx(rt,{type:"text",placeholder:"Their first name (optional)",value:P,onChange:x=>R(x.target.value),disabled:k,autoComplete:"off"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx($,{variant:"outline",onClick:()=>b(!1),disabled:k,className:"flex-1",children:"Not now"}),e.jsx($,{onClick:f,disabled:k,className:"flex-1",children:k?"Sending…":e.jsxs(e.Fragment,{children:["Send invite ",e.jsx(K,{className:"w-4 h-4 ml-1.5","aria-hidden":"true"})]})})]})]})]})}const gs=30,Os=({embedded:s=!1}
1)=>{const{user:r,loading:C,isAdmin:_}=Pe(),b=Wt(),{isActivated:y}=$t(),[S]=At(),P=S.get("preview")==="1",R=S.get("reveal")==="1",{primary:u,alternates:c,isLiteCorpus:k,isBossBestGuess:m,isLoading:w}=ms(),{synthesis:l,isRunning:f,generate:x,isGenerating:d,run:B}=Ut(),{status:j,canReadMail:p,isLoading:g,isConnecting:Y,connect:H}=dt(),{job:a,startJob:me}=zt(),{status:xe,isLoading:X}=Jt(),{posthog:o}=Re(),mt=ct(),[pe,Ee]=i.useState(null),[ie,xt]=i.useState(null),[Z,pt]=i.useState(!1),[he,Le]=i.useState(""),h=i.useMemo(()=>{const t=[ie,u,...c].filter(Boolean);return pe?t.find(n=>n.externalPersonId===pe)??ie??u:ie??u},[pe,ie,u,c]),{results:fe,isSearching:Me}=Ht(he),ht=i.useCallback(t=>({name:t.name,email:t.email,receiptCount:0,edgeType:"named",tags:[],externalPersonId:t.externalPersonId,collectionId:t.collectionId,bestReceiptLine:null}),[]),Ge=i.useCallback((t,n)=>{xt(t),Ee(t.externalPersonId),pt(!0),Le(""),o?.capture("welcome_person_chosen",{external_person_id:t.externalPersonId,source:n})},[o]),le=i.useRef(new Set),{dossier:G,claims:ft,isLoading:Te,isRunning:ee,isGenerating:te,generate:Ae}=Kt(h?.externalPersonId),[U,gt]=i.useState(new Set),[Oe,Fe]=i.useState(null),[De,yt]=i.useState(new Set),[We,_t]=i.useState(new Map),[bt,$e]=i.useState(0);i.useEffect(()=>{!r||!o||o.capture("welcome_viewed",{has_gmail_connection:!!j?.isConnected,can_read_mail:p,has_counterpart:!!u,lite_corpus:k,self_mirror_ready:!!l,self_mirror_running:f||d,boss_best_guess:m})},[r?.id]);const ge=i.useRef(!1);i.useEffect(()=>{ge.current||!r||!p||l||f||d||(ge.current=!0,o?.capture("welcome_self_mirror_auto_fired"),x().catch(()=>{}))},[r,p,l,f,d,x,o]);const ce=i.useRef(!1);i.useEffect(()=>{if(!ce.current&&!(!r||!p)){if(a){ce.current=!0;return}ce.current=!0,o?.capture("welcome_gmail_history_auto_fired"),me().catch(()=>{ce.current=!1})}},[r,p,a,me,o]);const ye=i.useRef(!1);i.useEffect(()=>{if(ye.current||!ge.current||f||d)return;const t=a;!t||t.status!=="completed"||(t.patternsWritten??0)!==0&&((t.messagesProcessed??0)<gs||(ye.current=!0,o?.capture("welcome_self_mirror_resynth_on_backfill",{messages_processed:t.messagesProcessed,patterns_written:t.patternsWritten,had_thin_synthesis:!!l}),x().catch(()=>{ye.current=!1})))},[a,f,d,l,x,o]),i.useEffect(()=>{if(!s&&!Z)return;const t=h?.externalPersonId;!t||Te||le.current.has(t)||G?.status==="success"||ee||te||(le.current.add(t),o?.capture("welcome_counterpart_read_auto_fired",{external_person_id:t}),Ae({}).catch(()=>{}))},[h?.externalPersonId,Te,G?.status,ee,te,s,Z]);const _e=i.useRef(new Set),wt=a?.threadsProcessed??0,Q=a?.status??null;i.useEffect(()=>{if(!r?.id||!Z)return;const t=h?.externalPersonId;if(!t)return;const n=`${t}:${Q==="completed"?"job_completed":"thread_floor"}`;if(_e.current.has(n)||G?.status!=="failed"||ee||te||Q!=="running"&&Q!=="completed")return;let D=!1;return(async()=>{try{let v=Q==="completed";if(!v){const{data:T}=await q.from("email_thread_turns").select("thread_id").eq("user_id",r.id).eq("external_person_id",t).limit(60);v=new Set((T??[]).map(M=>M.thread_id).filter(Boolean)).size>=6}if(!v||D||_e.current.has(n))return;_e.current.add(n),o?.capture("welcome_counterpart_read_refired",{external_person_id:t,trigger:Q==="completed"?"job_completed":"thread_floor"}),await Ae({})}catch{}})(),()=>{D=!0}},[r?.id,Z,h?.externalPersonId,G?.status,ee,te,Q,wt]);const qe=i.useRef(!1);i.useEffect(()=>{const t=G?.status==="failed"&&/spend cap/i.test(G.error_message??""),n=B?.status==="failed"&&/spend cap/i.test(B.error_message??"");qe.current||!t&&!n||(qe.current=!0,o?.capture("synthesis_spend_capped",{surface:"welcome",self_mirror_capped:n,dossier_capped:t}))},[G?.status,G?.error_message,B?.status,B?.error_message,o]),i.useEffect(()=>{const t=c.map(n=>n?.externalPersonId).filter(n=>!!n);for(const n of t)le.current.has(n)||(le.current.add(n),q.functions.invoke("synthesize-person-dossier",{body:{external_person_id:n,force:!1}}).catch(()=>{}))},[c.length]);const Be=3,jt=12e3;i.useEffect(()=>{const t=!g&&!w&&!X,n=p,v=!!xe?.isConnected;if(!(t&&n&&v&&(!!!u||(f||d)&&!l))){$e(ae=>ae===0?ae:0);return}const Tt=window.setInterval(()=>{$e(ae=>ae+1>=Be?Be-1:ae+1)},jt);return()=>window.clearInterval(Tt)},[g,w,X,p,xe?.isConnected,u,f,d,l]);const Ye=i.useRef(!1);if(i.useEffect(()=>{Ye.current||!(!g&&!w&&!X)||!p||u||!a||a.status==="queued"||a.status==="running"||a.hasMore||(f||d)&&!l||(Ye.current=!0,o?.capture("welcome_no_counterpart_dead_end_viewed",{job_status:a?.status??null,
1job_reason:a?.result?.reason??null,messages_processed:a?.messagesProcessed??0,missing_mail_scope:j?.hasMailScope===!1,ingest_broke:a?.status==="failed"||a?.status==="cancelled"}))},[g,w,X,p,u,a,f,d,l,j?.hasMailScope,o]),C)return null;if(!r)return s?null:e.jsx(st,{to:"/login",replace:!0});if(y&&U.size===0&&!P&&!R)return s?null:e.jsx(st,{to:"/today",replace:!0});const E=!g&&!w&&!X,de=p,vt=!!j?.isConnected&&j?.hasMailScope===!1,Nt=!!xe?.isConnected,I=!!u,A=h?.name??"them",O=A.split(/\s+/)[0]||A,se=h?.receiptCount??0,Ct=G?.status==="failed"&&/spend cap/i.test(G.error_message??""),St=G?.pitch??(Ct?_?"⚠️ Admin: daily AI spend cap reached, so synthesis is paused. Upsert a user_spend_cap_overrides row for this user (or raise ANTHROPIC_DAILY_TOKEN_CAP_PER_USER); new accounts get the Day-0 grace cap automatically.":`We're at capacity right now. Your read on ${O} will land later today, and there's nothing to redo on your end.`:ee||te?`Reading your ${se} ${se===1?"receipt":"receipts"} with ${O}. Your read lands in a moment.`:h?.bestReceiptLine??"What lands, what makes them quiet, what to watch for."),He=(ft??[]).filter(t=>{if(t.rejected_by_user)return!1;const n=`${Ne(t)} ${oe(t)}`.toLowerCase();return!/(not yet legible|no reliable read|not yet visible|cause is not|too thin|can't tell yet|cannot tell yet)/.test(n)}),Ue=(t,n)=>{if(t.length===0)return null;const D=t.filter(L=>(L.evidence_excerpts?.length??0)>0),v=D.length>0?D:t,T=L=>{const M=n.indexOf(L);return M===-1?99:M};return[...v].sort((L,M)=>T(L.section)-T(M.section)||L.display_order-M.display_order)[0]??null},J=Ue(He.filter(t=>t.section==="high_stakes_handles"||t.section==="opportunities"),["high_stakes_handles","opportunities"]),z=Ue(He.filter(t=>Qt(t.section)&&t.id!==J?.id),["friction_points","their_priorities_with_you","high_stakes_handles","who_you_are_to_each_other","opportunities"]),re=h?h.collectionId??We.get(h.externalPersonId)??null:null,ze=re?`/person/${re}`:null,ue=ze?`${ze}/brief`:null,be=!!h&&U.has(h.externalPersonId),Ke=!!h&&Oe===h.externalPersonId,ne=[u,...c].find(t=>t&&!U.has(t.externalPersonId))??null,Qe=h?.externalPersonId??null,kt=!Qe||!re||De.has(Qe),Je=be&&kt,It=(f||d)&&!!!l,Pt=de&&(!a||a.status==="queued"||a.status==="running"||a.hasMore),we=E&&de&&!I&&(Pt||It),F=we,V=j?.hasMailScope===!1,je=a?.status==="failed"||a?.status==="cancelled",ve=a?.messagesProcessed??0,Rt=a?.status==="completed"&&ve===0,Ve=I?[{title:`Reading your sent mail with ${A}`,body:`Looking for what ${A} actually rewards vs. what they say they value.`},{title:"Finding your tells",body:"How you come across: what lands, and what makes them quiet."},{title:"Sharpening your read",body:"A few more seconds."}]:[{title:"Reading your sent mail",body:"Your sent mail, oldest threads included. Patterns, not bodies."},{title:"Looking for who you message most",body:"Top recipients, by volume and asymmetry."},{title:"Sharpening your first read",body:"Your first read lands in a moment."}],Xe=Ve[Math.min(bt,Ve.length-1)],Ze=t=>{Ee(t),o?.capture("welcome_counterpart_changed",{external_person_id:t})},et=()=>{o?.capture("welcome_read_opened",{external_person_id:h?.externalPersonId})},Et=()=>{o?.capture("welcome_self_mirror_opened")},Lt=async()=>{const t=h;if(!(!t||!r?.id)&&Oe!==t.externalPersonId&&!U.has(t.externalPersonId)){Fe(t.externalPersonId);try{const{error:n}=await q.from("person_receipts").insert({external_person_id:t.externalPersonId,owner_user_id:r.id,text:`Saved as first read on ${t.name}.`,tag:"general",strength:1,auto_generated:!1,source:"user_written",context:"welcome_card_2",cluster_key:`welcome-save:${t.externalPersonId}`}),D=!!n&&/duplicate|unique/i.test(n.message??"");if(n&&!D)throw n;if(typeof window<"u"){const v=`tcm_read_saved_at:${r.id}`;window.localStorage.getItem(v)||window.localStorage.setItem(v,new Date().toISOString())}if(o?.capture("read_saved",{surface:"welcome_card_2",external_person_id:t.externalPersonId,boss_best_guess:m}),gt(v=>{if(v.has(t.externalPersonId))return v;const T=new Set(v);return T.add(t.externalPersonId),T}),!t.collectionId&&!We.has(t.externalPersonId))try{const{data:v,error:T}=await q.from("insight_collections").insert({user_id:r.id,linked_person_id:null,person_id:t.externalPersonId,external_person_name:t.name,perspective_type:"person",title:`About ${t.name}`,visibility:"private",is_draft:!1}).select("id").single();let L=v?.id??null;if(T&&/duplicate|unique/i.test(T.message??"")){const{data:M}=await q.from("insight_collections").select("id").eq("user_id",r.id).eq("person_id",t.externalPersonId).eq("perspective_type","person").is("ar
1chived_at",null).limit(1).maybeSingle();L=M?.id??null}L&&_t(M=>new Map(M).set(t.externalPersonId,L))}catch{}mt.invalidateQueries({queryKey:["activation-note-count",r.id]})}catch{ke({title:"Could not save the read",description:"Try again in a moment.",variant:"destructive"})}finally{Fe(null)}}},tt=e.jsxs(e.Fragment,{children:[I&&!F&&e.jsx("div",{className:"mb-6 rounded-lg border border-primary/20 bg-primary/5 p-4",children:e.jsxs("p",{className:"text-xs sm:text-sm text-foreground/80 leading-relaxed",children:[se>0?e.jsxs(e.Fragment,{children:["From your ",e.jsx("span",{className:"font-medium text-foreground",children:se})," ",se===1?"receipt":"receipts"," with"," ",e.jsx("span",{className:"font-medium text-foreground",children:A}),"."]}):e.jsxs(e.Fragment,{children:["From your history with ",e.jsx("span",{className:"font-medium text-foreground",children:A}),"."]})," ","Not a profile of ",A,"."," ",e.jsx("span",{className:"block mt-1 text-foreground/70 italic",children:"We show you the read. You write the message."})]})}),e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("p",{className:"text-xs sm:text-sm uppercase tracking-widest text-primary/80 mb-2",children:"Your first read"}),e.jsx("h1",{className:"text-2xl sm:text-3xl md:text-4xl font-bold text-foreground leading-tight",children:I?`What ${A} won't tell you, and your move for the next conversation.`:"See how the people you write to actually read you."})]}),E&&I&&c.length>0&&!F&&e.jsxs("div",{className:"mb-6",children:[e.jsx("p",{className:"text-xs uppercase tracking-widest text-muted-foreground mb-2",children:m?"Best read on":"Reading on"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:[u,...c].filter(Boolean).map(t=>{if(!t)return null;const n=(h?.externalPersonId??u?.externalPersonId)===t.externalPersonId;return e.jsxs("button",{type:"button",onClick:()=>Ze(t.externalPersonId),className:at("inline-flex items-center gap-2 rounded-full border px-3 py-1.5 text-sm transition-colors",n?"border-primary bg-primary/10 text-foreground":"border-border bg-card text-muted-foreground hover:bg-muted"),children:[e.jsx("span",{className:"font-medium",children:t.name}),e.jsx("span",{className:"text-xs text-muted-foreground",children:t.receiptCount})]},t.externalPersonId)})}),m&&c.length>0&&e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"Not the right person? Pick who you mean."})]}),E&&!de&&e.jsxs("div",{className:"rounded-xl border border-border bg-card p-6 text-center mb-6",children:[e.jsx(qt,{className:"w-8 h-8 mx-auto text-primary mb-3"}),e.jsx("h2",{className:"text-lg font-semibold text-foreground mb-2",children:"Connect Gmail for your sharpest first read"}),vt&&e.jsxs("p",{className:"text-sm text-foreground/90 mb-3 max-w-md mx-auto",children:["You’re signed in",j?.connectedEmail?` as ${j.connectedEmail}`:"",", but that sign-in didn’t include mail access — we only ask for that here, once you can see what it’s for. Nothing went wrong, and there’s nothing to undo."]}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4 max-w-md mx-auto",children:"Two Curious Minds reads your sent mail to map how the people you deal with most actually decide, and how you come across to them. It’s the fastest way to a first read — but it’s optional, and you can start without it."}),e.jsxs("ul",{className:"text-xs text-muted-foreground space-y-1 mb-4 inline-block text-left",children:[e.jsx("li",{children:"• Sent mail in the background, never your inbox."}),e.jsx("li",{children:"• Patterns, not message bodies. We never store an email."}),e.jsx("li",{children:"• When you open an email to prep a reply, we read just that one, in the moment. It is never stored."}),e.jsx("li",{children:"• Private to you. Your circle never sees your messages, and nothing is shared unless you choose to."}),e.jsx("li",{children:"• Disconnect any time, one click."}),e.jsx("li",{children:"• Google's permission screen comes next, in their wording, not ours."})]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-4 max-w-md mx-auto",children:"Pick the Gmail where you work with your team. It can be a different Google account than your Two Curious Minds login."}),e.jsx($,{onClick:()=>{o?.capture("welcome_gmail_connect_clicked"),o?.capture("gmail_connect_clicked",{surface:"welcome",door:"direct"}),H().catch(()=>{})},disabled:Y,children:Y?"Connecting…":e.jsxs(e.Fragment,{children:["Connect Gmail ",e.jsx(K,{className:"w-4 h-4 ml-2"})]})}),e.jsxs("div",{className:"mt-4 pt-4 border-t border-border/50",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"Not ready to connect yet?"}),e.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-x-4 gap-y-1 text-sm",children:[e.jsx(W,{to:"/read-email",onClick:()=>o?.capture("welcome_try_paste_email_clicked"),className:"text-primary hover:underline",children:"See it work on one email first"}),e.jsx(W,{to:"/groups",onClick:()=>o?.capture("welcome_explore_groups_clicked"),className:"text-primary hover:underline",children:"Explore your groups"})]})]})]}),E&&we&&e.jsxs("div",{className:"rounded-xl border border-border bg-card p-6 text-center mb-6",children:[e.jsx(Ce,{className:"w-8 h-8 mx-auto text-primary mb-3"}),e.jsx("h2",{className:"text-lg font-semibold text-foreground mb-2",children:Xe.title}),j?.connectedEmail&&e.jsxs("p",{className:"text-xs text-muted-foreground mb-2",children:["from ",j.connectedEmail]}),e.jsx("p",{className:"text-sm text-muted-foreground mb-2 max-w-md mx-auto",children:Xe.body}),a&&a.threadsProcessed>0&&e.jsxs("p",{className:"text-sm font-medium text-foreground mb-2","data-testid":"welcome-ingest-progress",children:["Scanned ",a.threadsProcessed.toLocaleStr
1ing()," conversations so far",a.patternsWritten>0?` · ${a.patternsWritten} patterns`:""]}),e.jsx("p",{className:"text-xs text-muted-foreground italic",children:"Patterns, not message bodies. Disconnect anytime."}),j?.connectedEmail&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-3",children:["Boss not in this Gmail?"," ",e.jsx("button",{type:"button",onClick:()=>{o?.capture("welcome_loader_reconnect_clicked"),H().catch(()=>{})},disabled:Y,className:"text-primary hover:underline disabled:opacity-50",children:Y?"Connecting…":"Connect a different Gmail"})]})]}),E&&I&&!F&&e.jsx("div",{className:"mb-6 gap-4",children:e.jsxs("div",{className:"rounded-xl border border-border bg-card p-5 flex flex-col",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs uppercase tracking-widest text-muted-foreground mb-3",children:[e.jsx(Ce,{className:"w-4 h-4"}),"Your read on ",A]}),z||J?e.jsxs("div",{className:"space-y-4 mb-4 flex-1",children:[z&&e.jsxs("div",{className:"space-y-1",children:[e.jsxs("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-primary/70",children:["What ",O," won't tell you"]}),e.jsx("p",{className:"text-sm font-semibold text-foreground leading-snug",children:Ne(z)}),oe(z)&&e.jsx("p",{className:"text-sm text-foreground/90 leading-relaxed line-clamp-2",children:oe(z)}),z.evidence_excerpts?.[0]&&e.jsxs("blockquote",{className:"mt-1 border-l-2 border-primary/40 pl-3 text-xs text-muted-foreground italic",children:["“",z.evidence_excerpts[0],"”",e.jsxs("span",{className:"block mt-1 not-italic text-[10px] uppercase tracking-wider text-muted-foreground/70",children:["from your email with ",O]})]})]}),J&&e.jsxs("div",{className:"rounded-r-md border-l-2 border-primary/50 bg-primary/[0.05] py-2.5 pl-3 pr-2",children:[e.jsxs("p",{className:"flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-wider text-primary mb-1",children:[e.jsx(ut,{className:"w-3 h-3"}),"The move"]}),e.jsx("p",{className:"text-sm font-semibold text-foreground leading-snug",children:Ne(J)}),oe(J)&&e.jsx("p",{className:"text-sm text-foreground/90 leading-relaxed line-clamp-2 mt-0.5",children:oe(J)})]})]}):e.jsx("p",{className:"text-sm text-foreground/90 mb-4 leading-relaxed flex-1",children:St}),be?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{className:"inline-flex items-center gap-1.5 text-sm font-medium text-foreground",children:[e.jsx(Se,{className:"w-4 h-4 text-primary"}),"Saved. ",O," is now in your reads."]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[ne&&e.jsxs($,{size:"sm",onClick:()=>Ze(ne.externalPersonId),children:["See your read on ",ne.name.split(/\s+/)[0]||ne.name,e.jsx(K,{className:"w-3.5 h-3.5 ml-1.5"})]}),ue&&e.jsxs(W,{to:ue,onClick:et,className:at("inline-flex items-center gap-1 text-sm font-medium transition-transform",ne?"text-muted-foreground hover:text-foreground":"text-primary hover:translate-x-0.5"),children:["Open ",O,"'s brief ",e.jsx(K,{className:"w-3.5 h-3.5"})]}),!s&&e.jsx(W,{to:"/today",onClick:()=>o?.capture("welcome_done_after_save_clicked"),className:"inline-flex items-center gap-1 text-sm text-muted-foreground hover:text-foreground transition-colors",children:"I'm done, take me home"})]})]}):e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs($,{size:"sm",onClick:Lt,disabled:Ke,children:[Ke?"One sec…":`Set what you want from ${O}`,e.jsx(K,{className:"w-3.5 h-3.5 ml-1.5"})]}),ue&&e.jsxs(W,{to:ue,onClick:et,className:"text-sm font-medium text-muted-foreground hover:text-foreground transition-colors",children:["Open ",O,"'s brief"]})]})]})}),!s&&E&&I&&!F&&U.size===0&&e.jsx("div",{className:"text-center mb-6",children:e.jsx(W,{to:"/today",onClick:()=>o?.capture("welcome_explore_on_own_clicked"),className:"text-sm text-muted-foreground hover:text-foreground transition-colors",children:"Explore on my own →"})}),E&&de&&!I&&!we&&e.jsxs("div",{className:"space-y-4 mb-6","data-testid":"welcome-no-counterpart",children:[!s&&!!l?.meta_read&&e.jsxs(W,{to:"/self-mirror",onClick:Et,className:"group block rounded-xl border border-border bg-card hover:bg-card/70 transition-colors p-5",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs uppercase tracking-widest text-muted-foreground mb-3",children:[e.jsx(es,{className:"w-4 h-4"}
1),"How you come across"]}),e.jsxs("p",{className:"text-sm text-foreground/90 mb-3 leading-relaxed",children:[l.meta_read.slice(0,180),l.meta_read.length>180?"…":""]}),e.jsxs("span",{className:"inline-flex items-center gap-1 text-sm font-medium text-primary group-hover:translate-x-0.5 transition-transform",children:["Open the read ",e.jsx(K,{className:"w-3.5 h-3.5"})]})]}),e.jsxs("div",{className:"rounded-xl border border-dashed border-border bg-muted/30 p-5 text-center",children:[e.jsx("p",{className:"text-sm text-foreground/90 mb-1",children:V?"We don't have permission to read your Gmail yet.":je?"We couldn't finish reading your sent mail.":Rt?"We didn't find any sent mail on this account to read.":ve>0?`We read ${ve.toLocaleString()} of your sent messages but haven't found someone you go back and forth with yet.`:"We read your sent mail but didn't find a clear recurring person yet."}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:V?`${j?.connectedEmail?`${j.connectedEmail} is connected`:"Your account is connected"}, but the Google permission that lets us read your sent mail isn’t part of it — so there’s nothing for us to read yet. Reconnect and tick the Gmail box, and your first read lands a couple of minutes later.`:je?"Nothing is wrong with your account — the scan stopped partway. Running it again usually clears it. You can also point me at someone directly: name them, paste a call transcript or your notes on their page.":"Your reads sharpen as you send more. Or point me at someone now: name them, paste a call transcript or your notes on their page, and I’ll build your first read from that."}),e.jsxs("div",{className:"flex flex-wrap gap-3 justify-center",children:[je&&!V&&e.jsx($,{size:"sm",onClick:()=>{o?.capture("welcome_no_counterpart_rescan_clicked",{job_status:a?.status??null}),me().catch(()=>{})},children:"Read my sent mail again"}),e.jsx($,{variant:V?"default":"outline",size:"sm",onClick:()=>{o?.capture("welcome_no_counterpart_reconnect_clicked",{missing_mail_scope:V}),H().catch(()=>{})},disabled:Y,children:Y?"Connecting…":V?"Reconnect with Gmail access":"Connect a different Gmail"}),e.jsx(W,{to:"/people",onClick:()=>o?.capture("welcome_no_counterpart_explore_clicked"),className:"inline-flex items-center text-sm font-medium text-primary hover:underline",children:"Point me at someone"})]})]})]}),E&&I&&!F&&be&&h&&re&&!De.has(h.externalPersonId)&&e.jsx(ps,{collectionId:re,externalPersonId:h.externalPersonId,firstName:O,bossBestGuess:m,onDone:()=>{const t=h.externalPersonId;yt(n=>new Set(n).add(t))}}),E&&I&&k&&!F&&e.jsxs("p",{className:"text-xs text-muted-foreground italic text-center mb-6",children:["Your read on ",A," sharpens as you exchange more email."]}),E&&I&&!F&&Je&&!s&&e.jsxs("div",{className:"rounded-xl border border-border bg-card p-5 mb-6 text-center",children:[e.jsx(Se,{className:"w-6 h-6 mx-auto text-primary mb-2"}),e.jsxs("p",{className:"text-base font-semibold text-foreground mb-1",children:["You're set",U.size>1?`, with ${U.size} reads saved`:"","."]}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4 max-w-sm mx-auto",children:Nt?"Your reads live on your home now, and sharpen every time you exchange email.":"Your reads live on your home now, and sharpen every time you exchange email. Next: connect your calendar there to get a read before each meeting."}),e.jsx($,{asChild:!0,children:e.jsxs(W,{to:"/today",onClick:()=>o?.capture("welcome_complete_home_clicked"),children:["Go to your home ",e.jsx(K,{className:"w-4 h-4 ml-1.5"})]})}),!b&&!Vt()&&e.jsxs("div",{className:"mt-4",children:[e.jsx($,{asChild:!0,variant:"outline",size:"sm",children:e.jsxs("a",{href:Xt,target:"_blank",rel:"noopener noreferrer",onClick:()=>o?.capture("welcome_extension_cta_clicked",{destination:"chrome_web_store"}),children:[e.jsx(ts,{className:"w-3.5 h-3.5 mr-1.5"}),"Install the Gmail extension"]})}),e.jsx("p",{className:"mt-1.5 text-xs text-muted-foreground",children:"Your read fires every time you draft, right inside Gmail."})]}),r?.id&&e.jsx(fs,{senderUserId:r.id,senderEmail:r.email})]}),E&&I&&!F&&Je&&!s&&e.jsx(Zt,{className:"mb-6"})]}),Mt=!s&&E&&!F&&I&&!Z,Gt=e.jsxs("div",{className:"max-w-xl mx-auto pt-2",children:[e.jsxs("div",{className:"text-center mb-6",children:[e.jsx("p",{className:"text-xs sm:text-sm uppercase tracking-widest text-primary/80 mb-2",children:"Your first read"}),e.jsx("h1",{className:"text-2xl sm:text-3xl md:text-4xl font-bold text-foreground leading-tight",children:"Who do you need a read on?"}),e.jsx("p",{className:"text-base text-muted-foreground mt-3",children:"A customer, a client, a candidate, whoever you most need to get right. We’ll read your history with them and show you what actually works."})]}),(u||c.length>0)&&e.jsxs("div",{className:"mb-5",children:[e.jsx("p",{className:"text-xs uppercase tracking-widest text-muted-foreground mb-2",children:"Suggestions"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:[u,...c].filter(
1Boolean).map(t=>t?e.jsx("button",{type:"button",onClick:()=>Ge(t,"suggestion"),className:"inline-flex items-center gap-2 rounded-full border border-border bg-card px-3 py-1.5 text-sm text-foreground hover:bg-muted transition-colors",children:e.jsx("span",{className:"font-medium",children:t.name})},t.externalPersonId):null)})]}),e.jsxs("div",{children:[e.jsx("input",{type:"text",value:he,onChange:t=>Le(t.target.value),placeholder:"Or search anyone you work with…","aria-label":"Search for the person you want a read on",className:"w-full rounded-lg border border-border bg-card px-4 py-3 text-base text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-primary/40"}),he.trim().length>=2&&e.jsxs("div",{className:"mt-2 rounded-lg border border-border bg-card overflow-hidden divide-y divide-border/60",children:[Me&&fe.length===0&&e.jsx("p",{className:"px-4 py-3 text-sm text-muted-foreground",children:"Searching…"}),!Me&&fe.length===0&&e.jsx("p",{className:"px-4 py-3 text-sm text-muted-foreground",children:"No one found by that name yet."}),fe.map(t=>e.jsxs("button",{type:"button",onClick:()=>Ge(ht(t),"search"),className:"block w-full text-left px-4 py-3 hover:bg-muted transition-colors",children:[e.jsx("span",{className:"text-sm font-medium text-foreground",children:t.name}),t.email&&e.jsx("span",{className:"block text-xs text-muted-foreground",children:t.email})]},t.externalPersonId))]})]})]});return s?e.jsx("section",{className:"space-y-6","aria-label":"Day-0 activation reveal",children:tt}):e.jsxs(e.Fragment,{children:[e.jsx(Bt,{children:e.jsx("title",{children:"Your first read | Two Curious Minds"})}),e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-background to-muted/20 pb-16",children:e.jsx("div",{className:"content-container max-w-3xl mx-auto pt-8 sm:pt-12 px-4",children:Mt?Gt:tt})})]})};export{Os as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.