"use strict";var e=require("./context-rs-ygOK2.js"),t=require("./events-context-Di6--rDg.js"),n=require("./internal-context-CdsQ3LEl.js"),r=require("./modal-context-BgeioxwT.js"),a=require("./use-unlink-wallet-DAxmY7kq.js"),i=require("react"),o=require("./privy-context-UTJouJ1x.js"),l=require("./errors-CBapWvRs.js"),s=require("./get-entropy-details-for-user-D63rM5_a.js");exports.useExportWallet=function(){let{user:t,getAccessToken:d}=o.usePrivyContext(),{walletProxy:u,openModal:c,client:p}=n.usePrivyInternal(),{setModalData:y}=r.usePrivyModal(),f=e.useAppConfig();return i.useMemo((()=>({exportWallet:e=>new Promise((async(n,r)=>{if(!t)return void r(new l.PrivyClientError("User must be authenticated before exporting their Privy wallet"));let i=e?.address?o.getPrivyWalletWithAddress(t,e.address):o.getPrivySolanaWallet(t);if(!i)return void r(new l.PrivyClientError("User must have an embedded wallet."));if(!a.isFirstClassChainWallet(i))return void r(Error(`Export is not supported for ${i.chainType} wallets`));let v=o.getIsUnifiedWallet(i),{entropyId:g,entropyIdVerifier:h}=s.getEntropyDetailsForUser(t,i);await d()?u?(y({connectWallet:{recoveryMethod:i.recoveryMethod,connectingWalletAddress:i.address,isUnifiedWallet:v,entropyId:g,entropyIdVerifier:h,onCompleteNavigateTo:"EmbeddedWalletKeyExportScreen",onFailure:r,shouldForceMFA:!0},keyExport:{appId:f.id,appClientId:f.appClientId,origin:p.apiUrl,address:i.address,entropyId:g,entropyIdVerifier:h,hdWalletIndex:i.walletIndex,chainType:i.chainType,walletId:i.id,isUnifiedWallet:v,imported:i.imported,onSuccess:n,onFailure:r,showBackButton:e?.showBackButton}}),c("EmbeddedWalletConnectingScreen")):r(new l.PrivyClientError("Wallet not ready for export")):r(new l.PrivyClientError("Must have valid access token."))}))})),[t,d,u,c,p,y,f])},exports.useFundWallet=function(i){t.usePrivyEventSubscription("fundSolanaWallet",i);let o=e.useAppConfig(),{openModal:l}=n.usePrivyInternal(),{setModalData:s}=r.usePrivyModal();return{fundWallet:async({address:e,options:t})=>{let n=t?.amount||o.fundingConfig?.defaultRecommendedAmount||"1",r=t?.asset||o.fundingConfig?.defaultRecommendedCurrency.asset||"native-currency",i=t?.chain||"solana:mainnet";s({funding:a.prepareSolanaFundingModalData({address:e,appConfig:o,methodScreen:"FundingMethodSelectionScreen",fundWalletConfig:{...t,amount:n,asset:r,chain:i},externalSolanaFundingScreen:"FundSolWalletWithExternalSolanaWallet"}),solanaFundingData:{amount:n,asset:"native-currency"===r?"SOL":"USDC",chain:i,destinationAddress:e,sourceWalletData:void 0}}),l("FundingMethodSelectionScreen")}}};
//# sourceMappingURL=use-export-wallet-B9NINnNW.js.map
