1import{j as e}from"./ui-E7cH9GT0.js";import{r as l}from"./vendor-Cpi2Ks0G.js";import{b as p}from"./router-CKghwl56.js";import{c as j,S as g,C as y,f as v,b as N,r as u,X as m}from"./index-BeEEDwOo.js";import{L as x}from"./loader-circle-D3Z90CiJ.js";import{C as h}from"./circle-x-DngJgpNd.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 w=j("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"}]]),X=()=>{const[b]=p(),r=b.get("token"),[a,s]=l.useState("loading"),[c,o]=l.useState(!1);l.useEffect(()=>{if(!r){s("invalid");return}(async()=>{try{const t=m.supabaseUrl||"https://nzyljjngxfkydjeoyefz.supabase.co",d=await fetch(`${t}/functions/v1/handle-email-unsubscribe?token=${r}`,{headers:{apikey:"sb_publishable_RDadn3XYAfFU_K3wbX28rA_a-mAnqrR"}}),i=await d.json();d.ok&&i.valid===!0?s("valid"):i.reason==="already_unsubscribed"||i.valid===!1?s("already_unsubscribed"):s("invalid")}catch{s("invalid")}})()},[r]);const f=async()=>{if(r){o(!0);try{const{data:n,error:t}=await m.functions.invoke("handle-email-unsubscribe",{body:{token:r}});if(t)throw t;n?.success?s("success"):n?.reason==="already_unsubscribed"?s("already_unsubscribed"):s("error")}catch{s("error")}finally{o(!1)}}};return e.jsxs("div",{className:"min-h-[60vh] flex items-center justify-center p-4",children:[e.jsx(g,{title:"Unsubscribe â Alper Refrigerants",description:"Manage your email preferences"}),e.jsx(y,{className:"max-w-md w-full",children:e.jsxs(v,{className:"pt-6 text-center space-y-4",children:[a==="loading"&&e.jsxs(e.Fragment,{children:[e.jsx(x,{className:"h-12 w-12 animate-spin text-muted-foreground mx-auto"}),e.jsx("p",{className:"text-muted-foreground",children:"Validating your request..."})]}),a==="valid"&&e.jsxs(e.Fragment,{children:[e.jsx(w,{className:"h-12 w-12 text-primary mx-auto"}),e.jsx("h2",{className:"text-xl font-semibold",children:"Unsubscribe from emails"}),e.jsx("p",{className:"text-muted-foreground",children:"Click below to stop receiving app emails from Alper Refrigerants."}),e.jsxs(N,{onClick:f,disabled:c,className:"w-full",children:[c?e.jsx(x,{className:"h-4 w-4 animate-spin mr-2"}):null,"Confirm Unsubscribe"]})]}),a==="success"&&e.jsxs(e.Fragment,{children:[e.jsx(u,{className:"h-12 w-12 text-primary mx-auto"}),e.jsx("h2",{className:"text-xl font-semibold",children:"You've been unsubscribed"}),e.jsx("p",{className:"text-muted-foreground",children:"You will no longer receive app emails from us."})]}),a==="already_unsubscribed"&&e.jsxs(e.Fragment,{children:[e.jsx(u,{className:"h-12 w-12 text-muted-foreground mx-auto"}),e.jsx("h2",{className:"text-xl font-semibold",children:"Already unsubscribed"}),e.jsx("p",{className:"text-muted-foreground",children:"This email address has already been unsubscribed."})]}),a==="invalid"&&e.jsxs(e.Fragment,{children:[e.jsx(h,{className:"h-12 w-12 text-destructive mx-auto"}),e.jsx("h2",{className:"text-xl font-semibold",children:"Invalid link"}),e.jsx("p",{className:"text-muted-foreground",children:"This unsubscribe link is invalid or expired."})]}),a==="error"&&e.jsxs(e.Fragment,{children:[e.jsx(h,{className:"h-12 w-12 text-destructive mx-auto"}),e.jsx("h2",{className:"text-xl font-semibold",children:"Something went wrong"}),e.jsx("p",{className:"text-muted-foreground",children:"Please try again later or contact support."})]})]})})]})};export{X 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.