"use strict";var e=require("react/jsx-runtime"),t=require("react"),n=require("viem"),a=require("@privy-io/js-sdk-core"),s=require("./Address-DW_NyDV7.js"),r=require("./context-rs-ygOK2.js"),i=require("./wallet-connect-BuohfvHK.js"),o=require("./internal-context-CdsQ3LEl.js"),u=require("./modal-context-BgeioxwT.js"),l=require("./privy-context-UTJouJ1x.js"),c=require("./useGetTokenPrice-kLl5cylh.js"),p=require("./useWalletBalance-BvG77-8u.js"),d=require("./getErc20TokenInfo-BAl5vkXC.js"),m=require("./formatErc20TokenAmount-DxwoWe7e.js"),y=require("./ethers-DEImj_8B.js"),f=require("./getPublicClient-CFd_sHBk.js"),b=require("./ErrorScreen-CakvnnzU.js"),T=require("styled-components"),h=require("./ModalHeader-Cpls13mi.js"),g=require("./JsonTree-C28xtYM0.js"),v=require("./TransactionErrorView-CIZbOcj4.js"),q=require("./Layouts-D3TOcPhm.js"),I=require("./ScreenHeader-CgYJ5Fmg.js"),j=require("./useActiveWallet-dTc6deka.js"),E=require("./TransactionDetails-BlFm7wK6.js"),k=require("./transfer-B1Y_9LWi.js"),x=require("./toViemAccount-CopJpCYv.js");require("lucide-react"),require("tinycolor2"),require("./errors-CBapWvRs.js"),require("ofetch"),require("eventemitter3"),require("@privy-io/are-addresses-equal"),require("./useGetSolPrice-BOxa4idj.js"),require("viem/chains"),require("./index-BoiKFBqR.js"),require("./PrivyPluginContext-DsLtVhZA.js"),require("zustand"),require("mipd"),require("react-device-detect"),require("viem/utils"),require("./pkce-CmuJlEgn.js"),require("jose"),require("./paths-DizMb-lU.js"),require("@scure/base"),require("./usePrivy-Dt4_yE6Q.js"),require("./use-unlink-wallet-DAxmY7kq.js"),require("./get-entropy-details-for-user-D63rM5_a.js"),require("./user-D2oPA-vS.js"),require("@privy-io/popup"),require("./events-context-Di6--rDg.js"),require("@headlessui/react"),require("./index-Ub4KpwSY.js"),require("@privy-io/urls"),require("./getEmbeddedConnectedWallet-D6YL2FS9.js"),require("@privy-io/ethereum"),require("./frame-BHa-PKpX.js"),require("@privy-io/routes"),require("./use-deposit-address-CVyd0fqP.js"),require("x402/client"),require("@privy-io/api-base"),require("./use-sign-with-user-signer-BhoaqeNG.js"),require("./reservoir-CfS214MF.js"),require("./ScreenLayout-DaFW0I3a.js"),require("./Screen-8NusMFtu.js"),require("./index-ByFhjjzH.js"),require("@coinbase/wallet-sdk"),require("@walletconnect/ethereum-provider"),require("js-cookie"),require("viem/accounts"),require("@heroicons/react/24/outline/ArrowLeftIcon"),require("@heroicons/react/24/outline/ArrowRightIcon"),require("@heroicons/react/24/outline/QuestionMarkCircleIcon"),require("@heroicons/react/24/outline/XMarkIcon"),require("@heroicons/react/24/outline"),require("./Value-mhPsfsxe.js"),require("./LoadingSkeleton-BoyADunQ.js"),require("./Row-CMqYn75Q.js"),require("./ErrorMessage-BfTVyue9.js"),require("./LabelXs-C8rLnCfU.js"),require("./Subtitle-CR8zM7ZJ.js"),require("./Title-ifTy35V5.js"),require("./WalletInfoCard-CG-n_44w.js"),require("./shared-DBm7PUrg.js"),require("./Checkbox-DzxHC5tk.js"),require("./ErrorBanner-dOLclNms.js"),require("@heroicons/react/24/outline/ExclamationCircleIcon"),require("./WarningBanner-DUcGaIpZ.js"),require("@heroicons/react/24/outline/ExclamationTriangleIcon"),require("@heroicons/react/24/outline/ClipboardDocumentCheckIcon"),require("@heroicons/react/24/outline/ClipboardDocumentIcon"),require("./WalletLink-Dxq-sK27.js"),require("./getFormattedUsdFromLamports-Mu2fqwL2.js"),require("./transaction-DjF5X-by.js"),require("@heroicons/react/24/outline/ChevronDownIcon");let S=[{constant:!0,inputs:[{name:"_owner",type:"address"}],name:"balanceOf",outputs:[{name:"balance",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"}],M=T.styled.div`
  display: flex;
  flex-direction: column;
  min-height: 72px;
`;var C=({onBack:t,details:n})=>/*#__PURE__*/e.jsxs(M,{children:[/*#__PURE__*/e.jsx(h.ModalHeader,{backFn:t}),/*#__PURE__*/e.jsx(g.DisplayJsonTree,{data:n}),/*#__PURE__*/e.jsx(h.BlobbyFooter,{})]});let F=({gasUsed:e,effectiveGasPrice:t})=>{if(e&&t)try{return n.toHex(e*t)}catch(e){return}};const _=({txn:t,receipt:n,transactionInfo:a,onClose:s,tokenPrice:r,tokenSymbol:i,receiptHeader:o,receiptDescription:u})=>/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(h.ModalHeader,{onClose:s}),/*#__PURE__*/e.jsx(I.ScreenHeader,{title:o??"Transaction complete!",description:u??"You're all set."}),/*#__PURE__*/e.jsx(E.TransactionDetails,{tokenPrice:r,from:n.from,to:n.to,gas:F(n),txn:t,transactionInfo:a,tokenSymbol:i}),/*#__PURE__*/e.jsx(j.Grow,{}),/*#__PURE__*/e.jsx(w,{loading:!1,onClick:s,children:"All Done"}),/*#__PURE__*/e.jsx(q.RefactorSpacerBottom,{}),/*#__PURE__*/e.jsx(h.BlobbyFooter,{})]});let w=T.styled(h.PrimaryButton)`
  && {
    margin-top: 24px;
  }
  transition:
    color 350ms ease,
    background-color 350ms ease;
`;const A=[{constant:!1,inputs:[{name:"_salt",type:"bytes32"},{name:"_initializer",type:"bytes"}],name:"deployAccount",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"}],N=[{name:"from",type:"address"},{name:"param2",type:"address"},{name:"param3",type:"bytes"},{name:"param4",type:"tuple",components:[]},{type:"tuple",components:[{name:"param5",type:"address"},{name:"param6",type:"uint256"},{name:"param7",type:"uint256"},{name:"encodedInitData",type:"bytes"}]}],P=[{constant:!1,inputs:[{name:"spender",type:"address"},{name:"value",type:"uint256"}],name:"approve",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"}],R=[{inputs:[{name:"to",type:"address"},{name:"amount",type:"uint256"},{name:"memo",type:"bytes32"}],name:"transferWithMemo",outputs:[{name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"}],D=[{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"mint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"mint",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"}],name:"mint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"}],name:"mint",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"uint256",name:"quantity",type:"uint256"},{internalType:"bytes",name:"data",type:"bytes"}],name:"mint",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"uint256",name:"quantity",type:"uint256"},{internalType:"bytes",name:"data",type:"bytes"}],name:"mint",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256[]",name:"tokenIds",type:"uint256[]"},{internalType:"uint256[]",name:"quantities",type:"uint256[]"},{internalType:"bytes",name:"data",type:"bytes"}],name:"mintBatch",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256[]",name:"tokenIds",type:"uint256[]"},{internalType:"uint256[]",name:"quantities",type:"uint256[]"},{internalType:"bytes",name:"data",type:"bytes"}],name:"mintBatch",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"payable",type:"function"},{inputs:[{internalType:"uint256",name:"quantity",type:"uint256"}],name:"mint",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"quantity",type:"uint256"}],name:"mint",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"}],name:"safeMint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"}],name:"safeMint",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"string",name:"uri",type:"string"}],name:"safeMint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"string",name:"uri",type:"string"}],name:"safeMint",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"safeMint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"safeMint",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"string",name:"uri",type:"string"}],name:"safeMint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"string",name:"uri",type:"string"}],name:"safeMint",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"batchMint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"batchMint",outputs:[],stateMutability:"payable",type:"function"}],B=[{constant:!1,inputs:[{name:"_from",type:"address"},{name:"_to",type:"address"},{name:"_tokenId",type:"uint256"}],name:"safeTransferFrom",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"}],O=[{constant:!1,inputs:[{name:"_operator",type:"address"},{name:"_approved",type:"bool"}],name:"setApprovalForAll",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"}],$=[{constant:!1,inputs:[{name:"_from",type:"address"},{name:"_to",type:"address"},{name:"_tokenId",type:"uint256"}],name:"transferFrom",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"}],W=[{constant:!1,inputs:[{name:"_from",type:"address"},{name:"_to",type:"address"},{name:"_tokenIds",type:"uint256[]"},{name:"_amounts",type:"uint256[]"},{name:"_data",type:"bytes"}],name:"safeBatchTransferFrom",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"}],L=[{constant:!1,inputs:[{name:"_from",type:"address"},{name:"_to",type:"address"},{name:"_tokenId",type:"uint256"},{name:"_amount",type:"uint256"},{name:"_data",type:"bytes"}],name:"safeTransferFrom",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"}],U=(e,t)=>{let n=H(P,e);if(n)return{action:"approve",functionName:"approve",isErc20Ish:!0,isNFTIsh:!1,spender:n.args[0],amount:n.args[1]};let a=H(k.ERC20_TRANSFER_ABI_STUB,e);if(a)return{action:"transfer",functionName:"transfer",isErc20Ish:!0,isNFTIsh:!1,transferTo:a.args[0],amount:a.args[1]};let s=H(R,e);if(s)return{action:"transfer",functionName:"transferWithMemo",isErc20Ish:!0,isNFTIsh:!1,transferTo:s.args[0],amount:s.args[1]};if(!t)return{action:"transaction",functionName:"",isErc20Ish:!1,isNFTIsh:!1};let r=H(A,e);if(r&&"string"==typeof r.args[1]){let e=V(r.args[1]);if(e&&e[4].encodedInitData)return U(e[4].encodedInitData,t)}let i=H(O,e);if(i)return{action:"approve",functionName:"setApprovalForAll",isNFTIsh:!0,isErc20Ish:!1,operator:i.args[0],approved:i.args[1]};let o=H($,e);if(o)return{action:"transfer",functionName:"transferFrom",isNFTIsh:!0,isErc20Ish:!1,transferFrom:o.args[0],transferTo:o.args[1],tokenId:o.args[2]};let u=H(B,e);if(u)return{action:"transfer",functionName:"safeTransferFrom",isNFTIsh:!0,isErc20Ish:!1,transferFrom:u.args[0],transferTo:u.args[1],tokenId:u.args[2]};let l=H(L,e);if(l)return{action:"transfer",functionName:"safeTransferFrom",isNFTIsh:!0,isErc20Ish:!1,transferFrom:l.args[0],transferTo:l.args[1],tokenId:l.args[2],amount:l.args[3]};let c=H(W,e);if(c)return{action:"batch transfer",functionName:"safeBatchTransferFrom",isNFTIsh:!0,isErc20Ish:!1,transferFrom:c.args[0],transferTo:c.args[1],tokenIds:c.args[2],amounts:c.args[3]};let p=H(D,e);return p?{action:"mint",functionName:p.functionName,isNFTIsh:!0,isErc20Ish:!1,args:p.args}:{action:"transaction",isErc20Ish:!1,isNFTIsh:!1}};let H=(e,t)=>{try{let a=n.decodeFunctionData({abi:e,data:t});return{functionName:a.functionName,args:a.args||[]}}catch(e){return null}},V=e=>{try{if("string"==typeof e)return n.decodeAbiParameters(N,`0x${e.slice(10)}`)}catch(e){return null}},G=e=>`${parseFloat(e).toFixed(2)}`;function J(e,t){let n=[],a=new Map;if(e)for(let t of e)if(t.in[0]){let e;e="ERC721"===t.asset.type||"approve_for_all"===t.in[0].value?{id:`nft:${t.asset.name}`,nftName:t.asset.name,nftCount:t.in.length}:{id:`token:${t.asset.type}:${t.asset.symbol}:${t.asset.name}`,iconUrl:t.asset.logo_url,value:t.in[0].value,symbol:t.asset.symbol,usdValue:t.in[0].usd_price?G(t.in[0].usd_price):void 0,decimals:t.asset.decimals},n.push(e)}else if(t.out[0]?.value){let e;e="ERC721"===t.asset.type||"approve_for_all"===t.out[0].value?{id:`nft:${t.asset.name}`,nftName:t.asset.name}:{id:`token:${t.asset.type}:${t.asset.symbol}:${t.asset.name}`,iconUrl:t.asset.logo_url,value:t.out[0].value,symbol:t.asset.symbol,usdValue:t.out[0].usd_price?G(t.out[0].usd_price):void 0,decimals:t.asset.decimals},a.has(e.id)||a.set(e.id,e)}for(let e of t)for(let t of Object.keys(e.spenders)){let n;n="ERC721"===e.asset.type||"approve_for_all"===e.spenders[t]?.value?{id:`nft:${e.asset.name}`,nftName:e.asset.name}:{id:`token:${e.asset.type}:${e.asset.symbol}:${e.asset.name}`,iconUrl:e.asset.logo_url,value:e.spenders[t]?.value,symbol:e.asset.symbol,usdValue:e.spenders[t]?.usd_price?G(e.spenders[t]?.usd_price):void 0,decimals:e.asset.decimals},a.has(n.id)||a.set(n.id,n)}return{assetsIn:n,assetsOut:Array.from(a.values())}}const z=(e,n,a,s)=>{let[r,i]=t.useState(null),{walletProxy:u}=o.usePrivyInternal();return t.useEffect((()=>{r&&i(null),(async()=>{if(!u||!n)return null;let t=[],r=!0,i=await x.prepareTransactionRequest(e,a,n,s).catch((n=>(n.message&&n.message.includes("Insufficient balance for transaction")||n.message&&n.message.includes("Insufficient funds for gas * price + value")||n.details&&n.details.includes("insufficient funds")||n.details&&n.details.includes("gas required exceeds allowance")?r=!1:t.push(n),e)));return{tx:i,totalGasEstimate:i.gas,hasFunds:r,errors:t}})().then(i)}),[e]),r};let Q=new i.PrivyProviderRpcError(new i.ProviderRpcError("There was an issue preparing your transaction",a.ProviderErrors.E32603_DEFAULT_INTERNAL_ERROR.eipCode)),X=(e,t)=>e?.sendTransaction?"transactionRequest"in e.sendTransaction?e.sendTransaction.transactionRequest:e.sendTransaction.transactionRequests[t]:void 0;const Y={component:()=>{let{data:T,onUserCloseViaDialogOrKeybindRef:h,setModalData:g,navigate:q}=u.usePrivyModal(),{client:I,rpcConfig:j,chains:E,closePrivyModal:k,walletProxy:x,showFiatPrices:M}=o.usePrivyInternal(),{user:F}=l.usePrivyContext(),w=r.useAppConfig(),[A,N]=t.useState(0),[P,R]=t.useState(0),[D,B]=t.useState(X(T,A)),[O,$]=t.useState(null),[W,L]=t.useState(),[H,V]=t.useState(!1),[G,Y]=t.useState(null),[K,Z]=t.useState(null),[ee,te]=t.useState(null),[ne,ae]=t.useState(void 0),[se,re]=t.useState(void 0),[ie,oe]=t.useState(!1),[ue,le]=t.useState(!1),[ce,pe]=t.useState([]),[de,me]=t.useState([]),[ye,fe]=t.useState("uninitiated"),[be,Te]=t.useState(void 0);if(!D||!T?.sendTransaction||!T?.sendTransaction)/*#__PURE__*/return e.jsx(b.ErrorScreenView,{error:Error("Invalid transaction request"),allowlistConfig:w.allowlistConfig,onRetry:()=>{T?.sendTransaction?.onFailure(Q),k({shouldCallAuthOnSuccess:!1})}});let{transactingWalletAddress:he}=T.sendTransaction,ge=t.useMemo((()=>E.find((e=>Number(e.id)===Number(D.chainId)))),[D.chainId]),ve=ge?.nativeCurrency.symbol??"ETH",qe=t.useMemo((()=>U(D.data,!!w.embeddedWallets.extendedCalldataDecoding)),[D.data]),{action:Ie,isErc20Ish:je,isNFTIsh:Ee,functionName:ke}=qe,{toAddress:xe,tokenAddress:Se}=t.useMemo((()=>({toAddress:qe.isErc20Ish?qe.transferTo:D.to??void 0,tokenAddress:qe.isErc20Ish?D.to:void 0})),[qe]);t.useEffect((()=>{D.to&&ge&&je&&d.getErc20TokenInfo({address:D.to,chain:ge,rpcConfig:w.rpcConfig,privyAppId:w.id}).then($).catch(console.error)}),[D.to,ge]);let{tokenPrice:Me,isTokenPriceLoading:Ce}=c.useGetTokenPrice(D.chainId),{balance:Fe}=p.useWalletBalance({rpcConfig:w.rpcConfig,appId:w.id,address:he,chain:ge}),_e=function({rpcConfig:e,appId:s,address:r,chain:i,tokenInfo:u}){let{chains:l}=o.usePrivyInternal(),[c,p]=t.useState(null),[d,m]=t.useState(!1),y=t.useMemo((()=>{let t=i||l[0];if(t)return n.createPublicClient({chain:i,transport:n.http(a.getJsonRpcEndpointFromChain(t,e,s))})}),[i,e,s]),f=t.useCallback((async()=>{if(r&&y&&u.address)try{return m(!0),await y.readContract({address:u.address,abi:S,functionName:"balanceOf",args:[r]})}catch(e){console.error(e)}finally{m(!1)}}),[y,r,u?.address,i]);return t.useEffect((()=>{f().then((e=>null!=e&&p(e)))}),[f]),{balance:c,isLoading:d&&null==c,formattedBalance:a.formatTokenAmount({amount:c??BigInt(0),decimals:u.decimals})}}({rpcConfig:w.rpcConfig,appId:w.id,address:he,tokenInfo:{address:Se||"",decimals:O?.decimals??18},chain:ge}),we=t.useMemo((()=>f.getPublicClient(Number(D.chainId),E,j,{appId:w.id})),[D.chainId,j]),Ae=z(D,he,we,T?.sendTransaction?.prepareTransactionRequest);t.useEffect((()=>{B(X(T,A))}),[A]),t.useEffect((()=>{T.sendTransaction?.getIsSponsored?T.sendTransaction.getIsSponsored().then(L).catch(console.error):L(!1)}),[T.sendTransaction.getIsSponsored]);let Ne=()=>{if(!H)return G?T?.sendTransaction?.onSuccess({hash:G}):ee||Ae?.errors[0]?T?.sendTransaction?.onFailure(ee??Ae?.errors[0]??Q):T?.sendTransaction?.onFailure(new i.PrivyProviderRpcError(new i.ProviderRpcError("The user rejected the request",a.ProviderErrors.E4001_USER_REJECTED_REQUEST.eipCode))),k({shouldCallAuthOnSuccess:!1})};h.current=Ne;let Pe=!!(T.funding&&T.funding.supportedOptions.length>0),Re=y.getNativeCurrencyFromWei(BigInt(Ae?.totalGasEstimate??0n),ve),De=M&&Me?y.getDollarsFromWei(BigInt(Ae?.totalGasEstimate??0n),Me):void 0,Be=y.getNativeCurrencyFromWei(Fe??0n,ve,void 0,!0),Oe=M&&Me?y.getDollarsFromWei(Fe??0n,Me):void 0,$e=O&&!_e.isLoading&&je&&"approve"!==Ie?`${_e.formattedBalance} ${O.symbol}`:void 0,We=T.sendTransaction?.uiOptions?.transactionInfo?.title;We||(We="approve"===Ie?je?"Confirm address":"Confirm action":`Approve ${Ie}`);let Le=t.useMemo((()=>{if(T.sendTransaction?.uiOptions?.description)return T.sendTransaction?.uiOptions?.description;if("approve"===Ie&&"setApprovalForAll"===ke&&qe.approved){let t=/*#__PURE__*/e.jsx(s.Address,{address:qe.operator||"",url:ge?.blockExplorers?.default?.url});/*#__PURE__*/return e.jsxs(e.Fragment,{children:[w.name," would like your permission for ",t," to transfer tokens on your behalf."]})}if("approve"===Ie&&"setApprovalForAll"===ke&&!qe.approved){let t=/*#__PURE__*/e.jsx(s.Address,{address:qe.operator||"",url:ge?.blockExplorers?.default?.url});/*#__PURE__*/return e.jsxs(e.Fragment,{children:[w.name," would like your permission to revoke permissions of ",t," from transferring tokens on your behalf."]})}return je&&"approve"===Ie||je&&"approve"===Ie?`${w.name} would like your permission for ${i.formatWalletAddress(qe.spender)} to spend tokens on your behalf.`:`${w.name} wants your permission to approve the following transaction.`}),[w.name,je,qe,T.sendTransaction?.uiOptions.description,ke]),Ue=T.sendTransaction?.uiOptions?.transactionInfo?.contractInfo?.imgUrl?/*#__PURE__*/e.jsx("img",{src:T.sendTransaction.uiOptions.transactionInfo.contractInfo.imgUrl,alt:T.sendTransaction.uiOptions.transactionInfo.contractInfo.imgAltText}):null,He=!(!Ae||Ae.errors[0]||Ae.hasFunds||!1!==W),Ve=He&&Pe,Ge=Ve?"Add funds":T.sendTransaction?.uiOptions?.buttonText||(A<P?"Continue":"Approve"),Je=e=>{if(!e)throw Error("Transaction scan failed");if("Success"===e.validation.status&&("Benign"===e.validation.result_type?re("safe"):"Warning"===e.validation.result_type?re("warn"):"Malicious"===e.validation.result_type&&(re("error"),le(!0))),"Success"!==e.simulation.status)throw Error("Simulation failed");{ae(e.simulation.params);let{assetsIn:t,assetsOut:n}=J(e.simulation.assets_diffs,e.simulation.exposures);if(0===n.length&&0===t.length)throw Error("No tokens found");pe(n),me(t)}};if(t.useEffect((()=>{T.sendTransaction?.scanTransaction&&w.embeddedWallets.transactionScanning.enabled&&"uninitiated"===ye&&(fe("in progress"),T.sendTransaction.scanTransaction().then((e=>{Je(e),fe("completed")})).catch((()=>fe("failed"))))}),[!!T.sendTransaction?.scanTransaction]),t.useEffect((()=>{T.sendTransaction?.scanTransaction&&"failed"!==ye||((e,t,n)=>{if(R((e=>e?.sendTransaction?"transactionRequest"in e.sendTransaction?0:e.sendTransaction.transactionRequests.length-1:0)(T)),t.isErc20Ish&&t.amount&&n){let e=m.formatErc20TokenAmount({amount:t.amount,decimals:n.decimals});Te(e),pe([{value:e,symbol:n?.symbol,decimals:n?.decimals}])}else if(e.value){let t=BigInt(e.value),n=Me?y.getDollarsFromWei(t,Me):void 0;pe(M&&n?[{value:n}]:[{value:y.parseNativeCurrencyFromWei(t),symbol:ve,decimals:18,usdValue:n}])}else pe(M?[{value:"$0"}]:[{value:"0",symbol:ve,decimals:18}])})(Ae?.tx??D,qe,O)}),[D,Ae?.tx,qe,O,ye]),K/*#__PURE__*/)return e.jsx(_,{txn:Ae?.tx??D,onClose:Ne,receipt:K,transactionInfo:T.sendTransaction?.uiOptions.transactionInfo,tokenPrice:Me,tokenSymbol:ve,receiptHeader:T.sendTransaction?.uiOptions.successHeader,receiptDescription:T.sendTransaction?.uiOptions.successDescription});if(ee)/*#__PURE__*/return e.jsx(v.TransactionErrorView,{transactionError:ee,transactionHash:G??void 0,chainType:"ethereum",chainId:Ae?.tx.chainId??D.chainId,onClose:Ne,onRetry:({resetNonce:e})=>{te(null);let t={...Ae?.tx??D};e&&(t.nonce=void 0),B(t)}});let ze=0!==P&&"number"==typeof A&&0!==A?()=>{N(A-1)}:void 0;return ie&&ne?/*#__PURE__*/e.jsx(C,{details:ne,onBack:()=>oe(!1)}):/*#__PURE__*/e.jsx(v.SendTransactionScreenView,{transactionIndex:A,onBack:ze,maxIndex:P,disabled:He&&!Pe||ue,isSubmitting:H,submitError:ee,isPreparing:!Ae,isTokenPriceLoading:Ce,isTokenContractInfoLoading:!Ee&&!O,prepareError:Ae?.errors[0],symbol:O?.symbol,chain:ge,img:Ue,title:We,subtitle:Le,txValue:D.value,fee:De??Re,isSponsored:W,from:he??"",to:xe,tokenAddress:Se??void 0,network:w.chains.find((e=>e.id===D.chainId))?.name??"",transactionDetails:{...qe,formattedAmount:be},cta:Ge,missingFunds:He,action:Ie,balance:$e??Oe??Be,onClose:Ne,onClick:Ve?async()=>{if(!he)return;if(!Pe)throw Error("Funding wallet is not enabled");let e="FundingMethodSelectionScreen";g({...T,funding:{...T.funding,methodScreen:e,chainType:"ethereum",amount:n.formatEther(BigInt(Ae?.tx.value??0)+BigInt(Ae?.totalGasEstimate?.toString()??0)),chain:ge},solanaFundingData:T?.solanaFundingData}),q(e)}:async()=>{if(A<P)N(A+1);else{V(!0);try{let e=await I.getAccessToken();if(H||!e||!x||!F)return;let t=await T.sendTransaction.onConfirm({transactionRequest:Ae?.tx??D});if(Y(t),T.sendTransaction?.signOnly)return await new Promise((e=>setTimeout(e,r.DEFAULT_SUCCESS_SCREEN_DURATION_MS))),T?.sendTransaction?.onSuccess({hash:t}),k({shouldCallAuthOnSuccess:!1});let n=await we.waitForTransactionReceipt({hash:t});if("reverted"===n.status)throw Error("Transaction failed");Z(n)}catch(e){console.warn({transaction:Ae?.tx??D,error:e}),te(e)}finally{V(!1)}}},validation:se,hasScanDetails:!!ne,setIsScanDetailsOpen:oe,preventMaliciousTransaction:ue,setPreventMaliciousTransaction:le,tokensSent:ce,tokensReceived:de,isScanning:"in progress"===ye,isCancellable:T.sendTransaction?.uiOptions?.isCancellable??!1,functionName:ke})}};exports.SendTransactionScreen=Y,exports.default=Y;
//# sourceMappingURL=index-CMrFMY7Q.js.map
