@getpara/react-sdk 1.3.0 → 1.3.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/dist/index.js CHANGED
@@ -52,7 +52,7 @@ import{CpslAuthModal as nm,defineCustomElements as rm,generateTheme as am}from"@
52
52
  --height: 80px;
53
53
  --width: 80px;
54
54
  --icon-color: var(--cpsl-color-text-primary);
55
- `;import{AuthMethod as zo}from"@getpara/core-sdk";import{createStore as Zi,useStore as Ji}from"zustand";var nr=e=>({client:void 0,setClient:t=>e({client:t})});var rr=e=>({isOpen:!1,setIsOpen:t=>e({isOpen:t})});var ar=e=>({selectedWalletId:void 0,selectedWalletType:void 0,setSelectedWallet:(t,o)=>e({selectedWalletId:t,selectedWalletType:o}),clearSelectedWallet:()=>e({selectedWalletId:void 0,selectedWalletType:void 0})});import{createJSONStorage as ji,persist as es}from"zustand/middleware";var mt=Zi()(es((...e)=>({...nr(...e),...rr(...e),...ar(...e)}),{version:1,name:"@PARA/web-state",storage:ji(()=>sessionStorage),partialize:e=>({selectedWalletId:e.selectedWalletId,selectedWalletType:e.selectedWalletType})})),ts=e=>t=>Ji(e,t),Z=ts(mt);var b=()=>Z(t=>t.client);import{Fragment as ls,jsx as At,jsxs as ft}from"react/jsx-runtime";var ir=()=>{let e=_(I=>I.theme),t=V(I=>I.getAuthInfo()),o=s(I=>I.setStep),a=s(I=>I.setWebAuthURLForCreate),n=s(I=>I.setIFrameUrl),i=s(I=>I.setIsIFrameReady),l=s(I=>I.isIFrameReady),r=b(),c=as(null),[p,d]=Ct(""),[u,A]=Ct(""),[m,f]=Ct("Resend."),[S,y]=Ct(!1),[D,W]=Ct(!1),[E,h]=Ct(),R=t?.authType==="email";Xo(()=>{setTimeout(()=>{c.current.shadowRoot.querySelectorAll("input")?.[0]?.focus()},10)},[]),Xo(()=>{E&&l&&setTimeout(()=>{o(E),W(!1)},200)},[E,l]),Xo(()=>{p.length===6&&T()},[p]);let C=async()=>{S||(f("Resent!"),y(!0),R?await r.resendVerificationCode():await r.resendVerificationCodeByPhone(),setTimeout(()=>{f("Resend."),y(!1)},3e3))},L=I=>{u&&A(""),d(I.detail.value.trim())},T=async()=>{if(W(!0),p.length===6&&/^\d+$/.test(p))try{let I=await r.getSupportedCreateAuthMethods();if(I.has(zo.PASSWORD)&&I.has(zo.PASSKEY)){i(!1);let U=R?await r.verifyEmail({verificationCode:p}):await r.verifyPhone({verificationCode:p}),x=await r.getSetupPasswordURL({authType:t?.authType,theme:e});a(await r.shortenLoginLink(U)),n(await r.shortenLoginLink(x)),h("BIOMETRIC_CREATION");return}else if(I.has(zo.PASSWORD)){i(!1),R?await r.verifyEmail({verificationCode:p}):await r.verifyPhone({verificationCode:p});let U=await r.getSetupPasswordURL({authType:t?.authType,theme:e});n(await r.shortenLoginLink(U)),h("PASSWORD_CREATION");return}else{let U=R?await r.verifyEmail({verificationCode:p}):await r.verifyPhone({verificationCode:p});a(await r.shortenLoginLink(U)),o("BIOMETRIC_CREATION")}}catch(I){I.message.includes("429")?A("Too many incorrect attempts. Please try again in 10 minutes."):A("Incorrect code.")}else A("Incorrect code.");W(!1)};return ft(F,{$wide:!0,children:[ft(O,{children:[ft(X,{variant:"headingS",weight:"bold",children:["Verify ",R?"Email":"Phone Number"]}),ft(Yt,{variant:"bodyS",color:"secondary",children:["Please enter the code we sent to ",At(Yt,{variant:"bodyS",children:t.identifier})]})]}),At(O,{children:D?At(ns,{}):ft(ls,{children:[At("form",{onSubmit:async I=>{I.preventDefault(),await T()},children:At(is,{ref:c,length:6,type:"number",code:p,onCpslInput:L,errorText:u,onKeyDown:async I=>I.key==="Enter"&&await T()})}),ft(Yt,{variant:"bodyS",color:"secondary",children:["Didn\u2019t receive a code?"," ",At(ss,{variant:"bodyS",style:{cursor:S?"default":"pointer"},onClick:C,children:m})]})]})})]})},is=Qo(os)`
55
+ `;import{AuthMethod as zo}from"@getpara/core-sdk";import{createStore as Zi,useStore as Ji}from"zustand";var nr=e=>({client:void 0,setClient:t=>e({client:t})});var rr=e=>({isOpen:!1,setIsOpen:t=>e({isOpen:t})});var ar=e=>({selectedWalletId:void 0,selectedWalletType:void 0,setSelectedWallet:(t,o)=>e({selectedWalletId:t,selectedWalletType:o}),clearSelectedWallet:()=>e({selectedWalletId:void 0,selectedWalletType:void 0})});import{createJSONStorage as ji,persist as es}from"zustand/middleware";var mt=Zi()(es((...e)=>({...nr(...e),...rr(...e),...ar(...e)}),{version:1,name:"@PARA/web-state",storage:ji(()=>sessionStorage),partialize:e=>({selectedWalletId:e.selectedWalletId,selectedWalletType:e.selectedWalletType})})),ts=e=>t=>Ji(e,t),Z=ts(mt);var b=()=>Z(t=>t.client);import{Fragment as ls,jsx as At,jsxs as ft}from"react/jsx-runtime";var ir=()=>{let e=_(g=>g.theme),t=V(g=>g.getAuthInfo()),o=s(g=>g.setStep),a=s(g=>g.setWebAuthURLForCreate),n=s(g=>g.setIFrameUrl),i=s(g=>g.setIsIFrameReady),l=s(g=>g.isIFrameReady),r=b(),c=as(null),[p,d]=Ct(""),[u,A]=Ct(""),[m,f]=Ct("Resend."),[S,y]=Ct(!1),[D,W]=Ct(!1),[E,h]=Ct(),R=t?.authType==="email";Xo(()=>{setTimeout(()=>{c.current.shadowRoot.querySelectorAll("input")?.[0]?.focus()},10)},[]),Xo(()=>{E&&l&&setTimeout(()=>{o(E),W(!1)},200)},[E,l]),Xo(()=>{p.length===6&&T()},[p]);let C=async()=>{S||(f("Resent!"),y(!0),R?await r.resendVerificationCode():await r.resendVerificationCodeByPhone(),setTimeout(()=>{f("Resend."),y(!1)},3e3))},L=g=>{u&&A(""),d(g.detail.value.trim())},T=async()=>{if(W(!0),p.length===6&&/^\d+$/.test(p))try{let g=await r.getSupportedCreateAuthMethods();if(g.has(zo.PASSWORD)&&g.has(zo.PASSKEY)){i(!1);let U=R?await r.verifyEmail({verificationCode:p}):await r.verifyPhone({verificationCode:p}),x=await r.getSetupPasswordURL({authType:t?.authType,theme:e});a(await r.shortenLoginLink(U)),n(await r.shortenLoginLink(x)),h("BIOMETRIC_CREATION");return}else if(g.has(zo.PASSWORD)){i(!1),R?await r.verifyEmail({verificationCode:p}):await r.verifyPhone({verificationCode:p});let U=await r.getSetupPasswordURL({authType:t?.authType,theme:e});n(await r.shortenLoginLink(U)),h("PASSWORD_CREATION");return}else{let U=R?await r.verifyEmail({verificationCode:p}):await r.verifyPhone({verificationCode:p});a(await r.shortenLoginLink(U)),o("BIOMETRIC_CREATION")}}catch(g){g.message.includes("429")?A("Too many incorrect attempts. Please try again in 10 minutes."):A("Incorrect code.")}else A("Incorrect code.");W(!1)};return ft(F,{$wide:!0,children:[ft(O,{children:[ft(X,{variant:"headingS",weight:"bold",children:["Verify ",R?"Email":"Phone Number"]}),ft(Yt,{variant:"bodyS",color:"secondary",children:["Please enter the code we sent to ",At(Yt,{variant:"bodyS",children:t.identifier})]})]}),At(O,{children:D?At(ns,{}):ft(ls,{children:[At("form",{onSubmit:async g=>{g.preventDefault(),await T()},children:At(is,{ref:c,length:6,type:"number",code:p,onCpslInput:L,errorText:u,onKeyDown:async g=>g.key==="Enter"&&await T()})}),ft(Yt,{variant:"bodyS",color:"secondary",children:["Didn\u2019t receive a code?"," ",At(ss,{variant:"bodyS",style:{cursor:S?"default":"pointer"},onClick:C,children:m})]})]})})]})},is=Qo(os)`
56
56
  align-self: center;
57
57
  `,Yt=Qo(rs)`
58
58
  text-align: center;
@@ -61,14 +61,14 @@ import{CpslAuthModal as nm,defineCustomElements as rm,generateTheme as am}from"@
61
61
  cursor: pointer;
62
62
  display: inline-block;
63
63
  `;import{CpslButton as sr,CpslDivider as ds,CpslIcon as ps}from"@getpara/react-components";import{useEffect as us,useMemo as ms,useState as Cs}from"react";function je(e,t,o){if(typeof window>"u")return;let a=560,n;switch(o){case"LOGIN_PASSWORD":{n=460;break}case"LOGIN_PASSKEY":{n=798;break}case"CREATE_PASSWORD":{n=400;break}case"CREATE_PASSKEY":{n=464;break}case"TRANSACTION_REVIEW":{n=480;break}case"OAUTH":default:{n=768;break}}let i=window.screenLeft!==void 0?window.screenLeft:window.screenX,l=window.screenTop!==void 0?window.screenTop:window.screenY,r=window.innerWidth?window.innerWidth:document.documentElement.clientWidth?document.documentElement.clientWidth:screen.width,c=window.innerHeight?window.innerHeight:document.documentElement.clientHeight?document.documentElement.clientHeight:screen.height,p=(r-a)/2+i,d=(c-n)/2+l,u=`toolbar=no, menubar=no, width=${a},
64
- height=${n}, top=${d}, left=${p}`,A=window.open(e,t,u);return A||setTimeout(()=>{A=window.open(e,"_blank")},0),A}import fs from"styled-components";import{AuthMethod as St,getPublicKeyHex as zt}from"@getpara/web-sdk";import{detect as cs}from"detect-browser";var Xt=()=>{switch(cs().os){case"linux":case"Chrome OS":return!1}return!0};import{formatBiometricHints as As,KnownDevices as Ss,UserIdentifier as Es}from"@getpara/react-common";import{Fragment as qo,jsx as Pe,jsxs as Et}from"react/jsx-runtime";var lr=()=>{let e=s(E=>E.popupWindow),t=s(E=>E.supportedAuthMethods),o=s(E=>E.passwordUrlForLogin),a=s(E=>E.webAuthURLForLogin),n=s(E=>E.setStep),i=s(E=>E.setPopupWindow),l=s(E=>E.biometricLocationHints),r=b(),c=V(E=>E.getAuthInfo()),p=s(E=>E.setWebAuthURLForLogin),d=s(E=>E.setPasswordUrlForLogin),u=Xt(),A=ms(()=>As(l),[l]),m=s(E=>E.setSupportedAuthMethods),[f,S]=Cs();us(()=>{async function E(){if(!t?.size&&r.getUserId()){let x=await r.supportedAuthMethods({userId:r.getUserId()});x?.size&&m(x);return}if(!r.isEmail&&!r.isPhone&&!r.isFarcaster&&!r.isTelegram||!r.loginEncryptionKeyPair)return;let h=r.isEmail?"email":r.isPhone?"phone":r.isFarcaster?"farcaster":"telegram",R=await r.touchSession(),C=t?.has&&t.has(St.PASSKEY)?await r.getWebAuthURLForLogin({sessionId:R.data.sessionId,loginEncryptionPublicKey:zt(r.loginEncryptionKeyPair),partnerId:R.data.partnerId,authType:h,displayName:c.displayName,pfpUrl:c.pfpUrl}):void 0,L=t?.has&&t.has(St.PASSKEY)?await r.getWebAuthURLForLogin({sessionId:R.data.sessionId,loginEncryptionPublicKey:zt(r.loginEncryptionKeyPair),partnerId:R.data.partnerId,newDeviceSessionId:R.data.sessionLookupId,newDeviceEncryptionKey:zt(r.loginEncryptionKeyPair),authType:h,displayName:c.displayName,pfpUrl:c.pfpUrl}):void 0,T=t?.has&&t.has(St.PASSWORD)?await r.getPasswordURLForLogin({sessionId:R.data.sessionId,loginEncryptionPublicKey:zt(r.loginEncryptionKeyPair),partnerId:R.data.partnerId,authType:h,displayName:c.displayName,pfpUrl:c.pfpUrl}):void 0,I=C?await r.shortenLoginLink(C):void 0,U=L?await r.shortenLoginLink(L):void 0;S(U),p(I),d(T)}E()},[t,r]);let y=()=>{if(e)return;let E=je(a,"ParaPasskey","LOGIN_PASSKEY");i(E),n("AWAITING_BIOMETRIC_LOGIN")},D=()=>{let E=je(o,"ParaPassword","LOGIN_PASSWORD");i(E),n("AWAITING_PASSWORD_LOGIN")};function W(){return!l?.length||u&&A.isOnKnownDevice||t?.has&&t.has(St.PASSWORD)}return Et(F,{$wide:!0,children:[Et(O,{children:[W()&&Pe(X,{variant:"headingS",weight:"bold",children:"Welcome back,"}),Pe(Es,{...c})]}),Et(Is,{children:[t?.has&&t.has(St.PASSWORD)&&o&&Pe(hs,{handlePasswordClick:D}),t?.has&&t.has(St.PASSKEY)&&a&&f&&Pe(Ts,{handlePasskeyClick:y,formattedHints:A,shortLoginLink:f,passkeysSupported:u,biometricLocationHints:l})]})]})},hs=({handlePasswordClick:e})=>Pe(sr,{fullWidth:!0,onClick:e,children:"Login"}),Ts=({handlePasskeyClick:e,formattedHints:t,shortLoginLink:o,passkeysSupported:a,biometricLocationHints:n=[]})=>{let[i,l]=[n.length>0,t.isOnKnownDevice];return Et(qo,{children:[(i&&!l||!a)&&Pe(Ss,{hints:t,link:o}),a&&Et(qo,{children:[i&&!l&&Pe(ds,{children:"or"}),Pe(sr,{fullWidth:!0,onClick:e,children:!i||l?Et(qo,{children:[Pe(ps,{slot:"start",icon:"key"}),"Login with passkey"]}):"Continue anyway"})]})]})},Is=fs(O)`
64
+ height=${n}, top=${d}, left=${p}`,A=window.open(e,t,u);return A||setTimeout(()=>{A=window.open(e,"_blank")},0),A}import fs from"styled-components";import{AuthMethod as St,getPublicKeyHex as zt}from"@getpara/web-sdk";import{detect as cs}from"detect-browser";var Xt=()=>{switch(cs().os){case"linux":case"Chrome OS":return!1}return!0};import{formatBiometricHints as As,KnownDevices as Ss,UserIdentifier as Es}from"@getpara/react-common";import{Fragment as qo,jsx as Pe,jsxs as Et}from"react/jsx-runtime";var lr=()=>{let e=s(E=>E.popupWindow),t=s(E=>E.supportedAuthMethods),o=s(E=>E.passwordUrlForLogin),a=s(E=>E.webAuthURLForLogin),n=s(E=>E.setStep),i=s(E=>E.setPopupWindow),l=s(E=>E.biometricLocationHints),r=b(),c=V(E=>E.getAuthInfo()),p=s(E=>E.setWebAuthURLForLogin),d=s(E=>E.setPasswordUrlForLogin),u=Xt(),A=ms(()=>As(l),[l]),m=s(E=>E.setSupportedAuthMethods),[f,S]=Cs();us(()=>{async function E(){if(!t?.size&&r.getUserId()){let x=await r.supportedAuthMethods({userId:r.getUserId()});x?.size&&m(x);return}if(!r.isEmail&&!r.isPhone&&!r.isFarcaster&&!r.isTelegram||!r.loginEncryptionKeyPair)return;let h=r.isEmail?"email":r.isPhone?"phone":r.isFarcaster?"farcaster":"telegram",R=await r.touchSession(),C=t?.has&&t.has(St.PASSKEY)?await r.getWebAuthURLForLogin({sessionId:R.data.sessionId,loginEncryptionPublicKey:zt(r.loginEncryptionKeyPair),partnerId:R.data.partnerId,authType:h,displayName:c.displayName,pfpUrl:c.pfpUrl}):void 0,L=t?.has&&t.has(St.PASSKEY)?await r.getWebAuthURLForLogin({sessionId:R.data.sessionId,loginEncryptionPublicKey:zt(r.loginEncryptionKeyPair),partnerId:R.data.partnerId,newDeviceSessionId:R.data.sessionLookupId,newDeviceEncryptionKey:zt(r.loginEncryptionKeyPair),authType:h,displayName:c.displayName,pfpUrl:c.pfpUrl}):void 0,T=t?.has&&t.has(St.PASSWORD)?await r.getPasswordURLForLogin({sessionId:R.data.sessionId,loginEncryptionPublicKey:zt(r.loginEncryptionKeyPair),partnerId:R.data.partnerId,authType:h,displayName:c.displayName,pfpUrl:c.pfpUrl}):void 0,g=C?await r.shortenLoginLink(C):void 0,U=L?await r.shortenLoginLink(L):void 0;S(U),p(g),d(T)}E()},[t,r]);let y=()=>{if(e)return;let E=je(a,"ParaPasskey","LOGIN_PASSKEY");i(E),n("AWAITING_BIOMETRIC_LOGIN")},D=()=>{let E=je(o,"ParaPassword","LOGIN_PASSWORD");i(E),n("AWAITING_PASSWORD_LOGIN")};function W(){return!l?.length||u&&A.isOnKnownDevice||t?.has&&t.has(St.PASSWORD)}return Et(F,{$wide:!0,children:[Et(O,{children:[W()&&Pe(X,{variant:"headingS",weight:"bold",children:"Welcome back,"}),Pe(Es,{...c})]}),Et(Is,{children:[t?.has&&t.has(St.PASSWORD)&&o&&Pe(hs,{handlePasswordClick:D}),t?.has&&t.has(St.PASSKEY)&&a&&f&&Pe(Ts,{handlePasskeyClick:y,formattedHints:A,shortLoginLink:f,passkeysSupported:u,biometricLocationHints:l})]})]})},hs=({handlePasswordClick:e})=>Pe(sr,{fullWidth:!0,onClick:e,children:"Login"}),Ts=({handlePasskeyClick:e,formattedHints:t,shortLoginLink:o,passkeysSupported:a,biometricLocationHints:n=[]})=>{let[i,l]=[n.length>0,t.isOnKnownDevice];return Et(qo,{children:[(i&&!l||!a)&&Pe(Ss,{hints:t,link:o}),a&&Et(qo,{children:[i&&!l&&Pe(ds,{children:"or"}),Pe(sr,{fullWidth:!0,onClick:e,children:!i||l?Et(qo,{children:[Pe(ps,{slot:"start",icon:"key"}),"Login with passkey"]}):"Continue anyway"})]})]})},Is=fs(O)`
65
65
  gap: 16px;
