import{u as e}from"./context-BKnOUECq.mjs";import{u as t}from"./events-context-BJ75xIIf.mjs";import{u as n}from"./internal-context-dfitw7Ot.mjs";import{u as a}from"./modal-context-DBwfUxD-.mjs";import{b as o,i as r}from"./use-unlink-wallet-oAguM2-k.mjs";import{useMemo as d}from"react";import{u as i,f as s,d as l,a as c}from"./privy-context-Bi6vqCPc.mjs";import{P as u}from"./errors-Dd6zfYtp.mjs";import{g as m}from"./get-entropy-details-for-user-BIWg0YxF.mjs";function p(r){t("fundSolanaWallet",r);let d=e(),{openModal:i}=n(),{setModalData:s}=a();return{fundWallet:async({address:e,options:t})=>{let n=t?.amount||d.fundingConfig?.defaultRecommendedAmount||"1",a=t?.asset||d.fundingConfig?.defaultRecommendedCurrency.asset||"native-currency",r=t?.chain||"solana:mainnet";s({funding:o({address:e,appConfig:d,methodScreen:"FundingMethodSelectionScreen",fundWalletConfig:{...t,amount:n,asset:a,chain:r},externalSolanaFundingScreen:"FundSolWalletWithExternalSolanaWallet"}),solanaFundingData:{amount:n,asset:"native-currency"===a?"SOL":"USDC",chain:r,destinationAddress:e,sourceWalletData:void 0}}),i("FundingMethodSelectionScreen")}}}function f(){let{user:t,getAccessToken:o}=i(),{walletProxy:p,openModal:f,client:y}=n(),{setModalData:h}=a(),g=e();return d((()=>({exportWallet:e=>new Promise((async(n,a)=>{if(!t)return void a(new u("User must be authenticated before exporting their Privy wallet"));let d=e?.address?s(t,e.address):l(t);if(!d)return void a(new u("User must have an embedded wallet."));if(!r(d))return void a(Error(`Export is not supported for ${d.chainType} wallets`));let i=c(d),{entropyId:x,entropyIdVerifier:W}=m(t,d);await o()?p?(h({connectWallet:{recoveryMethod:d.recoveryMethod,connectingWalletAddress:d.address,isUnifiedWallet:i,entropyId:x,entropyIdVerifier:W,onCompleteNavigateTo:"EmbeddedWalletKeyExportScreen",onFailure:a,shouldForceMFA:!0},keyExport:{appId:g.id,appClientId:g.appClientId,origin:y.apiUrl,address:d.address,entropyId:x,entropyIdVerifier:W,hdWalletIndex:d.walletIndex,chainType:d.chainType,walletId:d.id,isUnifiedWallet:i,imported:d.imported,onSuccess:n,onFailure:a,showBackButton:e?.showBackButton}}),f("EmbeddedWalletConnectingScreen")):a(new u("Wallet not ready for export")):a(new u("Must have valid access token."))}))})),[t,o,p,f,y,h,g])}export{f as a,p as u};
//# sourceMappingURL=use-export-wallet-Cx7lSdBF.mjs.map
