@firebase-oss/ui-react 0.0.2 → 7.0.1-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/package.json +9 -9
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {registerFramework,getBehavior,getTranslation,createSignInAuthFormSchema,createSignUpAuthFormSchema,createForgotPasswordAuthFormSchema,createEmailLinkAuthFormSchema,createPhoneAuthNumberFormSchema,createPhoneAuthVerifyFormSchema,createMultiFactorPhoneAuthNumberFormSchema,createMultiFactorPhoneAuthVerifyFormSchema,createMultiFactorTotpAuthNumberFormSchema,createMultiFactorTotpAuthVerifyFormSchema,sendSignInLinkToEmail,FirebaseUIError,completeEmailLinkSignIn,sendPasswordResetEmail,signInWithMultiFactorAssertion,verifyPhoneNumber,enrollWithMultiFactorAssertion,generateTotpSecret,generateTotpQrCode,confirmPhoneNumber,signInWithEmailAndPassword,hasBehavior,createUserWithEmailAndPassword,signInWithProvider,formatPhoneNumber}from'@firebase-oss/ui-core';import {createContext,forwardRef,useState,useCallback,useImperativeHandle,useContext,cloneElement,useEffect,useMemo,useRef}from'react';import {useStore}from'@nanostores/react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {createFormHookContexts,createFormHook}from'@tanstack/react-form';import {Slot}from'@radix-ui/react-slot';import {buttonVariant}from'@firebase-oss/ui-styles';import {twMerge}from'tailwind-merge';import {clsx}from'clsx';import {FactorId,TotpMultiFactorGenerator,PhoneAuthProvider,PhoneMultiFactorGenerator,multiFactor,OAuthProvider,FacebookAuthProvider,GithubAuthProvider,GoogleAuthProvider,TwitterAuthProvider}from'firebase/auth';var tr={version:"
|
|
1
|
+
import {registerFramework,getBehavior,getTranslation,createSignInAuthFormSchema,createSignUpAuthFormSchema,createForgotPasswordAuthFormSchema,createEmailLinkAuthFormSchema,createPhoneAuthNumberFormSchema,createPhoneAuthVerifyFormSchema,createMultiFactorPhoneAuthNumberFormSchema,createMultiFactorPhoneAuthVerifyFormSchema,createMultiFactorTotpAuthNumberFormSchema,createMultiFactorTotpAuthVerifyFormSchema,sendSignInLinkToEmail,FirebaseUIError,completeEmailLinkSignIn,sendPasswordResetEmail,signInWithMultiFactorAssertion,verifyPhoneNumber,enrollWithMultiFactorAssertion,generateTotpSecret,generateTotpQrCode,confirmPhoneNumber,signInWithEmailAndPassword,hasBehavior,createUserWithEmailAndPassword,signInWithProvider,formatPhoneNumber}from'@firebase-oss/ui-core';import {createContext,forwardRef,useState,useCallback,useImperativeHandle,useContext,cloneElement,useEffect,useMemo,useRef}from'react';import {useStore}from'@nanostores/react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {createFormHookContexts,createFormHook}from'@tanstack/react-form';import {Slot}from'@radix-ui/react-slot';import {buttonVariant}from'@firebase-oss/ui-styles';import {twMerge}from'tailwind-merge';import {clsx}from'clsx';import {FactorId,TotpMultiFactorGenerator,PhoneAuthProvider,PhoneMultiFactorGenerator,multiFactor,OAuthProvider,FacebookAuthProvider,GithubAuthProvider,GoogleAuthProvider,TwitterAuthProvider}from'firebase/auth';var tr={version:"7.0.1-beta"};var vt=createContext(void 0);function er({children:t,policies:e}){return jsx(vt.Provider,{value:e,children:t})}function A(){let t=s(),e=useContext(vt);if(!e)return null;let{termsOfServiceUrl:r,privacyPolicyUrl:o,onNavigate:n}=e,a=getTranslation(t,"messages","termsAndPrivacy").split(/(\{tos\}|\{privacy\})/),C=n?jsx("button",{}):jsx("a",{target:"_blank",rel:"noopener noreferrer"});return jsx("div",{className:"fui-policies",children:a.map((y,T)=>y==="{tos}"?cloneElement(C,{key:T,onClick:n?()=>n(r):void 0,href:n?void 0:r,children:getTranslation(t,"labels","termsOfService")}):y==="{privacy}"?cloneElement(C,{key:T,onClick:n?()=>n(o):void 0,href:n?void 0:o,children:getTranslation(t,"labels","privacyPolicy")}):jsx("span",{children:y},T))})}var Pt=createContext(null);function Ge({children:t,ui:e,policies:r}){let o=useStore(e);return jsx(Pt.Provider,{value:o,children:jsx(er,{policies:r,children:t})})}function s(){let t=useContext(Pt);if(!t)throw new Error(`No FirebaseUI context found. Your application must be wrapped in a FirebaseUIProvider:
|
|
2
2
|
|
|
3
3
|
const ui = initializeUI(...);
|
|
4
4
|
|
|
5
5
|
<FirebaseUIProvider ui={ui}>
|
|
6
6
|
<App />
|
|
7
7
|
</FirebaseUIProvider>
|
|
8
|
-
`);return t}function N(t){let r=s().auth;useEffect(()=>r.onAuthStateChanged(o=>{o&&!o.isAnonymous&&t?.(o);}),[r,t]);}function ir(){let t=s();return useMemo(()=>{if(t.redirectError)return t.redirectError instanceof Error?t.redirectError.message:String(t.redirectError)},[t.redirectError])}function sr(){let t=s();return useMemo(()=>createSignInAuthFormSchema(t),[t])}function ar(){let t=s();return useMemo(()=>createSignUpAuthFormSchema(t),[t])}function ur(){let t=s();return useMemo(()=>createForgotPasswordAuthFormSchema(t),[t])}function cr(){let t=s();return useMemo(()=>createEmailLinkAuthFormSchema(t),[t])}function mr(){let t=s();return useMemo(()=>createPhoneAuthNumberFormSchema(t),[t])}function lr(){let t=s();return useMemo(()=>createPhoneAuthVerifyFormSchema(t),[t])}function pr(){let t=s();return useMemo(()=>createMultiFactorPhoneAuthNumberFormSchema(t),[t])}function mt(){let t=s();return useMemo(()=>createMultiFactorPhoneAuthVerifyFormSchema(t),[t])}function fr(){let t=s();return useMemo(()=>createMultiFactorTotpAuthNumberFormSchema(t),[t])}function lt(){let t=s();return useMemo(()=>createMultiFactorTotpAuthVerifyFormSchema(t),[t])}function W(t){let e=s(),r=useRef(null),o=useRef(e),n=useRef(null);return o.current=e,useEffect(()=>{let i=t.current,a=o.current;i!==n.current&&(n.current=i,i?(r.current=getBehavior(a,"recaptchaVerification")(a,i),r.current.render()):r.current=null);},[t]),r.current}function u(...t){return twMerge(clsx(...t))}function x({className:t,variant:e="primary",asChild:r,...o}){return jsx(r?Slot:"button",{className:u(buttonVariant({variant:e}),t),...o})}var{fieldContext:oo,useFieldContext:no,formContext:io,useFormContext:dr}=createFormHookContexts();function so({className:t,...e}){return !e.field.state.meta.isTouched||!e.field.state.meta.errors.length?null:jsx("div",{children:jsx("div",{role:"alert","aria-live":"polite",className:u("fui-error",t),...e,children:e.field.state.meta.errors.map(r=>r.message).join(", ")})})}function ao({children:t,before:e,label:r,action:o,description:n,...i}){let a=no();return jsxs("label",{htmlFor:a.name,children:[jsxs("div",{"data-input-label":true,children:[jsx("div",{children:r}),o?jsx("div",{children:o}):null]}),n?jsx("div",{"data-input-description":true,children:n}):null,jsxs("div",{"data-input-group":true,children:[e,jsx("input",{...i,"aria-invalid":a.state.meta.isTouched&&a.state.meta.errors.length>0,id:a.name,name:a.name,value:a.state.value,onBlur:()=>{a.handleBlur();},onChange:C=>{a.handleChange(C.target.value);}})]}),t?jsx(Fragment,{children:t}):null,jsx(so,{field:a})]})}function uo({className:t,...e}){return jsx("button",{type:"button",...e,className:u("fui-form__action",t)})}function co(t){let e=dr();return jsx(e.Subscribe,{selector:r=>r.isSubmitting,children:r=>jsx(x,{...t,type:"submit",disabled:r})})}function mo(){let t=dr();return jsx(t.Subscribe,{selector:e=>[e.errorMap],children:([e])=>e?.onSubmit&&typeof e.onSubmit=="string"?jsx("div",{className:"fui-error",children:e.onSubmit}):null})}var c=createFormHook({fieldComponents:{Input:ao},formComponents:{SubmitButton:co,ErrorMessage:mo,Action:uo},fieldContext:oo,formContext:io});function Fr(){let t=s();return useCallback(async({email:e})=>{try{return await sendSignInLinkToEmail(t,e)}catch(r){throw r instanceof FirebaseUIError?new Error(r.message):(console.error(r),new Error(getTranslation(t,"errors","unknownError")))}},[t])}function Sr(t){let e=cr(),r=Fr();return c.useAppForm({defaultValues:{email:""},validators:{onBlur:e,onSubmitAsync:async({value:o})=>{try{return await r(o),t?.()}catch(n){return n instanceof Error?n.message:String(n)}}}})}function gr(t){let e=s();useEffect(()=>{(async()=>{let o=await completeEmailLinkSignIn(e,window.location.href);o&&t?.(o);})();},[t]);}function It({onEmailSent:t,onSignIn:e}){let r=s(),[o,n]=useState(false),i=Sr(()=>{n(!0),t?.();});return gr(e),o?jsx("div",{className:"fui-success",children:getTranslation(r,"messages","signInLinkSent")}):jsx("form",{className:"fui-form",onSubmit:async a=>{a.preventDefault(),a.stopPropagation(),await i.handleSubmit();},children:jsxs(i.AppForm,{children:[jsx("fieldset",{children:jsx(i.AppField,{name:"email",children:a=>jsx(a.Input,{label:getTranslation(r,"labels","emailAddress"),type:"email"})})}),jsx(A,{}),jsxs("fieldset",{children:[jsx(i.SubmitButton,{children:getTranslation(r,"labels","sendSignInLink")}),jsx(i.ErrorMessage,{})]})]})})}function yr(){let t=s();return useCallback(async({email:e})=>{try{return await sendPasswordResetEmail(t,e)}catch(r){throw r instanceof FirebaseUIError?new Error(r.message):(console.error(r),new Error(getTranslation(t,"errors","unknownError")))}},[t])}function Ar(t){let e=ur(),r=yr();return c.useAppForm({defaultValues:{email:""},validators:{onBlur:e,onSubmitAsync:async({value:o})=>{try{return await r(o),t?.()}catch(n){return n instanceof Error?n.message:String(n)}}}})}function Mt({onBackToSignInClick:t,onPasswordSent:e}){let r=s(),[o,n]=useState(false),i=Ar(()=>{n(!0),e?.();});return o?jsx("div",{className:"fui-success",children:getTranslation(r,"messages","checkEmailForReset")}):jsx("form",{className:"fui-form",onSubmit:async a=>{a.preventDefault(),a.stopPropagation(),await i.handleSubmit();},children:jsxs(i.AppForm,{children:[jsx("fieldset",{children:jsx(i.AppField,{name:"email",children:a=>jsx(a.Input,{label:getTranslation(r,"labels","emailAddress"),type:"email"})})}),jsx(A,{}),jsxs("fieldset",{children:[jsx(i.SubmitButton,{children:getTranslation(r,"labels","resetPassword")}),jsx(i.ErrorMessage,{})]}),t?jsxs(i.Action,{onClick:t,children:["\u2190 ",getTranslation(r,"labels","backToSignIn")]}):null]})})}function Pr(){let t=s();return useCallback(async({verificationCode:e,hint:r})=>{let o=TotpMultiFactorGenerator.assertionForSignIn(r.uid,e);return await signInWithMultiFactorAssertion(t,o)},[t])}function br({hint:t,onSuccess:e}){let r=Pr(),o=lt();return c.useAppForm({defaultValues:{verificationCode:""},validators:{onBlur:o,onSubmitAsync:async({value:n})=>{try{let i=await r({verificationCode:n.verificationCode,hint:t});return e(i)}catch(i){return i instanceof FirebaseUIError?i.message:String(i)}}}})}function wt(t){let e=s(),r=br({hint:t.hint,onSuccess:o=>{t.onSuccess?.(o);}});return jsx("form",{className:"fui-form",onSubmit:async o=>{o.preventDefault(),o.stopPropagation(),await r.handleSubmit();},children:jsxs(r.AppForm,{children:[jsx("fieldset",{children:jsx(r.AppField,{name:"verificationCode",children:o=>jsx(o.Input,{description:getTranslation(e,"prompts","enterVerificationCode"),label:getTranslation(e,"labels","verificationCode"),type:"text",placeholder:"123456",maxLength:6})})}),jsxs("fieldset",{children:[jsx(r.SubmitButton,{children:getTranslation(e,"labels","verifyCode")}),jsx(r.ErrorMessage,{})]})]})})}function xr(){let t=s();return useCallback(async({hint:e,recaptchaVerifier:r})=>await verifyPhoneNumber(t,"",r,void 0,e),[t])}function Vo({hint:t,recaptchaVerifier:e,onSuccess:r}){let o=xr();return c.useAppForm({validators:{onSubmitAsync:async()=>{try{let n=await o({hint:t,recaptchaVerifier:e});return r(n)}catch(n){return n instanceof FirebaseUIError?n.message:String(n)}}}})}function Bo(t){let e=s(),r=useRef(null),o=W(r),n=Vo({hint:t.hint,recaptchaVerifier:o,onSuccess:t.onSubmit});return jsx("form",{className:"fui-form",onSubmit:async i=>{i.preventDefault(),i.stopPropagation(),await n.handleSubmit();},children:jsxs(n.AppForm,{children:[jsx("fieldset",{children:jsx("label",{children:jsx("div",{"data-input-description":true,children:getTranslation(e,"messages","mfaSmsAssertionPrompt",{phoneNumber:t.hint.phoneNumber||""})})})}),jsx("fieldset",{children:jsx("div",{className:"fui-recaptcha-container",ref:r})}),jsxs("fieldset",{children:[jsx(n.SubmitButton,{children:getTranslation(e,"labels","sendCode")}),jsx(n.ErrorMessage,{})]})]})})}function Mr(){let t=s();return useCallback(async({verificationId:e,verificationCode:r})=>{let o=PhoneAuthProvider.credential(e,r),n=PhoneMultiFactorGenerator.assertion(o);return await signInWithMultiFactorAssertion(t,n)},[t])}function ko({verificationId:t,onSuccess:e}){let r=Mr(),o=mt();return c.useAppForm({defaultValues:{verificationId:t,verificationCode:""},validators:{onBlur:o,onSubmitAsync:async({value:n})=>{try{let i=await r(n);return e(i)}catch(i){return i instanceof FirebaseUIError?i.message:String(i)}}}})}function Ro(t){let e=s(),r=ko({verificationId:t.verificationId,onSuccess:t.onSuccess});return jsx("form",{className:"fui-form",onSubmit:async o=>{o.preventDefault(),o.stopPropagation(),await r.handleSubmit();},children:jsxs(r.AppForm,{children:[jsx("fieldset",{children:jsx(r.AppField,{name:"verificationCode",children:o=>jsx(o.Input,{label:getTranslation(e,"labels","verificationCode"),type:"text",description:getTranslation(e,"prompts","smsVerificationPrompt")})})}),jsxs("fieldset",{children:[jsx(r.SubmitButton,{children:getTranslation(e,"labels","verifyCode")}),jsx(r.ErrorMessage,{})]})]})})}function Nt(t){let[e,r]=useState(null);return e?jsx(Ro,{verificationId:e.verificationId,onSuccess:o=>{t.onSuccess?.(o);}}):jsx(Bo,{hint:t.hint,onSubmit:o=>r({verificationId:o})})}function Nr(){let t=s();useEffect(()=>()=>{t.setMultiFactorResolver();},[]);}function Tt(t){let e=s(),r=e.multiFactorResolver,o=getTranslation(e,"prompts","mfaAssertionFactorPrompt");if(Nr(),!r)throw new Error("MultiFactorAuthAssertionForm requires a multi-factor resolver");let[n,i]=useState(r.hints.length===1?r.hints[0]:void 0);if(n){if(n.factorId===PhoneMultiFactorGenerator.FACTOR_ID)return jsx(Nt,{hint:n,onSuccess:a=>{t.onSuccess?.(a);}});if(n.factorId===TotpMultiFactorGenerator.FACTOR_ID)return jsx(wt,{hint:n,onSuccess:a=>{t.onSuccess?.(a);}})}return jsxs("div",{className:"fui-content",children:[jsx("p",{children:o}),r.hints.map(a=>a.factorId===TotpMultiFactorGenerator.FACTOR_ID?jsx(_o,{onClick:()=>i(a)},a.factorId):a.factorId===PhoneMultiFactorGenerator.FACTOR_ID?jsx(Do,{onClick:()=>i(a)},a.factorId):null)]})}function _o(t){let e=s(),r=getTranslation(e,"labels","mfaTotpVerification");return jsx(x,{...t,children:r})}function Do(t){let e=s(),r=getTranslation(e,"labels","mfaSmsVerification");return jsx(x,{...t,children:r})}function Tr(){let t=s();return getBehavior(t,"countryCodes")().allowedCountries}function Vr(){let t=s();return getBehavior(t,"countryCodes")().defaultCountry}var q=forwardRef(({className:t,...e},r)=>{let o=Tr(),n=Vr(),[i,a]=useState(n),C=useCallback(y=>{let T=o.find(yt=>yt.code===y);a(T);},[o]);return useImperativeHandle(r,()=>({getCountry:()=>i,setCountry:C}),[i,C]),jsx("div",{className:u("fui-country-selector",t),...e,children:jsxs("div",{className:"fui-country-selector__wrapper",children:[jsx("span",{className:"fui-country-selector__flag",children:i.emoji}),jsxs("div",{className:"fui-country-selector__select-wrapper",children:[jsx("span",{className:"fui-country-selector__dial-code",children:i.dialCode}),jsx("select",{className:"fui-country-selector__select",value:i.code,onChange:y=>{let T=o.find(yt=>yt.code===y.target.value);T&&a(T);},children:o.map(y=>jsxs("option",{value:y.code,children:[y.dialCode," (",y.name,")"]},`${y.code}-${y.dialCode}`))})]})]})})});q.displayName="CountrySelector";function Gr(){let t=s();return useCallback(async({phoneNumber:e,recaptchaVerifier:r})=>{let o=multiFactor(t.auth.currentUser);return await verifyPhoneNumber(t,e,r,o)},[t])}function Lr({recaptchaVerifier:t,onSuccess:e,formatPhoneNumber:r}){let o=Gr(),n=pr();return c.useAppForm({defaultValues:{displayName:"",phoneNumber:""},validators:{onBlur:n,onSubmitAsync:async({value:i})=>{try{let a=r?r(i.phoneNumber):i.phoneNumber,C=await o({phoneNumber:a,recaptchaVerifier:t});return e(C,i.displayName)}catch(a){return a instanceof FirebaseUIError?a.message:String(a)}}}})}function jo(t){let e=s(),r=useRef(null),o=W(r),n=useRef(null),i=Lr({recaptchaVerifier:o,onSuccess:t.onSubmit,formatPhoneNumber:a=>formatPhoneNumber(a,n.current.getCountry())});return jsx("form",{className:"fui-form",onSubmit:async a=>{a.preventDefault(),a.stopPropagation(),await i.handleSubmit();},children:jsxs(i.AppForm,{children:[jsx("fieldset",{children:jsx(i.AppField,{name:"displayName",children:a=>jsx(a.Input,{label:getTranslation(e,"labels","displayName"),type:"text"})})}),jsx("fieldset",{children:jsx(i.AppField,{name:"phoneNumber",children:a=>jsx(a.Input,{label:getTranslation(e,"labels","phoneNumber"),type:"tel",before:jsx(q,{ref:n})})})}),jsx("fieldset",{children:jsx("div",{className:"fui-recaptcha-container",ref:r})}),jsxs("fieldset",{children:[jsx(i.SubmitButton,{children:getTranslation(e,"labels","sendCode")}),jsx(i.ErrorMessage,{})]})]})})}function _r(){let t=s();return useCallback(async({verificationId:e,verificationCode:r,displayName:o})=>{let n=PhoneAuthProvider.credential(e,r),i=PhoneMultiFactorGenerator.assertion(n);return await enrollWithMultiFactorAssertion(t,i,o)},[t])}function Dr({verificationId:t,displayName:e,onSuccess:r}){let o=mt(),n=_r();return c.useAppForm({defaultValues:{verificationId:t,verificationCode:""},validators:{onBlur:o,onSubmitAsync:async({value:i})=>{try{return await n({...i,displayName:e}),r()}catch(a){return a instanceof FirebaseUIError?a.message:String(a)}}}})}function Or(t){let e=s(),r=Dr({...t,onSuccess:t.onSuccess});return jsx("form",{className:"fui-form",onSubmit:async o=>{o.preventDefault(),o.stopPropagation(),await r.handleSubmit();},children:jsxs(r.AppForm,{children:[jsx("fieldset",{children:jsx(r.AppField,{name:"verificationCode",children:o=>jsx(o.Input,{description:getTranslation(e,"prompts","smsVerificationPrompt"),label:getTranslation(e,"labels","verificationCode"),type:"text"})})}),jsxs("fieldset",{children:[jsx(r.SubmitButton,{children:getTranslation(e,"labels","verifyCode")}),jsx(r.ErrorMessage,{})]})]})})}function Bt(t){let e=s(),[r,o]=useState(null);if(!e.auth.currentUser)throw new Error("User must be authenticated to enroll with multi-factor authentication");return r?jsx(Or,{...r,onSuccess:()=>{t.onSuccess?.();}}):jsx(jo,{onSubmit:(n,i)=>o({verificationId:n,displayName:i})})}function zr(){let t=s();return useCallback(async()=>await generateTotpSecret(t),[t])}function qr({onSuccess:t}){let e=zr(),r=fr();return c.useAppForm({defaultValues:{displayName:""},validators:{onBlur:r,onSubmitAsync:async({value:o})=>{try{let n=await e();return t(n,o.displayName)}catch(n){return n instanceof FirebaseUIError?n.message:String(n)}}}})}function sn(t){let e=s(),r=qr({onSuccess:t.onSubmit});return jsx("form",{className:"fui-form",onSubmit:async o=>{o.preventDefault(),o.stopPropagation(),await r.handleSubmit();},children:jsxs(r.AppForm,{children:[jsx("fieldset",{children:jsx(r.AppField,{name:"displayName",children:o=>jsx(o.Input,{label:getTranslation(e,"labels","displayName"),type:"text"})})}),jsxs("fieldset",{children:[jsx(r.SubmitButton,{children:getTranslation(e,"labels","generateQrCode")}),jsx(r.ErrorMessage,{})]})]})})}function $r(){let t=s();return useCallback(async({secret:e,verificationCode:r,displayName:o})=>{let n=TotpMultiFactorGenerator.assertionForEnrollment(e,r);return await enrollWithMultiFactorAssertion(t,n,o)},[t])}function Qr({secret:t,displayName:e,onSuccess:r}){let o=lt(),n=$r();return c.useAppForm({defaultValues:{verificationCode:""},validators:{onBlur:o,onSubmitAsync:async({value:i})=>{try{return await n({secret:t,verificationCode:i.verificationCode,displayName:e}),r()}catch(a){return a instanceof FirebaseUIError?a.message:String(a)}}}})}function Jr(t){let e=s(),r=Qr({...t,onSuccess:t.onSuccess}),o=generateTotpQrCode(e,t.secret,t.displayName);return jsxs("form",{className:"fui-form",onSubmit:async n=>{n.preventDefault(),n.stopPropagation(),await r.handleSubmit();},children:[jsxs("div",{className:"fui-qr-code-container",children:[jsx("img",{src:o,alt:"TOTP QR Code"}),jsx("code",{children:t.secret.secretKey.toString()}),jsx("p",{children:getTranslation(e,"prompts","mfaTotpQrCodePrompt")})]}),jsxs(r.AppForm,{children:[jsx("fieldset",{children:jsx(r.AppField,{name:"verificationCode",children:n=>jsx(n.Input,{label:getTranslation(e,"labels","verificationCode"),type:"text",description:getTranslation(e,"prompts","mfaTotpEnrollmentVerificationPrompt")})})}),jsxs("fieldset",{children:[jsx(r.SubmitButton,{children:getTranslation(e,"labels","verifyCode")}),jsx(r.ErrorMessage,{})]})]})]})}function kt(t){let e=s(),[r,o]=useState(null);if(!e.auth.currentUser)throw new Error("User must be authenticated to enroll with multi-factor authentication");return r?jsx(Jr,{...r,onSuccess:()=>{t.onSuccess?.();}}):jsx(sn,{onSubmit:(n,i)=>o({secret:n,displayName:i})})}var un=[FactorId.TOTP,FactorId.PHONE];function Rt(t){let e=t.hints??un;if(e.length===0)throw new Error("MultiFactorAuthEnrollmentForm must have at least one hint");let[r,o]=useState(e.length===1?e[0]:void 0);if(r){if(r===FactorId.TOTP)return jsx(kt,{onSuccess:t.onEnrollment});if(r===FactorId.PHONE)return jsx(Bt,{onSuccess:t.onEnrollment});throw new Error(`Unknown multi-factor enrollment type: ${r}`)}return jsx("div",{className:"fui-content",children:e.map(n=>n===FactorId.TOTP?jsx(cn,{onClick:()=>o(n)},n):n===FactorId.PHONE?jsx(mn,{onClick:()=>o(n)},n):null)})}function cn(t){let e=s(),r=getTranslation(e,"labels","mfaTotpVerification");return jsx(x,{variant:"secondary",...t,children:r})}function mn(t){let e=s(),r=getTranslation(e,"labels","mfaSmsVerification");return jsx(x,{variant:"secondary",...t,children:r})}function jr(){let t=s();return useCallback(async({phoneNumber:e,recaptchaVerifier:r})=>await verifyPhoneNumber(t,e,r),[t])}function te({recaptchaVerifier:t,onSuccess:e,formatPhoneNumber:r}){let o=jr(),n=mr();return c.useAppForm({defaultValues:{phoneNumber:""},validators:{onBlur:n,onSubmitAsync:async({value:i})=>{try{let a=r?r(i.phoneNumber):i.phoneNumber,C=await o({phoneNumber:a,recaptchaVerifier:t});return e(C)}catch(a){return a instanceof FirebaseUIError?a.message:String(a)}}}})}function hn(t){let e=s(),r=useRef(null),o=W(r),n=useRef(null),i=te({recaptchaVerifier:o,onSuccess:t.onSubmit,formatPhoneNumber:a=>formatPhoneNumber(a,n.current.getCountry())});return jsx("form",{className:"fui-form",onSubmit:async a=>{a.preventDefault(),a.stopPropagation(),await i.handleSubmit();},children:jsxs(i.AppForm,{children:[jsx("fieldset",{children:jsx(i.AppField,{name:"phoneNumber",children:a=>jsx(a.Input,{label:getTranslation(e,"labels","phoneNumber"),type:"tel",before:jsx(q,{ref:n})})})}),jsx("fieldset",{children:jsx("div",{className:"fui-recaptcha-container",ref:r})}),jsx(A,{}),jsxs("fieldset",{children:[jsx(i.SubmitButton,{children:getTranslation(e,"labels","sendCode")}),jsx(i.ErrorMessage,{})]})]})})}function re(){let t=s();return useCallback(async({verificationId:e,verificationCode:r})=>await confirmPhoneNumber(t,e,r),[t])}function ee({verificationId:t,onSuccess:e}){let r=lr(),o=re();return c.useAppForm({defaultValues:{verificationId:t,verificationCode:""},validators:{onBlur:r,onSubmitAsync:async({value:n})=>{try{let i=await o(n);return e(i)}catch(i){return i instanceof FirebaseUIError?i.message:String(i)}}}})}function Fn(t){let e=s(),r=ee({verificationId:t.verificationId,onSuccess:t.onSuccess});return jsx("form",{className:"fui-form",onSubmit:async o=>{o.preventDefault(),o.stopPropagation(),await r.handleSubmit();},children:jsxs(r.AppForm,{children:[jsx("fieldset",{children:jsx(r.AppField,{name:"verificationCode",children:o=>jsx(o.Input,{label:getTranslation(e,"labels","verificationCode"),description:getTranslation(e,"prompts","smsVerificationPrompt"),type:"text"})})}),jsxs("fieldset",{children:[jsx(r.SubmitButton,{children:getTranslation(e,"labels","verifyCode")}),jsx(r.ErrorMessage,{})]})]})})}function Gt(t){let[e,r]=useState(null);return e?jsx(Fn,{verificationId:e,onSuccess:o=>{t.onSignIn?.(o);}}):jsx(hn,{onSubmit:r})}function oe(){let t=s();return useCallback(async({email:e,password:r})=>{try{return await signInWithEmailAndPassword(t,e,r)}catch(o){throw o instanceof FirebaseUIError?new Error(o.message):(console.error(o),new Error(getTranslation(t,"errors","unknownError")))}},[t])}function ne(t){let e=sr(),r=oe();return c.useAppForm({defaultValues:{email:"",password:""},validators:{onBlur:e,onSubmitAsync:async({value:o})=>{try{let n=await r(o);return t?.(n)}catch(n){return n instanceof Error?n.message:String(n)}}}})}function _t({onSignIn:t,onForgotPasswordClick:e,onSignUpClick:r}){let o=s(),n=ne(t);return jsx("form",{className:"fui-form",onSubmit:async i=>{i.preventDefault(),i.stopPropagation(),await n.handleSubmit();},children:jsxs(n.AppForm,{children:[jsx("fieldset",{children:jsx(n.AppField,{name:"email",children:i=>jsx(i.Input,{label:getTranslation(o,"labels","emailAddress"),type:"email"})})}),jsx("fieldset",{children:jsx(n.AppField,{name:"password",children:i=>jsx(i.Input,{label:getTranslation(o,"labels","password"),type:"password",action:e?jsx(n.Action,{onClick:e,children:getTranslation(o,"labels","forgotPassword")}):null})})}),jsx(A,{}),jsxs("fieldset",{children:[jsx(n.SubmitButton,{children:getTranslation(o,"labels","signIn")}),jsx(n.ErrorMessage,{})]}),r?jsxs(n.Action,{onClick:r,children:[getTranslation(o,"prompts","noAccount")," ",getTranslation(o,"labels","signUp")]}):null]})})}function Ot(){let t=s();return hasBehavior(t,"requireDisplayName")}function ie(){let t=s();return useCallback(async({email:e,password:r,displayName:o})=>{try{return await createUserWithEmailAndPassword(t,e,r,o)}catch(n){throw n instanceof FirebaseUIError?new Error(n.message):(console.error(n),new Error(getTranslation(t,"errors","unknownError")))}},[t])}function se(t){let e=ar(),r=ie(),o=Ot();return c.useAppForm({defaultValues:{email:"",password:"",displayName:o?"":void 0},validators:{onBlur:e,onSubmitAsync:async({value:n})=>{try{let i=await r(n);return t?.(i)}catch(i){return i instanceof Error?i.message:String(i)}}}})}function Ht({onSignInClick:t,onSignUp:e}){let r=s(),o=se(e),n=Ot();return jsx("form",{className:"fui-form",onSubmit:async i=>{i.preventDefault(),i.stopPropagation(),await o.handleSubmit();},children:jsxs(o.AppForm,{children:[n?jsx("fieldset",{children:jsx(o.AppField,{name:"displayName",children:i=>jsx(i.Input,{label:getTranslation(r,"labels","displayName")})})}):null,jsx("fieldset",{children:jsx(o.AppField,{name:"email",children:i=>jsx(i.Input,{label:getTranslation(r,"labels","emailAddress"),type:"email"})})}),jsx("fieldset",{children:jsx(o.AppField,{name:"password",children:i=>jsx(i.Input,{label:getTranslation(r,"labels","password"),type:"password"})})}),jsx(A,{}),jsxs("fieldset",{children:[jsx(o.SubmitButton,{children:getTranslation(r,"labels","createAccount")}),jsx(o.ErrorMessage,{})]}),t?jsxs(o.Action,{onClick:t,children:[getTranslation(r,"prompts","haveAccount")," ",getTranslation(r,"labels","signIn")]}):null]})})}function U({className:t,children:e,...r}){return e?jsxs("div",{className:u("fui-divider",t),...r,children:[jsx("div",{className:"fui-divider__line"}),jsx("div",{className:"fui-divider__text",children:e}),jsx("div",{className:"fui-divider__line"})]}):jsx("div",{className:u("fui-divider",t),...r,children:jsx("div",{className:"fui-divider__line"})})}function p({children:t,className:e,...r}){return jsx("div",{className:u("fui-card",e),...r,children:t})}function f({children:t,className:e,...r}){return jsx("div",{className:u("fui-card__header",e),...r,children:t})}function d({children:t,className:e,...r}){return jsx("h2",{className:u("fui-card__title",e),...r,children:t})}function h({children:t,className:e,...r}){return jsx("p",{className:u("fui-card__subtitle",e),...r,children:t})}function F({children:t,className:e,...r}){return jsx("div",{className:u("fui-card__content",e),...r,children:t})}function E(){let t=ir();return t?jsx("div",{className:"fui-error",children:t}):null}function w(t){let e=s(),r=getTranslation(e,"labels","multiFactorAssertion"),o=getTranslation(e,"prompts","mfaAssertionPrompt");return jsx("div",{className:"fui-screen",children:jsxs(p,{children:[jsxs(f,{children:[jsx(d,{children:r}),jsx(h,{children:o})]}),jsx(F,{children:jsx(Tt,{...t})})]})})}function xn({children:t,onEmailSent:e,onSignIn:r}){let o=s(),n=getTranslation(o,"labels","signIn"),i=getTranslation(o,"prompts","signInToAccount"),a=o.multiFactorResolver;return N(r),a?jsx(w,{}):jsx("div",{className:"fui-screen",children:jsxs(p,{children:[jsxs(f,{children:[jsx(d,{children:n}),jsx(h,{children:i})]}),jsxs(F,{children:[jsx(It,{onEmailSent:e}),t?jsxs(Fragment,{children:[jsx(U,{children:getTranslation(o,"messages","dividerOr")}),jsxs("div",{className:"fui-screen__children",children:[t,jsx(E,{})]})]}):null]})]})})}function En(t){let e=s(),r=getTranslation(e,"labels","resetPassword"),o=getTranslation(e,"prompts","enterEmailToReset");return jsx("div",{className:"fui-screen",children:jsxs(p,{children:[jsxs(f,{children:[jsx(d,{children:r}),jsx(h,{children:o})]}),jsx(F,{children:jsx(Mt,{...t})})]})})}function wn(t){let e=s(),r=getTranslation(e,"labels","multiFactorEnrollment"),o=getTranslation(e,"prompts","mfaEnrollmentPrompt");return jsx("div",{className:"fui-screen",children:jsxs(p,{children:[jsxs(f,{children:[jsx(d,{children:r}),jsx(h,{children:o})]}),jsx(F,{children:jsx(Rt,{...t})})]})})}function Nn({children:t,onSignIn:e}){let r=s(),o=getTranslation(r,"labels","signIn"),n=getTranslation(r,"prompts","signInToAccount"),i=r.multiFactorResolver;return N(e),i?jsx(w,{}):jsx("div",{className:"fui-screen",children:jsxs(p,{children:[jsxs(f,{children:[jsx(d,{children:o}),jsx(h,{children:n})]}),jsxs(F,{className:"fui-screen__children",children:[t,jsx(E,{}),jsx(A,{})]})]})})}function Un({children:t,...e}){let r=s(),o=getTranslation(r,"labels","signIn"),n=getTranslation(r,"prompts","signInToAccount"),i=r.multiFactorResolver;return N(e.onSignIn),i?jsx(w,{}):jsx("div",{className:"fui-screen",children:jsxs(p,{children:[jsxs(f,{children:[jsx(d,{children:o}),jsx(h,{children:n})]}),jsxs(F,{children:[jsx(Gt,{}),t?jsxs(Fragment,{children:[jsx(U,{children:getTranslation(r,"messages","dividerOr")}),jsxs("div",{className:"fui-screen__children",children:[t,jsx(E,{})]})]}):null]})]})})}function Vn({children:t,onSignIn:e,...r}){let o=s(),n=getTranslation(o,"labels","signIn"),i=getTranslation(o,"prompts","signInToAccount");return N(e),o.multiFactorResolver?jsx(w,{}):jsx("div",{className:"fui-screen",children:jsxs(p,{children:[jsxs(f,{children:[jsx(d,{children:n}),jsx(h,{children:i})]}),jsxs(F,{children:[jsx(_t,{...r}),t?jsxs(Fragment,{children:[jsx(U,{children:getTranslation(o,"messages","dividerOr")}),jsxs("div",{className:"fui-screen__children",children:[t,jsx(E,{})]})]}):null]})]})})}function kn({children:t,onSignUp:e,...r}){let o=s(),n=getTranslation(o,"labels","signUp"),i=getTranslation(o,"prompts","enterDetailsToCreate");return N(e),o.multiFactorResolver?jsx(w,{}):jsx("div",{className:"fui-screen",children:jsxs(p,{children:[jsxs(f,{children:[jsx(d,{children:n}),jsx(h,{children:i})]}),jsxs(F,{children:[jsx(Ht,{...r}),t?jsxs(Fragment,{children:[jsx(U,{children:getTranslation(o,"messages","dividerOr")}),jsxs("div",{className:"fui-screen__children",children:[t,jsx(E,{})]})]}):null]})]})})}function he(t,e){let r=s(),[o,n]=useState(null),i=useCallback(async()=>{n(null);try{let a=await signInWithProvider(r,t);e?.(a);}catch(a){if(a instanceof FirebaseUIError){n(a.message);return}console.error(a),n(getTranslation(r,"errors","unknownError"));}},[r,t,n,e]);return {error:o,callback:i}}function b({provider:t,children:e,themed:r,onSignIn:o}){let n=s(),{error:i,callback:a}=he(t,o);return jsxs("div",{children:[jsx(x,{type:"button",variant:r?"primary":"secondary","data-themed":r,"data-provider":t.providerId,disabled:n.state!=="idle",onClick:a,className:"fui-provider__button",children:e}),i&&jsx("div",{className:"fui-error",children:i})]})}var Wn=t=>jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 50 50",...t,children:jsx("path",{fill:"currentColor",d:"M44.527 34.75c-1.078 2.395-1.597 3.465-2.984 5.578-1.941 2.953-4.68 6.64-8.063 6.664-3.011.028-3.789-1.965-7.878-1.93-4.086.02-4.938 1.97-7.954 1.938-3.386-.031-5.976-3.352-7.918-6.3-5.43-8.27-6.003-17.966-2.648-23.122 2.375-3.656 6.129-5.805 9.656-5.805 3.594 0 5.852 1.973 8.82 1.973 2.883 0 4.637-1.976 8.794-1.976 3.14 0 6.46 1.71 8.836 4.664-7.766 4.257-6.504 15.347 1.34 18.316M31.195 8.469c1.512-1.942 2.66-4.68 2.242-7.469-2.464.168-5.347 1.742-7.03 3.781-1.528 1.86-2.794 4.617-2.302 7.285 2.692.086 5.477-1.52 7.09-3.597"})}),Se=Wn;function $n({provider:t,...e}){let r=s();return jsxs(b,{...e,provider:t||new OAuthProvider("apple.com"),children:[jsx(ge,{}),jsx("span",{children:getTranslation(r,"labels","signInWithApple")})]})}function ge({className:t,...e}){return jsx(Se,{className:u("fui-provider__icon",t),...e})}var Jn=t=>jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 50 50",...t,children:jsx("path",{fill:"currentColor",d:"M25 3C12.85 3 3 12.85 3 25c0 11.03 8.125 20.137 18.712 21.728V30.831h-5.443v-5.783h5.443V21.2c0-6.371 3.104-9.168 8.399-9.168 2.536 0 3.877.188 4.512.274v5.048h-3.612c-2.248 0-3.033 2.131-3.033 4.533v3.161h6.588l-.894 5.783h-5.694v15.944C38.716 45.318 47 36.137 47 25c0-12.15-9.85-22-22-22"})}),Ae=Jn;function Xn({provider:t,...e}){let r=s();return jsxs(b,{...e,provider:t||new FacebookAuthProvider,children:[jsx(ve,{}),jsx("span",{children:getTranslation(r,"labels","signInWithFacebook")})]})}function ve({className:t,...e}){return jsx(Ae,{className:u("fui-provider__icon",t),...e})}var jn=t=>jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",fill:"currentColor",viewBox:"0 0 30 30",...t,children:jsx("path",{d:"M15 3C8.373 3 3 8.373 3 15c0 5.623 3.872 10.328 9.092 11.63a1.8 1.8 0 0 1-.092-.583v-2.051h-1.508c-.821 0-1.551-.353-1.905-1.009-.393-.729-.461-1.844-1.435-2.526-.289-.227-.069-.486.264-.451.615.174 1.125.596 1.605 1.222.478.627.703.769 1.596.769.433 0 1.081-.025 1.691-.121.328-.833.895-1.6 1.588-1.962-3.996-.411-5.903-2.399-5.903-5.098 0-1.162.495-2.286 1.336-3.233-.276-.94-.623-2.857.106-3.587 1.798 0 2.885 1.166 3.146 1.481A9 9 0 0 1 15.495 9c1.036 0 2.024.174 2.922.483C18.675 9.17 19.763 8 21.565 8c.732.731.381 2.656.102 3.594.836.945 1.328 2.066 1.328 3.226 0 2.697-1.904 4.684-5.894 5.097C18.199 20.49 19 22.1 19 23.313v2.734c0 .104-.023.179-.035.268C23.641 24.676 27 20.236 27 15c0-6.627-5.373-12-12-12"})}),be=jn;function ei({provider:t,...e}){let r=s();return jsxs(b,{...e,provider:t||new GithubAuthProvider,children:[jsx(Ce,{}),jsx("span",{children:getTranslation(r,"labels","signInWithGitHub")})]})}function Ce({className:t,...e}){return jsx(be,{className:u("fui-provider__icon",t),...e})}var ni=t=>jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 48 48",...t,children:[jsx("path",{fill:"#FFC107",d:"M43.611 20.083H42V20H24v8h11.303c-1.649 4.657-6.08 8-11.303 8-6.627 0-12-5.373-12-12s5.373-12 12-12c3.059 0 5.842 1.154 7.961 3.039l5.657-5.657C34.046 6.053 29.268 4 24 4 12.955 4 4 12.955 4 24s8.955 20 20 20 20-8.955 20-20c0-1.341-.138-2.65-.389-3.917"}),jsx("path",{fill:"#FF3D00",d:"m6.306 14.691 6.571 4.819C14.655 15.108 18.961 12 24 12c3.059 0 5.842 1.154 7.961 3.039l5.657-5.657C34.046 6.053 29.268 4 24 4 16.318 4 9.656 8.337 6.306 14.691"}),jsx("path",{fill:"#4CAF50",d:"M24 44c5.166 0 9.86-1.977 13.409-5.192l-6.19-5.238A11.9 11.9 0 0 1 24 36c-5.202 0-9.619-3.317-11.283-7.946l-6.522 5.025C9.505 39.556 16.227 44 24 44"}),jsx("path",{fill:"#1976D2",d:"M43.611 20.083H42V20H24v8h11.303a12.04 12.04 0 0 1-4.087 5.571l.003-.002 6.19 5.238C36.971 39.205 44 34 44 24c0-1.341-.138-2.65-.389-3.917"})]}),Ie=ni;function ui({provider:t,...e}){let r=s();return jsxs(b,{...e,provider:t||new GoogleAuthProvider,children:[jsx(xe,{}),jsx("span",{children:getTranslation(r,"labels","signInWithGoogle")})]})}function xe({className:t,...e}){return jsx(Ie,{className:u("fui-provider__icon",t),...e})}var mi=t=>jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 48 48",...t,children:[jsx("path",{fill:"#ff5722",d:"M22 22H6V6h16z"}),jsx("path",{fill:"#4caf50",d:"M42 22H26V6h16z"}),jsx("path",{fill:"#ffc107",d:"M42 42H26V26h16z"}),jsx("path",{fill:"#03a9f4",d:"M22 42H6V26h16z"})]}),Me=mi;function di({provider:t,...e}){let r=s();return jsxs(b,{...e,provider:t||new OAuthProvider("microsoft.com"),children:[jsx(Ee,{}),jsx("span",{children:getTranslation(r,"labels","signInWithMicrosoft")})]})}function Ee({className:t,...e}){return jsx(Me,{className:u("fui-provider__icon",t),...e})}var Fi=t=>jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",fill:"currentColor",viewBox:"0 0 30 30",...t,children:jsx("path",{d:"m26.37 26-8.795-12.822.015.012L25.52 4h-2.65l-6.46 7.48L11.28 4H4.33l8.211 11.971-.001-.001L3.88 26h2.65l7.182-8.322L19.42 26zM10.23 6l12.34 18h-2.1L8.12 6z"})}),Ne=Fi;function yi({provider:t,...e}){let r=s();return jsxs(b,{...e,provider:t||new TwitterAuthProvider,children:[jsx(Ue,{}),jsx("span",{children:getTranslation(r,"labels","signInWithTwitter")})]})}function Ue({className:t,...e}){return jsx(Ne,{className:u("fui-provider__icon",t),...e})}registerFramework("react",tr.version);
|
|
9
|
-
export{ge as AppleLogo,$n as AppleSignInButton,x as Button,p as Card,F as CardContent,f as CardHeader,h as CardSubtitle,d as CardTitle,q as CountrySelector,U as Divider,It as EmailLinkAuthForm,xn as EmailLinkAuthScreen,ve as FacebookLogo,Xn as FacebookSignInButton,Ge as FirebaseUIProvider,Mt as ForgotPasswordAuthForm,En as ForgotPasswordAuthScreen,Ce as GitHubLogo,ei as GitHubSignInButton,xe as GoogleLogo,ui as GoogleSignInButton,Ee as MicrosoftLogo,di as MicrosoftSignInButton,Tt as MultiFactorAuthAssertionForm,w as MultiFactorAuthAssertionScreen,Rt as MultiFactorAuthEnrollmentForm,wn as MultiFactorAuthEnrollmentScreen,Or as MultiFactorEnrollmentVerifyPhoneNumberForm,Jr as MultiFactorEnrollmentVerifyTotpForm,b as OAuthButton,Nn as OAuthScreen,Gt as PhoneAuthForm,Un as PhoneAuthScreen,A as Policies,vt as PolicyContext,E as RedirectError,_t as SignInAuthForm,Vn as SignInAuthScreen,Ht as SignUpAuthForm,kn as SignUpAuthScreen,Nt as SmsMultiFactorAssertionForm,Bt as SmsMultiFactorEnrollmentForm,wt as TotpMultiFactorAssertionForm,kt as TotpMultiFactorEnrollmentForm,Ue as TwitterLogo,yi as TwitterSignInButton,
|
|
8
|
+
`);return t}function N(t){let r=s().auth;useEffect(()=>r.onAuthStateChanged(o=>{o&&!o.isAnonymous&&t?.(o);}),[r,t]);}function ir(){let t=s();return useMemo(()=>{if(t.redirectError)return t.redirectError instanceof Error?t.redirectError.message:String(t.redirectError)},[t.redirectError])}function sr(){let t=s();return useMemo(()=>createSignInAuthFormSchema(t),[t])}function ar(){let t=s();return useMemo(()=>createSignUpAuthFormSchema(t),[t])}function ur(){let t=s();return useMemo(()=>createForgotPasswordAuthFormSchema(t),[t])}function mr(){let t=s();return useMemo(()=>createEmailLinkAuthFormSchema(t),[t])}function cr(){let t=s();return useMemo(()=>createPhoneAuthNumberFormSchema(t),[t])}function lr(){let t=s();return useMemo(()=>createPhoneAuthVerifyFormSchema(t),[t])}function pr(){let t=s();return useMemo(()=>createMultiFactorPhoneAuthNumberFormSchema(t),[t])}function ct(){let t=s();return useMemo(()=>createMultiFactorPhoneAuthVerifyFormSchema(t),[t])}function fr(){let t=s();return useMemo(()=>createMultiFactorTotpAuthNumberFormSchema(t),[t])}function lt(){let t=s();return useMemo(()=>createMultiFactorTotpAuthVerifyFormSchema(t),[t])}function W(t){let e=s(),r=useRef(null),o=useRef(e),n=useRef(null);return o.current=e,useEffect(()=>{let i=t.current,a=o.current;i!==n.current&&(n.current=i,i?(r.current=getBehavior(a,"recaptchaVerification")(a,i),r.current.render()):r.current=null);},[t]),r.current}function u(...t){return twMerge(clsx(...t))}function x({className:t,variant:e="primary",asChild:r,...o}){return jsx(r?Slot:"button",{className:u(buttonVariant({variant:e}),t),...o})}var{fieldContext:oo,useFieldContext:no,formContext:io,useFormContext:dr}=createFormHookContexts();function so({className:t,...e}){return !e.field.state.meta.isTouched||!e.field.state.meta.errors.length?null:jsx("div",{children:jsx("div",{role:"alert","aria-live":"polite",className:u("fui-error",t),...e,children:e.field.state.meta.errors.map(r=>r.message).join(", ")})})}function ao({children:t,before:e,label:r,action:o,description:n,...i}){let a=no();return jsxs("label",{htmlFor:a.name,children:[jsxs("div",{"data-input-label":true,children:[jsx("div",{children:r}),o?jsx("div",{children:o}):null]}),n?jsx("div",{"data-input-description":true,children:n}):null,jsxs("div",{"data-input-group":true,children:[e,jsx("input",{...i,"aria-invalid":a.state.meta.isTouched&&a.state.meta.errors.length>0,id:a.name,name:a.name,value:a.state.value,onBlur:()=>{a.handleBlur();},onChange:C=>{a.handleChange(C.target.value);}})]}),t?jsx(Fragment,{children:t}):null,jsx(so,{field:a})]})}function uo({className:t,...e}){return jsx("button",{type:"button",...e,className:u("fui-form__action",t)})}function mo(t){let e=dr();return jsx(e.Subscribe,{selector:r=>r.isSubmitting,children:r=>jsx(x,{...t,type:"submit",disabled:r})})}function co(){let t=dr();return jsx(t.Subscribe,{selector:e=>[e.errorMap],children:([e])=>e?.onSubmit&&typeof e.onSubmit=="string"?jsx("div",{className:"fui-error",children:e.onSubmit}):null})}var m=createFormHook({fieldComponents:{Input:ao},formComponents:{SubmitButton:mo,ErrorMessage:co,Action:uo},fieldContext:oo,formContext:io});function Fr(){let t=s();return useCallback(async({email:e})=>{try{return await sendSignInLinkToEmail(t,e)}catch(r){throw r instanceof FirebaseUIError?new Error(r.message):(console.error(r),new Error(getTranslation(t,"errors","unknownError")))}},[t])}function Sr(t){let e=mr(),r=Fr();return m.useAppForm({defaultValues:{email:""},validators:{onBlur:e,onSubmitAsync:async({value:o})=>{try{return await r(o),t?.()}catch(n){return n instanceof Error?n.message:String(n)}}}})}function gr(t){let e=s();useEffect(()=>{(async()=>{let o=await completeEmailLinkSignIn(e,window.location.href);o&&t?.(o);})();},[t]);}function It({onEmailSent:t,onSignIn:e}){let r=s(),[o,n]=useState(false),i=Sr(()=>{n(!0),t?.();});return gr(e),o?jsx("div",{className:"fui-success",children:getTranslation(r,"messages","signInLinkSent")}):jsx("form",{className:"fui-form",onSubmit:async a=>{a.preventDefault(),a.stopPropagation(),await i.handleSubmit();},children:jsxs(i.AppForm,{children:[jsx("fieldset",{children:jsx(i.AppField,{name:"email",children:a=>jsx(a.Input,{label:getTranslation(r,"labels","emailAddress"),type:"email"})})}),jsx(A,{}),jsxs("fieldset",{children:[jsx(i.SubmitButton,{children:getTranslation(r,"labels","sendSignInLink")}),jsx(i.ErrorMessage,{})]})]})})}function yr(){let t=s();return useCallback(async({email:e})=>{try{return await sendPasswordResetEmail(t,e)}catch(r){throw r instanceof FirebaseUIError?new Error(r.message):(console.error(r),new Error(getTranslation(t,"errors","unknownError")))}},[t])}function Ar(t){let e=ur(),r=yr();return m.useAppForm({defaultValues:{email:""},validators:{onBlur:e,onSubmitAsync:async({value:o})=>{try{return await r(o),t?.()}catch(n){return n instanceof Error?n.message:String(n)}}}})}function Mt({onBackToSignInClick:t,onPasswordSent:e}){let r=s(),[o,n]=useState(false),i=Ar(()=>{n(!0),e?.();});return o?jsx("div",{className:"fui-success",children:getTranslation(r,"messages","checkEmailForReset")}):jsx("form",{className:"fui-form",onSubmit:async a=>{a.preventDefault(),a.stopPropagation(),await i.handleSubmit();},children:jsxs(i.AppForm,{children:[jsx("fieldset",{children:jsx(i.AppField,{name:"email",children:a=>jsx(a.Input,{label:getTranslation(r,"labels","emailAddress"),type:"email"})})}),jsx(A,{}),jsxs("fieldset",{children:[jsx(i.SubmitButton,{children:getTranslation(r,"labels","resetPassword")}),jsx(i.ErrorMessage,{})]}),t?jsxs(i.Action,{onClick:t,children:["\u2190 ",getTranslation(r,"labels","backToSignIn")]}):null]})})}function Pr(){let t=s();return useCallback(async({verificationCode:e,hint:r})=>{let o=TotpMultiFactorGenerator.assertionForSignIn(r.uid,e);return await signInWithMultiFactorAssertion(t,o)},[t])}function br({hint:t,onSuccess:e}){let r=Pr(),o=lt();return m.useAppForm({defaultValues:{verificationCode:""},validators:{onBlur:o,onSubmitAsync:async({value:n})=>{try{let i=await r({verificationCode:n.verificationCode,hint:t});return e(i)}catch(i){return i instanceof FirebaseUIError?i.message:String(i)}}}})}function wt(t){let e=s(),r=br({hint:t.hint,onSuccess:o=>{t.onSuccess?.(o);}});return jsx("form",{className:"fui-form",onSubmit:async o=>{o.preventDefault(),o.stopPropagation(),await r.handleSubmit();},children:jsxs(r.AppForm,{children:[jsx("fieldset",{children:jsx(r.AppField,{name:"verificationCode",children:o=>jsx(o.Input,{description:getTranslation(e,"prompts","enterVerificationCode"),label:getTranslation(e,"labels","verificationCode"),type:"text",placeholder:"123456",maxLength:6})})}),jsxs("fieldset",{children:[jsx(r.SubmitButton,{children:getTranslation(e,"labels","verifyCode")}),jsx(r.ErrorMessage,{})]})]})})}function xr(){let t=s();return useCallback(async({hint:e,recaptchaVerifier:r})=>await verifyPhoneNumber(t,"",r,void 0,e),[t])}function Vo({hint:t,recaptchaVerifier:e,onSuccess:r}){let o=xr();return m.useAppForm({validators:{onSubmitAsync:async()=>{try{let n=await o({hint:t,recaptchaVerifier:e});return r(n)}catch(n){return n instanceof FirebaseUIError?n.message:String(n)}}}})}function Bo(t){let e=s(),r=useRef(null),o=W(r),n=Vo({hint:t.hint,recaptchaVerifier:o,onSuccess:t.onSubmit});return jsx("form",{className:"fui-form",onSubmit:async i=>{i.preventDefault(),i.stopPropagation(),await n.handleSubmit();},children:jsxs(n.AppForm,{children:[jsx("fieldset",{children:jsx("label",{children:jsx("div",{"data-input-description":true,children:getTranslation(e,"messages","mfaSmsAssertionPrompt",{phoneNumber:t.hint.phoneNumber||""})})})}),jsx("fieldset",{children:jsx("div",{className:"fui-recaptcha-container",ref:r})}),jsxs("fieldset",{children:[jsx(n.SubmitButton,{children:getTranslation(e,"labels","sendCode")}),jsx(n.ErrorMessage,{})]})]})})}function Mr(){let t=s();return useCallback(async({verificationId:e,verificationCode:r})=>{let o=PhoneAuthProvider.credential(e,r),n=PhoneMultiFactorGenerator.assertion(o);return await signInWithMultiFactorAssertion(t,n)},[t])}function ko({verificationId:t,onSuccess:e}){let r=Mr(),o=ct();return m.useAppForm({defaultValues:{verificationId:t,verificationCode:""},validators:{onBlur:o,onSubmitAsync:async({value:n})=>{try{let i=await r(n);return e(i)}catch(i){return i instanceof FirebaseUIError?i.message:String(i)}}}})}function Ro(t){let e=s(),r=ko({verificationId:t.verificationId,onSuccess:t.onSuccess});return jsx("form",{className:"fui-form",onSubmit:async o=>{o.preventDefault(),o.stopPropagation(),await r.handleSubmit();},children:jsxs(r.AppForm,{children:[jsx("fieldset",{children:jsx(r.AppField,{name:"verificationCode",children:o=>jsx(o.Input,{label:getTranslation(e,"labels","verificationCode"),type:"text",description:getTranslation(e,"prompts","smsVerificationPrompt")})})}),jsxs("fieldset",{children:[jsx(r.SubmitButton,{children:getTranslation(e,"labels","verifyCode")}),jsx(r.ErrorMessage,{})]})]})})}function Nt(t){let[e,r]=useState(null);return e?jsx(Ro,{verificationId:e.verificationId,onSuccess:o=>{t.onSuccess?.(o);}}):jsx(Bo,{hint:t.hint,onSubmit:o=>r({verificationId:o})})}function Nr(){let t=s();useEffect(()=>()=>{t.setMultiFactorResolver();},[]);}function Tt(t){let e=s(),r=e.multiFactorResolver,o=getTranslation(e,"prompts","mfaAssertionFactorPrompt");if(Nr(),!r)throw new Error("MultiFactorAuthAssertionForm requires a multi-factor resolver");let[n,i]=useState(r.hints.length===1?r.hints[0]:void 0);if(n){if(n.factorId===PhoneMultiFactorGenerator.FACTOR_ID)return jsx(Nt,{hint:n,onSuccess:a=>{t.onSuccess?.(a);}});if(n.factorId===TotpMultiFactorGenerator.FACTOR_ID)return jsx(wt,{hint:n,onSuccess:a=>{t.onSuccess?.(a);}})}return jsxs("div",{className:"fui-content",children:[jsx("p",{children:o}),r.hints.map(a=>a.factorId===TotpMultiFactorGenerator.FACTOR_ID?jsx(_o,{onClick:()=>i(a)},a.factorId):a.factorId===PhoneMultiFactorGenerator.FACTOR_ID?jsx(Do,{onClick:()=>i(a)},a.factorId):null)]})}function _o(t){let e=s(),r=getTranslation(e,"labels","mfaTotpVerification");return jsx(x,{...t,children:r})}function Do(t){let e=s(),r=getTranslation(e,"labels","mfaSmsVerification");return jsx(x,{...t,children:r})}function Tr(){let t=s();return getBehavior(t,"countryCodes")().allowedCountries}function Vr(){let t=s();return getBehavior(t,"countryCodes")().defaultCountry}var q=forwardRef(({className:t,...e},r)=>{let o=Tr(),n=Vr(),[i,a]=useState(n),C=useCallback(y=>{let T=o.find(yt=>yt.code===y);a(T);},[o]);return useImperativeHandle(r,()=>({getCountry:()=>i,setCountry:C}),[i,C]),jsx("div",{className:u("fui-country-selector",t),...e,children:jsxs("div",{className:"fui-country-selector__wrapper",children:[jsx("span",{className:"fui-country-selector__flag",children:i.emoji}),jsxs("div",{className:"fui-country-selector__select-wrapper",children:[jsx("span",{className:"fui-country-selector__dial-code",children:i.dialCode}),jsx("select",{className:"fui-country-selector__select",value:i.code,onChange:y=>{let T=o.find(yt=>yt.code===y.target.value);T&&a(T);},children:o.map(y=>jsxs("option",{value:y.code,children:[y.dialCode," (",y.name,")"]},`${y.code}-${y.dialCode}`))})]})]})})});q.displayName="CountrySelector";function Gr(){let t=s();return useCallback(async({phoneNumber:e,recaptchaVerifier:r})=>{let o=multiFactor(t.auth.currentUser);return await verifyPhoneNumber(t,e,r,o)},[t])}function Lr({recaptchaVerifier:t,onSuccess:e,formatPhoneNumber:r}){let o=Gr(),n=pr();return m.useAppForm({defaultValues:{displayName:"",phoneNumber:""},validators:{onBlur:n,onSubmitAsync:async({value:i})=>{try{let a=r?r(i.phoneNumber):i.phoneNumber,C=await o({phoneNumber:a,recaptchaVerifier:t});return e(C,i.displayName)}catch(a){return a instanceof FirebaseUIError?a.message:String(a)}}}})}function jo(t){let e=s(),r=useRef(null),o=W(r),n=useRef(null),i=Lr({recaptchaVerifier:o,onSuccess:t.onSubmit,formatPhoneNumber:a=>formatPhoneNumber(a,n.current.getCountry())});return jsx("form",{className:"fui-form",onSubmit:async a=>{a.preventDefault(),a.stopPropagation(),await i.handleSubmit();},children:jsxs(i.AppForm,{children:[jsx("fieldset",{children:jsx(i.AppField,{name:"displayName",children:a=>jsx(a.Input,{label:getTranslation(e,"labels","displayName"),type:"text"})})}),jsx("fieldset",{children:jsx(i.AppField,{name:"phoneNumber",children:a=>jsx(a.Input,{label:getTranslation(e,"labels","phoneNumber"),type:"tel",before:jsx(q,{ref:n})})})}),jsx("fieldset",{children:jsx("div",{className:"fui-recaptcha-container",ref:r})}),jsxs("fieldset",{children:[jsx(i.SubmitButton,{children:getTranslation(e,"labels","sendCode")}),jsx(i.ErrorMessage,{})]})]})})}function _r(){let t=s();return useCallback(async({verificationId:e,verificationCode:r,displayName:o})=>{let n=PhoneAuthProvider.credential(e,r),i=PhoneMultiFactorGenerator.assertion(n);return await enrollWithMultiFactorAssertion(t,i,o)},[t])}function Dr({verificationId:t,displayName:e,onSuccess:r}){let o=ct(),n=_r();return m.useAppForm({defaultValues:{verificationId:t,verificationCode:""},validators:{onBlur:o,onSubmitAsync:async({value:i})=>{try{return await n({...i,displayName:e}),r()}catch(a){return a instanceof FirebaseUIError?a.message:String(a)}}}})}function Or(t){let e=s(),r=Dr({...t,onSuccess:t.onSuccess});return jsx("form",{className:"fui-form",onSubmit:async o=>{o.preventDefault(),o.stopPropagation(),await r.handleSubmit();},children:jsxs(r.AppForm,{children:[jsx("fieldset",{children:jsx(r.AppField,{name:"verificationCode",children:o=>jsx(o.Input,{description:getTranslation(e,"prompts","smsVerificationPrompt"),label:getTranslation(e,"labels","verificationCode"),type:"text"})})}),jsxs("fieldset",{children:[jsx(r.SubmitButton,{children:getTranslation(e,"labels","verifyCode")}),jsx(r.ErrorMessage,{})]})]})})}function Bt(t){let e=s(),[r,o]=useState(null);if(!e.auth.currentUser)throw new Error("User must be authenticated to enroll with multi-factor authentication");return r?jsx(Or,{...r,onSuccess:()=>{t.onSuccess?.();}}):jsx(jo,{onSubmit:(n,i)=>o({verificationId:n,displayName:i})})}function zr(){let t=s();return useCallback(async()=>await generateTotpSecret(t),[t])}function qr({onSuccess:t}){let e=zr(),r=fr();return m.useAppForm({defaultValues:{displayName:""},validators:{onBlur:r,onSubmitAsync:async({value:o})=>{try{let n=await e();return t(n,o.displayName)}catch(n){return n instanceof FirebaseUIError?n.message:String(n)}}}})}function sn(t){let e=s(),r=qr({onSuccess:t.onSubmit});return jsx("form",{className:"fui-form",onSubmit:async o=>{o.preventDefault(),o.stopPropagation(),await r.handleSubmit();},children:jsxs(r.AppForm,{children:[jsx("fieldset",{children:jsx(r.AppField,{name:"displayName",children:o=>jsx(o.Input,{label:getTranslation(e,"labels","displayName"),type:"text"})})}),jsxs("fieldset",{children:[jsx(r.SubmitButton,{children:getTranslation(e,"labels","generateQrCode")}),jsx(r.ErrorMessage,{})]})]})})}function $r(){let t=s();return useCallback(async({secret:e,verificationCode:r,displayName:o})=>{let n=TotpMultiFactorGenerator.assertionForEnrollment(e,r);return await enrollWithMultiFactorAssertion(t,n,o)},[t])}function Qr({secret:t,displayName:e,onSuccess:r}){let o=lt(),n=$r();return m.useAppForm({defaultValues:{verificationCode:""},validators:{onBlur:o,onSubmitAsync:async({value:i})=>{try{return await n({secret:t,verificationCode:i.verificationCode,displayName:e}),r()}catch(a){return a instanceof FirebaseUIError?a.message:String(a)}}}})}function Jr(t){let e=s(),r=Qr({...t,onSuccess:t.onSuccess}),o=generateTotpQrCode(e,t.secret,t.displayName);return jsxs("form",{className:"fui-form",onSubmit:async n=>{n.preventDefault(),n.stopPropagation(),await r.handleSubmit();},children:[jsxs("div",{className:"fui-qr-code-container",children:[jsx("img",{src:o,alt:"TOTP QR Code"}),jsx("code",{children:t.secret.secretKey.toString()}),jsx("p",{children:getTranslation(e,"prompts","mfaTotpQrCodePrompt")})]}),jsxs(r.AppForm,{children:[jsx("fieldset",{children:jsx(r.AppField,{name:"verificationCode",children:n=>jsx(n.Input,{label:getTranslation(e,"labels","verificationCode"),type:"text",description:getTranslation(e,"prompts","mfaTotpEnrollmentVerificationPrompt")})})}),jsxs("fieldset",{children:[jsx(r.SubmitButton,{children:getTranslation(e,"labels","verifyCode")}),jsx(r.ErrorMessage,{})]})]})]})}function kt(t){let e=s(),[r,o]=useState(null);if(!e.auth.currentUser)throw new Error("User must be authenticated to enroll with multi-factor authentication");return r?jsx(Jr,{...r,onSuccess:()=>{t.onSuccess?.();}}):jsx(sn,{onSubmit:(n,i)=>o({secret:n,displayName:i})})}var un=[FactorId.TOTP,FactorId.PHONE];function Rt(t){let e=t.hints??un;if(e.length===0)throw new Error("MultiFactorAuthEnrollmentForm must have at least one hint");let[r,o]=useState(e.length===1?e[0]:void 0);if(r){if(r===FactorId.TOTP)return jsx(kt,{onSuccess:t.onEnrollment});if(r===FactorId.PHONE)return jsx(Bt,{onSuccess:t.onEnrollment});throw new Error(`Unknown multi-factor enrollment type: ${r}`)}return jsx("div",{className:"fui-content",children:e.map(n=>n===FactorId.TOTP?jsx(mn,{onClick:()=>o(n)},n):n===FactorId.PHONE?jsx(cn,{onClick:()=>o(n)},n):null)})}function mn(t){let e=s(),r=getTranslation(e,"labels","mfaTotpVerification");return jsx(x,{variant:"secondary",...t,children:r})}function cn(t){let e=s(),r=getTranslation(e,"labels","mfaSmsVerification");return jsx(x,{variant:"secondary",...t,children:r})}function jr(){let t=s();return useCallback(async({phoneNumber:e,recaptchaVerifier:r})=>await verifyPhoneNumber(t,e,r),[t])}function te({recaptchaVerifier:t,onSuccess:e,formatPhoneNumber:r}){let o=jr(),n=cr();return m.useAppForm({defaultValues:{phoneNumber:""},validators:{onBlur:n,onSubmitAsync:async({value:i})=>{try{let a=r?r(i.phoneNumber):i.phoneNumber,C=await o({phoneNumber:a,recaptchaVerifier:t});return e(C)}catch(a){return a instanceof FirebaseUIError?a.message:String(a)}}}})}function hn(t){let e=s(),r=useRef(null),o=W(r),n=useRef(null),i=te({recaptchaVerifier:o,onSuccess:t.onSubmit,formatPhoneNumber:a=>formatPhoneNumber(a,n.current.getCountry())});return jsx("form",{className:"fui-form",onSubmit:async a=>{a.preventDefault(),a.stopPropagation(),await i.handleSubmit();},children:jsxs(i.AppForm,{children:[jsx("fieldset",{children:jsx(i.AppField,{name:"phoneNumber",children:a=>jsx(a.Input,{label:getTranslation(e,"labels","phoneNumber"),type:"tel",before:jsx(q,{ref:n})})})}),jsx("fieldset",{children:jsx("div",{className:"fui-recaptcha-container",ref:r})}),jsx(A,{}),jsxs("fieldset",{children:[jsx(i.SubmitButton,{children:getTranslation(e,"labels","sendCode")}),jsx(i.ErrorMessage,{})]})]})})}function re(){let t=s();return useCallback(async({verificationId:e,verificationCode:r})=>await confirmPhoneNumber(t,e,r),[t])}function ee({verificationId:t,onSuccess:e}){let r=lr(),o=re();return m.useAppForm({defaultValues:{verificationId:t,verificationCode:""},validators:{onBlur:r,onSubmitAsync:async({value:n})=>{try{let i=await o(n);return e(i)}catch(i){return i instanceof FirebaseUIError?i.message:String(i)}}}})}function Fn(t){let e=s(),r=ee({verificationId:t.verificationId,onSuccess:t.onSuccess});return jsx("form",{className:"fui-form",onSubmit:async o=>{o.preventDefault(),o.stopPropagation(),await r.handleSubmit();},children:jsxs(r.AppForm,{children:[jsx("fieldset",{children:jsx(r.AppField,{name:"verificationCode",children:o=>jsx(o.Input,{label:getTranslation(e,"labels","verificationCode"),description:getTranslation(e,"prompts","smsVerificationPrompt"),type:"text"})})}),jsxs("fieldset",{children:[jsx(r.SubmitButton,{children:getTranslation(e,"labels","verifyCode")}),jsx(r.ErrorMessage,{})]})]})})}function Gt(t){let[e,r]=useState(null);return e?jsx(Fn,{verificationId:e,onSuccess:o=>{t.onSignIn?.(o);}}):jsx(hn,{onSubmit:r})}function oe(){let t=s();return useCallback(async({email:e,password:r})=>{try{return await signInWithEmailAndPassword(t,e,r)}catch(o){throw o instanceof FirebaseUIError?new Error(o.message):(console.error(o),new Error(getTranslation(t,"errors","unknownError")))}},[t])}function ne(t){let e=sr(),r=oe();return m.useAppForm({defaultValues:{email:"",password:""},validators:{onBlur:e,onSubmitAsync:async({value:o})=>{try{let n=await r(o);return t?.(n)}catch(n){return n instanceof Error?n.message:String(n)}}}})}function _t({onSignIn:t,onForgotPasswordClick:e,onSignUpClick:r}){let o=s(),n=ne(t);return jsx("form",{className:"fui-form",onSubmit:async i=>{i.preventDefault(),i.stopPropagation(),await n.handleSubmit();},children:jsxs(n.AppForm,{children:[jsx("fieldset",{children:jsx(n.AppField,{name:"email",children:i=>jsx(i.Input,{label:getTranslation(o,"labels","emailAddress"),type:"email"})})}),jsx("fieldset",{children:jsx(n.AppField,{name:"password",children:i=>jsx(i.Input,{label:getTranslation(o,"labels","password"),type:"password",action:e?jsx(n.Action,{onClick:e,children:getTranslation(o,"labels","forgotPassword")}):null})})}),jsx(A,{}),jsxs("fieldset",{children:[jsx(n.SubmitButton,{children:getTranslation(o,"labels","signIn")}),jsx(n.ErrorMessage,{})]}),r?jsxs(n.Action,{onClick:r,children:[getTranslation(o,"prompts","noAccount")," ",getTranslation(o,"labels","signUp")]}):null]})})}function Ot(){let t=s();return hasBehavior(t,"requireDisplayName")}function ie(){let t=s();return useCallback(async({email:e,password:r,displayName:o})=>{try{return await createUserWithEmailAndPassword(t,e,r,o)}catch(n){throw n instanceof FirebaseUIError?new Error(n.message):(console.error(n),new Error(getTranslation(t,"errors","unknownError")))}},[t])}function se(t){let e=ar(),r=ie(),o=Ot();return m.useAppForm({defaultValues:{email:"",password:"",displayName:o?"":void 0},validators:{onBlur:e,onSubmitAsync:async({value:n})=>{try{let i=await r(n);return t?.(i)}catch(i){return i instanceof Error?i.message:String(i)}}}})}function Ht({onSignInClick:t,onSignUp:e}){let r=s(),o=se(e),n=Ot();return jsx("form",{className:"fui-form",onSubmit:async i=>{i.preventDefault(),i.stopPropagation(),await o.handleSubmit();},children:jsxs(o.AppForm,{children:[n?jsx("fieldset",{children:jsx(o.AppField,{name:"displayName",children:i=>jsx(i.Input,{label:getTranslation(r,"labels","displayName")})})}):null,jsx("fieldset",{children:jsx(o.AppField,{name:"email",children:i=>jsx(i.Input,{label:getTranslation(r,"labels","emailAddress"),type:"email"})})}),jsx("fieldset",{children:jsx(o.AppField,{name:"password",children:i=>jsx(i.Input,{label:getTranslation(r,"labels","password"),type:"password"})})}),jsx(A,{}),jsxs("fieldset",{children:[jsx(o.SubmitButton,{children:getTranslation(r,"labels","createAccount")}),jsx(o.ErrorMessage,{})]}),t?jsxs(o.Action,{onClick:t,children:[getTranslation(r,"prompts","haveAccount")," ",getTranslation(r,"labels","signIn")]}):null]})})}function U({className:t,children:e,...r}){return e?jsxs("div",{className:u("fui-divider",t),...r,children:[jsx("div",{className:"fui-divider__line"}),jsx("div",{className:"fui-divider__text",children:e}),jsx("div",{className:"fui-divider__line"})]}):jsx("div",{className:u("fui-divider",t),...r,children:jsx("div",{className:"fui-divider__line"})})}function p({children:t,className:e,...r}){return jsx("div",{className:u("fui-card",e),...r,children:t})}function f({children:t,className:e,...r}){return jsx("div",{className:u("fui-card__header",e),...r,children:t})}function d({children:t,className:e,...r}){return jsx("h2",{className:u("fui-card__title",e),...r,children:t})}function h({children:t,className:e,...r}){return jsx("p",{className:u("fui-card__subtitle",e),...r,children:t})}function F({children:t,className:e,...r}){return jsx("div",{className:u("fui-card__content",e),...r,children:t})}function E(){let t=ir();return t?jsx("div",{className:"fui-error",children:t}):null}function w(t){let e=s(),r=getTranslation(e,"labels","multiFactorAssertion"),o=getTranslation(e,"prompts","mfaAssertionPrompt");return jsx("div",{className:"fui-screen",children:jsxs(p,{children:[jsxs(f,{children:[jsx(d,{children:r}),jsx(h,{children:o})]}),jsx(F,{children:jsx(Tt,{...t})})]})})}function xn({children:t,onEmailSent:e,onSignIn:r}){let o=s(),n=getTranslation(o,"labels","signIn"),i=getTranslation(o,"prompts","signInToAccount"),a=o.multiFactorResolver;return N(r),a?jsx(w,{}):jsx("div",{className:"fui-screen",children:jsxs(p,{children:[jsxs(f,{children:[jsx(d,{children:n}),jsx(h,{children:i})]}),jsxs(F,{children:[jsx(It,{onEmailSent:e}),t?jsxs(Fragment,{children:[jsx(U,{children:getTranslation(o,"messages","dividerOr")}),jsxs("div",{className:"fui-screen__children",children:[t,jsx(E,{})]})]}):null]})]})})}function En(t){let e=s(),r=getTranslation(e,"labels","resetPassword"),o=getTranslation(e,"prompts","enterEmailToReset");return jsx("div",{className:"fui-screen",children:jsxs(p,{children:[jsxs(f,{children:[jsx(d,{children:r}),jsx(h,{children:o})]}),jsx(F,{children:jsx(Mt,{...t})})]})})}function wn(t){let e=s(),r=getTranslation(e,"labels","multiFactorEnrollment"),o=getTranslation(e,"prompts","mfaEnrollmentPrompt");return jsx("div",{className:"fui-screen",children:jsxs(p,{children:[jsxs(f,{children:[jsx(d,{children:r}),jsx(h,{children:o})]}),jsx(F,{children:jsx(Rt,{...t})})]})})}function Nn({children:t,onSignIn:e}){let r=s(),o=getTranslation(r,"labels","signIn"),n=getTranslation(r,"prompts","signInToAccount"),i=r.multiFactorResolver;return N(e),i?jsx(w,{}):jsx("div",{className:"fui-screen",children:jsxs(p,{children:[jsxs(f,{children:[jsx(d,{children:o}),jsx(h,{children:n})]}),jsxs(F,{className:"fui-screen__children",children:[t,jsx(E,{}),jsx(A,{})]})]})})}function Un({children:t,...e}){let r=s(),o=getTranslation(r,"labels","signIn"),n=getTranslation(r,"prompts","signInToAccount"),i=r.multiFactorResolver;return N(e.onSignIn),i?jsx(w,{}):jsx("div",{className:"fui-screen",children:jsxs(p,{children:[jsxs(f,{children:[jsx(d,{children:o}),jsx(h,{children:n})]}),jsxs(F,{children:[jsx(Gt,{}),t?jsxs(Fragment,{children:[jsx(U,{children:getTranslation(r,"messages","dividerOr")}),jsxs("div",{className:"fui-screen__children",children:[t,jsx(E,{})]})]}):null]})]})})}function Vn({children:t,onSignIn:e,...r}){let o=s(),n=getTranslation(o,"labels","signIn"),i=getTranslation(o,"prompts","signInToAccount");return N(e),o.multiFactorResolver?jsx(w,{}):jsx("div",{className:"fui-screen",children:jsxs(p,{children:[jsxs(f,{children:[jsx(d,{children:n}),jsx(h,{children:i})]}),jsxs(F,{children:[jsx(_t,{...r}),t?jsxs(Fragment,{children:[jsx(U,{children:getTranslation(o,"messages","dividerOr")}),jsxs("div",{className:"fui-screen__children",children:[t,jsx(E,{})]})]}):null]})]})})}function kn({children:t,onSignUp:e,...r}){let o=s(),n=getTranslation(o,"labels","signUp"),i=getTranslation(o,"prompts","enterDetailsToCreate");return N(e),o.multiFactorResolver?jsx(w,{}):jsx("div",{className:"fui-screen",children:jsxs(p,{children:[jsxs(f,{children:[jsx(d,{children:n}),jsx(h,{children:i})]}),jsxs(F,{children:[jsx(Ht,{...r}),t?jsxs(Fragment,{children:[jsx(U,{children:getTranslation(o,"messages","dividerOr")}),jsxs("div",{className:"fui-screen__children",children:[t,jsx(E,{})]})]}):null]})]})})}function he(t,e){let r=s(),[o,n]=useState(null),i=useCallback(async()=>{n(null);try{let a=await signInWithProvider(r,t);e?.(a);}catch(a){if(a instanceof FirebaseUIError){n(a.message);return}console.error(a),n(getTranslation(r,"errors","unknownError"));}},[r,t,n,e]);return {error:o,callback:i}}function b({provider:t,children:e,themed:r,onSignIn:o}){let n=s(),{error:i,callback:a}=he(t,o);return jsxs("div",{children:[jsx(x,{type:"button",variant:r?"primary":"secondary","data-themed":r,"data-provider":t.providerId,disabled:n.state!=="idle",onClick:a,className:"fui-provider__button",children:e}),i&&jsx("div",{className:"fui-error",children:i})]})}var Wn=t=>jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 50 50",...t,children:jsx("path",{fill:"currentColor",d:"M44.527 34.75c-1.078 2.395-1.597 3.465-2.984 5.578-1.941 2.953-4.68 6.64-8.063 6.664-3.011.028-3.789-1.965-7.878-1.93-4.086.02-4.938 1.97-7.954 1.938-3.386-.031-5.976-3.352-7.918-6.3-5.43-8.27-6.003-17.966-2.648-23.122 2.375-3.656 6.129-5.805 9.656-5.805 3.594 0 5.852 1.973 8.82 1.973 2.883 0 4.637-1.976 8.794-1.976 3.14 0 6.46 1.71 8.836 4.664-7.766 4.257-6.504 15.347 1.34 18.316M31.195 8.469c1.512-1.942 2.66-4.68 2.242-7.469-2.464.168-5.347 1.742-7.03 3.781-1.528 1.86-2.794 4.617-2.302 7.285 2.692.086 5.477-1.52 7.09-3.597"})}),Se=Wn;function $n({provider:t,...e}){let r=s();return jsxs(b,{...e,provider:t||new OAuthProvider("apple.com"),children:[jsx(ge,{}),jsx("span",{children:getTranslation(r,"labels","signInWithApple")})]})}function ge({className:t,...e}){return jsx(Se,{className:u("fui-provider__icon",t),...e})}var Jn=t=>jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 50 50",...t,children:jsx("path",{fill:"currentColor",d:"M25 3C12.85 3 3 12.85 3 25c0 11.03 8.125 20.137 18.712 21.728V30.831h-5.443v-5.783h5.443V21.2c0-6.371 3.104-9.168 8.399-9.168 2.536 0 3.877.188 4.512.274v5.048h-3.612c-2.248 0-3.033 2.131-3.033 4.533v3.161h6.588l-.894 5.783h-5.694v15.944C38.716 45.318 47 36.137 47 25c0-12.15-9.85-22-22-22"})}),Ae=Jn;function Xn({provider:t,...e}){let r=s();return jsxs(b,{...e,provider:t||new FacebookAuthProvider,children:[jsx(ve,{}),jsx("span",{children:getTranslation(r,"labels","signInWithFacebook")})]})}function ve({className:t,...e}){return jsx(Ae,{className:u("fui-provider__icon",t),...e})}var jn=t=>jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",fill:"currentColor",viewBox:"0 0 30 30",...t,children:jsx("path",{d:"M15 3C8.373 3 3 8.373 3 15c0 5.623 3.872 10.328 9.092 11.63a1.8 1.8 0 0 1-.092-.583v-2.051h-1.508c-.821 0-1.551-.353-1.905-1.009-.393-.729-.461-1.844-1.435-2.526-.289-.227-.069-.486.264-.451.615.174 1.125.596 1.605 1.222.478.627.703.769 1.596.769.433 0 1.081-.025 1.691-.121.328-.833.895-1.6 1.588-1.962-3.996-.411-5.903-2.399-5.903-5.098 0-1.162.495-2.286 1.336-3.233-.276-.94-.623-2.857.106-3.587 1.798 0 2.885 1.166 3.146 1.481A9 9 0 0 1 15.495 9c1.036 0 2.024.174 2.922.483C18.675 9.17 19.763 8 21.565 8c.732.731.381 2.656.102 3.594.836.945 1.328 2.066 1.328 3.226 0 2.697-1.904 4.684-5.894 5.097C18.199 20.49 19 22.1 19 23.313v2.734c0 .104-.023.179-.035.268C23.641 24.676 27 20.236 27 15c0-6.627-5.373-12-12-12"})}),be=jn;function ei({provider:t,...e}){let r=s();return jsxs(b,{...e,provider:t||new GithubAuthProvider,children:[jsx(Ce,{}),jsx("span",{children:getTranslation(r,"labels","signInWithGitHub")})]})}function Ce({className:t,...e}){return jsx(be,{className:u("fui-provider__icon",t),...e})}var ni=t=>jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 48 48",...t,children:[jsx("path",{fill:"#FFC107",d:"M43.611 20.083H42V20H24v8h11.303c-1.649 4.657-6.08 8-11.303 8-6.627 0-12-5.373-12-12s5.373-12 12-12c3.059 0 5.842 1.154 7.961 3.039l5.657-5.657C34.046 6.053 29.268 4 24 4 12.955 4 4 12.955 4 24s8.955 20 20 20 20-8.955 20-20c0-1.341-.138-2.65-.389-3.917"}),jsx("path",{fill:"#FF3D00",d:"m6.306 14.691 6.571 4.819C14.655 15.108 18.961 12 24 12c3.059 0 5.842 1.154 7.961 3.039l5.657-5.657C34.046 6.053 29.268 4 24 4 16.318 4 9.656 8.337 6.306 14.691"}),jsx("path",{fill:"#4CAF50",d:"M24 44c5.166 0 9.86-1.977 13.409-5.192l-6.19-5.238A11.9 11.9 0 0 1 24 36c-5.202 0-9.619-3.317-11.283-7.946l-6.522 5.025C9.505 39.556 16.227 44 24 44"}),jsx("path",{fill:"#1976D2",d:"M43.611 20.083H42V20H24v8h11.303a12.04 12.04 0 0 1-4.087 5.571l.003-.002 6.19 5.238C36.971 39.205 44 34 44 24c0-1.341-.138-2.65-.389-3.917"})]}),Ie=ni;function ui({provider:t,...e}){let r=s();return jsxs(b,{...e,provider:t||new GoogleAuthProvider,children:[jsx(xe,{}),jsx("span",{children:getTranslation(r,"labels","signInWithGoogle")})]})}function xe({className:t,...e}){return jsx(Ie,{className:u("fui-provider__icon",t),...e})}var ci=t=>jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 48 48",...t,children:[jsx("path",{fill:"#ff5722",d:"M22 22H6V6h16z"}),jsx("path",{fill:"#4caf50",d:"M42 22H26V6h16z"}),jsx("path",{fill:"#ffc107",d:"M42 42H26V26h16z"}),jsx("path",{fill:"#03a9f4",d:"M22 42H6V26h16z"})]}),Me=ci;function di({provider:t,...e}){let r=s();return jsxs(b,{...e,provider:t||new OAuthProvider("microsoft.com"),children:[jsx(Ee,{}),jsx("span",{children:getTranslation(r,"labels","signInWithMicrosoft")})]})}function Ee({className:t,...e}){return jsx(Me,{className:u("fui-provider__icon",t),...e})}var Fi=t=>jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",fill:"currentColor",viewBox:"0 0 30 30",...t,children:jsx("path",{d:"m26.37 26-8.795-12.822.015.012L25.52 4h-2.65l-6.46 7.48L11.28 4H4.33l8.211 11.971-.001-.001L3.88 26h2.65l7.182-8.322L19.42 26zM10.23 6l12.34 18h-2.1L8.12 6z"})}),Ne=Fi;function yi({provider:t,...e}){let r=s();return jsxs(b,{...e,provider:t||new TwitterAuthProvider,children:[jsx(Ue,{}),jsx("span",{children:getTranslation(r,"labels","signInWithTwitter")})]})}function Ue({className:t,...e}){return jsx(Ne,{className:u("fui-provider__icon",t),...e})}registerFramework("react",tr.version);
|
|
9
|
+
export{ge as AppleLogo,$n as AppleSignInButton,x as Button,p as Card,F as CardContent,f as CardHeader,h as CardSubtitle,d as CardTitle,q as CountrySelector,U as Divider,It as EmailLinkAuthForm,xn as EmailLinkAuthScreen,ve as FacebookLogo,Xn as FacebookSignInButton,Ge as FirebaseUIProvider,Mt as ForgotPasswordAuthForm,En as ForgotPasswordAuthScreen,Ce as GitHubLogo,ei as GitHubSignInButton,xe as GoogleLogo,ui as GoogleSignInButton,Ee as MicrosoftLogo,di as MicrosoftSignInButton,Tt as MultiFactorAuthAssertionForm,w as MultiFactorAuthAssertionScreen,Rt as MultiFactorAuthEnrollmentForm,wn as MultiFactorAuthEnrollmentScreen,Or as MultiFactorEnrollmentVerifyPhoneNumberForm,Jr as MultiFactorEnrollmentVerifyTotpForm,b as OAuthButton,Nn as OAuthScreen,Gt as PhoneAuthForm,Un as PhoneAuthScreen,A as Policies,vt as PolicyContext,E as RedirectError,_t as SignInAuthForm,Vn as SignInAuthScreen,Ht as SignUpAuthForm,kn as SignUpAuthScreen,Nt as SmsMultiFactorAssertionForm,Bt as SmsMultiFactorEnrollmentForm,wt as TotpMultiFactorAssertionForm,kt as TotpMultiFactorEnrollmentForm,Ue as TwitterLogo,yi as TwitterSignInButton,m as form,Tr as useCountries,Vr as useDefaultCountry,Sr as useEmailLinkAuthForm,Fr as useEmailLinkAuthFormAction,gr as useEmailLinkAuthFormCompleteSignIn,mr as useEmailLinkAuthFormSchema,Ar as useForgotPasswordAuthForm,yr as useForgotPasswordAuthFormAction,ur as useForgotPasswordAuthFormSchema,Nr as useMultiFactorAssertionCleanup,Dr as useMultiFactorEnrollmentVerifyPhoneNumberForm,_r as useMultiFactorEnrollmentVerifyPhoneNumberFormAction,Qr as useMultiFactorEnrollmentVerifyTotpForm,$r as useMultiFactorEnrollmentVerifyTotpFormAction,pr as useMultiFactorPhoneAuthNumberFormSchema,ct as useMultiFactorPhoneAuthVerifyFormSchema,fr as useMultiFactorTotpAuthNumberFormSchema,lt as useMultiFactorTotpAuthVerifyFormSchema,N as useOnUserAuthenticated,cr as usePhoneAuthNumberFormSchema,lr as usePhoneAuthVerifyFormSchema,te as usePhoneNumberForm,jr as usePhoneNumberFormAction,W as useRecaptchaVerifier,ir as useRedirectError,Ot as useRequireDisplayName,ne as useSignInAuthForm,oe as useSignInAuthFormAction,sr as useSignInAuthFormSchema,he as useSignInWithProvider,se as useSignUpAuthForm,ie as useSignUpAuthFormAction,ar as useSignUpAuthFormSchema,xr as useSmsMultiFactorAssertionPhoneFormAction,Mr as useSmsMultiFactorAssertionVerifyFormAction,Gr as useSmsMultiFactorEnrollmentPhoneAuthFormAction,Lr as useSmsMultiFactorEnrollmentPhoneNumberForm,br as useTotpMultiFactorAssertionForm,Pr as useTotpMultiFactorAssertionFormAction,qr as useTotpMultiFactorSecretGenerationForm,zr as useTotpMultiFactorSecretGenerationFormAction,s as useUI,ee as useVerifyPhoneNumberForm,re as useVerifyPhoneNumberFormAction};//# sourceMappingURL=index.js.map
|
|
10
10
|
//# sourceMappingURL=index.js.map
|