import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{i as t,r as n}from"./bundle-mjs-fcjm5Rpo.js";import{n as r}from"./utils-C1dPOAK7.js";import{a as i,c as a,n as o,o as s,r as c,t as l}from"./access-control-D86mfb14.js";var u=e(t()),d=n();function f(){return(0,d.jsxs)(`svg`,{viewBox:`0 0 48 48`,className:`size-5`,"aria-hidden":`true`,children:[(0,d.jsx)(`path`,{fill:`#EA4335`,d:`M24 9.5c3.5 0 6.6 1.2 9.1 3.6l6.8-6.8C35.9 2.4 30.4 0 24 0 14.6 0 6.5 5.4 2.6 13.2l7.9 6.2C12.4 13.5 17.7 9.5 24 9.5z`}),(0,d.jsx)(`path`,{fill:`#4285F4`,d:`M46.1 24.6c0-1.6-.1-2.8-.4-4.1H24v7.8h12.7c-.3 2.1-1.6 5.3-4.7 7.4l7.7 6c4.5-4.2 7.1-10.3 7.1-17.1z`}),(0,d.jsx)(`path`,{fill:`#FBBC05`,d:`M10.5 28.6c-.5-1.5-.8-3-.8-4.6s.3-3.1.8-4.6l-7.9-6.2C1 16.3 0 20 0 24s1 7.7 2.6 10.8l7.9-6.2z`}),(0,d.jsx)(`path`,{fill:`#34A853`,d:`M24 48c6.5 0 11.9-2.1 15.8-5.8l-7.7-6c-2.1 1.4-4.9 2.4-8.1 2.4-6.3 0-11.6-4-13.5-9.9l-7.9 6.2C6.5 42.6 14.6 48 24 48z`})]})}function p(){let e=r(),[t,n]=(0,u.useState)(!1),[p,m]=(0,u.useState)(!0),[h,g]=(0,u.useState)(``);return(0,u.useEffect)(()=>{let t=!0;return(async()=>{let n=c();n&&t&&g(n);try{let n=s(),r=await l(n);if(!t)return;if(r.allowed){e({to:`/chat`,replace:!0});return}if(r.reason!==`signed_out`){if(await o(n),!t)return;g(r.message)}}catch(e){console.error(e),t&&g(e instanceof Error?e.message:`No se pudo iniciar Supabase.`)}finally{t&&m(!1)}})(),()=>{t=!1}},[e]),(0,d.jsxs)(`main`,{className:`login-canvas relative flex min-h-[100dvh] items-center justify-center overflow-hidden px-5 py-10`,children:[(0,d.jsx)(`div`,{className:`login-grid`,"aria-hidden":`true`}),(0,d.jsx)(`div`,{className:`login-orb login-orb-left`,"aria-hidden":`true`}),(0,d.jsx)(`div`,{className:`login-orb login-orb-right`,"aria-hidden":`true`}),(0,d.jsx)(`section`,{className:`animate-rise relative z-10 w-full max-w-[25rem]`,children:(0,d.jsxs)(`div`,{className:`login-card overflow-hidden rounded-[1.9rem] border border-white/80 bg-white/90 px-7 pb-9 pt-10 shadow-[var(--shadow-login)] backdrop-blur-xl sm:px-10 sm:pb-10 sm:pt-11`,children:[(0,d.jsx)(`div`,{className:`absolute inset-x-0 top-0 h-[3px] bg-[image:var(--gradient-brand)]`}),(0,d.jsxs)(`div`,{className:`flex flex-col items-center text-center`,children:[(0,d.jsx)(`div`,{className:`login-logo-box grid h-[5.7rem] w-[6.8rem] place-items-center rounded-[1.45rem] border border-slate-100 bg-white shadow-[0_12px_34px_-18px_rgba(79,117,139,0.55)]`,children:(0,d.jsx)(a,{className:`h-auto w-[5.2rem]`})}),(0,d.jsx)(`h1`,{className:`mt-8 text-[1.85rem] font-bold leading-tight tracking-[-0.045em] text-primary sm:text-[2rem]`,children:`Cotizador Walmart Connect`}),(0,d.jsxs)(`button`,{type:`button`,onClick:async()=>{n(!0),g(``);try{let{error:e}=await s().auth.signInWithOAuth({provider:`google`,options:{redirectTo:i(),queryParams:{access_type:`offline`,prompt:`select_account`,hd:`gomezleemarketing.com`}}});if(e)throw e}catch(e){console.error(e),g(`No se pudo abrir el acceso con Google. Intenta nuevamente.`),n(!1)}},disabled:t||p,className:`login-google-button mt-9 inline-flex h-[3.35rem] w-full items-center justify-center gap-3 rounded-xl px-5 text-[0.94rem] font-bold text-white shadow-[0_15px_30px_-17px_rgba(79,117,139,0.9)] transition-all hover:-translate-y-0.5 hover:brightness-[1.03] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-4 disabled:pointer-events-none disabled:opacity-70`,children:[t||p?(0,d.jsx)(`span`,{className:`size-4 animate-spin rounded-full border-2 border-white/50 border-t-white`}):(0,d.jsx)(f,{}),p?`Verificando acceso...`:t?`Abriendo Google...`:`Continuar con Google`]}),h?(0,d.jsx)(`p`,{role:`alert`,className:`mt-4 text-sm leading-relaxed text-destructive`,children:h}):null]})]})})]})}export{p as component};