@clerk/clerk-js
Version:
Clerk JS library
1 lines • 59.8 kB
JavaScript
"use strict";(globalThis.webpackChunk_clerk_clerk_js=globalThis.webpackChunk_clerk_clerk_js||[]).push([["722"],{7389:function(e,t,r){r.d(t,{v:()=>s});var o=r(9109),n=r(4562),i=r(4204);let s=e=>{let{onBackLinkClick:t}=e;return(0,o.tZ)(n._,{cardTitle:(0,i.localizationKeys)("signIn.alternativeMethods.getHelp.title"),cardSubtitle:(0,i.localizationKeys)("signIn.alternativeMethods.getHelp.content"),onBackLinkClick:t})}},6154:function(e,t,r){r.r(t),r.d(t,{SignIn:()=>ej,SignInModal:()=>eY});var o=r(9109),n=r(3799),i=r(9144),s=r(5112),a=r(1576),l=r(4204),c=r(2464),d=r(4511),u=r(7508),p=r(4676),h=r(2073);let m=()=>Promise.all([r.e("200"),r.e("573"),r.e("710")]).then(r.bind(r,5049)),f=(0,i.lazy)(()=>m().then(e=>({default:e.SignUpVerifyPhone}))),g=(0,i.lazy)(()=>m().then(e=>({default:e.SignUpVerifyEmail}))),I=(0,i.lazy)(()=>m().then(e=>({default:e.SignUpStart}))),S=(0,i.lazy)(()=>m().then(e=>({default:e.SignUpSSOCallback}))),v=(0,i.lazy)(()=>m().then(e=>({default:e.SignUpContinue})));var C=r(2418),y=r(2672),_=r(431),b=r(2654),B=r(8870),w=r(6842),Z=r(6788),A=r(4152),k=r(3234);let P=(0,y.withCardStateProvider)(()=>{let e=(0,a.useCoreSignIn)(),t=(0,y.useCardState)(),{navigate:r}=(0,p.useRouter)(),n=(0,k.H)(),{userSettings:{passwordSettings:s}}=(0,a.useEnvironment)(),{t:d,locale:u}=(0,l.useLocalizations)(),h="needs_new_password"===e.status&&"reset_password_email_code"!==e.firstFactorVerification.strategy&&"reset_password_phone_code"!==e.firstFactorVerification.strategy;i.useEffect(()=>{h&&t.setError(d((0,l.localizationKeys)("signIn.resetPassword.requiredMessage")))},[]);let m=(0,Z.Yp)("password","",{type:"password",label:(0,l.localizationKeys)("formFieldLabel__newPassword"),isRequired:!0,validatePassword:!0,buildErrorMessage:e=>(0,w.GM)(e,{t:d,locale:u,passwordSettings:s})}),f=(0,Z.Yp)("confirmPassword","",{type:"password",label:(0,l.localizationKeys)("formFieldLabel__confirmPassword"),isRequired:!0}),g=(0,Z.Yp)("signOutOfOtherSessions","",{type:"checkbox",label:(0,l.localizationKeys)("formFieldLabel__signOutOfOtherSessions"),defaultChecked:!0}),{setConfirmPasswordFeedback:I,isPasswordMatch:S}=(0,c.p5)({passwordField:m,confirmPasswordField:f}),v=async()=>{m.clearFeedback(),f.clearFeedback();try{let{status:t,createdSessionId:o}=await e.resetPassword({password:m.value,signOutOfOtherSessions:g.checked});switch(t){case"complete":if(o){let e=new URLSearchParams;return e.set("createdSessionId",o),r(`../reset-password-success?${e.toString()}`)}return console.error((0,A.Ws)(t,n));case"needs_second_factor":return r("../factor-two");default:return console.error((0,A.Ws)(t,n))}}catch(e){return(0,B.S3)(e,[m,f],t.setError)}};return(0,o.BX)(C.Z.Root,{children:[(0,o.BX)(C.Z.Content,{children:[(0,o.tZ)(b.h.Root,{showLogo:!0,children:(0,o.tZ)(b.h.Title,{localizationKey:(0,l.localizationKeys)("signIn.resetPassword.title")})}),(0,o.tZ)(C.Z.Alert,{children:t.error}),(0,o.tZ)(l.Col,{elementDescriptor:l.descriptors.main,gap:8,children:(0,o.BX)(_.l.Root,{onSubmit:v,onBlur:()=>{m.value&&I(f.value)},gap:8,children:[(0,o.BX)(l.Col,{gap:6,children:[(0,o.tZ)("input",{readOnly:!0,"data-testid":"hidden-identifier",id:"identifier-field",name:"identifier",value:e.identifier||"",style:{display:"none"}}),(0,o.tZ)(_.l.ControlRow,{elementId:m.id,children:(0,o.tZ)(_.l.PasswordInput,{...m.props,isRequired:!0,autoFocus:!0})}),(0,o.tZ)(_.l.ControlRow,{elementId:f.id,children:(0,o.tZ)(_.l.PasswordInput,{...f.props,onChange:e=>(e.target.value&&I(e.target.value),f.props.onChange(e))})}),!h&&(0,o.tZ)(_.l.ControlRow,{elementId:g.id,children:(0,o.tZ)(_.l.Checkbox,{...g.props})})]}),(0,o.BX)(l.Col,{gap:3,children:[(0,o.tZ)(_.l.SubmitButton,{isDisabled:!S,localizationKey:(0,l.localizationKeys)("signIn.resetPassword.formButtonPrimary")}),(0,o.tZ)(C.Z.Action,{elementId:"alternativeMethods",children:(0,o.tZ)(C.Z.ActionLink,{elementDescriptor:l.descriptors.backLink,localizationKey:(0,l.localizationKeys)("backButton"),onClick:()=>r("../")})})]})]})})]}),(0,o.tZ)(C.Z.Footer,{})]})});var U=r(4875),E=r(215);let z=(0,y.withCardStateProvider)(()=>{let e=(0,y.useCardState)();return(0,U.E)(),(0,o.BX)(C.Z.Root,{children:[(0,o.BX)(C.Z.Content,{children:[(0,o.tZ)(b.h.Root,{showLogo:!0,children:(0,o.tZ)(b.h.Title,{localizationKey:(0,l.localizationKeys)("signIn.resetPassword.title")})}),(0,o.tZ)(C.Z.Alert,{children:e.error}),(0,o.BX)(l.Col,{elementDescriptor:l.descriptors.main,gap:8,children:[(0,o.tZ)(l.Text,{localizationKey:(0,l.localizationKeys)("signIn.resetPassword.successMessage")}),(0,o.tZ)(E.kC,{direction:"row",center:!0,children:(0,o.tZ)(l.Spinner,{size:"xl",colorScheme:"primary",elementDescriptor:l.descriptors.spinner})})]})]}),(0,o.tZ)(C.Z.Footer,{})]})});var F=r(2305),R=r(8774),L=r(7295),K=r(8969),T=r(4174),x=r(9327),M=r(5241);let O=(0,K.Hy)((0,y.withCardStateProvider)(()=>{let e=(0,y.useCardState)(),{userProfileUrl:t}=(0,a.useEnvironment)().displayConfig,{afterSignInUrl:r,path:n}=(0,a.useSignInContext)(),{navigateAfterSignOut:i}=(0,a.useSignOutContext)(),{handleSignOutAllClicked:s,handleSessionClicked:c,signedInSessions:d,handleAddAccountClicked:u}=(0,M.Z)({navigateAfterSignOut:i,afterSwitchSessionUrl:r,userProfileUrl:t,signInUrl:n,user:void 0});return(0,o.tZ)(l.Flow.Part,{part:"accountSwitcher",children:(0,o.BX)(C.Z.Root,{children:[(0,o.BX)(C.Z.Content,{sx:e=>({padding:`${e.space.$8} ${e.space.$none} ${e.space.$none}`}),children:[(0,o.BX)(b.h.Root,{children:[(0,o.tZ)(b.h.Title,{localizationKey:(0,l.localizationKeys)("signIn.accountSwitcher.title")}),(0,o.tZ)(b.h.Subtitle,{localizationKey:(0,l.localizationKeys)("signIn.accountSwitcher.subtitle")})]}),(0,o.tZ)(C.Z.Alert,{children:e.error}),(0,o.tZ)(l.Col,{elementDescriptor:l.descriptors.main,gap:8,sx:e=>({borderTopWidth:e.borderWidths.$normal,borderTopStyle:e.borderStyles.$solid,borderTopColor:e.colors.$borderAlpha100}),children:(0,o.BX)(F.eX,{role:"menu",children:[d.map(e=>(0,o.tZ)(R.K,{onClick:c(e),sx:e=>({height:e.sizes.$16,justifyContent:"flex-start",borderRadius:0}),icon:T.nR,children:(0,o.tZ)(L.E,{user:e.user,sx:{width:"100%"}})},e.id)),(0,o.tZ)(F.aU,{elementDescriptor:l.descriptors.accountSwitcherActionButton,elementId:l.descriptors.accountSwitcherActionButton.setId("addAccount"),iconBoxElementDescriptor:l.descriptors.accountSwitcherActionButtonIconBox,iconBoxElementId:l.descriptors.accountSwitcherActionButtonIconBox.setId("addAccount"),iconElementDescriptor:l.descriptors.accountSwitcherActionButtonIcon,iconElementId:l.descriptors.accountSwitcherActionButtonIcon.setId("addAccount"),icon:T.mm,label:(0,l.localizationKeys)("signIn.accountSwitcher.action__addAccount"),onClick:u,iconSx:e=>({width:e.sizes.$9,height:e.sizes.$6}),iconBoxSx:e=>({minHeight:e.sizes.$9,minWidth:e.sizes.$6,alignItems:"center"}),spinnerSize:"md"})]})})]}),(0,o.tZ)(C.Z.Footer,{sx:e=>({">:first-of-type":{padding:`${e.space.$1}`,width:"100%"}}),children:(0,o.tZ)(C.Z.Action,{sx:{width:"100%",">:first-of-type":{width:"100%",borderBottomWidth:0}},children:(0,o.tZ)(x.gW,{handleSignOutAllClicked:s,elementDescriptor:l.descriptors.accountSwitcherActionButton,elementId:l.descriptors.accountSwitcherActionButton.setId("signOutAll"),iconBoxElementDescriptor:l.descriptors.accountSwitcherActionButtonIconBox,iconBoxElementId:l.descriptors.accountSwitcherActionButtonIconBox.setId("signOutAll"),iconElementDescriptor:l.descriptors.accountSwitcherActionButtonIcon,iconElementId:l.descriptors.accountSwitcherActionButtonIcon.setId("signOutAll"),label:(0,l.localizationKeys)("signIn.accountSwitcher.action__signOutAll"),actionSx:e=>({padding:`${e.space.$2} ${e.space.$2}`})})})})]})})}));var D=r(4562),$=r(1455),X=r(1752),N=r(7703),W=r(8246),V=r(5482),H=r(6735),G=r(4271),j=r(6565),Y=r(9955),q=r(6749),Q=r(5747),J=r(138);let ee=i.memo(e=>{let t=(0,n.cL)(),{navigate:r}=(0,p.useRouter)(),i=(0,y.useCardState)(),{displayConfig:s}=(0,Q.O)(),l=(0,a.useSignInContext)(),c=(0,a.useCoreSignIn)(),d=(0,q.wT)(l,s.signInUrl),u=l.afterSignInUrl||"/",h="popup"===l.oauthFlow||"auto"===l.oauthFlow&&(0,j.t)(),{onAlternativePhoneCodeProviderClick:m,...f}=e;return(0,o.tZ)(J.L,{...f,idleAfterDelay:!h,oauthCallback:e=>{if(h){let t=window.open("about:blank","","width=600,height=800"),r=setInterval(()=>{(!t||t.closed)&&(clearInterval(r),i.setIdle())},500);return c.authenticateWithPopup({strategy:e,redirectUrl:d,redirectUrlComplete:u,popup:t,oidcPrompt:l.oidcPrompt}).catch(e=>(0,B.S3)(e,[],i.setError))}return c.authenticateWithRedirect({strategy:e,redirectUrl:d,redirectUrlComplete:u,oidcPrompt:l.oidcPrompt}).catch(e=>(0,B.S3)(e,[],i.setError))},web3Callback:e=>t.authenticateWithWeb3({customNavigate:r,redirectUrl:u,signUpContinueUrl:l.isCombinedFlow?"create/continue":l.signUpContinueUrl,strategy:e,secondFactorUrl:"factor-two"}).catch(e=>(0,Y.H)(e,i.setError)),alternativePhoneCodeCallback:e=>{m?.(e)}})});var et=r(5518);function er(){let e=(0,a.useCoreSignIn)();return e.supportedFirstFactors?.find(({strategy:e})=>(0,et.Vh)(e))}var eo=r(7389);let en=e=>((e,t)=>{let[r,n]=i.useState(!1),s=i.useCallback(()=>n(e=>!e),[n]);return r?(0,o.tZ)(eo.v,{onBackLinkClick:s}):(0,o.tZ)(e,{...t,onHavingTroubleClick:s})})(ei,{...e}),ei=e=>{let{onBackLinkClick:t,onHavingTroubleClick:r,onFactorSelected:n,mode:i="default"}=e,s=(0,y.useCardState)(),c=er(),{supportedFirstFactors:d}=(0,a.useCoreSignIn)(),{firstPartyFactors:u,hasAnyStrategy:p}=(0,X.l)({filterOutFactor:e?.currentFactor,supportedFirstFactors:d}),h=function(e){switch(e){case"forgot":return"forgotPasswordMethods";case"pwned":return"passwordPwnedMethods";default:return"alternativeMethods"}}(i),m=function(e){switch(e){case"forgot":return(0,l.localizationKeys)("signIn.forgotPasswordAlternativeMethods.title");case"pwned":return(0,l.localizationKeys)("signIn.passwordPwned.title");default:return(0,l.localizationKeys)("signIn.alternativeMethods.title")}}(i),f=function(e){switch(e){case"forgot":case"pwned":return!0;default:return!1}}(i);return(0,o.tZ)(l.Flow.Part,{part:h,children:(0,o.BX)(C.Z.Root,{children:[(0,o.BX)(C.Z.Content,{children:[(0,o.BX)(b.h.Root,{showLogo:!0,children:[(0,o.tZ)(b.h.Title,{localizationKey:m}),!f&&(0,o.tZ)(b.h.Subtitle,{localizationKey:(0,l.localizationKeys)("signIn.alternativeMethods.subtitle")})]}),(0,o.tZ)(C.Z.Alert,{children:s.error}),(0,o.BX)(l.Flex,{direction:"col",elementDescriptor:l.descriptors.main,gap:6,children:[f&&c&&(0,o.tZ)(l.Button,{localizationKey:es(c),elementDescriptor:l.descriptors.alternativeMethodsBlockButton,isDisabled:s.isLoading,onClick:()=>{s.setError(void 0),n(c)}}),f&&p&&(0,o.tZ)(H.i,{dividerText:(0,l.localizationKeys)("signIn.forgotPasswordAlternativeMethods.label__alternativeMethods")}),(0,o.BX)(l.Col,{gap:4,children:[p&&(0,o.BX)(l.Flex,{elementDescriptor:l.descriptors.alternativeMethods,direction:"col",gap:2,children:[(0,o.tZ)(ee,{enableWeb3Providers:!0,enableOAuthProviders:!0,enableAlternativePhoneCodeProviders:!1}),u&&u.map((e,t)=>{var r;return(0,o.tZ)(W.$,{leftIcon:(r=e,({email_link:T.xP,email_code:T.GT,phone_code:T.iU,reset_password_email_code:T.ds,reset_password_phone_code:T.ds,password:T.kh,passkey:T.IG})[r.strategy]),textLocalizationKey:es(e),elementDescriptor:l.descriptors.alternativeMethodsBlockButton,textElementDescriptor:l.descriptors.alternativeMethodsBlockButtonText,arrowElementDescriptor:l.descriptors.alternativeMethodsBlockButtonArrow,textVariant:"buttonLarge",isDisabled:s.isLoading,onClick:()=>{s.setError(void 0),n(e)}},t)})]}),t&&(0,o.tZ)(V.h,{boxElementDescriptor:l.descriptors.backRow,linkElementDescriptor:l.descriptors.backLink,onClick:t})]})]})]}),(0,o.tZ)(C.Z.Footer,{children:(0,o.BX)(C.Z.Action,{elementId:"havingTrouble",children:[(0,o.tZ)(C.Z.ActionText,{localizationKey:(0,l.localizationKeys)("signIn.alternativeMethods.actionText")}),(0,o.tZ)(C.Z.ActionLink,{localizationKey:(0,l.localizationKeys)("signIn.alternativeMethods.actionLink"),onClick:r})]})})]})})};function es(e){switch(e.strategy){case"email_link":return(0,l.localizationKeys)("signIn.alternativeMethods.blockButton__emailLink",{identifier:(0,G.H)(e.safeIdentifier)||""});case"email_code":return(0,l.localizationKeys)("signIn.alternativeMethods.blockButton__emailCode",{identifier:(0,G.H)(e.safeIdentifier)||""});case"phone_code":return(0,l.localizationKeys)("signIn.alternativeMethods.blockButton__phoneCode",{identifier:(0,G.H)(e.safeIdentifier)||""});case"password":return(0,l.localizationKeys)("signIn.alternativeMethods.blockButton__password");case"passkey":return(0,l.localizationKeys)("signIn.alternativeMethods.blockButton__passkey");case"reset_password_email_code":case"reset_password_phone_code":return(0,l.localizationKeys)("signIn.forgotPasswordAlternativeMethods.blockButton__resetPassword");default:throw Error(`Invalid sign in strategy: "${e.strategy}"`)}}var ea=r(6543),el=r(3531),ec=r(3465);let ed=e=>{let t=(0,a.useCoreSignIn)(),r=(0,y.useCardState)(),{navigate:i}=(0,p.useRouter)(),{afterSignInUrl:s}=(0,a.useSignInContext)(),{setActive:l}=(0,n.cL)(),c=(0,k.H)(),d=(0,n.cL)(),u=e.factor.channel,h="verified"===t.firstFactorVerification.status&&e.factorAlreadyPrepared;return(0,o.tZ)(ec.U,{cardTitle:e.cardTitle,cardSubtitle:e.cardSubtitle,inputLabel:e.inputLabel,resendButton:e.resendButton,onCodeEntryFinishedAction:(r,o,n)=>{t.attemptFirstFactor({strategy:e.factor.strategy,code:r}).then(async e=>{switch(await o(),e.status){case"complete":return l({session:e.createdSessionId,redirectUrl:s});case"needs_second_factor":return i("../factor-two");case"needs_new_password":return i("../reset-password");default:return console.error((0,A.Ws)(e.status,c))}}).catch(e=>(0,el.ay)(e)?d.__internal_navigateWithError("..",e.errors[0]):n(e))},onResendCodeClicked:()=>{h||t.prepareFirstFactor({...e.factor,channel:u}).then(()=>e.onFactorPrepare()).catch(e=>(0,B.S3)(e,[],r.setError))},safeIdentifier:e.factor.safeIdentifier,profileImageUrl:t.userData.imageUrl,alternativeMethodsLabel:(0,N.u1)("footerActionLink__alternativePhoneCodeProvider"),onShowAlternativeMethodsClicked:()=>{r.setError(void 0),e.onChangePhoneCodeChannel({...e.factor,channel:void 0})},showAlternativeMethods:!0,onIdentityPreviewEditClicked:()=>i("../"),onBackLinkClicked:e.onBackLinkClicked})},eu=e=>(0,o.tZ)(l.Flow.Part,{part:"phoneCode",children:(0,o.tZ)(ed,{...e,cardTitle:(0,l.localizationKeys)("signIn.alternativePhoneCodeProvider.title",{provider:(0,ea.H)(e.factor.channel)?.name||""}),cardSubtitle:(0,l.localizationKeys)("signIn.alternativePhoneCodeProvider.subtitle"),inputLabel:(0,l.localizationKeys)("signIn.alternativePhoneCodeProvider.formTitle"),resendButton:(0,l.localizationKeys)("signIn.alternativePhoneCodeProvider.resendButton")})}),ep=e=>{let t=(0,a.useCoreSignIn)(),r=(0,y.useCardState)(),{navigate:s}=(0,p.useRouter)(),{afterSignInUrl:l}=(0,a.useSignInContext)(),{setActive:d}=(0,n.cL)(),u=(0,k.H)(),h=(0,n.cL)(),m="verified"===t.firstFactorVerification.status&&e.factorAlreadyPrepared,f=(0,i.useMemo)(()=>{let t=e.factor,r=t.strategy;return"emailAddressId"in t&&(r+=`_${t.emailAddressId}`),"phoneNumberId"in t&&(r+=`_${t.phoneNumberId}`),"channel"in t&&t.channel&&(r+=`_${t.channel}`),{name:"signIn.prepareFirstFactor",factorKey:r}},[e.factor.strategy,"emailAddressId"in e.factor?e.factor.emailAddressId:void 0,"phoneNumberId"in e.factor?e.factor.phoneNumberId:void 0,"channel"in e.factor?e.factor.channel:void 0]);return(0,c.ib)(m?void 0:()=>t?.prepareFirstFactor(e.factor).then(()=>e.onFactorPrepare()).catch(e=>(0,B.S3)(e,[],r.setError)),f,{staleTime:100}),(0,o.tZ)(ec.U,{cardTitle:e.cardTitle,cardSubtitle:e.cardSubtitle,inputLabel:e.inputLabel,resendButton:e.resendButton,onCodeEntryFinishedAction:(r,o,n)=>{t.attemptFirstFactor({strategy:e.factor.strategy,code:r}).then(async e=>{switch(await o(),e.status){case"complete":return d({session:e.createdSessionId,redirectUrl:l});case"needs_second_factor":return s("../factor-two");case"needs_new_password":return s("../reset-password");default:return console.error((0,A.Ws)(e.status,u))}}).catch(e=>(0,el.ay)(e)?h.__internal_navigateWithError("..",e.errors[0]):n(e))},onResendCodeClicked:()=>{m||t.prepareFirstFactor(e.factor).then(()=>e.onFactorPrepare()).catch(e=>(0,B.S3)(e,[],r.setError))},safeIdentifier:e.factor.safeIdentifier,profileImageUrl:t.userData.imageUrl,onShowAlternativeMethodsClicked:e.onShowAlternativeMethodsClicked,showAlternativeMethods:e.showAlternativeMethods,onIdentityPreviewEditClicked:()=>s("../"),onBackLinkClicked:e.onBackLinkClicked})},eh=e=>(0,o.tZ)(l.Flow.Part,{part:"emailCode",children:(0,o.tZ)(ep,{...e,cardTitle:(0,l.localizationKeys)("signIn.emailCode.title"),cardSubtitle:(0,l.localizationKeys)("signIn.emailCode.subtitle"),inputLabel:(0,l.localizationKeys)("signIn.emailCode.formTitle"),resendButton:(0,l.localizationKeys)("signIn.emailCode.resendButton")})});var em=r(5495),ef=r(4814),eg=r(5117);let eI=e=>{let{t}=(0,l.useLocalizations)(),r=(0,y.useCardState)(),s=(0,a.useCoreSignIn)(),c=(0,a.useSignInContext)(),{signInUrl:d}=c,{navigate:u}=(0,eg.t)(),{afterSignInUrl:p}=(0,a.useSignInContext)(),{setActive:h}=(0,n.cL)(),{startEmailLinkFlow:m,cancelEmailLinkFlow:f}=(0,ef.E)(s),[g,I]=i.useState(!1),S=(0,n.cL)();i.useEffect(()=>{v()},[]);let v=()=>{m({emailAddressId:e.factor.emailAddressId,redirectUrl:(0,q.Uu)({ctx:c,baseUrl:d,intent:"sign-in"})}).then(e=>C(e)).catch(e=>{if((0,el.ay)(e))return S.__internal_navigateWithError("..",e.errors[0]);(0,B.S3)(e,[],r.setError)})},C=async e=>{let o=e.firstFactorVerification;"expired"===o.status?r.setError(t((0,l.localizationKeys)("formFieldError__verificationLinkExpired"))):o.verifiedFromTheSameClient()?I(!0):await _(e)},_=async e=>"complete"===e.status?h({session:e.createdSessionId,redirectUrl:p}):"needs_second_factor"===e.status?u("../factor-two"):void 0;return g?(0,o.tZ)(K.Ej,{title:(0,l.localizationKeys)("signIn.emailLink.verifiedSwitchTab.titleNewTab"),subtitle:(0,l.localizationKeys)("signIn.emailLink.verifiedSwitchTab.subtitleNewTab"),status:"verified_switch_tab"}):(0,o.tZ)(l.Flow.Part,{part:"emailLink",children:(0,o.tZ)(em.J,{cardTitle:(0,l.localizationKeys)("signIn.emailLink.title"),cardSubtitle:(0,l.localizationKeys)("signIn.emailLink.subtitle"),formTitle:(0,l.localizationKeys)("signIn.emailLink.formTitle"),formSubtitle:(0,l.localizationKeys)("signIn.emailLink.formSubtitle"),resendButton:(0,l.localizationKeys)("signIn.emailLink.resendButton"),onResendCodeClicked:()=>{f(),v()},safeIdentifier:e.factor.safeIdentifier,profileImageUrl:s.userData.imageUrl,onShowAlternativeMethodsClicked:e.onShowAlternativeMethodsClicked})})},eS=e=>(0,o.tZ)(l.Flow.Part,{part:"resetPassword",children:(0,o.tZ)(ep,{...e,showAlternativeMethods:!1,cardTitle:(0,l.localizationKeys)("signIn.forgotPassword.title"),inputLabel:(0,l.localizationKeys)("signIn.forgotPassword.formTitle"),resendButton:(0,l.localizationKeys)("signIn.forgotPassword.resendButton")})});var ev=r(9577),eC=r(3367);function ey(e){let t=(0,y.useCardState)(),{setActive:r,__internal_navigateWithError:o}=(0,n.cL)(),s=(0,k.H)(),{afterSignInUrl:l}=(0,a.useSignInContext)(),{authenticateWithPasskey:c}=(0,a.useCoreSignIn)();return(0,i.useEffect)(()=>()=>{eC.YI.abort()},[]),(0,i.useCallback)(async(...n)=>{try{let t=await c(...n);switch(t.status){case"complete":return r({session:t.createdSessionId,redirectUrl:l});case"needs_second_factor":return e();default:return console.error((0,A.Ws)(t.status,s))}}catch(r){let{flow:e}=n[0]||{};if((0,el.uX)(r)&&("passkey_operation_aborted"===r.code||"autofill"===e&&"passkey_retrieval_cancelled"===r.code))return;if((0,el.ay)(r))return o("..",r.errors[0]);(0,B.S3)(r,[],t.setError)}},[])}let e_=e=>{let{onShowAlternativeMethodsClick:t}=e,r=(0,y.useCardState)(),n=(0,a.useCoreSignIn)(),{navigate:s}=(0,eg.t)(),[c,d]=i.useState(!1),u=i.useCallback(()=>d(e=>!e),[d]),p=ey(()=>s("../factor-two"));return c?(0,o.tZ)(eo.v,{onBackLinkClick:u}):(0,o.tZ)(l.Flow.Part,{part:"password",children:(0,o.BX)(C.Z.Root,{children:[(0,o.BX)(C.Z.Content,{children:[(0,o.BX)(b.h.Root,{showLogo:!0,children:[(0,o.tZ)(l.Icon,{elementDescriptor:l.descriptors.passkeyIcon,icon:T.IG,sx:e=>({color:e.colors.$neutralAlpha500,marginInline:"auto",paddingBottom:e.sizes.$1,width:e.sizes.$12,height:e.sizes.$12})}),(0,o.tZ)(b.h.Title,{localizationKey:(0,l.localizationKeys)("signIn.passkey.title")}),(0,o.tZ)(b.h.Subtitle,{localizationKey:(0,l.localizationKeys)("signIn.passkey.subtitle")}),(0,o.tZ)(ev.m,{identifier:n.identifier,avatarUrl:n.userData.imageUrl,onClick:()=>s("../")})]}),(0,o.tZ)(C.Z.Alert,{children:r.error}),(0,o.BX)(l.Flex,{direction:"col",elementDescriptor:l.descriptors.main,gap:4,children:[(0,o.tZ)(_.l.Root,{onSubmit:e=>(e.preventDefault(),p()),gap:8,children:(0,o.tZ)(_.l.SubmitButton,{hasArrow:!0})}),(0,o.tZ)(C.Z.Action,{elementId:t?"alternativeMethods":"havingTrouble",children:(0,o.tZ)(C.Z.ActionLink,{localizationKey:(0,l.localizationKeys)(t?"footerActionLink__useAnotherMethod":"signIn.alternativeMethods.actionLink"),onClick:t||u})})]})]}),(0,o.tZ)(C.Z.Footer,{})]})})},eb=e=>{let{onShowAlternativeMethodsClick:t,onPasswordPwned:r}=e,s=i.useRef(null),c=(0,y.useCardState)(),{setActive:d}=(0,n.cL)(),u=(0,a.useCoreSignIn)(),{afterSignInUrl:p}=(0,a.useSignInContext)(),h=(0,k.H)(),m=(e=>{let{onForgotPasswordMethodClick:t,onShowAlternativeMethodsClick:r}=e,o=er(),n=(0,Z.Yp)("password","",{type:"password",label:(0,l.localizationKeys)("formFieldLabel__password"),placeholder:(0,l.localizationKeys)("formFieldInputPlaceholder__password")});return{...n,props:{...n.props,actionLabel:o||r?(0,l.localizationKeys)("formFieldAction__forgotPassword"):"",onActionClicked:t||r||(()=>null)}}})(e),{navigate:f}=(0,eg.t)(),[g,I]=i.useState(!1),S=i.useCallback(()=>I(e=>!e),[I]),v=(0,n.cL)(),w=async e=>(e.preventDefault(),u.attemptFirstFactor({strategy:"password",password:m.value}).then(e=>{switch(e.status){case"complete":return d({session:e.createdSessionId,redirectUrl:p});case"needs_second_factor":return f("../factor-two");default:return console.error((0,A.Ws)(e.status,h))}}).catch(e=>{if((0,el.ay)(e))return v.__internal_navigateWithError("..",e.errors[0]);if((0,el.UZ)(e)&&r){c.setError({...e.errors[0],code:"form_password_pwned__sign_in"}),r();return}(0,B.S3)(e,[m],c.setError),setTimeout(()=>s.current?.focus(),0)}));return g?(0,o.tZ)(eo.v,{onBackLinkClick:S}):(0,o.tZ)(l.Flow.Part,{part:"password",children:(0,o.BX)(C.Z.Root,{children:[(0,o.BX)(C.Z.Content,{children:[(0,o.BX)(b.h.Root,{showLogo:!0,children:[(0,o.tZ)(b.h.Title,{localizationKey:(0,l.localizationKeys)("signIn.password.title")}),(0,o.tZ)(b.h.Subtitle,{localizationKey:(0,l.localizationKeys)("signIn.password.subtitle")}),(0,o.tZ)(ev.m,{identifier:u.identifier,avatarUrl:u.userData.imageUrl,onClick:()=>f("../")})]}),(0,o.tZ)(C.Z.Alert,{children:c.error}),(0,o.BX)(l.Flex,{direction:"col",elementDescriptor:l.descriptors.main,gap:4,children:[(0,o.BX)(_.l.Root,{onSubmit:w,gap:8,children:[(0,o.tZ)("input",{readOnly:!0,id:"identifier-field",name:"identifier",value:u.identifier||"",style:{display:"none"}}),(0,o.tZ)(_.l.ControlRow,{elementId:m.id,children:(0,o.tZ)(_.l.PasswordInput,{...m.props,ref:s,autoFocus:!0})}),(0,o.tZ)(_.l.SubmitButton,{hasArrow:!0})]}),(0,o.tZ)(C.Z.Action,{elementId:t?"alternativeMethods":"havingTrouble",children:(0,o.tZ)(C.Z.ActionLink,{localizationKey:(0,l.localizationKeys)(t?"signIn.password.actionLink":"signIn.alternativeMethods.actionLink"),onClick:t||S})})]})]}),(0,o.tZ)(C.Z.Footer,{})]})})},eB=e=>(0,o.tZ)(l.Flow.Part,{part:"phoneCode",children:(0,o.tZ)(ep,{...e,cardTitle:(0,l.localizationKeys)("signIn.phoneCode.title"),cardSubtitle:(0,l.localizationKeys)("signIn.phoneCode.subtitle"),inputLabel:(0,l.localizationKeys)("signIn.phoneCode.formTitle"),resendButton:(0,l.localizationKeys)("signIn.phoneCode.resendButton")})}),ew=e=>{if(!e)return"";let t=e.strategy;return"emailAddressId"in e&&(t+=e.emailAddressId),"phoneNumberId"in e&&(t+=e.phoneNumberId),"channel"in e&&(t+=e.channel),t},eZ=(0,K.Hy)((0,y.withCardStateProvider)(function(){let e=(0,a.useCoreSignIn)(),{preferredSignInStrategy:t}=(0,a.useEnvironment)().displayConfig,r=e.supportedFirstFactors,n=(0,p.useRouter)(),s=(0,y.useCardState)(),{supportedFirstFactors:l,firstFactorVerification:c}=(0,a.useCoreSignIn)(),d=i.useRef(""),[{currentFactor:u},h]=i.useState(()=>{let o=(0,et.t3)(r,e.identifier,t);return o?.strategy==="phone_code"&&c.channel&&"sms"!==c.channel&&(o.channel=c.channel),{currentFactor:o,prevCurrentFactor:void 0}}),{hasAnyStrategy:m}=(0,X.l)({filterOutFactor:u,supportedFirstFactors:l}),[f,g]=i.useState(()=>!u||!(0,et.xT)(u)),I=er(),[S,v]=i.useState(!1),[C,_]=i.useState(!1);if(i.useEffect(()=>{("needs_identifier"===e.status||null===e.status)&&n.navigate("../")},[]),!u&&e.status)return(0,o.tZ)(D._,{cardTitle:(0,N.u1)("signIn.noAvailableMethods.title"),cardSubtitle:(0,N.u1)("signIn.noAvailableMethods.subtitle"),message:(0,N.u1)("signIn.noAvailableMethods.message")});let b=m?()=>g(e=>!e):void 0,B=()=>v(e=>!e),w=()=>{d.current=ew(u)},Z=e=>{h(t=>({currentFactor:e,prevCurrentFactor:t.currentFactor}))};if(f||S){let e=(0,et.xT)(u),t=f?b:B;return(0,o.tZ)(en,{mode:S?C?"pwned":"forgot":"default",onBackLinkClick:e?()=>{s.setError(void 0),_(!1),t?.()}:void 0,onFactorSelected:e=>{Z(e),t?.()},currentFactor:u})}if(!u)return(0,o.tZ)($.W,{});switch(u?.strategy){case"passkey":return(0,o.tZ)(e_,{onFactorPrepare:w,onShowAlternativeMethodsClick:b});case"password":return(0,o.tZ)(eb,{onForgotPasswordMethodClick:I?B:b,onShowAlternativeMethodsClick:b,onPasswordPwned:()=>{_(!0),B()}});case"email_code":return(0,o.tZ)(eh,{factorAlreadyPrepared:d.current===ew(u),onFactorPrepare:w,factor:u,onShowAlternativeMethodsClicked:b});case"phone_code":if(u.channel&&"sms"!==u.channel)return(0,o.tZ)(eu,{factorAlreadyPrepared:d.current===ew(u),onFactorPrepare:w,factor:u,onChangePhoneCodeChannel:Z});return(0,o.tZ)(eB,{factorAlreadyPrepared:d.current===ew(u),onFactorPrepare:w,factor:u,onShowAlternativeMethodsClicked:b});case"email_link":return(0,o.tZ)(eI,{factorAlreadyPrepared:d.current===ew(u),onFactorPrepare:w,factor:u,onShowAlternativeMethodsClicked:b});case"reset_password_phone_code":return(0,o.tZ)(eS,{factorAlreadyPrepared:d.current===ew(u),onFactorPrepare:w,factor:u,onShowAlternativeMethodsClicked:b,onBackLinkClicked:()=>{h(e=>({currentFactor:e.prevCurrentFactor,prevCurrentFactor:e.currentFactor})),B()},cardSubtitle:(0,N.u1)("signIn.forgotPassword.subtitle_phone")});case"reset_password_email_code":return(0,o.tZ)(eS,{factorAlreadyPrepared:d.current===ew(u),onFactorPrepare:w,factor:u,onShowAlternativeMethodsClicked:b,onBackLinkClicked:()=>{h(e=>({currentFactor:e.prevCurrentFactor,prevCurrentFactor:e.currentFactor})),B()},cardSubtitle:(0,N.u1)("signIn.forgotPassword.subtitle_email")});default:return(0,o.tZ)($.W,{})}}));var eA=r(577);let ek=e=>{let[t,r]=i.useState(!1),n=i.useCallback(()=>r(e=>!e),[r]);return t?(0,o.tZ)(eo.v,{onBackLinkClick:n}):(0,o.tZ)(eP,{onBackLinkClick:e.onBackLinkClick,onFactorSelected:e.onFactorSelected,onHavingTroubleClick:n})},eP=e=>{let{onHavingTroubleClick:t,onFactorSelected:r,onBackLinkClick:n}=e,i=(0,y.useCardState)(),{supportedSecondFactors:s}=(0,a.useCoreSignIn)();return(0,o.tZ)(l.Flow.Part,{part:"alternativeMethods",children:(0,o.BX)(C.Z.Root,{children:[(0,o.BX)(C.Z.Content,{children:[(0,o.BX)(b.h.Root,{showLogo:!0,children:[(0,o.tZ)(b.h.Title,{localizationKey:(0,l.localizationKeys)("signIn.alternativeMethods.title")}),(0,o.tZ)(b.h.Subtitle,{localizationKey:(0,l.localizationKeys)("signIn.alternativeMethods.subtitle")})]}),(0,o.tZ)(C.Z.Alert,{children:i.error}),(0,o.BX)(l.Col,{elementDescriptor:l.descriptors.main,gap:3,children:[(0,o.tZ)(l.Col,{gap:2,children:s&&s.sort(eA.Q0).map((e,t)=>(0,o.tZ)(W.$,{textLocalizationKey:function(e){switch(e.strategy){case"phone_code":return(0,l.localizationKeys)("signIn.alternativeMethods.blockButton__phoneCode",{identifier:(0,G.H)(e.safeIdentifier)||""});case"totp":return(0,l.localizationKeys)("signIn.alternativeMethods.blockButton__totp");case"backup_code":return(0,l.localizationKeys)("signIn.alternativeMethods.blockButton__backupCode");default:throw Error(`Invalid sign in strategy: "${e.strategy}"`)}}(e),elementDescriptor:l.descriptors.alternativeMethodsBlockButton,textElementDescriptor:l.descriptors.alternativeMethodsBlockButtonText,arrowElementDescriptor:l.descriptors.alternativeMethodsBlockButtonArrow,isDisabled:i.isLoading,onClick:()=>r(e)},t))}),(0,o.tZ)(C.Z.Action,{elementId:"alternativeMethods",children:n&&(0,o.tZ)(C.Z.ActionLink,{localizationKey:(0,l.localizationKeys)("backButton"),onClick:e.onBackLinkClick})})]})]}),(0,o.tZ)(C.Z.Footer,{children:(0,o.BX)(C.Z.Action,{elementId:"havingTrouble",children:[(0,o.tZ)(C.Z.ActionText,{localizationKey:(0,l.localizationKeys)("signIn.alternativeMethods.actionText")}),(0,o.tZ)(C.Z.ActionLink,{localizationKey:(0,l.localizationKeys)("signIn.alternativeMethods.actionLink"),onClick:t})]})})]})})},eU=e=>{let{onShowAlternativeMethodsClicked:t}=e,r=(0,a.useCoreSignIn)(),{afterSignInUrl:i}=(0,a.useSignInContext)(),{setActive:s}=(0,n.cL)(),{navigate:c}=(0,p.useRouter)(),d=(0,k.H)(),u=(0,y.useCardState)(),h=(0,Z.Yp)("code","",{type:"text",label:(0,l.localizationKeys)("formFieldLabel__backupCode"),isRequired:!0}),m=(0,n.cL)(),f=e=>(0,et.Vh)(e.firstFactorVerification?.strategy)&&e.firstFactorVerification?.status==="verified";return(0,o.BX)(C.Z.Root,{children:[(0,o.BX)(C.Z.Content,{children:[(0,o.BX)(b.h.Root,{showLogo:!0,children:[(0,o.tZ)(b.h.Title,{localizationKey:(0,l.localizationKeys)("signIn.backupCodeMfa.title")}),(0,o.tZ)(b.h.Subtitle,{localizationKey:f(r)?(0,l.localizationKeys)("signIn.forgotPassword.subtitle"):(0,l.localizationKeys)("signIn.backupCodeMfa.subtitle")})]}),(0,o.tZ)(C.Z.Alert,{children:u.error}),(0,o.tZ)(l.Col,{elementDescriptor:l.descriptors.main,gap:8,children:(0,o.BX)(_.l.Root,{onSubmit:e=>(e.preventDefault(),r.attemptSecondFactor({strategy:"backup_code",code:h.value}).then(e=>{if("complete"!==e.status)return console.error((0,A.Ws)(e.status,d));if(f(e)&&e.createdSessionId){let t=new URLSearchParams;return t.set("createdSessionId",e.createdSessionId),c(`../reset-password-success?${t.toString()}`)}return s({session:e.createdSessionId,redirectUrl:i})}).catch(e=>{if((0,el.ay)(e))return m.__internal_navigateWithError("..",e.errors[0]);(0,B.S3)(e,[h],u.setError)})),children:[(0,o.tZ)(_.l.ControlRow,{elementId:h.id,children:(0,o.tZ)(_.l.PlainInput,{...h.props,autoFocus:!0,onActionClicked:t})}),(0,o.BX)(l.Col,{gap:3,children:[(0,o.tZ)(_.l.SubmitButton,{hasArrow:!0}),(0,o.tZ)(C.Z.Action,{elementId:"alternativeMethods",children:t&&(0,o.tZ)(C.Z.ActionLink,{localizationKey:(0,l.localizationKeys)("footerActionLink__useAnotherMethod"),onClick:t})})]})]})})]}),(0,o.tZ)(C.Z.Footer,{})]})},eE=e=>{let t=(0,a.useCoreSignIn)(),r=(0,y.useCardState)(),{afterSignInUrl:s}=(0,a.useSignInContext)(),{setActive:c}=(0,n.cL)(),{navigate:d}=(0,p.useRouter)(),u=(0,k.H)(),h=(0,n.cL)();i.useEffect(()=>{e.factorAlreadyPrepared||m?.()},[]);let m=e.prepare?()=>e.prepare?.().then(()=>e.onFactorPrepare()).catch(e=>{if((0,el.ay)(e))return h.__internal_navigateWithError("..",e.errors[0]);(0,B.S3)(e,[],r.setError)}):void 0,f=e=>(0,et.Vh)(e.firstFactorVerification?.strategy)&&e.firstFactorVerification?.status==="verified";return(0,o.tZ)(ec.U,{cardTitle:e.cardTitle,cardSubtitle:f(t)?(0,l.localizationKeys)("signIn.forgotPassword.subtitle"):e.cardSubtitle,resendButton:e.resendButton,inputLabel:e.inputLabel,onCodeEntryFinishedAction:(r,o,n)=>{t.attemptSecondFactor({strategy:e.factor.strategy,code:r}).then(async e=>{if(await o(),"complete"!==e.status)return console.error((0,A.Ws)(e.status,u));if(f(e)&&e.createdSessionId){let t=new URLSearchParams;return t.set("createdSessionId",e.createdSessionId),d(`../reset-password-success?${t.toString()}`)}return c({session:e.createdSessionId,redirectUrl:s})}).catch(e=>(0,el.ay)(e)?h.__internal_navigateWithError("..",e.errors[0]):n(e))},onResendCodeClicked:m,safeIdentifier:"safeIdentifier"in e.factor?e.factor.safeIdentifier:void 0,profileImageUrl:t.userData.imageUrl,onShowAlternativeMethodsClicked:e.onShowAlternativeMethodsClicked,children:f(t)&&(0,o.tZ)(l.Text,{localizationKey:(0,l.localizationKeys)("signIn.resetPasswordMfa.detailsLabel"),colorScheme:"secondary"})})},ez=e=>{let t=(0,a.useCoreSignIn)();return(0,o.tZ)(l.Flow.Part,{part:"phoneCode2Fa",children:(0,o.tZ)(eE,{...e,cardTitle:(0,l.localizationKeys)("signIn.phoneCodeMfa.title"),cardSubtitle:(0,l.localizationKeys)("signIn.phoneCodeMfa.subtitle"),inputLabel:(0,l.localizationKeys)("signIn.phoneCodeMfa.formTitle"),resendButton:(0,l.localizationKeys)("signIn.phoneCodeMfa.resendButton"),prepare:()=>{let{phoneNumberId:r,strategy:o}=e.factor;return t.prepareSecondFactor({phoneNumberId:r,strategy:o})}})})},eF=e=>(0,o.tZ)(l.Flow.Part,{part:"totp2Fa",children:(0,o.tZ)(eE,{...e,cardTitle:(0,l.localizationKeys)("signIn.totpMfa.title"),cardSubtitle:(0,l.localizationKeys)("signIn.totpMfa.subtitle"),inputLabel:(0,l.localizationKeys)("signIn.totpMfa.formTitle")})}),eR=e=>{if(!e)return"";let t=e.strategy;return"phoneNumberId"in e&&(t+=e.phoneNumberId),t},eL=(0,K.Hy)((0,y.withCardStateProvider)(function(){let e=(0,a.useCoreSignIn)().supportedSecondFactors,t=i.useRef(""),[r,n]=i.useState(()=>(0,et.bx)(e)),[s,l]=i.useState(!r),c=()=>l(e=>!e),d=()=>{t.current=eR(r)};if(!r)return(0,o.tZ)($.W,{});if(s)return(0,o.tZ)(ek,{onBackLinkClick:c,onFactorSelected:e=>{n(e),c()}});switch(r?.strategy){case"phone_code":return(0,o.tZ)(ez,{factorAlreadyPrepared:t.current===eR(r),onFactorPrepare:d,factor:r,onShowAlternativeMethodsClicked:c});case"totp":return(0,o.tZ)(eF,{factorAlreadyPrepared:t.current===eR(r),onFactorPrepare:d,factor:r,onShowAlternativeMethodsClicked:c});case"backup_code":return(0,o.tZ)(eU,{onShowAlternativeMethodsClicked:c});default:return(0,o.tZ)($.W,{})}})),eK=(0,K.Hy)(K.L);var eT=r(2208),ex=r(8350),eM=r(3621),eO=r(753),eD=r(3344),e$=r(7321);let eX=e=>{let{handleSubmit:t,phoneNumberFormState:r,onUseAnotherMethod:n,phoneCodeProvider:i}=e,{providerToDisplayData:s,strategyToDisplayData:a}=(0,c.vO)(),d=i.name,u=i.channel,p=(0,y.useCardState)();return(0,o.tZ)(C.Z.Root,{children:(0,o.BX)(C.Z.Content,{children:[(0,o.BX)(b.h.Root,{showLogo:!0,showDivider:!0,children:[(0,o.tZ)(l.Col,{center:!0,children:(0,o.tZ)(l.Image,{src:s[u]?.iconUrl,alt:`${a[u].name} logo`,sx:e=>({width:e.sizes.$7,height:e.sizes.$7,maxWidth:"100%",marginBottom:e.sizes.$6})})}),(0,o.tZ)(b.h.Title,{localizationKey:(0,l.localizationKeys)("signIn.start.alternativePhoneCodeProvider.title",{provider:d})}),(0,o.tZ)(b.h.Subtitle,{localizationKey:(0,l.localizationKeys)("signIn.start.alternativePhoneCodeProvider.subtitle",{provider:d})})]}),(0,o.tZ)(C.Z.Alert,{children:p.error}),(0,o.tZ)(l.Flex,{direction:"col",elementDescriptor:l.descriptors.main,gap:6,children:(0,o.BX)(_.l.Root,{onSubmit:t,gap:8,children:[(0,o.tZ)(l.Col,{gap:6,children:(0,o.tZ)(_.l.ControlRow,{elementId:"phoneNumber",children:(0,o.tZ)(_.l.PhoneInput,{...r.props,label:(0,l.localizationKeys)("signIn.start.alternativePhoneCodeProvider.label",{provider:d}),isRequired:!0,isOptional:!1,actionLabel:void 0,onActionClicked:void 0})})}),(0,o.BX)(l.Col,{center:!0,children:[(0,o.tZ)(e$.S,{}),(0,o.tZ)(l.Col,{gap:6,sx:{width:"100%"},children:(0,o.tZ)(_.l.SubmitButton,{hasArrow:!0,localizationKey:(0,l.localizationKeys)("formButtonPrimary")})})]}),(0,o.tZ)(l.Col,{center:!0,children:(0,o.tZ)(l.Button,{variant:"link",colorScheme:"neutral",onClick:n,localizationKey:(0,l.localizationKeys)("signIn.start.alternativePhoneCodeProvider.actionLink")})})]})})]})})},eN=e=>!!e.supportedFirstFactors?.length&&e.supportedFirstFactors.every(e=>"enterprise_sso"===e.strategy),eW=({field:e})=>{let[t,r]=(0,i.useState)(!1),n=(0,i.useRef)(null),s=!!(t||e?.value);return((0,i.useLayoutEffect)(()=>{let e=setInterval(()=>{if(n?.current){let t="onAutoFillStart"===window.getComputedStyle(n.current,":autofill").animationName||!!n.current?.matches("*:-webkit-autofill");t&&(r(t),clearInterval(e))}},500);return()=>{clearInterval(e)}},[]),(0,i.useEffect)(()=>{e?.value&&""!==e.value&&r(!1)},[e?.value]),e)?(0,o.tZ)(_.l.ControlRow,{elementId:e.id,sx:s?void 0:{position:"absolute",opacity:0,height:0,pointerEvents:"none",marginTop:"-1rem"},children:(0,o.tZ)(_.l.PasswordInput,{...e.props,ref:n,tabIndex:s?void 0:-1})}):null},eV=(0,K.Hy)((0,y.withCardStateProvider)(function(){let e=(0,y.useCardState)(),t=(0,n.cL)(),s=(0,c._m)(),{displayConfig:d,userSettings:u,authConfig:h}=(0,a.useEnvironment)(),m=(0,a.useCoreSignIn)(),{navigate:f}=(0,p.useRouter)(),g=(0,a.useSignInContext)(),{afterSignInUrl:I,signUpUrl:S,waitlistUrl:v,isCombinedFlow:w}=g,P=(0,k.H)(),U=(0,i.useMemo)(()=>(0,K.vX)(u.enabledFirstFactorIdentifiers),[u.enabledFirstFactorIdentifiers]),E=u.alternativePhoneCodeChannels,{isWebAuthnAutofillSupported:z}=(()=>{let[e,t]=(0,i.useState)(!1),{navigate:r}=(0,p.useRouter)(),o=ey(()=>r("factor-two")),{userSettings:n}=(0,a.useEnvironment)(),{passkeySettings:s,attributes:l}=n;return(0,i.useEffect)(()=>{async function e(){let e=await (0,eT.h_)();t(e),e&&await o({flow:"autofill"})}s.allow_autofill&&l.passkey?.enabled&&e()},[]),{isWebAuthnAutofillSupported:e}})(),F=ey(()=>f("factor-two")),R=(0,eT.iW)(),L=!!g.initialValues?.phoneNumber&&!(g.initialValues.emailAddress||g.initialValues.username)&&U.includes("phone_number"),[T,x]=(0,i.useState)(L?"phone_number":U[0]||""),[M,O]=(0,i.useState)(!1),D=(0,eD.XV)("__clerk_ticket")||"",X=(0,eD.XV)("__clerk_status")||"",N=u.enabledFirstFactorIdentifiers,W=u.web3FirstFactors,V=u.authenticatableSocialStrategies,H=u.instanceIsPasswordBased,{currentIdentifier:G,nextIdentifier:j}=(0,K.vO)(U,T),Y=(0,Z.Yp)("password","",{type:"password",label:(0,l.localizationKeys)("formFieldLabel__password"),placeholder:(0,l.localizationKeys)("formFieldInputPlaceholder__password")}),[q,Q]=(0,i.useState)(null),J=u.alternativePhoneCodeChannels.length>0,er=g.initialValues||{},eo=(0,i.useMemo)(()=>({email_address:er.emailAddress,email_address_username:er.emailAddress||er.username,username:er.username,phone_number:er.phoneNumber}),[g.initialValues]),en=!!V.length||!!W.length||!!E.length,[ei,es]=(0,i.useState)(!(0,eM.s)()&&!en),el=(0,Z.Yp)("identifier",eo[T]||"",{...G,isRequired:!0,transformer:e=>e.trim()}),ec=(0,Z.Yp)("identifier",eo.phone_number||"",{...G,isRequired:!0}),ed="phone_number"===T?ec:el;(0,i.useLayoutEffect)(()=>{if(ed.value.startsWith("+")&&U.includes("phone_number")&&"phone_number"!==T&&!M){var e;e=ed.value,el.setValue(eo[T]||""),ec.setValue(e),x("phone_number"),es(!0),O(!0)}},[ed.value,U]),(0,i.useEffect)(()=>{if(D){if("sign_up"===X){let e=new URLSearchParams;D&&e.set("__clerk_ticket",D),f(w?"create":S,{searchParams:e});return}s.setLoading(),e.setLoading(),m.create({strategy:"ticket",ticket:D}).then(e=>{switch(e.status){case"needs_first_factor":if(eN(e))return ep();return f("factor-one");case"needs_second_factor":return f("factor-two");case"complete":return(0,eD.xy)("__clerk_ticket"),t.setActive({session:e.createdSessionId,redirectUrl:I});default:return void console.error((0,A.Ws)(e.status,P))}}).catch(e=>eh(e)).finally(()=>{eN(m)||(s.setIdle(),e.setIdle())})}},[]),(0,i.useEffect)(()=>{!async function(){let t=m?.firstFactorVerification?.error;if(t){switch(t.code){case eO.O1.NOT_ALLOWED_TO_SIGN_UP:case eO.O1.OAUTH_ACCESS_DENIED:case eO.O1.NOT_ALLOWED_ACCESS:case eO.O1.SAML_USER_ATTRIBUTE_MISSING:case eO.O1.OAUTH_EMAIL_DOMAIN_RESERVED_BY_SAML:case eO.O1.USER_LOCKED:case eO.O1.EXTERNAL_ACCOUNT_NOT_FOUND:case eO.O1.SIGN_UP_MODE_RESTRICTED:case eO.O1.SIGN_UP_MODE_RESTRICTED_WAITLIST:case eO.O1.ENTERPRISE_SSO_USER_ATTRIBUTE_MISSING:case eO.O1.ENTERPRISE_SSO_EMAIL_ADDRESS_DOMAIN_MISMATCH:case eO.O1.ENTERPRISE_SSO_HOSTED_DOMAIN_MISMATCH:case eO.O1.SAML_EMAIL_ADDRESS_DOMAIN_MISMATCH:case eO.O1.ORGANIZATION_MEMBERSHIP_QUOTA_EXCEEDED_FOR_SSO:case eO.O1.CAPTCHA_INVALID:case eO.O1.FRAUD_DEVICE_BLOCKED:case eO.O1.FRAUD_ACTION_BLOCKED:case eO.O1.SIGNUP_RATE_LIMIT_EXCEEDED:e.setError(t);break;default:e.setError("Unable to complete action at this time. If the problem persists please contact support.")}await m.create({})}}()},[]);let eu=async(...e)=>{let r=q?.channel||(0,et.Vs)(e,h.preferredChannels,"identifier");if(r){let t=()=>{};e.push({id:"strategy",value:"phone_code",clearFeedback:t,setValue:t,onChange:t,setError:t}),e.push({id:"channel",value:r,clearFeedback:t,setValue:t,onChange:t,setError:t})}try{let r,o=await (r=m.create((e=>{let t=e.some(e=>"password"===e.name&&!!e.value);return(!t||u.enterpriseSSO.enabled)&&(e=e.filter(e=>"password"!==e.name)),{...(0,Z.ni)(e),...t&&!u.enterpriseSSO.enabled&&{strategy:"password"}}})(e)),r.then(t=>{if(!u.enterpriseSSO.enabled)return t;let r=e.find(e=>"password"===e.name)?.value;return!r||t.supportedFirstFactors?.some(e=>"saml"===e.strategy||"enterprise_sso"===e.strategy)?t:t.attemptFirstFactor({strategy:"password",password:r})}));switch(o.status){case"needs_identifier":o.supportedFirstFactors?.some(e=>"saml"===e.strategy||"enterprise_sso"===e.strategy)&&await ep();break;case"needs_first_factor":if(eN(o)){await ep();break}return f("factor-one");case"needs_second_factor":return f("factor-two");case"complete":return t.setActive({session:o.createdSessionId,redirectUrl:I});default:return void console.error((0,A.Ws)(o.status,P))}}catch(e){return eh(e)}},ep=async()=>{let e=(0,K.wT)(g,d.signInUrl),t=g.afterSignInUrl||"/";return m.authenticateWithRedirect({strategy:"enterprise_sso",redirectUrl:e,redirectUrlComplete:t,oidcPrompt:g.oidcPrompt,continueSignIn:!0})},eh=async o=>{if(!o.errors)return;let n=o.errors.find(e=>e.code===eO.O1.INVALID_STRATEGY_FOR_USER||e.code===eO.O1.FORM_PASSWORD_INCORRECT||e.code===eO.O1.FORM_PASSWORD_PWNED),i=o.errors.find(e=>"identifier_already_signed_in"===e.code),s=o.errors.find(e=>e.code===eO.O1.INVITATION_ACCOUNT_NOT_EXISTS||e.code===eO.O1.FORM_IDENTIFIER_NOT_FOUND);if(n)await eu(ed);else if(i){let e=i.meta.sessionId;await t.setActive({session:e,redirectUrl:I})}else if(w&&s){let o=(0,et.s2)(ed);if(u.signUp.mode===eO.ci.WAITLIST)return f(t.buildWaitlistUrl("emailAddress"===o?{initialValues:{[o]:ed.value}}:{}));t.client.signUp[o]=ed.value;let n=(0,K.wT)(g,d.signUpUrl),i=g.afterSignUpUrl||"/";return function({identifierAttribute:e,identifierValue:t,signUpMode:o,navigate:n,organizationTicket:i,afterSignUpUrl:s,clerk:a,handleError:l,redirectUrl:c,redirectUrlComplete:d,passwordEnabled:u,alternativePhoneCodeChannel:p}){var h,m;if(o===eO.ci.WAITLIST)return n(a.buildWaitlistUrl("emailAddress"===e?{initialValues:{[e]:t}}:{}));a.client.signUp[e]=t;let f=new URLSearchParams;return(i&&f.set("__clerk_ticket",i),u||(h=a.client.signUp,m=e,h.optionalFields.filter(e=>!(e.startsWith("oauth_")||e.startsWith("web3_")||["enterprise_sso","saml"].includes(e))&&"password"!==e&&("phoneNumber"!==m||"phone_number"!==e)).length>0)||"emailAddress"!==e&&"phoneNumber"!==e)?n("create",{searchParams:f}):a.client.signUp.create({[e]:t,...p?{strategy:"phone_code",channel:p}:{}}).then(async e=>(await Promise.all([r.e("200"),r.e("573"),r.e("710")]).then(r.bind(r,6052)).then(e=>e.completeSignUpFlow))({signUp:e,verifyEmailPath:"create/verify-email-address",verifyPhonePath:"create/verify-phone-number",handleComplete:()=>a.setActive({session:e.createdSessionId,redirectUrl:s}),navigate:n,redirectUrl:c,redirectUrlComplete:d})).catch(e=>l(e))}({afterSignUpUrl:g.afterSignUpUrl||"/",clerk:t,handleError:t=>(0,B.S3)(t,[ed,Y],e.setError),identifierAttribute:o,identifierValue:ed.value,navigate:f,organizationTicket:D,signUpMode:u.signUp.mode,redirectUrl:n,redirectUrlComplete:i,passwordEnabled:u.attributes.password?.required??!1,alternativePhoneCodeChannel:q?.channel||(0,et.mQ)(h.preferredChannels,o,ed.value)})}else(0,B.S3)(o,[ed,Y],e.setError)},em=async e=>(e.preventDefault(),eu(ed,Y)),ef=(0,i.useMemo)(()=>({tel:_.l.PhoneInput,password:_.l.PasswordInput,text:_.l.PlainInput,email:_.l.PlainInput})[ed.type],[ed.type]);if(s.isLoading||"sign_up"===X)return(0,o.tZ)($.W,{});let{action:eg,...eI}=ed.props;return(0,o.tZ)(l.Flow.Part,{part:"start",children:q?(0,o.tZ)(eX,{handleSubmit:em,phoneNumberFormState:ec,onUseAnotherMethod:()=>{Q(null)},phoneCodeProvider:q}):(0,o.BX)(C.Z.Root,{children:[(0,o.BX)(C.Z.Content,{children:[(0,o.BX)(b.h.Root,{showLogo:!0,children:[(0,o.tZ)(b.h.Title,{localizationKey:w?(0,l.localizationKeys)("signIn.start.titleCombined"):(0,l.localizationKeys)("signIn.start.title")}),(0,o.tZ)(b.h.Subtitle,{localizationKey:w?(0,l.localizationKeys)("signIn.start.subtitleCombined"):(0,l.localizationKeys)("signIn.start.subtitle"),sx:{"&:empty":{display:"none"}}})]}),(0,o.tZ)(C.Z.Alert,{children:e.error}),(0,o.BX)(l.Col,{elementDescriptor:l.descriptors.main,gap:6,children:[(0,o.BX)(ex.G,{children:[en&&(0,o.tZ)(ee,{enableWeb3Providers:!0,enableOAuthProviders:!0,enableAlternativePhoneCodeProviders:J,onAlternativePhoneCodeProviderClick:e=>{Q((0,ea.H)(e)||null)}}),N.length?(0,o.BX)(_.l.Root,{onSubmit:em,gap:8,children:[(0,o.BX)(l.Col,{gap:6,children:[(0,o.tZ)(_.l.ControlRow,{elementId:ed.id,children:(0,o.tZ)(ef,{actionLabel:j?.action,onActionClicked:()=>{x(e=>U[(U.indexOf(e)+1)%U.length]),es(!0),O(!1)},...eI,autoFocus:ei,autoComplete:z?"webauthn":void 0})}),(0,o.tZ)(eW,{field:H?Y:void 0})]}),(0,o.BX)(l.Col,{center:!0,children:[(0,o.tZ)(e$.S,{}),(0,o.tZ)(_.l.SubmitButton,{hasArrow:!0})]})]}):null]}),!N.length&&(0,o.tZ)(e$.S,{}),u.attributes.passkey?.enabled&&u.passkeySettings.show_sign_in_button&&R&&(0,o.tZ)(C.Z.Action,{elementId:"usePasskey",children:(0,o.tZ)(C.Z.ActionLink,{localizationKey:(0,l.localizationKeys)("signIn.start.actionLink__use_passkey"),onClick:()=>F({flow:"discoverable"})})})]})]}),(0,o.BX)(C.Z.Footer,{children:[u.signUp.mode===eO.ci.PUBLIC&&!w&&(0,o.BX)(C.Z.Action,{elementId:"signIn",children:[(0,o.tZ)(C.Z.ActionText,{localizationKey:(0,l.localizationKeys)("signIn.start.actionText")}),(0,o.tZ)(C.Z.ActionLink,{localizationKey:(0,l.localizationKeys)("signIn.start.actionLink"),to:t.buildUrlWithAuth(S)})]}),u.signUp.mode===eO.ci.WAITLIST&&(0,o.BX)(C.Z.Action,{elementId:"signIn",children:[(0,o.tZ)(C.Z.ActionText,{localizationKey:(0,l.localizationKeys)("signIn.start.actionText__join_waitlist")}),(0,o.tZ)(C.Z.ActionLink,{localizationKey:(0,l.localizationKeys)("signIn.start.actionLink__join_waitlist"),to:t.buildUrlWithAuth(v)})]})]})]})})}));function eH(){let e=(0,n.cL)();return i.useEffect(()=>{e.redirectToSignIn()},[]),null}function eG(){let e=(0,a.useSignInContext)(),t=(0,a.useSignUpContext)();return(0,o.tZ)(l.Flow.Root,{flow:"signIn",children:(0,o.BX)(p.Switch,{children:[(0,o.tZ)(p.Route,{path:"factor-one",children:(0,o.tZ)(eZ,{})}),(0,o.tZ)(p.Route,{path:"factor-two",children:(0,o.tZ)(eL,{})}),(0,o.tZ)(p.Route,{path:"reset-password",children:(0,o.tZ)(P,{})}),(0,o.tZ)(p.Route,{path:"reset-password-success",children:(0,o.tZ)(z,{})}),(0,o.tZ)(p.Route,{path:"sso-callback",children:(0,o.tZ)(eK,{signUpUrl:e.signUpUrl,signInUrl:e.signInUrl,signInForceRedirectUrl:e.afterSignInUrl,signUpForceRedirectUrl:e.afterSignUpUrl,continueSignUpUrl:e.signUpContinueUrl,transferable:e.transferable,firstFactorUrl:"../factor-one",secondFactorUrl:"../factor-two",resetPasswordUrl:"../reset-password"})}),(0,o.tZ)(p.Route,{path:"choose",children:(0,o.tZ)(O,{})}),(0,o.tZ)(p.Route,{path:"verify",children:(0,o.tZ)(s.J,{redirectUrlComplete:e.afterSignInUrl,redirectUrl:"../factor-two"})}),e.isCombinedFlow&&(0,o.BX)(p.Route,{path:"create",children:[(0,o.tZ)(p.Route,{path:"verify-email-address",canActivate:e=>!!e.client.signUp.emailAddress,children:(0,o.tZ)(g,{})}),(0,o.tZ)(p.Route,{path:"verify-phone-number",canActivate:e=>!!e.client.signUp.phoneNumber,children:(0,o.tZ)(f,{})}),(0,o.tZ)(p.Route,{path:"sso-callback",children:(0,o.tZ)(S,{signUpUrl:t.signUpUrl,signInUrl:t.signInUrl,signUpForceRedirectUrl:t.afterSignUpUrl,signInForceRedirectUrl:t.afterSignInUrl,secondFactorUrl:t.secondFactorUrl,continueSignUpUrl:"../continue",verifyEmailAddressUrl:"../verify-email-address",verifyPhoneNumberUrl:"../verify-phone-number"})}),(0,o.tZ)(p.Route,{path:"verify",children:(0,o.tZ)(s.$,{redirectUrlComplete:t.afterSignUpUrl,verifyEmailPath:"../verify-email-address",verifyPhonePath:"../verify-phone-number",continuePath:"../continue"})}),(0,o.BX)(p.Route,{path:"continue",children:[(0,o.tZ)(p.Route,{path:"verify-email-address",canActivate:e=>!!e.client.signUp.emailAddress,children:(0,o.tZ)(g,{})}),(0,o.tZ)(p.Route,{path:"verify-phone-number",canActivate:e=>!!e.client.signUp.phoneNumber,children:(0,o.tZ)(f,{})}),(0,o.tZ)(p.Route,{path:"tasks",children:(0,o.tZ)(u.x7,{})}),(0,o.tZ)(p.Route,{index:!0,children:(0,o.tZ)(v,{})})]}),(0,o.tZ)(p.Route,{index:!0,children:(0,o.tZ)(I,{})})]}),(0,o.tZ)(p.Route,{path:"tasks",children:(0,o.tZ)(u.x7,{})}),(0,o.tZ)(p.Route,{index:!0,children:(0,o.tZ)(eV,{})}),(0,o.tZ)(p.Route,{children:(0,o.tZ)(eH,{})})]})})}eG.displayName="SignIn";let ej=(0,a.withCoreSessionSwitchGuard)(function(){let{__internal_setComponentNavigationContext:e}=(0,n.cL)(),{navigate:t,indexPath:r}=(0,p.useRouter)(),s=(0,a.useSignInContext)(),l={componentName:"SignUp",emailLinkRedirectUrl:s.emailLinkRedirectUrl,ssoCallbackUrl:s.ssoCallbackUrl,forceRedirectUrl:s.signUpForceRedirectUrl,fallbackRedirectUrl:s.signUpFallbackRedirectUrl,signInUrl:s.signInUrl,unsafeMetadata:s.unsafeMetadata,...(0,h.L)({routing:s?.routing,path:s?.path})};return((e=!1)=>(0,c.ib)(e?m:void 0,"preloadComponent",{staleTime:1/0}))(s.isCombinedFlow),(0,d.z)(),i.useEffect(()=>e?.({indexPath:r,navigate:t}),[r,t]),(0,o.tZ)(a.SignUpContext.Provider,{value:l,children:(0,o.tZ)(eG,{})})}),eY=e=>{let t={signUpUrl:`/${p.VIRTUAL_ROUTER_BASE_PATH}/sign-up`,waitlistUrl:`/${p.VIRTUAL_ROUTER_BASE_PATH}/waitlist`,...e};return(0,o.tZ)(p.Route,{path:"sign-in",children:(0,o.tZ)(a.SignInContext.Provider,{value:{componentName:"SignIn",...t,routing:"virtual",mode:"modal"},children:(0,o.tZ)("div",{children:(0,o.tZ)(ej,{...t,routing:"virtual"})})})})}},5518:function(e,t,r){r.d(t,{Vh:()=>m,Vs:()=>g,bx:()=>p,mQ:()=>I,s2:()=>f,t3:()=>c,xT:()=>u}),r(5027);var o=r(2208),n=r(8690),i=r(7772),s=r(577);let a=e=>t=>"safeIdentifier"in t&&t.safeIdentifier===e;function l(e){if((0,o.iW)()){let t=e.find(({strategy:e})=>"passkey"===e);if(t)return t}return null}function c(e,t,r){return e&&0!==e.length?r===i.kJ.Password?function(e,t){let r=l(e);if(r)return r;let o=e.sort(s.sZ)[0];return"password"===o.s