@firebase-oss/ui-react 0.0.1
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 +80 -0
- package/dist/index.cjs +3 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +3093 -0
- package/dist/index.d.ts +3093 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/package.json +72 -0
package/README.md
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# @firebase-oss/ui-react
|
|
2
|
+
|
|
3
|
+
This package contains the React components for the FirebaseUI.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Install the package from NPM:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @firebase-oss/ui-react
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
### Importing styles
|
|
16
|
+
|
|
17
|
+
To use the components, you need to import the styles from the `@firebase-oss/ui-styles` package.
|
|
18
|
+
|
|
19
|
+
If using Tailwind CSS, you can import the styles directly into your project.
|
|
20
|
+
|
|
21
|
+
```css
|
|
22
|
+
@import "tailwindcss";
|
|
23
|
+
@import "@firebase-oss/ui-styles/src/base.css";
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Alternatively, you can import the fully compiled CSS file into your project.
|
|
27
|
+
|
|
28
|
+
```tsx
|
|
29
|
+
import "@firebase-oss/ui-styles/dist.css";
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Initializing the UI
|
|
33
|
+
|
|
34
|
+
First, initalize the Firebase JS SDK:
|
|
35
|
+
|
|
36
|
+
```tsx
|
|
37
|
+
import { initializeApp } from "firebase/app";
|
|
38
|
+
|
|
39
|
+
const app = initializeApp({ ... });
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Then, initialize the FirebaseUI with the configuration:
|
|
43
|
+
|
|
44
|
+
```tsx
|
|
45
|
+
import { initializeUI } from "@firebase-oss/ui-react";
|
|
46
|
+
|
|
47
|
+
const ui = initializeUI({
|
|
48
|
+
app,
|
|
49
|
+
});
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Finally, wrap your app in the `ConfigProvider` component:
|
|
53
|
+
|
|
54
|
+
```tsx
|
|
55
|
+
import { ConfigProvider } from "@firebase-oss/ui-react";
|
|
56
|
+
|
|
57
|
+
createRoot(document.getElementById("root")!).render(
|
|
58
|
+
<StrictMode>
|
|
59
|
+
<ConfigProvider config={ui}>
|
|
60
|
+
<App />
|
|
61
|
+
</ConfigProvider>
|
|
62
|
+
</StrictMode>
|
|
63
|
+
);
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Importing components
|
|
67
|
+
|
|
68
|
+
To use the components, you need to import the components from the `@firebase-oss/ui-react` package.
|
|
69
|
+
|
|
70
|
+
```tsx
|
|
71
|
+
import { SignInAuthScreen, GoogleSignInButton } from "@firebase-oss/ui-react";
|
|
72
|
+
|
|
73
|
+
function App() {
|
|
74
|
+
return (
|
|
75
|
+
<SignInAuthScreen>
|
|
76
|
+
<GoogleSignInButton />
|
|
77
|
+
</SignInAuthScreen>
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
```
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
'use strict';var uiCore=require('@firebase-oss/ui-core'),react=require('react'),react$1=require('@nanostores/react'),jsxRuntime=require('react/jsx-runtime'),reactForm=require('@tanstack/react-form'),reactSlot=require('@radix-ui/react-slot'),uiStyles=require('@firebase-oss/ui-styles'),tailwindMerge=require('tailwind-merge'),clsx=require('clsx'),auth=require('firebase/auth');var Qt={version:"0.0.1"};var yt=react.createContext({});function be({children:t,ui:e,policies:r}){let o=react$1.useStore(e);return jsxRuntime.jsx(yt.Provider,{value:o,children:jsxRuntime.jsx(Yt,{policies:r,children:t})})}function s(){let t=react.useContext(yt);if(!t)throw new Error("No FirebaseUI context found. Your application must be wrapped in a <FirebaseUIProvider> component.");return t}function Kt(){let t=s();return react.useMemo(()=>{if(t.redirectError)return t.redirectError instanceof Error?t.redirectError.message:String(t.redirectError)},[t.redirectError])}function Xt(){let t=s();return react.useMemo(()=>uiCore.createSignInAuthFormSchema(t),[t])}function Zt(){let t=s();return react.useMemo(()=>uiCore.createSignUpAuthFormSchema(t),[t])}function jt(){let t=s();return react.useMemo(()=>uiCore.createForgotPasswordAuthFormSchema(t),[t])}function tr(){let t=s();return react.useMemo(()=>uiCore.createEmailLinkAuthFormSchema(t),[t])}function rr(){let t=s();return react.useMemo(()=>uiCore.createPhoneAuthNumberFormSchema(t),[t])}function er(){let t=s();return react.useMemo(()=>uiCore.createPhoneAuthVerifyFormSchema(t),[t])}function it(){let t=s();return react.useMemo(()=>uiCore.createMultiFactorPhoneAuthNumberFormSchema(t),[t])}function st(){let t=s();return react.useMemo(()=>uiCore.createMultiFactorPhoneAuthVerifyFormSchema(t),[t])}function or(){let t=s();return react.useMemo(()=>uiCore.createMultiFactorTotpAuthNumberFormSchema(t),[t])}function at(){let t=s();return react.useMemo(()=>uiCore.createMultiFactorTotpAuthVerifyFormSchema(t),[t])}function O(t){let e=s(),r=react.useRef(null),o=react.useRef(e),n=react.useRef(null);return o.current=e,react.useEffect(()=>{let i=t.current,a=o.current;i!==n.current&&(n.current=i,i?(r.current=uiCore.getBehavior(a,"recaptchaVerification")(a,i),r.current.render()):r.current=null);},[t]),r.current}var At=react.createContext(void 0);function Yt({children:t,policies:e}){return jsxRuntime.jsx(At.Provider,{value:e,children:t})}function b(){let t=s(),e=react.useContext(At);if(!e)return null;let{termsOfServiceUrl:r,privacyPolicyUrl:o,onNavigate:n}=e,a=uiCore.getTranslation(t,"messages","termsAndPrivacy").split(/(\{tos\}|\{privacy\})/),N=n?jsxRuntime.jsx("button",{}):jsxRuntime.jsx("a",{target:"_blank",rel:"noopener noreferrer"});return jsxRuntime.jsx("div",{className:"fui-policies",children:a.map((y,T)=>y==="{tos}"?react.cloneElement(N,{key:T,onClick:n?()=>n(r):void 0,href:n?void 0:r,children:uiCore.getTranslation(t,"labels","termsOfService")}):y==="{privacy}"?react.cloneElement(N,{key:T,onClick:n?()=>n(o):void 0,href:n?void 0:o,children:uiCore.getTranslation(t,"labels","privacyPolicy")}):jsxRuntime.jsx("span",{children:y},T))})}function u(...t){return tailwindMerge.twMerge(clsx.clsx(...t))}function I({className:t,variant:e="primary",asChild:r,...o}){return jsxRuntime.jsx(r?reactSlot.Slot:"button",{className:u(uiStyles.buttonVariant({variant:e}),t),...o})}var{fieldContext:We,useFieldContext:qe,formContext:ze,useFormContext:ir}=reactForm.createFormHookContexts();function $e({className:t,...e}){return !e.field.state.meta.isTouched||!e.field.state.meta.errors.length?null:jsxRuntime.jsx("div",{children:jsxRuntime.jsx("div",{role:"alert","aria-live":"polite",className:u("fui-form__error",t),...e,children:e.field.state.meta.errors.map(r=>r.message).join(", ")})})}function Qe({children:t,before:e,label:r,action:o,...n}){let i=qe();return jsxRuntime.jsxs("label",{htmlFor:i.name,children:[jsxRuntime.jsxs("div",{"data-input-label":true,children:[jsxRuntime.jsx("div",{children:r}),o?jsxRuntime.jsx("div",{children:o}):null]}),jsxRuntime.jsxs("div",{"data-input-group":true,children:[e,jsxRuntime.jsx("input",{...n,"aria-invalid":i.state.meta.isTouched&&i.state.meta.errors.length>0,id:i.name,name:i.name,value:i.state.value,onBlur:()=>{i.handleBlur();},onChange:a=>{i.handleChange(a.target.value);}})]}),t?jsxRuntime.jsx(jsxRuntime.Fragment,{children:t}):null,jsxRuntime.jsx($e,{field:i})]})}function Je({className:t,...e}){return jsxRuntime.jsx("button",{type:"button",...e,className:u("fui-form__action",t)})}function Ye(t){let e=ir();return jsxRuntime.jsx(e.Subscribe,{selector:r=>r.isSubmitting,children:r=>jsxRuntime.jsx(I,{...t,type:"submit",disabled:r})})}function Ke(){let t=ir();return jsxRuntime.jsx(t.Subscribe,{selector:e=>[e.errorMap],children:([e])=>e?.onSubmit&&typeof e.onSubmit=="string"?jsxRuntime.jsx("div",{className:"fui-form__error",children:e.onSubmit}):null})}var m=reactForm.createFormHook({fieldComponents:{Input:Qe},formComponents:{SubmitButton:Ye,ErrorMessage:Ke,Action:Je},fieldContext:We,formContext:ze});function ar(){let t=s();return react.useCallback(async({email:e})=>{try{return await uiCore.sendSignInLinkToEmail(t,e)}catch(r){throw r instanceof uiCore.FirebaseUIError?new Error(r.message):(console.error(r),new Error(uiCore.getTranslation(t,"errors","unknownError")))}},[t])}function ur(t){let e=tr(),r=ar();return m.useAppForm({defaultValues:{email:""},validators:{onBlur:e,onSubmit:e,onSubmitAsync:async({value:o})=>{try{return await r(o),t?.()}catch(n){return n instanceof Error?n.message:String(n)}}}})}function mr(t){let e=s();react.useEffect(()=>{(async()=>{let o=await uiCore.completeEmailLinkSignIn(e,window.location.href);o&&t?.(o);})();},[e,t]);}function Ct({onEmailSent:t,onSignIn:e}){let r=s(),[o,n]=react.useState(false),i=ur(()=>{n(!0),t?.();});return mr(e),o?jsxRuntime.jsx("div",{className:"fui-success",children:uiCore.getTranslation(r,"messages","signInLinkSent")}):jsxRuntime.jsx("form",{className:"fui-form",onSubmit:async a=>{a.preventDefault(),a.stopPropagation(),await i.handleSubmit();},children:jsxRuntime.jsxs(i.AppForm,{children:[jsxRuntime.jsx("fieldset",{children:jsxRuntime.jsx(i.AppField,{name:"email",children:a=>jsxRuntime.jsx(a.Input,{label:uiCore.getTranslation(r,"labels","emailAddress"),type:"email"})})}),jsxRuntime.jsx(b,{}),jsxRuntime.jsxs("fieldset",{children:[jsxRuntime.jsx(i.SubmitButton,{children:uiCore.getTranslation(r,"labels","sendSignInLink")}),jsxRuntime.jsx(i.ErrorMessage,{})]})]})})}function lr(){let t=s();return react.useCallback(async({email:e})=>{try{return await uiCore.sendPasswordResetEmail(t,e)}catch(r){throw r instanceof uiCore.FirebaseUIError?new Error(r.message):(console.error(r),new Error(uiCore.getTranslation(t,"errors","unknownError")))}},[t])}function pr(t){let e=jt(),r=lr();return m.useAppForm({defaultValues:{email:""},validators:{onBlur:e,onSubmit:e,onSubmitAsync:async({value:o})=>{try{return await r(o),t?.()}catch(n){return n instanceof Error?n.message:String(n)}}}})}function It({onBackToSignInClick:t,onPasswordSent:e}){let r=s(),[o,n]=react.useState(false),i=pr(()=>{n(!0),e?.();});return o?jsxRuntime.jsx("div",{className:"fui-success",children:uiCore.getTranslation(r,"messages","checkEmailForReset")}):jsxRuntime.jsx("form",{className:"fui-form",onSubmit:async a=>{a.preventDefault(),a.stopPropagation(),await i.handleSubmit();},children:jsxRuntime.jsxs(i.AppForm,{children:[jsxRuntime.jsx("fieldset",{children:jsxRuntime.jsx(i.AppField,{name:"email",children:a=>jsxRuntime.jsx(a.Input,{label:uiCore.getTranslation(r,"labels","emailAddress"),type:"email"})})}),jsxRuntime.jsx(b,{}),jsxRuntime.jsxs("fieldset",{children:[jsxRuntime.jsx(i.SubmitButton,{children:uiCore.getTranslation(r,"labels","resetPassword")}),jsxRuntime.jsx(i.ErrorMessage,{})]}),t?jsxRuntime.jsx(i.Action,{onClick:t,children:uiCore.getTranslation(r,"labels","backToSignIn")}):null]})})}function dr(){let t=s();return uiCore.getBehavior(t,"countryCodes")().allowedCountries}function hr(){let t=s();return uiCore.getBehavior(t,"countryCodes")().defaultCountry}var W=react.forwardRef(({className:t,...e},r)=>{let o=dr(),n=hr(),[i,a]=react.useState(n),N=react.useCallback(y=>{let T=o.find(gt=>gt.code===y);a(T);},[o]);return react.useImperativeHandle(r,()=>({getCountry:()=>i,setCountry:N}),[i,N]),jsxRuntime.jsx("div",{className:u("fui-country-selector",t),...e,children:jsxRuntime.jsxs("div",{className:"fui-country-selector__wrapper",children:[jsxRuntime.jsx("span",{className:"fui-country-selector__flag",children:i.emoji}),jsxRuntime.jsxs("div",{className:"fui-country-selector__select-wrapper",children:[jsxRuntime.jsx("span",{className:"fui-country-selector__dial-code",children:i.dialCode}),jsxRuntime.jsx("select",{className:"fui-country-selector__select",value:i.code,onChange:y=>{let T=o.find(gt=>gt.code===y.target.value);T&&a(T);},children:o.map(y=>jsxRuntime.jsxs("option",{value:y.code,children:[y.dialCode," (",y.name,")"]},`${y.code}-${y.dialCode}`))})]})]})})});W.displayName="CountrySelector";function yr(){let t=s();return react.useCallback(async({phoneNumber:e,recaptchaVerifier:r})=>await uiCore.verifyPhoneNumber(t,e,r),[t])}function br({recaptchaVerifier:t,onSuccess:e,formatPhoneNumber:r}){let o=yr(),n=rr();return m.useAppForm({defaultValues:{phoneNumber:""},validators:{onBlur:n,onSubmit:n,onSubmitAsync:async({value:i})=>{try{let a=r?r(i.phoneNumber):i.phoneNumber,N=await o({phoneNumber:a,recaptchaVerifier:t});return e(N)}catch(a){return a instanceof uiCore.FirebaseUIError?a.message:String(a)}}}})}function So(t){let e=s(),r=react.useRef(null),o=O(r),n=react.useRef(null),i=br({recaptchaVerifier:o,onSuccess:t.onSubmit,formatPhoneNumber:a=>uiCore.formatPhoneNumber(a,n.current.getCountry())});return jsxRuntime.jsx("form",{className:"fui-form",onSubmit:async a=>{a.preventDefault(),a.stopPropagation(),await i.handleSubmit();},children:jsxRuntime.jsxs(i.AppForm,{children:[jsxRuntime.jsx("fieldset",{children:jsxRuntime.jsx(i.AppField,{name:"phoneNumber",children:a=>jsxRuntime.jsx(a.Input,{label:uiCore.getTranslation(e,"labels","phoneNumber"),type:"tel",before:jsxRuntime.jsx(W,{ref:n})})})}),jsxRuntime.jsx("fieldset",{children:jsxRuntime.jsx("div",{className:"fui-recaptcha-container",ref:r})}),jsxRuntime.jsx(b,{}),jsxRuntime.jsxs("fieldset",{children:[jsxRuntime.jsx(i.SubmitButton,{children:uiCore.getTranslation(e,"labels","sendCode")}),jsxRuntime.jsx(i.ErrorMessage,{})]})]})})}function vr(){let t=s();return react.useCallback(async({verificationId:e,verificationCode:r})=>await uiCore.confirmPhoneNumber(t,e,r),[t])}function Ar({verificationId:t,onSuccess:e}){let r=er(),o=vr();return m.useAppForm({defaultValues:{verificationId:t,verificationCode:""},validators:{onSubmit:r,onBlur:r,onSubmitAsync:async({value:n})=>{try{let i=await o(n);return e(i)}catch(i){return i instanceof uiCore.FirebaseUIError?i.message:String(i)}}}})}function go(t){let e=s(),r=Ar({verificationId:t.verificationId,onSuccess:t.onSuccess});return jsxRuntime.jsx("form",{className:"fui-form",onSubmit:async o=>{o.preventDefault(),o.stopPropagation(),await r.handleSubmit();},children:jsxRuntime.jsxs(r.AppForm,{children:[jsxRuntime.jsx("fieldset",{children:jsxRuntime.jsx(r.AppField,{name:"verificationCode",children:o=>jsxRuntime.jsx(o.Input,{label:uiCore.getTranslation(e,"labels","verificationCode"),type:"text"})})}),jsxRuntime.jsxs("fieldset",{children:[jsxRuntime.jsx(r.SubmitButton,{children:uiCore.getTranslation(e,"labels","verifyCode")}),jsxRuntime.jsx(r.ErrorMessage,{})]})]})})}function wt(t){let[e,r]=react.useState(null);return e?jsxRuntime.jsx(go,{verificationId:e,onSuccess:o=>{t.onSignIn?.(o);}}):jsxRuntime.jsx(So,{onSubmit:r})}function Pr(){let t=s();return react.useCallback(async({email:e,password:r})=>{try{return await uiCore.signInWithEmailAndPassword(t,e,r)}catch(o){throw o instanceof uiCore.FirebaseUIError?new Error(o.message):(console.error(o),new Error(uiCore.getTranslation(t,"errors","unknownError")))}},[t])}function Cr(t){let e=Xt(),r=Pr();return m.useAppForm({defaultValues:{email:"",password:""},validators:{onBlur:e,onSubmit: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 Et({onSignIn:t,onForgotPasswordClick:e,onSignUpClick:r}){let o=s(),n=Cr(t);return jsxRuntime.jsx("form",{className:"fui-form",onSubmit:async i=>{i.preventDefault(),i.stopPropagation(),await n.handleSubmit();},children:jsxRuntime.jsxs(n.AppForm,{children:[jsxRuntime.jsx("fieldset",{children:jsxRuntime.jsx(n.AppField,{name:"email",children:i=>jsxRuntime.jsx(i.Input,{label:uiCore.getTranslation(o,"labels","emailAddress"),type:"email"})})}),jsxRuntime.jsx("fieldset",{children:jsxRuntime.jsx(n.AppField,{name:"password",children:i=>jsxRuntime.jsx(i.Input,{label:uiCore.getTranslation(o,"labels","password"),type:"password",action:e?jsxRuntime.jsx(n.Action,{onClick:e,children:uiCore.getTranslation(o,"labels","forgotPassword")}):null})})}),jsxRuntime.jsx(b,{}),jsxRuntime.jsxs("fieldset",{children:[jsxRuntime.jsx(n.SubmitButton,{children:uiCore.getTranslation(o,"labels","signIn")}),jsxRuntime.jsx(n.ErrorMessage,{})]}),r?jsxRuntime.jsxs(n.Action,{onClick:r,children:[uiCore.getTranslation(o,"prompts","noAccount")," ",uiCore.getTranslation(o,"labels","signUp")]}):null]})})}function Tt(){let t=s();return uiCore.hasBehavior(t,"requireDisplayName")}function Ir(){let t=s();return react.useCallback(async({email:e,password:r,displayName:o})=>{try{return await uiCore.createUserWithEmailAndPassword(t,e,r,o)}catch(n){throw n instanceof uiCore.FirebaseUIError?new Error(n.message):(console.error(n),new Error(uiCore.getTranslation(t,"errors","unknownError")))}},[t])}function xr(t){let e=Zt(),r=Ir(),o=Tt();return m.useAppForm({defaultValues:{email:"",password:"",displayName:o?"":void 0},validators:{onBlur:e,onSubmit: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 Vt({onBackToSignInClick:t,onSignUp:e}){let r=s(),o=xr(e),n=Tt();return jsxRuntime.jsx("form",{className:"fui-form",onSubmit:async i=>{i.preventDefault(),i.stopPropagation(),await o.handleSubmit();},children:jsxRuntime.jsxs(o.AppForm,{children:[n?jsxRuntime.jsx("fieldset",{children:jsxRuntime.jsx(o.AppField,{name:"displayName",children:i=>jsxRuntime.jsx(i.Input,{label:uiCore.getTranslation(r,"labels","displayName")})})}):null,jsxRuntime.jsx("fieldset",{children:jsxRuntime.jsx(o.AppField,{name:"email",children:i=>jsxRuntime.jsx(i.Input,{label:uiCore.getTranslation(r,"labels","emailAddress"),type:"email"})})}),jsxRuntime.jsx("fieldset",{children:jsxRuntime.jsx(o.AppField,{name:"password",children:i=>jsxRuntime.jsx(i.Input,{label:uiCore.getTranslation(r,"labels","password"),type:"password"})})}),jsxRuntime.jsx(b,{}),jsxRuntime.jsxs("fieldset",{children:[jsxRuntime.jsx(o.SubmitButton,{children:uiCore.getTranslation(r,"labels","createAccount")}),jsxRuntime.jsx(o.ErrorMessage,{})]}),t?jsxRuntime.jsxs(o.Action,{onClick:t,children:[uiCore.getTranslation(r,"prompts","haveAccount")," ",uiCore.getTranslation(r,"labels","signIn")]}):null]})})}function M({className:t,children:e,...r}){return e?jsxRuntime.jsxs("div",{className:u("fui-divider",t),...r,children:[jsxRuntime.jsx("div",{className:"fui-divider__line"}),jsxRuntime.jsx("div",{className:"fui-divider__text",children:e}),jsxRuntime.jsx("div",{className:"fui-divider__line"})]}):jsxRuntime.jsx("div",{className:u("fui-divider",t),...r,children:jsxRuntime.jsx("div",{className:"fui-divider__line"})})}function f({children:t,className:e,...r}){return jsxRuntime.jsx("div",{className:u("fui-card",e),...r,children:t})}function d({children:t,className:e,...r}){return jsxRuntime.jsx("div",{className:u("fui-card__header",e),...r,children:t})}function h({children:t,className:e,...r}){return jsxRuntime.jsx("h2",{className:u("fui-card__title",e),...r,children:t})}function F({children:t,className:e,...r}){return jsxRuntime.jsx("p",{className:u("fui-card__subtitle",e),...r,children:t})}function S({children:t,className:e,...r}){return jsxRuntime.jsx("div",{className:u("fui-card__content",e),...r,children:t})}function w(){let t=Kt();return t?jsxRuntime.jsx("div",{className:"fui-form__error",children:t}):null}function No({children:t,onEmailSent:e}){let r=s(),o=uiCore.getTranslation(r,"labels","signIn"),n=uiCore.getTranslation(r,"prompts","signInToAccount");return jsxRuntime.jsx("div",{className:"fui-screen",children:jsxRuntime.jsxs(f,{children:[jsxRuntime.jsxs(d,{children:[jsxRuntime.jsx(h,{children:o}),jsxRuntime.jsx(F,{children:n})]}),jsxRuntime.jsxs(S,{children:[jsxRuntime.jsx(Ct,{onEmailSent:e}),t?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(M,{children:uiCore.getTranslation(r,"messages","dividerOr")}),jsxRuntime.jsxs("div",{className:"fui-screen__children",children:[t,jsxRuntime.jsx(w,{})]})]}):null]})]})})}function Mo(t){let e=s(),r=uiCore.getTranslation(e,"labels","resetPassword"),o=uiCore.getTranslation(e,"prompts","enterEmailToReset");return jsxRuntime.jsx("div",{className:"fui-screen",children:jsxRuntime.jsxs(f,{children:[jsxRuntime.jsxs(d,{children:[jsxRuntime.jsx(h,{children:r}),jsxRuntime.jsx(F,{children:o})]}),jsxRuntime.jsx(S,{children:jsxRuntime.jsx(It,{...t})})]})})}function Tr(){let t=s();return react.useCallback(async({verificationCode:e,hint:r})=>{let o=auth.TotpMultiFactorGenerator.assertionForSignIn(r.uid,e);return await uiCore.signInWithMultiFactorAssertion(t,o)},[t])}function ko({hint:t,onSuccess:e}){let r=Tr(),o=at();return m.useAppForm({defaultValues:{verificationCode:""},validators:{onSubmit:o,onBlur:o,onSubmitAsync:async({value:n})=>{try{return await r({verificationCode:n.verificationCode,hint:t}),e()}catch(i){return i instanceof uiCore.FirebaseUIError?i.message:String(i)}}}})}function Bt(t){let e=s(),r=ko({hint:t.hint,onSuccess:()=>{t.onSuccess?.();}});return jsxRuntime.jsx("form",{className:"fui-form",onSubmit:async o=>{o.preventDefault(),o.stopPropagation(),await r.handleSubmit();},children:jsxRuntime.jsxs(r.AppForm,{children:[jsxRuntime.jsx("fieldset",{children:jsxRuntime.jsx(r.AppField,{name:"verificationCode",children:o=>jsxRuntime.jsx(o.Input,{label:uiCore.getTranslation(e,"labels","verificationCode"),type:"text",placeholder:"123456",maxLength:6})})}),jsxRuntime.jsxs("fieldset",{children:[jsxRuntime.jsx(r.SubmitButton,{children:uiCore.getTranslation(e,"labels","verifyCode")}),jsxRuntime.jsx(r.ErrorMessage,{})]})]})})}function Br(){let t=s();return react.useCallback(async({hint:e,recaptchaVerifier:r})=>await uiCore.verifyPhoneNumber(t,"",r,void 0,e),[t])}function Oo({hint:t,recaptchaVerifier:e,onSuccess:r}){let o=Br(),n=it();return m.useAppForm({defaultValues:{phoneNumber:t.phoneNumber||""},validators:{onBlur:n,onSubmit:n,onSubmitAsync:async()=>{try{let i=await o({hint:t,recaptchaVerifier:e});return r(i)}catch(i){return i instanceof uiCore.FirebaseUIError?i.message:String(i)}}}})}function Wo(t){let e=s(),r=react.useRef(null),o=O(r),n=Oo({hint:t.hint,recaptchaVerifier:o,onSuccess:t.onSubmit});return jsxRuntime.jsx("form",{className:"fui-form",onSubmit:async i=>{i.preventDefault(),i.stopPropagation(),await n.handleSubmit();},children:jsxRuntime.jsxs(n.AppForm,{children:[jsxRuntime.jsx("fieldset",{children:jsxRuntime.jsx(n.AppField,{name:"phoneNumber",children:i=>jsxRuntime.jsx(i.Input,{label:uiCore.getTranslation(e,"labels","phoneNumber"),type:"tel",disabled:true,value:t.hint.phoneNumber||""})})}),jsxRuntime.jsx("fieldset",{children:jsxRuntime.jsx("div",{className:"fui-recaptcha-container",ref:r})}),jsxRuntime.jsxs("fieldset",{children:[jsxRuntime.jsx(n.SubmitButton,{children:uiCore.getTranslation(e,"labels","sendCode")}),jsxRuntime.jsx(n.ErrorMessage,{})]})]})})}function kr(){let t=s();return react.useCallback(async({verificationId:e,verificationCode:r})=>{let o=auth.PhoneAuthProvider.credential(e,r),n=auth.PhoneMultiFactorGenerator.assertion(o);return await uiCore.signInWithMultiFactorAssertion(t,n)},[t])}function qo({verificationId:t,onSuccess:e}){let r=kr(),o=st();return m.useAppForm({defaultValues:{verificationId:t,verificationCode:""},validators:{onSubmit:o,onBlur:o,onSubmitAsync:async({value:n})=>{try{return await r(n),e()}catch(i){return i instanceof uiCore.FirebaseUIError?i.message:String(i)}}}})}function zo(t){let e=s(),r=qo({verificationId:t.verificationId,onSuccess:t.onSuccess});return jsxRuntime.jsx("form",{className:"fui-form",onSubmit:async o=>{o.preventDefault(),o.stopPropagation(),await r.handleSubmit();},children:jsxRuntime.jsxs(r.AppForm,{children:[jsxRuntime.jsx("fieldset",{children:jsxRuntime.jsx(r.AppField,{name:"verificationCode",children:o=>jsxRuntime.jsx(o.Input,{label:uiCore.getTranslation(e,"labels","verificationCode"),type:"text"})})}),jsxRuntime.jsxs("fieldset",{children:[jsxRuntime.jsx(r.SubmitButton,{children:uiCore.getTranslation(e,"labels","verifyCode")}),jsxRuntime.jsx(r.ErrorMessage,{})]})]})})}function kt(t){let[e,r]=react.useState(null);return e?jsxRuntime.jsx(zo,{verificationId:e.verificationId,onSuccess:()=>{t.onSuccess?.();}}):jsxRuntime.jsx(Wo,{hint:t.hint,onSubmit:o=>r({verificationId:o})})}function U(){let e=s().multiFactorResolver;if(!e)throw new Error("MultiFactorAuthAssertionForm requires a multi-factor resolver");let[r,o]=react.useState(e.hints.length===1?e.hints[0]:void 0);if(r){if(r.factorId===auth.PhoneMultiFactorGenerator.FACTOR_ID)return jsxRuntime.jsx(kt,{hint:r});if(r.factorId===auth.TotpMultiFactorGenerator.FACTOR_ID)return jsxRuntime.jsx(Bt,{hint:r})}return jsxRuntime.jsxs("div",{className:"fui-content",children:[jsxRuntime.jsx("p",{children:"TODO: Select a multi-factor authentication method"}),e.hints.map(n=>n.factorId===auth.TotpMultiFactorGenerator.FACTOR_ID?jsxRuntime.jsx(Qo,{onClick:()=>o(n)},n.factorId):n.factorId===auth.PhoneMultiFactorGenerator.FACTOR_ID?jsxRuntime.jsx(Jo,{onClick:()=>o(n)},n.factorId):null)]})}function Qo(t){let e=s(),r=uiCore.getTranslation(e,"labels","mfaTotpVerification");return jsxRuntime.jsx(I,{...t,children:r})}function Jo(t){let e=s(),r=uiCore.getTranslation(e,"labels","mfaSmsVerification");return jsxRuntime.jsx(I,{...t,children:r})}function Ko({children:t}){let e=s(),r=uiCore.getTranslation(e,"labels","signIn"),o=uiCore.getTranslation(e,"prompts","signInToAccount"),n=e.multiFactorResolver;return jsxRuntime.jsx("div",{className:"fui-screen",children:jsxRuntime.jsxs(f,{children:[jsxRuntime.jsxs(d,{children:[jsxRuntime.jsx(h,{children:r}),jsxRuntime.jsx(F,{children:o})]}),jsxRuntime.jsx(S,{className:"fui-screen__children",children:n?jsxRuntime.jsx(U,{}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[t,jsxRuntime.jsx(w,{}),jsxRuntime.jsx(b,{})]})})]})})}function Zo({children:t,...e}){let r=s(),o=uiCore.getTranslation(r,"labels","signIn"),n=uiCore.getTranslation(r,"prompts","signInToAccount"),i=r.multiFactorResolver;return jsxRuntime.jsx("div",{className:"fui-screen",children:jsxRuntime.jsxs(f,{children:[jsxRuntime.jsxs(d,{children:[jsxRuntime.jsx(h,{children:o}),jsxRuntime.jsx(F,{children:n})]}),jsxRuntime.jsx(S,{children:i?jsxRuntime.jsx(U,{}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(wt,{...e}),t?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(M,{children:uiCore.getTranslation(r,"messages","dividerOr")}),jsxRuntime.jsxs("div",{className:"fui-screen__children",children:[t,jsxRuntime.jsx(w,{})]})]}):null]})})]})})}function jo({children:t,...e}){let r=s(),o=uiCore.getTranslation(r,"labels","signIn"),n=uiCore.getTranslation(r,"prompts","signInToAccount"),i=r.multiFactorResolver;return jsxRuntime.jsx("div",{className:"fui-screen",children:jsxRuntime.jsxs(f,{children:[jsxRuntime.jsxs(d,{children:[jsxRuntime.jsx(h,{children:o}),jsxRuntime.jsx(F,{children:n})]}),jsxRuntime.jsx(S,{children:i?jsxRuntime.jsx(U,{}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Et,{...e}),t?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(M,{children:uiCore.getTranslation(r,"messages","dividerOr")}),jsxRuntime.jsxs("div",{className:"fui-screen__children",children:[t,jsxRuntime.jsx(w,{})]})]}):null]})})]})})}function tn({children:t,...e}){let r=s(),o=uiCore.getTranslation(r,"labels","signUp"),n=uiCore.getTranslation(r,"prompts","enterDetailsToCreate"),i=r.multiFactorResolver;return jsxRuntime.jsx("div",{className:"fui-screen",children:jsxRuntime.jsxs(f,{children:[jsxRuntime.jsxs(d,{children:[jsxRuntime.jsx(h,{children:o}),jsxRuntime.jsx(F,{children:n})]}),jsxRuntime.jsx(S,{children:i?jsxRuntime.jsx(U,{}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Vt,{...e}),t?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(M,{children:uiCore.getTranslation(r,"messages","dividerOr")}),jsxRuntime.jsxs("div",{className:"fui-screen__children",children:[t,jsxRuntime.jsx(w,{})]})]}):null]})})]})})}function qr(t){let e=s(),[r,o]=react.useState(null),n=react.useCallback(async()=>{o(null);try{await uiCore.signInWithProvider(e,t);}catch(i){if(i instanceof uiCore.FirebaseUIError){o(i.message);return}console.error(i),o(uiCore.getTranslation(e,"errors","unknownError"));}},[e,t,o]);return {error:r,callback:n}}function A({provider:t,children:e,themed:r}){let o=s(),{error:n,callback:i}=qr(t);return jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(I,{type:"button","data-themed":r,"data-provider":t.providerId,disabled:o.state!=="idle",onClick:i,className:"fui-provider__button",children:e}),n&&jsxRuntime.jsx("div",{className:"fui-form__error",children:n})]})}var un=t=>jsxRuntime.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 50 50",...t,children:jsxRuntime.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"})}),$r=un;function ln({provider:t,themed:e}){let r=s();return jsxRuntime.jsxs(A,{provider:t||new auth.OAuthProvider("apple.com"),themed:e,children:[jsxRuntime.jsx(Qr,{}),jsxRuntime.jsx("span",{children:uiCore.getTranslation(r,"labels","signInWithApple")})]})}function Qr({className:t,...e}){return jsxRuntime.jsx($r,{className:u("fui-provider__icon",t),...e})}var fn=t=>jsxRuntime.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 50 50",...t,children:jsxRuntime.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"})}),Yr=fn;function Fn({provider:t,themed:e}){let r=s();return jsxRuntime.jsxs(A,{provider:t||new auth.FacebookAuthProvider,themed:e,children:[jsxRuntime.jsx(Kr,{}),jsxRuntime.jsx("span",{children:uiCore.getTranslation(r,"labels","signInWithFacebook")})]})}function Kr({className:t,...e}){return jsxRuntime.jsx(Yr,{className:u("fui-provider__icon",t),...e})}var gn=t=>jsxRuntime.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",fill:"currentColor",viewBox:"0 0 30 30",...t,children:jsxRuntime.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"})}),Zr=gn;function vn({provider:t,themed:e}){let r=s();return jsxRuntime.jsxs(A,{provider:t||new auth.GithubAuthProvider,themed:e,children:[jsxRuntime.jsx(jr,{}),jsxRuntime.jsx("span",{children:uiCore.getTranslation(r,"labels","signInWithGitHub")})]})}function jr({className:t,...e}){return jsxRuntime.jsx(Zr,{className:u("fui-provider__icon",t),...e})}var Pn=t=>jsxRuntime.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 48 48",...t,children:[jsxRuntime.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"}),jsxRuntime.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"}),jsxRuntime.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"}),jsxRuntime.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"})]}),te=Pn;function wn({provider:t,themed:e}){let r=s();return jsxRuntime.jsxs(A,{provider:t||new auth.GoogleAuthProvider,themed:e,children:[jsxRuntime.jsx(re,{}),jsxRuntime.jsx("span",{children:uiCore.getTranslation(r,"labels","signInWithGoogle")})]})}function re({className:t,...e}){return jsxRuntime.jsx(te,{className:u("fui-provider__icon",t),...e})}var En=t=>jsxRuntime.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 48 48",...t,children:[jsxRuntime.jsx("path",{fill:"#ff5722",d:"M22 22H6V6h16z"}),jsxRuntime.jsx("path",{fill:"#4caf50",d:"M42 22H26V6h16z"}),jsxRuntime.jsx("path",{fill:"#ffc107",d:"M42 42H26V26h16z"}),jsxRuntime.jsx("path",{fill:"#03a9f4",d:"M22 42H6V26h16z"})]}),ee=En;function Un({provider:t,themed:e}){let r=s();return jsxRuntime.jsxs(A,{provider:t||new auth.OAuthProvider("microsoft.com"),themed:e,children:[jsxRuntime.jsx(oe,{}),jsxRuntime.jsx("span",{children:uiCore.getTranslation(r,"labels","signInWithMicrosoft")})]})}function oe({className:t,...e}){return jsxRuntime.jsx(ee,{className:u("fui-provider__icon",t),...e})}var kn=t=>jsxRuntime.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",fill:"currentColor",viewBox:"0 0 30 30",...t,children:jsxRuntime.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"})}),ie=kn;function Ln({provider:t,themed:e}){let r=s();return jsxRuntime.jsxs(A,{provider:t||new auth.TwitterAuthProvider,themed:e,children:[jsxRuntime.jsx(se,{}),jsxRuntime.jsx("span",{children:uiCore.getTranslation(r,"labels","signInWithTwitter")})]})}function se({className:t,...e}){return jsxRuntime.jsx(ie,{className:u("fui-provider__icon",t),...e})}function Qn(){let t=s();return react.useCallback(async({phoneNumber:e,recaptchaVerifier:r})=>{let o=auth.multiFactor(t.auth.currentUser);return await uiCore.verifyPhoneNumber(t,e,r,o)},[t])}function Jn({recaptchaVerifier:t,onSuccess:e,formatPhoneNumber:r}){let o=Qn(),n=it();return m.useAppForm({defaultValues:{displayName:"",phoneNumber:""},validators:{onBlur:n,onSubmit:n,onSubmitAsync:async({value:i})=>{try{let a=r?r(i.phoneNumber):i.phoneNumber,N=await o({phoneNumber:a,recaptchaVerifier:t});return e(N,i.displayName)}catch(a){return a instanceof uiCore.FirebaseUIError?a.message:String(a)}}}})}function Yn(t){let e=s(),r=react.useRef(null),o=O(r),n=react.useRef(null),i=Jn({recaptchaVerifier:o,onSuccess:t.onSubmit,formatPhoneNumber:a=>uiCore.formatPhoneNumber(a,n.current.getCountry())});return jsxRuntime.jsx("form",{className:"fui-form",onSubmit:async a=>{a.preventDefault(),a.stopPropagation(),await i.handleSubmit();},children:jsxRuntime.jsxs(i.AppForm,{children:[jsxRuntime.jsx("fieldset",{children:jsxRuntime.jsx(i.AppField,{name:"displayName",children:a=>jsxRuntime.jsx(a.Input,{label:uiCore.getTranslation(e,"labels","displayName"),type:"text"})})}),jsxRuntime.jsx("fieldset",{children:jsxRuntime.jsx(i.AppField,{name:"phoneNumber",children:a=>jsxRuntime.jsx(a.Input,{label:uiCore.getTranslation(e,"labels","phoneNumber"),type:"tel",before:jsxRuntime.jsx(W,{ref:n})})})}),jsxRuntime.jsx("fieldset",{children:jsxRuntime.jsx("div",{className:"fui-recaptcha-container",ref:r})}),jsxRuntime.jsxs("fieldset",{children:[jsxRuntime.jsx(i.SubmitButton,{children:uiCore.getTranslation(e,"labels","sendCode")}),jsxRuntime.jsx(i.ErrorMessage,{})]})]})})}function Kn(){let t=s();return react.useCallback(async({verificationId:e,verificationCode:r,displayName:o})=>{let n=auth.PhoneAuthProvider.credential(e,r),i=auth.PhoneMultiFactorGenerator.assertion(n);return await uiCore.enrollWithMultiFactorAssertion(t,i,o)},[t])}function Xn({verificationId:t,displayName:e,onSuccess:r}){let o=st(),n=Kn();return m.useAppForm({defaultValues:{verificationId:t,verificationCode:""},validators:{onSubmit:o,onBlur:o,onSubmitAsync:async({value:i})=>{try{return await n({...i,displayName:e}),r()}catch(a){return a instanceof uiCore.FirebaseUIError?a.message:String(a)}}}})}function Zn(t){let e=s(),r=Xn({...t,onSuccess:t.onSuccess});return jsxRuntime.jsx("form",{className:"fui-form",onSubmit:async o=>{o.preventDefault(),o.stopPropagation(),await r.handleSubmit();},children:jsxRuntime.jsxs(r.AppForm,{children:[jsxRuntime.jsx("fieldset",{children:jsxRuntime.jsx(r.AppField,{name:"verificationCode",children:o=>jsxRuntime.jsx(o.Input,{label:uiCore.getTranslation(e,"labels","verificationCode"),type:"text"})})}),jsxRuntime.jsxs("fieldset",{children:[jsxRuntime.jsx(r.SubmitButton,{children:uiCore.getTranslation(e,"labels","verifyCode")}),jsxRuntime.jsx(r.ErrorMessage,{})]})]})})}function ce(t){let e=s(),[r,o]=react.useState(null);if(!e.auth.currentUser)throw new Error("User must be authenticated to enroll with multi-factor authentication");return r?jsxRuntime.jsx(Zn,{...r,onSuccess:()=>{t.onSuccess?.();}}):jsxRuntime.jsx(Yn,{onSubmit:(n,i)=>o({verificationId:n,displayName:i})})}function ni(){let t=s();return react.useCallback(async()=>await uiCore.generateTotpSecret(t),[t])}function ii({onSuccess:t}){let e=ni(),r=or();return m.useAppForm({defaultValues:{displayName:""},validators:{onBlur:r,onSubmit:r,onSubmitAsync:async({value:o})=>{try{let n=await e();return t(n,o.displayName)}catch(n){return n instanceof uiCore.FirebaseUIError?n.message:String(n)}}}})}function si(t){let e=s(),r=ii({onSuccess:t.onSubmit});return jsxRuntime.jsx("form",{className:"fui-form",onSubmit:async o=>{o.preventDefault(),o.stopPropagation(),await r.handleSubmit();},children:jsxRuntime.jsxs(r.AppForm,{children:[jsxRuntime.jsx("fieldset",{children:jsxRuntime.jsx(r.AppField,{name:"displayName",children:o=>jsxRuntime.jsx(o.Input,{label:uiCore.getTranslation(e,"labels","displayName"),type:"text"})})}),jsxRuntime.jsxs("fieldset",{children:[jsxRuntime.jsx(r.SubmitButton,{children:uiCore.getTranslation(e,"labels","generateQrCode")}),jsxRuntime.jsx(r.ErrorMessage,{})]})]})})}function ai(){let t=s();return react.useCallback(async({secret:e,verificationCode:r})=>{let o=auth.TotpMultiFactorGenerator.assertionForEnrollment(e,r);return await uiCore.enrollWithMultiFactorAssertion(t,o,r)},[t])}function ui({secret:t,displayName:e,onSuccess:r}){let o=at(),n=ai();return m.useAppForm({defaultValues:{verificationCode:""},validators:{onSubmit:o,onBlur:o,onSubmitAsync:async({value:i})=>{try{return await n({secret:t,verificationCode:i.verificationCode,displayName:e}),r()}catch(a){return a instanceof uiCore.FirebaseUIError?a.message:String(a)}}}})}function mi(t){let e=s(),r=ui({...t,onSuccess:t.onSuccess}),o=uiCore.generateTotpQrCode(e,t.secret,t.displayName);return jsxRuntime.jsxs("form",{className:"fui-form",onSubmit:async n=>{n.preventDefault(),n.stopPropagation(),await r.handleSubmit();},children:[jsxRuntime.jsxs("div",{className:"fui-qr-code-container",children:[jsxRuntime.jsx("img",{src:o,alt:"TOTP QR Code"}),jsxRuntime.jsx("p",{children:"TODO: Scan this QR code with your authenticator app"})]}),jsxRuntime.jsxs(r.AppForm,{children:[jsxRuntime.jsx("fieldset",{children:jsxRuntime.jsx(r.AppField,{name:"verificationCode",children:n=>jsxRuntime.jsx(n.Input,{label:uiCore.getTranslation(e,"labels","verificationCode"),type:"text"})})}),jsxRuntime.jsxs("fieldset",{children:[jsxRuntime.jsx(r.SubmitButton,{children:uiCore.getTranslation(e,"labels","verifyCode")}),jsxRuntime.jsx(r.ErrorMessage,{})]})]})]})}function fe(t){let e=s(),[r,o]=react.useState(null);if(!e.auth.currentUser)throw new Error("User must be authenticated to enroll with multi-factor authentication");return r?jsxRuntime.jsx(mi,{...r,onSuccess:()=>{t.onSuccess?.();}}):jsxRuntime.jsx(si,{onSubmit:(n,i)=>o({secret:n,displayName:i})})}var li=[auth.FactorId.TOTP,auth.FactorId.PHONE];function $t(t){let e=t.hints??li;if(e.length===0)throw new Error("MultiFactorAuthEnrollmentForm must have at least one hint");let[r,o]=react.useState(e.length===1?e[0]:void 0);if(r){if(r===auth.FactorId.TOTP)return jsxRuntime.jsx(fe,{onSuccess:t.onEnrollment});if(r===auth.FactorId.PHONE)return jsxRuntime.jsx(ce,{onSuccess:t.onEnrollment});throw new Error(`Unknown multi-factor enrollment type: ${r}`)}return jsxRuntime.jsx("div",{className:"fui-content",children:e.map(n=>n===auth.FactorId.TOTP?jsxRuntime.jsx(pi,{onClick:()=>o(n)},n):n===auth.FactorId.PHONE?jsxRuntime.jsx(fi,{onClick:()=>o(n)},n):null)})}function pi(t){let e=s(),r=uiCore.getTranslation(e,"labels","mfaTotpVerification");return jsxRuntime.jsx(I,{...t,children:r})}function fi(t){let e=s(),r=uiCore.getTranslation(e,"labels","mfaSmsVerification");return jsxRuntime.jsx(I,{...t,children:r})}function di(t){let e=s(),r=uiCore.getTranslation(e,"labels","multiFactorEnrollment"),o=uiCore.getTranslation(e,"prompts","mfaEnrollmentPrompt");return jsxRuntime.jsx("div",{className:"fui-screen",children:jsxRuntime.jsxs(f,{children:[jsxRuntime.jsxs(d,{children:[jsxRuntime.jsx(h,{children:r}),jsxRuntime.jsx(F,{children:o})]}),jsxRuntime.jsx(S,{children:jsxRuntime.jsx($t,{...t})})]})})}undefined.PROD&&uiCore.registerFramework("react",Qt.version);
|
|
2
|
+
exports.AppleLogo=Qr;exports.AppleSignInButton=ln;exports.Button=I;exports.Card=f;exports.CardContent=S;exports.CardHeader=d;exports.CardSubtitle=F;exports.CardTitle=h;exports.CountrySelector=W;exports.Divider=M;exports.EmailLinkAuthForm=Ct;exports.EmailLinkAuthScreen=No;exports.FacebookLogo=Kr;exports.FacebookSignInButton=Fn;exports.FirebaseUIProvider=be;exports.ForgotPasswordAuthForm=It;exports.ForgotPasswordAuthScreen=Mo;exports.GitHubLogo=jr;exports.GitHubSignInButton=vn;exports.GoogleLogo=re;exports.GoogleSignInButton=wn;exports.MicrosoftLogo=oe;exports.MicrosoftSignInButton=Un;exports.MultiFactorAuthEnrollmentForm=$t;exports.MultiFactorAuthEnrollmentScreen=di;exports.OAuthButton=A;exports.OAuthScreen=Ko;exports.PhoneAuthForm=wt;exports.PhoneAuthScreen=Zo;exports.Policies=b;exports.PolicyContext=At;exports.SignInAuthForm=Et;exports.SignInAuthScreen=jo;exports.SignUpAuthForm=Vt;exports.SignUpAuthScreen=tn;exports.SmsMultiFactorAssertionForm=kt;exports.TotpMultiFactorAssertionForm=Bt;exports.TwitterLogo=se;exports.TwitterSignInButton=Ln;exports.form=m;exports.useCountries=dr;exports.useDefaultCountry=hr;exports.useEmailLinkAuthForm=ur;exports.useEmailLinkAuthFormAction=ar;exports.useEmailLinkAuthFormCompleteSignIn=mr;exports.useEmailLinkAuthFormSchema=tr;exports.useForgotPasswordAuthForm=pr;exports.useForgotPasswordAuthFormAction=lr;exports.useForgotPasswordAuthFormSchema=jt;exports.useMultiFactorPhoneAuthNumberFormSchema=it;exports.useMultiFactorPhoneAuthVerifyFormSchema=st;exports.useMultiFactorTotpAuthNumberFormSchema=or;exports.useMultiFactorTotpAuthVerifyFormSchema=at;exports.usePhoneAuthNumberFormSchema=rr;exports.usePhoneAuthVerifyFormSchema=er;exports.usePhoneNumberForm=br;exports.usePhoneNumberFormAction=yr;exports.useRecaptchaVerifier=O;exports.useRedirectError=Kt;exports.useRequireDisplayName=Tt;exports.useSignInAuthForm=Cr;exports.useSignInAuthFormAction=Pr;exports.useSignInAuthFormSchema=Xt;exports.useSignInWithProvider=qr;exports.useSignUpAuthForm=xr;exports.useSignUpAuthFormAction=Ir;exports.useSignUpAuthFormSchema=Zt;exports.useSmsMultiFactorAssertionPhoneFormAction=Br;exports.useSmsMultiFactorAssertionVerifyFormAction=kr;exports.useTotpMultiFactorAssertionFormAction=Tr;exports.useUI=s;exports.useVerifyPhoneNumberForm=Ar;exports.useVerifyPhoneNumberFormAction=vr;//# sourceMappingURL=index.cjs.map
|
|
3
|
+
//# sourceMappingURL=index.cjs.map
|