1import{ax as K,r as k,bf as U,j as e,cL as I,n as q,L as P,B,R as G,a4 as x,a9 as h,az as Q,d1 as W,c_ as D,cE as Y,U as X,a5 as b,a6 as y,a8 as A,H as F,J as H,K as S,N as o,O as z,Q as f,W as J,v as V}from"./index-CERo9Lrd.js";import{u as Z,T as ee}from"./useTablePage-B7RV1TX2.js";import{u as se,F as te}from"./ListFold-GnxF6aMk.js";import{C as ae,a as ne,b as re,c as ie,d as le}from"./chart-BOA0IVBv.js";import{A as ce}from"./AutoApplyAccountDetail-CfQCGxCm.js";import{T as oe}from"./thumbs-down-CpHsJjTA.js";import{B as de}from"./BarChart-6pxLMU4H.js";import{C as me,X as xe,Y as he,B as g}from"./generateCategoricalChart-poSrOFB_.js";import{s as ue}from"./subDays-uLyoRGvs.js";import{f as M}from"./format-Bh4RquCw.js";import"./formatDistanceToNowStrict-BZBPieat.js";import"./index-BPfaU68d.js";/** 2 * @license lucide-react v0.462.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const je=K("MailQuestion",[["path",{d:"M22 10.5V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h12.5",key:"e61zoh"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"M18 15.28c.2-.4.5-.8.9-1a2.1 2.1 0 0 1 2.6.4c.3.4.5.8.5 1.3 0 1.3-2 2-2 2",key:"7z9rxb"}],["path",{d:"M20 22v.01",key:"12bgn6"}]]),fe={"7d":7,"30d":30,"90d":90},pe=(n,d)=>V.rpc(n,d),i=n=>Number(n??0).toLocaleString("en-GB"),m=(n,d)=>{const l=Number(d??0);if(l<=0)return"â";const c=Number(n??0)/l*100;return`${c>0&&c<10?c.toFixed(1):Math.round(c)}%`},L=n=>n==null?"â":`${n} day${Number(n)===1?"":"s"}`,N={offer:"#0ca30c",interview:"#2a78d6",action_needed:"#fab219",rejected:"#d03b3b",confirmed_only:"#9aa4b2",no_email:"#d9dee5"},E={offer:{text:"Offer",className:"bg-emerald-600 text-white hover:bg-emerald-600"},interview:{text:"Interview",className:"bg-sky-100 text-sky-800 hover:bg-sky-100"},action_needed:{text:"Action needed",className:"bg-amber-100 text-amber-800 hover:bg-amber-100"},rejection:{text:"Rejection",className:"bg-red-100 text-red-800 hover:bg-red-100"}},be={"0-2":"0â2 days","3-6":"3â6 days","7-13":"1â2 weeks","14+":"2 weeks +"};function j({icon:n,label:d,value:l,sub:c}){return e.jsxs(x,{children:[e.jsx(b,{className:"pb-2",children:e.jsxs(y,{className:"flex items-center gap-2 text-sm font-medium text-muted-foreground",children:[e.jsx(n,{className:"h-4 w-4"}),d]})}),e.jsxs(h,{children:[e.jsx("div",{className:"text-2xl font-bold",children:l}),c?e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:c}):null]})]})}function C({value:n,of:d}){const l=Number(n??0);return e.jsxs(f,{className:"text-right",children:[e.jsx("span",{className:l===0?"text-muted-foreground":"font-medium",children:m(l,d)}),e.jsxs("span",{className:"ml-1 text-xs text-muted-foreground",children:["(",i(l),")"]})]})}function T({rows:n,keyLabel:d,keyOf:l,labelOf:c}){const w=n.some(r=>r.confirmed!==void 0),v=n.some(r=>r.offer!==void 0),$=se(n,8);return n.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No applications sent in this period."}):e.jsxs(e.Fragment,{children:[e.jsxs(F,{children:[e.jsx(H,{children:e.jsxs(S,{children:[e.jsx(o,{children:d}),e.jsx(o,{className:"text-right",children:"Sent"}),w?e.jsx(o,{className:"text-right",children:"Confirmed"}):null,e.jsx(o,{className:"text-right",children:"Any reply"}),e.jsx(o,{className:"text-right",children:"Interview"}),v?e.jsx(o,{className:"text-right",children:"Offer"}):null,e.jsx(o,{className:"text-right",children:"Rejected"})]})}),e.jsx(z,{children:$.rows.map(r=>e.jsxs(S,{children:[e.jsx(f,{className:"font-medium",children:c?c(r):l(r)}),e.jsx(f,{className:"text-right font-semibold",children:i(r.sent)}),w?e.jsx(C,{value:r.confirmed,of:r.sent}):null,e.jsx(C,{value:r.replied,of:r.sent}),e.jsx(C,{value:r.interview,of:r.sent}),v?e.jsx(C,{value:r.offer,of:r.sent}):null,e.jsx(C,{value:r.rejected,of:r.sent})]},l(r)))})]}),e.jsx(te,{fold:$})]})}function Se(){const[n,d]=k.useState("30d"),[l,c]=k.useState(!1),[w,v]=k.useState(null),$=k.useMemo(()=>(n==="all"?new Date("2026-01-01T00:00:00Z"):ue(new Date,fe[n])).toISOString(),[n]),r=U({queryKey:["autoapply-outcomes",n,l],queryFn:async()=>{const{data:s,error:p}=await pe("get_autoapply_outcomes",{p_since:$,p_include_test:l});if(p)throw new Error(p.message);return s},staleTime:5*6e4,refetchOnWindowFocus:!1}),a=r.data,_=Z(a==null?void 0:a.events,10,n),t=a==null?void 0:a.totals,u=a==null?void 0:a.candidates,O=k.useMemo(()=>((a==null?void 0:a.weekly)??[]).map(s=>({week:M(new Date(s.week),"dd MMM"),offer:Number(s.offer),interview:Number(s.interview),action_needed:Number(s.action_needed),rejected:Number(s.rejected),confirmed_only:Number(s.confirmed_only),no_email:Number(s.no_email)})),[a==null?void 0:a.weekly]),R=a?Number(a.unmatched.interview)+Number(a.unmatched.rejection)+Number(a.unmatched.action_needed):0;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("h2",{className:"flex items-center gap-2 text-xl font-semibold",children:[e.jsx(I,{className:"h-5 w-5"})," AutoApply outcomes"]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["What employers did after applications went out, read from candidates' Haystack inboxes",a!=null&&a.first_inbox_email?` (emails since ${M(new Date(a.first_inbox_email),"dd MMM yyyy")})`:"","."]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(q,{id:"outcomes-include-test",checked:l,onCheckedChange:c}),e.jsx(P,{htmlFor:"outcomes-include-test",className:"text-sm text-muted-foreground",children:"Test accounts"})]}),["7d","30d","90d","all"].map(s=>e.jsx(B,{size:"sm",variant:n===s?"default":"outline",onClick:()=>d(s),children:s==="all"?"All":s},s)),e.jsx(B,{size:"sm",variant:"ghost",onClick:()=>r.refetch(),disabled:r.isFetching,"aria-label":"Refresh",children:e.jsx(G,{className:`h-4 w-4 ${r.isFetching?"animate-spin":""}`})})]})]}),r.isError?e.jsx(x,{children:e.jsxs(h,{className:"py-6 text-sm text-destructive",children:["Could not load outcomes: ",r.error.message]})}):r.isLoading||!a||!t||!u?e.jsx("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-4",children:Array.from({length:8}).map((s,p)=>e.jsx(Q,{className:"h-24"},p))}):e.jsxs(e.Fragment,{children:[Number(t.sent)>0&&Number(t.mature)/Number(t.sent)<.5?e.jsx(x,{className:"border-amber-300",children:e.jsx(h,{className:"py-3 text-sm",children:`${m(Number(t.sent)-Number(t.mature),t.sent)} of these applications were sent less than a week ago. Employers usually reply within one to three weeks, so interview and rejection rates will rise as they age; the "Days since sent" table shows rates by age.`})}):null,e.jsxs("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-4",children:[e.jsx(j,{icon:W,label:"Applications sent",value:i(t.sent),sub:`${i(t.candidates)} candidates · median ${i(u.median_sent)} each`}),e.jsx(j,{icon:I,label:"Receipt confirmed",value:m(t.confirmed,t.sent),sub:`${i(t.confirmed)}
6 with the employer's confirmation email · ${i(t.no_email)} with no email at all`}),e.jsx(j,{icon:je,label:"Employer replied",value:m(t.replied,t.sent),sub:`${i(t.replied)} with an interview, offer, rejection or request · median ${L(t.median_days_to_reply)} to reply`}),e.jsx(j,{icon:D,label:"Interview rate",value:m(t.interview,t.sent),sub:`${i(t.interview)} applications · median ${L(t.median_days_to_interview)} to the invite`}),e.jsx(j,{icon:Y,label:"Offer rate",value:m(t.offer,t.sent),sub:`${i(t.offer)} offers · candidate-marked or clear offer wording`}),e.jsx(j,{icon:oe,label:"Rejection rate",value:m(t.rejected,t.sent),sub:`${i(t.rejected)} applications · median ${L(t.median_days_to_rejection)} to the rejection`}),e.jsx(j,{icon:X,label:"Candidates with an interview",value:m(u.with_interview,u.with_sent),sub:`${i(u.with_interview)} of ${i(u.with_sent)} · ${i(u.with_offer)} with an offer · ${i(u.with_rejection)} with a rejection`}),e.jsx(j,{icon:D,label:"Week-old applications",value:m(t.mature_interview,t.mature),sub:`Interview rate on the ${i(t.mature)} sent 7+ days ago · ${m(t.mature_replied,t.mature)} replied · ${m(t.mature_rejected,t.mature)} rejected`})]}),e.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[e.jsxs(x,{children:[e.jsxs(b,{children:[e.jsx(y,{className:"text-base",children:"Days since sent"}),e.jsx(A,{children:"Rates for applications of each age. The older rows are the fairest read."})]}),e.jsx(h,{className:"overflow-x-auto",children:e.jsx(T,{rows:a.by_age,keyLabel:"Age",keyOf:s=>s.bucket,labelOf:s=>be[s.bucket]??s.bucket})})]}),e.jsxs(x,{children:[e.jsxs(b,{children:[e.jsx(y,{className:"text-base",children:"Furthest outcome by week sent"}),e.jsx(A,{children:"Each application once, at the furthest point it reached."})]}),e.jsx(h,{children:O.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No applications sent in this period."}):e.jsx(ae,{config:{offer:{label:"Offer",color:N.offer},interview:{label:"Interview",color:N.interview},action_needed:{label:"Action needed",color:N.action_needed},rejected:{label:"Rejected",color:N.rejected},confirmed_only:{label:"Confirmed, no reply",color:N.confirmed_only},no_email:{label:"No email",color:N.no_email}},className:"h-[260px] w-full",children:e.jsxs(de,{data:O,children:[e.jsx(me,{strokeDasharray:"3 3",vertical:!1}),e.jsx(xe,{dataKey:"week",tick:{fontSize:12}}),e.jsx(he,{allowDecimals:!1,tick:{fontSize:12}}),e.jsx(ne,{content:e.jsx(re,{})}),e.jsx(ie,{content:e.jsx(le,{})}),e.jsx(g,{dataKey:"offer",stackId:"a",fill:"var(--color-offer)"}),e.jsx(g,{dataKey:"interview",stackId:"a",fill:"var(--color-interview)"}),e.jsx(g,{dataKey:"action_needed",stackId:"a",fill:"var(--color-action_needed)"}),e.jsx(g,{dataKey:"rejected",stackId:"a",fill:"var(--color-rejected)"}),e.jsx(g,{dataKey:"confirmed_only",stackId:"a",fill:"var(--color-confirmed_only)"}),e.jsx(g,{dataKey:"no_email",stackId:"a",fill:"var(--color-no_email)",radius:[4,4,0,0]})]})})})]})]}),e.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[e.jsxs(x,{children:[e.jsx(b,{children:e.jsx(y,{className:"text-base",children:"By applicant tracking system"})}),e.jsx(h,{className:"overflow-x-auto",children:e.jsx(T,{rows:a.by_source,keyLabel:"Source",keyOf:s=>s.source})})]}),e.jsxs(x,{children:[e.jsx(b,{children:e.jsx(y,{className:"text-base",children:"By seniority"})}),e.jsx(h,{className:"overflow-x-auto",children:e.jsx(T,{rows:a.by_seniority,keyLabel:"Seniority",keyOf:s=>s.seniority})})]})]}),e.jsxs(x,{children:[e.jsxs(b,{children:[e.jsx(y,{className:"text-base",children:"Sent by the AI agent vs by the candidate"}),e.jsx(A,{children:'"Candidate" is an application the candidate finished themselves from the kit.'})]}),e.jsx(h,{className:"overflow-x-auto",children:e.jsx(T,{rows:a.by_sender,keyLabel:"Sent by",keyOf:s=>s.sent_by,labelOf:s=>s.sent_by==="agent"?"Haystack's AI agent":"Candidate"})})]}),e.jsxs(x,{children:[e.jsxs(b,{children:[e.jsx(y,{className:"text-base",children:"Latest interviews, offers, rejections and requests"}),e.jsxs(A,{children:['Newest 100 in the period, to spot-check the labels. "Matched" means an unlinked email was tied to the application by company name.',R>0?` ${i(R)} could not be tied to an application and are left out of the rates.`:""," Click a row for the account."]})]}),e.jsx(h,{className:"overflow-x-auto",children:a.events.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No employer replies in this period."}):e.jsxs(e.Fragment,{children:[e.jsxs(F,{children:[e.jsx(H,{children:e.jsxs(S,{children:[e.jsx(o,{children:"Received"}),e.jsx(o,{children:"Outcome"}),e.jsx(o,{children:"Email"}),e.jsx(o,{children:"Application"}),e.jsx(o,{children:"Candidate"})]})}),e.jsx(z,{children:_.pageRows.map(s=>{const p=E[s.label]??E.action_needed;return e.jsxs(S,{className:"cursor-pointer hover:bg-muted/50",onClick:()=>
6v(s.user_id),children:[e.jsx(f,{className:"whitespace-nowrap text-sm",children:M(new Date(s.received_at),"dd MMM HH:mm")}),e.jsxs(f,{children:[e.jsx(J,{className:p.className,children:p.text}),s.label_source==="candidate"?e.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:"Marked by candidate"}):null]}),e.jsx(f,{className:"max-w-[320px] truncate text-sm",title:s.subject??"",children:s.subject??"(no subject)"}),e.jsx(f,{className:"text-sm",children:s.company?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"max-w-[240px] truncate font-medium",children:[s.company,s.title].filter(Boolean).join(" · ")}),e.jsx("div",{className:"text-xs text-muted-foreground",children:[s.source,s.sent_at?`sent ${M(new Date(s.sent_at),"dd MMM")}`:null,s.how==="matched"?"matched by company":null].filter(Boolean).join(" · ")})]}):e.jsx("span",{className:"text-muted-foreground",children:"Unmatched"})}),e.jsx(f,{className:"text-sm",children:s.email??s.user_id.slice(0,8)})]},s.id)})})]}),e.jsx(ee,{page:_.page,pageSize:_.pageSize,total:_.total,onPageChange:_.setPage})]})})]})]}),e.jsx(ce,{userId:w,open:w!==null,onOpenChange:s=>{s||v(null)}})]})}export{Se 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.