1import{s as _,m as C,r as f,j as e,L as P,af as I,b as N}from"./index-BCW6nnV8.js";import{M as O}from"./mail-BtjO9jke.js";var T={version:"1.1.2"},L="authorization_response",M="/~oauth/initiate",R=["https://oauth.lovable.app","https://lovable.dev"],U="lovable://oauth-callback",D="http://127.0.0.1/iframe-oauth/callback",B=500,$=12e4;function H(t){let r;const n=new Promise(l=>{r=l}),o=l=>{if(!t.some(u=>l.origin===u))return;const a=l.data;!a||typeof a!="object"||a.type===L&&r(a.response)},p=()=>{window.removeEventListener("message",o)};return window.addEventListener("message",o),{cleanup:p,messagePromise:n}}function W(t){const r=window.screenX!==0||window.screenY!==0||!t,n=r?window.outerWidth*.5:window.screen.width*.5,o=r?window.outerHeight*.5:window.screen.height*.5,p=r?window.screenX+(window.outerWidth-n)/2:(window.screen.width-n)/2,l=r?window.screenY+(window.outerHeight-o)/2:(window.screen.height-o)/2;return{width:n,height:o,left:p,top:l}}function k(t,r){return t.state!==r?{error:new Error("State is invalid")}:t.error?t.error==="legacy_flow"?{error:new Error("This flow is not supported in Preview mode. Please open the app in a new tab to sign in.")}:{error:new Error(t.error_description??"Sign in failed")}:!t.access_token||!t.refresh_token?{error:new Error("No tokens received")}:{tokens:{access_token:t.access_token,refresh_token:t.refresh_token},error:null}}function z(){const t=navigator.userAgent;return!!(/iPhone|iPad|iPod|Android/i.test(t)||/Macintosh/i.test(t)&&navigator.maxTouchPoints>1)}function F(){return typeof crypto<"u"&&crypto.getRandomValues?[...crypto.getRandomValues(new Uint8Array(16))].map(t=>t.toString(16).padStart(2,"0")).join(""):Math.random().toString(36).substring(2)+Date.now().toString(36)}function V(t={}){const r=t.oauthBrokerUrl??M,n=t.supportedOAuthOrigins??R;async function o(p,l={}){let d=!1;try{d=window.self!==window.top}catch{d=!0}const a=navigator.userAgent,u=/LovableApp\//.test(a),m=!u&&/lovable/i.test(a),w=F();let x=l.redirect_uri??window.location.origin;u&&d?x=U:m&&d&&(x=D);const h=new URLSearchParams({...l.extraParams,provider:p,redirect_uri:x,state:w});if(!d)return window.location.href=`${r}?${h.toString()}`,{error:null,redirected:!0};!u&&!m&&h.set("response_mode","web_message");const v=`${r}?${h.toString()}`,j=m?[...n,window.location.origin]:n,{messagePromise:i,cleanup:s}=H(j);let b;if(z())b=window.open(v,"_blank");else{const{width:c,height:y,left:g,top:A}=W(d);b=window.open(v,"oauth",`width=${c},height=${y},left=${g},top=${A}`)}if(!b&&(u||m)){let c;const y=new Promise((g,A)=>{c=setTimeout(()=>{A(new Error("OAuth timed out waiting for response"))},$)});try{const g=await Promise.race([i,y]);return k(g,w)}catch(g){return{error:g instanceof Error?g:new Error(String(g))}}finally{c&&clearTimeout(c),s()}}if(!b)return s(),{error:new Error("Popup was blocked")};let E;const S=new Promise((c,y)=>{E=setInterval(()=>{b.closed&&(clearInterval(E),y(new Error("Sign in was cancelled")))},B)});try{const c=await Promise.race([i,S]);return k(c,w)}catch(c){return{error:c instanceof Error?c:new Error(String(c))}}finally{clearInterval(E),s(),b?.close()}}return{signInWithOAuth:o}}typeof window<"u"&&(window.__lovable_cloud_auth_js_version=T.version);function G(t={}){return V(t)}const K=G(),Y={auth:{signInWithOAuth:async(t,r)=>{const n=await K.signInWithOAuth(t,{redirect_uri:r?.redirect_uri,extraParams:{...r?.extraParams}});if(n.redirected||n.error)return n;try{await _.auth.setSession(n.tokens)}catch(o){return{error:o instanceof Error?o:new Error(String(o))}}return n}}};function Z(){const t=C(),[r,n]=f.useState("signin"),[o,p]=f.useState(""),[l,d]=f.useState(""),[a,u]=f.useState(null),[m,w]=f.useState(null),[x,h]=f.useState(null);f.useEffect(()=>{_.auth.getUser().then(({data:i})=>{i.user&&t({to:"/account",replace:!0})})},[t]);const v=async i=>{h(null),u(i);try{const s=await Y.auth.signInWithOAuth(i,{redirect_uri:window.location.origin});if(s.error)throw new Error(s.error.message||`${i} sign in failed`);if(s.redirected)return;t({to:"/account",replace:!0})}catch(s){h(s.message||"Sign in failed"),u(null)}},j=async i=>{i.preventDefault(),h(null),w(null),u("email");try{if(r==="signin"){const{error:s}=await _.auth.signInWithPassword({email:o.trim(),password:l});if(s)throw s;t({to:"/account",replace:!0})}else{const{error:s}=await _.auth.signUp({email:o.trim(),password:l,options:{emailRedirectTo:`${window.location.origin}/`}});if(s)throw s;w("Check your email to confirm your account.")}}catch(s){h(s.message||"Authentication failed")}finally{u(null)}};return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background px-4 py-12 bg-gradient-to-b from-background via-background to-surface/20",children:e.jsxs("div",{className:"w-full max-w-md",children:[e.jsxs(P,{to:"/",className:"flex items-center justify-center gap-2 mb-8",children:[e.jsx("img",{src:I,alt:"GelToyNation",className:"h-14 w-auto drop-shadow-[0_4px_20px_rgba(255,120,0,0.35)]"}),e.jsxs("span",{className:"text-xl font-extrabold italic tracking-tight font-display",children:[e.jsx("span",{className:"text-brand",children:"GELTOY"}),e.jsx("span",{className:"text-foreground",children:"NATION"})]})]}),e.jsxs("div",{className:"rounded-2xl border border-border bg-surface/40 backdrop-blur p-7 shadow-2xl",children:[e.jsx("h1",{className:"font-display text-2xl font-bold uppercase tracking-wider mb-1 text-center",children:r==="signin"?"Welcome back":"Create your account"}),e.jsx("p",{className:"text-xs text-muted-foreground mb-6 text-center",children:r==="signin"?"Sign in to access your orders and rewards.":"Join the nation. Members get exclusive drops."}),e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs("button",{type:"button",onClick:()=>v("google"),disabled:!!a,className:"w-full h-11 rounded-lg bg-white text-gray-900 text-sm font-semibold flex items-center justify-center gap-3 hover:bg-gray-100 transition disabled:opacity-50",children:[a==="google"?e.jsx(N,{className:"h-4 w-4 animate-spin"}):e.jsx(X,{}),"Continue with Google"]}),e.jsxs("button",{type:"button",onClick:()=>v("apple"),disabled:!!a,className:"w-full h-11 rounded-lg bg-black text-white text-sm font-semibold flex items-center justify-center gap-3 hover:bg-zinc-900 transition disabled:opacity-50 border border-white/10",children:[a==="apple"?e.jsx(N,{className:"h-4 w-4 animate-spin"}):e.jsx(q,{}),"Continue with Apple"]})]}),e.jsxs("div",{className:"my-5 flex items-center gap-3",children:[e.jsx("div",{className:"h-px flex-1 bg-border"}),e.jsx("span",{className:"text-[11px] uppercase tracking-wider text-muted-foreground",children:"or with email"}),e.jsx("div",{className:"h-px flex-1 bg-border"})]}),e.jsxs("form",{onSubmit:j,className:"space-y-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(O,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx("input",{type:"email",required:!0,"aria-label":"Email address",autoComplete:"email",placeholder:"[email protected]",value:o,onChange:i=>p(i.target.value),className:"w-full h-11 rounded-lg bg-background border border-border pl-10 pr-3 text-sm focus:border-brand focus:outline-none"})]}),e.jsx("input",{type:"password",required:!0,"aria-label":"Password",minLength:6,autoComplete:r==="signin"?"current-password":"new-password",placeholder:"Password",value:l,onCh
1ange:i=>d(i.target.value),className:"w-full h-11 rounded-lg bg-background border border-border px-3 text-sm focus:border-brand focus:outline-none"}),x&&e.jsx("p",{className:"text-xs text-red-500",children:x}),m&&e.jsx("p",{className:"text-xs text-green-500",children:m}),e.jsx("button",{type:"submit",disabled:!!a,className:"w-full h-11 rounded-lg bg-brand text-brand-foreground text-sm font-bold uppercase tracking-wider hover:brightness-110 disabled:opacity-50 flex items-center justify-center gap-2",children:a==="email"?e.jsx(N,{className:"h-4 w-4 animate-spin"}):r==="signin"?"Sign in":"Create account"})]}),e.jsx("button",{type:"button",onClick:()=>{n(i=>i==="signin"?"signup":"signin"),h(null),w(null)},className:"mt-5 w-full text-xs text-muted-foreground hover:text-foreground",children:r==="signin"?"New here? Create an account":"Already a member? Sign in"})]}),e.jsxs("p",{className:"mt-6 text-center text-[11px] text-muted-foreground",children:["By continuing you agree to our"," ",e.jsx(P,{to:"/terms",className:"underline hover:text-foreground",children:"Terms"}),"."]})]})})}function X(){return e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24","aria-hidden":!0,children:[e.jsx("path",{fill:"#4285F4",d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92a5.06 5.06 0 0 1-2.2 3.32v2.76h3.56c2.08-1.92 3.28-4.74 3.28-8.09z"}),e.jsx("path",{fill:"#34A853",d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.56-2.76c-.98.66-2.24 1.06-3.72 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84A11 11 0 0 0 12 23z"}),e.jsx("path",{fill:"#FBBC05",d:"M5.84 14.11A6.6 6.6 0 0 1 5.48 12c0-.73.13-1.44.36-2.11V7.05H2.18A11 11 0 0 0 1 12c0 1.77.42 3.45 1.18 4.95l3.66-2.84z"}),e.jsx("path",{fill:"#EA4335",d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.05l3.66 2.84C6.71 7.31 9.14 5.38 12 5.38z"})]})}function q(){return e.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":!0,children:e.jsx("path",{d:"M16.365 1.43c0 1.14-.43 2.22-1.15 3-1.06 1.16-2.78 2.04-4.18 1.93-.18-1.12.43-2.29 1.13-3.04C13.27 2.13 14.96 1.3 16.36 1.43zM20.5 17.4c-.55 1.27-.82 1.84-1.53 2.96-.99 1.57-2.38 3.52-4.11 3.54-1.54.02-1.94-1-4.03-.99-2.1.01-2.53 1.01-4.07.99-1.73-.02-3.05-1.78-4.04-3.35-2.77-4.41-3.06-9.59-1.35-12.34 1.21-1.95 3.13-3.09 4.93-3.09 1.83 0 2.99 1 4.5 1 1.47 0 2.36-1.01 4.48-1.01 1.6 0 3.3.87 4.51 2.38-3.97 2.17-3.32 7.84.71 8.91z"})})}export{Z as component};
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.