@rango-dev/widget-embedded 0.32.2-next.0 → 0.32.2-next.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- var Nh=Object.defineProperty;var i=(t,e)=>Nh(t,"name",{value:e,configurable:!0});import{EventSeverity as vj,RouteEventType as xj,StepEventType as wj,StepExecutionBlockedEventStatus as bj,StepExecutionEventStatus as Ej}from"@rango-dev/queue-manager-rango-preset";import{legacyReadAccountAddress as Aj}from"@rango-dev/wallets-core/legacy";import{useWallets as Gr,Events as Wj}from"@rango-dev/wallets-react";import{Networks as Bj,WalletTypes as Lj}from"@rango-dev/wallets-shared";import{PendingSwapNetworkStatus as Dj}from"rango-types";import{UI_ID as Wh}from"@rango-dev/ui";var Yn="c6381a79-2817-4602-83bf-6a641a409e32",ip="https://api.rango.exchange",ap="https://explorer.rango.exchange",_e={SWAP_BOX_ID:"rango-swap-box",EXPANDED_BOX_ID:"rango-expanded-box",...Wh};var sp="Roboto",Xi=[{name:"Roboto",value:"Roboto",url:""},{name:"Times New Roman",value:"Times New Roman",url:"https://fonts.cdnfonts.com/css/times-new-roman"},{name:"Arial",value:"Arial",url:""},{name:"Open Sans",value:"Open Sans",url:"https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,300..800;1,300..800&display=swap"},{name:"Noto Sans",value:"Noto Sans",url:"https://fonts.googleapis.com/css2?family=Noto+Sans:ital,wght@0,100..900;1,100..900&display=swap"},{name:"Montserrat",value:"Montserrat",url:"https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100..900;1,100..900&display=swap"},{name:"Poppins",value:"Poppins",url:"https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap"},{name:"Roboto Condensed",value:"Roboto Condensed",url:"https://fonts.googleapis.com/css2?family=Roboto+Condensed:ital,wght@0,100..900;1,100..900&display=swap"},{name:"Roboto Mono",value:"Roboto Mono",url:"https://fonts.googleapis.com/css2?family=Roboto+Mono:ital,wght@0,100..700;1,100..700&display=swap"},{name:"Oswald",value:"Oswald",url:"https://fonts.googleapis.com/css2?family=Oswald:wght@200..700&display=swap"},{name:"Raleway",value:"Raleway",url:"https://fonts.googleapis.com/css2?family=Raleway:ital,wght@0,100..900;1,100..900&display=swap"},{name:"Sedan",value:"Sedan",url:"https://fonts.googleapis.com/css2?family=Sedan:ital@0;1&display=swap"},{name:"Inter",value:"Inter",url:"https://fonts.googleapis.com/css2?family=Inter:wght@100..900&display=swap"},{name:"Rubik",value:"Rubik",url:"https://fonts.googleapis.com/css2?family=Rubik:ital,wght@0,300..900;1,300..900&display=swap"},{name:"Lora",value:"Lora",url:"https://fonts.googleapis.com/css2?family=Lora:ital,wght@0,400..700;1,400..700&display=swap"},{name:"Barlow Condensed",value:"Barlow Condensed",url:"https://fonts.googleapis.com/css2?family=Barlow+Condensed:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap"}];import{Events as ma,Provider as xy}from"@rango-dev/wallets-react";import{isEvmBlockchain as wy}from"rango-sdk";import gr,{createContext as by,useEffect as ic,useMemo as Ey,useRef as ac}from"react";import{useEffect as Yh}from"react";import{create as Kh}from"zustand";import{subscribeWithSelector as jh}from"zustand/middleware";import Mh from"mitt";var ye=Mh(),Zn={on:ye.on,off:ye.off};import{RangoClient as Gh}from"rango-sdk";import{BlockchainCategories as Fh,WalletState as Et}from"@rango-dev/ui";import{legacyReadAccountAddress as Oh}from"@rango-dev/wallets-core/legacy";import{detectInstallLink as Uh,getCosmosExperimentalChainInfo as zh,isEvmAddress as Qh,KEPLR_COMPATIBLE_WALLETS as KE,Networks as kp}from"@rango-dev/wallets-shared";import ta from"bignumber.js";import{isCosmosBlockchain as qh}from"rango-types";import Bh from"bignumber.js";var Ue=new Bh(0);import{WalletTypes as Lh}from"@rango-dev/wallets-shared";var lp=[Lh.LEAP];import{BlockchainCategories as Yi,WalletState as $h}from"@rango-dev/ui";import{TransactionType as Jn}from"rango-sdk";function Ao(t){return Array.from(new Set(t))}i(Ao,"removeDuplicateFrom");function Ri(t,e){return t.length===e.length&&t.every((o,n)=>o===e[n])}i(Ri,"areEqual");function fp(t,e){let o;return n;function n(...r){o&&clearTimeout(o),o=setTimeout(()=>{o=null,t(...r)},e)}}i(fp,"debounce");function et(t,e){return t.toLowerCase().indexOf(e.toLowerCase())>-1}i(et,"containsText");function up(t,e){return t.toLowerCase()===e.toLowerCase()}i(up,"exactText");function mp(t,e){return t.toLowerCase().startsWith(e.toLowerCase())}i(mp,"startWithText");var A=i(()=>document.getElementById(_e.SWAP_BOX_ID),"getContainer"),on=i(()=>document.getElementById(_e.EXPANDED_BOX_ID),"getExpanded");function dp(t,e,o){let n=!!e&&up(e,t),r=!!o&&up(o,t);return n!==r?n?-1:1:0}i(dp,"compareExactMatchText");function Zi(t,e,o){let n=!!e&&et(e,t),r=!!o&&et(o,t);return n!==r?n?-1:1:n&&r&&e?.length!==o?.length?e?.length-o?.length:0}i(Zi,"compareContainsText");function Ji(t,e,o){let n=!!e&&mp(e,t),r=!!o&&mp(o,t);return n!==r?n?-1:1:n&&r&&e?.length!==o?.length?e?.length-o?.length:0}i(Ji,"compareStartWithText");function gp(t,e,o){if(!o)return 0;let n=dp(o,t.symbol,e.symbol);if(n)return n;if(o.length>=3){let r=dp(o,t.name,e.name);if(r)return r}if(o.length>=2){let r=Ji(o,t.symbol,e.symbol);if(r)return r}if(o.length>=3){let r=Zi(o,t.symbol,e.symbol);if(r)return r}if(o.length>=3){let r=Ji(o,t.name,e.name);if(r)return r}if(o.length>=3){let r=Zi(o,t.name,e.name);if(r!==0)return r}if(o.length>=4){let r=Ji(o,t.address,e.address);if(r)return r}if(o.length>=4){let r=Zi(o,t.address,e.address);if(r!==0)return r}return 0}i(gp,"compareWithSearchFor");var Rn=i((t,e)=>{switch(e){case Yi.ALL:return!0;case Yi.UTXO:return t===Jn.TRANSFER;case Yi.OTHER:return t!==Jn.TRANSFER&&t!==Jn.COSMOS&&t!==Jn.EVM;default:return t===e}},"isBlockchainTypeInCategory"),hp=i(t=>Xi.find(o=>o.value===t)?.url,"getFontUrlByName");function yp(t,e){let o=!!t.find(n=>n.state===$h.CONNECTED);return e===!1&&o}i(yp,"isSingleWalletActive");function er(t,e){return e.find(o=>o.name===t)?.displayName}i(er,"getBlockchainDisplayNameFor");function pt(t,e){return e.find(o=>o.name===t)?.shortName}i(pt,"getBlockchainShortNameFor");function Sp(t,e){return e.find(o=>o.name===t)?.logo}i(Sp,"getBlockchainImage");function nn(t,e){return e.find(o=>o.id===t)?.title}i(nn,"getSwapperDisplayName");function rn(t,e){return e.find(o=>o.name===t)??null}i(rn,"findBlockchain");function ea(t,e){if(!e||!t)return!1;for(let o of e.feeAssets)if(t?.blockchain===o?.blockchain&&t?.symbol===o?.symbol&&t?.address===o?.address)return!0;return!1}i(ea,"isTokenNative");function $e(t){return`${t.blockchain.toLowerCase()}-${t.symbol.toLowerCase()}-${(t.address??"").toLowerCase()}`}i($e,"createTokenHash");function No(t,e){return t.addressPatterns.filter(r=>new RegExp(r).test(e)).length>0}i(No,"isValidTokenAddress");import{BigNumber as Cp}from"bignumber.js";var an=i(t=>{let e=Math.floor(t%60/15)*15,o=parseInt((t/60).toString());return o>=60?`${Math.floor(o/5)*5}:00`:`${o.toString().padStart(2,"0")}:${e.toString().padStart(2,"0")}`},"roundedSecondsToString"),B=i((t,e=null,o=null)=>{if(t==null||t==="")return"";let n=new Cp(t),r=1,a=1e3;for(let s=0;s<60;s++)if(new Cp(n.toFixed(s,r)).eq(n)){a=s;break}if(n.gte(1e4))return n.toFormat(0,r);if(n.gte(1e3)||n.gte(100))return n.toFormat(Math.min(a,Math.min(o||100,Math.max(e||0,1))),r);if(n.gte(1))return n.toFormat(Math.min(a,Math.min(o||100,Math.max(e||0,2))),r);if(n.gte(.01))return n.toFormat(Math.min(a,Math.min(o||100,Math.max(e||0,4))),r);for(let s=e||4;s<17;s++)if(n.gte(Math.pow(10,-s)))return n.toFormat(Math.min(a,Math.min(o||100,Math.max(e||0,s))),r);return n.isEqualTo(0)?"0":n.toFormat(Math.min(a,Math.min(o||100,Math.max(e||0,8))),r)},"numberToString");var tr=i(t=>t?.reduce((e,o)=>e+(o.estimatedTimeInSeconds??0),0)||0,"totalArrivalTime");var bt=i((t,e)=>t.toLowerCase().indexOf(e.toLowerCase())>-1,"containsText"),sn=i(t=>!!t&&parseFloat(t)>0,"isPositiveNumber");function ln(t){switch(!0){case t.connected:return Et.CONNECTED;case t.connecting:return Et.CONNECTING;case!t.installed:return Et.NOT_INSTALLED;default:return Et.DISCONNECTED}}i(ln,"mapStatusToWalletState");function Tp(t,e,o,n){return o.filter(r=>!lp.includes(r)).filter(r=>{let{supportedChains:a,isContractWallet:s}=e(r),{installed:l,network:p}=t(r);return s&&(!l||!!n&&p!==n)?!1:n?!!a.find(c=>c.name===n):!0}).map(r=>{let{name:a,img:s,installLink:l,showOnMobile:p,namespaces:u,singleNamespace:c,supportedChains:m,needsDerivationPath:g}=e(r),d=Ao(m.map(h=>h.type)),f=ln(t(r));return{title:a,image:s,link:Uh(l),state:f,type:r,showOnMobile:p,namespaces:u,singleNamespace:c,blockchainTypes:d,needsDerivationPath:g}})}i(Tp,"mapWalletTypesToWalletInfo");function rr(t){if(!t)return null;let e=[];return e=t.map(o=>o.name),e}i(rr,"walletAndSupportedChainsNames");function vp(t,e,o,n,r){let a=[];function s(p,u){if(!!!a.find(m=>m.chain===p)){let m={address:u,chain:p,walletType:t};a.push(m)}}i(s,"addAccount");let l=n||[];return e.forEach(p=>{let{address:u,network:c}=Oh(p),m=l.length>0,g=l.includes(c),d=c===kp.Unknown;if(m&&!g&&!d)return;let h=c===kp.Unknown&&Qh(u);if(d&&!h)return;o.includes(c)||h?r?s(c,u.toLowerCase()):l.filter(k=>o.includes(k)).forEach(k=>{s(k,u.toLowerCase())}):s(c,u)}),a}i(vp,"prepareAccountsForWalletStore");function ao(t){let{filter:e,quote:o}=t,n=new Set;return o?.swaps.forEach((r,a)=>{let s=r.from.blockchain,l=r.to.blockchain;if(n.add(s),r.internalSwaps){let{internalSwaps:p}=r;p.forEach((u,c)=>{let m=u.from.blockchain,g=u.to.blockchain,d=a===o.swaps.length-1,f=c===p.length-1;(!d&&!f||d&&l!==m||e==="all")&&n.add(m),e==="all"&&n.add(g)})}e==="all"&&n.add(l)}),Array.from(n)}i(ao,"getQuoteWallets");function ir(t,e){return t.address===e.address&&t.chain===e.chain&&t.walletType===e.walletType}i(ir,"isAccountAndWalletMatched");function xp(t,e){let{blockChain:o,balances:n=[]}=t;return n?.map(r=>({chain:o,symbol:r.asset.symbol,ticker:r.asset.symbol,address:r.asset.address||null,rawAmount:r.amount.amount,decimal:r.amount.decimals,amount:new ta(r.amount.amount).shiftedBy(-r.amount.decimals).toFixed(),logo:"",usdPrice:e(r.asset)?.usdPrice||null}))||[]}i(xp,"makeBalanceFor");function wp(t){return{...t,loading:!1,error:!0}}i(wp,"resetConnectedWalletState");var bp=i(t=>{let e=new Set,n=t?.reduce((a,s)=>a.findIndex(l=>l.address===s.address&&l.chain===s.chain)===-1?[...a,s]:a,[])?.map(a=>{let s={name:a.chain,accounts:[]};return e.has(a.address)||e.add(a.address),e.forEach(l=>{a.address===l&&s.accounts.push(a)}),s}),r=B(n?.flatMap(a=>a.accounts)?.flatMap(a=>a?.balances)?.map(a=>new ta(a?.amount||Ue).multipliedBy(a?.usdPrice||0))?.reduce((a,s)=>a.plus(s),Ue)||Ue).toString();return Hh(r)},"calculateWalletUsdValue");function Hh(t){let e=t.toString().split(".");return e[0]=e[0].replace(/\B(?=(\d{3})+(?!\d))/g,","),e.join(".")}i(Hh,"numberWithThousandSeparator");var ar=i((t,e)=>{let o=zh(Object.entries(t).map(([,n])=>n).filter(qh));return o&&o[e]?.experimental},"isExperimentalChain");function sr(t){return t?{...t,amount:B(t.amount,8,8),usdValue:B(t.usdValue,4,4)}:null}i(sr,"formatBalance");function Ep(t,e){return t?.usdValue||e?.usdValue?parseFloat(e?.usdValue||"0")-parseFloat(t?.usdValue||"0"):t?.amount||e?.amount?parseFloat(e?.amount||"0")-parseFloat(t?.amount||"0"):0}i(Ep,"compareTokenBalance");function so(t,e){return t?.blockchain===e?.blockchain&&t?.symbol.toLowerCase()===e?.symbol.toLowerCase()&&t?.address?.toLowerCase()===e?.address?.toLowerCase()}i(so,"areTokensEqual");function Ip(t){return t.sort((e,o)=>+(o.state===Et.CONNECTED)-+(e.state===Et.CONNECTED)||+(o.state===Et.DISCONNECTED||o.state===Et.CONNECTING)-+(e.state===Et.DISCONNECTED||e.state===Et.CONNECTING))}i(Ip,"sortWalletsBasedOnConnectionState");function lr(t,e=8,o=3){if(t.length<2*e+o)return t;let n=t.slice(0,e),r=t.slice(-e);return`${n}${".".repeat(o)}${r}`}i(lr,"getConciseAddress");function Ap({chain:t,connectedWallets:e,walletType:o}){return e.find(n=>n.walletType===o&&n.chain===t)?.address}i(Ap,"getAddress");function pr(t){return t.flatMap(e=>e.balances).reduce((e,o)=>{let n={amount:o?.amount??"",decimals:o?.decimal??0,usdValue:o?.usdPrice?new ta(o?.usdPrice??Ue).multipliedBy(o?.amount).toString():""},r=o?$e({symbol:o.symbol,blockchain:o.chain,address:o.address}):null,a=r?e[r]:null;return r&&(!a||a&&a.amount<n.amount)&&(e[r]=n),e},{})}i(pr,"makeTokensBalance");var Np=i((t,e)=>!!t.find(o=>o.chain===e&&o.loading),"isFetchingBalance");function Wp(t){return t.map(e=>e.state).join("-")}i(Wp,"hashWalletsState");function Mp(t,e){let o=new Set;return t.forEach(r=>{r.blockchainTypes.forEach(a=>{o.add(a)})}),e.filter(r=>o.has(r.type))}i(Mp,"filterBlockchainsByWalletTypes");function Bp(t,e){return e===Fh.ALL?t:t.filter(o=>{for(let n of o.blockchainTypes)if(Rn(n,e))return!0;return!1})}i(Bp,"filterWalletsByCategory");var oa={API_KEY:Yn};function ct(t){return oa[t]||""}i(ct,"getConfig");function Lp(t){let e;return typeof structuredClone=="function"?e=structuredClone(t):e=JSON.parse(JSON.stringify(t)),oa=e,oa}i(Lp,"initConfig");var Pp=20,Dp=25,na="theme-widget",ra=i((t,e)=>{let o=!1;if(e&&t){if(Array.isArray(e))o=!e.some(n=>so(n,t));else if(!Array.isArray(e)&&e[t.blockchain]){o=e[t.blockchain].tokens.some(r=>so(r,t));let n=e[t.blockchain].isExcluded;return!n&&!o||n&&o}}return o},"isTokenExcludedInConfig"),ia=i((t,e)=>t&&e&&!e.includes(t.name),"isBlockchainExcludedInConfig"),_p=i((t,e,o)=>o==="expanded"&&(t||e)||o==="full-expanded"&&e,"isVariantExpandable");var cr,qt=i(()=>cr||(cr=new Gh(ct("API_KEY"),ct("BASE_URL")),cr),"httpService");import{WidgetEvents as $p}from"@rango-dev/queue-manager-rango-preset";var aa=(o=>(o.QUOTE_INPUT_UPDATE="quoteInputUpdate",o.QUOTE_OUTPUT_UPDATE="quoteOutputUpdate",o))(aa||{}),ur=(o=>(o.CONNECT="connect",o.DISCONNECT="disconnect",o))(ur||{}),sa=(e=>(e.CLICK_CONNECT_WALLET="clickConnectWallet",e))(sa||{}),lo=(a=>(a[a.RouteEvent=$p.RouteEvent]="RouteEvent",a[a.StepEvent=$p.StepEvent]="StepEvent",a.QuoteEvent="quoteEvent",a.WalletEvent="walletEvent",a.UiEvent="uiEvent",a))(lo||{});var Vh=i(t=>{let e=t;e.use={};for(let o of Object.keys(e.getState()))e.use[o]=()=>e(n=>n[o]);return e},"createSelectors"),Ht=Vh;var Z=Ht(Kh()(jh((t,e)=>({connectedWallets:[],balances:{},loading:!1,connectWallet:(o,n)=>{ye.emit("walletEvent",{type:"connect",payload:{walletType:o[0].walletType,accounts:o}});let r=e().getWalletsDetails;t(a=>({loading:!0,connectedWallets:a.connectedWallets.filter(s=>s.walletType!==o[0].walletType).concat(o.map(s=>{let l=!a.connectedWallets.some(p=>p.chain===s.chain&&p.selected&&p.walletType!==s.walletType);return{balances:[],address:s.address,chain:s.chain,explorerUrl:null,walletType:s.walletType,selected:l,loading:!0,error:!1}}))})),r(o,n)},disconnectWallet:o=>{t(n=>{n.connectedWallets.find(l=>l.walletType===o)&&ye.emit("walletEvent",{type:"disconnect",payload:{walletType:o}});let r=n.connectedWallets.filter(l=>l.selected&&l.walletType!==o).map(l=>l.chain),a=n.connectedWallets.filter(l=>l.walletType!==o).map(l=>r.includes(l.chain)?l:(r.push(l.chain),{...l,selected:!0}));return{balances:pr(a),connectedWallets:a}})},selectWallets:o=>t(n=>({connectedWallets:n.connectedWallets.map(r=>{let a=!!o.find(l=>l.chain===r.chain&&l.walletType!==r.walletType&&r.selected),s=!!o.find(l=>l.chain===r.chain&&l.walletType===r.walletType&&!r.selected);return a?{...r,selected:!1}:s?{...r,selected:!0}:r})})),clearConnectedWallet:()=>t(()=>({connectedWallets:[],selectedWallets:[]})),getWalletsDetails:async(o,n,r=!0)=>{let a=e().getWalletsDetails;t(s=>({loading:!0,connectedWallets:s.connectedWallets.map(l=>o.find(p=>ir(p,l))?{...l,loading:!0}:l)}));try{let s=o.map(({address:u,chain:c})=>({address:u,blockchain:c})),p=(await qt().getWalletsDetails(s)).wallets;if(p)t(u=>{let c=u.connectedWallets.map(g=>{let d=o.find(h=>ir(h,g)),f=p.find(h=>h.address===g.address&&h.blockChain===g.chain);return f?.failed&&d&&r&&a([d],n,!1),d&&f?{...g,explorerUrl:f.explorerUrl,balances:xp(f,n),loading:!1,error:!1}:g});return{loading:!1,balances:pr(c),connectedWallets:c}});else throw new Error("Wallet not found")}catch{t(l=>{let p=l.connectedWallets.map(c=>o.find(m=>ir(m,c))?wp(c):c);return{loading:!1,balances:pr(p),connectedWallets:p}})}},getBalanceFor:o=>{let{balances:n}=e(),r=$e(o);return n[r]??null}}))));import{allProviders as Xh}from"@rango-dev/provider-all";function mr(t,e){let o=Xh({walletconnect2:{WC_PROJECT_ID:e?.walletConnectProjectId||"",DISABLE_MODAL_AND_OPEN_LINK:e?.walletConnectListedDesktopWalletLink},selectedProviders:t,trezor:e?.trezorManifest?{manifest:e.trezorManifest}:void 0});if(t){let n=[];return t.forEach(r=>{if(typeof r=="string"){let a=o.find(s=>s.config.type===r);a?n.push(a):console.warn(`Couldn't find ${r} provider. Please make sure you are passing the correct name.`)}else n.push(r)}),n}return o}i(mr,"matchAndGenerateProviders");function Fp(t,e){return mr(t,e).map(r=>r.config.type)}i(Fp,"configWalletsToWalletName");function Op(t){return t.map(e=>typeof e=="string"?e:e.config.type).join("-")}i(Op,"hashProviders");function la(t,e){let o=Z.use.clearConnectedWallet(),n=mr(t,e);return Yh(()=>{o(),n=mr(t,e)},[Op(t??[]),e?.walletConnectProjectId,e?.walletConnectListedDesktopWalletLink]),{providers:n}}i(la,"useWalletProviders");import hy,{createContext as yy,useContext as Sy,useEffect as Cy,useRef as ky}from"react";import{create as fy}from"zustand";import{persist as gy}from"zustand/middleware";var pa=class{static{i(this,"CacheService")}#e=new Map;get(e){return this.#e.get(e)}set(e,o){this.#e.set(e,o)}remove(e){this.#e.delete(e)}clear(){this.#e.clear()}},Wo=new pa;function pn(t){let{config:e,meta:o}=t,n={},r=e.tokens,a=i(l=>{l.forEach(p=>{typeof p!="string"&&(p=$e(p));let u=o.tokensMapByTokenHash.get(p);u&&(n[p]=u)})},"addTokens");if(Array.isArray(r))return r.length>0?(a(r),Object.values(n)):Array.from(o.tokensMapByTokenHash.values());if(!r)return Array.from(o.tokensMapByTokenHash.values());let s;if(e.blockchains?.length)s=e.blockchains;else{s=Object.keys(r);let l=new Set(s);Object.keys(o.tokensMapByBlockchainName).forEach(p=>{l.has(p)||a(o.tokensMapByBlockchainName[p])})}return s.forEach(l=>{let p=r[l];if(!p&&o.tokensMapByBlockchainName?.[l]){a(o.tokensMapByBlockchainName[l]);return}p&&(p.isExcluded?(a(o.tokensMapByBlockchainName[l]),p.tokens.forEach(u=>{let c=$e(u);delete n[c]})):a(p.tokens))}),Object.values(n)}i(pn,"matchTokensFromConfigWithMeta");function dr(t){let{config:e}=t,o=e.from?.blockchains||[],n=e.to?.blockchains||[];if(!o.length||!n.length)return[];let r=[...o,...n],a=new Set(r);return Array.from(a)}i(dr,"getSupportedBlockchainsFromConfig");var ca={apiKey:"",title:void 0,multiWallets:!0,excludeLiquiditySources:!0,customDestination:!0,variant:"default",trezorManifest:{appUrl:"https://widget.rango.exchange/",email:"hi+trezorwidget@rango.exchange"}},Zh={clientUrl:void 0},Jh={liquiditySources:void 0},Up=i((t,e,o)=>({config:{...ca,...t},iframe:Zh,campaignMode:Jh,getLiquiditySources:()=>{let{config:n,campaignMode:r}=o();return r.liquiditySources?.length?r.liquiditySources:n.liquiditySources??[]},getDisabledLiquiditySources:()=>{let{disabledLiquiditySources:n,campaignMode:r}=o();return r.liquiditySources?.length?[]:n},excludeLiquiditySources:()=>{let{config:n,campaignMode:r}=o();return r.liquiditySources?.length?!1:!!n.excludeLiquiditySources},isInCampaignMode:()=>{let{campaignMode:n}=o();return!!n.liquiditySources?.length},updateConfig:n=>{let r=o().config,{_tokensMapByTokenHash:a,_tokensMapByBlockchainName:s}=o(),l=pn({type:"source",config:{blockchains:n.from?.blockchains,tokens:n.from?.tokens},meta:{tokensMapByBlockchainName:s,tokensMapByTokenHash:a}}),p=pn({type:"destination",config:{blockchains:n.to?.blockchains,tokens:n.to?.tokens},meta:{tokensMapByBlockchainName:s,tokensMapByTokenHash:a}});Wo.set("supportedSourceTokens",l),Wo.set("supportedDestinationTokens",p),e({config:{...r,...n}})},updateCampaignMode:(n,r)=>{let a=o().campaignMode;e({campaignMode:{...a,[n]:r}})},updateIframe:(n,r)=>{let a=o().iframe;e({iframe:{...a,[n]:r}})}}),"createConfigSlice");import{TransactionType as zp}from"rango-types";var Qp=[zp.EVM,zp.SOLANA];function fr(t,e){let o=t.map(a=>a.swapperGroup),n=[];return Ao(t.map(a=>a.swapperGroup)).map(a=>{let s=t.find(l=>l.swapperGroup===a);if(s){let l=!0;o&&(l=o.some(p=>p===s.swapperGroup)),l&&s.types.map(p=>{n.push({id:s.swapperGroup,groupTitle:s.swapperGroup,logo:s.logo,type:p,selected:!e.includes(s.swapperGroup)})})}}),n}i(fr,"getUniqueSwappersGroups");function qp(t,e){return t.swapperGroup<e.swapperGroup?-1:t.swapperGroup>e.swapperGroup?1:0}i(qp,"sortLiquiditySourcesByGroupTitle");function je(t,e){return e?.[t]==="hidden"}i(je,"isFeatureHidden");function Hp(t,e){return e?.[t]==="enabled"}i(Hp,"isFeatureEnabled");var Gp=i((t,e,o)=>je("customTokens",o)?t:t.concat(e),"addCustomTokensToSupportedTokens");var Vp=i((t,e)=>({_blockchainsMapByName:new Map,_tokensMapByTokenHash:new Map,_tokensMapByBlockchainName:{},_popularTokens:[],_swappers:[],fetchStatus:"loading",blockchains:o=>{let n=e()._blockchainsMapByName,r=Array.from(n?.values()||[]);if(!o||!o?.type)return r;let a=e().config;if(o.type==="custom-token"){let p=dr({config:a}),u=r;return p.length>0&&(u=u.filter(c=>p.includes(c.name))),u.filter(c=>Qp.includes(c.type))}let s=(o.type==="source"?a.from?.blockchains:a.to?.blockchains)??[];return r.filter(p=>!(s.length>0&&!s.includes(p.name)))},tokens:o=>{let{_tokensMapByTokenHash:n,_tokensMapByBlockchainName:r,config:a,_customTokens:s}=e(),l=Array.from(n.values()),p=e()._blockchainsMapByName;if(!o||!o.type)return l;let u=o.type==="source"?"from":"to",c=o.type==="source"?"supportedSourceTokens":"supportedDestinationTokens",m=Wo.get(c);m?.length||(m=pn({type:o.type,config:{blockchains:a[u]?.blockchains,tokens:a[u]?.tokens},meta:{tokensMapByTokenHash:n,tokensMapByBlockchainName:r}}),Wo.set(c,m)),m=Gp(m,s,a.features);let g=e().blockchains({type:o.type});return m.filter(f=>o.blockchain&&f.blockchain!==o.blockchain||!g.some(h=>h.name===f.blockchain)?!1:o.searchFor?!!(et(f.symbol,o.searchFor)||et(f.address||"",o.searchFor)||et(f.name||"",o.searchFor)):!0).sort((f,h)=>{let S=e().isTokenPinned(f,o.type),C=e().isTokenPinned(h,o.type);if(S!==C)return S?-1:1;if(o.getBalanceFor){let N=o.getBalanceFor(f),M=o.getBalanceFor(h),w=Ep(N,M);if(w!==0)return w}let k=p.get(f.blockchain),T=p.get(h.blockchain),v=ea(f,k),x=ea(h,T);if(v!==x)return v?-1:1;if(f.isPopular!==h.isPopular)return f.isPopular?-1:1;if(o.searchFor){let N=gp(f,h,o.searchFor);if(N)return N}return f.isSecondaryCoin!==h.isSecondaryCoin?f.isSecondaryCoin?1:-1:k&&T?k.sort-T.sort:0})},findToken:o=>{let n=e()._tokensMapByTokenHash,r=e().customTokens(),a=$e(o),s=n.get(a);return s||(s=r.find(l=>$e(l)===a)),s},isTokenPinned:(o,n)=>!!(n==="source"?e().config.from?.pinnedTokens:e().config.to?.pinnedTokens)?.some(s=>so(s,o)),swappers:()=>{let{config:o,campaignMode:n}=e(),r=n.liquiditySources?.length?n.liquiditySources:null,a=r??o.liquiditySources,s=r?!1:o.excludeLiquiditySources;return e()._swappers.filter(u=>{let c=a?.includes(u.swapperGroup);return s||!a||a.length===0?!c:c}).sort(qp)},fetch:async()=>{try{let{enableCentralizedSwappers:o}=e().config,n=await qt().getAllMetadata({enableCentralizedSwappers:o});t({fetchStatus:"success"});let r=new Map,a=new Map,s={},l=[],p=n.popularTokens,u=n.swappers,c=new Set;n.tokens.forEach(g=>{c.add(g.blockchain),l.push(g)}),n.blockchains.sort((g,d)=>g.sort-d.sort).forEach(g=>{g.enabled&&c.has(g.name)&&r.set(g.name,g)}),l.forEach(g=>{let d=$e(g);s[g.blockchain]||(s[g.blockchain]=[]),a.set(d,g),s[g.blockchain].push(d)}),t({_blockchainsMapByName:r,_tokensMapByTokenHash:a,_tokensMapByBlockchainName:s,_popularTokens:p,_swappers:u})}catch(o){throw t({fetchStatus:"failed"}),o}}}),"createDataSlice");import{Chinese as Rh,English as ey,Finland as ty,French as oy,German as ny,Greece as ry,Italian as iy,Japanese as ay,Netherlands as sy,Poland as ly,Portuguese as py,Russian as cy,Spanish as uy,Swedish as my,Ukrainian as dy}from"@rango-dev/ui";var Kp=[{title:"English",label:"English",local:"en",SVGFlag:ey},{title:"Spanish",label:"Espa\xF1ol",local:"es",SVGFlag:uy},{title:"French",label:"Fran\xE7ais",local:"fr",SVGFlag:oy},{title:"Japanese",label:"\u65E5\u672C\u8A9E",local:"ja",SVGFlag:ay},{title:"Portuguese",label:"Portugu\xEAs",local:"pt",SVGFlag:py},{title:"Chinese",label:"\u4E2D\u56FD\u4EBA",local:"zh",SVGFlag:Rh},{title:"Russian",label:"\u0420\u0443\u0441\u0441\u043A\u0438\u0439",local:"ru",SVGFlag:cy},{title:"German",label:"Deutsch",local:"de",SVGFlag:ny},{title:"Ukrainian",label:"\u0423\u043A\u0440\u0430\u0457\u043D\u0456",local:"uk",SVGFlag:dy},{title:"Swedish",label:"svenska",local:"sv",SVGFlag:my},{title:"Finnish",label:"Suomalainen",local:"fi",SVGFlag:ty},{title:"Dutch",label:"Nederlands",local:"nl",SVGFlag:sy},{title:"Greek",label:"Grieks",local:"el",SVGFlag:ry},{title:"Italian",label:"Italiana",local:"it",SVGFlag:iy},{title:"Polish",label:"Polski",local:"pl",SVGFlag:ly}],Mo="en";var jp=[.5,1,3],Xp=1,Yp=5,Zp=100,Jp=0;var Rp=i((t,e)=>({disabledLiquiditySources:[],theme:"auto",language:null,preferredBlockchains:[],slippage:Xp,customSlippage:null,infiniteApprove:!1,affiliateRef:null,affiliatePercent:null,affiliateWallets:null,_customTokens:[],addPreferredBlockchain:o=>{let n=e().preferredBlockchains;if(n.find((s,l)=>{let p=s===o,u=l<=9;return p&&u}))return;let a=n.filter(s=>!(s===o));t(()=>({preferredBlockchains:[o,...a]}))},setSlippage:o=>t(()=>({slippage:o})),setCustomSlippage:o=>t(()=>({customSlippage:o})),setAffiliateRef:o=>t(()=>({affiliateRef:o})),setAffiliatePercent:o=>t(()=>({affiliatePercent:o})),setAffiliateWallets:o=>t(()=>({affiliateWallets:o})),toggleAllLiquiditySources:(o,n)=>t(r=>{if(n)return{disabledLiquiditySources:[]};let a=Ao(o.map(s=>s.swapperGroup));return a.length===r.disabledLiquiditySources.length?{disabledLiquiditySources:[]}:{disabledLiquiditySources:a}}),toggleInfiniteApprove:()=>t(o=>({infiniteApprove:!o.infiniteApprove})),toggleLiquiditySource:o=>t(n=>n.disabledLiquiditySources.includes(o)?{disabledLiquiditySources:n.disabledLiquiditySources.filter(r=>r!=o)}:{disabledLiquiditySources:n.disabledLiquiditySources.concat(o)}),setTheme:o=>t(()=>({theme:o})),setLanguage:o=>t(()=>({language:o})),updateSettings:o=>{let{features:n,theme:r}=o,a=je("theme",n),s=je("language",n),l=je("liquiditySource",n),p=r?.singleTheme,u=o?.__UNSTABLE_OR_INTERNAL__?.autoUpdateSettings;t({...a&&{theme:o.theme?.mode||"auto"},...p&&{theme:o.theme?.mode||"light"},...s&&{language:o.language||Mo},...l&&{disabledLiquiditySources:o.liquiditySources||[]},...u&&{language:o.language||Mo}})},setCustomToken:o=>t(n=>({_customTokens:[o,...n._customTokens]})),deleteCustomToken:o=>t(n=>({_customTokens:n._customTokens.filter(r=>r.address!==o.address)})),customTokens:()=>{let o=e().config,n=e()._customTokens,r=dr({config:o});return r.length?n.filter(a=>r.includes(a.blockchain)):n}}),"createSettingsSlice");function ec(t){return fy()(gy((...e)=>({...Vp(...e),...Rp(...e),...Up(t,...e)}),{name:"user-settings",skipHydration:!0,partialize:e=>({_customTokens:e._customTokens,theme:e.theme,language:e.language,affiliatePercent:e.affiliatePercent,affiliateRef:e.affiliateRef,affiliateWallets:e.affiliateWallets,slippage:e.slippage,customSlippage:e.customSlippage,infiniteApprove:e.infiniteApprove,preferredBlockchains:e.preferredBlockchains,disabledLiquiditySources:e.disabledLiquiditySources})}))}i(ec,"createAppStore");var tc=yy(null);function y(){let t=Sy(tc);if(Cy(()=>{t&&!t.persist.hasHydrated()&&t.persist.rehydrate()},[]),!t)throw new Error("Missing AppStoreContext.Provider in the tree");return t()}i(y,"useAppStore");function oc(t){let e=ky();return e.current||(e.current=ec(t.config)),hy.createElement(tc.Provider,{value:e.current},t.children)}i(oc,"AppStoreProvider");import{create as vy}from"zustand";var nc="rango-widget";var cn=class{constructor(e){this.state="not-initiated";this.events={};this.init=()=>{this.initEvents(),this.tryClaim()};this.forceClaim=()=>{if(!this.isClaimed()){let e={name:"force-claim",candidateId:this.tabId};this.channel.postMessage(e),setTimeout(()=>{this.isClaimed()||this.claim()},300)}};this.isClaimed=()=>this.state==="claimed";this.destroy=()=>{this.channel.removeEventListener("message",this.handleMessageEvent),document.removeEventListener("visibilitychange",this.handleVisibilityChange),document.removeEventListener("resume",this.handleResume)};this.handleMessageEvent=e=>{let o=e.data.name;switch(o){case"ping":this.claimedByCurrentTab(e.data.pingAt);break;case"pong":this.alreadyClaimedByAnotherTab();break;case"force-claim":this.forceRelease(e.data.candidateId);break;case"force-release":this.tabId===e.data.candidateId&&this.claim();break;default:throw new Error(`${o} is not supported.`)}};this.handleVisibilityChange=async()=>{document.visibilityState==="visible"&&await this.tryClaim()};this.handleResume=async()=>{this.isClaimed()&&(await this.tryClaim(),this.isClaimed()||this.events.onRelease?.())};this.channel=new BroadcastChannel(nc),this.tabId=Math.trunc(Math.random()*1e5),this.events=e}static{i(this,"TabManager")}initEvents(){this.channel.addEventListener("message",this.handleMessageEvent),document.addEventListener("visibilitychange",this.handleVisibilityChange),document.addEventListener("resume",this.handleResume)}claimedByCurrentTab(e){let o=this.lastTryClaim&&this.lastTryClaim<e;if(this.isClaimed()||o){let n={name:"pong"};this.channel.postMessage(n);return}}alreadyClaimedByAnotherTab(){this.resetLastCheck()}async tryClaim(){return this.setLastCheck(),new Promise(e=>{setTimeout(()=>{this.check(),e()},300)})}check(){this.state==="not-initiated"&&this.events.onInit?.(),this.lastTryClaim?(this.claim(),this.resetLastCheck()):this.state="not-claimed"}claim(){this.state="claimed",this.events.onClaim?.()}setLastCheck(){this.lastTryClaim=Date.now();let e={name:"ping",pingAt:this.lastTryClaim};this.channel.postMessage(e)}resetLastCheck(){this.lastTryClaim=void 0}forceRelease(e){if(this.isClaimed()){this.state="not-claimed",this.events.onRelease?.();let o={name:"force-release",candidateId:e};this.channel.postMessage(o)}}};var se=Ht(vy()((t,e)=>({isActiveTab:!1,tabManagerInitiated:!1,showActivateTabModal:!1,watermark:"NONE",fetchingApiConfig:!1,activateCurrentTab:(o,n)=>{let{showActivateTabModal:r}=e();!r&&n?t({showActivateTabModal:!0}):(r||!n)&&o()},setShowActivateTabModal:o=>{t({showActivateTabModal:o})},setWatermark:o=>{t({watermark:o})}}))),po=new cn({onInit:()=>se.setState({tabManagerInitiated:!0}),onClaim:()=>se.setState({isActiveTab:!0,showActivateTabModal:!1}),onRelease:()=>se.setState({isActiveTab:!1})});var hr=by({onConnectWallet:()=>{},onDisconnectWallet:()=>{}});function Iy(t){let{updateConfig:e,updateSettings:o,fetch:n,fetchStatus:r}=y(),a=y().blockchains(),{findToken:s}=y(),l=y().config,p={walletConnectProjectId:l?.walletConnectProjectId,trezorManifest:l?.trezorManifest,walletConnectListedDesktopWalletLink:t.config.__UNSTABLE_OR_INTERNAL__?.walletConnectListedDesktopWalletLink},{providers:u}=la(l.wallets,p),{connectWallet:c,disconnectWallet:m}=Z(),g=ac(),d=ac();ic(()=>{n().catch(console.log)},[]),ic(()=>{t.config&&(e(t.config),o(t.config),window.__rango={config:l,dappConfig:t.config})},[t.config,r]);let f=a.filter(wy).map(k=>k.name),h=i((k,T,v,x,N)=>{if(T===ma.ACCOUNTS)if(v){let M=rr(N.supportedBlockchains),w=vp(k,v,f,M,N.isContractWallet);w.length&&c(w,s)}else m(k),d.current?d.current(k):console.warn("onDisconnectWallet handler hasn't been set. Are you sure?");if(T===ma.ACCOUNTS&&x.connected){let M=`${k}-${x.network}-${v}`;x.connected&&(g.current?g.current(M):console.warn("onConnectWallet handler hasn't been set. Are you sure?"))}if(T===ma.NETWORK&&x.network){let M=`${k}-${x.network}`;g.current?g.current(M):console.warn("onConnectWallet handler hasn't been set. Are you sure?")}t.onUpdateState&&t.onUpdateState(k,T,v,x,N)},"onUpdateState"),S=se.use.isActiveTab(),C=Ey(()=>({onConnectWallet:k=>{g.current=k},onDisconnectWallet:k=>{d.current=k}}),[]);return gr.createElement(hr.Provider,{value:C},gr.createElement(xy,{allBlockChains:a,providers:u,onUpdateState:h,autoConnect:!!S},t.children))}i(Iy,"Main");function yr(t){let{config:e,...o}=t;return gr.createElement(oc,{config:e},gr.createElement(Iy,{...o,config:e}))}i(yr,"WidgetWallets");import Ki from"react";import Ay,{Fragment as Ny}from"react";import{MemoryRouter as Wy,useInRouterContext as My}from"react-router";function sc({children:t}){let o=My()?Ny:Wy;return Ay.createElement(o,null,t)}i(sc,"AppRouter");import{I18nManager as Jb}from"@rango-dev/ui";import op from"react";import De from"react";import{useRoutes as Fb}from"react-router-dom";var D={home:"/",fromSwap:"from-swap",toSwap:"to-swap",blockchains:"blockchains",settings:"settings",customTokens:"custom-tokens",addCustomTokens:"add-custom-tokens",liquiditySources:"liquidity-sources",bridges:"bridges",exchanges:"exchanges",languages:"languages",swaps:"swaps",wallets:"wallets",confirmSwap:"confirm-swap",swapDetails:":requestId",routes:"routes"};import{useEffect as Po,useRef as Er}from"react";import Xe from"bignumber.js";import{create as Py}from"zustand";import{subscribeWithSelector as Dy}from"zustand/middleware";import{getLastSuccessfulStep as Ly}from"@rango-dev/queue-manager-rango-preset";import OA from"bignumber.js";function da(t,e){return{"Network Fee":e("Network Fee"),"Swapper Fee":e("Protocol Fee"),"Affiliate Fee":e("Affiliate Fee"),"Outbound network fee":e("Outbound Fee"),"Rango Fee":e("Rango Fee")}[t]}i(da,"getFeeLabel");var fa=["RECOMMENDED","CENTRALIZED","LOWEST_FEE","FASTEST","HIGH_IMPACT"],lc=30;import{i18n as ft}from"@lingui/core";import{RouteEventType as wA}from"@rango-dev/queue-manager-rango-preset";import ze from"bignumber.js";import{PendingSwapNetworkStatus as Cr}from"rango-types";import{i18n as Fe}from"@lingui/core";var te=i(()=>({genericServerError:Fe.t("Failed Network, Please retry your swap."),liquiditySourcesError:{title:Fe.t("Please reset your liquidity sources."),description:Fe.t("You have limited the liquidity sources and this might result in Rango finding no routes. Please consider resetting your liquidity sources.")},noResultError:{title:Fe.t("No Routes Found."),description:Fe.t("Reasons why Rango couldn't find a route: low liquidity on token, very low input amount or no routes available for the selected input/output token combination.")},bridgeLimitErrors:{increaseAmount:Fe.t("Bridge Limit Error: Please increase your amount."),decreaseAmount:Fe.t("Bridge Limit Error: Please decrease your amount.")},highValueLossError:{impactTitle:Fe.t("High Price Impact"),title:Fe.t("Price impact is too high!"),description:Fe.t("The price impact is significantly higher than the allowed amount."),confirmMessage:Fe.t("Confirm high price impact")},quoteUpdatedWithHighValueLoss:{title:Fe.t("Route updated and price impact is too high, try again later!")},unknownPriceError:{impactTitle:Fe.t("USD Price Unknown"),title:Fe.t("USD Price Unknown, Cannot calculate Price Impact."),description:Fe.t("USD Price Unknown, Cannot calculate Price Impact. The price impact may be higher than usual. Are you sure to continue the Swap?"),confirmMessage:Fe.t("Confirm USD Price Unknown")}}),"errorMessages");function pc(t){switch(t.type){case 0:return t.diagnosisMessage??te().noResultError.title;case 1:return te().genericServerError;default:return""}}i(pc,"getQuoteErrorMessage");import{i18n as Sr}from"@lingui/core";var co=i(()=>({connectWallet:Sr.t("Connect Wallet"),swap:Sr.t("Swap"),swapAnyway:Sr.t("Swap anyway"),ethWarning:Sr.t("The route goes through Ethereum. Continue?")}),"swapButtonTitles");function cc(t,e){return(parseInt(e.toFixed(2)||"0")<=-10&&t?.gte(new ze(400))||parseInt(e.toFixed(2)||"0")<=-5&&t?.gte(new ze(1e3)))??!1}i(cc,"hasHighValueLoss");function uc(t){return(t||[]).filter(e=>{let o=e.fromAmountMinValue?new ze(e.fromAmountMinValue):null,n=e.fromAmountMaxValue?new ze(e.fromAmountMaxValue):null;return e.fromAmountRestrictionType==="EXCLUSIVE"?o?.gte(e.fromAmount)||n?.lte(e.fromAmount):o?.gt(e.fromAmount)||n?.lt(e.fromAmount)}).length>0}i(uc,"hasLimitError");function mc(t){let e=(t||[]).filter(l=>{let p=l.fromAmountMinValue?new ze(l.fromAmountMinValue):null,u=l.fromAmountMaxValue?new ze(l.fromAmountMaxValue):null;return l.fromAmountRestrictionType==="EXCLUSIVE"?p?.gte(l.fromAmount)||u?.lte(l.fromAmount):p?.gt(l.fromAmount)||u?.lt(l.fromAmount)})[0],o=e.fromAmountMinValue?new ze(e.fromAmountMinValue):null,n=e.fromAmountMaxValue?new ze(e.fromAmountMaxValue):null,r=e.fromAmountRestrictionType==="EXCLUSIVE",a="",s="";return!r&&o&&o.gt(e.fromAmount)?(a=ft.t({id:"Required: >= {min} {symbol}",values:{min:B(o,6,6),symbol:e.from.symbol}}),s=te().bridgeLimitErrors.increaseAmount):r&&o&&o.gte(e.fromAmount)&&(a=ft.t({id:"Required: > {min} {symbol}",values:{min:B(o,6,6),symbol:e.from.symbol}}),s=te().bridgeLimitErrors.increaseAmount),!r&&n&&n.lt(e.fromAmount)?(a=ft.t({id:"Required: <= {max} {symbol}",values:{max:B(n,6,6),symbol:e.from.symbol}}),s=te().bridgeLimitErrors.decreaseAmount):r&&n&&n.lte(e.fromAmount)&&(a=ft.t({id:"Required: < {max} {symbol}",values:{max:B(n,6,6),symbol:e.from.symbol}}),s=te().bridgeLimitErrors.decreaseAmount),{swap:e,fromAmountRangeError:a,recommendation:s}}i(mc,"getLimitErrorMessage");function dc(t){let{fetchMetaStatus:e,anyWalletConnected:o,fetchingQuote:n,inputAmount:r,quote:a,warning:s,error:l,needsToWarnEthOnPath:p}=t;return e!=="success"?{title:co().connectWallet,action:"connect-wallet",disabled:!0}:o?n||!a||l||!r||r==="0"?{title:co().swap,action:"confirm-swap",disabled:!0}:s?{title:co().swapAnyway,action:"confirm-warning",disabled:!1}:p?{title:co().ethWarning,action:"confirm-warning",disabled:!1}:{title:co().swap,action:"confirm-swap",disabled:!1}:{title:co().connectWallet,action:"connect-wallet",disabled:!1}}i(dc,"getSwapButtonState");function ga(t,e,o){let n=parseFloat(e||"0");return!(t&&(!o||o.lte(Ue))&&e&&e!=="0"&&n!==0)}i(ga,"canComputePriceImpact");function ha(t,e){let o=Ue;for(let n=0;n<t.fee.length;n++){let r=t.fee[n];if(r.expenseType==="DECREASE_FROM_OUTPUT")continue;let a=e(r.asset)?.usdPrice||null;o=o.plus(new ze(r.amount).multipliedBy(a||0))}return o}i(ha,"getUsdFeeOfStep");function kr(t,e){return t.reduce((o,n)=>o.plus(ha(n,e)),Ue)}i(kr,"getTotalFeeInUsd");function ya(t){let e=Ue;return e=e.plus(new ze(t.amount).multipliedBy(t.price||0)),e}i(ya,"getUsdFee");function fc(t){return t.reduce((e,o)=>e.plus(ya(o)),Ue)}i(fc,"getTotalFeesInUsd");function gc(t){return t.reduce((e,o)=>{for(let n of o.fee){let r=n.name,a=n.expenseType!=="DECREASE_FROM_OUTPUT"?e.payable:e.nonePayable;a[r]=[...a[r]||[],n]}return e},{payable:{},nonePayable:{}})}i(gc,"getFeesGroup");function hc(t){let e=new Map;return t.forEach((o,n)=>{o.recommendedSlippage?.error&&e.set(n,o.recommendedSlippage.slippage)}),e.size>0?e:null}i(hc,"checkSlippageErrors");function yc(t,e){let o=new Map;return t?.swaps.forEach((n,r)=>{n.recommendedSlippage?.slippage&&parseFloat(n.recommendedSlippage.slippage)>e&&o.set(r,n.recommendedSlippage.slippage)}),o.size>0?o:null}i(yc,"checkSlippageWarnings");function Tr(t){return t.map(o=>o.recommendedSlippage)?.map(o=>o?.slippage||"0")?.filter(o=>parseFloat(o)>0)?.sort((o,n)=>parseFloat(n)-parseFloat(o))?.find(()=>!0)||null}i(Tr,"getMinRequiredSlippage");function Sc(t,e){return e?parseFloat(t)>=parseFloat(e):!0}i(Sc,"hasProperSlippage");function Cc(t){let{fromToken:e,toToken:o,inputAmount:n,wallets:r,selectedWallets:a,disabledLiquiditySources:s,liquiditySources:l,excludeLiquiditySources:p,slippage:u,affiliateRef:c,affiliatePercent:m,affiliateWallets:g,destination:d,enableCentralizedSwappers:f}=t,h=a?.reduce((k,T)=>(k[T.chain]=T.address,k),{}),S=[];return r?.forEach(k=>{S.push({blockchain:k.chain,addresses:[k.address]})}),{amount:n.toString(),affiliateRef:c??void 0,affiliatePercent:m??void 0,affiliateWallets:g??void 0,from:{address:e.address,blockchain:e.blockchain,symbol:e.symbol},to:{address:o.address,blockchain:o.blockchain,symbol:o.symbol},connectedWallets:S,selectedWallets:h??{},slippage:u.toString(),...d&&{destination:d},...p&&{swapperGroups:s.concat(l??[]),swappersGroupsExclude:!0},...!p&&{swapperGroups:l?.filter(k=>!s.includes(k)),swappersGroupsExclude:!1},enableCentralizedSwappers:f}}i(Cc,"createQuoteRequestBody");function kc(t){return t.reduce((o,n)=>(o[n.chain]={address:n.address,walletType:n.walletType},o),{})}i(kc,"getWalletsForNewSwap");function Bo(t){return t?.outputAmount||null}i(Bo,"getQuoteOutputAmount");function Tc(t,e){return new ze(e).div(new ze(t)).minus(1).multipliedBy(100).toNumber()}i(Tc,"getPercentageChange");function vc(t,e){let o=Bo(t),n=Bo(e);if(!o||!n)return!1;let r=ut(o,n);return r?r<=-1:!0}i(vc,"isOutputAmountChangedALot");function xc(t,e,o){let n=t.validationStatus,r=ao({filter:"required",quote:t});return e.sort((s,l)=>r.indexOf(s.chain)-r.indexOf(l.chain)).flatMap(s=>Nc(s,n)||[]).filter(s=>!s.ok).map(s=>{let l=s.asset.symbol,p=B(new ze(s.currentAmount.amount).shiftedBy(-s.currentAmount.decimals),8,8),u=B(new ze(s.requiredAmount.amount).shiftedBy(-s.requiredAmount.decimals),8,8),c="";return s.reason==="FEE"&&(c=ft.t(" for network fee")),s.reason==="INPUT_ASSET"&&(c=ft.t(" for swap")),s.reason==="FEE_AND_INPUT_ASSET"&&(c=ft.t(" for input and network fee")),ft.t({id:"Needs \u2248 {requiredAmount} {symbol}{reason}, but you have {currentAmount} {symbol} in your {blockchain} wallet.",values:{requiredAmount:u,symbol:l,reason:c,currentAmount:p,blockchain:pt(s.asset.blockchain,o)}})})}i(xc,"generateBalanceWarnings");function Vt(t,e){return(t?new ze(t):Ue).multipliedBy(e||0)}i(Vt,"calcOutputUsdValue");function un(t){return!!t&&t.networkStatus!==null&&t.networkStatus!==Cr.NetworkChanged}i(un,"isNetworkStatusInWarningState");function wc(t,e){let o="bellow button or",n=t.extraMessage,r=t.extraMessageDetail;if(t.networkStatusExtraMessageDetail?.includes(o)&&(t.networkStatusExtraMessageDetail=t.networkStatusExtraMessageDetail.replace(o,"")),un(e))switch(n=t.networkStatusExtraMessage||"",r=t.networkStatusExtraMessageDetail||"",e?.networkStatus){case Cr.WaitingForConnectingWallet:n=n||ft.t("Waiting for connecting wallet");break;case Cr.WaitingForQueue:n=n||ft.t("Waiting for other running tasks to be finished");break;case Cr.WaitingForNetworkChange:n=n||ft.t("Waiting for changing wallet network");break;default:n=n||"";break}r=r||"",n=n||"";let s=n?.indexOf("code")!==-1&&n?.indexOf("reason")!==-1;return{shortMessage:n,detailedMessage:{content:r,long:s}}}i(wc,"getSwapMessages");function bc(t){let e=null;if(t.status==="failed"){let o=t.steps.slice().reverse().filter(n=>n.status==="success")[0];o&&(e={blockchain:o.toBlockchain,symbol:o.toSymbol,outputAmount:o.outputAmount,address:o.toSymbolAddress})}return e}i(bc,"getLastConvertedTokenInFailedSwap");function Ec(t){return t.status==="failed"}i(Ec,"shouldRetrySwap");function Ic(t,e,o,n,r,a){if(!n||t)return!0;let s=ao({filter:"all",quote:n}),l=ao({filter:"required",quote:n}),p=s.every(m=>r.some(g=>g.chain===m)),u=l.every(m=>r.some(g=>g.chain===m)),c=o&&a?No(a,o):!1;return!e&&!p||e&&!o||e&&!!o&&(!c||!u)}i(Ic,"isConfirmSwapDisabled");function Ac(t,e){return t.blockchain===e.blockchain&&t.symbol===e.symbol&&t.address===e.address}i(Ac,"isTokensIdentical");function uo(t){let e=t?.swaps||[];return e[e.length-1].to.usdPrice}i(uo,"getQuoteToTokenUsdPrice");function mn(t){return(t?.swaps||[])[0].from.usdPrice}i(mn,"getQuoteFromTokenUsdPrice");function Sa(t,e){let o=t?.swaps||[],n=e?.swaps||[];return o.length!==n.length}i(Sa,"isNumberOfSwapsChanged");function Ca(t,e){let o=t?.swaps.map(r=>r.swapperId)||[],n=e?.swaps.map(r=>r.swapperId)||[];return!Ri(o,n)}i(Ca,"isQuoteSwappersUpdated");function ka(t,e){let o=t?.swaps.map(r=>r.to.symbol)||[],n=e?.swaps.map(r=>r.to.symbol)||[];return!Ri(o,n)}i(ka,"isQuoteInternalCoinsUpdated");function Mc(t,e){return Sa(t,e)||Ca(t,e)||ka(t,e)}i(Mc,"isQuoteChanged");function Nc(t,e){if(e===null)return null;let o=e?.find(n=>n.blockchain===t.chain)?.wallets.find(n=>n.address?.toLowerCase()===t.address.toLowerCase());return o?o.requiredAssets:null}i(Nc,"getRequiredBalanceOfWallet");function Lt(t){let e;return t<=-3&&t>-10?e="low":t<=-10&&(e="high"),e}i(Lt,"getPriceImpactLevel");function xr(t,e,o){let n=t.steps[0],r=t.steps[t.steps.length-1],a=Ly(t.steps),s={blockchain:r.toBlockchain,symbol:r.toSymbol,address:r.toSymbolAddress},l=rn(a?a.toBlockchain:n.fromBlockchain,e),p=rn(r.toBlockchain,e),u=o(a?{blockchain:l?.name??"",symbol:a.toSymbol,address:a.toSymbolAddress}:{blockchain:l?.name??"",symbol:n.fromSymbol,address:n.fromSymbolAddress}),c=o(s),m=a?a.outputAmount??"":t.inputAmount;return{fromBlockchain:l,fromToken:u,toBlockchain:p,toToken:c,inputAmount:m}}i(xr,"createRetryQuote");function Lo(t,e){let{fromToken:o,toToken:n,findToken:r,userSlippage:a}=e,s=Vt(t.requestAmount,mn(t)||o?.usdPrice),l=Vt(t.outputAmount,uo(t)||n?.usdPrice);if(t&&s&&l){let c=ut(s.toString(),l.toString());if(!!c&&cc(s,c)){let g=kr(t?.swaps,r),d=Lt(c);return{type:0,inputUsdValue:s,outputUsdValue:l,priceImpact:c,totalFee:g,warningLevel:d}}}else if(t&&(!s||!l))return{type:1};let p=Tr(t.swaps),u=a>Yp;if(Sc(e.userSlippage.toString(),p)){if(u&&parseFloat(p??"0")<a)return{type:3,slippage:a.toString()}}else return{type:2,recommendedSlippages:yc(t,a),minRequiredSlippage:p};return null}i(Lo,"generateQuoteWarnings");function ut(t,e){let o=typeof e=="string"?parseFloat(e)<=0:!e?.gt(0),n=!t||!e||o?null:Tc(t.toString(),e.toString());return n&&n<0?n:null}i(ut,"getPriceImpact");var Bc=i(t=>{let e=new Set,o=[];return t.forEach(n=>{e.has(n.from.chain.displayName)||(e.add(n.from.chain.displayName),o.push(n.from.chain)),e.has(n.to.chain.displayName)||(e.add(n.to.chain.displayName),o.push(n.to.chain))}),o},"getUniqueBlockchains"),wr=i((t,e)=>e.sort((o,n)=>{let r=i(u=>u.scores?.find(c=>c.preferenceType===t)?.score??0,"getScore"),a=r(o),s=r(n);if(a!==s)return s-a;let l=o.requestId.toLowerCase(),p=n.requestId.toLowerCase();return l.localeCompare(p)}),"sortQuotesBy"),Lc=i((t,e,o)=>{if(!e.length)return null;if(!t)return{requestAmount:o,...e[0]};let n=new Set(t.swaps.map(a=>a.swapperId)),r=e.find(a=>{let s=new Set(a.swaps.map(l=>l.swapperId));return Array.from(n).every(l=>s.has(l))});return{requestAmount:o,...r||e[0]}},"getDefaultQuote"),Pc=i(t=>{let e=i((o,n)=>{let r=fa.indexOf(o.value),a=fa.indexOf(n.value);return r!==-1&&a!==-1?r-a:r!==-1?-1:a!==-1?1:0},"customSort");return t.sort(e)},"sortTags");var br=i((t,e)=>t?.usdPrice?new Xe(e||Ue).multipliedBy(t?.usdPrice||0):null,"getUsdValue"),z=Ht(Py()(Dy(t=>({fromBlockchain:null,fromToken:null,inputAmount:"",outputAmount:null,inputUsdValue:new Xe(0),outputUsdValue:new Xe(0),toBlockchain:null,toToken:null,refetchQuote:!0,sortStrategy:"SMART",selectedQuote:null,quotes:null,error:null,warning:null,quoteWalletsConfirmed:!1,selectedWallets:[],customDestination:null,quoteWarningsConfirmed:!1,updateQuotePartialState:(e,o)=>t(n=>({...n,[e]:o})),setSelectedQuote:e=>t(o=>{let n=null,r=Ue,a=o.inputUsdValue;return sn(o.inputAmount)?(e&&(n=e?.outputAmount?new Xe(e?.outputAmount):null,a=Vt(o.inputAmount,mn(e)||o.fromToken?.usdPrice),r=Vt(e.outputAmount,uo(e)||o.toToken?.usdPrice)),{selectedQuote:e,...!!e&&{outputAmount:n,outputUsdValue:r,inputUsdValue:a}}):{}}),resetAlerts:()=>t(()=>({error:null,warning:null})),resetQuote:()=>t(()=>({selectedQuote:null,outputAmount:null,outputUsdValue:new Xe(0),quotes:null,refetchQuote:!0,error:null,warning:null})),setFromBlockchain:e=>{t(o=>o.fromBlockchain?.name===e?.name?{}:{fromBlockchain:e,inputUsdValue:new Xe(0),...o.fromToken&&{selectedQuote:null,fromToken:null,outputAmount:null,outputUsdValue:new Xe(0)}})},setFromToken:e=>t(o=>({fromToken:e.token,...e.token&&{fromBlockchain:e.meta.blockchains.find(n=>n.name===e.token.blockchain)??null},...!!o.inputAmount&&{inputUsdValue:br(e.token,o.inputAmount)}})),setToBlockchain:e=>{t(o=>o.toBlockchain?.name===e?.name?{}:{toBlockchain:e,...o.toToken&&{selectedQuote:null,toToken:null,outputAmount:null,outputUsdValue:new Xe(0)}})},setToToken:e=>t(()=>({toToken:e.token,...e.token&&{toBlockchain:e.meta.blockchains.find(o=>o.name===e.token.blockchain)??null}})),setInputAmount:e=>{t(o=>({inputAmount:e,...!e&&{outputAmount:null,outputUsdValue:new Xe(0),selectedQuote:null},...!!o.fromToken&&{inputUsdValue:br(o.fromToken,e)}}))},retry:e=>{let{fromBlockchain:o,fromToken:n,toBlockchain:r,toToken:a,inputAmount:s}=e;t({fromBlockchain:o,fromToken:n,inputAmount:s,outputAmount:null,inputUsdValue:br(n??null,s),outputUsdValue:new Xe(0),toBlockchain:r,toToken:a,selectedQuote:null})},switchFromAndTo:()=>t(e=>({fromBlockchain:e.toBlockchain,fromToken:e.toToken,toBlockchain:e.fromBlockchain,toToken:e.fromToken,inputAmount:e.outputAmount?.toString()||"",inputUsdValue:e.toToken?br(e.toToken,e.outputAmount?.toString()||""):new Xe(0)})),resetFromBlockchain:()=>t(()=>({fromToken:null,fromBlockchain:null,outputUsdValue:new Xe(0),inputUsdValue:new Xe(0),inputAmount:"",outputAmount:null,selectedQuote:null})),resetToBlockchain:()=>t(()=>({toToken:null,toBlockchain:null,outputAmount:null,outputUsdValue:new Xe(0),selectedQuote:null})),setQuoteWalletConfirmed:e=>t({quoteWalletsConfirmed:e}),setSelectedWallets:e=>t({selectedWallets:e}),setCustomDestination:e=>t({customDestination:e}),resetQuoteWallets:()=>t({quoteWalletsConfirmed:!1,selectedWallets:[],customDestination:null}),setQuoteWarningsConfirmed:e=>t({quoteWarningsConfirmed:e})})))),Dc=z.subscribe((t,e)=>{(t.fromBlockchain!==e.fromBlockchain||t.fromToken!==e.fromToken||t.toBlockchain!==e.toBlockchain||t.toToken!==e.toToken||t.inputAmount!==e.inputAmount)&&ye.emit("quoteEvent",{type:"quoteInputUpdate",payload:{fromBlockchain:t.fromBlockchain?.name,toBlockchain:t.toBlockchain?.name,fromToken:t.fromToken?{symbol:t.fromToken.symbol,name:t.fromToken.name,address:t.fromToken.address}:void 0,toToken:t.toToken?{symbol:t.toToken.symbol,name:t.toToken.name,address:t.toToken.address}:void 0,requestAmount:t.inputAmount}}),t.selectedQuote?.requestId!==e.selectedQuote?.requestId&&ye.emit("quoteEvent",{type:"quoteOutputUpdate",payload:t.selectedQuote?{requestAmount:t.selectedQuote.requestAmount,swaps:t.selectedQuote.swaps,outputAmount:t.selectedQuote.outputAmount,resultType:t.selectedQuote.resultType,tags:t.selectedQuote.tags}:null})});function _c(){let{setInputAmount:t,setToToken:e,setToBlockchain:o,setFromBlockchain:n,resetQuote:r,setFromToken:a,fromToken:s,toToken:l,fromBlockchain:p,toBlockchain:u}=z(),c=y().config,m=y().fetchStatus,g=y().blockchains(),d=y().tokens(),{findToken:f}=y(),{setAffiliateRef:h,setAffiliatePercent:S,setAffiliateWallets:C}=y(),k=c?.from?.tokens,T=c?.from?.blockchains,v=c?.to?.tokens,x=c?.to?.blockchains,N=Er(void 0),M=Er(void 0),w=Er(void 0),E=Er(void 0);Po(()=>{typeof c.amount<"u"&&t(c.amount.toString())},[c?.amount]),Po(()=>{if(m==="success"){r();let b=g.find(I=>I.name===c?.from?.blockchain),W=c?.from?.token,$=W&&f(W);(b||!b&&w.current)&&n(b??null),$?a({token:$,meta:{blockchains:g,tokens:d}}):!$&&N.current&&a({token:null}),w.current=c?.from?.blockchain,N.current=c?.from?.token}},[c?.from?.token?.symbol,c?.from?.token?.address,c?.from?.token?.blockchain,c?.from?.blockchain,m]),Po(()=>{ra(s,k)&&a({token:null}),ia(p,T)&&n(null)},[k,T]),Po(()=>{ra(l,v)&&a({token:null}),ia(u,x)&&o(null)},[v,x]),Po(()=>{if(m==="success"){r();let b=g.find(I=>I.name===c?.to?.blockchain),W=c?.to?.token,$=W&&f(W);(b||!b&&E.current)&&o(b??null),$?e({token:$,meta:{blockchains:g,tokens:d}}):!$&&M.current&&e({token:null}),E.current=c?.to?.blockchain,M.current=c?.to?.token}},[c?.to?.token?.symbol,c?.to?.token?.address,c?.to?.token?.blockchain,c?.to?.blockchain,m]),Po(()=>{h(c?.affiliate?.ref??null),S(c?.affiliate?.percent??null),C(c?.affiliate?.wallets??null)},[c?.affiliate?.ref,c?.affiliate?.percent,c?.affiliate?.wallets])}i(_c,"useSyncStoresWithConfig");import{useEffect as xa,useRef as _y}from"react";import{useInRouterContext as $y,useLocation as Fy,useSearchParams as Oy}from"react-router-dom";function Ta(t,e){let o=t.split("--");return{blockchain:e.name,address:o?.[1]||null,symbol:o[0]}}i(Ta,"convertTokenSearchParamToAsset");function va(t){if(t)return`${t.symbol}${t.address?`--${t.address}`:""}`}i(va,"tokenToSearchParam");function ba(){let t=Fy(),[e,o]=Oy(),{fromBlockchain:n,toBlockchain:r,fromToken:a,toToken:s,inputAmount:l,setFromBlockchain:p,setToBlockchain:u,setFromToken:c,setToToken:m,setInputAmount:g}=z(),d=y().fetchStatus,f=y().blockchains(),h=y().tokens(),S=$y(),{updateIframe:C,updateCampaignMode:k}=y(),T=y().isInCampaignMode(),v=_y(),{findToken:x}=y(),N=i(()=>{let w={};for(let[V,le]of e.entries())V.startsWith("utm_")&&(w[V]=le);let E=e.get("fromAmount"),b=e.get("fromBlockchain"),W=e.get("fromToken"),$=e.get("toBlockchain"),I=e.get("toToken"),R=e.get("autoConnect"),ee=e.get("clientUrl"),oe=e.get("liquiditySources"),L=e.get("blockchain");return{fromAmount:E,fromBlockchain:b,fromToken:W,toBlockchain:$,toToken:I,autoConnect:R,clientUrl:ee,liquiditySources:oe,utmQueryParams:w,blockchain:L}},"getUrlSearchParams"),M=i(w=>{for(let E in w)w[E]||delete w[E];o(w,{replace:!0})},"updateUrlSearchParams");xa(()=>{let{autoConnect:w,clientUrl:E,utmQueryParams:b,blockchain:W}=N();S&&d==="success"&&M({fromBlockchain:n?.name,fromToken:va(a),toBlockchain:r?.name,toToken:va(s),fromAmount:l,autoConnect:w??void 0,clientUrl:E??void 0,blockchain:W??void 0,liquiditySources:T?v.current:void 0,...b})},[t.pathname,l,n,a,r,s,T]),xa(()=>{if(!S)return;let w=N();if(!v.current&&w.liquiditySources&&(v.current=w.liquiditySources),w.fromAmount&&g(w.fromAmount),d==="success"){let E=f.find(I=>I.name===w.fromBlockchain),b=w.fromToken&&E?x(Ta(w.fromToken,E)):void 0,W=f.find(I=>I.name===w.toBlockchain),$=w.toToken&&W?x(Ta(w.toToken,W)):void 0;E&&(p(E),b&&c({token:b,meta:{blockchains:f,tokens:h}})),W&&(u(W),$&&m({token:$,meta:{blockchains:f,tokens:h}}))}},[d]),xa(()=>{let{clientUrl:w,liquiditySources:E}=N();C("clientUrl",w||void 0),k("liquiditySources",E?.split(",")??void 0)},[])}i(ba,"useSyncUrlAndStore");import{i18n as At}from"@lingui/core";import{Alert as mC,Button as bu,darkTheme as dC,Divider as gn,DoneIcon as fC,MessageBox as gC,styled as hC,TextField as yC,Typography as SC}from"@rango-dev/ui";import Se,{useEffect as CC,useState as Pr}from"react";import{useNavigate as kC,useSearchParams as TC}from"react-router-dom";import{ChevronRightIcon as Uy,Divider as zc,Image as zy,Typography as Qc}from"@rango-dev/ui";import gt from"react";import{darkTheme as $c,styled as Ea}from"@rango-dev/ui";var Fc=Ea("div",{display:"flex",justifyContent:"space-between",width:"100%",height:"$40",padding:"$4 $10",borderRadius:"$sm",cursor:"pointer",alignItems:"center",backgroundColor:"$neutral300",[`.${$c} &`]:{backgroundColor:"$neutral400"},"&:hover":{backgroundColor:"$secondary100",[`.${$c} &`]:{backgroundColor:"$neutral500"}},variants:{disabled:{true:{cursor:"default","&:hover":{borderColor:"$neutral300","& svg":{color:"$neutral700"}}}}}}),Oc=Ea("div",{display:"flex",flexDirection:"column",width:"100%",".title_typography":{textTransform:"capitalize"}}),Uc=Ea("div",{display:"flex"});function Ia(t){let{onClick:e,value:o,title:n,hasLogo:r,placeholder:a,disabled:s}=t;return gt.createElement(Oc,null,gt.createElement(Qc,{size:"large",variant:"label"},n),gt.createElement(zc,{size:10}),gt.createElement(Fc,{onClick:s?void 0:e,disabled:s},gt.createElement(Uc,null,r&&gt.createElement(gt.Fragment,null,gt.createElement(zy,{src:o?.logo,size:16,useAsPlaceholder:!o?.logo,type:"circular"}),gt.createElement(zc,{size:4,direction:"horizontal"})),gt.createElement(Qc,{className:"title_typography",size:"medium",variant:"label"},o?.name||a)),gt.createElement(Uy,{size:12,color:"black"})))}i(Ia,"BlockchainSelectorButton");import{Modal as Qy}from"@rango-dev/ui";import qy from"react";function J(t){let{watermark:e}=se();return qy.createElement(Qy,{hasWatermark:e==="FULL",...t},t.children)}i(J,"WatermarkedModal");import{i18n as Na}from"@lingui/core";import{Button as Hy,Divider as dn,ExternalLinkIcon as Gy,Image as Vy,Typography as _o}from"@rango-dev/ui";import Me from"react";function qc(t,e){if(e.type==="COSMOS")return"";let o=e.info?.addressUrl;return!o||!t?"":o.replace("{wallet}",t)}i(qc,"generateExplorerLink");import{darkTheme as Do,styled as Hc}from"@rango-dev/ui";var Aa=Hc("a",{textDecoration:"none",color:"$colors$neutral700",[`.${Do} &`]:{color:"$colors$neutral900"},"& svg":{marginLeft:"$4",color:"$colors$neutral700",[`.${Do} &`]:{color:"$colors$neutral900"}},variants:{hasHover:{true:{"&:hover":{color:"$colors$secondary550",[`.${Do} &`]:{color:"$colors$secondary500"},"& svg":{color:"$colors$secondary550",[`.${Do} &`]:{color:"$colors$secondary500"}}}},false:{}}}}),Gc=Hc("div",{display:"flex",justifyContent:"center",flexDirection:"column",alignItems:"center",textAlign:"center","& ._blockchain-name, & ._coin-source":{color:"$colors$neutral600",[`.${Do} &`]:{color:"$colors$neutral800"}},"& ._coin-source-name, & ._custom-token-description":{color:"$colors$neutral700",[`.${Do} &`]:{color:"$colors$neutral900"}}});function Wa(t){let{open:e,onClose:o,token:n,onSubmitClick:r,blockchain:a}=t,s=qc(n.address,a);return Me.createElement(J,{open:e,dismissible:!0,onClose:o,container:A()},Me.createElement(Gc,null,Me.createElement(Vy,{src:n.image,size:45,type:"circular"}),Me.createElement(_o,{variant:"title",size:"medium"},n.name),Me.createElement(_o,{variant:"body",size:"small",className:"_blockchain-name"},a.displayName),Me.createElement(dn,{size:4}),Me.createElement(_o,{variant:"body",size:"medium"},s?Me.createElement(Aa,{hasHover:!0,href:s,target:"_blank",rel:"nofollow noreferrer"},n.address,Me.createElement(Gy,{size:12,color:"gray"})):Me.createElement(Aa,null,n.address)),Me.createElement(dn,{size:4}),n.coinSource&&Me.createElement(_o,{className:"_coin-source",variant:"body",size:"xsmall"},Na.t("via")," ",Me.createElement(_o,{className:"_coin-source-name",variant:"body",size:"xsmall"},n.coinSource)),Me.createElement(dn,{size:"32"}),Me.createElement(_o,{size:"medium",variant:"body",className:"_custom-token-description"},Na.t("This token doesn't appear on the active token list(s). Make sure this is the token that you want to trade."))),Me.createElement(dn,{size:40}),Me.createElement(dn,{size:10}),Me.createElement(Hy,{variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:r},Na.t("Import")))}i(Wa,"CustomTokenModal");import{useManager as aC}from"@rango-dev/queue-manager-react";import{BottomLogo as sC,Divider as ku,Header as lC}from"@rango-dev/ui";import Te,{useEffect as ts,useRef as Tu,useState as pC}from"react";import{useRef as Ky}from"react";function Ir(){return window.self!==window.top}i(Ir,"isAppLoadedIntoIframe");function Ma(){let t=Ky(null),{iframe:e}=y(),o=Ir()&&e.clientUrl,n=i(s=>{o&&window.top?.postMessage(s,e.clientUrl)},"send");return{send:n,connectHeightObserver:i(s=>{t.current=new ResizeObserver(l=>{for(let p of l)n({type:"widget_height",data:{height:p.contentRect.height}})}),t.current.observe(s)},"connectHeightObserver"),disconnectHeightObserver:i(()=>{t.current&&(t.current.disconnect(),t.current=null)},"disconnectHeightObserver")}}i(Ma,"useIframe");import{useNavigate as jy}from"react-router-dom";function Ye(){let t=jy();return()=>t(-1)}i(Ye,"useNavigateBack");import{createTheme as Fa,darkTheme as lS,lightTheme as pS}from"@rango-dev/ui";import{useEffect as cS,useState as uS}from"react";import{theme as aS,darkColors as sS}from"@rango-dev/ui";import _a from"react";function Xy(t){return t.startsWith("#")&&(t=t.slice(1)),t.length===3?`#${t.split("").reduce(function(n,r){return n+r+r},"")}`:`#${t}`}i(Xy,"expandShortHexColor");function Yy(t){return/[0-9]+$/.test(t)}i(Yy,"isOverridingColor");function Zy(t,e){return t.padStart(e,"0")}i(Zy,"pad");function Ba(t){let e=Math.min(Math.max(Math.round(t),0),255);return Zy(e.toString(16),2)}i(Ba,"intToHex");function Jy(t){return`#${Ba(t.red)}${Ba(t.green)}${Ba(t.blue)}`}i(Jy,"rgbToHex");function Ry(t){let e=parseInt(t.slice(1,3),16),o=parseInt(t.slice(3,5),16),n=parseInt(t.slice(5,7),16);return{red:e,green:o,blue:n}}i(Ry,"hexToRGB");function eS(t,e){let o=1-.11*e;return{red:t.red*o,green:t.green*o,blue:t.blue*o}}i(eS,"generateShade");function tS(t,e){let o=.11*e;return{red:t.red+(255-t.red)*o,green:t.green+(255-t.green)*o,blue:t.blue+(255-t.blue)*o}}i(tS,"generateTint");function oS(t){return Vc(t,eS)}i(oS,"calculateShades");function nS(t){return Vc(t,tS)}i(nS,"calculateTints");function Vc(t,e){let o=Ry(t),n=[];for(let r=1;r<9;r++)n.push(Jy(e(o,r)));return n}i(Vc,"calculateColors");function La(t,e,o){let a=nS(t).reverse().concat(t),s=oS(t),l=a.concat(s),p={},u=l.length;for(let c=0;c<u;c++){let m=100+(o?u-1-c:c)*50;p[`${e}${m}`]=l[c]}return p}i(La,"createTintsAndShades");function Pa(t,e,o){let n={...t};for(let r in e){let a=e[r],s=r==="neutral"&&!!o?.reverseNeutralRange;if(!["background","foreground"].includes(r)&&!Yy(r)){let p=Xy(a);Object.assign(n,La(p,r,s))}}return{...n,...e}}i(Pa,"expandToGenerateThemeColors");var Kc=i(t=>String.fromCharCode(t+(t>25?39:97)),"toAlphabeticChar"),rS=i(t=>{let e="",o;for(o=Math.abs(t);o>52;o=o/52|0)e=Kc(o%52)+e;return Kc(o%52)+e},"toAlphabeticName"),iS=i((t,e)=>{let o=e.length;for(;o;)t=t*33^e.charCodeAt(--o);return t},"toPhash"),Da=i(t=>rS(iS(5381,JSON.stringify(t))>>>0),"toHash");function $a(t){let e=aS.colors,o={...e,...sS},n,r;if(t?.light){let s={colors:Pa(e,t.light)};n={id:`${na}-light-${Da(s)}`,tokens:s}}if(t?.dark){let s={colors:Pa(o,t.dark,{reverseNeutralRange:!0})};r={id:`${na}-dark-${Da(s)}`,tokens:s}}return{light:n,dark:r}}i($a,"customizedThemeTokens");function jc(t,e){if(t.length<=1)return t.map(({element:n,key:r})=>_a.cloneElement(n,{key:r}));let o=[];return t.forEach((n,r)=>{let{element:a,key:s}=n;if(o.push(_a.cloneElement(a,{key:s})),r<t.length-1){let l=`divider-${r}`;o.push(_a.cloneElement(e,{key:l}))}}),o}i(jc,"joinList");function Xc(){return window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches}i(Xc,"doesWindowPreferDarkColorScheme");function $o(t){let{colors:e,fontFamily:o=sp,borderRadius:n=Pp,secondaryBorderRadius:r=Dp}=t,[a,s]=uS(Xc()?"dark":"light"),{theme:l}=y(),{dark:p,light:u}=$a(e),c=Fa({shadows:t.shadows||{},radii:{primary:`${n}px`,secondary:`${r}px`},fonts:{widget:o}}),m=[c.className,pS.className],g=[c.className,lS.className];if(u){let f=Fa(u.id,u.tokens);m.push(f.className)}if(p){let f=Fa(p.id,p.tokens);g.push(f.className)}return cS(()=>{let f=i(h=>{h.matches?s("dark"):s("light")},"switchThemeListener");return Xc()&&s("dark"),window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",f),()=>{window.matchMedia("(prefers-color-scheme: dark)").removeEventListener("change",f)}},[]),{activeTheme:i(()=>{let f=m.join(" "),h=g.join(" ");return l==="auto"?a==="dark"?h:f:l==="dark"?h:f},"getActiveTheme"),mode:l==="auto"?a:l}}i($o,"useTheme");var mt=i(t=>{let e=[];return t?.getAll().forEach((o,n)=>{let r=o.list.getStorage();r?.swapDetails&&e.push({id:n,swap:r?.swapDetails})}),e.sort((o,n)=>Number(n.swap.creationTime)-Number(o.swap.creationTime))},"getPendingSwaps");import{i18n as Yc}from"@lingui/core";import{Alert as mS,Button as dS}from"@rango-dev/ui";import Zc from"react";function Oa(t){return Zc.createElement(mS,{action:Zc.createElement(dS,{onClick:t.onActivateTab,variant:"contained",size:"xxsmall",type:"warning"},Yc.t("Activate this tab")),type:"warning",variant:"alarm",title:Yc.t("Another tab is open and handles transactions.")})}i(Oa,"ActivateTabAlert");import{i18n as Ua}from"@lingui/core";import{Button as fS,Divider as gS,MessageBox as hS}from"@rango-dev/ui";import Ar from"react";function za(t){let{open:e,onClose:o,onConfirm:n}=t;return Ar.createElement(J,{open:e,dismissible:!0,onClose:o,container:A()},Ar.createElement(hS,{title:Ua.t("Activate current tab"),type:"warning",description:Ua.t("Currently, some transactions are running and being handled by other browser tab. If you activate this tab, all transactions that are already in the transaction sign step will expire.")},Ar.createElement(gS,{size:20}),Ar.createElement(fS,{variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:n},Ua.t("Confirm"))))}i(za,"ActivateTabModal");import{ChevronLeftIcon as CS}from"@rango-dev/ui";import ru from"react";import{css as yS,darkTheme as Jc,IconButton as SS,styled as mo}from"@rango-dev/ui";var It=mo(SS,{width:"$24",position:"relative",padding:"0",overflow:"unset","&:hover":{backgroundColor:"$secondary100",[`.${Jc} &`]:{backgroundColor:"$neutral"}}}),Rc=mo("div",{position:"absolute",background:"$secondary500",[`.${Jc} &`]:{$$color:"$colors$secondary250"},width:"$6",height:"$6",borderRadius:"$lg",right:"$4",border:"1px solid $surface100"}),Kt=mo("div",{display:"flex",justifyContent:"flex-end",minWidth:"$40",button:{padding:0}}),eu=mo("div",{position:"absolute",width:"14px",height:"14px",display:"flex",justifyContent:"center",alignItems:"center",borderRadius:"7px",top:"$0",right:"$0",variants:{isSever:{true:{backgroundColor:"$error500"},false:{backgroundColor:"$secondary500"}}}}),tu=mo("div",{padding:"$2",variants:{isRefetched:{true:{transform:"rotate(360deg)",transition:"transform 1s ease-in-out"}}}}),ou=mo("div",{position:"absolute",right:"$4",top:"$4",backgroundColor:"$background",borderRadius:"100%"}),nu=yS({display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center"}),Nr=mo("div",{borderRadius:"100%",border:"1.5px transparent solid","&:not(:first-child)":{marginLeft:"-$6"},img:{borderRadius:"100%"}});function Qa(t){return ru.createElement(It,{variant:"ghost",size:"small",onClick:t.onClick},ru.createElement(CS,{color:"black",size:16}))}i(Qa,"BackButton");import{i18n as kS}from"@lingui/core";import{Button as TS,Typography as vS}from"@rango-dev/ui";import qa from"react";function Ha(t){return qa.createElement(Kt,null,qa.createElement(TS,{variant:"ghost",onClick:t.onClick,size:"xsmall"},qa.createElement(vS,{variant:"label",size:"medium",color:"error500"},kS.t("Cancel"))))}i(Ha,"CancelButton");import{i18n as BS}from"@lingui/core";import{Image as LS,Tooltip as PS,WalletIcon as DS}from"@rango-dev/ui";import fo from"react";import{WalletState as Ka}from"@rango-dev/ui";import{useWallets as ES}from"@rango-dev/wallets-react";import{detectMobileScreens as IS,KEPLR_COMPATIBLE_WALLETS as AS,WalletTypes as Fo}from"@rango-dev/wallets-shared";import{useCallback as NS,useEffect as WS}from"react";import{WalletState as xS}from"@rango-dev/ui";import{useWallets as wS}from"@rango-dev/wallets-react";import{useReducer as bS}from"react";function iu(t){return!!t.derivationPath}i(iu,"isStateOnDerivationPathStep");function au(t){return!!t.namespace}i(au,"isStateOnNamespace");var Ga={status:"init",namespace:null,derivationPath:null};function su(t,e){switch(e.type){case"needsNamespace":return{...t,status:"namespace",namespace:e.payload,derivationPath:null};case"needsDerivationPath":return{...t,status:"derivationPath",derivationPath:e.payload};case"reset":return Ga;case"resetDerivation":return{...t,derivationPath:null,status:"namespace"};default:throw new Error("Action hasn't been defined.")}}i(su,"reducer");function jt(){let{state:t,disconnect:e,connect:o}=wS(),[n,r]=bS(su,Ga),a=i(async(c,m,g)=>{r({type:"reset"});try{return await o(c,void 0,m),{status:"connected"}}catch(d){let f=d?.message?`Error: ${d.message}`:"An unknown error happened during connecting wallet.";throw new Error(f,{cause:d})}},"runConnect"),s=i(async(c,m)=>{if(c.state===xS.DISCONNECTED){if(!c.namespaces)return await a(c.type,void 0,m);let d=c.namespaces.length>1,f=c.needsDerivationPath;return d?(r({type:"needsNamespace",payload:{providerType:c.type,providerImage:c.image,availableNamespaces:c.namespaces,singleNamespace:c.singleNamespace}}),{status:"namespace"}):f?(r({type:"needsDerivationPath",payload:{providerType:c.type,providerImage:c.image,namespace:c.namespaces[0]}}),{status:"derivation-path"}):await a(c.type,c.namespaces.map(h=>({namespace:h})),m)}return m?.disconnectIfConnected?(await u(c.type),{status:"disconnected"}):{status:"disconnected-unhandled"}},"handleConnect"),l=i(async(c,m)=>{let g=c.singleNamespace,d=c.needsDerivationPath,f=m[0];if(!f)throw new Error("To confirm a namespace, you should select at least one namespace.");if(g&&d)return r({type:"needsDerivationPath",payload:{providerType:c.type,providerImage:c.image,namespace:f}}),{status:"derivation-path"};if(!au(n))throw new Error("Something went wrong on handling namespace. Please retry.");let h=n.namespace.providerType,S=m.map(C=>({namespace:C}));return await a(h,S)},"handleNamespace"),p=i(async c=>{if(!c)throw new Error("Derivation path is empty. Please make sure you've filled the field correctly.");if(!iu(n))throw new Error("It seems you are filling derivation path without setting namespace before doing that. Please retry to connect.");let m=n.derivationPath.providerType,d=[{namespace:n.derivationPath.namespace,derivationPath:c}];return await a(m,d)},"handleDerivationPath"),u=i(async c=>t(c).connected?(await e(c),{status:"disconnected"}):{status:"noop"},"handleDisconnect");return{handleConnect:s,handleDisconnect:u,handleNamespace:l,handleDerivationPath:p,getState:()=>n,resetState:c=>{r(c==="derivation"?{type:"resetDerivation"}:{type:"reset"})}}}i(jt,"useStatefulConnect");var MS=Object.values(Fo);function ht(t){let{chain:e}=t||{},{config:o}=y(),{state:n,getWalletInfo:r}=ES(),{connectedWallets:a}=Z(),s=y().blockchains(),{handleDisconnect:l}=jt(),p=Fp(o?.wallets,{trezorManifest:o?.trezorManifest,walletConnectProjectId:o?.walletConnectProjectId,walletConnectListedDesktopWalletLink:o.__UNSTABLE_OR_INTERNAL__?.walletConnectListedDesktopWalletLink})||MS,u=Tp(n,r,p,e);u=IS()?u.filter(h=>h.showOnMobile!==!1&&n(h.type).installed):u;let c=Ip(u),m=i(h=>!a.find(S=>S.walletType===h&&S.chain===e),"isExperimentalChainNotAdded"),g=NS(()=>{let h=u?.filter(S=>S.state===Ka.CONNECTING)||[];for(let S of h)l(S.type)},[Wp(u)]);WS(()=>()=>{g()},[]);let d=i(h=>{let S=h.find(k=>k.type===Fo.DEFAULT);return!S||S.state===Ka.NOT_INSTALLED?!1:h.filter(k=>k.state!=Ka.NOT_INSTALLED&&![Fo.DEFAULT,Fo.WALLET_CONNECT_2,Fo.LEDGER].includes(k.type)&&r(k.type).supportedChains.filter(T=>T.type=="EVM").length>0).length==0},"shouldShowDefaultInjectedWallet"),f=i((h,S,C)=>ar(C,S)&&m(h)&&!AS.includes(h)||h==Fo.DEFAULT&&!d(u),"shouldExcludeWallet");return{list:c.filter(h=>!f(h.type,e??"",s)),terminateConnectingWallets:g}}i(ht,"useWalletList");function ja(t){let{list:e}=ht(),o=e.filter(r=>r.state==="connected"),n=o.length?fo.createElement("div",{className:nu()},o.map(r=>fo.createElement(Nr,{key:r.title},fo.createElement(LS,{src:r.image,size:14})))):BS.t("Connect Wallet");return fo.createElement(PS,{container:t.container,side:"bottom",content:n},fo.createElement(It,{variant:"ghost",size:"small",onClick:t.onClick},t.isConnected&&fo.createElement(Rc,null),fo.createElement(DS,{size:18,color:"black"})))}i(ja,"WalletButton");import{i18n as Mr}from"@lingui/core";import{NotificationsIcon as ZS,Popover as JS,SettingsIcon as RS,Tooltip as Br,TransactionIcon as eC}from"@rango-dev/ui";import Be from"react";import{Notifications as OS}from"@rango-dev/ui";import US from"react";import{useNavigate as zS}from"react-router-dom";import{create as _S}from"zustand";import{persist as $S,subscribeWithSelector as FS}from"zustand/middleware";var we=Ht(_S()($S(FS((t,e)=>({isSynced:!1,notifications:[],setNotification:(o,n)=>{let r=n.steps[0],a=n.steps[n.steps.length-1],s={event:o,creationTime:Date.now(),requestId:n.requestId,route:{creationTime:parseInt(n.creationTime),from:{blockchain:r.fromBlockchain,address:r.fromSymbolAddress,symbol:r.fromSymbol},to:{blockchain:a.toBlockchain,address:a.toSymbolAddress,symbol:a.toSymbol}}},l=e().notifications.filter(p=>p.requestId!==n.requestId);t(()=>({notifications:[...l,s]}))},removeNotification:o=>{t(n=>({notifications:n.notifications.filter(r=>r.requestId!==o)}))},getNotifications:()=>{let{isSynced:o,notifications:n}=e();return o?n.sort((r,a)=>r.route.creationTime&&!a.route.creationTime?-1:!r.route.creationTime&&a.route.creationTime?1:!r.route.creationTime&&!a.route.creationTime?a.creationTime-r.creationTime:a.route.creationTime-r.route.creationTime):[]},syncNotifications:o=>{let{isSynced:n,notifications:r}=e();if(!n){let a=[];r.forEach(s=>{o.some(p=>p.swap.requestId===s.requestId)&&a.push(s)}),t({isSynced:!0,notifications:a})}},clearNotifications:()=>t({notifications:[]})})),{name:"notification",skipHydration:!0,partialize:({isSynced:t,...e})=>e,version:1,migrate:(t,e)=>{if(e===0){let o=t.notifications;t.notifications=o.filter(n=>!n.read).map(({read:n,...r})=>r)}return t}})));function Xa(){let t=zS(),{getNotifications:e,clearNotifications:o}=we(),n=e(),r=y().blockchains(),{findToken:a}=y();return US.createElement(OS,{list:n,getBlockchainImage:l=>Sp(l,r)??"",getTokenImage:l=>a(l)?.image??"",onClickItem:i(l=>{t(`${D.swaps}/${l}`)},"onClickItem"),onClearAll:o})}i(Xa,"NotificationContent");import{useManager as QS}from"@rango-dev/queue-manager-react";import{InProgressIcon as qS}from"@rango-dev/ui";import lu from"react";var HS=i(()=>{let{manager:t}=QS();return mt(t).map(({swap:o})=>o).find(o=>o.status==="running")?lu.createElement(ou,null,lu.createElement(qS,{color:"info",size:6})):null},"InProgressTransactionBadge"),pu=HS;import{EventSeverity as GS}from"@rango-dev/queue-manager-rango-preset";import{Typography as VS}from"@rango-dev/ui";import cu from"react";function uu(){let{getNotifications:t}=we(),e=t(),o=e.length,n=!!e.find(r=>r.event.messageSeverity===GS.WARNING);return o?cu.createElement(eu,{isSever:n},cu.createElement(VS,{variant:"body",size:"xsmall",color:"$background"},o)):null}i(uu,"NotificationsBadge");import{RefreshProgressButton as KS}from"@rango-dev/ui";import Ya,{useEffect as jS,useState as mu}from"react";var XS=1e3,du=60,YS=100;function Wr({onClick:t}){let[e,o]=mu(0),[n,r]=mu(!1),a=i(p=>{document.hidden&&p&&s(p)},"handleVisibilityChange");jS(()=>{let p;return t?p=window.setInterval(()=>{o(u=>u+1),e===du&&l()},XS):s(p),document.addEventListener("visibilitychange",()=>a(p)),()=>{document.removeEventListener("visibilitychange",()=>a(p)),p&&clearInterval(p)}},[e,t]);let s=i(p=>{p&&clearInterval(p),o(0)},"clearTimeout"),l=i(()=>{t?.(),o(0),r(!0)},"handleRefreshClick");return Ya.createElement(It,{variant:"ghost",size:"small",style:{paddingTop:0,paddingBottom:0},onClick:l,disabled:!t},Ya.createElement(tu,{onTransitionEnd:()=>r(!1),isRefetched:n},Ya.createElement(KS,{size:22,color:t?"black":"gray",progress:e/du*YS})))}i(Wr,"RefreshButton");function go(t){let{onClickRefresh:e,onClickHistory:o,onClickSettings:n,hidden:r=[],container:a}=t,{config:{features:s}}=y(),l=je("notification",s)||r.includes("notifications");return Be.createElement(Be.Fragment,null,!r.includes("refresh")&&Be.createElement(Br,{container:a||A(),side:"top",content:Mr.t("Refresh")},Be.createElement(Wr,{onClick:e})),!l&&Be.createElement(JS,{align:"end",alignOffset:-88,sideOffset:15,collisionPadding:{right:20,left:20},container:A(),content:Be.createElement(Xa,null)},Be.createElement("div",null,Be.createElement(Br,{container:A(),side:"top",content:Mr.t("Notifications")},Be.createElement(It,{size:"small",variant:"ghost"},Be.createElement(ZS,{size:18,color:"black"}),Be.createElement(uu,null))))),!r.includes("settings")&&Be.createElement(Br,{container:A(),side:"top",content:Mr.t("Settings")},Be.createElement(It,{size:"small",variant:"ghost",onClick:n},Be.createElement(RS,{size:18,color:"black"}))),!r.includes("history")&&Be.createElement(Br,{container:A(),side:"top",content:Mr.t("Transactions History")},Be.createElement(It,{size:"small",variant:"ghost",onClick:o},Be.createElement(eC,{size:18,color:"black"}),Be.createElement(pu,null))))}i(go,"HeaderButtons");import{i18n as Za}from"@lingui/core";import{Divider as gu,MessageBox as nC,RefreshIcon as rC}from"@rango-dev/ui";import Oo from"react";import{Button as tC,styled as oC}from"@rango-dev/ui";var fu=oC(tC,{"& span":{display:"flex",justifyContent:"center",alignItems:"center"}});function Ja(t){let{open:e,onClose:o}=t;return Oo.createElement(J,{open:e,dismissible:!0,onClose:o,container:A()},Oo.createElement(nC,{title:Za.t("Something went wrong"),type:"error",description:Za.t("Something went wrong. Please refresh the app.")},Oo.createElement(gu,{size:30}),Oo.createElement(fu,{variant:"outlined",size:"large",type:"primary",fullWidth:!0,onClick:()=>location.reload()},Oo.createElement(rC,{size:20,color:"primary"}),Oo.createElement(gu,{size:4,direction:"horizontal"}),Za.t("Refresh"))))}i(Ja,"RefreshModal");function Ra(t){let e=t.target;if(e){let o=e.scrollTop,n=A();o>1?n.classList.add("rng-scrolled"):n.classList.remove("rng-scrolled")}}i(Ra,"onScrollContentAttachStatusToContainer");import{css as iC,styled as es}from"@rango-dev/ui";var hu="700px",Lr=iC({borderRadius:"$primary",display:"flex",flexDirection:"column",overflow:"hidden",boxShadow:"$mainContainer"}),yu=es("div",{position:"relative",width:"100vw",minWidth:"300px",maxWidth:"390px",backgroundColor:"$background",variants:{height:{auto:{height:"auto",maxHeight:hu},fixed:{height:hu}}}}),Su=es("div",{position:"relative",overflow:"hidden",flexGrow:1,display:"flex",flexDirection:"column",padding:0,overflowY:"auto"}),Cu=es("div",{padding:"0 $20 $10","& .footer__alert":{paddingTop:"$10"},"& .footer__logo":{opacity:0,transition:"opacity 1s ease-in-out","&.logo__show":{opacity:1},"&.logo__hidden":{visibility:"hidden"}}});function ne(t){let{connectHeightObserver:e,disconnectHeightObserver:o}=Ma(),{children:n,header:r,footer:a,height:s="fixed"}=t,{fetchStatus:l}=y(),[p,u]=pC(!1),c=Z.use.connectedWallets(),{config:{features:m,theme:g}}=y(),{watermark:d}=se(),f=d==="FULL",{activeTheme:h}=$o(g||{}),S=je("connectWalletButton",m),{isActiveTab:C,tabManagerInitiated:k,showActivateTabModal:T,setShowActivateTabModal:v,activateCurrentTab:x}=se(),N=Ye(),{manager:M}=aC(),E=mt(M).map(({swap:ee})=>ee).some(ee=>ee.status==="running"),b=i(()=>x(po.forceClaim,E),"onActivateTab"),W=i(()=>{r.onWallet?.()},"onConnectWallet"),$=typeof r.hasBackButton>"u"||r.hasBackButton,I=Tu(null),R=Tu(null);return ts(()=>(Ir()&&R.current&&e(R.current),()=>{o()}),[]),ts(()=>(I.current?.addEventListener("scroll",Ra),()=>{I.current?.removeEventListener("scroll",Ra)}),[]),ts(()=>{u(l==="failed")},[l]),Te.createElement(yu,{height:s,id:_e.SWAP_BOX_ID,className:`${h()} ${Lr()}`,ref:R},Te.createElement(lC,{prefix:Te.createElement(Te.Fragment,null,$&&Te.createElement(Qa,{onClick:()=>{N(),r.onBack&&r.onBack()}})),title:r.title,suffix:Te.createElement(Te.Fragment,null,r.suffix,r.onWallet&&!S&&Te.createElement(ja,{container:A(),onClick:W,isConnected:!!c?.length}),r.onCancel&&Te.createElement(Ha,{onClick:r.onCancel}))}),Te.createElement(Su,{ref:I},n),Te.createElement(za,{open:T,onClose:()=>v(!1),onConfirm:b}),Te.createElement(Cu,null,Te.createElement("div",{className:"footer__content"},k&&!C&&Te.createElement("div",{className:"footer__alert"},Te.createElement(Oa,{onActivateTab:b}),Te.createElement(ku,{size:10})),a),Te.createElement(ku,{size:12}),Te.createElement("div",{className:`footer__logo ${f?"logo__show":"logo__hidden"}`},Te.createElement(sC,null))),Te.createElement(Ja,{open:p,onClose:()=>u(!1)}))}i(ne,"Layout");import{styled as cC}from"@rango-dev/ui";var vu="$20 $20 $10 $20",fn=cC("div",{padding:vu,overflowY:"auto",flexGrow:1});import{styled as uC}from"@rango-dev/ui";var ie=uC("div",{display:"flex",flexDirection:"column",padding:"20px 20px 10px",flexGrow:1,variants:{view:{true:{flexGrow:1,overflow:"hidden"}},compact:{true:{padding:0}}}});import{i18n as Uo}from"@lingui/core";import{useState as xu}from"react";function wu(){let[t,e]=xu(!1),[o,n]=xu(void 0),{findToken:r}=y(),a=y().customTokens();function s(p,u){switch(p){case"duplicated":return{title:Uo.t("Duplicate Token"),message:Uo.t("The address you entered is duplicate, please enter a new address.")};case"token-exist":return{title:Uo.t("Token Already Exists"),message:Uo.t("There's no need to add this token again because it already exists and is supported by us.")};case"not-found":return{title:Uo.t("Token Not Found"),message:Uo.t(`Sorry, no token was found on ${u} blockchain with the provided address. please make sure you have entered the right token address.`)}}}return i(s,"produceErrorMessage"),{fetchCustomToken:i(async({blockchain:p,tokenAddress:u})=>{e(!0);try{if(a.some(h=>h.address?.toLowerCase()===u.toLowerCase())){let h=s("duplicated");n(h);return}let m=await fetch(`${ct("BASE_URL")}/meta/token?apiKey=${ct("API_KEY")}&blockchain=${p}&address=${u}`),g=m.headers.get("content-type"),d=g&&g.includes("application/json")&&await m.json();if(!d||d.error){let h=s("not-found",p);n(h);return}if(r({blockchain:d.blockchain,address:d.address,symbol:d.symbol})){let h=s("token-exist");n(h);return}return d}catch(c){throw n(void 0),new Error(c.message)}finally{e(!1)}},"fetchCustomToken"),loading:t,error:o}}i(wu,"useFetchCustomToken");var vC=hC("div",{display:"flex",justifyContent:"space-between",flexDirection:"column",flex:1,"& ._text-field":{padding:"$4 $10",backgroundColor:"$neutral300",[`.${dC} &`]:{backgroundColor:"$neutral400"},borderRadius:"$sm",height:"$40"}}),xC=1e3;function Eu(){let t=kC(),[e]=TC(),o=Ye(),{setCustomToken:n}=y(),r=y().blockchains(),a=e.get("blockchain")||"",s=rn(a,r),[l,p]=Pr(""),[u,c]=Pr(!1),[m,g]=Pr(),{fetchCustomToken:d,loading:f,error:h}=wu(),[S,C]=Pr(""),k=!!s&&No(s,l),T=!s||!l||!k,v=i(async()=>{if(s)try{let M=await d({blockchain:a,tokenAddress:l});C(""),M&&g(M)}catch(M){M.message==="Failed to fetch"&&(C(At.t("Network Error")),c(!0))}},"getCustomToken"),x=i(()=>{h&&p(""),c(!1)},"closeErrorModal"),N=i(async()=>{S&&setTimeout(async()=>{await v()},xC),x()},"handleErrorModalButtonClick");return CC(()=>{h&&c(!0)},[h]),Se.createElement(ne,{header:{title:At.t("Add Custom Token")}},Se.createElement(ie,null,Se.createElement(vC,null,Se.createElement("div",null,Se.createElement(Ia,{onClick:()=>t(D.blockchains,{replace:!0}),hasLogo:!!s?.logo,value:s?{name:s.displayName,logo:s.logo}:void 0,title:At.t("Select chain"),placeholder:At.t("Select chain")}),Se.createElement(gn,{size:"24"}),Se.createElement(SC,{size:"large",variant:"label"},At.t("Enter Address")),Se.createElement(gn,{size:10}),Se.createElement(yC,{fullWidth:!0,disabled:!s,variant:"contained",placeholder:At.t("Enter token address"),size:"large",value:l,suffix:!!l&&k&&Se.createElement(fC,{color:"success",size:12}),onChange:M=>p(M.target.value)}),!k&&!!l&&Se.createElement(Se.Fragment,null,Se.createElement(gn,{size:4}),Se.createElement(mC,{type:"error",variant:"alarm",title:"Invalid Address"}))),Se.createElement(bu,{disabled:T,type:"primary",variant:"contained",loading:f,size:"large",onClick:v},At.t("Import"))),Se.createElement(J,{open:u,dismissible:!0,onClose:x,container:A()},Se.createElement(gC,{title:h?.title||S,type:"error",description:h?.message||At.t("Failed Network, Please retry.")},Se.createElement(gn,{size:40}),Se.createElement(gn,{size:10}),Se.createElement(bu,{variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:N},S?At.t("Retry"):At.t("Add another custom token")))),s&&m&&Se.createElement(Wa,{blockchain:s,token:m,onSubmitClick:()=>{m&&(n(m),g(void 0),o())},onClose:()=>g(void 0),open:!!s&&!!m})))}i(Eu,"AddCustomTokenPage");import{i18n as zs}from"@lingui/core";import{useManager as _T}from"@rango-dev/queue-manager-react";import{Alert as Pd,Button as $T,css as qs,Divider as Qs,IconButton as Dd,styled as FT,Typography as OT,WalletIcon as UT}from"@rango-dev/ui";import Ae,{useEffect as di,useLayoutEffect as zT,useRef as QT,useState as An}from"react";import{useNavigate as qT}from"react-router-dom";import{i18n as Co}from"@lingui/core";import{Alert as mm,BalanceErrors as bk,Button as dm,ChevronLeftIcon as Ek,Divider as Vr,MessageBox as Ik,Typography as ks}from"@rango-dev/ui";import j,{useCallback as Ak,useEffect as fm,useMemo as Nk,useState as ko}from"react";import{useNavigate as Wk}from"react-router-dom";import{i18n as Dr}from"@lingui/core";function _r(t){switch(t.type){case 0:return Dr.t("Route has been updated.");case 3:return Dr.t("Output amount changed to {newOutputAmount} ({percentageChange}% change).",{newOutputAmount:t.newOutputAmount,percentageChange:t.percentageChange});case 1:return Dr.t("Route swappers has been updated.");case 2:return Dr.t("Route internal coins has been updated.");default:return""}}i(_r,"getQuoteUpdateWarningMessage");import{i18n as is}from"@lingui/core";import{Alert as NC,ChevronDownIcon as WC,CloseIcon as MC,Divider as Lu,IconButton as Pu,PasteIcon as BC,Typography as LC,WalletIcon as PC}from"@rango-dev/ui";import Le,{useEffect as DC,useRef as _C}from"react";import Ur,{useRef as IC}from"react";import*as zo from"@radix-ui/react-collapsible";import{keyframes as Iu,styled as $r}from"@rango-dev/ui";var os=300,bC=Iu({from:{height:0},to:{height:"var(--radix-collapsible-content-height)"}}),EC=Iu({from:{height:"var(--radix-collapsible-content-height)"},to:{height:0}}),Au=$r(zo.Root,{borderRadius:"$sm",overflow:"hidden",variants:{selected:{true:{outlineWidth:1,outlineColor:"$secondary500",outlineStyle:"solid"}}}}),ns=$r(zo.Trigger,{padding:"$0",border:"none",outline:"none",width:"100%",backgroundColor:"transparent",fontFamily:"inherit",cursor:"pointer"}),Fr=$r(zo.Content,{overflow:"hidden",variants:{open:{true:{animation:`${bC} ${os}ms ease-out`},false:{animation:`${EC} ${os}ms ease-out`}}}}),Or=$r("div",{transition:`all ${os}ms ease`,display:"flex",alignItems:"center",variants:{orientation:{down:{transform:"rotate(0)"},up:{transform:"rotate(180deg)"}}}});function zr(t){let{open:e,hasSelected:o,onOpenChange:n,children:r,onClickTrigger:a,trigger:s,triggerAnchor:l}=t,p=IC(null);return Ur.createElement(Au,{ref:p,className:"collapsible_root",selected:o&&e,open:e,onOpenChange:n},l==="top"&&Ur.createElement(ns,{className:"collapsible_trigger",onClick:a},s),Ur.createElement(Fr,{className:"collapsible_content",open:e},r),l==="bottom"&&Ur.createElement(ns,{className:"collapsible_trigger",onClick:a},s))}i(zr,"CustomCollapsible");import{darkTheme as Nu,styled as rs,TextField as AC}from"@rango-dev/ui";var Wu=rs("div",{padding:"$10 $0","& .button__content":{display:"flex",alignItems:"center"},"& .alarms":{paddingTop:"$5"},"& .collapsible_content":{backgroundColor:"$neutral100"},"& .collapsible_root":{backgroundColor:"$neutral100"}}),Mu=rs(AC,{backgroundColor:"$neutral100",padding:"$15"}),Bu=rs("div",{width:"100%",borderRadius:"$sm",display:"flex",padding:"$15",justifyContent:"space-between",alignItems:"center",$$color:"$colors$neutral100",[`.${Nu} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",borderBottomRightRadius:"0",borderBottomLeftRadius:"0","&:focus-visible":{$$background:"$colors$secondary100",[`.${Nu} &`]:{$$background:"$colors$info700"},backgroundColor:"$$background",outline:0}});function Du(t){let{blockchain:e,handleOpenChange:o,open:n}=t,{customDestination:r,setCustomDestination:a}=z(),{config:s}=y(),l=y().blockchains(),p=er(e.name,l),u=_C(null),c=s?.defaultCustomDestinations?.[e.name],m=navigator?.userAgent.includes("Firefox"),d=n&&!!r&&e&&!No(e,r),f=i(()=>{a("")},"handleClear"),h=i(async C=>{if(C.preventDefault(),navigator.clipboard!==void 0){let k=await navigator.clipboard.readText();a(k),u?.current?.focus()}},"handlePaste"),S=i(()=>r?Le.createElement(Pu,{onClick:f,variant:"ghost"},Le.createElement(MC,{size:12,color:"gray"})):m?null:Le.createElement(Pu,{onClick:h,variant:"ghost"},Le.createElement(BC,{size:16})),"renderSuffix");return DC(()=>{!!c&&r===null&&(a(c),o(!0))},[c]),Le.createElement(Wu,null,Le.createElement(zr,{onOpenChange:o,hasSelected:!0,open:n,triggerAnchor:"top",trigger:Le.createElement(Bu,null,Le.createElement("div",{className:"button__content"},Le.createElement(PC,{size:18,color:"info"}),Le.createElement(Lu,{size:4,direction:"horizontal"}),Le.createElement(LC,{variant:"label",size:"medium",color:n?"$neutral600":void 0},is.t("Send to a different address"))),Le.createElement(Or,{orientation:n?"up":"down"},Le.createElement(WC,{size:10,color:"secondary"}))),onClickTrigger:()=>o(!n)},Le.createElement(Mu,{ref:u,style:{padding:0,paddingRight:r?"8px":"5px"},autoFocus:!r,placeholder:is.t("Enter {blockchainName} address",{blockchainName:p}),value:r||"",suffix:S(),onChange:C=>{let k=C.target.value;a(k)}})),d&&Le.createElement(Le.Fragment,null,Le.createElement(Lu,{size:4}),Le.createElement(NC,{variant:"alarm",type:"error",title:is.t({values:{destination:r},id:"Address {destination} doesn't match the blockchain address pattern."})})))}i(Du,"CustomDestination");import{css as $C,darkTheme as as,IconButton as FC,styled as Pt}from"@rango-dev/ui";var _u=Pt("div",{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center"}),$u=Pt("div",{display:"flex",justifyContent:"space-evenly",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5",height:"100%"}),OC=Pt("button",{borderRadius:"$xm",padding:"$10",border:"0",display:"flex",justifyContent:"center",$$color:"$colors$neutral100",[`.${as} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",alignItems:"center",cursor:"pointer",width:110,position:"relative","&:hover":{$$color:"$colors$secondary100",[`.${as} &`]:{$$color:"$colors$neutral100"},backgroundColor:"$$color"},"&:focus-visible":{$$color:"$colors$secondary100",[`.${as} &`]:{$$color:"$colors$info700"},backgroundColor:"$$color",outline:0},variants:{selected:{true:{outlineWidth:1,outlineColor:"$secondary",outlineStyle:"solid"}}}}),Fu=Pt(OC,{alignSelf:"stretch",minHeight:"93px"}),Ou=Pt("div",{padding:"$20 $20 $15 $20",display:"flex",justifyContent:"center",alignItems:"center",backgroundColor:"$neutral200",position:"relative",width:"100%"}),Uu=Pt(FC,{position:"absolute",left:"$20"}),zu=Pt("div",{paddingTop:"$20"}),Qu=$C({display:"flex",justifyContent:"space-evenly",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5",height:"100%"}),qu=Pt("div",{display:"flex"}),Hu=Pt("div",{overflow:"visible",width:"100%"});import{i18n as lm}from"@lingui/core";import{warn as kk}from"@rango-dev/logging-core";import{Divider as Tk,SelectableWallet as vk,Typography as pm,WalletState as cm}from"@rango-dev/ui";import Ze,{useEffect as um,useState as yn}from"react";import{Divider as uk}from"@rango-dev/ui";import yo,{useEffect as mk,useState as nm}from"react";import{i18n as ss}from"@lingui/core";import{Button as qC,Checkbox as HC,Divider as GC,Image as Ku,ListItemButton as VC,MessageBox as KC,Radio as jC,RadioRoot as XC}from"@rango-dev/ui";import{namespaces as ju}from"@rango-dev/wallets-shared";import be,{useMemo as YC,useState as ZC}from"react";import{keyframes as UC,styled as Qr}from"@rango-dev/ui";var MP=Qr("div",{borderRadius:"$lg",width:"$45",height:"$45",backgroundColor:"$success300",display:"flex",justifyContent:"center",alignItems:"center"}),Qo=Qr("div",{position:"relative"}),zC=UC({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}),qo=Qr("div",{position:"absolute",border:"2px solid rgba(0, 0, 0, 0.1)",borderTop:"2px solid $info500",borderRadius:"$lg",width:"$45",height:"$45",animation:`${zC} 1s linear infinite`,top:0,bottom:0,right:0,left:0}),qr=Qr("div",{"& img":{borderRadius:"50%"}});function Gu(t,e){return t.find(o=>o.name===e)?.logo}i(Gu,"getBlockchainLogo");import{styled as QC}from"@rango-dev/ui";var Vu=QC("ul",{padding:0,paddingTop:"$4",paddingBottom:"$4"});function ls(t){let{singleNamespace:e,availableNamespaces:o,providerImage:n}=t.value,[r,a]=ZC([]),s=y().blockchains(),l=YC(()=>o?.map(c=>({name:c,logo:Gu(s,ju[c].mainBlockchain),title:ju[c].title})),[o]),p=i(c=>{a(e?[c]:m=>m.includes(c)?m.filter(g=>g!==c):m.concat(c))},"onSelect"),u=i(c=>e?be.createElement(XC,{value:r?.[0]},c):be.createElement(be.Fragment,null,c),"wrapRadioRoot");return be.createElement(be.Fragment,null,be.createElement(GC,{size:20}),be.createElement(KC,{type:"info",title:ss.t("Select chain types"),description:ss.t("This wallet supports multiple chains. Select which chain you'd like to connect to."),icon:be.createElement(Qo,null,be.createElement(Nr,null,be.createElement(Ku,{src:n,size:45})),be.createElement(qo,null))}),be.createElement(Vu,null,u(be.createElement(be.Fragment,null,l?.map(c=>be.createElement(VC,{key:c.name,id:c.name,title:c.title,hasDivider:!0,style:{height:60},onClick:()=>p(c.name),start:be.createElement(Ku,{src:c.logo,size:22}),end:e?be.createElement(jC,{value:c.name}):be.createElement(HC,{checked:r.includes(c.name)})}))))),be.createElement(qC,{type:"primary",disabled:!r.length,onClick:()=>t.onConfirm(r)},ss.t("Confirm")))}i(ls,"Namespaces");import{i18n as Ho}from"@lingui/core";import{Button as ek,Divider as Zu,Image as tk,MessageBox as ok,Select as nk,TextField as rk}from"@rango-dev/ui";import Qe,{useEffect as ik,useState as Ju}from"react";import{namespaces as JC}from"@rango-dev/wallets-shared";var ps={id:"custom",label:"Custom",generateDerivationPath:t=>t};function cs(t){let e=t?JC[t].derivationPaths:null;return e?[...e,ps]:[]}i(cs,"getDerivationPaths");import{styled as Xu,Typography as RC}from"@rango-dev/ui";var Yu=Xu("div",{paddingTop:"$30",paddingBottom:"$30",zIndex:10}),us=Xu(RC,{paddingLeft:"$10"}),ms={height:"$40",backgroundColor:"$neutral200",borderRadius:"$sm"};function ds(t){let{onConfirm:e}=t,{namespace:o,providerImage:n,providerType:r}=t.value,[a,s]=Ju(null),[l,p]=Ju("0"),u=a===ps.id,c=cs(o),m=i(({value:d})=>{let f=c?.find(h=>h.id===d);f&&s(f.id)},"handleDerivationPathItemClick"),g=i(()=>{let d=c.find(f=>f.id===a);if(d)e(d.generateDerivationPath(l));else throw new Error("selectedDerivationPath can not be undefined")},"handleConfirm");return ik(()=>{s(cs(o)[0]?.id||null)},[o]),Qe.createElement(Qe.Fragment,null,Qe.createElement(Zu,{size:20}),Qe.createElement(ok,{type:"info",title:Ho.t("Select Derivation Path"),description:Ho.t(`In order to connect to ${r}, you must first select a Derivation Path`),icon:Qe.createElement(Qo,null,Qe.createElement(qr,null,Qe.createElement(tk,{src:n,size:45})),Qe.createElement(qo,null))}),Qe.createElement(Yu,null,Qe.createElement(us,{variant:"body",size:"xsmall",color:"$neutral600"},Ho.t("Choose Derivation Path Template")),Qe.createElement(nk,{value:a||"",options:c.map(d=>({value:d.id,label:d.label})),variant:"filled",handleItemClick:m,styles:{trigger:ms}}),Qe.createElement(Zu,{size:20}),Qe.createElement(us,{variant:"body",size:"xsmall",color:"$neutral600"},u?Ho.t("Enter Path"):Ho.t("Enter Index")),Qe.createElement(rk,{type:u?"text":"number",variant:"contained",value:l,onChange:d=>p(d.target.value),style:ms})),Qe.createElement(ek,{type:"primary",onClick:g,disabled:!c||!a||!l},Ho.t("Confirm")))}i(ds,"DerivationPath");import{i18n as Go}from"@lingui/core";import{Image as ak,MessageBox as fs,WalletState as sk}from"@rango-dev/ui";import{useWallets as lk}from"@rango-dev/wallets-react";import ho from"react";function gs(t){let{wallet:e,error:o}=t,{type:n,image:r}=e,{state:a}=lk();return ln(a(n))===sk.CONNECTED?ho.createElement(fs,{type:"success",title:Go.t("Wallet Connected"),description:Go.t("Your wallet is connected, you can use it to swap.")}):o?ho.createElement(fs,{type:"error",title:Go.t("Failed to Connect"),description:o||Go.t("Your wallet is not connected. Please try again.")}):ho.createElement(fs,{type:"loading",title:Go.t("Connecting to your wallet"),description:Go.t("Click connect in your wallet popup."),icon:ho.createElement(Qo,null,ho.createElement(qr,null,ho.createElement(ak,{src:r,size:45})),ho.createElement(qo,null))})}i(gs,"ConnectStatus");import{i18n as hs}from"@lingui/core";import{Button as pk,Divider as Ru,MessageBox as ck}from"@rango-dev/ui";import Hr from"react";function ys(t){let{displayName:e,onConfirm:o}=t;return Hr.createElement(ck,{title:hs.t({id:"Add {blockchainDisplayName} Chain",values:{blockchainDisplayName:e}}),type:"warning",description:hs.t({id:"You should connect a {blockchainDisplayName} supported wallet or choose a different {blockchainDisplayName} address",values:{blockchainDisplayName:e}})},Hr.createElement(Ru,{size:18}),Hr.createElement(Ru,{size:32}),Hr.createElement(pk,{onClick:o,variant:"outlined",type:"primary",fullWidth:!0,size:"large"},hs.t("Confirm")))}i(ys,"ExperimentalChain");function em(t,e){return t().status==="init"&&!!e}i(em,"isOnStatus");function tm(t){return t().status==="namespace"}i(tm,"isOnNamespace");function om(t){return t().status==="derivationPath"}i(om,"isOnDerivationPath");var dk=3e3,fk=300;function So(t){let[e,o]=nm(!1),[n,r]=nm(),a=i(S=>{r(S.message)},"catchErrorOnHandle"),{terminateConnectingWallets:s}=ht(),{handleConnect:l,handleDerivationPath:p,handleNamespace:u,getState:c,resetState:m}=jt(),g=i(S=>{u(t.wallet,S).catch(a)},"handleConfirmNamespaces"),d=i(S=>{if(!S)throw new Error("Derivation path is empty. Please make sure you've filled the field correctly.");p(S).catch(a)},"handleDerivationPathConfirm"),f=i(()=>{o(!1)},"handleClosingModal"),h=i(()=>{r(void 0),m(),o(!1)},"resetModalState");return mk(()=>{if(t.wallet){h();let S=!1,C=!0,k=i(()=>{setTimeout(()=>{C=!1,S||o(!0)},fk)},"beforeConnecting"),T=i(v=>{let x=v.status==="connected",N=["disconnected","disconnected-unhandled"].includes(v.status);["namespace","derivation-path"].includes(v.status)||(S=!0),x&&!C?setTimeout(f,dk):N&&f(),t.onConnect&&t.onConnect(v)},"afterConnected");k(),l(t.wallet,{disconnectIfConnected:!0}).then(T).catch(a)}},[t.wallet]),yo.createElement(J,{open:e,onClose:f,onExit:()=>{h(),s(),t.onClose&&t.onClose()},container:A()},em(c,t.wallet)&&yo.createElement(yo.Fragment,null,yo.createElement(gs,{wallet:{type:t.wallet.type,image:t.wallet.image},error:n}),yo.createElement(uk,{direction:"vertical",size:32})),tm(c)&&yo.createElement(ls,{onConfirm:g,value:c().namespace}),om(c)&&yo.createElement(ds,{onConfirm:d,value:c().derivationPath}))}i(So,"StatefulConnectModal");import{Image as yk,MessageBox as Sk,Spinner as Ck}from"@rango-dev/ui";import hn from"react";import{keyframes as gk,styled as Ss}from"@rango-dev/ui";var rm=Ss("div",{position:"relative"}),hk=gk({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}),UD=Ss("div",{position:"absolute",border:"2px solid rgba(0, 0, 0, 0.1)",borderTop:"2px solid $info500",borderRadius:"$lg",width:"$45",height:"$45",animation:`${hk} 1s linear infinite`,top:0,bottom:0,right:0,left:0}),im=Ss("div",{"& img":{borderRadius:"50%"}});import{i18n as Vo}from"@lingui/core";function am(t,e){switch(t){case"in-progress":return{type:"loading",title:Vo.t({id:"Add {blockchainDisplayName} Chain",values:{blockchainDisplayName:e}}),description:Vo.t({id:"You should connect a {blockchainDisplayName} supported wallet or choose a different {blockchainDisplayName} address",values:{blockchainDisplayName:e}})};case"completed":return{type:"success",title:Vo.t({id:"{blockchainDisplayName} Chain Added",values:{blockchainDisplayName:e}}),description:Vo.t({id:"You should connect a {blockchainDisplayName} supported wallet or choose a different {blockchainDisplayName} address",values:{blockchainDisplayName:e}})};case"rejected":return{type:"error",title:Vo.t("Request Rejected"),description:Vo.t({id:"You've rejected adding {blockchainDisplayName} chain to your wallet.",values:{blockchainDisplayName:e}})};default:throw new Error(`Showing information about an experimentation chain status needs to be defined first. status: ${t}`)}}i(am,"generateMessageByStatus");function sm(t){let{status:e,displayName:o,image:n}=t,r=am(e,o),a=e=="in-progress";return hn.createElement(Sk,{type:r.type,title:r.title,description:r.description,icon:a?hn.createElement(rm,null,hn.createElement(im,null,hn.createElement(yk,{src:n,size:45})),hn.createElement(Ck,null)):void 0})}i(sm,"ExperimentalChainStatus");var xk=7,wk=3e3;function Cs(t){let{chain:e,isSelected:o,selectWallet:n,limit:r,onShowMore:a}=t,s=se.use.isActiveTab(),l=Z.use.connectedWallets(),{blockchains:p}=y(),[u,c]=yn(),[m,g]=yn(null),[d,f]=yn(!1),[h,S]=yn(null),{suggestAndConnect:C}=Gr(),{handleDisconnect:k}=jt(),{list:T}=ht({chain:e}),[v,x]=yn(T),N=T.length,M=r&&N-r>0,w=i(async b=>{f(!1),S("in-progress");try{await C(b.walletType,b.chain),S("completed")}catch{S("rejected")}},"addExperimentalChain");um(()=>{x(b=>{let W=T.findIndex($=>o($.type,e));return M&&W>1?[T[W]].concat(T.filter(($,I)=>I!==W)):b.map($=>T.find(I=>I.type===$.type)??$)})},[JSON.stringify(T)]);let E=document.getElementById(_e.SWAP_BOX_ID);return um(()=>{let b=null;return(h==="completed"||h==="rejected")&&(b=setTimeout(()=>S(null),wk)),()=>{b&&clearTimeout(b)}},[h]),Ze.createElement(Ze.Fragment,null,v.slice(0,r).map(b=>{let W=Ap({connectedWallets:l,walletType:b.type,chain:e}),$=W?lr(W,xk):"",I=ar(p(),e),R=!l.find(le=>le.walletType===b.type&&le.chain===e),ee=I&&R&&b.state===cm.CONNECTED,oe=ee?lm.t({id:"Add {chain} chain",values:{chain:e}}):$,L=i(async()=>{b.state===cm.DISCONNECTED?c(b):b.namespaces&&!$?(await k(b.type),c(b)):ee?(g({walletType:b.type,chain:e,address:W??""}),f(!0)):n({walletType:b.type,chain:e,address:W??""})},"onSelectableWalletClick"),V=m?.chain?er(m.chain,p()):void 0;return Ze.createElement(Ze.Fragment,{key:`${b.title}_${V}`},!!m&&Ze.createElement(J,{open:!!m&&d,container:E,onClose:()=>{g(null)}},Ze.createElement(ys,{displayName:V,onConfirm:()=>{w(m)}})),h&&Ze.createElement(J,{open:!!h,onClose:S.bind(null,null),container:E},Ze.createElement(sm,{status:h,displayName:V,image:b.image}),Ze.createElement(Tk,{direction:"vertical",size:32})),Ze.createElement(vk,{key:b.type,description:oe,onClick:L,selected:o(b.type,e),disabled:!s,...b}))}),Ze.createElement(So,{wallet:u,onClose:()=>{c(void 0)},onConnect:b=>{t.onConnect&&b.status==="connected"&&(u?.type?t.onConnect(u.type):kk(new Error("The selected wallet hasn't been detected after the connection process finished. It usually shouldn't happen.")))}}),M&&Ze.createElement(Fu,{selected:!1,onClick:a},Ze.createElement(pm,{variant:"label",size:"medium"},lm.t("Show more wallets"),Ze.createElement(pm,{variant:"label",size:"medium",color:"$primary"},"\xA0+",N-(r??0)))))}i(Cs,"WalletList");var Mk=2;function gm(t){let{open:e,onClose:o,onCancel:n,onCheckBalance:r,loading:a}=t,s=Wk(),l=y().blockchains(),{selectedQuote:p,setSelectedWallets:u,quoteWalletsConfirmed:c,setQuoteWalletConfirmed:m,customDestination:g,setCustomDestination:d}=z(),{connectedWallets:f,selectWallets:h}=Z(),{config:S}=y(),[C,k]=ko(""),[T,v]=ko([]),[x,N]=ko(""),[M,w]=ko(null),[E,b]=ko(!!g),W=Nk(()=>ao({filter:"all",quote:p}),[p]),$=ao({filter:"required",quote:p}),I=l.find(_=>_.name===p?.swaps[p?.swaps.length-1].to.blockchain),R=i(_=>$.includes(_),"isWalletRequiredFor"),ee=Ak(()=>f.filter(_=>_.selected&&W.includes(_.chain)),[f,W]),[oe,L]=ko(ee()),[V,le]=ko([]),Y=i((_,Q)=>le(G=>G.concat({blockchain:_,walletType:Q})),"addNextSelectedWallets"),ae=T.length>0,ge=i((_,Q)=>!!oe.find(G=>G.walletType===_&&G.chain===Q&&G.selected&&(R(Q)||!R(Q)&&!g)),"isSelected"),xe=i((_,Q,G)=>{let pe=!1;return _.map(ce=>{if(ce.chain===Q){let de=ce.selected;return!pe&&G?(pe=!0,de=!0):G||(de=!1),{...ce,selected:de}}return ce})},"updateSelectableWallets"),U=i(_=>{b(_),_?R(I?.name??"")||L(Q=>xe(Q,I?.name||"",!1)):(d(""),L(Q=>xe(Q,I?.name||"",!0)))},"handleCustomDestinationCollapsibleOpenChange"),Ke=i(_=>{if(C&&k(""),ge(_.walletType,_.chain))return;let G=f.find(pe=>pe.walletType===_.walletType&&pe.chain===_.chain);G&&(n(),_.chain===I?.name&&E&&!R(I.name)&&(b(!1),d(null)),L(pe=>pe.filter(ce=>ce.chain!==_.chain).concat({...G,selected:!0})))},"onChange"),xt=i(()=>{let _=oe.filter(Q=>Q.selected);h(_),u(_),m(!0),o()},"onConfirmBalance"),lt=i(async()=>{v([]),N(""),w(null);let _=await r?.({selectedWallets:oe.filter(G=>G.selected),customDestination:g}),Q=_.warnings;Q?.balance?.messages&&v(Q.balance.messages),Q?.quoteUpdate&&w(Q.quoteUpdate),_.error&&N(pc(_.error)),!_.error&&!Q?.balance?.messages.length?xt():v(Q?.balance?.messages??[])},"onConfirmWallets");fm(()=>{L(_=>{let Q=[];return _.forEach(G=>{!f.some(ce=>ce.chain===G.chain&&ce.walletType===G.walletType&&ce.address===G.address)||Q.push(G)}),Q=Q.concat(f.filter(G=>!!!Q.find(ce=>ce.chain===G.chain)&&G.selected&&W.includes(G.chain))),Q})},[f,W]),fm(()=>{let _=[];V.length>0&&(V.forEach(Q=>{let G=f.find(pe=>pe.chain===Q.blockchain&&pe.walletType===Q.walletType);G?Ke(G):_.push(Q)}),le(_))},[f,V]);let wt=document.getElementById(_e.SWAP_BOX_ID);return j.createElement(J,{open:e,onClose:()=>{c||s("../",{replace:!0}),o()},dismissible:!C,container:wt,...!C&&{styles:{container:{height:"100%"}},footer:j.createElement(qu,null,j.createElement(dm,{loading:a,disabled:Ic(a,E,g,p,oe,I),onClick:lt,variant:"contained",type:"primary",fullWidth:!0,size:"large"},Co.t("Confirm")))},...C&&{styles:{container:{height:"100%",padding:"$0"}},header:j.createElement(Ou,null,j.createElement(Uu,{variant:"ghost",onClick:k.bind(null,"")},j.createElement(Ek,{size:16})),j.createElement(ks,{variant:"headline",size:"small"},Co.t({id:"Your {blockchainName} wallets",values:{blockchainName:pt(C,l)}})))},anchor:"center"},j.createElement(J,{open:ae,onClose:v.bind(null,[]),container:wt},j.createElement(Ik,{title:Co.t("Insufficient account balance"),type:"error",description:j.createElement(bk,{messages:T??[]})},j.createElement(dm,{variant:"outlined",size:"large",type:"primary",fullWidth:!0,onClick:xt},Co.t("Proceed anyway")))),C&&j.createElement(zu,null,j.createElement("div",{className:Qu()},j.createElement(Cs,{chain:C,isSelected:ge,selectWallet:Ke,onShowMore:()=>k(C),onConnect:_=>{Y(C,_)}}))),!C&&j.createElement(j.Fragment,null,x&&j.createElement(j.Fragment,null,j.createElement(mm,{variant:"alarm",type:"error",title:Co.t(x)}),j.createElement(Vr,{size:12})),M&&j.createElement(j.Fragment,null,j.createElement(mm,{variant:"alarm",type:"warning",title:_r(M)}),j.createElement(Vr,{size:12})),j.createElement(Hu,null,W.map((_,Q)=>{let G=l.find(he=>he.name===_),pe=`wallet-${Q}`,ce=Q===W.length-1,de=ce&&I&&S?.customDestination!==!1;return j.createElement("div",{key:pe},j.createElement(_u,null,j.createElement(ks,{variant:"title",size:"xmedium"},Co.t({id:"Your {blockchainName} wallets",values:{blockchainName:G?.shortName}})),j.createElement(ks,{variant:"label",color:"$neutral700",size:"medium"},Co.t({id:"You need to connect a {blockchainName} wallet.",values:{blockchainName:G?.shortName}}))),j.createElement(Vr,{size:24}),j.createElement($u,null,j.createElement(Cs,{chain:_,isSelected:ge,selectWallet:Ke,limit:Mk,onShowMore:()=>k(G?.name??""),onConnect:he=>{Y(_,he)}})),!ce&&j.createElement(Vr,{size:32}),de&&j.createElement(Du,{blockchain:I,open:E,handleOpenChange:U}))}))))}i(gm,"ConfirmWalletsModal");import{i18n as Yk}from"@lingui/core";import{Alert as Zk,Button as Jk,InfoIcon as Rk}from"@rango-dev/ui";import ot from"react";import{Alert as Pk,Button as Dk,Divider as xs,NoRouteIcon as _k,RefreshIcon as $k,Typography as vm}from"@rango-dev/ui";import tt from"react";import{i18n as hm}from"@lingui/core";var Bk=24,Lk=60;function ym(t,e,o,n){return t?.type===1?{alert:{type:"warning",text:te().genericServerError,action:{onClick:n,title:hm.t("Retry")}},description:""}:e.length?{alert:{type:"warning",text:te().liquiditySourcesError.title,action:{onClick:()=>o(!0),title:hm.t("Reset")}},description:te().liquiditySourcesError.description}:t?.type===0&&t.diagnosisMessage?{alert:{type:"error",text:t.diagnosisMessage,action:null},description:""}:{alert:null,description:te().noResultError.description}}i(ym,"makeInfo");var Ts=(o=>(o[o.small=Bk]="small",o[o.large=Lk]="large",o))(Ts||{}),vs=(o=>(o.small="small",o.large="medium",o))(vs||{});import{styled as Kr}from"@rango-dev/ui";var Sm=Kr("div",{display:"flex",flexDirection:"column",alignItems:"center"}),Cm=Kr("div",{variants:{size:{small:{},large:{maxWidth:"316px"}}}}),km=Kr("div",{variants:{size:{small:{width:"100%"},large:{}}}}),Tm=Kr("div",{padding:"$6 $0"});function Sn(t){let{fetch:e,error:o,size:n="small"}=t,r=y().getDisabledLiquiditySources(),a=y().toggleAllLiquiditySources,s=y().swappers(),l=ym(o,r,()=>a(s,!0),e);return tt.createElement(Sm,null,tt.createElement(_k,{size:Ts[n],color:"gray"}),tt.createElement(xs,{size:4}),tt.createElement(vm,{variant:"title",size:vs[n]},te().noResultError.title),n==="large"&&tt.createElement(xs,{size:4}),!!l.description&&tt.createElement(Cm,{size:n},tt.createElement(vm,{variant:"body",size:"small",align:"center",color:"neutral700"},l.description)),tt.createElement(xs,{size:n==="large"?"24":"4"}),!!l.alert&&tt.createElement(km,{size:n},tt.createElement(Pk,{type:l.alert.type,title:l.alert.text,titleAlign:"left",action:l.alert.action&&tt.createElement(Dk,{size:"xsmall",type:l.alert.type,prefix:tt.createElement(Tm,null,tt.createElement($k,{size:8})),onClick:l.alert.action.onClick},l.alert.action.title),variant:"alarm"})))}i(Sn,"NoResult");import{i18n as Cn}from"@lingui/core";import{Button as Ok,Divider as Uk,MessageBox as zk,Typography as Qk,WarningIcon as qk}from"@rango-dev/ui";import Dt from"react";import{Typography as Em}from"@rango-dev/ui";import bs from"react";import{darkTheme as Fk,styled as jr}from"@rango-dev/ui";var xm=jr("div",{width:"100%"}),ws=jr("div",{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"$5",width:"100%"}),wm=jr("div",{display:"flex",padding:"$5 0",justifyContent:"space-between",alignItems:"center",width:"100%","._title":{$$color:"$colors$neutral600",[`.${Fk} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),bm=jr("div",{padding:"$2",alignSelf:"flex-start",cursor:"pointer"});function Im(t){let{title:e,value:o,valueColor:n}=t;return bs.createElement(wm,null,bs.createElement(Em,{size:"medium",variant:"label",className:"_title"},e),bs.createElement(Em,{size:"large",variant:"label",color:n||"foreground"},`${n?"%":"$"}${o}`))}i(Im,"QuoteErrorsModalItem");function Am(t){let{open:e,onClose:o,onConfirm:n,warning:r,confirmationDisabled:a}=t,s=r.warningLevel==="high"?"error":"warning",l=[{title:Cn.t("Swapping"),value:B(r.inputUsdValue,4,4)},{title:Cn.t("Gas cost"),value:B(r.totalFee,2,2)},{title:Cn.t("Receiving"),value:B(r.outputUsdValue,4,4)},{title:Cn.t("Price impact"),value:B(r.priceImpact,2,2),valueColor:`${s}500`}];return Dt.createElement(J,{footer:Dt.createElement(Ok,{type:"primary",size:"large",prefix:Dt.createElement(qk,null),fullWidth:!0,disabled:a,onClick:n},te().highValueLossError.confirmMessage),open:e,onClose:o,container:A()},Dt.createElement(zk,{type:s,title:te().highValueLossError.impactTitle,description:te().highValueLossError.description}),Dt.createElement(ws,null,Dt.createElement(Uk,{size:"4"}),Dt.createElement(Qk,{size:"small",variant:"title"},Cn.t("Details")),Dt.createElement(ws,null,l.map((p,u)=>Dt.createElement(Im,{key:u,...p})))))}i(Am,"HighValueLossWarningModal");import{i18n as Es}from"@lingui/core";function Nm(t,e){let o={alertType:"warning",title:"",action:null};return e?(o.alertType="error",e.type===3&&(o.title=e.recommendation),e.type===4&&(o.title=Es.t({id:"You need to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:e.minRequiredSlippage}}),o.action="change-settings"),o):t?(t.type===0&&(Lt(t.priceImpact)==="high"&&(o.alertType="error"),o.action="show-info",o.title=te().highValueLossError.title),t.type===1&&(o.title=te().unknownPriceError.title),t.type===2&&(o.title=Es.t({id:"We recommend you to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:t.minRequiredSlippage}}),o.action="change-settings"),t.type===3&&(o.title=Es.t("Caution, your slippage is high."),o.action="change-settings"),o):null}i(Nm,"makeAlerts");import{i18n as Ko}from"@lingui/core";import{Button as Wm,Divider as Mm,MessageBox as Hk,Typography as Gk}from"@rango-dev/ui";import To from"react";import{useNavigate as Vk}from"react-router-dom";function Bm(t){let{customSlippage:e,slippage:o}=y(),{open:n,onClose:r,onConfirm:a,warning:s,confirmationDisabled:l}=t,p=Vk(),u=e??o;return To.createElement(J,{anchor:"bottom",open:n,prefix:To.createElement(Wm,{size:"small",variant:"ghost",onClick:()=>p("../"+D.settings)},To.createElement(Gk,{variant:"label",size:"medium",color:"$neutral900"},Ko.t("Change settings"))),container:A(),onClose:r},To.createElement(Hk,{type:"warning",title:s.type===3?Ko.t("High slippage"):Ko.t("Low slippage"),description:s.type===3?Ko.t({id:" Caution, your slippage is high (={userSlippage}). Your trade may be front run.",values:{userSlippage:u}}):Ko.t({id:"We recommend you to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:s.minRequiredSlippage}})},To.createElement(Mm,{size:18}),To.createElement(Mm,{size:32}),To.createElement(Wm,{size:"large",type:"primary",variant:"contained",fullWidth:!0,disabled:l,onClick:a},Ko.t("Confirm anyway"))))}i(Bm,"SlippageWarningModal");import{Button as Kk,MessageBox as jk,WarningIcon as Xk}from"@rango-dev/ui";import Xr from"react";function Lm(t){let{open:e,onClose:o,onConfirm:n,confirmationDisabled:r}=t;return Xr.createElement(J,{footer:Xr.createElement(Kk,{type:"primary",size:"large",prefix:Xr.createElement(Xk,null),fullWidth:!0,disabled:r,onClick:n},te().unknownPriceError.confirmMessage),open:e,onClose:o,container:A()},Xr.createElement(jk,{type:"warning",title:te().unknownPriceError.impactTitle,description:te().unknownPriceError.description}))}i(Lm,"UnknownPriceWarningModal");function kn(t){let{warning:e,error:o,couldChangeSettings:n,showWarningModal:r,confirmationDisabled:a,refetchQuote:s,onOpenWarningModal:l,onCloseWarningModal:p,onConfirmWarningModal:u,onChangeSettings:c}=t,m={confirmationDisabled:a,open:r,onClose:p,onConfirm:u},g=o?.type===0||o?.type===1,d=Nm(e,o?.type===3||o?.type===4?o:null);return d&&!n&&(d.action=null),ot.createElement(ot.Fragment,null,g&&ot.createElement(Sn,{error:o,fetch:s}),!!d&&ot.createElement(xm,null,ot.createElement(Zk,{title:d.title,type:d.alertType,variant:"alarm",...d.action==="show-info"&&{action:ot.createElement(bm,{onClick:l},ot.createElement(Rk,{size:12,color:"gray"}))},...d.action==="change-settings"&&{action:ot.createElement(Jk,{size:"xxsmall",type:d.alertType,onClick:c},Yk.t("Change"))}})),e&&ot.createElement(ot.Fragment,null,e.type===0&&ot.createElement(Am,{...m,warning:e}),(e.type===3||e.type===2)&&ot.createElement(Bm,{...m,warning:e}),e.type===1&&ot.createElement(Lm,{...m,warning:e})))}i(kn,"QuoteWarningsAndErrors");import WT from"bignumber.js";import pi from"react";import{i18n as vo}from"@lingui/core";import{Alert as yT,Divider as Xo,FullExpandedQuote as ST,InfoIcon as CT,NumericTooltip as md,QuoteTag as kT,StepDetails as TT,TokenAmount as vT,Typography as Yo}from"@rango-dev/ui";import Ps from"bignumber.js";import F,{useRef as xT,useState as wT}from"react";import{styled as Is}from"@rango-dev/ui";var As=Is("div",{width:"100%","& .position-top__skeleton":{paddingTop:"$10"}}),Pm=Is("div",{paddingBottom:"$15",variants:{dense:{true:{paddingBottom:0}}}}),Dm=Is("div",{width:"100%",display:"flex"});import*as Yr from"@radix-ui/react-collapsible";import{Button as eT,css as Tn,darkTheme as Ee,Image as _m,styled as qe,Typography as tT}from"@rango-dev/ui";var oT=300,$m=qe(Yr.Root,{display:"flex",flexDirection:"column",alignItems:"start",overflowX:"auto",overflowY:"hidden",width:"100%",borderRadius:"$xm",variants:{selected:{true:{},false:{$$color:"$colors$neutral400",[`.${Ee} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"}},listItem:{true:{$$color:"$colors$neutral400",[`.${Ee} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"},false:{}}},compoundVariants:[{listItem:!1,selected:!0,css:{$$color:"$colors$secondary200",[`.${Ee} &`]:{$$color:"$colors$secondary800"},backgroundColor:"$$color"}}]}),Fm=Tn({padding:"$10 $15"}),Om=qe(eT,{backgroundColor:"transparent",border:"1px solid $secondary550",[`.${Ee} &`]:{border:"1px solid $secondary"},transition:"background-color 0.3s ease","&:hover":{backgroundColor:"$secondary550",[`.${Ee} &`]:{backgroundColor:"$secondary"},".allRoutesLabel":{$$color:"$colors$background",[`.${Ee} &`]:{$$color:"$colors$foreground"},color:"$$color",transition:"color 0.3s ease"}}}),Um=qe("div",{borderRadius:"$xm",display:"flex",flexDirection:"column",alignItems:"start",justifyContent:"space-between",color:"$foreground",boxSizing:"border-box",position:"relative",variants:{selected:{true:{},false:{$$color:"$colors$neutral200",[`.${Ee} &`]:{$$color:"$colors$neutral500"},backgroundColor:"$$color"}},basic:{true:{borderTopRightRadius:"0",borderTopLeftRadius:"0"}},listItem:{true:{$$color:"$colors$neutral200",[`.${Ee} &`]:{$$color:"$colors$neutral500"},backgroundColor:"$$color","&:hover":{"& .quote_container":{"& button":{backgroundColor:"$neutral500",[`.${Ee} &`]:{backgroundColor:"$neutral200"}},backgroundColor:"$neutral500",[`.${Ee} &`]:{backgroundColor:"$neutral200"}},backgroundColor:"$neutral300",[`.${Ee} &`]:{backgroundColor:"$neutral400"}},cursor:"pointer"},false:{}}},compoundVariants:[{listItem:!0,selected:!0,css:{outline:"1px solid $secondary"}},{listItem:!1,selected:!0,css:{$$color:"$colors$secondary100",[`.${Ee} &`]:{$$color:"$colors$secondary550"},backgroundColor:"$$color","&:hover":{backgroundColor:"$$color"}}},{listItem:!0,selected:!1,css:{cursor:"pointer","&:hover":{backgroundColor:"$neutral300",[`.${Ee} &`]:{backgroundColor:"$neutral400"}}}}]}),zm=Tn({width:"100%",padding:"$15 $15 $10 $15"}),Qm=Tn({display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingBottom:"$10",position:"relative"}),jo=Tn({display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",".blockchainImage":{marginLeft:"-$8"}}),qm=Tn({display:"flex",alignItems:"center",".usd-value":{$$color:"$colors$neutral600",[`.${Ee} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),Hm=qe(Yr.Trigger,{display:"flex",width:"100%",justifyContent:"space-between",alignItems:"center",height:"$36",padding:"$10 $15",boxSizing:"border-box",cursor:"pointer",border:"none",outline:"none",backgroundColor:"transparent",variants:{error:{true:{[`& ${_m}`]:{border:"1px $warning500 solid",borderRadius:"100%"}},false:{[`& ${_m}`]:{border:"1px transparent solid",borderRadius:"100%"}}},selected:{true:{},false:{$$color:"$colors$neutral400",[`.${Ee} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"}},listItem:{true:{$$color:"$colors$neutral400",[`.${Ee} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"},false:{}}},compoundVariants:[{listItem:!1,selected:!0,css:{$$color:"$colors$secondary200",[`.${Ee} &`]:{$$color:"$colors$secondary800"},backgroundColor:"$$color"}}],".blockchains_section":{display:"none"},"@xs":{".blockchains_section":{display:"block"}}}),Gm=qe("div",{width:"18px",height:"18px",borderRadius:"100%",display:"flex",justifyContent:"center",alignItems:"center",border:"1.5px transparent solid",img:{borderRadius:"100%"},variants:{state:{error:{borderColor:"$error500"},warning:{borderColor:"$warning500"}}}}),Vm=qe(Fr,{width:"100%",background:"inherit"}),Ns=qe("div",{display:"flex",justifyContent:"center",alignItems:"center",padding:"$2",transition:`all ${oT}ms ease`,variants:{orientation:{down:{transform:"rotate(0)"},up:{transform:"rotate(180deg)"}}}}),a1=qe("div",{height:"$12",marginLeft:"$10",marginRight:"$10",borderLeft:"1px solid $foreground"}),Km=qe("div",{display:"flex",justifyContent:"center",margin:"0 $15",borderTop:"1px solid",$$color:"$colors$neutral300",[`.${Ee} &`]:{$$color:"$colors$neutral400"},borderColor:"$$color"}),jm=qe("div",{width:"$16",height:"$16",justifyContent:"center",alignItems:"center",display:"flex"}),Ws=qe(tT,{overflow:"hidden",textOverflow:"ellipsis",letterSpacing:.4}),Xm=qe("div",{display:"flex",flexWrap:"wrap"}),Ms=qe("div",{width:"18px",height:"18px",borderRadius:"100%",backgroundColor:"$background",cursor:"default",display:"flex",justifyContent:"center",alignItems:"center",border:"1.5px transparent solid",variants:{state:{error:{borderColor:"$error500"},warning:{borderColor:"$warning500"}}}}),Ym=qe("div",{display:"flex"}),Zr=qe("div",{width:"100%",borderTopWidth:"1px",borderTopStyle:"solid",borderTopColor:"$neutral",margin:"$5 0",[`.${Ee} &`]:{borderTopColor:"$neutral800"}});import{i18n as Nt}from"@lingui/core";import{ChevronDownIcon as rT,CloseIcon as iT,Divider as ei,IconButton as aT,NumericTooltip as sT,QuoteCost as lT,Typography as yt}from"@rango-dev/ui";import X,{useState as ed}from"react";import{css as nT,styled as Jr}from"@rango-dev/ui";var Rr=Jr("div",{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"$5 0","&.total_payable_fee":{padding:"$12 0"}}),Bs=Jr("div",{width:"100%",borderTop:"1px solid $neutral300",margin:"$10 0"}),Zm=Jr("div",{padding:"$20 0",display:"flex",flexDirection:"column","& .collapsible_trigger":{display:"flex",alignItems:"center"}}),Jm=Jr("div",{padding:"$20 $20 $10",textAlign:"center",position:"relative","._icon-button":{position:"absolute",zIndex:10,top:"$16",right:"$16"}}),Rm=nT({display:"flex",flexDirection:"row",alignItems:"center",padding:"$5","&:hover":{"& ._typography, & svg":{color:"$secondary"}}});var pT=i(t=>t.fee.isZero()?null:X.createElement(Rr,null,X.createElement(yt,{variant:"label",size:"medium",color:"neutral600"},t.label),X.createElement(yt,{variant:"label",size:"medium"},"$",B(t.fee,4,4))),"NonPayableFee");function td(t){let[e,o]=ed(!1),[n,r]=ed(!1),{steps:a,quote:s,fee:l,time:p,feeWarning:u,showModalFee:c}=t,m=s?.swaps??[],g=A(),d=gc(m);return X.createElement(X.Fragment,null,X.createElement(lT,{onClickFee:c?f=>{f.stopPropagation(),o(!e)}:void 0,fee:l,feeWarning:u,time:p,steps:a,tooltipGas:c?Nt.t("View more info"):void 0,tooltipContainer:g}),X.createElement(J,{container:g,open:e,header:X.createElement(Jm,null,X.createElement(yt,{variant:"title",size:"medium"},Nt.t("Gas & Fee Explanation")),X.createElement(aT,{onClick:()=>o(!1),variant:"ghost"},X.createElement(iT,{color:"gray",size:14}))),onClose:()=>{o(!1)}},X.createElement(Zm,null,X.createElement(yt,{variant:"title",size:"small"},Nt.t("Details")),X.createElement(ei,{size:10}),Object.entries(d.payable).flatMap(([f,h])=>h.map((S,C)=>{let k=`payable-fee-${C}`,T=ya(S);return X.createElement(Rr,{key:k},X.createElement(yt,{variant:"label",size:"medium",color:"neutral600"},da(f,Nt.t)),X.createElement(sT,{content:S.amount,container:g},X.createElement(yt,{variant:"label",size:"medium"},B(S.amount,2,2)," ",S.asset.symbol," ($",B(T,4,4),")")))})),X.createElement(Rr,{className:"total_payable_fee"},X.createElement(yt,{variant:"label",size:"medium"},Nt.t("Total Payable Fee")),X.createElement(yt,{variant:"label",size:"medium"},"$",B(l,4,4))),X.createElement(Bs,null),Object.keys(d.nonePayable).length&&X.createElement(zr,{triggerAnchor:"bottom",onClickTrigger:()=>r(f=>!f),trigger:X.createElement("div",{className:Rm()},X.createElement(yt,{size:"small",variant:"body",color:"neutral700"},n?Nt.t("Hide non-payable fees"):Nt.t("Show non-payable fees")),X.createElement(ei,{size:4,direction:"horizontal"}),X.createElement(Or,{orientation:n?"up":"down"},X.createElement(rT,{size:12,color:"gray"}))),open:n},X.createElement(yt,{size:"small",variant:"title"},Nt.t("Description")),X.createElement(ei,{size:4}),X.createElement(yt,{size:"small",variant:"body",color:"neutral700"},Nt.t(`The following fees are considered in the transaction output and
2
- you won\u2019t need to pay extra gas for them.`)),X.createElement(ei,{size:10}),Object.entries(d.nonePayable).map(([f,h],S)=>{let C=fc(h),k=da(f,Nt.t),T=`non-payable-fee-${S}`;return X.createElement(pT,{key:T,fee:C,label:k})}),X.createElement(Bs,null)))))}i(td,"QuoteCostDetails");import{i18n as rd}from"@lingui/core";import{TokenAmount as id}from"@rango-dev/ui";import ti from"react";import{css as cT,styled as uT}from"@rango-dev/ui";var od=uT("div",{position:"relative",display:"flex",flexDirection:"column",width:"100%"}),nd=cT({height:"14px",marginLeft:"14px",position:"absolute",borderLeft:"1px solid $foreground",top:"42%"});function vn(t){let{from:e,to:o,percentageChange:n,warningLevel:r}=t;return ti.createElement(od,null,ti.createElement(id,{direction:"horizontal",label:rd.t("Swap input"),type:"input",tooltipContainer:A(),price:{value:e.price.value,usdValue:e.price.usdValue,realValue:e.price.realValue,realUsdValue:e.price.realUsdValue},token:{displayName:e.token.displayName,image:e.token.image},chain:{image:e.chain.image}}),ti.createElement("div",{className:nd()}),ti.createElement(id,{direction:"horizontal",tooltipContainer:A(),label:rd.t("Estimated output"),type:"output",price:{value:o.price.value,usdValue:o.price.usdValue,realValue:o.price.realValue,realUsdValue:o.price.realUsdValue},token:{displayName:o.token.displayName,image:o.token.image},chain:{image:o.chain.image},percentageChange:n,warningLevel:r}))}i(vn,"QuoteSummary");import{i18n as cd}from"@lingui/core";import{ChevronDownIcon as fT,ChevronRightIcon as gT,Divider as Ls,Image as hT,Tooltip as ai,Typography as ni}from"@rango-dev/ui";import O from"react";import{useLayoutEffect as mT,useState as xn}from"react";var ad=480,sd=768,ld=1024,pd=1200,dT=i(()=>{let[t,e]=xn(!1),[o,n]=xn(!1),[r,a]=xn(!1),[s,l]=xn(!1),[p,u]=xn(!1),c=i(()=>{e(window.innerWidth<=ad),n(window.innerWidth>ad&&window.innerWidth<=sd),a(window.innerWidth>sd&&window.innerWidth<=ld),l(window.innerWidth>ld&&window.innerWidth<=pd),u(window.innerWidth>pd)},"handleResize");return mT(()=>(c(),window.addEventListener("resize",c),()=>window.removeEventListener("resize",c)),[]),{isMobile:t,isTablet:o,isNotebook:r,isLargeScreen:s,isExtraLargeScreen:p}},"useScreenDetect"),oi=dT;var ri=4,ii=6,wn=i(t=>{let{content:e,src:o,className:n,open:r,state:a,container:s}=t,l=s||A();return O.createElement(ai,{container:l,side:"bottom",sideOffset:4,open:r,content:e},O.createElement(Gm,{className:n,state:a},O.createElement(hT,{src:o,size:16})))},"ImageComponent");function ud(t){let{quoteRef:e,selected:o,setExpanded:n,steps:r,expanded:a,type:s,container:l}=t,p=l||A(),u=r.length,c=Bc(r),{isTablet:m,isMobile:g}=oi();return O.createElement(Hm,{listItem:s==="list-item",ref:d=>e.current=d,selected:o,onClick:d=>{d.stopPropagation(),n(f=>!f)}},O.createElement("div",{className:jo()},O.createElement(ni,{variant:"body",size:"xsmall"},cd.t("Via:")),O.createElement(Ls,{direction:"horizontal",size:4}),r.map((d,f)=>{let h=`item-${f}`,S=O.createElement(Ns,null,O.createElement(gT,{size:12,color:"black"}));return g||m?O.createElement(O.Fragment,{key:h},O.createElement(wn,{content:d.swapper.displayName,src:d.swapper.image,state:d.state,container:l}),f!==u-1&&O.createElement(O.Fragment,null,S)):O.createElement(O.Fragment,{key:h},u<=ri||u>ri&&f<ri-1?O.createElement(O.Fragment,null,O.createElement(wn,{content:d.swapper.displayName,src:d.swapper.image,state:d.state,container:l}),f!==u-1&&O.createElement(O.Fragment,null,S)):f===ri-1&&O.createElement(ai,{container:p,side:"bottom",align:"end",sideOffset:4,content:O.createElement("div",{className:jo()},S,r.map((C,k)=>{let T=`image-${k}`;return k>=f&&O.createElement(O.Fragment,{key:T},O.createElement(wn,{content:C.swapper.displayName,src:C.swapper.image,state:C.state,open:!1}),k!==u-1&&O.createElement(O.Fragment,null,S))}))},O.createElement(Ms,{state:r.find((C,k)=>k>=f&&(C.state==="error"||C.state==="warning"))?.state},O.createElement(ni,{size:"xsmall",variant:"body"},"+",u-f))))})),O.createElement("div",{className:jo()},O.createElement("div",{className:"blockchains_section"},O.createElement("div",{className:jo()},O.createElement(ni,{variant:"body",size:"xsmall"},cd.t("Chains:")),O.createElement(Ls,{direction:"horizontal",size:4}),c.map((d,f)=>O.createElement(O.Fragment,{key:d.displayName},c.length<=ii||c.length>ii&&f<ii-1?O.createElement(ai,{container:p,side:"bottom",content:d.displayName,sideOffset:4},O.createElement(wn,{content:"",src:d.image,open:!1,className:f!==0?"blockchainImage":""})):f===ii-1&&O.createElement(ai,{container:p,side:"bottom",align:"end",sideOffset:4,content:O.createElement("div",{className:jo()},c.map((h,S)=>S>=f&&O.createElement(wn,{key:h.displayName,content:"",src:h.image,open:!1,className:S>f?"blockchainImage":"",container:l})))},O.createElement(Ms,{className:"blockchainImage"},O.createElement(ni,{size:"xsmall",variant:"body"},"+",c.length-f))))),O.createElement(Ls,{direction:"horizontal",size:32}))),O.createElement(Ns,{orientation:a?"up":"down"},O.createElement(fT,{size:12,color:"black"}))))}i(ud,"QuoteTrigger");function Ds(t){let{quote:e,input:o,output:n,error:r,warning:a,type:s,selected:l=!1,tagHidden:p=!0,showModalFee:u=!0,onClickAllRoutes:c,fullExpandedMode:m=!1,container:g}=t,d=y().blockchains(),{findToken:f}=y(),h=y().swappers(),{customSlippage:S,slippage:C}=y(),k=S||C,[T,v]=wT(t.expanded),x=xT(null),N=B(o.value,6,6),M=B(n.value,6,6),w=n.usdValue?B(n.usdValue,4,4):"",E=ut(o.usdValue,n.usdValue??null),b=B(E,2,2),W=Lt(E??0),$=i((ge,xe)=>ge.map((U,Ke)=>{let xt,lt=r?.type===3&&r.swap.swapperId===U.swapperId,wt=r?.type===4&&r.recommendedSlippages?.has(Ke),_=a?.type===2&&a.recommendedSlippages?.has(Ke),Q=lt||wt,G=_;Q?xt="error":G&&(xt="warning");let pe=Q?vo.t("Slippage Error"):vo.t("Slippage Warning");return lt&&(pe=vo.t("Bridge Limit Error")),{swapper:{displayName:nn(U.swapperId,h)??"",image:U.swapperLogo},from:{token:{displayName:U.from.symbol,image:U.from.logo},chain:{displayName:pt(U.from.blockchain,d)??"",image:U.from.blockchainLogo},price:{value:Ke===0&&!xe?B(o.value,6,6):B(U.fromAmount,6,6),usdValue:B((U.from.usdPrice??0)*parseFloat(U.fromAmount),4,4),realValue:Ke===0?o.value:U.fromAmount,realUsdValue:new Ps(U.from.usdPrice??0).multipliedBy(U.fromAmount).toString()}},to:{token:{displayName:U.to.symbol,image:U.to.logo},chain:{displayName:pt(U.to.blockchain,d)||"",image:U.to.blockchainLogo},price:{value:B(U.toAmount,6,6),usdValue:B((U.to.usdPrice??0)*parseFloat(U.toAmount),4,4),realValue:U.toAmount,realUsdValue:new Ps(U.to.usdPrice??0).multipliedBy(U.toAmount).toString()}},state:xt,alerts:Q||G?F.createElement(Pm,{dense:m},F.createElement(yT,{variant:"alarm",type:Q?"error":"warning",title:pe,footer:F.createElement(Dm,null,lt&&F.createElement("div",null,F.createElement(Yo,{size:"xsmall",variant:"body",color:"neutral900"},r.fromAmountRangeError),F.createElement(Xo,{direction:"vertical",size:2}),F.createElement(Yo,{size:"xsmall",variant:"body",color:"neutral900"},vo.t({id:"Yours: {amount} {symbol}",values:{amount:B(U.fromAmount,6,6),symbol:U?.from.symbol}}))),(wt||_)&&!lt&&F.createElement("div",null,F.createElement(Yo,{size:"xsmall",variant:"body",color:"neutral900"},vo.t({id:"Minimum required slippage: {minRequiredSlippage}",values:{...r?.type===4&&{minRequiredSlippage:r.recommendedSlippages?.get(Ke)},...a?.type===2&&{minRequiredSlippage:a.recommendedSlippages?.get(Ke)}}})),F.createElement(Xo,{direction:"vertical",size:2}),F.createElement(Yo,{size:"xsmall",variant:"body",color:"neutral900"},vo.t({id:"Yours: {userSlippage}",values:{userSlippage:k}}))))})):void 0,time:an(U.estimatedTimeInSeconds),fee:B(ha(U,f),2,2),internalSwaps:U.internalSwaps?$(U.internalSwaps):void 0}}),"getQuoteSteps"),I=$(e?.swaps??[]),R=I.length,ee=g||A(),oe=Pc(t.quote.tags||[]),L=!!c,V=an(tr(e?.swaps)),le=kr(e?.swaps??[],f),Y=B(le,2,2),ae=le.gte(new Ps(lc));return m?F.createElement(ST,{selected:l,fee:Y,time:V,tooltipContainer:on(),steps:I,tags:oe,feeWarning:ae,percentageChange:b,warningLevel:W,outputPrice:{value:M,usdValue:w,realValue:n.value,realUsdValue:n.usdValue}}):F.createElement(Um,{selected:l,listItem:s==="list-item",basic:s==="basic"},F.createElement("div",{className:zm()},!p&&oe.length?F.createElement(F.Fragment,null,F.createElement(Ym,null,oe.map((ge,xe)=>{let U=`${ge.value}_${xe}`;return F.createElement(F.Fragment,{key:U},F.createElement(kT,{label:ge.label,value:ge.value}),F.createElement(Xo,{size:4,direction:"horizontal"}))})),F.createElement(Zr,null),!L&&F.createElement(Xo,{size:4})):null,F.createElement("div",{id:"portal-root",className:Qm()},F.createElement(td,{quote:e,time:V,fee:Y,feeWarning:ae,showModalFee:u,steps:R}),L&&F.createElement(Om,{onClick:ge=>{ge.stopPropagation(),c()},size:"xxsmall",type:"secondary",variant:"default",css:{paddingLeft:"$10",paddingRight:"$10",paddingTop:"$5",paddingBottom:"$5"}},F.createElement(Yo,{color:"secondary",variant:"body",size:"xsmall",className:"allRoutesLabel"},vo.t("See All Routes")))),s==="basic"&&F.createElement("div",{className:qm()},F.createElement(jm,null,F.createElement(CT,{size:12,color:"gray"})),F.createElement(Xm,null,F.createElement(Ws,{size:"small",variant:"body"},`${N} ${I[0].from.token.displayName} = `),F.createElement(md,{content:n.value,container:ee,open:n.value?void 0:!1},F.createElement(Ws,{size:"small",variant:"body"},"\xA0",`${M} ${I[I.length-1].to.token.displayName}`))),F.createElement(md,{content:n.usdValue,container:ee},F.createElement(Xo,{size:2,direction:"horizontal"}),F.createElement(Yo,{color:"$neutral600",size:"xsmall",variant:"body"},`($${w})`))),s==="list-item"&&F.createElement(vT,{tooltipContainer:ee,type:"output",direction:"vertical",price:{value:M,usdValue:w,realValue:n.value,realUsdValue:n.usdValue},token:{displayName:I[R-1].to.token.displayName,image:I[R-1].to.token.image},chain:{image:I[R-1].to.chain.image},percentageChange:b,warningLevel:W}),s==="swap-preview"&&F.createElement(F.Fragment,null,F.createElement(vn,{from:I[0].from,to:I[R-1].to,percentageChange:b,warningLevel:W}),F.createElement(Xo,{size:4}))),F.createElement($m,{selected:l,listItem:s==="list-item",open:T,className:"quote_container",onOpenChange:v},F.createElement(ud,{type:s,quoteRef:x,selected:l,setExpanded:v,container:ee,expanded:T,steps:I}),F.createElement(Vm,{open:T},F.createElement(Km,null),F.createElement("div",{className:Fm()},I.map((ge,xe)=>{let U=`item-${xe}`;return F.createElement(TT,{type:"quote-details",key:U,tooltipContainer:ee,step:ge,hasSeparator:xe!==I.length-1,state:ge.state})})))))}i(Ds,"Quote");import{Divider as AT,Skeleton as NT}from"@rango-dev/ui";import $t from"react";import{darkTheme as bT,styled as si}from"@rango-dev/ui";var dd=si("div",{$$color:"$colors$neutral100",[`.${bT} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",borderBottomLeftRadius:"$xm",borderBottomRightRadius:"$xm",padding:"$15",variants:{rounded:{true:{borderRadius:"$xm"}},expanded:{true:{paddingBottom:"3px"},false:{paddingBottom:"$12"}}}}),fd=si("div",{paddingTop:"$2"}),gd=si("div",{paddingLeft:"$8"}),hd=si("div",{borderLeft:"1px dashed $foreground",minHeight:" 0",margin:"0px 11.5px",alignSelf:"stretch",variants:{hideSeparator:{true:{minHeight:"unset",height:"0"}}}});import{ChainToken as Ed,Divider as St,Skeleton as nt}from"@rango-dev/ui";import q from"react";import{css as ET,styled as _t}from"@rango-dev/ui";var _s=_t("div",{display:"flex"}),yd=_t("div",{padding:"$10 $0 $20"}),Sd=_t("div",{padding:"14px $0 $20 $0",display:"flex",flexDirection:"column"}),Cd=_t("div",{display:"flex",justifyContent:"start",alignItems:"center"}),kd=_t("div",{display:"flex",justifyContent:"space-between",alignItems:"end"}),Td=_t("div",{height:"$24",marginLeft:"13px",borderLeft:"1px solid $neutral700"}),vd=_t("div",{width:"65%",display:"flex",justifyContent:"start"}),xd=_t("div",{display:"flex",flexDirection:"column",alignItems:"start",flexGrow:1,maxWidth:"148px"}),wd=_t("div",{padding:"$15 $0 $15 $0"}),bd=ET({display:"flex",justifyContent:"space-between",alignItems:"center"});function bn(t){let{type:e,tagHidden:o=!0}=t,n=q.createElement(kd,null,q.createElement(vd,null,q.createElement(Ed,{loading:!0,size:"medium",chainImage:"",tokenImage:""}),q.createElement(St,{size:8,direction:"horizontal"}),q.createElement(xd,null,q.createElement(nt,{height:10,width:60,variant:"rounded"}),q.createElement(St,{size:4}),q.createElement(nt,{height:15,variant:"rounded"}))),q.createElement(nt,{height:12,width:64,variant:"rounded"})),r=e==="basic"&&!o;return q.createElement("div",null,!o&&q.createElement(q.Fragment,null,q.createElement(_s,null,q.createElement(nt,{width:65,height:20,variant:"rounded"}),q.createElement(St,{size:4,direction:"horizontal"}),q.createElement(nt,{width:65,height:20,variant:"rounded"}),q.createElement(St,{size:4,direction:"horizontal"}),q.createElement(nt,{width:65,height:20,variant:"rounded"})),q.createElement(Zr,null),!r&&q.createElement(St,{size:4})),q.createElement("div",{className:bd()},q.createElement(_s,null,q.createElement(nt,{width:60,height:10,variant:"rounded"}),q.createElement(St,{size:4,direction:"horizontal"}),q.createElement(nt,{width:60,height:10,variant:"rounded"}),q.createElement(St,{size:4,direction:"horizontal"}),q.createElement(nt,{width:60,height:10,variant:"rounded"})),r&&q.createElement(nt,{width:85,height:24,variant:"rounded"})),e==="basic"&&q.createElement(yd,null,q.createElement(nt,{height:15,width:148,variant:"rounded"})),e==="list-item"&&q.createElement(Sd,null,q.createElement(Cd,null,q.createElement(Ed,{loading:!0,size:"medium",chainImage:"",tokenImage:""}),q.createElement(St,{direction:"horizontal",size:4}),q.createElement(nt,{height:15,width:150,variant:"rounded"})),q.createElement(St,{size:10}),q.createElement(nt,{height:10,width:184,variant:"rounded"})),e==="swap-preview"&&q.createElement(q.Fragment,null,q.createElement(St,{size:4}),q.createElement(wd,null,n,q.createElement(Td,null),n),q.createElement(St,{size:12})))}i(bn,"QuoteSummarySkeleton");import{ChainToken as Md,Divider as Fs,NextIcon as IT,Skeleton as li}from"@rango-dev/ui";import Ie from"react";import{styled as En}from"@rango-dev/ui";var Id=En("div",{display:"flex",alignItems:"start"}),Ad=En("div",{flexGrow:1,paddingTop:"$5",paddingBottom:"$10",display:"flex",alignItems:"center",variants:{extraSpace:{true:{paddingBottom:"$40"}}}}),$s=En("div",{display:"flex",alignItems:"center",flexGrow:1}),Nd=En("div",{margin:"$0 $2",padding:"$4",display:"flex",justifyContent:"center",alignItems:"center"}),Wd=En("div",{display:"flex",alignItems:"center"});function Wt(t){let{separator:e=!0}=t;return Ie.createElement(Ie.Fragment,null,Ie.createElement(Wd,null,Ie.createElement(li,{height:22,width:22,variant:"circular"}),Ie.createElement(Fs,{direction:"horizontal",size:8}),Ie.createElement(li,{height:15,width:148,variant:"rounded"})),Ie.createElement(Id,null,Ie.createElement(hd,{hideSeparator:!e}),Ie.createElement(Ad,{extraSpace:e},Ie.createElement($s,null,Ie.createElement(Md,{size:"small",loading:!0,chainImage:"",tokenImage:""}),Ie.createElement(Fs,{direction:"horizontal",size:8}),Ie.createElement(li,{height:12,variant:"rounded"})),Ie.createElement(Nd,null,Ie.createElement(IT,{color:"gray",size:16})),Ie.createElement($s,null,Ie.createElement(Md,{size:"small",loading:!0,chainImage:"",tokenImage:""}),Ie.createElement(Fs,{direction:"horizontal",size:8}),Ie.createElement(li,{height:12,variant:"rounded"})))))}i(Wt,"StepSkeleton");function In(t){let{type:e,expanded:o,tagHidden:n=!1}=t;return $t.createElement(dd,{expanded:o,rounded:e!=="basic"},$t.createElement(bn,{type:e,tagHidden:n}),$t.createElement(fd,null,$t.createElement(NT,{height:15,variant:"rounded"})),o&&$t.createElement(gd,null,$t.createElement(AT,{size:24}),$t.createElement(Wt,null),$t.createElement(Wt,null),$t.createElement(Wt,{separator:!1})))}i(In,"QuoteSkeleton");function xo(t){let{quote:e,type:o,loading:n,error:r,warning:a,expanded:s=!1,tagHidden:l,onClick:p,showModalFee:u,selected:c,onClickAllRoutes:m,fullExpandedMode:g=!1,container:d}=t,{inputAmount:f,inputUsdValue:h,toToken:S}=z(),C=e?.outputAmount?new WT(e?.outputAmount):null,k=e?.outputAmount?Vt(e?.outputAmount,uo(e)||S?.usdPrice):null,v=!(r&&(r.type===0||r.type===1))&&e&&!n;return n?pi.createElement(As,null,pi.createElement(In,{tagHidden:l,type:o,expanded:s})):v?pi.createElement(As,{onClick:()=>p?.(e)},pi.createElement(Ds,{quote:e,error:r,container:d,showModalFee:u,warning:a,tagHidden:l,selected:c,type:o,expanded:s,onClickAllRoutes:m,fullExpandedMode:g,input:{value:f,usdValue:h?.toString()??""},output:{value:C?.toString()??"",usdValue:k?.toString()??""}})):null}i(xo,"QuoteInfo");import{calculatePendingSwap as PT}from"@rango-dev/queue-manager-rango-preset";import{useEffect as DT}from"react";import{useRef as MT,useState as BT}from"react";var LT=2e3;function ci({request:t}){let[e,o]=BT(!1),n=MT(null),r=i(()=>n.current?.abort(),"cancelFetch"),a=i(async l=>(await new Promise(p=>setTimeout(p,LT)),await s(l,!1)),"retryFetch"),s=i(async(l,p=!1)=>{r(),n.current=new AbortController,o(!0);try{let u=await t(l,{signal:n.current.signal});return n.current=null,u}catch(u){if(p)return await a(l);throw u}finally{o(!1)}},"fetch");return{fetch:s,loading:e,cancelFetch:r}}i(ci,"useFetch");function Bd(){let{fetch:t,loading:e,cancelFetch:o}=ci({request:async(n,r)=>await qt().confirmRouteRequest(n,r)});return{fetch:t,loading:e,cancelFetch:o}}i(Bd,"useFetchConfirmQuote");function ui(t){if(!t.swaps)throw new Error(te().noResultError.title,{cause:{type:0,diagnosisMessage:t.diagnosisMessages?.[0]}});let e=Os(t.swaps);if(e)throw new Error(e.message,{cause:e.options})}i(ui,"throwErrorIfResponseIsNotValid");function Os(t){if(uc(t)){let{swap:n,recommendation:r,fromAmountRangeError:a}=mc(t);return{message:"bridge limit error",options:{type:3,swap:n,recommendation:r,fromAmountRangeError:a}}}let o=hc(t);if(o){let n=Tr(t);return{message:"",options:{type:4,recommendedSlippages:o,minRequiredSlippage:n}}}return null}i(Os,"getQuoteError");function Ld(t,e,o){let n=!1;t&&(n=Mc(t,e));let r={quote:null,quoteUpdate:null,balance:null},a=Lo(e,{fromToken:o.fromToken,toToken:o.toToken,findToken:o.findToken,userSlippage:o.userSlippage});a&&(r.quote=a),t&&n&&(vc(t,e)?r.quoteUpdate={type:3,newOutputAmount:B(Bo(e)),percentageChange:B(ut(Bo(t)??"",Bo(e)??""),null,2)}:Sa(t,e)?r.quoteUpdate={type:0}:Ca(t,e)?r.quoteUpdate={type:1}:ka(t,e)&&(r.quoteUpdate={type:2}));let s=xc(e,o.selectedWallets,o.meta.blockchains);return s.length===0||(r.balance={messages:s}),r}i(Ld,"generateWarnings");function mi(t){return t?.code==="ERR_CANCELED"?{swap:null,error:{type:2},warnings:null}:t.cause?{swap:null,error:t.cause,warnings:null}:{swap:null,error:{type:1},warnings:null}}i(mi,"handleQuoteErrors");function Us(){let{fromToken:t,toToken:e,inputAmount:o,setSelectedQuote:n,selectedQuote:r,customDestination:a,setQuoteWarningsConfirmed:s,resetAlerts:l}=z(),{slippage:p,customSlippage:u}=y(),c=y().getDisabledLiquiditySources(),m=y().blockchains(),g=y().tokens(),{findToken:d}=y(),f=u||p,{fetch:h,cancelFetch:S,loading:C}=Bd();return DT(()=>S,[]),{loading:C,fetch:i(async T=>{let v=T.selectedWallets,x=T?.customDestination??a;if(!t||!e||!o)return{quote:null,swap:null,error:null,warnings:null};let N=v.reduce((w,E)=>(w[E.chain]=E.address,w),{}),M={requestId:r?.requestId||"",selectedWallets:N,destination:x||void 0};try{return await h(M,!0).then(w=>{let{result:E}=w;ui({diagnosisMessages:E.diagnosisMessages,requestId:E.requestId,swaps:E.result?.swaps});let b={outputAmount:E.result?.outputAmount,requestId:E.requestId,resultType:E.result?.resultType,swaps:E.result?.swaps||[],validationStatus:E.validationStatus,requestAmount:E.requestAmount};n(b);let W={slippage:f.toString(),disabledSwappersGroups:c},$=Ld(r??void 0,b,{fromToken:t,toToken:e,meta:{blockchains:m},findToken:d,selectedWallets:v,userSlippage:f});$.quoteUpdate&&s(!1),l();let I=!!$.balance,R=PT(o.toString(),E,kc(v),W,!I,{blockchains:m,tokens:g});return{quote:b,swap:R,error:null,warnings:$}})}catch(w){return mi(w)}},"fetch"),cancelFetch:S}}i(Us,"useConfirmSwap");var HT=FT("div",{width:"100%",display:"flex",justifyContent:"space-between",[`& ${Dd}`]:{width:"$48",height:"$48"}}),GT=qs({flexGrow:1,paddingRight:"$10"}),VT=qs({width:"$24",height:"$24",display:"flex",justifyContent:"center",alignItems:"center"}),KT=qs({display:"flex",justifyContent:"space-between",alignItems:"center"});function _d(){let{selectedQuote:t,setInputAmount:e,selectedWallets:o,quoteWalletsConfirmed:n,customDestination:r,quoteWarningsConfirmed:a}=z(),s=qT(),[l,p]=An(""),u=!n,[c,m]=An(!1),[g,d]=An(!1),{isActiveTab:f}=se(),h=y().getDisabledLiquiditySources(),S=QT(h),{manager:C}=_T(),{fetch:k,loading:T,cancelFetch:v}=Us(),[x,N]=An({swap:null,error:null,warnings:null}),[M,w]=An(!1),E=i(async({selectedWallets:L,customDestination:V})=>{let le=await k?.({selectedWallets:L,customDestination:V});return N(le),le},"onConfirmSwap"),b=i(async()=>{if(x.swap&&n)try{await C?.create("swap",{swapDetails:x.swap},{id:x.swap.requestId});let L=`../${D.swaps}/${x.swap.requestId}`;s(L,{replace:!0}),setTimeout(()=>{e("")},0)}catch(L){p("Error: "+L?.message)}},"addNewSwap"),W=i(async()=>{d(!0),await b(),d(!1)},"onConfirm"),$=i(async()=>{x?.warnings?.quote&&!a?w(!0):await W()},"onStartConfirmSwap"),I=i(async()=>{N({error:null,swap:null,warnings:null}),k({selectedWallets:o,customDestination:r}).then(L=>{N(L)}).catch(L=>console.error(L))},"onRefresh");di(()=>{!!S.current.length&&!h.length&&I(),S.current=h},[h.length]),di(()=>{u&&v()},[u]),di(()=>{u&&m(u)},[u]),di(()=>{u||k({selectedWallets:o,customDestination:r}).then(L=>N(L)).catch(L=>console.error(L))},[]),zT(()=>{t?.requestId||s(`../${location.search}`)},[t?.requestId]);let R=x.warnings?.quote??null,ee=x.error,oe=[];if(l&&oe.push(Ae.createElement(Pd,{type:"error",variant:"alarm",title:l})),x.warnings?.quoteUpdate&&oe.push(Ae.createElement(Pd,{variant:"alarm",type:"warning",title:x.warnings.quoteUpdate&&_r(x.warnings.quoteUpdate)})),R||ee){let L=`../${D.settings}`;oe.push(Ae.createElement(kn,{warning:R,error:ee,couldChangeSettings:!1,refetchQuote:I,showWarningModal:M,confirmationDisabled:!f,onOpenWarningModal:()=>w(!0),onCloseWarningModal:()=>w(!1),onConfirmWarningModal:async()=>{w(!1),await b()},onChangeSettings:()=>s(L)}))}return Ae.createElement(ne,{header:{title:zs.t("Confirm Swap"),onWallet:()=>{let L=`../${D.wallets}`;s(L)}},footer:Ae.createElement(HT,null,Ae.createElement("div",{className:GT()},Ae.createElement($T,{variant:"contained",type:"primary",size:"large",fullWidth:!0,loading:T||g,disabled:!!x.error||!f,onClick:$},zs.t("Start Swap"))),Ae.createElement(Dd,{variant:"contained",type:"primary",size:"large",loading:T||g,disabled:!f,onClick:m.bind(null,!0)},Ae.createElement(UT,{size:24})))},c&&Ae.createElement(gm,{open:c,onClose:()=>m(!1),onCancel:v,loading:T,onCheckBalance:E}),Ae.createElement(ie,null,Ae.createElement("div",{className:KT()},Ae.createElement(OT,{variant:"title",size:"small"},zs.t("You get")),Ae.createElement("div",{className:VT()},Ae.createElement(Wr,{onClick:!T&&!c&&!M?I:void 0}))),Ae.createElement(Qs,{size:"12"}),jc(oe.map((L,V)=>({element:L,key:`alert-${V}`})),Ae.createElement(Qs,{size:10})),oe.length>0?Ae.createElement(Qs,{size:10}):null,Ae.createElement(xo,{quote:t,type:"swap-preview",expanded:!0,tagHidden:!0,error:x.error,loading:T,warning:x.warnings?.quote??null})))}i(_d,"ConfirmSwapPage");import{i18n as Ft}from"@lingui/core";import{Button as ol,CustomTokensZeroStateDarkIcon as mv,CustomTokensZeroStateIcon as dv,DeleteIcon as fv,Divider as Bn,IconButton as gv,MessageBox as hv,NotFound as yv,styled as rl}from"@rango-dev/ui";import fe,{useState as nl}from"react";import{useNavigate as Sv}from"react-router-dom";import{CloseIcon as XT,IconButton as YT,SearchIcon as ZT,TextField as JT}from"@rango-dev/ui";import Nn from"react";import{styled as jT}from"@rango-dev/ui";var $d=jT("div",{width:"$24",height:"$24",display:"flex",alignItems:"center",justifyContent:"center"});function Ct(t){let{variant:e,fullWidth:o,color:n,size:r,onChange:a,value:s,style:l,setValue:p,...u}=t;return Nn.createElement(JT,{prefix:Nn.createElement($d,null,Nn.createElement(ZT,{color:"black"})),suffix:!!s.length&&Nn.createElement(YT,{variant:"ghost",onClick:()=>p?.(""),size:"small"},Nn.createElement(XT,{color:"gray",size:10})),fullWidth:o,color:n,variant:e,style:{padding:10,borderRadius:25,alignItems:"center",...l},size:r,value:s,onChange:a,...u})}i(Ct,"SearchInput");import{i18n as el}from"@lingui/core";import{darkTheme as jd,Divider as Jo,ExternalLinkIcon as iv,Image as av,ListItemButton as sv,NotFound as lv,PinIcon as pv,Skeleton as Xd,Typography as hi,VirtualizedList as cv}from"@rango-dev/ui";import H,{useEffect as Yd,useState as Zd}from"react";import{useWallets as RT}from"@rango-dev/wallets-react";import{useEffect as ev,useRef as tv,useState as ov}from"react";function Hs(t){let{connectedWallets:e}=Z(),{getWalletInfo:o}=RT(),n=tv([]),[r,a]=ov(0);return ev(()=>{let s=i(p=>{p.type==="disconnect"&&o(p.payload.walletType).supportedChains.some(m=>m.name===t)&&a(m=>m+1)},"handleWalletEvent");return Zn.on("walletEvent",s),t?(e.filter(p=>p.chain===t).forEach(p=>{let{walletType:u}=p,c=n.current.includes(u);p.loading&&!c?n.current=n.current.concat(u):!p.loading&&c&&(n.current=n.current.filter(m=>m!==u),a(m=>m+1))}),()=>Zn.off("walletEvent",s)):a(p=>p+1)},[e,t,o]),{balanceKey:r}}i(Hs,"useObserveBalanceChanges");import{Divider as Vd,ListItem as rv,Skeleton as Wn}from"@rango-dev/ui";import kt from"react";import{css as Zo,darkTheme as Fd,ImageContainer as nv,styled as dt,Typography as Od}from"@rango-dev/ui";var Gs=Zo({position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:100,overflow:"hidden"}),Vs=Zo({position:"relative",height:12,width:"30%",maxWidth:"150px"}),Ks=Zo({position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",bottom:"-8px"}),js=Zo({transform:"translateY(12px)",visibility:"hidden",display:"flex","& a":{display:"flex",justifyContent:"center",alignItems:"center",fontSize:"$12",lineHeight:"$16",$$color:"$colors$neutral600",[`.${Fd} &`]:{$$color:"$colors$neutral700"},color:"$$color",textDecoration:"none"}}),Xs=Zo({}),Ys=Zo(),Ud=dt("div",{display:"flex",flexDirection:"column",flexGrow:1,overflow:"hidden",justifyContent:"center"}),Zs=dt("div",{display:"flex",alignItems:"center","._typography":{textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:100,overflow:"hidden"}}),fi=dt("ul",{flexGrow:1,padding:0,margin:0,listStyle:"none","& li":{alignItems:"none","&:hover":{[`& .${Vs}`]:{[`& .${js}`]:{position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",visibility:"visible"},[`& .${Xs}`]:{bottom:"-15px"},[`& .${Gs}`]:{position:"absolute",transform:"translateY(-12px)",visibility:"hidden"},[`& .${Ks}`]:{position:"absolute",transform:"translateY(-12px)",bottom:"-10px"}}}}}),Js=dt("div",{paddingLeft:"$5",paddingRight:"$5",borderRadius:"$md",display:"flex",alignItems:"center"}),Rs=dt(Od,{}),zd=dt("div",{textAlign:"right",width:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",[`& .${Ys}`]:{$$color:"$colors$neutral600",[`.${Fd} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),gi=dt("div",{display:"flex",alignItems:"end",flexDirection:"column"}),uU=dt("div",{display:"flex",alignItems:"center"}),Qd=dt("div",{position:"relative",[`& ${nv}`]:{borderRadius:"$xm",overflow:"hidden"}}),qd=dt("div",{position:"absolute",backgroundColor:"$neutral100",padding:"$4",borderRadius:"50%",bottom:-6,right:-6}),Hd=dt(Od,{width:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}),Gd=dt("a",{"& svg:hover":{color:"$colors$info"}});function Kd(t){return kt.createElement(fi,null,Array.from(Array(t.size),e=>kt.createElement(rv,{key:e,hasDivider:!0,start:kt.createElement(Wn,{variant:"circular",width:35,height:35}),end:kt.createElement(gi,null,kt.createElement(Wn,{variant:"text",size:"large",width:70}),kt.createElement(Vd,{size:4}),kt.createElement(Wn,{variant:"text",size:"medium",width:50})),title:kt.createElement("div",null,kt.createElement(Wn,{variant:"text",size:"large",width:90}),kt.createElement(Vd,{size:4}),kt.createElement(Wn,{variant:"text",size:"medium",width:90}))})))}i(Kd,"LoadingTokenList");var tl=20,uv=i(t=>{let{address:e,name:o,url:n,token:r,customCssForTag:a,customCssForTagTitle:s}=t,l=e.length;return H.createElement("div",{className:Vs()},o?H.createElement("div",{className:Gs()},o):H.createElement(Zs,{className:Ks()},H.createElement(hi,{variant:"title",size:"xmedium"},r.symbol),H.createElement(Jo,{direction:"horizontal",size:4}),H.createElement(Js,{css:a},H.createElement(Rs,{variant:"body",size:"xsmall",css:s},r.blockchain))),!!e&&H.createElement("div",{className:`${js()} ${!o&&Xs()}`},l>10?`${e.slice(0,5)}...${e.slice(l-6,l)}`:e," ",H.createElement(Jo,{size:4,direction:"horizontal"}),H.createElement(Gd,{href:n,target:"_blank",rel:"nofollow noreferrer",onClick:p=>p.stopPropagation()},H.createElement(iv,{size:12}))))},"renderDesc");function Mn(t){let{list:e,searchedFor:o="",onChange:n,selectedBlockchain:r,showTitle:a=!0,action:s}=t,[l,p]=Zd(e),u=y().fetchStatus,c=y().blockchains(),[m,g]=Zd(!0),{getBalanceFor:d,loading:f}=Z(),{isTokenPinned:h}=y(),{balanceKey:S}=Hs(r),C=i(()=>{p(e.slice(0,l.length+tl))},"loadNextPage");Yd(()=>{g(e.length>l.length)},[l.length]),Yd(()=>{p(e.slice(0,tl))},[e.length,r,S]);let k=i(v=>{let x=sr(d(v));return s?s(v):f?H.createElement(gi,null,H.createElement(Xd,{variant:"text",size:"large",width:70}),H.createElement(Jo,{size:4}),H.createElement(Xd,{variant:"text",size:"medium",width:50})):x&&H.createElement(zd,null,H.createElement(Hd,{variant:"title",size:"small"},x.amount),H.createElement("div",null),x.usdValue&&H.createElement(hi,{variant:"body",className:Ys(),size:"xsmall"},`$${x.usdValue}`))},"endRenderer"),T=i(()=>H.createElement(cv,{endReached:m?C:void 0,itemContent:v=>{let x=l[v],N=x.address||"",M=c.find(W=>W.name===x.blockchain),w=La(M.color,"main"),E={$$color:w.main150,[`.${jd} &`]:{$$color:w.main750},backgroundColor:"$$color"},b={$$color:w.main750,[`.${jd} &`]:{$$color:w.main150},color:"$$color"};return H.createElement("div",{style:{paddingRight:5}},H.createElement(sv,{style:{width:"100%",overflow:"hidden",height:"60px"},"tab-index":v,key:`${x.symbol}${x.address}`,id:`${x.symbol}${x.address}`,hasDivider:!0,onClick:()=>n&&n(l[v]),start:H.createElement(Qd,null,H.createElement(av,{src:x.image,size:30}),t.type!=="custom-token"&&h(x,t.type)&&H.createElement(qd,null,H.createElement(pv,{size:12,color:"gray"}))),title:M?.type==="COSMOS"||x.name||!x.name&&!N?H.createElement(Zs,null,H.createElement(hi,{variant:"title",size:"xmedium"},x.symbol),H.createElement(Jo,{direction:"horizontal",size:4}),H.createElement(Js,{css:E},H.createElement(Rs,{variant:"body",size:"xsmall",css:b},x.blockchain))):void 0,description:M?.info&&N&&M.type!=="COSMOS"?uv({address:N,token:l[v],customCssForTag:E,customCssForTagTitle:b,name:x.name,url:M.info.addressUrl.split("{wallet}").join(N)}):x.name||void 0,end:k(x)}))},totalCount:l.length,key:`${r}-${o}-${S}`}),"renderList");return H.createElement(H.Fragment,null,a&&H.createElement(H.Fragment,null,H.createElement(hi,{variant:"label",size:"large"},el.t("Select Token")),H.createElement(Jo,{size:4})),H.createElement(Ud,null,H.createElement(Jo,{size:4}),u==="loading"&&H.createElement(Kd,{size:tl}),u==="success"&&(l.length?H.createElement(fi,{as:"ul"},T()):!!o&&H.createElement(lv,{title:el.t("No results found"),description:el.t("Try using different keywords")}))))}i(Mn,"TokenList");var Cv=rl("div",{display:"flex",justifyContent:"space-between",flexDirection:"column",flex:1}),kv=rl("div",{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",flex:"0.75"}),Tv=rl(gv,{"&:hover":{"& svg":{color:"$secondary550"}}});function Jd(){let[t,e]=nl(""),{deleteCustomToken:o}=y(),n=y().customTokens(),{fromToken:r,toToken:a,setFromToken:s,setToToken:l}=z(),{mode:p}=$o({}),u=Sv(),[c,m]=nl(!1),[g,d]=nl(),f=i(k=>{let T=k.target.value;e(T)},"handleSearch"),h=p==="dark",S=n.filter(k=>et(k.symbol,t)||et(k.address||"",t)||et(k.name||"",t)),C=i(()=>{if(g){let k=a?$e(a):null,T=r?$e(r):null,v=$e(g);k===v?l({token:null}):T===v&&s({token:null}),o(g)}m(!1)},"handleDeleteCustomToken");return fe.createElement(ne,{header:{title:Ft.t("Custom Tokens")}},fe.createElement(ie,null,fe.createElement(Cv,null,n.length?fe.createElement(fe.Fragment,null,fe.createElement(Ct,{value:t,setValue:e,fullWidth:!0,color:"light",variant:"contained",placeholder:Ft.t("Search Token"),onChange:f}),fe.createElement(Bn,{size:16}),fe.createElement(Mn,{list:S,type:"custom-token",searchedFor:t,showTitle:!1,action:k=>fe.createElement(Tv,{variant:"ghost",onClick:()=>{m(!0),d(k)}},fe.createElement(fv,{size:12,color:"gray"}))})):fe.createElement(kv,null,fe.createElement(yv,{icon:h?fe.createElement(mv,{size:200}):fe.createElement(dv,{size:200}),title:Ft.t("No custom tokens"),description:Ft.t("press the button to add your custom token")})),fe.createElement(Bn,{size:20}),fe.createElement(ol,{type:"primary",variant:"contained",size:"large",onClick:()=>u(D.addCustomTokens)},Ft.t("Add Custom Token"))),fe.createElement(J,{open:c,dismissible:!0,onClose:()=>m(!1),container:A()},fe.createElement(hv,{title:Ft.t("Delete Custom Token"),type:"error",description:Ft.t("Are you sure you want to Delete this Token?")},fe.createElement(Bn,{size:40}),fe.createElement(Bn,{size:10}),fe.createElement(ol,{fullWidth:!0,variant:"contained",type:"primary",size:"large",onClick:C},Ft.t("Yes, Delete it")),fe.createElement(Bn,{size:12}),fe.createElement(ol,{fullWidth:!0,variant:"outlined",type:"primary",size:"large",onClick:()=>m(!1)},Ft.t("No, Continue"))))))}i(Jd,"CustomTokensPage");import{i18n as Ge}from"@lingui/core";import{useManager as Uv}from"@rango-dev/queue-manager-react";import{Button as ul,darkTheme as zv,Divider as Rt,MessageBox as Qv,NotFound as qv,styled as ml,Typography as Ci}from"@rango-dev/ui";import{TransactionStatus as Dn}from"rango-types";import re,{useMemo as Sf,useState as ki}from"react";import{useNavigate as Hv}from"react-router-dom";import{FilterIcon as Av,Popover as Nv}from"@rango-dev/ui";import wo from"react";import{css as vv,darkTheme as yi,IconButton as xv,styled as Ln}from"@rango-dev/ui";var il=Ln("div",{position:"relative","&::before":{position:"absolute",right:"1px",top:"-1px",width:"$8",height:"$8",borderRadius:"100%",backgroundColor:"$neutral300",[`.${yi} &`]:{backgroundColor:"$neutral400"},padding:"$2"},variants:{isSelect:{true:{"&::before":{content:""}}}}}),Rd=Ln(xv,{width:"$36",height:"$36",position:"relative",padding:"0",overflow:"unset",backgroundColor:"$neutral300",[`.${yi} &`]:{backgroundColor:"$neutral400"},"&:hover":{backgroundColor:"$secondary100",[`.${yi} &`]:{backgroundColor:"$neutral"},[`& ${il}::before`]:{backgroundColor:"$secondary100",[`.${yi} &`]:{backgroundColor:"$neutral"}}},variants:{isSelect:{true:{border:"1px solid $secondary"}}}}),ef=Ln("div",{position:"absolute",width:"$6",height:"$6",display:"flex",justifyContent:"center",alignItems:"center",borderRadius:"3px",top:"$0",right:"1px",backgroundColor:"$secondary500"}),tf=Ln("div",{padding:"$15",borderRadius:"$sm",width:"248px",backgroundColor:"$background",zIndex:10}),of=vv({display:"flex",justifyContent:"space-between",alignItems:"center"}),nf=Ln("ul",{margin:0,listStyle:"none",height:"100%",padding:0,".item-start-container":{paddingRight:"0 !important"}});import{i18n as rf}from"@lingui/core";import{Button as wv,Divider as af,ListItemButton as bv,Radio as Ev,RadioRoot as Iv,Typography as sf}from"@rango-dev/ui";import rt from"react";function lf(t){let{filterBy:e,onClickItem:o}=t;return rt.createElement(tf,null,rt.createElement("div",{className:of()},rt.createElement(sf,{size:"small",variant:"body"},rf.t("Status")),rt.createElement(wv,{variant:"ghost",size:"xxsmall",onClick:()=>o("")},rf.t("Reset"))),rt.createElement(af,{size:10}),rt.createElement(Iv,{value:e},rt.createElement(nf,null,t.list.map((n,r)=>rt.createElement(bv,{key:n.id,style:{height:"40px",width:"100%"},selected:!1,hasDivider:t.list.length-1!=r,id:n.id,title:rt.createElement(rt.Fragment,null,rt.createElement(af,{direction:"horizontal",size:4}),rt.createElement(sf,{size:"medium",variant:"body"},n.title)),start:rt.createElement(Ev,{value:n.id}),onClick:o})))))}i(lf,"FilterSelectorContent");function al(t){let{onClickItem:e,onOpenChange:o,filterBy:n,list:r,open:a}=t;return wo.createElement("div",null,wo.createElement(Nv,{open:a,align:"end",onOpenChange:o,container:A(),content:wo.createElement(lf,{list:r,filterBy:n,onClickItem:s=>{e(s),o(!1)}})},wo.createElement(Rd,{variant:"default",isSelect:!!n,onClick:()=>o(!t.open)},wo.createElement(il,{isSelect:!!n},wo.createElement(Av,{size:16,color:"black"}),!!n&&wo.createElement(ef,null)))))}i(al,"FilterSelector");import{i18n as Bv}from"@lingui/core";import{Divider as df,GroupedVirtualizedList as Lv,Skeleton as Pv,SwapListItem as ff,Typography as Dv}from"@rango-dev/ui";import He,{useCallback as gf,useEffect as _v,useRef as $v,useState as Fv}from"react";function pf(t,e){let o=[],n=0;do{let r=t[n];o.push(Math.min(r,e)),e-=r,n++}while(e>0&&n<=t.length);return o}i(pf,"calculateGroupsSoFar");import{css as Wv,darkTheme as Mv,styled as Pn}from"@rango-dev/ui";var sl=Wv(),cf=Pn("div",{display:"flex",justifyContent:"center",alignItems:"center",padding:"$5"}),ll=Pn("div",{width:"100%",display:"flex",flexDirection:"column",backgroundColor:"$background",padding:"$10 $5 0 $5",[`& .${sl}`]:{$$color:"$colors$neutral600",[`.${Mv} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),pl=Pn("div",{display:"flex",justifyContent:"flex-start",padding:"$2"}),uf=Pn("div",{gap:"$10",display:"flex",flexDirection:"column"}),mf=Pn("div",{height:"100%",display:"flex",justifyContent:"center",alignItems:"center"});var Ov=10;function cl(t){let{list:e,onSwapClick:o,groupBy:n,isLoading:r}=t,[a,s]=Fv([]),l=$v(0),{swaps:p,groupCounts:u,groups:c}=n(e),m=gf(pf,[]),g=gf(()=>{let d=e.length-l.current;d&&(l.current+=Math.min(d,Ov),s(m(u,l.current)))},[e.length]);if(_v(()=>{r||g()},[r,g]),r){let d=[1,2];return He.createElement(He.Fragment,null,[d,d].map((h,S)=>He.createElement(ll,{key:S},He.createElement(pl,null,He.createElement(Pv,{variant:"text",width:60,size:"small"}),He.createElement(df,{size:16})),He.createElement(df,{size:4}),He.createElement(uf,null,h.map((k,T)=>He.createElement(ff,{isLoading:!0,key:T}))))))}return He.createElement(Lv,{endReached:()=>{l.current<e.length&&g()},groupCounts:a,groupContent:d=>He.createElement(ll,null,He.createElement(pl,null,He.createElement(Dv,{variant:"label",size:"medium",className:sl()},c[d]))),itemContent:(d,f)=>{let h=p[d];if(!h)return null;let S=h.steps[0],C=h.steps[h.steps.length-1];return He.createElement(cf,{key:h.requestId},He.createElement(ff,{requestId:h.requestId,creationTime:h.creationTime,status:h.status,onClick:o,tooltipContainer:A(),onlyShowTime:c[f]===Bv.t("Today"),swapTokenData:{from:{token:{image:S.fromLogo,displayName:S.fromSymbol},blockchain:{image:S.fromBlockchainLogo||""},amount:B(h.inputAmount,6,6),realAmount:h.inputAmount},to:{token:{image:C.toLogo,displayName:C.toSymbol},blockchain:{image:C.toBlockchainLogo||""},amount:B(C.outputAmount||C.expectedOutputAmountHumanReadable||"",6,6),realAmount:C.outputAmount||C.expectedOutputAmountHumanReadable||""}}}))}})}i(cl,"HistoryGroupedList");import{i18n as Si}from"@lingui/core";import hf from"dayjs";var yf=i(t=>{let e=new Map([["today",{title:Si.t("Today"),swaps:[]}],["week",{title:Si.t("This week"),swaps:[]}],["month",{title:Si.t("This month"),swaps:[]}],["year",{title:Si.t("This year"),swaps:[]}]]);function o(p,u){e.has(p)||e.set(p,{title:p,swaps:[]}),e.get(p)?.swaps.push(u)}i(o,"addYearsToOutput");let n=hf();t.forEach(p=>{let u=Number(p.creationTime),c=hf(u);if(n.isSame(c,"day"))e.get("today")?.swaps.push(p);else if(n.isSame(c,"week"))e.get("week")?.swaps.push(p);else if(n.isSame(c,"month"))e.get("month")?.swaps.push(p);else if(n.isSame(c,"year"))e.get("year")?.swaps.push(p);else{let m=new Date(u).getFullYear().toString();o(m,p)}});let r=Array.from(e.values()).filter(p=>p.swaps.length>0),a=r.flatMap(p=>p.swaps),s=r.map(p=>p.swaps.length),l=r.map(p=>p.title);return{swaps:a,groupCounts:s,groups:l}},"groupSwapsByDate");var Gv=ml("div",{overflowY:"visible",width:"100%",display:"flex",flexDirection:"column",gap:15,height:"100%"}),Vv=ml("div",{display:"flex",justifyContent:"center",alignItems:"center"}),Kv=ml("div",{"._typography":{color:"$neutral700",[`.${zv}&`]:{color:"$neutral900"}}}),jv=[{id:Dn.SUCCESS,title:Ge.t("Complete")},{id:Dn.RUNNING,title:Ge.t("Running")},{id:Dn.FAILED,title:Ge.t("Failed")}],Xv=i((t,e)=>t?.length?t.filter(o=>bt(o.fromBlockchain,e)||bt(o.toBlockchain,e)||bt(o.toSymbol,e)||bt(o.fromSymbol,e)).length:!1,"isStepContainsText");function Cf(){let t=Hv(),{manager:e,state:o}=Uv(),n=mt(e).map(({swap:T})=>T),[r,a]=ki(""),[s,l]=ki(!1),p=!o.loadedFromPersistor,[u,c]=ki(""),[m,g]=ki(!1),d=i(T=>{let v=T.target.value;a(v)},"handleSearch"),f=Sf(()=>!r&&!u?n:n.filter(T=>{let{inputAmount:v,status:x,steps:N,requestId:M}=T;return(!r||bt(v,r)||bt(x,r)||Xv(N,r)||bt(M,r))&&(!u||u===x)}),[n,r,u]),h=!f?.length&&!p,S=i(()=>g(!1),"onCloseModal"),C=i(async()=>{try{await e?.clearQueue(),g(!1)}catch(T){console.log(T)}},"onClear"),k=Sf(()=>!n.some(T=>T.status===Dn.SUCCESS||T.status===Dn.FAILED),[n]);return re.createElement(ne,{header:{title:Ge.t("History"),suffix:re.createElement(Kt,null,re.createElement(ul,{disabled:k,variant:"ghost",size:"xsmall",onClick:()=>g(!0)},re.createElement(Ci,{size:"medium",variant:"label",color:"error"},Ge.t("Clear all Txs"))))}},re.createElement(ie,null,re.createElement(Vv,null,re.createElement(Ct,{setValue:a,fullWidth:!0,variant:"contained",placeholder:Ge.t("Search Transaction"),autoFocus:!0,onChange:d,style:{height:36},value:r}),re.createElement(Rt,{size:10,direction:"horizontal"}),re.createElement(al,{filterBy:u,open:s,onOpenChange:T=>l(T),onClickItem:T=>c(T),list:jv})),re.createElement(Rt,{size:"16"}),re.createElement(Gv,null,h&&re.createElement(mf,null,re.createElement(Rt,{size:32}),re.createElement(qv,{title:r?Ge.t("No results found"):Ge.t("No transactions"),titleColor:r?void 0:"$info",hasIcon:!!r,description:r?Ge.t("Try using different keywords"):Ge.t("Your transaction history is stored locally and will appear here after you start a swap")})),!h&&re.createElement(cl,{list:f,onSwapClick:t,groupBy:yf,isLoading:p}))),re.createElement(J,{open:m,onClose:S,container:A()},re.createElement(Rt,{size:20}),re.createElement(Qv,{type:"warning",title:Ge.t("Clear History"),description:re.createElement(Kv,null,re.createElement(Ci,{variant:"body",size:"medium"},Ge.t("This would clear all succeeded/failed transactions from widget. Do you wish to proceed?")),re.createElement(Rt,{size:"24"}),re.createElement(Ci,{variant:"body",size:"small"},Ge.t("Hint: This does not clear your transaction history on blockchain. Only hides them in this page.")))}),re.createElement(Rt,{size:40}),re.createElement(Rt,{size:10}),re.createElement(ul,{variant:"contained",type:"primary",size:"large",onClick:C},Ge.t("Yes, Clear history")),re.createElement(Rt,{size:10}),re.createElement(ul,{variant:"outlined",type:"primary",size:"large",onClick:S},re.createElement(Ci,{variant:"title",size:"medium",color:"primary"},Ge.t("No, Cancel")))))}i(Cf,"HistoryPage");import{i18n as fx}from"@lingui/core";import{Button as gx,Divider as Ff,styled as hx,WarningIcon as yx}from"@rango-dev/ui";import Sx from"bignumber.js";import Je,{useEffect as Of,useState as Uf}from"react";import{useNavigate as Cx}from"react-router-dom";import{i18n as tx}from"@lingui/core";import{Header as ox}from"@rango-dev/ui";import eo,{useEffect as nx,useState as rx}from"react";import{i18n as Zv}from"@lingui/core";import{Divider as fl,FullExpandedQuote as Jv,Typography as Rv}from"@rango-dev/ui";import Ce from"react";import{styled as dl}from"@rango-dev/ui";var kf=dl("div",{display:"flex",justifyContent:"center",flexDirection:"column",height:"100%"}),Tf=dl("div",{display:"flex",justifyContent:"space-between",alignItems:"center"}),vf=dl("div",{width:"146px"});import{i18n as _n}from"@lingui/core";import{Select as Yv}from"@rango-dev/ui";import xf from"react";function Ti(t){let{updateQuotePartialState:e,sortStrategy:o}=z(),n=[{value:"SMART",label:_n.t("Smart Routing")},{value:"FEE",label:_n.t("Lowest Fee")},{value:"SPEED",label:_n.t("Fastest Transfer")},{value:"NET_OUTPUT",label:_n.t("Maximum Return")},{value:"PRICE",label:_n.t("Maximum Output")}];return xf.createElement(vf,null,xf.createElement(Yv,{container:t.container,options:n,value:o,handleItemClick:r=>{e("sortStrategy",r.value)},variant:"filled"}))}i(Ti,"SelectStrategy");var wf=3;function $n(t){let{loading:e,onClickOnQuote:o,fetch:n,showModalFee:r,hasSort:a=!0,fullExpandedMode:s=!1,container:l}=t,{selectedQuote:p,quotes:u,updateQuotePartialState:c,fromToken:m,toToken:g,sortStrategy:d,error:f}=z(),{slippage:h,customSlippage:S}=y(),{findToken:C}=y(),k=l||A(),T=!!u&&u.results.length,v=S??h,x=i(w=>{if(!m||!g||!u)return null;let E={requestAmount:u.requestAmount,...w};return Lo(E,{fromToken:m,toToken:g,userSlippage:v,findToken:C})},"getQuoteWarning"),N=f?.type===0||f?.type===1,M=u?.results?wr(d,u?.results):[];return Ce.createElement(Ce.Fragment,null,a&&Ce.createElement(Ce.Fragment,null,Ce.createElement(Tf,null,Ce.createElement(Rv,{size:"xmedium",variant:"title"},Zv.t("Sort by")),Ce.createElement(Ti,{container:k})),Ce.createElement(fl,{size:"10"})),e&&Array.from({length:wf},(w,E)=>Ce.createElement(Ce.Fragment,{key:E},s?Ce.createElement(Jv,{loading:!0}):Ce.createElement(In,{tagHidden:!1,type:"list-item",expanded:!1}),E!==wf-1&&Ce.createElement(fl,{size:16}))),!e&&Ce.createElement(Ce.Fragment,null,T?M.map((w,E)=>{let b=x(w),W=Os(w.swaps),$=M.length-1===E;return Ce.createElement(Ce.Fragment,{key:w.requestId},Ce.createElement(xo,{showModalFee:r,container:k,selected:p?.requestId===w.requestId,tagHidden:!1,quote:{...w,requestAmount:u.requestAmount},loading:e,error:W?.options||null,warning:b,fullExpandedMode:s,onClick:I=>{W||c("warning",b),c("error",W?.options||null),o(I)},type:"list-item"}),!$&&Ce.createElement(fl,{size:16}))}):N&&Ce.createElement(kf,null,Ce.createElement(Sn,{size:s?"large":"small",error:f,fetch:n}))))}i($n,"Quotes");import{darkTheme as ex,styled as bf}from"@rango-dev/ui";var Ef=bf("div",{transition:"width 0.2s, opacity 0.2s, margin-left 0.2s",height:"700px",width:"390px",opacity:1,marginLeft:"$16",backgroundColor:"$neutral100",[`.${ex} &`]:{backgroundColor:"$neutral300"},variants:{expandMode:{default:{width:"390px"},full:{width:"719px"}}},"&.is-hidden":{width:0,height:0,opacity:0,marginLeft:0}}),If=bf("div",{position:"relative",overflow:"hidden",padding:"$20",flexGrow:1,display:"flex",flexDirection:"column",overflowY:"auto",borderRadius:"$primary",backgroundColor:"$background"});var ix=100;function gl(t){let{fetch:e,loading:o,onClickOnQuote:n,onClickRefresh:r,isVisible:a}=t,[s,l]=rx(!1),p=s?"":"is-hidden",{config:u}=y(),c=u?.variant==="full-expanded",m=on();return nx(()=>{let g=null;return a?g=setTimeout(()=>{l(!0)},ix):(l(!1),g&&clearTimeout(g)),()=>{g&&clearTimeout(g)}},[a]),eo.createElement(Ef,{expandMode:u?.variant==="full-expanded"?"full":"default",className:`${p} ${Lr()}`,id:_e.EXPANDED_BOX_ID},eo.createElement(ox,{title:tx.t("Routes"),suffix:eo.createElement(eo.Fragment,null,eo.createElement(Ti,{container:m}),eo.createElement(go,{container:m,onClickRefresh:r,hidden:["history","notifications","settings"]}))}),eo.createElement(If,null,eo.createElement($n,{showModalFee:!1,fetch:e,hasSort:!1,loading:o,container:on(),onClickOnQuote:n,fullExpandedMode:c})))}i(gl,"ExpandedQuotes");import{i18n as Pf}from"@lingui/core";import{SwapInput as Df}from"@rango-dev/ui";import Fn from"react";import{ReverseIcon as lx}from"@rango-dev/ui";import yl from"react";import{keyframes as ax,styled as Af}from"@rango-dev/ui";var hl=450,sx=ax({"0%":{transform:"rotateX(0deg) rotateY(0deg) rotateZ(0deg)"},"33%":{transform:"rotateX(0deg) rotateZ(78deg) rotateY(66deg)"},"66%":{transform:"rotateX(0deg) rotateZ(163deg) rotateY(66deg)"},"100%":{transform:"rotateX(0deg) rotateZ(180deg) rotateY(0deg)"}}),Nf=Af("div",{position:"absolute",bottom:"-12px",left:"50%",transform:"translate(-50%, 10%)",cursor:"pointer"}),Wf=Af("div",{borderRadius:"$md",border:"3px solid $background",background:"$neutral100",width:"$24",height:"$24",display:"flex",justifyContent:"center",alignItems:"center",color:"$foreground","&.rotate":{"& svg":{animation:`${sx} ${hl}ms ease-in-out forwards`}},"&:hover":{color:"$secondary500",transform:"translateY(1px) scale(1.04)",boxShadow:"1px 1px 1px 1px rgba(0, 0, 0, 0.05)"}});function Sl(){let t=z.use.switchFromAndTo();return yl.createElement(Nf,null,yl.createElement(Wf,{onClick:e=>{let o=e.currentTarget;o.classList.add("rotate"),setTimeout(()=>{o.classList.remove("rotate")},hl),t()}},yl.createElement(lx,{size:12})))}i(Sl,"SwitchFromAndToButton");import{styled as Mf}from"@rango-dev/ui";var Bf=Mf("div",{display:"flex",flexDirection:"column",gap:"$5",alignSelf:"stretch"}),Lf=Mf("div",{position:"relative"});function Cl(t){let{fetchingQuote:e,fetchMetaStatus:o,onClickToken:n,isExpandable:r}=t,{fromToken:a,fromBlockchain:s,toToken:l,toBlockchain:p,setInputAmount:u,inputAmount:c,inputUsdValue:m,outputAmount:g,outputUsdValue:d,selectedQuote:f}=z(),{connectedWallets:h,getBalanceFor:S}=Z(),C=a?S(a):null,k=sr(C)?.amount??"0",T=s&&a?B(C?.amount,C?.decimals):"0",v=!!s&&Np(h,s.name),x=!ga(f,c,m),N=!ga(f,c,d),M=!m||!d||!d.gt(0)?null:ut(m.toString(),d.toString());return Fn.createElement(Bf,null,Fn.createElement(Lf,null,Fn.createElement(Df,{label:Pf.t("From"),mode:"From",onInputChange:u,balance:k,chain:{displayName:s?.displayName||"",image:s?.logo||""},token:{displayName:a?.symbol||"",image:a?.image||""},onClickToken:()=>n("from"),price:{value:c,usdValue:x?void 0:B(m,4,4),realUsdValue:x?void 0:m?.toString(),error:x?te().unknownPriceError.impactTitle:void 0},disabled:o==="failed",loading:o==="loading",loadingBalance:v,tooltipContainer:A(),onSelectMaxBalance:()=>{u(T.split(",").join(""))},anyWalletConnected:h.length>0}),Fn.createElement(Sl,null)),Fn.createElement(Df,{sharpBottomStyle:!r&&(!!f||e),label:Pf.t("To"),mode:"To",fetchingQuote:e,chain:{displayName:p?.displayName||"",image:p?.logo||""},token:{displayName:l?.symbol||"",image:l?.image||""},percentageChange:B(ut(m,d),2,2),warningLevel:Lt(M??0),price:{value:B(g,6,6),usdValue:N?void 0:B(d,4,4),realValue:g?.toString(),realUsdValue:N?void 0:d?.toString(),error:N?te().unknownPriceError.impactTitle:void 0},onClickToken:()=>n("to"),disabled:o==="failed",loading:o==="loading",tooltipContainer:A()}))}i(Cl,"Inputs");import{useCallback as px,useEffect as cx,useRef as ux,useState as mx}from"react";function _f(){let{fetch:t,loading:e,cancelFetch:o}=ci({request:async(n,r)=>await qt().getAllRoutes(n,r)});return{fetch:t,loading:e,cancelFetch:o}}i(_f,"useFetchAllQuotes");var dx=600;function vi({refetchQuote:t}){let{fetch:e,cancelFetch:o}=_f(),{excludeLiquiditySources:n,features:r,enableCentralizedSwappers:a}=y().config,s=Z.use.connectedWallets(),{fromToken:l,toToken:p,inputAmount:u,inputUsdValue:c,selectedQuote:m,sortStrategy:g,resetQuote:d,error:f,warning:h,setSelectedQuote:S,updateQuotePartialState:C}=z(),{slippage:k,customSlippage:T,affiliatePercent:v,affiliateRef:x,affiliateWallets:N,fetchStatus:M}=y(),w=y().getLiquiditySources(),E=y().getDisabledLiquiditySources(),b=y().excludeLiquiditySources(),{findToken:W}=y(),[$,I]=mx(!0),R=ux(u),ee=T??k,L=!l||!p||so(l,p)||!sn(u),V=i(ae=>{I(ae)},"resetState"),le=i(ae=>{let{fromToken:ge,toToken:xe,inputAmount:U,liquiditySources:Ke,excludeLiquiditySources:xt,disabledLiquiditySources:lt,slippage:wt,affiliateRef:_,affiliatePercent:Q,affiliateWallets:G}=ae;if($||V(!0),!L&&ge&&xe){d();let pe=Cc({fromToken:ge,toToken:xe,inputAmount:U,liquiditySources:Ke,excludeLiquiditySources:xt,disabledLiquiditySources:lt,wallets:s,slippage:wt,affiliateRef:_,affiliatePercent:Q,affiliateWallets:G,enableCentralizedSwappers:a});Hp("experimentalRoute",r)&&(pe.experimental=!0),e(pe).then(ce=>{let de=wr(g,ce.results),he=Lc(m,de,ce.requestAmount);I(!1),C("quotes",ce),S(he),ui({diagnosisMessages:ce.diagnosisMessages,requestId:he?.requestId||"",swaps:he?.swaps});let Xn=uo(he)||xe?.usdPrice,io=mn(he)||ge?.usdPrice,ji=he&&Lo(he,{fromToken:{...ge,usdPrice:io},toToken:{...xe,usdPrice:Xn},userSlippage:ee,findToken:W});C("warning",ji)}).catch(ce=>{let{error:de}=mi(ce);(de?.type===0||de?.type===1)&&d(),de?.type!==2&&(C("error",de),I(!1))})}},"fetch"),Y=px(fp(ae=>{le(ae)},dx),[L]);return cx(()=>{if(!t){I(!1);return}if(M!=="success")return;if(L){I(!1),(m||f||h)&&d();return}if(!sn(u)||c?.eq(0)){V(!1),o();return}d(),V(!0);let ae=le;return R.current&&R.current!=u&&(ae=Y),R.current=u,ae({inputAmount:u,fromToken:l,toToken:p,liquiditySources:w,excludeLiquiditySources:b,disabledLiquiditySources:E,slippage:ee,affiliateRef:x,affiliatePercent:v,affiliateWallets:N}),o},[M,u,l?.symbol,l?.address,l?.blockchain,p?.symbol,p?.address,p?.blockchain,L,w?.length,n,E.length,ee,x,v,JSON.stringify(N)]),{fetch:()=>le({inputAmount:u,fromToken:l,toToken:p,liquiditySources:w,excludeLiquiditySources:b,disabledLiquiditySources:E,slippage:ee,affiliateRef:x,affiliatePercent:v,affiliateWallets:N}),loading:$}}i(vi,"useSwapInput");function $f(t,e){let o=!1,n={preventDefault(){o=!0},...t.payload===void 0&&{payload:t.payload}};ye.emit("uiEvent",{type:t.type,payload:n}),o||e()}i($f,"emitPreventableEvent");var kx=hx("div",{display:"flex",alignItems:"flex-start",maxHeight:700,"& .footer__alert":{paddingTop:"0 !important"}}),Tx=300;function zf(){let t=Cx(),{fromToken:e,toToken:o,inputAmount:n,selectedQuote:r,refetchQuote:a,error:s,warning:l,quotes:p,setSelectedQuote:u,resetQuoteWallets:c,setQuoteWarningsConfirmed:m,updateQuotePartialState:g}=z(),[d,f]=Uf(!1),{isLargeScreen:h,isExtraLargeScreen:S}=oi(),{fetch:C,loading:k}=vi({refetchQuote:a}),{config:T,fetchStatus:v}=y(),{connectedWallets:x}=Z(),{isActiveTab:N}=se(),[M,w]=Uf(!1),b=dc({fetchMetaStatus:v,fetchingQuote:k,inputAmount:n,quote:r,anyWalletConnected:x.length>0,error:s,warning:l,needsToWarnEthOnPath:!1}),W=_p(h,S,T?.variant),$=!!n&&!!e&&!!o&&new Sx(n).gt(0)&&!Ac(e,o),I=$&&v==="success"&&k,oe=(!W||W&&p?.results.length)&&(l||s);Of(()=>{c(),g("refetchQuote",!0)},[]),Of(()=>{f($)},[$]);let L=(r||s)&&!M?C:void 0,V=i(Y=>{W&&d?(f(!1),setTimeout(()=>{t(Y)},Tx)):t(Y)},"onHandleNavigation"),le=i(Y=>{r?.requestId!==Y.requestId&&(w(!1),u(Y))},"onClickOnQuote");return Je.createElement(kx,null,Je.createElement(ne,{height:"auto",footer:Je.createElement(gx,{type:"primary",size:"large",disabled:b.disabled||!N,prefix:b.action==="confirm-warning"&&Je.createElement(yx,null),fullWidth:!0,onClick:()=>{b.action==="connect-wallet"?$f({type:"clickConnectWallet"},()=>V(D.wallets)):b.action==="confirm-warning"?w(!0):V(D.confirmSwap)}},b.title),header:{onWallet:()=>{V(D.wallets)},hasBackButton:!1,title:T.title||fx.t("Swap"),suffix:Je.createElement(go,{hidden:W?["refresh"]:void 0,onClickRefresh:L,onClickHistory:()=>V(D.swaps),onClickSettings:()=>{V(D.settings)}})}},Je.createElement(ie,null,Je.createElement(Cl,{fetchingQuote:I,fetchMetaStatus:v,isExpandable:W,onClickToken:Y=>{V(Y==="from"?D.fromSwap:D.toSwap)}}),Je.createElement(Ff,{size:"2"}),W?null:Je.createElement(xo,{quote:r,loading:I,error:s,tagHidden:!1,warning:l,type:"basic",onClickAllRoutes:p&&p.results.length>1?()=>{g("refetchQuote",!1),V(D.routes)}:void 0}),oe?Je.createElement(Je.Fragment,null,Je.createElement(Ff,{size:"10"}),Je.createElement(kn,{warning:l,error:s,couldChangeSettings:!0,refetchQuote:C,showWarningModal:M,confirmationDisabled:!N,onOpenWarningModal:()=>w(!0),onCloseWarningModal:()=>w(!1),onConfirmWarningModal:()=>{w(!1),m(!0),V(D.confirmSwap)},onChangeSettings:()=>V(D.settings)})):null)),W?Je.createElement(gl,{loading:I,onClickOnQuote:le,fetch:C,onClickRefresh:L,isVisible:d}):null)}i(zf,"Home");import{i18n as Qf}from"@lingui/core";import{Alert as vx,Divider as xx,List as wx,ListItemButton as bx,Radio as Ex,RadioRoot as Ix,Typography as Ax}from"@rango-dev/ui";import Mt from"react";function to(){let{setLanguage:t,language:e,config:o}=y(),n=Kp,r=o?.language||Mo;return{activeLanguage:e||r,languages:n,defaultLanguage:r,changeLanguage:a=>t(a||Mo),resetLanguage:()=>t(null)}}i(to,"useLanguage");function qf(){let{activeLanguage:t,changeLanguage:e,languages:o}=to(),n=Ye(),r=o.map(a=>{let{local:s,label:l,SVGFlag:p}=a;return{id:s,value:s,title:Mt.createElement(Ax,{variant:"title",size:"xmedium"},l),onClick:()=>{e(a.local),n()},end:Mt.createElement(Ex,{value:s}),start:Mt.createElement(p,null)}});return Mt.createElement(ne,{header:{title:Qf.t("Language")}},Mt.createElement(ie,null,Mt.createElement(vx,{type:"warning",variant:"alarm",title:"Important Notice: Machine translations are in use"}),Mt.createElement(xx,{size:"8"}),Mt.createElement(Ix,{value:t},Mt.createElement(wx,{type:Mt.createElement(bx,{title:Qf.t("language"),id:"_",onClick:()=>console.log()}),items:r}))))}i(qf,"LanguagePage");import{i18n as Ot}from"@lingui/core";import{Button as Lx,Checkbox as Px,Image as Dx,ListItemButton as _x,NotFound as $x,Typography as Fx}from"@rango-dev/ui";import Ve,{useState as Ox}from"react";import{Checkbox as Mx,Skeleton as Gf}from"@rango-dev/ui";import Un from"react";import{styled as kl}from"@rango-dev/ui";var On=kl("ul",{padding:"$15 $5 0",margin:0,listStyle:"none",height:"100%",overflowY:"auto",variants:{disabled:{true:{pointerEvents:"none"}}}}),Tl=kl("div",{width:80,display:"flex",justifyContent:"flex-end"}),vl=kl("div",{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%"});import{ListItem as Nx,styled as Wx}from"@rango-dev/ui";var Hf=Wx(Nx,{height:61});var Bx=30;function xl(){return Un.createElement(On,null,Array.from(Array(Bx),(t,e)=>Un.createElement(Hf,{hasDivider:!0,key:e,start:Un.createElement(Gf,{variant:"circular",width:35,height:35}),title:Un.createElement(Gf,{variant:"text",size:"large",width:90}),end:Un.createElement(Mx,{checked:!1})})))}i(xl,"LoadingLiquiditySourceList");function wl({sourceType:t}){let e=y().fetchStatus,o=y().swappers(),n=y().getDisabledLiquiditySources(),[r,a]=Ox(""),s=y().toggleLiquiditySource,l=y().isInCampaignMode(),p=fr(o,n),u={Exchanges:Ot.t("Exchanges"),Bridges:Ot.t("Bridges")},c=[];t==="Exchanges"&&c.push("DEX"),t==="Bridges"&&c.push("BRIDGE","AGGREGATOR","OFF_CHAIN");let m=p.filter(C=>c.includes(C.type)),g=m.length===m.filter(C=>C.selected).length,d=i(()=>{m.forEach(C=>{g?s(C.groupTitle):C.selected||s(C.groupTitle)})},"toggleAllSources"),f=m.map(C=>{let{selected:k,groupTitle:T,logo:v}=C;return{start:Ve.createElement(Dx,{src:v,size:22,type:"circular"}),onClick:()=>{l||s(T)},end:Ve.createElement(Px,{checked:k,disabled:l}),title:Ve.createElement(Fx,{variant:"title",size:"xmedium"},Ot.t(T)),...C}}),h=i(C=>{let k=C.target.value;a(k)},"handleSearch"),S=f;return r&&(S=f.filter(C=>bt(C.groupTitle,r))),Ve.createElement(ne,{header:{title:Ot.t(t),suffix:Ve.createElement(Tl,null,Ve.createElement(Lx,{variant:"ghost",size:"xsmall",onClick:d},g?Ot.t("Deselect all"):Ot.t("Select all")))}},Ve.createElement(ie,{view:!0},Ve.createElement(Ct,{value:r,setValue:a,fullWidth:!0,color:"light",variant:"contained",placeholder:Ot.t("Search {sourceType}",{sourceType:u[t]}),onChange:h}),e==="loading"&&Ve.createElement(xl,null),!S.length&&r?Ve.createElement(vl,null,Ve.createElement($x,{title:Ot.t("No results found"),description:Ot.t("Try using different keywords")})):e==="success"&&Ve.createElement(On,{disabled:l},S.map(C=>{let{groupTitle:k,...T}=C;return Ve.createElement(Ve.Fragment,{key:C.id},Ve.createElement(_x,{style:{height:"61px"},...T,selected:!1,hasDivider:!0}))}))))}i(wl,"LiquiditySourcePage");import{i18n as Ux}from"@lingui/core";import xi from"react";import{useNavigate as zx}from"react-router-dom";function Vf(){let t=zx(),e=Ye(),{selectedQuote:o,refetchQuote:n,setSelectedQuote:r,updateQuotePartialState:a,error:s}=z(),{fetch:l,loading:p}=vi({refetchQuote:n}),u=i(g=>{r(g),a("refetchQuote",!1),e()},"onClickOnQuote"),c=`../${D.settings}`,m=`../${D.wallets}`;return xi.createElement(ne,{header:{onWallet:()=>{t(m),a("refetchQuote",!0)},onBack:()=>{a("refetchQuote",!1)},title:Ux.t("Routes"),suffix:xi.createElement(go,{onClickRefresh:o||s?l:void 0,hidden:["notifications","history"],onClickSettings:()=>{t(c),a("refetchQuote",!0)}})}},xi.createElement(ie,null,xi.createElement($n,{fetch:l,loading:p,onClickOnQuote:u})))}i(Vf,"RoutesPage");import{i18n as Rf}from"@lingui/core";import{Divider as eg,getCategoriesCount as Zx,SelectableCategoryList as Jx}from"@rango-dev/ui";import Ut,{useState as tg}from"react";import{useNavigate as Rx}from"react-router-dom";import{i18n as bl}from"@lingui/core";import{Divider as Gx,Image as Vx,ListItemButton as Kx,NotFound as jx,Typography as Jf}from"@rango-dev/ui";import it,{useEffect as Xx,useState as Yx}from"react";var Kf=i((t,e,o)=>t.filter(n=>Rn(n.type,o)).filter(n=>et(n.name,e)||et(n.displayName,e)),"filterBlockchains");import{ImageContainer as Qx,styled as jf}from"@rango-dev/ui";var Xf=jf("div",{display:"flex",flexDirection:"column",overflow:"hidden",height:"100%",justifyContent:"center"}),wi=jf(fn,{padding:0,margin:0,listStyle:"none",[`& ${Qx}`]:{borderRadius:"$xm",overflow:"hidden"}});import{ListItem as qx,Skeleton as Yf}from"@rango-dev/ui";import bi from"react";var Hx=20;function Zf(){return bi.createElement(wi,null,Array.from(Array(Hx),t=>bi.createElement(qx,{key:t,hasDivider:!0,start:bi.createElement(Yf,{variant:"circular",width:35,height:35}),title:bi.createElement(Yf,{variant:"text",size:"large",width:90})})))}i(Zf,"LoadingBlockchainList");function El(t){let{list:e,searchedFor:o,onChange:n,blockchainCategory:r,showTitle:a=!0}=t,[s,l]=Yx(e),{fetchStatus:p}=y();Xx(()=>{l([...Kf(e,o,r)])},[e,o,r]);let u=i(()=>!s.length&&o?it.createElement(jx,{title:bl.t("No results found"),description:bl.t("Try using different keywords")}):it.createElement(wi,{as:"ul",key:`${r}-${o}`},s.map(c=>it.createElement(Kx,{key:`${c.name}-${c.chainId}`,hasDivider:!0,onClick:()=>n(c),start:it.createElement(Vx,{src:c.logo,size:30}),title:it.createElement(Jf,{variant:"title",size:"medium"},c.displayName),id:c.chainId}))),"renderList");return it.createElement(it.Fragment,null,a&&it.createElement(it.Fragment,null,it.createElement(Jf,{variant:"label",size:"large"},bl.t("Select Blockchain")),it.createElement(Gx,{size:4})),it.createElement(Xf,null,p==="loading"&&it.createElement(Zf,null),p==="success"&&u()))}i(El,"BlockchainList");function Ei(t){let{type:e}=t,o=Ye(),[n,r]=tg(""),[a,s]=tg("ALL"),l=z.use.setToBlockchain(),p=z.use.setFromBlockchain(),{fetchStatus:u}=y(),c=Rx(),m=y().blockchains({type:e}),g=Zx(m),d=!t.hideCategory&&g!==1;return Ut.createElement(ne,{header:{title:Rf.t("Select Blockchain")}},Ut.createElement(ie,{view:!0},d&&Ut.createElement(Ut.Fragment,null,Ut.createElement(Jx,{setCategory:s,category:a,blockchains:m,isLoading:u==="loading"}),Ut.createElement(eg,{size:24})),Ut.createElement(Ct,{value:n,autoFocus:!0,placeholder:Rf.t("Search Blockchain"),color:"light",variant:"contained",size:"large",setValue:()=>r(""),onChange:f=>r(f.target.value)}),Ut.createElement(eg,{size:16}),Ut.createElement(El,{list:m,showTitle:e!=="custom-token",searchedFor:n,blockchainCategory:a,onChange:f=>{e==="custom-token"?c(`..?blockchain=${f.name}`,{replace:!0}):(e==="source"?p(f):l(f),o())}})))}i(Ei,"SelectBlockchainPage");import{i18n as Ai}from"@lingui/core";import{Divider as sg}from"@rango-dev/ui";import bo,{useState as sw}from"react";import{useNavigate as lw}from"react-router-dom";import{i18n as Nl}from"@lingui/core";import{BlockchainsChip as Ii,Divider as ig,Image as ag,Skeleton as rw,Tooltip as iw,Typography as Wl}from"@rango-dev/ui";import Pe from"react";import{useEffect as ow}from"react";var og=["ETH","COSMOS","OSMOSIS"];function Il(t,e,o){let n=JSON.parse(JSON.stringify(t)),r=[];if(n.sort(ew),o?.limit&&t.length>o.limit){let a=o.limit,s=e;if(e.length<=o.limit){let l=o.limit-e.length;for(let p=0;p<=l;p++){let u=n[p];s=s.filter(c=>u.name!==c)}}n.sort(tw(s)),r=n.splice(a)}return{list:n,more:r}}i(Il,"prepare");function ew(t,e){let o=og,n=o.findIndex(l=>l===t.name),r=o.findIndex(l=>l===e.name),a=n>-1,s=r>-1;return a&&s?n>r?1:-1:a?-1:s?1:0}i(ew,"sortByMostUsedBlockchains");function tw(t){return i(function(o,n){let r=t.findIndex(p=>p===o.name),a=t.findIndex(p=>p===n.name),s=r>-1,l=a>-1;return s&&l?r>a?1:-1:t.includes(o.name)?-1:t.includes(n.name)?1:0},"sortByPreferred")}i(tw,"generateSortByPreferredBlockchainsFor");function ng(t,e){return!!e.list.find(o=>o.name===t)}i(ng,"isInVisibleList");function Al(t,e){let{preferredBlockchains:o,addPreferredBlockchain:n}=y();ow(()=>{if(e?.selected){let a=Il(t,o,e);ng(e.selected,a)||n(e?.selected)}},[e?.selected]);let r=Il(t,o,e);return{list:r.list,more:r.more,history:[]}}i(Al,"usePrepareBlockchainList");import{styled as nw}from"@rango-dev/ui";var rg=nw("div",{display:"grid",gap:"$10",gridTemplateColumns:"repeat(6, minmax(0, 1fr))"});var aw=12;function Ml(t){let{blockchains:e,type:o,blockchain:n,onChange:r,onMoreClick:a}=t,s=Al(e,{limit:10,selected:n?.name}),{fetchStatus:l}=y(),p=z.use.resetToBlockchain(),u=z.use.resetFromBlockchain(),c=s.more.length>0,m=s.more.length===1,g=!m&&c;return Pe.createElement(Pe.Fragment,null,Pe.createElement(ig,{size:12}),Pe.createElement(Wl,{variant:"label",size:"large"},Nl.t("Select Blockchain")),Pe.createElement(ig,{size:12}),Pe.createElement(rg,null,l==="loading"&&Array.from(Array(aw),d=>Pe.createElement(rw,{key:d,variant:"rounded",height:50})),l==="success"&&Pe.createElement(Pe.Fragment,null,Pe.createElement(Ii,{selected:!n,onClick:()=>{o==="from"?u():p()}},Pe.createElement(Wl,{variant:"body",size:"xsmall",color:"secondary500"},Nl.t("All"))),s.list.map(d=>Pe.createElement(iw,{key:d.name,content:d.shortName,side:"bottom",sideOffset:2,container:A()},Pe.createElement(Ii,{key:d.name,selected:!!n&&n.name===d.name,onClick:()=>r(d)},Pe.createElement(ag,{src:d.logo,size:30})))),m?Pe.createElement(Ii,{key:s.more[0].name,selected:!!n&&n.name===s.more[0].name,onClick:()=>r(s.more[0])},Pe.createElement(ag,{src:s.more[0].logo,size:30})):null,g?Pe.createElement(Ii,{onClick:a,key:"more-blockchains"},Pe.createElement(Wl,{variant:"body",size:"xsmall",color:"secondary500"},Nl._("More +{count}",{count:s.more.length}))):null)))}i(Ml,"BlockchainsSection");function Bl(t){let{type:e}=t,o=lw(),n=Ye(),{fromBlockchain:r,toBlockchain:a,setFromToken:s,setToToken:l,setFromBlockchain:p,setToBlockchain:u}=z(),c=Z.use.getBalanceFor(),[m,g]=sw(""),f=(e==="source"?r:a)?.name??"",h=y().blockchains({type:e}),S=y().tokens({type:e,blockchain:f,searchFor:m,getBalanceFor:c}),C=i(v=>{e==="source"?p(v):u(v)},"updateBlockchain"),k=i(v=>{e==="source"?s({token:v,meta:{blockchains:h,tokens:S}}):l({token:v,meta:{blockchains:h,tokens:S}})},"updateToken"),T={source:Ai.t("Source"),destination:Ai.t("Destination")};return bo.createElement(ne,{header:{title:Ai.t("Swap {type}",{type:T[e]})}},bo.createElement(ie,null,bo.createElement(Ml,{blockchains:h,type:e=="source"?"from":"to",blockchain:e==="source"?r:a,onMoreClick:()=>o(D.blockchains),onChange:v=>{C(v)}}),bo.createElement(sg,{size:24}),bo.createElement(Ct,{value:m,autoFocus:!0,placeholder:Ai.t("Search Token"),color:"light",variant:"contained",size:"large",setValue:()=>g(""),onChange:v=>g(v.target.value)}),bo.createElement(sg,{size:16}),bo.createElement(Mn,{list:S,selectedBlockchain:f,searchedFor:m,type:e,onChange:v=>{k(v);let x=h.find(N=>v.blockchain===N.name);x&&C(x),n()}})))}i(Bl,"SelectSwapItemsPage");import{i18n as Dl}from"@lingui/core";import{Alert as Pw,Button as Dw,styled as _w}from"@rango-dev/ui";import Eo from"react";import{useInRouterContext as $w,useSearchParams as Fw}from"react-router-dom";import{i18n as dg}from"@lingui/core";import{Divider as fg,InfoIcon as mw,SlippageIcon as dw,TextField as fw,Tooltip as gw,Typography as gg}from"@rango-dev/ui";import at from"react";import{Chip as pw,styled as zn,TextField as cw}from"@rango-dev/ui";var lg=zn("div",{paddingTop:"$5",padding:"$10 $5"}),pg=zn("div",{display:"flex",flexWrap:"wrap",gap:"$10",[`& ${cw}`]:{flex:"1 1 0",maxWidth:"127px",minWidth:"85px"}}),cg=zn("div",{display:"flex",justifyContent:"start",alignItems:"center",paddingBottom:"$10"}),Ni=zn("div",{maxWidth:"280px",padding:"$10"}),ug=zn(pw,{width:"61px",flexShrink:0});import{i18n as Ll}from"@lingui/core";import{Typography as uw}from"@rango-dev/ui";import Qn from"react";function mg(){return Qn.createElement(Ni,null,Qn.createElement(uw,{variant:"label",size:"medium",color:"neutral700"},Ll.t("Your transaction will be reverted if the price changes unfavorably by more than this percentage"),Qn.createElement("br",null),Qn.createElement("br",null),Qn.createElement("b",null,Ll.t("Warning")),":",Ll.t("This setting is applied per step (e.g. 1Inch, Thorchain, etc) which means only the step will be reverted, not the whole transaction.")))}i(mg,"SlippageTooltipContent");function Pl(){let{slippage:t,setSlippage:e,customSlippage:o,setCustomSlippage:n}=y();return at.createElement(lg,null,at.createElement(cg,null,at.createElement(dw,{size:16,color:"gray"}),at.createElement(fg,{direction:"horizontal",size:4}),at.createElement(gg,{variant:"title",size:"xmedium"},dg.t("Slippage tolerance per swap")),at.createElement(fg,{direction:"horizontal",size:4}),at.createElement(gw,{container:A(),side:"top",sideOffset:4,content:at.createElement(mg,null)},at.createElement(mw,{color:"gray"}))),at.createElement(pg,null,jp.map((r,a)=>{let s=`slippage-${a}`;return at.createElement(ug,{key:s,onClick:()=>{o&&n(null),e(r)},selected:!o&&r===t,label:`${r.toString()}%`})}),at.createElement(fw,{type:"number",min:"0.01",max:"30",step:"0.01",fullWidth:!0,variant:"contained",value:o===null?"":o,color:"dark",onChange:r=>{let a=r.target.value,s=parseFloat(a);s>=Jp&&s<=Zp?n(s):n(null)},suffix:o&&at.createElement(gg,{variant:"body",size:"small"},"%"),placeholder:dg.t("Custom")})))}i(Pl,"Slippage");import{i18n as Tt}from"@lingui/core";import{AutoThemeIcon as hg,BridgesIcon as hw,ChevronRightIcon as Wi,DarkModeIcon as yg,Divider as qn,ExchangeIcon as yw,InfinityIcon as Sw,InfoIcon as Cw,LanguageIcon as kw,LightModeIcon as Sg,List as Tw,ListItem as vw,ListItemButton as xw,Skeleton as ww,styled as bw,Switch as Ew,Tabs as Iw,TargetIcon as Aw,Tooltip as Nw,Typography as Re}from"@rango-dev/ui";import P from"react";import{useNavigate as Ww}from"react-router-dom";var Mw=bw("div",{width:"202px",height:"$40"}),Bw=[{id:"light",icon:P.createElement(Sg,{color:"black",size:24}),tooltip:P.createElement(Re,{size:"xsmall",variant:"body"},Tt.t("Light"))},{id:"dark",icon:P.createElement(yg,{color:"black",size:24}),tooltip:P.createElement(Re,{size:"xsmall",variant:"body"},Tt.t("Dark"))},{id:"auto",icon:P.createElement(hg,{color:"black",size:24}),tooltip:P.createElement(Re,{size:"xsmall",variant:"body"},Tt.t("Auto"))}],Lw=i(t=>{let e={color:"gray",size:16};switch(t){case"auto":return P.createElement(hg,{...e});case"dark":return P.createElement(yg,{...e});default:return P.createElement(Sg,{...e})}},"getThemeIcon");function Cg(){let t=Ww(),{theme:e}=y().config,{setTheme:o,theme:n}=y(),{activeLanguage:r,languages:a}=to(),s=a.find(L=>L.local===r)?.label,l=y().fetchStatus,p=y().swappers(),u=y().getDisabledLiquiditySources(),{config:{features:c}}=y(),m=y().customTokens(),g=je("theme",c),d=je("liquiditySource",c),f=je("language",c),h=je("customTokens",c),S=y().infiniteApprove,C=y().toggleInfiniteApprove,k=fr(p,u),T=k.filter(L=>["BRIDGE","AGGREGATOR","OFF_CHAIN"].includes(L.type)),v=T.length,x=T.filter(L=>L.selected).length,N=k.filter(L=>L.type==="DEX"),M=N.length,w=N.filter(L=>L.selected).length,E=i((L,V)=>{switch(l){case"loading":return P.createElement(ww,{variant:"text",size:"medium",width:50});case"failed":return P.createElement(Re,{variant:"body",size:"medium",color:"$error500"},Tt.t("Loading failed"));default:return P.createElement(Re,{variant:"body",size:"medium"},`${L} / ${V}`)}},"handleSwapperEndItem"),b={id:"bridge-item",title:P.createElement(Re,{variant:"title",size:"xmedium"},Tt.t("Bridges")),end:P.createElement(P.Fragment,null,E(x,v),P.createElement(qn,{direction:"horizontal",size:8}),P.createElement(Wi,{color:"black"})),onClick:()=>t(D.bridges),start:P.createElement(hw,{color:"gray",size:16})},W={id:"exchange-item",title:P.createElement(Re,{variant:"title",size:"xmedium"},Tt.t("Exchanges")),end:P.createElement(P.Fragment,null,E(w,M),P.createElement(qn,{direction:"horizontal",size:8}),P.createElement(Wi,{color:"black"})),start:P.createElement(yw,{color:"gray",size:16}),onClick:()=>t(D.exchanges)},$={id:"custom-tokens-item",title:P.createElement(Re,{variant:"title",size:"xmedium"},Tt.t("Custom Tokens")),end:P.createElement(P.Fragment,null,P.createElement(Re,{variant:"body",size:"medium"},`${m.length}`),P.createElement(qn,{direction:"horizontal",size:8}),P.createElement(Wi,{color:"black"})),start:P.createElement(Aw,{color:"gray",size:16}),onClick:()=>t(D.customTokens)},I={id:"language-item",title:P.createElement(Re,{variant:"title",size:"xmedium"},Tt.t("Language")),start:P.createElement(kw,{color:"gray",size:16}),end:P.createElement(P.Fragment,null,P.createElement(Re,{variant:"body",size:"medium"},s),P.createElement(qn,{direction:"horizontal",size:8}),P.createElement(Wi,{color:"black"})),onClick:()=>t(D.languages)},R={id:"infinite-approval-item",title:P.createElement(P.Fragment,null,P.createElement(Re,{variant:"title",size:"xmedium"},Tt.t("Infinite approval")),P.createElement(qn,{direction:"horizontal",size:4}),P.createElement(Nw,{side:"top",sideOffset:4,container:A(),content:P.createElement(Ni,null,P.createElement(Re,{variant:"label",size:"medium",color:"neutral700"},Tt.t("Enabling the 'Infinite approval' mode grants unrestricted access to smart contracts of DEXes/Bridges, allowing them to utilize the approved token amount without limitations.")))},P.createElement(Cw,{color:"gray"}))),start:P.createElement(Sw,{color:"gray",size:16}),end:P.createElement(Ew,{checked:S}),onClick:C},ee={id:"theme-item",type:P.createElement(vw,null),title:P.createElement(Re,{variant:"title",size:"xmedium"},Tt.t("Theme")),end:P.createElement(Mw,null,P.createElement(Iw,{container:A(),items:Bw,value:n,onChange:L=>o(L.id),type:"primary",borderRadius:"small"})),start:Lw(n)},oe=d?[]:[b,W];return h||oe.push($),f||oe.push(I),oe.push(R),!e?.singleTheme&&!g&&oe.push(ee),P.createElement(Tw,{type:P.createElement(xw,{hasDivider:!0,id:"_",onClick:()=>console.log()}),items:oe})}i(Cg,"SettingsLists");var Ow=_w("div",{paddingLeft:"$8"});function kg(){let{isInCampaignMode:t,updateCampaignMode:e}=y(),o=t(),[,n]=Fw(),r=$w(),a=i(()=>{r&&o&&(n(s=>(s.delete("liquiditySources"),s),{replace:!0}),e("liquiditySources",void 0))},"onClick");return Eo.createElement(ne,{header:{title:Dl.t("Settings")}},Eo.createElement(ie,null,o&&Eo.createElement(Pw,{type:"info",variant:"alarm",title:Dl.t("Currently, you're in campaign mode with restrictions on liquidity sources. Would you like to switch out of this mode and make use of all available liquidity sources?"),action:Eo.createElement(Ow,null,Eo.createElement(Dw,{type:"secondary",size:"small",onClick:a},Dl.t("Reset")))}),Eo.createElement(Pl,null),Eo.createElement(Cg,null)))}i(kg,"SettingsPage");import{i18n as Eb}from"@lingui/core";import{cancelSwap as Ib}from"@rango-dev/queue-manager-rango-preset";import{useManager as Ab}from"@rango-dev/queue-manager-react";import{Alert as Nb}from"@rango-dev/ui";import Jl from"react";import{useParams as Wb}from"react-router-dom";import{i18n as st}from"@lingui/core";import{getCurrentBlockchainOfOrNull as sb,getCurrentStep as lb,getRelatedWalletOrNull as pb}from"@rango-dev/queue-manager-rango-preset";import{Button as Zg,CopyIcon as cb,Divider as ub,DoneIcon as mb,IconButton as db,QuoteCost as fb,RangoExplorerIcon as gb,StepDetails as hb,Tooltip as Jg,Typography as Io,useCopyToClipboard as yb}from"@rango-dev/ui";import{useWallets as Sb}from"@rango-dev/wallets-react";import Rg from"bignumber.js";import{PendingSwapNetworkStatus as Oi}from"rango-types";import K,{useEffect as eh,useRef as Cb,useState as th}from"react";import{useNavigate as kb}from"react-router-dom";import{i18n as oo}from"@lingui/core";var Uw=[oo.t("Sunday"),oo.t("Monday"),oo.t("Tuesday"),oo.t("Wednesday"),oo.t("Thursday"),oo.t("Friday"),oo.t("Saturday")];function Tg(t){let e=new Date(t),o=e.getDate(),n=e.toLocaleString("default",{month:"long"}),r=e.getFullYear();return`${e.getDay()===new Date().getDay()?oo.t("Today"):`${Uw[e.getDay()]} ${o} ${n} ${r}`}, ${new Date(t).toLocaleTimeString()}`}i(Tg,"timeSince");function vg(t){return t.finishTime?Tg(parseInt(t.finishTime)):Tg(parseInt(t.creationTime))}i(vg,"getSwapDate");import{PendingSwapNetworkStatus as Li}from"rango-types";import Pi from"react";import{i18n as Mi}from"@lingui/core";import{Button as xg,Divider as _l,MessageBox as zw}from"@rango-dev/ui";import no from"react";var wg=i(({onCancel:t,onClose:e})=>no.createElement(no.Fragment,null,no.createElement(_l,{size:20}),no.createElement(zw,{type:"error",title:Mi.t("Cancel Swap"),description:Mi.t("Are you sure you want to cancel this swap?")}),no.createElement(_l,{size:32}),no.createElement(xg,{variant:"contained",type:"primary",size:"large",onClick:t},Mi.t("Yes, Cancel it")),no.createElement(_l,{size:12}),no.createElement(xg,{variant:"outlined",type:"primary",size:"large",onClick:e},Mi.t("No, Continue"))),"CancelContent");import{i18n as Bi}from"@lingui/core";import{Button as bg,Divider as $l,MessageBox as Qw,Typography as qw}from"@rango-dev/ui";import zt from"react";var Eg=i(({onDelete:t,onClose:e})=>zt.createElement(zt.Fragment,null,zt.createElement($l,{size:20}),zt.createElement(Qw,{type:"error",title:Bi.t("Delete Transaction"),description:Bi.t("Are you sure you want to delete this swap?")}),zt.createElement($l,{size:32}),zt.createElement(bg,{variant:"contained",type:"primary",size:"large",onClick:t},Bi.t("Yes, Delete it")),zt.createElement($l,{size:12}),zt.createElement(bg,{variant:"outlined",type:"primary",size:"large",onClick:e},zt.createElement(qw,{variant:"title",size:"medium",color:"primary"},Bi.t("No, Cancel")))),"DeleteContent");import{i18n as Fl}from"@lingui/core";import{PendingSwapNetworkStatus as Ol}from"rango-types";var Ul={[Ol.WaitingForNetworkChange]:{type:"loading",title:Fl.t("Change Network")},[Ol.WaitingForConnectingWallet]:{type:"warning",title:Fl.t("Connect Wallet")},[Ol.NetworkChanged]:{type:"success",title:Fl.t("Network Changed")}};import{warn as Hw}from"@rango-dev/logging-core";import{MessageBox as Gw,Wallet as Vw}from"@rango-dev/ui";import{useWallets as Kw}from"@rango-dev/wallets-react";import Ro,{useState as jw}from"react";import{styled as Ig}from"@rango-dev/ui";var Ag=Ig("div",{display:"flex",justifyContent:"center"}),D2=Ig("div",{maxWidth:280,"& ._typography":{wordWrap:"break-word",display:"block"}});var Ng=i(t=>{let{type:e,title:o,currentStepWallet:n,message:r,showWalletButton:a,walletButtonDisabled:s}=t,[l,p]=jw(),{getWalletInfo:u,state:c}=Kw(),m=n?.walletType,g=m?ln(c(m)):null,d=m?u(m):null,f=a&&!!m&&!!g&&!!d,{list:h}=ht(),S=i(()=>{if(m){let C=h.find(k=>k.type===m);C?p(C):Hw(new Error(`It seems requested wallet to be connected is not available in the list. requested wallet: ${C}`))}},"handleWalletItemClick");return Ro.createElement(Ro.Fragment,null,Ro.createElement(Gw,{type:e,title:o,description:r}),f&&Ro.createElement(Ag,null,Ro.createElement(Vw,{container:A(),title:d.name,image:d.img,type:m,state:g,link:d.installLink,disabled:s,onClick:S})),Ro.createElement(So,{wallet:l,onClose:()=>{p(void 0)}}))},"WalletStateContent");function zl(t){let{state:e,onClose:o,onDelete:n,onCancel:r,currentStepWallet:a,message:s,walletButtonDisabled:l}=t,p=e===Li.WaitingForNetworkChange||e===Li.WaitingForConnectingWallet||e===Li.NetworkChanged;return Pi.createElement(J,{open:!!e,onClose:o,container:document.getElementById(_e.SWAP_BOX_ID)||document.body},p&&Pi.createElement(Ng,{type:Ul[e].type,title:Ul[e].title,currentStepWallet:a,message:s,walletButtonDisabled:l,showWalletButton:e!==Li.WaitingForNetworkChange}),e==="delete"&&Pi.createElement(Eg,{onClose:o,onDelete:n}),e==="cancel"&&Pi.createElement(wg,{onClose:o,onCancel:r}))}i(zl,"SwapDetailsModal");import{i18n as Hn}from"@lingui/core";import{Button as Ql,Divider as Di,MessageBox as Wg,TokenAmount as Xw,Typography as ql}from"@rango-dev/ui";import Oe from"react";import{useNavigate as Yw}from"react-router-dom";function Hl(t){let{open:e,onClose:o,status:n,priceValue:r,usdValue:a,realUsdValue:s,realValue:l,token:p,chain:u,percentageChange:c,description:m,diagnosisUrl:g}=t,d=Yw();return Oe.createElement(J,{open:e,onClose:o,container:document.getElementById(_e.SWAP_BOX_ID)||document.body},n==="success"?Oe.createElement(Wg,{type:"success",title:Hn.t("Swap Successful")},Oe.createElement(Xw,{direction:"vertical",tooltipContainer:A(),type:"output",centerAlign:!0,price:{value:r,usdValue:a,realUsdValue:s,realValue:l},token:p,chain:u,percentageChange:c}),Oe.createElement(Di,{size:12}),Oe.createElement(ql,{variant:"body",size:"medium",color:"neutral700",align:"center"},m)):Oe.createElement(Wg,{type:"error",title:Hn.t("Transaction Failed"),description:m}),Oe.createElement(Di,{size:32}),n==="success"&&Oe.createElement(Ql,{variant:"contained",type:"primary",size:"large",onClick:()=>{d("../../")}},Oe.createElement(ql,{variant:"title",size:"medium",color:"neutral100"},Hn.t("Done"))),Oe.createElement(Di,{size:12}),g&&Oe.createElement(Oe.Fragment,null,Oe.createElement(Ql,{variant:"contained",type:"primary",size:"large",onClick:()=>window.open(g,"_blank")},Hn.t("Diagnosis")),Oe.createElement(Di,{size:12})),Oe.createElement(Ql,{variant:"outlined",type:"primary",size:"large",onClick:o},Oe.createElement(ql,{variant:"title",size:"medium",color:"primary"},Hn.t("See Details"))))}i(Hl,"SwapDetailsCompleteModal");import ab from"react";import{i18n as ob}from"@lingui/core";import{Alert as Kg,IconButton as nb,LinkIcon as rb}from"@rango-dev/ui";import ro,{Fragment as ib}from"react";import{Alert as Jw,ChevronDownIcon as Rw,IconButton as eb}from"@rango-dev/ui";import tn,{useState as tb}from"react";import{css as Gn,darkTheme as Mg,styled as Qt,Typography as Zw}from"@rango-dev/ui";var Bg=Qt("div",{display:"flex",flexDirection:"column",flexGrow:1,overflow:"hidden"}),_i=Qt("div",{width:"100%","& ._icon-button":{"&:hover":{"& svg":{color:"$secondary550",[`.${Mg} &`]:{color:"$secondary500"}}}}}),Lg=Qt(fn,{padding:"$0 $20 $20 $20"}),S5=Qt("div",{display:"flex",flexDirection:"column",gap:"$10"}),Pg=Qt("div",{height:"450px",display:"flex",alignItems:"center",justifyContent:"center"}),C5=Qt("div",{display:"flex",justifyContent:"center",width:"100%",paddingTop:"33%",flex:1}),en=Gn({display:"flex",width:"100%",justifyContent:"space-between",alignItems:"center",padding:"$10 $20",borderBottom:"1px solid",$$color:"$colors$neutral300",[`.${Mg} &`]:{$$color:"$colors$neutral400"},borderColor:"$$color",color:"$neutral500"}),Dg=Gn({padding:"$5 0"}),$i=Gn({display:"flex",justifyContent:"center",alignItems:"center",height:"$24"}),_g=Gn({display:"flex",width:"100%",padding:"$15 $20 $20",flexDirection:"column",alignItems:"start"}),$g=Gn({width:"100%",padding:"0 $20 $10"}),Fg=Qt("a",{fontSize:"$16",fontWeight:"$400",color:"$neutral700",display:"flex",alignItems:"center",justifyContent:"center"}),Og=Qt("div",{display:"flex",flexDirection:"column",gap:"$5"}),Fi=Qt(Zw,{wordBreak:"break-word"});import{styled as Gl}from"@rango-dev/ui";var Ug=Gl("div",{display:"flex",flexDirection:"column",gap:"$10"}),zg=Gl("div",{transition:"transform 0.3s ease-in-out",variants:{rotated:{true:{transform:"rotate(180deg)"}}}}),Qg=Gl("div",{transition:"max-height 0.3s ease-in-out",maxHeight:"0px",overflow:"hidden",variants:{open:{true:{maxHeight:"200px"}}}});function qg(t){let{message:e}=t,[o,n]=tb(!1);return tn.createElement(Jw,{type:"error",title:e.shortMessage,containerStyles:{"& .footer":{paddingTop:"$0"}},action:e.detailedMessage.content&&tn.createElement(eb,{onClick:()=>n(r=>!r),variant:"ghost",size:"xsmall"},tn.createElement(zg,{rotated:o},tn.createElement(Rw,{size:12,color:"gray"}))),footer:tn.createElement(Qg,{open:o},tn.createElement(Fi,{variant:"body",size:"xsmall",color:"neutral700"},e.detailedMessage.content))})}i(qg,"FailedAlert");import{i18n as Hg}from"@lingui/core";import{Alert as Vl,Button as Gg}from"@rango-dev/ui";import{PendingSwapNetworkStatus as Kl}from"rango-types";import Vn from"react";function Vg(t){let{switchNetwork:e,setNetworkModal:o,message:n,showNetworkModal:r}=t;return e?Vn.createElement(Vl,{type:"warning",title:n.shortMessage,action:Vn.createElement(Gg,{size:"xxsmall",type:"warning",onClick:()=>{o(Kl.WaitingForNetworkChange),e().catch(a=>{console.log(a)})}},Hg.t("Change"))}):r===Kl.WaitingForConnectingWallet?Vn.createElement(Vl,{type:"warning",title:n.shortMessage,action:Vn.createElement(Gg,{size:"xxsmall",type:"warning",onClick:()=>{o(Kl.WaitingForConnectingWallet)}},Hg.t("Connect"))}):Vn.createElement(Vl,{type:"warning",title:n.shortMessage})}i(Vg,"WarningAlert");function jl(t){let{switchNetwork:e,showNetworkModal:o,setNetworkModal:n,message:r,step:a,hasAlreadyProceededToSign:s}=t,l=un(a),p=a.status==="waitingForApproval"&&!l,u=a.status==="running"&&!l,c=u&&!s||p&&!a.explorerUrl?.length;return ro.createElement(Ug,null,a.explorerUrl?.map((m,g,d)=>{let f=g+m.url,h=g===d.length-1,S=(h&&u||p)&&!c,C=h&&a.status==="failed";return ro.createElement(ib,{key:f},ro.createElement(Kg,{type:h&&(S&&"loading"||C&&"error")||"success",title:m.description?`${m.description} Tx`:ob.t("View transaction"),action:m.url&&ro.createElement(nb,{variant:"ghost",size:"xsmall",onClick:()=>window.open(m.url,"_blank")},ro.createElement(rb,{size:12}))}))}),c&&ro.createElement(Kg,{type:"loading",title:r.shortMessage}),a.status!=="failed"&&l&&ro.createElement(Vg,{switchNetwork:e,showNetworkModal:o,setNetworkModal:n,message:r}),a.status==="failed"&&ro.createElement(qg,{message:r}))}i(jl,"SwapDetailsAlerts");var jg=2e3;var Xg=i(({swap:t,blockchains:e,swappers:o,...n})=>{let r=t.hasAlreadyProceededToSign!==!1;return t.steps.map((a,s)=>{let l=s===0?t.inputAmount:t.steps[s-1].outputAmount||t.steps[s-1].expectedOutputAmountHumanReadable;return{from:{token:{displayName:a.fromSymbol,image:a.fromLogo??""},chain:{displayName:pt(a.fromBlockchain,e)??"",image:a.fromBlockchainLogo??""},price:{value:B(l,6,6),realValue:l??""}},to:{token:{displayName:a.toSymbol,image:a.toLogo},chain:{displayName:pt(a.toBlockchain,e)??"",image:a.toBlockchainLogo??""},price:{value:B(a.outputAmount||a.expectedOutputAmountHumanReadable,6,6),realValue:a.outputAmount||a.expectedOutputAmountHumanReadable||""}},swapper:{displayName:nn(a.swapperId,o)??"",image:a.swapperLogo??"",type:a.swapperType},internalSwaps:a.internalSwaps?a.internalSwaps.map(p=>({from:{chain:{displayName:pt(p.fromBlockchain,e)??"",image:p.fromBlockchainLogo??""}},to:{chain:{displayName:pt(p.toBlockchain,e)??"",image:p.toBlockchainLogo??""}},swapper:{displayName:nn(p.swapperId,o)??"",image:p.swapperLogo??"",type:p.swapperType}})):[],alerts:ab.createElement(jl,{step:a,hasAlreadyProceededToSign:r,...n})}})},"getSteps");function Yg(t){if(un(t)&&t.status!=="failed"&&t.status!=="success")return"warning";switch(t.status){case"created":return"default";case"approved":case"waitingForApproval":case"running":return"in-progress";case"failed":return"error";case"success":return"completed"}}i(Yg,"getStepState");function Xl(t){let{swap:e,requestId:o,onDelete:n,onCancel:r}=t,{canSwitchNetworkTo:a,connect:s,getWalletInfo:l}=Sb(),p=y().blockchains(),u=y().swappers(),{findToken:c}=y(),m=z.use.retry(),g=se.use.isActiveTab(),d=kb(),[f,h]=yb(jg),S=Cb(null),[C,k]=th(null),[T,v]=th(null),x=i(()=>{r(),k(null)},"onCancel"),N=we.use.getNotifications(),M=we.use.removeNotification(),w=N(),E=lb(e),b=E?.networkStatus;eh(()=>{w.find(he=>he.requestId===e.requestId)&&(e.status==="success"||e.status==="failed"?(v(e.status),M(e.requestId)):T&&v(null))},[e.status,e.requestId]),eh(()=>{L?k(Oi.WaitingForNetworkChange):b===Oi.WaitingForConnectingWallet||b===Oi.NetworkChanged?k(b):k(null)},[b]);let W=bc(e),$=E?sb(e,E):null,I=E?pb(e,E):null,R=vg(e),ee=Ec(e),oe=i(de=>!!l(de)?.mobileWallet,"isMobileWallet"),L=b===Oi.WaitingForNetworkChange&&!!$&&!!I?.walletType&&(oe(I.walletType)||a(I.walletType,$)),V=L?s.bind(null,I.walletType,$):void 0,le=wc(e,E),Y=Xg({swap:e,switchNetwork:V,showNetworkModal:b,setNetworkModal:k,message:le,blockchains:p,swappers:u}),ae=Y.length,[ge,xe]=[e.steps[0],e.steps[ae-1]],U=xe.outputAmount||xe.expectedOutputAmountHumanReadable,Ke=e.steps.reduce((de,he)=>de+parseFloat(he.feeInUsd||""),0),xt=e.steps.find(de=>de.diagnosisUrl)?.diagnosisUrl,lt=B(parseFloat(U||"0")*(xe.toUsdPrice||0),4,4),wt=B(parseFloat(e.inputAmount)*(ge.fromUsdPrice||0),4,4),_=U?new Rg(U).multipliedBy(xe.toUsdPrice||0).toString():"",Q=new Rg(e.inputAmount).multipliedBy(ge.fromUsdPrice||0).toString(),G=ut(wt,lt),pe=le.detailedMessage.content||le.shortMessage,ce=e.status==="success"?st.t({id:"You have received {amount} {token} in {conciseAddress} wallet on {chain} chain.",values:{amount:B(U,6,6),token:Y[ae-1].to.token.displayName,conciseAddress:lr(e.wallets[Y[ae-1].to.chain.displayName]?.address||""),chain:Y[ae-1].to.chain.displayName}}):K.createElement(Og,null,K.createElement(Io,{variant:"body",size:"medium",color:"neutral700",align:"center"},pe?"":st.t("Transaction was not sent."),W?`${st.t({id:"{amount} {symbol} on {blockchain} remain in your wallet",values:{amount:W.outputAmount,symbol:W.symbol,blockchain:W.blockchain}})}`:""),pe&&K.createElement(Fi,{align:"center",variant:"body",size:"medium",color:"neutral700"},K.createElement("b",null,"Reason:")," ",pe));return K.createElement(ne,{header:{title:st.t("Swap Details"),onCancel:e.status==="running"?()=>k("cancel"):void 0,suffix:e.status!=="running"&&K.createElement(Kt,null,K.createElement(Zg,{variant:"ghost",type:"error",size:"xsmall",onClick:()=>k("delete")},K.createElement(Io,{size:"medium",variant:"label",color:"error"},st.t("Delete"))))},footer:ee&&!T&&K.createElement(Zg,{fullWidth:!0,variant:"contained",type:"primary",size:"large",onClick:()=>{let de=xr(e,p,c);m(de),setTimeout(()=>{d("../../")},0)}},st.t("Try again"))},K.createElement(ie,{compact:!0,view:!0},K.createElement(_i,null,K.createElement("div",{className:en()},K.createElement(Io,{variant:"label",size:"large",color:"neutral700"},`${st.t("Request ID")}:`),K.createElement("div",{className:$i()},K.createElement(Io,{variant:"label",size:"small",color:"neutral700"},o),K.createElement(Jg,{container:A(),content:f?st.t("Copied To Clipboard"):st.t("Copy Request ID"),open:f||void 0,side:"bottom",alignOffset:-16,align:"end"},K.createElement(db,{variant:"ghost",onClick:h.bind(null,o||"")},f?K.createElement(mb,{size:16,color:"secondary"}):K.createElement(cb,{size:16,color:"gray"}))),K.createElement(Fg,{target:"_blank",href:`${ap}/swap/${o}`},K.createElement(Jg,{container:A(),content:st.t("View on Rango Explorer"),side:"bottom"},K.createElement(gb,{size:20}))))),K.createElement("div",{className:en()},K.createElement(Io,{variant:"label",size:"large",color:"neutral700"},e.finishTime?st.t("Finished at"):st.t("Created at")),K.createElement(Io,{variant:"label",size:"small",color:"neutral700"},R))),K.createElement("div",{className:_g()},K.createElement(fb,{fee:B(String(Ke),2,2),time:an(tr(e.steps)),steps:ae}),K.createElement(vn,{from:{price:{value:B(e.inputAmount,6,6),usdValue:wt,realUsdValue:Q,realValue:e.inputAmount},token:{displayName:Y[0].from.token.displayName,image:Y[0].from.token.image},chain:{image:Y[0].from.chain.image,displayName:Y[0].from.chain.displayName}},to:{price:{value:B(U,6,6),usdValue:lt,realUsdValue:_,realValue:U||""},token:{displayName:Y[ae-1].to.token.displayName,image:Y[ae-1].to.token.image},chain:{image:Y[ae-1].to.chain.image,displayName:Y[ae-1].to.chain.displayName}},percentageChange:B(G,2,2),warningLevel:Lt(G??0)})),K.createElement("div",{className:$g()},K.createElement(Io,{variant:"title",size:"small"},st.t("Swaps steps"))),K.createElement(ub,{size:8}),K.createElement(Lg,{ref:S},Y.map((de,he)=>{let Xn=he,io=Yg(e.steps[he]),ji=io==="error"||io==="in-progress"||io==="warning"||io==="completed"&&he===Y.length-1;return K.createElement(hb,{key:Xn,step:de,type:"swap-progress",ref:S,state:io,hasSeparator:he!==0,tabIndex:Xn,isFocused:ji,tooltipContainer:A()})}))),K.createElement(zl,{state:C,onClose:()=>k(null),onCancel:x,onDelete:n,message:le.detailedMessage.content,currentStepWallet:I,walletButtonDisabled:!g}),K.createElement(Hl,{open:!!T,diagnosisUrl:xt,onClose:()=>v(null),status:e.status==="success"?"success":"failed",priceValue:B(U,6,6),usdValue:lt,realUsdValue:_,realValue:U||"",percentageChange:B(G,2,2),token:{displayName:Y[ae-1].to.token.displayName,image:Y[ae-1].to.token.image},chain:{image:Y[ae-1].to.chain.image},description:ce}))}i(Xl,"SwapDetails");import{i18n as zi}from"@lingui/core";import{Divider as rh,NotFound as bb,Skeleton as jn,Typography as Qi}from"@rango-dev/ui";import ke from"react";import{i18n as Tb}from"@lingui/core";import{Divider as vb,Skeleton as xb,Typography as wb}from"@rango-dev/ui";import ve from"react";import{css as vt,styled as Yl}from"@rango-dev/ui";var oh=Yl("div",{width:"100%",height:"100%",padding:"$10 $20"}),Kn=Yl("div",{backgroundColor:"$neutral100",borderRadius:"$xm",padding:"$10 $15"}),Ui=Yl("div",{width:"0px",height:"$20",borderLeft:"1px dashed $neutral700",marginLeft:"25px"}),M4=vt({display:"flex",justifyContent:"space-between",alignItems:"center"}),B4=vt({display:"flex",justifyContent:"space-between",alignItems:"center"}),L4=vt({paddingTop:"$15",display:"flex"}),P4=vt({padding:"$15 $0"}),D4=vt({width:"0px",height:"$16",borderLeft:"1px solid $neutral400",marginLeft:"13px"}),_4=vt({paddingBottom:"$10"}),$4=vt({display:"flex",justifyContent:"start",alignItems:"center"}),F4=vt({paddingTop:"$5",display:"flex",alignItems:"center"}),O4=vt({display:"flex",alignItems:"center"}),U4=vt({padding:"$4 $6",display:"flex",justifyContent:"center",alignItems:"center"}),nh=vt({display:"flex",paddingTop:"$10",paddingBottom:"$5"});function Zl(){return ve.createElement(oh,null,ve.createElement(bn,{type:"swap-preview"}),ve.createElement("div",{className:"swaps-steps"},ve.createElement(wb,{variant:"title",size:"small"},Tb.t("Swaps steps"))),ve.createElement(ve.Fragment,null,ve.createElement(Kn,null,ve.createElement(Wt,{separator:!1}),ve.createElement("div",{className:nh()},ve.createElement(vb,{direction:"horizontal",size:20}),ve.createElement(xb,{height:22,variant:"rectangular"}))),ve.createElement(Ui,null),ve.createElement(Kn,null,ve.createElement(Wt,{separator:!1})),ve.createElement(Ui,null),ve.createElement(Kn,null,ve.createElement(Wt,{separator:!1})),ve.createElement(Ui,null),ve.createElement(Kn,null,ve.createElement(Wt,{separator:!1}))))}i(Zl,"LoadingSwapDetails");function ih(t){let{requestId:e,showSkeleton:o}=t;return ke.createElement(ne,{header:{title:zi.t("Swap Details"),suffix:ke.createElement(Kt,null)}},o&&ke.createElement(Bg,null,ke.createElement(_i,null,ke.createElement("div",{className:en()},ke.createElement(Qi,{variant:"label",size:"large",color:"neutral700"},`${zi.t("Request ID")}:`),ke.createElement("div",{className:$i()},ke.createElement(Qi,{variant:"label",size:"small",color:"neutral700"},ke.createElement(jn,{width:60,height:10,variant:"rounded"})),ke.createElement(rh,{direction:"horizontal",size:4}),ke.createElement(jn,{width:16,height:16,variant:"rectangular"}),ke.createElement(rh,{direction:"horizontal",size:4}),ke.createElement(jn,{width:16,height:16,variant:"rectangular"}))),ke.createElement("div",{className:en()},ke.createElement(Qi,{className:Dg(),variant:"label",size:"large",color:"neutral700"},ke.createElement(jn,{width:60,height:10,variant:"rounded"})),ke.createElement(Qi,{variant:"label",size:"small",color:"neutral700"},ke.createElement(jn,{width:60,height:10,variant:"rounded"})))),ke.createElement(Zl,null)),!o&&ke.createElement(Pg,null,ke.createElement(bb,{title:zi.t("Not found"),description:zi.t({id:"Swap with request ID = {requestId} not found.",values:{requestId:e}})})))}i(ih,"SwapDetailsPlaceholder");function ah(){let{manager:t,state:e}=Ab(),o=!e.loadedFromPersistor,n=mt(t),{requestId:r}=Wb(),a=Ye(),{fetchStatus:s}=y();if(!r)return Jl.createElement(Nb,{containerStyles:{margin:"20px"},type:"error",title:Eb.t("The request ID is necessary to display the swap details.")});let l=o||s==="loading",p=r?n.find(({swap:g})=>g.requestId===r):void 0,u=i(()=>{if(p?.id){let g=t?.get(p.id);g&&Ib(g)}},"onCancel"),c=i(async()=>{if(p?.id)try{t?.deleteQueue(p.id),a()}catch(g){console.log(g)}},"onDelete"),m=p?.swap;return!m||l?Jl.createElement(ih,{requestId:r,showSkeleton:l}):Jl.createElement(Xl,{swap:m,requestId:r,onCancel:u,onDelete:c})}i(ah,"SwapDetailsPage");import{i18n as sh}from"@lingui/core";import{Divider as Mb,getCategoriesCount as Bb,SelectableCategoryList as Lb,styled as ph,Typography as Pb,Wallet as Db}from"@rango-dev/ui";import Bt,{useState as lh}from"react";var _b=ph("div",{display:"flex",justifyContent:"center",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5"}),$b=ph(ie,{textAlign:"center"});function ch(){let{fetchStatus:t}=y(),[e,o]=lh("ALL"),n=y().blockchains(),{config:r}=y(),[a,s]=lh(),l=se.use.isActiveTab(),{list:p}=ht(),u=Mp(p,n),m=Bb(u)!==1,g=Bp(p,e),d=i(f=>{yp(p,r.multiWallets)||s(f)},"handleWalletItemClick");return Bt.createElement(ne,{header:{title:sh.t("Connect Wallets")}},Bt.createElement($b,null,m&&Bt.createElement(Bt.Fragment,null,Bt.createElement(Lb,{setCategory:o,category:e,blockchains:u,isLoading:t==="loading"}),Bt.createElement(Mb,{size:24})),Bt.createElement(Pb,{variant:"title",size:"xmedium",align:"center"},sh.t("Choose a wallet to connect.")),Bt.createElement(_b,null,g.map((f,h)=>{let S=`wallet-${h}-${f.type}`;return Bt.createElement(Db,{key:S,...f,container:A(),onClick:()=>d(f),isLoading:t==="loading",disabled:!l})}),Bt.createElement(So,{wallet:a,onClose:()=>{s(void 0)}}))))}i(ch,"WalletsPage");function uh(){return _c(),ba(),Fb([{path:D.home,element:De.createElement(zf,null)},{path:D.routes,element:De.createElement(Vf,null)},{path:D.fromSwap,children:[{index:!0,element:De.createElement(Bl,{type:"source"})},{path:D.blockchains,element:De.createElement(Ei,{type:"source"})}]},{path:D.toSwap,children:[{index:!0,element:De.createElement(Bl,{type:"destination"})},{path:D.blockchains,element:De.createElement(Ei,{type:"destination"})}]},{path:D.settings,children:[{index:!0,element:De.createElement(kg,null)},{path:D.languages,element:De.createElement(qf,null)},{path:D.exchanges,element:De.createElement(wl,{sourceType:"Exchanges"})},{path:D.bridges,element:De.createElement(wl,{sourceType:"Bridges"})},{path:D.customTokens,children:[{index:!0,element:De.createElement(Jd,null)},{path:D.addCustomTokens,children:[{index:!0,element:De.createElement(Eu,null)},{path:D.blockchains,element:De.createElement(Ei,{hideCategory:!0,type:"custom-token"})}]}]}]},{path:D.swaps,children:[{index:!0,element:De.createElement(Cf,null)},{path:D.swapDetails,element:De.createElement(ah,null)}]},{path:D.wallets,element:De.createElement(ch,null)},{path:D.confirmSwap,element:De.createElement(_d,null)}])}i(uh,"AppRoutes");import{useQueueManager as Kb}from"@rango-dev/queue-manager-rango-preset";import{splitWalletNetwork as jb}from"@rango-dev/wallets-shared";import{isEvmBlockchain as Xb}from"rango-sdk";import{useContext as Yb,useEffect as Sh,useState as Ch}from"react";import{globalCss as Ob}from"@rango-dev/ui";var mh=i(()=>Ob({"@import":"url('https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap')"})(),"globalFont");function dh(){let{setWatermark:t}=se();return{fetchApiConfig:i(async()=>{let o=await fetch(`${ct("BASE_URL")}/meta/dapp/config?apiKey=${ct("API_KEY")}`);if(!o.ok)throw new Error(`Request failed with status: ${o.status} `);let n=await o.json();t(n.config.watermark)},"fetchApiConfig")}}i(dh,"useFetchApiConfig");import{useWallets as Ub}from"@rango-dev/wallets-react";import{useEffect as zb,useRef as Qb}from"react";function fh(){let{connect:t,state:e}=Ub(),o=Qb({}),{fetchStatus:n}=y(),r=new URLSearchParams(location.search).get("autoConnect")||"",a=e(r);zb(()=>{n==="success"&&r&&a.installed&&!a.connecting&&!a.connected&&!o.current[r]&&(o.current[r]=!0,t(r))},[a,n])}i(fh,"useForceAutoConnect");import{isApprovalTX as qb,RouteEventType as gh,StepEventType as hh,StepExecutionEventStatus as Hb,WidgetEvents as qi}from"@rango-dev/queue-manager-rango-preset";import{useEffect as yh}from"react";function Rl(){let t=Z.use.connectedWallets(),e=Z.use.getWalletsDetails(),o=we.use.setNotification(),{findToken:n}=y();yh(()=>{let r=i(a=>{let{event:s,step:l,route:p}=a;if(s.type===hh.TX_EXECUTION&&s.status===Hb.TX_SENT&&!qb(l)||s.type===hh.SUCCEEDED){let c=t.find(g=>g.chain===l?.fromBlockchain),m=l?.fromBlockchain!==l?.toBlockchain&&t.find(g=>g.chain===l?.toBlockchain);c&&e([c],n),m&&e([m],n)}o(s,p)},"handleStepEvent");return ye.on(qi.StepEvent,r),()=>ye.off(qi.StepEvent,r)},[ye,t]),yh(()=>{let r=i(a=>{let{event:s,route:l}=a;(s.type===gh.FAILED||s.type===gh.SUCCEEDED)&&o(s,l)},"handleRouteEvent");return ye.on(qi.RouteEvent,r),()=>ye.off(qi.RouteEvent,r)},[ye])}i(Rl,"useSubscribeToWidgetEvents");import{useManager as Gb}from"@rango-dev/queue-manager-react";import{useEffect as Vb}from"react";function ep(){let{isSynced:t,syncNotifications:e}=we(),{manager:o,state:n}=Gb();Vb(()=>{we.persist.hasHydrated()&&n.loadedFromPersistor&&!t&&e(mt(o))},[we.persist.hasHydrated(),n.loadedFromPersistor,t])}i(ep,"useSyncNotifications");function tp(){fh(),mh(),Rl(),ep();let t=y().blockchains(),{canSwitchNetworkTo:e}=Gr(),[o,n]=Ch(""),[r,a]=Ch(),s=Yb(hr),l=t.filter(Xb),{fetchApiConfig:p}=dh();Sh(()=>()=>Dc(),[]),Kb({lastConnectedWallet:o,clearDisconnectedWallet:()=>{a(void 0)},disconnectedWallet:r,evmChains:l,canSwitchNetworkTo:e}),Sh(()=>(po.init(),we.persist.hasHydrated()||we.persist.rehydrate(),s.onConnectWallet(n),s.onDisconnectWallet(u=>{a(u),u===jb(o)?.[0]&&n("")}),p().catch(console.log),po.destroy),[])}i(tp,"useBootstrap");import{styled as Zb}from"@rango-dev/ui";var kh=Zb("div",{fontFamily:"$widget",boxSizing:"border-box",textAlign:"left","& *, *::before, *::after":{boxSizing:"inherit"},"& *:focus-visible":{outlineColor:"$info500",transition:"none"},"& ul, ol, li":{listStyleType:"none"}});function Hi(){tp();let{config:t}=y(),{activeTheme:e}=$o(t?.theme||{}),{activeLanguage:o}=to();return op.createElement(Jb,{language:o},op.createElement(kh,{id:"swap-container",className:e()},op.createElement(uh,null)))}i(Hi,"Main");import{setSolanaSignerConfig as SE}from"@rango-dev/signer-solana";import rp,{useEffect as Eh,useMemo as CE}from"react";import{useState as Rb}from"react";var eE=i(()=>{let[t,e]=Rb(null),o=i(a=>{let s=document.createElement("link");return s.href=a,s.rel="stylesheet",document.head.appendChild(s),s},"loadFont"),n=i(()=>{t&&(document.head.removeChild(t),e(null))},"unloadFont");return{handleLoadCustomFont:i(a=>{n();let s=hp(a);if(s){let l=o(s);e(l)}},"handleLoadCustomFont")}},"useFontLoader"),Th=eE;import{checkWaitingForNetworkChange as tE,makeQueueDefinition as oE}from"@rango-dev/queue-manager-rango-preset";import{Provider as nE}from"@rango-dev/queue-manager-react";import{useWallets as rE}from"@rango-dev/wallets-react";import{convertEvmBlockchainMetaToEvmChainInfo as iE}from"@rango-dev/wallets-shared";import{isEvmBlockchain as aE}from"rango-types";import sE,{useMemo as lE}from"react";function pE(t){let{providers:e,getSigners:o,state:n,connect:r,canSwitchNetworkTo:a,getWalletInfo:s}=rE(),l=lE(()=>oE({API_KEY:t.apiKey||ct("API_KEY"),BASE_URL:ct("BASE_URL"),emitter:{emit:ye.emit}}),[t.apiKey]),p=y().blockchains(),c={blockchains:Z.use.connectedWallets().map(T=>({accounts:[T],name:T.chain}))},m=i(async(T,v)=>{if(a(T,v))return r(T,v)},"switchNetwork"),g=i(T=>!!s(T).mobileWallet,"isMobileWallet"),d=p.filter(T=>T.enabled).reduce((T,v)=>(T[v.name]=v,T),{}),f=p.filter(aE),h=i(T=>{let{supportedChains:v}=s(T);return rr(v)},"getSupportedChainNames"),S=e(),C={meta:{blockchains:d,evmBasedChains:f,evmNetworkChainInfo:iE(f),getSupportedChainNames:h},getSigners:o,wallets:c,providers:S,switchNetwork:m,canSwitchNetworkTo:a,connect:r,state:n,isMobileWallet:g},k=se.use.isActiveTab();return sE.createElement(nE,{queuesDefs:[l],context:C,onPersistedDataLoaded:T=>{tE(T)},isPaused:!k},t.children)}i(pE,"QueueManager");var vh=pE;import{useManager as fE}from"@rango-dev/queue-manager-react";import gE,{createContext as hE,useContext as yE}from"react";function xh(){let{findToken:t}=y(),e=y().blockchains(),o=y().tokens(),{setFromBlockchain:n,setFromToken:r,setToBlockchain:a,setToToken:s,setInputAmount:l}=z();return i(u=>{let{fromBlockchain:c,fromToken:m,toBlockchain:g,toToken:d,requestAmount:f}=u,h={blockchains:e,tokens:o};if(c!==void 0){let S=e.find(C=>C.name===c)??null;n(S)}if(m!==void 0){let S=m?t(m)??null:null;r({meta:h,token:S})}if(g!==void 0){let S=e.find(C=>C.name===g)??null;a(S)}if(d!==void 0){let S=d?t(d)??null:null;s({meta:h,token:S})}f!==void 0&&l(f)},"updateQuoteInputs")}i(xh,"useUpdateQuoteInputs");import{cancelSwap as cE,getCurrentBlockchainOfOrNull as uE,getCurrentStep as mE,getRelatedWalletOrNull as dE}from"@rango-dev/queue-manager-rango-preset";var Gi=class{static{i(this,"WidgetHistory")}constructor(e,o){this.manager=e,this.actions=o}getAllSwaps(){return mt(this.manager)}getCurrentStep(e){return this.getCurrentStepInfo(e).step}getCurrentStepWallet(e){return this.getCurrentStepInfo(e).wallet}getCurrentStepNetwork(e){return this.getCurrentStepInfo(e).network}retry(e,o){let n=xr(e,o.blockchains,this.actions.findToken);return this.actions.retrySwap(n)}cancel(e){let o=this.manager?.get(e);o&&cE(o)}getCurrentStepInfo(e){let o=mE(e);return{step:o,wallet:o?dE(e,o):null,network:o?uE(e,o):null}}};var wh=hE(void 0);function np(t){let{manager:e}=fE(),o=se.use.isActiveTab(),n=z.use.retry(),{findToken:r}=y(),a=new Gi(e,{retrySwap:n,findToken:r}),s=Z.use.connectedWallets(),l=Z.use.loading(),p=bp(s),u=Z.use.getWalletsDetails(),c=y().blockchains(),m=y().tokens(),g=y().swappers(),d=y().fetchStatus,f=to().resetLanguage,h=we().getNotifications(),S=we().clearNotifications,C=xh(),{fromBlockchain:k,toBlockchain:T,fromToken:v,toToken:x,inputAmount:N}=z(),M={isActiveTab:o,setCurrentTabAsActive:po.forceClaim,history:a,wallets:{isLoading:l,details:s,totalBalance:p,refetch:w=>u(w,r)},meta:{blockchains:c,tokens:m,swappers:g,loadingStatus:d,findToken:r},resetLanguage:f,notifications:{list:h,clearAll:S},quote:{quoteInputs:{fromBlockchain:k?.name??null,fromToken:v?{symbol:v.symbol,blockchain:v.blockchain,address:v.address}:null,toBlockchain:T?.name??null,toToken:x?{symbol:x.symbol,blockchain:x.blockchain,address:x.address}:null,requestAmount:N},updateQuoteInputs:C}};return gE.createElement(wh.Provider,{value:M},t.children)}i(np,"WidgetInfo");function bh(){let t=yE(wh);if(!t)throw new Error("useWidget can only be used within the WidgetProvider component");return t}i(bh,"useWidget");function Vi(t){let{onUpdateState:e,config:o}=t,n=t.config?.theme?.fontFamily,{handleLoadCustomFont:r}=Th();return Eh(()=>{n&&r(n)},[n]),CE(()=>{Lp({API_KEY:o?.apiKey||Yn,BASE_URL:o?.apiUrl||ip})},[o.apiKey,o.apiUrl]),Eh(()=>{t.config?.signers?.customSolanaRPC&&SE("customRPC",t.config.signers.customSolanaRPC)},[t.config?.signers?.customSolanaRPC]),rp.createElement(yr,{config:o,onUpdateState:e},rp.createElement(vh,{apiKey:o.apiKey},rp.createElement(np,null,t.children)))}i(Vi,"WidgetProvider");function Ih(t){let e=t.config?.externalWallets;return Ki.createElement(sc,null,e?Ki.createElement(Hi,null):Ki.createElement(Vi,{config:t.config??ca},Ki.createElement(Hi,null)))}i(Ih,"Widget");function Ah(){let{on:t,off:e}=ye;return{on:t,off:e}}i(Ah,"useWidgetEvents");export{vj as EventSeverity,lo as MainEvents,Bj as Networks,Dj as PendingSwapNetworkStatus,aa as QuoteEventTypes,xj as RouteEventType,Xi as SUPPORTED_FONTS,wj as StepEventType,bj as StepExecutionBlockedEventStatus,Ej as StepExecutionEventStatus,_e as UI_ID,sa as UiEventTypes,ur as WalletEventTypes,Wj as WalletEvents,Lj as WalletTypes,Ih as Widget,lo as WidgetEvents,Vi as WidgetProvider,yr as WidgetWallets,$a as customizedThemeTokens,Aj as readAccountAddress,jt as useStatefulConnect,ht as useWalletList,Gr as useWallets,bh as useWidget,Ah as useWidgetEvents,Zn as widgetEventEmitter};
1
+ var Wh=Object.defineProperty;var i=(t,e)=>Wh(t,"name",{value:e,configurable:!0});import{EventSeverity as bj,RouteEventType as Ej,StepEventType as Ij,StepExecutionBlockedEventStatus as Aj,StepExecutionEventStatus as Nj}from"@rango-dev/queue-manager-rango-preset";import{legacyReadAccountAddress as Mj}from"@rango-dev/wallets-core/legacy";import{useWallets as Zr,Events as Lj}from"@rango-dev/wallets-react";import{Networks as Dj,WalletTypes as _j}from"@rango-dev/wallets-shared";import{PendingSwapNetworkStatus as Fj}from"rango-types";import{Divider as sS}from"@rango-dev/ui";import mo,{useEffect as lS,useRef as pS,useState as Ec}from"react";import{WalletState as Mh}from"@rango-dev/ui";import{useWallets as Bh}from"@rango-dev/wallets-react";import{useReducer as Lh}from"react";function sp(t){return!!t.derivationPath}i(sp,"isStateOnDerivationPathStep");function lp(t){return!!t.namespace}i(lp,"isStateOnNamespace");var er={status:"init",namespace:null,derivationPath:null};function pp(t,e){switch(e.type){case"needsNamespace":return{...t,status:"namespace",namespace:e.payload,derivationPath:null};case"needsDerivationPath":return{...t,status:"derivationPath",derivationPath:e.payload};case"reset":return er;case"resetDerivation":return t.namespace?{...t,derivationPath:null,status:"namespace"}:er;default:throw new Error("Action hasn't been defined.")}}i(pp,"reducer");function qt(){let{state:t,disconnect:e,connect:o}=Bh(),[n,r]=Lh(pp,er),a=i(async(c,m,g)=>{r({type:"reset"});try{return await o(c,void 0,m),{status:"connected"}}catch(d){let f=d?.message?`Error: ${d.message}`:"An unknown error happened during connecting wallet.";throw new Error(f,{cause:d})}},"runConnect"),s=i(async(c,m)=>{if(c.state===Mh.DISCONNECTED){if(!c.namespaces)return await a(c.type,void 0,m);let d=c.namespaces.length>1,f=c.needsDerivationPath;return d?(r({type:"needsNamespace",payload:{providerType:c.type,providerImage:c.image,availableNamespaces:c.namespaces,singleNamespace:c.singleNamespace}}),{status:"namespace"}):f?(r({type:"needsDerivationPath",payload:{providerType:c.type,providerImage:c.image,namespace:c.namespaces[0]}}),{status:"derivation-path"}):await a(c.type,c.namespaces.map(h=>({namespace:h})),m)}return m?.disconnectIfConnected?(await u(c.type),{status:"disconnected"}):{status:"disconnected-unhandled"}},"handleConnect"),l=i(async(c,m)=>{let g=c.singleNamespace,d=c.needsDerivationPath,f=m[0];if(!f)throw new Error("To confirm a namespace, you should select at least one namespace.");if(g&&d)return r({type:"needsDerivationPath",payload:{providerType:c.type,providerImage:c.image,namespace:f}}),{status:"derivation-path"};if(!lp(n))throw new Error("Something went wrong on handling namespace. Please retry.");let h=n.namespace.providerType,T=m.map(S=>({namespace:S}));return await a(h,T)},"handleNamespace"),p=i(async c=>{if(!c)throw new Error("Derivation path is empty. Please make sure you've filled the field correctly.");if(!sp(n))throw new Error("It seems you are filling derivation path without setting namespace before doing that. Please retry to connect.");let m=n.derivationPath.providerType,d=[{namespace:n.derivationPath.namespace,derivationPath:c}];return await a(m,d)},"handleDerivationPath"),u=i(async c=>{let m=t(c);return m.connected||m.connecting?(await e(c),{status:"disconnected"}):{status:"noop"}},"handleDisconnect");return{handleConnect:s,handleDisconnect:u,handleNamespace:l,handleDerivationPath:p,getState:()=>n,resetState:c=>{r(c==="derivation"?{type:"resetDerivation"}:{type:"reset"})}}}i(qt,"useStatefulConnect");import{WalletState as Sa}from"@rango-dev/ui";import{useWallets as wy}from"@rango-dev/wallets-react";import{detectMobileScreens as by,KEPLR_COMPATIBLE_WALLETS as Ey,WalletTypes as Bo}from"@rango-dev/wallets-shared";import{useCallback as Iy,useEffect as Ay}from"react";import fy,{createContext as gy,useContext as hy,useEffect as yy,useRef as Sy}from"react";import{create as my}from"zustand";import{persist as dy}from"zustand/middleware";var oa=class{static{i(this,"CacheService")}#e=new Map;get(e){return this.#e.get(e)}set(e,o){this.#e.set(e,o)}remove(e){this.#e.delete(e)}clear(){this.#e.clear()}},Ao=new oa;function tr(t,e){return e.find(o=>o.name===t)?.displayName}i(tr,"getBlockchainDisplayNameFor");function pt(t,e){return e.find(o=>o.name===t)?.shortName}i(pt,"getBlockchainShortNameFor");function cp(t,e){return e.find(o=>o.name===t)?.logo}i(cp,"getBlockchainImage");function on(t,e){return e.find(o=>o.id===t)?.title}i(on,"getSwapperDisplayName");function nn(t,e){return e.find(o=>o.name===t)??null}i(nn,"findBlockchain");function na(t,e){if(!e||!t)return!1;for(let o of e.feeAssets)if(t?.blockchain===o?.blockchain&&t?.symbol===o?.symbol&&t?.address===o?.address)return!0;return!1}i(na,"isTokenNative");function _e(t){return`${t.blockchain.toLowerCase()}-${t.symbol.toLowerCase()}-${(t.address??"").toLowerCase()}`}i(_e,"createTokenHash");function No(t,e){return t.addressPatterns.filter(r=>new RegExp(r).test(e)).length>0}i(No,"isValidTokenAddress");function rn(t){let{config:e,meta:o}=t,n={},r=e.tokens,a=i(l=>{l.forEach(p=>{typeof p!="string"&&(p=_e(p));let u=o.tokensMapByTokenHash.get(p);u&&(n[p]=u)})},"addTokens");if(Array.isArray(r))return r.length>0?(a(r),Object.values(n)):Array.from(o.tokensMapByTokenHash.values());if(!r)return Array.from(o.tokensMapByTokenHash.values());let s;if(e.blockchains?.length)s=e.blockchains;else{s=Object.keys(r);let l=new Set(s);Object.keys(o.tokensMapByBlockchainName).forEach(p=>{l.has(p)||a(o.tokensMapByBlockchainName[p])})}return s.forEach(l=>{let p=r[l];if(!p&&o.tokensMapByBlockchainName?.[l]){a(o.tokensMapByBlockchainName[l]);return}p&&(p.isExcluded?(a(o.tokensMapByBlockchainName[l]),p.tokens.forEach(u=>{let c=_e(u);delete n[c]})):a(p.tokens))}),Object.values(n)}i(rn,"matchTokensFromConfigWithMeta");function or(t){let{config:e}=t,o=e.from?.blockchains||[],n=e.to?.blockchains||[];if(!o.length||!n.length)return[];let r=[...o,...n],a=new Set(r);return Array.from(a)}i(or,"getSupportedBlockchainsFromConfig");var ra={apiKey:"",title:void 0,multiWallets:!0,excludeLiquiditySources:!0,customDestination:!0,variant:"default",trezorManifest:{appUrl:"https://widget.rango.exchange/",email:"hi+trezorwidget@rango.exchange"}},Ph={clientUrl:void 0},Dh={liquiditySources:void 0},up=i((t,e,o)=>({config:{...ra,...t},iframe:Ph,campaignMode:Dh,getLiquiditySources:()=>{let{config:n,campaignMode:r}=o();return r.liquiditySources?.length?r.liquiditySources:n.liquiditySources??[]},getDisabledLiquiditySources:()=>{let{disabledLiquiditySources:n,campaignMode:r}=o();return r.liquiditySources?.length?[]:n},excludeLiquiditySources:()=>{let{config:n,campaignMode:r}=o();return r.liquiditySources?.length?!1:!!n.excludeLiquiditySources},isInCampaignMode:()=>{let{campaignMode:n}=o();return!!n.liquiditySources?.length},updateConfig:n=>{let r=o().config,{_tokensMapByTokenHash:a,_tokensMapByBlockchainName:s}=o(),l=rn({type:"source",config:{blockchains:n.from?.blockchains,tokens:n.from?.tokens},meta:{tokensMapByBlockchainName:s,tokensMapByTokenHash:a}}),p=rn({type:"destination",config:{blockchains:n.to?.blockchains,tokens:n.to?.tokens},meta:{tokensMapByBlockchainName:s,tokensMapByTokenHash:a}});Ao.set("supportedSourceTokens",l),Ao.set("supportedDestinationTokens",p),e({config:{...r,...n}})},updateCampaignMode:(n,r)=>{let a=o().campaignMode;e({campaignMode:{...a,[n]:r}})},updateIframe:(n,r)=>{let a=o().iframe;e({iframe:{...a,[n]:r}})}}),"createConfigSlice");import{TransactionType as mp}from"rango-types";var dp=[mp.EVM,mp.SOLANA];import{RangoClient as Yh}from"rango-sdk";import{UI_ID as _h}from"@rango-dev/ui";var nr="c6381a79-2817-4602-83bf-6a641a409e32",fp="https://api.rango.exchange",gp="https://explorer.rango.exchange",$e={SWAP_BOX_ID:"rango-swap-box",EXPANDED_BOX_ID:"rango-expanded-box",..._h};import{BlockchainCategories as qh,WalletState as Et}from"@rango-dev/ui";import{legacyReadAccountAddress as Hh}from"@rango-dev/wallets-core/legacy";import{detectInstallLink as Gh,getCosmosExperimentalChainInfo as Vh,isEvmAddress as Kh,KEPLR_COMPATIBLE_WALLETS as vI,Networks as Ap}from"@rango-dev/wallets-shared";import ca from"bignumber.js";import{isCosmosBlockchain as jh}from"rango-types";import $h from"bignumber.js";var Ue=new $h(0);import{WalletTypes as Fh}from"@rango-dev/wallets-shared";var hp=[Fh.LEAP];import{BlockchainCategories as aa,WalletState as Qh}from"@rango-dev/ui";import{TransactionType as rr}from"rango-sdk";var yp="Roboto",ia=[{name:"Roboto",value:"Roboto",url:""},{name:"Times New Roman",value:"Times New Roman",url:"https://fonts.cdnfonts.com/css/times-new-roman"},{name:"Arial",value:"Arial",url:""},{name:"Open Sans",value:"Open Sans",url:"https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,300..800;1,300..800&display=swap"},{name:"Noto Sans",value:"Noto Sans",url:"https://fonts.googleapis.com/css2?family=Noto+Sans:ital,wght@0,100..900;1,100..900&display=swap"},{name:"Montserrat",value:"Montserrat",url:"https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100..900;1,100..900&display=swap"},{name:"Poppins",value:"Poppins",url:"https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap"},{name:"Roboto Condensed",value:"Roboto Condensed",url:"https://fonts.googleapis.com/css2?family=Roboto+Condensed:ital,wght@0,100..900;1,100..900&display=swap"},{name:"Roboto Mono",value:"Roboto Mono",url:"https://fonts.googleapis.com/css2?family=Roboto+Mono:ital,wght@0,100..700;1,100..700&display=swap"},{name:"Oswald",value:"Oswald",url:"https://fonts.googleapis.com/css2?family=Oswald:wght@200..700&display=swap"},{name:"Raleway",value:"Raleway",url:"https://fonts.googleapis.com/css2?family=Raleway:ital,wght@0,100..900;1,100..900&display=swap"},{name:"Sedan",value:"Sedan",url:"https://fonts.googleapis.com/css2?family=Sedan:ital@0;1&display=swap"},{name:"Inter",value:"Inter",url:"https://fonts.googleapis.com/css2?family=Inter:wght@100..900&display=swap"},{name:"Rubik",value:"Rubik",url:"https://fonts.googleapis.com/css2?family=Rubik:ital,wght@0,300..900;1,300..900&display=swap"},{name:"Lora",value:"Lora",url:"https://fonts.googleapis.com/css2?family=Lora:ital,wght@0,400..700;1,400..700&display=swap"},{name:"Barlow Condensed",value:"Barlow Condensed",url:"https://fonts.googleapis.com/css2?family=Barlow+Condensed:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap"}];function Wo(t){return Array.from(new Set(t))}i(Wo,"removeDuplicateFrom");function pa(t,e){return t.length===e.length&&t.every((o,n)=>o===e[n])}i(pa,"areEqual");function xp(t,e){let o;return n;function n(...r){o&&clearTimeout(o),o=setTimeout(()=>{o=null,t(...r)},e)}}i(xp,"debounce");function et(t,e){return t.toLowerCase().indexOf(e.toLowerCase())>-1}i(et,"containsText");function Tp(t,e){return t.toLowerCase()===e.toLowerCase()}i(Tp,"exactText");function kp(t,e){return t.toLowerCase().startsWith(e.toLowerCase())}i(kp,"startWithText");var A=i(()=>document.getElementById($e.SWAP_BOX_ID),"getContainer"),an=i(()=>document.getElementById($e.EXPANDED_BOX_ID),"getExpanded");function vp(t,e,o){let n=!!e&&Tp(e,t),r=!!o&&Tp(o,t);return n!==r?n?-1:1:0}i(vp,"compareExactMatchText");function sa(t,e,o){let n=!!e&&et(e,t),r=!!o&&et(o,t);return n!==r?n?-1:1:n&&r&&e?.length!==o?.length?e?.length-o?.length:0}i(sa,"compareContainsText");function la(t,e,o){let n=!!e&&kp(e,t),r=!!o&&kp(o,t);return n!==r?n?-1:1:n&&r&&e?.length!==o?.length?e?.length-o?.length:0}i(la,"compareStartWithText");function wp(t,e,o){if(!o)return 0;let n=vp(o,t.symbol,e.symbol);if(n)return n;if(o.length>=3){let r=vp(o,t.name,e.name);if(r)return r}if(o.length>=2){let r=la(o,t.symbol,e.symbol);if(r)return r}if(o.length>=3){let r=sa(o,t.symbol,e.symbol);if(r)return r}if(o.length>=3){let r=la(o,t.name,e.name);if(r)return r}if(o.length>=3){let r=sa(o,t.name,e.name);if(r!==0)return r}if(o.length>=4){let r=la(o,t.address,e.address);if(r)return r}if(o.length>=4){let r=sa(o,t.address,e.address);if(r!==0)return r}return 0}i(wp,"compareWithSearchFor");var ir=i((t,e)=>{switch(e){case aa.ALL:return!0;case aa.UTXO:return t===rr.TRANSFER;case aa.OTHER:return t!==rr.TRANSFER&&t!==rr.COSMOS&&t!==rr.EVM;default:return t===e}},"isBlockchainTypeInCategory"),bp=i(t=>ia.find(o=>o.value===t)?.url,"getFontUrlByName");function Ep(t,e){let o=!!t.find(n=>n.state===Qh.CONNECTED);return e===!1&&o}i(Ep,"isSingleWalletActive");import{BigNumber as Ip}from"bignumber.js";var sn=i(t=>{let e=Math.floor(t%60/15)*15,o=parseInt((t/60).toString());return o>=60?`${Math.floor(o/5)*5}:00`:`${o.toString().padStart(2,"0")}:${e.toString().padStart(2,"0")}`},"roundedSecondsToString"),B=i((t,e=null,o=null)=>{if(t==null||t==="")return"";let n=new Ip(t),r=1,a=1e3;for(let s=0;s<60;s++)if(new Ip(n.toFixed(s,r)).eq(n)){a=s;break}if(n.gte(1e4))return n.toFormat(0,r);if(n.gte(1e3)||n.gte(100))return n.toFormat(Math.min(a,Math.min(o||100,Math.max(e||0,1))),r);if(n.gte(1))return n.toFormat(Math.min(a,Math.min(o||100,Math.max(e||0,2))),r);if(n.gte(.01))return n.toFormat(Math.min(a,Math.min(o||100,Math.max(e||0,4))),r);for(let s=e||4;s<17;s++)if(n.gte(Math.pow(10,-s)))return n.toFormat(Math.min(a,Math.min(o||100,Math.max(e||0,s))),r);return n.isEqualTo(0)?"0":n.toFormat(Math.min(a,Math.min(o||100,Math.max(e||0,8))),r)},"numberToString");var ar=i(t=>t?.reduce((e,o)=>e+(o.estimatedTimeInSeconds??0),0)||0,"totalArrivalTime");var bt=i((t,e)=>t.toLowerCase().indexOf(e.toLowerCase())>-1,"containsText"),ln=i(t=>!!t&&parseFloat(t)>0,"isPositiveNumber");function pn(t){switch(!0){case t.connected:return Et.CONNECTED;case t.connecting:return Et.CONNECTING;case!t.installed:return Et.NOT_INSTALLED;default:return Et.DISCONNECTED}}i(pn,"mapStatusToWalletState");function Np(t,e,o,n){return o.filter(r=>!hp.includes(r)).filter(r=>{let{supportedChains:a,isContractWallet:s}=e(r),{installed:l,network:p}=t(r);return s&&(!l||!!n&&p!==n)?!1:n?!!a.find(c=>c.name===n):!0}).map(r=>{let{name:a,img:s,installLink:l,showOnMobile:p,namespaces:u,singleNamespace:c,supportedChains:m,needsDerivationPath:g}=e(r),d=Wo(m.map(h=>h.type)),f=pn(t(r));return{title:a,image:s,link:Gh(l),state:f,type:r,showOnMobile:p,namespaces:u,singleNamespace:c,blockchainTypes:d,needsDerivationPath:g}})}i(Np,"mapWalletTypesToWalletInfo");function pr(t){if(!t)return null;let e=[];return e=t.map(o=>o.name),e}i(pr,"walletAndSupportedChainsNames");function Wp(t,e,o,n,r){let a=[];function s(p,u){if(!!!a.find(m=>m.chain===p)){let m={address:u,chain:p,walletType:t};a.push(m)}}i(s,"addAccount");let l=n||[];return e.forEach(p=>{let{address:u,network:c}=Hh(p),m=l.length>0,g=l.includes(c),d=c===Ap.Unknown;if(m&&!g&&!d)return;let h=c===Ap.Unknown&&Kh(u);if(d&&!h)return;o.includes(c)||h?r?s(c,u.toLowerCase()):l.filter(C=>o.includes(C)).forEach(C=>{s(C,u.toLowerCase())}):s(c,u)}),a}i(Wp,"prepareAccountsForWalletStore");function ao(t){let{filter:e,quote:o}=t,n=new Set;return o?.swaps.forEach((r,a)=>{let s=r.from.blockchain,l=r.to.blockchain;if(n.add(s),r.internalSwaps){let{internalSwaps:p}=r;p.forEach((u,c)=>{let m=u.from.blockchain,g=u.to.blockchain,d=a===o.swaps.length-1,f=c===p.length-1;(!d&&!f||d&&l!==m||e==="all")&&n.add(m),e==="all"&&n.add(g)})}e==="all"&&n.add(l)}),Array.from(n)}i(ao,"getQuoteWallets");function cr(t,e){return t.address===e.address&&t.chain===e.chain&&t.walletType===e.walletType}i(cr,"isAccountAndWalletMatched");function Mp(t,e){let{blockChain:o,balances:n=[]}=t;return n?.map(r=>({chain:o,symbol:r.asset.symbol,ticker:r.asset.symbol,address:r.asset.address||null,rawAmount:r.amount.amount,decimal:r.amount.decimals,amount:new ca(r.amount.amount).shiftedBy(-r.amount.decimals).toFixed(),logo:"",usdPrice:e(r.asset)?.usdPrice||null}))||[]}i(Mp,"makeBalanceFor");function Bp(t){return{...t,loading:!1,error:!0}}i(Bp,"resetConnectedWalletState");var Lp=i(t=>{let e=new Set,n=t?.reduce((a,s)=>a.findIndex(l=>l.address===s.address&&l.chain===s.chain)===-1?[...a,s]:a,[])?.map(a=>{let s={name:a.chain,accounts:[]};return e.has(a.address)||e.add(a.address),e.forEach(l=>{a.address===l&&s.accounts.push(a)}),s}),r=B(n?.flatMap(a=>a.accounts)?.flatMap(a=>a?.balances)?.map(a=>new ca(a?.amount||Ue).multipliedBy(a?.usdPrice||0))?.reduce((a,s)=>a.plus(s),Ue)||Ue).toString();return Xh(r)},"calculateWalletUsdValue");function Xh(t){let e=t.toString().split(".");return e[0]=e[0].replace(/\B(?=(\d{3})+(?!\d))/g,","),e.join(".")}i(Xh,"numberWithThousandSeparator");var ur=i((t,e)=>{let o=Vh(Object.entries(t).map(([,n])=>n).filter(jh));return o&&o[e]?.experimental},"isExperimentalChain");function mr(t){return t?{...t,amount:B(t.amount,8,8),usdValue:B(t.usdValue,4,4)}:null}i(mr,"formatBalance");function Pp(t,e){return t?.usdValue||e?.usdValue?parseFloat(e?.usdValue||"0")-parseFloat(t?.usdValue||"0"):t?.amount||e?.amount?parseFloat(e?.amount||"0")-parseFloat(t?.amount||"0"):0}i(Pp,"compareTokenBalance");function so(t,e){return t?.blockchain===e?.blockchain&&t?.symbol.toLowerCase()===e?.symbol.toLowerCase()&&t?.address?.toLowerCase()===e?.address?.toLowerCase()}i(so,"areTokensEqual");function Dp(t){return t.sort((e,o)=>+(o.state===Et.CONNECTED)-+(e.state===Et.CONNECTED)||+(o.state===Et.DISCONNECTED||o.state===Et.CONNECTING)-+(e.state===Et.DISCONNECTED||e.state===Et.CONNECTING))}i(Dp,"sortWalletsBasedOnConnectionState");function dr(t,e=8,o=3){if(t.length<2*e+o)return t;let n=t.slice(0,e),r=t.slice(-e);return`${n}${".".repeat(o)}${r}`}i(dr,"getConciseAddress");function _p({chain:t,connectedWallets:e,walletType:o}){return e.find(n=>n.walletType===o&&n.chain===t)?.address}i(_p,"getAddress");function fr(t){return t.flatMap(e=>e.balances).reduce((e,o)=>{let n={amount:o?.amount??"",decimals:o?.decimal??0,usdValue:o?.usdPrice?new ca(o?.usdPrice??Ue).multipliedBy(o?.amount).toString():""},r=o?_e({symbol:o.symbol,blockchain:o.chain,address:o.address}):null,a=r?e[r]:null;return r&&(!a||a&&a.amount<n.amount)&&(e[r]=n),e},{})}i(fr,"makeTokensBalance");var $p=i((t,e)=>!!t.find(o=>o.chain===e&&o.loading),"isFetchingBalance");function Fp(t){return t.map(e=>e.state).join("-")}i(Fp,"hashWalletsState");function Op(t,e){let o=new Set;return t.forEach(r=>{r.blockchainTypes.forEach(a=>{o.add(a)})}),e.filter(r=>o.has(r.type))}i(Op,"filterBlockchainsByWalletTypes");function Up(t,e){return e===qh.ALL?t:t.filter(o=>{for(let n of o.blockchainTypes)if(ir(n,e))return!0;return!1})}i(Up,"filterWalletsByCategory");var ua={API_KEY:nr};function ct(t){return ua[t]||""}i(ct,"getConfig");function zp(t){let e;return typeof structuredClone=="function"?e=structuredClone(t):e=JSON.parse(JSON.stringify(t)),ua=e,ua}i(zp,"initConfig");var Qp=20,qp=25,ma="theme-widget",da=i((t,e)=>{let o=!1;if(e&&t){if(Array.isArray(e))o=!e.some(n=>so(n,t));else if(!Array.isArray(e)&&e[t.blockchain]){o=e[t.blockchain].tokens.some(r=>so(r,t));let n=e[t.blockchain].isExcluded;return!n&&!o||n&&o}}return o},"isTokenExcludedInConfig"),fa=i((t,e)=>t&&e&&!e.includes(t.name),"isBlockchainExcludedInConfig"),Hp=i((t,e,o)=>o==="expanded"&&(t||e)||o==="full-expanded"&&e,"isVariantExpandable");var gr,Ht=i(()=>gr||(gr=new Yh(ct("API_KEY"),ct("BASE_URL")),gr),"httpService");function hr(t,e){let o=t.map(a=>a.swapperGroup),n=[];return Wo(t.map(a=>a.swapperGroup)).map(a=>{let s=t.find(l=>l.swapperGroup===a);if(s){let l=!0;o&&(l=o.some(p=>p===s.swapperGroup)),l&&s.types.map(p=>{n.push({id:s.swapperGroup,groupTitle:s.swapperGroup,logo:s.logo,type:p,selected:!e.includes(s.swapperGroup)})})}}),n}i(hr,"getUniqueSwappersGroups");function Gp(t,e){return t.swapperGroup<e.swapperGroup?-1:t.swapperGroup>e.swapperGroup?1:0}i(Gp,"sortLiquiditySourcesByGroupTitle");function je(t,e){return e?.[t]==="hidden"}i(je,"isFeatureHidden");function Vp(t,e){return e?.[t]==="enabled"}i(Vp,"isFeatureEnabled");var Kp=i((t,e,o)=>je("customTokens",o)?t:t.concat(e),"addCustomTokensToSupportedTokens");var jp=i((t,e)=>({_blockchainsMapByName:new Map,_tokensMapByTokenHash:new Map,_tokensMapByBlockchainName:{},_popularTokens:[],_swappers:[],fetchStatus:"loading",blockchains:o=>{let n=e()._blockchainsMapByName,r=Array.from(n?.values()||[]);if(!o||!o?.type)return r;let a=e().config;if(o.type==="custom-token"){let p=or({config:a}),u=r;return p.length>0&&(u=u.filter(c=>p.includes(c.name))),u.filter(c=>dp.includes(c.type))}let s=(o.type==="source"?a.from?.blockchains:a.to?.blockchains)??[];return r.filter(p=>!(s.length>0&&!s.includes(p.name)))},tokens:o=>{let{_tokensMapByTokenHash:n,_tokensMapByBlockchainName:r,config:a,_customTokens:s}=e(),l=Array.from(n.values()),p=e()._blockchainsMapByName;if(!o||!o.type)return l;let u=o.type==="source"?"from":"to",c=o.type==="source"?"supportedSourceTokens":"supportedDestinationTokens",m=Ao.get(c);m?.length||(m=rn({type:o.type,config:{blockchains:a[u]?.blockchains,tokens:a[u]?.tokens},meta:{tokensMapByTokenHash:n,tokensMapByBlockchainName:r}}),Ao.set(c,m)),m=Kp(m,s,a.features);let g=e().blockchains({type:o.type});return m.filter(f=>o.blockchain&&f.blockchain!==o.blockchain||!g.some(h=>h.name===f.blockchain)?!1:o.searchFor?!!(et(f.symbol,o.searchFor)||et(f.address||"",o.searchFor)||et(f.name||"",o.searchFor)):!0).sort((f,h)=>{let T=e().isTokenPinned(f,o.type),S=e().isTokenPinned(h,o.type);if(T!==S)return T?-1:1;if(o.getBalanceFor){let N=o.getBalanceFor(f),M=o.getBalanceFor(h),w=Pp(N,M);if(w!==0)return w}let C=p.get(f.blockchain),k=p.get(h.blockchain),v=na(f,C),x=na(h,k);if(v!==x)return v?-1:1;if(f.isPopular!==h.isPopular)return f.isPopular?-1:1;if(o.searchFor){let N=wp(f,h,o.searchFor);if(N)return N}return f.isSecondaryCoin!==h.isSecondaryCoin?f.isSecondaryCoin?1:-1:C&&k?C.sort-k.sort:0})},findToken:o=>{let n=e()._tokensMapByTokenHash,r=e().customTokens(),a=_e(o),s=n.get(a);return s||(s=r.find(l=>_e(l)===a)),s},isTokenPinned:(o,n)=>!!(n==="source"?e().config.from?.pinnedTokens:e().config.to?.pinnedTokens)?.some(s=>so(s,o)),swappers:()=>{let{config:o,campaignMode:n}=e(),r=n.liquiditySources?.length?n.liquiditySources:null,a=r??o.liquiditySources,s=r?!1:o.excludeLiquiditySources;return e()._swappers.filter(u=>{let c=a?.includes(u.swapperGroup);return s||!a||a.length===0?!c:c}).sort(Gp)},fetch:async()=>{try{let{enableCentralizedSwappers:o}=e().config,n=await Ht().getAllMetadata({enableCentralizedSwappers:o});t({fetchStatus:"success"});let r=new Map,a=new Map,s={},l=[],p=n.popularTokens,u=n.swappers,c=new Set;n.tokens.forEach(g=>{c.add(g.blockchain),l.push(g)}),n.blockchains.sort((g,d)=>g.sort-d.sort).forEach(g=>{g.enabled&&c.has(g.name)&&r.set(g.name,g)}),l.forEach(g=>{let d=_e(g);s[g.blockchain]||(s[g.blockchain]=[]),a.set(d,g),s[g.blockchain].push(d)}),t({_blockchainsMapByName:r,_tokensMapByTokenHash:a,_tokensMapByBlockchainName:s,_popularTokens:p,_swappers:u})}catch(o){throw t({fetchStatus:"failed"}),o}}}),"createDataSlice");import{Chinese as Zh,English as Jh,Finland as Rh,French as ey,German as ty,Greece as oy,Italian as ny,Japanese as ry,Netherlands as iy,Poland as ay,Portuguese as sy,Russian as ly,Spanish as py,Swedish as cy,Ukrainian as uy}from"@rango-dev/ui";var Xp=[{title:"English",label:"English",local:"en",SVGFlag:Jh},{title:"Spanish",label:"Espa\xF1ol",local:"es",SVGFlag:py},{title:"French",label:"Fran\xE7ais",local:"fr",SVGFlag:ey},{title:"Japanese",label:"\u65E5\u672C\u8A9E",local:"ja",SVGFlag:ry},{title:"Portuguese",label:"Portugu\xEAs",local:"pt",SVGFlag:sy},{title:"Chinese",label:"\u4E2D\u56FD\u4EBA",local:"zh",SVGFlag:Zh},{title:"Russian",label:"\u0420\u0443\u0441\u0441\u043A\u0438\u0439",local:"ru",SVGFlag:ly},{title:"German",label:"Deutsch",local:"de",SVGFlag:ty},{title:"Ukrainian",label:"\u0423\u043A\u0440\u0430\u0457\u043D\u0456",local:"uk",SVGFlag:uy},{title:"Swedish",label:"svenska",local:"sv",SVGFlag:cy},{title:"Finnish",label:"Suomalainen",local:"fi",SVGFlag:Rh},{title:"Dutch",label:"Nederlands",local:"nl",SVGFlag:iy},{title:"Greek",label:"Grieks",local:"el",SVGFlag:oy},{title:"Italian",label:"Italiana",local:"it",SVGFlag:ny},{title:"Polish",label:"Polski",local:"pl",SVGFlag:ay}],Mo="en";var Yp=[.5,1,3],Zp=1,Jp=5,Rp=100,ec=0;var tc=i((t,e)=>({disabledLiquiditySources:[],theme:"auto",language:null,preferredBlockchains:[],slippage:Zp,customSlippage:null,infiniteApprove:!1,affiliateRef:null,affiliatePercent:null,affiliateWallets:null,_customTokens:[],addPreferredBlockchain:o=>{let n=e().preferredBlockchains;if(n.find((s,l)=>{let p=s===o,u=l<=9;return p&&u}))return;let a=n.filter(s=>!(s===o));t(()=>({preferredBlockchains:[o,...a]}))},setSlippage:o=>t(()=>({slippage:o})),setCustomSlippage:o=>t(()=>({customSlippage:o})),setAffiliateRef:o=>t(()=>({affiliateRef:o})),setAffiliatePercent:o=>t(()=>({affiliatePercent:o})),setAffiliateWallets:o=>t(()=>({affiliateWallets:o})),toggleAllLiquiditySources:(o,n)=>t(r=>{if(n)return{disabledLiquiditySources:[]};let a=Wo(o.map(s=>s.swapperGroup));return a.length===r.disabledLiquiditySources.length?{disabledLiquiditySources:[]}:{disabledLiquiditySources:a}}),toggleInfiniteApprove:()=>t(o=>({infiniteApprove:!o.infiniteApprove})),toggleLiquiditySource:o=>t(n=>n.disabledLiquiditySources.includes(o)?{disabledLiquiditySources:n.disabledLiquiditySources.filter(r=>r!=o)}:{disabledLiquiditySources:n.disabledLiquiditySources.concat(o)}),setTheme:o=>t(()=>({theme:o})),setLanguage:o=>t(()=>({language:o})),updateSettings:o=>{let{features:n,theme:r}=o,a=je("theme",n),s=je("language",n),l=je("liquiditySource",n),p=r?.singleTheme,u=o?.__UNSTABLE_OR_INTERNAL__?.autoUpdateSettings;t({...a&&{theme:o.theme?.mode||"auto"},...p&&{theme:o.theme?.mode||"light"},...s&&{language:o.language||Mo},...l&&{disabledLiquiditySources:o.liquiditySources||[]},...u&&{language:o.language||Mo}})},setCustomToken:o=>t(n=>({_customTokens:[o,...n._customTokens]})),deleteCustomToken:o=>t(n=>({_customTokens:n._customTokens.filter(r=>r.address!==o.address)})),customTokens:()=>{let o=e().config,n=e()._customTokens,r=or({config:o});return r.length?n.filter(a=>r.includes(a.blockchain)):n}}),"createSettingsSlice");function oc(t){return my()(dy((...e)=>({...jp(...e),...tc(...e),...up(t,...e)}),{name:"user-settings",skipHydration:!0,partialize:e=>({_customTokens:e._customTokens,theme:e.theme,language:e.language,affiliatePercent:e.affiliatePercent,affiliateRef:e.affiliateRef,affiliateWallets:e.affiliateWallets,slippage:e.slippage,customSlippage:e.customSlippage,infiniteApprove:e.infiniteApprove,preferredBlockchains:e.preferredBlockchains,disabledLiquiditySources:e.disabledLiquiditySources})}))}i(oc,"createAppStore");var nc=gy(null);function y(){let t=hy(nc);if(yy(()=>{t&&!t.persist.hasHydrated()&&t.persist.rehydrate()},[]),!t)throw new Error("Missing AppStoreContext.Provider in the tree");return t()}i(y,"useAppStore");function rc(t){let e=Sy();return e.current||(e.current=oc(t.config)),fy.createElement(nc.Provider,{value:e.current},t.children)}i(rc,"AppStoreProvider");import{create as ky}from"zustand";import{subscribeWithSelector as vy}from"zustand/middleware";import Cy from"mitt";var ye=Cy(),yr={on:ye.on,off:ye.off};import{WidgetEvents as ic}from"@rango-dev/queue-manager-rango-preset";var ha=(o=>(o.QUOTE_INPUT_UPDATE="quoteInputUpdate",o.QUOTE_OUTPUT_UPDATE="quoteOutputUpdate",o))(ha||{}),Sr=(o=>(o.CONNECT="connect",o.DISCONNECT="disconnect",o))(Sr||{}),ya=(e=>(e.CLICK_CONNECT_WALLET="clickConnectWallet",e))(ya||{}),lo=(a=>(a[a.RouteEvent=ic.RouteEvent]="RouteEvent",a[a.StepEvent=ic.StepEvent]="StepEvent",a.QuoteEvent="quoteEvent",a.WalletEvent="walletEvent",a.UiEvent="uiEvent",a))(lo||{});var Ty=i(t=>{let e=t;e.use={};for(let o of Object.keys(e.getState()))e.use[o]=()=>e(n=>n[o]);return e},"createSelectors"),Gt=Ty;var Z=Gt(ky()(vy((t,e)=>({connectedWallets:[],balances:{},loading:!1,connectWallet:(o,n)=>{ye.emit("walletEvent",{type:"connect",payload:{walletType:o[0].walletType,accounts:o}});let r=e().getWalletsDetails;t(a=>({loading:!0,connectedWallets:a.connectedWallets.filter(s=>s.walletType!==o[0].walletType).concat(o.map(s=>{let l=!a.connectedWallets.some(p=>p.chain===s.chain&&p.selected&&p.walletType!==s.walletType);return{balances:[],address:s.address,chain:s.chain,explorerUrl:null,walletType:s.walletType,selected:l,loading:!0,error:!1}}))})),r(o,n)},disconnectWallet:o=>{t(n=>{n.connectedWallets.find(l=>l.walletType===o)&&ye.emit("walletEvent",{type:"disconnect",payload:{walletType:o}});let r=n.connectedWallets.filter(l=>l.selected&&l.walletType!==o).map(l=>l.chain),a=n.connectedWallets.filter(l=>l.walletType!==o).map(l=>r.includes(l.chain)?l:(r.push(l.chain),{...l,selected:!0}));return{balances:fr(a),connectedWallets:a}})},selectWallets:o=>t(n=>({connectedWallets:n.connectedWallets.map(r=>{let a=!!o.find(l=>l.chain===r.chain&&l.walletType!==r.walletType&&r.selected),s=!!o.find(l=>l.chain===r.chain&&l.walletType===r.walletType&&!r.selected);return a?{...r,selected:!1}:s?{...r,selected:!0}:r})})),clearConnectedWallet:()=>t(()=>({connectedWallets:[],selectedWallets:[]})),getWalletsDetails:async(o,n,r=!0)=>{let a=e().getWalletsDetails;t(s=>({loading:!0,connectedWallets:s.connectedWallets.map(l=>o.find(p=>cr(p,l))?{...l,loading:!0}:l)}));try{let s=o.map(({address:u,chain:c})=>({address:u,blockchain:c})),p=(await Ht().getWalletsDetails(s)).wallets;if(p)t(u=>{let c=u.connectedWallets.map(g=>{let d=o.find(h=>cr(h,g)),f=p.find(h=>h.address===g.address&&h.blockChain===g.chain);return f?.failed&&d&&r&&a([d],n,!1),d&&f?{...g,explorerUrl:f.explorerUrl,balances:Mp(f,n),loading:!1,error:!1}:g});return{loading:!1,balances:fr(c),connectedWallets:c}});else throw new Error("Wallet not found")}catch{t(l=>{let p=l.connectedWallets.map(c=>o.find(m=>cr(m,c))?Bp(c):c);return{loading:!1,balances:fr(p),connectedWallets:p}})}},getBalanceFor:o=>{let{balances:n}=e(),r=_e(o);return n[r]??null}}))));import{allProviders as xy}from"@rango-dev/provider-all";function Cr(t,e){let o=xy({walletconnect2:{WC_PROJECT_ID:e?.walletConnectProjectId||"",DISABLE_MODAL_AND_OPEN_LINK:e?.walletConnectListedDesktopWalletLink},selectedProviders:t,trezor:e?.trezorManifest?{manifest:e.trezorManifest}:void 0});if(t){let n=[];return t.forEach(r=>{if(typeof r=="string"){let a=o.find(s=>s.config.type===r);a?n.push(a):console.warn(`Couldn't find ${r} provider. Please make sure you are passing the correct name.`)}else n.push(r)}),n}return o}i(Cr,"matchAndGenerateProviders");function ac(t,e){return Cr(t,e).map(r=>r.config.type)}i(ac,"configWalletsToWalletName");var Ny=Object.values(Bo);function ft(t){let{chain:e}=t||{},{config:o}=y(),{state:n,getWalletInfo:r}=wy(),{connectedWallets:a}=Z(),s=y().blockchains(),{handleDisconnect:l}=qt(),p=ac(o?.wallets,{trezorManifest:o?.trezorManifest,walletConnectProjectId:o?.walletConnectProjectId,walletConnectListedDesktopWalletLink:o.__UNSTABLE_OR_INTERNAL__?.walletConnectListedDesktopWalletLink})||Ny,u=Np(n,r,p,e);u=by()?u.filter(h=>h.showOnMobile!==!1&&n(h.type).installed):u;let c=Dp(u),m=i(h=>!a.find(T=>T.walletType===h&&T.chain===e),"isExperimentalChainNotAdded"),g=Iy(()=>{let h=u?.filter(T=>T.state===Sa.CONNECTING)||[];for(let T of h)l(T.type)},[Fp(u)]);Ay(()=>()=>{g()},[]);let d=i(h=>{let T=h.find(C=>C.type===Bo.DEFAULT);return!T||T.state===Sa.NOT_INSTALLED?!1:h.filter(C=>C.state!=Sa.NOT_INSTALLED&&![Bo.DEFAULT,Bo.WALLET_CONNECT_2,Bo.LEDGER].includes(C.type)&&r(C.type).supportedChains.filter(k=>k.type=="EVM").length>0).length==0},"shouldShowDefaultInjectedWallet"),f=i((h,T,S)=>ur(S,T)&&m(h)&&!Ey.includes(h)||h==Bo.DEFAULT&&!d(u),"shouldExcludeWallet");return{list:c.filter(h=>!f(h.type,e??"",s)),terminateConnectingWallets:g}}i(ft,"useWalletList");import{Modal as By}from"@rango-dev/ui";import Ly from"react";import{create as My}from"zustand";var sc="rango-widget";var cn=class{constructor(e){this.state="not-initiated";this.events={};this.init=()=>{this.initEvents(),this.tryClaim()};this.forceClaim=()=>{if(!this.isClaimed()){let e={name:"force-claim",candidateId:this.tabId};this.channel.postMessage(e),setTimeout(()=>{this.isClaimed()||this.claim()},300)}};this.isClaimed=()=>this.state==="claimed";this.destroy=()=>{this.channel.removeEventListener("message",this.handleMessageEvent),document.removeEventListener("visibilitychange",this.handleVisibilityChange),document.removeEventListener("resume",this.handleResume)};this.handleMessageEvent=e=>{let o=e.data.name;switch(o){case"ping":this.claimedByCurrentTab(e.data.pingAt);break;case"pong":this.alreadyClaimedByAnotherTab();break;case"force-claim":this.forceRelease(e.data.candidateId);break;case"force-release":this.tabId===e.data.candidateId&&this.claim();break;default:throw new Error(`${o} is not supported.`)}};this.handleVisibilityChange=async()=>{document.visibilityState==="visible"&&await this.tryClaim()};this.handleResume=async()=>{this.isClaimed()&&(await this.tryClaim(),this.isClaimed()||this.events.onRelease?.())};this.channel=new BroadcastChannel(sc),this.tabId=Math.trunc(Math.random()*1e5),this.events=e}static{i(this,"TabManager")}initEvents(){this.channel.addEventListener("message",this.handleMessageEvent),document.addEventListener("visibilitychange",this.handleVisibilityChange),document.addEventListener("resume",this.handleResume)}claimedByCurrentTab(e){let o=this.lastTryClaim&&this.lastTryClaim<e;if(this.isClaimed()||o){let n={name:"pong"};this.channel.postMessage(n);return}}alreadyClaimedByAnotherTab(){this.resetLastCheck()}async tryClaim(){return this.setLastCheck(),new Promise(e=>{setTimeout(()=>{this.check(),e()},300)})}check(){this.state==="not-initiated"&&this.events.onInit?.(),this.lastTryClaim?(this.claim(),this.resetLastCheck()):this.state="not-claimed"}claim(){this.state="claimed",this.events.onClaim?.()}setLastCheck(){this.lastTryClaim=Date.now();let e={name:"ping",pingAt:this.lastTryClaim};this.channel.postMessage(e)}resetLastCheck(){this.lastTryClaim=void 0}forceRelease(e){if(this.isClaimed()){this.state="not-claimed",this.events.onRelease?.();let o={name:"force-release",candidateId:e};this.channel.postMessage(o)}}};var se=Gt(My()((t,e)=>({isActiveTab:!1,tabManagerInitiated:!1,showActivateTabModal:!1,watermark:"NONE",fetchingApiConfig:!1,activateCurrentTab:(o,n)=>{let{showActivateTabModal:r}=e();!r&&n?t({showActivateTabModal:!0}):(r||!n)&&o()},setShowActivateTabModal:o=>{t({showActivateTabModal:o})},setWatermark:o=>{t({watermark:o})}}))),po=new cn({onInit:()=>se.setState({tabManagerInitiated:!0}),onClaim:()=>se.setState({isActiveTab:!0,showActivateTabModal:!1}),onRelease:()=>se.setState({isActiveTab:!1})});function J(t){let{watermark:e}=se();return Ly.createElement(By,{hasWatermark:e==="FULL",...t},t.children)}i(J,"WatermarkedModal");import{i18n as Ca}from"@lingui/core";import{Button as Oy,Checkbox as Uy,Divider as zy,Image as yc,ListItemButton as Qy,MessageBox as qy,Radio as Hy,RadioRoot as Gy}from"@rango-dev/ui";import{namespaces as Sc}from"@rango-dev/wallets-shared";import we,{useMemo as Vy,useState as Ky}from"react";import{css as Py,darkTheme as pc,IconButton as Dy,styled as co}from"@rango-dev/ui";var It=co(Dy,{width:"$24",position:"relative",padding:"0",overflow:"unset","&:hover":{backgroundColor:"$secondary100",[`.${pc} &`]:{backgroundColor:"$neutral"}}}),cc=co("div",{position:"absolute",background:"$secondary500",[`.${pc} &`]:{$$color:"$colors$secondary250"},width:"$6",height:"$6",borderRadius:"$lg",right:"$4",border:"1px solid $surface100"}),Vt=co("div",{display:"flex",justifyContent:"flex-end",minWidth:"$40",button:{padding:0}}),uc=co("div",{position:"absolute",width:"14px",height:"14px",display:"flex",justifyContent:"center",alignItems:"center",borderRadius:"7px",top:"$0",right:"$0",variants:{isSever:{true:{backgroundColor:"$error500"},false:{backgroundColor:"$secondary500"}}}}),mc=co("div",{padding:"$2",variants:{isRefetched:{true:{transform:"rotate(360deg)",transition:"transform 1s ease-in-out"}}}}),dc=co("div",{position:"absolute",right:"$4",top:"$4",backgroundColor:"$background",borderRadius:"100%"}),fc=Py({display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center"}),Tr=co("div",{borderRadius:"100%",border:"1.5px transparent solid","&:not(:first-child)":{marginLeft:"-$6"},img:{borderRadius:"100%"}});import{keyframes as _y,styled as kr}from"@rango-dev/ui";var bA=kr("div",{borderRadius:"$lg",width:"$45",height:"$45",backgroundColor:"$success300",display:"flex",justifyContent:"center",alignItems:"center"}),Lo=kr("div",{position:"relative"}),$y=_y({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}),Po=kr("div",{position:"absolute",border:"2px solid rgba(0, 0, 0, 0.1)",borderTop:"2px solid $info500",borderRadius:"$lg",width:"$45",height:"$45",animation:`${$y} 1s linear infinite`,top:0,bottom:0,right:0,left:0}),vr=kr("div",{"& img":{borderRadius:"50%"}});function gc(t,e){return t.find(o=>o.name===e)?.logo}i(gc,"getBlockchainLogo");import{styled as Fy}from"@rango-dev/ui";var hc=Fy("ul",{padding:0,paddingTop:"$4",paddingBottom:"$4"});function un(t){let{singleNamespace:e,availableNamespaces:o,providerImage:n}=t.value,[r,a]=Ky([]),s=y().blockchains(),l=Vy(()=>o?.map(c=>({name:c,logo:gc(s,Sc[c].mainBlockchain),title:Sc[c].title})),[o]),p=i(c=>{a(e?[c]:m=>m.includes(c)?m.filter(g=>g!==c):m.concat(c))},"onSelect"),u=i(c=>e?we.createElement(Gy,{value:r?.[0]},c):we.createElement(we.Fragment,null,c),"wrapRadioRoot");return we.createElement(we.Fragment,null,we.createElement(zy,{size:20}),we.createElement(qy,{type:"info",title:Ca.t("Select chain types"),description:Ca.t("This wallet supports multiple chains. Select which chain you'd like to connect to."),icon:we.createElement(Lo,null,we.createElement(Tr,null,we.createElement(yc,{src:n,size:45})),we.createElement(Po,null))}),we.createElement(hc,null,u(we.createElement(we.Fragment,null,l?.map(c=>we.createElement(Qy,{key:c.name,id:c.name,title:c.title,hasDivider:!0,style:{height:60},onClick:()=>p(c.name),start:we.createElement(yc,{src:c.logo,size:22}),end:e?we.createElement(Hy,{value:c.name}):we.createElement(Uy,{checked:r.includes(c.name)})}))))),we.createElement(Oy,{type:"primary",disabled:!r.length,onClick:()=>t.onConfirm(r)},Ca.t("Confirm")))}i(un,"Namespaces");import{i18n as Do}from"@lingui/core";import{Button as Yy,Divider as kc,Image as Zy,MessageBox as Jy,Select as Ry,TextField as eS}from"@rango-dev/ui";import ze,{useEffect as tS,useState as vc}from"react";import{namespaces as jy}from"@rango-dev/wallets-shared";var xr={id:"custom",label:"Custom",generateDerivationPath:t=>t};function Ta(t){let e=t?jy[t].derivationPaths:null;return e?[...e,xr]:[]}i(Ta,"getDerivationPaths");import{styled as Cc,Typography as Xy}from"@rango-dev/ui";var Tc=Cc("div",{paddingTop:"$30",paddingBottom:"$30",zIndex:10}),ka=Cc(Xy,{paddingLeft:"$10"}),va={height:"$40",backgroundColor:"$neutral200",borderRadius:"$sm"};var xc="0";function mn(t){let{onConfirm:e}=t,{namespace:o,providerImage:n,providerType:r}=t.value,[a,s]=vc(null),[l,p]=vc(xc),u=a===xr.id,c=Ta(o),m=i(({value:d})=>{let f=c?.find(h=>h.id===d);f&&(a===xr.id&&Number.isNaN(Number(l))&&p(xc),s(f.id))},"handleDerivationPathItemClick"),g=i(()=>{let d=c.find(f=>f.id===a);if(d)e(d.generateDerivationPath(l));else throw new Error("selectedDerivationPath can not be undefined")},"handleConfirm");return tS(()=>{s(Ta(o)[0]?.id||null)},[o]),ze.createElement(ze.Fragment,null,ze.createElement(kc,{size:20}),ze.createElement(Jy,{type:"info",title:Do.t("Select Derivation Path"),description:Do.t(`In order to connect to ${r}, you must first select a Derivation Path`),icon:ze.createElement(Lo,null,ze.createElement(vr,null,ze.createElement(Zy,{src:n,size:45})),ze.createElement(Po,null))}),ze.createElement(Tc,null,ze.createElement(ka,{variant:"body",size:"xsmall",color:"$neutral600"},Do.t("Choose Derivation Path Template")),ze.createElement(Ry,{value:a||"",options:c.map(d=>({value:d.id,label:d.label})),variant:"filled",handleItemClick:m,styles:{trigger:va}}),ze.createElement(kc,{size:20}),ze.createElement(ka,{variant:"body",size:"xsmall",color:"$neutral600"},u?Do.t("Enter Path"):Do.t("Enter Index")),ze.createElement(eS,{type:u?"text":"number",variant:"contained",value:l,onChange:d=>p(d.target.value),style:va})),ze.createElement(Yy,{type:"primary",onClick:g,disabled:!c||!a||!l},Do.t("Confirm")))}i(mn,"DerivationPath");import{i18n as _o}from"@lingui/core";import{Image as oS,MessageBox as xa,WalletState as nS}from"@rango-dev/ui";import{useWallets as rS}from"@rango-dev/wallets-react";import uo from"react";function wa(t){let{wallet:e,error:o}=t,{type:n,image:r}=e,{state:a}=rS();return pn(a(n))===nS.CONNECTED?uo.createElement(xa,{type:"success",title:_o.t("Wallet Connected"),description:_o.t("Your wallet is connected, you can use it to swap.")}):o?uo.createElement(xa,{type:"error",title:_o.t("Failed to Connect"),description:o||_o.t("Your wallet is not connected. Please try again.")}):uo.createElement(xa,{type:"loading",title:_o.t("Connecting to your wallet"),description:_o.t("Click connect in your wallet popup."),icon:uo.createElement(Lo,null,uo.createElement(vr,null,uo.createElement(oS,{src:r,size:45})),uo.createElement(Po,null))})}i(wa,"ConnectStatus");import{i18n as ba}from"@lingui/core";import{Button as iS,Divider as wc,MessageBox as aS}from"@rango-dev/ui";import wr from"react";function Ea(t){let{displayName:e,onConfirm:o}=t;return wr.createElement(aS,{title:ba.t({id:"Add {blockchainDisplayName} Chain",values:{blockchainDisplayName:e}}),type:"warning",description:ba.t({id:"You should connect a {blockchainDisplayName} supported wallet or choose a different {blockchainDisplayName} address",values:{blockchainDisplayName:e}})},wr.createElement(wc,{size:18}),wr.createElement(wc,{size:32}),wr.createElement(iS,{onClick:o,variant:"outlined",type:"primary",fullWidth:!0,size:"large"},ba.t("Confirm")))}i(Ea,"ExperimentalChain");function bc(t,e){return t().status==="init"&&!!e}i(bc,"isOnStatus");function dn(t){return t().status==="namespace"}i(dn,"isOnNamespace");function fn(t){return t().status==="derivationPath"}i(fn,"isOnDerivationPath");var cS=3e3,uS=300;function fo(t){let e=pS(),[o,n]=Ec(!1),[r,a]=Ec(),s=i(S=>{a(S.message)},"catchErrorOnHandle"),{terminateConnectingWallets:l}=ft(),{handleConnect:p,handleDerivationPath:u,handleNamespace:c,getState:m,resetState:g}=qt(),d=i(S=>{c(t.wallet,S).catch(s)},"handleConfirmNamespaces"),f=i(S=>{if(!S)throw new Error("Derivation path is empty. Please make sure you've filled the field correctly.");u(S).catch(s)},"handleDerivationPathConfirm"),h=i(()=>{n(!1)},"handleClosingModal"),T=i(()=>{a(void 0),g(),n(!1),e.current&&clearTimeout(e.current)},"resetModalState");return lS(()=>{if(t.wallet){T();let S=!1,C=!0,k=i(()=>{setTimeout(()=>{C=!1,S||n(!0)},uS)},"beforeConnecting"),v=i(x=>{let N=x.status==="connected",M=["disconnected","disconnected-unhandled"].includes(x.status);["namespace","derivation-path"].includes(x.status)||(S=!0),N&&!C?e.current=setTimeout(h,cS):M&&h(),t.onConnect&&t.onConnect(x)},"afterConnected");k(),p(t.wallet,{disconnectIfConnected:!0}).then(v).catch(s)}},[t.wallet]),mo.createElement(J,{open:o,onClose:h,onExit:()=>{T(),l(),t.onClose&&t.onClose()},container:A()},bc(m,t.wallet)&&mo.createElement(mo.Fragment,null,mo.createElement(wa,{wallet:{type:t.wallet.type,image:t.wallet.image},error:r}),mo.createElement(sS,{direction:"vertical",size:32})),dn(m)&&mo.createElement(un,{onConfirm:d,value:m().namespace}),fn(m)&&mo.createElement(mn,{onConfirm:f,value:m().derivationPath}))}i(fo,"StatefulConnectModal");import{Events as Aa,Provider as dS}from"@rango-dev/wallets-react";import{isEvmBlockchain as fS}from"rango-sdk";import br,{createContext as gS,useEffect as Ac,useMemo as hS,useRef as Nc}from"react";import{useEffect as mS}from"react";function Ic(t){return t.map(e=>typeof e=="string"?e:e.config.type).join("-")}i(Ic,"hashProviders");function Ia(t,e){let o=Z.use.clearConnectedWallet(),n=Cr(t,e);return mS(()=>{o(),n=Cr(t,e)},[Ic(t??[]),e?.walletConnectProjectId,e?.walletConnectListedDesktopWalletLink]),{providers:n}}i(Ia,"useWalletProviders");var Er=gS({onConnectWallet:()=>{},onDisconnectWallet:()=>{}});function yS(t){let{updateConfig:e,updateSettings:o,fetch:n,fetchStatus:r}=y(),a=y().blockchains(),{findToken:s}=y(),l=y().config,p={walletConnectProjectId:l?.walletConnectProjectId,trezorManifest:l?.trezorManifest,walletConnectListedDesktopWalletLink:t.config.__UNSTABLE_OR_INTERNAL__?.walletConnectListedDesktopWalletLink},{providers:u}=Ia(l.wallets,p),{connectWallet:c,disconnectWallet:m}=Z(),g=Nc(),d=Nc();Ac(()=>{n().catch(console.log)},[]),Ac(()=>{t.config&&(e(t.config),o(t.config),window.__rango={config:l,dappConfig:t.config})},[t.config,r]);let f=a.filter(fS).map(C=>C.name),h=i((C,k,v,x,N)=>{if(k===Aa.ACCOUNTS)if(v){let M=pr(N.supportedBlockchains),w=Wp(C,v,f,M,N.isContractWallet);w.length&&c(w,s)}else m(C),d.current?d.current(C):console.warn("onDisconnectWallet handler hasn't been set. Are you sure?");if(k===Aa.ACCOUNTS&&x.connected){let M=`${C}-${x.network}-${v}`;x.connected&&(g.current?g.current(M):console.warn("onConnectWallet handler hasn't been set. Are you sure?"))}if(k===Aa.NETWORK&&x.network){let M=`${C}-${x.network}`;g.current?g.current(M):console.warn("onConnectWallet handler hasn't been set. Are you sure?")}t.onUpdateState&&t.onUpdateState(C,k,v,x,N)},"onUpdateState"),T=se.use.isActiveTab(),S=hS(()=>({onConnectWallet:C=>{g.current=C},onDisconnectWallet:C=>{d.current=C}}),[]);return br.createElement(Er.Provider,{value:S},br.createElement(dS,{allBlockChains:a,providers:u,onUpdateState:h,autoConnect:!!T},t.children))}i(yS,"Main");function Ir(t){let{config:e,...o}=t;return br.createElement(rc,{config:e},br.createElement(yS,{...o,config:e}))}i(Ir,"WidgetWallets");import Ri from"react";import SS,{Fragment as CS}from"react";import{MemoryRouter as TS,useInRouterContext as kS}from"react-router";function Wc({children:t}){let o=kS()?CS:TS;return SS.createElement(o,null,t)}i(Wc,"AppRouter");import{I18nManager as eE}from"@rango-dev/ui";import rp from"react";import De from"react";import{useRoutes as Ub}from"react-router-dom";var D={home:"/",fromSwap:"from-swap",toSwap:"to-swap",blockchains:"blockchains",settings:"settings",customTokens:"custom-tokens",addCustomTokens:"add-custom-tokens",liquiditySources:"liquidity-sources",bridges:"bridges",exchanges:"exchanges",languages:"languages",swaps:"swaps",wallets:"wallets",confirmSwap:"confirm-swap",swapDetails:":requestId",routes:"routes"};import{useEffect as Oo,useRef as _r}from"react";import Xe from"bignumber.js";import{create as wS}from"zustand";import{subscribeWithSelector as bS}from"zustand/middleware";import{getLastSuccessfulStep as xS}from"@rango-dev/queue-manager-rango-preset";import LW from"bignumber.js";function Na(t,e){return{"Network Fee":e("Network Fee"),"Swapper Fee":e("Protocol Fee"),"Affiliate Fee":e("Affiliate Fee"),"Outbound network fee":e("Outbound Fee"),"Rango Fee":e("Rango Fee")}[t]}i(Na,"getFeeLabel");var Wa=["RECOMMENDED","CENTRALIZED","LOWEST_FEE","FASTEST","HIGH_IMPACT"],Mc=30;import{i18n as gt}from"@lingui/core";import{RouteEventType as SW}from"@rango-dev/queue-manager-rango-preset";import Qe from"bignumber.js";import{PendingSwapNetworkStatus as Nr}from"rango-types";import{i18n as Fe}from"@lingui/core";var te=i(()=>({genericServerError:Fe.t("Failed Network, Please retry your swap."),liquiditySourcesError:{title:Fe.t("Please reset your liquidity sources."),description:Fe.t("You have limited the liquidity sources and this might result in Rango finding no routes. Please consider resetting your liquidity sources.")},noResultError:{title:Fe.t("No Routes Found."),description:Fe.t("Reasons why Rango couldn't find a route: low liquidity on token, very low input amount or no routes available for the selected input/output token combination.")},bridgeLimitErrors:{increaseAmount:Fe.t("Bridge Limit Error: Please increase your amount."),decreaseAmount:Fe.t("Bridge Limit Error: Please decrease your amount.")},highValueLossError:{impactTitle:Fe.t("High Price Impact"),title:Fe.t("Price impact is too high!"),description:Fe.t("The price impact is significantly higher than the allowed amount."),confirmMessage:Fe.t("Confirm high price impact")},quoteUpdatedWithHighValueLoss:{title:Fe.t("Route updated and price impact is too high, try again later!")},unknownPriceError:{impactTitle:Fe.t("USD Price Unknown"),title:Fe.t("USD Price Unknown, Cannot calculate Price Impact."),description:Fe.t("USD Price Unknown, Cannot calculate Price Impact. The price impact may be higher than usual. Are you sure to continue the Swap?"),confirmMessage:Fe.t("Confirm USD Price Unknown")}}),"errorMessages");function Bc(t){switch(t.type){case 0:return t.diagnosisMessage??te().noResultError.title;case 1:return te().genericServerError;default:return""}}i(Bc,"getQuoteErrorMessage");import{i18n as Ar}from"@lingui/core";var go=i(()=>({connectWallet:Ar.t("Connect Wallet"),swap:Ar.t("Swap"),swapAnyway:Ar.t("Swap anyway"),ethWarning:Ar.t("The route goes through Ethereum. Continue?")}),"swapButtonTitles");function Lc(t,e){return(parseInt(e.toFixed(2)||"0")<=-10&&t?.gte(new Qe(400))||parseInt(e.toFixed(2)||"0")<=-5&&t?.gte(new Qe(1e3)))??!1}i(Lc,"hasHighValueLoss");function Pc(t){return(t||[]).filter(e=>{let o=e.fromAmountMinValue?new Qe(e.fromAmountMinValue):null,n=e.fromAmountMaxValue?new Qe(e.fromAmountMaxValue):null;return e.fromAmountRestrictionType==="EXCLUSIVE"?o?.gte(e.fromAmount)||n?.lte(e.fromAmount):o?.gt(e.fromAmount)||n?.lt(e.fromAmount)}).length>0}i(Pc,"hasLimitError");function Dc(t){let e=(t||[]).filter(l=>{let p=l.fromAmountMinValue?new Qe(l.fromAmountMinValue):null,u=l.fromAmountMaxValue?new Qe(l.fromAmountMaxValue):null;return l.fromAmountRestrictionType==="EXCLUSIVE"?p?.gte(l.fromAmount)||u?.lte(l.fromAmount):p?.gt(l.fromAmount)||u?.lt(l.fromAmount)})[0],o=e.fromAmountMinValue?new Qe(e.fromAmountMinValue):null,n=e.fromAmountMaxValue?new Qe(e.fromAmountMaxValue):null,r=e.fromAmountRestrictionType==="EXCLUSIVE",a="",s="";return!r&&o&&o.gt(e.fromAmount)?(a=gt.t({id:"Required: >= {min} {symbol}",values:{min:B(o,6,6),symbol:e.from.symbol}}),s=te().bridgeLimitErrors.increaseAmount):r&&o&&o.gte(e.fromAmount)&&(a=gt.t({id:"Required: > {min} {symbol}",values:{min:B(o,6,6),symbol:e.from.symbol}}),s=te().bridgeLimitErrors.increaseAmount),!r&&n&&n.lt(e.fromAmount)?(a=gt.t({id:"Required: <= {max} {symbol}",values:{max:B(n,6,6),symbol:e.from.symbol}}),s=te().bridgeLimitErrors.decreaseAmount):r&&n&&n.lte(e.fromAmount)&&(a=gt.t({id:"Required: < {max} {symbol}",values:{max:B(n,6,6),symbol:e.from.symbol}}),s=te().bridgeLimitErrors.decreaseAmount),{swap:e,fromAmountRangeError:a,recommendation:s}}i(Dc,"getLimitErrorMessage");function _c(t){let{fetchMetaStatus:e,anyWalletConnected:o,fetchingQuote:n,inputAmount:r,quote:a,warning:s,error:l,needsToWarnEthOnPath:p}=t;return e!=="success"?{title:go().connectWallet,action:"connect-wallet",disabled:!0}:o?n||!a||l||!r||r==="0"?{title:go().swap,action:"confirm-swap",disabled:!0}:s?{title:go().swapAnyway,action:"confirm-warning",disabled:!1}:p?{title:go().ethWarning,action:"confirm-warning",disabled:!1}:{title:go().swap,action:"confirm-swap",disabled:!1}:{title:go().connectWallet,action:"connect-wallet",disabled:!1}}i(_c,"getSwapButtonState");function Ma(t,e,o){let n=parseFloat(e||"0");return!(t&&(!o||o.lte(Ue))&&e&&e!=="0"&&n!==0)}i(Ma,"canComputePriceImpact");function Ba(t,e){let o=Ue;for(let n=0;n<t.fee.length;n++){let r=t.fee[n];if(r.expenseType==="DECREASE_FROM_OUTPUT")continue;let a=e(r.asset)?.usdPrice||null;o=o.plus(new Qe(r.amount).multipliedBy(a||0))}return o}i(Ba,"getUsdFeeOfStep");function Wr(t,e){return t.reduce((o,n)=>o.plus(Ba(n,e)),Ue)}i(Wr,"getTotalFeeInUsd");function La(t){let e=Ue;return e=e.plus(new Qe(t.amount).multipliedBy(t.price||0)),e}i(La,"getUsdFee");function $c(t){return t.reduce((e,o)=>e.plus(La(o)),Ue)}i($c,"getTotalFeesInUsd");function Fc(t){return t.reduce((e,o)=>{for(let n of o.fee){let r=n.name,a=n.expenseType!=="DECREASE_FROM_OUTPUT"?e.payable:e.nonePayable;a[r]=[...a[r]||[],n]}return e},{payable:{},nonePayable:{}})}i(Fc,"getFeesGroup");function Oc(t){let e=new Map;return t.forEach((o,n)=>{o.recommendedSlippage?.error&&e.set(n,o.recommendedSlippage.slippage)}),e.size>0?e:null}i(Oc,"checkSlippageErrors");function Uc(t,e){let o=new Map;return t?.swaps.forEach((n,r)=>{n.recommendedSlippage?.slippage&&parseFloat(n.recommendedSlippage.slippage)>e&&o.set(r,n.recommendedSlippage.slippage)}),o.size>0?o:null}i(Uc,"checkSlippageWarnings");function Mr(t){return t.map(o=>o.recommendedSlippage)?.map(o=>o?.slippage||"0")?.filter(o=>parseFloat(o)>0)?.sort((o,n)=>parseFloat(n)-parseFloat(o))?.find(()=>!0)||null}i(Mr,"getMinRequiredSlippage");function zc(t,e){return e?parseFloat(t)>=parseFloat(e):!0}i(zc,"hasProperSlippage");function Qc(t){let{fromToken:e,toToken:o,inputAmount:n,wallets:r,selectedWallets:a,disabledLiquiditySources:s,liquiditySources:l,excludeLiquiditySources:p,slippage:u,affiliateRef:c,affiliatePercent:m,affiliateWallets:g,destination:d,enableCentralizedSwappers:f}=t,h=a?.reduce((C,k)=>(C[k.chain]=k.address,C),{}),T=[];return r?.forEach(C=>{T.push({blockchain:C.chain,addresses:[C.address]})}),{amount:n.toString(),affiliateRef:c??void 0,affiliatePercent:m??void 0,affiliateWallets:g??void 0,from:{address:e.address,blockchain:e.blockchain,symbol:e.symbol},to:{address:o.address,blockchain:o.blockchain,symbol:o.symbol},connectedWallets:T,selectedWallets:h??{},slippage:u.toString(),...d&&{destination:d},...p&&{swapperGroups:s.concat(l??[]),swappersGroupsExclude:!0},...!p&&{swapperGroups:l?.filter(C=>!s.includes(C)),swappersGroupsExclude:!1},enableCentralizedSwappers:f}}i(Qc,"createQuoteRequestBody");function qc(t){return t.reduce((o,n)=>(o[n.chain]={address:n.address,walletType:n.walletType},o),{})}i(qc,"getWalletsForNewSwap");function $o(t){return t?.outputAmount||null}i($o,"getQuoteOutputAmount");function Hc(t,e){return new Qe(e).div(new Qe(t)).minus(1).multipliedBy(100).toNumber()}i(Hc,"getPercentageChange");function Gc(t,e){let o=$o(t),n=$o(e);if(!o||!n)return!1;let r=ut(o,n);return r?r<=-1:!0}i(Gc,"isOutputAmountChangedALot");function Vc(t,e,o){let n=t.validationStatus,r=ao({filter:"required",quote:t});return e.sort((s,l)=>r.indexOf(s.chain)-r.indexOf(l.chain)).flatMap(s=>Jc(s,n)||[]).filter(s=>!s.ok).map(s=>{let l=s.asset.symbol,p=B(new Qe(s.currentAmount.amount).shiftedBy(-s.currentAmount.decimals),8,8),u=B(new Qe(s.requiredAmount.amount).shiftedBy(-s.requiredAmount.decimals),8,8),c="";return s.reason==="FEE"&&(c=gt.t(" for network fee")),s.reason==="INPUT_ASSET"&&(c=gt.t(" for swap")),s.reason==="FEE_AND_INPUT_ASSET"&&(c=gt.t(" for input and network fee")),gt.t({id:"Needs \u2248 {requiredAmount} {symbol}{reason}, but you have {currentAmount} {symbol} in your {blockchain} wallet.",values:{requiredAmount:u,symbol:l,reason:c,currentAmount:p,blockchain:pt(s.asset.blockchain,o)}})})}i(Vc,"generateBalanceWarnings");function jt(t,e){return(t?new Qe(t):Ue).multipliedBy(e||0)}i(jt,"calcOutputUsdValue");function gn(t){return!!t&&t.networkStatus!==null&&t.networkStatus!==Nr.NetworkChanged}i(gn,"isNetworkStatusInWarningState");function Kc(t,e){let o="bellow button or",n=t.extraMessage,r=t.extraMessageDetail;if(t.networkStatusExtraMessageDetail?.includes(o)&&(t.networkStatusExtraMessageDetail=t.networkStatusExtraMessageDetail.replace(o,"")),gn(e))switch(n=t.networkStatusExtraMessage||"",r=t.networkStatusExtraMessageDetail||"",e?.networkStatus){case Nr.WaitingForConnectingWallet:n=n||gt.t("Waiting for connecting wallet");break;case Nr.WaitingForQueue:n=n||gt.t("Waiting for other running tasks to be finished");break;case Nr.WaitingForNetworkChange:n=n||gt.t("Waiting for changing wallet network");break;default:n=n||"";break}r=r||"",n=n||"";let s=n?.indexOf("code")!==-1&&n?.indexOf("reason")!==-1;return{shortMessage:n,detailedMessage:{content:r,long:s}}}i(Kc,"getSwapMessages");function jc(t){let e=null;if(t.status==="failed"){let o=t.steps.slice().reverse().filter(n=>n.status==="success")[0];o&&(e={blockchain:o.toBlockchain,symbol:o.toSymbol,outputAmount:o.outputAmount,address:o.toSymbolAddress})}return e}i(jc,"getLastConvertedTokenInFailedSwap");function Xc(t){return t.status==="failed"}i(Xc,"shouldRetrySwap");function Yc(t,e,o,n,r,a){if(!n||t)return!0;let s=ao({filter:"all",quote:n}),l=ao({filter:"required",quote:n}),p=s.every(m=>r.some(g=>g.chain===m)),u=l.every(m=>r.some(g=>g.chain===m)),c=o&&a?No(a,o):!1;return!e&&!p||e&&!o||e&&!!o&&(!c||!u)}i(Yc,"isConfirmSwapDisabled");function Zc(t,e){return t.blockchain===e.blockchain&&t.symbol===e.symbol&&t.address===e.address}i(Zc,"isTokensIdentical");function ho(t){let e=t?.swaps||[];return e[e.length-1].to.usdPrice}i(ho,"getQuoteToTokenUsdPrice");function hn(t){return(t?.swaps||[])[0].from.usdPrice}i(hn,"getQuoteFromTokenUsdPrice");function Pa(t,e){let o=t?.swaps||[],n=e?.swaps||[];return o.length!==n.length}i(Pa,"isNumberOfSwapsChanged");function Da(t,e){let o=t?.swaps.map(r=>r.swapperId)||[],n=e?.swaps.map(r=>r.swapperId)||[];return!pa(o,n)}i(Da,"isQuoteSwappersUpdated");function _a(t,e){let o=t?.swaps.map(r=>r.to.symbol)||[],n=e?.swaps.map(r=>r.to.symbol)||[];return!pa(o,n)}i(_a,"isQuoteInternalCoinsUpdated");function eu(t,e){return Pa(t,e)||Da(t,e)||_a(t,e)}i(eu,"isQuoteChanged");function Jc(t,e){if(e===null)return null;let o=e?.find(n=>n.blockchain===t.chain)?.wallets.find(n=>n.address?.toLowerCase()===t.address.toLowerCase());return o?o.requiredAssets:null}i(Jc,"getRequiredBalanceOfWallet");function Lt(t){let e;return t<=-3&&t>-10?e="low":t<=-10&&(e="high"),e}i(Lt,"getPriceImpactLevel");function Lr(t,e,o){let n=t.steps[0],r=t.steps[t.steps.length-1],a=xS(t.steps),s={blockchain:r.toBlockchain,symbol:r.toSymbol,address:r.toSymbolAddress},l=nn(a?a.toBlockchain:n.fromBlockchain,e),p=nn(r.toBlockchain,e),u=o(a?{blockchain:l?.name??"",symbol:a.toSymbol,address:a.toSymbolAddress}:{blockchain:l?.name??"",symbol:n.fromSymbol,address:n.fromSymbolAddress}),c=o(s),m=a?a.outputAmount??"":t.inputAmount;return{fromBlockchain:l,fromToken:u,toBlockchain:p,toToken:c,inputAmount:m}}i(Lr,"createRetryQuote");function Fo(t,e){let{fromToken:o,toToken:n,findToken:r,userSlippage:a}=e,s=jt(t.requestAmount,hn(t)||o?.usdPrice),l=jt(t.outputAmount,ho(t)||n?.usdPrice);if(t&&s&&l){let c=ut(s.toString(),l.toString());if(!!c&&Lc(s,c)){let g=Wr(t?.swaps,r),d=Lt(c);return{type:0,inputUsdValue:s,outputUsdValue:l,priceImpact:c,totalFee:g,warningLevel:d}}}else if(t&&(!s||!l))return{type:1};let p=Mr(t.swaps),u=a>Jp;if(zc(e.userSlippage.toString(),p)){if(u&&parseFloat(p??"0")<a)return{type:3,slippage:a.toString()}}else return{type:2,recommendedSlippages:Uc(t,a),minRequiredSlippage:p};return null}i(Fo,"generateQuoteWarnings");function ut(t,e){let o=typeof e=="string"?parseFloat(e)<=0:!e?.gt(0),n=!t||!e||o?null:Hc(t.toString(),e.toString());return n&&n<0?n:null}i(ut,"getPriceImpact");var tu=i(t=>{let e=new Set,o=[];return t.forEach(n=>{e.has(n.from.chain.displayName)||(e.add(n.from.chain.displayName),o.push(n.from.chain)),e.has(n.to.chain.displayName)||(e.add(n.to.chain.displayName),o.push(n.to.chain))}),o},"getUniqueBlockchains"),Pr=i((t,e)=>e.sort((o,n)=>{let r=i(u=>u.scores?.find(c=>c.preferenceType===t)?.score??0,"getScore"),a=r(o),s=r(n);if(a!==s)return s-a;let l=o.requestId.toLowerCase(),p=n.requestId.toLowerCase();return l.localeCompare(p)}),"sortQuotesBy"),ou=i((t,e,o)=>{if(!e.length)return null;if(!t)return{requestAmount:o,...e[0]};let n=new Set(t.swaps.map(a=>a.swapperId)),r=e.find(a=>{let s=new Set(a.swaps.map(l=>l.swapperId));return Array.from(n).every(l=>s.has(l))});return{requestAmount:o,...r||e[0]}},"getDefaultQuote"),nu=i(t=>{let e=i((o,n)=>{let r=Wa.indexOf(o.value),a=Wa.indexOf(n.value);return r!==-1&&a!==-1?r-a:r!==-1?-1:a!==-1?1:0},"customSort");return t.sort(e)},"sortTags");var Dr=i((t,e)=>t?.usdPrice?new Xe(e||Ue).multipliedBy(t?.usdPrice||0):null,"getUsdValue"),z=Gt(wS()(bS(t=>({fromBlockchain:null,fromToken:null,inputAmount:"",outputAmount:null,inputUsdValue:new Xe(0),outputUsdValue:new Xe(0),toBlockchain:null,toToken:null,refetchQuote:!0,sortStrategy:"SMART",selectedQuote:null,quotes:null,error:null,warning:null,quoteWalletsConfirmed:!1,selectedWallets:[],customDestination:null,quoteWarningsConfirmed:!1,updateQuotePartialState:(e,o)=>t(n=>({...n,[e]:o})),setSelectedQuote:e=>t(o=>{let n=null,r=Ue,a=o.inputUsdValue;return ln(o.inputAmount)?(e&&(n=e?.outputAmount?new Xe(e?.outputAmount):null,a=jt(o.inputAmount,hn(e)||o.fromToken?.usdPrice),r=jt(e.outputAmount,ho(e)||o.toToken?.usdPrice)),{selectedQuote:e,...!!e&&{outputAmount:n,outputUsdValue:r,inputUsdValue:a}}):{}}),resetAlerts:()=>t(()=>({error:null,warning:null})),resetQuote:()=>t(()=>({selectedQuote:null,outputAmount:null,outputUsdValue:new Xe(0),quotes:null,refetchQuote:!0,error:null,warning:null})),setFromBlockchain:e=>{t(o=>o.fromBlockchain?.name===e?.name?{}:{fromBlockchain:e,inputUsdValue:new Xe(0),...o.fromToken&&{selectedQuote:null,fromToken:null,outputAmount:null,outputUsdValue:new Xe(0)}})},setFromToken:e=>t(o=>({fromToken:e.token,...e.token&&{fromBlockchain:e.meta.blockchains.find(n=>n.name===e.token.blockchain)??null},...!!o.inputAmount&&{inputUsdValue:Dr(e.token,o.inputAmount)}})),setToBlockchain:e=>{t(o=>o.toBlockchain?.name===e?.name?{}:{toBlockchain:e,...o.toToken&&{selectedQuote:null,toToken:null,outputAmount:null,outputUsdValue:new Xe(0)}})},setToToken:e=>t(()=>({toToken:e.token,...e.token&&{toBlockchain:e.meta.blockchains.find(o=>o.name===e.token.blockchain)??null}})),setInputAmount:e=>{t(o=>({inputAmount:e,...!e&&{outputAmount:null,outputUsdValue:new Xe(0),selectedQuote:null},...!!o.fromToken&&{inputUsdValue:Dr(o.fromToken,e)}}))},retry:e=>{let{fromBlockchain:o,fromToken:n,toBlockchain:r,toToken:a,inputAmount:s}=e;t({fromBlockchain:o,fromToken:n,inputAmount:s,outputAmount:null,inputUsdValue:Dr(n??null,s),outputUsdValue:new Xe(0),toBlockchain:r,toToken:a,selectedQuote:null})},switchFromAndTo:()=>t(e=>({fromBlockchain:e.toBlockchain,fromToken:e.toToken,toBlockchain:e.fromBlockchain,toToken:e.fromToken,inputAmount:e.outputAmount?.toString()||"",inputUsdValue:e.toToken?Dr(e.toToken,e.outputAmount?.toString()||""):new Xe(0)})),resetFromBlockchain:()=>t(()=>({fromToken:null,fromBlockchain:null,outputUsdValue:new Xe(0),inputUsdValue:new Xe(0),inputAmount:"",outputAmount:null,selectedQuote:null})),resetToBlockchain:()=>t(()=>({toToken:null,toBlockchain:null,outputAmount:null,outputUsdValue:new Xe(0),selectedQuote:null})),setQuoteWalletConfirmed:e=>t({quoteWalletsConfirmed:e}),setSelectedWallets:e=>t({selectedWallets:e}),setCustomDestination:e=>t({customDestination:e}),resetQuoteWallets:()=>t({quoteWalletsConfirmed:!1,selectedWallets:[],customDestination:null}),setQuoteWarningsConfirmed:e=>t({quoteWarningsConfirmed:e})})))),ru=z.subscribe((t,e)=>{(t.fromBlockchain!==e.fromBlockchain||t.fromToken!==e.fromToken||t.toBlockchain!==e.toBlockchain||t.toToken!==e.toToken||t.inputAmount!==e.inputAmount)&&ye.emit("quoteEvent",{type:"quoteInputUpdate",payload:{fromBlockchain:t.fromBlockchain?.name,toBlockchain:t.toBlockchain?.name,fromToken:t.fromToken?{symbol:t.fromToken.symbol,name:t.fromToken.name,address:t.fromToken.address}:void 0,toToken:t.toToken?{symbol:t.toToken.symbol,name:t.toToken.name,address:t.toToken.address}:void 0,requestAmount:t.inputAmount}}),t.selectedQuote?.requestId!==e.selectedQuote?.requestId&&ye.emit("quoteEvent",{type:"quoteOutputUpdate",payload:t.selectedQuote?{requestAmount:t.selectedQuote.requestAmount,swaps:t.selectedQuote.swaps,outputAmount:t.selectedQuote.outputAmount,resultType:t.selectedQuote.resultType,tags:t.selectedQuote.tags}:null})});function iu(){let{setInputAmount:t,setToToken:e,setToBlockchain:o,setFromBlockchain:n,resetQuote:r,setFromToken:a,fromToken:s,toToken:l,fromBlockchain:p,toBlockchain:u}=z(),c=y().config,m=y().fetchStatus,g=y().blockchains(),d=y().tokens(),{findToken:f}=y(),{setAffiliateRef:h,setAffiliatePercent:T,setAffiliateWallets:S}=y(),C=c?.from?.tokens,k=c?.from?.blockchains,v=c?.to?.tokens,x=c?.to?.blockchains,N=_r(void 0),M=_r(void 0),w=_r(void 0),E=_r(void 0);Oo(()=>{typeof c.amount<"u"&&t(c.amount.toString())},[c?.amount]),Oo(()=>{if(m==="success"){r();let b=g.find(I=>I.name===c?.from?.blockchain),W=c?.from?.token,$=W&&f(W);(b||!b&&w.current)&&n(b??null),$?a({token:$,meta:{blockchains:g,tokens:d}}):!$&&N.current&&a({token:null}),w.current=c?.from?.blockchain,N.current=c?.from?.token}},[c?.from?.token?.symbol,c?.from?.token?.address,c?.from?.token?.blockchain,c?.from?.blockchain,m]),Oo(()=>{da(s,C)&&a({token:null}),fa(p,k)&&n(null)},[C,k]),Oo(()=>{da(l,v)&&a({token:null}),fa(u,x)&&o(null)},[v,x]),Oo(()=>{if(m==="success"){r();let b=g.find(I=>I.name===c?.to?.blockchain),W=c?.to?.token,$=W&&f(W);(b||!b&&E.current)&&o(b??null),$?e({token:$,meta:{blockchains:g,tokens:d}}):!$&&M.current&&e({token:null}),E.current=c?.to?.blockchain,M.current=c?.to?.token}},[c?.to?.token?.symbol,c?.to?.token?.address,c?.to?.token?.blockchain,c?.to?.blockchain,m]),Oo(()=>{h(c?.affiliate?.ref??null),T(c?.affiliate?.percent??null),S(c?.affiliate?.wallets??null)},[c?.affiliate?.ref,c?.affiliate?.percent,c?.affiliate?.wallets])}i(iu,"useSyncStoresWithConfig");import{useEffect as Oa,useRef as ES}from"react";import{useInRouterContext as IS,useLocation as AS,useSearchParams as NS}from"react-router-dom";function $a(t,e){let o=t.split("--");return{blockchain:e.name,address:o?.[1]||null,symbol:o[0]}}i($a,"convertTokenSearchParamToAsset");function Fa(t){if(t)return`${t.symbol}${t.address?`--${t.address}`:""}`}i(Fa,"tokenToSearchParam");function za(){let t=AS(),[e,o]=NS(),{fromBlockchain:n,toBlockchain:r,fromToken:a,toToken:s,inputAmount:l,setFromBlockchain:p,setToBlockchain:u,setFromToken:c,setToToken:m,setInputAmount:g}=z(),d=y().fetchStatus,f=y().blockchains(),h=y().tokens(),T=IS(),{updateIframe:S,updateCampaignMode:C}=y(),k=y().isInCampaignMode(),v=ES(),{findToken:x}=y(),N=i(()=>{let w={};for(let[V,le]of e.entries())V.startsWith("utm_")&&(w[V]=le);let E=e.get("fromAmount"),b=e.get("fromBlockchain"),W=e.get("fromToken"),$=e.get("toBlockchain"),I=e.get("toToken"),R=e.get("autoConnect"),ee=e.get("clientUrl"),oe=e.get("liquiditySources"),L=e.get("blockchain");return{fromAmount:E,fromBlockchain:b,fromToken:W,toBlockchain:$,toToken:I,autoConnect:R,clientUrl:ee,liquiditySources:oe,utmQueryParams:w,blockchain:L}},"getUrlSearchParams"),M=i(w=>{for(let E in w)w[E]||delete w[E];o(w,{replace:!0})},"updateUrlSearchParams");Oa(()=>{let{autoConnect:w,clientUrl:E,utmQueryParams:b,blockchain:W}=N();T&&d==="success"&&M({fromBlockchain:n?.name,fromToken:Fa(a),toBlockchain:r?.name,toToken:Fa(s),fromAmount:l,autoConnect:w??void 0,clientUrl:E??void 0,blockchain:W??void 0,liquiditySources:k?v.current:void 0,...b})},[t.pathname,l,n,a,r,s,k]),Oa(()=>{if(!T)return;let w=N();if(!v.current&&w.liquiditySources&&(v.current=w.liquiditySources),w.fromAmount&&g(w.fromAmount),d==="success"){let E=f.find(I=>I.name===w.fromBlockchain),b=w.fromToken&&E?x($a(w.fromToken,E)):void 0,W=f.find(I=>I.name===w.toBlockchain),$=w.toToken&&W?x($a(w.toToken,W)):void 0;E&&(p(E),b&&c({token:b,meta:{blockchains:f,tokens:h}})),W&&(u(W),$&&m({token:$,meta:{blockchains:f,tokens:h}}))}},[d]),Oa(()=>{let{clientUrl:w,liquiditySources:E}=N();S("clientUrl",w||void 0),C("liquiditySources",E?.split(",")??void 0)},[])}i(za,"useSyncUrlAndStore");import{i18n as At}from"@lingui/core";import{Alert as qC,Button as Ou,darkTheme as HC,Divider as Cn,DoneIcon as GC,MessageBox as VC,styled as KC,TextField as jC,Typography as XC}from"@rango-dev/ui";import Se,{useEffect as YC,useState as qr}from"react";import{useNavigate as ZC,useSearchParams as JC}from"react-router-dom";import{ChevronRightIcon as WS,Divider as cu,Image as MS,Typography as uu}from"@rango-dev/ui";import ht from"react";import{darkTheme as au,styled as Qa}from"@rango-dev/ui";var su=Qa("div",{display:"flex",justifyContent:"space-between",width:"100%",height:"$40",padding:"$4 $10",borderRadius:"$sm",cursor:"pointer",alignItems:"center",backgroundColor:"$neutral300",[`.${au} &`]:{backgroundColor:"$neutral400"},"&:hover":{backgroundColor:"$secondary100",[`.${au} &`]:{backgroundColor:"$neutral500"}},variants:{disabled:{true:{cursor:"default","&:hover":{borderColor:"$neutral300","& svg":{color:"$neutral700"}}}}}}),lu=Qa("div",{display:"flex",flexDirection:"column",width:"100%",".title_typography":{textTransform:"capitalize"}}),pu=Qa("div",{display:"flex"});function qa(t){let{onClick:e,value:o,title:n,hasLogo:r,placeholder:a,disabled:s}=t;return ht.createElement(lu,null,ht.createElement(uu,{size:"large",variant:"label"},n),ht.createElement(cu,{size:10}),ht.createElement(su,{onClick:s?void 0:e,disabled:s},ht.createElement(pu,null,r&&ht.createElement(ht.Fragment,null,ht.createElement(MS,{src:o?.logo,size:16,useAsPlaceholder:!o?.logo,type:"circular"}),ht.createElement(cu,{size:4,direction:"horizontal"})),ht.createElement(uu,{className:"title_typography",size:"medium",variant:"label"},o?.name||a)),ht.createElement(WS,{size:12,color:"black"})))}i(qa,"BlockchainSelectorButton");import{i18n as Ga}from"@lingui/core";import{Button as BS,Divider as yn,ExternalLinkIcon as LS,Image as PS,Typography as zo}from"@rango-dev/ui";import Me from"react";function mu(t,e){if(e.type==="COSMOS")return"";let o=e.info?.addressUrl;return!o||!t?"":o.replace("{wallet}",t)}i(mu,"generateExplorerLink");import{darkTheme as Uo,styled as du}from"@rango-dev/ui";var Ha=du("a",{textDecoration:"none",color:"$colors$neutral700",[`.${Uo} &`]:{color:"$colors$neutral900"},"& svg":{marginLeft:"$4",color:"$colors$neutral700",[`.${Uo} &`]:{color:"$colors$neutral900"}},variants:{hasHover:{true:{"&:hover":{color:"$colors$secondary550",[`.${Uo} &`]:{color:"$colors$secondary500"},"& svg":{color:"$colors$secondary550",[`.${Uo} &`]:{color:"$colors$secondary500"}}}},false:{}}}}),fu=du("div",{display:"flex",justifyContent:"center",flexDirection:"column",alignItems:"center",textAlign:"center","& ._blockchain-name, & ._coin-source":{color:"$colors$neutral600",[`.${Uo} &`]:{color:"$colors$neutral800"}},"& ._coin-source-name, & ._custom-token-description":{color:"$colors$neutral700",[`.${Uo} &`]:{color:"$colors$neutral900"}}});function Va(t){let{open:e,onClose:o,token:n,onSubmitClick:r,blockchain:a}=t,s=mu(n.address,a);return Me.createElement(J,{open:e,dismissible:!0,onClose:o,container:A()},Me.createElement(fu,null,Me.createElement(PS,{src:n.image,size:45,type:"circular"}),Me.createElement(zo,{variant:"title",size:"medium"},n.name),Me.createElement(zo,{variant:"body",size:"small",className:"_blockchain-name"},a.displayName),Me.createElement(yn,{size:4}),Me.createElement(zo,{variant:"body",size:"medium"},s?Me.createElement(Ha,{hasHover:!0,href:s,target:"_blank",rel:"nofollow noreferrer"},n.address,Me.createElement(LS,{size:12,color:"gray"})):Me.createElement(Ha,null,n.address)),Me.createElement(yn,{size:4}),n.coinSource&&Me.createElement(zo,{className:"_coin-source",variant:"body",size:"xsmall"},Ga.t("via")," ",Me.createElement(zo,{className:"_coin-source-name",variant:"body",size:"xsmall"},n.coinSource)),Me.createElement(yn,{size:"32"}),Me.createElement(zo,{size:"medium",variant:"body",className:"_custom-token-description"},Ga.t("This token doesn't appear on the active token list(s). Make sure this is the token that you want to trade."))),Me.createElement(yn,{size:40}),Me.createElement(yn,{size:10}),Me.createElement(BS,{variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:r},Ga.t("Import")))}i(Va,"CustomTokenModal");import{useManager as $C}from"@rango-dev/queue-manager-react";import{BottomLogo as FC,Divider as Pu,Header as OC}from"@rango-dev/ui";import ke,{useEffect as fs,useRef as Du,useState as UC}from"react";import{useRef as DS}from"react";function $r(){return window.self!==window.top}i($r,"isAppLoadedIntoIframe");function Ka(){let t=DS(null),{iframe:e}=y(),o=$r()&&e.clientUrl,n=i(s=>{o&&window.top?.postMessage(s,e.clientUrl)},"send");return{send:n,connectHeightObserver:i(s=>{t.current=new ResizeObserver(l=>{for(let p of l)n({type:"widget_height",data:{height:p.contentRect.height}})}),t.current.observe(s)},"connectHeightObserver"),disconnectHeightObserver:i(()=>{t.current&&(t.current.disconnect(),t.current=null)},"disconnectHeightObserver")}}i(Ka,"useIframe");import{useNavigate as _S}from"react-router-dom";function Ye(){let t=_S();return()=>t(-1)}i(Ye,"useNavigateBack");import{createTheme as es,darkTheme as YS,lightTheme as ZS}from"@rango-dev/ui";import{useEffect as JS,useState as RS}from"react";import{theme as jS,darkColors as XS}from"@rango-dev/ui";import Ja from"react";function $S(t){return t.startsWith("#")&&(t=t.slice(1)),t.length===3?`#${t.split("").reduce(function(n,r){return n+r+r},"")}`:`#${t}`}i($S,"expandShortHexColor");function FS(t){return/[0-9]+$/.test(t)}i(FS,"isOverridingColor");function OS(t,e){return t.padStart(e,"0")}i(OS,"pad");function ja(t){let e=Math.min(Math.max(Math.round(t),0),255);return OS(e.toString(16),2)}i(ja,"intToHex");function US(t){return`#${ja(t.red)}${ja(t.green)}${ja(t.blue)}`}i(US,"rgbToHex");function zS(t){let e=parseInt(t.slice(1,3),16),o=parseInt(t.slice(3,5),16),n=parseInt(t.slice(5,7),16);return{red:e,green:o,blue:n}}i(zS,"hexToRGB");function QS(t,e){let o=1-.11*e;return{red:t.red*o,green:t.green*o,blue:t.blue*o}}i(QS,"generateShade");function qS(t,e){let o=.11*e;return{red:t.red+(255-t.red)*o,green:t.green+(255-t.green)*o,blue:t.blue+(255-t.blue)*o}}i(qS,"generateTint");function HS(t){return gu(t,QS)}i(HS,"calculateShades");function GS(t){return gu(t,qS)}i(GS,"calculateTints");function gu(t,e){let o=zS(t),n=[];for(let r=1;r<9;r++)n.push(US(e(o,r)));return n}i(gu,"calculateColors");function Xa(t,e,o){let a=GS(t).reverse().concat(t),s=HS(t),l=a.concat(s),p={},u=l.length;for(let c=0;c<u;c++){let m=100+(o?u-1-c:c)*50;p[`${e}${m}`]=l[c]}return p}i(Xa,"createTintsAndShades");function Ya(t,e,o){let n={...t};for(let r in e){let a=e[r],s=r==="neutral"&&!!o?.reverseNeutralRange;if(!["background","foreground"].includes(r)&&!FS(r)){let p=$S(a);Object.assign(n,Xa(p,r,s))}}return{...n,...e}}i(Ya,"expandToGenerateThemeColors");var hu=i(t=>String.fromCharCode(t+(t>25?39:97)),"toAlphabeticChar"),VS=i(t=>{let e="",o;for(o=Math.abs(t);o>52;o=o/52|0)e=hu(o%52)+e;return hu(o%52)+e},"toAlphabeticName"),KS=i((t,e)=>{let o=e.length;for(;o;)t=t*33^e.charCodeAt(--o);return t},"toPhash"),Za=i(t=>VS(KS(5381,JSON.stringify(t))>>>0),"toHash");function Ra(t){let e=jS.colors,o={...e,...XS},n,r;if(t?.light){let s={colors:Ya(e,t.light)};n={id:`${ma}-light-${Za(s)}`,tokens:s}}if(t?.dark){let s={colors:Ya(o,t.dark,{reverseNeutralRange:!0})};r={id:`${ma}-dark-${Za(s)}`,tokens:s}}return{light:n,dark:r}}i(Ra,"customizedThemeTokens");function yu(t,e){if(t.length<=1)return t.map(({element:n,key:r})=>Ja.cloneElement(n,{key:r}));let o=[];return t.forEach((n,r)=>{let{element:a,key:s}=n;if(o.push(Ja.cloneElement(a,{key:s})),r<t.length-1){let l=`divider-${r}`;o.push(Ja.cloneElement(e,{key:l}))}}),o}i(yu,"joinList");function Su(){return window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches}i(Su,"doesWindowPreferDarkColorScheme");function Qo(t){let{colors:e,fontFamily:o=yp,borderRadius:n=Qp,secondaryBorderRadius:r=qp}=t,[a,s]=RS(Su()?"dark":"light"),{theme:l}=y(),{dark:p,light:u}=Ra(e),c=es({shadows:t.shadows||{},radii:{primary:`${n}px`,secondary:`${r}px`},fonts:{widget:o}}),m=[c.className,ZS.className],g=[c.className,YS.className];if(u){let f=es(u.id,u.tokens);m.push(f.className)}if(p){let f=es(p.id,p.tokens);g.push(f.className)}return JS(()=>{let f=i(h=>{h.matches?s("dark"):s("light")},"switchThemeListener");return Su()&&s("dark"),window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",f),()=>{window.matchMedia("(prefers-color-scheme: dark)").removeEventListener("change",f)}},[]),{activeTheme:i(()=>{let f=m.join(" "),h=g.join(" ");return l==="auto"?a==="dark"?h:f:l==="dark"?h:f},"getActiveTheme"),mode:l==="auto"?a:l}}i(Qo,"useTheme");var mt=i(t=>{let e=[];return t?.getAll().forEach((o,n)=>{let r=o.list.getStorage();r?.swapDetails&&e.push({id:n,swap:r?.swapDetails})}),e.sort((o,n)=>Number(n.swap.creationTime)-Number(o.swap.creationTime))},"getPendingSwaps");import{i18n as Cu}from"@lingui/core";import{Alert as eC,Button as tC}from"@rango-dev/ui";import Tu from"react";function ts(t){return Tu.createElement(eC,{action:Tu.createElement(tC,{onClick:t.onActivateTab,variant:"contained",size:"xxsmall",type:"warning"},Cu.t("Activate this tab")),type:"warning",variant:"alarm",title:Cu.t("Another tab is open and handles transactions.")})}i(ts,"ActivateTabAlert");import{i18n as os}from"@lingui/core";import{Button as oC,Divider as nC,MessageBox as rC}from"@rango-dev/ui";import Fr from"react";function ns(t){let{open:e,onClose:o,onConfirm:n}=t;return Fr.createElement(J,{open:e,dismissible:!0,onClose:o,container:A()},Fr.createElement(rC,{title:os.t("Activate current tab"),type:"warning",description:os.t("Currently, some transactions are running and being handled by other browser tab. If you activate this tab, all transactions that are already in the transaction sign step will expire.")},Fr.createElement(nC,{size:20}),Fr.createElement(oC,{variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:n},os.t("Confirm"))))}i(ns,"ActivateTabModal");import{ChevronLeftIcon as iC}from"@rango-dev/ui";import ku from"react";function rs(t){return ku.createElement(It,{variant:"ghost",size:"small",onClick:t.onClick},ku.createElement(iC,{color:"black",size:16}))}i(rs,"BackButton");import{i18n as aC}from"@lingui/core";import{Button as sC,Typography as lC}from"@rango-dev/ui";import is from"react";function as(t){return is.createElement(Vt,null,is.createElement(sC,{variant:"ghost",onClick:t.onClick,size:"xsmall"},is.createElement(lC,{variant:"label",size:"medium",color:"error500"},aC.t("Cancel"))))}i(as,"CancelButton");import{i18n as pC}from"@lingui/core";import{Image as cC,Tooltip as uC,WalletIcon as mC}from"@rango-dev/ui";import yo from"react";function ss(t){let{list:e}=ft(),o=e.filter(r=>r.state==="connected"),n=o.length?yo.createElement("div",{className:fc()},o.map(r=>yo.createElement(Tr,{key:r.title},yo.createElement(cC,{src:r.image,size:14})))):pC.t("Connect Wallet");return yo.createElement(uC,{container:t.container,side:"bottom",content:n},yo.createElement(It,{variant:"ghost",size:"small",onClick:t.onClick},t.isConnected&&yo.createElement(cc,null),yo.createElement(mC,{size:18,color:"black"})))}i(ss,"WalletButton");import{i18n as Ur}from"@lingui/core";import{NotificationsIcon as AC,Popover as NC,SettingsIcon as WC,Tooltip as zr,TransactionIcon as MC}from"@rango-dev/ui";import Be from"react";import{Notifications as hC}from"@rango-dev/ui";import yC from"react";import{useNavigate as SC}from"react-router-dom";import{create as dC}from"zustand";import{persist as fC,subscribeWithSelector as gC}from"zustand/middleware";var be=Gt(dC()(fC(gC((t,e)=>({isSynced:!1,notifications:[],setNotification:(o,n)=>{let r=n.steps[0],a=n.steps[n.steps.length-1],s={event:o,creationTime:Date.now(),requestId:n.requestId,route:{creationTime:parseInt(n.creationTime),from:{blockchain:r.fromBlockchain,address:r.fromSymbolAddress,symbol:r.fromSymbol},to:{blockchain:a.toBlockchain,address:a.toSymbolAddress,symbol:a.toSymbol}}},l=e().notifications.filter(p=>p.requestId!==n.requestId);t(()=>({notifications:[...l,s]}))},removeNotification:o=>{t(n=>({notifications:n.notifications.filter(r=>r.requestId!==o)}))},getNotifications:()=>{let{isSynced:o,notifications:n}=e();return o?n.sort((r,a)=>r.route.creationTime&&!a.route.creationTime?-1:!r.route.creationTime&&a.route.creationTime?1:!r.route.creationTime&&!a.route.creationTime?a.creationTime-r.creationTime:a.route.creationTime-r.route.creationTime):[]},syncNotifications:o=>{let{isSynced:n,notifications:r}=e();if(!n){let a=[];r.forEach(s=>{o.some(p=>p.swap.requestId===s.requestId)&&a.push(s)}),t({isSynced:!0,notifications:a})}},clearNotifications:()=>t({notifications:[]})})),{name:"notification",skipHydration:!0,partialize:({isSynced:t,...e})=>e,version:1,migrate:(t,e)=>{if(e===0){let o=t.notifications;t.notifications=o.filter(n=>!n.read).map(({read:n,...r})=>r)}return t}})));function ls(){let t=SC(),{getNotifications:e,clearNotifications:o}=be(),n=e(),r=y().blockchains(),{findToken:a}=y();return yC.createElement(hC,{list:n,getBlockchainImage:l=>cp(l,r)??"",getTokenImage:l=>a(l)?.image??"",onClickItem:i(l=>{t(`${D.swaps}/${l}`)},"onClickItem"),onClearAll:o})}i(ls,"NotificationContent");import{useManager as CC}from"@rango-dev/queue-manager-react";import{InProgressIcon as TC}from"@rango-dev/ui";import vu from"react";var kC=i(()=>{let{manager:t}=CC();return mt(t).map(({swap:o})=>o).find(o=>o.status==="running")?vu.createElement(dc,null,vu.createElement(TC,{color:"info",size:6})):null},"InProgressTransactionBadge"),xu=kC;import{EventSeverity as vC}from"@rango-dev/queue-manager-rango-preset";import{Typography as xC}from"@rango-dev/ui";import wu from"react";function bu(){let{getNotifications:t}=be(),e=t(),o=e.length,n=!!e.find(r=>r.event.messageSeverity===vC.WARNING);return o?wu.createElement(uc,{isSever:n},wu.createElement(xC,{variant:"body",size:"xsmall",color:"$background"},o)):null}i(bu,"NotificationsBadge");import{RefreshProgressButton as wC}from"@rango-dev/ui";import ps,{useEffect as bC,useState as Eu}from"react";var EC=1e3,Iu=60,IC=100;function Or({onClick:t}){let[e,o]=Eu(0),[n,r]=Eu(!1),a=i(p=>{document.hidden&&p&&s(p)},"handleVisibilityChange");bC(()=>{let p;return t?p=window.setInterval(()=>{o(u=>u+1),e===Iu&&l()},EC):s(p),document.addEventListener("visibilitychange",()=>a(p)),()=>{document.removeEventListener("visibilitychange",()=>a(p)),p&&clearInterval(p)}},[e,t]);let s=i(p=>{p&&clearInterval(p),o(0)},"clearTimeout"),l=i(()=>{t?.(),o(0),r(!0)},"handleRefreshClick");return ps.createElement(It,{variant:"ghost",size:"small",style:{paddingTop:0,paddingBottom:0},onClick:l,disabled:!t},ps.createElement(mc,{onTransitionEnd:()=>r(!1),isRefetched:n},ps.createElement(wC,{size:22,color:t?"black":"gray",progress:e/Iu*IC})))}i(Or,"RefreshButton");function So(t){let{onClickRefresh:e,onClickHistory:o,onClickSettings:n,hidden:r=[],container:a}=t,{config:{features:s}}=y(),l=je("notification",s)||r.includes("notifications");return Be.createElement(Be.Fragment,null,!r.includes("refresh")&&Be.createElement(zr,{container:a||A(),side:"top",content:Ur.t("Refresh")},Be.createElement(Or,{onClick:e})),!l&&Be.createElement(NC,{align:"end",alignOffset:-88,sideOffset:15,collisionPadding:{right:20,left:20},container:A(),content:Be.createElement(ls,null)},Be.createElement("div",null,Be.createElement(zr,{container:A(),side:"top",content:Ur.t("Notifications")},Be.createElement(It,{size:"small",variant:"ghost"},Be.createElement(AC,{size:18,color:"black"}),Be.createElement(bu,null))))),!r.includes("settings")&&Be.createElement(zr,{container:A(),side:"top",content:Ur.t("Settings")},Be.createElement(It,{size:"small",variant:"ghost",onClick:n},Be.createElement(WC,{size:18,color:"black"}))),!r.includes("history")&&Be.createElement(zr,{container:A(),side:"top",content:Ur.t("Transactions History")},Be.createElement(It,{size:"small",variant:"ghost",onClick:o},Be.createElement(MC,{size:18,color:"black"}),Be.createElement(xu,null))))}i(So,"HeaderButtons");import{i18n as cs}from"@lingui/core";import{Divider as Nu,MessageBox as PC,RefreshIcon as DC}from"@rango-dev/ui";import qo from"react";import{Button as BC,styled as LC}from"@rango-dev/ui";var Au=LC(BC,{"& span":{display:"flex",justifyContent:"center",alignItems:"center"}});function us(t){let{open:e,onClose:o}=t;return qo.createElement(J,{open:e,dismissible:!0,onClose:o,container:A()},qo.createElement(PC,{title:cs.t("Something went wrong"),type:"error",description:cs.t("Something went wrong. Please refresh the app.")},qo.createElement(Nu,{size:30}),qo.createElement(Au,{variant:"outlined",size:"large",type:"primary",fullWidth:!0,onClick:()=>location.reload()},qo.createElement(DC,{size:20,color:"primary"}),qo.createElement(Nu,{size:4,direction:"horizontal"}),cs.t("Refresh"))))}i(us,"RefreshModal");function ms(t){let e=t.target;if(e){let o=e.scrollTop,n=A();o>1?n.classList.add("rng-scrolled"):n.classList.remove("rng-scrolled")}}i(ms,"onScrollContentAttachStatusToContainer");import{css as _C,styled as ds}from"@rango-dev/ui";var Wu="700px",Qr=_C({borderRadius:"$primary",display:"flex",flexDirection:"column",overflow:"hidden",boxShadow:"$mainContainer"}),Mu=ds("div",{position:"relative",width:"100vw",minWidth:"300px",maxWidth:"390px",backgroundColor:"$background",variants:{height:{auto:{height:"auto",maxHeight:Wu},fixed:{height:Wu}}}}),Bu=ds("div",{position:"relative",overflow:"hidden",flexGrow:1,display:"flex",flexDirection:"column",padding:0,overflowY:"auto"}),Lu=ds("div",{padding:"0 $20 $10","& .footer__alert":{paddingTop:"$10"},"& .footer__logo":{opacity:0,transition:"opacity 1s ease-in-out","&.logo__show":{opacity:1},"&.logo__hidden":{visibility:"hidden"}}});function ne(t){let{connectHeightObserver:e,disconnectHeightObserver:o}=Ka(),{children:n,header:r,footer:a,height:s="fixed"}=t,{fetchStatus:l}=y(),[p,u]=UC(!1),c=Z.use.connectedWallets(),{config:{features:m,theme:g}}=y(),{watermark:d}=se(),f=d==="FULL",{activeTheme:h}=Qo(g||{}),T=je("connectWalletButton",m),{isActiveTab:S,tabManagerInitiated:C,showActivateTabModal:k,setShowActivateTabModal:v,activateCurrentTab:x}=se(),N=Ye(),{manager:M}=$C(),E=mt(M).map(({swap:ee})=>ee).some(ee=>ee.status==="running"),b=i(()=>x(po.forceClaim,E),"onActivateTab"),W=i(()=>{r.onWallet?.()},"onConnectWallet"),$=typeof r.hasBackButton>"u"||r.hasBackButton,I=Du(null),R=Du(null);return fs(()=>($r()&&R.current&&e(R.current),()=>{o()}),[]),fs(()=>(I.current?.addEventListener("scroll",ms),()=>{I.current?.removeEventListener("scroll",ms)}),[]),fs(()=>{u(l==="failed")},[l]),ke.createElement(Mu,{height:s,id:$e.SWAP_BOX_ID,className:`${h()} ${Qr()}`,ref:R},ke.createElement(OC,{prefix:ke.createElement(ke.Fragment,null,$&&ke.createElement(rs,{onClick:()=>{N(),r.onBack&&r.onBack()}})),title:r.title,suffix:ke.createElement(ke.Fragment,null,r.suffix,r.onWallet&&!T&&ke.createElement(ss,{container:A(),onClick:W,isConnected:!!c?.length}),r.onCancel&&ke.createElement(as,{onClick:r.onCancel}))}),ke.createElement(Bu,{ref:I},n),ke.createElement(ns,{open:k,onClose:()=>v(!1),onConfirm:b}),ke.createElement(Lu,null,ke.createElement("div",{className:"footer__content"},C&&!S&&ke.createElement("div",{className:"footer__alert"},ke.createElement(ts,{onActivateTab:b}),ke.createElement(Pu,{size:10})),a),ke.createElement(Pu,{size:12}),ke.createElement("div",{className:`footer__logo ${f?"logo__show":"logo__hidden"}`},ke.createElement(FC,null))),ke.createElement(us,{open:p,onClose:()=>u(!1)}))}i(ne,"Layout");import{styled as zC}from"@rango-dev/ui";var _u="$20 $20 $10 $20",Sn=zC("div",{padding:_u,overflowY:"auto",flexGrow:1});import{styled as QC}from"@rango-dev/ui";var ie=QC("div",{display:"flex",flexDirection:"column",padding:"20px 20px 10px",flexGrow:1,variants:{view:{true:{flexGrow:1,overflow:"hidden"}},compact:{true:{padding:0}}}});import{i18n as Ho}from"@lingui/core";import{useState as $u}from"react";function Fu(){let[t,e]=$u(!1),[o,n]=$u(void 0),{findToken:r}=y(),a=y().customTokens();function s(p,u){switch(p){case"duplicated":return{title:Ho.t("Duplicate Token"),message:Ho.t("The address you entered is duplicate, please enter a new address.")};case"token-exist":return{title:Ho.t("Token Already Exists"),message:Ho.t("There's no need to add this token again because it already exists and is supported by us.")};case"not-found":return{title:Ho.t("Token Not Found"),message:Ho.t(`Sorry, no token was found on ${u} blockchain with the provided address. please make sure you have entered the right token address.`)}}}return i(s,"produceErrorMessage"),{fetchCustomToken:i(async({blockchain:p,tokenAddress:u})=>{e(!0);try{if(a.some(h=>h.address?.toLowerCase()===u.toLowerCase())){let h=s("duplicated");n(h);return}let m=await fetch(`${ct("BASE_URL")}/meta/token?apiKey=${ct("API_KEY")}&blockchain=${p}&address=${u}`),g=m.headers.get("content-type"),d=g&&g.includes("application/json")&&await m.json();if(!d||d.error){let h=s("not-found",p);n(h);return}if(r({blockchain:d.blockchain,address:d.address,symbol:d.symbol})){let h=s("token-exist");n(h);return}return d}catch(c){throw n(void 0),new Error(c.message)}finally{e(!1)}},"fetchCustomToken"),loading:t,error:o}}i(Fu,"useFetchCustomToken");var RC=KC("div",{display:"flex",justifyContent:"space-between",flexDirection:"column",flex:1,"& ._text-field":{padding:"$4 $10",backgroundColor:"$neutral300",[`.${HC} &`]:{backgroundColor:"$neutral400"},borderRadius:"$sm",height:"$40"}}),eT=1e3;function Uu(){let t=ZC(),[e]=JC(),o=Ye(),{setCustomToken:n}=y(),r=y().blockchains(),a=e.get("blockchain")||"",s=nn(a,r),[l,p]=qr(""),[u,c]=qr(!1),[m,g]=qr(),{fetchCustomToken:d,loading:f,error:h}=Fu(),[T,S]=qr(""),C=!!s&&No(s,l),k=!s||!l||!C,v=i(async()=>{if(s)try{let M=await d({blockchain:a,tokenAddress:l});S(""),M&&g(M)}catch(M){M.message==="Failed to fetch"&&(S(At.t("Network Error")),c(!0))}},"getCustomToken"),x=i(()=>{h&&p(""),c(!1)},"closeErrorModal"),N=i(async()=>{T&&setTimeout(async()=>{await v()},eT),x()},"handleErrorModalButtonClick");return YC(()=>{h&&c(!0)},[h]),Se.createElement(ne,{header:{title:At.t("Add Custom Token")}},Se.createElement(ie,null,Se.createElement(RC,null,Se.createElement("div",null,Se.createElement(qa,{onClick:()=>t(D.blockchains,{replace:!0}),hasLogo:!!s?.logo,value:s?{name:s.displayName,logo:s.logo}:void 0,title:At.t("Select chain"),placeholder:At.t("Select chain")}),Se.createElement(Cn,{size:"24"}),Se.createElement(XC,{size:"large",variant:"label"},At.t("Enter Address")),Se.createElement(Cn,{size:10}),Se.createElement(jC,{fullWidth:!0,disabled:!s,variant:"contained",placeholder:At.t("Enter token address"),size:"large",value:l,suffix:!!l&&C&&Se.createElement(GC,{color:"success",size:12}),onChange:M=>p(M.target.value)}),!C&&!!l&&Se.createElement(Se.Fragment,null,Se.createElement(Cn,{size:4}),Se.createElement(qC,{type:"error",variant:"alarm",title:"Invalid Address"}))),Se.createElement(Ou,{disabled:k,type:"primary",variant:"contained",loading:f,size:"large",onClick:v},At.t("Import"))),Se.createElement(J,{open:u,dismissible:!0,onClose:x,container:A()},Se.createElement(VC,{title:h?.title||T,type:"error",description:h?.message||At.t("Failed Network, Please retry.")},Se.createElement(Cn,{size:40}),Se.createElement(Cn,{size:10}),Se.createElement(Ou,{variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:N},T?At.t("Retry"):At.t("Add another custom token")))),s&&m&&Se.createElement(Va,{blockchain:s,token:m,onSubmitClick:()=>{m&&(n(m),g(void 0),o())},onClose:()=>g(void 0),open:!!s&&!!m})))}i(Uu,"AddCustomTokenPage");import{i18n as qs}from"@lingui/core";import{useManager as Fk}from"@rango-dev/queue-manager-react";import{Alert as Dd,Button as Ok,css as Gs,Divider as Hs,IconButton as _d,styled as Uk,Typography as zk,WalletIcon as Qk}from"@rango-dev/ui";import Ae,{useEffect as Ci,useLayoutEffect as qk,useRef as Hk,useState as Bn}from"react";import{useNavigate as Gk}from"react-router-dom";import{i18n as Co}from"@lingui/core";import{Alert as dm,BalanceErrors as IT,Button as fm,ChevronLeftIcon as AT,Divider as Jr,MessageBox as NT,Typography as vs}from"@rango-dev/ui";import j,{useCallback as WT,useEffect as gm,useMemo as MT,useState as To}from"react";import{useNavigate as BT}from"react-router-dom";import{i18n as Hr}from"@lingui/core";function Gr(t){switch(t.type){case 0:return Hr.t("Route has been updated.");case 3:return Hr.t("Output amount changed to {newOutputAmount} ({percentageChange}% change).",{newOutputAmount:t.newOutputAmount,percentageChange:t.percentageChange});case 1:return Hr.t("Route swappers has been updated.");case 2:return Hr.t("Route internal coins has been updated.");default:return""}}i(Gr,"getQuoteUpdateWarningMessage");import{i18n as Ss}from"@lingui/core";import{Alert as aT,ChevronDownIcon as sT,CloseIcon as lT,Divider as Ku,IconButton as ju,PasteIcon as pT,Typography as cT,WalletIcon as uT}from"@rango-dev/ui";import Le,{useEffect as mT,useRef as dT}from"react";import Xr,{useRef as rT}from"react";import*as Go from"@radix-ui/react-collapsible";import{keyframes as zu,styled as Vr}from"@rango-dev/ui";var gs=300,oT=zu({from:{height:0},to:{height:"var(--radix-collapsible-content-height)"}}),nT=zu({from:{height:"var(--radix-collapsible-content-height)"},to:{height:0}}),Qu=Vr(Go.Root,{borderRadius:"$sm",overflow:"hidden",variants:{selected:{true:{outlineWidth:1,outlineColor:"$secondary500",outlineStyle:"solid"}}}}),hs=Vr(Go.Trigger,{padding:"$0",border:"none",outline:"none",width:"100%",backgroundColor:"transparent",fontFamily:"inherit",cursor:"pointer"}),Kr=Vr(Go.Content,{overflow:"hidden",variants:{open:{true:{animation:`${oT} ${gs}ms ease-out`},false:{animation:`${nT} ${gs}ms ease-out`}}}}),jr=Vr("div",{transition:`all ${gs}ms ease`,display:"flex",alignItems:"center",variants:{orientation:{down:{transform:"rotate(0)"},up:{transform:"rotate(180deg)"}}}});function Yr(t){let{open:e,hasSelected:o,onOpenChange:n,children:r,onClickTrigger:a,trigger:s,triggerAnchor:l}=t,p=rT(null);return Xr.createElement(Qu,{ref:p,className:"collapsible_root",selected:o&&e,open:e,onOpenChange:n},l==="top"&&Xr.createElement(hs,{className:"collapsible_trigger",onClick:a},s),Xr.createElement(Kr,{className:"collapsible_content",open:e},r),l==="bottom"&&Xr.createElement(hs,{className:"collapsible_trigger",onClick:a},s))}i(Yr,"CustomCollapsible");import{darkTheme as qu,styled as ys,TextField as iT}from"@rango-dev/ui";var Hu=ys("div",{padding:"$10 $0","& .button__content":{display:"flex",alignItems:"center"},"& .alarms":{paddingTop:"$5"},"& .collapsible_content":{backgroundColor:"$neutral100"},"& .collapsible_root":{backgroundColor:"$neutral100"}}),Gu=ys(iT,{backgroundColor:"$neutral100",padding:"$15"}),Vu=ys("div",{width:"100%",borderRadius:"$sm",display:"flex",padding:"$15",justifyContent:"space-between",alignItems:"center",$$color:"$colors$neutral100",[`.${qu} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",borderBottomRightRadius:"0",borderBottomLeftRadius:"0","&:focus-visible":{$$background:"$colors$secondary100",[`.${qu} &`]:{$$background:"$colors$info700"},backgroundColor:"$$background",outline:0}});function Xu(t){let{blockchain:e,handleOpenChange:o,open:n}=t,{customDestination:r,setCustomDestination:a}=z(),{config:s}=y(),l=y().blockchains(),p=tr(e.name,l),u=dT(null),c=s?.defaultCustomDestinations?.[e.name],m=navigator?.userAgent.includes("Firefox"),d=n&&!!r&&e&&!No(e,r),f=i(()=>{a("")},"handleClear"),h=i(async S=>{if(S.preventDefault(),navigator.clipboard!==void 0){let C=await navigator.clipboard.readText();a(C),u?.current?.focus()}},"handlePaste"),T=i(()=>r?Le.createElement(ju,{onClick:f,variant:"ghost"},Le.createElement(lT,{size:12,color:"gray"})):m?null:Le.createElement(ju,{onClick:h,variant:"ghost"},Le.createElement(pT,{size:16})),"renderSuffix");return mT(()=>{!!c&&r===null&&(a(c),o(!0))},[c]),Le.createElement(Hu,null,Le.createElement(Yr,{onOpenChange:o,hasSelected:!0,open:n,triggerAnchor:"top",trigger:Le.createElement(Vu,null,Le.createElement("div",{className:"button__content"},Le.createElement(uT,{size:18,color:"info"}),Le.createElement(Ku,{size:4,direction:"horizontal"}),Le.createElement(cT,{variant:"label",size:"medium",color:n?"$neutral600":void 0},Ss.t("Send to a different address"))),Le.createElement(jr,{orientation:n?"up":"down"},Le.createElement(sT,{size:10,color:"secondary"}))),onClickTrigger:()=>o(!n)},Le.createElement(Gu,{ref:u,style:{padding:0,paddingRight:r?"8px":"5px"},autoFocus:!r,placeholder:Ss.t("Enter {blockchainName} address",{blockchainName:p}),value:r||"",suffix:T(),onChange:S=>{let C=S.target.value;a(C)}})),d&&Le.createElement(Le.Fragment,null,Le.createElement(Ku,{size:4}),Le.createElement(aT,{variant:"alarm",type:"error",title:Ss.t({values:{destination:r},id:"Address {destination} doesn't match the blockchain address pattern."})})))}i(Xu,"CustomDestination");import{css as fT,darkTheme as Cs,IconButton as gT,styled as Pt}from"@rango-dev/ui";var Yu=Pt("div",{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center"}),Zu=Pt("div",{display:"flex",justifyContent:"space-evenly",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5",height:"100%"}),hT=Pt("button",{borderRadius:"$xm",padding:"$10",border:"0",display:"flex",justifyContent:"center",$$color:"$colors$neutral100",[`.${Cs} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",alignItems:"center",cursor:"pointer",width:110,position:"relative","&:hover":{$$color:"$colors$secondary100",[`.${Cs} &`]:{$$color:"$colors$neutral100"},backgroundColor:"$$color"},"&:focus-visible":{$$color:"$colors$secondary100",[`.${Cs} &`]:{$$color:"$colors$info700"},backgroundColor:"$$color",outline:0},variants:{selected:{true:{outlineWidth:1,outlineColor:"$secondary",outlineStyle:"solid"}}}}),Ju=Pt(hT,{alignSelf:"stretch",minHeight:"93px"}),Ru=Pt("div",{padding:"$20 $20 $15 $20",display:"flex",justifyContent:"center",alignItems:"center",backgroundColor:"$neutral200",position:"relative",width:"100%"}),em=Pt(gT,{position:"absolute",left:"$20"}),tm=Pt("div",{paddingTop:"$20"}),om=fT({display:"flex",justifyContent:"space-evenly",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5",height:"100%"}),nm=Pt("div",{display:"flex"}),rm=Pt("div",{overflow:"visible",width:"100%"});import{i18n as pm}from"@lingui/core";import{warn as vT}from"@rango-dev/logging-core";import{Divider as xT,SelectableWallet as wT,Typography as cm,WalletState as um}from"@rango-dev/ui";import Ze,{useEffect as mm,useState as kn}from"react";import{Image as CT,MessageBox as TT,Spinner as kT}from"@rango-dev/ui";import Tn from"react";import{keyframes as yT,styled as Ts}from"@rango-dev/ui";var im=Ts("div",{position:"relative"}),ST=yT({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}),qD=Ts("div",{position:"absolute",border:"2px solid rgba(0, 0, 0, 0.1)",borderTop:"2px solid $info500",borderRadius:"$lg",width:"$45",height:"$45",animation:`${ST} 1s linear infinite`,top:0,bottom:0,right:0,left:0}),am=Ts("div",{"& img":{borderRadius:"50%"}});import{i18n as Vo}from"@lingui/core";function sm(t,e){switch(t){case"in-progress":return{type:"loading",title:Vo.t({id:"Add {blockchainDisplayName} Chain",values:{blockchainDisplayName:e}}),description:Vo.t({id:"You should connect a {blockchainDisplayName} supported wallet or choose a different {blockchainDisplayName} address",values:{blockchainDisplayName:e}})};case"completed":return{type:"success",title:Vo.t({id:"{blockchainDisplayName} Chain Added",values:{blockchainDisplayName:e}}),description:Vo.t({id:"You should connect a {blockchainDisplayName} supported wallet or choose a different {blockchainDisplayName} address",values:{blockchainDisplayName:e}})};case"rejected":return{type:"error",title:Vo.t("Request Rejected"),description:Vo.t({id:"You've rejected adding {blockchainDisplayName} chain to your wallet.",values:{blockchainDisplayName:e}})};default:throw new Error(`Showing information about an experimentation chain status needs to be defined first. status: ${t}`)}}i(sm,"generateMessageByStatus");function lm(t){let{status:e,displayName:o,image:n}=t,r=sm(e,o),a=e=="in-progress";return Tn.createElement(TT,{type:r.type,title:r.title,description:r.description,icon:a?Tn.createElement(im,null,Tn.createElement(am,null,Tn.createElement(CT,{src:n,size:45})),Tn.createElement(kT,null)):void 0})}i(lm,"ExperimentalChainStatus");var bT=7,ET=3e3;function ks(t){let{chain:e,isSelected:o,selectWallet:n,limit:r,onShowMore:a}=t,s=se.use.isActiveTab(),l=Z.use.connectedWallets(),{blockchains:p}=y(),[u,c]=kn(),[m,g]=kn(null),[d,f]=kn(!1),[h,T]=kn(null),{suggestAndConnect:S}=Zr(),{handleDisconnect:C}=qt(),{list:k}=ft({chain:e}),[v,x]=kn(k),N=k.length,M=r&&N-r>0,w=i(async b=>{f(!1),T("in-progress");try{await S(b.walletType,b.chain),T("completed")}catch{T("rejected")}},"addExperimentalChain");mm(()=>{x(b=>{let W=k.findIndex($=>o($.type,e));return M&&W>1?[k[W]].concat(k.filter(($,I)=>I!==W)):b.map($=>k.find(I=>I.type===$.type)??$)})},[JSON.stringify(k)]);let E=document.getElementById($e.SWAP_BOX_ID);return mm(()=>{let b=null;return(h==="completed"||h==="rejected")&&(b=setTimeout(()=>T(null),ET)),()=>{b&&clearTimeout(b)}},[h]),Ze.createElement(Ze.Fragment,null,v.slice(0,r).map(b=>{let W=_p({connectedWallets:l,walletType:b.type,chain:e}),$=W?dr(W,bT):"",I=ur(p(),e),R=!l.find(le=>le.walletType===b.type&&le.chain===e),ee=I&&R&&b.state===um.CONNECTED,oe=ee?pm.t({id:"Add {chain} chain",values:{chain:e}}):$,L=i(async()=>{b.state===um.DISCONNECTED?c(b):b.namespaces&&!$?(await C(b.type),c(b)):ee?(g({walletType:b.type,chain:e,address:W??""}),f(!0)):n({walletType:b.type,chain:e,address:W??""})},"onSelectableWalletClick"),V=m?.chain?tr(m.chain,p()):void 0;return Ze.createElement(Ze.Fragment,{key:`${b.title}_${V}`},!!m&&Ze.createElement(J,{open:!!m&&d,container:E,onClose:()=>{g(null)}},Ze.createElement(Ea,{displayName:V,onConfirm:()=>{w(m)}})),h&&Ze.createElement(J,{open:!!h,onClose:T.bind(null,null),container:E},Ze.createElement(lm,{status:h,displayName:V,image:b.image}),Ze.createElement(xT,{direction:"vertical",size:32})),Ze.createElement(wT,{key:b.type,description:oe,onClick:L,selected:o(b.type,e),disabled:!s,...b}))}),Ze.createElement(fo,{wallet:u,onClose:()=>{c(void 0)},onConnect:b=>{t.onConnect&&b.status==="connected"&&(u?.type?t.onConnect(u.type):vT(new Error("The selected wallet hasn't been detected after the connection process finished. It usually shouldn't happen.")))}}),M&&Ze.createElement(Ju,{selected:!1,onClick:a},Ze.createElement(cm,{variant:"label",size:"medium"},pm.t("Show more wallets"),Ze.createElement(cm,{variant:"label",size:"medium",color:"$primary"},"\xA0+",N-(r??0)))))}i(ks,"WalletList");var LT=2;function hm(t){let{open:e,onClose:o,onCancel:n,onCheckBalance:r,loading:a}=t,s=BT(),l=y().blockchains(),{selectedQuote:p,setSelectedWallets:u,quoteWalletsConfirmed:c,setQuoteWalletConfirmed:m,customDestination:g,setCustomDestination:d}=z(),{connectedWallets:f,selectWallets:h}=Z(),{config:T}=y(),[S,C]=To(""),[k,v]=To([]),[x,N]=To(""),[M,w]=To(null),[E,b]=To(!!g),W=MT(()=>ao({filter:"all",quote:p}),[p]),$=ao({filter:"required",quote:p}),I=l.find(_=>_.name===p?.swaps[p?.swaps.length-1].to.blockchain),R=i(_=>$.includes(_),"isWalletRequiredFor"),ee=WT(()=>f.filter(_=>_.selected&&W.includes(_.chain)),[f,W]),[oe,L]=To(ee()),[V,le]=To([]),Y=i((_,Q)=>le(G=>G.concat({blockchain:_,walletType:Q})),"addNextSelectedWallets"),ae=k.length>0,ge=i((_,Q)=>!!oe.find(G=>G.walletType===_&&G.chain===Q&&G.selected&&(R(Q)||!R(Q)&&!g)),"isSelected"),xe=i((_,Q,G)=>{let pe=!1;return _.map(ce=>{if(ce.chain===Q){let de=ce.selected;return!pe&&G?(pe=!0,de=!0):G||(de=!1),{...ce,selected:de}}return ce})},"updateSelectableWallets"),U=i(_=>{b(_),_?R(I?.name??"")||L(Q=>xe(Q,I?.name||"",!1)):(d(""),L(Q=>xe(Q,I?.name||"",!0)))},"handleCustomDestinationCollapsibleOpenChange"),Ke=i(_=>{if(S&&C(""),ge(_.walletType,_.chain))return;let G=f.find(pe=>pe.walletType===_.walletType&&pe.chain===_.chain);G&&(n(),_.chain===I?.name&&E&&!R(I.name)&&(b(!1),d(null)),L(pe=>pe.filter(ce=>ce.chain!==_.chain).concat({...G,selected:!0})))},"onChange"),xt=i(()=>{let _=oe.filter(Q=>Q.selected);h(_),u(_),m(!0),o()},"onConfirmBalance"),lt=i(async()=>{v([]),N(""),w(null);let _=await r?.({selectedWallets:oe.filter(G=>G.selected),customDestination:g}),Q=_.warnings;Q?.balance?.messages&&v(Q.balance.messages),Q?.quoteUpdate&&w(Q.quoteUpdate),_.error&&N(Bc(_.error)),!_.error&&!Q?.balance?.messages.length?xt():v(Q?.balance?.messages??[])},"onConfirmWallets");gm(()=>{L(_=>{let Q=[];return _.forEach(G=>{!f.some(ce=>ce.chain===G.chain&&ce.walletType===G.walletType&&ce.address===G.address)||Q.push(G)}),Q=Q.concat(f.filter(G=>!!!Q.find(ce=>ce.chain===G.chain)&&G.selected&&W.includes(G.chain))),Q})},[f,W]),gm(()=>{let _=[];V.length>0&&(V.forEach(Q=>{let G=f.find(pe=>pe.chain===Q.blockchain&&pe.walletType===Q.walletType);G?Ke(G):_.push(Q)}),le(_))},[f,V]);let wt=document.getElementById($e.SWAP_BOX_ID);return j.createElement(J,{open:e,onClose:()=>{c||s("../",{replace:!0}),o()},dismissible:!S,container:wt,...!S&&{styles:{container:{height:"100%"}},footer:j.createElement(nm,null,j.createElement(fm,{loading:a,disabled:Yc(a,E,g,p,oe,I),onClick:lt,variant:"contained",type:"primary",fullWidth:!0,size:"large"},Co.t("Confirm")))},...S&&{styles:{container:{height:"100%",padding:"$0"}},header:j.createElement(Ru,null,j.createElement(em,{variant:"ghost",onClick:C.bind(null,"")},j.createElement(AT,{size:16})),j.createElement(vs,{variant:"headline",size:"small"},Co.t({id:"Your {blockchainName} wallets",values:{blockchainName:pt(S,l)}})))},anchor:"center"},j.createElement(J,{open:ae,onClose:v.bind(null,[]),container:wt},j.createElement(NT,{title:Co.t("Insufficient account balance"),type:"error",description:j.createElement(IT,{messages:k??[]})},j.createElement(fm,{variant:"outlined",size:"large",type:"primary",fullWidth:!0,onClick:xt},Co.t("Proceed anyway")))),S&&j.createElement(tm,null,j.createElement("div",{className:om()},j.createElement(ks,{chain:S,isSelected:ge,selectWallet:Ke,onShowMore:()=>C(S),onConnect:_=>{Y(S,_)}}))),!S&&j.createElement(j.Fragment,null,x&&j.createElement(j.Fragment,null,j.createElement(dm,{variant:"alarm",type:"error",title:Co.t(x)}),j.createElement(Jr,{size:12})),M&&j.createElement(j.Fragment,null,j.createElement(dm,{variant:"alarm",type:"warning",title:Gr(M)}),j.createElement(Jr,{size:12})),j.createElement(rm,null,W.map((_,Q)=>{let G=l.find(he=>he.name===_),pe=`wallet-${Q}`,ce=Q===W.length-1,de=ce&&I&&T?.customDestination!==!1;return j.createElement("div",{key:pe},j.createElement(Yu,null,j.createElement(vs,{variant:"title",size:"xmedium"},Co.t({id:"Your {blockchainName} wallets",values:{blockchainName:G?.shortName}})),j.createElement(vs,{variant:"label",color:"$neutral700",size:"medium"},Co.t({id:"You need to connect a {blockchainName} wallet.",values:{blockchainName:G?.shortName}}))),j.createElement(Jr,{size:24}),j.createElement(Zu,null,j.createElement(ks,{chain:_,isSelected:ge,selectWallet:Ke,limit:LT,onShowMore:()=>C(G?.name??""),onConnect:he=>{Y(_,he)}})),!ce&&j.createElement(Jr,{size:32}),de&&j.createElement(Xu,{blockchain:I,open:E,handleOpenChange:U}))}))))}i(hm,"ConfirmWalletsModal");import{i18n as JT}from"@lingui/core";import{Alert as RT,Button as ek,InfoIcon as tk}from"@rango-dev/ui";import ot from"react";import{Alert as _T,Button as $T,Divider as bs,NoRouteIcon as FT,RefreshIcon as OT,Typography as xm}from"@rango-dev/ui";import tt from"react";import{i18n as ym}from"@lingui/core";var PT=24,DT=60;function Sm(t,e,o,n){return t?.type===1?{alert:{type:"warning",text:te().genericServerError,action:{onClick:n,title:ym.t("Retry")}},description:""}:e.length?{alert:{type:"warning",text:te().liquiditySourcesError.title,action:{onClick:()=>o(!0),title:ym.t("Reset")}},description:te().liquiditySourcesError.description}:t?.type===0&&t.diagnosisMessage?{alert:{type:"error",text:t.diagnosisMessage,action:null},description:""}:{alert:null,description:te().noResultError.description}}i(Sm,"makeInfo");var xs=(o=>(o[o.small=PT]="small",o[o.large=DT]="large",o))(xs||{}),ws=(o=>(o.small="small",o.large="medium",o))(ws||{});import{styled as Rr}from"@rango-dev/ui";var Cm=Rr("div",{display:"flex",flexDirection:"column",alignItems:"center"}),Tm=Rr("div",{variants:{size:{small:{},large:{maxWidth:"316px"}}}}),km=Rr("div",{variants:{size:{small:{width:"100%"},large:{}}}}),vm=Rr("div",{padding:"$6 $0"});function vn(t){let{fetch:e,error:o,size:n="small"}=t,r=y().getDisabledLiquiditySources(),a=y().toggleAllLiquiditySources,s=y().swappers(),l=Sm(o,r,()=>a(s,!0),e);return tt.createElement(Cm,null,tt.createElement(FT,{size:xs[n],color:"gray"}),tt.createElement(bs,{size:4}),tt.createElement(xm,{variant:"title",size:ws[n]},te().noResultError.title),n==="large"&&tt.createElement(bs,{size:4}),!!l.description&&tt.createElement(Tm,{size:n},tt.createElement(xm,{variant:"body",size:"small",align:"center",color:"neutral700"},l.description)),tt.createElement(bs,{size:n==="large"?"24":"4"}),!!l.alert&&tt.createElement(km,{size:n},tt.createElement(_T,{type:l.alert.type,title:l.alert.text,titleAlign:"left",action:l.alert.action&&tt.createElement($T,{size:"xsmall",type:l.alert.type,prefix:tt.createElement(vm,null,tt.createElement(OT,{size:8})),onClick:l.alert.action.onClick},l.alert.action.title),variant:"alarm"})))}i(vn,"NoResult");import{i18n as xn}from"@lingui/core";import{Button as zT,Divider as QT,MessageBox as qT,Typography as HT,WarningIcon as GT}from"@rango-dev/ui";import Dt from"react";import{Typography as Im}from"@rango-dev/ui";import Is from"react";import{darkTheme as UT,styled as ei}from"@rango-dev/ui";var wm=ei("div",{width:"100%"}),Es=ei("div",{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"$5",width:"100%"}),bm=ei("div",{display:"flex",padding:"$5 0",justifyContent:"space-between",alignItems:"center",width:"100%","._title":{$$color:"$colors$neutral600",[`.${UT} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),Em=ei("div",{padding:"$2",alignSelf:"flex-start",cursor:"pointer"});function Am(t){let{title:e,value:o,valueColor:n}=t;return Is.createElement(bm,null,Is.createElement(Im,{size:"medium",variant:"label",className:"_title"},e),Is.createElement(Im,{size:"large",variant:"label",color:n||"foreground"},`${n?"%":"$"}${o}`))}i(Am,"QuoteErrorsModalItem");function Nm(t){let{open:e,onClose:o,onConfirm:n,warning:r,confirmationDisabled:a}=t,s=r.warningLevel==="high"?"error":"warning",l=[{title:xn.t("Swapping"),value:B(r.inputUsdValue,4,4)},{title:xn.t("Gas cost"),value:B(r.totalFee,2,2)},{title:xn.t("Receiving"),value:B(r.outputUsdValue,4,4)},{title:xn.t("Price impact"),value:B(r.priceImpact,2,2),valueColor:`${s}500`}];return Dt.createElement(J,{footer:Dt.createElement(zT,{type:"primary",size:"large",prefix:Dt.createElement(GT,null),fullWidth:!0,disabled:a,onClick:n},te().highValueLossError.confirmMessage),open:e,onClose:o,container:A()},Dt.createElement(qT,{type:s,title:te().highValueLossError.impactTitle,description:te().highValueLossError.description}),Dt.createElement(Es,null,Dt.createElement(QT,{size:"4"}),Dt.createElement(HT,{size:"small",variant:"title"},xn.t("Details")),Dt.createElement(Es,null,l.map((p,u)=>Dt.createElement(Am,{key:u,...p})))))}i(Nm,"HighValueLossWarningModal");import{i18n as As}from"@lingui/core";function Wm(t,e){let o={alertType:"warning",title:"",action:null};return e?(o.alertType="error",e.type===3&&(o.title=e.recommendation),e.type===4&&(o.title=As.t({id:"You need to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:e.minRequiredSlippage}}),o.action="change-settings"),o):t?(t.type===0&&(Lt(t.priceImpact)==="high"&&(o.alertType="error"),o.action="show-info",o.title=te().highValueLossError.title),t.type===1&&(o.title=te().unknownPriceError.title),t.type===2&&(o.title=As.t({id:"We recommend you to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:t.minRequiredSlippage}}),o.action="change-settings"),t.type===3&&(o.title=As.t("Caution, your slippage is high."),o.action="change-settings"),o):null}i(Wm,"makeAlerts");import{i18n as Ko}from"@lingui/core";import{Button as Mm,Divider as Bm,MessageBox as VT,Typography as KT}from"@rango-dev/ui";import ko from"react";import{useNavigate as jT}from"react-router-dom";function Lm(t){let{customSlippage:e,slippage:o}=y(),{open:n,onClose:r,onConfirm:a,warning:s,confirmationDisabled:l}=t,p=jT(),u=e??o;return ko.createElement(J,{anchor:"bottom",open:n,prefix:ko.createElement(Mm,{size:"small",variant:"ghost",onClick:()=>p("../"+D.settings)},ko.createElement(KT,{variant:"label",size:"medium",color:"$neutral900"},Ko.t("Change settings"))),container:A(),onClose:r},ko.createElement(VT,{type:"warning",title:s.type===3?Ko.t("High slippage"):Ko.t("Low slippage"),description:s.type===3?Ko.t({id:" Caution, your slippage is high (={userSlippage}). Your trade may be front run.",values:{userSlippage:u}}):Ko.t({id:"We recommend you to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:s.minRequiredSlippage}})},ko.createElement(Bm,{size:18}),ko.createElement(Bm,{size:32}),ko.createElement(Mm,{size:"large",type:"primary",variant:"contained",fullWidth:!0,disabled:l,onClick:a},Ko.t("Confirm anyway"))))}i(Lm,"SlippageWarningModal");import{Button as XT,MessageBox as YT,WarningIcon as ZT}from"@rango-dev/ui";import ti from"react";function Pm(t){let{open:e,onClose:o,onConfirm:n,confirmationDisabled:r}=t;return ti.createElement(J,{footer:ti.createElement(XT,{type:"primary",size:"large",prefix:ti.createElement(ZT,null),fullWidth:!0,disabled:r,onClick:n},te().unknownPriceError.confirmMessage),open:e,onClose:o,container:A()},ti.createElement(YT,{type:"warning",title:te().unknownPriceError.impactTitle,description:te().unknownPriceError.description}))}i(Pm,"UnknownPriceWarningModal");function wn(t){let{warning:e,error:o,couldChangeSettings:n,showWarningModal:r,confirmationDisabled:a,refetchQuote:s,onOpenWarningModal:l,onCloseWarningModal:p,onConfirmWarningModal:u,onChangeSettings:c}=t,m={confirmationDisabled:a,open:r,onClose:p,onConfirm:u},g=o?.type===0||o?.type===1,d=Wm(e,o?.type===3||o?.type===4?o:null);return d&&!n&&(d.action=null),ot.createElement(ot.Fragment,null,g&&ot.createElement(vn,{error:o,fetch:s}),!!d&&ot.createElement(wm,null,ot.createElement(RT,{title:d.title,type:d.alertType,variant:"alarm",...d.action==="show-info"&&{action:ot.createElement(Em,{onClick:l},ot.createElement(tk,{size:12,color:"gray"}))},...d.action==="change-settings"&&{action:ot.createElement(ek,{size:"xxsmall",type:d.alertType,onClick:c},JT.t("Change"))}})),e&&ot.createElement(ot.Fragment,null,e.type===0&&ot.createElement(Nm,{...m,warning:e}),(e.type===3||e.type===2)&&ot.createElement(Lm,{...m,warning:e}),e.type===1&&ot.createElement(Pm,{...m,warning:e})))}i(wn,"QuoteWarningsAndErrors");import Bk from"bignumber.js";import gi from"react";import{i18n as vo}from"@lingui/core";import{Alert as Ck,Divider as Xo,FullExpandedQuote as Tk,InfoIcon as kk,NumericTooltip as dd,QuoteTag as vk,StepDetails as xk,TokenAmount as wk,Typography as Yo}from"@rango-dev/ui";import _s from"bignumber.js";import F,{useRef as bk,useState as Ek}from"react";import{styled as Ns}from"@rango-dev/ui";var Ws=Ns("div",{width:"100%","& .position-top__skeleton":{paddingTop:"$10"}}),Dm=Ns("div",{paddingBottom:"$15",variants:{dense:{true:{paddingBottom:0}}}}),_m=Ns("div",{width:"100%",display:"flex"});import*as oi from"@radix-ui/react-collapsible";import{Button as ok,css as bn,darkTheme as Ee,Image as $m,styled as qe,Typography as nk}from"@rango-dev/ui";var rk=300,Fm=qe(oi.Root,{display:"flex",flexDirection:"column",alignItems:"start",overflowX:"auto",overflowY:"hidden",width:"100%",borderRadius:"$xm",variants:{selected:{true:{},false:{$$color:"$colors$neutral400",[`.${Ee} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"}},listItem:{true:{$$color:"$colors$neutral400",[`.${Ee} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"},false:{}}},compoundVariants:[{listItem:!1,selected:!0,css:{$$color:"$colors$secondary200",[`.${Ee} &`]:{$$color:"$colors$secondary800"},backgroundColor:"$$color"}}]}),Om=bn({padding:"$10 $15"}),Um=qe(ok,{backgroundColor:"transparent",border:"1px solid $secondary550",[`.${Ee} &`]:{border:"1px solid $secondary"},transition:"background-color 0.3s ease","&:hover":{backgroundColor:"$secondary550",[`.${Ee} &`]:{backgroundColor:"$secondary"},".allRoutesLabel":{$$color:"$colors$background",[`.${Ee} &`]:{$$color:"$colors$foreground"},color:"$$color",transition:"color 0.3s ease"}}}),zm=qe("div",{borderRadius:"$xm",display:"flex",flexDirection:"column",alignItems:"start",justifyContent:"space-between",color:"$foreground",boxSizing:"border-box",position:"relative",variants:{selected:{true:{},false:{$$color:"$colors$neutral200",[`.${Ee} &`]:{$$color:"$colors$neutral500"},backgroundColor:"$$color"}},basic:{true:{borderTopRightRadius:"0",borderTopLeftRadius:"0"}},listItem:{true:{$$color:"$colors$neutral200",[`.${Ee} &`]:{$$color:"$colors$neutral500"},backgroundColor:"$$color","&:hover":{"& .quote_container":{"& button":{backgroundColor:"$neutral500",[`.${Ee} &`]:{backgroundColor:"$neutral200"}},backgroundColor:"$neutral500",[`.${Ee} &`]:{backgroundColor:"$neutral200"}},backgroundColor:"$neutral300",[`.${Ee} &`]:{backgroundColor:"$neutral400"}},cursor:"pointer"},false:{}}},compoundVariants:[{listItem:!0,selected:!0,css:{outline:"1px solid $secondary"}},{listItem:!1,selected:!0,css:{$$color:"$colors$secondary100",[`.${Ee} &`]:{$$color:"$colors$secondary550"},backgroundColor:"$$color","&:hover":{backgroundColor:"$$color"}}},{listItem:!0,selected:!1,css:{cursor:"pointer","&:hover":{backgroundColor:"$neutral300",[`.${Ee} &`]:{backgroundColor:"$neutral400"}}}}]}),Qm=bn({width:"100%",padding:"$15 $15 $10 $15"}),qm=bn({display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingBottom:"$10",position:"relative"}),jo=bn({display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",".blockchainImage":{marginLeft:"-$8"}}),Hm=bn({display:"flex",alignItems:"center",".usd-value":{$$color:"$colors$neutral600",[`.${Ee} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),Gm=qe(oi.Trigger,{display:"flex",width:"100%",justifyContent:"space-between",alignItems:"center",height:"$36",padding:"$10 $15",boxSizing:"border-box",cursor:"pointer",border:"none",outline:"none",backgroundColor:"transparent",variants:{error:{true:{[`& ${$m}`]:{border:"1px $warning500 solid",borderRadius:"100%"}},false:{[`& ${$m}`]:{border:"1px transparent solid",borderRadius:"100%"}}},selected:{true:{},false:{$$color:"$colors$neutral400",[`.${Ee} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"}},listItem:{true:{$$color:"$colors$neutral400",[`.${Ee} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"},false:{}}},compoundVariants:[{listItem:!1,selected:!0,css:{$$color:"$colors$secondary200",[`.${Ee} &`]:{$$color:"$colors$secondary800"},backgroundColor:"$$color"}}],".blockchains_section":{display:"none"},"@xs":{".blockchains_section":{display:"block"}}}),Vm=qe("div",{width:"18px",height:"18px",borderRadius:"100%",display:"flex",justifyContent:"center",alignItems:"center",border:"1.5px transparent solid",img:{borderRadius:"100%"},variants:{state:{error:{borderColor:"$error500"},warning:{borderColor:"$warning500"}}}}),Km=qe(Kr,{width:"100%",background:"inherit"}),Ms=qe("div",{display:"flex",justifyContent:"center",alignItems:"center",padding:"$2",transition:`all ${rk}ms ease`,variants:{orientation:{down:{transform:"rotate(0)"},up:{transform:"rotate(180deg)"}}}}),p1=qe("div",{height:"$12",marginLeft:"$10",marginRight:"$10",borderLeft:"1px solid $foreground"}),jm=qe("div",{display:"flex",justifyContent:"center",margin:"0 $15",borderTop:"1px solid",$$color:"$colors$neutral300",[`.${Ee} &`]:{$$color:"$colors$neutral400"},borderColor:"$$color"}),Xm=qe("div",{width:"$16",height:"$16",justifyContent:"center",alignItems:"center",display:"flex"}),Bs=qe(nk,{overflow:"hidden",textOverflow:"ellipsis",letterSpacing:.4}),Ym=qe("div",{display:"flex",flexWrap:"wrap"}),Ls=qe("div",{width:"18px",height:"18px",borderRadius:"100%",backgroundColor:"$background",cursor:"default",display:"flex",justifyContent:"center",alignItems:"center",border:"1.5px transparent solid",variants:{state:{error:{borderColor:"$error500"},warning:{borderColor:"$warning500"}}}}),Zm=qe("div",{display:"flex"}),ni=qe("div",{width:"100%",borderTopWidth:"1px",borderTopStyle:"solid",borderTopColor:"$neutral",margin:"$5 0",[`.${Ee} &`]:{borderTopColor:"$neutral800"}});import{i18n as Nt}from"@lingui/core";import{ChevronDownIcon as ak,CloseIcon as sk,Divider as ai,IconButton as lk,NumericTooltip as pk,QuoteCost as ck,Typography as yt}from"@rango-dev/ui";import X,{useState as td}from"react";import{css as ik,styled as ri}from"@rango-dev/ui";var ii=ri("div",{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"$5 0","&.total_payable_fee":{padding:"$12 0"}}),Ps=ri("div",{width:"100%",borderTop:"1px solid $neutral300",margin:"$10 0"}),Jm=ri("div",{padding:"$20 0",display:"flex",flexDirection:"column","& .collapsible_trigger":{display:"flex",alignItems:"center"}}),Rm=ri("div",{padding:"$20 $20 $10",textAlign:"center",position:"relative","._icon-button":{position:"absolute",zIndex:10,top:"$16",right:"$16"}}),ed=ik({display:"flex",flexDirection:"row",alignItems:"center",padding:"$5","&:hover":{"& ._typography, & svg":{color:"$secondary"}}});var uk=i(t=>t.fee.isZero()?null:X.createElement(ii,null,X.createElement(yt,{variant:"label",size:"medium",color:"neutral600"},t.label),X.createElement(yt,{variant:"label",size:"medium"},"$",B(t.fee,4,4))),"NonPayableFee");function od(t){let[e,o]=td(!1),[n,r]=td(!1),{steps:a,quote:s,fee:l,time:p,feeWarning:u,showModalFee:c}=t,m=s?.swaps??[],g=A(),d=Fc(m);return X.createElement(X.Fragment,null,X.createElement(ck,{onClickFee:c?f=>{f.stopPropagation(),o(!e)}:void 0,fee:l,feeWarning:u,time:p,steps:a,tooltipGas:c?Nt.t("View more info"):void 0,tooltipContainer:g}),X.createElement(J,{container:g,open:e,header:X.createElement(Rm,null,X.createElement(yt,{variant:"title",size:"medium"},Nt.t("Gas & Fee Explanation")),X.createElement(lk,{onClick:()=>o(!1),variant:"ghost"},X.createElement(sk,{color:"gray",size:14}))),onClose:()=>{o(!1)}},X.createElement(Jm,null,X.createElement(yt,{variant:"title",size:"small"},Nt.t("Details")),X.createElement(ai,{size:10}),Object.entries(d.payable).flatMap(([f,h])=>h.map((T,S)=>{let C=`payable-fee-${S}`,k=La(T);return X.createElement(ii,{key:C},X.createElement(yt,{variant:"label",size:"medium",color:"neutral600"},Na(f,Nt.t)),X.createElement(pk,{content:T.amount,container:g},X.createElement(yt,{variant:"label",size:"medium"},B(T.amount,2,2)," ",T.asset.symbol," ($",B(k,4,4),")")))})),X.createElement(ii,{className:"total_payable_fee"},X.createElement(yt,{variant:"label",size:"medium"},Nt.t("Total Payable Fee")),X.createElement(yt,{variant:"label",size:"medium"},"$",B(l,4,4))),X.createElement(Ps,null),Object.keys(d.nonePayable).length&&X.createElement(Yr,{triggerAnchor:"bottom",onClickTrigger:()=>r(f=>!f),trigger:X.createElement("div",{className:ed()},X.createElement(yt,{size:"small",variant:"body",color:"neutral700"},n?Nt.t("Hide non-payable fees"):Nt.t("Show non-payable fees")),X.createElement(ai,{size:4,direction:"horizontal"}),X.createElement(jr,{orientation:n?"up":"down"},X.createElement(ak,{size:12,color:"gray"}))),open:n},X.createElement(yt,{size:"small",variant:"title"},Nt.t("Description")),X.createElement(ai,{size:4}),X.createElement(yt,{size:"small",variant:"body",color:"neutral700"},Nt.t(`The following fees are considered in the transaction output and
2
+ you won\u2019t need to pay extra gas for them.`)),X.createElement(ai,{size:10}),Object.entries(d.nonePayable).map(([f,h],T)=>{let S=$c(h),C=Na(f,Nt.t),k=`non-payable-fee-${T}`;return X.createElement(uk,{key:k,fee:S,label:C})}),X.createElement(Ps,null)))))}i(od,"QuoteCostDetails");import{i18n as id}from"@lingui/core";import{TokenAmount as ad}from"@rango-dev/ui";import si from"react";import{css as mk,styled as dk}from"@rango-dev/ui";var nd=dk("div",{position:"relative",display:"flex",flexDirection:"column",width:"100%"}),rd=mk({height:"14px",marginLeft:"14px",position:"absolute",borderLeft:"1px solid $foreground",top:"42%"});function En(t){let{from:e,to:o,percentageChange:n,warningLevel:r}=t;return si.createElement(nd,null,si.createElement(ad,{direction:"horizontal",label:id.t("Swap input"),type:"input",tooltipContainer:A(),price:{value:e.price.value,usdValue:e.price.usdValue,realValue:e.price.realValue,realUsdValue:e.price.realUsdValue},token:{displayName:e.token.displayName,image:e.token.image},chain:{image:e.chain.image}}),si.createElement("div",{className:rd()}),si.createElement(ad,{direction:"horizontal",tooltipContainer:A(),label:id.t("Estimated output"),type:"output",price:{value:o.price.value,usdValue:o.price.usdValue,realValue:o.price.realValue,realUsdValue:o.price.realUsdValue},token:{displayName:o.token.displayName,image:o.token.image},chain:{image:o.chain.image},percentageChange:n,warningLevel:r}))}i(En,"QuoteSummary");import{i18n as ud}from"@lingui/core";import{ChevronDownIcon as hk,ChevronRightIcon as yk,Divider as Ds,Image as Sk,Tooltip as mi,Typography as pi}from"@rango-dev/ui";import O from"react";import{useLayoutEffect as fk,useState as In}from"react";var sd=480,ld=768,pd=1024,cd=1200,gk=i(()=>{let[t,e]=In(!1),[o,n]=In(!1),[r,a]=In(!1),[s,l]=In(!1),[p,u]=In(!1),c=i(()=>{e(window.innerWidth<=sd),n(window.innerWidth>sd&&window.innerWidth<=ld),a(window.innerWidth>ld&&window.innerWidth<=pd),l(window.innerWidth>pd&&window.innerWidth<=cd),u(window.innerWidth>cd)},"handleResize");return fk(()=>(c(),window.addEventListener("resize",c),()=>window.removeEventListener("resize",c)),[]),{isMobile:t,isTablet:o,isNotebook:r,isLargeScreen:s,isExtraLargeScreen:p}},"useScreenDetect"),li=gk;var ci=4,ui=6,An=i(t=>{let{content:e,src:o,className:n,open:r,state:a,container:s}=t,l=s||A();return O.createElement(mi,{container:l,side:"bottom",sideOffset:4,open:r,content:e},O.createElement(Vm,{className:n,state:a},O.createElement(Sk,{src:o,size:16})))},"ImageComponent");function md(t){let{quoteRef:e,selected:o,setExpanded:n,steps:r,expanded:a,type:s,container:l}=t,p=l||A(),u=r.length,c=tu(r),{isTablet:m,isMobile:g}=li();return O.createElement(Gm,{listItem:s==="list-item",ref:d=>e.current=d,selected:o,onClick:d=>{d.stopPropagation(),n(f=>!f)}},O.createElement("div",{className:jo()},O.createElement(pi,{variant:"body",size:"xsmall"},ud.t("Via:")),O.createElement(Ds,{direction:"horizontal",size:4}),r.map((d,f)=>{let h=`item-${f}`,T=O.createElement(Ms,null,O.createElement(yk,{size:12,color:"black"}));return g||m?O.createElement(O.Fragment,{key:h},O.createElement(An,{content:d.swapper.displayName,src:d.swapper.image,state:d.state,container:l}),f!==u-1&&O.createElement(O.Fragment,null,T)):O.createElement(O.Fragment,{key:h},u<=ci||u>ci&&f<ci-1?O.createElement(O.Fragment,null,O.createElement(An,{content:d.swapper.displayName,src:d.swapper.image,state:d.state,container:l}),f!==u-1&&O.createElement(O.Fragment,null,T)):f===ci-1&&O.createElement(mi,{container:p,side:"bottom",align:"end",sideOffset:4,content:O.createElement("div",{className:jo()},T,r.map((S,C)=>{let k=`image-${C}`;return C>=f&&O.createElement(O.Fragment,{key:k},O.createElement(An,{content:S.swapper.displayName,src:S.swapper.image,state:S.state,open:!1}),C!==u-1&&O.createElement(O.Fragment,null,T))}))},O.createElement(Ls,{state:r.find((S,C)=>C>=f&&(S.state==="error"||S.state==="warning"))?.state},O.createElement(pi,{size:"xsmall",variant:"body"},"+",u-f))))})),O.createElement("div",{className:jo()},O.createElement("div",{className:"blockchains_section"},O.createElement("div",{className:jo()},O.createElement(pi,{variant:"body",size:"xsmall"},ud.t("Chains:")),O.createElement(Ds,{direction:"horizontal",size:4}),c.map((d,f)=>O.createElement(O.Fragment,{key:d.displayName},c.length<=ui||c.length>ui&&f<ui-1?O.createElement(mi,{container:p,side:"bottom",content:d.displayName,sideOffset:4},O.createElement(An,{content:"",src:d.image,open:!1,className:f!==0?"blockchainImage":""})):f===ui-1&&O.createElement(mi,{container:p,side:"bottom",align:"end",sideOffset:4,content:O.createElement("div",{className:jo()},c.map((h,T)=>T>=f&&O.createElement(An,{key:h.displayName,content:"",src:h.image,open:!1,className:T>f?"blockchainImage":"",container:l})))},O.createElement(Ls,{className:"blockchainImage"},O.createElement(pi,{size:"xsmall",variant:"body"},"+",c.length-f))))),O.createElement(Ds,{direction:"horizontal",size:32}))),O.createElement(Ms,{orientation:a?"up":"down"},O.createElement(hk,{size:12,color:"black"}))))}i(md,"QuoteTrigger");function $s(t){let{quote:e,input:o,output:n,error:r,warning:a,type:s,selected:l=!1,tagHidden:p=!0,showModalFee:u=!0,onClickAllRoutes:c,fullExpandedMode:m=!1,container:g}=t,d=y().blockchains(),{findToken:f}=y(),h=y().swappers(),{customSlippage:T,slippage:S}=y(),C=T||S,[k,v]=Ek(t.expanded),x=bk(null),N=B(o.value,6,6),M=B(n.value,6,6),w=n.usdValue?B(n.usdValue,4,4):"",E=ut(o.usdValue,n.usdValue??null),b=B(E,2,2),W=Lt(E??0),$=i((ge,xe)=>ge.map((U,Ke)=>{let xt,lt=r?.type===3&&r.swap.swapperId===U.swapperId,wt=r?.type===4&&r.recommendedSlippages?.has(Ke),_=a?.type===2&&a.recommendedSlippages?.has(Ke),Q=lt||wt,G=_;Q?xt="error":G&&(xt="warning");let pe=Q?vo.t("Slippage Error"):vo.t("Slippage Warning");return lt&&(pe=vo.t("Bridge Limit Error")),{swapper:{displayName:on(U.swapperId,h)??"",image:U.swapperLogo},from:{token:{displayName:U.from.symbol,image:U.from.logo},chain:{displayName:pt(U.from.blockchain,d)??"",image:U.from.blockchainLogo},price:{value:Ke===0&&!xe?B(o.value,6,6):B(U.fromAmount,6,6),usdValue:B((U.from.usdPrice??0)*parseFloat(U.fromAmount),4,4),realValue:Ke===0?o.value:U.fromAmount,realUsdValue:new _s(U.from.usdPrice??0).multipliedBy(U.fromAmount).toString()}},to:{token:{displayName:U.to.symbol,image:U.to.logo},chain:{displayName:pt(U.to.blockchain,d)||"",image:U.to.blockchainLogo},price:{value:B(U.toAmount,6,6),usdValue:B((U.to.usdPrice??0)*parseFloat(U.toAmount),4,4),realValue:U.toAmount,realUsdValue:new _s(U.to.usdPrice??0).multipliedBy(U.toAmount).toString()}},state:xt,alerts:Q||G?F.createElement(Dm,{dense:m},F.createElement(Ck,{variant:"alarm",type:Q?"error":"warning",title:pe,footer:F.createElement(_m,null,lt&&F.createElement("div",null,F.createElement(Yo,{size:"xsmall",variant:"body",color:"neutral900"},r.fromAmountRangeError),F.createElement(Xo,{direction:"vertical",size:2}),F.createElement(Yo,{size:"xsmall",variant:"body",color:"neutral900"},vo.t({id:"Yours: {amount} {symbol}",values:{amount:B(U.fromAmount,6,6),symbol:U?.from.symbol}}))),(wt||_)&&!lt&&F.createElement("div",null,F.createElement(Yo,{size:"xsmall",variant:"body",color:"neutral900"},vo.t({id:"Minimum required slippage: {minRequiredSlippage}",values:{...r?.type===4&&{minRequiredSlippage:r.recommendedSlippages?.get(Ke)},...a?.type===2&&{minRequiredSlippage:a.recommendedSlippages?.get(Ke)}}})),F.createElement(Xo,{direction:"vertical",size:2}),F.createElement(Yo,{size:"xsmall",variant:"body",color:"neutral900"},vo.t({id:"Yours: {userSlippage}",values:{userSlippage:C}}))))})):void 0,time:sn(U.estimatedTimeInSeconds),fee:B(Ba(U,f),2,2),internalSwaps:U.internalSwaps?$(U.internalSwaps):void 0}}),"getQuoteSteps"),I=$(e?.swaps??[]),R=I.length,ee=g||A(),oe=nu(t.quote.tags||[]),L=!!c,V=sn(ar(e?.swaps)),le=Wr(e?.swaps??[],f),Y=B(le,2,2),ae=le.gte(new _s(Mc));return m?F.createElement(Tk,{selected:l,fee:Y,time:V,tooltipContainer:an(),steps:I,tags:oe,feeWarning:ae,percentageChange:b,warningLevel:W,outputPrice:{value:M,usdValue:w,realValue:n.value,realUsdValue:n.usdValue}}):F.createElement(zm,{selected:l,listItem:s==="list-item",basic:s==="basic"},F.createElement("div",{className:Qm()},!p&&oe.length?F.createElement(F.Fragment,null,F.createElement(Zm,null,oe.map((ge,xe)=>{let U=`${ge.value}_${xe}`;return F.createElement(F.Fragment,{key:U},F.createElement(vk,{label:ge.label,value:ge.value}),F.createElement(Xo,{size:4,direction:"horizontal"}))})),F.createElement(ni,null),!L&&F.createElement(Xo,{size:4})):null,F.createElement("div",{id:"portal-root",className:qm()},F.createElement(od,{quote:e,time:V,fee:Y,feeWarning:ae,showModalFee:u,steps:R}),L&&F.createElement(Um,{onClick:ge=>{ge.stopPropagation(),c()},size:"xxsmall",type:"secondary",variant:"default",css:{paddingLeft:"$10",paddingRight:"$10",paddingTop:"$5",paddingBottom:"$5"}},F.createElement(Yo,{color:"secondary",variant:"body",size:"xsmall",className:"allRoutesLabel"},vo.t("See All Routes")))),s==="basic"&&F.createElement("div",{className:Hm()},F.createElement(Xm,null,F.createElement(kk,{size:12,color:"gray"})),F.createElement(Ym,null,F.createElement(Bs,{size:"small",variant:"body"},`${N} ${I[0].from.token.displayName} = `),F.createElement(dd,{content:n.value,container:ee,open:n.value?void 0:!1},F.createElement(Bs,{size:"small",variant:"body"},"\xA0",`${M} ${I[I.length-1].to.token.displayName}`))),F.createElement(dd,{content:n.usdValue,container:ee},F.createElement(Xo,{size:2,direction:"horizontal"}),F.createElement(Yo,{color:"$neutral600",size:"xsmall",variant:"body"},`($${w})`))),s==="list-item"&&F.createElement(wk,{tooltipContainer:ee,type:"output",direction:"vertical",price:{value:M,usdValue:w,realValue:n.value,realUsdValue:n.usdValue},token:{displayName:I[R-1].to.token.displayName,image:I[R-1].to.token.image},chain:{image:I[R-1].to.chain.image},percentageChange:b,warningLevel:W}),s==="swap-preview"&&F.createElement(F.Fragment,null,F.createElement(En,{from:I[0].from,to:I[R-1].to,percentageChange:b,warningLevel:W}),F.createElement(Xo,{size:4}))),F.createElement(Fm,{selected:l,listItem:s==="list-item",open:k,className:"quote_container",onOpenChange:v},F.createElement(md,{type:s,quoteRef:x,selected:l,setExpanded:v,container:ee,expanded:k,steps:I}),F.createElement(Km,{open:k},F.createElement(jm,null),F.createElement("div",{className:Om()},I.map((ge,xe)=>{let U=`item-${xe}`;return F.createElement(xk,{type:"quote-details",key:U,tooltipContainer:ee,step:ge,hasSeparator:xe!==I.length-1,state:ge.state})})))))}i($s,"Quote");import{Divider as Wk,Skeleton as Mk}from"@rango-dev/ui";import $t from"react";import{darkTheme as Ik,styled as di}from"@rango-dev/ui";var fd=di("div",{$$color:"$colors$neutral100",[`.${Ik} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",borderBottomLeftRadius:"$xm",borderBottomRightRadius:"$xm",padding:"$15",variants:{rounded:{true:{borderRadius:"$xm"}},expanded:{true:{paddingBottom:"3px"},false:{paddingBottom:"$12"}}}}),gd=di("div",{paddingTop:"$2"}),hd=di("div",{paddingLeft:"$8"}),yd=di("div",{borderLeft:"1px dashed $foreground",minHeight:" 0",margin:"0px 11.5px",alignSelf:"stretch",variants:{hideSeparator:{true:{minHeight:"unset",height:"0"}}}});import{ChainToken as Id,Divider as St,Skeleton as nt}from"@rango-dev/ui";import q from"react";import{css as Ak,styled as _t}from"@rango-dev/ui";var Fs=_t("div",{display:"flex"}),Sd=_t("div",{padding:"$10 $0 $20"}),Cd=_t("div",{padding:"14px $0 $20 $0",display:"flex",flexDirection:"column"}),Td=_t("div",{display:"flex",justifyContent:"start",alignItems:"center"}),kd=_t("div",{display:"flex",justifyContent:"space-between",alignItems:"end"}),vd=_t("div",{height:"$24",marginLeft:"13px",borderLeft:"1px solid $neutral700"}),xd=_t("div",{width:"65%",display:"flex",justifyContent:"start"}),wd=_t("div",{display:"flex",flexDirection:"column",alignItems:"start",flexGrow:1,maxWidth:"148px"}),bd=_t("div",{padding:"$15 $0 $15 $0"}),Ed=Ak({display:"flex",justifyContent:"space-between",alignItems:"center"});function Nn(t){let{type:e,tagHidden:o=!0}=t,n=q.createElement(kd,null,q.createElement(xd,null,q.createElement(Id,{loading:!0,size:"medium",chainImage:"",tokenImage:""}),q.createElement(St,{size:8,direction:"horizontal"}),q.createElement(wd,null,q.createElement(nt,{height:10,width:60,variant:"rounded"}),q.createElement(St,{size:4}),q.createElement(nt,{height:15,variant:"rounded"}))),q.createElement(nt,{height:12,width:64,variant:"rounded"})),r=e==="basic"&&!o;return q.createElement("div",null,!o&&q.createElement(q.Fragment,null,q.createElement(Fs,null,q.createElement(nt,{width:65,height:20,variant:"rounded"}),q.createElement(St,{size:4,direction:"horizontal"}),q.createElement(nt,{width:65,height:20,variant:"rounded"}),q.createElement(St,{size:4,direction:"horizontal"}),q.createElement(nt,{width:65,height:20,variant:"rounded"})),q.createElement(ni,null),!r&&q.createElement(St,{size:4})),q.createElement("div",{className:Ed()},q.createElement(Fs,null,q.createElement(nt,{width:60,height:10,variant:"rounded"}),q.createElement(St,{size:4,direction:"horizontal"}),q.createElement(nt,{width:60,height:10,variant:"rounded"}),q.createElement(St,{size:4,direction:"horizontal"}),q.createElement(nt,{width:60,height:10,variant:"rounded"})),r&&q.createElement(nt,{width:85,height:24,variant:"rounded"})),e==="basic"&&q.createElement(Sd,null,q.createElement(nt,{height:15,width:148,variant:"rounded"})),e==="list-item"&&q.createElement(Cd,null,q.createElement(Td,null,q.createElement(Id,{loading:!0,size:"medium",chainImage:"",tokenImage:""}),q.createElement(St,{direction:"horizontal",size:4}),q.createElement(nt,{height:15,width:150,variant:"rounded"})),q.createElement(St,{size:10}),q.createElement(nt,{height:10,width:184,variant:"rounded"})),e==="swap-preview"&&q.createElement(q.Fragment,null,q.createElement(St,{size:4}),q.createElement(bd,null,n,q.createElement(vd,null),n),q.createElement(St,{size:12})))}i(Nn,"QuoteSummarySkeleton");import{ChainToken as Bd,Divider as Us,NextIcon as Nk,Skeleton as fi}from"@rango-dev/ui";import Ie from"react";import{styled as Wn}from"@rango-dev/ui";var Ad=Wn("div",{display:"flex",alignItems:"start"}),Nd=Wn("div",{flexGrow:1,paddingTop:"$5",paddingBottom:"$10",display:"flex",alignItems:"center",variants:{extraSpace:{true:{paddingBottom:"$40"}}}}),Os=Wn("div",{display:"flex",alignItems:"center",flexGrow:1}),Wd=Wn("div",{margin:"$0 $2",padding:"$4",display:"flex",justifyContent:"center",alignItems:"center"}),Md=Wn("div",{display:"flex",alignItems:"center"});function Wt(t){let{separator:e=!0}=t;return Ie.createElement(Ie.Fragment,null,Ie.createElement(Md,null,Ie.createElement(fi,{height:22,width:22,variant:"circular"}),Ie.createElement(Us,{direction:"horizontal",size:8}),Ie.createElement(fi,{height:15,width:148,variant:"rounded"})),Ie.createElement(Ad,null,Ie.createElement(yd,{hideSeparator:!e}),Ie.createElement(Nd,{extraSpace:e},Ie.createElement(Os,null,Ie.createElement(Bd,{size:"small",loading:!0,chainImage:"",tokenImage:""}),Ie.createElement(Us,{direction:"horizontal",size:8}),Ie.createElement(fi,{height:12,variant:"rounded"})),Ie.createElement(Wd,null,Ie.createElement(Nk,{color:"gray",size:16})),Ie.createElement(Os,null,Ie.createElement(Bd,{size:"small",loading:!0,chainImage:"",tokenImage:""}),Ie.createElement(Us,{direction:"horizontal",size:8}),Ie.createElement(fi,{height:12,variant:"rounded"})))))}i(Wt,"StepSkeleton");function Mn(t){let{type:e,expanded:o,tagHidden:n=!1}=t;return $t.createElement(fd,{expanded:o,rounded:e!=="basic"},$t.createElement(Nn,{type:e,tagHidden:n}),$t.createElement(gd,null,$t.createElement(Mk,{height:15,variant:"rounded"})),o&&$t.createElement(hd,null,$t.createElement(Wk,{size:24}),$t.createElement(Wt,null),$t.createElement(Wt,null),$t.createElement(Wt,{separator:!1})))}i(Mn,"QuoteSkeleton");function xo(t){let{quote:e,type:o,loading:n,error:r,warning:a,expanded:s=!1,tagHidden:l,onClick:p,showModalFee:u,selected:c,onClickAllRoutes:m,fullExpandedMode:g=!1,container:d}=t,{inputAmount:f,inputUsdValue:h,toToken:T}=z(),S=e?.outputAmount?new Bk(e?.outputAmount):null,C=e?.outputAmount?jt(e?.outputAmount,ho(e)||T?.usdPrice):null,v=!(r&&(r.type===0||r.type===1))&&e&&!n;return n?gi.createElement(Ws,null,gi.createElement(Mn,{tagHidden:l,type:o,expanded:s})):v?gi.createElement(Ws,{onClick:()=>p?.(e)},gi.createElement($s,{quote:e,error:r,container:d,showModalFee:u,warning:a,tagHidden:l,selected:c,type:o,expanded:s,onClickAllRoutes:m,fullExpandedMode:g,input:{value:f,usdValue:h?.toString()??""},output:{value:S?.toString()??"",usdValue:C?.toString()??""}})):null}i(xo,"QuoteInfo");import{calculatePendingSwap as _k}from"@rango-dev/queue-manager-rango-preset";import{useEffect as $k}from"react";import{useRef as Lk,useState as Pk}from"react";var Dk=2e3;function hi({request:t}){let[e,o]=Pk(!1),n=Lk(null),r=i(()=>n.current?.abort(),"cancelFetch"),a=i(async l=>(await new Promise(p=>setTimeout(p,Dk)),await s(l,!1)),"retryFetch"),s=i(async(l,p=!1)=>{r(),n.current=new AbortController,o(!0);try{let u=await t(l,{signal:n.current.signal});return n.current=null,u}catch(u){if(p)return await a(l);throw u}finally{o(!1)}},"fetch");return{fetch:s,loading:e,cancelFetch:r}}i(hi,"useFetch");function Ld(){let{fetch:t,loading:e,cancelFetch:o}=hi({request:async(n,r)=>await Ht().confirmRouteRequest(n,r)});return{fetch:t,loading:e,cancelFetch:o}}i(Ld,"useFetchConfirmQuote");function yi(t){if(!t.swaps)throw new Error(te().noResultError.title,{cause:{type:0,diagnosisMessage:t.diagnosisMessages?.[0]}});let e=zs(t.swaps);if(e)throw new Error(e.message,{cause:e.options})}i(yi,"throwErrorIfResponseIsNotValid");function zs(t){if(Pc(t)){let{swap:n,recommendation:r,fromAmountRangeError:a}=Dc(t);return{message:"bridge limit error",options:{type:3,swap:n,recommendation:r,fromAmountRangeError:a}}}let o=Oc(t);if(o){let n=Mr(t);return{message:"",options:{type:4,recommendedSlippages:o,minRequiredSlippage:n}}}return null}i(zs,"getQuoteError");function Pd(t,e,o){let n=!1;t&&(n=eu(t,e));let r={quote:null,quoteUpdate:null,balance:null},a=Fo(e,{fromToken:o.fromToken,toToken:o.toToken,findToken:o.findToken,userSlippage:o.userSlippage});a&&(r.quote=a),t&&n&&(Gc(t,e)?r.quoteUpdate={type:3,newOutputAmount:B($o(e)),percentageChange:B(ut($o(t)??"",$o(e)??""),null,2)}:Pa(t,e)?r.quoteUpdate={type:0}:Da(t,e)?r.quoteUpdate={type:1}:_a(t,e)&&(r.quoteUpdate={type:2}));let s=Vc(e,o.selectedWallets,o.meta.blockchains);return s.length===0||(r.balance={messages:s}),r}i(Pd,"generateWarnings");function Si(t){return t?.code==="ERR_CANCELED"?{swap:null,error:{type:2},warnings:null}:t.cause?{swap:null,error:t.cause,warnings:null}:{swap:null,error:{type:1},warnings:null}}i(Si,"handleQuoteErrors");function Qs(){let{fromToken:t,toToken:e,inputAmount:o,setSelectedQuote:n,selectedQuote:r,customDestination:a,setQuoteWarningsConfirmed:s,resetAlerts:l}=z(),{slippage:p,customSlippage:u}=y(),c=y().getDisabledLiquiditySources(),m=y().blockchains(),g=y().tokens(),{findToken:d}=y(),f=u||p,{fetch:h,cancelFetch:T,loading:S}=Ld();return $k(()=>T,[]),{loading:S,fetch:i(async k=>{let v=k.selectedWallets,x=k?.customDestination??a;if(!t||!e||!o)return{quote:null,swap:null,error:null,warnings:null};let N=v.reduce((w,E)=>(w[E.chain]=E.address,w),{}),M={requestId:r?.requestId||"",selectedWallets:N,destination:x||void 0};try{return await h(M,!0).then(w=>{let{result:E}=w;yi({diagnosisMessages:E.diagnosisMessages,requestId:E.requestId,swaps:E.result?.swaps});let b={outputAmount:E.result?.outputAmount,requestId:E.requestId,resultType:E.result?.resultType,swaps:E.result?.swaps||[],validationStatus:E.validationStatus,requestAmount:E.requestAmount};n(b);let W={slippage:f.toString(),disabledSwappersGroups:c},$=Pd(r??void 0,b,{fromToken:t,toToken:e,meta:{blockchains:m},findToken:d,selectedWallets:v,userSlippage:f});$.quoteUpdate&&s(!1),l();let I=!!$.balance,R=_k(o.toString(),E,qc(v),W,!I,{blockchains:m,tokens:g});return{quote:b,swap:R,error:null,warnings:$}})}catch(w){return Si(w)}},"fetch"),cancelFetch:T}}i(Qs,"useConfirmSwap");var Vk=Uk("div",{width:"100%",display:"flex",justifyContent:"space-between",[`& ${_d}`]:{width:"$48",height:"$48"}}),Kk=Gs({flexGrow:1,paddingRight:"$10"}),jk=Gs({width:"$24",height:"$24",display:"flex",justifyContent:"center",alignItems:"center"}),Xk=Gs({display:"flex",justifyContent:"space-between",alignItems:"center"});function $d(){let{selectedQuote:t,setInputAmount:e,selectedWallets:o,quoteWalletsConfirmed:n,customDestination:r,quoteWarningsConfirmed:a}=z(),s=Gk(),[l,p]=Bn(""),u=!n,[c,m]=Bn(!1),[g,d]=Bn(!1),{isActiveTab:f}=se(),h=y().getDisabledLiquiditySources(),T=Hk(h),{manager:S}=Fk(),{fetch:C,loading:k,cancelFetch:v}=Qs(),[x,N]=Bn({swap:null,error:null,warnings:null}),[M,w]=Bn(!1),E=i(async({selectedWallets:L,customDestination:V})=>{let le=await C?.({selectedWallets:L,customDestination:V});return N(le),le},"onConfirmSwap"),b=i(async()=>{if(x.swap&&n)try{await S?.create("swap",{swapDetails:x.swap},{id:x.swap.requestId});let L=`../${D.swaps}/${x.swap.requestId}`;s(L,{replace:!0}),setTimeout(()=>{e("")},0)}catch(L){p("Error: "+L?.message)}},"addNewSwap"),W=i(async()=>{d(!0),await b(),d(!1)},"onConfirm"),$=i(async()=>{x?.warnings?.quote&&!a?w(!0):await W()},"onStartConfirmSwap"),I=i(async()=>{N({error:null,swap:null,warnings:null}),C({selectedWallets:o,customDestination:r}).then(L=>{N(L)}).catch(L=>console.error(L))},"onRefresh");Ci(()=>{!!T.current.length&&!h.length&&I(),T.current=h},[h.length]),Ci(()=>{u&&v()},[u]),Ci(()=>{u&&m(u)},[u]),Ci(()=>{u||C({selectedWallets:o,customDestination:r}).then(L=>N(L)).catch(L=>console.error(L))},[]),qk(()=>{t?.requestId||s(`../${location.search}`)},[t?.requestId]);let R=x.warnings?.quote??null,ee=x.error,oe=[];if(l&&oe.push(Ae.createElement(Dd,{type:"error",variant:"alarm",title:l})),x.warnings?.quoteUpdate&&oe.push(Ae.createElement(Dd,{variant:"alarm",type:"warning",title:x.warnings.quoteUpdate&&Gr(x.warnings.quoteUpdate)})),R||ee){let L=`../${D.settings}`;oe.push(Ae.createElement(wn,{warning:R,error:ee,couldChangeSettings:!1,refetchQuote:I,showWarningModal:M,confirmationDisabled:!f,onOpenWarningModal:()=>w(!0),onCloseWarningModal:()=>w(!1),onConfirmWarningModal:async()=>{w(!1),await b()},onChangeSettings:()=>s(L)}))}return Ae.createElement(ne,{header:{title:qs.t("Confirm Swap"),onWallet:()=>{let L=`../${D.wallets}`;s(L)}},footer:Ae.createElement(Vk,null,Ae.createElement("div",{className:Kk()},Ae.createElement(Ok,{variant:"contained",type:"primary",size:"large",fullWidth:!0,loading:k||g,disabled:!!x.error||!f,onClick:$},qs.t("Start Swap"))),Ae.createElement(_d,{variant:"contained",type:"primary",size:"large",loading:k||g,disabled:!f,onClick:m.bind(null,!0)},Ae.createElement(Qk,{size:24})))},c&&Ae.createElement(hm,{open:c,onClose:()=>m(!1),onCancel:v,loading:k,onCheckBalance:E}),Ae.createElement(ie,null,Ae.createElement("div",{className:Xk()},Ae.createElement(zk,{variant:"title",size:"small"},qs.t("You get")),Ae.createElement("div",{className:jk()},Ae.createElement(Or,{onClick:!k&&!c&&!M?I:void 0}))),Ae.createElement(Hs,{size:"12"}),yu(oe.map((L,V)=>({element:L,key:`alert-${V}`})),Ae.createElement(Hs,{size:10})),oe.length>0?Ae.createElement(Hs,{size:10}):null,Ae.createElement(xo,{quote:t,type:"swap-preview",expanded:!0,tagHidden:!0,error:x.error,loading:k,warning:x.warnings?.quote??null})))}i($d,"ConfirmSwapPage");import{i18n as Ft}from"@lingui/core";import{Button as rl,CustomTokensZeroStateDarkIcon as fv,CustomTokensZeroStateIcon as gv,DeleteIcon as hv,Divider as _n,IconButton as yv,MessageBox as Sv,NotFound as Cv,styled as al}from"@rango-dev/ui";import fe,{useState as il}from"react";import{useNavigate as Tv}from"react-router-dom";import{CloseIcon as Zk,IconButton as Jk,SearchIcon as Rk,TextField as ev}from"@rango-dev/ui";import Ln from"react";import{styled as Yk}from"@rango-dev/ui";var Fd=Yk("div",{width:"$24",height:"$24",display:"flex",alignItems:"center",justifyContent:"center"});function Ct(t){let{variant:e,fullWidth:o,color:n,size:r,onChange:a,value:s,style:l,setValue:p,...u}=t;return Ln.createElement(ev,{prefix:Ln.createElement(Fd,null,Ln.createElement(Rk,{color:"black"})),suffix:!!s.length&&Ln.createElement(Jk,{variant:"ghost",onClick:()=>p?.(""),size:"small"},Ln.createElement(Zk,{color:"gray",size:10})),fullWidth:o,color:n,variant:e,style:{padding:10,borderRadius:25,alignItems:"center",...l},size:r,value:s,onChange:a,...u})}i(Ct,"SearchInput");import{i18n as ol}from"@lingui/core";import{darkTheme as Xd,Divider as Jo,ExternalLinkIcon as sv,Image as lv,ListItemButton as pv,NotFound as cv,PinIcon as uv,Skeleton as Yd,Typography as vi,VirtualizedList as mv}from"@rango-dev/ui";import H,{useEffect as Zd,useState as Jd}from"react";import{useWallets as tv}from"@rango-dev/wallets-react";import{useEffect as ov,useRef as nv,useState as rv}from"react";function Vs(t){let{connectedWallets:e}=Z(),{getWalletInfo:o}=tv(),n=nv([]),[r,a]=rv(0);return ov(()=>{let s=i(p=>{p.type==="disconnect"&&o(p.payload.walletType).supportedChains.some(m=>m.name===t)&&a(m=>m+1)},"handleWalletEvent");return yr.on("walletEvent",s),t?(e.filter(p=>p.chain===t).forEach(p=>{let{walletType:u}=p,c=n.current.includes(u);p.loading&&!c?n.current=n.current.concat(u):!p.loading&&c&&(n.current=n.current.filter(m=>m!==u),a(m=>m+1))}),()=>yr.off("walletEvent",s)):a(p=>p+1)},[e,t,o]),{balanceKey:r}}i(Vs,"useObserveBalanceChanges");import{Divider as Kd,ListItem as av,Skeleton as Pn}from"@rango-dev/ui";import Tt from"react";import{css as Zo,darkTheme as Od,ImageContainer as iv,styled as dt,Typography as Ud}from"@rango-dev/ui";var Ks=Zo({position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:100,overflow:"hidden"}),js=Zo({position:"relative",height:12,width:"30%",maxWidth:"150px"}),Xs=Zo({position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",bottom:"-8px"}),Ys=Zo({transform:"translateY(12px)",visibility:"hidden",display:"flex","& a":{display:"flex",justifyContent:"center",alignItems:"center",fontSize:"$12",lineHeight:"$16",$$color:"$colors$neutral600",[`.${Od} &`]:{$$color:"$colors$neutral700"},color:"$$color",textDecoration:"none"}}),Zs=Zo({}),Js=Zo(),zd=dt("div",{display:"flex",flexDirection:"column",flexGrow:1,overflow:"hidden",justifyContent:"center"}),Rs=dt("div",{display:"flex",alignItems:"center","._typography":{textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:100,overflow:"hidden"}}),Ti=dt("ul",{flexGrow:1,padding:0,margin:0,listStyle:"none","& li":{alignItems:"none","&:hover":{[`& .${js}`]:{[`& .${Ys}`]:{position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",visibility:"visible"},[`& .${Zs}`]:{bottom:"-15px"},[`& .${Ks}`]:{position:"absolute",transform:"translateY(-12px)",visibility:"hidden"},[`& .${Xs}`]:{position:"absolute",transform:"translateY(-12px)",bottom:"-10px"}}}}}),el=dt("div",{paddingLeft:"$5",paddingRight:"$5",borderRadius:"$md",display:"flex",alignItems:"center"}),tl=dt(Ud,{}),Qd=dt("div",{textAlign:"right",width:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",[`& .${Js}`]:{$$color:"$colors$neutral600",[`.${Od} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),ki=dt("div",{display:"flex",alignItems:"end",flexDirection:"column"}),fU=dt("div",{display:"flex",alignItems:"center"}),qd=dt("div",{position:"relative",[`& ${iv}`]:{borderRadius:"$xm",overflow:"hidden"}}),Hd=dt("div",{position:"absolute",backgroundColor:"$neutral100",padding:"$4",borderRadius:"50%",bottom:-6,right:-6}),Gd=dt(Ud,{width:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}),Vd=dt("a",{"& svg:hover":{color:"$colors$info"}});function jd(t){return Tt.createElement(Ti,null,Array.from(Array(t.size),e=>Tt.createElement(av,{key:e,hasDivider:!0,start:Tt.createElement(Pn,{variant:"circular",width:35,height:35}),end:Tt.createElement(ki,null,Tt.createElement(Pn,{variant:"text",size:"large",width:70}),Tt.createElement(Kd,{size:4}),Tt.createElement(Pn,{variant:"text",size:"medium",width:50})),title:Tt.createElement("div",null,Tt.createElement(Pn,{variant:"text",size:"large",width:90}),Tt.createElement(Kd,{size:4}),Tt.createElement(Pn,{variant:"text",size:"medium",width:90}))})))}i(jd,"LoadingTokenList");var nl=20,dv=i(t=>{let{address:e,name:o,url:n,token:r,customCssForTag:a,customCssForTagTitle:s}=t,l=e.length;return H.createElement("div",{className:js()},o?H.createElement("div",{className:Ks()},o):H.createElement(Rs,{className:Xs()},H.createElement(vi,{variant:"title",size:"xmedium"},r.symbol),H.createElement(Jo,{direction:"horizontal",size:4}),H.createElement(el,{css:a},H.createElement(tl,{variant:"body",size:"xsmall",css:s},r.blockchain))),!!e&&H.createElement("div",{className:`${Ys()} ${!o&&Zs()}`},l>10?`${e.slice(0,5)}...${e.slice(l-6,l)}`:e," ",H.createElement(Jo,{size:4,direction:"horizontal"}),H.createElement(Vd,{href:n,target:"_blank",rel:"nofollow noreferrer",onClick:p=>p.stopPropagation()},H.createElement(sv,{size:12}))))},"renderDesc");function Dn(t){let{list:e,searchedFor:o="",onChange:n,selectedBlockchain:r,showTitle:a=!0,action:s}=t,[l,p]=Jd(e),u=y().fetchStatus,c=y().blockchains(),[m,g]=Jd(!0),{getBalanceFor:d,loading:f}=Z(),{isTokenPinned:h}=y(),{balanceKey:T}=Vs(r),S=i(()=>{p(e.slice(0,l.length+nl))},"loadNextPage");Zd(()=>{g(e.length>l.length)},[l.length]),Zd(()=>{p(e.slice(0,nl))},[e.length,r,T]);let C=i(v=>{let x=mr(d(v));return s?s(v):f?H.createElement(ki,null,H.createElement(Yd,{variant:"text",size:"large",width:70}),H.createElement(Jo,{size:4}),H.createElement(Yd,{variant:"text",size:"medium",width:50})):x&&H.createElement(Qd,null,H.createElement(Gd,{variant:"title",size:"small"},x.amount),H.createElement("div",null),x.usdValue&&H.createElement(vi,{variant:"body",className:Js(),size:"xsmall"},`$${x.usdValue}`))},"endRenderer"),k=i(()=>H.createElement(mv,{endReached:m?S:void 0,itemContent:v=>{let x=l[v],N=x.address||"",M=c.find(W=>W.name===x.blockchain),w=Xa(M.color,"main"),E={$$color:w.main150,[`.${Xd} &`]:{$$color:w.main750},backgroundColor:"$$color"},b={$$color:w.main750,[`.${Xd} &`]:{$$color:w.main150},color:"$$color"};return H.createElement("div",{style:{paddingRight:5}},H.createElement(pv,{style:{width:"100%",overflow:"hidden",height:"60px"},"tab-index":v,key:`${x.symbol}${x.address}`,id:`${x.symbol}${x.address}`,hasDivider:!0,onClick:()=>n&&n(l[v]),start:H.createElement(qd,null,H.createElement(lv,{src:x.image,size:30}),t.type!=="custom-token"&&h(x,t.type)&&H.createElement(Hd,null,H.createElement(uv,{size:12,color:"gray"}))),title:M?.type==="COSMOS"||x.name||!x.name&&!N?H.createElement(Rs,null,H.createElement(vi,{variant:"title",size:"xmedium"},x.symbol),H.createElement(Jo,{direction:"horizontal",size:4}),H.createElement(el,{css:E},H.createElement(tl,{variant:"body",size:"xsmall",css:b},x.blockchain))):void 0,description:M?.info&&N&&M.type!=="COSMOS"?dv({address:N,token:l[v],customCssForTag:E,customCssForTagTitle:b,name:x.name,url:M.info.addressUrl.split("{wallet}").join(N)}):x.name||void 0,end:C(x)}))},totalCount:l.length,key:`${r}-${o}-${T}`}),"renderList");return H.createElement(H.Fragment,null,a&&H.createElement(H.Fragment,null,H.createElement(vi,{variant:"label",size:"large"},ol.t("Select Token")),H.createElement(Jo,{size:4})),H.createElement(zd,null,H.createElement(Jo,{size:4}),u==="loading"&&H.createElement(jd,{size:nl}),u==="success"&&(l.length?H.createElement(Ti,{as:"ul"},k()):!!o&&H.createElement(cv,{title:ol.t("No results found"),description:ol.t("Try using different keywords")}))))}i(Dn,"TokenList");var kv=al("div",{display:"flex",justifyContent:"space-between",flexDirection:"column",flex:1}),vv=al("div",{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",flex:"0.75"}),xv=al(yv,{"&:hover":{"& svg":{color:"$secondary550"}}});function Rd(){let[t,e]=il(""),{deleteCustomToken:o}=y(),n=y().customTokens(),{fromToken:r,toToken:a,setFromToken:s,setToToken:l}=z(),{mode:p}=Qo({}),u=Tv(),[c,m]=il(!1),[g,d]=il(),f=i(C=>{let k=C.target.value;e(k)},"handleSearch"),h=p==="dark",T=n.filter(C=>et(C.symbol,t)||et(C.address||"",t)||et(C.name||"",t)),S=i(()=>{if(g){let C=a?_e(a):null,k=r?_e(r):null,v=_e(g);C===v?l({token:null}):k===v&&s({token:null}),o(g)}m(!1)},"handleDeleteCustomToken");return fe.createElement(ne,{header:{title:Ft.t("Custom Tokens")}},fe.createElement(ie,null,fe.createElement(kv,null,n.length?fe.createElement(fe.Fragment,null,fe.createElement(Ct,{value:t,setValue:e,fullWidth:!0,color:"light",variant:"contained",placeholder:Ft.t("Search Token"),onChange:f}),fe.createElement(_n,{size:16}),fe.createElement(Dn,{list:T,type:"custom-token",searchedFor:t,showTitle:!1,action:C=>fe.createElement(xv,{variant:"ghost",onClick:()=>{m(!0),d(C)}},fe.createElement(hv,{size:12,color:"gray"}))})):fe.createElement(vv,null,fe.createElement(Cv,{icon:h?fe.createElement(fv,{size:200}):fe.createElement(gv,{size:200}),title:Ft.t("No custom tokens"),description:Ft.t("press the button to add your custom token")})),fe.createElement(_n,{size:20}),fe.createElement(rl,{type:"primary",variant:"contained",size:"large",onClick:()=>u(D.addCustomTokens)},Ft.t("Add Custom Token"))),fe.createElement(J,{open:c,dismissible:!0,onClose:()=>m(!1),container:A()},fe.createElement(Sv,{title:Ft.t("Delete Custom Token"),type:"error",description:Ft.t("Are you sure you want to Delete this Token?")},fe.createElement(_n,{size:40}),fe.createElement(_n,{size:10}),fe.createElement(rl,{fullWidth:!0,variant:"contained",type:"primary",size:"large",onClick:S},Ft.t("Yes, Delete it")),fe.createElement(_n,{size:12}),fe.createElement(rl,{fullWidth:!0,variant:"outlined",type:"primary",size:"large",onClick:()=>m(!1)},Ft.t("No, Continue"))))))}i(Rd,"CustomTokensPage");import{i18n as Ge}from"@lingui/core";import{useManager as Qv}from"@rango-dev/queue-manager-react";import{Button as dl,darkTheme as qv,Divider as Rt,MessageBox as Hv,NotFound as Gv,styled as fl,Typography as bi}from"@rango-dev/ui";import{TransactionStatus as On}from"rango-types";import re,{useMemo as Cf,useState as Ei}from"react";import{useNavigate as Vv}from"react-router-dom";import{FilterIcon as Wv,Popover as Mv}from"@rango-dev/ui";import wo from"react";import{css as wv,darkTheme as xi,IconButton as bv,styled as $n}from"@rango-dev/ui";var sl=$n("div",{position:"relative","&::before":{position:"absolute",right:"1px",top:"-1px",width:"$8",height:"$8",borderRadius:"100%",backgroundColor:"$neutral300",[`.${xi} &`]:{backgroundColor:"$neutral400"},padding:"$2"},variants:{isSelect:{true:{"&::before":{content:""}}}}}),ef=$n(bv,{width:"$36",height:"$36",position:"relative",padding:"0",overflow:"unset",backgroundColor:"$neutral300",[`.${xi} &`]:{backgroundColor:"$neutral400"},"&:hover":{backgroundColor:"$secondary100",[`.${xi} &`]:{backgroundColor:"$neutral"},[`& ${sl}::before`]:{backgroundColor:"$secondary100",[`.${xi} &`]:{backgroundColor:"$neutral"}}},variants:{isSelect:{true:{border:"1px solid $secondary"}}}}),tf=$n("div",{position:"absolute",width:"$6",height:"$6",display:"flex",justifyContent:"center",alignItems:"center",borderRadius:"3px",top:"$0",right:"1px",backgroundColor:"$secondary500"}),of=$n("div",{padding:"$15",borderRadius:"$sm",width:"248px",backgroundColor:"$background",zIndex:10}),nf=wv({display:"flex",justifyContent:"space-between",alignItems:"center"}),rf=$n("ul",{margin:0,listStyle:"none",height:"100%",padding:0,".item-start-container":{paddingRight:"0 !important"}});import{i18n as af}from"@lingui/core";import{Button as Ev,Divider as sf,ListItemButton as Iv,Radio as Av,RadioRoot as Nv,Typography as lf}from"@rango-dev/ui";import rt from"react";function pf(t){let{filterBy:e,onClickItem:o}=t;return rt.createElement(of,null,rt.createElement("div",{className:nf()},rt.createElement(lf,{size:"small",variant:"body"},af.t("Status")),rt.createElement(Ev,{variant:"ghost",size:"xxsmall",onClick:()=>o("")},af.t("Reset"))),rt.createElement(sf,{size:10}),rt.createElement(Nv,{value:e},rt.createElement(rf,null,t.list.map((n,r)=>rt.createElement(Iv,{key:n.id,style:{height:"40px",width:"100%"},selected:!1,hasDivider:t.list.length-1!=r,id:n.id,title:rt.createElement(rt.Fragment,null,rt.createElement(sf,{direction:"horizontal",size:4}),rt.createElement(lf,{size:"medium",variant:"body"},n.title)),start:rt.createElement(Av,{value:n.id}),onClick:o})))))}i(pf,"FilterSelectorContent");function ll(t){let{onClickItem:e,onOpenChange:o,filterBy:n,list:r,open:a}=t;return wo.createElement("div",null,wo.createElement(Mv,{open:a,align:"end",onOpenChange:o,container:A(),content:wo.createElement(pf,{list:r,filterBy:n,onClickItem:s=>{e(s),o(!1)}})},wo.createElement(ef,{variant:"default",isSelect:!!n,onClick:()=>o(!t.open)},wo.createElement(sl,{isSelect:!!n},wo.createElement(Wv,{size:16,color:"black"}),!!n&&wo.createElement(tf,null)))))}i(ll,"FilterSelector");import{i18n as Pv}from"@lingui/core";import{Divider as ff,GroupedVirtualizedList as Dv,Skeleton as _v,SwapListItem as gf,Typography as $v}from"@rango-dev/ui";import He,{useCallback as hf,useEffect as Fv,useRef as Ov,useState as Uv}from"react";function cf(t,e){let o=[],n=0;do{let r=t[n];o.push(Math.min(r,e)),e-=r,n++}while(e>0&&n<=t.length);return o}i(cf,"calculateGroupsSoFar");import{css as Bv,darkTheme as Lv,styled as Fn}from"@rango-dev/ui";var pl=Bv(),uf=Fn("div",{display:"flex",justifyContent:"center",alignItems:"center",padding:"$5"}),cl=Fn("div",{width:"100%",display:"flex",flexDirection:"column",backgroundColor:"$background",padding:"$10 $5 0 $5",[`& .${pl}`]:{$$color:"$colors$neutral600",[`.${Lv} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),ul=Fn("div",{display:"flex",justifyContent:"flex-start",padding:"$2"}),mf=Fn("div",{gap:"$10",display:"flex",flexDirection:"column"}),df=Fn("div",{height:"100%",display:"flex",justifyContent:"center",alignItems:"center"});var zv=10;function ml(t){let{list:e,onSwapClick:o,groupBy:n,isLoading:r}=t,[a,s]=Uv([]),l=Ov(0),{swaps:p,groupCounts:u,groups:c}=n(e),m=hf(cf,[]),g=hf(()=>{let d=e.length-l.current;d&&(l.current+=Math.min(d,zv),s(m(u,l.current)))},[e.length]);if(Fv(()=>{r||g()},[r,g]),r){let d=[1,2];return He.createElement(He.Fragment,null,[d,d].map((h,T)=>He.createElement(cl,{key:T},He.createElement(ul,null,He.createElement(_v,{variant:"text",width:60,size:"small"}),He.createElement(ff,{size:16})),He.createElement(ff,{size:4}),He.createElement(mf,null,h.map((C,k)=>He.createElement(gf,{isLoading:!0,key:k}))))))}return He.createElement(Dv,{endReached:()=>{l.current<e.length&&g()},groupCounts:a,groupContent:d=>He.createElement(cl,null,He.createElement(ul,null,He.createElement($v,{variant:"label",size:"medium",className:pl()},c[d]))),itemContent:(d,f)=>{let h=p[d];if(!h)return null;let T=h.steps[0],S=h.steps[h.steps.length-1];return He.createElement(uf,{key:h.requestId},He.createElement(gf,{requestId:h.requestId,creationTime:h.creationTime,status:h.status,onClick:o,tooltipContainer:A(),onlyShowTime:c[f]===Pv.t("Today"),swapTokenData:{from:{token:{image:T.fromLogo,displayName:T.fromSymbol},blockchain:{image:T.fromBlockchainLogo||""},amount:B(h.inputAmount,6,6),realAmount:h.inputAmount},to:{token:{image:S.toLogo,displayName:S.toSymbol},blockchain:{image:S.toBlockchainLogo||""},amount:B(S.outputAmount||S.expectedOutputAmountHumanReadable||"",6,6),realAmount:S.outputAmount||S.expectedOutputAmountHumanReadable||""}}}))}})}i(ml,"HistoryGroupedList");import{i18n as wi}from"@lingui/core";import yf from"dayjs";var Sf=i(t=>{let e=new Map([["today",{title:wi.t("Today"),swaps:[]}],["week",{title:wi.t("This week"),swaps:[]}],["month",{title:wi.t("This month"),swaps:[]}],["year",{title:wi.t("This year"),swaps:[]}]]);function o(p,u){e.has(p)||e.set(p,{title:p,swaps:[]}),e.get(p)?.swaps.push(u)}i(o,"addYearsToOutput");let n=yf();t.forEach(p=>{let u=Number(p.creationTime),c=yf(u);if(n.isSame(c,"day"))e.get("today")?.swaps.push(p);else if(n.isSame(c,"week"))e.get("week")?.swaps.push(p);else if(n.isSame(c,"month"))e.get("month")?.swaps.push(p);else if(n.isSame(c,"year"))e.get("year")?.swaps.push(p);else{let m=new Date(u).getFullYear().toString();o(m,p)}});let r=Array.from(e.values()).filter(p=>p.swaps.length>0),a=r.flatMap(p=>p.swaps),s=r.map(p=>p.swaps.length),l=r.map(p=>p.title);return{swaps:a,groupCounts:s,groups:l}},"groupSwapsByDate");var Kv=fl("div",{overflowY:"visible",width:"100%",display:"flex",flexDirection:"column",gap:15,height:"100%"}),jv=fl("div",{display:"flex",justifyContent:"center",alignItems:"center"}),Xv=fl("div",{"._typography":{color:"$neutral700",[`.${qv}&`]:{color:"$neutral900"}}}),Yv=[{id:On.SUCCESS,title:Ge.t("Complete")},{id:On.RUNNING,title:Ge.t("Running")},{id:On.FAILED,title:Ge.t("Failed")}],Zv=i((t,e)=>t?.length?t.filter(o=>bt(o.fromBlockchain,e)||bt(o.toBlockchain,e)||bt(o.toSymbol,e)||bt(o.fromSymbol,e)).length:!1,"isStepContainsText");function Tf(){let t=Vv(),{manager:e,state:o}=Qv(),n=mt(e).map(({swap:k})=>k),[r,a]=Ei(""),[s,l]=Ei(!1),p=!o.loadedFromPersistor,[u,c]=Ei(""),[m,g]=Ei(!1),d=i(k=>{let v=k.target.value;a(v)},"handleSearch"),f=Cf(()=>!r&&!u?n:n.filter(k=>{let{inputAmount:v,status:x,steps:N,requestId:M}=k;return(!r||bt(v,r)||bt(x,r)||Zv(N,r)||bt(M,r))&&(!u||u===x)}),[n,r,u]),h=!f?.length&&!p,T=i(()=>g(!1),"onCloseModal"),S=i(async()=>{try{await e?.clearQueue(),g(!1)}catch(k){console.log(k)}},"onClear"),C=Cf(()=>!n.some(k=>k.status===On.SUCCESS||k.status===On.FAILED),[n]);return re.createElement(ne,{header:{title:Ge.t("History"),suffix:re.createElement(Vt,null,re.createElement(dl,{disabled:C,variant:"ghost",size:"xsmall",onClick:()=>g(!0)},re.createElement(bi,{size:"medium",variant:"label",color:"error"},Ge.t("Clear all Txs"))))}},re.createElement(ie,null,re.createElement(jv,null,re.createElement(Ct,{setValue:a,fullWidth:!0,variant:"contained",placeholder:Ge.t("Search Transaction"),autoFocus:!0,onChange:d,style:{height:36},value:r}),re.createElement(Rt,{size:10,direction:"horizontal"}),re.createElement(ll,{filterBy:u,open:s,onOpenChange:k=>l(k),onClickItem:k=>c(k),list:Yv})),re.createElement(Rt,{size:"16"}),re.createElement(Kv,null,h&&re.createElement(df,null,re.createElement(Rt,{size:32}),re.createElement(Gv,{title:r?Ge.t("No results found"):Ge.t("No transactions"),titleColor:r?void 0:"$info",hasIcon:!!r,description:r?Ge.t("Try using different keywords"):Ge.t("Your transaction history is stored locally and will appear here after you start a swap")})),!h&&re.createElement(ml,{list:f,onSwapClick:t,groupBy:Sf,isLoading:p}))),re.createElement(J,{open:m,onClose:T,container:A()},re.createElement(Rt,{size:20}),re.createElement(Hv,{type:"warning",title:Ge.t("Clear History"),description:re.createElement(Xv,null,re.createElement(bi,{variant:"body",size:"medium"},Ge.t("This would clear all succeeded/failed transactions from widget. Do you wish to proceed?")),re.createElement(Rt,{size:"24"}),re.createElement(bi,{variant:"body",size:"small"},Ge.t("Hint: This does not clear your transaction history on blockchain. Only hides them in this page.")))}),re.createElement(Rt,{size:40}),re.createElement(Rt,{size:10}),re.createElement(dl,{variant:"contained",type:"primary",size:"large",onClick:S},Ge.t("Yes, Clear history")),re.createElement(Rt,{size:10}),re.createElement(dl,{variant:"outlined",type:"primary",size:"large",onClick:T},re.createElement(bi,{variant:"title",size:"medium",color:"primary"},Ge.t("No, Cancel")))))}i(Tf,"HistoryPage");import{i18n as hx}from"@lingui/core";import{Button as yx,Divider as Of,styled as Sx,WarningIcon as Cx}from"@rango-dev/ui";import Tx from"bignumber.js";import Je,{useEffect as Uf,useState as zf}from"react";import{useNavigate as kx}from"react-router-dom";import{i18n as nx}from"@lingui/core";import{Header as rx}from"@rango-dev/ui";import eo,{useEffect as ix,useState as ax}from"react";import{i18n as Rv}from"@lingui/core";import{Divider as hl,FullExpandedQuote as ex,Typography as tx}from"@rango-dev/ui";import Ce from"react";import{styled as gl}from"@rango-dev/ui";var kf=gl("div",{display:"flex",justifyContent:"center",flexDirection:"column",height:"100%"}),vf=gl("div",{display:"flex",justifyContent:"space-between",alignItems:"center"}),xf=gl("div",{width:"146px"});import{i18n as Un}from"@lingui/core";import{Select as Jv}from"@rango-dev/ui";import wf from"react";function Ii(t){let{updateQuotePartialState:e,sortStrategy:o}=z(),n=[{value:"SMART",label:Un.t("Smart Routing")},{value:"FEE",label:Un.t("Lowest Fee")},{value:"SPEED",label:Un.t("Fastest Transfer")},{value:"NET_OUTPUT",label:Un.t("Maximum Return")},{value:"PRICE",label:Un.t("Maximum Output")}];return wf.createElement(xf,null,wf.createElement(Jv,{container:t.container,options:n,value:o,handleItemClick:r=>{e("sortStrategy",r.value)},variant:"filled"}))}i(Ii,"SelectStrategy");var bf=3;function zn(t){let{loading:e,onClickOnQuote:o,fetch:n,showModalFee:r,hasSort:a=!0,fullExpandedMode:s=!1,container:l}=t,{selectedQuote:p,quotes:u,updateQuotePartialState:c,fromToken:m,toToken:g,sortStrategy:d,error:f}=z(),{slippage:h,customSlippage:T}=y(),{findToken:S}=y(),C=l||A(),k=!!u&&u.results.length,v=T??h,x=i(w=>{if(!m||!g||!u)return null;let E={requestAmount:u.requestAmount,...w};return Fo(E,{fromToken:m,toToken:g,userSlippage:v,findToken:S})},"getQuoteWarning"),N=f?.type===0||f?.type===1,M=u?.results?Pr(d,u?.results):[];return Ce.createElement(Ce.Fragment,null,a&&Ce.createElement(Ce.Fragment,null,Ce.createElement(vf,null,Ce.createElement(tx,{size:"xmedium",variant:"title"},Rv.t("Sort by")),Ce.createElement(Ii,{container:C})),Ce.createElement(hl,{size:"10"})),e&&Array.from({length:bf},(w,E)=>Ce.createElement(Ce.Fragment,{key:E},s?Ce.createElement(ex,{loading:!0}):Ce.createElement(Mn,{tagHidden:!1,type:"list-item",expanded:!1}),E!==bf-1&&Ce.createElement(hl,{size:16}))),!e&&Ce.createElement(Ce.Fragment,null,k?M.map((w,E)=>{let b=x(w),W=zs(w.swaps),$=M.length-1===E;return Ce.createElement(Ce.Fragment,{key:w.requestId},Ce.createElement(xo,{showModalFee:r,container:C,selected:p?.requestId===w.requestId,tagHidden:!1,quote:{...w,requestAmount:u.requestAmount},loading:e,error:W?.options||null,warning:b,fullExpandedMode:s,onClick:I=>{W||c("warning",b),c("error",W?.options||null),o(I)},type:"list-item"}),!$&&Ce.createElement(hl,{size:16}))}):N&&Ce.createElement(kf,null,Ce.createElement(vn,{size:s?"large":"small",error:f,fetch:n}))))}i(zn,"Quotes");import{darkTheme as ox,styled as Ef}from"@rango-dev/ui";var If=Ef("div",{transition:"width 0.2s, opacity 0.2s, margin-left 0.2s",height:"700px",width:"390px",opacity:1,marginLeft:"$16",backgroundColor:"$neutral100",[`.${ox} &`]:{backgroundColor:"$neutral300"},variants:{expandMode:{default:{width:"390px"},full:{width:"719px"}}},"&.is-hidden":{width:0,height:0,opacity:0,marginLeft:0}}),Af=Ef("div",{position:"relative",overflow:"hidden",padding:"$20",flexGrow:1,display:"flex",flexDirection:"column",overflowY:"auto",borderRadius:"$primary",backgroundColor:"$background"});var sx=100;function yl(t){let{fetch:e,loading:o,onClickOnQuote:n,onClickRefresh:r,isVisible:a}=t,[s,l]=ax(!1),p=s?"":"is-hidden",{config:u}=y(),c=u?.variant==="full-expanded",m=an();return ix(()=>{let g=null;return a?g=setTimeout(()=>{l(!0)},sx):(l(!1),g&&clearTimeout(g)),()=>{g&&clearTimeout(g)}},[a]),eo.createElement(If,{expandMode:u?.variant==="full-expanded"?"full":"default",className:`${p} ${Qr()}`,id:$e.EXPANDED_BOX_ID},eo.createElement(rx,{title:nx.t("Routes"),suffix:eo.createElement(eo.Fragment,null,eo.createElement(Ii,{container:m}),eo.createElement(So,{container:m,onClickRefresh:r,hidden:["history","notifications","settings"]}))}),eo.createElement(Af,null,eo.createElement(zn,{showModalFee:!1,fetch:e,hasSort:!1,loading:o,container:an(),onClickOnQuote:n,fullExpandedMode:c})))}i(yl,"ExpandedQuotes");import{i18n as Df}from"@lingui/core";import{SwapInput as _f}from"@rango-dev/ui";import Qn from"react";import{ReverseIcon as cx}from"@rango-dev/ui";import Cl from"react";import{keyframes as lx,styled as Nf}from"@rango-dev/ui";var Sl=450,px=lx({"0%":{transform:"rotateX(0deg) rotateY(0deg) rotateZ(0deg)"},"33%":{transform:"rotateX(0deg) rotateZ(78deg) rotateY(66deg)"},"66%":{transform:"rotateX(0deg) rotateZ(163deg) rotateY(66deg)"},"100%":{transform:"rotateX(0deg) rotateZ(180deg) rotateY(0deg)"}}),Wf=Nf("div",{position:"absolute",bottom:"-12px",left:"50%",transform:"translate(-50%, 10%)",cursor:"pointer"}),Mf=Nf("div",{borderRadius:"$md",border:"3px solid $background",background:"$neutral100",width:"$24",height:"$24",display:"flex",justifyContent:"center",alignItems:"center",color:"$foreground","&.rotate":{"& svg":{animation:`${px} ${Sl}ms ease-in-out forwards`}},"&:hover":{color:"$secondary500",transform:"translateY(1px) scale(1.04)",boxShadow:"1px 1px 1px 1px rgba(0, 0, 0, 0.05)"}});function Tl(){let t=z.use.switchFromAndTo();return Cl.createElement(Wf,null,Cl.createElement(Mf,{onClick:e=>{let o=e.currentTarget;o.classList.add("rotate"),setTimeout(()=>{o.classList.remove("rotate")},Sl),t()}},Cl.createElement(cx,{size:12})))}i(Tl,"SwitchFromAndToButton");import{styled as Bf}from"@rango-dev/ui";var Lf=Bf("div",{display:"flex",flexDirection:"column",gap:"$5",alignSelf:"stretch"}),Pf=Bf("div",{position:"relative"});function kl(t){let{fetchingQuote:e,fetchMetaStatus:o,onClickToken:n,isExpandable:r}=t,{fromToken:a,fromBlockchain:s,toToken:l,toBlockchain:p,setInputAmount:u,inputAmount:c,inputUsdValue:m,outputAmount:g,outputUsdValue:d,selectedQuote:f}=z(),{connectedWallets:h,getBalanceFor:T}=Z(),S=a?T(a):null,C=mr(S)?.amount??"0",k=s&&a?B(S?.amount,S?.decimals):"0",v=!!s&&$p(h,s.name),x=!Ma(f,c,m),N=!Ma(f,c,d),M=!m||!d||!d.gt(0)?null:ut(m.toString(),d.toString());return Qn.createElement(Lf,null,Qn.createElement(Pf,null,Qn.createElement(_f,{label:Df.t("From"),mode:"From",onInputChange:u,balance:C,chain:{displayName:s?.displayName||"",image:s?.logo||""},token:{displayName:a?.symbol||"",image:a?.image||""},onClickToken:()=>n("from"),price:{value:c,usdValue:x?void 0:B(m,4,4),realUsdValue:x?void 0:m?.toString(),error:x?te().unknownPriceError.impactTitle:void 0},disabled:o==="failed",loading:o==="loading",loadingBalance:v,tooltipContainer:A(),onSelectMaxBalance:()=>{u(k.split(",").join(""))},anyWalletConnected:h.length>0}),Qn.createElement(Tl,null)),Qn.createElement(_f,{sharpBottomStyle:!r&&(!!f||e),label:Df.t("To"),mode:"To",fetchingQuote:e,chain:{displayName:p?.displayName||"",image:p?.logo||""},token:{displayName:l?.symbol||"",image:l?.image||""},percentageChange:B(ut(m,d),2,2),warningLevel:Lt(M??0),price:{value:B(g,6,6),usdValue:N?void 0:B(d,4,4),realValue:g?.toString(),realUsdValue:N?void 0:d?.toString(),error:N?te().unknownPriceError.impactTitle:void 0},onClickToken:()=>n("to"),disabled:o==="failed",loading:o==="loading",tooltipContainer:A()}))}i(kl,"Inputs");import{useCallback as ux,useEffect as mx,useRef as dx,useState as fx}from"react";function $f(){let{fetch:t,loading:e,cancelFetch:o}=hi({request:async(n,r)=>await Ht().getAllRoutes(n,r)});return{fetch:t,loading:e,cancelFetch:o}}i($f,"useFetchAllQuotes");var gx=600;function Ai({refetchQuote:t}){let{fetch:e,cancelFetch:o}=$f(),{excludeLiquiditySources:n,features:r,enableCentralizedSwappers:a}=y().config,s=Z.use.connectedWallets(),{fromToken:l,toToken:p,inputAmount:u,inputUsdValue:c,selectedQuote:m,sortStrategy:g,resetQuote:d,error:f,warning:h,setSelectedQuote:T,updateQuotePartialState:S}=z(),{slippage:C,customSlippage:k,affiliatePercent:v,affiliateRef:x,affiliateWallets:N,fetchStatus:M}=y(),w=y().getLiquiditySources(),E=y().getDisabledLiquiditySources(),b=y().excludeLiquiditySources(),{findToken:W}=y(),[$,I]=fx(!0),R=dx(u),ee=k??C,L=!l||!p||so(l,p)||!ln(u),V=i(ae=>{I(ae)},"resetState"),le=i(ae=>{let{fromToken:ge,toToken:xe,inputAmount:U,liquiditySources:Ke,excludeLiquiditySources:xt,disabledLiquiditySources:lt,slippage:wt,affiliateRef:_,affiliatePercent:Q,affiliateWallets:G}=ae;if($||V(!0),!L&&ge&&xe){d();let pe=Qc({fromToken:ge,toToken:xe,inputAmount:U,liquiditySources:Ke,excludeLiquiditySources:xt,disabledLiquiditySources:lt,wallets:s,slippage:wt,affiliateRef:_,affiliatePercent:Q,affiliateWallets:G,enableCentralizedSwappers:a});Vp("experimentalRoute",r)&&(pe.experimental=!0),e(pe).then(ce=>{let de=Pr(g,ce.results),he=ou(m,de,ce.requestAmount);I(!1),S("quotes",ce),T(he),yi({diagnosisMessages:ce.diagnosisMessages,requestId:he?.requestId||"",swaps:he?.swaps});let Rn=ho(he)||xe?.usdPrice,io=hn(he)||ge?.usdPrice,ea=he&&Fo(he,{fromToken:{...ge,usdPrice:io},toToken:{...xe,usdPrice:Rn},userSlippage:ee,findToken:W});S("warning",ea)}).catch(ce=>{let{error:de}=Si(ce);(de?.type===0||de?.type===1)&&d(),de?.type!==2&&(S("error",de),I(!1))})}},"fetch"),Y=ux(xp(ae=>{le(ae)},gx),[L]);return mx(()=>{if(!t){I(!1);return}if(M!=="success")return;if(L){I(!1),(m||f||h)&&d();return}if(!ln(u)||c?.eq(0)){V(!1),o();return}d(),V(!0);let ae=le;return R.current&&R.current!=u&&(ae=Y),R.current=u,ae({inputAmount:u,fromToken:l,toToken:p,liquiditySources:w,excludeLiquiditySources:b,disabledLiquiditySources:E,slippage:ee,affiliateRef:x,affiliatePercent:v,affiliateWallets:N}),o},[M,u,l?.symbol,l?.address,l?.blockchain,p?.symbol,p?.address,p?.blockchain,L,w?.length,n,E.length,ee,x,v,JSON.stringify(N)]),{fetch:()=>le({inputAmount:u,fromToken:l,toToken:p,liquiditySources:w,excludeLiquiditySources:b,disabledLiquiditySources:E,slippage:ee,affiliateRef:x,affiliatePercent:v,affiliateWallets:N}),loading:$}}i(Ai,"useSwapInput");function Ff(t,e){let o=!1,n={preventDefault(){o=!0},...t.payload===void 0&&{payload:t.payload}};ye.emit("uiEvent",{type:t.type,payload:n}),o||e()}i(Ff,"emitPreventableEvent");var vx=Sx("div",{display:"flex",alignItems:"flex-start",maxHeight:700,"& .footer__alert":{paddingTop:"0 !important"}}),xx=300;function Qf(){let t=kx(),{fromToken:e,toToken:o,inputAmount:n,selectedQuote:r,refetchQuote:a,error:s,warning:l,quotes:p,setSelectedQuote:u,resetQuoteWallets:c,setQuoteWarningsConfirmed:m,updateQuotePartialState:g}=z(),[d,f]=zf(!1),{isLargeScreen:h,isExtraLargeScreen:T}=li(),{fetch:S,loading:C}=Ai({refetchQuote:a}),{config:k,fetchStatus:v}=y(),{connectedWallets:x}=Z(),{isActiveTab:N}=se(),[M,w]=zf(!1),b=_c({fetchMetaStatus:v,fetchingQuote:C,inputAmount:n,quote:r,anyWalletConnected:x.length>0,error:s,warning:l,needsToWarnEthOnPath:!1}),W=Hp(h,T,k?.variant),$=!!n&&!!e&&!!o&&new Tx(n).gt(0)&&!Zc(e,o),I=$&&v==="success"&&C,oe=(!W||W&&p?.results.length)&&(l||s);Uf(()=>{c(),g("refetchQuote",!0)},[]),Uf(()=>{f($)},[$]);let L=(r||s)&&!M?S:void 0,V=i(Y=>{W&&d?(f(!1),setTimeout(()=>{t(Y)},xx)):t(Y)},"onHandleNavigation"),le=i(Y=>{r?.requestId!==Y.requestId&&(w(!1),u(Y))},"onClickOnQuote");return Je.createElement(vx,null,Je.createElement(ne,{height:"auto",footer:Je.createElement(yx,{type:"primary",size:"large",disabled:b.disabled||!N,prefix:b.action==="confirm-warning"&&Je.createElement(Cx,null),fullWidth:!0,onClick:()=>{b.action==="connect-wallet"?Ff({type:"clickConnectWallet"},()=>V(D.wallets)):b.action==="confirm-warning"?w(!0):V(D.confirmSwap)}},b.title),header:{onWallet:()=>{V(D.wallets)},hasBackButton:!1,title:k.title||hx.t("Swap"),suffix:Je.createElement(So,{hidden:W?["refresh"]:void 0,onClickRefresh:L,onClickHistory:()=>V(D.swaps),onClickSettings:()=>{V(D.settings)}})}},Je.createElement(ie,null,Je.createElement(kl,{fetchingQuote:I,fetchMetaStatus:v,isExpandable:W,onClickToken:Y=>{V(Y==="from"?D.fromSwap:D.toSwap)}}),Je.createElement(Of,{size:"2"}),W?null:Je.createElement(xo,{quote:r,loading:I,error:s,tagHidden:!1,warning:l,type:"basic",onClickAllRoutes:p&&p.results.length>1?()=>{g("refetchQuote",!1),V(D.routes)}:void 0}),oe?Je.createElement(Je.Fragment,null,Je.createElement(Of,{size:"10"}),Je.createElement(wn,{warning:l,error:s,couldChangeSettings:!0,refetchQuote:S,showWarningModal:M,confirmationDisabled:!N,onOpenWarningModal:()=>w(!0),onCloseWarningModal:()=>w(!1),onConfirmWarningModal:()=>{w(!1),m(!0),V(D.confirmSwap)},onChangeSettings:()=>V(D.settings)})):null)),W?Je.createElement(yl,{loading:I,onClickOnQuote:le,fetch:S,onClickRefresh:L,isVisible:d}):null)}i(Qf,"Home");import{i18n as qf}from"@lingui/core";import{Alert as wx,Divider as bx,List as Ex,ListItemButton as Ix,Radio as Ax,RadioRoot as Nx,Typography as Wx}from"@rango-dev/ui";import Mt from"react";function to(){let{setLanguage:t,language:e,config:o}=y(),n=Xp,r=o?.language||Mo;return{activeLanguage:e||r,languages:n,defaultLanguage:r,changeLanguage:a=>t(a||Mo),resetLanguage:()=>t(null)}}i(to,"useLanguage");function Hf(){let{activeLanguage:t,changeLanguage:e,languages:o}=to(),n=Ye(),r=o.map(a=>{let{local:s,label:l,SVGFlag:p}=a;return{id:s,value:s,title:Mt.createElement(Wx,{variant:"title",size:"xmedium"},l),onClick:()=>{e(a.local),n()},end:Mt.createElement(Ax,{value:s}),start:Mt.createElement(p,null)}});return Mt.createElement(ne,{header:{title:qf.t("Language")}},Mt.createElement(ie,null,Mt.createElement(wx,{type:"warning",variant:"alarm",title:"Important Notice: Machine translations are in use"}),Mt.createElement(bx,{size:"8"}),Mt.createElement(Nx,{value:t},Mt.createElement(Ex,{type:Mt.createElement(Ix,{title:qf.t("language"),id:"_",onClick:()=>console.log()}),items:r}))))}i(Hf,"LanguagePage");import{i18n as Ot}from"@lingui/core";import{Button as Dx,Checkbox as _x,Image as $x,ListItemButton as Fx,NotFound as Ox,Typography as Ux}from"@rango-dev/ui";import Ve,{useState as zx}from"react";import{Checkbox as Lx,Skeleton as Vf}from"@rango-dev/ui";import Hn from"react";import{styled as vl}from"@rango-dev/ui";var qn=vl("ul",{padding:"$15 $5 0",margin:0,listStyle:"none",height:"100%",overflowY:"auto",variants:{disabled:{true:{pointerEvents:"none"}}}}),xl=vl("div",{width:80,display:"flex",justifyContent:"flex-end"}),wl=vl("div",{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%"});import{ListItem as Mx,styled as Bx}from"@rango-dev/ui";var Gf=Bx(Mx,{height:61});var Px=30;function bl(){return Hn.createElement(qn,null,Array.from(Array(Px),(t,e)=>Hn.createElement(Gf,{hasDivider:!0,key:e,start:Hn.createElement(Vf,{variant:"circular",width:35,height:35}),title:Hn.createElement(Vf,{variant:"text",size:"large",width:90}),end:Hn.createElement(Lx,{checked:!1})})))}i(bl,"LoadingLiquiditySourceList");function El({sourceType:t}){let e=y().fetchStatus,o=y().swappers(),n=y().getDisabledLiquiditySources(),[r,a]=zx(""),s=y().toggleLiquiditySource,l=y().isInCampaignMode(),p=hr(o,n),u={Exchanges:Ot.t("Exchanges"),Bridges:Ot.t("Bridges")},c=[];t==="Exchanges"&&c.push("DEX"),t==="Bridges"&&c.push("BRIDGE","AGGREGATOR","OFF_CHAIN");let m=p.filter(S=>c.includes(S.type)),g=m.length===m.filter(S=>S.selected).length,d=i(()=>{m.forEach(S=>{g?s(S.groupTitle):S.selected||s(S.groupTitle)})},"toggleAllSources"),f=m.map(S=>{let{selected:C,groupTitle:k,logo:v}=S;return{start:Ve.createElement($x,{src:v,size:22,type:"circular"}),onClick:()=>{l||s(k)},end:Ve.createElement(_x,{checked:C,disabled:l}),title:Ve.createElement(Ux,{variant:"title",size:"xmedium"},Ot.t(k)),...S}}),h=i(S=>{let C=S.target.value;a(C)},"handleSearch"),T=f;return r&&(T=f.filter(S=>bt(S.groupTitle,r))),Ve.createElement(ne,{header:{title:Ot.t(t),suffix:Ve.createElement(xl,null,Ve.createElement(Dx,{variant:"ghost",size:"xsmall",onClick:d},g?Ot.t("Deselect all"):Ot.t("Select all")))}},Ve.createElement(ie,{view:!0},Ve.createElement(Ct,{value:r,setValue:a,fullWidth:!0,color:"light",variant:"contained",placeholder:Ot.t("Search {sourceType}",{sourceType:u[t]}),onChange:h}),e==="loading"&&Ve.createElement(bl,null),!T.length&&r?Ve.createElement(wl,null,Ve.createElement(Ox,{title:Ot.t("No results found"),description:Ot.t("Try using different keywords")})):e==="success"&&Ve.createElement(qn,{disabled:l},T.map(S=>{let{groupTitle:C,...k}=S;return Ve.createElement(Ve.Fragment,{key:S.id},Ve.createElement(Fx,{style:{height:"61px"},...k,selected:!1,hasDivider:!0}))}))))}i(El,"LiquiditySourcePage");import{i18n as Qx}from"@lingui/core";import Ni from"react";import{useNavigate as qx}from"react-router-dom";function Kf(){let t=qx(),e=Ye(),{selectedQuote:o,refetchQuote:n,setSelectedQuote:r,updateQuotePartialState:a,error:s}=z(),{fetch:l,loading:p}=Ai({refetchQuote:n}),u=i(g=>{r(g),a("refetchQuote",!1),e()},"onClickOnQuote"),c=`../${D.settings}`,m=`../${D.wallets}`;return Ni.createElement(ne,{header:{onWallet:()=>{t(m),a("refetchQuote",!0)},onBack:()=>{a("refetchQuote",!1)},title:Qx.t("Routes"),suffix:Ni.createElement(So,{onClickRefresh:o||s?l:void 0,hidden:["notifications","history"],onClickSettings:()=>{t(c),a("refetchQuote",!0)}})}},Ni.createElement(ie,null,Ni.createElement(zn,{fetch:l,loading:p,onClickOnQuote:u})))}i(Kf,"RoutesPage");import{i18n as eg}from"@lingui/core";import{Divider as tg,getCategoriesCount as Rx,SelectableCategoryList as ew}from"@rango-dev/ui";import Ut,{useState as og}from"react";import{useNavigate as tw}from"react-router-dom";import{i18n as Il}from"@lingui/core";import{Divider as Kx,Image as jx,ListItemButton as Xx,NotFound as Yx,Typography as Rf}from"@rango-dev/ui";import it,{useEffect as Zx,useState as Jx}from"react";var jf=i((t,e,o)=>t.filter(n=>ir(n.type,o)).filter(n=>et(n.name,e)||et(n.displayName,e)),"filterBlockchains");import{ImageContainer as Hx,styled as Xf}from"@rango-dev/ui";var Yf=Xf("div",{display:"flex",flexDirection:"column",overflow:"hidden",height:"100%",justifyContent:"center"}),Wi=Xf(Sn,{padding:0,margin:0,listStyle:"none",[`& ${Hx}`]:{borderRadius:"$xm",overflow:"hidden"}});import{ListItem as Gx,Skeleton as Zf}from"@rango-dev/ui";import Mi from"react";var Vx=20;function Jf(){return Mi.createElement(Wi,null,Array.from(Array(Vx),t=>Mi.createElement(Gx,{key:t,hasDivider:!0,start:Mi.createElement(Zf,{variant:"circular",width:35,height:35}),title:Mi.createElement(Zf,{variant:"text",size:"large",width:90})})))}i(Jf,"LoadingBlockchainList");function Al(t){let{list:e,searchedFor:o,onChange:n,blockchainCategory:r,showTitle:a=!0}=t,[s,l]=Jx(e),{fetchStatus:p}=y();Zx(()=>{l([...jf(e,o,r)])},[e,o,r]);let u=i(()=>!s.length&&o?it.createElement(Yx,{title:Il.t("No results found"),description:Il.t("Try using different keywords")}):it.createElement(Wi,{as:"ul",key:`${r}-${o}`},s.map(c=>it.createElement(Xx,{key:`${c.name}-${c.chainId}`,hasDivider:!0,onClick:()=>n(c),start:it.createElement(jx,{src:c.logo,size:30}),title:it.createElement(Rf,{variant:"title",size:"medium"},c.displayName),id:c.chainId}))),"renderList");return it.createElement(it.Fragment,null,a&&it.createElement(it.Fragment,null,it.createElement(Rf,{variant:"label",size:"large"},Il.t("Select Blockchain")),it.createElement(Kx,{size:4})),it.createElement(Yf,null,p==="loading"&&it.createElement(Jf,null),p==="success"&&u()))}i(Al,"BlockchainList");function Bi(t){let{type:e}=t,o=Ye(),[n,r]=og(""),[a,s]=og("ALL"),l=z.use.setToBlockchain(),p=z.use.setFromBlockchain(),{fetchStatus:u}=y(),c=tw(),m=y().blockchains({type:e}),g=Rx(m),d=!t.hideCategory&&g!==1;return Ut.createElement(ne,{header:{title:eg.t("Select Blockchain")}},Ut.createElement(ie,{view:!0},d&&Ut.createElement(Ut.Fragment,null,Ut.createElement(ew,{setCategory:s,category:a,blockchains:m,isLoading:u==="loading"}),Ut.createElement(tg,{size:24})),Ut.createElement(Ct,{value:n,autoFocus:!0,placeholder:eg.t("Search Blockchain"),color:"light",variant:"contained",size:"large",setValue:()=>r(""),onChange:f=>r(f.target.value)}),Ut.createElement(tg,{size:16}),Ut.createElement(Al,{list:m,showTitle:e!=="custom-token",searchedFor:n,blockchainCategory:a,onChange:f=>{e==="custom-token"?c(`..?blockchain=${f.name}`,{replace:!0}):(e==="source"?p(f):l(f),o())}})))}i(Bi,"SelectBlockchainPage");import{i18n as Pi}from"@lingui/core";import{Divider as lg}from"@rango-dev/ui";import bo,{useState as pw}from"react";import{useNavigate as cw}from"react-router-dom";import{i18n as Ml}from"@lingui/core";import{BlockchainsChip as Li,Divider as ag,Image as sg,Skeleton as aw,Tooltip as sw,Typography as Bl}from"@rango-dev/ui";import Pe from"react";import{useEffect as rw}from"react";var ng=["ETH","COSMOS","OSMOSIS"];function Nl(t,e,o){let n=JSON.parse(JSON.stringify(t)),r=[];if(n.sort(ow),o?.limit&&t.length>o.limit){let a=o.limit,s=e;if(e.length<=o.limit){let l=o.limit-e.length;for(let p=0;p<=l;p++){let u=n[p];s=s.filter(c=>u.name!==c)}}n.sort(nw(s)),r=n.splice(a)}return{list:n,more:r}}i(Nl,"prepare");function ow(t,e){let o=ng,n=o.findIndex(l=>l===t.name),r=o.findIndex(l=>l===e.name),a=n>-1,s=r>-1;return a&&s?n>r?1:-1:a?-1:s?1:0}i(ow,"sortByMostUsedBlockchains");function nw(t){return i(function(o,n){let r=t.findIndex(p=>p===o.name),a=t.findIndex(p=>p===n.name),s=r>-1,l=a>-1;return s&&l?r>a?1:-1:t.includes(o.name)?-1:t.includes(n.name)?1:0},"sortByPreferred")}i(nw,"generateSortByPreferredBlockchainsFor");function rg(t,e){return!!e.list.find(o=>o.name===t)}i(rg,"isInVisibleList");function Wl(t,e){let{preferredBlockchains:o,addPreferredBlockchain:n}=y();rw(()=>{if(e?.selected){let a=Nl(t,o,e);rg(e.selected,a)||n(e?.selected)}},[e?.selected]);let r=Nl(t,o,e);return{list:r.list,more:r.more,history:[]}}i(Wl,"usePrepareBlockchainList");import{styled as iw}from"@rango-dev/ui";var ig=iw("div",{display:"grid",gap:"$10",gridTemplateColumns:"repeat(6, minmax(0, 1fr))"});var lw=12;function Ll(t){let{blockchains:e,type:o,blockchain:n,onChange:r,onMoreClick:a}=t,s=Wl(e,{limit:10,selected:n?.name}),{fetchStatus:l}=y(),p=z.use.resetToBlockchain(),u=z.use.resetFromBlockchain(),c=s.more.length>0,m=s.more.length===1,g=!m&&c;return Pe.createElement(Pe.Fragment,null,Pe.createElement(ag,{size:12}),Pe.createElement(Bl,{variant:"label",size:"large"},Ml.t("Select Blockchain")),Pe.createElement(ag,{size:12}),Pe.createElement(ig,null,l==="loading"&&Array.from(Array(lw),d=>Pe.createElement(aw,{key:d,variant:"rounded",height:50})),l==="success"&&Pe.createElement(Pe.Fragment,null,Pe.createElement(Li,{selected:!n,onClick:()=>{o==="from"?u():p()}},Pe.createElement(Bl,{variant:"body",size:"xsmall",color:"secondary500"},Ml.t("All"))),s.list.map(d=>Pe.createElement(sw,{key:d.name,content:d.shortName,side:"bottom",sideOffset:2,container:A()},Pe.createElement(Li,{key:d.name,selected:!!n&&n.name===d.name,onClick:()=>r(d)},Pe.createElement(sg,{src:d.logo,size:30})))),m?Pe.createElement(Li,{key:s.more[0].name,selected:!!n&&n.name===s.more[0].name,onClick:()=>r(s.more[0])},Pe.createElement(sg,{src:s.more[0].logo,size:30})):null,g?Pe.createElement(Li,{onClick:a,key:"more-blockchains"},Pe.createElement(Bl,{variant:"body",size:"xsmall",color:"secondary500"},Ml._("More +{count}",{count:s.more.length}))):null)))}i(Ll,"BlockchainsSection");function Pl(t){let{type:e}=t,o=cw(),n=Ye(),{fromBlockchain:r,toBlockchain:a,setFromToken:s,setToToken:l,setFromBlockchain:p,setToBlockchain:u}=z(),c=Z.use.getBalanceFor(),[m,g]=pw(""),f=(e==="source"?r:a)?.name??"",h=y().blockchains({type:e}),T=y().tokens({type:e,blockchain:f,searchFor:m,getBalanceFor:c}),S=i(v=>{e==="source"?p(v):u(v)},"updateBlockchain"),C=i(v=>{e==="source"?s({token:v,meta:{blockchains:h,tokens:T}}):l({token:v,meta:{blockchains:h,tokens:T}})},"updateToken"),k={source:Pi.t("Source"),destination:Pi.t("Destination")};return bo.createElement(ne,{header:{title:Pi.t("Swap {type}",{type:k[e]})}},bo.createElement(ie,null,bo.createElement(Ll,{blockchains:h,type:e=="source"?"from":"to",blockchain:e==="source"?r:a,onMoreClick:()=>o(D.blockchains),onChange:v=>{S(v)}}),bo.createElement(lg,{size:24}),bo.createElement(Ct,{value:m,autoFocus:!0,placeholder:Pi.t("Search Token"),color:"light",variant:"contained",size:"large",setValue:()=>g(""),onChange:v=>g(v.target.value)}),bo.createElement(lg,{size:16}),bo.createElement(Dn,{list:T,selectedBlockchain:f,searchedFor:m,type:e,onChange:v=>{C(v);let x=h.find(N=>v.blockchain===N.name);x&&S(x),n()}})))}i(Pl,"SelectSwapItemsPage");import{i18n as $l}from"@lingui/core";import{Alert as _w,Button as $w,styled as Fw}from"@rango-dev/ui";import Eo from"react";import{useInRouterContext as Ow,useSearchParams as Uw}from"react-router-dom";import{i18n as fg}from"@lingui/core";import{Divider as gg,InfoIcon as fw,SlippageIcon as gw,TextField as hw,Tooltip as yw,Typography as hg}from"@rango-dev/ui";import at from"react";import{Chip as uw,styled as Gn,TextField as mw}from"@rango-dev/ui";var pg=Gn("div",{paddingTop:"$5",padding:"$10 $5"}),cg=Gn("div",{display:"flex",flexWrap:"wrap",gap:"$10",[`& ${mw}`]:{flex:"1 1 0",maxWidth:"127px",minWidth:"85px"}}),ug=Gn("div",{display:"flex",justifyContent:"start",alignItems:"center",paddingBottom:"$10"}),Di=Gn("div",{maxWidth:"280px",padding:"$10"}),mg=Gn(uw,{width:"61px",flexShrink:0});import{i18n as Dl}from"@lingui/core";import{Typography as dw}from"@rango-dev/ui";import Vn from"react";function dg(){return Vn.createElement(Di,null,Vn.createElement(dw,{variant:"label",size:"medium",color:"neutral700"},Dl.t("Your transaction will be reverted if the price changes unfavorably by more than this percentage"),Vn.createElement("br",null),Vn.createElement("br",null),Vn.createElement("b",null,Dl.t("Warning")),":",Dl.t("This setting is applied per step (e.g. 1Inch, Thorchain, etc) which means only the step will be reverted, not the whole transaction.")))}i(dg,"SlippageTooltipContent");function _l(){let{slippage:t,setSlippage:e,customSlippage:o,setCustomSlippage:n}=y();return at.createElement(pg,null,at.createElement(ug,null,at.createElement(gw,{size:16,color:"gray"}),at.createElement(gg,{direction:"horizontal",size:4}),at.createElement(hg,{variant:"title",size:"xmedium"},fg.t("Slippage tolerance per swap")),at.createElement(gg,{direction:"horizontal",size:4}),at.createElement(yw,{container:A(),side:"top",sideOffset:4,content:at.createElement(dg,null)},at.createElement(fw,{color:"gray"}))),at.createElement(cg,null,Yp.map((r,a)=>{let s=`slippage-${a}`;return at.createElement(mg,{key:s,onClick:()=>{o&&n(null),e(r)},selected:!o&&r===t,label:`${r.toString()}%`})}),at.createElement(hw,{type:"number",min:"0.01",max:"30",step:"0.01",fullWidth:!0,variant:"contained",value:o===null?"":o,color:"dark",onChange:r=>{let a=r.target.value,s=parseFloat(a);s>=ec&&s<=Rp?n(s):n(null)},suffix:o&&at.createElement(hg,{variant:"body",size:"small"},"%"),placeholder:fg.t("Custom")})))}i(_l,"Slippage");import{i18n as kt}from"@lingui/core";import{AutoThemeIcon as yg,BridgesIcon as Sw,ChevronRightIcon as _i,DarkModeIcon as Sg,Divider as Kn,ExchangeIcon as Cw,InfinityIcon as Tw,InfoIcon as kw,LanguageIcon as vw,LightModeIcon as Cg,List as xw,ListItem as ww,ListItemButton as bw,Skeleton as Ew,styled as Iw,Switch as Aw,Tabs as Nw,TargetIcon as Ww,Tooltip as Mw,Typography as Re}from"@rango-dev/ui";import P from"react";import{useNavigate as Bw}from"react-router-dom";var Lw=Iw("div",{width:"202px",height:"$40"}),Pw=[{id:"light",icon:P.createElement(Cg,{color:"black",size:24}),tooltip:P.createElement(Re,{size:"xsmall",variant:"body"},kt.t("Light"))},{id:"dark",icon:P.createElement(Sg,{color:"black",size:24}),tooltip:P.createElement(Re,{size:"xsmall",variant:"body"},kt.t("Dark"))},{id:"auto",icon:P.createElement(yg,{color:"black",size:24}),tooltip:P.createElement(Re,{size:"xsmall",variant:"body"},kt.t("Auto"))}],Dw=i(t=>{let e={color:"gray",size:16};switch(t){case"auto":return P.createElement(yg,{...e});case"dark":return P.createElement(Sg,{...e});default:return P.createElement(Cg,{...e})}},"getThemeIcon");function Tg(){let t=Bw(),{theme:e}=y().config,{setTheme:o,theme:n}=y(),{activeLanguage:r,languages:a}=to(),s=a.find(L=>L.local===r)?.label,l=y().fetchStatus,p=y().swappers(),u=y().getDisabledLiquiditySources(),{config:{features:c}}=y(),m=y().customTokens(),g=je("theme",c),d=je("liquiditySource",c),f=je("language",c),h=je("customTokens",c),T=y().infiniteApprove,S=y().toggleInfiniteApprove,C=hr(p,u),k=C.filter(L=>["BRIDGE","AGGREGATOR","OFF_CHAIN"].includes(L.type)),v=k.length,x=k.filter(L=>L.selected).length,N=C.filter(L=>L.type==="DEX"),M=N.length,w=N.filter(L=>L.selected).length,E=i((L,V)=>{switch(l){case"loading":return P.createElement(Ew,{variant:"text",size:"medium",width:50});case"failed":return P.createElement(Re,{variant:"body",size:"medium",color:"$error500"},kt.t("Loading failed"));default:return P.createElement(Re,{variant:"body",size:"medium"},`${L} / ${V}`)}},"handleSwapperEndItem"),b={id:"bridge-item",title:P.createElement(Re,{variant:"title",size:"xmedium"},kt.t("Bridges")),end:P.createElement(P.Fragment,null,E(x,v),P.createElement(Kn,{direction:"horizontal",size:8}),P.createElement(_i,{color:"black"})),onClick:()=>t(D.bridges),start:P.createElement(Sw,{color:"gray",size:16})},W={id:"exchange-item",title:P.createElement(Re,{variant:"title",size:"xmedium"},kt.t("Exchanges")),end:P.createElement(P.Fragment,null,E(w,M),P.createElement(Kn,{direction:"horizontal",size:8}),P.createElement(_i,{color:"black"})),start:P.createElement(Cw,{color:"gray",size:16}),onClick:()=>t(D.exchanges)},$={id:"custom-tokens-item",title:P.createElement(Re,{variant:"title",size:"xmedium"},kt.t("Custom Tokens")),end:P.createElement(P.Fragment,null,P.createElement(Re,{variant:"body",size:"medium"},`${m.length}`),P.createElement(Kn,{direction:"horizontal",size:8}),P.createElement(_i,{color:"black"})),start:P.createElement(Ww,{color:"gray",size:16}),onClick:()=>t(D.customTokens)},I={id:"language-item",title:P.createElement(Re,{variant:"title",size:"xmedium"},kt.t("Language")),start:P.createElement(vw,{color:"gray",size:16}),end:P.createElement(P.Fragment,null,P.createElement(Re,{variant:"body",size:"medium"},s),P.createElement(Kn,{direction:"horizontal",size:8}),P.createElement(_i,{color:"black"})),onClick:()=>t(D.languages)},R={id:"infinite-approval-item",title:P.createElement(P.Fragment,null,P.createElement(Re,{variant:"title",size:"xmedium"},kt.t("Infinite approval")),P.createElement(Kn,{direction:"horizontal",size:4}),P.createElement(Mw,{side:"top",sideOffset:4,container:A(),content:P.createElement(Di,null,P.createElement(Re,{variant:"label",size:"medium",color:"neutral700"},kt.t("Enabling the 'Infinite approval' mode grants unrestricted access to smart contracts of DEXes/Bridges, allowing them to utilize the approved token amount without limitations.")))},P.createElement(kw,{color:"gray"}))),start:P.createElement(Tw,{color:"gray",size:16}),end:P.createElement(Aw,{checked:T}),onClick:S},ee={id:"theme-item",type:P.createElement(ww,null),title:P.createElement(Re,{variant:"title",size:"xmedium"},kt.t("Theme")),end:P.createElement(Lw,null,P.createElement(Nw,{container:A(),items:Pw,value:n,onChange:L=>o(L.id),type:"primary",borderRadius:"small"})),start:Dw(n)},oe=d?[]:[b,W];return h||oe.push($),f||oe.push(I),oe.push(R),!e?.singleTheme&&!g&&oe.push(ee),P.createElement(xw,{type:P.createElement(bw,{hasDivider:!0,id:"_",onClick:()=>console.log()}),items:oe})}i(Tg,"SettingsLists");var zw=Fw("div",{paddingLeft:"$8"});function kg(){let{isInCampaignMode:t,updateCampaignMode:e}=y(),o=t(),[,n]=Uw(),r=Ow(),a=i(()=>{r&&o&&(n(s=>(s.delete("liquiditySources"),s),{replace:!0}),e("liquiditySources",void 0))},"onClick");return Eo.createElement(ne,{header:{title:$l.t("Settings")}},Eo.createElement(ie,null,o&&Eo.createElement(_w,{type:"info",variant:"alarm",title:$l.t("Currently, you're in campaign mode with restrictions on liquidity sources. Would you like to switch out of this mode and make use of all available liquidity sources?"),action:Eo.createElement(zw,null,Eo.createElement($w,{type:"secondary",size:"small",onClick:a},$l.t("Reset")))}),Eo.createElement(_l,null),Eo.createElement(Tg,null)))}i(kg,"SettingsPage");import{i18n as Ab}from"@lingui/core";import{cancelSwap as Nb}from"@rango-dev/queue-manager-rango-preset";import{useManager as Wb}from"@rango-dev/queue-manager-react";import{Alert as Mb}from"@rango-dev/ui";import ep from"react";import{useParams as Bb}from"react-router-dom";import{i18n as st}from"@lingui/core";import{getCurrentBlockchainOfOrNull as pb,getCurrentStep as cb,getRelatedWalletOrNull as ub}from"@rango-dev/queue-manager-rango-preset";import{Button as Jg,CopyIcon as mb,Divider as db,DoneIcon as fb,IconButton as gb,QuoteCost as hb,RangoExplorerIcon as yb,StepDetails as Sb,Tooltip as Rg,Typography as Io,useCopyToClipboard as Cb}from"@rango-dev/ui";import{useWallets as Tb}from"@rango-dev/wallets-react";import eh from"bignumber.js";import{PendingSwapNetworkStatus as Gi}from"rango-types";import K,{useEffect as th,useRef as kb,useState as oh}from"react";import{useNavigate as vb}from"react-router-dom";import{i18n as oo}from"@lingui/core";var Qw=[oo.t("Sunday"),oo.t("Monday"),oo.t("Tuesday"),oo.t("Wednesday"),oo.t("Thursday"),oo.t("Friday"),oo.t("Saturday")];function vg(t){let e=new Date(t),o=e.getDate(),n=e.toLocaleString("default",{month:"long"}),r=e.getFullYear();return`${e.getDay()===new Date().getDay()?oo.t("Today"):`${Qw[e.getDay()]} ${o} ${n} ${r}`}, ${new Date(t).toLocaleTimeString()}`}i(vg,"timeSince");function xg(t){return t.finishTime?vg(parseInt(t.finishTime)):vg(parseInt(t.creationTime))}i(xg,"getSwapDate");import{PendingSwapNetworkStatus as Oi}from"rango-types";import Ui from"react";import{i18n as $i}from"@lingui/core";import{Button as wg,Divider as Fl,MessageBox as qw}from"@rango-dev/ui";import no from"react";var bg=i(({onCancel:t,onClose:e})=>no.createElement(no.Fragment,null,no.createElement(Fl,{size:20}),no.createElement(qw,{type:"error",title:$i.t("Cancel Swap"),description:$i.t("Are you sure you want to cancel this swap?")}),no.createElement(Fl,{size:32}),no.createElement(wg,{variant:"contained",type:"primary",size:"large",onClick:t},$i.t("Yes, Cancel it")),no.createElement(Fl,{size:12}),no.createElement(wg,{variant:"outlined",type:"primary",size:"large",onClick:e},$i.t("No, Continue"))),"CancelContent");import{i18n as Fi}from"@lingui/core";import{Button as Eg,Divider as Ol,MessageBox as Hw,Typography as Gw}from"@rango-dev/ui";import zt from"react";var Ig=i(({onDelete:t,onClose:e})=>zt.createElement(zt.Fragment,null,zt.createElement(Ol,{size:20}),zt.createElement(Hw,{type:"error",title:Fi.t("Delete Transaction"),description:Fi.t("Are you sure you want to delete this swap?")}),zt.createElement(Ol,{size:32}),zt.createElement(Eg,{variant:"contained",type:"primary",size:"large",onClick:t},Fi.t("Yes, Delete it")),zt.createElement(Ol,{size:12}),zt.createElement(Eg,{variant:"outlined",type:"primary",size:"large",onClick:e},zt.createElement(Gw,{variant:"title",size:"medium",color:"primary"},Fi.t("No, Cancel")))),"DeleteContent");import{i18n as Ul}from"@lingui/core";import{PendingSwapNetworkStatus as zl}from"rango-types";var Ql={[zl.WaitingForNetworkChange]:{type:"loading",title:Ul.t("Change Network")},[zl.WaitingForConnectingWallet]:{type:"warning",title:Ul.t("Connect Wallet")},[zl.NetworkChanged]:{type:"success",title:Ul.t("Network Changed")}};import{warn as Vw}from"@rango-dev/logging-core";import{MessageBox as Kw,Wallet as jw}from"@rango-dev/ui";import{useWallets as Xw}from"@rango-dev/wallets-react";import Ro,{useState as Yw}from"react";import{styled as Ag}from"@rango-dev/ui";var Ng=Ag("div",{display:"flex",justifyContent:"center"}),F2=Ag("div",{maxWidth:280,"& ._typography":{wordWrap:"break-word",display:"block"}});var Wg=i(t=>{let{type:e,title:o,currentStepWallet:n,message:r,showWalletButton:a,walletButtonDisabled:s}=t,[l,p]=Yw(),{getWalletInfo:u,state:c}=Xw(),m=n?.walletType,g=m?pn(c(m)):null,d=m?u(m):null,f=a&&!!m&&!!g&&!!d,{list:h}=ft(),T=i(()=>{if(m){let S=h.find(C=>C.type===m);S?p(S):Vw(new Error(`It seems requested wallet to be connected is not available in the list. requested wallet: ${S}`))}},"handleWalletItemClick");return Ro.createElement(Ro.Fragment,null,Ro.createElement(Kw,{type:e,title:o,description:r}),f&&Ro.createElement(Ng,null,Ro.createElement(jw,{container:A(),title:d.name,image:d.img,type:m,state:g,link:d.installLink,disabled:s,onClick:T})),Ro.createElement(fo,{wallet:l,onClose:()=>{p(void 0)}}))},"WalletStateContent");function ql(t){let{state:e,onClose:o,onDelete:n,onCancel:r,currentStepWallet:a,message:s,walletButtonDisabled:l}=t,p=e===Oi.WaitingForNetworkChange||e===Oi.WaitingForConnectingWallet||e===Oi.NetworkChanged;return Ui.createElement(J,{open:!!e,onClose:o,container:document.getElementById($e.SWAP_BOX_ID)||document.body},p&&Ui.createElement(Wg,{type:Ql[e].type,title:Ql[e].title,currentStepWallet:a,message:s,walletButtonDisabled:l,showWalletButton:e!==Oi.WaitingForNetworkChange}),e==="delete"&&Ui.createElement(Ig,{onClose:o,onDelete:n}),e==="cancel"&&Ui.createElement(bg,{onClose:o,onCancel:r}))}i(ql,"SwapDetailsModal");import{i18n as jn}from"@lingui/core";import{Button as Hl,Divider as zi,MessageBox as Mg,TokenAmount as Zw,Typography as Gl}from"@rango-dev/ui";import Oe from"react";import{useNavigate as Jw}from"react-router-dom";function Vl(t){let{open:e,onClose:o,status:n,priceValue:r,usdValue:a,realUsdValue:s,realValue:l,token:p,chain:u,percentageChange:c,description:m,diagnosisUrl:g}=t,d=Jw();return Oe.createElement(J,{open:e,onClose:o,container:document.getElementById($e.SWAP_BOX_ID)||document.body},n==="success"?Oe.createElement(Mg,{type:"success",title:jn.t("Swap Successful")},Oe.createElement(Zw,{direction:"vertical",tooltipContainer:A(),type:"output",centerAlign:!0,price:{value:r,usdValue:a,realUsdValue:s,realValue:l},token:p,chain:u,percentageChange:c}),Oe.createElement(zi,{size:12}),Oe.createElement(Gl,{variant:"body",size:"medium",color:"neutral700",align:"center"},m)):Oe.createElement(Mg,{type:"error",title:jn.t("Transaction Failed"),description:m}),Oe.createElement(zi,{size:32}),n==="success"&&Oe.createElement(Hl,{variant:"contained",type:"primary",size:"large",onClick:()=>{d("../../")}},Oe.createElement(Gl,{variant:"title",size:"medium",color:"neutral100"},jn.t("Done"))),Oe.createElement(zi,{size:12}),g&&Oe.createElement(Oe.Fragment,null,Oe.createElement(Hl,{variant:"contained",type:"primary",size:"large",onClick:()=>window.open(g,"_blank")},jn.t("Diagnosis")),Oe.createElement(zi,{size:12})),Oe.createElement(Hl,{variant:"outlined",type:"primary",size:"large",onClick:o},Oe.createElement(Gl,{variant:"title",size:"medium",color:"primary"},jn.t("See Details"))))}i(Vl,"SwapDetailsCompleteModal");import lb from"react";import{i18n as rb}from"@lingui/core";import{Alert as jg,IconButton as ib,LinkIcon as ab}from"@rango-dev/ui";import ro,{Fragment as sb}from"react";import{Alert as eb,ChevronDownIcon as tb,IconButton as ob}from"@rango-dev/ui";import tn,{useState as nb}from"react";import{css as Xn,darkTheme as Bg,styled as Qt,Typography as Rw}from"@rango-dev/ui";var Lg=Qt("div",{display:"flex",flexDirection:"column",flexGrow:1,overflow:"hidden"}),Qi=Qt("div",{width:"100%","& ._icon-button":{"&:hover":{"& svg":{color:"$secondary550",[`.${Bg} &`]:{color:"$secondary500"}}}}}),Pg=Qt(Sn,{padding:"$0 $20 $20 $20"}),k5=Qt("div",{display:"flex",flexDirection:"column",gap:"$10"}),Dg=Qt("div",{height:"450px",display:"flex",alignItems:"center",justifyContent:"center"}),v5=Qt("div",{display:"flex",justifyContent:"center",width:"100%",paddingTop:"33%",flex:1}),en=Xn({display:"flex",width:"100%",justifyContent:"space-between",alignItems:"center",padding:"$10 $20",borderBottom:"1px solid",$$color:"$colors$neutral300",[`.${Bg} &`]:{$$color:"$colors$neutral400"},borderColor:"$$color",color:"$neutral500"}),_g=Xn({padding:"$5 0"}),qi=Xn({display:"flex",justifyContent:"center",alignItems:"center",height:"$24"}),$g=Xn({display:"flex",width:"100%",padding:"$15 $20 $20",flexDirection:"column",alignItems:"start"}),Fg=Xn({width:"100%",padding:"0 $20 $10"}),Og=Qt("a",{fontSize:"$16",fontWeight:"$400",color:"$neutral700",display:"flex",alignItems:"center",justifyContent:"center"}),Ug=Qt("div",{display:"flex",flexDirection:"column",gap:"$5"}),Hi=Qt(Rw,{wordBreak:"break-word"});import{styled as Kl}from"@rango-dev/ui";var zg=Kl("div",{display:"flex",flexDirection:"column",gap:"$10"}),Qg=Kl("div",{transition:"transform 0.3s ease-in-out",variants:{rotated:{true:{transform:"rotate(180deg)"}}}}),qg=Kl("div",{transition:"max-height 0.3s ease-in-out",maxHeight:"0px",overflow:"hidden",variants:{open:{true:{maxHeight:"200px"}}}});function Hg(t){let{message:e}=t,[o,n]=nb(!1);return tn.createElement(eb,{type:"error",title:e.shortMessage,containerStyles:{"& .footer":{paddingTop:"$0"}},action:e.detailedMessage.content&&tn.createElement(ob,{onClick:()=>n(r=>!r),variant:"ghost",size:"xsmall"},tn.createElement(Qg,{rotated:o},tn.createElement(tb,{size:12,color:"gray"}))),footer:tn.createElement(qg,{open:o},tn.createElement(Hi,{variant:"body",size:"xsmall",color:"neutral700"},e.detailedMessage.content))})}i(Hg,"FailedAlert");import{i18n as Gg}from"@lingui/core";import{Alert as jl,Button as Vg}from"@rango-dev/ui";import{PendingSwapNetworkStatus as Xl}from"rango-types";import Yn from"react";function Kg(t){let{switchNetwork:e,setNetworkModal:o,message:n,showNetworkModal:r}=t;return e?Yn.createElement(jl,{type:"warning",title:n.shortMessage,action:Yn.createElement(Vg,{size:"xxsmall",type:"warning",onClick:()=>{o(Xl.WaitingForNetworkChange),e().catch(a=>{console.log(a)})}},Gg.t("Change"))}):r===Xl.WaitingForConnectingWallet?Yn.createElement(jl,{type:"warning",title:n.shortMessage,action:Yn.createElement(Vg,{size:"xxsmall",type:"warning",onClick:()=>{o(Xl.WaitingForConnectingWallet)}},Gg.t("Connect"))}):Yn.createElement(jl,{type:"warning",title:n.shortMessage})}i(Kg,"WarningAlert");function Yl(t){let{switchNetwork:e,showNetworkModal:o,setNetworkModal:n,message:r,step:a,hasAlreadyProceededToSign:s}=t,l=gn(a),p=a.status==="waitingForApproval"&&!l,u=a.status==="running"&&!l,c=u&&!s||p&&!a.explorerUrl?.length;return ro.createElement(zg,null,a.explorerUrl?.map((m,g,d)=>{let f=g+m.url,h=g===d.length-1,T=(h&&u||p)&&!c,S=h&&a.status==="failed";return ro.createElement(sb,{key:f},ro.createElement(jg,{type:h&&(T&&"loading"||S&&"error")||"success",title:m.description?`${m.description} Tx`:rb.t("View transaction"),action:m.url&&ro.createElement(ib,{variant:"ghost",size:"xsmall",onClick:()=>window.open(m.url,"_blank")},ro.createElement(ab,{size:12}))}))}),c&&ro.createElement(jg,{type:"loading",title:r.shortMessage}),a.status!=="failed"&&l&&ro.createElement(Kg,{switchNetwork:e,showNetworkModal:o,setNetworkModal:n,message:r}),a.status==="failed"&&ro.createElement(Hg,{message:r}))}i(Yl,"SwapDetailsAlerts");var Xg=2e3;var Yg=i(({swap:t,blockchains:e,swappers:o,...n})=>{let r=t.hasAlreadyProceededToSign!==!1;return t.steps.map((a,s)=>{let l=s===0?t.inputAmount:t.steps[s-1].outputAmount||t.steps[s-1].expectedOutputAmountHumanReadable;return{from:{token:{displayName:a.fromSymbol,image:a.fromLogo??""},chain:{displayName:pt(a.fromBlockchain,e)??"",image:a.fromBlockchainLogo??""},price:{value:B(l,6,6),realValue:l??""}},to:{token:{displayName:a.toSymbol,image:a.toLogo},chain:{displayName:pt(a.toBlockchain,e)??"",image:a.toBlockchainLogo??""},price:{value:B(a.outputAmount||a.expectedOutputAmountHumanReadable,6,6),realValue:a.outputAmount||a.expectedOutputAmountHumanReadable||""}},swapper:{displayName:on(a.swapperId,o)??"",image:a.swapperLogo??"",type:a.swapperType},internalSwaps:a.internalSwaps?a.internalSwaps.map(p=>({from:{chain:{displayName:pt(p.fromBlockchain,e)??"",image:p.fromBlockchainLogo??""}},to:{chain:{displayName:pt(p.toBlockchain,e)??"",image:p.toBlockchainLogo??""}},swapper:{displayName:on(p.swapperId,o)??"",image:p.swapperLogo??"",type:p.swapperType}})):[],alerts:lb.createElement(Yl,{step:a,hasAlreadyProceededToSign:r,...n})}})},"getSteps");function Zg(t){if(gn(t)&&t.status!=="failed"&&t.status!=="success")return"warning";switch(t.status){case"created":return"default";case"approved":case"waitingForApproval":case"running":return"in-progress";case"failed":return"error";case"success":return"completed"}}i(Zg,"getStepState");function Zl(t){let{swap:e,requestId:o,onDelete:n,onCancel:r}=t,{canSwitchNetworkTo:a,connect:s,getWalletInfo:l}=Tb(),p=y().blockchains(),u=y().swappers(),{findToken:c}=y(),m=z.use.retry(),g=se.use.isActiveTab(),d=vb(),[f,h]=Cb(Xg),T=kb(null),[S,C]=oh(null),[k,v]=oh(null),x=i(()=>{r(),C(null)},"onCancel"),N=be.use.getNotifications(),M=be.use.removeNotification(),w=N(),E=cb(e),b=E?.networkStatus;th(()=>{w.find(he=>he.requestId===e.requestId)&&(e.status==="success"||e.status==="failed"?(v(e.status),M(e.requestId)):k&&v(null))},[e.status,e.requestId]),th(()=>{L?C(Gi.WaitingForNetworkChange):b===Gi.WaitingForConnectingWallet||b===Gi.NetworkChanged?C(b):C(null)},[b]);let W=jc(e),$=E?pb(e,E):null,I=E?ub(e,E):null,R=xg(e),ee=Xc(e),oe=i(de=>!!l(de)?.mobileWallet,"isMobileWallet"),L=b===Gi.WaitingForNetworkChange&&!!$&&!!I?.walletType&&(oe(I.walletType)||a(I.walletType,$)),V=L?s.bind(null,I.walletType,$):void 0,le=Kc(e,E),Y=Yg({swap:e,switchNetwork:V,showNetworkModal:b,setNetworkModal:C,message:le,blockchains:p,swappers:u}),ae=Y.length,[ge,xe]=[e.steps[0],e.steps[ae-1]],U=xe.outputAmount||xe.expectedOutputAmountHumanReadable,Ke=e.steps.reduce((de,he)=>de+parseFloat(he.feeInUsd||""),0),xt=e.steps.find(de=>de.diagnosisUrl)?.diagnosisUrl,lt=B(parseFloat(U||"0")*(xe.toUsdPrice||0),4,4),wt=B(parseFloat(e.inputAmount)*(ge.fromUsdPrice||0),4,4),_=U?new eh(U).multipliedBy(xe.toUsdPrice||0).toString():"",Q=new eh(e.inputAmount).multipliedBy(ge.fromUsdPrice||0).toString(),G=ut(wt,lt),pe=le.detailedMessage.content||le.shortMessage,ce=e.status==="success"?st.t({id:"You have received {amount} {token} in {conciseAddress} wallet on {chain} chain.",values:{amount:B(U,6,6),token:Y[ae-1].to.token.displayName,conciseAddress:dr(e.wallets[Y[ae-1].to.chain.displayName]?.address||""),chain:Y[ae-1].to.chain.displayName}}):K.createElement(Ug,null,K.createElement(Io,{variant:"body",size:"medium",color:"neutral700",align:"center"},pe?"":st.t("Transaction was not sent."),W?`${st.t({id:"{amount} {symbol} on {blockchain} remain in your wallet",values:{amount:W.outputAmount,symbol:W.symbol,blockchain:W.blockchain}})}`:""),pe&&K.createElement(Hi,{align:"center",variant:"body",size:"medium",color:"neutral700"},K.createElement("b",null,"Reason:")," ",pe));return K.createElement(ne,{header:{title:st.t("Swap Details"),onCancel:e.status==="running"?()=>C("cancel"):void 0,suffix:e.status!=="running"&&K.createElement(Vt,null,K.createElement(Jg,{variant:"ghost",type:"error",size:"xsmall",onClick:()=>C("delete")},K.createElement(Io,{size:"medium",variant:"label",color:"error"},st.t("Delete"))))},footer:ee&&!k&&K.createElement(Jg,{fullWidth:!0,variant:"contained",type:"primary",size:"large",onClick:()=>{let de=Lr(e,p,c);m(de),setTimeout(()=>{d("../../")},0)}},st.t("Try again"))},K.createElement(ie,{compact:!0,view:!0},K.createElement(Qi,null,K.createElement("div",{className:en()},K.createElement(Io,{variant:"label",size:"large",color:"neutral700"},`${st.t("Request ID")}:`),K.createElement("div",{className:qi()},K.createElement(Io,{variant:"label",size:"small",color:"neutral700"},o),K.createElement(Rg,{container:A(),content:f?st.t("Copied To Clipboard"):st.t("Copy Request ID"),open:f||void 0,side:"bottom",alignOffset:-16,align:"end"},K.createElement(gb,{variant:"ghost",onClick:h.bind(null,o||"")},f?K.createElement(fb,{size:16,color:"secondary"}):K.createElement(mb,{size:16,color:"gray"}))),K.createElement(Og,{target:"_blank",href:`${gp}/swap/${o}`},K.createElement(Rg,{container:A(),content:st.t("View on Rango Explorer"),side:"bottom"},K.createElement(yb,{size:20}))))),K.createElement("div",{className:en()},K.createElement(Io,{variant:"label",size:"large",color:"neutral700"},e.finishTime?st.t("Finished at"):st.t("Created at")),K.createElement(Io,{variant:"label",size:"small",color:"neutral700"},R))),K.createElement("div",{className:$g()},K.createElement(hb,{fee:B(String(Ke),2,2),time:sn(ar(e.steps)),steps:ae}),K.createElement(En,{from:{price:{value:B(e.inputAmount,6,6),usdValue:wt,realUsdValue:Q,realValue:e.inputAmount},token:{displayName:Y[0].from.token.displayName,image:Y[0].from.token.image},chain:{image:Y[0].from.chain.image,displayName:Y[0].from.chain.displayName}},to:{price:{value:B(U,6,6),usdValue:lt,realUsdValue:_,realValue:U||""},token:{displayName:Y[ae-1].to.token.displayName,image:Y[ae-1].to.token.image},chain:{image:Y[ae-1].to.chain.image,displayName:Y[ae-1].to.chain.displayName}},percentageChange:B(G,2,2),warningLevel:Lt(G??0)})),K.createElement("div",{className:Fg()},K.createElement(Io,{variant:"title",size:"small"},st.t("Swaps steps"))),K.createElement(db,{size:8}),K.createElement(Pg,{ref:T},Y.map((de,he)=>{let Rn=he,io=Zg(e.steps[he]),ea=io==="error"||io==="in-progress"||io==="warning"||io==="completed"&&he===Y.length-1;return K.createElement(Sb,{key:Rn,step:de,type:"swap-progress",ref:T,state:io,hasSeparator:he!==0,tabIndex:Rn,isFocused:ea,tooltipContainer:A()})}))),K.createElement(ql,{state:S,onClose:()=>C(null),onCancel:x,onDelete:n,message:le.detailedMessage.content,currentStepWallet:I,walletButtonDisabled:!g}),K.createElement(Vl,{open:!!k,diagnosisUrl:xt,onClose:()=>v(null),status:e.status==="success"?"success":"failed",priceValue:B(U,6,6),usdValue:lt,realUsdValue:_,realValue:U||"",percentageChange:B(G,2,2),token:{displayName:Y[ae-1].to.token.displayName,image:Y[ae-1].to.token.image},chain:{image:Y[ae-1].to.chain.image},description:ce}))}i(Zl,"SwapDetails");import{i18n as Ki}from"@lingui/core";import{Divider as ih,NotFound as Ib,Skeleton as Jn,Typography as ji}from"@rango-dev/ui";import Te from"react";import{i18n as xb}from"@lingui/core";import{Divider as wb,Skeleton as bb,Typography as Eb}from"@rango-dev/ui";import ve from"react";import{css as vt,styled as Jl}from"@rango-dev/ui";var nh=Jl("div",{width:"100%",height:"100%",padding:"$10 $20"}),Zn=Jl("div",{backgroundColor:"$neutral100",borderRadius:"$xm",padding:"$10 $15"}),Vi=Jl("div",{width:"0px",height:"$20",borderLeft:"1px dashed $neutral700",marginLeft:"25px"}),P4=vt({display:"flex",justifyContent:"space-between",alignItems:"center"}),D4=vt({display:"flex",justifyContent:"space-between",alignItems:"center"}),_4=vt({paddingTop:"$15",display:"flex"}),$4=vt({padding:"$15 $0"}),F4=vt({width:"0px",height:"$16",borderLeft:"1px solid $neutral400",marginLeft:"13px"}),O4=vt({paddingBottom:"$10"}),U4=vt({display:"flex",justifyContent:"start",alignItems:"center"}),z4=vt({paddingTop:"$5",display:"flex",alignItems:"center"}),Q4=vt({display:"flex",alignItems:"center"}),q4=vt({padding:"$4 $6",display:"flex",justifyContent:"center",alignItems:"center"}),rh=vt({display:"flex",paddingTop:"$10",paddingBottom:"$5"});function Rl(){return ve.createElement(nh,null,ve.createElement(Nn,{type:"swap-preview"}),ve.createElement("div",{className:"swaps-steps"},ve.createElement(Eb,{variant:"title",size:"small"},xb.t("Swaps steps"))),ve.createElement(ve.Fragment,null,ve.createElement(Zn,null,ve.createElement(Wt,{separator:!1}),ve.createElement("div",{className:rh()},ve.createElement(wb,{direction:"horizontal",size:20}),ve.createElement(bb,{height:22,variant:"rectangular"}))),ve.createElement(Vi,null),ve.createElement(Zn,null,ve.createElement(Wt,{separator:!1})),ve.createElement(Vi,null),ve.createElement(Zn,null,ve.createElement(Wt,{separator:!1})),ve.createElement(Vi,null),ve.createElement(Zn,null,ve.createElement(Wt,{separator:!1}))))}i(Rl,"LoadingSwapDetails");function ah(t){let{requestId:e,showSkeleton:o}=t;return Te.createElement(ne,{header:{title:Ki.t("Swap Details"),suffix:Te.createElement(Vt,null)}},o&&Te.createElement(Lg,null,Te.createElement(Qi,null,Te.createElement("div",{className:en()},Te.createElement(ji,{variant:"label",size:"large",color:"neutral700"},`${Ki.t("Request ID")}:`),Te.createElement("div",{className:qi()},Te.createElement(ji,{variant:"label",size:"small",color:"neutral700"},Te.createElement(Jn,{width:60,height:10,variant:"rounded"})),Te.createElement(ih,{direction:"horizontal",size:4}),Te.createElement(Jn,{width:16,height:16,variant:"rectangular"}),Te.createElement(ih,{direction:"horizontal",size:4}),Te.createElement(Jn,{width:16,height:16,variant:"rectangular"}))),Te.createElement("div",{className:en()},Te.createElement(ji,{className:_g(),variant:"label",size:"large",color:"neutral700"},Te.createElement(Jn,{width:60,height:10,variant:"rounded"})),Te.createElement(ji,{variant:"label",size:"small",color:"neutral700"},Te.createElement(Jn,{width:60,height:10,variant:"rounded"})))),Te.createElement(Rl,null)),!o&&Te.createElement(Dg,null,Te.createElement(Ib,{title:Ki.t("Not found"),description:Ki.t({id:"Swap with request ID = {requestId} not found.",values:{requestId:e}})})))}i(ah,"SwapDetailsPlaceholder");function sh(){let{manager:t,state:e}=Wb(),o=!e.loadedFromPersistor,n=mt(t),{requestId:r}=Bb(),a=Ye(),{fetchStatus:s}=y();if(!r)return ep.createElement(Mb,{containerStyles:{margin:"20px"},type:"error",title:Ab.t("The request ID is necessary to display the swap details.")});let l=o||s==="loading",p=r?n.find(({swap:g})=>g.requestId===r):void 0,u=i(()=>{if(p?.id){let g=t?.get(p.id);g&&Nb(g)}},"onCancel"),c=i(async()=>{if(p?.id)try{t?.deleteQueue(p.id),a()}catch(g){console.log(g)}},"onDelete"),m=p?.swap;return!m||l?ep.createElement(ah,{requestId:r,showSkeleton:l}):ep.createElement(Zl,{swap:m,requestId:r,onCancel:u,onDelete:c})}i(sh,"SwapDetailsPage");import{i18n as lh}from"@lingui/core";import{Divider as Lb,getCategoriesCount as Pb,SelectableCategoryList as Db,styled as ch,Typography as _b,Wallet as $b}from"@rango-dev/ui";import Bt,{useState as ph}from"react";var Fb=ch("div",{display:"flex",justifyContent:"center",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5"}),Ob=ch(ie,{textAlign:"center"});function uh(){let{fetchStatus:t}=y(),[e,o]=ph("ALL"),n=y().blockchains(),{config:r}=y(),[a,s]=ph(),l=se.use.isActiveTab(),{list:p}=ft(),u=Op(p,n),m=Pb(u)!==1,g=Up(p,e),d=i(f=>{Ep(p,r.multiWallets)||s(f)},"handleWalletItemClick");return Bt.createElement(ne,{header:{title:lh.t("Connect Wallets")}},Bt.createElement(Ob,null,m&&Bt.createElement(Bt.Fragment,null,Bt.createElement(Db,{setCategory:o,category:e,blockchains:u,isLoading:t==="loading"}),Bt.createElement(Lb,{size:24})),Bt.createElement(_b,{variant:"title",size:"xmedium",align:"center"},lh.t("Choose a wallet to connect.")),Bt.createElement(Fb,null,g.map((f,h)=>{let T=`wallet-${h}-${f.type}`;return Bt.createElement($b,{key:T,...f,container:A(),onClick:()=>d(f),isLoading:t==="loading",disabled:!l})}),Bt.createElement(fo,{wallet:a,onClose:()=>{s(void 0)}}))))}i(uh,"WalletsPage");function mh(){return iu(),za(),Ub([{path:D.home,element:De.createElement(Qf,null)},{path:D.routes,element:De.createElement(Kf,null)},{path:D.fromSwap,children:[{index:!0,element:De.createElement(Pl,{type:"source"})},{path:D.blockchains,element:De.createElement(Bi,{type:"source"})}]},{path:D.toSwap,children:[{index:!0,element:De.createElement(Pl,{type:"destination"})},{path:D.blockchains,element:De.createElement(Bi,{type:"destination"})}]},{path:D.settings,children:[{index:!0,element:De.createElement(kg,null)},{path:D.languages,element:De.createElement(Hf,null)},{path:D.exchanges,element:De.createElement(El,{sourceType:"Exchanges"})},{path:D.bridges,element:De.createElement(El,{sourceType:"Bridges"})},{path:D.customTokens,children:[{index:!0,element:De.createElement(Rd,null)},{path:D.addCustomTokens,children:[{index:!0,element:De.createElement(Uu,null)},{path:D.blockchains,element:De.createElement(Bi,{hideCategory:!0,type:"custom-token"})}]}]}]},{path:D.swaps,children:[{index:!0,element:De.createElement(Tf,null)},{path:D.swapDetails,element:De.createElement(sh,null)}]},{path:D.wallets,element:De.createElement(uh,null)},{path:D.confirmSwap,element:De.createElement($d,null)}])}i(mh,"AppRoutes");import{useQueueManager as Xb}from"@rango-dev/queue-manager-rango-preset";import{splitWalletNetwork as Yb}from"@rango-dev/wallets-shared";import{isEvmBlockchain as Zb}from"rango-sdk";import{useContext as Jb,useEffect as Ch,useState as Th}from"react";import{globalCss as zb}from"@rango-dev/ui";var dh=i(()=>zb({"@import":"url('https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap')"})(),"globalFont");function fh(){let{setWatermark:t}=se();return{fetchApiConfig:i(async()=>{let o=await fetch(`${ct("BASE_URL")}/meta/dapp/config?apiKey=${ct("API_KEY")}`);if(!o.ok)throw new Error(`Request failed with status: ${o.status} `);let n=await o.json();t(n.config.watermark)},"fetchApiConfig")}}i(fh,"useFetchApiConfig");import{useWallets as Qb}from"@rango-dev/wallets-react";import{useEffect as qb,useRef as Hb}from"react";function gh(){let{connect:t,state:e}=Qb(),o=Hb({}),{fetchStatus:n}=y(),r=new URLSearchParams(location.search).get("autoConnect")||"",a=e(r);qb(()=>{n==="success"&&r&&a.installed&&!a.connecting&&!a.connected&&!o.current[r]&&(o.current[r]=!0,t(r))},[a,n])}i(gh,"useForceAutoConnect");import{isApprovalTX as Gb,RouteEventType as hh,StepEventType as yh,StepExecutionEventStatus as Vb,WidgetEvents as Xi}from"@rango-dev/queue-manager-rango-preset";import{useEffect as Sh}from"react";function tp(){let t=Z.use.connectedWallets(),e=Z.use.getWalletsDetails(),o=be.use.setNotification(),{findToken:n}=y();Sh(()=>{let r=i(a=>{let{event:s,step:l,route:p}=a;if(s.type===yh.TX_EXECUTION&&s.status===Vb.TX_SENT&&!Gb(l)||s.type===yh.SUCCEEDED){let c=t.find(g=>g.chain===l?.fromBlockchain),m=l?.fromBlockchain!==l?.toBlockchain&&t.find(g=>g.chain===l?.toBlockchain);c&&e([c],n),m&&e([m],n)}o(s,p)},"handleStepEvent");return ye.on(Xi.StepEvent,r),()=>ye.off(Xi.StepEvent,r)},[ye,t]),Sh(()=>{let r=i(a=>{let{event:s,route:l}=a;(s.type===hh.FAILED||s.type===hh.SUCCEEDED)&&o(s,l)},"handleRouteEvent");return ye.on(Xi.RouteEvent,r),()=>ye.off(Xi.RouteEvent,r)},[ye])}i(tp,"useSubscribeToWidgetEvents");import{useManager as Kb}from"@rango-dev/queue-manager-react";import{useEffect as jb}from"react";function op(){let{isSynced:t,syncNotifications:e}=be(),{manager:o,state:n}=Kb();jb(()=>{be.persist.hasHydrated()&&n.loadedFromPersistor&&!t&&e(mt(o))},[be.persist.hasHydrated(),n.loadedFromPersistor,t])}i(op,"useSyncNotifications");function np(){gh(),dh(),tp(),op();let t=y().blockchains(),{canSwitchNetworkTo:e}=Zr(),[o,n]=Th(""),[r,a]=Th(),s=Jb(Er),l=t.filter(Zb),{fetchApiConfig:p}=fh();Ch(()=>()=>ru(),[]),Xb({lastConnectedWallet:o,clearDisconnectedWallet:()=>{a(void 0)},disconnectedWallet:r,evmChains:l,canSwitchNetworkTo:e}),Ch(()=>(po.init(),be.persist.hasHydrated()||be.persist.rehydrate(),s.onConnectWallet(n),s.onDisconnectWallet(u=>{a(u),u===Yb(o)?.[0]&&n("")}),p().catch(console.log),po.destroy),[])}i(np,"useBootstrap");import{styled as Rb}from"@rango-dev/ui";var kh=Rb("div",{fontFamily:"$widget",boxSizing:"border-box",textAlign:"left","& *, *::before, *::after":{boxSizing:"inherit"},"& *:focus-visible":{outlineColor:"$info500",transition:"none"},"& ul, ol, li":{listStyleType:"none"}});function Yi(){np();let{config:t}=y(),{activeTheme:e}=Qo(t?.theme||{}),{activeLanguage:o}=to();return rp.createElement(eE,{language:o},rp.createElement(kh,{id:"swap-container",className:e()},rp.createElement(mh,null)))}i(Yi,"Main");import{setSolanaSignerConfig as TE}from"@rango-dev/signer-solana";import ap,{useEffect as Ih,useMemo as kE}from"react";import{useState as tE}from"react";var oE=i(()=>{let[t,e]=tE(null),o=i(a=>{let s=document.createElement("link");return s.href=a,s.rel="stylesheet",document.head.appendChild(s),s},"loadFont"),n=i(()=>{t&&(document.head.removeChild(t),e(null))},"unloadFont");return{handleLoadCustomFont:i(a=>{n();let s=bp(a);if(s){let l=o(s);e(l)}},"handleLoadCustomFont")}},"useFontLoader"),vh=oE;import{checkWaitingForNetworkChange as nE,makeQueueDefinition as rE}from"@rango-dev/queue-manager-rango-preset";import{Provider as iE}from"@rango-dev/queue-manager-react";import{useWallets as aE}from"@rango-dev/wallets-react";import{convertEvmBlockchainMetaToEvmChainInfo as sE}from"@rango-dev/wallets-shared";import{isEvmBlockchain as lE}from"rango-types";import pE,{useMemo as cE}from"react";function uE(t){let{providers:e,getSigners:o,state:n,connect:r,canSwitchNetworkTo:a,getWalletInfo:s}=aE(),l=cE(()=>rE({API_KEY:t.apiKey||ct("API_KEY"),BASE_URL:ct("BASE_URL"),emitter:{emit:ye.emit}}),[t.apiKey]),p=y().blockchains(),c={blockchains:Z.use.connectedWallets().map(k=>({accounts:[k],name:k.chain}))},m=i(async(k,v)=>{if(a(k,v))return r(k,v)},"switchNetwork"),g=i(k=>!!s(k).mobileWallet,"isMobileWallet"),d=p.filter(k=>k.enabled).reduce((k,v)=>(k[v.name]=v,k),{}),f=p.filter(lE),h=i(k=>{let{supportedChains:v}=s(k);return pr(v)},"getSupportedChainNames"),T=e(),S={meta:{blockchains:d,evmBasedChains:f,evmNetworkChainInfo:sE(f),getSupportedChainNames:h},getSigners:o,wallets:c,providers:T,switchNetwork:m,canSwitchNetworkTo:a,connect:r,state:n,isMobileWallet:g},C=se.use.isActiveTab();return pE.createElement(iE,{queuesDefs:[l],context:S,onPersistedDataLoaded:k=>{nE(k)},isPaused:!C},t.children)}i(uE,"QueueManager");var xh=uE;import{useManager as hE}from"@rango-dev/queue-manager-react";import yE,{createContext as SE,useContext as CE}from"react";function wh(){let{findToken:t}=y(),e=y().blockchains(),o=y().tokens(),{setFromBlockchain:n,setFromToken:r,setToBlockchain:a,setToToken:s,setInputAmount:l}=z();return i(u=>{let{fromBlockchain:c,fromToken:m,toBlockchain:g,toToken:d,requestAmount:f}=u,h={blockchains:e,tokens:o};if(c!==void 0){let T=e.find(S=>S.name===c)??null;n(T)}if(m!==void 0){let T=m?t(m)??null:null;r({meta:h,token:T})}if(g!==void 0){let T=e.find(S=>S.name===g)??null;a(T)}if(d!==void 0){let T=d?t(d)??null:null;s({meta:h,token:T})}f!==void 0&&l(f)},"updateQuoteInputs")}i(wh,"useUpdateQuoteInputs");import{cancelSwap as mE,getCurrentBlockchainOfOrNull as dE,getCurrentStep as fE,getRelatedWalletOrNull as gE}from"@rango-dev/queue-manager-rango-preset";var Zi=class{static{i(this,"WidgetHistory")}constructor(e,o){this.manager=e,this.actions=o}getAllSwaps(){return mt(this.manager)}getCurrentStep(e){return this.getCurrentStepInfo(e).step}getCurrentStepWallet(e){return this.getCurrentStepInfo(e).wallet}getCurrentStepNetwork(e){return this.getCurrentStepInfo(e).network}retry(e,o){let n=Lr(e,o.blockchains,this.actions.findToken);return this.actions.retrySwap(n)}cancel(e){let o=this.manager?.get(e);o&&mE(o)}getCurrentStepInfo(e){let o=fE(e);return{step:o,wallet:o?gE(e,o):null,network:o?dE(e,o):null}}};var bh=SE(void 0);function ip(t){let{manager:e}=hE(),o=se.use.isActiveTab(),n=z.use.retry(),{findToken:r}=y(),a=new Zi(e,{retrySwap:n,findToken:r}),s=Z.use.connectedWallets(),l=Z.use.loading(),p=Lp(s),u=Z.use.getWalletsDetails(),c=y().blockchains(),m=y().tokens(),g=y().swappers(),d=y().fetchStatus,f=to().resetLanguage,h=be().getNotifications(),T=be().clearNotifications,S=wh(),{fromBlockchain:C,toBlockchain:k,fromToken:v,toToken:x,inputAmount:N}=z(),M={isActiveTab:o,setCurrentTabAsActive:po.forceClaim,history:a,wallets:{isLoading:l,details:s,totalBalance:p,refetch:w=>u(w,r)},meta:{blockchains:c,tokens:m,swappers:g,loadingStatus:d,findToken:r},resetLanguage:f,notifications:{list:h,clearAll:T},quote:{quoteInputs:{fromBlockchain:C?.name??null,fromToken:v?{symbol:v.symbol,blockchain:v.blockchain,address:v.address}:null,toBlockchain:k?.name??null,toToken:x?{symbol:x.symbol,blockchain:x.blockchain,address:x.address}:null,requestAmount:N},updateQuoteInputs:S}};return yE.createElement(bh.Provider,{value:M},t.children)}i(ip,"WidgetInfo");function Eh(){let t=CE(bh);if(!t)throw new Error("useWidget can only be used within the WidgetProvider component");return t}i(Eh,"useWidget");function Ji(t){let{onUpdateState:e,config:o}=t,n=t.config?.theme?.fontFamily,{handleLoadCustomFont:r}=vh();return Ih(()=>{n&&r(n)},[n]),kE(()=>{zp({API_KEY:o?.apiKey||nr,BASE_URL:o?.apiUrl||fp})},[o.apiKey,o.apiUrl]),Ih(()=>{t.config?.signers?.customSolanaRPC&&TE("customRPC",t.config.signers.customSolanaRPC)},[t.config?.signers?.customSolanaRPC]),ap.createElement(Ir,{config:o,onUpdateState:e},ap.createElement(xh,{apiKey:o.apiKey},ap.createElement(ip,null,t.children)))}i(Ji,"WidgetProvider");function Ah(t){let e=t.config?.externalWallets;return Ri.createElement(Wc,null,e?Ri.createElement(Yi,null):Ri.createElement(Ji,{config:t.config??ra},Ri.createElement(Yi,null)))}i(Ah,"Widget");function Nh(){let{on:t,off:e}=ye;return{on:t,off:e}}i(Nh,"useWidgetEvents");var Rj={DerivationPath:mn,Namespaces:un,isOnDerivationPath:fn,isOnNamespace:dn};export{bj as EventSeverity,lo as MainEvents,Dj as Networks,Fj as PendingSwapNetworkStatus,ha as QuoteEventTypes,Ej as RouteEventType,ia as SUPPORTED_FONTS,Rj as StatefulConnect,Ij as StepEventType,Aj as StepExecutionBlockedEventStatus,Nj as StepExecutionEventStatus,$e as UI_ID,ya as UiEventTypes,Sr as WalletEventTypes,Lj as WalletEvents,_j as WalletTypes,Ah as Widget,lo as WidgetEvents,Ji as WidgetProvider,Ir as WidgetWallets,Ra as customizedThemeTokens,Mj as readAccountAddress,qt as useStatefulConnect,ft as useWalletList,Zr as useWallets,Eh as useWidget,Nh as useWidgetEvents,yr as widgetEventEmitter};
3
3
  //# sourceMappingURL=index.js.map