import{j as e,b2 as s,aY as t,b1 as a}from"./ui-vendor-BewJQzBv.js";import{r}from"./react-vendor-D6Nbkvjy.js";import{d as l,u as o}from"./router-vendor-DmQqpneu.js";import{s as i,B as n}from"./home-components-zRcEiFkI.js";import{u as c}from"./case-study-components-DWRUehs-.js";import"./supabase-vendor-aM9kV88h.js";import"./three-vendor-He8TdPNb.js";const d=()=>{const[d]=l(),m=o(),{toast:u}=c(),[h,x]=r.useState(!0),[f,g]=r.useState("loading"),[j,v]=r.useState("");return r.useEffect(()=>{const e=()=>{return s=function*(){try{const{data:{session:s},error:t}=yield i.auth.getSession();if(t)throw t;if(s&&s.user)s.user.email_confirmed_at?(g("success"),u({title:"Welcome to Marzelet!",description:"Your email has been confirmed and you're now logged in."}),setTimeout(()=>{m("/")},2e3)):setTimeout(e,1e3);else{const s=d.get("error"),t=d.get("error_description");if(s)return g("error"),void v(t||s);const a=d.get("access_token"),r=d.get("refresh_token");if(a&&r){const{data:e,error:s}=yield i.auth.setSession({access_token:a,refresh_token:r});if(s)throw s;e.user&&(g("success"),u({title:"Email Confirmed Successfully!",description:"Welcome to Marzelet! You're now logged in."}),setTimeout(()=>{m("/")},2e3))}else setTimeout(e,1e3)}}catch(s){g("error"),v(s.message||"An unexpected error occurred during email confirmation."),u({title:"Confirmation Failed",description:s.message||"There was an error confirming your email. Please try again.",variant:"destructive"})}finally{x(!1)}},new Promise((e,t)=>{var a=e=>{try{l(s.next(e))}catch(a){t(a)}},r=e=>{try{l(s.throw(e))}catch(a){t(a)}},l=s=>s.done?e(s.value):Promise.resolve(s.value).then(a,r);l((s=s.apply(undefined,null)).next())});var s},{data:{subscription:s}}=i.auth.onAuthStateChange((e,s)=>{var t;"SIGNED_IN"===e&&(null==(t=null==s?void 0:s.user)?void 0:t.email_confirmed_at)&&(g("success"),u({title:"Welcome to Marzelet!",description:"Your email has been confirmed and you're now logged in."}),setTimeout(()=>{m("/")},2e3))});return e(),()=>s.unsubscribe()},[d,m,u]),e.jsxs("div",{className:"min-h-screen flex bg-white",children:[e.jsxs("div",{className:"w-1/2 bg-slate-800 flex flex-col justify-center items-center p-12 relative",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-slate-700 to-slate-900"}),e.jsx("div",{className:"absolute bottom-20 right-20 w-64 h-64 bg-purple-600/20 rounded-full blur-3xl"}),e.jsxs("div",{className:"relative z-10 text-center",children:[e.jsx("div",{className:"w-24 h-24 rounded-full flex items-center justify-center mx-auto mb-8 overflow-hidden",children:e.jsx("img",{src:"/lovable-uploads/ea4b0375-50fd-4c5e-83fd-3830452ef78b.png",alt:"Marzelet Info Technology Logo",className:"w-full h-full object-contain"})}),e.jsx("h1",{className:"text-4xl font-bold text-white mb-6",children:"Marzelet Info Technology"}),e.jsx("p",{className:"text-xl text-slate-300 mb-12 max-w-md",children:"Welcome to the future of technology solutions"})]})]}),e.jsx("div",{className:"w-1/2 bg-white flex flex-col justify-center p-12",children:e.jsxs("div",{className:"max-w-md mx-auto w-full text-center",children:["loading"===f&&e.jsxs("div",{className:"space-y-6",children:[e.jsx(s,{className:"w-16 h-16 text-orange-500 mx-auto animate-spin"}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-3xl font-bold text-slate-900 mb-2",children:"Confirming Your Email"}),e.jsx("p",{className:"text-slate-600",children:"Please wait while we verify your email address..."})]})]}),"success"===f&&e.jsxs("div",{className:"space-y-6",children:[e.jsx(t,{className:"w-16 h-16 text-green-500 mx-auto"}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-3xl font-bold text-slate-900 mb-2",children:"Email Confirmed!"}),e.jsx("p",{className:"text-slate-600 mb-4",children:"Your email has been successfully verified and you're now logged in."}),e.jsx("p",{className:"text-sm text-slate-500",children:"Redirecting you to the home page..."})]}),e.jsx("div",{className:"w-full bg-slate-200 rounded-full h-2",children:e.jsx("div",{className:"bg-orange-500 h-2 rounded-full animate-pulse",style:{width:"100%"}})})]}),"error"===f&&e.jsxs("div",{className:"space-y-6",children:[e.jsx(a,{className:"w-16 h-16 text-red-500 mx-auto"}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-3xl font-bold text-slate-900 mb-2",children:"Confirmation Failed"}),e.jsx("p",{className:"text-slate-600 mb-4",children:j||"There was an error confirming your email address."}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(n,{onClick:()=>m("/auth/signup"),className:"w-full bg-orange-500 hover:bg-orange-600 text-white",children:"Try Signing Up Again"}),e.jsx(n,{onClick:()=>m("/auth/signin"),variant:"outline",className:"w-full",children:"Sign In Instead"}),e.jsx(n,{onClick:()=>m("/"),variant:"ghost",className:"w-full text-slate-600 hover:text-slate-900",children:"Return to Home"})]})]})]})]})})]})};export{d as default};
