1import{r as d,j as e}from"./animation-CddyXVCz.js";import{b as m,h,J as l}from"./index-DnWsV7cE.js";import"./react-vendor-CbN3pvl2.js";import"./supabase-iKSPld20.js";import"./docgen-Bp8WKBAE.js";import"./query-DPqpbKNH.js";const j=()=>{const[c]=m(),n=c.get("token"),s=c.get("state"),[t,a]=d.useState(()=>s==="invalid"?{kind:"invalid"}:s==="error"?{kind:"error"}:n?{kind:"loading"}:{kind:"invalid"});d.useEffect(()=>{if(!n||s)return;let o=!1;return(async()=>{try{const i=await fetch(`/api/watches/guest/confirm?token=${encodeURIComponent(n)}`,{credentials:"include"}),r=await i.json().catch(()=>({}));if(o)return;i.ok&&r.ok?a({kind:"confirmed",title:r.title??"",location:r.location??"",already:!!r.alreadyConfirmed}):r.code==="unsubscribed"?a({kind:"unsubscribed"}):i.status===404||i.status===400?a({kind:"invalid"}):a({kind:"error"})}catch{o||a({kind:"error"})}})(),()=>{o=!0}},[n,s]);const x=t.kind==="confirmed"?t.location?`${t.title} · ${t.location}`:t.title:"";return e.jsx("main",{className:"min-h-[60vh] bg-[var(--bg-primary)] px-4 py-16",children:e.jsx("div",{className:"mx-auto max-w-xl",children:e.jsx(h,{variant:"soft",padding:"lg",children:e.jsxs("div",{className:"space-y-3 text-center","data-testid":"watch-confirm-state","data-state":t.kind,children:[t.kind==="loading"&&e.jsx("p",{className:"text-[var(--text-secondary)]",children:"Confirming your watchâ¦"}),t.kind==="confirmed"&&e.jsxs(e.Fragment,{children:[e.jsx("h1",{className:"font-display text-2xl font-bold text-[var(--text-primary)]",children:t.already?"Already confirmed":"You are all set"}),e.jsxs("p",{className:"text-[var(--text-secondary)]",children:["Every Tuesday we re-run ",e.jsx("strong",{children:x})," and send only the postings you have not seen before."]}),e.jsxs("p",{className:"text-sm text-[var(--text-secondary)]",children:["Want scores, history and the tracker too?"," ",e.jsx(l,{to:"/auth",className:"font-semibold text-[var(--color-accent)] underline underline-offset-2",children:"Create a free account"})," ","â or wait for the first digest and claim it from there in one click."]})]}),t.kind==="invalid"&&e.jsxs(e.Fragment,{children:[e.jsx("h1",{className:"font-display text-2xl font-bold text-[var(--text-primary)]",children:"This link has expired or already been used"}),e.jsx("p",{className:"text-[var(--text-secondary)]",children:"Start the watch again from the page you were on and we will send a fresh confirmation."})]}),t.kind==="unsubscribed"&&e.jsxs(e.Fragment,{children:[e.jsx("h1",{className:"font-display text-2xl font-bold text-[var(--text-primary)]",children:"This watch was unsubscribed"}),e.jsx("p",{className:"text-[var(--text-secondary)]",children:"Start it again from the page you were on if you want it back."})]}),t.kind==="error"&&e.jsxs(e.Fragment,{children:[e.jsx("h1",{className:"font-display text-2xl font-bold text-[var(--text-primary)]",children:"Something went wrong"}),e.jsx("p",{className:"text-[var(--text-secondary)]",children:"Please try the link again in a minute."})]}),e.jsx("p",{className:"pt-2 text-sm",children:e.jsx(l,{to:"/",className:"text-[var(--color-accent)] underline underline-offset-2",children:"Back to CareerDiary"})})]})})})})};export{j as WatchConfirmPage,j 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.