66
66
  `;import{CpslButton as jo,CpslCodeInput as gs,CpslDivider as ys,CpslIcon as xs,CpslQrCode as ws,CpslSpinner as cr,CpslText as dr}from"@getpara/react-components";import{useEffect as Zo,useRef as Ws,useState as Qt}from"react";import{styled as pr}from"styled-components";import{useCopyToClipboard as _s}from"@getpara/react-common";import{Fragment as Jo,jsx as oe,jsxs as Ot}from"react/jsx-runtime";var ur=({onClose:e})=>{let t=s(L=>L.isLogin()),o=s(L=>L.setStep),a=b(),n=s(L=>L.step==="VERIFY_2FA"),[i,l]=_s(),r=Ws(null),[c,p]=Qt(null),[d,u]=Qt(""),[A,m]=Qt(""),[f,S]=Qt(!1),D=(c?new URL(c).searchParams:void 0)?.get("secret");Zo(()=>{async function L(){try{let{uri:T}=await a.setup2FA();p(T)}catch(T){console.error("Error fetching OTPAuth URL:",T)}}L()},[]),Zo(()=>{setTimeout(()=>{r?.current?.shadowRoot.querySelectorAll("input")?.[0]?.focus()},10)},[n]),Zo(()=>{d.length===6&&R()},[d]);let W=()=>{o("VERIFY_2FA")},E=()=>{t?o("LOGIN_DONE"):e()},h=L=>{A&&m(""),u(L.detail.value.trim())},R=async()=>{if(S(!0),d.length===6&&/^\d+$/.test(d))try{await a.enable2FA({verificationCode:d}),o("TWO_FACTOR_DONE")}catch{m("Incorrect Code")}else m("Incorrect Code");S(!1)};return Ot(F,{children:[Ot(O,{children:[oe(X,{variant:"headingS",weight:"bold",children:"Turn on Two-Factor authentication"}),n&&oe(dr,{variant:"bodyS",color:"secondary",weight:"medium",children:"Please enter the code from your authenticator app."})]}),oe(O,{children:n?oe(Jo,{children:f?oe(cr,{}):oe("form",{onSubmit:async L=>{L.preventDefault(),await R()},children:oe(Rs,{ref:r,code:d,onCpslInput:h,errorText:A,length:6,onKeyDown:async L=>L.key==="Enter"&&await R()})})}):Ot(Jo,{children:[oe(dr,{variant:"bodyS",color:"secondary",weight:"medium",children:"Scan with your preferred authenticator app."}),oe(Se,{children:c?oe(ws,{url:c}):oe(cr,{size:100})})]})}),!n&&Ot(Jo,{children:[oe(O,{children:oe(ys,{children:"or enter the code manually"})}),oe(O,{children:oe(Mt,{disabled:!0,value:D,noAutoDisable:!0,children:oe(jo,{slot:"end",variant:"ghost",onClick:()=>{l(D)},children:oe(xs,{icon:i?"check":"copy"})})})}),Ot(O,{children:[oe(jo,{fullWidth:!0,onClick:W,children:"Continue"}),oe(Ls,{variant:"ghost",onClick:E,children:"Skip"})]})]})]})},Rs=pr(gs)`
67
67
  align-self: center;
68
68
  `,Ls=pr(jo)`
69
69
  margin-top: 8px;
70
70
  text-decoration: underline;
71
- `;import{useEffect as Al}from"react";import ht from"styled-components";import{CpslButton as dl,CpslIdenticon as pl,CpslText as Rr}from"@getpara/react-components";import{truncateAddress as Lr}from"@getpara/web-sdk";import{useEffect as il}from"react";import{useEffect as el,useRef as tl}from"react";var B=()=>Z(t=>t.client);var qt=()=>{let e=Z(n=>n.isOpen),t=Z(n=>n.setIsOpen);return{isOpen:e,openModal:()=>{t(!0)},closeModal:()=>{t(!1)}}};var Ce=()=>{let e=B(),t=Z(l=>l.selectedWalletId),o=Z(l=>l.selectedWalletType),a=Z(l=>l.setSelectedWallet),n=Z(l=>l.clearSelectedWallet);return{selectedWallet:{id:t,type:o},setSelectedWallet:({id:l,type:r})=>{try{e.findWalletId(l,{type:[r]})!==l?n():a(l,r)}catch{n()}}}};import{useQuery as Ms}from"@tanstack/react-query";var mr=async e=>{let o={isConnected:!!await e?.isFullyLoggedIn(),email:void 0,phone:void 0,wallets:void 0};return e&&o.isConnected&&(o.email=e.getEmail(),o.phone=e.getPhoneNumber(),o.wallets=e.getWallets()),o};var Ee="PARA_ACCOUNT",en=()=>{let e=B();return Ms({queryKey:[Ee,e?.getUserId()],queryFn:async()=>await mr(e)})};import{useQuery as Os}from"@tanstack/react-query";var Cr=async(e,t)=>{let o=await e?.isFullyLoggedIn();return!e||!o?null:e.findWallet(t?.id,t?.type)};var ye="PARA_WALLET",Nt=()=>{let e=B(),{selectedWallet:t}=Ce();return Os({queryKey:[ye,e?.getUserId(),t.id,t.type],queryFn:async()=>await Cr(e,t)})};import{useMutation as Ns,useQueryClient as vs}from"@tanstack/react-query";var fr=async(e,t)=>{if(!e)throw new Error("no para instance");if(!t)throw new Error("no valid args passed to waitForLoginAndSetup");try{let o=await e.waitForLoginAndSetup(t);if(o.isError)throw new Error("error during waitForLoginAndSetup");return o}catch(o){throw new Error(o)}};function J(e,t){let{mutate:o,mutateAsync:a,...n}=e;return{...{[t]:e.mutate,[`${t}Async`]:e.mutateAsync},...n}}var bs=()=>{let e=B(),t=vs(),o=Ns({mutationFn:async a=>await fr(e,a),onSettled:async()=>{await t.invalidateQueries({queryKey:[Ee],exact:!1}),await t.invalidateQueries({queryKey:[ye],exact:!1})}});return J(o,"waitForLoginAndSetup")};import{useMutation as Ds,useQueryClient as Us}from"@tanstack/react-query";var Ar=async e=>{if(!e)throw new Error("no para instance");try{let t=await e.waitForAccountCreation();if(!t)throw new Error("error during waitForAccountCreation");return t}catch(t){throw new Error(t)}};var Ps=()=>{let e=B(),t=Us(),o=Ds({mutationFn:async()=>await Ar(e),onSettled:async()=>{await t.invalidateQueries({queryKey:[Ee],exact:!1}),await t.invalidateQueries({queryKey:[ye],exact:!1})}});return J(o,"waitForAccountCreation")};import{useMutation as Fs,useQueryClient as ks}from"@tanstack/react-query";var Sr=async e=>{if(!e)throw new Error("no para instance");try{let t=await e.waitForPasskeyAndCreateWallet();if(!t)throw new Error("error during waitForAccountCreation");return t}catch(t){throw new Error(t)}};var Bs=()=>{let e=B(),t=ks(),o=Fs({mutationFn:async()=>await Sr(e),onSettled:async()=>{await t.invalidateQueries({queryKey:[Ee],exact:!1}),await t.invalidateQueries({queryKey:[ye],exact:!1})}});return J(o,"waitForPasskeyAndCreateWallet")};import{useMutation as Hs}from"@tanstack/react-query";var Er=async(e,t)=>{if(!e)throw new Error("no para instance");if(!t)throw new Error("no valid args passed to createUser");try{await(t.type==="EMAIL"?e.createUser({email:t.identifier}):e.createUserByPhone({phone:t.identifier,countryCode:t.countryCode}))}catch(o){throw new Error(o)}};var Gs=()=>{let e=B(),t=Hs({mutationFn:async o=>await Er(e,o)});return J(t,"createUser")};import{useMutation as Vs}from"@tanstack/react-query";var hr=async(e,t)=>{if(!e)throw new Error("no para instance");if(!t)throw new Error("no valid args passed to checkIfUserExists");try{return await(t.type==="EMAIL"?e.checkIfUserExists({email:t.identifier}):e.checkIfUserExistsByPhone({phone:t.identifier,countryCode:t.countryCode}))}catch(o){throw new Error(o)}};var $s=()=>{let e=B(),t=Vs({mutationFn:async o=>await hr(e,o)});return J(t,"checkIfUserExists")};import{useMutation as Ks}from"@tanstack/react-query";var Tr=async(e,t)=>{if(!e)throw new Error("no para instance");if(!t)throw new Error("no valid args passed to initiateLogin");try{return await e.initiateUserLoginV2(t)}catch(o){throw new Error(o)}};var Ys=()=>{let e=B(),t=Ks({mutationFn:async o=>await Tr(e,o)});return J(t,"initiateLogin")};import{useMutation as Xs,useQueryClient as zs}from"@tanstack/react-query";var Ir=async e=>{if(!e)throw new Error("no para instance");try{await e.logout()}catch(t){throw new Error(t)}};var tn=()=>{let e=B(),t=zs(),o=Z(n=>n.clearSelectedWallet),a=Xs({mutationFn:async()=>await Ir(e),onSettled:async()=>{await t.invalidateQueries({queryKey:[Ee],exact:!1}),await t.invalidateQueries({queryKey:[ye],exact:!1}),o()}});return J(a,"logout")};import{useMutation as Qs}from"@tanstack/react-query";var gr=async e=>{if(!e)throw new Error("no para instance");try{if(!await e.keepSessionAlive())throw new Error("session expired")}catch(t){throw new Error(t)}};var on=()=>{let e=B(),t=Qs({mutationFn:async()=>await gr(e)});return J(t,"keepSessionAlive")};import{useMutation as qs}from"@tanstack/react-query";var yr=async(e,t)=>{if(!e)throw new Error("no para instance");if(!t)throw new Error("no valid args passed to signMessage");try{return await e.signMessage(t)}catch(o){throw new Error(o)}};var Zs=()=>{let e=B(),{data:t}=Nt(),o=qs({mutationFn:async a=>{let n=a?.walletId;if(n||(n=t?.id),!n)throw Error("no wallet id found");return await yr(e,{...a,walletId:n})}});return J(o,"signMessage")};import{useMutation as Js}from"@tanstack/react-query";var xr=async(e,t)=>{if(!e)throw new Error("no para instance");if(!t)throw new Error("no valid args passed to signTransaction");try{return await e.signTransaction(t)}catch(o){throw new Error(o)}};var js=()=>{let e=B(),{data:t}=Nt(),o=Js({mutationFn:async a=>{let n=a?.walletId;if(n||(n=t?.id),!n)throw Error("no wallet id found");return await xr(e,{...a,walletId:n})}});return J(o,"signTransaction")};var ol=6e4,nl=3e5,wr=({disabled:e})=>{let t=B(),{data:o}=en(),{logoutAsync:a}=tn(),{keepSessionAliveAsync:n}=on(),i=tl(null);el(()=>{if(!t||e){c();return}return o?.isConnected?r():c(),()=>c()},[t,o,e]);let l=async()=>{try{let p=await t.retrieveSessionCookie();if(!p)return null;let d=p.match(/Expires=([^;]+)/);return d?new Date(d[1]):null}catch{return null}},r=()=>{c(),i.current=setInterval(async()=>{let p=await l();if(!p){await a(),c();return}let d=p.getTime()-Date.now();if(d<=0){await a(),c();return}if(d<=nl){try{await n(),r()}catch(u){console.error("Failed to keep session alive:",u),await a(),c()}return}},ol)},c=()=>{i.current&&clearInterval(i.current)}};import{useQueryClient as rl}from"@tanstack/react-query";import{useEffect as al}from"react";import{ParaEvent as j}from"@getpara/web-sdk";var Wr=({onLogin:e,onLogout:t,onAccountSetup:o,onAccountCreation:a,onSignMessage:n,onSignTransaction:i,onWalletCreated:l,onPregenWalletClaimed:r,onExternalWalletChange:c,onWalletsChange:p}={})=>{let d=rl(),u=B(),A=Z(x=>x.clearSelectedWallet),{selectedWallet:m,setSelectedWallet:f}=Ce(),S=x=>{D(),e?.(x)},y=x=>{D(),o?.(x)},D=()=>{d.invalidateQueries({queryKey:[Ee],exact:!1}),d.invalidateQueries({queryKey:[ye],exact:!1})},W=x=>{a?.(x)},E=x=>{d.invalidateQueries({queryKey:[Ee],exact:!1}),A(),t?.(x)},h=x=>{n?.(x)},R=x=>{i?.(x)},C=x=>{U(),p?.(x)},L=x=>{U(),c?.(x)},T=x=>{l?.(x)},I=x=>{r?.(x)},U=()=>{if(!u){A();return}if(!m?.id||!u.findWallet(m?.id)){let x=u.findWallet(void 0,void 0,{forbidPregen:!0});f({id:x?.id,type:x?.type})}};al(()=>(window.addEventListener(j.LOGIN_EVENT,S),window.addEventListener(j.ACCOUNT_SETUP_EVENT,y),window.addEventListener(j.ACCOUNT_CREATION_EVENT,W),window.addEventListener(j.LOGOUT_EVENT,E),window.addEventListener(j.SIGN_MESSAGE_EVENT,h),window.addEventListener(j.SIGN_TRANSACTION_EVENT,R),window.addEventListener(j.WALLETS_CHANGE_EVENT,C),window.addEventListener(j.EXTERNAL_WALLET_CHANGE_EVENT,L),window.addEventListener(j.WALLET_CREATED,T),window.addEventListener(j.PREGEN_WALLET_CLAIMED,I),()=>{window.removeEventListener(j.LOGIN_EVENT,S),window.removeEventListener(j.ACCOUNT_SETUP_EVENT,y),window.removeEventListener(j.ACCOUNT_CREATION_EVENT,W),window.removeEventListener(j.LOGOUT_EVENT,E),window.removeEventListener(j.SIGN_MESSAGE_EVENT,h),window.removeEventListener(j.SIGN_TRANSACTION_EVENT,R),window.removeEventListener(j.WALLETS_CHANGE_EVENT,C),window.removeEventListener(j.EXTERNAL_WALLET_CHANGE_EVENT,L),window.removeEventListener(j.WALLET_CREATED,T),window.removeEventListener(j.PREGEN_WALLET_CLAIMED,I)}),[u])};import{ParaInternal as sl}from"@getpara/react-common";var ll={disableAutoSessionKeepAlive:!1},cl=({children:e,paraClientConfig:t,callbacks:o,config:a=ll})=>{Wr(o),wr({disabled:a.disableAutoSessionKeepAlive});let n=Z(i=>i.setClient);return il(()=>{let i=a.paraClientOverride??new sl(t.env,t.apiKey,t.opts);n(i)},[t,a.paraClientOverride]),e};var RS=()=>mt.getState().client,LS=()=>mt.getState().isOpen,MS=()=>mt.getState().selectedWalletId,OS=()=>mt.getState().selectedWalletType;import{jsx as et,jsxs as nn}from"react/jsx-runtime";var Mr=({address:e,showAddFunds:t})=>{let o=b(),a=o.externalWallets[e];return a?et(Or,{address:Lr(a.address,a.type),identiconHash:o.getIdenticonHash(a.id,a.type),showAddFunds:t}):null},Zt=({id:e,type:t,showAddFunds:o})=>{let a=b(),n=_(r=>r.appName),i=a.findWallet(e,t);if(!i)return null;let l=a.getDisplayAddress(i.id,{addressType:t});return et(Or,{id:i.id,type:i.type,address:Lr(l,t,{prefix:a.cosmosPrefix}),name:i.name??`${n?`${n} `:""}Wallet`,identiconHash:a.getIdenticonHash(i.id,t),showAddFunds:o})},Or=({address:e,name:t,identiconHash:o,showAddFunds:a,id:n,type:i})=>{let l=s(u=>u.onRampConfig),{setSelectedWallet:r}=Ce(),c=s(u=>u.setStep),p=l.isBuyEnabled||l.isReceiveEnabled;return nn(ul,{children:[nn(ml,{children:[et(pl,{size:"48px",hash:o}),nn(Cl,{children:[!!t&&et(_r,{color:"contrast",variant:"bodyL",weight:"semiBold",children:t}),et(_r,{color:"secondary",variant:"bodyS",weight:"medium",children:e})]})]}),a&&p&&et(fl,{onClick:()=>{n&&i&&(r({id:n,type:i}),p&&c(l.isBuyEnabled?"ADD_FUNDS_BUY":"ADD_FUNDS_RECEIVE"))},children:et(Rr,{variant:"bodyXS",color:"contrast",weight:"medium",children:"Add Funds"})})]})},Jt=ht.div`
71
+ `;import{useEffect as Al}from"react";import ht from"styled-components";import{CpslButton as dl,CpslIdenticon as pl,CpslText as Rr}from"@getpara/react-components";import{truncateAddress as Lr}from"@getpara/web-sdk";import{useEffect as il}from"react";import{useEffect as el,useRef as tl}from"react";var B=()=>Z(t=>t.client);var qt=()=>{let e=Z(n=>n.isOpen),t=Z(n=>n.setIsOpen);return{isOpen:e,openModal:()=>{t(!0)},closeModal:()=>{t(!1)}}};var Ce=()=>{let e=B(),t=Z(l=>l.selectedWalletId),o=Z(l=>l.selectedWalletType),a=Z(l=>l.setSelectedWallet),n=Z(l=>l.clearSelectedWallet);return{selectedWallet:{id:t,type:o},setSelectedWallet:({id:l,type:r})=>{try{e.findWalletId(l,{type:[r]})!==l?n():a(l,r)}catch{n()}}}};import{useQuery as Ms}from"@tanstack/react-query";var mr=async e=>{let o={isConnected:!!await e?.isFullyLoggedIn(),email:void 0,phone:void 0,wallets:void 0};return e&&o.isConnected&&(o.email=e.getEmail(),o.phone=e.getPhoneNumber(),o.wallets=e.getWallets()),o};var Ee="PARA_ACCOUNT",en=()=>{let e=B();return Ms({queryKey:[Ee,e?.getUserId()],queryFn:async()=>await mr(e)})};import{useQuery as Os}from"@tanstack/react-query";var Cr=async(e,t)=>{let o=await e?.isFullyLoggedIn();return!e||!o?null:e.findWallet(t?.id,t?.type)};var ye="PARA_WALLET",Nt=()=>{let e=B(),{selectedWallet:t}=Ce();return Os({queryKey:[ye,e?.getUserId(),t.id,t.type],queryFn:async()=>await Cr(e,t)})};import{useMutation as Ns,useQueryClient as vs}from"@tanstack/react-query";var fr=async(e,t)=>{if(!e)throw new Error("no para instance");if(!t)throw new Error("no valid args passed to waitForLoginAndSetup");try{let o=await e.waitForLoginAndSetup(t);if(o.isError)throw new Error("error during waitForLoginAndSetup");return o}catch(o){throw new Error(o)}};function J(e,t){let{mutate:o,mutateAsync:a,...n}=e;return{...{[t]:e.mutate,[`${t}Async`]:e.mutateAsync},...n}}var bs=()=>{let e=B(),t=vs(),o=Ns({mutationFn:async a=>await fr(e,a),onSettled:async()=>{await t.invalidateQueries({queryKey:[Ee],exact:!1}),await t.invalidateQueries({queryKey:[ye],exact:!1})}});return J(o,"waitForLoginAndSetup")};import{useMutation as Ds,useQueryClient as Us}from"@tanstack/react-query";var Ar=async e=>{if(!e)throw new Error("no para instance");try{let t=await e.waitForAccountCreation();if(!t)throw new Error("error during waitForAccountCreation");return t}catch(t){throw new Error(t)}};var Ps=()=>{let e=B(),t=Us(),o=Ds({mutationFn:async()=>await Ar(e),onSettled:async()=>{await t.invalidateQueries({queryKey:[Ee],exact:!1}),await t.invalidateQueries({queryKey:[ye],exact:!1})}});return J(o,"waitForAccountCreation")};import{useMutation as Fs,useQueryClient as ks}from"@tanstack/react-query";var Sr=async e=>{if(!e)throw new Error("no para instance");try{let t=await e.waitForPasskeyAndCreateWallet();if(!t)throw new Error("error during waitForAccountCreation");return t}catch(t){throw new Error(t)}};var Bs=()=>{let e=B(),t=ks(),o=Fs({mutationFn:async()=>await Sr(e),onSettled:async()=>{await t.invalidateQueries({queryKey:[Ee],exact:!1}),await t.invalidateQueries({queryKey:[ye],exact:!1})}});return J(o,"waitForPasskeyAndCreateWallet")};import{useMutation as Hs}from"@tanstack/react-query";var Er=async(e,t)=>{if(!e)throw new Error("no para instance");if(!t)throw new Error("no valid args passed to createUser");try{await(t.type==="EMAIL"?e.createUser({email:t.identifier}):e.createUserByPhone({phone:t.identifier,countryCode:t.countryCode}))}catch(o){throw new Error(o)}};var Gs=()=>{let e=B(),t=Hs({mutationFn:async o=>await Er(e,o)});return J(t,"createUser")};import{useMutation as Vs}from"@tanstack/react-query";var hr=async(e,t)=>{if(!e)throw new Error("no para instance");if(!t)throw new Error("no valid args passed to checkIfUserExists");try{return await(t.type==="EMAIL"?e.checkIfUserExists({email:t.identifier}):e.checkIfUserExistsByPhone({phone:t.identifier,countryCode:t.countryCode}))}catch(o){throw new Error(o)}};var $s=()=>{let e=B(),t=Vs({mutationFn:async o=>await hr(e,o)});return J(t,"checkIfUserExists")};import{useMutation as Ks}from"@tanstack/react-query";var Tr=async(e,t)=>{if(!e)throw new Error("no para instance");if(!t)throw new Error("no valid args passed to initiateLogin");try{return await e.initiateUserLoginV2(t)}catch(o){throw new Error(o)}};var Ys=()=>{let e=B(),t=Ks({mutationFn:async o=>await Tr(e,o)});return J(t,"initiateLogin")};import{useMutation as Xs,useQueryClient as zs}from"@tanstack/react-query";var Ir=async e=>{if(!e)throw new Error("no para instance");try{await e.logout()}catch(t){throw new Error(t)}};var tn=()=>{let e=B(),t=zs(),o=Z(n=>n.clearSelectedWallet),a=Xs({mutationFn:async()=>await Ir(e),onSettled:async()=>{await t.invalidateQueries({queryKey:[Ee],exact:!1}),await t.invalidateQueries({queryKey:[ye],exact:!1}),o()}});return J(a,"logout")};import{useMutation as Qs}from"@tanstack/react-query";var gr=async e=>{if(!e)throw new Error("no para instance");try{if(!await e.keepSessionAlive())throw new Error("session expired")}catch(t){throw new Error(t)}};var on=()=>{let e=B(),t=Qs({mutationFn:async()=>await gr(e)});return J(t,"keepSessionAlive")};import{useMutation as qs}from"@tanstack/react-query";var yr=async(e,t)=>{if(!e)throw new Error("no para instance");if(!t)throw new Error("no valid args passed to signMessage");try{return await e.signMessage(t)}catch(o){throw new Error(o)}};var Zs=()=>{let e=B(),{data:t}=Nt(),o=qs({mutationFn:async a=>{let n=a?.walletId;if(n||(n=t?.id),!n)throw Error("no wallet id found");return await yr(e,{...a,walletId:n})}});return J(o,"signMessage")};import{useMutation as Js}from"@tanstack/react-query";var xr=async(e,t)=>{if(!e)throw new Error("no para instance");if(!t)throw new Error("no valid args passed to signTransaction");try{return await e.signTransaction(t)}catch(o){throw new Error(o)}};var js=()=>{let e=B(),{data:t}=Nt(),o=Js({mutationFn:async a=>{let n=a?.walletId;if(n||(n=t?.id),!n)throw Error("no wallet id found");return await xr(e,{...a,walletId:n})}});return J(o,"signTransaction")};var ol=6e4,nl=3e5,wr=({disabled:e})=>{let t=B(),{data:o}=en(),{logoutAsync:a}=tn(),{keepSessionAliveAsync:n}=on(),i=tl(null);el(()=>{if(!t||e){c();return}return o?.isConnected?r():c(),()=>c()},[t,o,e]);let l=async()=>{try{let p=await t.retrieveSessionCookie();if(!p)return null;let d=p.match(/Expires=([^;]+)/);return d?new Date(d[1]):null}catch{return null}},r=()=>{c(),i.current=setInterval(async()=>{let p=await l();if(!p){await a(),c();return}let d=p.getTime()-Date.now();if(d<=0){await a(),c();return}if(d<=nl){try{await n(),r()}catch(u){console.error("Failed to keep session alive:",u),await a(),c()}return}},ol)},c=()=>{i.current&&clearInterval(i.current)}};import{useQueryClient as rl}from"@tanstack/react-query";import{useEffect as al}from"react";import{ParaEvent as j}from"@getpara/web-sdk";var Wr=({onLogin:e,onLogout:t,onAccountSetup:o,onAccountCreation:a,onSignMessage:n,onSignTransaction:i,onWalletCreated:l,onPregenWalletClaimed:r,onExternalWalletChange:c,onWalletsChange:p}={})=>{let d=rl(),u=B(),A=Z(x=>x.clearSelectedWallet),{selectedWallet:m,setSelectedWallet:f}=Ce(),S=x=>{D(),e?.(x)},y=x=>{D(),o?.(x)},D=()=>{d.invalidateQueries({queryKey:[Ee],exact:!1}),d.invalidateQueries({queryKey:[ye],exact:!1})},W=x=>{a?.(x)},E=x=>{d.invalidateQueries({queryKey:[Ee],exact:!1}),A(),t?.(x)},h=x=>{n?.(x)},R=x=>{i?.(x)},C=x=>{U(),p?.(x)},L=x=>{U(),c?.(x)},T=x=>{l?.(x)},g=x=>{r?.(x)},U=()=>{if(!u){A();return}if(!m?.id||!u.findWallet(m?.id)){let x=u.findWallet(void 0,void 0,{forbidPregen:!0});f({id:x?.id,type:x?.type})}};al(()=>(window.addEventListener(j.LOGIN_EVENT,S),window.addEventListener(j.ACCOUNT_SETUP_EVENT,y),window.addEventListener(j.ACCOUNT_CREATION_EVENT,W),window.addEventListener(j.LOGOUT_EVENT,E),window.addEventListener(j.SIGN_MESSAGE_EVENT,h),window.addEventListener(j.SIGN_TRANSACTION_EVENT,R),window.addEventListener(j.WALLETS_CHANGE_EVENT,C),window.addEventListener(j.EXTERNAL_WALLET_CHANGE_EVENT,L),window.addEventListener(j.WALLET_CREATED,T),window.addEventListener(j.PREGEN_WALLET_CLAIMED,g),()=>{window.removeEventListener(j.LOGIN_EVENT,S),window.removeEventListener(j.ACCOUNT_SETUP_EVENT,y),window.removeEventListener(j.ACCOUNT_CREATION_EVENT,W),window.removeEventListener(j.LOGOUT_EVENT,E),window.removeEventListener(j.SIGN_MESSAGE_EVENT,h),window.removeEventListener(j.SIGN_TRANSACTION_EVENT,R),window.removeEventListener(j.WALLETS_CHANGE_EVENT,C),window.removeEventListener(j.EXTERNAL_WALLET_CHANGE_EVENT,L),window.removeEventListener(j.WALLET_CREATED,T),window.removeEventListener(j.PREGEN_WALLET_CLAIMED,g)}),[u])};import{ParaInternal as sl}from"@getpara/react-common";var ll={disableAutoSessionKeepAlive:!1},cl=({children:e,paraClientConfig:t,callbacks:o,config:a=ll})=>{Wr(o),wr({disabled:a.disableAutoSessionKeepAlive});let n=Z(i=>i.setClient);return il(()=>{let i=a.paraClientOverride??new sl(t.env,t.apiKey,t.opts);n(i)},[t,a.paraClientOverride]),e};var RS=()=>mt.getState().client,LS=()=>mt.getState().isOpen,MS=()=>mt.getState().selectedWalletId,OS=()=>mt.getState().selectedWalletType;import{jsx as et,jsxs as nn}from"react/jsx-runtime";var Mr=({address:e,showAddFunds:t})=>{let o=b(),a=o.externalWallets[e];return a?et(Or,{address:Lr(a.address,a.type),identiconHash:o.getIdenticonHash(a.id,a.type),showAddFunds:t}):null},Zt=({id:e,type:t,showAddFunds:o})=>{let a=b(),n=_(r=>r.appName),i=a.findWallet(e,t);if(!i)return null;let l=a.getDisplayAddress(i.id,{addressType:t});return et(Or,{id:i.id,type:i.type,address:Lr(l,t,{prefix:a.cosmosPrefix}),name:i.name??`${n?`${n} `:""}Wallet`,identiconHash:a.getIdenticonHash(i.id,t),showAddFunds:o})},Or=({address:e,name:t,identiconHash:o,showAddFunds:a,id:n,type:i})=>{let l=s(u=>u.onRampConfig),{setSelectedWallet:r}=Ce(),c=s(u=>u.setStep),p=l.isBuyEnabled||l.isReceiveEnabled;return nn(ul,{children:[nn(ml,{children:[et(pl,{size:"48px",hash:o}),nn(Cl,{children:[!!t&&et(_r,{color:"contrast",variant:"bodyL",weight:"semiBold",children:t}),et(_r,{color:"secondary",variant:"bodyS",weight:"medium",children:e})]})]}),a&&p&&et(fl,{onClick:()=>{n&&i&&(r({id:n,type:i}),p&&c(l.isBuyEnabled?"ADD_FUNDS_BUY":"ADD_FUNDS_RECEIVE"))},children:et(Rr,{variant:"bodyXS",color:"contrast",weight:"medium",children:"Add Funds"})})]})},Jt=ht.div`
72
72
  display: flex;
