1import{j as e,r as m,M as je,h as be,G as H,n as G,D as Ze,aV as Je,ap as Xe,V as ge,x as K,y as Y,ao as Ye,F as es,t as ss,s as ts,a3 as rs}from"./index-B_KAAQRW.js";import{A as ls}from"./arrow-left-UC0--JGs.js";import{P as fe}from"./phone-BfpOt-qN.js";import{B as ee}from"./bookmark-C_PmajsZ.js";import{M as ve}from"./message-square-CYFJ0Piz.js";import{S as Le}from"./shield-BPZ5WDw7.js";import{C as se}from"./clock-YVp-5kfK.js";import{T as Ne}from"./trending-up-DL7o_FOp.js";import{M as te}from"./mail-D74WUkx5.js";import{E as as}from"./external-link-CaCnbLs9.js";import{S as ze}from"./send-BB5fwkiS.js";import{L as ke}from"./linkedin-DYm-os3b.js";import{B as is}from"./briefcase-est9p3tI.js";import{X as os}from"./x-circle-B4Cgrcvg.js";const x=s=>({width:s,height:s,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"}),B=({size:s=16,className:t=""})=>e.jsxs("svg",{...x(s),className:t,children:[e.jsx("circle",{cx:"10.5",cy:"10.5",r:"6.5",stroke:"currentColor",strokeWidth:"2.2"}),e.jsx("path",{d:"M15.5 15.5L20.5 20.5",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round"})]}),O=({size:s=16,className:t=""})=>e.jsxs("svg",{...x(s),className:t,children:[e.jsx("path",{d:"M12 2l1.8 5.4L19 9l-5.2 1.6L12 16l-1.8-5.4L5 9l5.2-1.6L12 2z",fill:"currentColor"}),e.jsx("path",{d:"M18 14l.9 2.7L21.6 17.6l-2.7.9L18 21.2l-.9-2.7-2.7-.9 2.7-.9L18 14z",fill:"currentColor",opacity:"0.6"}),e.jsx("path",{d:"M6 16l.6 1.8 1.8.6-1.8.6L6 20.8l-.6-1.8L3.6 18.4l1.8-.6L6 16z",fill:"currentColor",opacity:"0.4"})]}),ns=({size:s=16,className:t=""})=>e.jsxs("svg",{...x(s),className:t,children:[e.jsx("rect",{x:"4",y:"2",width:"16",height:"20",rx:"2.5",stroke:"currentColor",strokeWidth:"1.8"}),e.jsx("path",{d:"M8 8h8M8 12h8M8 16h4",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"}),e.jsx("rect",{x:"4",y:"2",width:"16",height:"5",rx:"2.5",fill:"currentColor",opacity:"0.12"})]}),cs=({size:s=16,className:t=""})=>e.jsxs("svg",{...x(s),className:t,children:[e.jsx("path",{d:"M12 3v12M12 15l-3.5-3.5M12 15l3.5-3.5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M5 18h14",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}),ds=({size:s=16,className:t=""})=>e.jsx("svg",{...x(s),className:t,children:e.jsx("path",{d:"M6 9l6 6 6-6",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round"})}),we=({size:s=16,className:t=""})=>e.jsx("svg",{...x(s),className:t,children:e.jsx("path",{d:"M9 6l6 6-6 6",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round"})}),re=({size:s=16,className:t="",fill:a})=>e.jsx("svg",{...x(s),className:t,children:e.jsx("path",{d:"M12 2.5l2.8 5.7 6.2.9-4.5 4.4 1.1 6.2L12 16.9l-5.6 2.8 1.1-6.2L3 9.1l6.2-.9L12 2.5z",fill:a||"currentColor",stroke:"currentColor",strokeWidth:"1",strokeLinejoin:"round"})}),ye=({size:s=16,className:t=""})=>e.jsxs("svg",{...x(s),className:t,children:[e.jsx("path",{d:"M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7z",fill:"currentColor",opacity:"0.15",stroke:"currentColor",strokeWidth:"1.8"}),e.jsx("circle",{cx:"12",cy:"9",r:"2.5",fill:"currentColor"})]}),hs=({size:s=16,className:t=""})=>e.jsx("svg",{...x(s),className:t,children:e.jsx("path",{d:"M5.2 3h4l1.5 4.5-2.3 1.3a13 13 0 006.8 6.8l1.3-2.3L21 14.8v4a2 2 0 01-2 2A17 17 0 013 4.8a2 2 0 012-1.8z",fill:"currentColor",opacity:"0.15",stroke:"currentColor",strokeWidth:"1.6",strokeLinejoin:"round"})}),le=({size:s=16,className:t=""})=>e.jsxs("svg",{...x(s),className:t,children:[e.jsx("circle",{cx:"12",cy:"12",r:"9",stroke:"currentColor",strokeWidth:"1.8"}),e.jsx("ellipse",{cx:"12",cy:"12",rx:"4",ry:"9",stroke:"currentColor",strokeWidth:"1.4"}),e.jsx("path",{d:"M3.5 9h17M3.5 15h17",stroke:"currentColor",strokeWidth:"1.2"})]}),ae=({size:s=16,className:t=""})=>e.jsxs("svg",{...x(s),className:t,children:[e.jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"2.5",stroke:"currentColor",strokeWidth:"1.8",fill:"
1currentColor",fillOpacity:"0.08"}),e.jsx("path",{d:"M3.5 6.5l8.5 6 8.5-6",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"})]}),us=({size:s=16,className:t=""})=>e.jsx("svg",{...x(s),className:t,children:e.jsx("path",{d:"M5 4.5A2.5 2.5 0 017.5 2h9A2.5 2.5 0 0119 4.5V22l-7-4.5L5 22V4.5z",fill:"currentColor",opacity:"0.12",stroke:"currentColor",strokeWidth:"1.8",strokeLinejoin:"round"})}),Me=({size:s=16,className:t=""})=>e.jsxs("svg",{...x(s),className:t,children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"3",stroke:"currentColor",strokeWidth:"1.6",fill:"currentColor",fillOpacity:"0.08"}),e.jsx("path",{d:"M8 11v5M8 8v.01M12 16v-4a2 2 0 014 0v4",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"})]}),P=({size:s=16,className:t=""})=>e.jsxs("svg",{...x(s),className:t,children:[e.jsx("path",{d:"M4 12a8 8 0 0114.5-4.6L21 10",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M20 12a8 8 0 01-14.5 4.6L3 14",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M21 4v6h-6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M3 20v-6h6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),ms=({size:s=16,className:t=""})=>e.jsxs("svg",{...x(s),className:t,children:[e.jsx("circle",{cx:"9",cy:"7",r:"3.5",fill:"currentColor",opacity:"0.15",stroke:"currentColor",strokeWidth:"1.6"}),e.jsx("path",{d:"M2 20c0-3.3 2.7-6 6-6h2c3.3 0 6 2.7 6 6",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"}),e.jsx("circle",{cx:"17",cy:"8",r:"2.5",stroke:"currentColor",strokeWidth:"1.4"}),e.jsx("path",{d:"M18 14c2.2.5 4 2.5 4 5",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"})]}),We=({size:s=16,className:t=""})=>e.jsxs("svg",{...x(s),className:t,children:[e.jsx("circle",{cx:"12",cy:"12",r:"9",stroke:"currentColor",strokeWidth:"1.6"}),e.jsx("circle",{cx:"12",cy:"12",r:"5.5",stroke:"currentColor",strokeWidth:"1.4"}),e.jsx("circle",{cx:"12",cy:"12",r:"2",fill:"currentColor"})]}),ps=({size:s=16,className:t=""})=>e.jsx("svg",{...x(s),className:t,children:e.jsx("path",{d:"M13 2L4.5 13H12l-1 9 8.5-11H12l1-9z",fill:"currentColor",opacity:"0.15",stroke:"currentColor",strokeWidth:"1.6",strokeLinejoin:"round"})}),xs=({size:s=16,className:t=""})=>e.jsxs("svg",{...x(s),className:t,children:[e.jsx("path",{d:"M12 22c4-2 7-5 7-10 0-4-2-7-4-9l-1.5 3c-.6 1.2-2.4 1.2-3 0L9 3C7 5 5 8 5 12c0 5 3 8 7 10z",fill:"currentColor",opacity:"0.15",stroke:"currentColor",strokeWidth:"1.6",strokeLinejoin:"round"}),e.jsx("path",{d:"M12 22c1.5-1 3-2.5 3-5s-1.5-4-3-5c-1.5 1-3 2.5-3 5s1.5 4 3 5z",fill:"currentColor",opacity:"0.3"})]}),ie=({size:s=16,className:t=""})=>e.jsxs("svg",{...x(s),className:t,children:[e.jsx("path",{d:"M10.3 3.2L1.8 18.5a2 2 0 001.7 3h17a2 2 0 001.7-3L13.7 3.2a2 2 0 00-3.4 0z",fill:"currentColor",opacity:"0.1",stroke:"currentColor",strokeWidth:"1.6",strokeLinejoin:"round"}),e.jsx("path",{d:"M12 9v4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}),e.jsx("circle",{cx:"12",cy:"16.5",r:"1",fill:"currentColor"})]}),js=({size:s=16,className:t=""})=>e.jsx("svg",{...x(s),className:t,children:e.jsx("path",{d:"M6 6l12 12M18 6L6 18",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round"})}),bs=({size:s=16,className:t=""})=>e.jsxs("svg",{...x(s),className:t,children:[e.jsx("path",{d:"M4 6h3M11 6h9M4 12h9M17 12h3M4 18h5M13 18h7",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round"}),e.jsx("circle",{cx:"8.5",cy:"6",r:"2",fill:"currentColor",opacity:"0.2",stroke:"currentColor",strokeWidth:"1.4"}),e.jsx("circle",{cx:"15.5",cy:"12",r:"2",fill:"currentColor",opacity:"0.2",stroke:"currentColor",strokeWidth:"1.4"}),e.jsx("circle",{cx:"11",cy:"18",r:"2",fill:"currentColor",opacity:"0.2",stroke:"currentColor",strokeWidth:"1.4"})]}),Ie=({size:s=16,className:t=""})=>e.jsxs("svg",{...x(s),className:t,children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"3",fill:"currentColor",opacity:"0.18",stroke:"currentColor",strokeWidth:"1.6"}),e.jsx("path",{d:"M8 12.5l2.8 2.8L16 9",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round"})]}),Ue=({size:s=16,className:t=""})=>e.jsx("svg",{...x(s),className:t,children:e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"3",stroke:"currentColor",strokeWidth:"1.6"})}),gs=({size:s=16,className:t=""})=>e.jsxs("svg",{...x(s),className:t,children:[e.jsx("rect",{x:"3",y:"12",width:"4",height:"9",rx:"1",fill:"currentColor",opacity:"0.3",stroke:"currentColor",strokeWidth:"1.2"}
1),e.jsx("rect",{x:"10",y:"6",width:"4",height:"15",rx:"1",fill:"currentColor",opacity:"0.2",stroke:"currentColor",strokeWidth:"1.2"}),e.jsx("rect",{x:"17",y:"3",width:"4",height:"18",rx:"1",fill:"currentColor",opacity:"0.15",stroke:"currentColor",strokeWidth:"1.2"})]}),fs=({size:s=16,className:t=""})=>e.jsxs("svg",{...x(s),className:t,children:[e.jsx("rect",{x:"4",y:"3",width:"16",height:"19",rx:"2",stroke:"currentColor",strokeWidth:"1.6",fill:"currentColor",fillOpacity:"0.06"}),e.jsx("rect",{x:"8",y:"7",width:"2.5",height:"2.5",rx:"0.5",fill:"currentColor",opacity:"0.5"}),e.jsx("rect",{x:"13.5",y:"7",width:"2.5",height:"2.5",rx:"0.5",fill:"currentColor",opacity:"0.5"}),e.jsx("rect",{x:"8",y:"12.5",width:"2.5",height:"2.5",rx:"0.5",fill:"currentColor",opacity:"0.5"}),e.jsx("rect",{x:"13.5",y:"12.5",width:"2.5",height:"2.5",rx:"0.5",fill:"currentColor",opacity:"0.5"}),e.jsx("rect",{x:"10",y:"18",width:"4",height:"4",rx:"0.5",fill:"currentColor",opacity:"0.3"})]}),vs=({size:s=16,className:t=""})=>e.jsxs("svg",{...x(s),className:t,children:[e.jsx("path",{d:"M12 2a10 10 0 00-8.6 15l-1.2 4.2 4.3-1.1A10 10 0 1012 2z",stroke:"currentColor",strokeWidth:"1.6",fill:"currentColor",fillOpacity:"0.06"}),e.jsx("path",{d:"M9 10c0-.6.4-1.2 1-1.5.3-.2.7 0 .8.3l.4 1c.1.2 0 .5-.2.6l-.3.2c-.1.1-.1.3 0 .5.4.7 1 1.3 1.7 1.7.2.1.4.1.5 0l.2-.3c.1-.2.4-.3.6-.2l1 .4c.3.1.5.5.3.8-.3.6-.9 1-1.5 1-2.5 0-4.5-2-4.5-4.5z",fill:"
1currentColor"})]}),Ns=({size:s=16,className:t=""})=>e.jsxs("svg",{...x(s),className:t,children:[e.jsx("circle",{cx:"12",cy:"12",r:"9",stroke:"currentColor",strokeWidth:"1.6"}),e.jsx("path",{d:"M16.2 7.8l-2.4 5.8-5.8 2.4 2.4-5.8 5.8-2.4z",fill:"currentColor",opacity:"0.2",stroke:"currentColor",strokeWidth:"1.2",strokeLinejoin:"round"}),e.jsx("circle",{cx:"12",cy:"12",r:"1.2",fill:"currentColor"})]}),ks=["Score","Issues","Contact","Website","Pitch","Activity"],ws=[{icon:es,label:"Proposals",count:0},{icon:is,label:"Case Studies",count:0},{icon:Le,label:"Audits",count:0},{icon:H,label:"Generated Websites",count:0},{icon:ze,label:"Follow-up Sequences",count:0}],ys=({value:s,size:t=90,stroke:a=7,color:n})=>{const d=Math.max(0,Math.min(100,Number(s)||0)),p=(t-a)/2,i=2*Math.PI*p,o=i-d/100*i;return e.jsxs("svg",{width:t,height:t,className:"ld-score-ring","aria-label":`Score ${d} out of 100`,children:[e.jsx("circle",{cx:t/2,cy:t/2,r:p,fill:"none",stroke:"rgba(255,255,255,0.06)",strokeWidth:a}),e.jsx("circle",{cx:t/2,cy:t/2,r:p,fill:"none",stroke:n,strokeWidth:a,strokeLinecap:"round",strokeDasharray:i,strokeDashoffset:o,style:{transform:"rotate(-90deg)",transformOrigin:"50% 50%",transition:"stroke-dashoffset 1s ease"}}),e.jsx("text",{x:"50%",y:"50%",textAnchor:"middle",dominantBaseline:"central",fill:"#f1f5f9",fontSize:t*.32,fontWeight:800,children:d})]})},T=({icon:s,value:t,label:a,color:n="#f1f5f9"})=>e.jsxs("div",{className:"ld-metric-card",children:[s&&e.jsx(s,{size:18,className:"ld-metric-icon",style:{color:n}}),e.jsx("span",{className:"ld-metric-value",style:{color:n},children:t}),e.jsx("span",{className:"ld-metric-label",children:a})]}),C=({label:s,passed:t,value:a})=>e.jsxs("div",{className:"ld-seo-check-row",children:[e.jsx("span",{className:"ld-seo-check-label",children:s}),e.jsxs("span",{className:"ld-seo-check-status",children:[a&&e.jsx("span",{className:"ld-seo-check-value",children:a}),t?e.jsx(K,{size:15,className:"ld-check-pass"}):e.jsx(os,{size:15,className:"ld-check-fail"})]})]}),_=({label:s,value:t,color:a="#64748b"})=>e.jsxs("div",{className:"ld-authority-stat",children:[e.jsx("div",{className:"ld-authority-bar",style:{background:a}}),e.jsx("span",{className:"ld-authority-label",children:s}),t!==void 0&&e.jsx("span",{className:"ld-score-card-label",children:t})]}),Cs=({lead:s,isSaved:t=!1,onToggleSave:a,onBack:n})=>{const[d,p]=m.useState("Score"),[i,o]=m.useState(""),l=m.useMemo(()=>Ss(s),[s]),j=$s(l.overallScore),k=m.useMemo(()=>ks.map(u=>u==="Issues"?`Issues (${l.issues.length})`:u),[l.issues.length]),g=(u,b)=>{var f;u&&((f=navigator.clipboard)==null||f.writeText(u).catch(()=>{}),o(b),window.setTimeout(()=>o(""),1400))},v=u=>{u&&window.open(u,"_blank","noopener,noreferrer")},W=()=>{const u=new Blob([Bs(l)],{type:"text/plain;charset=utf-8"}),b=URL.createObjectURL(u),f=document.createElement("a");f.href=b,f.download=`${Ts(l.name)}-lead-report.txt`,document.body.appendChild(f),f.click(),document.body.removeChild(f),URL.revokeObjectURL(b)};return e.jsxs("div",{className:"ld-root",children:[e.jsxs("button",{className:"ld-back-btn",onClick:n,type:"button",children:[e.jsx(ls,{size:16})," Back to leads"]}),e.jsxs("div",{className:"ld-header",children:[e.jsxs("div",{className:"ld-header-left",children:[e.jsx("h1",{className:"ld-business-name",children:l.name}),e.jsxs("div",{className:"ld-header-meta",children:[e.jsxs("span",{className:"ld-meta-row",children:[e.jsx(je,{size:13})," ",l.location||"Location unavailable"]}),e.jsxs("span",{className:"ld-meta-row",children:[e.jsx(fe,{size:13})," ",l.phone||"No phone listed"]})]})]}),e.jsxs("div",{className:"ld-header-right",children:[e.jsxs("button",{className:"ld-save-btn",type:"button",onClick:a,children:[e.jsx(ee,{size:14})," ",t?"Saved":"Save Lead"]}),e.jsx("span",{className:"ld-score-pill",style:{background:`${j}22`,color:j,borderColor:`${j}44`},children:l.scoreLabel})]})]}),e.jsxs("div",{className:"ld-quick-actions",children:[e.jsxs("button",{className:"ld-more-actions",type:"button",onClick:()=>g(l.pitch,"pitch-menu"),children:[i==="pitch-menu"?"Pitch copied":"Copy pitch"," ",e.jsx(be,{size:14})]}),e.jsxs("div",{className:"ld-action-pills",children:[e.jsxs("button",{className:"ld-pill ld-pill-default",type:"button",disabled:!l.websiteUrl,onClick:()=>v(l.websiteUrl),children:[e.jsx(H,{size:13})," Visit Website"]}),e.jsxs("button",{className:"ld-pill ld-pill-default",type:"button",onClick:()=>v(l.mapsUrl),children:[e.jsx(je,{size:13})," Maps"]}),e.jsxs("button",{className:"ld-pill ld-pill-whatsapp",type:"button",disabled:!l.whatsappUrl,onClick:()=>v(l.whatsappUrl),children:[e.jsx(ve,{size:13})," WhatsApp"]}),e.jsxs("button",{className:"ld-pill ld-pill-pitch",type:"button",onClick:()=>g(l.pitch,"pitch"),children:[e.jsx(G,{size:13})," ",i==="pitch"?"Copied":"Copy AI Pitch"]}),e.jsxs("button",{className:"ld-pill ld-pill-default",type:"button",onClick:W,children:[e.jsx(Ze,{size:13})," Download Report ",e.jsx(be,{size:12})]})]})]}),e.jsx("div",{className:"ld-tabs",children:k.map(u=>{const b=u.startsWith("Issues")?"Issues":u;return e.jsx("button",{className:`ld-tab ${d===b?"ld-tab-active":""}`,onClick:()=>p(b),type:"button",children:u},u)})}),e.jsxs("div",{className:"ld-body",children:[e.jsxs("div",{className:"ld-main",children:[d==="Score"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"ld-card",children:[e.jsxs("div",{className:"ld-card-header",children:[e.jsx(Le,{size:16,className:"ld-card-icon"})," Site signals"]}),e.jsxs("div",{className:"ld-site-signal-banner",children:[e.jsxs("div",{className:"ld-signal-text",children:[e.jsxs("strong",{children:[e.jsx(ee,{size:14})," ",t?"Lead saved":"Save this lead"]}),e.jsx("span",{children:l.siteSignalSummary})]}),e.jsxs("button",{className:"ld-signal-save-btn",type:"button",onClick:a,children:[e.jsx(ee,{size:13})," ",t?"Saved":"Save lead"]})]})]}),e.jsxs("div",{className:"ld-scores-grid",children:[e.jsxs("div",{className:"ld-score-card ld-score-main",children:[e.jsx(ys,{value:l.overallScore,size:80,color:j}),e.jsx("span",{className:"ld-score-card-label",children:"Overall"}),e.jsx("span",{className:"ld-score-badge-sm",style:{color:j,background:`${j}1a`},children:l.scoreLabel}),e.jsxs("span",{className:"ld-score-analyzed",children:[e.jsx(se,{size:11})," Analyzed now"]})]}),e.jsx(T,{icon:H,value:l.websiteScore,label:"Website",color:"#3b82f6"}),e.jsx(T,{icon:Ne,value:l.seoScore,label:"SEO",color:"#22c55e"}),e.jsx(T,{icon:Je,value:l.contactScore,label:"Contact",color:"#f1f5f9"}),e.jsx(T,{icon:Xe,value:l.reviewCount,label:"Reviews",color:"#eab308"})]}),e.jsxs("div",{className:"ld-card",children:[e.jsxs("div",{className:"ld-card-header",children:[e.jsx(Ne,{size:16,className:"ld-card-icon",style:{color:"#22c55e"}})," SEO Authority",e.jsxs("span",{className:"ld-just-now",children:[e.jsx(se,{size:11})," live lead data"]})]}),e.jsxs("div",{className:"ld-authority-grid",children:[e.jsx(_,{label:"Website",value:l.website?"Found":"Missing",color:l.website?"#22c55e":"#ef4444"}),e.jsx(_,{label:"Direct Email",value:l.primaryEmail?"Found":"Missing",color:l.primaryEmail?"#22c55e":"#64748b"}),e.jsx(_,{label:"LinkedIn",value:l.linkedinUrl?"Found":"Search",color:l.linkedinUrl?"#38bdf8":"#64748b"}),e.jsx(_,{label:"GBP",value:l.mapsUrl?"Found":"Search",color:"#eab308"})]}),e.jsxs("div",{className:"ld-seo-checks-grid",children:[e.jsx(C,{label:"Website listed",passed:!!l.websiteUrl}),e.jsx(C,{label:"Direct email discovered",passed:!!l.primaryEmail}),e.jsx(C,{label:"Phone listed",passed:!!l.phone}),e.jsx(C,{label:"Review base",passed:l.reviewCount>=20,value:`${l.reviewCount} reviews`}),e.jsx(C,{label:"Rating strength",passed:!!(l.rating&&l.rating>=4),value:l.rating?`${l.rating} stars`:"No rating"})]})]})]}),d==="Issues"&&e.jsxs("div",{className:"ld-card",children:[e.jsxs("div",{className:"ld-card-header",children:[e.jsx(ge,{size:16,className:"ld-card-icon",style:{color:"#eab308"}})," Lead issues"]}),l.issues.length?e.jsx("div",{className:"ld-seo-checks-grid",children:l.issues.map(u=>e.jsx(C,{label:u,passed:!1},u))}):e.jsx("p",{className:"ld-muted-text",children:"No major pitch issues were detected from the available Places data."})]}),d==="Contact"&&e.jsxs("div",{className:"ld-card",children:[e.jsxs("div",{className:"ld-card-header",children:[e.jsx(te,{size:16,className:"ld-card-icon"})," Contact options"]}),l.primaryEmail?e.jsxs("div",{className:"ld-email-row",children:[e.jsx("span",{className:"ld-email-addr",children:l.primaryEmail}),e.jsxs("span",{className:"ld-email-status",children:[e.jsx(K,{size:12})," Direct email"]}),e.jsx("button",{className:"ld-copy-btn",onClick:()=>g(l.primaryEmail,"email"),type:"button",children:i==="email"?e.jsxs(e.Fragment,{children:[e.jsx(K,{size:12})," Copied"]}):e.jsxs(e.Fragment,{children:[e.jsx(Y,{size:12})," Copy"]})}),e.jsxs("button",{className:"ld-copy-btn",onClick:()=>v(l.emailUrl),type:"button",children:[e.jsx(te,{size:12})," Email"]})]}):e.jsxs("div",{className:"ld-email-warn",children:[e.jsx(ge,{size:14})," No direct email was discovered for this lead."]}),e.jsxs("div",{className:"ld-email-row",children:[e.jsx("span",{className:"ld-email-addr",children:l.phone||"No phone listed"}),e.jsx("span",{className:"ld-email-status",children:l.phone?"Phone":"Missing"}),e.jsx("button",{className:"ld-copy-btn",onClick:()=>g(l.phone,"phone"),disabled:!l.phone,type:"button",children:i==="phone"?e.jsxs(e.Fragment,{children:[e.jsx(K,{size:12})," Copied"]}):e.jsxs(e.Fragment,{children:[e.jsx(Y,{size:12})," Copy"]})}),e.jsxs("button",{className:"ld-copy-btn",onClick:()=>v(l.phoneUrl),disabled:!l.phoneUrl,type:"button",children:[e.jsx(fe,{size:12})," Call"]})]}),e.jsxs("div",{className:"ld-built-with",children:["Source: ",e.jsx("span",{className:"ld-tech-badge",children:"Google Places"})]})]}),d==="Website"&&e.jsxs("div",{className:"ld-two-col",children:[e.jsxs("div",{className:"ld-card",children:[e.jsxs("div",{className:"ld-card-header",children:[e.jsx(H,{size:16,className:"ld-card-icon",style:{color:"#3b82f6"}})," Website"]}),e.jsx(C,{label:"Website found",passed:!!l.websiteUrl,value:l.website||"Missing"}),e.jsx(C,{label:"Contact discovery",passed:!!l.primaryEmail,value:l.emailStatus}),e.jsxs("button",{className:"ld-outline-btn",type:"button",disabled:!l.websiteUrl,onClick:()=>v(l.websiteUrl),children:[e.jsx(as,{size:13})," Open website"]})]}),e.jsxs("div",{className:"ld-card",children:[e.jsxs("div",{className:"ld-card-header",children:[e.jsx(Ye,{size:16,className:"ld-card-icon",style:{color:"#eab308"}})," Suggested angles"]}),e.jsx("div",{className:"ld-seo-checks-grid",children:l.pitchServices.map(u=>e.jsx(C,{label:u,passed:!0},u))})]})]}),d==="Pitch"&&e.jsxs("div",{className:"ld-card",children:[e.jsxs("div",{className:"ld-card-header",children:[e.jsx(G,{size:16,className:"ld-card-icon",style:{color:"#a85
15f7"}})," Pitch"]}),e.jsx("p",{className:"ld-sidebar-bold",children:l.pitch}),e.jsx("p",{className:"ld-sidebar-muted",children:l.outreachMessage}),e.jsxs("div",{className:"ld-action-pills",children:[e.jsxs("button",{className:"ld-pill ld-pill-pitch",type:"button",onClick:()=>g(l.outreachMessage,"message"),children:[e.jsx(Y,{size:13})," ",i==="message"?"Copied":"Copy message"]}),e.jsxs("button",{className:"ld-pill ld-pill-whatsapp",type:"button",disabled:!l.whatsappUrl,onClick:()=>v(l.whatsappUrl),children:[e.jsx(ve,{size:13})," WhatsApp"]}),e.jsxs("button",{className:"ld-pill ld-pill-default",type:"button",disabled:!l.emailUrl,onClick:()=>v(l.emailUrl),children:[e.jsx(te,{size:13})," Email"]})]})]}),d==="Activity"&&e.jsxs("div",{className:"ld-card",children:[e.jsxs("div",{className:"ld-card-header",children:[e.jsx(se,{size:16,className:"ld-card-icon"})," Activity"]}),e.jsxs("div",{className:"ld-rating-notes",children:[e.jsxs("div",{className:"ld-note-row",children:["Lead opened ",e.jsx("span",{children:"Just now"})]}),e.jsxs("div",{className:"ld-note-row",children:["Saved status ",e.jsx("span",{children:t?"Saved":"Not saved"})]}),e.jsxs("div",{className:"ld-note-row",children:["Last search order ",e.jsxs("span",{children:["#",l.searchOrder||"-"]})]})]})]})]}),e.jsxs("div",{className:"ld-sidebar",children:[e.jsxs("div",{className:"ld-card",children:[e.jsxs("div",{className:"ld-card-header",children:[e.jsx(G,{size:16,className:"ld-card-icon",style:{color:"#eab308"}})," Outreach"]}),e.jsx("p",{className:"ld-sidebar-bold",children:l.pitch}),e.jsx("p",{className:"ld-sidebar-muted",children:l.outreachMessage}),e.jsxs("button",{className:"ld-campaign-btn",type:"button",onClick:()=>g(l.outreachMessage,"campaign"),children:[e.jsx(ze,{size:13})," ",i==="campaign"?"Message copied":"Copy outreach"]})]}),e.jsxs("div",{className:"ld-card",children:[e.jsxs("div",{className:"ld-card-header",children:[e.jsx(ke,{size:16,className:"ld-card-icon",style:{color:"#38bdf8"}})," LinkedIn"]}),e.jsx("p",{className:"ld-sidebar-muted",children:l.linkedinUrl?"A LinkedIn profile was discovered for this lead.":"No LinkedIn profile was found, but you can search by business name."}),e.jsxs("button",{className:"ld-outline-btn",type:"button",onClick:()=>v(l.linkedinUrl||l.linkedinSearchUrl),children:[e.jsx(ke,{size:13})," ",l.linkedinUrl?"Open LinkedIn":"Search LinkedIn"]})]}),e.jsxs("div",{className:"ld-sidebar-note",children:[e.jsx("span",{className:"ld-contact-dot"})," ",l.primaryEmail?"Direct email available":"Direct email not found"]}),e.jsxs("div",{className:"ld-card",children:[e.jsxs("div",{className:"ld-card-header",children:[e.jsx(G,{size:16,className:"ld-card-icon"})," Connections"]}),ws.map(u=>e.jsxs("div",{className:"ld-connection-row",children:[e.jsx(ss,{size:14,className:"ld-conn-chevron"}),e.jsx(u.icon,{size:15,className:"ld-conn-icon"}),e.jsx("span",{className:"ld-conn-label",children:u.label}),e.jsx("span",{className:"ld-conn-count",children:u.count})]},u.label))]})]})]})]})};function Ss(s={}){const t=s.name||"Unnamed business",a=s.location||"",n=s.phone||"",d=s.websiteUrl||"",p=s.website||Gs(d),i=s.mapsUrl||Ps(s),o=s.emailAddress||"",l=s.pitch||"Local SEO + Review Growth",j=Array.isArray(s.needs)?s.needs:[],k=typeof s.rating=="number"?s.rating:null,g=Number.isFinite(s.reviewCount)?s.reviewCount:0,v=q(Number(s.score)||0,0,100),W=Ls({needs:j,rating:k,reviewCount:g,websiteUrl:d,phone:n,primaryEmail:o}),u=j.length?j.map(f=>zs(f)):[l],b=Es({name:t,pitch:l});return{...s,name:t,location:a,phone:n,website:p,websiteUrl:d,mapsUrl:i,primaryEmail:o,pitch:l,needs:j,rating:k,reviewCount:g,overallScore:v,scoreLabel:`${Us(s.priority)} - ${v}/100`,websiteScore:Ms({websiteUrl:d,primaryEmail:o}),seoScore:Ws({needs:j,rating:k,reviewCount:g,websiteUrl:d}),contactScore:Is({phone:n,primaryEmail:o,websiteUrl:d}),issues:W,pitchServices:[...new Set(u)],siteSignalSummary:d?"Website and contact signals are based on the current Google Places result and lightweight contact discovery.":"No website was found in Google Places, making this a stronger website-build pitch.",emailStatus:o?"Found":s.email==="searching"?"Searching":"Not found",whatsappUrl:Rs(n,b),emailUrl:o?As(o,t,b):"",phoneUrl:Os(n),linkedinUrl:s.linkedinUrl||"",linkedinSearchUrl:Fs({name:t,location:a}),outreachMessage:b}}function Ls({needs:s,rating:t,reviewCount:a,websiteUrl:n,phone:d,primaryEmail:p}){const i=[...s];return!n&&!i.includes("No Website")&&i.push("No Website"),!d&&!i.includes("No Phone Listed")&&i.push("No Phone Listed"),p||i.push("No Direct Email"),!t&&!i.includes("No Rating")&&i.push("No Rating"),a<20&&!i.some(o=>o.includes("Reviews")||o.includes("Zero"))&&i.push("Few Reviews"),[...new Set(i)]}function zs(s){return s.includes("No Website")?"Website Build":s.includes("SEO")?"Local SEO Setup":s.includes("Rating")||s.includes("Star")?"Reputation Management":s.includes("Review")||s.includes("Reviews")||s.includes("Zero")?"Review Growth":s.includes("Phone")?"Google Business Profile Optimization":s.includes("Email")?"Contact Discovery":s}function Ms({websiteUrl:s,primaryEmail:t}){let a=s?62:18;return t&&(a+=12),q(a,0,100)}function Ws({needs:s,rating:t,reviewCount:a,websiteUrl:n}){let d=n?58:28;return s.some(p=>p.includes("SEO"))&&(d-=12),t&&t>=4&&(d+=10),a>=50&&(d+=12),a<20&&(d-=8),q(d,0,100)}function Is({phone:s,primaryEmail:t,websiteUrl:a}){let n=20;return s&&(n+=30),t&&(n+=35),a&&(n+=10),q(n,0,100)}
1function Us(s){return{hot:"Hot Lead",good:"Good Opportunity",moderate:"Moderate",low:"Low Priority"}[s]||"Lead"}function $s(s){return s>=70?"#22c55e":s>=40?"#eab308":"#ef4444"}function Es({name:s,pitch:t}){return[`Hi, I came across ${s} and noticed an opportunity around ${t}.`,"I help local businesses improve visibility, reviews, and inbound leads.","Do you have a moment to chat?"].join(` 2 3`)}function Rs(s,t){const a=Ds(s);return a?`https://wa.me/${a}?text=${encodeURIComponent(t)}`:""}function As(s,t,a){return`mailto:${encodeURIComponent(s)}?subject=${encodeURIComponent(`Quick idea for ${t}`)}&body=${encodeURIComponent(a)}`}function Os(s){const t=String(s||"").replace(/[^\d+]/g,"");return t?`tel:${t}`:""}function Ps(s){return`https://www.google.com/maps/search/?api=1&query=${encodeURIComponent(`${s.name||""} ${s.location||""}`)}`}function Fs(s){return`https://www.linkedin.com/search/results/all/?keywords=${encodeURIComponent(`${s.name||""} ${s.location||""}`)}`}function Ds(s){const t=String(s||"").replace(/\D/g,"");return t?t.length===10?`1${t}`:t:""}function Gs(s){if(!s)return"";try{return new URL(s).hostname.replace(/^www\./,"")}catch{return s}}function Bs(s){return[`Lead report: ${s.name}`,`Location: ${s.location||"N/A"}`,`Phone: ${s.phone||"N/A"}`,`Website: ${s.websiteUrl||"N/A"}`,`Email: ${s.primaryEmail||"N/A"}`,`Score: ${s.scoreLabel}`,`Rating: ${s.rating||"N/A"}`,`Reviews: ${s.reviewCount}`,`Pitch: ${s.pitch}`,"","Issues:",...s.issues.length?s.issues.map(t=>`- ${t}`):["- None detected"],"","Outreach message:",s.outreachMessage].join(` 4`)}function Ts(s){return String(s||"lead").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"lead"}function q(s,t,a){return Math.min(a,Math.max(t,s))}const _s=["Best Leads First","AI Relevance","Search Order","Weakest SEO First","Strongest SEO First","Lowest Rating First","Highest Rating First","Fewest Reviews First","Most Reviews First"],Hs=["Dentists in New York","Plumbers in New York without websites","Restaurants with low ratings in Brooklyn","Landscapers in Brooklyn","Chiropractors under 20 reviews in Jersey City"],Ks="Add your Google Places API key in Settings before running Lead Finder searches.",qs=[{icon:We,color:"#f43f5e",bg:"rgba(244,63,94,0.1)",title:"AI-Scored Leads",desc:"Every business gets an opportunity score based on SEO gaps, reviews, and online presence."},{icon:ae,color:"#0ea5e9",bg:"rgba(14,165,233,0.1)",title:"Auto Email Discovery",desc:"The finder checks discovered websites for direct emails and LinkedIn links when they are available."},{icon:ps,color:"#8b5cf6",bg:"rgba(139,92,246,0.1)",title:"Instant Pitch Ideas",desc:"Pitch suggestions are generated from each lead source, rating, website, and review profile."}],Vs=({score:s,priority:t})=>{const a={hot:{bg:"rgba(239,68,68,0.15)",border:"rgba(239,68,68,0.4)",text:"#ef4444",label:"HOT"},good:{bg:"rgba(34,197,94,0.15)",border:"rgba(34,197,94,0.4)",text:"#22c55e",label:"GOOD"},moderate:{bg:"rgba(234,179,8,0.15)",border:"rgba(234,179,8,0.4)",text:"#eab308",label:"MED"},low:{bg:"rgba(100,116,139,0.15)",border:"rgba(100,116,139,0.4)",text:"#94a3b8",label:"LOW"}},n=a[t]||a.low;return e.jsxs("div",{className:"lead-score-badge",style:{background:n.bg,borderColor:n.border,color:n.text},children:[e.jsx("span",{className:"lead-score-number",children:s}),e.jsx("span",{className:"lead-score-label",children:n.label})]})},Qs=({priority:s})=>{const t={hot:{label:"Hot Lead",color:"#ef4444",bg:"rgba(239,68,68,0.15)"},good:{label:"Good Opportunity",color:"#22c55e",bg:"rgba(34,197,94,0.15)"},moderate:{label:"Moderate",color:"#eab308",bg:"rgba(234,179,8,0.15)"},low:{label:"Low Priority",color:"#94a3b8",bg:"rgba(100,116,139,0.15)"}},a=t[s]||t.low;return e.jsx("span",{className:"lead-priority-tag",style:{color:a.color,background:a.bg},children:a.label})},Zs=({text:s})=>{const t=s.includes("No Website")||s.includes("Zero")||s.includes("Star Rating")||s.includes("No Rating");return e.jsxs("span",{className:`lead-need-badge ${t?"lead-need-warning":"lead-need-info"}`,children:[e.jsx(ie,{size:10}),s]})},Js=({status:s})=>
4{const t={found:{label:"Found",color:"#22c55e"},on_linkedin:{label:"On LinkedIn",color:"#3b82f6"},not_found:{label:"Not Found",color:"#6b7280"}},a=t[s]||t.not_found;return e.jsxs("span",{className:"lead-linkedin-tag",style:{color:a.color,borderColor:`${a.color}44`},children:[e.jsx(Me,{size:10}),a.label]})},Xs=({status:s,hasDirectEmail:t})=>t?e.jsxs("span",{className:"lead-email-tag lead-email-found",children:[e.jsx(ae,{size:10}),"Direct email"]}):s==="searching"?e.jsxs("span",{className:"lead-email-tag lead-email-searching",children:[e.jsx(P,{size:10,className:"lead-spin"}),"Finding..."]}):null,M=({icon:s,label:t,title:a,variant:n="default",disabled:d=!1,onClick:p})=>{const i=n==="primary"?"lead-action-btn lead-action-primary":n==="linkedin"?"lead-action-btn lead-action-linkedin":n==="whatsapp"?"lead-action-btn lead-action-whatsapp":n==="email"?"lead-action-btn lead-action-email":"lead-action-btn";return e.jsxs("button",{className:`${i} ${d?"lead-action-disabled":""}`,onClick:p,title:a||t,"aria-label":a||t,disabled:d,type:"button",children:[e.jsx(s,{size:13}),t&&e.jsx("span",{children:t})]})},Ce=()=>e.jsxs("div",{className:"lead-api-warning",role:"alert",children:[e.jsx(ie,{size:18}),e.jsxs("div",{children:[e.jsx("strong",{children:"Google Places API key required"}),e.jsxs("span",{children:["Lead Finder now uses your own Google Places API key. Add it in ",e.jsx(rs,{to:"/settings",children:"Settings"})," to search live local businesses."]})]})]}),Ys=({lead:s,isSelected:t,isSaved:a,onToggleSelect:n,onToggleSave:d,onOpenDetail:p})=>{const i=s.mapsUrl||$e(s),o=s.linkedinUrl||lt(s),l=at(s),j=it(s);return e.jsx("div",{className:`lead-card ${t?"lead-card-selected":""}`,children:e.jsxs("div",{className:"lead-card-inner",children:[e.jsx("button",{className:"lead-checkbox",onClick:()=>n(s.id),type:"button","aria-label":"Select lead",children:t?e.jsx(Ie,{size:16,className:"lead-check-active"}):e.jsx(Ue,{size:16})}),e.jsx(Vs,{score:s.score,priority:s.priority}),e.jsxs("div",{className:"lead-info",children:[e.jsxs("div",{className:"lead-info-header",children:[e.jsx("h3",{className:"lead-name",children:s.name}),e.jsx(Qs,{priority:s.priority}),e.jsx(Xs,{status:s.email,hasDirectEmail:s.hasDirectEmail})]}),e.jsxs("div",{className:"lead-meta",children:[s.location&&e.jsxs("span",{className:"lead-meta-item",children:[e.jsx(ye,{size:12,className:"lead-meta-icon"}),s.location]}),s.rating?e.jsxs("span",{className:`lead-meta-item ${s.rating<3.5?"lead-meta-warning":""}`,children:[e.jsx(re,{size:12,className:"lead-meta-icon",fill:"currentColor"}),s.rating," (",s.reviewCount,")"]}):e.jsxs("span",{className:"lead-meta-item lead-meta-warning",children:[e.jsx(re,{size:12,className:"lead-meta-icon"}),"No rating"]}),s.phone&&e.jsxs("a",{className:"lead-meta-item lead-meta-link",href:ot(s.phone),title:`Call ${s.phone}`,children:[e.jsx(hs,{size:12,className:"lead-meta-icon"}),s.phone]}),s.website&&e.jsxs("span",{className:"lead-meta-item",children:[e.jsx(le,{size:12,className:"lead-meta-icon"}),s.website]})]}),e.jsxs("div",{className:"lead-bottom-row",children:[e.jsxs("div",{className:"lead-needs-row",children:[e.jsx("span",{className:"lead-needs-label",children:"Needs:"}),s.needs.map(k=>e.jsx(Zs,{text:k},k))]}),e.jsx(Js,{status:s.linkedinStatus}),!s.linkedinUrl&&e.jsx("span",{className:"lead-open-detail",children:"Open lead detail to verify the owner profile"})]}),s.pitch&&e.jsxs("div",{className:"lead-pitch",children:[e.jsx(O,{size:12,className:"lead-pitch-icon"}),"Pitch: ",s.pitch]})]}),e.jsxs("div",{className:"lead-actions",children:[e.jsx(M,{icon:us,label:a?"Saved":"Save",title:a?"Remove saved lead":"Save lead",variant:a?"primary":"default",onClick:()=>d(s.id)}),e.jsx(M,{icon:Me,variant:"linkedin",title:s.linkedinUrl?"Open LinkedIn profile":"Search LinkedIn",onClick:()=>$(o)}),e.jsx(M,{icon:le,title:s.websiteUrl?"Open website":"No website found",disabled:!s.websiteUrl,onClick:()=>$(s.websiteUrl)}),e.jsx(M,{icon:fs,title:"Open Google business listing",onClick:()=>$(i)}),e.jsx(M,{icon:vs,variant:"whatsapp",title:l?`Message ${s.name} on WhatsApp`:"No phone number for WhatsApp",disabled:!l,onClick:()=>$(l)}),e.jsx(M,{icon:ae,title:s.emailAddress?"Email lead":"No direct email found",variant:"email",disabled:!s.emailAddress,onClick:()=>$(j)}),e.jsx(M,{icon:ye,title:"Open on Google Maps",onClick:()=>$(i)}),e.jsxs("button",{className:"lead-details-btn",onClick:()=>p(s),type:"button",children:["Explorer ",e.jsx(Ns,{size:14})]})]})]})})},wt=()=>{const{user:s}=ts(),[t,a]=m.useState([]),[n,d]=m.useState(""),[p,i]=m.useState(""),[o,l]=m.useState(""),[j,k]=m.useState("all"),[g,v]=m.useState("Best Leads First"),[W,u]=m.useState(!1),[b,f]=m.useState(new Set),[Re,Ae]=m.useState(new Set),[y,V]=m.useState({website:!1,seo:!1,reviews:!1}),[E,Oe]=m.useState(!1),[Pe,oe]=m.useState(!1),[S,Q]=m.useState(!1),[ne,ce]=m.useState(null),[I,R]=m.useState(""),Z=m.useRef(null),U=m.useRef(null),J=m.useMemo(()=>et(s),[s==null?void 0:s.googlePlacesApiKey]),z=J.length>0;m.useEffect(()=>{const r=c=>{Z.current&&!Z.current.contains(c.target)&&u(!1)};return document.addEventListener("mousedown",r),()=>document.removeEventListener("mousedown",r)},[]),m.useEffect(()=>()=>{var r;(r=U.current)==null||r.abort()},[]);const X=m.useCallback(async r=>{var N;const c=r.trim();if(!c){R("Enter a business type and location to search.");return}if(!z){R(Ks);return}(N=U.current)==null||N.abort();const h=new AbortController;U.current=h,oe(!0),Q(!0),R(""),l(c),i(c),d(""),k("all"),f(new Set);try{const A=await fetch("/api/local-leads",{method:"POST",headers:{"Content-Type":"application/json"},signal:h.signal,body:JSON.stringify({query:c,limit:40,discoverContacts:!0,googlePlacesApiKey:J})}),D=await A.json().catch(()=>({}));if(!A.ok)throw new Error(D.message||D.error||"Lead search failed.");a(Array.isArray(D.leads)?D.leads:[])}catch(A){A.name!=="AbortError"&&(a([]),R(A.message||"Lead search failed."))}finally{U.current===h&&(Q(!1),U.current=null)}},[J,z]),Fe=m.useMemo(()=>[{id:"all",label:"All Results",count:t.length},{id:"hot",label:"Hot Leads",count:t.filter(r=>r.priority==="hot").length,color:"#ef4444"},{id:"weak_seo",label:"Weak SEO",count:t.filter(F).length,color:"#eab308"},{id:"no_website",label:"No Website",count:t.filter(r=>!r.website).length,color:"#f97316"},{id:"under_20",label:"Under 20 reviews",count:t.filter(r=>r.reviewCount<20).length},{id:"low_rating",label:"Low Rating",count:t.filter(r=>r.rating&&r.rating<3.5).length,color:"#ef4444"},{id:"has_phone",label:"Has Phone",count:t.filter(r=>r.phone).length}],[t]),de=m.useMemo(()=>{const r=new Map;return t.forEach(c=>{r.set(c.category,(r.get(c.category)||0)+1)}),[...r.entries()].sort((c,h)=>h[1]-c[1]).slice(0,8).map(([c,h])=>({label:c,count:h}))},[t]),L=m.useMemo(()=>({website:t.filter(r=>!r.website).length,seo:t.filter(F).length,reviews:t.filter(Se).length}),[t]),w=m.useMemo(()=>{let r=[...t];if(j==="hot"?r=r.filter(c=>c.priority==="hot"):j==="no_website"?r=r.filter(c=>!c.website):j==="weak_seo"?r=r.filter(F):j==="low_rating"?r=r.filter(c=>c.rating&&c.rating<3.5):j==="has_phone"?r=r.filter(c=>c.phone):j==="under_20"&&(r=r.filter(c=>c.reviewCount<20)),E&&(r=r.filter(c=>c.ownerOperated)),(y.website||y.seo||y.reviews)&&(r=r.filter(c=>y.website&&!c.website||y.seo&&F(c)||y.reviews&&Se(c))),n.trim()){const c=n.toLowerCase();r=r.filter(h=>[h.name,h.category,h.location,h.phone,h.website,h.emailAddress].some(N=>String(N||"").toLowerCase().includes(c)))}return st(r,g)},[j,E,n,y,t,g]),De=m.useMemo(()=>{const r={},c=["hot","good","moderate","low"],h={hot:"Hot Leads",good:"Good Opp
4ortunities",moderate:"Moderate Leads",low:"Low Priority"};return c.forEach(N=>{r[N]={label:h[N],leads:[]}}),w.forEach(N=>{r[N.priority]&&r[N.priority].leads.push(N)}),Object.entries(r).filter(([,N])=>N.leads.length>0)},[w]),Ge=m.useMemo(()=>[{label:"Hot Leads",value:t.filter(r=>r.priority==="hot").length,icon:xs,color:"#f43f5e",bg:"rgba(244,63,94,0.1)"},{label:"No Website",value:L.website,icon:le,color:"#0ea5e9",bg:"rgba(14,165,233,0.1)"},{label:"Weak SEO",value:L.seo,icon:We,color:"#f59e0b",bg:"rgba(245,158,11,0.1)"},{label:"Few Reviews",value:L.reviews,icon:re,color:"#8b5cf6",bg:"rgba(139,92,246,0.1)"}],[t,L]),he=t.filter(r=>r.hasDirectEmail).length,ue=t.filter(r=>r.email==="searching").length,Be=L.website,Te=t.length?Math.round(he/t.length*100):0,me=w.length>0&&w.every(r=>b.has(r.id)),_e=r=>{f(c=>{const h=new Set(c);return h.has(r)?h.delete(r):h.add(r),h})},He=()=>{f(r=>{const c=new Set(r);return me?w.forEach(h=>c.delete(h.id)):w.forEach(h=>c.add(h.id)),c})},Ke=r=>{Ae(c=>{const h=new Set(c);return h.has(r)?h.delete(r):h.add(r),h})},pe=()=>{X(p||n)},xe=()=>{X(n||p||o)},qe=()=>{var r;(r=U.current)==null||r.abort(),oe(!1),d(""),i(""),l(""),k("all"),f(new Set),a([]),R(""),Q(!1)},Ve=r=>{i(r),X(r)},Qe=()=>{const r=b.size?t.filter(c=>b.has(c.id)):w;tt(r)};return ne?e.jsx("div",{className:"lead-finder-root",children:e.jsx(Cs,{lead:ne,onBack:()=>ce(null)})}):Pe?e.jsxs("div",{className:"lead-finder-root",children:[e.jsxs("div",{className:"lead-finder-header",children:[e.jsxs("div",{className:"lead-finder-title-row",children:[e.jsxs("div",{className:"lead-finder-title-group",children:[e.jsx("div",{className:"lead-finder-logo",children:e.jsx(O,{size:20})}),e.jsxs("div",{children:[e.jsx("h1",{className:"lead-finder-title",children:"AI Lead Finder"}),e.jsx("p",{className:"lead-finder-subtitle",children:o?`Live Google Places results for "${o}".`:"Search local businesses and pull matching leads."})]})]}),e.jsxs("div",{className:"lead-finder-header-actions",children:[e.jsxs("button",{className:"lead-header-btn lead-csv-btn",onClick:Qe,disabled:!w.length,type:"button",children:[e.jsx(ns,{size:15}),e.jsx("span",{children:"Export CSV"}),e.jsx(cs,{size:13,className:"lead-csv-arrow"})]}),e.jsxs("button",{className:"lead-header-btn",onClick:qe,type:"button",children:[e.jsx(P,{size:15})," New Search"]})]})]}),e.jsxs("div",{className:"lead-search-bar",children:[e.jsx(B,{size:18,className:"lead-search-icon"}),e.jsx("input",{type:"text",placeholder:"Filter current leads, or enter a new search...",value:n,onChange:r=>d(r.target.value),className:"lead-search-input",onKeyDown:r=>r.key==="Enter"&&xe()}),e.jsxs("button",{className:"lead-search-btn",onClick:xe,disabled:S||!z,type:"button",children:[S?e.jsx(P,{size:14,className:"lead-spin"}):e.jsx(O,{size:14}),"AI Search"]})]}),!z&&e.jsx(Ce,{})]}),e.jsx("div",{className:"lead-stats-grid",children:Ge.map(r=>e.jsxs("div",{className:"lead-stat-card",children:[e.jsx("div",{className:"lead-stat-icon",style:{background:r.bg},children:e.jsx(r.icon,{size:18,style:{color:r.color}})}),e.jsxs("div",{children:[e.jsx("div",{className:"lead-stat-value",children:r.value}),e.jsx("div",{className:"lead-stat-label",children:r.label})]})]},r.label))}),e.jsxs("div",{className:"lead-filters-section",children:[e.jsx("div",{className:"lead-filter-tabs",children:Fe.map(r=>e.jsxs("button",{className:`lead-filter-tab ${j===r.id?"lead-filter-active":""}`,onClick:()=>k(r.id),type:"button",children:[r.id==="all"&&e.jsx(bs,{size:13}),r.label," ",e.jsx("span",{className:"lead-filter-count",children:r.count})]},r.id))}),e.jsxs("div",{className:"lead-secondary-filters",children:[e.jsxs("button",{className:`lead-owner-filter ${E?"lead-owner-active":""}`,onClick:()=>Oe(!E),type:"button",children:[e.jsx(ms,{size:13}),"Owner-operated ",E&&e.jsx(js,{size:12})]}),e.jsxs("div",{className:"lead-sort-wrapper",ref:Z,children:[e.jsxs("button",{className:"lead-sort-btn",onClick:()=>u(!W),type:"button",children:[e.jsx(gs,{size:13})," ",g," ",e.jsx(ds,{size:14})]}),W&&e.jsx("div",{className:"lead-sort-dropdown",children:_s.map(r=>e.jsx("button",{className:`lead-sort-option ${g===r?"lead-sort-selected":""}`,onClick:()=>{v(r),u(!1)},type:"button",children:r},r))})]})]})]}),de.length>0&&e.jsxs("div",{className:"lead-categories",children:[e.jsx("span",{className:"lead-cat-label",children:"CATEGORIES"}),de.map(r=>e.jsxs("button",{className:"lead-cat-tag",type:"button",children:[r.label," ",e.jsx("span",{className:"lead-cat-count",children:r.count})]},r.label))]}),e.jsxs("div",{className:"lead-needs-filter",children:[e.jsxs("span",{className:"lead-needs-filter-label",children:[e.jsx("span",{className:"lead-needs-dot"})," Show leads needing:"]}),e.jsxs("button",{className:`lead-need-toggle ${y.website?"active":""}`,onClick:()=>V(r=>({...r,website:!r.website})),type:"button",children:["Website ",L.website]}),e.jsxs("button",{className:`lead-need-toggle ${y.seo?"active":""}`,onClick:()=>V(r=>({...r,seo:!r.seo})),type:"button",children:["SEO ",L.seo]}),e.jsxs("button",{className:`lead-need-toggle ${y.reviews?"active":""}`,onClick:()=>V(r=>({...r,reviews:!r.reviews})),type:"button",children:["Reviews ",L.reviews]})]}),e.jsx("div",{className:"lead-email-bar",children:e.jsxs("div",{className:"lead-email-bar-inner",children:[e.jsx(P,{size:14,className:S||ue?"lead-spin":""}),e.jsx("span",{children:S?e.jsx("strong",{children:"Fetching Google Places data..."}):e.jsxs(e.Fragment,{children:[e.jsxs("strong",{children:[he," emails found"]}
4)," | ",ue," searching | ",Be," no website |"," ",e.jsxs("span",{className:"lead-coverage",children:[Te,"% coverage of scrapable rows"]})]})})]})}),e.jsxs("div",{className:"lead-select-all",children:[e.jsx("button",{className:"lead-checkbox",onClick:He,disabled:!w.length,type:"button","aria-label":"Select all leads",children:me?e.jsx(Ie,{size:16,className:"lead-check-active"}):e.jsx(Ue,{size:16})}),e.jsxs("span",{children:["Select all ",w.length]})]}),e.jsxs("div",{className:"lead-list",children:[S&&e.jsxs("div",{className:"lead-empty",children:[e.jsx(P,{size:40,className:"lead-empty-icon lead-spin"}),e.jsx("h3",{children:"Searching Google Places"}),e.jsx("p",{children:"Fetching business details, websites, phones, and contact signals."})]}),!S&&I&&e.jsxs("div",{className:"lead-empty lead-error",children:[e.jsx(ie,{size:40,className:"lead-empty-icon"}),e.jsx("h3",{children:"Search failed"}),e.jsx("p",{children:I})]}),!S&&!I&&De.map(([r,c])=>e.jsxs("div",{className:"lead-group",children:[e.jsxs("div",{className:"lead-group-header",children:[e.jsx("span",{className:"lead-group-dot","data-priority":r}),e.jsx("span",{className:"lead-group-title",children:c.label})]}),c.leads.map(h=>e.jsx(Ys,{lead:h,isSelected:b.has(h.id),isSaved:Re.has(h.id),onToggleSelect:_e,onToggleSave:Ke,onOpenDetail:ce},h.id))]},r)),!S&&!I&&w.length===0&&e.jsxs("div",{className:"lead-empty",children:[e.jsx(B,{size:40,className:"lead-empty-icon"}),e.jsx("h3",{children:"No leads found"}),e.jsx("p",{children:"Try a broader business type, city, or filter set."})]})]})]}):e.jsx("div",{className:"lead-finder-root",children:e.jsxs("div",{className:"lead-homepage",children:[e.jsxs("div",{className:"lead-homepage-hero",children:[e.jsx("div",{className:"lead-homepage-icon",children:e.jsx(O,{size:36})}),e.jsx("h1",{className:"lead-homepage-title",children:"AI Lead Finder"}),e.jsx("p",{className:"lead-homepage-desc",children:"Describe the businesses you want to find. The finder searches Google Places, scores opportunities, and surfaces contacts that are ready to pitch."})]}),e.jsxs("div",{className:"lead-homepage-search",children:[!z&&e.jsx(Ce,{}),e.jsxs("div",{className:"lead-search-bar",children:[e.jsx(B,{size:18,className:"lead-search-icon"}),e.jsx("input",{type:"text",placeholder:"Try 'Dentists in Brooklyn with under 10 reviews'...",value:p,onChange:r=>i(r.target.value),className:"lead-search-input",onKeyDown:r=>r.key==="Enter"&&pe()}),e.jsxs("button",{className:"lead-search-btn",onClick:pe,disabled:!z,type:"button",children:[e.jsx(O,{size:14})," AI Search"]})]}),I&&e.jsx("div",{className:"lead-inline-error",children:I}),e.jsx("div",{className:"lead-homepage-suggestions",children:Hs.map(r=>e.jsxs("button",{className:"lead-suggestion-chip",onClick:()=>Ve(r),disabled:!z,type:"button",children:[e.jsx(B,{size:11}),r]},r))})]}),e.jsxs("div",{className:"lead-homepage-steps",children:[e.jsxs("div",{className:"lead-step",children:[e.jsx("span",{className:"lead-step-number",children:"1"}),"Describe your target"]}),e.jsx(we,{size:16,className:"lead-step-arrow"}),e.jsxs("div",{className:"lead-step",children:[e.jsx("span",{className:"lead-step-number",children:"2"}),"Google Places finds leads"]}),e.jsx(we,{size:16,className:"lead-step-arrow"}),e.jsxs("div",{className:"lead-step",children:[e.jsx("span",{className:"lead-step-number",children:"3"}),"Export and pitch"]})]}),e.jsx("div",{className:"lead-homepage-features",children:qs.map(r=>e.jsxs("div",{className:"lead-feature-card",children:[e.jsx("div",{className:"lead-feature-icon",style:{background:r.bg},children:e.jsx(r.icon,{size:20,style:{color:r.color}})}),e.jsx("div",{className:"lead-feature-title",children:r.title}),e.jsx("div",{className:"lead-feature-desc",children:r.desc})]},r.title))})]})})};function F(s){var t;return((t=s.needs)==null?void 0:t.some(a=>a.includes("SEO")))||!s.website}function et(s){const t=(s==null?void 0:s.googlePlacesApiKey)||(typeof window<"u"?window.localStorage.getItem("googlePlacesApiKey"):"");return String(t||"").trim()}function Se(s){var t;return s.reviewCount<20||((t=s.needs)==null?void 0:t.some(a=>a.includes("Review")||a.includes("Rating")))}function st(s,t){const a=[...s],n=i=>(i.website?0:2)+(F(i)?1:0),d=i=>typeof i.rating=="number"?i.rating:-1,p=i=>Number.isFinite(i.reviewCount)?i.reviewCount:0;return t==="Search Order"?a.sort((i,o)=>(i.searchOrder||0)-(o.searchOrder||0)):t==="Weakest SEO First"?a.sort((i,o)=>n(o)-n(i)||o.score-i.score):t==="Strongest SEO First"?a.sort((i,o)=>n(i)-n(o)||o.score-i.score):t==="Lowest Rating First"?a.sort((i,o)=>d(i)-d(o)):t==="Highest Rating First"?a.sort((i,o)=>d(o)-d(i)):t==="Fewest Reviews First"?a.sort((i,o)=>p(i)-p(o)):t==="Most Reviews First"?a.sort((i,o)=>p(o)-p(i)):a.sort((i,o)=>o.score-i.score)}function tt(s){if(!s.length)return;const t=["Name","Category","Score","Priority","Location","Rating","Reviews","Phone","Website","Email","LinkedIn","Needs","Pitch","Google Maps URL"],a=s.map(o=>[o.name,o.category,o.score,o.priority,o.location,o.rating||"",o.reviewCount,o.phone,o.websiteUrl||"",o.emailAddress||"",o.linkedinUrl||"",o.needs.join("; "),o.pitch,o.mapsUrl||$e(o)]),n=[t,...a].map(o=>o.map(rt).join(",")).join(`\r 5`),d=new Blob([n],{type:"text/csv;charset=utf-8;"}),p=URL.createObjectURL(d),i=document.createElement("a");i.href=p,i.download=`local-leads-${new Date().toISOString().slice(0,10)}.csv`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(p)}function rt(s){const t=String(s??"");return/[",\r\n]/.test(t)?`"${t.replace(/"/g,'""')}"`:t}function $e(s){return`https://www.google.com/maps/search/?api=1&query=${encodeURIComponent(`${s.name} ${s.location||""}`)}`}function lt(s){return`https://www.linkedin.com/search/results/all/?keywords=${encodeURIComponent(`${s.name} ${s.location||""}`)}`}function at(s){const t=nt(s.phone);return t?`https://wa.me/${t}?text=${encodeURIComponent(Ee(s))}`:""}function it(s){if(!s.emailAddress)return"";const t=`Quick idea for ${s.name}`,a=Ee(s);return`mailto:${encodeURIComponent(s.emailAddress)}?subject=${encodeURIComponent(t)}&body=${encodeURIComponent(a)}`}function ot(s){const t=String(s||"").replace(/[^\d+]/g,"");return t?`tel:${t}`:""}function Ee(s){const t=s.pitch||"your local online presence";return[`Hi, I came across ${s.name} and noticed an opportunity around ${t}.`,"I help local businesses improve visibility, reviews, and inbound leads.","Do you have a moment to chat?"].join(` 6 7`)}function nt(s){const t=String(s||"").replace(/\D/g,"");return t?t.length===10?`1${t}`:t:""}function $(s){s&&window.open(s,"_blank","noopener,noreferrer")}export{wt 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.