import{useState as r,useEffect as e}from"react";import{addToDefaultChains as o}from"@privy-io/js-sdk-core";import{t as i}from"./context-BKnOUECq.mjs";import{u as n}from"./internal-context-dfitw7Ot.mjs";import{u as t}from"./useGetSolPrice-x7gfUIHJ.mjs";function c(c){let{tokenPrice:a,isTokenPriceLoading:s,tokenPriceError:l}=(t=>{let{showFiatPrices:c,getUsdTokenPrice:a,chains:s}=n(),[l,P]=r(!0),[d,k]=r(void 0),[m,f]=r(void 0);return e((()=>{t||=i;let r=o(s).find((r=>r.id===Number(t)));(async()=>{if(c){if(!r)return P(!1),void k(Error(`Unable to fetch token price on chain id ${t}`));try{P(!0);let e=await a(r);e?f(e):k(Error(`Unable to fetch token price on chain id ${r.id}`))}catch(r){k(r)}finally{P(!1)}}else P(!1)})()}),[t]),{tokenPrice:m,isTokenPriceLoading:l,tokenPriceError:d}})("solana"===c?-1:c),{solPrice:P,isSolPriceLoading:d,solPriceError:k}=t({enabled:"solana"===c});return"solana"===c?{tokenPrice:P,isTokenPriceLoading:d,tokenPriceError:k}:{tokenPrice:a,isTokenPriceLoading:s,tokenPriceError:l}}export{c as u};
//# sourceMappingURL=useGetTokenPrice-ENX-6s3C.mjs.map