73
73
  flex-direction: column;
74
74
  gap: 8px;
@@ -169,7 +169,7 @@ import{CpslAuthModal as nm,defineCustomElements as rm,generateTheme as am}from"@
169
169
  `,nc=ot(Jr)`
170
170
  transform: rotate(90deg);
171
171
  --icon-color: #fff;
172
- `;import{isMobile as Ic}from"@getpara/web-sdk";import{useMemo as rc}from"react";function nt(){let e=b(),{selectedWallet:t}=Ce();return rc(()=>e.findWallet(t.id,t.type,{forbidPregen:!0}),[e,t])}import{motion as gc,AnimatePresence as yc}from"framer-motion";import{createContext as ac,useCallback as ea,useContext as so,useEffect as ic,useMemo as It,useState as ta}from"react";import{WalletType as we,isIOS as sc,isIOSWebview as lc,isMobile as io,truncateAddress as oa}from"@getpara/web-sdk";import{jsx as dc}from"react/jsx-runtime";var cc={wallets:[],chains:[],chainId:void 0,wallet:void 0,qrUri:void 0,chainIdSwitchingTo:void 0,walletDisplayHelpers:{showExtension:!1,showMobile:!1,isSolanaMobileIOS:!1,isCosmosMobileWallet:!1},username:void 0,avatar:void 0,connectExternalWallet:()=>{},disconnectExternalWallet:()=>Promise.resolve(),switchChain:()=>Promise.resolve(),setChainIdSwitchingTo:()=>{}},na=ac(cc);function ra({children:e,evmContext:t,solanaContext:o,cosmosContext:a,walletSort:n}){let{wallets:i,disconnect:l,chains:r,chainId:c,switchChain:p,username:d,avatar:u}=so(t),{wallets:A,disconnect:m}=so(o),{wallets:f,disconnect:S,chains:y,chainId:D,switchChain:W}=so(a),E=s(g=>g.setStep),h=s(g=>g.setStepDirection),R=s(g=>g.setIsExternalWalletConnecting),C=s(g=>g.isExternalWalletConnecting),L=s(g=>g.setSelectedExternalWalletId),T=s(g=>g.selectedExternalWalletId),I=s(g=>g.setExternalWalletError),U=s(g=>g.setIsUsingMobileConnector),x=s(g=>g.isUsingMobileConnector),P=b(),[K,M]=ta(),[ne,ae]=ta(),ce=[...i,...A,...f].filter(g=>n.includes(g.id.toUpperCase())).sort((g,H)=>n.indexOf(g.id.toUpperCase())-n.indexOf(H.id.toUpperCase())).sort((g,H)=>g.installed===H.installed?0:g.installed?-1:1),Y=It(()=>ce.find(g=>g.id===T),[ce,T]),N=async()=>{let g=await Y?.getQrUri?.();M(g)};ic(()=>{Y?K||N():K&&M(void 0)},[Y]);let Q=It(()=>{switch(P.externalWallets[P.currentExternalWalletAddresses?.[0]??""]?.type){case we.COSMOS:return y;case we.EVM:return r;default:return[]}},[y,r,T]),te=It(()=>{switch(P.externalWallets[P.currentExternalWalletAddresses?.[0]??""]?.type){case we.COSMOS:return D;case we.EVM:return c?.toString();default:return}},[y,r,T]),G=ea(async g=>{let H=P.externalWallets[P.currentExternalWalletAddresses?.[0]??""]?.type;if(H){let q;switch(I(),ae(g),H){case we.COSMOS:{E("CHAIN_SWITCH"),q=await W(g);break}case we.EVM:{E("CHAIN_SWITCH"),q=await p(parseInt(g));break}default:break}q.error?I(q.error):(ae(void 0),h(-1),E("ACCOUNT_MAIN"))}},[p,W]),de=ea(async(g,H,q,pe)=>{if(C&&q&&(await l(),await m(),await S(),M(void 0),R(!1)),pe||q||!C){I(),R(!0),U(H);let{address:ue,error:me}=await(H?g.connectMobile(q):g.connect());if(me){if(I([me]),U(),q&&me==="Connection request rejected"){I(),await de(g,!1,!1,!0),await N();return}}else ue&&E("LOGIN_DONE");R(!1)}},[C]),De=async()=>{await l(),await m(),await S(),L()},pt={showExtension:!io()&&(Y?.isExtension&&Y?.installed||!Y?.isMobile||Y?.type===we.SOLANA),showMobile:io()&&Y?.isMobile||!io()&&!Y?.installed,isSolanaMobileIOS:sc()&&io()&&!lc()&&Y?.type===we.SOLANA,isCosmosMobileWallet:Y?.type===we.COSMOS&&x},Ue=It(()=>{let g,H=P.externalWallets[P.currentExternalWalletAddresses?.[0]??""];if(H)switch(H?.type){case we.EVM:{g=d?d.startsWith("0x")?oa(d,"EVM"):d:void 0;break}default:{g=H.address?oa(H.address,H.type):void 0;break}}return g},[d,Y]),w=It(()=>{let g=P.externalWallets[P.currentExternalWalletAddresses?.[0]??""]?.type;if(g)switch(g){case we.EVM:return u;default:return}},[u,Y]);return dc(na.Provider,{value:It(()=>({wallets:ce,chains:Q,chainId:te,wallet:Y,qrUri:K,walletDisplayHelpers:pt,chainIdSwitchingTo:ne,username:Ue,avatar:w,connectExternalWallet:de,disconnectExternalWallet:De,switchChain:G,setChainIdSwitchingTo:ae}),[ce,Q,te,Y,K,pt,ne,Ue,w,De,de,G,ae]),children:e})}var $=()=>so(na);import{getNetworkFromChainId as xc,getNetworkOrMainNetEquivalent as wc,useCopyToClipboard as Wc}from"@getpara/react-common";import{format as Sh}from"date-fns";var aa=e=>e.length===1?bt(e[0]):`${e.map(t=>bt(t)).slice(0,-1).join(", ")}${e.length>2?",":""} and ${bt(e[e.length-1])}`;import En from"styled-components";import{Fragment as co,jsx as ee,jsxs as We}from"react/jsx-runtime";var ca=[[rt.BUY,"isBuyEnabled","creditCard","Buy"],[rt.RECEIVE,"isReceiveEnabled","qrCode","Receive"],[rt.WITHDRAW,"isWithdrawEnabled","arrowCircleBrokenDownLeft","Withdraw"]],_c={[An.EVM]:"Ethereum or EVM-based L2s",[An.SOLANA]:"Solana",[An.COSMOS]:"Cosmos"},pa=()=>{let[e,t]=Wc(),o=b(),a=_(h=>h.appName),n=s(h=>h.onRampConfig),i=_(h=>h.hideWallets),l=s(h=>h.accountAddFundTab),r=s(h=>h.setStep),c=s(h=>h.setOnRampPurchase),{chainId:p}=$(),d=nt(),u=ca.filter(([,h])=>!!n[h]),A=u.length>1,m=l??u[0][0],f=la(()=>d?o.getDisplayAddress(d.id,{addressType:d.type}):"",[o,d?.id,d?.type]),S=h=>{r(ut(h.detail.tab))},y=()=>{t(f)},[D,W,E]=la(()=>{if(!n||!d)return[[],[],{}];let h=m===rt.BUY?lo.BUY:lo.SELL,R=xc(p),L=d.isExternal&&!!R?[wc(R,n.testMode)]:uc(n.assetInfo,{walletType:d.type,allowed:n.allowedAssets?Object.keys(n.allowedAssets):void 0}),T=L.reduce((U,x)=>{let P=n.allowedAssets?.[x],K=P===!0?void 0:P;return{...U,[x]:pc(n.assetInfo,{walletType:d.type,network:x,allowed:K})}},{}),I=n.providers.reduce((U,x)=>{let P=Cc(n.assetInfo).some(([K,M,ne,ae])=>K===d.type&&L.includes(M)&&(!T[M]||T[M].includes(ne))&&!!ae[x]?.[1]?.[h]);return{...U,[x]:P}},{});return[L,[...new Set(Object.values(T).flat())],I]},[d?.type,d?.isExternal,m,n.assetInfo,n.allowedAssets,p]);return Sn(()=>{c(void 0)},[]),Sn(()=>{c(void 0)},[]),!n||!d?ee(Rc,{children:ee(sa,{})}):(Sn(()=>{c(void 0)},[]),We(F,{children:[A&&ee(O,{children:ee(Tc,{selectedTab:m,onCpslTabsChanged:S,children:ca.map(([h,R,C,L])=>We(hc,{tab:h,children:[ee(ia,{slot:"start",icon:C}),L]},h))})}),ee(co,{children:[rt.BUY,rt.WITHDRAW].includes(m)?We(co,{children:[ee(X,{variant:"headingS",weight:"bold",children:"Choose Provider"}),We(Lc,{children:[We(Mc,{isHidden:Object.values(E).some(h=>!!h),variant:"bodyM",children:["No providers are available for this ",i?"account":"wallet"]}),ee(yc,{children:n.providers.map((h,R)=>E[h]?ee(gc.div,{style:{width:"100%"},layout:!0,initial:{opacity:0,transform:"translateX(25px)"},animate:{opacity:1,transform:"none"},exit:{opacity:0,transform:"translateX(-25px)"},transition:{duration:.2},children:ee(jr,{config:n,index:R,onClick:async()=>{if(!d?.type)return;let C=h!==mc.RAMP,{onRampPurchase:L}=await o.initiateOnRampTransaction({walletId:d.isExternal?void 0:d.id,externalWalletAddress:d.isExternal?d.id:void 0,shouldOpenPopup:C,params:{type:m===rt.BUY?lo.BUY:lo.SELL,walletType:d.type,provider:h,networks:D,assets:W,defaultNetwork:n.defaultOnRampNetwork,defaultAsset:n.defaultOnRampAsset,fiatQuantity:n.defaultBuyAmount?.[0],testMode:n.testMode}});c({...L,fiat:"USD"}),!C&&r("ADD_FUNDS_AWAITING")}},h)},h):null)})]})]}):We(co,{children:[ee(O,{children:We(Mt,{noAutoDisable:!0,readonly:!0,placeholder:f,children:[ee(Sc,{slot:"start",size:"32px",hash:o.getIdenticonHash(d.id,d.type)}),ee(fc,{slot:"end",variant:"ghost",onClick:y,children:ee(ia,{icon:e?"check":"copy"})})]},f)}),!Ic()&&We(co,{children:[ee(Ac,{children:"or"}),We(O,{children:[ee(Se,{children:f?ee(Ec,{url:f},f):ee(sa,{size:100})}),ee(da,{weight:"semiBold",color:"secondary",children:"Scan with your crypto wallet"})]})]}),We(O,{children:[We(ie,{weight:"semiBold",children:[n.allowedAssets&&D.length>0||i?a??"This App":"This Wallet"," ","Only Supports:"]}),ee(ie,{weight:"medium",color:"secondary",children:n.allowedAssets&&D.length>0?aa(D):_c[d.type]})]})]})})]}))},Rc=En(F)`
172
+ `;import{isMobile as Ic}from"@getpara/web-sdk";import{useMemo as rc}from"react";function nt(){let e=b(),{selectedWallet:t}=Ce();return rc(()=>e.findWallet(t.id,t.type,{forbidPregen:!0}),[e,t])}import{motion as gc,AnimatePresence as yc}from"framer-motion";import{createContext as ac,useCallback as ea,useContext as so,useEffect as ic,useMemo as It,useState as ta}from"react";import{WalletType as we,isIOS as sc,isIOSWebview as lc,isMobile as io,truncateAddress as oa}from"@getpara/web-sdk";import{jsx as dc}from"react/jsx-runtime";var cc={wallets:[],chains:[],chainId:void 0,wallet:void 0,qrUri:void 0,chainIdSwitchingTo:void 0,walletDisplayHelpers:{showExtension:!1,showMobile:!1,isSolanaMobileIOS:!1,isCosmosMobileWallet:!1},username:void 0,avatar:void 0,connectExternalWallet:()=>{},disconnectExternalWallet:()=>Promise.resolve(),switchChain:()=>Promise.resolve(),setChainIdSwitchingTo:()=>{}},na=ac(cc);function ra({children:e,evmContext:t,solanaContext:o,cosmosContext:a,walletSort:n}){let{wallets:i,disconnect:l,chains:r,chainId:c,switchChain:p,username:d,avatar:u}=so(t),{wallets:A,disconnect:m}=so(o),{wallets:f,disconnect:S,chains:y,chainId:D,switchChain:W}=so(a),E=s(I=>I.setStep),h=s(I=>I.setStepDirection),R=s(I=>I.setIsExternalWalletConnecting),C=s(I=>I.isExternalWalletConnecting),L=s(I=>I.setSelectedExternalWalletId),T=s(I=>I.selectedExternalWalletId),g=s(I=>I.setExternalWalletError),U=s(I=>I.setIsUsingMobileConnector),x=s(I=>I.isUsingMobileConnector),P=b(),[K,M]=ta(),[ne,ae]=ta(),ce=[...i,...A,...f].filter(I=>n.includes(I.id.toUpperCase())).sort((I,H)=>n.indexOf(I.id.toUpperCase())-n.indexOf(H.id.toUpperCase())).sort((I,H)=>I.installed===H.installed?0:I.installed?-1:1),Y=It(()=>ce.find(I=>I.id===T),[ce,T]),N=async()=>{let I=await Y?.getQrUri?.();M(I)};ic(()=>{Y?K||N():K&&M(void 0)},[Y]);let Q=It(()=>{switch(P.externalWallets[P.currentExternalWalletAddresses?.[0]??""]?.type){case we.COSMOS:return y;case we.EVM:return r;default:return[]}},[y,r,T]),te=It(()=>{switch(P.externalWallets[P.currentExternalWalletAddresses?.[0]??""]?.type){case we.COSMOS:return D;case we.EVM:return c?.toString();default:return}},[y,r,T]),G=ea(async I=>{let H=P.externalWallets[P.currentExternalWalletAddresses?.[0]??""]?.type;if(H){let q;switch(g(),ae(I),H){case we.COSMOS:{E("CHAIN_SWITCH"),q=await W(I);break}case we.EVM:{E("CHAIN_SWITCH"),q=await p(parseInt(I));break}default:break}q.error?g(q.error):(ae(void 0),h(-1),E("ACCOUNT_MAIN"))}},[p,W]),de=ea(async(I,H,q,pe)=>{if(C&&q&&(await l(),await m(),await S(),M(void 0),R(!1)),pe||q||!C){g(),R(!0),U(H);let{address:ue,error:me}=await(H?I.connectMobile(q):I.connect());if(me){if(g([me]),U(),q&&me==="Connection request rejected"){g(),await de(I,!1,!1,!0),await N();return}}else ue&&E("LOGIN_DONE");R(!1)}},[C]),De=async()=>{await l(),await m(),await S(),L()},pt={showExtension:!io()&&(Y?.isExtension&&Y?.installed||!Y?.isMobile||Y?.type===we.SOLANA),showMobile:io()&&Y?.isMobile||!io()&&!Y?.installed,isSolanaMobileIOS:sc()&&io()&&!lc()&&Y?.type===we.SOLANA,isCosmosMobileWallet:Y?.type===we.COSMOS&&x},Ue=It(()=>{let I,H=P.externalWallets[P.currentExternalWalletAddresses?.[0]??""];if(H)switch(H?.type){case we.EVM:{I=d?d.startsWith("0x")?oa(d,"EVM"):d:void 0;break}default:{I=H.address?oa(H.address,H.type):void 0;break}}return I},[d,Y]),w=It(()=>{let I=P.externalWallets[P.currentExternalWalletAddresses?.[0]??""]?.type;if(I)switch(I){case we.EVM:return u;default:return}},[u,Y]);return dc(na.Provider,{value:It(()=>({wallets:ce,chains:Q,chainId:te,wallet:Y,qrUri:K,walletDisplayHelpers:pt,chainIdSwitchingTo:ne,username:Ue,avatar:w,connectExternalWallet:de,disconnectExternalWallet:De,switchChain:G,setChainIdSwitchingTo:ae}),[ce,Q,te,Y,K,pt,ne,Ue,w,De,de,G,ae]),children:e})}var $=()=>so(na);import{getNetworkFromChainId as xc,getNetworkOrMainNetEquivalent as wc,useCopyToClipboard as Wc}from"@getpara/react-common";import{format as Sh}from"date-fns";var aa=e=>e.length===1?bt(e[0]):`${e.map(t=>bt(t)).slice(0,-1).join(", ")}${e.length>2?",":""} and ${bt(e[e.length-1])}`;import En from"styled-components";import{Fragment as co,jsx as ee,jsxs as We}from"react/jsx-runtime";var ca=[[rt.BUY,"isBuyEnabled","creditCard","Buy"],[rt.RECEIVE,"isReceiveEnabled","qrCode","Receive"],[rt.WITHDRAW,"isWithdrawEnabled","arrowCircleBrokenDownLeft","Withdraw"]],_c={[An.EVM]:"Ethereum or EVM-based L2s",[An.SOLANA]:"Solana",[An.COSMOS]:"Cosmos"},pa=()=>{let[e,t]=Wc(),o=b(),a=_(h=>h.appName),n=s(h=>h.onRampConfig),i=_(h=>h.hideWallets),l=s(h=>h.accountAddFundTab),r=s(h=>h.setStep),c=s(h=>h.setOnRampPurchase),{chainId:p}=$(),d=nt(),u=ca.filter(([,h])=>!!n[h]),A=u.length>1,m=l??u[0][0],f=la(()=>d?o.getDisplayAddress(d.id,{addressType:d.type}):"",[o,d?.id,d?.type]),S=h=>{r(ut(h.detail.tab))},y=()=>{t(f)},[D,W,E]=la(()=>{if(!n||!d)return[[],[],{}];let h=m===rt.BUY?lo.BUY:lo.SELL,R=xc(p),L=d.isExternal&&!!R?[wc(R,n.testMode)]:uc(n.assetInfo,{walletType:d.type,allowed:n.allowedAssets?Object.keys(n.allowedAssets):void 0}),T=L.reduce((U,x)=>{let P=n.allowedAssets?.[x],K=P===!0?void 0:P;return{...U,[x]:pc(n.assetInfo,{walletType:d.type,network:x,allowed:K})}},{}),g=n.providers.reduce((U,x)=>{let P=Cc(n.assetInfo).some(([K,M,ne,ae])=>K===d.type&&L.includes(M)&&(!T[M]||T[M].includes(ne))&&!!ae[x]?.[1]?.[h]);return{...U,[x]:P}},{});return[L,[...new Set(Object.values(T).flat())],g]},[d?.type,d?.isExternal,m,n.assetInfo,n.allowedAssets,p]);return Sn(()=>{c(void 0)},[]),Sn(()=>{c(void 0)},[]),!n||!d?ee(Rc,{children:ee(sa,{})}):(Sn(()=>{c(void 0)},[]),We(F,{children:[A&&ee(O,{children:ee(Tc,{selectedTab:m,onCpslTabsChanged:S,children:ca.map(([h,R,C,L])=>We(hc,{tab:h,children:[ee(ia,{slot:"start",icon:C}),L]},h))})}),ee(co,{children:[rt.BUY,rt.WITHDRAW].includes(m)?We(co,{children:[ee(X,{variant:"headingS",weight:"bold",children:"Choose Provider"}),We(Lc,{children:[We(Mc,{isHidden:Object.values(E).some(h=>!!h),variant:"bodyM",children:["No providers are available for this ",i?"account":"wallet"]}),ee(yc,{children:n.providers.map((h,R)=>E[h]?ee(gc.div,{style:{width:"100%"},layout:!0,initial:{opacity:0,transform:"translateX(25px)"},animate:{opacity:1,transform:"none"},exit:{opacity:0,transform:"translateX(-25px)"},transition:{duration:.2},children:ee(jr,{config:n,index:R,onClick:async()=>{if(!d?.type)return;let C=h!==mc.RAMP,{onRampPurchase:L}=await o.initiateOnRampTransaction({walletId:d.isExternal?void 0:d.id,externalWalletAddress:d.isExternal?d.id:void 0,shouldOpenPopup:C,params:{type:m===rt.BUY?lo.BUY:lo.SELL,walletType:d.type,provider:h,networks:D,assets:W,defaultNetwork:n.defaultOnRampNetwork,defaultAsset:n.defaultOnRampAsset,fiatQuantity:n.defaultBuyAmount?.[0],testMode:n.testMode}});c({...L,fiat:"USD"}),!C&&r("ADD_FUNDS_AWAITING")}},h)},h):null)})]})]}):We(co,{children:[ee(O,{children:We(Mt,{noAutoDisable:!0,readonly:!0,placeholder:f,children:[ee(Sc,{slot:"start",size:"32px",hash:o.getIdenticonHash(d.id,d.type)}),ee(fc,{slot:"end",variant:"ghost",onClick:y,children:ee(ia,{icon:e?"check":"copy"})})]},f)}),!Ic()&&We(co,{children:[ee(Ac,{children:"or"}),We(O,{children:[ee(Se,{children:f?ee(Ec,{url:f},f):ee(sa,{size:100})}),ee(da,{weight:"semiBold",color:"secondary",children:"Scan with your crypto wallet"})]})]}),We(O,{children:[We(ie,{weight:"semiBold",children:[n.allowedAssets&&D.length>0||i?a??"This App":"This Wallet"," ","Only Supports:"]}),ee(ie,{weight:"medium",color:"secondary",children:n.allowedAssets&&D.length>0?aa(D):_c[d.type]})]})]})})]}))},Rc=En(F)`
173
173
  margin: 50% 0;
