(globalThis.webpackChunk=globalThis.webpackChunk||[]).push([[1938],{361938(__unused_webpack___webpack_module__,__webpack_exports__,__webpack_require__){(function(){if(!this.ST)return()=>{};with(this.ST)with(this.RH)with(this.G)return function(){"use strict";__webpack_require__.d(__webpack_exports__,{DL:()=>h,Wo:()=>p,hT:()=>d,ig:()=>f});var e=__webpack_require__(644174);let t="https://token.api.cx.metamask.io";let n;let r=0;let a;async function i(){let e=Date.now();return n!==undefined&&e-r<null?n:(0,a!==undefined)?a:(0,a=(async()=>{try{let e=await fetch(null);if(e.ok){let t=await e.json();n=t&&typeof t=="object"&&!Array.isArray(t)?t:{}}else n={}}catch{n={}}finally{r=Date.now(),a=undefined}return n??{}})())}async function o(e){return(await i())[String(convertHexToDecimal(e))]??3}function c(e){let{chainIds:n,query:r,limit:a,after:i,...o}=e;let c=encodeURIComponent(r);let s=n.map(e=>encodeURIComponent(e)).join(",");let u=new URLSearchParams;Object.entries(o).forEach(([e,t])=>{t!==undefined&&u.append(e,String(t))});let l;return a&&(l=a<=50||r.includes("Ondo")&&a<=500?a:50),`${t}/tokens/search?networks=${s}&query=${c}${l?`&first=${l}`:""}${i?`&after=${encodeURIComponent(i)}`:""}&${u.toString()}`}function s(e){let{assetIds:n,...r}=e;let a=n.map(e=>encodeURIComponent(e)).join(",");let i=new URLSearchParams;return Object.entries(r).forEach(([e,t])=>{t!==undefined&&i.append(e,String(t))}),`${t}/assets?assetIds=${a}${i.toString()?`&${i.toString()}`:""}`}function u(e){let{chainIds:n,query:r,active:a,custodian:i,type:o,industry:c,sortBy:s,limit:u=100,after:l,...d}=e;let f=r?.trim();let h=new URLSearchParams;return Object.entries({...n?.length?{chainIds:n}:{},...f&&{query:f},...a===undefined?{}:{active:a},...i&&{custodian:i},...o&&{type:o},...c&&{industry:c},...s&&{sortBy:s},limit:u,...l&&{after:l},...d}).forEach(([e,t])=>{if(t===undefined||t==="")return;if(Array.isArray(t)){t.length>0&&h.append(e,t.join(","));return}h.append(e,String(t))}),`${t}/v1/rwas?${h.toString()}`}function l(e){let n=e.chainIds.map(e=>encodeURIComponent(e)).join(",");let r=new URLSearchParams;let{chainIds:a,excludeLabels:i,...o}=e;Object.entries(o).forEach(([e,t])=>{t!==undefined&&r.append(e,String(t))});let c=i!==undefined&&i.length>0?`&excludeLabels=${i.join(",")}`:"";return`${t}/v3/tokens/trending?chainIds=${n}${r.toString()?`&${r.toString()}`:""}${c}`}async function d(t,n,{limit:r=10,after:a,includeMarketData:i=!1,includeRwaData:o=!0,includeTokenSecurityData:s}={}){let u=c({chainIds:t,query:n,limit:r,after:a,includeMarketData:i,includeRwaData:o,includeTokenSecurityData:s});try{let t=await (0,e.Pf)(u);if(t&&typeof t=="object"&&Array.isArray(t.data))return{count:t.count??t.data.length,...t.totalCount!==undefined&&{totalCount:t.totalCount},data:t.data,...t.pageInfo!==undefined&&{pageInfo:t.pageInfo}};return{count:0,data:[],error:"Unexpected API response format"}}catch(e){return{count:0,data:[],error:e instanceof Error?e.message:String(e)}}}async function f(t){let{chainIds:n,...r}=t;if(n.length===0)return console.error("No chains provided"),[];let a=l({chainIds:n,...r,includeRwaData:r.includeRwaData??!0,usePriceApiData:r.usePriceApiData??!0});try{let t=await (0,e.Pf)(a);if(Array.isArray(t))return t;return console.error("Trending tokens API returned non-array response:",t),[]}catch(e){return console.error("Trending tokens request failed:",e),[]}}async function h(t,{includeAggregators:n,includeCoingeckoId:r,includeLabels:a,includeMarketData:i,includeOccurrences:o,includeTokenSecurityData:c,includeRwaData:u}={}){if(t.length===0)return[];let l=s({assetIds:t,includeAggregators:n,includeCoingeckoId:r,includeLabels:a,includeMarketData:i,includeOccurrences:o,includeTokenSecurityData:c,includeRwaData:u});try{let t=await (0,e.Pf)(l);if(Array.isArray(t))return t;return[]}catch{return[]}}async function p(t={}){return(0,e.Pf)(u(t),{headers:{accept:"*/*"}})}}}).call(__webpack_require__._LM_("@metamask/assets-controllers",{__webpack_require__,__webpack_exports__}))()}}]);