import{getAssociatedTokenAddress as h}from"@solana/spl-token";import{useConnection as x,useWallet as K}from"@solana/wallet-adapter-react";import{LAMPORTS_PER_SOL as L,PublicKey as M}from"@solana/web3.js";import{useWeb3React as P}from"@web3-react/core";import z from"bignumber.js";import{useCallback as r,useEffect as b,useState as B}from"react";var F={BONK:new M("DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263")},W=({connectedChainId:u,chainId:i,isSwapPaySupported:o,externalCurrencyEnabled:j,mintPrice:c,mintPriceUnit:m,payUsing:n,requiredCustomAmount:A})=>{let[w,S]=B(0),[C,d]=B(0),[k,y]=B(0),{account:s,provider:g}=P(),{connected:l,publicKey:e}=K(),{connection:t}=x(),f=r(async()=>{if(s)try{let a=await g.getBalance(s);S(a)}catch(a){console.log(a)}},[s,c,g]),E=r(async()=>{if(l&&e){let a=await t.getBalance(e);d(a)}},[l,e,t]),p=r(async()=>{if(n==="BONK"&&e){let a=F[n.toUpperCase()],O=await h(a,e),R=(await t.getTokenAccountBalance(O)).value.uiAmount;y(R)}},[t,n,e]);b(()=>{Number(i)===Number(u)&&f()},[i,u,f]),b(()=>{E(),o&&p()},[e,l,o,E,p]);let N=new z(w.toString()).gte(c),T=C>=c*L,v=parseFloat(k.toString())>=parseFloat(A);return{isEnoughBalance:o&&n.toUpperCase()!=="DEFAULT"?v:m==="SOL"?T:["ETH","MATIC","SHM","BNB"].includes(m)?N:!0}},Z=W;export{Z as default};
