1import{k as g,l as f,e as b,g as N,r as v,j as e,U as y}from"./index-qp2ru7DR.js";import{P as _}from"./AppShell-CWyrekZ1.js";import{B as w}from"./button-D2uRa2eV.js";import{T as k,a as L,b as h,c as l,d as C,e as d}from"./table-iysoSA_9.js";import{P as S,q as T,O as P}from"./assessment-UBMlgj9C.js";import{D as B}from"./download-Bfqt0aE-.js";import{L as E}from"./loader-circle-Bf-CJzVz.js";import{F as O}from"./flame-BZAf58te.js";import{M as R}from"./mail-D0oWgW8o.js";import{M as F}from"./mouse-pointer-click-BrqSFsM6.js";import"./sheet-DPpwwA9Z.js";import"./index-Cq2L4fUL.js";import"./index-BUx1SUyn.js";import"./tslib.es6-eMSY344_.js";import"./index-Be3q6WH_.js";import"./x-eMSWKRxF.js";import"./db-Ci0KArjV.js";import"./travelcs.functions-CiSSQw1d.js";import"./BrandLogo-LhrbQrqn.js";import"./useMutation-C64P70D_.js";import"./dialog-DaKKZ7bQ.js";import"./index-hLWEBsPQ.js";import"./client-bPd5HcGv.js";import"./star-U1HfSnWB.js";import"./dropdown-menu-BEQrcLtD.js";import"./index-zocKir6P.js";import"./index-bG4Jkymn.js";import"./chevron-right-BaNm4SwX.js";import"./check-_AvfohVi.js";import"./building-2-D2YqBDUQ.js";import"./chevrons-up-down-DSqvJs7-.js";import"./menu-D4JVc0f8.js";import"./search-C6cy-ctd.js";import"./inbox-Br0eFZNU.js";import"./calendar-clock-1STufm64.js";import"./megaphone-GWHVyo_p.js";import"./brain-DyJUm11F.js";import"./bell-aykl8KOJ.js";import"./shield-check-Smp21mwG.js";import"./rocket-C931b47c.js";import"./log-out-ytDUMB6l.js";const U=g({method:"GET"}).handler(f("c306d2538f27a74e7b9154aba1a4d469a07d55bafbdc5d85ed74e605284caebe"));function $(){const i={...P};for(const n of S.options.map(r=>r.value))for(const r of T(n))for(const o of r.options)i[o.value]=o.label;return i}function x({icon:i,label:n,value:r,hint:o}){return e.jsxs("div",{className:"rounded-xl border border-border bg-card p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(i,{className:"h-3.5 w-3.5"})," ",n]}),e.jsx("div",{className:"mt-1 text-2xl font-semibold text-foreground",children:r}),o&&e.jsx("div",{className:"text-xs text-muted-foreground",children:o})]})}function c({title:i,rows:n,labels:r,total:o}){return n.length?e.jsxs("div",{className:"rounded-xl border border-border bg-card p-4",children:[e.jsx("div",{className:"text-sm font-medium text-foreground",children:i}),e.jsx("div",{className:"mt-3 grid gap-2",children:n.slice(0,6).map(s=>e.jsxs("div",{className:"grid gap-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsx("span",{className:"text-foreground",children:r[s.key]??s.key}),e.jsx("span",{className:"text-muted-foreground",children:s.count})]}),e.jsx("div",{className:"h-1.5 rounded-full bg-muted overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full bg-primary",style:{width:`${o?Math.round(s.count/o*100):0}%`}})})]},s.key))})]}):null}function M(i){const n=["created_at","language","company","contact","email","role","main_pain","goal","messages_per_day","channels","booking_sources","top_opportunities","cta_clicked","referrer_host"],r=s=>`"${String(s??"").replace(/"/g,'""')}"`,o=i.map(s=>[s.created_at,s.source==="assessment-pt"?"pt":"en",s.company_name,s.contact_name,s.email,s.role,s.main_pain,s.goal,s.messages_per_day,s.channels.join("|"),s.booking_sources.join("|"),s.top_opportunities.join("|"),s.cta_clicked?"yes":"no",s.referrer_host].map(r).join(","));return[n.join(","),...o].join(` 2`)}function Le(){const i=b(U),{data:n,isLoading:r,error:o}=N({queryKey:["admin","assessments"],queryFn:()=>i({data:{days:365}}),retry:!1}),s=v.useMemo($,[]),m=n?.rows??[],t=n?.analytics;function j(){const a=new Blob([M(m)],{type:"text/csv;charset=utf-8"}),p=URL.createObjectURL(a),u=document.createElement("a");u.href=p,u.download=`assessment-leads-${new Date().toISOString().slice(0,10)}.csv`,u.click(),URL.revokeObjectURL(p)}return e.jsxs(e.Fragment,{children:[e.jsx(_,{title:"Assessment leads",description:"Submissions from the public operator check-up (/assessment and /pt/assessment).",actions:e.jsxs(w,{variant:"outline",onClick:j,disabled:!m.length,children:[e.jsx(B,{className:"mr-1.5 h-4 w-4"})," Export CSV"]})}),e.jsxs("div",{className:"px-4 sm:px-8 py-5",children:[r&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(E,{className:"h-4 w-4 animate-spin"})," Loadingâ¦"]}),o&&e.jsx("div",{className:"rounded-xl border border-destructive/40 bg-destructive/5 p-4 text-sm text-foreground",children:"Could not load the assessment leads. Try again in a moment."}),t&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-4",children:[e.jsx(x,{icon:y,label:"Submissions",value:t.total,hint:"Last 12 months"}),e.jsx(x,{icon:O,label:"Last 7 days",value:t.last7,hint:`${t.last30} in 30 days`}),e.jsx(x,{icon:R,label:"With email",value:t.withEmail}),e.jsx(x,{icon:F,label:"Booked-call clicks",value:`${t.ctaClicks} (${t.ctaRate}%)`})]}),e.jsxs("div",{className:"mt-4 grid gap-3 md:grid-cols-2 lg:grid-cols-3",children:[e.jsx(c,{title:"Biggest pain",rows:t.topPains,labels:s,total:t.total}),e.jsx(c,{title:"Top opportunities",rows:t.topOpportunities,labels:s,total:t.total}),e.jsx(c,{title:"Goal",rows:t.topGoals,labels:s,total:t.total}),e.jsx(c,{title:"Channels used",rows:t.topChannels,labels:s,total:t.total}),e.jsx(c,{title:"Booking sources",rows:t.topSources,labels:s,total:t.total}),e.jsx(c,{title:"Language",rows:t.byLang,labels:{en:"English",pt:"Português"},total:t.total})]})]}),!!m.length&&e.jsx("div",{className:"mt-6 rounded-xl border border-border overflow-x-auto",children:e.jsxs(k,{children:[e.jsx(L,{children:e.jsxs(h,{children:[e.jsx(l,{children:"When"}),e.jsx(l,{children:"Company"}),e.jsx(l,{children:"Contact"}),e.jsx(l,{children:"Pain"}),e.jsx(l,{children:"Opportunities"}),e.jsx(l,{children:"Lang"}),e.jsx(l,{children:"Call"})]})}),e.jsx(C,{children:m.map(a=>e.jsxs(h,{children:[e.jsx(d,{className:"whitespace-nowrap text-xs text-muted-foreground",children:new Date(a.created_at).toLocaleStr
2ing()}),e.jsx(d,{className:"text-sm",children:a.company_name??"â"}),e.jsxs(d,{className:"text-sm",children:[e.jsx("div",{children:a.contact_name??"â"}),a.email?e.jsx("a",{className:"text-xs text-primary hover:underline",href:`mailto:${a.email}`,children:a.email}):e.jsx("span",{className:"text-xs text-muted-foreground",children:"no email"}),a.role?e.jsx("div",{className:"text-xs text-muted-foreground",children:a.role}):null]}),e.jsx(d,{className:"text-sm",children:a.main_pain?s[a.main_pain]??a.main_pain:"â"}),e.jsx(d,{className:"text-xs text-muted-foreground",children:a.top_opportunities.map(p=>s[p]??p).join(", ")||"â"}),e.jsx(d,{className:"text-xs uppercase text-muted-foreground",children:a.source==="assessment-pt"?"pt":"en"}),e.jsx(d,{className:"text-xs",children:a.cta_clicked?e.jsx("span",{className:"rounded-full bg-primary/10 px-2 py-0.5 text-primary",children:"clicked"}):e.jsx("span",{className:"text-muted-foreground",children:"â"})})]},a.id))})]})}),!r&&!o&&!m.length&&e.jsx("div",{className:"mt-6 rounded-xl border border-border bg-card p-6 text-sm text-muted-foreground",children:"No check-up submissions yet."})]})]})}export{Le as component};
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.