1import{r as o,j as e}from"./vendor-react-CfkQo2Qg.js";import{t as i,d,L as T,B as c}from"./index-DgwJNwTT.js";import{B as X}from"./Breadcrumbs-C5_OWaxK.js";import{R as Y}from"./RelatedTools-BdteHLPx.js";import{C as a}from"./card-CcbKiFa6.js";import{aa as J,r as _,a7 as p,k as D,j as I,Z as $,g as E,E as A,n as F,v as K,h as Q,a2 as ee,ao as U,al as se,ba as te,bb as ae,aq as ne,i as ie,a9 as q,ak as re,b8 as ce,bc as le}from"./vendor-lucide-CpuI9xs4.js";import"./vendor-cytoscape-q9j-66rY.js";import"./vendor-trpc-CqKgE1xI.js";import"./vendor-vite-preload-BXl3LOEh.js";import"./vendor-radix-overlay-DthDVWT0.js";import"./vendor-radix-base-ZbR3PUjz.js";import"./vendor-recharts-Cht0p0lU.js";import"./vendor-d3-CzMK0bJS.js";import"./vendor-framer-BGJAXFmM.js";function ve(){const[m,G]=o.useState("dashboard"),[h,j]=o.useState(!1),[C,N]=o.useState(!1),[f,S]=o.useState(""),[P,H]=o.useState("industry_search"),[M,k]=o.useState(!1),[z,O]=o.useState(null),R=i.aiMonitoring.getDashboard.useQuery(void 0,{refetchInterval:h?5e3:!1}),l=i.aiMonitoring.getPrompts.useQuery(),n=i.aiMonitoring.getRuns.useQuery({limit:20}),g=i.aiMonitoring.getRecentCitations.useQuery({limit:10}),u=i.aiMonitoring.getRunResults.useQuery({limit:50}),x=i.aiMonitoring.seedPrompts.useMutation({onSuccess:s=>{d.success(s.message||"Prompts seeded"),l.refetch()},onError:s=>d.error(s.message)}),w=i.aiMonitoring.addPrompt.useMutation({onSuccess:()=>{d.success("Prompt added"),S(""),k(!1),l.refetch()},onError:s=>d.error(s.message)}),V=i.aiMonitoring.togglePrompt.useMutation({onSuccess:()=>l.refetch()}),W=i.aiMonitoring.deletePrompt.useMutation({onSuccess:()=>{d.success("Prompt deleted"),l.refetch()}}),b=i.aiMonitoring.runScan.useMutation({onMutate:()=>j(!0),onSuccess:s=>{j(!1),d.success(`Scan complete: ${s.completed} queries. Brand mention rate: ${s.mentionRate.toFixed(1)}%`),R.refetch(),n.refetch(),u.refetch(),g.refetch()},onError:s=>{j(!1),d.error(`Scan failed: ${s.message}`)}}),t=R.data,Z=[{id:"dashboard",label:"Dashboard",icon:_},{id:"prompts",label:"Prompts",icon:E},{id:"results",label:"Results",icon:A},{id:"runs",label:"Run History",icon:F}],B=s=>s==="positive"?"text-green-400":s==="negative"?"text-red-400":"text-zinc-400",L=s=>s==="positive"?e.jsx(Q,{className:"h-4 w-4 text-green-400"}):s==="negative"?e.jsx(ce,{className:"h-4 w-4 text-red-400"}):e.jsx(le,{className:"h-4 w-4 text-zinc-400"}),v=s=>({chatgpt:"ChatGPT",perplexity:"Perplexity",gemini:"Gemini",claude:"Claude"})[s]||s,y=s=>({chatgpt:"bg-green-500/20 text-green-400 border-green-500/30",perplexity:"bg-blue-500/20 text-blue-400 border-blue-500/30",gemini:"bg-purple-500/20 text-purple-400 border-purple-500/30",claude:"bg-orange-500/20 text-orange-400 border-orange-500/30"})[s]||"bg-zinc-500/20 text-zinc-400 border-zinc-500/30";return e.jsxs("div",{className:"min-h-screen bg-background p-4 md:p-8",children:[e.jsxs("div",{className:"max-w-7xl mx-auto",children:[e.jsx(X,{items:[{label:"Admin",href:"/admin"},{label:"AI Monitoring"}]}),e.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[e.jsx(T,{href:"/admin",children:e.jsx(c,{variant:"ghost",size:"icon",className:"text-zinc-400 hover:text-white",children:e.jsx(J,{className:"h-5 w-5"})})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h1",{className:"text-3xl font-bold text-white",children:"AI Citation Monitor"}),e.jsx("p",{className:"text-zinc-400 text-sm mt-1",children:"Track brand visibility across ChatGPT, Perplexity, Gemini, and Claude"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-xs text-[#9ADD26] bg-[#9ADD26]/10 px-2 py-0.5 rounded-full",children:[e.jsx("span",{className:"w-1.5 h-1.5 bg-[#9ADD26] rounded-full animate-pulse"}),"Auto-scan: Sundays 2:00 AM ET"]}),n.data&&n.data.length>0&&e.jsxs("span",{className:"text-xs text-zinc-500",children:["Last scan: ",new Date(n.data[0].startedAt).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"}),n.data[0].triggeredBy==="weekly_cron"?" (auto)":" (manual)"]})]})]}),e.jsx(T,{href:"/admin/content-calendar",children:e.jsxs(c,{variant:"outline",className:"border-[#9ADD26]/30 text-[#9ADD26] hover:bg-[#9ADD26]/10 mr-2",children:[e.jsx(_,{className:"h-4 w-4 mr-1"})," Content Calendar"]})}),e.jsxs("div",{className:"relative flex",children:[e.jsx(c,{onClick:()=>b.mutate({engines:["chatgpt"],scanMode:"standard"}),disabled:h,className:"bg-[#9ADD26] text-black hover:bg-[#8BC922] font-semibold rounded-r-none border-r border-[#7ab820]",children:h?e.jsxs(e.Fragment,{children:[e.jsx(p,{className:"h-4 w-4 mr-2 animate-spin"}),"Scanning..."]}):e.jsxs(e.Fragment,{children:[e.jsx(D,{className:"h-4 w-4 mr-2"}),"Run Scan"]})}),e.jsx(c,{onClick:()=>N(!C),disabled:h,className:"bg-[#9ADD26] text-black hover:bg-[#8BC922] font-semibold rounded-l-none px-2",children:e.jsx(I,{className:"h-4 w-4"})}),C&&e.jsxs("div",{className:"absolute right-0 top-full mt-1 w-56 bg-zinc-900 border border-zinc-700 rounded-lg shadow-xl z-50",children:[e.jsxs("button",{className:"w-full flex items-center gap-3 px-4 py-3 text-sm text-white hover:bg-zinc-800 rounded-t-lg",onClick:()=>{N(!1),b.mutate({engines:["chatgpt"],scanMode:"standard"})},children:[e.jsx(D,{className:"h-4 w-4 text-[#9ADD26]"}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"font-medium",children:"Run Scan"}),e.jsx("p",{className:"text-xs text-zinc-500",children:"Sonar â standard depth"})]})]}),e.jsxs("button",{className:"w-full flex items-center gap-3 px-4 py-3 text-sm text-white hover:bg-zinc-800 rounded-b-lg border-t border-zinc-800",onClick:()=>{N(!1),b.mutate({engines:["chatgpt"],scanMode:"premium"})},children:[e.jsx($,{className:"h-4 w-4 text-amber-400"}),e.jsxs("div",{className:"text-left",children:[e.jsxs("p",{className:"font-medium flex items-center gap-2",children:["Run Premium Scan",e.jsx("span",{className:"text-xs px-1.5 py-0.5 bg-amber-500/20 text-amber-400 border border-amber-500/30 rounded",children:"PRO"})]}),e.jsx("p",{className:"text-xs text-zinc-500",children:"Sonar Pro â deeper citations"})]})]})]})]})]}),e.jsx("div",{className:"flex gap-1 mb-6 bg-zinc-900 rounded-lg p-1
1w-fit",children:Z.map(s=>{const r=s.icon;return e.jsxs("button",{onClick:()=>G(s.id),className:`flex items-center gap-2 px-4 py-2 rounded-md text-sm font-medium transition-all ${m===s.id?"bg-[#9ADD26] text-black":"text-zinc-400 hover:text-white hover:bg-zinc-800"}`,children:[e.jsx(r,{className:"h-4 w-4"}),s.label]},s.id)})}),m==="dashboard"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[e.jsxs(a,{className:"bg-zinc-900 border-zinc-800 p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-zinc-400 text-sm",children:"Brand Mention Rate"}),e.jsx(A,{className:"h-5 w-5 text-[#9ADD26]"})]}),e.jsxs("p",{className:"text-3xl font-bold text-white",children:[t?.metrics.mentionRate.toFixed(1)||"0","%"]}),e.jsxs("p",{className:"text-xs text-zinc-500 mt-1",children:[t?.metrics.totalMentions||0," of ",t?.metrics.totalQueries||0," queries"]})]}),e.jsxs(a,{className:"bg-zinc-900 border-zinc-800 p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-zinc-400 text-sm",children:"URL Citation Rate"}),e.jsx(K,{className:"h-5 w-5 text-blue-400"})]}),e.jsxs("p",{className:"text-3xl font-bold text-white",children:[t?.metrics.citationRate.toFixed(1)||"0","%"]}),e.jsxs("p",{className:"text-xs text-zinc-500 mt-1",children:[t?.metrics.totalCitations||0," direct URL citations"]})]}),e.jsxs(a,{className:"bg-zinc-900 border-zinc-800 p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-zinc-400 text-sm",children:"Sentiment"}),e.jsx(Q,{className:"h-5 w-5 text-green-400"})]}),e.jsxs("div",{className:"flex items-baseline gap-3",children:[e.jsx("span",{className:"text-green-400 text-xl font-bold",children:t?.metrics.sentiment.positive||0}),e.jsx("span",{className:"text-zinc-400 text-xl font-bold",children:t?.metrics.sentiment.neutral||0}),e.jsx("span",{className:"text-red-400 text-xl font-bold",children:t?.metrics.sentiment.negative||0})]}),e.jsx("p",{className:"text-xs text-zinc-500 mt-1",children:"Positive / Neutral / Negative"})]}),e.jsxs(a,{className:"bg-zinc-900 border-zinc-800 p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-zinc-400 text-sm",children:"Total Scans"}),e.jsx($,{className:"h-5 w-5 text-yellow-400"})]}),e.jsx("p",{className:"text-3xl font-bold text-white",children:t?.totalRuns||0}),e.jsx("p",{className:"text-xs text-zinc-500 mt-1",children:t?.latestRun?`Last: ${new Date(t.latestRun.startedAt).toLocaleDateString()}`:"No scans yet"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[e.jsxs(a,{className:"bg-zinc-900 border-zinc-800 p-6",children:[e.jsx("h3",{className:"text-lg font-semibold text-white mb-4",children:"Visibility by AI Engine"}),t?.engineBreakdown&&t.engineBreakdown.length>0?e.jsx("div",{className:"space-y-4",children:t.engineBreakdown.map(s=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:`text-sm font-medium px-2 py-1 rounded border ${y(s.engine)}`,children:v(s.engine)}),e.jsxs("span",{className:"text-white font-semibold",children:[s.mentionRate.toFixed(1),"%"]})]}),e.jsx("div",{className:"w-full bg-zinc-800 rounded-full h-2",children:e.jsx("div",{className:"bg-[#9ADD26] h-2 rounded-full transition-all",style:{width:`${Math.min(s.mentionRate,100)}%`}})}),e.jsxs("p",{className:"text-xs text-zinc-500",children:[s.mentions," mentions / ",s.citations," citations out of ",s.total," queries"]})]},s.engine))}):e.jsx("p",{className:"text-zinc-500 text-sm",children:"Run a scan to see engine breakdown"})]}),e.jsxs(a,{className:"bg-zinc-900 border-zinc-800 p-6",children:[e.jsx("h3",{className:"text-lg font-semibold text-white mb-4",children:"Top Competitors Mentioned"}),t?.topCompetitors&&t.topCompetitors.length>0?e.jsx("div",{className:"space-y-3",children:t.topCompetitors.map((s,r)=>e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"text-zinc-500 text-sm w-6",children:[r+1,"."]}),e.jsx("span",{className:"text-white text-sm",children:s.name})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-24 bg-zinc-800 rounded-full h-1.5",children:e.jsx("div",{className:"bg-red-500/60 h-1.5 rounded-full",style:{width:`${Math.min(s.count/(t.topCompetitors[0]?.count||1)*100,100)}%`}})}),e.jsx("span",{className:"text-zinc-400 text-xs w-8 text-right",children:s.count})]})]},s.name))}):e.jsx("p",{className:"text-zinc-500 text-sm",children:"Run a scan to see competitor analysis"})]})]}),t?.trendData&&t.trendData.length>1&&e.jsxs(a,{className:"bg-zinc-900 border-zinc-800 p-6",children:[e.jsx("h3",{className:"text-lg font-semibold text-white mb-4",children:"Mention Rate Trend"}),e.jsx("div",{className:"flex items-end gap-2 h-40",children:t.trendData.map((s,r)=>e.jsxs("div",{className:"flex flex-col items-center flex-1 gap-1",children:[e.jsxs("span",{className:"text-xs text-zinc-400",children:[s.mentionRate.toFixed(0),"%"]}),e.jsx("div",{className:"w-full bg-[#9ADD26]/80 rounded-t min-h-[4px] transition-all",style:{height:`${Math.max(s.mentionRate*1.2,4)}px`}}),e.jsx("span",{className:"text-[10px] text-zinc-500",children:new Date(s.date).toLocaleDateString("en-US",{month:"short",day:"numeric"})})]},s.runId))})]}),e.jsxs(a,{className:"bg-zinc-900 border-zinc-800 p-6",children:[e.jsx("h3",{className:"text-lg font-semibold text-white mb-4",children:"Recent Brand Mentions"}),g.data&&g.data.length>0?e.jsx("div",{className:"space-y-3",children:g.data.map(s=>e.jsxs("div",{className:"border border-zinc-800 rounded-lg p-4",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("span",{className:`text-xs px-2 py-0.5 rounded border ${y(s.engine)}`,children:v(s.engine)}),L(s.sentiment),e.jsx("span",{className:`text-xs ${B(s.sentiment)}`,children:s.sentiment}),s.brandCited&&e.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-[#9ADD26]/20 text-[#9ADD26] border border-[#9ADD26]/30",children:"URL Cited"}),s.mentionPosition&&e.jsxs("span",{className:"text-xs text-zinc-500",children:["Position: ",s.mentionPosition===1?"Top":s.mentionPosition===2?"Middle":"Bottom"]})]}),e.jsxs("p",{className:"text-xs text-zinc-500 mb-1",children:['Query: "',s.prompt,'"']}),s.snippet&&e.jsxs("p",{className:"text-sm text-zinc-300 italic border-l-2 border-[#9ADD26]/40 pl-3 mt-2",children:['"',s.snippet,'"']}),e.jsx("p",{className:"text-xs text-zinc-600 mt-2",children:new Date(s.queriedAt).toLocaleStr
1ing()})]},s.id))}):e.jsx("p",{className:"text-zinc-500 text-sm",children:"No brand mentions found yet. Run a scan to start tracking."})]}),(!t||t.totalRuns===0)&&e.jsxs(a,{className:"bg-zinc-900 border-zinc-800 p-12 text-center",children:[e.jsx(ee,{className:"h-16 w-16 text-zinc-700 mx-auto mb-4"}),e.jsx("h3",{className:"text-xl font-semibold text-white mb-2",children:"No Monitoring Data Yet"}),e.jsx("p",{className:"text-zinc-400 mb-6 max-w-md mx-auto",children:"Start by seeding the default monitoring prompts, then run your first scan to see how your brand appears across AI engines."}),e.jsxs("div",{className:"flex gap-3 justify-center",children:[e.jsxs(c,{onClick:()=>x.mutate(),variant:"outline",className:"border-zinc-700 text-zinc-300 hover:bg-zinc-800",disabled:x.isPending,children:[x.isPending?e.jsx(p,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(U,{className:"h-4 w-4 mr-2"}),"Seed Default Prompts"]}),e.jsxs(c,{onClick:()=>b.mutate({engines:["chatgpt"]}),disabled:h,className:"bg-[#9ADD26] text-black hover:bg-[#8BC922]",children:[e.jsx(D,{className:"h-4 w-4 mr-2"}),"Run First Scan"]})]})]})]}),m==="prompts"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"text-xl font-semibold text-white",children:"Monitoring Prompts"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(c,{onClick:()=>x.mutate(),variant:"outline",size:"sm",className:"border-zinc-700 text-zinc-300 hover:bg-zinc-800",disabled:x.isPending,children:[x.isPending?e.jsx(p,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(se,{className:"h-4 w-4 mr-2"}),"Seed Defaults"]}),e.jsxs(c,{onClick:()=>k(!M),size:"sm",className:"bg-[#9ADD26] text-black hover:bg-[#8BC922]",children:[e.jsx(U,{className:"h-4 w-4 mr-2"}),"Add Prompt"]})]})]}),M&&e.jsx(a,{className:"bg-zinc-900 border-zinc-800 p-4",children:e.jsxs("div",{className:"space-y-3",children:[e.jsx("input",{type:"text",value:f,onChange:s=>S(s.target.value),placeholder:"Enter a monitoring prompt (e.g., 'Best AI solutions for manufacturing')",className:"w-full bg-zinc-800 border border-zinc-700 rounded-lg px-4 py-2 text-white placeholder-zinc-500 focus:outline-none focus:border-[#9ADD26]"}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("select",{value:P,onChange:s=>H(s.target.value),className:"bg-zinc-800 border border-zinc-700 rounded-lg px-3 py-2 text-white text-sm focus:outline-none focus:border-[#9ADD26]",children:[e.jsxs("optgroup",{label:"General",children:[e.jsx("option",{value:"brand_awareness",children:"Brand Awareness"}),e.jsx("option",{value:"industry_search",children:"Industry Search"})]}),e.jsxs("optgroup",{label:"Industry Verticals",children:[e.jsx("option",{value:"3pl_warehouse",children:"3PL & Warehouse"}),e.jsx("option",{value:"manufacturing",children:"Manufacturing & QC"}),e.jsx("option",{value:"healthcare",children:"Healthcare Ops"}),e.jsx("option",{value:"msp",children:"MSP & IT Services"})]}),e.jsxs("optgroup",{label:"Products",children:[e.jsx("option",{value:"product_hatz",children:"Hatz AI Platform"}),e.jsx("option",{value:"product_vision",children:"Vision Systems"})]}),e.jsxs("optgroup",{label:"Other",children:[e.jsx("option",{value:"competitor_comparison",children:"Competitor Comparison"}),e.jsx("option",{value:"training",children:"Training & Education"}),e.jsx("option",{value:"roi_impact",children:"ROI & Business Impact"})]})]}),e.jsx(c,{onClick:()=>w.mutate({prompt:f,category:P}),disabled:!f||w.isPending,size:"sm",className:"bg-[#9ADD26] text-black hover:bg-[#8BC922]",children:w.isPending?e.jsx(p,{className:"h-4 w-4 animate-spin"}):"Add"})]})]})}),l.data&&l.data.length>0?e.jsx("div",{className:"space-y-2",children:l.data.map(s=>e.jsx(a,{className:`border p-4 ${s.active?"bg-zinc-900 border-zinc-800":"bg-zinc-950 border-zinc-900 opacity-60"}`,children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:()=>V.mutate({id:s.id}),className:"text-zinc-400 hover:text-[#9ADD26] transition-colors",children:s.active?e.jsx(te,{className:"h-6 w-6 text-[#9ADD26]"}):e.jsx(ae,{className:"h-6 w-6"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-white text-sm",children:s.prompt}),e.jsx("span",{className:`text-xs mt-1 inline-block px-2 py-0.5 rounded ${s.category==="3pl_warehouse"?"bg-blue-900/50 text-blue-300":s.category==="manufacturing"?"bg-orange-900/50 text-orange-300":s.category==="healthcare"?"bg-red-900/50 text-red-300":s.category==="msp"?"bg-purple-900/50 text-purple-300":s.category==="product_hatz"?"bg-[#9ADD26]/20 text-[#9ADD26]":s.category==="product_vision"?"bg-cyan-900/50 text-cyan-300":s.category==="competitor_comparison"?"bg-yellow-900/50 text-yellow-300":s.category==="training"?"bg-pink-900/50 text-pink-300":s.category==="roi_impact"?"bg-emerald-900/50 text-emerald-300":"bg-zinc-800 text-zinc-500"}`,children:{brand_awareness:"Brand Awareness",industry_search:"Industry Search","3pl_warehouse":"3PL & Warehouse",manufacturing:"Manufacturing & QC",healthcare:"Healthcare Ops",msp:"MSP & IT Services",product_hatz:"Hatz AI Platform",product_vision:"Vision Systems",competitor_comparison:"Competitor Comparison",training:"Training & Education",roi_impact:"ROI & Business Impact"}[s.category]||s.category})]}),e.jsx("button",{onClick:()=>W.mutate({id:s.id}),className:"text-zinc-600 hover:text-red-400 transition-colors",children:e.jsx(ne,{className:"h-4 w-4"})})]})},s.id))}):e.jsxs(a,{className:"bg-zinc-900 border-zinc-800 p-8 text-center",children:[e.jsx(E,{className:"h-12 w-12 text-zinc-700 mx-auto mb-3"}),e.jsx("p",{className:"text-zinc-400",children:"No prompts configured. Seed defaults or add custom prompts."})]})]}),m==="results"&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("h2",{className:"text-xl font-semibold text-white",children:"Scan Results"}),u.data&&u.data.length>0?e.jsx("div",{className:"space-y-2",children:u.data.map(s=>e.jsxs(a,{className:"bg-zinc-900 border-zinc-800 p-4",children:[e.jsxs("div",{className:"flex items-center gap-3 cursor-pointer",onClick:()=>O(z===s.id?null:s.id),children:[s.brandMentioned?e.jsx(ie,{className:"h-5 w-5 text-[#9ADD26] shrink-0"}):e.jsx(q,{className:"h-5 w-5 text-zinc-600 shrink-0"}),e.jsx("span",{className:`text-xs px-2 py-0.5 rounded border shrink-0 ${y(s.engine)}`,children:v(s.engine)}),e.jsx("p",{className:"text-sm text-white flex-1 truncate",children:s.prompt?.prompt||"Unknown prompt"}),L(s.sentiment),s.brandCited&&e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-[#9ADD26]/20 text-[#9ADD26] border border-[#9ADD26]/30 shrink-0",children:"Cited"}),e.jsx("span",{className:"text-xs text-zinc-500 shrink-0",children:new Date(s.queriedAt).toLocaleDateString()}),z===s.id?e.jsx(re,{className:"h-4 w-4 text-zinc-500 shrink-0"}):e.jsx(I,{className:"h-4 w-4 text-zinc-500 shrink-0"})]}),z===s.id&&e.jsxs("div",{className:"mt-4 pt-4 border-t border-zinc-800 space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-zinc-500 text-xs",children:"Mentions"}),e.jsx("p",{className:"text-white font-medium",children:s.mentionCount})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-zinc-500 text-xs",children:"Position"}),e.jsx("p",{className:"text-white font-medium",children:s.mentionPosition===1?"Top Third":s.mentionPosition===2?"Middle":s.mentionPosition===3?"Bottom Third":"N/A"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-zinc-500 text-xs",children:"Sentiment"}),e.jsx("p",{className:`font-medium ${B(s.sentiment)}`,children:s.sentiment||"N/A"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-zinc-500 text-xs",children:"Competitors Found"}),e.jsx("p",{className:"text-white font-medium",children:s.competitorsMentioned?.length||0})]})]}),s.competitorsMentioned?.length>0&&e.jsxs("div",{children:[e.jsx("span",{className:"text-zinc-500 text-xs",children:"Competitors:"}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:s.competitorsMentioned.map(r=>e.jsx("span",{className:"text-xs px-2 py-0.5 bg-red-500/10 text-red-400 rounded border border-red-500/20",children:r},r))})]}),s.responseSnippet&&e.jsxs("div",{children:[e.jsx("span",{className:"text-zinc-500 text-xs",children:"Response Snippet:"}),e.jsxs("p",{className:"text-sm text-zinc-300 mt-1 italic border-l-2 border-[#9ADD26]/40 pl-3",children:['"',s.responseSnippet,'"']})]}),e.jsxs("details",{className:"text-xs",children:[e.jsx("summary",{className:"text-zinc-500 cursor-pointer hover:text-zinc-300",children:"View Full Response"}),e.jsx("pre",{className:"mt-2 p-3 bg-zinc-950 rounded-lg text-zinc-400 whitespace-pre-wrap text-xs max-h-60 overflow-y-auto",children:s.response})]})]})]},s.id))}):e.jsxs(a,{className:"bg-zinc-900 border-zinc-800 p-8 text-center",children:[e.jsx(A,{className:"h-12 w-12 text-zinc-700 mx-auto mb-3"}),e.jsx("p",{className:"text-zinc-400",children:"No results yet. Run a scan to see results."})]})]}),m==="runs"&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("h2",{className:"text-xl font-semibold text-white",children:"Scan History"}),n.isLoading?e.jsxs(a,{className:"bg-zinc-900 border-zinc-800 p-8 text-center",children:[e.jsx(p,{className:"h-8 w-8 text-zinc-700 mx-auto mb-3 animate-spin"}),e.jsx("p",{className:"text-zinc-400",children:"Loading scan history..."})]}):n.error?e.jsxs(a,{className:"bg-zinc-900 border-zinc-800 p-8 text-center",children:[e.jsx(q,{className:"h-12 w-12 text-red-500 mx-auto mb-3"}),e.jsxs("p",{className:"text-red-400",children:["Error loading runs: ",n.error.message]})]}):n.data&&n.data.length>0?e.jsx("div",{className:"space-y-2",children:n.data.map(s=>e.jsx(a,{className:"bg-zinc-900 border-zinc-800 p-4",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:`w-3 h-3 rounded-full shrink-0 ${s.status==="completed"?"bg-green-500":s.status==="running"?"bg-yellow-500 animate-pulse":"bg-red-500"}`}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-white font-medium text-sm",children:["Scan #",s.id]}),e.jsx("span",{className:`text-xs px-2 py-0.5 rounded ${s.triggeredBy==="weekly_cron"?"bg-[#9ADD26]/10 text-[#9ADD26]":s.triggeredBy==="scheduled"?"bg-blue-500/10 text-blue-400":"bg-zinc-800 text-zinc-500"}`,children:s.triggeredBy==="weekly_cron"?"â° Auto (Weekly)":s.triggeredBy==="scheduled"?"â° Scheduled":"â¶ Manual"}),s.scanMode==="premium"?e.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-amber-500/20 text-amber-400 border border-amber-500/30",children:"â¡ Sonar Pro"}):e.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-zinc-800 text-zinc-500",children:"Sonar"})]}),e.jsxs("p",{className:"text-xs text-zinc-500 mt-1",children:[new Date(s.startedAt).toLocaleStr
1ing(),s.completedAt&&` â Completed ${new Date(s.completedAt).toLocaleString()}`]})]}),e.jsxs("div",{className:"text-right shrink-0",children:[e.jsx("p",{className:"text-sm text-white font-medium",children:s.brandMentionRate?`${parseFloat(s.brandMentionRate).toFixed(1)}%`:"N/A"}),e.jsxs("p",{className:"text-xs text-zinc-500",children:[s.completedPrompts,"/",s.totalPrompts," queries",s.failedPrompts>0&&` (${s.failedPrompts} failed)`]})]})]})},s.id))}):e.jsxs(a,{className:"bg-zinc-900 border-zinc-800 p-8 text-center",children:[e.jsx(F,{className:"h-12 w-12 text-zinc-700 mx-auto mb-3"}),e.jsx("p",{className:"text-zinc-400",children:"No scan history yet."})]})]})]}),e.jsx(Y,{currentPath:"/admin/ai-monitoring"})]})}export{ve 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.