@rango-dev/widget-embedded 0.39.1-next.17 → 0.39.1-next.18

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 zh=Object.defineProperty;var i=(t,e)=>zh(t,"name",{value:e,configurable:!0});import{EventSeverity as l3,RouteEventType as c3,StepEventType as p3,StepExecutionBlockedEventStatus as u3,StepExecutionEventStatus as d3}from"@rango-dev/queue-manager-rango-preset";import{legacyReadAccountAddress as f3}from"@rango-dev/wallets-core/legacy";import{useWallets as Xr,Events as h3}from"@rango-dev/wallets-react";import{Networks as S3,WalletTypes as C3}from"@rango-dev/wallets-shared";import{PendingSwapNetworkStatus as T3}from"rango-types";import{Divider as _S}from"@rango-dev/ui";import co,{useEffect as DS,useRef as $S,useState as Wp}from"react";import{WalletState as Qh}from"@rango-dev/ui";import{useWallets as Hh}from"@rango-dev/wallets-react";import{useReducer as qh}from"react";function nc(t){return!!t.derivationPath}i(nc,"isStateOnDerivationPathStep");function rc(t){return!!t.namespace}i(rc,"isStateOnNamespace");var ir={status:"init",namespace:null,derivationPath:null};function ic(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 ir;case"resetDerivation":return t.namespace?{...t,derivationPath:null,status:"namespace"}:ir;default:throw new Error("Action hasn't been defined.")}}i(ic,"reducer");function Gt(){let{state:t,disconnect:e,connect:o}=Hh(),[n,r]=qh(ic,ir),a=i(async(u,d,h)=>{r({type:"reset"});try{let g=d?.map(f=>({...f,network:void 0}));return await o(u,g),{status:"connected"}}catch(g){let f=g?.message?`Error: ${g.message}`:"An unknown error happened during connecting wallet.";throw new Error(f,{cause:g})}},"runConnect"),s=i(async(u,d)=>{if(u.state===Qh.DISCONNECTED){if(!!u.isHub&&u.properties?.find(k=>k.name==="detached")&&u.state!=="connected")return r({type:"needsNamespace",payload:{targetWallet:u}}),{status:"namespace"};if(!u.needsNamespace)return await a(u.type,void 0,d);let f=u.needsNamespace.data.length>1,m=u.needsDerivationPath;if(f)return r({type:"needsNamespace",payload:{targetWallet:u}}),{status:"namespace"};if(m){let C=u.needsNamespace.data[0];return r({type:"needsDerivationPath",payload:{providerType:u.type,providerImage:u.image,namespace:C.value}}),{status:"derivation-path"}}return await a(u.type,u.needsNamespace?.data.map(C=>({namespace:C.value})),d)}return d?.disconnectIfConnected?(await p(u.type),{status:"disconnected"}):{status:"disconnected-unhandled"}},"handleConnect"),l=i(async(u,d)=>{let h=u.needsNamespace?.selection==="single",g=u.needsDerivationPath,f=d[0];if(!f)throw new Error("To confirm a namespace, you should select at least one namespace.");if(h&&g)return r({type:"needsDerivationPath",payload:{providerType:u.type,providerImage:u.image,namespace:f}}),{status:"derivation-path"};if(!rc(n))throw new Error("Something went wrong on handling namespace. Please retry.");let m=n.namespace.targetWallet.type,C=d.map(S=>({namespace:S}));return await a(m,C)},"handleNamespace"),c=i(async u=>{if(!u)throw new Error("Derivation path is empty. Please make sure you've filled the field correctly.");if(!nc(n))throw new Error("It seems you are filling derivation path without setting namespace before doing that. Please retry to connect.");let d=n.derivationPath.providerType,g=[{namespace:n.derivationPath.namespace,derivationPath:u}];return await a(d,g)},"handleDerivationPath"),p=i(async u=>{let d=t(u);return d.connected||d.connecting?(await e(u),{status:"disconnected"}):{status:"noop"}},"handleDisconnect");return{handleConnect:s,handleDisconnect:p,handleNamespace:l,handleDerivationPath:c,getState:()=>n,resetState:u=>{r(u==="derivation"?{type:"resetDerivation"}:{type:"reset"})}}}i(Gt,"useStatefulConnect");import{WalletState as ha}from"@rango-dev/ui";import{useWallets as Ry}from"@rango-dev/wallets-react";import{detectMobileScreens as eS,KEPLR_COMPATIBLE_WALLETS as tS,WalletTypes as fn}from"@rango-dev/wallets-shared";import{useCallback as oS,useEffect as nS}from"react";import jy,{createContext as Xy,useContext as Yy,useEffect as Zy,useRef as Jy}from"react";import{create as Vy}from"zustand";import{persist as Ky}from"zustand/middleware";import{allProviders as Gh}from"@rango-dev/provider-all";var Zi=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()}},Eo=new Zi;import{defineVersions as sc,pickVersion as lc,Provider as Ji}from"@rango-dev/wallets-core";function cc({allProviders:t,configWallets:e}){if(e){let o=[];return e.forEach(n=>{if(typeof n=="string"){let r=t.find(a=>{let s=pc(a);return s instanceof Ji?s.id===n:s.config.type===n});r?o.push(r):console.warn(`Couldn't find ${n} provider. Please make sure you are passing the correct name.`)}else n instanceof Ji?o.push(sc().version("1.0.0",n).build()):o.push(sc().version("0.0.0",n).build())}),o}return t}i(cc,"matchAndGenerateProviders");function pc(t){try{return lc(t,"1.0.0")[1]}catch{return lc(t,"0.0.0")[1]}}i(pc,"pickProviderVersionWithFallbackToLegacy");function uc(t){return t.map(o=>pc(o)).map(o=>o instanceof Ji?o.id:o.config.type)}i(uc,"configWalletsToWalletName");function ar(t,e){return e.find(o=>o.name===t)?.displayName}i(ar,"getBlockchainDisplayNameFor");function st(t,e){return e.find(o=>o.name===t)?.shortName}i(st,"getBlockchainShortNameFor");function dc(t,e){return e.find(o=>o.name===t)?.logo}i(dc,"getBlockchainImage");function rn(t,e){return e.find(o=>o.id===t)?.title}i(rn,"getSwapperDisplayName");function an(t,e){return e.find(o=>o.name===t)??null}i(an,"findBlockchain");function Ri(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(Ri,"isTokenNative");function lt(t){return`${t.blockchain.toLowerCase()}-${t.symbol.toLowerCase()}-${(t.address??"").toLowerCase()}`}i(lt,"createTokenHash");function Io(t,e){return t.addressPatterns.filter(r=>new RegExp(r).test(e)).length>0}i(Io,"isValidTokenAddress");function sn(t){let{config:e,meta:o}=t,n={},r=e.tokens,a=i(l=>{l.forEach(c=>{typeof c!="string"&&(c=lt(c));let p=o.tokensMapByTokenHash.get(c);p&&(n[c]=p)})},"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(c=>{l.has(c)||a(o.tokensMapByBlockchainName[c])})}return s.forEach(l=>{let c=r[l];if(!c&&o.tokensMapByBlockchainName?.[l]){a(o.tokensMapByBlockchainName[l]);return}c&&(c.isExcluded?(a(o.tokensMapByBlockchainName[l]),c.tokens.forEach(p=>{let u=lt(p);delete n[u]})):a(c.tokens))}),Object.values(n)}i(sn,"matchTokensFromConfigWithMeta");function sr(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(sr,"getSupportedBlockchainsFromConfig");function fc(t){return{walletConnectProjectId:t?.walletConnectProjectId,trezorManifest:t?.trezorManifest,tonConnect:t?.tonConnect,walletConnectListedDesktopWalletLink:t.__UNSTABLE_OR_INTERNAL__?.walletConnectListedDesktopWalletLink}}i(fc,"makeProvidersOptionsFromConfig");var lr={apiKey:"",title:void 0,multiWallets:!0,excludeLiquiditySources:!0,customDestination:!0,variant:"default",trezorManifest:{appUrl:"https://widget.rango.exchange/",email:"hi+trezorwidget@rango.exchange"},tonConnect:{manifestUrl:"https://raw.githubusercontent.com/rango-exchange/rango-types/main/assets/manifests/tonconnect-manifest.json"}},Vh={clientUrl:void 0},Kh={liquiditySources:void 0};function mc(t){let e=fc(t),o={walletconnect2:{WC_PROJECT_ID:e?.walletConnectProjectId||"",DISABLE_MODAL_AND_OPEN_LINK:e?.walletConnectListedDesktopWalletLink},selectedProviders:t.wallets,trezor:e?.trezorManifest?{manifest:e.trezorManifest}:void 0,tonConnect:e?.tonConnect?.manifestUrl?{manifestUrl:e?.tonConnect.manifestUrl}:void 0};return Gh(o).map(a=>a())}i(mc,"generateProviders");var gc=i((t,e,o)=>{let n=mc({...lr,...t});return{config:{...lr,...t},iframe:Vh,campaignMode:Kh,allProviders:n,getLiquiditySources:()=>{let{config:r,campaignMode:a}=o();return a.liquiditySources?.length?a.liquiditySources:r.liquiditySources??[]},getDisabledLiquiditySources:()=>{let{disabledLiquiditySources:r,campaignMode:a}=o();return a.liquiditySources?.length?[]:r},excludeLiquiditySources:()=>{let{config:r,campaignMode:a}=o();return a.liquiditySources?.length?!1:!!r.excludeLiquiditySources},isInCampaignMode:()=>{let{campaignMode:r}=o();return!!r.liquiditySources?.length},updateConfig:r=>{let a=o().config,{_tokensMapByTokenHash:s,_tokensMapByBlockchainName:l}=o(),c=sn({type:"source",config:{blockchains:r.from?.blockchains,tokens:r.from?.tokens},meta:{tokensMapByBlockchainName:l,tokensMapByTokenHash:s}}),p=sn({type:"destination",config:{blockchains:r.to?.blockchains,tokens:r.to?.tokens},meta:{tokensMapByBlockchainName:l,tokensMapByTokenHash:s}});Eo.set("supportedSourceTokens",c),Eo.set("supportedDestinationTokens",p),e({config:{...a,...r}})},updateCampaignMode:(r,a)=>{let s=o().campaignMode;e({campaignMode:{...s,[r]:a}})},updateIframe:(r,a)=>{let s=o().iframe;e({iframe:{...s,[r]:a}})},buildAndSetProviders:()=>{let{config:r}=o(),a=mc(r);e({allProviders:a})},getAvailableProviders:()=>{let{allProviders:r,config:a}=o(),s=fc(a);return cc({allProviders:r,configWallets:a.wallets,options:s})}}},"createConfigSlice");import{TransactionType as hc}from"rango-types";var yc=[hc.EVM,hc.SOLANA];import{RangoClient as ly}from"rango-sdk";import{UI_ID as jh}from"@rango-dev/ui";var cr="c6381a79-2817-4602-83bf-6a641a409e32",Sc="https://api.rango.exchange",Cc="https://explorer.rango.exchange",De={SWAP_BOX_ID:"rango-swap-box",EXPANDED_BOX_ID:"rango-expanded-box",...jh};import{BlockchainCategories as ty,WalletState as bt}from"@rango-dev/ui";import{legacyReadAccountAddress as oy}from"@rango-dev/wallets-core/legacy";import{detectInstallLink as ny,getCosmosExperimentalChainInfo as ry,isEvmAddress as iy,KEPLR_COMPATIBLE_WALLETS as iA,Networks as Mc}from"@rango-dev/wallets-shared";import No from"bignumber.js";import{isCosmosBlockchain as ay}from"rango-types";import Xh from"bignumber.js";var ce=new Xh(0);import{WalletTypes as Yh}from"@rango-dev/wallets-shared";var no="~",kc=[Yh.LEAP];import{BlockchainCategories as ta,WalletState as ey}from"@rango-dev/ui";import{TransactionType as pr}from"rango-sdk";var Tc="Roboto",ea=[{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 Ao(t){return Array.from(new Set(t))}i(Ao,"removeDuplicateFrom");function Ic(t,e){let o;return n;function n(...r){o&&clearTimeout(o),o=setTimeout(()=>{o=null,t(...r)},e)}}i(Ic,"debounce");function Je(t,e){return t.toLowerCase().indexOf(e.toLowerCase())>-1}i(Je,"containsText");function bc(t,e){return t.toLowerCase()===e.toLowerCase()}i(bc,"exactText");function xc(t,e){return t.toLowerCase().startsWith(e.toLowerCase())}i(xc,"startWithText");var I=i(()=>document.getElementById(De.SWAP_BOX_ID),"getContainer"),ro=i(()=>document.getElementById(De.EXPANDED_BOX_ID),"getExpanded");function Ec(t,e,o){let n=!!e&&bc(e,t),r=!!o&&bc(o,t);return n!==r?n?-1:1:0}i(Ec,"compareExactMatchText");function oa(t,e,o){let n=!!e&&Je(e,t),r=!!o&&Je(o,t);return n!==r?n?-1:1:n&&r&&e?.length!==o?.length?e?.length-o?.length:0}i(oa,"compareContainsText");function na(t,e,o){let n=!!e&&xc(e,t),r=!!o&&xc(o,t);return n!==r?n?-1:1:n&&r&&e?.length!==o?.length?e?.length-o?.length:0}i(na,"compareStartWithText");function Ac(t,e,o){if(!o)return 0;let n=Ec(o,t.symbol,e.symbol);if(n)return n;if(o.length>=3){let r=Ec(o,t.name,e.name);if(r)return r}if(o.length>=2){let r=na(o,t.symbol,e.symbol);if(r)return r}if(o.length>=3){let r=oa(o,t.symbol,e.symbol);if(r)return r}if(o.length>=3){let r=na(o,t.name,e.name);if(r)return r}if(o.length>=3){let r=oa(o,t.name,e.name);if(r!==0)return r}if(o.length>=4){let r=na(o,t.address,e.address);if(r)return r}if(o.length>=4){let r=oa(o,t.address,e.address);if(r!==0)return r}return 0}i(Ac,"compareWithSearchFor");var ur=i((t,e)=>{switch(e){case ta.ALL:return!0;case ta.UTXO:return t===pr.TRANSFER;case ta.OTHER:return t!==pr.TRANSFER&&t!==pr.COSMOS&&t!==pr.EVM;default:return t===e}},"isBlockchainTypeInCategory"),Nc=i(t=>ea.find(o=>o.value===t)?.url,"getFontUrlByName");function Wc(t,e){let o=!!t.find(n=>n.state===ey.CONNECTED);return e===!1&&o}i(Wc,"isSingleWalletActive");import{BigNumber as Bc}from"bignumber.js";var ln=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 Bc(t),r=1,a=1e3;for(let s=0;s<60;s++)if(new Bc(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 dr=i(t=>t?.reduce((e,o)=>e+(o.estimatedTimeInSeconds??0),0)||0,"totalArrivalTime");var wt=i((t,e)=>t.toLowerCase().indexOf(e.toLowerCase())>-1,"containsText"),cn=i(t=>!!t&&parseFloat(t)>0,"isPositiveNumber");function pn(t){switch(!0){case t.connected:return bt.CONNECTED;case t.connecting:return bt.CONNECTING;case!t.installed:return bt.NOT_INSTALLED;default:return bt.DISCONNECTED}}i(pn,"mapStatusToWalletState");function Lc(t,e,o,n){return o.filter(r=>!kc.includes(r)).filter(r=>{let{supportedChains:a,isContractWallet:s}=e(r),{installed:l,network:c}=t(r);return s&&(!l||!!n&&c!==n)?!1:n?!!a.find(u=>u.name===n):!0}).map(r=>{let{name:a,img:s,installLink:l,showOnMobile:c,needsNamespace:p,supportedChains:u,needsDerivationPath:d,properties:h,isHub:g}=e(r),f=Ao(u.map(C=>C.type)),m=pn(t(r));return{title:a,image:s,link:ny(l),state:m,type:r,showOnMobile:c,needsNamespace:p,blockchainTypes:f,needsDerivationPath:d,properties:h,isHub:g}})}i(Lc,"mapWalletTypesToWalletInfo");function un(t){if(!t)return null;let e=[];return e=t.map(o=>o.name),e}i(un,"walletAndSupportedChainsNames");function ia(t,e,o,n,r){let a=[];function s(c,p){if(!!!a.find(d=>d.chain===c)){let d={address:p,chain:c,walletType:t};a.push(d)}}i(s,"addAccount");let l=n||[];return e.forEach(c=>{let{address:p,network:u}=oy(c),d=l.length>0,h=l.includes(u),g=u===Mc.Unknown;if(d&&!h&&!g)return;let m=u===Mc.Unknown&&iy(p);if(g&&!m)return;o.includes(u)||m?r?s(u,p.toLowerCase()):l.filter(k=>o.includes(k)).forEach(k=>{s(k,p.toLowerCase())}):s(u,p)}),a}i(ia,"prepareAccountsForWalletStore");function io(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:c}=r;c.forEach((p,u)=>{let d=p.from.blockchain,h=p.to.blockchain,g=a===o.swaps.length-1,f=u===c.length-1;(!g&&!f||g&&l!==d||e==="all")&&n.add(d),e==="all"&&n.add(h)})}e==="all"&&n.add(l)}),Array.from(n)}i(io,"getQuoteWallets");function Pc(t,e){return t.address===e.address&&t.chain===e.chain&&t.walletType===e.walletType}i(Pc,"isAccountAndWalletMatched");var _c=i(t=>{let e=Object.values(t).reduce((o,n)=>{let r=n.usdValue?ra(n.usdValue,n.decimals):ce.toFixed();return o.plus(r)},new No(ce));return sy(e.toString())},"calculateWalletUsdValue");function sy(t){let e=t.toString().split(".");return e[0]=e[0].replace(/\B(?=(\d{3})+(?!\d))/g,","),e.join(".")}i(sy,"numberWithThousandSeparator");var gr=i((t,e)=>{let o=ry(Object.entries(t).map(([,n])=>n).filter(ay));return o&&o[e]?.experimental},"isExperimentalChain");function ra(t,e){return new No(t).shiftedBy(-e).toFixed()}i(ra,"representAmountInNumber");function hr(t){if(!t)return null;let e=ra(t.amount,t.decimals),o=t.usdValue?ra(t.usdValue,t.decimals):null,n=B(e,8,8),r=o?B(o,4,4):null;return t?{...t,amount:n,usdValue:r}:null}i(hr,"formatBalance");function Dc(t,e){if(t?.usdValue||e?.usdValue){let o=t&&t.usdValue?new No(t.usdValue).shiftedBy(-t.decimals):ce,n=e&&e.usdValue?new No(e.usdValue).shiftedBy(-e.decimals):ce;return o.isEqualTo(n)?0:o.isGreaterThan(n)?-1:1}if(t?.amount||e?.amount){let o=t&&t.amount?new No(t.amount).shiftedBy(-t.decimals):ce,n=e&&e.amount?new No(e.amount).shiftedBy(-e.decimals):ce;return o.isEqualTo(n)?0:o.isGreaterThan(n)?-1:1}return 0}i(Dc,"compareTokenBalance");function Mt(t,e){return t?.blockchain===e?.blockchain&&t?.symbol.toLowerCase()===e?.symbol.toLowerCase()&&t?.address?.toLowerCase()===e?.address?.toLowerCase()}i(Mt,"areTokensEqual");function $c(t){return t.sort((e,o)=>+(o.state===bt.CONNECTED)-+(e.state===bt.CONNECTED)||+(o.state===bt.DISCONNECTED||o.state===bt.CONNECTING)-+(e.state===bt.DISCONNECTED||e.state===bt.CONNECTING))}i($c,"sortWalletsBasedOnConnectionState");function yr(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(yr,"getConciseAddress");function Fc({chain:t,connectedWallets:e,walletType:o}){return e.find(n=>n.walletType===o&&n.chain===t)?.address}i(Fc,"getAddress");var Oc=i((t,e)=>!!t.find(o=>o.chain===e&&o.loading),"isFetchingBalance");function Uc(t){return t.map(e=>e.state).join("-")}i(Uc,"hashWalletsState");function zc(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(zc,"filterBlockchainsByWalletTypes");function Qc(t,e){return e===ty.ALL?t:t.filter(o=>{for(let n of o.blockchainTypes)if(ur(n,e))return!0;return!1})}i(Qc,"filterWalletsByCategory");var aa={API_KEY:cr};function Lt(t){return aa[t]||""}i(Lt,"getConfig");function Hc(t){let e;return typeof structuredClone=="function"?e=structuredClone(t):e=JSON.parse(JSON.stringify(t)),aa=e,aa}i(Hc,"initConfig");var qc=20,Gc=25,sa="theme-widget",la=i((t,e)=>{let o=!1;if(e&&t){if(Array.isArray(e))o=!e.some(n=>Mt(n,t));else if(!Array.isArray(e)&&e[t.blockchain]){o=e[t.blockchain].tokens.some(r=>Mt(r,t));let n=e[t.blockchain].isExcluded;return!n&&!o||n&&o}}return o},"isTokenExcludedInConfig"),ca=i((t,e)=>t&&e&&!e.includes(t.name),"isBlockchainExcludedInConfig"),Vc=i((t,e,o)=>o==="expanded"&&(t||e)||o==="full-expanded"&&e,"isVariantExpandable");var Sr,xt=i(()=>Sr||(Sr=new ly(Lt("API_KEY"),Lt("BASE_URL")),Sr),"httpService");function Cr(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(c=>c===s.swapperGroup)),l&&s.types.map(c=>{n.push({id:s.swapperGroup,groupTitle:s.swapperGroup,logo:s.logo,type:c,selected:!e.includes(s.swapperGroup)})})}}),n}i(Cr,"getUniqueSwappersGroups");function Kc(t,e){return t.swapperGroup<e.swapperGroup?-1:t.swapperGroup>e.swapperGroup?1:0}i(Kc,"sortLiquiditySourcesByGroupTitle");function Ve(t,e){return e?.[t]==="hidden"}i(Ve,"isFeatureHidden");function Wo(t,e){return e?.[t]==="enabled"}i(Wo,"isRoutingEnabled");var jc=i((t,e,o)=>Ve("customTokens",o)?t:t.concat(e),"addCustomTokensToSupportedTokens");var Xc=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 c=sr({config:a}),p=r;return c.length>0&&(p=p.filter(u=>c.includes(u.name))),p.filter(u=>yc.includes(u.type))}let s=(o.type==="source"?a.from?.blockchains:a.to?.blockchains)??[];return r.filter(c=>!(s.length>0&&!s.includes(c.name)))},tokens:o=>{let{_tokensMapByTokenHash:n,_tokensMapByBlockchainName:r,config:a,_customTokens:s}=e(),l=Array.from(n.values()),c=e()._blockchainsMapByName;if(!o||!o.type)return l;let p=o.type==="source"?"from":"to",u=o.type==="source"?"supportedSourceTokens":"supportedDestinationTokens",d=Eo.get(u);d?.length||(d=sn({type:o.type,config:{blockchains:a[p]?.blockchains,tokens:a[p]?.tokens},meta:{tokensMapByTokenHash:n,tokensMapByBlockchainName:r}}),Eo.set(u,d)),d=jc(d,s,a.features);let h=e().blockchains({type:o.type});return d.filter(f=>o.blockchain&&f.blockchain!==o.blockchain||!h.some(m=>m.name===f.blockchain)?!1:o.searchFor?!!(Je(f.symbol,o.searchFor)||Je(f.address||"",o.searchFor)||Je(f.name||"",o.searchFor)):!0).sort((f,m)=>{let C=e().isTokenPinned(f,o.type),S=e().isTokenPinned(m,o.type);if(C!==S)return C?-1:1;if(o.getBalanceFor){let A=o.getBalanceFor(f),D=o.getBalanceFor(m),w=Dc(A,D);if(w!==0)return w}let k=c.get(f.blockchain),T=c.get(m.blockchain),v=Ri(f,k),b=Ri(m,T);if(v!==b)return v?-1:1;if(f.isPopular!==m.isPopular)return f.isPopular?-1:1;if(o.searchFor){let A=Ac(f,m,o.searchFor);if(A)return A}return f.isSecondaryCoin!==m.isSecondaryCoin?f.isSecondaryCoin?1:-1:k&&T?k.sort-T.sort:0})},findToken:o=>{let n=e()._tokensMapByTokenHash,r=e().customTokens(),a=lt(o),s=n.get(a);return s||(s=r.find(l=>lt(l)===a)),s},isTokenPinned:(o,n)=>!!(n==="source"?e().config.from?.pinnedTokens:e().config.to?.pinnedTokens)?.some(s=>Mt(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(p=>{let u=a?.includes(p.swapperGroup);return s||!a||a.length===0?!u:u}).sort(Kc)},fetch:async()=>{try{let{routing:o}=e().config,n=Wo("enableCentralizedSwappers",o),r=await xt().getAllMetadata({enableCentralizedSwappers:n});t({fetchStatus:"success"});let a=new Map,s=new Map,l={},c=[],p=r.popularTokens,u=r.swappers.filter(g=>g.enabled),d=new Set;r.tokens.forEach(g=>{d.add(g.blockchain),c.push(g)}),r.blockchains.sort((g,f)=>g.sort-f.sort).forEach(g=>{g.enabled&&d.has(g.name)&&a.set(g.name,g)}),c.forEach(g=>{let f=lt(g);l[g.blockchain]||(l[g.blockchain]=[]),s.set(f,g),l[g.blockchain].push(f)}),t({_blockchainsMapByName:a,_tokensMapByTokenHash:s,_tokensMapByBlockchainName:l,_popularTokens:p,_swappers:u})}catch(o){throw t({fetchStatus:"failed"}),o}}}),"createDataSlice");import{Bengali as cy,Catalonia as py,Chinese as Yc,Denmark as uy,English as dy,Finland as my,French as fy,German as gy,Greece as hy,Hungary as yy,India as Sy,Indonesian as Cy,Italian as ky,Japanese as Ty,Korea as vy,Lithuania as wy,Malay as by,Netherlands as xy,Pakistan as Ey,Philippines as Iy,Poland as Ay,Portuguese as Ny,Russian as Wy,SaudiArabia as By,Serbia as My,Slovakia as Ly,SouthAfrica as Py,Spanish as _y,Swahili as Dy,Swedish as $y,Thai as Fy,Turkish as Oy,Ukrainian as Uy,Vietnamese as zy}from"@rango-dev/ui";var Zc=[{title:"Afrikaans",label:"Afrikaans",local:"af",SVGFlag:Py},{title:"Arabic",label:"\u0639\u0631\u0628\u064A",local:"ar",SVGFlag:By},{title:"Bengali",label:"\u09AC\u09BE\u0982\u09B2\u09BE",local:"bn",SVGFlag:cy},{title:"Catalan",label:"Catal\xE0",local:"ca",SVGFlag:py},{title:"Chinese (Simplified)",label:"\u7B80\u4F53\u4E2D\u6587",local:"zh-CN",SVGFlag:Yc},{title:"Chinese (Traditional)",label:"\u4E2D\u6587\uFF08\u7E41\u9AD4)",local:"zh-TW",SVGFlag:Yc},{title:"Danish",label:"Dansk",local:"da",SVGFlag:uy},{title:"Dutch",label:"Nederlands",local:"nl",SVGFlag:xy},{title:"English",label:"English",local:"en",SVGFlag:dy},{title:"Filipino",label:"Filipino",local:"fil",SVGFlag:Iy},{title:"Finnish",label:"Suomalainen",local:"fi",SVGFlag:my},{title:"French",label:"Fran\xE7ais",local:"fr",SVGFlag:fy},{title:"German",label:"Deutsch",local:"de",SVGFlag:gy},{title:"Greek",label:"\u03B5\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AC",local:"el",SVGFlag:hy},{title:"Hindi",label:"\u0939\u093F\u0902\u0926\u0940",local:"hi",SVGFlag:Sy},{title:"Hungarian",label:"Magyar",local:"hu",SVGFlag:yy},{title:"Indonesian",label:"Indonesia",local:"id",SVGFlag:Cy},{title:"Italian",label:"Italiana",local:"it",SVGFlag:ky},{title:"Japanese",label:"\u65E5\u672C\u8A9E",local:"ja",SVGFlag:Ty},{title:"Korean",label:"\uD55C\uAD6D\uC778",local:"ko",SVGFlag:vy},{title:"Lithuanian",label:"Lietuvi\u0173",local:"lt",SVGFlag:wy},{title:"Malay",label:"Melayu",local:"ms",SVGFlag:by},{title:"Polish",label:"Polski",local:"pl",SVGFlag:Ay},{title:"Portuguese",label:"Portugu\xEAs",local:"pt",SVGFlag:Ny},{title:"Russian",label:"\u0420\u0443\u0441\u0441\u043A\u0438\u0439",local:"ru",SVGFlag:Wy},{title:"Serbian",label:"C\u0440\u043F\u0441\u043A\u0438",local:"sr",SVGFlag:My},{title:"Slovak",label:"Slovensk\xFD",local:"sk",SVGFlag:Ly},{title:"Spanish",label:"Espa\xF1ol",local:"es",SVGFlag:_y},{title:"Swahili",label:"Kiswahili",local:"sw",SVGFlag:Dy},{title:"Swedish",label:"Svenska",local:"sv",SVGFlag:$y},{title:"Thai",label:"\u0E41\u0E1A\u0E1A\u0E44\u0E17\u0E22",local:"th",SVGFlag:Fy},{title:"Turkish",label:"T\xFCrk\xE7e",local:"tr",SVGFlag:Oy},{title:"Ukrainian",label:"Y\u043A\u0440\u0430\u0457\u043D\u0456",local:"uk",SVGFlag:Uy},{title:"Urdu",label:"\u0627\u0631\u062F\u0648",local:"ur",SVGFlag:Ey},{title:"Vietnamese",label:"Ti\u1EBFng Vi\u1EC7t",local:"vi",SVGFlag:zy}],Bo="en";var Jc=[.5,1,3],Rc=1,ep=5,tp=100,op=0;var np=i((t,e)=>({disabledLiquiditySources:[],theme:"auto",language:null,preferredBlockchains:[],slippage:Rc,customSlippage:null,infiniteApprove:!1,affiliateRef:null,affiliatePercent:null,affiliateWallets:null,_customTokens:[],addPreferredBlockchain:o=>{let n=e().preferredBlockchains;if(n.find((s,l)=>{let c=s===o,p=l<=9;return c&&p}))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=Ve("theme",n),s=Ve("language",n),l=Ve("liquiditySource",n),c=r?.singleTheme,p=o?.__UNSTABLE_OR_INTERNAL__?.autoUpdateSettings;t({...a&&{theme:o.theme?.mode||"auto"},...c&&{theme:o.theme?.mode||"light"},...s&&{language:o.language||Bo},...l&&{disabledLiquiditySources:o.liquiditySources||[]},...p&&{language:o.language||Bo}})},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=sr({config:o});return r.length?n.filter(a=>r.includes(a.blockchain)):n}}),"createSettingsSlice");import ga from"bignumber.js";import Qy from"mitt";var he=Qy(),Hy={on:he.on,off:he.off};import{WidgetEvents as rp}from"@rango-dev/queue-manager-rango-preset";var ua=(o=>(o.QUOTE_INPUT_UPDATE="quoteInputUpdate",o.QUOTE_OUTPUT_UPDATE="quoteOutputUpdate",o))(ua||{}),da=(o=>(o.CONNECT="connect",o.DISCONNECT="disconnect",o))(da||{}),ma=(e=>(e.CLICK_CONNECT_WALLET="clickConnectWallet",e))(ma||{}),Mo=(a=>(a[a.RouteEvent=rp.RouteEvent]="RouteEvent",a[a.StepEvent=rp.StepEvent]="StepEvent",a.QuoteEvent="quoteEvent",a.WalletEvent="walletEvent",a.UiEvent="uiEvent",a))(Mo||{});import qy from"bignumber.js";function dn(t){return`${t.blockchain}${no}${t.address}${no}${t.symbol}`}i(dn,"createAssetKey");function fa(t,e){return`${dn(e)}${no}${t}`}i(fa,"createBalanceKey");function mn(t){let[e,o,n]=t.split(no);return{address:o==="null"?null:o,blockchain:e,symbol:n}}i(mn,"extractAssetFromBalanceKey");function ip(t,e){let o={};return t.balances?.forEach(n=>{let r=fa(t.address,n.asset),a=n.amount.amount,s=n.amount.decimals,l=e().findToken(n.asset)?.usdPrice,c=l?new qy(l??ce).multipliedBy(a).toString():"",p={amount:a,decimals:s,usdValue:c};o[r]=p}),o}i(ip,"createBalanceStateForNewAccount");function ap(t,e){for(let o in e){let n=mn(o),r=dn(n);t[r]||(t[r]=[]),t[r].includes(o)||(t[r]=[...t[r],o])}return t}i(ap,"updateAggregatedBalanceStateForNewAccount");function sp(t,e){let o=mn(e),n=dn(o);return t[n]&&(t[n]=t[n].filter(r=>r!==e)),t}i(sp,"removeBalanceFromAggregatedBalance");function Gy(t,e){return e.find(o=>t.address===o.address&&t.chain===o.blockChain)}i(Gy,"matchWalletDetailsWithConnectedWallet");var lp=i((t,e)=>({_balances:{},_aggregatedBalances:{},connectedWallets:[],fetchingWallets:!1,setConnectedWalletAsRefetching:o=>{t(n=>({fetchingWallets:!0,connectedWallets:n.connectedWallets.map(r=>r.walletType===o?{...r,loading:!0,error:!1}:r)}))},setConnectedWalletRetrievedData:(o,n)=>{t(r=>({fetchingWallets:!1,connectedWallets:r.connectedWallets.map(a=>a.walletType===o?{...a,loading:!1,error:!1,explorerUrl:Gy(a,n)?.explorerUrl||a.explorerUrl}:a)}))},setConnectedWalletHasError:o=>{t(n=>({fetchingWallets:!1,connectedWallets:n.connectedWallets.map(r=>r.walletType===o?{...r,loading:!1,error:!0}:r)}))},addConnectedWallet:(o,n)=>{let r=e().connectedWallets,a=o.filter(s=>!r.some(l=>Pc(s,l)));if(a.length>0){let s=a.map(l=>{let c=!r.some(p=>p.chain===l.chain&&p.selected&&p.walletType!==l.walletType);return{address:l.address,chain:l.chain,explorerUrl:null,walletType:l.walletType,selected:c,namespace:n,loading:!1,error:!1}});t(l=>({connectedWallets:[...l.connectedWallets.filter(p=>!s.some(u=>u.walletType===p.walletType&&u.chain===p.chain)),...s]}))}},setWalletsAsSelected:o=>{let n=e().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});t({connectedWallets:n})},newWalletConnected:async(o,n)=>{he.emit("walletEvent",{type:"connect",payload:{walletType:o[0].walletType,accounts:o}}),e().addConnectedWallet(o,n),e().fetchBalances(o)},removeBalancesForWallet:(o,n)=>{let r=e().connectedWallets.filter(p=>p.walletType===o);e().connectedWallets.forEach(p=>{p.walletType!==o&&(r=r.filter(u=>!(u.chain===p.chain&&u.address===p.address)))}),n?.chains&&n.chains.length>0&&(r=r.filter(p=>n.chains?.includes(p.chain))),n?.namespaces&&n.namespaces.length>0&&(r=r.filter(p=>p.namespace?n.namespaces?.includes(p.namespace):!1));let a={},s=e()._aggregatedBalances,l=e()._balances;Object.keys(l).forEach(p=>{let u=mn(p);!!r.find(h=>fa(h.address,{address:u.address,blockchain:h.chain,symbol:u.symbol})===p)?s=sp(s,p):a[p]=l[p]}),t({_balances:a,_aggregatedBalances:s})},disconnectNamespaces:(o,n)=>{if(e().connectedWallets.find(a=>a.walletType===o)){e().removeBalancesForWallet(o,{namespaces:n}),e()._changeSelectedWalletIfNeededOnRemove(o,{namespaces:n});let a=e().connectedWallets.filter(s=>s.namespace?!(s.walletType===o&&n.includes(s.namespace)):!0);t({connectedWallets:a})}},disconnectWallet:o=>{let n=e().connectedWallets.find(r=>r.walletType===o);if(he.emit("walletEvent",{type:"disconnect",payload:{walletType:o}}),n){e().removeBalancesForWallet(o),e()._changeSelectedWalletIfNeededOnRemove(o);let r=e().connectedWallets.filter(a=>a.walletType!==o);t({connectedWallets:r})}},_changeSelectedWalletIfNeededOnRemove:(o,n)=>{let r=e().connectedWallets;n?.namespaces&&n.namespaces.length>0&&(r=r.filter(s=>!!s.namespace&&n.namespaces?.includes(s.namespace)));let a=r.filter(s=>s.selected&&s.walletType===o).map(s=>s.chain);if(a.length>0){let s=e().connectedWallets.map(l=>a.includes(l.chain)?(a=a.filter(c=>c!==l.chain),{...l,selected:!0}):l);t({connectedWallets:s})}},clearConnectedWallet:()=>t({connectedWallets:[]}),fetchBalances:async(o,n)=>{let r=o[0].walletType;e().setConnectedWalletAsRefetching(r);let a=o.map(c=>({address:c.address,blockchain:c.chain})),l=(await xt().getWalletsDetails(a)).wallets;if(l){let{retryOnFailedBalances:c=!0}=n||{};if(c){let d=l.filter(h=>h.failed).map(h=>({chain:h.blockChain,walletType:r,address:h.address}));d.length>0&&e().fetchBalances(d,{retryOnFailedBalances:!1})}let p={},u=e()._aggregatedBalances;l.forEach(d=>{if(d.failed||(e().removeBalancesForWallet(r,{chains:[d.blockChain]}),!e().connectedWallets.find(g=>g.walletType===r&&g.address===d.address&&g.chain===d.blockChain)))return;let h=ip(d,e);u=ap(u,h),p={...p,...h}}),t(d=>({_balances:{...d._balances,...p},_aggregatedBalances:u})),e().setConnectedWalletRetrievedData(r,l)}else throw e().setConnectedWalletHasError(r),new Error("We couldn't fetch your account balances. Seem there is no information on blockchain for them yet.")},getBalances:()=>e()._balances,getBalanceFor:o=>{let n=e().getBalances(),r=dn(o),a=e()._aggregatedBalances[r]||[];if(a.length===0)return null;if(a.length===1){let c=a[0];return n[c]}let l=n[a[0]];return a.forEach(c=>{let p=n[c],u=new ga(p.amount),d=new ga(l.amount);u.isGreaterThan(d)&&(l=p)}),l},getBalancesForWalletAddress:o=>{let n=e().getBalances();return Object.keys(n).reduce((s,l)=>{let c=n[l],[,,,p]=l.split(no);return p===o&&(s[l]=c),s},{})},getConnectedWalletsDetails:()=>e().connectedWallets.map(n=>{let r=e().getBalancesForWalletAddress(n.address),a=Object.keys(r);return{...n,balances:a.reduce((s,l)=>{let c=r[l],p=mn(l);if(p.blockchain===n.chain){let u=e().findToken(p),d=c.amount?new ga(c.amount).shiftedBy(-c.decimals):ce;s.push({chain:n.chain,symbol:p.symbol,ticker:p.symbol,address:p.address,rawAmount:c.amount,decimal:c.decimals,amount:d.toString(),logo:u?.image||null,usdPrice:u?.usdPrice||null})}return s},[])}})}),"createWalletsSlice");function cp(t){return Vy()(Ky((...e)=>({...lp(...e),...Xc(...e),...np(...e),...gc(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(cp,"createAppStore");var pp=Xy(null);function y(){let t=Yy(pp);if(Zy(()=>{t&&!t.persist.hasHydrated()&&t.persist.rehydrate()},[]),!t)throw new Error("Missing AppStoreContext.Provider in the tree");return t()}i(y,"useAppStore");function up(t){let e=Jy();return e.current||(e.current=cp(t.config)),jy.createElement(pp.Provider,{value:e.current},t.children)}i(up,"AppStoreProvider");function ft(t){let{chain:e}=t||{},{connectedWallets:o,getAvailableProviders:n}=y(),{state:r,getWalletInfo:a}=Ry(),s=y().blockchains(),{handleDisconnect:l}=Gt(),c=uc(n()),p=Lc(r,a,c,e);p=eS()?p.filter(m=>m.showOnMobile!==!1&&r(m.type).installed):p;let u=$c(p),d=i(m=>!o.find(C=>C.walletType===m&&C.chain===e),"isExperimentalChainNotAdded"),h=oS(()=>{let m=p?.filter(C=>C.state===ha.CONNECTING)||[];for(let C of m)l(C.type)},[Uc(p)]);nS(()=>()=>{h()},[]);let g=i(m=>{let C=m.find(k=>k.type===fn.DEFAULT);return!C||C.state===ha.NOT_INSTALLED?!1:m.filter(k=>k.state!=ha.NOT_INSTALLED&&![fn.DEFAULT,fn.WALLET_CONNECT_2,fn.LEDGER].includes(k.type)&&a(k.type).supportedChains.filter(T=>T.type=="EVM").length>0).length==0},"shouldShowDefaultInjectedWallet"),f=i((m,C,S)=>gr(S,C)&&d(m)&&!tS.includes(m)||m==fn.DEFAULT&&!g(p),"shouldExcludeWallet");return{list:u.filter(m=>!f(m.type,e??"",s)),terminateConnectingWallets:h}}i(ft,"useWalletList");import{Modal as sS}from"@rango-dev/ui";import lS from"react";import{create as aS}from"zustand";var dp="rango-widget";var gn=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(dp),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 iS=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"),Lo=iS;var re=Lo(aS()((t,e)=>({isActiveTab:!1,tabManagerInitiated:!1,showActivateTabModal:!1,watermark:"NONE",showProfileBanner:!1,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})},setShowProfileBanner:o=>{t({showProfileBanner:o})}}))),ao=new gn({onInit:()=>re.setState({tabManagerInitiated:!0}),onClaim:()=>re.setState({isActiveTab:!0,showActivateTabModal:!1}),onRelease:()=>re.setState({isActiveTab:!1})});function Z(t){let{watermark:e}=re();return lS.createElement(sS,{hasWatermark:e==="FULL",...t},t.children)}i(Z,"WatermarkedModal");import{i18n as ya}from"@lingui/core";import{Button as fS,Checkbox as gS,Divider as hS,Image as vp,ListItemButton as yS,MessageBox as SS,Radio as CS,RadioRoot as kS}from"@rango-dev/ui";import we,{useState as TS}from"react";import{css as cS,darkTheme as fp,IconButton as pS,styled as so}from"@rango-dev/ui";var Et=so(pS,{width:"$24",position:"relative",padding:"0",overflow:"unset","&:hover":{backgroundColor:"$secondary100",[`.${fp} &`]:{backgroundColor:"$neutral"}}}),gp=so("div",{position:"absolute",background:"$secondary500",[`.${fp} &`]:{$$color:"$colors$secondary250"},width:"$6",height:"$6",borderRadius:"$lg",right:"$4",border:"1px solid $surface100"}),Vt=so("div",{display:"flex",justifyContent:"flex-end",minWidth:"$40",button:{padding:0}}),hp=so("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"}}}}),yp=so("div",{padding:"$2",variants:{isRefetched:{true:{transform:"rotate(360deg)",transition:"transform 1s ease-in-out"}}}}),Sp=so("div",{position:"absolute",right:"$4",top:"$4",backgroundColor:"$background",borderRadius:"100%"}),Cp=cS({display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center"}),kr=so("div",{borderRadius:"100%",border:"1.5px transparent solid","&:not(:first-child)":{marginLeft:"-$6"},img:{borderRadius:"100%"}});import{keyframes as uS,styled as Tr}from"@rango-dev/ui";var pN=Tr("div",{borderRadius:"$lg",width:"$45",height:"$45",backgroundColor:"$success300",display:"flex",justifyContent:"center",alignItems:"center"}),Po=Tr("div",{position:"relative"}),dS=uS({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}),_o=Tr("div",{position:"absolute",border:"2px solid rgba(0, 0, 0, 0.1)",borderTop:"2px solid $info500",borderRadius:"$lg",width:"$45",height:"$45",animation:`${dS} 1s linear infinite`,top:0,bottom:0,right:0,left:0}),vr=Tr("div",{"& img":{borderRadius:"50%"}});function kp(t,e){return t.find(o=>o.name===e)?.logo}i(kp,"getBlockchainLogo");import{styled as mS}from"@rango-dev/ui";var Tp=mS("ul",{padding:0,paddingTop:"$4",paddingBottom:"$4"});function hn(t){let{targetWallet:e}=t.value,o=e.needsNamespace?.selection==="single",n=e.image,[r,a]=TS([]),s=y().blockchains(),l=i(p=>{a(o?[p]:u=>u.includes(p)?u.filter(d=>d!==p):u.concat(p))},"onSelect"),c=i(p=>o?we.createElement(kS,{value:r?.[0]},p):we.createElement(we.Fragment,null,p),"wrapRadioRoot");return we.createElement(we.Fragment,null,we.createElement(hS,{size:20}),we.createElement(SS,{type:"info",title:ya.t("Select chain types"),description:ya.t("This wallet supports multiple chains. Select which chain you'd like to connect to."),icon:we.createElement(Po,null,we.createElement(kr,null,we.createElement(vp,{src:n,size:45})),we.createElement(_o,null))}),we.createElement(Tp,null,c(we.createElement(we.Fragment,null,e.needsNamespace?.data.map(p=>we.createElement(yS,{key:p.id,id:p.id,title:p.label,hasDivider:!0,style:{height:60},onClick:()=>l(p.value),start:we.createElement(vp,{src:kp(s,p.id),size:22}),end:o?we.createElement(CS,{value:p.value}):we.createElement(gS,{checked:r.includes(p.value)})}))))),we.createElement(fS,{id:"widget-name-space-confirm-btn",type:"primary",disabled:!r.length,onClick:()=>t.onConfirm(r)},ya.t("Confirm")))}i(hn,"Namespaces");import{i18n as Do}from"@lingui/core";import{Button as bS,Divider as xp,Image as xS,MessageBox as ES,Select as IS,TextField as AS}from"@rango-dev/ui";import Oe,{useEffect as NS,useState as Ep}from"react";import{namespaces as vS}from"@rango-dev/wallets-shared";var wr={id:"custom",label:"Custom",generateDerivationPath:t=>t};function Sa(t){let e=t?vS[t].derivationPaths:null;return e?[...e,wr]:[]}i(Sa,"getDerivationPaths");import{styled as wp,Typography as wS}from"@rango-dev/ui";var bp=wp("div",{paddingTop:"$30",paddingBottom:"$30",zIndex:10}),Ca=wp(wS,{paddingLeft:"$10"}),ka={height:"$40",backgroundColor:"$neutral200",borderRadius:"$sm"};var Ip="0";function yn(t){let{onConfirm:e}=t,{namespace:o,providerImage:n,providerType:r}=t.value,[a,s]=Ep(null),[l,c]=Ep(Ip),p=a===wr.id,u=Sa(o),d=i(({value:g})=>{let f=u?.find(m=>m.id===g);f&&(a===wr.id&&Number.isNaN(Number(l))&&c(Ip),s(f.id))},"handleDerivationPathItemClick"),h=i(()=>{let g=u.find(f=>f.id===a);if(g)e(g.generateDerivationPath(l));else throw new Error("selectedDerivationPath can not be undefined")},"handleConfirm");return NS(()=>{s(Sa(o)[0]?.id||null)},[o]),Oe.createElement(Oe.Fragment,null,Oe.createElement(xp,{size:20}),Oe.createElement(ES,{type:"info",title:Do.t("Select Derivation Path"),description:Do.t({id:"In order to connect to {type}, you must first select a Derivation Path",values:{type:r}}),icon:Oe.createElement(Po,null,Oe.createElement(vr,null,Oe.createElement(xS,{src:n,size:45})),Oe.createElement(_o,null))}),Oe.createElement(bp,null,Oe.createElement(Ca,{variant:"body",size:"xsmall",color:"$neutral600"},Do.t("Choose Derivation Path Template")),Oe.createElement(IS,{value:a||"",options:u.map(g=>({value:g.id,label:g.label})),variant:"filled",handleItemClick:d,styles:{trigger:ka}}),Oe.createElement(xp,{size:20}),Oe.createElement(Ca,{variant:"body",size:"xsmall",color:"$neutral600"},p?Do.t("Enter Path"):Do.t("Enter Index")),Oe.createElement(AS,{type:p?"text":"number",variant:"contained",value:l,onChange:g=>c(g.target.value),style:ka})),Oe.createElement(bS,{id:"widget-derivation-path-confirm-btn",type:"primary",onClick:h,disabled:!u||!a||!l},Do.t("Confirm")))}i(yn,"DerivationPath");import{i18n as $o}from"@lingui/core";import{Image as WS,MessageBox as Ta,WalletState as BS}from"@rango-dev/ui";import{useWallets as MS}from"@rango-dev/wallets-react";import lo from"react";function va(t){let{wallet:e,error:o}=t,{type:n,image:r}=e,{state:a}=MS();return pn(a(n))===BS.CONNECTED?lo.createElement(Ta,{type:"success",title:$o.t("Wallet Connected"),description:$o.t("Your wallet is connected, you can use it to swap.")}):o?lo.createElement(Ta,{type:"error",title:$o.t("Failed to Connect"),description:o||$o.t("Your wallet is not connected. Please try again.")}):lo.createElement(Ta,{type:"loading",title:$o.t("Connecting to your wallet"),description:$o.t("Click connect in your wallet popup."),icon:lo.createElement(Po,null,lo.createElement(vr,null,lo.createElement(WS,{src:r,size:45})),lo.createElement(_o,null))})}i(va,"ConnectStatus");import{i18n as wa}from"@lingui/core";import{Button as LS,Divider as Ap,MessageBox as PS}from"@rango-dev/ui";import br from"react";function ba(t){let{displayName:e,onConfirm:o}=t;return br.createElement(PS,{title:wa.t({id:"Add {blockchainDisplayName} Chain",values:{blockchainDisplayName:e}}),type:"warning",description:wa.t({id:"Would you like to add the {blockchainDisplayName} experimental chain to your wallet?",values:{blockchainDisplayName:e}})},br.createElement(Ap,{size:18}),br.createElement(Ap,{size:32}),br.createElement(LS,{id:"widget-experimental-chain-confirm-btn",onClick:o,variant:"outlined",type:"primary",fullWidth:!0,size:"large"},wa.t("Confirm")))}i(ba,"ExperimentalChain");function Np(t,e){return t().status==="init"&&!!e}i(Np,"isOnStatus");function Sn(t){return t().status==="namespace"}i(Sn,"isOnNamespace");function Cn(t){return t().status==="derivationPath"}i(Cn,"isOnDerivationPath");var FS=3e3,OS=300;function po(t){let e=$S(),[o,n]=Wp(!1),[r,a]=Wp(),s=i(k=>{a(k.message)},"catchErrorOnHandle"),{terminateConnectingWallets:l}=ft(),{handleConnect:c,handleDerivationPath:p,handleNamespace:u,getState:d,resetState:h}=Gt(),g=i(k=>{u(t.wallet,k).then(S).catch(s)},"handleConfirmNamespaces"),f=i(k=>{if(!k)throw new Error("Derivation path is empty. Please make sure you've filled the field correctly.");p(k).then(S).catch(s)},"handleDerivationPathConfirm"),m=i(()=>{n(!1)},"handleClosingModal"),C=i(()=>{a(void 0),h(),n(!1),e.current&&clearTimeout(e.current)},"resetModalState"),S=i((k,T)=>{let v=k.status==="connected",b=["disconnected","disconnected-unhandled"].includes(k.status);v?(t.onConnect?.(),T||(e.current=setTimeout(m,FS))):b&&m()},"afterConnected");return DS(()=>{if(t.wallet){C();let k=!1,T=!0;i(()=>{setTimeout(()=>{T=!1,k||n(!0)},OS)},"beforeConnecting")(),c(t.wallet,{disconnectIfConnected:!0}).then(b=>{["namespace","derivation-path"].includes(b.status)||(k=!0),S(b,T)}).catch(s)}},[t.wallet]),co.createElement(Z,{open:o,onClose:m,onExit:()=>{C(),l(),t.onClose&&t.onClose()},container:I()},Np(d,t.wallet)&&co.createElement(co.Fragment,null,co.createElement(va,{wallet:{type:t.wallet.type,image:t.wallet.image},error:r}),co.createElement(_S,{direction:"vertical",size:32})),Sn(d)&&co.createElement(hn,{onConfirm:g,value:d().namespace}),Cn(d)&&co.createElement(yn,{onConfirm:f,value:d().derivationPath}))}i(po,"StatefulConnectModal");import{Provider as qS}from"@rango-dev/wallets-react";import xr,{createContext as GS,useEffect as _p,useMemo as VS,useRef as Dp}from"react";import{useEffect as US}from"react";function Bp(t){return t.map(e=>typeof e=="string"?e:e.config.type).join("-")}i(Bp,"hashProviders");function xa(t,e){let{clearConnectedWallet:o,getAvailableProviders:n,buildAndSetProviders:r}=y(),a=n();return US(()=>{o(),r()},[Bp(t??[]),e?.walletConnectProjectId,e?.walletConnectListedDesktopWalletLink]),{providers:a}}i(xa,"useWalletProviders");import{legacyFormatAddressWithNetwork as zS,legacyReadAccountAddress as Mp}from"@rango-dev/wallets-core/legacy";import{Events as uo}from"@rango-dev/wallets-react";import{isEvmBlockchain as QS}from"rango-sdk";function Lp(t){let{newWalletConnected:e,disconnectWallet:o,disconnectNamespaces:n,connectedWallets:r,removeBalancesForWallet:a,blockchains:s}=y(),{onConnectWalletHandler:l,onDisconnectWalletHandler:c}=t,p=s().filter(QS).map(m=>m.name),u=i((m,C)=>{let[S,,k,,T]=m,v=ia(S,k,p,C.supportedChainNames,T.isContractWallet);v.length&&e(v,T.namespace)},"onAccountsEvent"),d=i((m,C,S,k,T)=>{if(C===uo.ACCOUNTS){let v=un(T.supportedBlockchains);S&&u([m,C,S,k,T],{supportedChainNames:v})}if(C===uo.CONNECTED){let v=`${m}-${k.network}-${S}`;l.current?l.current(v):console.warn("onConnectWallet handler hasn't been set. Are you sure?")}C===uo.PROVIDER_DISCONNECTED&&(o(m),c.current?c.current(m):console.warn("onDisconnectWallet handler hasn't been set. Are you sure?")),C===uo.NAMESPACE_DISCONNECTED&&n(m,S)},"handleUpdatesForHub"),h=i((m,C,S,k,T)=>{if(C===uo.ACCOUNTS){let v=un(T.supportedBlockchains),b=[],A=[];if(S?.forEach(w=>{let{network:x}=Mp(w);p.includes(x)?b.push(w):A.push(w)}),r.filter(w=>w.walletType===m).map(w=>zS(w.address,w.chain)).length>0){if(b.length>0){let w=ia(m,b,p,v,T.isContractWallet);a(m,{chains:w.map(x=>x.chain)})}A.length>0&&a(m,{chains:A.map(w=>{let{network:x}=Mp(w);return x})})}S?u([m,C,S,k,T],{supportedChainNames:v}):(o(m),c.current?c.current(m):console.warn("onDisconnectWallet handler hasn't been set. Are you sure?"))}if(C===uo.ACCOUNTS&&k.connected){let v=`${m}-${k.network}-${S}`;l.current?l.current(v):console.warn("onConnectWallet handler hasn't been set. Are you sure?")}},"handleUpdatesForLegacy"),g=i((m,C,S,k,T)=>{if(C===uo.NETWORK&&k.network){let v=`${m}-${k.network}`;l.current?l.current(v):console.warn("onConnectWallet handler hasn't been set. Are you sure?")}},"handleUpdatesForBoth");return{handler:i((m,C,S,k,T)=>{T.isHub?d(m,C,S,k,T):h(m,C,S,k,T),g(m,C,S,k,T)},"handler")}}i(Lp,"useUpdates");import{LegacyEvents as HS}from"@rango-dev/wallets-core/legacy";function Pp(t,e){let[o,n,r,a,s]=e;n!==HS.PROVIDER_DISCONNECTED&&t(o,n,r,a,s)}i(Pp,"propagateEvents");var Er=GS({onConnectWallet:()=>{},onDisconnectWallet:()=>{}});function KS(t){let{updateConfig:e,updateSettings:o,fetch:n,fetchStatus:r}=y(),a=y().blockchains(),s=y().config,l={walletConnectProjectId:s?.walletConnectProjectId,trezorManifest:s?.trezorManifest,tonConnect:s.tonConnect,walletConnectListedDesktopWalletLink:t.config.__UNSTABLE_OR_INTERNAL__?.walletConnectListedDesktopWalletLink},{providers:c}=xa(s.wallets,l),p=Dp(),u=Dp(),{handler:d}=Lp({onConnectWalletHandler:p,onDisconnectWalletHandler:u});_p(()=>{n().catch(console.log)},[]),_p(()=>{t.config&&(e(t.config),o(t.config),window.__rango={config:s,dappConfig:t.config})},[t.config,r]);let h=re.use.isActiveTab(),g=VS(()=>({onConnectWallet:f=>{p.current=f},onDisconnectWallet:f=>{u.current=f}}),[]);return xr.createElement(Er.Provider,{value:g},xr.createElement(qS,{allBlockChains:a,providers:c,onUpdateState:(f,m,C,S,k)=>{let T=[f,m,C,S,k];d(...T),t.onUpdateState&&Pp(t.onUpdateState,T)},autoConnect:!!h,configs:{wallets:s.wallets}},t.children))}i(KS,"Main");function Ir(t){let{config:e,...o}=t;return xr.createElement(up,{config:e},xr.createElement(KS,{...o,config:e}))}i(Ir,"WidgetWallets");import Yi from"react";import jS,{Fragment as XS}from"react";import{MemoryRouter as YS,useInRouterContext as ZS}from"react-router";function $p({children:t}){let o=ZS()?XS:YS;return jS.createElement(o,null,t)}i($p,"AppRouter");import{I18nManager as ME}from"@rango-dev/ui";import Rl from"react";import _e from"react";import{useRoutes as SE}from"react-router-dom";var $={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 Dr}from"react";import Ke from"bignumber.js";import{create as eC}from"zustand";import{subscribeWithSelector as tC}from"zustand/middleware";import{i18n as gt}from"@lingui/core";import{RouteEventType as xB}from"@rango-dev/queue-manager-rango-preset";import Ue from"bignumber.js";import{PendingSwapNetworkStatus as Pr}from"rango-types";import{i18n as $e}from"@lingui/core";var R=i(()=>({genericServerError:$e.t("Failed Network, Please retry your swap."),liquiditySourcesError:{title:$e.t("Please reset your liquidity sources."),description:$e.t("You have limited the liquidity sources and this might result in Rango finding no routes. Please consider resetting your liquidity sources.")},noResultError:{title:$e.t("No Routes Found."),description:$e.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:$e.t("Bridge Limit Error: Please increase your amount."),decreaseAmount:$e.t("Bridge Limit Error: Please decrease your amount.")},highValueLossError:{impactTitle:$e.t("High Price Impact"),title:$e.t("Price impact is too high!"),description:$e.t("The price impact is significantly higher than the allowed amount."),confirmMessage:$e.t("Confirm high price impact")},quoteUpdatedWithHighValueLoss:{title:$e.t("Route updated and price impact is too high, try again later!")},unknownPriceError:{impactTitle:$e.t("USD Price Unknown"),title:$e.t("USD Price Unknown, Cannot calculate Price Impact."),description:$e.t("USD Price Unknown, Cannot calculate Price Impact. The price impact may be higher than usual. Are you sure to continue the Swap?"),confirmMessage:$e.t("Confirm USD Price Unknown")}}),"errorMessages");function Fp(t){switch(t.type){case 0:return t.diagnosisMessage??R().noResultError.title;case 1:return R().genericServerError;default:return""}}i(Fp,"getQuoteErrorMessage");import{i18n as Ar}from"@lingui/core";var mo=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 Ea(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(Ea,"getFeeLabel");var Ia=["RECOMMENDED","CENTRALIZED","LOWEST_FEE","FASTEST","HIGH_IMPACT"],Op=100,Up=30,zp=15,Qp=60;var Hp=[{threshold:-10,minInput:400},{threshold:-5,minInput:1e3}],qp=[{threshold:-1,minInput:1e3},{threshold:-2,minInput:500}];import{getLastSuccessfulStep as RS}from"@rango-dev/queue-manager-rango-preset";import uB from"bignumber.js";function Vp(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(Vp,"getRequiredBalanceOfWallet");function _t(t){let e;return t<=-3&&t>-10?e="low":t<=-10&&(e="high"),e}i(_t,"getPriceImpactLevel");function Wr(t,e,o){let n=t.steps[0],r=t.steps[t.steps.length-1],a=RS(t.steps),s={blockchain:r.toBlockchain,symbol:r.toSymbol,address:r.toSymbolAddress},l=an(a?a.toBlockchain:n.fromBlockchain,e),c=an(r.toBlockchain,e),p=o(a?{blockchain:l?.name??"",symbol:a.toSymbol,address:a.toSymbolAddress}:{blockchain:l?.name??"",symbol:n.fromSymbol,address:n.fromSymbolAddress}),u=o(s),d=a?a.outputAmount??"":t.inputAmount;return{fromBlockchain:l,fromToken:p,toBlockchain:c,toToken:u,inputAmount:d}}i(Wr,"createRetryQuote");function Fo(t){let{previousQuote:e,currentQuote:o,findToken:n,userSlippage:r}=t,a=kn(o),s=ct(o);if(o&&a&&s){let p=Pt(a.toString(),s.toString());if(!!p&&Zp(a,p)){let d=Mr(o?.swaps,n),h=_t(p);return{type:0,inputUsdValue:a,outputUsdValue:s,priceImpact:p,totalFee:d,warningLevel:h}}}if(e&&eu(e,o))return{type:4,usdValueChange:B(ct(o)?.minus(ct(e)??0).toString()??"0",null,2),percentageChange:B(Pt(ct(e)??"1",ct(o)??"1"),null,2)};if(o&&(!a||!s))return{type:1};let l=Lr(o.swaps),c=r>ep;if(Rp(t.userSlippage.toString(),l)){if(c&&parseFloat(l??"0")<r)return{type:3,slippage:r.toString()}}else return{type:2,recommendedSlippages:Jp(o,r),minRequiredSlippage:l};return null}i(Fo,"generateQuoteWarnings");function Kp(t){return![4].includes(t.type)}i(Kp,"isQuoteWarningConfirmationRequired");function Pt(t,e){let o=typeof e=="string"?parseFloat(e)<=0:!e?.gt(0),n=!t||!e||o?null:Aa(t.toString(),e.toString());return n&&n<0?n:null}i(Pt,"getPriceImpact");var jp=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"),Br=i((t,e)=>e.sort((o,n)=>{let r=i(p=>p.scores?.find(u=>u.preferenceType===t)?.score??0,"getScore"),a=r(o),s=r(n);if(a!==s)return s-a;let l=o.requestId.toLowerCase(),c=n.requestId.toLowerCase();return l.localeCompare(c)}),"sortQuotesBy"),Xp=i((t,e,o)=>{if(!e.length)return null;if(!t)return{requestAmount:o,validationStatus:null,...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,validationStatus:null,...r||e[0]}},"getDefaultQuote"),Yp=i(t=>{let e=i((o,n)=>{let r=Ia.indexOf(o.value),a=Ia.indexOf(n.value);return r!==-1&&a!==-1?r-a:r!==-1?-1:a!==-1?1:0},"customSort");return t.sort(e)},"sortTags");function Zp(t,e){if(!t)return!1;let o=parseInt(e.toFixed(2)||"0");return Hp.some(({threshold:n,minInput:r})=>o<=n&&t.gte(new Ue(r)))}i(Zp,"hasHighValueLoss");function tu(t){return(t||[]).filter(e=>{let o=e.fromAmountMinValue?new Ue(e.fromAmountMinValue):null,n=e.fromAmountMaxValue?new Ue(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(tu,"hasLimitError");function ou(t){let e=(t||[]).filter(l=>{let c=l.fromAmountMinValue?new Ue(l.fromAmountMinValue):null,p=l.fromAmountMaxValue?new Ue(l.fromAmountMaxValue):null;return l.fromAmountRestrictionType==="EXCLUSIVE"?c?.gte(l.fromAmount)||p?.lte(l.fromAmount):c?.gt(l.fromAmount)||p?.lt(l.fromAmount)})[0],o=e.fromAmountMinValue?new Ue(e.fromAmountMinValue):null,n=e.fromAmountMaxValue?new Ue(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=R().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=R().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=R().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=R().bridgeLimitErrors.decreaseAmount),{swap:e,fromAmountRangeError:a,recommendation:s}}i(ou,"getLimitErrorMessage");function nu(t){let{fetchMetaStatus:e,anyWalletConnected:o,fetchingQuote:n,inputAmount:r,quote:a,warning:s,error:l,needsToWarnEthOnPath:c}=t;return e!=="success"?{title:mo().connectWallet,action:"connect-wallet",disabled:!0}:o?n||!a||l||!r||r==="0"?{title:mo().swap,action:"confirm-swap",disabled:!0}:s?{title:mo().swapAnyway,action:"confirm-warning",disabled:!1}:c?{title:mo().ethWarning,action:"confirm-warning",disabled:!1}:{title:mo().swap,action:"confirm-swap",disabled:!1}:{title:mo().connectWallet,action:"connect-wallet",disabled:!1}}i(nu,"getSwapButtonState");function Na(t,e,o){let n=parseFloat(e||"0");return!(t&&(!o||o.lte(ce))&&e&&e!=="0"&&n!==0)}i(Na,"canComputePriceImpact");function Wa(t,e){let o=ce;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 Ue(r.amount).multipliedBy(a||0))}return o}i(Wa,"getUsdFeeOfStep");function Mr(t,e){return t.reduce((o,n)=>o.plus(Wa(n,e)),ce)}i(Mr,"getTotalFeeInUsd");function Ba(t){let e=ce;return e=e.plus(new Ue(t.amount).multipliedBy(t.price||0)),e}i(Ba,"getUsdFee");function ru(t){return t.reduce((e,o)=>e.plus(Ba(o)),ce)}i(ru,"getTotalFeesInUsd");function iu(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(iu,"getFeesGroup");function au(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(au,"checkSlippageErrors");function Jp(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(Jp,"checkSlippageWarnings");function Lr(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(Lr,"getMinRequiredSlippage");function Rp(t,e){return e?parseFloat(t)>=parseFloat(e):!0}i(Rp,"hasProperSlippage");function su(t){let{fromToken:e,toToken:o,inputAmount:n,wallets:r,selectedWallets:a,disabledLiquiditySources:s,liquiditySources:l,excludeLiquiditySources:c,slippage:p,affiliateRef:u,affiliatePercent:d,affiliateWallets:h,destination:g}=t,f=a?.reduce((S,k)=>(S[k.chain]=k.address,S),{}),m=[];return r?.forEach(S=>{m.push({blockchain:S.chain,addresses:[S.address]})}),{amount:n.toString(),affiliateRef:u??void 0,affiliatePercent:d??void 0,affiliateWallets:h??void 0,from:{address:e.address,blockchain:e.blockchain,symbol:e.symbol},to:{address:o.address,blockchain:o.blockchain,symbol:o.symbol},connectedWallets:m,selectedWallets:f??{},slippage:p.toString(),...g&&{destination:g},...c&&{swapperGroups:s.concat(l??[]),swappersGroupsExclude:!0},...!c&&{swapperGroups:l?.filter(S=>!s.includes(S)),swappersGroupsExclude:!1}}}i(su,"createQuoteRequestBody");function lu(t){return t.reduce((o,n)=>(o[n.chain]={address:n.address,walletType:n.walletType},o),{})}i(lu,"getWalletsForNewSwap");function kn(t){let e=t.requestAmount,o=t.swaps[0].from.usdPrice;if(!(!e||!o))return new Ue(e).multipliedBy(o)}i(kn,"getUsdInputFrom");function ct(t){let e=t?.outputAmount||null,o=t.swaps[t.swaps.length-1].to.usdPrice;if(!(!e||!o))return new Ue(e).multipliedBy(o)}i(ct,"getUsdOutputFrom");function Aa(t,e){return new Ue(e).div(new Ue(t)).minus(1).multipliedBy(Op).toNumber()}i(Aa,"getPercentageChange");function eu(t,e){let o=kn(t),n=ct(t),r=ct(e);if(!o||!n||!r)return!1;let a=Aa(n.toString(),r.toString());return qp.some(({threshold:s,minInput:l})=>a<=s&&o.isGreaterThanOrEqualTo(l))}i(eu,"isOutputAmountChangedExcessively");function cu(t,e,o){let n=t.validationStatus,r=io({filter:"required",quote:t});return e.sort((s,l)=>r.indexOf(s.chain)-r.indexOf(l.chain)).flatMap(s=>Vp(s,n)||[]).filter(s=>!s.ok).map(s=>{let l=s.asset.symbol,c=B(new Ue(s.currentAmount.amount).shiftedBy(-s.currentAmount.decimals),8,8),p=B(new Ue(s.requiredAmount.amount).shiftedBy(-s.requiredAmount.decimals),8,8),u="";return s.reason==="FEE"&&(u=gt.t(" for network fee")),s.reason==="INPUT_ASSET"&&(u=gt.t(" for swap")),s.reason==="FEE_AND_INPUT_ASSET"&&(u=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:p,symbol:l,reason:u,currentAmount:c,blockchain:st(s.asset.blockchain,o)}})})}i(cu,"generateBalanceWarnings");function Tn(t){return!!t&&t.networkStatus!==null&&t.networkStatus!==Pr.NetworkChanged}i(Tn,"isNetworkStatusInWarningState");function pu(t,e){let o="bellow button or",n=t.extraMessage,r=t.extraMessageDetail;if(t.networkStatusExtraMessageDetail?.includes(o)&&(t.networkStatusExtraMessageDetail=t.networkStatusExtraMessageDetail.replace(o,"")),Tn(e))switch(n=t.networkStatusExtraMessage||"",r=t.networkStatusExtraMessageDetail||"",e?.networkStatus){case Pr.WaitingForConnectingWallet:n=n||gt.t("Waiting for connecting wallet");break;case Pr.WaitingForQueue:n=n||gt.t("Waiting for other running tasks to be finished");break;case Pr.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(pu,"getSwapMessages");function uu(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(uu,"getLastConvertedTokenInFailedSwap");function du(t){return t.status==="failed"}i(du,"shouldRetrySwap");function mu(t,e,o,n,r,a){if(!n||t)return!0;let s=io({filter:"all",quote:n}),l=io({filter:"required",quote:n}),c=s.every(d=>r.some(h=>h.chain===d)),p=l.every(d=>r.some(h=>h.chain===d)),u=o&&a?Io(a,o):!1;return!e&&!c||e&&!o||e&&!!o&&(!u||!p)}i(mu,"isConfirmSwapDisabled");function fu(t,e){return t.blockchain===e.blockchain&&t.symbol===e.symbol&&t.address===e.address}i(fu,"isTokensIdentical");var _r=i((t,e)=>t?.usdPrice?new Ke(e||ce).multipliedBy(t?.usdPrice||0):null,"getUsdValue"),O=Lo(eC()(tC(t=>({fromBlockchain:null,fromToken:null,inputAmount:"",outputAmount:null,inputUsdValue:new Ke(0),outputUsdValue:new Ke(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=ce,a=o.inputUsdValue;return cn(o.inputAmount)?(e&&(n=e?.outputAmount?new Ke(e?.outputAmount):null,a=kn(e)??ce,r=ct(e)??ce),{selectedQuote:e,...!!e&&{outputAmount:n,outputUsdValue:r,inputUsdValue:a}}):{}}),resetAlerts:()=>t(()=>({error:null,warning:null})),resetQuote:()=>t(()=>({selectedQuote:null,outputAmount:null,outputUsdValue:new Ke(0),quotes:null,refetchQuote:!0,error:null,warning:null})),setFromBlockchain:e=>{t(o=>o.fromBlockchain?.name===e?.name?{}:{fromBlockchain:e,inputUsdValue:new Ke(0),...o.fromToken&&{selectedQuote:null,fromToken:null,outputAmount:null,outputUsdValue:new Ke(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:_r(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 Ke(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 Ke(0),selectedQuote:null},...!!o.fromToken&&{inputUsdValue:_r(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:_r(n??null,s),outputUsdValue:new Ke(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?_r(e.toToken,e.outputAmount?.toString()||""):new Ke(0)})),resetFromBlockchain:()=>t(()=>({fromToken:null,fromBlockchain:null,outputUsdValue:new Ke(0),inputUsdValue:new Ke(0),inputAmount:"",outputAmount:null,selectedQuote:null})),resetToBlockchain:()=>t(()=>({toToken:null,toBlockchain:null,outputAmount:null,outputUsdValue:new Ke(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})})))),gu=O.subscribe((t,e)=>{(t.fromBlockchain!==e.fromBlockchain||t.fromToken!==e.fromToken||t.toBlockchain!==e.toBlockchain||t.toToken!==e.toToken||t.inputAmount!==e.inputAmount)&&he.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&&he.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 hu(){let{setInputAmount:t,setToToken:e,setToBlockchain:o,setFromBlockchain:n,resetQuote:r,setFromToken:a,fromToken:s,toToken:l,fromBlockchain:c,toBlockchain:p}=O(),u=y().config,d=y().fetchStatus,h=y().blockchains(),g=y().tokens(),{findToken:f}=y(),{setAffiliateRef:m,setAffiliatePercent:C,setAffiliateWallets:S}=y(),k=u?.from?.tokens,T=u?.from?.blockchains,v=u?.to?.tokens,b=u?.to?.blockchains,A=Dr(void 0),D=Dr(void 0),w=Dr(void 0),x=Dr(void 0);Oo(()=>{typeof u.amount<"u"&&t(u.amount.toString())},[u?.amount]),Oo(()=>{if(d==="success"){r();let E=h.find(W=>W.name===u?.from?.blockchain),N=u?.from?.token,M=N&&f(N);(E||!E&&w.current)&&n(E??null),M?a({token:M,meta:{blockchains:h,tokens:g}}):!M&&A.current&&a({token:null}),w.current=u?.from?.blockchain,A.current=u?.from?.token}},[u?.from?.token?.symbol,u?.from?.token?.address,u?.from?.token?.blockchain,u?.from?.blockchain,d]),Oo(()=>{la(s,k)&&a({token:null}),ca(c,T)&&n(null)},[k,T]),Oo(()=>{la(l,v)&&a({token:null}),ca(p,b)&&o(null)},[v,b]),Oo(()=>{if(d==="success"){r();let E=h.find(W=>W.name===u?.to?.blockchain),N=u?.to?.token,M=N&&f(N);(E||!E&&x.current)&&o(E??null),M?e({token:M,meta:{blockchains:h,tokens:g}}):!M&&D.current&&e({token:null}),x.current=u?.to?.blockchain,D.current=u?.to?.token}},[u?.to?.token?.symbol,u?.to?.token?.address,u?.to?.token?.blockchain,u?.to?.blockchain,d]),Oo(()=>{m(u?.affiliate?.ref??null),C(u?.affiliate?.percent??null),S(u?.affiliate?.wallets??null)},[u?.affiliate?.ref,u?.affiliate?.percent,u?.affiliate?.wallets])}i(hu,"useSyncStoresWithConfig");import{useEffect as Pa,useRef as oC}from"react";import{useInRouterContext as nC,useLocation as rC,useSearchParams as iC}from"react-router-dom";function Ma(t,e){let o=t.split("--");return{blockchain:e.name,address:o?.[1]||null,symbol:o[0]}}i(Ma,"convertTokenSearchParamToAsset");function La(t){if(t)return`${t.symbol}${t.address?`--${t.address}`:""}`}i(La,"tokenToSearchParam");function Da(){let t=rC(),[e,o]=iC(),{fromBlockchain:n,toBlockchain:r,fromToken:a,toToken:s,inputAmount:l,setFromBlockchain:c,setToBlockchain:p,setFromToken:u,setToToken:d,setInputAmount:h}=O(),g=y().fetchStatus,f=y().blockchains(),m=y().tokens(),C=nC(),{updateIframe:S,updateCampaignMode:k}=y(),T=y().isInCampaignMode(),v=oC(),{findToken:b}=y(),A=i(()=>{let w={};for(let[X,se]of e.entries())X.startsWith("utm_")&&(w[X]=se);let x=e.get("fromAmount"),E=e.get("fromBlockchain"),N=e.get("fromToken"),M=e.get("toBlockchain"),W=e.get("toToken"),j=e.get("autoConnect"),te=e.get("clientUrl"),J=e.get("liquiditySources"),L=e.get("blockchain");return{fromAmount:x,fromBlockchain:E,fromToken:N,toBlockchain:M,toToken:W,autoConnect:j,clientUrl:te,liquiditySources:J,utmQueryParams:w,blockchain:L}},"getUrlSearchParams"),D=i(w=>{for(let x in w)w[x]||delete w[x];o(w,{replace:!0})},"updateUrlSearchParams");Pa(()=>{let{autoConnect:w,clientUrl:x,utmQueryParams:E,blockchain:N}=A();C&&g==="success"&&D({fromBlockchain:n?.name,fromToken:La(a),toBlockchain:r?.name,toToken:La(s),fromAmount:l,autoConnect:w??void 0,clientUrl:x??void 0,blockchain:N??void 0,liquiditySources:T?v.current:void 0,...E})},[t.pathname,l,n,a,r,s,T]),Pa(()=>{if(!C)return;let w=A();if(!v.current&&w.liquiditySources&&(v.current=w.liquiditySources),w.fromAmount&&h(w.fromAmount),g==="success"){let x=f.find(W=>W.name===w.fromBlockchain),E=w.fromToken&&x?b(Ma(w.fromToken,x)):void 0,N=f.find(W=>W.name===w.toBlockchain),M=w.toToken&&N?b(Ma(w.toToken,N)):void 0;x&&(c(x),E&&u({token:E,meta:{blockchains:f,tokens:m}})),N&&(p(N),M&&d({token:M,meta:{blockchains:f,tokens:m}}))}},[g]),Pa(()=>{let{clientUrl:w,liquiditySources:x}=A();S("clientUrl",w||void 0),k("liquiditySources",x?.split(",")??void 0)},[])}i(Da,"useSyncUrlAndStore");import{i18n as It}from"@lingui/core";import{Alert as Ck,Button as Yu,darkTheme as kk,Divider as bn,DoneIcon as Tk,MessageBox as vk,styled as wk,TextField as bk,Typography as xk}from"@rango-dev/ui";import ye,{useEffect as Ek,useState as Hr}from"react";import{useNavigate as Ik,useSearchParams as Ak}from"react-router-dom";import{ChevronRightIcon as aC,Divider as Tu,Image as sC,Typography as vu}from"@rango-dev/ui";import ht from"react";import{darkTheme as yu,styled as $a}from"@rango-dev/ui";var Su=$a("div",{display:"flex",justifyContent:"space-between",width:"100%",height:"$40",padding:"$4 $10",borderRadius:"$sm",cursor:"pointer",alignItems:"center",backgroundColor:"$neutral300",[`.${yu} &`]:{backgroundColor:"$neutral400"},"&:hover":{backgroundColor:"$secondary100",[`.${yu} &`]:{backgroundColor:"$neutral500"}},variants:{disabled:{true:{cursor:"default","&:hover":{borderColor:"$neutral300","& svg":{color:"$neutral700"}}}}}}),Cu=$a("div",{display:"flex",flexDirection:"column",width:"100%",".title_typography":{textTransform:"capitalize"}}),ku=$a("div",{display:"flex"});function Fa(t){let{onClick:e,value:o,title:n,hasLogo:r,placeholder:a,disabled:s}=t;return ht.createElement(Cu,null,ht.createElement(vu,{size:"large",variant:"label"},n),ht.createElement(Tu,{size:10}),ht.createElement(Su,{onClick:s?void 0:e,disabled:s},ht.createElement(ku,null,r&&ht.createElement(ht.Fragment,null,ht.createElement(sC,{src:o?.logo,size:16,useAsPlaceholder:!o?.logo,type:"circular"}),ht.createElement(Tu,{size:4,direction:"horizontal"})),ht.createElement(vu,{className:"title_typography",size:"medium",variant:"label"},o?.name||a)),ht.createElement(aC,{size:12,color:"black"})))}i(Fa,"BlockchainSelectorButton");import{i18n as Ua}from"@lingui/core";import{Button as lC,Divider as vn,ExternalLinkIcon as cC,Image as pC,Typography as zo}from"@rango-dev/ui";import Ne from"react";function wu(t,e){if(e.type==="COSMOS")return"";let o=e.info?.addressUrl;return!o||!t?"":o.replace("{wallet}",t)}i(wu,"generateExplorerLink");import{darkTheme as Uo,styled as bu}from"@rango-dev/ui";var Oa=bu("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:{}}}}),xu=bu("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 za(t){let{open:e,onClose:o,token:n,onSubmitClick:r,blockchain:a}=t,s=wu(n.address,a);return Ne.createElement(Z,{open:e,dismissible:!0,onClose:o,container:I()},Ne.createElement(xu,null,Ne.createElement(pC,{src:n.image,size:45,type:"circular"}),Ne.createElement(zo,{variant:"title",size:"medium"},n.name),Ne.createElement(zo,{variant:"body",size:"small",className:"_blockchain-name"},a.displayName),Ne.createElement(vn,{size:4}),Ne.createElement(zo,{variant:"body",size:"medium"},s?Ne.createElement(Oa,{hasHover:!0,href:s,target:"_blank",rel:"nofollow noreferrer"},n.address,Ne.createElement(cC,{size:12,color:"gray"})):Ne.createElement(Oa,null,n.address)),Ne.createElement(vn,{size:4}),n.coinSource&&Ne.createElement(zo,{className:"_coin-source",variant:"body",size:"xsmall"},Ua.t("via")," ",Ne.createElement(zo,{className:"_coin-source-name",variant:"body",size:"xsmall"},n.coinSource)),Ne.createElement(vn,{size:"32"}),Ne.createElement(zo,{size:"medium",variant:"body",className:"_custom-token-description"},Ua.t("This token doesn't appear on the active token list(s). Make sure this is the token that you want to trade."))),Ne.createElement(vn,{size:40}),Ne.createElement(vn,{size:10}),Ne.createElement(lC,{id:"widget-custom-token-modal-import-btn",variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:r},Ua.t("Import")))}i(za,"CustomTokenModal");import{useManager as mk}from"@rango-dev/queue-manager-react";import{BottomLogo as fk,Divider as Gu,Header as gk}from"@rango-dev/ui";import Be,{useEffect as cs,useRef as Vu,useState as hk}from"react";import{useRef as uC}from"react";function $r(){return window.self!==window.top}i($r,"isAppLoadedIntoIframe");function Qa(){let t=uC(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 c of l)n({type:"widget_height",data:{height:c.contentRect.height}})}),t.current.observe(s)},"connectHeightObserver"),disconnectHeightObserver:i(()=>{t.current&&(t.current.disconnect(),t.current=null)},"disconnectHeightObserver")}}i(Qa,"useIframe");import{useNavigate as dC}from"react-router-dom";function je(){let t=dC();return()=>t(-1)}i(je,"useNavigateBack");import{createTheme as Xa,darkTheme as EC,lightTheme as IC}from"@rango-dev/ui";import{useEffect as AC,useState as NC}from"react";import{theme as bC,darkColors as xC}from"@rango-dev/ui";import Ka from"react";function mC(t){return t.startsWith("#")&&(t=t.slice(1)),t.length===3?`#${t.split("").reduce(function(n,r){return n+r+r},"")}`:`#${t}`}i(mC,"expandShortHexColor");function fC(t){return/[0-9]+$/.test(t)}i(fC,"isOverridingColor");function gC(t,e){return t.padStart(e,"0")}i(gC,"pad");function Ha(t){let e=Math.min(Math.max(Math.round(t),0),255);return gC(e.toString(16),2)}i(Ha,"intToHex");function hC(t){return`#${Ha(t.red)}${Ha(t.green)}${Ha(t.blue)}`}i(hC,"rgbToHex");function yC(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(yC,"hexToRGB");function SC(t,e){let o=1-.11*e;return{red:t.red*o,green:t.green*o,blue:t.blue*o}}i(SC,"generateShade");function CC(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(CC,"generateTint");function kC(t){return Eu(t,SC)}i(kC,"calculateShades");function TC(t){return Eu(t,CC)}i(TC,"calculateTints");function Eu(t,e){let o=yC(t),n=[];for(let r=1;r<9;r++)n.push(hC(e(o,r)));return n}i(Eu,"calculateColors");function qa(t,e,o){let a=TC(t).reverse().concat(t),s=kC(t),l=a.concat(s),c={},p=l.length;for(let u=0;u<p;u++){let d=100+(o?p-1-u:u)*50;c[`${e}${d}`]=l[u]}return c}i(qa,"createTintsAndShades");function Ga(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)&&!fC(r)){let c=mC(a);Object.assign(n,qa(c,r,s))}}return{...n,...e}}i(Ga,"expandToGenerateThemeColors");var Iu=i(t=>String.fromCharCode(t+(t>25?39:97)),"toAlphabeticChar"),vC=i(t=>{let e="",o;for(o=Math.abs(t);o>52;o=o/52|0)e=Iu(o%52)+e;return Iu(o%52)+e},"toAlphabeticName"),wC=i((t,e)=>{let o=e.length;for(;o;)t=t*33^e.charCodeAt(--o);return t},"toPhash"),Va=i(t=>vC(wC(5381,JSON.stringify(t))>>>0),"toHash");function ja(t){let e=bC.colors,o={...e,...xC},n,r;if(t?.light){let s={colors:Ga(e,t.light)};n={id:`${sa}-light-${Va(s)}`,tokens:s}}if(t?.dark){let s={colors:Ga(o,t.dark,{reverseNeutralRange:!0})};r={id:`${sa}-dark-${Va(s)}`,tokens:s}}return{light:n,dark:r}}i(ja,"customizedThemeTokens");function Au(t,e){if(t.length<=1)return t.map(({element:n,key:r})=>Ka.cloneElement(n,{key:r}));let o=[];return t.forEach((n,r)=>{let{element:a,key:s}=n;if(o.push(Ka.cloneElement(a,{key:s})),r<t.length-1){let l=`divider-${r}`;o.push(Ka.cloneElement(e,{key:l}))}}),o}i(Au,"joinList");function Nu(){return window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches}i(Nu,"doesWindowPreferDarkColorScheme");function Qo(t){let{colors:e,fontFamily:o=Tc,borderRadius:n=qc,secondaryBorderRadius:r=Gc}=t,[a,s]=NC(Nu()?"dark":"light"),{theme:l}=y(),{dark:c,light:p}=ja(e),u=Xa({shadows:t.shadows||{},radii:{primary:`${n}px`,secondary:`${r}px`},fonts:{widget:o}}),d=[u.className,IC.className],h=[u.className,EC.className];if(p){let f=Xa(p.id,p.tokens);d.push(f.className)}if(c){let f=Xa(c.id,c.tokens);h.push(f.className)}return AC(()=>{let f=i(m=>{m.matches?s("dark"):s("light")},"switchThemeListener");return Nu()&&s("dark"),window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",f),()=>{window.matchMedia("(prefers-color-scheme: dark)").removeEventListener("change",f)}},[]),{activeTheme:i(()=>{let f=d.join(" "),m=h.join(" ");return l==="auto"?a==="dark"?m:f:l==="dark"?m:f},"getActiveTheme"),mode:l==="auto"?a:l}}i(Qo,"useTheme");var pt=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 Wu}from"@lingui/core";import{Alert as WC,Button as BC}from"@rango-dev/ui";import Bu from"react";function Ya(t){return Bu.createElement(WC,{action:Bu.createElement(BC,{id:"widget-active-tab-btn",onClick:t.onActivateTab,variant:"contained",size:"xxsmall",type:"warning"},Wu.t("Activate this tab")),type:"warning",variant:"alarm",title:Wu.t("Another tab is open and handles transactions.")})}i(Ya,"ActivateTabAlert");import{i18n as Za}from"@lingui/core";import{Button as MC,Divider as LC,MessageBox as PC}from"@rango-dev/ui";import Fr from"react";function Ja(t){let{open:e,onClose:o,onConfirm:n}=t;return Fr.createElement(Z,{open:e,dismissible:!0,onClose:o,container:I()},Fr.createElement(PC,{title:Za.t("Activate current tab"),type:"warning",description:Za.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(LC,{size:20}),Fr.createElement(MC,{id:"widget-modal-confirm-activate-tab-btn",variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:n},Za.t("Confirm"))))}i(Ja,"ActivateTabModal");import{ChevronLeftIcon as _C}from"@rango-dev/ui";import Mu from"react";function Ra(t){return Mu.createElement(Et,{id:"widget-header-back-icon-btn",variant:"ghost",size:"small",onClick:t.onClick},Mu.createElement(_C,{color:"black",size:16}))}i(Ra,"BackButton");import{i18n as DC}from"@lingui/core";import{Button as $C,Typography as FC}from"@rango-dev/ui";import es from"react";function ts(t){return es.createElement(Vt,null,es.createElement($C,{id:"widget-header-cancel-btn",variant:"ghost",onClick:t.onClick,size:"xsmall"},es.createElement(FC,{variant:"label",size:"medium",color:"error500"},DC.t("Cancel"))))}i(ts,"CancelButton");import{i18n as OC}from"@lingui/core";import{Image as UC,Tooltip as zC,WalletIcon as QC}from"@rango-dev/ui";import fo from"react";function os(t){let{list:e}=ft(),o=e.filter(r=>r.state==="connected"),n=o.length?fo.createElement("div",{className:Cp()},o.map(r=>fo.createElement(kr,{key:r.title},fo.createElement(UC,{src:r.image,size:14})))):OC.t("Connect Wallet");return fo.createElement(zC,{container:t.container,side:"bottom",content:n},fo.createElement(Et,{id:"widget-header-wallet-icon-btn",variant:"ghost",size:"small",onClick:t.onClick},t.isConnected&&fo.createElement(gp,null),fo.createElement(QC,{size:18,color:"black"})))}i(os,"WalletButton");import{i18n as Ur}from"@lingui/core";import{NotificationsIcon as rk,Popover as ik,SettingsIcon as ak,Tooltip as zr,TransactionIcon as sk}from"@rango-dev/ui";import We from"react";import{Notifications as VC}from"@rango-dev/ui";import KC from"react";import{useNavigate as jC}from"react-router-dom";import{create as HC}from"zustand";import{persist as qC,subscribeWithSelector as GC}from"zustand/middleware";var be=Lo(HC()(qC(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(c=>c.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(c=>c.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 ns(){let t=jC(),{getNotifications:e,clearNotifications:o}=be(),n=e(),r=y().blockchains(),{findToken:a}=y();return KC.createElement(VC,{list:n,getBlockchainImage:l=>dc(l,r)??"",getTokenImage:l=>a(l)?.image??"",onClickItem:i(l=>{t(`${$.swaps}/${l}`)},"onClickItem"),onClearAll:o})}i(ns,"NotificationContent");import{useManager as XC}from"@rango-dev/queue-manager-react";import{InProgressIcon as YC}from"@rango-dev/ui";import Lu from"react";var ZC=i(()=>{let{manager:t}=XC();return pt(t).map(({swap:o})=>o).find(o=>o.status==="running")?Lu.createElement(Sp,null,Lu.createElement(YC,{color:"info",size:6})):null},"InProgressTransactionBadge"),Pu=ZC;import{EventSeverity as JC}from"@rango-dev/queue-manager-rango-preset";import{Typography as RC}from"@rango-dev/ui";import _u from"react";function Du(){let{getNotifications:t}=be(),e=t(),o=e.length,n=!!e.find(r=>r.event.messageSeverity===JC.WARNING);return o?_u.createElement(hp,{isSever:n},_u.createElement(RC,{variant:"body",size:"xsmall",color:"$background"},o)):null}i(Du,"NotificationsBadge");import{RefreshProgressButton as ek}from"@rango-dev/ui";import rs,{useEffect as tk,useState as $u}from"react";var ok=1e3,Fu=60,nk=100;function Or({onClick:t}){let[e,o]=$u(0),[n,r]=$u(!1),a=i(c=>{document.hidden&&c&&s(c)},"handleVisibilityChange");tk(()=>{let c;return t?c=window.setInterval(()=>{o(p=>p+1),e===Fu&&l()},ok):s(c),document.addEventListener("visibilitychange",()=>a(c)),()=>{document.removeEventListener("visibilitychange",()=>a(c)),c&&clearInterval(c)}},[e,t]);let s=i(c=>{c&&clearInterval(c),o(0)},"clearTimeout"),l=i(()=>{t?.(),o(0),r(!0)},"handleRefreshClick");return rs.createElement(Et,{id:"widget-header-refresh-icon-btn",variant:"ghost",size:"small",style:{paddingTop:0,paddingBottom:0},onClick:l,disabled:!t},rs.createElement(yp,{onTransitionEnd:()=>r(!1),isRefetched:n},rs.createElement(ek,{size:22,color:t?"black":"gray",progress:e/Fu*nk})))}i(Or,"RefreshButton");function go(t){let{onClickRefresh:e,onClickHistory:o,onClickSettings:n,hidden:r=[],container:a}=t,{config:{features:s}}=y(),l=Ve("notification",s)||r.includes("notifications");return We.createElement(We.Fragment,null,!r.includes("refresh")&&We.createElement(zr,{container:a||I(),side:"top",content:Ur.t("Refresh")},We.createElement(Or,{onClick:e})),!l&&We.createElement(ik,{align:"end",alignOffset:-88,sideOffset:15,collisionPadding:{right:20,left:20},container:I(),content:We.createElement(ns,null)},We.createElement("div",null,We.createElement(zr,{container:I(),side:"top",content:Ur.t("Notifications")},We.createElement(Et,{id:"widget-header-notification-icon-btn",size:"small",variant:"ghost"},We.createElement(rk,{size:18,color:"black"}),We.createElement(Du,null))))),!r.includes("settings")&&We.createElement(zr,{container:I(),side:"top",content:Ur.t("Settings")},We.createElement(Et,{id:"widget-header-setting-icon-btn",size:"small",variant:"ghost",onClick:n},We.createElement(ak,{size:18,color:"black"}))),!r.includes("history")&&We.createElement(zr,{container:I(),side:"top",content:Ur.t("History")},We.createElement(Et,{id:"widget-header-history-icon-btn",size:"small",variant:"ghost",onClick:o},We.createElement(sk,{size:18,color:"black"}),We.createElement(Pu,null))))}i(go,"HeaderButtons");import{i18n as is}from"@lingui/core";import{Divider as Uu,MessageBox as pk,RefreshIcon as uk}from"@rango-dev/ui";import Ho from"react";import{Button as lk,styled as ck}from"@rango-dev/ui";var Ou=ck(lk,{"& span":{display:"flex",justifyContent:"center",alignItems:"center"}});function as(t){let{open:e,onClose:o}=t;return Ho.createElement(Z,{open:e,dismissible:!0,onClose:o,container:I()},Ho.createElement(pk,{title:is.t("Something went wrong"),type:"error",description:is.t("Something went wrong. Please refresh the app.")},Ho.createElement(Uu,{size:30}),Ho.createElement(Ou,{variant:"outlined",size:"large",type:"primary",fullWidth:!0,onClick:()=>location.reload()},Ho.createElement(uk,{size:20,color:"primary"}),Ho.createElement(Uu,{size:4,direction:"horizontal"}),is.t("Refresh"))))}i(as,"RefreshModal");function ss(t){let e=t.target;if(e){let o=e.scrollTop,n=I();o>1?n.classList.add("rng-scrolled"):n.classList.remove("rng-scrolled")}}i(ss,"onScrollContentAttachStatusToContainer");import{css as dk,styled as ls}from"@rango-dev/ui";var zu="700px",Qr=dk({borderRadius:"$primary",display:"flex",flexDirection:"column",overflow:"hidden",boxShadow:"$mainContainer"}),Qu=ls("div",{position:"relative",width:"100vw",minWidth:"300px",maxWidth:"390px",backgroundColor:"$background",variants:{height:{auto:{height:"auto",maxHeight:zu},fixed:{height:zu}}}}),Hu=ls("div",{position:"relative",overflow:"hidden",flexGrow:1,display:"flex",flexDirection:"column",padding:0,overflowY:"auto"}),qu=ls("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 oe(t){let{connectHeightObserver:e,disconnectHeightObserver:o}=Qa(),{children:n,header:r,footer:a,height:s="fixed"}=t,{fetchStatus:l,connectedWallets:c}=y(),[p,u]=hk(!1),{config:{features:d,theme:h}}=y(),{watermark:g}=re(),f=g==="FULL",{activeTheme:m}=Qo(h||{}),C=Ve("connectWalletButton",d),{isActiveTab:S,tabManagerInitiated:k,showActivateTabModal:T,setShowActivateTabModal:v,activateCurrentTab:b}=re(),A=je(),{manager:D}=mk(),x=pt(D).map(({swap:te})=>te).some(te=>te.status==="running"),E=i(()=>b(ao.forceClaim,x),"onActivateTab"),N=i(()=>{r.onWallet?.()},"onConnectWallet"),M=typeof r.hasBackButton>"u"||r.hasBackButton,W=Vu(null),j=Vu(null);return cs(()=>($r()&&j.current&&e(j.current),()=>{o()}),[]),cs(()=>(W.current?.addEventListener("scroll",ss),()=>{W.current?.removeEventListener("scroll",ss)}),[]),cs(()=>{u(l==="failed")},[l]),Be.createElement(Qu,{height:s,id:De.SWAP_BOX_ID,className:`${m()} ${Qr()}`,ref:j},Be.createElement(gk,{prefix:M?Be.createElement(Ra,{onClick:()=>{A(),r.onBack&&r.onBack()}}):null,title:r.title,suffix:Be.createElement(Be.Fragment,null,r.suffix,r.onWallet&&!C&&Be.createElement(os,{container:I(),onClick:N,isConnected:!!c?.length}),r.onCancel&&Be.createElement(ts,{onClick:r.onCancel}))}),Be.createElement(Hu,{ref:W},n),Be.createElement(Ja,{open:T,onClose:()=>v(!1),onConfirm:E}),Be.createElement(qu,null,Be.createElement("div",{className:"footer__content"},k&&!S&&Be.createElement("div",{className:"footer__alert"},Be.createElement(Ya,{onActivateTab:E}),Be.createElement(Gu,{size:10})),a),Be.createElement(Gu,{size:12}),Be.createElement("div",{className:`footer__logo ${f?"logo__show":"logo__hidden"}`},Be.createElement(fk,null))),Be.createElement(as,{open:p,onClose:()=>u(!1)}))}i(oe,"Layout");import{styled as yk}from"@rango-dev/ui";var Ku="$20 $20 $10 $20",wn=yk("div",{padding:Ku,overflowY:"auto",flexGrow:1});import{styled as Sk}from"@rango-dev/ui";var ie=Sk("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 qo}from"@lingui/core";import{useState as ju}from"react";function Xu(){let[t,e]=ju(!1),[o,n]=ju(void 0),{findToken:r}=y(),a=y().customTokens();function s(c,p){switch(c){case"duplicated":return{title:qo.t("Duplicate Token"),message:qo.t("The address you entered is duplicate, please enter a new address.")};case"token-exist":return{title:qo.t("Token Already Exists"),message:qo.t("There's no need to add this token again because it already exists and is supported by us.")};case"not-found":return{title:qo.t("Token Not Found"),message:qo.t({id:"Sorry, no token was found on {blockchain} chain with the provided address. please make sure you have entered the right token address.",values:{blockchain:p}})}}}return i(s,"produceErrorMessage"),{fetchCustomToken:i(async({blockchain:c,tokenAddress:p})=>{e(!0);try{if(a.some(f=>f.address?.toLowerCase()===p.toLowerCase())){let f=s("duplicated");n(f);return}let d=await xt().getCustomToken({blockchain:c,address:p});if(!d||!d.token||d.error){let f=s("not-found",c);n(f);return}let h=d.token;if(r({blockchain:h.blockchain,address:h.address,symbol:h.symbol})){let f=s("token-exist");n(f);return}return h}catch(u){if(u?.code==="ERR_BAD_REQUEST"){let d=s("not-found",c);n(d);return}throw n(void 0),new Error(u.message)}finally{e(!1)}},"fetchCustomToken"),loading:t,error:o}}i(Xu,"useFetchCustomToken");var Nk=wk("div",{display:"flex",justifyContent:"space-between",flexDirection:"column",flex:1,"& ._text-field":{padding:"$4 $10",backgroundColor:"$neutral300",[`.${kk} &`]:{backgroundColor:"$neutral400"},borderRadius:"$sm",height:"$40"}}),Wk=1e3;function Zu(){let t=Ik(),[e]=Ak(),o=je(),{setCustomToken:n}=y(),r=y().blockchains(),a=e.get("blockchain")||"",s=an(a,r),[l,c]=Hr(""),[p,u]=Hr(!1),[d,h]=Hr(),{fetchCustomToken:g,loading:f,error:m}=Xu(),[C,S]=Hr(""),k=!!s&&Io(s,l),T=!s||!l||!k,v=i(async()=>{if(s)try{let D=await g({blockchain:a,tokenAddress:l});S(""),D&&h(D)}catch(D){D.message==="Failed to fetch"&&(S(It.t("Network Error")),u(!0))}},"getCustomToken"),b=i(()=>{m&&c(""),u(!1)},"closeErrorModal"),A=i(async()=>{C&&setTimeout(async()=>{await v()},Wk),b()},"handleErrorModalButtonClick");return Ek(()=>{m&&u(!0)},[m]),ye.createElement(oe,{header:{title:It.t("Add Custom Token")}},ye.createElement(ie,null,ye.createElement(Nk,null,ye.createElement("div",null,ye.createElement(Fa,{onClick:()=>t($.blockchains,{replace:!0}),hasLogo:!!s?.logo,value:s?{name:s.displayName,logo:s.logo}:void 0,title:It.t("Select chain"),placeholder:It.t("Select chain")}),ye.createElement(bn,{size:"24"}),ye.createElement(xk,{size:"large",variant:"label"},It.t("Enter Address")),ye.createElement(bn,{size:10}),ye.createElement(bk,{fullWidth:!0,disabled:!s,variant:"contained",placeholder:It.t("Enter token address"),size:"large",value:l,suffix:!!l&&k&&ye.createElement(Tk,{color:"success",size:12}),onChange:D=>c(D.target.value)}),!k&&!!l&&ye.createElement(ye.Fragment,null,ye.createElement(bn,{size:4}),ye.createElement(Ck,{type:"error",variant:"alarm",title:"Invalid Address"}))),ye.createElement(Yu,{id:"widget-add-custom-token-import-btn",disabled:T,type:"primary",variant:"contained",loading:f,size:"large",onClick:v},It.t("Import"))),ye.createElement(Z,{open:p,dismissible:!0,onClose:b,container:I()},ye.createElement(vk,{title:m?.title||C,type:"error",description:m?.message||It.t("Failed Network, Please retry.")},ye.createElement(bn,{size:40}),ye.createElement(bn,{size:10}),ye.createElement(Yu,{id:`widget-add-custom-token-${C?"retry":"add-another"}-btn`,variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:A},C?It.t("Retry"):It.t("Add another custom token")))),s&&d&&ye.createElement(za,{blockchain:s,token:d,onSubmitClick:()=>{d&&(n(d),h(void 0),o())},onClose:()=>h(void 0),open:!!s&&!!d})))}i(Zu,"AddCustomTokenPage");import{i18n as Os}from"@lingui/core";import{useManager as mv}from"@rango-dev/queue-manager-react";import{Alert as fv,Button as gv,css as zs,Divider as Us,IconButton as Gm,styled as hv,Typography as yv,WalletIcon as Sv}from"@rango-dev/ui";import Le,{useEffect as yi,useLayoutEffect as Cv,useRef as kv,useState as $n}from"react";import{useNavigate as Tv}from"react-router-dom";import{i18n as ho}from"@lingui/core";import{Alert as tT,BalanceErrors as oT,Button as xd,ChevronLeftIcon as nT,Divider as ys,MessageBox as rT,Typography as Ss}from"@rango-dev/ui";import ee,{useCallback as iT,useEffect as Ed,useMemo as aT,useState as Ko}from"react";import{useNavigate as sT}from"react-router-dom";import{i18n as ms}from"@lingui/core";import{Alert as _k,ChevronDownIcon as Dk,CloseIcon as $k,Divider as rd,IconButton as id,PasteIcon as Fk,Typography as Ok,WalletIcon as Uk}from"@rango-dev/ui";import Me,{useEffect as zk,useRef as Qk}from"react";import Kr,{useRef as Lk}from"react";import*as Go from"@radix-ui/react-collapsible";import{keyframes as Ju,styled as qr}from"@rango-dev/ui";var ps=300,Bk=Ju({from:{height:0},to:{height:"var(--radix-collapsible-content-height)"}}),Mk=Ju({from:{height:"var(--radix-collapsible-content-height)"},to:{height:0}}),Ru=qr(Go.Root,{borderRadius:"$sm",overflow:"hidden",variants:{selected:{true:{outlineWidth:1,outlineColor:"$secondary500",outlineStyle:"solid"}}}}),us=qr(Go.Trigger,{padding:"$0",border:"none",outline:"none",width:"100%",backgroundColor:"transparent",fontFamily:"inherit",cursor:"pointer"}),Gr=qr(Go.Content,{overflow:"hidden",variants:{open:{true:{animation:`${Bk} ${ps}ms ease-out`},false:{animation:`${Mk} ${ps}ms ease-out`}}}}),Vr=qr("div",{transition:`all ${ps}ms ease`,display:"flex",alignItems:"center",variants:{orientation:{down:{transform:"rotate(0)"},up:{transform:"rotate(180deg)"}}}});function jr(t){let{open:e,hasSelected:o,onOpenChange:n,children:r,onClickTrigger:a,trigger:s,triggerAnchor:l}=t,c=Lk(null);return Kr.createElement(Ru,{ref:c,className:"collapsible_root",selected:o&&e,open:e,onOpenChange:n},l==="top"&&Kr.createElement(us,{className:"collapsible_trigger",onClick:a},s),Kr.createElement(Gr,{className:"collapsible_content",open:e},r),l==="bottom"&&Kr.createElement(us,{className:"collapsible_trigger",onClick:a},s))}i(jr,"CustomCollapsible");import{darkTheme as ed,styled as ds,TextField as Pk}from"@rango-dev/ui";var td=ds("div",{padding:"$10 $0","& .button__content":{display:"flex",alignItems:"center"},"& .alarms":{paddingTop:"$5"},"& .collapsible_content":{backgroundColor:"$neutral100"},"& .collapsible_root":{backgroundColor:"$neutral100"}}),od=ds(Pk,{backgroundColor:"$neutral100",padding:"$15"}),nd=ds("div",{width:"100%",borderRadius:"$sm",display:"flex",padding:"$15",justifyContent:"space-between",alignItems:"center",$$color:"$colors$neutral100",[`.${ed} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",borderBottomRightRadius:"0",borderBottomLeftRadius:"0","&:focus-visible":{$$background:"$colors$secondary100",[`.${ed} &`]:{$$background:"$colors$info700"},backgroundColor:"$$background",outline:0}});function ad(t){let{blockchain:e,handleOpenChange:o,open:n}=t,{customDestination:r,setCustomDestination:a}=O(),{config:s}=y(),l=y().blockchains(),c=ar(e.name,l),p=Qk(null),u=s?.defaultCustomDestinations?.[e.name],d=navigator?.userAgent.includes("Firefox"),g=n&&!!r&&e&&!Io(e,r),f=i(()=>{a("")},"handleClear"),m=i(async S=>{if(S.preventDefault(),navigator.clipboard!==void 0){let k=await navigator.clipboard.readText();a(k),p?.current?.focus()}},"handlePaste"),C=i(()=>r?Me.createElement(id,{id:"widget-custom-destination-close-icon-btn",onClick:f,variant:"ghost"},Me.createElement($k,{size:12,color:"gray"})):d?null:Me.createElement(id,{id:"widget-custom-destination-paste-icon-btn",onClick:m,variant:"ghost"},Me.createElement(Fk,{size:16})),"renderSuffix");return zk(()=>{!!u&&r===null&&(a(u),o(!0))},[u]),Me.createElement(td,null,Me.createElement(jr,{onOpenChange:o,hasSelected:!0,open:n,triggerAnchor:"top",trigger:Me.createElement(nd,null,Me.createElement("div",{className:"button__content"},Me.createElement(Uk,{size:18,color:"info"}),Me.createElement(rd,{size:4,direction:"horizontal"}),Me.createElement(Ok,{variant:"label",size:"medium",color:n?"$neutral600":void 0},ms.t("Send to a different address"))),Me.createElement(Vr,{orientation:n?"up":"down"},Me.createElement(Dk,{size:10,color:"secondary"}))),onClickTrigger:()=>o(!n)},Me.createElement(od,{ref:p,style:{padding:0,paddingRight:r?"8px":"5px"},autoFocus:!r,placeholder:ms.t("Enter {blockchainName} address",{blockchainName:c}),value:r||"",suffix:C(),onChange:S=>{let k=S.target.value;a(k)}})),g&&Me.createElement(Me.Fragment,null,Me.createElement(rd,{size:4}),Me.createElement(_k,{variant:"alarm",type:"error",title:ms.t({values:{destination:r},id:"Address {destination} doesn't match the blockchain address pattern."})})))}i(ad,"CustomDestination");import{css as Hk,darkTheme as fs,IconButton as qk,styled as Dt}from"@rango-dev/ui";var sd=Dt("div",{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center"}),ld=Dt("div",{display:"flex",justifyContent:"space-evenly",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5",height:"100%"}),Gk=Dt("button",{borderRadius:"$xm",padding:"$10",border:"0",display:"flex",justifyContent:"center",$$color:"$colors$neutral100",[`.${fs} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",alignItems:"center",cursor:"pointer",width:110,position:"relative","&:hover":{$$color:"$colors$secondary100",[`.${fs} &`]:{$$color:"$colors$neutral100"},backgroundColor:"$$color"},"&:focus-visible":{$$color:"$colors$secondary100",[`.${fs} &`]:{$$color:"$colors$info700"},backgroundColor:"$$color",outline:0},variants:{selected:{true:{outlineWidth:1,outlineColor:"$secondary",outlineStyle:"solid"}}}}),cd=Dt(Gk,{alignSelf:"stretch",minHeight:"93px"}),pd=Dt("div",{padding:"$20 $20 $15 $20",display:"flex",justifyContent:"center",alignItems:"center",backgroundColor:"$neutral200",position:"relative",width:"100%"}),ud=Dt(qk,{position:"absolute",left:"$20"}),dd=Dt("div",{paddingTop:"$20"}),md=Hk({display:"flex",justifyContent:"space-evenly",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5",height:"100%"}),fd=Dt("div",{display:"flex"}),gd=Dt("div",{overflow:"visible",width:"100%"});import{i18n as Td}from"@lingui/core";import{warn as Yk}from"@rango-dev/logging-core";import{Divider as Zk,SelectableWallet as Jk,Typography as vd,WalletState as wd}from"@rango-dev/ui";import Xe,{useEffect as bd,useState as En}from"react";import{Image as jk,MessageBox as Xk}from"@rango-dev/ui";import xn from"react";import{keyframes as Vk,styled as gs}from"@rango-dev/ui";var hd=gs("div",{position:"relative"}),Kk=Vk({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}),yd=gs("div",{position:"absolute",border:"2px solid rgba(0, 0, 0, 0.1)",borderTop:"2px solid $info500",borderRadius:"$lg",width:"$45",height:"$45",animation:`${Kk} 1s linear infinite`,top:0,bottom:0,right:0,left:0}),Sd=gs("div",{"& img":{borderRadius:"50%"}});import{i18n as Vo}from"@lingui/core";function Cd(t,e){switch(t){case"in-progress":return{type:"loading",title:Vo.t({id:"Add {blockchainDisplayName} Chain",values:{blockchainDisplayName:e}}),description:Vo.t({id:"Please approve the experimental chain pop-up in your wallet.",values:{blockchainDisplayName:e}})};case"completed":return{type:"success",title:Vo.t({id:"{blockchainDisplayName} Chain Added",values:{blockchainDisplayName:e}}),description:Vo.t({id:"The {blockchainDisplayName} chain has been successfully added to your wallet.",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(Cd,"generateMessageByStatus");function kd(t){let{status:e,displayName:o,image:n}=t,r=Cd(e,o),a=e=="in-progress";return xn.createElement(Xk,{type:r.type,title:r.title,description:r.description,icon:a?xn.createElement(hd,null,xn.createElement(Sd,null,xn.createElement(jk,{src:n,size:45})),xn.createElement(yd,null)):void 0})}i(kd,"ExperimentalChainStatus");var Rk=7,eT=3e3;function hs(t){let{chain:e,isSelected:o,selectWallet:n,limit:r,onShowMore:a}=t,s=re.use.isActiveTab(),{blockchains:l,connectedWallets:c}=y(),[p,u]=En(),[d,h]=En(null),[g,f]=En(!1),[m,C]=En(null),{suggestAndConnect:S}=Xr(),{handleDisconnect:k}=Gt(),{list:T}=ft({chain:e}),[v,b]=En(T),A=T.length,D=r&&A-r>0,w=i(async E=>{f(!1),C("in-progress");try{await S(E.walletType,E.chain),C("completed")}catch{C("rejected")}},"addExperimentalChain");bd(()=>{b(E=>{let N=T.findIndex(M=>o(M.type,e));return D&&N>1?[T[N]].concat(T.filter((M,W)=>W!==N)):E.map(M=>T.find(W=>W.type===M.type)??M)})},[JSON.stringify(T)]);let x=document.getElementById(De.SWAP_BOX_ID);return bd(()=>{let E=null;return(m==="completed"||m==="rejected")&&(E=setTimeout(()=>C(null),eT)),()=>{E&&clearTimeout(E)}},[m]),Xe.createElement(Xe.Fragment,null,v.slice(0,r).map(E=>{let N=Fc({connectedWallets:c,walletType:E.type,chain:e}),M=N?yr(N,Rk):"",W=gr(l(),e),j=!c.find(se=>se.walletType===E.type&&se.chain===e),te=W&&j&&E.state===wd.CONNECTED,J=te?Td.t({id:"Add {chain} chain",values:{chain:e}}):M,L=i(async()=>{let se=E.state===wd.DISCONNECTED,z=(E.isHub||!!E.needsNamespace)&&!M;se?u(E):z?(await k(E.type),u(E)):te?(h({walletType:E.type,chain:e,address:N??""}),f(!0)):n({walletType:E.type,chain:e,address:N??""})},"onSelectableWalletClick"),X=d?.chain?ar(d.chain,l()):void 0;return Xe.createElement(Xe.Fragment,{key:`${E.title}_${X}`},!!d&&Xe.createElement(Z,{open:!!d&&g,container:x,onClose:()=>{h(null)}},Xe.createElement(ba,{displayName:X,onConfirm:()=>{w(d)}})),m&&Xe.createElement(Z,{open:!!m,onClose:C.bind(null,null),container:x},Xe.createElement(kd,{status:m,displayName:X,image:E.image}),Xe.createElement(Zk,{direction:"vertical",size:32})),Xe.createElement(Jk,{key:E.type,description:J,onClick:L,selected:o(E.type,e),disabled:!s,...E}))}),Xe.createElement(po,{wallet:p,onClose:()=>{u(void 0)},onConnect:()=>{t.onConnect&&(p?.type?t.onConnect(p.type):Yk(new Error("The selected wallet hasn't been detected after the connection process finished. It usually shouldn't happen.")))}}),D&&Xe.createElement(cd,{selected:!1,onClick:a},Xe.createElement(vd,{variant:"label",size:"medium"},Td.t("Show more wallets"),Xe.createElement(vd,{variant:"label",size:"medium",color:"$primary"},"\xA0+",A-(r??0)))))}i(hs,"WalletList");var lT=2;function Id(t){let{open:e,onClose:o,onCancel:n,onCheckBalance:r,loading:a}=t,s=sT(),l=y().blockchains(),{selectedQuote:c,setSelectedWallets:p,quoteWalletsConfirmed:u,setQuoteWalletConfirmed:d,customDestination:h,setCustomDestination:g}=O(),{config:f,connectedWallets:m,setWalletsAsSelected:C}=y(),[S,k]=Ko(""),[T,v]=Ko([]),[b,A]=Ko(""),[D,w]=Ko(!!h),x=aT(()=>io({filter:"all",quote:c}),[c]),E=io({filter:"required",quote:c}),N=l.find(P=>P.name===c?.swaps[c?.swaps.length-1].to.blockchain),M=i(P=>E.includes(P),"isWalletRequiredFor"),W=iT(()=>m.filter(P=>P.selected&&x.includes(P.chain)),[m,x]),[j,te]=Ko(W()),[J,L]=Ko([]),X=i((P,q)=>L(V=>V.concat({blockchain:P,walletType:q})),"addNextSelectedWallets"),se=T.length>0,z=i((P,q)=>!!j.find(V=>V.walletType===P&&V.chain===q&&V.selected&&(M(q)||!M(q)&&!h)),"isSelected"),me=i((P,q,V)=>{let fe=!1;return P.map(ne=>{if(ne.chain===q){let ge=ne.selected;return!fe&&V?(fe=!0,ge=!0):V||(ge=!1),{...ne,selected:ge}}return ne})},"updateSelectableWallets"),vt=i(P=>{w(P),P?M(N?.name??"")||te(q=>me(q,N?.name||"",!1)):(g(""),te(q=>me(q,N?.name||"",!0)))},"handleCustomDestinationCollapsibleOpenChange"),Ze=i(P=>{if(S&&k(""),z(P.walletType,P.chain))return;let V=m.find(fe=>fe.walletType===P.walletType&&fe.chain===P.chain);V&&(n(),P.chain===N?.name&&D&&!M(N.name)&&(w(!1),g(null)),te(fe=>fe.filter(ne=>ne.chain!==P.chain).concat({...V,selected:!0})))},"onChange"),le=i(()=>{let P=j.filter(q=>q.selected);C(P),p(P),d(!0),o()},"onConfirmBalance"),at=i(async()=>{v([]),A("");let P=await r?.({selectedWallets:j.filter(V=>V.selected),customDestination:h}),q=P.warnings;q?.balance?.messages&&v(q.balance.messages),P.error&&A(Fp(P.error)),!P.error&&!q?.balance?.messages.length?le():v(q?.balance?.messages??[])},"onConfirmWallets");Ed(()=>{te(P=>{let q=[];return P.forEach(V=>{!m.some(ne=>ne.chain===V.chain&&ne.walletType===V.walletType&&ne.address===V.address)||q.push(V)}),q=q.concat(m.filter(V=>!!!q.find(ne=>ne.chain===V.chain)&&V.selected&&x.includes(V.chain))),q})},[m,x]),Ed(()=>{let P=[];J.length>0&&(J.forEach(q=>{let V=m.find(fe=>fe.chain===q.blockchain&&fe.walletType===q.walletType);V?Ze(V):P.push(q)}),L(P))},[m,J]);let G=document.getElementById(De.SWAP_BOX_ID);return ee.createElement(Z,{open:e,onClose:()=>{u||s("../",{replace:!0}),o()},dismissible:!S,container:G,...!S&&{styles:{container:{height:"100%"}},footer:ee.createElement(fd,null,ee.createElement(xd,{id:"widget-confirm-wallet-modal-confirm-btn",loading:a,disabled:mu(a,D,h,c,j,N),onClick:at,variant:"contained",type:"primary",fullWidth:!0,size:"large"},ho.t("Confirm")))},...S&&{styles:{container:{height:"100%",padding:"$0"}},header:ee.createElement(pd,null,ee.createElement(ud,{id:"widget-confirm-wallet-modal-navigate-back-icon-btn",variant:"ghost",onClick:k.bind(null,"")},ee.createElement(nT,{size:16})),ee.createElement(Ss,{variant:"headline",size:"small"},ho.t({id:"Your {blockchainName} wallets",values:{blockchainName:st(S,l)}})))},anchor:"center"},ee.createElement(Z,{open:se,onClose:v.bind(null,[]),container:G},ee.createElement(rT,{title:ho.t("Insufficient account balance"),type:"error",description:ee.createElement(oT,{messages:T??[]})},ee.createElement(xd,{id:"widget-confirm-wallet-modal-proceed-anyway-btn",variant:"outlined",size:"large",type:"primary",fullWidth:!0,onClick:le},ho.t("Proceed anyway")))),S&&ee.createElement(dd,null,ee.createElement("div",{className:md()},ee.createElement(hs,{chain:S,isSelected:z,selectWallet:Ze,onShowMore:()=>k(S),onConnect:P=>{X(S,P)}}))),!S&&ee.createElement(ee.Fragment,null,b&&ee.createElement(ee.Fragment,null,ee.createElement(tT,{variant:"alarm",type:"error",title:ho.t(b)}),ee.createElement(ys,{size:12})),ee.createElement(gd,null,x.map((P,q)=>{let V=l.find(Fe=>Fe.name===P),fe=`wallet-${q}`,ne=q===x.length-1,ge=ne&&N&&f?.customDestination!==!1;return ee.createElement("div",{key:fe},ee.createElement(sd,null,ee.createElement(Ss,{variant:"title",size:"xmedium"},ho.t({id:"Your {blockchainName} wallets",values:{blockchainName:V?.shortName}})),ee.createElement(Ss,{variant:"label",color:"$neutral700",size:"medium"},ho.t({id:"You need to connect a {blockchainName} wallet.",values:{blockchainName:V?.shortName}}))),ee.createElement(ys,{size:24}),ee.createElement(ld,null,ee.createElement(hs,{chain:P,isSelected:z,selectWallet:Ze,limit:lT,onShowMore:()=>k(V?.name??""),onConnect:Fe=>{X(P,Fe)}})),!ne&&ee.createElement(ys,{size:32}),ge&&ee.createElement(ad,{blockchain:N,open:D,handleOpenChange:vt}))}))))}i(Id,"ConfirmWalletsModal");import{i18n as IT}from"@lingui/core";import{Alert as AT,Button as NT,InfoIcon as WT}from"@rango-dev/ui";import et from"react";import{Alert as uT,Button as dT,Divider as Ts,NoRouteIcon as mT,RefreshIcon as fT,Typography as Pd}from"@rango-dev/ui";import Re from"react";import{i18n as Ad}from"@lingui/core";var cT=24,pT=60;function Nd(t,e,o,n){return t?.type===1?{alert:{type:"warning",text:R().genericServerError,action:{onClick:n,title:Ad.t("Retry")}},description:""}:e.length?{alert:{type:"warning",text:R().liquiditySourcesError.title,action:{onClick:()=>o(!0),title:Ad.t("Reset")}},description:R().liquiditySourcesError.description}:t?.type===0&&t.diagnosisMessage?{alert:{type:"error",text:t.diagnosisMessage,action:null},description:""}:{alert:null,description:R().noResultError.description}}i(Nd,"makeInfo");var Cs=(o=>(o[o.small=cT]="small",o[o.large=pT]="large",o))(Cs||{}),ks=(o=>(o.small="small",o.large="medium",o))(ks||{});import{styled as Yr}from"@rango-dev/ui";var Wd=Yr("div",{display:"flex",flexDirection:"column",alignItems:"center"}),Bd=Yr("div",{variants:{size:{small:{},large:{maxWidth:"316px"}}}}),Md=Yr("div",{variants:{size:{small:{width:"100%"},large:{}}}}),Ld=Yr("div",{padding:"$6 $0"});function In(t){let{fetch:e,error:o,size:n="small"}=t,r=y().getDisabledLiquiditySources(),a=y().toggleAllLiquiditySources,s=y().swappers(),l=Nd(o,r,()=>a(s,!0),e);return Re.createElement(Wd,null,Re.createElement(mT,{size:Cs[n],color:"gray"}),Re.createElement(Ts,{size:4}),Re.createElement(Pd,{variant:"title",size:ks[n]},R().noResultError.title),n==="large"&&Re.createElement(Ts,{size:4}),!!l.description&&Re.createElement(Bd,{size:n},Re.createElement(Pd,{variant:"body",size:"small",align:"center",color:"neutral700"},l.description)),Re.createElement(Ts,{size:n==="large"?"24":"4"}),!!l.alert&&Re.createElement(Md,{size:n},Re.createElement(uT,{type:l.alert.type,title:l.alert.text,titleAlign:"left",action:l.alert.action&&Re.createElement(dT,{size:"xsmall",id:"widget-no-result-alert-btn",type:l.alert.type,prefix:Re.createElement(Ld,null,Re.createElement(fT,{size:8})),onClick:l.alert.action.onClick},l.alert.action.title),variant:"alarm"})))}i(In,"NoResult");import{i18n as An}from"@lingui/core";import{Button as hT,Divider as yT,MessageBox as ST,Typography as CT,WarningIcon as kT}from"@rango-dev/ui";import $t from"react";import{Typography as Fd}from"@rango-dev/ui";import ws from"react";import{darkTheme as gT,styled as Zr}from"@rango-dev/ui";var _d=Zr("div",{width:"100%"}),vs=Zr("div",{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"$5",width:"100%"}),Dd=Zr("div",{display:"flex",padding:"$5 0",justifyContent:"space-between",alignItems:"center",width:"100%","._title":{$$color:"$colors$neutral600",[`.${gT} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),$d=Zr("div",{padding:"$2",alignSelf:"flex-start",cursor:"pointer"});function Od(t){let{title:e,value:o,valueColor:n}=t;return ws.createElement(Dd,null,ws.createElement(Fd,{size:"medium",variant:"label",className:"_title"},e),ws.createElement(Fd,{size:"large",variant:"label",color:n||"foreground"},`${n?"%":"$"}${o}`))}i(Od,"QuoteErrorsModalItem");function Ud(t){let{open:e,onClose:o,onConfirm:n,warning:r,confirmationDisabled:a}=t,s=r.warningLevel==="high"?"error":"warning",l=[{title:An.t("Swapping"),value:B(r.inputUsdValue,4,4)},{title:An.t("Gas cost"),value:B(r.totalFee,2,2)},{title:An.t("Receiving"),value:B(r.outputUsdValue,4,4)},{title:An.t("Price impact"),value:B(r.priceImpact,2,2),valueColor:`${s}500`}];return $t.createElement(Z,{footer:$t.createElement(hT,{id:"widget-high-value-loss-warning-modal-confirm-btn",type:"primary",size:"large",prefix:$t.createElement(kT,null),fullWidth:!0,disabled:a,onClick:n},R().highValueLossError.confirmMessage),open:e,onClose:o,container:I()},$t.createElement(ST,{type:s,title:R().highValueLossError.impactTitle,description:R().highValueLossError.description}),$t.createElement(vs,null,$t.createElement(yT,{size:"4"}),$t.createElement(CT,{size:"small",variant:"title"},An.t("Details")),$t.createElement(vs,null,l.map((c,p)=>$t.createElement(Od,{key:p,...c})))))}i(Ud,"HighValueLossWarningModal");import{i18n as Jr}from"@lingui/core";function zd(t,e){let o={alertType:"warning",title:"",action:null};if(e)return o.alertType="error",e.type===3&&(o.title=e.recommendation),e.type===4&&(o.title=Jr.t({id:"You need to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:e.minRequiredSlippage}}),o.action="change-settings"),o;if(t){switch(t.type){case 0:{_t(t.priceImpact)==="high"&&(o.alertType="error"),o.action="show-info",o.title=R().highValueLossError.title;break}case 4:{o.title=Jr.t({id:"Output amount changed by {percentageChange}% (${usdValueChange}).",values:{percentageChange:t.percentageChange,usdValueChange:t.usdValueChange}});break}case 1:{o.title=R().unknownPriceError.title;break}case 2:{o.title=Jr.t({id:"We recommend you to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:t.minRequiredSlippage}}),o.action="change-settings";break}case 3:{o.title=Jr.t("Caution, your slippage is high."),o.action="change-settings";break}default:break}return o}return null}i(zd,"makeAlerts");import{i18n as jo}from"@lingui/core";import{Button as Qd,Divider as Hd,MessageBox as TT,Typography as vT}from"@rango-dev/ui";import yo from"react";import{useNavigate as wT}from"react-router-dom";function qd(t){let{customSlippage:e,slippage:o}=y(),{open:n,onClose:r,onConfirm:a,warning:s,confirmationDisabled:l}=t,c=wT(),p=e??o;return yo.createElement(Z,{anchor:"bottom",open:n,prefix:yo.createElement(Qd,{size:"small",id:"widget-slippage-warning-modal-change-settings-btn",variant:"ghost",onClick:()=>c("../"+$.settings)},yo.createElement(vT,{variant:"label",size:"medium",color:"$neutral900"},jo.t("Change settings"))),container:I(),onClose:r},yo.createElement(TT,{type:"warning",title:s.type===3?jo.t("High slippage"):jo.t("Low slippage"),description:s.type===3?jo.t({id:" Caution, your slippage is high (={userSlippage}). Your trade may be front run.",values:{userSlippage:p}}):jo.t({id:"We recommend you to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:s.minRequiredSlippage}})},yo.createElement(Hd,{size:18}),yo.createElement(Hd,{size:32}),yo.createElement(Qd,{id:"widget-slippage-warning-modal-confirm-anyway-btn",size:"large",type:"primary",variant:"contained",fullWidth:!0,disabled:l,onClick:a},jo.t("Confirm anyway"))))}i(qd,"SlippageWarningModal");import{Button as bT,MessageBox as xT,WarningIcon as ET}from"@rango-dev/ui";import Rr from"react";function Gd(t){let{open:e,onClose:o,onConfirm:n,confirmationDisabled:r}=t;return Rr.createElement(Z,{footer:Rr.createElement(bT,{id:"widget-unknown-price-warning-modal-confirm-btn",type:"primary",size:"large",prefix:Rr.createElement(ET,null),fullWidth:!0,disabled:r,onClick:n},R().unknownPriceError.confirmMessage),open:e,onClose:o,container:I()},Rr.createElement(xT,{type:"warning",title:R().unknownPriceError.impactTitle,description:R().unknownPriceError.description}))}i(Gd,"UnknownPriceWarningModal");function Nn(t){let{warning:e,error:o,couldChangeSettings:n,showWarningModal:r,confirmationDisabled:a,refetchQuote:s,onOpenWarningModal:l,onCloseWarningModal:c,onConfirmWarningModal:p,onChangeSettings:u}=t,d={confirmationDisabled:a,open:r,onClose:c,onConfirm:p},h=o?.type===0||o?.type===1,g=zd(e,o?.type===3||o?.type===4?o:null);return g&&!n&&(g.action=null),et.createElement(et.Fragment,null,h&&et.createElement(In,{error:o,fetch:s}),!!g&&et.createElement(_d,null,et.createElement(AT,{title:g.title,type:g.alertType,variant:"alarm",...g.action==="show-info"&&{action:et.createElement($d,{onClick:l},et.createElement(WT,{size:12,color:"gray"}))},...g.action==="change-settings"&&{action:et.createElement(NT,{id:"widget-quote-warning-error-change-settings-btn",size:"xxsmall",type:g.alertType,onClick:u},IT.t("Change"))}})),e&&et.createElement(et.Fragment,null,e.type===0&&et.createElement(Ud,{...d,warning:e}),(e.type===3||e.type===2)&&et.createElement(qd,{...d,warning:e}),e.type===1&&et.createElement(Gd,{...d,warning:e})))}i(Nn,"QuoteWarningsAndErrors");import sv from"bignumber.js";import mi from"react";import{i18n as So}from"@lingui/core";import{Alert as jT,Divider as Yo,FullExpandedQuote as XT,InfoIcon as YT,NumericTooltip as wm,QuoteTag as ZT,StepDetails as JT,TokenAmount as RT,Typography as Zo}from"@rango-dev/ui";import Ms from"bignumber.js";import F,{useRef as ev,useState as tv}from"react";import{styled as bs}from"@rango-dev/ui";var xs=bs("div",{width:"100%","& .position-top__skeleton":{paddingTop:"$10"}}),Vd=bs("div",{paddingBottom:"$15",variants:{dense:{true:{paddingBottom:0}}}}),Kd=bs("div",{width:"100%",display:"flex"});import*as ei from"@radix-ui/react-collapsible";import{Button as BT,css as Wn,darkTheme as xe,Image as jd,styled as ze,Typography as MT}from"@rango-dev/ui";var LT=300,Xd=ze(ei.Root,{display:"flex",flexDirection:"column",alignItems:"start",overflowX:"auto",overflowY:"hidden",width:"100%",borderRadius:"$xm",variants:{selected:{true:{},false:{$$color:"$colors$neutral400",[`.${xe} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"}},listItem:{true:{$$color:"$colors$neutral400",[`.${xe} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"},false:{}}},compoundVariants:[{listItem:!1,selected:!0,css:{$$color:"$colors$secondary200",[`.${xe} &`]:{$$color:"$colors$secondary800"},backgroundColor:"$$color"}}]}),Yd=Wn({padding:"$10 $15"}),Zd=ze(BT,{backgroundColor:"transparent",border:"1px solid $secondary550",[`.${xe} &`]:{border:"1px solid $secondary"},transition:"background-color 0.3s ease","&:hover":{backgroundColor:"$secondary550",[`.${xe} &`]:{backgroundColor:"$secondary"},".allRoutesLabel":{$$color:"$colors$background",[`.${xe} &`]:{$$color:"$colors$foreground"},color:"$$color",transition:"color 0.3s ease"}}}),Jd=ze("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",[`.${xe} &`]:{$$color:"$colors$neutral500"},backgroundColor:"$$color"}},basic:{true:{borderTopRightRadius:"0",borderTopLeftRadius:"0"}},listItem:{true:{$$color:"$colors$neutral200",[`.${xe} &`]:{$$color:"$colors$neutral500"},backgroundColor:"$$color","&:hover":{"& .quote_container":{"& button":{backgroundColor:"$neutral500",[`.${xe} &`]:{backgroundColor:"$neutral200"}},backgroundColor:"$neutral500",[`.${xe} &`]:{backgroundColor:"$neutral200"}},backgroundColor:"$neutral300",[`.${xe} &`]:{backgroundColor:"$neutral400"}},cursor:"pointer"},false:{}}},compoundVariants:[{listItem:!0,selected:!0,css:{outline:"1px solid $secondary"}},{listItem:!1,selected:!0,css:{$$color:"$colors$secondary100",[`.${xe} &`]:{$$color:"$colors$secondary550"},backgroundColor:"$$color","&:hover":{backgroundColor:"$$color"}}},{listItem:!0,selected:!1,css:{cursor:"pointer","&:hover":{backgroundColor:"$neutral300",[`.${xe} &`]:{backgroundColor:"$neutral400"}}}}]}),Rd=Wn({width:"100%",padding:"$15 $15 $10 $15"}),em=Wn({display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingBottom:"$10",position:"relative"}),Xo=Wn({display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",".blockchainImage":{marginLeft:"-$8"}}),tm=Wn({display:"flex",alignItems:"center",".usd-value":{$$color:"$colors$neutral600",[`.${xe} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),om=ze(ei.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:{[`& ${jd}`]:{border:"1px $warning500 solid",borderRadius:"100%"}},false:{[`& ${jd}`]:{border:"1px transparent solid",borderRadius:"100%"}}},selected:{true:{},false:{$$color:"$colors$neutral400",[`.${xe} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"}},listItem:{true:{$$color:"$colors$neutral400",[`.${xe} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"},false:{}}},compoundVariants:[{listItem:!1,selected:!0,css:{$$color:"$colors$secondary200",[`.${xe} &`]:{$$color:"$colors$secondary800"},backgroundColor:"$$color"}}],".blockchains_section":{display:"none"},"@xs":{".blockchains_section":{display:"block"}}}),nm=ze("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"}}}}),rm=ze(Gr,{width:"100%",background:"inherit"}),Es=ze("div",{display:"flex",justifyContent:"center",alignItems:"center",padding:"$2",transition:`all ${LT}ms ease`,variants:{orientation:{down:{transform:"rotate(0)"},up:{transform:"rotate(180deg)"}}}}),XF=ze("div",{height:"$12",marginLeft:"$10",marginRight:"$10",borderLeft:"1px solid $foreground"}),im=ze("div",{display:"flex",justifyContent:"center",margin:"0 $15",borderTop:"1px solid",$$color:"$colors$neutral300",[`.${xe} &`]:{$$color:"$colors$neutral400"},borderColor:"$$color"}),am=ze("div",{width:"$16",height:"$16",justifyContent:"center",alignItems:"center",display:"flex"}),Is=ze(MT,{overflow:"hidden",textOverflow:"ellipsis",letterSpacing:.4}),sm=ze("div",{display:"flex",flexWrap:"wrap"}),As=ze("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"}}}}),lm=ze("div",{display:"flex"}),ti=ze("div",{width:"100%",borderTopWidth:"1px",borderTopStyle:"solid",borderTopColor:"$neutral",margin:"$5 0",[`.${xe} &`]:{borderTopColor:"$neutral800"}});import{i18n as At}from"@lingui/core";import{ChevronDownIcon as _T,CloseIcon as DT,Divider as ri,IconButton as $T,NumericTooltip as FT,QuoteCost as OT,Typography as yt}from"@rango-dev/ui";import Y,{useState as dm}from"react";import{css as PT,styled as oi}from"@rango-dev/ui";var ni=oi("div",{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"$5 0","&.total_payable_fee":{padding:"$12 0"}}),Ns=oi("div",{width:"100%",borderTop:"1px solid $neutral300",margin:"$10 0"}),cm=oi("div",{padding:"$20 0",display:"flex",flexDirection:"column","& .collapsible_trigger":{display:"flex",alignItems:"center"}}),pm=oi("div",{padding:"$20 $20 $10",position:"relative","._icon-button":{position:"absolute",zIndex:10,top:"$16",right:"$16"}}),um=PT({display:"flex",flexDirection:"row",alignItems:"center",padding:"$5","&:hover":{"& ._typography, & svg":{color:"$secondary"}}});var UT=i(t=>t.fee.isZero()?null:Y.createElement(ni,null,Y.createElement(yt,{variant:"label",size:"medium",color:"neutral600"},t.label),Y.createElement(yt,{variant:"label",size:"medium"},"$",B(t.fee,4,4))),"NonPayableFee");function Ws(t){let[e,o]=dm(!1),[n,r]=dm(!1),{steps:a,quote:s,fee:l,time:c,feeWarning:p,timeWarning:u,showModalFee:d,fullExpandedMode:h=!1}=t,g=s?.swaps??[],f=h?ro():I(),m=iu(g);return Y.createElement(Y.Fragment,null,Y.createElement(OT,{onClickFee:d?C=>{C.stopPropagation(),o(!e)}:void 0,fee:l,feeWarning:p,timeWarning:u,time:c,steps:a,tooltipGas:d?At.t("View more info"):void 0,tooltipContainer:f}),Y.createElement(Z,{container:f,open:e,anchor:h?"center":"bottom",styles:{container:{maxWidth:h?"484px":"unset"}},header:Y.createElement(pm,{style:{textAlign:h?"left":"center"}},Y.createElement(yt,{variant:"title",size:"medium"},At.t("Gas & Fee Explanation")),Y.createElement($T,{id:"widget-quote-cost-details-modal-close-icon-btn",onClick:()=>o(!1),variant:"ghost"},Y.createElement(DT,{color:"gray",size:14}))),onClose:()=>{o(!1)}},Y.createElement(cm,null,Y.createElement(yt,{variant:"title",size:"small"},At.t("Details")),Y.createElement(ri,{size:10}),Object.entries(m.payable).flatMap(([C,S])=>S.map((k,T)=>{let v=`payable-fee-${T}`,b=Ba(k);return Y.createElement(ni,{key:v},Y.createElement(yt,{variant:"label",size:"medium",color:"neutral600"},Ea(C,At.t)),Y.createElement(FT,{content:k.amount,container:f},Y.createElement(yt,{variant:"label",size:"medium"},B(k.amount,2,2)," ",k.asset.symbol," ($",B(b,4,4),")")))})),Y.createElement(ni,{className:"total_payable_fee"},Y.createElement(yt,{variant:"label",size:"medium"},At.t("Total Payable Fee")),Y.createElement(yt,{variant:"label",size:"medium"},"$",B(l,4,4))),Y.createElement(Ns,null),Object.keys(m.nonePayable).length&&Y.createElement(jr,{triggerAnchor:"bottom",onClickTrigger:()=>r(C=>!C),trigger:Y.createElement("div",{className:um()},Y.createElement(yt,{size:"small",variant:"body",color:"neutral700"},n?At.t("Hide non-payable fees"):At.t("Show non-payable fees")),Y.createElement(ri,{size:4,direction:"horizontal"}),Y.createElement(Vr,{orientation:n?"up":"down"},Y.createElement(_T,{size:12,color:"gray"}))),open:n},Y.createElement(yt,{size:"small",variant:"title"},At.t("Description")),Y.createElement(ri,{size:4}),Y.createElement(yt,{size:"small",variant:"body",color:"neutral700"},At.t(`The following fees are considered in the transaction output and
2
- you won\u2019t need to pay extra gas for them.`)),Y.createElement(ri,{size:10}),Object.entries(m.nonePayable).map(([C,S],k)=>{let T=ru(S),v=Ea(C,At.t),b=`non-payable-fee-${k}`;return Y.createElement(UT,{key:b,fee:T,label:v})}),Y.createElement(Ns,null)))))}i(Ws,"QuoteCostDetails");import{i18n as gm}from"@lingui/core";import{TokenAmount as hm}from"@rango-dev/ui";import ii from"react";import{css as zT,styled as QT}from"@rango-dev/ui";var mm=QT("div",{position:"relative",display:"flex",flexDirection:"column",width:"100%"}),fm=zT({height:"14px",marginLeft:"14px",position:"absolute",borderLeft:"1px solid $foreground",top:"42%"});function Bn(t){let{from:e,to:o,percentageChange:n,warningLevel:r}=t;return ii.createElement(mm,null,ii.createElement(hm,{direction:"horizontal",label:gm.t("Swap input"),type:"input",tooltipContainer:I(),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}}),ii.createElement("div",{className:fm()}),ii.createElement(hm,{direction:"horizontal",tooltipContainer:I(),label:gm.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(Bn,"QuoteSummary");import{i18n as Tm}from"@lingui/core";import{ChevronDownIcon as GT,ChevronRightIcon as VT,Divider as Bs,Image as KT,Tooltip as pi,Typography as si}from"@rango-dev/ui";import U from"react";import{useLayoutEffect as HT,useState as Mn}from"react";var ym=480,Sm=768,Cm=1024,km=1200,qT=i(()=>{let[t,e]=Mn(!1),[o,n]=Mn(!1),[r,a]=Mn(!1),[s,l]=Mn(!1),[c,p]=Mn(!1),u=i(()=>{e(window.innerWidth<=ym),n(window.innerWidth>ym&&window.innerWidth<=Sm),a(window.innerWidth>Sm&&window.innerWidth<=Cm),l(window.innerWidth>Cm&&window.innerWidth<=km),p(window.innerWidth>km)},"handleResize");return HT(()=>(u(),window.addEventListener("resize",u),()=>window.removeEventListener("resize",u)),[]),{isMobile:t,isTablet:o,isNotebook:r,isLargeScreen:s,isExtraLargeScreen:c}},"useScreenDetect"),ai=qT;var li=4,ci=6,Ln=i(t=>{let{content:e,src:o,className:n,open:r,state:a,container:s}=t,l=s||I();return U.createElement(pi,{container:l,side:"bottom",sideOffset:4,open:r,content:e},U.createElement(nm,{className:n,state:a},U.createElement(KT,{src:o,size:16})))},"ImageComponent");function vm(t){let{quoteRef:e,selected:o,setExpanded:n,steps:r,expanded:a,type:s,container:l}=t,c=l||I(),p=r.length,u=jp(r),{isTablet:d,isMobile:h}=ai();return U.createElement(om,{listItem:s==="list-item",ref:g=>e.current=g,selected:o,onClick:g=>{g.stopPropagation(),n(f=>!f)}},U.createElement("div",{className:Xo()},U.createElement(si,{variant:"body",size:"xsmall"},Tm.t("Via:")),U.createElement(Bs,{direction:"horizontal",size:4}),r.map((g,f)=>{let m=`item-${f}`,C=U.createElement(Es,null,U.createElement(VT,{size:12,color:"black"}));return h||d?U.createElement(U.Fragment,{key:m},U.createElement(Ln,{content:g.swapper.displayName,src:g.swapper.image,state:g.state,container:l}),f!==p-1&&U.createElement(U.Fragment,null,C)):U.createElement(U.Fragment,{key:m},p<=li||p>li&&f<li-1?U.createElement(U.Fragment,null,U.createElement(Ln,{content:g.swapper.displayName,src:g.swapper.image,state:g.state,container:l}),f!==p-1&&U.createElement(U.Fragment,null,C)):f===li-1&&U.createElement(pi,{container:c,side:"bottom",align:"end",sideOffset:4,content:U.createElement("div",{className:Xo()},C,r.map((S,k)=>{let T=`image-${k}`;return k>=f&&U.createElement(U.Fragment,{key:T},U.createElement(Ln,{content:S.swapper.displayName,src:S.swapper.image,state:S.state,open:!1}),k!==p-1&&U.createElement(U.Fragment,null,C))}))},U.createElement(As,{state:r.find((S,k)=>k>=f&&(S.state==="error"||S.state==="warning"))?.state},U.createElement(si,{size:"xsmall",variant:"body"},"+",p-f))))})),U.createElement("div",{className:Xo()},U.createElement("div",{className:"blockchains_section"},U.createElement("div",{className:Xo()},U.createElement(si,{variant:"body",size:"xsmall"},Tm.t("Chains:")),U.createElement(Bs,{direction:"horizontal",size:4}),u.map((g,f)=>U.createElement(U.Fragment,{key:g.displayName},u.length<=ci||u.length>ci&&f<ci-1?U.createElement(pi,{container:c,side:"bottom",content:g.displayName,sideOffset:4},U.createElement(Ln,{content:"",src:g.image,open:!1,className:f!==0?"blockchainImage":""})):f===ci-1&&U.createElement(pi,{container:c,side:"bottom",align:"end",sideOffset:4,content:U.createElement("div",{className:Xo()},u.map((m,C)=>C>=f&&U.createElement(Ln,{key:m.displayName,content:"",src:m.image,open:!1,className:C>f?"blockchainImage":"",container:l})))},U.createElement(As,{className:"blockchainImage"},U.createElement(si,{size:"xsmall",variant:"body"},"+",u.length-f))))),U.createElement(Bs,{direction:"horizontal",size:32}))),U.createElement(Es,{orientation:a?"up":"down"},U.createElement(GT,{size:12,color:"black"}))))}i(vm,"QuoteTrigger");function Ls(t){let{quote:e,input:o,output:n,error:r,warning:a,type:s,selected:l=!1,tagHidden:c=!0,showModalFee:p=!0,onClickAllRoutes:u,fullExpandedMode:d=!1,container:h}=t,g=y().blockchains(),{findToken:f}=y(),m=y().swappers(),{customSlippage:C,slippage:S}=y(),k=C||S,[T,v]=tv(t.expanded),b=ev(null),A=B(o.value,6,6),D=B(n.value,6,6),w=n.usdValue?B(n.usdValue,4,4):"",x=Pt(o.usdValue,n.usdValue??null),E=B(x,2,2),N=_t(x??0),M=i((le,at)=>le.map((G,P)=>{let q,V=r?.type===3&&r.swap.swapperId===G.swapperId,fe=r?.type===4&&r.recommendedSlippages?.has(P),ne=a?.type===2&&a.recommendedSlippages?.has(P),ge=V||fe,Fe=ne;ge?q="error":Fe&&(q="warning");let ve=ge?So.t("Slippage Error"):So.t("Slippage Warning");return V&&(ve=So.t("Bridge Limit Error")),{swapper:{displayName:rn(G.swapperId,m)??"",image:G.swapperLogo},from:{token:{displayName:G.from.symbol,image:G.from.logo},chain:{displayName:st(G.from.blockchain,g)??"",image:G.from.blockchainLogo},price:{value:P===0&&!at?B(o.value,6,6):B(G.fromAmount,6,6),usdValue:B((G.from.usdPrice??0)*parseFloat(G.fromAmount),4,4),realValue:P===0?o.value:G.fromAmount,realUsdValue:new Ms(G.from.usdPrice??0).multipliedBy(G.fromAmount).toString()}},to:{token:{displayName:G.to.symbol,image:G.to.logo},chain:{displayName:st(G.to.blockchain,g)||"",image:G.to.blockchainLogo},price:{value:B(G.toAmount,6,6),usdValue:B((G.to.usdPrice??0)*parseFloat(G.toAmount),4,4),realValue:G.toAmount,realUsdValue:new Ms(G.to.usdPrice??0).multipliedBy(G.toAmount).toString()}},state:q,alerts:ge||Fe?F.createElement(Vd,{dense:d},F.createElement(jT,{variant:"alarm",type:ge?"error":"warning",title:ve,footer:F.createElement(Kd,null,V&&F.createElement("div",null,F.createElement(Zo,{size:"xsmall",variant:"body",color:"neutral900"},r.fromAmountRangeError),F.createElement(Yo,{direction:"vertical",size:2}),F.createElement(Zo,{size:"xsmall",variant:"body",color:"neutral900"},So.t({id:"Yours: {amount} {symbol}",values:{amount:B(G.fromAmount,6,6),symbol:G?.from.symbol}}))),(fe||ne)&&!V&&F.createElement("div",null,F.createElement(Zo,{size:"xsmall",variant:"body",color:"neutral900"},So.t({id:"Minimum required slippage: {minRequiredSlippage}",values:{...r?.type===4&&{minRequiredSlippage:r.recommendedSlippages?.get(P)},...a?.type===2&&{minRequiredSlippage:a.recommendedSlippages?.get(P)}}})),F.createElement(Yo,{direction:"vertical",size:2}),F.createElement(Zo,{size:"xsmall",variant:"body",color:"neutral900"},So.t({id:"Yours: {userSlippage}",values:{userSlippage:k}}))))})):void 0,time:ln(G.estimatedTimeInSeconds),fee:B(Wa(G,f),2,2),internalSwaps:G.internalSwaps?M(G.internalSwaps):void 0}}),"getQuoteSteps"),W=M(e?.swaps??[]),j=W.length,te=h||I(),J=Yp(t.quote.tags||[]),L=!!u,X=dr(e?.swaps),se=ln(X),z=Mr(e?.swaps??[],f),me=B(z,2,2),vt=z.gte(new Ms(Up)),Ze=X/Qp>=zp;return d?F.createElement(XT,{selected:l,fee:me,time:se,tooltipContainer:ro(),steps:W,tags:J,quoteCost:F.createElement(Ws,{quote:e,fullExpandedMode:!0,time:se,fee:me,feeWarning:vt,timeWarning:Ze,showModalFee:p,steps:j}),percentageChange:E,warningLevel:N,outputPrice:{value:D,usdValue:w,realValue:n.value,realUsdValue:n.usdValue}}):F.createElement(Jd,{selected:l,listItem:s==="list-item",basic:s==="basic"},F.createElement("div",{className:Rd()},!c&&J.length?F.createElement(F.Fragment,null,F.createElement(lm,null,J.map((le,at)=>{let G=`${le.value}_${at}`;return F.createElement(F.Fragment,{key:G},F.createElement(ZT,{label:le.label,value:le.value}),F.createElement(Yo,{size:4,direction:"horizontal"}))})),F.createElement(ti,null),!L&&F.createElement(Yo,{size:4})):null,F.createElement("div",{id:"portal-root",className:em()},F.createElement(Ws,{quote:e,time:se,fee:me,feeWarning:vt,timeWarning:Ze,showModalFee:p,steps:j}),L&&F.createElement(Zd,{onClick:le=>{le.stopPropagation(),u()},size:"xxsmall",type:"secondary",variant:"default",css:{paddingLeft:"$10",paddingRight:"$10",paddingTop:"$5",paddingBottom:"$5"}},F.createElement(Zo,{color:"secondary",variant:"body",size:"xsmall",className:"allRoutesLabel"},So.t("See All Routes")))),s==="basic"&&F.createElement("div",{className:tm()},F.createElement(am,null,F.createElement(YT,{size:12,color:"gray"})),F.createElement(sm,null,F.createElement(Is,{size:"small",variant:"body"},`${A} ${W[0].from.token.displayName} = `),F.createElement(wm,{content:n.value,container:te,open:n.value?void 0:!1},F.createElement(Is,{size:"small",variant:"body"},"\xA0",`${D} ${W[W.length-1].to.token.displayName}`))),F.createElement(wm,{content:n.usdValue,container:te},F.createElement(Yo,{size:2,direction:"horizontal"}),F.createElement(Zo,{color:"$neutral600",size:"xsmall",variant:"body"},`($${w})`))),s==="list-item"&&F.createElement(RT,{tooltipContainer:te,type:"output",direction:"vertical",price:{value:D,usdValue:w,realValue:n.value,realUsdValue:n.usdValue},token:{displayName:W[j-1].to.token.displayName,image:W[j-1].to.token.image},chain:{image:W[j-1].to.chain.image},percentageChange:E,warningLevel:N}),s==="swap-preview"&&F.createElement(F.Fragment,null,F.createElement(Bn,{from:W[0].from,to:W[j-1].to,percentageChange:E,warningLevel:N}),F.createElement(Yo,{size:4}))),F.createElement(Xd,{selected:l,listItem:s==="list-item",open:T,className:"quote_container",onOpenChange:v},F.createElement(vm,{type:s,quoteRef:b,selected:l,setExpanded:v,container:te,expanded:T,steps:W}),F.createElement(rm,{open:T},F.createElement(im,null),F.createElement("div",{className:Yd()},W.map((le,at)=>{let G=`item-${at}`;return F.createElement(JT,{type:"quote-details",key:G,tooltipContainer:te,step:le,hasSeparator:at!==W.length-1,state:le.state})})))))}i(Ls,"Quote");import{Divider as iv,Skeleton as av}from"@rango-dev/ui";import Ot from"react";import{darkTheme as ov,styled as ui}from"@rango-dev/ui";var bm=ui("div",{$$color:"$colors$neutral100",[`.${ov} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",borderBottomLeftRadius:"$xm",borderBottomRightRadius:"$xm",padding:"$15",variants:{rounded:{true:{borderRadius:"$xm"}},expanded:{true:{paddingBottom:"3px"},false:{paddingBottom:"$12"}}}}),xm=ui("div",{paddingTop:"$2"}),Em=ui("div",{paddingLeft:"$8"}),Im=ui("div",{borderLeft:"1px dashed $foreground",minHeight:" 0",margin:"0px 11.5px",alignSelf:"stretch",variants:{hideSeparator:{true:{minHeight:"unset",height:"0"}}}});import{ChainToken as $m,Divider as St,Skeleton as tt}from"@rango-dev/ui";import Q from"react";import{css as nv,styled as Ft}from"@rango-dev/ui";var Ps=Ft("div",{display:"flex"}),Am=Ft("div",{padding:"$10 $0 $20"}),Nm=Ft("div",{padding:"14px $0 $20 $0",display:"flex",flexDirection:"column"}),Wm=Ft("div",{display:"flex",justifyContent:"start",alignItems:"center"}),Bm=Ft("div",{display:"flex",justifyContent:"space-between",alignItems:"end"}),Mm=Ft("div",{height:"$24",marginLeft:"13px",borderLeft:"1px solid $neutral700"}),Lm=Ft("div",{width:"65%",display:"flex",justifyContent:"start"}),Pm=Ft("div",{display:"flex",flexDirection:"column",alignItems:"start",flexGrow:1,maxWidth:"148px"}),_m=Ft("div",{padding:"$15 $0 $15 $0"}),Dm=nv({display:"flex",justifyContent:"space-between",alignItems:"center"});function Pn(t){let{type:e,tagHidden:o=!0}=t,n=Q.createElement(Bm,null,Q.createElement(Lm,null,Q.createElement($m,{loading:!0,size:"medium",chainImage:"",tokenImage:""}),Q.createElement(St,{size:8,direction:"horizontal"}),Q.createElement(Pm,null,Q.createElement(tt,{height:10,width:60,variant:"rounded"}),Q.createElement(St,{size:4}),Q.createElement(tt,{height:15,variant:"rounded"}))),Q.createElement(tt,{height:12,width:64,variant:"rounded"})),r=e==="basic"&&!o;return Q.createElement("div",null,!o&&Q.createElement(Q.Fragment,null,Q.createElement(Ps,null,Q.createElement(tt,{width:65,height:20,variant:"rounded"}),Q.createElement(St,{size:4,direction:"horizontal"}),Q.createElement(tt,{width:65,height:20,variant:"rounded"}),Q.createElement(St,{size:4,direction:"horizontal"}),Q.createElement(tt,{width:65,height:20,variant:"rounded"})),Q.createElement(ti,null),!r&&Q.createElement(St,{size:4})),Q.createElement("div",{className:Dm()},Q.createElement(Ps,null,Q.createElement(tt,{width:60,height:10,variant:"rounded"}),Q.createElement(St,{size:4,direction:"horizontal"}),Q.createElement(tt,{width:60,height:10,variant:"rounded"}),Q.createElement(St,{size:4,direction:"horizontal"}),Q.createElement(tt,{width:60,height:10,variant:"rounded"})),r&&Q.createElement(tt,{width:85,height:24,variant:"rounded"})),e==="basic"&&Q.createElement(Am,null,Q.createElement(tt,{height:15,width:148,variant:"rounded"})),e==="list-item"&&Q.createElement(Nm,null,Q.createElement(Wm,null,Q.createElement($m,{loading:!0,size:"medium",chainImage:"",tokenImage:""}),Q.createElement(St,{direction:"horizontal",size:4}),Q.createElement(tt,{height:15,width:150,variant:"rounded"})),Q.createElement(St,{size:10}),Q.createElement(tt,{height:10,width:184,variant:"rounded"})),e==="swap-preview"&&Q.createElement(Q.Fragment,null,Q.createElement(St,{size:4}),Q.createElement(_m,null,n,Q.createElement(Mm,null),n),Q.createElement(St,{size:12})))}i(Pn,"QuoteSummarySkeleton");import{ChainToken as Qm,Divider as Ds,NextIcon as rv,Skeleton as di}from"@rango-dev/ui";import Ee from"react";import{styled as _n}from"@rango-dev/ui";var Fm=_n("div",{display:"flex",alignItems:"start"}),Om=_n("div",{flexGrow:1,paddingTop:"$5",paddingBottom:"$10",display:"flex",alignItems:"center",variants:{extraSpace:{true:{paddingBottom:"$40"}}}}),_s=_n("div",{display:"flex",alignItems:"center",flexGrow:1}),Um=_n("div",{margin:"$0 $2",padding:"$4",display:"flex",justifyContent:"center",alignItems:"center"}),zm=_n("div",{display:"flex",alignItems:"center"});function Nt(t){let{separator:e=!0}=t;return Ee.createElement(Ee.Fragment,null,Ee.createElement(zm,null,Ee.createElement(di,{height:22,width:22,variant:"circular"}),Ee.createElement(Ds,{direction:"horizontal",size:8}),Ee.createElement(di,{height:15,width:148,variant:"rounded"})),Ee.createElement(Fm,null,Ee.createElement(Im,{hideSeparator:!e}),Ee.createElement(Om,{extraSpace:e},Ee.createElement(_s,null,Ee.createElement(Qm,{size:"small",loading:!0,chainImage:"",tokenImage:""}),Ee.createElement(Ds,{direction:"horizontal",size:8}),Ee.createElement(di,{height:12,variant:"rounded"})),Ee.createElement(Um,null,Ee.createElement(rv,{color:"gray",size:16})),Ee.createElement(_s,null,Ee.createElement(Qm,{size:"small",loading:!0,chainImage:"",tokenImage:""}),Ee.createElement(Ds,{direction:"horizontal",size:8}),Ee.createElement(di,{height:12,variant:"rounded"})))))}i(Nt,"StepSkeleton");function Dn(t){let{type:e,expanded:o,tagHidden:n=!1}=t;return Ot.createElement(bm,{expanded:o,rounded:e!=="basic"},Ot.createElement(Pn,{type:e,tagHidden:n}),Ot.createElement(xm,null,Ot.createElement(av,{height:15,variant:"rounded"})),o&&Ot.createElement(Em,null,Ot.createElement(iv,{size:24}),Ot.createElement(Nt,null),Ot.createElement(Nt,null),Ot.createElement(Nt,{separator:!1})))}i(Dn,"QuoteSkeleton");function Co(t){let{quote:e,type:o,loading:n,error:r,warning:a,expanded:s=!1,tagHidden:l,onClick:c,showModalFee:p,selected:u,onClickAllRoutes:d,fullExpandedMode:h=!1,container:g}=t,{inputAmount:f,inputUsdValue:m}=O(),C=e?.outputAmount?new sv(e?.outputAmount):null,S=e?ct(e):null,T=!(r&&(r.type===0||r.type===1))&&e&&!n;return n?mi.createElement(xs,null,mi.createElement(Dn,{tagHidden:l,type:o,expanded:s})):T?mi.createElement(xs,{onClick:()=>c?.(e)},mi.createElement(Ls,{quote:e,error:r,container:g,showModalFee:p,warning:a,tagHidden:l,selected:u,type:o,expanded:s,onClickAllRoutes:d,fullExpandedMode:h,input:{value:f,usdValue:m?.toString()??""},output:{value:C?.toString()??"",usdValue:S?.toString()??""}})):null}i(Co,"QuoteInfo");import{calculatePendingSwap as uv}from"@rango-dev/queue-manager-rango-preset";import{useEffect as dv}from"react";import{useRef as lv,useState as cv}from"react";var pv=2e3;function fi({request:t}){let[e,o]=cv(!1),n=lv(null),r=i(()=>n.current?.abort(),"cancelFetch"),a=i(async l=>(await new Promise(c=>setTimeout(c,pv)),await s(l,!1)),"retryFetch"),s=i(async(l,c=!1)=>{r(),n.current=new AbortController,o(!0);try{let p=await t(l,{signal:n.current.signal});return n.current=null,p}catch(p){if(c)return await a(l);throw p}finally{o(!1)}},"fetch");return{fetch:s,loading:e,cancelFetch:r}}i(fi,"useFetch");function Hm(){let{fetch:t,loading:e,cancelFetch:o}=fi({request:async(n,r)=>await xt().confirmRoute(n,r)});return{fetch:t,loading:e,cancelFetch:o}}i(Hm,"useFetchConfirmQuote");function gi(t){if(!t.swaps)throw new Error(R().noResultError.title,{cause:{type:0,diagnosisMessage:t.diagnosisMessages?.[0]}});let e=$s(t.swaps);if(e)throw new Error(e.message,{cause:e.options})}i(gi,"throwErrorIfResponseIsNotValid");function $s(t){if(tu(t)){let{swap:n,recommendation:r,fromAmountRangeError:a}=ou(t);return{message:"bridge limit error",options:{type:3,swap:n,recommendation:r,fromAmountRangeError:a}}}let o=au(t);if(o){let n=Lr(t);return{message:"",options:{type:4,recommendedSlippages:o,minRequiredSlippage:n}}}return null}i($s,"getQuoteError");function qm(t){let{currentQuote:e,previousQuote:o,meta:n,selectedWallets:r,userSlippage:a,findToken:s}=t,l={quote:null,balance:null},c=Fo({previousQuote:o,currentQuote:e,findToken:s,userSlippage:a});c&&(l.quote=c);let p=cu(e,r,n.blockchains);return p.length===0||(l.balance={messages:p}),l}i(qm,"generateWarnings");function hi(t){return t?.code==="ERR_CANCELED"?{swap:null,error:{type:2},warnings:null}:t.cause?{swap:null,error:t.cause,warnings:null}:t?.code==="ERR_BAD_REQUEST"?{swap:null,error:{type:0,diagnosisMessage:t.response.data.error},warnings:null}:{swap:null,error:{type:1},warnings:null}}i(hi,"handleQuoteErrors");function Fs(){let{fromToken:t,toToken:e,inputAmount:o,inputUsdValue:n,setSelectedQuote:r,selectedQuote:a,customDestination:s,resetAlerts:l}=O(),{slippage:c,customSlippage:p}=y(),u=y().getDisabledLiquiditySources(),d=y().blockchains(),h=y().tokens(),{findToken:g}=y(),f=p||c,{fetch:m,cancelFetch:C,loading:S}=Hm();return dv(()=>C,[]),{loading:S,fetch:i(async T=>{let v=T.selectedWallets,b=T?.customDestination??s;if(!t||!e||!o)return{quote:null,swap:null,error:null,warnings:null};let A=v.reduce((w,x)=>(w[x.chain]=x.address,w),{}),D={requestId:a?.requestId||"",selectedWallets:A,destination:b||void 0};try{return await m(D,!0).then(w=>{let{result:x}=w;if(!x)throw new Error("Error fetching updated route");gi({diagnosisMessages:x.diagnosisMessages,requestId:x.requestId,swaps:x.result?.swaps});let E={outputAmount:x.result?.outputAmount,requestId:x.requestId,resultType:x.result?.resultType,swaps:x.result?.swaps||[],validationStatus:x.validationStatus,requestAmount:x.requestAmount};r(E);let N={slippage:f.toString(),disabledSwappersGroups:u},M=qm({previousQuote:a??void 0,currentQuote:E,meta:{blockchains:d},selectedWallets:v,userSlippage:f,inputUsdValue:n,findToken:g});l();let W=!!M.balance,j=uv(o.toString(),x,lu(v),N,!W,{blockchains:d,tokens:h});return{quote:E,swap:j,error:null,warnings:M}})}catch(w){return hi(w)}},"fetch"),cancelFetch:C}}i(Fs,"useConfirmSwap");var vv=hv("div",{width:"100%",display:"flex",justifyContent:"space-between",[`& ${Gm}`]:{width:"$48",height:"$48"}}),wv=zs({flexGrow:1,paddingRight:"$10"}),bv=zs({width:"$24",height:"$24",display:"flex",justifyContent:"center",alignItems:"center"}),xv=zs({display:"flex",justifyContent:"space-between",alignItems:"center"});function Vm(){let{selectedQuote:t,setInputAmount:e,selectedWallets:o,quoteWalletsConfirmed:n,customDestination:r,quoteWarningsConfirmed:a}=O(),s=Tv(),[l,c]=$n(""),p=!n,[u,d]=$n(!1),[h,g]=$n(!1),{isActiveTab:f}=re(),m=y().getDisabledLiquiditySources(),C=kv(m),{manager:S}=mv(),{fetch:k,loading:T,cancelFetch:v}=Fs(),[b,A]=$n({swap:null,error:null,warnings:null}),[D,w]=$n(!1),x=i(async({selectedWallets:L,customDestination:X})=>{let se=await k?.({selectedWallets:L,customDestination:X});return A(se),se},"onConfirmSwap"),E=i(async()=>{if(b.swap&&n)try{await S?.create("swap",{swapDetails:b.swap},{id:b.swap.requestId});let L=`../${$.swaps}/${b.swap.requestId}`;s(L,{replace:!0}),setTimeout(()=>{e("")},0)}catch(L){c("Error: "+L?.message)}},"addNewSwap"),N=i(async()=>{g(!0),await E(),g(!1)},"onConfirm"),M=i(async()=>{b.warnings?.quote&&Kp(b.warnings.quote)&&!a?w(!0):await N()},"onStartConfirmSwap"),W=i(async()=>{A({error:null,swap:null,warnings:null}),k({selectedWallets:o,customDestination:r}).then(L=>{A(L)}).catch(L=>console.error(L))},"onRefresh");yi(()=>{!!C.current.length&&!m.length&&W(),C.current=m},[m.length]),yi(()=>{p&&v()},[p]),yi(()=>{p&&d(p)},[p]),yi(()=>{p||k({selectedWallets:o,customDestination:r}).then(L=>A(L)).catch(L=>console.error(L))},[]),Cv(()=>{t?.requestId||s(`../${location.search}`)},[t?.requestId]);let j=b.warnings?.quote??null,te=b.error,J=[];if(l&&J.push(Le.createElement(fv,{type:"error",variant:"alarm",title:l})),j||te){let L=`../${$.settings}`;J.push(Le.createElement(Nn,{warning:j,error:te,couldChangeSettings:!1,refetchQuote:W,showWarningModal:D,confirmationDisabled:!f,onOpenWarningModal:()=>w(!0),onCloseWarningModal:()=>w(!1),onConfirmWarningModal:async()=>{w(!1),await E()},onChangeSettings:()=>s(L)}))}return Le.createElement(oe,{header:{title:Os.t("Confirm Swap"),onWallet:()=>{let L=`../${$.wallets}`;s(L)}},footer:Le.createElement(vv,null,Le.createElement("div",{className:wv()},Le.createElement(gv,{id:"widget-confirm-swap-start-btn",variant:"contained",type:"primary",size:"large",fullWidth:!0,loading:T||h,disabled:!!b.error||!f,onClick:M},Os.t("Start Swap"))),Le.createElement(Gm,{id:"widget-confirm-swap-wallet-icon-btn",variant:"contained",type:"primary",size:"large",loading:T||h,disabled:!f,onClick:d.bind(null,!0)},Le.createElement(Sv,{size:24})))},u&&Le.createElement(Id,{open:u,onClose:()=>d(!1),onCancel:v,loading:T,onCheckBalance:x}),Le.createElement(ie,null,Le.createElement("div",{className:xv()},Le.createElement(yv,{variant:"title",size:"small"},Os.t("You get")),Le.createElement("div",{className:bv()},Le.createElement(Or,{onClick:!T&&!u&&!D?W:void 0}))),Le.createElement(Us,{size:"12"}),Au(J.map((L,X)=>({element:L,key:`alert-${X}`})),Le.createElement(Us,{size:10})),J.length>0?Le.createElement(Us,{size:10}):null,Le.createElement(Co,{quote:t,type:"swap-preview",expanded:!0,tagHidden:!0,error:b.error,loading:T,warning:b.warnings?.quote??null})))}i(Vm,"ConfirmSwapPage");import{i18n as Ut}from"@lingui/core";import{Button as Js,CustomTokensZeroStateDarkIcon as zv,CustomTokensZeroStateIcon as Qv,DeleteIcon as Hv,Divider as zn,IconButton as qv,MessageBox as Gv,NotFound as Vv,styled as el}from"@rango-dev/ui";import de,{useState as Rs}from"react";import{useNavigate as Kv}from"react-router-dom";import{CloseIcon as Iv,IconButton as Av,SearchIcon as Nv,TextField as Wv}from"@rango-dev/ui";import Fn from"react";import{styled as Ev}from"@rango-dev/ui";var Km=Ev("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:c,...p}=t;return Fn.createElement(Wv,{prefix:Fn.createElement(Km,null,Fn.createElement(Nv,{color:"black"})),suffix:!!s.length&&Fn.createElement(Av,{variant:"ghost",onClick:()=>c?.(""),size:"small"},Fn.createElement(Iv,{color:"gray",size:10})),fullWidth:o,color:n,variant:e,style:{padding:10,borderRadius:25,alignItems:"center",...l},size:r,value:s,onChange:a,...p})}i(Ct,"SearchInput");import{i18n as Zs}from"@lingui/core";import{darkTheme as rf,Divider as Ro,ExternalLinkIcon as Lv,Image as Pv,ListItemButton as _v,NotFound as Dv,PinIcon as $v,Skeleton as af,Typography as ki,VirtualizedList as Fv}from"@rango-dev/ui";import H from"react";import{Divider as of,ListItem as Mv,Skeleton as On}from"@rango-dev/ui";import kt from"react";import{css as Jo,darkTheme as jm,ImageContainer as Bv,styled as ut,Typography as Xm}from"@rango-dev/ui";var Qs=Jo({position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:100,overflow:"hidden"}),Hs=Jo({position:"relative",height:12,width:"30%",maxWidth:"150px"}),qs=Jo({position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",bottom:"-8px"}),Gs=Jo({transform:"translateY(12px)",visibility:"hidden",display:"flex","& a":{display:"flex",justifyContent:"center",alignItems:"center",fontSize:"$12",lineHeight:"$16",$$color:"$colors$neutral600",[`.${jm} &`]:{$$color:"$colors$neutral700"},color:"$$color",textDecoration:"none"}}),Vs=Jo({}),Ks=Jo(),Ym=ut("div",{display:"flex",flexDirection:"column",flexGrow:1,overflow:"hidden",justifyContent:"center"}),js=ut("div",{display:"flex",alignItems:"center","._typography":{textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:100,overflow:"hidden"}}),Si=ut("ul",{flexGrow:1,padding:0,margin:0,listStyle:"none","& li":{alignItems:"none","&:hover":{[`& .${Hs}`]:{[`& .${Gs}`]:{position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",visibility:"visible"},[`& .${Vs}`]:{bottom:"-15px"},[`& .${Qs}`]:{position:"absolute",transform:"translateY(-12px)",visibility:"hidden"},[`& .${qs}`]:{position:"absolute",transform:"translateY(-12px)",bottom:"-10px"}}}}}),Xs=ut("div",{paddingLeft:"$5",paddingRight:"$5",borderRadius:"$md",display:"flex",alignItems:"center"}),Ys=ut(Xm,{}),Zm=ut("div",{textAlign:"right",width:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",[`& .${Ks}`]:{$$color:"$colors$neutral600",[`.${jm} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),Ci=ut("div",{display:"flex",alignItems:"end",flexDirection:"column"}),HU=ut("div",{display:"flex",alignItems:"center"}),Jm=ut("div",{position:"relative",[`& ${Bv}`]:{borderRadius:"$xm",overflow:"hidden"}}),Rm=ut("div",{position:"absolute",backgroundColor:"$neutral100",padding:"$4",borderRadius:"50%",bottom:-6,right:-6}),ef=ut(Xm,{width:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}),tf=ut("a",{"& svg:hover":{color:"$colors$info"}});function nf(t){return kt.createElement(Si,null,Array.from(Array(t.size),e=>kt.createElement(Mv,{key:e,hasDivider:!0,start:kt.createElement(On,{variant:"circular",width:35,height:35}),end:kt.createElement(Ci,null,kt.createElement(On,{variant:"text",size:"large",width:70}),kt.createElement(of,{size:4}),kt.createElement(On,{variant:"text",size:"medium",width:50})),title:kt.createElement("div",null,kt.createElement(On,{variant:"text",size:"large",width:90}),kt.createElement(of,{size:4}),kt.createElement(On,{variant:"text",size:"medium",width:90}))})))}i(nf,"LoadingTokenList");var Ov=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:Hs()},o?H.createElement("div",{className:Qs()},o):H.createElement(js,{className:qs()},H.createElement(ki,{variant:"title",size:"xmedium"},r.symbol),H.createElement(Ro,{direction:"horizontal",size:4}),H.createElement(Xs,{css:a},H.createElement(Ys,{variant:"body",size:"xsmall",css:s},r.blockchain))),!!e&&H.createElement("div",{className:`${Gs()} ${!o&&Vs()}`},l>10?`${e.slice(0,5)}...${e.slice(l-6,l)}`:e," ",H.createElement(Ro,{size:4,direction:"horizontal"}),H.createElement(tf,{href:n,target:"_blank",rel:"nofollow noreferrer",onClick:c=>c.stopPropagation()},H.createElement(Lv,{size:12}))))},"renderDesc");function Un(t){let{list:e,searchedFor:o="",onChange:n,selectedBlockchain:r,showTitle:a=!0,action:s}=t,l=y().fetchStatus,c=y().blockchains(),{getBalanceFor:p,fetchingWallets:u}=y(),{isTokenPinned:d}=y(),h=i(f=>{let m=hr(p(f));return s?s(f):u?H.createElement(Ci,null,H.createElement(af,{variant:"text",size:"large",width:70}),H.createElement(Ro,{size:4}),H.createElement(af,{variant:"text",size:"medium",width:50})):m&&H.createElement(Zm,null,H.createElement(ef,{variant:"title",size:"small"},m.amount),H.createElement("div",null),m.usdValue&&H.createElement(ki,{variant:"body",className:Ks(),size:"xsmall"},`$${m.usdValue}`))},"endRenderer"),g=i(()=>H.createElement(Fv,{itemContent:f=>{let m=e[f],C=m.address||"",S=c.find(b=>b.name===m.blockchain),k=qa(S.color,"main"),T={$$color:k.main150,[`.${rf} &`]:{$$color:k.main750},backgroundColor:"$$color"},v={$$color:k.main750,[`.${rf} &`]:{$$color:k.main150},color:"$$color"};return H.createElement("div",{style:{paddingRight:5}},H.createElement(_v,{style:{width:"100%",overflow:"hidden",height:"60px"},"tab-index":f,key:`${m.symbol}${m.address}`,id:`${m.symbol}${m.address}`,className:"widget-token-list-item-btn",hasDivider:!0,onClick:()=>n&&n(e[f]),start:H.createElement(Jm,null,H.createElement(Pv,{src:m.image,size:30}),t.type!=="custom-token"&&d(m,t.type)&&H.createElement(Rm,null,H.createElement($v,{size:12,color:"gray"}))),title:S?.type==="COSMOS"||m.name||!m.name&&!C?H.createElement(js,null,H.createElement(ki,{variant:"title",size:"xmedium"},m.symbol),H.createElement(Ro,{direction:"horizontal",size:4}),H.createElement(Xs,{css:T},H.createElement(Ys,{variant:"body",size:"xsmall",css:v},m.blockchain))):void 0,description:S?.info&&C&&S.type!=="COSMOS"?Uv({address:C,token:e[f],customCssForTag:T,customCssForTagTitle:v,name:m.name,url:S.info.addressUrl.split("{wallet}").join(C)}):m.name||void 0,end:h(m)}))},totalCount:e.length,key:`${r}-${o}`}),"renderList");return H.createElement(H.Fragment,null,a&&H.createElement(H.Fragment,null,H.createElement(ki,{variant:"label",size:"large"},Zs.t("Select Token")),H.createElement(Ro,{size:4})),H.createElement(Ym,null,H.createElement(Ro,{size:4}),l==="loading"&&H.createElement(nf,{size:Ov}),l==="success"&&(e.length?H.createElement(Si,{as:"ul"},g()):!!o&&H.createElement(Dv,{title:Zs.t("No results found"),description:Zs.t("Try using different keywords")}))))}i(Un,"TokenList");var jv=el("div",{display:"flex",justifyContent:"space-between",flexDirection:"column",flex:1}),Xv=el("div",{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",flex:"0.75"}),Yv=el(qv,{"&:hover":{"& svg":{color:"$secondary550"}}});function sf(){let[t,e]=Rs(""),{deleteCustomToken:o}=y(),n=y().customTokens(),{fromToken:r,toToken:a,setFromToken:s,setToToken:l}=O(),{mode:c}=Qo({}),p=Kv(),[u,d]=Rs(!1),[h,g]=Rs(),f=i(k=>{let T=k.target.value;e(T)},"handleSearch"),m=c==="dark",C=n.filter(k=>Je(k.symbol,t)||Je(k.address||"",t)||Je(k.name||"",t)),S=i(()=>{if(h){let k=a?lt(a):null,T=r?lt(r):null,v=lt(h);k===v?l({token:null}):T===v&&s({token:null}),o(h)}d(!1)},"handleDeleteCustomToken");return de.createElement(oe,{header:{title:Ut.t("Custom Tokens")}},de.createElement(ie,null,de.createElement(jv,null,n.length?de.createElement(de.Fragment,null,de.createElement(Ct,{value:t,setValue:e,fullWidth:!0,color:"light",variant:"contained",placeholder:Ut.t("Search Token"),onChange:f}),de.createElement(zn,{size:16}),de.createElement(Un,{list:C,type:"custom-token",searchedFor:t,showTitle:!1,action:k=>de.createElement(Yv,{id:"widget-custom-token-delete-icon-btn",variant:"ghost",onClick:()=>{d(!0),g(k)}},de.createElement(Hv,{size:12,color:"gray"}))})):de.createElement(Xv,null,de.createElement(Vv,{icon:m?de.createElement(zv,{size:200}):de.createElement(Qv,{size:200}),title:Ut.t("No custom tokens"),description:Ut.t("press the button to add your custom token")})),de.createElement(zn,{size:20}),de.createElement(Js,{id:"widget-custom-token-add-btn",type:"primary",variant:"contained",size:"large",onClick:()=>p($.addCustomTokens)},Ut.t("Add Custom Token"))),de.createElement(Z,{open:u,dismissible:!0,onClose:()=>d(!1),container:I()},de.createElement(Gv,{title:Ut.t("Delete Custom Token"),type:"error",description:Ut.t("Are you sure you want to Delete this Token?")},de.createElement(zn,{size:40}),de.createElement(zn,{size:10}),de.createElement(Js,{fullWidth:!0,id:"widget-custom-token-delete-modal-yes-btn",variant:"contained",type:"primary",size:"large",onClick:S},Ut.t("Yes, Delete it")),de.createElement(zn,{size:12}),de.createElement(Js,{id:"widget-custom-token-delete-modal-no-btn",fullWidth:!0,variant:"outlined",type:"primary",size:"large",onClick:()=>d(!1)},Ut.t("No, Continue"))))))}i(sf,"CustomTokensPage");import{i18n as He}from"@lingui/core";import{useManager as gw}from"@rango-dev/queue-manager-react";import{Button as sl,darkTheme as hw,Divider as To,MessageBox as yw,NotFound as Sw,styled as ll,Typography as wi}from"@rango-dev/ui";import{TransactionStatus as qn}from"rango-types";import ae,{useMemo as Ef,useState as bi}from"react";import{useNavigate as Cw}from"react-router-dom";import{FilterIcon as nw,Popover as rw}from"@rango-dev/ui";import ko from"react";import{css as Zv,darkTheme as Ti,IconButton as Jv,styled as Qn}from"@rango-dev/ui";var tl=Qn("div",{position:"relative","&::before":{position:"absolute",right:"1px",top:"-1px",width:"$8",height:"$8",borderRadius:"100%",backgroundColor:"$neutral300",[`.${Ti} &`]:{backgroundColor:"$neutral400"},padding:"$2"},variants:{isSelect:{true:{"&::before":{content:""}}}}}),lf=Qn(Jv,{width:"$36",height:"$36",position:"relative",padding:"0",overflow:"unset",backgroundColor:"$neutral300",[`.${Ti} &`]:{backgroundColor:"$neutral400"},"&:hover":{backgroundColor:"$secondary100",[`.${Ti} &`]:{backgroundColor:"$neutral"},[`& ${tl}::before`]:{backgroundColor:"$secondary100",[`.${Ti} &`]:{backgroundColor:"$neutral"}}},variants:{isSelect:{true:{border:"1px solid $secondary"}}}}),cf=Qn("div",{position:"absolute",width:"$6",height:"$6",display:"flex",justifyContent:"center",alignItems:"center",borderRadius:"3px",top:"$0",right:"1px",backgroundColor:"$secondary500"}),pf=Qn("div",{padding:"$15",borderRadius:"$sm",width:"248px",backgroundColor:"$background",zIndex:10}),uf=Zv({display:"flex",justifyContent:"space-between",alignItems:"center"}),df=Qn("ul",{margin:0,listStyle:"none",height:"100%",padding:0,".item-start-container":{paddingRight:"0 !important"}});import{i18n as mf}from"@lingui/core";import{Button as Rv,Divider as ff,ListItemButton as ew,Radio as tw,RadioRoot as ow,Typography as gf}from"@rango-dev/ui";import ot from"react";function hf(t){let{filterBy:e,onClickItem:o}=t;return ot.createElement(pf,null,ot.createElement("div",{className:uf()},ot.createElement(gf,{size:"small",variant:"body"},mf.t("Status")),ot.createElement(Rv,{id:"widget-filter-selector-reset-btn",variant:"ghost",size:"xxsmall",onClick:()=>o("")},mf.t("Reset"))),ot.createElement(ff,{size:10}),ot.createElement(ow,{value:e},ot.createElement(df,null,t.list.map((n,r)=>ot.createElement(ew,{key:n.id,style:{height:"40px",width:"100%"},selected:!1,hasDivider:t.list.length-1!=r,id:n.id,title:ot.createElement(ot.Fragment,null,ot.createElement(ff,{direction:"horizontal",size:4}),ot.createElement(gf,{size:"medium",variant:"body"},n.title)),start:ot.createElement(tw,{value:n.id}),onClick:o})))))}i(hf,"FilterSelectorContent");function ol(t){let{onClickItem:e,onOpenChange:o,filterBy:n,list:r,open:a}=t;return ko.createElement("div",null,ko.createElement(rw,{open:a,align:"end",onOpenChange:o,container:I(),content:ko.createElement(hf,{list:r,filterBy:n,onClickItem:s=>{e(s),o(!1)}})},ko.createElement(lf,{id:"widget-filter-selector-filter-icon-btn",variant:"default",isSelect:!!n,onClick:()=>o(!t.open)},ko.createElement(tl,{isSelect:!!n},ko.createElement(nw,{size:16,color:"black"}),!!n&&ko.createElement(cf,null)))))}i(ol,"FilterSelector");import{i18n as sw}from"@lingui/core";import{Divider as Tf,GroupedVirtualizedList as lw,Skeleton as cw,SwapListItem as vf,Typography as pw}from"@rango-dev/ui";import Qe,{useCallback as wf,useEffect as uw,useRef as dw,useState as mw}from"react";function yf(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(yf,"calculateGroupsSoFar");import{css as iw,darkTheme as aw,styled as Hn}from"@rango-dev/ui";var nl=iw(),Sf=Hn("div",{display:"flex",justifyContent:"center",alignItems:"center",padding:"$5"}),rl=Hn("div",{width:"100%",display:"flex",flexDirection:"column",backgroundColor:"$background",padding:"$10 $5 0 $5",[`& .${nl}`]:{$$color:"$colors$neutral600",[`.${aw} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),il=Hn("div",{display:"flex",justifyContent:"flex-start",padding:"$2"}),Cf=Hn("div",{gap:"$10",display:"flex",flexDirection:"column"}),kf=Hn("div",{height:"100%",display:"flex",justifyContent:"center",alignItems:"center"});var fw=10;function al(t){let{list:e,onSwapClick:o,groupBy:n,isLoading:r}=t,[a,s]=mw([]),l=dw(0),{swaps:c,groupCounts:p,groups:u}=n(e),d=wf(yf,[]),h=wf(()=>{let g=e.length-l.current;g&&(l.current+=Math.min(g,fw),s(d(p,l.current)))},[e.length]);if(uw(()=>{r||h()},[r,h]),r){let g=[1,2];return Qe.createElement(Qe.Fragment,null,[g,g].map((m,C)=>Qe.createElement(rl,{key:C},Qe.createElement(il,null,Qe.createElement(cw,{variant:"text",width:60,size:"small"}),Qe.createElement(Tf,{size:16})),Qe.createElement(Tf,{size:4}),Qe.createElement(Cf,null,m.map((k,T)=>Qe.createElement(vf,{isLoading:!0,key:T}))))))}return Qe.createElement(lw,{endReached:()=>{l.current<e.length&&h()},groupCounts:a,groupContent:g=>Qe.createElement(rl,null,Qe.createElement(il,null,Qe.createElement(pw,{variant:"label",size:"medium",className:nl()},u[g]))),itemContent:(g,f)=>{let m=c[g];if(!m)return null;let C=m.steps[0],S=m.steps[m.steps.length-1];return Qe.createElement(Sf,{key:m.requestId},Qe.createElement(vf,{requestId:m.requestId,creationTime:m.creationTime,status:m.status,onClick:o,tooltipContainer:I(),onlyShowTime:u[f]===sw.t("Today"),swapTokenData:{from:{token:{image:C.fromLogo,displayName:C.fromSymbol},blockchain:{image:C.fromBlockchainLogo||""},amount:B(m.inputAmount,6,6),realAmount:m.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(al,"HistoryGroupedList");import{i18n as vi}from"@lingui/core";import bf from"dayjs";var xf=i(t=>{let e=new Map([["today",{title:vi.t("Today"),swaps:[]}],["week",{title:vi.t("This week"),swaps:[]}],["month",{title:vi.t("This month"),swaps:[]}],["year",{title:vi.t("This year"),swaps:[]}]]);function o(c,p){e.has(c)||e.set(c,{title:c,swaps:[]}),e.get(c)?.swaps.push(p)}i(o,"addYearsToOutput");let n=bf();t.forEach(c=>{let p=Number(c.creationTime),u=bf(p);if(n.isSame(u,"day"))e.get("today")?.swaps.push(c);else if(n.isSame(u,"week"))e.get("week")?.swaps.push(c);else if(n.isSame(u,"month"))e.get("month")?.swaps.push(c);else if(n.isSame(u,"year"))e.get("year")?.swaps.push(c);else{let d=new Date(p).getFullYear().toString();o(d,c)}});let r=Array.from(e.values()).filter(c=>c.swaps.length>0),a=r.flatMap(c=>c.swaps),s=r.map(c=>c.swaps.length),l=r.map(c=>c.title);return{swaps:a,groupCounts:s,groups:l}},"groupSwapsByDate");var kw=ll("div",{overflowY:"visible",width:"100%",display:"flex",flexDirection:"column",gap:15,height:"100%"}),Tw=ll("div",{display:"flex",justifyContent:"center",alignItems:"center"}),vw=ll("div",{"._typography":{color:"$neutral700",[`.${hw}&`]:{color:"$neutral900"}}}),ww=[{id:qn.SUCCESS,title:He.t("Complete")},{id:qn.RUNNING,title:He.t("Running")},{id:qn.FAILED,title:He.t("Failed")}],bw=i((t,e)=>t?.length?t.filter(o=>wt(o.fromBlockchain,e)||wt(o.toBlockchain,e)||wt(o.toSymbol,e)||wt(o.fromSymbol,e)).length:!1,"isStepContainsText");function If(){let t=Cw(),{manager:e,state:o}=gw(),n=pt(e).map(({swap:T})=>T),[r,a]=bi(""),[s,l]=bi(!1),c=!o.loadedFromPersistor,[p,u]=bi(""),[d,h]=bi(!1),g=i(T=>{let v=T.target.value;a(v)},"handleSearch"),f=Ef(()=>!r&&!p?n:n.filter(T=>{let{inputAmount:v,status:b,steps:A,requestId:D}=T;return(!r||wt(v,r)||wt(b,r)||bw(A,r)||wt(D,r))&&(!p||p===b)}),[n,r,p]),m=!f?.length&&!c,C=i(()=>h(!1),"onCloseModal"),S=i(async()=>{try{await e?.clearQueue(),h(!1)}catch(T){console.log(T)}},"onClear"),k=Ef(()=>!n.some(T=>T.status===qn.SUCCESS||T.status===qn.FAILED),[n]);return ae.createElement(oe,{header:{title:He.t("History"),suffix:ae.createElement(Vt,null,ae.createElement(sl,{id:"widget-history-clear-btn",disabled:k,variant:"ghost",size:"xsmall",onClick:()=>h(!0)},ae.createElement(wi,{size:"medium",variant:"label",color:"error"},He.t("Clear"))))}},ae.createElement(ie,null,ae.createElement(Tw,null,ae.createElement(Ct,{setValue:a,fullWidth:!0,variant:"contained",placeholder:He.t("Search Transaction"),autoFocus:!0,onChange:g,style:{height:36},value:r}),ae.createElement(To,{size:10,direction:"horizontal"}),ae.createElement(ol,{filterBy:p,open:s,onOpenChange:T=>l(T),onClickItem:T=>u(T),list:ww})),ae.createElement(To,{size:"16"}),ae.createElement(kw,null,m&&ae.createElement(kf,null,ae.createElement(To,{size:32}),ae.createElement(Sw,{title:r?He.t("No results found"):He.t("No transactions"),titleColor:r?void 0:"$info",hasIcon:!!r,description:r?He.t("Try using different keywords"):He.t("Your transaction history is stored locally and will appear here after you start a swap")})),!m&&ae.createElement(al,{list:f,onSwapClick:t,groupBy:xf,isLoading:c}))),ae.createElement(Z,{open:d,onClose:C,container:I()},ae.createElement(To,{size:20}),ae.createElement(yw,{type:"warning",title:He.t("Clear Transaction History"),description:ae.createElement(vw,null,ae.createElement(wi,{variant:"body",size:"medium"},He.t("Proceeding will remove all successful and failed transactions from the widget. Do you want to continue?")),ae.createElement(To,{size:"24"}),ae.createElement(wi,{variant:"body",size:"small"},He.t("Note: This does not erase your transaction history on the chain; it only removes them here.")))}),ae.createElement(To,{size:30}),ae.createElement(sl,{id:"widget-history-clear-modal-yes-btn",variant:"contained",type:"primary",size:"large",onClick:S},He.t("Yes, Clear the history")),ae.createElement(To,{size:10}),ae.createElement(sl,{id:"widget-history-clear-modal-no-btn",variant:"outlined",type:"primary",size:"large",onClick:C},ae.createElement(wi,{variant:"title",size:"medium",color:"primary"},He.t("No, Cancel")))))}i(If,"HistoryPage");import{i18n as jw}from"@lingui/core";import{Button as Xw,Divider as jf,styled as Yw,WarningIcon as Zw}from"@rango-dev/ui";import Jw from"bignumber.js";import qe,{useEffect as Xf,useState as Yf}from"react";import{useNavigate as Rw}from"react-router-dom";import{i18n as Nf}from"@lingui/core";import{Alert as Ew,Divider as cl,NoRouteIcon as Iw,Typography as Aw}from"@rango-dev/ui";import vo from"react";import{styled as xw}from"@rango-dev/ui";var Af=xw("div",{display:"flex",flexDirection:"column",alignItems:"center"});function pl(){let{fromToken:t,toToken:e}=O();return!!t&&!!e&&Mt(t,e)?vo.createElement(Af,null,vo.createElement(cl,{size:10}),vo.createElement(Iw,{size:24,color:"gray"}),vo.createElement(cl,{size:4}),vo.createElement(Aw,{variant:"title",size:"small"},Nf.t("No Routes Found")),vo.createElement(cl,{size:4}),vo.createElement(Ew,{title:Nf.t("You cannot use the same token for From and To."),type:"warning",variant:"alarm"})):null}i(pl,"SameTokensWarning");import{i18n as Pw}from"@lingui/core";import{Header as _w}from"@rango-dev/ui";import Jt,{useEffect as Dw,useState as $w}from"react";import{i18n as Ww}from"@lingui/core";import{Divider as dl,FullExpandedQuote as Bw,Typography as Mw}from"@rango-dev/ui";import Se from"react";import{styled as ul}from"@rango-dev/ui";var Wf=ul("div",{display:"flex",justifyContent:"center",flexDirection:"column",height:"100%"}),Bf=ul("div",{display:"flex",justifyContent:"space-between",alignItems:"center"}),Mf=ul("div",{width:"146px"});import{i18n as Gn}from"@lingui/core";import{Select as Nw}from"@rango-dev/ui";import Lf from"react";function xi(t){let{updateQuotePartialState:e,sortStrategy:o}=O(),n=[{value:"SMART",label:Gn.t("Smart Routing")},{value:"FEE",label:Gn.t("Lowest Fee")},{value:"SPEED",label:Gn.t("Fastest Transfer")},{value:"NET_OUTPUT",label:Gn.t("Maximum Return")},{value:"PRICE",label:Gn.t("Maximum Output")}];return Lf.createElement(Mf,null,Lf.createElement(Nw,{container:t.container,options:n,value:o,handleItemClick:r=>{e("sortStrategy",r.value)},variant:"filled"}))}i(xi,"SelectStrategy");var Pf=3;function Vn(t){let{loading:e,onClickOnQuote:o,fetch:n,showModalFee:r,hasSort:a=!0,fullExpandedMode:s=!1,container:l}=t,{selectedQuote:c,quotes:p,updateQuotePartialState:u,fromToken:d,toToken:h,sortStrategy:g,error:f}=O(),{slippage:m,customSlippage:C}=y(),{findToken:S}=y(),k=l||I(),T=!!p&&p.results.length,v=C??m,b=i(w=>{if(!d||!h||!p)return null;let x={requestAmount:p.requestAmount,validationStatus:null,...w};return Fo({currentQuote:x,userSlippage:v,findToken:S})},"getQuoteWarning"),A=f?.type===0||f?.type===1,D=p?.results?Br(g,p?.results):[];return Se.createElement(Se.Fragment,null,a&&Se.createElement(Se.Fragment,null,Se.createElement(Bf,null,Se.createElement(Mw,{size:"xmedium",variant:"title"},Ww.t("Sort by")),Se.createElement(xi,{container:k})),Se.createElement(dl,{size:"10"})),e&&Array.from({length:Pf},(w,x)=>Se.createElement(Se.Fragment,{key:x},s?Se.createElement(Bw,{loading:!0}):Se.createElement(Dn,{tagHidden:!1,type:"list-item",expanded:!1}),x!==Pf-1&&Se.createElement(dl,{size:16}))),!e&&Se.createElement(Se.Fragment,null,T?D.map((w,x)=>{let E=b(w),N=$s(w.swaps),M=D.length-1===x;return Se.createElement(Se.Fragment,{key:w.requestId},Se.createElement(Co,{showModalFee:r,container:k,selected:c?.requestId===w.requestId,tagHidden:!1,quote:{...w,requestAmount:p.requestAmount,validationStatus:null},loading:e,error:N?.options||null,warning:E,fullExpandedMode:s,onClick:W=>{N||u("warning",E),u("error",N?.options||null),o(W)},type:"list-item"}),!M&&Se.createElement(dl,{size:16}))}):A&&Se.createElement(Wf,null,Se.createElement(In,{size:s?"large":"small",error:f,fetch:n}))))}i(Vn,"Quotes");import{darkTheme as Lw,styled as _f}from"@rango-dev/ui";var Df=_f("div",{transition:"width 0.2s, opacity 0.2s, margin-left 0.2s",height:"700px",width:"390px",position:"relative",opacity:1,marginLeft:"$16",backgroundColor:"$neutral100",[`.${Lw} &`]:{backgroundColor:"$neutral300"},variants:{expandMode:{default:{width:"390px"},full:{width:"719px"}}},"&.is-hidden":{width:0,height:0,opacity:0,marginLeft:0}}),$f=_f("div",{position:"relative",overflow:"hidden",padding:"$20",flexGrow:1,display:"flex",flexDirection:"column",overflowY:"auto",borderRadius:"$primary",backgroundColor:"$background"});var Fw=100;function ml(t){let{fetch:e,loading:o,onClickOnQuote:n,onClickRefresh:r,isVisible:a}=t,[s,l]=$w(!1),c=s?"":"is-hidden",{config:p}=y(),u=p?.variant==="full-expanded",d=ro();return Dw(()=>{let h=null;return a?h=setTimeout(()=>{l(!0)},Fw):(l(!1),h&&clearTimeout(h)),()=>{h&&clearTimeout(h)}},[a]),Jt.createElement(Df,{expandMode:p?.variant==="full-expanded"?"full":"default",className:`${c} ${Qr()}`,id:De.EXPANDED_BOX_ID},Jt.createElement(_w,{title:Pw.t("Routes"),suffix:Jt.createElement(Jt.Fragment,null,Jt.createElement(xi,{container:d}),Jt.createElement(go,{container:d,onClickRefresh:r,hidden:["history","notifications","settings"]}))}),Jt.createElement($f,null,Jt.createElement(Vn,{showModalFee:!0,fetch:e,hasSort:!1,loading:o,container:ro(),onClickOnQuote:n,fullExpandedMode:u})))}i(ml,"ExpandedQuotes");import{i18n as qf}from"@lingui/core";import{SwapInput as Gf}from"@rango-dev/ui";import Qw from"bignumber.js";import Kn from"react";import{ReverseIcon as zw}from"@rango-dev/ui";import gl from"react";import{keyframes as Ow,styled as Ff}from"@rango-dev/ui";var fl=450,Uw=Ow({"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)"}}),Of=Ff("div",{position:"absolute",bottom:"-12px",left:"50%",transform:"translate(-50%, 10%)",cursor:"pointer"}),Uf=Ff("div",{borderRadius:"$md",border:"3px solid $background",background:"$neutral100",width:"$24",height:"$24",display:"flex",justifyContent:"center",alignItems:"center",color:"$foreground","&.rotate":{"& svg":{animation:`${Uw} ${fl}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 hl(){let t=O.use.switchFromAndTo();return gl.createElement(Of,null,gl.createElement(Uf,{onClick:e=>{let o=e.currentTarget;o.classList.add("rotate"),setTimeout(()=>{o.classList.remove("rotate")},fl),t()}},gl.createElement(zw,{size:12})))}i(hl,"SwitchFromAndToButton");import{styled as zf}from"@rango-dev/ui";var Qf=zf("div",{display:"flex",flexDirection:"column",gap:"$5",alignSelf:"stretch"}),Hf=zf("div",{position:"relative"});function yl(t){let{fetchingQuote:e,fetchMetaStatus:o,onClickToken:n,isExpandable:r}=t,{fromToken:a,fromBlockchain:s,toToken:l,toBlockchain:c,setInputAmount:p,inputAmount:u,inputUsdValue:d,outputAmount:h,outputUsdValue:g,selectedQuote:f}=O(),{connectedWallets:m,getBalanceFor:C}=y(),S=a?C(a):null,k=hr(S)?.amount??"0",T=S?new Qw(S.amount).shiftedBy(-S.decimals):ce,v=!!s&&Oc(m,s.name),b=!Na(f,u,d),A=!Na(f,u,g),D=!d||!g||!g.gt(0)?null:Pt(d.toString(),g.toString());return Kn.createElement(Qf,null,Kn.createElement(Hf,null,Kn.createElement(Gf,{label:qf.t("From"),mode:"From",onInputChange:p,balance:k,chain:{displayName:s?.displayName||"",image:s?.logo||""},token:{displayName:a?.symbol||"",image:a?.image||""},onClickToken:()=>n("from"),price:{value:u,usdValue:b?void 0:B(d,4,4),realUsdValue:b?void 0:d?.toString(),error:b?R().unknownPriceError.impactTitle:void 0},disabled:o==="failed",loading:o==="loading",loadingBalance:v,tooltipContainer:I(),onSelectMaxBalance:()=>{let w=B(T,S?.decimals),x=S?.amount?w:"";p(x)},anyWalletConnected:m.length>0}),Kn.createElement(hl,null)),Kn.createElement(Gf,{sharpBottomStyle:!r&&(!!f||e),label:qf.t("To"),mode:"To",fetchingQuote:e,chain:{displayName:c?.displayName||"",image:c?.logo||""},token:{displayName:l?.symbol||"",image:l?.image||""},percentageChange:B(Pt(d,g),2,2),warningLevel:_t(D??0),price:{value:B(h,6,6),usdValue:A?void 0:B(g,4,4),realValue:h?.toString(),realUsdValue:A?void 0:g?.toString(),error:A?R().unknownPriceError.impactTitle:void 0},onClickToken:()=>n("to"),disabled:o==="failed",loading:o==="loading",tooltipContainer:I()}))}i(yl,"Inputs");import{useCallback as Hw,useEffect as qw,useRef as Gw,useState as Vw}from"react";function Vf(){let{fetch:t,loading:e,cancelFetch:o}=fi({request:async(n,r)=>await xt().getAllRoutes(n,r)});return{fetch:t,loading:e,cancelFetch:o}}i(Vf,"useFetchAllQuotes");var Kw=600;function Ei({refetchQuote:t}){let{fetch:e,cancelFetch:o}=Vf(),{excludeLiquiditySources:n,routing:r}=y().config,{connectedWallets:a}=y(),{fromToken:s,toToken:l,inputAmount:c,inputUsdValue:p,selectedQuote:u,sortStrategy:d,resetQuote:h,error:g,warning:f,setSelectedQuote:m,updateQuotePartialState:C}=O(),{slippage:S,customSlippage:k,affiliatePercent:T,affiliateRef:v,affiliateWallets:b,fetchStatus:A}=y(),D=y().getLiquiditySources(),w=y().getDisabledLiquiditySources(),x=y().excludeLiquiditySources(),{findToken:E}=y(),[N,M]=Vw(!0),W=Gw(c),j=k??S,J=!s||!l||Mt(s,l)||!cn(c),L=i(z=>{M(z)},"resetState"),X=i(z=>{let{fromToken:me,toToken:vt,inputAmount:Ze,liquiditySources:le,excludeLiquiditySources:at,disabledLiquiditySources:G,slippage:P,affiliateRef:q,affiliatePercent:V,affiliateWallets:fe}=z;if(N||L(!0),!J&&me&&vt){h();let ne=su({fromToken:me,toToken:vt,inputAmount:Ze,liquiditySources:le,excludeLiquiditySources:at,disabledLiquiditySources:G,wallets:a,slippage:P,affiliateRef:q,affiliatePercent:V,affiliateWallets:fe});Wo("experimental",r)&&(ne.experimental=!0),Wo("avoidNativeFee",r)&&(ne.avoidNativeFee=!0),Wo("enableCentralizedSwappers",r)&&(ne.enableCentralizedSwappers=!0),r?.maxLength&&(ne.maxLength=r.maxLength),e(ne).then(ge=>{let Fe=Br(d,ge.results),ve=Xp(u,Fe,ge.requestAmount);M(!1),C("quotes",ge),m(ve),gi({diagnosisMessages:ge.diagnosisMessages,requestId:ve?.requestId||"",swaps:ve?.swaps});let mt=ve&&Fo({currentQuote:ve,userSlippage:j,findToken:E});C("warning",mt)}).catch(ge=>{let{error:Fe}=hi(ge);(Fe?.type===0||Fe?.type===1)&&h(),Fe?.type!==2&&(C("error",Fe),M(!1))})}},"fetch"),se=Hw(Ic(z=>{X(z)},Kw),[J]);return qw(()=>{if(!t){M(!1);return}if(A!=="success")return;if(J){M(!1),(u||g||f)&&h();return}if(!cn(c)||p?.eq(0)){L(!1),o();return}h(),L(!0);let z=X;return W.current&&W.current!=c&&(z=se),W.current=c,z({inputAmount:c,fromToken:s,toToken:l,liquiditySources:D,excludeLiquiditySources:x,disabledLiquiditySources:w,slippage:j,affiliateRef:v,affiliatePercent:T,affiliateWallets:b}),o},[A,c,s?.symbol,s?.address,s?.blockchain,l?.symbol,l?.address,l?.blockchain,J,D?.length,n,w.length,j,v,T,JSON.stringify(b)]),{fetch:()=>X({inputAmount:c,fromToken:s,toToken:l,liquiditySources:D,excludeLiquiditySources:x,disabledLiquiditySources:w,slippage:j,affiliateRef:v,affiliatePercent:T,affiliateWallets:b}),loading:N}}i(Ei,"useSwapInput");function Kf(t,e){let o=!1,n={preventDefault(){o=!0},...t.payload===void 0&&{payload:t.payload}};he.emit("uiEvent",{type:t.type,payload:n}),o||e()}i(Kf,"emitPreventableEvent");var eb=Yw("div",{display:"flex",alignItems:"flex-start",maxHeight:700,"& .footer__alert":{paddingTop:"0 !important"}}),tb=300;function Zf(){let t=Rw(),{fromToken:e,toToken:o,inputAmount:n,selectedQuote:r,refetchQuote:a,error:s,warning:l,quotes:c,setSelectedQuote:p,resetQuoteWallets:u,setQuoteWarningsConfirmed:d,updateQuotePartialState:h}=O(),[g,f]=Yf(!1),{isLargeScreen:m,isExtraLargeScreen:C}=ai(),{fetch:S,loading:k}=Ei({refetchQuote:a}),{config:T,fetchStatus:v,connectedWallets:b}=y(),{isActiveTab:A}=re(),[D,w]=Yf(!1),E=nu({fetchMetaStatus:v,fetchingQuote:k,inputAmount:n,quote:r,anyWalletConnected:b.length>0,error:s,warning:l,needsToWarnEthOnPath:!1}),N=Vc(m,C,T?.variant),M=!!n&&!!e&&!!o&&new Jw(n).gt(0)&&!fu(e,o),W=M&&v==="success"&&k,J=(!N||N&&c?.results.length)&&(l||s);Xf(()=>{u(),h("refetchQuote",!0)},[]),Xf(()=>{f(M)},[M]);let L=(r||s)&&!D?S:void 0,X=i(z=>{N&&g?(f(!1),setTimeout(()=>{t(z)},tb)):t(z)},"onHandleNavigation"),se=i(z=>{r?.requestId!==z.requestId&&(w(!1),p(z))},"onClickOnQuote");return qe.createElement(eb,null,qe.createElement(oe,{height:"auto",footer:qe.createElement(Xw,{id:`widget-swap-${E.action}-btn`,type:"primary",size:"large",disabled:E.disabled||!A,prefix:E.action==="confirm-warning"&&qe.createElement(Zw,null),fullWidth:!0,onClick:()=>{E.action==="connect-wallet"?Kf({type:"clickConnectWallet"},()=>X($.wallets)):E.action==="confirm-warning"?w(!0):X($.confirmSwap)}},E.title),header:{onWallet:()=>{X($.wallets)},hasBackButton:!1,title:T.title||jw.t("Swap"),suffix:qe.createElement(go,{hidden:N?["refresh"]:void 0,onClickRefresh:L,onClickHistory:()=>X($.swaps),onClickSettings:()=>{X($.settings)}})}},qe.createElement(ie,null,qe.createElement(yl,{fetchingQuote:W,fetchMetaStatus:v,isExpandable:N,onClickToken:z=>{X(z==="from"?$.fromSwap:$.toSwap)}}),qe.createElement(jf,{size:"2"}),N?null:qe.createElement(Co,{quote:r,loading:W,error:s,tagHidden:!1,warning:l,type:"basic",onClickAllRoutes:c&&c.results.length>1?()=>{h("refetchQuote",!1),X($.routes)}:void 0}),J?qe.createElement(qe.Fragment,null,qe.createElement(jf,{size:"10"}),qe.createElement(Nn,{warning:l,error:s,couldChangeSettings:!0,refetchQuote:S,showWarningModal:D,confirmationDisabled:!A,onOpenWarningModal:()=>w(!0),onCloseWarningModal:()=>w(!1),onConfirmWarningModal:()=>{w(!1),d(!0),X($.confirmSwap)},onChangeSettings:()=>X($.settings)})):null,qe.createElement(pl,null))),N?qe.createElement(ml,{loading:W,onClickOnQuote:se,fetch:S,onClickRefresh:L,isVisible:g}):null)}i(Zf,"Home");import{i18n as Jf}from"@lingui/core";import{Alert as ob,Divider as nb,List as rb,ListItemButton as ib,Radio as ab,RadioRoot as sb,Typography as lb}from"@rango-dev/ui";import Wt from"react";function Rt(){let{setLanguage:t,language:e,config:o}=y(),n=Zc,r=o?.language||Bo;return{activeLanguage:e||r,languages:n,defaultLanguage:r,changeLanguage:a=>t(a||Bo),resetLanguage:()=>t(null)}}i(Rt,"useLanguage");function Rf(){let{activeLanguage:t,changeLanguage:e,languages:o}=Rt(),n=je(),r=o.map(a=>{let{local:s,label:l,SVGFlag:c}=a;return{id:`widget-setting-languages-${s}-item-btn`,value:s,title:Wt.createElement(lb,{variant:"title",size:"xmedium"},l),onClick:()=>{e(a.local),n()},end:Wt.createElement(ab,{value:s}),start:Wt.createElement(c,null)}});return Wt.createElement(oe,{header:{title:Jf.t("Language")}},Wt.createElement(ie,null,Wt.createElement(ob,{type:"warning",variant:"alarm",title:"Warning: We are using machine translation, so the translations may be inaccurate."}),Wt.createElement(nb,{size:"8"}),Wt.createElement(sb,{value:t},Wt.createElement(rb,{type:Wt.createElement(ib,{title:Jf.t("language"),id:"_",onClick:()=>console.log()}),items:r}))))}i(Rf,"LanguagePage");import{i18n as zt}from"@lingui/core";import{Button as mb,Checkbox as fb,Image as gb,ListItemButton as hb,NotFound as yb,Typography as Sb}from"@rango-dev/ui";import Ge,{useState as Cb}from"react";import{Checkbox as ub,Skeleton as tg}from"@rango-dev/ui";import Xn from"react";import{styled as Sl}from"@rango-dev/ui";var jn=Sl("ul",{padding:"$15 $5 0",margin:0,listStyle:"none",height:"100%",overflowY:"auto",variants:{disabled:{true:{pointerEvents:"none"}}}}),Cl=Sl("div",{width:80,display:"flex",justifyContent:"flex-end"}),kl=Sl("div",{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%"});import{ListItem as cb,styled as pb}from"@rango-dev/ui";var eg=pb(cb,{height:61});var db=30;function Tl(){return Xn.createElement(jn,null,Array.from(Array(db),(t,e)=>Xn.createElement(eg,{hasDivider:!0,key:e,start:Xn.createElement(tg,{variant:"circular",width:35,height:35}),title:Xn.createElement(tg,{variant:"text",size:"large",width:90}),end:Xn.createElement(ub,{checked:!1})})))}i(Tl,"LoadingLiquiditySourceList");function vl({sourceType:t}){let e=y().fetchStatus,o=y().swappers(),n=y().getDisabledLiquiditySources(),[r,a]=Cb(""),s=y().toggleLiquiditySource,l=y().isInCampaignMode(),c=Cr(o,n),p={Exchanges:zt.t("Exchanges"),Bridges:zt.t("Bridges")},u=[];t==="Exchanges"&&u.push("DEX"),t==="Bridges"&&u.push("BRIDGE","AGGREGATOR","OFF_CHAIN");let d=c.filter(S=>u.includes(S.type)),h=d.length===d.filter(S=>S.selected).length,g=i(()=>{d.forEach(S=>{h?s(S.groupTitle):S.selected||s(S.groupTitle)})},"toggleAllSources"),f=d.map(S=>{let{selected:k,groupTitle:T,logo:v,id:b,...A}=S;return{id:`widget-setting-liquidity-source-${b.toLowerCase().replace(/\s+/g,"-")}-item-btn`,start:Ge.createElement(gb,{src:v,size:22,type:"circular"}),onClick:()=>{l||s(T)},end:Ge.createElement(fb,{checked:k,disabled:l}),title:Ge.createElement(Sb,{variant:"title",size:"xmedium"},zt.t(T)),selected:k,groupTitle:T,logo:v,...A}}),m=i(S=>{let k=S.target.value;a(k)},"handleSearch"),C=f;return r&&(C=f.filter(S=>wt(S.groupTitle,r))),Ge.createElement(oe,{header:{title:zt.t(t),suffix:Ge.createElement(Cl,null,Ge.createElement(mb,{id:`widget-liquidity-source-${h?"deselect-all":"select-all"}-btn`,variant:"ghost",size:"xsmall",onClick:g},h?zt.t("Deselect all"):zt.t("Select all")))}},Ge.createElement(ie,{view:!0},Ge.createElement(Ct,{value:r,setValue:a,fullWidth:!0,color:"light",variant:"contained",placeholder:zt.t("Search {sourceType}",{sourceType:p[t]}),onChange:m}),e==="loading"&&Ge.createElement(Tl,null),!C.length&&r?Ge.createElement(kl,null,Ge.createElement(yb,{title:zt.t("No results found"),description:zt.t("Try using different keywords")})):e==="success"&&Ge.createElement(jn,{disabled:l},C.map(S=>{let{groupTitle:k,...T}=S;return Ge.createElement(Ge.Fragment,{key:S.id},Ge.createElement(hb,{style:{height:"61px"},...T,selected:!1,hasDivider:!0}))}))))}i(vl,"LiquiditySourcePage");import{i18n as kb}from"@lingui/core";import Ii from"react";import{useNavigate as Tb}from"react-router-dom";function og(){let t=Tb(),e=je(),{selectedQuote:o,refetchQuote:n,setSelectedQuote:r,updateQuotePartialState:a,error:s}=O(),{fetch:l,loading:c}=Ei({refetchQuote:n}),p=i(h=>{r(h),a("refetchQuote",!1),e()},"onClickOnQuote"),u=`../${$.settings}`,d=`../${$.wallets}`;return Ii.createElement(oe,{header:{onWallet:()=>{t(d),a("refetchQuote",!0)},onBack:()=>{a("refetchQuote",!1)},title:kb.t("Routes"),suffix:Ii.createElement(go,{onClickRefresh:o||s?l:void 0,hidden:["notifications","history"],onClickSettings:()=>{t(u),a("refetchQuote",!0)}})}},Ii.createElement(ie,null,Ii.createElement(Vn,{fetch:l,loading:c,onClickOnQuote:p})))}i(og,"RoutesPage");import{i18n as cg}from"@lingui/core";import{Divider as pg,getCategoriesCount as Bb,SelectableCategoryList as Mb}from"@rango-dev/ui";import Qt,{useState as ug}from"react";import{useNavigate as Lb}from"react-router-dom";import{i18n as wl}from"@lingui/core";import{Divider as xb,Image as Eb,ListItemButton as Ib,NotFound as Ab,Typography as lg}from"@rango-dev/ui";import nt,{useEffect as Nb,useState as Wb}from"react";var ng=i((t,e,o)=>t.filter(n=>ur(n.type,o)).filter(n=>Je(n.name,e)||Je(n.displayName,e)),"filterBlockchains");import{ImageContainer as vb,styled as rg}from"@rango-dev/ui";var ig=rg("div",{display:"flex",flexDirection:"column",overflow:"hidden",height:"100%",justifyContent:"center"}),Ai=rg(wn,{padding:0,margin:0,listStyle:"none",[`& ${vb}`]:{borderRadius:"$xm",overflow:"hidden"}});import{ListItem as wb,Skeleton as ag}from"@rango-dev/ui";import Ni from"react";var bb=20;function sg(){return Ni.createElement(Ai,null,Array.from(Array(bb),t=>Ni.createElement(wb,{key:t,hasDivider:!0,start:Ni.createElement(ag,{variant:"circular",width:35,height:35}),title:Ni.createElement(ag,{variant:"text",size:"large",width:90})})))}i(sg,"LoadingBlockchainList");function bl(t){let{list:e,searchedFor:o,onChange:n,blockchainCategory:r,showTitle:a=!0}=t,[s,l]=Wb(e),{fetchStatus:c}=y();Nb(()=>{l([...ng(e,o,r)])},[e,o,r]);let p=i(()=>!s.length&&o?nt.createElement(Ab,{title:wl.t("No results found"),description:wl.t("Try using different keywords")}):nt.createElement(Ai,{as:"ul",key:`${r}-${o}`},s.map(u=>nt.createElement(Ib,{key:`${u.name}-${u.chainId}`,className:"widget-blockchain-list-item-btn",hasDivider:!0,onClick:()=>n(u),start:nt.createElement(Eb,{src:u.logo,size:30}),title:nt.createElement(lg,{variant:"title",size:"medium"},u.displayName),id:u.name}))),"renderList");return nt.createElement(nt.Fragment,null,a&&nt.createElement(nt.Fragment,null,nt.createElement(lg,{variant:"label",size:"large"},wl.t("Select Chain")),nt.createElement(xb,{size:4})),nt.createElement(ig,null,c==="loading"&&nt.createElement(sg,null),c==="success"&&p()))}i(bl,"BlockchainList");function Wi(t){let{type:e}=t,o=je(),[n,r]=ug(""),[a,s]=ug("ALL"),l=O.use.setToBlockchain(),c=O.use.setFromBlockchain(),{fetchStatus:p}=y(),u=Lb(),d=y().blockchains({type:e}),h=Bb(d),g=!t.hideCategory&&h!==1;return Qt.createElement(oe,{header:{title:cg.t("Select Chain")}},Qt.createElement(ie,{view:!0},g&&Qt.createElement(Qt.Fragment,null,Qt.createElement(Mb,{setCategory:s,category:a,blockchains:d,isLoading:p==="loading"}),Qt.createElement(pg,{size:24})),Qt.createElement(Ct,{value:n,autoFocus:!0,placeholder:cg.t("Search Chain"),color:"light",variant:"contained",size:"large",setValue:()=>r(""),onChange:f=>r(f.target.value)}),Qt.createElement(pg,{size:16}),Qt.createElement(bl,{list:d,showTitle:e!=="custom-token",searchedFor:n,blockchainCategory:a,onChange:f=>{e==="custom-token"?u(`..?blockchain=${f.name}`,{replace:!0}):(e==="source"?c(f):l(f),o())}})))}i(Wi,"SelectBlockchainPage");import{i18n as Mi}from"@lingui/core";import{Divider as yg}from"@rango-dev/ui";import wo,{useState as zb}from"react";import{useNavigate as Qb}from"react-router-dom";import{i18n as Il}from"@lingui/core";import{BlockchainsChip as Bi,Divider as gg,Image as hg,Skeleton as Fb,Tooltip as Ob,Typography as Al}from"@rango-dev/ui";import Pe from"react";import{useEffect as Db}from"react";var dg=["ETH","COSMOS","OSMOSIS"];function xl(t,e,o){let n=JSON.parse(JSON.stringify(t)),r=[];if(n.sort(Pb),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 c=0;c<=l;c++){let p=n[c];s=s.filter(u=>p.name!==u)}}n.sort(_b(s)),r=n.splice(a)}return{list:n,more:r}}i(xl,"prepare");function Pb(t,e){let o=dg,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(Pb,"sortByMostUsedBlockchains");function _b(t){return i(function(o,n){let r=t.findIndex(c=>c===o.name),a=t.findIndex(c=>c===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(_b,"generateSortByPreferredBlockchainsFor");function mg(t,e){return!!e.list.find(o=>o.name===t)}i(mg,"isInVisibleList");function El(t,e){let{preferredBlockchains:o,addPreferredBlockchain:n}=y();Db(()=>{if(e?.selected){let a=xl(t,o,e);mg(e.selected,a)||n(e?.selected)}},[e?.selected]);let r=xl(t,o,e);return{list:r.list,more:r.more,history:[]}}i(El,"usePrepareBlockchainList");import{styled as $b}from"@rango-dev/ui";var fg=$b("div",{display:"grid",gap:"$10",gridTemplateColumns:"repeat(6, minmax(0, 1fr))"});var Ub=12;function Nl(t){let{blockchains:e,type:o,blockchain:n,onChange:r,onMoreClick:a}=t,s=El(e,{limit:10,selected:n?.name}),{fetchStatus:l}=y(),c=O.use.resetToBlockchain(),p=O.use.resetFromBlockchain(),u=s.more.length>0,d=s.more.length===1,h=!d&&u;return Pe.createElement(Pe.Fragment,null,Pe.createElement(gg,{size:12}),Pe.createElement(Al,{variant:"label",size:"large"},Il.t("Select Chain")),Pe.createElement(gg,{size:12}),Pe.createElement(fg,null,l==="loading"&&Array.from(Array(Ub),g=>Pe.createElement(Fb,{key:g,variant:"rounded",height:50})),l==="success"&&Pe.createElement(Pe.Fragment,null,Pe.createElement(Bi,{selected:!n,onClick:()=>{o==="from"?p():c()}},Pe.createElement(Al,{variant:"body",size:"xsmall",color:"secondary500"},Il.t("All"))),s.list.map(g=>Pe.createElement(Ob,{key:g.name,content:g.shortName,side:"bottom",sideOffset:2,container:I()},Pe.createElement(Bi,{key:g.name,selected:!!n&&n.name===g.name,onClick:()=>r(g)},Pe.createElement(hg,{src:g.logo,size:30})))),d?Pe.createElement(Bi,{key:s.more[0].name,selected:!!n&&n.name===s.more[0].name,onClick:()=>r(s.more[0])},Pe.createElement(hg,{src:s.more[0].logo,size:30})):null,h?Pe.createElement(Bi,{onClick:a,key:"more-blockchains"},Pe.createElement(Al,{variant:"body",size:"xsmall",color:"secondary500"},Il._("More +{count}",{count:s.more.length}))):null)))}i(Nl,"BlockchainsSection");function Wl(t){let{type:e}=t,o=Qb(),n=je(),{fromBlockchain:r,toBlockchain:a,setFromToken:s,setToToken:l,setFromBlockchain:c,setToBlockchain:p}=O(),{getBalanceFor:u}=y(),[d,h]=zb(""),f=(e==="source"?r:a)?.name??"",m=y().blockchains({type:e}),C=y().tokens({type:e,blockchain:f,searchFor:d,getBalanceFor:u}),S=i(v=>{e==="source"?c(v):p(v)},"updateBlockchain"),k=i(v=>{e==="source"?s({token:v,meta:{blockchains:m,tokens:C}}):l({token:v,meta:{blockchains:m,tokens:C}})},"updateToken"),T={source:Mi.t("Source"),destination:Mi.t("Destination")};return wo.createElement(oe,{header:{title:Mi.t("Swap {type}",{type:T[e]})}},wo.createElement(ie,null,wo.createElement(Nl,{blockchains:m,type:e=="source"?"from":"to",blockchain:e==="source"?r:a,onMoreClick:()=>o($.blockchains),onChange:v=>{S(v)}}),wo.createElement(yg,{size:24}),wo.createElement(Ct,{value:d,autoFocus:!0,placeholder:Mi.t("Search Token"),color:"light",variant:"contained",size:"large",setValue:()=>h(""),onChange:v=>h(v.target.value)}),wo.createElement(yg,{size:16}),wo.createElement(Un,{list:C,selectedBlockchain:f,searchedFor:d,type:e,onChange:v=>{k(v);let b=m.find(A=>v.blockchain===A.name);b&&S(b),n()}})))}i(Wl,"SelectSwapItemsPage");import{i18n as Ll}from"@lingui/core";import{Alert as fx,Button as gx,styled as hx}from"@rango-dev/ui";import bo from"react";import{useInRouterContext as yx,useSearchParams as Sx}from"react-router-dom";import{i18n as wg}from"@lingui/core";import{Divider as bg,InfoIcon as Vb,SlippageIcon as Kb,TextField as jb,Tooltip as Xb,Typography as xg}from"@rango-dev/ui";import rt from"react";import{Chip as Hb,styled as Yn,TextField as qb}from"@rango-dev/ui";var Sg=Yn("div",{paddingTop:"$5",padding:"$10 $5"}),Cg=Yn("div",{display:"flex",flexWrap:"wrap",gap:"$10",[`& ${qb}`]:{flex:"1 1 0",maxWidth:"127px",minWidth:"85px"}}),kg=Yn("div",{display:"flex",justifyContent:"start",alignItems:"center",paddingBottom:"$10"}),Li=Yn("div",{maxWidth:"280px",padding:"$10"}),Tg=Yn(Hb,{width:"61px",flexShrink:0});import{i18n as Bl}from"@lingui/core";import{Typography as Gb}from"@rango-dev/ui";import Zn from"react";function vg(){return Zn.createElement(Li,null,Zn.createElement(Gb,{variant:"label",size:"medium",color:"neutral700"},Bl.t("Your transaction will be reverted if the price changes unfavorably by more than this percentage."),Zn.createElement("br",null),Zn.createElement("br",null),Zn.createElement("b",null,Bl.t("Warning")),":\xA0",Bl.t("This setting is applied to each step (e.g. 1Inch, Thorchain, etc.), meaning only that specific step will be reverted, not the entire route.")))}i(vg,"SlippageTooltipContent");function Ml(){let{slippage:t,setSlippage:e,customSlippage:o,setCustomSlippage:n}=y();return rt.createElement(Sg,null,rt.createElement(kg,null,rt.createElement(Kb,{size:16,color:"gray"}),rt.createElement(bg,{direction:"horizontal",size:4}),rt.createElement(xg,{variant:"title",size:"xmedium"},wg.t("Slippage tolerance per swap")),rt.createElement(bg,{direction:"horizontal",size:4}),rt.createElement(Xb,{container:I(),side:"top",sideOffset:4,content:rt.createElement(vg,null)},rt.createElement(Vb,{color:"gray"}))),rt.createElement(Cg,null,Jc.map((r,a)=>{let s=`slippage-${a}`;return rt.createElement(Tg,{key:s,onClick:()=>{o&&n(null),e(r)},selected:!o&&r===t,label:`${r.toString()}%`})}),rt.createElement(jb,{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>=op&&s<=tp?n(s):n(null)},suffix:o&&rt.createElement(xg,{variant:"body",size:"small"},"%"),placeholder:wg.t("Custom")})))}i(Ml,"Slippage");import{i18n as dt}from"@lingui/core";import{AutoThemeIcon as Eg,BridgesIcon as Yb,ChevronRightIcon as Pi,DarkModeIcon as Ig,Divider as Jn,ExchangeIcon as Zb,InfinityIcon as Jb,InfoIcon as Rb,LanguageIcon as ex,LightModeIcon as Ag,List as tx,ListItem as ox,ListItemButton as nx,Skeleton as rx,styled as ix,Switch as ax,Tabs as sx,TargetIcon as lx,Tooltip as cx,Typography as Ye}from"@rango-dev/ui";import _ from"react";import{useNavigate as px}from"react-router-dom";var ux=ix("div",{width:"202px",height:"$40"}),dx=[{id:"light",icon:_.createElement(Ag,{color:"black",size:24}),tooltip:_.createElement(Ye,{size:"xsmall",variant:"body"},dt.t("Light"))},{id:"dark",icon:_.createElement(Ig,{color:"black",size:24}),tooltip:_.createElement(Ye,{size:"xsmall",variant:"body"},dt.t("Dark"))},{id:"auto",icon:_.createElement(Eg,{color:"black",size:24}),tooltip:_.createElement(Ye,{size:"xsmall",variant:"body"},dt.t("Auto"))}],mx=i(t=>{let e={color:"gray",size:16};switch(t){case"auto":return _.createElement(Eg,{...e});case"dark":return _.createElement(Ig,{...e});default:return _.createElement(Ag,{...e})}},"getThemeIcon");function Ng(){let t=px(),{theme:e}=y().config,{setTheme:o,theme:n}=y(),{activeLanguage:r,languages:a}=Rt(),s=a.find(L=>L.local===r)?.label,l=y().fetchStatus,c=y().swappers(),p=y().getDisabledLiquiditySources(),{config:{features:u}}=y(),d=y().customTokens(),h=Ve("theme",u),g=Ve("liquiditySource",u),f=Ve("language",u),m=Ve("customTokens",u),C=y().infiniteApprove,S=y().toggleInfiniteApprove,k=Cr(c,p),T=k.filter(L=>["BRIDGE","AGGREGATOR","OFF_CHAIN"].includes(L.type)),v=T.length,b=T.filter(L=>L.selected).length,A=k.filter(L=>L.type==="DEX"),D=A.length,w=A.filter(L=>L.selected).length,x=i((L,X)=>{switch(l){case"loading":return _.createElement(rx,{variant:"text",size:"medium",width:50});case"failed":return _.createElement(Ye,{variant:"body",size:"medium",color:"$error500"},dt.t("Loading failed"));default:return _.createElement(Ye,{variant:"body",size:"medium"},`${L} / ${X}`)}},"handleSwapperEndItem"),E={id:"widget-setting-bridge-item-btn",title:_.createElement(Ye,{variant:"title",size:"xmedium"},dt.t("Bridges")),end:_.createElement(_.Fragment,null,x(b,v),_.createElement(Jn,{direction:"horizontal",size:8}),_.createElement(Pi,{color:"black"})),onClick:()=>t($.bridges),start:_.createElement(Yb,{color:"gray",size:16})},N={id:"widget-setting-exchange-item-btn",title:_.createElement(Ye,{variant:"title",size:"xmedium"},dt.t("Exchanges")),end:_.createElement(_.Fragment,null,x(w,D),_.createElement(Jn,{direction:"horizontal",size:8}),_.createElement(Pi,{color:"black"})),start:_.createElement(Zb,{color:"gray",size:16}),onClick:()=>t($.exchanges)},M={id:"widget-setting-custom-tokens-item-btn",title:_.createElement(Ye,{variant:"title",size:"xmedium"},dt.t("Custom Tokens")),end:_.createElement(_.Fragment,null,_.createElement(Ye,{variant:"body",size:"medium"},`${d.length}`),_.createElement(Jn,{direction:"horizontal",size:8}),_.createElement(Pi,{color:"black"})),start:_.createElement(lx,{color:"gray",size:16}),onClick:()=>t($.customTokens)},W={id:"widget-setting-language-item-btn",title:_.createElement(Ye,{variant:"title",size:"xmedium"},dt.t("Language")),start:_.createElement(ex,{color:"gray",size:16}),end:_.createElement(_.Fragment,null,_.createElement(Ye,{variant:"body",size:"medium"},s),_.createElement(Jn,{direction:"horizontal",size:8}),_.createElement(Pi,{color:"black"})),onClick:()=>t($.languages)},j={id:"widget-setting-infinite-approval-item-btn",title:_.createElement(_.Fragment,null,_.createElement(Ye,{variant:"title",size:"xmedium"},dt.t("Infinite approval")),_.createElement(Jn,{direction:"horizontal",size:4}),_.createElement(cx,{side:"top",sideOffset:4,container:I(),content:_.createElement(Li,null,_.createElement(Ye,{variant:"label",size:"medium",color:"neutral700"},_.createElement("b",null,dt.t("Warning")),":\xA0",dt.t("Enabling the 'Infinite approval' mode grants unrestricted access to underlying smart contracts, allowing them to utilize the approved token amount without limitations.")))},_.createElement(Rb,{color:"gray"}))),start:_.createElement(Jb,{color:"gray",size:16}),end:_.createElement(ax,{checked:C}),onClick:S},te={id:"widget-setting-theme-item-btn",type:_.createElement(ox,null),title:_.createElement(Ye,{variant:"title",size:"xmedium"},dt.t("Theme")),end:_.createElement(ux,null,_.createElement(sx,{container:I(),items:dx,value:n,onChange:L=>o(L.id),type:"primary",borderRadius:"small"})),start:mx(n)},J=g?[]:[E,N];return m||J.push(M),f||J.push(W),J.push(j),!e?.singleTheme&&!h&&J.push(te),_.createElement(tx,{type:_.createElement(nx,{hasDivider:!0,id:"_",onClick:()=>console.log()}),items:J})}i(Ng,"SettingsLists");var Cx=hx("div",{paddingLeft:"$8"});function Wg(){let{isInCampaignMode:t,updateCampaignMode:e}=y(),o=t(),[,n]=Sx(),r=yx(),a=i(()=>{r&&o&&(n(s=>(s.delete("liquiditySources"),s),{replace:!0}),e("liquiditySources",void 0))},"onClick");return bo.createElement(oe,{header:{title:Ll.t("Settings")}},bo.createElement(ie,null,o&&bo.createElement(fx,{type:"info",variant:"alarm",title:Ll.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:bo.createElement(Cx,null,bo.createElement(gx,{id:"widget-setting-exit-campaign-mode-btn",type:"secondary",size:"small",onClick:a},Ll.t("Reset")))}),bo.createElement(Ml,null),bo.createElement(Ng,null)))}i(Wg,"SettingsPage");import{i18n as aE}from"@lingui/core";import{cancelSwap as sE}from"@rango-dev/queue-manager-rango-preset";import{useManager as lE}from"@rango-dev/queue-manager-react";import{Alert as cE}from"@rango-dev/ui";import Xl from"react";import{useParams as pE}from"react-router-dom";import{i18n as it}from"@lingui/core";import{getCurrentNamespaceOfOrNull as zx,getCurrentStep as Qx,getRelatedWalletOrNull as Hx}from"@rango-dev/queue-manager-rango-preset";import{Button as lh,CopyIcon as qx,Divider as Gx,DoneIcon as Vx,IconButton as Kx,QuoteCost as jx,RangoExplorerIcon as Xx,StepDetails as Yx,Tooltip as ch,Typography as xo,useCopyToClipboard as Zx}from"@rango-dev/ui";import{useWallets as Jx}from"@rango-dev/wallets-react";import ph from"bignumber.js";import{PendingSwapNetworkStatus as Qi}from"rango-types";import K,{useEffect as uh,useRef as Rx,useState as dh}from"react";import{useNavigate as eE}from"react-router-dom";import{i18n as eo}from"@lingui/core";var kx=[eo.t("Sunday"),eo.t("Monday"),eo.t("Tuesday"),eo.t("Wednesday"),eo.t("Thursday"),eo.t("Friday"),eo.t("Saturday")];function Bg(t){let e=new Date(t),o=e.getDate(),n=e.toLocaleString("default",{month:"long"}),r=e.getFullYear();return`${e.getDay()===new Date().getDay()?eo.t("Today"):`${kx[e.getDay()]} ${o} ${n} ${r}`}, ${new Date(t).toLocaleTimeString()}`}i(Bg,"timeSince");function Mg(t){return t.finishTime?Bg(parseInt(t.finishTime)):Bg(parseInt(t.creationTime))}i(Mg,"getSwapDate");import{PendingSwapNetworkStatus as $i}from"rango-types";import Fi from"react";import{i18n as _i}from"@lingui/core";import{Button as Lg,Divider as Pl,MessageBox as Tx}from"@rango-dev/ui";import to from"react";var Pg=i(({onCancel:t,onClose:e})=>to.createElement(to.Fragment,null,to.createElement(Pl,{size:20}),to.createElement(Tx,{type:"error",title:_i.t("Cancel Swap"),description:_i.t("Are you sure you want to cancel this swap?")}),to.createElement(Pl,{size:32}),to.createElement(Lg,{variant:"contained",id:"widget-swap-details-modal-cancel-swap-yes-btn",type:"primary",size:"large",onClick:t},_i.t("Yes, Cancel it")),to.createElement(Pl,{size:12}),to.createElement(Lg,{id:"widget-swap-details-modal-cancel-swap-no-btn",variant:"outlined",type:"primary",size:"large",onClick:e},_i.t("No, Continue"))),"CancelContent");import{i18n as Di}from"@lingui/core";import{Button as _g,Divider as _l,MessageBox as vx,Typography as wx}from"@rango-dev/ui";import Ht from"react";var Dg=i(({onDelete:t,onClose:e})=>Ht.createElement(Ht.Fragment,null,Ht.createElement(_l,{size:20}),Ht.createElement(vx,{type:"error",title:Di.t("Delete Transaction"),description:Di.t("Are you sure you want to delete this swap?")}),Ht.createElement(_l,{size:32}),Ht.createElement(_g,{id:"widget-swap-details-modal-delete-swap-yes-btn",variant:"contained",type:"primary",size:"large",onClick:t},Di.t("Yes, Delete it")),Ht.createElement(_l,{size:12}),Ht.createElement(_g,{id:"widget-swap-details-modal-delete-swap-no-btn",variant:"outlined",type:"primary",size:"large",onClick:e},Ht.createElement(wx,{variant:"title",size:"medium",color:"primary"},Di.t("No, Cancel")))),"DeleteContent");import{i18n as Dl}from"@lingui/core";import{PendingSwapNetworkStatus as $l}from"rango-types";var Fl={[$l.WaitingForNetworkChange]:{type:"loading",title:Dl.t("Change Network")},[$l.WaitingForConnectingWallet]:{type:"warning",title:Dl.t("Connect Wallet")},[$l.NetworkChanged]:{type:"success",title:Dl.t("Network Changed")}};import{warn as bx}from"@rango-dev/logging-core";import{MessageBox as xx,Wallet as Ex}from"@rango-dev/ui";import{useWallets as Ix}from"@rango-dev/wallets-react";import en,{useState as Ax}from"react";import{styled as $g}from"@rango-dev/ui";var Fg=$g("div",{display:"flex",justifyContent:"center"}),w5=$g("div",{maxWidth:280,"& ._typography":{wordWrap:"break-word",display:"block"}});var Og=i(t=>{let{type:e,title:o,currentStepWallet:n,message:r,showWalletButton:a,walletButtonDisabled:s}=t,[l,c]=Ax(),{getWalletInfo:p,state:u}=Ix(),d=n?.walletType,h=d?pn(u(d)):null,g=d?p(d):null,f=a&&!!d&&!!h&&!!g,{list:m}=ft(),C=i(()=>{if(d){let S=m.find(k=>k.type===d);S?c(S):bx(new Error(`It seems requested wallet to be connected is not available in the list. requested wallet: ${S}`))}},"handleWalletItemClick");return en.createElement(en.Fragment,null,en.createElement(xx,{type:e,title:o,description:r}),f&&en.createElement(Fg,null,en.createElement(Ex,{container:I(),title:g.name,image:g.img,type:d,state:h,link:g.installLink,disabled:s,onClick:C})),en.createElement(po,{wallet:l,onClose:()=>{c(void 0)}}))},"WalletStateContent");function Ol(t){let{state:e,onClose:o,onDelete:n,onCancel:r,currentStepWallet:a,message:s,walletButtonDisabled:l}=t,c=e===$i.WaitingForNetworkChange||e===$i.WaitingForConnectingWallet||e===$i.NetworkChanged;return Fi.createElement(Z,{open:!!e,onClose:o,container:document.getElementById(De.SWAP_BOX_ID)||document.body},c&&Fi.createElement(Og,{type:Fl[e].type,title:Fl[e].title,currentStepWallet:a,message:s,walletButtonDisabled:l,showWalletButton:e!==$i.WaitingForNetworkChange}),e==="delete"&&Fi.createElement(Dg,{onClose:o,onDelete:n}),e==="cancel"&&Fi.createElement(Pg,{onClose:o,onCancel:r}))}i(Ol,"SwapDetailsModal");import{i18n as Rn}from"@lingui/core";import{Button as Ul,Divider as er,MessageBox as Ug,TokenAmount as Nx,Typography as zg}from"@rango-dev/ui";import Ce from"react";import{useNavigate as Wx}from"react-router-dom";function zl(t){let{open:e,onClose:o,status:n,priceValue:r,usdValue:a,realUsdValue:s,realValue:l,token:c,chain:p,percentageChange:u,description:d,diagnosisUrl:h}=t,g=Wx(),{showProfileBanner:f}=re();return Ce.createElement(Z,{open:e,onClose:o,container:document.getElementById(De.SWAP_BOX_ID)||document.body},n==="success"?Ce.createElement(Ug,{type:"success",title:Rn.t("Swap Successful")},Ce.createElement(Nx,{direction:"vertical",tooltipContainer:I(),type:"output",centerAlign:!0,price:{value:r,usdValue:a,realUsdValue:s,realValue:l},token:c,chain:p,percentageChange:u}),Ce.createElement(er,{size:12}),Ce.createElement(zg,{variant:"body",size:"medium",color:"neutral700",align:"center"},d)):Ce.createElement(Ug,{type:"error",title:Rn.t("Transaction Failed"),description:d}),Ce.createElement(er,{size:30}),n==="success"&&Ce.createElement(Ce.Fragment,null,f&&Ce.createElement(Ce.Fragment,null,Ce.createElement("img",{src:"https://raw.githubusercontent.com/rango-exchange/assets/main/banners/widget/profile.jpg",alt:"Profile Banner"}),Ce.createElement(er,{size:30})),Ce.createElement(Ul,{id:"widget-swap-details-modal-done-btn",variant:"contained",type:"primary",size:"large",onClick:()=>{g("../../")}},Rn.t("Done"))),Ce.createElement(er,{size:12}),h&&Ce.createElement(Ce.Fragment,null,Ce.createElement(Ul,{variant:"contained",id:"widget-swap-detail-modal-diagnosis-btn",type:"primary",size:"large",onClick:()=>window.open(h,"_blank")},Rn.t("Diagnosis")),Ce.createElement(er,{size:12})),Ce.createElement(Ul,{id:"widget-swap-details-modal-see-details-btn",variant:"outlined",type:"primary",size:"large",onClick:o},Ce.createElement(zg,{variant:"title",size:"medium",color:"primary"},Rn.t("See Details"))))}i(zl,"SwapDetailsCompleteModal");import Ux from"react";import{i18n as Dx}from"@lingui/core";import{Alert as rh,IconButton as $x,LinkIcon as Fx}from"@rango-dev/ui";import oo,{Fragment as Ox}from"react";import{Alert as Mx,ChevronDownIcon as Lx,IconButton as Px}from"@rango-dev/ui";import on,{useState as _x}from"react";import{css as tr,darkTheme as Qg,styled as qt,Typography as Bx}from"@rango-dev/ui";var Hg=qt("div",{display:"flex",flexDirection:"column",flexGrow:1,overflow:"hidden"}),Oi=qt("div",{width:"100%","& ._icon-button":{"&:hover":{"& svg":{color:"$secondary550",[`.${Qg} &`]:{color:"$secondary500"}}}}}),qg=qt(wn,{padding:"$0 $20 $20 $20"}),s4=qt("div",{display:"flex",flexDirection:"column",gap:"$10"}),Gg=qt("div",{height:"450px",display:"flex",alignItems:"center",justifyContent:"center"}),l4=qt("div",{display:"flex",justifyContent:"center",width:"100%",paddingTop:"33%",flex:1}),tn=tr({display:"flex",width:"100%",justifyContent:"space-between",alignItems:"center",padding:"$10 $20",borderBottom:"1px solid",$$color:"$colors$neutral300",[`.${Qg} &`]:{$$color:"$colors$neutral400"},borderColor:"$$color",color:"$neutral500"}),Vg=tr({padding:"$5 0"}),Ui=tr({display:"flex",justifyContent:"center",alignItems:"center",height:"$24"}),Kg=tr({display:"flex",width:"100%",padding:"$15 $20 $20",flexDirection:"column",alignItems:"start"}),jg=tr({width:"100%",padding:"0 $20 $10"}),Xg=qt("a",{fontSize:"$16",fontWeight:"$400",color:"$neutral700",display:"flex",alignItems:"center",justifyContent:"center"}),Yg=qt("div",{display:"flex",flexDirection:"column",gap:"$5"}),zi=qt(Bx,{wordBreak:"break-word"});import{styled as Ql}from"@rango-dev/ui";var Zg=Ql("div",{display:"flex",flexDirection:"column",gap:"$10"}),Jg=Ql("div",{transition:"transform 0.3s ease-in-out",variants:{rotated:{true:{transform:"rotate(180deg)"}}}}),Rg=Ql("div",{transition:"max-height 0.3s ease-in-out",maxHeight:"0px",overflow:"hidden",variants:{open:{true:{maxHeight:"200px"}}}});function eh(t){let{message:e}=t,[o,n]=_x(!1);return on.createElement(Mx,{type:"error",title:e.shortMessage,containerStyles:{"& .footer":{paddingTop:"$0"}},action:e.detailedMessage.content&&on.createElement(Px,{onClick:()=>n(r=>!r),variant:"ghost",size:"xsmall"},on.createElement(Jg,{rotated:o},on.createElement(Lx,{size:12,color:"gray"}))),footer:on.createElement(Rg,{open:o},on.createElement(zi,{variant:"body",size:"xsmall",color:"neutral700"},e.detailedMessage.content))})}i(eh,"FailedAlert");import{i18n as th}from"@lingui/core";import{Alert as Hl,Button as oh}from"@rango-dev/ui";import{PendingSwapNetworkStatus as ql}from"rango-types";import or from"react";function nh(t){let{switchNetwork:e,setNetworkModal:o,message:n,showNetworkModal:r}=t;return e?or.createElement(Hl,{type:"warning",title:n.shortMessage,action:or.createElement(oh,{id:"widget-swap-details-warning-alert-change-network-btn",size:"xxsmall",type:"warning",onClick:()=>{o(ql.WaitingForNetworkChange),e().catch(a=>{console.log(a)})}},th.t("Change"))}):r===ql.WaitingForConnectingWallet?or.createElement(Hl,{type:"warning",title:n.shortMessage,action:or.createElement(oh,{id:"widget-swap-details-warning-alert-connect-wallet-btn",size:"xxsmall",type:"warning",onClick:()=>{o(ql.WaitingForConnectingWallet)}},th.t("Connect"))}):or.createElement(Hl,{type:"warning",title:n.shortMessage})}i(nh,"WarningAlert");function Gl(t){let{switchNetwork:e,showNetworkModal:o,setNetworkModal:n,message:r,step:a,hasAlreadyProceededToSign:s}=t,l=Tn(a),c=a.status==="waitingForApproval"&&!l,p=a.status==="running"&&!l,u=p&&!s||c&&!a.explorerUrl?.length;return oo.createElement(Zg,null,a.explorerUrl?.map((d,h,g)=>{let f=h+d.url,m=h===g.length-1,C=(m&&p||c)&&!u,S=m&&a.status==="failed";return oo.createElement(Ox,{key:f},oo.createElement(rh,{type:m&&(C&&"loading"||S&&"error")||"success",title:d.description?`${d.description} Tx`:Dx.t("View transaction"),action:d.url&&oo.createElement($x,{id:"widget-swap-details-tx-link-icon-btn",variant:"ghost",size:"xsmall",onClick:()=>window.open(d.url,"_blank")},oo.createElement(Fx,{size:12}))}))}),u&&oo.createElement(rh,{type:"loading",title:r.shortMessage}),a.status!=="failed"&&l&&oo.createElement(nh,{switchNetwork:e,showNetworkModal:o,setNetworkModal:n,message:r}),a.status==="failed"&&oo.createElement(eh,{message:r}))}i(Gl,"SwapDetailsAlerts");var ih=2e3;var ah=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:st(a.fromBlockchain,e)??"",image:a.fromBlockchainLogo??""},price:{value:B(l,6,6),realValue:l??""}},to:{token:{displayName:a.toSymbol,image:a.toLogo},chain:{displayName:st(a.toBlockchain,e)??"",image:a.toBlockchainLogo??""},price:{value:B(a.outputAmount||a.expectedOutputAmountHumanReadable,6,6),realValue:a.outputAmount||a.expectedOutputAmountHumanReadable||""}},swapper:{displayName:rn(a.swapperId,o)??"",image:a.swapperLogo??"",type:a.swapperType},internalSwaps:a.internalSwaps?a.internalSwaps.map(c=>({from:{chain:{displayName:st(c.fromBlockchain,e)??"",image:c.fromBlockchainLogo??""}},to:{chain:{displayName:st(c.toBlockchain,e)??"",image:c.toBlockchainLogo??""}},swapper:{displayName:rn(c.swapperId,o)??"",image:c.swapperLogo??"",type:c.swapperType}})):[],alerts:Ux.createElement(Gl,{step:a,hasAlreadyProceededToSign:r,...n})}})},"getSteps");function sh(t){if(Tn(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(sh,"getStepState");function Vl(t){let{swap:e,requestId:o,onDelete:n,onCancel:r}=t,{canSwitchNetworkTo:a,connect:s,getWalletInfo:l}=Jx(),c=y().blockchains(),p=y().swappers(),{findToken:u}=y(),d=O.use.retry(),h=re.use.isActiveTab(),g=eE(),[f,m]=Zx(ih),C=Rx(null),[S,k]=dh(null),[T,v]=dh(null),b=i(()=>{r(),k(null)},"onCancel"),A=be.use.getNotifications(),D=be.use.removeNotification(),w=A(),x=Qx(e),E=x?.networkStatus;uh(()=>{w.find(mt=>mt.requestId===e.requestId)&&(e.status==="success"||e.status==="failed"?(v(e.status),D(e.requestId)):T&&v(null))},[e.status,e.requestId]),uh(()=>{L?k(Qi.WaitingForNetworkChange):E===Qi.WaitingForConnectingWallet||E===Qi.NetworkChanged?k(E):k(null)},[E]);let N=uu(e),M=x?zx(e,x):null,W=x?Hx(e,x):null,j=Mg(e),te=du(e),J=i(ve=>!!l(ve)?.mobileWallet,"isMobileWallet"),L=E===Qi.WaitingForNetworkChange&&!!M&&!!W?.walletType&&(J(W.walletType)||a(W.walletType,M.network)),X=L?s.bind(null,W.walletType,[{namespace:M.namespace,network:M.network}]):void 0,se=pu(e,x),z=ah({swap:e,switchNetwork:X,showNetworkModal:E,setNetworkModal:k,message:se,blockchains:c,swappers:p}),me=z.length,[vt,Ze]=[e.steps[0],e.steps[me-1]],le=Ze.outputAmount||Ze.expectedOutputAmountHumanReadable,at=e.steps.reduce((ve,mt)=>ve+parseFloat(mt.feeInUsd||""),0),G=e.steps.find(ve=>ve.diagnosisUrl)?.diagnosisUrl,P=B(parseFloat(le||"0")*(Ze.toUsdPrice||0),4,4),q=B(parseFloat(e.inputAmount)*(vt.fromUsdPrice||0),4,4),V=le?new ph(le).multipliedBy(Ze.toUsdPrice||0).toString():"",fe=new ph(e.inputAmount).multipliedBy(vt.fromUsdPrice||0).toString(),ne=Pt(q,P),ge=se.detailedMessage.content||se.shortMessage,Fe=e.status==="success"?it.t({id:"You have received {amount} {token} in {conciseAddress} wallet on {chain} chain.",values:{amount:B(le,6,6),token:z[me-1].to.token.displayName,conciseAddress:yr(e.wallets[z[me-1].to.chain.displayName]?.address||""),chain:z[me-1].to.chain.displayName}}):K.createElement(Yg,null,K.createElement(xo,{variant:"body",size:"medium",color:"neutral700",align:"center"},ge?"":it.t("Transaction was not sent."),N?`${it.t({id:"{amount} {symbol} on {blockchain} remains in your wallet.",values:{amount:N.outputAmount,symbol:N.symbol,blockchain:N.blockchain}})}`:""),ge&&K.createElement(zi,{align:"center",variant:"body",size:"medium",color:"neutral700"},K.createElement("b",null,"Reason:")," ",ge));return K.createElement(oe,{header:{title:it.t("Swap Details"),onCancel:e.status==="running"?()=>k("cancel"):void 0,suffix:e.status!=="running"&&K.createElement(Vt,null,K.createElement(lh,{id:"widget-swap-details-delete-btn",variant:"ghost",type:"error",size:"xsmall",onClick:()=>k("delete")},K.createElement(xo,{size:"medium",variant:"label",color:"error"},it.t("Delete"))))},footer:te&&!T&&K.createElement(lh,{fullWidth:!0,id:"widget-swap-details-try-again-btn",variant:"contained",type:"primary",size:"large",onClick:()=>{let ve=Wr(e,c,u);d(ve),setTimeout(()=>{g("../../")},0)}},it.t("Try again"))},K.createElement(ie,{compact:!0,view:!0},K.createElement(Oi,null,K.createElement("div",{className:tn()},K.createElement(xo,{variant:"label",size:"large",color:"neutral700"},`${it.t("Request ID")}`),K.createElement("div",{className:Ui()},K.createElement(xo,{variant:"label",size:"small",color:"neutral700"},o),K.createElement(ch,{container:I(),content:f?it.t("Copied To Clipboard"):it.t("Copy Request ID"),open:f||void 0,side:"bottom",alignOffset:-16,align:"end"},K.createElement(Kx,{id:"widget-swap-details-done-copy-icon-btn",variant:"ghost",onClick:m.bind(null,o||"")},f?K.createElement(Vx,{size:16,color:"secondary"}):K.createElement(qx,{size:16,color:"gray"}))),K.createElement(Xg,{target:"_blank",href:`${Cc}/swap/${o}`},K.createElement(ch,{container:I(),content:it.t("View on Rango Explorer"),side:"bottom"},K.createElement(Xx,{size:20}))))),K.createElement("div",{className:tn()},K.createElement(xo,{variant:"label",size:"large",color:"neutral700"},e.finishTime?it.t("Finished at"):it.t("Created at")),K.createElement(xo,{variant:"label",size:"small",color:"neutral700"},j))),K.createElement("div",{className:Kg()},K.createElement(jx,{fee:B(String(at),2,2),time:ln(dr(e.steps)),steps:me}),K.createElement(Bn,{from:{price:{value:B(e.inputAmount,6,6),usdValue:q,realUsdValue:fe,realValue:e.inputAmount},token:{displayName:z[0].from.token.displayName,image:z[0].from.token.image},chain:{image:z[0].from.chain.image,displayName:z[0].from.chain.displayName}},to:{price:{value:B(le,6,6),usdValue:P,realUsdValue:V,realValue:le||""},token:{displayName:z[me-1].to.token.displayName,image:z[me-1].to.token.image},chain:{image:z[me-1].to.chain.image,displayName:z[me-1].to.chain.displayName}},percentageChange:B(ne,2,2),warningLevel:_t(ne??0)})),K.createElement("div",{className:jg()},K.createElement(xo,{variant:"title",size:"small"},it.t("Swaps steps"))),K.createElement(Gx,{size:8}),K.createElement(qg,{ref:C},z.map((ve,mt)=>{let oc=mt,nn=sh(e.steps[mt]),Uh=nn==="error"||nn==="in-progress"||nn==="warning"||nn==="completed"&&mt===z.length-1;return K.createElement(Yx,{key:oc,step:ve,type:"swap-progress",ref:C,state:nn,hasSeparator:mt!==0,tabIndex:oc,isFocused:Uh,tooltipContainer:I()})}))),K.createElement(Ol,{state:S,onClose:()=>k(null),onCancel:b,onDelete:n,message:se.detailedMessage.content,currentStepWallet:W,walletButtonDisabled:!h}),K.createElement(zl,{open:!!T,diagnosisUrl:G,onClose:()=>v(null),status:e.status==="success"?"success":"failed",priceValue:B(le,6,6),usdValue:P,realUsdValue:V,realValue:le||"",percentageChange:B(ne,2,2),token:{displayName:z[me-1].to.token.displayName,image:z[me-1].to.token.image},chain:{image:z[me-1].to.chain.image},description:Fe}))}i(Vl,"SwapDetails");import{i18n as qi}from"@lingui/core";import{Divider as gh,NotFound as iE,Skeleton as rr,Typography as Gi}from"@rango-dev/ui";import ke from"react";import{i18n as tE}from"@lingui/core";import{Divider as oE,Skeleton as nE,Typography as rE}from"@rango-dev/ui";import Te from"react";import{css as Tt,styled as Kl}from"@rango-dev/ui";var mh=Kl("div",{width:"100%",height:"100%",padding:"$10 $20"}),nr=Kl("div",{backgroundColor:"$neutral100",borderRadius:"$xm",padding:"$10 $15"}),Hi=Kl("div",{width:"0px",height:"$20",borderLeft:"1px dashed $neutral700",marginLeft:"25px"}),kK=Tt({display:"flex",justifyContent:"space-between",alignItems:"center"}),TK=Tt({display:"flex",justifyContent:"space-between",alignItems:"center"}),vK=Tt({paddingTop:"$15",display:"flex"}),wK=Tt({padding:"$15 $0"}),bK=Tt({width:"0px",height:"$16",borderLeft:"1px solid $neutral400",marginLeft:"13px"}),xK=Tt({paddingBottom:"$10"}),EK=Tt({display:"flex",justifyContent:"start",alignItems:"center"}),IK=Tt({paddingTop:"$5",display:"flex",alignItems:"center"}),AK=Tt({display:"flex",alignItems:"center"}),NK=Tt({padding:"$4 $6",display:"flex",justifyContent:"center",alignItems:"center"}),fh=Tt({display:"flex",paddingTop:"$10",paddingBottom:"$5"});function jl(){return Te.createElement(mh,null,Te.createElement(Pn,{type:"swap-preview"}),Te.createElement("div",{className:"swaps-steps"},Te.createElement(rE,{variant:"title",size:"small"},tE.t("Swaps steps"))),Te.createElement(Te.Fragment,null,Te.createElement(nr,null,Te.createElement(Nt,{separator:!1}),Te.createElement("div",{className:fh()},Te.createElement(oE,{direction:"horizontal",size:20}),Te.createElement(nE,{height:22,variant:"rectangular"}))),Te.createElement(Hi,null),Te.createElement(nr,null,Te.createElement(Nt,{separator:!1})),Te.createElement(Hi,null),Te.createElement(nr,null,Te.createElement(Nt,{separator:!1})),Te.createElement(Hi,null),Te.createElement(nr,null,Te.createElement(Nt,{separator:!1}))))}i(jl,"LoadingSwapDetails");function hh(t){let{requestId:e,showSkeleton:o}=t;return ke.createElement(oe,{header:{title:qi.t("Swap Details"),suffix:ke.createElement(Vt,null)}},o&&ke.createElement(Hg,null,ke.createElement(Oi,null,ke.createElement("div",{className:tn()},ke.createElement(Gi,{variant:"label",size:"large",color:"neutral700"},`${qi.t("Request ID")}`),ke.createElement("div",{className:Ui()},ke.createElement(Gi,{variant:"label",size:"small",color:"neutral700"},ke.createElement(rr,{width:60,height:10,variant:"rounded"})),ke.createElement(gh,{direction:"horizontal",size:4}),ke.createElement(rr,{width:16,height:16,variant:"rectangular"}),ke.createElement(gh,{direction:"horizontal",size:4}),ke.createElement(rr,{width:16,height:16,variant:"rectangular"}))),ke.createElement("div",{className:tn()},ke.createElement(Gi,{className:Vg(),variant:"label",size:"large",color:"neutral700"},ke.createElement(rr,{width:60,height:10,variant:"rounded"})),ke.createElement(Gi,{variant:"label",size:"small",color:"neutral700"},ke.createElement(rr,{width:60,height:10,variant:"rounded"})))),ke.createElement(jl,null)),!o&&ke.createElement(Gg,null,ke.createElement(iE,{title:qi.t("Not found"),description:qi.t({id:"Swap with request ID = {requestId} not found.",values:{requestId:e}})})))}i(hh,"SwapDetailsPlaceholder");function yh(){let{manager:t,state:e}=lE(),o=!e.loadedFromPersistor,n=pt(t),{requestId:r}=pE(),a=je(),{fetchStatus:s}=y();if(!r)return Xl.createElement(cE,{containerStyles:{margin:"20px"},type:"error",title:aE.t("The request ID is necessary to display the swap details.")});let l=o||s==="loading",c=r?n.find(({swap:h})=>h.requestId===r):void 0,p=i(()=>{if(c?.id){let h=t?.get(c.id);h&&sE(h)}},"onCancel"),u=i(async()=>{if(c?.id)try{t?.deleteQueue(c.id),a()}catch(h){console.log(h)}},"onDelete"),d=c?.swap;return!d||l?Xl.createElement(hh,{requestId:r,showSkeleton:l}):Xl.createElement(Vl,{swap:d,requestId:r,onCancel:p,onDelete:u})}i(yh,"SwapDetailsPage");import{i18n as Sh}from"@lingui/core";import{Divider as uE,getCategoriesCount as dE,SelectableCategoryList as mE,styled as kh,Typography as fE,Wallet as gE}from"@rango-dev/ui";import Bt,{useState as Ch}from"react";var hE=kh("div",{display:"flex",justifyContent:"center",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5"}),yE=kh(ie,{textAlign:"center"});function Th(){let{fetchStatus:t}=y(),[e,o]=Ch("ALL"),n=y().blockchains(),{config:r}=y(),[a,s]=Ch(),l=re.use.isActiveTab(),{list:c}=ft(),p=zc(c,n),d=dE(p)!==1,h=Qc(c,e),g=i(f=>{Wc(c,r.multiWallets)||s(f)},"handleWalletItemClick");return Bt.createElement(oe,{header:{title:Sh.t("Connect Wallets")}},Bt.createElement(yE,null,d&&Bt.createElement(Bt.Fragment,null,Bt.createElement(mE,{setCategory:o,category:e,blockchains:p,isLoading:t==="loading"}),Bt.createElement(uE,{size:24})),Bt.createElement(fE,{variant:"title",size:"xmedium",align:"center"},Sh.t("Choose a wallet to connect.")),Bt.createElement(hE,null,h.map((f,m)=>{let C=`wallet-${m}-${f.type}`;return Bt.createElement(gE,{key:C,...f,container:I(),onClick:()=>g(f),isLoading:t==="loading",disabled:!l})}),Bt.createElement(po,{wallet:a,onClose:()=>{s(void 0)}}))))}i(Th,"WalletsPage");function vh(){return hu(),Da(),SE([{path:$.home,element:_e.createElement(Zf,null)},{path:$.routes,element:_e.createElement(og,null)},{path:$.fromSwap,children:[{index:!0,element:_e.createElement(Wl,{type:"source"})},{path:$.blockchains,element:_e.createElement(Wi,{type:"source"})}]},{path:$.toSwap,children:[{index:!0,element:_e.createElement(Wl,{type:"destination"})},{path:$.blockchains,element:_e.createElement(Wi,{type:"destination"})}]},{path:$.settings,children:[{index:!0,element:_e.createElement(Wg,null)},{path:$.languages,element:_e.createElement(Rf,null)},{path:$.exchanges,element:_e.createElement(vl,{sourceType:"Exchanges"})},{path:$.bridges,element:_e.createElement(vl,{sourceType:"Bridges"})},{path:$.customTokens,children:[{index:!0,element:_e.createElement(sf,null)},{path:$.addCustomTokens,children:[{index:!0,element:_e.createElement(Zu,null)},{path:$.blockchains,element:_e.createElement(Wi,{hideCategory:!0,type:"custom-token"})}]}]}]},{path:$.swaps,children:[{index:!0,element:_e.createElement(If,null)},{path:$.swapDetails,element:_e.createElement(yh,null)}]},{path:$.wallets,element:_e.createElement(Th,null)},{path:$.confirmSwap,element:_e.createElement(Vm,null)}])}i(vh,"AppRoutes");import{useQueueManager as IE}from"@rango-dev/queue-manager-rango-preset";import{splitWalletNetwork as AE}from"@rango-dev/wallets-shared";import{isEvmBlockchain as NE}from"rango-sdk";import{useContext as WE,useEffect as Nh,useState as Wh}from"react";import{globalCss as CE}from"@rango-dev/ui";var wh=i(()=>CE({"@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 bh(){let{setWatermark:t,setShowProfileBanner:e}=re();return{fetchApiConfig:i(async()=>{let n=await fetch(`${Lt("BASE_URL")}/meta/dapp/config?apiKey=${Lt("API_KEY")}`);if(!n.ok)throw new Error(`Request failed with status: ${n.status} `);let r=await n.json();t(r.config.watermark),e(r.config.banners.profile)},"fetchApiConfig")}}i(bh,"useFetchApiConfig");import{useWallets as kE}from"@rango-dev/wallets-react";import{useEffect as TE,useRef as vE}from"react";function xh(){let{connect:t,state:e}=kE(),o=vE({}),{fetchStatus:n}=y(),r=new URLSearchParams(location.search).get("autoConnect")||"",a=e(r);TE(()=>{n==="success"&&r&&a.installed&&!a.connecting&&!a.connected&&!o.current[r]&&(o.current[r]=!0,t(r))},[a,n])}i(xh,"useForceAutoConnect");import{isApprovalTX as wE,RouteEventType as Eh,StepEventType as Ih,StepExecutionEventStatus as bE,WidgetEvents as Vi}from"@rango-dev/queue-manager-rango-preset";import{useEffect as Ah}from"react";function Yl(){let t=be.use.setNotification(),{connectedWallets:e,fetchBalances:o}=y();Ah(()=>{let n=i(r=>{let{event:a,step:s,route:l}=r;if(a.type===Ih.TX_EXECUTION&&a.status===bE.TX_SENT&&!wE(s)||a.type===Ih.SUCCEEDED){let p=e.find(d=>d.chain===s?.fromBlockchain),u=s?.fromBlockchain!==s?.toBlockchain&&e.find(d=>d.chain===s?.toBlockchain);p&&o([p]),u&&o([u])}t(a,l)},"handleStepEvent");return he.on(Vi.StepEvent,n),()=>he.off(Vi.StepEvent,n)},[he,e]),Ah(()=>{let n=i(r=>{let{event:a,route:s}=r;(a.type===Eh.FAILED||a.type===Eh.SUCCEEDED)&&t(a,s)},"handleRouteEvent");return he.on(Vi.RouteEvent,n),()=>he.off(Vi.RouteEvent,n)},[he])}i(Yl,"useSubscribeToWidgetEvents");import{useManager as xE}from"@rango-dev/queue-manager-react";import{useEffect as EE}from"react";function Zl(){let{isSynced:t,syncNotifications:e}=be(),{manager:o,state:n}=xE();EE(()=>{be.persist.hasHydrated()&&n.loadedFromPersistor&&!t&&e(pt(o))},[be.persist.hasHydrated(),n.loadedFromPersistor,t])}i(Zl,"useSyncNotifications");function Jl(){xh(),wh(),Yl(),Zl();let t=y().blockchains(),{canSwitchNetworkTo:e}=Xr(),[o,n]=Wh(""),[r,a]=Wh(),s=WE(Er),l=t.filter(NE),{fetchApiConfig:c}=bh();Nh(()=>()=>gu(),[]),IE({lastConnectedWallet:o,clearDisconnectedWallet:()=>{a(void 0)},disconnectedWallet:r,evmChains:l,canSwitchNetworkTo:e}),Nh(()=>(ao.init(),be.persist.hasHydrated()||be.persist.rehydrate(),s.onConnectWallet(n),s.onDisconnectWallet(p=>{a(p),p===AE(o)?.[0]&&n("")}),c().catch(console.log),ao.destroy),[])}i(Jl,"useBootstrap");import{styled as BE}from"@rango-dev/ui";var Bh=BE("div",{fontFamily:"$widget",boxSizing:"border-box",textAlign:"left","& *, *::before, *::after":{boxSizing:"inherit"},"& *:focus-visible":{outlineColor:"$info500",transition:"none"},"& ul, ol, li":{listStyleType:"none"}});function Ki(){Jl();let{config:t}=y(),{activeTheme:e}=Qo(t?.theme||{}),{activeLanguage:o}=Rt();return Rl.createElement(ME,{language:o},Rl.createElement(Bh,{id:"swap-container",className:e()},Rl.createElement(vh,null)))}i(Ki,"Main");import{setSolanaSignerConfig as JE}from"@rango-dev/signer-solana";import tc,{useEffect as $h,useMemo as RE}from"react";import{useState as LE}from"react";var PE=i(()=>{let[t,e]=LE(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=Nc(a);if(s){let l=o(s);e(l)}},"handleLoadCustomFont")}},"useFontLoader"),Mh=PE;import{checkWaitingForNetworkChange as _E,makeQueueDefinition as DE}from"@rango-dev/queue-manager-rango-preset";import{Provider as $E}from"@rango-dev/queue-manager-react";import{useWallets as FE}from"@rango-dev/wallets-react";import{convertEvmBlockchainMetaToEvmChainInfo as OE}from"@rango-dev/wallets-shared";import{isEvmBlockchain as UE}from"rango-types";import zE,{useMemo as QE}from"react";function HE(t){let{providers:e,getSigners:o,state:n,connect:r,canSwitchNetworkTo:a,getWalletInfo:s}=FE(),l=QE(()=>DE({API_KEY:t.apiKey||Lt("API_KEY"),BASE_URL:Lt("BASE_URL"),emitter:{emit:he.emit}}),[t.apiKey]),{blockchains:c,connectedWallets:p}=y(),u=c(),d={blockchains:p.map(v=>({accounts:[v],name:v.chain}))},h=i(async(v,b)=>a(v,b.network)?await r(v,[b]):void 0,"switchNetwork"),g=i(v=>!!s(v).mobileWallet,"isMobileWallet"),f=u.filter(v=>v.enabled).reduce((v,b)=>(v[b.name]=b,v),{}),m=u.filter(UE),C=i(v=>{let{supportedChains:b}=s(v);return un(b)},"getSupportedChainNames"),S=e(),k={meta:{blockchains:f,evmBasedChains:m,evmNetworkChainInfo:OE(m),getSupportedChainNames:C},getSigners:o,wallets:d,providers:S,switchNetwork:h,canSwitchNetworkTo:a,state:n,isMobileWallet:g},T=re.use.isActiveTab();return zE.createElement($E,{queuesDefs:[l],context:k,onPersistedDataLoaded:v=>{_E(v)},isPaused:!T},t.children)}i(HE,"QueueManager");var Lh=HE;import{useManager as jE}from"@rango-dev/queue-manager-react";import XE,{createContext as YE,useContext as ZE}from"react";function Ph(){let{findToken:t}=y(),e=y().blockchains(),o=y().tokens(),{setFromBlockchain:n,setFromToken:r,setToBlockchain:a,setToToken:s,setInputAmount:l}=O();return i(p=>{let{fromBlockchain:u,fromToken:d,toBlockchain:h,toToken:g,requestAmount:f}=p,m={blockchains:e,tokens:o};if(u!==void 0){let C=e.find(S=>S.name===u)??null;n(C)}if(d!==void 0){let C=d?t(d)??null:null;r({meta:m,token:C})}if(h!==void 0){let C=e.find(S=>S.name===h)??null;a(C)}if(g!==void 0){let C=g?t(g)??null:null;s({meta:m,token:C})}f!==void 0&&l(f)},"updateQuoteInputs")}i(Ph,"useUpdateQuoteInputs");import{cancelSwap as qE,getCurrentNamespaceOfOrNull as GE,getCurrentStep as VE,getRelatedWalletOrNull as KE}from"@rango-dev/queue-manager-rango-preset";var ji=class{static{i(this,"WidgetHistory")}constructor(e,o){this.manager=e,this.actions=o}getAllSwaps(){return pt(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=Wr(e,o.blockchains,this.actions.findToken);return this.actions.retrySwap(n)}cancel(e){let o=this.manager?.get(e);o&&qE(o)}getCurrentStepInfo(e){let o=VE(e);return{step:o,wallet:o?KE(e,o):null,network:o?GE(e,o)?.network:null}}};var _h=YE(void 0);function ec(t){let{manager:e}=jE(),o=re.use.isActiveTab(),n=O.use.retry(),{findToken:r,getBalances:a,getConnectedWalletsDetails:s,fetchBalances:l}=y(),c=new ji(e,{retrySwap:n,findToken:r}),{fetchingWallets:p}=y(),u=_c(a()),d=y().blockchains(),h=y().tokens(),g=y().swappers(),f=y().fetchStatus,m=Rt().resetLanguage,C=be().getNotifications(),S=be().clearNotifications,k=Ph(),{fromBlockchain:T,toBlockchain:v,fromToken:b,toToken:A,inputAmount:D}=O(),w={isActiveTab:o,setCurrentTabAsActive:ao.forceClaim,history:c,wallets:{isLoading:p,details:s(),totalBalance:u,refetch:async x=>l(x)},meta:{blockchains:d,tokens:h,swappers:g,loadingStatus:f,findToken:r},resetLanguage:m,notifications:{list:C,clearAll:S},quote:{quoteInputs:{fromBlockchain:T?.name??null,fromToken:b?{symbol:b.symbol,blockchain:b.blockchain,address:b.address}:null,toBlockchain:v?.name??null,toToken:A?{symbol:A.symbol,blockchain:A.blockchain,address:A.address}:null,requestAmount:D},updateQuoteInputs:k}};return XE.createElement(_h.Provider,{value:w},t.children)}i(ec,"WidgetInfo");function Dh(){let t=ZE(_h);if(!t)throw new Error("useWidget can only be used within the WidgetProvider component");return t}i(Dh,"useWidget");function Xi(t){let{onUpdateState:e,config:o}=t,n=t.config?.theme?.fontFamily,{handleLoadCustomFont:r}=Mh();return $h(()=>{n&&r(n)},[n]),RE(()=>{Hc({API_KEY:o?.apiKey||cr,BASE_URL:o?.apiUrl||Sc})},[o.apiKey,o.apiUrl]),$h(()=>{t.config?.signers?.customSolanaRPC&&JE("customRPC",t.config.signers.customSolanaRPC)},[t.config?.signers?.customSolanaRPC]),tc.createElement(Ir,{config:o,onUpdateState:e},tc.createElement(Lh,{apiKey:o.apiKey},tc.createElement(ec,null,t.children)))}i(Xi,"WidgetProvider");function Fh(t){let e=t.config?.externalWallets;return Yi.createElement($p,null,e?Yi.createElement(Ki,null):Yi.createElement(Xi,{config:t.config??lr},Yi.createElement(Ki,null)))}i(Fh,"Widget");function Oh(){let{on:t,off:e}=he;return{on:t,off:e}}i(Oh,"useWidgetEvents");var D3={DerivationPath:yn,Namespaces:hn,isOnDerivationPath:Cn,isOnNamespace:Sn};export{l3 as EventSeverity,Mo as MainEvents,S3 as Networks,T3 as PendingSwapNetworkStatus,ua as QuoteEventTypes,c3 as RouteEventType,ea as SUPPORTED_FONTS,D3 as StatefulConnect,p3 as StepEventType,u3 as StepExecutionBlockedEventStatus,d3 as StepExecutionEventStatus,De as UI_ID,ma as UiEventTypes,da as WalletEventTypes,h3 as WalletEvents,C3 as WalletTypes,Fh as Widget,Mo as WidgetEvents,Xi as WidgetProvider,Ir as WidgetWallets,ja as customizedThemeTokens,f3 as readAccountAddress,Gt as useStatefulConnect,ft as useWalletList,Xr as useWallets,Dh as useWidget,Oh as useWidgetEvents,Hy as widgetEventEmitter};
1
+ var Hh=Object.defineProperty;var i=(t,e)=>Hh(t,"name",{value:e,configurable:!0});import{EventSeverity as g3,RouteEventType as h3,StepEventType as y3,StepExecutionBlockedEventStatus as S3,StepExecutionEventStatus as C3}from"@rango-dev/queue-manager-rango-preset";import{legacyReadAccountAddress as T3}from"@rango-dev/wallets-core/legacy";import{useWallets as Yr,Events as w3}from"@rango-dev/wallets-react";import{Networks as x3,WalletTypes as E3}from"@rango-dev/wallets-shared";import{PendingSwapNetworkStatus as A3}from"rango-types";import{Divider as FS}from"@rango-dev/ui";import co,{useEffect as OS,useRef as US,useState as Mp}from"react";import{WalletState as qh}from"@rango-dev/ui";import{useWallets as Gh}from"@rango-dev/wallets-react";import{useReducer as Vh}from"react";function rc(t){return!!t.derivationPath}i(rc,"isStateOnDerivationPathStep");function ic(t){return!!t.namespace}i(ic,"isStateOnNamespace");var ar={status:"init",namespace:null,derivationPath:null};function ac(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 ar;case"resetDerivation":return t.namespace?{...t,derivationPath:null,status:"namespace"}:ar;default:throw new Error("Action hasn't been defined.")}}i(ac,"reducer");function Gt(){let{state:t,disconnect:e,connect:o}=Gh(),[n,r]=Vh(ac,ar),a=i(async(u,d,h)=>{r({type:"reset"});try{let g=d?.map(f=>({...f,network:void 0}));return await o(u,g),{status:"connected"}}catch(g){let f=g?.message?`Error: ${g.message}`:"An unknown error happened during connecting wallet.";throw new Error(f,{cause:g})}},"runConnect"),s=i(async(u,d)=>{if(u.state===qh.DISCONNECTED){if(!!u.isHub&&u.properties?.find(k=>k.name==="detached")&&u.state!=="connected")return r({type:"needsNamespace",payload:{targetWallet:u}}),{status:"namespace"};if(!u.needsNamespace)return await a(u.type,void 0,d);let f=u.needsNamespace.data.length>1,m=u.needsDerivationPath;if(f)return r({type:"needsNamespace",payload:{targetWallet:u}}),{status:"namespace"};if(m){let C=u.needsNamespace.data[0];return r({type:"needsDerivationPath",payload:{providerType:u.type,providerImage:u.image,namespace:C.value}}),{status:"derivation-path"}}return await a(u.type,u.needsNamespace?.data.map(C=>({namespace:C.value})),d)}return d?.disconnectIfConnected?(await p(u.type),{status:"disconnected"}):{status:"disconnected-unhandled"}},"handleConnect"),l=i(async(u,d)=>{let h=u.needsNamespace?.selection==="single",g=u.needsDerivationPath,f=d[0];if(!f)throw new Error("To confirm a namespace, you should select at least one namespace.");if(h&&g)return r({type:"needsDerivationPath",payload:{providerType:u.type,providerImage:u.image,namespace:f}}),{status:"derivation-path"};if(!ic(n))throw new Error("Something went wrong on handling namespace. Please retry.");let m=n.namespace.targetWallet.type,C=d.map(S=>({namespace:S}));return await a(m,C)},"handleNamespace"),c=i(async u=>{if(!u)throw new Error("Derivation path is empty. Please make sure you've filled the field correctly.");if(!rc(n))throw new Error("It seems you are filling derivation path without setting namespace before doing that. Please retry to connect.");let d=n.derivationPath.providerType,g=[{namespace:n.derivationPath.namespace,derivationPath:u}];return await a(d,g)},"handleDerivationPath"),p=i(async u=>{let d=t(u);return d.connected||d.connecting?(await e(u),{status:"disconnected"}):{status:"noop"}},"handleDisconnect");return{handleConnect:s,handleDisconnect:p,handleNamespace:l,handleDerivationPath:c,getState:()=>n,resetState:u=>{r(u==="derivation"?{type:"resetDerivation"}:{type:"reset"})}}}i(Gt,"useStatefulConnect");import{WalletState as ya}from"@rango-dev/ui";import{useWallets as oS}from"@rango-dev/wallets-react";import{detectMobileScreens as nS,KEPLR_COMPATIBLE_WALLETS as rS,WalletTypes as gn}from"@rango-dev/wallets-shared";import{useCallback as iS,useEffect as aS}from"react";import Zy,{createContext as Jy,useContext as Ry,useEffect as eS,useRef as tS}from"react";import{create as Xy}from"zustand";import{persist as Yy}from"zustand/middleware";import{allProviders as Kh}from"@rango-dev/provider-all";var Ji=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()}},Eo=new Ji;import{defineVersions as lc,pickVersion as cc,Provider as Ri}from"@rango-dev/wallets-core";function pc({allProviders:t,configWallets:e}){if(e){let o=[];return e.forEach(n=>{if(typeof n=="string"){let r=t.find(a=>{let s=uc(a);return s instanceof Ri?s.id===n:s.config.type===n});r?o.push(r):console.warn(`Couldn't find ${n} provider. Please make sure you are passing the correct name.`)}else n instanceof Ri?o.push(lc().version("1.0.0",n).build()):o.push(lc().version("0.0.0",n).build())}),o}return t}i(pc,"matchAndGenerateProviders");function uc(t){try{return cc(t,"1.0.0")[1]}catch{return cc(t,"0.0.0")[1]}}i(uc,"pickProviderVersionWithFallbackToLegacy");function dc(t){return t.map(o=>uc(o)).map(o=>o instanceof Ri?o.id:o.config.type)}i(dc,"configWalletsToWalletName");function sr(t,e){return e.find(o=>o.name===t)?.displayName}i(sr,"getBlockchainDisplayNameFor");function st(t,e){return e.find(o=>o.name===t)?.shortName}i(st,"getBlockchainShortNameFor");function mc(t,e){return e.find(o=>o.name===t)?.logo}i(mc,"getBlockchainImage");function rn(t,e){return e.find(o=>o.id===t)?.title}i(rn,"getSwapperDisplayName");function an(t,e){return e.find(o=>o.name===t)??null}i(an,"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 lt(t){return`${t.blockchain.toLowerCase()}-${t.symbol.toLowerCase()}-${(t.address??"").toLowerCase()}`}i(lt,"createTokenHash");function Io(t,e){return t.addressPatterns.filter(r=>new RegExp(r).test(e)).length>0}i(Io,"isValidTokenAddress");function sn(t){let{config:e,meta:o}=t,n={},r=e.tokens,a=i(l=>{l.forEach(c=>{typeof c!="string"&&(c=lt(c));let p=o.tokensMapByTokenHash.get(c);p&&(n[c]=p)})},"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(c=>{l.has(c)||a(o.tokensMapByBlockchainName[c])})}return s.forEach(l=>{let c=r[l];if(!c&&o.tokensMapByBlockchainName?.[l]){a(o.tokensMapByBlockchainName[l]);return}c&&(c.isExcluded?(a(o.tokensMapByBlockchainName[l]),c.tokens.forEach(p=>{let u=lt(p);delete n[u]})):a(c.tokens))}),Object.values(n)}i(sn,"matchTokensFromConfigWithMeta");function lr(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(lr,"getSupportedBlockchainsFromConfig");function gc(t){return{walletConnectProjectId:t?.walletConnectProjectId,trezorManifest:t?.trezorManifest,tonConnect:t?.tonConnect,walletConnectListedDesktopWalletLink:t.__UNSTABLE_OR_INTERNAL__?.walletConnectListedDesktopWalletLink}}i(gc,"makeProvidersOptionsFromConfig");var cr={apiKey:"",title:void 0,multiWallets:!0,excludeLiquiditySources:!0,customDestination:!0,variant:"default",trezorManifest:{appUrl:"https://widget.rango.exchange/",email:"hi+trezorwidget@rango.exchange"},tonConnect:{manifestUrl:"https://raw.githubusercontent.com/rango-exchange/rango-types/main/assets/manifests/tonconnect-manifest.json"}},jh={clientUrl:void 0},Xh={liquiditySources:void 0};function fc(t){let e=gc(t),o={walletconnect2:{WC_PROJECT_ID:e?.walletConnectProjectId||"",DISABLE_MODAL_AND_OPEN_LINK:e?.walletConnectListedDesktopWalletLink},selectedProviders:t.wallets,trezor:e?.trezorManifest?{manifest:e.trezorManifest}:void 0,tonConnect:e?.tonConnect?.manifestUrl?{manifestUrl:e?.tonConnect.manifestUrl}:void 0};return Kh(o).map(a=>a())}i(fc,"generateProviders");var hc=i((t,e,o)=>{let n=fc({...cr,...t});return{config:{...cr,...t},iframe:jh,campaignMode:Xh,allProviders:n,getLiquiditySources:()=>{let{config:r,campaignMode:a}=o();return a.liquiditySources?.length?a.liquiditySources:r.liquiditySources??[]},getDisabledLiquiditySources:()=>{let{disabledLiquiditySources:r,campaignMode:a}=o();return a.liquiditySources?.length?[]:r},excludeLiquiditySources:()=>{let{config:r,campaignMode:a}=o();return a.liquiditySources?.length?!1:!!r.excludeLiquiditySources},isInCampaignMode:()=>{let{campaignMode:r}=o();return!!r.liquiditySources?.length},updateConfig:r=>{let a=o().config,{_tokensMapByTokenHash:s,_tokensMapByBlockchainName:l}=o(),c=sn({type:"source",config:{blockchains:r.from?.blockchains,tokens:r.from?.tokens},meta:{tokensMapByBlockchainName:l,tokensMapByTokenHash:s}}),p=sn({type:"destination",config:{blockchains:r.to?.blockchains,tokens:r.to?.tokens},meta:{tokensMapByBlockchainName:l,tokensMapByTokenHash:s}});Eo.set("supportedSourceTokens",c),Eo.set("supportedDestinationTokens",p),e({config:{...a,...r}})},updateCampaignMode:(r,a)=>{let s=o().campaignMode;e({campaignMode:{...s,[r]:a}})},updateIframe:(r,a)=>{let s=o().iframe;e({iframe:{...s,[r]:a}})},buildAndSetProviders:()=>{let{config:r}=o(),a=fc(r);e({allProviders:a})},getAvailableProviders:()=>{let{allProviders:r,config:a}=o(),s=gc(a);return pc({allProviders:r,configWallets:a.wallets,options:s})}}},"createConfigSlice");import{TransactionType as yc}from"rango-types";var Sc=[yc.EVM,yc.SOLANA];import{RangoClient as py}from"rango-sdk";import{UI_ID as Yh}from"@rango-dev/ui";var pr="c6381a79-2817-4602-83bf-6a641a409e32",Cc="https://api.rango.exchange",kc="https://explorer.rango.exchange",De={SWAP_BOX_ID:"rango-swap-box",EXPANDED_BOX_ID:"rango-expanded-box",...Yh};import{BlockchainCategories as ny,WalletState as bt}from"@rango-dev/ui";import{legacyReadAccountAddress as ry}from"@rango-dev/wallets-core/legacy";import{detectInstallLink as iy,getCosmosExperimentalChainInfo as ay,isEvmAddress as sy,KEPLR_COMPATIBLE_WALLETS as lA,Networks as Pc}from"@rango-dev/wallets-shared";import No from"bignumber.js";import{isCosmosBlockchain as ly}from"rango-types";import Zh from"bignumber.js";var ce=new Zh(0);import{WalletTypes as Jh}from"@rango-dev/wallets-shared";var no="~",Tc=[Jh.LEAP];import{BlockchainCategories as oa,WalletState as oy}from"@rango-dev/ui";import{TransactionType as ur}from"rango-sdk";var vc="Roboto",ta=[{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 Ao(t){return Array.from(new Set(t))}i(Ao,"removeDuplicateFrom");function Ac(t,e){let o;return n;function n(...r){o&&clearTimeout(o),o=setTimeout(()=>{o=null,t(...r)},e)}}i(Ac,"debounce");function Je(t,e){return t.toLowerCase().indexOf(e.toLowerCase())>-1}i(Je,"containsText");function xc(t,e){return t.toLowerCase()===e.toLowerCase()}i(xc,"exactText");function Ec(t,e){return t.toLowerCase().startsWith(e.toLowerCase())}i(Ec,"startWithText");var I=i(()=>document.getElementById(De.SWAP_BOX_ID),"getContainer"),ro=i(()=>document.getElementById(De.EXPANDED_BOX_ID),"getExpanded");function Ic(t,e,o){let n=!!e&&xc(e,t),r=!!o&&xc(o,t);return n!==r?n?-1:1:0}i(Ic,"compareExactMatchText");function na(t,e,o){let n=!!e&&Je(e,t),r=!!o&&Je(o,t);return n!==r?n?-1:1:n&&r&&e?.length!==o?.length?e?.length-o?.length:0}i(na,"compareContainsText");function ra(t,e,o){let n=!!e&&Ec(e,t),r=!!o&&Ec(o,t);return n!==r?n?-1:1:n&&r&&e?.length!==o?.length?e?.length-o?.length:0}i(ra,"compareStartWithText");function Nc(t,e,o){if(!o)return 0;let n=Ic(o,t.symbol,e.symbol);if(n)return n;if(o.length>=3){let r=Ic(o,t.name,e.name);if(r)return r}if(o.length>=2){let r=ra(o,t.symbol,e.symbol);if(r)return r}if(o.length>=3){let r=na(o,t.symbol,e.symbol);if(r)return r}if(o.length>=3){let r=ra(o,t.name,e.name);if(r)return r}if(o.length>=3){let r=na(o,t.name,e.name);if(r!==0)return r}if(o.length>=4){let r=ra(o,t.address,e.address);if(r)return r}if(o.length>=4){let r=na(o,t.address,e.address);if(r!==0)return r}return 0}i(Nc,"compareWithSearchFor");var dr=i((t,e)=>{switch(e){case oa.ALL:return!0;case oa.UTXO:return t===ur.TRANSFER;case oa.OTHER:return t!==ur.TRANSFER&&t!==ur.COSMOS&&t!==ur.EVM;default:return t===e}},"isBlockchainTypeInCategory"),Wc=i(t=>ta.find(o=>o.value===t)?.url,"getFontUrlByName");function Bc(t,e){let o=!!t.find(n=>n.state===oy.CONNECTED);return e===!1&&o}i(Bc,"isSingleWalletActive");function Mc(){let t,e;return(o,n)=>((!e||!t||t!==n)&&(t=n,e=o()),e)}i(Mc,"memoizedResult");import{BigNumber as Lc}from"bignumber.js";var ln=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 Lc(t),r=1,a=1e3;for(let s=0;s<60;s++)if(new Lc(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 mr=i(t=>t?.reduce((e,o)=>e+(o.estimatedTimeInSeconds??0),0)||0,"totalArrivalTime");var wt=i((t,e)=>t.toLowerCase().indexOf(e.toLowerCase())>-1,"containsText"),cn=i(t=>!!t&&parseFloat(t)>0,"isPositiveNumber");function pn(t){switch(!0){case t.connected:return bt.CONNECTED;case t.connecting:return bt.CONNECTING;case!t.installed:return bt.NOT_INSTALLED;default:return bt.DISCONNECTED}}i(pn,"mapStatusToWalletState");function _c(t,e,o,n){return o.filter(r=>!Tc.includes(r)).filter(r=>{let{supportedChains:a,isContractWallet:s}=e(r),{installed:l,network:c}=t(r);return s&&(!l||!!n&&c!==n)?!1:n?!!a.find(u=>u.name===n):!0}).map(r=>{let{name:a,img:s,installLink:l,showOnMobile:c,needsNamespace:p,supportedChains:u,needsDerivationPath:d,properties:h,isHub:g}=e(r),f=Ao(u.map(C=>C.type)),m=pn(t(r));return{title:a,image:s,link:iy(l),state:m,type:r,showOnMobile:c,needsNamespace:p,blockchainTypes:f,needsDerivationPath:d,properties:h,isHub:g}})}i(_c,"mapWalletTypesToWalletInfo");function un(t){if(!t)return null;let e=[];return e=t.map(o=>o.name),e}i(un,"walletAndSupportedChainsNames");function aa(t,e,o,n,r){let a=[];function s(c,p){if(!!!a.find(d=>d.chain===c)){let d={address:p,chain:c,walletType:t};a.push(d)}}i(s,"addAccount");let l=n||[];return e.forEach(c=>{let{address:p,network:u}=ry(c),d=l.length>0,h=l.includes(u),g=u===Pc.Unknown;if(d&&!h&&!g)return;let m=u===Pc.Unknown&&sy(p);if(g&&!m)return;o.includes(u)||m?r?s(u,p.toLowerCase()):l.filter(k=>o.includes(k)).forEach(k=>{s(k,p.toLowerCase())}):s(u,p)}),a}i(aa,"prepareAccountsForWalletStore");function io(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:c}=r;c.forEach((p,u)=>{let d=p.from.blockchain,h=p.to.blockchain,g=a===o.swaps.length-1,f=u===c.length-1;(!g&&!f||g&&l!==d||e==="all")&&n.add(d),e==="all"&&n.add(h)})}e==="all"&&n.add(l)}),Array.from(n)}i(io,"getQuoteWallets");function dn(t,e){return t.address===e.address&&t.chain===e.chain&&t.walletType===e.walletType}i(dn,"isAccountAndWalletMatched");var Dc=i(t=>{let e=Object.values(t).reduce((o,n)=>{let r=n.usdValue?ia(n.usdValue,n.decimals):ce.toFixed();return o.plus(r)},new No(ce));return cy(e.toString())},"calculateWalletUsdValue");function cy(t){let e=t.toString().split(".");return e[0]=e[0].replace(/\B(?=(\d{3})+(?!\d))/g,","),e.join(".")}i(cy,"numberWithThousandSeparator");var hr=i((t,e)=>{let o=ay(Object.entries(t).map(([,n])=>n).filter(ly));return o&&o[e]?.experimental},"isExperimentalChain");function ia(t,e){return new No(t).shiftedBy(-e).toFixed()}i(ia,"representAmountInNumber");function yr(t){if(!t)return null;let e=ia(t.amount,t.decimals),o=t.usdValue?ia(t.usdValue,t.decimals):null,n=B(e,8,8),r=o?B(o,4,4):null;return t?{...t,amount:n,usdValue:r}:null}i(yr,"formatBalance");function $c(t,e){if(t?.usdValue||e?.usdValue){let o=t&&t.usdValue?new No(t.usdValue).shiftedBy(-t.decimals):ce,n=e&&e.usdValue?new No(e.usdValue).shiftedBy(-e.decimals):ce;return o.isEqualTo(n)?0:o.isGreaterThan(n)?-1:1}if(t?.amount||e?.amount){let o=t&&t.amount?new No(t.amount).shiftedBy(-t.decimals):ce,n=e&&e.amount?new No(e.amount).shiftedBy(-e.decimals):ce;return o.isEqualTo(n)?0:o.isGreaterThan(n)?-1:1}return 0}i($c,"compareTokenBalance");function Mt(t,e){return t?.blockchain===e?.blockchain&&t?.symbol.toLowerCase()===e?.symbol.toLowerCase()&&t?.address?.toLowerCase()===e?.address?.toLowerCase()}i(Mt,"areTokensEqual");function Fc(t){return t.sort((e,o)=>+(o.state===bt.CONNECTED)-+(e.state===bt.CONNECTED)||+(o.state===bt.DISCONNECTED||o.state===bt.CONNECTING)-+(e.state===bt.DISCONNECTED||e.state===bt.CONNECTING))}i(Fc,"sortWalletsBasedOnConnectionState");function Sr(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(Sr,"getConciseAddress");function Oc({chain:t,connectedWallets:e,walletType:o}){return e.find(n=>n.walletType===o&&n.chain===t)?.address}i(Oc,"getAddress");var Uc=i((t,e)=>!!t.find(o=>o.chain===e&&o.loading),"isFetchingBalance");function zc(t){return t.map(e=>e.state).join("-")}i(zc,"hashWalletsState");function Qc(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(Qc,"filterBlockchainsByWalletTypes");function Hc(t,e){return e===ny.ALL?t:t.filter(o=>{for(let n of o.blockchainTypes)if(dr(n,e))return!0;return!1})}i(Hc,"filterWalletsByCategory");var sa={API_KEY:pr};function Lt(t){return sa[t]||""}i(Lt,"getConfig");function qc(t){let e;return typeof structuredClone=="function"?e=structuredClone(t):e=JSON.parse(JSON.stringify(t)),sa=e,sa}i(qc,"initConfig");var Gc=20,Vc=25,la="theme-widget",ca=i((t,e)=>{let o=!1;if(e&&t){if(Array.isArray(e))o=!e.some(n=>Mt(n,t));else if(!Array.isArray(e)&&e[t.blockchain]){o=e[t.blockchain].tokens.some(r=>Mt(r,t));let n=e[t.blockchain].isExcluded;return!n&&!o||n&&o}}return o},"isTokenExcludedInConfig"),pa=i((t,e)=>t&&e&&!e.includes(t.name),"isBlockchainExcludedInConfig"),Kc=i((t,e,o)=>o==="expanded"&&(t||e)||o==="full-expanded"&&e,"isVariantExpandable");var Cr,xt=i(()=>Cr||(Cr=new py(Lt("API_KEY"),Lt("BASE_URL")),Cr),"httpService");function kr(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(c=>c===s.swapperGroup)),l&&s.types.map(c=>{n.push({id:s.swapperGroup,groupTitle:s.swapperGroup,logo:s.logo,type:c,selected:!e.includes(s.swapperGroup)})})}}),n}i(kr,"getUniqueSwappersGroups");function jc(t,e){return t.swapperGroup<e.swapperGroup?-1:t.swapperGroup>e.swapperGroup?1:0}i(jc,"sortLiquiditySourcesByGroupTitle");function Ve(t,e){return e?.[t]==="hidden"}i(Ve,"isFeatureHidden");function Wo(t,e){return e?.[t]==="enabled"}i(Wo,"isRoutingEnabled");var Xc=i((t,e,o)=>Ve("customTokens",o)?t:t.concat(e),"addCustomTokensToSupportedTokens");var Yc=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 c=lr({config:a}),p=r;return c.length>0&&(p=p.filter(u=>c.includes(u.name))),p.filter(u=>Sc.includes(u.type))}let s=(o.type==="source"?a.from?.blockchains:a.to?.blockchains)??[];return r.filter(c=>!(s.length>0&&!s.includes(c.name)))},tokens:o=>{let{_tokensMapByTokenHash:n,_tokensMapByBlockchainName:r,config:a,_customTokens:s}=e(),l=Array.from(n.values()),c=e()._blockchainsMapByName;if(!o||!o.type)return l;let p=o.type==="source"?"from":"to",u=o.type==="source"?"supportedSourceTokens":"supportedDestinationTokens",d=Eo.get(u);d?.length||(d=sn({type:o.type,config:{blockchains:a[p]?.blockchains,tokens:a[p]?.tokens},meta:{tokensMapByTokenHash:n,tokensMapByBlockchainName:r}}),Eo.set(u,d)),d=Xc(d,s,a.features);let h=e().blockchains({type:o.type});return d.filter(f=>o.blockchain&&f.blockchain!==o.blockchain||!h.some(m=>m.name===f.blockchain)?!1:o.searchFor?!!(Je(f.symbol,o.searchFor)||Je(f.address||"",o.searchFor)||Je(f.name||"",o.searchFor)):!0).sort((f,m)=>{let C=e().isTokenPinned(f,o.type),S=e().isTokenPinned(m,o.type);if(C!==S)return C?-1:1;if(o.getBalanceFor){let A=o.getBalanceFor(f),D=o.getBalanceFor(m),w=$c(A,D);if(w!==0)return w}let k=c.get(f.blockchain),T=c.get(m.blockchain),v=ea(f,k),b=ea(m,T);if(v!==b)return v?-1:1;if(f.isPopular!==m.isPopular)return f.isPopular?-1:1;if(o.searchFor){let A=Nc(f,m,o.searchFor);if(A)return A}return f.isSecondaryCoin!==m.isSecondaryCoin?f.isSecondaryCoin?1:-1:k&&T?k.sort-T.sort:0})},findToken:o=>{let n=e()._tokensMapByTokenHash,r=e().customTokens(),a=lt(o),s=n.get(a);return s||(s=r.find(l=>lt(l)===a)),s},isTokenPinned:(o,n)=>!!(n==="source"?e().config.from?.pinnedTokens:e().config.to?.pinnedTokens)?.some(s=>Mt(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(p=>{let u=a?.includes(p.swapperGroup);return s||!a||a.length===0?!u:u}).sort(jc)},fetch:async()=>{try{let{routing:o}=e().config,n=Wo("enableCentralizedSwappers",o),r=await xt().getAllMetadata({enableCentralizedSwappers:n});t({fetchStatus:"success"});let a=new Map,s=new Map,l={},c=[],p=r.popularTokens,u=r.swappers.filter(g=>g.enabled),d=new Set;r.tokens.forEach(g=>{d.add(g.blockchain),c.push(g)}),r.blockchains.sort((g,f)=>g.sort-f.sort).forEach(g=>{g.enabled&&d.has(g.name)&&a.set(g.name,g)}),c.forEach(g=>{let f=lt(g);l[g.blockchain]||(l[g.blockchain]=[]),s.set(f,g),l[g.blockchain].push(f)}),t({_blockchainsMapByName:a,_tokensMapByTokenHash:s,_tokensMapByBlockchainName:l,_popularTokens:p,_swappers:u})}catch(o){throw t({fetchStatus:"failed"}),o}}}),"createDataSlice");import{Bengali as uy,Catalonia as dy,Chinese as Zc,Denmark as my,English as fy,Finland as gy,French as hy,German as yy,Greece as Sy,Hungary as Cy,India as ky,Indonesian as Ty,Italian as vy,Japanese as wy,Korea as by,Lithuania as xy,Malay as Ey,Netherlands as Iy,Pakistan as Ay,Philippines as Ny,Poland as Wy,Portuguese as By,Russian as My,SaudiArabia as Ly,Serbia as Py,Slovakia as _y,SouthAfrica as Dy,Spanish as $y,Swahili as Fy,Swedish as Oy,Thai as Uy,Turkish as zy,Ukrainian as Qy,Vietnamese as Hy}from"@rango-dev/ui";var Jc=[{title:"Afrikaans",label:"Afrikaans",local:"af",SVGFlag:Dy},{title:"Arabic",label:"\u0639\u0631\u0628\u064A",local:"ar",SVGFlag:Ly},{title:"Bengali",label:"\u09AC\u09BE\u0982\u09B2\u09BE",local:"bn",SVGFlag:uy},{title:"Catalan",label:"Catal\xE0",local:"ca",SVGFlag:dy},{title:"Chinese (Simplified)",label:"\u7B80\u4F53\u4E2D\u6587",local:"zh-CN",SVGFlag:Zc},{title:"Chinese (Traditional)",label:"\u4E2D\u6587\uFF08\u7E41\u9AD4)",local:"zh-TW",SVGFlag:Zc},{title:"Danish",label:"Dansk",local:"da",SVGFlag:my},{title:"Dutch",label:"Nederlands",local:"nl",SVGFlag:Iy},{title:"English",label:"English",local:"en",SVGFlag:fy},{title:"Filipino",label:"Filipino",local:"fil",SVGFlag:Ny},{title:"Finnish",label:"Suomalainen",local:"fi",SVGFlag:gy},{title:"French",label:"Fran\xE7ais",local:"fr",SVGFlag:hy},{title:"German",label:"Deutsch",local:"de",SVGFlag:yy},{title:"Greek",label:"\u03B5\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AC",local:"el",SVGFlag:Sy},{title:"Hindi",label:"\u0939\u093F\u0902\u0926\u0940",local:"hi",SVGFlag:ky},{title:"Hungarian",label:"Magyar",local:"hu",SVGFlag:Cy},{title:"Indonesian",label:"Indonesia",local:"id",SVGFlag:Ty},{title:"Italian",label:"Italiana",local:"it",SVGFlag:vy},{title:"Japanese",label:"\u65E5\u672C\u8A9E",local:"ja",SVGFlag:wy},{title:"Korean",label:"\uD55C\uAD6D\uC778",local:"ko",SVGFlag:by},{title:"Lithuanian",label:"Lietuvi\u0173",local:"lt",SVGFlag:xy},{title:"Malay",label:"Melayu",local:"ms",SVGFlag:Ey},{title:"Polish",label:"Polski",local:"pl",SVGFlag:Wy},{title:"Portuguese",label:"Portugu\xEAs",local:"pt",SVGFlag:By},{title:"Russian",label:"\u0420\u0443\u0441\u0441\u043A\u0438\u0439",local:"ru",SVGFlag:My},{title:"Serbian",label:"C\u0440\u043F\u0441\u043A\u0438",local:"sr",SVGFlag:Py},{title:"Slovak",label:"Slovensk\xFD",local:"sk",SVGFlag:_y},{title:"Spanish",label:"Espa\xF1ol",local:"es",SVGFlag:$y},{title:"Swahili",label:"Kiswahili",local:"sw",SVGFlag:Fy},{title:"Swedish",label:"Svenska",local:"sv",SVGFlag:Oy},{title:"Thai",label:"\u0E41\u0E1A\u0E1A\u0E44\u0E17\u0E22",local:"th",SVGFlag:Uy},{title:"Turkish",label:"T\xFCrk\xE7e",local:"tr",SVGFlag:zy},{title:"Ukrainian",label:"Y\u043A\u0440\u0430\u0457\u043D\u0456",local:"uk",SVGFlag:Qy},{title:"Urdu",label:"\u0627\u0631\u062F\u0648",local:"ur",SVGFlag:Ay},{title:"Vietnamese",label:"Ti\u1EBFng Vi\u1EC7t",local:"vi",SVGFlag:Hy}],Bo="en";var Rc=[.5,1,3],ep=1,tp=5,op=100,np=0;var rp=i((t,e)=>({disabledLiquiditySources:[],theme:"auto",language:null,preferredBlockchains:[],slippage:ep,customSlippage:null,infiniteApprove:!1,affiliateRef:null,affiliatePercent:null,affiliateWallets:null,_customTokens:[],addPreferredBlockchain:o=>{let n=e().preferredBlockchains;if(n.find((s,l)=>{let c=s===o,p=l<=9;return c&&p}))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=Ve("theme",n),s=Ve("language",n),l=Ve("liquiditySource",n),c=r?.singleTheme,p=o?.__UNSTABLE_OR_INTERNAL__?.autoUpdateSettings;t({...a&&{theme:o.theme?.mode||"auto"},...c&&{theme:o.theme?.mode||"light"},...s&&{language:o.language||Bo},...l&&{disabledLiquiditySources:o.liquiditySources||[]},...p&&{language:o.language||Bo}})},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=lr({config:o});return r.length?n.filter(a=>r.includes(a.blockchain)):n}}),"createSettingsSlice");import ha from"bignumber.js";import qy from"mitt";var he=qy(),Gy={on:he.on,off:he.off};import{WidgetEvents as ip}from"@rango-dev/queue-manager-rango-preset";var da=(o=>(o.QUOTE_INPUT_UPDATE="quoteInputUpdate",o.QUOTE_OUTPUT_UPDATE="quoteOutputUpdate",o))(da||{}),ma=(o=>(o.CONNECT="connect",o.DISCONNECT="disconnect",o))(ma||{}),fa=(e=>(e.CLICK_CONNECT_WALLET="clickConnectWallet",e))(fa||{}),Mo=(a=>(a[a.RouteEvent=ip.RouteEvent]="RouteEvent",a[a.StepEvent=ip.StepEvent]="StepEvent",a.QuoteEvent="quoteEvent",a.WalletEvent="walletEvent",a.UiEvent="uiEvent",a))(Mo||{});var ap=i(t=>(e,o,n)=>t(i((...a)=>{e(s=>({...s,lastUpdatedAt:+new Date})),e(...a)},"modifedSet"),o,n),"keepLastUpdated");import Vy from"bignumber.js";function mn(t){return`${t.blockchain}${no}${t.address}${no}${t.symbol}`}i(mn,"createAssetKey");function ga(t,e){return`${mn(e)}${no}${t}`}i(ga,"createBalanceKey");function fn(t){let[e,o,n]=t.split(no);return{address:o==="null"?null:o,blockchain:e,symbol:n}}i(fn,"extractAssetFromBalanceKey");function sp(t,e){let o={};return t.balances?.forEach(n=>{let r=ga(t.address,n.asset),a=n.amount.amount,s=n.amount.decimals,l=e().findToken(n.asset)?.usdPrice,c=l?new Vy(l??ce).multipliedBy(a).toString():"",p={amount:a,decimals:s,usdValue:c};o[r]=p}),o}i(sp,"createBalanceStateForNewAccount");function lp(t,e){for(let o in e){let n=fn(o),r=mn(n);t[r]||(t[r]=[]),t[r].includes(o)||(t[r]=[...t[r],o])}return t}i(lp,"updateAggregatedBalanceStateForNewAccount");function cp(t,e){let o=fn(e),n=mn(o);return t[n]&&(t[n]=t[n].filter(r=>r!==e)),t}i(cp,"removeBalanceFromAggregatedBalance");function Ky(t,e){return e.find(o=>t.address===o.address&&t.chain===o.blockChain)}i(Ky,"matchWalletDetailsWithConnectedWallet");var jy=Mc(),pp=ap((t,e)=>({_balances:{},_aggregatedBalances:{},connectedWallets:[],fetchingWallets:!1,lastUpdatedAt:+new Date,setConnectedWalletAsRefetching:o=>{t(n=>({fetchingWallets:!0,connectedWallets:n.connectedWallets.map(r=>o.find(a=>dn(a,r))?{...r,loading:!0,error:!1}:r)}))},setConnectedWalletRetrievedData:(o,n)=>{t(r=>({fetchingWallets:!1,connectedWallets:r.connectedWallets.map(a=>o.find(s=>dn(s,a))?{...a,loading:!1,error:!1,explorerUrl:Ky(a,n)?.explorerUrl||a.explorerUrl}:a)}))},setConnectedWalletHasError:o=>{t(n=>({fetchingWallets:!1,connectedWallets:n.connectedWallets.map(r=>o.find(a=>dn(a,r))?{...r,loading:!1,error:!0}:r)}))},addConnectedWallet:(o,n)=>{let r=e().connectedWallets,a=o.filter(s=>!r.some(l=>dn(s,l)));if(a.length>0){let s=a.map(l=>{let c=!r.some(p=>p.chain===l.chain&&p.selected&&p.walletType!==l.walletType);return{address:l.address,chain:l.chain,explorerUrl:null,walletType:l.walletType,selected:c,namespace:n,loading:!1,error:!1}});t(l=>({connectedWallets:[...l.connectedWallets.filter(p=>!s.some(u=>u.walletType===p.walletType&&u.chain===p.chain)),...s]}))}},setWalletsAsSelected:o=>{let n=e().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});t({connectedWallets:n})},newWalletConnected:async(o,n)=>{he.emit("walletEvent",{type:"connect",payload:{walletType:o[0].walletType,accounts:o}}),e().addConnectedWallet(o,n),e().fetchBalances(o)},removeBalancesForWallet:(o,n)=>{let r=e().connectedWallets.filter(p=>p.walletType===o);e().connectedWallets.forEach(p=>{p.walletType!==o&&(r=r.filter(u=>!(u.chain===p.chain&&u.address===p.address)))}),n?.chains&&n.chains.length>0&&(r=r.filter(p=>n.chains?.includes(p.chain))),n?.namespaces&&n.namespaces.length>0&&(r=r.filter(p=>p.namespace?n.namespaces?.includes(p.namespace):!1));let a={},s=e()._aggregatedBalances,l=e()._balances;Object.keys(l).forEach(p=>{let u=fn(p);!!r.find(h=>ga(h.address,{address:u.address,blockchain:h.chain,symbol:u.symbol})===p)?s=cp(s,p):a[p]=l[p]}),t({_balances:a,_aggregatedBalances:s})},disconnectNamespaces:(o,n)=>{if(e().connectedWallets.find(a=>a.walletType===o)){e().removeBalancesForWallet(o,{namespaces:n}),e()._changeSelectedWalletIfNeededOnRemove(o,{namespaces:n});let a=e().connectedWallets.filter(s=>s.namespace?!(s.walletType===o&&n.includes(s.namespace)):!0);t({connectedWallets:a})}},disconnectWallet:o=>{let n=e().connectedWallets.find(r=>r.walletType===o);if(he.emit("walletEvent",{type:"disconnect",payload:{walletType:o}}),n){e().removeBalancesForWallet(o),e()._changeSelectedWalletIfNeededOnRemove(o);let r=e().connectedWallets.filter(a=>a.walletType!==o);t({connectedWallets:r})}},_changeSelectedWalletIfNeededOnRemove:(o,n)=>{let r=e().connectedWallets;n?.namespaces&&n.namespaces.length>0&&(r=r.filter(s=>!!s.namespace&&n.namespaces?.includes(s.namespace)));let a=r.filter(s=>s.selected&&s.walletType===o).map(s=>s.chain);if(a.length>0){let s=e().connectedWallets.map(l=>a.includes(l.chain)?(a=a.filter(c=>c!==l.chain),{...l,selected:!0}):l);t({connectedWallets:s})}},clearConnectedWallet:()=>t({connectedWallets:[]}),fetchBalances:async(o,n)=>{let r=o[0].walletType;e().setConnectedWalletAsRefetching(o);let a=o.map(c=>({address:c.address,blockchain:c.chain})),s;try{s=await xt().getWalletsDetails(a)}catch(c){throw e().setConnectedWalletHasError(o),new Error("Request for fetching balances failed.",{cause:c})}let l=s.wallets;if(l){let{retryOnFailedBalances:c=!0}=n||{};if(c){let d=l.filter(h=>h.failed).map(h=>({chain:h.blockChain,walletType:r,address:h.address}));d.length>0&&e().fetchBalances(d,{retryOnFailedBalances:!1})}let p={},u=e()._aggregatedBalances;l.forEach(d=>{if(d.failed||(e().removeBalancesForWallet(r,{chains:[d.blockChain]}),!e().connectedWallets.find(g=>g.walletType===r&&g.address===d.address&&g.chain===d.blockChain)))return;let h=sp(d,e);u=lp(u,h),p={...p,...h}}),t(d=>({_balances:{...d._balances,...p},_aggregatedBalances:u})),e().setConnectedWalletRetrievedData(o,l)}else throw e().setConnectedWalletHasError(o),new Error("We couldn't fetch your account balances. Seem there is no information on blockchain for them yet.")},getBalances:()=>e()._balances,getBalanceFor:o=>{let n=e().getBalances(),r=mn(o),a=e()._aggregatedBalances[r]||[];if(a.length===0)return null;if(a.length===1){let c=a[0];return n[c]}let l=n[a[0]];return a.forEach(c=>{let p=n[c],u=new ha(p.amount),d=new ha(l.amount);u.isGreaterThan(d)&&(l=p)}),l},getBalancesForWalletAddress:o=>{let n=e().getBalances();return Object.keys(n).reduce((s,l)=>{let c=n[l],[,,,p]=l.split(no);return p===o&&(s[l]=c),s},{})},getConnectedWalletsDetails:()=>jy(()=>e().connectedWallets.map(n=>{let r=e().getBalancesForWalletAddress(n.address),a=Object.keys(r);return{...n,balances:a.reduce((s,l)=>{let c=r[l],p=fn(l);if(p.blockchain===n.chain){let u=e().findToken(p),d=c.amount?new ha(c.amount).shiftedBy(-c.decimals):ce;s.push({chain:n.chain,symbol:p.symbol,ticker:p.symbol,address:p.address,rawAmount:c.amount,decimal:c.decimals,amount:d.toString(),logo:u?.image||null,usdPrice:u?.usdPrice||null})}return s},[])}}),e().lastUpdatedAt)}));function up(t){return Xy()(Yy((...e)=>({...pp(...e),...Yc(...e),...rp(...e),...hc(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(up,"createAppStore");var dp=Jy(null);function y(){let t=Ry(dp);if(eS(()=>{t&&!t.persist.hasHydrated()&&t.persist.rehydrate()},[]),!t)throw new Error("Missing AppStoreContext.Provider in the tree");return t()}i(y,"useAppStore");function mp(t){let e=tS();return e.current||(e.current=up(t.config)),Zy.createElement(dp.Provider,{value:e.current},t.children)}i(mp,"AppStoreProvider");function ft(t){let{chain:e}=t||{},{connectedWallets:o,getAvailableProviders:n}=y(),{state:r,getWalletInfo:a}=oS(),s=y().blockchains(),{handleDisconnect:l}=Gt(),c=dc(n()),p=_c(r,a,c,e);p=nS()?p.filter(m=>m.showOnMobile!==!1&&r(m.type).installed):p;let u=Fc(p),d=i(m=>!o.find(C=>C.walletType===m&&C.chain===e),"isExperimentalChainNotAdded"),h=iS(()=>{let m=p?.filter(C=>C.state===ya.CONNECTING)||[];for(let C of m)l(C.type)},[zc(p)]);aS(()=>()=>{h()},[]);let g=i(m=>{let C=m.find(k=>k.type===gn.DEFAULT);return!C||C.state===ya.NOT_INSTALLED?!1:m.filter(k=>k.state!=ya.NOT_INSTALLED&&![gn.DEFAULT,gn.WALLET_CONNECT_2,gn.LEDGER].includes(k.type)&&a(k.type).supportedChains.filter(T=>T.type=="EVM").length>0).length==0},"shouldShowDefaultInjectedWallet"),f=i((m,C,S)=>hr(S,C)&&d(m)&&!rS.includes(m)||m==gn.DEFAULT&&!g(p),"shouldExcludeWallet");return{list:u.filter(m=>!f(m.type,e??"",s)),terminateConnectingWallets:h}}i(ft,"useWalletList");import{Modal as pS}from"@rango-dev/ui";import uS from"react";import{create as cS}from"zustand";var fp="rango-widget";var hn=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(fp),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 lS=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"),Lo=lS;var re=Lo(cS()((t,e)=>({isActiveTab:!1,tabManagerInitiated:!1,showActivateTabModal:!1,watermark:"NONE",showProfileBanner:!1,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})},setShowProfileBanner:o=>{t({showProfileBanner:o})}}))),ao=new hn({onInit:()=>re.setState({tabManagerInitiated:!0}),onClaim:()=>re.setState({isActiveTab:!0,showActivateTabModal:!1}),onRelease:()=>re.setState({isActiveTab:!1})});function Z(t){let{watermark:e}=re();return uS.createElement(pS,{hasWatermark:e==="FULL",...t},t.children)}i(Z,"WatermarkedModal");import{i18n as Sa}from"@lingui/core";import{Button as yS,Checkbox as SS,Divider as CS,Image as bp,ListItemButton as kS,MessageBox as TS,Radio as vS,RadioRoot as wS}from"@rango-dev/ui";import we,{useState as bS}from"react";import{css as dS,darkTheme as hp,IconButton as mS,styled as so}from"@rango-dev/ui";var Et=so(mS,{width:"$24",position:"relative",padding:"0",overflow:"unset","&:hover":{backgroundColor:"$secondary100",[`.${hp} &`]:{backgroundColor:"$neutral"}}}),yp=so("div",{position:"absolute",background:"$secondary500",[`.${hp} &`]:{$$color:"$colors$secondary250"},width:"$6",height:"$6",borderRadius:"$lg",right:"$4",border:"1px solid $surface100"}),Vt=so("div",{display:"flex",justifyContent:"flex-end",minWidth:"$40",button:{padding:0}}),Sp=so("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"}}}}),Cp=so("div",{padding:"$2",variants:{isRefetched:{true:{transform:"rotate(360deg)",transition:"transform 1s ease-in-out"}}}}),kp=so("div",{position:"absolute",right:"$4",top:"$4",backgroundColor:"$background",borderRadius:"100%"}),Tp=dS({display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center"}),Tr=so("div",{borderRadius:"100%",border:"1.5px transparent solid","&:not(:first-child)":{marginLeft:"-$6"},img:{borderRadius:"100%"}});import{keyframes as fS,styled as vr}from"@rango-dev/ui";var yN=vr("div",{borderRadius:"$lg",width:"$45",height:"$45",backgroundColor:"$success300",display:"flex",justifyContent:"center",alignItems:"center"}),Po=vr("div",{position:"relative"}),gS=fS({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}),_o=vr("div",{position:"absolute",border:"2px solid rgba(0, 0, 0, 0.1)",borderTop:"2px solid $info500",borderRadius:"$lg",width:"$45",height:"$45",animation:`${gS} 1s linear infinite`,top:0,bottom:0,right:0,left:0}),wr=vr("div",{"& img":{borderRadius:"50%"}});function vp(t,e){return t.find(o=>o.name===e)?.logo}i(vp,"getBlockchainLogo");import{styled as hS}from"@rango-dev/ui";var wp=hS("ul",{padding:0,paddingTop:"$4",paddingBottom:"$4"});function yn(t){let{targetWallet:e}=t.value,o=e.needsNamespace?.selection==="single",n=e.image,[r,a]=bS([]),s=y().blockchains(),l=i(p=>{a(o?[p]:u=>u.includes(p)?u.filter(d=>d!==p):u.concat(p))},"onSelect"),c=i(p=>o?we.createElement(wS,{value:r?.[0]},p):we.createElement(we.Fragment,null,p),"wrapRadioRoot");return we.createElement(we.Fragment,null,we.createElement(CS,{size:20}),we.createElement(TS,{type:"info",title:Sa.t("Select chain types"),description:Sa.t("This wallet supports multiple chains. Select which chain you'd like to connect to."),icon:we.createElement(Po,null,we.createElement(Tr,null,we.createElement(bp,{src:n,size:45})),we.createElement(_o,null))}),we.createElement(wp,null,c(we.createElement(we.Fragment,null,e.needsNamespace?.data.map(p=>we.createElement(kS,{key:p.id,id:p.id,title:p.label,hasDivider:!0,style:{height:60},onClick:()=>l(p.value),start:we.createElement(bp,{src:vp(s,p.id),size:22}),end:o?we.createElement(vS,{value:p.value}):we.createElement(SS,{checked:r.includes(p.value)})}))))),we.createElement(yS,{id:"widget-name-space-confirm-btn",type:"primary",disabled:!r.length,onClick:()=>t.onConfirm(r)},Sa.t("Confirm")))}i(yn,"Namespaces");import{i18n as Do}from"@lingui/core";import{Button as IS,Divider as Ip,Image as AS,MessageBox as NS,Select as WS,TextField as BS}from"@rango-dev/ui";import Oe,{useEffect as MS,useState as Ap}from"react";import{namespaces as xS}from"@rango-dev/wallets-shared";var br={id:"custom",label:"Custom",generateDerivationPath:t=>t};function Ca(t){let e=t?xS[t].derivationPaths:null;return e?[...e,br]:[]}i(Ca,"getDerivationPaths");import{styled as xp,Typography as ES}from"@rango-dev/ui";var Ep=xp("div",{paddingTop:"$30",paddingBottom:"$30",zIndex:10}),ka=xp(ES,{paddingLeft:"$10"}),Ta={height:"$40",backgroundColor:"$neutral200",borderRadius:"$sm"};var Np="0";function Sn(t){let{onConfirm:e}=t,{namespace:o,providerImage:n,providerType:r}=t.value,[a,s]=Ap(null),[l,c]=Ap(Np),p=a===br.id,u=Ca(o),d=i(({value:g})=>{let f=u?.find(m=>m.id===g);f&&(a===br.id&&Number.isNaN(Number(l))&&c(Np),s(f.id))},"handleDerivationPathItemClick"),h=i(()=>{let g=u.find(f=>f.id===a);if(g)e(g.generateDerivationPath(l));else throw new Error("selectedDerivationPath can not be undefined")},"handleConfirm");return MS(()=>{s(Ca(o)[0]?.id||null)},[o]),Oe.createElement(Oe.Fragment,null,Oe.createElement(Ip,{size:20}),Oe.createElement(NS,{type:"info",title:Do.t("Select Derivation Path"),description:Do.t({id:"In order to connect to {type}, you must first select a Derivation Path",values:{type:r}}),icon:Oe.createElement(Po,null,Oe.createElement(wr,null,Oe.createElement(AS,{src:n,size:45})),Oe.createElement(_o,null))}),Oe.createElement(Ep,null,Oe.createElement(ka,{variant:"body",size:"xsmall",color:"$neutral600"},Do.t("Choose Derivation Path Template")),Oe.createElement(WS,{value:a||"",options:u.map(g=>({value:g.id,label:g.label})),variant:"filled",handleItemClick:d,styles:{trigger:Ta}}),Oe.createElement(Ip,{size:20}),Oe.createElement(ka,{variant:"body",size:"xsmall",color:"$neutral600"},p?Do.t("Enter Path"):Do.t("Enter Index")),Oe.createElement(BS,{type:p?"text":"number",variant:"contained",value:l,onChange:g=>c(g.target.value),style:Ta})),Oe.createElement(IS,{id:"widget-derivation-path-confirm-btn",type:"primary",onClick:h,disabled:!u||!a||!l},Do.t("Confirm")))}i(Sn,"DerivationPath");import{i18n as $o}from"@lingui/core";import{Image as LS,MessageBox as va,WalletState as PS}from"@rango-dev/ui";import{useWallets as _S}from"@rango-dev/wallets-react";import lo from"react";function wa(t){let{wallet:e,error:o}=t,{type:n,image:r}=e,{state:a}=_S();return pn(a(n))===PS.CONNECTED?lo.createElement(va,{type:"success",title:$o.t("Wallet Connected"),description:$o.t("Your wallet is connected, you can use it to swap.")}):o?lo.createElement(va,{type:"error",title:$o.t("Failed to Connect"),description:o||$o.t("Your wallet is not connected. Please try again.")}):lo.createElement(va,{type:"loading",title:$o.t("Connecting to your wallet"),description:$o.t("Click connect in your wallet popup."),icon:lo.createElement(Po,null,lo.createElement(wr,null,lo.createElement(LS,{src:r,size:45})),lo.createElement(_o,null))})}i(wa,"ConnectStatus");import{i18n as ba}from"@lingui/core";import{Button as DS,Divider as Wp,MessageBox as $S}from"@rango-dev/ui";import xr from"react";function xa(t){let{displayName:e,onConfirm:o}=t;return xr.createElement($S,{title:ba.t({id:"Add {blockchainDisplayName} Chain",values:{blockchainDisplayName:e}}),type:"warning",description:ba.t({id:"Would you like to add the {blockchainDisplayName} experimental chain to your wallet?",values:{blockchainDisplayName:e}})},xr.createElement(Wp,{size:18}),xr.createElement(Wp,{size:32}),xr.createElement(DS,{id:"widget-experimental-chain-confirm-btn",onClick:o,variant:"outlined",type:"primary",fullWidth:!0,size:"large"},ba.t("Confirm")))}i(xa,"ExperimentalChain");function Bp(t,e){return t().status==="init"&&!!e}i(Bp,"isOnStatus");function Cn(t){return t().status==="namespace"}i(Cn,"isOnNamespace");function kn(t){return t().status==="derivationPath"}i(kn,"isOnDerivationPath");var zS=3e3,QS=300;function po(t){let e=US(),[o,n]=Mp(!1),[r,a]=Mp(),s=i(k=>{a(k.message)},"catchErrorOnHandle"),{terminateConnectingWallets:l}=ft(),{handleConnect:c,handleDerivationPath:p,handleNamespace:u,getState:d,resetState:h}=Gt(),g=i(k=>{u(t.wallet,k).then(S).catch(s)},"handleConfirmNamespaces"),f=i(k=>{if(!k)throw new Error("Derivation path is empty. Please make sure you've filled the field correctly.");p(k).then(S).catch(s)},"handleDerivationPathConfirm"),m=i(()=>{n(!1)},"handleClosingModal"),C=i(()=>{a(void 0),h(),n(!1),e.current&&clearTimeout(e.current)},"resetModalState"),S=i((k,T)=>{let v=k.status==="connected",b=["disconnected","disconnected-unhandled"].includes(k.status);v?(t.onConnect?.(),T||(e.current=setTimeout(m,zS))):b&&m()},"afterConnected");return OS(()=>{if(t.wallet){C();let k=!1,T=!0;i(()=>{setTimeout(()=>{T=!1,k||n(!0)},QS)},"beforeConnecting")(),c(t.wallet,{disconnectIfConnected:!0}).then(b=>{["namespace","derivation-path"].includes(b.status)||(k=!0),S(b,T)}).catch(s)}},[t.wallet]),co.createElement(Z,{open:o,onClose:m,onExit:()=>{C(),l(),t.onClose&&t.onClose()},container:I()},Bp(d,t.wallet)&&co.createElement(co.Fragment,null,co.createElement(wa,{wallet:{type:t.wallet.type,image:t.wallet.image},error:r}),co.createElement(FS,{direction:"vertical",size:32})),Cn(d)&&co.createElement(yn,{onConfirm:g,value:d().namespace}),kn(d)&&co.createElement(Sn,{onConfirm:f,value:d().derivationPath}))}i(po,"StatefulConnectModal");import{Provider as KS}from"@rango-dev/wallets-react";import Er,{createContext as jS,useEffect as $p,useMemo as XS,useRef as Fp}from"react";import{useEffect as HS}from"react";function Lp(t){return t.map(e=>typeof e=="string"?e:e.config.type).join("-")}i(Lp,"hashProviders");function Ea(t,e){let{clearConnectedWallet:o,getAvailableProviders:n,buildAndSetProviders:r}=y(),a=n();return HS(()=>{o(),r()},[Lp(t??[]),e?.walletConnectProjectId,e?.walletConnectListedDesktopWalletLink]),{providers:a}}i(Ea,"useWalletProviders");import{legacyFormatAddressWithNetwork as qS,legacyReadAccountAddress as Pp}from"@rango-dev/wallets-core/legacy";import{Events as uo}from"@rango-dev/wallets-react";import{isEvmBlockchain as GS}from"rango-sdk";function _p(t){let{newWalletConnected:e,disconnectWallet:o,disconnectNamespaces:n,connectedWallets:r,removeBalancesForWallet:a,blockchains:s}=y(),{onConnectWalletHandler:l,onDisconnectWalletHandler:c}=t,p=s().filter(GS).map(m=>m.name),u=i((m,C)=>{let[S,,k,,T]=m,v=aa(S,k,p,C.supportedChainNames,T.isContractWallet);v.length&&e(v,T.namespace)},"onAccountsEvent"),d=i((m,C,S,k,T)=>{if(C===uo.ACCOUNTS){let v=un(T.supportedBlockchains);S&&u([m,C,S,k,T],{supportedChainNames:v})}if(C===uo.CONNECTED){let v=`${m}-${k.network}-${S}`;l.current?l.current(v):console.warn("onConnectWallet handler hasn't been set. Are you sure?")}C===uo.PROVIDER_DISCONNECTED&&(o(m),c.current?c.current(m):console.warn("onDisconnectWallet handler hasn't been set. Are you sure?")),C===uo.NAMESPACE_DISCONNECTED&&n(m,S)},"handleUpdatesForHub"),h=i((m,C,S,k,T)=>{if(C===uo.ACCOUNTS){let v=un(T.supportedBlockchains),b=[],A=[];if(S?.forEach(w=>{let{network:x}=Pp(w);p.includes(x)?b.push(w):A.push(w)}),r.filter(w=>w.walletType===m).map(w=>qS(w.address,w.chain)).length>0){if(b.length>0){let w=aa(m,b,p,v,T.isContractWallet);a(m,{chains:w.map(x=>x.chain)})}A.length>0&&a(m,{chains:A.map(w=>{let{network:x}=Pp(w);return x})})}S?u([m,C,S,k,T],{supportedChainNames:v}):(o(m),c.current?c.current(m):console.warn("onDisconnectWallet handler hasn't been set. Are you sure?"))}if(C===uo.ACCOUNTS&&k.connected){let v=`${m}-${k.network}-${S}`;l.current?l.current(v):console.warn("onConnectWallet handler hasn't been set. Are you sure?")}},"handleUpdatesForLegacy"),g=i((m,C,S,k,T)=>{if(C===uo.NETWORK&&k.network){let v=`${m}-${k.network}`;l.current?l.current(v):console.warn("onConnectWallet handler hasn't been set. Are you sure?")}},"handleUpdatesForBoth");return{handler:i((m,C,S,k,T)=>{T.isHub?d(m,C,S,k,T):h(m,C,S,k,T),g(m,C,S,k,T)},"handler")}}i(_p,"useUpdates");import{LegacyEvents as VS}from"@rango-dev/wallets-core/legacy";function Dp(t,e){let[o,n,r,a,s]=e;n!==VS.PROVIDER_DISCONNECTED&&t(o,n,r,a,s)}i(Dp,"propagateEvents");var Ir=jS({onConnectWallet:()=>{},onDisconnectWallet:()=>{}});function YS(t){let{updateConfig:e,updateSettings:o,fetch:n,fetchStatus:r}=y(),a=y().blockchains(),s=y().config,l={walletConnectProjectId:s?.walletConnectProjectId,trezorManifest:s?.trezorManifest,tonConnect:s.tonConnect,walletConnectListedDesktopWalletLink:t.config.__UNSTABLE_OR_INTERNAL__?.walletConnectListedDesktopWalletLink},{providers:c}=Ea(s.wallets,l),p=Fp(),u=Fp(),{handler:d}=_p({onConnectWalletHandler:p,onDisconnectWalletHandler:u});$p(()=>{n().catch(console.log)},[]),$p(()=>{t.config&&(e(t.config),o(t.config),window.__rango={config:s,dappConfig:t.config})},[t.config,r]);let h=re.use.isActiveTab(),g=XS(()=>({onConnectWallet:f=>{p.current=f},onDisconnectWallet:f=>{u.current=f}}),[]);return Er.createElement(Ir.Provider,{value:g},Er.createElement(KS,{allBlockChains:a,providers:c,onUpdateState:(f,m,C,S,k)=>{let T=[f,m,C,S,k];d(...T),t.onUpdateState&&Dp(t.onUpdateState,T)},autoConnect:!!h,configs:{wallets:s.wallets}},t.children))}i(YS,"Main");function Ar(t){let{config:e,...o}=t;return Er.createElement(mp,{config:e},Er.createElement(YS,{...o,config:e}))}i(Ar,"WidgetWallets");import Zi from"react";import ZS,{Fragment as JS}from"react";import{MemoryRouter as RS,useInRouterContext as eC}from"react-router";function Op({children:t}){let o=eC()?JS:RS;return ZS.createElement(o,null,t)}i(Op,"AppRouter");import{I18nManager as _E}from"@rango-dev/ui";import ec from"react";import _e from"react";import{useRoutes as TE}from"react-router-dom";var $={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 Ke from"bignumber.js";import{create as nC}from"zustand";import{subscribeWithSelector as rC}from"zustand/middleware";import{i18n as gt}from"@lingui/core";import{RouteEventType as MB}from"@rango-dev/queue-manager-rango-preset";import Ue from"bignumber.js";import{PendingSwapNetworkStatus as _r}from"rango-types";import{i18n as $e}from"@lingui/core";var R=i(()=>({genericServerError:$e.t("Failed Network, Please retry your swap."),liquiditySourcesError:{title:$e.t("Please reset your liquidity sources."),description:$e.t("You have limited the liquidity sources and this might result in Rango finding no routes. Please consider resetting your liquidity sources.")},noResultError:{title:$e.t("No Routes Found."),description:$e.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:$e.t("Bridge Limit Error: Please increase your amount."),decreaseAmount:$e.t("Bridge Limit Error: Please decrease your amount.")},highValueLossError:{impactTitle:$e.t("High Price Impact"),title:$e.t("Price impact is too high!"),description:$e.t("The price impact is significantly higher than the allowed amount."),confirmMessage:$e.t("Confirm high price impact")},quoteUpdatedWithHighValueLoss:{title:$e.t("Route updated and price impact is too high, try again later!")},unknownPriceError:{impactTitle:$e.t("USD Price Unknown"),title:$e.t("USD Price Unknown, Cannot calculate Price Impact."),description:$e.t("USD Price Unknown, Cannot calculate Price Impact. The price impact may be higher than usual. Are you sure to continue the Swap?"),confirmMessage:$e.t("Confirm USD Price Unknown")}}),"errorMessages");function Up(t){switch(t.type){case 0:return t.diagnosisMessage??R().noResultError.title;case 1:return R().genericServerError;default:return""}}i(Up,"getQuoteErrorMessage");import{i18n as Nr}from"@lingui/core";var mo=i(()=>({connectWallet:Nr.t("Connect Wallet"),swap:Nr.t("Swap"),swapAnyway:Nr.t("Swap anyway"),ethWarning:Nr.t("The route goes through Ethereum. Continue?")}),"swapButtonTitles");function Ia(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(Ia,"getFeeLabel");var Aa=["RECOMMENDED","CENTRALIZED","LOWEST_FEE","FASTEST","HIGH_IMPACT"],zp=100,Qp=30,Hp=15,qp=60;var Gp=[{threshold:-10,minInput:400},{threshold:-5,minInput:1e3}],Vp=[{threshold:-1,minInput:1e3},{threshold:-2,minInput:500}];import{getLastSuccessfulStep as oC}from"@rango-dev/queue-manager-rango-preset";import SB from"bignumber.js";function jp(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(jp,"getRequiredBalanceOfWallet");function _t(t){let e;return t<=-3&&t>-10?e="low":t<=-10&&(e="high"),e}i(_t,"getPriceImpactLevel");function Br(t,e,o){let n=t.steps[0],r=t.steps[t.steps.length-1],a=oC(t.steps),s={blockchain:r.toBlockchain,symbol:r.toSymbol,address:r.toSymbolAddress},l=an(a?a.toBlockchain:n.fromBlockchain,e),c=an(r.toBlockchain,e),p=o(a?{blockchain:l?.name??"",symbol:a.toSymbol,address:a.toSymbolAddress}:{blockchain:l?.name??"",symbol:n.fromSymbol,address:n.fromSymbolAddress}),u=o(s),d=a?a.outputAmount??"":t.inputAmount;return{fromBlockchain:l,fromToken:p,toBlockchain:c,toToken:u,inputAmount:d}}i(Br,"createRetryQuote");function Fo(t){let{previousQuote:e,currentQuote:o,findToken:n,userSlippage:r}=t,a=Tn(o),s=ct(o);if(o&&a&&s){let p=Pt(a.toString(),s.toString());if(!!p&&Rp(a,p)){let d=Lr(o?.swaps,n),h=_t(p);return{type:0,inputUsdValue:a,outputUsdValue:s,priceImpact:p,totalFee:d,warningLevel:h}}}if(e&&ou(e,o))return{type:4,usdValueChange:B(ct(o)?.minus(ct(e)??0).toString()??"0",null,2),percentageChange:B(Pt(ct(e)??"1",ct(o)??"1"),null,2)};if(o&&(!a||!s))return{type:1};let l=Pr(o.swaps),c=r>tp;if(tu(t.userSlippage.toString(),l)){if(c&&parseFloat(l??"0")<r)return{type:3,slippage:r.toString()}}else return{type:2,recommendedSlippages:eu(o,r),minRequiredSlippage:l};return null}i(Fo,"generateQuoteWarnings");function Xp(t){return![4].includes(t.type)}i(Xp,"isQuoteWarningConfirmationRequired");function Pt(t,e){let o=typeof e=="string"?parseFloat(e)<=0:!e?.gt(0),n=!t||!e||o?null:Na(t.toString(),e.toString());return n&&n<0?n:null}i(Pt,"getPriceImpact");var Yp=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"),Mr=i((t,e)=>e.sort((o,n)=>{let r=i(p=>p.scores?.find(u=>u.preferenceType===t)?.score??0,"getScore"),a=r(o),s=r(n);if(a!==s)return s-a;let l=o.requestId.toLowerCase(),c=n.requestId.toLowerCase();return l.localeCompare(c)}),"sortQuotesBy"),Zp=i((t,e,o)=>{if(!e.length)return null;if(!t)return{requestAmount:o,validationStatus:null,...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,validationStatus:null,...r||e[0]}},"getDefaultQuote"),Jp=i(t=>{let e=i((o,n)=>{let r=Aa.indexOf(o.value),a=Aa.indexOf(n.value);return r!==-1&&a!==-1?r-a:r!==-1?-1:a!==-1?1:0},"customSort");return t.sort(e)},"sortTags");function Rp(t,e){if(!t)return!1;let o=parseInt(e.toFixed(2)||"0");return Gp.some(({threshold:n,minInput:r})=>o<=n&&t.gte(new Ue(r)))}i(Rp,"hasHighValueLoss");function nu(t){return(t||[]).filter(e=>{let o=e.fromAmountMinValue?new Ue(e.fromAmountMinValue):null,n=e.fromAmountMaxValue?new Ue(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(nu,"hasLimitError");function ru(t){let e=(t||[]).filter(l=>{let c=l.fromAmountMinValue?new Ue(l.fromAmountMinValue):null,p=l.fromAmountMaxValue?new Ue(l.fromAmountMaxValue):null;return l.fromAmountRestrictionType==="EXCLUSIVE"?c?.gte(l.fromAmount)||p?.lte(l.fromAmount):c?.gt(l.fromAmount)||p?.lt(l.fromAmount)})[0],o=e.fromAmountMinValue?new Ue(e.fromAmountMinValue):null,n=e.fromAmountMaxValue?new Ue(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=R().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=R().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=R().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=R().bridgeLimitErrors.decreaseAmount),{swap:e,fromAmountRangeError:a,recommendation:s}}i(ru,"getLimitErrorMessage");function iu(t){let{fetchMetaStatus:e,anyWalletConnected:o,fetchingQuote:n,inputAmount:r,quote:a,warning:s,error:l,needsToWarnEthOnPath:c}=t;return e!=="success"?{title:mo().connectWallet,action:"connect-wallet",disabled:!0}:o?n||!a||l||!r||r==="0"?{title:mo().swap,action:"confirm-swap",disabled:!0}:s?{title:mo().swapAnyway,action:"confirm-warning",disabled:!1}:c?{title:mo().ethWarning,action:"confirm-warning",disabled:!1}:{title:mo().swap,action:"confirm-swap",disabled:!1}:{title:mo().connectWallet,action:"connect-wallet",disabled:!1}}i(iu,"getSwapButtonState");function Wa(t,e,o){let n=parseFloat(e||"0");return!(t&&(!o||o.lte(ce))&&e&&e!=="0"&&n!==0)}i(Wa,"canComputePriceImpact");function Ba(t,e){let o=ce;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 Ue(r.amount).multipliedBy(a||0))}return o}i(Ba,"getUsdFeeOfStep");function Lr(t,e){return t.reduce((o,n)=>o.plus(Ba(n,e)),ce)}i(Lr,"getTotalFeeInUsd");function Ma(t){let e=ce;return e=e.plus(new Ue(t.amount).multipliedBy(t.price||0)),e}i(Ma,"getUsdFee");function au(t){return t.reduce((e,o)=>e.plus(Ma(o)),ce)}i(au,"getTotalFeesInUsd");function su(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(su,"getFeesGroup");function lu(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(lu,"checkSlippageErrors");function eu(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(eu,"checkSlippageWarnings");function Pr(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(Pr,"getMinRequiredSlippage");function tu(t,e){return e?parseFloat(t)>=parseFloat(e):!0}i(tu,"hasProperSlippage");function cu(t){let{fromToken:e,toToken:o,inputAmount:n,wallets:r,selectedWallets:a,disabledLiquiditySources:s,liquiditySources:l,excludeLiquiditySources:c,slippage:p,affiliateRef:u,affiliatePercent:d,affiliateWallets:h,destination:g}=t,f=a?.reduce((S,k)=>(S[k.chain]=k.address,S),{}),m=[];return r?.forEach(S=>{m.push({blockchain:S.chain,addresses:[S.address]})}),{amount:n.toString(),affiliateRef:u??void 0,affiliatePercent:d??void 0,affiliateWallets:h??void 0,from:{address:e.address,blockchain:e.blockchain,symbol:e.symbol},to:{address:o.address,blockchain:o.blockchain,symbol:o.symbol},connectedWallets:m,selectedWallets:f??{},slippage:p.toString(),...g&&{destination:g},...c&&{swapperGroups:s.concat(l??[]),swappersGroupsExclude:!0},...!c&&{swapperGroups:l?.filter(S=>!s.includes(S)),swappersGroupsExclude:!1}}}i(cu,"createQuoteRequestBody");function pu(t){return t.reduce((o,n)=>(o[n.chain]={address:n.address,walletType:n.walletType},o),{})}i(pu,"getWalletsForNewSwap");function Tn(t){let e=t.requestAmount,o=t.swaps[0].from.usdPrice;if(!(!e||!o))return new Ue(e).multipliedBy(o)}i(Tn,"getUsdInputFrom");function ct(t){let e=t?.outputAmount||null,o=t.swaps[t.swaps.length-1].to.usdPrice;if(!(!e||!o))return new Ue(e).multipliedBy(o)}i(ct,"getUsdOutputFrom");function Na(t,e){return new Ue(e).div(new Ue(t)).minus(1).multipliedBy(zp).toNumber()}i(Na,"getPercentageChange");function ou(t,e){let o=Tn(t),n=ct(t),r=ct(e);if(!o||!n||!r)return!1;let a=Na(n.toString(),r.toString());return Vp.some(({threshold:s,minInput:l})=>a<=s&&o.isGreaterThanOrEqualTo(l))}i(ou,"isOutputAmountChangedExcessively");function uu(t,e,o){let n=t.validationStatus,r=io({filter:"required",quote:t});return e.sort((s,l)=>r.indexOf(s.chain)-r.indexOf(l.chain)).flatMap(s=>jp(s,n)||[]).filter(s=>!s.ok).map(s=>{let l=s.asset.symbol,c=B(new Ue(s.currentAmount.amount).shiftedBy(-s.currentAmount.decimals),8,8),p=B(new Ue(s.requiredAmount.amount).shiftedBy(-s.requiredAmount.decimals),8,8),u="";return s.reason==="FEE"&&(u=gt.t(" for network fee")),s.reason==="INPUT_ASSET"&&(u=gt.t(" for swap")),s.reason==="FEE_AND_INPUT_ASSET"&&(u=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:p,symbol:l,reason:u,currentAmount:c,blockchain:st(s.asset.blockchain,o)}})})}i(uu,"generateBalanceWarnings");function vn(t){return!!t&&t.networkStatus!==null&&t.networkStatus!==_r.NetworkChanged}i(vn,"isNetworkStatusInWarningState");function du(t,e){let o="bellow button or",n=t.extraMessage,r=t.extraMessageDetail;if(t.networkStatusExtraMessageDetail?.includes(o)&&(t.networkStatusExtraMessageDetail=t.networkStatusExtraMessageDetail.replace(o,"")),vn(e))switch(n=t.networkStatusExtraMessage||"",r=t.networkStatusExtraMessageDetail||"",e?.networkStatus){case _r.WaitingForConnectingWallet:n=n||gt.t("Waiting for connecting wallet");break;case _r.WaitingForQueue:n=n||gt.t("Waiting for other running tasks to be finished");break;case _r.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(du,"getSwapMessages");function mu(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(mu,"getLastConvertedTokenInFailedSwap");function fu(t){return t.status==="failed"}i(fu,"shouldRetrySwap");function gu(t,e,o,n,r,a){if(!n||t)return!0;let s=io({filter:"all",quote:n}),l=io({filter:"required",quote:n}),c=s.every(d=>r.some(h=>h.chain===d)),p=l.every(d=>r.some(h=>h.chain===d)),u=o&&a?Io(a,o):!1;return!e&&!c||e&&!o||e&&!!o&&(!u||!p)}i(gu,"isConfirmSwapDisabled");function hu(t,e){return t.blockchain===e.blockchain&&t.symbol===e.symbol&&t.address===e.address}i(hu,"isTokensIdentical");var Dr=i((t,e)=>t?.usdPrice?new Ke(e||ce).multipliedBy(t?.usdPrice||0):null,"getUsdValue"),O=Lo(nC()(rC(t=>({fromBlockchain:null,fromToken:null,inputAmount:"",outputAmount:null,inputUsdValue:new Ke(0),outputUsdValue:new Ke(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=ce,a=o.inputUsdValue;return cn(o.inputAmount)?(e&&(n=e?.outputAmount?new Ke(e?.outputAmount):null,a=Tn(e)??ce,r=ct(e)??ce),{selectedQuote:e,...!!e&&{outputAmount:n,outputUsdValue:r,inputUsdValue:a}}):{}}),resetAlerts:()=>t(()=>({error:null,warning:null})),resetQuote:()=>t(()=>({selectedQuote:null,outputAmount:null,outputUsdValue:new Ke(0),quotes:null,refetchQuote:!0,error:null,warning:null})),setFromBlockchain:e=>{t(o=>o.fromBlockchain?.name===e?.name?{}:{fromBlockchain:e,inputUsdValue:new Ke(0),...o.fromToken&&{selectedQuote:null,fromToken:null,outputAmount:null,outputUsdValue:new Ke(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 Ke(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 Ke(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 Ke(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 Ke(0)})),resetFromBlockchain:()=>t(()=>({fromToken:null,fromBlockchain:null,outputUsdValue:new Ke(0),inputUsdValue:new Ke(0),inputAmount:"",outputAmount:null,selectedQuote:null})),resetToBlockchain:()=>t(()=>({toToken:null,toBlockchain:null,outputAmount:null,outputUsdValue:new Ke(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})})))),yu=O.subscribe((t,e)=>{(t.fromBlockchain!==e.fromBlockchain||t.fromToken!==e.fromToken||t.toBlockchain!==e.toBlockchain||t.toToken!==e.toToken||t.inputAmount!==e.inputAmount)&&he.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&&he.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 Su(){let{setInputAmount:t,setToToken:e,setToBlockchain:o,setFromBlockchain:n,resetQuote:r,setFromToken:a,fromToken:s,toToken:l,fromBlockchain:c,toBlockchain:p}=O(),u=y().config,d=y().fetchStatus,h=y().blockchains(),g=y().tokens(),{findToken:f}=y(),{setAffiliateRef:m,setAffiliatePercent:C,setAffiliateWallets:S}=y(),k=u?.from?.tokens,T=u?.from?.blockchains,v=u?.to?.tokens,b=u?.to?.blockchains,A=$r(void 0),D=$r(void 0),w=$r(void 0),x=$r(void 0);Oo(()=>{typeof u.amount<"u"&&t(u.amount.toString())},[u?.amount]),Oo(()=>{if(d==="success"){r();let E=h.find(W=>W.name===u?.from?.blockchain),N=u?.from?.token,M=N&&f(N);(E||!E&&w.current)&&n(E??null),M?a({token:M,meta:{blockchains:h,tokens:g}}):!M&&A.current&&a({token:null}),w.current=u?.from?.blockchain,A.current=u?.from?.token}},[u?.from?.token?.symbol,u?.from?.token?.address,u?.from?.token?.blockchain,u?.from?.blockchain,d]),Oo(()=>{ca(s,k)&&a({token:null}),pa(c,T)&&n(null)},[k,T]),Oo(()=>{ca(l,v)&&a({token:null}),pa(p,b)&&o(null)},[v,b]),Oo(()=>{if(d==="success"){r();let E=h.find(W=>W.name===u?.to?.blockchain),N=u?.to?.token,M=N&&f(N);(E||!E&&x.current)&&o(E??null),M?e({token:M,meta:{blockchains:h,tokens:g}}):!M&&D.current&&e({token:null}),x.current=u?.to?.blockchain,D.current=u?.to?.token}},[u?.to?.token?.symbol,u?.to?.token?.address,u?.to?.token?.blockchain,u?.to?.blockchain,d]),Oo(()=>{m(u?.affiliate?.ref??null),C(u?.affiliate?.percent??null),S(u?.affiliate?.wallets??null)},[u?.affiliate?.ref,u?.affiliate?.percent,u?.affiliate?.wallets])}i(Su,"useSyncStoresWithConfig");import{useEffect as _a,useRef as iC}from"react";import{useInRouterContext as aC,useLocation as sC,useSearchParams as lC}from"react-router-dom";function La(t,e){let o=t.split("--");return{blockchain:e.name,address:o?.[1]||null,symbol:o[0]}}i(La,"convertTokenSearchParamToAsset");function Pa(t){if(t)return`${t.symbol}${t.address?`--${t.address}`:""}`}i(Pa,"tokenToSearchParam");function $a(){let t=sC(),[e,o]=lC(),{fromBlockchain:n,toBlockchain:r,fromToken:a,toToken:s,inputAmount:l,setFromBlockchain:c,setToBlockchain:p,setFromToken:u,setToToken:d,setInputAmount:h}=O(),g=y().fetchStatus,f=y().blockchains(),m=y().tokens(),C=aC(),{updateIframe:S,updateCampaignMode:k}=y(),T=y().isInCampaignMode(),v=iC(),{findToken:b}=y(),A=i(()=>{let w={};for(let[X,se]of e.entries())X.startsWith("utm_")&&(w[X]=se);let x=e.get("fromAmount"),E=e.get("fromBlockchain"),N=e.get("fromToken"),M=e.get("toBlockchain"),W=e.get("toToken"),j=e.get("autoConnect"),te=e.get("clientUrl"),J=e.get("liquiditySources"),L=e.get("blockchain");return{fromAmount:x,fromBlockchain:E,fromToken:N,toBlockchain:M,toToken:W,autoConnect:j,clientUrl:te,liquiditySources:J,utmQueryParams:w,blockchain:L}},"getUrlSearchParams"),D=i(w=>{for(let x in w)w[x]||delete w[x];o(w,{replace:!0})},"updateUrlSearchParams");_a(()=>{let{autoConnect:w,clientUrl:x,utmQueryParams:E,blockchain:N}=A();C&&g==="success"&&D({fromBlockchain:n?.name,fromToken:Pa(a),toBlockchain:r?.name,toToken:Pa(s),fromAmount:l,autoConnect:w??void 0,clientUrl:x??void 0,blockchain:N??void 0,liquiditySources:T?v.current:void 0,...E})},[t.pathname,l,n,a,r,s,T]),_a(()=>{if(!C)return;let w=A();if(!v.current&&w.liquiditySources&&(v.current=w.liquiditySources),w.fromAmount&&h(w.fromAmount),g==="success"){let x=f.find(W=>W.name===w.fromBlockchain),E=w.fromToken&&x?b(La(w.fromToken,x)):void 0,N=f.find(W=>W.name===w.toBlockchain),M=w.toToken&&N?b(La(w.toToken,N)):void 0;x&&(c(x),E&&u({token:E,meta:{blockchains:f,tokens:m}})),N&&(p(N),M&&d({token:M,meta:{blockchains:f,tokens:m}}))}},[g]),_a(()=>{let{clientUrl:w,liquiditySources:x}=A();S("clientUrl",w||void 0),k("liquiditySources",x?.split(",")??void 0)},[])}i($a,"useSyncUrlAndStore");import{i18n as It}from"@lingui/core";import{Alert as vk,Button as Ju,darkTheme as wk,Divider as xn,DoneIcon as bk,MessageBox as xk,styled as Ek,TextField as Ik,Typography as Ak}from"@rango-dev/ui";import ye,{useEffect as Nk,useState as qr}from"react";import{useNavigate as Wk,useSearchParams as Bk}from"react-router-dom";import{ChevronRightIcon as cC,Divider as wu,Image as pC,Typography as bu}from"@rango-dev/ui";import ht from"react";import{darkTheme as Cu,styled as Fa}from"@rango-dev/ui";var ku=Fa("div",{display:"flex",justifyContent:"space-between",width:"100%",height:"$40",padding:"$4 $10",borderRadius:"$sm",cursor:"pointer",alignItems:"center",backgroundColor:"$neutral300",[`.${Cu} &`]:{backgroundColor:"$neutral400"},"&:hover":{backgroundColor:"$secondary100",[`.${Cu} &`]:{backgroundColor:"$neutral500"}},variants:{disabled:{true:{cursor:"default","&:hover":{borderColor:"$neutral300","& svg":{color:"$neutral700"}}}}}}),Tu=Fa("div",{display:"flex",flexDirection:"column",width:"100%",".title_typography":{textTransform:"capitalize"}}),vu=Fa("div",{display:"flex"});function Oa(t){let{onClick:e,value:o,title:n,hasLogo:r,placeholder:a,disabled:s}=t;return ht.createElement(Tu,null,ht.createElement(bu,{size:"large",variant:"label"},n),ht.createElement(wu,{size:10}),ht.createElement(ku,{onClick:s?void 0:e,disabled:s},ht.createElement(vu,null,r&&ht.createElement(ht.Fragment,null,ht.createElement(pC,{src:o?.logo,size:16,useAsPlaceholder:!o?.logo,type:"circular"}),ht.createElement(wu,{size:4,direction:"horizontal"})),ht.createElement(bu,{className:"title_typography",size:"medium",variant:"label"},o?.name||a)),ht.createElement(cC,{size:12,color:"black"})))}i(Oa,"BlockchainSelectorButton");import{i18n as za}from"@lingui/core";import{Button as uC,Divider as wn,ExternalLinkIcon as dC,Image as mC,Typography as zo}from"@rango-dev/ui";import Ne from"react";function xu(t,e){if(e.type==="COSMOS")return"";let o=e.info?.addressUrl;return!o||!t?"":o.replace("{wallet}",t)}i(xu,"generateExplorerLink");import{darkTheme as Uo,styled as Eu}from"@rango-dev/ui";var Ua=Eu("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:{}}}}),Iu=Eu("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 Qa(t){let{open:e,onClose:o,token:n,onSubmitClick:r,blockchain:a}=t,s=xu(n.address,a);return Ne.createElement(Z,{open:e,dismissible:!0,onClose:o,container:I()},Ne.createElement(Iu,null,Ne.createElement(mC,{src:n.image,size:45,type:"circular"}),Ne.createElement(zo,{variant:"title",size:"medium"},n.name),Ne.createElement(zo,{variant:"body",size:"small",className:"_blockchain-name"},a.displayName),Ne.createElement(wn,{size:4}),Ne.createElement(zo,{variant:"body",size:"medium"},s?Ne.createElement(Ua,{hasHover:!0,href:s,target:"_blank",rel:"nofollow noreferrer"},n.address,Ne.createElement(dC,{size:12,color:"gray"})):Ne.createElement(Ua,null,n.address)),Ne.createElement(wn,{size:4}),n.coinSource&&Ne.createElement(zo,{className:"_coin-source",variant:"body",size:"xsmall"},za.t("via")," ",Ne.createElement(zo,{className:"_coin-source-name",variant:"body",size:"xsmall"},n.coinSource)),Ne.createElement(wn,{size:"32"}),Ne.createElement(zo,{size:"medium",variant:"body",className:"_custom-token-description"},za.t("This token doesn't appear on the active token list(s). Make sure this is the token that you want to trade."))),Ne.createElement(wn,{size:40}),Ne.createElement(wn,{size:10}),Ne.createElement(uC,{id:"widget-custom-token-modal-import-btn",variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:r},za.t("Import")))}i(Qa,"CustomTokenModal");import{useManager as hk}from"@rango-dev/queue-manager-react";import{BottomLogo as yk,Divider as Ku,Header as Sk}from"@rango-dev/ui";import Be,{useEffect as ps,useRef as ju,useState as Ck}from"react";import{useRef as fC}from"react";function Fr(){return window.self!==window.top}i(Fr,"isAppLoadedIntoIframe");function Ha(){let t=fC(null),{iframe:e}=y(),o=Fr()&&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 c of l)n({type:"widget_height",data:{height:c.contentRect.height}})}),t.current.observe(s)},"connectHeightObserver"),disconnectHeightObserver:i(()=>{t.current&&(t.current.disconnect(),t.current=null)},"disconnectHeightObserver")}}i(Ha,"useIframe");import{useNavigate as gC}from"react-router-dom";function je(){let t=gC();return()=>t(-1)}i(je,"useNavigateBack");import{createTheme as Ya,darkTheme as NC,lightTheme as WC}from"@rango-dev/ui";import{useEffect as BC,useState as MC}from"react";import{theme as IC,darkColors as AC}from"@rango-dev/ui";import ja from"react";function hC(t){return t.startsWith("#")&&(t=t.slice(1)),t.length===3?`#${t.split("").reduce(function(n,r){return n+r+r},"")}`:`#${t}`}i(hC,"expandShortHexColor");function yC(t){return/[0-9]+$/.test(t)}i(yC,"isOverridingColor");function SC(t,e){return t.padStart(e,"0")}i(SC,"pad");function qa(t){let e=Math.min(Math.max(Math.round(t),0),255);return SC(e.toString(16),2)}i(qa,"intToHex");function CC(t){return`#${qa(t.red)}${qa(t.green)}${qa(t.blue)}`}i(CC,"rgbToHex");function kC(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(kC,"hexToRGB");function TC(t,e){let o=1-.11*e;return{red:t.red*o,green:t.green*o,blue:t.blue*o}}i(TC,"generateShade");function vC(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(vC,"generateTint");function wC(t){return Au(t,TC)}i(wC,"calculateShades");function bC(t){return Au(t,vC)}i(bC,"calculateTints");function Au(t,e){let o=kC(t),n=[];for(let r=1;r<9;r++)n.push(CC(e(o,r)));return n}i(Au,"calculateColors");function Ga(t,e,o){let a=bC(t).reverse().concat(t),s=wC(t),l=a.concat(s),c={},p=l.length;for(let u=0;u<p;u++){let d=100+(o?p-1-u:u)*50;c[`${e}${d}`]=l[u]}return c}i(Ga,"createTintsAndShades");function Va(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)&&!yC(r)){let c=hC(a);Object.assign(n,Ga(c,r,s))}}return{...n,...e}}i(Va,"expandToGenerateThemeColors");var Nu=i(t=>String.fromCharCode(t+(t>25?39:97)),"toAlphabeticChar"),xC=i(t=>{let e="",o;for(o=Math.abs(t);o>52;o=o/52|0)e=Nu(o%52)+e;return Nu(o%52)+e},"toAlphabeticName"),EC=i((t,e)=>{let o=e.length;for(;o;)t=t*33^e.charCodeAt(--o);return t},"toPhash"),Ka=i(t=>xC(EC(5381,JSON.stringify(t))>>>0),"toHash");function Xa(t){let e=IC.colors,o={...e,...AC},n,r;if(t?.light){let s={colors:Va(e,t.light)};n={id:`${la}-light-${Ka(s)}`,tokens:s}}if(t?.dark){let s={colors:Va(o,t.dark,{reverseNeutralRange:!0})};r={id:`${la}-dark-${Ka(s)}`,tokens:s}}return{light:n,dark:r}}i(Xa,"customizedThemeTokens");function Wu(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(Wu,"joinList");function Bu(){return window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches}i(Bu,"doesWindowPreferDarkColorScheme");function Qo(t){let{colors:e,fontFamily:o=vc,borderRadius:n=Gc,secondaryBorderRadius:r=Vc}=t,[a,s]=MC(Bu()?"dark":"light"),{theme:l}=y(),{dark:c,light:p}=Xa(e),u=Ya({shadows:t.shadows||{},radii:{primary:`${n}px`,secondary:`${r}px`},fonts:{widget:o}}),d=[u.className,WC.className],h=[u.className,NC.className];if(p){let f=Ya(p.id,p.tokens);d.push(f.className)}if(c){let f=Ya(c.id,c.tokens);h.push(f.className)}return BC(()=>{let f=i(m=>{m.matches?s("dark"):s("light")},"switchThemeListener");return Bu()&&s("dark"),window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",f),()=>{window.matchMedia("(prefers-color-scheme: dark)").removeEventListener("change",f)}},[]),{activeTheme:i(()=>{let f=d.join(" "),m=h.join(" ");return l==="auto"?a==="dark"?m:f:l==="dark"?m:f},"getActiveTheme"),mode:l==="auto"?a:l}}i(Qo,"useTheme");var pt=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 Mu}from"@lingui/core";import{Alert as LC,Button as PC}from"@rango-dev/ui";import Lu from"react";function Za(t){return Lu.createElement(LC,{action:Lu.createElement(PC,{id:"widget-active-tab-btn",onClick:t.onActivateTab,variant:"contained",size:"xxsmall",type:"warning"},Mu.t("Activate this tab")),type:"warning",variant:"alarm",title:Mu.t("Another tab is open and handles transactions.")})}i(Za,"ActivateTabAlert");import{i18n as Ja}from"@lingui/core";import{Button as _C,Divider as DC,MessageBox as $C}from"@rango-dev/ui";import Or from"react";function Ra(t){let{open:e,onClose:o,onConfirm:n}=t;return Or.createElement(Z,{open:e,dismissible:!0,onClose:o,container:I()},Or.createElement($C,{title:Ja.t("Activate current tab"),type:"warning",description:Ja.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.")},Or.createElement(DC,{size:20}),Or.createElement(_C,{id:"widget-modal-confirm-activate-tab-btn",variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:n},Ja.t("Confirm"))))}i(Ra,"ActivateTabModal");import{ChevronLeftIcon as FC}from"@rango-dev/ui";import Pu from"react";function es(t){return Pu.createElement(Et,{id:"widget-header-back-icon-btn",variant:"ghost",size:"small",onClick:t.onClick},Pu.createElement(FC,{color:"black",size:16}))}i(es,"BackButton");import{i18n as OC}from"@lingui/core";import{Button as UC,Typography as zC}from"@rango-dev/ui";import ts from"react";function os(t){return ts.createElement(Vt,null,ts.createElement(UC,{id:"widget-header-cancel-btn",variant:"ghost",onClick:t.onClick,size:"xsmall"},ts.createElement(zC,{variant:"label",size:"medium",color:"error500"},OC.t("Cancel"))))}i(os,"CancelButton");import{i18n as QC}from"@lingui/core";import{Image as HC,Tooltip as qC,WalletIcon as GC}from"@rango-dev/ui";import fo from"react";function ns(t){let{list:e}=ft(),o=e.filter(r=>r.state==="connected"),n=o.length?fo.createElement("div",{className:Tp()},o.map(r=>fo.createElement(Tr,{key:r.title},fo.createElement(HC,{src:r.image,size:14})))):QC.t("Connect Wallet");return fo.createElement(qC,{container:t.container,side:"bottom",content:n},fo.createElement(Et,{id:"widget-header-wallet-icon-btn",variant:"ghost",size:"small",onClick:t.onClick},t.isConnected&&fo.createElement(yp,null),fo.createElement(GC,{size:18,color:"black"})))}i(ns,"WalletButton");import{i18n as zr}from"@lingui/core";import{NotificationsIcon as sk,Popover as lk,SettingsIcon as ck,Tooltip as Qr,TransactionIcon as pk}from"@rango-dev/ui";import We from"react";import{Notifications as XC}from"@rango-dev/ui";import YC from"react";import{useNavigate as ZC}from"react-router-dom";import{create as VC}from"zustand";import{persist as KC,subscribeWithSelector as jC}from"zustand/middleware";var be=Lo(VC()(KC(jC((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(c=>c.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(c=>c.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 rs(){let t=ZC(),{getNotifications:e,clearNotifications:o}=be(),n=e(),r=y().blockchains(),{findToken:a}=y();return YC.createElement(XC,{list:n,getBlockchainImage:l=>mc(l,r)??"",getTokenImage:l=>a(l)?.image??"",onClickItem:i(l=>{t(`${$.swaps}/${l}`)},"onClickItem"),onClearAll:o})}i(rs,"NotificationContent");import{useManager as JC}from"@rango-dev/queue-manager-react";import{InProgressIcon as RC}from"@rango-dev/ui";import _u from"react";var ek=i(()=>{let{manager:t}=JC();return pt(t).map(({swap:o})=>o).find(o=>o.status==="running")?_u.createElement(kp,null,_u.createElement(RC,{color:"info",size:6})):null},"InProgressTransactionBadge"),Du=ek;import{EventSeverity as tk}from"@rango-dev/queue-manager-rango-preset";import{Typography as ok}from"@rango-dev/ui";import $u from"react";function Fu(){let{getNotifications:t}=be(),e=t(),o=e.length,n=!!e.find(r=>r.event.messageSeverity===tk.WARNING);return o?$u.createElement(Sp,{isSever:n},$u.createElement(ok,{variant:"body",size:"xsmall",color:"$background"},o)):null}i(Fu,"NotificationsBadge");import{RefreshProgressButton as nk}from"@rango-dev/ui";import is,{useEffect as rk,useState as Ou}from"react";var ik=1e3,Uu=60,ak=100;function Ur({onClick:t}){let[e,o]=Ou(0),[n,r]=Ou(!1),a=i(c=>{document.hidden&&c&&s(c)},"handleVisibilityChange");rk(()=>{let c;return t?c=window.setInterval(()=>{o(p=>p+1),e===Uu&&l()},ik):s(c),document.addEventListener("visibilitychange",()=>a(c)),()=>{document.removeEventListener("visibilitychange",()=>a(c)),c&&clearInterval(c)}},[e,t]);let s=i(c=>{c&&clearInterval(c),o(0)},"clearTimeout"),l=i(()=>{t?.(),o(0),r(!0)},"handleRefreshClick");return is.createElement(Et,{id:"widget-header-refresh-icon-btn",variant:"ghost",size:"small",style:{paddingTop:0,paddingBottom:0},onClick:l,disabled:!t},is.createElement(Cp,{onTransitionEnd:()=>r(!1),isRefetched:n},is.createElement(nk,{size:22,color:t?"black":"gray",progress:e/Uu*ak})))}i(Ur,"RefreshButton");function go(t){let{onClickRefresh:e,onClickHistory:o,onClickSettings:n,hidden:r=[],container:a}=t,{config:{features:s}}=y(),l=Ve("notification",s)||r.includes("notifications");return We.createElement(We.Fragment,null,!r.includes("refresh")&&We.createElement(Qr,{container:a||I(),side:"top",content:zr.t("Refresh")},We.createElement(Ur,{onClick:e})),!l&&We.createElement(lk,{align:"end",alignOffset:-88,sideOffset:15,collisionPadding:{right:20,left:20},container:I(),content:We.createElement(rs,null)},We.createElement("div",null,We.createElement(Qr,{container:I(),side:"top",content:zr.t("Notifications")},We.createElement(Et,{id:"widget-header-notification-icon-btn",size:"small",variant:"ghost"},We.createElement(sk,{size:18,color:"black"}),We.createElement(Fu,null))))),!r.includes("settings")&&We.createElement(Qr,{container:I(),side:"top",content:zr.t("Settings")},We.createElement(Et,{id:"widget-header-setting-icon-btn",size:"small",variant:"ghost",onClick:n},We.createElement(ck,{size:18,color:"black"}))),!r.includes("history")&&We.createElement(Qr,{container:I(),side:"top",content:zr.t("History")},We.createElement(Et,{id:"widget-header-history-icon-btn",size:"small",variant:"ghost",onClick:o},We.createElement(pk,{size:18,color:"black"}),We.createElement(Du,null))))}i(go,"HeaderButtons");import{i18n as as}from"@lingui/core";import{Divider as Qu,MessageBox as mk,RefreshIcon as fk}from"@rango-dev/ui";import Ho from"react";import{Button as uk,styled as dk}from"@rango-dev/ui";var zu=dk(uk,{"& span":{display:"flex",justifyContent:"center",alignItems:"center"}});function ss(t){let{open:e,onClose:o}=t;return Ho.createElement(Z,{open:e,dismissible:!0,onClose:o,container:I()},Ho.createElement(mk,{title:as.t("Something went wrong"),type:"error",description:as.t("Something went wrong. Please refresh the app.")},Ho.createElement(Qu,{size:30}),Ho.createElement(zu,{variant:"outlined",size:"large",type:"primary",fullWidth:!0,onClick:()=>location.reload()},Ho.createElement(fk,{size:20,color:"primary"}),Ho.createElement(Qu,{size:4,direction:"horizontal"}),as.t("Refresh"))))}i(ss,"RefreshModal");function ls(t){let e=t.target;if(e){let o=e.scrollTop,n=I();o>1?n.classList.add("rng-scrolled"):n.classList.remove("rng-scrolled")}}i(ls,"onScrollContentAttachStatusToContainer");import{css as gk,styled as cs}from"@rango-dev/ui";var Hu="700px",Hr=gk({borderRadius:"$primary",display:"flex",flexDirection:"column",overflow:"hidden",boxShadow:"$mainContainer"}),qu=cs("div",{position:"relative",width:"100vw",minWidth:"300px",maxWidth:"390px",backgroundColor:"$background",variants:{height:{auto:{height:"auto",maxHeight:Hu},fixed:{height:Hu}}}}),Gu=cs("div",{position:"relative",overflow:"hidden",flexGrow:1,display:"flex",flexDirection:"column",padding:0,overflowY:"auto"}),Vu=cs("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 oe(t){let{connectHeightObserver:e,disconnectHeightObserver:o}=Ha(),{children:n,header:r,footer:a,height:s="fixed"}=t,{fetchStatus:l,connectedWallets:c}=y(),[p,u]=Ck(!1),{config:{features:d,theme:h}}=y(),{watermark:g}=re(),f=g==="FULL",{activeTheme:m}=Qo(h||{}),C=Ve("connectWalletButton",d),{isActiveTab:S,tabManagerInitiated:k,showActivateTabModal:T,setShowActivateTabModal:v,activateCurrentTab:b}=re(),A=je(),{manager:D}=hk(),x=pt(D).map(({swap:te})=>te).some(te=>te.status==="running"),E=i(()=>b(ao.forceClaim,x),"onActivateTab"),N=i(()=>{r.onWallet?.()},"onConnectWallet"),M=typeof r.hasBackButton>"u"||r.hasBackButton,W=ju(null),j=ju(null);return ps(()=>(Fr()&&j.current&&e(j.current),()=>{o()}),[]),ps(()=>(W.current?.addEventListener("scroll",ls),()=>{W.current?.removeEventListener("scroll",ls)}),[]),ps(()=>{u(l==="failed")},[l]),Be.createElement(qu,{height:s,id:De.SWAP_BOX_ID,className:`${m()} ${Hr()}`,ref:j},Be.createElement(Sk,{prefix:M?Be.createElement(es,{onClick:()=>{A(),r.onBack&&r.onBack()}}):null,title:r.title,suffix:Be.createElement(Be.Fragment,null,r.suffix,r.onWallet&&!C&&Be.createElement(ns,{container:I(),onClick:N,isConnected:!!c?.length}),r.onCancel&&Be.createElement(os,{onClick:r.onCancel}))}),Be.createElement(Gu,{ref:W},n),Be.createElement(Ra,{open:T,onClose:()=>v(!1),onConfirm:E}),Be.createElement(Vu,null,Be.createElement("div",{className:"footer__content"},k&&!S&&Be.createElement("div",{className:"footer__alert"},Be.createElement(Za,{onActivateTab:E}),Be.createElement(Ku,{size:10})),a),Be.createElement(Ku,{size:12}),Be.createElement("div",{className:`footer__logo ${f?"logo__show":"logo__hidden"}`},Be.createElement(yk,null))),Be.createElement(ss,{open:p,onClose:()=>u(!1)}))}i(oe,"Layout");import{styled as kk}from"@rango-dev/ui";var Xu="$20 $20 $10 $20",bn=kk("div",{padding:Xu,overflowY:"auto",flexGrow:1});import{styled as Tk}from"@rango-dev/ui";var ie=Tk("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 qo}from"@lingui/core";import{useState as Yu}from"react";function Zu(){let[t,e]=Yu(!1),[o,n]=Yu(void 0),{findToken:r}=y(),a=y().customTokens();function s(c,p){switch(c){case"duplicated":return{title:qo.t("Duplicate Token"),message:qo.t("The address you entered is duplicate, please enter a new address.")};case"token-exist":return{title:qo.t("Token Already Exists"),message:qo.t("There's no need to add this token again because it already exists and is supported by us.")};case"not-found":return{title:qo.t("Token Not Found"),message:qo.t({id:"Sorry, no token was found on {blockchain} chain with the provided address. please make sure you have entered the right token address.",values:{blockchain:p}})}}}return i(s,"produceErrorMessage"),{fetchCustomToken:i(async({blockchain:c,tokenAddress:p})=>{e(!0);try{if(a.some(f=>f.address?.toLowerCase()===p.toLowerCase())){let f=s("duplicated");n(f);return}let d=await xt().getCustomToken({blockchain:c,address:p});if(!d||!d.token||d.error){let f=s("not-found",c);n(f);return}let h=d.token;if(r({blockchain:h.blockchain,address:h.address,symbol:h.symbol})){let f=s("token-exist");n(f);return}return h}catch(u){if(u?.code==="ERR_BAD_REQUEST"){let d=s("not-found",c);n(d);return}throw n(void 0),new Error(u.message)}finally{e(!1)}},"fetchCustomToken"),loading:t,error:o}}i(Zu,"useFetchCustomToken");var Mk=Ek("div",{display:"flex",justifyContent:"space-between",flexDirection:"column",flex:1,"& ._text-field":{padding:"$4 $10",backgroundColor:"$neutral300",[`.${wk} &`]:{backgroundColor:"$neutral400"},borderRadius:"$sm",height:"$40"}}),Lk=1e3;function Ru(){let t=Wk(),[e]=Bk(),o=je(),{setCustomToken:n}=y(),r=y().blockchains(),a=e.get("blockchain")||"",s=an(a,r),[l,c]=qr(""),[p,u]=qr(!1),[d,h]=qr(),{fetchCustomToken:g,loading:f,error:m}=Zu(),[C,S]=qr(""),k=!!s&&Io(s,l),T=!s||!l||!k,v=i(async()=>{if(s)try{let D=await g({blockchain:a,tokenAddress:l});S(""),D&&h(D)}catch(D){D.message==="Failed to fetch"&&(S(It.t("Network Error")),u(!0))}},"getCustomToken"),b=i(()=>{m&&c(""),u(!1)},"closeErrorModal"),A=i(async()=>{C&&setTimeout(async()=>{await v()},Lk),b()},"handleErrorModalButtonClick");return Nk(()=>{m&&u(!0)},[m]),ye.createElement(oe,{header:{title:It.t("Add Custom Token")}},ye.createElement(ie,null,ye.createElement(Mk,null,ye.createElement("div",null,ye.createElement(Oa,{onClick:()=>t($.blockchains,{replace:!0}),hasLogo:!!s?.logo,value:s?{name:s.displayName,logo:s.logo}:void 0,title:It.t("Select chain"),placeholder:It.t("Select chain")}),ye.createElement(xn,{size:"24"}),ye.createElement(Ak,{size:"large",variant:"label"},It.t("Enter Address")),ye.createElement(xn,{size:10}),ye.createElement(Ik,{fullWidth:!0,disabled:!s,variant:"contained",placeholder:It.t("Enter token address"),size:"large",value:l,suffix:!!l&&k&&ye.createElement(bk,{color:"success",size:12}),onChange:D=>c(D.target.value)}),!k&&!!l&&ye.createElement(ye.Fragment,null,ye.createElement(xn,{size:4}),ye.createElement(vk,{type:"error",variant:"alarm",title:"Invalid Address"}))),ye.createElement(Ju,{id:"widget-add-custom-token-import-btn",disabled:T,type:"primary",variant:"contained",loading:f,size:"large",onClick:v},It.t("Import"))),ye.createElement(Z,{open:p,dismissible:!0,onClose:b,container:I()},ye.createElement(xk,{title:m?.title||C,type:"error",description:m?.message||It.t("Failed Network, Please retry.")},ye.createElement(xn,{size:40}),ye.createElement(xn,{size:10}),ye.createElement(Ju,{id:`widget-add-custom-token-${C?"retry":"add-another"}-btn`,variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:A},C?It.t("Retry"):It.t("Add another custom token")))),s&&d&&ye.createElement(Qa,{blockchain:s,token:d,onSubmitClick:()=>{d&&(n(d),h(void 0),o())},onClose:()=>h(void 0),open:!!s&&!!d})))}i(Ru,"AddCustomTokenPage");import{i18n as Us}from"@lingui/core";import{useManager as hv}from"@rango-dev/queue-manager-react";import{Alert as yv,Button as Sv,css as Qs,Divider as zs,IconButton as Km,styled as Cv,Typography as kv,WalletIcon as Tv}from"@rango-dev/ui";import Le,{useEffect as Si,useLayoutEffect as vv,useRef as wv,useState as Fn}from"react";import{useNavigate as bv}from"react-router-dom";import{i18n as ho}from"@lingui/core";import{Alert as rT,BalanceErrors as iT,Button as Id,ChevronLeftIcon as aT,Divider as Ss,MessageBox as sT,Typography as Cs}from"@rango-dev/ui";import ee,{useCallback as lT,useEffect as Ad,useMemo as cT,useState as Ko}from"react";import{useNavigate as pT}from"react-router-dom";import{i18n as fs}from"@lingui/core";import{Alert as Fk,ChevronDownIcon as Ok,CloseIcon as Uk,Divider as ad,IconButton as sd,PasteIcon as zk,Typography as Qk,WalletIcon as Hk}from"@rango-dev/ui";import Me,{useEffect as qk,useRef as Gk}from"react";import jr,{useRef as Dk}from"react";import*as Go from"@radix-ui/react-collapsible";import{keyframes as ed,styled as Gr}from"@rango-dev/ui";var us=300,Pk=ed({from:{height:0},to:{height:"var(--radix-collapsible-content-height)"}}),_k=ed({from:{height:"var(--radix-collapsible-content-height)"},to:{height:0}}),td=Gr(Go.Root,{borderRadius:"$sm",overflow:"hidden",variants:{selected:{true:{outlineWidth:1,outlineColor:"$secondary500",outlineStyle:"solid"}}}}),ds=Gr(Go.Trigger,{padding:"$0",border:"none",outline:"none",width:"100%",backgroundColor:"transparent",fontFamily:"inherit",cursor:"pointer"}),Vr=Gr(Go.Content,{overflow:"hidden",variants:{open:{true:{animation:`${Pk} ${us}ms ease-out`},false:{animation:`${_k} ${us}ms ease-out`}}}}),Kr=Gr("div",{transition:`all ${us}ms ease`,display:"flex",alignItems:"center",variants:{orientation:{down:{transform:"rotate(0)"},up:{transform:"rotate(180deg)"}}}});function Xr(t){let{open:e,hasSelected:o,onOpenChange:n,children:r,onClickTrigger:a,trigger:s,triggerAnchor:l}=t,c=Dk(null);return jr.createElement(td,{ref:c,className:"collapsible_root",selected:o&&e,open:e,onOpenChange:n},l==="top"&&jr.createElement(ds,{className:"collapsible_trigger",onClick:a},s),jr.createElement(Vr,{className:"collapsible_content",open:e},r),l==="bottom"&&jr.createElement(ds,{className:"collapsible_trigger",onClick:a},s))}i(Xr,"CustomCollapsible");import{darkTheme as od,styled as ms,TextField as $k}from"@rango-dev/ui";var nd=ms("div",{padding:"$10 $0","& .button__content":{display:"flex",alignItems:"center"},"& .alarms":{paddingTop:"$5"},"& .collapsible_content":{backgroundColor:"$neutral100"},"& .collapsible_root":{backgroundColor:"$neutral100"}}),rd=ms($k,{backgroundColor:"$neutral100",padding:"$15"}),id=ms("div",{width:"100%",borderRadius:"$sm",display:"flex",padding:"$15",justifyContent:"space-between",alignItems:"center",$$color:"$colors$neutral100",[`.${od} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",borderBottomRightRadius:"0",borderBottomLeftRadius:"0","&:focus-visible":{$$background:"$colors$secondary100",[`.${od} &`]:{$$background:"$colors$info700"},backgroundColor:"$$background",outline:0}});function ld(t){let{blockchain:e,handleOpenChange:o,open:n}=t,{customDestination:r,setCustomDestination:a}=O(),{config:s}=y(),l=y().blockchains(),c=sr(e.name,l),p=Gk(null),u=s?.defaultCustomDestinations?.[e.name],d=navigator?.userAgent.includes("Firefox"),g=n&&!!r&&e&&!Io(e,r),f=i(()=>{a("")},"handleClear"),m=i(async S=>{if(S.preventDefault(),navigator.clipboard!==void 0){let k=await navigator.clipboard.readText();a(k),p?.current?.focus()}},"handlePaste"),C=i(()=>r?Me.createElement(sd,{id:"widget-custom-destination-close-icon-btn",onClick:f,variant:"ghost"},Me.createElement(Uk,{size:12,color:"gray"})):d?null:Me.createElement(sd,{id:"widget-custom-destination-paste-icon-btn",onClick:m,variant:"ghost"},Me.createElement(zk,{size:16})),"renderSuffix");return qk(()=>{!!u&&r===null&&(a(u),o(!0))},[u]),Me.createElement(nd,null,Me.createElement(Xr,{onOpenChange:o,hasSelected:!0,open:n,triggerAnchor:"top",trigger:Me.createElement(id,null,Me.createElement("div",{className:"button__content"},Me.createElement(Hk,{size:18,color:"info"}),Me.createElement(ad,{size:4,direction:"horizontal"}),Me.createElement(Qk,{variant:"label",size:"medium",color:n?"$neutral600":void 0},fs.t("Send to a different address"))),Me.createElement(Kr,{orientation:n?"up":"down"},Me.createElement(Ok,{size:10,color:"secondary"}))),onClickTrigger:()=>o(!n)},Me.createElement(rd,{ref:p,style:{padding:0,paddingRight:r?"8px":"5px"},autoFocus:!r,placeholder:fs.t("Enter {blockchainName} address",{blockchainName:c}),value:r||"",suffix:C(),onChange:S=>{let k=S.target.value;a(k)}})),g&&Me.createElement(Me.Fragment,null,Me.createElement(ad,{size:4}),Me.createElement(Fk,{variant:"alarm",type:"error",title:fs.t({values:{destination:r},id:"Address {destination} doesn't match the blockchain address pattern."})})))}i(ld,"CustomDestination");import{css as Vk,darkTheme as gs,IconButton as Kk,styled as Dt}from"@rango-dev/ui";var cd=Dt("div",{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center"}),pd=Dt("div",{display:"flex",justifyContent:"space-evenly",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5",height:"100%"}),jk=Dt("button",{borderRadius:"$xm",padding:"$10",border:"0",display:"flex",justifyContent:"center",$$color:"$colors$neutral100",[`.${gs} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",alignItems:"center",cursor:"pointer",width:110,position:"relative","&:hover":{$$color:"$colors$secondary100",[`.${gs} &`]:{$$color:"$colors$neutral100"},backgroundColor:"$$color"},"&:focus-visible":{$$color:"$colors$secondary100",[`.${gs} &`]:{$$color:"$colors$info700"},backgroundColor:"$$color",outline:0},variants:{selected:{true:{outlineWidth:1,outlineColor:"$secondary",outlineStyle:"solid"}}}}),ud=Dt(jk,{alignSelf:"stretch",minHeight:"93px"}),dd=Dt("div",{padding:"$20 $20 $15 $20",display:"flex",justifyContent:"center",alignItems:"center",backgroundColor:"$neutral200",position:"relative",width:"100%"}),md=Dt(Kk,{position:"absolute",left:"$20"}),fd=Dt("div",{paddingTop:"$20"}),gd=Vk({display:"flex",justifyContent:"space-evenly",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5",height:"100%"}),hd=Dt("div",{display:"flex"}),yd=Dt("div",{overflow:"visible",width:"100%"});import{i18n as wd}from"@lingui/core";import{warn as Rk}from"@rango-dev/logging-core";import{Divider as eT,SelectableWallet as tT,Typography as bd,WalletState as xd}from"@rango-dev/ui";import Xe,{useEffect as Ed,useState as In}from"react";import{Image as Zk,MessageBox as Jk}from"@rango-dev/ui";import En from"react";import{keyframes as Xk,styled as hs}from"@rango-dev/ui";var Sd=hs("div",{position:"relative"}),Yk=Xk({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}),Cd=hs("div",{position:"absolute",border:"2px solid rgba(0, 0, 0, 0.1)",borderTop:"2px solid $info500",borderRadius:"$lg",width:"$45",height:"$45",animation:`${Yk} 1s linear infinite`,top:0,bottom:0,right:0,left:0}),kd=hs("div",{"& img":{borderRadius:"50%"}});import{i18n as Vo}from"@lingui/core";function Td(t,e){switch(t){case"in-progress":return{type:"loading",title:Vo.t({id:"Add {blockchainDisplayName} Chain",values:{blockchainDisplayName:e}}),description:Vo.t({id:"Please approve the experimental chain pop-up in your wallet.",values:{blockchainDisplayName:e}})};case"completed":return{type:"success",title:Vo.t({id:"{blockchainDisplayName} Chain Added",values:{blockchainDisplayName:e}}),description:Vo.t({id:"The {blockchainDisplayName} chain has been successfully added to your wallet.",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(Td,"generateMessageByStatus");function vd(t){let{status:e,displayName:o,image:n}=t,r=Td(e,o),a=e=="in-progress";return En.createElement(Jk,{type:r.type,title:r.title,description:r.description,icon:a?En.createElement(Sd,null,En.createElement(kd,null,En.createElement(Zk,{src:n,size:45})),En.createElement(Cd,null)):void 0})}i(vd,"ExperimentalChainStatus");var oT=7,nT=3e3;function ys(t){let{chain:e,isSelected:o,selectWallet:n,limit:r,onShowMore:a}=t,s=re.use.isActiveTab(),{blockchains:l,connectedWallets:c}=y(),[p,u]=In(),[d,h]=In(null),[g,f]=In(!1),[m,C]=In(null),{suggestAndConnect:S}=Yr(),{handleDisconnect:k}=Gt(),{list:T}=ft({chain:e}),[v,b]=In(T),A=T.length,D=r&&A-r>0,w=i(async E=>{f(!1),C("in-progress");try{await S(E.walletType,E.chain),C("completed")}catch{C("rejected")}},"addExperimentalChain");Ed(()=>{b(E=>{let N=T.findIndex(M=>o(M.type,e));return D&&N>1?[T[N]].concat(T.filter((M,W)=>W!==N)):E.map(M=>T.find(W=>W.type===M.type)??M)})},[JSON.stringify(T)]);let x=document.getElementById(De.SWAP_BOX_ID);return Ed(()=>{let E=null;return(m==="completed"||m==="rejected")&&(E=setTimeout(()=>C(null),nT)),()=>{E&&clearTimeout(E)}},[m]),Xe.createElement(Xe.Fragment,null,v.slice(0,r).map(E=>{let N=Oc({connectedWallets:c,walletType:E.type,chain:e}),M=N?Sr(N,oT):"",W=hr(l(),e),j=!c.find(se=>se.walletType===E.type&&se.chain===e),te=W&&j&&E.state===xd.CONNECTED,J=te?wd.t({id:"Add {chain} chain",values:{chain:e}}):M,L=i(async()=>{let se=E.state===xd.DISCONNECTED,z=(E.isHub||!!E.needsNamespace)&&!M;se?u(E):z?(await k(E.type),u(E)):te?(h({walletType:E.type,chain:e,address:N??""}),f(!0)):n({walletType:E.type,chain:e,address:N??""})},"onSelectableWalletClick"),X=d?.chain?sr(d.chain,l()):void 0;return Xe.createElement(Xe.Fragment,{key:`${E.title}_${X}`},!!d&&Xe.createElement(Z,{open:!!d&&g,container:x,onClose:()=>{h(null)}},Xe.createElement(xa,{displayName:X,onConfirm:()=>{w(d)}})),m&&Xe.createElement(Z,{open:!!m,onClose:C.bind(null,null),container:x},Xe.createElement(vd,{status:m,displayName:X,image:E.image}),Xe.createElement(eT,{direction:"vertical",size:32})),Xe.createElement(tT,{key:E.type,description:J,onClick:L,selected:o(E.type,e),disabled:!s,...E}))}),Xe.createElement(po,{wallet:p,onClose:()=>{u(void 0)},onConnect:()=>{t.onConnect&&(p?.type?t.onConnect(p.type):Rk(new Error("The selected wallet hasn't been detected after the connection process finished. It usually shouldn't happen.")))}}),D&&Xe.createElement(ud,{selected:!1,onClick:a},Xe.createElement(bd,{variant:"label",size:"medium"},wd.t("Show more wallets"),Xe.createElement(bd,{variant:"label",size:"medium",color:"$primary"},"\xA0+",A-(r??0)))))}i(ys,"WalletList");var uT=2;function Nd(t){let{open:e,onClose:o,onCancel:n,onCheckBalance:r,loading:a}=t,s=pT(),l=y().blockchains(),{selectedQuote:c,setSelectedWallets:p,quoteWalletsConfirmed:u,setQuoteWalletConfirmed:d,customDestination:h,setCustomDestination:g}=O(),{config:f,connectedWallets:m,setWalletsAsSelected:C}=y(),[S,k]=Ko(""),[T,v]=Ko([]),[b,A]=Ko(""),[D,w]=Ko(!!h),x=cT(()=>io({filter:"all",quote:c}),[c]),E=io({filter:"required",quote:c}),N=l.find(P=>P.name===c?.swaps[c?.swaps.length-1].to.blockchain),M=i(P=>E.includes(P),"isWalletRequiredFor"),W=lT(()=>m.filter(P=>P.selected&&x.includes(P.chain)),[m,x]),[j,te]=Ko(W()),[J,L]=Ko([]),X=i((P,q)=>L(V=>V.concat({blockchain:P,walletType:q})),"addNextSelectedWallets"),se=T.length>0,z=i((P,q)=>!!j.find(V=>V.walletType===P&&V.chain===q&&V.selected&&(M(q)||!M(q)&&!h)),"isSelected"),me=i((P,q,V)=>{let fe=!1;return P.map(ne=>{if(ne.chain===q){let ge=ne.selected;return!fe&&V?(fe=!0,ge=!0):V||(ge=!1),{...ne,selected:ge}}return ne})},"updateSelectableWallets"),vt=i(P=>{w(P),P?M(N?.name??"")||te(q=>me(q,N?.name||"",!1)):(g(""),te(q=>me(q,N?.name||"",!0)))},"handleCustomDestinationCollapsibleOpenChange"),Ze=i(P=>{if(S&&k(""),z(P.walletType,P.chain))return;let V=m.find(fe=>fe.walletType===P.walletType&&fe.chain===P.chain);V&&(n(),P.chain===N?.name&&D&&!M(N.name)&&(w(!1),g(null)),te(fe=>fe.filter(ne=>ne.chain!==P.chain).concat({...V,selected:!0})))},"onChange"),le=i(()=>{let P=j.filter(q=>q.selected);C(P),p(P),d(!0),o()},"onConfirmBalance"),at=i(async()=>{v([]),A("");let P=await r?.({selectedWallets:j.filter(V=>V.selected),customDestination:h}),q=P.warnings;q?.balance?.messages&&v(q.balance.messages),P.error&&A(Up(P.error)),!P.error&&!q?.balance?.messages.length?le():v(q?.balance?.messages??[])},"onConfirmWallets");Ad(()=>{te(P=>{let q=[];return P.forEach(V=>{!m.some(ne=>ne.chain===V.chain&&ne.walletType===V.walletType&&ne.address===V.address)||q.push(V)}),q=q.concat(m.filter(V=>!!!q.find(ne=>ne.chain===V.chain)&&V.selected&&x.includes(V.chain))),q})},[m,x]),Ad(()=>{let P=[];J.length>0&&(J.forEach(q=>{let V=m.find(fe=>fe.chain===q.blockchain&&fe.walletType===q.walletType);V?Ze(V):P.push(q)}),L(P))},[m,J]);let G=document.getElementById(De.SWAP_BOX_ID);return ee.createElement(Z,{open:e,onClose:()=>{u||s("../",{replace:!0}),o()},dismissible:!S,container:G,...!S&&{styles:{container:{height:"100%"}},footer:ee.createElement(hd,null,ee.createElement(Id,{id:"widget-confirm-wallet-modal-confirm-btn",loading:a,disabled:gu(a,D,h,c,j,N),onClick:at,variant:"contained",type:"primary",fullWidth:!0,size:"large"},ho.t("Confirm")))},...S&&{styles:{container:{height:"100%",padding:"$0"}},header:ee.createElement(dd,null,ee.createElement(md,{id:"widget-confirm-wallet-modal-navigate-back-icon-btn",variant:"ghost",onClick:k.bind(null,"")},ee.createElement(aT,{size:16})),ee.createElement(Cs,{variant:"headline",size:"small"},ho.t({id:"Your {blockchainName} wallets",values:{blockchainName:st(S,l)}})))},anchor:"center"},ee.createElement(Z,{open:se,onClose:v.bind(null,[]),container:G},ee.createElement(sT,{title:ho.t("Insufficient account balance"),type:"error",description:ee.createElement(iT,{messages:T??[]})},ee.createElement(Id,{id:"widget-confirm-wallet-modal-proceed-anyway-btn",variant:"outlined",size:"large",type:"primary",fullWidth:!0,onClick:le},ho.t("Proceed anyway")))),S&&ee.createElement(fd,null,ee.createElement("div",{className:gd()},ee.createElement(ys,{chain:S,isSelected:z,selectWallet:Ze,onShowMore:()=>k(S),onConnect:P=>{X(S,P)}}))),!S&&ee.createElement(ee.Fragment,null,b&&ee.createElement(ee.Fragment,null,ee.createElement(rT,{variant:"alarm",type:"error",title:ho.t(b)}),ee.createElement(Ss,{size:12})),ee.createElement(yd,null,x.map((P,q)=>{let V=l.find(Fe=>Fe.name===P),fe=`wallet-${q}`,ne=q===x.length-1,ge=ne&&N&&f?.customDestination!==!1;return ee.createElement("div",{key:fe},ee.createElement(cd,null,ee.createElement(Cs,{variant:"title",size:"xmedium"},ho.t({id:"Your {blockchainName} wallets",values:{blockchainName:V?.shortName}})),ee.createElement(Cs,{variant:"label",color:"$neutral700",size:"medium"},ho.t({id:"You need to connect a {blockchainName} wallet.",values:{blockchainName:V?.shortName}}))),ee.createElement(Ss,{size:24}),ee.createElement(pd,null,ee.createElement(ys,{chain:P,isSelected:z,selectWallet:Ze,limit:uT,onShowMore:()=>k(V?.name??""),onConnect:Fe=>{X(P,Fe)}})),!ne&&ee.createElement(Ss,{size:32}),ge&&ee.createElement(ld,{blockchain:N,open:D,handleOpenChange:vt}))}))))}i(Nd,"ConfirmWalletsModal");import{i18n as WT}from"@lingui/core";import{Alert as BT,Button as MT,InfoIcon as LT}from"@rango-dev/ui";import et from"react";import{Alert as fT,Button as gT,Divider as vs,NoRouteIcon as hT,RefreshIcon as yT,Typography as Dd}from"@rango-dev/ui";import Re from"react";import{i18n as Wd}from"@lingui/core";var dT=24,mT=60;function Bd(t,e,o,n){return t?.type===1?{alert:{type:"warning",text:R().genericServerError,action:{onClick:n,title:Wd.t("Retry")}},description:""}:e.length?{alert:{type:"warning",text:R().liquiditySourcesError.title,action:{onClick:()=>o(!0),title:Wd.t("Reset")}},description:R().liquiditySourcesError.description}:t?.type===0&&t.diagnosisMessage?{alert:{type:"error",text:t.diagnosisMessage,action:null},description:""}:{alert:null,description:R().noResultError.description}}i(Bd,"makeInfo");var ks=(o=>(o[o.small=dT]="small",o[o.large=mT]="large",o))(ks||{}),Ts=(o=>(o.small="small",o.large="medium",o))(Ts||{});import{styled as Zr}from"@rango-dev/ui";var Md=Zr("div",{display:"flex",flexDirection:"column",alignItems:"center"}),Ld=Zr("div",{variants:{size:{small:{},large:{maxWidth:"316px"}}}}),Pd=Zr("div",{variants:{size:{small:{width:"100%"},large:{}}}}),_d=Zr("div",{padding:"$6 $0"});function An(t){let{fetch:e,error:o,size:n="small"}=t,r=y().getDisabledLiquiditySources(),a=y().toggleAllLiquiditySources,s=y().swappers(),l=Bd(o,r,()=>a(s,!0),e);return Re.createElement(Md,null,Re.createElement(hT,{size:ks[n],color:"gray"}),Re.createElement(vs,{size:4}),Re.createElement(Dd,{variant:"title",size:Ts[n]},R().noResultError.title),n==="large"&&Re.createElement(vs,{size:4}),!!l.description&&Re.createElement(Ld,{size:n},Re.createElement(Dd,{variant:"body",size:"small",align:"center",color:"neutral700"},l.description)),Re.createElement(vs,{size:n==="large"?"24":"4"}),!!l.alert&&Re.createElement(Pd,{size:n},Re.createElement(fT,{type:l.alert.type,title:l.alert.text,titleAlign:"left",action:l.alert.action&&Re.createElement(gT,{size:"xsmall",id:"widget-no-result-alert-btn",type:l.alert.type,prefix:Re.createElement(_d,null,Re.createElement(yT,{size:8})),onClick:l.alert.action.onClick},l.alert.action.title),variant:"alarm"})))}i(An,"NoResult");import{i18n as Nn}from"@lingui/core";import{Button as CT,Divider as kT,MessageBox as TT,Typography as vT,WarningIcon as wT}from"@rango-dev/ui";import $t from"react";import{Typography as Ud}from"@rango-dev/ui";import bs from"react";import{darkTheme as ST,styled as Jr}from"@rango-dev/ui";var $d=Jr("div",{width:"100%"}),ws=Jr("div",{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"$5",width:"100%"}),Fd=Jr("div",{display:"flex",padding:"$5 0",justifyContent:"space-between",alignItems:"center",width:"100%","._title":{$$color:"$colors$neutral600",[`.${ST} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),Od=Jr("div",{padding:"$2",alignSelf:"flex-start",cursor:"pointer"});function zd(t){let{title:e,value:o,valueColor:n}=t;return bs.createElement(Fd,null,bs.createElement(Ud,{size:"medium",variant:"label",className:"_title"},e),bs.createElement(Ud,{size:"large",variant:"label",color:n||"foreground"},`${n?"%":"$"}${o}`))}i(zd,"QuoteErrorsModalItem");function Qd(t){let{open:e,onClose:o,onConfirm:n,warning:r,confirmationDisabled:a}=t,s=r.warningLevel==="high"?"error":"warning",l=[{title:Nn.t("Swapping"),value:B(r.inputUsdValue,4,4)},{title:Nn.t("Gas cost"),value:B(r.totalFee,2,2)},{title:Nn.t("Receiving"),value:B(r.outputUsdValue,4,4)},{title:Nn.t("Price impact"),value:B(r.priceImpact,2,2),valueColor:`${s}500`}];return $t.createElement(Z,{footer:$t.createElement(CT,{id:"widget-high-value-loss-warning-modal-confirm-btn",type:"primary",size:"large",prefix:$t.createElement(wT,null),fullWidth:!0,disabled:a,onClick:n},R().highValueLossError.confirmMessage),open:e,onClose:o,container:I()},$t.createElement(TT,{type:s,title:R().highValueLossError.impactTitle,description:R().highValueLossError.description}),$t.createElement(ws,null,$t.createElement(kT,{size:"4"}),$t.createElement(vT,{size:"small",variant:"title"},Nn.t("Details")),$t.createElement(ws,null,l.map((c,p)=>$t.createElement(zd,{key:p,...c})))))}i(Qd,"HighValueLossWarningModal");import{i18n as Rr}from"@lingui/core";function Hd(t,e){let o={alertType:"warning",title:"",action:null};if(e)return o.alertType="error",e.type===3&&(o.title=e.recommendation),e.type===4&&(o.title=Rr.t({id:"You need to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:e.minRequiredSlippage}}),o.action="change-settings"),o;if(t){switch(t.type){case 0:{_t(t.priceImpact)==="high"&&(o.alertType="error"),o.action="show-info",o.title=R().highValueLossError.title;break}case 4:{o.title=Rr.t({id:"Output amount changed by {percentageChange}% (${usdValueChange}).",values:{percentageChange:t.percentageChange,usdValueChange:t.usdValueChange}});break}case 1:{o.title=R().unknownPriceError.title;break}case 2:{o.title=Rr.t({id:"We recommend you to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:t.minRequiredSlippage}}),o.action="change-settings";break}case 3:{o.title=Rr.t("Caution, your slippage is high."),o.action="change-settings";break}default:break}return o}return null}i(Hd,"makeAlerts");import{i18n as jo}from"@lingui/core";import{Button as qd,Divider as Gd,MessageBox as bT,Typography as xT}from"@rango-dev/ui";import yo from"react";import{useNavigate as ET}from"react-router-dom";function Vd(t){let{customSlippage:e,slippage:o}=y(),{open:n,onClose:r,onConfirm:a,warning:s,confirmationDisabled:l}=t,c=ET(),p=e??o;return yo.createElement(Z,{anchor:"bottom",open:n,prefix:yo.createElement(qd,{size:"small",id:"widget-slippage-warning-modal-change-settings-btn",variant:"ghost",onClick:()=>c("../"+$.settings)},yo.createElement(xT,{variant:"label",size:"medium",color:"$neutral900"},jo.t("Change settings"))),container:I(),onClose:r},yo.createElement(bT,{type:"warning",title:s.type===3?jo.t("High slippage"):jo.t("Low slippage"),description:s.type===3?jo.t({id:" Caution, your slippage is high (={userSlippage}). Your trade may be front run.",values:{userSlippage:p}}):jo.t({id:"We recommend you to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:s.minRequiredSlippage}})},yo.createElement(Gd,{size:18}),yo.createElement(Gd,{size:32}),yo.createElement(qd,{id:"widget-slippage-warning-modal-confirm-anyway-btn",size:"large",type:"primary",variant:"contained",fullWidth:!0,disabled:l,onClick:a},jo.t("Confirm anyway"))))}i(Vd,"SlippageWarningModal");import{Button as IT,MessageBox as AT,WarningIcon as NT}from"@rango-dev/ui";import ei from"react";function Kd(t){let{open:e,onClose:o,onConfirm:n,confirmationDisabled:r}=t;return ei.createElement(Z,{footer:ei.createElement(IT,{id:"widget-unknown-price-warning-modal-confirm-btn",type:"primary",size:"large",prefix:ei.createElement(NT,null),fullWidth:!0,disabled:r,onClick:n},R().unknownPriceError.confirmMessage),open:e,onClose:o,container:I()},ei.createElement(AT,{type:"warning",title:R().unknownPriceError.impactTitle,description:R().unknownPriceError.description}))}i(Kd,"UnknownPriceWarningModal");function Wn(t){let{warning:e,error:o,couldChangeSettings:n,showWarningModal:r,confirmationDisabled:a,refetchQuote:s,onOpenWarningModal:l,onCloseWarningModal:c,onConfirmWarningModal:p,onChangeSettings:u}=t,d={confirmationDisabled:a,open:r,onClose:c,onConfirm:p},h=o?.type===0||o?.type===1,g=Hd(e,o?.type===3||o?.type===4?o:null);return g&&!n&&(g.action=null),et.createElement(et.Fragment,null,h&&et.createElement(An,{error:o,fetch:s}),!!g&&et.createElement($d,null,et.createElement(BT,{title:g.title,type:g.alertType,variant:"alarm",...g.action==="show-info"&&{action:et.createElement(Od,{onClick:l},et.createElement(LT,{size:12,color:"gray"}))},...g.action==="change-settings"&&{action:et.createElement(MT,{id:"widget-quote-warning-error-change-settings-btn",size:"xxsmall",type:g.alertType,onClick:u},WT.t("Change"))}})),e&&et.createElement(et.Fragment,null,e.type===0&&et.createElement(Qd,{...d,warning:e}),(e.type===3||e.type===2)&&et.createElement(Vd,{...d,warning:e}),e.type===1&&et.createElement(Kd,{...d,warning:e})))}i(Wn,"QuoteWarningsAndErrors");import pv from"bignumber.js";import fi from"react";import{i18n as So}from"@lingui/core";import{Alert as ZT,Divider as Yo,FullExpandedQuote as JT,InfoIcon as RT,NumericTooltip as xm,QuoteTag as ev,StepDetails as tv,TokenAmount as ov,Typography as Zo}from"@rango-dev/ui";import Ls from"bignumber.js";import F,{useRef as nv,useState as rv}from"react";import{styled as xs}from"@rango-dev/ui";var Es=xs("div",{width:"100%","& .position-top__skeleton":{paddingTop:"$10"}}),jd=xs("div",{paddingBottom:"$15",variants:{dense:{true:{paddingBottom:0}}}}),Xd=xs("div",{width:"100%",display:"flex"});import*as ti from"@radix-ui/react-collapsible";import{Button as PT,css as Bn,darkTheme as xe,Image as Yd,styled as ze,Typography as _T}from"@rango-dev/ui";var DT=300,Zd=ze(ti.Root,{display:"flex",flexDirection:"column",alignItems:"start",overflowX:"auto",overflowY:"hidden",width:"100%",borderRadius:"$xm",variants:{selected:{true:{},false:{$$color:"$colors$neutral400",[`.${xe} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"}},listItem:{true:{$$color:"$colors$neutral400",[`.${xe} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"},false:{}}},compoundVariants:[{listItem:!1,selected:!0,css:{$$color:"$colors$secondary200",[`.${xe} &`]:{$$color:"$colors$secondary800"},backgroundColor:"$$color"}}]}),Jd=Bn({padding:"$10 $15"}),Rd=ze(PT,{backgroundColor:"transparent",border:"1px solid $secondary550",[`.${xe} &`]:{border:"1px solid $secondary"},transition:"background-color 0.3s ease","&:hover":{backgroundColor:"$secondary550",[`.${xe} &`]:{backgroundColor:"$secondary"},".allRoutesLabel":{$$color:"$colors$background",[`.${xe} &`]:{$$color:"$colors$foreground"},color:"$$color",transition:"color 0.3s ease"}}}),em=ze("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",[`.${xe} &`]:{$$color:"$colors$neutral500"},backgroundColor:"$$color"}},basic:{true:{borderTopRightRadius:"0",borderTopLeftRadius:"0"}},listItem:{true:{$$color:"$colors$neutral200",[`.${xe} &`]:{$$color:"$colors$neutral500"},backgroundColor:"$$color","&:hover":{"& .quote_container":{"& button":{backgroundColor:"$neutral500",[`.${xe} &`]:{backgroundColor:"$neutral200"}},backgroundColor:"$neutral500",[`.${xe} &`]:{backgroundColor:"$neutral200"}},backgroundColor:"$neutral300",[`.${xe} &`]:{backgroundColor:"$neutral400"}},cursor:"pointer"},false:{}}},compoundVariants:[{listItem:!0,selected:!0,css:{outline:"1px solid $secondary"}},{listItem:!1,selected:!0,css:{$$color:"$colors$secondary100",[`.${xe} &`]:{$$color:"$colors$secondary550"},backgroundColor:"$$color","&:hover":{backgroundColor:"$$color"}}},{listItem:!0,selected:!1,css:{cursor:"pointer","&:hover":{backgroundColor:"$neutral300",[`.${xe} &`]:{backgroundColor:"$neutral400"}}}}]}),tm=Bn({width:"100%",padding:"$15 $15 $10 $15"}),om=Bn({display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingBottom:"$10",position:"relative"}),Xo=Bn({display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",".blockchainImage":{marginLeft:"-$8"}}),nm=Bn({display:"flex",alignItems:"center",".usd-value":{$$color:"$colors$neutral600",[`.${xe} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),rm=ze(ti.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:{[`& ${Yd}`]:{border:"1px $warning500 solid",borderRadius:"100%"}},false:{[`& ${Yd}`]:{border:"1px transparent solid",borderRadius:"100%"}}},selected:{true:{},false:{$$color:"$colors$neutral400",[`.${xe} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"}},listItem:{true:{$$color:"$colors$neutral400",[`.${xe} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"},false:{}}},compoundVariants:[{listItem:!1,selected:!0,css:{$$color:"$colors$secondary200",[`.${xe} &`]:{$$color:"$colors$secondary800"},backgroundColor:"$$color"}}],".blockchains_section":{display:"none"},"@xs":{".blockchains_section":{display:"block"}}}),im=ze("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"}}}}),am=ze(Vr,{width:"100%",background:"inherit"}),Is=ze("div",{display:"flex",justifyContent:"center",alignItems:"center",padding:"$2",transition:`all ${DT}ms ease`,variants:{orientation:{down:{transform:"rotate(0)"},up:{transform:"rotate(180deg)"}}}}),o1=ze("div",{height:"$12",marginLeft:"$10",marginRight:"$10",borderLeft:"1px solid $foreground"}),sm=ze("div",{display:"flex",justifyContent:"center",margin:"0 $15",borderTop:"1px solid",$$color:"$colors$neutral300",[`.${xe} &`]:{$$color:"$colors$neutral400"},borderColor:"$$color"}),lm=ze("div",{width:"$16",height:"$16",justifyContent:"center",alignItems:"center",display:"flex"}),As=ze(_T,{overflow:"hidden",textOverflow:"ellipsis",letterSpacing:.4}),cm=ze("div",{display:"flex",flexWrap:"wrap"}),Ns=ze("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"}}}}),pm=ze("div",{display:"flex"}),oi=ze("div",{width:"100%",borderTopWidth:"1px",borderTopStyle:"solid",borderTopColor:"$neutral",margin:"$5 0",[`.${xe} &`]:{borderTopColor:"$neutral800"}});import{i18n as At}from"@lingui/core";import{ChevronDownIcon as FT,CloseIcon as OT,Divider as ii,IconButton as UT,NumericTooltip as zT,QuoteCost as QT,Typography as yt}from"@rango-dev/ui";import Y,{useState as fm}from"react";import{css as $T,styled as ni}from"@rango-dev/ui";var ri=ni("div",{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"$5 0","&.total_payable_fee":{padding:"$12 0"}}),Ws=ni("div",{width:"100%",borderTop:"1px solid $neutral300",margin:"$10 0"}),um=ni("div",{padding:"$20 0",display:"flex",flexDirection:"column","& .collapsible_trigger":{display:"flex",alignItems:"center"}}),dm=ni("div",{padding:"$20 $20 $10",position:"relative","._icon-button":{position:"absolute",zIndex:10,top:"$16",right:"$16"}}),mm=$T({display:"flex",flexDirection:"row",alignItems:"center",padding:"$5","&:hover":{"& ._typography, & svg":{color:"$secondary"}}});var HT=i(t=>t.fee.isZero()?null:Y.createElement(ri,null,Y.createElement(yt,{variant:"label",size:"medium",color:"neutral600"},t.label),Y.createElement(yt,{variant:"label",size:"medium"},"$",B(t.fee,4,4))),"NonPayableFee");function Bs(t){let[e,o]=fm(!1),[n,r]=fm(!1),{steps:a,quote:s,fee:l,time:c,feeWarning:p,timeWarning:u,showModalFee:d,fullExpandedMode:h=!1}=t,g=s?.swaps??[],f=h?ro():I(),m=su(g);return Y.createElement(Y.Fragment,null,Y.createElement(QT,{onClickFee:d?C=>{C.stopPropagation(),o(!e)}:void 0,fee:l,feeWarning:p,timeWarning:u,time:c,steps:a,tooltipGas:d?At.t("View more info"):void 0,tooltipContainer:f}),Y.createElement(Z,{container:f,open:e,anchor:h?"center":"bottom",styles:{container:{maxWidth:h?"484px":"unset"}},header:Y.createElement(dm,{style:{textAlign:h?"left":"center"}},Y.createElement(yt,{variant:"title",size:"medium"},At.t("Gas & Fee Explanation")),Y.createElement(UT,{id:"widget-quote-cost-details-modal-close-icon-btn",onClick:()=>o(!1),variant:"ghost"},Y.createElement(OT,{color:"gray",size:14}))),onClose:()=>{o(!1)}},Y.createElement(um,null,Y.createElement(yt,{variant:"title",size:"small"},At.t("Details")),Y.createElement(ii,{size:10}),Object.entries(m.payable).flatMap(([C,S])=>S.map((k,T)=>{let v=`payable-fee-${T}`,b=Ma(k);return Y.createElement(ri,{key:v},Y.createElement(yt,{variant:"label",size:"medium",color:"neutral600"},Ia(C,At.t)),Y.createElement(zT,{content:k.amount,container:f},Y.createElement(yt,{variant:"label",size:"medium"},B(k.amount,2,2)," ",k.asset.symbol," ($",B(b,4,4),")")))})),Y.createElement(ri,{className:"total_payable_fee"},Y.createElement(yt,{variant:"label",size:"medium"},At.t("Total Payable Fee")),Y.createElement(yt,{variant:"label",size:"medium"},"$",B(l,4,4))),Y.createElement(Ws,null),Object.keys(m.nonePayable).length&&Y.createElement(Xr,{triggerAnchor:"bottom",onClickTrigger:()=>r(C=>!C),trigger:Y.createElement("div",{className:mm()},Y.createElement(yt,{size:"small",variant:"body",color:"neutral700"},n?At.t("Hide non-payable fees"):At.t("Show non-payable fees")),Y.createElement(ii,{size:4,direction:"horizontal"}),Y.createElement(Kr,{orientation:n?"up":"down"},Y.createElement(FT,{size:12,color:"gray"}))),open:n},Y.createElement(yt,{size:"small",variant:"title"},At.t("Description")),Y.createElement(ii,{size:4}),Y.createElement(yt,{size:"small",variant:"body",color:"neutral700"},At.t(`The following fees are considered in the transaction output and
2
+ you won\u2019t need to pay extra gas for them.`)),Y.createElement(ii,{size:10}),Object.entries(m.nonePayable).map(([C,S],k)=>{let T=au(S),v=Ia(C,At.t),b=`non-payable-fee-${k}`;return Y.createElement(HT,{key:b,fee:T,label:v})}),Y.createElement(Ws,null)))))}i(Bs,"QuoteCostDetails");import{i18n as ym}from"@lingui/core";import{TokenAmount as Sm}from"@rango-dev/ui";import ai from"react";import{css as qT,styled as GT}from"@rango-dev/ui";var gm=GT("div",{position:"relative",display:"flex",flexDirection:"column",width:"100%"}),hm=qT({height:"14px",marginLeft:"14px",position:"absolute",borderLeft:"1px solid $foreground",top:"42%"});function Mn(t){let{from:e,to:o,percentageChange:n,warningLevel:r}=t;return ai.createElement(gm,null,ai.createElement(Sm,{direction:"horizontal",label:ym.t("Swap input"),type:"input",tooltipContainer:I(),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}}),ai.createElement("div",{className:hm()}),ai.createElement(Sm,{direction:"horizontal",tooltipContainer:I(),label:ym.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(Mn,"QuoteSummary");import{i18n as wm}from"@lingui/core";import{ChevronDownIcon as jT,ChevronRightIcon as XT,Divider as Ms,Image as YT,Tooltip as ui,Typography as li}from"@rango-dev/ui";import U from"react";import{useLayoutEffect as VT,useState as Ln}from"react";var Cm=480,km=768,Tm=1024,vm=1200,KT=i(()=>{let[t,e]=Ln(!1),[o,n]=Ln(!1),[r,a]=Ln(!1),[s,l]=Ln(!1),[c,p]=Ln(!1),u=i(()=>{e(window.innerWidth<=Cm),n(window.innerWidth>Cm&&window.innerWidth<=km),a(window.innerWidth>km&&window.innerWidth<=Tm),l(window.innerWidth>Tm&&window.innerWidth<=vm),p(window.innerWidth>vm)},"handleResize");return VT(()=>(u(),window.addEventListener("resize",u),()=>window.removeEventListener("resize",u)),[]),{isMobile:t,isTablet:o,isNotebook:r,isLargeScreen:s,isExtraLargeScreen:c}},"useScreenDetect"),si=KT;var ci=4,pi=6,Pn=i(t=>{let{content:e,src:o,className:n,open:r,state:a,container:s}=t,l=s||I();return U.createElement(ui,{container:l,side:"bottom",sideOffset:4,open:r,content:e},U.createElement(im,{className:n,state:a},U.createElement(YT,{src:o,size:16})))},"ImageComponent");function bm(t){let{quoteRef:e,selected:o,setExpanded:n,steps:r,expanded:a,type:s,container:l}=t,c=l||I(),p=r.length,u=Yp(r),{isTablet:d,isMobile:h}=si();return U.createElement(rm,{listItem:s==="list-item",ref:g=>e.current=g,selected:o,onClick:g=>{g.stopPropagation(),n(f=>!f)}},U.createElement("div",{className:Xo()},U.createElement(li,{variant:"body",size:"xsmall"},wm.t("Via:")),U.createElement(Ms,{direction:"horizontal",size:4}),r.map((g,f)=>{let m=`item-${f}`,C=U.createElement(Is,null,U.createElement(XT,{size:12,color:"black"}));return h||d?U.createElement(U.Fragment,{key:m},U.createElement(Pn,{content:g.swapper.displayName,src:g.swapper.image,state:g.state,container:l}),f!==p-1&&U.createElement(U.Fragment,null,C)):U.createElement(U.Fragment,{key:m},p<=ci||p>ci&&f<ci-1?U.createElement(U.Fragment,null,U.createElement(Pn,{content:g.swapper.displayName,src:g.swapper.image,state:g.state,container:l}),f!==p-1&&U.createElement(U.Fragment,null,C)):f===ci-1&&U.createElement(ui,{container:c,side:"bottom",align:"end",sideOffset:4,content:U.createElement("div",{className:Xo()},C,r.map((S,k)=>{let T=`image-${k}`;return k>=f&&U.createElement(U.Fragment,{key:T},U.createElement(Pn,{content:S.swapper.displayName,src:S.swapper.image,state:S.state,open:!1}),k!==p-1&&U.createElement(U.Fragment,null,C))}))},U.createElement(Ns,{state:r.find((S,k)=>k>=f&&(S.state==="error"||S.state==="warning"))?.state},U.createElement(li,{size:"xsmall",variant:"body"},"+",p-f))))})),U.createElement("div",{className:Xo()},U.createElement("div",{className:"blockchains_section"},U.createElement("div",{className:Xo()},U.createElement(li,{variant:"body",size:"xsmall"},wm.t("Chains:")),U.createElement(Ms,{direction:"horizontal",size:4}),u.map((g,f)=>U.createElement(U.Fragment,{key:g.displayName},u.length<=pi||u.length>pi&&f<pi-1?U.createElement(ui,{container:c,side:"bottom",content:g.displayName,sideOffset:4},U.createElement(Pn,{content:"",src:g.image,open:!1,className:f!==0?"blockchainImage":""})):f===pi-1&&U.createElement(ui,{container:c,side:"bottom",align:"end",sideOffset:4,content:U.createElement("div",{className:Xo()},u.map((m,C)=>C>=f&&U.createElement(Pn,{key:m.displayName,content:"",src:m.image,open:!1,className:C>f?"blockchainImage":"",container:l})))},U.createElement(Ns,{className:"blockchainImage"},U.createElement(li,{size:"xsmall",variant:"body"},"+",u.length-f))))),U.createElement(Ms,{direction:"horizontal",size:32}))),U.createElement(Is,{orientation:a?"up":"down"},U.createElement(jT,{size:12,color:"black"}))))}i(bm,"QuoteTrigger");function Ps(t){let{quote:e,input:o,output:n,error:r,warning:a,type:s,selected:l=!1,tagHidden:c=!0,showModalFee:p=!0,onClickAllRoutes:u,fullExpandedMode:d=!1,container:h}=t,g=y().blockchains(),{findToken:f}=y(),m=y().swappers(),{customSlippage:C,slippage:S}=y(),k=C||S,[T,v]=rv(t.expanded),b=nv(null),A=B(o.value,6,6),D=B(n.value,6,6),w=n.usdValue?B(n.usdValue,4,4):"",x=Pt(o.usdValue,n.usdValue??null),E=B(x,2,2),N=_t(x??0),M=i((le,at)=>le.map((G,P)=>{let q,V=r?.type===3&&r.swap.swapperId===G.swapperId,fe=r?.type===4&&r.recommendedSlippages?.has(P),ne=a?.type===2&&a.recommendedSlippages?.has(P),ge=V||fe,Fe=ne;ge?q="error":Fe&&(q="warning");let ve=ge?So.t("Slippage Error"):So.t("Slippage Warning");return V&&(ve=So.t("Bridge Limit Error")),{swapper:{displayName:rn(G.swapperId,m)??"",image:G.swapperLogo},from:{token:{displayName:G.from.symbol,image:G.from.logo},chain:{displayName:st(G.from.blockchain,g)??"",image:G.from.blockchainLogo},price:{value:P===0&&!at?B(o.value,6,6):B(G.fromAmount,6,6),usdValue:B((G.from.usdPrice??0)*parseFloat(G.fromAmount),4,4),realValue:P===0?o.value:G.fromAmount,realUsdValue:new Ls(G.from.usdPrice??0).multipliedBy(G.fromAmount).toString()}},to:{token:{displayName:G.to.symbol,image:G.to.logo},chain:{displayName:st(G.to.blockchain,g)||"",image:G.to.blockchainLogo},price:{value:B(G.toAmount,6,6),usdValue:B((G.to.usdPrice??0)*parseFloat(G.toAmount),4,4),realValue:G.toAmount,realUsdValue:new Ls(G.to.usdPrice??0).multipliedBy(G.toAmount).toString()}},state:q,alerts:ge||Fe?F.createElement(jd,{dense:d},F.createElement(ZT,{variant:"alarm",type:ge?"error":"warning",title:ve,footer:F.createElement(Xd,null,V&&F.createElement("div",null,F.createElement(Zo,{size:"xsmall",variant:"body",color:"neutral900"},r.fromAmountRangeError),F.createElement(Yo,{direction:"vertical",size:2}),F.createElement(Zo,{size:"xsmall",variant:"body",color:"neutral900"},So.t({id:"Yours: {amount} {symbol}",values:{amount:B(G.fromAmount,6,6),symbol:G?.from.symbol}}))),(fe||ne)&&!V&&F.createElement("div",null,F.createElement(Zo,{size:"xsmall",variant:"body",color:"neutral900"},So.t({id:"Minimum required slippage: {minRequiredSlippage}",values:{...r?.type===4&&{minRequiredSlippage:r.recommendedSlippages?.get(P)},...a?.type===2&&{minRequiredSlippage:a.recommendedSlippages?.get(P)}}})),F.createElement(Yo,{direction:"vertical",size:2}),F.createElement(Zo,{size:"xsmall",variant:"body",color:"neutral900"},So.t({id:"Yours: {userSlippage}",values:{userSlippage:k}}))))})):void 0,time:ln(G.estimatedTimeInSeconds),fee:B(Ba(G,f),2,2),internalSwaps:G.internalSwaps?M(G.internalSwaps):void 0}}),"getQuoteSteps"),W=M(e?.swaps??[]),j=W.length,te=h||I(),J=Jp(t.quote.tags||[]),L=!!u,X=mr(e?.swaps),se=ln(X),z=Lr(e?.swaps??[],f),me=B(z,2,2),vt=z.gte(new Ls(Qp)),Ze=X/qp>=Hp;return d?F.createElement(JT,{selected:l,fee:me,time:se,tooltipContainer:ro(),steps:W,tags:J,quoteCost:F.createElement(Bs,{quote:e,fullExpandedMode:!0,time:se,fee:me,feeWarning:vt,timeWarning:Ze,showModalFee:p,steps:j}),percentageChange:E,warningLevel:N,outputPrice:{value:D,usdValue:w,realValue:n.value,realUsdValue:n.usdValue}}):F.createElement(em,{selected:l,listItem:s==="list-item",basic:s==="basic"},F.createElement("div",{className:tm()},!c&&J.length?F.createElement(F.Fragment,null,F.createElement(pm,null,J.map((le,at)=>{let G=`${le.value}_${at}`;return F.createElement(F.Fragment,{key:G},F.createElement(ev,{label:le.label,value:le.value}),F.createElement(Yo,{size:4,direction:"horizontal"}))})),F.createElement(oi,null),!L&&F.createElement(Yo,{size:4})):null,F.createElement("div",{id:"portal-root",className:om()},F.createElement(Bs,{quote:e,time:se,fee:me,feeWarning:vt,timeWarning:Ze,showModalFee:p,steps:j}),L&&F.createElement(Rd,{onClick:le=>{le.stopPropagation(),u()},size:"xxsmall",type:"secondary",variant:"default",css:{paddingLeft:"$10",paddingRight:"$10",paddingTop:"$5",paddingBottom:"$5"}},F.createElement(Zo,{color:"secondary",variant:"body",size:"xsmall",className:"allRoutesLabel"},So.t("See All Routes")))),s==="basic"&&F.createElement("div",{className:nm()},F.createElement(lm,null,F.createElement(RT,{size:12,color:"gray"})),F.createElement(cm,null,F.createElement(As,{size:"small",variant:"body"},`${A} ${W[0].from.token.displayName} = `),F.createElement(xm,{content:n.value,container:te,open:n.value?void 0:!1},F.createElement(As,{size:"small",variant:"body"},"\xA0",`${D} ${W[W.length-1].to.token.displayName}`))),F.createElement(xm,{content:n.usdValue,container:te},F.createElement(Yo,{size:2,direction:"horizontal"}),F.createElement(Zo,{color:"$neutral600",size:"xsmall",variant:"body"},`($${w})`))),s==="list-item"&&F.createElement(ov,{tooltipContainer:te,type:"output",direction:"vertical",price:{value:D,usdValue:w,realValue:n.value,realUsdValue:n.usdValue},token:{displayName:W[j-1].to.token.displayName,image:W[j-1].to.token.image},chain:{image:W[j-1].to.chain.image},percentageChange:E,warningLevel:N}),s==="swap-preview"&&F.createElement(F.Fragment,null,F.createElement(Mn,{from:W[0].from,to:W[j-1].to,percentageChange:E,warningLevel:N}),F.createElement(Yo,{size:4}))),F.createElement(Zd,{selected:l,listItem:s==="list-item",open:T,className:"quote_container",onOpenChange:v},F.createElement(bm,{type:s,quoteRef:b,selected:l,setExpanded:v,container:te,expanded:T,steps:W}),F.createElement(am,{open:T},F.createElement(sm,null),F.createElement("div",{className:Jd()},W.map((le,at)=>{let G=`item-${at}`;return F.createElement(tv,{type:"quote-details",key:G,tooltipContainer:te,step:le,hasSeparator:at!==W.length-1,state:le.state})})))))}i(Ps,"Quote");import{Divider as lv,Skeleton as cv}from"@rango-dev/ui";import Ot from"react";import{darkTheme as iv,styled as di}from"@rango-dev/ui";var Em=di("div",{$$color:"$colors$neutral100",[`.${iv} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",borderBottomLeftRadius:"$xm",borderBottomRightRadius:"$xm",padding:"$15",variants:{rounded:{true:{borderRadius:"$xm"}},expanded:{true:{paddingBottom:"3px"},false:{paddingBottom:"$12"}}}}),Im=di("div",{paddingTop:"$2"}),Am=di("div",{paddingLeft:"$8"}),Nm=di("div",{borderLeft:"1px dashed $foreground",minHeight:" 0",margin:"0px 11.5px",alignSelf:"stretch",variants:{hideSeparator:{true:{minHeight:"unset",height:"0"}}}});import{ChainToken as Om,Divider as St,Skeleton as tt}from"@rango-dev/ui";import Q from"react";import{css as av,styled as Ft}from"@rango-dev/ui";var _s=Ft("div",{display:"flex"}),Wm=Ft("div",{padding:"$10 $0 $20"}),Bm=Ft("div",{padding:"14px $0 $20 $0",display:"flex",flexDirection:"column"}),Mm=Ft("div",{display:"flex",justifyContent:"start",alignItems:"center"}),Lm=Ft("div",{display:"flex",justifyContent:"space-between",alignItems:"end"}),Pm=Ft("div",{height:"$24",marginLeft:"13px",borderLeft:"1px solid $neutral700"}),_m=Ft("div",{width:"65%",display:"flex",justifyContent:"start"}),Dm=Ft("div",{display:"flex",flexDirection:"column",alignItems:"start",flexGrow:1,maxWidth:"148px"}),$m=Ft("div",{padding:"$15 $0 $15 $0"}),Fm=av({display:"flex",justifyContent:"space-between",alignItems:"center"});function _n(t){let{type:e,tagHidden:o=!0}=t,n=Q.createElement(Lm,null,Q.createElement(_m,null,Q.createElement(Om,{loading:!0,size:"medium",chainImage:"",tokenImage:""}),Q.createElement(St,{size:8,direction:"horizontal"}),Q.createElement(Dm,null,Q.createElement(tt,{height:10,width:60,variant:"rounded"}),Q.createElement(St,{size:4}),Q.createElement(tt,{height:15,variant:"rounded"}))),Q.createElement(tt,{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(tt,{width:65,height:20,variant:"rounded"}),Q.createElement(St,{size:4,direction:"horizontal"}),Q.createElement(tt,{width:65,height:20,variant:"rounded"}),Q.createElement(St,{size:4,direction:"horizontal"}),Q.createElement(tt,{width:65,height:20,variant:"rounded"})),Q.createElement(oi,null),!r&&Q.createElement(St,{size:4})),Q.createElement("div",{className:Fm()},Q.createElement(_s,null,Q.createElement(tt,{width:60,height:10,variant:"rounded"}),Q.createElement(St,{size:4,direction:"horizontal"}),Q.createElement(tt,{width:60,height:10,variant:"rounded"}),Q.createElement(St,{size:4,direction:"horizontal"}),Q.createElement(tt,{width:60,height:10,variant:"rounded"})),r&&Q.createElement(tt,{width:85,height:24,variant:"rounded"})),e==="basic"&&Q.createElement(Wm,null,Q.createElement(tt,{height:15,width:148,variant:"rounded"})),e==="list-item"&&Q.createElement(Bm,null,Q.createElement(Mm,null,Q.createElement(Om,{loading:!0,size:"medium",chainImage:"",tokenImage:""}),Q.createElement(St,{direction:"horizontal",size:4}),Q.createElement(tt,{height:15,width:150,variant:"rounded"})),Q.createElement(St,{size:10}),Q.createElement(tt,{height:10,width:184,variant:"rounded"})),e==="swap-preview"&&Q.createElement(Q.Fragment,null,Q.createElement(St,{size:4}),Q.createElement($m,null,n,Q.createElement(Pm,null),n),Q.createElement(St,{size:12})))}i(_n,"QuoteSummarySkeleton");import{ChainToken as qm,Divider as $s,NextIcon as sv,Skeleton as mi}from"@rango-dev/ui";import Ee from"react";import{styled as Dn}from"@rango-dev/ui";var Um=Dn("div",{display:"flex",alignItems:"start"}),zm=Dn("div",{flexGrow:1,paddingTop:"$5",paddingBottom:"$10",display:"flex",alignItems:"center",variants:{extraSpace:{true:{paddingBottom:"$40"}}}}),Ds=Dn("div",{display:"flex",alignItems:"center",flexGrow:1}),Qm=Dn("div",{margin:"$0 $2",padding:"$4",display:"flex",justifyContent:"center",alignItems:"center"}),Hm=Dn("div",{display:"flex",alignItems:"center"});function Nt(t){let{separator:e=!0}=t;return Ee.createElement(Ee.Fragment,null,Ee.createElement(Hm,null,Ee.createElement(mi,{height:22,width:22,variant:"circular"}),Ee.createElement($s,{direction:"horizontal",size:8}),Ee.createElement(mi,{height:15,width:148,variant:"rounded"})),Ee.createElement(Um,null,Ee.createElement(Nm,{hideSeparator:!e}),Ee.createElement(zm,{extraSpace:e},Ee.createElement(Ds,null,Ee.createElement(qm,{size:"small",loading:!0,chainImage:"",tokenImage:""}),Ee.createElement($s,{direction:"horizontal",size:8}),Ee.createElement(mi,{height:12,variant:"rounded"})),Ee.createElement(Qm,null,Ee.createElement(sv,{color:"gray",size:16})),Ee.createElement(Ds,null,Ee.createElement(qm,{size:"small",loading:!0,chainImage:"",tokenImage:""}),Ee.createElement($s,{direction:"horizontal",size:8}),Ee.createElement(mi,{height:12,variant:"rounded"})))))}i(Nt,"StepSkeleton");function $n(t){let{type:e,expanded:o,tagHidden:n=!1}=t;return Ot.createElement(Em,{expanded:o,rounded:e!=="basic"},Ot.createElement(_n,{type:e,tagHidden:n}),Ot.createElement(Im,null,Ot.createElement(cv,{height:15,variant:"rounded"})),o&&Ot.createElement(Am,null,Ot.createElement(lv,{size:24}),Ot.createElement(Nt,null),Ot.createElement(Nt,null),Ot.createElement(Nt,{separator:!1})))}i($n,"QuoteSkeleton");function Co(t){let{quote:e,type:o,loading:n,error:r,warning:a,expanded:s=!1,tagHidden:l,onClick:c,showModalFee:p,selected:u,onClickAllRoutes:d,fullExpandedMode:h=!1,container:g}=t,{inputAmount:f,inputUsdValue:m}=O(),C=e?.outputAmount?new pv(e?.outputAmount):null,S=e?ct(e):null,T=!(r&&(r.type===0||r.type===1))&&e&&!n;return n?fi.createElement(Es,null,fi.createElement($n,{tagHidden:l,type:o,expanded:s})):T?fi.createElement(Es,{onClick:()=>c?.(e)},fi.createElement(Ps,{quote:e,error:r,container:g,showModalFee:p,warning:a,tagHidden:l,selected:u,type:o,expanded:s,onClickAllRoutes:d,fullExpandedMode:h,input:{value:f,usdValue:m?.toString()??""},output:{value:C?.toString()??"",usdValue:S?.toString()??""}})):null}i(Co,"QuoteInfo");import{calculatePendingSwap as fv}from"@rango-dev/queue-manager-rango-preset";import{useEffect as gv}from"react";import{useRef as uv,useState as dv}from"react";var mv=2e3;function gi({request:t}){let[e,o]=dv(!1),n=uv(null),r=i(()=>n.current?.abort(),"cancelFetch"),a=i(async l=>(await new Promise(c=>setTimeout(c,mv)),await s(l,!1)),"retryFetch"),s=i(async(l,c=!1)=>{r(),n.current=new AbortController,o(!0);try{let p=await t(l,{signal:n.current.signal});return n.current=null,p}catch(p){if(c)return await a(l);throw p}finally{o(!1)}},"fetch");return{fetch:s,loading:e,cancelFetch:r}}i(gi,"useFetch");function Gm(){let{fetch:t,loading:e,cancelFetch:o}=gi({request:async(n,r)=>await xt().confirmRoute(n,r)});return{fetch:t,loading:e,cancelFetch:o}}i(Gm,"useFetchConfirmQuote");function hi(t){if(!t.swaps)throw new Error(R().noResultError.title,{cause:{type:0,diagnosisMessage:t.diagnosisMessages?.[0]}});let e=Fs(t.swaps);if(e)throw new Error(e.message,{cause:e.options})}i(hi,"throwErrorIfResponseIsNotValid");function Fs(t){if(nu(t)){let{swap:n,recommendation:r,fromAmountRangeError:a}=ru(t);return{message:"bridge limit error",options:{type:3,swap:n,recommendation:r,fromAmountRangeError:a}}}let o=lu(t);if(o){let n=Pr(t);return{message:"",options:{type:4,recommendedSlippages:o,minRequiredSlippage:n}}}return null}i(Fs,"getQuoteError");function Vm(t){let{currentQuote:e,previousQuote:o,meta:n,selectedWallets:r,userSlippage:a,findToken:s}=t,l={quote:null,balance:null},c=Fo({previousQuote:o,currentQuote:e,findToken:s,userSlippage:a});c&&(l.quote=c);let p=uu(e,r,n.blockchains);return p.length===0||(l.balance={messages:p}),l}i(Vm,"generateWarnings");function yi(t){return t?.code==="ERR_CANCELED"?{swap:null,error:{type:2},warnings:null}:t.cause?{swap:null,error:t.cause,warnings:null}:t?.code==="ERR_BAD_REQUEST"?{swap:null,error:{type:0,diagnosisMessage:t.response.data.error},warnings:null}:{swap:null,error:{type:1},warnings:null}}i(yi,"handleQuoteErrors");function Os(){let{fromToken:t,toToken:e,inputAmount:o,inputUsdValue:n,setSelectedQuote:r,selectedQuote:a,customDestination:s,resetAlerts:l}=O(),{slippage:c,customSlippage:p}=y(),u=y().getDisabledLiquiditySources(),d=y().blockchains(),h=y().tokens(),{findToken:g}=y(),f=p||c,{fetch:m,cancelFetch:C,loading:S}=Gm();return gv(()=>C,[]),{loading:S,fetch:i(async T=>{let v=T.selectedWallets,b=T?.customDestination??s;if(!t||!e||!o)return{quote:null,swap:null,error:null,warnings:null};let A=v.reduce((w,x)=>(w[x.chain]=x.address,w),{}),D={requestId:a?.requestId||"",selectedWallets:A,destination:b||void 0};try{return await m(D,!0).then(w=>{let{result:x}=w;if(!x)throw new Error("Error fetching updated route");hi({diagnosisMessages:x.diagnosisMessages,requestId:x.requestId,swaps:x.result?.swaps});let E={outputAmount:x.result?.outputAmount,requestId:x.requestId,resultType:x.result?.resultType,swaps:x.result?.swaps||[],validationStatus:x.validationStatus,requestAmount:x.requestAmount};r(E);let N={slippage:f.toString(),disabledSwappersGroups:u},M=Vm({previousQuote:a??void 0,currentQuote:E,meta:{blockchains:d},selectedWallets:v,userSlippage:f,inputUsdValue:n,findToken:g});l();let W=!!M.balance,j=fv(o.toString(),x,pu(v),N,!W,{blockchains:d,tokens:h});return{quote:E,swap:j,error:null,warnings:M}})}catch(w){return yi(w)}},"fetch"),cancelFetch:C}}i(Os,"useConfirmSwap");var xv=Cv("div",{width:"100%",display:"flex",justifyContent:"space-between",[`& ${Km}`]:{width:"$48",height:"$48"}}),Ev=Qs({flexGrow:1,paddingRight:"$10"}),Iv=Qs({width:"$24",height:"$24",display:"flex",justifyContent:"center",alignItems:"center"}),Av=Qs({display:"flex",justifyContent:"space-between",alignItems:"center"});function jm(){let{selectedQuote:t,setInputAmount:e,selectedWallets:o,quoteWalletsConfirmed:n,customDestination:r,quoteWarningsConfirmed:a}=O(),s=bv(),[l,c]=Fn(""),p=!n,[u,d]=Fn(!1),[h,g]=Fn(!1),{isActiveTab:f}=re(),m=y().getDisabledLiquiditySources(),C=wv(m),{manager:S}=hv(),{fetch:k,loading:T,cancelFetch:v}=Os(),[b,A]=Fn({swap:null,error:null,warnings:null}),[D,w]=Fn(!1),x=i(async({selectedWallets:L,customDestination:X})=>{let se=await k?.({selectedWallets:L,customDestination:X});return A(se),se},"onConfirmSwap"),E=i(async()=>{if(b.swap&&n)try{await S?.create("swap",{swapDetails:b.swap},{id:b.swap.requestId});let L=`../${$.swaps}/${b.swap.requestId}`;s(L,{replace:!0}),setTimeout(()=>{e("")},0)}catch(L){c("Error: "+L?.message)}},"addNewSwap"),N=i(async()=>{g(!0),await E(),g(!1)},"onConfirm"),M=i(async()=>{b.warnings?.quote&&Xp(b.warnings.quote)&&!a?w(!0):await N()},"onStartConfirmSwap"),W=i(async()=>{A({error:null,swap:null,warnings:null}),k({selectedWallets:o,customDestination:r}).then(L=>{A(L)}).catch(L=>console.error(L))},"onRefresh");Si(()=>{!!C.current.length&&!m.length&&W(),C.current=m},[m.length]),Si(()=>{p&&v()},[p]),Si(()=>{p&&d(p)},[p]),Si(()=>{p||k({selectedWallets:o,customDestination:r}).then(L=>A(L)).catch(L=>console.error(L))},[]),vv(()=>{t?.requestId||s(`../${location.search}`)},[t?.requestId]);let j=b.warnings?.quote??null,te=b.error,J=[];if(l&&J.push(Le.createElement(yv,{type:"error",variant:"alarm",title:l})),j||te){let L=`../${$.settings}`;J.push(Le.createElement(Wn,{warning:j,error:te,couldChangeSettings:!1,refetchQuote:W,showWarningModal:D,confirmationDisabled:!f,onOpenWarningModal:()=>w(!0),onCloseWarningModal:()=>w(!1),onConfirmWarningModal:async()=>{w(!1),await E()},onChangeSettings:()=>s(L)}))}return Le.createElement(oe,{header:{title:Us.t("Confirm Swap"),onWallet:()=>{let L=`../${$.wallets}`;s(L)}},footer:Le.createElement(xv,null,Le.createElement("div",{className:Ev()},Le.createElement(Sv,{id:"widget-confirm-swap-start-btn",variant:"contained",type:"primary",size:"large",fullWidth:!0,loading:T||h,disabled:!!b.error||!f,onClick:M},Us.t("Start Swap"))),Le.createElement(Km,{id:"widget-confirm-swap-wallet-icon-btn",variant:"contained",type:"primary",size:"large",loading:T||h,disabled:!f,onClick:d.bind(null,!0)},Le.createElement(Tv,{size:24})))},u&&Le.createElement(Nd,{open:u,onClose:()=>d(!1),onCancel:v,loading:T,onCheckBalance:x}),Le.createElement(ie,null,Le.createElement("div",{className:Av()},Le.createElement(kv,{variant:"title",size:"small"},Us.t("You get")),Le.createElement("div",{className:Iv()},Le.createElement(Ur,{onClick:!T&&!u&&!D?W:void 0}))),Le.createElement(zs,{size:"12"}),Wu(J.map((L,X)=>({element:L,key:`alert-${X}`})),Le.createElement(zs,{size:10})),J.length>0?Le.createElement(zs,{size:10}):null,Le.createElement(Co,{quote:t,type:"swap-preview",expanded:!0,tagHidden:!0,error:b.error,loading:T,warning:b.warnings?.quote??null})))}i(jm,"ConfirmSwapPage");import{i18n as Ut}from"@lingui/core";import{Button as Rs,CustomTokensZeroStateDarkIcon as qv,CustomTokensZeroStateIcon as Gv,DeleteIcon as Vv,Divider as Qn,IconButton as Kv,MessageBox as jv,NotFound as Xv,styled as tl}from"@rango-dev/ui";import de,{useState as el}from"react";import{useNavigate as Yv}from"react-router-dom";import{CloseIcon as Wv,IconButton as Bv,SearchIcon as Mv,TextField as Lv}from"@rango-dev/ui";import On from"react";import{styled as Nv}from"@rango-dev/ui";var Xm=Nv("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:c,...p}=t;return On.createElement(Lv,{prefix:On.createElement(Xm,null,On.createElement(Mv,{color:"black"})),suffix:!!s.length&&On.createElement(Bv,{variant:"ghost",onClick:()=>c?.(""),size:"small"},On.createElement(Wv,{color:"gray",size:10})),fullWidth:o,color:n,variant:e,style:{padding:10,borderRadius:25,alignItems:"center",...l},size:r,value:s,onChange:a,...p})}i(Ct,"SearchInput");import{i18n as Js}from"@lingui/core";import{darkTheme as sf,Divider as Ro,ExternalLinkIcon as Dv,Image as $v,ListItemButton as Fv,NotFound as Ov,PinIcon as Uv,Skeleton as lf,Typography as Ti,VirtualizedList as zv}from"@rango-dev/ui";import H from"react";import{Divider as rf,ListItem as _v,Skeleton as Un}from"@rango-dev/ui";import kt from"react";import{css as Jo,darkTheme as Ym,ImageContainer as Pv,styled as ut,Typography as Zm}from"@rango-dev/ui";var Hs=Jo({position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:100,overflow:"hidden"}),qs=Jo({position:"relative",height:12,width:"30%",maxWidth:"150px"}),Gs=Jo({position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",bottom:"-8px"}),Vs=Jo({transform:"translateY(12px)",visibility:"hidden",display:"flex","& a":{display:"flex",justifyContent:"center",alignItems:"center",fontSize:"$12",lineHeight:"$16",$$color:"$colors$neutral600",[`.${Ym} &`]:{$$color:"$colors$neutral700"},color:"$$color",textDecoration:"none"}}),Ks=Jo({}),js=Jo(),Jm=ut("div",{display:"flex",flexDirection:"column",flexGrow:1,overflow:"hidden",justifyContent:"center"}),Xs=ut("div",{display:"flex",alignItems:"center","._typography":{textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:100,overflow:"hidden"}}),Ci=ut("ul",{flexGrow:1,padding:0,margin:0,listStyle:"none","& li":{alignItems:"none","&:hover":{[`& .${qs}`]:{[`& .${Vs}`]:{position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",visibility:"visible"},[`& .${Ks}`]:{bottom:"-15px"},[`& .${Hs}`]:{position:"absolute",transform:"translateY(-12px)",visibility:"hidden"},[`& .${Gs}`]:{position:"absolute",transform:"translateY(-12px)",bottom:"-10px"}}}}}),Ys=ut("div",{paddingLeft:"$5",paddingRight:"$5",borderRadius:"$md",display:"flex",alignItems:"center"}),Zs=ut(Zm,{}),Rm=ut("div",{textAlign:"right",width:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",[`& .${js}`]:{$$color:"$colors$neutral600",[`.${Ym} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),ki=ut("div",{display:"flex",alignItems:"end",flexDirection:"column"}),YU=ut("div",{display:"flex",alignItems:"center"}),ef=ut("div",{position:"relative",[`& ${Pv}`]:{borderRadius:"$xm",overflow:"hidden"}}),tf=ut("div",{position:"absolute",backgroundColor:"$neutral100",padding:"$4",borderRadius:"50%",bottom:-6,right:-6}),of=ut(Zm,{width:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}),nf=ut("a",{"& svg:hover":{color:"$colors$info"}});function af(t){return kt.createElement(Ci,null,Array.from(Array(t.size),e=>kt.createElement(_v,{key:e,hasDivider:!0,start:kt.createElement(Un,{variant:"circular",width:35,height:35}),end:kt.createElement(ki,null,kt.createElement(Un,{variant:"text",size:"large",width:70}),kt.createElement(rf,{size:4}),kt.createElement(Un,{variant:"text",size:"medium",width:50})),title:kt.createElement("div",null,kt.createElement(Un,{variant:"text",size:"large",width:90}),kt.createElement(rf,{size:4}),kt.createElement(Un,{variant:"text",size:"medium",width:90}))})))}i(af,"LoadingTokenList");var Qv=20,Hv=i(t=>{let{address:e,name:o,url:n,token:r,customCssForTag:a,customCssForTagTitle:s}=t,l=e.length;return H.createElement("div",{className:qs()},o?H.createElement("div",{className:Hs()},o):H.createElement(Xs,{className:Gs()},H.createElement(Ti,{variant:"title",size:"xmedium"},r.symbol),H.createElement(Ro,{direction:"horizontal",size:4}),H.createElement(Ys,{css:a},H.createElement(Zs,{variant:"body",size:"xsmall",css:s},r.blockchain))),!!e&&H.createElement("div",{className:`${Vs()} ${!o&&Ks()}`},l>10?`${e.slice(0,5)}...${e.slice(l-6,l)}`:e," ",H.createElement(Ro,{size:4,direction:"horizontal"}),H.createElement(nf,{href:n,target:"_blank",rel:"nofollow noreferrer",onClick:c=>c.stopPropagation()},H.createElement(Dv,{size:12}))))},"renderDesc");function zn(t){let{list:e,searchedFor:o="",onChange:n,selectedBlockchain:r,showTitle:a=!0,action:s}=t,l=y().fetchStatus,c=y().blockchains(),{getBalanceFor:p,fetchingWallets:u}=y(),{isTokenPinned:d}=y(),h=i(f=>{let m=yr(p(f));return s?s(f):u?H.createElement(ki,null,H.createElement(lf,{variant:"text",size:"large",width:70}),H.createElement(Ro,{size:4}),H.createElement(lf,{variant:"text",size:"medium",width:50})):m&&H.createElement(Rm,null,H.createElement(of,{variant:"title",size:"small"},m.amount),H.createElement("div",null),m.usdValue&&H.createElement(Ti,{variant:"body",className:js(),size:"xsmall"},`$${m.usdValue}`))},"endRenderer"),g=i(()=>H.createElement(zv,{itemContent:f=>{let m=e[f],C=m.address||"",S=c.find(b=>b.name===m.blockchain),k=Ga(S.color,"main"),T={$$color:k.main150,[`.${sf} &`]:{$$color:k.main750},backgroundColor:"$$color"},v={$$color:k.main750,[`.${sf} &`]:{$$color:k.main150},color:"$$color"};return H.createElement("div",{style:{paddingRight:5}},H.createElement(Fv,{style:{width:"100%",overflow:"hidden",height:"60px"},"tab-index":f,key:`${m.symbol}${m.address}`,id:`${m.symbol}${m.address}`,className:"widget-token-list-item-btn",hasDivider:!0,onClick:()=>n&&n(e[f]),start:H.createElement(ef,null,H.createElement($v,{src:m.image,size:30}),t.type!=="custom-token"&&d(m,t.type)&&H.createElement(tf,null,H.createElement(Uv,{size:12,color:"gray"}))),title:S?.type==="COSMOS"||m.name||!m.name&&!C?H.createElement(Xs,null,H.createElement(Ti,{variant:"title",size:"xmedium"},m.symbol),H.createElement(Ro,{direction:"horizontal",size:4}),H.createElement(Ys,{css:T},H.createElement(Zs,{variant:"body",size:"xsmall",css:v},m.blockchain))):void 0,description:S?.info&&C&&S.type!=="COSMOS"?Hv({address:C,token:e[f],customCssForTag:T,customCssForTagTitle:v,name:m.name,url:S.info.addressUrl.split("{wallet}").join(C)}):m.name||void 0,end:h(m)}))},totalCount:e.length,key:`${r}-${o}`}),"renderList");return H.createElement(H.Fragment,null,a&&H.createElement(H.Fragment,null,H.createElement(Ti,{variant:"label",size:"large"},Js.t("Select Token")),H.createElement(Ro,{size:4})),H.createElement(Jm,null,H.createElement(Ro,{size:4}),l==="loading"&&H.createElement(af,{size:Qv}),l==="success"&&(e.length?H.createElement(Ci,{as:"ul"},g()):!!o&&H.createElement(Ov,{title:Js.t("No results found"),description:Js.t("Try using different keywords")}))))}i(zn,"TokenList");var Zv=tl("div",{display:"flex",justifyContent:"space-between",flexDirection:"column",flex:1}),Jv=tl("div",{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",flex:"0.75"}),Rv=tl(Kv,{"&:hover":{"& svg":{color:"$secondary550"}}});function cf(){let[t,e]=el(""),{deleteCustomToken:o}=y(),n=y().customTokens(),{fromToken:r,toToken:a,setFromToken:s,setToToken:l}=O(),{mode:c}=Qo({}),p=Yv(),[u,d]=el(!1),[h,g]=el(),f=i(k=>{let T=k.target.value;e(T)},"handleSearch"),m=c==="dark",C=n.filter(k=>Je(k.symbol,t)||Je(k.address||"",t)||Je(k.name||"",t)),S=i(()=>{if(h){let k=a?lt(a):null,T=r?lt(r):null,v=lt(h);k===v?l({token:null}):T===v&&s({token:null}),o(h)}d(!1)},"handleDeleteCustomToken");return de.createElement(oe,{header:{title:Ut.t("Custom Tokens")}},de.createElement(ie,null,de.createElement(Zv,null,n.length?de.createElement(de.Fragment,null,de.createElement(Ct,{value:t,setValue:e,fullWidth:!0,color:"light",variant:"contained",placeholder:Ut.t("Search Token"),onChange:f}),de.createElement(Qn,{size:16}),de.createElement(zn,{list:C,type:"custom-token",searchedFor:t,showTitle:!1,action:k=>de.createElement(Rv,{id:"widget-custom-token-delete-icon-btn",variant:"ghost",onClick:()=>{d(!0),g(k)}},de.createElement(Vv,{size:12,color:"gray"}))})):de.createElement(Jv,null,de.createElement(Xv,{icon:m?de.createElement(qv,{size:200}):de.createElement(Gv,{size:200}),title:Ut.t("No custom tokens"),description:Ut.t("press the button to add your custom token")})),de.createElement(Qn,{size:20}),de.createElement(Rs,{id:"widget-custom-token-add-btn",type:"primary",variant:"contained",size:"large",onClick:()=>p($.addCustomTokens)},Ut.t("Add Custom Token"))),de.createElement(Z,{open:u,dismissible:!0,onClose:()=>d(!1),container:I()},de.createElement(jv,{title:Ut.t("Delete Custom Token"),type:"error",description:Ut.t("Are you sure you want to Delete this Token?")},de.createElement(Qn,{size:40}),de.createElement(Qn,{size:10}),de.createElement(Rs,{fullWidth:!0,id:"widget-custom-token-delete-modal-yes-btn",variant:"contained",type:"primary",size:"large",onClick:S},Ut.t("Yes, Delete it")),de.createElement(Qn,{size:12}),de.createElement(Rs,{id:"widget-custom-token-delete-modal-no-btn",fullWidth:!0,variant:"outlined",type:"primary",size:"large",onClick:()=>d(!1)},Ut.t("No, Continue"))))))}i(cf,"CustomTokensPage");import{i18n as He}from"@lingui/core";import{useManager as Sw}from"@rango-dev/queue-manager-react";import{Button as ll,darkTheme as Cw,Divider as To,MessageBox as kw,NotFound as Tw,styled as cl,Typography as bi}from"@rango-dev/ui";import{TransactionStatus as Gn}from"rango-types";import ae,{useMemo as Af,useState as xi}from"react";import{useNavigate as vw}from"react-router-dom";import{FilterIcon as aw,Popover as sw}from"@rango-dev/ui";import ko from"react";import{css as ew,darkTheme as vi,IconButton as tw,styled as Hn}from"@rango-dev/ui";var ol=Hn("div",{position:"relative","&::before":{position:"absolute",right:"1px",top:"-1px",width:"$8",height:"$8",borderRadius:"100%",backgroundColor:"$neutral300",[`.${vi} &`]:{backgroundColor:"$neutral400"},padding:"$2"},variants:{isSelect:{true:{"&::before":{content:""}}}}}),pf=Hn(tw,{width:"$36",height:"$36",position:"relative",padding:"0",overflow:"unset",backgroundColor:"$neutral300",[`.${vi} &`]:{backgroundColor:"$neutral400"},"&:hover":{backgroundColor:"$secondary100",[`.${vi} &`]:{backgroundColor:"$neutral"},[`& ${ol}::before`]:{backgroundColor:"$secondary100",[`.${vi} &`]:{backgroundColor:"$neutral"}}},variants:{isSelect:{true:{border:"1px solid $secondary"}}}}),uf=Hn("div",{position:"absolute",width:"$6",height:"$6",display:"flex",justifyContent:"center",alignItems:"center",borderRadius:"3px",top:"$0",right:"1px",backgroundColor:"$secondary500"}),df=Hn("div",{padding:"$15",borderRadius:"$sm",width:"248px",backgroundColor:"$background",zIndex:10}),mf=ew({display:"flex",justifyContent:"space-between",alignItems:"center"}),ff=Hn("ul",{margin:0,listStyle:"none",height:"100%",padding:0,".item-start-container":{paddingRight:"0 !important"}});import{i18n as gf}from"@lingui/core";import{Button as ow,Divider as hf,ListItemButton as nw,Radio as rw,RadioRoot as iw,Typography as yf}from"@rango-dev/ui";import ot from"react";function Sf(t){let{filterBy:e,onClickItem:o}=t;return ot.createElement(df,null,ot.createElement("div",{className:mf()},ot.createElement(yf,{size:"small",variant:"body"},gf.t("Status")),ot.createElement(ow,{id:"widget-filter-selector-reset-btn",variant:"ghost",size:"xxsmall",onClick:()=>o("")},gf.t("Reset"))),ot.createElement(hf,{size:10}),ot.createElement(iw,{value:e},ot.createElement(ff,null,t.list.map((n,r)=>ot.createElement(nw,{key:n.id,style:{height:"40px",width:"100%"},selected:!1,hasDivider:t.list.length-1!=r,id:n.id,title:ot.createElement(ot.Fragment,null,ot.createElement(hf,{direction:"horizontal",size:4}),ot.createElement(yf,{size:"medium",variant:"body"},n.title)),start:ot.createElement(rw,{value:n.id}),onClick:o})))))}i(Sf,"FilterSelectorContent");function nl(t){let{onClickItem:e,onOpenChange:o,filterBy:n,list:r,open:a}=t;return ko.createElement("div",null,ko.createElement(sw,{open:a,align:"end",onOpenChange:o,container:I(),content:ko.createElement(Sf,{list:r,filterBy:n,onClickItem:s=>{e(s),o(!1)}})},ko.createElement(pf,{id:"widget-filter-selector-filter-icon-btn",variant:"default",isSelect:!!n,onClick:()=>o(!t.open)},ko.createElement(ol,{isSelect:!!n},ko.createElement(aw,{size:16,color:"black"}),!!n&&ko.createElement(uf,null)))))}i(nl,"FilterSelector");import{i18n as pw}from"@lingui/core";import{Divider as wf,GroupedVirtualizedList as uw,Skeleton as dw,SwapListItem as bf,Typography as mw}from"@rango-dev/ui";import Qe,{useCallback as xf,useEffect as fw,useRef as gw,useState as hw}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 lw,darkTheme as cw,styled as qn}from"@rango-dev/ui";var rl=lw(),kf=qn("div",{display:"flex",justifyContent:"center",alignItems:"center",padding:"$5"}),il=qn("div",{width:"100%",display:"flex",flexDirection:"column",backgroundColor:"$background",padding:"$10 $5 0 $5",[`& .${rl}`]:{$$color:"$colors$neutral600",[`.${cw} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),al=qn("div",{display:"flex",justifyContent:"flex-start",padding:"$2"}),Tf=qn("div",{gap:"$10",display:"flex",flexDirection:"column"}),vf=qn("div",{height:"100%",display:"flex",justifyContent:"center",alignItems:"center"});var yw=10;function sl(t){let{list:e,onSwapClick:o,groupBy:n,isLoading:r}=t,[a,s]=hw([]),l=gw(0),{swaps:c,groupCounts:p,groups:u}=n(e),d=xf(Cf,[]),h=xf(()=>{let g=e.length-l.current;g&&(l.current+=Math.min(g,yw),s(d(p,l.current)))},[e.length]);if(fw(()=>{r||h()},[r,h]),r){let g=[1,2];return Qe.createElement(Qe.Fragment,null,[g,g].map((m,C)=>Qe.createElement(il,{key:C},Qe.createElement(al,null,Qe.createElement(dw,{variant:"text",width:60,size:"small"}),Qe.createElement(wf,{size:16})),Qe.createElement(wf,{size:4}),Qe.createElement(Tf,null,m.map((k,T)=>Qe.createElement(bf,{isLoading:!0,key:T}))))))}return Qe.createElement(uw,{endReached:()=>{l.current<e.length&&h()},groupCounts:a,groupContent:g=>Qe.createElement(il,null,Qe.createElement(al,null,Qe.createElement(mw,{variant:"label",size:"medium",className:rl()},u[g]))),itemContent:(g,f)=>{let m=c[g];if(!m)return null;let C=m.steps[0],S=m.steps[m.steps.length-1];return Qe.createElement(kf,{key:m.requestId},Qe.createElement(bf,{requestId:m.requestId,creationTime:m.creationTime,status:m.status,onClick:o,tooltipContainer:I(),onlyShowTime:u[f]===pw.t("Today"),swapTokenData:{from:{token:{image:C.fromLogo,displayName:C.fromSymbol},blockchain:{image:C.fromBlockchainLogo||""},amount:B(m.inputAmount,6,6),realAmount:m.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(sl,"HistoryGroupedList");import{i18n as wi}from"@lingui/core";import Ef from"dayjs";var If=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(c,p){e.has(c)||e.set(c,{title:c,swaps:[]}),e.get(c)?.swaps.push(p)}i(o,"addYearsToOutput");let n=Ef();t.forEach(c=>{let p=Number(c.creationTime),u=Ef(p);if(n.isSame(u,"day"))e.get("today")?.swaps.push(c);else if(n.isSame(u,"week"))e.get("week")?.swaps.push(c);else if(n.isSame(u,"month"))e.get("month")?.swaps.push(c);else if(n.isSame(u,"year"))e.get("year")?.swaps.push(c);else{let d=new Date(p).getFullYear().toString();o(d,c)}});let r=Array.from(e.values()).filter(c=>c.swaps.length>0),a=r.flatMap(c=>c.swaps),s=r.map(c=>c.swaps.length),l=r.map(c=>c.title);return{swaps:a,groupCounts:s,groups:l}},"groupSwapsByDate");var ww=cl("div",{overflowY:"visible",width:"100%",display:"flex",flexDirection:"column",gap:15,height:"100%"}),bw=cl("div",{display:"flex",justifyContent:"center",alignItems:"center"}),xw=cl("div",{"._typography":{color:"$neutral700",[`.${Cw}&`]:{color:"$neutral900"}}}),Ew=[{id:Gn.SUCCESS,title:He.t("Complete")},{id:Gn.RUNNING,title:He.t("Running")},{id:Gn.FAILED,title:He.t("Failed")}],Iw=i((t,e)=>t?.length?t.filter(o=>wt(o.fromBlockchain,e)||wt(o.toBlockchain,e)||wt(o.toSymbol,e)||wt(o.fromSymbol,e)).length:!1,"isStepContainsText");function Nf(){let t=vw(),{manager:e,state:o}=Sw(),n=pt(e).map(({swap:T})=>T),[r,a]=xi(""),[s,l]=xi(!1),c=!o.loadedFromPersistor,[p,u]=xi(""),[d,h]=xi(!1),g=i(T=>{let v=T.target.value;a(v)},"handleSearch"),f=Af(()=>!r&&!p?n:n.filter(T=>{let{inputAmount:v,status:b,steps:A,requestId:D}=T;return(!r||wt(v,r)||wt(b,r)||Iw(A,r)||wt(D,r))&&(!p||p===b)}),[n,r,p]),m=!f?.length&&!c,C=i(()=>h(!1),"onCloseModal"),S=i(async()=>{try{await e?.clearQueue(),h(!1)}catch(T){console.log(T)}},"onClear"),k=Af(()=>!n.some(T=>T.status===Gn.SUCCESS||T.status===Gn.FAILED),[n]);return ae.createElement(oe,{header:{title:He.t("History"),suffix:ae.createElement(Vt,null,ae.createElement(ll,{id:"widget-history-clear-btn",disabled:k,variant:"ghost",size:"xsmall",onClick:()=>h(!0)},ae.createElement(bi,{size:"medium",variant:"label",color:"error"},He.t("Clear"))))}},ae.createElement(ie,null,ae.createElement(bw,null,ae.createElement(Ct,{setValue:a,fullWidth:!0,variant:"contained",placeholder:He.t("Search Transaction"),autoFocus:!0,onChange:g,style:{height:36},value:r}),ae.createElement(To,{size:10,direction:"horizontal"}),ae.createElement(nl,{filterBy:p,open:s,onOpenChange:T=>l(T),onClickItem:T=>u(T),list:Ew})),ae.createElement(To,{size:"16"}),ae.createElement(ww,null,m&&ae.createElement(vf,null,ae.createElement(To,{size:32}),ae.createElement(Tw,{title:r?He.t("No results found"):He.t("No transactions"),titleColor:r?void 0:"$info",hasIcon:!!r,description:r?He.t("Try using different keywords"):He.t("Your transaction history is stored locally and will appear here after you start a swap")})),!m&&ae.createElement(sl,{list:f,onSwapClick:t,groupBy:If,isLoading:c}))),ae.createElement(Z,{open:d,onClose:C,container:I()},ae.createElement(To,{size:20}),ae.createElement(kw,{type:"warning",title:He.t("Clear Transaction History"),description:ae.createElement(xw,null,ae.createElement(bi,{variant:"body",size:"medium"},He.t("Proceeding will remove all successful and failed transactions from the widget. Do you want to continue?")),ae.createElement(To,{size:"24"}),ae.createElement(bi,{variant:"body",size:"small"},He.t("Note: This does not erase your transaction history on the chain; it only removes them here.")))}),ae.createElement(To,{size:30}),ae.createElement(ll,{id:"widget-history-clear-modal-yes-btn",variant:"contained",type:"primary",size:"large",onClick:S},He.t("Yes, Clear the history")),ae.createElement(To,{size:10}),ae.createElement(ll,{id:"widget-history-clear-modal-no-btn",variant:"outlined",type:"primary",size:"large",onClick:C},ae.createElement(bi,{variant:"title",size:"medium",color:"primary"},He.t("No, Cancel")))))}i(Nf,"HistoryPage");import{i18n as Zw}from"@lingui/core";import{Button as Jw,Divider as Yf,styled as Rw,WarningIcon as eb}from"@rango-dev/ui";import tb from"bignumber.js";import qe,{useEffect as Zf,useState as Jf}from"react";import{useNavigate as ob}from"react-router-dom";import{i18n as Bf}from"@lingui/core";import{Alert as Nw,Divider as pl,NoRouteIcon as Ww,Typography as Bw}from"@rango-dev/ui";import vo from"react";import{styled as Aw}from"@rango-dev/ui";var Wf=Aw("div",{display:"flex",flexDirection:"column",alignItems:"center"});function ul(){let{fromToken:t,toToken:e}=O();return!!t&&!!e&&Mt(t,e)?vo.createElement(Wf,null,vo.createElement(pl,{size:10}),vo.createElement(Ww,{size:24,color:"gray"}),vo.createElement(pl,{size:4}),vo.createElement(Bw,{variant:"title",size:"small"},Bf.t("No Routes Found")),vo.createElement(pl,{size:4}),vo.createElement(Nw,{title:Bf.t("You cannot use the same token for From and To."),type:"warning",variant:"alarm"})):null}i(ul,"SameTokensWarning");import{i18n as $w}from"@lingui/core";import{Header as Fw}from"@rango-dev/ui";import Jt,{useEffect as Ow,useState as Uw}from"react";import{i18n as Lw}from"@lingui/core";import{Divider as ml,FullExpandedQuote as Pw,Typography as _w}from"@rango-dev/ui";import Se from"react";import{styled as dl}from"@rango-dev/ui";var Mf=dl("div",{display:"flex",justifyContent:"center",flexDirection:"column",height:"100%"}),Lf=dl("div",{display:"flex",justifyContent:"space-between",alignItems:"center"}),Pf=dl("div",{width:"146px"});import{i18n as Vn}from"@lingui/core";import{Select as Mw}from"@rango-dev/ui";import _f from"react";function Ei(t){let{updateQuotePartialState:e,sortStrategy:o}=O(),n=[{value:"SMART",label:Vn.t("Smart Routing")},{value:"FEE",label:Vn.t("Lowest Fee")},{value:"SPEED",label:Vn.t("Fastest Transfer")},{value:"NET_OUTPUT",label:Vn.t("Maximum Return")},{value:"PRICE",label:Vn.t("Maximum Output")}];return _f.createElement(Pf,null,_f.createElement(Mw,{container:t.container,options:n,value:o,handleItemClick:r=>{e("sortStrategy",r.value)},variant:"filled"}))}i(Ei,"SelectStrategy");var Df=3;function Kn(t){let{loading:e,onClickOnQuote:o,fetch:n,showModalFee:r,hasSort:a=!0,fullExpandedMode:s=!1,container:l}=t,{selectedQuote:c,quotes:p,updateQuotePartialState:u,fromToken:d,toToken:h,sortStrategy:g,error:f}=O(),{slippage:m,customSlippage:C}=y(),{findToken:S}=y(),k=l||I(),T=!!p&&p.results.length,v=C??m,b=i(w=>{if(!d||!h||!p)return null;let x={requestAmount:p.requestAmount,validationStatus:null,...w};return Fo({currentQuote:x,userSlippage:v,findToken:S})},"getQuoteWarning"),A=f?.type===0||f?.type===1,D=p?.results?Mr(g,p?.results):[];return Se.createElement(Se.Fragment,null,a&&Se.createElement(Se.Fragment,null,Se.createElement(Lf,null,Se.createElement(_w,{size:"xmedium",variant:"title"},Lw.t("Sort by")),Se.createElement(Ei,{container:k})),Se.createElement(ml,{size:"10"})),e&&Array.from({length:Df},(w,x)=>Se.createElement(Se.Fragment,{key:x},s?Se.createElement(Pw,{loading:!0}):Se.createElement($n,{tagHidden:!1,type:"list-item",expanded:!1}),x!==Df-1&&Se.createElement(ml,{size:16}))),!e&&Se.createElement(Se.Fragment,null,T?D.map((w,x)=>{let E=b(w),N=Fs(w.swaps),M=D.length-1===x;return Se.createElement(Se.Fragment,{key:w.requestId},Se.createElement(Co,{showModalFee:r,container:k,selected:c?.requestId===w.requestId,tagHidden:!1,quote:{...w,requestAmount:p.requestAmount,validationStatus:null},loading:e,error:N?.options||null,warning:E,fullExpandedMode:s,onClick:W=>{N||u("warning",E),u("error",N?.options||null),o(W)},type:"list-item"}),!M&&Se.createElement(ml,{size:16}))}):A&&Se.createElement(Mf,null,Se.createElement(An,{size:s?"large":"small",error:f,fetch:n}))))}i(Kn,"Quotes");import{darkTheme as Dw,styled as $f}from"@rango-dev/ui";var Ff=$f("div",{transition:"width 0.2s, opacity 0.2s, margin-left 0.2s",height:"700px",width:"390px",position:"relative",opacity:1,marginLeft:"$16",backgroundColor:"$neutral100",[`.${Dw} &`]:{backgroundColor:"$neutral300"},variants:{expandMode:{default:{width:"390px"},full:{width:"719px"}}},"&.is-hidden":{width:0,height:0,opacity:0,marginLeft:0}}),Of=$f("div",{position:"relative",overflow:"hidden",padding:"$20",flexGrow:1,display:"flex",flexDirection:"column",overflowY:"auto",borderRadius:"$primary",backgroundColor:"$background"});var zw=100;function fl(t){let{fetch:e,loading:o,onClickOnQuote:n,onClickRefresh:r,isVisible:a}=t,[s,l]=Uw(!1),c=s?"":"is-hidden",{config:p}=y(),u=p?.variant==="full-expanded",d=ro();return Ow(()=>{let h=null;return a?h=setTimeout(()=>{l(!0)},zw):(l(!1),h&&clearTimeout(h)),()=>{h&&clearTimeout(h)}},[a]),Jt.createElement(Ff,{expandMode:p?.variant==="full-expanded"?"full":"default",className:`${c} ${Hr()}`,id:De.EXPANDED_BOX_ID},Jt.createElement(Fw,{title:$w.t("Routes"),suffix:Jt.createElement(Jt.Fragment,null,Jt.createElement(Ei,{container:d}),Jt.createElement(go,{container:d,onClickRefresh:r,hidden:["history","notifications","settings"]}))}),Jt.createElement(Of,null,Jt.createElement(Kn,{showModalFee:!0,fetch:e,hasSort:!1,loading:o,container:ro(),onClickOnQuote:n,fullExpandedMode:u})))}i(fl,"ExpandedQuotes");import{i18n as Vf}from"@lingui/core";import{SwapInput as Kf}from"@rango-dev/ui";import Gw from"bignumber.js";import jn from"react";import{ReverseIcon as qw}from"@rango-dev/ui";import hl from"react";import{keyframes as Qw,styled as Uf}from"@rango-dev/ui";var gl=450,Hw=Qw({"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)"}}),zf=Uf("div",{position:"absolute",bottom:"-12px",left:"50%",transform:"translate(-50%, 10%)",cursor:"pointer"}),Qf=Uf("div",{borderRadius:"$md",border:"3px solid $background",background:"$neutral100",width:"$24",height:"$24",display:"flex",justifyContent:"center",alignItems:"center",color:"$foreground","&.rotate":{"& svg":{animation:`${Hw} ${gl}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 yl(){let t=O.use.switchFromAndTo();return hl.createElement(zf,null,hl.createElement(Qf,{onClick:e=>{let o=e.currentTarget;o.classList.add("rotate"),setTimeout(()=>{o.classList.remove("rotate")},gl),t()}},hl.createElement(qw,{size:12})))}i(yl,"SwitchFromAndToButton");import{styled as Hf}from"@rango-dev/ui";var qf=Hf("div",{display:"flex",flexDirection:"column",gap:"$5",alignSelf:"stretch"}),Gf=Hf("div",{position:"relative"});function Sl(t){let{fetchingQuote:e,fetchMetaStatus:o,onClickToken:n,isExpandable:r}=t,{fromToken:a,fromBlockchain:s,toToken:l,toBlockchain:c,setInputAmount:p,inputAmount:u,inputUsdValue:d,outputAmount:h,outputUsdValue:g,selectedQuote:f}=O(),{connectedWallets:m,getBalanceFor:C}=y(),S=a?C(a):null,k=yr(S)?.amount??"0",T=S?new Gw(S.amount).shiftedBy(-S.decimals):ce,v=!!s&&Uc(m,s.name),b=!Wa(f,u,d),A=!Wa(f,u,g),D=!d||!g||!g.gt(0)?null:Pt(d.toString(),g.toString());return jn.createElement(qf,null,jn.createElement(Gf,null,jn.createElement(Kf,{label:Vf.t("From"),mode:"From",onInputChange:p,balance:k,chain:{displayName:s?.displayName||"",image:s?.logo||""},token:{displayName:a?.symbol||"",image:a?.image||""},onClickToken:()=>n("from"),price:{value:u,usdValue:b?void 0:B(d,4,4),realUsdValue:b?void 0:d?.toString(),error:b?R().unknownPriceError.impactTitle:void 0},disabled:o==="failed",loading:o==="loading",loadingBalance:v,tooltipContainer:I(),onSelectMaxBalance:()=>{let w=B(T,S?.decimals),x=S?.amount?w:"";p(x)},anyWalletConnected:m.length>0}),jn.createElement(yl,null)),jn.createElement(Kf,{sharpBottomStyle:!r&&(!!f||e),label:Vf.t("To"),mode:"To",fetchingQuote:e,chain:{displayName:c?.displayName||"",image:c?.logo||""},token:{displayName:l?.symbol||"",image:l?.image||""},percentageChange:B(Pt(d,g),2,2),warningLevel:_t(D??0),price:{value:B(h,6,6),usdValue:A?void 0:B(g,4,4),realValue:h?.toString(),realUsdValue:A?void 0:g?.toString(),error:A?R().unknownPriceError.impactTitle:void 0},onClickToken:()=>n("to"),disabled:o==="failed",loading:o==="loading",tooltipContainer:I()}))}i(Sl,"Inputs");import{useCallback as Vw,useEffect as Kw,useRef as jw,useState as Xw}from"react";function jf(){let{fetch:t,loading:e,cancelFetch:o}=gi({request:async(n,r)=>await xt().getAllRoutes(n,r)});return{fetch:t,loading:e,cancelFetch:o}}i(jf,"useFetchAllQuotes");var Yw=600;function Ii({refetchQuote:t}){let{fetch:e,cancelFetch:o}=jf(),{excludeLiquiditySources:n,routing:r}=y().config,{connectedWallets:a}=y(),{fromToken:s,toToken:l,inputAmount:c,inputUsdValue:p,selectedQuote:u,sortStrategy:d,resetQuote:h,error:g,warning:f,setSelectedQuote:m,updateQuotePartialState:C}=O(),{slippage:S,customSlippage:k,affiliatePercent:T,affiliateRef:v,affiliateWallets:b,fetchStatus:A}=y(),D=y().getLiquiditySources(),w=y().getDisabledLiquiditySources(),x=y().excludeLiquiditySources(),{findToken:E}=y(),[N,M]=Xw(!0),W=jw(c),j=k??S,J=!s||!l||Mt(s,l)||!cn(c),L=i(z=>{M(z)},"resetState"),X=i(z=>{let{fromToken:me,toToken:vt,inputAmount:Ze,liquiditySources:le,excludeLiquiditySources:at,disabledLiquiditySources:G,slippage:P,affiliateRef:q,affiliatePercent:V,affiliateWallets:fe}=z;if(N||L(!0),!J&&me&&vt){h();let ne=cu({fromToken:me,toToken:vt,inputAmount:Ze,liquiditySources:le,excludeLiquiditySources:at,disabledLiquiditySources:G,wallets:a,slippage:P,affiliateRef:q,affiliatePercent:V,affiliateWallets:fe});Wo("experimental",r)&&(ne.experimental=!0),Wo("avoidNativeFee",r)&&(ne.avoidNativeFee=!0),Wo("enableCentralizedSwappers",r)&&(ne.enableCentralizedSwappers=!0),r?.maxLength&&(ne.maxLength=r.maxLength),e(ne).then(ge=>{let Fe=Mr(d,ge.results),ve=Zp(u,Fe,ge.requestAmount);M(!1),C("quotes",ge),m(ve),hi({diagnosisMessages:ge.diagnosisMessages,requestId:ve?.requestId||"",swaps:ve?.swaps});let mt=ve&&Fo({currentQuote:ve,userSlippage:j,findToken:E});C("warning",mt)}).catch(ge=>{let{error:Fe}=yi(ge);(Fe?.type===0||Fe?.type===1)&&h(),Fe?.type!==2&&(C("error",Fe),M(!1))})}},"fetch"),se=Vw(Ac(z=>{X(z)},Yw),[J]);return Kw(()=>{if(!t){M(!1);return}if(A!=="success")return;if(J){M(!1),(u||g||f)&&h();return}if(!cn(c)||p?.eq(0)){L(!1),o();return}h(),L(!0);let z=X;return W.current&&W.current!=c&&(z=se),W.current=c,z({inputAmount:c,fromToken:s,toToken:l,liquiditySources:D,excludeLiquiditySources:x,disabledLiquiditySources:w,slippage:j,affiliateRef:v,affiliatePercent:T,affiliateWallets:b}),o},[A,c,s?.symbol,s?.address,s?.blockchain,l?.symbol,l?.address,l?.blockchain,J,D?.length,n,w.length,j,v,T,JSON.stringify(b)]),{fetch:()=>X({inputAmount:c,fromToken:s,toToken:l,liquiditySources:D,excludeLiquiditySources:x,disabledLiquiditySources:w,slippage:j,affiliateRef:v,affiliatePercent:T,affiliateWallets:b}),loading:N}}i(Ii,"useSwapInput");function Xf(t,e){let o=!1,n={preventDefault(){o=!0},...t.payload===void 0&&{payload:t.payload}};he.emit("uiEvent",{type:t.type,payload:n}),o||e()}i(Xf,"emitPreventableEvent");var nb=Rw("div",{display:"flex",alignItems:"flex-start",maxHeight:700,"& .footer__alert":{paddingTop:"0 !important"}}),rb=300;function Rf(){let t=ob(),{fromToken:e,toToken:o,inputAmount:n,selectedQuote:r,refetchQuote:a,error:s,warning:l,quotes:c,setSelectedQuote:p,resetQuoteWallets:u,setQuoteWarningsConfirmed:d,updateQuotePartialState:h}=O(),[g,f]=Jf(!1),{isLargeScreen:m,isExtraLargeScreen:C}=si(),{fetch:S,loading:k}=Ii({refetchQuote:a}),{config:T,fetchStatus:v,connectedWallets:b}=y(),{isActiveTab:A}=re(),[D,w]=Jf(!1),E=iu({fetchMetaStatus:v,fetchingQuote:k,inputAmount:n,quote:r,anyWalletConnected:b.length>0,error:s,warning:l,needsToWarnEthOnPath:!1}),N=Kc(m,C,T?.variant),M=!!n&&!!e&&!!o&&new tb(n).gt(0)&&!hu(e,o),W=M&&v==="success"&&k,J=(!N||N&&c?.results.length)&&(l||s);Zf(()=>{u(),h("refetchQuote",!0)},[]),Zf(()=>{f(M)},[M]);let L=(r||s)&&!D?S:void 0,X=i(z=>{N&&g?(f(!1),setTimeout(()=>{t(z)},rb)):t(z)},"onHandleNavigation"),se=i(z=>{r?.requestId!==z.requestId&&(w(!1),p(z))},"onClickOnQuote");return qe.createElement(nb,null,qe.createElement(oe,{height:"auto",footer:qe.createElement(Jw,{id:`widget-swap-${E.action}-btn`,type:"primary",size:"large",disabled:E.disabled||!A,prefix:E.action==="confirm-warning"&&qe.createElement(eb,null),fullWidth:!0,onClick:()=>{E.action==="connect-wallet"?Xf({type:"clickConnectWallet"},()=>X($.wallets)):E.action==="confirm-warning"?w(!0):X($.confirmSwap)}},E.title),header:{onWallet:()=>{X($.wallets)},hasBackButton:!1,title:T.title||Zw.t("Swap"),suffix:qe.createElement(go,{hidden:N?["refresh"]:void 0,onClickRefresh:L,onClickHistory:()=>X($.swaps),onClickSettings:()=>{X($.settings)}})}},qe.createElement(ie,null,qe.createElement(Sl,{fetchingQuote:W,fetchMetaStatus:v,isExpandable:N,onClickToken:z=>{X(z==="from"?$.fromSwap:$.toSwap)}}),qe.createElement(Yf,{size:"2"}),N?null:qe.createElement(Co,{quote:r,loading:W,error:s,tagHidden:!1,warning:l,type:"basic",onClickAllRoutes:c&&c.results.length>1?()=>{h("refetchQuote",!1),X($.routes)}:void 0}),J?qe.createElement(qe.Fragment,null,qe.createElement(Yf,{size:"10"}),qe.createElement(Wn,{warning:l,error:s,couldChangeSettings:!0,refetchQuote:S,showWarningModal:D,confirmationDisabled:!A,onOpenWarningModal:()=>w(!0),onCloseWarningModal:()=>w(!1),onConfirmWarningModal:()=>{w(!1),d(!0),X($.confirmSwap)},onChangeSettings:()=>X($.settings)})):null,qe.createElement(ul,null))),N?qe.createElement(fl,{loading:W,onClickOnQuote:se,fetch:S,onClickRefresh:L,isVisible:g}):null)}i(Rf,"Home");import{i18n as eg}from"@lingui/core";import{Alert as ib,Divider as ab,List as sb,ListItemButton as lb,Radio as cb,RadioRoot as pb,Typography as ub}from"@rango-dev/ui";import Wt from"react";function Rt(){let{setLanguage:t,language:e,config:o}=y(),n=Jc,r=o?.language||Bo;return{activeLanguage:e||r,languages:n,defaultLanguage:r,changeLanguage:a=>t(a||Bo),resetLanguage:()=>t(null)}}i(Rt,"useLanguage");function tg(){let{activeLanguage:t,changeLanguage:e,languages:o}=Rt(),n=je(),r=o.map(a=>{let{local:s,label:l,SVGFlag:c}=a;return{id:`widget-setting-languages-${s}-item-btn`,value:s,title:Wt.createElement(ub,{variant:"title",size:"xmedium"},l),onClick:()=>{e(a.local),n()},end:Wt.createElement(cb,{value:s}),start:Wt.createElement(c,null)}});return Wt.createElement(oe,{header:{title:eg.t("Language")}},Wt.createElement(ie,null,Wt.createElement(ib,{type:"warning",variant:"alarm",title:"Warning: We are using machine translation, so the translations may be inaccurate."}),Wt.createElement(ab,{size:"8"}),Wt.createElement(pb,{value:t},Wt.createElement(sb,{type:Wt.createElement(lb,{title:eg.t("language"),id:"_",onClick:()=>console.log()}),items:r}))))}i(tg,"LanguagePage");import{i18n as zt}from"@lingui/core";import{Button as hb,Checkbox as yb,Image as Sb,ListItemButton as Cb,NotFound as kb,Typography as Tb}from"@rango-dev/ui";import Ge,{useState as vb}from"react";import{Checkbox as fb,Skeleton as ng}from"@rango-dev/ui";import Yn from"react";import{styled as Cl}from"@rango-dev/ui";var Xn=Cl("ul",{padding:"$15 $5 0",margin:0,listStyle:"none",height:"100%",overflowY:"auto",variants:{disabled:{true:{pointerEvents:"none"}}}}),kl=Cl("div",{width:80,display:"flex",justifyContent:"flex-end"}),Tl=Cl("div",{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%"});import{ListItem as db,styled as mb}from"@rango-dev/ui";var og=mb(db,{height:61});var gb=30;function vl(){return Yn.createElement(Xn,null,Array.from(Array(gb),(t,e)=>Yn.createElement(og,{hasDivider:!0,key:e,start:Yn.createElement(ng,{variant:"circular",width:35,height:35}),title:Yn.createElement(ng,{variant:"text",size:"large",width:90}),end:Yn.createElement(fb,{checked:!1})})))}i(vl,"LoadingLiquiditySourceList");function wl({sourceType:t}){let e=y().fetchStatus,o=y().swappers(),n=y().getDisabledLiquiditySources(),[r,a]=vb(""),s=y().toggleLiquiditySource,l=y().isInCampaignMode(),c=kr(o,n),p={Exchanges:zt.t("Exchanges"),Bridges:zt.t("Bridges")},u=[];t==="Exchanges"&&u.push("DEX"),t==="Bridges"&&u.push("BRIDGE","AGGREGATOR","OFF_CHAIN");let d=c.filter(S=>u.includes(S.type)),h=d.length===d.filter(S=>S.selected).length,g=i(()=>{d.forEach(S=>{h?s(S.groupTitle):S.selected||s(S.groupTitle)})},"toggleAllSources"),f=d.map(S=>{let{selected:k,groupTitle:T,logo:v,id:b,...A}=S;return{id:`widget-setting-liquidity-source-${b.toLowerCase().replace(/\s+/g,"-")}-item-btn`,start:Ge.createElement(Sb,{src:v,size:22,type:"circular"}),onClick:()=>{l||s(T)},end:Ge.createElement(yb,{checked:k,disabled:l}),title:Ge.createElement(Tb,{variant:"title",size:"xmedium"},zt.t(T)),selected:k,groupTitle:T,logo:v,...A}}),m=i(S=>{let k=S.target.value;a(k)},"handleSearch"),C=f;return r&&(C=f.filter(S=>wt(S.groupTitle,r))),Ge.createElement(oe,{header:{title:zt.t(t),suffix:Ge.createElement(kl,null,Ge.createElement(hb,{id:`widget-liquidity-source-${h?"deselect-all":"select-all"}-btn`,variant:"ghost",size:"xsmall",onClick:g},h?zt.t("Deselect all"):zt.t("Select all")))}},Ge.createElement(ie,{view:!0},Ge.createElement(Ct,{value:r,setValue:a,fullWidth:!0,color:"light",variant:"contained",placeholder:zt.t("Search {sourceType}",{sourceType:p[t]}),onChange:m}),e==="loading"&&Ge.createElement(vl,null),!C.length&&r?Ge.createElement(Tl,null,Ge.createElement(kb,{title:zt.t("No results found"),description:zt.t("Try using different keywords")})):e==="success"&&Ge.createElement(Xn,{disabled:l},C.map(S=>{let{groupTitle:k,...T}=S;return Ge.createElement(Ge.Fragment,{key:S.id},Ge.createElement(Cb,{style:{height:"61px"},...T,selected:!1,hasDivider:!0}))}))))}i(wl,"LiquiditySourcePage");import{i18n as wb}from"@lingui/core";import Ai from"react";import{useNavigate as bb}from"react-router-dom";function rg(){let t=bb(),e=je(),{selectedQuote:o,refetchQuote:n,setSelectedQuote:r,updateQuotePartialState:a,error:s}=O(),{fetch:l,loading:c}=Ii({refetchQuote:n}),p=i(h=>{r(h),a("refetchQuote",!1),e()},"onClickOnQuote"),u=`../${$.settings}`,d=`../${$.wallets}`;return Ai.createElement(oe,{header:{onWallet:()=>{t(d),a("refetchQuote",!0)},onBack:()=>{a("refetchQuote",!1)},title:wb.t("Routes"),suffix:Ai.createElement(go,{onClickRefresh:o||s?l:void 0,hidden:["notifications","history"],onClickSettings:()=>{t(u),a("refetchQuote",!0)}})}},Ai.createElement(ie,null,Ai.createElement(Kn,{fetch:l,loading:c,onClickOnQuote:p})))}i(rg,"RoutesPage");import{i18n as ug}from"@lingui/core";import{Divider as dg,getCategoriesCount as Pb,SelectableCategoryList as _b}from"@rango-dev/ui";import Qt,{useState as mg}from"react";import{useNavigate as Db}from"react-router-dom";import{i18n as bl}from"@lingui/core";import{Divider as Ab,Image as Nb,ListItemButton as Wb,NotFound as Bb,Typography as pg}from"@rango-dev/ui";import nt,{useEffect as Mb,useState as Lb}from"react";var ig=i((t,e,o)=>t.filter(n=>dr(n.type,o)).filter(n=>Je(n.name,e)||Je(n.displayName,e)),"filterBlockchains");import{ImageContainer as xb,styled as ag}from"@rango-dev/ui";var sg=ag("div",{display:"flex",flexDirection:"column",overflow:"hidden",height:"100%",justifyContent:"center"}),Ni=ag(bn,{padding:0,margin:0,listStyle:"none",[`& ${xb}`]:{borderRadius:"$xm",overflow:"hidden"}});import{ListItem as Eb,Skeleton as lg}from"@rango-dev/ui";import Wi from"react";var Ib=20;function cg(){return Wi.createElement(Ni,null,Array.from(Array(Ib),t=>Wi.createElement(Eb,{key:t,hasDivider:!0,start:Wi.createElement(lg,{variant:"circular",width:35,height:35}),title:Wi.createElement(lg,{variant:"text",size:"large",width:90})})))}i(cg,"LoadingBlockchainList");function xl(t){let{list:e,searchedFor:o,onChange:n,blockchainCategory:r,showTitle:a=!0}=t,[s,l]=Lb(e),{fetchStatus:c}=y();Mb(()=>{l([...ig(e,o,r)])},[e,o,r]);let p=i(()=>!s.length&&o?nt.createElement(Bb,{title:bl.t("No results found"),description:bl.t("Try using different keywords")}):nt.createElement(Ni,{as:"ul",key:`${r}-${o}`},s.map(u=>nt.createElement(Wb,{key:`${u.name}-${u.chainId}`,className:"widget-blockchain-list-item-btn",hasDivider:!0,onClick:()=>n(u),start:nt.createElement(Nb,{src:u.logo,size:30}),title:nt.createElement(pg,{variant:"title",size:"medium"},u.displayName),id:u.name}))),"renderList");return nt.createElement(nt.Fragment,null,a&&nt.createElement(nt.Fragment,null,nt.createElement(pg,{variant:"label",size:"large"},bl.t("Select Chain")),nt.createElement(Ab,{size:4})),nt.createElement(sg,null,c==="loading"&&nt.createElement(cg,null),c==="success"&&p()))}i(xl,"BlockchainList");function Bi(t){let{type:e}=t,o=je(),[n,r]=mg(""),[a,s]=mg("ALL"),l=O.use.setToBlockchain(),c=O.use.setFromBlockchain(),{fetchStatus:p}=y(),u=Db(),d=y().blockchains({type:e}),h=Pb(d),g=!t.hideCategory&&h!==1;return Qt.createElement(oe,{header:{title:ug.t("Select Chain")}},Qt.createElement(ie,{view:!0},g&&Qt.createElement(Qt.Fragment,null,Qt.createElement(_b,{setCategory:s,category:a,blockchains:d,isLoading:p==="loading"}),Qt.createElement(dg,{size:24})),Qt.createElement(Ct,{value:n,autoFocus:!0,placeholder:ug.t("Search Chain"),color:"light",variant:"contained",size:"large",setValue:()=>r(""),onChange:f=>r(f.target.value)}),Qt.createElement(dg,{size:16}),Qt.createElement(xl,{list:d,showTitle:e!=="custom-token",searchedFor:n,blockchainCategory:a,onChange:f=>{e==="custom-token"?u(`..?blockchain=${f.name}`,{replace:!0}):(e==="source"?c(f):l(f),o())}})))}i(Bi,"SelectBlockchainPage");import{i18n as Li}from"@lingui/core";import{Divider as Cg}from"@rango-dev/ui";import wo,{useState as qb}from"react";import{useNavigate as Gb}from"react-router-dom";import{i18n as Al}from"@lingui/core";import{BlockchainsChip as Mi,Divider as yg,Image as Sg,Skeleton as zb,Tooltip as Qb,Typography as Nl}from"@rango-dev/ui";import Pe from"react";import{useEffect as Ob}from"react";var fg=["ETH","COSMOS","OSMOSIS"];function El(t,e,o){let n=JSON.parse(JSON.stringify(t)),r=[];if(n.sort($b),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 c=0;c<=l;c++){let p=n[c];s=s.filter(u=>p.name!==u)}}n.sort(Fb(s)),r=n.splice(a)}return{list:n,more:r}}i(El,"prepare");function $b(t,e){let o=fg,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($b,"sortByMostUsedBlockchains");function Fb(t){return i(function(o,n){let r=t.findIndex(c=>c===o.name),a=t.findIndex(c=>c===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(Fb,"generateSortByPreferredBlockchainsFor");function gg(t,e){return!!e.list.find(o=>o.name===t)}i(gg,"isInVisibleList");function Il(t,e){let{preferredBlockchains:o,addPreferredBlockchain:n}=y();Ob(()=>{if(e?.selected){let a=El(t,o,e);gg(e.selected,a)||n(e?.selected)}},[e?.selected]);let r=El(t,o,e);return{list:r.list,more:r.more,history:[]}}i(Il,"usePrepareBlockchainList");import{styled as Ub}from"@rango-dev/ui";var hg=Ub("div",{display:"grid",gap:"$10",gridTemplateColumns:"repeat(6, minmax(0, 1fr))"});var Hb=12;function Wl(t){let{blockchains:e,type:o,blockchain:n,onChange:r,onMoreClick:a}=t,s=Il(e,{limit:10,selected:n?.name}),{fetchStatus:l}=y(),c=O.use.resetToBlockchain(),p=O.use.resetFromBlockchain(),u=s.more.length>0,d=s.more.length===1,h=!d&&u;return Pe.createElement(Pe.Fragment,null,Pe.createElement(yg,{size:12}),Pe.createElement(Nl,{variant:"label",size:"large"},Al.t("Select Chain")),Pe.createElement(yg,{size:12}),Pe.createElement(hg,null,l==="loading"&&Array.from(Array(Hb),g=>Pe.createElement(zb,{key:g,variant:"rounded",height:50})),l==="success"&&Pe.createElement(Pe.Fragment,null,Pe.createElement(Mi,{selected:!n,onClick:()=>{o==="from"?p():c()}},Pe.createElement(Nl,{variant:"body",size:"xsmall",color:"secondary500"},Al.t("All"))),s.list.map(g=>Pe.createElement(Qb,{key:g.name,content:g.shortName,side:"bottom",sideOffset:2,container:I()},Pe.createElement(Mi,{key:g.name,selected:!!n&&n.name===g.name,onClick:()=>r(g)},Pe.createElement(Sg,{src:g.logo,size:30})))),d?Pe.createElement(Mi,{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,h?Pe.createElement(Mi,{onClick:a,key:"more-blockchains"},Pe.createElement(Nl,{variant:"body",size:"xsmall",color:"secondary500"},Al._("More +{count}",{count:s.more.length}))):null)))}i(Wl,"BlockchainsSection");function Bl(t){let{type:e}=t,o=Gb(),n=je(),{fromBlockchain:r,toBlockchain:a,setFromToken:s,setToToken:l,setFromBlockchain:c,setToBlockchain:p}=O(),{getBalanceFor:u}=y(),[d,h]=qb(""),f=(e==="source"?r:a)?.name??"",m=y().blockchains({type:e}),C=y().tokens({type:e,blockchain:f,searchFor:d,getBalanceFor:u}),S=i(v=>{e==="source"?c(v):p(v)},"updateBlockchain"),k=i(v=>{e==="source"?s({token:v,meta:{blockchains:m,tokens:C}}):l({token:v,meta:{blockchains:m,tokens:C}})},"updateToken"),T={source:Li.t("Source"),destination:Li.t("Destination")};return wo.createElement(oe,{header:{title:Li.t("Swap {type}",{type:T[e]})}},wo.createElement(ie,null,wo.createElement(Wl,{blockchains:m,type:e=="source"?"from":"to",blockchain:e==="source"?r:a,onMoreClick:()=>o($.blockchains),onChange:v=>{S(v)}}),wo.createElement(Cg,{size:24}),wo.createElement(Ct,{value:d,autoFocus:!0,placeholder:Li.t("Search Token"),color:"light",variant:"contained",size:"large",setValue:()=>h(""),onChange:v=>h(v.target.value)}),wo.createElement(Cg,{size:16}),wo.createElement(zn,{list:C,selectedBlockchain:f,searchedFor:d,type:e,onChange:v=>{k(v);let b=m.find(A=>v.blockchain===A.name);b&&S(b),n()}})))}i(Bl,"SelectSwapItemsPage");import{i18n as Pl}from"@lingui/core";import{Alert as yx,Button as Sx,styled as Cx}from"@rango-dev/ui";import bo from"react";import{useInRouterContext as kx,useSearchParams as Tx}from"react-router-dom";import{i18n as xg}from"@lingui/core";import{Divider as Eg,InfoIcon as Xb,SlippageIcon as Yb,TextField as Zb,Tooltip as Jb,Typography as Ig}from"@rango-dev/ui";import rt from"react";import{Chip as Vb,styled as Zn,TextField as Kb}from"@rango-dev/ui";var kg=Zn("div",{paddingTop:"$5",padding:"$10 $5"}),Tg=Zn("div",{display:"flex",flexWrap:"wrap",gap:"$10",[`& ${Kb}`]:{flex:"1 1 0",maxWidth:"127px",minWidth:"85px"}}),vg=Zn("div",{display:"flex",justifyContent:"start",alignItems:"center",paddingBottom:"$10"}),Pi=Zn("div",{maxWidth:"280px",padding:"$10"}),wg=Zn(Vb,{width:"61px",flexShrink:0});import{i18n as Ml}from"@lingui/core";import{Typography as jb}from"@rango-dev/ui";import Jn from"react";function bg(){return Jn.createElement(Pi,null,Jn.createElement(jb,{variant:"label",size:"medium",color:"neutral700"},Ml.t("Your transaction will be reverted if the price changes unfavorably by more than this percentage."),Jn.createElement("br",null),Jn.createElement("br",null),Jn.createElement("b",null,Ml.t("Warning")),":\xA0",Ml.t("This setting is applied to each step (e.g. 1Inch, Thorchain, etc.), meaning only that specific step will be reverted, not the entire route.")))}i(bg,"SlippageTooltipContent");function Ll(){let{slippage:t,setSlippage:e,customSlippage:o,setCustomSlippage:n}=y();return rt.createElement(kg,null,rt.createElement(vg,null,rt.createElement(Yb,{size:16,color:"gray"}),rt.createElement(Eg,{direction:"horizontal",size:4}),rt.createElement(Ig,{variant:"title",size:"xmedium"},xg.t("Slippage tolerance per swap")),rt.createElement(Eg,{direction:"horizontal",size:4}),rt.createElement(Jb,{container:I(),side:"top",sideOffset:4,content:rt.createElement(bg,null)},rt.createElement(Xb,{color:"gray"}))),rt.createElement(Tg,null,Rc.map((r,a)=>{let s=`slippage-${a}`;return rt.createElement(wg,{key:s,onClick:()=>{o&&n(null),e(r)},selected:!o&&r===t,label:`${r.toString()}%`})}),rt.createElement(Zb,{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>=np&&s<=op?n(s):n(null)},suffix:o&&rt.createElement(Ig,{variant:"body",size:"small"},"%"),placeholder:xg.t("Custom")})))}i(Ll,"Slippage");import{i18n as dt}from"@lingui/core";import{AutoThemeIcon as Ag,BridgesIcon as Rb,ChevronRightIcon as _i,DarkModeIcon as Ng,Divider as Rn,ExchangeIcon as ex,InfinityIcon as tx,InfoIcon as ox,LanguageIcon as nx,LightModeIcon as Wg,List as rx,ListItem as ix,ListItemButton as ax,Skeleton as sx,styled as lx,Switch as cx,Tabs as px,TargetIcon as ux,Tooltip as dx,Typography as Ye}from"@rango-dev/ui";import _ from"react";import{useNavigate as mx}from"react-router-dom";var fx=lx("div",{width:"202px",height:"$40"}),gx=[{id:"light",icon:_.createElement(Wg,{color:"black",size:24}),tooltip:_.createElement(Ye,{size:"xsmall",variant:"body"},dt.t("Light"))},{id:"dark",icon:_.createElement(Ng,{color:"black",size:24}),tooltip:_.createElement(Ye,{size:"xsmall",variant:"body"},dt.t("Dark"))},{id:"auto",icon:_.createElement(Ag,{color:"black",size:24}),tooltip:_.createElement(Ye,{size:"xsmall",variant:"body"},dt.t("Auto"))}],hx=i(t=>{let e={color:"gray",size:16};switch(t){case"auto":return _.createElement(Ag,{...e});case"dark":return _.createElement(Ng,{...e});default:return _.createElement(Wg,{...e})}},"getThemeIcon");function Bg(){let t=mx(),{theme:e}=y().config,{setTheme:o,theme:n}=y(),{activeLanguage:r,languages:a}=Rt(),s=a.find(L=>L.local===r)?.label,l=y().fetchStatus,c=y().swappers(),p=y().getDisabledLiquiditySources(),{config:{features:u}}=y(),d=y().customTokens(),h=Ve("theme",u),g=Ve("liquiditySource",u),f=Ve("language",u),m=Ve("customTokens",u),C=y().infiniteApprove,S=y().toggleInfiniteApprove,k=kr(c,p),T=k.filter(L=>["BRIDGE","AGGREGATOR","OFF_CHAIN"].includes(L.type)),v=T.length,b=T.filter(L=>L.selected).length,A=k.filter(L=>L.type==="DEX"),D=A.length,w=A.filter(L=>L.selected).length,x=i((L,X)=>{switch(l){case"loading":return _.createElement(sx,{variant:"text",size:"medium",width:50});case"failed":return _.createElement(Ye,{variant:"body",size:"medium",color:"$error500"},dt.t("Loading failed"));default:return _.createElement(Ye,{variant:"body",size:"medium"},`${L} / ${X}`)}},"handleSwapperEndItem"),E={id:"widget-setting-bridge-item-btn",title:_.createElement(Ye,{variant:"title",size:"xmedium"},dt.t("Bridges")),end:_.createElement(_.Fragment,null,x(b,v),_.createElement(Rn,{direction:"horizontal",size:8}),_.createElement(_i,{color:"black"})),onClick:()=>t($.bridges),start:_.createElement(Rb,{color:"gray",size:16})},N={id:"widget-setting-exchange-item-btn",title:_.createElement(Ye,{variant:"title",size:"xmedium"},dt.t("Exchanges")),end:_.createElement(_.Fragment,null,x(w,D),_.createElement(Rn,{direction:"horizontal",size:8}),_.createElement(_i,{color:"black"})),start:_.createElement(ex,{color:"gray",size:16}),onClick:()=>t($.exchanges)},M={id:"widget-setting-custom-tokens-item-btn",title:_.createElement(Ye,{variant:"title",size:"xmedium"},dt.t("Custom Tokens")),end:_.createElement(_.Fragment,null,_.createElement(Ye,{variant:"body",size:"medium"},`${d.length}`),_.createElement(Rn,{direction:"horizontal",size:8}),_.createElement(_i,{color:"black"})),start:_.createElement(ux,{color:"gray",size:16}),onClick:()=>t($.customTokens)},W={id:"widget-setting-language-item-btn",title:_.createElement(Ye,{variant:"title",size:"xmedium"},dt.t("Language")),start:_.createElement(nx,{color:"gray",size:16}),end:_.createElement(_.Fragment,null,_.createElement(Ye,{variant:"body",size:"medium"},s),_.createElement(Rn,{direction:"horizontal",size:8}),_.createElement(_i,{color:"black"})),onClick:()=>t($.languages)},j={id:"widget-setting-infinite-approval-item-btn",title:_.createElement(_.Fragment,null,_.createElement(Ye,{variant:"title",size:"xmedium"},dt.t("Infinite approval")),_.createElement(Rn,{direction:"horizontal",size:4}),_.createElement(dx,{side:"top",sideOffset:4,container:I(),content:_.createElement(Pi,null,_.createElement(Ye,{variant:"label",size:"medium",color:"neutral700"},_.createElement("b",null,dt.t("Warning")),":\xA0",dt.t("Enabling the 'Infinite approval' mode grants unrestricted access to underlying smart contracts, allowing them to utilize the approved token amount without limitations.")))},_.createElement(ox,{color:"gray"}))),start:_.createElement(tx,{color:"gray",size:16}),end:_.createElement(cx,{checked:C}),onClick:S},te={id:"widget-setting-theme-item-btn",type:_.createElement(ix,null),title:_.createElement(Ye,{variant:"title",size:"xmedium"},dt.t("Theme")),end:_.createElement(fx,null,_.createElement(px,{container:I(),items:gx,value:n,onChange:L=>o(L.id),type:"primary",borderRadius:"small"})),start:hx(n)},J=g?[]:[E,N];return m||J.push(M),f||J.push(W),J.push(j),!e?.singleTheme&&!h&&J.push(te),_.createElement(rx,{type:_.createElement(ax,{hasDivider:!0,id:"_",onClick:()=>console.log()}),items:J})}i(Bg,"SettingsLists");var vx=Cx("div",{paddingLeft:"$8"});function Mg(){let{isInCampaignMode:t,updateCampaignMode:e}=y(),o=t(),[,n]=Tx(),r=kx(),a=i(()=>{r&&o&&(n(s=>(s.delete("liquiditySources"),s),{replace:!0}),e("liquiditySources",void 0))},"onClick");return bo.createElement(oe,{header:{title:Pl.t("Settings")}},bo.createElement(ie,null,o&&bo.createElement(yx,{type:"info",variant:"alarm",title:Pl.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:bo.createElement(vx,null,bo.createElement(Sx,{id:"widget-setting-exit-campaign-mode-btn",type:"secondary",size:"small",onClick:a},Pl.t("Reset")))}),bo.createElement(Ll,null),bo.createElement(Bg,null)))}i(Mg,"SettingsPage");import{i18n as cE}from"@lingui/core";import{cancelSwap as pE}from"@rango-dev/queue-manager-rango-preset";import{useManager as uE}from"@rango-dev/queue-manager-react";import{Alert as dE}from"@rango-dev/ui";import Yl from"react";import{useParams as mE}from"react-router-dom";import{i18n as it}from"@lingui/core";import{getCurrentNamespaceOfOrNull as qx,getCurrentStep as Gx,getRelatedWalletOrNull as Vx}from"@rango-dev/queue-manager-rango-preset";import{Button as ph,CopyIcon as Kx,Divider as jx,DoneIcon as Xx,IconButton as Yx,QuoteCost as Zx,RangoExplorerIcon as Jx,StepDetails as Rx,Tooltip as uh,Typography as xo,useCopyToClipboard as eE}from"@rango-dev/ui";import{useWallets as tE}from"@rango-dev/wallets-react";import dh from"bignumber.js";import{PendingSwapNetworkStatus as Hi}from"rango-types";import K,{useEffect as mh,useRef as oE,useState as fh}from"react";import{useNavigate as nE}from"react-router-dom";import{i18n as eo}from"@lingui/core";var wx=[eo.t("Sunday"),eo.t("Monday"),eo.t("Tuesday"),eo.t("Wednesday"),eo.t("Thursday"),eo.t("Friday"),eo.t("Saturday")];function Lg(t){let e=new Date(t),o=e.getDate(),n=e.toLocaleString("default",{month:"long"}),r=e.getFullYear();return`${e.getDay()===new Date().getDay()?eo.t("Today"):`${wx[e.getDay()]} ${o} ${n} ${r}`}, ${new Date(t).toLocaleTimeString()}`}i(Lg,"timeSince");function Pg(t){return t.finishTime?Lg(parseInt(t.finishTime)):Lg(parseInt(t.creationTime))}i(Pg,"getSwapDate");import{PendingSwapNetworkStatus as Fi}from"rango-types";import Oi from"react";import{i18n as Di}from"@lingui/core";import{Button as _g,Divider as _l,MessageBox as bx}from"@rango-dev/ui";import to from"react";var Dg=i(({onCancel:t,onClose:e})=>to.createElement(to.Fragment,null,to.createElement(_l,{size:20}),to.createElement(bx,{type:"error",title:Di.t("Cancel Swap"),description:Di.t("Are you sure you want to cancel this swap?")}),to.createElement(_l,{size:32}),to.createElement(_g,{variant:"contained",id:"widget-swap-details-modal-cancel-swap-yes-btn",type:"primary",size:"large",onClick:t},Di.t("Yes, Cancel it")),to.createElement(_l,{size:12}),to.createElement(_g,{id:"widget-swap-details-modal-cancel-swap-no-btn",variant:"outlined",type:"primary",size:"large",onClick:e},Di.t("No, Continue"))),"CancelContent");import{i18n as $i}from"@lingui/core";import{Button as $g,Divider as Dl,MessageBox as xx,Typography as Ex}from"@rango-dev/ui";import Ht from"react";var Fg=i(({onDelete:t,onClose:e})=>Ht.createElement(Ht.Fragment,null,Ht.createElement(Dl,{size:20}),Ht.createElement(xx,{type:"error",title:$i.t("Delete Transaction"),description:$i.t("Are you sure you want to delete this swap?")}),Ht.createElement(Dl,{size:32}),Ht.createElement($g,{id:"widget-swap-details-modal-delete-swap-yes-btn",variant:"contained",type:"primary",size:"large",onClick:t},$i.t("Yes, Delete it")),Ht.createElement(Dl,{size:12}),Ht.createElement($g,{id:"widget-swap-details-modal-delete-swap-no-btn",variant:"outlined",type:"primary",size:"large",onClick:e},Ht.createElement(Ex,{variant:"title",size:"medium",color:"primary"},$i.t("No, Cancel")))),"DeleteContent");import{i18n as $l}from"@lingui/core";import{PendingSwapNetworkStatus as Fl}from"rango-types";var Ol={[Fl.WaitingForNetworkChange]:{type:"loading",title:$l.t("Change Network")},[Fl.WaitingForConnectingWallet]:{type:"warning",title:$l.t("Connect Wallet")},[Fl.NetworkChanged]:{type:"success",title:$l.t("Network Changed")}};import{warn as Ix}from"@rango-dev/logging-core";import{MessageBox as Ax,Wallet as Nx}from"@rango-dev/ui";import{useWallets as Wx}from"@rango-dev/wallets-react";import en,{useState as Bx}from"react";import{styled as Og}from"@rango-dev/ui";var Ug=Og("div",{display:"flex",justifyContent:"center"}),W5=Og("div",{maxWidth:280,"& ._typography":{wordWrap:"break-word",display:"block"}});var zg=i(t=>{let{type:e,title:o,currentStepWallet:n,message:r,showWalletButton:a,walletButtonDisabled:s}=t,[l,c]=Bx(),{getWalletInfo:p,state:u}=Wx(),d=n?.walletType,h=d?pn(u(d)):null,g=d?p(d):null,f=a&&!!d&&!!h&&!!g,{list:m}=ft(),C=i(()=>{if(d){let S=m.find(k=>k.type===d);S?c(S):Ix(new Error(`It seems requested wallet to be connected is not available in the list. requested wallet: ${S}`))}},"handleWalletItemClick");return en.createElement(en.Fragment,null,en.createElement(Ax,{type:e,title:o,description:r}),f&&en.createElement(Ug,null,en.createElement(Nx,{container:I(),title:g.name,image:g.img,type:d,state:h,link:g.installLink,disabled:s,onClick:C})),en.createElement(po,{wallet:l,onClose:()=>{c(void 0)}}))},"WalletStateContent");function Ul(t){let{state:e,onClose:o,onDelete:n,onCancel:r,currentStepWallet:a,message:s,walletButtonDisabled:l}=t,c=e===Fi.WaitingForNetworkChange||e===Fi.WaitingForConnectingWallet||e===Fi.NetworkChanged;return Oi.createElement(Z,{open:!!e,onClose:o,container:document.getElementById(De.SWAP_BOX_ID)||document.body},c&&Oi.createElement(zg,{type:Ol[e].type,title:Ol[e].title,currentStepWallet:a,message:s,walletButtonDisabled:l,showWalletButton:e!==Fi.WaitingForNetworkChange}),e==="delete"&&Oi.createElement(Fg,{onClose:o,onDelete:n}),e==="cancel"&&Oi.createElement(Dg,{onClose:o,onCancel:r}))}i(Ul,"SwapDetailsModal");import{i18n as er}from"@lingui/core";import{Button as zl,Divider as tr,MessageBox as Qg,TokenAmount as Mx,Typography as Hg}from"@rango-dev/ui";import Ce from"react";import{useNavigate as Lx}from"react-router-dom";function Ql(t){let{open:e,onClose:o,status:n,priceValue:r,usdValue:a,realUsdValue:s,realValue:l,token:c,chain:p,percentageChange:u,description:d,diagnosisUrl:h}=t,g=Lx(),{showProfileBanner:f}=re();return Ce.createElement(Z,{open:e,onClose:o,container:document.getElementById(De.SWAP_BOX_ID)||document.body},n==="success"?Ce.createElement(Qg,{type:"success",title:er.t("Swap Successful")},Ce.createElement(Mx,{direction:"vertical",tooltipContainer:I(),type:"output",centerAlign:!0,price:{value:r,usdValue:a,realUsdValue:s,realValue:l},token:c,chain:p,percentageChange:u}),Ce.createElement(tr,{size:12}),Ce.createElement(Hg,{variant:"body",size:"medium",color:"neutral700",align:"center"},d)):Ce.createElement(Qg,{type:"error",title:er.t("Transaction Failed"),description:d}),Ce.createElement(tr,{size:30}),n==="success"&&Ce.createElement(Ce.Fragment,null,f&&Ce.createElement(Ce.Fragment,null,Ce.createElement("img",{src:"https://raw.githubusercontent.com/rango-exchange/assets/main/banners/widget/profile.jpg",alt:"Profile Banner"}),Ce.createElement(tr,{size:30})),Ce.createElement(zl,{id:"widget-swap-details-modal-done-btn",variant:"contained",type:"primary",size:"large",onClick:()=>{g("../../")}},er.t("Done"))),Ce.createElement(tr,{size:12}),h&&Ce.createElement(Ce.Fragment,null,Ce.createElement(zl,{variant:"contained",id:"widget-swap-detail-modal-diagnosis-btn",type:"primary",size:"large",onClick:()=>window.open(h,"_blank")},er.t("Diagnosis")),Ce.createElement(tr,{size:12})),Ce.createElement(zl,{id:"widget-swap-details-modal-see-details-btn",variant:"outlined",type:"primary",size:"large",onClick:o},Ce.createElement(Hg,{variant:"title",size:"medium",color:"primary"},er.t("See Details"))))}i(Ql,"SwapDetailsCompleteModal");import Hx from"react";import{i18n as Ox}from"@lingui/core";import{Alert as ah,IconButton as Ux,LinkIcon as zx}from"@rango-dev/ui";import oo,{Fragment as Qx}from"react";import{Alert as _x,ChevronDownIcon as Dx,IconButton as $x}from"@rango-dev/ui";import on,{useState as Fx}from"react";import{css as or,darkTheme as qg,styled as qt,Typography as Px}from"@rango-dev/ui";var Gg=qt("div",{display:"flex",flexDirection:"column",flexGrow:1,overflow:"hidden"}),Ui=qt("div",{width:"100%","& ._icon-button":{"&:hover":{"& svg":{color:"$secondary550",[`.${qg} &`]:{color:"$secondary500"}}}}}),Vg=qt(bn,{padding:"$0 $20 $20 $20"}),f4=qt("div",{display:"flex",flexDirection:"column",gap:"$10"}),Kg=qt("div",{height:"450px",display:"flex",alignItems:"center",justifyContent:"center"}),g4=qt("div",{display:"flex",justifyContent:"center",width:"100%",paddingTop:"33%",flex:1}),tn=or({display:"flex",width:"100%",justifyContent:"space-between",alignItems:"center",padding:"$10 $20",borderBottom:"1px solid",$$color:"$colors$neutral300",[`.${qg} &`]:{$$color:"$colors$neutral400"},borderColor:"$$color",color:"$neutral500"}),jg=or({padding:"$5 0"}),zi=or({display:"flex",justifyContent:"center",alignItems:"center",height:"$24"}),Xg=or({display:"flex",width:"100%",padding:"$15 $20 $20",flexDirection:"column",alignItems:"start"}),Yg=or({width:"100%",padding:"0 $20 $10"}),Zg=qt("a",{fontSize:"$16",fontWeight:"$400",color:"$neutral700",display:"flex",alignItems:"center",justifyContent:"center"}),Jg=qt("div",{display:"flex",flexDirection:"column",gap:"$5"}),Qi=qt(Px,{wordBreak:"break-word"});import{styled as Hl}from"@rango-dev/ui";var Rg=Hl("div",{display:"flex",flexDirection:"column",gap:"$10"}),eh=Hl("div",{transition:"transform 0.3s ease-in-out",variants:{rotated:{true:{transform:"rotate(180deg)"}}}}),th=Hl("div",{transition:"max-height 0.3s ease-in-out",maxHeight:"0px",overflow:"hidden",variants:{open:{true:{maxHeight:"200px"}}}});function oh(t){let{message:e}=t,[o,n]=Fx(!1);return on.createElement(_x,{type:"error",title:e.shortMessage,containerStyles:{"& .footer":{paddingTop:"$0"}},action:e.detailedMessage.content&&on.createElement($x,{onClick:()=>n(r=>!r),variant:"ghost",size:"xsmall"},on.createElement(eh,{rotated:o},on.createElement(Dx,{size:12,color:"gray"}))),footer:on.createElement(th,{open:o},on.createElement(Qi,{variant:"body",size:"xsmall",color:"neutral700"},e.detailedMessage.content))})}i(oh,"FailedAlert");import{i18n as nh}from"@lingui/core";import{Alert as ql,Button as rh}from"@rango-dev/ui";import{PendingSwapNetworkStatus as Gl}from"rango-types";import nr from"react";function ih(t){let{switchNetwork:e,setNetworkModal:o,message:n,showNetworkModal:r}=t;return e?nr.createElement(ql,{type:"warning",title:n.shortMessage,action:nr.createElement(rh,{id:"widget-swap-details-warning-alert-change-network-btn",size:"xxsmall",type:"warning",onClick:()=>{o(Gl.WaitingForNetworkChange),e().catch(a=>{console.log(a)})}},nh.t("Change"))}):r===Gl.WaitingForConnectingWallet?nr.createElement(ql,{type:"warning",title:n.shortMessage,action:nr.createElement(rh,{id:"widget-swap-details-warning-alert-connect-wallet-btn",size:"xxsmall",type:"warning",onClick:()=>{o(Gl.WaitingForConnectingWallet)}},nh.t("Connect"))}):nr.createElement(ql,{type:"warning",title:n.shortMessage})}i(ih,"WarningAlert");function Vl(t){let{switchNetwork:e,showNetworkModal:o,setNetworkModal:n,message:r,step:a,hasAlreadyProceededToSign:s}=t,l=vn(a),c=a.status==="waitingForApproval"&&!l,p=a.status==="running"&&!l,u=p&&!s||c&&!a.explorerUrl?.length;return oo.createElement(Rg,null,a.explorerUrl?.map((d,h,g)=>{let f=h+d.url,m=h===g.length-1,C=(m&&p||c)&&!u,S=m&&a.status==="failed";return oo.createElement(Qx,{key:f},oo.createElement(ah,{type:m&&(C&&"loading"||S&&"error")||"success",title:d.description?`${d.description} Tx`:Ox.t("View transaction"),action:d.url&&oo.createElement(Ux,{id:"widget-swap-details-tx-link-icon-btn",variant:"ghost",size:"xsmall",onClick:()=>window.open(d.url,"_blank")},oo.createElement(zx,{size:12}))}))}),u&&oo.createElement(ah,{type:"loading",title:r.shortMessage}),a.status!=="failed"&&l&&oo.createElement(ih,{switchNetwork:e,showNetworkModal:o,setNetworkModal:n,message:r}),a.status==="failed"&&oo.createElement(oh,{message:r}))}i(Vl,"SwapDetailsAlerts");var sh=2e3;var lh=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:st(a.fromBlockchain,e)??"",image:a.fromBlockchainLogo??""},price:{value:B(l,6,6),realValue:l??""}},to:{token:{displayName:a.toSymbol,image:a.toLogo},chain:{displayName:st(a.toBlockchain,e)??"",image:a.toBlockchainLogo??""},price:{value:B(a.outputAmount||a.expectedOutputAmountHumanReadable,6,6),realValue:a.outputAmount||a.expectedOutputAmountHumanReadable||""}},swapper:{displayName:rn(a.swapperId,o)??"",image:a.swapperLogo??"",type:a.swapperType},internalSwaps:a.internalSwaps?a.internalSwaps.map(c=>({from:{chain:{displayName:st(c.fromBlockchain,e)??"",image:c.fromBlockchainLogo??""}},to:{chain:{displayName:st(c.toBlockchain,e)??"",image:c.toBlockchainLogo??""}},swapper:{displayName:rn(c.swapperId,o)??"",image:c.swapperLogo??"",type:c.swapperType}})):[],alerts:Hx.createElement(Vl,{step:a,hasAlreadyProceededToSign:r,...n})}})},"getSteps");function ch(t){if(vn(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(ch,"getStepState");function Kl(t){let{swap:e,requestId:o,onDelete:n,onCancel:r}=t,{canSwitchNetworkTo:a,connect:s,getWalletInfo:l}=tE(),c=y().blockchains(),p=y().swappers(),{findToken:u}=y(),d=O.use.retry(),h=re.use.isActiveTab(),g=nE(),[f,m]=eE(sh),C=oE(null),[S,k]=fh(null),[T,v]=fh(null),b=i(()=>{r(),k(null)},"onCancel"),A=be.use.getNotifications(),D=be.use.removeNotification(),w=A(),x=Gx(e),E=x?.networkStatus;mh(()=>{w.find(mt=>mt.requestId===e.requestId)&&(e.status==="success"||e.status==="failed"?(v(e.status),D(e.requestId)):T&&v(null))},[e.status,e.requestId]),mh(()=>{L?k(Hi.WaitingForNetworkChange):E===Hi.WaitingForConnectingWallet||E===Hi.NetworkChanged?k(E):k(null)},[E]);let N=mu(e),M=x?qx(e,x):null,W=x?Vx(e,x):null,j=Pg(e),te=fu(e),J=i(ve=>!!l(ve)?.mobileWallet,"isMobileWallet"),L=E===Hi.WaitingForNetworkChange&&!!M&&!!W?.walletType&&(J(W.walletType)||a(W.walletType,M.network)),X=L?s.bind(null,W.walletType,[{namespace:M.namespace,network:M.network}]):void 0,se=du(e,x),z=lh({swap:e,switchNetwork:X,showNetworkModal:E,setNetworkModal:k,message:se,blockchains:c,swappers:p}),me=z.length,[vt,Ze]=[e.steps[0],e.steps[me-1]],le=Ze.outputAmount||Ze.expectedOutputAmountHumanReadable,at=e.steps.reduce((ve,mt)=>ve+parseFloat(mt.feeInUsd||""),0),G=e.steps.find(ve=>ve.diagnosisUrl)?.diagnosisUrl,P=B(parseFloat(le||"0")*(Ze.toUsdPrice||0),4,4),q=B(parseFloat(e.inputAmount)*(vt.fromUsdPrice||0),4,4),V=le?new dh(le).multipliedBy(Ze.toUsdPrice||0).toString():"",fe=new dh(e.inputAmount).multipliedBy(vt.fromUsdPrice||0).toString(),ne=Pt(q,P),ge=se.detailedMessage.content||se.shortMessage,Fe=e.status==="success"?it.t({id:"You have received {amount} {token} in {conciseAddress} wallet on {chain} chain.",values:{amount:B(le,6,6),token:z[me-1].to.token.displayName,conciseAddress:Sr(e.wallets[z[me-1].to.chain.displayName]?.address||""),chain:z[me-1].to.chain.displayName}}):K.createElement(Jg,null,K.createElement(xo,{variant:"body",size:"medium",color:"neutral700",align:"center"},ge?"":it.t("Transaction was not sent."),N?`${it.t({id:"{amount} {symbol} on {blockchain} remains in your wallet.",values:{amount:N.outputAmount,symbol:N.symbol,blockchain:N.blockchain}})}`:""),ge&&K.createElement(Qi,{align:"center",variant:"body",size:"medium",color:"neutral700"},K.createElement("b",null,"Reason:")," ",ge));return K.createElement(oe,{header:{title:it.t("Swap Details"),onCancel:e.status==="running"?()=>k("cancel"):void 0,suffix:e.status!=="running"&&K.createElement(Vt,null,K.createElement(ph,{id:"widget-swap-details-delete-btn",variant:"ghost",type:"error",size:"xsmall",onClick:()=>k("delete")},K.createElement(xo,{size:"medium",variant:"label",color:"error"},it.t("Delete"))))},footer:te&&!T&&K.createElement(ph,{fullWidth:!0,id:"widget-swap-details-try-again-btn",variant:"contained",type:"primary",size:"large",onClick:()=>{let ve=Br(e,c,u);d(ve),setTimeout(()=>{g("../../")},0)}},it.t("Try again"))},K.createElement(ie,{compact:!0,view:!0},K.createElement(Ui,null,K.createElement("div",{className:tn()},K.createElement(xo,{variant:"label",size:"large",color:"neutral700"},`${it.t("Request ID")}`),K.createElement("div",{className:zi()},K.createElement(xo,{variant:"label",size:"small",color:"neutral700"},o),K.createElement(uh,{container:I(),content:f?it.t("Copied To Clipboard"):it.t("Copy Request ID"),open:f||void 0,side:"bottom",alignOffset:-16,align:"end"},K.createElement(Yx,{id:"widget-swap-details-done-copy-icon-btn",variant:"ghost",onClick:m.bind(null,o||"")},f?K.createElement(Xx,{size:16,color:"secondary"}):K.createElement(Kx,{size:16,color:"gray"}))),K.createElement(Zg,{target:"_blank",href:`${kc}/swap/${o}`},K.createElement(uh,{container:I(),content:it.t("View on Rango Explorer"),side:"bottom"},K.createElement(Jx,{size:20}))))),K.createElement("div",{className:tn()},K.createElement(xo,{variant:"label",size:"large",color:"neutral700"},e.finishTime?it.t("Finished at"):it.t("Created at")),K.createElement(xo,{variant:"label",size:"small",color:"neutral700"},j))),K.createElement("div",{className:Xg()},K.createElement(Zx,{fee:B(String(at),2,2),time:ln(mr(e.steps)),steps:me}),K.createElement(Mn,{from:{price:{value:B(e.inputAmount,6,6),usdValue:q,realUsdValue:fe,realValue:e.inputAmount},token:{displayName:z[0].from.token.displayName,image:z[0].from.token.image},chain:{image:z[0].from.chain.image,displayName:z[0].from.chain.displayName}},to:{price:{value:B(le,6,6),usdValue:P,realUsdValue:V,realValue:le||""},token:{displayName:z[me-1].to.token.displayName,image:z[me-1].to.token.image},chain:{image:z[me-1].to.chain.image,displayName:z[me-1].to.chain.displayName}},percentageChange:B(ne,2,2),warningLevel:_t(ne??0)})),K.createElement("div",{className:Yg()},K.createElement(xo,{variant:"title",size:"small"},it.t("Swaps steps"))),K.createElement(jx,{size:8}),K.createElement(Vg,{ref:C},z.map((ve,mt)=>{let nc=mt,nn=ch(e.steps[mt]),Qh=nn==="error"||nn==="in-progress"||nn==="warning"||nn==="completed"&&mt===z.length-1;return K.createElement(Rx,{key:nc,step:ve,type:"swap-progress",ref:C,state:nn,hasSeparator:mt!==0,tabIndex:nc,isFocused:Qh,tooltipContainer:I()})}))),K.createElement(Ul,{state:S,onClose:()=>k(null),onCancel:b,onDelete:n,message:se.detailedMessage.content,currentStepWallet:W,walletButtonDisabled:!h}),K.createElement(Ql,{open:!!T,diagnosisUrl:G,onClose:()=>v(null),status:e.status==="success"?"success":"failed",priceValue:B(le,6,6),usdValue:P,realUsdValue:V,realValue:le||"",percentageChange:B(ne,2,2),token:{displayName:z[me-1].to.token.displayName,image:z[me-1].to.token.image},chain:{image:z[me-1].to.chain.image},description:Fe}))}i(Kl,"SwapDetails");import{i18n as Gi}from"@lingui/core";import{Divider as yh,NotFound as lE,Skeleton as ir,Typography as Vi}from"@rango-dev/ui";import ke from"react";import{i18n as rE}from"@lingui/core";import{Divider as iE,Skeleton as aE,Typography as sE}from"@rango-dev/ui";import Te from"react";import{css as Tt,styled as jl}from"@rango-dev/ui";var gh=jl("div",{width:"100%",height:"100%",padding:"$10 $20"}),rr=jl("div",{backgroundColor:"$neutral100",borderRadius:"$xm",padding:"$10 $15"}),qi=jl("div",{width:"0px",height:"$20",borderLeft:"1px dashed $neutral700",marginLeft:"25px"}),IK=Tt({display:"flex",justifyContent:"space-between",alignItems:"center"}),AK=Tt({display:"flex",justifyContent:"space-between",alignItems:"center"}),NK=Tt({paddingTop:"$15",display:"flex"}),WK=Tt({padding:"$15 $0"}),BK=Tt({width:"0px",height:"$16",borderLeft:"1px solid $neutral400",marginLeft:"13px"}),MK=Tt({paddingBottom:"$10"}),LK=Tt({display:"flex",justifyContent:"start",alignItems:"center"}),PK=Tt({paddingTop:"$5",display:"flex",alignItems:"center"}),_K=Tt({display:"flex",alignItems:"center"}),DK=Tt({padding:"$4 $6",display:"flex",justifyContent:"center",alignItems:"center"}),hh=Tt({display:"flex",paddingTop:"$10",paddingBottom:"$5"});function Xl(){return Te.createElement(gh,null,Te.createElement(_n,{type:"swap-preview"}),Te.createElement("div",{className:"swaps-steps"},Te.createElement(sE,{variant:"title",size:"small"},rE.t("Swaps steps"))),Te.createElement(Te.Fragment,null,Te.createElement(rr,null,Te.createElement(Nt,{separator:!1}),Te.createElement("div",{className:hh()},Te.createElement(iE,{direction:"horizontal",size:20}),Te.createElement(aE,{height:22,variant:"rectangular"}))),Te.createElement(qi,null),Te.createElement(rr,null,Te.createElement(Nt,{separator:!1})),Te.createElement(qi,null),Te.createElement(rr,null,Te.createElement(Nt,{separator:!1})),Te.createElement(qi,null),Te.createElement(rr,null,Te.createElement(Nt,{separator:!1}))))}i(Xl,"LoadingSwapDetails");function Sh(t){let{requestId:e,showSkeleton:o}=t;return ke.createElement(oe,{header:{title:Gi.t("Swap Details"),suffix:ke.createElement(Vt,null)}},o&&ke.createElement(Gg,null,ke.createElement(Ui,null,ke.createElement("div",{className:tn()},ke.createElement(Vi,{variant:"label",size:"large",color:"neutral700"},`${Gi.t("Request ID")}`),ke.createElement("div",{className:zi()},ke.createElement(Vi,{variant:"label",size:"small",color:"neutral700"},ke.createElement(ir,{width:60,height:10,variant:"rounded"})),ke.createElement(yh,{direction:"horizontal",size:4}),ke.createElement(ir,{width:16,height:16,variant:"rectangular"}),ke.createElement(yh,{direction:"horizontal",size:4}),ke.createElement(ir,{width:16,height:16,variant:"rectangular"}))),ke.createElement("div",{className:tn()},ke.createElement(Vi,{className:jg(),variant:"label",size:"large",color:"neutral700"},ke.createElement(ir,{width:60,height:10,variant:"rounded"})),ke.createElement(Vi,{variant:"label",size:"small",color:"neutral700"},ke.createElement(ir,{width:60,height:10,variant:"rounded"})))),ke.createElement(Xl,null)),!o&&ke.createElement(Kg,null,ke.createElement(lE,{title:Gi.t("Not found"),description:Gi.t({id:"Swap with request ID = {requestId} not found.",values:{requestId:e}})})))}i(Sh,"SwapDetailsPlaceholder");function Ch(){let{manager:t,state:e}=uE(),o=!e.loadedFromPersistor,n=pt(t),{requestId:r}=mE(),a=je(),{fetchStatus:s}=y();if(!r)return Yl.createElement(dE,{containerStyles:{margin:"20px"},type:"error",title:cE.t("The request ID is necessary to display the swap details.")});let l=o||s==="loading",c=r?n.find(({swap:h})=>h.requestId===r):void 0,p=i(()=>{if(c?.id){let h=t?.get(c.id);h&&pE(h)}},"onCancel"),u=i(async()=>{if(c?.id)try{t?.deleteQueue(c.id),a()}catch(h){console.log(h)}},"onDelete"),d=c?.swap;return!d||l?Yl.createElement(Sh,{requestId:r,showSkeleton:l}):Yl.createElement(Kl,{swap:d,requestId:r,onCancel:p,onDelete:u})}i(Ch,"SwapDetailsPage");import{i18n as kh}from"@lingui/core";import{Divider as fE,getCategoriesCount as gE,SelectableCategoryList as hE,styled as vh,Typography as yE,Wallet as SE}from"@rango-dev/ui";import Bt,{useState as Th}from"react";var CE=vh("div",{display:"flex",justifyContent:"center",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5"}),kE=vh(ie,{textAlign:"center"});function wh(){let{fetchStatus:t}=y(),[e,o]=Th("ALL"),n=y().blockchains(),{config:r}=y(),[a,s]=Th(),l=re.use.isActiveTab(),{list:c}=ft(),p=Qc(c,n),d=gE(p)!==1,h=Hc(c,e),g=i(f=>{Bc(c,r.multiWallets)||s(f)},"handleWalletItemClick");return Bt.createElement(oe,{header:{title:kh.t("Connect Wallets")}},Bt.createElement(kE,null,d&&Bt.createElement(Bt.Fragment,null,Bt.createElement(hE,{setCategory:o,category:e,blockchains:p,isLoading:t==="loading"}),Bt.createElement(fE,{size:24})),Bt.createElement(yE,{variant:"title",size:"xmedium",align:"center"},kh.t("Choose a wallet to connect.")),Bt.createElement(CE,null,h.map((f,m)=>{let C=`wallet-${m}-${f.type}`;return Bt.createElement(SE,{key:C,...f,container:I(),onClick:()=>g(f),isLoading:t==="loading",disabled:!l})}),Bt.createElement(po,{wallet:a,onClose:()=>{s(void 0)}}))))}i(wh,"WalletsPage");function bh(){return Su(),$a(),TE([{path:$.home,element:_e.createElement(Rf,null)},{path:$.routes,element:_e.createElement(rg,null)},{path:$.fromSwap,children:[{index:!0,element:_e.createElement(Bl,{type:"source"})},{path:$.blockchains,element:_e.createElement(Bi,{type:"source"})}]},{path:$.toSwap,children:[{index:!0,element:_e.createElement(Bl,{type:"destination"})},{path:$.blockchains,element:_e.createElement(Bi,{type:"destination"})}]},{path:$.settings,children:[{index:!0,element:_e.createElement(Mg,null)},{path:$.languages,element:_e.createElement(tg,null)},{path:$.exchanges,element:_e.createElement(wl,{sourceType:"Exchanges"})},{path:$.bridges,element:_e.createElement(wl,{sourceType:"Bridges"})},{path:$.customTokens,children:[{index:!0,element:_e.createElement(cf,null)},{path:$.addCustomTokens,children:[{index:!0,element:_e.createElement(Ru,null)},{path:$.blockchains,element:_e.createElement(Bi,{hideCategory:!0,type:"custom-token"})}]}]}]},{path:$.swaps,children:[{index:!0,element:_e.createElement(Nf,null)},{path:$.swapDetails,element:_e.createElement(Ch,null)}]},{path:$.wallets,element:_e.createElement(wh,null)},{path:$.confirmSwap,element:_e.createElement(jm,null)}])}i(bh,"AppRoutes");import{useQueueManager as WE}from"@rango-dev/queue-manager-rango-preset";import{splitWalletNetwork as BE}from"@rango-dev/wallets-shared";import{isEvmBlockchain as ME}from"rango-sdk";import{useContext as LE,useEffect as Bh,useState as Mh}from"react";import{globalCss as vE}from"@rango-dev/ui";var xh=i(()=>vE({"@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 Eh(){let{setWatermark:t,setShowProfileBanner:e}=re();return{fetchApiConfig:i(async()=>{let n=await fetch(`${Lt("BASE_URL")}/meta/dapp/config?apiKey=${Lt("API_KEY")}`);if(!n.ok)throw new Error(`Request failed with status: ${n.status} `);let r=await n.json();t(r.config.watermark),e(r.config.banners.profile)},"fetchApiConfig")}}i(Eh,"useFetchApiConfig");import{useWallets as wE}from"@rango-dev/wallets-react";import{useEffect as bE,useRef as xE}from"react";function Ih(){let{connect:t,state:e}=wE(),o=xE({}),{fetchStatus:n}=y(),r=new URLSearchParams(location.search).get("autoConnect")||"",a=e(r);bE(()=>{n==="success"&&r&&a.installed&&!a.connecting&&!a.connected&&!o.current[r]&&(o.current[r]=!0,t(r))},[a,n])}i(Ih,"useForceAutoConnect");import{isApprovalTX as EE,RouteEventType as Ah,StepEventType as Nh,StepExecutionEventStatus as IE,WidgetEvents as Ki}from"@rango-dev/queue-manager-rango-preset";import{useEffect as Wh}from"react";function Zl(){let t=be.use.setNotification(),{connectedWallets:e,fetchBalances:o}=y();Wh(()=>{let n=i(r=>{let{event:a,step:s,route:l}=r;if(a.type===Nh.TX_EXECUTION&&a.status===IE.TX_SENT&&!EE(s)||a.type===Nh.SUCCEEDED){let p=e.find(d=>d.chain===s?.fromBlockchain),u=s?.fromBlockchain!==s?.toBlockchain&&e.find(d=>d.chain===s?.toBlockchain);p&&o([p]),u&&o([u])}t(a,l)},"handleStepEvent");return he.on(Ki.StepEvent,n),()=>he.off(Ki.StepEvent,n)},[he,e]),Wh(()=>{let n=i(r=>{let{event:a,route:s}=r;(a.type===Ah.FAILED||a.type===Ah.SUCCEEDED)&&t(a,s)},"handleRouteEvent");return he.on(Ki.RouteEvent,n),()=>he.off(Ki.RouteEvent,n)},[he])}i(Zl,"useSubscribeToWidgetEvents");import{useManager as AE}from"@rango-dev/queue-manager-react";import{useEffect as NE}from"react";function Jl(){let{isSynced:t,syncNotifications:e}=be(),{manager:o,state:n}=AE();NE(()=>{be.persist.hasHydrated()&&n.loadedFromPersistor&&!t&&e(pt(o))},[be.persist.hasHydrated(),n.loadedFromPersistor,t])}i(Jl,"useSyncNotifications");function Rl(){Ih(),xh(),Zl(),Jl();let t=y().blockchains(),{canSwitchNetworkTo:e}=Yr(),[o,n]=Mh(""),[r,a]=Mh(),s=LE(Ir),l=t.filter(ME),{fetchApiConfig:c}=Eh();Bh(()=>()=>yu(),[]),WE({lastConnectedWallet:o,clearDisconnectedWallet:()=>{a(void 0)},disconnectedWallet:r,evmChains:l,canSwitchNetworkTo:e}),Bh(()=>(ao.init(),be.persist.hasHydrated()||be.persist.rehydrate(),s.onConnectWallet(n),s.onDisconnectWallet(p=>{a(p),p===BE(o)?.[0]&&n("")}),c().catch(console.log),ao.destroy),[])}i(Rl,"useBootstrap");import{styled as PE}from"@rango-dev/ui";var Lh=PE("div",{fontFamily:"$widget",boxSizing:"border-box",textAlign:"left","& *, *::before, *::after":{boxSizing:"inherit"},"& *:focus-visible":{outlineColor:"$info500",transition:"none"},"& ul, ol, li":{listStyleType:"none"}});function ji(){Rl();let{config:t}=y(),{activeTheme:e}=Qo(t?.theme||{}),{activeLanguage:o}=Rt();return ec.createElement(_E,{language:o},ec.createElement(Lh,{id:"swap-container",className:e()},ec.createElement(bh,null)))}i(ji,"Main");import{setSolanaSignerConfig as tI}from"@rango-dev/signer-solana";import oc,{useEffect as Oh,useMemo as oI}from"react";import{useState as DE}from"react";var $E=i(()=>{let[t,e]=DE(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=Wc(a);if(s){let l=o(s);e(l)}},"handleLoadCustomFont")}},"useFontLoader"),Ph=$E;import{checkWaitingForNetworkChange as FE,makeQueueDefinition as OE}from"@rango-dev/queue-manager-rango-preset";import{Provider as UE}from"@rango-dev/queue-manager-react";import{useWallets as zE}from"@rango-dev/wallets-react";import{convertEvmBlockchainMetaToEvmChainInfo as QE}from"@rango-dev/wallets-shared";import{isEvmBlockchain as HE}from"rango-types";import qE,{useMemo as GE}from"react";function VE(t){let{providers:e,getSigners:o,state:n,connect:r,canSwitchNetworkTo:a,getWalletInfo:s}=zE(),l=GE(()=>OE({API_KEY:t.apiKey||Lt("API_KEY"),BASE_URL:Lt("BASE_URL"),emitter:{emit:he.emit}}),[t.apiKey]),{blockchains:c,connectedWallets:p}=y(),u=c(),d={blockchains:p.map(v=>({accounts:[v],name:v.chain}))},h=i(async(v,b)=>a(v,b.network)?await r(v,[b]):void 0,"switchNetwork"),g=i(v=>!!s(v).mobileWallet,"isMobileWallet"),f=u.filter(v=>v.enabled).reduce((v,b)=>(v[b.name]=b,v),{}),m=u.filter(HE),C=i(v=>{let{supportedChains:b}=s(v);return un(b)},"getSupportedChainNames"),S=e(),k={meta:{blockchains:f,evmBasedChains:m,evmNetworkChainInfo:QE(m),getSupportedChainNames:C},getSigners:o,wallets:d,providers:S,switchNetwork:h,canSwitchNetworkTo:a,state:n,isMobileWallet:g},T=re.use.isActiveTab();return qE.createElement(UE,{queuesDefs:[l],context:k,onPersistedDataLoaded:v=>{FE(v)},isPaused:!T},t.children)}i(VE,"QueueManager");var _h=VE;import{useManager as ZE}from"@rango-dev/queue-manager-react";import JE,{createContext as RE,useContext as eI}from"react";function Dh(){let{findToken:t}=y(),e=y().blockchains(),o=y().tokens(),{setFromBlockchain:n,setFromToken:r,setToBlockchain:a,setToToken:s,setInputAmount:l}=O();return i(p=>{let{fromBlockchain:u,fromToken:d,toBlockchain:h,toToken:g,requestAmount:f}=p,m={blockchains:e,tokens:o};if(u!==void 0){let C=e.find(S=>S.name===u)??null;n(C)}if(d!==void 0){let C=d?t(d)??null:null;r({meta:m,token:C})}if(h!==void 0){let C=e.find(S=>S.name===h)??null;a(C)}if(g!==void 0){let C=g?t(g)??null:null;s({meta:m,token:C})}f!==void 0&&l(f)},"updateQuoteInputs")}i(Dh,"useUpdateQuoteInputs");import{cancelSwap as KE,getCurrentNamespaceOfOrNull as jE,getCurrentStep as XE,getRelatedWalletOrNull as YE}from"@rango-dev/queue-manager-rango-preset";var Xi=class{static{i(this,"WidgetHistory")}constructor(e,o){this.manager=e,this.actions=o}getAllSwaps(){return pt(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=Br(e,o.blockchains,this.actions.findToken);return this.actions.retrySwap(n)}cancel(e){let o=this.manager?.get(e);o&&KE(o)}getCurrentStepInfo(e){let o=XE(e);return{step:o,wallet:o?YE(e,o):null,network:o?jE(e,o)?.network:null}}};var $h=RE(void 0);function tc(t){let{manager:e}=ZE(),o=re.use.isActiveTab(),n=O.use.retry(),{findToken:r,getBalances:a,getConnectedWalletsDetails:s,fetchBalances:l}=y(),c=new Xi(e,{retrySwap:n,findToken:r}),{fetchingWallets:p}=y(),u=Dc(a()),d=y().blockchains(),h=y().tokens(),g=y().swappers(),f=y().fetchStatus,m=Rt().resetLanguage,C=be().getNotifications(),S=be().clearNotifications,k=Dh(),{fromBlockchain:T,toBlockchain:v,fromToken:b,toToken:A,inputAmount:D}=O(),w={isActiveTab:o,setCurrentTabAsActive:ao.forceClaim,history:c,wallets:{isLoading:p,details:s(),totalBalance:u,refetch:async x=>l(x)},meta:{blockchains:d,tokens:h,swappers:g,loadingStatus:f,findToken:r},resetLanguage:m,notifications:{list:C,clearAll:S},quote:{quoteInputs:{fromBlockchain:T?.name??null,fromToken:b?{symbol:b.symbol,blockchain:b.blockchain,address:b.address}:null,toBlockchain:v?.name??null,toToken:A?{symbol:A.symbol,blockchain:A.blockchain,address:A.address}:null,requestAmount:D},updateQuoteInputs:k}};return JE.createElement($h.Provider,{value:w},t.children)}i(tc,"WidgetInfo");function Fh(){let t=eI($h);if(!t)throw new Error("useWidget can only be used within the WidgetProvider component");return t}i(Fh,"useWidget");function Yi(t){let{onUpdateState:e,config:o}=t,n=t.config?.theme?.fontFamily,{handleLoadCustomFont:r}=Ph();return Oh(()=>{n&&r(n)},[n]),oI(()=>{qc({API_KEY:o?.apiKey||pr,BASE_URL:o?.apiUrl||Cc})},[o.apiKey,o.apiUrl]),Oh(()=>{t.config?.signers?.customSolanaRPC&&tI("customRPC",t.config.signers.customSolanaRPC)},[t.config?.signers?.customSolanaRPC]),oc.createElement(Ar,{config:o,onUpdateState:e},oc.createElement(_h,{apiKey:o.apiKey},oc.createElement(tc,null,t.children)))}i(Yi,"WidgetProvider");function Uh(t){let e=t.config?.externalWallets;return Zi.createElement(Op,null,e?Zi.createElement(ji,null):Zi.createElement(Yi,{config:t.config??cr},Zi.createElement(ji,null)))}i(Uh,"Widget");function zh(){let{on:t,off:e}=he;return{on:t,off:e}}i(zh,"useWidgetEvents");var H3={DerivationPath:Sn,Namespaces:yn,isOnDerivationPath:kn,isOnNamespace:Cn};export{g3 as EventSeverity,Mo as MainEvents,x3 as Networks,A3 as PendingSwapNetworkStatus,da as QuoteEventTypes,h3 as RouteEventType,ta as SUPPORTED_FONTS,H3 as StatefulConnect,y3 as StepEventType,S3 as StepExecutionBlockedEventStatus,C3 as StepExecutionEventStatus,De as UI_ID,fa as UiEventTypes,ma as WalletEventTypes,w3 as WalletEvents,E3 as WalletTypes,Uh as Widget,Mo as WidgetEvents,Yi as WidgetProvider,Ar as WidgetWallets,Xa as customizedThemeTokens,T3 as readAccountAddress,Gt as useStatefulConnect,ft as useWalletList,Yr as useWallets,Fh as useWidget,zh as useWidgetEvents,Gy as widgetEventEmitter};
3
3
  //# sourceMappingURL=index.js.map