@rango-dev/widget-embedded 0.39.1-next.13 → 0.39.1-next.14

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 Fh=Object.defineProperty;var i=(t,e)=>Fh(t,"name",{value:e,configurable:!0});import{EventSeverity as Kj,RouteEventType as jj,StepEventType as Xj,StepExecutionBlockedEventStatus as Yj,StepExecutionEventStatus as Zj}from"@rango-dev/queue-manager-rango-preset";import{legacyReadAccountAddress as Rj}from"@rango-dev/wallets-core/legacy";import{useWallets as jr,Events as t3}from"@rango-dev/wallets-react";import{Networks as n3,WalletTypes as r3}from"@rango-dev/wallets-shared";import{PendingSwapNetworkStatus as a3}from"rango-types";import{Divider as MS}from"@rango-dev/ui";import lo,{useEffect as LS,useRef as PS,useState as Np}from"react";import{WalletState as Oh}from"@rango-dev/ui";import{useWallets as Uh}from"@rango-dev/wallets-react";import{useReducer as zh}from"react";function oc(t){return!!t.derivationPath}i(oc,"isStateOnDerivationPathStep");function nc(t){return!!t.namespace}i(nc,"isStateOnNamespace");var nr={status:"init",namespace:null,derivationPath:null};function rc(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 nr;case"resetDerivation":return t.namespace?{...t,derivationPath:null,status:"namespace"}:nr;default:throw new Error("Action hasn't been defined.")}}i(rc,"reducer");function Gt(){let{state:t,disconnect:e,connect:o}=Uh(),[n,r]=zh(rc,nr),a=i(async(p,d,h)=>{r({type:"reset"});try{let m=d?.map(f=>({...f,network:void 0}));return await o(p,m),{status:"connected"}}catch(m){let f=m?.message?`Error: ${m.message}`:"An unknown error happened during connecting wallet.";throw new Error(f,{cause:m})}},"runConnect"),s=i(async(p,d)=>{if(p.state===Oh.DISCONNECTED){if(!!p.isHub&&p.properties?.find(k=>k.name==="detached")&&p.state!=="connected")return r({type:"needsNamespace",payload:{targetWallet:p}}),{status:"namespace"};if(!p.needsNamespace)return await a(p.type,void 0,d);let f=p.needsNamespace.data.length>1,g=p.needsDerivationPath;if(f)return r({type:"needsNamespace",payload:{targetWallet:p}}),{status:"namespace"};if(g){let C=p.needsNamespace.data[0];return r({type:"needsDerivationPath",payload:{providerType:p.type,providerImage:p.image,namespace:C.value}}),{status:"derivation-path"}}return await a(p.type,p.needsNamespace?.data.map(C=>({namespace:C.value})),d)}return d?.disconnectIfConnected?(await u(p.type),{status:"disconnected"}):{status:"disconnected-unhandled"}},"handleConnect"),l=i(async(p,d)=>{let h=p.needsNamespace?.selection==="single",m=p.needsDerivationPath,f=d[0];if(!f)throw new Error("To confirm a namespace, you should select at least one namespace.");if(h&&m)return r({type:"needsDerivationPath",payload:{providerType:p.type,providerImage:p.image,namespace:f}}),{status:"derivation-path"};if(!nc(n))throw new Error("Something went wrong on handling namespace. Please retry.");let g=n.namespace.targetWallet.type,C=d.map(S=>({namespace:S}));return await a(g,C)},"handleNamespace"),c=i(async p=>{if(!p)throw new Error("Derivation path is empty. Please make sure you've filled the field correctly.");if(!oc(n))throw new Error("It seems you are filling derivation path without setting namespace before doing that. Please retry to connect.");let d=n.derivationPath.providerType,m=[{namespace:n.derivationPath.namespace,derivationPath:p}];return await a(d,m)},"handleDerivationPath"),u=i(async p=>{let d=t(p);return d.connected||d.connecting?(await e(p),{status:"disconnected"}):{status:"noop"}},"handleDisconnect");return{handleConnect:s,handleDisconnect:u,handleNamespace:l,handleDerivationPath:c,getState:()=>n,resetState:p=>{r(p==="derivation"?{type:"resetDerivation"}:{type:"reset"})}}}i(Gt,"useStatefulConnect");import{WalletState as ga}from"@rango-dev/ui";import{useWallets as Yy}from"@rango-dev/wallets-react";import{detectMobileScreens as Zy,KEPLR_COMPATIBLE_WALLETS as Jy,WalletTypes as un}from"@rango-dev/wallets-shared";import{useCallback as Ry,useEffect as eS}from"react";import Gy,{createContext as Vy,useContext as Ky,useEffect as jy,useRef as Xy}from"react";import{create as qy}from"zustand";import{persist as Hy}from"zustand/middleware";import{allProviders as Qh}from"@rango-dev/provider-all";var Yi=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()}},bo=new Yi;import{defineVersions as ac,pickVersion as sc,Provider as Zi}from"@rango-dev/wallets-core";function lc({allProviders:t,configWallets:e}){if(e){let o=[];return e.forEach(n=>{if(typeof n=="string"){let r=t.find(a=>{let s=cc(a);return s instanceof Zi?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 Zi?o.push(ac().version("1.0.0",n).build()):o.push(ac().version("0.0.0",n).build())}),o}return t}i(lc,"matchAndGenerateProviders");function cc(t){try{return sc(t,"1.0.0")[1]}catch{return sc(t,"0.0.0")[1]}}i(cc,"pickProviderVersionWithFallbackToLegacy");function pc(t){return t.map(o=>cc(o)).map(o=>o instanceof Zi?o.id:o.config.type)}i(pc,"configWalletsToWalletName");function rr(t,e){return e.find(o=>o.name===t)?.displayName}i(rr,"getBlockchainDisplayNameFor");function st(t,e){return e.find(o=>o.name===t)?.shortName}i(st,"getBlockchainShortNameFor");function uc(t,e){return e.find(o=>o.name===t)?.logo}i(uc,"getBlockchainImage");function on(t,e){return e.find(o=>o.id===t)?.title}i(on,"getSwapperDisplayName");function nn(t,e){return e.find(o=>o.name===t)??null}i(nn,"findBlockchain");function Ji(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(Ji,"isTokenNative");function lt(t){return`${t.blockchain.toLowerCase()}-${t.symbol.toLowerCase()}-${(t.address??"").toLowerCase()}`}i(lt,"createTokenHash");function xo(t,e){return t.addressPatterns.filter(r=>new RegExp(r).test(e)).length>0}i(xo,"isValidTokenAddress");function rn(t){let{config:e,meta:o}=t,n={},r=e.tokens,a=i(l=>{l.forEach(c=>{typeof c!="string"&&(c=lt(c));let u=o.tokensMapByTokenHash.get(c);u&&(n[c]=u)})},"addTokens");if(Array.isArray(r))return r.length>0?(a(r),Object.values(n)):Array.from(o.tokensMapByTokenHash.values());if(!r)return Array.from(o.tokensMapByTokenHash.values());let s;if(e.blockchains?.length)s=e.blockchains;else{s=Object.keys(r);let l=new Set(s);Object.keys(o.tokensMapByBlockchainName).forEach(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(u=>{let p=lt(u);delete n[p]})):a(c.tokens))}),Object.values(n)}i(rn,"matchTokensFromConfigWithMeta");function ir(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(ir,"getSupportedBlockchainsFromConfig");function mc(t){return{walletConnectProjectId:t?.walletConnectProjectId,trezorManifest:t?.trezorManifest,tonConnect:t?.tonConnect,walletConnectListedDesktopWalletLink:t.__UNSTABLE_OR_INTERNAL__?.walletConnectListedDesktopWalletLink}}i(mc,"makeProvidersOptionsFromConfig");var ar={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"}},qh={clientUrl:void 0},Hh={liquiditySources:void 0};function dc(t){let e=mc(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 Qh(o).map(a=>a())}i(dc,"generateProviders");var fc=i((t,e,o)=>{let n=dc({...ar,...t});return{config:{...ar,...t},iframe:qh,campaignMode:Hh,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=rn({type:"source",config:{blockchains:r.from?.blockchains,tokens:r.from?.tokens},meta:{tokensMapByBlockchainName:l,tokensMapByTokenHash:s}}),u=rn({type:"destination",config:{blockchains:r.to?.blockchains,tokens:r.to?.tokens},meta:{tokensMapByBlockchainName:l,tokensMapByTokenHash:s}});bo.set("supportedSourceTokens",c),bo.set("supportedDestinationTokens",u),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=dc(r);e({allProviders:a})},getAvailableProviders:()=>{let{allProviders:r,config:a}=o(),s=mc(a);return lc({allProviders:r,configWallets:a.wallets,options:s})}}},"createConfigSlice");import{TransactionType as gc}from"rango-types";var hc=[gc.EVM,gc.SOLANA];import{RangoClient as iy}from"rango-sdk";import{UI_ID as Gh}from"@rango-dev/ui";var sr="c6381a79-2817-4602-83bf-6a641a409e32",yc="https://api.rango.exchange",Sc="https://explorer.rango.exchange",De={SWAP_BOX_ID:"rango-swap-box",EXPANDED_BOX_ID:"rango-expanded-box",...Gh};import{BlockchainCategories as Jh,WalletState as bt}from"@rango-dev/ui";import{legacyReadAccountAddress as Rh}from"@rango-dev/wallets-core/legacy";import{detectInstallLink as ey,getCosmosExperimentalChainInfo as ty,isEvmAddress as oy,KEPLR_COMPATIBLE_WALLETS as tA,Networks as Bc}from"@rango-dev/wallets-shared";import Io from"bignumber.js";import{isCosmosBlockchain as ny}from"rango-types";import Vh from"bignumber.js";var ce=new Vh(0);import{WalletTypes as Kh}from"@rango-dev/wallets-shared";var Cc=[Kh.LEAP];import{BlockchainCategories as ea,WalletState as Zh}from"@rango-dev/ui";import{TransactionType as lr}from"rango-sdk";var kc="Roboto",Ri=[{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 Eo(t){return Array.from(new Set(t))}i(Eo,"removeDuplicateFrom");function Ec(t,e){let o;return n;function n(...r){o&&clearTimeout(o),o=setTimeout(()=>{o=null,t(...r)},e)}}i(Ec,"debounce");function Je(t,e){return t.toLowerCase().indexOf(e.toLowerCase())>-1}i(Je,"containsText");function wc(t,e){return t.toLowerCase()===e.toLowerCase()}i(wc,"exactText");function bc(t,e){return t.toLowerCase().startsWith(e.toLowerCase())}i(bc,"startWithText");var N=i(()=>document.getElementById(De.SWAP_BOX_ID),"getContainer"),no=i(()=>document.getElementById(De.EXPANDED_BOX_ID),"getExpanded");function xc(t,e,o){let n=!!e&&wc(e,t),r=!!o&&wc(o,t);return n!==r?n?-1:1:0}i(xc,"compareExactMatchText");function ta(t,e,o){let n=!!e&&Je(e,t),r=!!o&&Je(o,t);return n!==r?n?-1:1:n&&r&&e?.length!==o?.length?e?.length-o?.length:0}i(ta,"compareContainsText");function oa(t,e,o){let n=!!e&&bc(e,t),r=!!o&&bc(o,t);return n!==r?n?-1:1:n&&r&&e?.length!==o?.length?e?.length-o?.length:0}i(oa,"compareStartWithText");function Ic(t,e,o){if(!o)return 0;let n=xc(o,t.symbol,e.symbol);if(n)return n;if(o.length>=3){let r=xc(o,t.name,e.name);if(r)return r}if(o.length>=2){let r=oa(o,t.symbol,e.symbol);if(r)return r}if(o.length>=3){let r=ta(o,t.symbol,e.symbol);if(r)return r}if(o.length>=3){let r=oa(o,t.name,e.name);if(r)return r}if(o.length>=3){let r=ta(o,t.name,e.name);if(r!==0)return r}if(o.length>=4){let r=oa(o,t.address,e.address);if(r)return r}if(o.length>=4){let r=ta(o,t.address,e.address);if(r!==0)return r}return 0}i(Ic,"compareWithSearchFor");var cr=i((t,e)=>{switch(e){case ea.ALL:return!0;case ea.UTXO:return t===lr.TRANSFER;case ea.OTHER:return t!==lr.TRANSFER&&t!==lr.COSMOS&&t!==lr.EVM;default:return t===e}},"isBlockchainTypeInCategory"),Ac=i(t=>Ri.find(o=>o.value===t)?.url,"getFontUrlByName");function Nc(t,e){let o=!!t.find(n=>n.state===Zh.CONNECTED);return e===!1&&o}i(Nc,"isSingleWalletActive");import{BigNumber as Wc}from"bignumber.js";var an=i(t=>{let e=Math.floor(t%60/15)*15,o=parseInt((t/60).toString());return o>=60?`${Math.floor(o/5)*5}:00`:`${o.toString().padStart(2,"0")}:${e.toString().padStart(2,"0")}`},"roundedSecondsToString"),L=i((t,e=null,o=null)=>{if(t==null||t==="")return"";let n=new Wc(t),r=1,a=1e3;for(let s=0;s<60;s++)if(new Wc(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 pr=i(t=>t?.reduce((e,o)=>e+(o.estimatedTimeInSeconds??0),0)||0,"totalArrivalTime");var wt=i((t,e)=>t.toLowerCase().indexOf(e.toLowerCase())>-1,"containsText"),sn=i(t=>!!t&&parseFloat(t)>0,"isPositiveNumber");function ln(t){switch(!0){case t.connected:return bt.CONNECTED;case t.connecting:return bt.CONNECTING;case!t.installed:return bt.NOT_INSTALLED;default:return bt.DISCONNECTED}}i(ln,"mapStatusToWalletState");function Mc(t,e,o,n){return o.filter(r=>!Cc.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(p=>p.name===n):!0}).map(r=>{let{name:a,img:s,installLink:l,showOnMobile:c,needsNamespace:u,supportedChains:p,needsDerivationPath:d,properties:h,isHub:m}=e(r),f=Eo(p.map(C=>C.type)),g=ln(t(r));return{title:a,image:s,link:ey(l),state:g,type:r,showOnMobile:c,needsNamespace:u,blockchainTypes:f,needsDerivationPath:d,properties:h,isHub:m}})}i(Mc,"mapWalletTypesToWalletInfo");function mr(t){if(!t)return null;let e=[];return e=t.map(o=>o.name),e}i(mr,"walletAndSupportedChainsNames");function ra(t,e,o,n,r){let a=[];function s(c,u){if(!!!a.find(d=>d.chain===c)){let d={address:u,chain:c,walletType:t};a.push(d)}}i(s,"addAccount");let l=n||[];return e.forEach(c=>{let{address:u,network:p}=Rh(c),d=l.length>0,h=l.includes(p),m=p===Bc.Unknown;if(d&&!h&&!m)return;let g=p===Bc.Unknown&&oy(u);if(m&&!g)return;o.includes(p)||g?r?s(p,u.toLowerCase()):l.filter(k=>o.includes(k)).forEach(k=>{s(k,u.toLowerCase())}):s(p,u)}),a}i(ra,"prepareAccountsForWalletStore");function ro(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((u,p)=>{let d=u.from.blockchain,h=u.to.blockchain,m=a===o.swaps.length-1,f=p===c.length-1;(!m&&!f||m&&l!==d||e==="all")&&n.add(d),e==="all"&&n.add(h)})}e==="all"&&n.add(l)}),Array.from(n)}i(ro,"getQuoteWallets");function Lc(t,e){return t.address===e.address&&t.chain===e.chain&&t.walletType===e.walletType}i(Lc,"isAccountAndWalletMatched");var Pc=i(t=>{let e=Object.values(t).reduce((o,n)=>{let r=n.usdValue?na(n.usdValue,n.decimals):ce.toFixed();return o.plus(r)},new Io(ce));return ry(e.toString())},"calculateWalletUsdValue");function ry(t){let e=t.toString().split(".");return e[0]=e[0].replace(/\B(?=(\d{3})+(?!\d))/g,","),e.join(".")}i(ry,"numberWithThousandSeparator");var fr=i((t,e)=>{let o=ty(Object.entries(t).map(([,n])=>n).filter(ny));return o&&o[e]?.experimental},"isExperimentalChain");function na(t,e){return new Io(t).shiftedBy(-e).toFixed()}i(na,"representAmountInNumber");function gr(t){if(!t)return null;let e=na(t.amount,t.decimals),o=t.usdValue?na(t.usdValue,t.decimals):null,n=L(e,8,8),r=o?L(o,4,4):null;return t?{...t,amount:n,usdValue:r}:null}i(gr,"formatBalance");function _c(t,e){if(t?.usdValue||e?.usdValue){let o=t&&t.usdValue?new Io(t.usdValue).shiftedBy(-t.decimals):ce,n=e&&e.usdValue?new Io(e.usdValue).shiftedBy(-e.decimals):ce;return o.isEqualTo(n)?0:o.isGreaterThan(n)?-1:1}if(t?.amount||e?.amount){let o=t&&t.amount?new Io(t.amount).shiftedBy(-t.decimals):ce,n=e&&e.amount?new Io(e.amount).shiftedBy(-e.decimals):ce;return o.isEqualTo(n)?0:o.isGreaterThan(n)?-1:1}return 0}i(_c,"compareTokenBalance");function Mt(t,e){return t?.blockchain===e?.blockchain&&t?.symbol.toLowerCase()===e?.symbol.toLowerCase()&&t?.address?.toLowerCase()===e?.address?.toLowerCase()}i(Mt,"areTokensEqual");function Dc(t){return t.sort((e,o)=>+(o.state===bt.CONNECTED)-+(e.state===bt.CONNECTED)||+(o.state===bt.DISCONNECTED||o.state===bt.CONNECTING)-+(e.state===bt.DISCONNECTED||e.state===bt.CONNECTING))}i(Dc,"sortWalletsBasedOnConnectionState");function hr(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(hr,"getConciseAddress");function $c({chain:t,connectedWallets:e,walletType:o}){return e.find(n=>n.walletType===o&&n.chain===t)?.address}i($c,"getAddress");var Fc=i((t,e)=>!!t.find(o=>o.chain===e&&o.loading),"isFetchingBalance");function Oc(t){return t.map(e=>e.state).join("-")}i(Oc,"hashWalletsState");function Uc(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(Uc,"filterBlockchainsByWalletTypes");function zc(t,e){return e===Jh.ALL?t:t.filter(o=>{for(let n of o.blockchainTypes)if(cr(n,e))return!0;return!1})}i(zc,"filterWalletsByCategory");var ia={API_KEY:sr};function Lt(t){return ia[t]||""}i(Lt,"getConfig");function Qc(t){let e;return typeof structuredClone=="function"?e=structuredClone(t):e=JSON.parse(JSON.stringify(t)),ia=e,ia}i(Qc,"initConfig");var qc=20,Hc=25,aa="theme-widget",sa=i((t,e)=>{let o=!1;if(e&&t){if(Array.isArray(e))o=!e.some(n=>Mt(n,t));else if(!Array.isArray(e)&&e[t.blockchain]){o=e[t.blockchain].tokens.some(r=>Mt(r,t));let n=e[t.blockchain].isExcluded;return!n&&!o||n&&o}}return o},"isTokenExcludedInConfig"),la=i((t,e)=>t&&e&&!e.includes(t.name),"isBlockchainExcludedInConfig"),Gc=i((t,e,o)=>o==="expanded"&&(t||e)||o==="full-expanded"&&e,"isVariantExpandable");var yr,xt=i(()=>yr||(yr=new iy(Lt("API_KEY"),Lt("BASE_URL")),yr),"httpService");function Sr(t,e){let o=t.map(a=>a.swapperGroup),n=[];return Eo(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(Sr,"getUniqueSwappersGroups");function Vc(t,e){return t.swapperGroup<e.swapperGroup?-1:t.swapperGroup>e.swapperGroup?1:0}i(Vc,"sortLiquiditySourcesByGroupTitle");function Ve(t,e){return e?.[t]==="hidden"}i(Ve,"isFeatureHidden");function Ao(t,e){return e?.[t]==="enabled"}i(Ao,"isRoutingEnabled");var Kc=i((t,e,o)=>Ve("customTokens",o)?t:t.concat(e),"addCustomTokensToSupportedTokens");var jc=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=ir({config:a}),u=r;return c.length>0&&(u=u.filter(p=>c.includes(p.name))),u.filter(p=>hc.includes(p.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 u=o.type==="source"?"from":"to",p=o.type==="source"?"supportedSourceTokens":"supportedDestinationTokens",d=bo.get(p);d?.length||(d=rn({type:o.type,config:{blockchains:a[u]?.blockchains,tokens:a[u]?.tokens},meta:{tokensMapByTokenHash:n,tokensMapByBlockchainName:r}}),bo.set(p,d)),d=Kc(d,s,a.features);let h=e().blockchains({type:o.type});return d.filter(f=>o.blockchain&&f.blockchain!==o.blockchain||!h.some(g=>g.name===f.blockchain)?!1:o.searchFor?!!(Je(f.symbol,o.searchFor)||Je(f.address||"",o.searchFor)||Je(f.name||"",o.searchFor)):!0).sort((f,g)=>{let C=e().isTokenPinned(f,o.type),S=e().isTokenPinned(g,o.type);if(C!==S)return C?-1:1;if(o.getBalanceFor){let A=o.getBalanceFor(f),M=o.getBalanceFor(g),x=_c(A,M);if(x!==0)return x}let k=c.get(f.blockchain),T=c.get(g.blockchain),v=Ji(f,k),w=Ji(g,T);if(v!==w)return v?-1:1;if(f.isPopular!==g.isPopular)return f.isPopular?-1:1;if(o.searchFor){let A=Ic(f,g,o.searchFor);if(A)return A}return f.isSecondaryCoin!==g.isSecondaryCoin?f.isSecondaryCoin?1:-1:k&&T?k.sort-T.sort:0})},findToken:o=>{let n=e()._tokensMapByTokenHash,r=e().customTokens(),a=lt(o),s=n.get(a);return s||(s=r.find(l=>lt(l)===a)),s},isTokenPinned:(o,n)=>!!(n==="source"?e().config.from?.pinnedTokens:e().config.to?.pinnedTokens)?.some(s=>Mt(s,o)),swappers:()=>{let{config:o,campaignMode:n}=e(),r=n.liquiditySources?.length?n.liquiditySources:null,a=r??o.liquiditySources,s=r?!1:o.excludeLiquiditySources;return e()._swappers.filter(u=>{let p=a?.includes(u.swapperGroup);return s||!a||a.length===0?!p:p}).sort(Vc)},fetch:async()=>{try{let{routing:o}=e().config,n=Ao("enableCentralizedSwappers",o),r=await xt().getAllMetadata({enableCentralizedSwappers:n});t({fetchStatus:"success"});let a=new Map,s=new Map,l={},c=[],u=r.popularTokens,p=r.swappers.filter(m=>m.enabled),d=new Set;r.tokens.forEach(m=>{d.add(m.blockchain),c.push(m)}),r.blockchains.sort((m,f)=>m.sort-f.sort).forEach(m=>{m.enabled&&d.has(m.name)&&a.set(m.name,m)}),c.forEach(m=>{let f=lt(m);l[m.blockchain]||(l[m.blockchain]=[]),s.set(f,m),l[m.blockchain].push(f)}),t({_blockchainsMapByName:a,_tokensMapByTokenHash:s,_tokensMapByBlockchainName:l,_popularTokens:u,_swappers:p})}catch(o){throw t({fetchStatus:"failed"}),o}}}),"createDataSlice");import{Bengali as ay,Catalonia as sy,Chinese as Xc,Denmark as ly,English as cy,Finland as py,French as uy,German as dy,Greece as my,Hungary as fy,India as gy,Indonesian as hy,Italian as yy,Japanese as Sy,Korea as Cy,Lithuania as ky,Malay as Ty,Netherlands as vy,Pakistan as wy,Philippines as by,Poland as xy,Portuguese as Ey,Russian as Iy,SaudiArabia as Ay,Serbia as Ny,Slovakia as Wy,SouthAfrica as By,Spanish as My,Swahili as Ly,Swedish as Py,Thai as _y,Turkish as Dy,Ukrainian as $y,Vietnamese as Fy}from"@rango-dev/ui";var Yc=[{title:"Afrikaans",label:"Afrikaans",local:"af",SVGFlag:By},{title:"Arabic",label:"\u0639\u0631\u0628\u064A",local:"ar",SVGFlag:Ay},{title:"Bengali",label:"\u09AC\u09BE\u0982\u09B2\u09BE",local:"bn",SVGFlag:ay},{title:"Catalan",label:"Catal\xE0",local:"ca",SVGFlag:sy},{title:"Chinese (Simplified)",label:"\u7B80\u4F53\u4E2D\u6587",local:"zh-CN",SVGFlag:Xc},{title:"Chinese (Traditional)",label:"\u4E2D\u6587\uFF08\u7E41\u9AD4)",local:"zh-TW",SVGFlag:Xc},{title:"Danish",label:"Dansk",local:"da",SVGFlag:ly},{title:"Dutch",label:"Nederlands",local:"nl",SVGFlag:vy},{title:"English",label:"English",local:"en",SVGFlag:cy},{title:"Filipino",label:"Filipino",local:"fil",SVGFlag:by},{title:"Finnish",label:"Suomalainen",local:"fi",SVGFlag:py},{title:"French",label:"Fran\xE7ais",local:"fr",SVGFlag:uy},{title:"German",label:"Deutsch",local:"de",SVGFlag:dy},{title:"Greek",label:"\u03B5\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AC",local:"el",SVGFlag:my},{title:"Hindi",label:"\u0939\u093F\u0902\u0926\u0940",local:"hi",SVGFlag:gy},{title:"Hungarian",label:"Magyar",local:"hu",SVGFlag:fy},{title:"Indonesian",label:"Indonesia",local:"id",SVGFlag:hy},{title:"Italian",label:"Italiana",local:"it",SVGFlag:yy},{title:"Japanese",label:"\u65E5\u672C\u8A9E",local:"ja",SVGFlag:Sy},{title:"Korean",label:"\uD55C\uAD6D\uC778",local:"ko",SVGFlag:Cy},{title:"Lithuanian",label:"Lietuvi\u0173",local:"lt",SVGFlag:ky},{title:"Malay",label:"Melayu",local:"ms",SVGFlag:Ty},{title:"Polish",label:"Polski",local:"pl",SVGFlag:xy},{title:"Portuguese",label:"Portugu\xEAs",local:"pt",SVGFlag:Ey},{title:"Russian",label:"\u0420\u0443\u0441\u0441\u043A\u0438\u0439",local:"ru",SVGFlag:Iy},{title:"Serbian",label:"C\u0440\u043F\u0441\u043A\u0438",local:"sr",SVGFlag:Ny},{title:"Slovak",label:"Slovensk\xFD",local:"sk",SVGFlag:Wy},{title:"Spanish",label:"Espa\xF1ol",local:"es",SVGFlag:My},{title:"Swahili",label:"Kiswahili",local:"sw",SVGFlag:Ly},{title:"Swedish",label:"Svenska",local:"sv",SVGFlag:Py},{title:"Thai",label:"\u0E41\u0E1A\u0E1A\u0E44\u0E17\u0E22",local:"th",SVGFlag:_y},{title:"Turkish",label:"T\xFCrk\xE7e",local:"tr",SVGFlag:Dy},{title:"Ukrainian",label:"Y\u043A\u0440\u0430\u0457\u043D\u0456",local:"uk",SVGFlag:$y},{title:"Urdu",label:"\u0627\u0631\u062F\u0648",local:"ur",SVGFlag:wy},{title:"Vietnamese",label:"Ti\u1EBFng Vi\u1EC7t",local:"vi",SVGFlag:Fy}],No="en";var Zc=[.5,1,3],Jc=1,Rc=5,ep=100,tp=0;var op=i((t,e)=>({disabledLiquiditySources:[],theme:"auto",language:null,preferredBlockchains:[],slippage:Jc,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,u=l<=9;return c&&u}))return;let a=n.filter(s=>!(s===o));t(()=>({preferredBlockchains:[o,...a]}))},setSlippage:o=>t(()=>({slippage:o})),setCustomSlippage:o=>t(()=>({customSlippage:o})),setAffiliateRef:o=>t(()=>({affiliateRef:o})),setAffiliatePercent:o=>t(()=>({affiliatePercent:o})),setAffiliateWallets:o=>t(()=>({affiliateWallets:o})),toggleAllLiquiditySources:(o,n)=>t(r=>{if(n)return{disabledLiquiditySources:[]};let a=Eo(o.map(s=>s.swapperGroup));return a.length===r.disabledLiquiditySources.length?{disabledLiquiditySources:[]}:{disabledLiquiditySources:a}}),toggleInfiniteApprove:()=>t(o=>({infiniteApprove:!o.infiniteApprove})),toggleLiquiditySource:o=>t(n=>n.disabledLiquiditySources.includes(o)?{disabledLiquiditySources:n.disabledLiquiditySources.filter(r=>r!=o)}:{disabledLiquiditySources:n.disabledLiquiditySources.concat(o)}),setTheme:o=>t(()=>({theme:o})),setLanguage:o=>t(()=>({language:o})),updateSettings:o=>{let{features:n,theme:r}=o,a=Ve("theme",n),s=Ve("language",n),l=Ve("liquiditySource",n),c=r?.singleTheme,u=o?.__UNSTABLE_OR_INTERNAL__?.autoUpdateSettings;t({...a&&{theme:o.theme?.mode||"auto"},...c&&{theme:o.theme?.mode||"light"},...s&&{language:o.language||No},...l&&{disabledLiquiditySources:o.liquiditySources||[]},...u&&{language:o.language||No}})},setCustomToken:o=>t(n=>({_customTokens:[o,...n._customTokens]})),deleteCustomToken:o=>t(n=>({_customTokens:n._customTokens.filter(r=>r.address!==o.address)})),customTokens:()=>{let o=e().config,n=e()._customTokens,r=ir({config:o});return r.length?n.filter(a=>r.includes(a.blockchain)):n}}),"createSettingsSlice");import fa from"bignumber.js";import Oy from"mitt";var he=Oy(),Uy={on:he.on,off:he.off};import{WidgetEvents as np}from"@rango-dev/queue-manager-rango-preset";var pa=(o=>(o.QUOTE_INPUT_UPDATE="quoteInputUpdate",o.QUOTE_OUTPUT_UPDATE="quoteOutputUpdate",o))(pa||{}),ua=(o=>(o.CONNECT="connect",o.DISCONNECT="disconnect",o))(ua||{}),da=(e=>(e.CLICK_CONNECT_WALLET="clickConnectWallet",e))(da||{}),Wo=(a=>(a[a.RouteEvent=np.RouteEvent]="RouteEvent",a[a.StepEvent=np.StepEvent]="StepEvent",a.QuoteEvent="quoteEvent",a.WalletEvent="walletEvent",a.UiEvent="uiEvent",a))(Wo||{});import zy from"bignumber.js";function cn(t){return`${t.blockchain}-${t.address}-${t.symbol}`}i(cn,"createAssetKey");function ma(t,e){return`${cn(e)}-${t}`}i(ma,"createBalanceKey");function pn(t){let[e,o,n]=t.split("-");return{address:o==="null"?null:o,blockchain:e,symbol:n}}i(pn,"extractAssetFromBalanceKey");function rp(t,e){let o={};return t.balances?.forEach(n=>{let r=ma(t.address,n.asset),a=n.amount.amount,s=n.amount.decimals,l=e().findToken(n.asset)?.usdPrice,c=l?new zy(l??ce).multipliedBy(a).toString():"",u={amount:a,decimals:s,usdValue:c};o[r]=u}),o}i(rp,"createBalanceStateForNewAccount");function ip(t,e){for(let o in e){let n=pn(o),r=cn(n);t[r]||(t[r]=[]),t[r].includes(o)||(t[r]=[...t[r],o])}return t}i(ip,"updateAggregatedBalanceStateForNewAccount");function ap(t,e){let o=pn(e),n=cn(o);return t[n]&&(t[n]=t[n].filter(r=>r!==e)),t}i(ap,"removeBalanceFromAggregatedBalance");function Qy(t,e){return e.find(o=>t.address===o.address&&t.chain===o.blockChain)}i(Qy,"matchWalletDetailsWithConnectedWallet");var sp=i((t,e)=>({_balances:{},_aggregatedBalances:{},connectedWallets:[],fetchingWallets:!1,setConnectedWalletAsRefetching:o=>{t(n=>({fetchingWallets:!0,connectedWallets:n.connectedWallets.map(r=>r.walletType===o?{...r,loading:!0,error:!1}:r)}))},setConnectedWalletRetrievedData:(o,n)=>{t(r=>({fetchingWallets:!1,connectedWallets:r.connectedWallets.map(a=>a.walletType===o?{...a,loading:!1,error:!1,explorerUrl:Qy(a,n)?.explorerUrl||a.explorerUrl}:a)}))},setConnectedWalletHasError:o=>{t(n=>({fetchingWallets:!1,connectedWallets:n.connectedWallets.map(r=>r.walletType===o?{...r,loading:!1,error:!0}:r)}))},addConnectedWallet:(o,n)=>{let r=e().connectedWallets,a=o.filter(s=>!r.some(l=>Lc(s,l)));if(a.length>0){let s=a.map(l=>{let c=!r.some(u=>u.chain===l.chain&&u.selected&&u.walletType!==l.walletType);return{address:l.address,chain:l.chain,explorerUrl:null,walletType:l.walletType,selected:c,namespace:n,loading:!1,error:!1}});t(l=>({connectedWallets:[...l.connectedWallets.filter(u=>!s.some(p=>p.walletType===u.walletType&&p.chain===u.chain)),...s]}))}},setWalletsAsSelected:o=>{let n=e().connectedWallets.map(r=>{let a=!!o.find(l=>l.chain===r.chain&&l.walletType!==r.walletType&&r.selected),s=!!o.find(l=>l.chain===r.chain&&l.walletType===r.walletType&&!r.selected);return a?{...r,selected:!1}:s?{...r,selected:!0}:r});t({connectedWallets:n})},newWalletConnected:async(o,n)=>{he.emit("walletEvent",{type:"connect",payload:{walletType:o[0].walletType,accounts:o}}),e().addConnectedWallet(o,n),e().fetchBalances(o)},removeBalancesForWallet:(o,n)=>{let r=e().connectedWallets.filter(u=>u.walletType===o);e().connectedWallets.forEach(u=>{u.walletType!==o&&(r=r.filter(p=>!(p.chain===u.chain&&p.address===u.address)))}),n?.chains&&n.chains.length>0&&(r=r.filter(u=>n.chains?.includes(u.chain))),n?.namespaces&&n.namespaces.length>0&&(r=r.filter(u=>u.namespace?n.namespaces?.includes(u.namespace):!1));let a={},s=e()._aggregatedBalances,l=e()._balances;Object.keys(l).forEach(u=>{let p=pn(u);!!r.find(h=>ma(h.address,{address:p.address,blockchain:h.chain,symbol:p.symbol})===u)?s=ap(s,u):a[u]=l[u]}),t({_balances:a,_aggregatedBalances:s})},disconnectWallet:o=>{if(e().connectedWallets.find(r=>r.walletType===o)){he.emit("walletEvent",{type:"disconnect",payload:{walletType:o}}),e().removeBalancesForWallet(o);let r=e().connectedWallets.filter(s=>s.selected&&s.walletType===o).map(s=>s.chain),a=e().connectedWallets.filter(s=>s.walletType!==o);r.length>0&&(a=a.map(s=>r.includes(s.chain)?(r=r.filter(l=>l!==s.chain),{...s,selected:!0}):s)),t({connectedWallets:a})}},clearConnectedWallet:()=>t({connectedWallets:[]}),fetchBalances:async(o,n)=>{let r=o[0].walletType;e().setConnectedWalletAsRefetching(r);let a=o.map(c=>({address:c.address,blockchain:c.chain})),l=(await xt().getWalletsDetails(a)).wallets;if(l){let{retryOnFailedBalances:c=!0}=n||{};if(c){let d=l.filter(h=>h.failed).map(h=>({chain:h.blockChain,walletType:r,address:h.address}));d.length>0&&e().fetchBalances(d,{retryOnFailedBalances:!1})}let u={},p=e()._aggregatedBalances;l.forEach(d=>{if(d.failed||(e().removeBalancesForWallet(r,{chains:[d.blockChain]}),!e().connectedWallets.find(m=>m.walletType===r&&m.address===d.address&&m.chain===d.blockChain)))return;let h=rp(d,e);p=ip(p,h),u={...u,...h}}),t(d=>({_balances:{...d._balances,...u},_aggregatedBalances:p})),e().setConnectedWalletRetrievedData(r,l)}else throw e().setConnectedWalletHasError(r),new Error("We couldn't fetch your account balances. Seem there is no information on blockchain for them yet.")},getBalances:()=>e()._balances,getBalanceFor:o=>{let n=e().getBalances(),r=cn(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 u=n[c],p=new fa(u.amount),d=new fa(l.amount);p.isGreaterThan(d)&&(l=u)}),l},getBalancesForWalletAddress:o=>{let n=e().getBalances();return Object.keys(n).reduce((s,l)=>{let c=n[l],[,,,u]=l.split("-");return u===o&&(s[l]=c),s},{})},getConnectedWalletsDetails:()=>e().connectedWallets.map(n=>{let r=e().getBalancesForWalletAddress(n.address),a=Object.keys(r);return{...n,balances:a.reduce((s,l)=>{let c=r[l],u=pn(l);if(u.blockchain===n.chain){let p=e().findToken(u),d=c.amount?new fa(c.amount).shiftedBy(-c.decimals):ce;s.push({chain:n.chain,symbol:u.symbol,ticker:u.symbol,address:u.address,rawAmount:c.amount,decimal:c.decimals,amount:d.toString(),logo:p?.image||null,usdPrice:p?.usdPrice||null})}return s},[])}})}),"createWalletsSlice");function lp(t){return qy()(Hy((...e)=>({...sp(...e),...jc(...e),...op(...e),...fc(t,...e)}),{name:"user-settings",skipHydration:!0,partialize:e=>({_customTokens:e._customTokens,theme:e.theme,language:e.language,affiliatePercent:e.affiliatePercent,affiliateRef:e.affiliateRef,affiliateWallets:e.affiliateWallets,slippage:e.slippage,customSlippage:e.customSlippage,infiniteApprove:e.infiniteApprove,preferredBlockchains:e.preferredBlockchains,disabledLiquiditySources:e.disabledLiquiditySources})}))}i(lp,"createAppStore");var cp=Vy(null);function y(){let t=Ky(cp);if(jy(()=>{t&&!t.persist.hasHydrated()&&t.persist.rehydrate()},[]),!t)throw new Error("Missing AppStoreContext.Provider in the tree");return t()}i(y,"useAppStore");function pp(t){let e=Xy();return e.current||(e.current=lp(t.config)),Gy.createElement(cp.Provider,{value:e.current},t.children)}i(pp,"AppStoreProvider");function ft(t){let{chain:e}=t||{},{connectedWallets:o,getAvailableProviders:n}=y(),{state:r,getWalletInfo:a}=Yy(),s=y().blockchains(),{handleDisconnect:l}=Gt(),c=pc(n()),u=Mc(r,a,c,e);u=Zy()?u.filter(g=>g.showOnMobile!==!1&&r(g.type).installed):u;let p=Dc(u),d=i(g=>!o.find(C=>C.walletType===g&&C.chain===e),"isExperimentalChainNotAdded"),h=Ry(()=>{let g=u?.filter(C=>C.state===ga.CONNECTING)||[];for(let C of g)l(C.type)},[Oc(u)]);eS(()=>()=>{h()},[]);let m=i(g=>{let C=g.find(k=>k.type===un.DEFAULT);return!C||C.state===ga.NOT_INSTALLED?!1:g.filter(k=>k.state!=ga.NOT_INSTALLED&&![un.DEFAULT,un.WALLET_CONNECT_2,un.LEDGER].includes(k.type)&&a(k.type).supportedChains.filter(T=>T.type=="EVM").length>0).length==0},"shouldShowDefaultInjectedWallet"),f=i((g,C,S)=>fr(S,C)&&d(g)&&!Jy.includes(g)||g==un.DEFAULT&&!m(u),"shouldExcludeWallet");return{list:p.filter(g=>!f(g.type,e??"",s)),terminateConnectingWallets:h}}i(ft,"useWalletList");import{Modal as rS}from"@rango-dev/ui";import iS from"react";import{create as nS}from"zustand";var up="rango-widget";var dn=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(up),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 oS=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"),Bo=oS;var re=Bo(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})}}))),io=new dn({onInit:()=>re.setState({tabManagerInitiated:!0}),onClaim:()=>re.setState({isActiveTab:!0,showActivateTabModal:!1}),onRelease:()=>re.setState({isActiveTab:!1})});function J(t){let{watermark:e}=re();return iS.createElement(rS,{hasWatermark:e==="FULL",...t},t.children)}i(J,"WatermarkedModal");import{i18n as ha}from"@lingui/core";import{Button as uS,Checkbox as dS,Divider as mS,Image as Tp,ListItemButton as fS,MessageBox as gS,Radio as hS,RadioRoot as yS}from"@rango-dev/ui";import we,{useState as SS}from"react";import{css as aS,darkTheme as mp,IconButton as sS,styled as ao}from"@rango-dev/ui";var Et=ao(sS,{width:"$24",position:"relative",padding:"0",overflow:"unset","&:hover":{backgroundColor:"$secondary100",[`.${mp} &`]:{backgroundColor:"$neutral"}}}),fp=ao("div",{position:"absolute",background:"$secondary500",[`.${mp} &`]:{$$color:"$colors$secondary250"},width:"$6",height:"$6",borderRadius:"$lg",right:"$4",border:"1px solid $surface100"}),Vt=ao("div",{display:"flex",justifyContent:"flex-end",minWidth:"$40",button:{padding:0}}),gp=ao("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"}}}}),hp=ao("div",{padding:"$2",variants:{isRefetched:{true:{transform:"rotate(360deg)",transition:"transform 1s ease-in-out"}}}}),yp=ao("div",{position:"absolute",right:"$4",top:"$4",backgroundColor:"$background",borderRadius:"100%"}),Sp=aS({display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center"}),Cr=ao("div",{borderRadius:"100%",border:"1.5px transparent solid","&:not(:first-child)":{marginLeft:"-$6"},img:{borderRadius:"100%"}});import{keyframes as lS,styled as kr}from"@rango-dev/ui";var rN=kr("div",{borderRadius:"$lg",width:"$45",height:"$45",backgroundColor:"$success300",display:"flex",justifyContent:"center",alignItems:"center"}),Mo=kr("div",{position:"relative"}),cS=lS({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}),Lo=kr("div",{position:"absolute",border:"2px solid rgba(0, 0, 0, 0.1)",borderTop:"2px solid $info500",borderRadius:"$lg",width:"$45",height:"$45",animation:`${cS} 1s linear infinite`,top:0,bottom:0,right:0,left:0}),Tr=kr("div",{"& img":{borderRadius:"50%"}});function Cp(t,e){return t.find(o=>o.name===e)?.logo}i(Cp,"getBlockchainLogo");import{styled as pS}from"@rango-dev/ui";var kp=pS("ul",{padding:0,paddingTop:"$4",paddingBottom:"$4"});function mn(t){let{targetWallet:e}=t.value,o=e.needsNamespace?.selection==="single",n=e.image,[r,a]=SS([]),s=y().blockchains(),l=i(u=>{a(o?[u]:p=>p.includes(u)?p.filter(d=>d!==u):p.concat(u))},"onSelect"),c=i(u=>o?we.createElement(yS,{value:r?.[0]},u):we.createElement(we.Fragment,null,u),"wrapRadioRoot");return we.createElement(we.Fragment,null,we.createElement(mS,{size:20}),we.createElement(gS,{type:"info",title:ha.t("Select chain types"),description:ha.t("This wallet supports multiple chains. Select which chain you'd like to connect to."),icon:we.createElement(Mo,null,we.createElement(Cr,null,we.createElement(Tp,{src:n,size:45})),we.createElement(Lo,null))}),we.createElement(kp,null,c(we.createElement(we.Fragment,null,e.needsNamespace?.data.map(u=>we.createElement(fS,{key:u.id,id:u.id,title:u.label,hasDivider:!0,style:{height:60},onClick:()=>l(u.value),start:we.createElement(Tp,{src:Cp(s,u.id),size:22}),end:o?we.createElement(hS,{value:u.value}):we.createElement(dS,{checked:r.includes(u.value)})}))))),we.createElement(uS,{id:"widget-name-space-confirm-btn",type:"primary",disabled:!r.length,onClick:()=>t.onConfirm(r)},ha.t("Confirm")))}i(mn,"Namespaces");import{i18n as Po}from"@lingui/core";import{Button as TS,Divider as bp,Image as vS,MessageBox as wS,Select as bS,TextField as xS}from"@rango-dev/ui";import Oe,{useEffect as ES,useState as xp}from"react";import{namespaces as CS}from"@rango-dev/wallets-shared";var vr={id:"custom",label:"Custom",generateDerivationPath:t=>t};function ya(t){let e=t?CS[t].derivationPaths:null;return e?[...e,vr]:[]}i(ya,"getDerivationPaths");import{styled as vp,Typography as kS}from"@rango-dev/ui";var wp=vp("div",{paddingTop:"$30",paddingBottom:"$30",zIndex:10}),Sa=vp(kS,{paddingLeft:"$10"}),Ca={height:"$40",backgroundColor:"$neutral200",borderRadius:"$sm"};var Ep="0";function fn(t){let{onConfirm:e}=t,{namespace:o,providerImage:n,providerType:r}=t.value,[a,s]=xp(null),[l,c]=xp(Ep),u=a===vr.id,p=ya(o),d=i(({value:m})=>{let f=p?.find(g=>g.id===m);f&&(a===vr.id&&Number.isNaN(Number(l))&&c(Ep),s(f.id))},"handleDerivationPathItemClick"),h=i(()=>{let m=p.find(f=>f.id===a);if(m)e(m.generateDerivationPath(l));else throw new Error("selectedDerivationPath can not be undefined")},"handleConfirm");return ES(()=>{s(ya(o)[0]?.id||null)},[o]),Oe.createElement(Oe.Fragment,null,Oe.createElement(bp,{size:20}),Oe.createElement(wS,{type:"info",title:Po.t("Select Derivation Path"),description:Po.t({id:"In order to connect to {type}, you must first select a Derivation Path",values:{type:r}}),icon:Oe.createElement(Mo,null,Oe.createElement(Tr,null,Oe.createElement(vS,{src:n,size:45})),Oe.createElement(Lo,null))}),Oe.createElement(wp,null,Oe.createElement(Sa,{variant:"body",size:"xsmall",color:"$neutral600"},Po.t("Choose Derivation Path Template")),Oe.createElement(bS,{value:a||"",options:p.map(m=>({value:m.id,label:m.label})),variant:"filled",handleItemClick:d,styles:{trigger:Ca}}),Oe.createElement(bp,{size:20}),Oe.createElement(Sa,{variant:"body",size:"xsmall",color:"$neutral600"},u?Po.t("Enter Path"):Po.t("Enter Index")),Oe.createElement(xS,{type:u?"text":"number",variant:"contained",value:l,onChange:m=>c(m.target.value),style:Ca})),Oe.createElement(TS,{id:"widget-derivation-path-confirm-btn",type:"primary",onClick:h,disabled:!p||!a||!l},Po.t("Confirm")))}i(fn,"DerivationPath");import{i18n as _o}from"@lingui/core";import{Image as IS,MessageBox as ka,WalletState as AS}from"@rango-dev/ui";import{useWallets as NS}from"@rango-dev/wallets-react";import so from"react";function Ta(t){let{wallet:e,error:o}=t,{type:n,image:r}=e,{state:a}=NS();return ln(a(n))===AS.CONNECTED?so.createElement(ka,{type:"success",title:_o.t("Wallet Connected"),description:_o.t("Your wallet is connected, you can use it to swap.")}):o?so.createElement(ka,{type:"error",title:_o.t("Failed to Connect"),description:o||_o.t("Your wallet is not connected. Please try again.")}):so.createElement(ka,{type:"loading",title:_o.t("Connecting to your wallet"),description:_o.t("Click connect in your wallet popup."),icon:so.createElement(Mo,null,so.createElement(Tr,null,so.createElement(IS,{src:r,size:45})),so.createElement(Lo,null))})}i(Ta,"ConnectStatus");import{i18n as va}from"@lingui/core";import{Button as WS,Divider as Ip,MessageBox as BS}from"@rango-dev/ui";import wr from"react";function wa(t){let{displayName:e,onConfirm:o}=t;return wr.createElement(BS,{title:va.t({id:"Add {blockchainDisplayName} Chain",values:{blockchainDisplayName:e}}),type:"warning",description:va.t({id:"Would you like to add the {blockchainDisplayName} experimental chain to your wallet?",values:{blockchainDisplayName:e}})},wr.createElement(Ip,{size:18}),wr.createElement(Ip,{size:32}),wr.createElement(WS,{id:"widget-experimental-chain-confirm-btn",onClick:o,variant:"outlined",type:"primary",fullWidth:!0,size:"large"},va.t("Confirm")))}i(wa,"ExperimentalChain");function Ap(t,e){return t().status==="init"&&!!e}i(Ap,"isOnStatus");function gn(t){return t().status==="namespace"}i(gn,"isOnNamespace");function hn(t){return t().status==="derivationPath"}i(hn,"isOnDerivationPath");var _S=3e3,DS=300;function co(t){let e=PS(),[o,n]=Np(!1),[r,a]=Np(),s=i(k=>{a(k.message)},"catchErrorOnHandle"),{terminateConnectingWallets:l}=ft(),{handleConnect:c,handleDerivationPath:u,handleNamespace:p,getState:d,resetState:h}=Gt(),m=i(k=>{p(t.wallet,k).then(S).catch(s)},"handleConfirmNamespaces"),f=i(k=>{if(!k)throw new Error("Derivation path is empty. Please make sure you've filled the field correctly.");u(k).then(S).catch(s)},"handleDerivationPathConfirm"),g=i(()=>{n(!1)},"handleClosingModal"),C=i(()=>{a(void 0),h(),n(!1),e.current&&clearTimeout(e.current)},"resetModalState"),S=i((k,T)=>{let v=k.status==="connected",w=["disconnected","disconnected-unhandled"].includes(k.status);v?(t.onConnect?.(),T||(e.current=setTimeout(g,_S))):w&&g()},"afterConnected");return LS(()=>{if(t.wallet){C();let k=!1,T=!0;i(()=>{setTimeout(()=>{T=!1,k||n(!0)},DS)},"beforeConnecting")(),c(t.wallet,{disconnectIfConnected:!0}).then(w=>{["namespace","derivation-path"].includes(w.status)||(k=!0),S(w,T)}).catch(s)}},[t.wallet]),lo.createElement(J,{open:o,onClose:g,onExit:()=>{C(),l(),t.onClose&&t.onClose()},container:N()},Ap(d,t.wallet)&&lo.createElement(lo.Fragment,null,lo.createElement(Ta,{wallet:{type:t.wallet.type,image:t.wallet.image},error:r}),lo.createElement(MS,{direction:"vertical",size:32})),gn(d)&&lo.createElement(mn,{onConfirm:m,value:d().namespace}),hn(d)&&lo.createElement(fn,{onConfirm:f,value:d().derivationPath}))}i(co,"StatefulConnectModal");import{legacyFormatAddressWithNetwork as FS,legacyReadAccountAddress as Bp}from"@rango-dev/wallets-core/legacy";import{Events as yn,Provider as OS}from"@rango-dev/wallets-react";import{isEvmBlockchain as US}from"rango-sdk";import br,{createContext as zS,useEffect as Mp,useMemo as QS,useRef as Lp}from"react";import{useEffect as $S}from"react";function Wp(t){return t.map(e=>typeof e=="string"?e:e.config.type).join("-")}i(Wp,"hashProviders");function ba(t,e){let{clearConnectedWallet:o,getAvailableProviders:n,buildAndSetProviders:r}=y(),a=n();return $S(()=>{o(),r()},[Wp(t??[]),e?.walletConnectProjectId,e?.walletConnectListedDesktopWalletLink]),{providers:a}}i(ba,"useWalletProviders");var xr=zS({onConnectWallet:()=>{},onDisconnectWallet:()=>{}});function qS(t){let{updateConfig:e,updateSettings:o,fetch:n,fetchStatus:r,removeBalancesForWallet:a}=y(),s=y().blockchains(),{newWalletConnected:l,disconnectWallet:c,connectedWallets:u}=y(),p=y().config,d={walletConnectProjectId:p?.walletConnectProjectId,trezorManifest:p?.trezorManifest,tonConnect:p.tonConnect,walletConnectListedDesktopWalletLink:t.config.__UNSTABLE_OR_INTERNAL__?.walletConnectListedDesktopWalletLink},{providers:h}=ba(p.wallets,d),m=Lp(),f=Lp();Mp(()=>{n().catch(console.log)},[]),Mp(()=>{t.config&&(e(t.config),o(t.config),window.__rango={config:p,dappConfig:t.config})},[t.config,r]);let g=s.filter(US).map(T=>T.name),C=i((T,v,w,A,M)=>{if(v===yn.NAMESPACE_DISCONNECTED&&a(T,{namespaces:w}),v===yn.ACCOUNTS){let b=mr(M.supportedBlockchains);if(!M.isHub){let I=[],W=[];if(w?.forEach(U=>{let{network:j}=Bp(U);g.includes(j)?I.push(U):W.push(U)}),u.filter(U=>U.walletType===T).map(U=>FS(U.address,U.chain)).length>0){if(I.length>0){let U=ra(T,I,g,b,M.isContractWallet);a(T,{chains:U.map(j=>j.chain)})}W.length>0&&a(T,{chains:W.map(U=>{let{network:j}=Bp(U);return j})})}}if(w){let I=ra(T,w,g,b,M.isContractWallet);I.length&&l(I,M.namespace)}else c(T),f.current?f.current(T):console.warn("onDisconnectWallet handler hasn't been set. Are you sure?")}let x=v===yn.ACCOUNTS&&A.connected,E=v===yn.CONNECTED&&M.isHub;if(x||E){let b=`${T}-${A.network}-${w}`;m.current?m.current(b):console.warn("onConnectWallet handler hasn't been set. Are you sure?")}if(v===yn.NETWORK&&A.network){let b=`${T}-${A.network}`;m.current?m.current(b):console.warn("onConnectWallet handler hasn't been set. Are you sure?")}t.onUpdateState&&t.onUpdateState(T,v,w,A,M)},"onUpdateState"),S=re.use.isActiveTab(),k=QS(()=>({onConnectWallet:T=>{m.current=T},onDisconnectWallet:T=>{f.current=T}}),[]);return br.createElement(xr.Provider,{value:k},br.createElement(OS,{allBlockChains:s,providers:h,onUpdateState:C,autoConnect:!!S,configs:{wallets:p.wallets}},t.children))}i(qS,"Main");function Er(t){let{config:e,...o}=t;return br.createElement(pp,{config:e},br.createElement(qS,{...o,config:e}))}i(Er,"WidgetWallets");import Xi from"react";import HS,{Fragment as GS}from"react";import{MemoryRouter as VS,useInRouterContext as KS}from"react-router";function Pp({children:t}){let o=KS()?GS:VS;return HS.createElement(o,null,t)}i(Pp,"AppRouter");import{I18nManager as AE}from"@rango-dev/ui";import Jl from"react";import _e from"react";import{useRoutes as fE}from"react-router-dom";var $={home:"/",fromSwap:"from-swap",toSwap:"to-swap",blockchains:"blockchains",settings:"settings",customTokens:"custom-tokens",addCustomTokens:"add-custom-tokens",liquiditySources:"liquidity-sources",bridges:"bridges",exchanges:"exchanges",languages:"languages",swaps:"swaps",wallets:"wallets",confirmSwap:"confirm-swap",swapDetails:":requestId",routes:"routes"};import{useEffect as $o,useRef as _r}from"react";import Ke from"bignumber.js";import{create as YS}from"zustand";import{subscribeWithSelector as ZS}from"zustand/middleware";import{i18n as gt}from"@lingui/core";import{RouteEventType as pB}from"@rango-dev/queue-manager-rango-preset";import Ue from"bignumber.js";import{PendingSwapNetworkStatus as Lr}from"rango-types";import{i18n as $e}from"@lingui/core";var ee=i(()=>({genericServerError:$e.t("Failed Network, Please retry your swap."),liquiditySourcesError:{title:$e.t("Please reset your liquidity sources."),description:$e.t("You have limited the liquidity sources and this might result in Rango finding no routes. Please consider resetting your liquidity sources.")},noResultError:{title:$e.t("No Routes Found."),description:$e.t("Reasons why Rango couldn't find a route: low liquidity on token, very low input amount or no routes available for the selected input/output token combination.")},bridgeLimitErrors:{increaseAmount:$e.t("Bridge Limit Error: Please increase your amount."),decreaseAmount:$e.t("Bridge Limit Error: Please decrease your amount.")},highValueLossError:{impactTitle:$e.t("High Price Impact"),title:$e.t("Price impact is too high!"),description:$e.t("The price impact is significantly higher than the allowed amount."),confirmMessage:$e.t("Confirm high price impact")},quoteUpdatedWithHighValueLoss:{title:$e.t("Route updated and price impact is too high, try again later!")},unknownPriceError:{impactTitle:$e.t("USD Price Unknown"),title:$e.t("USD Price Unknown, Cannot calculate Price Impact."),description:$e.t("USD Price Unknown, Cannot calculate Price Impact. The price impact may be higher than usual. Are you sure to continue the Swap?"),confirmMessage:$e.t("Confirm USD Price Unknown")}}),"errorMessages");function _p(t){switch(t.type){case 0:return t.diagnosisMessage??ee().noResultError.title;case 1:return ee().genericServerError;default:return""}}i(_p,"getQuoteErrorMessage");import{i18n as Ir}from"@lingui/core";var po=i(()=>({connectWallet:Ir.t("Connect Wallet"),swap:Ir.t("Swap"),swapAnyway:Ir.t("Swap anyway"),ethWarning:Ir.t("The route goes through Ethereum. Continue?")}),"swapButtonTitles");function xa(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(xa,"getFeeLabel");var Ea=["RECOMMENDED","CENTRALIZED","LOWEST_FEE","FASTEST","HIGH_IMPACT"],Dp=100,$p=30,Fp=15,Op=60;var Up=[{threshold:-10,minInput:400},{threshold:-5,minInput:1e3}],zp=[{threshold:-1,minInput:1e3},{threshold:-2,minInput:500}];import{getLastSuccessfulStep as XS}from"@rango-dev/queue-manager-rango-preset";import YW from"bignumber.js";function qp(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(qp,"getRequiredBalanceOfWallet");function _t(t){let e;return t<=-3&&t>-10?e="low":t<=-10&&(e="high"),e}i(_t,"getPriceImpactLevel");function Nr(t,e,o){let n=t.steps[0],r=t.steps[t.steps.length-1],a=XS(t.steps),s={blockchain:r.toBlockchain,symbol:r.toSymbol,address:r.toSymbolAddress},l=nn(a?a.toBlockchain:n.fromBlockchain,e),c=nn(r.toBlockchain,e),u=o(a?{blockchain:l?.name??"",symbol:a.toSymbol,address:a.toSymbolAddress}:{blockchain:l?.name??"",symbol:n.fromSymbol,address:n.fromSymbolAddress}),p=o(s),d=a?a.outputAmount??"":t.inputAmount;return{fromBlockchain:l,fromToken:u,toBlockchain:c,toToken:p,inputAmount:d}}i(Nr,"createRetryQuote");function Do(t){let{previousQuote:e,currentQuote:o,findToken:n,userSlippage:r}=t,a=Sn(o),s=ct(o);if(o&&a&&s){let u=Pt(a.toString(),s.toString());if(!!u&&jp(a,u)){let d=Br(o?.swaps,n),h=_t(u);return{type:0,inputUsdValue:a,outputUsdValue:s,priceImpact:u,totalFee:d,warningLevel:h}}}if(e&&Zp(e,o))return{type:4,usdValueChange:L(ct(o)?.minus(ct(e)??0).toString()??"0",null,2),percentageChange:L(Pt(ct(e)??"1",ct(o)??"1"),null,2)};if(o&&(!a||!s))return{type:1};let l=Mr(o.swaps),c=r>Rc;if(Yp(t.userSlippage.toString(),l)){if(c&&parseFloat(l??"0")<r)return{type:3,slippage:r.toString()}}else return{type:2,recommendedSlippages:Xp(o,r),minRequiredSlippage:l};return null}i(Do,"generateQuoteWarnings");function Hp(t){return![4].includes(t.type)}i(Hp,"isQuoteWarningConfirmationRequired");function Pt(t,e){let o=typeof e=="string"?parseFloat(e)<=0:!e?.gt(0),n=!t||!e||o?null:Ia(t.toString(),e.toString());return n&&n<0?n:null}i(Pt,"getPriceImpact");var Gp=i(t=>{let e=new Set,o=[];return t.forEach(n=>{e.has(n.from.chain.displayName)||(e.add(n.from.chain.displayName),o.push(n.from.chain)),e.has(n.to.chain.displayName)||(e.add(n.to.chain.displayName),o.push(n.to.chain))}),o},"getUniqueBlockchains"),Wr=i((t,e)=>e.sort((o,n)=>{let r=i(u=>u.scores?.find(p=>p.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"),Vp=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"),Kp=i(t=>{let e=i((o,n)=>{let r=Ea.indexOf(o.value),a=Ea.indexOf(n.value);return r!==-1&&a!==-1?r-a:r!==-1?-1:a!==-1?1:0},"customSort");return t.sort(e)},"sortTags");function jp(t,e){if(!t)return!1;let o=parseInt(e.toFixed(2)||"0");return Up.some(({threshold:n,minInput:r})=>o<=n&&t.gte(new Ue(r)))}i(jp,"hasHighValueLoss");function Jp(t){return(t||[]).filter(e=>{let o=e.fromAmountMinValue?new Ue(e.fromAmountMinValue):null,n=e.fromAmountMaxValue?new Ue(e.fromAmountMaxValue):null;return e.fromAmountRestrictionType==="EXCLUSIVE"?o?.gte(e.fromAmount)||n?.lte(e.fromAmount):o?.gt(e.fromAmount)||n?.lt(e.fromAmount)}).length>0}i(Jp,"hasLimitError");function Rp(t){let e=(t||[]).filter(l=>{let c=l.fromAmountMinValue?new Ue(l.fromAmountMinValue):null,u=l.fromAmountMaxValue?new Ue(l.fromAmountMaxValue):null;return l.fromAmountRestrictionType==="EXCLUSIVE"?c?.gte(l.fromAmount)||u?.lte(l.fromAmount):c?.gt(l.fromAmount)||u?.lt(l.fromAmount)})[0],o=e.fromAmountMinValue?new Ue(e.fromAmountMinValue):null,n=e.fromAmountMaxValue?new Ue(e.fromAmountMaxValue):null,r=e.fromAmountRestrictionType==="EXCLUSIVE",a="",s="";return!r&&o&&o.gt(e.fromAmount)?(a=gt.t({id:"Required: >= {min} {symbol}",values:{min:L(o,6,6),symbol:e.from.symbol}}),s=ee().bridgeLimitErrors.increaseAmount):r&&o&&o.gte(e.fromAmount)&&(a=gt.t({id:"Required: > {min} {symbol}",values:{min:L(o,6,6),symbol:e.from.symbol}}),s=ee().bridgeLimitErrors.increaseAmount),!r&&n&&n.lt(e.fromAmount)?(a=gt.t({id:"Required: <= {max} {symbol}",values:{max:L(n,6,6),symbol:e.from.symbol}}),s=ee().bridgeLimitErrors.decreaseAmount):r&&n&&n.lte(e.fromAmount)&&(a=gt.t({id:"Required: < {max} {symbol}",values:{max:L(n,6,6),symbol:e.from.symbol}}),s=ee().bridgeLimitErrors.decreaseAmount),{swap:e,fromAmountRangeError:a,recommendation:s}}i(Rp,"getLimitErrorMessage");function eu(t){let{fetchMetaStatus:e,anyWalletConnected:o,fetchingQuote:n,inputAmount:r,quote:a,warning:s,error:l,needsToWarnEthOnPath:c}=t;return e!=="success"?{title:po().connectWallet,action:"connect-wallet",disabled:!0}:o?n||!a||l||!r||r==="0"?{title:po().swap,action:"confirm-swap",disabled:!0}:s?{title:po().swapAnyway,action:"confirm-warning",disabled:!1}:c?{title:po().ethWarning,action:"confirm-warning",disabled:!1}:{title:po().swap,action:"confirm-swap",disabled:!1}:{title:po().connectWallet,action:"connect-wallet",disabled:!1}}i(eu,"getSwapButtonState");function Aa(t,e,o){let n=parseFloat(e||"0");return!(t&&(!o||o.lte(ce))&&e&&e!=="0"&&n!==0)}i(Aa,"canComputePriceImpact");function Na(t,e){let o=ce;for(let n=0;n<t.fee.length;n++){let r=t.fee[n];if(r.expenseType==="DECREASE_FROM_OUTPUT")continue;let a=e(r.asset)?.usdPrice||null;o=o.plus(new Ue(r.amount).multipliedBy(a||0))}return o}i(Na,"getUsdFeeOfStep");function Br(t,e){return t.reduce((o,n)=>o.plus(Na(n,e)),ce)}i(Br,"getTotalFeeInUsd");function Wa(t){let e=ce;return e=e.plus(new Ue(t.amount).multipliedBy(t.price||0)),e}i(Wa,"getUsdFee");function tu(t){return t.reduce((e,o)=>e.plus(Wa(o)),ce)}i(tu,"getTotalFeesInUsd");function ou(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(ou,"getFeesGroup");function nu(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(nu,"checkSlippageErrors");function Xp(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(Xp,"checkSlippageWarnings");function Mr(t){return t.map(o=>o.recommendedSlippage)?.map(o=>o?.slippage||"0")?.filter(o=>parseFloat(o)>0)?.sort((o,n)=>parseFloat(n)-parseFloat(o))?.find(()=>!0)||null}i(Mr,"getMinRequiredSlippage");function Yp(t,e){return e?parseFloat(t)>=parseFloat(e):!0}i(Yp,"hasProperSlippage");function ru(t){let{fromToken:e,toToken:o,inputAmount:n,wallets:r,selectedWallets:a,disabledLiquiditySources:s,liquiditySources:l,excludeLiquiditySources:c,slippage:u,affiliateRef:p,affiliatePercent:d,affiliateWallets:h,destination:m}=t,f=a?.reduce((S,k)=>(S[k.chain]=k.address,S),{}),g=[];return r?.forEach(S=>{g.push({blockchain:S.chain,addresses:[S.address]})}),{amount:n.toString(),affiliateRef:p??void 0,affiliatePercent:d??void 0,affiliateWallets:h??void 0,from:{address:e.address,blockchain:e.blockchain,symbol:e.symbol},to:{address:o.address,blockchain:o.blockchain,symbol:o.symbol},connectedWallets:g,selectedWallets:f??{},slippage:u.toString(),...m&&{destination:m},...c&&{swapperGroups:s.concat(l??[]),swappersGroupsExclude:!0},...!c&&{swapperGroups:l?.filter(S=>!s.includes(S)),swappersGroupsExclude:!1}}}i(ru,"createQuoteRequestBody");function iu(t){return t.reduce((o,n)=>(o[n.chain]={address:n.address,walletType:n.walletType},o),{})}i(iu,"getWalletsForNewSwap");function Sn(t){let e=t.requestAmount,o=t.swaps[0].from.usdPrice;if(!(!e||!o))return new Ue(e).multipliedBy(o)}i(Sn,"getUsdInputFrom");function ct(t){let e=t?.outputAmount||null,o=t.swaps[t.swaps.length-1].to.usdPrice;if(!(!e||!o))return new Ue(e).multipliedBy(o)}i(ct,"getUsdOutputFrom");function Ia(t,e){return new Ue(e).div(new Ue(t)).minus(1).multipliedBy(Dp).toNumber()}i(Ia,"getPercentageChange");function Zp(t,e){let o=Sn(t),n=ct(t),r=ct(e);if(!o||!n||!r)return!1;let a=Ia(n.toString(),r.toString());return zp.some(({threshold:s,minInput:l})=>a<=s&&o.isGreaterThanOrEqualTo(l))}i(Zp,"isOutputAmountChangedExcessively");function au(t,e,o){let n=t.validationStatus,r=ro({filter:"required",quote:t});return e.sort((s,l)=>r.indexOf(s.chain)-r.indexOf(l.chain)).flatMap(s=>qp(s,n)||[]).filter(s=>!s.ok).map(s=>{let l=s.asset.symbol,c=L(new Ue(s.currentAmount.amount).shiftedBy(-s.currentAmount.decimals),8,8),u=L(new Ue(s.requiredAmount.amount).shiftedBy(-s.requiredAmount.decimals),8,8),p="";return s.reason==="FEE"&&(p=gt.t(" for network fee")),s.reason==="INPUT_ASSET"&&(p=gt.t(" for swap")),s.reason==="FEE_AND_INPUT_ASSET"&&(p=gt.t(" for input and network fee")),gt.t({id:"Needs \u2248 {requiredAmount} {symbol}{reason}, but you have {currentAmount} {symbol} in your {blockchain} wallet.",values:{requiredAmount:u,symbol:l,reason:p,currentAmount:c,blockchain:st(s.asset.blockchain,o)}})})}i(au,"generateBalanceWarnings");function Cn(t){return!!t&&t.networkStatus!==null&&t.networkStatus!==Lr.NetworkChanged}i(Cn,"isNetworkStatusInWarningState");function su(t,e){let o="bellow button or",n=t.extraMessage,r=t.extraMessageDetail;if(t.networkStatusExtraMessageDetail?.includes(o)&&(t.networkStatusExtraMessageDetail=t.networkStatusExtraMessageDetail.replace(o,"")),Cn(e))switch(n=t.networkStatusExtraMessage||"",r=t.networkStatusExtraMessageDetail||"",e?.networkStatus){case Lr.WaitingForConnectingWallet:n=n||gt.t("Waiting for connecting wallet");break;case Lr.WaitingForQueue:n=n||gt.t("Waiting for other running tasks to be finished");break;case Lr.WaitingForNetworkChange:n=n||gt.t("Waiting for changing wallet network");break;default:n=n||"";break}r=r||"",n=n||"";let s=n?.indexOf("code")!==-1&&n?.indexOf("reason")!==-1;return{shortMessage:n,detailedMessage:{content:r,long:s}}}i(su,"getSwapMessages");function lu(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(lu,"getLastConvertedTokenInFailedSwap");function cu(t){return t.status==="failed"}i(cu,"shouldRetrySwap");function pu(t,e,o,n,r,a){if(!n||t)return!0;let s=ro({filter:"all",quote:n}),l=ro({filter:"required",quote:n}),c=s.every(d=>r.some(h=>h.chain===d)),u=l.every(d=>r.some(h=>h.chain===d)),p=o&&a?xo(a,o):!1;return!e&&!c||e&&!o||e&&!!o&&(!p||!u)}i(pu,"isConfirmSwapDisabled");function uu(t,e){return t.blockchain===e.blockchain&&t.symbol===e.symbol&&t.address===e.address}i(uu,"isTokensIdentical");var Pr=i((t,e)=>t?.usdPrice?new Ke(e||ce).multipliedBy(t?.usdPrice||0):null,"getUsdValue"),O=Bo(YS()(ZS(t=>({fromBlockchain:null,fromToken:null,inputAmount:"",outputAmount:null,inputUsdValue:new Ke(0),outputUsdValue:new Ke(0),toBlockchain:null,toToken:null,refetchQuote:!0,sortStrategy:"SMART",selectedQuote:null,quotes:null,error:null,warning:null,quoteWalletsConfirmed:!1,selectedWallets:[],customDestination:null,quoteWarningsConfirmed:!1,updateQuotePartialState:(e,o)=>t(n=>({...n,[e]:o})),setSelectedQuote:e=>t(o=>{let n=null,r=ce,a=o.inputUsdValue;return sn(o.inputAmount)?(e&&(n=e?.outputAmount?new Ke(e?.outputAmount):null,a=Sn(e)??ce,r=ct(e)??ce),{selectedQuote:e,...!!e&&{outputAmount:n,outputUsdValue:r,inputUsdValue:a}}):{}}),resetAlerts:()=>t(()=>({error:null,warning:null})),resetQuote:()=>t(()=>({selectedQuote:null,outputAmount:null,outputUsdValue:new Ke(0),quotes:null,refetchQuote:!0,error:null,warning:null})),setFromBlockchain:e=>{t(o=>o.fromBlockchain?.name===e?.name?{}:{fromBlockchain:e,inputUsdValue:new Ke(0),...o.fromToken&&{selectedQuote:null,fromToken:null,outputAmount:null,outputUsdValue:new Ke(0)}})},setFromToken:e=>t(o=>({fromToken:e.token,...e.token&&{fromBlockchain:e.meta.blockchains.find(n=>n.name===e.token.blockchain)??null},...!!o.inputAmount&&{inputUsdValue:Pr(e.token,o.inputAmount)}})),setToBlockchain:e=>{t(o=>o.toBlockchain?.name===e?.name?{}:{toBlockchain:e,...o.toToken&&{selectedQuote:null,toToken:null,outputAmount:null,outputUsdValue:new Ke(0)}})},setToToken:e=>t(()=>({toToken:e.token,...e.token&&{toBlockchain:e.meta.blockchains.find(o=>o.name===e.token.blockchain)??null}})),setInputAmount:e=>{t(o=>({inputAmount:e,...!e&&{outputAmount:null,outputUsdValue:new Ke(0),selectedQuote:null},...!!o.fromToken&&{inputUsdValue:Pr(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:Pr(n??null,s),outputUsdValue:new Ke(0),toBlockchain:r,toToken:a,selectedQuote:null})},switchFromAndTo:()=>t(e=>({fromBlockchain:e.toBlockchain,fromToken:e.toToken,toBlockchain:e.fromBlockchain,toToken:e.fromToken,inputAmount:e.outputAmount?.toString()||"",inputUsdValue:e.toToken?Pr(e.toToken,e.outputAmount?.toString()||""):new Ke(0)})),resetFromBlockchain:()=>t(()=>({fromToken:null,fromBlockchain:null,outputUsdValue:new Ke(0),inputUsdValue:new Ke(0),inputAmount:"",outputAmount:null,selectedQuote:null})),resetToBlockchain:()=>t(()=>({toToken:null,toBlockchain:null,outputAmount:null,outputUsdValue:new Ke(0),selectedQuote:null})),setQuoteWalletConfirmed:e=>t({quoteWalletsConfirmed:e}),setSelectedWallets:e=>t({selectedWallets:e}),setCustomDestination:e=>t({customDestination:e}),resetQuoteWallets:()=>t({quoteWalletsConfirmed:!1,selectedWallets:[],customDestination:null}),setQuoteWarningsConfirmed:e=>t({quoteWarningsConfirmed:e})})))),du=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 mu(){let{setInputAmount:t,setToToken:e,setToBlockchain:o,setFromBlockchain:n,resetQuote:r,setFromToken:a,fromToken:s,toToken:l,fromBlockchain:c,toBlockchain:u}=O(),p=y().config,d=y().fetchStatus,h=y().blockchains(),m=y().tokens(),{findToken:f}=y(),{setAffiliateRef:g,setAffiliatePercent:C,setAffiliateWallets:S}=y(),k=p?.from?.tokens,T=p?.from?.blockchains,v=p?.to?.tokens,w=p?.to?.blockchains,A=_r(void 0),M=_r(void 0),x=_r(void 0),E=_r(void 0);$o(()=>{typeof p.amount<"u"&&t(p.amount.toString())},[p?.amount]),$o(()=>{if(d==="success"){r();let b=h.find(B=>B.name===p?.from?.blockchain),I=p?.from?.token,W=I&&f(I);(b||!b&&x.current)&&n(b??null),W?a({token:W,meta:{blockchains:h,tokens:m}}):!W&&A.current&&a({token:null}),x.current=p?.from?.blockchain,A.current=p?.from?.token}},[p?.from?.token?.symbol,p?.from?.token?.address,p?.from?.token?.blockchain,p?.from?.blockchain,d]),$o(()=>{sa(s,k)&&a({token:null}),la(c,T)&&n(null)},[k,T]),$o(()=>{sa(l,v)&&a({token:null}),la(u,w)&&o(null)},[v,w]),$o(()=>{if(d==="success"){r();let b=h.find(B=>B.name===p?.to?.blockchain),I=p?.to?.token,W=I&&f(I);(b||!b&&E.current)&&o(b??null),W?e({token:W,meta:{blockchains:h,tokens:m}}):!W&&M.current&&e({token:null}),E.current=p?.to?.blockchain,M.current=p?.to?.token}},[p?.to?.token?.symbol,p?.to?.token?.address,p?.to?.token?.blockchain,p?.to?.blockchain,d]),$o(()=>{g(p?.affiliate?.ref??null),C(p?.affiliate?.percent??null),S(p?.affiliate?.wallets??null)},[p?.affiliate?.ref,p?.affiliate?.percent,p?.affiliate?.wallets])}i(mu,"useSyncStoresWithConfig");import{useEffect as La,useRef as JS}from"react";import{useInRouterContext as RS,useLocation as eC,useSearchParams as tC}from"react-router-dom";function Ba(t,e){let o=t.split("--");return{blockchain:e.name,address:o?.[1]||null,symbol:o[0]}}i(Ba,"convertTokenSearchParamToAsset");function Ma(t){if(t)return`${t.symbol}${t.address?`--${t.address}`:""}`}i(Ma,"tokenToSearchParam");function _a(){let t=eC(),[e,o]=tC(),{fromBlockchain:n,toBlockchain:r,fromToken:a,toToken:s,inputAmount:l,setFromBlockchain:c,setToBlockchain:u,setFromToken:p,setToToken:d,setInputAmount:h}=O(),m=y().fetchStatus,f=y().blockchains(),g=y().tokens(),C=RS(),{updateIframe:S,updateCampaignMode:k}=y(),T=y().isInCampaignMode(),v=JS(),{findToken:w}=y(),A=i(()=>{let x={};for(let[Y,se]of e.entries())Y.startsWith("utm_")&&(x[Y]=se);let E=e.get("fromAmount"),b=e.get("fromBlockchain"),I=e.get("fromToken"),W=e.get("toBlockchain"),B=e.get("toToken"),U=e.get("autoConnect"),j=e.get("clientUrl"),R=e.get("liquiditySources"),P=e.get("blockchain");return{fromAmount:E,fromBlockchain:b,fromToken:I,toBlockchain:W,toToken:B,autoConnect:U,clientUrl:j,liquiditySources:R,utmQueryParams:x,blockchain:P}},"getUrlSearchParams"),M=i(x=>{for(let E in x)x[E]||delete x[E];o(x,{replace:!0})},"updateUrlSearchParams");La(()=>{let{autoConnect:x,clientUrl:E,utmQueryParams:b,blockchain:I}=A();C&&m==="success"&&M({fromBlockchain:n?.name,fromToken:Ma(a),toBlockchain:r?.name,toToken:Ma(s),fromAmount:l,autoConnect:x??void 0,clientUrl:E??void 0,blockchain:I??void 0,liquiditySources:T?v.current:void 0,...b})},[t.pathname,l,n,a,r,s,T]),La(()=>{if(!C)return;let x=A();if(!v.current&&x.liquiditySources&&(v.current=x.liquiditySources),x.fromAmount&&h(x.fromAmount),m==="success"){let E=f.find(B=>B.name===x.fromBlockchain),b=x.fromToken&&E?w(Ba(x.fromToken,E)):void 0,I=f.find(B=>B.name===x.toBlockchain),W=x.toToken&&I?w(Ba(x.toToken,I)):void 0;E&&(c(E),b&&p({token:b,meta:{blockchains:f,tokens:g}})),I&&(u(I),W&&d({token:W,meta:{blockchains:f,tokens:g}}))}},[m]),La(()=>{let{clientUrl:x,liquiditySources:E}=A();S("clientUrl",x||void 0),k("liquiditySources",E?.split(",")??void 0)},[])}i(_a,"useSyncUrlAndStore");import{i18n as It}from"@lingui/core";import{Alert as gk,Button as Ku,darkTheme as hk,Divider as vn,DoneIcon as yk,MessageBox as Sk,styled as Ck,TextField as kk,Typography as Tk}from"@rango-dev/ui";import ye,{useEffect as vk,useState as Qr}from"react";import{useNavigate as wk,useSearchParams as bk}from"react-router-dom";import{ChevronRightIcon as oC,Divider as Su,Image as nC,Typography as Cu}from"@rango-dev/ui";import ht from"react";import{darkTheme as fu,styled as Da}from"@rango-dev/ui";var gu=Da("div",{display:"flex",justifyContent:"space-between",width:"100%",height:"$40",padding:"$4 $10",borderRadius:"$sm",cursor:"pointer",alignItems:"center",backgroundColor:"$neutral300",[`.${fu} &`]:{backgroundColor:"$neutral400"},"&:hover":{backgroundColor:"$secondary100",[`.${fu} &`]:{backgroundColor:"$neutral500"}},variants:{disabled:{true:{cursor:"default","&:hover":{borderColor:"$neutral300","& svg":{color:"$neutral700"}}}}}}),hu=Da("div",{display:"flex",flexDirection:"column",width:"100%",".title_typography":{textTransform:"capitalize"}}),yu=Da("div",{display:"flex"});function $a(t){let{onClick:e,value:o,title:n,hasLogo:r,placeholder:a,disabled:s}=t;return ht.createElement(hu,null,ht.createElement(Cu,{size:"large",variant:"label"},n),ht.createElement(Su,{size:10}),ht.createElement(gu,{onClick:s?void 0:e,disabled:s},ht.createElement(yu,null,r&&ht.createElement(ht.Fragment,null,ht.createElement(nC,{src:o?.logo,size:16,useAsPlaceholder:!o?.logo,type:"circular"}),ht.createElement(Su,{size:4,direction:"horizontal"})),ht.createElement(Cu,{className:"title_typography",size:"medium",variant:"label"},o?.name||a)),ht.createElement(oC,{size:12,color:"black"})))}i($a,"BlockchainSelectorButton");import{i18n as Oa}from"@lingui/core";import{Button as rC,Divider as kn,ExternalLinkIcon as iC,Image as aC,Typography as Oo}from"@rango-dev/ui";import Ne from"react";function ku(t,e){if(e.type==="COSMOS")return"";let o=e.info?.addressUrl;return!o||!t?"":o.replace("{wallet}",t)}i(ku,"generateExplorerLink");import{darkTheme as Fo,styled as Tu}from"@rango-dev/ui";var Fa=Tu("a",{textDecoration:"none",color:"$colors$neutral700",[`.${Fo} &`]:{color:"$colors$neutral900"},"& svg":{marginLeft:"$4",color:"$colors$neutral700",[`.${Fo} &`]:{color:"$colors$neutral900"}},variants:{hasHover:{true:{"&:hover":{color:"$colors$secondary550",[`.${Fo} &`]:{color:"$colors$secondary500"},"& svg":{color:"$colors$secondary550",[`.${Fo} &`]:{color:"$colors$secondary500"}}}},false:{}}}}),vu=Tu("div",{display:"flex",justifyContent:"center",flexDirection:"column",alignItems:"center",textAlign:"center","& ._blockchain-name, & ._coin-source":{color:"$colors$neutral600",[`.${Fo} &`]:{color:"$colors$neutral800"}},"& ._coin-source-name, & ._custom-token-description":{color:"$colors$neutral700",[`.${Fo} &`]:{color:"$colors$neutral900"}}});function Ua(t){let{open:e,onClose:o,token:n,onSubmitClick:r,blockchain:a}=t,s=ku(n.address,a);return Ne.createElement(J,{open:e,dismissible:!0,onClose:o,container:N()},Ne.createElement(vu,null,Ne.createElement(aC,{src:n.image,size:45,type:"circular"}),Ne.createElement(Oo,{variant:"title",size:"medium"},n.name),Ne.createElement(Oo,{variant:"body",size:"small",className:"_blockchain-name"},a.displayName),Ne.createElement(kn,{size:4}),Ne.createElement(Oo,{variant:"body",size:"medium"},s?Ne.createElement(Fa,{hasHover:!0,href:s,target:"_blank",rel:"nofollow noreferrer"},n.address,Ne.createElement(iC,{size:12,color:"gray"})):Ne.createElement(Fa,null,n.address)),Ne.createElement(kn,{size:4}),n.coinSource&&Ne.createElement(Oo,{className:"_coin-source",variant:"body",size:"xsmall"},Oa.t("via")," ",Ne.createElement(Oo,{className:"_coin-source-name",variant:"body",size:"xsmall"},n.coinSource)),Ne.createElement(kn,{size:"32"}),Ne.createElement(Oo,{size:"medium",variant:"body",className:"_custom-token-description"},Oa.t("This token doesn't appear on the active token list(s). Make sure this is the token that you want to trade."))),Ne.createElement(kn,{size:40}),Ne.createElement(kn,{size:10}),Ne.createElement(rC,{id:"widget-custom-token-modal-import-btn",variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:r},Oa.t("Import")))}i(Ua,"CustomTokenModal");import{useManager as ck}from"@rango-dev/queue-manager-react";import{BottomLogo as pk,Divider as Qu,Header as uk}from"@rango-dev/ui";import Be,{useEffect as ls,useRef as qu,useState as dk}from"react";import{useRef as sC}from"react";function Dr(){return window.self!==window.top}i(Dr,"isAppLoadedIntoIframe");function za(){let t=sC(null),{iframe:e}=y(),o=Dr()&&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(za,"useIframe");import{useNavigate as lC}from"react-router-dom";function je(){let t=lC();return()=>t(-1)}i(je,"useNavigateBack");import{createTheme as ja,darkTheme as vC,lightTheme as wC}from"@rango-dev/ui";import{useEffect as bC,useState as xC}from"react";import{theme as kC,darkColors as TC}from"@rango-dev/ui";import Va from"react";function cC(t){return t.startsWith("#")&&(t=t.slice(1)),t.length===3?`#${t.split("").reduce(function(n,r){return n+r+r},"")}`:`#${t}`}i(cC,"expandShortHexColor");function pC(t){return/[0-9]+$/.test(t)}i(pC,"isOverridingColor");function uC(t,e){return t.padStart(e,"0")}i(uC,"pad");function Qa(t){let e=Math.min(Math.max(Math.round(t),0),255);return uC(e.toString(16),2)}i(Qa,"intToHex");function dC(t){return`#${Qa(t.red)}${Qa(t.green)}${Qa(t.blue)}`}i(dC,"rgbToHex");function mC(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(mC,"hexToRGB");function fC(t,e){let o=1-.11*e;return{red:t.red*o,green:t.green*o,blue:t.blue*o}}i(fC,"generateShade");function gC(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(gC,"generateTint");function hC(t){return wu(t,fC)}i(hC,"calculateShades");function yC(t){return wu(t,gC)}i(yC,"calculateTints");function wu(t,e){let o=mC(t),n=[];for(let r=1;r<9;r++)n.push(dC(e(o,r)));return n}i(wu,"calculateColors");function qa(t,e,o){let a=yC(t).reverse().concat(t),s=hC(t),l=a.concat(s),c={},u=l.length;for(let p=0;p<u;p++){let d=100+(o?u-1-p:p)*50;c[`${e}${d}`]=l[p]}return c}i(qa,"createTintsAndShades");function Ha(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)&&!pC(r)){let c=cC(a);Object.assign(n,qa(c,r,s))}}return{...n,...e}}i(Ha,"expandToGenerateThemeColors");var bu=i(t=>String.fromCharCode(t+(t>25?39:97)),"toAlphabeticChar"),SC=i(t=>{let e="",o;for(o=Math.abs(t);o>52;o=o/52|0)e=bu(o%52)+e;return bu(o%52)+e},"toAlphabeticName"),CC=i((t,e)=>{let o=e.length;for(;o;)t=t*33^e.charCodeAt(--o);return t},"toPhash"),Ga=i(t=>SC(CC(5381,JSON.stringify(t))>>>0),"toHash");function Ka(t){let e=kC.colors,o={...e,...TC},n,r;if(t?.light){let s={colors:Ha(e,t.light)};n={id:`${aa}-light-${Ga(s)}`,tokens:s}}if(t?.dark){let s={colors:Ha(o,t.dark,{reverseNeutralRange:!0})};r={id:`${aa}-dark-${Ga(s)}`,tokens:s}}return{light:n,dark:r}}i(Ka,"customizedThemeTokens");function xu(t,e){if(t.length<=1)return t.map(({element:n,key:r})=>Va.cloneElement(n,{key:r}));let o=[];return t.forEach((n,r)=>{let{element:a,key:s}=n;if(o.push(Va.cloneElement(a,{key:s})),r<t.length-1){let l=`divider-${r}`;o.push(Va.cloneElement(e,{key:l}))}}),o}i(xu,"joinList");function Eu(){return window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches}i(Eu,"doesWindowPreferDarkColorScheme");function Uo(t){let{colors:e,fontFamily:o=kc,borderRadius:n=qc,secondaryBorderRadius:r=Hc}=t,[a,s]=xC(Eu()?"dark":"light"),{theme:l}=y(),{dark:c,light:u}=Ka(e),p=ja({shadows:t.shadows||{},radii:{primary:`${n}px`,secondary:`${r}px`},fonts:{widget:o}}),d=[p.className,wC.className],h=[p.className,vC.className];if(u){let f=ja(u.id,u.tokens);d.push(f.className)}if(c){let f=ja(c.id,c.tokens);h.push(f.className)}return bC(()=>{let f=i(g=>{g.matches?s("dark"):s("light")},"switchThemeListener");return Eu()&&s("dark"),window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",f),()=>{window.matchMedia("(prefers-color-scheme: dark)").removeEventListener("change",f)}},[]),{activeTheme:i(()=>{let f=d.join(" "),g=h.join(" ");return l==="auto"?a==="dark"?g:f:l==="dark"?g:f},"getActiveTheme"),mode:l==="auto"?a:l}}i(Uo,"useTheme");var pt=i(t=>{let e=[];return t?.getAll().forEach((o,n)=>{let r=o.list.getStorage();r?.swapDetails&&e.push({id:n,swap:r?.swapDetails})}),e.sort((o,n)=>Number(n.swap.creationTime)-Number(o.swap.creationTime))},"getPendingSwaps");import{i18n as Iu}from"@lingui/core";import{Alert as EC,Button as IC}from"@rango-dev/ui";import Au from"react";function Xa(t){return Au.createElement(EC,{action:Au.createElement(IC,{id:"widget-active-tab-btn",onClick:t.onActivateTab,variant:"contained",size:"xxsmall",type:"warning"},Iu.t("Activate this tab")),type:"warning",variant:"alarm",title:Iu.t("Another tab is open and handles transactions.")})}i(Xa,"ActivateTabAlert");import{i18n as Ya}from"@lingui/core";import{Button as AC,Divider as NC,MessageBox as WC}from"@rango-dev/ui";import $r from"react";function Za(t){let{open:e,onClose:o,onConfirm:n}=t;return $r.createElement(J,{open:e,dismissible:!0,onClose:o,container:N()},$r.createElement(WC,{title:Ya.t("Activate current tab"),type:"warning",description:Ya.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.")},$r.createElement(NC,{size:20}),$r.createElement(AC,{id:"widget-modal-confirm-activate-tab-btn",variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:n},Ya.t("Confirm"))))}i(Za,"ActivateTabModal");import{ChevronLeftIcon as BC}from"@rango-dev/ui";import Nu from"react";function Ja(t){return Nu.createElement(Et,{id:"widget-header-back-icon-btn",variant:"ghost",size:"small",onClick:t.onClick},Nu.createElement(BC,{color:"black",size:16}))}i(Ja,"BackButton");import{i18n as MC}from"@lingui/core";import{Button as LC,Typography as PC}from"@rango-dev/ui";import Ra from"react";function es(t){return Ra.createElement(Vt,null,Ra.createElement(LC,{id:"widget-header-cancel-btn",variant:"ghost",onClick:t.onClick,size:"xsmall"},Ra.createElement(PC,{variant:"label",size:"medium",color:"error500"},MC.t("Cancel"))))}i(es,"CancelButton");import{i18n as _C}from"@lingui/core";import{Image as DC,Tooltip as $C,WalletIcon as FC}from"@rango-dev/ui";import uo from"react";function ts(t){let{list:e}=ft(),o=e.filter(r=>r.state==="connected"),n=o.length?uo.createElement("div",{className:Sp()},o.map(r=>uo.createElement(Cr,{key:r.title},uo.createElement(DC,{src:r.image,size:14})))):_C.t("Connect Wallet");return uo.createElement($C,{container:t.container,side:"bottom",content:n},uo.createElement(Et,{id:"widget-header-wallet-icon-btn",variant:"ghost",size:"small",onClick:t.onClick},t.isConnected&&uo.createElement(fp,null),uo.createElement(FC,{size:18,color:"black"})))}i(ts,"WalletButton");import{i18n as Or}from"@lingui/core";import{NotificationsIcon as ek,Popover as tk,SettingsIcon as ok,Tooltip as Ur,TransactionIcon as nk}from"@rango-dev/ui";import We from"react";import{Notifications as QC}from"@rango-dev/ui";import qC from"react";import{useNavigate as HC}from"react-router-dom";import{create as OC}from"zustand";import{persist as UC,subscribeWithSelector as zC}from"zustand/middleware";var be=Bo(OC()(UC(zC((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 os(){let t=HC(),{getNotifications:e,clearNotifications:o}=be(),n=e(),r=y().blockchains(),{findToken:a}=y();return qC.createElement(QC,{list:n,getBlockchainImage:l=>uc(l,r)??"",getTokenImage:l=>a(l)?.image??"",onClickItem:i(l=>{t(`${$.swaps}/${l}`)},"onClickItem"),onClearAll:o})}i(os,"NotificationContent");import{useManager as GC}from"@rango-dev/queue-manager-react";import{InProgressIcon as VC}from"@rango-dev/ui";import Wu from"react";var KC=i(()=>{let{manager:t}=GC();return pt(t).map(({swap:o})=>o).find(o=>o.status==="running")?Wu.createElement(yp,null,Wu.createElement(VC,{color:"info",size:6})):null},"InProgressTransactionBadge"),Bu=KC;import{EventSeverity as jC}from"@rango-dev/queue-manager-rango-preset";import{Typography as XC}from"@rango-dev/ui";import Mu from"react";function Lu(){let{getNotifications:t}=be(),e=t(),o=e.length,n=!!e.find(r=>r.event.messageSeverity===jC.WARNING);return o?Mu.createElement(gp,{isSever:n},Mu.createElement(XC,{variant:"body",size:"xsmall",color:"$background"},o)):null}i(Lu,"NotificationsBadge");import{RefreshProgressButton as YC}from"@rango-dev/ui";import ns,{useEffect as ZC,useState as Pu}from"react";var JC=1e3,_u=60,RC=100;function Fr({onClick:t}){let[e,o]=Pu(0),[n,r]=Pu(!1),a=i(c=>{document.hidden&&c&&s(c)},"handleVisibilityChange");ZC(()=>{let c;return t?c=window.setInterval(()=>{o(u=>u+1),e===_u&&l()},JC):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 ns.createElement(Et,{id:"widget-header-refresh-icon-btn",variant:"ghost",size:"small",style:{paddingTop:0,paddingBottom:0},onClick:l,disabled:!t},ns.createElement(hp,{onTransitionEnd:()=>r(!1),isRefetched:n},ns.createElement(YC,{size:22,color:t?"black":"gray",progress:e/_u*RC})))}i(Fr,"RefreshButton");function mo(t){let{onClickRefresh:e,onClickHistory:o,onClickSettings:n,hidden:r=[],container:a}=t,{config:{features:s}}=y(),l=Ve("notification",s)||r.includes("notifications");return We.createElement(We.Fragment,null,!r.includes("refresh")&&We.createElement(Ur,{container:a||N(),side:"top",content:Or.t("Refresh")},We.createElement(Fr,{onClick:e})),!l&&We.createElement(tk,{align:"end",alignOffset:-88,sideOffset:15,collisionPadding:{right:20,left:20},container:N(),content:We.createElement(os,null)},We.createElement("div",null,We.createElement(Ur,{container:N(),side:"top",content:Or.t("Notifications")},We.createElement(Et,{id:"widget-header-notification-icon-btn",size:"small",variant:"ghost"},We.createElement(ek,{size:18,color:"black"}),We.createElement(Lu,null))))),!r.includes("settings")&&We.createElement(Ur,{container:N(),side:"top",content:Or.t("Settings")},We.createElement(Et,{id:"widget-header-setting-icon-btn",size:"small",variant:"ghost",onClick:n},We.createElement(ok,{size:18,color:"black"}))),!r.includes("history")&&We.createElement(Ur,{container:N(),side:"top",content:Or.t("History")},We.createElement(Et,{id:"widget-header-history-icon-btn",size:"small",variant:"ghost",onClick:o},We.createElement(nk,{size:18,color:"black"}),We.createElement(Bu,null))))}i(mo,"HeaderButtons");import{i18n as rs}from"@lingui/core";import{Divider as $u,MessageBox as ak,RefreshIcon as sk}from"@rango-dev/ui";import zo from"react";import{Button as rk,styled as ik}from"@rango-dev/ui";var Du=ik(rk,{"& span":{display:"flex",justifyContent:"center",alignItems:"center"}});function is(t){let{open:e,onClose:o}=t;return zo.createElement(J,{open:e,dismissible:!0,onClose:o,container:N()},zo.createElement(ak,{title:rs.t("Something went wrong"),type:"error",description:rs.t("Something went wrong. Please refresh the app.")},zo.createElement($u,{size:30}),zo.createElement(Du,{variant:"outlined",size:"large",type:"primary",fullWidth:!0,onClick:()=>location.reload()},zo.createElement(sk,{size:20,color:"primary"}),zo.createElement($u,{size:4,direction:"horizontal"}),rs.t("Refresh"))))}i(is,"RefreshModal");function as(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(as,"onScrollContentAttachStatusToContainer");import{css as lk,styled as ss}from"@rango-dev/ui";var Fu="700px",zr=lk({borderRadius:"$primary",display:"flex",flexDirection:"column",overflow:"hidden",boxShadow:"$mainContainer"}),Ou=ss("div",{position:"relative",width:"100vw",minWidth:"300px",maxWidth:"390px",backgroundColor:"$background",variants:{height:{auto:{height:"auto",maxHeight:Fu},fixed:{height:Fu}}}}),Uu=ss("div",{position:"relative",overflow:"hidden",flexGrow:1,display:"flex",flexDirection:"column",padding:0,overflowY:"auto"}),zu=ss("div",{padding:"0 $20 $10","& .footer__alert":{paddingTop:"$10"},"& .footer__logo":{opacity:0,transition:"opacity 1s ease-in-out","&.logo__show":{opacity:1},"&.logo__hidden":{visibility:"hidden"}}});function oe(t){let{connectHeightObserver:e,disconnectHeightObserver:o}=za(),{children:n,header:r,footer:a,height:s="fixed"}=t,{fetchStatus:l,connectedWallets:c}=y(),[u,p]=dk(!1),{config:{features:d,theme:h}}=y(),{watermark:m}=re(),f=m==="FULL",{activeTheme:g}=Uo(h||{}),C=Ve("connectWalletButton",d),{isActiveTab:S,tabManagerInitiated:k,showActivateTabModal:T,setShowActivateTabModal:v,activateCurrentTab:w}=re(),A=je(),{manager:M}=ck(),E=pt(M).map(({swap:j})=>j).some(j=>j.status==="running"),b=i(()=>w(io.forceClaim,E),"onActivateTab"),I=i(()=>{r.onWallet?.()},"onConnectWallet"),W=typeof r.hasBackButton>"u"||r.hasBackButton,B=qu(null),U=qu(null);return ls(()=>(Dr()&&U.current&&e(U.current),()=>{o()}),[]),ls(()=>(B.current?.addEventListener("scroll",as),()=>{B.current?.removeEventListener("scroll",as)}),[]),ls(()=>{p(l==="failed")},[l]),Be.createElement(Ou,{height:s,id:De.SWAP_BOX_ID,className:`${g()} ${zr()}`,ref:U},Be.createElement(uk,{prefix:W?Be.createElement(Ja,{onClick:()=>{A(),r.onBack&&r.onBack()}}):null,title:r.title,suffix:Be.createElement(Be.Fragment,null,r.suffix,r.onWallet&&!C&&Be.createElement(ts,{container:N(),onClick:I,isConnected:!!c?.length}),r.onCancel&&Be.createElement(es,{onClick:r.onCancel}))}),Be.createElement(Uu,{ref:B},n),Be.createElement(Za,{open:T,onClose:()=>v(!1),onConfirm:b}),Be.createElement(zu,null,Be.createElement("div",{className:"footer__content"},k&&!S&&Be.createElement("div",{className:"footer__alert"},Be.createElement(Xa,{onActivateTab:b}),Be.createElement(Qu,{size:10})),a),Be.createElement(Qu,{size:12}),Be.createElement("div",{className:`footer__logo ${f?"logo__show":"logo__hidden"}`},Be.createElement(pk,null))),Be.createElement(is,{open:u,onClose:()=>p(!1)}))}i(oe,"Layout");import{styled as mk}from"@rango-dev/ui";var Hu="$20 $20 $10 $20",Tn=mk("div",{padding:Hu,overflowY:"auto",flexGrow:1});import{styled as fk}from"@rango-dev/ui";var ie=fk("div",{display:"flex",flexDirection:"column",padding:"20px 20px 10px",flexGrow:1,variants:{view:{true:{flexGrow:1,overflow:"hidden"}},compact:{true:{padding:0}}}});import{i18n as Qo}from"@lingui/core";import{useState as Gu}from"react";function Vu(){let[t,e]=Gu(!1),[o,n]=Gu(void 0),{findToken:r}=y(),a=y().customTokens();function s(c,u){switch(c){case"duplicated":return{title:Qo.t("Duplicate Token"),message:Qo.t("The address you entered is duplicate, please enter a new address.")};case"token-exist":return{title:Qo.t("Token Already Exists"),message:Qo.t("There's no need to add this token again because it already exists and is supported by us.")};case"not-found":return{title:Qo.t("Token Not Found"),message:Qo.t({id:"Sorry, no token was found on {blockchain} chain with the provided address. please make sure you have entered the right token address.",values:{blockchain:u}})}}}return i(s,"produceErrorMessage"),{fetchCustomToken:i(async({blockchain:c,tokenAddress:u})=>{e(!0);try{if(a.some(f=>f.address?.toLowerCase()===u.toLowerCase())){let f=s("duplicated");n(f);return}let d=await xt().getCustomToken({blockchain:c,address:u});if(!d||!d.token||d.error){let f=s("not-found",c);n(f);return}let h=d.token;if(r({blockchain:h.blockchain,address:h.address,symbol:h.symbol})){let f=s("token-exist");n(f);return}return h}catch(p){if(p?.code==="ERR_BAD_REQUEST"){let d=s("not-found",c);n(d);return}throw n(void 0),new Error(p.message)}finally{e(!1)}},"fetchCustomToken"),loading:t,error:o}}i(Vu,"useFetchCustomToken");var xk=Ck("div",{display:"flex",justifyContent:"space-between",flexDirection:"column",flex:1,"& ._text-field":{padding:"$4 $10",backgroundColor:"$neutral300",[`.${hk} &`]:{backgroundColor:"$neutral400"},borderRadius:"$sm",height:"$40"}}),Ek=1e3;function ju(){let t=wk(),[e]=bk(),o=je(),{setCustomToken:n}=y(),r=y().blockchains(),a=e.get("blockchain")||"",s=nn(a,r),[l,c]=Qr(""),[u,p]=Qr(!1),[d,h]=Qr(),{fetchCustomToken:m,loading:f,error:g}=Vu(),[C,S]=Qr(""),k=!!s&&xo(s,l),T=!s||!l||!k,v=i(async()=>{if(s)try{let M=await m({blockchain:a,tokenAddress:l});S(""),M&&h(M)}catch(M){M.message==="Failed to fetch"&&(S(It.t("Network Error")),p(!0))}},"getCustomToken"),w=i(()=>{g&&c(""),p(!1)},"closeErrorModal"),A=i(async()=>{C&&setTimeout(async()=>{await v()},Ek),w()},"handleErrorModalButtonClick");return vk(()=>{g&&p(!0)},[g]),ye.createElement(oe,{header:{title:It.t("Add Custom Token")}},ye.createElement(ie,null,ye.createElement(xk,null,ye.createElement("div",null,ye.createElement($a,{onClick:()=>t($.blockchains,{replace:!0}),hasLogo:!!s?.logo,value:s?{name:s.displayName,logo:s.logo}:void 0,title:It.t("Select chain"),placeholder:It.t("Select chain")}),ye.createElement(vn,{size:"24"}),ye.createElement(Tk,{size:"large",variant:"label"},It.t("Enter Address")),ye.createElement(vn,{size:10}),ye.createElement(kk,{fullWidth:!0,disabled:!s,variant:"contained",placeholder:It.t("Enter token address"),size:"large",value:l,suffix:!!l&&k&&ye.createElement(yk,{color:"success",size:12}),onChange:M=>c(M.target.value)}),!k&&!!l&&ye.createElement(ye.Fragment,null,ye.createElement(vn,{size:4}),ye.createElement(gk,{type:"error",variant:"alarm",title:"Invalid Address"}))),ye.createElement(Ku,{id:"widget-add-custom-token-import-btn",disabled:T,type:"primary",variant:"contained",loading:f,size:"large",onClick:v},It.t("Import"))),ye.createElement(J,{open:u,dismissible:!0,onClose:w,container:N()},ye.createElement(Sk,{title:g?.title||C,type:"error",description:g?.message||It.t("Failed Network, Please retry.")},ye.createElement(vn,{size:40}),ye.createElement(vn,{size:10}),ye.createElement(Ku,{id:`widget-add-custom-token-${C?"retry":"add-another"}-btn`,variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:A},C?It.t("Retry"):It.t("Add another custom token")))),s&&d&&ye.createElement(Ua,{blockchain:s,token:d,onSubmitClick:()=>{d&&(n(d),h(void 0),o())},onClose:()=>h(void 0),open:!!s&&!!d})))}i(ju,"AddCustomTokenPage");import{i18n as Fs}from"@lingui/core";import{useManager as cv}from"@rango-dev/queue-manager-react";import{Alert as pv,Button as uv,css as Us,Divider as Os,IconButton as Qm,styled as dv,Typography as mv,WalletIcon as fv}from"@rango-dev/ui";import Le,{useEffect as hi,useLayoutEffect as gv,useRef as hv,useState as _n}from"react";import{useNavigate as yv}from"react-router-dom";import{i18n as fo}from"@lingui/core";import{Alert as Zk,BalanceErrors as Jk,Button as vd,ChevronLeftIcon as Rk,Divider as hs,MessageBox as eT,Typography as ys}from"@rango-dev/ui";import te,{useCallback as tT,useEffect as wd,useMemo as oT,useState as Go}from"react";import{useNavigate as nT}from"react-router-dom";import{i18n as ds}from"@lingui/core";import{Alert as Bk,ChevronDownIcon as Mk,CloseIcon as Lk,Divider as td,IconButton as od,PasteIcon as Pk,Typography as _k,WalletIcon as Dk}from"@rango-dev/ui";import Me,{useEffect as $k,useRef as Fk}from"react";import Vr,{useRef as Nk}from"react";import*as qo from"@radix-ui/react-collapsible";import{keyframes as Xu,styled as qr}from"@rango-dev/ui";var cs=300,Ik=Xu({from:{height:0},to:{height:"var(--radix-collapsible-content-height)"}}),Ak=Xu({from:{height:"var(--radix-collapsible-content-height)"},to:{height:0}}),Yu=qr(qo.Root,{borderRadius:"$sm",overflow:"hidden",variants:{selected:{true:{outlineWidth:1,outlineColor:"$secondary500",outlineStyle:"solid"}}}}),ps=qr(qo.Trigger,{padding:"$0",border:"none",outline:"none",width:"100%",backgroundColor:"transparent",fontFamily:"inherit",cursor:"pointer"}),Hr=qr(qo.Content,{overflow:"hidden",variants:{open:{true:{animation:`${Ik} ${cs}ms ease-out`},false:{animation:`${Ak} ${cs}ms ease-out`}}}}),Gr=qr("div",{transition:`all ${cs}ms ease`,display:"flex",alignItems:"center",variants:{orientation:{down:{transform:"rotate(0)"},up:{transform:"rotate(180deg)"}}}});function Kr(t){let{open:e,hasSelected:o,onOpenChange:n,children:r,onClickTrigger:a,trigger:s,triggerAnchor:l}=t,c=Nk(null);return Vr.createElement(Yu,{ref:c,className:"collapsible_root",selected:o&&e,open:e,onOpenChange:n},l==="top"&&Vr.createElement(ps,{className:"collapsible_trigger",onClick:a},s),Vr.createElement(Hr,{className:"collapsible_content",open:e},r),l==="bottom"&&Vr.createElement(ps,{className:"collapsible_trigger",onClick:a},s))}i(Kr,"CustomCollapsible");import{darkTheme as Zu,styled as us,TextField as Wk}from"@rango-dev/ui";var Ju=us("div",{padding:"$10 $0","& .button__content":{display:"flex",alignItems:"center"},"& .alarms":{paddingTop:"$5"},"& .collapsible_content":{backgroundColor:"$neutral100"},"& .collapsible_root":{backgroundColor:"$neutral100"}}),Ru=us(Wk,{backgroundColor:"$neutral100",padding:"$15"}),ed=us("div",{width:"100%",borderRadius:"$sm",display:"flex",padding:"$15",justifyContent:"space-between",alignItems:"center",$$color:"$colors$neutral100",[`.${Zu} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",borderBottomRightRadius:"0",borderBottomLeftRadius:"0","&:focus-visible":{$$background:"$colors$secondary100",[`.${Zu} &`]:{$$background:"$colors$info700"},backgroundColor:"$$background",outline:0}});function nd(t){let{blockchain:e,handleOpenChange:o,open:n}=t,{customDestination:r,setCustomDestination:a}=O(),{config:s}=y(),l=y().blockchains(),c=rr(e.name,l),u=Fk(null),p=s?.defaultCustomDestinations?.[e.name],d=navigator?.userAgent.includes("Firefox"),m=n&&!!r&&e&&!xo(e,r),f=i(()=>{a("")},"handleClear"),g=i(async S=>{if(S.preventDefault(),navigator.clipboard!==void 0){let k=await navigator.clipboard.readText();a(k),u?.current?.focus()}},"handlePaste"),C=i(()=>r?Me.createElement(od,{id:"widget-custom-destination-close-icon-btn",onClick:f,variant:"ghost"},Me.createElement(Lk,{size:12,color:"gray"})):d?null:Me.createElement(od,{id:"widget-custom-destination-paste-icon-btn",onClick:g,variant:"ghost"},Me.createElement(Pk,{size:16})),"renderSuffix");return $k(()=>{!!p&&r===null&&(a(p),o(!0))},[p]),Me.createElement(Ju,null,Me.createElement(Kr,{onOpenChange:o,hasSelected:!0,open:n,triggerAnchor:"top",trigger:Me.createElement(ed,null,Me.createElement("div",{className:"button__content"},Me.createElement(Dk,{size:18,color:"info"}),Me.createElement(td,{size:4,direction:"horizontal"}),Me.createElement(_k,{variant:"label",size:"medium",color:n?"$neutral600":void 0},ds.t("Send to a different address"))),Me.createElement(Gr,{orientation:n?"up":"down"},Me.createElement(Mk,{size:10,color:"secondary"}))),onClickTrigger:()=>o(!n)},Me.createElement(Ru,{ref:u,style:{padding:0,paddingRight:r?"8px":"5px"},autoFocus:!r,placeholder:ds.t("Enter {blockchainName} address",{blockchainName:c}),value:r||"",suffix:C(),onChange:S=>{let k=S.target.value;a(k)}})),m&&Me.createElement(Me.Fragment,null,Me.createElement(td,{size:4}),Me.createElement(Bk,{variant:"alarm",type:"error",title:ds.t({values:{destination:r},id:"Address {destination} doesn't match the blockchain address pattern."})})))}i(nd,"CustomDestination");import{css as Ok,darkTheme as ms,IconButton as Uk,styled as Dt}from"@rango-dev/ui";var rd=Dt("div",{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center"}),id=Dt("div",{display:"flex",justifyContent:"space-evenly",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5",height:"100%"}),zk=Dt("button",{borderRadius:"$xm",padding:"$10",border:"0",display:"flex",justifyContent:"center",$$color:"$colors$neutral100",[`.${ms} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",alignItems:"center",cursor:"pointer",width:110,position:"relative","&:hover":{$$color:"$colors$secondary100",[`.${ms} &`]:{$$color:"$colors$neutral100"},backgroundColor:"$$color"},"&:focus-visible":{$$color:"$colors$secondary100",[`.${ms} &`]:{$$color:"$colors$info700"},backgroundColor:"$$color",outline:0},variants:{selected:{true:{outlineWidth:1,outlineColor:"$secondary",outlineStyle:"solid"}}}}),ad=Dt(zk,{alignSelf:"stretch",minHeight:"93px"}),sd=Dt("div",{padding:"$20 $20 $15 $20",display:"flex",justifyContent:"center",alignItems:"center",backgroundColor:"$neutral200",position:"relative",width:"100%"}),ld=Dt(Uk,{position:"absolute",left:"$20"}),cd=Dt("div",{paddingTop:"$20"}),pd=Ok({display:"flex",justifyContent:"space-evenly",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5",height:"100%"}),ud=Dt("div",{display:"flex"}),dd=Dt("div",{overflow:"visible",width:"100%"});import{i18n as Sd}from"@lingui/core";import{warn as Vk}from"@rango-dev/logging-core";import{Divider as Kk,SelectableWallet as jk,Typography as Cd,WalletState as kd}from"@rango-dev/ui";import Xe,{useEffect as Td,useState as bn}from"react";import{Image as Hk,MessageBox as Gk}from"@rango-dev/ui";import wn from"react";import{keyframes as Qk,styled as fs}from"@rango-dev/ui";var md=fs("div",{position:"relative"}),qk=Qk({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}),fd=fs("div",{position:"absolute",border:"2px solid rgba(0, 0, 0, 0.1)",borderTop:"2px solid $info500",borderRadius:"$lg",width:"$45",height:"$45",animation:`${qk} 1s linear infinite`,top:0,bottom:0,right:0,left:0}),gd=fs("div",{"& img":{borderRadius:"50%"}});import{i18n as Ho}from"@lingui/core";function hd(t,e){switch(t){case"in-progress":return{type:"loading",title:Ho.t({id:"Add {blockchainDisplayName} Chain",values:{blockchainDisplayName:e}}),description:Ho.t({id:"Please approve the experimental chain pop-up in your wallet.",values:{blockchainDisplayName:e}})};case"completed":return{type:"success",title:Ho.t({id:"{blockchainDisplayName} Chain Added",values:{blockchainDisplayName:e}}),description:Ho.t({id:"The {blockchainDisplayName} chain has been successfully added to your wallet.",values:{blockchainDisplayName:e}})};case"rejected":return{type:"error",title:Ho.t("Request Rejected"),description:Ho.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(hd,"generateMessageByStatus");function yd(t){let{status:e,displayName:o,image:n}=t,r=hd(e,o),a=e=="in-progress";return wn.createElement(Gk,{type:r.type,title:r.title,description:r.description,icon:a?wn.createElement(md,null,wn.createElement(gd,null,wn.createElement(Hk,{src:n,size:45})),wn.createElement(fd,null)):void 0})}i(yd,"ExperimentalChainStatus");var Xk=7,Yk=3e3;function gs(t){let{chain:e,isSelected:o,selectWallet:n,limit:r,onShowMore:a}=t,s=re.use.isActiveTab(),{blockchains:l,connectedWallets:c}=y(),[u,p]=bn(),[d,h]=bn(null),[m,f]=bn(!1),[g,C]=bn(null),{suggestAndConnect:S}=jr(),{handleDisconnect:k}=Gt(),{list:T}=ft({chain:e}),[v,w]=bn(T),A=T.length,M=r&&A-r>0,x=i(async b=>{f(!1),C("in-progress");try{await S(b.walletType,b.chain),C("completed")}catch{C("rejected")}},"addExperimentalChain");Td(()=>{w(b=>{let I=T.findIndex(W=>o(W.type,e));return M&&I>1?[T[I]].concat(T.filter((W,B)=>B!==I)):b.map(W=>T.find(B=>B.type===W.type)??W)})},[JSON.stringify(T)]);let E=document.getElementById(De.SWAP_BOX_ID);return Td(()=>{let b=null;return(g==="completed"||g==="rejected")&&(b=setTimeout(()=>C(null),Yk)),()=>{b&&clearTimeout(b)}},[g]),Xe.createElement(Xe.Fragment,null,v.slice(0,r).map(b=>{let I=$c({connectedWallets:c,walletType:b.type,chain:e}),W=I?hr(I,Xk):"",B=fr(l(),e),U=!c.find(se=>se.walletType===b.type&&se.chain===e),j=B&&U&&b.state===kd.CONNECTED,R=j?Sd.t({id:"Add {chain} chain",values:{chain:e}}):W,P=i(async()=>{let se=b.state===kd.DISCONNECTED,Q=(b.isHub||!!b.needsNamespace)&&!W;se?p(b):Q?(await k(b.type),p(b)):j?(h({walletType:b.type,chain:e,address:I??""}),f(!0)):n({walletType:b.type,chain:e,address:I??""})},"onSelectableWalletClick"),Y=d?.chain?rr(d.chain,l()):void 0;return Xe.createElement(Xe.Fragment,{key:`${b.title}_${Y}`},!!d&&Xe.createElement(J,{open:!!d&&m,container:E,onClose:()=>{h(null)}},Xe.createElement(wa,{displayName:Y,onConfirm:()=>{x(d)}})),g&&Xe.createElement(J,{open:!!g,onClose:C.bind(null,null),container:E},Xe.createElement(yd,{status:g,displayName:Y,image:b.image}),Xe.createElement(Kk,{direction:"vertical",size:32})),Xe.createElement(jk,{key:b.type,description:R,onClick:P,selected:o(b.type,e),disabled:!s,...b}))}),Xe.createElement(co,{wallet:u,onClose:()=>{p(void 0)},onConnect:()=>{t.onConnect&&(u?.type?t.onConnect(u.type):Vk(new Error("The selected wallet hasn't been detected after the connection process finished. It usually shouldn't happen.")))}}),M&&Xe.createElement(ad,{selected:!1,onClick:a},Xe.createElement(Cd,{variant:"label",size:"medium"},Sd.t("Show more wallets"),Xe.createElement(Cd,{variant:"label",size:"medium",color:"$primary"},"\xA0+",A-(r??0)))))}i(gs,"WalletList");var rT=2;function bd(t){let{open:e,onClose:o,onCancel:n,onCheckBalance:r,loading:a}=t,s=nT(),l=y().blockchains(),{selectedQuote:c,setSelectedWallets:u,quoteWalletsConfirmed:p,setQuoteWalletConfirmed:d,customDestination:h,setCustomDestination:m}=O(),{config:f,connectedWallets:g,setWalletsAsSelected:C}=y(),[S,k]=Go(""),[T,v]=Go([]),[w,A]=Go(""),[M,x]=Go(!!h),E=oT(()=>ro({filter:"all",quote:c}),[c]),b=ro({filter:"required",quote:c}),I=l.find(_=>_.name===c?.swaps[c?.swaps.length-1].to.blockchain),W=i(_=>b.includes(_),"isWalletRequiredFor"),B=tT(()=>g.filter(_=>_.selected&&E.includes(_.chain)),[g,E]),[U,j]=Go(B()),[R,P]=Go([]),Y=i((_,G)=>P(K=>K.concat({blockchain:_,walletType:G})),"addNextSelectedWallets"),se=T.length>0,Q=i((_,G)=>!!U.find(K=>K.walletType===_&&K.chain===G&&K.selected&&(W(G)||!W(G)&&!h)),"isSelected"),me=i((_,G,K)=>{let fe=!1;return _.map(ne=>{if(ne.chain===G){let ge=ne.selected;return!fe&&K?(fe=!0,ge=!0):K||(ge=!1),{...ne,selected:ge}}return ne})},"updateSelectableWallets"),vt=i(_=>{x(_),_?W(I?.name??"")||j(G=>me(G,I?.name||"",!1)):(m(""),j(G=>me(G,I?.name||"",!0)))},"handleCustomDestinationCollapsibleOpenChange"),Ze=i(_=>{if(S&&k(""),Q(_.walletType,_.chain))return;let K=g.find(fe=>fe.walletType===_.walletType&&fe.chain===_.chain);K&&(n(),_.chain===I?.name&&M&&!W(I.name)&&(x(!1),m(null)),j(fe=>fe.filter(ne=>ne.chain!==_.chain).concat({...K,selected:!0})))},"onChange"),le=i(()=>{let _=U.filter(G=>G.selected);C(_),u(_),d(!0),o()},"onConfirmBalance"),at=i(async()=>{v([]),A("");let _=await r?.({selectedWallets:U.filter(K=>K.selected),customDestination:h}),G=_.warnings;G?.balance?.messages&&v(G.balance.messages),_.error&&A(_p(_.error)),!_.error&&!G?.balance?.messages.length?le():v(G?.balance?.messages??[])},"onConfirmWallets");wd(()=>{j(_=>{let G=[];return _.forEach(K=>{!g.some(ne=>ne.chain===K.chain&&ne.walletType===K.walletType&&ne.address===K.address)||G.push(K)}),G=G.concat(g.filter(K=>!!!G.find(ne=>ne.chain===K.chain)&&K.selected&&E.includes(K.chain))),G})},[g,E]),wd(()=>{let _=[];R.length>0&&(R.forEach(G=>{let K=g.find(fe=>fe.chain===G.blockchain&&fe.walletType===G.walletType);K?Ze(K):_.push(G)}),P(_))},[g,R]);let V=document.getElementById(De.SWAP_BOX_ID);return te.createElement(J,{open:e,onClose:()=>{p||s("../",{replace:!0}),o()},dismissible:!S,container:V,...!S&&{styles:{container:{height:"100%"}},footer:te.createElement(ud,null,te.createElement(vd,{id:"widget-confirm-wallet-modal-confirm-btn",loading:a,disabled:pu(a,M,h,c,U,I),onClick:at,variant:"contained",type:"primary",fullWidth:!0,size:"large"},fo.t("Confirm")))},...S&&{styles:{container:{height:"100%",padding:"$0"}},header:te.createElement(sd,null,te.createElement(ld,{id:"widget-confirm-wallet-modal-navigate-back-icon-btn",variant:"ghost",onClick:k.bind(null,"")},te.createElement(Rk,{size:16})),te.createElement(ys,{variant:"headline",size:"small"},fo.t({id:"Your {blockchainName} wallets",values:{blockchainName:st(S,l)}})))},anchor:"center"},te.createElement(J,{open:se,onClose:v.bind(null,[]),container:V},te.createElement(eT,{title:fo.t("Insufficient account balance"),type:"error",description:te.createElement(Jk,{messages:T??[]})},te.createElement(vd,{id:"widget-confirm-wallet-modal-proceed-anyway-btn",variant:"outlined",size:"large",type:"primary",fullWidth:!0,onClick:le},fo.t("Proceed anyway")))),S&&te.createElement(cd,null,te.createElement("div",{className:pd()},te.createElement(gs,{chain:S,isSelected:Q,selectWallet:Ze,onShowMore:()=>k(S),onConnect:_=>{Y(S,_)}}))),!S&&te.createElement(te.Fragment,null,w&&te.createElement(te.Fragment,null,te.createElement(Zk,{variant:"alarm",type:"error",title:fo.t(w)}),te.createElement(hs,{size:12})),te.createElement(dd,null,E.map((_,G)=>{let K=l.find(Fe=>Fe.name===_),fe=`wallet-${G}`,ne=G===E.length-1,ge=ne&&I&&f?.customDestination!==!1;return te.createElement("div",{key:fe},te.createElement(rd,null,te.createElement(ys,{variant:"title",size:"xmedium"},fo.t({id:"Your {blockchainName} wallets",values:{blockchainName:K?.shortName}})),te.createElement(ys,{variant:"label",color:"$neutral700",size:"medium"},fo.t({id:"You need to connect a {blockchainName} wallet.",values:{blockchainName:K?.shortName}}))),te.createElement(hs,{size:24}),te.createElement(id,null,te.createElement(gs,{chain:_,isSelected:Q,selectWallet:Ze,limit:rT,onShowMore:()=>k(K?.name??""),onConnect:Fe=>{Y(_,Fe)}})),!ne&&te.createElement(hs,{size:32}),ge&&te.createElement(nd,{blockchain:I,open:M,handleOpenChange:vt}))}))))}i(bd,"ConfirmWalletsModal");import{i18n as wT}from"@lingui/core";import{Alert as bT,Button as xT,InfoIcon as ET}from"@rango-dev/ui";import et from"react";import{Alert as sT,Button as lT,Divider as ks,NoRouteIcon as cT,RefreshIcon as pT,Typography as Bd}from"@rango-dev/ui";import Re from"react";import{i18n as xd}from"@lingui/core";var iT=24,aT=60;function Ed(t,e,o,n){return t?.type===1?{alert:{type:"warning",text:ee().genericServerError,action:{onClick:n,title:xd.t("Retry")}},description:""}:e.length?{alert:{type:"warning",text:ee().liquiditySourcesError.title,action:{onClick:()=>o(!0),title:xd.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(Ed,"makeInfo");var Ss=(o=>(o[o.small=iT]="small",o[o.large=aT]="large",o))(Ss||{}),Cs=(o=>(o.small="small",o.large="medium",o))(Cs||{});import{styled as Xr}from"@rango-dev/ui";var Id=Xr("div",{display:"flex",flexDirection:"column",alignItems:"center"}),Ad=Xr("div",{variants:{size:{small:{},large:{maxWidth:"316px"}}}}),Nd=Xr("div",{variants:{size:{small:{width:"100%"},large:{}}}}),Wd=Xr("div",{padding:"$6 $0"});function xn(t){let{fetch:e,error:o,size:n="small"}=t,r=y().getDisabledLiquiditySources(),a=y().toggleAllLiquiditySources,s=y().swappers(),l=Ed(o,r,()=>a(s,!0),e);return Re.createElement(Id,null,Re.createElement(cT,{size:Ss[n],color:"gray"}),Re.createElement(ks,{size:4}),Re.createElement(Bd,{variant:"title",size:Cs[n]},ee().noResultError.title),n==="large"&&Re.createElement(ks,{size:4}),!!l.description&&Re.createElement(Ad,{size:n},Re.createElement(Bd,{variant:"body",size:"small",align:"center",color:"neutral700"},l.description)),Re.createElement(ks,{size:n==="large"?"24":"4"}),!!l.alert&&Re.createElement(Nd,{size:n},Re.createElement(sT,{type:l.alert.type,title:l.alert.text,titleAlign:"left",action:l.alert.action&&Re.createElement(lT,{size:"xsmall",id:"widget-no-result-alert-btn",type:l.alert.type,prefix:Re.createElement(Wd,null,Re.createElement(pT,{size:8})),onClick:l.alert.action.onClick},l.alert.action.title),variant:"alarm"})))}i(xn,"NoResult");import{i18n as En}from"@lingui/core";import{Button as dT,Divider as mT,MessageBox as fT,Typography as gT,WarningIcon as hT}from"@rango-dev/ui";import $t from"react";import{Typography as _d}from"@rango-dev/ui";import vs from"react";import{darkTheme as uT,styled as Yr}from"@rango-dev/ui";var Md=Yr("div",{width:"100%"}),Ts=Yr("div",{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"$5",width:"100%"}),Ld=Yr("div",{display:"flex",padding:"$5 0",justifyContent:"space-between",alignItems:"center",width:"100%","._title":{$$color:"$colors$neutral600",[`.${uT} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),Pd=Yr("div",{padding:"$2",alignSelf:"flex-start",cursor:"pointer"});function Dd(t){let{title:e,value:o,valueColor:n}=t;return vs.createElement(Ld,null,vs.createElement(_d,{size:"medium",variant:"label",className:"_title"},e),vs.createElement(_d,{size:"large",variant:"label",color:n||"foreground"},`${n?"%":"$"}${o}`))}i(Dd,"QuoteErrorsModalItem");function $d(t){let{open:e,onClose:o,onConfirm:n,warning:r,confirmationDisabled:a}=t,s=r.warningLevel==="high"?"error":"warning",l=[{title:En.t("Swapping"),value:L(r.inputUsdValue,4,4)},{title:En.t("Gas cost"),value:L(r.totalFee,2,2)},{title:En.t("Receiving"),value:L(r.outputUsdValue,4,4)},{title:En.t("Price impact"),value:L(r.priceImpact,2,2),valueColor:`${s}500`}];return $t.createElement(J,{footer:$t.createElement(dT,{id:"widget-high-value-loss-warning-modal-confirm-btn",type:"primary",size:"large",prefix:$t.createElement(hT,null),fullWidth:!0,disabled:a,onClick:n},ee().highValueLossError.confirmMessage),open:e,onClose:o,container:N()},$t.createElement(fT,{type:s,title:ee().highValueLossError.impactTitle,description:ee().highValueLossError.description}),$t.createElement(Ts,null,$t.createElement(mT,{size:"4"}),$t.createElement(gT,{size:"small",variant:"title"},En.t("Details")),$t.createElement(Ts,null,l.map((c,u)=>$t.createElement(Dd,{key:u,...c})))))}i($d,"HighValueLossWarningModal");import{i18n as Zr}from"@lingui/core";function Fd(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=Zr.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=Zr.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=Zr.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=Zr.t("Caution, your slippage is high."),o.action="change-settings";break}default:break}return o}return null}i(Fd,"makeAlerts");import{i18n as Vo}from"@lingui/core";import{Button as Od,Divider as Ud,MessageBox as yT,Typography as ST}from"@rango-dev/ui";import go from"react";import{useNavigate as CT}from"react-router-dom";function zd(t){let{customSlippage:e,slippage:o}=y(),{open:n,onClose:r,onConfirm:a,warning:s,confirmationDisabled:l}=t,c=CT(),u=e??o;return go.createElement(J,{anchor:"bottom",open:n,prefix:go.createElement(Od,{size:"small",id:"widget-slippage-warning-modal-change-settings-btn",variant:"ghost",onClick:()=>c("../"+$.settings)},go.createElement(ST,{variant:"label",size:"medium",color:"$neutral900"},Vo.t("Change settings"))),container:N(),onClose:r},go.createElement(yT,{type:"warning",title:s.type===3?Vo.t("High slippage"):Vo.t("Low slippage"),description:s.type===3?Vo.t({id:" Caution, your slippage is high (={userSlippage}). Your trade may be front run.",values:{userSlippage:u}}):Vo.t({id:"We recommend you to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:s.minRequiredSlippage}})},go.createElement(Ud,{size:18}),go.createElement(Ud,{size:32}),go.createElement(Od,{id:"widget-slippage-warning-modal-confirm-anyway-btn",size:"large",type:"primary",variant:"contained",fullWidth:!0,disabled:l,onClick:a},Vo.t("Confirm anyway"))))}i(zd,"SlippageWarningModal");import{Button as kT,MessageBox as TT,WarningIcon as vT}from"@rango-dev/ui";import Jr from"react";function Qd(t){let{open:e,onClose:o,onConfirm:n,confirmationDisabled:r}=t;return Jr.createElement(J,{footer:Jr.createElement(kT,{id:"widget-unknown-price-warning-modal-confirm-btn",type:"primary",size:"large",prefix:Jr.createElement(vT,null),fullWidth:!0,disabled:r,onClick:n},ee().unknownPriceError.confirmMessage),open:e,onClose:o,container:N()},Jr.createElement(TT,{type:"warning",title:ee().unknownPriceError.impactTitle,description:ee().unknownPriceError.description}))}i(Qd,"UnknownPriceWarningModal");function In(t){let{warning:e,error:o,couldChangeSettings:n,showWarningModal:r,confirmationDisabled:a,refetchQuote:s,onOpenWarningModal:l,onCloseWarningModal:c,onConfirmWarningModal:u,onChangeSettings:p}=t,d={confirmationDisabled:a,open:r,onClose:c,onConfirm:u},h=o?.type===0||o?.type===1,m=Fd(e,o?.type===3||o?.type===4?o:null);return m&&!n&&(m.action=null),et.createElement(et.Fragment,null,h&&et.createElement(xn,{error:o,fetch:s}),!!m&&et.createElement(Md,null,et.createElement(bT,{title:m.title,type:m.alertType,variant:"alarm",...m.action==="show-info"&&{action:et.createElement(Pd,{onClick:l},et.createElement(ET,{size:12,color:"gray"}))},...m.action==="change-settings"&&{action:et.createElement(xT,{id:"widget-quote-warning-error-change-settings-btn",size:"xxsmall",type:m.alertType,onClick:p},wT.t("Change"))}})),e&&et.createElement(et.Fragment,null,e.type===0&&et.createElement($d,{...d,warning:e}),(e.type===3||e.type===2)&&et.createElement(zd,{...d,warning:e}),e.type===1&&et.createElement(Qd,{...d,warning:e})))}i(In,"QuoteWarningsAndErrors");import nv from"bignumber.js";import di from"react";import{i18n as ho}from"@lingui/core";import{Alert as HT,Divider as jo,FullExpandedQuote as GT,InfoIcon as VT,NumericTooltip as km,QuoteTag as KT,StepDetails as jT,TokenAmount as XT,Typography as Xo}from"@rango-dev/ui";import Bs from"bignumber.js";import F,{useRef as YT,useState as ZT}from"react";import{styled as ws}from"@rango-dev/ui";var bs=ws("div",{width:"100%","& .position-top__skeleton":{paddingTop:"$10"}}),qd=ws("div",{paddingBottom:"$15",variants:{dense:{true:{paddingBottom:0}}}}),Hd=ws("div",{width:"100%",display:"flex"});import*as Rr from"@radix-ui/react-collapsible";import{Button as IT,css as An,darkTheme as xe,Image as Gd,styled as ze,Typography as AT}from"@rango-dev/ui";var NT=300,Vd=ze(Rr.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"}}]}),Kd=An({padding:"$10 $15"}),jd=ze(IT,{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"}}}),Xd=ze("div",{borderRadius:"$xm",display:"flex",flexDirection:"column",alignItems:"start",justifyContent:"space-between",color:"$foreground",boxSizing:"border-box",position:"relative",variants:{selected:{true:{},false:{$$color:"$colors$neutral200",[`.${xe} &`]:{$$color:"$colors$neutral500"},backgroundColor:"$$color"}},basic:{true:{borderTopRightRadius:"0",borderTopLeftRadius:"0"}},listItem:{true:{$$color:"$colors$neutral200",[`.${xe} &`]:{$$color:"$colors$neutral500"},backgroundColor:"$$color","&:hover":{"& .quote_container":{"& button":{backgroundColor:"$neutral500",[`.${xe} &`]:{backgroundColor:"$neutral200"}},backgroundColor:"$neutral500",[`.${xe} &`]:{backgroundColor:"$neutral200"}},backgroundColor:"$neutral300",[`.${xe} &`]:{backgroundColor:"$neutral400"}},cursor:"pointer"},false:{}}},compoundVariants:[{listItem:!0,selected:!0,css:{outline:"1px solid $secondary"}},{listItem:!1,selected:!0,css:{$$color:"$colors$secondary100",[`.${xe} &`]:{$$color:"$colors$secondary550"},backgroundColor:"$$color","&:hover":{backgroundColor:"$$color"}}},{listItem:!0,selected:!1,css:{cursor:"pointer","&:hover":{backgroundColor:"$neutral300",[`.${xe} &`]:{backgroundColor:"$neutral400"}}}}]}),Yd=An({width:"100%",padding:"$15 $15 $10 $15"}),Zd=An({display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingBottom:"$10",position:"relative"}),Ko=An({display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",".blockchainImage":{marginLeft:"-$8"}}),Jd=An({display:"flex",alignItems:"center",".usd-value":{$$color:"$colors$neutral600",[`.${xe} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),Rd=ze(Rr.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:{[`& ${Gd}`]:{border:"1px $warning500 solid",borderRadius:"100%"}},false:{[`& ${Gd}`]:{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"}}}),em=ze("div",{width:"18px",height:"18px",borderRadius:"100%",display:"flex",justifyContent:"center",alignItems:"center",border:"1.5px transparent solid",img:{borderRadius:"100%"},variants:{state:{error:{borderColor:"$error500"},warning:{borderColor:"$warning500"}}}}),tm=ze(Hr,{width:"100%",background:"inherit"}),xs=ze("div",{display:"flex",justifyContent:"center",alignItems:"center",padding:"$2",transition:`all ${NT}ms ease`,variants:{orientation:{down:{transform:"rotate(0)"},up:{transform:"rotate(180deg)"}}}}),PF=ze("div",{height:"$12",marginLeft:"$10",marginRight:"$10",borderLeft:"1px solid $foreground"}),om=ze("div",{display:"flex",justifyContent:"center",margin:"0 $15",borderTop:"1px solid",$$color:"$colors$neutral300",[`.${xe} &`]:{$$color:"$colors$neutral400"},borderColor:"$$color"}),nm=ze("div",{width:"$16",height:"$16",justifyContent:"center",alignItems:"center",display:"flex"}),Es=ze(AT,{overflow:"hidden",textOverflow:"ellipsis",letterSpacing:.4}),rm=ze("div",{display:"flex",flexWrap:"wrap"}),Is=ze("div",{width:"18px",height:"18px",borderRadius:"100%",backgroundColor:"$background",cursor:"default",display:"flex",justifyContent:"center",alignItems:"center",border:"1.5px transparent solid",variants:{state:{error:{borderColor:"$error500"},warning:{borderColor:"$warning500"}}}}),im=ze("div",{display:"flex"}),ei=ze("div",{width:"100%",borderTopWidth:"1px",borderTopStyle:"solid",borderTopColor:"$neutral",margin:"$5 0",[`.${xe} &`]:{borderTopColor:"$neutral800"}});import{i18n as At}from"@lingui/core";import{ChevronDownIcon as BT,CloseIcon as MT,Divider as ni,IconButton as LT,NumericTooltip as PT,QuoteCost as _T,Typography as yt}from"@rango-dev/ui";import Z,{useState as cm}from"react";import{css as WT,styled as ti}from"@rango-dev/ui";var oi=ti("div",{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"$5 0","&.total_payable_fee":{padding:"$12 0"}}),As=ti("div",{width:"100%",borderTop:"1px solid $neutral300",margin:"$10 0"}),am=ti("div",{padding:"$20 0",display:"flex",flexDirection:"column","& .collapsible_trigger":{display:"flex",alignItems:"center"}}),sm=ti("div",{padding:"$20 $20 $10",position:"relative","._icon-button":{position:"absolute",zIndex:10,top:"$16",right:"$16"}}),lm=WT({display:"flex",flexDirection:"row",alignItems:"center",padding:"$5","&:hover":{"& ._typography, & svg":{color:"$secondary"}}});var DT=i(t=>t.fee.isZero()?null:Z.createElement(oi,null,Z.createElement(yt,{variant:"label",size:"medium",color:"neutral600"},t.label),Z.createElement(yt,{variant:"label",size:"medium"},"$",L(t.fee,4,4))),"NonPayableFee");function Ns(t){let[e,o]=cm(!1),[n,r]=cm(!1),{steps:a,quote:s,fee:l,time:c,feeWarning:u,timeWarning:p,showModalFee:d,fullExpandedMode:h=!1}=t,m=s?.swaps??[],f=h?no():N(),g=ou(m);return Z.createElement(Z.Fragment,null,Z.createElement(_T,{onClickFee:d?C=>{C.stopPropagation(),o(!e)}:void 0,fee:l,feeWarning:u,timeWarning:p,time:c,steps:a,tooltipGas:d?At.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(sm,{style:{textAlign:h?"left":"center"}},Z.createElement(yt,{variant:"title",size:"medium"},At.t("Gas & Fee Explanation")),Z.createElement(LT,{id:"widget-quote-cost-details-modal-close-icon-btn",onClick:()=>o(!1),variant:"ghost"},Z.createElement(MT,{color:"gray",size:14}))),onClose:()=>{o(!1)}},Z.createElement(am,null,Z.createElement(yt,{variant:"title",size:"small"},At.t("Details")),Z.createElement(ni,{size:10}),Object.entries(g.payable).flatMap(([C,S])=>S.map((k,T)=>{let v=`payable-fee-${T}`,w=Wa(k);return Z.createElement(oi,{key:v},Z.createElement(yt,{variant:"label",size:"medium",color:"neutral600"},xa(C,At.t)),Z.createElement(PT,{content:k.amount,container:f},Z.createElement(yt,{variant:"label",size:"medium"},L(k.amount,2,2)," ",k.asset.symbol," ($",L(w,4,4),")")))})),Z.createElement(oi,{className:"total_payable_fee"},Z.createElement(yt,{variant:"label",size:"medium"},At.t("Total Payable Fee")),Z.createElement(yt,{variant:"label",size:"medium"},"$",L(l,4,4))),Z.createElement(As,null),Object.keys(g.nonePayable).length&&Z.createElement(Kr,{triggerAnchor:"bottom",onClickTrigger:()=>r(C=>!C),trigger:Z.createElement("div",{className:lm()},Z.createElement(yt,{size:"small",variant:"body",color:"neutral700"},n?At.t("Hide non-payable fees"):At.t("Show non-payable fees")),Z.createElement(ni,{size:4,direction:"horizontal"}),Z.createElement(Gr,{orientation:n?"up":"down"},Z.createElement(BT,{size:12,color:"gray"}))),open:n},Z.createElement(yt,{size:"small",variant:"title"},At.t("Description")),Z.createElement(ni,{size:4}),Z.createElement(yt,{size:"small",variant:"body",color:"neutral700"},At.t(`The following fees are considered in the transaction output and
2
- you won\u2019t need to pay extra gas for them.`)),Z.createElement(ni,{size:10}),Object.entries(g.nonePayable).map(([C,S],k)=>{let T=tu(S),v=xa(C,At.t),w=`non-payable-fee-${k}`;return Z.createElement(DT,{key:w,fee:T,label:v})}),Z.createElement(As,null)))))}i(Ns,"QuoteCostDetails");import{i18n as dm}from"@lingui/core";import{TokenAmount as mm}from"@rango-dev/ui";import ri from"react";import{css as $T,styled as FT}from"@rango-dev/ui";var pm=FT("div",{position:"relative",display:"flex",flexDirection:"column",width:"100%"}),um=$T({height:"14px",marginLeft:"14px",position:"absolute",borderLeft:"1px solid $foreground",top:"42%"});function Nn(t){let{from:e,to:o,percentageChange:n,warningLevel:r}=t;return ri.createElement(pm,null,ri.createElement(mm,{direction:"horizontal",label:dm.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}}),ri.createElement("div",{className:um()}),ri.createElement(mm,{direction:"horizontal",tooltipContainer:N(),label:dm.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(Nn,"QuoteSummary");import{i18n as Sm}from"@lingui/core";import{ChevronDownIcon as zT,ChevronRightIcon as QT,Divider as Ws,Image as qT,Tooltip as ci,Typography as ai}from"@rango-dev/ui";import z from"react";import{useLayoutEffect as OT,useState as Wn}from"react";var fm=480,gm=768,hm=1024,ym=1200,UT=i(()=>{let[t,e]=Wn(!1),[o,n]=Wn(!1),[r,a]=Wn(!1),[s,l]=Wn(!1),[c,u]=Wn(!1),p=i(()=>{e(window.innerWidth<=fm),n(window.innerWidth>fm&&window.innerWidth<=gm),a(window.innerWidth>gm&&window.innerWidth<=hm),l(window.innerWidth>hm&&window.innerWidth<=ym),u(window.innerWidth>ym)},"handleResize");return OT(()=>(p(),window.addEventListener("resize",p),()=>window.removeEventListener("resize",p)),[]),{isMobile:t,isTablet:o,isNotebook:r,isLargeScreen:s,isExtraLargeScreen:c}},"useScreenDetect"),ii=UT;var si=4,li=6,Bn=i(t=>{let{content:e,src:o,className:n,open:r,state:a,container:s}=t,l=s||N();return z.createElement(ci,{container:l,side:"bottom",sideOffset:4,open:r,content:e},z.createElement(em,{className:n,state:a},z.createElement(qT,{src:o,size:16})))},"ImageComponent");function Cm(t){let{quoteRef:e,selected:o,setExpanded:n,steps:r,expanded:a,type:s,container:l}=t,c=l||N(),u=r.length,p=Gp(r),{isTablet:d,isMobile:h}=ii();return z.createElement(Rd,{listItem:s==="list-item",ref:m=>e.current=m,selected:o,onClick:m=>{m.stopPropagation(),n(f=>!f)}},z.createElement("div",{className:Ko()},z.createElement(ai,{variant:"body",size:"xsmall"},Sm.t("Via:")),z.createElement(Ws,{direction:"horizontal",size:4}),r.map((m,f)=>{let g=`item-${f}`,C=z.createElement(xs,null,z.createElement(QT,{size:12,color:"black"}));return h||d?z.createElement(z.Fragment,{key:g},z.createElement(Bn,{content:m.swapper.displayName,src:m.swapper.image,state:m.state,container:l}),f!==u-1&&z.createElement(z.Fragment,null,C)):z.createElement(z.Fragment,{key:g},u<=si||u>si&&f<si-1?z.createElement(z.Fragment,null,z.createElement(Bn,{content:m.swapper.displayName,src:m.swapper.image,state:m.state,container:l}),f!==u-1&&z.createElement(z.Fragment,null,C)):f===si-1&&z.createElement(ci,{container:c,side:"bottom",align:"end",sideOffset:4,content:z.createElement("div",{className:Ko()},C,r.map((S,k)=>{let T=`image-${k}`;return k>=f&&z.createElement(z.Fragment,{key:T},z.createElement(Bn,{content:S.swapper.displayName,src:S.swapper.image,state:S.state,open:!1}),k!==u-1&&z.createElement(z.Fragment,null,C))}))},z.createElement(Is,{state:r.find((S,k)=>k>=f&&(S.state==="error"||S.state==="warning"))?.state},z.createElement(ai,{size:"xsmall",variant:"body"},"+",u-f))))})),z.createElement("div",{className:Ko()},z.createElement("div",{className:"blockchains_section"},z.createElement("div",{className:Ko()},z.createElement(ai,{variant:"body",size:"xsmall"},Sm.t("Chains:")),z.createElement(Ws,{direction:"horizontal",size:4}),p.map((m,f)=>z.createElement(z.Fragment,{key:m.displayName},p.length<=li||p.length>li&&f<li-1?z.createElement(ci,{container:c,side:"bottom",content:m.displayName,sideOffset:4},z.createElement(Bn,{content:"",src:m.image,open:!1,className:f!==0?"blockchainImage":""})):f===li-1&&z.createElement(ci,{container:c,side:"bottom",align:"end",sideOffset:4,content:z.createElement("div",{className:Ko()},p.map((g,C)=>C>=f&&z.createElement(Bn,{key:g.displayName,content:"",src:g.image,open:!1,className:C>f?"blockchainImage":"",container:l})))},z.createElement(Is,{className:"blockchainImage"},z.createElement(ai,{size:"xsmall",variant:"body"},"+",p.length-f))))),z.createElement(Ws,{direction:"horizontal",size:32}))),z.createElement(xs,{orientation:a?"up":"down"},z.createElement(zT,{size:12,color:"black"}))))}i(Cm,"QuoteTrigger");function Ms(t){let{quote:e,input:o,output:n,error:r,warning:a,type:s,selected:l=!1,tagHidden:c=!0,showModalFee:u=!0,onClickAllRoutes:p,fullExpandedMode:d=!1,container:h}=t,m=y().blockchains(),{findToken:f}=y(),g=y().swappers(),{customSlippage:C,slippage:S}=y(),k=C||S,[T,v]=ZT(t.expanded),w=YT(null),A=L(o.value,6,6),M=L(n.value,6,6),x=n.usdValue?L(n.usdValue,4,4):"",E=Pt(o.usdValue,n.usdValue??null),b=L(E,2,2),I=_t(E??0),W=i((le,at)=>le.map((V,_)=>{let G,K=r?.type===3&&r.swap.swapperId===V.swapperId,fe=r?.type===4&&r.recommendedSlippages?.has(_),ne=a?.type===2&&a.recommendedSlippages?.has(_),ge=K||fe,Fe=ne;ge?G="error":Fe&&(G="warning");let ve=ge?ho.t("Slippage Error"):ho.t("Slippage Warning");return K&&(ve=ho.t("Bridge Limit Error")),{swapper:{displayName:on(V.swapperId,g)??"",image:V.swapperLogo},from:{token:{displayName:V.from.symbol,image:V.from.logo},chain:{displayName:st(V.from.blockchain,m)??"",image:V.from.blockchainLogo},price:{value:_===0&&!at?L(o.value,6,6):L(V.fromAmount,6,6),usdValue:L((V.from.usdPrice??0)*parseFloat(V.fromAmount),4,4),realValue:_===0?o.value:V.fromAmount,realUsdValue:new Bs(V.from.usdPrice??0).multipliedBy(V.fromAmount).toString()}},to:{token:{displayName:V.to.symbol,image:V.to.logo},chain:{displayName:st(V.to.blockchain,m)||"",image:V.to.blockchainLogo},price:{value:L(V.toAmount,6,6),usdValue:L((V.to.usdPrice??0)*parseFloat(V.toAmount),4,4),realValue:V.toAmount,realUsdValue:new Bs(V.to.usdPrice??0).multipliedBy(V.toAmount).toString()}},state:G,alerts:ge||Fe?F.createElement(qd,{dense:d},F.createElement(HT,{variant:"alarm",type:ge?"error":"warning",title:ve,footer:F.createElement(Hd,null,K&&F.createElement("div",null,F.createElement(Xo,{size:"xsmall",variant:"body",color:"neutral900"},r.fromAmountRangeError),F.createElement(jo,{direction:"vertical",size:2}),F.createElement(Xo,{size:"xsmall",variant:"body",color:"neutral900"},ho.t({id:"Yours: {amount} {symbol}",values:{amount:L(V.fromAmount,6,6),symbol:V?.from.symbol}}))),(fe||ne)&&!K&&F.createElement("div",null,F.createElement(Xo,{size:"xsmall",variant:"body",color:"neutral900"},ho.t({id:"Minimum required slippage: {minRequiredSlippage}",values:{...r?.type===4&&{minRequiredSlippage:r.recommendedSlippages?.get(_)},...a?.type===2&&{minRequiredSlippage:a.recommendedSlippages?.get(_)}}})),F.createElement(jo,{direction:"vertical",size:2}),F.createElement(Xo,{size:"xsmall",variant:"body",color:"neutral900"},ho.t({id:"Yours: {userSlippage}",values:{userSlippage:k}}))))})):void 0,time:an(V.estimatedTimeInSeconds),fee:L(Na(V,f),2,2),internalSwaps:V.internalSwaps?W(V.internalSwaps):void 0}}),"getQuoteSteps"),B=W(e?.swaps??[]),U=B.length,j=h||N(),R=Kp(t.quote.tags||[]),P=!!p,Y=pr(e?.swaps),se=an(Y),Q=Br(e?.swaps??[],f),me=L(Q,2,2),vt=Q.gte(new Bs($p)),Ze=Y/Op>=Fp;return d?F.createElement(GT,{selected:l,fee:me,time:se,tooltipContainer:no(),steps:B,tags:R,quoteCost:F.createElement(Ns,{quote:e,fullExpandedMode:!0,time:se,fee:me,feeWarning:vt,timeWarning:Ze,showModalFee:u,steps:U}),percentageChange:b,warningLevel:I,outputPrice:{value:M,usdValue:x,realValue:n.value,realUsdValue:n.usdValue}}):F.createElement(Xd,{selected:l,listItem:s==="list-item",basic:s==="basic"},F.createElement("div",{className:Yd()},!c&&R.length?F.createElement(F.Fragment,null,F.createElement(im,null,R.map((le,at)=>{let V=`${le.value}_${at}`;return F.createElement(F.Fragment,{key:V},F.createElement(KT,{label:le.label,value:le.value}),F.createElement(jo,{size:4,direction:"horizontal"}))})),F.createElement(ei,null),!P&&F.createElement(jo,{size:4})):null,F.createElement("div",{id:"portal-root",className:Zd()},F.createElement(Ns,{quote:e,time:se,fee:me,feeWarning:vt,timeWarning:Ze,showModalFee:u,steps:U}),P&&F.createElement(jd,{onClick:le=>{le.stopPropagation(),p()},size:"xxsmall",type:"secondary",variant:"default",css:{paddingLeft:"$10",paddingRight:"$10",paddingTop:"$5",paddingBottom:"$5"}},F.createElement(Xo,{color:"secondary",variant:"body",size:"xsmall",className:"allRoutesLabel"},ho.t("See All Routes")))),s==="basic"&&F.createElement("div",{className:Jd()},F.createElement(nm,null,F.createElement(VT,{size:12,color:"gray"})),F.createElement(rm,null,F.createElement(Es,{size:"small",variant:"body"},`${A} ${B[0].from.token.displayName} = `),F.createElement(km,{content:n.value,container:j,open:n.value?void 0:!1},F.createElement(Es,{size:"small",variant:"body"},"\xA0",`${M} ${B[B.length-1].to.token.displayName}`))),F.createElement(km,{content:n.usdValue,container:j},F.createElement(jo,{size:2,direction:"horizontal"}),F.createElement(Xo,{color:"$neutral600",size:"xsmall",variant:"body"},`($${x})`))),s==="list-item"&&F.createElement(XT,{tooltipContainer:j,type:"output",direction:"vertical",price:{value:M,usdValue:x,realValue:n.value,realUsdValue:n.usdValue},token:{displayName:B[U-1].to.token.displayName,image:B[U-1].to.token.image},chain:{image:B[U-1].to.chain.image},percentageChange:b,warningLevel:I}),s==="swap-preview"&&F.createElement(F.Fragment,null,F.createElement(Nn,{from:B[0].from,to:B[U-1].to,percentageChange:b,warningLevel:I}),F.createElement(jo,{size:4}))),F.createElement(Vd,{selected:l,listItem:s==="list-item",open:T,className:"quote_container",onOpenChange:v},F.createElement(Cm,{type:s,quoteRef:w,selected:l,setExpanded:v,container:j,expanded:T,steps:B}),F.createElement(tm,{open:T},F.createElement(om,null),F.createElement("div",{className:Kd()},B.map((le,at)=>{let V=`item-${at}`;return F.createElement(jT,{type:"quote-details",key:V,tooltipContainer:j,step:le,hasSeparator:at!==B.length-1,state:le.state})})))))}i(Ms,"Quote");import{Divider as tv,Skeleton as ov}from"@rango-dev/ui";import Ot from"react";import{darkTheme as JT,styled as pi}from"@rango-dev/ui";var Tm=pi("div",{$$color:"$colors$neutral100",[`.${JT} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",borderBottomLeftRadius:"$xm",borderBottomRightRadius:"$xm",padding:"$15",variants:{rounded:{true:{borderRadius:"$xm"}},expanded:{true:{paddingBottom:"3px"},false:{paddingBottom:"$12"}}}}),vm=pi("div",{paddingTop:"$2"}),wm=pi("div",{paddingLeft:"$8"}),bm=pi("div",{borderLeft:"1px dashed $foreground",minHeight:" 0",margin:"0px 11.5px",alignSelf:"stretch",variants:{hideSeparator:{true:{minHeight:"unset",height:"0"}}}});import{ChainToken as Pm,Divider as St,Skeleton as tt}from"@rango-dev/ui";import q from"react";import{css as RT,styled as Ft}from"@rango-dev/ui";var Ls=Ft("div",{display:"flex"}),xm=Ft("div",{padding:"$10 $0 $20"}),Em=Ft("div",{padding:"14px $0 $20 $0",display:"flex",flexDirection:"column"}),Im=Ft("div",{display:"flex",justifyContent:"start",alignItems:"center"}),Am=Ft("div",{display:"flex",justifyContent:"space-between",alignItems:"end"}),Nm=Ft("div",{height:"$24",marginLeft:"13px",borderLeft:"1px solid $neutral700"}),Wm=Ft("div",{width:"65%",display:"flex",justifyContent:"start"}),Bm=Ft("div",{display:"flex",flexDirection:"column",alignItems:"start",flexGrow:1,maxWidth:"148px"}),Mm=Ft("div",{padding:"$15 $0 $15 $0"}),Lm=RT({display:"flex",justifyContent:"space-between",alignItems:"center"});function Mn(t){let{type:e,tagHidden:o=!0}=t,n=q.createElement(Am,null,q.createElement(Wm,null,q.createElement(Pm,{loading:!0,size:"medium",chainImage:"",tokenImage:""}),q.createElement(St,{size:8,direction:"horizontal"}),q.createElement(Bm,null,q.createElement(tt,{height:10,width:60,variant:"rounded"}),q.createElement(St,{size:4}),q.createElement(tt,{height:15,variant:"rounded"}))),q.createElement(tt,{height:12,width:64,variant:"rounded"})),r=e==="basic"&&!o;return q.createElement("div",null,!o&&q.createElement(q.Fragment,null,q.createElement(Ls,null,q.createElement(tt,{width:65,height:20,variant:"rounded"}),q.createElement(St,{size:4,direction:"horizontal"}),q.createElement(tt,{width:65,height:20,variant:"rounded"}),q.createElement(St,{size:4,direction:"horizontal"}),q.createElement(tt,{width:65,height:20,variant:"rounded"})),q.createElement(ei,null),!r&&q.createElement(St,{size:4})),q.createElement("div",{className:Lm()},q.createElement(Ls,null,q.createElement(tt,{width:60,height:10,variant:"rounded"}),q.createElement(St,{size:4,direction:"horizontal"}),q.createElement(tt,{width:60,height:10,variant:"rounded"}),q.createElement(St,{size:4,direction:"horizontal"}),q.createElement(tt,{width:60,height:10,variant:"rounded"})),r&&q.createElement(tt,{width:85,height:24,variant:"rounded"})),e==="basic"&&q.createElement(xm,null,q.createElement(tt,{height:15,width:148,variant:"rounded"})),e==="list-item"&&q.createElement(Em,null,q.createElement(Im,null,q.createElement(Pm,{loading:!0,size:"medium",chainImage:"",tokenImage:""}),q.createElement(St,{direction:"horizontal",size:4}),q.createElement(tt,{height:15,width:150,variant:"rounded"})),q.createElement(St,{size:10}),q.createElement(tt,{height:10,width:184,variant:"rounded"})),e==="swap-preview"&&q.createElement(q.Fragment,null,q.createElement(St,{size:4}),q.createElement(Mm,null,n,q.createElement(Nm,null),n),q.createElement(St,{size:12})))}i(Mn,"QuoteSummarySkeleton");import{ChainToken as Om,Divider as _s,NextIcon as ev,Skeleton as ui}from"@rango-dev/ui";import Ee from"react";import{styled as Ln}from"@rango-dev/ui";var _m=Ln("div",{display:"flex",alignItems:"start"}),Dm=Ln("div",{flexGrow:1,paddingTop:"$5",paddingBottom:"$10",display:"flex",alignItems:"center",variants:{extraSpace:{true:{paddingBottom:"$40"}}}}),Ps=Ln("div",{display:"flex",alignItems:"center",flexGrow:1}),$m=Ln("div",{margin:"$0 $2",padding:"$4",display:"flex",justifyContent:"center",alignItems:"center"}),Fm=Ln("div",{display:"flex",alignItems:"center"});function Nt(t){let{separator:e=!0}=t;return Ee.createElement(Ee.Fragment,null,Ee.createElement(Fm,null,Ee.createElement(ui,{height:22,width:22,variant:"circular"}),Ee.createElement(_s,{direction:"horizontal",size:8}),Ee.createElement(ui,{height:15,width:148,variant:"rounded"})),Ee.createElement(_m,null,Ee.createElement(bm,{hideSeparator:!e}),Ee.createElement(Dm,{extraSpace:e},Ee.createElement(Ps,null,Ee.createElement(Om,{size:"small",loading:!0,chainImage:"",tokenImage:""}),Ee.createElement(_s,{direction:"horizontal",size:8}),Ee.createElement(ui,{height:12,variant:"rounded"})),Ee.createElement($m,null,Ee.createElement(ev,{color:"gray",size:16})),Ee.createElement(Ps,null,Ee.createElement(Om,{size:"small",loading:!0,chainImage:"",tokenImage:""}),Ee.createElement(_s,{direction:"horizontal",size:8}),Ee.createElement(ui,{height:12,variant:"rounded"})))))}i(Nt,"StepSkeleton");function Pn(t){let{type:e,expanded:o,tagHidden:n=!1}=t;return Ot.createElement(Tm,{expanded:o,rounded:e!=="basic"},Ot.createElement(Mn,{type:e,tagHidden:n}),Ot.createElement(vm,null,Ot.createElement(ov,{height:15,variant:"rounded"})),o&&Ot.createElement(wm,null,Ot.createElement(tv,{size:24}),Ot.createElement(Nt,null),Ot.createElement(Nt,null),Ot.createElement(Nt,{separator:!1})))}i(Pn,"QuoteSkeleton");function yo(t){let{quote:e,type:o,loading:n,error:r,warning:a,expanded:s=!1,tagHidden:l,onClick:c,showModalFee:u,selected:p,onClickAllRoutes:d,fullExpandedMode:h=!1,container:m}=t,{inputAmount:f,inputUsdValue:g}=O(),C=e?.outputAmount?new nv(e?.outputAmount):null,S=e?ct(e):null,T=!(r&&(r.type===0||r.type===1))&&e&&!n;return n?di.createElement(bs,null,di.createElement(Pn,{tagHidden:l,type:o,expanded:s})):T?di.createElement(bs,{onClick:()=>c?.(e)},di.createElement(Ms,{quote:e,error:r,container:m,showModalFee:u,warning:a,tagHidden:l,selected:p,type:o,expanded:s,onClickAllRoutes:d,fullExpandedMode:h,input:{value:f,usdValue:g?.toString()??""},output:{value:C?.toString()??"",usdValue:S?.toString()??""}})):null}i(yo,"QuoteInfo");import{calculatePendingSwap as sv}from"@rango-dev/queue-manager-rango-preset";import{useEffect as lv}from"react";import{useRef as rv,useState as iv}from"react";var av=2e3;function mi({request:t}){let[e,o]=iv(!1),n=rv(null),r=i(()=>n.current?.abort(),"cancelFetch"),a=i(async l=>(await new Promise(c=>setTimeout(c,av)),await s(l,!1)),"retryFetch"),s=i(async(l,c=!1)=>{r(),n.current=new AbortController,o(!0);try{let u=await t(l,{signal:n.current.signal});return n.current=null,u}catch(u){if(c)return await a(l);throw u}finally{o(!1)}},"fetch");return{fetch:s,loading:e,cancelFetch:r}}i(mi,"useFetch");function Um(){let{fetch:t,loading:e,cancelFetch:o}=mi({request:async(n,r)=>await xt().confirmRoute(n,r)});return{fetch:t,loading:e,cancelFetch:o}}i(Um,"useFetchConfirmQuote");function fi(t){if(!t.swaps)throw new Error(ee().noResultError.title,{cause:{type:0,diagnosisMessage:t.diagnosisMessages?.[0]}});let e=Ds(t.swaps);if(e)throw new Error(e.message,{cause:e.options})}i(fi,"throwErrorIfResponseIsNotValid");function Ds(t){if(Jp(t)){let{swap:n,recommendation:r,fromAmountRangeError:a}=Rp(t);return{message:"bridge limit error",options:{type:3,swap:n,recommendation:r,fromAmountRangeError:a}}}let o=nu(t);if(o){let n=Mr(t);return{message:"",options:{type:4,recommendedSlippages:o,minRequiredSlippage:n}}}return null}i(Ds,"getQuoteError");function zm(t){let{currentQuote:e,previousQuote:o,meta:n,selectedWallets:r,userSlippage:a,findToken:s}=t,l={quote:null,balance:null},c=Do({previousQuote:o,currentQuote:e,findToken:s,userSlippage:a});c&&(l.quote=c);let u=au(e,r,n.blockchains);return u.length===0||(l.balance={messages:u}),l}i(zm,"generateWarnings");function gi(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(gi,"handleQuoteErrors");function $s(){let{fromToken:t,toToken:e,inputAmount:o,inputUsdValue:n,setSelectedQuote:r,selectedQuote:a,customDestination:s,resetAlerts:l}=O(),{slippage:c,customSlippage:u}=y(),p=y().getDisabledLiquiditySources(),d=y().blockchains(),h=y().tokens(),{findToken:m}=y(),f=u||c,{fetch:g,cancelFetch:C,loading:S}=Um();return lv(()=>C,[]),{loading:S,fetch:i(async T=>{let v=T.selectedWallets,w=T?.customDestination??s;if(!t||!e||!o)return{quote:null,swap:null,error:null,warnings:null};let A=v.reduce((x,E)=>(x[E.chain]=E.address,x),{}),M={requestId:a?.requestId||"",selectedWallets:A,destination:w||void 0};try{return await g(M,!0).then(x=>{let{result:E}=x;if(!E)throw new Error("Error fetching updated route");fi({diagnosisMessages:E.diagnosisMessages,requestId:E.requestId,swaps:E.result?.swaps});let b={outputAmount:E.result?.outputAmount,requestId:E.requestId,resultType:E.result?.resultType,swaps:E.result?.swaps||[],validationStatus:E.validationStatus,requestAmount:E.requestAmount};r(b);let I={slippage:f.toString(),disabledSwappersGroups:p},W=zm({previousQuote:a??void 0,currentQuote:b,meta:{blockchains:d},selectedWallets:v,userSlippage:f,inputUsdValue:n,findToken:m});l();let B=!!W.balance,U=sv(o.toString(),E,iu(v),I,!B,{blockchains:d,tokens:h});return{quote:b,swap:U,error:null,warnings:W}})}catch(x){return gi(x)}},"fetch"),cancelFetch:C}}i($s,"useConfirmSwap");var Sv=dv("div",{width:"100%",display:"flex",justifyContent:"space-between",[`& ${Qm}`]:{width:"$48",height:"$48"}}),Cv=Us({flexGrow:1,paddingRight:"$10"}),kv=Us({width:"$24",height:"$24",display:"flex",justifyContent:"center",alignItems:"center"}),Tv=Us({display:"flex",justifyContent:"space-between",alignItems:"center"});function qm(){let{selectedQuote:t,setInputAmount:e,selectedWallets:o,quoteWalletsConfirmed:n,customDestination:r,quoteWarningsConfirmed:a}=O(),s=yv(),[l,c]=_n(""),u=!n,[p,d]=_n(!1),[h,m]=_n(!1),{isActiveTab:f}=re(),g=y().getDisabledLiquiditySources(),C=hv(g),{manager:S}=cv(),{fetch:k,loading:T,cancelFetch:v}=$s(),[w,A]=_n({swap:null,error:null,warnings:null}),[M,x]=_n(!1),E=i(async({selectedWallets:P,customDestination:Y})=>{let se=await k?.({selectedWallets:P,customDestination:Y});return A(se),se},"onConfirmSwap"),b=i(async()=>{if(w.swap&&n)try{await S?.create("swap",{swapDetails:w.swap},{id:w.swap.requestId});let P=`../${$.swaps}/${w.swap.requestId}`;s(P,{replace:!0}),setTimeout(()=>{e("")},0)}catch(P){c("Error: "+P?.message)}},"addNewSwap"),I=i(async()=>{m(!0),await b(),m(!1)},"onConfirm"),W=i(async()=>{w.warnings?.quote&&Hp(w.warnings.quote)&&!a?x(!0):await I()},"onStartConfirmSwap"),B=i(async()=>{A({error:null,swap:null,warnings:null}),k({selectedWallets:o,customDestination:r}).then(P=>{A(P)}).catch(P=>console.error(P))},"onRefresh");hi(()=>{!!C.current.length&&!g.length&&B(),C.current=g},[g.length]),hi(()=>{u&&v()},[u]),hi(()=>{u&&d(u)},[u]),hi(()=>{u||k({selectedWallets:o,customDestination:r}).then(P=>A(P)).catch(P=>console.error(P))},[]),gv(()=>{t?.requestId||s(`../${location.search}`)},[t?.requestId]);let U=w.warnings?.quote??null,j=w.error,R=[];if(l&&R.push(Le.createElement(pv,{type:"error",variant:"alarm",title:l})),U||j){let P=`../${$.settings}`;R.push(Le.createElement(In,{warning:U,error:j,couldChangeSettings:!1,refetchQuote:B,showWarningModal:M,confirmationDisabled:!f,onOpenWarningModal:()=>x(!0),onCloseWarningModal:()=>x(!1),onConfirmWarningModal:async()=>{x(!1),await b()},onChangeSettings:()=>s(P)}))}return Le.createElement(oe,{header:{title:Fs.t("Confirm Swap"),onWallet:()=>{let P=`../${$.wallets}`;s(P)}},footer:Le.createElement(Sv,null,Le.createElement("div",{className:Cv()},Le.createElement(uv,{id:"widget-confirm-swap-start-btn",variant:"contained",type:"primary",size:"large",fullWidth:!0,loading:T||h,disabled:!!w.error||!f,onClick:W},Fs.t("Start Swap"))),Le.createElement(Qm,{id:"widget-confirm-swap-wallet-icon-btn",variant:"contained",type:"primary",size:"large",loading:T||h,disabled:!f,onClick:d.bind(null,!0)},Le.createElement(fv,{size:24})))},p&&Le.createElement(bd,{open:p,onClose:()=>d(!1),onCancel:v,loading:T,onCheckBalance:E}),Le.createElement(ie,null,Le.createElement("div",{className:Tv()},Le.createElement(mv,{variant:"title",size:"small"},Fs.t("You get")),Le.createElement("div",{className:kv()},Le.createElement(Fr,{onClick:!T&&!p&&!M?B:void 0}))),Le.createElement(Os,{size:"12"}),xu(R.map((P,Y)=>({element:P,key:`alert-${Y}`})),Le.createElement(Os,{size:10})),R.length>0?Le.createElement(Os,{size:10}):null,Le.createElement(yo,{quote:t,type:"swap-preview",expanded:!0,tagHidden:!0,error:w.error,loading:T,warning:w.warnings?.quote??null})))}i(qm,"ConfirmSwapPage");import{i18n as Ut}from"@lingui/core";import{Button as Zs,CustomTokensZeroStateDarkIcon as $v,CustomTokensZeroStateIcon as Fv,DeleteIcon as Ov,Divider as On,IconButton as Uv,MessageBox as zv,NotFound as Qv,styled as Rs}from"@rango-dev/ui";import de,{useState as Js}from"react";import{useNavigate as qv}from"react-router-dom";import{CloseIcon as wv,IconButton as bv,SearchIcon as xv,TextField as Ev}from"@rango-dev/ui";import Dn from"react";import{styled as vv}from"@rango-dev/ui";var Hm=vv("div",{width:"$24",height:"$24",display:"flex",alignItems:"center",justifyContent:"center"});function Ct(t){let{variant:e,fullWidth:o,color:n,size:r,onChange:a,value:s,style:l,setValue:c,...u}=t;return Dn.createElement(Ev,{prefix:Dn.createElement(Hm,null,Dn.createElement(xv,{color:"black"})),suffix:!!s.length&&Dn.createElement(bv,{variant:"ghost",onClick:()=>c?.(""),size:"small"},Dn.createElement(wv,{color:"gray",size:10})),fullWidth:o,color:n,variant:e,style:{padding:10,borderRadius:25,alignItems:"center",...l},size:r,value:s,onChange:a,...u})}i(Ct,"SearchInput");import{i18n as Ys}from"@lingui/core";import{darkTheme as tf,Divider as Zo,ExternalLinkIcon as Nv,Image as Wv,ListItemButton as Bv,NotFound as Mv,PinIcon as Lv,Skeleton as of,Typography as Ci,VirtualizedList as Pv}from"@rango-dev/ui";import H from"react";import{Divider as Rm,ListItem as Av,Skeleton as $n}from"@rango-dev/ui";import kt from"react";import{css as Yo,darkTheme as Gm,ImageContainer as Iv,styled as ut,Typography as Vm}from"@rango-dev/ui";var zs=Yo({position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:100,overflow:"hidden"}),Qs=Yo({position:"relative",height:12,width:"30%",maxWidth:"150px"}),qs=Yo({position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",bottom:"-8px"}),Hs=Yo({transform:"translateY(12px)",visibility:"hidden",display:"flex","& a":{display:"flex",justifyContent:"center",alignItems:"center",fontSize:"$12",lineHeight:"$16",$$color:"$colors$neutral600",[`.${Gm} &`]:{$$color:"$colors$neutral700"},color:"$$color",textDecoration:"none"}}),Gs=Yo({}),Vs=Yo(),Km=ut("div",{display:"flex",flexDirection:"column",flexGrow:1,overflow:"hidden",justifyContent:"center"}),Ks=ut("div",{display:"flex",alignItems:"center","._typography":{textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:100,overflow:"hidden"}}),yi=ut("ul",{flexGrow:1,padding:0,margin:0,listStyle:"none","& li":{alignItems:"none","&:hover":{[`& .${Qs}`]:{[`& .${Hs}`]:{position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",visibility:"visible"},[`& .${Gs}`]:{bottom:"-15px"},[`& .${zs}`]:{position:"absolute",transform:"translateY(-12px)",visibility:"hidden"},[`& .${qs}`]:{position:"absolute",transform:"translateY(-12px)",bottom:"-10px"}}}}}),js=ut("div",{paddingLeft:"$5",paddingRight:"$5",borderRadius:"$md",display:"flex",alignItems:"center"}),Xs=ut(Vm,{}),jm=ut("div",{textAlign:"right",width:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",[`& .${Vs}`]:{$$color:"$colors$neutral600",[`.${Gm} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),Si=ut("div",{display:"flex",alignItems:"end",flexDirection:"column"}),AU=ut("div",{display:"flex",alignItems:"center"}),Xm=ut("div",{position:"relative",[`& ${Iv}`]:{borderRadius:"$xm",overflow:"hidden"}}),Ym=ut("div",{position:"absolute",backgroundColor:"$neutral100",padding:"$4",borderRadius:"50%",bottom:-6,right:-6}),Zm=ut(Vm,{width:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}),Jm=ut("a",{"& svg:hover":{color:"$colors$info"}});function ef(t){return kt.createElement(yi,null,Array.from(Array(t.size),e=>kt.createElement(Av,{key:e,hasDivider:!0,start:kt.createElement($n,{variant:"circular",width:35,height:35}),end:kt.createElement(Si,null,kt.createElement($n,{variant:"text",size:"large",width:70}),kt.createElement(Rm,{size:4}),kt.createElement($n,{variant:"text",size:"medium",width:50})),title:kt.createElement("div",null,kt.createElement($n,{variant:"text",size:"large",width:90}),kt.createElement(Rm,{size:4}),kt.createElement($n,{variant:"text",size:"medium",width:90}))})))}i(ef,"LoadingTokenList");var _v=20,Dv=i(t=>{let{address:e,name:o,url:n,token:r,customCssForTag:a,customCssForTagTitle:s}=t,l=e.length;return H.createElement("div",{className:Qs()},o?H.createElement("div",{className:zs()},o):H.createElement(Ks,{className:qs()},H.createElement(Ci,{variant:"title",size:"xmedium"},r.symbol),H.createElement(Zo,{direction:"horizontal",size:4}),H.createElement(js,{css:a},H.createElement(Xs,{variant:"body",size:"xsmall",css:s},r.blockchain))),!!e&&H.createElement("div",{className:`${Hs()} ${!o&&Gs()}`},l>10?`${e.slice(0,5)}...${e.slice(l-6,l)}`:e," ",H.createElement(Zo,{size:4,direction:"horizontal"}),H.createElement(Jm,{href:n,target:"_blank",rel:"nofollow noreferrer",onClick:c=>c.stopPropagation()},H.createElement(Nv,{size:12}))))},"renderDesc");function Fn(t){let{list:e,searchedFor:o="",onChange:n,selectedBlockchain:r,showTitle:a=!0,action:s}=t,l=y().fetchStatus,c=y().blockchains(),{getBalanceFor:u,fetchingWallets:p}=y(),{isTokenPinned:d}=y(),h=i(f=>{let g=gr(u(f));return s?s(f):p?H.createElement(Si,null,H.createElement(of,{variant:"text",size:"large",width:70}),H.createElement(Zo,{size:4}),H.createElement(of,{variant:"text",size:"medium",width:50})):g&&H.createElement(jm,null,H.createElement(Zm,{variant:"title",size:"small"},g.amount),H.createElement("div",null),g.usdValue&&H.createElement(Ci,{variant:"body",className:Vs(),size:"xsmall"},`$${g.usdValue}`))},"endRenderer"),m=i(()=>H.createElement(Pv,{itemContent:f=>{let g=e[f],C=g.address||"",S=c.find(w=>w.name===g.blockchain),k=qa(S.color,"main"),T={$$color:k.main150,[`.${tf} &`]:{$$color:k.main750},backgroundColor:"$$color"},v={$$color:k.main750,[`.${tf} &`]:{$$color:k.main150},color:"$$color"};return H.createElement("div",{style:{paddingRight:5}},H.createElement(Bv,{style:{width:"100%",overflow:"hidden",height:"60px"},"tab-index":f,key:`${g.symbol}${g.address}`,id:`${g.symbol}${g.address}`,className:"widget-token-list-item-btn",hasDivider:!0,onClick:()=>n&&n(e[f]),start:H.createElement(Xm,null,H.createElement(Wv,{src:g.image,size:30}),t.type!=="custom-token"&&d(g,t.type)&&H.createElement(Ym,null,H.createElement(Lv,{size:12,color:"gray"}))),title:S?.type==="COSMOS"||g.name||!g.name&&!C?H.createElement(Ks,null,H.createElement(Ci,{variant:"title",size:"xmedium"},g.symbol),H.createElement(Zo,{direction:"horizontal",size:4}),H.createElement(js,{css:T},H.createElement(Xs,{variant:"body",size:"xsmall",css:v},g.blockchain))):void 0,description:S?.info&&C&&S.type!=="COSMOS"?Dv({address:C,token:e[f],customCssForTag:T,customCssForTagTitle:v,name:g.name,url:S.info.addressUrl.split("{wallet}").join(C)}):g.name||void 0,end:h(g)}))},totalCount:e.length,key:`${r}-${o}`}),"renderList");return H.createElement(H.Fragment,null,a&&H.createElement(H.Fragment,null,H.createElement(Ci,{variant:"label",size:"large"},Ys.t("Select Token")),H.createElement(Zo,{size:4})),H.createElement(Km,null,H.createElement(Zo,{size:4}),l==="loading"&&H.createElement(ef,{size:_v}),l==="success"&&(e.length?H.createElement(yi,{as:"ul"},m()):!!o&&H.createElement(Mv,{title:Ys.t("No results found"),description:Ys.t("Try using different keywords")}))))}i(Fn,"TokenList");var Hv=Rs("div",{display:"flex",justifyContent:"space-between",flexDirection:"column",flex:1}),Gv=Rs("div",{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",flex:"0.75"}),Vv=Rs(Uv,{"&:hover":{"& svg":{color:"$secondary550"}}});function nf(){let[t,e]=Js(""),{deleteCustomToken:o}=y(),n=y().customTokens(),{fromToken:r,toToken:a,setFromToken:s,setToToken:l}=O(),{mode:c}=Uo({}),u=qv(),[p,d]=Js(!1),[h,m]=Js(),f=i(k=>{let T=k.target.value;e(T)},"handleSearch"),g=c==="dark",C=n.filter(k=>Je(k.symbol,t)||Je(k.address||"",t)||Je(k.name||"",t)),S=i(()=>{if(h){let k=a?lt(a):null,T=r?lt(r):null,v=lt(h);k===v?l({token:null}):T===v&&s({token:null}),o(h)}d(!1)},"handleDeleteCustomToken");return de.createElement(oe,{header:{title:Ut.t("Custom Tokens")}},de.createElement(ie,null,de.createElement(Hv,null,n.length?de.createElement(de.Fragment,null,de.createElement(Ct,{value:t,setValue:e,fullWidth:!0,color:"light",variant:"contained",placeholder:Ut.t("Search Token"),onChange:f}),de.createElement(On,{size:16}),de.createElement(Fn,{list:C,type:"custom-token",searchedFor:t,showTitle:!1,action:k=>de.createElement(Vv,{id:"widget-custom-token-delete-icon-btn",variant:"ghost",onClick:()=>{d(!0),m(k)}},de.createElement(Ov,{size:12,color:"gray"}))})):de.createElement(Gv,null,de.createElement(Qv,{icon:g?de.createElement($v,{size:200}):de.createElement(Fv,{size:200}),title:Ut.t("No custom tokens"),description:Ut.t("press the button to add your custom token")})),de.createElement(On,{size:20}),de.createElement(Zs,{id:"widget-custom-token-add-btn",type:"primary",variant:"contained",size:"large",onClick:()=>u($.addCustomTokens)},Ut.t("Add Custom Token"))),de.createElement(J,{open:p,dismissible:!0,onClose:()=>d(!1),container:N()},de.createElement(zv,{title:Ut.t("Delete Custom Token"),type:"error",description:Ut.t("Are you sure you want to Delete this Token?")},de.createElement(On,{size:40}),de.createElement(On,{size:10}),de.createElement(Zs,{fullWidth:!0,id:"widget-custom-token-delete-modal-yes-btn",variant:"contained",type:"primary",size:"large",onClick:S},Ut.t("Yes, Delete it")),de.createElement(On,{size:12}),de.createElement(Zs,{id:"widget-custom-token-delete-modal-no-btn",fullWidth:!0,variant:"outlined",type:"primary",size:"large",onClick:()=>d(!1)},Ut.t("No, Continue"))))))}i(nf,"CustomTokensPage");import{i18n as qe}from"@lingui/core";import{useManager as uw}from"@rango-dev/queue-manager-react";import{Button as al,darkTheme as dw,Divider as Co,MessageBox as mw,NotFound as fw,styled as sl,Typography as vi}from"@rango-dev/ui";import{TransactionStatus as Qn}from"rango-types";import ae,{useMemo as wf,useState as wi}from"react";import{useNavigate as gw}from"react-router-dom";import{FilterIcon as Rv,Popover as ew}from"@rango-dev/ui";import So from"react";import{css as Kv,darkTheme as ki,IconButton as jv,styled as Un}from"@rango-dev/ui";var el=Un("div",{position:"relative","&::before":{position:"absolute",right:"1px",top:"-1px",width:"$8",height:"$8",borderRadius:"100%",backgroundColor:"$neutral300",[`.${ki} &`]:{backgroundColor:"$neutral400"},padding:"$2"},variants:{isSelect:{true:{"&::before":{content:""}}}}}),rf=Un(jv,{width:"$36",height:"$36",position:"relative",padding:"0",overflow:"unset",backgroundColor:"$neutral300",[`.${ki} &`]:{backgroundColor:"$neutral400"},"&:hover":{backgroundColor:"$secondary100",[`.${ki} &`]:{backgroundColor:"$neutral"},[`& ${el}::before`]:{backgroundColor:"$secondary100",[`.${ki} &`]:{backgroundColor:"$neutral"}}},variants:{isSelect:{true:{border:"1px solid $secondary"}}}}),af=Un("div",{position:"absolute",width:"$6",height:"$6",display:"flex",justifyContent:"center",alignItems:"center",borderRadius:"3px",top:"$0",right:"1px",backgroundColor:"$secondary500"}),sf=Un("div",{padding:"$15",borderRadius:"$sm",width:"248px",backgroundColor:"$background",zIndex:10}),lf=Kv({display:"flex",justifyContent:"space-between",alignItems:"center"}),cf=Un("ul",{margin:0,listStyle:"none",height:"100%",padding:0,".item-start-container":{paddingRight:"0 !important"}});import{i18n as pf}from"@lingui/core";import{Button as Xv,Divider as uf,ListItemButton as Yv,Radio as Zv,RadioRoot as Jv,Typography as df}from"@rango-dev/ui";import ot from"react";function mf(t){let{filterBy:e,onClickItem:o}=t;return ot.createElement(sf,null,ot.createElement("div",{className:lf()},ot.createElement(df,{size:"small",variant:"body"},pf.t("Status")),ot.createElement(Xv,{id:"widget-filter-selector-reset-btn",variant:"ghost",size:"xxsmall",onClick:()=>o("")},pf.t("Reset"))),ot.createElement(uf,{size:10}),ot.createElement(Jv,{value:e},ot.createElement(cf,null,t.list.map((n,r)=>ot.createElement(Yv,{key:n.id,style:{height:"40px",width:"100%"},selected:!1,hasDivider:t.list.length-1!=r,id:n.id,title:ot.createElement(ot.Fragment,null,ot.createElement(uf,{direction:"horizontal",size:4}),ot.createElement(df,{size:"medium",variant:"body"},n.title)),start:ot.createElement(Zv,{value:n.id}),onClick:o})))))}i(mf,"FilterSelectorContent");function tl(t){let{onClickItem:e,onOpenChange:o,filterBy:n,list:r,open:a}=t;return So.createElement("div",null,So.createElement(ew,{open:a,align:"end",onOpenChange:o,container:N(),content:So.createElement(mf,{list:r,filterBy:n,onClickItem:s=>{e(s),o(!1)}})},So.createElement(rf,{id:"widget-filter-selector-filter-icon-btn",variant:"default",isSelect:!!n,onClick:()=>o(!t.open)},So.createElement(el,{isSelect:!!n},So.createElement(Rv,{size:16,color:"black"}),!!n&&So.createElement(af,null)))))}i(tl,"FilterSelector");import{i18n as nw}from"@lingui/core";import{Divider as Sf,GroupedVirtualizedList as rw,Skeleton as iw,SwapListItem as Cf,Typography as aw}from"@rango-dev/ui";import Qe,{useCallback as kf,useEffect as sw,useRef as lw,useState as cw}from"react";function ff(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(ff,"calculateGroupsSoFar");import{css as tw,darkTheme as ow,styled as zn}from"@rango-dev/ui";var ol=tw(),gf=zn("div",{display:"flex",justifyContent:"center",alignItems:"center",padding:"$5"}),nl=zn("div",{width:"100%",display:"flex",flexDirection:"column",backgroundColor:"$background",padding:"$10 $5 0 $5",[`& .${ol}`]:{$$color:"$colors$neutral600",[`.${ow} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),rl=zn("div",{display:"flex",justifyContent:"flex-start",padding:"$2"}),hf=zn("div",{gap:"$10",display:"flex",flexDirection:"column"}),yf=zn("div",{height:"100%",display:"flex",justifyContent:"center",alignItems:"center"});var pw=10;function il(t){let{list:e,onSwapClick:o,groupBy:n,isLoading:r}=t,[a,s]=cw([]),l=lw(0),{swaps:c,groupCounts:u,groups:p}=n(e),d=kf(ff,[]),h=kf(()=>{let m=e.length-l.current;m&&(l.current+=Math.min(m,pw),s(d(u,l.current)))},[e.length]);if(sw(()=>{r||h()},[r,h]),r){let m=[1,2];return Qe.createElement(Qe.Fragment,null,[m,m].map((g,C)=>Qe.createElement(nl,{key:C},Qe.createElement(rl,null,Qe.createElement(iw,{variant:"text",width:60,size:"small"}),Qe.createElement(Sf,{size:16})),Qe.createElement(Sf,{size:4}),Qe.createElement(hf,null,g.map((k,T)=>Qe.createElement(Cf,{isLoading:!0,key:T}))))))}return Qe.createElement(rw,{endReached:()=>{l.current<e.length&&h()},groupCounts:a,groupContent:m=>Qe.createElement(nl,null,Qe.createElement(rl,null,Qe.createElement(aw,{variant:"label",size:"medium",className:ol()},p[m]))),itemContent:(m,f)=>{let g=c[m];if(!g)return null;let C=g.steps[0],S=g.steps[g.steps.length-1];return Qe.createElement(gf,{key:g.requestId},Qe.createElement(Cf,{requestId:g.requestId,creationTime:g.creationTime,status:g.status,onClick:o,tooltipContainer:N(),onlyShowTime:p[f]===nw.t("Today"),swapTokenData:{from:{token:{image:C.fromLogo,displayName:C.fromSymbol},blockchain:{image:C.fromBlockchainLogo||""},amount:L(g.inputAmount,6,6),realAmount:g.inputAmount},to:{token:{image:S.toLogo,displayName:S.toSymbol},blockchain:{image:S.toBlockchainLogo||""},amount:L(S.outputAmount||S.expectedOutputAmountHumanReadable||"",6,6),realAmount:S.outputAmount||S.expectedOutputAmountHumanReadable||""}}}))}})}i(il,"HistoryGroupedList");import{i18n as Ti}from"@lingui/core";import Tf from"dayjs";var vf=i(t=>{let e=new Map([["today",{title:Ti.t("Today"),swaps:[]}],["week",{title:Ti.t("This week"),swaps:[]}],["month",{title:Ti.t("This month"),swaps:[]}],["year",{title:Ti.t("This year"),swaps:[]}]]);function o(c,u){e.has(c)||e.set(c,{title:c,swaps:[]}),e.get(c)?.swaps.push(u)}i(o,"addYearsToOutput");let n=Tf();t.forEach(c=>{let u=Number(c.creationTime),p=Tf(u);if(n.isSame(p,"day"))e.get("today")?.swaps.push(c);else if(n.isSame(p,"week"))e.get("week")?.swaps.push(c);else if(n.isSame(p,"month"))e.get("month")?.swaps.push(c);else if(n.isSame(p,"year"))e.get("year")?.swaps.push(c);else{let d=new Date(u).getFullYear().toString();o(d,c)}});let r=Array.from(e.values()).filter(c=>c.swaps.length>0),a=r.flatMap(c=>c.swaps),s=r.map(c=>c.swaps.length),l=r.map(c=>c.title);return{swaps:a,groupCounts:s,groups:l}},"groupSwapsByDate");var hw=sl("div",{overflowY:"visible",width:"100%",display:"flex",flexDirection:"column",gap:15,height:"100%"}),yw=sl("div",{display:"flex",justifyContent:"center",alignItems:"center"}),Sw=sl("div",{"._typography":{color:"$neutral700",[`.${dw}&`]:{color:"$neutral900"}}}),Cw=[{id:Qn.SUCCESS,title:qe.t("Complete")},{id:Qn.RUNNING,title:qe.t("Running")},{id:Qn.FAILED,title:qe.t("Failed")}],kw=i((t,e)=>t?.length?t.filter(o=>wt(o.fromBlockchain,e)||wt(o.toBlockchain,e)||wt(o.toSymbol,e)||wt(o.fromSymbol,e)).length:!1,"isStepContainsText");function bf(){let t=gw(),{manager:e,state:o}=uw(),n=pt(e).map(({swap:T})=>T),[r,a]=wi(""),[s,l]=wi(!1),c=!o.loadedFromPersistor,[u,p]=wi(""),[d,h]=wi(!1),m=i(T=>{let v=T.target.value;a(v)},"handleSearch"),f=wf(()=>!r&&!u?n:n.filter(T=>{let{inputAmount:v,status:w,steps:A,requestId:M}=T;return(!r||wt(v,r)||wt(w,r)||kw(A,r)||wt(M,r))&&(!u||u===w)}),[n,r,u]),g=!f?.length&&!c,C=i(()=>h(!1),"onCloseModal"),S=i(async()=>{try{await e?.clearQueue(),h(!1)}catch(T){console.log(T)}},"onClear"),k=wf(()=>!n.some(T=>T.status===Qn.SUCCESS||T.status===Qn.FAILED),[n]);return ae.createElement(oe,{header:{title:qe.t("History"),suffix:ae.createElement(Vt,null,ae.createElement(al,{id:"widget-history-clear-btn",disabled:k,variant:"ghost",size:"xsmall",onClick:()=>h(!0)},ae.createElement(vi,{size:"medium",variant:"label",color:"error"},qe.t("Clear"))))}},ae.createElement(ie,null,ae.createElement(yw,null,ae.createElement(Ct,{setValue:a,fullWidth:!0,variant:"contained",placeholder:qe.t("Search Transaction"),autoFocus:!0,onChange:m,style:{height:36},value:r}),ae.createElement(Co,{size:10,direction:"horizontal"}),ae.createElement(tl,{filterBy:u,open:s,onOpenChange:T=>l(T),onClickItem:T=>p(T),list:Cw})),ae.createElement(Co,{size:"16"}),ae.createElement(hw,null,g&&ae.createElement(yf,null,ae.createElement(Co,{size:32}),ae.createElement(fw,{title:r?qe.t("No results found"):qe.t("No transactions"),titleColor:r?void 0:"$info",hasIcon:!!r,description:r?qe.t("Try using different keywords"):qe.t("Your transaction history is stored locally and will appear here after you start a swap")})),!g&&ae.createElement(il,{list:f,onSwapClick:t,groupBy:vf,isLoading:c}))),ae.createElement(J,{open:d,onClose:C,container:N()},ae.createElement(Co,{size:20}),ae.createElement(mw,{type:"warning",title:qe.t("Clear Transaction History"),description:ae.createElement(Sw,null,ae.createElement(vi,{variant:"body",size:"medium"},qe.t("Proceeding will remove all successful and failed transactions from the widget. Do you want to continue?")),ae.createElement(Co,{size:"24"}),ae.createElement(vi,{variant:"body",size:"small"},qe.t("Note: This does not erase your transaction history on the chain; it only removes them here.")))}),ae.createElement(Co,{size:30}),ae.createElement(al,{id:"widget-history-clear-modal-yes-btn",variant:"contained",type:"primary",size:"large",onClick:S},qe.t("Yes, Clear the history")),ae.createElement(Co,{size:10}),ae.createElement(al,{id:"widget-history-clear-modal-no-btn",variant:"outlined",type:"primary",size:"large",onClick:C},ae.createElement(vi,{variant:"title",size:"medium",color:"primary"},qe.t("No, Cancel")))))}i(bf,"HistoryPage");import{i18n as Hw}from"@lingui/core";import{Button as Gw,Divider as Gf,styled as Vw,WarningIcon as Kw}from"@rango-dev/ui";import jw from"bignumber.js";import He,{useEffect as Vf,useState as Kf}from"react";import{useNavigate as Xw}from"react-router-dom";import{i18n as Ef}from"@lingui/core";import{Alert as vw,Divider as ll,NoRouteIcon as ww,Typography as bw}from"@rango-dev/ui";import ko from"react";import{styled as Tw}from"@rango-dev/ui";var xf=Tw("div",{display:"flex",flexDirection:"column",alignItems:"center"});function cl(){let{fromToken:t,toToken:e}=O();return!!t&&!!e&&Mt(t,e)?ko.createElement(xf,null,ko.createElement(ll,{size:10}),ko.createElement(ww,{size:24,color:"gray"}),ko.createElement(ll,{size:4}),ko.createElement(bw,{variant:"title",size:"small"},Ef.t("No Routes Found")),ko.createElement(ll,{size:4}),ko.createElement(vw,{title:Ef.t("You cannot use the same token for From and To."),type:"warning",variant:"alarm"})):null}i(cl,"SameTokensWarning");import{i18n as Ww}from"@lingui/core";import{Header as Bw}from"@rango-dev/ui";import Jt,{useEffect as Mw,useState as Lw}from"react";import{i18n as Ew}from"@lingui/core";import{Divider as ul,FullExpandedQuote as Iw,Typography as Aw}from"@rango-dev/ui";import Se from"react";import{styled as pl}from"@rango-dev/ui";var If=pl("div",{display:"flex",justifyContent:"center",flexDirection:"column",height:"100%"}),Af=pl("div",{display:"flex",justifyContent:"space-between",alignItems:"center"}),Nf=pl("div",{width:"146px"});import{i18n as qn}from"@lingui/core";import{Select as xw}from"@rango-dev/ui";import Wf from"react";function bi(t){let{updateQuotePartialState:e,sortStrategy:o}=O(),n=[{value:"SMART",label:qn.t("Smart Routing")},{value:"FEE",label:qn.t("Lowest Fee")},{value:"SPEED",label:qn.t("Fastest Transfer")},{value:"NET_OUTPUT",label:qn.t("Maximum Return")},{value:"PRICE",label:qn.t("Maximum Output")}];return Wf.createElement(Nf,null,Wf.createElement(xw,{container:t.container,options:n,value:o,handleItemClick:r=>{e("sortStrategy",r.value)},variant:"filled"}))}i(bi,"SelectStrategy");var Bf=3;function Hn(t){let{loading:e,onClickOnQuote:o,fetch:n,showModalFee:r,hasSort:a=!0,fullExpandedMode:s=!1,container:l}=t,{selectedQuote:c,quotes:u,updateQuotePartialState:p,fromToken:d,toToken:h,sortStrategy:m,error:f}=O(),{slippage:g,customSlippage:C}=y(),{findToken:S}=y(),k=l||N(),T=!!u&&u.results.length,v=C??g,w=i(x=>{if(!d||!h||!u)return null;let E={requestAmount:u.requestAmount,validationStatus:null,...x};return Do({currentQuote:E,userSlippage:v,findToken:S})},"getQuoteWarning"),A=f?.type===0||f?.type===1,M=u?.results?Wr(m,u?.results):[];return Se.createElement(Se.Fragment,null,a&&Se.createElement(Se.Fragment,null,Se.createElement(Af,null,Se.createElement(Aw,{size:"xmedium",variant:"title"},Ew.t("Sort by")),Se.createElement(bi,{container:k})),Se.createElement(ul,{size:"10"})),e&&Array.from({length:Bf},(x,E)=>Se.createElement(Se.Fragment,{key:E},s?Se.createElement(Iw,{loading:!0}):Se.createElement(Pn,{tagHidden:!1,type:"list-item",expanded:!1}),E!==Bf-1&&Se.createElement(ul,{size:16}))),!e&&Se.createElement(Se.Fragment,null,T?M.map((x,E)=>{let b=w(x),I=Ds(x.swaps),W=M.length-1===E;return Se.createElement(Se.Fragment,{key:x.requestId},Se.createElement(yo,{showModalFee:r,container:k,selected:c?.requestId===x.requestId,tagHidden:!1,quote:{...x,requestAmount:u.requestAmount,validationStatus:null},loading:e,error:I?.options||null,warning:b,fullExpandedMode:s,onClick:B=>{I||p("warning",b),p("error",I?.options||null),o(B)},type:"list-item"}),!W&&Se.createElement(ul,{size:16}))}):A&&Se.createElement(If,null,Se.createElement(xn,{size:s?"large":"small",error:f,fetch:n}))))}i(Hn,"Quotes");import{darkTheme as Nw,styled as Mf}from"@rango-dev/ui";var Lf=Mf("div",{transition:"width 0.2s, opacity 0.2s, margin-left 0.2s",height:"700px",width:"390px",position:"relative",opacity:1,marginLeft:"$16",backgroundColor:"$neutral100",[`.${Nw} &`]:{backgroundColor:"$neutral300"},variants:{expandMode:{default:{width:"390px"},full:{width:"719px"}}},"&.is-hidden":{width:0,height:0,opacity:0,marginLeft:0}}),Pf=Mf("div",{position:"relative",overflow:"hidden",padding:"$20",flexGrow:1,display:"flex",flexDirection:"column",overflowY:"auto",borderRadius:"$primary",backgroundColor:"$background"});var Pw=100;function dl(t){let{fetch:e,loading:o,onClickOnQuote:n,onClickRefresh:r,isVisible:a}=t,[s,l]=Lw(!1),c=s?"":"is-hidden",{config:u}=y(),p=u?.variant==="full-expanded",d=no();return Mw(()=>{let h=null;return a?h=setTimeout(()=>{l(!0)},Pw):(l(!1),h&&clearTimeout(h)),()=>{h&&clearTimeout(h)}},[a]),Jt.createElement(Lf,{expandMode:u?.variant==="full-expanded"?"full":"default",className:`${c} ${zr()}`,id:De.EXPANDED_BOX_ID},Jt.createElement(Bw,{title:Ww.t("Routes"),suffix:Jt.createElement(Jt.Fragment,null,Jt.createElement(bi,{container:d}),Jt.createElement(mo,{container:d,onClickRefresh:r,hidden:["history","notifications","settings"]}))}),Jt.createElement(Pf,null,Jt.createElement(Hn,{showModalFee:!0,fetch:e,hasSort:!1,loading:o,container:no(),onClickOnQuote:n,fullExpandedMode:p})))}i(dl,"ExpandedQuotes");import{i18n as zf}from"@lingui/core";import{SwapInput as Qf}from"@rango-dev/ui";import Fw from"bignumber.js";import Gn from"react";import{ReverseIcon as $w}from"@rango-dev/ui";import fl from"react";import{keyframes as _w,styled as _f}from"@rango-dev/ui";var ml=450,Dw=_w({"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)"}}),Df=_f("div",{position:"absolute",bottom:"-12px",left:"50%",transform:"translate(-50%, 10%)",cursor:"pointer"}),$f=_f("div",{borderRadius:"$md",border:"3px solid $background",background:"$neutral100",width:"$24",height:"$24",display:"flex",justifyContent:"center",alignItems:"center",color:"$foreground","&.rotate":{"& svg":{animation:`${Dw} ${ml}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 gl(){let t=O.use.switchFromAndTo();return fl.createElement(Df,null,fl.createElement($f,{onClick:e=>{let o=e.currentTarget;o.classList.add("rotate"),setTimeout(()=>{o.classList.remove("rotate")},ml),t()}},fl.createElement($w,{size:12})))}i(gl,"SwitchFromAndToButton");import{styled as Ff}from"@rango-dev/ui";var Of=Ff("div",{display:"flex",flexDirection:"column",gap:"$5",alignSelf:"stretch"}),Uf=Ff("div",{position:"relative"});function hl(t){let{fetchingQuote:e,fetchMetaStatus:o,onClickToken:n,isExpandable:r}=t,{fromToken:a,fromBlockchain:s,toToken:l,toBlockchain:c,setInputAmount:u,inputAmount:p,inputUsdValue:d,outputAmount:h,outputUsdValue:m,selectedQuote:f}=O(),{connectedWallets:g,getBalanceFor:C}=y(),S=a?C(a):null,k=gr(S)?.amount??"0",T=S?new Fw(S.amount).shiftedBy(-S.decimals):ce,v=!!s&&Fc(g,s.name),w=!Aa(f,p,d),A=!Aa(f,p,m),M=!d||!m||!m.gt(0)?null:Pt(d.toString(),m.toString());return Gn.createElement(Of,null,Gn.createElement(Uf,null,Gn.createElement(Qf,{label:zf.t("From"),mode:"From",onInputChange:u,balance:k,chain:{displayName:s?.displayName||"",image:s?.logo||""},token:{displayName:a?.symbol||"",image:a?.image||""},onClickToken:()=>n("from"),price:{value:p,usdValue:w?void 0:L(d,4,4),realUsdValue:w?void 0:d?.toString(),error:w?ee().unknownPriceError.impactTitle:void 0},disabled:o==="failed",loading:o==="loading",loadingBalance:v,tooltipContainer:N(),onSelectMaxBalance:()=>{let x=L(T,S?.decimals),E=S?.amount?x:"";u(E)},anyWalletConnected:g.length>0}),Gn.createElement(gl,null)),Gn.createElement(Qf,{sharpBottomStyle:!r&&(!!f||e),label:zf.t("To"),mode:"To",fetchingQuote:e,chain:{displayName:c?.displayName||"",image:c?.logo||""},token:{displayName:l?.symbol||"",image:l?.image||""},percentageChange:L(Pt(d,m),2,2),warningLevel:_t(M??0),price:{value:L(h,6,6),usdValue:A?void 0:L(m,4,4),realValue:h?.toString(),realUsdValue:A?void 0:m?.toString(),error:A?ee().unknownPriceError.impactTitle:void 0},onClickToken:()=>n("to"),disabled:o==="failed",loading:o==="loading",tooltipContainer:N()}))}i(hl,"Inputs");import{useCallback as Ow,useEffect as Uw,useRef as zw,useState as Qw}from"react";function qf(){let{fetch:t,loading:e,cancelFetch:o}=mi({request:async(n,r)=>await xt().getAllRoutes(n,r)});return{fetch:t,loading:e,cancelFetch:o}}i(qf,"useFetchAllQuotes");var qw=600;function xi({refetchQuote:t}){let{fetch:e,cancelFetch:o}=qf(),{excludeLiquiditySources:n,routing:r}=y().config,{connectedWallets:a}=y(),{fromToken:s,toToken:l,inputAmount:c,inputUsdValue:u,selectedQuote:p,sortStrategy:d,resetQuote:h,error:m,warning:f,setSelectedQuote:g,updateQuotePartialState:C}=O(),{slippage:S,customSlippage:k,affiliatePercent:T,affiliateRef:v,affiliateWallets:w,fetchStatus:A}=y(),M=y().getLiquiditySources(),x=y().getDisabledLiquiditySources(),E=y().excludeLiquiditySources(),{findToken:b}=y(),[I,W]=Qw(!0),B=zw(c),U=k??S,R=!s||!l||Mt(s,l)||!sn(c),P=i(Q=>{W(Q)},"resetState"),Y=i(Q=>{let{fromToken:me,toToken:vt,inputAmount:Ze,liquiditySources:le,excludeLiquiditySources:at,disabledLiquiditySources:V,slippage:_,affiliateRef:G,affiliatePercent:K,affiliateWallets:fe}=Q;if(I||P(!0),!R&&me&&vt){h();let ne=ru({fromToken:me,toToken:vt,inputAmount:Ze,liquiditySources:le,excludeLiquiditySources:at,disabledLiquiditySources:V,wallets:a,slippage:_,affiliateRef:G,affiliatePercent:K,affiliateWallets:fe});Ao("experimental",r)&&(ne.experimental=!0),Ao("avoidNativeFee",r)&&(ne.avoidNativeFee=!0),Ao("enableCentralizedSwappers",r)&&(ne.enableCentralizedSwappers=!0),r?.maxLength&&(ne.maxLength=r.maxLength),e(ne).then(ge=>{let Fe=Wr(d,ge.results),ve=Vp(p,Fe,ge.requestAmount);W(!1),C("quotes",ge),g(ve),fi({diagnosisMessages:ge.diagnosisMessages,requestId:ve?.requestId||"",swaps:ve?.swaps});let mt=ve&&Do({currentQuote:ve,userSlippage:U,findToken:b});C("warning",mt)}).catch(ge=>{let{error:Fe}=gi(ge);(Fe?.type===0||Fe?.type===1)&&h(),Fe?.type!==2&&(C("error",Fe),W(!1))})}},"fetch"),se=Ow(Ec(Q=>{Y(Q)},qw),[R]);return Uw(()=>{if(!t){W(!1);return}if(A!=="success")return;if(R){W(!1),(p||m||f)&&h();return}if(!sn(c)||u?.eq(0)){P(!1),o();return}h(),P(!0);let Q=Y;return B.current&&B.current!=c&&(Q=se),B.current=c,Q({inputAmount:c,fromToken:s,toToken:l,liquiditySources:M,excludeLiquiditySources:E,disabledLiquiditySources:x,slippage:U,affiliateRef:v,affiliatePercent:T,affiliateWallets:w}),o},[A,c,s?.symbol,s?.address,s?.blockchain,l?.symbol,l?.address,l?.blockchain,R,M?.length,n,x.length,U,v,T,JSON.stringify(w)]),{fetch:()=>Y({inputAmount:c,fromToken:s,toToken:l,liquiditySources:M,excludeLiquiditySources:E,disabledLiquiditySources:x,slippage:U,affiliateRef:v,affiliatePercent:T,affiliateWallets:w}),loading:I}}i(xi,"useSwapInput");function Hf(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(Hf,"emitPreventableEvent");var Yw=Vw("div",{display:"flex",alignItems:"flex-start",maxHeight:700,"& .footer__alert":{paddingTop:"0 !important"}}),Zw=300;function jf(){let t=Xw(),{fromToken:e,toToken:o,inputAmount:n,selectedQuote:r,refetchQuote:a,error:s,warning:l,quotes:c,setSelectedQuote:u,resetQuoteWallets:p,setQuoteWarningsConfirmed:d,updateQuotePartialState:h}=O(),[m,f]=Kf(!1),{isLargeScreen:g,isExtraLargeScreen:C}=ii(),{fetch:S,loading:k}=xi({refetchQuote:a}),{config:T,fetchStatus:v,connectedWallets:w}=y(),{isActiveTab:A}=re(),[M,x]=Kf(!1),b=eu({fetchMetaStatus:v,fetchingQuote:k,inputAmount:n,quote:r,anyWalletConnected:w.length>0,error:s,warning:l,needsToWarnEthOnPath:!1}),I=Gc(g,C,T?.variant),W=!!n&&!!e&&!!o&&new jw(n).gt(0)&&!uu(e,o),B=W&&v==="success"&&k,R=(!I||I&&c?.results.length)&&(l||s);Vf(()=>{p(),h("refetchQuote",!0)},[]),Vf(()=>{f(W)},[W]);let P=(r||s)&&!M?S:void 0,Y=i(Q=>{I&&m?(f(!1),setTimeout(()=>{t(Q)},Zw)):t(Q)},"onHandleNavigation"),se=i(Q=>{r?.requestId!==Q.requestId&&(x(!1),u(Q))},"onClickOnQuote");return He.createElement(Yw,null,He.createElement(oe,{height:"auto",footer:He.createElement(Gw,{id:`widget-swap-${b.action}-btn`,type:"primary",size:"large",disabled:b.disabled||!A,prefix:b.action==="confirm-warning"&&He.createElement(Kw,null),fullWidth:!0,onClick:()=>{b.action==="connect-wallet"?Hf({type:"clickConnectWallet"},()=>Y($.wallets)):b.action==="confirm-warning"?x(!0):Y($.confirmSwap)}},b.title),header:{onWallet:()=>{Y($.wallets)},hasBackButton:!1,title:T.title||Hw.t("Swap"),suffix:He.createElement(mo,{hidden:I?["refresh"]:void 0,onClickRefresh:P,onClickHistory:()=>Y($.swaps),onClickSettings:()=>{Y($.settings)}})}},He.createElement(ie,null,He.createElement(hl,{fetchingQuote:B,fetchMetaStatus:v,isExpandable:I,onClickToken:Q=>{Y(Q==="from"?$.fromSwap:$.toSwap)}}),He.createElement(Gf,{size:"2"}),I?null:He.createElement(yo,{quote:r,loading:B,error:s,tagHidden:!1,warning:l,type:"basic",onClickAllRoutes:c&&c.results.length>1?()=>{h("refetchQuote",!1),Y($.routes)}:void 0}),R?He.createElement(He.Fragment,null,He.createElement(Gf,{size:"10"}),He.createElement(In,{warning:l,error:s,couldChangeSettings:!0,refetchQuote:S,showWarningModal:M,confirmationDisabled:!A,onOpenWarningModal:()=>x(!0),onCloseWarningModal:()=>x(!1),onConfirmWarningModal:()=>{x(!1),d(!0),Y($.confirmSwap)},onChangeSettings:()=>Y($.settings)})):null,He.createElement(cl,null))),I?He.createElement(dl,{loading:B,onClickOnQuote:se,fetch:S,onClickRefresh:P,isVisible:m}):null)}i(jf,"Home");import{i18n as Xf}from"@lingui/core";import{Alert as Jw,Divider as Rw,List as eb,ListItemButton as tb,Radio as ob,RadioRoot as nb,Typography as rb}from"@rango-dev/ui";import Wt from"react";function Rt(){let{setLanguage:t,language:e,config:o}=y(),n=Yc,r=o?.language||No;return{activeLanguage:e||r,languages:n,defaultLanguage:r,changeLanguage:a=>t(a||No),resetLanguage:()=>t(null)}}i(Rt,"useLanguage");function Yf(){let{activeLanguage:t,changeLanguage:e,languages:o}=Rt(),n=je(),r=o.map(a=>{let{local:s,label:l,SVGFlag:c}=a;return{id:`widget-setting-languages-${s}-item-btn`,value:s,title:Wt.createElement(rb,{variant:"title",size:"xmedium"},l),onClick:()=>{e(a.local),n()},end:Wt.createElement(ob,{value:s}),start:Wt.createElement(c,null)}});return Wt.createElement(oe,{header:{title:Xf.t("Language")}},Wt.createElement(ie,null,Wt.createElement(Jw,{type:"warning",variant:"alarm",title:"Warning: We are using machine translation, so the translations may be inaccurate."}),Wt.createElement(Rw,{size:"8"}),Wt.createElement(nb,{value:t},Wt.createElement(eb,{type:Wt.createElement(tb,{title:Xf.t("language"),id:"_",onClick:()=>console.log()}),items:r}))))}i(Yf,"LanguagePage");import{i18n as zt}from"@lingui/core";import{Button as cb,Checkbox as pb,Image as ub,ListItemButton as db,NotFound as mb,Typography as fb}from"@rango-dev/ui";import Ge,{useState as gb}from"react";import{Checkbox as sb,Skeleton as Jf}from"@rango-dev/ui";import Kn from"react";import{styled as yl}from"@rango-dev/ui";var Vn=yl("ul",{padding:"$15 $5 0",margin:0,listStyle:"none",height:"100%",overflowY:"auto",variants:{disabled:{true:{pointerEvents:"none"}}}}),Sl=yl("div",{width:80,display:"flex",justifyContent:"flex-end"}),Cl=yl("div",{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%"});import{ListItem as ib,styled as ab}from"@rango-dev/ui";var Zf=ab(ib,{height:61});var lb=30;function kl(){return Kn.createElement(Vn,null,Array.from(Array(lb),(t,e)=>Kn.createElement(Zf,{hasDivider:!0,key:e,start:Kn.createElement(Jf,{variant:"circular",width:35,height:35}),title:Kn.createElement(Jf,{variant:"text",size:"large",width:90}),end:Kn.createElement(sb,{checked:!1})})))}i(kl,"LoadingLiquiditySourceList");function Tl({sourceType:t}){let e=y().fetchStatus,o=y().swappers(),n=y().getDisabledLiquiditySources(),[r,a]=gb(""),s=y().toggleLiquiditySource,l=y().isInCampaignMode(),c=Sr(o,n),u={Exchanges:zt.t("Exchanges"),Bridges:zt.t("Bridges")},p=[];t==="Exchanges"&&p.push("DEX"),t==="Bridges"&&p.push("BRIDGE","AGGREGATOR","OFF_CHAIN");let d=c.filter(S=>p.includes(S.type)),h=d.length===d.filter(S=>S.selected).length,m=i(()=>{d.forEach(S=>{h?s(S.groupTitle):S.selected||s(S.groupTitle)})},"toggleAllSources"),f=d.map(S=>{let{selected:k,groupTitle:T,logo:v,id:w,...A}=S;return{id:`widget-setting-liquidity-source-${w.toLowerCase().replace(/\s+/g,"-")}-item-btn`,start:Ge.createElement(ub,{src:v,size:22,type:"circular"}),onClick:()=>{l||s(T)},end:Ge.createElement(pb,{checked:k,disabled:l}),title:Ge.createElement(fb,{variant:"title",size:"xmedium"},zt.t(T)),selected:k,groupTitle:T,logo:v,...A}}),g=i(S=>{let k=S.target.value;a(k)},"handleSearch"),C=f;return r&&(C=f.filter(S=>wt(S.groupTitle,r))),Ge.createElement(oe,{header:{title:zt.t(t),suffix:Ge.createElement(Sl,null,Ge.createElement(cb,{id:`widget-liquidity-source-${h?"deselect-all":"select-all"}-btn`,variant:"ghost",size:"xsmall",onClick:m},h?zt.t("Deselect all"):zt.t("Select all")))}},Ge.createElement(ie,{view:!0},Ge.createElement(Ct,{value:r,setValue:a,fullWidth:!0,color:"light",variant:"contained",placeholder:zt.t("Search {sourceType}",{sourceType:u[t]}),onChange:g}),e==="loading"&&Ge.createElement(kl,null),!C.length&&r?Ge.createElement(Cl,null,Ge.createElement(mb,{title:zt.t("No results found"),description:zt.t("Try using different keywords")})):e==="success"&&Ge.createElement(Vn,{disabled:l},C.map(S=>{let{groupTitle:k,...T}=S;return Ge.createElement(Ge.Fragment,{key:S.id},Ge.createElement(db,{style:{height:"61px"},...T,selected:!1,hasDivider:!0}))}))))}i(Tl,"LiquiditySourcePage");import{i18n as hb}from"@lingui/core";import Ei from"react";import{useNavigate as yb}from"react-router-dom";function Rf(){let t=yb(),e=je(),{selectedQuote:o,refetchQuote:n,setSelectedQuote:r,updateQuotePartialState:a,error:s}=O(),{fetch:l,loading:c}=xi({refetchQuote:n}),u=i(h=>{r(h),a("refetchQuote",!1),e()},"onClickOnQuote"),p=`../${$.settings}`,d=`../${$.wallets}`;return Ei.createElement(oe,{header:{onWallet:()=>{t(d),a("refetchQuote",!0)},onBack:()=>{a("refetchQuote",!1)},title:hb.t("Routes"),suffix:Ei.createElement(mo,{onClickRefresh:o||s?l:void 0,hidden:["notifications","history"],onClickSettings:()=>{t(p),a("refetchQuote",!0)}})}},Ei.createElement(ie,null,Ei.createElement(Hn,{fetch:l,loading:c,onClickOnQuote:u})))}i(Rf,"RoutesPage");import{i18n as ag}from"@lingui/core";import{Divider as sg,getCategoriesCount as Ib,SelectableCategoryList as Ab}from"@rango-dev/ui";import Qt,{useState as lg}from"react";import{useNavigate as Nb}from"react-router-dom";import{i18n as vl}from"@lingui/core";import{Divider as Tb,Image as vb,ListItemButton as wb,NotFound as bb,Typography as ig}from"@rango-dev/ui";import nt,{useEffect as xb,useState as Eb}from"react";var eg=i((t,e,o)=>t.filter(n=>cr(n.type,o)).filter(n=>Je(n.name,e)||Je(n.displayName,e)),"filterBlockchains");import{ImageContainer as Sb,styled as tg}from"@rango-dev/ui";var og=tg("div",{display:"flex",flexDirection:"column",overflow:"hidden",height:"100%",justifyContent:"center"}),Ii=tg(Tn,{padding:0,margin:0,listStyle:"none",[`& ${Sb}`]:{borderRadius:"$xm",overflow:"hidden"}});import{ListItem as Cb,Skeleton as ng}from"@rango-dev/ui";import Ai from"react";var kb=20;function rg(){return Ai.createElement(Ii,null,Array.from(Array(kb),t=>Ai.createElement(Cb,{key:t,hasDivider:!0,start:Ai.createElement(ng,{variant:"circular",width:35,height:35}),title:Ai.createElement(ng,{variant:"text",size:"large",width:90})})))}i(rg,"LoadingBlockchainList");function wl(t){let{list:e,searchedFor:o,onChange:n,blockchainCategory:r,showTitle:a=!0}=t,[s,l]=Eb(e),{fetchStatus:c}=y();xb(()=>{l([...eg(e,o,r)])},[e,o,r]);let u=i(()=>!s.length&&o?nt.createElement(bb,{title:vl.t("No results found"),description:vl.t("Try using different keywords")}):nt.createElement(Ii,{as:"ul",key:`${r}-${o}`},s.map(p=>nt.createElement(wb,{key:`${p.name}-${p.chainId}`,className:"widget-blockchain-list-item-btn",hasDivider:!0,onClick:()=>n(p),start:nt.createElement(vb,{src:p.logo,size:30}),title:nt.createElement(ig,{variant:"title",size:"medium"},p.displayName),id:p.name}))),"renderList");return nt.createElement(nt.Fragment,null,a&&nt.createElement(nt.Fragment,null,nt.createElement(ig,{variant:"label",size:"large"},vl.t("Select Chain")),nt.createElement(Tb,{size:4})),nt.createElement(og,null,c==="loading"&&nt.createElement(rg,null),c==="success"&&u()))}i(wl,"BlockchainList");function Ni(t){let{type:e}=t,o=je(),[n,r]=lg(""),[a,s]=lg("ALL"),l=O.use.setToBlockchain(),c=O.use.setFromBlockchain(),{fetchStatus:u}=y(),p=Nb(),d=y().blockchains({type:e}),h=Ib(d),m=!t.hideCategory&&h!==1;return Qt.createElement(oe,{header:{title:ag.t("Select Chain")}},Qt.createElement(ie,{view:!0},m&&Qt.createElement(Qt.Fragment,null,Qt.createElement(Ab,{setCategory:s,category:a,blockchains:d,isLoading:u==="loading"}),Qt.createElement(sg,{size:24})),Qt.createElement(Ct,{value:n,autoFocus:!0,placeholder:ag.t("Search Chain"),color:"light",variant:"contained",size:"large",setValue:()=>r(""),onChange:f=>r(f.target.value)}),Qt.createElement(sg,{size:16}),Qt.createElement(wl,{list:d,showTitle:e!=="custom-token",searchedFor:n,blockchainCategory:a,onChange:f=>{e==="custom-token"?p(`..?blockchain=${f.name}`,{replace:!0}):(e==="source"?c(f):l(f),o())}})))}i(Ni,"SelectBlockchainPage");import{i18n as Bi}from"@lingui/core";import{Divider as fg}from"@rango-dev/ui";import To,{useState as $b}from"react";import{useNavigate as Fb}from"react-router-dom";import{i18n as El}from"@lingui/core";import{BlockchainsChip as Wi,Divider as dg,Image as mg,Skeleton as Pb,Tooltip as _b,Typography as Il}from"@rango-dev/ui";import Pe from"react";import{useEffect as Mb}from"react";var cg=["ETH","COSMOS","OSMOSIS"];function bl(t,e,o){let n=JSON.parse(JSON.stringify(t)),r=[];if(n.sort(Wb),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 u=n[c];s=s.filter(p=>u.name!==p)}}n.sort(Bb(s)),r=n.splice(a)}return{list:n,more:r}}i(bl,"prepare");function Wb(t,e){let o=cg,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(Wb,"sortByMostUsedBlockchains");function Bb(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(Bb,"generateSortByPreferredBlockchainsFor");function pg(t,e){return!!e.list.find(o=>o.name===t)}i(pg,"isInVisibleList");function xl(t,e){let{preferredBlockchains:o,addPreferredBlockchain:n}=y();Mb(()=>{if(e?.selected){let a=bl(t,o,e);pg(e.selected,a)||n(e?.selected)}},[e?.selected]);let r=bl(t,o,e);return{list:r.list,more:r.more,history:[]}}i(xl,"usePrepareBlockchainList");import{styled as Lb}from"@rango-dev/ui";var ug=Lb("div",{display:"grid",gap:"$10",gridTemplateColumns:"repeat(6, minmax(0, 1fr))"});var Db=12;function Al(t){let{blockchains:e,type:o,blockchain:n,onChange:r,onMoreClick:a}=t,s=xl(e,{limit:10,selected:n?.name}),{fetchStatus:l}=y(),c=O.use.resetToBlockchain(),u=O.use.resetFromBlockchain(),p=s.more.length>0,d=s.more.length===1,h=!d&&p;return Pe.createElement(Pe.Fragment,null,Pe.createElement(dg,{size:12}),Pe.createElement(Il,{variant:"label",size:"large"},El.t("Select Chain")),Pe.createElement(dg,{size:12}),Pe.createElement(ug,null,l==="loading"&&Array.from(Array(Db),m=>Pe.createElement(Pb,{key:m,variant:"rounded",height:50})),l==="success"&&Pe.createElement(Pe.Fragment,null,Pe.createElement(Wi,{selected:!n,onClick:()=>{o==="from"?u():c()}},Pe.createElement(Il,{variant:"body",size:"xsmall",color:"secondary500"},El.t("All"))),s.list.map(m=>Pe.createElement(_b,{key:m.name,content:m.shortName,side:"bottom",sideOffset:2,container:N()},Pe.createElement(Wi,{key:m.name,selected:!!n&&n.name===m.name,onClick:()=>r(m)},Pe.createElement(mg,{src:m.logo,size:30})))),d?Pe.createElement(Wi,{key:s.more[0].name,selected:!!n&&n.name===s.more[0].name,onClick:()=>r(s.more[0])},Pe.createElement(mg,{src:s.more[0].logo,size:30})):null,h?Pe.createElement(Wi,{onClick:a,key:"more-blockchains"},Pe.createElement(Il,{variant:"body",size:"xsmall",color:"secondary500"},El._("More +{count}",{count:s.more.length}))):null)))}i(Al,"BlockchainsSection");function Nl(t){let{type:e}=t,o=Fb(),n=je(),{fromBlockchain:r,toBlockchain:a,setFromToken:s,setToToken:l,setFromBlockchain:c,setToBlockchain:u}=O(),{getBalanceFor:p}=y(),[d,h]=$b(""),f=(e==="source"?r:a)?.name??"",g=y().blockchains({type:e}),C=y().tokens({type:e,blockchain:f,searchFor:d,getBalanceFor:p}),S=i(v=>{e==="source"?c(v):u(v)},"updateBlockchain"),k=i(v=>{e==="source"?s({token:v,meta:{blockchains:g,tokens:C}}):l({token:v,meta:{blockchains:g,tokens:C}})},"updateToken"),T={source:Bi.t("Source"),destination:Bi.t("Destination")};return To.createElement(oe,{header:{title:Bi.t("Swap {type}",{type:T[e]})}},To.createElement(ie,null,To.createElement(Al,{blockchains:g,type:e=="source"?"from":"to",blockchain:e==="source"?r:a,onMoreClick:()=>o($.blockchains),onChange:v=>{S(v)}}),To.createElement(fg,{size:24}),To.createElement(Ct,{value:d,autoFocus:!0,placeholder:Bi.t("Search Token"),color:"light",variant:"contained",size:"large",setValue:()=>h(""),onChange:v=>h(v.target.value)}),To.createElement(fg,{size:16}),To.createElement(Fn,{list:C,selectedBlockchain:f,searchedFor:d,type:e,onChange:v=>{k(v);let w=g.find(A=>v.blockchain===A.name);w&&S(w),n()}})))}i(Nl,"SelectSwapItemsPage");import{i18n as Ml}from"@lingui/core";import{Alert as px,Button as ux,styled as dx}from"@rango-dev/ui";import vo from"react";import{useInRouterContext as mx,useSearchParams as fx}from"react-router-dom";import{i18n as kg}from"@lingui/core";import{Divider as Tg,InfoIcon as Qb,SlippageIcon as qb,TextField as Hb,Tooltip as Gb,Typography as vg}from"@rango-dev/ui";import rt from"react";import{Chip as Ob,styled as jn,TextField as Ub}from"@rango-dev/ui";var gg=jn("div",{paddingTop:"$5",padding:"$10 $5"}),hg=jn("div",{display:"flex",flexWrap:"wrap",gap:"$10",[`& ${Ub}`]:{flex:"1 1 0",maxWidth:"127px",minWidth:"85px"}}),yg=jn("div",{display:"flex",justifyContent:"start",alignItems:"center",paddingBottom:"$10"}),Mi=jn("div",{maxWidth:"280px",padding:"$10"}),Sg=jn(Ob,{width:"61px",flexShrink:0});import{i18n as Wl}from"@lingui/core";import{Typography as zb}from"@rango-dev/ui";import Xn from"react";function Cg(){return Xn.createElement(Mi,null,Xn.createElement(zb,{variant:"label",size:"medium",color:"neutral700"},Wl.t("Your transaction will be reverted if the price changes unfavorably by more than this percentage."),Xn.createElement("br",null),Xn.createElement("br",null),Xn.createElement("b",null,Wl.t("Warning")),":\xA0",Wl.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(Cg,"SlippageTooltipContent");function Bl(){let{slippage:t,setSlippage:e,customSlippage:o,setCustomSlippage:n}=y();return rt.createElement(gg,null,rt.createElement(yg,null,rt.createElement(qb,{size:16,color:"gray"}),rt.createElement(Tg,{direction:"horizontal",size:4}),rt.createElement(vg,{variant:"title",size:"xmedium"},kg.t("Slippage tolerance per swap")),rt.createElement(Tg,{direction:"horizontal",size:4}),rt.createElement(Gb,{container:N(),side:"top",sideOffset:4,content:rt.createElement(Cg,null)},rt.createElement(Qb,{color:"gray"}))),rt.createElement(hg,null,Zc.map((r,a)=>{let s=`slippage-${a}`;return rt.createElement(Sg,{key:s,onClick:()=>{o&&n(null),e(r)},selected:!o&&r===t,label:`${r.toString()}%`})}),rt.createElement(Hb,{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>=tp&&s<=ep?n(s):n(null)},suffix:o&&rt.createElement(vg,{variant:"body",size:"small"},"%"),placeholder:kg.t("Custom")})))}i(Bl,"Slippage");import{i18n as dt}from"@lingui/core";import{AutoThemeIcon as wg,BridgesIcon as Vb,ChevronRightIcon as Li,DarkModeIcon as bg,Divider as Yn,ExchangeIcon as Kb,InfinityIcon as jb,InfoIcon as Xb,LanguageIcon as Yb,LightModeIcon as xg,List as Zb,ListItem as Jb,ListItemButton as Rb,Skeleton as ex,styled as tx,Switch as ox,Tabs as nx,TargetIcon as rx,Tooltip as ix,Typography as Ye}from"@rango-dev/ui";import D from"react";import{useNavigate as ax}from"react-router-dom";var sx=tx("div",{width:"202px",height:"$40"}),lx=[{id:"light",icon:D.createElement(xg,{color:"black",size:24}),tooltip:D.createElement(Ye,{size:"xsmall",variant:"body"},dt.t("Light"))},{id:"dark",icon:D.createElement(bg,{color:"black",size:24}),tooltip:D.createElement(Ye,{size:"xsmall",variant:"body"},dt.t("Dark"))},{id:"auto",icon:D.createElement(wg,{color:"black",size:24}),tooltip:D.createElement(Ye,{size:"xsmall",variant:"body"},dt.t("Auto"))}],cx=i(t=>{let e={color:"gray",size:16};switch(t){case"auto":return D.createElement(wg,{...e});case"dark":return D.createElement(bg,{...e});default:return D.createElement(xg,{...e})}},"getThemeIcon");function Eg(){let t=ax(),{theme:e}=y().config,{setTheme:o,theme:n}=y(),{activeLanguage:r,languages:a}=Rt(),s=a.find(P=>P.local===r)?.label,l=y().fetchStatus,c=y().swappers(),u=y().getDisabledLiquiditySources(),{config:{features:p}}=y(),d=y().customTokens(),h=Ve("theme",p),m=Ve("liquiditySource",p),f=Ve("language",p),g=Ve("customTokens",p),C=y().infiniteApprove,S=y().toggleInfiniteApprove,k=Sr(c,u),T=k.filter(P=>["BRIDGE","AGGREGATOR","OFF_CHAIN"].includes(P.type)),v=T.length,w=T.filter(P=>P.selected).length,A=k.filter(P=>P.type==="DEX"),M=A.length,x=A.filter(P=>P.selected).length,E=i((P,Y)=>{switch(l){case"loading":return D.createElement(ex,{variant:"text",size:"medium",width:50});case"failed":return D.createElement(Ye,{variant:"body",size:"medium",color:"$error500"},dt.t("Loading failed"));default:return D.createElement(Ye,{variant:"body",size:"medium"},`${P} / ${Y}`)}},"handleSwapperEndItem"),b={id:"widget-setting-bridge-item-btn",title:D.createElement(Ye,{variant:"title",size:"xmedium"},dt.t("Bridges")),end:D.createElement(D.Fragment,null,E(w,v),D.createElement(Yn,{direction:"horizontal",size:8}),D.createElement(Li,{color:"black"})),onClick:()=>t($.bridges),start:D.createElement(Vb,{color:"gray",size:16})},I={id:"widget-setting-exchange-item-btn",title:D.createElement(Ye,{variant:"title",size:"xmedium"},dt.t("Exchanges")),end:D.createElement(D.Fragment,null,E(x,M),D.createElement(Yn,{direction:"horizontal",size:8}),D.createElement(Li,{color:"black"})),start:D.createElement(Kb,{color:"gray",size:16}),onClick:()=>t($.exchanges)},W={id:"widget-setting-custom-tokens-item-btn",title:D.createElement(Ye,{variant:"title",size:"xmedium"},dt.t("Custom Tokens")),end:D.createElement(D.Fragment,null,D.createElement(Ye,{variant:"body",size:"medium"},`${d.length}`),D.createElement(Yn,{direction:"horizontal",size:8}),D.createElement(Li,{color:"black"})),start:D.createElement(rx,{color:"gray",size:16}),onClick:()=>t($.customTokens)},B={id:"widget-setting-language-item-btn",title:D.createElement(Ye,{variant:"title",size:"xmedium"},dt.t("Language")),start:D.createElement(Yb,{color:"gray",size:16}),end:D.createElement(D.Fragment,null,D.createElement(Ye,{variant:"body",size:"medium"},s),D.createElement(Yn,{direction:"horizontal",size:8}),D.createElement(Li,{color:"black"})),onClick:()=>t($.languages)},U={id:"widget-setting-infinite-approval-item-btn",title:D.createElement(D.Fragment,null,D.createElement(Ye,{variant:"title",size:"xmedium"},dt.t("Infinite approval")),D.createElement(Yn,{direction:"horizontal",size:4}),D.createElement(ix,{side:"top",sideOffset:4,container:N(),content:D.createElement(Mi,null,D.createElement(Ye,{variant:"label",size:"medium",color:"neutral700"},D.createElement("b",null,dt.t("Warning")),":\xA0",dt.t("Enabling the 'Infinite approval' mode grants unrestricted access to underlying smart contracts, allowing them to utilize the approved token amount without limitations.")))},D.createElement(Xb,{color:"gray"}))),start:D.createElement(jb,{color:"gray",size:16}),end:D.createElement(ox,{checked:C}),onClick:S},j={id:"widget-setting-theme-item-btn",type:D.createElement(Jb,null),title:D.createElement(Ye,{variant:"title",size:"xmedium"},dt.t("Theme")),end:D.createElement(sx,null,D.createElement(nx,{container:N(),items:lx,value:n,onChange:P=>o(P.id),type:"primary",borderRadius:"small"})),start:cx(n)},R=m?[]:[b,I];return g||R.push(W),f||R.push(B),R.push(U),!e?.singleTheme&&!h&&R.push(j),D.createElement(Zb,{type:D.createElement(Rb,{hasDivider:!0,id:"_",onClick:()=>console.log()}),items:R})}i(Eg,"SettingsLists");var gx=dx("div",{paddingLeft:"$8"});function Ig(){let{isInCampaignMode:t,updateCampaignMode:e}=y(),o=t(),[,n]=fx(),r=mx(),a=i(()=>{r&&o&&(n(s=>(s.delete("liquiditySources"),s),{replace:!0}),e("liquiditySources",void 0))},"onClick");return vo.createElement(oe,{header:{title:Ml.t("Settings")}},vo.createElement(ie,null,o&&vo.createElement(px,{type:"info",variant:"alarm",title:Ml.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:vo.createElement(gx,null,vo.createElement(ux,{id:"widget-setting-exit-campaign-mode-btn",type:"secondary",size:"small",onClick:a},Ml.t("Reset")))}),vo.createElement(Bl,null),vo.createElement(Eg,null)))}i(Ig,"SettingsPage");import{i18n as oE}from"@lingui/core";import{cancelSwap as nE}from"@rango-dev/queue-manager-rango-preset";import{useManager as rE}from"@rango-dev/queue-manager-react";import{Alert as iE}from"@rango-dev/ui";import jl from"react";import{useParams as aE}from"react-router-dom";import{i18n as it}from"@lingui/core";import{getCurrentNamespaceOfOrNull as $x,getCurrentStep as Fx,getRelatedWalletOrNull as Ox}from"@rango-dev/queue-manager-rango-preset";import{Button as ih,CopyIcon as Ux,Divider as zx,DoneIcon as Qx,IconButton as qx,QuoteCost as Hx,RangoExplorerIcon as Gx,StepDetails as Vx,Tooltip as ah,Typography as wo,useCopyToClipboard as Kx}from"@rango-dev/ui";import{useWallets as jx}from"@rango-dev/wallets-react";import sh from"bignumber.js";import{PendingSwapNetworkStatus as zi}from"rango-types";import X,{useEffect as lh,useRef as Xx,useState as ch}from"react";import{useNavigate as Yx}from"react-router-dom";import{i18n as eo}from"@lingui/core";var hx=[eo.t("Sunday"),eo.t("Monday"),eo.t("Tuesday"),eo.t("Wednesday"),eo.t("Thursday"),eo.t("Friday"),eo.t("Saturday")];function Ag(t){let e=new Date(t),o=e.getDate(),n=e.toLocaleString("default",{month:"long"}),r=e.getFullYear();return`${e.getDay()===new Date().getDay()?eo.t("Today"):`${hx[e.getDay()]} ${o} ${n} ${r}`}, ${new Date(t).toLocaleTimeString()}`}i(Ag,"timeSince");function Ng(t){return t.finishTime?Ag(parseInt(t.finishTime)):Ag(parseInt(t.creationTime))}i(Ng,"getSwapDate");import{PendingSwapNetworkStatus as Di}from"rango-types";import $i from"react";import{i18n as Pi}from"@lingui/core";import{Button as Wg,Divider as Ll,MessageBox as yx}from"@rango-dev/ui";import to from"react";var Bg=i(({onCancel:t,onClose:e})=>to.createElement(to.Fragment,null,to.createElement(Ll,{size:20}),to.createElement(yx,{type:"error",title:Pi.t("Cancel Swap"),description:Pi.t("Are you sure you want to cancel this swap?")}),to.createElement(Ll,{size:32}),to.createElement(Wg,{variant:"contained",id:"widget-swap-details-modal-cancel-swap-yes-btn",type:"primary",size:"large",onClick:t},Pi.t("Yes, Cancel it")),to.createElement(Ll,{size:12}),to.createElement(Wg,{id:"widget-swap-details-modal-cancel-swap-no-btn",variant:"outlined",type:"primary",size:"large",onClick:e},Pi.t("No, Continue"))),"CancelContent");import{i18n as _i}from"@lingui/core";import{Button as Mg,Divider as Pl,MessageBox as Sx,Typography as Cx}from"@rango-dev/ui";import qt from"react";var Lg=i(({onDelete:t,onClose:e})=>qt.createElement(qt.Fragment,null,qt.createElement(Pl,{size:20}),qt.createElement(Sx,{type:"error",title:_i.t("Delete Transaction"),description:_i.t("Are you sure you want to delete this swap?")}),qt.createElement(Pl,{size:32}),qt.createElement(Mg,{id:"widget-swap-details-modal-delete-swap-yes-btn",variant:"contained",type:"primary",size:"large",onClick:t},_i.t("Yes, Delete it")),qt.createElement(Pl,{size:12}),qt.createElement(Mg,{id:"widget-swap-details-modal-delete-swap-no-btn",variant:"outlined",type:"primary",size:"large",onClick:e},qt.createElement(Cx,{variant:"title",size:"medium",color:"primary"},_i.t("No, Cancel")))),"DeleteContent");import{i18n as _l}from"@lingui/core";import{PendingSwapNetworkStatus as Dl}from"rango-types";var $l={[Dl.WaitingForNetworkChange]:{type:"loading",title:_l.t("Change Network")},[Dl.WaitingForConnectingWallet]:{type:"warning",title:_l.t("Connect Wallet")},[Dl.NetworkChanged]:{type:"success",title:_l.t("Network Changed")}};import{warn as kx}from"@rango-dev/logging-core";import{MessageBox as Tx,Wallet as vx}from"@rango-dev/ui";import{useWallets as wx}from"@rango-dev/wallets-react";import Jo,{useState as bx}from"react";import{styled as Pg}from"@rango-dev/ui";var _g=Pg("div",{display:"flex",justifyContent:"center"}),l5=Pg("div",{maxWidth:280,"& ._typography":{wordWrap:"break-word",display:"block"}});var Dg=i(t=>{let{type:e,title:o,currentStepWallet:n,message:r,showWalletButton:a,walletButtonDisabled:s}=t,[l,c]=bx(),{getWalletInfo:u,state:p}=wx(),d=n?.walletType,h=d?ln(p(d)):null,m=d?u(d):null,f=a&&!!d&&!!h&&!!m,{list:g}=ft(),C=i(()=>{if(d){let S=g.find(k=>k.type===d);S?c(S):kx(new Error(`It seems requested wallet to be connected is not available in the list. requested wallet: ${S}`))}},"handleWalletItemClick");return Jo.createElement(Jo.Fragment,null,Jo.createElement(Tx,{type:e,title:o,description:r}),f&&Jo.createElement(_g,null,Jo.createElement(vx,{container:N(),title:m.name,image:m.img,type:d,state:h,link:m.installLink,disabled:s,onClick:C})),Jo.createElement(co,{wallet:l,onClose:()=>{c(void 0)}}))},"WalletStateContent");function Fl(t){let{state:e,onClose:o,onDelete:n,onCancel:r,currentStepWallet:a,message:s,walletButtonDisabled:l}=t,c=e===Di.WaitingForNetworkChange||e===Di.WaitingForConnectingWallet||e===Di.NetworkChanged;return $i.createElement(J,{open:!!e,onClose:o,container:document.getElementById(De.SWAP_BOX_ID)||document.body},c&&$i.createElement(Dg,{type:$l[e].type,title:$l[e].title,currentStepWallet:a,message:s,walletButtonDisabled:l,showWalletButton:e!==Di.WaitingForNetworkChange}),e==="delete"&&$i.createElement(Lg,{onClose:o,onDelete:n}),e==="cancel"&&$i.createElement(Bg,{onClose:o,onCancel:r}))}i(Fl,"SwapDetailsModal");import{i18n as Zn}from"@lingui/core";import{Button as Ol,Divider as Jn,MessageBox as $g,TokenAmount as xx,Typography as Fg}from"@rango-dev/ui";import Ce from"react";import{useNavigate as Ex}from"react-router-dom";function Ul(t){let{open:e,onClose:o,status:n,priceValue:r,usdValue:a,realUsdValue:s,realValue:l,token:c,chain:u,percentageChange:p,description:d,diagnosisUrl:h}=t,m=Ex(),{showProfileBanner:f}=re();return Ce.createElement(J,{open:e,onClose:o,container:document.getElementById(De.SWAP_BOX_ID)||document.body},n==="success"?Ce.createElement($g,{type:"success",title:Zn.t("Swap Successful")},Ce.createElement(xx,{direction:"vertical",tooltipContainer:N(),type:"output",centerAlign:!0,price:{value:r,usdValue:a,realUsdValue:s,realValue:l},token:c,chain:u,percentageChange:p}),Ce.createElement(Jn,{size:12}),Ce.createElement(Fg,{variant:"body",size:"medium",color:"neutral700",align:"center"},d)):Ce.createElement($g,{type:"error",title:Zn.t("Transaction Failed"),description:d}),Ce.createElement(Jn,{size:30}),n==="success"&&Ce.createElement(Ce.Fragment,null,f&&Ce.createElement(Ce.Fragment,null,Ce.createElement("img",{src:"https://raw.githubusercontent.com/rango-exchange/assets/main/banners/widget/profile.jpg",alt:"Profile Banner"}),Ce.createElement(Jn,{size:30})),Ce.createElement(Ol,{id:"widget-swap-details-modal-done-btn",variant:"contained",type:"primary",size:"large",onClick:()=>{m("../../")}},Zn.t("Done"))),Ce.createElement(Jn,{size:12}),h&&Ce.createElement(Ce.Fragment,null,Ce.createElement(Ol,{variant:"contained",id:"widget-swap-detail-modal-diagnosis-btn",type:"primary",size:"large",onClick:()=>window.open(h,"_blank")},Zn.t("Diagnosis")),Ce.createElement(Jn,{size:12})),Ce.createElement(Ol,{id:"widget-swap-details-modal-see-details-btn",variant:"outlined",type:"primary",size:"large",onClick:o},Ce.createElement(Fg,{variant:"title",size:"medium",color:"primary"},Zn.t("See Details"))))}i(Ul,"SwapDetailsCompleteModal");import Dx from"react";import{i18n as Mx}from"@lingui/core";import{Alert as th,IconButton as Lx,LinkIcon as Px}from"@rango-dev/ui";import oo,{Fragment as _x}from"react";import{Alert as Ax,ChevronDownIcon as Nx,IconButton as Wx}from"@rango-dev/ui";import en,{useState as Bx}from"react";import{css as Rn,darkTheme as Og,styled as Ht,Typography as Ix}from"@rango-dev/ui";var Ug=Ht("div",{display:"flex",flexDirection:"column",flexGrow:1,overflow:"hidden"}),Fi=Ht("div",{width:"100%","& ._icon-button":{"&:hover":{"& svg":{color:"$secondary550",[`.${Og} &`]:{color:"$secondary500"}}}}}),zg=Ht(Tn,{padding:"$0 $20 $20 $20"}),V5=Ht("div",{display:"flex",flexDirection:"column",gap:"$10"}),Qg=Ht("div",{height:"450px",display:"flex",alignItems:"center",justifyContent:"center"}),K5=Ht("div",{display:"flex",justifyContent:"center",width:"100%",paddingTop:"33%",flex:1}),Ro=Rn({display:"flex",width:"100%",justifyContent:"space-between",alignItems:"center",padding:"$10 $20",borderBottom:"1px solid",$$color:"$colors$neutral300",[`.${Og} &`]:{$$color:"$colors$neutral400"},borderColor:"$$color",color:"$neutral500"}),qg=Rn({padding:"$5 0"}),Oi=Rn({display:"flex",justifyContent:"center",alignItems:"center",height:"$24"}),Hg=Rn({display:"flex",width:"100%",padding:"$15 $20 $20",flexDirection:"column",alignItems:"start"}),Gg=Rn({width:"100%",padding:"0 $20 $10"}),Vg=Ht("a",{fontSize:"$16",fontWeight:"$400",color:"$neutral700",display:"flex",alignItems:"center",justifyContent:"center"}),Kg=Ht("div",{display:"flex",flexDirection:"column",gap:"$5"}),Ui=Ht(Ix,{wordBreak:"break-word"});import{styled as zl}from"@rango-dev/ui";var jg=zl("div",{display:"flex",flexDirection:"column",gap:"$10"}),Xg=zl("div",{transition:"transform 0.3s ease-in-out",variants:{rotated:{true:{transform:"rotate(180deg)"}}}}),Yg=zl("div",{transition:"max-height 0.3s ease-in-out",maxHeight:"0px",overflow:"hidden",variants:{open:{true:{maxHeight:"200px"}}}});function Zg(t){let{message:e}=t,[o,n]=Bx(!1);return en.createElement(Ax,{type:"error",title:e.shortMessage,containerStyles:{"& .footer":{paddingTop:"$0"}},action:e.detailedMessage.content&&en.createElement(Wx,{onClick:()=>n(r=>!r),variant:"ghost",size:"xsmall"},en.createElement(Xg,{rotated:o},en.createElement(Nx,{size:12,color:"gray"}))),footer:en.createElement(Yg,{open:o},en.createElement(Ui,{variant:"body",size:"xsmall",color:"neutral700"},e.detailedMessage.content))})}i(Zg,"FailedAlert");import{i18n as Jg}from"@lingui/core";import{Alert as Ql,Button as Rg}from"@rango-dev/ui";import{PendingSwapNetworkStatus as ql}from"rango-types";import er from"react";function eh(t){let{switchNetwork:e,setNetworkModal:o,message:n,showNetworkModal:r}=t;return e?er.createElement(Ql,{type:"warning",title:n.shortMessage,action:er.createElement(Rg,{id:"widget-swap-details-warning-alert-change-network-btn",size:"xxsmall",type:"warning",onClick:()=>{o(ql.WaitingForNetworkChange),e().catch(a=>{console.log(a)})}},Jg.t("Change"))}):r===ql.WaitingForConnectingWallet?er.createElement(Ql,{type:"warning",title:n.shortMessage,action:er.createElement(Rg,{id:"widget-swap-details-warning-alert-connect-wallet-btn",size:"xxsmall",type:"warning",onClick:()=>{o(ql.WaitingForConnectingWallet)}},Jg.t("Connect"))}):er.createElement(Ql,{type:"warning",title:n.shortMessage})}i(eh,"WarningAlert");function Hl(t){let{switchNetwork:e,showNetworkModal:o,setNetworkModal:n,message:r,step:a,hasAlreadyProceededToSign:s}=t,l=Cn(a),c=a.status==="waitingForApproval"&&!l,u=a.status==="running"&&!l,p=u&&!s||c&&!a.explorerUrl?.length;return oo.createElement(jg,null,a.explorerUrl?.map((d,h,m)=>{let f=h+d.url,g=h===m.length-1,C=(g&&u||c)&&!p,S=g&&a.status==="failed";return oo.createElement(_x,{key:f},oo.createElement(th,{type:g&&(C&&"loading"||S&&"error")||"success",title:d.description?`${d.description} Tx`:Mx.t("View transaction"),action:d.url&&oo.createElement(Lx,{id:"widget-swap-details-tx-link-icon-btn",variant:"ghost",size:"xsmall",onClick:()=>window.open(d.url,"_blank")},oo.createElement(Px,{size:12}))}))}),p&&oo.createElement(th,{type:"loading",title:r.shortMessage}),a.status!=="failed"&&l&&oo.createElement(eh,{switchNetwork:e,showNetworkModal:o,setNetworkModal:n,message:r}),a.status==="failed"&&oo.createElement(Zg,{message:r}))}i(Hl,"SwapDetailsAlerts");var oh=2e3;var nh=i(({swap:t,blockchains:e,swappers:o,...n})=>{let r=t.hasAlreadyProceededToSign!==!1;return t.steps.map((a,s)=>{let l=s===0?t.inputAmount:t.steps[s-1].outputAmount||t.steps[s-1].expectedOutputAmountHumanReadable;return{from:{token:{displayName:a.fromSymbol,image:a.fromLogo??""},chain:{displayName:st(a.fromBlockchain,e)??"",image:a.fromBlockchainLogo??""},price:{value:L(l,6,6),realValue:l??""}},to:{token:{displayName:a.toSymbol,image:a.toLogo},chain:{displayName:st(a.toBlockchain,e)??"",image:a.toBlockchainLogo??""},price:{value:L(a.outputAmount||a.expectedOutputAmountHumanReadable,6,6),realValue:a.outputAmount||a.expectedOutputAmountHumanReadable||""}},swapper:{displayName:on(a.swapperId,o)??"",image:a.swapperLogo??"",type:a.swapperType},internalSwaps:a.internalSwaps?a.internalSwaps.map(c=>({from:{chain:{displayName:st(c.fromBlockchain,e)??"",image:c.fromBlockchainLogo??""}},to:{chain:{displayName:st(c.toBlockchain,e)??"",image:c.toBlockchainLogo??""}},swapper:{displayName:on(c.swapperId,o)??"",image:c.swapperLogo??"",type:c.swapperType}})):[],alerts:Dx.createElement(Hl,{step:a,hasAlreadyProceededToSign:r,...n})}})},"getSteps");function rh(t){if(Cn(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(rh,"getStepState");function Gl(t){let{swap:e,requestId:o,onDelete:n,onCancel:r}=t,{canSwitchNetworkTo:a,connect:s,getWalletInfo:l}=jx(),c=y().blockchains(),u=y().swappers(),{findToken:p}=y(),d=O.use.retry(),h=re.use.isActiveTab(),m=Yx(),[f,g]=Kx(oh),C=Xx(null),[S,k]=ch(null),[T,v]=ch(null),w=i(()=>{r(),k(null)},"onCancel"),A=be.use.getNotifications(),M=be.use.removeNotification(),x=A(),E=Fx(e),b=E?.networkStatus;lh(()=>{x.find(mt=>mt.requestId===e.requestId)&&(e.status==="success"||e.status==="failed"?(v(e.status),M(e.requestId)):T&&v(null))},[e.status,e.requestId]),lh(()=>{P?k(zi.WaitingForNetworkChange):b===zi.WaitingForConnectingWallet||b===zi.NetworkChanged?k(b):k(null)},[b]);let I=lu(e),W=E?$x(e,E):null,B=E?Ox(e,E):null,U=Ng(e),j=cu(e),R=i(ve=>!!l(ve)?.mobileWallet,"isMobileWallet"),P=b===zi.WaitingForNetworkChange&&!!W&&!!B?.walletType&&(R(B.walletType)||a(B.walletType,W.network)),Y=P?s.bind(null,B.walletType,[{namespace:W.namespace,network:W.network}]):void 0,se=su(e,E),Q=nh({swap:e,switchNetwork:Y,showNetworkModal:b,setNetworkModal:k,message:se,blockchains:c,swappers:u}),me=Q.length,[vt,Ze]=[e.steps[0],e.steps[me-1]],le=Ze.outputAmount||Ze.expectedOutputAmountHumanReadable,at=e.steps.reduce((ve,mt)=>ve+parseFloat(mt.feeInUsd||""),0),V=e.steps.find(ve=>ve.diagnosisUrl)?.diagnosisUrl,_=L(parseFloat(le||"0")*(Ze.toUsdPrice||0),4,4),G=L(parseFloat(e.inputAmount)*(vt.fromUsdPrice||0),4,4),K=le?new sh(le).multipliedBy(Ze.toUsdPrice||0).toString():"",fe=new sh(e.inputAmount).multipliedBy(vt.fromUsdPrice||0).toString(),ne=Pt(G,_),ge=se.detailedMessage.content||se.shortMessage,Fe=e.status==="success"?it.t({id:"You have received {amount} {token} in {conciseAddress} wallet on {chain} chain.",values:{amount:L(le,6,6),token:Q[me-1].to.token.displayName,conciseAddress:hr(e.wallets[Q[me-1].to.chain.displayName]?.address||""),chain:Q[me-1].to.chain.displayName}}):X.createElement(Kg,null,X.createElement(wo,{variant:"body",size:"medium",color:"neutral700",align:"center"},ge?"":it.t("Transaction was not sent."),I?`${it.t({id:"{amount} {symbol} on {blockchain} remains in your wallet.",values:{amount:I.outputAmount,symbol:I.symbol,blockchain:I.blockchain}})}`:""),ge&&X.createElement(Ui,{align:"center",variant:"body",size:"medium",color:"neutral700"},X.createElement("b",null,"Reason:")," ",ge));return X.createElement(oe,{header:{title:it.t("Swap Details"),onCancel:e.status==="running"?()=>k("cancel"):void 0,suffix:e.status!=="running"&&X.createElement(Vt,null,X.createElement(ih,{id:"widget-swap-details-delete-btn",variant:"ghost",type:"error",size:"xsmall",onClick:()=>k("delete")},X.createElement(wo,{size:"medium",variant:"label",color:"error"},it.t("Delete"))))},footer:j&&!T&&X.createElement(ih,{fullWidth:!0,id:"widget-swap-details-try-again-btn",variant:"contained",type:"primary",size:"large",onClick:()=>{let ve=Nr(e,c,p);d(ve),setTimeout(()=>{m("../../")},0)}},it.t("Try again"))},X.createElement(ie,{compact:!0,view:!0},X.createElement(Fi,null,X.createElement("div",{className:Ro()},X.createElement(wo,{variant:"label",size:"large",color:"neutral700"},`${it.t("Request ID")}`),X.createElement("div",{className:Oi()},X.createElement(wo,{variant:"label",size:"small",color:"neutral700"},o),X.createElement(ah,{container:N(),content:f?it.t("Copied To Clipboard"):it.t("Copy Request ID"),open:f||void 0,side:"bottom",alignOffset:-16,align:"end"},X.createElement(qx,{id:"widget-swap-details-done-copy-icon-btn",variant:"ghost",onClick:g.bind(null,o||"")},f?X.createElement(Qx,{size:16,color:"secondary"}):X.createElement(Ux,{size:16,color:"gray"}))),X.createElement(Vg,{target:"_blank",href:`${Sc}/swap/${o}`},X.createElement(ah,{container:N(),content:it.t("View on Rango Explorer"),side:"bottom"},X.createElement(Gx,{size:20}))))),X.createElement("div",{className:Ro()},X.createElement(wo,{variant:"label",size:"large",color:"neutral700"},e.finishTime?it.t("Finished at"):it.t("Created at")),X.createElement(wo,{variant:"label",size:"small",color:"neutral700"},U))),X.createElement("div",{className:Hg()},X.createElement(Hx,{fee:L(String(at),2,2),time:an(pr(e.steps)),steps:me}),X.createElement(Nn,{from:{price:{value:L(e.inputAmount,6,6),usdValue:G,realUsdValue:fe,realValue:e.inputAmount},token:{displayName:Q[0].from.token.displayName,image:Q[0].from.token.image},chain:{image:Q[0].from.chain.image,displayName:Q[0].from.chain.displayName}},to:{price:{value:L(le,6,6),usdValue:_,realUsdValue:K,realValue:le||""},token:{displayName:Q[me-1].to.token.displayName,image:Q[me-1].to.token.image},chain:{image:Q[me-1].to.chain.image,displayName:Q[me-1].to.chain.displayName}},percentageChange:L(ne,2,2),warningLevel:_t(ne??0)})),X.createElement("div",{className:Gg()},X.createElement(wo,{variant:"title",size:"small"},it.t("Swaps steps"))),X.createElement(zx,{size:8}),X.createElement(zg,{ref:C},Q.map((ve,mt)=>{let tc=mt,tn=rh(e.steps[mt]),$h=tn==="error"||tn==="in-progress"||tn==="warning"||tn==="completed"&&mt===Q.length-1;return X.createElement(Vx,{key:tc,step:ve,type:"swap-progress",ref:C,state:tn,hasSeparator:mt!==0,tabIndex:tc,isFocused:$h,tooltipContainer:N()})}))),X.createElement(Fl,{state:S,onClose:()=>k(null),onCancel:w,onDelete:n,message:se.detailedMessage.content,currentStepWallet:B,walletButtonDisabled:!h}),X.createElement(Ul,{open:!!T,diagnosisUrl:V,onClose:()=>v(null),status:e.status==="success"?"success":"failed",priceValue:L(le,6,6),usdValue:_,realUsdValue:K,realValue:le||"",percentageChange:L(ne,2,2),token:{displayName:Q[me-1].to.token.displayName,image:Q[me-1].to.token.image},chain:{image:Q[me-1].to.chain.image},description:Fe}))}i(Gl,"SwapDetails");import{i18n as qi}from"@lingui/core";import{Divider as dh,NotFound as tE,Skeleton as or,Typography as Hi}from"@rango-dev/ui";import ke from"react";import{i18n as Zx}from"@lingui/core";import{Divider as Jx,Skeleton as Rx,Typography as eE}from"@rango-dev/ui";import Te from"react";import{css as Tt,styled as Vl}from"@rango-dev/ui";var ph=Vl("div",{width:"100%",height:"100%",padding:"$10 $20"}),tr=Vl("div",{backgroundColor:"$neutral100",borderRadius:"$xm",padding:"$10 $15"}),Qi=Vl("div",{width:"0px",height:"$20",borderLeft:"1px dashed $neutral700",marginLeft:"25px"}),iK=Tt({display:"flex",justifyContent:"space-between",alignItems:"center"}),aK=Tt({display:"flex",justifyContent:"space-between",alignItems:"center"}),sK=Tt({paddingTop:"$15",display:"flex"}),lK=Tt({padding:"$15 $0"}),cK=Tt({width:"0px",height:"$16",borderLeft:"1px solid $neutral400",marginLeft:"13px"}),pK=Tt({paddingBottom:"$10"}),uK=Tt({display:"flex",justifyContent:"start",alignItems:"center"}),dK=Tt({paddingTop:"$5",display:"flex",alignItems:"center"}),mK=Tt({display:"flex",alignItems:"center"}),fK=Tt({padding:"$4 $6",display:"flex",justifyContent:"center",alignItems:"center"}),uh=Tt({display:"flex",paddingTop:"$10",paddingBottom:"$5"});function Kl(){return Te.createElement(ph,null,Te.createElement(Mn,{type:"swap-preview"}),Te.createElement("div",{className:"swaps-steps"},Te.createElement(eE,{variant:"title",size:"small"},Zx.t("Swaps steps"))),Te.createElement(Te.Fragment,null,Te.createElement(tr,null,Te.createElement(Nt,{separator:!1}),Te.createElement("div",{className:uh()},Te.createElement(Jx,{direction:"horizontal",size:20}),Te.createElement(Rx,{height:22,variant:"rectangular"}))),Te.createElement(Qi,null),Te.createElement(tr,null,Te.createElement(Nt,{separator:!1})),Te.createElement(Qi,null),Te.createElement(tr,null,Te.createElement(Nt,{separator:!1})),Te.createElement(Qi,null),Te.createElement(tr,null,Te.createElement(Nt,{separator:!1}))))}i(Kl,"LoadingSwapDetails");function mh(t){let{requestId:e,showSkeleton:o}=t;return ke.createElement(oe,{header:{title:qi.t("Swap Details"),suffix:ke.createElement(Vt,null)}},o&&ke.createElement(Ug,null,ke.createElement(Fi,null,ke.createElement("div",{className:Ro()},ke.createElement(Hi,{variant:"label",size:"large",color:"neutral700"},`${qi.t("Request ID")}`),ke.createElement("div",{className:Oi()},ke.createElement(Hi,{variant:"label",size:"small",color:"neutral700"},ke.createElement(or,{width:60,height:10,variant:"rounded"})),ke.createElement(dh,{direction:"horizontal",size:4}),ke.createElement(or,{width:16,height:16,variant:"rectangular"}),ke.createElement(dh,{direction:"horizontal",size:4}),ke.createElement(or,{width:16,height:16,variant:"rectangular"}))),ke.createElement("div",{className:Ro()},ke.createElement(Hi,{className:qg(),variant:"label",size:"large",color:"neutral700"},ke.createElement(or,{width:60,height:10,variant:"rounded"})),ke.createElement(Hi,{variant:"label",size:"small",color:"neutral700"},ke.createElement(or,{width:60,height:10,variant:"rounded"})))),ke.createElement(Kl,null)),!o&&ke.createElement(Qg,null,ke.createElement(tE,{title:qi.t("Not found"),description:qi.t({id:"Swap with request ID = {requestId} not found.",values:{requestId:e}})})))}i(mh,"SwapDetailsPlaceholder");function fh(){let{manager:t,state:e}=rE(),o=!e.loadedFromPersistor,n=pt(t),{requestId:r}=aE(),a=je(),{fetchStatus:s}=y();if(!r)return jl.createElement(iE,{containerStyles:{margin:"20px"},type:"error",title:oE.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,u=i(()=>{if(c?.id){let h=t?.get(c.id);h&&nE(h)}},"onCancel"),p=i(async()=>{if(c?.id)try{t?.deleteQueue(c.id),a()}catch(h){console.log(h)}},"onDelete"),d=c?.swap;return!d||l?jl.createElement(mh,{requestId:r,showSkeleton:l}):jl.createElement(Gl,{swap:d,requestId:r,onCancel:u,onDelete:p})}i(fh,"SwapDetailsPage");import{i18n as gh}from"@lingui/core";import{Divider as sE,getCategoriesCount as lE,SelectableCategoryList as cE,styled as yh,Typography as pE,Wallet as uE}from"@rango-dev/ui";import Bt,{useState as hh}from"react";var dE=yh("div",{display:"flex",justifyContent:"center",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5"}),mE=yh(ie,{textAlign:"center"});function Sh(){let{fetchStatus:t}=y(),[e,o]=hh("ALL"),n=y().blockchains(),{config:r}=y(),[a,s]=hh(),l=re.use.isActiveTab(),{list:c}=ft(),u=Uc(c,n),d=lE(u)!==1,h=zc(c,e),m=i(f=>{Nc(c,r.multiWallets)||s(f)},"handleWalletItemClick");return Bt.createElement(oe,{header:{title:gh.t("Connect Wallets")}},Bt.createElement(mE,null,d&&Bt.createElement(Bt.Fragment,null,Bt.createElement(cE,{setCategory:o,category:e,blockchains:u,isLoading:t==="loading"}),Bt.createElement(sE,{size:24})),Bt.createElement(pE,{variant:"title",size:"xmedium",align:"center"},gh.t("Choose a wallet to connect.")),Bt.createElement(dE,null,h.map((f,g)=>{let C=`wallet-${g}-${f.type}`;return Bt.createElement(uE,{key:C,...f,container:N(),onClick:()=>m(f),isLoading:t==="loading",disabled:!l})}),Bt.createElement(co,{wallet:a,onClose:()=>{s(void 0)}}))))}i(Sh,"WalletsPage");function Ch(){return mu(),_a(),fE([{path:$.home,element:_e.createElement(jf,null)},{path:$.routes,element:_e.createElement(Rf,null)},{path:$.fromSwap,children:[{index:!0,element:_e.createElement(Nl,{type:"source"})},{path:$.blockchains,element:_e.createElement(Ni,{type:"source"})}]},{path:$.toSwap,children:[{index:!0,element:_e.createElement(Nl,{type:"destination"})},{path:$.blockchains,element:_e.createElement(Ni,{type:"destination"})}]},{path:$.settings,children:[{index:!0,element:_e.createElement(Ig,null)},{path:$.languages,element:_e.createElement(Yf,null)},{path:$.exchanges,element:_e.createElement(Tl,{sourceType:"Exchanges"})},{path:$.bridges,element:_e.createElement(Tl,{sourceType:"Bridges"})},{path:$.customTokens,children:[{index:!0,element:_e.createElement(nf,null)},{path:$.addCustomTokens,children:[{index:!0,element:_e.createElement(ju,null)},{path:$.blockchains,element:_e.createElement(Ni,{hideCategory:!0,type:"custom-token"})}]}]}]},{path:$.swaps,children:[{index:!0,element:_e.createElement(bf,null)},{path:$.swapDetails,element:_e.createElement(fh,null)}]},{path:$.wallets,element:_e.createElement(Sh,null)},{path:$.confirmSwap,element:_e.createElement(qm,null)}])}i(Ch,"AppRoutes");import{useQueueManager as wE}from"@rango-dev/queue-manager-rango-preset";import{splitWalletNetwork as bE}from"@rango-dev/wallets-shared";import{isEvmBlockchain as xE}from"rango-sdk";import{useContext as EE,useEffect as Eh,useState as Ih}from"react";import{globalCss as gE}from"@rango-dev/ui";var kh=i(()=>gE({"@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 Th(){let{setWatermark:t,setShowProfileBanner:e}=re();return{fetchApiConfig:i(async()=>{let n=await fetch(`${Lt("BASE_URL")}/meta/dapp/config?apiKey=${Lt("API_KEY")}`);if(!n.ok)throw new Error(`Request failed with status: ${n.status} `);let r=await n.json();t(r.config.watermark),e(r.config.banners.profile)},"fetchApiConfig")}}i(Th,"useFetchApiConfig");import{useWallets as hE}from"@rango-dev/wallets-react";import{useEffect as yE,useRef as SE}from"react";function vh(){let{connect:t,state:e}=hE(),o=SE({}),{fetchStatus:n}=y(),r=new URLSearchParams(location.search).get("autoConnect")||"",a=e(r);yE(()=>{n==="success"&&r&&a.installed&&!a.connecting&&!a.connected&&!o.current[r]&&(o.current[r]=!0,t(r))},[a,n])}i(vh,"useForceAutoConnect");import{isApprovalTX as CE,RouteEventType as wh,StepEventType as bh,StepExecutionEventStatus as kE,WidgetEvents as Gi}from"@rango-dev/queue-manager-rango-preset";import{useEffect as xh}from"react";function Xl(){let t=be.use.setNotification(),{connectedWallets:e,fetchBalances:o}=y();xh(()=>{let n=i(r=>{let{event:a,step:s,route:l}=r;if(a.type===bh.TX_EXECUTION&&a.status===kE.TX_SENT&&!CE(s)||a.type===bh.SUCCEEDED){let u=e.find(d=>d.chain===s?.fromBlockchain),p=s?.fromBlockchain!==s?.toBlockchain&&e.find(d=>d.chain===s?.toBlockchain);u&&o([u]),p&&o([p])}t(a,l)},"handleStepEvent");return he.on(Gi.StepEvent,n),()=>he.off(Gi.StepEvent,n)},[he,e]),xh(()=>{let n=i(r=>{let{event:a,route:s}=r;(a.type===wh.FAILED||a.type===wh.SUCCEEDED)&&t(a,s)},"handleRouteEvent");return he.on(Gi.RouteEvent,n),()=>he.off(Gi.RouteEvent,n)},[he])}i(Xl,"useSubscribeToWidgetEvents");import{useManager as TE}from"@rango-dev/queue-manager-react";import{useEffect as vE}from"react";function Yl(){let{isSynced:t,syncNotifications:e}=be(),{manager:o,state:n}=TE();vE(()=>{be.persist.hasHydrated()&&n.loadedFromPersistor&&!t&&e(pt(o))},[be.persist.hasHydrated(),n.loadedFromPersistor,t])}i(Yl,"useSyncNotifications");function Zl(){vh(),kh(),Xl(),Yl();let t=y().blockchains(),{canSwitchNetworkTo:e}=jr(),[o,n]=Ih(""),[r,a]=Ih(),s=EE(xr),l=t.filter(xE),{fetchApiConfig:c}=Th();Eh(()=>()=>du(),[]),wE({lastConnectedWallet:o,clearDisconnectedWallet:()=>{a(void 0)},disconnectedWallet:r,evmChains:l,canSwitchNetworkTo:e}),Eh(()=>(io.init(),be.persist.hasHydrated()||be.persist.rehydrate(),s.onConnectWallet(n),s.onDisconnectWallet(u=>{a(u),u===bE(o)?.[0]&&n("")}),c().catch(console.log),io.destroy),[])}i(Zl,"useBootstrap");import{styled as IE}from"@rango-dev/ui";var Ah=IE("div",{fontFamily:"$widget",boxSizing:"border-box",textAlign:"left","& *, *::before, *::after":{boxSizing:"inherit"},"& *:focus-visible":{outlineColor:"$info500",transition:"none"},"& ul, ol, li":{listStyleType:"none"}});function Vi(){Zl();let{config:t}=y(),{activeTheme:e}=Uo(t?.theme||{}),{activeLanguage:o}=Rt();return Jl.createElement(AE,{language:o},Jl.createElement(Ah,{id:"swap-container",className:e()},Jl.createElement(Ch,null)))}i(Vi,"Main");import{setSolanaSignerConfig as jE}from"@rango-dev/signer-solana";import ec,{useEffect as Ph,useMemo as XE}from"react";import{useState as NE}from"react";var WE=i(()=>{let[t,e]=NE(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=Ac(a);if(s){let l=o(s);e(l)}},"handleLoadCustomFont")}},"useFontLoader"),Nh=WE;import{checkWaitingForNetworkChange as BE,makeQueueDefinition as ME}from"@rango-dev/queue-manager-rango-preset";import{Provider as LE}from"@rango-dev/queue-manager-react";import{useWallets as PE}from"@rango-dev/wallets-react";import{convertEvmBlockchainMetaToEvmChainInfo as _E}from"@rango-dev/wallets-shared";import{isEvmBlockchain as DE}from"rango-types";import $E,{useMemo as FE}from"react";function OE(t){let{providers:e,getSigners:o,state:n,connect:r,canSwitchNetworkTo:a,getWalletInfo:s}=PE(),l=FE(()=>ME({API_KEY:t.apiKey||Lt("API_KEY"),BASE_URL:Lt("BASE_URL"),emitter:{emit:he.emit}}),[t.apiKey]),{blockchains:c,connectedWallets:u}=y(),p=c(),d={blockchains:u.map(v=>({accounts:[v],name:v.chain}))},h=i(async(v,w)=>a(v,w.network)?await r(v,[w]):void 0,"switchNetwork"),m=i(v=>!!s(v).mobileWallet,"isMobileWallet"),f=p.filter(v=>v.enabled).reduce((v,w)=>(v[w.name]=w,v),{}),g=p.filter(DE),C=i(v=>{let{supportedChains:w}=s(v);return mr(w)},"getSupportedChainNames"),S=e(),k={meta:{blockchains:f,evmBasedChains:g,evmNetworkChainInfo:_E(g),getSupportedChainNames:C},getSigners:o,wallets:d,providers:S,switchNetwork:h,canSwitchNetworkTo:a,state:n,isMobileWallet:m},T=re.use.isActiveTab();return $E.createElement(LE,{queuesDefs:[l],context:k,onPersistedDataLoaded:v=>{BE(v)},isPaused:!T},t.children)}i(OE,"QueueManager");var Wh=OE;import{useManager as HE}from"@rango-dev/queue-manager-react";import GE,{createContext as VE,useContext as KE}from"react";function Bh(){let{findToken:t}=y(),e=y().blockchains(),o=y().tokens(),{setFromBlockchain:n,setFromToken:r,setToBlockchain:a,setToToken:s,setInputAmount:l}=O();return i(u=>{let{fromBlockchain:p,fromToken:d,toBlockchain:h,toToken:m,requestAmount:f}=u,g={blockchains:e,tokens:o};if(p!==void 0){let C=e.find(S=>S.name===p)??null;n(C)}if(d!==void 0){let C=d?t(d)??null:null;r({meta:g,token:C})}if(h!==void 0){let C=e.find(S=>S.name===h)??null;a(C)}if(m!==void 0){let C=m?t(m)??null:null;s({meta:g,token:C})}f!==void 0&&l(f)},"updateQuoteInputs")}i(Bh,"useUpdateQuoteInputs");import{cancelSwap as UE,getCurrentNamespaceOfOrNull as zE,getCurrentStep as QE,getRelatedWalletOrNull as qE}from"@rango-dev/queue-manager-rango-preset";var Ki=class{static{i(this,"WidgetHistory")}constructor(e,o){this.manager=e,this.actions=o}getAllSwaps(){return pt(this.manager)}getCurrentStep(e){return this.getCurrentStepInfo(e).step}getCurrentStepWallet(e){return this.getCurrentStepInfo(e).wallet}getCurrentStepNetwork(e){return this.getCurrentStepInfo(e).network}retry(e,o){let n=Nr(e,o.blockchains,this.actions.findToken);return this.actions.retrySwap(n)}cancel(e){let o=this.manager?.get(e);o&&UE(o)}getCurrentStepInfo(e){let o=QE(e);return{step:o,wallet:o?qE(e,o):null,network:o?zE(e,o)?.network:null}}};var Mh=VE(void 0);function Rl(t){let{manager:e}=HE(),o=re.use.isActiveTab(),n=O.use.retry(),{findToken:r,getBalances:a,getConnectedWalletsDetails:s,fetchBalances:l}=y(),c=new Ki(e,{retrySwap:n,findToken:r}),{fetchingWallets:u}=y(),p=Pc(a()),d=y().blockchains(),h=y().tokens(),m=y().swappers(),f=y().fetchStatus,g=Rt().resetLanguage,C=be().getNotifications(),S=be().clearNotifications,k=Bh(),{fromBlockchain:T,toBlockchain:v,fromToken:w,toToken:A,inputAmount:M}=O(),x={isActiveTab:o,setCurrentTabAsActive:io.forceClaim,history:c,wallets:{isLoading:u,details:s(),totalBalance:p,refetch:async E=>l(E)},meta:{blockchains:d,tokens:h,swappers:m,loadingStatus:f,findToken:r},resetLanguage:g,notifications:{list:C,clearAll:S},quote:{quoteInputs:{fromBlockchain:T?.name??null,fromToken:w?{symbol:w.symbol,blockchain:w.blockchain,address:w.address}:null,toBlockchain:v?.name??null,toToken:A?{symbol:A.symbol,blockchain:A.blockchain,address:A.address}:null,requestAmount:M},updateQuoteInputs:k}};return GE.createElement(Mh.Provider,{value:x},t.children)}i(Rl,"WidgetInfo");function Lh(){let t=KE(Mh);if(!t)throw new Error("useWidget can only be used within the WidgetProvider component");return t}i(Lh,"useWidget");function ji(t){let{onUpdateState:e,config:o}=t,n=t.config?.theme?.fontFamily,{handleLoadCustomFont:r}=Nh();return Ph(()=>{n&&r(n)},[n]),XE(()=>{Qc({API_KEY:o?.apiKey||sr,BASE_URL:o?.apiUrl||yc})},[o.apiKey,o.apiUrl]),Ph(()=>{t.config?.signers?.customSolanaRPC&&jE("customRPC",t.config.signers.customSolanaRPC)},[t.config?.signers?.customSolanaRPC]),ec.createElement(Er,{config:o,onUpdateState:e},ec.createElement(Wh,{apiKey:o.apiKey},ec.createElement(Rl,null,t.children)))}i(ji,"WidgetProvider");function _h(t){let e=t.config?.externalWallets;return Xi.createElement(Pp,null,e?Xi.createElement(Vi,null):Xi.createElement(ji,{config:t.config??ar},Xi.createElement(Vi,null)))}i(_h,"Widget");function Dh(){let{on:t,off:e}=he;return{on:t,off:e}}i(Dh,"useWidgetEvents");var T3={DerivationPath:fn,Namespaces:mn,isOnDerivationPath:hn,isOnNamespace:gn};export{Kj as EventSeverity,Wo as MainEvents,n3 as Networks,a3 as PendingSwapNetworkStatus,pa as QuoteEventTypes,jj as RouteEventType,Ri as SUPPORTED_FONTS,T3 as StatefulConnect,Xj as StepEventType,Yj as StepExecutionBlockedEventStatus,Zj as StepExecutionEventStatus,De as UI_ID,da as UiEventTypes,ua as WalletEventTypes,t3 as WalletEvents,r3 as WalletTypes,_h as Widget,Wo as WidgetEvents,ji as WidgetProvider,Er as WidgetWallets,Ka as customizedThemeTokens,Rj as readAccountAddress,Gt as useStatefulConnect,ft as useWalletList,jr as useWallets,Lh as useWidget,Dh as useWidgetEvents,Uy as widgetEventEmitter};
1
+ var Oh=Object.defineProperty;var i=(t,e)=>Oh(t,"name",{value:e,configurable:!0});import{EventSeverity as Yj,RouteEventType as Zj,StepEventType as Jj,StepExecutionBlockedEventStatus as Rj,StepExecutionEventStatus as e3}from"@rango-dev/queue-manager-rango-preset";import{legacyReadAccountAddress as o3}from"@rango-dev/wallets-core/legacy";import{useWallets as Xr,Events as r3}from"@rango-dev/wallets-react";import{Networks as a3,WalletTypes as s3}from"@rango-dev/wallets-shared";import{PendingSwapNetworkStatus as c3}from"rango-types";import{Divider as LS}from"@rango-dev/ui";import co,{useEffect as PS,useRef as _S,useState as Wp}from"react";import{WalletState as Uh}from"@rango-dev/ui";import{useWallets as zh}from"@rango-dev/wallets-react";import{useReducer as Qh}from"react";function nc(t){return!!t.derivationPath}i(nc,"isStateOnDerivationPathStep");function rc(t){return!!t.namespace}i(rc,"isStateOnNamespace");var rr={status:"init",namespace:null,derivationPath:null};function ic(t,e){switch(e.type){case"needsNamespace":return{...t,status:"namespace",namespace:e.payload,derivationPath:null};case"needsDerivationPath":return{...t,status:"derivationPath",derivationPath:e.payload};case"reset":return rr;case"resetDerivation":return t.namespace?{...t,derivationPath:null,status:"namespace"}:rr;default:throw new Error("Action hasn't been defined.")}}i(ic,"reducer");function Gt(){let{state:t,disconnect:e,connect:o}=zh(),[n,r]=Qh(ic,rr),a=i(async(p,m,h)=>{r({type:"reset"});try{let d=m?.map(f=>({...f,network:void 0}));return await o(p,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(p,m)=>{if(p.state===Uh.DISCONNECTED){if(!!p.isHub&&p.properties?.find(k=>k.name==="detached")&&p.state!=="connected")return r({type:"needsNamespace",payload:{targetWallet:p}}),{status:"namespace"};if(!p.needsNamespace)return await a(p.type,void 0,m);let f=p.needsNamespace.data.length>1,g=p.needsDerivationPath;if(f)return r({type:"needsNamespace",payload:{targetWallet:p}}),{status:"namespace"};if(g){let C=p.needsNamespace.data[0];return r({type:"needsDerivationPath",payload:{providerType:p.type,providerImage:p.image,namespace:C.value}}),{status:"derivation-path"}}return await a(p.type,p.needsNamespace?.data.map(C=>({namespace:C.value})),m)}return m?.disconnectIfConnected?(await u(p.type),{status:"disconnected"}):{status:"disconnected-unhandled"}},"handleConnect"),l=i(async(p,m)=>{let h=p.needsNamespace?.selection==="single",d=p.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:p.type,providerImage:p.image,namespace:f}}),{status:"derivation-path"};if(!rc(n))throw new Error("Something went wrong on handling namespace. Please retry.");let g=n.namespace.targetWallet.type,C=m.map(S=>({namespace:S}));return await a(g,C)},"handleNamespace"),c=i(async p=>{if(!p)throw new Error("Derivation path is empty. Please make sure you've filled the field correctly.");if(!nc(n))throw new Error("It seems you are filling derivation path without setting namespace before doing that. Please retry to connect.");let m=n.derivationPath.providerType,d=[{namespace:n.derivationPath.namespace,derivationPath:p}];return await a(m,d)},"handleDerivationPath"),u=i(async p=>{let m=t(p);return m.connected||m.connecting?(await e(p),{status:"disconnected"}):{status:"noop"}},"handleDisconnect");return{handleConnect:s,handleDisconnect:u,handleNamespace:l,handleDerivationPath:c,getState:()=>n,resetState:p=>{r(p==="derivation"?{type:"resetDerivation"}:{type:"reset"})}}}i(Gt,"useStatefulConnect");import{WalletState as ha}from"@rango-dev/ui";import{useWallets as Zy}from"@rango-dev/wallets-react";import{detectMobileScreens as Jy,KEPLR_COMPATIBLE_WALLETS as Ry,WalletTypes as mn}from"@rango-dev/wallets-shared";import{useCallback as eS,useEffect as tS}from"react";import Vy,{createContext as Ky,useContext as jy,useEffect as Xy,useRef as Yy}from"react";import{create as Hy}from"zustand";import{persist as Gy}from"zustand/middleware";import{allProviders as qh}from"@rango-dev/provider-all";var Zi=class{static{i(this,"CacheService")}#e=new Map;get(e){return this.#e.get(e)}set(e,o){this.#e.set(e,o)}remove(e){this.#e.delete(e)}clear(){this.#e.clear()}},xo=new Zi;import{defineVersions as sc,pickVersion as lc,Provider as Ji}from"@rango-dev/wallets-core";function cc({allProviders:t,configWallets:e}){if(e){let o=[];return e.forEach(n=>{if(typeof n=="string"){let r=t.find(a=>{let s=pc(a);return s instanceof Ji?s.id===n:s.config.type===n});r?o.push(r):console.warn(`Couldn't find ${n} provider. Please make sure you are passing the correct name.`)}else n instanceof Ji?o.push(sc().version("1.0.0",n).build()):o.push(sc().version("0.0.0",n).build())}),o}return t}i(cc,"matchAndGenerateProviders");function pc(t){try{return lc(t,"1.0.0")[1]}catch{return lc(t,"0.0.0")[1]}}i(pc,"pickProviderVersionWithFallbackToLegacy");function uc(t){return t.map(o=>pc(o)).map(o=>o instanceof Ji?o.id:o.config.type)}i(uc,"configWalletsToWalletName");function ir(t,e){return e.find(o=>o.name===t)?.displayName}i(ir,"getBlockchainDisplayNameFor");function st(t,e){return e.find(o=>o.name===t)?.shortName}i(st,"getBlockchainShortNameFor");function mc(t,e){return e.find(o=>o.name===t)?.logo}i(mc,"getBlockchainImage");function nn(t,e){return e.find(o=>o.id===t)?.title}i(nn,"getSwapperDisplayName");function rn(t,e){return e.find(o=>o.name===t)??null}i(rn,"findBlockchain");function Ri(t,e){if(!e||!t)return!1;for(let o of e.feeAssets)if(t?.blockchain===o?.blockchain&&t?.symbol===o?.symbol&&t?.address===o?.address)return!0;return!1}i(Ri,"isTokenNative");function lt(t){return`${t.blockchain.toLowerCase()}-${t.symbol.toLowerCase()}-${(t.address??"").toLowerCase()}`}i(lt,"createTokenHash");function Eo(t,e){return t.addressPatterns.filter(r=>new RegExp(r).test(e)).length>0}i(Eo,"isValidTokenAddress");function an(t){let{config:e,meta:o}=t,n={},r=e.tokens,a=i(l=>{l.forEach(c=>{typeof c!="string"&&(c=lt(c));let u=o.tokensMapByTokenHash.get(c);u&&(n[c]=u)})},"addTokens");if(Array.isArray(r))return r.length>0?(a(r),Object.values(n)):Array.from(o.tokensMapByTokenHash.values());if(!r)return Array.from(o.tokensMapByTokenHash.values());let s;if(e.blockchains?.length)s=e.blockchains;else{s=Object.keys(r);let l=new Set(s);Object.keys(o.tokensMapByBlockchainName).forEach(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(u=>{let p=lt(u);delete n[p]})):a(c.tokens))}),Object.values(n)}i(an,"matchTokensFromConfigWithMeta");function ar(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(ar,"getSupportedBlockchainsFromConfig");function fc(t){return{walletConnectProjectId:t?.walletConnectProjectId,trezorManifest:t?.trezorManifest,tonConnect:t?.tonConnect,walletConnectListedDesktopWalletLink:t.__UNSTABLE_OR_INTERNAL__?.walletConnectListedDesktopWalletLink}}i(fc,"makeProvidersOptionsFromConfig");var sr={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"}},Hh={clientUrl:void 0},Gh={liquiditySources:void 0};function dc(t){let e=fc(t),o={walletconnect2:{WC_PROJECT_ID:e?.walletConnectProjectId||"",DISABLE_MODAL_AND_OPEN_LINK:e?.walletConnectListedDesktopWalletLink},selectedProviders:t.wallets,trezor:e?.trezorManifest?{manifest:e.trezorManifest}:void 0,tonConnect:e?.tonConnect?.manifestUrl?{manifestUrl:e?.tonConnect.manifestUrl}:void 0};return qh(o).map(a=>a())}i(dc,"generateProviders");var gc=i((t,e,o)=>{let n=dc({...sr,...t});return{config:{...sr,...t},iframe:Hh,campaignMode:Gh,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=an({type:"source",config:{blockchains:r.from?.blockchains,tokens:r.from?.tokens},meta:{tokensMapByBlockchainName:l,tokensMapByTokenHash:s}}),u=an({type:"destination",config:{blockchains:r.to?.blockchains,tokens:r.to?.tokens},meta:{tokensMapByBlockchainName:l,tokensMapByTokenHash:s}});xo.set("supportedSourceTokens",c),xo.set("supportedDestinationTokens",u),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=dc(r);e({allProviders:a})},getAvailableProviders:()=>{let{allProviders:r,config:a}=o(),s=fc(a);return cc({allProviders:r,configWallets:a.wallets,options:s})}}},"createConfigSlice");import{TransactionType as hc}from"rango-types";var yc=[hc.EVM,hc.SOLANA];import{RangoClient as ay}from"rango-sdk";import{UI_ID as Vh}from"@rango-dev/ui";var lr="c6381a79-2817-4602-83bf-6a641a409e32",Sc="https://api.rango.exchange",Cc="https://explorer.rango.exchange",De={SWAP_BOX_ID:"rango-swap-box",EXPANDED_BOX_ID:"rango-expanded-box",...Vh};import{BlockchainCategories as Rh,WalletState as bt}from"@rango-dev/ui";import{legacyReadAccountAddress as ey}from"@rango-dev/wallets-core/legacy";import{detectInstallLink as ty,getCosmosExperimentalChainInfo as oy,isEvmAddress as ny,KEPLR_COMPATIBLE_WALLETS as oA,Networks as Mc}from"@rango-dev/wallets-shared";import Ao from"bignumber.js";import{isCosmosBlockchain as ry}from"rango-types";import Kh from"bignumber.js";var ce=new Kh(0);import{WalletTypes as jh}from"@rango-dev/wallets-shared";var no="$$",kc=[jh.LEAP];import{BlockchainCategories as ta,WalletState as Jh}from"@rango-dev/ui";import{TransactionType as cr}from"rango-sdk";var Tc="Roboto",ea=[{name:"Roboto",value:"Roboto",url:""},{name:"Times New Roman",value:"Times New Roman",url:"https://fonts.cdnfonts.com/css/times-new-roman"},{name:"Arial",value:"Arial",url:""},{name:"Open Sans",value:"Open Sans",url:"https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,300..800;1,300..800&display=swap"},{name:"Noto Sans",value:"Noto Sans",url:"https://fonts.googleapis.com/css2?family=Noto+Sans:ital,wght@0,100..900;1,100..900&display=swap"},{name:"Montserrat",value:"Montserrat",url:"https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100..900;1,100..900&display=swap"},{name:"Poppins",value:"Poppins",url:"https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap"},{name:"Roboto Condensed",value:"Roboto Condensed",url:"https://fonts.googleapis.com/css2?family=Roboto+Condensed:ital,wght@0,100..900;1,100..900&display=swap"},{name:"Roboto Mono",value:"Roboto Mono",url:"https://fonts.googleapis.com/css2?family=Roboto+Mono:ital,wght@0,100..700;1,100..700&display=swap"},{name:"Oswald",value:"Oswald",url:"https://fonts.googleapis.com/css2?family=Oswald:wght@200..700&display=swap"},{name:"Raleway",value:"Raleway",url:"https://fonts.googleapis.com/css2?family=Raleway:ital,wght@0,100..900;1,100..900&display=swap"},{name:"Sedan",value:"Sedan",url:"https://fonts.googleapis.com/css2?family=Sedan:ital@0;1&display=swap"},{name:"Inter",value:"Inter",url:"https://fonts.googleapis.com/css2?family=Inter:wght@100..900&display=swap"},{name:"Rubik",value:"Rubik",url:"https://fonts.googleapis.com/css2?family=Rubik:ital,wght@0,300..900;1,300..900&display=swap"},{name:"Lora",value:"Lora",url:"https://fonts.googleapis.com/css2?family=Lora:ital,wght@0,400..700;1,400..700&display=swap"},{name:"Barlow Condensed",value:"Barlow Condensed",url:"https://fonts.googleapis.com/css2?family=Barlow+Condensed:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap"}];function Io(t){return Array.from(new Set(t))}i(Io,"removeDuplicateFrom");function Ic(t,e){let o;return n;function n(...r){o&&clearTimeout(o),o=setTimeout(()=>{o=null,t(...r)},e)}}i(Ic,"debounce");function Je(t,e){return t.toLowerCase().indexOf(e.toLowerCase())>-1}i(Je,"containsText");function bc(t,e){return t.toLowerCase()===e.toLowerCase()}i(bc,"exactText");function xc(t,e){return t.toLowerCase().startsWith(e.toLowerCase())}i(xc,"startWithText");var N=i(()=>document.getElementById(De.SWAP_BOX_ID),"getContainer"),ro=i(()=>document.getElementById(De.EXPANDED_BOX_ID),"getExpanded");function Ec(t,e,o){let n=!!e&&bc(e,t),r=!!o&&bc(o,t);return n!==r?n?-1:1:0}i(Ec,"compareExactMatchText");function oa(t,e,o){let n=!!e&&Je(e,t),r=!!o&&Je(o,t);return n!==r?n?-1:1:n&&r&&e?.length!==o?.length?e?.length-o?.length:0}i(oa,"compareContainsText");function na(t,e,o){let n=!!e&&xc(e,t),r=!!o&&xc(o,t);return n!==r?n?-1:1:n&&r&&e?.length!==o?.length?e?.length-o?.length:0}i(na,"compareStartWithText");function Ac(t,e,o){if(!o)return 0;let n=Ec(o,t.symbol,e.symbol);if(n)return n;if(o.length>=3){let r=Ec(o,t.name,e.name);if(r)return r}if(o.length>=2){let r=na(o,t.symbol,e.symbol);if(r)return r}if(o.length>=3){let r=oa(o,t.symbol,e.symbol);if(r)return r}if(o.length>=3){let r=na(o,t.name,e.name);if(r)return r}if(o.length>=3){let r=oa(o,t.name,e.name);if(r!==0)return r}if(o.length>=4){let r=na(o,t.address,e.address);if(r)return r}if(o.length>=4){let r=oa(o,t.address,e.address);if(r!==0)return r}return 0}i(Ac,"compareWithSearchFor");var pr=i((t,e)=>{switch(e){case ta.ALL:return!0;case ta.UTXO:return t===cr.TRANSFER;case ta.OTHER:return t!==cr.TRANSFER&&t!==cr.COSMOS&&t!==cr.EVM;default:return t===e}},"isBlockchainTypeInCategory"),Nc=i(t=>ea.find(o=>o.value===t)?.url,"getFontUrlByName");function Wc(t,e){let o=!!t.find(n=>n.state===Jh.CONNECTED);return e===!1&&o}i(Wc,"isSingleWalletActive");import{BigNumber as Bc}from"bignumber.js";var sn=i(t=>{let e=Math.floor(t%60/15)*15,o=parseInt((t/60).toString());return o>=60?`${Math.floor(o/5)*5}:00`:`${o.toString().padStart(2,"0")}:${e.toString().padStart(2,"0")}`},"roundedSecondsToString"),L=i((t,e=null,o=null)=>{if(t==null||t==="")return"";let n=new Bc(t),r=1,a=1e3;for(let s=0;s<60;s++)if(new Bc(n.toFixed(s,r)).eq(n)){a=s;break}if(n.gte(1e4))return n.toFormat(0,r);if(n.gte(1e3)||n.gte(100))return n.toFormat(Math.min(a,Math.min(o||100,Math.max(e||0,1))),r);if(n.gte(1))return n.toFormat(Math.min(a,Math.min(o||100,Math.max(e||0,2))),r);if(n.gte(.01))return n.toFormat(Math.min(a,Math.min(o||100,Math.max(e||0,4))),r);for(let s=e||4;s<17;s++)if(n.gte(Math.pow(10,-s)))return n.toFormat(Math.min(a,Math.min(o||100,Math.max(e||0,s))),r);return n.isEqualTo(0)?"0":n.toFormat(Math.min(a,Math.min(o||100,Math.max(e||0,8))),r)},"numberToString");var ur=i(t=>t?.reduce((e,o)=>e+(o.estimatedTimeInSeconds??0),0)||0,"totalArrivalTime");var wt=i((t,e)=>t.toLowerCase().indexOf(e.toLowerCase())>-1,"containsText"),ln=i(t=>!!t&&parseFloat(t)>0,"isPositiveNumber");function cn(t){switch(!0){case t.connected:return bt.CONNECTED;case t.connecting:return bt.CONNECTING;case!t.installed:return bt.NOT_INSTALLED;default:return bt.DISCONNECTED}}i(cn,"mapStatusToWalletState");function Lc(t,e,o,n){return o.filter(r=>!kc.includes(r)).filter(r=>{let{supportedChains:a,isContractWallet:s}=e(r),{installed:l,network:c}=t(r);return s&&(!l||!!n&&c!==n)?!1:n?!!a.find(p=>p.name===n):!0}).map(r=>{let{name:a,img:s,installLink:l,showOnMobile:c,needsNamespace:u,supportedChains:p,needsDerivationPath:m,properties:h,isHub:d}=e(r),f=Io(p.map(C=>C.type)),g=cn(t(r));return{title:a,image:s,link:ty(l),state:g,type:r,showOnMobile:c,needsNamespace:u,blockchainTypes:f,needsDerivationPath:m,properties:h,isHub:d}})}i(Lc,"mapWalletTypesToWalletInfo");function fr(t){if(!t)return null;let e=[];return e=t.map(o=>o.name),e}i(fr,"walletAndSupportedChainsNames");function ia(t,e,o,n,r){let a=[];function s(c,u){if(!!!a.find(m=>m.chain===c)){let m={address:u,chain:c,walletType:t};a.push(m)}}i(s,"addAccount");let l=n||[];return e.forEach(c=>{let{address:u,network:p}=ey(c),m=l.length>0,h=l.includes(p),d=p===Mc.Unknown;if(m&&!h&&!d)return;let g=p===Mc.Unknown&&ny(u);if(d&&!g)return;o.includes(p)||g?r?s(p,u.toLowerCase()):l.filter(k=>o.includes(k)).forEach(k=>{s(k,u.toLowerCase())}):s(p,u)}),a}i(ia,"prepareAccountsForWalletStore");function io(t){let{filter:e,quote:o}=t,n=new Set;return o?.swaps.forEach((r,a)=>{let s=r.from.blockchain,l=r.to.blockchain;if(n.add(s),r.internalSwaps){let{internalSwaps:c}=r;c.forEach((u,p)=>{let m=u.from.blockchain,h=u.to.blockchain,d=a===o.swaps.length-1,f=p===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(io,"getQuoteWallets");function Pc(t,e){return t.address===e.address&&t.chain===e.chain&&t.walletType===e.walletType}i(Pc,"isAccountAndWalletMatched");var _c=i(t=>{let e=Object.values(t).reduce((o,n)=>{let r=n.usdValue?ra(n.usdValue,n.decimals):ce.toFixed();return o.plus(r)},new Ao(ce));return iy(e.toString())},"calculateWalletUsdValue");function iy(t){let e=t.toString().split(".");return e[0]=e[0].replace(/\B(?=(\d{3})+(?!\d))/g,","),e.join(".")}i(iy,"numberWithThousandSeparator");var gr=i((t,e)=>{let o=oy(Object.entries(t).map(([,n])=>n).filter(ry));return o&&o[e]?.experimental},"isExperimentalChain");function ra(t,e){return new Ao(t).shiftedBy(-e).toFixed()}i(ra,"representAmountInNumber");function hr(t){if(!t)return null;let e=ra(t.amount,t.decimals),o=t.usdValue?ra(t.usdValue,t.decimals):null,n=L(e,8,8),r=o?L(o,4,4):null;return t?{...t,amount:n,usdValue:r}:null}i(hr,"formatBalance");function Dc(t,e){if(t?.usdValue||e?.usdValue){let o=t&&t.usdValue?new Ao(t.usdValue).shiftedBy(-t.decimals):ce,n=e&&e.usdValue?new Ao(e.usdValue).shiftedBy(-e.decimals):ce;return o.isEqualTo(n)?0:o.isGreaterThan(n)?-1:1}if(t?.amount||e?.amount){let o=t&&t.amount?new Ao(t.amount).shiftedBy(-t.decimals):ce,n=e&&e.amount?new Ao(e.amount).shiftedBy(-e.decimals):ce;return o.isEqualTo(n)?0:o.isGreaterThan(n)?-1:1}return 0}i(Dc,"compareTokenBalance");function Mt(t,e){return t?.blockchain===e?.blockchain&&t?.symbol.toLowerCase()===e?.symbol.toLowerCase()&&t?.address?.toLowerCase()===e?.address?.toLowerCase()}i(Mt,"areTokensEqual");function $c(t){return t.sort((e,o)=>+(o.state===bt.CONNECTED)-+(e.state===bt.CONNECTED)||+(o.state===bt.DISCONNECTED||o.state===bt.CONNECTING)-+(e.state===bt.DISCONNECTED||e.state===bt.CONNECTING))}i($c,"sortWalletsBasedOnConnectionState");function yr(t,e=8,o=3){if(t.length<2*e+o)return t;let n=t.slice(0,e),r=t.slice(-e);return`${n}${".".repeat(o)}${r}`}i(yr,"getConciseAddress");function Fc({chain:t,connectedWallets:e,walletType:o}){return e.find(n=>n.walletType===o&&n.chain===t)?.address}i(Fc,"getAddress");var Oc=i((t,e)=>!!t.find(o=>o.chain===e&&o.loading),"isFetchingBalance");function Uc(t){return t.map(e=>e.state).join("-")}i(Uc,"hashWalletsState");function zc(t,e){let o=new Set;return t.forEach(r=>{r.blockchainTypes.forEach(a=>{o.add(a)})}),e.filter(r=>o.has(r.type))}i(zc,"filterBlockchainsByWalletTypes");function Qc(t,e){return e===Rh.ALL?t:t.filter(o=>{for(let n of o.blockchainTypes)if(pr(n,e))return!0;return!1})}i(Qc,"filterWalletsByCategory");var aa={API_KEY:lr};function Lt(t){return aa[t]||""}i(Lt,"getConfig");function qc(t){let e;return typeof structuredClone=="function"?e=structuredClone(t):e=JSON.parse(JSON.stringify(t)),aa=e,aa}i(qc,"initConfig");var Hc=20,Gc=25,sa="theme-widget",la=i((t,e)=>{let o=!1;if(e&&t){if(Array.isArray(e))o=!e.some(n=>Mt(n,t));else if(!Array.isArray(e)&&e[t.blockchain]){o=e[t.blockchain].tokens.some(r=>Mt(r,t));let n=e[t.blockchain].isExcluded;return!n&&!o||n&&o}}return o},"isTokenExcludedInConfig"),ca=i((t,e)=>t&&e&&!e.includes(t.name),"isBlockchainExcludedInConfig"),Vc=i((t,e,o)=>o==="expanded"&&(t||e)||o==="full-expanded"&&e,"isVariantExpandable");var Sr,xt=i(()=>Sr||(Sr=new ay(Lt("API_KEY"),Lt("BASE_URL")),Sr),"httpService");function Cr(t,e){let o=t.map(a=>a.swapperGroup),n=[];return Io(t.map(a=>a.swapperGroup)).map(a=>{let s=t.find(l=>l.swapperGroup===a);if(s){let l=!0;o&&(l=o.some(c=>c===s.swapperGroup)),l&&s.types.map(c=>{n.push({id:s.swapperGroup,groupTitle:s.swapperGroup,logo:s.logo,type:c,selected:!e.includes(s.swapperGroup)})})}}),n}i(Cr,"getUniqueSwappersGroups");function Kc(t,e){return t.swapperGroup<e.swapperGroup?-1:t.swapperGroup>e.swapperGroup?1:0}i(Kc,"sortLiquiditySourcesByGroupTitle");function Ve(t,e){return e?.[t]==="hidden"}i(Ve,"isFeatureHidden");function No(t,e){return e?.[t]==="enabled"}i(No,"isRoutingEnabled");var jc=i((t,e,o)=>Ve("customTokens",o)?t:t.concat(e),"addCustomTokensToSupportedTokens");var Xc=i((t,e)=>({_blockchainsMapByName:new Map,_tokensMapByTokenHash:new Map,_tokensMapByBlockchainName:{},_popularTokens:[],_swappers:[],fetchStatus:"loading",blockchains:o=>{let n=e()._blockchainsMapByName,r=Array.from(n?.values()||[]);if(!o||!o?.type)return r;let a=e().config;if(o.type==="custom-token"){let c=ar({config:a}),u=r;return c.length>0&&(u=u.filter(p=>c.includes(p.name))),u.filter(p=>yc.includes(p.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 u=o.type==="source"?"from":"to",p=o.type==="source"?"supportedSourceTokens":"supportedDestinationTokens",m=xo.get(p);m?.length||(m=an({type:o.type,config:{blockchains:a[u]?.blockchains,tokens:a[u]?.tokens},meta:{tokensMapByTokenHash:n,tokensMapByBlockchainName:r}}),xo.set(p,m)),m=jc(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?!!(Je(f.symbol,o.searchFor)||Je(f.address||"",o.searchFor)||Je(f.name||"",o.searchFor)):!0).sort((f,g)=>{let C=e().isTokenPinned(f,o.type),S=e().isTokenPinned(g,o.type);if(C!==S)return C?-1:1;if(o.getBalanceFor){let A=o.getBalanceFor(f),M=o.getBalanceFor(g),x=Dc(A,M);if(x!==0)return x}let k=c.get(f.blockchain),T=c.get(g.blockchain),v=Ri(f,k),w=Ri(g,T);if(v!==w)return v?-1:1;if(f.isPopular!==g.isPopular)return f.isPopular?-1:1;if(o.searchFor){let A=Ac(f,g,o.searchFor);if(A)return A}return f.isSecondaryCoin!==g.isSecondaryCoin?f.isSecondaryCoin?1:-1:k&&T?k.sort-T.sort:0})},findToken:o=>{let n=e()._tokensMapByTokenHash,r=e().customTokens(),a=lt(o),s=n.get(a);return s||(s=r.find(l=>lt(l)===a)),s},isTokenPinned:(o,n)=>!!(n==="source"?e().config.from?.pinnedTokens:e().config.to?.pinnedTokens)?.some(s=>Mt(s,o)),swappers:()=>{let{config:o,campaignMode:n}=e(),r=n.liquiditySources?.length?n.liquiditySources:null,a=r??o.liquiditySources,s=r?!1:o.excludeLiquiditySources;return e()._swappers.filter(u=>{let p=a?.includes(u.swapperGroup);return s||!a||a.length===0?!p:p}).sort(Kc)},fetch:async()=>{try{let{routing:o}=e().config,n=No("enableCentralizedSwappers",o),r=await xt().getAllMetadata({enableCentralizedSwappers:n});t({fetchStatus:"success"});let a=new Map,s=new Map,l={},c=[],u=r.popularTokens,p=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=lt(d);l[d.blockchain]||(l[d.blockchain]=[]),s.set(f,d),l[d.blockchain].push(f)}),t({_blockchainsMapByName:a,_tokensMapByTokenHash:s,_tokensMapByBlockchainName:l,_popularTokens:u,_swappers:p})}catch(o){throw t({fetchStatus:"failed"}),o}}}),"createDataSlice");import{Bengali as sy,Catalonia as ly,Chinese as Yc,Denmark as cy,English as py,Finland as uy,French as my,German as dy,Greece as fy,Hungary as gy,India as hy,Indonesian as yy,Italian as Sy,Japanese as Cy,Korea as ky,Lithuania as Ty,Malay as vy,Netherlands as wy,Pakistan as by,Philippines as xy,Poland as Ey,Portuguese as Iy,Russian as Ay,SaudiArabia as Ny,Serbia as Wy,Slovakia as By,SouthAfrica as My,Spanish as Ly,Swahili as Py,Swedish as _y,Thai as Dy,Turkish as $y,Ukrainian as Fy,Vietnamese as Oy}from"@rango-dev/ui";var Zc=[{title:"Afrikaans",label:"Afrikaans",local:"af",SVGFlag:My},{title:"Arabic",label:"\u0639\u0631\u0628\u064A",local:"ar",SVGFlag:Ny},{title:"Bengali",label:"\u09AC\u09BE\u0982\u09B2\u09BE",local:"bn",SVGFlag:sy},{title:"Catalan",label:"Catal\xE0",local:"ca",SVGFlag:ly},{title:"Chinese (Simplified)",label:"\u7B80\u4F53\u4E2D\u6587",local:"zh-CN",SVGFlag:Yc},{title:"Chinese (Traditional)",label:"\u4E2D\u6587\uFF08\u7E41\u9AD4)",local:"zh-TW",SVGFlag:Yc},{title:"Danish",label:"Dansk",local:"da",SVGFlag:cy},{title:"Dutch",label:"Nederlands",local:"nl",SVGFlag:wy},{title:"English",label:"English",local:"en",SVGFlag:py},{title:"Filipino",label:"Filipino",local:"fil",SVGFlag:xy},{title:"Finnish",label:"Suomalainen",local:"fi",SVGFlag:uy},{title:"French",label:"Fran\xE7ais",local:"fr",SVGFlag:my},{title:"German",label:"Deutsch",local:"de",SVGFlag:dy},{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:hy},{title:"Hungarian",label:"Magyar",local:"hu",SVGFlag:gy},{title:"Indonesian",label:"Indonesia",local:"id",SVGFlag:yy},{title:"Italian",label:"Italiana",local:"it",SVGFlag:Sy},{title:"Japanese",label:"\u65E5\u672C\u8A9E",local:"ja",SVGFlag:Cy},{title:"Korean",label:"\uD55C\uAD6D\uC778",local:"ko",SVGFlag:ky},{title:"Lithuanian",label:"Lietuvi\u0173",local:"lt",SVGFlag:Ty},{title:"Malay",label:"Melayu",local:"ms",SVGFlag:vy},{title:"Polish",label:"Polski",local:"pl",SVGFlag:Ey},{title:"Portuguese",label:"Portugu\xEAs",local:"pt",SVGFlag:Iy},{title:"Russian",label:"\u0420\u0443\u0441\u0441\u043A\u0438\u0439",local:"ru",SVGFlag:Ay},{title:"Serbian",label:"C\u0440\u043F\u0441\u043A\u0438",local:"sr",SVGFlag:Wy},{title:"Slovak",label:"Slovensk\xFD",local:"sk",SVGFlag:By},{title:"Spanish",label:"Espa\xF1ol",local:"es",SVGFlag:Ly},{title:"Swahili",label:"Kiswahili",local:"sw",SVGFlag:Py},{title:"Swedish",label:"Svenska",local:"sv",SVGFlag:_y},{title:"Thai",label:"\u0E41\u0E1A\u0E1A\u0E44\u0E17\u0E22",local:"th",SVGFlag:Dy},{title:"Turkish",label:"T\xFCrk\xE7e",local:"tr",SVGFlag:$y},{title:"Ukrainian",label:"Y\u043A\u0440\u0430\u0457\u043D\u0456",local:"uk",SVGFlag:Fy},{title:"Urdu",label:"\u0627\u0631\u062F\u0648",local:"ur",SVGFlag:by},{title:"Vietnamese",label:"Ti\u1EBFng Vi\u1EC7t",local:"vi",SVGFlag:Oy}],Wo="en";var Jc=[.5,1,3],Rc=1,ep=5,tp=100,op=0;var np=i((t,e)=>({disabledLiquiditySources:[],theme:"auto",language:null,preferredBlockchains:[],slippage:Rc,customSlippage:null,infiniteApprove:!1,affiliateRef:null,affiliatePercent:null,affiliateWallets:null,_customTokens:[],addPreferredBlockchain:o=>{let n=e().preferredBlockchains;if(n.find((s,l)=>{let c=s===o,u=l<=9;return c&&u}))return;let a=n.filter(s=>!(s===o));t(()=>({preferredBlockchains:[o,...a]}))},setSlippage:o=>t(()=>({slippage:o})),setCustomSlippage:o=>t(()=>({customSlippage:o})),setAffiliateRef:o=>t(()=>({affiliateRef:o})),setAffiliatePercent:o=>t(()=>({affiliatePercent:o})),setAffiliateWallets:o=>t(()=>({affiliateWallets:o})),toggleAllLiquiditySources:(o,n)=>t(r=>{if(n)return{disabledLiquiditySources:[]};let a=Io(o.map(s=>s.swapperGroup));return a.length===r.disabledLiquiditySources.length?{disabledLiquiditySources:[]}:{disabledLiquiditySources:a}}),toggleInfiniteApprove:()=>t(o=>({infiniteApprove:!o.infiniteApprove})),toggleLiquiditySource:o=>t(n=>n.disabledLiquiditySources.includes(o)?{disabledLiquiditySources:n.disabledLiquiditySources.filter(r=>r!=o)}:{disabledLiquiditySources:n.disabledLiquiditySources.concat(o)}),setTheme:o=>t(()=>({theme:o})),setLanguage:o=>t(()=>({language:o})),updateSettings:o=>{let{features:n,theme:r}=o,a=Ve("theme",n),s=Ve("language",n),l=Ve("liquiditySource",n),c=r?.singleTheme,u=o?.__UNSTABLE_OR_INTERNAL__?.autoUpdateSettings;t({...a&&{theme:o.theme?.mode||"auto"},...c&&{theme:o.theme?.mode||"light"},...s&&{language:o.language||Wo},...l&&{disabledLiquiditySources:o.liquiditySources||[]},...u&&{language:o.language||Wo}})},setCustomToken:o=>t(n=>({_customTokens:[o,...n._customTokens]})),deleteCustomToken:o=>t(n=>({_customTokens:n._customTokens.filter(r=>r.address!==o.address)})),customTokens:()=>{let o=e().config,n=e()._customTokens,r=ar({config:o});return r.length?n.filter(a=>r.includes(a.blockchain)):n}}),"createSettingsSlice");import ga from"bignumber.js";import Uy from"mitt";var he=Uy(),zy={on:he.on,off:he.off};import{WidgetEvents as rp}from"@rango-dev/queue-manager-rango-preset";var ua=(o=>(o.QUOTE_INPUT_UPDATE="quoteInputUpdate",o.QUOTE_OUTPUT_UPDATE="quoteOutputUpdate",o))(ua||{}),ma=(o=>(o.CONNECT="connect",o.DISCONNECT="disconnect",o))(ma||{}),da=(e=>(e.CLICK_CONNECT_WALLET="clickConnectWallet",e))(da||{}),Bo=(a=>(a[a.RouteEvent=rp.RouteEvent]="RouteEvent",a[a.StepEvent=rp.StepEvent]="StepEvent",a.QuoteEvent="quoteEvent",a.WalletEvent="walletEvent",a.UiEvent="uiEvent",a))(Bo||{});import Qy from"bignumber.js";function pn(t){return`${t.blockchain}${no}${t.address}${no}${t.symbol}`}i(pn,"createAssetKey");function fa(t,e){return`${pn(e)}${no}${t}`}i(fa,"createBalanceKey");function un(t){let[e,o,n]=t.split(no);return{address:o==="null"?null:o,blockchain:e,symbol:n}}i(un,"extractAssetFromBalanceKey");function ip(t,e){let o={};return t.balances?.forEach(n=>{let r=fa(t.address,n.asset),a=n.amount.amount,s=n.amount.decimals,l=e().findToken(n.asset)?.usdPrice,c=l?new Qy(l??ce).multipliedBy(a).toString():"",u={amount:a,decimals:s,usdValue:c};o[r]=u}),o}i(ip,"createBalanceStateForNewAccount");function ap(t,e){for(let o in e){let n=un(o),r=pn(n);t[r]||(t[r]=[]),t[r].includes(o)||(t[r]=[...t[r],o])}return t}i(ap,"updateAggregatedBalanceStateForNewAccount");function sp(t,e){let o=un(e),n=pn(o);return t[n]&&(t[n]=t[n].filter(r=>r!==e)),t}i(sp,"removeBalanceFromAggregatedBalance");function qy(t,e){return e.find(o=>t.address===o.address&&t.chain===o.blockChain)}i(qy,"matchWalletDetailsWithConnectedWallet");var lp=i((t,e)=>({_balances:{},_aggregatedBalances:{},connectedWallets:[],fetchingWallets:!1,setConnectedWalletAsRefetching:o=>{t(n=>({fetchingWallets:!0,connectedWallets:n.connectedWallets.map(r=>r.walletType===o?{...r,loading:!0,error:!1}:r)}))},setConnectedWalletRetrievedData:(o,n)=>{t(r=>({fetchingWallets:!1,connectedWallets:r.connectedWallets.map(a=>a.walletType===o?{...a,loading:!1,error:!1,explorerUrl:qy(a,n)?.explorerUrl||a.explorerUrl}:a)}))},setConnectedWalletHasError:o=>{t(n=>({fetchingWallets:!1,connectedWallets:n.connectedWallets.map(r=>r.walletType===o?{...r,loading:!1,error:!0}:r)}))},addConnectedWallet:(o,n)=>{let r=e().connectedWallets,a=o.filter(s=>!r.some(l=>Pc(s,l)));if(a.length>0){let s=a.map(l=>{let c=!r.some(u=>u.chain===l.chain&&u.selected&&u.walletType!==l.walletType);return{address:l.address,chain:l.chain,explorerUrl:null,walletType:l.walletType,selected:c,namespace:n,loading:!1,error:!1}});t(l=>({connectedWallets:[...l.connectedWallets.filter(u=>!s.some(p=>p.walletType===u.walletType&&p.chain===u.chain)),...s]}))}},setWalletsAsSelected:o=>{let n=e().connectedWallets.map(r=>{let a=!!o.find(l=>l.chain===r.chain&&l.walletType!==r.walletType&&r.selected),s=!!o.find(l=>l.chain===r.chain&&l.walletType===r.walletType&&!r.selected);return a?{...r,selected:!1}:s?{...r,selected:!0}:r});t({connectedWallets:n})},newWalletConnected:async(o,n)=>{he.emit("walletEvent",{type:"connect",payload:{walletType:o[0].walletType,accounts:o}}),e().addConnectedWallet(o,n),e().fetchBalances(o)},removeBalancesForWallet:(o,n)=>{let r=e().connectedWallets.filter(u=>u.walletType===o);e().connectedWallets.forEach(u=>{u.walletType!==o&&(r=r.filter(p=>!(p.chain===u.chain&&p.address===u.address)))}),n?.chains&&n.chains.length>0&&(r=r.filter(u=>n.chains?.includes(u.chain))),n?.namespaces&&n.namespaces.length>0&&(r=r.filter(u=>u.namespace?n.namespaces?.includes(u.namespace):!1));let a={},s=e()._aggregatedBalances,l=e()._balances;Object.keys(l).forEach(u=>{let p=un(u);!!r.find(h=>fa(h.address,{address:p.address,blockchain:h.chain,symbol:p.symbol})===u)?s=sp(s,u):a[u]=l[u]}),t({_balances:a,_aggregatedBalances:s})},disconnectWallet:o=>{if(e().connectedWallets.find(r=>r.walletType===o)){he.emit("walletEvent",{type:"disconnect",payload:{walletType:o}}),e().removeBalancesForWallet(o);let r=e().connectedWallets.filter(s=>s.selected&&s.walletType===o).map(s=>s.chain),a=e().connectedWallets.filter(s=>s.walletType!==o);r.length>0&&(a=a.map(s=>r.includes(s.chain)?(r=r.filter(l=>l!==s.chain),{...s,selected:!0}):s)),t({connectedWallets:a})}},clearConnectedWallet:()=>t({connectedWallets:[]}),fetchBalances:async(o,n)=>{let r=o[0].walletType;e().setConnectedWalletAsRefetching(r);let a=o.map(c=>({address:c.address,blockchain:c.chain})),l=(await xt().getWalletsDetails(a)).wallets;if(l){let{retryOnFailedBalances:c=!0}=n||{};if(c){let 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 u={},p=e()._aggregatedBalances;l.forEach(m=>{if(m.failed||(e().removeBalancesForWallet(r,{chains:[m.blockChain]}),!e().connectedWallets.find(d=>d.walletType===r&&d.address===m.address&&d.chain===m.blockChain)))return;let h=ip(m,e);p=ap(p,h),u={...u,...h}}),t(m=>({_balances:{...m._balances,...u},_aggregatedBalances:p})),e().setConnectedWalletRetrievedData(r,l)}else throw e().setConnectedWalletHasError(r),new Error("We couldn't fetch your account balances. Seem there is no information on blockchain for them yet.")},getBalances:()=>e()._balances,getBalanceFor:o=>{let n=e().getBalances(),r=pn(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 u=n[c],p=new ga(u.amount),m=new ga(l.amount);p.isGreaterThan(m)&&(l=u)}),l},getBalancesForWalletAddress:o=>{let n=e().getBalances();return Object.keys(n).reduce((s,l)=>{let c=n[l],[,,,u]=l.split(no);return u===o&&(s[l]=c),s},{})},getConnectedWalletsDetails:()=>e().connectedWallets.map(n=>{let r=e().getBalancesForWalletAddress(n.address),a=Object.keys(r);return{...n,balances:a.reduce((s,l)=>{let c=r[l],u=un(l);if(u.blockchain===n.chain){let p=e().findToken(u),m=c.amount?new ga(c.amount).shiftedBy(-c.decimals):ce;s.push({chain:n.chain,symbol:u.symbol,ticker:u.symbol,address:u.address,rawAmount:c.amount,decimal:c.decimals,amount:m.toString(),logo:p?.image||null,usdPrice:p?.usdPrice||null})}return s},[])}})}),"createWalletsSlice");function cp(t){return Hy()(Gy((...e)=>({...lp(...e),...Xc(...e),...np(...e),...gc(t,...e)}),{name:"user-settings",skipHydration:!0,partialize:e=>({_customTokens:e._customTokens,theme:e.theme,language:e.language,affiliatePercent:e.affiliatePercent,affiliateRef:e.affiliateRef,affiliateWallets:e.affiliateWallets,slippage:e.slippage,customSlippage:e.customSlippage,infiniteApprove:e.infiniteApprove,preferredBlockchains:e.preferredBlockchains,disabledLiquiditySources:e.disabledLiquiditySources})}))}i(cp,"createAppStore");var pp=Ky(null);function y(){let t=jy(pp);if(Xy(()=>{t&&!t.persist.hasHydrated()&&t.persist.rehydrate()},[]),!t)throw new Error("Missing AppStoreContext.Provider in the tree");return t()}i(y,"useAppStore");function up(t){let e=Yy();return e.current||(e.current=cp(t.config)),Vy.createElement(pp.Provider,{value:e.current},t.children)}i(up,"AppStoreProvider");function ft(t){let{chain:e}=t||{},{connectedWallets:o,getAvailableProviders:n}=y(),{state:r,getWalletInfo:a}=Zy(),s=y().blockchains(),{handleDisconnect:l}=Gt(),c=uc(n()),u=Lc(r,a,c,e);u=Jy()?u.filter(g=>g.showOnMobile!==!1&&r(g.type).installed):u;let p=$c(u),m=i(g=>!o.find(C=>C.walletType===g&&C.chain===e),"isExperimentalChainNotAdded"),h=eS(()=>{let g=u?.filter(C=>C.state===ha.CONNECTING)||[];for(let C of g)l(C.type)},[Uc(u)]);tS(()=>()=>{h()},[]);let d=i(g=>{let C=g.find(k=>k.type===mn.DEFAULT);return!C||C.state===ha.NOT_INSTALLED?!1:g.filter(k=>k.state!=ha.NOT_INSTALLED&&![mn.DEFAULT,mn.WALLET_CONNECT_2,mn.LEDGER].includes(k.type)&&a(k.type).supportedChains.filter(T=>T.type=="EVM").length>0).length==0},"shouldShowDefaultInjectedWallet"),f=i((g,C,S)=>gr(S,C)&&m(g)&&!Ry.includes(g)||g==mn.DEFAULT&&!d(u),"shouldExcludeWallet");return{list:p.filter(g=>!f(g.type,e??"",s)),terminateConnectingWallets:h}}i(ft,"useWalletList");import{Modal as iS}from"@rango-dev/ui";import aS from"react";import{create as rS}from"zustand";var mp="rango-widget";var dn=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(mp),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 nS=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"),Mo=nS;var re=Mo(rS()((t,e)=>({isActiveTab:!1,tabManagerInitiated:!1,showActivateTabModal:!1,watermark:"NONE",showProfileBanner:!1,fetchingApiConfig:!1,activateCurrentTab:(o,n)=>{let{showActivateTabModal:r}=e();!r&&n?t({showActivateTabModal:!0}):(r||!n)&&o()},setShowActivateTabModal:o=>{t({showActivateTabModal:o})},setWatermark:o=>{t({watermark:o})},setShowProfileBanner:o=>{t({showProfileBanner:o})}}))),ao=new dn({onInit:()=>re.setState({tabManagerInitiated:!0}),onClaim:()=>re.setState({isActiveTab:!0,showActivateTabModal:!1}),onRelease:()=>re.setState({isActiveTab:!1})});function J(t){let{watermark:e}=re();return aS.createElement(iS,{hasWatermark:e==="FULL",...t},t.children)}i(J,"WatermarkedModal");import{i18n as ya}from"@lingui/core";import{Button as mS,Checkbox as dS,Divider as fS,Image as vp,ListItemButton as gS,MessageBox as hS,Radio as yS,RadioRoot as SS}from"@rango-dev/ui";import we,{useState as CS}from"react";import{css as sS,darkTheme as fp,IconButton as lS,styled as so}from"@rango-dev/ui";var Et=so(lS,{width:"$24",position:"relative",padding:"0",overflow:"unset","&:hover":{backgroundColor:"$secondary100",[`.${fp} &`]:{backgroundColor:"$neutral"}}}),gp=so("div",{position:"absolute",background:"$secondary500",[`.${fp} &`]:{$$color:"$colors$secondary250"},width:"$6",height:"$6",borderRadius:"$lg",right:"$4",border:"1px solid $surface100"}),Vt=so("div",{display:"flex",justifyContent:"flex-end",minWidth:"$40",button:{padding:0}}),hp=so("div",{position:"absolute",width:"14px",height:"14px",display:"flex",justifyContent:"center",alignItems:"center",borderRadius:"7px",top:"$0",right:"$0",variants:{isSever:{true:{backgroundColor:"$error500"},false:{backgroundColor:"$secondary500"}}}}),yp=so("div",{padding:"$2",variants:{isRefetched:{true:{transform:"rotate(360deg)",transition:"transform 1s ease-in-out"}}}}),Sp=so("div",{position:"absolute",right:"$4",top:"$4",backgroundColor:"$background",borderRadius:"100%"}),Cp=sS({display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center"}),kr=so("div",{borderRadius:"100%",border:"1.5px transparent solid","&:not(:first-child)":{marginLeft:"-$6"},img:{borderRadius:"100%"}});import{keyframes as cS,styled as Tr}from"@rango-dev/ui";var sN=Tr("div",{borderRadius:"$lg",width:"$45",height:"$45",backgroundColor:"$success300",display:"flex",justifyContent:"center",alignItems:"center"}),Lo=Tr("div",{position:"relative"}),pS=cS({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}),Po=Tr("div",{position:"absolute",border:"2px solid rgba(0, 0, 0, 0.1)",borderTop:"2px solid $info500",borderRadius:"$lg",width:"$45",height:"$45",animation:`${pS} 1s linear infinite`,top:0,bottom:0,right:0,left:0}),vr=Tr("div",{"& img":{borderRadius:"50%"}});function kp(t,e){return t.find(o=>o.name===e)?.logo}i(kp,"getBlockchainLogo");import{styled as uS}from"@rango-dev/ui";var Tp=uS("ul",{padding:0,paddingTop:"$4",paddingBottom:"$4"});function fn(t){let{targetWallet:e}=t.value,o=e.needsNamespace?.selection==="single",n=e.image,[r,a]=CS([]),s=y().blockchains(),l=i(u=>{a(o?[u]:p=>p.includes(u)?p.filter(m=>m!==u):p.concat(u))},"onSelect"),c=i(u=>o?we.createElement(SS,{value:r?.[0]},u):we.createElement(we.Fragment,null,u),"wrapRadioRoot");return we.createElement(we.Fragment,null,we.createElement(fS,{size:20}),we.createElement(hS,{type:"info",title:ya.t("Select chain types"),description:ya.t("This wallet supports multiple chains. Select which chain you'd like to connect to."),icon:we.createElement(Lo,null,we.createElement(kr,null,we.createElement(vp,{src:n,size:45})),we.createElement(Po,null))}),we.createElement(Tp,null,c(we.createElement(we.Fragment,null,e.needsNamespace?.data.map(u=>we.createElement(gS,{key:u.id,id:u.id,title:u.label,hasDivider:!0,style:{height:60},onClick:()=>l(u.value),start:we.createElement(vp,{src:kp(s,u.id),size:22}),end:o?we.createElement(yS,{value:u.value}):we.createElement(dS,{checked:r.includes(u.value)})}))))),we.createElement(mS,{id:"widget-name-space-confirm-btn",type:"primary",disabled:!r.length,onClick:()=>t.onConfirm(r)},ya.t("Confirm")))}i(fn,"Namespaces");import{i18n as _o}from"@lingui/core";import{Button as vS,Divider as xp,Image as wS,MessageBox as bS,Select as xS,TextField as ES}from"@rango-dev/ui";import Oe,{useEffect as IS,useState as Ep}from"react";import{namespaces as kS}from"@rango-dev/wallets-shared";var wr={id:"custom",label:"Custom",generateDerivationPath:t=>t};function Sa(t){let e=t?kS[t].derivationPaths:null;return e?[...e,wr]:[]}i(Sa,"getDerivationPaths");import{styled as wp,Typography as TS}from"@rango-dev/ui";var bp=wp("div",{paddingTop:"$30",paddingBottom:"$30",zIndex:10}),Ca=wp(TS,{paddingLeft:"$10"}),ka={height:"$40",backgroundColor:"$neutral200",borderRadius:"$sm"};var Ip="0";function gn(t){let{onConfirm:e}=t,{namespace:o,providerImage:n,providerType:r}=t.value,[a,s]=Ep(null),[l,c]=Ep(Ip),u=a===wr.id,p=Sa(o),m=i(({value:d})=>{let f=p?.find(g=>g.id===d);f&&(a===wr.id&&Number.isNaN(Number(l))&&c(Ip),s(f.id))},"handleDerivationPathItemClick"),h=i(()=>{let d=p.find(f=>f.id===a);if(d)e(d.generateDerivationPath(l));else throw new Error("selectedDerivationPath can not be undefined")},"handleConfirm");return IS(()=>{s(Sa(o)[0]?.id||null)},[o]),Oe.createElement(Oe.Fragment,null,Oe.createElement(xp,{size:20}),Oe.createElement(bS,{type:"info",title:_o.t("Select Derivation Path"),description:_o.t({id:"In order to connect to {type}, you must first select a Derivation Path",values:{type:r}}),icon:Oe.createElement(Lo,null,Oe.createElement(vr,null,Oe.createElement(wS,{src:n,size:45})),Oe.createElement(Po,null))}),Oe.createElement(bp,null,Oe.createElement(Ca,{variant:"body",size:"xsmall",color:"$neutral600"},_o.t("Choose Derivation Path Template")),Oe.createElement(xS,{value:a||"",options:p.map(d=>({value:d.id,label:d.label})),variant:"filled",handleItemClick:m,styles:{trigger:ka}}),Oe.createElement(xp,{size:20}),Oe.createElement(Ca,{variant:"body",size:"xsmall",color:"$neutral600"},u?_o.t("Enter Path"):_o.t("Enter Index")),Oe.createElement(ES,{type:u?"text":"number",variant:"contained",value:l,onChange:d=>c(d.target.value),style:ka})),Oe.createElement(vS,{id:"widget-derivation-path-confirm-btn",type:"primary",onClick:h,disabled:!p||!a||!l},_o.t("Confirm")))}i(gn,"DerivationPath");import{i18n as Do}from"@lingui/core";import{Image as AS,MessageBox as Ta,WalletState as NS}from"@rango-dev/ui";import{useWallets as WS}from"@rango-dev/wallets-react";import lo from"react";function va(t){let{wallet:e,error:o}=t,{type:n,image:r}=e,{state:a}=WS();return cn(a(n))===NS.CONNECTED?lo.createElement(Ta,{type:"success",title:Do.t("Wallet Connected"),description:Do.t("Your wallet is connected, you can use it to swap.")}):o?lo.createElement(Ta,{type:"error",title:Do.t("Failed to Connect"),description:o||Do.t("Your wallet is not connected. Please try again.")}):lo.createElement(Ta,{type:"loading",title:Do.t("Connecting to your wallet"),description:Do.t("Click connect in your wallet popup."),icon:lo.createElement(Lo,null,lo.createElement(vr,null,lo.createElement(AS,{src:r,size:45})),lo.createElement(Po,null))})}i(va,"ConnectStatus");import{i18n as wa}from"@lingui/core";import{Button as BS,Divider as Ap,MessageBox as MS}from"@rango-dev/ui";import br from"react";function ba(t){let{displayName:e,onConfirm:o}=t;return br.createElement(MS,{title:wa.t({id:"Add {blockchainDisplayName} Chain",values:{blockchainDisplayName:e}}),type:"warning",description:wa.t({id:"Would you like to add the {blockchainDisplayName} experimental chain to your wallet?",values:{blockchainDisplayName:e}})},br.createElement(Ap,{size:18}),br.createElement(Ap,{size:32}),br.createElement(BS,{id:"widget-experimental-chain-confirm-btn",onClick:o,variant:"outlined",type:"primary",fullWidth:!0,size:"large"},wa.t("Confirm")))}i(ba,"ExperimentalChain");function Np(t,e){return t().status==="init"&&!!e}i(Np,"isOnStatus");function hn(t){return t().status==="namespace"}i(hn,"isOnNamespace");function yn(t){return t().status==="derivationPath"}i(yn,"isOnDerivationPath");var DS=3e3,$S=300;function po(t){let e=_S(),[o,n]=Wp(!1),[r,a]=Wp(),s=i(k=>{a(k.message)},"catchErrorOnHandle"),{terminateConnectingWallets:l}=ft(),{handleConnect:c,handleDerivationPath:u,handleNamespace:p,getState:m,resetState:h}=Gt(),d=i(k=>{p(t.wallet,k).then(S).catch(s)},"handleConfirmNamespaces"),f=i(k=>{if(!k)throw new Error("Derivation path is empty. Please make sure you've filled the field correctly.");u(k).then(S).catch(s)},"handleDerivationPathConfirm"),g=i(()=>{n(!1)},"handleClosingModal"),C=i(()=>{a(void 0),h(),n(!1),e.current&&clearTimeout(e.current)},"resetModalState"),S=i((k,T)=>{let v=k.status==="connected",w=["disconnected","disconnected-unhandled"].includes(k.status);v?(t.onConnect?.(),T||(e.current=setTimeout(g,DS))):w&&g()},"afterConnected");return PS(()=>{if(t.wallet){C();let k=!1,T=!0;i(()=>{setTimeout(()=>{T=!1,k||n(!0)},$S)},"beforeConnecting")(),c(t.wallet,{disconnectIfConnected:!0}).then(w=>{["namespace","derivation-path"].includes(w.status)||(k=!0),S(w,T)}).catch(s)}},[t.wallet]),co.createElement(J,{open:o,onClose:g,onExit:()=>{C(),l(),t.onClose&&t.onClose()},container:N()},Np(m,t.wallet)&&co.createElement(co.Fragment,null,co.createElement(va,{wallet:{type:t.wallet.type,image:t.wallet.image},error:r}),co.createElement(LS,{direction:"vertical",size:32})),hn(m)&&co.createElement(fn,{onConfirm:d,value:m().namespace}),yn(m)&&co.createElement(gn,{onConfirm:f,value:m().derivationPath}))}i(po,"StatefulConnectModal");import{legacyFormatAddressWithNetwork as OS,legacyReadAccountAddress as Mp}from"@rango-dev/wallets-core/legacy";import{Events as Sn,Provider as US}from"@rango-dev/wallets-react";import{isEvmBlockchain as zS}from"rango-sdk";import xr,{createContext as QS,useEffect as Lp,useMemo as qS,useRef as Pp}from"react";import{useEffect as FS}from"react";function Bp(t){return t.map(e=>typeof e=="string"?e:e.config.type).join("-")}i(Bp,"hashProviders");function xa(t,e){let{clearConnectedWallet:o,getAvailableProviders:n,buildAndSetProviders:r}=y(),a=n();return FS(()=>{o(),r()},[Bp(t??[]),e?.walletConnectProjectId,e?.walletConnectListedDesktopWalletLink]),{providers:a}}i(xa,"useWalletProviders");var Er=QS({onConnectWallet:()=>{},onDisconnectWallet:()=>{}});function HS(t){let{updateConfig:e,updateSettings:o,fetch:n,fetchStatus:r,removeBalancesForWallet:a}=y(),s=y().blockchains(),{newWalletConnected:l,disconnectWallet:c,connectedWallets:u}=y(),p=y().config,m={walletConnectProjectId:p?.walletConnectProjectId,trezorManifest:p?.trezorManifest,tonConnect:p.tonConnect,walletConnectListedDesktopWalletLink:t.config.__UNSTABLE_OR_INTERNAL__?.walletConnectListedDesktopWalletLink},{providers:h}=xa(p.wallets,m),d=Pp(),f=Pp();Lp(()=>{n().catch(console.log)},[]),Lp(()=>{t.config&&(e(t.config),o(t.config),window.__rango={config:p,dappConfig:t.config})},[t.config,r]);let g=s.filter(zS).map(T=>T.name),C=i((T,v,w,A,M)=>{if(v===Sn.NAMESPACE_DISCONNECTED&&a(T,{namespaces:w}),v===Sn.ACCOUNTS){let b=fr(M.supportedBlockchains);if(!M.isHub){let I=[],W=[];if(w?.forEach(U=>{let{network:j}=Mp(U);g.includes(j)?I.push(U):W.push(U)}),u.filter(U=>U.walletType===T).map(U=>OS(U.address,U.chain)).length>0){if(I.length>0){let U=ia(T,I,g,b,M.isContractWallet);a(T,{chains:U.map(j=>j.chain)})}W.length>0&&a(T,{chains:W.map(U=>{let{network:j}=Mp(U);return j})})}}if(w){let I=ia(T,w,g,b,M.isContractWallet);I.length&&l(I,M.namespace)}else c(T),f.current?f.current(T):console.warn("onDisconnectWallet handler hasn't been set. Are you sure?")}let x=v===Sn.ACCOUNTS&&A.connected,E=v===Sn.CONNECTED&&M.isHub;if(x||E){let b=`${T}-${A.network}-${w}`;d.current?d.current(b):console.warn("onConnectWallet handler hasn't been set. Are you sure?")}if(v===Sn.NETWORK&&A.network){let b=`${T}-${A.network}`;d.current?d.current(b):console.warn("onConnectWallet handler hasn't been set. Are you sure?")}t.onUpdateState&&t.onUpdateState(T,v,w,A,M)},"onUpdateState"),S=re.use.isActiveTab(),k=qS(()=>({onConnectWallet:T=>{d.current=T},onDisconnectWallet:T=>{f.current=T}}),[]);return xr.createElement(Er.Provider,{value:k},xr.createElement(US,{allBlockChains:s,providers:h,onUpdateState:C,autoConnect:!!S,configs:{wallets:p.wallets}},t.children))}i(HS,"Main");function Ir(t){let{config:e,...o}=t;return xr.createElement(up,{config:e},xr.createElement(HS,{...o,config:e}))}i(Ir,"WidgetWallets");import Yi from"react";import GS,{Fragment as VS}from"react";import{MemoryRouter as KS,useInRouterContext as jS}from"react-router";function _p({children:t}){let o=jS()?VS:KS;return GS.createElement(o,null,t)}i(_p,"AppRouter");import{I18nManager as NE}from"@rango-dev/ui";import Rl from"react";import _e from"react";import{useRoutes as gE}from"react-router-dom";var $={home:"/",fromSwap:"from-swap",toSwap:"to-swap",blockchains:"blockchains",settings:"settings",customTokens:"custom-tokens",addCustomTokens:"add-custom-tokens",liquiditySources:"liquidity-sources",bridges:"bridges",exchanges:"exchanges",languages:"languages",swaps:"swaps",wallets:"wallets",confirmSwap:"confirm-swap",swapDetails:":requestId",routes:"routes"};import{useEffect as Fo,useRef as Dr}from"react";import Ke from"bignumber.js";import{create as ZS}from"zustand";import{subscribeWithSelector as JS}from"zustand/middleware";import{i18n as gt}from"@lingui/core";import{RouteEventType as dB}from"@rango-dev/queue-manager-rango-preset";import Ue from"bignumber.js";import{PendingSwapNetworkStatus as Pr}from"rango-types";import{i18n as $e}from"@lingui/core";var ee=i(()=>({genericServerError:$e.t("Failed Network, Please retry your swap."),liquiditySourcesError:{title:$e.t("Please reset your liquidity sources."),description:$e.t("You have limited the liquidity sources and this might result in Rango finding no routes. Please consider resetting your liquidity sources.")},noResultError:{title:$e.t("No Routes Found."),description:$e.t("Reasons why Rango couldn't find a route: low liquidity on token, very low input amount or no routes available for the selected input/output token combination.")},bridgeLimitErrors:{increaseAmount:$e.t("Bridge Limit Error: Please increase your amount."),decreaseAmount:$e.t("Bridge Limit Error: Please decrease your amount.")},highValueLossError:{impactTitle:$e.t("High Price Impact"),title:$e.t("Price impact is too high!"),description:$e.t("The price impact is significantly higher than the allowed amount."),confirmMessage:$e.t("Confirm high price impact")},quoteUpdatedWithHighValueLoss:{title:$e.t("Route updated and price impact is too high, try again later!")},unknownPriceError:{impactTitle:$e.t("USD Price Unknown"),title:$e.t("USD Price Unknown, Cannot calculate Price Impact."),description:$e.t("USD Price Unknown, Cannot calculate Price Impact. The price impact may be higher than usual. Are you sure to continue the Swap?"),confirmMessage:$e.t("Confirm USD Price Unknown")}}),"errorMessages");function Dp(t){switch(t.type){case 0:return t.diagnosisMessage??ee().noResultError.title;case 1:return ee().genericServerError;default:return""}}i(Dp,"getQuoteErrorMessage");import{i18n as Ar}from"@lingui/core";var uo=i(()=>({connectWallet:Ar.t("Connect Wallet"),swap:Ar.t("Swap"),swapAnyway:Ar.t("Swap anyway"),ethWarning:Ar.t("The route goes through Ethereum. Continue?")}),"swapButtonTitles");function Ea(t,e){return{"Network Fee":e("Network Fee"),"Swapper Fee":e("Protocol Fee"),"Affiliate Fee":e("Affiliate Fee"),"Outbound network fee":e("Outbound Fee"),"Rango Fee":e("Rango Fee")}[t]}i(Ea,"getFeeLabel");var Ia=["RECOMMENDED","CENTRALIZED","LOWEST_FEE","FASTEST","HIGH_IMPACT"],$p=100,Fp=30,Op=15,Up=60;var zp=[{threshold:-10,minInput:400},{threshold:-5,minInput:1e3}],Qp=[{threshold:-1,minInput:1e3},{threshold:-2,minInput:500}];import{getLastSuccessfulStep as YS}from"@rango-dev/queue-manager-rango-preset";import RW from"bignumber.js";function Hp(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(Hp,"getRequiredBalanceOfWallet");function _t(t){let e;return t<=-3&&t>-10?e="low":t<=-10&&(e="high"),e}i(_t,"getPriceImpactLevel");function Wr(t,e,o){let n=t.steps[0],r=t.steps[t.steps.length-1],a=YS(t.steps),s={blockchain:r.toBlockchain,symbol:r.toSymbol,address:r.toSymbolAddress},l=rn(a?a.toBlockchain:n.fromBlockchain,e),c=rn(r.toBlockchain,e),u=o(a?{blockchain:l?.name??"",symbol:a.toSymbol,address:a.toSymbolAddress}:{blockchain:l?.name??"",symbol:n.fromSymbol,address:n.fromSymbolAddress}),p=o(s),m=a?a.outputAmount??"":t.inputAmount;return{fromBlockchain:l,fromToken:u,toBlockchain:c,toToken:p,inputAmount:m}}i(Wr,"createRetryQuote");function $o(t){let{previousQuote:e,currentQuote:o,findToken:n,userSlippage:r}=t,a=Cn(o),s=ct(o);if(o&&a&&s){let u=Pt(a.toString(),s.toString());if(!!u&&Xp(a,u)){let m=Mr(o?.swaps,n),h=_t(u);return{type:0,inputUsdValue:a,outputUsdValue:s,priceImpact:u,totalFee:m,warningLevel:h}}}if(e&&Jp(e,o))return{type:4,usdValueChange:L(ct(o)?.minus(ct(e)??0).toString()??"0",null,2),percentageChange:L(Pt(ct(e)??"1",ct(o)??"1"),null,2)};if(o&&(!a||!s))return{type:1};let l=Lr(o.swaps),c=r>ep;if(Zp(t.userSlippage.toString(),l)){if(c&&parseFloat(l??"0")<r)return{type:3,slippage:r.toString()}}else return{type:2,recommendedSlippages:Yp(o,r),minRequiredSlippage:l};return null}i($o,"generateQuoteWarnings");function Gp(t){return![4].includes(t.type)}i(Gp,"isQuoteWarningConfirmationRequired");function Pt(t,e){let o=typeof e=="string"?parseFloat(e)<=0:!e?.gt(0),n=!t||!e||o?null:Aa(t.toString(),e.toString());return n&&n<0?n:null}i(Pt,"getPriceImpact");var Vp=i(t=>{let e=new Set,o=[];return t.forEach(n=>{e.has(n.from.chain.displayName)||(e.add(n.from.chain.displayName),o.push(n.from.chain)),e.has(n.to.chain.displayName)||(e.add(n.to.chain.displayName),o.push(n.to.chain))}),o},"getUniqueBlockchains"),Br=i((t,e)=>e.sort((o,n)=>{let r=i(u=>u.scores?.find(p=>p.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"),Kp=i((t,e,o)=>{if(!e.length)return null;if(!t)return{requestAmount:o,validationStatus:null,...e[0]};let n=new Set(t.swaps.map(a=>a.swapperId)),r=e.find(a=>{let s=new Set(a.swaps.map(l=>l.swapperId));return Array.from(n).every(l=>s.has(l))});return{requestAmount:o,validationStatus:null,...r||e[0]}},"getDefaultQuote"),jp=i(t=>{let e=i((o,n)=>{let r=Ia.indexOf(o.value),a=Ia.indexOf(n.value);return r!==-1&&a!==-1?r-a:r!==-1?-1:a!==-1?1:0},"customSort");return t.sort(e)},"sortTags");function Xp(t,e){if(!t)return!1;let o=parseInt(e.toFixed(2)||"0");return zp.some(({threshold:n,minInput:r})=>o<=n&&t.gte(new Ue(r)))}i(Xp,"hasHighValueLoss");function Rp(t){return(t||[]).filter(e=>{let o=e.fromAmountMinValue?new Ue(e.fromAmountMinValue):null,n=e.fromAmountMaxValue?new Ue(e.fromAmountMaxValue):null;return e.fromAmountRestrictionType==="EXCLUSIVE"?o?.gte(e.fromAmount)||n?.lte(e.fromAmount):o?.gt(e.fromAmount)||n?.lt(e.fromAmount)}).length>0}i(Rp,"hasLimitError");function eu(t){let e=(t||[]).filter(l=>{let c=l.fromAmountMinValue?new Ue(l.fromAmountMinValue):null,u=l.fromAmountMaxValue?new Ue(l.fromAmountMaxValue):null;return l.fromAmountRestrictionType==="EXCLUSIVE"?c?.gte(l.fromAmount)||u?.lte(l.fromAmount):c?.gt(l.fromAmount)||u?.lt(l.fromAmount)})[0],o=e.fromAmountMinValue?new Ue(e.fromAmountMinValue):null,n=e.fromAmountMaxValue?new Ue(e.fromAmountMaxValue):null,r=e.fromAmountRestrictionType==="EXCLUSIVE",a="",s="";return!r&&o&&o.gt(e.fromAmount)?(a=gt.t({id:"Required: >= {min} {symbol}",values:{min:L(o,6,6),symbol:e.from.symbol}}),s=ee().bridgeLimitErrors.increaseAmount):r&&o&&o.gte(e.fromAmount)&&(a=gt.t({id:"Required: > {min} {symbol}",values:{min:L(o,6,6),symbol:e.from.symbol}}),s=ee().bridgeLimitErrors.increaseAmount),!r&&n&&n.lt(e.fromAmount)?(a=gt.t({id:"Required: <= {max} {symbol}",values:{max:L(n,6,6),symbol:e.from.symbol}}),s=ee().bridgeLimitErrors.decreaseAmount):r&&n&&n.lte(e.fromAmount)&&(a=gt.t({id:"Required: < {max} {symbol}",values:{max:L(n,6,6),symbol:e.from.symbol}}),s=ee().bridgeLimitErrors.decreaseAmount),{swap:e,fromAmountRangeError:a,recommendation:s}}i(eu,"getLimitErrorMessage");function tu(t){let{fetchMetaStatus:e,anyWalletConnected:o,fetchingQuote:n,inputAmount:r,quote:a,warning:s,error:l,needsToWarnEthOnPath:c}=t;return e!=="success"?{title:uo().connectWallet,action:"connect-wallet",disabled:!0}:o?n||!a||l||!r||r==="0"?{title:uo().swap,action:"confirm-swap",disabled:!0}:s?{title:uo().swapAnyway,action:"confirm-warning",disabled:!1}:c?{title:uo().ethWarning,action:"confirm-warning",disabled:!1}:{title:uo().swap,action:"confirm-swap",disabled:!1}:{title:uo().connectWallet,action:"connect-wallet",disabled:!1}}i(tu,"getSwapButtonState");function Na(t,e,o){let n=parseFloat(e||"0");return!(t&&(!o||o.lte(ce))&&e&&e!=="0"&&n!==0)}i(Na,"canComputePriceImpact");function Wa(t,e){let o=ce;for(let n=0;n<t.fee.length;n++){let r=t.fee[n];if(r.expenseType==="DECREASE_FROM_OUTPUT")continue;let a=e(r.asset)?.usdPrice||null;o=o.plus(new Ue(r.amount).multipliedBy(a||0))}return o}i(Wa,"getUsdFeeOfStep");function Mr(t,e){return t.reduce((o,n)=>o.plus(Wa(n,e)),ce)}i(Mr,"getTotalFeeInUsd");function Ba(t){let e=ce;return e=e.plus(new Ue(t.amount).multipliedBy(t.price||0)),e}i(Ba,"getUsdFee");function ou(t){return t.reduce((e,o)=>e.plus(Ba(o)),ce)}i(ou,"getTotalFeesInUsd");function nu(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(nu,"getFeesGroup");function ru(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(ru,"checkSlippageErrors");function Yp(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(Yp,"checkSlippageWarnings");function Lr(t){return t.map(o=>o.recommendedSlippage)?.map(o=>o?.slippage||"0")?.filter(o=>parseFloat(o)>0)?.sort((o,n)=>parseFloat(n)-parseFloat(o))?.find(()=>!0)||null}i(Lr,"getMinRequiredSlippage");function Zp(t,e){return e?parseFloat(t)>=parseFloat(e):!0}i(Zp,"hasProperSlippage");function iu(t){let{fromToken:e,toToken:o,inputAmount:n,wallets:r,selectedWallets:a,disabledLiquiditySources:s,liquiditySources:l,excludeLiquiditySources:c,slippage:u,affiliateRef:p,affiliatePercent:m,affiliateWallets:h,destination:d}=t,f=a?.reduce((S,k)=>(S[k.chain]=k.address,S),{}),g=[];return r?.forEach(S=>{g.push({blockchain:S.chain,addresses:[S.address]})}),{amount:n.toString(),affiliateRef:p??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:g,selectedWallets:f??{},slippage:u.toString(),...d&&{destination:d},...c&&{swapperGroups:s.concat(l??[]),swappersGroupsExclude:!0},...!c&&{swapperGroups:l?.filter(S=>!s.includes(S)),swappersGroupsExclude:!1}}}i(iu,"createQuoteRequestBody");function au(t){return t.reduce((o,n)=>(o[n.chain]={address:n.address,walletType:n.walletType},o),{})}i(au,"getWalletsForNewSwap");function Cn(t){let e=t.requestAmount,o=t.swaps[0].from.usdPrice;if(!(!e||!o))return new Ue(e).multipliedBy(o)}i(Cn,"getUsdInputFrom");function ct(t){let e=t?.outputAmount||null,o=t.swaps[t.swaps.length-1].to.usdPrice;if(!(!e||!o))return new Ue(e).multipliedBy(o)}i(ct,"getUsdOutputFrom");function Aa(t,e){return new Ue(e).div(new Ue(t)).minus(1).multipliedBy($p).toNumber()}i(Aa,"getPercentageChange");function Jp(t,e){let o=Cn(t),n=ct(t),r=ct(e);if(!o||!n||!r)return!1;let a=Aa(n.toString(),r.toString());return Qp.some(({threshold:s,minInput:l})=>a<=s&&o.isGreaterThanOrEqualTo(l))}i(Jp,"isOutputAmountChangedExcessively");function su(t,e,o){let n=t.validationStatus,r=io({filter:"required",quote:t});return e.sort((s,l)=>r.indexOf(s.chain)-r.indexOf(l.chain)).flatMap(s=>Hp(s,n)||[]).filter(s=>!s.ok).map(s=>{let l=s.asset.symbol,c=L(new Ue(s.currentAmount.amount).shiftedBy(-s.currentAmount.decimals),8,8),u=L(new Ue(s.requiredAmount.amount).shiftedBy(-s.requiredAmount.decimals),8,8),p="";return s.reason==="FEE"&&(p=gt.t(" for network fee")),s.reason==="INPUT_ASSET"&&(p=gt.t(" for swap")),s.reason==="FEE_AND_INPUT_ASSET"&&(p=gt.t(" for input and network fee")),gt.t({id:"Needs \u2248 {requiredAmount} {symbol}{reason}, but you have {currentAmount} {symbol} in your {blockchain} wallet.",values:{requiredAmount:u,symbol:l,reason:p,currentAmount:c,blockchain:st(s.asset.blockchain,o)}})})}i(su,"generateBalanceWarnings");function kn(t){return!!t&&t.networkStatus!==null&&t.networkStatus!==Pr.NetworkChanged}i(kn,"isNetworkStatusInWarningState");function lu(t,e){let o="bellow button or",n=t.extraMessage,r=t.extraMessageDetail;if(t.networkStatusExtraMessageDetail?.includes(o)&&(t.networkStatusExtraMessageDetail=t.networkStatusExtraMessageDetail.replace(o,"")),kn(e))switch(n=t.networkStatusExtraMessage||"",r=t.networkStatusExtraMessageDetail||"",e?.networkStatus){case Pr.WaitingForConnectingWallet:n=n||gt.t("Waiting for connecting wallet");break;case Pr.WaitingForQueue:n=n||gt.t("Waiting for other running tasks to be finished");break;case Pr.WaitingForNetworkChange:n=n||gt.t("Waiting for changing wallet network");break;default:n=n||"";break}r=r||"",n=n||"";let s=n?.indexOf("code")!==-1&&n?.indexOf("reason")!==-1;return{shortMessage:n,detailedMessage:{content:r,long:s}}}i(lu,"getSwapMessages");function cu(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(cu,"getLastConvertedTokenInFailedSwap");function pu(t){return t.status==="failed"}i(pu,"shouldRetrySwap");function uu(t,e,o,n,r,a){if(!n||t)return!0;let s=io({filter:"all",quote:n}),l=io({filter:"required",quote:n}),c=s.every(m=>r.some(h=>h.chain===m)),u=l.every(m=>r.some(h=>h.chain===m)),p=o&&a?Eo(a,o):!1;return!e&&!c||e&&!o||e&&!!o&&(!p||!u)}i(uu,"isConfirmSwapDisabled");function mu(t,e){return t.blockchain===e.blockchain&&t.symbol===e.symbol&&t.address===e.address}i(mu,"isTokensIdentical");var _r=i((t,e)=>t?.usdPrice?new Ke(e||ce).multipliedBy(t?.usdPrice||0):null,"getUsdValue"),O=Mo(ZS()(JS(t=>({fromBlockchain:null,fromToken:null,inputAmount:"",outputAmount:null,inputUsdValue:new Ke(0),outputUsdValue:new Ke(0),toBlockchain:null,toToken:null,refetchQuote:!0,sortStrategy:"SMART",selectedQuote:null,quotes:null,error:null,warning:null,quoteWalletsConfirmed:!1,selectedWallets:[],customDestination:null,quoteWarningsConfirmed:!1,updateQuotePartialState:(e,o)=>t(n=>({...n,[e]:o})),setSelectedQuote:e=>t(o=>{let n=null,r=ce,a=o.inputUsdValue;return ln(o.inputAmount)?(e&&(n=e?.outputAmount?new Ke(e?.outputAmount):null,a=Cn(e)??ce,r=ct(e)??ce),{selectedQuote:e,...!!e&&{outputAmount:n,outputUsdValue:r,inputUsdValue:a}}):{}}),resetAlerts:()=>t(()=>({error:null,warning:null})),resetQuote:()=>t(()=>({selectedQuote:null,outputAmount:null,outputUsdValue:new Ke(0),quotes:null,refetchQuote:!0,error:null,warning:null})),setFromBlockchain:e=>{t(o=>o.fromBlockchain?.name===e?.name?{}:{fromBlockchain:e,inputUsdValue:new Ke(0),...o.fromToken&&{selectedQuote:null,fromToken:null,outputAmount:null,outputUsdValue:new Ke(0)}})},setFromToken:e=>t(o=>({fromToken:e.token,...e.token&&{fromBlockchain:e.meta.blockchains.find(n=>n.name===e.token.blockchain)??null},...!!o.inputAmount&&{inputUsdValue:_r(e.token,o.inputAmount)}})),setToBlockchain:e=>{t(o=>o.toBlockchain?.name===e?.name?{}:{toBlockchain:e,...o.toToken&&{selectedQuote:null,toToken:null,outputAmount:null,outputUsdValue:new Ke(0)}})},setToToken:e=>t(()=>({toToken:e.token,...e.token&&{toBlockchain:e.meta.blockchains.find(o=>o.name===e.token.blockchain)??null}})),setInputAmount:e=>{t(o=>({inputAmount:e,...!e&&{outputAmount:null,outputUsdValue:new Ke(0),selectedQuote:null},...!!o.fromToken&&{inputUsdValue:_r(o.fromToken,e)}}))},retry:e=>{let{fromBlockchain:o,fromToken:n,toBlockchain:r,toToken:a,inputAmount:s}=e;t({fromBlockchain:o,fromToken:n,inputAmount:s,outputAmount:null,inputUsdValue:_r(n??null,s),outputUsdValue:new Ke(0),toBlockchain:r,toToken:a,selectedQuote:null})},switchFromAndTo:()=>t(e=>({fromBlockchain:e.toBlockchain,fromToken:e.toToken,toBlockchain:e.fromBlockchain,toToken:e.fromToken,inputAmount:e.outputAmount?.toString()||"",inputUsdValue:e.toToken?_r(e.toToken,e.outputAmount?.toString()||""):new Ke(0)})),resetFromBlockchain:()=>t(()=>({fromToken:null,fromBlockchain:null,outputUsdValue:new Ke(0),inputUsdValue:new Ke(0),inputAmount:"",outputAmount:null,selectedQuote:null})),resetToBlockchain:()=>t(()=>({toToken:null,toBlockchain:null,outputAmount:null,outputUsdValue:new Ke(0),selectedQuote:null})),setQuoteWalletConfirmed:e=>t({quoteWalletsConfirmed:e}),setSelectedWallets:e=>t({selectedWallets:e}),setCustomDestination:e=>t({customDestination:e}),resetQuoteWallets:()=>t({quoteWalletsConfirmed:!1,selectedWallets:[],customDestination:null}),setQuoteWarningsConfirmed:e=>t({quoteWarningsConfirmed:e})})))),du=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 fu(){let{setInputAmount:t,setToToken:e,setToBlockchain:o,setFromBlockchain:n,resetQuote:r,setFromToken:a,fromToken:s,toToken:l,fromBlockchain:c,toBlockchain:u}=O(),p=y().config,m=y().fetchStatus,h=y().blockchains(),d=y().tokens(),{findToken:f}=y(),{setAffiliateRef:g,setAffiliatePercent:C,setAffiliateWallets:S}=y(),k=p?.from?.tokens,T=p?.from?.blockchains,v=p?.to?.tokens,w=p?.to?.blockchains,A=Dr(void 0),M=Dr(void 0),x=Dr(void 0),E=Dr(void 0);Fo(()=>{typeof p.amount<"u"&&t(p.amount.toString())},[p?.amount]),Fo(()=>{if(m==="success"){r();let b=h.find(B=>B.name===p?.from?.blockchain),I=p?.from?.token,W=I&&f(I);(b||!b&&x.current)&&n(b??null),W?a({token:W,meta:{blockchains:h,tokens:d}}):!W&&A.current&&a({token:null}),x.current=p?.from?.blockchain,A.current=p?.from?.token}},[p?.from?.token?.symbol,p?.from?.token?.address,p?.from?.token?.blockchain,p?.from?.blockchain,m]),Fo(()=>{la(s,k)&&a({token:null}),ca(c,T)&&n(null)},[k,T]),Fo(()=>{la(l,v)&&a({token:null}),ca(u,w)&&o(null)},[v,w]),Fo(()=>{if(m==="success"){r();let b=h.find(B=>B.name===p?.to?.blockchain),I=p?.to?.token,W=I&&f(I);(b||!b&&E.current)&&o(b??null),W?e({token:W,meta:{blockchains:h,tokens:d}}):!W&&M.current&&e({token:null}),E.current=p?.to?.blockchain,M.current=p?.to?.token}},[p?.to?.token?.symbol,p?.to?.token?.address,p?.to?.token?.blockchain,p?.to?.blockchain,m]),Fo(()=>{g(p?.affiliate?.ref??null),C(p?.affiliate?.percent??null),S(p?.affiliate?.wallets??null)},[p?.affiliate?.ref,p?.affiliate?.percent,p?.affiliate?.wallets])}i(fu,"useSyncStoresWithConfig");import{useEffect as Pa,useRef as RS}from"react";import{useInRouterContext as eC,useLocation as tC,useSearchParams as oC}from"react-router-dom";function Ma(t,e){let o=t.split("--");return{blockchain:e.name,address:o?.[1]||null,symbol:o[0]}}i(Ma,"convertTokenSearchParamToAsset");function La(t){if(t)return`${t.symbol}${t.address?`--${t.address}`:""}`}i(La,"tokenToSearchParam");function Da(){let t=tC(),[e,o]=oC(),{fromBlockchain:n,toBlockchain:r,fromToken:a,toToken:s,inputAmount:l,setFromBlockchain:c,setToBlockchain:u,setFromToken:p,setToToken:m,setInputAmount:h}=O(),d=y().fetchStatus,f=y().blockchains(),g=y().tokens(),C=eC(),{updateIframe:S,updateCampaignMode:k}=y(),T=y().isInCampaignMode(),v=RS(),{findToken:w}=y(),A=i(()=>{let x={};for(let[Y,se]of e.entries())Y.startsWith("utm_")&&(x[Y]=se);let E=e.get("fromAmount"),b=e.get("fromBlockchain"),I=e.get("fromToken"),W=e.get("toBlockchain"),B=e.get("toToken"),U=e.get("autoConnect"),j=e.get("clientUrl"),R=e.get("liquiditySources"),P=e.get("blockchain");return{fromAmount:E,fromBlockchain:b,fromToken:I,toBlockchain:W,toToken:B,autoConnect:U,clientUrl:j,liquiditySources:R,utmQueryParams:x,blockchain:P}},"getUrlSearchParams"),M=i(x=>{for(let E in x)x[E]||delete x[E];o(x,{replace:!0})},"updateUrlSearchParams");Pa(()=>{let{autoConnect:x,clientUrl:E,utmQueryParams:b,blockchain:I}=A();C&&d==="success"&&M({fromBlockchain:n?.name,fromToken:La(a),toBlockchain:r?.name,toToken:La(s),fromAmount:l,autoConnect:x??void 0,clientUrl:E??void 0,blockchain:I??void 0,liquiditySources:T?v.current:void 0,...b})},[t.pathname,l,n,a,r,s,T]),Pa(()=>{if(!C)return;let x=A();if(!v.current&&x.liquiditySources&&(v.current=x.liquiditySources),x.fromAmount&&h(x.fromAmount),d==="success"){let E=f.find(B=>B.name===x.fromBlockchain),b=x.fromToken&&E?w(Ma(x.fromToken,E)):void 0,I=f.find(B=>B.name===x.toBlockchain),W=x.toToken&&I?w(Ma(x.toToken,I)):void 0;E&&(c(E),b&&p({token:b,meta:{blockchains:f,tokens:g}})),I&&(u(I),W&&m({token:W,meta:{blockchains:f,tokens:g}}))}},[d]),Pa(()=>{let{clientUrl:x,liquiditySources:E}=A();S("clientUrl",x||void 0),k("liquiditySources",E?.split(",")??void 0)},[])}i(Da,"useSyncUrlAndStore");import{i18n as It}from"@lingui/core";import{Alert as hk,Button as ju,darkTheme as yk,Divider as wn,DoneIcon as Sk,MessageBox as Ck,styled as kk,TextField as Tk,Typography as vk}from"@rango-dev/ui";import ye,{useEffect as wk,useState as qr}from"react";import{useNavigate as bk,useSearchParams as xk}from"react-router-dom";import{ChevronRightIcon as nC,Divider as Cu,Image as rC,Typography as ku}from"@rango-dev/ui";import ht from"react";import{darkTheme as gu,styled as $a}from"@rango-dev/ui";var hu=$a("div",{display:"flex",justifyContent:"space-between",width:"100%",height:"$40",padding:"$4 $10",borderRadius:"$sm",cursor:"pointer",alignItems:"center",backgroundColor:"$neutral300",[`.${gu} &`]:{backgroundColor:"$neutral400"},"&:hover":{backgroundColor:"$secondary100",[`.${gu} &`]:{backgroundColor:"$neutral500"}},variants:{disabled:{true:{cursor:"default","&:hover":{borderColor:"$neutral300","& svg":{color:"$neutral700"}}}}}}),yu=$a("div",{display:"flex",flexDirection:"column",width:"100%",".title_typography":{textTransform:"capitalize"}}),Su=$a("div",{display:"flex"});function Fa(t){let{onClick:e,value:o,title:n,hasLogo:r,placeholder:a,disabled:s}=t;return ht.createElement(yu,null,ht.createElement(ku,{size:"large",variant:"label"},n),ht.createElement(Cu,{size:10}),ht.createElement(hu,{onClick:s?void 0:e,disabled:s},ht.createElement(Su,null,r&&ht.createElement(ht.Fragment,null,ht.createElement(rC,{src:o?.logo,size:16,useAsPlaceholder:!o?.logo,type:"circular"}),ht.createElement(Cu,{size:4,direction:"horizontal"})),ht.createElement(ku,{className:"title_typography",size:"medium",variant:"label"},o?.name||a)),ht.createElement(nC,{size:12,color:"black"})))}i(Fa,"BlockchainSelectorButton");import{i18n as Ua}from"@lingui/core";import{Button as iC,Divider as Tn,ExternalLinkIcon as aC,Image as sC,Typography as Uo}from"@rango-dev/ui";import Ne from"react";function Tu(t,e){if(e.type==="COSMOS")return"";let o=e.info?.addressUrl;return!o||!t?"":o.replace("{wallet}",t)}i(Tu,"generateExplorerLink");import{darkTheme as Oo,styled as vu}from"@rango-dev/ui";var Oa=vu("a",{textDecoration:"none",color:"$colors$neutral700",[`.${Oo} &`]:{color:"$colors$neutral900"},"& svg":{marginLeft:"$4",color:"$colors$neutral700",[`.${Oo} &`]:{color:"$colors$neutral900"}},variants:{hasHover:{true:{"&:hover":{color:"$colors$secondary550",[`.${Oo} &`]:{color:"$colors$secondary500"},"& svg":{color:"$colors$secondary550",[`.${Oo} &`]:{color:"$colors$secondary500"}}}},false:{}}}}),wu=vu("div",{display:"flex",justifyContent:"center",flexDirection:"column",alignItems:"center",textAlign:"center","& ._blockchain-name, & ._coin-source":{color:"$colors$neutral600",[`.${Oo} &`]:{color:"$colors$neutral800"}},"& ._coin-source-name, & ._custom-token-description":{color:"$colors$neutral700",[`.${Oo} &`]:{color:"$colors$neutral900"}}});function za(t){let{open:e,onClose:o,token:n,onSubmitClick:r,blockchain:a}=t,s=Tu(n.address,a);return Ne.createElement(J,{open:e,dismissible:!0,onClose:o,container:N()},Ne.createElement(wu,null,Ne.createElement(sC,{src:n.image,size:45,type:"circular"}),Ne.createElement(Uo,{variant:"title",size:"medium"},n.name),Ne.createElement(Uo,{variant:"body",size:"small",className:"_blockchain-name"},a.displayName),Ne.createElement(Tn,{size:4}),Ne.createElement(Uo,{variant:"body",size:"medium"},s?Ne.createElement(Oa,{hasHover:!0,href:s,target:"_blank",rel:"nofollow noreferrer"},n.address,Ne.createElement(aC,{size:12,color:"gray"})):Ne.createElement(Oa,null,n.address)),Ne.createElement(Tn,{size:4}),n.coinSource&&Ne.createElement(Uo,{className:"_coin-source",variant:"body",size:"xsmall"},Ua.t("via")," ",Ne.createElement(Uo,{className:"_coin-source-name",variant:"body",size:"xsmall"},n.coinSource)),Ne.createElement(Tn,{size:"32"}),Ne.createElement(Uo,{size:"medium",variant:"body",className:"_custom-token-description"},Ua.t("This token doesn't appear on the active token list(s). Make sure this is the token that you want to trade."))),Ne.createElement(Tn,{size:40}),Ne.createElement(Tn,{size:10}),Ne.createElement(iC,{id:"widget-custom-token-modal-import-btn",variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:r},Ua.t("Import")))}i(za,"CustomTokenModal");import{useManager as pk}from"@rango-dev/queue-manager-react";import{BottomLogo as uk,Divider as qu,Header as mk}from"@rango-dev/ui";import Be,{useEffect as cs,useRef as Hu,useState as dk}from"react";import{useRef as lC}from"react";function $r(){return window.self!==window.top}i($r,"isAppLoadedIntoIframe");function Qa(){let t=lC(null),{iframe:e}=y(),o=$r()&&e.clientUrl,n=i(s=>{o&&window.top?.postMessage(s,e.clientUrl)},"send");return{send:n,connectHeightObserver:i(s=>{t.current=new ResizeObserver(l=>{for(let c of l)n({type:"widget_height",data:{height:c.contentRect.height}})}),t.current.observe(s)},"connectHeightObserver"),disconnectHeightObserver:i(()=>{t.current&&(t.current.disconnect(),t.current=null)},"disconnectHeightObserver")}}i(Qa,"useIframe");import{useNavigate as cC}from"react-router-dom";function je(){let t=cC();return()=>t(-1)}i(je,"useNavigateBack");import{createTheme as Xa,darkTheme as wC,lightTheme as bC}from"@rango-dev/ui";import{useEffect as xC,useState as EC}from"react";import{theme as TC,darkColors as vC}from"@rango-dev/ui";import Ka from"react";function pC(t){return t.startsWith("#")&&(t=t.slice(1)),t.length===3?`#${t.split("").reduce(function(n,r){return n+r+r},"")}`:`#${t}`}i(pC,"expandShortHexColor");function uC(t){return/[0-9]+$/.test(t)}i(uC,"isOverridingColor");function mC(t,e){return t.padStart(e,"0")}i(mC,"pad");function qa(t){let e=Math.min(Math.max(Math.round(t),0),255);return mC(e.toString(16),2)}i(qa,"intToHex");function dC(t){return`#${qa(t.red)}${qa(t.green)}${qa(t.blue)}`}i(dC,"rgbToHex");function fC(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(fC,"hexToRGB");function gC(t,e){let o=1-.11*e;return{red:t.red*o,green:t.green*o,blue:t.blue*o}}i(gC,"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 yC(t){return bu(t,gC)}i(yC,"calculateShades");function SC(t){return bu(t,hC)}i(SC,"calculateTints");function bu(t,e){let o=fC(t),n=[];for(let r=1;r<9;r++)n.push(dC(e(o,r)));return n}i(bu,"calculateColors");function Ha(t,e,o){let a=SC(t).reverse().concat(t),s=yC(t),l=a.concat(s),c={},u=l.length;for(let p=0;p<u;p++){let m=100+(o?u-1-p:p)*50;c[`${e}${m}`]=l[p]}return c}i(Ha,"createTintsAndShades");function Ga(t,e,o){let n={...t};for(let r in e){let a=e[r],s=r==="neutral"&&!!o?.reverseNeutralRange;if(!["background","foreground"].includes(r)&&!uC(r)){let c=pC(a);Object.assign(n,Ha(c,r,s))}}return{...n,...e}}i(Ga,"expandToGenerateThemeColors");var xu=i(t=>String.fromCharCode(t+(t>25?39:97)),"toAlphabeticChar"),CC=i(t=>{let e="",o;for(o=Math.abs(t);o>52;o=o/52|0)e=xu(o%52)+e;return xu(o%52)+e},"toAlphabeticName"),kC=i((t,e)=>{let o=e.length;for(;o;)t=t*33^e.charCodeAt(--o);return t},"toPhash"),Va=i(t=>CC(kC(5381,JSON.stringify(t))>>>0),"toHash");function ja(t){let e=TC.colors,o={...e,...vC},n,r;if(t?.light){let s={colors:Ga(e,t.light)};n={id:`${sa}-light-${Va(s)}`,tokens:s}}if(t?.dark){let s={colors:Ga(o,t.dark,{reverseNeutralRange:!0})};r={id:`${sa}-dark-${Va(s)}`,tokens:s}}return{light:n,dark:r}}i(ja,"customizedThemeTokens");function Eu(t,e){if(t.length<=1)return t.map(({element:n,key:r})=>Ka.cloneElement(n,{key:r}));let o=[];return t.forEach((n,r)=>{let{element:a,key:s}=n;if(o.push(Ka.cloneElement(a,{key:s})),r<t.length-1){let l=`divider-${r}`;o.push(Ka.cloneElement(e,{key:l}))}}),o}i(Eu,"joinList");function Iu(){return window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches}i(Iu,"doesWindowPreferDarkColorScheme");function zo(t){let{colors:e,fontFamily:o=Tc,borderRadius:n=Hc,secondaryBorderRadius:r=Gc}=t,[a,s]=EC(Iu()?"dark":"light"),{theme:l}=y(),{dark:c,light:u}=ja(e),p=Xa({shadows:t.shadows||{},radii:{primary:`${n}px`,secondary:`${r}px`},fonts:{widget:o}}),m=[p.className,bC.className],h=[p.className,wC.className];if(u){let f=Xa(u.id,u.tokens);m.push(f.className)}if(c){let f=Xa(c.id,c.tokens);h.push(f.className)}return xC(()=>{let f=i(g=>{g.matches?s("dark"):s("light")},"switchThemeListener");return Iu()&&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(zo,"useTheme");var pt=i(t=>{let e=[];return t?.getAll().forEach((o,n)=>{let r=o.list.getStorage();r?.swapDetails&&e.push({id:n,swap:r?.swapDetails})}),e.sort((o,n)=>Number(n.swap.creationTime)-Number(o.swap.creationTime))},"getPendingSwaps");import{i18n as Au}from"@lingui/core";import{Alert as IC,Button as AC}from"@rango-dev/ui";import Nu from"react";function Ya(t){return Nu.createElement(IC,{action:Nu.createElement(AC,{id:"widget-active-tab-btn",onClick:t.onActivateTab,variant:"contained",size:"xxsmall",type:"warning"},Au.t("Activate this tab")),type:"warning",variant:"alarm",title:Au.t("Another tab is open and handles transactions.")})}i(Ya,"ActivateTabAlert");import{i18n as Za}from"@lingui/core";import{Button as NC,Divider as WC,MessageBox as BC}from"@rango-dev/ui";import Fr from"react";function Ja(t){let{open:e,onClose:o,onConfirm:n}=t;return Fr.createElement(J,{open:e,dismissible:!0,onClose:o,container:N()},Fr.createElement(BC,{title:Za.t("Activate current tab"),type:"warning",description:Za.t("Currently, some transactions are running and being handled by other browser tab. If you activate this tab, all transactions that are already in the transaction sign step will expire.")},Fr.createElement(WC,{size:20}),Fr.createElement(NC,{id:"widget-modal-confirm-activate-tab-btn",variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:n},Za.t("Confirm"))))}i(Ja,"ActivateTabModal");import{ChevronLeftIcon as MC}from"@rango-dev/ui";import Wu from"react";function Ra(t){return Wu.createElement(Et,{id:"widget-header-back-icon-btn",variant:"ghost",size:"small",onClick:t.onClick},Wu.createElement(MC,{color:"black",size:16}))}i(Ra,"BackButton");import{i18n as LC}from"@lingui/core";import{Button as PC,Typography as _C}from"@rango-dev/ui";import es from"react";function ts(t){return es.createElement(Vt,null,es.createElement(PC,{id:"widget-header-cancel-btn",variant:"ghost",onClick:t.onClick,size:"xsmall"},es.createElement(_C,{variant:"label",size:"medium",color:"error500"},LC.t("Cancel"))))}i(ts,"CancelButton");import{i18n as DC}from"@lingui/core";import{Image as $C,Tooltip as FC,WalletIcon as OC}from"@rango-dev/ui";import mo from"react";function os(t){let{list:e}=ft(),o=e.filter(r=>r.state==="connected"),n=o.length?mo.createElement("div",{className:Cp()},o.map(r=>mo.createElement(kr,{key:r.title},mo.createElement($C,{src:r.image,size:14})))):DC.t("Connect Wallet");return mo.createElement(FC,{container:t.container,side:"bottom",content:n},mo.createElement(Et,{id:"widget-header-wallet-icon-btn",variant:"ghost",size:"small",onClick:t.onClick},t.isConnected&&mo.createElement(gp,null),mo.createElement(OC,{size:18,color:"black"})))}i(os,"WalletButton");import{i18n as Ur}from"@lingui/core";import{NotificationsIcon as tk,Popover as ok,SettingsIcon as nk,Tooltip as zr,TransactionIcon as rk}from"@rango-dev/ui";import We from"react";import{Notifications as qC}from"@rango-dev/ui";import HC from"react";import{useNavigate as GC}from"react-router-dom";import{create as UC}from"zustand";import{persist as zC,subscribeWithSelector as QC}from"zustand/middleware";var be=Mo(UC()(zC(QC((t,e)=>({isSynced:!1,notifications:[],setNotification:(o,n)=>{let r=n.steps[0],a=n.steps[n.steps.length-1],s={event:o,creationTime:Date.now(),requestId:n.requestId,route:{creationTime:parseInt(n.creationTime),from:{blockchain:r.fromBlockchain,address:r.fromSymbolAddress,symbol:r.fromSymbol},to:{blockchain:a.toBlockchain,address:a.toSymbolAddress,symbol:a.toSymbol}}},l=e().notifications.filter(c=>c.requestId!==n.requestId);t(()=>({notifications:[...l,s]}))},removeNotification:o=>{t(n=>({notifications:n.notifications.filter(r=>r.requestId!==o)}))},getNotifications:()=>{let{isSynced:o,notifications:n}=e();return o?n.sort((r,a)=>r.route.creationTime&&!a.route.creationTime?-1:!r.route.creationTime&&a.route.creationTime?1:!r.route.creationTime&&!a.route.creationTime?a.creationTime-r.creationTime:a.route.creationTime-r.route.creationTime):[]},syncNotifications:o=>{let{isSynced:n,notifications:r}=e();if(!n){let a=[];r.forEach(s=>{o.some(c=>c.swap.requestId===s.requestId)&&a.push(s)}),t({isSynced:!0,notifications:a})}},clearNotifications:()=>t({notifications:[]})})),{name:"notification",skipHydration:!0,partialize:({isSynced:t,...e})=>e,version:1,migrate:(t,e)=>{if(e===0){let o=t.notifications;t.notifications=o.filter(n=>!n.read).map(({read:n,...r})=>r)}return t}})));function ns(){let t=GC(),{getNotifications:e,clearNotifications:o}=be(),n=e(),r=y().blockchains(),{findToken:a}=y();return HC.createElement(qC,{list:n,getBlockchainImage:l=>mc(l,r)??"",getTokenImage:l=>a(l)?.image??"",onClickItem:i(l=>{t(`${$.swaps}/${l}`)},"onClickItem"),onClearAll:o})}i(ns,"NotificationContent");import{useManager as VC}from"@rango-dev/queue-manager-react";import{InProgressIcon as KC}from"@rango-dev/ui";import Bu from"react";var jC=i(()=>{let{manager:t}=VC();return pt(t).map(({swap:o})=>o).find(o=>o.status==="running")?Bu.createElement(Sp,null,Bu.createElement(KC,{color:"info",size:6})):null},"InProgressTransactionBadge"),Mu=jC;import{EventSeverity as XC}from"@rango-dev/queue-manager-rango-preset";import{Typography as YC}from"@rango-dev/ui";import Lu from"react";function Pu(){let{getNotifications:t}=be(),e=t(),o=e.length,n=!!e.find(r=>r.event.messageSeverity===XC.WARNING);return o?Lu.createElement(hp,{isSever:n},Lu.createElement(YC,{variant:"body",size:"xsmall",color:"$background"},o)):null}i(Pu,"NotificationsBadge");import{RefreshProgressButton as ZC}from"@rango-dev/ui";import rs,{useEffect as JC,useState as _u}from"react";var RC=1e3,Du=60,ek=100;function Or({onClick:t}){let[e,o]=_u(0),[n,r]=_u(!1),a=i(c=>{document.hidden&&c&&s(c)},"handleVisibilityChange");JC(()=>{let c;return t?c=window.setInterval(()=>{o(u=>u+1),e===Du&&l()},RC):s(c),document.addEventListener("visibilitychange",()=>a(c)),()=>{document.removeEventListener("visibilitychange",()=>a(c)),c&&clearInterval(c)}},[e,t]);let s=i(c=>{c&&clearInterval(c),o(0)},"clearTimeout"),l=i(()=>{t?.(),o(0),r(!0)},"handleRefreshClick");return rs.createElement(Et,{id:"widget-header-refresh-icon-btn",variant:"ghost",size:"small",style:{paddingTop:0,paddingBottom:0},onClick:l,disabled:!t},rs.createElement(yp,{onTransitionEnd:()=>r(!1),isRefetched:n},rs.createElement(ZC,{size:22,color:t?"black":"gray",progress:e/Du*ek})))}i(Or,"RefreshButton");function fo(t){let{onClickRefresh:e,onClickHistory:o,onClickSettings:n,hidden:r=[],container:a}=t,{config:{features:s}}=y(),l=Ve("notification",s)||r.includes("notifications");return We.createElement(We.Fragment,null,!r.includes("refresh")&&We.createElement(zr,{container:a||N(),side:"top",content:Ur.t("Refresh")},We.createElement(Or,{onClick:e})),!l&&We.createElement(ok,{align:"end",alignOffset:-88,sideOffset:15,collisionPadding:{right:20,left:20},container:N(),content:We.createElement(ns,null)},We.createElement("div",null,We.createElement(zr,{container:N(),side:"top",content:Ur.t("Notifications")},We.createElement(Et,{id:"widget-header-notification-icon-btn",size:"small",variant:"ghost"},We.createElement(tk,{size:18,color:"black"}),We.createElement(Pu,null))))),!r.includes("settings")&&We.createElement(zr,{container:N(),side:"top",content:Ur.t("Settings")},We.createElement(Et,{id:"widget-header-setting-icon-btn",size:"small",variant:"ghost",onClick:n},We.createElement(nk,{size:18,color:"black"}))),!r.includes("history")&&We.createElement(zr,{container:N(),side:"top",content:Ur.t("History")},We.createElement(Et,{id:"widget-header-history-icon-btn",size:"small",variant:"ghost",onClick:o},We.createElement(rk,{size:18,color:"black"}),We.createElement(Mu,null))))}i(fo,"HeaderButtons");import{i18n as is}from"@lingui/core";import{Divider as Fu,MessageBox as sk,RefreshIcon as lk}from"@rango-dev/ui";import Qo from"react";import{Button as ik,styled as ak}from"@rango-dev/ui";var $u=ak(ik,{"& span":{display:"flex",justifyContent:"center",alignItems:"center"}});function as(t){let{open:e,onClose:o}=t;return Qo.createElement(J,{open:e,dismissible:!0,onClose:o,container:N()},Qo.createElement(sk,{title:is.t("Something went wrong"),type:"error",description:is.t("Something went wrong. Please refresh the app.")},Qo.createElement(Fu,{size:30}),Qo.createElement($u,{variant:"outlined",size:"large",type:"primary",fullWidth:!0,onClick:()=>location.reload()},Qo.createElement(lk,{size:20,color:"primary"}),Qo.createElement(Fu,{size:4,direction:"horizontal"}),is.t("Refresh"))))}i(as,"RefreshModal");function ss(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(ss,"onScrollContentAttachStatusToContainer");import{css as ck,styled as ls}from"@rango-dev/ui";var Ou="700px",Qr=ck({borderRadius:"$primary",display:"flex",flexDirection:"column",overflow:"hidden",boxShadow:"$mainContainer"}),Uu=ls("div",{position:"relative",width:"100vw",minWidth:"300px",maxWidth:"390px",backgroundColor:"$background",variants:{height:{auto:{height:"auto",maxHeight:Ou},fixed:{height:Ou}}}}),zu=ls("div",{position:"relative",overflow:"hidden",flexGrow:1,display:"flex",flexDirection:"column",padding:0,overflowY:"auto"}),Qu=ls("div",{padding:"0 $20 $10","& .footer__alert":{paddingTop:"$10"},"& .footer__logo":{opacity:0,transition:"opacity 1s ease-in-out","&.logo__show":{opacity:1},"&.logo__hidden":{visibility:"hidden"}}});function oe(t){let{connectHeightObserver:e,disconnectHeightObserver:o}=Qa(),{children:n,header:r,footer:a,height:s="fixed"}=t,{fetchStatus:l,connectedWallets:c}=y(),[u,p]=dk(!1),{config:{features:m,theme:h}}=y(),{watermark:d}=re(),f=d==="FULL",{activeTheme:g}=zo(h||{}),C=Ve("connectWalletButton",m),{isActiveTab:S,tabManagerInitiated:k,showActivateTabModal:T,setShowActivateTabModal:v,activateCurrentTab:w}=re(),A=je(),{manager:M}=pk(),E=pt(M).map(({swap:j})=>j).some(j=>j.status==="running"),b=i(()=>w(ao.forceClaim,E),"onActivateTab"),I=i(()=>{r.onWallet?.()},"onConnectWallet"),W=typeof r.hasBackButton>"u"||r.hasBackButton,B=Hu(null),U=Hu(null);return cs(()=>($r()&&U.current&&e(U.current),()=>{o()}),[]),cs(()=>(B.current?.addEventListener("scroll",ss),()=>{B.current?.removeEventListener("scroll",ss)}),[]),cs(()=>{p(l==="failed")},[l]),Be.createElement(Uu,{height:s,id:De.SWAP_BOX_ID,className:`${g()} ${Qr()}`,ref:U},Be.createElement(mk,{prefix:W?Be.createElement(Ra,{onClick:()=>{A(),r.onBack&&r.onBack()}}):null,title:r.title,suffix:Be.createElement(Be.Fragment,null,r.suffix,r.onWallet&&!C&&Be.createElement(os,{container:N(),onClick:I,isConnected:!!c?.length}),r.onCancel&&Be.createElement(ts,{onClick:r.onCancel}))}),Be.createElement(zu,{ref:B},n),Be.createElement(Ja,{open:T,onClose:()=>v(!1),onConfirm:b}),Be.createElement(Qu,null,Be.createElement("div",{className:"footer__content"},k&&!S&&Be.createElement("div",{className:"footer__alert"},Be.createElement(Ya,{onActivateTab:b}),Be.createElement(qu,{size:10})),a),Be.createElement(qu,{size:12}),Be.createElement("div",{className:`footer__logo ${f?"logo__show":"logo__hidden"}`},Be.createElement(uk,null))),Be.createElement(as,{open:u,onClose:()=>p(!1)}))}i(oe,"Layout");import{styled as fk}from"@rango-dev/ui";var Gu="$20 $20 $10 $20",vn=fk("div",{padding:Gu,overflowY:"auto",flexGrow:1});import{styled as gk}from"@rango-dev/ui";var ie=gk("div",{display:"flex",flexDirection:"column",padding:"20px 20px 10px",flexGrow:1,variants:{view:{true:{flexGrow:1,overflow:"hidden"}},compact:{true:{padding:0}}}});import{i18n as qo}from"@lingui/core";import{useState as Vu}from"react";function Ku(){let[t,e]=Vu(!1),[o,n]=Vu(void 0),{findToken:r}=y(),a=y().customTokens();function s(c,u){switch(c){case"duplicated":return{title:qo.t("Duplicate Token"),message:qo.t("The address you entered is duplicate, please enter a new address.")};case"token-exist":return{title:qo.t("Token Already Exists"),message:qo.t("There's no need to add this token again because it already exists and is supported by us.")};case"not-found":return{title:qo.t("Token Not Found"),message:qo.t({id:"Sorry, no token was found on {blockchain} chain with the provided address. please make sure you have entered the right token address.",values:{blockchain:u}})}}}return i(s,"produceErrorMessage"),{fetchCustomToken:i(async({blockchain:c,tokenAddress:u})=>{e(!0);try{if(a.some(f=>f.address?.toLowerCase()===u.toLowerCase())){let f=s("duplicated");n(f);return}let m=await xt().getCustomToken({blockchain:c,address:u});if(!m||!m.token||m.error){let f=s("not-found",c);n(f);return}let h=m.token;if(r({blockchain:h.blockchain,address:h.address,symbol:h.symbol})){let f=s("token-exist");n(f);return}return h}catch(p){if(p?.code==="ERR_BAD_REQUEST"){let m=s("not-found",c);n(m);return}throw n(void 0),new Error(p.message)}finally{e(!1)}},"fetchCustomToken"),loading:t,error:o}}i(Ku,"useFetchCustomToken");var Ek=kk("div",{display:"flex",justifyContent:"space-between",flexDirection:"column",flex:1,"& ._text-field":{padding:"$4 $10",backgroundColor:"$neutral300",[`.${yk} &`]:{backgroundColor:"$neutral400"},borderRadius:"$sm",height:"$40"}}),Ik=1e3;function Xu(){let t=bk(),[e]=xk(),o=je(),{setCustomToken:n}=y(),r=y().blockchains(),a=e.get("blockchain")||"",s=rn(a,r),[l,c]=qr(""),[u,p]=qr(!1),[m,h]=qr(),{fetchCustomToken:d,loading:f,error:g}=Ku(),[C,S]=qr(""),k=!!s&&Eo(s,l),T=!s||!l||!k,v=i(async()=>{if(s)try{let M=await d({blockchain:a,tokenAddress:l});S(""),M&&h(M)}catch(M){M.message==="Failed to fetch"&&(S(It.t("Network Error")),p(!0))}},"getCustomToken"),w=i(()=>{g&&c(""),p(!1)},"closeErrorModal"),A=i(async()=>{C&&setTimeout(async()=>{await v()},Ik),w()},"handleErrorModalButtonClick");return wk(()=>{g&&p(!0)},[g]),ye.createElement(oe,{header:{title:It.t("Add Custom Token")}},ye.createElement(ie,null,ye.createElement(Ek,null,ye.createElement("div",null,ye.createElement(Fa,{onClick:()=>t($.blockchains,{replace:!0}),hasLogo:!!s?.logo,value:s?{name:s.displayName,logo:s.logo}:void 0,title:It.t("Select chain"),placeholder:It.t("Select chain")}),ye.createElement(wn,{size:"24"}),ye.createElement(vk,{size:"large",variant:"label"},It.t("Enter Address")),ye.createElement(wn,{size:10}),ye.createElement(Tk,{fullWidth:!0,disabled:!s,variant:"contained",placeholder:It.t("Enter token address"),size:"large",value:l,suffix:!!l&&k&&ye.createElement(Sk,{color:"success",size:12}),onChange:M=>c(M.target.value)}),!k&&!!l&&ye.createElement(ye.Fragment,null,ye.createElement(wn,{size:4}),ye.createElement(hk,{type:"error",variant:"alarm",title:"Invalid Address"}))),ye.createElement(ju,{id:"widget-add-custom-token-import-btn",disabled:T,type:"primary",variant:"contained",loading:f,size:"large",onClick:v},It.t("Import"))),ye.createElement(J,{open:u,dismissible:!0,onClose:w,container:N()},ye.createElement(Ck,{title:g?.title||C,type:"error",description:g?.message||It.t("Failed Network, Please retry.")},ye.createElement(wn,{size:40}),ye.createElement(wn,{size:10}),ye.createElement(ju,{id:`widget-add-custom-token-${C?"retry":"add-another"}-btn`,variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:A},C?It.t("Retry"):It.t("Add another custom token")))),s&&m&&ye.createElement(za,{blockchain:s,token:m,onSubmitClick:()=>{m&&(n(m),h(void 0),o())},onClose:()=>h(void 0),open:!!s&&!!m})))}i(Xu,"AddCustomTokenPage");import{i18n as Os}from"@lingui/core";import{useManager as pv}from"@rango-dev/queue-manager-react";import{Alert as uv,Button as mv,css as zs,Divider as Us,IconButton as qd,styled as dv,Typography as fv,WalletIcon as gv}from"@rango-dev/ui";import Le,{useEffect as yi,useLayoutEffect as hv,useRef as yv,useState as Dn}from"react";import{useNavigate as Sv}from"react-router-dom";import{i18n as go}from"@lingui/core";import{Alert as Jk,BalanceErrors as Rk,Button as wm,ChevronLeftIcon as eT,Divider as ys,MessageBox as tT,Typography as Ss}from"@rango-dev/ui";import te,{useCallback as oT,useEffect as bm,useMemo as nT,useState as Vo}from"react";import{useNavigate as rT}from"react-router-dom";import{i18n as ds}from"@lingui/core";import{Alert as Mk,ChevronDownIcon as Lk,CloseIcon as Pk,Divider as om,IconButton as nm,PasteIcon as _k,Typography as Dk,WalletIcon as $k}from"@rango-dev/ui";import Me,{useEffect as Fk,useRef as Ok}from"react";import Kr,{useRef as Wk}from"react";import*as Ho from"@radix-ui/react-collapsible";import{keyframes as Yu,styled as Hr}from"@rango-dev/ui";var ps=300,Ak=Yu({from:{height:0},to:{height:"var(--radix-collapsible-content-height)"}}),Nk=Yu({from:{height:"var(--radix-collapsible-content-height)"},to:{height:0}}),Zu=Hr(Ho.Root,{borderRadius:"$sm",overflow:"hidden",variants:{selected:{true:{outlineWidth:1,outlineColor:"$secondary500",outlineStyle:"solid"}}}}),us=Hr(Ho.Trigger,{padding:"$0",border:"none",outline:"none",width:"100%",backgroundColor:"transparent",fontFamily:"inherit",cursor:"pointer"}),Gr=Hr(Ho.Content,{overflow:"hidden",variants:{open:{true:{animation:`${Ak} ${ps}ms ease-out`},false:{animation:`${Nk} ${ps}ms ease-out`}}}}),Vr=Hr("div",{transition:`all ${ps}ms ease`,display:"flex",alignItems:"center",variants:{orientation:{down:{transform:"rotate(0)"},up:{transform:"rotate(180deg)"}}}});function jr(t){let{open:e,hasSelected:o,onOpenChange:n,children:r,onClickTrigger:a,trigger:s,triggerAnchor:l}=t,c=Wk(null);return Kr.createElement(Zu,{ref:c,className:"collapsible_root",selected:o&&e,open:e,onOpenChange:n},l==="top"&&Kr.createElement(us,{className:"collapsible_trigger",onClick:a},s),Kr.createElement(Gr,{className:"collapsible_content",open:e},r),l==="bottom"&&Kr.createElement(us,{className:"collapsible_trigger",onClick:a},s))}i(jr,"CustomCollapsible");import{darkTheme as Ju,styled as ms,TextField as Bk}from"@rango-dev/ui";var Ru=ms("div",{padding:"$10 $0","& .button__content":{display:"flex",alignItems:"center"},"& .alarms":{paddingTop:"$5"},"& .collapsible_content":{backgroundColor:"$neutral100"},"& .collapsible_root":{backgroundColor:"$neutral100"}}),em=ms(Bk,{backgroundColor:"$neutral100",padding:"$15"}),tm=ms("div",{width:"100%",borderRadius:"$sm",display:"flex",padding:"$15",justifyContent:"space-between",alignItems:"center",$$color:"$colors$neutral100",[`.${Ju} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",borderBottomRightRadius:"0",borderBottomLeftRadius:"0","&:focus-visible":{$$background:"$colors$secondary100",[`.${Ju} &`]:{$$background:"$colors$info700"},backgroundColor:"$$background",outline:0}});function rm(t){let{blockchain:e,handleOpenChange:o,open:n}=t,{customDestination:r,setCustomDestination:a}=O(),{config:s}=y(),l=y().blockchains(),c=ir(e.name,l),u=Ok(null),p=s?.defaultCustomDestinations?.[e.name],m=navigator?.userAgent.includes("Firefox"),d=n&&!!r&&e&&!Eo(e,r),f=i(()=>{a("")},"handleClear"),g=i(async S=>{if(S.preventDefault(),navigator.clipboard!==void 0){let k=await navigator.clipboard.readText();a(k),u?.current?.focus()}},"handlePaste"),C=i(()=>r?Me.createElement(nm,{id:"widget-custom-destination-close-icon-btn",onClick:f,variant:"ghost"},Me.createElement(Pk,{size:12,color:"gray"})):m?null:Me.createElement(nm,{id:"widget-custom-destination-paste-icon-btn",onClick:g,variant:"ghost"},Me.createElement(_k,{size:16})),"renderSuffix");return Fk(()=>{!!p&&r===null&&(a(p),o(!0))},[p]),Me.createElement(Ru,null,Me.createElement(jr,{onOpenChange:o,hasSelected:!0,open:n,triggerAnchor:"top",trigger:Me.createElement(tm,null,Me.createElement("div",{className:"button__content"},Me.createElement($k,{size:18,color:"info"}),Me.createElement(om,{size:4,direction:"horizontal"}),Me.createElement(Dk,{variant:"label",size:"medium",color:n?"$neutral600":void 0},ds.t("Send to a different address"))),Me.createElement(Vr,{orientation:n?"up":"down"},Me.createElement(Lk,{size:10,color:"secondary"}))),onClickTrigger:()=>o(!n)},Me.createElement(em,{ref:u,style:{padding:0,paddingRight:r?"8px":"5px"},autoFocus:!r,placeholder:ds.t("Enter {blockchainName} address",{blockchainName:c}),value:r||"",suffix:C(),onChange:S=>{let k=S.target.value;a(k)}})),d&&Me.createElement(Me.Fragment,null,Me.createElement(om,{size:4}),Me.createElement(Mk,{variant:"alarm",type:"error",title:ds.t({values:{destination:r},id:"Address {destination} doesn't match the blockchain address pattern."})})))}i(rm,"CustomDestination");import{css as Uk,darkTheme as fs,IconButton as zk,styled as Dt}from"@rango-dev/ui";var im=Dt("div",{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center"}),am=Dt("div",{display:"flex",justifyContent:"space-evenly",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5",height:"100%"}),Qk=Dt("button",{borderRadius:"$xm",padding:"$10",border:"0",display:"flex",justifyContent:"center",$$color:"$colors$neutral100",[`.${fs} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",alignItems:"center",cursor:"pointer",width:110,position:"relative","&:hover":{$$color:"$colors$secondary100",[`.${fs} &`]:{$$color:"$colors$neutral100"},backgroundColor:"$$color"},"&:focus-visible":{$$color:"$colors$secondary100",[`.${fs} &`]:{$$color:"$colors$info700"},backgroundColor:"$$color",outline:0},variants:{selected:{true:{outlineWidth:1,outlineColor:"$secondary",outlineStyle:"solid"}}}}),sm=Dt(Qk,{alignSelf:"stretch",minHeight:"93px"}),lm=Dt("div",{padding:"$20 $20 $15 $20",display:"flex",justifyContent:"center",alignItems:"center",backgroundColor:"$neutral200",position:"relative",width:"100%"}),cm=Dt(zk,{position:"absolute",left:"$20"}),pm=Dt("div",{paddingTop:"$20"}),um=Uk({display:"flex",justifyContent:"space-evenly",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5",height:"100%"}),mm=Dt("div",{display:"flex"}),dm=Dt("div",{overflow:"visible",width:"100%"});import{i18n as Cm}from"@lingui/core";import{warn as Kk}from"@rango-dev/logging-core";import{Divider as jk,SelectableWallet as Xk,Typography as km,WalletState as Tm}from"@rango-dev/ui";import Xe,{useEffect as vm,useState as xn}from"react";import{Image as Gk,MessageBox as Vk}from"@rango-dev/ui";import bn from"react";import{keyframes as qk,styled as gs}from"@rango-dev/ui";var fm=gs("div",{position:"relative"}),Hk=qk({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}),gm=gs("div",{position:"absolute",border:"2px solid rgba(0, 0, 0, 0.1)",borderTop:"2px solid $info500",borderRadius:"$lg",width:"$45",height:"$45",animation:`${Hk} 1s linear infinite`,top:0,bottom:0,right:0,left:0}),hm=gs("div",{"& img":{borderRadius:"50%"}});import{i18n as Go}from"@lingui/core";function ym(t,e){switch(t){case"in-progress":return{type:"loading",title:Go.t({id:"Add {blockchainDisplayName} Chain",values:{blockchainDisplayName:e}}),description:Go.t({id:"Please approve the experimental chain pop-up in your wallet.",values:{blockchainDisplayName:e}})};case"completed":return{type:"success",title:Go.t({id:"{blockchainDisplayName} Chain Added",values:{blockchainDisplayName:e}}),description:Go.t({id:"The {blockchainDisplayName} chain has been successfully added to your wallet.",values:{blockchainDisplayName:e}})};case"rejected":return{type:"error",title:Go.t("Request Rejected"),description:Go.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(ym,"generateMessageByStatus");function Sm(t){let{status:e,displayName:o,image:n}=t,r=ym(e,o),a=e=="in-progress";return bn.createElement(Vk,{type:r.type,title:r.title,description:r.description,icon:a?bn.createElement(fm,null,bn.createElement(hm,null,bn.createElement(Gk,{src:n,size:45})),bn.createElement(gm,null)):void 0})}i(Sm,"ExperimentalChainStatus");var Yk=7,Zk=3e3;function hs(t){let{chain:e,isSelected:o,selectWallet:n,limit:r,onShowMore:a}=t,s=re.use.isActiveTab(),{blockchains:l,connectedWallets:c}=y(),[u,p]=xn(),[m,h]=xn(null),[d,f]=xn(!1),[g,C]=xn(null),{suggestAndConnect:S}=Xr(),{handleDisconnect:k}=Gt(),{list:T}=ft({chain:e}),[v,w]=xn(T),A=T.length,M=r&&A-r>0,x=i(async b=>{f(!1),C("in-progress");try{await S(b.walletType,b.chain),C("completed")}catch{C("rejected")}},"addExperimentalChain");vm(()=>{w(b=>{let I=T.findIndex(W=>o(W.type,e));return M&&I>1?[T[I]].concat(T.filter((W,B)=>B!==I)):b.map(W=>T.find(B=>B.type===W.type)??W)})},[JSON.stringify(T)]);let E=document.getElementById(De.SWAP_BOX_ID);return vm(()=>{let b=null;return(g==="completed"||g==="rejected")&&(b=setTimeout(()=>C(null),Zk)),()=>{b&&clearTimeout(b)}},[g]),Xe.createElement(Xe.Fragment,null,v.slice(0,r).map(b=>{let I=Fc({connectedWallets:c,walletType:b.type,chain:e}),W=I?yr(I,Yk):"",B=gr(l(),e),U=!c.find(se=>se.walletType===b.type&&se.chain===e),j=B&&U&&b.state===Tm.CONNECTED,R=j?Cm.t({id:"Add {chain} chain",values:{chain:e}}):W,P=i(async()=>{let se=b.state===Tm.DISCONNECTED,Q=(b.isHub||!!b.needsNamespace)&&!W;se?p(b):Q?(await k(b.type),p(b)):j?(h({walletType:b.type,chain:e,address:I??""}),f(!0)):n({walletType:b.type,chain:e,address:I??""})},"onSelectableWalletClick"),Y=m?.chain?ir(m.chain,l()):void 0;return Xe.createElement(Xe.Fragment,{key:`${b.title}_${Y}`},!!m&&Xe.createElement(J,{open:!!m&&d,container:E,onClose:()=>{h(null)}},Xe.createElement(ba,{displayName:Y,onConfirm:()=>{x(m)}})),g&&Xe.createElement(J,{open:!!g,onClose:C.bind(null,null),container:E},Xe.createElement(Sm,{status:g,displayName:Y,image:b.image}),Xe.createElement(jk,{direction:"vertical",size:32})),Xe.createElement(Xk,{key:b.type,description:R,onClick:P,selected:o(b.type,e),disabled:!s,...b}))}),Xe.createElement(po,{wallet:u,onClose:()=>{p(void 0)},onConnect:()=>{t.onConnect&&(u?.type?t.onConnect(u.type):Kk(new Error("The selected wallet hasn't been detected after the connection process finished. It usually shouldn't happen.")))}}),M&&Xe.createElement(sm,{selected:!1,onClick:a},Xe.createElement(km,{variant:"label",size:"medium"},Cm.t("Show more wallets"),Xe.createElement(km,{variant:"label",size:"medium",color:"$primary"},"\xA0+",A-(r??0)))))}i(hs,"WalletList");var iT=2;function xm(t){let{open:e,onClose:o,onCancel:n,onCheckBalance:r,loading:a}=t,s=rT(),l=y().blockchains(),{selectedQuote:c,setSelectedWallets:u,quoteWalletsConfirmed:p,setQuoteWalletConfirmed:m,customDestination:h,setCustomDestination:d}=O(),{config:f,connectedWallets:g,setWalletsAsSelected:C}=y(),[S,k]=Vo(""),[T,v]=Vo([]),[w,A]=Vo(""),[M,x]=Vo(!!h),E=nT(()=>io({filter:"all",quote:c}),[c]),b=io({filter:"required",quote:c}),I=l.find(_=>_.name===c?.swaps[c?.swaps.length-1].to.blockchain),W=i(_=>b.includes(_),"isWalletRequiredFor"),B=oT(()=>g.filter(_=>_.selected&&E.includes(_.chain)),[g,E]),[U,j]=Vo(B()),[R,P]=Vo([]),Y=i((_,G)=>P(K=>K.concat({blockchain:_,walletType:G})),"addNextSelectedWallets"),se=T.length>0,Q=i((_,G)=>!!U.find(K=>K.walletType===_&&K.chain===G&&K.selected&&(W(G)||!W(G)&&!h)),"isSelected"),de=i((_,G,K)=>{let fe=!1;return _.map(ne=>{if(ne.chain===G){let ge=ne.selected;return!fe&&K?(fe=!0,ge=!0):K||(ge=!1),{...ne,selected:ge}}return ne})},"updateSelectableWallets"),vt=i(_=>{x(_),_?W(I?.name??"")||j(G=>de(G,I?.name||"",!1)):(d(""),j(G=>de(G,I?.name||"",!0)))},"handleCustomDestinationCollapsibleOpenChange"),Ze=i(_=>{if(S&&k(""),Q(_.walletType,_.chain))return;let K=g.find(fe=>fe.walletType===_.walletType&&fe.chain===_.chain);K&&(n(),_.chain===I?.name&&M&&!W(I.name)&&(x(!1),d(null)),j(fe=>fe.filter(ne=>ne.chain!==_.chain).concat({...K,selected:!0})))},"onChange"),le=i(()=>{let _=U.filter(G=>G.selected);C(_),u(_),m(!0),o()},"onConfirmBalance"),at=i(async()=>{v([]),A("");let _=await r?.({selectedWallets:U.filter(K=>K.selected),customDestination:h}),G=_.warnings;G?.balance?.messages&&v(G.balance.messages),_.error&&A(Dp(_.error)),!_.error&&!G?.balance?.messages.length?le():v(G?.balance?.messages??[])},"onConfirmWallets");bm(()=>{j(_=>{let G=[];return _.forEach(K=>{!g.some(ne=>ne.chain===K.chain&&ne.walletType===K.walletType&&ne.address===K.address)||G.push(K)}),G=G.concat(g.filter(K=>!!!G.find(ne=>ne.chain===K.chain)&&K.selected&&E.includes(K.chain))),G})},[g,E]),bm(()=>{let _=[];R.length>0&&(R.forEach(G=>{let K=g.find(fe=>fe.chain===G.blockchain&&fe.walletType===G.walletType);K?Ze(K):_.push(G)}),P(_))},[g,R]);let V=document.getElementById(De.SWAP_BOX_ID);return te.createElement(J,{open:e,onClose:()=>{p||s("../",{replace:!0}),o()},dismissible:!S,container:V,...!S&&{styles:{container:{height:"100%"}},footer:te.createElement(mm,null,te.createElement(wm,{id:"widget-confirm-wallet-modal-confirm-btn",loading:a,disabled:uu(a,M,h,c,U,I),onClick:at,variant:"contained",type:"primary",fullWidth:!0,size:"large"},go.t("Confirm")))},...S&&{styles:{container:{height:"100%",padding:"$0"}},header:te.createElement(lm,null,te.createElement(cm,{id:"widget-confirm-wallet-modal-navigate-back-icon-btn",variant:"ghost",onClick:k.bind(null,"")},te.createElement(eT,{size:16})),te.createElement(Ss,{variant:"headline",size:"small"},go.t({id:"Your {blockchainName} wallets",values:{blockchainName:st(S,l)}})))},anchor:"center"},te.createElement(J,{open:se,onClose:v.bind(null,[]),container:V},te.createElement(tT,{title:go.t("Insufficient account balance"),type:"error",description:te.createElement(Rk,{messages:T??[]})},te.createElement(wm,{id:"widget-confirm-wallet-modal-proceed-anyway-btn",variant:"outlined",size:"large",type:"primary",fullWidth:!0,onClick:le},go.t("Proceed anyway")))),S&&te.createElement(pm,null,te.createElement("div",{className:um()},te.createElement(hs,{chain:S,isSelected:Q,selectWallet:Ze,onShowMore:()=>k(S),onConnect:_=>{Y(S,_)}}))),!S&&te.createElement(te.Fragment,null,w&&te.createElement(te.Fragment,null,te.createElement(Jk,{variant:"alarm",type:"error",title:go.t(w)}),te.createElement(ys,{size:12})),te.createElement(dm,null,E.map((_,G)=>{let K=l.find(Fe=>Fe.name===_),fe=`wallet-${G}`,ne=G===E.length-1,ge=ne&&I&&f?.customDestination!==!1;return te.createElement("div",{key:fe},te.createElement(im,null,te.createElement(Ss,{variant:"title",size:"xmedium"},go.t({id:"Your {blockchainName} wallets",values:{blockchainName:K?.shortName}})),te.createElement(Ss,{variant:"label",color:"$neutral700",size:"medium"},go.t({id:"You need to connect a {blockchainName} wallet.",values:{blockchainName:K?.shortName}}))),te.createElement(ys,{size:24}),te.createElement(am,null,te.createElement(hs,{chain:_,isSelected:Q,selectWallet:Ze,limit:iT,onShowMore:()=>k(K?.name??""),onConnect:Fe=>{Y(_,Fe)}})),!ne&&te.createElement(ys,{size:32}),ge&&te.createElement(rm,{blockchain:I,open:M,handleOpenChange:vt}))}))))}i(xm,"ConfirmWalletsModal");import{i18n as bT}from"@lingui/core";import{Alert as xT,Button as ET,InfoIcon as IT}from"@rango-dev/ui";import et from"react";import{Alert as lT,Button as cT,Divider as Ts,NoRouteIcon as pT,RefreshIcon as uT,Typography as Mm}from"@rango-dev/ui";import Re from"react";import{i18n as Em}from"@lingui/core";var aT=24,sT=60;function Im(t,e,o,n){return t?.type===1?{alert:{type:"warning",text:ee().genericServerError,action:{onClick:n,title:Em.t("Retry")}},description:""}:e.length?{alert:{type:"warning",text:ee().liquiditySourcesError.title,action:{onClick:()=>o(!0),title:Em.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(Im,"makeInfo");var Cs=(o=>(o[o.small=aT]="small",o[o.large=sT]="large",o))(Cs||{}),ks=(o=>(o.small="small",o.large="medium",o))(ks||{});import{styled as Yr}from"@rango-dev/ui";var Am=Yr("div",{display:"flex",flexDirection:"column",alignItems:"center"}),Nm=Yr("div",{variants:{size:{small:{},large:{maxWidth:"316px"}}}}),Wm=Yr("div",{variants:{size:{small:{width:"100%"},large:{}}}}),Bm=Yr("div",{padding:"$6 $0"});function En(t){let{fetch:e,error:o,size:n="small"}=t,r=y().getDisabledLiquiditySources(),a=y().toggleAllLiquiditySources,s=y().swappers(),l=Im(o,r,()=>a(s,!0),e);return Re.createElement(Am,null,Re.createElement(pT,{size:Cs[n],color:"gray"}),Re.createElement(Ts,{size:4}),Re.createElement(Mm,{variant:"title",size:ks[n]},ee().noResultError.title),n==="large"&&Re.createElement(Ts,{size:4}),!!l.description&&Re.createElement(Nm,{size:n},Re.createElement(Mm,{variant:"body",size:"small",align:"center",color:"neutral700"},l.description)),Re.createElement(Ts,{size:n==="large"?"24":"4"}),!!l.alert&&Re.createElement(Wm,{size:n},Re.createElement(lT,{type:l.alert.type,title:l.alert.text,titleAlign:"left",action:l.alert.action&&Re.createElement(cT,{size:"xsmall",id:"widget-no-result-alert-btn",type:l.alert.type,prefix:Re.createElement(Bm,null,Re.createElement(uT,{size:8})),onClick:l.alert.action.onClick},l.alert.action.title),variant:"alarm"})))}i(En,"NoResult");import{i18n as In}from"@lingui/core";import{Button as dT,Divider as fT,MessageBox as gT,Typography as hT,WarningIcon as yT}from"@rango-dev/ui";import $t from"react";import{Typography as Dm}from"@rango-dev/ui";import ws from"react";import{darkTheme as mT,styled as Zr}from"@rango-dev/ui";var Lm=Zr("div",{width:"100%"}),vs=Zr("div",{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"$5",width:"100%"}),Pm=Zr("div",{display:"flex",padding:"$5 0",justifyContent:"space-between",alignItems:"center",width:"100%","._title":{$$color:"$colors$neutral600",[`.${mT} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),_m=Zr("div",{padding:"$2",alignSelf:"flex-start",cursor:"pointer"});function $m(t){let{title:e,value:o,valueColor:n}=t;return ws.createElement(Pm,null,ws.createElement(Dm,{size:"medium",variant:"label",className:"_title"},e),ws.createElement(Dm,{size:"large",variant:"label",color:n||"foreground"},`${n?"%":"$"}${o}`))}i($m,"QuoteErrorsModalItem");function Fm(t){let{open:e,onClose:o,onConfirm:n,warning:r,confirmationDisabled:a}=t,s=r.warningLevel==="high"?"error":"warning",l=[{title:In.t("Swapping"),value:L(r.inputUsdValue,4,4)},{title:In.t("Gas cost"),value:L(r.totalFee,2,2)},{title:In.t("Receiving"),value:L(r.outputUsdValue,4,4)},{title:In.t("Price impact"),value:L(r.priceImpact,2,2),valueColor:`${s}500`}];return $t.createElement(J,{footer:$t.createElement(dT,{id:"widget-high-value-loss-warning-modal-confirm-btn",type:"primary",size:"large",prefix:$t.createElement(yT,null),fullWidth:!0,disabled:a,onClick:n},ee().highValueLossError.confirmMessage),open:e,onClose:o,container:N()},$t.createElement(gT,{type:s,title:ee().highValueLossError.impactTitle,description:ee().highValueLossError.description}),$t.createElement(vs,null,$t.createElement(fT,{size:"4"}),$t.createElement(hT,{size:"small",variant:"title"},In.t("Details")),$t.createElement(vs,null,l.map((c,u)=>$t.createElement($m,{key:u,...c})))))}i(Fm,"HighValueLossWarningModal");import{i18n as Jr}from"@lingui/core";function Om(t,e){let o={alertType:"warning",title:"",action:null};if(e)return o.alertType="error",e.type===3&&(o.title=e.recommendation),e.type===4&&(o.title=Jr.t({id:"You need to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:e.minRequiredSlippage}}),o.action="change-settings"),o;if(t){switch(t.type){case 0:{_t(t.priceImpact)==="high"&&(o.alertType="error"),o.action="show-info",o.title=ee().highValueLossError.title;break}case 4:{o.title=Jr.t({id:"Output amount changed by {percentageChange}% (${usdValueChange}).",values:{percentageChange:t.percentageChange,usdValueChange:t.usdValueChange}});break}case 1:{o.title=ee().unknownPriceError.title;break}case 2:{o.title=Jr.t({id:"We recommend you to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:t.minRequiredSlippage}}),o.action="change-settings";break}case 3:{o.title=Jr.t("Caution, your slippage is high."),o.action="change-settings";break}default:break}return o}return null}i(Om,"makeAlerts");import{i18n as Ko}from"@lingui/core";import{Button as Um,Divider as zm,MessageBox as ST,Typography as CT}from"@rango-dev/ui";import ho from"react";import{useNavigate as kT}from"react-router-dom";function Qm(t){let{customSlippage:e,slippage:o}=y(),{open:n,onClose:r,onConfirm:a,warning:s,confirmationDisabled:l}=t,c=kT(),u=e??o;return ho.createElement(J,{anchor:"bottom",open:n,prefix:ho.createElement(Um,{size:"small",id:"widget-slippage-warning-modal-change-settings-btn",variant:"ghost",onClick:()=>c("../"+$.settings)},ho.createElement(CT,{variant:"label",size:"medium",color:"$neutral900"},Ko.t("Change settings"))),container:N(),onClose:r},ho.createElement(ST,{type:"warning",title:s.type===3?Ko.t("High slippage"):Ko.t("Low slippage"),description:s.type===3?Ko.t({id:" Caution, your slippage is high (={userSlippage}). Your trade may be front run.",values:{userSlippage:u}}):Ko.t({id:"We recommend you to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:s.minRequiredSlippage}})},ho.createElement(zm,{size:18}),ho.createElement(zm,{size:32}),ho.createElement(Um,{id:"widget-slippage-warning-modal-confirm-anyway-btn",size:"large",type:"primary",variant:"contained",fullWidth:!0,disabled:l,onClick:a},Ko.t("Confirm anyway"))))}i(Qm,"SlippageWarningModal");import{Button as TT,MessageBox as vT,WarningIcon as wT}from"@rango-dev/ui";import Rr from"react";function qm(t){let{open:e,onClose:o,onConfirm:n,confirmationDisabled:r}=t;return Rr.createElement(J,{footer:Rr.createElement(TT,{id:"widget-unknown-price-warning-modal-confirm-btn",type:"primary",size:"large",prefix:Rr.createElement(wT,null),fullWidth:!0,disabled:r,onClick:n},ee().unknownPriceError.confirmMessage),open:e,onClose:o,container:N()},Rr.createElement(vT,{type:"warning",title:ee().unknownPriceError.impactTitle,description:ee().unknownPriceError.description}))}i(qm,"UnknownPriceWarningModal");function An(t){let{warning:e,error:o,couldChangeSettings:n,showWarningModal:r,confirmationDisabled:a,refetchQuote:s,onOpenWarningModal:l,onCloseWarningModal:c,onConfirmWarningModal:u,onChangeSettings:p}=t,m={confirmationDisabled:a,open:r,onClose:c,onConfirm:u},h=o?.type===0||o?.type===1,d=Om(e,o?.type===3||o?.type===4?o:null);return d&&!n&&(d.action=null),et.createElement(et.Fragment,null,h&&et.createElement(En,{error:o,fetch:s}),!!d&&et.createElement(Lm,null,et.createElement(xT,{title:d.title,type:d.alertType,variant:"alarm",...d.action==="show-info"&&{action:et.createElement(_m,{onClick:l},et.createElement(IT,{size:12,color:"gray"}))},...d.action==="change-settings"&&{action:et.createElement(ET,{id:"widget-quote-warning-error-change-settings-btn",size:"xxsmall",type:d.alertType,onClick:p},bT.t("Change"))}})),e&&et.createElement(et.Fragment,null,e.type===0&&et.createElement(Fm,{...m,warning:e}),(e.type===3||e.type===2)&&et.createElement(Qm,{...m,warning:e}),e.type===1&&et.createElement(qm,{...m,warning:e})))}i(An,"QuoteWarningsAndErrors");import rv from"bignumber.js";import di from"react";import{i18n as yo}from"@lingui/core";import{Alert as GT,Divider as Xo,FullExpandedQuote as VT,InfoIcon as KT,NumericTooltip as Td,QuoteTag as jT,StepDetails as XT,TokenAmount as YT,Typography as Yo}from"@rango-dev/ui";import Ms from"bignumber.js";import F,{useRef as ZT,useState as JT}from"react";import{styled as bs}from"@rango-dev/ui";var xs=bs("div",{width:"100%","& .position-top__skeleton":{paddingTop:"$10"}}),Hm=bs("div",{paddingBottom:"$15",variants:{dense:{true:{paddingBottom:0}}}}),Gm=bs("div",{width:"100%",display:"flex"});import*as ei from"@radix-ui/react-collapsible";import{Button as AT,css as Nn,darkTheme as xe,Image as Vm,styled as ze,Typography as NT}from"@rango-dev/ui";var WT=300,Km=ze(ei.Root,{display:"flex",flexDirection:"column",alignItems:"start",overflowX:"auto",overflowY:"hidden",width:"100%",borderRadius:"$xm",variants:{selected:{true:{},false:{$$color:"$colors$neutral400",[`.${xe} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"}},listItem:{true:{$$color:"$colors$neutral400",[`.${xe} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"},false:{}}},compoundVariants:[{listItem:!1,selected:!0,css:{$$color:"$colors$secondary200",[`.${xe} &`]:{$$color:"$colors$secondary800"},backgroundColor:"$$color"}}]}),jm=Nn({padding:"$10 $15"}),Xm=ze(AT,{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"}}}),Ym=ze("div",{borderRadius:"$xm",display:"flex",flexDirection:"column",alignItems:"start",justifyContent:"space-between",color:"$foreground",boxSizing:"border-box",position:"relative",variants:{selected:{true:{},false:{$$color:"$colors$neutral200",[`.${xe} &`]:{$$color:"$colors$neutral500"},backgroundColor:"$$color"}},basic:{true:{borderTopRightRadius:"0",borderTopLeftRadius:"0"}},listItem:{true:{$$color:"$colors$neutral200",[`.${xe} &`]:{$$color:"$colors$neutral500"},backgroundColor:"$$color","&:hover":{"& .quote_container":{"& button":{backgroundColor:"$neutral500",[`.${xe} &`]:{backgroundColor:"$neutral200"}},backgroundColor:"$neutral500",[`.${xe} &`]:{backgroundColor:"$neutral200"}},backgroundColor:"$neutral300",[`.${xe} &`]:{backgroundColor:"$neutral400"}},cursor:"pointer"},false:{}}},compoundVariants:[{listItem:!0,selected:!0,css:{outline:"1px solid $secondary"}},{listItem:!1,selected:!0,css:{$$color:"$colors$secondary100",[`.${xe} &`]:{$$color:"$colors$secondary550"},backgroundColor:"$$color","&:hover":{backgroundColor:"$$color"}}},{listItem:!0,selected:!1,css:{cursor:"pointer","&:hover":{backgroundColor:"$neutral300",[`.${xe} &`]:{backgroundColor:"$neutral400"}}}}]}),Zm=Nn({width:"100%",padding:"$15 $15 $10 $15"}),Jm=Nn({display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingBottom:"$10",position:"relative"}),jo=Nn({display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",".blockchainImage":{marginLeft:"-$8"}}),Rm=Nn({display:"flex",alignItems:"center",".usd-value":{$$color:"$colors$neutral600",[`.${xe} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),ed=ze(ei.Trigger,{display:"flex",width:"100%",justifyContent:"space-between",alignItems:"center",height:"$36",padding:"$10 $15",boxSizing:"border-box",cursor:"pointer",border:"none",outline:"none",backgroundColor:"transparent",variants:{error:{true:{[`& ${Vm}`]:{border:"1px $warning500 solid",borderRadius:"100%"}},false:{[`& ${Vm}`]:{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"}}}),td=ze("div",{width:"18px",height:"18px",borderRadius:"100%",display:"flex",justifyContent:"center",alignItems:"center",border:"1.5px transparent solid",img:{borderRadius:"100%"},variants:{state:{error:{borderColor:"$error500"},warning:{borderColor:"$warning500"}}}}),od=ze(Gr,{width:"100%",background:"inherit"}),Es=ze("div",{display:"flex",justifyContent:"center",alignItems:"center",padding:"$2",transition:`all ${WT}ms ease`,variants:{orientation:{down:{transform:"rotate(0)"},up:{transform:"rotate(180deg)"}}}}),$F=ze("div",{height:"$12",marginLeft:"$10",marginRight:"$10",borderLeft:"1px solid $foreground"}),nd=ze("div",{display:"flex",justifyContent:"center",margin:"0 $15",borderTop:"1px solid",$$color:"$colors$neutral300",[`.${xe} &`]:{$$color:"$colors$neutral400"},borderColor:"$$color"}),rd=ze("div",{width:"$16",height:"$16",justifyContent:"center",alignItems:"center",display:"flex"}),Is=ze(NT,{overflow:"hidden",textOverflow:"ellipsis",letterSpacing:.4}),id=ze("div",{display:"flex",flexWrap:"wrap"}),As=ze("div",{width:"18px",height:"18px",borderRadius:"100%",backgroundColor:"$background",cursor:"default",display:"flex",justifyContent:"center",alignItems:"center",border:"1.5px transparent solid",variants:{state:{error:{borderColor:"$error500"},warning:{borderColor:"$warning500"}}}}),ad=ze("div",{display:"flex"}),ti=ze("div",{width:"100%",borderTopWidth:"1px",borderTopStyle:"solid",borderTopColor:"$neutral",margin:"$5 0",[`.${xe} &`]:{borderTopColor:"$neutral800"}});import{i18n as At}from"@lingui/core";import{ChevronDownIcon as MT,CloseIcon as LT,Divider as ri,IconButton as PT,NumericTooltip as _T,QuoteCost as DT,Typography as yt}from"@rango-dev/ui";import Z,{useState as pd}from"react";import{css as BT,styled as oi}from"@rango-dev/ui";var ni=oi("div",{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"$5 0","&.total_payable_fee":{padding:"$12 0"}}),Ns=oi("div",{width:"100%",borderTop:"1px solid $neutral300",margin:"$10 0"}),sd=oi("div",{padding:"$20 0",display:"flex",flexDirection:"column","& .collapsible_trigger":{display:"flex",alignItems:"center"}}),ld=oi("div",{padding:"$20 $20 $10",position:"relative","._icon-button":{position:"absolute",zIndex:10,top:"$16",right:"$16"}}),cd=BT({display:"flex",flexDirection:"row",alignItems:"center",padding:"$5","&:hover":{"& ._typography, & svg":{color:"$secondary"}}});var $T=i(t=>t.fee.isZero()?null:Z.createElement(ni,null,Z.createElement(yt,{variant:"label",size:"medium",color:"neutral600"},t.label),Z.createElement(yt,{variant:"label",size:"medium"},"$",L(t.fee,4,4))),"NonPayableFee");function Ws(t){let[e,o]=pd(!1),[n,r]=pd(!1),{steps:a,quote:s,fee:l,time:c,feeWarning:u,timeWarning:p,showModalFee:m,fullExpandedMode:h=!1}=t,d=s?.swaps??[],f=h?ro():N(),g=nu(d);return Z.createElement(Z.Fragment,null,Z.createElement(DT,{onClickFee:m?C=>{C.stopPropagation(),o(!e)}:void 0,fee:l,feeWarning:u,timeWarning:p,time:c,steps:a,tooltipGas:m?At.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(ld,{style:{textAlign:h?"left":"center"}},Z.createElement(yt,{variant:"title",size:"medium"},At.t("Gas & Fee Explanation")),Z.createElement(PT,{id:"widget-quote-cost-details-modal-close-icon-btn",onClick:()=>o(!1),variant:"ghost"},Z.createElement(LT,{color:"gray",size:14}))),onClose:()=>{o(!1)}},Z.createElement(sd,null,Z.createElement(yt,{variant:"title",size:"small"},At.t("Details")),Z.createElement(ri,{size:10}),Object.entries(g.payable).flatMap(([C,S])=>S.map((k,T)=>{let v=`payable-fee-${T}`,w=Ba(k);return Z.createElement(ni,{key:v},Z.createElement(yt,{variant:"label",size:"medium",color:"neutral600"},Ea(C,At.t)),Z.createElement(_T,{content:k.amount,container:f},Z.createElement(yt,{variant:"label",size:"medium"},L(k.amount,2,2)," ",k.asset.symbol," ($",L(w,4,4),")")))})),Z.createElement(ni,{className:"total_payable_fee"},Z.createElement(yt,{variant:"label",size:"medium"},At.t("Total Payable Fee")),Z.createElement(yt,{variant:"label",size:"medium"},"$",L(l,4,4))),Z.createElement(Ns,null),Object.keys(g.nonePayable).length&&Z.createElement(jr,{triggerAnchor:"bottom",onClickTrigger:()=>r(C=>!C),trigger:Z.createElement("div",{className:cd()},Z.createElement(yt,{size:"small",variant:"body",color:"neutral700"},n?At.t("Hide non-payable fees"):At.t("Show non-payable fees")),Z.createElement(ri,{size:4,direction:"horizontal"}),Z.createElement(Vr,{orientation:n?"up":"down"},Z.createElement(MT,{size:12,color:"gray"}))),open:n},Z.createElement(yt,{size:"small",variant:"title"},At.t("Description")),Z.createElement(ri,{size:4}),Z.createElement(yt,{size:"small",variant:"body",color:"neutral700"},At.t(`The following fees are considered in the transaction output and
2
+ you won\u2019t need to pay extra gas for them.`)),Z.createElement(ri,{size:10}),Object.entries(g.nonePayable).map(([C,S],k)=>{let T=ou(S),v=Ea(C,At.t),w=`non-payable-fee-${k}`;return Z.createElement($T,{key:w,fee:T,label:v})}),Z.createElement(Ns,null)))))}i(Ws,"QuoteCostDetails");import{i18n as dd}from"@lingui/core";import{TokenAmount as fd}from"@rango-dev/ui";import ii from"react";import{css as FT,styled as OT}from"@rango-dev/ui";var ud=OT("div",{position:"relative",display:"flex",flexDirection:"column",width:"100%"}),md=FT({height:"14px",marginLeft:"14px",position:"absolute",borderLeft:"1px solid $foreground",top:"42%"});function Wn(t){let{from:e,to:o,percentageChange:n,warningLevel:r}=t;return ii.createElement(ud,null,ii.createElement(fd,{direction:"horizontal",label:dd.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}}),ii.createElement("div",{className:md()}),ii.createElement(fd,{direction:"horizontal",tooltipContainer:N(),label:dd.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(Wn,"QuoteSummary");import{i18n as Cd}from"@lingui/core";import{ChevronDownIcon as QT,ChevronRightIcon as qT,Divider as Bs,Image as HT,Tooltip as pi,Typography as si}from"@rango-dev/ui";import z from"react";import{useLayoutEffect as UT,useState as Bn}from"react";var gd=480,hd=768,yd=1024,Sd=1200,zT=i(()=>{let[t,e]=Bn(!1),[o,n]=Bn(!1),[r,a]=Bn(!1),[s,l]=Bn(!1),[c,u]=Bn(!1),p=i(()=>{e(window.innerWidth<=gd),n(window.innerWidth>gd&&window.innerWidth<=hd),a(window.innerWidth>hd&&window.innerWidth<=yd),l(window.innerWidth>yd&&window.innerWidth<=Sd),u(window.innerWidth>Sd)},"handleResize");return UT(()=>(p(),window.addEventListener("resize",p),()=>window.removeEventListener("resize",p)),[]),{isMobile:t,isTablet:o,isNotebook:r,isLargeScreen:s,isExtraLargeScreen:c}},"useScreenDetect"),ai=zT;var li=4,ci=6,Mn=i(t=>{let{content:e,src:o,className:n,open:r,state:a,container:s}=t,l=s||N();return z.createElement(pi,{container:l,side:"bottom",sideOffset:4,open:r,content:e},z.createElement(td,{className:n,state:a},z.createElement(HT,{src:o,size:16})))},"ImageComponent");function kd(t){let{quoteRef:e,selected:o,setExpanded:n,steps:r,expanded:a,type:s,container:l}=t,c=l||N(),u=r.length,p=Vp(r),{isTablet:m,isMobile:h}=ai();return z.createElement(ed,{listItem:s==="list-item",ref:d=>e.current=d,selected:o,onClick:d=>{d.stopPropagation(),n(f=>!f)}},z.createElement("div",{className:jo()},z.createElement(si,{variant:"body",size:"xsmall"},Cd.t("Via:")),z.createElement(Bs,{direction:"horizontal",size:4}),r.map((d,f)=>{let g=`item-${f}`,C=z.createElement(Es,null,z.createElement(qT,{size:12,color:"black"}));return h||m?z.createElement(z.Fragment,{key:g},z.createElement(Mn,{content:d.swapper.displayName,src:d.swapper.image,state:d.state,container:l}),f!==u-1&&z.createElement(z.Fragment,null,C)):z.createElement(z.Fragment,{key:g},u<=li||u>li&&f<li-1?z.createElement(z.Fragment,null,z.createElement(Mn,{content:d.swapper.displayName,src:d.swapper.image,state:d.state,container:l}),f!==u-1&&z.createElement(z.Fragment,null,C)):f===li-1&&z.createElement(pi,{container:c,side:"bottom",align:"end",sideOffset:4,content:z.createElement("div",{className:jo()},C,r.map((S,k)=>{let T=`image-${k}`;return k>=f&&z.createElement(z.Fragment,{key:T},z.createElement(Mn,{content:S.swapper.displayName,src:S.swapper.image,state:S.state,open:!1}),k!==u-1&&z.createElement(z.Fragment,null,C))}))},z.createElement(As,{state:r.find((S,k)=>k>=f&&(S.state==="error"||S.state==="warning"))?.state},z.createElement(si,{size:"xsmall",variant:"body"},"+",u-f))))})),z.createElement("div",{className:jo()},z.createElement("div",{className:"blockchains_section"},z.createElement("div",{className:jo()},z.createElement(si,{variant:"body",size:"xsmall"},Cd.t("Chains:")),z.createElement(Bs,{direction:"horizontal",size:4}),p.map((d,f)=>z.createElement(z.Fragment,{key:d.displayName},p.length<=ci||p.length>ci&&f<ci-1?z.createElement(pi,{container:c,side:"bottom",content:d.displayName,sideOffset:4},z.createElement(Mn,{content:"",src:d.image,open:!1,className:f!==0?"blockchainImage":""})):f===ci-1&&z.createElement(pi,{container:c,side:"bottom",align:"end",sideOffset:4,content:z.createElement("div",{className:jo()},p.map((g,C)=>C>=f&&z.createElement(Mn,{key:g.displayName,content:"",src:g.image,open:!1,className:C>f?"blockchainImage":"",container:l})))},z.createElement(As,{className:"blockchainImage"},z.createElement(si,{size:"xsmall",variant:"body"},"+",p.length-f))))),z.createElement(Bs,{direction:"horizontal",size:32}))),z.createElement(Es,{orientation:a?"up":"down"},z.createElement(QT,{size:12,color:"black"}))))}i(kd,"QuoteTrigger");function Ls(t){let{quote:e,input:o,output:n,error:r,warning:a,type:s,selected:l=!1,tagHidden:c=!0,showModalFee:u=!0,onClickAllRoutes:p,fullExpandedMode:m=!1,container:h}=t,d=y().blockchains(),{findToken:f}=y(),g=y().swappers(),{customSlippage:C,slippage:S}=y(),k=C||S,[T,v]=JT(t.expanded),w=ZT(null),A=L(o.value,6,6),M=L(n.value,6,6),x=n.usdValue?L(n.usdValue,4,4):"",E=Pt(o.usdValue,n.usdValue??null),b=L(E,2,2),I=_t(E??0),W=i((le,at)=>le.map((V,_)=>{let G,K=r?.type===3&&r.swap.swapperId===V.swapperId,fe=r?.type===4&&r.recommendedSlippages?.has(_),ne=a?.type===2&&a.recommendedSlippages?.has(_),ge=K||fe,Fe=ne;ge?G="error":Fe&&(G="warning");let ve=ge?yo.t("Slippage Error"):yo.t("Slippage Warning");return K&&(ve=yo.t("Bridge Limit Error")),{swapper:{displayName:nn(V.swapperId,g)??"",image:V.swapperLogo},from:{token:{displayName:V.from.symbol,image:V.from.logo},chain:{displayName:st(V.from.blockchain,d)??"",image:V.from.blockchainLogo},price:{value:_===0&&!at?L(o.value,6,6):L(V.fromAmount,6,6),usdValue:L((V.from.usdPrice??0)*parseFloat(V.fromAmount),4,4),realValue:_===0?o.value:V.fromAmount,realUsdValue:new Ms(V.from.usdPrice??0).multipliedBy(V.fromAmount).toString()}},to:{token:{displayName:V.to.symbol,image:V.to.logo},chain:{displayName:st(V.to.blockchain,d)||"",image:V.to.blockchainLogo},price:{value:L(V.toAmount,6,6),usdValue:L((V.to.usdPrice??0)*parseFloat(V.toAmount),4,4),realValue:V.toAmount,realUsdValue:new Ms(V.to.usdPrice??0).multipliedBy(V.toAmount).toString()}},state:G,alerts:ge||Fe?F.createElement(Hm,{dense:m},F.createElement(GT,{variant:"alarm",type:ge?"error":"warning",title:ve,footer:F.createElement(Gm,null,K&&F.createElement("div",null,F.createElement(Yo,{size:"xsmall",variant:"body",color:"neutral900"},r.fromAmountRangeError),F.createElement(Xo,{direction:"vertical",size:2}),F.createElement(Yo,{size:"xsmall",variant:"body",color:"neutral900"},yo.t({id:"Yours: {amount} {symbol}",values:{amount:L(V.fromAmount,6,6),symbol:V?.from.symbol}}))),(fe||ne)&&!K&&F.createElement("div",null,F.createElement(Yo,{size:"xsmall",variant:"body",color:"neutral900"},yo.t({id:"Minimum required slippage: {minRequiredSlippage}",values:{...r?.type===4&&{minRequiredSlippage:r.recommendedSlippages?.get(_)},...a?.type===2&&{minRequiredSlippage:a.recommendedSlippages?.get(_)}}})),F.createElement(Xo,{direction:"vertical",size:2}),F.createElement(Yo,{size:"xsmall",variant:"body",color:"neutral900"},yo.t({id:"Yours: {userSlippage}",values:{userSlippage:k}}))))})):void 0,time:sn(V.estimatedTimeInSeconds),fee:L(Wa(V,f),2,2),internalSwaps:V.internalSwaps?W(V.internalSwaps):void 0}}),"getQuoteSteps"),B=W(e?.swaps??[]),U=B.length,j=h||N(),R=jp(t.quote.tags||[]),P=!!p,Y=ur(e?.swaps),se=sn(Y),Q=Mr(e?.swaps??[],f),de=L(Q,2,2),vt=Q.gte(new Ms(Fp)),Ze=Y/Up>=Op;return m?F.createElement(VT,{selected:l,fee:de,time:se,tooltipContainer:ro(),steps:B,tags:R,quoteCost:F.createElement(Ws,{quote:e,fullExpandedMode:!0,time:se,fee:de,feeWarning:vt,timeWarning:Ze,showModalFee:u,steps:U}),percentageChange:b,warningLevel:I,outputPrice:{value:M,usdValue:x,realValue:n.value,realUsdValue:n.usdValue}}):F.createElement(Ym,{selected:l,listItem:s==="list-item",basic:s==="basic"},F.createElement("div",{className:Zm()},!c&&R.length?F.createElement(F.Fragment,null,F.createElement(ad,null,R.map((le,at)=>{let V=`${le.value}_${at}`;return F.createElement(F.Fragment,{key:V},F.createElement(jT,{label:le.label,value:le.value}),F.createElement(Xo,{size:4,direction:"horizontal"}))})),F.createElement(ti,null),!P&&F.createElement(Xo,{size:4})):null,F.createElement("div",{id:"portal-root",className:Jm()},F.createElement(Ws,{quote:e,time:se,fee:de,feeWarning:vt,timeWarning:Ze,showModalFee:u,steps:U}),P&&F.createElement(Xm,{onClick:le=>{le.stopPropagation(),p()},size:"xxsmall",type:"secondary",variant:"default",css:{paddingLeft:"$10",paddingRight:"$10",paddingTop:"$5",paddingBottom:"$5"}},F.createElement(Yo,{color:"secondary",variant:"body",size:"xsmall",className:"allRoutesLabel"},yo.t("See All Routes")))),s==="basic"&&F.createElement("div",{className:Rm()},F.createElement(rd,null,F.createElement(KT,{size:12,color:"gray"})),F.createElement(id,null,F.createElement(Is,{size:"small",variant:"body"},`${A} ${B[0].from.token.displayName} = `),F.createElement(Td,{content:n.value,container:j,open:n.value?void 0:!1},F.createElement(Is,{size:"small",variant:"body"},"\xA0",`${M} ${B[B.length-1].to.token.displayName}`))),F.createElement(Td,{content:n.usdValue,container:j},F.createElement(Xo,{size:2,direction:"horizontal"}),F.createElement(Yo,{color:"$neutral600",size:"xsmall",variant:"body"},`($${x})`))),s==="list-item"&&F.createElement(YT,{tooltipContainer:j,type:"output",direction:"vertical",price:{value:M,usdValue:x,realValue:n.value,realUsdValue:n.usdValue},token:{displayName:B[U-1].to.token.displayName,image:B[U-1].to.token.image},chain:{image:B[U-1].to.chain.image},percentageChange:b,warningLevel:I}),s==="swap-preview"&&F.createElement(F.Fragment,null,F.createElement(Wn,{from:B[0].from,to:B[U-1].to,percentageChange:b,warningLevel:I}),F.createElement(Xo,{size:4}))),F.createElement(Km,{selected:l,listItem:s==="list-item",open:T,className:"quote_container",onOpenChange:v},F.createElement(kd,{type:s,quoteRef:w,selected:l,setExpanded:v,container:j,expanded:T,steps:B}),F.createElement(od,{open:T},F.createElement(nd,null),F.createElement("div",{className:jm()},B.map((le,at)=>{let V=`item-${at}`;return F.createElement(XT,{type:"quote-details",key:V,tooltipContainer:j,step:le,hasSeparator:at!==B.length-1,state:le.state})})))))}i(Ls,"Quote");import{Divider as ov,Skeleton as nv}from"@rango-dev/ui";import Ot from"react";import{darkTheme as RT,styled as ui}from"@rango-dev/ui";var vd=ui("div",{$$color:"$colors$neutral100",[`.${RT} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",borderBottomLeftRadius:"$xm",borderBottomRightRadius:"$xm",padding:"$15",variants:{rounded:{true:{borderRadius:"$xm"}},expanded:{true:{paddingBottom:"3px"},false:{paddingBottom:"$12"}}}}),wd=ui("div",{paddingTop:"$2"}),bd=ui("div",{paddingLeft:"$8"}),xd=ui("div",{borderLeft:"1px dashed $foreground",minHeight:" 0",margin:"0px 11.5px",alignSelf:"stretch",variants:{hideSeparator:{true:{minHeight:"unset",height:"0"}}}});import{ChainToken as _d,Divider as St,Skeleton as tt}from"@rango-dev/ui";import q from"react";import{css as ev,styled as Ft}from"@rango-dev/ui";var Ps=Ft("div",{display:"flex"}),Ed=Ft("div",{padding:"$10 $0 $20"}),Id=Ft("div",{padding:"14px $0 $20 $0",display:"flex",flexDirection:"column"}),Ad=Ft("div",{display:"flex",justifyContent:"start",alignItems:"center"}),Nd=Ft("div",{display:"flex",justifyContent:"space-between",alignItems:"end"}),Wd=Ft("div",{height:"$24",marginLeft:"13px",borderLeft:"1px solid $neutral700"}),Bd=Ft("div",{width:"65%",display:"flex",justifyContent:"start"}),Md=Ft("div",{display:"flex",flexDirection:"column",alignItems:"start",flexGrow:1,maxWidth:"148px"}),Ld=Ft("div",{padding:"$15 $0 $15 $0"}),Pd=ev({display:"flex",justifyContent:"space-between",alignItems:"center"});function Ln(t){let{type:e,tagHidden:o=!0}=t,n=q.createElement(Nd,null,q.createElement(Bd,null,q.createElement(_d,{loading:!0,size:"medium",chainImage:"",tokenImage:""}),q.createElement(St,{size:8,direction:"horizontal"}),q.createElement(Md,null,q.createElement(tt,{height:10,width:60,variant:"rounded"}),q.createElement(St,{size:4}),q.createElement(tt,{height:15,variant:"rounded"}))),q.createElement(tt,{height:12,width:64,variant:"rounded"})),r=e==="basic"&&!o;return q.createElement("div",null,!o&&q.createElement(q.Fragment,null,q.createElement(Ps,null,q.createElement(tt,{width:65,height:20,variant:"rounded"}),q.createElement(St,{size:4,direction:"horizontal"}),q.createElement(tt,{width:65,height:20,variant:"rounded"}),q.createElement(St,{size:4,direction:"horizontal"}),q.createElement(tt,{width:65,height:20,variant:"rounded"})),q.createElement(ti,null),!r&&q.createElement(St,{size:4})),q.createElement("div",{className:Pd()},q.createElement(Ps,null,q.createElement(tt,{width:60,height:10,variant:"rounded"}),q.createElement(St,{size:4,direction:"horizontal"}),q.createElement(tt,{width:60,height:10,variant:"rounded"}),q.createElement(St,{size:4,direction:"horizontal"}),q.createElement(tt,{width:60,height:10,variant:"rounded"})),r&&q.createElement(tt,{width:85,height:24,variant:"rounded"})),e==="basic"&&q.createElement(Ed,null,q.createElement(tt,{height:15,width:148,variant:"rounded"})),e==="list-item"&&q.createElement(Id,null,q.createElement(Ad,null,q.createElement(_d,{loading:!0,size:"medium",chainImage:"",tokenImage:""}),q.createElement(St,{direction:"horizontal",size:4}),q.createElement(tt,{height:15,width:150,variant:"rounded"})),q.createElement(St,{size:10}),q.createElement(tt,{height:10,width:184,variant:"rounded"})),e==="swap-preview"&&q.createElement(q.Fragment,null,q.createElement(St,{size:4}),q.createElement(Ld,null,n,q.createElement(Wd,null),n),q.createElement(St,{size:12})))}i(Ln,"QuoteSummarySkeleton");import{ChainToken as Ud,Divider as Ds,NextIcon as tv,Skeleton as mi}from"@rango-dev/ui";import Ee from"react";import{styled as Pn}from"@rango-dev/ui";var Dd=Pn("div",{display:"flex",alignItems:"start"}),$d=Pn("div",{flexGrow:1,paddingTop:"$5",paddingBottom:"$10",display:"flex",alignItems:"center",variants:{extraSpace:{true:{paddingBottom:"$40"}}}}),_s=Pn("div",{display:"flex",alignItems:"center",flexGrow:1}),Fd=Pn("div",{margin:"$0 $2",padding:"$4",display:"flex",justifyContent:"center",alignItems:"center"}),Od=Pn("div",{display:"flex",alignItems:"center"});function Nt(t){let{separator:e=!0}=t;return Ee.createElement(Ee.Fragment,null,Ee.createElement(Od,null,Ee.createElement(mi,{height:22,width:22,variant:"circular"}),Ee.createElement(Ds,{direction:"horizontal",size:8}),Ee.createElement(mi,{height:15,width:148,variant:"rounded"})),Ee.createElement(Dd,null,Ee.createElement(xd,{hideSeparator:!e}),Ee.createElement($d,{extraSpace:e},Ee.createElement(_s,null,Ee.createElement(Ud,{size:"small",loading:!0,chainImage:"",tokenImage:""}),Ee.createElement(Ds,{direction:"horizontal",size:8}),Ee.createElement(mi,{height:12,variant:"rounded"})),Ee.createElement(Fd,null,Ee.createElement(tv,{color:"gray",size:16})),Ee.createElement(_s,null,Ee.createElement(Ud,{size:"small",loading:!0,chainImage:"",tokenImage:""}),Ee.createElement(Ds,{direction:"horizontal",size:8}),Ee.createElement(mi,{height:12,variant:"rounded"})))))}i(Nt,"StepSkeleton");function _n(t){let{type:e,expanded:o,tagHidden:n=!1}=t;return Ot.createElement(vd,{expanded:o,rounded:e!=="basic"},Ot.createElement(Ln,{type:e,tagHidden:n}),Ot.createElement(wd,null,Ot.createElement(nv,{height:15,variant:"rounded"})),o&&Ot.createElement(bd,null,Ot.createElement(ov,{size:24}),Ot.createElement(Nt,null),Ot.createElement(Nt,null),Ot.createElement(Nt,{separator:!1})))}i(_n,"QuoteSkeleton");function So(t){let{quote:e,type:o,loading:n,error:r,warning:a,expanded:s=!1,tagHidden:l,onClick:c,showModalFee:u,selected:p,onClickAllRoutes:m,fullExpandedMode:h=!1,container:d}=t,{inputAmount:f,inputUsdValue:g}=O(),C=e?.outputAmount?new rv(e?.outputAmount):null,S=e?ct(e):null,T=!(r&&(r.type===0||r.type===1))&&e&&!n;return n?di.createElement(xs,null,di.createElement(_n,{tagHidden:l,type:o,expanded:s})):T?di.createElement(xs,{onClick:()=>c?.(e)},di.createElement(Ls,{quote:e,error:r,container:d,showModalFee:u,warning:a,tagHidden:l,selected:p,type:o,expanded:s,onClickAllRoutes:m,fullExpandedMode:h,input:{value:f,usdValue:g?.toString()??""},output:{value:C?.toString()??"",usdValue:S?.toString()??""}})):null}i(So,"QuoteInfo");import{calculatePendingSwap as lv}from"@rango-dev/queue-manager-rango-preset";import{useEffect as cv}from"react";import{useRef as iv,useState as av}from"react";var sv=2e3;function fi({request:t}){let[e,o]=av(!1),n=iv(null),r=i(()=>n.current?.abort(),"cancelFetch"),a=i(async l=>(await new Promise(c=>setTimeout(c,sv)),await s(l,!1)),"retryFetch"),s=i(async(l,c=!1)=>{r(),n.current=new AbortController,o(!0);try{let u=await t(l,{signal:n.current.signal});return n.current=null,u}catch(u){if(c)return await a(l);throw u}finally{o(!1)}},"fetch");return{fetch:s,loading:e,cancelFetch:r}}i(fi,"useFetch");function zd(){let{fetch:t,loading:e,cancelFetch:o}=fi({request:async(n,r)=>await xt().confirmRoute(n,r)});return{fetch:t,loading:e,cancelFetch:o}}i(zd,"useFetchConfirmQuote");function gi(t){if(!t.swaps)throw new Error(ee().noResultError.title,{cause:{type:0,diagnosisMessage:t.diagnosisMessages?.[0]}});let e=$s(t.swaps);if(e)throw new Error(e.message,{cause:e.options})}i(gi,"throwErrorIfResponseIsNotValid");function $s(t){if(Rp(t)){let{swap:n,recommendation:r,fromAmountRangeError:a}=eu(t);return{message:"bridge limit error",options:{type:3,swap:n,recommendation:r,fromAmountRangeError:a}}}let o=ru(t);if(o){let n=Lr(t);return{message:"",options:{type:4,recommendedSlippages:o,minRequiredSlippage:n}}}return null}i($s,"getQuoteError");function Qd(t){let{currentQuote:e,previousQuote:o,meta:n,selectedWallets:r,userSlippage:a,findToken:s}=t,l={quote:null,balance:null},c=$o({previousQuote:o,currentQuote:e,findToken:s,userSlippage:a});c&&(l.quote=c);let u=su(e,r,n.blockchains);return u.length===0||(l.balance={messages:u}),l}i(Qd,"generateWarnings");function hi(t){return t?.code==="ERR_CANCELED"?{swap:null,error:{type:2},warnings:null}:t.cause?{swap:null,error:t.cause,warnings:null}:t?.code==="ERR_BAD_REQUEST"?{swap:null,error:{type:0,diagnosisMessage:t.response.data.error},warnings:null}:{swap:null,error:{type:1},warnings:null}}i(hi,"handleQuoteErrors");function Fs(){let{fromToken:t,toToken:e,inputAmount:o,inputUsdValue:n,setSelectedQuote:r,selectedQuote:a,customDestination:s,resetAlerts:l}=O(),{slippage:c,customSlippage:u}=y(),p=y().getDisabledLiquiditySources(),m=y().blockchains(),h=y().tokens(),{findToken:d}=y(),f=u||c,{fetch:g,cancelFetch:C,loading:S}=zd();return cv(()=>C,[]),{loading:S,fetch:i(async T=>{let v=T.selectedWallets,w=T?.customDestination??s;if(!t||!e||!o)return{quote:null,swap:null,error:null,warnings:null};let A=v.reduce((x,E)=>(x[E.chain]=E.address,x),{}),M={requestId:a?.requestId||"",selectedWallets:A,destination:w||void 0};try{return await g(M,!0).then(x=>{let{result:E}=x;if(!E)throw new Error("Error fetching updated route");gi({diagnosisMessages:E.diagnosisMessages,requestId:E.requestId,swaps:E.result?.swaps});let b={outputAmount:E.result?.outputAmount,requestId:E.requestId,resultType:E.result?.resultType,swaps:E.result?.swaps||[],validationStatus:E.validationStatus,requestAmount:E.requestAmount};r(b);let I={slippage:f.toString(),disabledSwappersGroups:p},W=Qd({previousQuote:a??void 0,currentQuote:b,meta:{blockchains:m},selectedWallets:v,userSlippage:f,inputUsdValue:n,findToken:d});l();let B=!!W.balance,U=lv(o.toString(),E,au(v),I,!B,{blockchains:m,tokens:h});return{quote:b,swap:U,error:null,warnings:W}})}catch(x){return hi(x)}},"fetch"),cancelFetch:C}}i(Fs,"useConfirmSwap");var Cv=dv("div",{width:"100%",display:"flex",justifyContent:"space-between",[`& ${qd}`]:{width:"$48",height:"$48"}}),kv=zs({flexGrow:1,paddingRight:"$10"}),Tv=zs({width:"$24",height:"$24",display:"flex",justifyContent:"center",alignItems:"center"}),vv=zs({display:"flex",justifyContent:"space-between",alignItems:"center"});function Hd(){let{selectedQuote:t,setInputAmount:e,selectedWallets:o,quoteWalletsConfirmed:n,customDestination:r,quoteWarningsConfirmed:a}=O(),s=Sv(),[l,c]=Dn(""),u=!n,[p,m]=Dn(!1),[h,d]=Dn(!1),{isActiveTab:f}=re(),g=y().getDisabledLiquiditySources(),C=yv(g),{manager:S}=pv(),{fetch:k,loading:T,cancelFetch:v}=Fs(),[w,A]=Dn({swap:null,error:null,warnings:null}),[M,x]=Dn(!1),E=i(async({selectedWallets:P,customDestination:Y})=>{let se=await k?.({selectedWallets:P,customDestination:Y});return A(se),se},"onConfirmSwap"),b=i(async()=>{if(w.swap&&n)try{await S?.create("swap",{swapDetails:w.swap},{id:w.swap.requestId});let P=`../${$.swaps}/${w.swap.requestId}`;s(P,{replace:!0}),setTimeout(()=>{e("")},0)}catch(P){c("Error: "+P?.message)}},"addNewSwap"),I=i(async()=>{d(!0),await b(),d(!1)},"onConfirm"),W=i(async()=>{w.warnings?.quote&&Gp(w.warnings.quote)&&!a?x(!0):await I()},"onStartConfirmSwap"),B=i(async()=>{A({error:null,swap:null,warnings:null}),k({selectedWallets:o,customDestination:r}).then(P=>{A(P)}).catch(P=>console.error(P))},"onRefresh");yi(()=>{!!C.current.length&&!g.length&&B(),C.current=g},[g.length]),yi(()=>{u&&v()},[u]),yi(()=>{u&&m(u)},[u]),yi(()=>{u||k({selectedWallets:o,customDestination:r}).then(P=>A(P)).catch(P=>console.error(P))},[]),hv(()=>{t?.requestId||s(`../${location.search}`)},[t?.requestId]);let U=w.warnings?.quote??null,j=w.error,R=[];if(l&&R.push(Le.createElement(uv,{type:"error",variant:"alarm",title:l})),U||j){let P=`../${$.settings}`;R.push(Le.createElement(An,{warning:U,error:j,couldChangeSettings:!1,refetchQuote:B,showWarningModal:M,confirmationDisabled:!f,onOpenWarningModal:()=>x(!0),onCloseWarningModal:()=>x(!1),onConfirmWarningModal:async()=>{x(!1),await b()},onChangeSettings:()=>s(P)}))}return Le.createElement(oe,{header:{title:Os.t("Confirm Swap"),onWallet:()=>{let P=`../${$.wallets}`;s(P)}},footer:Le.createElement(Cv,null,Le.createElement("div",{className:kv()},Le.createElement(mv,{id:"widget-confirm-swap-start-btn",variant:"contained",type:"primary",size:"large",fullWidth:!0,loading:T||h,disabled:!!w.error||!f,onClick:W},Os.t("Start Swap"))),Le.createElement(qd,{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(gv,{size:24})))},p&&Le.createElement(xm,{open:p,onClose:()=>m(!1),onCancel:v,loading:T,onCheckBalance:E}),Le.createElement(ie,null,Le.createElement("div",{className:vv()},Le.createElement(fv,{variant:"title",size:"small"},Os.t("You get")),Le.createElement("div",{className:Tv()},Le.createElement(Or,{onClick:!T&&!p&&!M?B:void 0}))),Le.createElement(Us,{size:"12"}),Eu(R.map((P,Y)=>({element:P,key:`alert-${Y}`})),Le.createElement(Us,{size:10})),R.length>0?Le.createElement(Us,{size:10}):null,Le.createElement(So,{quote:t,type:"swap-preview",expanded:!0,tagHidden:!0,error:w.error,loading:T,warning:w.warnings?.quote??null})))}i(Hd,"ConfirmSwapPage");import{i18n as Ut}from"@lingui/core";import{Button as Js,CustomTokensZeroStateDarkIcon as Fv,CustomTokensZeroStateIcon as Ov,DeleteIcon as Uv,Divider as Un,IconButton as zv,MessageBox as Qv,NotFound as qv,styled as el}from"@rango-dev/ui";import me,{useState as Rs}from"react";import{useNavigate as Hv}from"react-router-dom";import{CloseIcon as bv,IconButton as xv,SearchIcon as Ev,TextField as Iv}from"@rango-dev/ui";import $n from"react";import{styled as wv}from"@rango-dev/ui";var Gd=wv("div",{width:"$24",height:"$24",display:"flex",alignItems:"center",justifyContent:"center"});function Ct(t){let{variant:e,fullWidth:o,color:n,size:r,onChange:a,value:s,style:l,setValue:c,...u}=t;return $n.createElement(Iv,{prefix:$n.createElement(Gd,null,$n.createElement(Ev,{color:"black"})),suffix:!!s.length&&$n.createElement(xv,{variant:"ghost",onClick:()=>c?.(""),size:"small"},$n.createElement(bv,{color:"gray",size:10})),fullWidth:o,color:n,variant:e,style:{padding:10,borderRadius:25,alignItems:"center",...l},size:r,value:s,onChange:a,...u})}i(Ct,"SearchInput");import{i18n as Zs}from"@lingui/core";import{darkTheme as of,Divider as Jo,ExternalLinkIcon as Wv,Image as Bv,ListItemButton as Mv,NotFound as Lv,PinIcon as Pv,Skeleton as nf,Typography as ki,VirtualizedList as _v}from"@rango-dev/ui";import H from"react";import{Divider as ef,ListItem as Nv,Skeleton as Fn}from"@rango-dev/ui";import kt from"react";import{css as Zo,darkTheme as Vd,ImageContainer as Av,styled as ut,Typography as Kd}from"@rango-dev/ui";var Qs=Zo({position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:100,overflow:"hidden"}),qs=Zo({position:"relative",height:12,width:"30%",maxWidth:"150px"}),Hs=Zo({position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",bottom:"-8px"}),Gs=Zo({transform:"translateY(12px)",visibility:"hidden",display:"flex","& a":{display:"flex",justifyContent:"center",alignItems:"center",fontSize:"$12",lineHeight:"$16",$$color:"$colors$neutral600",[`.${Vd} &`]:{$$color:"$colors$neutral700"},color:"$$color",textDecoration:"none"}}),Vs=Zo({}),Ks=Zo(),jd=ut("div",{display:"flex",flexDirection:"column",flexGrow:1,overflow:"hidden",justifyContent:"center"}),js=ut("div",{display:"flex",alignItems:"center","._typography":{textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:100,overflow:"hidden"}}),Si=ut("ul",{flexGrow:1,padding:0,margin:0,listStyle:"none","& li":{alignItems:"none","&:hover":{[`& .${qs}`]:{[`& .${Gs}`]:{position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",visibility:"visible"},[`& .${Vs}`]:{bottom:"-15px"},[`& .${Qs}`]:{position:"absolute",transform:"translateY(-12px)",visibility:"hidden"},[`& .${Hs}`]:{position:"absolute",transform:"translateY(-12px)",bottom:"-10px"}}}}}),Xs=ut("div",{paddingLeft:"$5",paddingRight:"$5",borderRadius:"$md",display:"flex",alignItems:"center"}),Ys=ut(Kd,{}),Xd=ut("div",{textAlign:"right",width:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",[`& .${Ks}`]:{$$color:"$colors$neutral600",[`.${Vd} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),Ci=ut("div",{display:"flex",alignItems:"end",flexDirection:"column"}),BU=ut("div",{display:"flex",alignItems:"center"}),Yd=ut("div",{position:"relative",[`& ${Av}`]:{borderRadius:"$xm",overflow:"hidden"}}),Zd=ut("div",{position:"absolute",backgroundColor:"$neutral100",padding:"$4",borderRadius:"50%",bottom:-6,right:-6}),Jd=ut(Kd,{width:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}),Rd=ut("a",{"& svg:hover":{color:"$colors$info"}});function tf(t){return kt.createElement(Si,null,Array.from(Array(t.size),e=>kt.createElement(Nv,{key:e,hasDivider:!0,start:kt.createElement(Fn,{variant:"circular",width:35,height:35}),end:kt.createElement(Ci,null,kt.createElement(Fn,{variant:"text",size:"large",width:70}),kt.createElement(ef,{size:4}),kt.createElement(Fn,{variant:"text",size:"medium",width:50})),title:kt.createElement("div",null,kt.createElement(Fn,{variant:"text",size:"large",width:90}),kt.createElement(ef,{size:4}),kt.createElement(Fn,{variant:"text",size:"medium",width:90}))})))}i(tf,"LoadingTokenList");var Dv=20,$v=i(t=>{let{address:e,name:o,url:n,token:r,customCssForTag:a,customCssForTagTitle:s}=t,l=e.length;return H.createElement("div",{className:qs()},o?H.createElement("div",{className:Qs()},o):H.createElement(js,{className:Hs()},H.createElement(ki,{variant:"title",size:"xmedium"},r.symbol),H.createElement(Jo,{direction:"horizontal",size:4}),H.createElement(Xs,{css:a},H.createElement(Ys,{variant:"body",size:"xsmall",css:s},r.blockchain))),!!e&&H.createElement("div",{className:`${Gs()} ${!o&&Vs()}`},l>10?`${e.slice(0,5)}...${e.slice(l-6,l)}`:e," ",H.createElement(Jo,{size:4,direction:"horizontal"}),H.createElement(Rd,{href:n,target:"_blank",rel:"nofollow noreferrer",onClick:c=>c.stopPropagation()},H.createElement(Wv,{size:12}))))},"renderDesc");function On(t){let{list:e,searchedFor:o="",onChange:n,selectedBlockchain:r,showTitle:a=!0,action:s}=t,l=y().fetchStatus,c=y().blockchains(),{getBalanceFor:u,fetchingWallets:p}=y(),{isTokenPinned:m}=y(),h=i(f=>{let g=hr(u(f));return s?s(f):p?H.createElement(Ci,null,H.createElement(nf,{variant:"text",size:"large",width:70}),H.createElement(Jo,{size:4}),H.createElement(nf,{variant:"text",size:"medium",width:50})):g&&H.createElement(Xd,null,H.createElement(Jd,{variant:"title",size:"small"},g.amount),H.createElement("div",null),g.usdValue&&H.createElement(ki,{variant:"body",className:Ks(),size:"xsmall"},`$${g.usdValue}`))},"endRenderer"),d=i(()=>H.createElement(_v,{itemContent:f=>{let g=e[f],C=g.address||"",S=c.find(w=>w.name===g.blockchain),k=Ha(S.color,"main"),T={$$color:k.main150,[`.${of} &`]:{$$color:k.main750},backgroundColor:"$$color"},v={$$color:k.main750,[`.${of} &`]:{$$color:k.main150},color:"$$color"};return H.createElement("div",{style:{paddingRight:5}},H.createElement(Mv,{style:{width:"100%",overflow:"hidden",height:"60px"},"tab-index":f,key:`${g.symbol}${g.address}`,id:`${g.symbol}${g.address}`,className:"widget-token-list-item-btn",hasDivider:!0,onClick:()=>n&&n(e[f]),start:H.createElement(Yd,null,H.createElement(Bv,{src:g.image,size:30}),t.type!=="custom-token"&&m(g,t.type)&&H.createElement(Zd,null,H.createElement(Pv,{size:12,color:"gray"}))),title:S?.type==="COSMOS"||g.name||!g.name&&!C?H.createElement(js,null,H.createElement(ki,{variant:"title",size:"xmedium"},g.symbol),H.createElement(Jo,{direction:"horizontal",size:4}),H.createElement(Xs,{css:T},H.createElement(Ys,{variant:"body",size:"xsmall",css:v},g.blockchain))):void 0,description:S?.info&&C&&S.type!=="COSMOS"?$v({address:C,token:e[f],customCssForTag:T,customCssForTagTitle:v,name:g.name,url:S.info.addressUrl.split("{wallet}").join(C)}):g.name||void 0,end:h(g)}))},totalCount:e.length,key:`${r}-${o}`}),"renderList");return H.createElement(H.Fragment,null,a&&H.createElement(H.Fragment,null,H.createElement(ki,{variant:"label",size:"large"},Zs.t("Select Token")),H.createElement(Jo,{size:4})),H.createElement(jd,null,H.createElement(Jo,{size:4}),l==="loading"&&H.createElement(tf,{size:Dv}),l==="success"&&(e.length?H.createElement(Si,{as:"ul"},d()):!!o&&H.createElement(Lv,{title:Zs.t("No results found"),description:Zs.t("Try using different keywords")}))))}i(On,"TokenList");var Gv=el("div",{display:"flex",justifyContent:"space-between",flexDirection:"column",flex:1}),Vv=el("div",{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",flex:"0.75"}),Kv=el(zv,{"&:hover":{"& svg":{color:"$secondary550"}}});function rf(){let[t,e]=Rs(""),{deleteCustomToken:o}=y(),n=y().customTokens(),{fromToken:r,toToken:a,setFromToken:s,setToToken:l}=O(),{mode:c}=zo({}),u=Hv(),[p,m]=Rs(!1),[h,d]=Rs(),f=i(k=>{let T=k.target.value;e(T)},"handleSearch"),g=c==="dark",C=n.filter(k=>Je(k.symbol,t)||Je(k.address||"",t)||Je(k.name||"",t)),S=i(()=>{if(h){let k=a?lt(a):null,T=r?lt(r):null,v=lt(h);k===v?l({token:null}):T===v&&s({token:null}),o(h)}m(!1)},"handleDeleteCustomToken");return me.createElement(oe,{header:{title:Ut.t("Custom Tokens")}},me.createElement(ie,null,me.createElement(Gv,null,n.length?me.createElement(me.Fragment,null,me.createElement(Ct,{value:t,setValue:e,fullWidth:!0,color:"light",variant:"contained",placeholder:Ut.t("Search Token"),onChange:f}),me.createElement(Un,{size:16}),me.createElement(On,{list:C,type:"custom-token",searchedFor:t,showTitle:!1,action:k=>me.createElement(Kv,{id:"widget-custom-token-delete-icon-btn",variant:"ghost",onClick:()=>{m(!0),d(k)}},me.createElement(Uv,{size:12,color:"gray"}))})):me.createElement(Vv,null,me.createElement(qv,{icon:g?me.createElement(Fv,{size:200}):me.createElement(Ov,{size:200}),title:Ut.t("No custom tokens"),description:Ut.t("press the button to add your custom token")})),me.createElement(Un,{size:20}),me.createElement(Js,{id:"widget-custom-token-add-btn",type:"primary",variant:"contained",size:"large",onClick:()=>u($.addCustomTokens)},Ut.t("Add Custom Token"))),me.createElement(J,{open:p,dismissible:!0,onClose:()=>m(!1),container:N()},me.createElement(Qv,{title:Ut.t("Delete Custom Token"),type:"error",description:Ut.t("Are you sure you want to Delete this Token?")},me.createElement(Un,{size:40}),me.createElement(Un,{size:10}),me.createElement(Js,{fullWidth:!0,id:"widget-custom-token-delete-modal-yes-btn",variant:"contained",type:"primary",size:"large",onClick:S},Ut.t("Yes, Delete it")),me.createElement(Un,{size:12}),me.createElement(Js,{id:"widget-custom-token-delete-modal-no-btn",fullWidth:!0,variant:"outlined",type:"primary",size:"large",onClick:()=>m(!1)},Ut.t("No, Continue"))))))}i(rf,"CustomTokensPage");import{i18n as qe}from"@lingui/core";import{useManager as mw}from"@rango-dev/queue-manager-react";import{Button as sl,darkTheme as dw,Divider as ko,MessageBox as fw,NotFound as gw,styled as ll,Typography as wi}from"@rango-dev/ui";import{TransactionStatus as qn}from"rango-types";import ae,{useMemo as bf,useState as bi}from"react";import{useNavigate as hw}from"react-router-dom";import{FilterIcon as ew,Popover as tw}from"@rango-dev/ui";import Co from"react";import{css as jv,darkTheme as Ti,IconButton as Xv,styled as zn}from"@rango-dev/ui";var tl=zn("div",{position:"relative","&::before":{position:"absolute",right:"1px",top:"-1px",width:"$8",height:"$8",borderRadius:"100%",backgroundColor:"$neutral300",[`.${Ti} &`]:{backgroundColor:"$neutral400"},padding:"$2"},variants:{isSelect:{true:{"&::before":{content:""}}}}}),af=zn(Xv,{width:"$36",height:"$36",position:"relative",padding:"0",overflow:"unset",backgroundColor:"$neutral300",[`.${Ti} &`]:{backgroundColor:"$neutral400"},"&:hover":{backgroundColor:"$secondary100",[`.${Ti} &`]:{backgroundColor:"$neutral"},[`& ${tl}::before`]:{backgroundColor:"$secondary100",[`.${Ti} &`]:{backgroundColor:"$neutral"}}},variants:{isSelect:{true:{border:"1px solid $secondary"}}}}),sf=zn("div",{position:"absolute",width:"$6",height:"$6",display:"flex",justifyContent:"center",alignItems:"center",borderRadius:"3px",top:"$0",right:"1px",backgroundColor:"$secondary500"}),lf=zn("div",{padding:"$15",borderRadius:"$sm",width:"248px",backgroundColor:"$background",zIndex:10}),cf=jv({display:"flex",justifyContent:"space-between",alignItems:"center"}),pf=zn("ul",{margin:0,listStyle:"none",height:"100%",padding:0,".item-start-container":{paddingRight:"0 !important"}});import{i18n as uf}from"@lingui/core";import{Button as Yv,Divider as mf,ListItemButton as Zv,Radio as Jv,RadioRoot as Rv,Typography as df}from"@rango-dev/ui";import ot from"react";function ff(t){let{filterBy:e,onClickItem:o}=t;return ot.createElement(lf,null,ot.createElement("div",{className:cf()},ot.createElement(df,{size:"small",variant:"body"},uf.t("Status")),ot.createElement(Yv,{id:"widget-filter-selector-reset-btn",variant:"ghost",size:"xxsmall",onClick:()=>o("")},uf.t("Reset"))),ot.createElement(mf,{size:10}),ot.createElement(Rv,{value:e},ot.createElement(pf,null,t.list.map((n,r)=>ot.createElement(Zv,{key:n.id,style:{height:"40px",width:"100%"},selected:!1,hasDivider:t.list.length-1!=r,id:n.id,title:ot.createElement(ot.Fragment,null,ot.createElement(mf,{direction:"horizontal",size:4}),ot.createElement(df,{size:"medium",variant:"body"},n.title)),start:ot.createElement(Jv,{value:n.id}),onClick:o})))))}i(ff,"FilterSelectorContent");function ol(t){let{onClickItem:e,onOpenChange:o,filterBy:n,list:r,open:a}=t;return Co.createElement("div",null,Co.createElement(tw,{open:a,align:"end",onOpenChange:o,container:N(),content:Co.createElement(ff,{list:r,filterBy:n,onClickItem:s=>{e(s),o(!1)}})},Co.createElement(af,{id:"widget-filter-selector-filter-icon-btn",variant:"default",isSelect:!!n,onClick:()=>o(!t.open)},Co.createElement(tl,{isSelect:!!n},Co.createElement(ew,{size:16,color:"black"}),!!n&&Co.createElement(sf,null)))))}i(ol,"FilterSelector");import{i18n as rw}from"@lingui/core";import{Divider as Cf,GroupedVirtualizedList as iw,Skeleton as aw,SwapListItem as kf,Typography as sw}from"@rango-dev/ui";import Qe,{useCallback as Tf,useEffect as lw,useRef as cw,useState as pw}from"react";function gf(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(gf,"calculateGroupsSoFar");import{css as ow,darkTheme as nw,styled as Qn}from"@rango-dev/ui";var nl=ow(),hf=Qn("div",{display:"flex",justifyContent:"center",alignItems:"center",padding:"$5"}),rl=Qn("div",{width:"100%",display:"flex",flexDirection:"column",backgroundColor:"$background",padding:"$10 $5 0 $5",[`& .${nl}`]:{$$color:"$colors$neutral600",[`.${nw} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),il=Qn("div",{display:"flex",justifyContent:"flex-start",padding:"$2"}),yf=Qn("div",{gap:"$10",display:"flex",flexDirection:"column"}),Sf=Qn("div",{height:"100%",display:"flex",justifyContent:"center",alignItems:"center"});var uw=10;function al(t){let{list:e,onSwapClick:o,groupBy:n,isLoading:r}=t,[a,s]=pw([]),l=cw(0),{swaps:c,groupCounts:u,groups:p}=n(e),m=Tf(gf,[]),h=Tf(()=>{let d=e.length-l.current;d&&(l.current+=Math.min(d,uw),s(m(u,l.current)))},[e.length]);if(lw(()=>{r||h()},[r,h]),r){let d=[1,2];return Qe.createElement(Qe.Fragment,null,[d,d].map((g,C)=>Qe.createElement(rl,{key:C},Qe.createElement(il,null,Qe.createElement(aw,{variant:"text",width:60,size:"small"}),Qe.createElement(Cf,{size:16})),Qe.createElement(Cf,{size:4}),Qe.createElement(yf,null,g.map((k,T)=>Qe.createElement(kf,{isLoading:!0,key:T}))))))}return Qe.createElement(iw,{endReached:()=>{l.current<e.length&&h()},groupCounts:a,groupContent:d=>Qe.createElement(rl,null,Qe.createElement(il,null,Qe.createElement(sw,{variant:"label",size:"medium",className:nl()},p[d]))),itemContent:(d,f)=>{let g=c[d];if(!g)return null;let C=g.steps[0],S=g.steps[g.steps.length-1];return Qe.createElement(hf,{key:g.requestId},Qe.createElement(kf,{requestId:g.requestId,creationTime:g.creationTime,status:g.status,onClick:o,tooltipContainer:N(),onlyShowTime:p[f]===rw.t("Today"),swapTokenData:{from:{token:{image:C.fromLogo,displayName:C.fromSymbol},blockchain:{image:C.fromBlockchainLogo||""},amount:L(g.inputAmount,6,6),realAmount:g.inputAmount},to:{token:{image:S.toLogo,displayName:S.toSymbol},blockchain:{image:S.toBlockchainLogo||""},amount:L(S.outputAmount||S.expectedOutputAmountHumanReadable||"",6,6),realAmount:S.outputAmount||S.expectedOutputAmountHumanReadable||""}}}))}})}i(al,"HistoryGroupedList");import{i18n as vi}from"@lingui/core";import vf from"dayjs";var wf=i(t=>{let e=new Map([["today",{title:vi.t("Today"),swaps:[]}],["week",{title:vi.t("This week"),swaps:[]}],["month",{title:vi.t("This month"),swaps:[]}],["year",{title:vi.t("This year"),swaps:[]}]]);function o(c,u){e.has(c)||e.set(c,{title:c,swaps:[]}),e.get(c)?.swaps.push(u)}i(o,"addYearsToOutput");let n=vf();t.forEach(c=>{let u=Number(c.creationTime),p=vf(u);if(n.isSame(p,"day"))e.get("today")?.swaps.push(c);else if(n.isSame(p,"week"))e.get("week")?.swaps.push(c);else if(n.isSame(p,"month"))e.get("month")?.swaps.push(c);else if(n.isSame(p,"year"))e.get("year")?.swaps.push(c);else{let m=new Date(u).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 yw=ll("div",{overflowY:"visible",width:"100%",display:"flex",flexDirection:"column",gap:15,height:"100%"}),Sw=ll("div",{display:"flex",justifyContent:"center",alignItems:"center"}),Cw=ll("div",{"._typography":{color:"$neutral700",[`.${dw}&`]:{color:"$neutral900"}}}),kw=[{id:qn.SUCCESS,title:qe.t("Complete")},{id:qn.RUNNING,title:qe.t("Running")},{id:qn.FAILED,title:qe.t("Failed")}],Tw=i((t,e)=>t?.length?t.filter(o=>wt(o.fromBlockchain,e)||wt(o.toBlockchain,e)||wt(o.toSymbol,e)||wt(o.fromSymbol,e)).length:!1,"isStepContainsText");function xf(){let t=hw(),{manager:e,state:o}=mw(),n=pt(e).map(({swap:T})=>T),[r,a]=bi(""),[s,l]=bi(!1),c=!o.loadedFromPersistor,[u,p]=bi(""),[m,h]=bi(!1),d=i(T=>{let v=T.target.value;a(v)},"handleSearch"),f=bf(()=>!r&&!u?n:n.filter(T=>{let{inputAmount:v,status:w,steps:A,requestId:M}=T;return(!r||wt(v,r)||wt(w,r)||Tw(A,r)||wt(M,r))&&(!u||u===w)}),[n,r,u]),g=!f?.length&&!c,C=i(()=>h(!1),"onCloseModal"),S=i(async()=>{try{await e?.clearQueue(),h(!1)}catch(T){console.log(T)}},"onClear"),k=bf(()=>!n.some(T=>T.status===qn.SUCCESS||T.status===qn.FAILED),[n]);return ae.createElement(oe,{header:{title:qe.t("History"),suffix:ae.createElement(Vt,null,ae.createElement(sl,{id:"widget-history-clear-btn",disabled:k,variant:"ghost",size:"xsmall",onClick:()=>h(!0)},ae.createElement(wi,{size:"medium",variant:"label",color:"error"},qe.t("Clear"))))}},ae.createElement(ie,null,ae.createElement(Sw,null,ae.createElement(Ct,{setValue:a,fullWidth:!0,variant:"contained",placeholder:qe.t("Search Transaction"),autoFocus:!0,onChange:d,style:{height:36},value:r}),ae.createElement(ko,{size:10,direction:"horizontal"}),ae.createElement(ol,{filterBy:u,open:s,onOpenChange:T=>l(T),onClickItem:T=>p(T),list:kw})),ae.createElement(ko,{size:"16"}),ae.createElement(yw,null,g&&ae.createElement(Sf,null,ae.createElement(ko,{size:32}),ae.createElement(gw,{title:r?qe.t("No results found"):qe.t("No transactions"),titleColor:r?void 0:"$info",hasIcon:!!r,description:r?qe.t("Try using different keywords"):qe.t("Your transaction history is stored locally and will appear here after you start a swap")})),!g&&ae.createElement(al,{list:f,onSwapClick:t,groupBy:wf,isLoading:c}))),ae.createElement(J,{open:m,onClose:C,container:N()},ae.createElement(ko,{size:20}),ae.createElement(fw,{type:"warning",title:qe.t("Clear Transaction History"),description:ae.createElement(Cw,null,ae.createElement(wi,{variant:"body",size:"medium"},qe.t("Proceeding will remove all successful and failed transactions from the widget. Do you want to continue?")),ae.createElement(ko,{size:"24"}),ae.createElement(wi,{variant:"body",size:"small"},qe.t("Note: This does not erase your transaction history on the chain; it only removes them here.")))}),ae.createElement(ko,{size:30}),ae.createElement(sl,{id:"widget-history-clear-modal-yes-btn",variant:"contained",type:"primary",size:"large",onClick:S},qe.t("Yes, Clear the history")),ae.createElement(ko,{size:10}),ae.createElement(sl,{id:"widget-history-clear-modal-no-btn",variant:"outlined",type:"primary",size:"large",onClick:C},ae.createElement(wi,{variant:"title",size:"medium",color:"primary"},qe.t("No, Cancel")))))}i(xf,"HistoryPage");import{i18n as Gw}from"@lingui/core";import{Button as Vw,Divider as Vf,styled as Kw,WarningIcon as jw}from"@rango-dev/ui";import Xw from"bignumber.js";import He,{useEffect as Kf,useState as jf}from"react";import{useNavigate as Yw}from"react-router-dom";import{i18n as If}from"@lingui/core";import{Alert as ww,Divider as cl,NoRouteIcon as bw,Typography as xw}from"@rango-dev/ui";import To from"react";import{styled as vw}from"@rango-dev/ui";var Ef=vw("div",{display:"flex",flexDirection:"column",alignItems:"center"});function pl(){let{fromToken:t,toToken:e}=O();return!!t&&!!e&&Mt(t,e)?To.createElement(Ef,null,To.createElement(cl,{size:10}),To.createElement(bw,{size:24,color:"gray"}),To.createElement(cl,{size:4}),To.createElement(xw,{variant:"title",size:"small"},If.t("No Routes Found")),To.createElement(cl,{size:4}),To.createElement(ww,{title:If.t("You cannot use the same token for From and To."),type:"warning",variant:"alarm"})):null}i(pl,"SameTokensWarning");import{i18n as Bw}from"@lingui/core";import{Header as Mw}from"@rango-dev/ui";import Jt,{useEffect as Lw,useState as Pw}from"react";import{i18n as Iw}from"@lingui/core";import{Divider as ml,FullExpandedQuote as Aw,Typography as Nw}from"@rango-dev/ui";import Se from"react";import{styled as ul}from"@rango-dev/ui";var Af=ul("div",{display:"flex",justifyContent:"center",flexDirection:"column",height:"100%"}),Nf=ul("div",{display:"flex",justifyContent:"space-between",alignItems:"center"}),Wf=ul("div",{width:"146px"});import{i18n as Hn}from"@lingui/core";import{Select as Ew}from"@rango-dev/ui";import Bf from"react";function xi(t){let{updateQuotePartialState:e,sortStrategy:o}=O(),n=[{value:"SMART",label:Hn.t("Smart Routing")},{value:"FEE",label:Hn.t("Lowest Fee")},{value:"SPEED",label:Hn.t("Fastest Transfer")},{value:"NET_OUTPUT",label:Hn.t("Maximum Return")},{value:"PRICE",label:Hn.t("Maximum Output")}];return Bf.createElement(Wf,null,Bf.createElement(Ew,{container:t.container,options:n,value:o,handleItemClick:r=>{e("sortStrategy",r.value)},variant:"filled"}))}i(xi,"SelectStrategy");var Mf=3;function Gn(t){let{loading:e,onClickOnQuote:o,fetch:n,showModalFee:r,hasSort:a=!0,fullExpandedMode:s=!1,container:l}=t,{selectedQuote:c,quotes:u,updateQuotePartialState:p,fromToken:m,toToken:h,sortStrategy:d,error:f}=O(),{slippage:g,customSlippage:C}=y(),{findToken:S}=y(),k=l||N(),T=!!u&&u.results.length,v=C??g,w=i(x=>{if(!m||!h||!u)return null;let E={requestAmount:u.requestAmount,validationStatus:null,...x};return $o({currentQuote:E,userSlippage:v,findToken:S})},"getQuoteWarning"),A=f?.type===0||f?.type===1,M=u?.results?Br(d,u?.results):[];return Se.createElement(Se.Fragment,null,a&&Se.createElement(Se.Fragment,null,Se.createElement(Nf,null,Se.createElement(Nw,{size:"xmedium",variant:"title"},Iw.t("Sort by")),Se.createElement(xi,{container:k})),Se.createElement(ml,{size:"10"})),e&&Array.from({length:Mf},(x,E)=>Se.createElement(Se.Fragment,{key:E},s?Se.createElement(Aw,{loading:!0}):Se.createElement(_n,{tagHidden:!1,type:"list-item",expanded:!1}),E!==Mf-1&&Se.createElement(ml,{size:16}))),!e&&Se.createElement(Se.Fragment,null,T?M.map((x,E)=>{let b=w(x),I=$s(x.swaps),W=M.length-1===E;return Se.createElement(Se.Fragment,{key:x.requestId},Se.createElement(So,{showModalFee:r,container:k,selected:c?.requestId===x.requestId,tagHidden:!1,quote:{...x,requestAmount:u.requestAmount,validationStatus:null},loading:e,error:I?.options||null,warning:b,fullExpandedMode:s,onClick:B=>{I||p("warning",b),p("error",I?.options||null),o(B)},type:"list-item"}),!W&&Se.createElement(ml,{size:16}))}):A&&Se.createElement(Af,null,Se.createElement(En,{size:s?"large":"small",error:f,fetch:n}))))}i(Gn,"Quotes");import{darkTheme as Ww,styled as Lf}from"@rango-dev/ui";var Pf=Lf("div",{transition:"width 0.2s, opacity 0.2s, margin-left 0.2s",height:"700px",width:"390px",position:"relative",opacity:1,marginLeft:"$16",backgroundColor:"$neutral100",[`.${Ww} &`]:{backgroundColor:"$neutral300"},variants:{expandMode:{default:{width:"390px"},full:{width:"719px"}}},"&.is-hidden":{width:0,height:0,opacity:0,marginLeft:0}}),_f=Lf("div",{position:"relative",overflow:"hidden",padding:"$20",flexGrow:1,display:"flex",flexDirection:"column",overflowY:"auto",borderRadius:"$primary",backgroundColor:"$background"});var _w=100;function dl(t){let{fetch:e,loading:o,onClickOnQuote:n,onClickRefresh:r,isVisible:a}=t,[s,l]=Pw(!1),c=s?"":"is-hidden",{config:u}=y(),p=u?.variant==="full-expanded",m=ro();return Lw(()=>{let h=null;return a?h=setTimeout(()=>{l(!0)},_w):(l(!1),h&&clearTimeout(h)),()=>{h&&clearTimeout(h)}},[a]),Jt.createElement(Pf,{expandMode:u?.variant==="full-expanded"?"full":"default",className:`${c} ${Qr()}`,id:De.EXPANDED_BOX_ID},Jt.createElement(Mw,{title:Bw.t("Routes"),suffix:Jt.createElement(Jt.Fragment,null,Jt.createElement(xi,{container:m}),Jt.createElement(fo,{container:m,onClickRefresh:r,hidden:["history","notifications","settings"]}))}),Jt.createElement(_f,null,Jt.createElement(Gn,{showModalFee:!0,fetch:e,hasSort:!1,loading:o,container:ro(),onClickOnQuote:n,fullExpandedMode:p})))}i(dl,"ExpandedQuotes");import{i18n as Qf}from"@lingui/core";import{SwapInput as qf}from"@rango-dev/ui";import Ow from"bignumber.js";import Vn from"react";import{ReverseIcon as Fw}from"@rango-dev/ui";import gl from"react";import{keyframes as Dw,styled as Df}from"@rango-dev/ui";var fl=450,$w=Dw({"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)"}}),$f=Df("div",{position:"absolute",bottom:"-12px",left:"50%",transform:"translate(-50%, 10%)",cursor:"pointer"}),Ff=Df("div",{borderRadius:"$md",border:"3px solid $background",background:"$neutral100",width:"$24",height:"$24",display:"flex",justifyContent:"center",alignItems:"center",color:"$foreground","&.rotate":{"& svg":{animation:`${$w} ${fl}ms ease-in-out forwards`}},"&:hover":{color:"$secondary500",transform:"translateY(1px) scale(1.04)",boxShadow:"1px 1px 1px 1px rgba(0, 0, 0, 0.05)"}});function hl(){let t=O.use.switchFromAndTo();return gl.createElement($f,null,gl.createElement(Ff,{onClick:e=>{let o=e.currentTarget;o.classList.add("rotate"),setTimeout(()=>{o.classList.remove("rotate")},fl),t()}},gl.createElement(Fw,{size:12})))}i(hl,"SwitchFromAndToButton");import{styled as Of}from"@rango-dev/ui";var Uf=Of("div",{display:"flex",flexDirection:"column",gap:"$5",alignSelf:"stretch"}),zf=Of("div",{position:"relative"});function yl(t){let{fetchingQuote:e,fetchMetaStatus:o,onClickToken:n,isExpandable:r}=t,{fromToken:a,fromBlockchain:s,toToken:l,toBlockchain:c,setInputAmount:u,inputAmount:p,inputUsdValue:m,outputAmount:h,outputUsdValue:d,selectedQuote:f}=O(),{connectedWallets:g,getBalanceFor:C}=y(),S=a?C(a):null,k=hr(S)?.amount??"0",T=S?new Ow(S.amount).shiftedBy(-S.decimals):ce,v=!!s&&Oc(g,s.name),w=!Na(f,p,m),A=!Na(f,p,d),M=!m||!d||!d.gt(0)?null:Pt(m.toString(),d.toString());return Vn.createElement(Uf,null,Vn.createElement(zf,null,Vn.createElement(qf,{label:Qf.t("From"),mode:"From",onInputChange:u,balance:k,chain:{displayName:s?.displayName||"",image:s?.logo||""},token:{displayName:a?.symbol||"",image:a?.image||""},onClickToken:()=>n("from"),price:{value:p,usdValue:w?void 0:L(m,4,4),realUsdValue:w?void 0:m?.toString(),error:w?ee().unknownPriceError.impactTitle:void 0},disabled:o==="failed",loading:o==="loading",loadingBalance:v,tooltipContainer:N(),onSelectMaxBalance:()=>{let x=L(T,S?.decimals),E=S?.amount?x:"";u(E)},anyWalletConnected:g.length>0}),Vn.createElement(hl,null)),Vn.createElement(qf,{sharpBottomStyle:!r&&(!!f||e),label:Qf.t("To"),mode:"To",fetchingQuote:e,chain:{displayName:c?.displayName||"",image:c?.logo||""},token:{displayName:l?.symbol||"",image:l?.image||""},percentageChange:L(Pt(m,d),2,2),warningLevel:_t(M??0),price:{value:L(h,6,6),usdValue:A?void 0:L(d,4,4),realValue:h?.toString(),realUsdValue:A?void 0:d?.toString(),error:A?ee().unknownPriceError.impactTitle:void 0},onClickToken:()=>n("to"),disabled:o==="failed",loading:o==="loading",tooltipContainer:N()}))}i(yl,"Inputs");import{useCallback as Uw,useEffect as zw,useRef as Qw,useState as qw}from"react";function Hf(){let{fetch:t,loading:e,cancelFetch:o}=fi({request:async(n,r)=>await xt().getAllRoutes(n,r)});return{fetch:t,loading:e,cancelFetch:o}}i(Hf,"useFetchAllQuotes");var Hw=600;function Ei({refetchQuote:t}){let{fetch:e,cancelFetch:o}=Hf(),{excludeLiquiditySources:n,routing:r}=y().config,{connectedWallets:a}=y(),{fromToken:s,toToken:l,inputAmount:c,inputUsdValue:u,selectedQuote:p,sortStrategy:m,resetQuote:h,error:d,warning:f,setSelectedQuote:g,updateQuotePartialState:C}=O(),{slippage:S,customSlippage:k,affiliatePercent:T,affiliateRef:v,affiliateWallets:w,fetchStatus:A}=y(),M=y().getLiquiditySources(),x=y().getDisabledLiquiditySources(),E=y().excludeLiquiditySources(),{findToken:b}=y(),[I,W]=qw(!0),B=Qw(c),U=k??S,R=!s||!l||Mt(s,l)||!ln(c),P=i(Q=>{W(Q)},"resetState"),Y=i(Q=>{let{fromToken:de,toToken:vt,inputAmount:Ze,liquiditySources:le,excludeLiquiditySources:at,disabledLiquiditySources:V,slippage:_,affiliateRef:G,affiliatePercent:K,affiliateWallets:fe}=Q;if(I||P(!0),!R&&de&&vt){h();let ne=iu({fromToken:de,toToken:vt,inputAmount:Ze,liquiditySources:le,excludeLiquiditySources:at,disabledLiquiditySources:V,wallets:a,slippage:_,affiliateRef:G,affiliatePercent:K,affiliateWallets:fe});No("experimental",r)&&(ne.experimental=!0),No("avoidNativeFee",r)&&(ne.avoidNativeFee=!0),No("enableCentralizedSwappers",r)&&(ne.enableCentralizedSwappers=!0),r?.maxLength&&(ne.maxLength=r.maxLength),e(ne).then(ge=>{let Fe=Br(m,ge.results),ve=Kp(p,Fe,ge.requestAmount);W(!1),C("quotes",ge),g(ve),gi({diagnosisMessages:ge.diagnosisMessages,requestId:ve?.requestId||"",swaps:ve?.swaps});let dt=ve&&$o({currentQuote:ve,userSlippage:U,findToken:b});C("warning",dt)}).catch(ge=>{let{error:Fe}=hi(ge);(Fe?.type===0||Fe?.type===1)&&h(),Fe?.type!==2&&(C("error",Fe),W(!1))})}},"fetch"),se=Uw(Ic(Q=>{Y(Q)},Hw),[R]);return zw(()=>{if(!t){W(!1);return}if(A!=="success")return;if(R){W(!1),(p||d||f)&&h();return}if(!ln(c)||u?.eq(0)){P(!1),o();return}h(),P(!0);let Q=Y;return B.current&&B.current!=c&&(Q=se),B.current=c,Q({inputAmount:c,fromToken:s,toToken:l,liquiditySources:M,excludeLiquiditySources:E,disabledLiquiditySources:x,slippage:U,affiliateRef:v,affiliatePercent:T,affiliateWallets:w}),o},[A,c,s?.symbol,s?.address,s?.blockchain,l?.symbol,l?.address,l?.blockchain,R,M?.length,n,x.length,U,v,T,JSON.stringify(w)]),{fetch:()=>Y({inputAmount:c,fromToken:s,toToken:l,liquiditySources:M,excludeLiquiditySources:E,disabledLiquiditySources:x,slippage:U,affiliateRef:v,affiliatePercent:T,affiliateWallets:w}),loading:I}}i(Ei,"useSwapInput");function Gf(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(Gf,"emitPreventableEvent");var Zw=Kw("div",{display:"flex",alignItems:"flex-start",maxHeight:700,"& .footer__alert":{paddingTop:"0 !important"}}),Jw=300;function Xf(){let t=Yw(),{fromToken:e,toToken:o,inputAmount:n,selectedQuote:r,refetchQuote:a,error:s,warning:l,quotes:c,setSelectedQuote:u,resetQuoteWallets:p,setQuoteWarningsConfirmed:m,updateQuotePartialState:h}=O(),[d,f]=jf(!1),{isLargeScreen:g,isExtraLargeScreen:C}=ai(),{fetch:S,loading:k}=Ei({refetchQuote:a}),{config:T,fetchStatus:v,connectedWallets:w}=y(),{isActiveTab:A}=re(),[M,x]=jf(!1),b=tu({fetchMetaStatus:v,fetchingQuote:k,inputAmount:n,quote:r,anyWalletConnected:w.length>0,error:s,warning:l,needsToWarnEthOnPath:!1}),I=Vc(g,C,T?.variant),W=!!n&&!!e&&!!o&&new Xw(n).gt(0)&&!mu(e,o),B=W&&v==="success"&&k,R=(!I||I&&c?.results.length)&&(l||s);Kf(()=>{p(),h("refetchQuote",!0)},[]),Kf(()=>{f(W)},[W]);let P=(r||s)&&!M?S:void 0,Y=i(Q=>{I&&d?(f(!1),setTimeout(()=>{t(Q)},Jw)):t(Q)},"onHandleNavigation"),se=i(Q=>{r?.requestId!==Q.requestId&&(x(!1),u(Q))},"onClickOnQuote");return He.createElement(Zw,null,He.createElement(oe,{height:"auto",footer:He.createElement(Vw,{id:`widget-swap-${b.action}-btn`,type:"primary",size:"large",disabled:b.disabled||!A,prefix:b.action==="confirm-warning"&&He.createElement(jw,null),fullWidth:!0,onClick:()=>{b.action==="connect-wallet"?Gf({type:"clickConnectWallet"},()=>Y($.wallets)):b.action==="confirm-warning"?x(!0):Y($.confirmSwap)}},b.title),header:{onWallet:()=>{Y($.wallets)},hasBackButton:!1,title:T.title||Gw.t("Swap"),suffix:He.createElement(fo,{hidden:I?["refresh"]:void 0,onClickRefresh:P,onClickHistory:()=>Y($.swaps),onClickSettings:()=>{Y($.settings)}})}},He.createElement(ie,null,He.createElement(yl,{fetchingQuote:B,fetchMetaStatus:v,isExpandable:I,onClickToken:Q=>{Y(Q==="from"?$.fromSwap:$.toSwap)}}),He.createElement(Vf,{size:"2"}),I?null:He.createElement(So,{quote:r,loading:B,error:s,tagHidden:!1,warning:l,type:"basic",onClickAllRoutes:c&&c.results.length>1?()=>{h("refetchQuote",!1),Y($.routes)}:void 0}),R?He.createElement(He.Fragment,null,He.createElement(Vf,{size:"10"}),He.createElement(An,{warning:l,error:s,couldChangeSettings:!0,refetchQuote:S,showWarningModal:M,confirmationDisabled:!A,onOpenWarningModal:()=>x(!0),onCloseWarningModal:()=>x(!1),onConfirmWarningModal:()=>{x(!1),m(!0),Y($.confirmSwap)},onChangeSettings:()=>Y($.settings)})):null,He.createElement(pl,null))),I?He.createElement(dl,{loading:B,onClickOnQuote:se,fetch:S,onClickRefresh:P,isVisible:d}):null)}i(Xf,"Home");import{i18n as Yf}from"@lingui/core";import{Alert as Rw,Divider as eb,List as tb,ListItemButton as ob,Radio as nb,RadioRoot as rb,Typography as ib}from"@rango-dev/ui";import Wt from"react";function Rt(){let{setLanguage:t,language:e,config:o}=y(),n=Zc,r=o?.language||Wo;return{activeLanguage:e||r,languages:n,defaultLanguage:r,changeLanguage:a=>t(a||Wo),resetLanguage:()=>t(null)}}i(Rt,"useLanguage");function Zf(){let{activeLanguage:t,changeLanguage:e,languages:o}=Rt(),n=je(),r=o.map(a=>{let{local:s,label:l,SVGFlag:c}=a;return{id:`widget-setting-languages-${s}-item-btn`,value:s,title:Wt.createElement(ib,{variant:"title",size:"xmedium"},l),onClick:()=>{e(a.local),n()},end:Wt.createElement(nb,{value:s}),start:Wt.createElement(c,null)}});return Wt.createElement(oe,{header:{title:Yf.t("Language")}},Wt.createElement(ie,null,Wt.createElement(Rw,{type:"warning",variant:"alarm",title:"Warning: We are using machine translation, so the translations may be inaccurate."}),Wt.createElement(eb,{size:"8"}),Wt.createElement(rb,{value:t},Wt.createElement(tb,{type:Wt.createElement(ob,{title:Yf.t("language"),id:"_",onClick:()=>console.log()}),items:r}))))}i(Zf,"LanguagePage");import{i18n as zt}from"@lingui/core";import{Button as pb,Checkbox as ub,Image as mb,ListItemButton as db,NotFound as fb,Typography as gb}from"@rango-dev/ui";import Ge,{useState as hb}from"react";import{Checkbox as lb,Skeleton as Rf}from"@rango-dev/ui";import jn from"react";import{styled as Sl}from"@rango-dev/ui";var Kn=Sl("ul",{padding:"$15 $5 0",margin:0,listStyle:"none",height:"100%",overflowY:"auto",variants:{disabled:{true:{pointerEvents:"none"}}}}),Cl=Sl("div",{width:80,display:"flex",justifyContent:"flex-end"}),kl=Sl("div",{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%"});import{ListItem as ab,styled as sb}from"@rango-dev/ui";var Jf=sb(ab,{height:61});var cb=30;function Tl(){return jn.createElement(Kn,null,Array.from(Array(cb),(t,e)=>jn.createElement(Jf,{hasDivider:!0,key:e,start:jn.createElement(Rf,{variant:"circular",width:35,height:35}),title:jn.createElement(Rf,{variant:"text",size:"large",width:90}),end:jn.createElement(lb,{checked:!1})})))}i(Tl,"LoadingLiquiditySourceList");function vl({sourceType:t}){let e=y().fetchStatus,o=y().swappers(),n=y().getDisabledLiquiditySources(),[r,a]=hb(""),s=y().toggleLiquiditySource,l=y().isInCampaignMode(),c=Cr(o,n),u={Exchanges:zt.t("Exchanges"),Bridges:zt.t("Bridges")},p=[];t==="Exchanges"&&p.push("DEX"),t==="Bridges"&&p.push("BRIDGE","AGGREGATOR","OFF_CHAIN");let m=c.filter(S=>p.includes(S.type)),h=m.length===m.filter(S=>S.selected).length,d=i(()=>{m.forEach(S=>{h?s(S.groupTitle):S.selected||s(S.groupTitle)})},"toggleAllSources"),f=m.map(S=>{let{selected:k,groupTitle:T,logo:v,id:w,...A}=S;return{id:`widget-setting-liquidity-source-${w.toLowerCase().replace(/\s+/g,"-")}-item-btn`,start:Ge.createElement(mb,{src:v,size:22,type:"circular"}),onClick:()=>{l||s(T)},end:Ge.createElement(ub,{checked:k,disabled:l}),title:Ge.createElement(gb,{variant:"title",size:"xmedium"},zt.t(T)),selected:k,groupTitle:T,logo:v,...A}}),g=i(S=>{let k=S.target.value;a(k)},"handleSearch"),C=f;return r&&(C=f.filter(S=>wt(S.groupTitle,r))),Ge.createElement(oe,{header:{title:zt.t(t),suffix:Ge.createElement(Cl,null,Ge.createElement(pb,{id:`widget-liquidity-source-${h?"deselect-all":"select-all"}-btn`,variant:"ghost",size:"xsmall",onClick:d},h?zt.t("Deselect all"):zt.t("Select all")))}},Ge.createElement(ie,{view:!0},Ge.createElement(Ct,{value:r,setValue:a,fullWidth:!0,color:"light",variant:"contained",placeholder:zt.t("Search {sourceType}",{sourceType:u[t]}),onChange:g}),e==="loading"&&Ge.createElement(Tl,null),!C.length&&r?Ge.createElement(kl,null,Ge.createElement(fb,{title:zt.t("No results found"),description:zt.t("Try using different keywords")})):e==="success"&&Ge.createElement(Kn,{disabled:l},C.map(S=>{let{groupTitle:k,...T}=S;return Ge.createElement(Ge.Fragment,{key:S.id},Ge.createElement(db,{style:{height:"61px"},...T,selected:!1,hasDivider:!0}))}))))}i(vl,"LiquiditySourcePage");import{i18n as yb}from"@lingui/core";import Ii from"react";import{useNavigate as Sb}from"react-router-dom";function eg(){let t=Sb(),e=je(),{selectedQuote:o,refetchQuote:n,setSelectedQuote:r,updateQuotePartialState:a,error:s}=O(),{fetch:l,loading:c}=Ei({refetchQuote:n}),u=i(h=>{r(h),a("refetchQuote",!1),e()},"onClickOnQuote"),p=`../${$.settings}`,m=`../${$.wallets}`;return Ii.createElement(oe,{header:{onWallet:()=>{t(m),a("refetchQuote",!0)},onBack:()=>{a("refetchQuote",!1)},title:yb.t("Routes"),suffix:Ii.createElement(fo,{onClickRefresh:o||s?l:void 0,hidden:["notifications","history"],onClickSettings:()=>{t(p),a("refetchQuote",!0)}})}},Ii.createElement(ie,null,Ii.createElement(Gn,{fetch:l,loading:c,onClickOnQuote:u})))}i(eg,"RoutesPage");import{i18n as sg}from"@lingui/core";import{Divider as lg,getCategoriesCount as Ab,SelectableCategoryList as Nb}from"@rango-dev/ui";import Qt,{useState as cg}from"react";import{useNavigate as Wb}from"react-router-dom";import{i18n as wl}from"@lingui/core";import{Divider as vb,Image as wb,ListItemButton as bb,NotFound as xb,Typography as ag}from"@rango-dev/ui";import nt,{useEffect as Eb,useState as Ib}from"react";var tg=i((t,e,o)=>t.filter(n=>pr(n.type,o)).filter(n=>Je(n.name,e)||Je(n.displayName,e)),"filterBlockchains");import{ImageContainer as Cb,styled as og}from"@rango-dev/ui";var ng=og("div",{display:"flex",flexDirection:"column",overflow:"hidden",height:"100%",justifyContent:"center"}),Ai=og(vn,{padding:0,margin:0,listStyle:"none",[`& ${Cb}`]:{borderRadius:"$xm",overflow:"hidden"}});import{ListItem as kb,Skeleton as rg}from"@rango-dev/ui";import Ni from"react";var Tb=20;function ig(){return Ni.createElement(Ai,null,Array.from(Array(Tb),t=>Ni.createElement(kb,{key:t,hasDivider:!0,start:Ni.createElement(rg,{variant:"circular",width:35,height:35}),title:Ni.createElement(rg,{variant:"text",size:"large",width:90})})))}i(ig,"LoadingBlockchainList");function bl(t){let{list:e,searchedFor:o,onChange:n,blockchainCategory:r,showTitle:a=!0}=t,[s,l]=Ib(e),{fetchStatus:c}=y();Eb(()=>{l([...tg(e,o,r)])},[e,o,r]);let u=i(()=>!s.length&&o?nt.createElement(xb,{title:wl.t("No results found"),description:wl.t("Try using different keywords")}):nt.createElement(Ai,{as:"ul",key:`${r}-${o}`},s.map(p=>nt.createElement(bb,{key:`${p.name}-${p.chainId}`,className:"widget-blockchain-list-item-btn",hasDivider:!0,onClick:()=>n(p),start:nt.createElement(wb,{src:p.logo,size:30}),title:nt.createElement(ag,{variant:"title",size:"medium"},p.displayName),id:p.name}))),"renderList");return nt.createElement(nt.Fragment,null,a&&nt.createElement(nt.Fragment,null,nt.createElement(ag,{variant:"label",size:"large"},wl.t("Select Chain")),nt.createElement(vb,{size:4})),nt.createElement(ng,null,c==="loading"&&nt.createElement(ig,null),c==="success"&&u()))}i(bl,"BlockchainList");function Wi(t){let{type:e}=t,o=je(),[n,r]=cg(""),[a,s]=cg("ALL"),l=O.use.setToBlockchain(),c=O.use.setFromBlockchain(),{fetchStatus:u}=y(),p=Wb(),m=y().blockchains({type:e}),h=Ab(m),d=!t.hideCategory&&h!==1;return Qt.createElement(oe,{header:{title:sg.t("Select Chain")}},Qt.createElement(ie,{view:!0},d&&Qt.createElement(Qt.Fragment,null,Qt.createElement(Nb,{setCategory:s,category:a,blockchains:m,isLoading:u==="loading"}),Qt.createElement(lg,{size:24})),Qt.createElement(Ct,{value:n,autoFocus:!0,placeholder:sg.t("Search Chain"),color:"light",variant:"contained",size:"large",setValue:()=>r(""),onChange:f=>r(f.target.value)}),Qt.createElement(lg,{size:16}),Qt.createElement(bl,{list:m,showTitle:e!=="custom-token",searchedFor:n,blockchainCategory:a,onChange:f=>{e==="custom-token"?p(`..?blockchain=${f.name}`,{replace:!0}):(e==="source"?c(f):l(f),o())}})))}i(Wi,"SelectBlockchainPage");import{i18n as Mi}from"@lingui/core";import{Divider as gg}from"@rango-dev/ui";import vo,{useState as Fb}from"react";import{useNavigate as Ob}from"react-router-dom";import{i18n as Il}from"@lingui/core";import{BlockchainsChip as Bi,Divider as dg,Image as fg,Skeleton as _b,Tooltip as Db,Typography as Al}from"@rango-dev/ui";import Pe from"react";import{useEffect as Lb}from"react";var pg=["ETH","COSMOS","OSMOSIS"];function xl(t,e,o){let n=JSON.parse(JSON.stringify(t)),r=[];if(n.sort(Bb),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 u=n[c];s=s.filter(p=>u.name!==p)}}n.sort(Mb(s)),r=n.splice(a)}return{list:n,more:r}}i(xl,"prepare");function Bb(t,e){let o=pg,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(Bb,"sortByMostUsedBlockchains");function Mb(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(Mb,"generateSortByPreferredBlockchainsFor");function ug(t,e){return!!e.list.find(o=>o.name===t)}i(ug,"isInVisibleList");function El(t,e){let{preferredBlockchains:o,addPreferredBlockchain:n}=y();Lb(()=>{if(e?.selected){let a=xl(t,o,e);ug(e.selected,a)||n(e?.selected)}},[e?.selected]);let r=xl(t,o,e);return{list:r.list,more:r.more,history:[]}}i(El,"usePrepareBlockchainList");import{styled as Pb}from"@rango-dev/ui";var mg=Pb("div",{display:"grid",gap:"$10",gridTemplateColumns:"repeat(6, minmax(0, 1fr))"});var $b=12;function Nl(t){let{blockchains:e,type:o,blockchain:n,onChange:r,onMoreClick:a}=t,s=El(e,{limit:10,selected:n?.name}),{fetchStatus:l}=y(),c=O.use.resetToBlockchain(),u=O.use.resetFromBlockchain(),p=s.more.length>0,m=s.more.length===1,h=!m&&p;return Pe.createElement(Pe.Fragment,null,Pe.createElement(dg,{size:12}),Pe.createElement(Al,{variant:"label",size:"large"},Il.t("Select Chain")),Pe.createElement(dg,{size:12}),Pe.createElement(mg,null,l==="loading"&&Array.from(Array($b),d=>Pe.createElement(_b,{key:d,variant:"rounded",height:50})),l==="success"&&Pe.createElement(Pe.Fragment,null,Pe.createElement(Bi,{selected:!n,onClick:()=>{o==="from"?u():c()}},Pe.createElement(Al,{variant:"body",size:"xsmall",color:"secondary500"},Il.t("All"))),s.list.map(d=>Pe.createElement(Db,{key:d.name,content:d.shortName,side:"bottom",sideOffset:2,container:N()},Pe.createElement(Bi,{key:d.name,selected:!!n&&n.name===d.name,onClick:()=>r(d)},Pe.createElement(fg,{src:d.logo,size:30})))),m?Pe.createElement(Bi,{key:s.more[0].name,selected:!!n&&n.name===s.more[0].name,onClick:()=>r(s.more[0])},Pe.createElement(fg,{src:s.more[0].logo,size:30})):null,h?Pe.createElement(Bi,{onClick:a,key:"more-blockchains"},Pe.createElement(Al,{variant:"body",size:"xsmall",color:"secondary500"},Il._("More +{count}",{count:s.more.length}))):null)))}i(Nl,"BlockchainsSection");function Wl(t){let{type:e}=t,o=Ob(),n=je(),{fromBlockchain:r,toBlockchain:a,setFromToken:s,setToToken:l,setFromBlockchain:c,setToBlockchain:u}=O(),{getBalanceFor:p}=y(),[m,h]=Fb(""),f=(e==="source"?r:a)?.name??"",g=y().blockchains({type:e}),C=y().tokens({type:e,blockchain:f,searchFor:m,getBalanceFor:p}),S=i(v=>{e==="source"?c(v):u(v)},"updateBlockchain"),k=i(v=>{e==="source"?s({token:v,meta:{blockchains:g,tokens:C}}):l({token:v,meta:{blockchains:g,tokens:C}})},"updateToken"),T={source:Mi.t("Source"),destination:Mi.t("Destination")};return vo.createElement(oe,{header:{title:Mi.t("Swap {type}",{type:T[e]})}},vo.createElement(ie,null,vo.createElement(Nl,{blockchains:g,type:e=="source"?"from":"to",blockchain:e==="source"?r:a,onMoreClick:()=>o($.blockchains),onChange:v=>{S(v)}}),vo.createElement(gg,{size:24}),vo.createElement(Ct,{value:m,autoFocus:!0,placeholder:Mi.t("Search Token"),color:"light",variant:"contained",size:"large",setValue:()=>h(""),onChange:v=>h(v.target.value)}),vo.createElement(gg,{size:16}),vo.createElement(On,{list:C,selectedBlockchain:f,searchedFor:m,type:e,onChange:v=>{k(v);let w=g.find(A=>v.blockchain===A.name);w&&S(w),n()}})))}i(Wl,"SelectSwapItemsPage");import{i18n as Ll}from"@lingui/core";import{Alert as ux,Button as mx,styled as dx}from"@rango-dev/ui";import wo from"react";import{useInRouterContext as fx,useSearchParams as gx}from"react-router-dom";import{i18n as Tg}from"@lingui/core";import{Divider as vg,InfoIcon as qb,SlippageIcon as Hb,TextField as Gb,Tooltip as Vb,Typography as wg}from"@rango-dev/ui";import rt from"react";import{Chip as Ub,styled as Xn,TextField as zb}from"@rango-dev/ui";var hg=Xn("div",{paddingTop:"$5",padding:"$10 $5"}),yg=Xn("div",{display:"flex",flexWrap:"wrap",gap:"$10",[`& ${zb}`]:{flex:"1 1 0",maxWidth:"127px",minWidth:"85px"}}),Sg=Xn("div",{display:"flex",justifyContent:"start",alignItems:"center",paddingBottom:"$10"}),Li=Xn("div",{maxWidth:"280px",padding:"$10"}),Cg=Xn(Ub,{width:"61px",flexShrink:0});import{i18n as Bl}from"@lingui/core";import{Typography as Qb}from"@rango-dev/ui";import Yn from"react";function kg(){return Yn.createElement(Li,null,Yn.createElement(Qb,{variant:"label",size:"medium",color:"neutral700"},Bl.t("Your transaction will be reverted if the price changes unfavorably by more than this percentage."),Yn.createElement("br",null),Yn.createElement("br",null),Yn.createElement("b",null,Bl.t("Warning")),":\xA0",Bl.t("This setting is applied to each step (e.g. 1Inch, Thorchain, etc.), meaning only that specific step will be reverted, not the entire route.")))}i(kg,"SlippageTooltipContent");function Ml(){let{slippage:t,setSlippage:e,customSlippage:o,setCustomSlippage:n}=y();return rt.createElement(hg,null,rt.createElement(Sg,null,rt.createElement(Hb,{size:16,color:"gray"}),rt.createElement(vg,{direction:"horizontal",size:4}),rt.createElement(wg,{variant:"title",size:"xmedium"},Tg.t("Slippage tolerance per swap")),rt.createElement(vg,{direction:"horizontal",size:4}),rt.createElement(Vb,{container:N(),side:"top",sideOffset:4,content:rt.createElement(kg,null)},rt.createElement(qb,{color:"gray"}))),rt.createElement(yg,null,Jc.map((r,a)=>{let s=`slippage-${a}`;return rt.createElement(Cg,{key:s,onClick:()=>{o&&n(null),e(r)},selected:!o&&r===t,label:`${r.toString()}%`})}),rt.createElement(Gb,{type:"number",min:"0.01",max:"30",step:"0.01",fullWidth:!0,variant:"contained",value:o===null?"":o,color:"dark",onChange:r=>{let a=r.target.value,s=parseFloat(a);s>=op&&s<=tp?n(s):n(null)},suffix:o&&rt.createElement(wg,{variant:"body",size:"small"},"%"),placeholder:Tg.t("Custom")})))}i(Ml,"Slippage");import{i18n as mt}from"@lingui/core";import{AutoThemeIcon as bg,BridgesIcon as Kb,ChevronRightIcon as Pi,DarkModeIcon as xg,Divider as Zn,ExchangeIcon as jb,InfinityIcon as Xb,InfoIcon as Yb,LanguageIcon as Zb,LightModeIcon as Eg,List as Jb,ListItem as Rb,ListItemButton as ex,Skeleton as tx,styled as ox,Switch as nx,Tabs as rx,TargetIcon as ix,Tooltip as ax,Typography as Ye}from"@rango-dev/ui";import D from"react";import{useNavigate as sx}from"react-router-dom";var lx=ox("div",{width:"202px",height:"$40"}),cx=[{id:"light",icon:D.createElement(Eg,{color:"black",size:24}),tooltip:D.createElement(Ye,{size:"xsmall",variant:"body"},mt.t("Light"))},{id:"dark",icon:D.createElement(xg,{color:"black",size:24}),tooltip:D.createElement(Ye,{size:"xsmall",variant:"body"},mt.t("Dark"))},{id:"auto",icon:D.createElement(bg,{color:"black",size:24}),tooltip:D.createElement(Ye,{size:"xsmall",variant:"body"},mt.t("Auto"))}],px=i(t=>{let e={color:"gray",size:16};switch(t){case"auto":return D.createElement(bg,{...e});case"dark":return D.createElement(xg,{...e});default:return D.createElement(Eg,{...e})}},"getThemeIcon");function Ig(){let t=sx(),{theme:e}=y().config,{setTheme:o,theme:n}=y(),{activeLanguage:r,languages:a}=Rt(),s=a.find(P=>P.local===r)?.label,l=y().fetchStatus,c=y().swappers(),u=y().getDisabledLiquiditySources(),{config:{features:p}}=y(),m=y().customTokens(),h=Ve("theme",p),d=Ve("liquiditySource",p),f=Ve("language",p),g=Ve("customTokens",p),C=y().infiniteApprove,S=y().toggleInfiniteApprove,k=Cr(c,u),T=k.filter(P=>["BRIDGE","AGGREGATOR","OFF_CHAIN"].includes(P.type)),v=T.length,w=T.filter(P=>P.selected).length,A=k.filter(P=>P.type==="DEX"),M=A.length,x=A.filter(P=>P.selected).length,E=i((P,Y)=>{switch(l){case"loading":return D.createElement(tx,{variant:"text",size:"medium",width:50});case"failed":return D.createElement(Ye,{variant:"body",size:"medium",color:"$error500"},mt.t("Loading failed"));default:return D.createElement(Ye,{variant:"body",size:"medium"},`${P} / ${Y}`)}},"handleSwapperEndItem"),b={id:"widget-setting-bridge-item-btn",title:D.createElement(Ye,{variant:"title",size:"xmedium"},mt.t("Bridges")),end:D.createElement(D.Fragment,null,E(w,v),D.createElement(Zn,{direction:"horizontal",size:8}),D.createElement(Pi,{color:"black"})),onClick:()=>t($.bridges),start:D.createElement(Kb,{color:"gray",size:16})},I={id:"widget-setting-exchange-item-btn",title:D.createElement(Ye,{variant:"title",size:"xmedium"},mt.t("Exchanges")),end:D.createElement(D.Fragment,null,E(x,M),D.createElement(Zn,{direction:"horizontal",size:8}),D.createElement(Pi,{color:"black"})),start:D.createElement(jb,{color:"gray",size:16}),onClick:()=>t($.exchanges)},W={id:"widget-setting-custom-tokens-item-btn",title:D.createElement(Ye,{variant:"title",size:"xmedium"},mt.t("Custom Tokens")),end:D.createElement(D.Fragment,null,D.createElement(Ye,{variant:"body",size:"medium"},`${m.length}`),D.createElement(Zn,{direction:"horizontal",size:8}),D.createElement(Pi,{color:"black"})),start:D.createElement(ix,{color:"gray",size:16}),onClick:()=>t($.customTokens)},B={id:"widget-setting-language-item-btn",title:D.createElement(Ye,{variant:"title",size:"xmedium"},mt.t("Language")),start:D.createElement(Zb,{color:"gray",size:16}),end:D.createElement(D.Fragment,null,D.createElement(Ye,{variant:"body",size:"medium"},s),D.createElement(Zn,{direction:"horizontal",size:8}),D.createElement(Pi,{color:"black"})),onClick:()=>t($.languages)},U={id:"widget-setting-infinite-approval-item-btn",title:D.createElement(D.Fragment,null,D.createElement(Ye,{variant:"title",size:"xmedium"},mt.t("Infinite approval")),D.createElement(Zn,{direction:"horizontal",size:4}),D.createElement(ax,{side:"top",sideOffset:4,container:N(),content:D.createElement(Li,null,D.createElement(Ye,{variant:"label",size:"medium",color:"neutral700"},D.createElement("b",null,mt.t("Warning")),":\xA0",mt.t("Enabling the 'Infinite approval' mode grants unrestricted access to underlying smart contracts, allowing them to utilize the approved token amount without limitations.")))},D.createElement(Yb,{color:"gray"}))),start:D.createElement(Xb,{color:"gray",size:16}),end:D.createElement(nx,{checked:C}),onClick:S},j={id:"widget-setting-theme-item-btn",type:D.createElement(Rb,null),title:D.createElement(Ye,{variant:"title",size:"xmedium"},mt.t("Theme")),end:D.createElement(lx,null,D.createElement(rx,{container:N(),items:cx,value:n,onChange:P=>o(P.id),type:"primary",borderRadius:"small"})),start:px(n)},R=d?[]:[b,I];return g||R.push(W),f||R.push(B),R.push(U),!e?.singleTheme&&!h&&R.push(j),D.createElement(Jb,{type:D.createElement(ex,{hasDivider:!0,id:"_",onClick:()=>console.log()}),items:R})}i(Ig,"SettingsLists");var hx=dx("div",{paddingLeft:"$8"});function Ag(){let{isInCampaignMode:t,updateCampaignMode:e}=y(),o=t(),[,n]=gx(),r=fx(),a=i(()=>{r&&o&&(n(s=>(s.delete("liquiditySources"),s),{replace:!0}),e("liquiditySources",void 0))},"onClick");return wo.createElement(oe,{header:{title:Ll.t("Settings")}},wo.createElement(ie,null,o&&wo.createElement(ux,{type:"info",variant:"alarm",title:Ll.t("Currently, you're in campaign mode with restrictions on liquidity sources. Would you like to switch out of this mode and make use of all available liquidity sources?"),action:wo.createElement(hx,null,wo.createElement(mx,{id:"widget-setting-exit-campaign-mode-btn",type:"secondary",size:"small",onClick:a},Ll.t("Reset")))}),wo.createElement(Ml,null),wo.createElement(Ig,null)))}i(Ag,"SettingsPage");import{i18n as nE}from"@lingui/core";import{cancelSwap as rE}from"@rango-dev/queue-manager-rango-preset";import{useManager as iE}from"@rango-dev/queue-manager-react";import{Alert as aE}from"@rango-dev/ui";import Xl from"react";import{useParams as sE}from"react-router-dom";import{i18n as it}from"@lingui/core";import{getCurrentNamespaceOfOrNull as Fx,getCurrentStep as Ox,getRelatedWalletOrNull as Ux}from"@rango-dev/queue-manager-rango-preset";import{Button as ah,CopyIcon as zx,Divider as Qx,DoneIcon as qx,IconButton as Hx,QuoteCost as Gx,RangoExplorerIcon as Vx,StepDetails as Kx,Tooltip as sh,Typography as bo,useCopyToClipboard as jx}from"@rango-dev/ui";import{useWallets as Xx}from"@rango-dev/wallets-react";import lh from"bignumber.js";import{PendingSwapNetworkStatus as Qi}from"rango-types";import X,{useEffect as ch,useRef as Yx,useState as ph}from"react";import{useNavigate as Zx}from"react-router-dom";import{i18n as eo}from"@lingui/core";var yx=[eo.t("Sunday"),eo.t("Monday"),eo.t("Tuesday"),eo.t("Wednesday"),eo.t("Thursday"),eo.t("Friday"),eo.t("Saturday")];function Ng(t){let e=new Date(t),o=e.getDate(),n=e.toLocaleString("default",{month:"long"}),r=e.getFullYear();return`${e.getDay()===new Date().getDay()?eo.t("Today"):`${yx[e.getDay()]} ${o} ${n} ${r}`}, ${new Date(t).toLocaleTimeString()}`}i(Ng,"timeSince");function Wg(t){return t.finishTime?Ng(parseInt(t.finishTime)):Ng(parseInt(t.creationTime))}i(Wg,"getSwapDate");import{PendingSwapNetworkStatus as $i}from"rango-types";import Fi from"react";import{i18n as _i}from"@lingui/core";import{Button as Bg,Divider as Pl,MessageBox as Sx}from"@rango-dev/ui";import to from"react";var Mg=i(({onCancel:t,onClose:e})=>to.createElement(to.Fragment,null,to.createElement(Pl,{size:20}),to.createElement(Sx,{type:"error",title:_i.t("Cancel Swap"),description:_i.t("Are you sure you want to cancel this swap?")}),to.createElement(Pl,{size:32}),to.createElement(Bg,{variant:"contained",id:"widget-swap-details-modal-cancel-swap-yes-btn",type:"primary",size:"large",onClick:t},_i.t("Yes, Cancel it")),to.createElement(Pl,{size:12}),to.createElement(Bg,{id:"widget-swap-details-modal-cancel-swap-no-btn",variant:"outlined",type:"primary",size:"large",onClick:e},_i.t("No, Continue"))),"CancelContent");import{i18n as Di}from"@lingui/core";import{Button as Lg,Divider as _l,MessageBox as Cx,Typography as kx}from"@rango-dev/ui";import qt from"react";var Pg=i(({onDelete:t,onClose:e})=>qt.createElement(qt.Fragment,null,qt.createElement(_l,{size:20}),qt.createElement(Cx,{type:"error",title:Di.t("Delete Transaction"),description:Di.t("Are you sure you want to delete this swap?")}),qt.createElement(_l,{size:32}),qt.createElement(Lg,{id:"widget-swap-details-modal-delete-swap-yes-btn",variant:"contained",type:"primary",size:"large",onClick:t},Di.t("Yes, Delete it")),qt.createElement(_l,{size:12}),qt.createElement(Lg,{id:"widget-swap-details-modal-delete-swap-no-btn",variant:"outlined",type:"primary",size:"large",onClick:e},qt.createElement(kx,{variant:"title",size:"medium",color:"primary"},Di.t("No, Cancel")))),"DeleteContent");import{i18n as Dl}from"@lingui/core";import{PendingSwapNetworkStatus as $l}from"rango-types";var Fl={[$l.WaitingForNetworkChange]:{type:"loading",title:Dl.t("Change Network")},[$l.WaitingForConnectingWallet]:{type:"warning",title:Dl.t("Connect Wallet")},[$l.NetworkChanged]:{type:"success",title:Dl.t("Network Changed")}};import{warn as Tx}from"@rango-dev/logging-core";import{MessageBox as vx,Wallet as wx}from"@rango-dev/ui";import{useWallets as bx}from"@rango-dev/wallets-react";import Ro,{useState as xx}from"react";import{styled as _g}from"@rango-dev/ui";var Dg=_g("div",{display:"flex",justifyContent:"center"}),u5=_g("div",{maxWidth:280,"& ._typography":{wordWrap:"break-word",display:"block"}});var $g=i(t=>{let{type:e,title:o,currentStepWallet:n,message:r,showWalletButton:a,walletButtonDisabled:s}=t,[l,c]=xx(),{getWalletInfo:u,state:p}=bx(),m=n?.walletType,h=m?cn(p(m)):null,d=m?u(m):null,f=a&&!!m&&!!h&&!!d,{list:g}=ft(),C=i(()=>{if(m){let S=g.find(k=>k.type===m);S?c(S):Tx(new Error(`It seems requested wallet to be connected is not available in the list. requested wallet: ${S}`))}},"handleWalletItemClick");return Ro.createElement(Ro.Fragment,null,Ro.createElement(vx,{type:e,title:o,description:r}),f&&Ro.createElement(Dg,null,Ro.createElement(wx,{container:N(),title:d.name,image:d.img,type:m,state:h,link:d.installLink,disabled:s,onClick:C})),Ro.createElement(po,{wallet:l,onClose:()=>{c(void 0)}}))},"WalletStateContent");function Ol(t){let{state:e,onClose:o,onDelete:n,onCancel:r,currentStepWallet:a,message:s,walletButtonDisabled:l}=t,c=e===$i.WaitingForNetworkChange||e===$i.WaitingForConnectingWallet||e===$i.NetworkChanged;return Fi.createElement(J,{open:!!e,onClose:o,container:document.getElementById(De.SWAP_BOX_ID)||document.body},c&&Fi.createElement($g,{type:Fl[e].type,title:Fl[e].title,currentStepWallet:a,message:s,walletButtonDisabled:l,showWalletButton:e!==$i.WaitingForNetworkChange}),e==="delete"&&Fi.createElement(Pg,{onClose:o,onDelete:n}),e==="cancel"&&Fi.createElement(Mg,{onClose:o,onCancel:r}))}i(Ol,"SwapDetailsModal");import{i18n as Jn}from"@lingui/core";import{Button as Ul,Divider as Rn,MessageBox as Fg,TokenAmount as Ex,Typography as Og}from"@rango-dev/ui";import Ce from"react";import{useNavigate as Ix}from"react-router-dom";function zl(t){let{open:e,onClose:o,status:n,priceValue:r,usdValue:a,realUsdValue:s,realValue:l,token:c,chain:u,percentageChange:p,description:m,diagnosisUrl:h}=t,d=Ix(),{showProfileBanner:f}=re();return Ce.createElement(J,{open:e,onClose:o,container:document.getElementById(De.SWAP_BOX_ID)||document.body},n==="success"?Ce.createElement(Fg,{type:"success",title:Jn.t("Swap Successful")},Ce.createElement(Ex,{direction:"vertical",tooltipContainer:N(),type:"output",centerAlign:!0,price:{value:r,usdValue:a,realUsdValue:s,realValue:l},token:c,chain:u,percentageChange:p}),Ce.createElement(Rn,{size:12}),Ce.createElement(Og,{variant:"body",size:"medium",color:"neutral700",align:"center"},m)):Ce.createElement(Fg,{type:"error",title:Jn.t("Transaction Failed"),description:m}),Ce.createElement(Rn,{size:30}),n==="success"&&Ce.createElement(Ce.Fragment,null,f&&Ce.createElement(Ce.Fragment,null,Ce.createElement("img",{src:"https://raw.githubusercontent.com/rango-exchange/assets/main/banners/widget/profile.jpg",alt:"Profile Banner"}),Ce.createElement(Rn,{size:30})),Ce.createElement(Ul,{id:"widget-swap-details-modal-done-btn",variant:"contained",type:"primary",size:"large",onClick:()=>{d("../../")}},Jn.t("Done"))),Ce.createElement(Rn,{size:12}),h&&Ce.createElement(Ce.Fragment,null,Ce.createElement(Ul,{variant:"contained",id:"widget-swap-detail-modal-diagnosis-btn",type:"primary",size:"large",onClick:()=>window.open(h,"_blank")},Jn.t("Diagnosis")),Ce.createElement(Rn,{size:12})),Ce.createElement(Ul,{id:"widget-swap-details-modal-see-details-btn",variant:"outlined",type:"primary",size:"large",onClick:o},Ce.createElement(Og,{variant:"title",size:"medium",color:"primary"},Jn.t("See Details"))))}i(zl,"SwapDetailsCompleteModal");import $x from"react";import{i18n as Lx}from"@lingui/core";import{Alert as oh,IconButton as Px,LinkIcon as _x}from"@rango-dev/ui";import oo,{Fragment as Dx}from"react";import{Alert as Nx,ChevronDownIcon as Wx,IconButton as Bx}from"@rango-dev/ui";import tn,{useState as Mx}from"react";import{css as er,darkTheme as Ug,styled as Ht,Typography as Ax}from"@rango-dev/ui";var zg=Ht("div",{display:"flex",flexDirection:"column",flexGrow:1,overflow:"hidden"}),Oi=Ht("div",{width:"100%","& ._icon-button":{"&:hover":{"& svg":{color:"$secondary550",[`.${Ug} &`]:{color:"$secondary500"}}}}}),Qg=Ht(vn,{padding:"$0 $20 $20 $20"}),X5=Ht("div",{display:"flex",flexDirection:"column",gap:"$10"}),qg=Ht("div",{height:"450px",display:"flex",alignItems:"center",justifyContent:"center"}),Y5=Ht("div",{display:"flex",justifyContent:"center",width:"100%",paddingTop:"33%",flex:1}),en=er({display:"flex",width:"100%",justifyContent:"space-between",alignItems:"center",padding:"$10 $20",borderBottom:"1px solid",$$color:"$colors$neutral300",[`.${Ug} &`]:{$$color:"$colors$neutral400"},borderColor:"$$color",color:"$neutral500"}),Hg=er({padding:"$5 0"}),Ui=er({display:"flex",justifyContent:"center",alignItems:"center",height:"$24"}),Gg=er({display:"flex",width:"100%",padding:"$15 $20 $20",flexDirection:"column",alignItems:"start"}),Vg=er({width:"100%",padding:"0 $20 $10"}),Kg=Ht("a",{fontSize:"$16",fontWeight:"$400",color:"$neutral700",display:"flex",alignItems:"center",justifyContent:"center"}),jg=Ht("div",{display:"flex",flexDirection:"column",gap:"$5"}),zi=Ht(Ax,{wordBreak:"break-word"});import{styled as Ql}from"@rango-dev/ui";var Xg=Ql("div",{display:"flex",flexDirection:"column",gap:"$10"}),Yg=Ql("div",{transition:"transform 0.3s ease-in-out",variants:{rotated:{true:{transform:"rotate(180deg)"}}}}),Zg=Ql("div",{transition:"max-height 0.3s ease-in-out",maxHeight:"0px",overflow:"hidden",variants:{open:{true:{maxHeight:"200px"}}}});function Jg(t){let{message:e}=t,[o,n]=Mx(!1);return tn.createElement(Nx,{type:"error",title:e.shortMessage,containerStyles:{"& .footer":{paddingTop:"$0"}},action:e.detailedMessage.content&&tn.createElement(Bx,{onClick:()=>n(r=>!r),variant:"ghost",size:"xsmall"},tn.createElement(Yg,{rotated:o},tn.createElement(Wx,{size:12,color:"gray"}))),footer:tn.createElement(Zg,{open:o},tn.createElement(zi,{variant:"body",size:"xsmall",color:"neutral700"},e.detailedMessage.content))})}i(Jg,"FailedAlert");import{i18n as Rg}from"@lingui/core";import{Alert as ql,Button as eh}from"@rango-dev/ui";import{PendingSwapNetworkStatus as Hl}from"rango-types";import tr from"react";function th(t){let{switchNetwork:e,setNetworkModal:o,message:n,showNetworkModal:r}=t;return e?tr.createElement(ql,{type:"warning",title:n.shortMessage,action:tr.createElement(eh,{id:"widget-swap-details-warning-alert-change-network-btn",size:"xxsmall",type:"warning",onClick:()=>{o(Hl.WaitingForNetworkChange),e().catch(a=>{console.log(a)})}},Rg.t("Change"))}):r===Hl.WaitingForConnectingWallet?tr.createElement(ql,{type:"warning",title:n.shortMessage,action:tr.createElement(eh,{id:"widget-swap-details-warning-alert-connect-wallet-btn",size:"xxsmall",type:"warning",onClick:()=>{o(Hl.WaitingForConnectingWallet)}},Rg.t("Connect"))}):tr.createElement(ql,{type:"warning",title:n.shortMessage})}i(th,"WarningAlert");function Gl(t){let{switchNetwork:e,showNetworkModal:o,setNetworkModal:n,message:r,step:a,hasAlreadyProceededToSign:s}=t,l=kn(a),c=a.status==="waitingForApproval"&&!l,u=a.status==="running"&&!l,p=u&&!s||c&&!a.explorerUrl?.length;return oo.createElement(Xg,null,a.explorerUrl?.map((m,h,d)=>{let f=h+m.url,g=h===d.length-1,C=(g&&u||c)&&!p,S=g&&a.status==="failed";return oo.createElement(Dx,{key:f},oo.createElement(oh,{type:g&&(C&&"loading"||S&&"error")||"success",title:m.description?`${m.description} Tx`:Lx.t("View transaction"),action:m.url&&oo.createElement(Px,{id:"widget-swap-details-tx-link-icon-btn",variant:"ghost",size:"xsmall",onClick:()=>window.open(m.url,"_blank")},oo.createElement(_x,{size:12}))}))}),p&&oo.createElement(oh,{type:"loading",title:r.shortMessage}),a.status!=="failed"&&l&&oo.createElement(th,{switchNetwork:e,showNetworkModal:o,setNetworkModal:n,message:r}),a.status==="failed"&&oo.createElement(Jg,{message:r}))}i(Gl,"SwapDetailsAlerts");var nh=2e3;var rh=i(({swap:t,blockchains:e,swappers:o,...n})=>{let r=t.hasAlreadyProceededToSign!==!1;return t.steps.map((a,s)=>{let l=s===0?t.inputAmount:t.steps[s-1].outputAmount||t.steps[s-1].expectedOutputAmountHumanReadable;return{from:{token:{displayName:a.fromSymbol,image:a.fromLogo??""},chain:{displayName:st(a.fromBlockchain,e)??"",image:a.fromBlockchainLogo??""},price:{value:L(l,6,6),realValue:l??""}},to:{token:{displayName:a.toSymbol,image:a.toLogo},chain:{displayName:st(a.toBlockchain,e)??"",image:a.toBlockchainLogo??""},price:{value:L(a.outputAmount||a.expectedOutputAmountHumanReadable,6,6),realValue:a.outputAmount||a.expectedOutputAmountHumanReadable||""}},swapper:{displayName:nn(a.swapperId,o)??"",image:a.swapperLogo??"",type:a.swapperType},internalSwaps:a.internalSwaps?a.internalSwaps.map(c=>({from:{chain:{displayName:st(c.fromBlockchain,e)??"",image:c.fromBlockchainLogo??""}},to:{chain:{displayName:st(c.toBlockchain,e)??"",image:c.toBlockchainLogo??""}},swapper:{displayName:nn(c.swapperId,o)??"",image:c.swapperLogo??"",type:c.swapperType}})):[],alerts:$x.createElement(Gl,{step:a,hasAlreadyProceededToSign:r,...n})}})},"getSteps");function ih(t){if(kn(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(ih,"getStepState");function Vl(t){let{swap:e,requestId:o,onDelete:n,onCancel:r}=t,{canSwitchNetworkTo:a,connect:s,getWalletInfo:l}=Xx(),c=y().blockchains(),u=y().swappers(),{findToken:p}=y(),m=O.use.retry(),h=re.use.isActiveTab(),d=Zx(),[f,g]=jx(nh),C=Yx(null),[S,k]=ph(null),[T,v]=ph(null),w=i(()=>{r(),k(null)},"onCancel"),A=be.use.getNotifications(),M=be.use.removeNotification(),x=A(),E=Ox(e),b=E?.networkStatus;ch(()=>{x.find(dt=>dt.requestId===e.requestId)&&(e.status==="success"||e.status==="failed"?(v(e.status),M(e.requestId)):T&&v(null))},[e.status,e.requestId]),ch(()=>{P?k(Qi.WaitingForNetworkChange):b===Qi.WaitingForConnectingWallet||b===Qi.NetworkChanged?k(b):k(null)},[b]);let I=cu(e),W=E?Fx(e,E):null,B=E?Ux(e,E):null,U=Wg(e),j=pu(e),R=i(ve=>!!l(ve)?.mobileWallet,"isMobileWallet"),P=b===Qi.WaitingForNetworkChange&&!!W&&!!B?.walletType&&(R(B.walletType)||a(B.walletType,W.network)),Y=P?s.bind(null,B.walletType,[{namespace:W.namespace,network:W.network}]):void 0,se=lu(e,E),Q=rh({swap:e,switchNetwork:Y,showNetworkModal:b,setNetworkModal:k,message:se,blockchains:c,swappers:u}),de=Q.length,[vt,Ze]=[e.steps[0],e.steps[de-1]],le=Ze.outputAmount||Ze.expectedOutputAmountHumanReadable,at=e.steps.reduce((ve,dt)=>ve+parseFloat(dt.feeInUsd||""),0),V=e.steps.find(ve=>ve.diagnosisUrl)?.diagnosisUrl,_=L(parseFloat(le||"0")*(Ze.toUsdPrice||0),4,4),G=L(parseFloat(e.inputAmount)*(vt.fromUsdPrice||0),4,4),K=le?new lh(le).multipliedBy(Ze.toUsdPrice||0).toString():"",fe=new lh(e.inputAmount).multipliedBy(vt.fromUsdPrice||0).toString(),ne=Pt(G,_),ge=se.detailedMessage.content||se.shortMessage,Fe=e.status==="success"?it.t({id:"You have received {amount} {token} in {conciseAddress} wallet on {chain} chain.",values:{amount:L(le,6,6),token:Q[de-1].to.token.displayName,conciseAddress:yr(e.wallets[Q[de-1].to.chain.displayName]?.address||""),chain:Q[de-1].to.chain.displayName}}):X.createElement(jg,null,X.createElement(bo,{variant:"body",size:"medium",color:"neutral700",align:"center"},ge?"":it.t("Transaction was not sent."),I?`${it.t({id:"{amount} {symbol} on {blockchain} remains in your wallet.",values:{amount:I.outputAmount,symbol:I.symbol,blockchain:I.blockchain}})}`:""),ge&&X.createElement(zi,{align:"center",variant:"body",size:"medium",color:"neutral700"},X.createElement("b",null,"Reason:")," ",ge));return X.createElement(oe,{header:{title:it.t("Swap Details"),onCancel:e.status==="running"?()=>k("cancel"):void 0,suffix:e.status!=="running"&&X.createElement(Vt,null,X.createElement(ah,{id:"widget-swap-details-delete-btn",variant:"ghost",type:"error",size:"xsmall",onClick:()=>k("delete")},X.createElement(bo,{size:"medium",variant:"label",color:"error"},it.t("Delete"))))},footer:j&&!T&&X.createElement(ah,{fullWidth:!0,id:"widget-swap-details-try-again-btn",variant:"contained",type:"primary",size:"large",onClick:()=>{let ve=Wr(e,c,p);m(ve),setTimeout(()=>{d("../../")},0)}},it.t("Try again"))},X.createElement(ie,{compact:!0,view:!0},X.createElement(Oi,null,X.createElement("div",{className:en()},X.createElement(bo,{variant:"label",size:"large",color:"neutral700"},`${it.t("Request ID")}`),X.createElement("div",{className:Ui()},X.createElement(bo,{variant:"label",size:"small",color:"neutral700"},o),X.createElement(sh,{container:N(),content:f?it.t("Copied To Clipboard"):it.t("Copy Request ID"),open:f||void 0,side:"bottom",alignOffset:-16,align:"end"},X.createElement(Hx,{id:"widget-swap-details-done-copy-icon-btn",variant:"ghost",onClick:g.bind(null,o||"")},f?X.createElement(qx,{size:16,color:"secondary"}):X.createElement(zx,{size:16,color:"gray"}))),X.createElement(Kg,{target:"_blank",href:`${Cc}/swap/${o}`},X.createElement(sh,{container:N(),content:it.t("View on Rango Explorer"),side:"bottom"},X.createElement(Vx,{size:20}))))),X.createElement("div",{className:en()},X.createElement(bo,{variant:"label",size:"large",color:"neutral700"},e.finishTime?it.t("Finished at"):it.t("Created at")),X.createElement(bo,{variant:"label",size:"small",color:"neutral700"},U))),X.createElement("div",{className:Gg()},X.createElement(Gx,{fee:L(String(at),2,2),time:sn(ur(e.steps)),steps:de}),X.createElement(Wn,{from:{price:{value:L(e.inputAmount,6,6),usdValue:G,realUsdValue:fe,realValue:e.inputAmount},token:{displayName:Q[0].from.token.displayName,image:Q[0].from.token.image},chain:{image:Q[0].from.chain.image,displayName:Q[0].from.chain.displayName}},to:{price:{value:L(le,6,6),usdValue:_,realUsdValue:K,realValue:le||""},token:{displayName:Q[de-1].to.token.displayName,image:Q[de-1].to.token.image},chain:{image:Q[de-1].to.chain.image,displayName:Q[de-1].to.chain.displayName}},percentageChange:L(ne,2,2),warningLevel:_t(ne??0)})),X.createElement("div",{className:Vg()},X.createElement(bo,{variant:"title",size:"small"},it.t("Swaps steps"))),X.createElement(Qx,{size:8}),X.createElement(Qg,{ref:C},Q.map((ve,dt)=>{let oc=dt,on=ih(e.steps[dt]),Fh=on==="error"||on==="in-progress"||on==="warning"||on==="completed"&&dt===Q.length-1;return X.createElement(Kx,{key:oc,step:ve,type:"swap-progress",ref:C,state:on,hasSeparator:dt!==0,tabIndex:oc,isFocused:Fh,tooltipContainer:N()})}))),X.createElement(Ol,{state:S,onClose:()=>k(null),onCancel:w,onDelete:n,message:se.detailedMessage.content,currentStepWallet:B,walletButtonDisabled:!h}),X.createElement(zl,{open:!!T,diagnosisUrl:V,onClose:()=>v(null),status:e.status==="success"?"success":"failed",priceValue:L(le,6,6),usdValue:_,realUsdValue:K,realValue:le||"",percentageChange:L(ne,2,2),token:{displayName:Q[de-1].to.token.displayName,image:Q[de-1].to.token.image},chain:{image:Q[de-1].to.chain.image},description:Fe}))}i(Vl,"SwapDetails");import{i18n as Hi}from"@lingui/core";import{Divider as dh,NotFound as oE,Skeleton as nr,Typography as Gi}from"@rango-dev/ui";import ke from"react";import{i18n as Jx}from"@lingui/core";import{Divider as Rx,Skeleton as eE,Typography as tE}from"@rango-dev/ui";import Te from"react";import{css as Tt,styled as Kl}from"@rango-dev/ui";var uh=Kl("div",{width:"100%",height:"100%",padding:"$10 $20"}),or=Kl("div",{backgroundColor:"$neutral100",borderRadius:"$xm",padding:"$10 $15"}),qi=Kl("div",{width:"0px",height:"$20",borderLeft:"1px dashed $neutral700",marginLeft:"25px"}),lK=Tt({display:"flex",justifyContent:"space-between",alignItems:"center"}),cK=Tt({display:"flex",justifyContent:"space-between",alignItems:"center"}),pK=Tt({paddingTop:"$15",display:"flex"}),uK=Tt({padding:"$15 $0"}),mK=Tt({width:"0px",height:"$16",borderLeft:"1px solid $neutral400",marginLeft:"13px"}),dK=Tt({paddingBottom:"$10"}),fK=Tt({display:"flex",justifyContent:"start",alignItems:"center"}),gK=Tt({paddingTop:"$5",display:"flex",alignItems:"center"}),hK=Tt({display:"flex",alignItems:"center"}),yK=Tt({padding:"$4 $6",display:"flex",justifyContent:"center",alignItems:"center"}),mh=Tt({display:"flex",paddingTop:"$10",paddingBottom:"$5"});function jl(){return Te.createElement(uh,null,Te.createElement(Ln,{type:"swap-preview"}),Te.createElement("div",{className:"swaps-steps"},Te.createElement(tE,{variant:"title",size:"small"},Jx.t("Swaps steps"))),Te.createElement(Te.Fragment,null,Te.createElement(or,null,Te.createElement(Nt,{separator:!1}),Te.createElement("div",{className:mh()},Te.createElement(Rx,{direction:"horizontal",size:20}),Te.createElement(eE,{height:22,variant:"rectangular"}))),Te.createElement(qi,null),Te.createElement(or,null,Te.createElement(Nt,{separator:!1})),Te.createElement(qi,null),Te.createElement(or,null,Te.createElement(Nt,{separator:!1})),Te.createElement(qi,null),Te.createElement(or,null,Te.createElement(Nt,{separator:!1}))))}i(jl,"LoadingSwapDetails");function fh(t){let{requestId:e,showSkeleton:o}=t;return ke.createElement(oe,{header:{title:Hi.t("Swap Details"),suffix:ke.createElement(Vt,null)}},o&&ke.createElement(zg,null,ke.createElement(Oi,null,ke.createElement("div",{className:en()},ke.createElement(Gi,{variant:"label",size:"large",color:"neutral700"},`${Hi.t("Request ID")}`),ke.createElement("div",{className:Ui()},ke.createElement(Gi,{variant:"label",size:"small",color:"neutral700"},ke.createElement(nr,{width:60,height:10,variant:"rounded"})),ke.createElement(dh,{direction:"horizontal",size:4}),ke.createElement(nr,{width:16,height:16,variant:"rectangular"}),ke.createElement(dh,{direction:"horizontal",size:4}),ke.createElement(nr,{width:16,height:16,variant:"rectangular"}))),ke.createElement("div",{className:en()},ke.createElement(Gi,{className:Hg(),variant:"label",size:"large",color:"neutral700"},ke.createElement(nr,{width:60,height:10,variant:"rounded"})),ke.createElement(Gi,{variant:"label",size:"small",color:"neutral700"},ke.createElement(nr,{width:60,height:10,variant:"rounded"})))),ke.createElement(jl,null)),!o&&ke.createElement(qg,null,ke.createElement(oE,{title:Hi.t("Not found"),description:Hi.t({id:"Swap with request ID = {requestId} not found.",values:{requestId:e}})})))}i(fh,"SwapDetailsPlaceholder");function gh(){let{manager:t,state:e}=iE(),o=!e.loadedFromPersistor,n=pt(t),{requestId:r}=sE(),a=je(),{fetchStatus:s}=y();if(!r)return Xl.createElement(aE,{containerStyles:{margin:"20px"},type:"error",title:nE.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,u=i(()=>{if(c?.id){let h=t?.get(c.id);h&&rE(h)}},"onCancel"),p=i(async()=>{if(c?.id)try{t?.deleteQueue(c.id),a()}catch(h){console.log(h)}},"onDelete"),m=c?.swap;return!m||l?Xl.createElement(fh,{requestId:r,showSkeleton:l}):Xl.createElement(Vl,{swap:m,requestId:r,onCancel:u,onDelete:p})}i(gh,"SwapDetailsPage");import{i18n as hh}from"@lingui/core";import{Divider as lE,getCategoriesCount as cE,SelectableCategoryList as pE,styled as Sh,Typography as uE,Wallet as mE}from"@rango-dev/ui";import Bt,{useState as yh}from"react";var dE=Sh("div",{display:"flex",justifyContent:"center",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5"}),fE=Sh(ie,{textAlign:"center"});function Ch(){let{fetchStatus:t}=y(),[e,o]=yh("ALL"),n=y().blockchains(),{config:r}=y(),[a,s]=yh(),l=re.use.isActiveTab(),{list:c}=ft(),u=zc(c,n),m=cE(u)!==1,h=Qc(c,e),d=i(f=>{Wc(c,r.multiWallets)||s(f)},"handleWalletItemClick");return Bt.createElement(oe,{header:{title:hh.t("Connect Wallets")}},Bt.createElement(fE,null,m&&Bt.createElement(Bt.Fragment,null,Bt.createElement(pE,{setCategory:o,category:e,blockchains:u,isLoading:t==="loading"}),Bt.createElement(lE,{size:24})),Bt.createElement(uE,{variant:"title",size:"xmedium",align:"center"},hh.t("Choose a wallet to connect.")),Bt.createElement(dE,null,h.map((f,g)=>{let C=`wallet-${g}-${f.type}`;return Bt.createElement(mE,{key:C,...f,container:N(),onClick:()=>d(f),isLoading:t==="loading",disabled:!l})}),Bt.createElement(po,{wallet:a,onClose:()=>{s(void 0)}}))))}i(Ch,"WalletsPage");function kh(){return fu(),Da(),gE([{path:$.home,element:_e.createElement(Xf,null)},{path:$.routes,element:_e.createElement(eg,null)},{path:$.fromSwap,children:[{index:!0,element:_e.createElement(Wl,{type:"source"})},{path:$.blockchains,element:_e.createElement(Wi,{type:"source"})}]},{path:$.toSwap,children:[{index:!0,element:_e.createElement(Wl,{type:"destination"})},{path:$.blockchains,element:_e.createElement(Wi,{type:"destination"})}]},{path:$.settings,children:[{index:!0,element:_e.createElement(Ag,null)},{path:$.languages,element:_e.createElement(Zf,null)},{path:$.exchanges,element:_e.createElement(vl,{sourceType:"Exchanges"})},{path:$.bridges,element:_e.createElement(vl,{sourceType:"Bridges"})},{path:$.customTokens,children:[{index:!0,element:_e.createElement(rf,null)},{path:$.addCustomTokens,children:[{index:!0,element:_e.createElement(Xu,null)},{path:$.blockchains,element:_e.createElement(Wi,{hideCategory:!0,type:"custom-token"})}]}]}]},{path:$.swaps,children:[{index:!0,element:_e.createElement(xf,null)},{path:$.swapDetails,element:_e.createElement(gh,null)}]},{path:$.wallets,element:_e.createElement(Ch,null)},{path:$.confirmSwap,element:_e.createElement(Hd,null)}])}i(kh,"AppRoutes");import{useQueueManager as bE}from"@rango-dev/queue-manager-rango-preset";import{splitWalletNetwork as xE}from"@rango-dev/wallets-shared";import{isEvmBlockchain as EE}from"rango-sdk";import{useContext as IE,useEffect as Ih,useState as Ah}from"react";import{globalCss as hE}from"@rango-dev/ui";var Th=i(()=>hE({"@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}=re();return{fetchApiConfig:i(async()=>{let n=await fetch(`${Lt("BASE_URL")}/meta/dapp/config?apiKey=${Lt("API_KEY")}`);if(!n.ok)throw new Error(`Request failed with status: ${n.status} `);let r=await n.json();t(r.config.watermark),e(r.config.banners.profile)},"fetchApiConfig")}}i(vh,"useFetchApiConfig");import{useWallets as yE}from"@rango-dev/wallets-react";import{useEffect as SE,useRef as CE}from"react";function wh(){let{connect:t,state:e}=yE(),o=CE({}),{fetchStatus:n}=y(),r=new URLSearchParams(location.search).get("autoConnect")||"",a=e(r);SE(()=>{n==="success"&&r&&a.installed&&!a.connecting&&!a.connected&&!o.current[r]&&(o.current[r]=!0,t(r))},[a,n])}i(wh,"useForceAutoConnect");import{isApprovalTX as kE,RouteEventType as bh,StepEventType as xh,StepExecutionEventStatus as TE,WidgetEvents as Vi}from"@rango-dev/queue-manager-rango-preset";import{useEffect as Eh}from"react";function Yl(){let t=be.use.setNotification(),{connectedWallets:e,fetchBalances:o}=y();Eh(()=>{let n=i(r=>{let{event:a,step:s,route:l}=r;if(a.type===xh.TX_EXECUTION&&a.status===TE.TX_SENT&&!kE(s)||a.type===xh.SUCCEEDED){let u=e.find(m=>m.chain===s?.fromBlockchain),p=s?.fromBlockchain!==s?.toBlockchain&&e.find(m=>m.chain===s?.toBlockchain);u&&o([u]),p&&o([p])}t(a,l)},"handleStepEvent");return he.on(Vi.StepEvent,n),()=>he.off(Vi.StepEvent,n)},[he,e]),Eh(()=>{let n=i(r=>{let{event:a,route:s}=r;(a.type===bh.FAILED||a.type===bh.SUCCEEDED)&&t(a,s)},"handleRouteEvent");return he.on(Vi.RouteEvent,n),()=>he.off(Vi.RouteEvent,n)},[he])}i(Yl,"useSubscribeToWidgetEvents");import{useManager as vE}from"@rango-dev/queue-manager-react";import{useEffect as wE}from"react";function Zl(){let{isSynced:t,syncNotifications:e}=be(),{manager:o,state:n}=vE();wE(()=>{be.persist.hasHydrated()&&n.loadedFromPersistor&&!t&&e(pt(o))},[be.persist.hasHydrated(),n.loadedFromPersistor,t])}i(Zl,"useSyncNotifications");function Jl(){wh(),Th(),Yl(),Zl();let t=y().blockchains(),{canSwitchNetworkTo:e}=Xr(),[o,n]=Ah(""),[r,a]=Ah(),s=IE(Er),l=t.filter(EE),{fetchApiConfig:c}=vh();Ih(()=>()=>du(),[]),bE({lastConnectedWallet:o,clearDisconnectedWallet:()=>{a(void 0)},disconnectedWallet:r,evmChains:l,canSwitchNetworkTo:e}),Ih(()=>(ao.init(),be.persist.hasHydrated()||be.persist.rehydrate(),s.onConnectWallet(n),s.onDisconnectWallet(u=>{a(u),u===xE(o)?.[0]&&n("")}),c().catch(console.log),ao.destroy),[])}i(Jl,"useBootstrap");import{styled as AE}from"@rango-dev/ui";var Nh=AE("div",{fontFamily:"$widget",boxSizing:"border-box",textAlign:"left","& *, *::before, *::after":{boxSizing:"inherit"},"& *:focus-visible":{outlineColor:"$info500",transition:"none"},"& ul, ol, li":{listStyleType:"none"}});function Ki(){Jl();let{config:t}=y(),{activeTheme:e}=zo(t?.theme||{}),{activeLanguage:o}=Rt();return Rl.createElement(NE,{language:o},Rl.createElement(Nh,{id:"swap-container",className:e()},Rl.createElement(kh,null)))}i(Ki,"Main");import{setSolanaSignerConfig as XE}from"@rango-dev/signer-solana";import tc,{useEffect as _h,useMemo as YE}from"react";import{useState as WE}from"react";var BE=i(()=>{let[t,e]=WE(null),o=i(a=>{let s=document.createElement("link");return s.href=a,s.rel="stylesheet",document.head.appendChild(s),s},"loadFont"),n=i(()=>{t&&(document.head.removeChild(t),e(null))},"unloadFont");return{handleLoadCustomFont:i(a=>{n();let s=Nc(a);if(s){let l=o(s);e(l)}},"handleLoadCustomFont")}},"useFontLoader"),Wh=BE;import{checkWaitingForNetworkChange as ME,makeQueueDefinition as LE}from"@rango-dev/queue-manager-rango-preset";import{Provider as PE}from"@rango-dev/queue-manager-react";import{useWallets as _E}from"@rango-dev/wallets-react";import{convertEvmBlockchainMetaToEvmChainInfo as DE}from"@rango-dev/wallets-shared";import{isEvmBlockchain as $E}from"rango-types";import FE,{useMemo as OE}from"react";function UE(t){let{providers:e,getSigners:o,state:n,connect:r,canSwitchNetworkTo:a,getWalletInfo:s}=_E(),l=OE(()=>LE({API_KEY:t.apiKey||Lt("API_KEY"),BASE_URL:Lt("BASE_URL"),emitter:{emit:he.emit}}),[t.apiKey]),{blockchains:c,connectedWallets:u}=y(),p=c(),m={blockchains:u.map(v=>({accounts:[v],name:v.chain}))},h=i(async(v,w)=>a(v,w.network)?await r(v,[w]):void 0,"switchNetwork"),d=i(v=>!!s(v).mobileWallet,"isMobileWallet"),f=p.filter(v=>v.enabled).reduce((v,w)=>(v[w.name]=w,v),{}),g=p.filter($E),C=i(v=>{let{supportedChains:w}=s(v);return fr(w)},"getSupportedChainNames"),S=e(),k={meta:{blockchains:f,evmBasedChains:g,evmNetworkChainInfo:DE(g),getSupportedChainNames:C},getSigners:o,wallets:m,providers:S,switchNetwork:h,canSwitchNetworkTo:a,state:n,isMobileWallet:d},T=re.use.isActiveTab();return FE.createElement(PE,{queuesDefs:[l],context:k,onPersistedDataLoaded:v=>{ME(v)},isPaused:!T},t.children)}i(UE,"QueueManager");var Bh=UE;import{useManager as GE}from"@rango-dev/queue-manager-react";import VE,{createContext as KE,useContext as jE}from"react";function Mh(){let{findToken:t}=y(),e=y().blockchains(),o=y().tokens(),{setFromBlockchain:n,setFromToken:r,setToBlockchain:a,setToToken:s,setInputAmount:l}=O();return i(u=>{let{fromBlockchain:p,fromToken:m,toBlockchain:h,toToken:d,requestAmount:f}=u,g={blockchains:e,tokens:o};if(p!==void 0){let C=e.find(S=>S.name===p)??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(S=>S.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(Mh,"useUpdateQuoteInputs");import{cancelSwap as zE,getCurrentNamespaceOfOrNull as QE,getCurrentStep as qE,getRelatedWalletOrNull as HE}from"@rango-dev/queue-manager-rango-preset";var ji=class{static{i(this,"WidgetHistory")}constructor(e,o){this.manager=e,this.actions=o}getAllSwaps(){return pt(this.manager)}getCurrentStep(e){return this.getCurrentStepInfo(e).step}getCurrentStepWallet(e){return this.getCurrentStepInfo(e).wallet}getCurrentStepNetwork(e){return this.getCurrentStepInfo(e).network}retry(e,o){let n=Wr(e,o.blockchains,this.actions.findToken);return this.actions.retrySwap(n)}cancel(e){let o=this.manager?.get(e);o&&zE(o)}getCurrentStepInfo(e){let o=qE(e);return{step:o,wallet:o?HE(e,o):null,network:o?QE(e,o)?.network:null}}};var Lh=KE(void 0);function ec(t){let{manager:e}=GE(),o=re.use.isActiveTab(),n=O.use.retry(),{findToken:r,getBalances:a,getConnectedWalletsDetails:s,fetchBalances:l}=y(),c=new ji(e,{retrySwap:n,findToken:r}),{fetchingWallets:u}=y(),p=_c(a()),m=y().blockchains(),h=y().tokens(),d=y().swappers(),f=y().fetchStatus,g=Rt().resetLanguage,C=be().getNotifications(),S=be().clearNotifications,k=Mh(),{fromBlockchain:T,toBlockchain:v,fromToken:w,toToken:A,inputAmount:M}=O(),x={isActiveTab:o,setCurrentTabAsActive:ao.forceClaim,history:c,wallets:{isLoading:u,details:s(),totalBalance:p,refetch:async E=>l(E)},meta:{blockchains:m,tokens:h,swappers:d,loadingStatus:f,findToken:r},resetLanguage:g,notifications:{list:C,clearAll:S},quote:{quoteInputs:{fromBlockchain:T?.name??null,fromToken:w?{symbol:w.symbol,blockchain:w.blockchain,address:w.address}:null,toBlockchain:v?.name??null,toToken:A?{symbol:A.symbol,blockchain:A.blockchain,address:A.address}:null,requestAmount:M},updateQuoteInputs:k}};return VE.createElement(Lh.Provider,{value:x},t.children)}i(ec,"WidgetInfo");function Ph(){let t=jE(Lh);if(!t)throw new Error("useWidget can only be used within the WidgetProvider component");return t}i(Ph,"useWidget");function Xi(t){let{onUpdateState:e,config:o}=t,n=t.config?.theme?.fontFamily,{handleLoadCustomFont:r}=Wh();return _h(()=>{n&&r(n)},[n]),YE(()=>{qc({API_KEY:o?.apiKey||lr,BASE_URL:o?.apiUrl||Sc})},[o.apiKey,o.apiUrl]),_h(()=>{t.config?.signers?.customSolanaRPC&&XE("customRPC",t.config.signers.customSolanaRPC)},[t.config?.signers?.customSolanaRPC]),tc.createElement(Ir,{config:o,onUpdateState:e},tc.createElement(Bh,{apiKey:o.apiKey},tc.createElement(ec,null,t.children)))}i(Xi,"WidgetProvider");function Dh(t){let e=t.config?.externalWallets;return Yi.createElement(_p,null,e?Yi.createElement(Ki,null):Yi.createElement(Xi,{config:t.config??sr},Yi.createElement(Ki,null)))}i(Dh,"Widget");function $h(){let{on:t,off:e}=he;return{on:t,off:e}}i($h,"useWidgetEvents");var b3={DerivationPath:gn,Namespaces:fn,isOnDerivationPath:yn,isOnNamespace:hn};export{Yj as EventSeverity,Bo as MainEvents,a3 as Networks,c3 as PendingSwapNetworkStatus,ua as QuoteEventTypes,Zj as RouteEventType,ea as SUPPORTED_FONTS,b3 as StatefulConnect,Jj as StepEventType,Rj as StepExecutionBlockedEventStatus,e3 as StepExecutionEventStatus,De as UI_ID,da as UiEventTypes,ma as WalletEventTypes,r3 as WalletEvents,s3 as WalletTypes,Dh as Widget,Bo as WidgetEvents,Xi as WidgetProvider,Ir as WidgetWallets,ja as customizedThemeTokens,o3 as readAccountAddress,Gt as useStatefulConnect,ft as useWalletList,Xr as useWallets,Ph as useWidget,$h as useWidgetEvents,zy as widgetEventEmitter};
3
3
  //# sourceMappingURL=index.js.map