174
174
  `,Lc=En(O)`
175
175
  position: relative;
@@ -273,7 +273,7 @@ import{CpslAuthModal as nm,defineCustomElements as rm,generateTheme as am}from"@
273
273
 
274
274
  background: linear-gradient(0deg, var(--cpsl-color-background-0) 0%, rgba(234, 239, 211, 0) 100%);
275
275
  pointer-events: none;
276
- `;var Ao={GOOGLE:"googleBrand",TWITTER:"twitter",APPLE:"apple",DISCORD:"discordBrand",FACEBOOK:"facebookBrand",FARCASTER:"farcasterBrand",TELEGRAM:"telegramBrand"},So={GOOGLE:"google",TWITTER:"twitter",APPLE:"apple",DISCORD:"discord",FACEBOOK:"facebook",FARCASTER:"farcaster",TELEGRAM:"telegram"};import{useMemo as Pd}from"react";import Fd from"styled-components";import{AuthMethod as fd,OAuthMethod as wn}from"@getpara/web-sdk";import{styled as _a}from"styled-components";var ya=(e,t)=>{if(t<2)return"1 1 auto";if(t%3===0)return`0 0 calc(33.333333% - ${5.336}px)`;if(t%3===1)return e<4?"0 0 calc(50% - 4px)":`0 0 calc(33.333333% - ${5.336}px)`;if(t%3===2)return e<2?"0 0 calc(50% - 4px)":`0 0 calc(33.333333% - ${5.336}px)`};import{useEffect as Ad}from"react";import{isAndroid as md,isMobile as Cd,isTelegram as xa}from"@getpara/web-sdk";var at=e=>{if(!(typeof window>"u")&&Cd()){if(!e)return;if(!xa()&&e.startsWith("http")){let t=document.createElement("a");t.href=e,t.target="_blank",t.rel="noreferrer noopener",t.click()}else if(xa()){let t=e;md()&&(t=encodeURI(e)),window.open(t,"_blank","noreferrer noopener")}else window.location.href=e}};import{jsx as Wa,jsxs as Ed}from"react/jsx-runtime";var Pt=3,Ra=({methods:e})=>{let t=Me(),o=_(C=>C.oAuthLogoVariant),a=_(C=>C.isDark),n=b(),i=s(C=>C.popupWindow),l=s(C=>C.setFlow),r=s(C=>C.setStep),c=s(C=>C.setPopupWindow),p=V(C=>C.setAuthInfo),d=s(C=>C.setSupportedAuthMethods),u=s(C=>C.setBiometricLocationHints),A=s(C=>C.setFarcasterConnectUri),m=s(C=>C.farcasterConnectUri),f=s(C=>C.step==="AUTH_MORE");Ad(()=>{(async()=>{if(!e.includes(wn.FARCASTER))return;let L=await n.getFarcasterConnectURL();A(L)})()},[]);let S=e.length>Pt,y=f||!S?e:e.slice(0,Pt-1),D=()=>{r("AUTH_MORE")},W=C=>async()=>{if(!i)switch(C){case wn.FARCASTER:if(!m)return;at(m),r("FARCASTER_OAUTH");return;case wn.TELEGRAM:r("TELEGRAM_OAUTH");break;default:{r("AWAITING_OAUTH");let L=await n.getOAuthURL({method:C}),T=je(L,`${C}AuthPopup`,"OAUTH");c(T);let{email:I,isError:U,userExists:x}=await n.waitForOAuth({popupWindow:T});if(c(void 0),U){t();return}if(!I)throw r("AUTH_MAIN"),new Error("email is required");if(p({email:I}),x){let P=await n.initiateUserLoginV2({email:I});if(P.size===0)l("signUp"),r("BIOMETRIC_CREATION");else{let K=P.has(fd.PASSKEY)?await n.getUserBiometricLocationHints():[];l("login"),r("BIOMETRIC_LOGIN"),d(P),u(K);return}}await n.createUser({email:I}),l("signUp"),r("VERIFICATIONS");return}}},E=o==="default",h=E?a:o!=="dark",R=!f&&S;return Ed(Sd,{children:[y.map((C,L)=>Wa(wa,{$isDark:h,icon:E?Ao[C]:So[C],onClick:W(C),$index:L,$totalItems:R?Pt:y.length},C)),R&&Wa(wa,{$isDark:h,icon:"moreLoginOptions",onClick:D,$index:Pt-1,$totalItems:Pt})]})},Sd=_a.div`
276
+ `;var Ao={GOOGLE:"googleBrand",TWITTER:"twitter",APPLE:"apple",DISCORD:"discordBrand",FACEBOOK:"facebookBrand",FARCASTER:"farcasterBrand",TELEGRAM:"telegramBrand"},So={GOOGLE:"google",TWITTER:"twitter",APPLE:"apple",DISCORD:"discord",FACEBOOK:"facebook",FARCASTER:"farcaster",TELEGRAM:"telegram"};import{useMemo as Pd}from"react";import Fd from"styled-components";import{AuthMethod as fd,OAuthMethod as wn}from"@getpara/web-sdk";import{styled as _a}from"styled-components";var ya=(e,t)=>{if(t<2)return"1 1 auto";if(t%3===0)return`0 0 calc(33.333333% - ${5.336}px)`;if(t%3===1)return e<4?"0 0 calc(50% - 4px)":`0 0 calc(33.333333% - ${5.336}px)`;if(t%3===2)return e<2?"0 0 calc(50% - 4px)":`0 0 calc(33.333333% - ${5.336}px)`};import{useEffect as Ad}from"react";import{isAndroid as md,isMobile as Cd,isTelegram as xa}from"@getpara/web-sdk";var at=e=>{if(!(typeof window>"u")&&Cd()){if(!e)return;if(!xa()&&e.startsWith("http")){let t=document.createElement("a");t.href=e,t.target="_blank",t.rel="noreferrer noopener",t.click()}else if(xa()){let t=e;md()&&(t=encodeURI(e)),window.open(t,"_blank","noreferrer noopener")}else window.location.href=e}};import{jsx as Wa,jsxs as Ed}from"react/jsx-runtime";var Pt=3,Ra=({methods:e})=>{let t=Me(),o=_(C=>C.oAuthLogoVariant),a=_(C=>C.isDark),n=b(),i=s(C=>C.popupWindow),l=s(C=>C.setFlow),r=s(C=>C.setStep),c=s(C=>C.setPopupWindow),p=V(C=>C.setAuthInfo),d=s(C=>C.setSupportedAuthMethods),u=s(C=>C.setBiometricLocationHints),A=s(C=>C.setFarcasterConnectUri),m=s(C=>C.farcasterConnectUri),f=s(C=>C.step==="AUTH_MORE");Ad(()=>{(async()=>{if(!e.includes(wn.FARCASTER))return;let L=await n.getFarcasterConnectURL();A(L)})()},[]);let S=e.length>Pt,y=f||!S?e:e.slice(0,Pt-1),D=()=>{r("AUTH_MORE")},W=C=>async()=>{if(!i)switch(C){case wn.FARCASTER:if(!m)return;at(m),r("FARCASTER_OAUTH");break;case wn.TELEGRAM:r("TELEGRAM_OAUTH");break;default:r("AWAITING_OAUTH");let L=await n.getOAuthURL({method:C}),T=je(L,`${C}AuthPopup`,"OAUTH");c(T);let{email:g,isError:U,userExists:x}=await n.waitForOAuth({popupWindow:T});if(c(void 0),U){t();return}if(!g)throw r("AUTH_MAIN"),new Error("email is required");if(p({email:g}),x){let P=await n.initiateUserLoginV2({email:g});if(P.size>0){let K=P.has(fd.PASSKEY)?await n.getUserBiometricLocationHints():[];l("login"),r("BIOMETRIC_LOGIN"),d(P),u(K);return}}l("signUp"),r("BIOMETRIC_CREATION");break}},E=o==="default",h=E?a:o!=="dark",R=!f&&S;return Ed(Sd,{children:[y.map((C,L)=>Wa(wa,{$isDark:h,icon:E?Ao[C]:So[C],onClick:W(C),$index:L,$totalItems:R?Pt:y.length},C)),R&&Wa(wa,{$isDark:h,icon:"moreLoginOptions",onClick:D,$index:Pt-1,$totalItems:Pt})]})},Sd=_a.div`
277
277
  display: flex;
