1import{f as a,fv as f,j as e}from"./index-BlPuTuyh.js";const i=t=>`${Math.round(t*1e3)/10}%`,v={auto_signup_day:"Auto invite (day N)",auto_reminder:"Auto reminder",manual:"Manual send"};function c({label:t,value:n,sub:d}){return e.jsxs("div",{className:"rounded-2xl border border-border p-4",children:[e.jsx("p",{className:"text-xs uppercase tracking-wider text-muted-foreground",children:t}),e.jsx("p",{className:"mt-1 text-2xl font-semibold",children:n}),d?e.jsx("p",{className:"text-xs text-muted-foreground",children:d}):null]})}const x=t=>t?new Date(t).toLocaleString(void 0,{month:"short",day:"numeric",year:"numeric"}):"-";function j({open:t,onClick:n,count:d}){return e.jsx("button",{type:"button",onClick:n,className:"rounded-full border border-border px-3 py-1 text-xs font-medium hover:bg-muted",children:t?"Hide":`Audit ${d}`})}function g({id:t,email:n}){return e.jsxs("span",{className:"block",children:[e.jsx("span",{className:"font-medium",children:n??"(no email)"}),e.jsx("span",{className:"block font-mono text-[10px] text-muted-foreground",children:t})]})}function N({columns:t,rows:n}){return n.length===0?e.jsx("p",{className:"text-xs text-muted-foreground",children:"No users."}):e.jsx("div",{className:"max-h-80 overflow-auto rounded-xl border border-border bg-background",children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{className:"sticky top-0 bg-muted/70 text-left uppercase tracking-wider text-muted-foreground",children:e.jsx("tr",{children:t.map(d=>e.jsx("th",{className:"px-3 py-2 font-medium",children:d},d))})}),e.jsx("tbody",{children:n.map((d,m)=>e.jsx("tr",{className:"border-t border-border",children:d.map((p,o)=>e.jsx("td",{className:"px-3 py-2 align-top",children:p},o))},m))})]})})}function S(){const[t,n]=a.useState(null),[d,m]=a.useState(void 0),[p,o]=a.useState(!0),[u,y]=a.useState(null),[h,b]=a.useState(null);a.useEffect(()=>{let s=!0;return o(!0),f({data:d?{surveyId:d}:{}}).then(r=>{s&&(n(r),o(!1))}),()=>{s=!1}},[d]);const l=t?.overall;return e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-semibold",children:"Survey funnel"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Invite rate, reminder rate, and completed conversion by signup cohort and send type."})]}),t?.surveys?.length?e.jsx("select",{value:d??t.survey?.id??"",onChange:s=>m(s.target.value),className:"rounded-full border border-border bg-background px-4 py-2 text-sm",children:t.surveys.map(s=>e.jsx("option",{value:s.id,children:s.title},s.id))}):null]}),p?e.jsx("p",{className:"mt-8 text-sm text-muted-foreground",children:"Loading..."}):t?.survey?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mt-6 grid gap-3 sm:grid-cols-2 lg:grid-cols-4",children:[e.jsx(c,{label:"Invite rate",value:i(l.inviteRate),sub:`${l.invited} of ${l.totalSignups} signups invited`}),e.jsx(c,{label:"Reminder rate",value:i(l.reminderRate),sub:`${l.reminded} reminded`}),e.jsx(c,{label:"Completed conversion",value:i(l.conversion),sub:`${l.respondents} respondents`}),e.jsx(c,{label:"Total responses",value:String(l.responses),sub:"includes repeat submissions"})]}),e.jsx("h3",{className:"mt-10 text-sm font-semibold uppercase tracking-wider text-muted-foreground",children:"By send type"}),e.jsx("div",{className:"mt-3 overflow-hidden rounded-2xl border border-border",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-muted/50 text-left text-xs uppercase tracking-wider text-muted-foreground",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-2",children:"Send type"}),e.jsx("th",{className:"px-4 py-2",children:"Sends"}),e.jsx("th",{className:"px-4 py-2",children:"People"}),e.jsx("th",{className:"px-4 py-2",children:"Completed after"}),e.jsx("th",{className:"px-4 py-2",children:"Conversion"}),e.jsx("th",{className:"px-4 py-2"})]})}),e.jsx("tbody",{children:t.bySendType.length===0?e.jsx("tr",{children:e.jsx("td",{className:"px-4 py-3 text-muted-foreground",colSpan:6,children:"No sends yet."})}):t.bySendType.map(s=>e.jsxs(a.Fragment,{children:[e.jsxs("tr",{className:"border-t border-border",children:[e.jsx("td",{className:"px-4 py-3 font-medium",children:v[s.trigger]??s.trigger}),e.jsx("td",{className:"px-4 py-3",children:s.sends}),e.jsx("td",{className:"px-4 py-3",children:s.users}),e.jsx("td",{className:"px-4 py-3",children:s.converted}),e.jsx("td",{className:"px-4 py-3",children:i(s.rate)}),e.jsx("td",{className:"px-4 py-3 text-right",children:e.jsx(j,{open:u===s.trigger,onClick:()=>y(u===s.trigger?null:s.trigger),count:s.detail?.length??0})})]},s.trigger),u===s.trigger?e.jsx("tr",{className:"border-t border-border bg-muted/20",children:e.jsx("td",{colSpan:6,className:"px-4 py-3",children:e.jsx(N,{columns:["User","Sent","Completed"],rows:(s.detail??[]).map(r=>[e.jsx(g,{id:r.userId,email:r.email},"u"),x(r.sentAt),r.completed?x(r.completedAt):"-"])})})},`${s.trigger}-detail`):null]},s.trigger))})]})}),e.jsx("h3",{className:"mt-10 text-sm font-semibold uppercase tracking-wider text-muted-foreground",children:"By
1signup cohort (week)"}),e.jsx("div",{className:"mt-3 overflow-x-auto rounded-2xl border border-border",children:e.jsxs("table",{className:"w-full min-w-[640px] text-sm",children:[e.jsx("thead",{className:"bg-muted/50 text-left text-xs uppercase tracking-wider text-muted-foreground",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-2",children:"Week of"}),e.jsx("th",{className:"px-4 py-2",children:"Signups"}),e.jsx("th",{className:"px-4 py-2",children:"Invited"}),e.jsx("th",{className:"px-4 py-2",children:"Invite rate"}),e.jsx("th",{className:"px-4 py-2",children:"Reminded"}),e.jsx("th",{className:"px-4 py-2",children:"Reminder rate"}),e.jsx("th",{className:"px-4 py-2",children:"Completed"}),e.jsx("th",{className:"px-4 py-2",children:"Conversion"}),e.jsx("th",{className:"px-4 py-2"})]})}),e.jsx("tbody",{children:t.byCohort.length===0?e.jsx("tr",{children:e.jsx("td",{className:"px-4 py-3 text-muted-foreground",colSpan:9,children:"No cohorts yet."})}):t.byCohort.map(s=>e.jsxs(a.Fragment,{children:[e.jsxs("tr",{className:"border-t border-border",children:[e.jsx("td",{className:"px-4 py-3 font-medium",children:s.week}),e.jsx("td",{className:"px-4 py-3",children:s.signups}),e.jsx("td",{className:"px-4 py-3",children:s.invited}),e.jsx("td",{className:"px-4 py-3",children:i(s.inviteRate)}),e.jsx("td",{className:"px-4 py-3",children:s.reminded}),e.jsx("td",{className:"px-4 py-3",children:i(s.reminderRate)}),e.jsx("td",{className:"px-4 py-3",children:s.responded}),e.jsx("td",{className:"px-4 py-3",children:i(s.conversion)}),e.jsx("td",{className:"px-4 py-3 text-right",children:e.jsx(j,{open:h===s.week,onClick:()=>b(h===s.week?null:s.week),count:s.detail?.length??0})})]},s.week),h===s.week?e.jsx("tr",{className:"border-t border-border bg-muted/20",children:e.jsx("td",{colSpan:9,className:"px-4 py-3",children:e.jsx(N,{columns:["User","Signed up","Invited","Reminded","Completed"],rows:(s.detail??[]).map(r=>[e.jsx(g,{id:r.userId,email:r.email},"u"),x(r.signedUpAt),r.invited?"Yes":"No",r.reminded?"Yes":"No",r.completed?x(r.completedAt):"No"])})})},`${s.week}-detail`):null]},s.week))})]})})]}):e.jsx("p",{className:"mt-8 text-sm text-muted-foreground",children:"No surveys yet."})]})}export{S 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.