1import{c as x,r,j as e,i as o,B as b}from"./app-BRgu96SN.js";import{N as f,F as g}from"./Footer-CiT4_Ngk.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 d=x("MailCheck",[["path",{d:"M22 13V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h8",key:"12jkf8"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"m16 19 2 2 4-4",key:"1b14m6"}]]);/** 7 * @license lucide-react v0.462.0 - ISC 8 * 9 * This source code is licensed under the ISC license. 10 * See the LICENSE file in the root directory of this source tree. 11 */const c=x("MailX",[["path",{d:"M22 13V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h9",key:"1j9vog"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"m17 17 4 4",key:"1b3523"}],["path",{d:"m21 17-4 4",key:"uinynz"}]]),l="https://goikhaxnfnzzdyxpghmm.supabase.co",m="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImdvaWtoYXhuZm56emR5eHBnaG1tIiwicm9sZSI6ImFub24iLCJpYXQiOjE3Nzk2NTA1MTUsImV4cCI6MjA5NTIyNjUxNX0.akxsB3HqCgFdiEfxosAC8RXGfsIAR4AbazN7bIxexWo",p=()=>{const[a,s]=r.useState({kind:"loading"}),[t,u]=r.useState(null);r.useEffect(()=>{document.title="Unsubscribe â AMCO Delivery",u(new URLSearchParams(window.location.search).get("token")||"")},[]),r.useEffect(()=>{if(t!==null){if(!t){s({kind:"invalid",msg:"Missing unsubscribe token."});return}(async()=>{try{const i=await fetch(`${l}/functions/v1/handle-email-unsubscribe?token=${encodeURIComponent(t)}`,{headers:{apikey:m}}),n=await i.json();i.ok&&n.valid?s({kind:"valid"}):n.reason==="already_unsubscribed"?s({kind:"already"}):s({kind:"invalid",msg:n.error||"Invalid or expired link."})}catch{s({kind:"invalid",msg:"Network error. Please try again."})}})()}},[t]);const h=async()=>{s({kind:"submitting"});try{const i=await fetch(`${l}/functions/v1/handle-email-unsubscribe`,{method:"POST",headers:{apikey:m,"Content-Type":"application/json"},body:JSON.stringify({token:t})}),n=await i.json();i.ok&&n.success?s({kind:"done"}):n.reason==="already_unsubscribed"?s({kind:"already"}):s({kind:"invalid",msg:n.error||"Could not unsubscribe."})}catch{s({kind:"invalid",msg:"Network error. Please try again."})}};return e.jsxs("div",{className:"min-h-screen bg-background flex flex-col",children:[e.jsx(f,{}),e.jsx("main",{className:"flex-1 flex items-center",children:e.jsx("div",{className:"container max-w-md py-16",children:e.jsxs("div",{className:"bg-card border border-border rounded-2xl shadow-card p-8 text-center",children:[a.kind==="loading"&&e.jsxs(e.Fragment,{children:[e.jsx(o,{className:"h-10 w-10 text-muted-foreground animate-spin mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"Checking linkâ¦"})]}),a.kind==="valid"&&e.jsxs(e.Fragment,{children:[e.jsx(c,{className:"h-10 w-10 text-accent mx-auto mb-4"}),e.jsx("h1",{className:"font-heading font-bold text-2xl text-foreground mb-2",children:"Unsubscribe from AMCO Delivery emails?"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-6",children:"You won't receive further notification emails at this address."}),e.jsx(b,{variant:"accent",onClick:h,className:"w-full h-11",children:"Confirm unsubscribe"})]}),a.kind==="submitting"&&e.jsxs(e.Fragment,{children:[e.jsx(o,{className:"h-10 w-10 text-muted-foreground animate-spin mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"Processingâ¦"})]}),a.kind==="done"&&e.jsxs(e.Fragment,{children:[e.jsx(d,{className:"h-10 w-10 text-emerald-600 mx-auto mb-4"}),e.jsx("h1",{className:"font-heading font-bold text-2xl text-foreground mb-2",children:"You've been unsubscribed"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"We won't email this address again. You can close this tab."})]}),a.kind==="already"&&e.jsxs(e.Fragment,{children:[e.jsx(d,{className:"h-10 w-10 text-emerald-600 mx-auto mb-4"}),e.jsx("h1",{className:"font-heading font-bold text-2xl text-foreground mb-2",children:"Already unsubscribed"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"This address is no longer receiving our emails."})]}),a.kind==="invalid"&&e.jsxs(e.Fragment,{children:[e.jsx(c,{className:"h-10 w-10 text-rose-600 mx-auto mb-4"}),e.jsx("h1",{className:"font-heading font-bold text-2xl text-foreground mb-2",children:"Link not val
11id"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:a.msg})]})]})})}),e.jsx(g,{})]})};export{p 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.