278
278
  justify-content: center;
279
279
  gap: 8px;
@@ -282,7 +282,7 @@ import{CpslAuthModal as nm,defineCustomElements as rm,generateTheme as am}from"@
282
282
  flex: ${({$index:e,$totalItems:t})=>ya(e,t)};
283
283
 
284
284
  --button-icon-color: ${({$isDark:e})=>e?"white":"black"};
285
- `;import{CpslButton as wd,CpslIcon as _n,CpslInput as Wd,CpslSelect as _d,CpslSelectItem as Rd,CpslSpinner as Ld,CpslText as Eo}from"@getpara/react-components";import{useRef as Md,useState as it}from"react";import Ht from"styled-components";import{getCountries as hd,getCountryCallingCode as Td}from"libphonenumber-js";var Id=["AC","CG","CI","CV","GF","GP","MF","NC","PM","RE","SD","SH","SJ","TA","VA","WF","XK","YT"],gd=()=>hd().filter(o=>!Id.includes(o)).map(o=>{let a=Td(o);return{label:new Intl.DisplayNames(["en"],{type:"region"}).of(o),value:`+${a}`,selectedLabel:o,icon:o}}).sort((o,a)=>o.label.localeCompare(a.label)),yd=gd(),Ft=yd;import{useEffect as xd,useState as Wn}from"react";var kt=e=>{let[t,o]=Wn(),[a,n]=Wn(),[i,l]=Wn(),r=()=>{if(typeof window<"u"){let c=Math.max(window.innerHeight-e?.current?.getBoundingClientRect().bottom-20,window.innerHeight*.25);o(c),n(e?.current?.getBoundingClientRect().width),l(e?.current?.getBoundingClientRect().height)}};return e.current&&!t&&r(),xd(()=>(typeof window<"u"&&window.addEventListener("resize",r),()=>{typeof window<"u"&&window.removeEventListener("resize",r)}),[]),{dropdownMaxHeight:t,dropdownWidth:a,mobileAnchor:i,resize:r}};var La="#################",Ma={AF:"### ### ####",AX:"## ### ####",AL:"(###) ### ###",DZ:"(###) ### ###",AS:"(###) ###-####",AD:"### ###",AO:"(###) ### ###",AI:"(###) ###-####",AG:"(###) ###-####",AR:"(###) ###-####",AM:"## ### ###",AW:"### ####",AU:"# #### ####",AT:"(###) ### ####",AZ:"(###) ### ## ##",BS:"(###) ###-####",BH:"#### ####",BD:"# ### ###",BB:"(###) ###-####",BY:"(##) ###-##-##",BE:"(###) ### ###",BZ:"###-####",BJ:"##-##-####",BM:"(###) ###-####",BT:"# ### ###",BO:"# ### ####",BA:"## ###-###",BW:"## ### ###",BR:"(##) ####-####",IO:"### ####",BN:"### ####",BG:"(###) ### ###",BF:"## ## ####",BI:"## ## ####",KH:"## ### ###",CM:"#### ####",CA:"(###) ###-####",CV:"(###) ## ##",KY:"(###) ###-####",CF:"## ## ####",TD:"## ## ## ##",CL:"# #### ####",CN:"(###) #### ####",CX:"# ## ## ##",CC:"# ## ## ##",CO:"(###) ### ####",KM:"## ## ## ##",CG:"## ### ####",CK:"## ###",CR:"#### ####",HR:"## #### ###",CU:"# ### ####",CY:"## ### ###",CZ:"### ### ###",CD:"### ### ###",DK:"## ## ## ##",DJ:"## ## ## ##",DM:"(###) ###-####",DO:"(###) ###-####",EC:"## ### ####",EG:"# #### ####",SV:"#### ####",GQ:"## ### ####",ER:"# ### ###",EE:"#### ####",SZ:"#### ####",ET:"## ### ####",FK:"#####",FO:"######",FJ:"### ####",FI:"## ### ####",FR:"## ## ## ## ##",GF:"### ## ## ##",PF:"## ## ##",GA:"# ## ## ##",GM:"### ####",GE:"(###) ## ## ##",DE:"(###) ### ####",GH:"## ### ####",GI:"### #####",GR:"(###) ### ####",GL:"## ## ##",GD:"(###) ###-####",GP:"### ## ## ##",GU:"(###) ###-####",GT:"# ### ####",GG:"(####) ### ###",GN:"## ### ###",GW:"# #######",GY:"### ####",HT:"## ## ####",VA:"### ####",HN:"####-####",HK:"#### ####",HU:"(##) ### ####",IS:"### ####",IN:"####### ###",ID:"(###) ###-####",IR:"(###) ### ####",IQ:"(###) ### ####",IE:"(###) ### ###",IM:"(####) ### ###",IL:"#-###-####",IT:"(###) #### ###",CI:"## ## ## ##",JM:"(###) ###-####",JP:"(###) ###-####",JE:"(####) ### ###",JO:"# #### ####",KZ:"(###) ###-##-##",KE:"### ######",KI:"## ###",KP:"###-###-####",KR:"(###) ####-####",XK:"## ### ###",KW:"#### ####",KG:"(###) ###-###",LA:"## ## ####",LV:"## ### ###",LB:"## ### ###",LS:"# ### ####",LR:"## ### ###",LY:"##-#######",LI:"(###) ###-####",LT:"(###) ## ###",LU:"### ### ###",MO:"#### ####",MG:"## ## ### ##",MW:"# #### ####",MY:"(###) ###-###",MV:"###-####",ML:"## ## ####",MT:"#### ####",MH:"###-####",MQ:"### ## ## ##",MR:"## ## ####",MU:"### ####",YT:"### ## ## ##",MX:"(###) ###-####",FM:"### ####",MD:"#### ####",MC:"(###) ###-###",MN:"## ## ####",ME:"## ### ###",MS:"(###) ###-####",MA:"#-####-####",MZ:"## ### ####",MM:"# ### ####",NA:"## ### ####",NR:"### ####",NP:"#-######",NL:"## ### ####",NC:"##.##.##",NZ:"## ### ###",NI:"#### ####",NE:"## ## ## ##",NG:"## ### ####",NU:"####",NF:"### ###",MK:"## ### ###",MP:"(###) ###-####",NO:"### ## ###",OM:"#### ####",PK:"(###) #######",PW:"### ####",PS:"## ### ####",PA:"####-####",PG:"(###) ## ###",PY:"## ### ####",PE:"(###) ### ###",PH:"(###) ###-####",PN:"### ####",PL:"### ### ###",PT:"## ### ####",PR:"(###) ###-####",QA:"#### ####",RE:"##### ####",RO:"## ### ####",RU:"(###) ###-##-##",RW:"(###) ### ###",BL:"### ## ## ##",SH:"####",KN:"(###) ###-####",LC:"(###) ###-####",MF:"### ## ## ##",PM:"## ## ##",VC:"(###) ###-####",WS:"####",SM:"(####) ######",ST:"## ####",SA:"# ### ####",SN:"## ### ####",RS:"## ### ####",SC:"# ### ###",SL:"## ######",SG:"#### ####",SX:"(###) ###-####",SK:"(###) ### ###",SI:"## ### ###",SB:"### ####",SO:"# ### ###",ZA:"## ### ####",GS:"####",SS:"# ### ####",ES:"### ### ###",LK:"## ### ####",SD:"## ### ####",SR:"###-####",SJ:"### ## ###",SE:"## ### ####",CH:"## ### ####",SY:"## #### ###",TW:"#### ####",TJ:"## ### ####",TZ:"## ### ####",TH:"# #### ####",TL:"#### ####",TG:"## ## ## ##",TK:"####",TO:"####",TT:"(###) ###-####",TN:"## ### ###",TR:"(###) ### ####",TM:"# ### ###",TC:"(###) ###-####",TV:"####",UG:"## ### ####",UA:"## ### ####",AE:"# ### ####",GB:"#### ### ###",US:"(###) ###-####",UM:"(###) ###-####",UY:"# ### ## ##",UZ:"## ### ####",VU:"## ####",VE:"###-###-####",VN:"## #### ###",VG:"(###) ###-####",VI:"(###) ###-####",WF:"## ####",EH:"###-###-###",YE:"# ### ###",ZM:"## ### ####",ZW:"# #######"};import{AuthMethod as Oa}from"@getpara/web-sdk";import{jsx as Oe,jsxs as Bt}from"react/jsx-runtime";var Od={label:"United States",value:"+1",selectedLabel:"US",icon:"US"},Na=({disableEmailLogin:e,disablePhoneLogin:t})=>{let o=Md(null),{dropdownMaxHeight:a,dropdownWidth:n}=kt(o),i=b(),l=V(N=>N.setAuthInfo),r=V(N=>N.getAuthInfo()),c=s(N=>N.setFlow),p=s(N=>N.setStep),d=s(N=>N.setSupportedAuthMethods),u=s(N=>N.setBiometricLocationHints),[A,m]=it(r?.authType==="phone"?r.auth.countryCode:"+1"),[f,S]=it(!r||["telegramUserId","farcasterUsername"].includes(r.authType)?"":r.authType!=="phone"?r.identifier:r.auth.phone),[y,D]=it(r&&(r.authType==="email"||r.authType==="phone")?r.authType:void 0),[W,E]=it(Od),[h,R]=it(!1),[C,L]=it(""),[T,I]=it(""),U=y==="email",x=y==="phone",P=!y,K=T?Ft.filter(N=>N.selectedLabel.toLowerCase().includes(T.toLowerCase())||N.label.toLowerCase().includes(T.toLowerCase())||N.value.toLowerCase().includes(T.toLowerCase())):Ft,M=N=>{I(N.detail)},ne=N=>{let Q=N.detail.value,te=!1,G=!1;if(!t){let de=Ft.find(De=>De.value===Q);if(de){m(de.value),E(de),D("phone"),S("");return}te=!U&&x?/\d+$/.test(Q):/\d\d\d+$/.test(Q)}e||(G=/\D.*$/.test(Q)),D(G?"email":te?"phone":void 0),S(Q)},ae=N=>{let Q=Ft.find(te=>te.selectedLabel===N.detail);m(Q.value),E(Q)},ce=async()=>{if(L(""),P){L("Please enter a valid email or phone number!");return}let N;if(U){if(!Qr.test(f)){L("Please enter a valid email!");return}if(await i.logout(),N={email:f},l(N),await i.checkIfUserExists({email:f})){let te=await i.initiateUserLoginV2(N),G=te.has(Oa.PASSKEY)?await i.getUserBiometricLocationHints():[];c("login"),p("BIOMETRIC_LOGIN"),d(te),u(G);return}await i.createUser(N),c("signUp"),p("VERIFICATIONS");return}if(x){await i.logout();let Q=!1;try{Q=await i.checkIfUserExistsByPhone({phone:f,countryCode:A})}catch{L("Please enter a valid phone number!");return}if(N={phone:f,countryCode:A},l(N),Q){let te=await i.initiateUserLoginV2(N),G=te.has(Oa.PASSKEY)?await i.getUserBiometricLocationHints():[];c("login"),p("BIOMETRIC_LOGIN"),d(te),u(G);return}await i.createUserByPhone(N),c("signUp"),p("VERIFICATIONS");return}},Y=async()=>{R(!0),await ce(),R(!1)};return e&&t?null:Oe("form",{onSubmit:async N=>{N.preventDefault(),await Y()},children:Bt(Ud,{ref:o,id:"authInput",placeholder:U||t?"Enter email":x||e?"Enter phone":"Enter email or phone",onCpslInput:ne,value:f,errorText:C,autofocus:!0,inputMode:"email",onKeyDown:async N=>N.key==="Enter"&&Y(),contrastText:!0,isPhone:x,mask:y==="phone"?Ma[W.selectedLabel]??La:void 0,enterkeyhint:"go",noAutoDisable:!0,disabled:h,"data-testid":"auth-input",children:[Bt(Nd,{slot:"start",children:[!e&&(P||U)&&Oe(_n,{"aria-label":"email",icon:"mail"}),!t&&P&&Oe(_n,{"aria-label":"phone",icon:"phone"}),x&&Bt(vd,{selectedValue:W.selectedLabel,onCpslSelectValueChange:ae,showFormattedSelectedItem:!0,autoWidth:!0,dropdownMaxHeight:a,anchorElId:"authInput",$width:n,showSearch:!0,searchPlaceholder:"Search Countries",onCpslSearchChange:M,"data-testid":"country-code-select",children:[W&&Bt(Dd,{slot:"selected-item",children:[Oe(Eo,{children:W.selectedLabel}),Oe(Eo,{children:W.value})]}),K.map(N=>Bt(bd,{slot:"items",value:N.selectedLabel,children:[Oe(Eo,{children:N.label}),Oe(Eo,{children:N.value})]},N.selectedLabel))]})]}),f&&Oe(wd,{slot:"end",size:"small",fullWidth:!0,disabled:h,onClick:Y,children:h?Oe(Ld,{size:16}):Oe(_n,{icon:"arrowNarrow"})})]},"email")})},Nd=Ht.div`
285
+ `;import{CpslButton as wd,CpslIcon as _n,CpslInput as Wd,CpslSelect as _d,CpslSelectItem as Rd,CpslSpinner as Ld,CpslText as Eo}from"@getpara/react-components";import{useRef as Md,useState as it}from"react";import Ht from"styled-components";import{getCountries as hd,getCountryCallingCode as Td}from"libphonenumber-js";var Id=["AC","CG","CI","CV","GF","GP","MF","NC","PM","RE","SD","SH","SJ","TA","VA","WF","XK","YT"],gd=()=>hd().filter(o=>!Id.includes(o)).map(o=>{let a=Td(o);return{label:new Intl.DisplayNames(["en"],{type:"region"}).of(o),value:`+${a}`,selectedLabel:o,icon:o}}).sort((o,a)=>o.label.localeCompare(a.label)),yd=gd(),Ft=yd;import{useEffect as xd,useState as Wn}from"react";var kt=e=>{let[t,o]=Wn(),[a,n]=Wn(),[i,l]=Wn(),r=()=>{if(typeof window<"u"){let c=Math.max(window.innerHeight-e?.current?.getBoundingClientRect().bottom-20,window.innerHeight*.25);o(c),n(e?.current?.getBoundingClientRect().width),l(e?.current?.getBoundingClientRect().height)}};return e.current&&!t&&r(),xd(()=>(typeof window<"u"&&window.addEventListener("resize",r),()=>{typeof window<"u"&&window.removeEventListener("resize",r)}),[]),{dropdownMaxHeight:t,dropdownWidth:a,mobileAnchor:i,resize:r}};var La="#################",Ma={AF:"### ### ####",AX:"## ### ####",AL:"(###) ### ###",DZ:"(###) ### ###",AS:"(###) ###-####",AD:"### ###",AO:"(###) ### ###",AI:"(###) ###-####",AG:"(###) ###-####",AR:"(###) ###-####",AM:"## ### ###",AW:"### ####",AU:"# #### ####",AT:"(###) ### ####",AZ:"(###) ### ## ##",BS:"(###) ###-####",BH:"#### ####",BD:"# ### ###",BB:"(###) ###-####",BY:"(##) ###-##-##",BE:"(###) ### ###",BZ:"###-####",BJ:"##-##-####",BM:"(###) ###-####",BT:"# ### ###",BO:"# ### ####",BA:"## ###-###",BW:"## ### ###",BR:"(##) ####-####",IO:"### ####",BN:"### ####",BG:"(###) ### ###",BF:"## ## ####",BI:"## ## ####",KH:"## ### ###",CM:"#### ####",CA:"(###) ###-####",CV:"(###) ## ##",KY:"(###) ###-####",CF:"## ## ####",TD:"## ## ## ##",CL:"# #### ####",CN:"(###) #### ####",CX:"# ## ## ##",CC:"# ## ## ##",CO:"(###) ### ####",KM:"## ## ## ##",CG:"## ### ####",CK:"## ###",CR:"#### ####",HR:"## #### ###",CU:"# ### ####",CY:"## ### ###",CZ:"### ### ###",CD:"### ### ###",DK:"## ## ## ##",DJ:"## ## ## ##",DM:"(###) ###-####",DO:"(###) ###-####",EC:"## ### ####",EG:"# #### ####",SV:"#### ####",GQ:"## ### ####",ER:"# ### ###",EE:"#### ####",SZ:"#### ####",ET:"## ### ####",FK:"#####",FO:"######",FJ:"### ####",FI:"## ### ####",FR:"## ## ## ## ##",GF:"### ## ## ##",PF:"## ## ##",GA:"# ## ## ##",GM:"### ####",GE:"(###) ## ## ##",DE:"(###) ### ####",GH:"## ### ####",GI:"### #####",GR:"(###) ### ####",GL:"## ## ##",GD:"(###) ###-####",GP:"### ## ## ##",GU:"(###) ###-####",GT:"# ### ####",GG:"(####) ### ###",GN:"## ### ###",GW:"# #######",GY:"### ####",HT:"## ## ####",VA:"### ####",HN:"####-####",HK:"#### ####",HU:"(##) ### ####",IS:"### ####",IN:"####### ###",ID:"(###) ###-####",IR:"(###) ### ####",IQ:"(###) ### ####",IE:"(###) ### ###",IM:"(####) ### ###",IL:"#-###-####",IT:"(###) #### ###",CI:"## ## ## ##",JM:"(###) ###-####",JP:"(###) ###-####",JE:"(####) ### ###",JO:"# #### ####",KZ:"(###) ###-##-##",KE:"### ######",KI:"## ###",KP:"###-###-####",KR:"(###) ####-####",XK:"## ### ###",KW:"#### ####",KG:"(###) ###-###",LA:"## ## ####",LV:"## ### ###",LB:"## ### ###",LS:"# ### ####",LR:"## ### ###",LY:"##-#######",LI:"(###) ###-####",LT:"(###) ## ###",LU:"### ### ###",MO:"#### ####",MG:"## ## ### ##",MW:"# #### ####",MY:"(###) ###-###",MV:"###-####",ML:"## ## ####",MT:"#### ####",MH:"###-####",MQ:"### ## ## ##",MR:"## ## ####",MU:"### ####",YT:"### ## ## ##",MX:"(###) ###-####",FM:"### ####",MD:"#### ####",MC:"(###) ###-###",MN:"## ## ####",ME:"## ### ###",MS:"(###) ###-####",MA:"#-####-####",MZ:"## ### ####",MM:"# ### ####",NA:"## ### ####",NR:"### ####",NP:"#-######",NL:"## ### ####",NC:"##.##.##",NZ:"## ### ###",NI:"#### ####",NE:"## ## ## ##",NG:"## ### ####",NU:"####",NF:"### ###",MK:"## ### ###",MP:"(###) ###-####",NO:"### ## ###",OM:"#### ####",PK:"(###) #######",PW:"### ####",PS:"## ### ####",PA:"####-####",PG:"(###) ## ###",PY:"## ### ####",PE:"(###) ### ###",PH:"(###) ###-####",PN:"### ####",PL:"### ### ###",PT:"## ### ####",PR:"(###) ###-####",QA:"#### ####",RE:"##### ####",RO:"## ### ####",RU:"(###) ###-##-##",RW:"(###) ### ###",BL:"### ## ## ##",SH:"####",KN:"(###) ###-####",LC:"(###) ###-####",MF:"### ## ## ##",PM:"## ## ##",VC:"(###) ###-####",WS:"####",SM:"(####) ######",ST:"## ####",SA:"# ### ####",SN:"## ### ####",RS:"## ### ####",SC:"# ### ###",SL:"## ######",SG:"#### ####",SX:"(###) ###-####",SK:"(###) ### ###",SI:"## ### ###",SB:"### ####",SO:"# ### ###",ZA:"## ### ####",GS:"####",SS:"# ### ####",ES:"### ### ###",LK:"## ### ####",SD:"## ### ####",SR:"###-####",SJ:"### ## ###",SE:"## ### ####",CH:"## ### ####",SY:"## #### ###",TW:"#### ####",TJ:"## ### ####",TZ:"## ### ####",TH:"# #### ####",TL:"#### ####",TG:"## ## ## ##",TK:"####",TO:"####",TT:"(###) ###-####",TN:"## ### ###",TR:"(###) ### ####",TM:"# ### ###",TC:"(###) ###-####",TV:"####",UG:"## ### ####",UA:"## ### ####",AE:"# ### ####",GB:"#### ### ###",US:"(###) ###-####",UM:"(###) ###-####",UY:"# ### ## ##",UZ:"## ### ####",VU:"## ####",VE:"###-###-####",VN:"## #### ###",VG:"(###) ###-####",VI:"(###) ###-####",WF:"## ####",EH:"###-###-###",YE:"# ### ###",ZM:"## ### ####",ZW:"# #######"};import{AuthMethod as Oa}from"@getpara/web-sdk";import{jsx as Oe,jsxs as Bt}from"react/jsx-runtime";var Od={label:"United States",value:"+1",selectedLabel:"US",icon:"US"},Na=({disableEmailLogin:e,disablePhoneLogin:t})=>{let o=Md(null),{dropdownMaxHeight:a,dropdownWidth:n}=kt(o),i=b(),l=V(N=>N.setAuthInfo),r=V(N=>N.getAuthInfo()),c=s(N=>N.setFlow),p=s(N=>N.setStep),d=s(N=>N.setSupportedAuthMethods),u=s(N=>N.setBiometricLocationHints),[A,m]=it(r?.authType==="phone"?r.auth.countryCode:"+1"),[f,S]=it(!r||["telegramUserId","farcasterUsername"].includes(r.authType)?"":r.authType!=="phone"?r.identifier:r.auth.phone),[y,D]=it(r&&(r.authType==="email"||r.authType==="phone")?r.authType:void 0),[W,E]=it(Od),[h,R]=it(!1),[C,L]=it(""),[T,g]=it(""),U=y==="email",x=y==="phone",P=!y,K=T?Ft.filter(N=>N.selectedLabel.toLowerCase().includes(T.toLowerCase())||N.label.toLowerCase().includes(T.toLowerCase())||N.value.toLowerCase().includes(T.toLowerCase())):Ft,M=N=>{g(N.detail)},ne=N=>{let Q=N.detail.value,te=!1,G=!1;if(!t){let de=Ft.find(De=>De.value===Q);if(de){m(de.value),E(de),D("phone"),S("");return}te=!U&&x?/\d+$/.test(Q):/\d\d\d+$/.test(Q)}e||(G=/\D.*$/.test(Q)),D(G?"email":te?"phone":void 0),S(Q)},ae=N=>{let Q=Ft.find(te=>te.selectedLabel===N.detail);m(Q.value),E(Q)},ce=async()=>{if(L(""),P){L("Please enter a valid email or phone number!");return}let N;if(U){if(!Qr.test(f)){L("Please enter a valid email!");return}if(await i.logout(),N={email:f},l(N),await i.checkIfUserExists({email:f})){let te=await i.initiateUserLoginV2(N),G=te.has(Oa.PASSKEY)?await i.getUserBiometricLocationHints():[];c("login"),p("BIOMETRIC_LOGIN"),d(te),u(G);return}await i.createUser(N),c("signUp"),p("VERIFICATIONS");return}if(x){await i.logout();let Q=!1;try{Q=await i.checkIfUserExistsByPhone({phone:f,countryCode:A})}catch{L("Please enter a valid phone number!");return}if(N={phone:f,countryCode:A},l(N),Q){let te=await i.initiateUserLoginV2(N),G=te.has(Oa.PASSKEY)?await i.getUserBiometricLocationHints():[];c("login"),p("BIOMETRIC_LOGIN"),d(te),u(G);return}await i.createUserByPhone(N),c("signUp"),p("VERIFICATIONS");return}},Y=async()=>{R(!0),await ce(),R(!1)};return e&&t?null:Oe("form",{onSubmit:async N=>{N.preventDefault(),await Y()},children:Bt(Ud,{ref:o,id:"authInput",placeholder:U||t?"Enter email":x||e?"Enter phone":"Enter email or phone",onCpslInput:ne,value:f,errorText:C,autofocus:!0,inputMode:"email",onKeyDown:async N=>N.key==="Enter"&&Y(),contrastText:!0,isPhone:x,mask:y==="phone"?Ma[W.selectedLabel]??La:void 0,enterkeyhint:"go",noAutoDisable:!0,disabled:h,"data-testid":"auth-input",children:[Bt(Nd,{slot:"start",children:[!e&&(P||U)&&Oe(_n,{"aria-label":"email",icon:"mail"}),!t&&P&&Oe(_n,{"aria-label":"phone",icon:"phone"}),x&&Bt(vd,{selectedValue:W.selectedLabel,onCpslSelectValueChange:ae,showFormattedSelectedItem:!0,autoWidth:!0,dropdownMaxHeight:a,anchorElId:"authInput",$width:n,showSearch:!0,searchPlaceholder:"Search Countries",onCpslSearchChange:M,"data-testid":"country-code-select",children:[W&&Bt(Dd,{slot:"selected-item",children:[Oe(Eo,{children:W.selectedLabel}),Oe(Eo,{children:W.value})]}),K.map(N=>Bt(bd,{slot:"items",value:N.selectedLabel,children:[Oe(Eo,{children:N.label}),Oe(Eo,{children:N.value})]},N.selectedLabel))]})]}),f&&Oe(wd,{slot:"end",size:"small",fullWidth:!0,disabled:h,onClick:Y,children:h?Oe(Ld,{size:16}):Oe(_n,{icon:"arrowNarrow"})})]},"email")})},Nd=Ht.div`
286
286
  height: 100%;
