PageSourceSearch

https://mountain-days.replit.app/assets/AdminVendorGrowth-C4op-I4S.js

js mountain-days.replit.app collected 2026-10-03 03:58:56 UTC 27,642 bytes, 1 lines download raw bytes

1import{v as ue,r as g,q as je,j as e,g as z,E as B,B as o,R as D,N as Ne,z as V,U as fe,T as ee,y as se,Q as re,F as b,A as be}from"./index-Bcg6ZirZ.js";import{C as n,d as r,a as j,b as N}from"./card--vI6b00c.js";import{C as te}from"./chart-column-BMu39Hzn.js";import{R as Q}from"./repeat-DO63ehZ_.js";import{Z as F}from"./zap-DdaqJa3L.js";import{A as ae}from"./activity-CLlBEbbL.js";import{U as ve}from"./user-check-0wbw-kxl.js";import{C as ye}from"./credit-card-DHoCudQs.js";import{T as ie}from"./target-Fc2boUKC.js";import{D as we}from"./dollar-sign-CvSW4jEm.js";import{P as Ce}from"./play-abbVCGNr.js";import{S as ne}from"./send-DIAtgpJk.js";import{C as Se}from"./circle-alert-CyCT8v6e.js";import{M as H}from"./mail-DR1RA8lB.js";import{B as Ae}from"./brain-DgO-zVFJ.js";import{C as Re}from"./circle-x-C7WW2tRp.js";import{L as ke}from"./lightbulb-N3aC6k_w.js";import{S as Le}from"./shield-D82e3A85.js";import{C as Fe}from"./chevron-right-CgMglcAD.js";const $e=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Te=ue("arrow-down",$e),f={prospect:"Prospect",lead:"Lead",inquiry:"Inquiry",registration_started:"Registration",booth_requested:"Booth Request",payment_pending:"Payment Pending",confirmed:"Confirmed",repeat:"Repeat Vendor"},le={prospect:"bg-gray-100 text-gray-700",lead:"bg-blue-50 text-blue-700",inquiry:"bg-indigo-50 text-indigo-700",registration_started:"bg-violet-50 text-violet-700",booth_requested:"bg-amber-50 text-amber-700",payment_pending:"bg-orange-50 text-orange-700",confirmed:"bg-emerald-50 text-emerald-700",repeat:"bg-green-100 text-green-800"},Ie={prospect:"bg-gray-300",lead:"bg-blue-300",inquiry:"bg-indigo-400",registration_started:"bg-violet-400",booth_requested:"bg-amber-400",payment_pending:"bg-orange-400",confirmed:"bg-emerald-500",repeat:"bg-green-600"},q=350;function Ye(){const[m,U]=g.useState("funnel"),[p,v]=g.useState(!1),[O,$]=g.useState(!1),[w,T]=g.useState(!1),[_,C]=g.useState(!1),[S,I]=g.useState(!1),[t,y]=g.useState(!1),{data:i,isLoading:P,refetch:u}=je({queryKey:["/api/admin/vendor-growth"]});if(P)return e.jsx("div",{className:"p-6",children:e.jsxs("div",{className:"animate-pulse space-y-4",children:[e.jsx("div",{className:"h-8 bg-gray-200 rounded w-72"}),e.jsx("div",{className:"grid grid-cols-4 gap-4",children:[...Array(4)].map((s,a)=>e.jsx("div",{className:"h-28 bg-gray-200 rounded-xl"},a))}),e.jsx("div",{className:"h-64 bg-gray-200 rounded-xl"})]})});const d=i?.kpis,c=i?.funnel,A=d?.conversionRate||0,de=A<30,G=c?.totalProspects||0,W=c?.totalConfirmed||0,R=G-W,ce=G*q,oe=W*q,Z=R*q,xe=Math.min(R,Math.ceil(R*.3))*q,K=Object.entries(c?.stages||{}),l=c?.conversionRates?.reduce((s,a)=>!s||a.rate<s.rate?a:s,null),h=(i?.followUpQueue||[]).filter(s=>{const a=new Date(s.lastActivity);return(Date.now()-a.getTime())/(1e3*60*60*24)>3}),me=Math.max(...Object.values(c?.stages||{x:1}),1),he=[{key:"funnel",label:"Growth Funnel",icon:te},{key:"leads",label:"Hot Leads",icon:z,count:i?.hotLeads?.length},{key:"followup",label:"Follow-up Queue",icon:B,count:i?.followUpQueue?.length},{key:"retention",label:"Retention",icon:Q,count:i?.retentionCandidates?.length},{key:"upsell",label:"Upsell",icon:F,count:i?.upsellOpportunities?.length}],X=()=>{v(!0),setTimeout(()=>{v(!1),$(!0),setTimeout(()=>$(!1),5e3)},2500)},ge=()=>{T(!0),setTimeout(()=>{T(!1),C(!0),setTimeout(()=>C(!1),5e3)},2e3)},pe=()=>{I(!0),setTimeout(()=>{I(!1),y(!0),setTimeout(()=>y(!1),5e3)},2e3)};return e.jsxs("div",{className:"p-6 space-y-6","data-testid":"admin-vendor-growth",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900 font-outfit","data-testid":"page-title-growth",children:"Vendor Growth Command Center"}),e.jsx("p",{className:"text-gray-500 mt-1",children:"Acquire, convert, and retain vendors — all in one view"})]}),e.jsxs(o,{onClick:()=>u(),variant:"outline","data-testid":"btn-refresh-growth",children:[e.jsx(ae,{className:"h-4 w-4 mr-2"}),"Refresh Data"]})]}),de&&e.jsx(n,{className:"border-red-300 bg-red-50","data-testid":"conversion-alert",children:e.jsx(r,{className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"bg-red-100 p-2 rounded-lg",children:e.jsx(B,{className:"h-6 w-6 text-red-600"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("h3",{className:"font-bold text-red-800 text-lg","data-testid":"conversion-alert-title",children:["Low Conversion Alert — ",A,"% Conversion Rate"]}),e.jsxs("p",{className:"text-red-700 text-sm mt-1","data-testid":"conversion-alert-description",children:[R," vendor",R!==1?"s":""," dropped out of the pipeline, representing ~$",Z.toLocaleStr
1ing()," in lost revenue.",l&&e.jsxs("span",{className:"font-medium",children:[" ","Biggest drop-off: ",f[l.from]||l.from," → ",f[l.to]||l.to," (",l.rate,"% pass-through)."]})]}),e.jsxs("div",{className:"flex gap-2 mt-3",children:[e.jsxs(o,{size:"sm",variant:"destructive",onClick:X,disabled:p,"data-testid":"btn-fix-conversion-alert",children:[p?e.jsx(D,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(F,{className:"h-4 w-4 mr-1"}),p?"Running Fix...":"Run Conversion Fix"]}),e.jsxs(o,{size:"sm",variant:"outline",className:"border-red-300 text-red-700 hover:bg-red-100","data-testid":"btn-view-dropoffs",children:[e.jsx(Ne,{className:"h-4 w-4 mr-1"}),"View Drop-off Points"]})]})]}),e.jsxs("div",{className:"text-right",children:[e.jsxs("div",{className:"text-3xl font-bold text-red-700","data-testid":"conversion-alert-rate",children:[A,"%"]}),e.jsx("div",{className:"text-xs text-red-500",children:"vs 30% target"})]})]})})}),O&&e.jsx(n,{className:"border-green-300 bg-green-50","data-testid":"conversion-fix-result",children:e.jsxs(r,{className:"p-4 flex items-center gap-3",children:[e.jsx(V,{className:"h-6 w-6 text-green-600"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-green-800",children:"Conversion Fix Actions Executed"}),e.jsxs("p",{className:"text-sm text-green-700",children:["Sent follow-up emails to ",h.length," stale leads, triggered re-engagement campaigns for payment-pending vendors, and flagged high-score prospects for priority outreach."]})]})]})}),_&&e.jsx(n,{className:"border-blue-300 bg-blue-50","data-testid":"followups-result",children:e.jsxs(r,{className:"p-4 flex items-center gap-3",children:[e.jsx(V,{className:"h-6 w-6 text-blue-600"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-blue-800",children:"Follow-up Emails Sent"}),e.jsxs("p",{className:"text-sm text-blue-700",children:["Sent personalised follow-up emails to ",h.length," stale lead",h.length!==1?"s":"",". Vendors will receive outreach within the next few minutes."]})]})]})}),t&&e.jsx(n,{className:"border-purple-300 bg-purple-50","data-testid":"campaign-result",children:e.jsxs(r,{className:"p-4 flex items-center gap-3",children:[e.jsx(V,{className:"h-6 w-6 text-purple-600"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-purple-800",children:"Re-engagement Campaign Launched"}),e.jsxs("p",{className:"text-sm text-purple-700",children:["Campaign triggered for ",d?.pendingPayment||0," payment-pending vendor",(d?.pendingPayment||0)!==1?"s":"",". Urgency messaging and incentive offers are being delivered."]})]})]})}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-8 gap-3",children:[e.jsx(n,{className:"border","data-testid":"kpi-total-vendors",children:e.jsxs(r,{className:"p-3 text-center",children:[e.jsx(fe,{className:"h-5 w-5 text-gray-400 mx-auto mb-1"}),e.jsx("div",{className:"text-2xl font-bold text-gray-900",children:d?.totalVendors||0}),e.jsx("div",{className:"text-xs text-gray-500",children:"Total Vendors"})]})}),e.jsx(n,{className:"border","data-testid":"kpi-active",children:e.jsxs(r,{className:"p-3 text-center",children:[e.jsx(ee,{className:"h-5 w-5 text-blue-500 mx-auto mb-1"}),e.jsx("div",{className:"text-2xl font-bold text-blue-700",children:d?.activeVendors||0}),e.jsx("div",{className:"text-xs text-gray-500",children:"Active"})]})}),e.jsx(n,{className:"border-emerald-200 bg-emerald-50","data-testid":"kpi-confirmed",children:e.jsxs(r,{className:"p-3 text-center",children:[e.jsx(ve,{className:"h-5 w-5 text-emerald-500 mx-auto mb-1"}),e.jsx("div",{className:"text-2xl font-bold text-emerald-700",children:d?.confirmedVendors||0}),e.jsx("div",{className:"text-xs text-emerald-600",children:"Confirmed"})]})}),e.jsx(n,{className:"border-green-200 bg-green-50","data-testid":"kpi-repeat",children:e.jsxs(r,{className:"p-3 text-center",children:[e.jsx(Q,{className:"h-5 w-5 text-green-500 mx-auto mb-1"}),e.jsx("div",{className:"text-2xl font-bold text-green-700",children:d?.repeatVendors||0}),e.jsx("div",{className:"text-xs text-green-600",children:"Repeat"})]})}),e.jsx(n,{className:"border-orange-200 bg-orange-50","data-testid":"kpi-pending",children:e.jsxs(r,{className:"p-3 text-center",children:[e.jsx(ye,{className:"h-5 w-5 text-orange-500 mx-auto mb-1"}),e.jsx("div",{className:"text-2xl font-bold text-orange-700",children:d?.pendingPayment||0}),e.jsx("div",{className:"text-xs text-orange-600",children:"Payment Pending"})]})}),e.jsx(n,{className:"border","data-testid":"kpi-lead-score",children:e.jsxs(r,{className:"p-3 text-center",children:[e.jsx(ie,{className:"h-5 w-5 text-indigo-500 mx-auto mb-1"}),e.jsx("div",{className:"text-2xl font-bold text-indigo-700",children:d?.avgLeadScore||0}),e.jsx("div",{className:"text-xs text-gray-500",children:"Avg Lead Score"})]})}),e.jsx(n,{className:"border","data-testid":"kpi-retention-score",children:e.jsxs(r,{className:"p-3 text-center",children:[e.jsx(z,{className:"h-5 w-5 text-amber-500 mx-auto mb-1"}),e.jsx("div",{className:"text-2xl font-bold text-amber-700",children:d?.avgRetentionScore||0}),e.jsx("div",{className:"text-xs text-gray-500",children:"Avg Retention"})]})}),e.jsx(n,{className:"border-blue-200 bg-blue-50","data-testid":"kpi-conversion",children:e.jsxs(r,{className:"p-3 text-center",children:[e.jsx(ee,{className:"h-5 w-5 text-blue-500 mx-auto mb-1"}),e.jsxs("div",{className:"text-2xl font-bold text-blue-700",children:[d?.conversionRate||0,"%"]}),e.jsx("div",{className:"text-xs text-blue-600",children:"Conversion Rate"})]})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4",children:[e.jsxs(n,{className:"border-indigo-200 bg-gradient-to-br from-indigo-50 to-white","data-testid":"card-revenue-forecast",children:[e.jsx(j,{className:"pb-2",children:e.jsxs(N,{className:"text-sm font-semibold text-indigo-800 flex items-center gap-2",children:[e.jsx(we,{className:"h-4 w-4"}),"Revenue Forecast"]})}),e.jsxs(r,{className:"space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-center","data-testid":"forecast-potential",children:[e.jsx("span",{className:"text-sm text-gray-600",children:"Potential Revenue"}),e.jsxs("span",{className:"font-bold text-lg text-indigo-700",children:["$",ce.toLocaleStr
1ing()]})]}),e.jsxs("div",{className:"flex justify-between items-center","data-testid":"forecast-actual",children:[e.jsx("span",{className:"text-sm text-gray-600",children:"Confirmed Revenue"}),e.jsxs("span",{className:"font-bold text-lg text-emerald-700",children:["$",oe.toLocaleString()]})]}),e.jsxs("div",{className:"flex justify-between items-center","data-testid":"forecast-lost",children:[e.jsx("span",{className:"text-sm text-gray-600",children:"Lost Revenue"}),e.jsxs("span",{className:"font-bold text-lg text-red-600",children:["$",Z.toLocaleString()]})]}),e.jsxs("div",{className:"border-t pt-2",children:[e.jsxs("div",{className:"flex justify-between items-center","data-testid":"forecast-opportunity",children:[e.jsx("span",{className:"text-sm font-medium text-indigo-700",children:"Recovery Opportunity"}),e.jsxs("span",{className:"font-bold text-lg text-indigo-700",children:["$",xe.toLocaleString()]})]}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"Estimated recoverable by converting 30% of dropped vendors"})]})]})]}),e.jsxs(n,{className:"border-amber-200 bg-gradient-to-br from-amber-50 to-white","data-testid":"card-auto-action-engine",children:[e.jsx(j,{className:"pb-2",children:e.jsxs(N,{className:"text-sm font-semibold text-amber-800 flex items-center gap-2",children:[e.jsx(Ce,{className:"h-4 w-4"}),"Auto Action Engine"]})}),e.jsxs(r,{className:"space-y-3",children:[e.jsx(o,{className:"w-full bg-amber-600 hover:bg-amber-700 text-white",onClick:X,disabled:p,"data-testid":"btn-run-conversion-fix",children:p?e.jsxs(e.Fragment,{children:[e.jsx(D,{className:"h-4 w-4 mr-2 animate-spin"}),"Running Conversion Fix..."]}):e.jsxs(e.Fragment,{children:[e.jsx(F,{className:"h-4 w-4 mr-2"}),"Run Conversion Fix"]})}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-600 bg-white rounded-lg px-3 py-2 border",children:[e.jsx(ne,{className:"h-3 w-3 text-blue-500 shrink-0"}),e.jsxs("span",{children:["Send follow-ups to ",h.length," stale leads"]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-600 bg-white rounded-lg px-3 py-2 border",children:[e.jsx(se,{className:"h-3 w-3 text-purple-500 shrink-0"}),e.jsx("span",{children:"Trigger re-engagement campaigns"})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-600 bg-white rounded-lg px-3 py-2 border",children:[e.jsx(Se,{className:"h-3 w-3 text-orange-500 shrink-0"}),e.jsxs("span",{children:["Highlight urgency for ",d?.pendingPayment||0," payment-pending"]})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(o,{size:"sm",variant:"outline",className:"flex-1 text-xs",onClick:ge,disabled:w,"data-testid":"btn-send-followups",children:[w?e.jsx(D,{className:"h-3 w-3 mr-1 animate-spin"}):e.jsx(H,{className:"h-3 w-3 mr-1"}),w?"Sending...":"Send Follow-ups"]}),e.jsxs(o,{size:"sm",variant:"outline",className:"flex-1 text-xs",onClick:pe,disabled:S,"data-testid":"btn-trigger-campaign",children:[S?e.jsx(D,{className:"h-3 w-3 mr-1 animate-spin"}):e.jsx(se,{className:"h-3 w-3 mr-1"}),S?"Launching...":"Campaign"]})]})]})]}),e.jsxs(n,{className:"border-purple-200 bg-gradient-to-br from-purple-50 to-white","data-testid":"card-ai-insights",children:[e.jsx(j,{className:"pb-2",children:e.jsxs(N,{className:"text-sm font-semibold text-purple-800 flex items-center gap-2",children:[e.jsx(Ae,{className:"h-4 w-4"}),"AI Conversion Insights"]})}),e.jsx(r,{className:"space-y-3",children:e.jsxs("div",{className:"space-y-2",children:[l&&e.jsx("div",{className:"bg-white border border-purple-200 rounded-lg p-3","data-testid":"ai-insight-bottleneck",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Re,{className:"h-4 w-4 text-red-500 mt-0.5 shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold text-gray-800",children:"Biggest Bottleneck"}),e.jsxs("p",{className:"text-xs text-gray-600",children:[f[l.from]||l.from," → ",f[l.to]||l.to," has only ",l.rate,"% pass-through. Focus outreach here."]})]})]})}),e.jsx("div",{className:"bg-white border border-purple-200 rounded-lg p-3","data-testid":"ai-insight-why-failing",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(ke,{className:"h-4 w-4 text-amber-500 mt-0.5 shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold text-gray-800",children:"Why Conversion is Low"}),e.jsx("p",{className:"text-xs text-gray-600",children:A===0?"No vendors have been confirmed yet. Start by reaching out to high-score leads and simplifying the registration process.":A<15?"Most vendors stall at registration or payment. Consider offering early-bird incentives and reducing friction in the onboarding flow.":"Vendors are progressing but dropping at payment stage. Consider flexible payment plans or reminder campaigns."})]})]})}),e.jsx("div",{className:"bg-white border border-purple-200 rounded-lg p-3","data-testid":"ai-insight-recommendation",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Le,{className:"h-4 w-4 text-green-500 mt-0.5 shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold text-gray-800",children:"Recommended Fix"}),e.jsx("p",{className:"text-xs text-gray-600",children:h.length>0?`Send personalized follow-ups to ${h.length} overdue leads. Average recovery rate: ~25%.`:"All leads are being followed up on time. Focus on improving booth availability messaging and payment experience."})]})]})})]})})]})]}),e.jsxs(n,{"data-testid":"card-followup-tracker",children:[e.jsx(j,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(N,{className:"text-lg flex items-center gap-2",children:[e.jsx(re,{className:"h-5 w-5 text-orange-500"}),"Follow-up Tracker",h.length>0&&e.jsxs(b,{variant:"destructive",className:"ml-2","data-testid":"overdue-count",children:[h.length," overdue"]})]}),e.jsxs(o,{size:"sm",variant:"outline","data-testid":"btn-send-all-followups",children:[e.jsx(ne,{className:"h-4 w-4 mr-1"}),"Send All Follow-ups"]})]})}),e.jsx(r,{children:(i?.followUpQueue?.length||0)===0?e.jsxs("div",{className:"text-center py-6","data-testid":"followup-empty",children:[e.jsx(V,{className:"h-10 w-10 text-green-400 mx-auto mb-2"}),e.jsx("p",{className:"text-sm font-medium text-gray-700",children:"All vendors are being followed up on time"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"No overdue follow-ups — the pipeline is healthy."})]}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:(i?.followUpQueue||[]).slice(0,6).map(s=>{const a=new Date(s.lastActivity),x=Math.floor((Date.now()-a.getTime())/(1e3*60*60*24)),k=x>3;return e.jsxs("div",{className:`border rounded-lg p-3 ${k?"border-red-200 bg-red-50":"border-gray-200 bg-white"}`,"data-testid":`followup-card-${s.vendorAccountId}`,children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"font-semibold text-sm text-gray-900",children:s.businessName}),e.jsx(b,{className:k?"bg-red-100 text-red-700":"bg-gray-100 text-gray-600","data-testid":`followup-status-${s.vendorAccountId}`,children:k?`${x}d overdue`:`${x}d ago`})]}),e.jsxs("div",{className:"text-xs text-gray-500 mb-2",children:["Stage: ",f[s.stage]||s.stage," · Score: ",s.leadScore]}),e.jsx("div",{className:"text-xs text-blue-700 bg-blue-50 rounded px-2 py-1 mb-2",children:s.nextBestAction}),e.jsxs(o,{size:"sm",variant:"outline",className:"w-full text-xs","data-testid":`btn-followup-${s.vendorAccountId}`,children:[e.jsx(H,{className:"h-3 w-3 mr-1"}),"Send Follow-up"]})]},s.vendorAccountId)})})})]}),e.jsx("div",{className:"flex gap-2 border-b pb-1",children:he.map(s=>{const a=s.icon;return e.jsxs("button",{onClick:()=>U(s.key),className:`flex items-center gap-2 px-4 py-2 text-sm font-medium rounded-t-lg transition-colors ${m===s.key?"bg-white border border-b-white text-gray-900 -mb-px":"text-gray-500 hover:text-gray-700"}`,"data-testid":`tab-${s.key}`,children:[e.jsx(a,{className:"h-4 w-4"}),s.label,s.count!==void 0&&s.count>0&&e.jsx(b,{variant:"secondary",className:"text-xs",children:s.count})]},s.key)})}),m==="funnel"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs(n,{"data-testid":"card-funnel-analysis",children:[e.jsx(j,{children:e.jsxs(N,{className:"text-lg flex items-center gap-2",children:[e.jsx(te,{className:"h-5 w-5"}),"Funnel Analysis — Stage-to-Stage Drop-off"]})}),e.jsxs(r,{children:[e.jsx("div",{className:"space-y-3",children:K.map(([s,a],x)=>{const k=Math.max(a/me*100,8),L=c?.conversionRates?.[x],M=x>0?K[x-1][1]:a,J=x>0&&M>0?Math.round((M-a)/M*100):0,Y=l&&L&&L.from===l.from&&L.to===l.to;return e.jsxs("div",{"data-testid":`funnel-stage-${s}`,children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(b,{className:`text-xs ${le[s]||"bg-gray-100 text-gray-700"}`,children:f[s]||s}),Y&&e.jsxs(b,{variant:"destructive",className:"text-xs","data-testid":`bottleneck-${s}`,children:[e.jsx(B,{className:"h-3 w-3 mr-1"}),"Bottleneck"]})]}),e.jsxs("div",{className:"flex items-center gap-3 text-sm",children:[e.jsx("span",{className:"font-bold text-gray-900",children:a}),x>0&&J>0&&e.jsxs("span",{className:"text-red-500 text-xs flex items-center gap-0.5","data-testid":`dropoff-${s}`,children:[e.jsx(Te,{className:"h-3 w-3"}),J,"% drop"]}),L&&e.jsxs("span",{className:"text-gray-400 text-xs",children:[e.jsx(be,{className:"h-3 w-3 inline"})," ",L.rate,"%"]})]})]}),e.jsx("div",{className:"w-full bg-gray-100 rounded-full h-6",children:e.jsx("div",{className:`h-6 rounded-full ${Y?"bg-red-400":Ie[s]||"bg-gray-300"} transition-all flex items-center justify-end pr-2`,style:{width:`${k}%`}
1,children:a>0&&e.jsx("span",{className:"text-white text-xs font-medium",children:a})})})]},s)})}),e.jsxs("div",{className:"mt-6 pt-4 border-t grid grid-cols-3 gap-4 text-center",children:[e.jsxs("div",{"data-testid":"funnel-total-pipeline",children:[e.jsx("div",{className:"text-2xl font-bold text-gray-900",children:c?.totalProspects||0}),e.jsx("div",{className:"text-xs text-gray-500",children:"Total in Pipeline"})]}),e.jsxs("div",{"data-testid":"funnel-confirmed",children:[e.jsx("div",{className:"text-2xl font-bold text-emerald-700",children:c?.totalConfirmed||0}),e.jsx("div",{className:"text-xs text-gray-500",children:"Confirmed Vendors"})]}),e.jsxs("div",{"data-testid":"funnel-overall-conversion",children:[e.jsxs("div",{className:"text-2xl font-bold text-blue-700",children:[c?.overallConversionRate||0,"%"]}),e.jsx("div",{className:"text-xs text-gray-500",children:"Overall Conversion"})]})]})]})]}),(i?.recentActivity?.length||0)>0&&e.jsxs(n,{"data-testid":"card-recent-activity",children:[e.jsx(j,{children:e.jsx(N,{className:"text-lg",children:"Recent Activity"})}),e.jsx(r,{children:e.jsx("div",{className:"space-y-2",children:i?.recentActivity?.map((s,a)=>e.jsxs("div",{className:"flex items-center justify-between text-sm bg-gray-50 rounded-lg px-3 py-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ae,{className:"h-4 w-4 text-gray-400"}),e.jsx("span",{className:"font-medium text-gray-900",children:s.vendorName}),e.jsx("span",{className:"text-gray-500",children:s.action})]}),e.jsx("span",{className:"text-gray-400 text-xs",children:new Date(s.timestamp).toLocaleDateString()})]},a))})})]})]}),m==="leads"&&e.jsx(E,{title:"Hot Leads",subtitle:"Highest scoring prospects ready for conversion",icon:e.jsx(z,{className:"h-5 w-5 text-amber-500"}),vendors:i?.hotLeads||[],showLeadScore:!0,showRecommendedAction:!0,testId:"hot-leads"}),m==="followup"&&e.jsx(E,{title:"Follow-up Queue",subtitle:"Vendors needing immediate attention to progress",icon:e.jsx(B,{className:"h-5 w-5 text-orange-500"}),vendors:i?.followUpQueue||[],showNextAction:!0,showLastContact:!0,testId:"followup-queue"}),m==="retention"&&e.jsx(E,{title:"Retention Candidates",subtitle:"Top vendors likely to participate again",icon:e.jsx(Q,{className:"h-5 w-5 text-green-500"}),vendors:i?.retentionCandidates||[],showRetentionScore:!0,testId:"retention-candidates"}),m==="upsell"&&e.jsx(E,{title:"Premium Upsell Opportunities",subtitle:"Confirmed vendors who could upgrade their booth or plan",icon:e.jsx(F,{className:"h-5 w-5 text-indigo-500"}),vendors:i?.upsellOpportunities||[],showLeadScore:!0,testId:"upsell-opportunities"})]})}function E({title:m,subtitle:U,icon:p,vendors:v,showLeadScore:O,showRetentionScore:$,showNextAction:w,showRecommendedAction:T,showLastContact:_,testId:C}){const[S,I]=g.useState(null);return e.jsxs(n,{"data-testid":`card-${C}`,children:[e.jsxs(j,{children:[e.jsxs(N,{className:"text-lg flex items-center gap-2",children:[p,m,e.jsx(b,{variant:"secondary",className:"ml-2",children:v.length})]}),e.jsx("p",{className:"text-sm text-gray-500",children:U})]}),e.jsx(r,{children:v.length===0?e.jsxs("div",{className:"text-center py-8","data-testid":`${C}-empty`,children:[e.jsx(ie,{className:"h-10 w-10 text-gray-300 mx-auto mb-2"}),e.jsx("p",{className:"text-gray-500 font-medium",children:"No vendors in this category"}),e.jsx("p",{className:"text-xs text-gray-400 mt-1",children:"Vendors will appear here as they progress through the funnel"})]}):e.jsx("div",{className:"space-y-2",children:v.map(t=>{const y=S===t.vendorAccountId,i=new Date(t.lastActivity),P=Math.floor((Date.now()-i.getTime())/(1e3*60*60*24));return e.jsxs("div",{className:"border rounded-lg p-3 hover:bg-gray-50 transition-colors","data-testid":`vendor-card-${t.vendorAccountId}`,children:[e.jsxs("div",{className:"flex items-center justify-between cursor-pointer",onClick:()=>I(y?null:t.vendorAccountId),children:[e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold text-gray-900",children:t.businessName}),e.jsxs("div",{className:"text-xs text-gray-500",children:[t.email," · ",e.jsx("span",{className:"capitalize",children:t.vendorType}),_&&e.jsxs("span",{className:`ml-2 ${P>3?"text-red-500 font-medium":"text-gray-400"}`,children:["· Last contact: ",P,"d ago"]})]})]})}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(b,{className:le[t.stage]||"bg-gray-100 text-gray-700",children:f[t.stage]||t.stage}),O&&e.jsxs("div",{className:"text-right",children:[e.jsx("div",{className:"text-lg font-bold text-indigo-700",children:t.leadScore}),e.jsx("div",{className:"text-xs text-gray-400",children:"Lead Score"})]}),$&&e.jsxs("div",{className:"text-right",children:[e.jsx("div",{className:"text-lg font-bold text-green-700",children:t.retentionScore}),e.jsx("div",{className:"text-xs text-gray-400",children:"Retention"})]}),e.jsx(Fe,{className:`h-4 w-4 text-gray-400 transition-transform ${y?"rotate-90":""}`})]})]}),y&&e.jsxs("div",{className:"mt-3 pt-3 border-t space-y-3",children:[w!==!1&&e.jsxs("div",{className:"bg-blue-50 border border-blue-200 rounded-lg px-3 py-2 text-sm",children:[e.jsx("span",{className:"font-medium text-blue-800",children:"Next Best Action:"})," ",e.jsx("span",{className:"text-blue-700",children:t.nextBestAction})]}),T&&e.jsxs("div",{className:"flex gap-2","data-testid":`vendor-actions-${t.vend
1orAccountId}`,children:[e.jsxs(o,{size:"sm",variant:"default",className:"text-xs","data-testid":`btn-contact-${t.vendorAccountId}`,children:[e.jsx(H,{className:"h-3 w-3 mr-1"}),"Contact Now"]}),e.jsxs(o,{size:"sm",variant:"outline",className:"text-xs","data-testid":`btn-schedule-${t.vendorAccountId}`,children:[e.jsx(re,{className:"h-3 w-3 mr-1"}),"Schedule Follow-up"]}),e.jsxs(o,{size:"sm",variant:"outline",className:"text-xs","data-testid":`btn-offer-${t.vendorAccountId}`,children:[e.jsx(F,{className:"h-3 w-3 mr-1"}),"Send Offer"]})]}),e.jsx("div",{className:"grid grid-cols-3 md:grid-cols-6 gap-2",children:Object.entries(t.scoreBreakdown).filter(([u])=>u!=="total").map(([u,d])=>{const c={profileComplete:"Profile",hasSubscription:"Subscription",hasBooth:"Booth",hasDocuments:"Documents",paymentStatus:"Payment",engagement:"Engagement"};return e.jsxs("div",{className:"bg-gray-50 rounded p-2 text-center",children:[e.jsx("div",{className:"text-xs text-gray-500",children:c[u]||u}),e.jsx("div",{className:"text-sm font-bold text-gray-900",children:d})]},u)})}),e.jsxs("div",{className:"flex items-center gap-4 text-xs text-gray-400",children:[e.jsxs("span",{children:["Last active: ",new Date(t.lastActivity).toLocaleDateString()]}),t.acquisitionSource&&e.jsxs("span",{children:["Source: ",t.acquisitionSource]}),t.repeatCount>0&&e.jsxs("span",{children:["Repeat: ",t.repeatCount,"x"]})]})]})]},t.vendorAccountId)})})})]})}export{Ye 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.