1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4859],{8159:(e,s,t)=>{"use strict";t.d(s,{r:()=>i.r});var i=t(63911)},61337:(e,s,t)=>{"use strict";t.d(s,{bd:()=>c,cc:()=>d,gz:()=>l,q6:()=>n});var i=t(55118),a=t(22953),r=t(37465);let n=["user","session"],l=()=>(0,r.useQuery)({queryKey:n,queryFn:async()=>{let{data:e,error:s}=await i.y.getSession({query:{disableCookieCache:!0}});if(s)throw Error(s.message||"Failed to fetch session");return e},staleTime:1/0,refetchOnWindowFocus:!1,retry:!1,enabled:a.$.ui.saas.enabled}),o=["user","accounts"],c=()=>(0,r.useQuery)({queryKey:o,queryFn:async()=>{let{data:e,error:s}=await i.y.listAccounts();if(s)throw s;return e}}),u=["user","passkeys"],d=()=>(0,r.useQuery)({queryKey:u,queryFn:async()=>{let{data:e,error:s}=await i.y.passkey.listUserPasskeys();if(s)throw s;return e}})},88375:(e,s,t)=>{"use strict";t.d(s,{LoginForm:()=>M});var i=t(40098),a=t(92387),r=t(55118),n=t(22953),l=t(79492),o=t(61337),c=t(2502),u=t(8159),d=t(23914),m=t(85103),h=t(43531),g=t(81213),x=t(62397),f=t(65308),b=t(25519),j=t(2561),p=t(86229),y=t(2695),v=t(99142),w=t(98342),N=t.n(w),k=t(99115),S=t(33938),L=t(73482),$=t(74750),C=t(10398),A=t(75249),P=t(38815),F=t(93020),q=t(90987);function E(e){let{activeMode:s,onChange:t,className:a}=e,r=(0,S.c3)();return(0,i.jsx)(q.tU,{value:s,onValueChange:t,className:a,children:(0,i.jsxs)(q.j7,{className:"w-full",children:[(0,i.jsx)(q.Xi,{value:"password",className:"flex-1",children:r("auth.login.modes.password")}),(0,i.jsx)(q.Xi,{value:"magic-link",className:"flex-1",children:r("auth.login.modes.magicLink")})]})})}var I=t(4369);let z=A.union([A.object({mode:A.literal("magic-link"),email:A.string().email()}),A.object({mode:A.literal("password"),email:A.string().email(),password:A.string().min(1)})]);function M(){var e;let s=(0,S.c3)(),{getAuthErrorMessage:t}=(0,l.e)(),w=(0,u.r)(),A=(0,d.useQueryClient)(),q=(0,k.useSearchParams)(),{user:M,loaded:O}=(0,F.w)(),[V,_]=(0,L.useState)(!1),Q=q.get("invitationId"),U=q.get("email"),X=q.get("redirectTo"),K=(0,$.mN)({resolver:(0,a.u)(z),defaultValues:{email:null!=U?U:"",password:"",mode:n.$.auth.enablePasswordLogin?"password":"magic-link"}}),R=Q?"/organization-invitation/".concat(Q):null!=X?X:n.$.auth.redirectAfterSignIn;(0,L.useEffect)(()=>{O&&M&&w.replace(R)},[M,O]);let T=async e=>{try{if("password"===e.mode){let{data:s,error:t}=await r.y.signIn.email({...e});if(t)throw t;if(s.twoFactorRedirect)return void w.replace((0,C.VL)("/auth/verify",Object.fromEntries(q.entries())));A.invalidateQueries({queryKey:o.q6}),w.replace(R)}else{let{error:s}=await r.y.signIn.magicLink({...e,callbackURL:R});if(s)throw s}}catch(e){K.setError("root",{message:t(e&&"object"==typeof e&&"code"in e?e.code:void 0)})}},B=async()=>{try{await r.y.signIn.passkey(),w.replace(R)}catch(e){K.setError("root",{message:t(e&&"object"==typeof e&&"code"in e?e.code:void 0)})}},W=K.watch("mode");return(0,i.jsxs)("div",{children:[(0,i.jsx)("h1",{className:"font-bold text-xl md:text-2xl",children:s("auth.login.title")}),(0,i.jsx)("p",{className:"mt-1 mb-6 text-foreground/60",children:s("auth.login.subtitle")}),K.formState.isSubmitSuccessful&&"magic-link"===W?(0,i.jsxs)(m.Fc,{variant:"success",children:[(0,i.jsx)(f.A,{}),(0,i.jsx)(m.XL,{children:s("auth.login.hints.linkSent.title")}),(0,i.jsx)(m.TN,{children:s("auth.login.hints.linkSent.message")})]}):(0,i.jsxs)(i.Fragment,{children:[Q&&(0,i.jsx)(c.T,{className:"mb-6"}),(0,i.jsx)(g.lV,{...K,children:(0,i.jsxs)("form",{className:"space-y-4",onSubmit:K.handleSubmit(T),children:[n.$.auth.enableMagicLink&&n.$.auth.enablePasswordLogin&&(0,i.jsx)(E,{activeMode:W,onChange:e=>K.setValue("mode",e)}),K.formState.isSubmitted&&(null==(e=K.formState.errors.root)?void 0:e.message)&&(0,i.jsxs)(m.Fc,{variant:"error",children:[(0,i.jsx)(b.A,{}),(0,i.jsx)(m.XL,{children:K.formState.errors.root.message})]}),(0,i.jsx)(g.zB,{control:K.control,name:"email",render:e=>{let{field:t}=e;return(0,i.jsxs)(g.eI,{children:[(0,i.jsx)(g.lR,{children:s("auth.signup.email")}),(0,i.jsx)(g.MJ,{children:(0,i.jsx)(x.p,{...t,autoComplete:"email"})})]})}}),n.$.auth.enablePasswordLogin&&"password"===W&&(0,i.jsx)(g.zB,{control:K.control,name:"password",render:e=>{let{field:t}=e;return(0,i.jsxs)(g.eI,{children:[(0,i.jsxs)("div",{className:"flex justify-between gap-4",children:[(0,i.jsx)(g.lR,{children:s("auth.signup.password")}),(0,i.jsx)(N(),{href:"/auth/forgot-password",className:"text-foreground
1/60 text-xs",children:s("auth.login.forgotPassword")})]}),(0,i.jsx)(g.MJ,{children:(0,i.jsxs)("div",{className:"relative",children:[(0,i.jsx)(x.p,{type:V?"text":"password",className:"pr-10",...t,autoComplete:"current-password"}),(0,i.jsx)("button",{type:"button",onClick:()=>_(!V),className:"absolute inset-y-0 right-0 flex items-center pr-4 text-primary text-xl",children:V?(0,i.jsx)(j.A,{className:"size-4"}):(0,i.jsx)(p.A,{className:"size-4"})})]})})]})}}),(0,i.jsx)(h.$,{className:"w-full",type:"submit",variant:"secondary",loading:K.formState.isSubmitting,children:"magic-link"===W?s("auth.login.sendMagicLink"):s("auth.login.submit")})]})}),(n.$.auth.enablePasskeys||n.$.auth.enableSignup&&n.$.auth.enableSocialLogin)&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("div",{className:"relative my-6 h-4",children:[(0,i.jsx)("hr",{className:"relative top-2"}),(0,i.jsx)("p",{className:"-translate-x-1/2 absolute top-0 left-1/2 mx-auto inline-block h-4 bg-card px-2 text-center font-medium text-foreground/60 text-sm leading-tight",children:s("auth.login.continueWith")})]}),(0,i.jsxs)("div",{className:"grid grid-cols-1 items-stretch gap-2 sm:grid-cols-1",children:[n.$.auth.enableSignup&&n.$.auth.enableSocialLogin&&Object.keys(P.M).map(e=>(0,i.jsx)(I.S,{provider:e},e)),n.$.auth.enablePasskeys&&(0,i.jsxs)(h.$,{variant:"light",className:"w-full sm:col-span-2",onClick:()=>B(),children:[(0,i.jsx)(y.A,{className:"mr-1.5 size-4 text-primary"}),s("auth.login.loginWithPasskey")]})]})]}),n.$.auth.enableSignup&&(0,i.jsxs)("div",{className:"mt-6 text-center text-sm",children:[(0,i.jsxs)("span",{className:"text-foreground/60",children:[s("auth.login.dontHaveAnAccount")," "]}),(0,i.jsxs)(N(),{href:(0,C.VL)("/auth/signup",Object.fromEntries(q.entries())),children:[s("auth.login.createAnAccount"),(0,i.jsx)(v.A,{className:"ml-1 inline size-4 align-middle"})]})]})]})]})}},88675:(e,s,t)=>{"use strict";t.d(s,{I:()=>i});let i=t(73482).createContext(void 0)},90987:(e,s,t)=>{"use strict";t.d(s,{Xi:()=>o,av:()=>c,j7:()=>l,tU:()=>n});var i=t(40098),a=t(50141),r=t(78874);t(73482);let n=a.bL,l=e=>{let{className:s,...t}=e;return(0,i.jsx)(a.B8,{className:(0,r.cn)("inline-flex items-center justify-center border-b-2 text-card-foreground/80 text-sm",s),...t})},o=e=>{let{className:s,...t}=e;return(0,i.jsx)(a.l9,{className:(0,r.cn)("-mb-0.5 inline-flex items-center justify-center whitespace-nowrap border-transparent border-b-2 px-3 py-2 font-medium text-foreground/60 text-sm ring-offset-background transition-all hover:text-foreground/80 focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:border-primary data-[state=active]:text-card-foreground",s),...t})},c=e=>{let{className:s,...t}=e;return(0,i.jsx)(a.UC,{className:(0,r.cn)("mt-2 ring-offset-background focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",s),...t})}},93020:(e,s,t)=>{"use strict";t.d(s,{w:()=>r});var i=t(73482),a=t(88675);let r=()=>{let e=(0,i.useContext)(a.I);if(void 0===e)throw Error("useSession must be used within SessionProvider");return e}},99791:(e,s,t)=>{Promise.resolve().then(t.bind(t,88375)),Promise.resolve().then(t.bind(t,53458))}},e=>{e.O(0,[4881,86,8342,1341,1841,9512,3911,7465,9770,7540,4201,9583,5189,85,1719,6411,7358],()=>e(e.s=99791)),_N_E=e.O()}]);
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.