import{Au as e,Cd as t,Dd as n,Ed as r,Eu as i,Pd as a,i as o,ql as s,t as c,zd as l}from"./index-Q5R6-AeA.js";var u=l(a(),1),d=i();function f(){let{loginWithRedirect:i,isAuthenticated:a,isLoading:l}=t(),f=n(),p=r(),m=new URLSearchParams(p.search),h=m.get(`reauth`)===`1`,g=p.state?.returnTo??(h?sessionStorage.getItem(`auth:invitationReturnTo`):null)??e.HOME,_=m.get(`error`),v=_?_===`auth_failed`?`Authentication failed. Please try again.`:c[_]??_:h?`Your session expired. Please sign in again.`:null;return(0,u.useEffect)(()=>{!l&&a&&!h&&f(g,{replace:!0})},[a,l,h,f,g]),(0,u.useEffect)(()=>{localStorage.removeItem(`user`),h&&o()},[h]),(0,d.jsxs)(`div`,{className:`w-full flex flex-col justify-center items-center h-screen lg:grid lg:min-h-[200px] lg:grid-cols-2 xl:min-h-screen`,children:[(0,d.jsx)(`div`,{className:`flex items-center justify-center`,children:(0,d.jsxs)(`div`,{className:`space-y-8 w-[320px]`,children:[(0,d.jsxs)(`div`,{className:`grid gap-2 text-center`,children:[(0,d.jsx)(`h1`,{className:`text-3xl font-bold`,children:`Accounter`}),(0,d.jsx)(`h2`,{className:`text-3xl font-bold`,children:`Sign In`}),(0,d.jsx)(`p`,{className:`text-balance text-muted-foreground`,children:`Use your Auth0 account to continue`}),v?(0,d.jsx)(`p`,{className:`text-sm text-destructive`,children:v}):null]}),(0,d.jsx)(s,{onClick:()=>((!h||!sessionStorage.getItem(`auth:returnTo`))&&sessionStorage.setItem(`auth:returnTo`,g),i({authorizationParams:{audience:void 0,scope:`openid profile email offline_access`,...h?{prompt:`login`}:{},redirect_uri:`${window.location.origin}${e.AUTH_CALLBACK}`},appState:{returnTo:g}})),className:`w-full font-semibold`,disabled:l,children:l?`Preparing sign in...`:`Continue with Auth0`})]})}),(0,d.jsx)(`div`,{className:`hidden bg-muted lg:block bg-black rounded-tl-3xl rounded-bl-3xl`,children:(0,d.jsx)(`div`,{className:`flex flex-row justify-center items-center h-screen`,children:(0,d.jsx)(`img`,{src:`../../icons/guild-logo.svg`,alt:`Guild logo`,className:`w-[100px] h-[100px] object-cover`})})})]})}export{f as LoginPage};