1import{j as e}from"./ui-DIPIJzva.js";import{u as Re,e as Oe,r as t}from"./router-Byi7yoBN.js";import{d as Ee,a as Te,f as Be,s as De,e as $e,h as fe,r as ge,p as je}from"./saas-origination-api-amu1sO5E.js";import{J as Ie,B as f,f as Me,w as h,I,a as v,W as M,y as Ae,F as Fe,U as qe,a9 as We,a0 as Le}from"./index-SYZ0ryS_.js";import{C as N,d as _,a as X,b as Y}from"./card-Bqje0w-P.js";import{B as Z}from"./building-2-KIFzlo0a.js";import{E as be}from"./external-link-CojsOPty.js";import{M as ee}from"./index-gO7RNnWo.js";import{r as se}from"./index-BPDSNHwI.js";import{T as ve}from"./target-t_ivEW_4.js";import{E as He}from"./earth-r03JeXmz.js";import"./react-vendor-Bq7xPAhO.js";import"./index-CmW2B-hH.js";function rs(){const w=Re(),{dossierId:j}=Oe(),{toast:g}=Ie(),[n,p]=t.useState(j||null),[i,ae]=t.useState(""),[c,z]=t.useState(""),[m,te]=t.useState(""),[y,re]=t.useState(""),[A,ie]=t.useState(!1),[F,le]=t.useState(!1),[q,ne]=t.useState(!1),[ce,x]=t.useState(null),[r,W]=t.useState(null),[l,L]=t.useState(null),[d,H]=t.useState(null),[oe,de]=t.useState(!1),[S,P]=t.useState([]),[U,me]=t.useState([]),[G,xe]=t.useState(!1),[u,Ne]=t.useState(null),R=i.trim().length>=2;t.useEffect(()=>{if(!j){de(!0);return}Ee(j).then(s=>{p(s.id),ae(s.company_name||""),z(s.official_website||""),te(s.operator_note||""),re(s.extra_focus||""),W(s.confirm_result||null),L(s.research_result||null),H(s.materials_result||null),s.downstream_runs&&P(s.downstream_runs),s.company_name&&Te({search:s.company_name,limit:1}).then(({items:a})=>{a.length>0&&Ne(a[0])}).catch(()=>{})}).catch(()=>x("Failed to load dossier")).finally(()=>de(!0))},[j]),t.useEffect(()=>{const s=r?.category_hint||l?.category_hint,a=r?.geography_hint||l?.geography_hint;!s&&!a||(xe(!0),Be({category:s||void 0,geography:a||void 0,limit:15}).then(({items:o})=>me(o)).catch(()=>me([])).finally(()=>xe(!1)))},[r,l]),t.useEffect(()=>{if(!oe||!i.trim())return;const s=setTimeout(async()=>{try{const a=await De({dossier_id:n||void 0,company_name:i,official_website:c||void 0,operator_note:m||void 0,extra_focus:y||void 0,confirm_result:r,research_result:l,materials_result:d});n||p(a.id)}catch{}},1500);return()=>clearTimeout(s)},[oe,i,c,m,y,r,l,d]),t.useEffect(()=>{if(!n||!S.some(o=>o.status==="queued"||o.status==="running"))return;const a=setInterval(async()=>{try{const o=await $e(n);P(o),o.some(ue=>ue.status==="queued"||ue.status==="running")||clearInterval(a)}catch{}},2500);return()=>clearInterval(a)},[n,S]);const _e=async()=>{ie(!0),x(null);try{const s=await fe({company_name:i,official_website:c||void 0,operator_note:m||void 0});W(s),s.official_url&&!c&&z(s.official_url),g({title:"Confirmed",description:`${i} verified`})}catch(s){x(String(s))}finally{ie(!1)}},we=async()=>{le(!0),x(null);try{const s=await ge({company_name:i,official_website:c||void 0,operator_note:m||void 0,extra_focus:y||void 0});L(s),g({title:"Research complete",description:`Memo generated for ${i}`})}catch(s){x(String(s))}finally{le(!1)}},ye=async()=>{ne(!0),x(null);try{const s=await je({dossier_id:n||void 0,company_name:i,official_website:c||void 0,working_summary:l?.working_summary||r?.working_summary||void 0,category_hint:l?.category_hint||r?.category_hint||void 0,geography_hint:l?.geography_hint||r?.geography_hint||void 0,memo_markdown:l?.memo_markdown||void 0,operator_note:m||void 0});H(s),s.downstream_runs&&P(s.downstream_runs),s.dossier_id&&p(s.dossier_id),g({title:"Materials ready",description:"Teaser, buyer search, and valuation briefs generated"})}catch(s){x(String(s))}finally{ne(!1)}},[b,he]=t.useState(!1),[ke,k]=t.useState(""),Ce=async()=>{if(i.trim()){he(!0),x(null);try{k("Confirming company...");const s=await fe({company_name:i,official_website:c||u?.official_url||void 0,operator_note:m||void 0});W(s),s.official_url&&!c&&z(s.official_url),k("Running deep research...");const a=await ge({company_name:i,official_website:s.official_url||c||void 0,operator_note:m||void 0,extra_focus:y||void 0});L(a),k("Generating package...");const o=await je({dossier_id:n||void 0,company_name:i,official_website:s.official_url||c||void 0,working_summary:a.working_summary||void 0,category_hint:a.category_hint||void 0,geography_hint:a.geography_hint||void 0,memo_markdown:a.memo_markdown||void 0,operator_note:m||void 0});H(o),o.downstream_runs&&P(o.downstream_runs),o.dossier_id&&p(o.dossier_id),k("Package ready! Teaser generating in background..."),g({title:"Full package created",description:`Preview ready for ${i}`})}catch(s){x(String(s)),k("")}finally{he(!1)}}},ze=l?.category_hint||r?.category_hint,Se=l?.geography_hint||r?.geography_hint,V=l?.working_summary||r?.working_summary,pe=u?.working_summary||V,O=u?.category_hint||ze,E=u?.geography_hint||Se,J=u?.official_domain||(c?c.replace(/^https?:\/\/(www\.)?/,"").replace(/\/$/,""):""),T=u?.source_system==="vc_scrape"?u.source_ref:null,K=d?.buyer_search_payload,Q=s=>Array.isArray(s)?s.map(a=>
1typeof a=="string"?a:a?.name||"").filter(Boolean):[],B=Q(K?.strategic_acquirers),D=Q(K?.pe_direct),$=Q(K?.pe_backed_platforms),Pe=B.length>0||D.length>0||$.length>0;return e.jsxs("div",{className:"min-h-screen bg-slate-50 dark:bg-zinc-950",children:[e.jsx("div",{className:"border-b border-slate-200 dark:border-zinc-800 bg-white dark:bg-zinc-900",children:e.jsxs("div",{className:"max-w-6xl mx-auto px-6 py-3 flex items-center gap-4",children:[e.jsxs(f,{variant:"ghost",size:"sm",className:"gap-1.5 text-slate-500 hover:text-slate-900 dark:text-zinc-400",onClick:()=>w("/saas-origination"),children:[e.jsx(Me,{className:"w-4 h-4"}),"Pipeline"]}),e.jsx("div",{className:"h-5 w-px bg-slate-200 dark:bg-zinc-700"}),e.jsx("h1",{className:"text-lg font-bold text-slate-900 dark:text-white",children:i||"New Company"}),O&&e.jsx(h,{variant:"outline",className:"text-xs",children:O}),E&&e.jsx(h,{variant:"outline",className:"text-xs",children:E}),T&&e.jsx(h,{variant:"outline",className:"text-[9px] py-0 text-purple-600 border-purple-200",children:T}),e.jsx("div",{className:"flex-1"}),r&&e.jsx(h,{className:"bg-amber-500 text-white text-[10px]",children:"Confirmed"}),l&&e.jsx(h,{className:"bg-blue-600 text-white text-[10px]",children:"Researched"}),d&&e.jsx(h,{className:"bg-emerald-600 text-white text-[10px]",children:"Package Ready"})]})}),e.jsxs("div",{className:"max-w-6xl mx-auto px-6 py-5 space-y-5",children:[pe&&!r&&e.jsx(N,{className:"border-blue-100 dark:border-blue-900 bg-blue-50/30 dark:bg-blue-950/10",children:e.jsx(_,{className:"pt-4 pb-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Z,{className:"w-5 h-5 text-blue-600 mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"text-xs font-semibold text-blue-800 dark:text-blue-300 uppercase tracking-wider mb-1",children:"What We Know"}),e.jsx("p",{className:"text-sm text-slate-700 dark:text-zinc-300 mb-2",children:pe}),e.jsxs("div",{className:"flex items-center gap-4 text-xs text-slate-500",children:[J&&e.jsxs("a",{href:u?.official_url||`https://${J}`,target:"_blank",rel:"noreferrer",className:"text-blue-600 hover:underline flex items-center gap-1",children:[e.jsx(be,{className:"w-3 h-3"}),J]}),O&&e.jsxs("span",{children:["Category: ",e.jsx("strong",{children:O})]}),E&&e.jsxs("span",{children:["HQ: ",e.jsx("strong",{children:E})]}),T&&e.jsxs("span",{children:["Investor: ",e.jsx("strong",{children:T})]})]})]})]})})}),e.jsx(N,{children:e.jsxs(_,{className:"pt-4 pb-4",children:[e.jsxs("div",{className:"grid gap-3 md:grid-cols-4 mb-3",children:[e.jsx(I,{value:i,onChange:s=>ae(s.target.value),placeholder:"Company name"}),e.jsx(I,{value:c,onChange:s=>z(s.target.value),placeholder:"https://..."}),e.jsx(I,{value:m,onChange:s=>te(s.target.value),placeholder:"Operator note (optional)"}),e.jsx(I,{value:y,onChange:s=>re(s.target.value),placeholder:"Extra focus (optional)"})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(f,{size:"sm",className:"bg-blue-600 hover:bg-blue-700 text-white gap-1.5",onClick:Ce,disabled:!R||b||A||F||q,children:[b?e.jsx(v,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(M,{className:"h-3.5 w-3.5"}),b?ke:"Create Full Package"]}),e.jsx("div",{className:"h-6 w-px bg-slate-200 dark:bg-zinc-700 self-center"}),e.jsxs(f,{size:"sm",variant:"ghost",onClick:_e,disabled:!R||A||b,children:[A?e.jsx(v,{className:"mr-1 h-3 w-3 animate-spin"}):e.jsx(Ae,{className:"mr-1 h-3 w-3"}),"Confirm"]}),e.jsxs(f,{size:"sm",variant:"ghost",onClick:we,disabled:!R||F||b,title:"Run deep web research: 4 parallel searches for company info, news, competitors, and M&A activity",children:[F?e.jsx(v,{className:"mr-1 h-3 w-3 animate-spin"}):e.jsx(Fe,{className:"mr-1 h-3 w-3"}),"Research"]}),e.jsxs(f,{size:"sm",variant:"ghost",onClick:ye,disabled:!R||q||!l||b,children:[q?e.jsx(v,{className:"mr-1 h-3 w-3 animate-spin"}):e.jsx(M,{className:"mr-1 h-3 w-3"}),"Package Only"]}),ce&&e.jsx("span",{className:"text-xs text-red-500 self-center ml-2",children:ce})]}),n&&d&&e.jsxs("div",{className:"mt-3 flex items-center gap-3 p-3 bg-emerald-50 dark:bg-emerald-950/20 rounded-lg border border-emerald-200 dark:border-emerald-800",children:[e.jsx(M,{className:"w-4 h-4 text-emerald-600 flex-shrink-0"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("span",{className:"text-sm font-medium text-emerald-800 dark:text-emerald-200",children:"Package ready!"}),e.jsx("span",{className:"text-xs text-emerald-600 dark:text-emerald-400 ml-2",children:"Share this with the founder:"})]}),e.jsx(f,{size:"sm",variant:"outline",className:"text-xs gap-1 border-emerald-300",onClick:()=>{const s=`${window.location.origin}/origination-preview/${n}`;navigator.clipboard.writeText(s),g({title:"URL copied",description:s})},children:"Copy Preview URL"}),e.jsx(f,{size:"sm",variant:"outline",className:"text-xs gap-1 border-emerald-300",onClick:()=>w(`/origination-preview/${n}`),children:"Open Preview"})]})]})}),V&&e.jsx(N,{children:e.jsx(_,{className:"pt-4 pb-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Z,{className:"w-5 h-5 text-blue-600 mt-0.5 flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-slate-700 dark:text-zinc-300",children:V}),r?.official_url&&e.jsxs("a",{href:r.official_url,target:"_blank",rel:"noreferrer",className:"text-xs text-blue-600 hover:underline mt-1 inline-flex items-center gap-1",children:[e.jsx(be,{className:"w-3 h-3"}),r.official_url.replace(/^https?:\/\/(www\.)?/,"")]})]})]})})}),(l?.memo_markdown||d)&&e.jsxs("div",{className:"space-y-2",children:[l?.memo_markdown&&e.jsx(C,{title:"Research Memo",defaultOpen:!0,badge:"Completed",children:e.jsx("div",{className:"pt-4 prose prose-sm prose-slate dark:prose-invert max-w-none",children:e.jsx(ee,{remarkPlugins:[se],children:l.memo_markdown})})}),d?.teaser_brief_markdown&&e.jsx(C,{title:"Teaser Brief",defaultOpen:!1,badge:"Completed",children:e.jsx("div",{className:"pt-4 prose prose-sm prose-slate dark:prose-invert max-w-none",children:e.jsx(ee,{remarkPlugins:[se],children:d.teaser_brief_markdown})})}),d?.valuation_workplan_markdown&&e.jsx(C,{title:"Valuation Work Plan",defaultOpen:!1,badge:"Completed",children:e.jsx("div",{className:"pt-4 prose prose-sm prose-slate dark:prose-invert max-w-none",children:e.jsx(ee,{remarkPlugins:[se],children:d.valuation_workplan_markdown})})}),d?.outreach_blurb&&e.jsx(C,{title:"Outreach Blurb",defaultOpen:!1,badge:"Completed",children:e.jsx("div",{className:"pt-4 text-sm text-slate-700 dark:text-zinc-300 whitespace-pre-wrap",children:d.outreach_blurb})}),Pe&&e.jsx(C,{title:"Buyer Search Handoff",defaultOpen:!1,badge:"Completed",children:e.jsxs("div",{className:"pt-4 grid gap-4 md:grid-cols-3",children:[B.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[e.jsx(Z,{className:"w-3.5 h-3.5 text-blue-600"}),e.jsx("span",{className:"text-xs font-semibold text-zinc-700 uppercase tracking-wide",children:"Strategic Acquirers"}),e.jsxs("span",{className:"text-[10px] text-zinc-400 ml-1",children:["(",B.length,")"]})]}),e.jsx("ul",{className:"space-y-1",children:B.map((s,a)=>e.jsxs("li",{className:"text-sm text-zinc-700 dark:text-zinc-300 flex items-start gap-1.5",children:[e.jsx("span",{className:"mt-1.5 w-1.5 h-1.5 rounded-full bg-blue-400 flex-shrink-0"}),s]},a))})]}),D.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[e.jsx(ve,{className:"w-3.5 h-3.5 text-purple-600"}),e.jsx("span",{className:"text-xs font-semibold text-zinc-700 uppercase tracking-wide",children:"PE Direct"}),e.jsxs("span",{className:"text-[10px] text-zinc-400 ml-1",children:["(",D.length,")"]})]}),e.jsx("ul",{className:"space-y-1",children:D.map((s,a)=>e.jsxs("li",{className:"text-sm text-zinc-700 dark:text-zinc-300 flex items-start gap-1.5",children:[e.jsx("span",{className:"mt-1.5 w-1.5 h-1.5 rounded-full bg-purple-400 flex-shrink-0"}),s]},a))})]}),$.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[e.jsx(qe,{className:"w-3.5 h-3.5 text-emerald-600"}),e.jsx("span",{className:"text-xs font-semibold text-zinc-700 uppercase tracking-wide",children:"PE-Backed Platforms"}),e.jsxs("span",{className:"text-[10px] text-zinc-400 ml-1",children:["(",$.length,")"]})]}),e.jsx("ul",{className:"space-y-1",children:$.map((s,a)=>e.jsxs("li",{className:"text-sm text-zinc-700 dark:text-zinc-300 flex items-start gap-1.5",children:[e.jsx("span",{className:"mt-1.5 w-1.5 h-1.5 rounded-full bg-emerald-400 flex-shrink-0"}),s]},a))})]})]})})]}),S.length>0&&e.jsxs(N,{children:[e.jsx(X,{className:"pb-2",children:e.jsxs(Y,{className:"text-base flex items-center gap-2",children:[e.jsx(M,{className:"w-4 h-4 text-emerald-600"}
1)," Background Jobs"]})}),e.jsx(_,{children:e.jsx("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-4",children:S.map(s=>e.jsxs("div",{className:"rounded-xl border border-slate-200 dark:border-zinc-700 p-3",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{className:"text-xs font-medium text-slate-900 dark:text-white",children:s.title||s.run_type.replace(/_/g," ")}),e.jsx(h,{variant:"outline",className:`text-[9px] py-0 ${s.status==="completed"?"text-emerald-600 border-emerald-200":s.status==="running"?"text-amber-600 border-amber-200":s.status==="failed"?"text-red-600 border-red-200":""}`,children:s.status})]}),e.jsx("p",{className:"text-[11px] text-slate-500 dark:text-zinc-400 mb-2",children:s.summary||""}),s.status==="completed"&&s.launch_path&&e.jsx(f,{size:"sm",variant:"outline",className:"text-xs w-full",onClick:()=>w(s.launch_path),children:"Open"}),s.status==="running"&&e.jsxs("div",{className:"flex items-center gap-1 text-xs text-amber-600",children:[e.jsx(v,{className:"w-3 h-3 animate-spin"}),"Processing..."]})]},s.id))})})]}),(U.length>0||G)&&e.jsxs(N,{children:[e.jsx(X,{className:"pb-2",children:e.jsxs(Y,{className:"text-base flex items-center gap-2",children:[e.jsx(ve,{className:"w-4 h-4 text-blue-600"}),"Precedent Transactions",!G&&e.jsxs(h,{variant:"outline",className:"text-[10px]",children:[U.length," deals"]}),G&&e.jsx(v,{className:"w-4 h-4 animate-spin text-slate-400"})]})}),e.jsx(_,{children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-slate-200 dark:border-zinc-700 text-left",children:[e.jsx("th",{className:"py-2 pr-3 font-medium text-slate-500 text-xs",children:"Date"}),e.jsx("th",{className:"py-2 pr-3 font-medium text-slate-500 text-xs",children:"Target"}),e.jsx("th",{className:"py-2 pr-3 font-medium text-slate-500 text-xs",children:"Acquirer"}),e.jsx("th",{className:"py-2 pr-3 font-medium text-slate-500 text-xs",children:"Type"}),e.jsx("th",{className:"py-2 pr-3 font-medium text-slate-500 text-xs",children:"Category"}),e.jsx("th",{className:"py-2 pr-3 font-medium text-slate-500 text-xs text-right",children:"Value"})]})}),e.jsx("tbody",{className:"divide-y divide-slate-100 dark:divide-zinc-800",children:U.map(s=>e.jsxs("tr",{className:"hover:bg-slate-50 dark:hover:bg-zinc-900/50",children:[e.jsx("td",{className:"py-2 pr-3 text-xs whitespace-nowrap",children:s.announced_date||"â"}),e.jsx("td",{className:"py-2 pr-3 font-medium text-xs",children:s.target_company_name||"â"}),e.jsx("td",{className:"py-2 pr-3 text-xs",children:s.acquirer_company_name||"â"}),e.jsx("td",{className:"py-2 pr-3",children:e.jsx(h,{variant:"outline",className:"text-[9px] py-0",children:s.acquirer_type||"â"})}),e.jsx("td",{className:"py-2 pr-3 text-xs text-slate-500",children:s.seg_vertical||s.seg_category||"â"}),e.jsx("td",{className:"py-2 pr-3 text-right text-xs",children:s.deal_value_usd_m?`$${s.deal_value_usd_m.toFixed(1)}M`:"â"})]},s.id))})]})})})]}),r?.evidence&&r.evidence.length>0&&e.jsxs(N,{children:[e.jsx(X,{className:"pb-2",children:e.jsxs(Y,{className:"text-base flex items-center gap-2",children:[e.jsx(He,{className:"w-4 h-4 text-blue-600"})," Evidence Sources"]})}),e.jsx(_,{children:e.jsx("div",{className:"grid gap-2 md:grid-cols-2",children:r.evidence.map(s=>e.jsxs("a",{href:s.url,target:"_blank",rel:"noreferrer",className:"rounded-lg border border-slate-200 dark:border-zinc-700 p-3 hover:bg-slate-50 dark:hover:bg-zinc-900 transition-colors block",children:[e.jsx("div",{className:"text-sm font-medium text-blue-600 dark:text-blue-400 truncate",children:s.title||s.url}),s.snippet&&e.jsx("p",{className:"text-xs text-slate-500 dark:text-zinc-400 mt-1 line-clamp-2",children:s.snippet})]},s.url))})})]})]})]})}function C({title:w,defaultOpen:j=!1,children:g,badge:n}){const[p,i]=t.useState(j);return e.jsxs("div",{className:"border border-zinc-200 rounded-xl overflow-hidden max-w-full",children:[e.jsx("button",{onClick:()=>i(!p),className:"w-full flex items-center justify-between px-5 py-4 bg-white hover:bg-zinc-50 transition-colors",children:e.jsxs("div",{className:"flex items-center gap-2",children:[p?e.jsx(We,{className:"w-4 h-4 text-zinc-400"}):e.jsx(Le,{className:"w-4 h-4 text-zinc-400"}),e.jsx("span",{className:"text-sm font-semibold text-zinc-900",children:w}),n&&e.jsx("span",{className:"text-[10px] font-medium px-2 py-0.5 rounded-full bg-emerald-50 text-emerald-700 border border-emerald-200",children:n})]})}),p&&e.jsx("div",{className:"px-5 pb-5 bg-white border-t border-zinc-100 overflow-x-auto",style:{overflowWrap:"break-word",wordBreak:"break-word"},children:g})]})}
1export{rs 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.