LoginPage-CXIN3BLj.js 22 KB

1
  1. import{i as e}from"./chunk-aKtaBQYM.js";import{C as t,D as n,a as r,w as i}from"./client-BdOyoZJz.js";import{t as a}from"./useQuery-CCy0EwsM.js";import{t as o}from"./useMutation-qh3Iyscy.js";import{n as s}from"./ToastContext-VFOrCCoA.js";import{t as ee}from"./shield-CfkeOiiL.js";import{t as te}from"./smartphone-DOKM2tP4.js";import{t as ne}from"./x-Dctff5l9.js";import{i as re,n as ie,t as ae}from"./Card-OUAj0Ayh.js";import{t as c}from"./Button-pwVKPiYn.js";import{Bn as oe,Vn as se,Wn as ce,in as le,ln as ue,vt as de,yt as fe}from"./index-BoVbGTav.js";var l=e(n(),1),u=t(),d=`auth_remember_me`,f=`auth_post_login_redirect`;function p(e){return e?`persistent`:`session`}function pe(){try{let e=sessionStorage.getItem(d)===`1`;return sessionStorage.removeItem(d),e}catch(e){return console.warn(`consumeSavedRememberMe: sessionStorage unavailable, Remember Me preference lost across OIDC redirect`,e),!1}}function m(e){return!e||!e.startsWith(`/`)||e.startsWith(`//`)||e.startsWith(`/login`)?null:e}function h(e){let t=m(e);if(t)try{sessionStorage.setItem(f,t)}catch(e){console.warn(`stashPostLoginRedirect: sessionStorage unavailable, post-login target will be lost across OIDC redirect`,e)}}function me(){try{let e=sessionStorage.getItem(f);return sessionStorage.removeItem(f),m(e)}catch(e){return console.warn(`consumePostLoginRedirect: sessionStorage unavailable`,e),null}}function he({provider:e,onClick:t,disabled:n}){let{t:a}=i(),[o,s]=(0,l.useState)(!1);return(0,u.jsxs)(`button`,{type:`button`,onClick:t,disabled:n,className:`w-full flex items-center justify-center gap-3 py-3 px-4 bg-bambu-dark-secondary border border-bambu-dark-tertiary hover:border-bambu-green/50 rounded-lg text-white font-medium transition-colors disabled:opacity-50`,children:[e.has_icon&&!o?(0,u.jsx)(`img`,{src:r.oidcProviderIconUrl(e.id),alt:``,className:`w-5 h-5 object-contain`,onError:()=>s(!0)}):(0,u.jsx)(ee,{className:`w-5 h-5 text-bambu-green`}),a(`login.twoFA.signInWith`,{provider:e.name})]})}function g(){let e=se(),t=oe(),[n]=ce(),{t:f}=i(),{login:g,loginWithToken:_,user:v,loading:ge}=fe(),{showToast:y}=s(),{mode:_e}=de();function b(){let e=t.state?.from;if(e?.pathname){let t=m(`${e.pathname}${e.search??``}`);if(t)return t}return me()??`/`}let[x,ve]=(0,l.useState)(``),[S,ye]=(0,l.useState)(``),[be,C]=(0,l.useState)(!1),[w,T]=(0,l.useState)(``),[E,D]=(0,l.useState)(`credentials`),[O,k]=(0,l.useState)(``),[A,j]=(0,l.useState)([]),[M,N]=(0,l.useState)(`totp`),[P,F]=(0,l.useState)(``),[I,L]=(0,l.useState)(!1),xe=(0,l.useRef)(null),[R,z]=(0,l.useState)(!1),[Se,B]=(0,l.useState)(``),[V,H]=(0,l.useState)(``),[U,W]=(0,l.useState)(``),{data:G}=a({queryKey:[`advancedAuthStatus`],queryFn:()=>r.getAdvancedAuthStatus()}),{data:K}=a({queryKey:[`oidcProviders`],queryFn:()=>r.getOIDCProviders()}),[Ce,we]=(0,l.useState)(!1);(0,l.useEffect)(()=>{!ge&&v&&E===`credentials`&&e(`/`,{replace:!0})},[ge,v,E,e]);let Te=(0,l.useRef)(!1);(0,l.useEffect)(()=>{if(Te.current||n.get(`fallback`)===`local`||!G||!G.autologin_provider_id||window.location.hash.startsWith(`#oidc_token=`)||n.get(`oidc_error`))return;Te.current=!0;let e=G.autologin_provider_id,i=new Promise((e,t)=>setTimeout(()=>t(Error(`autologin timeout`)),5e3));Promise.race([r.getOIDCAuthorizeUrl(e),i]).then(e=>{let n=t.state?.from;n?.pathname&&h(`${n.pathname}${n.search??``}`),window.location.href=e.auth_url}).catch(()=>{we(!0)})},[G,n,t.state]);let q=G?.local_login_enabled!==!1,Ee=Ce&&G?.autologin_provider_id!=null;(0,l.useEffect)(()=>{let t=window.location.hash,n=t.startsWith(`#reset_token=`)?t.slice(13):null;n&&(B(n),D(`reset-password`),e(`/login`,{replace:!0}))},[]),(0,l.useEffect)(()=>{let t=window.location.hash,i=t.startsWith(`#oidc_token=`)?t.slice(12):null,a=n.get(`oidc_error`);if(!i&&!a)return;let o=pe();if(a){y({oidc_provider_error:f(`login.oidcErrors.providerError`),missing_parameters:f(`login.oidcErrors.missingParameters`),invalid_state:f(`login.oidcErrors.invalidState`),state_expired:f(`login.oidcErrors.stateExpired`),provider_not_found:f(`login.oidcErrors.providerNotFound`),discovery_failed:f(`login.oidcErrors.discoveryFailed`),invalid_discovery_document:f(`login.oidcErrors.invalidDiscovery`),token_exchange_network_error:f(`login.oidcErrors.networkError`),token_exchange_bad_response:f(`login.oidcErrors.badResponse`),no_id_token:f(`login.oidcErrors.noIdToken`),token_validation_failed:f(`login.oidcErrors.validationFailed`),nonce_mismatch:f(`login.oidcErrors.nonceMismatch`),missing_sub_claim:f(`login.oidcErrors.missingSubClaim`),no_linked_account:f(`login.oidcErrors.noLinkedAccount`),account_inactive:f(`login.oidcErrors.accountInactive`),user_resolution_failed:f(`login.oidcErrors.userResolutionFailed`),internal_error:f(`login.oidcErrors.internalError`)}[a]??(a.startsWith(`token_exchange_`)?f(`login.oidcErrors.tokenExchangeFailed`):f(`login.oidcLoginFailed`)),`error`),e(`/login`,{replace:!0});return}i&&r.exchangeOIDCToken(i).then(t=>{if(t.requires_2fa&&t.pre_auth_token){z(o),k(t.pre_auth_token);let n=t.two_fa_methods??[];j(n),n.includes(`totp`)?N(`totp`):n.includes(`email`)?N(`email`):N(`backup`),D(`2fa`),e(`/login`,{replace:!0})}else t.access_token&&t.user?(_(t.access_token,t.user,p(o)),y(f(`login.loginSuccess`)),e(b(),{replace:!0})):(y(f(`login.oidcLoginFailed`),`error`),e(`/login`,{replace:!0}))}).catch(t=>{console.error(`OIDC token exchange failed`,t),y(f(`login.oidcLoginFailed`),`error`),e(`/login`,{replace:!0})})},[n]);let J=o({mutationFn:()=>g(x,S,p(R)),onSuccess:t=>{if(t.requires_2fa&&t.pre_auth_token){k(t.pre_auth_token);let e=t.two_fa_methods??[];j(e),e.includes(`totp`)?N(`totp`):e.includes(`email`)?N(`email`):N(`backup`),D(`2fa`)}else t.access_token&&t.user&&(y(f(`login.loginSuccess`)),e(b(),{replace:!0}))},onError:e=>{y(e.message||f(`login.loginFailed`),`error`)}}),Y=o({mutationFn:e=>r.forgotPassword({email:e}),onSuccess:e=>{y(e.message,`success`),C(!1),T(``)},onError:e=>{y(e.message,`error`)}}),X=o({mutationFn:()=>r.forgotPasswordConfirm(Se,V),onSuccess:e=>{y(e.message,`success`),D(`credentials`),B(``),H(``),W(``)},onError:e=>{y(e.message||f(`login.resetPassword.resetFailed`),`error`)}}),Z=o({mutationFn:()=>r.sendEmailOTP(O),onSuccess:e=>{L(!0),e.pre_auth_token&&k(e.pre_auth_token),y(e.message,`success`)},onError:e=>{y(e.message||f(`login.twoFA.sendCodeFailed`),`error`)}}),Q=o({mutationFn:()=>r.verify2FA({pre_auth_token:O,code:P,method:M}),onSuccess:t=>{t.access_token&&t.user?(_(t.access_token,t.user,p(R)),y(f(`login.loginSuccess`)),e(b(),{replace:!0})):(console.error(`2FA verify: unexpected response shape`,t),y(f(`login.loginFailed`),`error`))},onError:e=>{y(e.message||f(`login.twoFA.invalidCode`),`error`),F(``)}}),De=o({mutationFn:e=>r.getOIDCAuthorizeUrl(e),onSuccess:e=>{try{R?sessionStorage.setItem(d,`1`):sessionStorage.removeItem(d)}catch(e){console.warn(`setItem/removeItem auth_remember_me failed, Remember Me will not carry through OIDC redirect`,e)}let n=t.state?.from;n?.pathname&&h(`${n.pathname}${n.search??``}`),window.location.href=e.auth_url},onError:e=>{y(e.message||f(`login.oidcLoginFailed`),`error`)}}),Oe=e=>{if(e.preventDefault(),!x||!S){y(f(`login.enterCredentials`),`error`);return}J.mutate()},ke=e=>{if(e.preventDefault(),!P.trim()){y(f(`login.twoFA.enterCode`),`error`);return}Q.mutate()},Ae=e=>{if(e.preventDefault(),!w){y(f(`login.enterEmail`),`error`);return}Y.mutate(w)},$=e=>{N(e),F(``),L(!1),setTimeout(()=>xe.current?.focus(),0)};return E===`reset-password`?(0,u.jsx)(`div`,{className:`min-h-screen flex items-center justify-center bg-bambu-dark p-4`,children:(0,u.jsxs)(`div`,{className:`max-w-md w-full space-y-8 p-8 bg-gradient-to-br from-bambu-card to-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary shadow-lg`,children:[(0,u.jsxs)(`div`,{className:`text-center`,children:[(0,u.jsx)(`div`,{className:`flex items-center justify-center mb-4`,children:(0,u.jsx)(`div`,{className:`w-14 h-14 rounded-full bg-bambu-green/20 flex items-center justify-center`,children:(0,u.jsx)(ue,{className:`w-7 h-7 text-bambu-green`})})}),(0,u.jsx)(`h2`,{className:`text-2xl font-bold text-white`,children:f(`login.resetPassword.title`)}),(0,u.jsx)(`p`,{className:`mt-2 text-sm text-bambu-gray`,children:f(`login.resetPassword.subtitle`)})]}),(0,u.jsxs)(`form`,{onSubmit:e=>{if(e.preventDefault(),V!==U){y(f(`login.resetPassword.passwordsDoNotMatch`),`error`);return}if(V.length<8){y(f(`login.resetPassword.passwordTooShort`),`error`);return}X.mutate()},className:`space-y-4`,children:[(0,u.jsxs)(`div`,{children:[(0,u.jsx)(`label`,{htmlFor:`new-password`,className:`block text-sm font-medium text-white mb-2`,children:f(`login.resetPassword.newPassword`)}),(0,u.jsx)(`input`,{id:`new-password`,type:`password`,required:!0,value:V,onChange:e=>H(e.target.value),className:`block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors`,placeholder:f(`login.resetPassword.newPasswordPlaceholder`),autoFocus:!0,autoComplete:`new-password`,minLength:8})]}),(0,u.jsxs)(`div`,{children:[(0,u.jsx)(`label`,{htmlFor:`confirm-password`,className:`block text-sm font-medium text-white mb-2`,children:f(`login.resetPassword.confirmPassword`)}),(0,u.jsx)(`input`,{id:`confirm-password`,type:`password`,required:!0,value:U,onChange:e=>W(e.target.value),className:`block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors`,placeholder:f(`login.resetPassword.confirmPasswordPlaceholder`),autoComplete:`new-password`})]}),(0,u.jsx)(`button`,{type:`submit`,disabled:X.isPending||!V||!U,className:`w-full flex justify-center py-3 px-4 bg-bambu-green hover:bg-bambu-green-light text-white font-medium rounded-lg shadow-lg shadow-bambu-green/20 hover:shadow-bambu-green/30 focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:ring-offset-2 focus:ring-offset-bambu-dark-secondary transition-all disabled:opacity-50 disabled:cursor-not-allowed`,children:X.isPending?f(`login.resetPassword.saving`):f(`login.resetPassword.submit`)})]}),(0,u.jsx)(`div`,{className:`text-center`,children:(0,u.jsx)(`button`,{type:`button`,onClick:()=>{D(`credentials`),B(``),H(``),W(``)},className:`text-sm text-bambu-gray hover:text-bambu-green transition-colors`,children:f(`login.resetPassword.backToLogin`)})})]})}):E===`2fa`?(0,u.jsx)(`div`,{className:`min-h-screen flex items-center justify-center bg-bambu-dark p-4`,children:(0,u.jsxs)(`div`,{className:`max-w-md w-full space-y-8 p-8 bg-gradient-to-br from-bambu-card to-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary shadow-lg`,children:[(0,u.jsxs)(`div`,{className:`text-center`,children:[(0,u.jsx)(`div`,{className:`flex items-center justify-center mb-4`,children:(0,u.jsx)(`div`,{className:`w-14 h-14 rounded-full bg-bambu-green/20 flex items-center justify-center`,children:(0,u.jsx)(ee,{className:`w-7 h-7 text-bambu-green`})})}),(0,u.jsx)(`h2`,{className:`text-2xl font-bold text-white`,children:f(`login.twoFA.title`)}),(0,u.jsx)(`p`,{className:`mt-2 text-sm text-bambu-gray`,children:f(`login.twoFA.subtitle`)})]}),A.length>1&&(0,u.jsxs)(`div`,{className:`flex gap-2`,children:[A.includes(`totp`)&&(0,u.jsxs)(`button`,{type:`button`,onClick:()=>$(`totp`),className:`flex-1 flex flex-col items-center gap-1 py-2 px-3 rounded-lg border text-xs font-medium transition-colors ${M===`totp`?`border-bambu-green bg-bambu-green/10 text-bambu-green`:`border-bambu-dark-tertiary text-bambu-gray hover:border-bambu-green/50`}`,children:[(0,u.jsx)(te,{className:`w-4 h-4`}),f(`login.twoFA.methodAuthenticator`)]}),A.includes(`email`)&&(0,u.jsxs)(`button`,{type:`button`,onClick:()=>$(`email`),className:`flex-1 flex flex-col items-center gap-1 py-2 px-3 rounded-lg border text-xs font-medium transition-colors ${M===`email`?`border-bambu-green bg-bambu-green/10 text-bambu-green`:`border-bambu-dark-tertiary text-bambu-gray hover:border-bambu-green/50`}`,children:[(0,u.jsx)(le,{className:`w-4 h-4`}),f(`login.twoFA.methodEmail`)]}),A.includes(`backup`)&&(0,u.jsxs)(`button`,{type:`button`,onClick:()=>$(`backup`),className:`flex-1 flex flex-col items-center gap-1 py-2 px-3 rounded-lg border text-xs font-medium transition-colors ${M===`backup`?`border-bambu-green bg-bambu-green/10 text-bambu-green`:`border-bambu-dark-tertiary text-bambu-gray hover:border-bambu-green/50`}`,children:[(0,u.jsx)(ue,{className:`w-4 h-4`}),f(`login.twoFA.methodBackup`)]})]}),(0,u.jsxs)(`form`,{onSubmit:ke,className:`space-y-4`,children:[M===`totp`&&(0,u.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:f(`login.twoFA.instructionsTotp`)}),M===`email`&&(0,u.jsxs)(`div`,{className:`space-y-3`,children:[(0,u.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:f(I?`login.twoFA.instructionsEmail`:`login.twoFA.instructionsEmailNotSent`)}),!I&&(0,u.jsx)(c,{type:`button`,variant:`secondary`,className:`w-full`,onClick:()=>Z.mutate(),disabled:Z.isPending,children:Z.isPending?f(`login.twoFA.sendingCode`):f(`login.twoFA.sendCodeButton`)}),I&&(0,u.jsx)(`button`,{type:`button`,onClick:()=>{L(!1),Z.mutate()},className:`text-xs text-bambu-gray hover:text-bambu-green transition-colors`,children:f(`login.twoFA.resendCode`)})]}),M===`backup`&&(0,u.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:f(`login.twoFA.instructionsBackup`)}),(0,u.jsxs)(`div`,{children:[(0,u.jsx)(`label`,{htmlFor:`twofa-code`,className:`block text-sm font-medium text-white mb-2`,children:f(M===`backup`?`login.twoFA.backupCodeLabel`:`login.twoFA.codeLabel`)}),(0,u.jsx)(`input`,{ref:xe,id:`twofa-code`,type:`text`,inputMode:M===`backup`?`text`:`numeric`,autoComplete:`one-time-code`,value:P,onChange:e=>F(e.target.value.trim()),disabled:M===`email`&&!I,className:`block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray text-center tracking-widest text-xl font-mono focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors disabled:opacity-40`,placeholder:f(M===`backup`?`login.twoFA.backupCodePlaceholder`:`login.twoFA.codePlaceholder`),maxLength:M===`backup`?8:6,autoFocus:!0})]}),(0,u.jsx)(`button`,{type:`submit`,disabled:Q.isPending||!P.trim()||M===`email`&&!I,className:`w-full flex justify-center py-3 px-4 bg-bambu-green hover:bg-bambu-green-light text-white font-medium rounded-lg shadow-lg shadow-bambu-green/20 hover:shadow-bambu-green/30 focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:ring-offset-2 focus:ring-offset-bambu-dark-secondary transition-all disabled:opacity-50 disabled:cursor-not-allowed`,children:Q.isPending?f(`login.twoFA.verifyingButton`):f(`login.twoFA.verifyButton`)})]}),(0,u.jsx)(`div`,{className:`text-center`,children:(0,u.jsx)(`button`,{type:`button`,onClick:()=>{D(`credentials`),k(``),F(``),L(!1)},className:`text-sm text-bambu-gray hover:text-bambu-green transition-colors`,children:f(`login.twoFA.backToLogin`)})})]})}):(0,u.jsxs)(`div`,{className:`min-h-screen flex items-center justify-center bg-bambu-dark p-4`,children:[(0,u.jsxs)(`div`,{className:`max-w-md w-full space-y-8 p-8 bg-gradient-to-br from-bambu-card to-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary shadow-lg`,children:[(0,u.jsxs)(`div`,{className:`text-center`,children:[(0,u.jsx)(`div`,{className:`flex items-center justify-center mb-6`,children:(0,u.jsx)(`img`,{src:_e===`dark`?`/img/bambuddy_logo_dark_transparent.png`:`/img/bambuddy_logo_light.png`,alt:`Bambuddy`,className:`h-16`})}),(0,u.jsx)(`h2`,{className:`text-3xl font-bold text-white`,children:f(`login.title`)}),(0,u.jsx)(`p`,{className:`mt-2 text-sm text-bambu-gray`,children:f(`login.subtitle`)})]}),Ee&&(0,u.jsx)(`div`,{className:`mt-6 rounded-lg border border-amber-300 dark:border-amber-500/40 bg-amber-50 dark:bg-amber-500/10 px-4 py-3 text-sm text-amber-800 dark:text-amber-200`,children:f(`login.autologinFailed`)}),!q&&(0,u.jsx)(`div`,{className:`mt-6 rounded-lg border border-bambu-dark-tertiary bg-bambu-dark/40 px-4 py-3 text-sm text-bambu-gray`,children:f(`login.localDisabledNotice`)}),q&&(0,u.jsxs)(`form`,{className:`mt-8 space-y-6`,onSubmit:Oe,children:[(0,u.jsxs)(`div`,{className:`space-y-4`,children:[(0,u.jsxs)(`div`,{children:[(0,u.jsx)(`label`,{htmlFor:`username`,className:`block text-sm font-medium text-white mb-2`,children:G?.advanced_auth_enabled?f(`login.usernameOrEmail`):f(`login.username`)}),(0,u.jsx)(`input`,{id:`username`,type:`text`,required:!0,value:x,onChange:e=>ve(e.target.value),className:`block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors`,placeholder:G?.advanced_auth_enabled?f(`login.usernameOrEmailPlaceholder`):f(`login.usernamePlaceholder`),autoComplete:`username`})]}),(0,u.jsxs)(`div`,{children:[(0,u.jsx)(`label`,{htmlFor:`password`,className:`block text-sm font-medium text-white mb-2`,children:f(`login.password`)||`Password`}),(0,u.jsx)(`input`,{id:`password`,type:`password`,required:!0,value:S,onChange:e=>ye(e.target.value),className:`block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors`,placeholder:f(`login.passwordPlaceholder`),autoComplete:`current-password`})]})]}),(0,u.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,u.jsx)(`input`,{id:`remember-me`,type:`checkbox`,checked:R,onChange:e=>z(e.target.checked),className:`h-4 w-4 rounded border-bambu-dark-tertiary bg-bambu-dark-secondary text-bambu-green focus:ring-bambu-green/50 cursor-pointer`}),(0,u.jsx)(`label`,{htmlFor:`remember-me`,className:`text-sm text-bambu-gray cursor-pointer`,children:f(`login.rememberMe`)})]}),(0,u.jsx)(`div`,{children:(0,u.jsx)(`button`,{type:`submit`,disabled:J.isPending,className:`w-full flex justify-center py-3 px-4 bg-bambu-green hover:bg-bambu-green-light text-white font-medium rounded-lg shadow-lg shadow-bambu-green/20 hover:shadow-bambu-green/30 focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:ring-offset-2 focus:ring-offset-bambu-dark-secondary transition-all disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-bambu-green`,children:J.isPending?f(`login.signingIn`):f(`login.signIn`)})}),(0,u.jsx)(`div`,{className:`text-center`,children:(0,u.jsx)(`button`,{type:`button`,onClick:()=>C(!0),className:`text-sm text-bambu-gray hover:text-bambu-green transition-colors`,children:f(`login.forgotPassword`)})})]}),K&&K.length>0&&(0,u.jsxs)(`div`,{className:`space-y-3`,children:[q&&(0,u.jsxs)(`div`,{className:`relative`,children:[(0,u.jsx)(`div`,{className:`absolute inset-0 flex items-center`,children:(0,u.jsx)(`div`,{className:`w-full border-t border-bambu-dark-tertiary`})}),(0,u.jsx)(`div`,{className:`relative flex justify-center text-sm`,children:(0,u.jsx)(`span`,{className:`px-2 bg-bambu-dark-secondary text-bambu-gray`,children:f(`login.twoFA.orContinueWith`)})})]}),!q&&(0,u.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,u.jsx)(`input`,{id:`remember-me`,type:`checkbox`,checked:R,onChange:e=>z(e.target.checked),className:`h-4 w-4 rounded border-bambu-dark-tertiary bg-bambu-dark-secondary text-bambu-green focus:ring-bambu-green/50 cursor-pointer`}),(0,u.jsx)(`label`,{htmlFor:`remember-me`,className:`text-sm text-bambu-gray cursor-pointer`,children:f(`login.rememberMe`)})]}),(0,u.jsx)(`div`,{className:`space-y-2`,children:K.map(e=>(0,u.jsx)(he,{provider:e,onClick:()=>De.mutate(e.id),disabled:De.isPending},e.id))})]})]}),be&&(0,u.jsx)(`div`,{className:`fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4`,onClick:()=>C(!1),children:(0,u.jsxs)(ae,{className:`w-full max-w-md`,onClick:e=>e.stopPropagation(),children:[(0,u.jsx)(re,{children:(0,u.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,u.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,u.jsx)(le,{className:`w-5 h-5 text-bambu-green`}),(0,u.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:f(`login.forgotPasswordTitle`)})]}),(0,u.jsx)(c,{variant:`ghost`,size:`sm`,onClick:()=>{C(!1),T(``)},children:(0,u.jsx)(ne,{className:`w-5 h-5`})})]})}),(0,u.jsx)(ie,{children:G?.advanced_auth_enabled?(0,u.jsxs)(`form`,{onSubmit:Ae,className:`space-y-4`,children:[(0,u.jsx)(`p`,{className:`text-bambu-gray text-sm`,children:f(`login.forgotPasswordEmailMessage`)}),(0,u.jsxs)(`div`,{children:[(0,u.jsx)(`label`,{htmlFor:`forgot-email`,className:`block text-sm font-medium text-white mb-2`,children:f(`login.emailAddress`)}),(0,u.jsx)(`input`,{id:`forgot-email`,type:`email`,required:!0,value:w,onChange:e=>T(e.target.value),className:`block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors`,placeholder:f(`login.emailPlaceholder`)})]}),(0,u.jsxs)(`div`,{className:`flex gap-2`,children:[(0,u.jsx)(c,{type:`button`,variant:`secondary`,className:`flex-1`,onClick:()=>{C(!1),T(``)},children:f(`login.cancel`)}),(0,u.jsx)(c,{type:`submit`,className:`flex-1`,disabled:Y.isPending,children:Y.isPending?f(`login.sending`):f(`login.sendResetEmail`)})]})]}):(0,u.jsxs)(`div`,{className:`space-y-4`,children:[(0,u.jsx)(`p`,{className:`text-bambu-gray`,children:f(`login.forgotPasswordMessage`)}),(0,u.jsxs)(`div`,{className:`bg-bambu-dark rounded-lg p-4 space-y-2`,children:[(0,u.jsx)(`p`,{className:`text-sm text-white font-medium`,children:f(`login.howToReset`)}),(0,u.jsxs)(`ol`,{className:`text-sm text-bambu-gray space-y-1 list-decimal list-inside`,children:[(0,u.jsx)(`li`,{children:f(`login.resetStep1`)}),(0,u.jsx)(`li`,{children:f(`login.resetStep2`)}),(0,u.jsx)(`li`,{children:f(`login.resetStep3`)}),(0,u.jsx)(`li`,{children:f(`login.resetStep4`)})]})]}),(0,u.jsx)(c,{variant:`secondary`,className:`w-full`,onClick:()=>C(!1),children:f(`login.gotIt`)})]})})]})})]})}export{g as LoginPage};