1import{c8 as g,bw as x,bk as t,f as c,aS as w,bB as j,bX as d,aR as k,bR as N,aw as C,X as S,Y as A,g as v,J as R,aX as E,bx as _}from"./index-BdR958M7.js";import{I as O}from"./input-C8Uuo3Hp.js";import{L as T}from"./label-B2bNnO3u.js";import{B as L}from"./badge-DB8vyzPB.js";import{C as F}from"./company-logo-C56L6Fo-.js";import{u as I}from"./apply-dialog-CXjshCnO.js";import{u as B,a as $}from"./extension-install-BmJ4kZaI.js";import{F as z}from"./file-text-BlC7zoaz.js";import{E as P}from"./external-link-Tu6E-dMr.js";import"./textarea-xbFlfrGt.js";import"./analytics-Bvs4eqqS.js";import"./badge-check-Dwk-dWRA.js";import"./zap-Bju978CI.js";const D={login:{reason:"Sign in on the employer site in the tab we opened.",action:"Sign in"},captcha:{reason:"The employer asked for a verification check.",action:"Complete verification"},mfa:{reason:"Enter the verification code the employer sent you, in the employer tab.",action:"Complete verification"},email_verification:{reason:"Open the sign-in link the employer emailed you. We pick the application up in that tab.",action:"Reopen application"},wrong_account:{reason:"The employer site is signed in to a different account. Switch to your application email there.",action:"Continue"},missing_info:{reason:"The employer asked for details we donât have yet.",action:"Save answers & continue"},resume:{reason:"The employer did not accept your résumé upload. Check it on your profile.",action:"Retry upload"},validation:{reason:"The employer rejected part of the form.",action:"Retry"},disconnected:{reason:"Waiting for your browser. Keep Chrome open with the extension enabled.",action:"Reconnect browser"},unsupported:{reason:"We canât submit on this employer site automatically. Finish it on the employer page.",action:"Try again"}};function U({app:e}){const n=g(),[i,m]=x.useState({}),[p,u]=x.useState(!1),[o,a]=x.useState(!1);if(!e.attempt||e.attempt.cancelled||["submitted","submission_unknown","submitting"].includes(e.attempt.state))return null;const l=e.attempt.state==="blocked",b=e.attempt.blocker?D[e.attempt.blocker]:void 0;async function f(){a(!0);try{if(l){const r=await j({data:{applicationId:e.id,answers:i,remember:p}});if(!r.ok){d.error("Complete the required answers first");return}r.resumedOthers>0&&d.success(`Also continued ${r.resumedOthers} other approved application${r.resumedOthers===1?"":"s"} waiting on the same answers`)}if(e.attempt?.executor==="cloud"){await n.invalidate();return}const s=await k({data:{applicationId:e.id}});if(!s.ok){d.error(s.error);return}await N({...s.payload,autoSubmit:!0}),await n.invalidate()}catch(s){d.error(s instanceof Error?s.message:"Could not reconnect")}finally{a(!1)}}return t.jsxs("div",{className:"mt-3 space-y-3 border-t pt-3",children:[t.jsxs("p",{className:"text-muted-foreground text-sm",children:[l?`${b?.reason??"This application needs your attention."} `:"","Your application is approved. Weâll continue automatically when this is resolved."]}),e.attempt.missingFields.map(s=>t.jsxs("div",{className:"space-y-1",children:[t.jsx(T,{htmlFor:`${e.id}-${s.name}`,children:s.label}),s.options?.length?t.jsxs("select",{id:`${e.id}-${s.name}`,className:"w-full rounded border p-2",value:i[s.name]??"",onChange:r=>m({...i,[s.name]:r.target.value}),children:[t.jsx("option",{value:"",children:"Choose an answer"}),s.options.map(r=>t.jsx("option",{value:r,children:r},r))]}):t.jsx(O,{id:`${e.id}-${s.name}`,value:i[s.name]??"",onChange:r=>m({...i,[s.name]:r.target.value})})]},s.name)),e.attempt.missingFields.length>0&&t.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[t.jsx("input",{type:"checkbox",checked:p,onChange:s=>u(s.target.checked)}),"Use these answers for similar applications"]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(c,{disabled:o,onClick:f,children:l?b?.action??"Continue":"Reconnect browser"}),t.jsx(c,{variant:"outline",disabled:o,onClick:async()=>{a(!0);try{await w({data:{applicationId:e.id}}),await n.invalidate()}finally{a(!1)}},children:"Cancel application"})]})]})}const W={approved:"You approved this application",claimed:"Started applying",blocked:"Paused",resumed:"Continued",submit_intent:"Submitting",submitted:"Submitted â employer confirmed receipt",submission_unknown:"Submitted, but the employer did not confirm",cancelled:"You cancelled this application",swept:"Browser stopped responding",self_reported:"You confirmed it went through"},Y={candidate:"you",extension:"your browser",cloud:"Hireeing",system:"Hireeing"};function H(e){const n=W[e.type]??e.type,i=typeof e.detail?.blocker=="string"?e.detail.blocker.replaceAll("_"," "):null;return i?`${n}: ${i}`:n}function q({events:e}){return e?.length?t.jsxs("details",{className:"mt-3 border-t pt-3 text-sm",children:[t.jsxs("summary",{className:"text-muted-foreground cursor-pointer",children:["History (",e.length,")"]}),t.jsx("ol",{className:"mt-2 space-y-1",children:[...e].reverse().map((n,i)=>t.jsxs("li",{className:"text-muted-foreground flex gap-2",children:[t.jsx("time",{className:"shrink-0 tabular-nums",dateTime:new Date(n.at).toISOString(),children:new Date(n.at).toLocaleStr
1ing(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})}),t.jsxs("span",{children:[H(n)," ",t.jsxs("span",{className:"text-xs",children:["· ",Y[n.actor]??n.actor]})]})]},`${n.at}-${i}`))})]}):null}const X={interview:"Interviewed",replied:"They replied",no_response:"No response yet",rejected:"Rejected"},K=new Set(["ready","needs_review","pending","generating"]),M=new Set(["ready","needs_review","blocked","prepared","filled","submission_unknown"]);function V(e){return e.external?e.status!=="submitted":M.has(e.status)}const G={queued:{label:"Waiting for your browser",variant:"secondary"},running:{label:"Applyingâ¦",variant:"secondary"},cancelled:{label:"Cancelled",variant:"secondary"},submission_unknown:{label:"Acceptance not verified",variant:"warning"},needs_review:{label:"Needs review",variant:"warning"},ready:{label:"Ready to submit",variant:"default"},prepared:{label:"Prepared - send it",variant:"warning"},submitting:{label:"Submittingâ¦",variant:"secondary"},submitted:{label:"Submitted",variant:"success"},blocked:{label:"Needs your input",variant:"warning"},pending:{label:"Pending",variant:"secondary"},filled:{label:"Filled - submit on site",variant:"default"},saved:{label:"Saved - open to apply",variant:"secondary"}};function ue(){const{apps:e}=C.useLoaderData(),n=g(),i=e.some(a=>a.attempt&&["queued","running","submitting"].includes(a.status));x.useEffect(()=>{if(!i)return;const a=setInterval(()=>{document.visibilityState==="visible"&&n.invalidate()},15e3);return()=>clearInterval(a)},[i,n]);const m=I(),{installed:p,outdated:u}=B(),o=g();return t.jsxs(S,{children:[t.jsx(A,{title:"Applications",description:"Everything you've applied to - prepared, submitted, or needing a hand."}),(!p||u)&&t.jsx($,{className:"mt-4",outdated:u}),e.length===0?t.jsxs(v,{className:"mt-6 items-center gap-3 border-dashed py-16 text-center",children:[t.jsx("span",{className:"bg-primary/10 text-primary grid size-14 place-items-center rounded-2xl",children:t.jsx(z,{className:"size-7"})}),t.jsx("p",{className:"font-medium",children:"No applications yet"}),t.jsx("p",{className:"text-muted-foreground max-w-sm text-sm",children:"Review a match and hit Apply - weâll prepare the whole application for your approval."}),t.jsx(c,{asChild:!0,children:t.jsx(R,{to:"/app/jobs",children:"Browse jobs"})})]}):t.jsx("div",{className:"mt-6 flex flex-col gap-3",children:e.map(a=>t.jsx(J,{app:a,onReview:()=>m.resume(a.id),onConfirmSent:()=>o.invalidate(),onOutcome:()=>o.invalidate()},a.id))}),m.node]})}function J({app:e,onReview:n,onConfirmSent:i,onOutcome:m}){const[p,u]=x.useState(!1),[o,a]=x.useState(!1),l=e.status==="prepared",b=G[e.status]??{label:e.status,variant:"secondary"},f=e.submittedAt??e.loggedAt,s=e.companyName||"Direct application";async function r(){u(!0);try{const h=await E({data:{applicationId:e.id}});h.ok?(d.success("Marked as sent"),i()):d.error("error"in h&&h.error?h.error:"Could not mark as sent")}catch{d.error("Could not mark as sent")}finally{u(!1)}}async function y(h){a(!0);try{(await _({data:{applicationId:e.id,outcome:h}})).ok?m():d.error("Could not save your answer")}catch{d.error("Could not save your answer")}finally{a(!1)}}return t.jsxs(v,{className:"min-w-0 overflow-hidden p-4 sm:p-5",children:[t.jsxs("div",{className:"flex flex-col justify-between gap-4 sm:flex-row sm:items-center",children:[t.jsxs("div",{className:"flex min-w-0 flex-1 items-start gap-3",children:[t.jsx(F,{name:s,size:"md",className:"shrink-0"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"truncate text-base font-semibold sm:text-lg",children:e.title??"Application"}),t.jsx("p",{className:"text-muted-foreground truncate text-xs font-medium sm:text-sm",children:s}),t.jsxs("div",{className:"text-muted-foreground mt-1.5 flex flex-wrap items-center gap-2 text-xs",children:[e.external&&t.jsx("span",{className:"bg-secondary rounded px-1.5 py-0.5 font-medium",children:"Filled by extension"}),l?t.jsx("span",{children:"We couldnât submit this one - open it on the employerâs site to finish."}):f?t.jsxs("span",{children:[e.submittedAt?"Submitted":e.external?"Filled":"Updated"," ",new Date(f).toLocaleDateString()]}):null,e.riskCount>0&&t.jsxs("span",{children:["· ",e.riskCount," item(s) flagged"]}),e.blockedReason&&t.jsxs("span",{className:"capitalize",children:["· ",e.blockedReason]})]})]})]}),t.jsxs("div",{className:"border-border/60 flex shrink-0 items-center gap-2 border-t pt-2 sm:flex-col sm:items-end sm:border-t-0 sm:pt-0",children:[t.jsx(L,{variant:b.variant,className:"shrink-0 text-xs",children:b.label}),t.jsxs("div",{className:"ml-auto flex items-center gap-2 sm:ml-0",children:[!e.external&&K.has(e.status)&&t.jsx(c,{size:"sm",variant:"outline",onClick:n,children:"Review & submit"}),e.applyUrl&&(e.external||e.status==="blocked"||l||e.status==="filled")&&t.jsx(c,{asChild:!0,size:"sm",variant:l||e.status==="filled"?"default":"outline",children:t.jsxs("a",{href:e.applyUrl,target:"_blank",rel:"noopener noreferrer",children:[t.jsx(P,{className:"size-4"}
1)," ",e.external?"View job":e.status==="filled"?"Open to submit":l?"Open application":"Finish manually"]})}),V(e)&&t.jsx(c,{size:"sm",variant:"outline",disabled:p,onClick:r,children:e.status==="submission_unknown"?"I confirmed it went through":l||e.status==="filled"?"I sent it":"I already applied"})]})]})]}),e.outcome?t.jsx("div",{className:"border-border/60 mt-3 border-t pt-3",children:t.jsx("span",{className:"text-muted-foreground text-xs",children:X[e.outcome]??e.outcome})}):e.outcomePromptDue&&t.jsxs("div",{className:"border-border/60 mt-3 flex flex-wrap items-center gap-2 border-t pt-3",children:[t.jsxs("span",{className:"text-muted-foreground text-xs",children:["Did you hear back from ",s,"?"]}),t.jsx(c,{size:"sm",variant:"outline",disabled:o,onClick:()=>y("interview"),children:"Got an interview"}),t.jsx(c,{size:"sm",variant:"outline",disabled:o,onClick:()=>y("replied"),children:"They replied"}),t.jsx(c,{size:"sm",variant:"ghost",disabled:o,onClick:()=>y("no_response"),children:"Nothing yet"})]}),t.jsx(U,{app:e}),t.jsx(q,{events:e.events})]})}export{ue 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.