@rango-dev/widget-embedded 0.41.1-next.4 → 0.41.1

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 cy=Object.defineProperty;var i=(t,e)=>cy(t,"name",{value:e,configurable:!0});import{EventSeverity as PX,RouteEventType as _X,StepEventType as DX,StepExecutionBlockedEventStatus as $X,StepExecutionEventStatus as FX}from"@rango-dev/queue-manager-rango-preset";import{legacyReadAccountAddress as UX}from"@rango-dev/wallets-core/legacy";import{useWallets as ii,Events as QX}from"@rango-dev/wallets-react";import{Networks as qX,WalletTypes as GX}from"@rango-dev/wallets-shared";import{PendingSwapNetworkStatus as KX}from"rango-types";import{Divider as rC}from"@rango-dev/ui";import yo,{useEffect as iC,useRef as aC,useState as Gp}from"react";import{WalletState as py}from"@rango-dev/ui";import{useWallets as uy}from"@rango-dev/wallets-react";import{useReducer as my}from"react";function Cc(t){return!!t.derivationPath}i(Cc,"isStateOnDerivationPathStep");function kc(t){return!!t.namespace}i(kc,"isStateOnNamespace");var ur={status:"init",namespace:null,derivationPath:null};function Tc(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 ur;case"resetDerivation":return t.namespace?{...t,derivationPath:null,status:"namespace"}:ur;default:throw new Error("Action hasn't been defined.")}}i(Tc,"reducer");function Kt(){let{state:t,disconnect:e,connect:o}=uy(),[n,r]=my(Tc,ur),a=i(async(u,m,h)=>{r({type:"reset"});try{let d=m?.map(f=>({...f,network:void 0}));return await o(u,d),{status:"connected"}}catch(d){let f=d?.message?`Error: ${d.message}`:"An unknown error happened during connecting wallet.";throw new Error(f,{cause:d})}},"runConnect"),s=i(async(u,m)=>{if(u.state===py.DISCONNECTED){if(!!u.isHub&&u.properties?.find(S=>S.name==="detached")&&u.state!=="connected")return r({type:"needsNamespace",payload:{targetWallet:u}}),{status:"namespace"};if(!u.needsNamespace)return await a(u.type,void 0,m);let f=u.needsNamespace.data.length>1,g=u.needsDerivationPath;if(f)return r({type:"needsNamespace",payload:{targetWallet:u}}),{status:"namespace"};if(g){let k=u.needsNamespace.data[0];return r({type:"needsDerivationPath",payload:{providerType:u.type,providerImage:u.image,namespace:k.value}}),{status:"derivation-path"}}return await a(u.type,u.needsNamespace?.data.map(k=>({namespace:k.value})),m)}return m?.disconnectIfConnected?(await p(u.type),{status:"disconnected"}):{status:"disconnected-unhandled"}},"handleConnect"),l=i(async(u,m)=>{let h=u.needsNamespace?.selection==="single",d=u.needsDerivationPath,f=m[0];if(!f)throw new Error("To confirm a namespace, you should select at least one namespace.");if(h&&d)return r({type:"needsDerivationPath",payload:{providerType:u.type,providerImage:u.image,namespace:f}}),{status:"derivation-path"};if(!kc(n))throw new Error("Something went wrong on handling namespace. Please retry.");let g=n.namespace.targetWallet.type,k=m.map(C=>({namespace:C}));return await a(g,k)},"handleNamespace"),c=i(async u=>{if(!u)throw new Error("Derivation path is empty. Please make sure you've filled the field correctly.");if(!Cc(n))throw new Error("It seems you are filling derivation path without setting namespace before doing that. Please retry to connect.");let m=n.derivationPath.providerType,d=[{namespace:n.derivationPath.namespace,derivationPath:u}];return await a(m,d)},"handleDerivationPath"),p=i(async u=>{let m=t(u);return m.connected||m.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(Kt,"useStatefulConnect");import{WalletState as Na}from"@rango-dev/ui";import{useWallets as vS}from"@rango-dev/wallets-react";import{detectMobileScreens as wS,KEPLR_COMPATIBLE_WALLETS as bS,WalletTypes as Cn}from"@rango-dev/wallets-shared";import{useCallback as xS,useEffect as ES}from"react";import yS,{createContext as SS,useContext as CS,useEffect as kS,useRef as TS}from"react";import{create as gS}from"zustand";import{persist as hS}from"zustand/middleware";import{allProviders as dy}from"@rango-dev/provider-all";var sa=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()}},Po=new sa;import{defineVersions as wc,pickVersion as bc,Provider as la}from"@rango-dev/wallets-core";function xc({allProviders:t,configWallets:e}){if(e){let o=[];return e.forEach(n=>{if(typeof n=="string"){let r=t.find(a=>{let s=Ec(a);return s instanceof la?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 la?o.push(wc().version("1.0.0",n).build()):o.push(wc().version("0.0.0",n).build())}),o}return t}i(xc,"matchAndGenerateProviders");function Ec(t){try{return bc(t,"1.0.0")[1]}catch{return bc(t,"0.0.0")[1]}}i(Ec,"pickProviderVersionWithFallbackToLegacy");function Ic(t){return t.map(o=>Ec(o)).map(o=>o instanceof la?o.id:o.config.type)}i(Ic,"configWalletsToWalletName");function mr(t,e){return e.find(o=>o.name===t)?.displayName}i(mr,"getBlockchainDisplayNameFor");function ut(t,e){return e.find(o=>o.name===t)?.shortName}i(ut,"getBlockchainShortNameFor");function Ac(t,e){return e.find(o=>o.name===t)?.logo}i(Ac,"getBlockchainImage");function un(t,e){return e.find(o=>o.id===t)?.title}i(un,"getSwapperDisplayName");function co(t,e){return e.find(o=>o.name===t)??null}i(co,"findBlockchain");function ca(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(ca,"isTokenNative");function mt(t){return`${t.blockchain.toLowerCase()}-${t.symbol.toLowerCase()}-${(t.address??"").toLowerCase()}`}i(mt,"createTokenHash");function _o(t,e){return t.addressPatterns.filter(r=>new RegExp(r).test(e)).length>0}i(_o,"isValidTokenAddress");function mn(t){let{config:e,meta:o}=t,n={},r=e.tokens,a=i(l=>{l.forEach(c=>{typeof c!="string"&&(c=mt(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=mt(p);delete n[u]})):a(c.tokens))}),Object.values(n)}i(mn,"matchTokensFromConfigWithMeta");function dr(t){let{config:e}=t,o=e.from?.blockchains||[],n=e.to?.blockchains||[];if(!o.length||!n.length)return[];let r=[...o,...n],a=new Set(r);return Array.from(a)}i(dr,"getSupportedBlockchainsFromConfig");function Bc(t){return{walletConnectProjectId:t?.walletConnectProjectId,trezorManifest:t?.trezorManifest,tonConnect:t?.tonConnect,walletConnectListedDesktopWalletLink:t.__UNSTABLE_OR_INTERNAL__?.walletConnectListedDesktopWalletLink}}i(Bc,"makeProvidersOptionsFromConfig");var fr={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"}},fy={clientUrl:void 0},gy={liquiditySources:void 0};function Nc(t){let e=Bc(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 dy(o).map(a=>a())}i(Nc,"generateProviders");var Wc=i((t,e,o)=>{let n=Nc({...fr,...t});return{config:{...fr,...t},iframe:fy,campaignMode:gy,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=mn({type:"source",config:{blockchains:r.from?.blockchains,tokens:r.from?.tokens},meta:{tokensMapByBlockchainName:l,tokensMapByTokenHash:s}}),p=mn({type:"destination",config:{blockchains:r.to?.blockchains,tokens:r.to?.tokens},meta:{tokensMapByBlockchainName:l,tokensMapByTokenHash:s}});Po.set("supportedSourceTokens",c),Po.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=Nc(r);e({allProviders:a})},getAvailableProviders:()=>{let{allProviders:r,config:a}=o(),s=Bc(a);return xc({allProviders:r,configWallets:a.wallets,options:s})}}},"createConfigSlice");import{TransactionType as Lc}from"rango-types";var Mc=[Lc.EVM,Lc.SOLANA],gr="https://raw.githubusercontent.com/rango-exchange/assets/refs/heads/main/common/unknown-image.png";import{RangoClient as By}from"rango-sdk";import{UI_ID as hy}from"@rango-dev/ui";var hr="c6381a79-2817-4602-83bf-6a641a409e32",Pc="https://api.rango.exchange",_c="https://explorer.rango.exchange",$e={SWAP_BOX_ID:"rango-swap-box",EXPANDED_BOX_ID:"rango-expanded-box",...hy};import{BlockchainCategories as wy,WalletState as xt}from"@rango-dev/ui";import{legacyReadAccountAddress as by}from"@rango-dev/wallets-core/legacy";import{detectInstallLink as xy,getCosmosExperimentalChainInfo as Ey,isEvmAddress as Iy,KEPLR_COMPATIBLE_WALLETS as UA,Networks as jc}from"@rango-dev/wallets-shared";import $o from"bignumber.js";import{isCosmosBlockchain as Ay}from"rango-types";import yy from"bignumber.js";var le=new yy(0);import{WalletTypes as Sy}from"@rango-dev/wallets-shared";var po="~",Dc=[Sy.LEAP];import{BlockchainCategories as ua,WalletState as vy}from"@rango-dev/ui";import{TransactionType as yr}from"rango-sdk";var $c="Roboto",pa=[{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 Do(t){return Array.from(new Set(t))}i(Do,"removeDuplicateFrom");function Sr(t,e){let o;return n;function n(...r){o&&clearTimeout(o),o=setTimeout(()=>{o=null,t(...r)},e)}}i(Sr,"debounce");function tt(t,e){return t.toLowerCase().indexOf(e.toLowerCase())>-1}i(tt,"containsText");function Uc(t,e){return t.toLowerCase()===e.toLowerCase()}i(Uc,"exactText");function zc(t,e){return t.toLowerCase().startsWith(e.toLowerCase())}i(zc,"startWithText");var N=i(()=>document.getElementById($e.SWAP_BOX_ID),"getContainer"),uo=i(()=>document.getElementById($e.EXPANDED_BOX_ID),"getExpanded");function Qc(t,e,o){let n=!!e&&Uc(e,t),r=!!o&&Uc(o,t);return n!==r?n?-1:1:0}i(Qc,"compareExactMatchText");function ma(t,e,o){let n=!!e&&tt(e,t),r=!!o&&tt(o,t);return n!==r?n?-1:1:n&&r&&e?.length!==o?.length?e?.length-o?.length:0}i(ma,"compareContainsText");function da(t,e,o){let n=!!e&&zc(e,t),r=!!o&&zc(o,t);return n!==r?n?-1:1:n&&r&&e?.length!==o?.length?e?.length-o?.length:0}i(da,"compareStartWithText");function Hc(t,e,o){if(!o)return 0;let n=Qc(o,t.symbol,e.symbol);if(n)return n;if(o.length>=3){let r=Qc(o,t.name,e.name);if(r)return r}if(o.length>=2){let r=da(o,t.symbol,e.symbol);if(r)return r}if(o.length>=3){let r=ma(o,t.symbol,e.symbol);if(r)return r}if(o.length>=3){let r=da(o,t.name,e.name);if(r)return r}if(o.length>=3){let r=ma(o,t.name,e.name);if(r!==0)return r}if(o.length>=4){let r=da(o,t.address,e.address);if(r)return r}if(o.length>=4){let r=ma(o,t.address,e.address);if(r!==0)return r}return 0}i(Hc,"compareWithSearchFor");var Cr=i((t,e)=>{switch(e){case ua.ALL:return!0;case ua.UTXO:return t===yr.TRANSFER;case ua.OTHER:return t!==yr.TRANSFER&&t!==yr.COSMOS&&t!==yr.EVM;default:return t===e}},"isBlockchainTypeInCategory"),qc=i(t=>pa.find(o=>o.value===t)?.url,"getFontUrlByName");function Gc(t,e){let o=!!t.find(n=>n.state===vy.CONNECTED);return e===!1&&o}i(Gc,"isSingleWalletActive");function Vc(){let t,e;return(o,n)=>((!e||!t||t!==n)&&(t=n,e=o()),e)}i(Vc,"memoizedResult");import{BigNumber as Kc}from"bignumber.js";var dn=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"),P=i((t,e=null,o=null)=>{if(t==null||t==="")return"";let n=new Kc(t),r=1,a=1e3;for(let s=0;s<60;s++)if(new Kc(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 kr=i(t=>t?.reduce((e,o)=>e+(o.estimatedTimeInSeconds??0),0)||0,"totalArrivalTime");var bt=i((t,e)=>t.toLowerCase().indexOf(e.toLowerCase())>-1,"containsText"),fn=i(t=>!!t&&parseFloat(t)>0,"isPositiveNumber");function gn(t){switch(!0){case t.connected:return xt.CONNECTED;case t.connecting:return xt.CONNECTING;case!t.installed:return xt.NOT_INSTALLED;default:return xt.DISCONNECTED}}i(gn,"mapStatusToWalletState");function Xc(t,e,o,n){return o.filter(r=>!Dc.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:m,properties:h,isHub:d}=e(r),f=Do(u.map(k=>k.type)),g=gn(t(r));return{title:a,image:s,link:xy(l),state:g,type:r,showOnMobile:c,needsNamespace:p,blockchainTypes:f,needsDerivationPath:m,properties:h,isHub:d}})}i(Xc,"mapWalletTypesToWalletInfo");function hn(t){if(!t)return null;let e=[];return e=t.map(o=>o.name),e}i(hn,"walletAndSupportedChainsNames");function ga(t,e,o,n,r){let a=[];function s(c,p,u){if(!!!a.find(h=>h.chain===c)){let h={address:p,chain:c,walletType:t,isContractWallet:u??!1};a.push(h)}}i(s,"addAccount");let l=n||[];return e.forEach(c=>{let{address:p,network:u}=by(c),m=l.length>0,h=l.includes(u),d=u===jc.Unknown;if(m&&!h&&!d)return;let g=u===jc.Unknown&&Iy(p);if(d&&!g)return;o.includes(u)||g?r?s(u,p.toLowerCase(),r):l.filter(S=>o.includes(S)).forEach(S=>{s(S,p.toLowerCase())}):s(u,p)}),a}i(ga,"prepareAccountsForWalletStore");function mo(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 m=p.from.blockchain,h=p.to.blockchain,d=a===o.swaps.length-1,f=u===c.length-1;(!d&&!f||d&&l!==m||e==="all")&&n.add(m),e==="all"&&n.add(h)})}e==="all"&&n.add(l)}),Array.from(n)}i(mo,"getQuoteWallets");function yn(t,e){return t.address===e.address&&t.chain===e.chain&&t.walletType===e.walletType}i(yn,"isAccountAndWalletMatched");var Yc=i(t=>{let e=Object.values(t).reduce((o,n)=>{let r=n.usdValue?fa(n.usdValue,n.decimals):le.toFixed();return o.plus(r)},new $o(le));return Ny(e.toString())},"calculateWalletUsdValue");function Ny(t){let e=t.toString().split(".");return e[0]=e[0].replace(/\B(?=(\d{3})+(?!\d))/g,","),e.join(".")}i(Ny,"numberWithThousandSeparator");var wr=i((t,e)=>{let o=Ey(Object.entries(t).map(([,n])=>n).filter(Ay));return o&&o[e]?.experimental},"isExperimentalChain");function fa(t,e){return new $o(t).shiftedBy(-e).toFixed()}i(fa,"representAmountInNumber");function br(t){if(!t)return null;let e=fa(t.amount,t.decimals),o=t.usdValue?fa(t.usdValue,t.decimals):null,n=P(e,8,8),r=o?P(o,4,4):null;return t?{...t,amount:n,usdValue:r}:null}i(br,"formatBalance");function Zc(t,e){if(t?.usdValue||e?.usdValue){let o=t&&t.usdValue?new $o(t.usdValue).shiftedBy(-t.decimals):le,n=e&&e.usdValue?new $o(e.usdValue).shiftedBy(-e.decimals):le;return o.isEqualTo(n)?0:o.isGreaterThan(n)?-1:1}if(t?.amount||e?.amount){let o=t&&t.amount?new $o(t.amount).shiftedBy(-t.decimals):le,n=e&&e.amount?new $o(e.amount).shiftedBy(-e.decimals):le;return o.isEqualTo(n)?0:o.isGreaterThan(n)?-1:1}return 0}i(Zc,"compareTokenBalance");function Wt(t,e){return t?.blockchain===e?.blockchain&&t?.symbol.toLowerCase()===e?.symbol.toLowerCase()&&t?.address?.toLowerCase()===e?.address?.toLowerCase()}i(Wt,"areTokensEqual");function Jc(t){return t.sort((e,o)=>+(o.state===xt.CONNECTED)-+(e.state===xt.CONNECTED)||+(o.state===xt.DISCONNECTED||o.state===xt.CONNECTING)-+(e.state===xt.DISCONNECTED||e.state===xt.CONNECTING))}i(Jc,"sortWalletsBasedOnConnectionState");function xr(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(xr,"getConciseAddress");function Rc({chain:t,connectedWallets:e,walletType:o}){return e.find(n=>n.walletType===o&&n.chain===t)?.address}i(Rc,"getAddress");var ep=i((t,e)=>!!t.find(o=>o.chain===e&&o.loading),"isFetchingBalance");function tp(t){return t.map(e=>e.state).join("-")}i(tp,"hashWalletsState");function op(t,e){let o=new Set;return t.forEach(r=>{r.blockchainTypes.forEach(a=>{o.add(a)})}),e.filter(r=>o.has(r.type))}i(op,"filterBlockchainsByWalletTypes");function np(t,e){return e===wy.ALL?t:t.filter(o=>{for(let n of o.blockchainTypes)if(Cr(n,e))return!0;return!1})}i(np,"filterWalletsByCategory");var ha={API_KEY:hr};function Lt(t){return ha[t]||""}i(Lt,"getConfig");function rp(t){let e;return typeof structuredClone=="function"?e=structuredClone(t):e=JSON.parse(JSON.stringify(t)),ha=e,ha}i(rp,"initConfig");var ip=20,ap=25,ya="theme-widget",Sa=i((t,e)=>{let o=!1;if(e&&t){if(Array.isArray(e))o=!e.some(n=>Wt(n,t));else if(!Array.isArray(e)&&e[t.blockchain]){o=e[t.blockchain].tokens.some(r=>Wt(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"),sp=i((t,e,o)=>o==="expanded"&&(t||e)||o==="full-expanded"&&e,"isVariantExpandable");var Er,ot=i(()=>Er||(Er=new By(Lt("API_KEY"),Lt("BASE_URL")),Er),"httpService");function Ir(t,e){let o=t.map(a=>a.swapperGroup),n=[];return Do(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(Ir,"getUniqueSwappersGroups");function lp(t,e){return t.swapperGroup<e.swapperGroup?-1:t.swapperGroup>e.swapperGroup?1:0}i(lp,"sortLiquiditySourcesByGroupTitle");function Ye(t,e){return e?.[t]==="hidden"}i(Ye,"isFeatureHidden");function Fo(t,e){return e?.[t]==="enabled"}i(Fo,"isRoutingEnabled");var cp=i((t,e,o)=>Ye("customTokens",o)?t:t.concat(e),"addCustomTokensToSupportedTokens");var pp=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=dr({config:a}),p=r;return c.length>0&&(p=p.filter(u=>c.includes(u.name))),p.filter(u=>Mc.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",m=Po.get(u);m?.length||(m=mn({type:o.type,config:{blockchains:a[p]?.blockchains,tokens:a[p]?.tokens},meta:{tokensMapByTokenHash:n,tokensMapByBlockchainName:r}}),Po.set(u,m)),m=cp(m,s,a.features);let h=e().blockchains({type:o.type});return m.filter(f=>o.blockchain&&f.blockchain!==o.blockchain||!h.some(g=>g.name===f.blockchain)?!1:o.searchFor?!!(tt(f.symbol,o.searchFor)||tt(f.address||"",o.searchFor)||tt(f.name||"",o.searchFor)):!0).sort((f,g)=>{let k=e().isTokenPinned(f,o.type),C=e().isTokenPinned(g,o.type);if(k!==C)return k?-1:1;if(o.getBalanceFor){let B=o.getBalanceFor(f),I=o.getBalanceFor(g),x=Zc(B,I);if(x!==0)return x}let S=c.get(f.blockchain),T=c.get(g.blockchain),w=ca(f,S),E=ca(g,T);if(w!==E)return w?-1:1;if(f.isPopular!==g.isPopular)return f.isPopular?-1:1;if(o.searchFor){let B=Hc(f,g,o.searchFor);if(B)return B}return f.isSecondaryCoin!==g.isSecondaryCoin?f.isSecondaryCoin?1:-1:S&&T?S.sort-T.sort:0})},findToken:o=>{let n=e()._tokensMapByTokenHash,r=e().customTokens(),a=mt(o),s=n.get(a);return s||(s=r.find(l=>mt(l)===a)),s},isTokenPinned:(o,n)=>!!(n==="source"?e().config.from?.pinnedTokens:e().config.to?.pinnedTokens)?.some(s=>Wt(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(lp)},fetch:async()=>{try{let{routing:o}=e().config,n=Fo("enableCentralizedSwappers",o),r=await ot().getAllMetadata({enableCentralizedSwappers:n});t({fetchStatus:"success"});let a=new Map,s=new Map,l={},c=[],p=r.popularTokens,u=r.swappers.filter(d=>d.enabled),m=new Set;r.tokens.forEach(d=>{m.add(d.blockchain),c.push(d)}),r.blockchains.sort((d,f)=>d.sort-f.sort).forEach(d=>{d.enabled&&m.has(d.name)&&a.set(d.name,d)}),c.forEach(d=>{let f=mt(d);l[d.blockchain]||(l[d.blockchain]=[]),s.set(f,d),l[d.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 Wy,Catalonia as Ly,Chinese as up,Denmark as My,English as Py,Finland as _y,French as Dy,German as $y,Greece as Fy,Hungary as Oy,India as Uy,Indonesian as zy,Italian as Qy,Japanese as Hy,Korea as qy,Lithuania as Gy,Malay as Vy,Netherlands as Ky,Pakistan as jy,Philippines as Xy,Poland as Yy,Portuguese as Zy,Russian as Jy,SaudiArabia as Ry,Serbia as eS,Slovakia as tS,SouthAfrica as oS,Spanish as nS,Swahili as rS,Swedish as iS,Thai as aS,Turkish as sS,Ukrainian as lS,Vietnamese as cS}from"@rango-dev/ui";var mp=[{title:"Afrikaans",label:"Afrikaans",local:"af",SVGFlag:oS},{title:"Arabic",label:"\u0639\u0631\u0628\u064A",local:"ar",SVGFlag:Ry},{title:"Bengali",label:"\u09AC\u09BE\u0982\u09B2\u09BE",local:"bn",SVGFlag:Wy},{title:"Catalan",label:"Catal\xE0",local:"ca",SVGFlag:Ly},{title:"Chinese (Simplified)",label:"\u7B80\u4F53\u4E2D\u6587",local:"zh-CN",SVGFlag:up},{title:"Chinese (Traditional)",label:"\u4E2D\u6587\uFF08\u7E41\u9AD4)",local:"zh-TW",SVGFlag:up},{title:"Danish",label:"Dansk",local:"da",SVGFlag:My},{title:"Dutch",label:"Nederlands",local:"nl",SVGFlag:Ky},{title:"English",label:"English",local:"en",SVGFlag:Py},{title:"Filipino",label:"Filipino",local:"fil",SVGFlag:Xy},{title:"Finnish",label:"Suomalainen",local:"fi",SVGFlag:_y},{title:"French",label:"Fran\xE7ais",local:"fr",SVGFlag:Dy},{title:"German",label:"Deutsch",local:"de",SVGFlag:$y},{title:"Greek",label:"\u03B5\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AC",local:"el",SVGFlag:Fy},{title:"Hindi",label:"\u0939\u093F\u0902\u0926\u0940",local:"hi",SVGFlag:Uy},{title:"Hungarian",label:"Magyar",local:"hu",SVGFlag:Oy},{title:"Indonesian",label:"Indonesia",local:"id",SVGFlag:zy},{title:"Italian",label:"Italiana",local:"it",SVGFlag:Qy},{title:"Japanese",label:"\u65E5\u672C\u8A9E",local:"ja",SVGFlag:Hy},{title:"Korean",label:"\uD55C\uAD6D\uC778",local:"ko",SVGFlag:qy},{title:"Lithuanian",label:"Lietuvi\u0173",local:"lt",SVGFlag:Gy},{title:"Malay",label:"Melayu",local:"ms",SVGFlag:Vy},{title:"Polish",label:"Polski",local:"pl",SVGFlag:Yy},{title:"Portuguese",label:"Portugu\xEAs",local:"pt",SVGFlag:Zy},{title:"Russian",label:"\u0420\u0443\u0441\u0441\u043A\u0438\u0439",local:"ru",SVGFlag:Jy},{title:"Serbian",label:"C\u0440\u043F\u0441\u043A\u0438",local:"sr",SVGFlag:eS},{title:"Slovak",label:"Slovensk\xFD",local:"sk",SVGFlag:tS},{title:"Spanish",label:"Espa\xF1ol",local:"es",SVGFlag:nS},{title:"Swahili",label:"Kiswahili",local:"sw",SVGFlag:rS},{title:"Swedish",label:"Svenska",local:"sv",SVGFlag:iS},{title:"Thai",label:"\u0E41\u0E1A\u0E1A\u0E44\u0E17\u0E22",local:"th",SVGFlag:aS},{title:"Turkish",label:"T\xFCrk\xE7e",local:"tr",SVGFlag:sS},{title:"Ukrainian",label:"Y\u043A\u0440\u0430\u0457\u043D\u0456",local:"uk",SVGFlag:lS},{title:"Urdu",label:"\u0627\u0631\u062F\u0648",local:"ur",SVGFlag:jy},{title:"Vietnamese",label:"Ti\u1EBFng Vi\u1EC7t",local:"vi",SVGFlag:cS}],Oo="en";var dp=[.5,1,3],fp=1,gp=5,hp=100,yp=0;var Sp=i((t,e)=>({disabledLiquiditySources:[],theme:"auto",language:null,preferredBlockchains:[],slippage:fp,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=Do(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=Ye("theme",n),s=Ye("language",n),l=Ye("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||Oo},...l&&{disabledLiquiditySources:o.liquiditySources||[]},...p&&{language:o.language||Oo}})},setCustomToken:o=>{e().fetchCustomTokensBalance({tokens:[o],connectedWallets:e().connectedWallets}),t(n=>({_customTokens:[o,...n._customTokens]}))},deleteCustomToken:o=>t(n=>({_customTokens:n._customTokens.filter(r=>r.address!==o.address)})),customTokens:()=>{let o=e().config,n=e()._customTokens,r=dr({config:o});return r.length?n.filter(a=>r.includes(a.blockchain)):n}}),"createSettingsSlice");import Aa from"bignumber.js";import pS from"mitt";var he=pS(),uS={on:he.on,off:he.off};import{WidgetEvents as Cp}from"@rango-dev/queue-manager-rango-preset";var Ta=(o=>(o.QUOTE_INPUT_UPDATE="quoteInputUpdate",o.QUOTE_OUTPUT_UPDATE="quoteOutputUpdate",o))(Ta||{}),va=(o=>(o.CONNECT="connect",o.DISCONNECT="disconnect",o))(va||{}),wa=(e=>(e.CLICK_CONNECT_WALLET="clickConnectWallet",e))(wa||{}),Uo=(a=>(a[a.RouteEvent=Cp.RouteEvent]="RouteEvent",a[a.StepEvent=Cp.StepEvent]="StepEvent",a.QuoteEvent="quoteEvent",a.WalletEvent="walletEvent",a.UiEvent="uiEvent",a))(Uo||{});var kp=i(t=>(e,o,n)=>t(i((...a)=>{let[s,...l]=a;e(c=>({...typeof s=="function"?s(c):s,lastUpdatedAt:+new Date}),...l)},"modifedSet"),o,n),"keepLastUpdated");import Tp from"bignumber.js";function Mt(t){return`${t.blockchain}${po}${t.address}${po}${t.symbol}`}i(Mt,"createAssetKey");function vp(t,e){return`${Mt(e)}${po}${t}`}i(vp,"createBalanceKey");function Sn(t){let[e,o,n]=t.split(po);return{address:o==="null"?null:o,blockchain:e,symbol:n}}i(Sn,"extractAssetFromBalanceKey");function ba(t,e,o){return e.balances?.forEach(n=>{let r=n.price??t.findToken(n.asset)?.usdPrice;t._aggregatedBalances[Mt(n.asset)]?.forEach(s=>{o[s]&&(o[s]={...o[s],usdValue:r?new Tp(r??le).multipliedBy(o[s].amount).toString():""})})}),o}i(ba,"computeNextBalancesWithNewPrices");function xa(t,e){let o={};return t.balances?.forEach(n=>{let r=vp(t.address,n.asset),a=n.amount.amount,s=n.amount.decimals,l=n.price??e().findToken(n.asset)?.usdPrice,c=l?new Tp(l??le).multipliedBy(a).toString():"",p={amount:a,decimals:s,usdValue:c};o[r]=p}),o}i(xa,"createBalanceStateForNewAccount");function Ea(t,e){for(let o in e){let n=Sn(o),r=Mt(n);t[r]||(t[r]=[]),t[r].includes(o)||(t[r]=[...t[r],o])}return t}i(Ea,"updateAggregatedBalanceStateForNewAccount");function mS(t,e){let o=Sn(e),n=Mt(o);return t[n]&&(t[n]=t[n].filter(r=>r!==e)),t}i(mS,"removeBalanceFromAggregatedBalance");function Ia(t,e,o){let n=t.connectedWallets.filter(c=>c.walletType===e);t.connectedWallets.forEach(c=>{c.walletType!==e&&(n=n.filter(p=>!(p.chain===c.chain&&p.address===c.address)))}),o?.chains&&o.chains.length>0&&(n=n.filter(c=>o.chains?.includes(c.chain))),o?.namespaces&&o.namespaces.length>0&&(n=n.filter(c=>c.namespace?o.namespaces?.includes(c.namespace):!1));let r={},a=t._aggregatedBalances,s=t._balances;return Object.keys(s).forEach(c=>{let p=Sn(c);!!n.find(m=>vp(m.address,{address:p.address,blockchain:m.chain,symbol:p.symbol})===c)?a=mS(a,c):r[c]=s[c]}),{_balances:r,_aggregatedBalances:a}}i(Ia,"computeNextStateAfterWalletBalanceRemoval");function dS(t,e){return e.find(o=>t.address===o.address&&t.chain===o.blockChain)}i(dS,"matchWalletDetailsWithConnectedWallet");var fS=Vc(),wp=kp((t,e)=>({_balances:{},_aggregatedBalances:{},connectedWallets:[],fetchingWallets:!1,lastUpdatedAt:+new Date,setConnectedWalletAsRefetching:o=>{t(n=>({fetchingWallets:!0,connectedWallets:n.connectedWallets.map(r=>o.find(a=>yn(a,r))?{...r,loading:!0,error:!1}:r)}))},setConnectedWalletRetrievedData:(o,n)=>{t(r=>({fetchingWallets:!1,connectedWallets:r.connectedWallets.map(a=>o.find(s=>yn(s,a))?{...a,loading:!1,error:!1,explorerUrl:dS(a,n)?.explorerUrl||a.explorerUrl}:a)}))},setConnectedWalletHasError:o=>{t(n=>({fetchingWallets:!1,connectedWallets:n.connectedWallets.map(r=>o.find(a=>yn(a,r))?{...r,loading:!1,error:!0}:r)}))},addConnectedWallet:(o,n)=>{let r=e().connectedWallets,a=o.filter(s=>!r.some(l=>yn(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,isContractWallet:l.isContractWallet,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]}))}},fetchCustomTokensBalance:async o=>{let{tokens:n,connectedWallets:r}=o,a=n.reduce((c,p)=>((c[p.blockchain]||=[]).push(p),c),{}),s=new Set,l=r.reduce((c,p)=>{let u=`${p.address}-${p.chain}`;return s.has(u)||(s.add(u),a[p.chain]&&(c[p.address]||(c[p.address]=[]),c[p.address].push(...a[p.chain]))),c},{});Object.entries(l).forEach(async([c,p])=>{try{let{balances:u}=await ot().getMultipleTokenBalance({assets:p.map(({symbol:m,address:h,blockchain:d})=>({symbol:m,address:h,blockchain:d})),walletAddress:c});if(u){let m=e()._balances,h=e()._aggregatedBalances;u.forEach(d=>{if(parseFloat(d.amount.amount)===0)return;let f={blockChain:d.asset.blockchain,balances:[d],address:c},g={_aggregatedBalances:e()._aggregatedBalances,findToken:e().findToken};ba(g,f,m);let k=xa(f,e);h=Ea(h,k),m={...m,...k}}),t(d=>({_balances:{...d._balances,...m},_aggregatedBalances:h}))}}catch(u){console.error(u)}})},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),e().fetchCustomTokensBalance({tokens:e().customTokens(),connectedWallets:o})},removeBalancesForWallet:(o,n)=>{let r={_balances:e()._balances,_aggregatedBalances:e()._aggregatedBalances,connectedWallets:e().connectedWallets},{_balances:a,_aggregatedBalances:s}=Ia(r,o,n);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 ot().getWalletsDetails(a)}catch(c){e().setConnectedWalletHasError(o),console.error(`Request for fetching balances failed. cause: ${c}`);return}let l=s.wallets;if(l){let{retryOnFailedBalances:c=!0}=n||{};if(c){let m=l.filter(h=>h.failed).map(h=>({chain:h.blockChain,walletType:r,address:h.address}));m.length>0&&e().fetchBalances(m,{retryOnFailedBalances:!1})}let p=e()._balances,u=e()._aggregatedBalances;l.forEach(m=>{if(m.failed)return;let h={_balances:p,_aggregatedBalances:u,connectedWallets:e().connectedWallets,findToken:e().findToken};ba(h,m,p);let{_balances:d,_aggregatedBalances:f}=Ia(h,r,{chains:[m.blockChain]});if(u=f,p=d,!e().connectedWallets.find(k=>k.walletType===r&&k.address===m.address&&k.chain===m.blockChain))return;let g=xa(m,e);u=Ea(u,g),p={...p,...g}}),t(m=>({_balances:{...m._balances,...p},_aggregatedBalances:u})),e().setConnectedWalletRetrievedData(o,l)}else e().setConnectedWalletHasError(o),console.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=Mt(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 Aa(p.amount),m=new Aa(l.amount);u.isGreaterThan(m)&&(l=p)}),l},getBalancesForWalletAddress:o=>{let n=e().getBalances();return Object.keys(n).reduce((s,l)=>{let c=n[l],[,,,p]=l.split(po);return p===o&&(s[l]=c),s},{})},getConnectedWalletsDetails:()=>fS(()=>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=Sn(l);if(p.blockchain===n.chain){let u=e().findToken(p),m=c.amount?new Aa(c.amount).shiftedBy(-c.decimals):le;s.push({chain:n.chain,symbol:p.symbol,ticker:p.symbol,address:p.address,rawAmount:c.amount,decimal:c.decimals,amount:m.toString(),logo:u?.image||null,usdPrice:u?.usdPrice||null})}return s},[])}}),e().lastUpdatedAt)}));function bp(t){return gS()(hS((...e)=>({...wp(...e),...pp(...e),...Sp(...e),...Wc(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}),version:1,migrate:(e,o)=>{let n=e;return o===0&&(n._customTokens=n._customTokens.map(r=>({...r,warning:!0}))),n}}))}i(bp,"createAppStore");var xp=SS(null);function y(){let t=CS(xp);if(kS(()=>{t&&!t.persist.hasHydrated()&&t.persist.rehydrate()},[]),!t)throw new Error("Missing AppStoreContext.Provider in the tree");return t()}i(y,"useAppStore");function Ep(t){let e=TS();return e.current||(e.current=bp(t.config)),yS.createElement(xp.Provider,{value:e.current},t.children)}i(Ep,"AppStoreProvider");function ht(t){let{chain:e}=t||{},{connectedWallets:o,getAvailableProviders:n}=y(),{state:r,getWalletInfo:a}=vS(),s=y().blockchains(),{handleDisconnect:l}=Kt(),c=Ic(n()),p=Xc(r,a,c,e);p=wS()?p.filter(g=>g.showOnMobile!==!1&&r(g.type).installed):p;let u=Jc(p),m=i(g=>!o.find(k=>k.walletType===g&&k.chain===e),"isExperimentalChainNotAdded"),h=xS(()=>{let g=p?.filter(k=>k.state===Na.CONNECTING)||[];for(let k of g)l(k.type)},[tp(p)]);ES(()=>()=>{h()},[]);let d=i(g=>{let k=g.find(S=>S.type===Cn.DEFAULT);return!k||k.state===Na.NOT_INSTALLED?!1:g.filter(S=>S.state!=Na.NOT_INSTALLED&&![Cn.DEFAULT,Cn.WALLET_CONNECT_2,Cn.LEDGER].includes(S.type)&&a(S.type).supportedChains.filter(T=>T.type=="EVM").length>0).length==0},"shouldShowDefaultInjectedWallet"),f=i((g,k,C)=>wr(C,k)&&m(g)&&!bS.includes(g)||g==Cn.DEFAULT&&!d(p),"shouldExcludeWallet");return{list:u.filter(g=>!f(g.type,e??"",s)),terminateConnectingWallets:h}}i(ht,"useWalletList");import{Modal as BS}from"@rango-dev/ui";import WS from"react";import{create as NS}from"zustand";var Ip="rango-widget";var kn=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(Ip),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 AS=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"),zo=AS;var ne=zo(NS()((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})}}))),fo=new kn({onInit:()=>ne.setState({tabManagerInitiated:!0}),onClaim:()=>ne.setState({isActiveTab:!0,showActivateTabModal:!1}),onRelease:()=>ne.setState({isActiveTab:!1})});function J(t){let{watermark:e}=ne();return WS.createElement(BS,{hasWatermark:e==="FULL",...t},t.children)}i(J,"WatermarkedModal");import{i18n as Ba}from"@lingui/core";import{Button as $S,Checkbox as FS,Divider as OS,Image as $p,ListItemButton as US,MessageBox as zS,Radio as QS,RadioRoot as HS}from"@rango-dev/ui";import ve,{useState as qS}from"react";import{css as LS,darkTheme as Np,IconButton as MS,styled as go}from"@rango-dev/ui";var Et=go(MS,{width:"$24",position:"relative",padding:"0",overflow:"unset","&:hover":{backgroundColor:"$secondary100",[`.${Np} &`]:{backgroundColor:"$neutral"}}}),Bp=go("div",{position:"absolute",background:"$secondary500",[`.${Np} &`]:{$$color:"$colors$secondary250"},width:"$6",height:"$6",borderRadius:"$lg",right:"$4",border:"1px solid $surface100"}),jt=go("div",{display:"flex",justifyContent:"flex-end",minWidth:"$40",button:{padding:0}}),Wp=go("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"}}}}),Lp=go("div",{padding:"$2",variants:{isRefetched:{true:{transform:"rotate(360deg)",transition:"transform 1s ease-in-out"}}}}),Mp=go("div",{position:"absolute",right:"$4",top:"$4",backgroundColor:"$background",borderRadius:"100%"}),Pp=LS({display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center"}),Ar=go("div",{borderRadius:"100%",border:"1.5px transparent solid","&:not(:first-child)":{marginLeft:"-$6"},img:{borderRadius:"100%"}});import{keyframes as PS,styled as Nr}from"@rango-dev/ui";var XN=Nr("div",{borderRadius:"$lg",width:"$45",height:"$45",backgroundColor:"$success300",display:"flex",justifyContent:"center",alignItems:"center"}),Qo=Nr("div",{position:"relative"}),_S=PS({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}),Ho=Nr("div",{position:"absolute",border:"2px solid rgba(0, 0, 0, 0.1)",borderTop:"2px solid $info500",borderRadius:"$lg",width:"$45",height:"$45",animation:`${_S} 1s linear infinite`,top:0,bottom:0,right:0,left:0}),Br=Nr("div",{"& img":{borderRadius:"50%"}});function _p(t,e){return t.find(o=>o.name===e)?.logo}i(_p,"getBlockchainLogo");import{styled as DS}from"@rango-dev/ui";var Dp=DS("ul",{padding:0,paddingTop:"$4",paddingBottom:"$4"});function Tn(t){let{targetWallet:e}=t.value,o=e.needsNamespace?.selection==="single",n=e.image,[r,a]=qS([]),s=y().blockchains(),l=i(p=>{a(o?[p]:u=>u.includes(p)?u.filter(m=>m!==p):u.concat(p))},"onSelect"),c=i(p=>o?ve.createElement(HS,{value:r?.[0]},p):ve.createElement(ve.Fragment,null,p),"wrapRadioRoot");return ve.createElement(ve.Fragment,null,ve.createElement(OS,{size:20}),ve.createElement(zS,{type:"info",title:Ba.t("Select chain types"),description:Ba.t("This wallet supports multiple chains. Select which chain you'd like to connect to."),icon:ve.createElement(Qo,null,ve.createElement(Ar,null,ve.createElement($p,{src:n,size:45})),ve.createElement(Ho,null))}),ve.createElement(Dp,null,c(ve.createElement(ve.Fragment,null,e.needsNamespace?.data.map(p=>ve.createElement(US,{key:p.id,id:p.id,title:p.label,hasDivider:!0,style:{height:60},onClick:()=>l(p.value),start:ve.createElement($p,{src:_p(s,p.id),size:22}),end:o?ve.createElement(QS,{value:p.value}):ve.createElement(FS,{checked:r.includes(p.value)})}))))),ve.createElement($S,{id:"widget-name-space-confirm-btn",type:"primary",disabled:!r.length,onClick:()=>t.onConfirm(r)},Ba.t("Confirm")))}i(Tn,"Namespaces");import{i18n as qo}from"@lingui/core";import{Button as KS,Divider as Up,Image as jS,MessageBox as XS,Select as YS,TextField as ZS}from"@rango-dev/ui";import ze,{useEffect as JS,useState as zp}from"react";import{namespaces as GS}from"@rango-dev/wallets-shared";var Wr={id:"custom",label:"Custom",generateDerivationPath:t=>t};function Wa(t){let e=t?GS[t].derivationPaths:null;return e?[...e,Wr]:[]}i(Wa,"getDerivationPaths");import{styled as Fp,Typography as VS}from"@rango-dev/ui";var Op=Fp("div",{paddingTop:"$30",paddingBottom:"$30",zIndex:10}),La=Fp(VS,{paddingLeft:"$10"}),Ma={height:"$40",backgroundColor:"$neutral200",borderRadius:"$sm"};var Qp="0";function vn(t){let{onConfirm:e}=t,{namespace:o,providerImage:n,providerType:r}=t.value,[a,s]=zp(null),[l,c]=zp(Qp),p=a===Wr.id,u=Wa(o),m=i(({value:d})=>{let f=u?.find(g=>g.id===d);f&&(a===Wr.id&&Number.isNaN(Number(l))&&c(Qp),s(f.id))},"handleDerivationPathItemClick"),h=i(()=>{let d=u.find(f=>f.id===a);if(d)e(d.generateDerivationPath(l));else throw new Error("selectedDerivationPath can not be undefined")},"handleConfirm");return JS(()=>{s(Wa(o)[0]?.id||null)},[o]),ze.createElement(ze.Fragment,null,ze.createElement(Up,{size:20}),ze.createElement(XS,{type:"info",title:qo.t("Select Derivation Path"),description:qo.t({id:"In order to connect to {type}, you must first select a Derivation Path",values:{type:r}}),icon:ze.createElement(Qo,null,ze.createElement(Br,null,ze.createElement(jS,{src:n,size:45})),ze.createElement(Ho,null))}),ze.createElement(Op,null,ze.createElement(La,{variant:"body",size:"xsmall",color:"$neutral600"},qo.t("Choose Derivation Path Template")),ze.createElement(YS,{value:a||"",options:u.map(d=>({value:d.id,label:d.label})),variant:"filled",handleItemClick:m,styles:{trigger:Ma}}),ze.createElement(Up,{size:20}),ze.createElement(La,{variant:"body",size:"xsmall",color:"$neutral600"},p?qo.t("Enter Path"):qo.t("Enter Index")),ze.createElement(ZS,{type:p?"text":"number",variant:"contained",value:l,onChange:d=>c(d.target.value),style:Ma})),ze.createElement(KS,{id:"widget-derivation-path-confirm-btn",type:"primary",onClick:h,disabled:!u||!a||!l},qo.t("Confirm")))}i(vn,"DerivationPath");import{i18n as Go}from"@lingui/core";import{Image as RS,MessageBox as Pa,WalletState as eC}from"@rango-dev/ui";import{useWallets as tC}from"@rango-dev/wallets-react";import ho from"react";function _a(t){let{wallet:e,error:o}=t,{type:n,image:r}=e,{state:a}=tC();return gn(a(n))===eC.CONNECTED?ho.createElement(Pa,{type:"success",title:Go.t("Wallet Connected"),description:Go.t("Your wallet is connected, you can use it to swap.")}):o?ho.createElement(Pa,{type:"error",title:Go.t("Failed to Connect"),description:o||Go.t("Your wallet is not connected. Please try again.")}):ho.createElement(Pa,{type:"loading",title:Go.t("Connecting to your wallet"),description:Go.t("Click connect in your wallet popup."),icon:ho.createElement(Qo,null,ho.createElement(Br,null,ho.createElement(RS,{src:r,size:45})),ho.createElement(Ho,null))})}i(_a,"ConnectStatus");import{i18n as Da}from"@lingui/core";import{Button as oC,Divider as Hp,MessageBox as nC}from"@rango-dev/ui";import Lr from"react";function $a(t){let{displayName:e,onConfirm:o}=t;return Lr.createElement(nC,{title:Da.t({id:"Add {blockchainDisplayName} Chain",values:{blockchainDisplayName:e}}),type:"warning",description:Da.t({id:"Would you like to add the {blockchainDisplayName} experimental chain to your wallet?",values:{blockchainDisplayName:e}})},Lr.createElement(Hp,{size:18}),Lr.createElement(Hp,{size:32}),Lr.createElement(oC,{id:"widget-experimental-chain-confirm-btn",onClick:o,variant:"outlined",type:"primary",fullWidth:!0,size:"large"},Da.t("Confirm")))}i($a,"ExperimentalChain");function qp(t,e){return t().status==="init"&&!!e}i(qp,"isOnStatus");function wn(t){return t().status==="namespace"}i(wn,"isOnNamespace");function bn(t){return t().status==="derivationPath"}i(bn,"isOnDerivationPath");var sC=3e3,lC=300;function So(t){let e=aC(),[o,n]=Gp(!1),[r,a]=Gp(),s=i(S=>{a(S.message)},"catchErrorOnHandle"),{terminateConnectingWallets:l}=ht(),{handleConnect:c,handleDerivationPath:p,handleNamespace:u,getState:m,resetState:h}=Kt(),d=i(S=>{u(t.wallet,S).then(C).catch(s)},"handleConfirmNamespaces"),f=i(S=>{if(!S)throw new Error("Derivation path is empty. Please make sure you've filled the field correctly.");p(S).then(C).catch(s)},"handleDerivationPathConfirm"),g=i(()=>{n(!1)},"handleClosingModal"),k=i(()=>{a(void 0),h(),n(!1),e.current&&clearTimeout(e.current)},"resetModalState"),C=i((S,T)=>{let w=S.status==="connected",E=["disconnected","disconnected-unhandled"].includes(S.status);w?(t.onConnect?.(),T||(e.current=setTimeout(g,sC))):E&&g()},"afterConnected");return iC(()=>{if(t.wallet){k();let S=!1,T=!0;i(()=>{setTimeout(()=>{T=!1,S||n(!0)},lC)},"beforeConnecting")(),c(t.wallet,{disconnectIfConnected:!0}).then(E=>{["namespace","derivation-path"].includes(E.status)||(S=!0),C(E,T)}).catch(s)}},[t.wallet]),yo.createElement(J,{open:o,onClose:g,onExit:()=>{k(),l(),t.onClose&&t.onClose()},container:N()},qp(m,t.wallet)&&yo.createElement(yo.Fragment,null,yo.createElement(_a,{wallet:{type:t.wallet.type,image:t.wallet.image},error:r}),yo.createElement(rC,{direction:"vertical",size:32})),wn(m)&&yo.createElement(Tn,{onConfirm:d,value:m().namespace}),bn(m)&&yo.createElement(vn,{onConfirm:f,value:m().derivationPath}))}i(So,"StatefulConnectModal");import{Provider as dC}from"@rango-dev/wallets-react";import Mr,{createContext as fC,useEffect as Yp,useMemo as gC,useRef as Zp}from"react";import{useEffect as cC}from"react";function Vp(t){return t.map(e=>typeof e=="string"?e:e.config.type).join("-")}i(Vp,"hashProviders");function Fa(t,e){let{clearConnectedWallet:o,getAvailableProviders:n,buildAndSetProviders:r}=y(),a=n();return cC(()=>{o(),r()},[Vp(t??[]),e?.walletConnectProjectId,e?.walletConnectListedDesktopWalletLink]),{providers:a}}i(Fa,"useWalletProviders");import{legacyFormatAddressWithNetwork as pC,legacyReadAccountAddress as Kp}from"@rango-dev/wallets-core/legacy";import{Events as Co}from"@rango-dev/wallets-react";import{isEvmBlockchain as uC}from"rango-sdk";function jp(t){let{newWalletConnected:e,disconnectWallet:o,disconnectNamespaces:n,connectedWallets:r,removeBalancesForWallet:a,blockchains:s}=y(),{onConnectWalletHandler:l,onDisconnectWalletHandler:c}=t,p=s().filter(uC).map(g=>g.name),u=i((g,k)=>{let[C,,S,,T]=g,w=ga(C,S,p,k.supportedChainNames,T.isContractWallet);w.length&&e(w,T.namespace)},"onAccountsEvent"),m=i((g,k,C,S,T)=>{if(k===Co.ACCOUNTS){let w=hn(T.supportedBlockchains);C&&u([g,k,C,S,T],{supportedChainNames:w})}if(k===Co.CONNECTED){let w=`${g}-${S.network}-${C}`;l.current?l.current(w):console.warn("onConnectWallet handler hasn't been set. Are you sure?")}k===Co.PROVIDER_DISCONNECTED&&(o(g),c.current?c.current(g):console.warn("onDisconnectWallet handler hasn't been set. Are you sure?")),k===Co.NAMESPACE_DISCONNECTED&&n(g,C)},"handleUpdatesForHub"),h=i((g,k,C,S,T)=>{if(k===Co.ACCOUNTS){let w=hn(T.supportedBlockchains),E=[],B=[];if(C?.forEach(x=>{let{network:b}=Kp(x);p.includes(b)?E.push(x):B.push(x)}),r.filter(x=>x.walletType===g).map(x=>pC(x.address,x.chain)).length>0){if(E.length>0){let x=ga(g,E,p,w,T.isContractWallet);a(g,{chains:x.map(b=>b.chain)})}B.length>0&&a(g,{chains:B.map(x=>{let{network:b}=Kp(x);return b})})}C?u([g,k,C,S,T],{supportedChainNames:w}):(o(g),c.current?c.current(g):console.warn("onDisconnectWallet handler hasn't been set. Are you sure?"))}if(k===Co.ACCOUNTS&&S.connected){let w=`${g}-${S.network}-${C}`;l.current?l.current(w):console.warn("onConnectWallet handler hasn't been set. Are you sure?")}},"handleUpdatesForLegacy"),d=i((g,k,C,S,T)=>{if(k===Co.NETWORK&&S.network){let w=`${g}-${S.network}`;l.current?l.current(w):console.warn("onConnectWallet handler hasn't been set. Are you sure?")}},"handleUpdatesForBoth");return{handler:i((g,k,C,S,T)=>{T.isHub?m(g,k,C,S,T):h(g,k,C,S,T),d(g,k,C,S,T)},"handler")}}i(jp,"useUpdates");import{LegacyEvents as mC}from"@rango-dev/wallets-core/legacy";function Xp(t,e){let[o,n,r,a,s]=e;n!==mC.PROVIDER_DISCONNECTED&&t(o,n,r,a,s)}i(Xp,"propagateEvents");var Pr=fC({onConnectWallet:()=>{},onDisconnectWallet:()=>{}});function hC(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}=Fa(s.wallets,l),p=Zp(),u=Zp(),{handler:m}=jp({onConnectWalletHandler:p,onDisconnectWalletHandler:u});Yp(()=>{n().catch(console.log)},[]),Yp(()=>{t.config&&(e(t.config),o(t.config),window.__rango={config:s,dappConfig:t.config})},[t.config,r]);let h=ne.use.isActiveTab(),d=gC(()=>({onConnectWallet:f=>{p.current=f},onDisconnectWallet:f=>{u.current=f}}),[]);return Mr.createElement(Pr.Provider,{value:d},Mr.createElement(dC,{allBlockChains:a,providers:c,onUpdateState:(f,g,k,C,S)=>{let T=[f,g,k,C,S];m(...T),t.onUpdateState&&Xp(t.onUpdateState,T)},autoConnect:!!h,configs:{wallets:s.wallets}},t.children))}i(hC,"Main");function _r(t){let{config:e,...o}=t;return Mr.createElement(Ep,{config:e},Mr.createElement(hC,{...o,config:e}))}i(_r,"WidgetWallets");import aa from"react";import yC,{Fragment as SC}from"react";import{MemoryRouter as CC,useInRouterContext as kC}from"react-router";function Jp({children:t}){let o=kC()?SC:CC;return yC.createElement(o,null,t)}i(Jp,"AppRouter");import{I18nManager as dI}from"@rango-dev/ui";import hc from"react";import Pe from"react";import{useRoutes as RE}from"react-router-dom";var F={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 Ko,useRef as qr}from"react";import Ze from"bignumber.js";import{create as wC}from"zustand";import{subscribeWithSelector as bC}from"zustand/middleware";import{i18n as yt}from"@lingui/core";import{RouteEventType as pL}from"@rango-dev/queue-manager-rango-preset";import Qe from"bignumber.js";import{PendingSwapNetworkStatus as Qr}from"rango-types";import{i18n as Fe}from"@lingui/core";var ee=i(()=>({genericServerError:Fe.t("Failed Network, Please retry your swap."),liquiditySourcesError:{title:Fe.t("Please reset your liquidity sources."),description:Fe.t("You have limited the liquidity sources and this might result in Rango finding no routes. Please consider resetting your liquidity sources.")},noResultError:{title:Fe.t("No Routes Found."),description:Fe.t("Reasons why Rango couldn't find a route: low liquidity on token, very low input amount or no routes available for the selected input/output token combination.")},bridgeLimitErrors:{increaseAmount:Fe.t("Bridge Limit Error: Please increase your amount."),decreaseAmount:Fe.t("Bridge Limit Error: Please decrease your amount.")},highValueLossError:{impactTitle:Fe.t("High Price Impact"),title:Fe.t("Price impact is too high!"),description:Fe.t("The price impact is significantly higher than the allowed amount."),confirmMessage:Fe.t("Confirm high price impact")},quoteUpdatedWithHighValueLoss:{title:Fe.t("Route updated and price impact is too high, try again later!")},unknownPriceError:{impactTitle:Fe.t("USD Price Unknown"),title:Fe.t("USD Price Unknown, Cannot calculate Price Impact."),description:Fe.t("USD Price Unknown, Cannot calculate Price Impact. The price impact may be higher than usual. Are you sure to continue the Swap?"),confirmMessage:Fe.t("Confirm USD Price Unknown")}}),"errorMessages");function Rp(t){switch(t.type){case 0:return t.diagnosisMessage??ee().noResultError.title;case 1:return ee().genericServerError;default:return""}}i(Rp,"getQuoteErrorMessage");import{i18n as Dr}from"@lingui/core";var ko=i(()=>({connectWallet:Dr.t("Connect Wallet"),swap:Dr.t("Swap"),swapAnyway:Dr.t("Swap anyway"),ethWarning:Dr.t("The route goes through Ethereum. Continue?")}),"swapButtonTitles");function Oa(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(Oa,"getFeeLabel");var Ua=["RECOMMENDED","CENTRALIZED","LOWEST_FEE","FASTEST","HIGH_IMPACT"],eu=100,tu=30,ou=15,nu=60;var ru=[{threshold:-10,minInput:400},{threshold:-5,minInput:1e3}],iu=[{threshold:-1,minInput:1e3},{threshold:-2,minInput:500}];import{getLastSuccessfulStep as vC}from"@rango-dev/queue-manager-rango-preset";import YW from"bignumber.js";function su(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(su,"getRequiredBalanceOfWallet");function _t(t){let e;return t<=-3&&t>-10?e="low":t<=-10&&(e="high"),e}i(_t,"getPriceImpactLevel");function Fr(t,e,o){let n=t.steps[0],r=t.steps[t.steps.length-1],a=vC(t.steps),s={blockchain:r.toBlockchain,symbol:r.toSymbol,address:r.toSymbolAddress},l=co(a?a.toBlockchain:n.fromBlockchain,e),c=co(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),m=a?a.outputAmount??"":t.inputAmount;return{fromBlockchain:l,fromToken:p,toBlockchain:c,toToken:u,inputAmount:m}}i(Fr,"createRetryQuote");function Vo(t){let{previousQuote:e,currentQuote:o,findToken:n,userSlippage:r}=t,a=xn(o),s=dt(o);if(o&&a&&s){let p=Pt(a.toString(),s.toString());if(!!p&&mu(a,p)){let m=Ur(o?.swaps,n),h=_t(p);return{type:0,inputUsdValue:a,outputUsdValue:s,priceImpact:p,totalFee:m,warningLevel:h}}}if(e&&gu(e,o))return{type:4,usdValueChange:P(dt(o)?.minus(dt(e)??0).toString()??"0",null,2),percentageChange:P(Pt(dt(e)??"1",dt(o)??"1"),null,2)};if(o&&(!a||!s))return{type:1};let l=zr(o.swaps),c=r>gp;if(fu(t.userSlippage.toString(),l)){if(c&&parseFloat(l??"0")<r)return{type:3,slippage:r.toString()}}else return{type:2,recommendedSlippages:du(o,r),minRequiredSlippage:l};return null}i(Vo,"generateQuoteWarnings");function lu(t){return![4].includes(t.type)}i(lu,"isQuoteWarningConfirmationRequired");function Pt(t,e){let o=typeof e=="string"?parseFloat(e)<=0:!e?.gt(0),n=!t||!e||o?null:za(t.toString(),e.toString());return n&&n<0?n:null}i(Pt,"getPriceImpact");var cu=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"),Or=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"),pu=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"),uu=i(t=>{let e=i((o,n)=>{let r=Ua.indexOf(o.value),a=Ua.indexOf(n.value);return r!==-1&&a!==-1?r-a:r!==-1?-1:a!==-1?1:0},"customSort");return t.sort(e)},"sortTags");function mu(t,e){if(!t)return!1;let o=parseInt(e.toFixed(2)||"0");return ru.some(({threshold:n,minInput:r})=>o<=n&&t.gte(new Qe(r)))}i(mu,"hasHighValueLoss");function hu(t){return(t||[]).filter(e=>{let o=e.fromAmountMinValue?new Qe(e.fromAmountMinValue):null,n=e.fromAmountMaxValue?new Qe(e.fromAmountMaxValue):null;return e.fromAmountRestrictionType==="EXCLUSIVE"?o?.gte(e.fromAmount)||n?.lte(e.fromAmount):o?.gt(e.fromAmount)||n?.lt(e.fromAmount)}).length>0}i(hu,"hasLimitError");function yu(t){let e=(t||[]).filter(l=>{let c=l.fromAmountMinValue?new Qe(l.fromAmountMinValue):null,p=l.fromAmountMaxValue?new Qe(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 Qe(e.fromAmountMinValue):null,n=e.fromAmountMaxValue?new Qe(e.fromAmountMaxValue):null,r=e.fromAmountRestrictionType==="EXCLUSIVE",a="",s="";return!r&&o&&o.gt(e.fromAmount)?(a=yt.t({id:"Required: >= {min} {symbol}",values:{min:P(o,6,6),symbol:e.from.symbol}}),s=ee().bridgeLimitErrors.increaseAmount):r&&o&&o.gte(e.fromAmount)&&(a=yt.t({id:"Required: > {min} {symbol}",values:{min:P(o,6,6),symbol:e.from.symbol}}),s=ee().bridgeLimitErrors.increaseAmount),!r&&n&&n.lt(e.fromAmount)?(a=yt.t({id:"Required: <= {max} {symbol}",values:{max:P(n,6,6),symbol:e.from.symbol}}),s=ee().bridgeLimitErrors.decreaseAmount):r&&n&&n.lte(e.fromAmount)&&(a=yt.t({id:"Required: < {max} {symbol}",values:{max:P(n,6,6),symbol:e.from.symbol}}),s=ee().bridgeLimitErrors.decreaseAmount),{swap:e,fromAmountRangeError:a,recommendation:s}}i(yu,"getLimitErrorMessage");function Su(t){let{fetchMetaStatus:e,anyWalletConnected:o,fetchingQuote:n,inputAmount:r,quote:a,warning:s,error:l,needsToWarnEthOnPath:c}=t;return e!=="success"?{title:ko().connectWallet,action:"connect-wallet",disabled:!0}:o?n||!a||l||!r||r==="0"?{title:ko().swap,action:"confirm-swap",disabled:!0}:s?{title:ko().swapAnyway,action:"confirm-warning",disabled:!1}:c?{title:ko().ethWarning,action:"confirm-warning",disabled:!1}:{title:ko().swap,action:"confirm-swap",disabled:!1}:{title:ko().connectWallet,action:"connect-wallet",disabled:!1}}i(Su,"getSwapButtonState");function Qa(t,e,o){let n=parseFloat(e||"0");return!(t&&(!o||o.lte(le))&&e&&e!=="0"&&n!==0)}i(Qa,"canComputePriceImpact");function Ha(t,e){let o=le;for(let n=0;n<t.fee.length;n++){let r=t.fee[n];if(r.expenseType==="DECREASE_FROM_OUTPUT")continue;let a=e(r.asset)?.usdPrice||null;o=o.plus(new Qe(r.amount).multipliedBy(a||0))}return o}i(Ha,"getUsdFeeOfStep");function Ur(t,e){return t.reduce((o,n)=>o.plus(Ha(n,e)),le)}i(Ur,"getTotalFeeInUsd");function qa(t){let e=le;return e=e.plus(new Qe(t.amount).multipliedBy(t.price||0)),e}i(qa,"getUsdFee");function Cu(t){return t.reduce((e,o)=>e.plus(qa(o)),le)}i(Cu,"getTotalFeesInUsd");function ku(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(ku,"getFeesGroup");function Tu(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(Tu,"checkSlippageErrors");function du(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(du,"checkSlippageWarnings");function zr(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(zr,"getMinRequiredSlippage");function fu(t,e){return e?parseFloat(t)>=parseFloat(e):!0}i(fu,"hasProperSlippage");function vu(t){let{fromToken:e,toToken:o,inputAmount:n,wallets:r,selectedWallets:a,disabledLiquiditySources:s,liquiditySources:l,excludeLiquiditySources:c,slippage:p,affiliateRef:u,affiliatePercent:m,affiliateWallets:h,destination:d,contractCall:f}=t,g=a?.reduce((S,T)=>(S[T.chain]=T.address,S),{}),k=[];return r?.forEach(S=>{k.push({blockchain:S.chain,addresses:[S.address]})}),{amount:n.toString(),affiliateRef:u??void 0,affiliatePercent:m??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:k,selectedWallets:g??{},slippage:p.toString(),contractCall:f,...d&&{destination:d},...c&&{swapperGroups:s.concat(l??[]),swappersGroupsExclude:!0},...!c&&{swapperGroups:l?.filter(S=>!s.includes(S)),swappersGroupsExclude:!1}}}i(vu,"createQuoteRequestBody");function wu(t){return t.reduce((o,n)=>(o[n.chain]={address:n.address,walletType:n.walletType},o),{})}i(wu,"getWalletsForNewSwap");function xn(t){let e=t.requestAmount,o=t.swaps[0].from.usdPrice;if(!(!e||!o))return new Qe(e).multipliedBy(o)}i(xn,"getUsdInputFrom");function dt(t){let e=t?.outputAmount||null,o=t.swaps[t.swaps.length-1].to.usdPrice;if(!(!e||!o))return new Qe(e).multipliedBy(o)}i(dt,"getUsdOutputFrom");function za(t,e){return new Qe(e).div(new Qe(t)).minus(1).multipliedBy(eu).toNumber()}i(za,"getPercentageChange");function gu(t,e){let o=xn(t),n=dt(t),r=dt(e);if(!o||!n||!r)return!1;let a=za(n.toString(),r.toString());return iu.some(({threshold:s,minInput:l})=>a<=s&&o.isGreaterThanOrEqualTo(l))}i(gu,"isOutputAmountChangedExcessively");function bu(t,e,o){let n=t.validationStatus,r=mo({filter:"required",quote:t});return e.sort((s,l)=>r.indexOf(s.chain)-r.indexOf(l.chain)).flatMap(s=>su(s,n)||[]).filter(s=>!s.ok).map(s=>{let l=s.asset.symbol,c=P(new Qe(s.currentAmount.amount).shiftedBy(-s.currentAmount.decimals),8,8),p=P(new Qe(s.requiredAmount.amount).shiftedBy(-s.requiredAmount.decimals),8,8),u="";return s.reason==="FEE"&&(u=yt.t(" for network fee")),s.reason==="INPUT_ASSET"&&(u=yt.t(" for swap")),s.reason==="FEE_AND_INPUT_ASSET"&&(u=yt.t(" for input and network fee")),yt.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:ut(s.asset.blockchain,o)}})})}i(bu,"generateBalanceWarnings");function En(t){return!!t&&t.networkStatus!==null&&t.networkStatus!==Qr.NetworkChanged}i(En,"isNetworkStatusInWarningState");function xu(t,e){let o="bellow button or",n=t.extraMessage,r=t.extraMessageDetail;if(t.networkStatusExtraMessageDetail?.includes(o)&&(t.networkStatusExtraMessageDetail=t.networkStatusExtraMessageDetail.replace(o,"")),En(e))switch(n=t.networkStatusExtraMessage||"",r=t.networkStatusExtraMessageDetail||"",e?.networkStatus){case Qr.WaitingForConnectingWallet:n=n||yt.t("Waiting for connecting wallet");break;case Qr.WaitingForQueue:n=n||yt.t("Waiting for other running tasks to be finished");break;case Qr.WaitingForNetworkChange:n=n||yt.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(xu,"getSwapMessages");function Eu(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(Eu,"getLastConvertedTokenInFailedSwap");function Iu(t){return t.status==="failed"}i(Iu,"shouldRetrySwap");function Au(t,e,o,n,r,a){if(!n||t)return!0;let s=mo({filter:"all",quote:n}),l=mo({filter:"required",quote:n}),c=s.every(m=>r.some(h=>h.chain===m)),p=l.every(m=>r.some(h=>h.chain===m)),u=o&&a?_o(a,o):!1;return!e&&!c||e&&!o||e&&!!o&&(!u||!p)}i(Au,"isConfirmSwapDisabled");function Nu(t,e){return t.blockchain===e.blockchain&&t.symbol===e.symbol&&t.address===e.address}i(Nu,"isTokensIdentical");var Hr=i((t,e)=>t?.usdPrice?new Ze(e||le).multipliedBy(t?.usdPrice||0):null,"getUsdValue"),O=zo(wC()(bC(t=>({fromBlockchain:null,fromToken:null,inputAmount:"",outputAmount:null,inputUsdValue:new Ze(0),outputUsdValue:new Ze(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=le,a=o.inputUsdValue;return fn(o.inputAmount)?(e&&(n=e?.outputAmount?new Ze(e?.outputAmount):null,a=xn(e)??le,r=dt(e)??le),{selectedQuote:e,...!!e&&{outputAmount:n,outputUsdValue:r,inputUsdValue:a}}):{}}),resetAlerts:()=>t(()=>({error:null,warning:null})),resetQuote:()=>t(()=>({selectedQuote:null,outputAmount:null,outputUsdValue:new Ze(0),quotes:null,refetchQuote:!0,error:null,warning:null})),setFromBlockchain:e=>{t(o=>o.fromBlockchain?.name===e?.name?{}:{fromBlockchain:e,inputUsdValue:new Ze(0),...o.fromToken&&{selectedQuote:null,fromToken:null,outputAmount:null,outputUsdValue:new Ze(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:Hr(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 Ze(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 Ze(0),selectedQuote:null},...!!o.fromToken&&{inputUsdValue:Hr(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:Hr(n??null,s),outputUsdValue:new Ze(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?Hr(e.toToken,e.outputAmount?.toString()||""):new Ze(0)})),resetFromBlockchain:()=>t(()=>({fromToken:null,fromBlockchain:null,outputUsdValue:new Ze(0),inputUsdValue:new Ze(0),inputAmount:"",outputAmount:null,selectedQuote:null})),resetToBlockchain:()=>t(()=>({toToken:null,toBlockchain:null,outputAmount:null,outputUsdValue:new Ze(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})})))),Bu=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 Wu(){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,m=y().fetchStatus,h=y().blockchains(),{findToken:d}=y(),{setAffiliateRef:f,setAffiliatePercent:g,setAffiliateWallets:k}=y(),C=u?.from?.tokens,S=u?.from?.blockchains,T=u?.to?.tokens,w=u?.to?.blockchains,E=qr(void 0),B=qr(void 0),I=qr(void 0),x=qr(void 0);Ko(()=>{typeof u.amount<"u"&&t(u.amount.toString())},[u?.amount]),Ko(()=>{if(m==="success"){r();let b=h.find(M=>M.name===u?.from?.blockchain),v=u?.from?.token,A=v&&d(v);(b||!b&&I.current)&&n(b??null),A?a({token:A,meta:{blockchains:h}}):!A&&E.current&&a({token:null}),I.current=u?.from?.blockchain,E.current=u?.from?.token}},[u?.from?.token?.symbol,u?.from?.token?.address,u?.from?.token?.blockchain,u?.from?.blockchain,m]),Ko(()=>{Sa(s,C)&&a({token:null}),Ca(c,S)&&n(null)},[C,S]),Ko(()=>{Sa(l,T)&&a({token:null}),Ca(p,w)&&o(null)},[T,w]),Ko(()=>{if(m==="success"){r();let b=h.find(M=>M.name===u?.to?.blockchain),v=u?.to?.token,A=v&&d(v);(b||!b&&x.current)&&o(b??null),A?e({token:A,meta:{blockchains:h}}):!A&&B.current&&e({token:null}),x.current=u?.to?.blockchain,B.current=u?.to?.token}},[u?.to?.token?.symbol,u?.to?.token?.address,u?.to?.token?.blockchain,u?.to?.blockchain,m]),Ko(()=>{f(u?.affiliate?.ref??null),g(u?.affiliate?.percent??null),k(u?.affiliate?.wallets??null)},[u?.affiliate?.ref,u?.affiliate?.percent,u?.affiliate?.wallets])}i(Wu,"useSyncStoresWithConfig");import{useEffect as Ka,useRef as xC}from"react";import{useInRouterContext as EC,useLocation as IC,useSearchParams as AC}from"react-router-dom";function Ga(t,e){let o=t.split("--");return{blockchain:e.name,address:o?.[1]||null,symbol:o[0]}}i(Ga,"convertTokenSearchParamToAsset");function Va(t){if(t)return`${t.symbol}${t.address?`--${t.address}`:""}`}i(Va,"tokenToSearchParam");function Xa(){let t=IC(),[e,o]=AC(),{fromBlockchain:n,toBlockchain:r,fromToken:a,toToken:s,inputAmount:l,setFromBlockchain:c,setToBlockchain:p,setFromToken:u,setToToken:m,setInputAmount:h}=O(),d=y().fetchStatus,f=y().blockchains(),g=EC(),{updateIframe:k,updateCampaignMode:C}=y(),S=y().isInCampaignMode(),T=xC(),{findToken:w}=y(),E=i(()=>{let I={};for(let[L,H]of e.entries())L.startsWith("utm_")&&(I[L]=H);let x=e.get("fromAmount"),b=e.get("fromBlockchain"),v=e.get("fromToken"),A=e.get("toBlockchain"),M=e.get("toToken"),_=e.get("autoConnect"),j=e.get("clientUrl"),R=e.get("liquiditySources"),X=e.get("blockchain");return{fromAmount:x,fromBlockchain:b,fromToken:v,toBlockchain:A,toToken:M,autoConnect:_,clientUrl:j,liquiditySources:R,utmQueryParams:I,blockchain:X}},"getUrlSearchParams"),B=i(I=>{for(let x in I)I[x]||delete I[x];o(I,{replace:!0})},"updateUrlSearchParams");Ka(()=>{let{autoConnect:I,clientUrl:x,utmQueryParams:b,blockchain:v}=E();g&&d==="success"&&B({fromBlockchain:n?.name,fromToken:Va(a),toBlockchain:r?.name,toToken:Va(s),fromAmount:l,autoConnect:I??void 0,clientUrl:x??void 0,blockchain:v??void 0,liquiditySources:S?T.current:void 0,...b})},[t.pathname,l,n,a,r,s,S]),Ka(()=>{if(!g)return;let I=E();if(!T.current&&I.liquiditySources&&(T.current=I.liquiditySources),I.fromAmount&&h(I.fromAmount),d==="success"){let x=f.find(M=>M.name===I.fromBlockchain),b=I.fromToken&&x?w(Ga(I.fromToken,x)):void 0,v=f.find(M=>M.name===I.toBlockchain),A=I.toToken&&v?w(Ga(I.toToken,v)):void 0;x&&(c(x),b&&u({token:b,meta:{blockchains:f}})),v&&(p(v),A&&m({token:A,meta:{blockchains:f}}))}},[d]),Ka(()=>{let{clientUrl:I,liquiditySources:x}=E();k("clientUrl",I||void 0),C("liquiditySources",x?.split(",")??void 0)},[])}i(Xa,"useSyncUrlAndStore");import{i18n as Jo}from"@lingui/core";import{Alert as Qk,Button as Hk,darkTheme as qk,Divider as ws,DoneIcon as Gk,styled as Vk,TextField as Kk,Typography as jk}from"@rango-dev/ui";import Ue,{useState as Xk}from"react";import{useNavigate as Yk,useSearchParams as Zk}from"react-router-dom";import{ChevronRightIcon as NC,Divider as Du,Image as BC,Typography as $u}from"@rango-dev/ui";import St from"react";import{darkTheme as Lu,styled as Ya}from"@rango-dev/ui";var Mu=Ya("div",{display:"flex",justifyContent:"space-between",width:"100%",height:"$40",padding:"$4 $10",borderRadius:"$sm",cursor:"pointer",alignItems:"center",backgroundColor:"$neutral300",[`.${Lu} &`]:{backgroundColor:"$neutral400"},"&:hover":{backgroundColor:"$secondary100",[`.${Lu} &`]:{backgroundColor:"$neutral500"}},variants:{disabled:{true:{cursor:"default","&:hover":{borderColor:"$neutral300","& svg":{color:"$neutral700"}}}}}}),Pu=Ya("div",{display:"flex",flexDirection:"column",width:"100%",".title_typography":{textTransform:"capitalize"}}),_u=Ya("div",{display:"flex"});function Za(t){let{onClick:e,value:o,title:n,hasLogo:r,placeholder:a,disabled:s}=t;return St.createElement(Pu,null,St.createElement($u,{size:"large",variant:"label"},n),St.createElement(Du,{size:10}),St.createElement(Mu,{onClick:s?void 0:e,disabled:s},St.createElement(_u,null,r&&St.createElement(St.Fragment,null,St.createElement(BC,{src:o?.logo,size:16,useAsPlaceholder:!o?.logo,type:"circular"}),St.createElement(Du,{size:4,direction:"horizontal"})),St.createElement($u,{className:"title_typography",size:"medium",variant:"label"},o?.name||a)),St.createElement(NC,{size:12,color:"black"})))}i(Za,"BlockchainSelectorButton");import{i18n as es}from"@lingui/core";import{Button as MC,Divider as Hu,MessageBox as PC}from"@rango-dev/ui";import Yt,{useEffect as qu,useState as ts}from"react";import{i18n as Gr}from"@lingui/core";import{Button as Qu,Divider as To,ExternalLinkIcon as WC,Image as LC,Typography as Xo}from"@rango-dev/ui";import ye from"react";var Fu="https://blog.rango.exchange/understanding-the-risks-of-using-custom-token-contract-addresses-96022308eca4";function Ou(t,e){if(e.type==="COSMOS")return"";let o=e.info?.addressUrl;return!o||!t?"":o.replace("{wallet}",t)}i(Ou,"generateExplorerLink");import{darkTheme as jo,styled as Uu}from"@rango-dev/ui";var Ja=Uu("a",{textDecoration:"none",color:"$colors$neutral700",[`.${jo} &`]:{color:"$colors$neutral900"},"& svg":{marginLeft:"$4",color:"$colors$neutral700",[`.${jo} &`]:{color:"$colors$neutral900"}},variants:{hasHover:{true:{"&:hover":{color:"$colors$secondary550",[`.${jo} &`]:{color:"$colors$secondary500"},"& svg":{color:"$colors$secondary550",[`.${jo} &`]:{color:"$colors$secondary500"}}}},false:{}}}}),zu=Uu("div",{display:"flex",justifyContent:"center",flexDirection:"column",alignItems:"center",textAlign:"center","& ._blockchain-name, & ._coin-source":{color:"$colors$neutral600",[`.${jo} &`]:{color:"$colors$neutral800"}},"& ._coin-source-name, & ._custom-token-description":{color:"$colors$neutral700",[`.${jo} &`]:{color:"$colors$neutral900"}}});function Ra(t){let{open:e,onClose:o,token:n,onExit:r,onSubmitClick:a,blockchain:s}=t,l=Ou(n.address,s),c=i(()=>window.open(Fu,"_blank"),"onClickLearnMore");return ye.createElement(J,{open:e,dismissible:!0,onClose:o,onExit:r,container:N()},ye.createElement(zu,null,ye.createElement(LC,{src:n.image===""?gr:n.image,size:45,type:"circular"}),ye.createElement(To,{size:4}),ye.createElement(Xo,{variant:"title",size:"medium"},n.symbol),ye.createElement(Xo,{variant:"body",size:"small",className:"_blockchain-name"},s.displayName),ye.createElement(To,{size:4}),ye.createElement(Xo,{variant:"body",size:"medium"},l?ye.createElement(Ja,{hasHover:!0,href:l,target:"_blank",rel:"nofollow noreferrer"},n.address,ye.createElement(WC,{size:12,color:"gray"})):ye.createElement(Ja,null,n.address)),ye.createElement(To,{size:4}),n.coinSource&&ye.createElement(Xo,{className:"_coin-source",variant:"body",size:"xsmall"},Gr.t("via")," ",ye.createElement(Xo,{className:"_coin-source-name",variant:"body",size:"xsmall"},n.coinSource)),ye.createElement(To,{size:"32"}),ye.createElement(Xo,{size:"medium",variant:"body",className:"_custom-token-description"},Gr.t("This token is not part of our verified token list. please verify its source and make sure to understand all associated risks before proceeding."))),ye.createElement(To,{size:40}),ye.createElement(To,{size:10}),ye.createElement(Qu,{id:"widget-custom-token-modal-import-btn",variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:a},Gr.t("Import Anyway")),ye.createElement(To,{size:10}),ye.createElement(Qu,{id:"widget-custom-token-modal-learn-more-btn",variant:"outlined",size:"large",type:"primary",fullWidth:!0,onClick:c},Gr.t("Learn More")))}i(Ra,"CustomTokenModal");function In(t){let{token:e,blockchain:o,error:n,address:r,fetchCustomToken:a,onCloseErrorModal:s,onImport:l,onExitErrorModal:c,onExitImportModal:p}=t,{setCustomToken:u}=y(),[m,h]=ts(!1),[d,f]=ts(!1),[g,k]=ts(!1),C=i(()=>{o&&a?.({blockchain:o.name,tokenAddress:r})},"getCustomToken"),S=i(()=>{n?.type!=="network-error"&&s?.(),h(!1)},"closeErrorModal"),T=i(()=>{k(!0),S()},"handleErrorModalButtonClick"),w=i(()=>{g&&n?.type==="network-error"&&(k(!1),C()),c()},"handleExit"),E=i(()=>{e&&(u(e),l())},"handleSubmit");return qu(()=>{n&&h(!0)},[n]),qu(()=>{o&&e&&f(!0)},[o,e]),Yt.createElement(Yt.Fragment,null,Yt.createElement(J,{open:m,dismissible:!0,onClose:S,onExit:w,container:N()},Yt.createElement(PC,{title:n?.title??"",type:"error",description:n?.message||es.t("Failed Network, Please retry.")},Yt.createElement(Hu,{size:40}),Yt.createElement(Hu,{size:10}),Yt.createElement(MC,{id:`widget-add-custom-token-${n?.type==="network-error"?"retry":"add-another"}-btn`,variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:T},n?.type==="network-error"?es.t("Retry"):es.t("Add another custom token")))),o&&e&&Yt.createElement(Ra,{blockchain:o,token:e,onSubmitClick:E,onClose:()=>f(!1),open:d,onExit:p}))}i(In,"ImportCustomToken");import{useManager as $k}from"@rango-dev/queue-manager-react";import{BottomLogo as Fk,Divider as um,Header as Ok}from"@rango-dev/ui";import be,{useEffect as Rr,useRef as mm,useState as dm}from"react";import{useRef as _C}from"react";function Vr(){return window.self!==window.top}i(Vr,"isAppLoadedIntoIframe");function os(){let t=_C(null),{iframe:e}=y(),o=Vr()&&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(os,"useIframe");import{useNavigate as DC}from"react-router-dom";function Oe(){let t=DC();return()=>t(-1)}i(Oe,"useNavigateBack");import{createTheme as cs,darkTheme as YC,lightTheme as ZC}from"@rango-dev/ui";import{useEffect as JC,useState as RC}from"react";import{theme as jC,darkColors as XC}from"@rango-dev/ui";import ss from"react";function $C(t){return t.startsWith("#")&&(t=t.slice(1)),t.length===3?`#${t.split("").reduce(function(n,r){return n+r+r},"")}`:`#${t}`}i($C,"expandShortHexColor");function FC(t){return/[0-9]+$/.test(t)}i(FC,"isOverridingColor");function OC(t,e){return t.padStart(e,"0")}i(OC,"pad");function ns(t){let e=Math.min(Math.max(Math.round(t),0),255);return OC(e.toString(16),2)}i(ns,"intToHex");function UC(t){return`#${ns(t.red)}${ns(t.green)}${ns(t.blue)}`}i(UC,"rgbToHex");function zC(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(zC,"hexToRGB");function QC(t,e){let o=1-.11*e;return{red:t.red*o,green:t.green*o,blue:t.blue*o}}i(QC,"generateShade");function HC(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(HC,"generateTint");function qC(t){return Gu(t,QC)}i(qC,"calculateShades");function GC(t){return Gu(t,HC)}i(GC,"calculateTints");function Gu(t,e){let o=zC(t),n=[];for(let r=1;r<9;r++)n.push(UC(e(o,r)));return n}i(Gu,"calculateColors");function rs(t,e,o){let a=GC(t).reverse().concat(t),s=qC(t),l=a.concat(s),c={},p=l.length;for(let u=0;u<p;u++){let m=100+(o?p-1-u:u)*50;c[`${e}${m}`]=l[u]}return c}i(rs,"createTintsAndShades");function is(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=$C(a);Object.assign(n,rs(c,r,s))}}return{...n,...e}}i(is,"expandToGenerateThemeColors");var Vu=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=Vu(o%52)+e;return Vu(o%52)+e},"toAlphabeticName"),KC=i((t,e)=>{let o=e.length;for(;o;)t=t*33^e.charCodeAt(--o);return t},"toPhash"),as=i(t=>VC(KC(5381,JSON.stringify(t))>>>0),"toHash");function ls(t){let e=jC.colors,o={...e,...XC},n,r;if(t?.light){let s={colors:is(e,t.light)};n={id:`${ya}-light-${as(s)}`,tokens:s}}if(t?.dark){let s={colors:is(o,t.dark,{reverseNeutralRange:!0})};r={id:`${ya}-dark-${as(s)}`,tokens:s}}return{light:n,dark:r}}i(ls,"customizedThemeTokens");function Ku(t,e){if(t.length<=1)return t.map(({element:n,key:r})=>ss.cloneElement(n,{key:r}));let o=[];return t.forEach((n,r)=>{let{element:a,key:s}=n;if(o.push(ss.cloneElement(a,{key:s})),r<t.length-1){let l=`divider-${r}`;o.push(ss.cloneElement(e,{key:l}))}}),o}i(Ku,"joinList");function ju(){return window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches}i(ju,"doesWindowPreferDarkColorScheme");function Yo(t){let{colors:e,fontFamily:o=$c,borderRadius:n=ip,secondaryBorderRadius:r=ap}=t,[a,s]=RC(ju()?"dark":"light"),{theme:l}=y(),{dark:c,light:p}=ls(e),u=cs({shadows:t.shadows||{},radii:{primary:`${n}px`,secondary:`${r}px`},fonts:{widget:o}}),m=[u.className,ZC.className],h=[u.className,YC.className];if(p){let f=cs(p.id,p.tokens);m.push(f.className)}if(c){let f=cs(c.id,c.tokens);h.push(f.className)}return JC(()=>{let f=i(g=>{g.matches?s("dark"):s("light")},"switchThemeListener");return ju()&&s("dark"),window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",f),()=>{window.matchMedia("(prefers-color-scheme: dark)").removeEventListener("change",f)}},[]),{activeTheme:i(()=>{let f=m.join(" "),g=h.join(" ");return l==="auto"?a==="dark"?g:f:l==="dark"?g:f},"getActiveTheme"),mode:l==="auto"?a:l}}i(Yo,"useTheme");var ft=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 Xu}from"@lingui/core";import{Alert as ek,Button as tk}from"@rango-dev/ui";import Yu from"react";function ps(t){return Yu.createElement(ek,{action:Yu.createElement(tk,{id:"widget-active-tab-btn",onClick:t.onActivateTab,variant:"contained",size:"xxsmall",type:"warning"},Xu.t("Activate this tab")),type:"warning",variant:"alarm",title:Xu.t("Another tab is open and handles transactions.")})}i(ps,"ActivateTabAlert");import{i18n as us}from"@lingui/core";import{Button as ok,Divider as nk,MessageBox as rk}from"@rango-dev/ui";import Kr from"react";function ms(t){let{open:e,onClose:o,onConfirm:n}=t;return Kr.createElement(J,{open:e,dismissible:!0,onClose:o,container:N()},Kr.createElement(rk,{title:us.t("Activate current tab"),type:"warning",description:us.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.")},Kr.createElement(nk,{size:20}),Kr.createElement(ok,{id:"widget-modal-confirm-activate-tab-btn",variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:n},us.t("Confirm"))))}i(ms,"ActivateTabModal");import{ChevronLeftIcon as ik}from"@rango-dev/ui";import Zu from"react";function ds(t){return Zu.createElement(Et,{id:"widget-header-back-icon-btn",variant:"ghost",size:"small",onClick:t.onClick},Zu.createElement(ik,{color:"black",size:16}))}i(ds,"BackButton");import{i18n as ak}from"@lingui/core";import{Button as sk,Typography as lk}from"@rango-dev/ui";import fs from"react";function gs(t){return fs.createElement(jt,null,fs.createElement(sk,{id:"widget-header-cancel-btn",variant:"ghost",onClick:t.onClick,size:"xsmall"},fs.createElement(lk,{variant:"label",size:"medium",color:"error500"},ak.t("Cancel"))))}i(gs,"CancelButton");import{i18n as ck}from"@lingui/core";import{Image as pk,Tooltip as uk,WalletIcon as mk}from"@rango-dev/ui";import vo from"react";function hs(t){let{list:e}=ht(),o=e.filter(r=>r.state==="connected"),n=o.length?vo.createElement("div",{className:Pp()},o.map(r=>vo.createElement(Ar,{key:r.title},vo.createElement(pk,{src:r.image,size:14})))):ck.t("Connect Wallet");return vo.createElement(uk,{container:t.container,side:"bottom",content:n},vo.createElement(Et,{id:"widget-header-wallet-icon-btn",variant:"ghost",size:"small",onClick:t.onClick},t.isConnected&&vo.createElement(Bp,null),vo.createElement(mk,{size:18,color:"black"})))}i(hs,"WalletButton");import{i18n as Xr}from"@lingui/core";import{NotificationsIcon as Ak,Popover as Nk,SettingsIcon as Bk,Tooltip as Yr,TransactionIcon as Wk}from"@rango-dev/ui";import Be from"react";import{Notifications as hk}from"@rango-dev/ui";import yk from"react";import{useNavigate as Sk}from"react-router-dom";import{create as dk}from"zustand";import{persist as fk,subscribeWithSelector as gk}from"zustand/middleware";var we=zo(dk()(fk(gk((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 ys(){let t=Sk(),{getNotifications:e,clearNotifications:o}=we(),n=e(),r=y().blockchains(),{findToken:a}=y();return yk.createElement(hk,{list:n,getBlockchainImage:l=>Ac(l,r),getTokenImage:l=>a(l)?.image,onClickItem:i(l=>{t(`${F.swaps}/${l}`)},"onClickItem"),onClearAll:o})}i(ys,"NotificationContent");import{useManager as Ck}from"@rango-dev/queue-manager-react";import{InProgressIcon as kk}from"@rango-dev/ui";import Ju from"react";var Tk=i(()=>{let{manager:t}=Ck();return ft(t).map(({swap:o})=>o).find(o=>o.status==="running")?Ju.createElement(Mp,null,Ju.createElement(kk,{color:"info",size:6})):null},"InProgressTransactionBadge"),Ru=Tk;import{EventSeverity as vk}from"@rango-dev/queue-manager-rango-preset";import{Typography as wk}from"@rango-dev/ui";import em from"react";function tm(){let{getNotifications:t}=we(),e=t(),o=e.length,n=!!e.find(r=>r.event.messageSeverity===vk.WARNING);return o?em.createElement(Wp,{isSever:n},em.createElement(wk,{variant:"body",size:"xsmall",color:"$background"},o)):null}i(tm,"NotificationsBadge");import{RefreshProgressButton as bk}from"@rango-dev/ui";import Ss,{useEffect as xk,useState as om}from"react";var Ek=1e3,nm=60,Ik=100;function jr({onClick:t}){let[e,o]=om(0),[n,r]=om(!1),a=i(c=>{document.hidden&&c&&s(c)},"handleVisibilityChange");xk(()=>{let c;return t?c=window.setInterval(()=>{o(p=>p+1),e===nm&&l()},Ek):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 Ss.createElement(Et,{id:"widget-header-refresh-icon-btn",variant:"ghost",size:"small",style:{paddingTop:0,paddingBottom:0},onClick:l,disabled:!t},Ss.createElement(Lp,{onTransitionEnd:()=>r(!1),isRefetched:n},Ss.createElement(bk,{size:22,color:t?"black":"gray",progress:e/nm*Ik})))}i(jr,"RefreshButton");function wo(t){let{onClickRefresh:e,onClickHistory:o,onClickSettings:n,hidden:r=[],container:a}=t,{config:{features:s}}=y(),l=Ye("notification",s)||r.includes("notifications");return Be.createElement(Be.Fragment,null,!r.includes("refresh")&&Be.createElement(Yr,{container:a||N(),side:"top",content:Xr.t("Refresh")},Be.createElement(jr,{onClick:e})),!l&&Be.createElement(Nk,{align:"end",alignOffset:-88,sideOffset:15,collisionPadding:{right:20,left:20},container:N(),content:Be.createElement(ys,null)},Be.createElement("div",null,Be.createElement(Yr,{container:N(),side:"top",content:Xr.t("Notifications")},Be.createElement(Et,{id:"widget-header-notification-icon-btn",size:"small",variant:"ghost"},Be.createElement(Ak,{size:18,color:"black"}),Be.createElement(tm,null))))),!r.includes("settings")&&Be.createElement(Yr,{container:N(),side:"top",content:Xr.t("Settings")},Be.createElement(Et,{id:"widget-header-setting-icon-btn",size:"small",variant:"ghost",onClick:n},Be.createElement(Bk,{size:18,color:"black"}))),!r.includes("history")&&Be.createElement(Yr,{container:N(),side:"top",content:Xr.t("History")},Be.createElement(Et,{id:"widget-header-history-icon-btn",size:"small",variant:"ghost",onClick:o},Be.createElement(Wk,{size:18,color:"black"}),Be.createElement(Ru,null))))}i(wo,"HeaderButtons");import{i18n as Cs}from"@lingui/core";import{Divider as im,MessageBox as Pk,RefreshIcon as _k}from"@rango-dev/ui";import Zo from"react";import{Button as Lk,styled as Mk}from"@rango-dev/ui";var rm=Mk(Lk,{"& span":{display:"flex",justifyContent:"center",alignItems:"center"}});function ks(t){let{open:e,onClose:o}=t;return Zo.createElement(J,{open:e,dismissible:!0,onClose:o,container:N()},Zo.createElement(Pk,{title:Cs.t("Something went wrong"),type:"error",description:Cs.t("Something went wrong. Please refresh the app.")},Zo.createElement(im,{size:30}),Zo.createElement(rm,{variant:"outlined",size:"large",type:"primary",fullWidth:!0,onClick:()=>location.reload()},Zo.createElement(_k,{size:20,color:"primary"}),Zo.createElement(im,{size:4,direction:"horizontal"}),Cs.t("Refresh"))))}i(ks,"RefreshModal");function Ts(t){let e=t.target;if(e){let o=e.scrollTop,n=N();o>1?n.classList.add("rng-scrolled"):n.classList.remove("rng-scrolled")}}i(Ts,"onScrollContentAttachStatusToContainer");import{css as Dk,styled as Zr}from"@rango-dev/ui";var am="700px",Jr=Dk({borderRadius:"$primary",display:"flex",flexDirection:"column",overflow:"hidden",boxShadow:"$mainContainer"}),sm=Zr("div",{position:"relative",width:"100vw",minWidth:"300px",maxWidth:"390px",backgroundColor:"$background",variants:{height:{auto:{height:"auto",maxHeight:am},fixed:{height:am}},showBanner:{true:{overflow:"visible"}}}}),lm=Zr("div",{position:"relative",overflow:"hidden",flexGrow:1,display:"flex",flexDirection:"column",padding:0,overflowY:"auto"}),cm=Zr("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"}}}),pm=Zr("div",{width:"100%",position:"absolute",bottom:"-$10",transform:"translateY(100%)",overflow:"hidden"});function oe(t){let{connectHeightObserver:e,disconnectHeightObserver:o}=os(),{children:n,header:r,footer:a,height:s="fixed"}=t,{fetchStatus:l,connectedWallets:c,config:{__UNSTABLE_OR_INTERNAL__:p}}=y(),[u,m]=dm(!1),{config:{features:h,theme:d}}=y(),{watermark:f}=ne(),g=f==="FULL",{activeTheme:k}=Yo(d||{}),[C,S]=dm(!1),T=Ye("connectWalletButton",h),{isActiveTab:w,tabManagerInitiated:E,showActivateTabModal:B,setShowActivateTabModal:I,activateCurrentTab:x}=ne(),b=Oe(),{manager:v}=$k(),M=ft(v).map(({swap:H})=>H).some(H=>H.status==="running"),_=i(()=>x(fo.forceClaim,M),"onActivateTab"),j=i(()=>{r.onWallet?.()},"onConnectWallet"),R=typeof r.hasBackButton>"u"||r.hasBackButton,X=mm(null),L=mm(null);return Rr(()=>{let H=(p?.swapBoxBanner?.routes?.length??0)===0,ae=!!p?.swapBoxBanner?.routes?.some(G=>location.pathname.endsWith(G));S(!!p?.swapBoxBanner&&(H||ae))},[p?.swapBoxBanner?.routes?.toString(),location.pathname]),Rr(()=>(Vr()&&L.current&&e(L.current),()=>{o()}),[]),Rr(()=>(X.current?.addEventListener("scroll",Ts),()=>{X.current?.removeEventListener("scroll",Ts)}),[]),Rr(()=>{m(l==="failed")},[l]),be.createElement(sm,{height:s,id:$e.SWAP_BOX_ID,className:`${k()} ${Jr()}`,ref:L,showBanner:C},be.createElement(Ok,{prefix:R?be.createElement(ds,{onClick:()=>{b(),r.onBack?.()}}):null,title:r.title,suffix:be.createElement(be.Fragment,null,r.suffix,r.onWallet&&!T&&be.createElement(hs,{container:N(),onClick:j,isConnected:!!c?.length}),r.onCancel&&be.createElement(gs,{onClick:r.onCancel}))}),be.createElement(lm,{ref:X},n),be.createElement(ms,{open:B,onClose:()=>I(!1),onConfirm:_}),be.createElement(cm,null,be.createElement("div",{className:"footer__content"},E&&!w&&be.createElement("div",{className:"footer__alert"},be.createElement(ps,{onActivateTab:_}),be.createElement(um,{size:10})),a),be.createElement(um,{size:12}),be.createElement("div",{className:`footer__logo ${g?"logo__show":"logo__hidden"}`},be.createElement(Fk,null))),C&&be.createElement(pm,null,p?.swapBoxBanner?.element),be.createElement(ks,{open:u,onClose:()=>m(!1)}))}i(oe,"Layout");import{styled as Uk}from"@rango-dev/ui";var fm="$20 $20 $10 $20",An=Uk("div",{padding:fm,overflowY:"auto",flexGrow:1});import{styled as zk}from"@rango-dev/ui";var re=zk("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 Zt}from"@lingui/core";import{useState as vs}from"react";function gm(){let[t,e]=vs(!1),[o,n]=vs(null),[r,a]=vs(null),{findToken:s}=y(),l=y().customTokens(),c=i(()=>{a(null),e(!1),n(null)},"resetState");function p(m,h){switch(m){case"duplicated":return{type:m,title:Zt.t("Duplicate Token"),message:Zt.t("The address you entered is duplicate, please enter a new address.")};case"token-exist":return{type:m,title:Zt.t("Token Already Exists"),message:Zt.t("There's no need to add this token again because it already exists and is supported by us.")};case"not-found":return{type:m,title:Zt.t("Token Not Found"),message:Zt.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:h}})};case"network-error":return{type:m,title:Zt.t("Network error"),message:Zt.t("An error occurred while retrieving token data.")}}}return i(p,"produceErrorMessage"),{fetchCustomToken:i(async({blockchain:m,tokenAddress:h})=>{e(!0);try{if(l.some(C=>C.address?.toLowerCase()===h.toLowerCase())){let C=p("duplicated");n(C);return}let f=await ot().getCustomToken({blockchain:m,address:h});if(!f||!f.token||f.error){let C=p("not-found",m);n(C);return}let g=f.token;if(s({blockchain:g.blockchain,address:g.address,symbol:g.symbol})){let C=p("token-exist");n(C);return}return a({...g,warning:!0})}catch(d){if(d.code==="ERR_BAD_REQUEST"){let f=p("not-found",m);n(f);return}n(p("network-error"));return}finally{e(!1)}},"fetchCustomToken"),token:r,loading:t,error:o,resetState:c}}i(gm,"useFetchCustomToken");var Jk=Vk("div",{display:"flex",justifyContent:"space-between",flexDirection:"column",flex:1,"& ._text-field":{padding:"$4 $10",backgroundColor:"$neutral300",[`.${qk} &`]:{backgroundColor:"$neutral400"},borderRadius:"$sm",height:"$40"}});function hm(){let t=Yk(),[e]=Zk(),o=Oe(),n=y().blockchains(),r=e.get("blockchain")||"",a=co(r,n),[s,l]=Xk(""),{fetchCustomToken:c,token:p,loading:u,error:m,resetState:h}=gm(),d=!!a&&_o(a,s),f=!a||!s||!d,g=i(()=>{a&&c({blockchain:r,tokenAddress:s})},"getCustomToken");return Ue.createElement(oe,{header:{title:Jo.t("Add Custom Token")}},Ue.createElement(re,null,Ue.createElement(Jk,null,Ue.createElement("div",null,Ue.createElement(Za,{onClick:()=>t(F.blockchains,{replace:!0}),hasLogo:!!a?.logo,value:a?{name:a.displayName,logo:a.logo}:void 0,title:Jo.t("Select chain"),placeholder:Jo.t("Select chain")}),Ue.createElement(ws,{size:"24"}),Ue.createElement(jk,{size:"large",variant:"label"},Jo.t("Enter Address")),Ue.createElement(ws,{size:10}),Ue.createElement(Kk,{fullWidth:!0,disabled:!a,variant:"contained",placeholder:Jo.t("Enter token address"),size:"large",value:s,suffix:!!s&&d&&Ue.createElement(Gk,{color:"success",size:12}),onChange:k=>l(k.target.value)}),!d&&!!s&&Ue.createElement(Ue.Fragment,null,Ue.createElement(ws,{size:4}),Ue.createElement(Qk,{type:"error",variant:"alarm",title:"Invalid Address"}))),Ue.createElement(Hk,{id:"widget-add-custom-token-import-btn",disabled:f,type:"primary",variant:"contained",loading:u,size:"large",onClick:g},Jo.t("Import"))),Ue.createElement(In,{token:p,blockchain:a??void 0,address:s,error:m??void 0,fetchCustomToken:c,onCloseErrorModal:()=>{m?.type!=="network-error"&&l("")},onImport:o,onExitErrorModal:h,onExitImportModal:h})))}i(hm,"AddCustomTokenPage");import{i18n as Rs}from"@lingui/core";import{useManager as _v}from"@rango-dev/queue-manager-react";import{Alert as Dv,Button as $v,css as tl,Divider as el,IconButton as uf,styled as Fv,Typography as Ov,WalletIcon as Uv}from"@rango-dev/ui";import Le,{useEffect as Ii,useLayoutEffect as zv,useRef as Qv,useState as zn}from"react";import{useNavigate as Hv}from"react-router-dom";import{i18n as bo}from"@lingui/core";import{Alert as wT,BalanceErrors as bT,Button as qm,ChevronLeftIcon as xT,Divider as Ws,MessageBox as ET,Typography as Ls}from"@rango-dev/ui";import te,{useCallback as IT,useEffect as Gm,useMemo as AT,useState as tn}from"react";import{useNavigate as NT}from"react-router-dom";import{i18n as Is}from"@lingui/core";import{Alert as nT,ChevronDownIcon as rT,CloseIcon as iT,Divider as wm,IconButton as bm,PasteIcon as aT,Typography as sT,WalletIcon as lT}from"@rango-dev/ui";import We,{useEffect as cT,useRef as pT}from"react";import ni,{useRef as tT}from"react";import*as Ro from"@radix-ui/react-collapsible";import{keyframes as ym,styled as ei}from"@rango-dev/ui";var bs=300,Rk=ym({from:{height:0},to:{height:"var(--radix-collapsible-content-height)"}}),eT=ym({from:{height:"var(--radix-collapsible-content-height)"},to:{height:0}}),Sm=ei(Ro.Root,{borderRadius:"$sm",overflow:"hidden",variants:{selected:{true:{outlineWidth:1,outlineColor:"$secondary500",outlineStyle:"solid"}}}}),xs=ei(Ro.Trigger,{padding:"$0",border:"none",outline:"none",width:"100%",backgroundColor:"transparent",fontFamily:"inherit",cursor:"pointer"}),ti=ei(Ro.Content,{overflow:"hidden",variants:{open:{true:{animation:`${Rk} ${bs}ms ease-out`},false:{animation:`${eT} ${bs}ms ease-out`}}}}),oi=ei("div",{transition:`all ${bs}ms ease`,display:"flex",alignItems:"center",variants:{orientation:{down:{transform:"rotate(0)"},up:{transform:"rotate(180deg)"}}}});function ri(t){let{open:e,hasSelected:o,onOpenChange:n,children:r,onClickTrigger:a,trigger:s,triggerAnchor:l}=t,c=tT(null);return ni.createElement(Sm,{ref:c,className:"collapsible_root",selected:o&&e,open:e,onOpenChange:n},l==="top"&&ni.createElement(xs,{className:"collapsible_trigger",onClick:a},s),ni.createElement(ti,{className:"collapsible_content",open:e},r),l==="bottom"&&ni.createElement(xs,{className:"collapsible_trigger",onClick:a},s))}i(ri,"CustomCollapsible");import{darkTheme as Cm,styled as Es,TextField as oT}from"@rango-dev/ui";var km=Es("div",{padding:"$10 $0","& .button__content":{display:"flex",alignItems:"center"},"& .alarms":{paddingTop:"$5"},"& .collapsible_content":{backgroundColor:"$neutral100"},"& .collapsible_root":{backgroundColor:"$neutral100"}}),Tm=Es(oT,{backgroundColor:"$neutral100",padding:"$15"}),vm=Es("div",{width:"100%",borderRadius:"$sm",display:"flex",padding:"$15",justifyContent:"space-between",alignItems:"center",$$color:"$colors$neutral100",[`.${Cm} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",borderBottomRightRadius:"0",borderBottomLeftRadius:"0","&:focus-visible":{$$background:"$colors$secondary100",[`.${Cm} &`]:{$$background:"$colors$info700"},backgroundColor:"$$background",outline:0}});function xm(t){let{blockchain:e,handleOpenChange:o,open:n}=t,{customDestination:r,setCustomDestination:a}=O(),{config:s}=y(),l=y().blockchains(),c=mr(e.name,l),p=pT(null),u=s?.defaultCustomDestinations?.[e.name],m=navigator?.userAgent.includes("Firefox"),d=n&&!!r&&e&&!_o(e,r),f=i(()=>{a("")},"handleClear"),g=i(async C=>{if(C.preventDefault(),navigator.clipboard!==void 0){let S=await navigator.clipboard.readText();a(S),p?.current?.focus()}},"handlePaste"),k=i(()=>r?We.createElement(bm,{id:"widget-custom-destination-close-icon-btn",onClick:f,variant:"ghost"},We.createElement(iT,{size:12,color:"gray"})):m?null:We.createElement(bm,{id:"widget-custom-destination-paste-icon-btn",onClick:g,variant:"ghost"},We.createElement(aT,{size:16})),"renderSuffix");return cT(()=>{!!u&&r===null&&(a(u),o(!0))},[u]),We.createElement(km,null,We.createElement(ri,{onOpenChange:o,hasSelected:!0,open:n,triggerAnchor:"top",trigger:We.createElement(vm,null,We.createElement("div",{className:"button__content"},We.createElement(lT,{size:18,color:"info"}),We.createElement(wm,{size:4,direction:"horizontal"}),We.createElement(sT,{variant:"label",size:"medium",color:n?"$neutral600":void 0},Is.t("Send to a different address"))),We.createElement(oi,{orientation:n?"up":"down"},We.createElement(rT,{size:10,color:"secondary"}))),onClickTrigger:()=>o(!n)},We.createElement(Tm,{ref:p,style:{padding:0,paddingRight:r?"8px":"5px"},autoFocus:!r,placeholder:Is.t("Enter {blockchainName} address",{blockchainName:c}),value:r||"",suffix:k(),onChange:C=>{let S=C.target.value;a(S)}})),d&&We.createElement(We.Fragment,null,We.createElement(wm,{size:4}),We.createElement(nT,{variant:"alarm",type:"error",title:Is.t({values:{destination:r},id:"Address {destination} doesn't match the blockchain address pattern."})})))}i(xm,"CustomDestination");import{css as uT,darkTheme as As,IconButton as mT,styled as Dt}from"@rango-dev/ui";var Em=Dt("div",{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center"}),Im=Dt("div",{display:"flex",justifyContent:"space-evenly",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5",height:"100%"}),dT=Dt("button",{borderRadius:"$xm",padding:"$10",border:"0",display:"flex",justifyContent:"center",$$color:"$colors$neutral100",[`.${As} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",alignItems:"center",cursor:"pointer",width:110,position:"relative","&:hover":{$$color:"$colors$secondary100",[`.${As} &`]:{$$color:"$colors$neutral100"},backgroundColor:"$$color"},"&:focus-visible":{$$color:"$colors$secondary100",[`.${As} &`]:{$$color:"$colors$info700"},backgroundColor:"$$color",outline:0},variants:{selected:{true:{outlineWidth:1,outlineColor:"$secondary",outlineStyle:"solid"}}}}),Am=Dt(dT,{alignSelf:"stretch",minHeight:"93px"}),Nm=Dt("div",{padding:"$20 $20 $15 $20",display:"flex",justifyContent:"center",alignItems:"center",backgroundColor:"$neutral200",position:"relative",width:"100%"}),Bm=Dt(mT,{position:"absolute",left:"$20"}),Wm=Dt("div",{paddingTop:"$20"}),Lm=uT({display:"flex",justifyContent:"space-evenly",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5",height:"100%"}),Mm=Dt("div",{display:"flex"}),Pm=Dt("div",{overflow:"visible",width:"100%"});import{i18n as Um}from"@lingui/core";import{warn as ST}from"@rango-dev/logging-core";import{Divider as CT,SelectableWallet as kT,Typography as zm,WalletState as Qm}from"@rango-dev/ui";import Je,{useEffect as Hm,useState as Bn}from"react";import{Image as hT,MessageBox as yT}from"@rango-dev/ui";import Nn from"react";import{keyframes as fT,styled as Ns}from"@rango-dev/ui";var _m=Ns("div",{position:"relative"}),gT=fT({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}),Dm=Ns("div",{position:"absolute",border:"2px solid rgba(0, 0, 0, 0.1)",borderTop:"2px solid $info500",borderRadius:"$lg",width:"$45",height:"$45",animation:`${gT} 1s linear infinite`,top:0,bottom:0,right:0,left:0}),$m=Ns("div",{"& img":{borderRadius:"50%"}});import{i18n as en}from"@lingui/core";function Fm(t,e){switch(t){case"in-progress":return{type:"loading",title:en.t({id:"Add {blockchainDisplayName} Chain",values:{blockchainDisplayName:e}}),description:en.t({id:"Please approve the experimental chain pop-up in your wallet.",values:{blockchainDisplayName:e}})};case"completed":return{type:"success",title:en.t({id:"{blockchainDisplayName} Chain Added",values:{blockchainDisplayName:e}}),description:en.t({id:"The {blockchainDisplayName} chain has been successfully added to your wallet.",values:{blockchainDisplayName:e}})};case"rejected":return{type:"error",title:en.t("Request Rejected"),description:en.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(Fm,"generateMessageByStatus");function Om(t){let{status:e,displayName:o,image:n}=t,r=Fm(e,o),a=e=="in-progress";return Nn.createElement(yT,{type:r.type,title:r.title,description:r.description,icon:a?Nn.createElement(_m,null,Nn.createElement($m,null,Nn.createElement(hT,{src:n,size:45})),Nn.createElement(Dm,null)):void 0})}i(Om,"ExperimentalChainStatus");var TT=7,vT=3e3;function Bs(t){let{chain:e,isSelected:o,selectWallet:n,limit:r,onShowMore:a}=t,s=ne.use.isActiveTab(),{blockchains:l,connectedWallets:c}=y(),[p,u]=Bn(),[m,h]=Bn(null),[d,f]=Bn(!1),[g,k]=Bn(null),{suggestAndConnect:C}=ii(),{handleDisconnect:S}=Kt(),{list:T}=ht({chain:e}),[w,E]=Bn(T),B=T.length,I=r&&B-r>0,x=i(async v=>{f(!1),k("in-progress");try{await C(v.walletType,v.chain),k("completed")}catch{k("rejected")}},"addExperimentalChain");Hm(()=>{E(v=>{let A=T.findIndex(M=>o(M.type,e));return I&&A>1?[T[A]].concat(T.filter((M,_)=>_!==A)):v.map(M=>T.find(_=>_.type===M.type)??M)})},[JSON.stringify(T)]);let b=document.getElementById($e.SWAP_BOX_ID);return Hm(()=>{let v=null;return(g==="completed"||g==="rejected")&&(v=setTimeout(()=>k(null),vT)),()=>{v&&clearTimeout(v)}},[g]),Je.createElement(Je.Fragment,null,w.slice(0,r).map(v=>{let A=Rc({connectedWallets:c,walletType:v.type,chain:e}),M=A?xr(A,TT):"",_=wr(l(),e),j=!c.find(ae=>ae.walletType===v.type&&ae.chain===e),R=_&&j&&v.state===Qm.CONNECTED,X=R?Um.t({id:"Add {chain} chain",values:{chain:e}}):M,L=i(async()=>{let ae=v.state===Qm.DISCONNECTED,G=(v.isHub||!!v.needsNamespace)&&!M;ae?u(v):G?(await S(v.type),u(v)):R?(h({walletType:v.type,chain:e,address:A??""}),f(!0)):n({walletType:v.type,chain:e,address:A??""})},"onSelectableWalletClick"),H=m?.chain?mr(m.chain,l()):void 0;return Je.createElement(Je.Fragment,{key:`${v.title}_${H}`},!!m&&Je.createElement(J,{open:!!m&&d,container:b,onClose:()=>{h(null)}},Je.createElement($a,{displayName:H,onConfirm:()=>{x(m)}})),g&&Je.createElement(J,{open:!!g,onClose:k.bind(null,null),container:b},Je.createElement(Om,{status:g,displayName:H,image:v.image}),Je.createElement(CT,{direction:"vertical",size:32})),Je.createElement(kT,{key:v.type,description:X,onClick:L,selected:o(v.type,e),disabled:!s,...v}))}),Je.createElement(So,{wallet:p,onClose:()=>{u(void 0)},onConnect:()=>{t.onConnect&&(p?.type?t.onConnect(p.type):ST(new Error("The selected wallet hasn't been detected after the connection process finished. It usually shouldn't happen.")))}}),I&&Je.createElement(Am,{selected:!1,onClick:a},Je.createElement(zm,{variant:"label",size:"medium"},Um.t("Show more wallets"),Je.createElement(zm,{variant:"label",size:"medium",color:"$primary"},"\xA0+",B-(r??0)))))}i(Bs,"WalletList");var BT=2;function Vm(t){let{open:e,onClose:o,onCancel:n,onCheckBalance:r,loading:a}=t,s=NT(),l=y().blockchains(),{selectedQuote:c,setSelectedWallets:p,quoteWalletsConfirmed:u,setQuoteWalletConfirmed:m,customDestination:h,setCustomDestination:d}=O(),{config:f,connectedWallets:g,setWalletsAsSelected:k}=y(),[C,S]=tn(""),[T,w]=tn([]),[E,B]=tn(""),[I,x]=tn(!!h),b=AT(()=>mo({filter:"all",quote:c}),[c]),v=mo({filter:"required",quote:c}),A=l.find(D=>D.name===c?.swaps[c?.swaps.length-1].to.blockchain),M=i(D=>v.includes(D),"isWalletRequiredFor"),_=IT(()=>g.filter(D=>D.selected&&b.includes(D.chain)),[g,b]),[j,R]=tn(_()),[X,L]=tn([]),H=i((D,q)=>L(K=>K.concat({blockchain:D,walletType:q})),"addNextSelectedWallets"),ae=T.length>0,G=i((D,q)=>!!j.find(K=>K.walletType===D&&K.chain===q&&K.selected&&(M(q)||!M(q)&&!h)),"isSelected"),fe=i((D,q,K)=>{let ge=!1;return D.map(ce=>{if(ce.chain===q){let _e=ce.selected;return!ge&&K?(ge=!0,_e=!0):K||(_e=!1),{...ce,selected:_e}}return ce})},"updateSelectableWallets"),Ie=i(D=>{x(D),D?M(A?.name??"")||R(q=>fe(q,A?.name||"",!1)):(d(""),R(q=>fe(q,A?.name||"",!0)))},"handleCustomDestinationCollapsibleOpenChange"),je=i(D=>{if(C&&S(""),G(D.walletType,D.chain))return;let K=g.find(ge=>ge.walletType===D.walletType&&ge.chain===D.chain);K&&(n(),D.chain===A?.name&&I&&!M(A.name)&&(x(!1),d(null)),R(ge=>ge.filter(ce=>ce.chain!==D.chain).concat({...K,selected:!0})))},"onChange"),se=i(()=>{let D=j.filter(q=>q.selected);k(D),p(D),m(!0),o()},"onConfirmBalance"),pt=i(async()=>{w([]),B("");let D=await r?.({selectedWallets:j.filter(K=>K.selected),customDestination:h}),q=D.warnings;q?.balance?.messages&&w(q.balance.messages),D.error&&B(Rp(D.error)),!D.error&&!q?.balance?.messages.length?se():w(q?.balance?.messages??[])},"onConfirmWallets");Gm(()=>{R(D=>{let q=[];return D.forEach(K=>{!g.some(ce=>ce.chain===K.chain&&ce.walletType===K.walletType&&ce.address===K.address)||q.push(K)}),q=q.concat(g.filter(K=>!!!q.find(ce=>ce.chain===K.chain)&&K.selected&&b.includes(K.chain))),q})},[g,b]),Gm(()=>{let D=[];X.length>0&&(X.forEach(q=>{let K=g.find(ge=>ge.chain===q.blockchain&&ge.walletType===q.walletType);K?je(K):D.push(q)}),L(D))},[g,X]);let V=document.getElementById($e.SWAP_BOX_ID);return te.createElement(J,{open:e,onClose:()=>{u||s("../",{replace:!0}),o()},dismissible:!C,container:V,...!C&&{styles:{container:{height:"100%"}},footer:te.createElement(Mm,null,te.createElement(qm,{id:"widget-confirm-wallet-modal-confirm-btn",loading:a,disabled:Au(a,I,h,c,j,A),onClick:pt,variant:"contained",type:"primary",fullWidth:!0,size:"large"},bo.t("Confirm")))},...C&&{styles:{container:{height:"100%",padding:"$0"}},header:te.createElement(Nm,null,te.createElement(Bm,{id:"widget-confirm-wallet-modal-navigate-back-icon-btn",variant:"ghost",onClick:S.bind(null,"")},te.createElement(xT,{size:16})),te.createElement(Ls,{variant:"headline",size:"small"},bo.t({id:"Your {blockchainName} wallets",values:{blockchainName:ut(C,l)}})))},anchor:"center"},te.createElement(J,{open:ae,onClose:w.bind(null,[]),container:V},te.createElement(ET,{title:bo.t("Insufficient account balance"),type:"error",description:te.createElement(bT,{messages:T??[]})},te.createElement(qm,{id:"widget-confirm-wallet-modal-proceed-anyway-btn",variant:"outlined",size:"large",type:"primary",fullWidth:!0,onClick:se},bo.t("Proceed anyway")))),C&&te.createElement(Wm,null,te.createElement("div",{className:Lm()},te.createElement(Bs,{chain:C,isSelected:G,selectWallet:je,onShowMore:()=>S(C),onConnect:D=>{H(C,D)}}))),!C&&te.createElement(te.Fragment,null,E&&te.createElement(te.Fragment,null,te.createElement(wT,{variant:"alarm",type:"error",title:bo.t(E)}),te.createElement(Ws,{size:12})),te.createElement(Pm,null,b.map((D,q)=>{let K=l.find(Xe=>Xe.name===D),ge=`wallet-${q}`,ce=q===b.length-1,_e=ce&&A&&f?.customDestination!==!1;return te.createElement("div",{key:ge},te.createElement(Em,null,te.createElement(Ls,{variant:"title",size:"xmedium"},bo.t({id:"Your {blockchainName} wallets",values:{blockchainName:K?.shortName}})),te.createElement(Ls,{variant:"label",color:"$neutral700",size:"medium"},bo.t({id:"You need to connect a {blockchainName} wallet.",values:{blockchainName:K?.shortName}}))),te.createElement(Ws,{size:24}),te.createElement(Im,null,te.createElement(Bs,{chain:D,isSelected:G,selectWallet:je,limit:BT,onShowMore:()=>S(K?.name??""),onConnect:Xe=>{H(D,Xe)}})),!ce&&te.createElement(Ws,{size:32}),_e&&te.createElement(xm,{blockchain:A,open:I,handleOpenChange:Ie}))}))))}i(Vm,"ConfirmWalletsModal");import{i18n as XT}from"@lingui/core";import{Alert as YT,Button as ZT,InfoIcon as JT}from"@rango-dev/ui";import rt from"react";import{Alert as MT,Button as PT,Divider as _s,NoRouteIcon as _T,RefreshIcon as DT,Typography as Rm}from"@rango-dev/ui";import nt from"react";import{i18n as Km}from"@lingui/core";var WT=24,LT=60;function jm(t,e,o,n){return t?.type===1?{alert:{type:"warning",text:ee().genericServerError,action:{onClick:n,title:Km.t("Retry")}},description:""}:e.length?{alert:{type:"warning",text:ee().liquiditySourcesError.title,action:{onClick:()=>o(!0),title:Km.t("Reset")}},description:ee().liquiditySourcesError.description}:t?.type===0&&t.diagnosisMessage?{alert:{type:"error",text:t.diagnosisMessage,action:null},description:""}:{alert:null,description:ee().noResultError.description}}i(jm,"makeInfo");var Ms=(o=>(o[o.small=WT]="small",o[o.large=LT]="large",o))(Ms||{}),Ps=(o=>(o.small="small",o.large="medium",o))(Ps||{});import{styled as ai}from"@rango-dev/ui";var Xm=ai("div",{display:"flex",flexDirection:"column",alignItems:"center"}),Ym=ai("div",{variants:{size:{small:{},large:{maxWidth:"316px"}}}}),Zm=ai("div",{variants:{size:{small:{width:"100%"},large:{}}}}),Jm=ai("div",{padding:"$6 $0"});function Wn(t){let{fetch:e,error:o,size:n="small"}=t,r=y().getDisabledLiquiditySources(),a=y().toggleAllLiquiditySources,s=y().swappers(),l=jm(o,r,()=>a(s,!0),e);return nt.createElement(Xm,null,nt.createElement(_T,{size:Ms[n],color:"gray"}),nt.createElement(_s,{size:4}),nt.createElement(Rm,{variant:"title",size:Ps[n]},ee().noResultError.title),n==="large"&&nt.createElement(_s,{size:4}),!!l.description&&nt.createElement(Ym,{size:n},nt.createElement(Rm,{variant:"body",size:"small",align:"center",color:"neutral700"},l.description)),nt.createElement(_s,{size:n==="large"?"24":"4"}),!!l.alert&&nt.createElement(Zm,{size:n},nt.createElement(MT,{type:l.alert.type,title:l.alert.text,titleAlign:"left",action:l.alert.action&&nt.createElement(PT,{size:"xsmall",id:"widget-no-result-alert-btn",type:l.alert.type,prefix:nt.createElement(Jm,null,nt.createElement(DT,{size:8})),onClick:l.alert.action.onClick},l.alert.action.title),variant:"alarm"})))}i(Wn,"NoResult");import{i18n as Ln}from"@lingui/core";import{Button as FT,Divider as OT,MessageBox as UT,Typography as zT,WarningIcon as QT}from"@rango-dev/ui";import $t from"react";import{Typography as nd}from"@rango-dev/ui";import $s from"react";import{darkTheme as $T,styled as si}from"@rango-dev/ui";var ed=si("div",{width:"100%"}),Ds=si("div",{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"$5",width:"100%"}),td=si("div",{display:"flex",padding:"$5 0",justifyContent:"space-between",alignItems:"center",width:"100%","._title":{$$color:"$colors$neutral600",[`.${$T} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),od=si("div",{padding:"$2",alignSelf:"flex-start",cursor:"pointer"});function rd(t){let{title:e,value:o,valueColor:n}=t;return $s.createElement(td,null,$s.createElement(nd,{size:"medium",variant:"label",className:"_title"},e),$s.createElement(nd,{size:"large",variant:"label",color:n||"foreground"},`${n?"%":"$"}${o}`))}i(rd,"QuoteErrorsModalItem");function id(t){let{open:e,onClose:o,onConfirm:n,warning:r,confirmationDisabled:a}=t,s=r.warningLevel==="high"?"error":"warning",l=[{title:Ln.t("Swapping"),value:P(r.inputUsdValue,4,4)},{title:Ln.t("Gas cost"),value:P(r.totalFee,2,2)},{title:Ln.t("Receiving"),value:P(r.outputUsdValue,4,4)},{title:Ln.t("Price impact"),value:P(r.priceImpact,2,2),valueColor:`${s}500`}];return $t.createElement(J,{footer:$t.createElement(FT,{id:"widget-high-value-loss-warning-modal-confirm-btn",type:"primary",size:"large",prefix:$t.createElement(QT,null),fullWidth:!0,disabled:a,onClick:n},ee().highValueLossError.confirmMessage),open:e,onClose:o,container:N()},$t.createElement(UT,{type:s,title:ee().highValueLossError.impactTitle,description:ee().highValueLossError.description}),$t.createElement(Ds,null,$t.createElement(OT,{size:"4"}),$t.createElement(zT,{size:"small",variant:"title"},Ln.t("Details")),$t.createElement(Ds,null,l.map((c,p)=>$t.createElement(rd,{key:p,...c})))))}i(id,"HighValueLossWarningModal");import{i18n as li}from"@lingui/core";function ad(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=li.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=ee().highValueLossError.title;break}case 4:{o.title=li.t({id:"Output amount changed by {percentageChange}% (${usdValueChange}).",values:{percentageChange:t.percentageChange,usdValueChange:t.usdValueChange}});break}case 1:{o.title=ee().unknownPriceError.title;break}case 2:{o.title=li.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=li.t("Caution, your slippage is high."),o.action="change-settings";break}default:break}return o}return null}i(ad,"makeAlerts");import{i18n as on}from"@lingui/core";import{Button as sd,Divider as ld,MessageBox as HT,Typography as qT}from"@rango-dev/ui";import xo from"react";import{useNavigate as GT}from"react-router-dom";function cd(t){let{customSlippage:e,slippage:o}=y(),{open:n,onClose:r,onConfirm:a,warning:s,confirmationDisabled:l}=t,c=GT(),p=e??o;return xo.createElement(J,{anchor:"bottom",open:n,prefix:xo.createElement(sd,{size:"small",id:"widget-slippage-warning-modal-change-settings-btn",variant:"ghost",onClick:()=>c("../"+F.settings)},xo.createElement(qT,{variant:"label",size:"medium",color:"$neutral900"},on.t("Change settings"))),container:N(),onClose:r},xo.createElement(HT,{type:"warning",title:s.type===3?on.t("High slippage"):on.t("Low slippage"),description:s.type===3?on.t({id:" Caution, your slippage is high (={userSlippage}). Your trade may be front run.",values:{userSlippage:p}}):on.t({id:"We recommend you to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:s.minRequiredSlippage}})},xo.createElement(ld,{size:18}),xo.createElement(ld,{size:32}),xo.createElement(sd,{id:"widget-slippage-warning-modal-confirm-anyway-btn",size:"large",type:"primary",variant:"contained",fullWidth:!0,disabled:l,onClick:a},on.t("Confirm anyway"))))}i(cd,"SlippageWarningModal");import{Button as VT,MessageBox as KT,WarningIcon as jT}from"@rango-dev/ui";import ci from"react";function pd(t){let{open:e,onClose:o,onConfirm:n,confirmationDisabled:r}=t;return ci.createElement(J,{footer:ci.createElement(VT,{id:"widget-unknown-price-warning-modal-confirm-btn",type:"primary",size:"large",prefix:ci.createElement(jT,null),fullWidth:!0,disabled:r,onClick:n},ee().unknownPriceError.confirmMessage),open:e,onClose:o,container:N()},ci.createElement(KT,{type:"warning",title:ee().unknownPriceError.impactTitle,description:ee().unknownPriceError.description}))}i(pd,"UnknownPriceWarningModal");function Mn(t){let{warning:e,error:o,couldChangeSettings:n,showWarningModal:r,confirmationDisabled:a,refetchQuote:s,onOpenWarningModal:l,onCloseWarningModal:c,onConfirmWarningModal:p,onChangeSettings:u}=t,m={confirmationDisabled:a,open:r,onClose:c,onConfirm:p},h=o?.type===0||o?.type===1,d=ad(e,o?.type===3||o?.type===4?o:null);return d&&!n&&(d.action=null),rt.createElement(rt.Fragment,null,h&&rt.createElement(Wn,{error:o,fetch:s}),!!d&&rt.createElement(ed,null,rt.createElement(YT,{title:d.title,type:d.alertType,variant:"alarm",...d.action==="show-info"&&{action:rt.createElement(od,{onClick:l},rt.createElement(JT,{size:12,color:"gray"}))},...d.action==="change-settings"&&{action:rt.createElement(ZT,{id:"widget-quote-warning-error-change-settings-btn",size:"xxsmall",type:d.alertType,onClick:u},XT.t("Change"))}})),e&&rt.createElement(rt.Fragment,null,e.type===0&&rt.createElement(id,{...m,warning:e}),(e.type===3||e.type===2)&&rt.createElement(cd,{...m,warning:e}),e.type===1&&rt.createElement(pd,{...m,warning:e})))}i(Mn,"QuoteWarningsAndErrors");import Nv from"bignumber.js";import wi from"react";import{i18n as Eo}from"@lingui/core";import{Alert as hv,Divider as rn,FullExpandedQuote as yv,InfoIcon as Sv,NumericTooltip as Qd,QuoteTag as Cv,StepDetails as kv,TokenAmount as Tv,Typography as an}from"@rango-dev/ui";import Vs from"bignumber.js";import U,{useRef as vv,useState as wv}from"react";import{styled as Fs}from"@rango-dev/ui";var Os=Fs("div",{width:"100%","& .position-top__skeleton":{paddingTop:"$10"}}),ud=Fs("div",{paddingBottom:"$15",variants:{dense:{true:{paddingBottom:0}}}}),md=Fs("div",{width:"100%",display:"flex"});import*as pi from"@radix-ui/react-collapsible";import{Button as RT,css as Pn,darkTheme as xe,Image as dd,styled as He,Typography as ev}from"@rango-dev/ui";var tv=300,fd=He(pi.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"}}]}),gd=Pn({padding:"$10 $15"}),hd=He(RT,{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"}}}),yd=He("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"}}}}]}),Sd=Pn({width:"100%",padding:"$15 $15 $10 $15"}),Cd=Pn({display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingBottom:"$10",position:"relative"}),nn=Pn({display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",".blockchainImage":{marginLeft:"-$8"}}),kd=Pn({display:"flex",alignItems:"center",".usd-value":{$$color:"$colors$neutral600",[`.${xe} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),Td=He(pi.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:{[`& ${dd}`]:{border:"1px $warning500 solid",borderRadius:"100%"}},false:{[`& ${dd}`]:{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"}}}),vd=He("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"}}}}),wd=He(ti,{width:"100%",background:"inherit"}),Us=He("div",{display:"flex",justifyContent:"center",alignItems:"center",padding:"$2",transition:`all ${tv}ms ease`,variants:{orientation:{down:{transform:"rotate(0)"},up:{transform:"rotate(180deg)"}}}}),V1=He("div",{height:"$12",marginLeft:"$10",marginRight:"$10",borderLeft:"1px solid $foreground"}),bd=He("div",{display:"flex",justifyContent:"center",margin:"0 $15",borderTop:"1px solid",$$color:"$colors$neutral300",[`.${xe} &`]:{$$color:"$colors$neutral400"},borderColor:"$$color"}),xd=He("div",{width:"$16",height:"$16",justifyContent:"center",alignItems:"center",display:"flex"}),zs=He(ev,{overflow:"hidden",textOverflow:"ellipsis",letterSpacing:.4}),Ed=He("div",{display:"flex",flexWrap:"wrap"}),Qs=He("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"}}}}),Id=He("div",{display:"flex"}),ui=He("div",{width:"100%",borderTopWidth:"1px",borderTopStyle:"solid",borderTopColor:"$neutral",margin:"$5 0",[`.${xe} &`]:{borderTopColor:"$neutral800"}});import{i18n as It}from"@lingui/core";import{ChevronDownIcon as nv,CloseIcon as rv,Divider as fi,IconButton as iv,NumericTooltip as av,QuoteCost as sv,Typography as Ct}from"@rango-dev/ui";import Z,{useState as Wd}from"react";import{css as ov,styled as mi}from"@rango-dev/ui";var di=mi("div",{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"$5 0","&.total_payable_fee":{padding:"$12 0"}}),Hs=mi("div",{width:"100%",borderTop:"1px solid $neutral300",margin:"$10 0"}),Ad=mi("div",{padding:"$20 0",display:"flex",flexDirection:"column","& .collapsible_trigger":{display:"flex",alignItems:"center"}}),Nd=mi("div",{padding:"$20 $20 $10",position:"relative","._icon-button":{position:"absolute",zIndex:10,top:"$16",right:"$16"}}),Bd=ov({display:"flex",flexDirection:"row",alignItems:"center",padding:"$5","&:hover":{"& ._typography, & svg":{color:"$secondary"}}});var lv=i(t=>t.fee.isZero()?null:Z.createElement(di,null,Z.createElement(Ct,{variant:"label",size:"medium",color:"neutral600"},t.label),Z.createElement(Ct,{variant:"label",size:"medium"},"$",P(t.fee,4,4))),"NonPayableFee");function qs(t){let[e,o]=Wd(!1),[n,r]=Wd(!1),{steps:a,quote:s,fee:l,time:c,feeWarning:p,timeWarning:u,showModalFee:m,fullExpandedMode:h=!1}=t,d=s?.swaps??[],f=h?uo():N(),g=ku(d);return Z.createElement(Z.Fragment,null,Z.createElement(sv,{onClickFee:m?k=>{k.stopPropagation(),o(!e)}:void 0,fee:l,feeWarning:p,timeWarning:u,time:c,steps:a,tooltipGas:m?It.t("View more info"):void 0,tooltipContainer:f}),Z.createElement(J,{container:f,open:e,anchor:h?"center":"bottom",styles:{container:{maxWidth:h?"484px":"unset"}},header:Z.createElement(Nd,{style:{textAlign:h?"left":"center"}},Z.createElement(Ct,{variant:"title",size:"medium"},It.t("Gas & Fee Explanation")),Z.createElement(iv,{id:"widget-quote-cost-details-modal-close-icon-btn",onClick:()=>o(!1),variant:"ghost"},Z.createElement(rv,{color:"gray",size:14}))),onClose:()=>{o(!1)}},Z.createElement(Ad,null,Z.createElement(Ct,{variant:"title",size:"small"},It.t("Details")),Z.createElement(fi,{size:10}),Object.entries(g.payable).flatMap(([k,C])=>C.map((S,T)=>{let w=`payable-fee-${T}`,E=qa(S);return Z.createElement(di,{key:w},Z.createElement(Ct,{variant:"label",size:"medium",color:"neutral600"},Oa(k,It.t)),Z.createElement(av,{content:S.amount,container:f},Z.createElement(Ct,{variant:"label",size:"medium"},P(S.amount,2,2)," ",S.asset.symbol," ($",P(E,4,4),")")))})),Z.createElement(di,{className:"total_payable_fee"},Z.createElement(Ct,{variant:"label",size:"medium"},It.t("Total Payable Fee")),Z.createElement(Ct,{variant:"label",size:"medium"},"$",P(l,4,4))),Z.createElement(Hs,null),Object.keys(g.nonePayable).length&&Z.createElement(ri,{triggerAnchor:"bottom",onClickTrigger:()=>r(k=>!k),trigger:Z.createElement("div",{className:Bd()},Z.createElement(Ct,{size:"small",variant:"body",color:"neutral700"},n?It.t("Hide non-payable fees"):It.t("Show non-payable fees")),Z.createElement(fi,{size:4,direction:"horizontal"}),Z.createElement(oi,{orientation:n?"up":"down"},Z.createElement(nv,{size:12,color:"gray"}))),open:n},Z.createElement(Ct,{size:"small",variant:"title"},It.t("Description")),Z.createElement(fi,{size:4}),Z.createElement(Ct,{size:"small",variant:"body",color:"neutral700"},It.t(`The following fees are considered in the transaction output and
2
- you won\u2019t need to pay extra gas for them.`)),Z.createElement(fi,{size:10}),Object.entries(g.nonePayable).map(([k,C],S)=>{let T=Cu(C),w=Oa(k,It.t),E=`non-payable-fee-${S}`;return Z.createElement(lv,{key:E,fee:T,label:w})}),Z.createElement(Hs,null)))))}i(qs,"QuoteCostDetails");import{i18n as Pd}from"@lingui/core";import{TokenAmount as _d}from"@rango-dev/ui";import gi from"react";import{css as cv,styled as pv}from"@rango-dev/ui";var Ld=pv("div",{position:"relative",display:"flex",flexDirection:"column",width:"100%"}),Md=cv({height:"14px",marginLeft:"14px",position:"absolute",borderLeft:"1px solid $foreground",top:"42%"});function _n(t){let{from:e,to:o,percentageChange:n,warningLevel:r}=t;return gi.createElement(Ld,null,gi.createElement(_d,{direction:"horizontal",label:Pd.t("Swap input"),type:"input",tooltipContainer:N(),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}}),gi.createElement("div",{className:Md()}),gi.createElement(_d,{direction:"horizontal",tooltipContainer:N(),label:Pd.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(_n,"QuoteSummary");import{i18n as Ud}from"@lingui/core";import{ChevronDownIcon as dv,ChevronRightIcon as fv,Divider as Gs,Image as gv,Tooltip as ki,Typography as yi}from"@rango-dev/ui";import z from"react";import{useLayoutEffect as uv,useState as Dn}from"react";var Dd=480,$d=768,Fd=1024,Od=1200,mv=i(()=>{let[t,e]=Dn(!1),[o,n]=Dn(!1),[r,a]=Dn(!1),[s,l]=Dn(!1),[c,p]=Dn(!1),u=i(()=>{e(window.innerWidth<=Dd),n(window.innerWidth>Dd&&window.innerWidth<=$d),a(window.innerWidth>$d&&window.innerWidth<=Fd),l(window.innerWidth>Fd&&window.innerWidth<=Od),p(window.innerWidth>Od)},"handleResize");return uv(()=>(u(),window.addEventListener("resize",u),()=>window.removeEventListener("resize",u)),[]),{isMobile:t,isTablet:o,isNotebook:r,isLargeScreen:s,isExtraLargeScreen:c}},"useScreenDetect"),hi=mv;var Si=4,Ci=6,$n=i(t=>{let{content:e,src:o,className:n,open:r,state:a,container:s}=t,l=s||N();return z.createElement(ki,{container:l,side:"bottom",sideOffset:4,open:r,content:e},z.createElement(vd,{className:n,state:a},z.createElement(gv,{src:o,size:16})))},"ImageComponent");function zd(t){let{quoteRef:e,selected:o,setExpanded:n,steps:r,expanded:a,type:s,container:l}=t,c=l||N(),p=r.length,u=cu(r),{isTablet:m,isMobile:h}=hi();return z.createElement(Td,{listItem:s==="list-item",ref:d=>e.current=d,selected:o,onClick:d=>{d.stopPropagation(),n(f=>!f)}},z.createElement("div",{className:nn()},z.createElement(yi,{variant:"body",size:"xsmall"},Ud.t("Via:")),z.createElement(Gs,{direction:"horizontal",size:4}),r.map((d,f)=>{let g=`item-${f}`,k=z.createElement(Us,null,z.createElement(fv,{size:12,color:"black"}));return h||m?z.createElement(z.Fragment,{key:g},z.createElement($n,{content:d.swapper.displayName,src:d.swapper.image??"",state:d.state,container:l}),f!==p-1&&z.createElement(z.Fragment,null,k)):z.createElement(z.Fragment,{key:g},p<=Si||p>Si&&f<Si-1?z.createElement(z.Fragment,null,z.createElement($n,{content:d.swapper.displayName,src:d.swapper.image??"",state:d.state,container:l}),f!==p-1&&z.createElement(z.Fragment,null,k)):f===Si-1&&z.createElement(ki,{container:c,side:"bottom",align:"end",sideOffset:4,content:z.createElement("div",{className:nn()},k,r.map((C,S)=>{let T=`image-${S}`;return S>=f&&z.createElement(z.Fragment,{key:T},z.createElement($n,{content:C.swapper.displayName,src:C.swapper.image??"",state:C.state,open:!1}),S!==p-1&&z.createElement(z.Fragment,null,k))}))},z.createElement(Qs,{state:r.find((C,S)=>S>=f&&(C.state==="error"||C.state==="warning"))?.state},z.createElement(yi,{size:"xsmall",variant:"body"},"+",p-f))))})),z.createElement("div",{className:nn()},z.createElement("div",{className:"blockchains_section"},z.createElement("div",{className:nn()},z.createElement(yi,{variant:"body",size:"xsmall"},Ud.t("Chains:")),z.createElement(Gs,{direction:"horizontal",size:4}),u.map((d,f)=>z.createElement(z.Fragment,{key:d.displayName},u.length<=Ci||u.length>Ci&&f<Ci-1?z.createElement(ki,{container:c,side:"bottom",content:d.displayName,sideOffset:4},z.createElement($n,{content:"",src:d.image??"",open:!1,className:f!==0?"blockchainImage":""})):f===Ci-1&&z.createElement(ki,{container:c,side:"bottom",align:"end",sideOffset:4,content:z.createElement("div",{className:nn()},u.map((g,k)=>k>=f&&z.createElement($n,{key:g.displayName,content:"",src:g.image??"",open:!1,className:k>f?"blockchainImage":"",container:l})))},z.createElement(Qs,{className:"blockchainImage"},z.createElement(yi,{size:"xsmall",variant:"body"},"+",u.length-f))))),z.createElement(Gs,{direction:"horizontal",size:32}))),z.createElement(Us,{orientation:a?"up":"down"},z.createElement(dv,{size:12,color:"black"}))))}i(zd,"QuoteTrigger");function Ks(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:m=!1,container:h}=t,d=y().blockchains(),{findToken:f}=y(),g=y().swappers(),{customSlippage:k,slippage:C}=y(),S=k||C,[T,w]=wv(t.expanded),E=vv(null),B=P(o.value,6,6),I=P(n.value,6,6),x=n.usdValue?P(n.usdValue,4,4):"",b=Pt(o.usdValue,n.usdValue??null),v=P(b,2,2),A=_t(b??0),M=i((se,pt)=>se.map((V,D)=>{let q,K=r?.type===3&&r.swap.swapperId===V.swapperId,ge=r?.type===4&&r.recommendedSlippages?.has(D),ce=a?.type===2&&a.recommendedSlippages?.has(D),_e=K||ge,Xe=ce;_e?q="error":Xe&&(q="warning");let ke=_e?Eo.t("Slippage Error"):Eo.t("Slippage Warning");return K&&(ke=Eo.t("Bridge Limit Error")),{swapper:{displayName:un(V.swapperId,g)??"",image:V.swapperLogo},from:{token:{displayName:V.from.symbol,image:V.from.logo},chain:{displayName:ut(V.from.blockchain,d)??"",image:V.from.blockchainLogo},price:{value:D===0&&!pt?P(o.value,6,6):P(V.fromAmount,6,6),usdValue:P((V.from.usdPrice??0)*parseFloat(V.fromAmount),4,4),realValue:D===0?o.value:V.fromAmount,realUsdValue:new Vs(V.from.usdPrice??0).multipliedBy(V.fromAmount).toString()}},to:{token:{displayName:V.to.symbol,image:V.to.logo},chain:{displayName:ut(V.to.blockchain,d)||"",image:V.to.blockchainLogo},price:{value:P(V.toAmount,6,6),usdValue:P((V.to.usdPrice??0)*parseFloat(V.toAmount),4,4),realValue:V.toAmount,realUsdValue:new Vs(V.to.usdPrice??0).multipliedBy(V.toAmount).toString()}},state:q,alerts:_e||Xe?U.createElement(ud,{dense:m},U.createElement(hv,{variant:"alarm",type:_e?"error":"warning",title:ke,footer:U.createElement(md,null,K&&U.createElement("div",null,U.createElement(an,{size:"xsmall",variant:"body",color:"neutral900"},r.fromAmountRangeError),U.createElement(rn,{direction:"vertical",size:2}),U.createElement(an,{size:"xsmall",variant:"body",color:"neutral900"},Eo.t({id:"Yours: {amount} {symbol}",values:{amount:P(V.fromAmount,6,6),symbol:V?.from.symbol}}))),(ge||ce)&&!K&&U.createElement("div",null,U.createElement(an,{size:"xsmall",variant:"body",color:"neutral900"},Eo.t({id:"Minimum required slippage: {minRequiredSlippage}",values:{...r?.type===4&&{minRequiredSlippage:r.recommendedSlippages?.get(D)},...a?.type===2&&{minRequiredSlippage:a.recommendedSlippages?.get(D)}}})),U.createElement(rn,{direction:"vertical",size:2}),U.createElement(an,{size:"xsmall",variant:"body",color:"neutral900"},Eo.t({id:"Yours: {userSlippage}",values:{userSlippage:S}}))))})):void 0,time:dn(V.estimatedTimeInSeconds),fee:P(Ha(V,f),2,2),internalSwaps:V.internalSwaps?M(V.internalSwaps):void 0}}),"getQuoteSteps"),_=M(e?.swaps??[]),j=_.length,R=h||N(),X=uu(t.quote.tags||[]),L=!!u,H=kr(e?.swaps),ae=dn(H),G=Ur(e?.swaps??[],f),fe=P(G,2,2),Ie=G.gte(new Vs(tu)),je=H/nu>=ou;return m?U.createElement(yv,{selected:l,fee:fe,time:ae,tooltipContainer:uo(),steps:_,tags:X,quoteCost:U.createElement(qs,{quote:e,fullExpandedMode:!0,time:ae,fee:fe,feeWarning:Ie,timeWarning:je,showModalFee:p,steps:j}),percentageChange:v,warningLevel:A,outputPrice:{value:I,usdValue:x,realValue:n.value,realUsdValue:n.usdValue}}):U.createElement(yd,{selected:l,listItem:s==="list-item",basic:s==="basic"},U.createElement("div",{className:Sd()},!c&&X.length?U.createElement(U.Fragment,null,U.createElement(Id,null,X.map((se,pt)=>{let V=`${se.value}_${pt}`;return U.createElement(U.Fragment,{key:V},U.createElement(Cv,{label:se.label,value:se.value}),U.createElement(rn,{size:4,direction:"horizontal"}))})),U.createElement(ui,null),!L&&U.createElement(rn,{size:4})):null,U.createElement("div",{id:"portal-root",className:Cd()},U.createElement(qs,{quote:e,time:ae,fee:fe,feeWarning:Ie,timeWarning:je,showModalFee:p,steps:j}),L&&U.createElement(hd,{onClick:se=>{se.stopPropagation(),u()},size:"xxsmall",type:"secondary",variant:"default",css:{paddingLeft:"$10",paddingRight:"$10",paddingTop:"$5",paddingBottom:"$5"}},U.createElement(an,{color:"secondary",variant:"body",size:"xsmall",className:"allRoutesLabel"},Eo.t("See All Routes")))),s==="basic"&&U.createElement("div",{className:kd()},U.createElement(xd,null,U.createElement(Sv,{size:12,color:"gray"})),U.createElement(Ed,null,U.createElement(zs,{size:"small",variant:"body"},`${B} ${_[0].from.token.displayName} = `),U.createElement(Qd,{content:n.value,container:R,open:n.value?void 0:!1},U.createElement(zs,{size:"small",variant:"body"},"\xA0",`${I} ${_[_.length-1].to.token.displayName}`))),U.createElement(Qd,{content:n.usdValue,container:R},U.createElement(rn,{size:2,direction:"horizontal"}),U.createElement(an,{color:"$neutral600",size:"xsmall",variant:"body"},`($${x})`))),s==="list-item"&&U.createElement(Tv,{tooltipContainer:R,type:"output",direction:"vertical",price:{value:I,usdValue:x,realValue:n.value,realUsdValue:n.usdValue},token:{displayName:_[j-1].to.token.displayName,image:_[j-1].to.token.image},chain:{image:_[j-1].to.chain.image},percentageChange:v,warningLevel:A}),s==="swap-preview"&&U.createElement(U.Fragment,null,U.createElement(_n,{from:_[0].from,to:_[j-1].to,percentageChange:v,warningLevel:A}),U.createElement(rn,{size:4}))),U.createElement(fd,{selected:l,listItem:s==="list-item",open:T,className:"quote_container",onOpenChange:w},U.createElement(zd,{type:s,quoteRef:E,selected:l,setExpanded:w,container:R,expanded:T,steps:_}),U.createElement(wd,{open:T},U.createElement(bd,null),U.createElement("div",{className:gd()},_.map((se,pt)=>{let V=`item-${pt}`;return U.createElement(kv,{type:"quote-details",key:V,tooltipContainer:R,step:se,hasSeparator:pt!==_.length-1,state:se.state})})))))}i(Ks,"Quote");import{Divider as Iv,Skeleton as Av}from"@rango-dev/ui";import Ot from"react";import{darkTheme as bv,styled as Ti}from"@rango-dev/ui";var Hd=Ti("div",{$$color:"$colors$neutral100",[`.${bv} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",borderBottomLeftRadius:"$xm",borderBottomRightRadius:"$xm",padding:"$15",variants:{rounded:{true:{borderRadius:"$xm"}},expanded:{true:{paddingBottom:"3px"},false:{paddingBottom:"$12"}}}}),qd=Ti("div",{paddingTop:"$2"}),Gd=Ti("div",{paddingLeft:"$8"}),Vd=Ti("div",{borderLeft:"1px dashed $foreground",minHeight:" 0",margin:"0px 11.5px",alignSelf:"stretch",variants:{hideSeparator:{true:{minHeight:"unset",height:"0"}}}});import{ChainToken as of,Divider as kt,Skeleton as it}from"@rango-dev/ui";import Q from"react";import{css as xv,styled as Ft}from"@rango-dev/ui";var js=Ft("div",{display:"flex"}),Kd=Ft("div",{padding:"$10 $0 $20"}),jd=Ft("div",{padding:"14px $0 $20 $0",display:"flex",flexDirection:"column"}),Xd=Ft("div",{display:"flex",justifyContent:"start",alignItems:"center"}),Yd=Ft("div",{display:"flex",justifyContent:"space-between",alignItems:"end"}),Zd=Ft("div",{height:"$24",marginLeft:"13px",borderLeft:"1px solid $neutral700"}),Jd=Ft("div",{width:"65%",display:"flex",justifyContent:"start"}),Rd=Ft("div",{display:"flex",flexDirection:"column",alignItems:"start",flexGrow:1,maxWidth:"148px"}),ef=Ft("div",{padding:"$15 $0 $15 $0"}),tf=xv({display:"flex",justifyContent:"space-between",alignItems:"center"});function Fn(t){let{type:e,tagHidden:o=!0}=t,n=Q.createElement(Yd,null,Q.createElement(Jd,null,Q.createElement(of,{loading:!0,size:"medium"}),Q.createElement(kt,{size:8,direction:"horizontal"}),Q.createElement(Rd,null,Q.createElement(it,{height:10,width:60,variant:"rounded"}),Q.createElement(kt,{size:4}),Q.createElement(it,{height:15,variant:"rounded"}))),Q.createElement(it,{height:12,width:64,variant:"rounded"})),r=e==="basic"&&!o;return Q.createElement("div",null,!o&&Q.createElement(Q.Fragment,null,Q.createElement(js,null,Q.createElement(it,{width:65,height:20,variant:"rounded"}),Q.createElement(kt,{size:4,direction:"horizontal"}),Q.createElement(it,{width:65,height:20,variant:"rounded"}),Q.createElement(kt,{size:4,direction:"horizontal"}),Q.createElement(it,{width:65,height:20,variant:"rounded"})),Q.createElement(ui,null),!r&&Q.createElement(kt,{size:4})),Q.createElement("div",{className:tf()},Q.createElement(js,null,Q.createElement(it,{width:60,height:10,variant:"rounded"}),Q.createElement(kt,{size:4,direction:"horizontal"}),Q.createElement(it,{width:60,height:10,variant:"rounded"}),Q.createElement(kt,{size:4,direction:"horizontal"}),Q.createElement(it,{width:60,height:10,variant:"rounded"})),r&&Q.createElement(it,{width:85,height:24,variant:"rounded"})),e==="basic"&&Q.createElement(Kd,null,Q.createElement(it,{height:15,width:148,variant:"rounded"})),e==="list-item"&&Q.createElement(jd,null,Q.createElement(Xd,null,Q.createElement(of,{loading:!0,size:"medium"}),Q.createElement(kt,{direction:"horizontal",size:4}),Q.createElement(it,{height:15,width:150,variant:"rounded"})),Q.createElement(kt,{size:10}),Q.createElement(it,{height:10,width:184,variant:"rounded"})),e==="swap-preview"&&Q.createElement(Q.Fragment,null,Q.createElement(kt,{size:4}),Q.createElement(ef,null,n,Q.createElement(Zd,null),n),Q.createElement(kt,{size:12})))}i(Fn,"QuoteSummarySkeleton");import{ChainToken as lf,Divider as Ys,NextIcon as Ev,Skeleton as vi}from"@rango-dev/ui";import Ee from"react";import{styled as On}from"@rango-dev/ui";var nf=On("div",{display:"flex",alignItems:"start"}),rf=On("div",{flexGrow:1,paddingTop:"$5",paddingBottom:"$10",display:"flex",alignItems:"center",variants:{extraSpace:{true:{paddingBottom:"$40"}}}}),Xs=On("div",{display:"flex",alignItems:"center",flexGrow:1}),af=On("div",{margin:"$0 $2",padding:"$4",display:"flex",justifyContent:"center",alignItems:"center"}),sf=On("div",{display:"flex",alignItems:"center"});function At(t){let{separator:e=!0}=t;return Ee.createElement(Ee.Fragment,null,Ee.createElement(sf,null,Ee.createElement(vi,{height:22,width:22,variant:"circular"}),Ee.createElement(Ys,{direction:"horizontal",size:8}),Ee.createElement(vi,{height:15,width:148,variant:"rounded"})),Ee.createElement(nf,null,Ee.createElement(Vd,{hideSeparator:!e}),Ee.createElement(rf,{extraSpace:e},Ee.createElement(Xs,null,Ee.createElement(lf,{size:"small",loading:!0}),Ee.createElement(Ys,{direction:"horizontal",size:8}),Ee.createElement(vi,{height:12,variant:"rounded"})),Ee.createElement(af,null,Ee.createElement(Ev,{color:"gray",size:16})),Ee.createElement(Xs,null,Ee.createElement(lf,{size:"small",loading:!0}),Ee.createElement(Ys,{direction:"horizontal",size:8}),Ee.createElement(vi,{height:12,variant:"rounded"})))))}i(At,"StepSkeleton");function Un(t){let{type:e,expanded:o,tagHidden:n=!1}=t;return Ot.createElement(Hd,{expanded:o,rounded:e!=="basic"},Ot.createElement(Fn,{type:e,tagHidden:n}),Ot.createElement(qd,null,Ot.createElement(Av,{height:15,variant:"rounded"})),o&&Ot.createElement(Gd,null,Ot.createElement(Iv,{size:24}),Ot.createElement(At,null),Ot.createElement(At,null),Ot.createElement(At,{separator:!1})))}i(Un,"QuoteSkeleton");function Io(t){let{quote:e,type:o,loading:n,error:r,warning:a,expanded:s=!1,tagHidden:l,onClick:c,showModalFee:p,selected:u,onClickAllRoutes:m,fullExpandedMode:h=!1,container:d}=t,{inputAmount:f,inputUsdValue:g}=O(),k=e?.outputAmount?new Nv(e?.outputAmount):null,C=e?dt(e):null,T=!(r&&(r.type===0||r.type===1))&&e&&!n;return n?wi.createElement(Os,null,wi.createElement(Un,{tagHidden:l,type:o,expanded:s})):T?wi.createElement(Os,{onClick:()=>c?.(e)},wi.createElement(Ks,{quote:e,error:r,container:d,showModalFee:p,warning:a,tagHidden:l,selected:u,type:o,expanded:s,onClickAllRoutes:m,fullExpandedMode:h,input:{value:f,usdValue:g?.toString()??""},output:{value:k?.toString()??"",usdValue:C?.toString()??""}})):null}i(Io,"QuoteInfo");import{calculatePendingSwap as Mv}from"@rango-dev/queue-manager-rango-preset";import{useEffect as Pv}from"react";import{useRef as Bv,useState as Wv}from"react";var Lv=2e3;function bi({request:t}){let[e,o]=Wv(!1),n=Bv(null),r=i(()=>n.current?.abort(),"cancelFetch"),a=i(async l=>(await new Promise(c=>setTimeout(c,Lv)),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(bi,"useFetch");function cf(){let{fetch:t,loading:e,cancelFetch:o}=bi({request:async(n,r)=>await ot().confirmRoute(n,r)});return{fetch:t,loading:e,cancelFetch:o}}i(cf,"useFetchConfirmQuote");function xi(t){if(!t.swaps)throw new Error(ee().noResultError.title,{cause:{type:0,diagnosisMessage:t.diagnosisMessages?.[0]}});let e=Zs(t.swaps);if(e)throw new Error(e.message,{cause:e.options})}i(xi,"throwErrorIfResponseIsNotValid");function Zs(t){if(hu(t)){let{swap:n,recommendation:r,fromAmountRangeError:a}=yu(t);return{message:"bridge limit error",options:{type:3,swap:n,recommendation:r,fromAmountRangeError:a}}}let o=Tu(t);if(o){let n=zr(t);return{message:"",options:{type:4,recommendedSlippages:o,minRequiredSlippage:n}}}return null}i(Zs,"getQuoteError");function pf(t){let{currentQuote:e,previousQuote:o,meta:n,selectedWallets:r,userSlippage:a,findToken:s}=t,l={quote:null,balance:null},c=Vo({previousQuote:o,currentQuote:e,findToken:s,userSlippage:a});c&&(l.quote=c);let p=bu(e,r,n.blockchains);return p.length===0||(l.balance={messages:p}),l}i(pf,"generateWarnings");function Ei(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(Ei,"handleQuoteErrors");function Js(){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(),m=y().blockchains(),h=y().tokens(),{findToken:d}=y(),f=p||c,{fetch:g,cancelFetch:k,loading:C}=cf();return Pv(()=>k,[]),{loading:C,fetch:i(async T=>{let w=T.selectedWallets,E=T?.customDestination??s;if(!t||!e||!o)return{quote:null,swap:null,error:null,warnings:null};let B=w.reduce((x,b)=>(x[b.chain]=b.address,x),{}),I={requestId:a?.requestId||"",selectedWallets:B,destination:E||void 0};try{return await g(I,!0).then(x=>{let{result:b}=x;if(!b)throw new Error("Error fetching updated route");xi({diagnosisMessages:b.diagnosisMessages,requestId:b.requestId,swaps:b.result?.swaps});let v={outputAmount:b.result?.outputAmount,requestId:b.requestId,resultType:b.result?.resultType,swaps:b.result?.swaps||[],validationStatus:b.validationStatus,requestAmount:b.requestAmount};r(v);let A={slippage:f.toString(),disabledSwappersGroups:u},M=pf({previousQuote:a??void 0,currentQuote:v,meta:{blockchains:m},selectedWallets:w,userSlippage:f,inputUsdValue:n,findToken:d});l();let _=!!M.balance,j=Mv(o.toString(),b,wu(w),A,!_,{blockchains:m,tokens:h});return{quote:v,swap:j,error:null,warnings:M}})}catch(x){return Ei(x)}},"fetch"),cancelFetch:k}}i(Js,"useConfirmSwap");var qv=Fv("div",{width:"100%",display:"flex",justifyContent:"space-between",[`& ${uf}`]:{width:"$48",height:"$48"}}),Gv=tl({flexGrow:1,paddingRight:"$10"}),Vv=tl({width:"$24",height:"$24",display:"flex",justifyContent:"center",alignItems:"center"}),Kv=tl({display:"flex",justifyContent:"space-between",alignItems:"center"});function mf(){let{selectedQuote:t,setInputAmount:e,selectedWallets:o,quoteWalletsConfirmed:n,customDestination:r,quoteWarningsConfirmed:a}=O(),s=Hv(),[l,c]=zn(""),p=!n,[u,m]=zn(!1),[h,d]=zn(!1),{isActiveTab:f}=ne(),g=y().getDisabledLiquiditySources(),k=Qv(g),{manager:C}=_v(),{fetch:S,loading:T,cancelFetch:w}=Js(),[E,B]=zn({swap:null,error:null,warnings:null}),[I,x]=zn(!1),b=i(async({selectedWallets:L,customDestination:H})=>{let ae=await S?.({selectedWallets:L,customDestination:H});return B(ae),ae},"onConfirmSwap"),v=i(async()=>{if(E.swap&&n)try{await C?.create("swap",{swapDetails:E.swap},{id:E.swap.requestId});let L=`../${F.swaps}/${E.swap.requestId}`;s(L,{replace:!0}),setTimeout(()=>{e("")},0)}catch(L){c("Error: "+L?.message)}},"addNewSwap"),A=i(async()=>{d(!0),await v(),d(!1)},"onConfirm"),M=i(async()=>{E.warnings?.quote&&lu(E.warnings.quote)&&!a?x(!0):await A()},"onStartConfirmSwap"),_=i(async()=>{B({error:null,swap:null,warnings:null}),S({selectedWallets:o,customDestination:r}).then(L=>{B(L)}).catch(L=>console.error(L))},"onRefresh");Ii(()=>{!!k.current.length&&!g.length&&_(),k.current=g},[g.length]),Ii(()=>{p&&w()},[p]),Ii(()=>{p&&m(p)},[p]),Ii(()=>{p||S({selectedWallets:o,customDestination:r}).then(L=>B(L)).catch(L=>console.error(L))},[]),zv(()=>{t?.requestId||s(`../${location.search}`)},[t?.requestId]);let j=E.warnings?.quote??null,R=E.error,X=[];if(l&&X.push(Le.createElement(Dv,{type:"error",variant:"alarm",title:l})),j||R){let L=`../${F.settings}`;X.push(Le.createElement(Mn,{warning:j,error:R,couldChangeSettings:!1,refetchQuote:_,showWarningModal:I,confirmationDisabled:!f,onOpenWarningModal:()=>x(!0),onCloseWarningModal:()=>x(!1),onConfirmWarningModal:async()=>{x(!1),await v()},onChangeSettings:()=>s(L)}))}return Le.createElement(oe,{header:{title:Rs.t("Confirm Swap"),onWallet:()=>{let L=`../${F.wallets}`;s(L)}},footer:Le.createElement(qv,null,Le.createElement("div",{className:Gv()},Le.createElement($v,{id:"widget-confirm-swap-start-btn",variant:"contained",type:"primary",size:"large",fullWidth:!0,loading:T||h,disabled:!!E.error||!f,onClick:M},Rs.t("Start Swap"))),Le.createElement(uf,{id:"widget-confirm-swap-wallet-icon-btn",variant:"contained",type:"primary",size:"large",loading:T||h,disabled:!f,onClick:m.bind(null,!0)},Le.createElement(Uv,{size:24})))},u&&Le.createElement(Vm,{open:u,onClose:()=>m(!1),onCancel:w,loading:T,onCheckBalance:b}),Le.createElement(re,null,Le.createElement("div",{className:Kv()},Le.createElement(Ov,{variant:"title",size:"small"},Rs.t("You get")),Le.createElement("div",{className:Vv()},Le.createElement(jr,{onClick:!T&&!u&&!I?_:void 0}))),Le.createElement(el,{size:"12"}),Ku(X.map((L,H)=>({element:L,key:`alert-${H}`})),Le.createElement(el,{size:10})),X.length>0?Le.createElement(el,{size:10}):null,Le.createElement(Io,{quote:t,type:"swap-preview",expanded:!0,tagHidden:!0,error:E.error,loading:T,warning:E.warnings?.quote??null})))}i(mf,"ConfirmSwapPage");import{i18n as zt}from"@lingui/core";import{Button as dl,CustomTokensZeroStateDarkIcon as fw,CustomTokensZeroStateIcon as gw,DeleteIcon as hw,Divider as Kn,IconButton as yw,MessageBox as Sw,NotFound as Cw,styled as gl}from"@rango-dev/ui";import me,{useState as fl}from"react";import{useNavigate as kw}from"react-router-dom";import{CloseIcon as Xv,IconButton as Yv,SearchIcon as Zv,TextField as Jv}from"@rango-dev/ui";import Qn from"react";import{styled as jv}from"@rango-dev/ui";var df=jv("div",{width:"$24",height:"$24",display:"flex",alignItems:"center",justifyContent:"center"});function Tt(t){let{variant:e,fullWidth:o,color:n,size:r,onChange:a,value:s,style:l,setValue:c,suffix:p,...u}=t,m=s.length?Qn.createElement(Yv,{variant:"ghost",onClick:()=>c?.(""),size:"small"},Qn.createElement(Xv,{color:"gray",size:10})):null;return p&&(m=p),Qn.createElement(Jv,{prefix:Qn.createElement(df,null,Qn.createElement(Zv,{color:"black"})),suffix:m,fullWidth:o,color:n,variant:e,style:{padding:10,borderRadius:25,alignItems:"center",...l},size:r,value:s,onChange:a,...u})}i(Tt,"SearchInput");import{i18n as ml}from"@lingui/core";import{Button as ow,CustomTokenWarning as nw,darkTheme as xf,Divider as Ut,ExternalLinkIcon as rw,Image as iw,ListItem as aw,NotFound as sw,PinIcon as lw,Skeleton as Ao,Typography as Gn,VirtualizedList as cw}from"@rango-dev/ui";import W,{useState as pw}from"react";import{useTranslation as uw}from"react-i18next";import{Divider as wf,ListItem as tw,Skeleton as qn}from"@rango-dev/ui";import vt from"react";import{css as sn,darkTheme as ol,ImageContainer as Rv,ListItemButton as ew,styled as Re,Typography as ff}from"@rango-dev/ui";var nl=sn({position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:100,overflow:"hidden"}),rl=sn({position:"relative",height:12,width:"30%",maxWidth:"150px"}),il=sn({position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",bottom:"-8px"}),al=sn({transform:"translateY(12px)",visibility:"hidden",display:"flex","& a":{display:"flex",justifyContent:"center",alignItems:"center",fontSize:"$12",lineHeight:"$16",$$color:"$colors$neutral600",[`.${ol} &`]:{$$color:"$colors$neutral700"},color:"$$color",textDecoration:"none"}}),sl=sn({}),ll=sn(),gf=Re("div",{display:"flex",flexDirection:"column",flexGrow:1,overflow:"hidden",justifyContent:"center"}),cl=Re("div",{display:"flex",alignItems:"center","._typography":{textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:100,overflow:"hidden"}}),Ai=Re("ul",{flexGrow:1,padding:0,margin:0,listStyle:"none","& li":{alignItems:"none","&:hover":{[`& .${rl}`]:{[`& .${al}`]:{position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",visibility:"visible"},[`& .${sl}`]:{bottom:"-15px"},[`& .${nl}`]:{position:"absolute",transform:"translateY(-12px)",visibility:"hidden"},[`& .${il}`]:{position:"absolute",transform:"translateY(-12px)",bottom:"-10px"}}}}}),hf=Re(ew,{variants:{customToken:{true:{"&:hover":{cursor:"unset"}}}}}),pl=Re("div",{paddingLeft:"$5",paddingRight:"$5",borderRadius:"$md",display:"flex",alignItems:"center"}),ul=Re(ff,{}),yf=Re("div",{textAlign:"right",width:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",[`& .${ll}`]:{$$color:"$colors$neutral600",[`.${ol} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),Hn=Re("div",{display:"flex",alignItems:"end",flexDirection:"column"}),Uz=Re("div",{display:"flex",alignItems:"center"}),Sf=Re("div",{position:"relative",[`& ${Rv}`]:{borderRadius:"$xm",overflow:"hidden"}}),Cf=Re("div",{position:"absolute",backgroundColor:"$neutral100",padding:"$4",borderRadius:"50%",bottom:-6,right:-6}),kf=Re(ff,{width:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}),Tf=Re("a",{"& svg:hover":{color:"$colors$info"}}),vf=Re("div",{paddingRight:"$5","& .widget-token-list-item-btn":{width:"100%",overflow:"hidden",height:"60px"},"& .widget-token-list-item-import-btn":{height:"$20",padding:"0 $10","& ._text":{display:"flex",justifyContent:"center",alignItems:"center"},"& ._typography":{[`.${ol} &`]:{color:"$foreground"}}}});function bf(t){return vt.createElement(Ai,null,Array.from(Array(t.size),e=>vt.createElement(tw,{key:e,hasDivider:!0,start:vt.createElement(qn,{variant:"circular",width:35,height:35}),end:vt.createElement(Hn,null,vt.createElement(qn,{variant:"text",size:"large",width:70}),vt.createElement(wf,{size:4}),vt.createElement(qn,{variant:"text",size:"medium",width:50})),title:vt.createElement("div",null,vt.createElement(qn,{variant:"text",size:"large",width:90}),vt.createElement(wf,{size:4}),vt.createElement(qn,{variant:"text",size:"medium",width:90}))})))}i(bf,"LoadingTokenList");var mw=20,dw=i(t=>{let{address:e,name:o,url:n,token:r,customCssForTag:a,customCssForTagTitle:s}=t,l=e.length;return W.createElement("div",{className:rl()},o?W.createElement("div",{className:nl()},o):W.createElement(cl,{className:il()},W.createElement(Gn,{variant:"title",size:"xmedium"},r.symbol),W.createElement(Ut,{direction:"horizontal",size:4}),W.createElement(pl,{css:a},W.createElement(ul,{variant:"body",size:"xsmall",css:s},r.blockchain))),!!e&&W.createElement("div",{className:`${al()} ${!o&&sl()}`},l>10?`${e.slice(0,5)}...${e.slice(l-6,l)}`:e," ",W.createElement(Ut,{size:4,direction:"horizontal"}),W.createElement(Tf,{href:n,target:"_blank",rel:"nofollow noreferrer",onClick:c=>c.stopPropagation()},W.createElement(rw,{size:12}))))},"renderDesc");function Vn(t){let{list:e,searchedFor:o="",onChange:n,selectedBlockchain:r,showTitle:a=!0,action:s,type:l,showWarning:c=!0}=t,p=y().fetchStatus,u=y().blockchains(),{getBalanceFor:m,fetchingWallets:h}=y(),{isTokenPinned:d}=y(),{setFromToken:f,setToToken:g}=O(),{t:k}=uw(),C=Oe(),[S,T]=pw(null),w=i(()=>{l==="source"?f({token:S,meta:{blockchains:u}}):g({token:S,meta:{blockchains:u}})},"updateToken"),E=i(()=>{w(),C()},"handleImportToken"),B=i(b=>{if(b.customToken){let{customToken:A,...M}=b;return W.createElement(ow,{variant:"contained",type:"primary",size:"small",className:"widget-token-list-item-import-btn",onClick:i(j=>{j.stopPropagation(),T({...M,warning:!0})},"handleClick")},W.createElement(Gn,{variant:"body",size:"xsmall",color:"background"},k("import")))}let v=br(m(b));return s?s(b):h?W.createElement(Hn,null,W.createElement(Ao,{variant:"text",size:"large",width:70}),W.createElement(Ut,{size:4}),W.createElement(Ao,{variant:"text",size:"medium",width:50})):v&&W.createElement(yf,null,W.createElement(kf,{variant:"title",size:"small"},v.amount),W.createElement("div",null),v.usdValue&&W.createElement(Gn,{variant:"body",className:ll(),size:"xsmall"},`$${v.usdValue}`))},"endRenderer"),I=i(()=>W.createElement(cw,{itemContent:b=>{let v=e[b];if(v==="skeleton")return W.createElement(aw,{hasDivider:!0,start:W.createElement(Ao,{variant:"circular",width:35,height:35}),end:W.createElement(Hn,null,W.createElement(Ao,{variant:"text",size:"large",width:70}),W.createElement(Ut,{size:4}),W.createElement(Ao,{variant:"text",size:"medium",width:50})),title:W.createElement("div",null,W.createElement(Ao,{variant:"text",size:"large",width:90}),W.createElement(Ut,{size:4}),W.createElement(Ao,{variant:"text",size:"medium",width:90}))});let A=v.address||"",M=u.find(L=>L.name===v.blockchain);if(!M)return null;let _=rs(M.color,"main"),j={$$color:_.main150,[`.${xf} &`]:{$$color:_.main750},backgroundColor:"$$color"},R={$$color:_.main750,[`.${xf} &`]:{$$color:_.main150},color:"$$color"},X=i(()=>{typeof v!="string"&&!v.customToken&&n?.(v)},"handleClick");return W.createElement(vf,null,W.createElement(hf,{"tab-index":b,key:`${v.symbol}${v.address}`,id:`${v.symbol}${v.address}`,className:"widget-token-list-item-btn",hasDivider:!0,customToken:v.customToken,onClick:X,start:W.createElement(Sf,null,W.createElement(iw,{src:v.image===""?gr:v.image,size:30}),t.type!=="custom-token"&&d(v,t.type)&&W.createElement(Cf,null,W.createElement(lw,{size:12,color:"gray"}))),title:M?.type==="COSMOS"||v.name||!v.name&&!A?W.createElement(cl,null,W.createElement(Gn,{variant:"title",size:"xmedium"},v.symbol),W.createElement(Ut,{direction:"horizontal",size:4}),W.createElement(pl,{css:j},W.createElement(ul,{variant:"body",size:"xsmall",css:R},v.blockchain)),c&&v.warning&&W.createElement(W.Fragment,null,W.createElement(Ut,{direction:"horizontal",size:4}),W.createElement(nw,{container:N()}))):void 0,description:typeof v!="string"&&M?.info&&A&&M.type!=="COSMOS"?dw({address:A,token:v,customCssForTag:j,customCssForTagTitle:R,name:v.name,url:M.info.addressUrl.split("{wallet}").join(A)}):v.name||void 0,end:B(v)}))},totalCount:e.length,key:`${r}-${o}`}),"renderList"),x=S?co(S?.blockchain,u):null;return W.createElement(W.Fragment,null,a&&W.createElement(W.Fragment,null,W.createElement(Gn,{variant:"label",size:"large"},ml.t("Select Token")),W.createElement(Ut,{size:4})),W.createElement(gf,null,W.createElement(Ut,{size:4}),p==="loading"&&W.createElement(bf,{size:mw}),p==="success"&&(e.length?W.createElement(W.Fragment,null,W.createElement(In,{token:S,address:S?.address??"",blockchain:x??void 0,onImport:E,onExitErrorModal:()=>T(null),onExitImportModal:()=>T(null)}),W.createElement(Ai,{as:"ul"},I())):!!o&&W.createElement(sw,{title:ml.t("No results found"),description:ml.t("Try using different keywords")}))))}i(Vn,"TokenList");var Tw=gl("div",{display:"flex",justifyContent:"space-between",flexDirection:"column",flex:1}),vw=gl("div",{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",flex:"0.75"}),ww=gl(yw,{"&:hover":{"& svg":{color:"$secondary550"}}});function Ef(){let[t,e]=fl(""),{deleteCustomToken:o}=y(),n=y().customTokens(),{fromToken:r,toToken:a,setFromToken:s,setToToken:l}=O(),{mode:c}=Yo({}),p=kw(),[u,m]=fl(!1),[h,d]=fl(),f=i(S=>{let T=S.target.value;e(T)},"handleSearch"),g=c==="dark",k=n.filter(S=>tt(S.symbol,t)||tt(S.address||"",t)||tt(S.name||"",t)),C=i(()=>{if(h){let S=a?mt(a):null,T=r?mt(r):null,w=mt(h);S===w?l({token:null}):T===w&&s({token:null}),o(h)}m(!1)},"handleDeleteCustomToken");return me.createElement(oe,{header:{title:zt.t("Custom Tokens")}},me.createElement(re,null,me.createElement(Tw,null,n.length?me.createElement(me.Fragment,null,me.createElement(Tt,{value:t,setValue:e,fullWidth:!0,color:"light",variant:"contained",placeholder:zt.t("Search Token"),onChange:f}),me.createElement(Kn,{size:16}),me.createElement(Vn,{list:k,type:"custom-token",searchedFor:t,showTitle:!1,showWarning:!1,action:S=>me.createElement(ww,{id:"widget-custom-token-delete-icon-btn",variant:"ghost",onClick:()=>{m(!0),d(S)}},me.createElement(hw,{size:12,color:"gray"}))})):me.createElement(vw,null,me.createElement(Cw,{icon:g?me.createElement(fw,{size:200}):me.createElement(gw,{size:200}),title:zt.t("No custom tokens"),description:zt.t("press the button to add your custom token")})),me.createElement(Kn,{size:20}),me.createElement(dl,{id:"widget-custom-token-add-btn",type:"primary",variant:"contained",size:"large",onClick:()=>p(F.addCustomTokens)},zt.t("Add Custom Token"))),me.createElement(J,{open:u,dismissible:!0,onClose:()=>m(!1),container:N()},me.createElement(Sw,{title:zt.t("Delete Custom Token"),type:"error",description:zt.t("Are you sure you want to Delete this Token?")},me.createElement(Kn,{size:40}),me.createElement(Kn,{size:10}),me.createElement(dl,{fullWidth:!0,id:"widget-custom-token-delete-modal-yes-btn",variant:"contained",type:"primary",size:"large",onClick:C},zt.t("Yes, Delete it")),me.createElement(Kn,{size:12}),me.createElement(dl,{id:"widget-custom-token-delete-modal-no-btn",fullWidth:!0,variant:"outlined",type:"primary",size:"large",onClick:()=>m(!1)},zt.t("No, Continue"))))))}i(Ef,"CustomTokensPage");import{i18n as Ge}from"@lingui/core";import{useManager as Qw}from"@rango-dev/queue-manager-react";import{Button as vl,darkTheme as Hw,Divider as Bo,MessageBox as qw,NotFound as Gw,styled as wl,Typography as Wi}from"@rango-dev/ui";import{TransactionStatus as Yn}from"rango-types";import ie,{useMemo as Gf,useState as Li}from"react";import{useNavigate as Vw}from"react-router-dom";import{FilterIcon as Bw,Popover as Ww}from"@rango-dev/ui";import No from"react";import{css as bw,darkTheme as Ni,IconButton as xw,styled as jn}from"@rango-dev/ui";var hl=jn("div",{position:"relative","&::before":{position:"absolute",right:"1px",top:"-1px",width:"$8",height:"$8",borderRadius:"100%",backgroundColor:"$neutral300",[`.${Ni} &`]:{backgroundColor:"$neutral400"},padding:"$2"},variants:{isSelect:{true:{"&::before":{content:""}}}}}),If=jn(xw,{width:"$36",height:"$36",position:"relative",padding:"0",overflow:"unset",backgroundColor:"$neutral300",[`.${Ni} &`]:{backgroundColor:"$neutral400"},"&:hover":{backgroundColor:"$secondary100",[`.${Ni} &`]:{backgroundColor:"$neutral"},[`& ${hl}::before`]:{backgroundColor:"$secondary100",[`.${Ni} &`]:{backgroundColor:"$neutral"}}},variants:{isSelect:{true:{border:"1px solid $secondary"}}}}),Af=jn("div",{position:"absolute",width:"$6",height:"$6",display:"flex",justifyContent:"center",alignItems:"center",borderRadius:"3px",top:"$0",right:"1px",backgroundColor:"$secondary500"}),Nf=jn("div",{padding:"$15",borderRadius:"$sm",width:"248px",backgroundColor:"$background",zIndex:10}),Bf=bw({display:"flex",justifyContent:"space-between",alignItems:"center"}),Wf=jn("ul",{margin:0,listStyle:"none",height:"100%",padding:0,".item-start-container":{paddingRight:"0 !important"}});import{i18n as Lf}from"@lingui/core";import{Button as Ew,Divider as Mf,ListItemButton as Iw,Radio as Aw,RadioRoot as Nw,Typography as Pf}from"@rango-dev/ui";import at from"react";function _f(t){let{filterBy:e,onClickItem:o}=t;return at.createElement(Nf,null,at.createElement("div",{className:Bf()},at.createElement(Pf,{size:"small",variant:"body"},Lf.t("Status")),at.createElement(Ew,{id:"widget-filter-selector-reset-btn",variant:"ghost",size:"xxsmall",onClick:()=>o("")},Lf.t("Reset"))),at.createElement(Mf,{size:10}),at.createElement(Nw,{value:e},at.createElement(Wf,null,t.list.map((n,r)=>at.createElement(Iw,{key:n.id,style:{height:"40px",width:"100%"},selected:!1,hasDivider:t.list.length-1!=r,id:n.id,title:at.createElement(at.Fragment,null,at.createElement(Mf,{direction:"horizontal",size:4}),at.createElement(Pf,{size:"medium",variant:"body"},n.title)),start:at.createElement(Aw,{value:n.id}),onClick:o})))))}i(_f,"FilterSelectorContent");function yl(t){let{onClickItem:e,onOpenChange:o,filterBy:n,list:r,open:a}=t;return No.createElement("div",null,No.createElement(Ww,{open:a,align:"end",onOpenChange:o,container:N(),content:No.createElement(_f,{list:r,filterBy:n,onClickItem:s=>{e(s),o(!1)}})},No.createElement(If,{id:"widget-filter-selector-filter-icon-btn",variant:"default",isSelect:!!n,onClick:()=>o(!t.open)},No.createElement(hl,{isSelect:!!n},No.createElement(Bw,{size:16,color:"black"}),!!n&&No.createElement(Af,null)))))}i(yl,"FilterSelector");import{i18n as Pw}from"@lingui/core";import{Divider as Uf,GroupedVirtualizedList as _w,Skeleton as Dw,SwapListItem as zf,Typography as $w}from"@rango-dev/ui";import qe,{useCallback as Qf,useEffect as Fw,useRef as Ow,useState as Uw}from"react";function Df(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(Df,"calculateGroupsSoFar");import{css as Lw,darkTheme as Mw,styled as Xn}from"@rango-dev/ui";var Sl=Lw(),$f=Xn("div",{display:"flex",justifyContent:"center",alignItems:"center",padding:"$5"}),Cl=Xn("div",{width:"100%",display:"flex",flexDirection:"column",backgroundColor:"$background",padding:"$10 $5 0 $5",[`& .${Sl}`]:{$$color:"$colors$neutral600",[`.${Mw} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),kl=Xn("div",{display:"flex",justifyContent:"flex-start",padding:"$2"}),Ff=Xn("div",{gap:"$10",display:"flex",flexDirection:"column"}),Of=Xn("div",{height:"100%",display:"flex",justifyContent:"center",alignItems:"center"});var zw=10;function Tl(t){let{list:e,onSwapClick:o,groupBy:n,isLoading:r}=t,[a,s]=Uw([]),l=Ow(0),{swaps:c,groupCounts:p,groups:u}=n(e),m=Qf(Df,[]),h=Qf(()=>{let d=e.length-l.current;d&&(l.current+=Math.min(d,zw),s(m(p,l.current)))},[e.length]);if(Fw(()=>{r||h()},[r,h]),r){let d=[1,2];return qe.createElement(qe.Fragment,null,[d,d].map((g,k)=>qe.createElement(Cl,{key:k},qe.createElement(kl,null,qe.createElement(Dw,{variant:"text",width:60,size:"small"}),qe.createElement(Uf,{size:16})),qe.createElement(Uf,{size:4}),qe.createElement(Ff,null,g.map((S,T)=>qe.createElement(zf,{isLoading:!0,key:T}))))))}return qe.createElement(_w,{endReached:()=>{l.current<e.length&&h()},groupCounts:a,groupContent:d=>qe.createElement(Cl,null,qe.createElement(kl,null,qe.createElement($w,{variant:"label",size:"medium",className:Sl()},u[d]))),itemContent:(d,f)=>{let g=c[d];if(!g)return null;let k=g.steps[0],C=g.steps[g.steps.length-1];return qe.createElement($f,{key:g.requestId},qe.createElement(zf,{requestId:g.requestId,creationTime:g.creationTime,status:g.status,onClick:o,tooltipContainer:N(),onlyShowTime:u[f]===Pw.t("Today"),swapTokenData:{from:{token:{image:k.fromLogo,displayName:k.fromSymbol},blockchain:{image:k.fromBlockchainLogo||""},amount:P(g.inputAmount,6,6),realAmount:g.inputAmount},to:{token:{image:C.toLogo,displayName:C.toSymbol},blockchain:{image:C.toBlockchainLogo||""},amount:P(C.outputAmount||C.expectedOutputAmountHumanReadable||"",6,6),realAmount:C.outputAmount||C.expectedOutputAmountHumanReadable||""}}}))}})}i(Tl,"HistoryGroupedList");import{i18n as Bi}from"@lingui/core";import Hf from"dayjs";var qf=i(t=>{let e=new Map([["today",{title:Bi.t("Today"),swaps:[]}],["week",{title:Bi.t("This week"),swaps:[]}],["month",{title:Bi.t("This month"),swaps:[]}],["year",{title:Bi.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=Hf();t.forEach(c=>{let p=Number(c.creationTime),u=Hf(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 m=new Date(p).getFullYear().toString();o(m,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=wl("div",{overflowY:"visible",width:"100%",display:"flex",flexDirection:"column",gap:15,height:"100%"}),jw=wl("div",{display:"flex",justifyContent:"center",alignItems:"center"}),Xw=wl("div",{"._typography":{color:"$neutral700",[`.${Hw}&`]:{color:"$neutral900"}}}),Yw=[{id:Yn.SUCCESS,title:Ge.t("Complete")},{id:Yn.RUNNING,title:Ge.t("Running")},{id:Yn.FAILED,title:Ge.t("Failed")}],Zw=i((t,e)=>t?.length?t.filter(o=>bt(o.fromBlockchain,e)||bt(o.toBlockchain,e)||bt(o.toSymbol,e)||bt(o.fromSymbol,e)).length:!1,"isStepContainsText");function Vf(){let t=Vw(),{manager:e,state:o}=Qw(),n=ft(e).map(({swap:T})=>T),[r,a]=Li(""),[s,l]=Li(!1),c=!o.loadedFromPersistor,[p,u]=Li(""),[m,h]=Li(!1),d=i(T=>{let w=T.target.value;a(w)},"handleSearch"),f=Gf(()=>!r&&!p?n:n.filter(T=>{let{inputAmount:w,status:E,steps:B,requestId:I}=T;return(!r||bt(w,r)||bt(E,r)||Zw(B,r)||bt(I,r))&&(!p||p===E)}),[n,r,p]),g=!f?.length&&!c,k=i(()=>h(!1),"onCloseModal"),C=i(async()=>{try{await e?.clearQueue(),h(!1)}catch(T){console.log(T)}},"onClear"),S=Gf(()=>!n.some(T=>T.status===Yn.SUCCESS||T.status===Yn.FAILED),[n]);return ie.createElement(oe,{header:{title:Ge.t("History"),suffix:ie.createElement(jt,null,ie.createElement(vl,{id:"widget-history-clear-btn",disabled:S,variant:"ghost",size:"xsmall",onClick:()=>h(!0)},ie.createElement(Wi,{size:"medium",variant:"label",color:"error"},Ge.t("Clear"))))}},ie.createElement(re,null,ie.createElement(jw,null,ie.createElement(Tt,{setValue:a,fullWidth:!0,variant:"contained",placeholder:Ge.t("Search Transaction"),autoFocus:!0,onChange:d,style:{height:36},value:r}),ie.createElement(Bo,{size:10,direction:"horizontal"}),ie.createElement(yl,{filterBy:p,open:s,onOpenChange:T=>l(T),onClickItem:T=>u(T),list:Yw})),ie.createElement(Bo,{size:"16"}),ie.createElement(Kw,null,g&&ie.createElement(Of,null,ie.createElement(Bo,{size:32}),ie.createElement(Gw,{title:r?Ge.t("No results found"):Ge.t("No transactions"),titleColor:r?void 0:"$info",hasIcon:!!r,description:r?Ge.t("Try using different keywords"):Ge.t("Your transaction history is stored locally and will appear here after you start a swap")})),!g&&ie.createElement(Tl,{list:f,onSwapClick:t,groupBy:qf,isLoading:c}))),ie.createElement(J,{open:m,onClose:k,container:N()},ie.createElement(Bo,{size:20}),ie.createElement(qw,{type:"warning",title:Ge.t("Clear Transaction History"),description:ie.createElement(Xw,null,ie.createElement(Wi,{variant:"body",size:"medium"},Ge.t("Proceeding will remove all successful and failed transactions from the widget. Do you want to continue?")),ie.createElement(Bo,{size:"24"}),ie.createElement(Wi,{variant:"body",size:"small"},Ge.t("Note: This does not erase your transaction history on the chain; it only removes them here.")))}),ie.createElement(Bo,{size:30}),ie.createElement(vl,{id:"widget-history-clear-modal-yes-btn",variant:"contained",type:"primary",size:"large",onClick:C},Ge.t("Yes, Clear the history")),ie.createElement(Bo,{size:10}),ie.createElement(vl,{id:"widget-history-clear-modal-no-btn",variant:"outlined",type:"primary",size:"large",onClick:k},ie.createElement(Wi,{variant:"title",size:"medium",color:"primary"},Ge.t("No, Cancel")))))}i(Vf,"HistoryPage");import{i18n as Tb}from"@lingui/core";import{Button as vb,Divider as dg,styled as wb,WarningIcon as bb}from"@rango-dev/ui";import xb from"bignumber.js";import Ve,{useEffect as fg,useState as gg}from"react";import{useNavigate as Eb}from"react-router-dom";import{i18n as jf}from"@lingui/core";import{Alert as Rw,Divider as bl,NoRouteIcon as eb,Typography as tb}from"@rango-dev/ui";import Wo from"react";import{styled as Jw}from"@rango-dev/ui";var Kf=Jw("div",{display:"flex",flexDirection:"column",alignItems:"center"});function xl(){let{fromToken:t,toToken:e}=O();return!!t&&!!e&&Wt(t,e)?Wo.createElement(Kf,null,Wo.createElement(bl,{size:10}),Wo.createElement(eb,{size:24,color:"gray"}),Wo.createElement(bl,{size:4}),Wo.createElement(tb,{variant:"title",size:"small"},jf.t("No Routes Found")),Wo.createElement(bl,{size:4}),Wo.createElement(Rw,{title:jf.t("You cannot use the same token for From and To."),type:"warning",variant:"alarm"})):null}i(xl,"SameTokensWarning");import{i18n as sb}from"@lingui/core";import{Header as lb}from"@rango-dev/ui";import oo,{useEffect as cb,useState as pb}from"react";import{i18n as nb}from"@lingui/core";import{Divider as Il,FullExpandedQuote as rb,Typography as ib}from"@rango-dev/ui";import Se from"react";import{styled as El}from"@rango-dev/ui";var Xf=El("div",{display:"flex",justifyContent:"center",flexDirection:"column",height:"100%"}),Yf=El("div",{display:"flex",justifyContent:"space-between",alignItems:"center"}),Zf=El("div",{width:"146px"});import{i18n as Zn}from"@lingui/core";import{Select as ob}from"@rango-dev/ui";import Jf from"react";function Mi(t){let{updateQuotePartialState:e,sortStrategy:o}=O(),n=[{value:"SMART",label:Zn.t("Smart Routing")},{value:"FEE",label:Zn.t("Lowest Fee")},{value:"SPEED",label:Zn.t("Fastest Transfer")},{value:"NET_OUTPUT",label:Zn.t("Maximum Return")},{value:"PRICE",label:Zn.t("Maximum Output")}];return Jf.createElement(Zf,null,Jf.createElement(ob,{container:t.container,options:n,value:o,handleItemClick:r=>{e("sortStrategy",r.value)},variant:"filled"}))}i(Mi,"SelectStrategy");var Rf=3;function Jn(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:m,toToken:h,sortStrategy:d,error:f}=O(),{slippage:g,customSlippage:k}=y(),{findToken:C}=y(),S=l||N(),T=!!p&&p.results.length,w=k??g,E=i(x=>{if(!m||!h||!p)return null;let b={requestAmount:p.requestAmount,validationStatus:null,...x};return Vo({currentQuote:b,userSlippage:w,findToken:C})},"getQuoteWarning"),B=f?.type===0||f?.type===1,I=p?.results?Or(d,p?.results):[];return Se.createElement(Se.Fragment,null,a&&Se.createElement(Se.Fragment,null,Se.createElement(Yf,null,Se.createElement(ib,{size:"xmedium",variant:"title"},nb.t("Sort by")),Se.createElement(Mi,{container:S})),Se.createElement(Il,{size:"10"})),e&&Array.from({length:Rf},(x,b)=>Se.createElement(Se.Fragment,{key:b},s?Se.createElement(rb,{loading:!0}):Se.createElement(Un,{tagHidden:!1,type:"list-item",expanded:!1}),b!==Rf-1&&Se.createElement(Il,{size:16}))),!e&&Se.createElement(Se.Fragment,null,T?I.map((x,b)=>{let v=E(x),A=Zs(x.swaps),M=I.length-1===b;return Se.createElement(Se.Fragment,{key:x.requestId},Se.createElement(Io,{showModalFee:r,container:S,selected:c?.requestId===x.requestId,tagHidden:!1,quote:{...x,requestAmount:p.requestAmount,validationStatus:null},loading:e,error:A?.options||null,warning:v,fullExpandedMode:s,onClick:_=>{A||u("warning",v),u("error",A?.options||null),o(_)},type:"list-item"}),!M&&Se.createElement(Il,{size:16}))}):B&&Se.createElement(Xf,null,Se.createElement(Wn,{size:s?"large":"small",error:f,fetch:n}))))}i(Jn,"Quotes");import{darkTheme as ab,styled as eg}from"@rango-dev/ui";var tg=eg("div",{transition:"width 0.2s, opacity 0.2s, margin-left 0.2s",height:"700px",width:"390px",position:"relative",opacity:1,marginLeft:"$16",backgroundColor:"$neutral100",[`.${ab} &`]:{backgroundColor:"$neutral300"},variants:{expandMode:{default:{width:"390px"},full:{width:"719px"}}},"&.is-hidden":{width:0,height:0,opacity:0,marginLeft:0}}),og=eg("div",{position:"relative",overflow:"hidden",padding:"$20",flexGrow:1,display:"flex",flexDirection:"column",overflowY:"auto",borderRadius:"$primary",backgroundColor:"$background"});var ub=100;function Al(t){let{fetch:e,loading:o,onClickOnQuote:n,onClickRefresh:r,isVisible:a}=t,[s,l]=pb(!1),c=s?"":"is-hidden",{config:p}=y(),u=p?.variant==="full-expanded",m=uo();return cb(()=>{let h=null;return a?h=setTimeout(()=>{l(!0)},ub):(l(!1),h&&clearTimeout(h)),()=>{h&&clearTimeout(h)}},[a]),oo.createElement(tg,{expandMode:p?.variant==="full-expanded"?"full":"default",className:`${c} ${Jr()}`,id:$e.EXPANDED_BOX_ID},oo.createElement(lb,{title:sb.t("Routes"),suffix:oo.createElement(oo.Fragment,null,oo.createElement(Mi,{container:m}),oo.createElement(wo,{container:m,onClickRefresh:r,hidden:["history","notifications","settings"]}))}),oo.createElement(og,null,oo.createElement(Jn,{showModalFee:!0,fetch:e,hasSort:!1,loading:o,container:uo(),onClickOnQuote:n,fullExpandedMode:u})))}i(Al,"ExpandedQuotes");import{i18n as cg}from"@lingui/core";import{SwapInput as pg}from"@rango-dev/ui";import gb from"bignumber.js";import Rn from"react";import{ReverseIcon as fb}from"@rango-dev/ui";import Bl from"react";import{keyframes as mb,styled as ng}from"@rango-dev/ui";var Nl=450,db=mb({"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)"}}),rg=ng("div",{position:"absolute",bottom:"-12px",left:"50%",transform:"translate(-50%, 10%)",cursor:"pointer"}),ig=ng("div",{borderRadius:"$md",border:"3px solid $background",background:"$neutral100",width:"$24",height:"$24",display:"flex",justifyContent:"center",alignItems:"center",color:"$foreground","&.rotate":{"& svg":{animation:`${db} ${Nl}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 Wl(){let t=O.use.switchFromAndTo();return Bl.createElement(rg,null,Bl.createElement(ig,{onClick:e=>{let o=e.currentTarget;o.classList.add("rotate"),setTimeout(()=>{o.classList.remove("rotate")},Nl),t()}},Bl.createElement(fb,{size:12})))}i(Wl,"SwitchFromAndToButton");import{styled as ag}from"@rango-dev/ui";var sg=ag("div",{display:"flex",flexDirection:"column",gap:"$5",alignSelf:"stretch"}),lg=ag("div",{position:"relative"});function Ll(t){let{fetchingQuote:e,fetchMetaStatus:o,onClickToken:n,isExpandable:r}=t,{fromToken:a,fromBlockchain:s,toToken:l,toBlockchain:c,setInputAmount:p,inputAmount:u,inputUsdValue:m,outputAmount:h,outputUsdValue:d,selectedQuote:f}=O(),{connectedWallets:g,getBalanceFor:k}=y(),C=a?k(a):null,S=br(C)?.amount??"0",T=C?new gb(C.amount).shiftedBy(-C.decimals):le,w=!!s&&ep(g,s.name),E=!Qa(f,u,m),B=!Qa(f,u,d),I=!m||!d||!d.gt(0)?null:Pt(m.toString(),d.toString());return Rn.createElement(sg,null,Rn.createElement(lg,null,Rn.createElement(pg,{label:cg.t("From"),mode:"From",onInputChange:p,balance:S,chain:{displayName:s?.displayName||"",image:s?.logo},token:{displayName:a?.symbol||"",image:a?.image,securityWarning:!!a?.warning},onClickToken:()=>n("from"),price:{value:u,usdValue:E?void 0:P(m,4,4),realUsdValue:E?void 0:m?.toString(),error:E?ee().unknownPriceError.impactTitle:void 0},disabled:o==="failed",loading:o==="loading",loadingBalance:w,tooltipContainer:N(),onSelectMaxBalance:()=>{let x=P(T,C?.decimals),b=C?.amount?x.split(",").join(""):"";p(b)},anyWalletConnected:g.length>0}),Rn.createElement(Wl,null)),Rn.createElement(pg,{sharpBottomStyle:!r&&(!!f||e),label:cg.t("To"),mode:"To",fetchingQuote:e,chain:{displayName:c?.displayName||"",image:c?.logo},token:{displayName:l?.symbol||"",image:l?.image,securityWarning:!!l?.warning},percentageChange:P(Pt(m,d),2,2),warningLevel:_t(I??0),price:{value:P(h,6,6),usdValue:B?void 0:P(d,4,4),realValue:h?.toString(),realUsdValue:B?void 0:d?.toString(),error:B?ee().unknownPriceError.impactTitle:void 0},onClickToken:()=>n("to"),disabled:o==="failed",loading:o==="loading",tooltipContainer:N()}))}i(Ll,"Inputs");import{useCallback as hb,useEffect as yb,useRef as Sb,useState as Cb}from"react";function ug(){let{fetch:t,loading:e,cancelFetch:o}=bi({request:async(n,r)=>await ot().getAllRoutes(n,r)});return{fetch:t,loading:e,cancelFetch:o}}i(ug,"useFetchAllQuotes");var kb=600;function Pi({refetchQuote:t}){let{fetch:e,cancelFetch:o}=ug(),{excludeLiquiditySources:n,routing:r}=y().config,{connectedWallets:a}=y(),l=a.some(Ie=>Ie.isContractWallet),{fromToken:c,toToken:p,inputAmount:u,inputUsdValue:m,selectedQuote:h,sortStrategy:d,resetQuote:f,error:g,warning:k,setSelectedQuote:C,updateQuotePartialState:S}=O(),{slippage:T,customSlippage:w,affiliatePercent:E,affiliateRef:B,affiliateWallets:I,fetchStatus:x}=y(),b=y().getLiquiditySources(),v=y().getDisabledLiquiditySources(),A=y().excludeLiquiditySources(),{findToken:M}=y(),[_,j]=Cb(!0),R=Sb(u),X=w??T,H=!c||!p||Wt(c,p)||!fn(u),ae=i(Ie=>{j(Ie)},"resetState"),G=i(Ie=>{let{fromToken:je,toToken:se,inputAmount:pt,liquiditySources:V,excludeLiquiditySources:D,disabledLiquiditySources:q,slippage:K,affiliateRef:ge,affiliatePercent:ce,affiliateWallets:_e}=Ie;if(_||ae(!0),!H&&je&&se){f();let Xe=vu({fromToken:je,toToken:se,inputAmount:pt,liquiditySources:V,excludeLiquiditySources:D,disabledLiquiditySources:q,wallets:a,slippage:K,affiliateRef:ge,affiliatePercent:ce,affiliateWallets:_e,contractCall:l});Fo("experimental",r)&&(Xe.experimental=!0),Fo("avoidNativeFee",r)&&(Xe.avoidNativeFee=!0),Fo("enableCentralizedSwappers",r)&&(Xe.enableCentralizedSwappers=!0),r?.maxLength&&(Xe.maxLength=r.maxLength),e(Xe).then(ke=>{let De=Or(d,ke.results),Vt=pu(h,De,ke.requestAmount);j(!1),S("quotes",ke),C(Vt),xi({diagnosisMessages:ke.diagnosisMessages,requestId:Vt?.requestId||"",swaps:Vt?.swaps});let lo=Vt&&Vo({currentQuote:Vt,userSlippage:X,findToken:M});S("warning",lo)}).catch(ke=>{let{error:De}=Ei(ke);(De?.type===0||De?.type===1)&&f(),De?.type!==2&&(S("error",De),j(!1))})}},"fetch"),fe=hb(Sr(Ie=>{G(Ie)},kb),[H]);return yb(()=>{if(!t){j(!1);return}if(x!=="success")return;if(H){j(!1),(h||g||k)&&f();return}if(!fn(u)||m?.eq(0)){ae(!1),o();return}f(),ae(!0);let Ie=G;return R.current&&R.current!=u&&(Ie=fe),R.current=u,Ie({inputAmount:u,fromToken:c,toToken:p,liquiditySources:b,excludeLiquiditySources:A,disabledLiquiditySources:v,slippage:X,affiliateRef:B,affiliatePercent:E,affiliateWallets:I,contractCall:l}),o},[x,u,c?.symbol,c?.address,c?.blockchain,p?.symbol,p?.address,p?.blockchain,H,b?.length,n,v.length,X,B,E,l,JSON.stringify(I)]),{fetch:()=>G({inputAmount:u,fromToken:c,toToken:p,liquiditySources:b,excludeLiquiditySources:A,disabledLiquiditySources:v,slippage:X,affiliateRef:B,affiliatePercent:E,affiliateWallets:I,contractCall:l}),loading:_}}i(Pi,"useSwapInput");function mg(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(mg,"emitPreventableEvent");var Ib=wb("div",{display:"flex",alignItems:"flex-start",maxHeight:700,"& .footer__alert":{paddingTop:"0 !important"}}),Ab=300;function hg(){let t=Eb(),{fromToken:e,toToken:o,inputAmount:n,selectedQuote:r,refetchQuote:a,error:s,warning:l,quotes:c,setSelectedQuote:p,resetQuoteWallets:u,setQuoteWarningsConfirmed:m,updateQuotePartialState:h}=O(),[d,f]=gg(!1),{isLargeScreen:g,isExtraLargeScreen:k}=hi(),{fetch:C,loading:S}=Pi({refetchQuote:a}),{config:T,fetchStatus:w,connectedWallets:E}=y(),{isActiveTab:B}=ne(),[I,x]=gg(!1),v=Su({fetchMetaStatus:w,fetchingQuote:S,inputAmount:n,quote:r,anyWalletConnected:E.length>0,error:s,warning:l,needsToWarnEthOnPath:!1}),A=sp(g,k,T?.variant),M=!!n&&!!e&&!!o&&new xb(n).gt(0)&&!Nu(e,o),_=M&&w==="success"&&S,X=(!A||A&&c?.results.length)&&(l||s);fg(()=>{u(),h("refetchQuote",!0)},[]),fg(()=>{f(M)},[M]);let L=(r||s)&&!I?C:void 0,H=i(G=>{A&&d?(f(!1),setTimeout(()=>{t(G)},Ab)):t(G)},"onHandleNavigation"),ae=i(G=>{r?.requestId!==G.requestId&&(x(!1),p(G))},"onClickOnQuote");return Ve.createElement(Ib,null,Ve.createElement(oe,{height:"auto",footer:Ve.createElement(vb,{id:`widget-swap-${v.action}-btn`,type:"primary",size:"large",disabled:v.disabled||!B,prefix:v.action==="confirm-warning"&&Ve.createElement(bb,null),fullWidth:!0,onClick:()=>{v.action==="connect-wallet"?mg({type:"clickConnectWallet"},()=>H(F.wallets)):v.action==="confirm-warning"?x(!0):H(F.confirmSwap)}},v.title),header:{onWallet:()=>{H(F.wallets)},hasBackButton:!1,title:T.title||Tb.t("Swap"),suffix:Ve.createElement(wo,{hidden:A?["refresh"]:void 0,onClickRefresh:L,onClickHistory:()=>H(F.swaps),onClickSettings:()=>{H(F.settings)}})}},Ve.createElement(re,null,Ve.createElement(Ll,{fetchingQuote:_,fetchMetaStatus:w,isExpandable:A,onClickToken:G=>{H(G==="from"?F.fromSwap:F.toSwap)}}),Ve.createElement(dg,{size:"2"}),A?null:Ve.createElement(Io,{quote:r,loading:_,error:s,tagHidden:!1,warning:l,type:"basic",onClickAllRoutes:c&&c.results.length>1?()=>{h("refetchQuote",!1),H(F.routes)}:void 0}),X?Ve.createElement(Ve.Fragment,null,Ve.createElement(dg,{size:"10"}),Ve.createElement(Mn,{warning:l,error:s,couldChangeSettings:!0,refetchQuote:C,showWarningModal:I,confirmationDisabled:!B,onOpenWarningModal:()=>x(!0),onCloseWarningModal:()=>x(!1),onConfirmWarningModal:()=>{x(!1),m(!0),H(F.confirmSwap)},onChangeSettings:()=>H(F.settings)})):null,Ve.createElement(xl,null))),A?Ve.createElement(Al,{loading:_,onClickOnQuote:ae,fetch:C,onClickRefresh:L,isVisible:d}):null)}i(hg,"Home");import{i18n as yg}from"@lingui/core";import{Alert as Nb,Divider as Bb,List as Wb,ListItemButton as Lb,Radio as Mb,RadioRoot as Pb,Typography as _b}from"@rango-dev/ui";import Nt from"react";function no(){let{setLanguage:t,language:e,config:o}=y(),n=mp,r=o?.language||Oo;return{activeLanguage:e||r,languages:n,defaultLanguage:r,changeLanguage:a=>t(a||Oo),resetLanguage:()=>t(null)}}i(no,"useLanguage");function Sg(){let{activeLanguage:t,changeLanguage:e,languages:o}=no(),n=Oe(),r=o.map(a=>{let{local:s,label:l,SVGFlag:c}=a;return{id:`widget-setting-languages-${s}-item-btn`,value:s,title:Nt.createElement(_b,{variant:"title",size:"xmedium"},l),onClick:()=>{e(a.local),n()},end:Nt.createElement(Mb,{value:s}),start:Nt.createElement(c,null)}});return Nt.createElement(oe,{header:{title:yg.t("Language")}},Nt.createElement(re,null,Nt.createElement(Nb,{type:"warning",variant:"alarm",title:"Warning: We are using machine translation, so the translations may be inaccurate."}),Nt.createElement(Bb,{size:"8"}),Nt.createElement(Pb,{value:t},Nt.createElement(Wb,{type:Nt.createElement(Lb,{title:yg.t("language"),id:"_",onClick:()=>console.log()}),items:r}))))}i(Sg,"LanguagePage");import{i18n as Qt}from"@lingui/core";import{Button as Ub,Checkbox as zb,Image as Qb,ListItemButton as Hb,NotFound as qb,Typography as Gb}from"@rango-dev/ui";import Ke,{useState as Vb}from"react";import{Checkbox as Fb,Skeleton as kg}from"@rango-dev/ui";import tr from"react";import{styled as Ml}from"@rango-dev/ui";var er=Ml("ul",{padding:"$15 $5 0",margin:0,listStyle:"none",height:"100%",overflowY:"auto",variants:{disabled:{true:{pointerEvents:"none"}}}}),Pl=Ml("div",{width:80,display:"flex",justifyContent:"flex-end"}),_l=Ml("div",{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%"});import{ListItem as Db,styled as $b}from"@rango-dev/ui";var Cg=$b(Db,{height:61});var Ob=30;function Dl(){return tr.createElement(er,null,Array.from(Array(Ob),(t,e)=>tr.createElement(Cg,{hasDivider:!0,key:e,start:tr.createElement(kg,{variant:"circular",width:35,height:35}),title:tr.createElement(kg,{variant:"text",size:"large",width:90}),end:tr.createElement(Fb,{checked:!1})})))}i(Dl,"LoadingLiquiditySourceList");function $l({sourceType:t}){let e=y().fetchStatus,o=y().swappers(),n=y().getDisabledLiquiditySources(),[r,a]=Vb(""),s=y().toggleLiquiditySource,l=y().isInCampaignMode(),c=Ir(o,n),p={Exchanges:Qt.t("Exchanges"),Bridges:Qt.t("Bridges")},u=[];t==="Exchanges"&&u.push("DEX"),t==="Bridges"&&u.push("BRIDGE","AGGREGATOR","OFF_CHAIN");let m=c.filter(C=>u.includes(C.type)),h=m.length===m.filter(C=>C.selected).length,d=i(()=>{m.forEach(C=>{h?s(C.groupTitle):C.selected||s(C.groupTitle)})},"toggleAllSources"),f=m.map(C=>{let{selected:S,groupTitle:T,logo:w,id:E,...B}=C;return{id:`widget-setting-liquidity-source-${E.toLowerCase().replace(/\s+/g,"-")}-item-btn`,start:Ke.createElement(Qb,{src:w,size:22,type:"circular"}),onClick:()=>{l||s(T)},end:Ke.createElement(zb,{checked:S,disabled:l}),title:Ke.createElement(Gb,{variant:"title",size:"xmedium"},Qt.t(T)),selected:S,groupTitle:T,logo:w,...B}}),g=i(C=>{let S=C.target.value;a(S)},"handleSearch"),k=f;return r&&(k=f.filter(C=>bt(C.groupTitle,r))),Ke.createElement(oe,{header:{title:Qt.t(t),suffix:Ke.createElement(Pl,null,Ke.createElement(Ub,{id:`widget-liquidity-source-${h?"deselect-all":"select-all"}-btn`,variant:"ghost",size:"xsmall",onClick:d},h?Qt.t("Deselect all"):Qt.t("Select all")))}},Ke.createElement(re,{view:!0},Ke.createElement(Tt,{value:r,setValue:a,fullWidth:!0,color:"light",variant:"contained",placeholder:Qt.t("Search {sourceType}",{sourceType:p[t]}),onChange:g}),e==="loading"&&Ke.createElement(Dl,null),!k.length&&r?Ke.createElement(_l,null,Ke.createElement(qb,{title:Qt.t("No results found"),description:Qt.t("Try using different keywords")})):e==="success"&&Ke.createElement(er,{disabled:l},k.map(C=>{let{groupTitle:S,...T}=C;return Ke.createElement(Ke.Fragment,{key:C.id},Ke.createElement(Hb,{style:{height:"61px"},...T,selected:!1,hasDivider:!0}))}))))}i($l,"LiquiditySourcePage");import{i18n as Kb}from"@lingui/core";import _i from"react";import{useNavigate as jb}from"react-router-dom";function Tg(){let t=jb(),e=Oe(),{selectedQuote:o,refetchQuote:n,setSelectedQuote:r,updateQuotePartialState:a,error:s}=O(),{fetch:l,loading:c}=Pi({refetchQuote:n}),p=i(h=>{r(h),a("refetchQuote",!1),e()},"onClickOnQuote"),u=`../${F.settings}`,m=`../${F.wallets}`;return _i.createElement(oe,{header:{onWallet:()=>{t(m),a("refetchQuote",!0)},onBack:()=>{a("refetchQuote",!1)},title:Kb.t("Routes"),suffix:_i.createElement(wo,{onClickRefresh:o||s?l:void 0,hidden:["notifications","history"],onClickSettings:()=>{t(u),a("refetchQuote",!0)}})}},_i.createElement(re,null,_i.createElement(Jn,{fetch:l,loading:c,onClickOnQuote:p})))}i(Tg,"RoutesPage");import{i18n as Ag}from"@lingui/core";import{Divider as Ng,getCategoriesCount as rx,SelectableCategoryList as ix}from"@rango-dev/ui";import Ht,{useState as Bg}from"react";import{useNavigate as ax}from"react-router-dom";import{i18n as Fl}from"@lingui/core";import{Divider as Jb,Image as Rb,ListItemButton as ex,NotFound as tx,Typography as Ig}from"@rango-dev/ui";import st,{useEffect as ox,useState as nx}from"react";var vg=i((t,e,o)=>t.filter(n=>Cr(n.type,o)).filter(n=>tt(n.name,e)||tt(n.displayName,e)),"filterBlockchains");import{ImageContainer as Xb,styled as wg}from"@rango-dev/ui";var bg=wg("div",{display:"flex",flexDirection:"column",overflow:"hidden",height:"100%",justifyContent:"center"}),Di=wg(An,{padding:0,margin:0,listStyle:"none",[`& ${Xb}`]:{borderRadius:"$xm",overflow:"hidden"}});import{ListItem as Yb,Skeleton as xg}from"@rango-dev/ui";import $i from"react";var Zb=20;function Eg(){return $i.createElement(Di,null,Array.from(Array(Zb),t=>$i.createElement(Yb,{key:t,hasDivider:!0,start:$i.createElement(xg,{variant:"circular",width:35,height:35}),title:$i.createElement(xg,{variant:"text",size:"large",width:90})})))}i(Eg,"LoadingBlockchainList");function Ol(t){let{list:e,searchedFor:o,onChange:n,blockchainCategory:r,showTitle:a=!0}=t,[s,l]=nx(e),{fetchStatus:c}=y();ox(()=>{l([...vg(e,o,r)])},[e,o,r]);let p=i(()=>!s.length&&o?st.createElement(tx,{title:Fl.t("No results found"),description:Fl.t("Try using different keywords")}):st.createElement(Di,{as:"ul",key:`${r}-${o}`},s.map(u=>st.createElement(ex,{key:`${u.name}-${u.chainId}`,className:"widget-blockchain-list-item-btn",hasDivider:!0,onClick:()=>n(u),start:st.createElement(Rb,{src:u.logo,size:30}),title:st.createElement(Ig,{variant:"title",size:"medium"},u.displayName),id:u.name}))),"renderList");return st.createElement(st.Fragment,null,a&&st.createElement(st.Fragment,null,st.createElement(Ig,{variant:"label",size:"large"},Fl.t("Select Chain")),st.createElement(Jb,{size:4})),st.createElement(bg,null,c==="loading"&&st.createElement(Eg,null),c==="success"&&p()))}i(Ol,"BlockchainList");function Fi(t){let{type:e}=t,o=Oe(),[n,r]=Bg(""),[a,s]=Bg("ALL"),l=O.use.setToBlockchain(),c=O.use.setFromBlockchain(),{fetchStatus:p}=y(),u=ax(),m=y().blockchains({type:e}),h=rx(m),d=!t.hideCategory&&h!==1;return Ht.createElement(oe,{header:{title:Ag.t("Select Chain")}},Ht.createElement(re,{view:!0},d&&Ht.createElement(Ht.Fragment,null,Ht.createElement(ix,{setCategory:s,category:a,blockchains:m,isLoading:p==="loading"}),Ht.createElement(Ng,{size:24})),Ht.createElement(Tt,{value:n,autoFocus:!0,placeholder:Ag.t("Search Chain"),color:"light",variant:"contained",size:"large",setValue:()=>r(""),onChange:f=>r(f.target.value)}),Ht.createElement(Ng,{size:16}),Ht.createElement(Ol,{list:m,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(Fi,"SelectBlockchainPage");import{i18n as zi}from"@lingui/core";import{Divider as $g,Spinner as Cx}from"@rango-dev/ui";import ro,{useEffect as kx,useState as Tx}from"react";import{useNavigate as vx}from"react-router-dom";import{i18n as Ql}from"@lingui/core";import{BlockchainsChip as Oi,Divider as Pg,Image as _g,Skeleton as ux,Tooltip as mx,Typography as Hl}from"@rango-dev/ui";import Me from"react";import{useEffect as cx}from"react";var Wg=["ETH","COSMOS","OSMOSIS"];function Ul(t,e,o){let n=JSON.parse(JSON.stringify(t)),r=[];if(n.sort(sx),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(lx(s)),r=n.splice(a)}return{list:n,more:r}}i(Ul,"prepare");function sx(t,e){let o=Wg,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(sx,"sortByMostUsedBlockchains");function lx(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(lx,"generateSortByPreferredBlockchainsFor");function Lg(t,e){return!!e.list.find(o=>o.name===t)}i(Lg,"isInVisibleList");function zl(t,e){let{preferredBlockchains:o,addPreferredBlockchain:n}=y();cx(()=>{if(e?.selected){let a=Ul(t,o,e);Lg(e.selected,a)||n(e?.selected)}},[e?.selected]);let r=Ul(t,o,e);return{list:r.list,more:r.more,history:[]}}i(zl,"usePrepareBlockchainList");import{styled as px}from"@rango-dev/ui";var Mg=px("div",{display:"grid",gap:"$10",gridTemplateColumns:"repeat(6, minmax(0, 1fr))"});var dx=12;function ql(t){let{blockchains:e,type:o,blockchain:n,onChange:r,onMoreClick:a}=t,s=zl(e,{limit:10,selected:n?.name}),{fetchStatus:l}=y(),c=O.use.resetToBlockchain(),p=O.use.resetFromBlockchain(),u=s.more.length>0,m=s.more.length===1,h=!m&&u;return Me.createElement(Me.Fragment,null,Me.createElement(Pg,{size:12}),Me.createElement(Hl,{variant:"label",size:"large"},Ql.t("Select Chain")),Me.createElement(Pg,{size:12}),Me.createElement(Mg,null,l==="loading"&&Array.from(Array(dx),d=>Me.createElement(ux,{key:d,variant:"rounded",height:50})),l==="success"&&Me.createElement(Me.Fragment,null,Me.createElement(Oi,{selected:!n,onClick:()=>{o==="from"?p():c()}},Me.createElement(Hl,{variant:"body",size:"xsmall",color:"secondary500"},Ql.t("All"))),s.list.map(d=>Me.createElement(mx,{key:d.name,content:d.shortName,side:"bottom",sideOffset:2,container:N()},Me.createElement(Oi,{key:d.name,selected:!!n&&n.name===d.name,onClick:()=>r(d)},Me.createElement(_g,{src:d.logo,size:30})))),m?Me.createElement(Oi,{key:s.more[0].name,selected:!!n&&n.name===s.more[0].name,onClick:()=>r(s.more[0])},Me.createElement(_g,{src:s.more[0].logo,size:30})):null,h?Me.createElement(Oi,{onClick:a,key:"more-blockchains"},Me.createElement(Hl,{variant:"body",size:"xsmall",color:"secondary500"},Ql._("More +{count}",{count:s.more.length}))):null)))}i(ql,"BlockchainsSection");import{useCallback as gx,useRef as hx,useState as Gl}from"react";function Vl(){let t=y().blockchains(),e=hx(null),{customTokens:o}=y(),[n,r]=Gl(!1),[a,s]=Gl([]),[l,c]=Gl(null),p=i(async(h,d)=>{c(null),r(!0),s([]);try{let f=await ot().searchCustomTokens({query:h,blockchain:d},{signal:e.current?.signal}),g=new Set(o().map(S=>Mt(S))),k=new Set(t.map(S=>S.name)),C=f.tokens.filter(S=>k.has(S.blockchain)&&!g.has(Mt(S)));s(C),r(!1)}catch(f){c(f instanceof Error?f.message:"something went wrong"),s([]),f?.name!=="CanceledError"&&r(!1)}},"fetch"),u=gx(Sr((h,d)=>{e.current?.signal.aborted||p(h,d)},600),[t.length]);return{fetch:(h,d)=>{e.current=new AbortController,s([]),r(!0),u(h,d)},cancel:i(()=>{e.current?.abort()},"cancel"),loading:n,tokens:a,error:l}}i(Vl,"useSearchCustomTokens");function Ui(t,e,o){return o&&t.length===1&&t[0].address===e?!1:t.length<20&&e.trim().length>=3}i(Ui,"shouldSearchForCustomTokens");function Dg(t,e,o,n,r){let a=[...t];return Ui(t,o,r)&&(a=n?[...a,"skeleton","skeleton","skeleton"]:[...a,...e.map(s=>({...s,customToken:!0,warning:!0}))]),a}i(Dg,"prepareTokensList");function Qi(t){let{type:e}=t,o=vx(),n=Oe(),{fromBlockchain:r,toBlockchain:a,setFromToken:s,setToToken:l,setFromBlockchain:c,setToBlockchain:p}=O(),{getBalanceFor:u}=y(),{fetch:m,loading:h,tokens:d,cancel:f}=Vl(),[g,k]=Tx(""),C=e==="source"?r:a,S=C?.name??"",T=y().blockchains({type:e}),w=y().tokens({type:e,blockchain:S,searchFor:g,getBalanceFor:u}),E=Dg(w,d,g,h,C?.name),B=i(b=>{e==="source"?c(b):p(b)},"updateBlockchain"),I=i(b=>{e==="source"?s({token:b,meta:{blockchains:T}}):l({token:b,meta:{blockchains:T}})},"updateToken"),x={source:zi.t("Source"),destination:zi.t("Destination")};return kx(()=>(Ui(w,g,C?.name)&&m(g,C?.name??void 0),()=>{f()}),[w.length,g,C?.name]),ro.createElement(oe,{header:{title:zi.t("Swap {type}",{type:x[e]})}},ro.createElement(re,null,ro.createElement(ql,{blockchains:T,type:e=="source"?"from":"to",blockchain:e==="source"?r:a,onMoreClick:()=>o(F.blockchains),onChange:b=>{B(b)}}),ro.createElement($g,{size:24}),ro.createElement(Tt,{value:g,autoFocus:!0,placeholder:zi.t("Search Token"),color:"light",variant:"contained",size:"large",setValue:()=>k(""),onChange:b=>k(b.target.value),suffix:Ui(w,g,C?.name)&&h?ro.createElement(Cx,{size:12,color:"secondary"}):void 0}),ro.createElement($g,{size:16}),ro.createElement(Vn,{list:E,selectedBlockchain:S,searchedFor:g,type:e,onChange:b=>{I(b);let v=T.find(A=>b.blockchain===A.name);v&&B(v),n()}})))}i(Qi,"SelectSwapItemsPage");import{i18n as Xl}from"@lingui/core";import{Alert as jx,Button as Xx,styled as Yx}from"@rango-dev/ui";import Lo from"react";import{useInRouterContext as Zx,useSearchParams as Jx}from"react-router-dom";import{i18n as Hg}from"@lingui/core";import{Divider as qg,InfoIcon as Ex,SlippageIcon as Ix,TextField as Ax,Tooltip as Nx,Typography as Gg}from"@rango-dev/ui";import lt from"react";import{Chip as wx,styled as or,TextField as bx}from"@rango-dev/ui";var Fg=or("div",{paddingTop:"$5",padding:"$10 $5"}),Og=or("div",{display:"flex",flexWrap:"wrap",gap:"$10",[`& ${bx}`]:{flex:"1 1 0",maxWidth:"127px",minWidth:"85px"}}),Ug=or("div",{display:"flex",justifyContent:"start",alignItems:"center",paddingBottom:"$10"}),Hi=or("div",{maxWidth:"280px",padding:"$10"}),zg=or(wx,{width:"61px",flexShrink:0});import{i18n as Kl}from"@lingui/core";import{Typography as xx}from"@rango-dev/ui";import nr from"react";function Qg(){return nr.createElement(Hi,null,nr.createElement(xx,{variant:"label",size:"medium",color:"neutral700"},Kl.t("Your transaction will be reverted if the price changes unfavorably by more than this percentage."),nr.createElement("br",null),nr.createElement("br",null),nr.createElement("b",null,Kl.t("Warning")),":\xA0",Kl.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(Qg,"SlippageTooltipContent");function jl(){let{slippage:t,setSlippage:e,customSlippage:o,setCustomSlippage:n}=y();return lt.createElement(Fg,null,lt.createElement(Ug,null,lt.createElement(Ix,{size:16,color:"gray"}),lt.createElement(qg,{direction:"horizontal",size:4}),lt.createElement(Gg,{variant:"title",size:"xmedium"},Hg.t("Slippage tolerance per swap")),lt.createElement(qg,{direction:"horizontal",size:4}),lt.createElement(Nx,{container:N(),side:"top",sideOffset:4,content:lt.createElement(Qg,null)},lt.createElement(Ex,{color:"gray"}))),lt.createElement(Og,null,dp.map((r,a)=>{let s=`slippage-${a}`;return lt.createElement(zg,{key:s,onClick:()=>{o&&n(null),e(r)},selected:!o&&r===t,label:`${r.toString()}%`})}),lt.createElement(Ax,{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>=yp&&s<=hp?n(s):n(null)},suffix:o&&lt.createElement(Gg,{variant:"body",size:"small"},"%"),placeholder:Hg.t("Custom")})))}i(jl,"Slippage");import{i18n as gt}from"@lingui/core";import{AutoThemeIcon as Vg,BridgesIcon as Bx,ChevronRightIcon as qi,DarkModeIcon as Kg,Divider as rr,ExchangeIcon as Wx,InfinityIcon as Lx,InfoIcon as Mx,LanguageIcon as Px,LightModeIcon as jg,List as _x,ListItem as Dx,ListItemButton as $x,Skeleton as Fx,styled as Ox,Switch as Ux,Tabs as zx,TargetIcon as Qx,Tooltip as Hx,Typography as et}from"@rango-dev/ui";import $ from"react";import{useNavigate as qx}from"react-router-dom";var Gx=Ox("div",{width:"202px",height:"$40"}),Vx=[{id:"light",icon:$.createElement(jg,{color:"black",size:24}),tooltip:$.createElement(et,{size:"xsmall",variant:"body"},gt.t("Light"))},{id:"dark",icon:$.createElement(Kg,{color:"black",size:24}),tooltip:$.createElement(et,{size:"xsmall",variant:"body"},gt.t("Dark"))},{id:"auto",icon:$.createElement(Vg,{color:"black",size:24}),tooltip:$.createElement(et,{size:"xsmall",variant:"body"},gt.t("Auto"))}],Kx=i(t=>{let e={color:"gray",size:16};switch(t){case"auto":return $.createElement(Vg,{...e});case"dark":return $.createElement(Kg,{...e});default:return $.createElement(jg,{...e})}},"getThemeIcon");function Xg(){let t=qx(),{theme:e}=y().config,{setTheme:o,theme:n}=y(),{activeLanguage:r,languages:a}=no(),s=a.find(L=>L.local===r)?.label,l=y().fetchStatus,c=y().swappers(),p=y().getDisabledLiquiditySources(),{config:{features:u}}=y(),m=y().customTokens(),h=Ye("theme",u),d=Ye("liquiditySource",u),f=Ye("language",u),g=Ye("customTokens",u),k=y().infiniteApprove,C=y().toggleInfiniteApprove,S=Ir(c,p),T=S.filter(L=>["BRIDGE","AGGREGATOR","OFF_CHAIN"].includes(L.type)),w=T.length,E=T.filter(L=>L.selected).length,B=S.filter(L=>L.type==="DEX"),I=B.length,x=B.filter(L=>L.selected).length,b=i((L,H)=>{switch(l){case"loading":return $.createElement(Fx,{variant:"text",size:"medium",width:50});case"failed":return $.createElement(et,{variant:"body",size:"medium",color:"$error500"},gt.t("Loading failed"));default:return $.createElement(et,{variant:"body",size:"medium"},`${L} / ${H}`)}},"handleSwapperEndItem"),v={id:"widget-setting-bridge-item-btn",title:$.createElement(et,{variant:"title",size:"xmedium"},gt.t("Bridges")),end:$.createElement($.Fragment,null,b(E,w),$.createElement(rr,{direction:"horizontal",size:8}),$.createElement(qi,{color:"black"})),onClick:()=>t(F.bridges),start:$.createElement(Bx,{color:"gray",size:16})},A={id:"widget-setting-exchange-item-btn",title:$.createElement(et,{variant:"title",size:"xmedium"},gt.t("Exchanges")),end:$.createElement($.Fragment,null,b(x,I),$.createElement(rr,{direction:"horizontal",size:8}),$.createElement(qi,{color:"black"})),start:$.createElement(Wx,{color:"gray",size:16}),onClick:()=>t(F.exchanges)},M={id:"widget-setting-custom-tokens-item-btn",title:$.createElement(et,{variant:"title",size:"xmedium"},gt.t("Custom Tokens")),end:$.createElement($.Fragment,null,$.createElement(et,{variant:"body",size:"medium"},`${m.length}`),$.createElement(rr,{direction:"horizontal",size:8}),$.createElement(qi,{color:"black"})),start:$.createElement(Qx,{color:"gray",size:16}),onClick:()=>t(F.customTokens)},_={id:"widget-setting-language-item-btn",title:$.createElement(et,{variant:"title",size:"xmedium"},gt.t("Language")),start:$.createElement(Px,{color:"gray",size:16}),end:$.createElement($.Fragment,null,$.createElement(et,{variant:"body",size:"medium"},s),$.createElement(rr,{direction:"horizontal",size:8}),$.createElement(qi,{color:"black"})),onClick:()=>t(F.languages)},j={id:"widget-setting-infinite-approval-item-btn",title:$.createElement($.Fragment,null,$.createElement(et,{variant:"title",size:"xmedium"},gt.t("Infinite approval")),$.createElement(rr,{direction:"horizontal",size:4}),$.createElement(Hx,{side:"top",sideOffset:4,container:N(),content:$.createElement(Hi,null,$.createElement(et,{variant:"label",size:"medium",color:"neutral700"},$.createElement("b",null,gt.t("Warning")),":\xA0",gt.t("Enabling the 'Infinite approval' mode grants unrestricted access to underlying smart contracts, allowing them to utilize the approved token amount without limitations.")))},$.createElement(Mx,{color:"gray"}))),start:$.createElement(Lx,{color:"gray",size:16}),end:$.createElement(Ux,{checked:k}),onClick:C},R={id:"widget-setting-theme-item-btn",type:$.createElement(Dx,null),title:$.createElement(et,{variant:"title",size:"xmedium"},gt.t("Theme")),end:$.createElement(Gx,null,$.createElement(zx,{container:N(),items:Vx,value:n,onChange:L=>o(L.id),type:"primary",borderRadius:"small"})),start:Kx(n)},X=d?[]:[v,A];return g||X.push(M),f||X.push(_),X.push(j),!e?.singleTheme&&!h&&X.push(R),$.createElement(_x,{type:$.createElement($x,{hasDivider:!0,id:"_",onClick:()=>console.log()}),items:X})}i(Xg,"SettingsLists");var Rx=Yx("div",{paddingLeft:"$8"});function Yg(){let{isInCampaignMode:t,updateCampaignMode:e}=y(),o=t(),[,n]=Jx(),r=Zx(),a=i(()=>{r&&o&&(n(s=>(s.delete("liquiditySources"),s),{replace:!0}),e("liquiditySources",void 0))},"onClick");return Lo.createElement(oe,{header:{title:Xl.t("Settings")}},Lo.createElement(re,null,o&&Lo.createElement(jx,{type:"info",variant:"alarm",title:Xl.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:Lo.createElement(Rx,null,Lo.createElement(Xx,{id:"widget-setting-exit-campaign-mode-btn",type:"secondary",size:"small",onClick:a},Xl.t("Reset")))}),Lo.createElement(jl,null),Lo.createElement(Xg,null)))}i(Yg,"SettingsPage");import{i18n as zE}from"@lingui/core";import{cancelSwap as QE}from"@rango-dev/queue-manager-rango-preset";import{useManager as HE}from"@rango-dev/queue-manager-react";import{Alert as qE}from"@rango-dev/ui";import mc from"react";import{useParams as GE}from"react-router-dom";import{i18n as ct}from"@lingui/core";import{getCurrentNamespaceOfOrNull as vE,getCurrentStep as wE,getRelatedWalletOrNull as bE}from"@rango-dev/queue-manager-rango-preset";import{Button as Bh,CopyIcon as xE,Divider as EE,DoneIcon as IE,IconButton as AE,QuoteCost as NE,RangoExplorerIcon as BE,StepDetails as WE,Tooltip as Wh,Typography as Mo,useCopyToClipboard as LE}from"@rango-dev/ui";import{useWallets as ME}from"@rango-dev/wallets-react";import Lh from"bignumber.js";import{PendingSwapNetworkStatus as Ji}from"rango-types";import Y,{useEffect as Mh,useRef as PE,useState as Ph}from"react";import{useNavigate as _E}from"react-router-dom";import{i18n as io}from"@lingui/core";var eE=[io.t("Sunday"),io.t("Monday"),io.t("Tuesday"),io.t("Wednesday"),io.t("Thursday"),io.t("Friday"),io.t("Saturday")];function Zg(t){let e=new Date(t),o=e.getDate(),n=e.toLocaleString("default",{month:"long"}),r=e.getFullYear();return`${e.getDay()===new Date().getDay()?io.t("Today"):`${eE[e.getDay()]} ${o} ${n} ${r}`}, ${new Date(t).toLocaleTimeString()}`}i(Zg,"timeSince");function Jg(t){return t.finishTime?Zg(parseInt(t.finishTime)):Zg(parseInt(t.creationTime))}i(Jg,"getSwapDate");import{PendingSwapNetworkStatus as Ki}from"rango-types";import ji from"react";import{i18n as Gi}from"@lingui/core";import{Button as Rg,Divider as Yl,MessageBox as tE}from"@rango-dev/ui";import ao from"react";var eh=i(({onCancel:t,onClose:e})=>ao.createElement(ao.Fragment,null,ao.createElement(Yl,{size:20}),ao.createElement(tE,{type:"error",title:Gi.t("Cancel Swap"),description:Gi.t("Are you sure you want to cancel this swap?")}),ao.createElement(Yl,{size:32}),ao.createElement(Rg,{variant:"contained",id:"widget-swap-details-modal-cancel-swap-yes-btn",type:"primary",size:"large",onClick:t},Gi.t("Yes, Cancel it")),ao.createElement(Yl,{size:12}),ao.createElement(Rg,{id:"widget-swap-details-modal-cancel-swap-no-btn",variant:"outlined",type:"primary",size:"large",onClick:e},Gi.t("No, Continue"))),"CancelContent");import{i18n as Vi}from"@lingui/core";import{Button as th,Divider as Zl,MessageBox as oE,Typography as nE}from"@rango-dev/ui";import qt from"react";var oh=i(({onDelete:t,onClose:e})=>qt.createElement(qt.Fragment,null,qt.createElement(Zl,{size:20}),qt.createElement(oE,{type:"error",title:Vi.t("Delete Transaction"),description:Vi.t("Are you sure you want to delete this swap?")}),qt.createElement(Zl,{size:32}),qt.createElement(th,{id:"widget-swap-details-modal-delete-swap-yes-btn",variant:"contained",type:"primary",size:"large",onClick:t},Vi.t("Yes, Delete it")),qt.createElement(Zl,{size:12}),qt.createElement(th,{id:"widget-swap-details-modal-delete-swap-no-btn",variant:"outlined",type:"primary",size:"large",onClick:e},qt.createElement(nE,{variant:"title",size:"medium",color:"primary"},Vi.t("No, Cancel")))),"DeleteContent");import{i18n as Jl}from"@lingui/core";import{PendingSwapNetworkStatus as Rl}from"rango-types";var ec={[Rl.WaitingForNetworkChange]:{type:"loading",title:Jl.t("Change Network")},[Rl.WaitingForConnectingWallet]:{type:"warning",title:Jl.t("Connect Wallet")},[Rl.NetworkChanged]:{type:"success",title:Jl.t("Network Changed")}};import{warn as rE}from"@rango-dev/logging-core";import{MessageBox as iE,Wallet as aE}from"@rango-dev/ui";import{useWallets as sE}from"@rango-dev/wallets-react";import ln,{useState as lE}from"react";import{styled as tc}from"@rango-dev/ui";var nh=tc("div",{display:"flex",justifyContent:"center"}),VK=tc("div",{maxWidth:280,"& ._typography":{wordWrap:"break-word",display:"block"}}),rh=tc("img",{width:"100%"});var ih=i(t=>{let{type:e,title:o,currentStepWallet:n,message:r,showWalletButton:a,walletButtonDisabled:s}=t,[l,c]=lE(),{getWalletInfo:p,state:u}=sE(),m=n?.walletType,h=m?gn(u(m)):null,d=m?p(m):null,f=a&&!!m&&!!h&&!!d,{list:g}=ht(),k=i(()=>{if(m){let C=g.find(S=>S.type===m);C?c(C):rE(new Error(`It seems requested wallet to be connected is not available in the list. requested wallet: ${C}`))}},"handleWalletItemClick");return ln.createElement(ln.Fragment,null,ln.createElement(iE,{type:e,title:o,description:r}),f&&ln.createElement(nh,null,ln.createElement(aE,{container:N(),title:d.name,image:d.img,type:m,state:h,link:d.installLink,disabled:s,onClick:k})),ln.createElement(So,{wallet:l,onClose:()=>{c(void 0)}}))},"WalletStateContent");function oc(t){let{state:e,onClose:o,onDelete:n,onCancel:r,currentStepWallet:a,message:s,walletButtonDisabled:l}=t,c=e===Ki.WaitingForNetworkChange||e===Ki.WaitingForConnectingWallet||e===Ki.NetworkChanged;return ji.createElement(J,{open:!!e,onClose:o,container:document.getElementById($e.SWAP_BOX_ID)||document.body},c&&ji.createElement(ih,{type:ec[e].type,title:ec[e].title,currentStepWallet:a,message:s,walletButtonDisabled:l,showWalletButton:e!==Ki.WaitingForNetworkChange}),e==="delete"&&ji.createElement(oh,{onClose:o,onDelete:n}),e==="cancel"&&ji.createElement(eh,{onClose:o,onCancel:r}))}i(oc,"SwapDetailsModal");import{i18n as ir}from"@lingui/core";import{Button as nc,Divider as ar,MessageBox as lh,TokenAmount as cE,Typography as ch}from"@rango-dev/ui";import de from"react";import{Link as pE,useNavigate as uE}from"react-router-dom";var ah="https://raw.githubusercontent.com/rango-exchange/assets/main/banners/widget/profile.jpg",sh="/profile";function rc(t){let{open:e,onClose:o,status:n,priceValue:r,usdValue:a,realUsdValue:s,realValue:l,token:c,chain:p,percentageChange:u,description:m,diagnosisUrl:h}=t,d=uE(),{showProfileBanner:f}=ne();return de.createElement(J,{open:e,onClose:o,container:document.getElementById($e.SWAP_BOX_ID)||document.body},n==="success"?de.createElement(lh,{type:"success",title:ir.t("Swap Successful")},de.createElement(cE,{direction:"vertical",tooltipContainer:N(),type:"output",centerAlign:!0,price:{value:r,usdValue:a,realUsdValue:s,realValue:l},token:c,chain:p,percentageChange:u}),de.createElement(ar,{size:12}),de.createElement(ch,{variant:"body",size:"medium",color:"neutral700",align:"center"},m)):de.createElement(lh,{type:"error",title:ir.t("Transaction Failed"),description:m}),de.createElement(ar,{size:30}),n==="success"&&de.createElement(de.Fragment,null,f&&de.createElement(de.Fragment,null,de.createElement(pE,{to:sh},de.createElement(rh,{src:ah,alt:"Profile Banner"})),de.createElement(ar,{size:30})),de.createElement(nc,{id:"widget-swap-details-modal-done-btn",variant:"contained",type:"primary",size:"large",onClick:()=>{d("../../")}},ir.t("Done"))),de.createElement(ar,{size:12}),h&&de.createElement(de.Fragment,null,de.createElement(nc,{variant:"contained",id:"widget-swap-detail-modal-diagnosis-btn",type:"primary",size:"large",onClick:()=>window.open(h,"_blank")},ir.t("Diagnosis")),de.createElement(ar,{size:12})),de.createElement(nc,{id:"widget-swap-details-modal-see-details-btn",variant:"outlined",type:"primary",size:"large",onClick:o},de.createElement(ch,{variant:"title",size:"medium",color:"primary"},ir.t("See Details"))))}i(rc,"SwapDetailsCompleteModal");import TE from"react";import{i18n as yE}from"@lingui/core";import{Alert as Eh,IconButton as SE,LinkIcon as CE}from"@rango-dev/ui";import so,{Fragment as kE}from"react";import{Alert as dE,ChevronDownIcon as fE,IconButton as gE}from"@rango-dev/ui";import pn,{useState as hE}from"react";import{css as sr,darkTheme as ph,styled as Gt,Typography as mE}from"@rango-dev/ui";var uh=Gt("div",{display:"flex",flexDirection:"column",flexGrow:1,overflow:"hidden"}),Xi=Gt("div",{width:"100%","& ._icon-button":{"&:hover":{"& svg":{color:"$secondary550",[`.${ph} &`]:{color:"$secondary500"}}}}}),mh=Gt(An,{padding:"$0 $20 $20 $20"}),M4=Gt("div",{display:"flex",flexDirection:"column",gap:"$10"}),dh=Gt("div",{height:"450px",display:"flex",alignItems:"center",justifyContent:"center"}),P4=Gt("div",{display:"flex",justifyContent:"center",width:"100%",paddingTop:"33%",flex:1}),cn=sr({display:"flex",width:"100%",justifyContent:"space-between",alignItems:"center",padding:"$10 $20",borderBottom:"1px solid",$$color:"$colors$neutral300",[`.${ph} &`]:{$$color:"$colors$neutral400"},borderColor:"$$color",color:"$neutral500"}),fh=sr({padding:"$5 0"}),Yi=sr({display:"flex",justifyContent:"center",alignItems:"center",height:"$24"}),gh=sr({display:"flex",width:"100%",padding:"$15 $20 $20",flexDirection:"column",alignItems:"start"}),hh=sr({width:"100%",padding:"0 $20 $10"}),yh=Gt("a",{fontSize:"$16",fontWeight:"$400",color:"$neutral700",display:"flex",alignItems:"center",justifyContent:"center"}),Sh=Gt("div",{display:"flex",flexDirection:"column",gap:"$5"}),Zi=Gt(mE,{wordBreak:"break-word"});import{styled as ic}from"@rango-dev/ui";var Ch=ic("div",{display:"flex",flexDirection:"column",gap:"$10"}),kh=ic("div",{transition:"transform 0.3s ease-in-out",variants:{rotated:{true:{transform:"rotate(180deg)"}}}}),Th=ic("div",{transition:"max-height 0.3s ease-in-out",maxHeight:"0px",overflow:"hidden",variants:{open:{true:{maxHeight:"200px"}}}});function vh(t){let{message:e}=t,[o,n]=hE(!1);return pn.createElement(dE,{type:"error",title:e.shortMessage,containerStyles:{"& .footer":{paddingTop:"$0"}},action:e.detailedMessage.content&&pn.createElement(gE,{onClick:()=>n(r=>!r),variant:"ghost",size:"xsmall"},pn.createElement(kh,{rotated:o},pn.createElement(fE,{size:12,color:"gray"}))),footer:pn.createElement(Th,{open:o},pn.createElement(Zi,{variant:"body",size:"xsmall",color:"neutral700"},e.detailedMessage.content))})}i(vh,"FailedAlert");import{i18n as wh}from"@lingui/core";import{Alert as ac,Button as bh}from"@rango-dev/ui";import{PendingSwapNetworkStatus as sc}from"rango-types";import lr from"react";function xh(t){let{switchNetwork:e,setNetworkModal:o,message:n,showNetworkModal:r}=t;return e?lr.createElement(ac,{type:"warning",title:n.shortMessage,action:lr.createElement(bh,{id:"widget-swap-details-warning-alert-change-network-btn",size:"xxsmall",type:"warning",onClick:()=>{o(sc.WaitingForNetworkChange),e().catch(a=>{console.log(a)})}},wh.t("Change"))}):r===sc.WaitingForConnectingWallet?lr.createElement(ac,{type:"warning",title:n.shortMessage,action:lr.createElement(bh,{id:"widget-swap-details-warning-alert-connect-wallet-btn",size:"xxsmall",type:"warning",onClick:()=>{o(sc.WaitingForConnectingWallet)}},wh.t("Connect"))}):lr.createElement(ac,{type:"warning",title:n.shortMessage})}i(xh,"WarningAlert");function lc(t){let{switchNetwork:e,showNetworkModal:o,setNetworkModal:n,message:r,step:a,hasAlreadyProceededToSign:s}=t,l=En(a),c=a.status==="waitingForApproval"&&!l,p=a.status==="running"&&!l,u=p&&!s||c&&!a.explorerUrl?.length;return so.createElement(Ch,null,a.explorerUrl?.map((m,h,d)=>{let f=h+m.url,g=h===d.length-1,k=(g&&p||c)&&!u,C=g&&a.status==="failed";return so.createElement(kE,{key:f},so.createElement(Eh,{type:g&&(k&&"loading"||C&&"error")||"success",title:m.description?`${m.description} Tx`:yE.t("View transaction"),action:m.url&&so.createElement(SE,{id:"widget-swap-details-tx-link-icon-btn",variant:"ghost",size:"xsmall",onClick:()=>window.open(m.url,"_blank")},so.createElement(CE,{size:12}))}))}),u&&so.createElement(Eh,{type:"loading",title:r.shortMessage}),a.status!=="failed"&&l&&so.createElement(xh,{switchNetwork:e,showNetworkModal:o,setNetworkModal:n,message:r}),a.status==="failed"&&so.createElement(vh,{message:r}))}i(lc,"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:ut(a.fromBlockchain,e)??"",image:a.fromBlockchainLogo??""},price:{value:P(l,6,6),realValue:l??""}},to:{token:{displayName:a.toSymbol,image:a.toLogo},chain:{displayName:ut(a.toBlockchain,e)??"",image:a.toBlockchainLogo??""},price:{value:P(a.outputAmount||a.expectedOutputAmountHumanReadable,6,6),realValue:a.outputAmount||a.expectedOutputAmountHumanReadable||""}},swapper:{displayName:un(a.swapperId,o)??"",image:a.swapperLogo??"",type:a.swapperType},internalSwaps:a.internalSwaps?a.internalSwaps.map(c=>({from:{chain:{displayName:ut(c.fromBlockchain,e)??"",image:c.fromBlockchainLogo??""}},to:{chain:{displayName:ut(c.toBlockchain,e)??"",image:c.toBlockchainLogo??""}},swapper:{displayName:un(c.swapperId,o)??"",image:c.swapperLogo??"",type:c.swapperType}})):[],alerts:TE.createElement(lc,{step:a,hasAlreadyProceededToSign:r,...n})}})},"getSteps");function Nh(t){if(En(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(Nh,"getStepState");function cc(t){let{swap:e,requestId:o,onDelete:n,onCancel:r}=t,{canSwitchNetworkTo:a,connect:s,getWalletInfo:l}=ME(),c=y().blockchains(),p=y().swappers(),{findToken:u}=y(),m=O.use.retry(),h=ne.use.isActiveTab(),d=_E(),[f,g]=LE(Ih),k=PE(null),[C,S]=Ph(null),[T,w]=Ph(null),E=i(()=>{r(),S(null)},"onCancel"),B=we.use.getNotifications(),I=we.use.removeNotification(),x=B(),b=wE(e),v=b?.networkStatus;Mh(()=>{x.find(De=>De.requestId===e.requestId)&&(e.status==="success"||e.status==="failed"?(w(e.status),I(e.requestId)):T&&w(null))},[e.status,e.requestId]),Mh(()=>{L?S(Ji.WaitingForNetworkChange):v===Ji.WaitingForConnectingWallet||v===Ji.NetworkChanged?S(v):S(null)},[v]);let A=Eu(e),M=b?vE(e,b):null,_=b?bE(e,b):null,j=Jg(e),R=Iu(e),X=i(ke=>!!l(ke)?.mobileWallet,"isMobileWallet"),L=v===Ji.WaitingForNetworkChange&&!!M&&!!_?.walletType&&(X(_.walletType)||a(_.walletType,M.network)),H=L?s.bind(null,_.walletType,[{namespace:M.namespace,network:M.network}]):void 0,ae=xu(e,b),G=Ah({swap:e,switchNetwork:H,showNetworkModal:v,setNetworkModal:S,message:ae,blockchains:c,swappers:p}),fe=G.length,[Ie,je]=[e.steps[0],e.steps[fe-1]],se=je.outputAmount||je.expectedOutputAmountHumanReadable,pt=e.steps.reduce((ke,De)=>ke+parseFloat(De.feeInUsd||""),0),V=e.steps.find(ke=>ke.diagnosisUrl)?.diagnosisUrl,D=P(parseFloat(se||"0")*(je.toUsdPrice||0),4,4),q=P(parseFloat(e.inputAmount)*(Ie.fromUsdPrice||0),4,4),K=se?new Lh(se).multipliedBy(je.toUsdPrice||0).toString():"",ge=new Lh(e.inputAmount).multipliedBy(Ie.fromUsdPrice||0).toString(),ce=Pt(q,D),_e=ae.detailedMessage.content||ae.shortMessage,Xe=e.status==="success"?ct.t({id:"You have received {amount} {token} in {conciseAddress} wallet on {chain} chain.",values:{amount:P(se,6,6),token:G[fe-1].to.token.displayName,conciseAddress:xr(e.wallets[G[fe-1].to.chain.displayName]?.address||""),chain:G[fe-1].to.chain.displayName}}):Y.createElement(Sh,null,Y.createElement(Mo,{variant:"body",size:"medium",color:"neutral700",align:"center"},_e?"":ct.t("Transaction was not sent."),A?`${ct.t({id:"{amount} {symbol} on {blockchain} remains in your wallet.",values:{amount:A.outputAmount,symbol:A.symbol,blockchain:A.blockchain}})}`:""),_e&&Y.createElement(Zi,{align:"center",variant:"body",size:"medium",color:"neutral700"},Y.createElement("b",null,"Reason:")," ",_e));return Y.createElement(oe,{header:{title:ct.t("Swap Details"),onCancel:e.status==="running"?()=>S("cancel"):void 0,suffix:e.status!=="running"&&Y.createElement(jt,null,Y.createElement(Bh,{id:"widget-swap-details-delete-btn",variant:"ghost",type:"error",size:"xsmall",onClick:()=>S("delete")},Y.createElement(Mo,{size:"medium",variant:"label",color:"error"},ct.t("Delete"))))},footer:R&&!T&&Y.createElement(Bh,{fullWidth:!0,id:"widget-swap-details-try-again-btn",variant:"contained",type:"primary",size:"large",onClick:()=>{let ke=Fr(e,c,u);m(ke),setTimeout(()=>{d("../../")},0)}},ct.t("Try again"))},Y.createElement(re,{compact:!0,view:!0},Y.createElement(Xi,null,Y.createElement("div",{className:cn()},Y.createElement(Mo,{variant:"label",size:"large",color:"neutral700"},`${ct.t("Request ID")}`),Y.createElement("div",{className:Yi()},Y.createElement(Mo,{variant:"label",size:"small",color:"neutral700"},o),Y.createElement(Wh,{container:N(),content:f?ct.t("Copied To Clipboard"):ct.t("Copy Request ID"),open:f||void 0,side:"bottom",alignOffset:-16,align:"end"},Y.createElement(AE,{id:"widget-swap-details-done-copy-icon-btn",variant:"ghost",onClick:g.bind(null,o||"")},f?Y.createElement(IE,{size:16,color:"secondary"}):Y.createElement(xE,{size:16,color:"gray"}))),Y.createElement(yh,{target:"_blank",href:`${_c}/swap/${o}`},Y.createElement(Wh,{container:N(),content:ct.t("View on Rango Explorer"),side:"bottom"},Y.createElement(BE,{size:20}))))),Y.createElement("div",{className:cn()},Y.createElement(Mo,{variant:"label",size:"large",color:"neutral700"},e.finishTime?ct.t("Finished at"):ct.t("Created at")),Y.createElement(Mo,{variant:"label",size:"small",color:"neutral700"},j))),Y.createElement("div",{className:gh()},Y.createElement(NE,{fee:P(String(pt),2,2),time:dn(kr(e.steps)),steps:fe}),Y.createElement(_n,{from:{price:{value:P(e.inputAmount,6,6),usdValue:q,realUsdValue:ge,realValue:e.inputAmount},token:{displayName:G[0].from.token.displayName,image:G[0].from.token.image},chain:{image:G[0].from.chain.image,displayName:G[0].from.chain.displayName}},to:{price:{value:P(se,6,6),usdValue:D,realUsdValue:K,realValue:se||""},token:{displayName:G[fe-1].to.token.displayName,image:G[fe-1].to.token.image},chain:{image:G[fe-1].to.chain.image,displayName:G[fe-1].to.chain.displayName}},percentageChange:P(ce,2,2),warningLevel:_t(ce??0)})),Y.createElement("div",{className:hh()},Y.createElement(Mo,{variant:"title",size:"small"},ct.t("Swaps steps"))),Y.createElement(EE,{size:8}),Y.createElement(mh,{ref:k},G.map((ke,De)=>{let Vt=De,lo=Nh(e.steps[De]),ly=lo==="error"||lo==="in-progress"||lo==="warning"||lo==="completed"&&De===G.length-1;return Y.createElement(WE,{key:Vt,step:ke,type:"swap-progress",ref:k,state:lo,hasSeparator:De!==0,tabIndex:Vt,isFocused:ly,tooltipContainer:N()})}))),Y.createElement(oc,{state:C,onClose:()=>S(null),onCancel:E,onDelete:n,message:ae.detailedMessage.content,currentStepWallet:_,walletButtonDisabled:!h}),Y.createElement(rc,{open:!!T,diagnosisUrl:V,onClose:()=>w(null),status:e.status==="success"?"success":"failed",priceValue:P(se,6,6),usdValue:D,realUsdValue:K,realValue:se||"",percentageChange:P(ce,2,2),token:{displayName:G[fe-1].to.token.displayName,image:G[fe-1].to.token.image},chain:{image:G[fe-1].to.chain.image},description:Xe}))}i(cc,"SwapDetails");import{i18n as ea}from"@lingui/core";import{Divider as $h,NotFound as UE,Skeleton as pr,Typography as ta}from"@rango-dev/ui";import Ce from"react";import{i18n as DE}from"@lingui/core";import{Divider as $E,Skeleton as FE,Typography as OE}from"@rango-dev/ui";import Te from"react";import{css as wt,styled as pc}from"@rango-dev/ui";var _h=pc("div",{width:"100%",height:"100%",padding:"$10 $20"}),cr=pc("div",{backgroundColor:"$neutral100",borderRadius:"$xm",padding:"$10 $15"}),Ri=pc("div",{width:"0px",height:"$20",borderLeft:"1px dashed $neutral700",marginLeft:"25px"}),V8=wt({display:"flex",justifyContent:"space-between",alignItems:"center"}),K8=wt({display:"flex",justifyContent:"space-between",alignItems:"center"}),j8=wt({paddingTop:"$15",display:"flex"}),X8=wt({padding:"$15 $0"}),Y8=wt({width:"0px",height:"$16",borderLeft:"1px solid $neutral400",marginLeft:"13px"}),Z8=wt({paddingBottom:"$10"}),J8=wt({display:"flex",justifyContent:"start",alignItems:"center"}),R8=wt({paddingTop:"$5",display:"flex",alignItems:"center"}),e6=wt({display:"flex",alignItems:"center"}),t6=wt({padding:"$4 $6",display:"flex",justifyContent:"center",alignItems:"center"}),Dh=wt({display:"flex",paddingTop:"$10",paddingBottom:"$5"});function uc(){return Te.createElement(_h,null,Te.createElement(Fn,{type:"swap-preview"}),Te.createElement("div",{className:"swaps-steps"},Te.createElement(OE,{variant:"title",size:"small"},DE.t("Swaps steps"))),Te.createElement(Te.Fragment,null,Te.createElement(cr,null,Te.createElement(At,{separator:!1}),Te.createElement("div",{className:Dh()},Te.createElement($E,{direction:"horizontal",size:20}),Te.createElement(FE,{height:22,variant:"rectangular"}))),Te.createElement(Ri,null),Te.createElement(cr,null,Te.createElement(At,{separator:!1})),Te.createElement(Ri,null),Te.createElement(cr,null,Te.createElement(At,{separator:!1})),Te.createElement(Ri,null),Te.createElement(cr,null,Te.createElement(At,{separator:!1}))))}i(uc,"LoadingSwapDetails");function Fh(t){let{requestId:e,showSkeleton:o}=t;return Ce.createElement(oe,{header:{title:ea.t("Swap Details"),suffix:Ce.createElement(jt,null)}},o&&Ce.createElement(uh,null,Ce.createElement(Xi,null,Ce.createElement("div",{className:cn()},Ce.createElement(ta,{variant:"label",size:"large",color:"neutral700"},`${ea.t("Request ID")}`),Ce.createElement("div",{className:Yi()},Ce.createElement(ta,{variant:"label",size:"small",color:"neutral700"},Ce.createElement(pr,{width:60,height:10,variant:"rounded"})),Ce.createElement($h,{direction:"horizontal",size:4}),Ce.createElement(pr,{width:16,height:16,variant:"rectangular"}),Ce.createElement($h,{direction:"horizontal",size:4}),Ce.createElement(pr,{width:16,height:16,variant:"rectangular"}))),Ce.createElement("div",{className:cn()},Ce.createElement(ta,{className:fh(),variant:"label",size:"large",color:"neutral700"},Ce.createElement(pr,{width:60,height:10,variant:"rounded"})),Ce.createElement(ta,{variant:"label",size:"small",color:"neutral700"},Ce.createElement(pr,{width:60,height:10,variant:"rounded"})))),Ce.createElement(uc,null)),!o&&Ce.createElement(dh,null,Ce.createElement(UE,{title:ea.t("Not found"),description:ea.t({id:"Swap with request ID = {requestId} not found.",values:{requestId:e}})})))}i(Fh,"SwapDetailsPlaceholder");function Oh(){let{manager:t,state:e}=HE(),o=!e.loadedFromPersistor,n=ft(t),{requestId:r}=GE(),a=Oe(),{fetchStatus:s}=y();if(!r)return mc.createElement(qE,{containerStyles:{margin:"20px"},type:"error",title:zE.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&&QE(h)}},"onCancel"),u=i(async()=>{if(c?.id)try{t?.deleteQueue(c.id),a()}catch(h){console.log(h)}},"onDelete"),m=c?.swap;return!m||l?mc.createElement(Fh,{requestId:r,showSkeleton:l}):mc.createElement(cc,{swap:m,requestId:r,onCancel:p,onDelete:u})}i(Oh,"SwapDetailsPage");import{i18n as Uh}from"@lingui/core";import{Divider as VE,getCategoriesCount as KE,SelectableCategoryList as jE,styled as Qh,Typography as XE,Wallet as YE}from"@rango-dev/ui";import Bt,{useState as zh}from"react";var ZE=Qh("div",{display:"flex",justifyContent:"center",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5"}),JE=Qh(re,{textAlign:"center"});function Hh(){let{fetchStatus:t}=y(),[e,o]=zh("ALL"),n=y().blockchains(),{config:r}=y(),[a,s]=zh(),l=ne.use.isActiveTab(),{list:c}=ht(),p=op(c,n),m=KE(p)!==1,h=np(c,e),d=i(f=>{Gc(c,r.multiWallets)||s(f)},"handleWalletItemClick");return Bt.createElement(oe,{header:{title:Uh.t("Connect Wallets")}},Bt.createElement(JE,null,m&&Bt.createElement(Bt.Fragment,null,Bt.createElement(jE,{setCategory:o,category:e,blockchains:p,isLoading:t==="loading"}),Bt.createElement(VE,{size:24})),Bt.createElement(XE,{variant:"title",size:"xmedium",align:"center"},Uh.t("Choose a wallet to connect.")),Bt.createElement(ZE,null,h.map((f,g)=>{let k=`wallet-${g}-${f.type}`;return Bt.createElement(YE,{key:k,...f,container:N(),onClick:()=>d(f),isLoading:t==="loading",disabled:!l})}),Bt.createElement(So,{wallet:a,onClose:()=>{s(void 0)}}))))}i(Hh,"WalletsPage");function qh(){return Wu(),Xa(),RE([{path:F.home,element:Pe.createElement(hg,null)},{path:F.routes,element:Pe.createElement(Tg,null)},{path:F.fromSwap,children:[{index:!0,element:Pe.createElement(Qi,{type:"source"})},{path:F.blockchains,element:Pe.createElement(Fi,{type:"source"})}]},{path:F.toSwap,children:[{index:!0,element:Pe.createElement(Qi,{type:"destination"})},{path:F.blockchains,element:Pe.createElement(Fi,{type:"destination"})}]},{path:F.settings,children:[{index:!0,element:Pe.createElement(Yg,null)},{path:F.languages,element:Pe.createElement(Sg,null)},{path:F.exchanges,element:Pe.createElement($l,{sourceType:"Exchanges"})},{path:F.bridges,element:Pe.createElement($l,{sourceType:"Bridges"})},{path:F.customTokens,children:[{index:!0,element:Pe.createElement(Ef,null)},{path:F.addCustomTokens,children:[{index:!0,element:Pe.createElement(hm,null)},{path:F.blockchains,element:Pe.createElement(Fi,{hideCategory:!0,type:"custom-token"})}]}]}]},{path:F.swaps,children:[{index:!0,element:Pe.createElement(Vf,null)},{path:F.swapDetails,element:Pe.createElement(Oh,null)}]},{path:F.wallets,element:Pe.createElement(Hh,null)},{path:F.confirmSwap,element:Pe.createElement(mf,null)}])}i(qh,"AppRoutes");import{useQueueManager as lI}from"@rango-dev/queue-manager-rango-preset";import{splitWalletNetwork as cI}from"@rango-dev/wallets-shared";import{isEvmBlockchain as pI}from"rango-sdk";import{useContext as uI,useEffect as Zh,useState as Jh}from"react";import{globalCss as eI}from"@rango-dev/ui";var Gh=i(()=>eI({"@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 Vh(){let{setWatermark:t,setShowProfileBanner:e}=ne();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(Vh,"useFetchApiConfig");import{useWallets as tI}from"@rango-dev/wallets-react";import{useEffect as oI,useRef as nI}from"react";function Kh(){let{connect:t,state:e}=tI(),o=nI({}),{fetchStatus:n}=y(),r=new URLSearchParams(location.search).get("autoConnect")||"",a=e(r);oI(()=>{n==="success"&&r&&a.installed&&!a.connecting&&!a.connected&&!o.current[r]&&(o.current[r]=!0,t(r))},[a,n])}i(Kh,"useForceAutoConnect");import{isApprovalTX as rI,RouteEventType as jh,StepEventType as Xh,StepExecutionEventStatus as iI,WidgetEvents as oa}from"@rango-dev/queue-manager-rango-preset";import{useEffect as Yh}from"react";function dc(){let t=we.use.setNotification(),{connectedWallets:e,fetchBalances:o}=y();Yh(()=>{let n=i(r=>{let{event:a,step:s,route:l}=r;if(a.type===Xh.TX_EXECUTION&&a.status===iI.TX_SENT&&!rI(s)||a.type===Xh.SUCCEEDED){let p=l.wallets[s?.fromBlockchain];if(p){let u=e.find(m=>m.address?.toLocaleLowerCase()===p.address?.toLocaleLowerCase()&&m.walletType===p.walletType&&m.chain===s?.fromBlockchain);u&&o([u])}if(s?.fromBlockchain!==s?.toBlockchain){let u=l.wallets[s?.toBlockchain];if(u){let m=e.find(h=>h.address?.toLocaleLowerCase()===u.address?.toLocaleLowerCase()&&h.walletType===u.walletType&&h.chain===s?.toBlockchain);m&&o([m])}}}t(a,l)},"handleStepEvent");return he.on(oa.StepEvent,n),()=>he.off(oa.StepEvent,n)},[he,e]),Yh(()=>{let n=i(r=>{let{event:a,route:s}=r;(a.type===jh.FAILED||a.type===jh.SUCCEEDED)&&t(a,s)},"handleRouteEvent");return he.on(oa.RouteEvent,n),()=>he.off(oa.RouteEvent,n)},[he])}i(dc,"useSubscribeToWidgetEvents");import{useManager as aI}from"@rango-dev/queue-manager-react";import{useEffect as sI}from"react";function fc(){let{isSynced:t,syncNotifications:e}=we(),{manager:o,state:n}=aI();sI(()=>{we.persist.hasHydrated()&&n.loadedFromPersistor&&!t&&e(ft(o))},[we.persist.hasHydrated(),n.loadedFromPersistor,t])}i(fc,"useSyncNotifications");function gc(){Kh(),Gh(),dc(),fc();let t=y().blockchains(),{canSwitchNetworkTo:e}=ii(),[o,n]=Jh(""),[r,a]=Jh(),s=uI(Pr),l=t.filter(pI),{fetchApiConfig:c}=Vh();Zh(()=>()=>Bu(),[]),lI({lastConnectedWallet:o,clearDisconnectedWallet:()=>{a(void 0)},disconnectedWallet:r,evmChains:l,canSwitchNetworkTo:e}),Zh(()=>(fo.init(),we.persist.hasHydrated()||we.persist.rehydrate(),s.onConnectWallet(n),s.onDisconnectWallet(p=>{a(p),p===cI(o)?.[0]&&n("")}),c().catch(console.log),fo.destroy),[])}i(gc,"useBootstrap");import{styled as mI}from"@rango-dev/ui";var Rh=mI("div",{fontFamily:"$widget",boxSizing:"border-box",textAlign:"left","& *, *::before, *::after":{boxSizing:"inherit"},"& *:focus-visible":{outlineColor:"$info500",transition:"none"},"& ul, ol, li":{listStyleType:"none"}});function na(){gc();let{config:t}=y(),{activeTheme:e}=Yo(t?.theme||{}),{activeLanguage:o}=no();return hc.createElement(dI,{language:o},hc.createElement(Rh,{id:"swap-container",className:e()},hc.createElement(qh,null)))}i(na,"Main");import{setSolanaSignerConfig as MI}from"@rango-dev/signer-solana";import Sc,{useEffect as iy,useMemo as PI}from"react";import{useState as fI}from"react";var gI=i(()=>{let[t,e]=fI(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=qc(a);if(s){let l=o(s);e(l)}},"handleLoadCustomFont")}},"useFontLoader"),ey=gI;import{checkWaitingForNetworkChange as hI,makeQueueDefinition as yI}from"@rango-dev/queue-manager-rango-preset";import{Provider as SI}from"@rango-dev/queue-manager-react";import{useWallets as CI}from"@rango-dev/wallets-react";import{convertEvmBlockchainMetaToEvmChainInfo as kI}from"@rango-dev/wallets-shared";import{isEvmBlockchain as TI}from"rango-types";import vI,{useMemo as wI}from"react";function bI(t){let{providers:e,getSigners:o,state:n,connect:r,canSwitchNetworkTo:a,getWalletInfo:s}=CI(),l=wI(()=>yI({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(),m={blockchains:p.map(w=>({accounts:[w],name:w.chain}))},h=i(async(w,E)=>a(w,E.network)?await r(w,[E]):void 0,"switchNetwork"),d=i(w=>!!s(w).mobileWallet,"isMobileWallet"),f=u.filter(w=>w.enabled).reduce((w,E)=>(w[E.name]=E,w),{}),g=u.filter(TI),k=i(w=>{let{supportedChains:E}=s(w);return hn(E)},"getSupportedChainNames"),C=e(),S={meta:{blockchains:f,evmBasedChains:g,evmNetworkChainInfo:kI(g),getSupportedChainNames:k},getSigners:o,wallets:m,providers:C,switchNetwork:h,canSwitchNetworkTo:a,state:n,isMobileWallet:d},T=ne.use.isActiveTab();return vI.createElement(SI,{queuesDefs:[l],context:S,onPersistedDataLoaded:w=>{hI(w)},isPaused:!T},t.children)}i(bI,"QueueManager");var ty=bI;import{useManager as NI}from"@rango-dev/queue-manager-react";import BI,{createContext as WI,useContext as LI}from"react";function oy(){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:m,toBlockchain:h,toToken:d,requestAmount:f}=p,g={blockchains:e,tokens:o};if(u!==void 0){let k=e.find(C=>C.name===u)??null;n(k)}if(m!==void 0){let k=m?t(m)??null:null;r({meta:g,token:k})}if(h!==void 0){let k=e.find(C=>C.name===h)??null;a(k)}if(d!==void 0){let k=d?t(d)??null:null;s({meta:g,token:k})}f!==void 0&&l(f)},"updateQuoteInputs")}i(oy,"useUpdateQuoteInputs");import{cancelSwap as xI,getCurrentNamespaceOfOrNull as EI,getCurrentStep as II,getRelatedWalletOrNull as AI}from"@rango-dev/queue-manager-rango-preset";var ra=class{static{i(this,"WidgetHistory")}constructor(e,o){this.manager=e,this.actions=o}getAllSwaps(){return ft(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=Fr(e,o.blockchains,this.actions.findToken);return this.actions.retrySwap(n)}cancel(e){let o=this.manager?.get(e);o&&xI(o)}getCurrentStepInfo(e){let o=II(e);return{step:o,wallet:o?AI(e,o):null,network:o?EI(e,o)?.network:null}}};var ny=WI(void 0);function yc(t){let{manager:e}=NI(),o=ne.use.isActiveTab(),n=O.use.retry(),{findToken:r,getBalances:a,getConnectedWalletsDetails:s,fetchBalances:l}=y(),c=new ra(e,{retrySwap:n,findToken:r}),{fetchingWallets:p}=y(),u=Yc(a()),m=y().blockchains(),h=y().tokens(),d=y().swappers(),f=y().fetchStatus,g=no().resetLanguage,k=we().getNotifications(),C=we().clearNotifications,S=oy(),{fromBlockchain:T,toBlockchain:w,fromToken:E,toToken:B,inputAmount:I}=O(),x={isActiveTab:o,setCurrentTabAsActive:fo.forceClaim,history:c,wallets:{isLoading:p,details:s(),totalBalance:u,refetch:async b=>l(b)},meta:{blockchains:m,tokens:h,swappers:d,loadingStatus:f,findToken:r},resetLanguage:g,notifications:{list:k,clearAll:C},quote:{quoteInputs:{fromBlockchain:T?.name??null,fromToken:E?{symbol:E.symbol,blockchain:E.blockchain,address:E.address}:null,toBlockchain:w?.name??null,toToken:B?{symbol:B.symbol,blockchain:B.blockchain,address:B.address}:null,requestAmount:I},updateQuoteInputs:S}};return BI.createElement(ny.Provider,{value:x},t.children)}i(yc,"WidgetInfo");function ry(){let t=LI(ny);if(!t)throw new Error("useWidget can only be used within the WidgetProvider component");return t}i(ry,"useWidget");function ia(t){let{onUpdateState:e,config:o}=t,n=t.config?.theme?.fontFamily,{handleLoadCustomFont:r}=ey();return iy(()=>{n&&r(n)},[n]),PI(()=>{rp({API_KEY:o?.apiKey||hr,BASE_URL:o?.apiUrl||Pc})},[o.apiKey,o.apiUrl]),iy(()=>{t.config?.signers?.customSolanaRPC&&MI("customRPC",t.config.signers.customSolanaRPC)},[t.config?.signers?.customSolanaRPC]),Sc.createElement(_r,{config:o,onUpdateState:e},Sc.createElement(ty,{apiKey:o.apiKey},Sc.createElement(yc,null,t.children)))}i(ia,"WidgetProvider");function ay(t){let e=t.config?.externalWallets;return aa.createElement(Jp,null,e?aa.createElement(na,null):aa.createElement(ia,{config:t.config??fr},aa.createElement(na,null)))}i(ay,"Widget");function sy(){let{on:t,off:e}=he;return{on:t,off:e}}i(sy,"useWidgetEvents");var lY={DerivationPath:vn,Namespaces:Tn,isOnDerivationPath:bn,isOnNamespace:wn};export{PX as EventSeverity,Uo as MainEvents,qX as Networks,KX as PendingSwapNetworkStatus,Ta as QuoteEventTypes,_X as RouteEventType,pa as SUPPORTED_FONTS,lY as StatefulConnect,DX as StepEventType,$X as StepExecutionBlockedEventStatus,FX as StepExecutionEventStatus,$e as UI_ID,wa as UiEventTypes,va as WalletEventTypes,QX as WalletEvents,GX as WalletTypes,ay as Widget,Uo as WidgetEvents,ia as WidgetProvider,_r as WidgetWallets,ls as customizedThemeTokens,UX as readAccountAddress,Kt as useStatefulConnect,ht as useWalletList,ii as useWallets,ry as useWidget,sy as useWidgetEvents,uS as widgetEventEmitter};
1
+ var cy=Object.defineProperty;var i=(t,e)=>cy(t,"name",{value:e,configurable:!0});import{EventSeverity as PX,RouteEventType as _X,StepEventType as DX,StepExecutionBlockedEventStatus as $X,StepExecutionEventStatus as FX}from"@rango-dev/queue-manager-rango-preset";import{legacyReadAccountAddress as UX}from"@rango-dev/wallets-core/legacy";import{useWallets as ii,Events as QX}from"@rango-dev/wallets-react";import{Networks as qX,WalletTypes as GX}from"@rango-dev/wallets-shared";import{PendingSwapNetworkStatus as KX}from"rango-types";import{Divider as rC}from"@rango-dev/ui";import yo,{useEffect as iC,useRef as aC,useState as Gp}from"react";import{WalletState as py}from"@rango-dev/ui";import{useWallets as uy}from"@rango-dev/wallets-react";import{useReducer as my}from"react";function Cc(t){return!!t.derivationPath}i(Cc,"isStateOnDerivationPathStep");function kc(t){return!!t.namespace}i(kc,"isStateOnNamespace");var ur={status:"init",namespace:null,derivationPath:null};function Tc(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 ur;case"resetDerivation":return t.namespace?{...t,derivationPath:null,status:"namespace"}:ur;default:throw new Error("Action hasn't been defined.")}}i(Tc,"reducer");function Kt(){let{state:t,disconnect:e,connect:o}=uy(),[n,r]=my(Tc,ur),a=i(async(u,m,h)=>{r({type:"reset"});try{let d=m?.map(f=>({...f,network:void 0}));return await o(u,d),{status:"connected"}}catch(d){let f=d?.message?`Error: ${d.message}`:"An unknown error happened during connecting wallet.";throw new Error(f,{cause:d})}},"runConnect"),s=i(async(u,m)=>{if(u.state===py.DISCONNECTED){if(!!u.isHub&&u.properties?.find(S=>S.name==="detached")&&u.state!=="connected")return r({type:"needsNamespace",payload:{targetWallet:u}}),{status:"namespace"};if(!u.needsNamespace)return await a(u.type,void 0,m);let f=u.needsNamespace.data.length>1,g=u.needsDerivationPath;if(f)return r({type:"needsNamespace",payload:{targetWallet:u}}),{status:"namespace"};if(g){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})),m)}return m?.disconnectIfConnected?(await p(u.type),{status:"disconnected"}):{status:"disconnected-unhandled"}},"handleConnect"),l=i(async(u,m)=>{let h=u.needsNamespace?.selection==="single",d=u.needsDerivationPath,f=m[0];if(!f)throw new Error("To confirm a namespace, you should select at least one namespace.");if(h&&d)return r({type:"needsDerivationPath",payload:{providerType:u.type,providerImage:u.image,namespace:f}}),{status:"derivation-path"};if(!kc(n))throw new Error("Something went wrong on handling namespace. Please retry.");let g=n.namespace.targetWallet.type,C=m.map(k=>({namespace:k}));return await a(g,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(!Cc(n))throw new Error("It seems you are filling derivation path without setting namespace before doing that. Please retry to connect.");let m=n.derivationPath.providerType,d=[{namespace:n.derivationPath.namespace,derivationPath:u}];return await a(m,d)},"handleDerivationPath"),p=i(async u=>{let m=t(u);return m.connected||m.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(Kt,"useStatefulConnect");import{WalletState as Na}from"@rango-dev/ui";import{useWallets as vS}from"@rango-dev/wallets-react";import{detectMobileScreens as wS,KEPLR_COMPATIBLE_WALLETS as bS,WalletTypes as Cn}from"@rango-dev/wallets-shared";import{useCallback as xS,useEffect as ES}from"react";import yS,{createContext as SS,useContext as CS,useEffect as kS,useRef as TS}from"react";import{create as gS}from"zustand";import{persist as hS}from"zustand/middleware";import{allProviders as dy}from"@rango-dev/provider-all";var sa=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()}},Po=new sa;import{defineVersions as wc,pickVersion as bc,Provider as la}from"@rango-dev/wallets-core";function xc({allProviders:t,configWallets:e}){if(e){let o=[];return e.forEach(n=>{if(typeof n=="string"){let r=t.find(a=>{let s=Ec(a);return s instanceof la?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 la?o.push(wc().version("1.0.0",n).build()):o.push(wc().version("0.0.0",n).build())}),o}return t}i(xc,"matchAndGenerateProviders");function Ec(t){try{return bc(t,"1.0.0")[1]}catch{return bc(t,"0.0.0")[1]}}i(Ec,"pickProviderVersionWithFallbackToLegacy");function Ic(t){return t.map(o=>Ec(o)).map(o=>o instanceof la?o.id:o.config.type)}i(Ic,"configWalletsToWalletName");function mr(t,e){return e.find(o=>o.name===t)?.displayName}i(mr,"getBlockchainDisplayNameFor");function ut(t,e){return e.find(o=>o.name===t)?.shortName}i(ut,"getBlockchainShortNameFor");function Ac(t,e){return e.find(o=>o.name===t)?.logo}i(Ac,"getBlockchainImage");function un(t,e){return e.find(o=>o.id===t)?.title}i(un,"getSwapperDisplayName");function co(t,e){return e.find(o=>o.name===t)??null}i(co,"findBlockchain");function ca(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(ca,"isTokenNative");function mt(t){return`${t.blockchain.toLowerCase()}-${t.symbol.toLowerCase()}-${(t.address??"").toLowerCase()}`}i(mt,"createTokenHash");function _o(t,e){return t.addressPatterns.filter(r=>new RegExp(r).test(e)).length>0}i(_o,"isValidTokenAddress");function mn(t){let{config:e,meta:o}=t,n={},r=e.tokens,a=i(l=>{l.forEach(c=>{typeof c!="string"&&(c=mt(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=mt(p);delete n[u]})):a(c.tokens))}),Object.values(n)}i(mn,"matchTokensFromConfigWithMeta");function dr(t){let{config:e}=t,o=e.from?.blockchains||[],n=e.to?.blockchains||[];if(!o.length||!n.length)return[];let r=[...o,...n],a=new Set(r);return Array.from(a)}i(dr,"getSupportedBlockchainsFromConfig");function Bc(t){return{walletConnectProjectId:t?.walletConnectProjectId,trezorManifest:t?.trezorManifest,tonConnect:t?.tonConnect,walletConnectListedDesktopWalletLink:t.__UNSTABLE_OR_INTERNAL__?.walletConnectListedDesktopWalletLink}}i(Bc,"makeProvidersOptionsFromConfig");var fr={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"}},fy={clientUrl:void 0},gy={liquiditySources:void 0};function Nc(t){let e=Bc(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 dy(o).map(a=>a())}i(Nc,"generateProviders");var Wc=i((t,e,o)=>{let n=Nc({...fr,...t});return{config:{...fr,...t},iframe:fy,campaignMode:gy,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=mn({type:"source",config:{blockchains:r.from?.blockchains,tokens:r.from?.tokens},meta:{tokensMapByBlockchainName:l,tokensMapByTokenHash:s}}),p=mn({type:"destination",config:{blockchains:r.to?.blockchains,tokens:r.to?.tokens},meta:{tokensMapByBlockchainName:l,tokensMapByTokenHash:s}});Po.set("supportedSourceTokens",c),Po.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=Nc(r);e({allProviders:a})},getAvailableProviders:()=>{let{allProviders:r,config:a}=o(),s=Bc(a);return xc({allProviders:r,configWallets:a.wallets,options:s})}}},"createConfigSlice");import{TransactionType as Lc}from"rango-types";var Mc=[Lc.EVM,Lc.SOLANA],gr="https://raw.githubusercontent.com/rango-exchange/assets/refs/heads/main/common/unknown-image.png";import{RangoClient as By}from"rango-sdk";import{UI_ID as hy}from"@rango-dev/ui";var hr="c6381a79-2817-4602-83bf-6a641a409e32",Pc="https://api.rango.exchange",_c="https://explorer.rango.exchange",$e={SWAP_BOX_ID:"rango-swap-box",EXPANDED_BOX_ID:"rango-expanded-box",...hy};import{BlockchainCategories as wy,WalletState as xt}from"@rango-dev/ui";import{legacyReadAccountAddress as by}from"@rango-dev/wallets-core/legacy";import{detectInstallLink as xy,getCosmosExperimentalChainInfo as Ey,isEvmAddress as Iy,KEPLR_COMPATIBLE_WALLETS as UA,Networks as jc}from"@rango-dev/wallets-shared";import $o from"bignumber.js";import{isCosmosBlockchain as Ay}from"rango-types";import yy from"bignumber.js";var le=new yy(0);import{WalletTypes as Sy}from"@rango-dev/wallets-shared";var po="~",Dc=[Sy.LEAP];import{BlockchainCategories as ua,WalletState as vy}from"@rango-dev/ui";import{TransactionType as yr}from"rango-sdk";var $c="Roboto",pa=[{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 Do(t){return Array.from(new Set(t))}i(Do,"removeDuplicateFrom");function Sr(t,e){let o;return n;function n(...r){o&&clearTimeout(o),o=setTimeout(()=>{o=null,t(...r)},e)}}i(Sr,"debounce");function tt(t,e){return t.toLowerCase().indexOf(e.toLowerCase())>-1}i(tt,"containsText");function Uc(t,e){return t.toLowerCase()===e.toLowerCase()}i(Uc,"exactText");function zc(t,e){return t.toLowerCase().startsWith(e.toLowerCase())}i(zc,"startWithText");var N=i(()=>document.getElementById($e.SWAP_BOX_ID),"getContainer"),uo=i(()=>document.getElementById($e.EXPANDED_BOX_ID),"getExpanded");function Qc(t,e,o){let n=!!e&&Uc(e,t),r=!!o&&Uc(o,t);return n!==r?n?-1:1:0}i(Qc,"compareExactMatchText");function ma(t,e,o){let n=!!e&&tt(e,t),r=!!o&&tt(o,t);return n!==r?n?-1:1:n&&r&&e?.length!==o?.length?e?.length-o?.length:0}i(ma,"compareContainsText");function da(t,e,o){let n=!!e&&zc(e,t),r=!!o&&zc(o,t);return n!==r?n?-1:1:n&&r&&e?.length!==o?.length?e?.length-o?.length:0}i(da,"compareStartWithText");function Hc(t,e,o){if(!o)return 0;let n=Qc(o,t.symbol,e.symbol);if(n)return n;if(o.length>=3){let r=Qc(o,t.name,e.name);if(r)return r}if(o.length>=2){let r=da(o,t.symbol,e.symbol);if(r)return r}if(o.length>=3){let r=ma(o,t.symbol,e.symbol);if(r)return r}if(o.length>=3){let r=da(o,t.name,e.name);if(r)return r}if(o.length>=3){let r=ma(o,t.name,e.name);if(r!==0)return r}if(o.length>=4){let r=da(o,t.address,e.address);if(r)return r}if(o.length>=4){let r=ma(o,t.address,e.address);if(r!==0)return r}return 0}i(Hc,"compareWithSearchFor");var Cr=i((t,e)=>{switch(e){case ua.ALL:return!0;case ua.UTXO:return t===yr.TRANSFER;case ua.OTHER:return t!==yr.TRANSFER&&t!==yr.COSMOS&&t!==yr.EVM;default:return t===e}},"isBlockchainTypeInCategory"),qc=i(t=>pa.find(o=>o.value===t)?.url,"getFontUrlByName");function Gc(t,e){let o=!!t.find(n=>n.state===vy.CONNECTED);return e===!1&&o}i(Gc,"isSingleWalletActive");function Vc(){let t,e;return(o,n)=>((!e||!t||t!==n)&&(t=n,e=o()),e)}i(Vc,"memoizedResult");import{BigNumber as Kc}from"bignumber.js";var dn=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"),P=i((t,e=null,o=null)=>{if(t==null||t==="")return"";let n=new Kc(t),r=1,a=1e3;for(let s=0;s<60;s++)if(new Kc(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 kr=i(t=>t?.reduce((e,o)=>e+(o.estimatedTimeInSeconds??0),0)||0,"totalArrivalTime");var bt=i((t,e)=>t.toLowerCase().indexOf(e.toLowerCase())>-1,"containsText"),fn=i(t=>!!t&&parseFloat(t)>0,"isPositiveNumber");function gn(t){switch(!0){case t.connected:return xt.CONNECTED;case t.connecting:return xt.CONNECTING;case!t.installed:return xt.NOT_INSTALLED;default:return xt.DISCONNECTED}}i(gn,"mapStatusToWalletState");function Xc(t,e,o,n){return o.filter(r=>!Dc.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:m,properties:h,isHub:d}=e(r),f=Do(u.map(C=>C.type)),g=gn(t(r));return{title:a,image:s,link:xy(l),state:g,type:r,showOnMobile:c,needsNamespace:p,blockchainTypes:f,needsDerivationPath:m,properties:h,isHub:d}})}i(Xc,"mapWalletTypesToWalletInfo");function hn(t){if(!t)return null;let e=[];return e=t.map(o=>o.name),e}i(hn,"walletAndSupportedChainsNames");function ga(t,e,o,n,r){let a=[];function s(c,p,u){if(!!!a.find(h=>h.chain===c)){let h={address:p,chain:c,walletType:t,isContractWallet:u??!1};a.push(h)}}i(s,"addAccount");let l=n||[];return e.forEach(c=>{let{address:p,network:u}=by(c),m=l.length>0,h=l.includes(u),d=u===jc.Unknown;if(m&&!h&&!d)return;let g=u===jc.Unknown&&Iy(p);if(d&&!g)return;o.includes(u)||g?r?s(u,p.toLowerCase(),r):l.filter(S=>o.includes(S)).forEach(S=>{s(S,p.toLowerCase())}):s(u,p)}),a}i(ga,"prepareAccountsForWalletStore");function mo(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 m=p.from.blockchain,h=p.to.blockchain,d=a===o.swaps.length-1,f=u===c.length-1;(!d&&!f||d&&l!==m||e==="all")&&n.add(m),e==="all"&&n.add(h)})}e==="all"&&n.add(l)}),Array.from(n)}i(mo,"getQuoteWallets");function yn(t,e){return t.address===e.address&&t.chain===e.chain&&t.walletType===e.walletType}i(yn,"isAccountAndWalletMatched");var Yc=i(t=>{let e=Object.values(t).reduce((o,n)=>{let r=n.usdValue?fa(n.usdValue,n.decimals):le.toFixed();return o.plus(r)},new $o(le));return Ny(e.toString())},"calculateWalletUsdValue");function Ny(t){let e=t.toString().split(".");return e[0]=e[0].replace(/\B(?=(\d{3})+(?!\d))/g,","),e.join(".")}i(Ny,"numberWithThousandSeparator");var wr=i((t,e)=>{let o=Ey(Object.entries(t).map(([,n])=>n).filter(Ay));return o&&o[e]?.experimental},"isExperimentalChain");function fa(t,e){return new $o(t).shiftedBy(-e).toFixed()}i(fa,"representAmountInNumber");function br(t){if(!t)return null;let e=fa(t.amount,t.decimals),o=t.usdValue?fa(t.usdValue,t.decimals):null,n=P(e,8,8),r=o?P(o,4,4):null;return t?{...t,amount:n,usdValue:r}:null}i(br,"formatBalance");function Zc(t,e){if(t?.usdValue||e?.usdValue){let o=t&&t.usdValue?new $o(t.usdValue).shiftedBy(-t.decimals):le,n=e&&e.usdValue?new $o(e.usdValue).shiftedBy(-e.decimals):le;return o.isEqualTo(n)?0:o.isGreaterThan(n)?-1:1}if(t?.amount||e?.amount){let o=t&&t.amount?new $o(t.amount).shiftedBy(-t.decimals):le,n=e&&e.amount?new $o(e.amount).shiftedBy(-e.decimals):le;return o.isEqualTo(n)?0:o.isGreaterThan(n)?-1:1}return 0}i(Zc,"compareTokenBalance");function Wt(t,e){return t?.blockchain===e?.blockchain&&t?.symbol.toLowerCase()===e?.symbol.toLowerCase()&&t?.address?.toLowerCase()===e?.address?.toLowerCase()}i(Wt,"areTokensEqual");function Jc(t){return t.sort((e,o)=>+(o.state===xt.CONNECTED)-+(e.state===xt.CONNECTED)||+(o.state===xt.DISCONNECTED||o.state===xt.CONNECTING)-+(e.state===xt.DISCONNECTED||e.state===xt.CONNECTING))}i(Jc,"sortWalletsBasedOnConnectionState");function xr(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(xr,"getConciseAddress");function Rc({chain:t,connectedWallets:e,walletType:o}){return e.find(n=>n.walletType===o&&n.chain===t)?.address}i(Rc,"getAddress");var ep=i((t,e)=>!!t.find(o=>o.chain===e&&o.loading),"isFetchingBalance");function tp(t){return t.map(e=>e.state).join("-")}i(tp,"hashWalletsState");function op(t,e){let o=new Set;return t.forEach(r=>{r.blockchainTypes.forEach(a=>{o.add(a)})}),e.filter(r=>o.has(r.type))}i(op,"filterBlockchainsByWalletTypes");function np(t,e){return e===wy.ALL?t:t.filter(o=>{for(let n of o.blockchainTypes)if(Cr(n,e))return!0;return!1})}i(np,"filterWalletsByCategory");var ha={API_KEY:hr};function Lt(t){return ha[t]||""}i(Lt,"getConfig");function rp(t){let e;return typeof structuredClone=="function"?e=structuredClone(t):e=JSON.parse(JSON.stringify(t)),ha=e,ha}i(rp,"initConfig");var ip=20,ap=25,ya="theme-widget",Sa=i((t,e)=>{let o=!1;if(e&&t){if(Array.isArray(e))o=!e.some(n=>Wt(n,t));else if(!Array.isArray(e)&&e[t.blockchain]){o=e[t.blockchain].tokens.some(r=>Wt(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"),sp=i((t,e,o)=>o==="expanded"&&(t||e)||o==="full-expanded"&&e,"isVariantExpandable");var Er,ot=i(()=>Er||(Er=new By(Lt("API_KEY"),Lt("BASE_URL")),Er),"httpService");function Ir(t,e){let o=t.map(a=>a.swapperGroup),n=[];return Do(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(Ir,"getUniqueSwappersGroups");function lp(t,e){return t.swapperGroup<e.swapperGroup?-1:t.swapperGroup>e.swapperGroup?1:0}i(lp,"sortLiquiditySourcesByGroupTitle");function Ye(t,e){return e?.[t]==="hidden"}i(Ye,"isFeatureHidden");function Fo(t,e){return e?.[t]==="enabled"}i(Fo,"isRoutingEnabled");var cp=i((t,e,o)=>Ye("customTokens",o)?t:t.concat(e),"addCustomTokensToSupportedTokens");var pp=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=dr({config:a}),p=r;return c.length>0&&(p=p.filter(u=>c.includes(u.name))),p.filter(u=>Mc.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",m=Po.get(u);m?.length||(m=mn({type:o.type,config:{blockchains:a[p]?.blockchains,tokens:a[p]?.tokens},meta:{tokensMapByTokenHash:n,tokensMapByBlockchainName:r}}),Po.set(u,m)),m=cp(m,s,a.features);let h=e().blockchains({type:o.type});return m.filter(f=>o.blockchain&&f.blockchain!==o.blockchain||!h.some(g=>g.name===f.blockchain)?!1:o.searchFor?!!(tt(f.symbol,o.searchFor)||tt(f.address||"",o.searchFor)||tt(f.name||"",o.searchFor)):!0).sort((f,g)=>{let C=e().isTokenPinned(f,o.type),k=e().isTokenPinned(g,o.type);if(C!==k)return C?-1:1;if(o.getBalanceFor){let B=o.getBalanceFor(f),I=o.getBalanceFor(g),x=Zc(B,I);if(x!==0)return x}let S=c.get(f.blockchain),T=c.get(g.blockchain),w=ca(f,S),E=ca(g,T);if(w!==E)return w?-1:1;if(f.isPopular!==g.isPopular)return f.isPopular?-1:1;if(o.searchFor){let B=Hc(f,g,o.searchFor);if(B)return B}return f.isSecondaryCoin!==g.isSecondaryCoin?f.isSecondaryCoin?1:-1:S&&T?S.sort-T.sort:0})},findToken:o=>{let n=e()._tokensMapByTokenHash,r=e().customTokens(),a=mt(o),s=n.get(a);return s||(s=r.find(l=>mt(l)===a)),s},isTokenPinned:(o,n)=>!!(n==="source"?e().config.from?.pinnedTokens:e().config.to?.pinnedTokens)?.some(s=>Wt(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(lp)},fetch:async()=>{try{let{routing:o}=e().config,n=Fo("enableCentralizedSwappers",o),r=await ot().getAllMetadata({enableCentralizedSwappers:n});t({fetchStatus:"success"});let a=new Map,s=new Map,l={},c=[],p=r.popularTokens,u=r.swappers.filter(d=>d.enabled),m=new Set;r.tokens.forEach(d=>{m.add(d.blockchain),c.push(d)}),r.blockchains.sort((d,f)=>d.sort-f.sort).forEach(d=>{d.enabled&&m.has(d.name)&&a.set(d.name,d)}),c.forEach(d=>{let f=mt(d);l[d.blockchain]||(l[d.blockchain]=[]),s.set(f,d),l[d.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 Wy,Catalonia as Ly,Chinese as up,Denmark as My,English as Py,Finland as _y,French as Dy,German as $y,Greece as Fy,Hungary as Oy,India as Uy,Indonesian as zy,Italian as Qy,Japanese as Hy,Korea as qy,Lithuania as Gy,Malay as Vy,Netherlands as Ky,Pakistan as jy,Philippines as Xy,Poland as Yy,Portuguese as Zy,Russian as Jy,SaudiArabia as Ry,Serbia as eS,Slovakia as tS,SouthAfrica as oS,Spanish as nS,Swahili as rS,Swedish as iS,Thai as aS,Turkish as sS,Ukrainian as lS,Vietnamese as cS}from"@rango-dev/ui";var mp=[{title:"Afrikaans",label:"Afrikaans",local:"af",SVGFlag:oS},{title:"Arabic",label:"\u0639\u0631\u0628\u064A",local:"ar",SVGFlag:Ry},{title:"Bengali",label:"\u09AC\u09BE\u0982\u09B2\u09BE",local:"bn",SVGFlag:Wy},{title:"Catalan",label:"Catal\xE0",local:"ca",SVGFlag:Ly},{title:"Chinese (Simplified)",label:"\u7B80\u4F53\u4E2D\u6587",local:"zh-CN",SVGFlag:up},{title:"Chinese (Traditional)",label:"\u4E2D\u6587\uFF08\u7E41\u9AD4)",local:"zh-TW",SVGFlag:up},{title:"Danish",label:"Dansk",local:"da",SVGFlag:My},{title:"Dutch",label:"Nederlands",local:"nl",SVGFlag:Ky},{title:"English",label:"English",local:"en",SVGFlag:Py},{title:"Filipino",label:"Filipino",local:"fil",SVGFlag:Xy},{title:"Finnish",label:"Suomalainen",local:"fi",SVGFlag:_y},{title:"French",label:"Fran\xE7ais",local:"fr",SVGFlag:Dy},{title:"German",label:"Deutsch",local:"de",SVGFlag:$y},{title:"Greek",label:"\u03B5\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AC",local:"el",SVGFlag:Fy},{title:"Hindi",label:"\u0939\u093F\u0902\u0926\u0940",local:"hi",SVGFlag:Uy},{title:"Hungarian",label:"Magyar",local:"hu",SVGFlag:Oy},{title:"Indonesian",label:"Indonesia",local:"id",SVGFlag:zy},{title:"Italian",label:"Italiana",local:"it",SVGFlag:Qy},{title:"Japanese",label:"\u65E5\u672C\u8A9E",local:"ja",SVGFlag:Hy},{title:"Korean",label:"\uD55C\uAD6D\uC778",local:"ko",SVGFlag:qy},{title:"Lithuanian",label:"Lietuvi\u0173",local:"lt",SVGFlag:Gy},{title:"Malay",label:"Melayu",local:"ms",SVGFlag:Vy},{title:"Polish",label:"Polski",local:"pl",SVGFlag:Yy},{title:"Portuguese",label:"Portugu\xEAs",local:"pt",SVGFlag:Zy},{title:"Russian",label:"\u0420\u0443\u0441\u0441\u043A\u0438\u0439",local:"ru",SVGFlag:Jy},{title:"Serbian",label:"C\u0440\u043F\u0441\u043A\u0438",local:"sr",SVGFlag:eS},{title:"Slovak",label:"Slovensk\xFD",local:"sk",SVGFlag:tS},{title:"Spanish",label:"Espa\xF1ol",local:"es",SVGFlag:nS},{title:"Swahili",label:"Kiswahili",local:"sw",SVGFlag:rS},{title:"Swedish",label:"Svenska",local:"sv",SVGFlag:iS},{title:"Thai",label:"\u0E41\u0E1A\u0E1A\u0E44\u0E17\u0E22",local:"th",SVGFlag:aS},{title:"Turkish",label:"T\xFCrk\xE7e",local:"tr",SVGFlag:sS},{title:"Ukrainian",label:"Y\u043A\u0440\u0430\u0457\u043D\u0456",local:"uk",SVGFlag:lS},{title:"Urdu",label:"\u0627\u0631\u062F\u0648",local:"ur",SVGFlag:jy},{title:"Vietnamese",label:"Ti\u1EBFng Vi\u1EC7t",local:"vi",SVGFlag:cS}],Oo="en";var dp=[.5,1,3],fp=1,gp=5,hp=100,yp=0;var Sp=i((t,e)=>({disabledLiquiditySources:[],theme:"auto",language:null,preferredBlockchains:[],slippage:fp,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=Do(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=Ye("theme",n),s=Ye("language",n),l=Ye("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||Oo},...l&&{disabledLiquiditySources:o.liquiditySources||[]},...p&&{language:o.language||Oo}})},setCustomToken:o=>{e().fetchCustomTokensBalances({tokens:[o],connectedWallets:e().connectedWallets}),t(n=>({_customTokens:[o,...n._customTokens]}))},deleteCustomToken:o=>t(n=>({_customTokens:n._customTokens.filter(r=>r.address!==o.address)})),customTokens:()=>{let o=e().config,n=e()._customTokens,r=dr({config:o});return r.length?n.filter(a=>r.includes(a.blockchain)):n}}),"createSettingsSlice");import Aa from"bignumber.js";import pS from"mitt";var he=pS(),uS={on:he.on,off:he.off};import{WidgetEvents as Cp}from"@rango-dev/queue-manager-rango-preset";var Ta=(o=>(o.QUOTE_INPUT_UPDATE="quoteInputUpdate",o.QUOTE_OUTPUT_UPDATE="quoteOutputUpdate",o))(Ta||{}),va=(o=>(o.CONNECT="connect",o.DISCONNECT="disconnect",o))(va||{}),wa=(e=>(e.CLICK_CONNECT_WALLET="clickConnectWallet",e))(wa||{}),Uo=(a=>(a[a.RouteEvent=Cp.RouteEvent]="RouteEvent",a[a.StepEvent=Cp.StepEvent]="StepEvent",a.QuoteEvent="quoteEvent",a.WalletEvent="walletEvent",a.UiEvent="uiEvent",a))(Uo||{});var kp=i(t=>(e,o,n)=>t(i((...a)=>{let[s,...l]=a;e(c=>({...typeof s=="function"?s(c):s,lastUpdatedAt:+new Date}),...l)},"modifedSet"),o,n),"keepLastUpdated");import Tp from"bignumber.js";function Mt(t){return`${t.blockchain}${po}${t.address}${po}${t.symbol}`}i(Mt,"createAssetKey");function vp(t,e){return`${Mt(e)}${po}${t}`}i(vp,"createBalanceKey");function Sn(t){let[e,o,n]=t.split(po);return{address:o==="null"?null:o,blockchain:e,symbol:n}}i(Sn,"extractAssetFromBalanceKey");function ba(t,e,o){return e.balances?.forEach(n=>{let r=n.price??t.findToken(n.asset)?.usdPrice;t._aggregatedBalances[Mt(n.asset)]?.forEach(s=>{o[s]&&(o[s]={...o[s],usdValue:r?new Tp(r??le).multipliedBy(o[s].amount).toString():""})})}),o}i(ba,"computeNextBalancesWithNewPrices");function xa(t,e){let o={};return t.balances?.forEach(n=>{let r=vp(t.address,n.asset),a=n.amount.amount,s=n.amount.decimals,l=n.price??e().findToken(n.asset)?.usdPrice,c=l?new Tp(l??le).multipliedBy(a).toString():"",p={amount:a,decimals:s,usdValue:c};o[r]=p}),o}i(xa,"createBalanceStateForNewAccount");function Ea(t,e){for(let o in e){let n=Sn(o),r=Mt(n);t[r]||(t[r]=[]),t[r].includes(o)||(t[r]=[...t[r],o])}return t}i(Ea,"updateAggregatedBalanceStateForNewAccount");function mS(t,e){let o=Sn(e),n=Mt(o);return t[n]&&(t[n]=t[n].filter(r=>r!==e)),t}i(mS,"removeBalanceFromAggregatedBalance");function Ia(t,e,o){let n=t.connectedWallets.filter(c=>c.walletType===e);t.connectedWallets.forEach(c=>{c.walletType!==e&&(n=n.filter(p=>!(p.chain===c.chain&&p.address===c.address)))}),o?.chains&&o.chains.length>0&&(n=n.filter(c=>o.chains?.includes(c.chain))),o?.namespaces&&o.namespaces.length>0&&(n=n.filter(c=>c.namespace?o.namespaces?.includes(c.namespace):!1));let r={},a=t._aggregatedBalances,s=t._balances;return Object.keys(s).forEach(c=>{let p=Sn(c);!!n.find(m=>vp(m.address,{address:p.address,blockchain:m.chain,symbol:p.symbol})===c)?a=mS(a,c):r[c]=s[c]}),{_balances:r,_aggregatedBalances:a}}i(Ia,"computeNextStateAfterWalletBalanceRemoval");function dS(t,e){return e.find(o=>t.address===o.address&&t.chain===o.blockChain)}i(dS,"matchWalletDetailsWithConnectedWallet");var fS=Vc(),wp=kp((t,e)=>({_balances:{},_aggregatedBalances:{},connectedWallets:[],fetchingWallets:!1,lastUpdatedAt:+new Date,setConnectedWalletAsRefetching:o=>{t(n=>({fetchingWallets:!0,connectedWallets:n.connectedWallets.map(r=>o.find(a=>yn(a,r))?{...r,loading:!0,error:!1}:r)}))},setConnectedWalletRetrievedData:(o,n)=>{t(r=>({fetchingWallets:!1,connectedWallets:r.connectedWallets.map(a=>o.find(s=>yn(s,a))?{...a,loading:!1,error:!1,explorerUrl:dS(a,n)?.explorerUrl||a.explorerUrl}:a)}))},setConnectedWalletHasError:o=>{t(n=>({fetchingWallets:!1,connectedWallets:n.connectedWallets.map(r=>o.find(a=>yn(a,r))?{...r,loading:!1,error:!0}:r)}))},addConnectedWallet:(o,n)=>{let r=e().connectedWallets,a=o.filter(s=>!r.some(l=>yn(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,isContractWallet:l.isContractWallet,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]}))}},fetchCustomTokensBalances:async o=>{let{tokens:n,connectedWallets:r}=o,a=n.reduce((c,p)=>((c[p.blockchain]||=[]).push(p),c),{}),s=new Set,l=r.reduce((c,p)=>{let u=`${p.address}-${p.chain}`;return s.has(u)||(s.add(u),a[p.chain]&&(c[p.address]||(c[p.address]=[]),c[p.address].push(...a[p.chain]))),c},{});Object.entries(l).forEach(async([c,p])=>{try{let{balances:u}=await ot().getMultipleTokenBalance({assets:p.map(({symbol:m,address:h,blockchain:d})=>({symbol:m,address:h,blockchain:d})),walletAddress:c});if(u){let m=e()._balances,h=e()._aggregatedBalances;u.forEach(d=>{if(parseFloat(d.amount.amount)===0)return;let f={blockChain:d.asset.blockchain,balances:[d],address:c},g={_aggregatedBalances:e()._aggregatedBalances,findToken:e().findToken};ba(g,f,m);let C=xa(f,e);h=Ea(h,C),m={...m,...C}}),t(d=>({_balances:{...d._balances,...m},_aggregatedBalances:h}))}}catch(u){console.error(u)}})},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={_balances:e()._balances,_aggregatedBalances:e()._aggregatedBalances,connectedWallets:e().connectedWallets},{_balances:a,_aggregatedBalances:s}=Ia(r,o,n);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{shouldFetchCustomTokens:r=!0,selectedCustomTokens:a}=n||{};await e().fetchMainTokensBalances(o),r&&e().fetchCustomTokensBalances({tokens:a??e().customTokens(),connectedWallets:o})},fetchMainTokensBalances:async(o,n)=>{if(o.length===0)return;let r=o[0].walletType;e().setConnectedWalletAsRefetching(o);let a=o.map(c=>({address:c.address,blockchain:c.chain})),s;try{s=await ot().getWalletsDetails(a)}catch(c){e().setConnectedWalletHasError(o),console.error(`Request for fetching balances failed. cause: ${c}`);return}let l=s.wallets;if(l){let c=e()._balances,p=e()._aggregatedBalances;l.forEach(m=>{if(m.failed)return;let h={_balances:c,_aggregatedBalances:p,connectedWallets:e().connectedWallets,findToken:e().findToken};ba(h,m,c);let{_balances:d,_aggregatedBalances:f}=Ia(h,r,{chains:[m.blockChain]});if(p=f,c=d,!e().connectedWallets.find(C=>C.walletType===r&&C.address===m.address&&C.chain===m.blockChain))return;let g=xa(m,e);p=Ea(p,g),c={...c,...g}}),t(m=>({_balances:{...m._balances,...c},_aggregatedBalances:p})),e().setConnectedWalletRetrievedData(o,l);let{retryOnFailedBalances:u=!0}=n||{};if(u){let m=l.filter(h=>h.failed).map(h=>({chain:h.blockChain,walletType:r,address:h.address}));m.length>0&&await e().fetchMainTokensBalances(m,{retryOnFailedBalances:!1})}}else e().setConnectedWalletHasError(o),console.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=Mt(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 Aa(p.amount),m=new Aa(l.amount);u.isGreaterThan(m)&&(l=p)}),l},getBalancesForWalletAddress:o=>{let n=e().getBalances();return Object.keys(n).reduce((s,l)=>{let c=n[l],[,,,p]=l.split(po);return p===o&&(s[l]=c),s},{})},getConnectedWalletsDetails:()=>fS(()=>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=Sn(l);if(p.blockchain===n.chain){let u=e().findToken(p),m=c.amount?new Aa(c.amount).shiftedBy(-c.decimals):le;s.push({chain:n.chain,symbol:p.symbol,ticker:p.symbol,address:p.address,rawAmount:c.amount,decimal:c.decimals,amount:m.toString(),logo:u?.image||null,usdPrice:u?.usdPrice||null})}return s},[])}}),e().lastUpdatedAt)}));function bp(t){return gS()(hS((...e)=>({...wp(...e),...pp(...e),...Sp(...e),...Wc(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}),version:1,migrate:(e,o)=>{let n=e;return o===0&&(n._customTokens=n._customTokens.map(r=>({...r,warning:!0}))),n}}))}i(bp,"createAppStore");var xp=SS(null);function y(){let t=CS(xp);if(kS(()=>{t&&!t.persist.hasHydrated()&&t.persist.rehydrate()},[]),!t)throw new Error("Missing AppStoreContext.Provider in the tree");return t()}i(y,"useAppStore");function Ep(t){let e=TS();return e.current||(e.current=bp(t.config)),yS.createElement(xp.Provider,{value:e.current},t.children)}i(Ep,"AppStoreProvider");function ht(t){let{chain:e}=t||{},{connectedWallets:o,getAvailableProviders:n}=y(),{state:r,getWalletInfo:a}=vS(),s=y().blockchains(),{handleDisconnect:l}=Kt(),c=Ic(n()),p=Xc(r,a,c,e);p=wS()?p.filter(g=>g.showOnMobile!==!1&&r(g.type).installed):p;let u=Jc(p),m=i(g=>!o.find(C=>C.walletType===g&&C.chain===e),"isExperimentalChainNotAdded"),h=xS(()=>{let g=p?.filter(C=>C.state===Na.CONNECTING)||[];for(let C of g)l(C.type)},[tp(p)]);ES(()=>()=>{h()},[]);let d=i(g=>{let C=g.find(S=>S.type===Cn.DEFAULT);return!C||C.state===Na.NOT_INSTALLED?!1:g.filter(S=>S.state!=Na.NOT_INSTALLED&&![Cn.DEFAULT,Cn.WALLET_CONNECT_2,Cn.LEDGER].includes(S.type)&&a(S.type).supportedChains.filter(T=>T.type=="EVM").length>0).length==0},"shouldShowDefaultInjectedWallet"),f=i((g,C,k)=>wr(k,C)&&m(g)&&!bS.includes(g)||g==Cn.DEFAULT&&!d(p),"shouldExcludeWallet");return{list:u.filter(g=>!f(g.type,e??"",s)),terminateConnectingWallets:h}}i(ht,"useWalletList");import{Modal as BS}from"@rango-dev/ui";import WS from"react";import{create as NS}from"zustand";var Ip="rango-widget";var kn=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(Ip),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 AS=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"),zo=AS;var ne=zo(NS()((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})}}))),fo=new kn({onInit:()=>ne.setState({tabManagerInitiated:!0}),onClaim:()=>ne.setState({isActiveTab:!0,showActivateTabModal:!1}),onRelease:()=>ne.setState({isActiveTab:!1})});function J(t){let{watermark:e}=ne();return WS.createElement(BS,{hasWatermark:e==="FULL",...t},t.children)}i(J,"WatermarkedModal");import{i18n as Ba}from"@lingui/core";import{Button as $S,Checkbox as FS,Divider as OS,Image as $p,ListItemButton as US,MessageBox as zS,Radio as QS,RadioRoot as HS}from"@rango-dev/ui";import ve,{useState as qS}from"react";import{css as LS,darkTheme as Np,IconButton as MS,styled as go}from"@rango-dev/ui";var Et=go(MS,{width:"$24",position:"relative",padding:"0",overflow:"unset","&:hover":{backgroundColor:"$secondary100",[`.${Np} &`]:{backgroundColor:"$neutral"}}}),Bp=go("div",{position:"absolute",background:"$secondary500",[`.${Np} &`]:{$$color:"$colors$secondary250"},width:"$6",height:"$6",borderRadius:"$lg",right:"$4",border:"1px solid $surface100"}),jt=go("div",{display:"flex",justifyContent:"flex-end",minWidth:"$40",button:{padding:0}}),Wp=go("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"}}}}),Lp=go("div",{padding:"$2",variants:{isRefetched:{true:{transform:"rotate(360deg)",transition:"transform 1s ease-in-out"}}}}),Mp=go("div",{position:"absolute",right:"$4",top:"$4",backgroundColor:"$background",borderRadius:"100%"}),Pp=LS({display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center"}),Ar=go("div",{borderRadius:"100%",border:"1.5px transparent solid","&:not(:first-child)":{marginLeft:"-$6"},img:{borderRadius:"100%"}});import{keyframes as PS,styled as Nr}from"@rango-dev/ui";var XN=Nr("div",{borderRadius:"$lg",width:"$45",height:"$45",backgroundColor:"$success300",display:"flex",justifyContent:"center",alignItems:"center"}),Qo=Nr("div",{position:"relative"}),_S=PS({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}),Ho=Nr("div",{position:"absolute",border:"2px solid rgba(0, 0, 0, 0.1)",borderTop:"2px solid $info500",borderRadius:"$lg",width:"$45",height:"$45",animation:`${_S} 1s linear infinite`,top:0,bottom:0,right:0,left:0}),Br=Nr("div",{"& img":{borderRadius:"50%"}});function _p(t,e){return t.find(o=>o.name===e)?.logo}i(_p,"getBlockchainLogo");import{styled as DS}from"@rango-dev/ui";var Dp=DS("ul",{padding:0,paddingTop:"$4",paddingBottom:"$4"});function Tn(t){let{targetWallet:e}=t.value,o=e.needsNamespace?.selection==="single",n=e.image,[r,a]=qS([]),s=y().blockchains(),l=i(p=>{a(o?[p]:u=>u.includes(p)?u.filter(m=>m!==p):u.concat(p))},"onSelect"),c=i(p=>o?ve.createElement(HS,{value:r?.[0]},p):ve.createElement(ve.Fragment,null,p),"wrapRadioRoot");return ve.createElement(ve.Fragment,null,ve.createElement(OS,{size:20}),ve.createElement(zS,{type:"info",title:Ba.t("Select chain types"),description:Ba.t("This wallet supports multiple chains. Select which chain you'd like to connect to."),icon:ve.createElement(Qo,null,ve.createElement(Ar,null,ve.createElement($p,{src:n,size:45})),ve.createElement(Ho,null))}),ve.createElement(Dp,null,c(ve.createElement(ve.Fragment,null,e.needsNamespace?.data.map(p=>ve.createElement(US,{key:p.id,id:p.id,title:p.label,hasDivider:!0,style:{height:60},onClick:()=>l(p.value),start:ve.createElement($p,{src:_p(s,p.id),size:22}),end:o?ve.createElement(QS,{value:p.value}):ve.createElement(FS,{checked:r.includes(p.value)})}))))),ve.createElement($S,{id:"widget-name-space-confirm-btn",type:"primary",disabled:!r.length,onClick:()=>t.onConfirm(r)},Ba.t("Confirm")))}i(Tn,"Namespaces");import{i18n as qo}from"@lingui/core";import{Button as KS,Divider as Up,Image as jS,MessageBox as XS,Select as YS,TextField as ZS}from"@rango-dev/ui";import ze,{useEffect as JS,useState as zp}from"react";import{namespaces as GS}from"@rango-dev/wallets-shared";var Wr={id:"custom",label:"Custom",generateDerivationPath:t=>t};function Wa(t){let e=t?GS[t].derivationPaths:null;return e?[...e,Wr]:[]}i(Wa,"getDerivationPaths");import{styled as Fp,Typography as VS}from"@rango-dev/ui";var Op=Fp("div",{paddingTop:"$30",paddingBottom:"$30",zIndex:10}),La=Fp(VS,{paddingLeft:"$10"}),Ma={height:"$40",backgroundColor:"$neutral200",borderRadius:"$sm"};var Qp="0";function vn(t){let{onConfirm:e}=t,{namespace:o,providerImage:n,providerType:r}=t.value,[a,s]=zp(null),[l,c]=zp(Qp),p=a===Wr.id,u=Wa(o),m=i(({value:d})=>{let f=u?.find(g=>g.id===d);f&&(a===Wr.id&&Number.isNaN(Number(l))&&c(Qp),s(f.id))},"handleDerivationPathItemClick"),h=i(()=>{let d=u.find(f=>f.id===a);if(d)e(d.generateDerivationPath(l));else throw new Error("selectedDerivationPath can not be undefined")},"handleConfirm");return JS(()=>{s(Wa(o)[0]?.id||null)},[o]),ze.createElement(ze.Fragment,null,ze.createElement(Up,{size:20}),ze.createElement(XS,{type:"info",title:qo.t("Select Derivation Path"),description:qo.t({id:"In order to connect to {type}, you must first select a Derivation Path",values:{type:r}}),icon:ze.createElement(Qo,null,ze.createElement(Br,null,ze.createElement(jS,{src:n,size:45})),ze.createElement(Ho,null))}),ze.createElement(Op,null,ze.createElement(La,{variant:"body",size:"xsmall",color:"$neutral600"},qo.t("Choose Derivation Path Template")),ze.createElement(YS,{value:a||"",options:u.map(d=>({value:d.id,label:d.label})),variant:"filled",handleItemClick:m,styles:{trigger:Ma}}),ze.createElement(Up,{size:20}),ze.createElement(La,{variant:"body",size:"xsmall",color:"$neutral600"},p?qo.t("Enter Path"):qo.t("Enter Index")),ze.createElement(ZS,{type:p?"text":"number",variant:"contained",value:l,onChange:d=>c(d.target.value),style:Ma})),ze.createElement(KS,{id:"widget-derivation-path-confirm-btn",type:"primary",onClick:h,disabled:!u||!a||!l},qo.t("Confirm")))}i(vn,"DerivationPath");import{i18n as Go}from"@lingui/core";import{Image as RS,MessageBox as Pa,WalletState as eC}from"@rango-dev/ui";import{useWallets as tC}from"@rango-dev/wallets-react";import ho from"react";function _a(t){let{wallet:e,error:o}=t,{type:n,image:r}=e,{state:a}=tC();return gn(a(n))===eC.CONNECTED?ho.createElement(Pa,{type:"success",title:Go.t("Wallet Connected"),description:Go.t("Your wallet is connected, you can use it to swap.")}):o?ho.createElement(Pa,{type:"error",title:Go.t("Failed to Connect"),description:o||Go.t("Your wallet is not connected. Please try again.")}):ho.createElement(Pa,{type:"loading",title:Go.t("Connecting to your wallet"),description:Go.t("Click connect in your wallet popup."),icon:ho.createElement(Qo,null,ho.createElement(Br,null,ho.createElement(RS,{src:r,size:45})),ho.createElement(Ho,null))})}i(_a,"ConnectStatus");import{i18n as Da}from"@lingui/core";import{Button as oC,Divider as Hp,MessageBox as nC}from"@rango-dev/ui";import Lr from"react";function $a(t){let{displayName:e,onConfirm:o}=t;return Lr.createElement(nC,{title:Da.t({id:"Add {blockchainDisplayName} Chain",values:{blockchainDisplayName:e}}),type:"warning",description:Da.t({id:"Would you like to add the {blockchainDisplayName} experimental chain to your wallet?",values:{blockchainDisplayName:e}})},Lr.createElement(Hp,{size:18}),Lr.createElement(Hp,{size:32}),Lr.createElement(oC,{id:"widget-experimental-chain-confirm-btn",onClick:o,variant:"outlined",type:"primary",fullWidth:!0,size:"large"},Da.t("Confirm")))}i($a,"ExperimentalChain");function qp(t,e){return t().status==="init"&&!!e}i(qp,"isOnStatus");function wn(t){return t().status==="namespace"}i(wn,"isOnNamespace");function bn(t){return t().status==="derivationPath"}i(bn,"isOnDerivationPath");var sC=3e3,lC=300;function So(t){let e=aC(),[o,n]=Gp(!1),[r,a]=Gp(),s=i(S=>{a(S.message)},"catchErrorOnHandle"),{terminateConnectingWallets:l}=ht(),{handleConnect:c,handleDerivationPath:p,handleNamespace:u,getState:m,resetState:h}=Kt(),d=i(S=>{u(t.wallet,S).then(k).catch(s)},"handleConfirmNamespaces"),f=i(S=>{if(!S)throw new Error("Derivation path is empty. Please make sure you've filled the field correctly.");p(S).then(k).catch(s)},"handleDerivationPathConfirm"),g=i(()=>{n(!1)},"handleClosingModal"),C=i(()=>{a(void 0),h(),n(!1),e.current&&clearTimeout(e.current)},"resetModalState"),k=i((S,T)=>{let w=S.status==="connected",E=["disconnected","disconnected-unhandled"].includes(S.status);w?(t.onConnect?.(),T||(e.current=setTimeout(g,sC))):E&&g()},"afterConnected");return iC(()=>{if(t.wallet){C();let S=!1,T=!0;i(()=>{setTimeout(()=>{T=!1,S||n(!0)},lC)},"beforeConnecting")(),c(t.wallet,{disconnectIfConnected:!0}).then(E=>{["namespace","derivation-path"].includes(E.status)||(S=!0),k(E,T)}).catch(s)}},[t.wallet]),yo.createElement(J,{open:o,onClose:g,onExit:()=>{C(),l(),t.onClose&&t.onClose()},container:N()},qp(m,t.wallet)&&yo.createElement(yo.Fragment,null,yo.createElement(_a,{wallet:{type:t.wallet.type,image:t.wallet.image},error:r}),yo.createElement(rC,{direction:"vertical",size:32})),wn(m)&&yo.createElement(Tn,{onConfirm:d,value:m().namespace}),bn(m)&&yo.createElement(vn,{onConfirm:f,value:m().derivationPath}))}i(So,"StatefulConnectModal");import{Provider as dC}from"@rango-dev/wallets-react";import Mr,{createContext as fC,useEffect as Yp,useMemo as gC,useRef as Zp}from"react";import{useEffect as cC}from"react";function Vp(t){return t.map(e=>typeof e=="string"?e:e.config.type).join("-")}i(Vp,"hashProviders");function Fa(t,e){let{clearConnectedWallet:o,getAvailableProviders:n,buildAndSetProviders:r}=y(),a=n();return cC(()=>{o(),r()},[Vp(t??[]),e?.walletConnectProjectId,e?.walletConnectListedDesktopWalletLink]),{providers:a}}i(Fa,"useWalletProviders");import{legacyFormatAddressWithNetwork as pC,legacyReadAccountAddress as Kp}from"@rango-dev/wallets-core/legacy";import{Events as Co}from"@rango-dev/wallets-react";import{isEvmBlockchain as uC}from"rango-sdk";function jp(t){let{newWalletConnected:e,disconnectWallet:o,disconnectNamespaces:n,connectedWallets:r,removeBalancesForWallet:a,blockchains:s}=y(),{onConnectWalletHandler:l,onDisconnectWalletHandler:c}=t,p=s().filter(uC).map(g=>g.name),u=i((g,C)=>{let[k,,S,,T]=g,w=ga(k,S,p,C.supportedChainNames,T.isContractWallet);w.length&&e(w,T.namespace)},"onAccountsEvent"),m=i((g,C,k,S,T)=>{if(C===Co.ACCOUNTS){let w=hn(T.supportedBlockchains);k&&u([g,C,k,S,T],{supportedChainNames:w})}if(C===Co.CONNECTED){let w=`${g}-${S.network}-${k}`;l.current?l.current(w):console.warn("onConnectWallet handler hasn't been set. Are you sure?")}C===Co.PROVIDER_DISCONNECTED&&(o(g),c.current?c.current(g):console.warn("onDisconnectWallet handler hasn't been set. Are you sure?")),C===Co.NAMESPACE_DISCONNECTED&&n(g,k)},"handleUpdatesForHub"),h=i((g,C,k,S,T)=>{if(C===Co.ACCOUNTS){let w=hn(T.supportedBlockchains),E=[],B=[];if(k?.forEach(x=>{let{network:b}=Kp(x);p.includes(b)?E.push(x):B.push(x)}),r.filter(x=>x.walletType===g).map(x=>pC(x.address,x.chain)).length>0){if(E.length>0){let x=ga(g,E,p,w,T.isContractWallet);a(g,{chains:x.map(b=>b.chain)})}B.length>0&&a(g,{chains:B.map(x=>{let{network:b}=Kp(x);return b})})}k?u([g,C,k,S,T],{supportedChainNames:w}):(o(g),c.current?c.current(g):console.warn("onDisconnectWallet handler hasn't been set. Are you sure?"))}if(C===Co.ACCOUNTS&&S.connected){let w=`${g}-${S.network}-${k}`;l.current?l.current(w):console.warn("onConnectWallet handler hasn't been set. Are you sure?")}},"handleUpdatesForLegacy"),d=i((g,C,k,S,T)=>{if(C===Co.NETWORK&&S.network){let w=`${g}-${S.network}`;l.current?l.current(w):console.warn("onConnectWallet handler hasn't been set. Are you sure?")}},"handleUpdatesForBoth");return{handler:i((g,C,k,S,T)=>{T.isHub?m(g,C,k,S,T):h(g,C,k,S,T),d(g,C,k,S,T)},"handler")}}i(jp,"useUpdates");import{LegacyEvents as mC}from"@rango-dev/wallets-core/legacy";function Xp(t,e){let[o,n,r,a,s]=e;n!==mC.PROVIDER_DISCONNECTED&&t(o,n,r,a,s)}i(Xp,"propagateEvents");var Pr=fC({onConnectWallet:()=>{},onDisconnectWallet:()=>{}});function hC(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}=Fa(s.wallets,l),p=Zp(),u=Zp(),{handler:m}=jp({onConnectWalletHandler:p,onDisconnectWalletHandler:u});Yp(()=>{n().catch(console.log)},[]),Yp(()=>{t.config&&(e(t.config),o(t.config),window.__rango={config:s,dappConfig:t.config})},[t.config,r]);let h=ne.use.isActiveTab(),d=gC(()=>({onConnectWallet:f=>{p.current=f},onDisconnectWallet:f=>{u.current=f}}),[]);return Mr.createElement(Pr.Provider,{value:d},Mr.createElement(dC,{allBlockChains:a,providers:c,onUpdateState:(f,g,C,k,S)=>{let T=[f,g,C,k,S];m(...T),t.onUpdateState&&Xp(t.onUpdateState,T)},autoConnect:!!h,configs:{wallets:s.wallets}},t.children))}i(hC,"Main");function _r(t){let{config:e,...o}=t;return Mr.createElement(Ep,{config:e},Mr.createElement(hC,{...o,config:e}))}i(_r,"WidgetWallets");import aa from"react";import yC,{Fragment as SC}from"react";import{MemoryRouter as CC,useInRouterContext as kC}from"react-router";function Jp({children:t}){let o=kC()?SC:CC;return yC.createElement(o,null,t)}i(Jp,"AppRouter");import{I18nManager as dI}from"@rango-dev/ui";import hc from"react";import Pe from"react";import{useRoutes as RE}from"react-router-dom";var F={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 Ko,useRef as qr}from"react";import Ze from"bignumber.js";import{create as wC}from"zustand";import{subscribeWithSelector as bC}from"zustand/middleware";import{i18n as yt}from"@lingui/core";import{RouteEventType as pL}from"@rango-dev/queue-manager-rango-preset";import Qe from"bignumber.js";import{PendingSwapNetworkStatus as Qr}from"rango-types";import{i18n as Fe}from"@lingui/core";var ee=i(()=>({genericServerError:Fe.t("Failed Network, Please retry your swap."),liquiditySourcesError:{title:Fe.t("Please reset your liquidity sources."),description:Fe.t("You have limited the liquidity sources and this might result in Rango finding no routes. Please consider resetting your liquidity sources.")},noResultError:{title:Fe.t("No Routes Found."),description:Fe.t("Reasons why Rango couldn't find a route: low liquidity on token, very low input amount or no routes available for the selected input/output token combination.")},bridgeLimitErrors:{increaseAmount:Fe.t("Bridge Limit Error: Please increase your amount."),decreaseAmount:Fe.t("Bridge Limit Error: Please decrease your amount.")},highValueLossError:{impactTitle:Fe.t("High Price Impact"),title:Fe.t("Price impact is too high!"),description:Fe.t("The price impact is significantly higher than the allowed amount."),confirmMessage:Fe.t("Confirm high price impact")},quoteUpdatedWithHighValueLoss:{title:Fe.t("Route updated and price impact is too high, try again later!")},unknownPriceError:{impactTitle:Fe.t("USD Price Unknown"),title:Fe.t("USD Price Unknown, Cannot calculate Price Impact."),description:Fe.t("USD Price Unknown, Cannot calculate Price Impact. The price impact may be higher than usual. Are you sure to continue the Swap?"),confirmMessage:Fe.t("Confirm USD Price Unknown")}}),"errorMessages");function Rp(t){switch(t.type){case 0:return t.diagnosisMessage??ee().noResultError.title;case 1:return ee().genericServerError;default:return""}}i(Rp,"getQuoteErrorMessage");import{i18n as Dr}from"@lingui/core";var ko=i(()=>({connectWallet:Dr.t("Connect Wallet"),swap:Dr.t("Swap"),swapAnyway:Dr.t("Swap anyway"),ethWarning:Dr.t("The route goes through Ethereum. Continue?")}),"swapButtonTitles");function Oa(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(Oa,"getFeeLabel");var Ua=["RECOMMENDED","CENTRALIZED","LOWEST_FEE","FASTEST","HIGH_IMPACT"],eu=100,tu=30,ou=15,nu=60;var ru=[{threshold:-10,minInput:400},{threshold:-5,minInput:1e3}],iu=[{threshold:-1,minInput:1e3},{threshold:-2,minInput:500}];import{getLastSuccessfulStep as vC}from"@rango-dev/queue-manager-rango-preset";import YW from"bignumber.js";function su(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(su,"getRequiredBalanceOfWallet");function _t(t){let e;return t<=-3&&t>-10?e="low":t<=-10&&(e="high"),e}i(_t,"getPriceImpactLevel");function Fr(t,e,o){let n=t.steps[0],r=t.steps[t.steps.length-1],a=vC(t.steps),s={blockchain:r.toBlockchain,symbol:r.toSymbol,address:r.toSymbolAddress},l=co(a?a.toBlockchain:n.fromBlockchain,e),c=co(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),m=a?a.outputAmount??"":t.inputAmount;return{fromBlockchain:l,fromToken:p,toBlockchain:c,toToken:u,inputAmount:m}}i(Fr,"createRetryQuote");function Vo(t){let{previousQuote:e,currentQuote:o,findToken:n,userSlippage:r}=t,a=xn(o),s=dt(o);if(o&&a&&s){let p=Pt(a.toString(),s.toString());if(!!p&&mu(a,p)){let m=Ur(o?.swaps,n),h=_t(p);return{type:0,inputUsdValue:a,outputUsdValue:s,priceImpact:p,totalFee:m,warningLevel:h}}}if(e&&gu(e,o))return{type:4,usdValueChange:P(dt(o)?.minus(dt(e)??0).toString()??"0",null,2),percentageChange:P(Pt(dt(e)??"1",dt(o)??"1"),null,2)};if(o&&(!a||!s))return{type:1};let l=zr(o.swaps),c=r>gp;if(fu(t.userSlippage.toString(),l)){if(c&&parseFloat(l??"0")<r)return{type:3,slippage:r.toString()}}else return{type:2,recommendedSlippages:du(o,r),minRequiredSlippage:l};return null}i(Vo,"generateQuoteWarnings");function lu(t){return![4].includes(t.type)}i(lu,"isQuoteWarningConfirmationRequired");function Pt(t,e){let o=typeof e=="string"?parseFloat(e)<=0:!e?.gt(0),n=!t||!e||o?null:za(t.toString(),e.toString());return n&&n<0?n:null}i(Pt,"getPriceImpact");var cu=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"),Or=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"),pu=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"),uu=i(t=>{let e=i((o,n)=>{let r=Ua.indexOf(o.value),a=Ua.indexOf(n.value);return r!==-1&&a!==-1?r-a:r!==-1?-1:a!==-1?1:0},"customSort");return t.sort(e)},"sortTags");function mu(t,e){if(!t)return!1;let o=parseInt(e.toFixed(2)||"0");return ru.some(({threshold:n,minInput:r})=>o<=n&&t.gte(new Qe(r)))}i(mu,"hasHighValueLoss");function hu(t){return(t||[]).filter(e=>{let o=e.fromAmountMinValue?new Qe(e.fromAmountMinValue):null,n=e.fromAmountMaxValue?new Qe(e.fromAmountMaxValue):null;return e.fromAmountRestrictionType==="EXCLUSIVE"?o?.gte(e.fromAmount)||n?.lte(e.fromAmount):o?.gt(e.fromAmount)||n?.lt(e.fromAmount)}).length>0}i(hu,"hasLimitError");function yu(t){let e=(t||[]).filter(l=>{let c=l.fromAmountMinValue?new Qe(l.fromAmountMinValue):null,p=l.fromAmountMaxValue?new Qe(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 Qe(e.fromAmountMinValue):null,n=e.fromAmountMaxValue?new Qe(e.fromAmountMaxValue):null,r=e.fromAmountRestrictionType==="EXCLUSIVE",a="",s="";return!r&&o&&o.gt(e.fromAmount)?(a=yt.t({id:"Required: >= {min} {symbol}",values:{min:P(o,6,6),symbol:e.from.symbol}}),s=ee().bridgeLimitErrors.increaseAmount):r&&o&&o.gte(e.fromAmount)&&(a=yt.t({id:"Required: > {min} {symbol}",values:{min:P(o,6,6),symbol:e.from.symbol}}),s=ee().bridgeLimitErrors.increaseAmount),!r&&n&&n.lt(e.fromAmount)?(a=yt.t({id:"Required: <= {max} {symbol}",values:{max:P(n,6,6),symbol:e.from.symbol}}),s=ee().bridgeLimitErrors.decreaseAmount):r&&n&&n.lte(e.fromAmount)&&(a=yt.t({id:"Required: < {max} {symbol}",values:{max:P(n,6,6),symbol:e.from.symbol}}),s=ee().bridgeLimitErrors.decreaseAmount),{swap:e,fromAmountRangeError:a,recommendation:s}}i(yu,"getLimitErrorMessage");function Su(t){let{fetchMetaStatus:e,anyWalletConnected:o,fetchingQuote:n,inputAmount:r,quote:a,warning:s,error:l,needsToWarnEthOnPath:c}=t;return e!=="success"?{title:ko().connectWallet,action:"connect-wallet",disabled:!0}:o?n||!a||l||!r||r==="0"?{title:ko().swap,action:"confirm-swap",disabled:!0}:s?{title:ko().swapAnyway,action:"confirm-warning",disabled:!1}:c?{title:ko().ethWarning,action:"confirm-warning",disabled:!1}:{title:ko().swap,action:"confirm-swap",disabled:!1}:{title:ko().connectWallet,action:"connect-wallet",disabled:!1}}i(Su,"getSwapButtonState");function Qa(t,e,o){let n=parseFloat(e||"0");return!(t&&(!o||o.lte(le))&&e&&e!=="0"&&n!==0)}i(Qa,"canComputePriceImpact");function Ha(t,e){let o=le;for(let n=0;n<t.fee.length;n++){let r=t.fee[n];if(r.expenseType==="DECREASE_FROM_OUTPUT")continue;let a=e(r.asset)?.usdPrice||null;o=o.plus(new Qe(r.amount).multipliedBy(a||0))}return o}i(Ha,"getUsdFeeOfStep");function Ur(t,e){return t.reduce((o,n)=>o.plus(Ha(n,e)),le)}i(Ur,"getTotalFeeInUsd");function qa(t){let e=le;return e=e.plus(new Qe(t.amount).multipliedBy(t.price||0)),e}i(qa,"getUsdFee");function Cu(t){return t.reduce((e,o)=>e.plus(qa(o)),le)}i(Cu,"getTotalFeesInUsd");function ku(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(ku,"getFeesGroup");function Tu(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(Tu,"checkSlippageErrors");function du(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(du,"checkSlippageWarnings");function zr(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(zr,"getMinRequiredSlippage");function fu(t,e){return e?parseFloat(t)>=parseFloat(e):!0}i(fu,"hasProperSlippage");function vu(t){let{fromToken:e,toToken:o,inputAmount:n,wallets:r,selectedWallets:a,disabledLiquiditySources:s,liquiditySources:l,excludeLiquiditySources:c,slippage:p,affiliateRef:u,affiliatePercent:m,affiliateWallets:h,destination:d,contractCall:f}=t,g=a?.reduce((S,T)=>(S[T.chain]=T.address,S),{}),C=[];return r?.forEach(S=>{C.push({blockchain:S.chain,addresses:[S.address]})}),{amount:n.toString(),affiliateRef:u??void 0,affiliatePercent:m??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:C,selectedWallets:g??{},slippage:p.toString(),contractCall:f,...d&&{destination:d},...c&&{swapperGroups:s.concat(l??[]),swappersGroupsExclude:!0},...!c&&{swapperGroups:l?.filter(S=>!s.includes(S)),swappersGroupsExclude:!1}}}i(vu,"createQuoteRequestBody");function wu(t){return t.reduce((o,n)=>(o[n.chain]={address:n.address,walletType:n.walletType},o),{})}i(wu,"getWalletsForNewSwap");function xn(t){let e=t.requestAmount,o=t.swaps[0].from.usdPrice;if(!(!e||!o))return new Qe(e).multipliedBy(o)}i(xn,"getUsdInputFrom");function dt(t){let e=t?.outputAmount||null,o=t.swaps[t.swaps.length-1].to.usdPrice;if(!(!e||!o))return new Qe(e).multipliedBy(o)}i(dt,"getUsdOutputFrom");function za(t,e){return new Qe(e).div(new Qe(t)).minus(1).multipliedBy(eu).toNumber()}i(za,"getPercentageChange");function gu(t,e){let o=xn(t),n=dt(t),r=dt(e);if(!o||!n||!r)return!1;let a=za(n.toString(),r.toString());return iu.some(({threshold:s,minInput:l})=>a<=s&&o.isGreaterThanOrEqualTo(l))}i(gu,"isOutputAmountChangedExcessively");function bu(t,e,o){let n=t.validationStatus,r=mo({filter:"required",quote:t});return e.sort((s,l)=>r.indexOf(s.chain)-r.indexOf(l.chain)).flatMap(s=>su(s,n)||[]).filter(s=>!s.ok).map(s=>{let l=s.asset.symbol,c=P(new Qe(s.currentAmount.amount).shiftedBy(-s.currentAmount.decimals),8,8),p=P(new Qe(s.requiredAmount.amount).shiftedBy(-s.requiredAmount.decimals),8,8),u="";return s.reason==="FEE"&&(u=yt.t(" for network fee")),s.reason==="INPUT_ASSET"&&(u=yt.t(" for swap")),s.reason==="FEE_AND_INPUT_ASSET"&&(u=yt.t(" for input and network fee")),yt.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:ut(s.asset.blockchain,o)}})})}i(bu,"generateBalanceWarnings");function En(t){return!!t&&t.networkStatus!==null&&t.networkStatus!==Qr.NetworkChanged}i(En,"isNetworkStatusInWarningState");function xu(t,e){let o="bellow button or",n=t.extraMessage,r=t.extraMessageDetail;if(t.networkStatusExtraMessageDetail?.includes(o)&&(t.networkStatusExtraMessageDetail=t.networkStatusExtraMessageDetail.replace(o,"")),En(e))switch(n=t.networkStatusExtraMessage||"",r=t.networkStatusExtraMessageDetail||"",e?.networkStatus){case Qr.WaitingForConnectingWallet:n=n||yt.t("Waiting for connecting wallet");break;case Qr.WaitingForQueue:n=n||yt.t("Waiting for other running tasks to be finished");break;case Qr.WaitingForNetworkChange:n=n||yt.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(xu,"getSwapMessages");function Eu(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(Eu,"getLastConvertedTokenInFailedSwap");function Iu(t){return t.status==="failed"}i(Iu,"shouldRetrySwap");function Au(t,e,o,n,r,a){if(!n||t)return!0;let s=mo({filter:"all",quote:n}),l=mo({filter:"required",quote:n}),c=s.every(m=>r.some(h=>h.chain===m)),p=l.every(m=>r.some(h=>h.chain===m)),u=o&&a?_o(a,o):!1;return!e&&!c||e&&!o||e&&!!o&&(!u||!p)}i(Au,"isConfirmSwapDisabled");function Nu(t,e){return t.blockchain===e.blockchain&&t.symbol===e.symbol&&t.address===e.address}i(Nu,"isTokensIdentical");var Hr=i((t,e)=>t?.usdPrice?new Ze(e||le).multipliedBy(t?.usdPrice||0):null,"getUsdValue"),O=zo(wC()(bC(t=>({fromBlockchain:null,fromToken:null,inputAmount:"",outputAmount:null,inputUsdValue:new Ze(0),outputUsdValue:new Ze(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=le,a=o.inputUsdValue;return fn(o.inputAmount)?(e&&(n=e?.outputAmount?new Ze(e?.outputAmount):null,a=xn(e)??le,r=dt(e)??le),{selectedQuote:e,...!!e&&{outputAmount:n,outputUsdValue:r,inputUsdValue:a}}):{}}),resetAlerts:()=>t(()=>({error:null,warning:null})),resetQuote:()=>t(()=>({selectedQuote:null,outputAmount:null,outputUsdValue:new Ze(0),quotes:null,refetchQuote:!0,error:null,warning:null})),setFromBlockchain:e=>{t(o=>o.fromBlockchain?.name===e?.name?{}:{fromBlockchain:e,inputUsdValue:new Ze(0),...o.fromToken&&{selectedQuote:null,fromToken:null,outputAmount:null,outputUsdValue:new Ze(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:Hr(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 Ze(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 Ze(0),selectedQuote:null},...!!o.fromToken&&{inputUsdValue:Hr(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:Hr(n??null,s),outputUsdValue:new Ze(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?Hr(e.toToken,e.outputAmount?.toString()||""):new Ze(0)})),resetFromBlockchain:()=>t(()=>({fromToken:null,fromBlockchain:null,outputUsdValue:new Ze(0),inputUsdValue:new Ze(0),inputAmount:"",outputAmount:null,selectedQuote:null})),resetToBlockchain:()=>t(()=>({toToken:null,toBlockchain:null,outputAmount:null,outputUsdValue:new Ze(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})})))),Bu=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 Wu(){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,m=y().fetchStatus,h=y().blockchains(),{findToken:d}=y(),{setAffiliateRef:f,setAffiliatePercent:g,setAffiliateWallets:C}=y(),k=u?.from?.tokens,S=u?.from?.blockchains,T=u?.to?.tokens,w=u?.to?.blockchains,E=qr(void 0),B=qr(void 0),I=qr(void 0),x=qr(void 0);Ko(()=>{typeof u.amount<"u"&&t(u.amount.toString())},[u?.amount]),Ko(()=>{if(m==="success"){r();let b=h.find(M=>M.name===u?.from?.blockchain),v=u?.from?.token,A=v&&d(v);(b||!b&&I.current)&&n(b??null),A?a({token:A,meta:{blockchains:h}}):!A&&E.current&&a({token:null}),I.current=u?.from?.blockchain,E.current=u?.from?.token}},[u?.from?.token?.symbol,u?.from?.token?.address,u?.from?.token?.blockchain,u?.from?.blockchain,m]),Ko(()=>{Sa(s,k)&&a({token:null}),Ca(c,S)&&n(null)},[k,S]),Ko(()=>{Sa(l,T)&&a({token:null}),Ca(p,w)&&o(null)},[T,w]),Ko(()=>{if(m==="success"){r();let b=h.find(M=>M.name===u?.to?.blockchain),v=u?.to?.token,A=v&&d(v);(b||!b&&x.current)&&o(b??null),A?e({token:A,meta:{blockchains:h}}):!A&&B.current&&e({token:null}),x.current=u?.to?.blockchain,B.current=u?.to?.token}},[u?.to?.token?.symbol,u?.to?.token?.address,u?.to?.token?.blockchain,u?.to?.blockchain,m]),Ko(()=>{f(u?.affiliate?.ref??null),g(u?.affiliate?.percent??null),C(u?.affiliate?.wallets??null)},[u?.affiliate?.ref,u?.affiliate?.percent,u?.affiliate?.wallets])}i(Wu,"useSyncStoresWithConfig");import{useEffect as Ka,useRef as xC}from"react";import{useInRouterContext as EC,useLocation as IC,useSearchParams as AC}from"react-router-dom";function Ga(t,e){let o=t.split("--");return{blockchain:e.name,address:o?.[1]||null,symbol:o[0]}}i(Ga,"convertTokenSearchParamToAsset");function Va(t){if(t)return`${t.symbol}${t.address?`--${t.address}`:""}`}i(Va,"tokenToSearchParam");function Xa(){let t=IC(),[e,o]=AC(),{fromBlockchain:n,toBlockchain:r,fromToken:a,toToken:s,inputAmount:l,setFromBlockchain:c,setToBlockchain:p,setFromToken:u,setToToken:m,setInputAmount:h}=O(),d=y().fetchStatus,f=y().blockchains(),g=EC(),{updateIframe:C,updateCampaignMode:k}=y(),S=y().isInCampaignMode(),T=xC(),{findToken:w}=y(),E=i(()=>{let I={};for(let[L,H]of e.entries())L.startsWith("utm_")&&(I[L]=H);let x=e.get("fromAmount"),b=e.get("fromBlockchain"),v=e.get("fromToken"),A=e.get("toBlockchain"),M=e.get("toToken"),_=e.get("autoConnect"),j=e.get("clientUrl"),R=e.get("liquiditySources"),X=e.get("blockchain");return{fromAmount:x,fromBlockchain:b,fromToken:v,toBlockchain:A,toToken:M,autoConnect:_,clientUrl:j,liquiditySources:R,utmQueryParams:I,blockchain:X}},"getUrlSearchParams"),B=i(I=>{for(let x in I)I[x]||delete I[x];o(I,{replace:!0})},"updateUrlSearchParams");Ka(()=>{let{autoConnect:I,clientUrl:x,utmQueryParams:b,blockchain:v}=E();g&&d==="success"&&B({fromBlockchain:n?.name,fromToken:Va(a),toBlockchain:r?.name,toToken:Va(s),fromAmount:l,autoConnect:I??void 0,clientUrl:x??void 0,blockchain:v??void 0,liquiditySources:S?T.current:void 0,...b})},[t.pathname,l,n,a,r,s,S]),Ka(()=>{if(!g)return;let I=E();if(!T.current&&I.liquiditySources&&(T.current=I.liquiditySources),I.fromAmount&&h(I.fromAmount),d==="success"){let x=f.find(M=>M.name===I.fromBlockchain),b=I.fromToken&&x?w(Ga(I.fromToken,x)):void 0,v=f.find(M=>M.name===I.toBlockchain),A=I.toToken&&v?w(Ga(I.toToken,v)):void 0;x&&(c(x),b&&u({token:b,meta:{blockchains:f}})),v&&(p(v),A&&m({token:A,meta:{blockchains:f}}))}},[d]),Ka(()=>{let{clientUrl:I,liquiditySources:x}=E();C("clientUrl",I||void 0),k("liquiditySources",x?.split(",")??void 0)},[])}i(Xa,"useSyncUrlAndStore");import{i18n as Jo}from"@lingui/core";import{Alert as Qk,Button as Hk,darkTheme as qk,Divider as ws,DoneIcon as Gk,styled as Vk,TextField as Kk,Typography as jk}from"@rango-dev/ui";import Ue,{useState as Xk}from"react";import{useNavigate as Yk,useSearchParams as Zk}from"react-router-dom";import{ChevronRightIcon as NC,Divider as Du,Image as BC,Typography as $u}from"@rango-dev/ui";import St from"react";import{darkTheme as Lu,styled as Ya}from"@rango-dev/ui";var Mu=Ya("div",{display:"flex",justifyContent:"space-between",width:"100%",height:"$40",padding:"$4 $10",borderRadius:"$sm",cursor:"pointer",alignItems:"center",backgroundColor:"$neutral300",[`.${Lu} &`]:{backgroundColor:"$neutral400"},"&:hover":{backgroundColor:"$secondary100",[`.${Lu} &`]:{backgroundColor:"$neutral500"}},variants:{disabled:{true:{cursor:"default","&:hover":{borderColor:"$neutral300","& svg":{color:"$neutral700"}}}}}}),Pu=Ya("div",{display:"flex",flexDirection:"column",width:"100%",".title_typography":{textTransform:"capitalize"}}),_u=Ya("div",{display:"flex"});function Za(t){let{onClick:e,value:o,title:n,hasLogo:r,placeholder:a,disabled:s}=t;return St.createElement(Pu,null,St.createElement($u,{size:"large",variant:"label"},n),St.createElement(Du,{size:10}),St.createElement(Mu,{onClick:s?void 0:e,disabled:s},St.createElement(_u,null,r&&St.createElement(St.Fragment,null,St.createElement(BC,{src:o?.logo,size:16,useAsPlaceholder:!o?.logo,type:"circular"}),St.createElement(Du,{size:4,direction:"horizontal"})),St.createElement($u,{className:"title_typography",size:"medium",variant:"label"},o?.name||a)),St.createElement(NC,{size:12,color:"black"})))}i(Za,"BlockchainSelectorButton");import{i18n as es}from"@lingui/core";import{Button as MC,Divider as Hu,MessageBox as PC}from"@rango-dev/ui";import Yt,{useEffect as qu,useState as ts}from"react";import{i18n as Gr}from"@lingui/core";import{Button as Qu,Divider as To,ExternalLinkIcon as WC,Image as LC,Typography as Xo}from"@rango-dev/ui";import ye from"react";var Fu="https://blog.rango.exchange/understanding-the-risks-of-using-custom-token-contract-addresses-96022308eca4";function Ou(t,e){if(e.type==="COSMOS")return"";let o=e.info?.addressUrl;return!o||!t?"":o.replace("{wallet}",t)}i(Ou,"generateExplorerLink");import{darkTheme as jo,styled as Uu}from"@rango-dev/ui";var Ja=Uu("a",{textDecoration:"none",color:"$colors$neutral700",[`.${jo} &`]:{color:"$colors$neutral900"},"& svg":{marginLeft:"$4",color:"$colors$neutral700",[`.${jo} &`]:{color:"$colors$neutral900"}},variants:{hasHover:{true:{"&:hover":{color:"$colors$secondary550",[`.${jo} &`]:{color:"$colors$secondary500"},"& svg":{color:"$colors$secondary550",[`.${jo} &`]:{color:"$colors$secondary500"}}}},false:{}}}}),zu=Uu("div",{display:"flex",justifyContent:"center",flexDirection:"column",alignItems:"center",textAlign:"center","& ._blockchain-name, & ._coin-source":{color:"$colors$neutral600",[`.${jo} &`]:{color:"$colors$neutral800"}},"& ._coin-source-name, & ._custom-token-description":{color:"$colors$neutral700",[`.${jo} &`]:{color:"$colors$neutral900"}}});function Ra(t){let{open:e,onClose:o,token:n,onExit:r,onSubmitClick:a,blockchain:s}=t,l=Ou(n.address,s),c=i(()=>window.open(Fu,"_blank"),"onClickLearnMore");return ye.createElement(J,{open:e,dismissible:!0,onClose:o,onExit:r,container:N()},ye.createElement(zu,null,ye.createElement(LC,{src:n.image===""?gr:n.image,size:45,type:"circular"}),ye.createElement(To,{size:4}),ye.createElement(Xo,{variant:"title",size:"medium"},n.symbol),ye.createElement(Xo,{variant:"body",size:"small",className:"_blockchain-name"},s.displayName),ye.createElement(To,{size:4}),ye.createElement(Xo,{variant:"body",size:"medium"},l?ye.createElement(Ja,{hasHover:!0,href:l,target:"_blank",rel:"nofollow noreferrer"},n.address,ye.createElement(WC,{size:12,color:"gray"})):ye.createElement(Ja,null,n.address)),ye.createElement(To,{size:4}),n.coinSource&&ye.createElement(Xo,{className:"_coin-source",variant:"body",size:"xsmall"},Gr.t("via")," ",ye.createElement(Xo,{className:"_coin-source-name",variant:"body",size:"xsmall"},n.coinSource)),ye.createElement(To,{size:"32"}),ye.createElement(Xo,{size:"medium",variant:"body",className:"_custom-token-description"},Gr.t("This token is not part of our verified token list. please verify its source and make sure to understand all associated risks before proceeding."))),ye.createElement(To,{size:40}),ye.createElement(To,{size:10}),ye.createElement(Qu,{id:"widget-custom-token-modal-import-btn",variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:a},Gr.t("Import Anyway")),ye.createElement(To,{size:10}),ye.createElement(Qu,{id:"widget-custom-token-modal-learn-more-btn",variant:"outlined",size:"large",type:"primary",fullWidth:!0,onClick:c},Gr.t("Learn More")))}i(Ra,"CustomTokenModal");function In(t){let{token:e,blockchain:o,error:n,address:r,fetchCustomToken:a,onCloseErrorModal:s,onImport:l,onExitErrorModal:c,onExitImportModal:p}=t,{setCustomToken:u}=y(),[m,h]=ts(!1),[d,f]=ts(!1),[g,C]=ts(!1),k=i(()=>{o&&a?.({blockchain:o.name,tokenAddress:r})},"getCustomToken"),S=i(()=>{n?.type!=="network-error"&&s?.(),h(!1)},"closeErrorModal"),T=i(()=>{C(!0),S()},"handleErrorModalButtonClick"),w=i(()=>{g&&n?.type==="network-error"&&(C(!1),k()),c()},"handleExit"),E=i(()=>{e&&(u(e),l())},"handleSubmit");return qu(()=>{n&&h(!0)},[n]),qu(()=>{o&&e&&f(!0)},[o,e]),Yt.createElement(Yt.Fragment,null,Yt.createElement(J,{open:m,dismissible:!0,onClose:S,onExit:w,container:N()},Yt.createElement(PC,{title:n?.title??"",type:"error",description:n?.message||es.t("Failed Network, Please retry.")},Yt.createElement(Hu,{size:40}),Yt.createElement(Hu,{size:10}),Yt.createElement(MC,{id:`widget-add-custom-token-${n?.type==="network-error"?"retry":"add-another"}-btn`,variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:T},n?.type==="network-error"?es.t("Retry"):es.t("Add another custom token")))),o&&e&&Yt.createElement(Ra,{blockchain:o,token:e,onSubmitClick:E,onClose:()=>f(!1),open:d,onExit:p}))}i(In,"ImportCustomToken");import{useManager as $k}from"@rango-dev/queue-manager-react";import{BottomLogo as Fk,Divider as um,Header as Ok}from"@rango-dev/ui";import be,{useEffect as Rr,useRef as mm,useState as dm}from"react";import{useRef as _C}from"react";function Vr(){return window.self!==window.top}i(Vr,"isAppLoadedIntoIframe");function os(){let t=_C(null),{iframe:e}=y(),o=Vr()&&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(os,"useIframe");import{useNavigate as DC}from"react-router-dom";function Oe(){let t=DC();return()=>t(-1)}i(Oe,"useNavigateBack");import{createTheme as cs,darkTheme as YC,lightTheme as ZC}from"@rango-dev/ui";import{useEffect as JC,useState as RC}from"react";import{theme as jC,darkColors as XC}from"@rango-dev/ui";import ss from"react";function $C(t){return t.startsWith("#")&&(t=t.slice(1)),t.length===3?`#${t.split("").reduce(function(n,r){return n+r+r},"")}`:`#${t}`}i($C,"expandShortHexColor");function FC(t){return/[0-9]+$/.test(t)}i(FC,"isOverridingColor");function OC(t,e){return t.padStart(e,"0")}i(OC,"pad");function ns(t){let e=Math.min(Math.max(Math.round(t),0),255);return OC(e.toString(16),2)}i(ns,"intToHex");function UC(t){return`#${ns(t.red)}${ns(t.green)}${ns(t.blue)}`}i(UC,"rgbToHex");function zC(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(zC,"hexToRGB");function QC(t,e){let o=1-.11*e;return{red:t.red*o,green:t.green*o,blue:t.blue*o}}i(QC,"generateShade");function HC(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(HC,"generateTint");function qC(t){return Gu(t,QC)}i(qC,"calculateShades");function GC(t){return Gu(t,HC)}i(GC,"calculateTints");function Gu(t,e){let o=zC(t),n=[];for(let r=1;r<9;r++)n.push(UC(e(o,r)));return n}i(Gu,"calculateColors");function rs(t,e,o){let a=GC(t).reverse().concat(t),s=qC(t),l=a.concat(s),c={},p=l.length;for(let u=0;u<p;u++){let m=100+(o?p-1-u:u)*50;c[`${e}${m}`]=l[u]}return c}i(rs,"createTintsAndShades");function is(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=$C(a);Object.assign(n,rs(c,r,s))}}return{...n,...e}}i(is,"expandToGenerateThemeColors");var Vu=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=Vu(o%52)+e;return Vu(o%52)+e},"toAlphabeticName"),KC=i((t,e)=>{let o=e.length;for(;o;)t=t*33^e.charCodeAt(--o);return t},"toPhash"),as=i(t=>VC(KC(5381,JSON.stringify(t))>>>0),"toHash");function ls(t){let e=jC.colors,o={...e,...XC},n,r;if(t?.light){let s={colors:is(e,t.light)};n={id:`${ya}-light-${as(s)}`,tokens:s}}if(t?.dark){let s={colors:is(o,t.dark,{reverseNeutralRange:!0})};r={id:`${ya}-dark-${as(s)}`,tokens:s}}return{light:n,dark:r}}i(ls,"customizedThemeTokens");function Ku(t,e){if(t.length<=1)return t.map(({element:n,key:r})=>ss.cloneElement(n,{key:r}));let o=[];return t.forEach((n,r)=>{let{element:a,key:s}=n;if(o.push(ss.cloneElement(a,{key:s})),r<t.length-1){let l=`divider-${r}`;o.push(ss.cloneElement(e,{key:l}))}}),o}i(Ku,"joinList");function ju(){return window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches}i(ju,"doesWindowPreferDarkColorScheme");function Yo(t){let{colors:e,fontFamily:o=$c,borderRadius:n=ip,secondaryBorderRadius:r=ap}=t,[a,s]=RC(ju()?"dark":"light"),{theme:l}=y(),{dark:c,light:p}=ls(e),u=cs({shadows:t.shadows||{},radii:{primary:`${n}px`,secondary:`${r}px`},fonts:{widget:o}}),m=[u.className,ZC.className],h=[u.className,YC.className];if(p){let f=cs(p.id,p.tokens);m.push(f.className)}if(c){let f=cs(c.id,c.tokens);h.push(f.className)}return JC(()=>{let f=i(g=>{g.matches?s("dark"):s("light")},"switchThemeListener");return ju()&&s("dark"),window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",f),()=>{window.matchMedia("(prefers-color-scheme: dark)").removeEventListener("change",f)}},[]),{activeTheme:i(()=>{let f=m.join(" "),g=h.join(" ");return l==="auto"?a==="dark"?g:f:l==="dark"?g:f},"getActiveTheme"),mode:l==="auto"?a:l}}i(Yo,"useTheme");var ft=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 Xu}from"@lingui/core";import{Alert as ek,Button as tk}from"@rango-dev/ui";import Yu from"react";function ps(t){return Yu.createElement(ek,{action:Yu.createElement(tk,{id:"widget-active-tab-btn",onClick:t.onActivateTab,variant:"contained",size:"xxsmall",type:"warning"},Xu.t("Activate this tab")),type:"warning",variant:"alarm",title:Xu.t("Another tab is open and handles transactions.")})}i(ps,"ActivateTabAlert");import{i18n as us}from"@lingui/core";import{Button as ok,Divider as nk,MessageBox as rk}from"@rango-dev/ui";import Kr from"react";function ms(t){let{open:e,onClose:o,onConfirm:n}=t;return Kr.createElement(J,{open:e,dismissible:!0,onClose:o,container:N()},Kr.createElement(rk,{title:us.t("Activate current tab"),type:"warning",description:us.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.")},Kr.createElement(nk,{size:20}),Kr.createElement(ok,{id:"widget-modal-confirm-activate-tab-btn",variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:n},us.t("Confirm"))))}i(ms,"ActivateTabModal");import{ChevronLeftIcon as ik}from"@rango-dev/ui";import Zu from"react";function ds(t){return Zu.createElement(Et,{id:"widget-header-back-icon-btn",variant:"ghost",size:"small",onClick:t.onClick},Zu.createElement(ik,{color:"black",size:16}))}i(ds,"BackButton");import{i18n as ak}from"@lingui/core";import{Button as sk,Typography as lk}from"@rango-dev/ui";import fs from"react";function gs(t){return fs.createElement(jt,null,fs.createElement(sk,{id:"widget-header-cancel-btn",variant:"ghost",onClick:t.onClick,size:"xsmall"},fs.createElement(lk,{variant:"label",size:"medium",color:"error500"},ak.t("Cancel"))))}i(gs,"CancelButton");import{i18n as ck}from"@lingui/core";import{Image as pk,Tooltip as uk,WalletIcon as mk}from"@rango-dev/ui";import vo from"react";function hs(t){let{list:e}=ht(),o=e.filter(r=>r.state==="connected"),n=o.length?vo.createElement("div",{className:Pp()},o.map(r=>vo.createElement(Ar,{key:r.title},vo.createElement(pk,{src:r.image,size:14})))):ck.t("Connect Wallet");return vo.createElement(uk,{container:t.container,side:"bottom",content:n},vo.createElement(Et,{id:"widget-header-wallet-icon-btn",variant:"ghost",size:"small",onClick:t.onClick},t.isConnected&&vo.createElement(Bp,null),vo.createElement(mk,{size:18,color:"black"})))}i(hs,"WalletButton");import{i18n as Xr}from"@lingui/core";import{NotificationsIcon as Ak,Popover as Nk,SettingsIcon as Bk,Tooltip as Yr,TransactionIcon as Wk}from"@rango-dev/ui";import Be from"react";import{Notifications as hk}from"@rango-dev/ui";import yk from"react";import{useNavigate as Sk}from"react-router-dom";import{create as dk}from"zustand";import{persist as fk,subscribeWithSelector as gk}from"zustand/middleware";var we=zo(dk()(fk(gk((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 ys(){let t=Sk(),{getNotifications:e,clearNotifications:o}=we(),n=e(),r=y().blockchains(),{findToken:a}=y();return yk.createElement(hk,{list:n,getBlockchainImage:l=>Ac(l,r),getTokenImage:l=>a(l)?.image,onClickItem:i(l=>{t(`${F.swaps}/${l}`)},"onClickItem"),onClearAll:o})}i(ys,"NotificationContent");import{useManager as Ck}from"@rango-dev/queue-manager-react";import{InProgressIcon as kk}from"@rango-dev/ui";import Ju from"react";var Tk=i(()=>{let{manager:t}=Ck();return ft(t).map(({swap:o})=>o).find(o=>o.status==="running")?Ju.createElement(Mp,null,Ju.createElement(kk,{color:"info",size:6})):null},"InProgressTransactionBadge"),Ru=Tk;import{EventSeverity as vk}from"@rango-dev/queue-manager-rango-preset";import{Typography as wk}from"@rango-dev/ui";import em from"react";function tm(){let{getNotifications:t}=we(),e=t(),o=e.length,n=!!e.find(r=>r.event.messageSeverity===vk.WARNING);return o?em.createElement(Wp,{isSever:n},em.createElement(wk,{variant:"body",size:"xsmall",color:"$background"},o)):null}i(tm,"NotificationsBadge");import{RefreshProgressButton as bk}from"@rango-dev/ui";import Ss,{useEffect as xk,useState as om}from"react";var Ek=1e3,nm=60,Ik=100;function jr({onClick:t}){let[e,o]=om(0),[n,r]=om(!1),a=i(c=>{document.hidden&&c&&s(c)},"handleVisibilityChange");xk(()=>{let c;return t?c=window.setInterval(()=>{o(p=>p+1),e===nm&&l()},Ek):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 Ss.createElement(Et,{id:"widget-header-refresh-icon-btn",variant:"ghost",size:"small",style:{paddingTop:0,paddingBottom:0},onClick:l,disabled:!t},Ss.createElement(Lp,{onTransitionEnd:()=>r(!1),isRefetched:n},Ss.createElement(bk,{size:22,color:t?"black":"gray",progress:e/nm*Ik})))}i(jr,"RefreshButton");function wo(t){let{onClickRefresh:e,onClickHistory:o,onClickSettings:n,hidden:r=[],container:a}=t,{config:{features:s}}=y(),l=Ye("notification",s)||r.includes("notifications");return Be.createElement(Be.Fragment,null,!r.includes("refresh")&&Be.createElement(Yr,{container:a||N(),side:"top",content:Xr.t("Refresh")},Be.createElement(jr,{onClick:e})),!l&&Be.createElement(Nk,{align:"end",alignOffset:-88,sideOffset:15,collisionPadding:{right:20,left:20},container:N(),content:Be.createElement(ys,null)},Be.createElement("div",null,Be.createElement(Yr,{container:N(),side:"top",content:Xr.t("Notifications")},Be.createElement(Et,{id:"widget-header-notification-icon-btn",size:"small",variant:"ghost"},Be.createElement(Ak,{size:18,color:"black"}),Be.createElement(tm,null))))),!r.includes("settings")&&Be.createElement(Yr,{container:N(),side:"top",content:Xr.t("Settings")},Be.createElement(Et,{id:"widget-header-setting-icon-btn",size:"small",variant:"ghost",onClick:n},Be.createElement(Bk,{size:18,color:"black"}))),!r.includes("history")&&Be.createElement(Yr,{container:N(),side:"top",content:Xr.t("History")},Be.createElement(Et,{id:"widget-header-history-icon-btn",size:"small",variant:"ghost",onClick:o},Be.createElement(Wk,{size:18,color:"black"}),Be.createElement(Ru,null))))}i(wo,"HeaderButtons");import{i18n as Cs}from"@lingui/core";import{Divider as im,MessageBox as Pk,RefreshIcon as _k}from"@rango-dev/ui";import Zo from"react";import{Button as Lk,styled as Mk}from"@rango-dev/ui";var rm=Mk(Lk,{"& span":{display:"flex",justifyContent:"center",alignItems:"center"}});function ks(t){let{open:e,onClose:o}=t;return Zo.createElement(J,{open:e,dismissible:!0,onClose:o,container:N()},Zo.createElement(Pk,{title:Cs.t("Something went wrong"),type:"error",description:Cs.t("Something went wrong. Please refresh the app.")},Zo.createElement(im,{size:30}),Zo.createElement(rm,{variant:"outlined",size:"large",type:"primary",fullWidth:!0,onClick:()=>location.reload()},Zo.createElement(_k,{size:20,color:"primary"}),Zo.createElement(im,{size:4,direction:"horizontal"}),Cs.t("Refresh"))))}i(ks,"RefreshModal");function Ts(t){let e=t.target;if(e){let o=e.scrollTop,n=N();o>1?n.classList.add("rng-scrolled"):n.classList.remove("rng-scrolled")}}i(Ts,"onScrollContentAttachStatusToContainer");import{css as Dk,styled as Zr}from"@rango-dev/ui";var am="700px",Jr=Dk({borderRadius:"$primary",display:"flex",flexDirection:"column",overflow:"hidden",boxShadow:"$mainContainer"}),sm=Zr("div",{position:"relative",width:"100vw",minWidth:"300px",maxWidth:"390px",backgroundColor:"$background",variants:{height:{auto:{height:"auto",maxHeight:am},fixed:{height:am}},showBanner:{true:{overflow:"visible"}}}}),lm=Zr("div",{position:"relative",overflow:"hidden",flexGrow:1,display:"flex",flexDirection:"column",padding:0,overflowY:"auto"}),cm=Zr("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"}}}),pm=Zr("div",{width:"100%",position:"absolute",bottom:"-$10",transform:"translateY(100%)",overflow:"hidden"});function oe(t){let{connectHeightObserver:e,disconnectHeightObserver:o}=os(),{children:n,header:r,footer:a,height:s="fixed"}=t,{fetchStatus:l,connectedWallets:c,config:{__UNSTABLE_OR_INTERNAL__:p}}=y(),[u,m]=dm(!1),{config:{features:h,theme:d}}=y(),{watermark:f}=ne(),g=f==="FULL",{activeTheme:C}=Yo(d||{}),[k,S]=dm(!1),T=Ye("connectWalletButton",h),{isActiveTab:w,tabManagerInitiated:E,showActivateTabModal:B,setShowActivateTabModal:I,activateCurrentTab:x}=ne(),b=Oe(),{manager:v}=$k(),M=ft(v).map(({swap:H})=>H).some(H=>H.status==="running"),_=i(()=>x(fo.forceClaim,M),"onActivateTab"),j=i(()=>{r.onWallet?.()},"onConnectWallet"),R=typeof r.hasBackButton>"u"||r.hasBackButton,X=mm(null),L=mm(null);return Rr(()=>{let H=(p?.swapBoxBanner?.routes?.length??0)===0,ae=!!p?.swapBoxBanner?.routes?.some(G=>location.pathname.endsWith(G));S(!!p?.swapBoxBanner&&(H||ae))},[p?.swapBoxBanner?.routes?.toString(),location.pathname]),Rr(()=>(Vr()&&L.current&&e(L.current),()=>{o()}),[]),Rr(()=>(X.current?.addEventListener("scroll",Ts),()=>{X.current?.removeEventListener("scroll",Ts)}),[]),Rr(()=>{m(l==="failed")},[l]),be.createElement(sm,{height:s,id:$e.SWAP_BOX_ID,className:`${C()} ${Jr()}`,ref:L,showBanner:k},be.createElement(Ok,{prefix:R?be.createElement(ds,{onClick:()=>{b(),r.onBack?.()}}):null,title:r.title,suffix:be.createElement(be.Fragment,null,r.suffix,r.onWallet&&!T&&be.createElement(hs,{container:N(),onClick:j,isConnected:!!c?.length}),r.onCancel&&be.createElement(gs,{onClick:r.onCancel}))}),be.createElement(lm,{ref:X},n),be.createElement(ms,{open:B,onClose:()=>I(!1),onConfirm:_}),be.createElement(cm,null,be.createElement("div",{className:"footer__content"},E&&!w&&be.createElement("div",{className:"footer__alert"},be.createElement(ps,{onActivateTab:_}),be.createElement(um,{size:10})),a),be.createElement(um,{size:12}),be.createElement("div",{className:`footer__logo ${g?"logo__show":"logo__hidden"}`},be.createElement(Fk,null))),k&&be.createElement(pm,null,p?.swapBoxBanner?.element),be.createElement(ks,{open:u,onClose:()=>m(!1)}))}i(oe,"Layout");import{styled as Uk}from"@rango-dev/ui";var fm="$20 $20 $10 $20",An=Uk("div",{padding:fm,overflowY:"auto",flexGrow:1});import{styled as zk}from"@rango-dev/ui";var re=zk("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 Zt}from"@lingui/core";import{useState as vs}from"react";function gm(){let[t,e]=vs(!1),[o,n]=vs(null),[r,a]=vs(null),{findToken:s}=y(),l=y().customTokens(),c=i(()=>{a(null),e(!1),n(null)},"resetState");function p(m,h){switch(m){case"duplicated":return{type:m,title:Zt.t("Duplicate Token"),message:Zt.t("The address you entered is duplicate, please enter a new address.")};case"token-exist":return{type:m,title:Zt.t("Token Already Exists"),message:Zt.t("There's no need to add this token again because it already exists and is supported by us.")};case"not-found":return{type:m,title:Zt.t("Token Not Found"),message:Zt.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:h}})};case"network-error":return{type:m,title:Zt.t("Network error"),message:Zt.t("An error occurred while retrieving token data.")}}}return i(p,"produceErrorMessage"),{fetchCustomToken:i(async({blockchain:m,tokenAddress:h})=>{e(!0);try{if(l.some(k=>k.address?.toLowerCase()===h.toLowerCase())){let k=p("duplicated");n(k);return}let f=await ot().getCustomToken({blockchain:m,address:h});if(!f||!f.token||f.error){let k=p("not-found",m);n(k);return}let g=f.token;if(s({blockchain:g.blockchain,address:g.address,symbol:g.symbol})){let k=p("token-exist");n(k);return}return a({...g,warning:!0})}catch(d){if(d.code==="ERR_BAD_REQUEST"){let f=p("not-found",m);n(f);return}n(p("network-error"));return}finally{e(!1)}},"fetchCustomToken"),token:r,loading:t,error:o,resetState:c}}i(gm,"useFetchCustomToken");var Jk=Vk("div",{display:"flex",justifyContent:"space-between",flexDirection:"column",flex:1,"& ._text-field":{padding:"$4 $10",backgroundColor:"$neutral300",[`.${qk} &`]:{backgroundColor:"$neutral400"},borderRadius:"$sm",height:"$40"}});function hm(){let t=Yk(),[e]=Zk(),o=Oe(),n=y().blockchains(),r=e.get("blockchain")||"",a=co(r,n),[s,l]=Xk(""),{fetchCustomToken:c,token:p,loading:u,error:m,resetState:h}=gm(),d=!!a&&_o(a,s),f=!a||!s||!d,g=i(()=>{a&&c({blockchain:r,tokenAddress:s})},"getCustomToken");return Ue.createElement(oe,{header:{title:Jo.t("Add Custom Token")}},Ue.createElement(re,null,Ue.createElement(Jk,null,Ue.createElement("div",null,Ue.createElement(Za,{onClick:()=>t(F.blockchains,{replace:!0}),hasLogo:!!a?.logo,value:a?{name:a.displayName,logo:a.logo}:void 0,title:Jo.t("Select chain"),placeholder:Jo.t("Select chain")}),Ue.createElement(ws,{size:"24"}),Ue.createElement(jk,{size:"large",variant:"label"},Jo.t("Enter Address")),Ue.createElement(ws,{size:10}),Ue.createElement(Kk,{fullWidth:!0,disabled:!a,variant:"contained",placeholder:Jo.t("Enter token address"),size:"large",value:s,suffix:!!s&&d&&Ue.createElement(Gk,{color:"success",size:12}),onChange:C=>l(C.target.value)}),!d&&!!s&&Ue.createElement(Ue.Fragment,null,Ue.createElement(ws,{size:4}),Ue.createElement(Qk,{type:"error",variant:"alarm",title:"Invalid Address"}))),Ue.createElement(Hk,{id:"widget-add-custom-token-import-btn",disabled:f,type:"primary",variant:"contained",loading:u,size:"large",onClick:g},Jo.t("Import"))),Ue.createElement(In,{token:p,blockchain:a??void 0,address:s,error:m??void 0,fetchCustomToken:c,onCloseErrorModal:()=>{m?.type!=="network-error"&&l("")},onImport:o,onExitErrorModal:h,onExitImportModal:h})))}i(hm,"AddCustomTokenPage");import{i18n as Rs}from"@lingui/core";import{useManager as _v}from"@rango-dev/queue-manager-react";import{Alert as Dv,Button as $v,css as tl,Divider as el,IconButton as uf,styled as Fv,Typography as Ov,WalletIcon as Uv}from"@rango-dev/ui";import Le,{useEffect as Ii,useLayoutEffect as zv,useRef as Qv,useState as zn}from"react";import{useNavigate as Hv}from"react-router-dom";import{i18n as bo}from"@lingui/core";import{Alert as wT,BalanceErrors as bT,Button as qm,ChevronLeftIcon as xT,Divider as Ws,MessageBox as ET,Typography as Ls}from"@rango-dev/ui";import te,{useCallback as IT,useEffect as Gm,useMemo as AT,useState as tn}from"react";import{useNavigate as NT}from"react-router-dom";import{i18n as Is}from"@lingui/core";import{Alert as nT,ChevronDownIcon as rT,CloseIcon as iT,Divider as wm,IconButton as bm,PasteIcon as aT,Typography as sT,WalletIcon as lT}from"@rango-dev/ui";import We,{useEffect as cT,useRef as pT}from"react";import ni,{useRef as tT}from"react";import*as Ro from"@radix-ui/react-collapsible";import{keyframes as ym,styled as ei}from"@rango-dev/ui";var bs=300,Rk=ym({from:{height:0},to:{height:"var(--radix-collapsible-content-height)"}}),eT=ym({from:{height:"var(--radix-collapsible-content-height)"},to:{height:0}}),Sm=ei(Ro.Root,{borderRadius:"$sm",overflow:"hidden",variants:{selected:{true:{outlineWidth:1,outlineColor:"$secondary500",outlineStyle:"solid"}}}}),xs=ei(Ro.Trigger,{padding:"$0",border:"none",outline:"none",width:"100%",backgroundColor:"transparent",fontFamily:"inherit",cursor:"pointer"}),ti=ei(Ro.Content,{overflow:"hidden",variants:{open:{true:{animation:`${Rk} ${bs}ms ease-out`},false:{animation:`${eT} ${bs}ms ease-out`}}}}),oi=ei("div",{transition:`all ${bs}ms ease`,display:"flex",alignItems:"center",variants:{orientation:{down:{transform:"rotate(0)"},up:{transform:"rotate(180deg)"}}}});function ri(t){let{open:e,hasSelected:o,onOpenChange:n,children:r,onClickTrigger:a,trigger:s,triggerAnchor:l}=t,c=tT(null);return ni.createElement(Sm,{ref:c,className:"collapsible_root",selected:o&&e,open:e,onOpenChange:n},l==="top"&&ni.createElement(xs,{className:"collapsible_trigger",onClick:a},s),ni.createElement(ti,{className:"collapsible_content",open:e},r),l==="bottom"&&ni.createElement(xs,{className:"collapsible_trigger",onClick:a},s))}i(ri,"CustomCollapsible");import{darkTheme as Cm,styled as Es,TextField as oT}from"@rango-dev/ui";var km=Es("div",{padding:"$10 $0","& .button__content":{display:"flex",alignItems:"center"},"& .alarms":{paddingTop:"$5"},"& .collapsible_content":{backgroundColor:"$neutral100"},"& .collapsible_root":{backgroundColor:"$neutral100"}}),Tm=Es(oT,{backgroundColor:"$neutral100",padding:"$15"}),vm=Es("div",{width:"100%",borderRadius:"$sm",display:"flex",padding:"$15",justifyContent:"space-between",alignItems:"center",$$color:"$colors$neutral100",[`.${Cm} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",borderBottomRightRadius:"0",borderBottomLeftRadius:"0","&:focus-visible":{$$background:"$colors$secondary100",[`.${Cm} &`]:{$$background:"$colors$info700"},backgroundColor:"$$background",outline:0}});function xm(t){let{blockchain:e,handleOpenChange:o,open:n}=t,{customDestination:r,setCustomDestination:a}=O(),{config:s}=y(),l=y().blockchains(),c=mr(e.name,l),p=pT(null),u=s?.defaultCustomDestinations?.[e.name],m=navigator?.userAgent.includes("Firefox"),d=n&&!!r&&e&&!_o(e,r),f=i(()=>{a("")},"handleClear"),g=i(async k=>{if(k.preventDefault(),navigator.clipboard!==void 0){let S=await navigator.clipboard.readText();a(S),p?.current?.focus()}},"handlePaste"),C=i(()=>r?We.createElement(bm,{id:"widget-custom-destination-close-icon-btn",onClick:f,variant:"ghost"},We.createElement(iT,{size:12,color:"gray"})):m?null:We.createElement(bm,{id:"widget-custom-destination-paste-icon-btn",onClick:g,variant:"ghost"},We.createElement(aT,{size:16})),"renderSuffix");return cT(()=>{!!u&&r===null&&(a(u),o(!0))},[u]),We.createElement(km,null,We.createElement(ri,{onOpenChange:o,hasSelected:!0,open:n,triggerAnchor:"top",trigger:We.createElement(vm,null,We.createElement("div",{className:"button__content"},We.createElement(lT,{size:18,color:"info"}),We.createElement(wm,{size:4,direction:"horizontal"}),We.createElement(sT,{variant:"label",size:"medium",color:n?"$neutral600":void 0},Is.t("Send to a different address"))),We.createElement(oi,{orientation:n?"up":"down"},We.createElement(rT,{size:10,color:"secondary"}))),onClickTrigger:()=>o(!n)},We.createElement(Tm,{ref:p,style:{padding:0,paddingRight:r?"8px":"5px"},autoFocus:!r,placeholder:Is.t("Enter {blockchainName} address",{blockchainName:c}),value:r||"",suffix:C(),onChange:k=>{let S=k.target.value;a(S)}})),d&&We.createElement(We.Fragment,null,We.createElement(wm,{size:4}),We.createElement(nT,{variant:"alarm",type:"error",title:Is.t({values:{destination:r},id:"Address {destination} doesn't match the blockchain address pattern."})})))}i(xm,"CustomDestination");import{css as uT,darkTheme as As,IconButton as mT,styled as Dt}from"@rango-dev/ui";var Em=Dt("div",{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center"}),Im=Dt("div",{display:"flex",justifyContent:"space-evenly",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5",height:"100%"}),dT=Dt("button",{borderRadius:"$xm",padding:"$10",border:"0",display:"flex",justifyContent:"center",$$color:"$colors$neutral100",[`.${As} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",alignItems:"center",cursor:"pointer",width:110,position:"relative","&:hover":{$$color:"$colors$secondary100",[`.${As} &`]:{$$color:"$colors$neutral100"},backgroundColor:"$$color"},"&:focus-visible":{$$color:"$colors$secondary100",[`.${As} &`]:{$$color:"$colors$info700"},backgroundColor:"$$color",outline:0},variants:{selected:{true:{outlineWidth:1,outlineColor:"$secondary",outlineStyle:"solid"}}}}),Am=Dt(dT,{alignSelf:"stretch",minHeight:"93px"}),Nm=Dt("div",{padding:"$20 $20 $15 $20",display:"flex",justifyContent:"center",alignItems:"center",backgroundColor:"$neutral200",position:"relative",width:"100%"}),Bm=Dt(mT,{position:"absolute",left:"$20"}),Wm=Dt("div",{paddingTop:"$20"}),Lm=uT({display:"flex",justifyContent:"space-evenly",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5",height:"100%"}),Mm=Dt("div",{display:"flex"}),Pm=Dt("div",{overflow:"visible",width:"100%"});import{i18n as Um}from"@lingui/core";import{warn as ST}from"@rango-dev/logging-core";import{Divider as CT,SelectableWallet as kT,Typography as zm,WalletState as Qm}from"@rango-dev/ui";import Je,{useEffect as Hm,useState as Bn}from"react";import{Image as hT,MessageBox as yT}from"@rango-dev/ui";import Nn from"react";import{keyframes as fT,styled as Ns}from"@rango-dev/ui";var _m=Ns("div",{position:"relative"}),gT=fT({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}),Dm=Ns("div",{position:"absolute",border:"2px solid rgba(0, 0, 0, 0.1)",borderTop:"2px solid $info500",borderRadius:"$lg",width:"$45",height:"$45",animation:`${gT} 1s linear infinite`,top:0,bottom:0,right:0,left:0}),$m=Ns("div",{"& img":{borderRadius:"50%"}});import{i18n as en}from"@lingui/core";function Fm(t,e){switch(t){case"in-progress":return{type:"loading",title:en.t({id:"Add {blockchainDisplayName} Chain",values:{blockchainDisplayName:e}}),description:en.t({id:"Please approve the experimental chain pop-up in your wallet.",values:{blockchainDisplayName:e}})};case"completed":return{type:"success",title:en.t({id:"{blockchainDisplayName} Chain Added",values:{blockchainDisplayName:e}}),description:en.t({id:"The {blockchainDisplayName} chain has been successfully added to your wallet.",values:{blockchainDisplayName:e}})};case"rejected":return{type:"error",title:en.t("Request Rejected"),description:en.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(Fm,"generateMessageByStatus");function Om(t){let{status:e,displayName:o,image:n}=t,r=Fm(e,o),a=e=="in-progress";return Nn.createElement(yT,{type:r.type,title:r.title,description:r.description,icon:a?Nn.createElement(_m,null,Nn.createElement($m,null,Nn.createElement(hT,{src:n,size:45})),Nn.createElement(Dm,null)):void 0})}i(Om,"ExperimentalChainStatus");var TT=7,vT=3e3;function Bs(t){let{chain:e,isSelected:o,selectWallet:n,limit:r,onShowMore:a}=t,s=ne.use.isActiveTab(),{blockchains:l,connectedWallets:c}=y(),[p,u]=Bn(),[m,h]=Bn(null),[d,f]=Bn(!1),[g,C]=Bn(null),{suggestAndConnect:k}=ii(),{handleDisconnect:S}=Kt(),{list:T}=ht({chain:e}),[w,E]=Bn(T),B=T.length,I=r&&B-r>0,x=i(async v=>{f(!1),C("in-progress");try{await k(v.walletType,v.chain),C("completed")}catch{C("rejected")}},"addExperimentalChain");Hm(()=>{E(v=>{let A=T.findIndex(M=>o(M.type,e));return I&&A>1?[T[A]].concat(T.filter((M,_)=>_!==A)):v.map(M=>T.find(_=>_.type===M.type)??M)})},[JSON.stringify(T)]);let b=document.getElementById($e.SWAP_BOX_ID);return Hm(()=>{let v=null;return(g==="completed"||g==="rejected")&&(v=setTimeout(()=>C(null),vT)),()=>{v&&clearTimeout(v)}},[g]),Je.createElement(Je.Fragment,null,w.slice(0,r).map(v=>{let A=Rc({connectedWallets:c,walletType:v.type,chain:e}),M=A?xr(A,TT):"",_=wr(l(),e),j=!c.find(ae=>ae.walletType===v.type&&ae.chain===e),R=_&&j&&v.state===Qm.CONNECTED,X=R?Um.t({id:"Add {chain} chain",values:{chain:e}}):M,L=i(async()=>{let ae=v.state===Qm.DISCONNECTED,G=(v.isHub||!!v.needsNamespace)&&!M;ae?u(v):G?(await S(v.type),u(v)):R?(h({walletType:v.type,chain:e,address:A??""}),f(!0)):n({walletType:v.type,chain:e,address:A??""})},"onSelectableWalletClick"),H=m?.chain?mr(m.chain,l()):void 0;return Je.createElement(Je.Fragment,{key:`${v.title}_${H}`},!!m&&Je.createElement(J,{open:!!m&&d,container:b,onClose:()=>{h(null)}},Je.createElement($a,{displayName:H,onConfirm:()=>{x(m)}})),g&&Je.createElement(J,{open:!!g,onClose:C.bind(null,null),container:b},Je.createElement(Om,{status:g,displayName:H,image:v.image}),Je.createElement(CT,{direction:"vertical",size:32})),Je.createElement(kT,{key:v.type,description:X,onClick:L,selected:o(v.type,e),disabled:!s,...v}))}),Je.createElement(So,{wallet:p,onClose:()=>{u(void 0)},onConnect:()=>{t.onConnect&&(p?.type?t.onConnect(p.type):ST(new Error("The selected wallet hasn't been detected after the connection process finished. It usually shouldn't happen.")))}}),I&&Je.createElement(Am,{selected:!1,onClick:a},Je.createElement(zm,{variant:"label",size:"medium"},Um.t("Show more wallets"),Je.createElement(zm,{variant:"label",size:"medium",color:"$primary"},"\xA0+",B-(r??0)))))}i(Bs,"WalletList");var BT=2;function Vm(t){let{open:e,onClose:o,onCancel:n,onCheckBalance:r,loading:a}=t,s=NT(),l=y().blockchains(),{selectedQuote:c,setSelectedWallets:p,quoteWalletsConfirmed:u,setQuoteWalletConfirmed:m,customDestination:h,setCustomDestination:d}=O(),{config:f,connectedWallets:g,setWalletsAsSelected:C}=y(),[k,S]=tn(""),[T,w]=tn([]),[E,B]=tn(""),[I,x]=tn(!!h),b=AT(()=>mo({filter:"all",quote:c}),[c]),v=mo({filter:"required",quote:c}),A=l.find(D=>D.name===c?.swaps[c?.swaps.length-1].to.blockchain),M=i(D=>v.includes(D),"isWalletRequiredFor"),_=IT(()=>g.filter(D=>D.selected&&b.includes(D.chain)),[g,b]),[j,R]=tn(_()),[X,L]=tn([]),H=i((D,q)=>L(K=>K.concat({blockchain:D,walletType:q})),"addNextSelectedWallets"),ae=T.length>0,G=i((D,q)=>!!j.find(K=>K.walletType===D&&K.chain===q&&K.selected&&(M(q)||!M(q)&&!h)),"isSelected"),fe=i((D,q,K)=>{let ge=!1;return D.map(ce=>{if(ce.chain===q){let _e=ce.selected;return!ge&&K?(ge=!0,_e=!0):K||(_e=!1),{...ce,selected:_e}}return ce})},"updateSelectableWallets"),Ie=i(D=>{x(D),D?M(A?.name??"")||R(q=>fe(q,A?.name||"",!1)):(d(""),R(q=>fe(q,A?.name||"",!0)))},"handleCustomDestinationCollapsibleOpenChange"),je=i(D=>{if(k&&S(""),G(D.walletType,D.chain))return;let K=g.find(ge=>ge.walletType===D.walletType&&ge.chain===D.chain);K&&(n(),D.chain===A?.name&&I&&!M(A.name)&&(x(!1),d(null)),R(ge=>ge.filter(ce=>ce.chain!==D.chain).concat({...K,selected:!0})))},"onChange"),se=i(()=>{let D=j.filter(q=>q.selected);C(D),p(D),m(!0),o()},"onConfirmBalance"),pt=i(async()=>{w([]),B("");let D=await r?.({selectedWallets:j.filter(K=>K.selected),customDestination:h}),q=D.warnings;q?.balance?.messages&&w(q.balance.messages),D.error&&B(Rp(D.error)),!D.error&&!q?.balance?.messages.length?se():w(q?.balance?.messages??[])},"onConfirmWallets");Gm(()=>{R(D=>{let q=[];return D.forEach(K=>{!g.some(ce=>ce.chain===K.chain&&ce.walletType===K.walletType&&ce.address===K.address)||q.push(K)}),q=q.concat(g.filter(K=>!!!q.find(ce=>ce.chain===K.chain)&&K.selected&&b.includes(K.chain))),q})},[g,b]),Gm(()=>{let D=[];X.length>0&&(X.forEach(q=>{let K=g.find(ge=>ge.chain===q.blockchain&&ge.walletType===q.walletType);K?je(K):D.push(q)}),L(D))},[g,X]);let V=document.getElementById($e.SWAP_BOX_ID);return te.createElement(J,{open:e,onClose:()=>{u||s("../",{replace:!0}),o()},dismissible:!k,container:V,...!k&&{styles:{container:{height:"100%"}},footer:te.createElement(Mm,null,te.createElement(qm,{id:"widget-confirm-wallet-modal-confirm-btn",loading:a,disabled:Au(a,I,h,c,j,A),onClick:pt,variant:"contained",type:"primary",fullWidth:!0,size:"large"},bo.t("Confirm")))},...k&&{styles:{container:{height:"100%",padding:"$0"}},header:te.createElement(Nm,null,te.createElement(Bm,{id:"widget-confirm-wallet-modal-navigate-back-icon-btn",variant:"ghost",onClick:S.bind(null,"")},te.createElement(xT,{size:16})),te.createElement(Ls,{variant:"headline",size:"small"},bo.t({id:"Your {blockchainName} wallets",values:{blockchainName:ut(k,l)}})))},anchor:"center"},te.createElement(J,{open:ae,onClose:w.bind(null,[]),container:V},te.createElement(ET,{title:bo.t("Insufficient account balance"),type:"error",description:te.createElement(bT,{messages:T??[]})},te.createElement(qm,{id:"widget-confirm-wallet-modal-proceed-anyway-btn",variant:"outlined",size:"large",type:"primary",fullWidth:!0,onClick:se},bo.t("Proceed anyway")))),k&&te.createElement(Wm,null,te.createElement("div",{className:Lm()},te.createElement(Bs,{chain:k,isSelected:G,selectWallet:je,onShowMore:()=>S(k),onConnect:D=>{H(k,D)}}))),!k&&te.createElement(te.Fragment,null,E&&te.createElement(te.Fragment,null,te.createElement(wT,{variant:"alarm",type:"error",title:bo.t(E)}),te.createElement(Ws,{size:12})),te.createElement(Pm,null,b.map((D,q)=>{let K=l.find(Xe=>Xe.name===D),ge=`wallet-${q}`,ce=q===b.length-1,_e=ce&&A&&f?.customDestination!==!1;return te.createElement("div",{key:ge},te.createElement(Em,null,te.createElement(Ls,{variant:"title",size:"xmedium"},bo.t({id:"Your {blockchainName} wallets",values:{blockchainName:K?.shortName}})),te.createElement(Ls,{variant:"label",color:"$neutral700",size:"medium"},bo.t({id:"You need to connect a {blockchainName} wallet.",values:{blockchainName:K?.shortName}}))),te.createElement(Ws,{size:24}),te.createElement(Im,null,te.createElement(Bs,{chain:D,isSelected:G,selectWallet:je,limit:BT,onShowMore:()=>S(K?.name??""),onConnect:Xe=>{H(D,Xe)}})),!ce&&te.createElement(Ws,{size:32}),_e&&te.createElement(xm,{blockchain:A,open:I,handleOpenChange:Ie}))}))))}i(Vm,"ConfirmWalletsModal");import{i18n as XT}from"@lingui/core";import{Alert as YT,Button as ZT,InfoIcon as JT}from"@rango-dev/ui";import rt from"react";import{Alert as MT,Button as PT,Divider as _s,NoRouteIcon as _T,RefreshIcon as DT,Typography as Rm}from"@rango-dev/ui";import nt from"react";import{i18n as Km}from"@lingui/core";var WT=24,LT=60;function jm(t,e,o,n){return t?.type===1?{alert:{type:"warning",text:ee().genericServerError,action:{onClick:n,title:Km.t("Retry")}},description:""}:e.length?{alert:{type:"warning",text:ee().liquiditySourcesError.title,action:{onClick:()=>o(!0),title:Km.t("Reset")}},description:ee().liquiditySourcesError.description}:t?.type===0&&t.diagnosisMessage?{alert:{type:"error",text:t.diagnosisMessage,action:null},description:""}:{alert:null,description:ee().noResultError.description}}i(jm,"makeInfo");var Ms=(o=>(o[o.small=WT]="small",o[o.large=LT]="large",o))(Ms||{}),Ps=(o=>(o.small="small",o.large="medium",o))(Ps||{});import{styled as ai}from"@rango-dev/ui";var Xm=ai("div",{display:"flex",flexDirection:"column",alignItems:"center"}),Ym=ai("div",{variants:{size:{small:{},large:{maxWidth:"316px"}}}}),Zm=ai("div",{variants:{size:{small:{width:"100%"},large:{}}}}),Jm=ai("div",{padding:"$6 $0"});function Wn(t){let{fetch:e,error:o,size:n="small"}=t,r=y().getDisabledLiquiditySources(),a=y().toggleAllLiquiditySources,s=y().swappers(),l=jm(o,r,()=>a(s,!0),e);return nt.createElement(Xm,null,nt.createElement(_T,{size:Ms[n],color:"gray"}),nt.createElement(_s,{size:4}),nt.createElement(Rm,{variant:"title",size:Ps[n]},ee().noResultError.title),n==="large"&&nt.createElement(_s,{size:4}),!!l.description&&nt.createElement(Ym,{size:n},nt.createElement(Rm,{variant:"body",size:"small",align:"center",color:"neutral700"},l.description)),nt.createElement(_s,{size:n==="large"?"24":"4"}),!!l.alert&&nt.createElement(Zm,{size:n},nt.createElement(MT,{type:l.alert.type,title:l.alert.text,titleAlign:"left",action:l.alert.action&&nt.createElement(PT,{size:"xsmall",id:"widget-no-result-alert-btn",type:l.alert.type,prefix:nt.createElement(Jm,null,nt.createElement(DT,{size:8})),onClick:l.alert.action.onClick},l.alert.action.title),variant:"alarm"})))}i(Wn,"NoResult");import{i18n as Ln}from"@lingui/core";import{Button as FT,Divider as OT,MessageBox as UT,Typography as zT,WarningIcon as QT}from"@rango-dev/ui";import $t from"react";import{Typography as nd}from"@rango-dev/ui";import $s from"react";import{darkTheme as $T,styled as si}from"@rango-dev/ui";var ed=si("div",{width:"100%"}),Ds=si("div",{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"$5",width:"100%"}),td=si("div",{display:"flex",padding:"$5 0",justifyContent:"space-between",alignItems:"center",width:"100%","._title":{$$color:"$colors$neutral600",[`.${$T} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),od=si("div",{padding:"$2",alignSelf:"flex-start",cursor:"pointer"});function rd(t){let{title:e,value:o,valueColor:n}=t;return $s.createElement(td,null,$s.createElement(nd,{size:"medium",variant:"label",className:"_title"},e),$s.createElement(nd,{size:"large",variant:"label",color:n||"foreground"},`${n?"%":"$"}${o}`))}i(rd,"QuoteErrorsModalItem");function id(t){let{open:e,onClose:o,onConfirm:n,warning:r,confirmationDisabled:a}=t,s=r.warningLevel==="high"?"error":"warning",l=[{title:Ln.t("Swapping"),value:P(r.inputUsdValue,4,4)},{title:Ln.t("Gas cost"),value:P(r.totalFee,2,2)},{title:Ln.t("Receiving"),value:P(r.outputUsdValue,4,4)},{title:Ln.t("Price impact"),value:P(r.priceImpact,2,2),valueColor:`${s}500`}];return $t.createElement(J,{footer:$t.createElement(FT,{id:"widget-high-value-loss-warning-modal-confirm-btn",type:"primary",size:"large",prefix:$t.createElement(QT,null),fullWidth:!0,disabled:a,onClick:n},ee().highValueLossError.confirmMessage),open:e,onClose:o,container:N()},$t.createElement(UT,{type:s,title:ee().highValueLossError.impactTitle,description:ee().highValueLossError.description}),$t.createElement(Ds,null,$t.createElement(OT,{size:"4"}),$t.createElement(zT,{size:"small",variant:"title"},Ln.t("Details")),$t.createElement(Ds,null,l.map((c,p)=>$t.createElement(rd,{key:p,...c})))))}i(id,"HighValueLossWarningModal");import{i18n as li}from"@lingui/core";function ad(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=li.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=ee().highValueLossError.title;break}case 4:{o.title=li.t({id:"Output amount changed by {percentageChange}% (${usdValueChange}).",values:{percentageChange:t.percentageChange,usdValueChange:t.usdValueChange}});break}case 1:{o.title=ee().unknownPriceError.title;break}case 2:{o.title=li.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=li.t("Caution, your slippage is high."),o.action="change-settings";break}default:break}return o}return null}i(ad,"makeAlerts");import{i18n as on}from"@lingui/core";import{Button as sd,Divider as ld,MessageBox as HT,Typography as qT}from"@rango-dev/ui";import xo from"react";import{useNavigate as GT}from"react-router-dom";function cd(t){let{customSlippage:e,slippage:o}=y(),{open:n,onClose:r,onConfirm:a,warning:s,confirmationDisabled:l}=t,c=GT(),p=e??o;return xo.createElement(J,{anchor:"bottom",open:n,prefix:xo.createElement(sd,{size:"small",id:"widget-slippage-warning-modal-change-settings-btn",variant:"ghost",onClick:()=>c("../"+F.settings)},xo.createElement(qT,{variant:"label",size:"medium",color:"$neutral900"},on.t("Change settings"))),container:N(),onClose:r},xo.createElement(HT,{type:"warning",title:s.type===3?on.t("High slippage"):on.t("Low slippage"),description:s.type===3?on.t({id:" Caution, your slippage is high (={userSlippage}). Your trade may be front run.",values:{userSlippage:p}}):on.t({id:"We recommend you to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:s.minRequiredSlippage}})},xo.createElement(ld,{size:18}),xo.createElement(ld,{size:32}),xo.createElement(sd,{id:"widget-slippage-warning-modal-confirm-anyway-btn",size:"large",type:"primary",variant:"contained",fullWidth:!0,disabled:l,onClick:a},on.t("Confirm anyway"))))}i(cd,"SlippageWarningModal");import{Button as VT,MessageBox as KT,WarningIcon as jT}from"@rango-dev/ui";import ci from"react";function pd(t){let{open:e,onClose:o,onConfirm:n,confirmationDisabled:r}=t;return ci.createElement(J,{footer:ci.createElement(VT,{id:"widget-unknown-price-warning-modal-confirm-btn",type:"primary",size:"large",prefix:ci.createElement(jT,null),fullWidth:!0,disabled:r,onClick:n},ee().unknownPriceError.confirmMessage),open:e,onClose:o,container:N()},ci.createElement(KT,{type:"warning",title:ee().unknownPriceError.impactTitle,description:ee().unknownPriceError.description}))}i(pd,"UnknownPriceWarningModal");function Mn(t){let{warning:e,error:o,couldChangeSettings:n,showWarningModal:r,confirmationDisabled:a,refetchQuote:s,onOpenWarningModal:l,onCloseWarningModal:c,onConfirmWarningModal:p,onChangeSettings:u}=t,m={confirmationDisabled:a,open:r,onClose:c,onConfirm:p},h=o?.type===0||o?.type===1,d=ad(e,o?.type===3||o?.type===4?o:null);return d&&!n&&(d.action=null),rt.createElement(rt.Fragment,null,h&&rt.createElement(Wn,{error:o,fetch:s}),!!d&&rt.createElement(ed,null,rt.createElement(YT,{title:d.title,type:d.alertType,variant:"alarm",...d.action==="show-info"&&{action:rt.createElement(od,{onClick:l},rt.createElement(JT,{size:12,color:"gray"}))},...d.action==="change-settings"&&{action:rt.createElement(ZT,{id:"widget-quote-warning-error-change-settings-btn",size:"xxsmall",type:d.alertType,onClick:u},XT.t("Change"))}})),e&&rt.createElement(rt.Fragment,null,e.type===0&&rt.createElement(id,{...m,warning:e}),(e.type===3||e.type===2)&&rt.createElement(cd,{...m,warning:e}),e.type===1&&rt.createElement(pd,{...m,warning:e})))}i(Mn,"QuoteWarningsAndErrors");import Nv from"bignumber.js";import wi from"react";import{i18n as Eo}from"@lingui/core";import{Alert as hv,Divider as rn,FullExpandedQuote as yv,InfoIcon as Sv,NumericTooltip as Qd,QuoteTag as Cv,StepDetails as kv,TokenAmount as Tv,Typography as an}from"@rango-dev/ui";import Vs from"bignumber.js";import U,{useRef as vv,useState as wv}from"react";import{styled as Fs}from"@rango-dev/ui";var Os=Fs("div",{width:"100%","& .position-top__skeleton":{paddingTop:"$10"}}),ud=Fs("div",{paddingBottom:"$15",variants:{dense:{true:{paddingBottom:0}}}}),md=Fs("div",{width:"100%",display:"flex"});import*as pi from"@radix-ui/react-collapsible";import{Button as RT,css as Pn,darkTheme as xe,Image as dd,styled as He,Typography as ev}from"@rango-dev/ui";var tv=300,fd=He(pi.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"}}]}),gd=Pn({padding:"$10 $15"}),hd=He(RT,{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"}}}),yd=He("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"}}}}]}),Sd=Pn({width:"100%",padding:"$15 $15 $10 $15"}),Cd=Pn({display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingBottom:"$10",position:"relative"}),nn=Pn({display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",".blockchainImage":{marginLeft:"-$8"}}),kd=Pn({display:"flex",alignItems:"center",".usd-value":{$$color:"$colors$neutral600",[`.${xe} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),Td=He(pi.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:{[`& ${dd}`]:{border:"1px $warning500 solid",borderRadius:"100%"}},false:{[`& ${dd}`]:{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"}}}),vd=He("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"}}}}),wd=He(ti,{width:"100%",background:"inherit"}),Us=He("div",{display:"flex",justifyContent:"center",alignItems:"center",padding:"$2",transition:`all ${tv}ms ease`,variants:{orientation:{down:{transform:"rotate(0)"},up:{transform:"rotate(180deg)"}}}}),V1=He("div",{height:"$12",marginLeft:"$10",marginRight:"$10",borderLeft:"1px solid $foreground"}),bd=He("div",{display:"flex",justifyContent:"center",margin:"0 $15",borderTop:"1px solid",$$color:"$colors$neutral300",[`.${xe} &`]:{$$color:"$colors$neutral400"},borderColor:"$$color"}),xd=He("div",{width:"$16",height:"$16",justifyContent:"center",alignItems:"center",display:"flex"}),zs=He(ev,{overflow:"hidden",textOverflow:"ellipsis",letterSpacing:.4}),Ed=He("div",{display:"flex",flexWrap:"wrap"}),Qs=He("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"}}}}),Id=He("div",{display:"flex"}),ui=He("div",{width:"100%",borderTopWidth:"1px",borderTopStyle:"solid",borderTopColor:"$neutral",margin:"$5 0",[`.${xe} &`]:{borderTopColor:"$neutral800"}});import{i18n as It}from"@lingui/core";import{ChevronDownIcon as nv,CloseIcon as rv,Divider as fi,IconButton as iv,NumericTooltip as av,QuoteCost as sv,Typography as Ct}from"@rango-dev/ui";import Z,{useState as Wd}from"react";import{css as ov,styled as mi}from"@rango-dev/ui";var di=mi("div",{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"$5 0","&.total_payable_fee":{padding:"$12 0"}}),Hs=mi("div",{width:"100%",borderTop:"1px solid $neutral300",margin:"$10 0"}),Ad=mi("div",{padding:"$20 0",display:"flex",flexDirection:"column","& .collapsible_trigger":{display:"flex",alignItems:"center"}}),Nd=mi("div",{padding:"$20 $20 $10",position:"relative","._icon-button":{position:"absolute",zIndex:10,top:"$16",right:"$16"}}),Bd=ov({display:"flex",flexDirection:"row",alignItems:"center",padding:"$5","&:hover":{"& ._typography, & svg":{color:"$secondary"}}});var lv=i(t=>t.fee.isZero()?null:Z.createElement(di,null,Z.createElement(Ct,{variant:"label",size:"medium",color:"neutral600"},t.label),Z.createElement(Ct,{variant:"label",size:"medium"},"$",P(t.fee,4,4))),"NonPayableFee");function qs(t){let[e,o]=Wd(!1),[n,r]=Wd(!1),{steps:a,quote:s,fee:l,time:c,feeWarning:p,timeWarning:u,showModalFee:m,fullExpandedMode:h=!1}=t,d=s?.swaps??[],f=h?uo():N(),g=ku(d);return Z.createElement(Z.Fragment,null,Z.createElement(sv,{onClickFee:m?C=>{C.stopPropagation(),o(!e)}:void 0,fee:l,feeWarning:p,timeWarning:u,time:c,steps:a,tooltipGas:m?It.t("View more info"):void 0,tooltipContainer:f}),Z.createElement(J,{container:f,open:e,anchor:h?"center":"bottom",styles:{container:{maxWidth:h?"484px":"unset"}},header:Z.createElement(Nd,{style:{textAlign:h?"left":"center"}},Z.createElement(Ct,{variant:"title",size:"medium"},It.t("Gas & Fee Explanation")),Z.createElement(iv,{id:"widget-quote-cost-details-modal-close-icon-btn",onClick:()=>o(!1),variant:"ghost"},Z.createElement(rv,{color:"gray",size:14}))),onClose:()=>{o(!1)}},Z.createElement(Ad,null,Z.createElement(Ct,{variant:"title",size:"small"},It.t("Details")),Z.createElement(fi,{size:10}),Object.entries(g.payable).flatMap(([C,k])=>k.map((S,T)=>{let w=`payable-fee-${T}`,E=qa(S);return Z.createElement(di,{key:w},Z.createElement(Ct,{variant:"label",size:"medium",color:"neutral600"},Oa(C,It.t)),Z.createElement(av,{content:S.amount,container:f},Z.createElement(Ct,{variant:"label",size:"medium"},P(S.amount,2,2)," ",S.asset.symbol," ($",P(E,4,4),")")))})),Z.createElement(di,{className:"total_payable_fee"},Z.createElement(Ct,{variant:"label",size:"medium"},It.t("Total Payable Fee")),Z.createElement(Ct,{variant:"label",size:"medium"},"$",P(l,4,4))),Z.createElement(Hs,null),Object.keys(g.nonePayable).length&&Z.createElement(ri,{triggerAnchor:"bottom",onClickTrigger:()=>r(C=>!C),trigger:Z.createElement("div",{className:Bd()},Z.createElement(Ct,{size:"small",variant:"body",color:"neutral700"},n?It.t("Hide non-payable fees"):It.t("Show non-payable fees")),Z.createElement(fi,{size:4,direction:"horizontal"}),Z.createElement(oi,{orientation:n?"up":"down"},Z.createElement(nv,{size:12,color:"gray"}))),open:n},Z.createElement(Ct,{size:"small",variant:"title"},It.t("Description")),Z.createElement(fi,{size:4}),Z.createElement(Ct,{size:"small",variant:"body",color:"neutral700"},It.t(`The following fees are considered in the transaction output and
2
+ you won\u2019t need to pay extra gas for them.`)),Z.createElement(fi,{size:10}),Object.entries(g.nonePayable).map(([C,k],S)=>{let T=Cu(k),w=Oa(C,It.t),E=`non-payable-fee-${S}`;return Z.createElement(lv,{key:E,fee:T,label:w})}),Z.createElement(Hs,null)))))}i(qs,"QuoteCostDetails");import{i18n as Pd}from"@lingui/core";import{TokenAmount as _d}from"@rango-dev/ui";import gi from"react";import{css as cv,styled as pv}from"@rango-dev/ui";var Ld=pv("div",{position:"relative",display:"flex",flexDirection:"column",width:"100%"}),Md=cv({height:"14px",marginLeft:"14px",position:"absolute",borderLeft:"1px solid $foreground",top:"42%"});function _n(t){let{from:e,to:o,percentageChange:n,warningLevel:r}=t;return gi.createElement(Ld,null,gi.createElement(_d,{direction:"horizontal",label:Pd.t("Swap input"),type:"input",tooltipContainer:N(),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}}),gi.createElement("div",{className:Md()}),gi.createElement(_d,{direction:"horizontal",tooltipContainer:N(),label:Pd.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(_n,"QuoteSummary");import{i18n as Ud}from"@lingui/core";import{ChevronDownIcon as dv,ChevronRightIcon as fv,Divider as Gs,Image as gv,Tooltip as ki,Typography as yi}from"@rango-dev/ui";import z from"react";import{useLayoutEffect as uv,useState as Dn}from"react";var Dd=480,$d=768,Fd=1024,Od=1200,mv=i(()=>{let[t,e]=Dn(!1),[o,n]=Dn(!1),[r,a]=Dn(!1),[s,l]=Dn(!1),[c,p]=Dn(!1),u=i(()=>{e(window.innerWidth<=Dd),n(window.innerWidth>Dd&&window.innerWidth<=$d),a(window.innerWidth>$d&&window.innerWidth<=Fd),l(window.innerWidth>Fd&&window.innerWidth<=Od),p(window.innerWidth>Od)},"handleResize");return uv(()=>(u(),window.addEventListener("resize",u),()=>window.removeEventListener("resize",u)),[]),{isMobile:t,isTablet:o,isNotebook:r,isLargeScreen:s,isExtraLargeScreen:c}},"useScreenDetect"),hi=mv;var Si=4,Ci=6,$n=i(t=>{let{content:e,src:o,className:n,open:r,state:a,container:s}=t,l=s||N();return z.createElement(ki,{container:l,side:"bottom",sideOffset:4,open:r,content:e},z.createElement(vd,{className:n,state:a},z.createElement(gv,{src:o,size:16})))},"ImageComponent");function zd(t){let{quoteRef:e,selected:o,setExpanded:n,steps:r,expanded:a,type:s,container:l}=t,c=l||N(),p=r.length,u=cu(r),{isTablet:m,isMobile:h}=hi();return z.createElement(Td,{listItem:s==="list-item",ref:d=>e.current=d,selected:o,onClick:d=>{d.stopPropagation(),n(f=>!f)}},z.createElement("div",{className:nn()},z.createElement(yi,{variant:"body",size:"xsmall"},Ud.t("Via:")),z.createElement(Gs,{direction:"horizontal",size:4}),r.map((d,f)=>{let g=`item-${f}`,C=z.createElement(Us,null,z.createElement(fv,{size:12,color:"black"}));return h||m?z.createElement(z.Fragment,{key:g},z.createElement($n,{content:d.swapper.displayName,src:d.swapper.image??"",state:d.state,container:l}),f!==p-1&&z.createElement(z.Fragment,null,C)):z.createElement(z.Fragment,{key:g},p<=Si||p>Si&&f<Si-1?z.createElement(z.Fragment,null,z.createElement($n,{content:d.swapper.displayName,src:d.swapper.image??"",state:d.state,container:l}),f!==p-1&&z.createElement(z.Fragment,null,C)):f===Si-1&&z.createElement(ki,{container:c,side:"bottom",align:"end",sideOffset:4,content:z.createElement("div",{className:nn()},C,r.map((k,S)=>{let T=`image-${S}`;return S>=f&&z.createElement(z.Fragment,{key:T},z.createElement($n,{content:k.swapper.displayName,src:k.swapper.image??"",state:k.state,open:!1}),S!==p-1&&z.createElement(z.Fragment,null,C))}))},z.createElement(Qs,{state:r.find((k,S)=>S>=f&&(k.state==="error"||k.state==="warning"))?.state},z.createElement(yi,{size:"xsmall",variant:"body"},"+",p-f))))})),z.createElement("div",{className:nn()},z.createElement("div",{className:"blockchains_section"},z.createElement("div",{className:nn()},z.createElement(yi,{variant:"body",size:"xsmall"},Ud.t("Chains:")),z.createElement(Gs,{direction:"horizontal",size:4}),u.map((d,f)=>z.createElement(z.Fragment,{key:d.displayName},u.length<=Ci||u.length>Ci&&f<Ci-1?z.createElement(ki,{container:c,side:"bottom",content:d.displayName,sideOffset:4},z.createElement($n,{content:"",src:d.image??"",open:!1,className:f!==0?"blockchainImage":""})):f===Ci-1&&z.createElement(ki,{container:c,side:"bottom",align:"end",sideOffset:4,content:z.createElement("div",{className:nn()},u.map((g,C)=>C>=f&&z.createElement($n,{key:g.displayName,content:"",src:g.image??"",open:!1,className:C>f?"blockchainImage":"",container:l})))},z.createElement(Qs,{className:"blockchainImage"},z.createElement(yi,{size:"xsmall",variant:"body"},"+",u.length-f))))),z.createElement(Gs,{direction:"horizontal",size:32}))),z.createElement(Us,{orientation:a?"up":"down"},z.createElement(dv,{size:12,color:"black"}))))}i(zd,"QuoteTrigger");function Ks(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:m=!1,container:h}=t,d=y().blockchains(),{findToken:f}=y(),g=y().swappers(),{customSlippage:C,slippage:k}=y(),S=C||k,[T,w]=wv(t.expanded),E=vv(null),B=P(o.value,6,6),I=P(n.value,6,6),x=n.usdValue?P(n.usdValue,4,4):"",b=Pt(o.usdValue,n.usdValue??null),v=P(b,2,2),A=_t(b??0),M=i((se,pt)=>se.map((V,D)=>{let q,K=r?.type===3&&r.swap.swapperId===V.swapperId,ge=r?.type===4&&r.recommendedSlippages?.has(D),ce=a?.type===2&&a.recommendedSlippages?.has(D),_e=K||ge,Xe=ce;_e?q="error":Xe&&(q="warning");let ke=_e?Eo.t("Slippage Error"):Eo.t("Slippage Warning");return K&&(ke=Eo.t("Bridge Limit Error")),{swapper:{displayName:un(V.swapperId,g)??"",image:V.swapperLogo},from:{token:{displayName:V.from.symbol,image:V.from.logo},chain:{displayName:ut(V.from.blockchain,d)??"",image:V.from.blockchainLogo},price:{value:D===0&&!pt?P(o.value,6,6):P(V.fromAmount,6,6),usdValue:P((V.from.usdPrice??0)*parseFloat(V.fromAmount),4,4),realValue:D===0?o.value:V.fromAmount,realUsdValue:new Vs(V.from.usdPrice??0).multipliedBy(V.fromAmount).toString()}},to:{token:{displayName:V.to.symbol,image:V.to.logo},chain:{displayName:ut(V.to.blockchain,d)||"",image:V.to.blockchainLogo},price:{value:P(V.toAmount,6,6),usdValue:P((V.to.usdPrice??0)*parseFloat(V.toAmount),4,4),realValue:V.toAmount,realUsdValue:new Vs(V.to.usdPrice??0).multipliedBy(V.toAmount).toString()}},state:q,alerts:_e||Xe?U.createElement(ud,{dense:m},U.createElement(hv,{variant:"alarm",type:_e?"error":"warning",title:ke,footer:U.createElement(md,null,K&&U.createElement("div",null,U.createElement(an,{size:"xsmall",variant:"body",color:"neutral900"},r.fromAmountRangeError),U.createElement(rn,{direction:"vertical",size:2}),U.createElement(an,{size:"xsmall",variant:"body",color:"neutral900"},Eo.t({id:"Yours: {amount} {symbol}",values:{amount:P(V.fromAmount,6,6),symbol:V?.from.symbol}}))),(ge||ce)&&!K&&U.createElement("div",null,U.createElement(an,{size:"xsmall",variant:"body",color:"neutral900"},Eo.t({id:"Minimum required slippage: {minRequiredSlippage}",values:{...r?.type===4&&{minRequiredSlippage:r.recommendedSlippages?.get(D)},...a?.type===2&&{minRequiredSlippage:a.recommendedSlippages?.get(D)}}})),U.createElement(rn,{direction:"vertical",size:2}),U.createElement(an,{size:"xsmall",variant:"body",color:"neutral900"},Eo.t({id:"Yours: {userSlippage}",values:{userSlippage:S}}))))})):void 0,time:dn(V.estimatedTimeInSeconds),fee:P(Ha(V,f),2,2),internalSwaps:V.internalSwaps?M(V.internalSwaps):void 0}}),"getQuoteSteps"),_=M(e?.swaps??[]),j=_.length,R=h||N(),X=uu(t.quote.tags||[]),L=!!u,H=kr(e?.swaps),ae=dn(H),G=Ur(e?.swaps??[],f),fe=P(G,2,2),Ie=G.gte(new Vs(tu)),je=H/nu>=ou;return m?U.createElement(yv,{selected:l,fee:fe,time:ae,tooltipContainer:uo(),steps:_,tags:X,quoteCost:U.createElement(qs,{quote:e,fullExpandedMode:!0,time:ae,fee:fe,feeWarning:Ie,timeWarning:je,showModalFee:p,steps:j}),percentageChange:v,warningLevel:A,outputPrice:{value:I,usdValue:x,realValue:n.value,realUsdValue:n.usdValue}}):U.createElement(yd,{selected:l,listItem:s==="list-item",basic:s==="basic"},U.createElement("div",{className:Sd()},!c&&X.length?U.createElement(U.Fragment,null,U.createElement(Id,null,X.map((se,pt)=>{let V=`${se.value}_${pt}`;return U.createElement(U.Fragment,{key:V},U.createElement(Cv,{label:se.label,value:se.value}),U.createElement(rn,{size:4,direction:"horizontal"}))})),U.createElement(ui,null),!L&&U.createElement(rn,{size:4})):null,U.createElement("div",{id:"portal-root",className:Cd()},U.createElement(qs,{quote:e,time:ae,fee:fe,feeWarning:Ie,timeWarning:je,showModalFee:p,steps:j}),L&&U.createElement(hd,{onClick:se=>{se.stopPropagation(),u()},size:"xxsmall",type:"secondary",variant:"default",css:{paddingLeft:"$10",paddingRight:"$10",paddingTop:"$5",paddingBottom:"$5"}},U.createElement(an,{color:"secondary",variant:"body",size:"xsmall",className:"allRoutesLabel"},Eo.t("See All Routes")))),s==="basic"&&U.createElement("div",{className:kd()},U.createElement(xd,null,U.createElement(Sv,{size:12,color:"gray"})),U.createElement(Ed,null,U.createElement(zs,{size:"small",variant:"body"},`${B} ${_[0].from.token.displayName} = `),U.createElement(Qd,{content:n.value,container:R,open:n.value?void 0:!1},U.createElement(zs,{size:"small",variant:"body"},"\xA0",`${I} ${_[_.length-1].to.token.displayName}`))),U.createElement(Qd,{content:n.usdValue,container:R},U.createElement(rn,{size:2,direction:"horizontal"}),U.createElement(an,{color:"$neutral600",size:"xsmall",variant:"body"},`($${x})`))),s==="list-item"&&U.createElement(Tv,{tooltipContainer:R,type:"output",direction:"vertical",price:{value:I,usdValue:x,realValue:n.value,realUsdValue:n.usdValue},token:{displayName:_[j-1].to.token.displayName,image:_[j-1].to.token.image},chain:{image:_[j-1].to.chain.image},percentageChange:v,warningLevel:A}),s==="swap-preview"&&U.createElement(U.Fragment,null,U.createElement(_n,{from:_[0].from,to:_[j-1].to,percentageChange:v,warningLevel:A}),U.createElement(rn,{size:4}))),U.createElement(fd,{selected:l,listItem:s==="list-item",open:T,className:"quote_container",onOpenChange:w},U.createElement(zd,{type:s,quoteRef:E,selected:l,setExpanded:w,container:R,expanded:T,steps:_}),U.createElement(wd,{open:T},U.createElement(bd,null),U.createElement("div",{className:gd()},_.map((se,pt)=>{let V=`item-${pt}`;return U.createElement(kv,{type:"quote-details",key:V,tooltipContainer:R,step:se,hasSeparator:pt!==_.length-1,state:se.state})})))))}i(Ks,"Quote");import{Divider as Iv,Skeleton as Av}from"@rango-dev/ui";import Ot from"react";import{darkTheme as bv,styled as Ti}from"@rango-dev/ui";var Hd=Ti("div",{$$color:"$colors$neutral100",[`.${bv} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",borderBottomLeftRadius:"$xm",borderBottomRightRadius:"$xm",padding:"$15",variants:{rounded:{true:{borderRadius:"$xm"}},expanded:{true:{paddingBottom:"3px"},false:{paddingBottom:"$12"}}}}),qd=Ti("div",{paddingTop:"$2"}),Gd=Ti("div",{paddingLeft:"$8"}),Vd=Ti("div",{borderLeft:"1px dashed $foreground",minHeight:" 0",margin:"0px 11.5px",alignSelf:"stretch",variants:{hideSeparator:{true:{minHeight:"unset",height:"0"}}}});import{ChainToken as of,Divider as kt,Skeleton as it}from"@rango-dev/ui";import Q from"react";import{css as xv,styled as Ft}from"@rango-dev/ui";var js=Ft("div",{display:"flex"}),Kd=Ft("div",{padding:"$10 $0 $20"}),jd=Ft("div",{padding:"14px $0 $20 $0",display:"flex",flexDirection:"column"}),Xd=Ft("div",{display:"flex",justifyContent:"start",alignItems:"center"}),Yd=Ft("div",{display:"flex",justifyContent:"space-between",alignItems:"end"}),Zd=Ft("div",{height:"$24",marginLeft:"13px",borderLeft:"1px solid $neutral700"}),Jd=Ft("div",{width:"65%",display:"flex",justifyContent:"start"}),Rd=Ft("div",{display:"flex",flexDirection:"column",alignItems:"start",flexGrow:1,maxWidth:"148px"}),ef=Ft("div",{padding:"$15 $0 $15 $0"}),tf=xv({display:"flex",justifyContent:"space-between",alignItems:"center"});function Fn(t){let{type:e,tagHidden:o=!0}=t,n=Q.createElement(Yd,null,Q.createElement(Jd,null,Q.createElement(of,{loading:!0,size:"medium"}),Q.createElement(kt,{size:8,direction:"horizontal"}),Q.createElement(Rd,null,Q.createElement(it,{height:10,width:60,variant:"rounded"}),Q.createElement(kt,{size:4}),Q.createElement(it,{height:15,variant:"rounded"}))),Q.createElement(it,{height:12,width:64,variant:"rounded"})),r=e==="basic"&&!o;return Q.createElement("div",null,!o&&Q.createElement(Q.Fragment,null,Q.createElement(js,null,Q.createElement(it,{width:65,height:20,variant:"rounded"}),Q.createElement(kt,{size:4,direction:"horizontal"}),Q.createElement(it,{width:65,height:20,variant:"rounded"}),Q.createElement(kt,{size:4,direction:"horizontal"}),Q.createElement(it,{width:65,height:20,variant:"rounded"})),Q.createElement(ui,null),!r&&Q.createElement(kt,{size:4})),Q.createElement("div",{className:tf()},Q.createElement(js,null,Q.createElement(it,{width:60,height:10,variant:"rounded"}),Q.createElement(kt,{size:4,direction:"horizontal"}),Q.createElement(it,{width:60,height:10,variant:"rounded"}),Q.createElement(kt,{size:4,direction:"horizontal"}),Q.createElement(it,{width:60,height:10,variant:"rounded"})),r&&Q.createElement(it,{width:85,height:24,variant:"rounded"})),e==="basic"&&Q.createElement(Kd,null,Q.createElement(it,{height:15,width:148,variant:"rounded"})),e==="list-item"&&Q.createElement(jd,null,Q.createElement(Xd,null,Q.createElement(of,{loading:!0,size:"medium"}),Q.createElement(kt,{direction:"horizontal",size:4}),Q.createElement(it,{height:15,width:150,variant:"rounded"})),Q.createElement(kt,{size:10}),Q.createElement(it,{height:10,width:184,variant:"rounded"})),e==="swap-preview"&&Q.createElement(Q.Fragment,null,Q.createElement(kt,{size:4}),Q.createElement(ef,null,n,Q.createElement(Zd,null),n),Q.createElement(kt,{size:12})))}i(Fn,"QuoteSummarySkeleton");import{ChainToken as lf,Divider as Ys,NextIcon as Ev,Skeleton as vi}from"@rango-dev/ui";import Ee from"react";import{styled as On}from"@rango-dev/ui";var nf=On("div",{display:"flex",alignItems:"start"}),rf=On("div",{flexGrow:1,paddingTop:"$5",paddingBottom:"$10",display:"flex",alignItems:"center",variants:{extraSpace:{true:{paddingBottom:"$40"}}}}),Xs=On("div",{display:"flex",alignItems:"center",flexGrow:1}),af=On("div",{margin:"$0 $2",padding:"$4",display:"flex",justifyContent:"center",alignItems:"center"}),sf=On("div",{display:"flex",alignItems:"center"});function At(t){let{separator:e=!0}=t;return Ee.createElement(Ee.Fragment,null,Ee.createElement(sf,null,Ee.createElement(vi,{height:22,width:22,variant:"circular"}),Ee.createElement(Ys,{direction:"horizontal",size:8}),Ee.createElement(vi,{height:15,width:148,variant:"rounded"})),Ee.createElement(nf,null,Ee.createElement(Vd,{hideSeparator:!e}),Ee.createElement(rf,{extraSpace:e},Ee.createElement(Xs,null,Ee.createElement(lf,{size:"small",loading:!0}),Ee.createElement(Ys,{direction:"horizontal",size:8}),Ee.createElement(vi,{height:12,variant:"rounded"})),Ee.createElement(af,null,Ee.createElement(Ev,{color:"gray",size:16})),Ee.createElement(Xs,null,Ee.createElement(lf,{size:"small",loading:!0}),Ee.createElement(Ys,{direction:"horizontal",size:8}),Ee.createElement(vi,{height:12,variant:"rounded"})))))}i(At,"StepSkeleton");function Un(t){let{type:e,expanded:o,tagHidden:n=!1}=t;return Ot.createElement(Hd,{expanded:o,rounded:e!=="basic"},Ot.createElement(Fn,{type:e,tagHidden:n}),Ot.createElement(qd,null,Ot.createElement(Av,{height:15,variant:"rounded"})),o&&Ot.createElement(Gd,null,Ot.createElement(Iv,{size:24}),Ot.createElement(At,null),Ot.createElement(At,null),Ot.createElement(At,{separator:!1})))}i(Un,"QuoteSkeleton");function Io(t){let{quote:e,type:o,loading:n,error:r,warning:a,expanded:s=!1,tagHidden:l,onClick:c,showModalFee:p,selected:u,onClickAllRoutes:m,fullExpandedMode:h=!1,container:d}=t,{inputAmount:f,inputUsdValue:g}=O(),C=e?.outputAmount?new Nv(e?.outputAmount):null,k=e?dt(e):null,T=!(r&&(r.type===0||r.type===1))&&e&&!n;return n?wi.createElement(Os,null,wi.createElement(Un,{tagHidden:l,type:o,expanded:s})):T?wi.createElement(Os,{onClick:()=>c?.(e)},wi.createElement(Ks,{quote:e,error:r,container:d,showModalFee:p,warning:a,tagHidden:l,selected:u,type:o,expanded:s,onClickAllRoutes:m,fullExpandedMode:h,input:{value:f,usdValue:g?.toString()??""},output:{value:C?.toString()??"",usdValue:k?.toString()??""}})):null}i(Io,"QuoteInfo");import{calculatePendingSwap as Mv}from"@rango-dev/queue-manager-rango-preset";import{useEffect as Pv}from"react";import{useRef as Bv,useState as Wv}from"react";var Lv=2e3;function bi({request:t}){let[e,o]=Wv(!1),n=Bv(null),r=i(()=>n.current?.abort(),"cancelFetch"),a=i(async l=>(await new Promise(c=>setTimeout(c,Lv)),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(bi,"useFetch");function cf(){let{fetch:t,loading:e,cancelFetch:o}=bi({request:async(n,r)=>await ot().confirmRoute(n,r)});return{fetch:t,loading:e,cancelFetch:o}}i(cf,"useFetchConfirmQuote");function xi(t){if(!t.swaps)throw new Error(ee().noResultError.title,{cause:{type:0,diagnosisMessage:t.diagnosisMessages?.[0]}});let e=Zs(t.swaps);if(e)throw new Error(e.message,{cause:e.options})}i(xi,"throwErrorIfResponseIsNotValid");function Zs(t){if(hu(t)){let{swap:n,recommendation:r,fromAmountRangeError:a}=yu(t);return{message:"bridge limit error",options:{type:3,swap:n,recommendation:r,fromAmountRangeError:a}}}let o=Tu(t);if(o){let n=zr(t);return{message:"",options:{type:4,recommendedSlippages:o,minRequiredSlippage:n}}}return null}i(Zs,"getQuoteError");function pf(t){let{currentQuote:e,previousQuote:o,meta:n,selectedWallets:r,userSlippage:a,findToken:s}=t,l={quote:null,balance:null},c=Vo({previousQuote:o,currentQuote:e,findToken:s,userSlippage:a});c&&(l.quote=c);let p=bu(e,r,n.blockchains);return p.length===0||(l.balance={messages:p}),l}i(pf,"generateWarnings");function Ei(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(Ei,"handleQuoteErrors");function Js(){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(),m=y().blockchains(),h=y().tokens(),{findToken:d}=y(),f=p||c,{fetch:g,cancelFetch:C,loading:k}=cf();return Pv(()=>C,[]),{loading:k,fetch:i(async T=>{let w=T.selectedWallets,E=T?.customDestination??s;if(!t||!e||!o)return{quote:null,swap:null,error:null,warnings:null};let B=w.reduce((x,b)=>(x[b.chain]=b.address,x),{}),I={requestId:a?.requestId||"",selectedWallets:B,destination:E||void 0};try{return await g(I,!0).then(x=>{let{result:b}=x;if(!b)throw new Error("Error fetching updated route");xi({diagnosisMessages:b.diagnosisMessages,requestId:b.requestId,swaps:b.result?.swaps});let v={outputAmount:b.result?.outputAmount,requestId:b.requestId,resultType:b.result?.resultType,swaps:b.result?.swaps||[],validationStatus:b.validationStatus,requestAmount:b.requestAmount};r(v);let A={slippage:f.toString(),disabledSwappersGroups:u},M=pf({previousQuote:a??void 0,currentQuote:v,meta:{blockchains:m},selectedWallets:w,userSlippage:f,inputUsdValue:n,findToken:d});l();let _=!!M.balance,j=Mv(o.toString(),b,wu(w),A,!_,{blockchains:m,tokens:h});return{quote:v,swap:j,error:null,warnings:M}})}catch(x){return Ei(x)}},"fetch"),cancelFetch:C}}i(Js,"useConfirmSwap");var qv=Fv("div",{width:"100%",display:"flex",justifyContent:"space-between",[`& ${uf}`]:{width:"$48",height:"$48"}}),Gv=tl({flexGrow:1,paddingRight:"$10"}),Vv=tl({width:"$24",height:"$24",display:"flex",justifyContent:"center",alignItems:"center"}),Kv=tl({display:"flex",justifyContent:"space-between",alignItems:"center"});function mf(){let{selectedQuote:t,setInputAmount:e,selectedWallets:o,quoteWalletsConfirmed:n,customDestination:r,quoteWarningsConfirmed:a}=O(),s=Hv(),[l,c]=zn(""),p=!n,[u,m]=zn(!1),[h,d]=zn(!1),{isActiveTab:f}=ne(),g=y().getDisabledLiquiditySources(),C=Qv(g),{manager:k}=_v(),{fetch:S,loading:T,cancelFetch:w}=Js(),[E,B]=zn({swap:null,error:null,warnings:null}),[I,x]=zn(!1),b=i(async({selectedWallets:L,customDestination:H})=>{let ae=await S?.({selectedWallets:L,customDestination:H});return B(ae),ae},"onConfirmSwap"),v=i(async()=>{if(E.swap&&n)try{await k?.create("swap",{swapDetails:E.swap},{id:E.swap.requestId});let L=`../${F.swaps}/${E.swap.requestId}`;s(L,{replace:!0}),setTimeout(()=>{e("")},0)}catch(L){c("Error: "+L?.message)}},"addNewSwap"),A=i(async()=>{d(!0),await v(),d(!1)},"onConfirm"),M=i(async()=>{E.warnings?.quote&&lu(E.warnings.quote)&&!a?x(!0):await A()},"onStartConfirmSwap"),_=i(async()=>{B({error:null,swap:null,warnings:null}),S({selectedWallets:o,customDestination:r}).then(L=>{B(L)}).catch(L=>console.error(L))},"onRefresh");Ii(()=>{!!C.current.length&&!g.length&&_(),C.current=g},[g.length]),Ii(()=>{p&&w()},[p]),Ii(()=>{p&&m(p)},[p]),Ii(()=>{p||S({selectedWallets:o,customDestination:r}).then(L=>B(L)).catch(L=>console.error(L))},[]),zv(()=>{t?.requestId||s(`../${location.search}`)},[t?.requestId]);let j=E.warnings?.quote??null,R=E.error,X=[];if(l&&X.push(Le.createElement(Dv,{type:"error",variant:"alarm",title:l})),j||R){let L=`../${F.settings}`;X.push(Le.createElement(Mn,{warning:j,error:R,couldChangeSettings:!1,refetchQuote:_,showWarningModal:I,confirmationDisabled:!f,onOpenWarningModal:()=>x(!0),onCloseWarningModal:()=>x(!1),onConfirmWarningModal:async()=>{x(!1),await v()},onChangeSettings:()=>s(L)}))}return Le.createElement(oe,{header:{title:Rs.t("Confirm Swap"),onWallet:()=>{let L=`../${F.wallets}`;s(L)}},footer:Le.createElement(qv,null,Le.createElement("div",{className:Gv()},Le.createElement($v,{id:"widget-confirm-swap-start-btn",variant:"contained",type:"primary",size:"large",fullWidth:!0,loading:T||h,disabled:!!E.error||!f,onClick:M},Rs.t("Start Swap"))),Le.createElement(uf,{id:"widget-confirm-swap-wallet-icon-btn",variant:"contained",type:"primary",size:"large",loading:T||h,disabled:!f,onClick:m.bind(null,!0)},Le.createElement(Uv,{size:24})))},u&&Le.createElement(Vm,{open:u,onClose:()=>m(!1),onCancel:w,loading:T,onCheckBalance:b}),Le.createElement(re,null,Le.createElement("div",{className:Kv()},Le.createElement(Ov,{variant:"title",size:"small"},Rs.t("You get")),Le.createElement("div",{className:Vv()},Le.createElement(jr,{onClick:!T&&!u&&!I?_:void 0}))),Le.createElement(el,{size:"12"}),Ku(X.map((L,H)=>({element:L,key:`alert-${H}`})),Le.createElement(el,{size:10})),X.length>0?Le.createElement(el,{size:10}):null,Le.createElement(Io,{quote:t,type:"swap-preview",expanded:!0,tagHidden:!0,error:E.error,loading:T,warning:E.warnings?.quote??null})))}i(mf,"ConfirmSwapPage");import{i18n as zt}from"@lingui/core";import{Button as dl,CustomTokensZeroStateDarkIcon as fw,CustomTokensZeroStateIcon as gw,DeleteIcon as hw,Divider as Kn,IconButton as yw,MessageBox as Sw,NotFound as Cw,styled as gl}from"@rango-dev/ui";import me,{useState as fl}from"react";import{useNavigate as kw}from"react-router-dom";import{CloseIcon as Xv,IconButton as Yv,SearchIcon as Zv,TextField as Jv}from"@rango-dev/ui";import Qn from"react";import{styled as jv}from"@rango-dev/ui";var df=jv("div",{width:"$24",height:"$24",display:"flex",alignItems:"center",justifyContent:"center"});function Tt(t){let{variant:e,fullWidth:o,color:n,size:r,onChange:a,value:s,style:l,setValue:c,suffix:p,...u}=t,m=s.length?Qn.createElement(Yv,{variant:"ghost",onClick:()=>c?.(""),size:"small"},Qn.createElement(Xv,{color:"gray",size:10})):null;return p&&(m=p),Qn.createElement(Jv,{prefix:Qn.createElement(df,null,Qn.createElement(Zv,{color:"black"})),suffix:m,fullWidth:o,color:n,variant:e,style:{padding:10,borderRadius:25,alignItems:"center",...l},size:r,value:s,onChange:a,...u})}i(Tt,"SearchInput");import{i18n as ml}from"@lingui/core";import{Button as ow,CustomTokenWarning as nw,darkTheme as xf,Divider as Ut,ExternalLinkIcon as rw,Image as iw,ListItem as aw,NotFound as sw,PinIcon as lw,Skeleton as Ao,Typography as Gn,VirtualizedList as cw}from"@rango-dev/ui";import W,{useState as pw}from"react";import{useTranslation as uw}from"react-i18next";import{Divider as wf,ListItem as tw,Skeleton as qn}from"@rango-dev/ui";import vt from"react";import{css as sn,darkTheme as ol,ImageContainer as Rv,ListItemButton as ew,styled as Re,Typography as ff}from"@rango-dev/ui";var nl=sn({position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:100,overflow:"hidden"}),rl=sn({position:"relative",height:12,width:"30%",maxWidth:"150px"}),il=sn({position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",bottom:"-8px"}),al=sn({transform:"translateY(12px)",visibility:"hidden",display:"flex","& a":{display:"flex",justifyContent:"center",alignItems:"center",fontSize:"$12",lineHeight:"$16",$$color:"$colors$neutral600",[`.${ol} &`]:{$$color:"$colors$neutral700"},color:"$$color",textDecoration:"none"}}),sl=sn({}),ll=sn(),gf=Re("div",{display:"flex",flexDirection:"column",flexGrow:1,overflow:"hidden",justifyContent:"center"}),cl=Re("div",{display:"flex",alignItems:"center","._typography":{textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:100,overflow:"hidden"}}),Ai=Re("ul",{flexGrow:1,padding:0,margin:0,listStyle:"none","& li":{alignItems:"none","&:hover":{[`& .${rl}`]:{[`& .${al}`]:{position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",visibility:"visible"},[`& .${sl}`]:{bottom:"-15px"},[`& .${nl}`]:{position:"absolute",transform:"translateY(-12px)",visibility:"hidden"},[`& .${il}`]:{position:"absolute",transform:"translateY(-12px)",bottom:"-10px"}}}}}),hf=Re(ew,{variants:{customToken:{true:{"&:hover":{cursor:"unset"}}}}}),pl=Re("div",{paddingLeft:"$5",paddingRight:"$5",borderRadius:"$md",display:"flex",alignItems:"center"}),ul=Re(ff,{}),yf=Re("div",{textAlign:"right",width:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",[`& .${ll}`]:{$$color:"$colors$neutral600",[`.${ol} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),Hn=Re("div",{display:"flex",alignItems:"end",flexDirection:"column"}),Uz=Re("div",{display:"flex",alignItems:"center"}),Sf=Re("div",{position:"relative",[`& ${Rv}`]:{borderRadius:"$xm",overflow:"hidden"}}),Cf=Re("div",{position:"absolute",backgroundColor:"$neutral100",padding:"$4",borderRadius:"50%",bottom:-6,right:-6}),kf=Re(ff,{width:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}),Tf=Re("a",{"& svg:hover":{color:"$colors$info"}}),vf=Re("div",{paddingRight:"$5","& .widget-token-list-item-btn":{width:"100%",overflow:"hidden",height:"60px"},"& .widget-token-list-item-import-btn":{height:"$20",padding:"0 $10","& ._text":{display:"flex",justifyContent:"center",alignItems:"center"},"& ._typography":{[`.${ol} &`]:{color:"$foreground"}}}});function bf(t){return vt.createElement(Ai,null,Array.from(Array(t.size),e=>vt.createElement(tw,{key:e,hasDivider:!0,start:vt.createElement(qn,{variant:"circular",width:35,height:35}),end:vt.createElement(Hn,null,vt.createElement(qn,{variant:"text",size:"large",width:70}),vt.createElement(wf,{size:4}),vt.createElement(qn,{variant:"text",size:"medium",width:50})),title:vt.createElement("div",null,vt.createElement(qn,{variant:"text",size:"large",width:90}),vt.createElement(wf,{size:4}),vt.createElement(qn,{variant:"text",size:"medium",width:90}))})))}i(bf,"LoadingTokenList");var mw=20,dw=i(t=>{let{address:e,name:o,url:n,token:r,customCssForTag:a,customCssForTagTitle:s}=t,l=e.length;return W.createElement("div",{className:rl()},o?W.createElement("div",{className:nl()},o):W.createElement(cl,{className:il()},W.createElement(Gn,{variant:"title",size:"xmedium"},r.symbol),W.createElement(Ut,{direction:"horizontal",size:4}),W.createElement(pl,{css:a},W.createElement(ul,{variant:"body",size:"xsmall",css:s},r.blockchain))),!!e&&W.createElement("div",{className:`${al()} ${!o&&sl()}`},l>10?`${e.slice(0,5)}...${e.slice(l-6,l)}`:e," ",W.createElement(Ut,{size:4,direction:"horizontal"}),W.createElement(Tf,{href:n,target:"_blank",rel:"nofollow noreferrer",onClick:c=>c.stopPropagation()},W.createElement(rw,{size:12}))))},"renderDesc");function Vn(t){let{list:e,searchedFor:o="",onChange:n,selectedBlockchain:r,showTitle:a=!0,action:s,type:l,showWarning:c=!0}=t,p=y().fetchStatus,u=y().blockchains(),{getBalanceFor:m,fetchingWallets:h}=y(),{isTokenPinned:d}=y(),{setFromToken:f,setToToken:g}=O(),{t:C}=uw(),k=Oe(),[S,T]=pw(null),w=i(()=>{l==="source"?f({token:S,meta:{blockchains:u}}):g({token:S,meta:{blockchains:u}})},"updateToken"),E=i(()=>{w(),k()},"handleImportToken"),B=i(b=>{if(b.customToken){let{customToken:A,...M}=b;return W.createElement(ow,{variant:"contained",type:"primary",size:"small",className:"widget-token-list-item-import-btn",onClick:i(j=>{j.stopPropagation(),T({...M,warning:!0})},"handleClick")},W.createElement(Gn,{variant:"body",size:"xsmall",color:"background"},C("import")))}let v=br(m(b));return s?s(b):h?W.createElement(Hn,null,W.createElement(Ao,{variant:"text",size:"large",width:70}),W.createElement(Ut,{size:4}),W.createElement(Ao,{variant:"text",size:"medium",width:50})):v&&W.createElement(yf,null,W.createElement(kf,{variant:"title",size:"small"},v.amount),W.createElement("div",null),v.usdValue&&W.createElement(Gn,{variant:"body",className:ll(),size:"xsmall"},`$${v.usdValue}`))},"endRenderer"),I=i(()=>W.createElement(cw,{itemContent:b=>{let v=e[b];if(v==="skeleton")return W.createElement(aw,{hasDivider:!0,start:W.createElement(Ao,{variant:"circular",width:35,height:35}),end:W.createElement(Hn,null,W.createElement(Ao,{variant:"text",size:"large",width:70}),W.createElement(Ut,{size:4}),W.createElement(Ao,{variant:"text",size:"medium",width:50})),title:W.createElement("div",null,W.createElement(Ao,{variant:"text",size:"large",width:90}),W.createElement(Ut,{size:4}),W.createElement(Ao,{variant:"text",size:"medium",width:90}))});let A=v.address||"",M=u.find(L=>L.name===v.blockchain);if(!M)return null;let _=rs(M.color,"main"),j={$$color:_.main150,[`.${xf} &`]:{$$color:_.main750},backgroundColor:"$$color"},R={$$color:_.main750,[`.${xf} &`]:{$$color:_.main150},color:"$$color"},X=i(()=>{typeof v!="string"&&!v.customToken&&n?.(v)},"handleClick");return W.createElement(vf,null,W.createElement(hf,{"tab-index":b,key:`${v.symbol}${v.address}`,id:`${v.symbol}${v.address}`,className:"widget-token-list-item-btn",hasDivider:!0,customToken:v.customToken,onClick:X,start:W.createElement(Sf,null,W.createElement(iw,{src:v.image===""?gr:v.image,size:30}),t.type!=="custom-token"&&d(v,t.type)&&W.createElement(Cf,null,W.createElement(lw,{size:12,color:"gray"}))),title:M?.type==="COSMOS"||v.name||!v.name&&!A?W.createElement(cl,null,W.createElement(Gn,{variant:"title",size:"xmedium"},v.symbol),W.createElement(Ut,{direction:"horizontal",size:4}),W.createElement(pl,{css:j},W.createElement(ul,{variant:"body",size:"xsmall",css:R},v.blockchain)),c&&v.warning&&W.createElement(W.Fragment,null,W.createElement(Ut,{direction:"horizontal",size:4}),W.createElement(nw,{container:N()}))):void 0,description:typeof v!="string"&&M?.info&&A&&M.type!=="COSMOS"?dw({address:A,token:v,customCssForTag:j,customCssForTagTitle:R,name:v.name,url:M.info.addressUrl.split("{wallet}").join(A)}):v.name||void 0,end:B(v)}))},totalCount:e.length,key:`${r}-${o}`}),"renderList"),x=S?co(S?.blockchain,u):null;return W.createElement(W.Fragment,null,a&&W.createElement(W.Fragment,null,W.createElement(Gn,{variant:"label",size:"large"},ml.t("Select Token")),W.createElement(Ut,{size:4})),W.createElement(gf,null,W.createElement(Ut,{size:4}),p==="loading"&&W.createElement(bf,{size:mw}),p==="success"&&(e.length?W.createElement(W.Fragment,null,W.createElement(In,{token:S,address:S?.address??"",blockchain:x??void 0,onImport:E,onExitErrorModal:()=>T(null),onExitImportModal:()=>T(null)}),W.createElement(Ai,{as:"ul"},I())):!!o&&W.createElement(sw,{title:ml.t("No results found"),description:ml.t("Try using different keywords")}))))}i(Vn,"TokenList");var Tw=gl("div",{display:"flex",justifyContent:"space-between",flexDirection:"column",flex:1}),vw=gl("div",{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",flex:"0.75"}),ww=gl(yw,{"&:hover":{"& svg":{color:"$secondary550"}}});function Ef(){let[t,e]=fl(""),{deleteCustomToken:o}=y(),n=y().customTokens(),{fromToken:r,toToken:a,setFromToken:s,setToToken:l}=O(),{mode:c}=Yo({}),p=kw(),[u,m]=fl(!1),[h,d]=fl(),f=i(S=>{let T=S.target.value;e(T)},"handleSearch"),g=c==="dark",C=n.filter(S=>tt(S.symbol,t)||tt(S.address||"",t)||tt(S.name||"",t)),k=i(()=>{if(h){let S=a?mt(a):null,T=r?mt(r):null,w=mt(h);S===w?l({token:null}):T===w&&s({token:null}),o(h)}m(!1)},"handleDeleteCustomToken");return me.createElement(oe,{header:{title:zt.t("Custom Tokens")}},me.createElement(re,null,me.createElement(Tw,null,n.length?me.createElement(me.Fragment,null,me.createElement(Tt,{value:t,setValue:e,fullWidth:!0,color:"light",variant:"contained",placeholder:zt.t("Search Token"),onChange:f}),me.createElement(Kn,{size:16}),me.createElement(Vn,{list:C,type:"custom-token",searchedFor:t,showTitle:!1,showWarning:!1,action:S=>me.createElement(ww,{id:"widget-custom-token-delete-icon-btn",variant:"ghost",onClick:()=>{m(!0),d(S)}},me.createElement(hw,{size:12,color:"gray"}))})):me.createElement(vw,null,me.createElement(Cw,{icon:g?me.createElement(fw,{size:200}):me.createElement(gw,{size:200}),title:zt.t("No custom tokens"),description:zt.t("press the button to add your custom token")})),me.createElement(Kn,{size:20}),me.createElement(dl,{id:"widget-custom-token-add-btn",type:"primary",variant:"contained",size:"large",onClick:()=>p(F.addCustomTokens)},zt.t("Add Custom Token"))),me.createElement(J,{open:u,dismissible:!0,onClose:()=>m(!1),container:N()},me.createElement(Sw,{title:zt.t("Delete Custom Token"),type:"error",description:zt.t("Are you sure you want to Delete this Token?")},me.createElement(Kn,{size:40}),me.createElement(Kn,{size:10}),me.createElement(dl,{fullWidth:!0,id:"widget-custom-token-delete-modal-yes-btn",variant:"contained",type:"primary",size:"large",onClick:k},zt.t("Yes, Delete it")),me.createElement(Kn,{size:12}),me.createElement(dl,{id:"widget-custom-token-delete-modal-no-btn",fullWidth:!0,variant:"outlined",type:"primary",size:"large",onClick:()=>m(!1)},zt.t("No, Continue"))))))}i(Ef,"CustomTokensPage");import{i18n as Ge}from"@lingui/core";import{useManager as Qw}from"@rango-dev/queue-manager-react";import{Button as vl,darkTheme as Hw,Divider as Bo,MessageBox as qw,NotFound as Gw,styled as wl,Typography as Wi}from"@rango-dev/ui";import{TransactionStatus as Yn}from"rango-types";import ie,{useMemo as Gf,useState as Li}from"react";import{useNavigate as Vw}from"react-router-dom";import{FilterIcon as Bw,Popover as Ww}from"@rango-dev/ui";import No from"react";import{css as bw,darkTheme as Ni,IconButton as xw,styled as jn}from"@rango-dev/ui";var hl=jn("div",{position:"relative","&::before":{position:"absolute",right:"1px",top:"-1px",width:"$8",height:"$8",borderRadius:"100%",backgroundColor:"$neutral300",[`.${Ni} &`]:{backgroundColor:"$neutral400"},padding:"$2"},variants:{isSelect:{true:{"&::before":{content:""}}}}}),If=jn(xw,{width:"$36",height:"$36",position:"relative",padding:"0",overflow:"unset",backgroundColor:"$neutral300",[`.${Ni} &`]:{backgroundColor:"$neutral400"},"&:hover":{backgroundColor:"$secondary100",[`.${Ni} &`]:{backgroundColor:"$neutral"},[`& ${hl}::before`]:{backgroundColor:"$secondary100",[`.${Ni} &`]:{backgroundColor:"$neutral"}}},variants:{isSelect:{true:{border:"1px solid $secondary"}}}}),Af=jn("div",{position:"absolute",width:"$6",height:"$6",display:"flex",justifyContent:"center",alignItems:"center",borderRadius:"3px",top:"$0",right:"1px",backgroundColor:"$secondary500"}),Nf=jn("div",{padding:"$15",borderRadius:"$sm",width:"248px",backgroundColor:"$background",zIndex:10}),Bf=bw({display:"flex",justifyContent:"space-between",alignItems:"center"}),Wf=jn("ul",{margin:0,listStyle:"none",height:"100%",padding:0,".item-start-container":{paddingRight:"0 !important"}});import{i18n as Lf}from"@lingui/core";import{Button as Ew,Divider as Mf,ListItemButton as Iw,Radio as Aw,RadioRoot as Nw,Typography as Pf}from"@rango-dev/ui";import at from"react";function _f(t){let{filterBy:e,onClickItem:o}=t;return at.createElement(Nf,null,at.createElement("div",{className:Bf()},at.createElement(Pf,{size:"small",variant:"body"},Lf.t("Status")),at.createElement(Ew,{id:"widget-filter-selector-reset-btn",variant:"ghost",size:"xxsmall",onClick:()=>o("")},Lf.t("Reset"))),at.createElement(Mf,{size:10}),at.createElement(Nw,{value:e},at.createElement(Wf,null,t.list.map((n,r)=>at.createElement(Iw,{key:n.id,style:{height:"40px",width:"100%"},selected:!1,hasDivider:t.list.length-1!=r,id:n.id,title:at.createElement(at.Fragment,null,at.createElement(Mf,{direction:"horizontal",size:4}),at.createElement(Pf,{size:"medium",variant:"body"},n.title)),start:at.createElement(Aw,{value:n.id}),onClick:o})))))}i(_f,"FilterSelectorContent");function yl(t){let{onClickItem:e,onOpenChange:o,filterBy:n,list:r,open:a}=t;return No.createElement("div",null,No.createElement(Ww,{open:a,align:"end",onOpenChange:o,container:N(),content:No.createElement(_f,{list:r,filterBy:n,onClickItem:s=>{e(s),o(!1)}})},No.createElement(If,{id:"widget-filter-selector-filter-icon-btn",variant:"default",isSelect:!!n,onClick:()=>o(!t.open)},No.createElement(hl,{isSelect:!!n},No.createElement(Bw,{size:16,color:"black"}),!!n&&No.createElement(Af,null)))))}i(yl,"FilterSelector");import{i18n as Pw}from"@lingui/core";import{Divider as Uf,GroupedVirtualizedList as _w,Skeleton as Dw,SwapListItem as zf,Typography as $w}from"@rango-dev/ui";import qe,{useCallback as Qf,useEffect as Fw,useRef as Ow,useState as Uw}from"react";function Df(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(Df,"calculateGroupsSoFar");import{css as Lw,darkTheme as Mw,styled as Xn}from"@rango-dev/ui";var Sl=Lw(),$f=Xn("div",{display:"flex",justifyContent:"center",alignItems:"center",padding:"$5"}),Cl=Xn("div",{width:"100%",display:"flex",flexDirection:"column",backgroundColor:"$background",padding:"$10 $5 0 $5",[`& .${Sl}`]:{$$color:"$colors$neutral600",[`.${Mw} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),kl=Xn("div",{display:"flex",justifyContent:"flex-start",padding:"$2"}),Ff=Xn("div",{gap:"$10",display:"flex",flexDirection:"column"}),Of=Xn("div",{height:"100%",display:"flex",justifyContent:"center",alignItems:"center"});var zw=10;function Tl(t){let{list:e,onSwapClick:o,groupBy:n,isLoading:r}=t,[a,s]=Uw([]),l=Ow(0),{swaps:c,groupCounts:p,groups:u}=n(e),m=Qf(Df,[]),h=Qf(()=>{let d=e.length-l.current;d&&(l.current+=Math.min(d,zw),s(m(p,l.current)))},[e.length]);if(Fw(()=>{r||h()},[r,h]),r){let d=[1,2];return qe.createElement(qe.Fragment,null,[d,d].map((g,C)=>qe.createElement(Cl,{key:C},qe.createElement(kl,null,qe.createElement(Dw,{variant:"text",width:60,size:"small"}),qe.createElement(Uf,{size:16})),qe.createElement(Uf,{size:4}),qe.createElement(Ff,null,g.map((S,T)=>qe.createElement(zf,{isLoading:!0,key:T}))))))}return qe.createElement(_w,{endReached:()=>{l.current<e.length&&h()},groupCounts:a,groupContent:d=>qe.createElement(Cl,null,qe.createElement(kl,null,qe.createElement($w,{variant:"label",size:"medium",className:Sl()},u[d]))),itemContent:(d,f)=>{let g=c[d];if(!g)return null;let C=g.steps[0],k=g.steps[g.steps.length-1];return qe.createElement($f,{key:g.requestId},qe.createElement(zf,{requestId:g.requestId,creationTime:g.creationTime,status:g.status,onClick:o,tooltipContainer:N(),onlyShowTime:u[f]===Pw.t("Today"),swapTokenData:{from:{token:{image:C.fromLogo,displayName:C.fromSymbol},blockchain:{image:C.fromBlockchainLogo||""},amount:P(g.inputAmount,6,6),realAmount:g.inputAmount},to:{token:{image:k.toLogo,displayName:k.toSymbol},blockchain:{image:k.toBlockchainLogo||""},amount:P(k.outputAmount||k.expectedOutputAmountHumanReadable||"",6,6),realAmount:k.outputAmount||k.expectedOutputAmountHumanReadable||""}}}))}})}i(Tl,"HistoryGroupedList");import{i18n as Bi}from"@lingui/core";import Hf from"dayjs";var qf=i(t=>{let e=new Map([["today",{title:Bi.t("Today"),swaps:[]}],["week",{title:Bi.t("This week"),swaps:[]}],["month",{title:Bi.t("This month"),swaps:[]}],["year",{title:Bi.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=Hf();t.forEach(c=>{let p=Number(c.creationTime),u=Hf(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 m=new Date(p).getFullYear().toString();o(m,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=wl("div",{overflowY:"visible",width:"100%",display:"flex",flexDirection:"column",gap:15,height:"100%"}),jw=wl("div",{display:"flex",justifyContent:"center",alignItems:"center"}),Xw=wl("div",{"._typography":{color:"$neutral700",[`.${Hw}&`]:{color:"$neutral900"}}}),Yw=[{id:Yn.SUCCESS,title:Ge.t("Complete")},{id:Yn.RUNNING,title:Ge.t("Running")},{id:Yn.FAILED,title:Ge.t("Failed")}],Zw=i((t,e)=>t?.length?t.filter(o=>bt(o.fromBlockchain,e)||bt(o.toBlockchain,e)||bt(o.toSymbol,e)||bt(o.fromSymbol,e)).length:!1,"isStepContainsText");function Vf(){let t=Vw(),{manager:e,state:o}=Qw(),n=ft(e).map(({swap:T})=>T),[r,a]=Li(""),[s,l]=Li(!1),c=!o.loadedFromPersistor,[p,u]=Li(""),[m,h]=Li(!1),d=i(T=>{let w=T.target.value;a(w)},"handleSearch"),f=Gf(()=>!r&&!p?n:n.filter(T=>{let{inputAmount:w,status:E,steps:B,requestId:I}=T;return(!r||bt(w,r)||bt(E,r)||Zw(B,r)||bt(I,r))&&(!p||p===E)}),[n,r,p]),g=!f?.length&&!c,C=i(()=>h(!1),"onCloseModal"),k=i(async()=>{try{await e?.clearQueue(),h(!1)}catch(T){console.log(T)}},"onClear"),S=Gf(()=>!n.some(T=>T.status===Yn.SUCCESS||T.status===Yn.FAILED),[n]);return ie.createElement(oe,{header:{title:Ge.t("History"),suffix:ie.createElement(jt,null,ie.createElement(vl,{id:"widget-history-clear-btn",disabled:S,variant:"ghost",size:"xsmall",onClick:()=>h(!0)},ie.createElement(Wi,{size:"medium",variant:"label",color:"error"},Ge.t("Clear"))))}},ie.createElement(re,null,ie.createElement(jw,null,ie.createElement(Tt,{setValue:a,fullWidth:!0,variant:"contained",placeholder:Ge.t("Search Transaction"),autoFocus:!0,onChange:d,style:{height:36},value:r}),ie.createElement(Bo,{size:10,direction:"horizontal"}),ie.createElement(yl,{filterBy:p,open:s,onOpenChange:T=>l(T),onClickItem:T=>u(T),list:Yw})),ie.createElement(Bo,{size:"16"}),ie.createElement(Kw,null,g&&ie.createElement(Of,null,ie.createElement(Bo,{size:32}),ie.createElement(Gw,{title:r?Ge.t("No results found"):Ge.t("No transactions"),titleColor:r?void 0:"$info",hasIcon:!!r,description:r?Ge.t("Try using different keywords"):Ge.t("Your transaction history is stored locally and will appear here after you start a swap")})),!g&&ie.createElement(Tl,{list:f,onSwapClick:t,groupBy:qf,isLoading:c}))),ie.createElement(J,{open:m,onClose:C,container:N()},ie.createElement(Bo,{size:20}),ie.createElement(qw,{type:"warning",title:Ge.t("Clear Transaction History"),description:ie.createElement(Xw,null,ie.createElement(Wi,{variant:"body",size:"medium"},Ge.t("Proceeding will remove all successful and failed transactions from the widget. Do you want to continue?")),ie.createElement(Bo,{size:"24"}),ie.createElement(Wi,{variant:"body",size:"small"},Ge.t("Note: This does not erase your transaction history on the chain; it only removes them here.")))}),ie.createElement(Bo,{size:30}),ie.createElement(vl,{id:"widget-history-clear-modal-yes-btn",variant:"contained",type:"primary",size:"large",onClick:k},Ge.t("Yes, Clear the history")),ie.createElement(Bo,{size:10}),ie.createElement(vl,{id:"widget-history-clear-modal-no-btn",variant:"outlined",type:"primary",size:"large",onClick:C},ie.createElement(Wi,{variant:"title",size:"medium",color:"primary"},Ge.t("No, Cancel")))))}i(Vf,"HistoryPage");import{i18n as Tb}from"@lingui/core";import{Button as vb,Divider as dg,styled as wb,WarningIcon as bb}from"@rango-dev/ui";import xb from"bignumber.js";import Ve,{useEffect as fg,useState as gg}from"react";import{useNavigate as Eb}from"react-router-dom";import{i18n as jf}from"@lingui/core";import{Alert as Rw,Divider as bl,NoRouteIcon as eb,Typography as tb}from"@rango-dev/ui";import Wo from"react";import{styled as Jw}from"@rango-dev/ui";var Kf=Jw("div",{display:"flex",flexDirection:"column",alignItems:"center"});function xl(){let{fromToken:t,toToken:e}=O();return!!t&&!!e&&Wt(t,e)?Wo.createElement(Kf,null,Wo.createElement(bl,{size:10}),Wo.createElement(eb,{size:24,color:"gray"}),Wo.createElement(bl,{size:4}),Wo.createElement(tb,{variant:"title",size:"small"},jf.t("No Routes Found")),Wo.createElement(bl,{size:4}),Wo.createElement(Rw,{title:jf.t("You cannot use the same token for From and To."),type:"warning",variant:"alarm"})):null}i(xl,"SameTokensWarning");import{i18n as sb}from"@lingui/core";import{Header as lb}from"@rango-dev/ui";import oo,{useEffect as cb,useState as pb}from"react";import{i18n as nb}from"@lingui/core";import{Divider as Il,FullExpandedQuote as rb,Typography as ib}from"@rango-dev/ui";import Se from"react";import{styled as El}from"@rango-dev/ui";var Xf=El("div",{display:"flex",justifyContent:"center",flexDirection:"column",height:"100%"}),Yf=El("div",{display:"flex",justifyContent:"space-between",alignItems:"center"}),Zf=El("div",{width:"146px"});import{i18n as Zn}from"@lingui/core";import{Select as ob}from"@rango-dev/ui";import Jf from"react";function Mi(t){let{updateQuotePartialState:e,sortStrategy:o}=O(),n=[{value:"SMART",label:Zn.t("Smart Routing")},{value:"FEE",label:Zn.t("Lowest Fee")},{value:"SPEED",label:Zn.t("Fastest Transfer")},{value:"NET_OUTPUT",label:Zn.t("Maximum Return")},{value:"PRICE",label:Zn.t("Maximum Output")}];return Jf.createElement(Zf,null,Jf.createElement(ob,{container:t.container,options:n,value:o,handleItemClick:r=>{e("sortStrategy",r.value)},variant:"filled"}))}i(Mi,"SelectStrategy");var Rf=3;function Jn(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:m,toToken:h,sortStrategy:d,error:f}=O(),{slippage:g,customSlippage:C}=y(),{findToken:k}=y(),S=l||N(),T=!!p&&p.results.length,w=C??g,E=i(x=>{if(!m||!h||!p)return null;let b={requestAmount:p.requestAmount,validationStatus:null,...x};return Vo({currentQuote:b,userSlippage:w,findToken:k})},"getQuoteWarning"),B=f?.type===0||f?.type===1,I=p?.results?Or(d,p?.results):[];return Se.createElement(Se.Fragment,null,a&&Se.createElement(Se.Fragment,null,Se.createElement(Yf,null,Se.createElement(ib,{size:"xmedium",variant:"title"},nb.t("Sort by")),Se.createElement(Mi,{container:S})),Se.createElement(Il,{size:"10"})),e&&Array.from({length:Rf},(x,b)=>Se.createElement(Se.Fragment,{key:b},s?Se.createElement(rb,{loading:!0}):Se.createElement(Un,{tagHidden:!1,type:"list-item",expanded:!1}),b!==Rf-1&&Se.createElement(Il,{size:16}))),!e&&Se.createElement(Se.Fragment,null,T?I.map((x,b)=>{let v=E(x),A=Zs(x.swaps),M=I.length-1===b;return Se.createElement(Se.Fragment,{key:x.requestId},Se.createElement(Io,{showModalFee:r,container:S,selected:c?.requestId===x.requestId,tagHidden:!1,quote:{...x,requestAmount:p.requestAmount,validationStatus:null},loading:e,error:A?.options||null,warning:v,fullExpandedMode:s,onClick:_=>{A||u("warning",v),u("error",A?.options||null),o(_)},type:"list-item"}),!M&&Se.createElement(Il,{size:16}))}):B&&Se.createElement(Xf,null,Se.createElement(Wn,{size:s?"large":"small",error:f,fetch:n}))))}i(Jn,"Quotes");import{darkTheme as ab,styled as eg}from"@rango-dev/ui";var tg=eg("div",{transition:"width 0.2s, opacity 0.2s, margin-left 0.2s",height:"700px",width:"390px",position:"relative",opacity:1,marginLeft:"$16",backgroundColor:"$neutral100",[`.${ab} &`]:{backgroundColor:"$neutral300"},variants:{expandMode:{default:{width:"390px"},full:{width:"719px"}}},"&.is-hidden":{width:0,height:0,opacity:0,marginLeft:0}}),og=eg("div",{position:"relative",overflow:"hidden",padding:"$20",flexGrow:1,display:"flex",flexDirection:"column",overflowY:"auto",borderRadius:"$primary",backgroundColor:"$background"});var ub=100;function Al(t){let{fetch:e,loading:o,onClickOnQuote:n,onClickRefresh:r,isVisible:a}=t,[s,l]=pb(!1),c=s?"":"is-hidden",{config:p}=y(),u=p?.variant==="full-expanded",m=uo();return cb(()=>{let h=null;return a?h=setTimeout(()=>{l(!0)},ub):(l(!1),h&&clearTimeout(h)),()=>{h&&clearTimeout(h)}},[a]),oo.createElement(tg,{expandMode:p?.variant==="full-expanded"?"full":"default",className:`${c} ${Jr()}`,id:$e.EXPANDED_BOX_ID},oo.createElement(lb,{title:sb.t("Routes"),suffix:oo.createElement(oo.Fragment,null,oo.createElement(Mi,{container:m}),oo.createElement(wo,{container:m,onClickRefresh:r,hidden:["history","notifications","settings"]}))}),oo.createElement(og,null,oo.createElement(Jn,{showModalFee:!0,fetch:e,hasSort:!1,loading:o,container:uo(),onClickOnQuote:n,fullExpandedMode:u})))}i(Al,"ExpandedQuotes");import{i18n as cg}from"@lingui/core";import{SwapInput as pg}from"@rango-dev/ui";import gb from"bignumber.js";import Rn from"react";import{ReverseIcon as fb}from"@rango-dev/ui";import Bl from"react";import{keyframes as mb,styled as ng}from"@rango-dev/ui";var Nl=450,db=mb({"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)"}}),rg=ng("div",{position:"absolute",bottom:"-12px",left:"50%",transform:"translate(-50%, 10%)",cursor:"pointer"}),ig=ng("div",{borderRadius:"$md",border:"3px solid $background",background:"$neutral100",width:"$24",height:"$24",display:"flex",justifyContent:"center",alignItems:"center",color:"$foreground","&.rotate":{"& svg":{animation:`${db} ${Nl}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 Wl(){let t=O.use.switchFromAndTo();return Bl.createElement(rg,null,Bl.createElement(ig,{onClick:e=>{let o=e.currentTarget;o.classList.add("rotate"),setTimeout(()=>{o.classList.remove("rotate")},Nl),t()}},Bl.createElement(fb,{size:12})))}i(Wl,"SwitchFromAndToButton");import{styled as ag}from"@rango-dev/ui";var sg=ag("div",{display:"flex",flexDirection:"column",gap:"$5",alignSelf:"stretch"}),lg=ag("div",{position:"relative"});function Ll(t){let{fetchingQuote:e,fetchMetaStatus:o,onClickToken:n,isExpandable:r}=t,{fromToken:a,fromBlockchain:s,toToken:l,toBlockchain:c,setInputAmount:p,inputAmount:u,inputUsdValue:m,outputAmount:h,outputUsdValue:d,selectedQuote:f}=O(),{connectedWallets:g,getBalanceFor:C}=y(),k=a?C(a):null,S=br(k)?.amount??"0",T=k?new gb(k.amount).shiftedBy(-k.decimals):le,w=!!s&&ep(g,s.name),E=!Qa(f,u,m),B=!Qa(f,u,d),I=!m||!d||!d.gt(0)?null:Pt(m.toString(),d.toString());return Rn.createElement(sg,null,Rn.createElement(lg,null,Rn.createElement(pg,{label:cg.t("From"),mode:"From",onInputChange:p,balance:S,chain:{displayName:s?.displayName||"",image:s?.logo},token:{displayName:a?.symbol||"",image:a?.image,securityWarning:!!a?.warning},onClickToken:()=>n("from"),price:{value:u,usdValue:E?void 0:P(m,4,4),realUsdValue:E?void 0:m?.toString(),error:E?ee().unknownPriceError.impactTitle:void 0},disabled:o==="failed",loading:o==="loading",loadingBalance:w,tooltipContainer:N(),onSelectMaxBalance:()=>{let x=P(T,k?.decimals),b=k?.amount?x.split(",").join(""):"";p(b)},anyWalletConnected:g.length>0}),Rn.createElement(Wl,null)),Rn.createElement(pg,{sharpBottomStyle:!r&&(!!f||e),label:cg.t("To"),mode:"To",fetchingQuote:e,chain:{displayName:c?.displayName||"",image:c?.logo},token:{displayName:l?.symbol||"",image:l?.image,securityWarning:!!l?.warning},percentageChange:P(Pt(m,d),2,2),warningLevel:_t(I??0),price:{value:P(h,6,6),usdValue:B?void 0:P(d,4,4),realValue:h?.toString(),realUsdValue:B?void 0:d?.toString(),error:B?ee().unknownPriceError.impactTitle:void 0},onClickToken:()=>n("to"),disabled:o==="failed",loading:o==="loading",tooltipContainer:N()}))}i(Ll,"Inputs");import{useCallback as hb,useEffect as yb,useRef as Sb,useState as Cb}from"react";function ug(){let{fetch:t,loading:e,cancelFetch:o}=bi({request:async(n,r)=>await ot().getAllRoutes(n,r)});return{fetch:t,loading:e,cancelFetch:o}}i(ug,"useFetchAllQuotes");var kb=600;function Pi({refetchQuote:t}){let{fetch:e,cancelFetch:o}=ug(),{excludeLiquiditySources:n,routing:r}=y().config,{connectedWallets:a}=y(),l=a.some(Ie=>Ie.isContractWallet),{fromToken:c,toToken:p,inputAmount:u,inputUsdValue:m,selectedQuote:h,sortStrategy:d,resetQuote:f,error:g,warning:C,setSelectedQuote:k,updateQuotePartialState:S}=O(),{slippage:T,customSlippage:w,affiliatePercent:E,affiliateRef:B,affiliateWallets:I,fetchStatus:x}=y(),b=y().getLiquiditySources(),v=y().getDisabledLiquiditySources(),A=y().excludeLiquiditySources(),{findToken:M}=y(),[_,j]=Cb(!0),R=Sb(u),X=w??T,H=!c||!p||Wt(c,p)||!fn(u),ae=i(Ie=>{j(Ie)},"resetState"),G=i(Ie=>{let{fromToken:je,toToken:se,inputAmount:pt,liquiditySources:V,excludeLiquiditySources:D,disabledLiquiditySources:q,slippage:K,affiliateRef:ge,affiliatePercent:ce,affiliateWallets:_e}=Ie;if(_||ae(!0),!H&&je&&se){f();let Xe=vu({fromToken:je,toToken:se,inputAmount:pt,liquiditySources:V,excludeLiquiditySources:D,disabledLiquiditySources:q,wallets:a,slippage:K,affiliateRef:ge,affiliatePercent:ce,affiliateWallets:_e,contractCall:l});Fo("experimental",r)&&(Xe.experimental=!0),Fo("avoidNativeFee",r)&&(Xe.avoidNativeFee=!0),Fo("enableCentralizedSwappers",r)&&(Xe.enableCentralizedSwappers=!0),r?.maxLength&&(Xe.maxLength=r.maxLength),e(Xe).then(ke=>{let De=Or(d,ke.results),Vt=pu(h,De,ke.requestAmount);j(!1),S("quotes",ke),k(Vt),xi({diagnosisMessages:ke.diagnosisMessages,requestId:Vt?.requestId||"",swaps:Vt?.swaps});let lo=Vt&&Vo({currentQuote:Vt,userSlippage:X,findToken:M});S("warning",lo)}).catch(ke=>{let{error:De}=Ei(ke);(De?.type===0||De?.type===1)&&f(),De?.type!==2&&(S("error",De),j(!1))})}},"fetch"),fe=hb(Sr(Ie=>{G(Ie)},kb),[H]);return yb(()=>{if(!t){j(!1);return}if(x!=="success")return;if(H){j(!1),(h||g||C)&&f();return}if(!fn(u)||m?.eq(0)){ae(!1),o();return}f(),ae(!0);let Ie=G;return R.current&&R.current!=u&&(Ie=fe),R.current=u,Ie({inputAmount:u,fromToken:c,toToken:p,liquiditySources:b,excludeLiquiditySources:A,disabledLiquiditySources:v,slippage:X,affiliateRef:B,affiliatePercent:E,affiliateWallets:I,contractCall:l}),o},[x,u,c?.symbol,c?.address,c?.blockchain,p?.symbol,p?.address,p?.blockchain,H,b?.length,n,v.length,X,B,E,l,JSON.stringify(I)]),{fetch:()=>G({inputAmount:u,fromToken:c,toToken:p,liquiditySources:b,excludeLiquiditySources:A,disabledLiquiditySources:v,slippage:X,affiliateRef:B,affiliatePercent:E,affiliateWallets:I,contractCall:l}),loading:_}}i(Pi,"useSwapInput");function mg(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(mg,"emitPreventableEvent");var Ib=wb("div",{display:"flex",alignItems:"flex-start",maxHeight:700,"& .footer__alert":{paddingTop:"0 !important"}}),Ab=300;function hg(){let t=Eb(),{fromToken:e,toToken:o,inputAmount:n,selectedQuote:r,refetchQuote:a,error:s,warning:l,quotes:c,setSelectedQuote:p,resetQuoteWallets:u,setQuoteWarningsConfirmed:m,updateQuotePartialState:h}=O(),[d,f]=gg(!1),{isLargeScreen:g,isExtraLargeScreen:C}=hi(),{fetch:k,loading:S}=Pi({refetchQuote:a}),{config:T,fetchStatus:w,connectedWallets:E}=y(),{isActiveTab:B}=ne(),[I,x]=gg(!1),v=Su({fetchMetaStatus:w,fetchingQuote:S,inputAmount:n,quote:r,anyWalletConnected:E.length>0,error:s,warning:l,needsToWarnEthOnPath:!1}),A=sp(g,C,T?.variant),M=!!n&&!!e&&!!o&&new xb(n).gt(0)&&!Nu(e,o),_=M&&w==="success"&&S,X=(!A||A&&c?.results.length)&&(l||s);fg(()=>{u(),h("refetchQuote",!0)},[]),fg(()=>{f(M)},[M]);let L=(r||s)&&!I?k:void 0,H=i(G=>{A&&d?(f(!1),setTimeout(()=>{t(G)},Ab)):t(G)},"onHandleNavigation"),ae=i(G=>{r?.requestId!==G.requestId&&(x(!1),p(G))},"onClickOnQuote");return Ve.createElement(Ib,null,Ve.createElement(oe,{height:"auto",footer:Ve.createElement(vb,{id:`widget-swap-${v.action}-btn`,type:"primary",size:"large",disabled:v.disabled||!B,prefix:v.action==="confirm-warning"&&Ve.createElement(bb,null),fullWidth:!0,onClick:()=>{v.action==="connect-wallet"?mg({type:"clickConnectWallet"},()=>H(F.wallets)):v.action==="confirm-warning"?x(!0):H(F.confirmSwap)}},v.title),header:{onWallet:()=>{H(F.wallets)},hasBackButton:!1,title:T.title||Tb.t("Swap"),suffix:Ve.createElement(wo,{hidden:A?["refresh"]:void 0,onClickRefresh:L,onClickHistory:()=>H(F.swaps),onClickSettings:()=>{H(F.settings)}})}},Ve.createElement(re,null,Ve.createElement(Ll,{fetchingQuote:_,fetchMetaStatus:w,isExpandable:A,onClickToken:G=>{H(G==="from"?F.fromSwap:F.toSwap)}}),Ve.createElement(dg,{size:"2"}),A?null:Ve.createElement(Io,{quote:r,loading:_,error:s,tagHidden:!1,warning:l,type:"basic",onClickAllRoutes:c&&c.results.length>1?()=>{h("refetchQuote",!1),H(F.routes)}:void 0}),X?Ve.createElement(Ve.Fragment,null,Ve.createElement(dg,{size:"10"}),Ve.createElement(Mn,{warning:l,error:s,couldChangeSettings:!0,refetchQuote:k,showWarningModal:I,confirmationDisabled:!B,onOpenWarningModal:()=>x(!0),onCloseWarningModal:()=>x(!1),onConfirmWarningModal:()=>{x(!1),m(!0),H(F.confirmSwap)},onChangeSettings:()=>H(F.settings)})):null,Ve.createElement(xl,null))),A?Ve.createElement(Al,{loading:_,onClickOnQuote:ae,fetch:k,onClickRefresh:L,isVisible:d}):null)}i(hg,"Home");import{i18n as yg}from"@lingui/core";import{Alert as Nb,Divider as Bb,List as Wb,ListItemButton as Lb,Radio as Mb,RadioRoot as Pb,Typography as _b}from"@rango-dev/ui";import Nt from"react";function no(){let{setLanguage:t,language:e,config:o}=y(),n=mp,r=o?.language||Oo;return{activeLanguage:e||r,languages:n,defaultLanguage:r,changeLanguage:a=>t(a||Oo),resetLanguage:()=>t(null)}}i(no,"useLanguage");function Sg(){let{activeLanguage:t,changeLanguage:e,languages:o}=no(),n=Oe(),r=o.map(a=>{let{local:s,label:l,SVGFlag:c}=a;return{id:`widget-setting-languages-${s}-item-btn`,value:s,title:Nt.createElement(_b,{variant:"title",size:"xmedium"},l),onClick:()=>{e(a.local),n()},end:Nt.createElement(Mb,{value:s}),start:Nt.createElement(c,null)}});return Nt.createElement(oe,{header:{title:yg.t("Language")}},Nt.createElement(re,null,Nt.createElement(Nb,{type:"warning",variant:"alarm",title:"Warning: We are using machine translation, so the translations may be inaccurate."}),Nt.createElement(Bb,{size:"8"}),Nt.createElement(Pb,{value:t},Nt.createElement(Wb,{type:Nt.createElement(Lb,{title:yg.t("language"),id:"_",onClick:()=>console.log()}),items:r}))))}i(Sg,"LanguagePage");import{i18n as Qt}from"@lingui/core";import{Button as Ub,Checkbox as zb,Image as Qb,ListItemButton as Hb,NotFound as qb,Typography as Gb}from"@rango-dev/ui";import Ke,{useState as Vb}from"react";import{Checkbox as Fb,Skeleton as kg}from"@rango-dev/ui";import tr from"react";import{styled as Ml}from"@rango-dev/ui";var er=Ml("ul",{padding:"$15 $5 0",margin:0,listStyle:"none",height:"100%",overflowY:"auto",variants:{disabled:{true:{pointerEvents:"none"}}}}),Pl=Ml("div",{width:80,display:"flex",justifyContent:"flex-end"}),_l=Ml("div",{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%"});import{ListItem as Db,styled as $b}from"@rango-dev/ui";var Cg=$b(Db,{height:61});var Ob=30;function Dl(){return tr.createElement(er,null,Array.from(Array(Ob),(t,e)=>tr.createElement(Cg,{hasDivider:!0,key:e,start:tr.createElement(kg,{variant:"circular",width:35,height:35}),title:tr.createElement(kg,{variant:"text",size:"large",width:90}),end:tr.createElement(Fb,{checked:!1})})))}i(Dl,"LoadingLiquiditySourceList");function $l({sourceType:t}){let e=y().fetchStatus,o=y().swappers(),n=y().getDisabledLiquiditySources(),[r,a]=Vb(""),s=y().toggleLiquiditySource,l=y().isInCampaignMode(),c=Ir(o,n),p={Exchanges:Qt.t("Exchanges"),Bridges:Qt.t("Bridges")},u=[];t==="Exchanges"&&u.push("DEX"),t==="Bridges"&&u.push("BRIDGE","AGGREGATOR","OFF_CHAIN");let m=c.filter(k=>u.includes(k.type)),h=m.length===m.filter(k=>k.selected).length,d=i(()=>{m.forEach(k=>{h?s(k.groupTitle):k.selected||s(k.groupTitle)})},"toggleAllSources"),f=m.map(k=>{let{selected:S,groupTitle:T,logo:w,id:E,...B}=k;return{id:`widget-setting-liquidity-source-${E.toLowerCase().replace(/\s+/g,"-")}-item-btn`,start:Ke.createElement(Qb,{src:w,size:22,type:"circular"}),onClick:()=>{l||s(T)},end:Ke.createElement(zb,{checked:S,disabled:l}),title:Ke.createElement(Gb,{variant:"title",size:"xmedium"},Qt.t(T)),selected:S,groupTitle:T,logo:w,...B}}),g=i(k=>{let S=k.target.value;a(S)},"handleSearch"),C=f;return r&&(C=f.filter(k=>bt(k.groupTitle,r))),Ke.createElement(oe,{header:{title:Qt.t(t),suffix:Ke.createElement(Pl,null,Ke.createElement(Ub,{id:`widget-liquidity-source-${h?"deselect-all":"select-all"}-btn`,variant:"ghost",size:"xsmall",onClick:d},h?Qt.t("Deselect all"):Qt.t("Select all")))}},Ke.createElement(re,{view:!0},Ke.createElement(Tt,{value:r,setValue:a,fullWidth:!0,color:"light",variant:"contained",placeholder:Qt.t("Search {sourceType}",{sourceType:p[t]}),onChange:g}),e==="loading"&&Ke.createElement(Dl,null),!C.length&&r?Ke.createElement(_l,null,Ke.createElement(qb,{title:Qt.t("No results found"),description:Qt.t("Try using different keywords")})):e==="success"&&Ke.createElement(er,{disabled:l},C.map(k=>{let{groupTitle:S,...T}=k;return Ke.createElement(Ke.Fragment,{key:k.id},Ke.createElement(Hb,{style:{height:"61px"},...T,selected:!1,hasDivider:!0}))}))))}i($l,"LiquiditySourcePage");import{i18n as Kb}from"@lingui/core";import _i from"react";import{useNavigate as jb}from"react-router-dom";function Tg(){let t=jb(),e=Oe(),{selectedQuote:o,refetchQuote:n,setSelectedQuote:r,updateQuotePartialState:a,error:s}=O(),{fetch:l,loading:c}=Pi({refetchQuote:n}),p=i(h=>{r(h),a("refetchQuote",!1),e()},"onClickOnQuote"),u=`../${F.settings}`,m=`../${F.wallets}`;return _i.createElement(oe,{header:{onWallet:()=>{t(m),a("refetchQuote",!0)},onBack:()=>{a("refetchQuote",!1)},title:Kb.t("Routes"),suffix:_i.createElement(wo,{onClickRefresh:o||s?l:void 0,hidden:["notifications","history"],onClickSettings:()=>{t(u),a("refetchQuote",!0)}})}},_i.createElement(re,null,_i.createElement(Jn,{fetch:l,loading:c,onClickOnQuote:p})))}i(Tg,"RoutesPage");import{i18n as Ag}from"@lingui/core";import{Divider as Ng,getCategoriesCount as rx,SelectableCategoryList as ix}from"@rango-dev/ui";import Ht,{useState as Bg}from"react";import{useNavigate as ax}from"react-router-dom";import{i18n as Fl}from"@lingui/core";import{Divider as Jb,Image as Rb,ListItemButton as ex,NotFound as tx,Typography as Ig}from"@rango-dev/ui";import st,{useEffect as ox,useState as nx}from"react";var vg=i((t,e,o)=>t.filter(n=>Cr(n.type,o)).filter(n=>tt(n.name,e)||tt(n.displayName,e)),"filterBlockchains");import{ImageContainer as Xb,styled as wg}from"@rango-dev/ui";var bg=wg("div",{display:"flex",flexDirection:"column",overflow:"hidden",height:"100%",justifyContent:"center"}),Di=wg(An,{padding:0,margin:0,listStyle:"none",[`& ${Xb}`]:{borderRadius:"$xm",overflow:"hidden"}});import{ListItem as Yb,Skeleton as xg}from"@rango-dev/ui";import $i from"react";var Zb=20;function Eg(){return $i.createElement(Di,null,Array.from(Array(Zb),t=>$i.createElement(Yb,{key:t,hasDivider:!0,start:$i.createElement(xg,{variant:"circular",width:35,height:35}),title:$i.createElement(xg,{variant:"text",size:"large",width:90})})))}i(Eg,"LoadingBlockchainList");function Ol(t){let{list:e,searchedFor:o,onChange:n,blockchainCategory:r,showTitle:a=!0}=t,[s,l]=nx(e),{fetchStatus:c}=y();ox(()=>{l([...vg(e,o,r)])},[e,o,r]);let p=i(()=>!s.length&&o?st.createElement(tx,{title:Fl.t("No results found"),description:Fl.t("Try using different keywords")}):st.createElement(Di,{as:"ul",key:`${r}-${o}`},s.map(u=>st.createElement(ex,{key:`${u.name}-${u.chainId}`,className:"widget-blockchain-list-item-btn",hasDivider:!0,onClick:()=>n(u),start:st.createElement(Rb,{src:u.logo,size:30}),title:st.createElement(Ig,{variant:"title",size:"medium"},u.displayName),id:u.name}))),"renderList");return st.createElement(st.Fragment,null,a&&st.createElement(st.Fragment,null,st.createElement(Ig,{variant:"label",size:"large"},Fl.t("Select Chain")),st.createElement(Jb,{size:4})),st.createElement(bg,null,c==="loading"&&st.createElement(Eg,null),c==="success"&&p()))}i(Ol,"BlockchainList");function Fi(t){let{type:e}=t,o=Oe(),[n,r]=Bg(""),[a,s]=Bg("ALL"),l=O.use.setToBlockchain(),c=O.use.setFromBlockchain(),{fetchStatus:p}=y(),u=ax(),m=y().blockchains({type:e}),h=rx(m),d=!t.hideCategory&&h!==1;return Ht.createElement(oe,{header:{title:Ag.t("Select Chain")}},Ht.createElement(re,{view:!0},d&&Ht.createElement(Ht.Fragment,null,Ht.createElement(ix,{setCategory:s,category:a,blockchains:m,isLoading:p==="loading"}),Ht.createElement(Ng,{size:24})),Ht.createElement(Tt,{value:n,autoFocus:!0,placeholder:Ag.t("Search Chain"),color:"light",variant:"contained",size:"large",setValue:()=>r(""),onChange:f=>r(f.target.value)}),Ht.createElement(Ng,{size:16}),Ht.createElement(Ol,{list:m,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(Fi,"SelectBlockchainPage");import{i18n as zi}from"@lingui/core";import{Divider as $g,Spinner as Cx}from"@rango-dev/ui";import ro,{useEffect as kx,useState as Tx}from"react";import{useNavigate as vx}from"react-router-dom";import{i18n as Ql}from"@lingui/core";import{BlockchainsChip as Oi,Divider as Pg,Image as _g,Skeleton as ux,Tooltip as mx,Typography as Hl}from"@rango-dev/ui";import Me from"react";import{useEffect as cx}from"react";var Wg=["ETH","COSMOS","OSMOSIS"];function Ul(t,e,o){let n=JSON.parse(JSON.stringify(t)),r=[];if(n.sort(sx),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(lx(s)),r=n.splice(a)}return{list:n,more:r}}i(Ul,"prepare");function sx(t,e){let o=Wg,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(sx,"sortByMostUsedBlockchains");function lx(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(lx,"generateSortByPreferredBlockchainsFor");function Lg(t,e){return!!e.list.find(o=>o.name===t)}i(Lg,"isInVisibleList");function zl(t,e){let{preferredBlockchains:o,addPreferredBlockchain:n}=y();cx(()=>{if(e?.selected){let a=Ul(t,o,e);Lg(e.selected,a)||n(e?.selected)}},[e?.selected]);let r=Ul(t,o,e);return{list:r.list,more:r.more,history:[]}}i(zl,"usePrepareBlockchainList");import{styled as px}from"@rango-dev/ui";var Mg=px("div",{display:"grid",gap:"$10",gridTemplateColumns:"repeat(6, minmax(0, 1fr))"});var dx=12;function ql(t){let{blockchains:e,type:o,blockchain:n,onChange:r,onMoreClick:a}=t,s=zl(e,{limit:10,selected:n?.name}),{fetchStatus:l}=y(),c=O.use.resetToBlockchain(),p=O.use.resetFromBlockchain(),u=s.more.length>0,m=s.more.length===1,h=!m&&u;return Me.createElement(Me.Fragment,null,Me.createElement(Pg,{size:12}),Me.createElement(Hl,{variant:"label",size:"large"},Ql.t("Select Chain")),Me.createElement(Pg,{size:12}),Me.createElement(Mg,null,l==="loading"&&Array.from(Array(dx),d=>Me.createElement(ux,{key:d,variant:"rounded",height:50})),l==="success"&&Me.createElement(Me.Fragment,null,Me.createElement(Oi,{selected:!n,onClick:()=>{o==="from"?p():c()}},Me.createElement(Hl,{variant:"body",size:"xsmall",color:"secondary500"},Ql.t("All"))),s.list.map(d=>Me.createElement(mx,{key:d.name,content:d.shortName,side:"bottom",sideOffset:2,container:N()},Me.createElement(Oi,{key:d.name,selected:!!n&&n.name===d.name,onClick:()=>r(d)},Me.createElement(_g,{src:d.logo,size:30})))),m?Me.createElement(Oi,{key:s.more[0].name,selected:!!n&&n.name===s.more[0].name,onClick:()=>r(s.more[0])},Me.createElement(_g,{src:s.more[0].logo,size:30})):null,h?Me.createElement(Oi,{onClick:a,key:"more-blockchains"},Me.createElement(Hl,{variant:"body",size:"xsmall",color:"secondary500"},Ql._("More +{count}",{count:s.more.length}))):null)))}i(ql,"BlockchainsSection");import{useCallback as gx,useRef as hx,useState as Gl}from"react";function Vl(){let t=y().blockchains(),e=hx(null),{customTokens:o}=y(),[n,r]=Gl(!1),[a,s]=Gl([]),[l,c]=Gl(null),p=i(async(h,d)=>{c(null),r(!0),s([]);try{let f=await ot().searchCustomTokens({query:h,blockchain:d},{signal:e.current?.signal}),g=new Set(o().map(S=>Mt(S))),C=new Set(t.map(S=>S.name)),k=f.tokens.filter(S=>C.has(S.blockchain)&&!g.has(Mt(S)));s(k),r(!1)}catch(f){c(f instanceof Error?f.message:"something went wrong"),s([]),f?.name!=="CanceledError"&&r(!1)}},"fetch"),u=gx(Sr((h,d)=>{e.current?.signal.aborted||p(h,d)},600),[t.length]);return{fetch:(h,d)=>{e.current=new AbortController,s([]),r(!0),u(h,d)},cancel:i(()=>{e.current?.abort()},"cancel"),loading:n,tokens:a,error:l}}i(Vl,"useSearchCustomTokens");function Ui(t,e,o){return o&&t.length===1&&t[0].address===e?!1:t.length<20&&e.trim().length>=3}i(Ui,"shouldSearchForCustomTokens");function Dg(t,e,o,n,r){let a=[...t];return Ui(t,o,r)&&(a=n?[...a,"skeleton","skeleton","skeleton"]:[...a,...e.map(s=>({...s,customToken:!0,warning:!0}))]),a}i(Dg,"prepareTokensList");function Qi(t){let{type:e}=t,o=vx(),n=Oe(),{fromBlockchain:r,toBlockchain:a,setFromToken:s,setToToken:l,setFromBlockchain:c,setToBlockchain:p}=O(),{getBalanceFor:u}=y(),{fetch:m,loading:h,tokens:d,cancel:f}=Vl(),[g,C]=Tx(""),k=e==="source"?r:a,S=k?.name??"",T=y().blockchains({type:e}),w=y().tokens({type:e,blockchain:S,searchFor:g,getBalanceFor:u}),E=Dg(w,d,g,h,k?.name),B=i(b=>{e==="source"?c(b):p(b)},"updateBlockchain"),I=i(b=>{e==="source"?s({token:b,meta:{blockchains:T}}):l({token:b,meta:{blockchains:T}})},"updateToken"),x={source:zi.t("Source"),destination:zi.t("Destination")};return kx(()=>(Ui(w,g,k?.name)&&m(g,k?.name??void 0),()=>{f()}),[w.length,g,k?.name]),ro.createElement(oe,{header:{title:zi.t("Swap {type}",{type:x[e]})}},ro.createElement(re,null,ro.createElement(ql,{blockchains:T,type:e=="source"?"from":"to",blockchain:e==="source"?r:a,onMoreClick:()=>o(F.blockchains),onChange:b=>{B(b)}}),ro.createElement($g,{size:24}),ro.createElement(Tt,{value:g,autoFocus:!0,placeholder:zi.t("Search Token"),color:"light",variant:"contained",size:"large",setValue:()=>C(""),onChange:b=>C(b.target.value),suffix:Ui(w,g,k?.name)&&h?ro.createElement(Cx,{size:12,color:"secondary"}):void 0}),ro.createElement($g,{size:16}),ro.createElement(Vn,{list:E,selectedBlockchain:S,searchedFor:g,type:e,onChange:b=>{I(b);let v=T.find(A=>b.blockchain===A.name);v&&B(v),n()}})))}i(Qi,"SelectSwapItemsPage");import{i18n as Xl}from"@lingui/core";import{Alert as jx,Button as Xx,styled as Yx}from"@rango-dev/ui";import Lo from"react";import{useInRouterContext as Zx,useSearchParams as Jx}from"react-router-dom";import{i18n as Hg}from"@lingui/core";import{Divider as qg,InfoIcon as Ex,SlippageIcon as Ix,TextField as Ax,Tooltip as Nx,Typography as Gg}from"@rango-dev/ui";import lt from"react";import{Chip as wx,styled as or,TextField as bx}from"@rango-dev/ui";var Fg=or("div",{paddingTop:"$5",padding:"$10 $5"}),Og=or("div",{display:"flex",flexWrap:"wrap",gap:"$10",[`& ${bx}`]:{flex:"1 1 0",maxWidth:"127px",minWidth:"85px"}}),Ug=or("div",{display:"flex",justifyContent:"start",alignItems:"center",paddingBottom:"$10"}),Hi=or("div",{maxWidth:"280px",padding:"$10"}),zg=or(wx,{width:"61px",flexShrink:0});import{i18n as Kl}from"@lingui/core";import{Typography as xx}from"@rango-dev/ui";import nr from"react";function Qg(){return nr.createElement(Hi,null,nr.createElement(xx,{variant:"label",size:"medium",color:"neutral700"},Kl.t("Your transaction will be reverted if the price changes unfavorably by more than this percentage."),nr.createElement("br",null),nr.createElement("br",null),nr.createElement("b",null,Kl.t("Warning")),":\xA0",Kl.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(Qg,"SlippageTooltipContent");function jl(){let{slippage:t,setSlippage:e,customSlippage:o,setCustomSlippage:n}=y();return lt.createElement(Fg,null,lt.createElement(Ug,null,lt.createElement(Ix,{size:16,color:"gray"}),lt.createElement(qg,{direction:"horizontal",size:4}),lt.createElement(Gg,{variant:"title",size:"xmedium"},Hg.t("Slippage tolerance per swap")),lt.createElement(qg,{direction:"horizontal",size:4}),lt.createElement(Nx,{container:N(),side:"top",sideOffset:4,content:lt.createElement(Qg,null)},lt.createElement(Ex,{color:"gray"}))),lt.createElement(Og,null,dp.map((r,a)=>{let s=`slippage-${a}`;return lt.createElement(zg,{key:s,onClick:()=>{o&&n(null),e(r)},selected:!o&&r===t,label:`${r.toString()}%`})}),lt.createElement(Ax,{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>=yp&&s<=hp?n(s):n(null)},suffix:o&&lt.createElement(Gg,{variant:"body",size:"small"},"%"),placeholder:Hg.t("Custom")})))}i(jl,"Slippage");import{i18n as gt}from"@lingui/core";import{AutoThemeIcon as Vg,BridgesIcon as Bx,ChevronRightIcon as qi,DarkModeIcon as Kg,Divider as rr,ExchangeIcon as Wx,InfinityIcon as Lx,InfoIcon as Mx,LanguageIcon as Px,LightModeIcon as jg,List as _x,ListItem as Dx,ListItemButton as $x,Skeleton as Fx,styled as Ox,Switch as Ux,Tabs as zx,TargetIcon as Qx,Tooltip as Hx,Typography as et}from"@rango-dev/ui";import $ from"react";import{useNavigate as qx}from"react-router-dom";var Gx=Ox("div",{width:"202px",height:"$40"}),Vx=[{id:"light",icon:$.createElement(jg,{color:"black",size:24}),tooltip:$.createElement(et,{size:"xsmall",variant:"body"},gt.t("Light"))},{id:"dark",icon:$.createElement(Kg,{color:"black",size:24}),tooltip:$.createElement(et,{size:"xsmall",variant:"body"},gt.t("Dark"))},{id:"auto",icon:$.createElement(Vg,{color:"black",size:24}),tooltip:$.createElement(et,{size:"xsmall",variant:"body"},gt.t("Auto"))}],Kx=i(t=>{let e={color:"gray",size:16};switch(t){case"auto":return $.createElement(Vg,{...e});case"dark":return $.createElement(Kg,{...e});default:return $.createElement(jg,{...e})}},"getThemeIcon");function Xg(){let t=qx(),{theme:e}=y().config,{setTheme:o,theme:n}=y(),{activeLanguage:r,languages:a}=no(),s=a.find(L=>L.local===r)?.label,l=y().fetchStatus,c=y().swappers(),p=y().getDisabledLiquiditySources(),{config:{features:u}}=y(),m=y().customTokens(),h=Ye("theme",u),d=Ye("liquiditySource",u),f=Ye("language",u),g=Ye("customTokens",u),C=y().infiniteApprove,k=y().toggleInfiniteApprove,S=Ir(c,p),T=S.filter(L=>["BRIDGE","AGGREGATOR","OFF_CHAIN"].includes(L.type)),w=T.length,E=T.filter(L=>L.selected).length,B=S.filter(L=>L.type==="DEX"),I=B.length,x=B.filter(L=>L.selected).length,b=i((L,H)=>{switch(l){case"loading":return $.createElement(Fx,{variant:"text",size:"medium",width:50});case"failed":return $.createElement(et,{variant:"body",size:"medium",color:"$error500"},gt.t("Loading failed"));default:return $.createElement(et,{variant:"body",size:"medium"},`${L} / ${H}`)}},"handleSwapperEndItem"),v={id:"widget-setting-bridge-item-btn",title:$.createElement(et,{variant:"title",size:"xmedium"},gt.t("Bridges")),end:$.createElement($.Fragment,null,b(E,w),$.createElement(rr,{direction:"horizontal",size:8}),$.createElement(qi,{color:"black"})),onClick:()=>t(F.bridges),start:$.createElement(Bx,{color:"gray",size:16})},A={id:"widget-setting-exchange-item-btn",title:$.createElement(et,{variant:"title",size:"xmedium"},gt.t("Exchanges")),end:$.createElement($.Fragment,null,b(x,I),$.createElement(rr,{direction:"horizontal",size:8}),$.createElement(qi,{color:"black"})),start:$.createElement(Wx,{color:"gray",size:16}),onClick:()=>t(F.exchanges)},M={id:"widget-setting-custom-tokens-item-btn",title:$.createElement(et,{variant:"title",size:"xmedium"},gt.t("Custom Tokens")),end:$.createElement($.Fragment,null,$.createElement(et,{variant:"body",size:"medium"},`${m.length}`),$.createElement(rr,{direction:"horizontal",size:8}),$.createElement(qi,{color:"black"})),start:$.createElement(Qx,{color:"gray",size:16}),onClick:()=>t(F.customTokens)},_={id:"widget-setting-language-item-btn",title:$.createElement(et,{variant:"title",size:"xmedium"},gt.t("Language")),start:$.createElement(Px,{color:"gray",size:16}),end:$.createElement($.Fragment,null,$.createElement(et,{variant:"body",size:"medium"},s),$.createElement(rr,{direction:"horizontal",size:8}),$.createElement(qi,{color:"black"})),onClick:()=>t(F.languages)},j={id:"widget-setting-infinite-approval-item-btn",title:$.createElement($.Fragment,null,$.createElement(et,{variant:"title",size:"xmedium"},gt.t("Infinite approval")),$.createElement(rr,{direction:"horizontal",size:4}),$.createElement(Hx,{side:"top",sideOffset:4,container:N(),content:$.createElement(Hi,null,$.createElement(et,{variant:"label",size:"medium",color:"neutral700"},$.createElement("b",null,gt.t("Warning")),":\xA0",gt.t("Enabling the 'Infinite approval' mode grants unrestricted access to underlying smart contracts, allowing them to utilize the approved token amount without limitations.")))},$.createElement(Mx,{color:"gray"}))),start:$.createElement(Lx,{color:"gray",size:16}),end:$.createElement(Ux,{checked:C}),onClick:k},R={id:"widget-setting-theme-item-btn",type:$.createElement(Dx,null),title:$.createElement(et,{variant:"title",size:"xmedium"},gt.t("Theme")),end:$.createElement(Gx,null,$.createElement(zx,{container:N(),items:Vx,value:n,onChange:L=>o(L.id),type:"primary",borderRadius:"small"})),start:Kx(n)},X=d?[]:[v,A];return g||X.push(M),f||X.push(_),X.push(j),!e?.singleTheme&&!h&&X.push(R),$.createElement(_x,{type:$.createElement($x,{hasDivider:!0,id:"_",onClick:()=>console.log()}),items:X})}i(Xg,"SettingsLists");var Rx=Yx("div",{paddingLeft:"$8"});function Yg(){let{isInCampaignMode:t,updateCampaignMode:e}=y(),o=t(),[,n]=Jx(),r=Zx(),a=i(()=>{r&&o&&(n(s=>(s.delete("liquiditySources"),s),{replace:!0}),e("liquiditySources",void 0))},"onClick");return Lo.createElement(oe,{header:{title:Xl.t("Settings")}},Lo.createElement(re,null,o&&Lo.createElement(jx,{type:"info",variant:"alarm",title:Xl.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:Lo.createElement(Rx,null,Lo.createElement(Xx,{id:"widget-setting-exit-campaign-mode-btn",type:"secondary",size:"small",onClick:a},Xl.t("Reset")))}),Lo.createElement(jl,null),Lo.createElement(Xg,null)))}i(Yg,"SettingsPage");import{i18n as zE}from"@lingui/core";import{cancelSwap as QE}from"@rango-dev/queue-manager-rango-preset";import{useManager as HE}from"@rango-dev/queue-manager-react";import{Alert as qE}from"@rango-dev/ui";import mc from"react";import{useParams as GE}from"react-router-dom";import{i18n as ct}from"@lingui/core";import{getCurrentNamespaceOfOrNull as vE,getCurrentStep as wE,getRelatedWalletOrNull as bE}from"@rango-dev/queue-manager-rango-preset";import{Button as Bh,CopyIcon as xE,Divider as EE,DoneIcon as IE,IconButton as AE,QuoteCost as NE,RangoExplorerIcon as BE,StepDetails as WE,Tooltip as Wh,Typography as Mo,useCopyToClipboard as LE}from"@rango-dev/ui";import{useWallets as ME}from"@rango-dev/wallets-react";import Lh from"bignumber.js";import{PendingSwapNetworkStatus as Ji}from"rango-types";import Y,{useEffect as Mh,useRef as PE,useState as Ph}from"react";import{useNavigate as _E}from"react-router-dom";import{i18n as io}from"@lingui/core";var eE=[io.t("Sunday"),io.t("Monday"),io.t("Tuesday"),io.t("Wednesday"),io.t("Thursday"),io.t("Friday"),io.t("Saturday")];function Zg(t){let e=new Date(t),o=e.getDate(),n=e.toLocaleString("default",{month:"long"}),r=e.getFullYear();return`${e.getDay()===new Date().getDay()?io.t("Today"):`${eE[e.getDay()]} ${o} ${n} ${r}`}, ${new Date(t).toLocaleTimeString()}`}i(Zg,"timeSince");function Jg(t){return t.finishTime?Zg(parseInt(t.finishTime)):Zg(parseInt(t.creationTime))}i(Jg,"getSwapDate");import{PendingSwapNetworkStatus as Ki}from"rango-types";import ji from"react";import{i18n as Gi}from"@lingui/core";import{Button as Rg,Divider as Yl,MessageBox as tE}from"@rango-dev/ui";import ao from"react";var eh=i(({onCancel:t,onClose:e})=>ao.createElement(ao.Fragment,null,ao.createElement(Yl,{size:20}),ao.createElement(tE,{type:"error",title:Gi.t("Cancel Swap"),description:Gi.t("Are you sure you want to cancel this swap?")}),ao.createElement(Yl,{size:32}),ao.createElement(Rg,{variant:"contained",id:"widget-swap-details-modal-cancel-swap-yes-btn",type:"primary",size:"large",onClick:t},Gi.t("Yes, Cancel it")),ao.createElement(Yl,{size:12}),ao.createElement(Rg,{id:"widget-swap-details-modal-cancel-swap-no-btn",variant:"outlined",type:"primary",size:"large",onClick:e},Gi.t("No, Continue"))),"CancelContent");import{i18n as Vi}from"@lingui/core";import{Button as th,Divider as Zl,MessageBox as oE,Typography as nE}from"@rango-dev/ui";import qt from"react";var oh=i(({onDelete:t,onClose:e})=>qt.createElement(qt.Fragment,null,qt.createElement(Zl,{size:20}),qt.createElement(oE,{type:"error",title:Vi.t("Delete Transaction"),description:Vi.t("Are you sure you want to delete this swap?")}),qt.createElement(Zl,{size:32}),qt.createElement(th,{id:"widget-swap-details-modal-delete-swap-yes-btn",variant:"contained",type:"primary",size:"large",onClick:t},Vi.t("Yes, Delete it")),qt.createElement(Zl,{size:12}),qt.createElement(th,{id:"widget-swap-details-modal-delete-swap-no-btn",variant:"outlined",type:"primary",size:"large",onClick:e},qt.createElement(nE,{variant:"title",size:"medium",color:"primary"},Vi.t("No, Cancel")))),"DeleteContent");import{i18n as Jl}from"@lingui/core";import{PendingSwapNetworkStatus as Rl}from"rango-types";var ec={[Rl.WaitingForNetworkChange]:{type:"loading",title:Jl.t("Change Network")},[Rl.WaitingForConnectingWallet]:{type:"warning",title:Jl.t("Connect Wallet")},[Rl.NetworkChanged]:{type:"success",title:Jl.t("Network Changed")}};import{warn as rE}from"@rango-dev/logging-core";import{MessageBox as iE,Wallet as aE}from"@rango-dev/ui";import{useWallets as sE}from"@rango-dev/wallets-react";import ln,{useState as lE}from"react";import{styled as tc}from"@rango-dev/ui";var nh=tc("div",{display:"flex",justifyContent:"center"}),VK=tc("div",{maxWidth:280,"& ._typography":{wordWrap:"break-word",display:"block"}}),rh=tc("img",{width:"100%"});var ih=i(t=>{let{type:e,title:o,currentStepWallet:n,message:r,showWalletButton:a,walletButtonDisabled:s}=t,[l,c]=lE(),{getWalletInfo:p,state:u}=sE(),m=n?.walletType,h=m?gn(u(m)):null,d=m?p(m):null,f=a&&!!m&&!!h&&!!d,{list:g}=ht(),C=i(()=>{if(m){let k=g.find(S=>S.type===m);k?c(k):rE(new Error(`It seems requested wallet to be connected is not available in the list. requested wallet: ${k}`))}},"handleWalletItemClick");return ln.createElement(ln.Fragment,null,ln.createElement(iE,{type:e,title:o,description:r}),f&&ln.createElement(nh,null,ln.createElement(aE,{container:N(),title:d.name,image:d.img,type:m,state:h,link:d.installLink,disabled:s,onClick:C})),ln.createElement(So,{wallet:l,onClose:()=>{c(void 0)}}))},"WalletStateContent");function oc(t){let{state:e,onClose:o,onDelete:n,onCancel:r,currentStepWallet:a,message:s,walletButtonDisabled:l}=t,c=e===Ki.WaitingForNetworkChange||e===Ki.WaitingForConnectingWallet||e===Ki.NetworkChanged;return ji.createElement(J,{open:!!e,onClose:o,container:document.getElementById($e.SWAP_BOX_ID)||document.body},c&&ji.createElement(ih,{type:ec[e].type,title:ec[e].title,currentStepWallet:a,message:s,walletButtonDisabled:l,showWalletButton:e!==Ki.WaitingForNetworkChange}),e==="delete"&&ji.createElement(oh,{onClose:o,onDelete:n}),e==="cancel"&&ji.createElement(eh,{onClose:o,onCancel:r}))}i(oc,"SwapDetailsModal");import{i18n as ir}from"@lingui/core";import{Button as nc,Divider as ar,MessageBox as lh,TokenAmount as cE,Typography as ch}from"@rango-dev/ui";import de from"react";import{Link as pE,useNavigate as uE}from"react-router-dom";var ah="https://raw.githubusercontent.com/rango-exchange/assets/main/banners/widget/profile.jpg",sh="/profile";function rc(t){let{open:e,onClose:o,status:n,priceValue:r,usdValue:a,realUsdValue:s,realValue:l,token:c,chain:p,percentageChange:u,description:m,diagnosisUrl:h}=t,d=uE(),{showProfileBanner:f}=ne();return de.createElement(J,{open:e,onClose:o,container:document.getElementById($e.SWAP_BOX_ID)||document.body},n==="success"?de.createElement(lh,{type:"success",title:ir.t("Swap Successful")},de.createElement(cE,{direction:"vertical",tooltipContainer:N(),type:"output",centerAlign:!0,price:{value:r,usdValue:a,realUsdValue:s,realValue:l},token:c,chain:p,percentageChange:u}),de.createElement(ar,{size:12}),de.createElement(ch,{variant:"body",size:"medium",color:"neutral700",align:"center"},m)):de.createElement(lh,{type:"error",title:ir.t("Transaction Failed"),description:m}),de.createElement(ar,{size:30}),n==="success"&&de.createElement(de.Fragment,null,f&&de.createElement(de.Fragment,null,de.createElement(pE,{to:sh},de.createElement(rh,{src:ah,alt:"Profile Banner"})),de.createElement(ar,{size:30})),de.createElement(nc,{id:"widget-swap-details-modal-done-btn",variant:"contained",type:"primary",size:"large",onClick:()=>{d("../../")}},ir.t("Done"))),de.createElement(ar,{size:12}),h&&de.createElement(de.Fragment,null,de.createElement(nc,{variant:"contained",id:"widget-swap-detail-modal-diagnosis-btn",type:"primary",size:"large",onClick:()=>window.open(h,"_blank")},ir.t("Diagnosis")),de.createElement(ar,{size:12})),de.createElement(nc,{id:"widget-swap-details-modal-see-details-btn",variant:"outlined",type:"primary",size:"large",onClick:o},de.createElement(ch,{variant:"title",size:"medium",color:"primary"},ir.t("See Details"))))}i(rc,"SwapDetailsCompleteModal");import TE from"react";import{i18n as yE}from"@lingui/core";import{Alert as Eh,IconButton as SE,LinkIcon as CE}from"@rango-dev/ui";import so,{Fragment as kE}from"react";import{Alert as dE,ChevronDownIcon as fE,IconButton as gE}from"@rango-dev/ui";import pn,{useState as hE}from"react";import{css as sr,darkTheme as ph,styled as Gt,Typography as mE}from"@rango-dev/ui";var uh=Gt("div",{display:"flex",flexDirection:"column",flexGrow:1,overflow:"hidden"}),Xi=Gt("div",{width:"100%","& ._icon-button":{"&:hover":{"& svg":{color:"$secondary550",[`.${ph} &`]:{color:"$secondary500"}}}}}),mh=Gt(An,{padding:"$0 $20 $20 $20"}),M4=Gt("div",{display:"flex",flexDirection:"column",gap:"$10"}),dh=Gt("div",{height:"450px",display:"flex",alignItems:"center",justifyContent:"center"}),P4=Gt("div",{display:"flex",justifyContent:"center",width:"100%",paddingTop:"33%",flex:1}),cn=sr({display:"flex",width:"100%",justifyContent:"space-between",alignItems:"center",padding:"$10 $20",borderBottom:"1px solid",$$color:"$colors$neutral300",[`.${ph} &`]:{$$color:"$colors$neutral400"},borderColor:"$$color",color:"$neutral500"}),fh=sr({padding:"$5 0"}),Yi=sr({display:"flex",justifyContent:"center",alignItems:"center",height:"$24"}),gh=sr({display:"flex",width:"100%",padding:"$15 $20 $20",flexDirection:"column",alignItems:"start"}),hh=sr({width:"100%",padding:"0 $20 $10"}),yh=Gt("a",{fontSize:"$16",fontWeight:"$400",color:"$neutral700",display:"flex",alignItems:"center",justifyContent:"center"}),Sh=Gt("div",{display:"flex",flexDirection:"column",gap:"$5"}),Zi=Gt(mE,{wordBreak:"break-word"});import{styled as ic}from"@rango-dev/ui";var Ch=ic("div",{display:"flex",flexDirection:"column",gap:"$10"}),kh=ic("div",{transition:"transform 0.3s ease-in-out",variants:{rotated:{true:{transform:"rotate(180deg)"}}}}),Th=ic("div",{transition:"max-height 0.3s ease-in-out",maxHeight:"0px",overflow:"hidden",variants:{open:{true:{maxHeight:"200px"}}}});function vh(t){let{message:e}=t,[o,n]=hE(!1);return pn.createElement(dE,{type:"error",title:e.shortMessage,containerStyles:{"& .footer":{paddingTop:"$0"}},action:e.detailedMessage.content&&pn.createElement(gE,{onClick:()=>n(r=>!r),variant:"ghost",size:"xsmall"},pn.createElement(kh,{rotated:o},pn.createElement(fE,{size:12,color:"gray"}))),footer:pn.createElement(Th,{open:o},pn.createElement(Zi,{variant:"body",size:"xsmall",color:"neutral700"},e.detailedMessage.content))})}i(vh,"FailedAlert");import{i18n as wh}from"@lingui/core";import{Alert as ac,Button as bh}from"@rango-dev/ui";import{PendingSwapNetworkStatus as sc}from"rango-types";import lr from"react";function xh(t){let{switchNetwork:e,setNetworkModal:o,message:n,showNetworkModal:r}=t;return e?lr.createElement(ac,{type:"warning",title:n.shortMessage,action:lr.createElement(bh,{id:"widget-swap-details-warning-alert-change-network-btn",size:"xxsmall",type:"warning",onClick:()=>{o(sc.WaitingForNetworkChange),e().catch(a=>{console.log(a)})}},wh.t("Change"))}):r===sc.WaitingForConnectingWallet?lr.createElement(ac,{type:"warning",title:n.shortMessage,action:lr.createElement(bh,{id:"widget-swap-details-warning-alert-connect-wallet-btn",size:"xxsmall",type:"warning",onClick:()=>{o(sc.WaitingForConnectingWallet)}},wh.t("Connect"))}):lr.createElement(ac,{type:"warning",title:n.shortMessage})}i(xh,"WarningAlert");function lc(t){let{switchNetwork:e,showNetworkModal:o,setNetworkModal:n,message:r,step:a,hasAlreadyProceededToSign:s}=t,l=En(a),c=a.status==="waitingForApproval"&&!l,p=a.status==="running"&&!l,u=p&&!s||c&&!a.explorerUrl?.length;return so.createElement(Ch,null,a.explorerUrl?.map((m,h,d)=>{let f=h+m.url,g=h===d.length-1,C=(g&&p||c)&&!u,k=g&&a.status==="failed";return so.createElement(kE,{key:f},so.createElement(Eh,{type:g&&(C&&"loading"||k&&"error")||"success",title:m.description?`${m.description} Tx`:yE.t("View transaction"),action:m.url&&so.createElement(SE,{id:"widget-swap-details-tx-link-icon-btn",variant:"ghost",size:"xsmall",onClick:()=>window.open(m.url,"_blank")},so.createElement(CE,{size:12}))}))}),u&&so.createElement(Eh,{type:"loading",title:r.shortMessage}),a.status!=="failed"&&l&&so.createElement(xh,{switchNetwork:e,showNetworkModal:o,setNetworkModal:n,message:r}),a.status==="failed"&&so.createElement(vh,{message:r}))}i(lc,"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:ut(a.fromBlockchain,e)??"",image:a.fromBlockchainLogo??""},price:{value:P(l,6,6),realValue:l??""}},to:{token:{displayName:a.toSymbol,image:a.toLogo},chain:{displayName:ut(a.toBlockchain,e)??"",image:a.toBlockchainLogo??""},price:{value:P(a.outputAmount||a.expectedOutputAmountHumanReadable,6,6),realValue:a.outputAmount||a.expectedOutputAmountHumanReadable||""}},swapper:{displayName:un(a.swapperId,o)??"",image:a.swapperLogo??"",type:a.swapperType},internalSwaps:a.internalSwaps?a.internalSwaps.map(c=>({from:{chain:{displayName:ut(c.fromBlockchain,e)??"",image:c.fromBlockchainLogo??""}},to:{chain:{displayName:ut(c.toBlockchain,e)??"",image:c.toBlockchainLogo??""}},swapper:{displayName:un(c.swapperId,o)??"",image:c.swapperLogo??"",type:c.swapperType}})):[],alerts:TE.createElement(lc,{step:a,hasAlreadyProceededToSign:r,...n})}})},"getSteps");function Nh(t){if(En(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(Nh,"getStepState");function cc(t){let{swap:e,requestId:o,onDelete:n,onCancel:r}=t,{canSwitchNetworkTo:a,connect:s,getWalletInfo:l}=ME(),c=y().blockchains(),p=y().swappers(),{findToken:u}=y(),m=O.use.retry(),h=ne.use.isActiveTab(),d=_E(),[f,g]=LE(Ih),C=PE(null),[k,S]=Ph(null),[T,w]=Ph(null),E=i(()=>{r(),S(null)},"onCancel"),B=we.use.getNotifications(),I=we.use.removeNotification(),x=B(),b=wE(e),v=b?.networkStatus;Mh(()=>{x.find(De=>De.requestId===e.requestId)&&(e.status==="success"||e.status==="failed"?(w(e.status),I(e.requestId)):T&&w(null))},[e.status,e.requestId]),Mh(()=>{L?S(Ji.WaitingForNetworkChange):v===Ji.WaitingForConnectingWallet||v===Ji.NetworkChanged?S(v):S(null)},[v]);let A=Eu(e),M=b?vE(e,b):null,_=b?bE(e,b):null,j=Jg(e),R=Iu(e),X=i(ke=>!!l(ke)?.mobileWallet,"isMobileWallet"),L=v===Ji.WaitingForNetworkChange&&!!M&&!!_?.walletType&&(X(_.walletType)||a(_.walletType,M.network)),H=L?s.bind(null,_.walletType,[{namespace:M.namespace,network:M.network}]):void 0,ae=xu(e,b),G=Ah({swap:e,switchNetwork:H,showNetworkModal:v,setNetworkModal:S,message:ae,blockchains:c,swappers:p}),fe=G.length,[Ie,je]=[e.steps[0],e.steps[fe-1]],se=je.outputAmount||je.expectedOutputAmountHumanReadable,pt=e.steps.reduce((ke,De)=>ke+parseFloat(De.feeInUsd||""),0),V=e.steps.find(ke=>ke.diagnosisUrl)?.diagnosisUrl,D=P(parseFloat(se||"0")*(je.toUsdPrice||0),4,4),q=P(parseFloat(e.inputAmount)*(Ie.fromUsdPrice||0),4,4),K=se?new Lh(se).multipliedBy(je.toUsdPrice||0).toString():"",ge=new Lh(e.inputAmount).multipliedBy(Ie.fromUsdPrice||0).toString(),ce=Pt(q,D),_e=ae.detailedMessage.content||ae.shortMessage,Xe=e.status==="success"?ct.t({id:"You have received {amount} {token} in {conciseAddress} wallet on {chain} chain.",values:{amount:P(se,6,6),token:G[fe-1].to.token.displayName,conciseAddress:xr(e.wallets[G[fe-1].to.chain.displayName]?.address||""),chain:G[fe-1].to.chain.displayName}}):Y.createElement(Sh,null,Y.createElement(Mo,{variant:"body",size:"medium",color:"neutral700",align:"center"},_e?"":ct.t("Transaction was not sent."),A?`${ct.t({id:"{amount} {symbol} on {blockchain} remains in your wallet.",values:{amount:A.outputAmount,symbol:A.symbol,blockchain:A.blockchain}})}`:""),_e&&Y.createElement(Zi,{align:"center",variant:"body",size:"medium",color:"neutral700"},Y.createElement("b",null,"Reason:")," ",_e));return Y.createElement(oe,{header:{title:ct.t("Swap Details"),onCancel:e.status==="running"?()=>S("cancel"):void 0,suffix:e.status!=="running"&&Y.createElement(jt,null,Y.createElement(Bh,{id:"widget-swap-details-delete-btn",variant:"ghost",type:"error",size:"xsmall",onClick:()=>S("delete")},Y.createElement(Mo,{size:"medium",variant:"label",color:"error"},ct.t("Delete"))))},footer:R&&!T&&Y.createElement(Bh,{fullWidth:!0,id:"widget-swap-details-try-again-btn",variant:"contained",type:"primary",size:"large",onClick:()=>{let ke=Fr(e,c,u);m(ke),setTimeout(()=>{d("../../")},0)}},ct.t("Try again"))},Y.createElement(re,{compact:!0,view:!0},Y.createElement(Xi,null,Y.createElement("div",{className:cn()},Y.createElement(Mo,{variant:"label",size:"large",color:"neutral700"},`${ct.t("Request ID")}`),Y.createElement("div",{className:Yi()},Y.createElement(Mo,{variant:"label",size:"small",color:"neutral700"},o),Y.createElement(Wh,{container:N(),content:f?ct.t("Copied To Clipboard"):ct.t("Copy Request ID"),open:f||void 0,side:"bottom",alignOffset:-16,align:"end"},Y.createElement(AE,{id:"widget-swap-details-done-copy-icon-btn",variant:"ghost",onClick:g.bind(null,o||"")},f?Y.createElement(IE,{size:16,color:"secondary"}):Y.createElement(xE,{size:16,color:"gray"}))),Y.createElement(yh,{target:"_blank",href:`${_c}/swap/${o}`},Y.createElement(Wh,{container:N(),content:ct.t("View on Rango Explorer"),side:"bottom"},Y.createElement(BE,{size:20}))))),Y.createElement("div",{className:cn()},Y.createElement(Mo,{variant:"label",size:"large",color:"neutral700"},e.finishTime?ct.t("Finished at"):ct.t("Created at")),Y.createElement(Mo,{variant:"label",size:"small",color:"neutral700"},j))),Y.createElement("div",{className:gh()},Y.createElement(NE,{fee:P(String(pt),2,2),time:dn(kr(e.steps)),steps:fe}),Y.createElement(_n,{from:{price:{value:P(e.inputAmount,6,6),usdValue:q,realUsdValue:ge,realValue:e.inputAmount},token:{displayName:G[0].from.token.displayName,image:G[0].from.token.image},chain:{image:G[0].from.chain.image,displayName:G[0].from.chain.displayName}},to:{price:{value:P(se,6,6),usdValue:D,realUsdValue:K,realValue:se||""},token:{displayName:G[fe-1].to.token.displayName,image:G[fe-1].to.token.image},chain:{image:G[fe-1].to.chain.image,displayName:G[fe-1].to.chain.displayName}},percentageChange:P(ce,2,2),warningLevel:_t(ce??0)})),Y.createElement("div",{className:hh()},Y.createElement(Mo,{variant:"title",size:"small"},ct.t("Swaps steps"))),Y.createElement(EE,{size:8}),Y.createElement(mh,{ref:C},G.map((ke,De)=>{let Vt=De,lo=Nh(e.steps[De]),ly=lo==="error"||lo==="in-progress"||lo==="warning"||lo==="completed"&&De===G.length-1;return Y.createElement(WE,{key:Vt,step:ke,type:"swap-progress",ref:C,state:lo,hasSeparator:De!==0,tabIndex:Vt,isFocused:ly,tooltipContainer:N()})}))),Y.createElement(oc,{state:k,onClose:()=>S(null),onCancel:E,onDelete:n,message:ae.detailedMessage.content,currentStepWallet:_,walletButtonDisabled:!h}),Y.createElement(rc,{open:!!T,diagnosisUrl:V,onClose:()=>w(null),status:e.status==="success"?"success":"failed",priceValue:P(se,6,6),usdValue:D,realUsdValue:K,realValue:se||"",percentageChange:P(ce,2,2),token:{displayName:G[fe-1].to.token.displayName,image:G[fe-1].to.token.image},chain:{image:G[fe-1].to.chain.image},description:Xe}))}i(cc,"SwapDetails");import{i18n as ea}from"@lingui/core";import{Divider as $h,NotFound as UE,Skeleton as pr,Typography as ta}from"@rango-dev/ui";import Ce from"react";import{i18n as DE}from"@lingui/core";import{Divider as $E,Skeleton as FE,Typography as OE}from"@rango-dev/ui";import Te from"react";import{css as wt,styled as pc}from"@rango-dev/ui";var _h=pc("div",{width:"100%",height:"100%",padding:"$10 $20"}),cr=pc("div",{backgroundColor:"$neutral100",borderRadius:"$xm",padding:"$10 $15"}),Ri=pc("div",{width:"0px",height:"$20",borderLeft:"1px dashed $neutral700",marginLeft:"25px"}),V8=wt({display:"flex",justifyContent:"space-between",alignItems:"center"}),K8=wt({display:"flex",justifyContent:"space-between",alignItems:"center"}),j8=wt({paddingTop:"$15",display:"flex"}),X8=wt({padding:"$15 $0"}),Y8=wt({width:"0px",height:"$16",borderLeft:"1px solid $neutral400",marginLeft:"13px"}),Z8=wt({paddingBottom:"$10"}),J8=wt({display:"flex",justifyContent:"start",alignItems:"center"}),R8=wt({paddingTop:"$5",display:"flex",alignItems:"center"}),e6=wt({display:"flex",alignItems:"center"}),t6=wt({padding:"$4 $6",display:"flex",justifyContent:"center",alignItems:"center"}),Dh=wt({display:"flex",paddingTop:"$10",paddingBottom:"$5"});function uc(){return Te.createElement(_h,null,Te.createElement(Fn,{type:"swap-preview"}),Te.createElement("div",{className:"swaps-steps"},Te.createElement(OE,{variant:"title",size:"small"},DE.t("Swaps steps"))),Te.createElement(Te.Fragment,null,Te.createElement(cr,null,Te.createElement(At,{separator:!1}),Te.createElement("div",{className:Dh()},Te.createElement($E,{direction:"horizontal",size:20}),Te.createElement(FE,{height:22,variant:"rectangular"}))),Te.createElement(Ri,null),Te.createElement(cr,null,Te.createElement(At,{separator:!1})),Te.createElement(Ri,null),Te.createElement(cr,null,Te.createElement(At,{separator:!1})),Te.createElement(Ri,null),Te.createElement(cr,null,Te.createElement(At,{separator:!1}))))}i(uc,"LoadingSwapDetails");function Fh(t){let{requestId:e,showSkeleton:o}=t;return Ce.createElement(oe,{header:{title:ea.t("Swap Details"),suffix:Ce.createElement(jt,null)}},o&&Ce.createElement(uh,null,Ce.createElement(Xi,null,Ce.createElement("div",{className:cn()},Ce.createElement(ta,{variant:"label",size:"large",color:"neutral700"},`${ea.t("Request ID")}`),Ce.createElement("div",{className:Yi()},Ce.createElement(ta,{variant:"label",size:"small",color:"neutral700"},Ce.createElement(pr,{width:60,height:10,variant:"rounded"})),Ce.createElement($h,{direction:"horizontal",size:4}),Ce.createElement(pr,{width:16,height:16,variant:"rectangular"}),Ce.createElement($h,{direction:"horizontal",size:4}),Ce.createElement(pr,{width:16,height:16,variant:"rectangular"}))),Ce.createElement("div",{className:cn()},Ce.createElement(ta,{className:fh(),variant:"label",size:"large",color:"neutral700"},Ce.createElement(pr,{width:60,height:10,variant:"rounded"})),Ce.createElement(ta,{variant:"label",size:"small",color:"neutral700"},Ce.createElement(pr,{width:60,height:10,variant:"rounded"})))),Ce.createElement(uc,null)),!o&&Ce.createElement(dh,null,Ce.createElement(UE,{title:ea.t("Not found"),description:ea.t({id:"Swap with request ID = {requestId} not found.",values:{requestId:e}})})))}i(Fh,"SwapDetailsPlaceholder");function Oh(){let{manager:t,state:e}=HE(),o=!e.loadedFromPersistor,n=ft(t),{requestId:r}=GE(),a=Oe(),{fetchStatus:s}=y();if(!r)return mc.createElement(qE,{containerStyles:{margin:"20px"},type:"error",title:zE.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&&QE(h)}},"onCancel"),u=i(async()=>{if(c?.id)try{t?.deleteQueue(c.id),a()}catch(h){console.log(h)}},"onDelete"),m=c?.swap;return!m||l?mc.createElement(Fh,{requestId:r,showSkeleton:l}):mc.createElement(cc,{swap:m,requestId:r,onCancel:p,onDelete:u})}i(Oh,"SwapDetailsPage");import{i18n as Uh}from"@lingui/core";import{Divider as VE,getCategoriesCount as KE,SelectableCategoryList as jE,styled as Qh,Typography as XE,Wallet as YE}from"@rango-dev/ui";import Bt,{useState as zh}from"react";var ZE=Qh("div",{display:"flex",justifyContent:"center",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5"}),JE=Qh(re,{textAlign:"center"});function Hh(){let{fetchStatus:t}=y(),[e,o]=zh("ALL"),n=y().blockchains(),{config:r}=y(),[a,s]=zh(),l=ne.use.isActiveTab(),{list:c}=ht(),p=op(c,n),m=KE(p)!==1,h=np(c,e),d=i(f=>{Gc(c,r.multiWallets)||s(f)},"handleWalletItemClick");return Bt.createElement(oe,{header:{title:Uh.t("Connect Wallets")}},Bt.createElement(JE,null,m&&Bt.createElement(Bt.Fragment,null,Bt.createElement(jE,{setCategory:o,category:e,blockchains:p,isLoading:t==="loading"}),Bt.createElement(VE,{size:24})),Bt.createElement(XE,{variant:"title",size:"xmedium",align:"center"},Uh.t("Choose a wallet to connect.")),Bt.createElement(ZE,null,h.map((f,g)=>{let C=`wallet-${g}-${f.type}`;return Bt.createElement(YE,{key:C,...f,container:N(),onClick:()=>d(f),isLoading:t==="loading",disabled:!l})}),Bt.createElement(So,{wallet:a,onClose:()=>{s(void 0)}}))))}i(Hh,"WalletsPage");function qh(){return Wu(),Xa(),RE([{path:F.home,element:Pe.createElement(hg,null)},{path:F.routes,element:Pe.createElement(Tg,null)},{path:F.fromSwap,children:[{index:!0,element:Pe.createElement(Qi,{type:"source"})},{path:F.blockchains,element:Pe.createElement(Fi,{type:"source"})}]},{path:F.toSwap,children:[{index:!0,element:Pe.createElement(Qi,{type:"destination"})},{path:F.blockchains,element:Pe.createElement(Fi,{type:"destination"})}]},{path:F.settings,children:[{index:!0,element:Pe.createElement(Yg,null)},{path:F.languages,element:Pe.createElement(Sg,null)},{path:F.exchanges,element:Pe.createElement($l,{sourceType:"Exchanges"})},{path:F.bridges,element:Pe.createElement($l,{sourceType:"Bridges"})},{path:F.customTokens,children:[{index:!0,element:Pe.createElement(Ef,null)},{path:F.addCustomTokens,children:[{index:!0,element:Pe.createElement(hm,null)},{path:F.blockchains,element:Pe.createElement(Fi,{hideCategory:!0,type:"custom-token"})}]}]}]},{path:F.swaps,children:[{index:!0,element:Pe.createElement(Vf,null)},{path:F.swapDetails,element:Pe.createElement(Oh,null)}]},{path:F.wallets,element:Pe.createElement(Hh,null)},{path:F.confirmSwap,element:Pe.createElement(mf,null)}])}i(qh,"AppRoutes");import{useQueueManager as lI}from"@rango-dev/queue-manager-rango-preset";import{splitWalletNetwork as cI}from"@rango-dev/wallets-shared";import{isEvmBlockchain as pI}from"rango-sdk";import{useContext as uI,useEffect as Zh,useState as Jh}from"react";import{globalCss as eI}from"@rango-dev/ui";var Gh=i(()=>eI({"@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 Vh(){let{setWatermark:t,setShowProfileBanner:e}=ne();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(Vh,"useFetchApiConfig");import{useWallets as tI}from"@rango-dev/wallets-react";import{useEffect as oI,useRef as nI}from"react";function Kh(){let{connect:t,state:e}=tI(),o=nI({}),{fetchStatus:n}=y(),r=new URLSearchParams(location.search).get("autoConnect")||"",a=e(r);oI(()=>{n==="success"&&r&&a.installed&&!a.connecting&&!a.connected&&!o.current[r]&&(o.current[r]=!0,t(r))},[a,n])}i(Kh,"useForceAutoConnect");import{isApprovalTX as rI,RouteEventType as jh,StepEventType as Xh,StepExecutionEventStatus as iI,WidgetEvents as oa}from"@rango-dev/queue-manager-rango-preset";import{useEffect as Yh}from"react";function dc(){let t=we.use.setNotification(),{connectedWallets:e,fetchBalances:o,customTokens:n}=y();Yh(()=>{let r=i(a=>{let{event:s,step:l,route:c}=a;if(s.type===Xh.TX_EXECUTION&&s.status===iI.TX_SENT&&!rI(l)||s.type===Xh.SUCCEEDED){let u=[],m=c.wallets[l?.fromBlockchain];if(m){let h=e.find(d=>d.address?.toLocaleLowerCase()===m.address?.toLocaleLowerCase()&&d.walletType===m.walletType&&d.chain===l?.fromBlockchain);h&&u.push(h)}if(l?.fromBlockchain!==l?.toBlockchain){let h=c.wallets[l?.toBlockchain];if(h){let d=e.find(f=>f.address?.toLocaleLowerCase()===h.address?.toLocaleLowerCase()&&f.walletType===h.walletType&&f.chain===l?.toBlockchain);d&&u.push(d)}}if(u.length>0){let h=n(),f=[{blockchain:l.fromBlockchain,address:l.fromSymbolAddress,symbol:l.fromSymbol},{blockchain:l.toBlockchain,address:l.toSymbolAddress,symbol:l.toSymbol}].filter(g=>h.some(C=>C.blockchain===g.blockchain&&C.address?.toLocaleLowerCase()===g.address?.toLocaleLowerCase()&&C.symbol?.toLocaleLowerCase()===g.symbol?.toLocaleLowerCase()));o(u,{selectedCustomTokens:f,shouldFetchCustomTokens:f.length>0})}}t(s,c)},"handleStepEvent");return he.on(oa.StepEvent,r),()=>he.off(oa.StepEvent,r)},[he,e]),Yh(()=>{let r=i(a=>{let{event:s,route:l}=a;(s.type===jh.FAILED||s.type===jh.SUCCEEDED)&&t(s,l)},"handleRouteEvent");return he.on(oa.RouteEvent,r),()=>he.off(oa.RouteEvent,r)},[he])}i(dc,"useSubscribeToWidgetEvents");import{useManager as aI}from"@rango-dev/queue-manager-react";import{useEffect as sI}from"react";function fc(){let{isSynced:t,syncNotifications:e}=we(),{manager:o,state:n}=aI();sI(()=>{we.persist.hasHydrated()&&n.loadedFromPersistor&&!t&&e(ft(o))},[we.persist.hasHydrated(),n.loadedFromPersistor,t])}i(fc,"useSyncNotifications");function gc(){Kh(),Gh(),dc(),fc();let t=y().blockchains(),{canSwitchNetworkTo:e}=ii(),[o,n]=Jh(""),[r,a]=Jh(),s=uI(Pr),l=t.filter(pI),{fetchApiConfig:c}=Vh();Zh(()=>()=>Bu(),[]),lI({lastConnectedWallet:o,clearDisconnectedWallet:()=>{a(void 0)},disconnectedWallet:r,evmChains:l,canSwitchNetworkTo:e}),Zh(()=>(fo.init(),we.persist.hasHydrated()||we.persist.rehydrate(),s.onConnectWallet(n),s.onDisconnectWallet(p=>{a(p),p===cI(o)?.[0]&&n("")}),c().catch(console.log),fo.destroy),[])}i(gc,"useBootstrap");import{styled as mI}from"@rango-dev/ui";var Rh=mI("div",{fontFamily:"$widget",boxSizing:"border-box",textAlign:"left","& *, *::before, *::after":{boxSizing:"inherit"},"& *:focus-visible":{outlineColor:"$info500",transition:"none"},"& ul, ol, li":{listStyleType:"none"}});function na(){gc();let{config:t}=y(),{activeTheme:e}=Yo(t?.theme||{}),{activeLanguage:o}=no();return hc.createElement(dI,{language:o},hc.createElement(Rh,{id:"swap-container",className:e()},hc.createElement(qh,null)))}i(na,"Main");import{setSolanaSignerConfig as MI}from"@rango-dev/signer-solana";import Sc,{useEffect as iy,useMemo as PI}from"react";import{useState as fI}from"react";var gI=i(()=>{let[t,e]=fI(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=qc(a);if(s){let l=o(s);e(l)}},"handleLoadCustomFont")}},"useFontLoader"),ey=gI;import{checkWaitingForNetworkChange as hI,makeQueueDefinition as yI}from"@rango-dev/queue-manager-rango-preset";import{Provider as SI}from"@rango-dev/queue-manager-react";import{useWallets as CI}from"@rango-dev/wallets-react";import{convertEvmBlockchainMetaToEvmChainInfo as kI}from"@rango-dev/wallets-shared";import{isEvmBlockchain as TI}from"rango-types";import vI,{useMemo as wI}from"react";function bI(t){let{providers:e,getSigners:o,state:n,connect:r,canSwitchNetworkTo:a,getWalletInfo:s}=CI(),l=wI(()=>yI({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(),m={blockchains:p.map(w=>({accounts:[w],name:w.chain}))},h=i(async(w,E)=>a(w,E.network)?await r(w,[E]):void 0,"switchNetwork"),d=i(w=>!!s(w).mobileWallet,"isMobileWallet"),f=u.filter(w=>w.enabled).reduce((w,E)=>(w[E.name]=E,w),{}),g=u.filter(TI),C=i(w=>{let{supportedChains:E}=s(w);return hn(E)},"getSupportedChainNames"),k=e(),S={meta:{blockchains:f,evmBasedChains:g,evmNetworkChainInfo:kI(g),getSupportedChainNames:C},getSigners:o,wallets:m,providers:k,switchNetwork:h,canSwitchNetworkTo:a,state:n,isMobileWallet:d},T=ne.use.isActiveTab();return vI.createElement(SI,{queuesDefs:[l],context:S,onPersistedDataLoaded:w=>{hI(w)},isPaused:!T},t.children)}i(bI,"QueueManager");var ty=bI;import{useManager as NI}from"@rango-dev/queue-manager-react";import BI,{createContext as WI,useContext as LI}from"react";function oy(){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:m,toBlockchain:h,toToken:d,requestAmount:f}=p,g={blockchains:e,tokens:o};if(u!==void 0){let C=e.find(k=>k.name===u)??null;n(C)}if(m!==void 0){let C=m?t(m)??null:null;r({meta:g,token:C})}if(h!==void 0){let C=e.find(k=>k.name===h)??null;a(C)}if(d!==void 0){let C=d?t(d)??null:null;s({meta:g,token:C})}f!==void 0&&l(f)},"updateQuoteInputs")}i(oy,"useUpdateQuoteInputs");import{cancelSwap as xI,getCurrentNamespaceOfOrNull as EI,getCurrentStep as II,getRelatedWalletOrNull as AI}from"@rango-dev/queue-manager-rango-preset";var ra=class{static{i(this,"WidgetHistory")}constructor(e,o){this.manager=e,this.actions=o}getAllSwaps(){return ft(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=Fr(e,o.blockchains,this.actions.findToken);return this.actions.retrySwap(n)}cancel(e){let o=this.manager?.get(e);o&&xI(o)}getCurrentStepInfo(e){let o=II(e);return{step:o,wallet:o?AI(e,o):null,network:o?EI(e,o)?.network:null}}};var ny=WI(void 0);function yc(t){let{manager:e}=NI(),o=ne.use.isActiveTab(),n=O.use.retry(),{findToken:r,getBalances:a,getConnectedWalletsDetails:s,fetchBalances:l}=y(),c=new ra(e,{retrySwap:n,findToken:r}),{fetchingWallets:p}=y(),u=Yc(a()),m=y().blockchains(),h=y().tokens(),d=y().swappers(),f=y().fetchStatus,g=no().resetLanguage,C=we().getNotifications(),k=we().clearNotifications,S=oy(),{fromBlockchain:T,toBlockchain:w,fromToken:E,toToken:B,inputAmount:I}=O(),x={isActiveTab:o,setCurrentTabAsActive:fo.forceClaim,history:c,wallets:{isLoading:p,details:s(),totalBalance:u,refetch:async b=>l(b)},meta:{blockchains:m,tokens:h,swappers:d,loadingStatus:f,findToken:r},resetLanguage:g,notifications:{list:C,clearAll:k},quote:{quoteInputs:{fromBlockchain:T?.name??null,fromToken:E?{symbol:E.symbol,blockchain:E.blockchain,address:E.address}:null,toBlockchain:w?.name??null,toToken:B?{symbol:B.symbol,blockchain:B.blockchain,address:B.address}:null,requestAmount:I},updateQuoteInputs:S}};return BI.createElement(ny.Provider,{value:x},t.children)}i(yc,"WidgetInfo");function ry(){let t=LI(ny);if(!t)throw new Error("useWidget can only be used within the WidgetProvider component");return t}i(ry,"useWidget");function ia(t){let{onUpdateState:e,config:o}=t,n=t.config?.theme?.fontFamily,{handleLoadCustomFont:r}=ey();return iy(()=>{n&&r(n)},[n]),PI(()=>{rp({API_KEY:o?.apiKey||hr,BASE_URL:o?.apiUrl||Pc})},[o.apiKey,o.apiUrl]),iy(()=>{t.config?.signers?.customSolanaRPC&&MI("customRPC",t.config.signers.customSolanaRPC)},[t.config?.signers?.customSolanaRPC]),Sc.createElement(_r,{config:o,onUpdateState:e},Sc.createElement(ty,{apiKey:o.apiKey},Sc.createElement(yc,null,t.children)))}i(ia,"WidgetProvider");function ay(t){let e=t.config?.externalWallets;return aa.createElement(Jp,null,e?aa.createElement(na,null):aa.createElement(ia,{config:t.config??fr},aa.createElement(na,null)))}i(ay,"Widget");function sy(){let{on:t,off:e}=he;return{on:t,off:e}}i(sy,"useWidgetEvents");var lY={DerivationPath:vn,Namespaces:Tn,isOnDerivationPath:bn,isOnNamespace:wn};export{PX as EventSeverity,Uo as MainEvents,qX as Networks,KX as PendingSwapNetworkStatus,Ta as QuoteEventTypes,_X as RouteEventType,pa as SUPPORTED_FONTS,lY as StatefulConnect,DX as StepEventType,$X as StepExecutionBlockedEventStatus,FX as StepExecutionEventStatus,$e as UI_ID,wa as UiEventTypes,va as WalletEventTypes,QX as WalletEvents,GX as WalletTypes,ay as Widget,Uo as WidgetEvents,ia as WidgetProvider,_r as WidgetWallets,ls as customizedThemeTokens,UX as readAccountAddress,Kt as useStatefulConnect,ht as useWalletList,ii as useWallets,ry as useWidget,sy as useWidgetEvents,uS as widgetEventEmitter};
3
3
  //# sourceMappingURL=index.js.map