1import{b as o,j as t}from"./query-uMsrUIDK.js";import{r as c}from"./vendor-P4SDRn1a.js";import{b as l}from"./index-BsOjzVjK.js";import{I as x}from"./Skeleton-Cg8AW_-o.js";function b(){const[a,d]=c.useState(30),{data:s,isLoading:n}=o({queryKey:["admin-attribution",a],queryFn:async()=>{const{data:e}=await l.get("/analytics/attribution",{params:{days:a}});return e},staleTime:2*6e4});return t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsx("h2",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider",children:"Marketing Attribution"}),t.jsx("div",{className:"flex gap-1",children:[7,14,30].map(e=>t.jsxs("button",{onClick:()=>d(e),className:`px-2.5 py-1 rounded text-xs transition-colors cursor-pointer ${a===e?"bg-primary/10 text-primary-light border border-primary/30":"text-text-muted hover:text-text border border-transparent"}`,children:[e,"d"]},e))})]}),n?t.jsx("div",{className:"py-10",children:t.jsx(x,{})}):s?t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsxs("div",{className:"bg-surface border border-border rounded-lg p-4",children:[t.jsx("div",{className:"text-xs text-text-muted uppercase tracking-wider mb-1",children:"Attributed Events"}),t.jsx("div",{className:"text-lg font-bold",children:s.total_attributed.toLocaleString()})]}),t.jsxs("div",{className:"bg-surface border border-border rounded-lg p-4",children:[t.jsx("div",{className:"text-xs text-text-muted uppercase tracking-wider mb-1",children:"Unattributed Events"}),t.jsx("div",{className:"text-lg font-bold",children:s.total_unattributed.toLocaleString()})]})]}),s.sources.length>0?t.jsxs("div",{className:"bg-surface border border-border rounded-lg p-4",children:[t.jsx("h3",{className:"text-xs text-text-muted uppercase tracking-wider mb-3",children:"By Source"}),t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full text-xs",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b border-border",children:[t.jsx("th",{className:"text-left py-2 pr-4 text-text-muted font-medium",children:"Source"}),t.jsx("th",{className:"text-left py-2 pr-4 text-text-muted font-medium",children:"Medium"}),t.jsx("th",{className:"text-right py-2 pr-4 text-text-muted font-medium",children:"Page Views"}),t.jsx("th",{className:"text-right py-2 pr-4 text-text-muted font-medium",children:"CTA Clicks"}),t.jsx("th",{className:"text-right py-2 pr-4 text-text-muted font-medium",children:"Reg Start"}),t.jsx("th",{className:"text-right py-2 pr-4 text-text-muted font-medium",children:"Reg Complete"}),t.jsx("th",{className:"text-right py-2 pr-4 text-text-muted font-medium",children:"First Action"}),t.jsx("th",{className:"text-right py-2 text-text-muted font-medium",children:"Total"})]})}),t.jsx("tbody",{children:s.sources.map(e=>{const r={};for(const i of e.events)r[i.event_type]=i.count;return t.jsxs("tr",{className:"border-b border-border/50",children:[t.jsx("td",{className:"py-2 pr-4 font-medium",children:e.source}),t.jsx("td",{className:"py-2 pr-4 text-text-muted",children:e.medium||"-"}),t.jsx("td",{className:"py-2 pr-4 text-right font-mono",children:(r.guest_page_view||0).toLocaleString()}),t.jsx("td",{className:"py-2 pr-4 text-right font-mono",children:(r.guest_cta_click||0).toLocaleString()}),t.jsx("td",{className:"py-2 pr-4 text-right font-mono",children:(r.register_start||0
1).toLocaleString()}),t.jsx("td",{className:"py-2 pr-4 text-right font-mono",children:t.jsx("span",{className:r.register_complete?"text-success":"",children:(r.register_complete||0).toLocaleString()})}),t.jsx("td",{className:"py-2 pr-4 text-right font-mono",children:t.jsx("span",{className:r.first_action?"text-primary-light":"",children:(r.first_action||0).toLocaleString()})}),t.jsx("td",{className:"py-2 text-right font-mono font-medium",children:e.total.toLocaleString()})]},`${e.source}-${e.medium}`)})})]})})]}):t.jsxs("div",{className:"bg-surface border border-border rounded-lg p-6 text-center",children:[t.jsx("p",{className:"text-sm text-text-muted",children:"No UTM-attributed events yet."}),t.jsx("p",{className:"text-xs text-text-muted mt-1",children:"Marketing bot links with utm_source params will appear here."})]})]}):null]})}export{b 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.