import{jsx as e}from"react/jsx-runtime";import{useState as o,useEffect as t}from"react";import{u as r}from"./context-BKnOUECq.mjs";import{R as i}from"./toViemAccount-4iGGrW4w.mjs";import{k as s}from"./errors-Dd6zfYtp.mjs";import{u as a}from"./internal-context-dfitw7Ot.mjs";import{n}from"./index-C5jxD-zy.mjs";import{u as m}from"./modal-context-DBwfUxD-.mjs";import{u as c}from"./privy-context-Bi6vqCPc.mjs";import{S as l,g as p}from"./SetWalletPasswordForm-DyC3u1As.mjs";import"@privy-io/js-sdk-core";import"tinycolor2";import"jose";import"eventemitter3";import"./index-BtwxknTg.mjs";import"zustand";import"viem";import"viem/utils";import"./wallet-connect-58EobR5U.mjs";import"./getPublicClient-D4yNgeGy.mjs";import"viem/chains";import"react-device-detect";import"@coinbase/wallet-sdk";import"@walletconnect/ethereum-provider";import"./pkce-BinverJO.mjs";import"ofetch";import"./paths-BH8W4zMc.mjs";import"./PrivyPluginContext-DA-yS5vO.mjs";import"js-cookie";import"@privy-io/ethereum";import"viem/accounts";import"mipd";import"@scure/base";import"./usePrivy-BhL-ltvm.mjs";import"./use-unlink-wallet-oAguM2-k.mjs";import"./get-entropy-details-for-user-BIWg0YxF.mjs";import"./user-D5cqJNp9.mjs";import"@privy-io/popup";import"./events-context-BJ75xIIf.mjs";import"styled-components";import"./useActiveWallet-BEfvREjE.mjs";import"@headlessui/react";import"@privy-io/urls";import"./getEmbeddedConnectedWallet-Ba6LFHzY.mjs";import"./frame-DtizlaLu.mjs";import"@privy-io/routes";import"./use-deposit-address-BwThybOQ.mjs";import"x402/client";import"@privy-io/api-base";import"@privy-io/are-addresses-equal";import"./use-sign-with-user-signer-CQI6hUH7.mjs";import"@heroicons/react/24/outline/ExclamationTriangleIcon";import"./Layouts-BlFm53ED.mjs";import"./ModalHeader-DffkxvO4.mjs";import"@heroicons/react/24/outline/ArrowLeftIcon";import"@heroicons/react/24/outline/ArrowRightIcon";import"@heroicons/react/24/outline/QuestionMarkCircleIcon";import"@heroicons/react/24/outline/XMarkIcon";import"./shared-nyNh_dA7.mjs";import"@heroicons/react/24/outline/ArrowPathIcon";import"@heroicons/react/24/outline/EyeIcon";import"@heroicons/react/24/outline/EyeSlashIcon";import"./Checkbox-BhNoOKjX.mjs";import"@heroicons/react/24/outline/KeyIcon";import"@heroicons/react/24/solid/CheckCircleIcon";import"fast-password-entropy";import"secure-password-utilities";import"secure-password-utilities/wordlists";import"@heroicons/react/24/outline/ArrowDownTrayIcon";import"@heroicons/react/24/outline/ClipboardDocumentCheckIcon";import"@heroicons/react/24/outline/DocumentDuplicateIcon";import"@heroicons/react/24/solid/XCircleIcon";import"./ScreenHeader-CHmc4-Lu.mjs";const u={component:()=>{let{navigate:u,data:d,onUserCloseViaDialogOrKeybindRef:h}=m(),w=r(),[y,j]=o(""),[v,f]=o(!1),[g,C]=o(),[x,I]=o(null),{create:b}=n(),{authenticated:P,user:S}=c(),{closePrivyModal:k,isNewUserThisSession:A,initializeWalletProxy:U}=a(),{onSuccess:E,onFailure:M,callAuthOnSuccessOnClose:T,shouldCreateEth:O,shouldCreateSol:W}=d.createWallet,[D,L]=o(null),R=new i((async()=>{try{let e;if(O&&W)e=await b({recoveryMethod:"user-passcode",recoveryPassword:g,chainType:"ethereum",walletIndex:0,latestUser:S}),e=await b({chainType:"solana",walletIndex:0,latestUser:e.user});else if(W)e=await b({recoveryMethod:"user-passcode",recoveryPassword:g,chainType:"solana",walletIndex:0,latestUser:S});else{if(!O)throw Error("Invalid args to create wallet");e=await b({recoveryMethod:"user-passcode",recoveryPassword:g,chainType:"ethereum",walletIndex:0,latestUser:S})}L(e),A?u("EmbeddedWalletCreatedScreen"):(E(e),k({shouldCallAuthOnSuccess:T}))}catch(e){j(e.message)}}));t((()=>{x||U(3e4).then((e=>I(e)))}),[x]),t((()=>{if(!P||!S)return u("LandingScreen"),void M(Error("User must be authenticated before creating a Privy wallet"))}),[P]),h.current=()=>null;/*#__PURE__*/return e(l,{config:{initiatedBy:"automatic"},appName:w?.name||"privy",loading:!x,buttonLoading:v,buttonHideAnimations:!D&&v,isResettingPassword:!1,error:y,password:g||"",onClose:()=>{D&&"user-passcode"!==D.account.recoveryMethod?(M(new s("User created a wallet but failed to set a password for it")),k({shouldCallAuthOnSuccess:!1})):D?(E(D),k({shouldCallAuthOnSuccess:T})):(M(new s("User wallet creation failed")),k({shouldCallAuthOnSuccess:!1}))},onPasswordChange:C,onPasswordGenerate:()=>C(p()),onSubmit:async()=>(f(!0),R.execute().then((()=>new Promise((e=>setTimeout(e,250))))).finally((()=>f(!1))))})}};export{u as EmbeddedWalletPasswordCreateScreen,u as default};
//# sourceMappingURL=RecoveryPasswordCreateScreen-Cvfkmm0x.mjs.map
