1import{k as ye,u as he,d as fe,b as xe,c as ge,a as be,r as n,e as I,f as C,j as e,B as _,a7 as je,L as we,a3 as ve,a4 as Ne,a5 as Ce,a6 as Z,i as x}from"./index-WXVTV-9b.js";import _e from"./html2canvas.esm-DXEQVQnt.js";import{f as ke,S as Se,M as Le,B as Ae,a as Ee,Q as De,C as Pe,R as qe,E as Te}from"./RightSidebar-BmPcWRlj.js";import{C as Fe,a as Ie,b as Me,d as $e}from"./card-DrnD9fpR.js";import{I as Re}from"./input-ExANaQVP.js";import{P as Be,a as Oe,b as ze}from"./popover-BqAavFjE.js";import{C as Ke,P as Qe,F as He,D as Ge}from"./product-sentiment-DQZGD6pz.js";import{A as Ue}from"./arrow-left-BM9JO63G.js";import{B as X}from"./bookmark-CD7UZnsY.js";import{L as We}from"./list-CRwkeOxM.js";import{P as Ve}from"./plus-CcaOnto5.js";import{L as Je}from"./link-2-D2DDFfB6.js";import{D as Ze}from"./download-BTW41Jru.js";import"./select-ClyFV9jF.js";import"./index-BdQq_4o_.js";import"./scroll-area-CfdTMPE6.js";import"./LineChart-CpsRId_s.js";import"./tiny-invariant-BaFNuDhB.js";import"./save-CH75VP0Z.js";import"./trash-2-CXXbYsVo.js";import"./underline-Bz57ij8a.js";import"./phone-BkoNMtfZ.js";import"./google-sheet-editor-BIhhQFO-.js";import"./maximize-2-BS7uaCUk.js";import"./Scatter-mA1UgTwk.js";const Xe=ye("BookmarkCheck",[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2Z",key:"169p4p"}],["path",{d:"m9 10 2 2 4-4",key:"1gnqz4"}]]);function Y(o){const i=Array.isArray(o)?o[0]:o;if(!i)return null;const h=i.match(/linkedin\.com\/company\/([^/?#]+)/i);return h?h[1].replace(/\/$/,""):null}function Ct(){const{slug:o}=he(),{user:i}=fe(),{toast:h}=xe(),g=ge(),[,M]=be(),[a,k]=n.useState(null),[t,ee]=n.useState(null),[d,S]=n.useState(""),[p,te]=n.useState(""),[se,b]=n.useState(!0),[$,j]=n.useState(null),[L,ae]=n.useState(null),[R,B]=n.useState(!1),[A,O]=n.useState(!1),[z,K]=n.useState(!0),[Q,H]=n.useState(0),[E,re]=n.useState(!1),[D,w]=n.useState(""),[ne,v]=n.useState(!1),ie=n.useRef(null),{data:G=[],isLoading:U}=I({queryKey:["/api/user-visited-companies",i?.id],queryFn:async()=>(await x("GET","/api/user-visited-companies")).json(),enabled:!!i?.id}),{data:oe=[]}=I({queryKey:["/api/company-lists",i?.id],queryFn:async()=>(await x("GET","/api/company-lists")).json(),enabled:!!i?.id&&E}),{data:P=[]}=I({queryKey:["/api/company-lists/for-company",a],queryFn:async()=>(await x("GET",`/api/company-lists/for-company/${a}`)).json(),enabled:!!a&&!!i?.id&&E}),[W,ce]=n.useState(""),le=C({mutationFn:async s=>(await x("POST","/api/user-visited-companies",s)).json(),onSuccess:()=>g.invalidateQueries({queryKey:["/api/user-visited-companies",i?.id]})}),q=C({mutationFn:async s=>{if(!a||!d)throw new Error("No company");const r=W||o||a;return(await x("POST",`/api/company-lists/${s}/items`,{companyId:a,companyName:d,slug:r,logo:p||void 0,location:t?.hq_location||t?.hq_country||void 0,employeeCount:t?.size_range||void 0,industry:t?.industry||void 0})).json()},onSuccess:()=>{g.invalidateQueries({queryKey:["/api/company-lists/for-company",a]}),g.invalidateQueries({queryKey:["/api/company-lists",i?.id]})}}),V=C({mutationFn:async s=>{if(!a)throw new Error("No company");await x("DELETE",`/api/company-lists/${s}/items/${a}`)},onSuccess:()=>{g.invalidateQueries({queryKey:["/api/company-lists/for-company",a]}),g.invalidateQueries({queryKey:["/api/company-lists",i?.id]})}}),T=C({mutationFn:async s=>(await x("POST","/api/company-lists",{name:s})).json(),onSuccess:async s=>{g.invalidateQueries({queryKey:["/api/company-lists",i?.id]}),w(""),v(!1),a&&await q.mutateAsync(s.id)}}),F=P.length>0,de=s=>{P.includes(s)?V.mutate(s):q.mutate(s)},J=()=>{const s=D.trim();s&&T.mutate(s)};n.useEffect(()=>{if(!o||i?.id&&U)return;const s=G.find(c=>c.slug===o||c.companyId===o);if(s){k(s.companyId),S(s.companyName);return}if(/^\d+$/.test(o)){k(o);return}const r=o.replace(/-/g," ");b(!0),j(null),(async()=>{try{const u=(await(await fetch("/api/companies/search",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({searchTerm:r})})).json()).companies||[],y=o.replace(/-/g," ").toLowerCase(),f=u.find(l=>Y(l.linkedin_url)===o)||u.find(l=>
1l.name.trim().toLowerCase()===y);f?(k(String(f.id)),S(f.name)):(j("Company not found. Try searching from the Clarity home page."),b(!1))}catch{j("Failed to resolve company. Please try again."),b(!1)}})()},[o,G,U,i?.id]),n.useEffect(()=>{if(!a)return;(async()=>{b(!0),j(null);try{const r=await fetch(`/api/startup-dashboard/company-data?companyId=${a}`);if(!r.ok)throw new Error("Failed to fetch company data");const c=await r.json(),m=c.data||c;ee(m);const u=m.company_name||m.name||d;S(u);const y=m.company_logo_url||"";te(y);const l=Y(m.linkedin_url)||a;ce(l),await le.mutateAsync({companyId:a,companyName:u,slug:l,logo:y})}catch{j("Failed to load company data. Please try again.")}finally{b(!1)}})()},[a]),n.useEffect(()=>{!a||!i?.id||fetch(`/api/memos/unread-count?companyId=${encodeURIComponent(a)}`).then(s=>s.ok?s.json():{count:0}).then(s=>H(s.count??0)).catch(()=>{})},[a,i?.id]),n.useEffect(()=>{if(!t||!a||L||R)return;const s=t.company_name||t.name||d,r=t.description_enriched||t.description||"";B(!0),ke(a,s,r,t.industry||"",t.hq_country||"").then(ae).catch(()=>{}).finally(()=>B(!1))},[t,a]);const me=async()=>{if(t){O(!0);try{let s=document.querySelector("main.flex-1.p-6.space-y-6");if(s||(s=document.querySelector("main.flex-1")),!s)throw new Error("Could not find content to export");const r=document.createElement("div");r.setAttribute("data-export-container","true"),r.style.cssText="position:absolute;left:-9999px;top:0;width:794px;background:white;padding:40px;font-family:system-ui,-apple-system,sans-serif;color:#000;";const c=s.cloneNode(!0),m=document.createElement("div");m.innerHTML=`<div style="display:flex;align-items:center;margin-bottom:20px;padding-bottom:20px;border-bottom:2px solid #e5e7eb;"> 2 ${p?`<img src="${p}" style="width:48px;height:48px;border-radius:50%;margin-right:16px;object-fit:cover;" />`:""} 3 <div><h1 style="font-size:24px;font-weight:bold;margin:0;color:#1f2937;">${d}</h1><p style="color:#6b7280;margin:4px 0 0 0;">Company Dashboard Report</p></div> 4 </div>`,r.appendChild(m),r.appendChild(c),document.body.appendChild(r);const u=await _e(r,{scale:1.5,useCORS:!0,backgroundColor:"#ffffff",logging:!1});document.body.removeChild(r);const y=new Te("p","mm","a4"),f=210,l=u.height*f/u.width;let N=0;const pe=297;for(;N<l;)y.addImage(u.toDataURL("image/png"),"PNG",0,-N,f,l,void 0,"FAST"),N+=pe,N<l&&y.addPage();y.save(`${d.replace(/[^a-z0-9]/gi,"_").toLowerCase()}_dashboard_report.pdf`),h({title:"Export Successful",description:"Dashboard exported as PDF."})}catch{h({title:"Export Error",description:"Failed to export PDF.",variant:"destructive"})}finally{O(!1)}}},ue=async()=>{try{await navigator.clipboard.writeText(window.location.href),h({title:"Link Copied",description:"Dashboard link copied to clipboard."})}catch{h({title:"Copy Error",description:"Failed to copy link.",variant:"destructive"})}};return se?e.jsx("div",{className:"min-h-screen bg-gray-50 flex flex-col",children:e.jsx("div",{className:"flex flex-1 items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-500 mx-auto mb-4"}),e.jsx("p",{className:"text-gray-600",children:"Loading company dataâ¦"})]})})}):$||!t?e.jsx("div",{className:"min-h-screen bg-gray-50 flex flex-col",children:e.jsx("div",{className:"flex flex-1 items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-red-600 mb-4",children:$||"Company data unavailable."}),e.jsx(_,{onClick:()=>M("/clarity"),children:"â Back to Clarity"})]})})}):e.jsxs("div",{className:"flex h-screen",children:[e.jsxs("div",{className:"min-h-screen bg-gray-50 flex-grow w-full",children:[e.jsx("div",{className:"bg-white border-b",children:e.jsx("div",{className:"max-w-7xl mx-auto px-4",children:e.jsxs("div",{className:"flex items-center justify-between h-14",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{onClick:()=>M("/clarity"),className:"flex items-center text-gray-500 hover:text-gray-800 transition-colors text-sm",children:[e.jsx(Ue,{className:"h-4 w-4 mr-1"}),"Clarity"]}),e.jsx("span",{className:"text-gray-300",children:"/"}),e.jsxs("div",{className:"flex items-center gap-2",children:[p&&e.jsx("img",{src:p.startsWith("data:")||p.startsWith("http")?p:`data:image/jpeg;base64,${p}`,alt:d,className:"w-6 h-6 rounded-full object-cover",onError:s=>{s.currentTarget.style.display="none"}}),e.jsx("span",{className:"text-sm font-medium text-gray-800",children:d})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(Be,{open:E,onOpenChange:s=>{re(s),s||(v(!1),w(""))},children:[e.jsx(Oe,{asChild:!0,children:e.jsxs("button",{className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm transition-colors hover:bg-gray-100",title:"Save to list",children:[F?e.jsx(Xe,{className:"h-4 w-4 text-[#7573ff]",fill:"#7573ff"}):e.jsx(X,{className:"h-4 w-4 text-gray-500"}),e.jsx("span",{className:F?"text-[#7573ff] text-xs font-medium":"text-gray-500 text-xs",children:F?"Saved":"Save"})]})}),e.jsxs(ze,{className:"w-64 p-2 shadow-xl",align:"end",sideOffset:6,children:[e.jsx("div",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wide px-2 py-1 mb-1",children:"Save to list"}),e.jsx("div",{className:"space-y-0.5 max-h-52 overflow-y-auto",children:oe.map(s=>
4{const r=P.includes(s.id),c=q.isPending||V.isPending;return e.jsxs("button",{onClick:()=>de(s.id),disabled:c,className:"w-full flex items-center gap-2.5 px-2 py-2 rounded-lg hover:bg-gray-50 text-left transition-colors",children:[e.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center flex-shrink-0 ${r?"bg-[#7573ff]/10":"bg-gray-100"}`,children:s.isBookmarks?e.jsx(X,{className:`h-3.5 w-3.5 ${r?"text-[#7573ff]":"text-gray-400"}`,fill:r?"#7573ff":"none"}):e.jsx(We,{className:`h-3.5 w-3.5 ${r?"text-[#7573ff]":"text-gray-400"}`})}),e.jsx("span",{className:`text-sm flex-1 truncate ${r?"font-medium text-gray-800":"text-gray-600"}`,children:s.name}),r&&e.jsx(je,{className:"h-3.5 w-3.5 text-[#7573ff] flex-shrink-0"})]},s.id)})}),e.jsx("div",{className:"mt-1 pt-1 border-t border-gray-100",children:ne?e.jsxs("div",{className:"flex gap-1 px-2 py-1",children:[e.jsx(Re,{ref:ie,autoFocus:!0,value:D,onChange:s=>w(s.target.value),onKeyDown:s=>{s.key==="Enter"&&J(),s.key==="Escape"&&(v(!1),w(""))},placeholder:"List name...",className:"h-7 text-xs flex-1"}),e.jsx(_,{size:"sm",className:"h-7 px-2 bg-[#7573ff] hover:bg-[#6461ff] text-white text-xs",onClick:J,disabled:T.isPending||!D.trim(),children:T.isPending?e.jsx(we,{className:"h-3 w-3 animate-spin"}):"Add"})]}):e.jsxs("button",{onClick:()=>v(!0),className:"w-full flex items-center gap-2 px-2 py-2 rounded-lg hover:bg-gray-50 text-[#7573ff] text-sm transition-colors",children:[e.jsx(Ve,{className:"h-4 w-4"}),"New list"]})})]})]}),z&&e.jsxs(_,{size:"sm",className:"h-8 text-sm bg-[#7573ff] hover:bg-[#7573ff] text-white relative",onClick:()=>{K(!1)},children:["See Memo",Q>0&&e.jsx("span",{style:{position:"absolute",top:-6,right:-6,background:"#e53e3e",color:"white",borderRadius:"50%",width:18,height:18,display:"flex",alignItems:"center",justifyContent:"center",fontSize:11,fontWeight:700,lineHeight:1},children:Q})]}),e.jsxs(ve,{children:[e.jsx(Ne,{asChild:!0,children:e.jsxs(_,{size:"sm",className:"h-8 text-sm bg-[#7573ff] hover:bg-[#7573ff] text-white",disabled:A,children:[e.jsx(Se,{className:"h-4 w-4 mr-1"}),A?"Exportingâ¦":"Share"]})}),e.jsxs(Ce,{align:"end",className:"w-56",children:[e.jsxs(Z,{onClick:ue,className:"cursor-pointer",children:[e.jsx(Je,{className:"h-4 w-4 mr-2"}),"Copy Dashboard Link"]}),e.jsxs(Z,{onClick:me,className:"cursor-pointer",disabled:A,children:[e.jsx(Ze,{className:"h-4 w-4 mr-2"}),"Download Dashboard as PDF"]})]})]})]})]})})}),e.jsxs("div",{className:"flex",children:[e.jsx(Ke,{sidebarProps:{companyId:a||"",logo:t.company_logo_url||"",companyName:t.company_name||t.name||"",website:t.websites_main||"",emails:t.emails||[],phone:t.company_phone_numbers||[],address:t.hq_location||"",industry:t.industry||"",founded:t.founded_year||"",description:t.description_enriched||"",keyExecutives:t.key_executives||[],scoreByMonth:t.product_reviews_aggregate_score,fundingRounds:t.funding_rounds||[],linkedin_url:Array.isArray(t.linkedin_url)?t.linkedin_url[0]||"":t.linkedin_url||"",twitter_url:Array.isArray(t.twitter_url)?t.twitter_url[0]||"":t.twitter_url||"",discord_url:Array.isArray(t.discord_url)?t.discord_url[0]||"":t.discord_url||"",facebook_url:Array.isArray(t.facebook_url)?t.facebook_url[0]||"":t.facebook_url||"",instagram_url:Array.isArray(t.instagram_url)?t.instagram_url[0]||"":t.instagram_url||"",pinterest_url:Array.isArray(t.pinterest_url)?t.pinterest_url[0]||"":t.pinterest_url||"",tiktok_url:Array.isArray(t.tiktok_url)?t.tiktok_url[0]||"":t.tiktok_url||"",youtube_url:Array.isArray(t.youtube_url)?t.youtube_url[0]||"":t.youtube_url||"",github_url:Array.isArray(t.github_url)?t.github_url[0]||"":t.github_url||"",reddit_url:Array.isArray(t.reddit_url)?t.reddit_url[0]||"":t.reddit_url||"",crunchbase_url:Array.isArray(t.crunchbase_url)?t.crunchbase_url[0]||"":t.crunchbase_url||""}}),e.jsxs("main",{className:"flex-1 p-6 space-y-6",children:[e.jsx("div",{className:"gap-6",children:e.jsx(Qe,{CompanyData:t})}),e.jsx("div",{className:"lg:flex gap-6",children:e.jsx("div",{className:"lg:w-full",children:e.jsx(Le,{companyData:t})})}),e.jsx(Ae,{companyId:a||"",hqCountry:t.hq_country}),t.hq_country?.toLowerCase?.()==="india"&&e.jsx(Ee,{source:t}),e.jsxs(Fe,{className:"rounded-2xl",children:[e.jsx(Ie,{children:e.jsx(Me,{children:"Competition Landscape"})}),e.jsx($e,{children:R?e.jsx("div",{className:"w-full h-[650px] bg-white rounded-xl shadow-lg border border-slate-200 flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-indigo-500 mx-auto mb-4"}),e.jsx("p",{className:"text-slate-500",children:"Analyzing competitive landscapeâ¦"})]})}
4):L?e.jsx(De,{data:L}):e.jsx("div",{className:"w-full h-[650px] bg-white rounded-xl shadow-lg border border-slate-200 flex items-center justify-center",children:e.jsx("p",{className:"text-slate-400",children:"Competition data unavailable"})})})]}),e.jsx(He,{fundingRounds:t.funding_rounds}),e.jsx(Pe,{companyData:t}),e.jsx(Ge,{companyData:t})]})]})]}),e.jsx(qe,{collapsed:z,setCollapsed:K,companyId:a||"",companyName:d,companySlug:W||o||a||"",onOpened:()=>H(0)})]})}export{Ct 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.