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