287
287
  display: flex;
288
288
  align-items: center;
@@ -537,7 +537,7 @@ Please choose another wallet or continue on desktop.`;return z(O,{children:z(Va,
537
537
  visibility: ${({bareModal:e})=>e?"hidden":"visible"};
538
538
  `,Yp=wo(Ei)`
539
539
  transform: rotate(180deg);
540
- `;import{useEffect as wi,useState as uu}from"react";import{AuthMethod as Ti,OAuthMethod as zp}from"@getpara/web-sdk";import Gn from"styled-components";import{useEffect as Hn,useRef as Qp,useState as $t}from"react";import{HeroSpinner as qp}from"@getpara/react-common";import{CpslSpinner as Zp}from"@getpara/react-components";import{jsx as Wo,jsxs as tu}from"react/jsx-runtime";function Ii(){let e=Qp(),t=b(),o=s(C=>C.setFlow),a=s(C=>C.setStep),n=V(C=>C.setAuthInfo),i=s(C=>C.setBiometricLocationHints),l=s(C=>C.setSupportedAuthMethods),r=s(C=>C.setIFrameUrl),c=s(C=>C.setIsIFrameReady),p=s(C=>C.isIFrameReady),d=s(C=>C.setWebAuthURLForCreate),u=_(C=>C.theme),[A,m]=$t(void 0),[f,S]=$t(!1),[y,D]=$t(!1),[W,E]=$t(!1),[h,R]=$t();return Hn(()=>{h&&p&&setTimeout(()=>{a(h)},200)},[h,p]),Hn(()=>{A||t.getOAuthURL({method:zp.TELEGRAM}).then(C=>{m(C)})},[A]),Hn(()=>{let C=async L=>{switch(L.data.type){case"TELEGRAM_LOGIN":S(!0),E(!1);break;case"TELEGRAM_FAILED":S(!1),E(!0);break;case"TELEGRAM_SUCCESS":if(L.data.payload){let T=L.data.payload,I=await t.verifyTelegram(T);if(!I.isValid){S(!1),E(!0),e.current&&e.current.contentWindow.postMessage({type:"TELEGRAM_FAILED"},"*");return}let{telegramUserId:U,isNewUser:x,supportedAuthMethods:P,biometricHints:K}=I;if(n({telegramUserId:U,pfpUrl:T.photo_url,displayName:T.username?`@${T.username}`:T.first_name?`${T.first_name}${T.last_name?` ${T.last_name}`:""}`:`Telegram User @${U}`}),x){let M=await t.getSupportedCreateAuthMethods();c(!1),o("signUp");let ne=M.has(Ti.PASSKEY);ne&&(d(await t.shortenLoginLink(await t.getSetUpBiometricsURL({authType:"telegram"}))),a("BIOMETRIC_CREATION")),M.has(Ti.PASSWORD)&&(r(await t.shortenLoginLink(await t.getSetupPasswordURL({authType:"telegram",theme:u}))),R(ne?"BIOMETRIC_CREATION":"PASSWORD_CREATION"))}else o("login"),P&&l(new Set(P)),K&&i(K),a("BIOMETRIC_LOGIN")}break}};return window?.addEventListener("message",C,!1),()=>{window?.removeEventListener("message",C,!1)}},[]),tu(Jp,{children:[Wo(jp,{children:Wo(qp,{icon:"telegramBrand",status:f?"loading":W?"error":"inactive",text:f?"Follow the on-screen prompts.":W?"Login Failed":void 0})}),A&&Wo(eu,{ref:e,style:{display:y?"block":"none"},src:A,onLoad:()=>D(!0)}),(!A||!y)&&Wo(Zp,{})]})}var Jp=Gn.div`
540
+ `;import{useEffect as wi,useState as uu}from"react";import{AuthMethod as Ti,OAuthMethod as zp}from"@getpara/web-sdk";import Gn from"styled-components";import{useEffect as Hn,useRef as Qp,useState as $t}from"react";import{HeroSpinner as qp}from"@getpara/react-common";import{CpslSpinner as Zp}from"@getpara/react-components";import{jsx as Wo,jsxs as tu}from"react/jsx-runtime";function Ii(){let e=Qp(),t=b(),o=s(C=>C.setFlow),a=s(C=>C.setStep),n=V(C=>C.setAuthInfo),i=s(C=>C.setBiometricLocationHints),l=s(C=>C.setSupportedAuthMethods),r=s(C=>C.setIFrameUrl),c=s(C=>C.setIsIFrameReady),p=s(C=>C.isIFrameReady),d=s(C=>C.setWebAuthURLForCreate),u=_(C=>C.theme),[A,m]=$t(void 0),[f,S]=$t(!1),[y,D]=$t(!1),[W,E]=$t(!1),[h,R]=$t();return Hn(()=>{h&&p&&setTimeout(()=>{a(h)},200)},[h,p]),Hn(()=>{A||t.getOAuthURL({method:zp.TELEGRAM}).then(C=>{m(C)})},[A]),Hn(()=>{let C=async L=>{switch(L.data.type){case"TELEGRAM_LOGIN":S(!0),E(!1);break;case"TELEGRAM_FAILED":S(!1),E(!0);break;case"TELEGRAM_SUCCESS":if(L.data.payload){let T=L.data.payload,g=await t.verifyTelegram(T);if(!g.isValid){S(!1),E(!0),e.current&&e.current.contentWindow.postMessage({type:"TELEGRAM_FAILED"},"*");return}let{telegramUserId:U,isNewUser:x,supportedAuthMethods:P,biometricHints:K}=g;if(n({telegramUserId:U,pfpUrl:T.photo_url,displayName:T.username?`@${T.username}`:T.first_name?`${T.first_name}${T.last_name?` ${T.last_name}`:""}`:`Telegram User @${U}`}),x){let M=await t.getSupportedCreateAuthMethods();c(!1),o("signUp");let ne=M.has(Ti.PASSKEY);ne&&(d(await t.shortenLoginLink(await t.getSetUpBiometricsURL({authType:"telegram"}))),a("BIOMETRIC_CREATION")),M.has(Ti.PASSWORD)&&(r(await t.shortenLoginLink(await t.getSetupPasswordURL({authType:"telegram",theme:u}))),R(ne?"BIOMETRIC_CREATION":"PASSWORD_CREATION"))}else o("login"),P&&l(new Set(P)),K&&i(K),a("BIOMETRIC_LOGIN")}break}};return window?.addEventListener("message",C,!1),()=>{window?.removeEventListener("message",C,!1)}},[]),tu(Jp,{children:[Wo(jp,{children:Wo(qp,{icon:"telegramBrand",status:f?"loading":W?"error":"inactive",text:f?"Follow the on-screen prompts.":W?"Login Failed":void 0})}),A&&Wo(eu,{ref:e,style:{display:y?"block":"none"},src:A,onLoad:()=>D(!0)}),(!A||!y)&&Wo(Zp,{})]})}var Jp=Gn.div`
541
541
  display: flex;
542
542
  flex-direction: column;
543
543
  align-items: center;
@@ -661,7 +661,7 @@ Please choose another wallet or continue on desktop.`;return z(O,{children:z(Va,
661
661
  --icon-color: var(--cpsl-color-text-secondary);
662
662
  --width: 49px;
663
663
  --height: auto;
664
- `;var dt={LOGGIN_POLLING_DELAY_MS:5e3,POLLING_INTERVAL_MS:2e3,ANIMATION_DURATION:.15};import{create as vu}from"zustand";var Ni=e=>({updateState:t=>{e(t)}});var bu={EvmProvider:void 0,evmContext:void 0,SolanaProvider:void 0,solanaContext:void 0,CosmosProvider:void 0,cosmosContext:void 0,connectParaEvmWallet:void 0,connectParaCosmosWallet:void 0},se=vu(e=>({...bu,...Ni(e)}));var vi=()=>{let e=se(r=>r.connectParaEvmWallet),t=se(r=>r.EvmProvider),o=se(r=>r.evmContext),a=se(r=>r.connectParaCosmosWallet),n=se(r=>r.CosmosProvider),i=se(r=>r.cosmosContext);return async()=>{if(o&&t&&e)try{let{error:r}=await e();r&&console.warn("Failed to connect Para EVM wallet to Wagmi:",r)}catch(r){console.warn("Error calling connectParaEvmWallet:",r)}if(i&&n&&a)try{let{error:r}=await a();r&&console.warn("Failed to connect Para Cosmos wallet to Graz:",r)}catch(r){console.warn("Error calling connectParaCosmosWallet:",r)}}};import{Fragment as Gu,jsx as Di,jsxs as Vu}from"react/jsx-runtime";function Bu(e){return"hostApiKey"in e}var Hu={[fe.SOLANA]:_t.SOLANA,[fe.ATOM]:_t.COSMOS,[fe.CELO]:_t.CELO,[fe.POLYGON]:_t.POLYGON},Vn={SOLANA:fe.SOLANA,SOL:fe.SOLANA,ATOM:fe.ATOM,CELO:fe.CELO,POLYGON:fe.POLYGON,MATIC:fe.POLYGON,USDC:fe.USDC,ETH:fe.ETHEREUM,ETHEREUM:fe.ETHEREUM},Ui=Du(({onRampConfig:e,twoFactorAuthEnabled:t=!1,recoverySecretStepEnabled:o=!1,oAuthMethods:a,disableEmailLogin:n,disablePhoneLogin:i,onClose:l,onRampTestMode:r,loginTransitionOverride:c,createWalletOverride:p},d)=>{let u=b(),A=s(w=>w.step),m=s(w=>w.webAuthURLForLogin),f=s(w=>w.webAuthURLForCreate),S=s(w=>w.passwordUrlForLogin),y=s(w=>w.isLogin()),D=s(w=>w.popupWindow),W=s(w=>w.onRampConfig),E=s(w=>w.setStep),h=s(w=>w.setBiometricLocationHints),R=s(w=>w.setWebAuthURLForLogin),C=s(w=>w.setWebAuthURLForCreate),L=s(w=>w.setPopupWindow),T=s(w=>w.setIFrameUrl),I=s(w=>w.setPasswordUrlForLogin),U=s(w=>w.setSupportedAuthMethods),x=s(w=>w.setOnRampConfig),P=s(w=>w.accountAddFundTab),K=s(w=>w.setAccountAddFundTab),M=V(w=>w.setRecoveryShare),ne=Me(),ae=bi(),ce=bi(),[Y,N]=Pu(!1),Q=vi();Uu(d,()=>({handleModalClose(){Ue()}}),[]);let te=async()=>{if(!t)return!0;try{let{isSetup:w}=await u.check2FAStatus();return w}catch(w){return console.error("An error occurred while checking 2FA:",w),!1}};async function G(){let{isComplete:w,isError:g,needsWallet:H}=await u.waitForLoginAndSetup({popupWindow:D});if(L(void 0),g){ne();return}w&&(R(""),I(""),U(new Set),h(),H?E("AWAITING_WALLET_CREATION"):(await Q(),await te()?E("LOGIN_DONE"):E("SETUP_2FA")))}async function de(){await u.waitForAccountCreation()&&(C(""),T(""),E("AWAITING_WALLET_CREATION"))}Wt(()=>{if(A!=="AWAITING_WALLET_CREATION"||Y)return;async function w(){N(!0);let g,H;if(p){let q=await p(u),pe=(await u.fetchWallets()).filter(me=>!!me.address),ue={};for(let me of pe)ue[me.id]={...Fu(me),signer:""};u.setWallets(ue),g=q.recoverySecret,H=q.walletIds}else{let q=await u.waitForPasskeyAndCreateWallet();g=q.recoverySecret,H=q.walletIds}await u.setCurrentWalletIds(H),o&&M(g),N(!1),E(!g||!o?"WALLET_CREATION_DONE":"SECRET")}w()},[y,A]);async function De(){E("PASSWORD_CREATION")}async function pt(){typeof window<"u"&&(clearTimeout(ce.current),ce.current=window.setTimeout(de,dt.POLLING_INTERVAL_MS),je(f,"ParaPasskey","CREATE_PASSKEY"),E("AWAITING_BIOMETRIC_CREATION"))}Wt(()=>{if(m||S){if(c){async function w(){await c(u),R(""),I(""),h(),await Q(),await te()?E("LOGIN_DONE"):E("SETUP_2FA")}w();return}typeof window<"u"&&(ae.current=window.setTimeout(G,dt.LOGGIN_POLLING_DELAY_MS))}return()=>{typeof window<"u"&&window.clearTimeout(ae.current),u.exitLogin()}},[m,S,D]);let Ue=()=>{l()};return Wt(()=>{["BIOMETRIC_CREATION","AWAITING_BIOMETRIC_CREATION"].includes(A)||u.exitAccountCreation(),["BIOMETRIC_LOGIN","AWAITING_BIOMETRIC_LOGIN"].includes(A)||u.exitLogin(),["AWAITING_OAUTH","FARCASTER_OAUTH"].includes(A)||u.exitOAuth(),A==="PASSWORD_CREATION"&&typeof window<"u"&&(clearTimeout(ce.current),ce.current=window.setTimeout(de,dt.POLLING_INTERVAL_MS))},[A]),Wt(()=>{W||u.ctx.client.getOnRampConfig().then(w=>{let g;if(e){let{enabledFlows:H,network:q,asset:pe,providers:ue,testMode:me}=e,Ho=ue.find(ge=>Bu(ge));g={isBuyEnabled:!H||H.some(ge=>He[ge]===He.BUY),isReceiveEnabled:!H||H.some(ge=>He[ge]===He.RECEIVE),isWithdrawEnabled:!H||H.some(ge=>He[ge]===He.WITHDRAW),allowedAssets:q?{[_t[q]]:pe?[Vn[pe]]:!0}:pe?{[Hu[Vn[pe]]??_t.ETHEREUM]:[Vn[pe]]}:w.allowedAssets,assetInfo:w.assetInfo,providers:ue.map(({id:ge})=>ku[ge]),rampApiKey:Ho?.hostApiKey??w.rampApiKey,testMode:me??r}}else g={...w,testMode:r};x(g),P||K(g.isBuyEnabled?He.BUY:g.isReceiveEnabled?He.RECEIVE:g.isWithdrawEnabled?He.WITHDRAW:void 0)}).catch()},[]),Wt(()=>{W&&x({...W,testMode:r})},[r]),Wt(()=>()=>{u.exitLoops()},[]),Vu(Gu,{children:[Di(Ri,{oAuthMethods:a,twoFactorAuthEnabled:t,disableEmailLogin:n,disablePhoneLogin:i,onClose:Ue,createAccountWithPasskey:pt,createAccountWithPassword:De}),Di(Oi,{})]})});import{forwardRef as Fi,useEffect as be,useImperativeHandle as im,useRef as sm,useState as Fo}from"react";import{ParaEvent as Po}from"@getpara/web-sdk";import{useEffect as om,useState as Rt}from"react";import{createContext as $u,useMemo as Ku}from"react";import{jsx as Xu}from"react/jsx-runtime";var Yu={wallets:[],chains:[],chainId:void 0,username:void 0,avatar:void 0,disconnect:()=>Promise.resolve(),switchChain:()=>Promise.resolve({})},Mo=$u(Yu);function $n({children:e}){let t=[],o=[],l=()=>Promise.resolve(),r=()=>Promise.resolve({});return Xu(Mo.Provider,{value:Ku(()=>({wallets:t,chains:o,chainId:void 0,username:void 0,avatar:void 0,disconnect:l,switchChain:r}),[t,o,void 0,void 0,void 0,l,r]),children:e})}var Oo=(l=>(l.METAMASK="METAMASK",l.RAINBOW="RAINBOW",l.COINBASE="COINBASE",l.WALLETCONNECT="WALLETCONNECT",l.ZERION="ZERION",l.RABBY="RABBY",l))(Oo||{}),No=(a=>(a.PHANTOM="PHANTOM",a.GLOW="GLOW",a.BACKPACK="BACKPACK",a))(No||{}),vo=(o=>(o.KEPLR="KEPLR",o.LEAP="LEAP",o))(vo||{}),ew={...Oo,...No,...vo};import{createContext as zu,useMemo as Qu}from"react";import{jsx as Zu}from"react/jsx-runtime";var qu={wallets:[],disconnect:()=>Promise.resolve()},bo=zu(qu);function Kn({children:e}){let t=[],o=()=>Promise.resolve();return Zu(bo.Provider,{value:Qu(()=>({wallets:t,disconnect:o}),[t,o]),children:e})}import{createContext as Ju,useMemo as ju}from"react";import{jsx as tm}from"react/jsx-runtime";var em={wallets:[],chains:[],chainId:void 0,disconnect:()=>Promise.resolve(),switchChain:()=>Promise.resolve({})},Do=Ju(em);function Yn({children:e}){let t=[],o=[],n=()=>Promise.resolve(),i=()=>Promise.resolve({});return tm(Do.Provider,{value:ju(()=>({wallets:t,chains:o,chainId:void 0,disconnect:n,switchChain:i}),[t,o,void 0,n,i]),children:e})}import{jsx as Uo}from"react/jsx-runtime";var Pi=({children:e,wallets:t})=>{let o=b(),a=s(T=>T.resetState),n=V(T=>T.resetState),i=se(T=>T.EvmProvider),l=se(T=>T.evmContext),r=se(T=>T.SolanaProvider),c=se(T=>T.solanaContext),p=se(T=>T.CosmosProvider),d=se(T=>T.cosmosContext),[u,A]=Rt(null),[m,f]=Rt(null),[S,y]=Rt(null),[D,W]=Rt(null),[E,h]=Rt(null),[R,C]=Rt(null);om(()=>{(async()=>{let I=Mo,U=$n,x=bo,P=Kn,K=Do,M=Yn;if(!t?.length)I=Mo,U=$n,x=bo,P=Kn,K=Do,M=Yn;else for(let ne=0;ne<t.length;ne++){let ae=t[ne];if(ae in Oo){if(!i||!l)throw new Error("@getpara/evm-wallet-connectors is required to use an external EVM wallet.");I=l,U=i}if(ae in No){if(!r||!c)throw new Error("@getpara/solana-wallet-connectors is required to use an external Solana wallet.");x=c,P=r}if(ae in vo){if(!p||!d)throw new Error("@getpara/cosmos-wallet-connectors is required to use an external Cosmos wallet.");K=d,M=p}}f(I),A(()=>U),W(x),y(()=>P),C(K),h(()=>M)})()},[t,l,i,c,r,d,p]);let L=({address:T,error:I})=>{(I||!T)&&(a(),n())};return!o||!u||!S||!E?null:Uo(u,{para:o,onSwitchWallet:L,children:Uo(S,{para:o,onSwitchWallet:L,children:Uo(E,{para:o,onSwitchWallet:L,children:Uo(ra,{evmContext:m,solanaContext:D,cosmosContext:R,walletSort:t,children:e})})})})};import lm from"styled-components";import{jsx as ko}from"react/jsx-runtime";rm();var Xw=Fi(({para:e,isOpen:t,...o},a)=>{let[n,i]=Fo(!1),l=Z(d=>d.setClient),r=Z(d=>d.client),{closeModal:c,openModal:p}=qt();return be(()=>{r||l(e),i(!0)},[]),be(()=>{t||c(),t&&p()},[t]),n?ko(cm,{ref:a,para:e,...o}):null}),cm=Fi(({theme:e,appName:t,logo:o,disableEmailLogin:a=!1,disablePhoneLogin:n=!1,oAuthMethods:i,bareModal:l=!1,className:r,currentStepOverride:c,externalWallets:p,authLayout:d=["AUTH:FULL","EXTERNAL:FULL"],embeddedModal:u,onModalStepChange:A,hideWallets:m=!1,onClose:f,...S},y)=>{let D=sm(null),W=_(v=>v.updateState),E=s(v=>v.setWebAuthURLForLogin),h=s(v=>v.setWebAuthURLForCreate),R=s(v=>v.setBiometricLocationHints),C=s(v=>v.step),L=s(v=>v.setOnModalStepChange),T=s(v=>v.setStep),I=V(v=>v.setAuthInfo),U=s(v=>v.hasPreviousStep()),x=s(v=>v.setFlow),P=s(v=>v.setIsFullyLoggedIn),K=Me(),M=_(v=>v.setAuthLayout),ne=_(v=>v.authLayout),ae=s(v=>v.resetState),ce=V(v=>v.resetState),Y=V(v=>v.setRecoveryShare),{disconnectExternalWallet:N}=$(),{isOpen:Q,closeModal:te}=qt(),G=b(),{selectedWallet:de,setSelectedWallet:De}=Ce(),[pt,Ue]=Fo(!1),[w,g]=Fo(!1),[H,q]=Fo(!1);im(y,()=>({goBack(){K()},canGoBack(){return U},currentStep(){return C},handleModalClose(){D?.current?.handleModalClose()}}),[U,C]);let pe=async()=>{let v=await G.isFullyLoggedIn();switch(c?T(Ve[c.toUpperCase()]):v?(x("account"),T("ACCOUNT_MAIN"),P(!0)):(C!=="AUTH_MAIN"&&C!=="SECRET"&&(T("AUTH_MAIN"),x(),E(),h(),R()),await N(),De({id:void 0,type:void 0}),P(!1)),!0){case G.isEmail:I({email:G.getEmail()});break;case G.isPhone:{let{phone:Ge,countryCode:ki}=G.getPhone();I({phone:Ge,countryCode:ki})}break;case G.isFarcaster:I({farcasterUsername:G.getFarcasterUsername()});break;case G.isTelegram:I({telegramUserId:G.telegramUserId}),v||T("TELEGRAM_OAUTH");break}g(!0)};be(()=>{let v=d;!p?.length&&yn(d)&&(v=v.filter(Ge=>!Ge.includes("EXTERNAL"))),a&&n&&!i?.length&&Dt(d)&&(v=v.filter(Ge=>!Ge.includes("AUTH"))),JSON.stringify(ne)!==JSON.stringify(v)&&M(v)},[a,n,i,p,d]),be(()=>{L(A)},[A]),be(()=>{W({logo:o,appName:t,oAuthLogoVariant:e?.oAuthLogoVariant??"default",bareModal:l,embeddedModal:u,hideWallets:m})},[o,t,e?.oAuthLogoVariant,l,u,m]),be(()=>{e&&(am(e),W({isDark:e.mode==="dark",theme:e}))},[e]),be(()=>{G?(pe(),l&&Ue(!0)):console.error("A Para instance must be provided.")},[]),be(()=>{Q&&G&&pe()},[Q]);let ue=()=>{if(!de?.id||!G.findWallet(de?.id)){let v=G.findWallet(void 0,void 0,{forbidPregen:!0});De({id:v?.id,type:v?.type})}};be(()=>{ue()},[G]),be(()=>(typeof window<"u"&&window.addEventListener(Po.WALLETS_CHANGE_EVENT,ue),typeof window<"u"&&window.addEventListener(Po.EXTERNAL_WALLET_CHANGE_EVENT,ue),q(!0),()=>{typeof window<"u"&&window.removeEventListener(Po.WALLETS_CHANGE_EVENT,ue),typeof window<"u"&&window.removeEventListener(Po.EXTERNAL_WALLET_CHANGE_EVENT,ue)}),[]);let me=()=>{te(),f?.()},Ho=()=>{Ue(!0)},ge=async()=>{Ue(!1),Xn.includes(C)?(ae(),ce(),Y(null)):zn.includes(C)&&T("LOGIN_DONE"),G&&(await pe(),G.exitLoops()),g(!1)};if(!H)return null;if(!G)return console.error("A Para instance is required."),null;if(!ne?.length){let v=!p?.length&&yn(d),Ge=a&&n&&!i?.length&&Dt(d);return v||Ge?(v&&console.error("At least one external wallet must be provided if external wallet auth is enabled."),Ge&&console.error("At least one login method (email, phone or OAuth) must be provided if embedded wallet auth is enabled.")):console.error("At least one auth layout selection is required."),null}return ko(Pi,{wallets:p,children:ko(dm,{enterTransitionDuration:dt.ANIMATION_DURATION,exitTransitionDuration:dt.ANIMATION_DURATION,open:Q,onCpslModalExited:ge,onCpslModalEntering:Ho,onCpslModalRequestClose:me,noOverlay:l,className:r,"data-testid":"modal",$embeddedModal:u,children:pt&&(w&&u||!u)&&ko(Ui,{oAuthMethods:i,disableEmailLogin:a,disablePhoneLogin:n,onClose:me,...S})})})}),dm=lm(nm)`
664
+ `;var dt={LOGGIN_POLLING_DELAY_MS:5e3,POLLING_INTERVAL_MS:2e3,ANIMATION_DURATION:.15};import{create as vu}from"zustand";var Ni=e=>({updateState:t=>{e(t)}});var bu={EvmProvider:void 0,evmContext:void 0,SolanaProvider:void 0,solanaContext:void 0,CosmosProvider:void 0,cosmosContext:void 0,connectParaEvmWallet:void 0,connectParaCosmosWallet:void 0},se=vu(e=>({...bu,...Ni(e)}));var vi=()=>{let e=se(r=>r.connectParaEvmWallet),t=se(r=>r.EvmProvider),o=se(r=>r.evmContext),a=se(r=>r.connectParaCosmosWallet),n=se(r=>r.CosmosProvider),i=se(r=>r.cosmosContext);return async()=>{if(o&&t&&e)try{let{error:r}=await e();r&&console.warn("Failed to connect Para EVM wallet to Wagmi:",r)}catch(r){console.warn("Error calling connectParaEvmWallet:",r)}if(i&&n&&a)try{let{error:r}=await a();r&&console.warn("Failed to connect Para Cosmos wallet to Graz:",r)}catch(r){console.warn("Error calling connectParaCosmosWallet:",r)}}};import{Fragment as Gu,jsx as Di,jsxs as Vu}from"react/jsx-runtime";function Bu(e){return"hostApiKey"in e}var Hu={[fe.SOLANA]:_t.SOLANA,[fe.ATOM]:_t.COSMOS,[fe.CELO]:_t.CELO,[fe.POLYGON]:_t.POLYGON},Vn={SOLANA:fe.SOLANA,SOL:fe.SOLANA,ATOM:fe.ATOM,CELO:fe.CELO,POLYGON:fe.POLYGON,MATIC:fe.POLYGON,USDC:fe.USDC,ETH:fe.ETHEREUM,ETHEREUM:fe.ETHEREUM},Ui=Du(({onRampConfig:e,twoFactorAuthEnabled:t=!1,recoverySecretStepEnabled:o=!1,oAuthMethods:a,disableEmailLogin:n,disablePhoneLogin:i,onClose:l,onRampTestMode:r,loginTransitionOverride:c,createWalletOverride:p},d)=>{let u=b(),A=s(w=>w.step),m=s(w=>w.webAuthURLForLogin),f=s(w=>w.webAuthURLForCreate),S=s(w=>w.passwordUrlForLogin),y=s(w=>w.isLogin()),D=s(w=>w.popupWindow),W=s(w=>w.onRampConfig),E=s(w=>w.setStep),h=s(w=>w.setBiometricLocationHints),R=s(w=>w.setWebAuthURLForLogin),C=s(w=>w.setWebAuthURLForCreate),L=s(w=>w.setPopupWindow),T=s(w=>w.setIFrameUrl),g=s(w=>w.setPasswordUrlForLogin),U=s(w=>w.setSupportedAuthMethods),x=s(w=>w.setOnRampConfig),P=s(w=>w.accountAddFundTab),K=s(w=>w.setAccountAddFundTab),M=V(w=>w.setRecoveryShare),ne=Me(),ae=bi(),ce=bi(),[Y,N]=Pu(!1),Q=vi();Uu(d,()=>({handleModalClose(){Ue()}}),[]);let te=async()=>{if(!t)return!0;try{let{isSetup:w}=await u.check2FAStatus();return w}catch(w){return console.error("An error occurred while checking 2FA:",w),!1}};async function G(){let{isComplete:w,isError:I,needsWallet:H}=await u.waitForLoginAndSetup({popupWindow:D});if(L(void 0),I){ne();return}w&&(R(""),g(""),U(new Set),h(),H?E("AWAITING_WALLET_CREATION"):(await Q(),await te()?E("LOGIN_DONE"):E("SETUP_2FA")))}async function de(){await u.waitForAccountCreation()&&(C(""),T(""),E("AWAITING_WALLET_CREATION"))}Wt(()=>{if(A!=="AWAITING_WALLET_CREATION"||Y)return;async function w(){N(!0);let I,H;if(p){let q=await p(u),pe=(await u.fetchWallets()).filter(me=>!!me.address),ue={};for(let me of pe)ue[me.id]={...Fu(me),signer:""};u.setWallets(ue),I=q.recoverySecret,H=q.walletIds}else{let q=await u.waitForPasskeyAndCreateWallet();I=q.recoverySecret,H=q.walletIds}await u.setCurrentWalletIds(H),o&&M(I),N(!1),E(!I||!o?"WALLET_CREATION_DONE":"SECRET")}w()},[y,A]);async function De(){E("PASSWORD_CREATION")}async function pt(){typeof window<"u"&&(clearTimeout(ce.current),ce.current=window.setTimeout(de,dt.POLLING_INTERVAL_MS),je(f,"ParaPasskey","CREATE_PASSKEY"),E("AWAITING_BIOMETRIC_CREATION"))}Wt(()=>{if(m||S){if(c){async function w(){await c(u),R(""),g(""),h(),await Q(),await te()?E("LOGIN_DONE"):E("SETUP_2FA")}w();return}typeof window<"u"&&(ae.current=window.setTimeout(G,dt.LOGGIN_POLLING_DELAY_MS))}return()=>{typeof window<"u"&&window.clearTimeout(ae.current),u.exitLogin()}},[m,S,D]);let Ue=()=>{l()};return Wt(()=>{["BIOMETRIC_CREATION","AWAITING_BIOMETRIC_CREATION"].includes(A)||u.exitAccountCreation(),["BIOMETRIC_LOGIN","AWAITING_BIOMETRIC_LOGIN"].includes(A)||u.exitLogin(),["AWAITING_OAUTH","FARCASTER_OAUTH"].includes(A)||u.exitOAuth(),A==="PASSWORD_CREATION"&&typeof window<"u"&&(clearTimeout(ce.current),ce.current=window.setTimeout(de,dt.POLLING_INTERVAL_MS))},[A]),Wt(()=>{W||u.ctx.client.getOnRampConfig().then(w=>{let I;if(e){let{enabledFlows:H,network:q,asset:pe,providers:ue,testMode:me}=e,Ho=ue.find(ge=>Bu(ge));I={isBuyEnabled:!H||H.some(ge=>He[ge]===He.BUY),isReceiveEnabled:!H||H.some(ge=>He[ge]===He.RECEIVE),isWithdrawEnabled:!H||H.some(ge=>He[ge]===He.WITHDRAW),allowedAssets:q?{[_t[q]]:pe?[Vn[pe]]:!0}:pe?{[Hu[Vn[pe]]??_t.ETHEREUM]:[Vn[pe]]}:w.allowedAssets,assetInfo:w.assetInfo,providers:ue.map(({id:ge})=>ku[ge]),rampApiKey:Ho?.hostApiKey??w.rampApiKey,testMode:me??r}}else I={...w,testMode:r};x(I),P||K(I.isBuyEnabled?He.BUY:I.isReceiveEnabled?He.RECEIVE:I.isWithdrawEnabled?He.WITHDRAW:void 0)}).catch()},[]),Wt(()=>{W&&x({...W,testMode:r})},[r]),Wt(()=>()=>{u.exitLoops()},[]),Vu(Gu,{children:[Di(Ri,{oAuthMethods:a,twoFactorAuthEnabled:t,disableEmailLogin:n,disablePhoneLogin:i,onClose:Ue,createAccountWithPasskey:pt,createAccountWithPassword:De}),Di(Oi,{})]})});import{forwardRef as Fi,useEffect as be,useImperativeHandle as im,useRef as sm,useState as Fo}from"react";import{ParaEvent as Po}from"@getpara/web-sdk";import{useEffect as om,useState as Rt}from"react";import{createContext as $u,useMemo as Ku}from"react";import{jsx as Xu}from"react/jsx-runtime";var Yu={wallets:[],chains:[],chainId:void 0,username:void 0,avatar:void 0,disconnect:()=>Promise.resolve(),switchChain:()=>Promise.resolve({})},Mo=$u(Yu);function $n({children:e}){let t=[],o=[],l=()=>Promise.resolve(),r=()=>Promise.resolve({});return Xu(Mo.Provider,{value:Ku(()=>({wallets:t,chains:o,chainId:void 0,username:void 0,avatar:void 0,disconnect:l,switchChain:r}),[t,o,void 0,void 0,void 0,l,r]),children:e})}var Oo=(l=>(l.METAMASK="METAMASK",l.RAINBOW="RAINBOW",l.COINBASE="COINBASE",l.WALLETCONNECT="WALLETCONNECT",l.ZERION="ZERION",l.RABBY="RABBY",l))(Oo||{}),No=(a=>(a.PHANTOM="PHANTOM",a.GLOW="GLOW",a.BACKPACK="BACKPACK",a))(No||{}),vo=(o=>(o.KEPLR="KEPLR",o.LEAP="LEAP",o))(vo||{}),ew={...Oo,...No,...vo};import{createContext as zu,useMemo as Qu}from"react";import{jsx as Zu}from"react/jsx-runtime";var qu={wallets:[],disconnect:()=>Promise.resolve()},bo=zu(qu);function Kn({children:e}){let t=[],o=()=>Promise.resolve();return Zu(bo.Provider,{value:Qu(()=>({wallets:t,disconnect:o}),[t,o]),children:e})}import{createContext as Ju,useMemo as ju}from"react";import{jsx as tm}from"react/jsx-runtime";var em={wallets:[],chains:[],chainId:void 0,disconnect:()=>Promise.resolve(),switchChain:()=>Promise.resolve({})},Do=Ju(em);function Yn({children:e}){let t=[],o=[],n=()=>Promise.resolve(),i=()=>Promise.resolve({});return tm(Do.Provider,{value:ju(()=>({wallets:t,chains:o,chainId:void 0,disconnect:n,switchChain:i}),[t,o,void 0,n,i]),children:e})}import{jsx as Uo}from"react/jsx-runtime";var Pi=({children:e,wallets:t})=>{let o=b(),a=s(T=>T.resetState),n=V(T=>T.resetState),i=se(T=>T.EvmProvider),l=se(T=>T.evmContext),r=se(T=>T.SolanaProvider),c=se(T=>T.solanaContext),p=se(T=>T.CosmosProvider),d=se(T=>T.cosmosContext),[u,A]=Rt(null),[m,f]=Rt(null),[S,y]=Rt(null),[D,W]=Rt(null),[E,h]=Rt(null),[R,C]=Rt(null);om(()=>{(async()=>{let g=Mo,U=$n,x=bo,P=Kn,K=Do,M=Yn;if(!t?.length)g=Mo,U=$n,x=bo,P=Kn,K=Do,M=Yn;else for(let ne=0;ne<t.length;ne++){let ae=t[ne];if(ae in Oo){if(!i||!l)throw new Error("@getpara/evm-wallet-connectors is required to use an external EVM wallet.");g=l,U=i}if(ae in No){if(!r||!c)throw new Error("@getpara/solana-wallet-connectors is required to use an external Solana wallet.");x=c,P=r}if(ae in vo){if(!p||!d)throw new Error("@getpara/cosmos-wallet-connectors is required to use an external Cosmos wallet.");K=d,M=p}}f(g),A(()=>U),W(x),y(()=>P),C(K),h(()=>M)})()},[t,l,i,c,r,d,p]);let L=({address:T,error:g})=>{(g||!T)&&(a(),n())};return!o||!u||!S||!E?null:Uo(u,{para:o,onSwitchWallet:L,children:Uo(S,{para:o,onSwitchWallet:L,children:Uo(E,{para:o,onSwitchWallet:L,children:Uo(ra,{evmContext:m,solanaContext:D,cosmosContext:R,walletSort:t,children:e})})})})};import lm from"styled-components";import{jsx as ko}from"react/jsx-runtime";rm();var Xw=Fi(({para:e,isOpen:t,...o},a)=>{let[n,i]=Fo(!1),l=Z(d=>d.setClient),r=Z(d=>d.client),{closeModal:c,openModal:p}=qt();return be(()=>{r||l(e),i(!0)},[]),be(()=>{t||c(),t&&p()},[t]),n?ko(cm,{ref:a,para:e,...o}):null}),cm=Fi(({theme:e,appName:t,logo:o,disableEmailLogin:a=!1,disablePhoneLogin:n=!1,oAuthMethods:i,bareModal:l=!1,className:r,currentStepOverride:c,externalWallets:p,authLayout:d=["AUTH:FULL","EXTERNAL:FULL"],embeddedModal:u,onModalStepChange:A,hideWallets:m=!1,onClose:f,...S},y)=>{let D=sm(null),W=_(v=>v.updateState),E=s(v=>v.setWebAuthURLForLogin),h=s(v=>v.setWebAuthURLForCreate),R=s(v=>v.setBiometricLocationHints),C=s(v=>v.step),L=s(v=>v.setOnModalStepChange),T=s(v=>v.setStep),g=V(v=>v.setAuthInfo),U=s(v=>v.hasPreviousStep()),x=s(v=>v.setFlow),P=s(v=>v.setIsFullyLoggedIn),K=Me(),M=_(v=>v.setAuthLayout),ne=_(v=>v.authLayout),ae=s(v=>v.resetState),ce=V(v=>v.resetState),Y=V(v=>v.setRecoveryShare),{disconnectExternalWallet:N}=$(),{isOpen:Q,closeModal:te}=qt(),G=b(),{selectedWallet:de,setSelectedWallet:De}=Ce(),[pt,Ue]=Fo(!1),[w,I]=Fo(!1),[H,q]=Fo(!1);im(y,()=>({goBack(){K()},canGoBack(){return U},currentStep(){return C},handleModalClose(){D?.current?.handleModalClose()}}),[U,C]);let pe=async()=>{let v=await G.isFullyLoggedIn();switch(c?T(Ve[c.toUpperCase()]):v?(x("account"),T("ACCOUNT_MAIN"),P(!0)):(C!=="AUTH_MAIN"&&C!=="SECRET"&&(T("AUTH_MAIN"),x(),E(),h(),R()),await N(),De({id:void 0,type:void 0}),P(!1)),!0){case G.isEmail:g({email:G.getEmail()});break;case G.isPhone:{let{phone:Ge,countryCode:ki}=G.getPhone();g({phone:Ge,countryCode:ki})}break;case G.isFarcaster:g({farcasterUsername:G.getFarcasterUsername()});break;case G.isTelegram:g({telegramUserId:G.telegramUserId}),v||T("TELEGRAM_OAUTH");break}I(!0)};be(()=>{let v=d;!p?.length&&yn(d)&&(v=v.filter(Ge=>!Ge.includes("EXTERNAL"))),a&&n&&!i?.length&&Dt(d)&&(v=v.filter(Ge=>!Ge.includes("AUTH"))),JSON.stringify(ne)!==JSON.stringify(v)&&M(v)},[a,n,i,p,d]),be(()=>{L(A)},[A]),be(()=>{W({logo:o,appName:t,oAuthLogoVariant:e?.oAuthLogoVariant??"default",bareModal:l,embeddedModal:u,hideWallets:m})},[o,t,e?.oAuthLogoVariant,l,u,m]),be(()=>{e&&(am(e),W({isDark:e.mode==="dark",theme:e}))},[e]),be(()=>{G?(pe(),l&&Ue(!0)):console.error("A Para instance must be provided.")},[]),be(()=>{Q&&G&&pe()},[Q]);let ue=()=>{if(!de?.id||!G.findWallet(de?.id)){let v=G.findWallet(void 0,void 0,{forbidPregen:!0});De({id:v?.id,type:v?.type})}};be(()=>{ue()},[G]),be(()=>(typeof window<"u"&&window.addEventListener(Po.WALLETS_CHANGE_EVENT,ue),typeof window<"u"&&window.addEventListener(Po.EXTERNAL_WALLET_CHANGE_EVENT,ue),q(!0),()=>{typeof window<"u"&&window.removeEventListener(Po.WALLETS_CHANGE_EVENT,ue),typeof window<"u"&&window.removeEventListener(Po.EXTERNAL_WALLET_CHANGE_EVENT,ue)}),[]);let me=()=>{te(),f?.()},Ho=()=>{Ue(!0)},ge=async()=>{Ue(!1),Xn.includes(C)?(ae(),ce(),Y(null)):zn.includes(C)&&T("LOGIN_DONE"),G&&(await pe(),G.exitLoops()),I(!1)};if(!H)return null;if(!G)return console.error("A Para instance is required."),null;if(!ne?.length){let v=!p?.length&&yn(d),Ge=a&&n&&!i?.length&&Dt(d);return v||Ge?(v&&console.error("At least one external wallet must be provided if external wallet auth is enabled."),Ge&&console.error("At least one login method (email, phone or OAuth) must be provided if embedded wallet auth is enabled.")):console.error("At least one auth layout selection is required."),null}return ko(Pi,{wallets:p,children:ko(dm,{enterTransitionDuration:dt.ANIMATION_DURATION,exitTransitionDuration:dt.ANIMATION_DURATION,open:Q,onCpslModalExited:ge,onCpslModalEntering:Ho,onCpslModalRequestClose:me,noOverlay:l,className:r,"data-testid":"modal",$embeddedModal:u,children:pt&&(w&&u||!u)&&ko(Ui,{oAuthMethods:i,disableEmailLogin:a,disablePhoneLogin:n,onClose:me,...S})})})}),dm=lm(nm)`
665
665
  ${({$embeddedModal:e})=>e&&`
666
666
  &::part(modal-body-card) {
667
667
  --card-box-shadow: none;
package/dist/index.js.br CHANGED
Binary file
package/dist/index.js.gz CHANGED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getpara/react-sdk",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -12,9 +12,9 @@
12
12
  "*.css"
13
13
  ],
14
14
  "dependencies": {
15
- "@getpara/react-common": "1.3.0",
16
- "@getpara/react-components": "1.3.0",
17
- "@getpara/web-sdk": "1.3.0",
15
+ "@getpara/react-common": "1.3.1",
16
+ "@getpara/react-components": "1.3.1",
17
+ "@getpara/web-sdk": "1.3.1",
18
18
  "@tanstack/react-query": "^5.0.0",
19
19
  "date-fns": "^3.6.0",
20
20
  "detect-browser": "^5.3.0",
@@ -49,5 +49,5 @@
49
49
  "resolutions": {
50
50
  "styled-components": "^6"
51
51
  },
52
- "gitHead": "2d421556a0a1497abd08e18dca94f08ec3ad640b"
52
+ "gitHead": "a35e01b55fde3220d50ead988b1c18f8442a9db4"
53
53
  }