UNPKG

@clerk/clerk-js

Version:
1 lines • 61.7 kB
"use strict";(globalThis.webpackChunk_clerk_clerk_js=globalThis.webpackChunk_clerk_clerk_js||[]).push([["722"],{7389:function(e,t,r){r.d(t,{v:()=>a});var o=r(79109),n=r(24562),i=r(64204);let a=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:()=>eY,SignInModal:()=>eq});var o=r(79109),n=r(83799),i=r(69144),a=r(15112),s=r(11576),l=r(64204),c=r(12464),d=r(4511),u=r(7508),p=r(24676),h=r(22073);r(50725);let f=()=>Promise.all([r.e("200"),r.e("573"),r.e("710")]).then(r.bind(r,85049)),m=(0,i.lazy)(()=>f().then(e=>({default:e.SignUpVerifyPhone}))),g=(0,i.lazy)(()=>f().then(e=>({default:e.SignUpVerifyEmail}))),I=(0,i.lazy)(()=>f().then(e=>({default:e.SignUpStart}))),v=(0,i.lazy)(()=>f().then(e=>({default:e.SignUpSSOCallback}))),S=(0,i.lazy)(()=>f().then(e=>({default:e.SignUpContinue})));r(45261),r(70957),r(24551),r(22349),r(65223);var C=r(92418),y=r(2672),_=r(70431),b=r(92654),B=r(88870),w=r(86842),Z=r(36788),A=r(24152),k=r(93234);let P=(0,y.withCardStateProvider)(()=>{let e=(0,s.useCoreSignIn)(),t=(0,y.useCardState)(),{navigate:r}=(0,p.useRouter)(),n=(0,k.H)(),{userSettings:{passwordSettings:a}}=(0,s.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 f=(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:a})}),m=(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:v}=(0,c.p5)({passwordField:f,confirmPasswordField:m}),S=async()=>{f.clearFeedback(),m.clearFeedback();try{let{status:t,createdSessionId:o}=await e.resetPassword({password:f.value,signOutOfOtherSessions:g.checked});switch(t){case"complete":if(o){let e=new URLSearchParams;return e.set("createdSessionId",o),r("../reset-password-success?".concat(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,[f,m],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:S,onBlur:()=>{f.value&&I(m.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:f.id,children:(0,o.tZ)(_.l.PasswordInput,{...f.props,isRequired:!0,autoFocus:!0})}),(0,o.tZ)(_.l.ControlRow,{elementId:m.id,children:(0,o.tZ)(_.l.PasswordInput,{...m.props,onChange:e=>(e.target.value&&I(e.target.value),m.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:!v,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(44875),E=r(30215);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(42305),R=r(48774),L=r(97295),K=r(8969),T=r(96519),x=r(49327),M=r(35241);let O=(0,K.Hy)((0,y.withCardStateProvider)(()=>{let e=(0,y.useCardState)(),{userProfileUrl:t}=(0,s.useEnvironment)().displayConfig,{afterSignInUrl:r,path:n}=(0,s.useSignInContext)(),{navigateAfterSignOut:i}=(0,s.useSignOutContext)(),{handleSignOutAllClicked:a,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:"".concat(e.space.$8," ").concat(e.space.$none," ").concat(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:"".concat(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:a,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:"".concat(e.space.$2," ").concat(e.space.$2)})})})})]})})}));var D=r(24562),X=r(21455),N=r(91752),W=r(17703);r(92037);var $=r(38246),V=r(5482),H=r(16735),G=r(44271),j=r(96565),Y=r(19955),q=r(56749),Q=r(75747),J=r(80138);let ee=i.memo(e=>{let t=(0,n.cL)(),{navigate:r}=(0,p.useRouter)(),i=(0,y.useCardState)(),{displayConfig:a}=(0,Q.O)(),l=(0,s.useSignInContext)(),c=(0,s.useCoreSignIn)(),d=(0,q.wT)(l,a.signInUrl),u=l.afterSignInUrl||"/",h="popup"===l.oauthFlow||"auto"===l.oauthFlow&&(0,j.t)(),{onAlternativePhoneCodeProviderClick:f,...m}=e;return(0,o.tZ)(J.L,{...m,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=>{null==f||f(e)}})});var et=r(95518);function er(){var e;return null==(e=(0,s.useCoreSignIn)().supportedFirstFactors)?void 0:e.find(e=>{let{strategy:t}=e;return(0,et.Vh)(t)})}var eo=r(7389);let en=e=>((e,t)=>{let[r,n]=i.useState(!1),a=i.useCallback(()=>n(e=>!e),[n]);return r?(0,o.tZ)(eo.v,{onBackLinkClick:a}):(0,o.tZ)(e,{...t,onHavingTroubleClick:a})})(ei,{...e}),ei=e=>{let{onBackLinkClick:t,onHavingTroubleClick:r,onFactorSelected:n,mode:i="default"}=e,a=(0,y.useCardState)(),c=er(),{supportedFirstFactors:d}=(0,s.useCoreSignIn)(),{firstPartyFactors:u,hasAnyStrategy:p}=(0,N.l)({filterOutFactor:null==e?void 0:e.currentFactor,supportedFirstFactors:d}),h=function(e){switch(e){case"forgot":return"forgotPasswordMethods";case"pwned":return"passwordPwnedMethods";default:return"alternativeMethods"}}(i),f=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),m=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:f}),!m&&(0,o.tZ)(b.h.Subtitle,{localizationKey:(0,l.localizationKeys)("signIn.alternativeMethods.subtitle")})]}),(0,o.tZ)(C.Z.Alert,{children:a.error}),(0,o.BX)(l.Flex,{direction:"col",elementDescriptor:l.descriptors.main,gap:6,children:[m&&c&&(0,o.tZ)(l.Button,{localizationKey:ea(c),elementDescriptor:l.descriptors.alternativeMethodsBlockButton,isDisabled:a.isLoading,onClick:()=>{a.setError(void 0),n(c)}}),m&&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)($.$,{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:ea(e),elementDescriptor:l.descriptors.alternativeMethodsBlockButton,textElementDescriptor:l.descriptors.alternativeMethodsBlockButtonText,arrowElementDescriptor:l.descriptors.alternativeMethodsBlockButtonArrow,textVariant:"buttonLarge",isDisabled:a.isLoading,onClick:()=>{a.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 ea(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: "'.concat(e.strategy,'"'))}}var es=r(36543),el=r(73531),ec=r(23465);let ed=e=>{let t=(0,s.useCoreSignIn)(),r=(0,y.useCardState)(),{navigate:i}=(0,p.useRouter)(),{afterSignInUrl:a}=(0,s.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:a});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,W.u1)("footerActionLink__alternativePhoneCodeProvider"),onShowAlternativeMethodsClicked:()=>{r.setError(void 0),e.onChangePhoneCodeChannel({...e.factor,channel:void 0})},showAlternativeMethods:!0,onIdentityPreviewEditClicked:()=>i("../"),onBackLinkClicked:e.onBackLinkClicked})},eu=e=>{var t;return(0,o.tZ)(l.Flow.Part,{part:"phoneCode",children:(0,o.tZ)(ed,{...e,cardTitle:(0,l.localizationKeys)("signIn.alternativePhoneCodeProvider.title",{provider:(null==(t=(0,es.H)(e.factor.channel))?void 0:t.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,s.useCoreSignIn)(),r=(0,y.useCardState)(),{navigate:a}=(0,p.useRouter)(),{afterSignInUrl:l}=(0,s.useSignInContext)(),{setActive:d}=(0,n.cL)(),u=(0,k.H)(),h=(0,n.cL)(),f="verified"===t.firstFactorVerification.status&&e.factorAlreadyPrepared,m=(0,i.useMemo)(()=>{let t=e.factor,r=t.strategy;return"emailAddressId"in t&&(r+="_".concat(t.emailAddressId)),"phoneNumberId"in t&&(r+="_".concat(t.phoneNumberId)),"channel"in t&&t.channel&&(r+="_".concat(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)(f?void 0:()=>null==t?void 0:t.prepareFirstFactor(e.factor).then(()=>e.onFactorPrepare()).catch(e=>(0,B.S3)(e,[],r.setError)),m,{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 a("../factor-two");case"needs_new_password":return a("../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:()=>{f||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:()=>a("../"),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 ef=r(65495),em=r(14814),eg=r(85117);let eI=e=>{let{t}=(0,l.useLocalizations)(),r=(0,y.useCardState)(),a=(0,s.useCoreSignIn)(),c=(0,s.useSignInContext)(),{signInUrl:d}=c,{navigate:u}=(0,eg.t)(),{afterSignInUrl:p}=(0,s.useSignInContext)(),{setActive:h}=(0,n.cL)(),{startEmailLinkFlow:f,cancelEmailLinkFlow:m}=(0,em.E)(a),[g,I]=i.useState(!1),v=(0,n.cL)();i.useEffect(()=>{S()},[]);let S=()=>{f({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 v.__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)(ef.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:()=>{m(),S()},safeIdentifier:e.factor.safeIdentifier,profileImageUrl:a.userData.imageUrl,onShowAlternativeMethodsClicked:e.onShowAlternativeMethodsClicked})})},ev=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 eS=r(384),eC=r(93367);function ey(e){let t=(0,y.useCardState)(),{setActive:r,__internal_navigateWithError:o}=(0,n.cL)(),a=(0,k.H)(),{afterSignInUrl:l}=(0,s.useSignInContext)(),{authenticateWithPasskey:c}=(0,s.useCoreSignIn)();return(0,i.useEffect)(()=>()=>{eC.YI.abort()},[]),(0,i.useCallback)(async function(){for(var n=arguments.length,i=Array(n),s=0;s<n;s++)i[s]=arguments[s];try{let t=await c(...i);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,a))}}catch(r){let{flow:e}=i[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,s.useCoreSignIn)(),{navigate:a}=(0,eg.t)(),[c,d]=i.useState(!1),u=i.useCallback(()=>d(e=>!e),[d]),p=ey(()=>a("../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)(eS.m,{identifier:n.identifier,avatarUrl:n.userData.imageUrl,onClick:()=>a("../")})]}),(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,a=i.useRef(null),c=(0,y.useCardState)(),{setActive:d}=(0,n.cL)(),u=(0,s.useCoreSignIn)(),{afterSignInUrl:p}=(0,s.useSignInContext)(),h=(0,k.H)(),f=(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:m}=(0,eg.t)(),[g,I]=i.useState(!1),v=i.useCallback(()=>I(e=>!e),[I]),S=(0,n.cL)(),w=async e=>(e.preventDefault(),u.attemptFirstFactor({strategy:"password",password:f.value}).then(e=>{switch(e.status){case"complete":return d({session:e.createdSessionId,redirectUrl:p});case"needs_second_factor":return m("../factor-two");default:return console.error((0,A.Ws)(e.status,h))}}).catch(e=>{if((0,el.ay)(e))return S.__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,[f],c.setError),setTimeout(()=>{var e;return null==(e=a.current)?void 0:e.focus()},0)}));return g?(0,o.tZ)(eo.v,{onBackLinkClick:v}):(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)(eS.m,{identifier:u.identifier,avatarUrl:u.userData.imageUrl,onClick:()=>m("../")})]}),(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:f.id,children:(0,o.tZ)(_.l.PasswordInput,{...f.props,ref:a,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||v})})]})]}),(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,s.useCoreSignIn)(),{preferredSignInStrategy:t}=(0,s.useEnvironment)().displayConfig,r=e.supportedFirstFactors,n=(0,p.useRouter)(),a=(0,y.useCardState)(),{supportedFirstFactors:l,firstFactorVerification:c}=(0,s.useCoreSignIn)(),d=i.useRef(""),[{currentFactor:u},h]=i.useState(()=>{let o=(0,et.t3)(r,e.identifier,t);return(null==o?void 0:o.strategy)==="phone_code"&&c.channel&&"sms"!==c.channel&&(o.channel=c.channel),{currentFactor:o,prevCurrentFactor:void 0}}),{hasAnyStrategy:f}=(0,N.l)({filterOutFactor:u,supportedFirstFactors:l}),[m,g]=i.useState(()=>!u||!(0,et.xT)(u)),I=er(),[v,S]=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,W.u1)("signIn.noAvailableMethods.title"),cardSubtitle:(0,W.u1)("signIn.noAvailableMethods.subtitle"),message:(0,W.u1)("signIn.noAvailableMethods.message")});let b=f?()=>g(e=>!e):void 0,B=()=>S(e=>!e),w=()=>{d.current=ew(u)},Z=e=>{h(t=>({currentFactor:e,prevCurrentFactor:t.currentFactor}))};if(m||v){let e=(0,et.xT)(u),t=m?b:B;return(0,o.tZ)(en,{mode:v?C?"pwned":"forgot":"default",onBackLinkClick:e?()=>{a.setError(void 0),_(!1),null==t||t()}:void 0,onFactorSelected:e=>{Z(e),null==t||t()},currentFactor:u})}if(!u)return(0,o.tZ)(X.W,{});switch(null==u?void 0: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)(ev,{factorAlreadyPrepared:d.current===ew(u),onFactorPrepare:w,factor:u,onShowAlternativeMethodsClicked:b,onBackLinkClicked:()=>{h(e=>({currentFactor:e.prevCurrentFactor,prevCurrentFactor:e.currentFactor})),B()},cardSubtitle:(0,W.u1)("signIn.forgotPassword.subtitle_phone")});case"reset_password_email_code":return(0,o.tZ)(ev,{factorAlreadyPrepared:d.current===ew(u),onFactorPrepare:w,factor:u,onShowAlternativeMethodsClicked:b,onBackLinkClicked:()=>{h(e=>({currentFactor:e.prevCurrentFactor,prevCurrentFactor:e.currentFactor})),B()},cardSubtitle:(0,W.u1)("signIn.forgotPassword.subtitle_email")});default:return(0,o.tZ)(X.W,{})}}));var eA=r(90577);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:a}=(0,s.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:a&&a.sort(eA.Q0).map((e,t)=>(0,o.tZ)($.$,{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: "'.concat(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,s.useCoreSignIn)(),{afterSignInUrl:i}=(0,s.useSignInContext)(),{setActive:a}=(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}),f=(0,n.cL)(),m=e=>{var t,r;return(0,et.Vh)(null==(t=e.firstFactorVerification)?void 0:t.strategy)&&(null==(r=e.firstFactorVerification)?void 0:r.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:m(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(m(e)&&e.createdSessionId){let t=new URLSearchParams;return t.set("createdSessionId",e.createdSessionId),c("../reset-password-success?".concat(t.toString()))}return a({session:e.createdSessionId,redirectUrl:i})}).catch(e=>{if((0,el.ay)(e))return f.__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,s.useCoreSignIn)(),r=(0,y.useCardState)(),{afterSignInUrl:a}=(0,s.useSignInContext)(),{setActive:c}=(0,n.cL)(),{navigate:d}=(0,p.useRouter)(),u=(0,k.H)(),h=(0,n.cL)();i.useEffect(()=>{e.factorAlreadyPrepared||null==f||f()},[]);let f=e.prepare?()=>{var t;return null==(t=e.prepare)?void 0:t.call(e).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,m=e=>{var t,r;return(0,et.Vh)(null==(t=e.firstFactorVerification)?void 0:t.strategy)&&(null==(r=e.firstFactorVerification)?void 0:r.status)==="verified"};return(0,o.tZ)(ec.U,{cardTitle:e.cardTitle,cardSubtitle:m(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(m(e)&&e.createdSessionId){let t=new URLSearchParams;return t.set("createdSessionId",e.createdSessionId),d("../reset-password-success?".concat(t.toString()))}return c({session:e.createdSessionId,redirectUrl:a})}).catch(e=>(0,el.ay)(e)?h.__internal_navigateWithError("..",e.errors[0]):n(e))},onResendCodeClicked:f,safeIdentifier:"safeIdentifier"in e.factor?e.factor.safeIdentifier:void 0,profileImageUrl:t.userData.imageUrl,onShowAlternativeMethodsClicked:e.onShowAlternativeMethodsClicked,children:m(t)&&(0,o.tZ)(l.Text,{localizationKey:(0,l.localizationKeys)("signIn.resetPasswordMfa.detailsLabel"),colorScheme:"secondary"})})},ez=e=>{let t=(0,s.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,s.useCoreSignIn)().supportedSecondFactors,t=i.useRef(""),[r,n]=i.useState(()=>(0,et.bx)(e)),[a,l]=i.useState(!r),c=()=>l(e=>!e),d=()=>{t.current=eR(r)};if(!r)return(0,o.tZ)(X.W,{});if(a)return(0,o.tZ)(ek,{onBackLinkClick:c,onFactorSelected:e=>{n(e),c()}});switch(null==r?void 0: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)(X.W,{})}})),eK=(0,K.Hy)(K.L);r(28419),r(38062),r(79876);var eT=r(32208),ex=r(18350),eM=r(53621),eO=r(80753),eD=r(93344),eX=r(37321);let eN=e=>{var t;let{handleSubmit:r,phoneNumberFormState:n,onUseAnotherMethod:i,phoneCodeProvider:a}=e,{providerToDisplayData:s,strategyToDisplayData:d}=(0,c.vO)(),u=a.name,p=a.channel,h=(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:null==(t=s[p])?void 0:t.iconUrl,alt:"".concat(d[p].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:u})}),(0,o.tZ)(b.h.Subtitle,{localizationKey:(0,l.localizationKeys)("signIn.start.alternativePhoneCodeProvider.subtitle",{provider:u})})]}),(0,o.tZ)(C.Z.Alert,{children:h.error}),(0,o.tZ)(l.Flex,{direction:"col",elementDescriptor:l.descriptors.main,gap:6,children:(0,o.BX)(_.l.Root,{onSubmit:r,gap:8,children:[(0,o.tZ)(l.Col,{gap:6,children:(0,o.tZ)(_.l.ControlRow,{elementId:"phoneNumber",children:(0,o.tZ)(_.l.PhoneInput,{...n.props,label:(0,l.localizationKeys)("signIn.start.alternativePhoneCodeProvider.label",{provider:u}),isRequired:!0,isOptional:!1,actionLabel:void 0,onActionClicked:void 0})})}),(0,o.BX)(l.Col,{center:!0,children:[(0,o.tZ)(eX.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:i,localizationKey:(0,l.localizationKeys)("signIn.start.alternativePhoneCodeProvider.actionLink")})})]})})]})})},eW=e=>{var t;return!!(null==(t=e.supportedFirstFactors)?void 0:t.length)&&e.supportedFirstFactors.every(e=>"enterprise_sso"===e.strategy)},e$=e=>{let{field:t}=e,[r,n]=(0,i.useState)(!1),a=(0,i.useRef)(null),s=!!(r||(null==t?void 0:t.value));return((0,i.useLayoutEffect)(()=>{let e=setInterval(()=>{if(null==a?void 0:a.current){var t;let r="onAutoFillStart"===window.getComputedStyle(a.current,":autofill").animationName||!!(null==(t=a.current)?void 0:t.matches("*:-webkit-autofill"));r&&(n(r),clearInterval(e))}},500);return()=>{clearInterval(e)}},[]),(0,i.useEffect)(()=>{(null==t?void 0:t.value)&&""!==t.value&&n(!1)},[null==t?void 0:t.value]),t)?(0,o.tZ)(_.l.ControlRow,{elementId:t.id,sx:s?void 0:{position:"absolute",opacity:0,height:0,pointerEvents:"none",marginTop:"-1rem"},children:(0,o.tZ)(_.l.PasswordInput,{...t.props,ref:a,tabIndex:s?void 0:-1})}):null},eV=(0,K.Hy)((0,y.withCardStateProvider)(function(){var e,t;let a=(0,y.useCardState)(),d=(0,n.cL)(),u=(0,c._m)(),{displayConfig:h,userSettings:f,authConfig:m}=(0,s.useEnvironment)(),g=(0,s.useCoreSignIn)(),{navigate:I}=(0,p.useRouter)(),v=(0,s.useSignInContext)(),{afterSignInUrl:S,signUpUrl:w,waitlistUrl:P,isCombinedFlow:U}=v,E=(0,k.H)(),z=(0,i.useMemo)(()=>(0,K.vX)(f.enabledFirstFactorIdentifiers),[f.enabledFirstFactorIdentifiers]),F=f.alternativePhoneCodeChannels,{isWebAuthnAutofillSupported:R}=(()=>{let[e,t]=(0,i.useState)(!1),{navigate:r}=(0,p.useRouter)(),o=ey(()=>r("factor-two")),{userSettings:n}=(0,s.useEnvironment)(),{passkeySettings:a,attributes:l}=n;return(0,i.useEffect)(()=>{var e;async function r(){let e=await (0,eT.h_)();t(e),e&&await o({flow:"autofill"})}a.allow_autofill&&(null==(e=l.passkey)?void 0:e.enabled)&&r()},[]),{isWebAuthnAutofillSupported:e}})(),L=ey(()=>I("factor-two")),T=(0,eT.iW)(),x=!!(null==(e=v.initialValues)?void 0:e.phoneNumber)&&!(v.initialValues.emailAddress||v.initialValues.username)&&z.includes("phone_number"),[M,O]=(0,i.useState)(x?"phone_number":z[0]||""),[D,N]=(0,i.useState)(!1),W=(0,eD.XV)("__clerk_ticket")||"",$=(0,eD.XV)("__clerk_status")||"",V=f.enabledFirstFactorIdentifiers,H=f.web3FirstFactors,G=f.authenticatableSocialStrategies,j=f.instanceIsPasswordBased,{currentIdentifier:Y,nextIdentifier:q}=(0,K.vO)(z,M),Q=(0,Z.Yp)("password","",{type:"password",label:(0,l.localizationKeys)("formFieldLabel__password"),placeholder:(0,l.localizationKeys)("formFieldInputPlaceholder__password")}),[J,er]=(0,i.useState)(null),eo=f.alternativePhoneCodeChannels.length>0,en=v.initialValues||{},ei=(0,i.useMemo)(()=>({email_address:en.emailAddress,email_address_username:en.emailAddress||en.username,username:en.username,phone_number:en.phoneNumber}),[v.initialValues]),ea=!!G.length||!!H.length||!!F.length,[el,ec]=(0,i.useState)(!(0,eM.s)()&&!ea),ed=(0,Z.Yp)("identifier",ei[M]||"",{...Y,isRequired:!0,transformer:e=>e.trim()}),eu=(0,Z.Yp)("identifier",ei.phone_number||"",{...Y,isRequired:!0}),ep="phone_number"===M?eu:ed;(0,i.useLayoutEffect)(()=>{if(ep.value.startsWith("+")&&z.includes("phone_number")&&"phone_number"!==M&&!D){var e;e=ep.value,ed.setValue(ei[M]||""),eu.setValue(e),O("phone_number"),ec(!0),N(!0)}},[ep.value,z]),(0,i.useEffect)(()=>{if(W){if("sign_up"===$){let e=new URLSearchParams;W&&e.set("__clerk_ticket",W),I(U?"create":w,{searchParams:e});return}u.setLoading(),a.setLoading(),g.create({strategy:"ticket",ticket:W}).then(e=>{switch(e.status){case"needs_first_factor":if(eW(e))return ef();return I("factor-one");case"needs_second_factor":return I("factor-two");case"complete":return(0,eD.xy)("__clerk_ticket"),d.setActive({session:e.createdSessionId,redirectUrl:S});default:return void console.error((0,A.Ws)(e.status,E))}}).catch(e=>em(e)).finally(()=>{eW(g)||(u.setIdle(),a.setIdle())})}},[]),(0,i.useEffect)(()=>{!async function(){var e;let t=null==g||null==(e=g.firstFactorVerification)?void 0:e.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:a.setError(t);break;default:a.setError("Unable to complete action at this time. If the problem persists please contact support.")}await g.create({})}}()},[]);let eh=async function(){for(var e,t=arguments.length,r=Array(t),o=0;o<t;o++)r[o]=arguments[o];let n=(null==J?void 0:J.channel)||(0,et.Vs)(r,m.preferredChannels,"identifier");if(n){let e=()=>{};r.push({id:"strategy",value:"phone_code",clearFeedback:e,setValue:e,onChange:e,setError:e}),r.push({id:"channel",value:n,clearFeedback:e,setValue:e,onChange:e,setError:e})}try{let t,o=await (t=g.create((e=>{let t=e.some(e=>"password"===e.name&&!!e.value);return(!t||f.enterpriseSSO.enabled)&&(e=e.filter(e=>"password"!==e.name)),{...(0,Z.ni)(e),...t&&!f.enterpriseSSO.enabled&&{strategy:"password"}}})(r)),t.then(e=>{var t,o;if(!f.enterpriseSSO.enabled)return e;let n=null==(t=r.find(e=>"password"===e.name))?void 0:t.value;return!n||(null==(o=e.supportedFirstFactors)?void 0:o.some(e=>"saml"===e.strategy||"enterprise_sso"===e.strategy))?e:e.attemptFirstFactor({strategy:"password",password:n})}));switch(o.status){case"needs_identifier":(null==(e=o.supportedFirstFactors)?void 0:e.some(e=>"saml"===e.strategy||"enterprise_sso"===e.strategy))&&await ef();break;case"needs_first_factor":if(eW(o)){await ef();break}return I("factor-one");case"needs_second_factor":return I("factor-two");case"complete":return d.setActive({session:o.createdSessionId,redirectUrl:S});default:return void console.error((0,A.Ws)(o.status,E))}}catch(e){return em(e)}},ef=async()=>{let e=(0,K.wT)(v,h.signInUrl),t=v.afterSignInUrl||"/";return g.authenticateWithRedirect({strategy:"enterprise_sso",redirectUrl:e,redirectUrlComplete:t,oidcPrompt:v.oidcPrompt,continueSignIn:!0})},em=async e=>{if(!e.errors)return;let t=e.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),o=e.errors.find(e=>"identifier_already_signed_in"===e.code),n=e.errors.find(e=>e.code===eO.O1.INVITATION_ACCOUNT_NOT_EXISTS||e.code===eO.O1.FORM_IDENTIFIER_NOT_FOUND);if(t)await eh(ep);else if(o){let e=o.meta.sessionId;await d.setActive({session:e,redirectUrl:S})}else if(U&&n){var i,s;let e=(0,et.s2)(ep);if(f.signUp.mode===eO.ci.WAITLIST)return I(d.buildWaitlistUrl("emailAddress"===e?{initialValues:{[e]:ep.value}}:{}));d.client.signUp[e]=ep.value;let t=(0,K.wT)(v,h.signUpUrl),o=v.afterSignUpUrl||"/";return function(e){var t,o;let{identifierAttribute:n,identifierValue:i,signUpMode:a,navigate:s,organizationTicket:l,afterSignUpUrl:c,clerk:d,handleError:u,redirectUrl:p,redirectUrlComplete:h,passwordEnabled:f,alternativePhoneCodeChannel:m}=e;if(a===eO.ci.WAITLIST)return s(d.buildWaitlistUrl("emailAddress"===n?{initialValues:{[n]:i}}:{}));d.client.signUp[n]=i;let g=new URLSearchParams;return(l&&g.set("__clerk_ticket",l),f||(t=d.client.signUp,o=n,t.optionalFields.filter(e=>!(e.startsWith("oauth_")||e.startsWith("web3_")||["enterprise_sso","saml"].includes(e))&&"password"!==e&&("phoneNumber"!==o||"phone_number"!==e)).length>0)||"emailAddress"!==n&&"phoneNumber"!==n)?s("create",{searchParams:g}):d.client.signUp.create({[n]:i,...m?{strategy:"phone_code",channel:m}:{}}).then(async e=>(await Promise.all([r.e("200"),r.e("573"),r.e("710")]).then(r.bind(r,46052)).then(e=>e.completeSignUpFlow))({signUp:e,verifyEmailPath:"create/verify-email-address",verifyPhonePath:"create/verify-phone-number",handleComplete:()=>d.setActive({session:e.createdSessionId,redirectUrl:c}),navigate:s,redirectUrl:p,redirectUrlComplete:h})).catch(e=>u(e))}({afterSignUpUrl:v.afterSignUpUrl||"/",clerk:d,handleError:e=>(0,B.S3)(e,[ep,Q],a.setError),identifierAttribute:e,identifierValue:ep.value,navigate:I,organizationTicket:W,signUpMode:f.signUp.mode,redirectUrl:t,redirectUrlComplete:o,passwordEnabled:null!=(s=null==(i=f.attributes.password)?void 0:i.required)&&s,alternativePhoneCodeChannel:(null==J?void 0:J.channel)||(0,et.mQ)(m.preferredChannels,e,ep.value)})}else(0,B.S3)(e,[ep,Q],a.setError)},eg=async e=>(e.preventDefault(),eh(ep,Q)),eI=(0,i.useMemo)(()=>({tel:_.l.PhoneInput,password:_.l.PasswordInput,text:_.l.PlainInput,email:_.l.PlainInput})[ep.type],[ep.type]);if(u.isLoading||"sign_up"===$)return(0,o.tZ)(X.W,{});let{action:ev,...eS}=ep.props;return(0,o.tZ)(l.Flow.Part,{part:"start",children:J?(0,o.tZ)(eN,{handleSubmit:eg,phoneNumberFormState:eu,onUseAnotherMethod:()=>{er(null)},phoneCodeProvider:J}):(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:U?(0,l.localizationKeys)("signIn.start.titleCombined"):(0,l.localizationKeys)("signIn.start.title")}),(0,o.tZ)(b.h.Subtitle,{localizationKey:U?(0,l.localizationKeys)("signIn.start.subtitleCombined"):(0,l.localizationKeys)("signIn.start.subtitle"),sx:{"&:empty":{display:"none"}}})]}),(0,o.tZ)(C.Z.Alert,{children:a.error}),(0,o.BX)(l.Col,{elementDescriptor:l.descriptors.main,gap:6,children:[(0,o.BX)(ex.G,{children:[ea&&(0,o.tZ)(ee,{enableWeb3Providers:!0,enableOAuthProviders:!0,enableAlternativePhoneCodeProviders:eo,onAlternativePhoneCodeProviderClick:e=>{er((0,es.H)(e)||null)}}),V.length?(0,o.BX)(_.l.Root,{onSubmit:eg,gap:8,children:[(0,o.BX)(l.Col,{gap:6,children:[(0,o.tZ)(_.l.ControlRow,{elementId:ep.id,children:(0,o.tZ)(eI,{actionLabel:null==q?void 0:q.action,onActionClicked:()=>{O(e=>z[(z.indexOf(e)+1)%z.length]),ec(!0),N(!1)},...eS,autoFocus:el,autoComplete:R?"webauthn":void 0})}),(0,o.tZ)(e$,{field:j?Q:void 0})]}),(0,o.BX)(l.Col,{center:!0,children:[(0,o.tZ)(eX.S,{}),(0,o.tZ)(_.l.SubmitButton,{hasArrow:!0})]})]}):null]}),!V.length&&(0,o.tZ)(eX.S,{}),(null==(t=f.attributes.passkey)?void 0:t.enabled)&&f.passkeySettings.show_sign_in_button&&T&&(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:()=>L({flow:"discoverable"})})})]})]}),(0,o.BX)(C.Z.Footer,{children:[f.signUp.mode===eO.ci.PUBLIC&&!U&&(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:d.buildUrlWithAuth(w)})]}),f.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:d.buildUrlWithAuth(P)})]})]})]})})}));function eH(){let e=(0,n.cL)();return i.useEffect(()=>{e.redirectToSignIn()},[]),null}function eG(){let e=(0,s.useSignInContext)(),t=(0,s.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)(a.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)(m,{})}),(0,o.tZ)(p.Route,{path:"sso-callback",children:(0,o.tZ)(v,{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)(a.$,{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)(m,{})}),(0,o.tZ)(p.Route,{path:"tasks",children:(0,o.tZ)(u.x7,{})}),(0,o.tZ)(p.Route,{index:!0,children:(0,o.tZ)(S,{})})]}),(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,{})})]})})}let ej=function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return(0,c.ib)(e?f:void 0,"preloadComponent",{staleTime:1/0})};eG.displayName="SignIn";let eY=(0,s.withCoreSessionSwitchGuard)(function(){let{__internal_setComponentNavigationContext:e}=(0,n.cL)(),{navigate:t,indexPath:r}=(0,p.useRouter)(),a=(0,s.useSignInContext)(),l={componen