@rango-dev/widget-embedded 0.34.1-next.4 → 0.34.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- var Lh=Object.defineProperty;var i=(t,e)=>Lh(t,"name",{value:e,configurable:!0});import{EventSeverity as q3,RouteEventType as H3,StepEventType as G3,StepExecutionBlockedEventStatus as V3,StepExecutionEventStatus as K3}from"@rango-dev/queue-manager-rango-preset";import{legacyReadAccountAddress as X3}from"@rango-dev/wallets-core/legacy";import{useWallets as Zr,Events as Z3}from"@rango-dev/wallets-react";import{Networks as R3,WalletTypes as ej}from"@rango-dev/wallets-shared";import{PendingSwapNetworkStatus as oj}from"rango-types";import{Divider as IS}from"@rango-dev/ui";import uo,{useEffect as AS,useRef as NS,useState as Ic}from"react";import{WalletState as Bh}from"@rango-dev/ui";import{useWallets as Ph}from"@rango-dev/wallets-react";import{useReducer as Dh}from"react";function sp(t){return!!t.derivationPath}i(sp,"isStateOnDerivationPathStep");function lp(t){return!!t.namespace}i(lp,"isStateOnNamespace");var er={status:"init",namespace:null,derivationPath:null};function pp(t,e){switch(e.type){case"needsNamespace":return{...t,status:"namespace",namespace:e.payload,derivationPath:null};case"needsDerivationPath":return{...t,status:"derivationPath",derivationPath:e.payload};case"reset":return er;case"resetDerivation":return t.namespace?{...t,derivationPath:null,status:"namespace"}:er;default:throw new Error("Action hasn't been defined.")}}i(pp,"reducer");function Ht(){let{state:t,disconnect:e,connect:o}=Ph(),[n,r]=Dh(pp,er),a=i(async(c,m,f)=>{r({type:"reset"});try{return await o(c,void 0,m),{status:"connected"}}catch(g){let d=g?.message?`Error: ${g.message}`:"An unknown error happened during connecting wallet.";throw new Error(d,{cause:g})}},"runConnect"),s=i(async(c,m)=>{if(c.state===Bh.DISCONNECTED){if(!c.namespaces)return await a(c.type,void 0,m);let g=c.namespaces.length>1,d=c.needsDerivationPath;return g?(r({type:"needsNamespace",payload:{providerType:c.type,providerImage:c.image,availableNamespaces:c.namespaces,singleNamespace:c.singleNamespace}}),{status:"namespace"}):d?(r({type:"needsDerivationPath",payload:{providerType:c.type,providerImage:c.image,namespace:c.namespaces[0]}}),{status:"derivation-path"}):await a(c.type,c.namespaces.map(h=>({namespace:h})),m)}return m?.disconnectIfConnected?(await u(c.type),{status:"disconnected"}):{status:"disconnected-unhandled"}},"handleConnect"),l=i(async(c,m)=>{let f=c.singleNamespace,g=c.needsDerivationPath,d=m[0];if(!d)throw new Error("To confirm a namespace, you should select at least one namespace.");if(f&&g)return r({type:"needsDerivationPath",payload:{providerType:c.type,providerImage:c.image,namespace:d}}),{status:"derivation-path"};if(!lp(n))throw new Error("Something went wrong on handling namespace. Please retry.");let h=n.namespace.providerType,k=m.map(S=>({namespace:S}));return await a(h,k)},"handleNamespace"),p=i(async c=>{if(!c)throw new Error("Derivation path is empty. Please make sure you've filled the field correctly.");if(!sp(n))throw new Error("It seems you are filling derivation path without setting namespace before doing that. Please retry to connect.");let m=n.derivationPath.providerType,g=[{namespace:n.derivationPath.namespace,derivationPath:c}];return await a(m,g)},"handleDerivationPath"),u=i(async c=>{let m=t(c);return m.connected||m.connecting?(await e(c),{status:"disconnected"}):{status:"noop"}},"handleDisconnect");return{handleConnect:s,handleDisconnect:u,handleNamespace:l,handleDerivationPath:p,getState:()=>n,resetState:c=>{r(c==="derivation"?{type:"resetDerivation"}:{type:"reset"})}}}i(Ht,"useStatefulConnect");import{WalletState as Sa}from"@rango-dev/ui";import{useWallets as Hy}from"@rango-dev/wallets-react";import{detectMobileScreens as Gy,KEPLR_COMPATIBLE_WALLETS as Vy,WalletTypes as Lo}from"@rango-dev/wallets-shared";import{useCallback as Ky,useEffect as jy}from"react";import Py,{createContext as Dy,useContext as _y,useEffect as $y,useRef as Fy}from"react";import{create as Ly}from"zustand";import{persist as By}from"zustand/middleware";var oa=class{static{i(this,"CacheService")}#e=new Map;get(e){return this.#e.get(e)}set(e,o){this.#e.set(e,o)}remove(e){this.#e.delete(e)}clear(){this.#e.clear()}},Ao=new oa;function tr(t,e){return e.find(o=>o.name===t)?.displayName}i(tr,"getBlockchainDisplayNameFor");function pt(t,e){return e.find(o=>o.name===t)?.shortName}i(pt,"getBlockchainShortNameFor");function cp(t,e){return e.find(o=>o.name===t)?.logo}i(cp,"getBlockchainImage");function on(t,e){return e.find(o=>o.id===t)?.title}i(on,"getSwapperDisplayName");function nn(t,e){return e.find(o=>o.name===t)??null}i(nn,"findBlockchain");function na(t,e){if(!e||!t)return!1;for(let o of e.feeAssets)if(t?.blockchain===o?.blockchain&&t?.symbol===o?.symbol&&t?.address===o?.address)return!0;return!1}i(na,"isTokenNative");function _e(t){return`${t.blockchain.toLowerCase()}-${t.symbol.toLowerCase()}-${(t.address??"").toLowerCase()}`}i(_e,"createTokenHash");function No(t,e){return t.addressPatterns.filter(r=>new RegExp(r).test(e)).length>0}i(No,"isValidTokenAddress");function rn(t){let{config:e,meta:o}=t,n={},r=e.tokens,a=i(l=>{l.forEach(p=>{typeof p!="string"&&(p=_e(p));let u=o.tokensMapByTokenHash.get(p);u&&(n[p]=u)})},"addTokens");if(Array.isArray(r))return r.length>0?(a(r),Object.values(n)):Array.from(o.tokensMapByTokenHash.values());if(!r)return Array.from(o.tokensMapByTokenHash.values());let s;if(e.blockchains?.length)s=e.blockchains;else{s=Object.keys(r);let l=new Set(s);Object.keys(o.tokensMapByBlockchainName).forEach(p=>{l.has(p)||a(o.tokensMapByBlockchainName[p])})}return s.forEach(l=>{let p=r[l];if(!p&&o.tokensMapByBlockchainName?.[l]){a(o.tokensMapByBlockchainName[l]);return}p&&(p.isExcluded?(a(o.tokensMapByBlockchainName[l]),p.tokens.forEach(u=>{let c=_e(u);delete n[c]})):a(p.tokens))}),Object.values(n)}i(rn,"matchTokensFromConfigWithMeta");function or(t){let{config:e}=t,o=e.from?.blockchains||[],n=e.to?.blockchains||[];if(!o.length||!n.length)return[];let r=[...o,...n],a=new Set(r);return Array.from(a)}i(or,"getSupportedBlockchainsFromConfig");var ra={apiKey:"",title:void 0,multiWallets:!0,excludeLiquiditySources:!0,customDestination:!0,variant:"default",trezorManifest:{appUrl:"https://widget.rango.exchange/",email:"hi+trezorwidget@rango.exchange"}},_h={clientUrl:void 0},$h={liquiditySources:void 0},up=i((t,e,o)=>({config:{...ra,...t},iframe:_h,campaignMode:$h,getLiquiditySources:()=>{let{config:n,campaignMode:r}=o();return r.liquiditySources?.length?r.liquiditySources:n.liquiditySources??[]},getDisabledLiquiditySources:()=>{let{disabledLiquiditySources:n,campaignMode:r}=o();return r.liquiditySources?.length?[]:n},excludeLiquiditySources:()=>{let{config:n,campaignMode:r}=o();return r.liquiditySources?.length?!1:!!n.excludeLiquiditySources},isInCampaignMode:()=>{let{campaignMode:n}=o();return!!n.liquiditySources?.length},updateConfig:n=>{let r=o().config,{_tokensMapByTokenHash:a,_tokensMapByBlockchainName:s}=o(),l=rn({type:"source",config:{blockchains:n.from?.blockchains,tokens:n.from?.tokens},meta:{tokensMapByBlockchainName:s,tokensMapByTokenHash:a}}),p=rn({type:"destination",config:{blockchains:n.to?.blockchains,tokens:n.to?.tokens},meta:{tokensMapByBlockchainName:s,tokensMapByTokenHash:a}});Ao.set("supportedSourceTokens",l),Ao.set("supportedDestinationTokens",p),e({config:{...r,...n}})},updateCampaignMode:(n,r)=>{let a=o().campaignMode;e({campaignMode:{...a,[n]:r}})},updateIframe:(n,r)=>{let a=o().iframe;e({iframe:{...a,[n]:r}})}}),"createConfigSlice");import{TransactionType as mp}from"rango-types";var dp=[mp.EVM,mp.SOLANA];import{RangoClient as Jh}from"rango-sdk";import{UI_ID as Fh}from"@rango-dev/ui";var nr="c6381a79-2817-4602-83bf-6a641a409e32",fp="https://api.rango.exchange",gp="https://explorer.rango.exchange",$e={SWAP_BOX_ID:"rango-swap-box",EXPANDED_BOX_ID:"rango-expanded-box",...Fh};import{BlockchainCategories as Gh,WalletState as xt}from"@rango-dev/ui";import{legacyReadAccountAddress as Vh}from"@rango-dev/wallets-core/legacy";import{detectInstallLink as Kh,getCosmosExperimentalChainInfo as jh,isEvmAddress as Xh,KEPLR_COMPATIBLE_WALLETS as zI,Networks as Ap}from"@rango-dev/wallets-shared";import ca from"bignumber.js";import{isCosmosBlockchain as Yh}from"rango-types";import Oh from"bignumber.js";var Ue=new Oh(0);import{WalletTypes as Uh}from"@rango-dev/wallets-shared";var hp=[Uh.LEAP];import{BlockchainCategories as aa,WalletState as Hh}from"@rango-dev/ui";import{TransactionType as rr}from"rango-sdk";var yp="Roboto",ia=[{name:"Roboto",value:"Roboto",url:""},{name:"Times New Roman",value:"Times New Roman",url:"https://fonts.cdnfonts.com/css/times-new-roman"},{name:"Arial",value:"Arial",url:""},{name:"Open Sans",value:"Open Sans",url:"https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,300..800;1,300..800&display=swap"},{name:"Noto Sans",value:"Noto Sans",url:"https://fonts.googleapis.com/css2?family=Noto+Sans:ital,wght@0,100..900;1,100..900&display=swap"},{name:"Montserrat",value:"Montserrat",url:"https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100..900;1,100..900&display=swap"},{name:"Poppins",value:"Poppins",url:"https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap"},{name:"Roboto Condensed",value:"Roboto Condensed",url:"https://fonts.googleapis.com/css2?family=Roboto+Condensed:ital,wght@0,100..900;1,100..900&display=swap"},{name:"Roboto Mono",value:"Roboto Mono",url:"https://fonts.googleapis.com/css2?family=Roboto+Mono:ital,wght@0,100..700;1,100..700&display=swap"},{name:"Oswald",value:"Oswald",url:"https://fonts.googleapis.com/css2?family=Oswald:wght@200..700&display=swap"},{name:"Raleway",value:"Raleway",url:"https://fonts.googleapis.com/css2?family=Raleway:ital,wght@0,100..900;1,100..900&display=swap"},{name:"Sedan",value:"Sedan",url:"https://fonts.googleapis.com/css2?family=Sedan:ital@0;1&display=swap"},{name:"Inter",value:"Inter",url:"https://fonts.googleapis.com/css2?family=Inter:wght@100..900&display=swap"},{name:"Rubik",value:"Rubik",url:"https://fonts.googleapis.com/css2?family=Rubik:ital,wght@0,300..900;1,300..900&display=swap"},{name:"Lora",value:"Lora",url:"https://fonts.googleapis.com/css2?family=Lora:ital,wght@0,400..700;1,400..700&display=swap"},{name:"Barlow Condensed",value:"Barlow Condensed",url:"https://fonts.googleapis.com/css2?family=Barlow+Condensed:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap"}];function Wo(t){return Array.from(new Set(t))}i(Wo,"removeDuplicateFrom");function pa(t,e){return t.length===e.length&&t.every((o,n)=>o===e[n])}i(pa,"areEqual");function wp(t,e){let o;return n;function n(...r){o&&clearTimeout(o),o=setTimeout(()=>{o=null,t(...r)},e)}}i(wp,"debounce");function et(t,e){return t.toLowerCase().indexOf(e.toLowerCase())>-1}i(et,"containsText");function kp(t,e){return t.toLowerCase()===e.toLowerCase()}i(kp,"exactText");function Tp(t,e){return t.toLowerCase().startsWith(e.toLowerCase())}i(Tp,"startWithText");var N=i(()=>document.getElementById($e.SWAP_BOX_ID),"getContainer"),an=i(()=>document.getElementById($e.EXPANDED_BOX_ID),"getExpanded");function vp(t,e,o){let n=!!e&&kp(e,t),r=!!o&&kp(o,t);return n!==r?n?-1:1:0}i(vp,"compareExactMatchText");function sa(t,e,o){let n=!!e&&et(e,t),r=!!o&&et(o,t);return n!==r?n?-1:1:n&&r&&e?.length!==o?.length?e?.length-o?.length:0}i(sa,"compareContainsText");function la(t,e,o){let n=!!e&&Tp(e,t),r=!!o&&Tp(o,t);return n!==r?n?-1:1:n&&r&&e?.length!==o?.length?e?.length-o?.length:0}i(la,"compareStartWithText");function bp(t,e,o){if(!o)return 0;let n=vp(o,t.symbol,e.symbol);if(n)return n;if(o.length>=3){let r=vp(o,t.name,e.name);if(r)return r}if(o.length>=2){let r=la(o,t.symbol,e.symbol);if(r)return r}if(o.length>=3){let r=sa(o,t.symbol,e.symbol);if(r)return r}if(o.length>=3){let r=la(o,t.name,e.name);if(r)return r}if(o.length>=3){let r=sa(o,t.name,e.name);if(r!==0)return r}if(o.length>=4){let r=la(o,t.address,e.address);if(r)return r}if(o.length>=4){let r=sa(o,t.address,e.address);if(r!==0)return r}return 0}i(bp,"compareWithSearchFor");var ir=i((t,e)=>{switch(e){case aa.ALL:return!0;case aa.UTXO:return t===rr.TRANSFER;case aa.OTHER:return t!==rr.TRANSFER&&t!==rr.COSMOS&&t!==rr.EVM;default:return t===e}},"isBlockchainTypeInCategory"),xp=i(t=>ia.find(o=>o.value===t)?.url,"getFontUrlByName");function Ep(t,e){let o=!!t.find(n=>n.state===Hh.CONNECTED);return e===!1&&o}i(Ep,"isSingleWalletActive");import{BigNumber as Ip}from"bignumber.js";var sn=i(t=>{let e=Math.floor(t%60/15)*15,o=parseInt((t/60).toString());return o>=60?`${Math.floor(o/5)*5}:00`:`${o.toString().padStart(2,"0")}:${e.toString().padStart(2,"0")}`},"roundedSecondsToString"),L=i((t,e=null,o=null)=>{if(t==null||t==="")return"";let n=new Ip(t),r=1,a=1e3;for(let s=0;s<60;s++)if(new Ip(n.toFixed(s,r)).eq(n)){a=s;break}if(n.gte(1e4))return n.toFormat(0,r);if(n.gte(1e3)||n.gte(100))return n.toFormat(Math.min(a,Math.min(o||100,Math.max(e||0,1))),r);if(n.gte(1))return n.toFormat(Math.min(a,Math.min(o||100,Math.max(e||0,2))),r);if(n.gte(.01))return n.toFormat(Math.min(a,Math.min(o||100,Math.max(e||0,4))),r);for(let s=e||4;s<17;s++)if(n.gte(Math.pow(10,-s)))return n.toFormat(Math.min(a,Math.min(o||100,Math.max(e||0,s))),r);return n.isEqualTo(0)?"0":n.toFormat(Math.min(a,Math.min(o||100,Math.max(e||0,8))),r)},"numberToString");var ar=i(t=>t?.reduce((e,o)=>e+(o.estimatedTimeInSeconds??0),0)||0,"totalArrivalTime");var bt=i((t,e)=>t.toLowerCase().indexOf(e.toLowerCase())>-1,"containsText"),ln=i(t=>!!t&&parseFloat(t)>0,"isPositiveNumber");function pn(t){switch(!0){case t.connected:return xt.CONNECTED;case t.connecting:return xt.CONNECTING;case!t.installed:return xt.NOT_INSTALLED;default:return xt.DISCONNECTED}}i(pn,"mapStatusToWalletState");function Np(t,e,o,n){return o.filter(r=>!hp.includes(r)).filter(r=>{let{supportedChains:a,isContractWallet:s}=e(r),{installed:l,network:p}=t(r);return s&&(!l||!!n&&p!==n)?!1:n?!!a.find(c=>c.name===n):!0}).map(r=>{let{name:a,img:s,installLink:l,showOnMobile:p,namespaces:u,singleNamespace:c,supportedChains:m,needsDerivationPath:f}=e(r),g=Wo(m.map(h=>h.type)),d=pn(t(r));return{title:a,image:s,link:Kh(l),state:d,type:r,showOnMobile:p,namespaces:u,singleNamespace:c,blockchainTypes:g,needsDerivationPath:f}})}i(Np,"mapWalletTypesToWalletInfo");function pr(t){if(!t)return null;let e=[];return e=t.map(o=>o.name),e}i(pr,"walletAndSupportedChainsNames");function Wp(t,e,o,n,r){let a=[];function s(p,u){if(!!!a.find(m=>m.chain===p)){let m={address:u,chain:p,walletType:t};a.push(m)}}i(s,"addAccount");let l=n||[];return e.forEach(p=>{let{address:u,network:c}=Vh(p),m=l.length>0,f=l.includes(c),g=c===Ap.Unknown;if(m&&!f&&!g)return;let h=c===Ap.Unknown&&Xh(u);if(g&&!h)return;o.includes(c)||h?r?s(c,u.toLowerCase()):l.filter(C=>o.includes(C)).forEach(C=>{s(C,u.toLowerCase())}):s(c,u)}),a}i(Wp,"prepareAccountsForWalletStore");function 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:p}=r;p.forEach((u,c)=>{let m=u.from.blockchain,f=u.to.blockchain,g=a===o.swaps.length-1,d=c===p.length-1;(!g&&!d||g&&l!==m||e==="all")&&n.add(m),e==="all"&&n.add(f)})}e==="all"&&n.add(l)}),Array.from(n)}i(io,"getQuoteWallets");function cr(t,e){return t.address===e.address&&t.chain===e.chain&&t.walletType===e.walletType}i(cr,"isAccountAndWalletMatched");function Mp(t,e){let{blockChain:o,balances:n=[]}=t;return n?.map(r=>({chain:o,symbol:r.asset.symbol,ticker:r.asset.symbol,address:r.asset.address||null,rawAmount:r.amount.amount,decimal:r.amount.decimals,amount:new ca(r.amount.amount).shiftedBy(-r.amount.decimals).toFixed(),logo:"",usdPrice:e(r.asset)?.usdPrice||null}))||[]}i(Mp,"makeBalanceFor");function Lp(t){return{...t,loading:!1,error:!0}}i(Lp,"resetConnectedWalletState");var Bp=i(t=>{let e=new Set,n=t?.reduce((a,s)=>a.findIndex(l=>l.address===s.address&&l.chain===s.chain)===-1?[...a,s]:a,[])?.map(a=>{let s={name:a.chain,accounts:[]};return e.has(a.address)||e.add(a.address),e.forEach(l=>{a.address===l&&s.accounts.push(a)}),s}),r=L(n?.flatMap(a=>a.accounts)?.flatMap(a=>a?.balances)?.map(a=>new ca(a?.amount||Ue).multipliedBy(a?.usdPrice||0))?.reduce((a,s)=>a.plus(s),Ue)||Ue).toString();return Zh(r)},"calculateWalletUsdValue");function Zh(t){let e=t.toString().split(".");return e[0]=e[0].replace(/\B(?=(\d{3})+(?!\d))/g,","),e.join(".")}i(Zh,"numberWithThousandSeparator");var ur=i((t,e)=>{let o=jh(Object.entries(t).map(([,n])=>n).filter(Yh));return o&&o[e]?.experimental},"isExperimentalChain");function mr(t){return t?{...t,amount:L(t.amount,8,8),usdValue:L(t.usdValue,4,4)}:null}i(mr,"formatBalance");function Pp(t,e){return t?.usdValue||e?.usdValue?parseFloat(e?.usdValue||"0")-parseFloat(t?.usdValue||"0"):t?.amount||e?.amount?parseFloat(e?.amount||"0")-parseFloat(t?.amount||"0"):0}i(Pp,"compareTokenBalance");function ao(t,e){return t?.blockchain===e?.blockchain&&t?.symbol.toLowerCase()===e?.symbol.toLowerCase()&&t?.address?.toLowerCase()===e?.address?.toLowerCase()}i(ao,"areTokensEqual");function Dp(t){return t.sort((e,o)=>+(o.state===xt.CONNECTED)-+(e.state===xt.CONNECTED)||+(o.state===xt.DISCONNECTED||o.state===xt.CONNECTING)-+(e.state===xt.DISCONNECTED||e.state===xt.CONNECTING))}i(Dp,"sortWalletsBasedOnConnectionState");function dr(t,e=8,o=3){if(t.length<2*e+o)return t;let n=t.slice(0,e),r=t.slice(-e);return`${n}${".".repeat(o)}${r}`}i(dr,"getConciseAddress");function _p({chain:t,connectedWallets:e,walletType:o}){return e.find(n=>n.walletType===o&&n.chain===t)?.address}i(_p,"getAddress");function fr(t){return t.flatMap(e=>e.balances).reduce((e,o)=>{let n={amount:o?.amount??"",decimals:o?.decimal??0,usdValue:o?.usdPrice?new ca(o?.usdPrice??Ue).multipliedBy(o?.amount).toString():""},r=o?_e({symbol:o.symbol,blockchain:o.chain,address:o.address}):null,a=r?e[r]:null;return r&&(!a||a&&a.amount<n.amount)&&(e[r]=n),e},{})}i(fr,"makeTokensBalance");var $p=i((t,e)=>!!t.find(o=>o.chain===e&&o.loading),"isFetchingBalance");function Fp(t){return t.map(e=>e.state).join("-")}i(Fp,"hashWalletsState");function Op(t,e){let o=new Set;return t.forEach(r=>{r.blockchainTypes.forEach(a=>{o.add(a)})}),e.filter(r=>o.has(r.type))}i(Op,"filterBlockchainsByWalletTypes");function Up(t,e){return e===Gh.ALL?t:t.filter(o=>{for(let n of o.blockchainTypes)if(ir(n,e))return!0;return!1})}i(Up,"filterWalletsByCategory");var ua={API_KEY:nr};function Bt(t){return ua[t]||""}i(Bt,"getConfig");function zp(t){let e;return typeof structuredClone=="function"?e=structuredClone(t):e=JSON.parse(JSON.stringify(t)),ua=e,ua}i(zp,"initConfig");var Qp=20,qp=25,ma="theme-widget",da=i((t,e)=>{let o=!1;if(e&&t){if(Array.isArray(e))o=!e.some(n=>ao(n,t));else if(!Array.isArray(e)&&e[t.blockchain]){o=e[t.blockchain].tokens.some(r=>ao(r,t));let n=e[t.blockchain].isExcluded;return!n&&!o||n&&o}}return o},"isTokenExcludedInConfig"),fa=i((t,e)=>t&&e&&!e.includes(t.name),"isBlockchainExcludedInConfig"),Hp=i((t,e,o)=>o==="expanded"&&(t||e)||o==="full-expanded"&&e,"isVariantExpandable");var gr,Et=i(()=>gr||(gr=new Jh(Bt("API_KEY"),Bt("BASE_URL")),gr),"httpService");function hr(t,e){let o=t.map(a=>a.swapperGroup),n=[];return Wo(t.map(a=>a.swapperGroup)).map(a=>{let s=t.find(l=>l.swapperGroup===a);if(s){let l=!0;o&&(l=o.some(p=>p===s.swapperGroup)),l&&s.types.map(p=>{n.push({id:s.swapperGroup,groupTitle:s.swapperGroup,logo:s.logo,type:p,selected:!e.includes(s.swapperGroup)})})}}),n}i(hr,"getUniqueSwappersGroups");function Gp(t,e){return t.swapperGroup<e.swapperGroup?-1:t.swapperGroup>e.swapperGroup?1:0}i(Gp,"sortLiquiditySourcesByGroupTitle");function je(t,e){return e?.[t]==="hidden"}i(je,"isFeatureHidden");function Vp(t,e){return e?.[t]==="enabled"}i(Vp,"isFeatureEnabled");var Kp=i((t,e,o)=>je("customTokens",o)?t:t.concat(e),"addCustomTokensToSupportedTokens");var jp=i((t,e)=>({_blockchainsMapByName:new Map,_tokensMapByTokenHash:new Map,_tokensMapByBlockchainName:{},_popularTokens:[],_swappers:[],fetchStatus:"loading",blockchains:o=>{let n=e()._blockchainsMapByName,r=Array.from(n?.values()||[]);if(!o||!o?.type)return r;let a=e().config;if(o.type==="custom-token"){let p=or({config:a}),u=r;return p.length>0&&(u=u.filter(c=>p.includes(c.name))),u.filter(c=>dp.includes(c.type))}let s=(o.type==="source"?a.from?.blockchains:a.to?.blockchains)??[];return r.filter(p=>!(s.length>0&&!s.includes(p.name)))},tokens:o=>{let{_tokensMapByTokenHash:n,_tokensMapByBlockchainName:r,config:a,_customTokens:s}=e(),l=Array.from(n.values()),p=e()._blockchainsMapByName;if(!o||!o.type)return l;let u=o.type==="source"?"from":"to",c=o.type==="source"?"supportedSourceTokens":"supportedDestinationTokens",m=Ao.get(c);m?.length||(m=rn({type:o.type,config:{blockchains:a[u]?.blockchains,tokens:a[u]?.tokens},meta:{tokensMapByTokenHash:n,tokensMapByBlockchainName:r}}),Ao.set(c,m)),m=Kp(m,s,a.features);let f=e().blockchains({type:o.type});return m.filter(d=>o.blockchain&&d.blockchain!==o.blockchain||!f.some(h=>h.name===d.blockchain)?!1:o.searchFor?!!(et(d.symbol,o.searchFor)||et(d.address||"",o.searchFor)||et(d.name||"",o.searchFor)):!0).sort((d,h)=>{let k=e().isTokenPinned(d,o.type),S=e().isTokenPinned(h,o.type);if(k!==S)return k?-1:1;if(o.getBalanceFor){let A=o.getBalanceFor(d),M=o.getBalanceFor(h),b=Pp(A,M);if(b!==0)return b}let C=p.get(d.blockchain),T=p.get(h.blockchain),v=na(d,C),w=na(h,T);if(v!==w)return v?-1:1;if(d.isPopular!==h.isPopular)return d.isPopular?-1:1;if(o.searchFor){let A=bp(d,h,o.searchFor);if(A)return A}return d.isSecondaryCoin!==h.isSecondaryCoin?d.isSecondaryCoin?1:-1:C&&T?C.sort-T.sort:0})},findToken:o=>{let n=e()._tokensMapByTokenHash,r=e().customTokens(),a=_e(o),s=n.get(a);return s||(s=r.find(l=>_e(l)===a)),s},isTokenPinned:(o,n)=>!!(n==="source"?e().config.from?.pinnedTokens:e().config.to?.pinnedTokens)?.some(s=>ao(s,o)),swappers:()=>{let{config:o,campaignMode:n}=e(),r=n.liquiditySources?.length?n.liquiditySources:null,a=r??o.liquiditySources,s=r?!1:o.excludeLiquiditySources;return e()._swappers.filter(u=>{let c=a?.includes(u.swapperGroup);return s||!a||a.length===0?!c:c}).sort(Gp)},fetch:async()=>{try{let{enableCentralizedSwappers:o}=e().config,n=await Et().getAllMetadata({enableCentralizedSwappers:o});t({fetchStatus:"success"});let r=new Map,a=new Map,s={},l=[],p=n.popularTokens,u=n.swappers,c=new Set;n.tokens.forEach(f=>{c.add(f.blockchain),l.push(f)}),n.blockchains.sort((f,g)=>f.sort-g.sort).forEach(f=>{f.enabled&&c.has(f.name)&&r.set(f.name,f)}),l.forEach(f=>{let g=_e(f);s[f.blockchain]||(s[f.blockchain]=[]),a.set(g,f),s[f.blockchain].push(g)}),t({_blockchainsMapByName:r,_tokensMapByTokenHash:a,_tokensMapByBlockchainName:s,_popularTokens:p,_swappers:u})}catch(o){throw t({fetchStatus:"failed"}),o}}}),"createDataSlice");import{Bengali as Rh,Catalonia as ey,Chinese as Xp,Denmark as ty,English as oy,Finland as ny,French as ry,German as iy,Greece as ay,Hungary as sy,India as ly,Indonesian as py,Italian as cy,Japanese as uy,Korea as my,Lithuania as dy,Malay as fy,Netherlands as gy,Pakistan as hy,Philippines as yy,Poland as Sy,Portuguese as Cy,Russian as ky,SaudiArabia as Ty,Serbia as vy,Slovakia as wy,SouthAfrica as by,Spanish as xy,Swahili as Ey,Swedish as Iy,Thai as Ay,Turkish as Ny,Ukrainian as Wy,Vietnamese as My}from"@rango-dev/ui";var Yp=[{title:"Afrikaans",label:"Afrikaans",local:"af",SVGFlag:by},{title:"Arabic",label:"\u0639\u0631\u0628\u064A",local:"ar",SVGFlag:Ty},{title:"Bengali",label:"\u09AC\u09BE\u0982\u09B2\u09BE",local:"bn",SVGFlag:Rh},{title:"Catalan",label:"Catal\xE0",local:"ca",SVGFlag:ey},{title:"Chinese (Simplified)",label:"\u7B80\u4F53\u4E2D\u6587",local:"zh-CN",SVGFlag:Xp},{title:"Chinese (Traditional)",label:"\u4E2D\u6587\uFF08\u7E41\u9AD4)",local:"zh-TW",SVGFlag:Xp},{title:"Danish",label:"Dansk",local:"da",SVGFlag:ty},{title:"Dutch",label:"Nederlands",local:"nl",SVGFlag:gy},{title:"English",label:"English",local:"en",SVGFlag:oy},{title:"Filipino",label:"Filipino",local:"fil",SVGFlag:yy},{title:"Finnish",label:"Suomalainen",local:"fi",SVGFlag:ny},{title:"French",label:"Fran\xE7ais",local:"fr",SVGFlag:ry},{title:"German",label:"Deutsch",local:"de",SVGFlag:iy},{title:"Greek",label:"\u03B5\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AC",local:"el",SVGFlag:ay},{title:"Hindi",label:"\u0939\u093F\u0902\u0926\u0940",local:"hi",SVGFlag:ly},{title:"Hungarian",label:"Magyar",local:"hu",SVGFlag:sy},{title:"Indonesian",label:"Indonesia",local:"id",SVGFlag:py},{title:"Italian",label:"Italiana",local:"it",SVGFlag:cy},{title:"Japanese",label:"\u65E5\u672C\u8A9E",local:"ja",SVGFlag:uy},{title:"Korean",label:"\uD55C\uAD6D\uC778",local:"ko",SVGFlag:my},{title:"Lithuanian",label:"Lietuvi\u0173",local:"lt",SVGFlag:dy},{title:"Malay",label:"Melayu",local:"ms",SVGFlag:fy},{title:"Polish",label:"Polski",local:"pl",SVGFlag:Sy},{title:"Portuguese",label:"Portugu\xEAs",local:"pt",SVGFlag:Cy},{title:"Russian",label:"\u0420\u0443\u0441\u0441\u043A\u0438\u0439",local:"ru",SVGFlag:ky},{title:"Serbian",label:"C\u0440\u043F\u0441\u043A\u0438",local:"sr",SVGFlag:vy},{title:"Slovak",label:"Slovensk\xFD",local:"sk",SVGFlag:wy},{title:"Spanish",label:"Espa\xF1ol",local:"es",SVGFlag:xy},{title:"Swahili",label:"Kiswahili",local:"sw",SVGFlag:Ey},{title:"Swedish",label:"Svenska",local:"sv",SVGFlag:Iy},{title:"Thai",label:"\u0E41\u0E1A\u0E1A\u0E44\u0E17\u0E22",local:"th",SVGFlag:Ay},{title:"Turkish",label:"T\xFCrk\xE7e",local:"tr",SVGFlag:Ny},{title:"Ukrainian",label:"Y\u043A\u0440\u0430\u0457\u043D\u0456",local:"uk",SVGFlag:Wy},{title:"Urdu",label:"\u0627\u0631\u062F\u0648",local:"ur",SVGFlag:hy},{title:"Vietnamese",label:"Ti\u1EBFng Vi\u1EC7t",local:"vi",SVGFlag:My}],Mo="en";var Zp=[.5,1,3],Jp=1,Rp=5,ec=100,tc=0;var oc=i((t,e)=>({disabledLiquiditySources:[],theme:"auto",language:null,preferredBlockchains:[],slippage:Jp,customSlippage:null,infiniteApprove:!1,affiliateRef:null,affiliatePercent:null,affiliateWallets:null,_customTokens:[],addPreferredBlockchain:o=>{let n=e().preferredBlockchains;if(n.find((s,l)=>{let p=s===o,u=l<=9;return p&&u}))return;let a=n.filter(s=>!(s===o));t(()=>({preferredBlockchains:[o,...a]}))},setSlippage:o=>t(()=>({slippage:o})),setCustomSlippage:o=>t(()=>({customSlippage:o})),setAffiliateRef:o=>t(()=>({affiliateRef:o})),setAffiliatePercent:o=>t(()=>({affiliatePercent:o})),setAffiliateWallets:o=>t(()=>({affiliateWallets:o})),toggleAllLiquiditySources:(o,n)=>t(r=>{if(n)return{disabledLiquiditySources:[]};let a=Wo(o.map(s=>s.swapperGroup));return a.length===r.disabledLiquiditySources.length?{disabledLiquiditySources:[]}:{disabledLiquiditySources:a}}),toggleInfiniteApprove:()=>t(o=>({infiniteApprove:!o.infiniteApprove})),toggleLiquiditySource:o=>t(n=>n.disabledLiquiditySources.includes(o)?{disabledLiquiditySources:n.disabledLiquiditySources.filter(r=>r!=o)}:{disabledLiquiditySources:n.disabledLiquiditySources.concat(o)}),setTheme:o=>t(()=>({theme:o})),setLanguage:o=>t(()=>({language:o})),updateSettings:o=>{let{features:n,theme:r}=o,a=je("theme",n),s=je("language",n),l=je("liquiditySource",n),p=r?.singleTheme,u=o?.__UNSTABLE_OR_INTERNAL__?.autoUpdateSettings;t({...a&&{theme:o.theme?.mode||"auto"},...p&&{theme:o.theme?.mode||"light"},...s&&{language:o.language||Mo},...l&&{disabledLiquiditySources:o.liquiditySources||[]},...u&&{language:o.language||Mo}})},setCustomToken:o=>t(n=>({_customTokens:[o,...n._customTokens]})),deleteCustomToken:o=>t(n=>({_customTokens:n._customTokens.filter(r=>r.address!==o.address)})),customTokens:()=>{let o=e().config,n=e()._customTokens,r=or({config:o});return r.length?n.filter(a=>r.includes(a.blockchain)):n}}),"createSettingsSlice");function nc(t){return Ly()(By((...e)=>({...jp(...e),...oc(...e),...up(t,...e)}),{name:"user-settings",skipHydration:!0,partialize:e=>({_customTokens:e._customTokens,theme:e.theme,language:e.language,affiliatePercent:e.affiliatePercent,affiliateRef:e.affiliateRef,affiliateWallets:e.affiliateWallets,slippage:e.slippage,customSlippage:e.customSlippage,infiniteApprove:e.infiniteApprove,preferredBlockchains:e.preferredBlockchains,disabledLiquiditySources:e.disabledLiquiditySources})}))}i(nc,"createAppStore");var rc=Dy(null);function y(){let t=_y(rc);if($y(()=>{t&&!t.persist.hasHydrated()&&t.persist.rehydrate()},[]),!t)throw new Error("Missing AppStoreContext.Provider in the tree");return t()}i(y,"useAppStore");function ic(t){let e=Fy();return e.current||(e.current=nc(t.config)),Py.createElement(rc.Provider,{value:e.current},t.children)}i(ic,"AppStoreProvider");import{create as zy}from"zustand";import{subscribeWithSelector as Qy}from"zustand/middleware";import Oy from"mitt";var ye=Oy(),yr={on:ye.on,off:ye.off};import{WidgetEvents as ac}from"@rango-dev/queue-manager-rango-preset";var ha=(o=>(o.QUOTE_INPUT_UPDATE="quoteInputUpdate",o.QUOTE_OUTPUT_UPDATE="quoteOutputUpdate",o))(ha||{}),Sr=(o=>(o.CONNECT="connect",o.DISCONNECT="disconnect",o))(Sr||{}),ya=(e=>(e.CLICK_CONNECT_WALLET="clickConnectWallet",e))(ya||{}),so=(a=>(a[a.RouteEvent=ac.RouteEvent]="RouteEvent",a[a.StepEvent=ac.StepEvent]="StepEvent",a.QuoteEvent="quoteEvent",a.WalletEvent="walletEvent",a.UiEvent="uiEvent",a))(so||{});var Uy=i(t=>{let e=t;e.use={};for(let o of Object.keys(e.getState()))e.use[o]=()=>e(n=>n[o]);return e},"createSelectors"),Gt=Uy;var Z=Gt(zy()(Qy((t,e)=>({connectedWallets:[],balances:{},loading:!1,connectWallet:(o,n)=>{ye.emit("walletEvent",{type:"connect",payload:{walletType:o[0].walletType,accounts:o}});let r=e().getWalletsDetails;t(a=>({loading:!0,connectedWallets:a.connectedWallets.filter(s=>s.walletType!==o[0].walletType).concat(o.map(s=>{let l=!a.connectedWallets.some(p=>p.chain===s.chain&&p.selected&&p.walletType!==s.walletType);return{balances:[],address:s.address,chain:s.chain,explorerUrl:null,walletType:s.walletType,selected:l,loading:!0,error:!1}}))})),r(o,n)},disconnectWallet:o=>{t(n=>{n.connectedWallets.find(l=>l.walletType===o)&&ye.emit("walletEvent",{type:"disconnect",payload:{walletType:o}});let r=n.connectedWallets.filter(l=>l.selected&&l.walletType!==o).map(l=>l.chain),a=n.connectedWallets.filter(l=>l.walletType!==o).map(l=>r.includes(l.chain)?l:(r.push(l.chain),{...l,selected:!0}));return{balances:fr(a),connectedWallets:a}})},selectWallets:o=>t(n=>({connectedWallets:n.connectedWallets.map(r=>{let a=!!o.find(l=>l.chain===r.chain&&l.walletType!==r.walletType&&r.selected),s=!!o.find(l=>l.chain===r.chain&&l.walletType===r.walletType&&!r.selected);return a?{...r,selected:!1}:s?{...r,selected:!0}:r})})),clearConnectedWallet:()=>t(()=>({connectedWallets:[],selectedWallets:[]})),getWalletsDetails:async(o,n,r=!0)=>{let a=e().getWalletsDetails;t(s=>({loading:!0,connectedWallets:s.connectedWallets.map(l=>o.find(p=>cr(p,l))?{...l,loading:!0}:l)}));try{let s=o.map(({address:u,chain:c})=>({address:u,blockchain:c})),p=(await Et().getWalletsDetails(s)).wallets;if(p)t(u=>{let c=u.connectedWallets.map(f=>{let g=o.find(h=>cr(h,f)),d=p.find(h=>h.address===f.address&&h.blockChain===f.chain);return d?.failed&&g&&r&&a([g],n,!1),g&&d?{...f,explorerUrl:d.explorerUrl,balances:Mp(d,n),loading:!1,error:!1}:f});return{loading:!1,balances:fr(c),connectedWallets:c}});else throw new Error("Wallet not found")}catch{t(l=>{let p=l.connectedWallets.map(c=>o.find(m=>cr(m,c))?Lp(c):c);return{loading:!1,balances:fr(p),connectedWallets:p}})}},getBalanceFor:o=>{let{balances:n}=e(),r=_e(o);return n[r]??null}}))));import{allProviders as qy}from"@rango-dev/provider-all";function Cr(t,e){let o=qy({walletconnect2:{WC_PROJECT_ID:e?.walletConnectProjectId||"",DISABLE_MODAL_AND_OPEN_LINK:e?.walletConnectListedDesktopWalletLink},selectedProviders:t,trezor:e?.trezorManifest?{manifest:e.trezorManifest}:void 0});if(t){let n=[];return t.forEach(r=>{if(typeof r=="string"){let a=o.find(s=>s.config.type===r);a?n.push(a):console.warn(`Couldn't find ${r} provider. Please make sure you are passing the correct name.`)}else n.push(r)}),n}return o}i(Cr,"matchAndGenerateProviders");function sc(t,e){return Cr(t,e).map(r=>r.config.type)}i(sc,"configWalletsToWalletName");var Xy=Object.values(Lo);function ft(t){let{chain:e}=t||{},{config:o}=y(),{state:n,getWalletInfo:r}=Hy(),{connectedWallets:a}=Z(),s=y().blockchains(),{handleDisconnect:l}=Ht(),p=sc(o?.wallets,{trezorManifest:o?.trezorManifest,walletConnectProjectId:o?.walletConnectProjectId,walletConnectListedDesktopWalletLink:o.__UNSTABLE_OR_INTERNAL__?.walletConnectListedDesktopWalletLink})||Xy,u=Np(n,r,p,e);u=Gy()?u.filter(h=>h.showOnMobile!==!1&&n(h.type).installed):u;let c=Dp(u),m=i(h=>!a.find(k=>k.walletType===h&&k.chain===e),"isExperimentalChainNotAdded"),f=Ky(()=>{let h=u?.filter(k=>k.state===Sa.CONNECTING)||[];for(let k of h)l(k.type)},[Fp(u)]);jy(()=>()=>{f()},[]);let g=i(h=>{let k=h.find(C=>C.type===Lo.DEFAULT);return!k||k.state===Sa.NOT_INSTALLED?!1:h.filter(C=>C.state!=Sa.NOT_INSTALLED&&![Lo.DEFAULT,Lo.WALLET_CONNECT_2,Lo.LEDGER].includes(C.type)&&r(C.type).supportedChains.filter(T=>T.type=="EVM").length>0).length==0},"shouldShowDefaultInjectedWallet"),d=i((h,k,S)=>ur(S,k)&&m(h)&&!Vy.includes(h)||h==Lo.DEFAULT&&!g(u),"shouldExcludeWallet");return{list:c.filter(h=>!d(h.type,e??"",s)),terminateConnectingWallets:f}}i(ft,"useWalletList");import{Modal as Jy}from"@rango-dev/ui";import Ry from"react";import{create as Zy}from"zustand";var lc="rango-widget";var cn=class{constructor(e){this.state="not-initiated";this.events={};this.init=()=>{this.initEvents(),this.tryClaim()};this.forceClaim=()=>{if(!this.isClaimed()){let e={name:"force-claim",candidateId:this.tabId};this.channel.postMessage(e),setTimeout(()=>{this.isClaimed()||this.claim()},300)}};this.isClaimed=()=>this.state==="claimed";this.destroy=()=>{this.channel.removeEventListener("message",this.handleMessageEvent),document.removeEventListener("visibilitychange",this.handleVisibilityChange),document.removeEventListener("resume",this.handleResume)};this.handleMessageEvent=e=>{let o=e.data.name;switch(o){case"ping":this.claimedByCurrentTab(e.data.pingAt);break;case"pong":this.alreadyClaimedByAnotherTab();break;case"force-claim":this.forceRelease(e.data.candidateId);break;case"force-release":this.tabId===e.data.candidateId&&this.claim();break;default:throw new Error(`${o} is not supported.`)}};this.handleVisibilityChange=async()=>{document.visibilityState==="visible"&&await this.tryClaim()};this.handleResume=async()=>{this.isClaimed()&&(await this.tryClaim(),this.isClaimed()||this.events.onRelease?.())};this.channel=new BroadcastChannel(lc),this.tabId=Math.trunc(Math.random()*1e5),this.events=e}static{i(this,"TabManager")}initEvents(){this.channel.addEventListener("message",this.handleMessageEvent),document.addEventListener("visibilitychange",this.handleVisibilityChange),document.addEventListener("resume",this.handleResume)}claimedByCurrentTab(e){let o=this.lastTryClaim&&this.lastTryClaim<e;if(this.isClaimed()||o){let n={name:"pong"};this.channel.postMessage(n);return}}alreadyClaimedByAnotherTab(){this.resetLastCheck()}async tryClaim(){return this.setLastCheck(),new Promise(e=>{setTimeout(()=>{this.check(),e()},300)})}check(){this.state==="not-initiated"&&this.events.onInit?.(),this.lastTryClaim?(this.claim(),this.resetLastCheck()):this.state="not-claimed"}claim(){this.state="claimed",this.events.onClaim?.()}setLastCheck(){this.lastTryClaim=Date.now();let e={name:"ping",pingAt:this.lastTryClaim};this.channel.postMessage(e)}resetLastCheck(){this.lastTryClaim=void 0}forceRelease(e){if(this.isClaimed()){this.state="not-claimed",this.events.onRelease?.();let o={name:"force-release",candidateId:e};this.channel.postMessage(o)}}};var se=Gt(Zy()((t,e)=>({isActiveTab:!1,tabManagerInitiated:!1,showActivateTabModal:!1,watermark:"NONE",fetchingApiConfig:!1,activateCurrentTab:(o,n)=>{let{showActivateTabModal:r}=e();!r&&n?t({showActivateTabModal:!0}):(r||!n)&&o()},setShowActivateTabModal:o=>{t({showActivateTabModal:o})},setWatermark:o=>{t({watermark:o})}}))),lo=new cn({onInit:()=>se.setState({tabManagerInitiated:!0}),onClaim:()=>se.setState({isActiveTab:!0,showActivateTabModal:!1}),onRelease:()=>se.setState({isActiveTab:!1})});function J(t){let{watermark:e}=se();return Ry.createElement(Jy,{hasWatermark:e==="FULL",...t},t.children)}i(J,"WatermarkedModal");import{i18n as Ca}from"@lingui/core";import{Button as iS,Checkbox as aS,Divider as sS,Image as Sc,ListItemButton as lS,MessageBox as pS,Radio as cS,RadioRoot as uS}from"@rango-dev/ui";import{namespaces as Cc}from"@rango-dev/wallets-shared";import we,{useMemo as mS,useState as dS}from"react";import{css as eS,darkTheme as cc,IconButton as tS,styled as po}from"@rango-dev/ui";var It=po(tS,{width:"$24",position:"relative",padding:"0",overflow:"unset","&:hover":{backgroundColor:"$secondary100",[`.${cc} &`]:{backgroundColor:"$neutral"}}}),uc=po("div",{position:"absolute",background:"$secondary500",[`.${cc} &`]:{$$color:"$colors$secondary250"},width:"$6",height:"$6",borderRadius:"$lg",right:"$4",border:"1px solid $surface100"}),Vt=po("div",{display:"flex",justifyContent:"flex-end",minWidth:"$40",button:{padding:0}}),mc=po("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"}}}}),dc=po("div",{padding:"$2",variants:{isRefetched:{true:{transform:"rotate(360deg)",transition:"transform 1s ease-in-out"}}}}),fc=po("div",{position:"absolute",right:"$4",top:"$4",backgroundColor:"$background",borderRadius:"100%"}),gc=eS({display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center"}),kr=po("div",{borderRadius:"100%",border:"1.5px transparent solid","&:not(:first-child)":{marginLeft:"-$6"},img:{borderRadius:"100%"}});import{keyframes as oS,styled as Tr}from"@rango-dev/ui";var HA=Tr("div",{borderRadius:"$lg",width:"$45",height:"$45",backgroundColor:"$success300",display:"flex",justifyContent:"center",alignItems:"center"}),Bo=Tr("div",{position:"relative"}),nS=oS({"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:`${nS} 1s linear infinite`,top:0,bottom:0,right:0,left:0}),vr=Tr("div",{"& img":{borderRadius:"50%"}});function hc(t,e){return t.find(o=>o.name===e)?.logo}i(hc,"getBlockchainLogo");import{styled as rS}from"@rango-dev/ui";var yc=rS("ul",{padding:0,paddingTop:"$4",paddingBottom:"$4"});function un(t){let{singleNamespace:e,availableNamespaces:o,providerImage:n}=t.value,[r,a]=dS([]),s=y().blockchains(),l=mS(()=>o?.map(c=>({name:c,logo:hc(s,Cc[c].mainBlockchain),title:Cc[c].title})),[o]),p=i(c=>{a(e?[c]:m=>m.includes(c)?m.filter(f=>f!==c):m.concat(c))},"onSelect"),u=i(c=>e?we.createElement(uS,{value:r?.[0]},c):we.createElement(we.Fragment,null,c),"wrapRadioRoot");return we.createElement(we.Fragment,null,we.createElement(sS,{size:20}),we.createElement(pS,{type:"info",title:Ca.t("Select chain types"),description:Ca.t("This wallet supports multiple chains. Select which chain you'd like to connect to."),icon:we.createElement(Bo,null,we.createElement(kr,null,we.createElement(Sc,{src:n,size:45})),we.createElement(Po,null))}),we.createElement(yc,null,u(we.createElement(we.Fragment,null,l?.map(c=>we.createElement(lS,{key:c.name,id:c.name,title:c.title,hasDivider:!0,style:{height:60},onClick:()=>p(c.name),start:we.createElement(Sc,{src:c.logo,size:22}),end:e?we.createElement(cS,{value:c.name}):we.createElement(aS,{checked:r.includes(c.name)})}))))),we.createElement(iS,{id:"widget-name-space-confirm-btn",type:"primary",disabled:!r.length,onClick:()=>t.onConfirm(r)},Ca.t("Confirm")))}i(un,"Namespaces");import{i18n as Do}from"@lingui/core";import{Button as hS,Divider as vc,Image as yS,MessageBox as SS,Select as CS,TextField as kS}from"@rango-dev/ui";import ze,{useEffect as TS,useState as wc}from"react";import{namespaces as fS}from"@rango-dev/wallets-shared";var wr={id:"custom",label:"Custom",generateDerivationPath:t=>t};function ka(t){let e=t?fS[t].derivationPaths:null;return e?[...e,wr]:[]}i(ka,"getDerivationPaths");import{styled as kc,Typography as gS}from"@rango-dev/ui";var Tc=kc("div",{paddingTop:"$30",paddingBottom:"$30",zIndex:10}),Ta=kc(gS,{paddingLeft:"$10"}),va={height:"$40",backgroundColor:"$neutral200",borderRadius:"$sm"};var bc="0";function mn(t){let{onConfirm:e}=t,{namespace:o,providerImage:n,providerType:r}=t.value,[a,s]=wc(null),[l,p]=wc(bc),u=a===wr.id,c=ka(o),m=i(({value:g})=>{let d=c?.find(h=>h.id===g);d&&(a===wr.id&&Number.isNaN(Number(l))&&p(bc),s(d.id))},"handleDerivationPathItemClick"),f=i(()=>{let g=c.find(d=>d.id===a);if(g)e(g.generateDerivationPath(l));else throw new Error("selectedDerivationPath can not be undefined")},"handleConfirm");return TS(()=>{s(ka(o)[0]?.id||null)},[o]),ze.createElement(ze.Fragment,null,ze.createElement(vc,{size:20}),ze.createElement(SS,{type:"info",title:Do.t("Select Derivation Path"),description:Do.t({id:"In order to connect to {type}, you must first select a Derivation Path",values:{type:r}}),icon:ze.createElement(Bo,null,ze.createElement(vr,null,ze.createElement(yS,{src:n,size:45})),ze.createElement(Po,null))}),ze.createElement(Tc,null,ze.createElement(Ta,{variant:"body",size:"xsmall",color:"$neutral600"},Do.t("Choose Derivation Path Template")),ze.createElement(CS,{value:a||"",options:c.map(g=>({value:g.id,label:g.label})),variant:"filled",handleItemClick:m,styles:{trigger:va}}),ze.createElement(vc,{size:20}),ze.createElement(Ta,{variant:"body",size:"xsmall",color:"$neutral600"},u?Do.t("Enter Path"):Do.t("Enter Index")),ze.createElement(kS,{type:u?"text":"number",variant:"contained",value:l,onChange:g=>p(g.target.value),style:va})),ze.createElement(hS,{id:"widget-derivation-path-confirm-btn",type:"primary",onClick:f,disabled:!c||!a||!l},Do.t("Confirm")))}i(mn,"DerivationPath");import{i18n as _o}from"@lingui/core";import{Image as vS,MessageBox as wa,WalletState as wS}from"@rango-dev/ui";import{useWallets as bS}from"@rango-dev/wallets-react";import co from"react";function ba(t){let{wallet:e,error:o}=t,{type:n,image:r}=e,{state:a}=bS();return pn(a(n))===wS.CONNECTED?co.createElement(wa,{type:"success",title:_o.t("Wallet Connected"),description:_o.t("Your wallet is connected, you can use it to swap.")}):o?co.createElement(wa,{type:"error",title:_o.t("Failed to Connect"),description:o||_o.t("Your wallet is not connected. Please try again.")}):co.createElement(wa,{type:"loading",title:_o.t("Connecting to your wallet"),description:_o.t("Click connect in your wallet popup."),icon:co.createElement(Bo,null,co.createElement(vr,null,co.createElement(vS,{src:r,size:45})),co.createElement(Po,null))})}i(ba,"ConnectStatus");import{i18n as xa}from"@lingui/core";import{Button as xS,Divider as xc,MessageBox as ES}from"@rango-dev/ui";import br from"react";function Ea(t){let{displayName:e,onConfirm:o}=t;return br.createElement(ES,{title:xa.t({id:"Add {blockchainDisplayName} Chain",values:{blockchainDisplayName:e}}),type:"warning",description:xa.t({id:"Would you like to add the {blockchainDisplayName} experimental chain to your wallet?",values:{blockchainDisplayName:e}})},br.createElement(xc,{size:18}),br.createElement(xc,{size:32}),br.createElement(xS,{id:"widget-experimental-chain-confirm-btn",onClick:o,variant:"outlined",type:"primary",fullWidth:!0,size:"large"},xa.t("Confirm")))}i(Ea,"ExperimentalChain");function Ec(t,e){return t().status==="init"&&!!e}i(Ec,"isOnStatus");function dn(t){return t().status==="namespace"}i(dn,"isOnNamespace");function fn(t){return t().status==="derivationPath"}i(fn,"isOnDerivationPath");var WS=3e3,MS=300;function mo(t){let e=NS(),[o,n]=Ic(!1),[r,a]=Ic(),s=i(S=>{a(S.message)},"catchErrorOnHandle"),{terminateConnectingWallets:l}=ft(),{handleConnect:p,handleDerivationPath:u,handleNamespace:c,getState:m,resetState:f}=Ht(),g=i(S=>{c(t.wallet,S).catch(s)},"handleConfirmNamespaces"),d=i(S=>{if(!S)throw new Error("Derivation path is empty. Please make sure you've filled the field correctly.");u(S).catch(s)},"handleDerivationPathConfirm"),h=i(()=>{n(!1)},"handleClosingModal"),k=i(()=>{a(void 0),f(),n(!1),e.current&&clearTimeout(e.current)},"resetModalState");return AS(()=>{if(t.wallet){k();let S=!1,C=!0,T=i(()=>{setTimeout(()=>{C=!1,S||n(!0)},MS)},"beforeConnecting"),v=i(w=>{let A=w.status==="connected",M=["disconnected","disconnected-unhandled"].includes(w.status);["namespace","derivation-path"].includes(w.status)||(S=!0),A&&!C?e.current=setTimeout(h,WS):M&&h(),t.onConnect&&t.onConnect(w)},"afterConnected");T(),p(t.wallet,{disconnectIfConnected:!0}).then(v).catch(s)}},[t.wallet]),uo.createElement(J,{open:o,onClose:h,onExit:()=>{k(),l(),t.onClose&&t.onClose()},container:N()},Ec(m,t.wallet)&&uo.createElement(uo.Fragment,null,uo.createElement(ba,{wallet:{type:t.wallet.type,image:t.wallet.image},error:r}),uo.createElement(IS,{direction:"vertical",size:32})),dn(m)&&uo.createElement(un,{onConfirm:g,value:m().namespace}),fn(m)&&uo.createElement(mn,{onConfirm:d,value:m().derivationPath}))}i(mo,"StatefulConnectModal");import{Events as Aa,Provider as BS}from"@rango-dev/wallets-react";import{isEvmBlockchain as PS}from"rango-sdk";import xr,{createContext as DS,useEffect as Nc,useMemo as _S,useRef as Wc}from"react";import{useEffect as LS}from"react";function Ac(t){return t.map(e=>typeof e=="string"?e:e.config.type).join("-")}i(Ac,"hashProviders");function Ia(t,e){let o=Z.use.clearConnectedWallet(),n=Cr(t,e);return LS(()=>{o(),n=Cr(t,e)},[Ac(t??[]),e?.walletConnectProjectId,e?.walletConnectListedDesktopWalletLink]),{providers:n}}i(Ia,"useWalletProviders");var Er=DS({onConnectWallet:()=>{},onDisconnectWallet:()=>{}});function $S(t){let{updateConfig:e,updateSettings:o,fetch:n,fetchStatus:r}=y(),a=y().blockchains(),{findToken:s}=y(),l=y().config,p={walletConnectProjectId:l?.walletConnectProjectId,trezorManifest:l?.trezorManifest,walletConnectListedDesktopWalletLink:t.config.__UNSTABLE_OR_INTERNAL__?.walletConnectListedDesktopWalletLink},{providers:u}=Ia(l.wallets,p),{connectWallet:c,disconnectWallet:m}=Z(),f=Wc(),g=Wc();Nc(()=>{n().catch(console.log)},[]),Nc(()=>{t.config&&(e(t.config),o(t.config),window.__rango={config:l,dappConfig:t.config})},[t.config,r]);let d=a.filter(PS).map(C=>C.name),h=i((C,T,v,w,A)=>{if(T===Aa.ACCOUNTS)if(v){let M=pr(A.supportedBlockchains),b=Wp(C,v,d,M,A.isContractWallet);b.length&&c(b,s)}else m(C),g.current?g.current(C):console.warn("onDisconnectWallet handler hasn't been set. Are you sure?");if(T===Aa.ACCOUNTS&&w.connected){let M=`${C}-${w.network}-${v}`;w.connected&&(f.current?f.current(M):console.warn("onConnectWallet handler hasn't been set. Are you sure?"))}if(T===Aa.NETWORK&&w.network){let M=`${C}-${w.network}`;f.current?f.current(M):console.warn("onConnectWallet handler hasn't been set. Are you sure?")}t.onUpdateState&&t.onUpdateState(C,T,v,w,A)},"onUpdateState"),k=se.use.isActiveTab(),S=_S(()=>({onConnectWallet:C=>{f.current=C},onDisconnectWallet:C=>{g.current=C}}),[]);return xr.createElement(Er.Provider,{value:S},xr.createElement(BS,{allBlockChains:a,providers:u,onUpdateState:h,autoConnect:!!k},t.children))}i($S,"Main");function Ir(t){let{config:e,...o}=t;return xr.createElement(ic,{config:e},xr.createElement($S,{...o,config:e}))}i(Ir,"WidgetWallets");import Ri from"react";import FS,{Fragment as OS}from"react";import{MemoryRouter as US,useInRouterContext as zS}from"react-router";function Mc({children:t}){let o=zS()?OS:US;return FS.createElement(o,null,t)}i(Mc,"AppRouter");import{I18nManager as CE}from"@rango-dev/ui";import rp from"react";import De from"react";import{useRoutes as iE}from"react-router-dom";var D={home:"/",fromSwap:"from-swap",toSwap:"to-swap",blockchains:"blockchains",settings:"settings",customTokens:"custom-tokens",addCustomTokens:"add-custom-tokens",liquiditySources:"liquidity-sources",bridges:"bridges",exchanges:"exchanges",languages:"languages",swaps:"swaps",wallets:"wallets",confirmSwap:"confirm-swap",swapDetails:":requestId",routes:"routes"};import{useEffect as Oo,useRef as _r}from"react";import Xe from"bignumber.js";import{create as HS}from"zustand";import{subscribeWithSelector as GS}from"zustand/middleware";import{getLastSuccessfulStep as qS}from"@rango-dev/queue-manager-rango-preset";import JW from"bignumber.js";function Na(t,e){return{"Network Fee":e("Network Fee"),"Swapper Fee":e("Protocol Fee"),"Affiliate Fee":e("Affiliate Fee"),"Outbound network fee":e("Outbound Fee"),"Rango Fee":e("Rango Fee")}[t]}i(Na,"getFeeLabel");var Wa=["RECOMMENDED","CENTRALIZED","LOWEST_FEE","FASTEST","HIGH_IMPACT"],Lc=30;import{i18n as gt}from"@lingui/core";import{RouteEventType as $W}from"@rango-dev/queue-manager-rango-preset";import Qe from"bignumber.js";import{PendingSwapNetworkStatus as Nr}from"rango-types";import{i18n as Fe}from"@lingui/core";var te=i(()=>({genericServerError:Fe.t("Failed Network, Please retry your swap."),liquiditySourcesError:{title:Fe.t("Please reset your liquidity sources."),description:Fe.t("You have limited the liquidity sources and this might result in Rango finding no routes. Please consider resetting your liquidity sources.")},noResultError:{title:Fe.t("No Routes Found."),description:Fe.t("Reasons why Rango couldn't find a route: low liquidity on token, very low input amount or no routes available for the selected input/output token combination.")},bridgeLimitErrors:{increaseAmount:Fe.t("Bridge Limit Error: Please increase your amount."),decreaseAmount:Fe.t("Bridge Limit Error: Please decrease your amount.")},highValueLossError:{impactTitle:Fe.t("High Price Impact"),title:Fe.t("Price impact is too high!"),description:Fe.t("The price impact is significantly higher than the allowed amount."),confirmMessage:Fe.t("Confirm high price impact")},quoteUpdatedWithHighValueLoss:{title:Fe.t("Route updated and price impact is too high, try again later!")},unknownPriceError:{impactTitle:Fe.t("USD Price Unknown"),title:Fe.t("USD Price Unknown, Cannot calculate Price Impact."),description:Fe.t("USD Price Unknown, Cannot calculate Price Impact. The price impact may be higher than usual. Are you sure to continue the Swap?"),confirmMessage:Fe.t("Confirm USD Price Unknown")}}),"errorMessages");function Bc(t){switch(t.type){case 0:return t.diagnosisMessage??te().noResultError.title;case 1:return te().genericServerError;default:return""}}i(Bc,"getQuoteErrorMessage");import{i18n as Ar}from"@lingui/core";var fo=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 Pc(t,e){return(parseInt(e.toFixed(2)||"0")<=-10&&t?.gte(new Qe(400))||parseInt(e.toFixed(2)||"0")<=-5&&t?.gte(new Qe(1e3)))??!1}i(Pc,"hasHighValueLoss");function Dc(t){return(t||[]).filter(e=>{let o=e.fromAmountMinValue?new Qe(e.fromAmountMinValue):null,n=e.fromAmountMaxValue?new Qe(e.fromAmountMaxValue):null;return e.fromAmountRestrictionType==="EXCLUSIVE"?o?.gte(e.fromAmount)||n?.lte(e.fromAmount):o?.gt(e.fromAmount)||n?.lt(e.fromAmount)}).length>0}i(Dc,"hasLimitError");function _c(t){let e=(t||[]).filter(l=>{let p=l.fromAmountMinValue?new Qe(l.fromAmountMinValue):null,u=l.fromAmountMaxValue?new Qe(l.fromAmountMaxValue):null;return l.fromAmountRestrictionType==="EXCLUSIVE"?p?.gte(l.fromAmount)||u?.lte(l.fromAmount):p?.gt(l.fromAmount)||u?.lt(l.fromAmount)})[0],o=e.fromAmountMinValue?new Qe(e.fromAmountMinValue):null,n=e.fromAmountMaxValue?new Qe(e.fromAmountMaxValue):null,r=e.fromAmountRestrictionType==="EXCLUSIVE",a="",s="";return!r&&o&&o.gt(e.fromAmount)?(a=gt.t({id:"Required: >= {min} {symbol}",values:{min:L(o,6,6),symbol:e.from.symbol}}),s=te().bridgeLimitErrors.increaseAmount):r&&o&&o.gte(e.fromAmount)&&(a=gt.t({id:"Required: > {min} {symbol}",values:{min:L(o,6,6),symbol:e.from.symbol}}),s=te().bridgeLimitErrors.increaseAmount),!r&&n&&n.lt(e.fromAmount)?(a=gt.t({id:"Required: <= {max} {symbol}",values:{max:L(n,6,6),symbol:e.from.symbol}}),s=te().bridgeLimitErrors.decreaseAmount):r&&n&&n.lte(e.fromAmount)&&(a=gt.t({id:"Required: < {max} {symbol}",values:{max:L(n,6,6),symbol:e.from.symbol}}),s=te().bridgeLimitErrors.decreaseAmount),{swap:e,fromAmountRangeError:a,recommendation:s}}i(_c,"getLimitErrorMessage");function $c(t){let{fetchMetaStatus:e,anyWalletConnected:o,fetchingQuote:n,inputAmount:r,quote:a,warning:s,error:l,needsToWarnEthOnPath:p}=t;return e!=="success"?{title:fo().connectWallet,action:"connect-wallet",disabled:!0}:o?n||!a||l||!r||r==="0"?{title:fo().swap,action:"confirm-swap",disabled:!0}:s?{title:fo().swapAnyway,action:"confirm-warning",disabled:!1}:p?{title:fo().ethWarning,action:"confirm-warning",disabled:!1}:{title:fo().swap,action:"confirm-swap",disabled:!1}:{title:fo().connectWallet,action:"connect-wallet",disabled:!1}}i($c,"getSwapButtonState");function Ma(t,e,o){let n=parseFloat(e||"0");return!(t&&(!o||o.lte(Ue))&&e&&e!=="0"&&n!==0)}i(Ma,"canComputePriceImpact");function La(t,e){let o=Ue;for(let n=0;n<t.fee.length;n++){let r=t.fee[n];if(r.expenseType==="DECREASE_FROM_OUTPUT")continue;let a=e(r.asset)?.usdPrice||null;o=o.plus(new Qe(r.amount).multipliedBy(a||0))}return o}i(La,"getUsdFeeOfStep");function Wr(t,e){return t.reduce((o,n)=>o.plus(La(n,e)),Ue)}i(Wr,"getTotalFeeInUsd");function Ba(t){let e=Ue;return e=e.plus(new Qe(t.amount).multipliedBy(t.price||0)),e}i(Ba,"getUsdFee");function Fc(t){return t.reduce((e,o)=>e.plus(Ba(o)),Ue)}i(Fc,"getTotalFeesInUsd");function Oc(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(Oc,"getFeesGroup");function Uc(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(Uc,"checkSlippageErrors");function zc(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(zc,"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 Qc(t,e){return e?parseFloat(t)>=parseFloat(e):!0}i(Qc,"hasProperSlippage");function qc(t){let{fromToken:e,toToken:o,inputAmount:n,wallets:r,selectedWallets:a,disabledLiquiditySources:s,liquiditySources:l,excludeLiquiditySources:p,slippage:u,affiliateRef:c,affiliatePercent:m,affiliateWallets:f,destination:g,enableCentralizedSwappers:d}=t,h=a?.reduce((C,T)=>(C[T.chain]=T.address,C),{}),k=[];return r?.forEach(C=>{k.push({blockchain:C.chain,addresses:[C.address]})}),{amount:n.toString(),affiliateRef:c??void 0,affiliatePercent:m??void 0,affiliateWallets:f??void 0,from:{address:e.address,blockchain:e.blockchain,symbol:e.symbol},to:{address:o.address,blockchain:o.blockchain,symbol:o.symbol},connectedWallets:k,selectedWallets:h??{},slippage:u.toString(),...g&&{destination:g},...p&&{swapperGroups:s.concat(l??[]),swappersGroupsExclude:!0},...!p&&{swapperGroups:l?.filter(C=>!s.includes(C)),swappersGroupsExclude:!1},enableCentralizedSwappers:d}}i(qc,"createQuoteRequestBody");function Hc(t){return t.reduce((o,n)=>(o[n.chain]={address:n.address,walletType:n.walletType},o),{})}i(Hc,"getWalletsForNewSwap");function $o(t){return t?.outputAmount||null}i($o,"getQuoteOutputAmount");function Gc(t,e){return new Qe(e).div(new Qe(t)).minus(1).multipliedBy(100).toNumber()}i(Gc,"getPercentageChange");function Vc(t,e){let o=$o(t),n=$o(e);if(!o||!n)return!1;let r=ct(o,n);return r?r<=-1:!0}i(Vc,"isOutputAmountChangedALot");function Kc(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=>Rc(s,n)||[]).filter(s=>!s.ok).map(s=>{let l=s.asset.symbol,p=L(new Qe(s.currentAmount.amount).shiftedBy(-s.currentAmount.decimals),8,8),u=L(new Qe(s.requiredAmount.amount).shiftedBy(-s.requiredAmount.decimals),8,8),c="";return s.reason==="FEE"&&(c=gt.t(" for network fee")),s.reason==="INPUT_ASSET"&&(c=gt.t(" for swap")),s.reason==="FEE_AND_INPUT_ASSET"&&(c=gt.t(" for input and network fee")),gt.t({id:"Needs \u2248 {requiredAmount} {symbol}{reason}, but you have {currentAmount} {symbol} in your {blockchain} wallet.",values:{requiredAmount:u,symbol:l,reason:c,currentAmount:p,blockchain:pt(s.asset.blockchain,o)}})})}i(Kc,"generateBalanceWarnings");function jt(t,e){return(t?new Qe(t):Ue).multipliedBy(e||0)}i(jt,"calcOutputUsdValue");function gn(t){return!!t&&t.networkStatus!==null&&t.networkStatus!==Nr.NetworkChanged}i(gn,"isNetworkStatusInWarningState");function jc(t,e){let o="bellow button or",n=t.extraMessage,r=t.extraMessageDetail;if(t.networkStatusExtraMessageDetail?.includes(o)&&(t.networkStatusExtraMessageDetail=t.networkStatusExtraMessageDetail.replace(o,"")),gn(e))switch(n=t.networkStatusExtraMessage||"",r=t.networkStatusExtraMessageDetail||"",e?.networkStatus){case Nr.WaitingForConnectingWallet:n=n||gt.t("Waiting for connecting wallet");break;case Nr.WaitingForQueue:n=n||gt.t("Waiting for other running tasks to be finished");break;case Nr.WaitingForNetworkChange:n=n||gt.t("Waiting for changing wallet network");break;default:n=n||"";break}r=r||"",n=n||"";let s=n?.indexOf("code")!==-1&&n?.indexOf("reason")!==-1;return{shortMessage:n,detailedMessage:{content:r,long:s}}}i(jc,"getSwapMessages");function Xc(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(Xc,"getLastConvertedTokenInFailedSwap");function Yc(t){return t.status==="failed"}i(Yc,"shouldRetrySwap");function Zc(t,e,o,n,r,a){if(!n||t)return!0;let s=io({filter:"all",quote:n}),l=io({filter:"required",quote:n}),p=s.every(m=>r.some(f=>f.chain===m)),u=l.every(m=>r.some(f=>f.chain===m)),c=o&&a?No(a,o):!1;return!e&&!p||e&&!o||e&&!!o&&(!c||!u)}i(Zc,"isConfirmSwapDisabled");function Jc(t,e){return t.blockchain===e.blockchain&&t.symbol===e.symbol&&t.address===e.address}i(Jc,"isTokensIdentical");function go(t){let e=t?.swaps||[];return e[e.length-1].to.usdPrice}i(go,"getQuoteToTokenUsdPrice");function hn(t){return(t?.swaps||[])[0].from.usdPrice}i(hn,"getQuoteFromTokenUsdPrice");function Pa(t,e){let o=t?.swaps||[],n=e?.swaps||[];return o.length!==n.length}i(Pa,"isNumberOfSwapsChanged");function Da(t,e){let o=t?.swaps.map(r=>r.swapperId)||[],n=e?.swaps.map(r=>r.swapperId)||[];return!pa(o,n)}i(Da,"isQuoteSwappersUpdated");function _a(t,e){let o=t?.swaps.map(r=>r.to.symbol)||[],n=e?.swaps.map(r=>r.to.symbol)||[];return!pa(o,n)}i(_a,"isQuoteInternalCoinsUpdated");function tu(t,e){return Pa(t,e)||Da(t,e)||_a(t,e)}i(tu,"isQuoteChanged");function Rc(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(Rc,"getRequiredBalanceOfWallet");function Pt(t){let e;return t<=-3&&t>-10?e="low":t<=-10&&(e="high"),e}i(Pt,"getPriceImpactLevel");function Br(t,e,o){let n=t.steps[0],r=t.steps[t.steps.length-1],a=qS(t.steps),s={blockchain:r.toBlockchain,symbol:r.toSymbol,address:r.toSymbolAddress},l=nn(a?a.toBlockchain:n.fromBlockchain,e),p=nn(r.toBlockchain,e),u=o(a?{blockchain:l?.name??"",symbol:a.toSymbol,address:a.toSymbolAddress}:{blockchain:l?.name??"",symbol:n.fromSymbol,address:n.fromSymbolAddress}),c=o(s),m=a?a.outputAmount??"":t.inputAmount;return{fromBlockchain:l,fromToken:u,toBlockchain:p,toToken:c,inputAmount:m}}i(Br,"createRetryQuote");function Fo(t,e){let{fromToken:o,toToken:n,findToken:r,userSlippage:a}=e,s=jt(t.requestAmount,hn(t)||o?.usdPrice),l=jt(t.outputAmount,go(t)||n?.usdPrice);if(t&&s&&l){let c=ct(s.toString(),l.toString());if(!!c&&Pc(s,c)){let f=Wr(t?.swaps,r),g=Pt(c);return{type:0,inputUsdValue:s,outputUsdValue:l,priceImpact:c,totalFee:f,warningLevel:g}}}else if(t&&(!s||!l))return{type:1};let p=Mr(t.swaps),u=a>Rp;if(Qc(e.userSlippage.toString(),p)){if(u&&parseFloat(p??"0")<a)return{type:3,slippage:a.toString()}}else return{type:2,recommendedSlippages:zc(t,a),minRequiredSlippage:p};return null}i(Fo,"generateQuoteWarnings");function ct(t,e){let o=typeof e=="string"?parseFloat(e)<=0:!e?.gt(0),n=!t||!e||o?null:Gc(t.toString(),e.toString());return n&&n<0?n:null}i(ct,"getPriceImpact");var ou=i(t=>{let e=new Set,o=[];return t.forEach(n=>{e.has(n.from.chain.displayName)||(e.add(n.from.chain.displayName),o.push(n.from.chain)),e.has(n.to.chain.displayName)||(e.add(n.to.chain.displayName),o.push(n.to.chain))}),o},"getUniqueBlockchains"),Pr=i((t,e)=>e.sort((o,n)=>{let r=i(u=>u.scores?.find(c=>c.preferenceType===t)?.score??0,"getScore"),a=r(o),s=r(n);if(a!==s)return s-a;let l=o.requestId.toLowerCase(),p=n.requestId.toLowerCase();return l.localeCompare(p)}),"sortQuotesBy"),nu=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"),ru=i(t=>{let e=i((o,n)=>{let r=Wa.indexOf(o.value),a=Wa.indexOf(n.value);return r!==-1&&a!==-1?r-a:r!==-1?-1:a!==-1?1:0},"customSort");return t.sort(e)},"sortTags");var Dr=i((t,e)=>t?.usdPrice?new Xe(e||Ue).multipliedBy(t?.usdPrice||0):null,"getUsdValue"),z=Gt(HS()(GS(t=>({fromBlockchain:null,fromToken:null,inputAmount:"",outputAmount:null,inputUsdValue:new Xe(0),outputUsdValue:new Xe(0),toBlockchain:null,toToken:null,refetchQuote:!0,sortStrategy:"SMART",selectedQuote:null,quotes:null,error:null,warning:null,quoteWalletsConfirmed:!1,selectedWallets:[],customDestination:null,quoteWarningsConfirmed:!1,updateQuotePartialState:(e,o)=>t(n=>({...n,[e]:o})),setSelectedQuote:e=>t(o=>{let n=null,r=Ue,a=o.inputUsdValue;return ln(o.inputAmount)?(e&&(n=e?.outputAmount?new Xe(e?.outputAmount):null,a=jt(o.inputAmount,hn(e)||o.fromToken?.usdPrice),r=jt(e.outputAmount,go(e)||o.toToken?.usdPrice)),{selectedQuote:e,...!!e&&{outputAmount:n,outputUsdValue:r,inputUsdValue:a}}):{}}),resetAlerts:()=>t(()=>({error:null,warning:null})),resetQuote:()=>t(()=>({selectedQuote:null,outputAmount:null,outputUsdValue:new Xe(0),quotes:null,refetchQuote:!0,error:null,warning:null})),setFromBlockchain:e=>{t(o=>o.fromBlockchain?.name===e?.name?{}:{fromBlockchain:e,inputUsdValue:new Xe(0),...o.fromToken&&{selectedQuote:null,fromToken:null,outputAmount:null,outputUsdValue:new Xe(0)}})},setFromToken:e=>t(o=>({fromToken:e.token,...e.token&&{fromBlockchain:e.meta.blockchains.find(n=>n.name===e.token.blockchain)??null},...!!o.inputAmount&&{inputUsdValue:Dr(e.token,o.inputAmount)}})),setToBlockchain:e=>{t(o=>o.toBlockchain?.name===e?.name?{}:{toBlockchain:e,...o.toToken&&{selectedQuote:null,toToken:null,outputAmount:null,outputUsdValue:new Xe(0)}})},setToToken:e=>t(()=>({toToken:e.token,...e.token&&{toBlockchain:e.meta.blockchains.find(o=>o.name===e.token.blockchain)??null}})),setInputAmount:e=>{t(o=>({inputAmount:e,...!e&&{outputAmount:null,outputUsdValue:new Xe(0),selectedQuote:null},...!!o.fromToken&&{inputUsdValue:Dr(o.fromToken,e)}}))},retry:e=>{let{fromBlockchain:o,fromToken:n,toBlockchain:r,toToken:a,inputAmount:s}=e;t({fromBlockchain:o,fromToken:n,inputAmount:s,outputAmount:null,inputUsdValue:Dr(n??null,s),outputUsdValue:new Xe(0),toBlockchain:r,toToken:a,selectedQuote:null})},switchFromAndTo:()=>t(e=>({fromBlockchain:e.toBlockchain,fromToken:e.toToken,toBlockchain:e.fromBlockchain,toToken:e.fromToken,inputAmount:e.outputAmount?.toString()||"",inputUsdValue:e.toToken?Dr(e.toToken,e.outputAmount?.toString()||""):new Xe(0)})),resetFromBlockchain:()=>t(()=>({fromToken:null,fromBlockchain:null,outputUsdValue:new Xe(0),inputUsdValue:new Xe(0),inputAmount:"",outputAmount:null,selectedQuote:null})),resetToBlockchain:()=>t(()=>({toToken:null,toBlockchain:null,outputAmount:null,outputUsdValue:new Xe(0),selectedQuote:null})),setQuoteWalletConfirmed:e=>t({quoteWalletsConfirmed:e}),setSelectedWallets:e=>t({selectedWallets:e}),setCustomDestination:e=>t({customDestination:e}),resetQuoteWallets:()=>t({quoteWalletsConfirmed:!1,selectedWallets:[],customDestination:null}),setQuoteWarningsConfirmed:e=>t({quoteWarningsConfirmed:e})})))),iu=z.subscribe((t,e)=>{(t.fromBlockchain!==e.fromBlockchain||t.fromToken!==e.fromToken||t.toBlockchain!==e.toBlockchain||t.toToken!==e.toToken||t.inputAmount!==e.inputAmount)&&ye.emit("quoteEvent",{type:"quoteInputUpdate",payload:{fromBlockchain:t.fromBlockchain?.name,toBlockchain:t.toBlockchain?.name,fromToken:t.fromToken?{symbol:t.fromToken.symbol,name:t.fromToken.name,address:t.fromToken.address}:void 0,toToken:t.toToken?{symbol:t.toToken.symbol,name:t.toToken.name,address:t.toToken.address}:void 0,requestAmount:t.inputAmount}}),t.selectedQuote?.requestId!==e.selectedQuote?.requestId&&ye.emit("quoteEvent",{type:"quoteOutputUpdate",payload:t.selectedQuote?{requestAmount:t.selectedQuote.requestAmount,swaps:t.selectedQuote.swaps,outputAmount:t.selectedQuote.outputAmount,resultType:t.selectedQuote.resultType,tags:t.selectedQuote.tags}:null})});function au(){let{setInputAmount:t,setToToken:e,setToBlockchain:o,setFromBlockchain:n,resetQuote:r,setFromToken:a,fromToken:s,toToken:l,fromBlockchain:p,toBlockchain:u}=z(),c=y().config,m=y().fetchStatus,f=y().blockchains(),g=y().tokens(),{findToken:d}=y(),{setAffiliateRef:h,setAffiliatePercent:k,setAffiliateWallets:S}=y(),C=c?.from?.tokens,T=c?.from?.blockchains,v=c?.to?.tokens,w=c?.to?.blockchains,A=_r(void 0),M=_r(void 0),b=_r(void 0),E=_r(void 0);Oo(()=>{typeof c.amount<"u"&&t(c.amount.toString())},[c?.amount]),Oo(()=>{if(m==="success"){r();let x=f.find(I=>I.name===c?.from?.blockchain),W=c?.from?.token,$=W&&d(W);(x||!x&&b.current)&&n(x??null),$?a({token:$,meta:{blockchains:f,tokens:g}}):!$&&A.current&&a({token:null}),b.current=c?.from?.blockchain,A.current=c?.from?.token}},[c?.from?.token?.symbol,c?.from?.token?.address,c?.from?.token?.blockchain,c?.from?.blockchain,m]),Oo(()=>{da(s,C)&&a({token:null}),fa(p,T)&&n(null)},[C,T]),Oo(()=>{da(l,v)&&a({token:null}),fa(u,w)&&o(null)},[v,w]),Oo(()=>{if(m==="success"){r();let x=f.find(I=>I.name===c?.to?.blockchain),W=c?.to?.token,$=W&&d(W);(x||!x&&E.current)&&o(x??null),$?e({token:$,meta:{blockchains:f,tokens:g}}):!$&&M.current&&e({token:null}),E.current=c?.to?.blockchain,M.current=c?.to?.token}},[c?.to?.token?.symbol,c?.to?.token?.address,c?.to?.token?.blockchain,c?.to?.blockchain,m]),Oo(()=>{h(c?.affiliate?.ref??null),k(c?.affiliate?.percent??null),S(c?.affiliate?.wallets??null)},[c?.affiliate?.ref,c?.affiliate?.percent,c?.affiliate?.wallets])}i(au,"useSyncStoresWithConfig");import{useEffect as Oa,useRef as VS}from"react";import{useInRouterContext as KS,useLocation as jS,useSearchParams as XS}from"react-router-dom";function $a(t,e){let o=t.split("--");return{blockchain:e.name,address:o?.[1]||null,symbol:o[0]}}i($a,"convertTokenSearchParamToAsset");function Fa(t){if(t)return`${t.symbol}${t.address?`--${t.address}`:""}`}i(Fa,"tokenToSearchParam");function za(){let t=jS(),[e,o]=XS(),{fromBlockchain:n,toBlockchain:r,fromToken:a,toToken:s,inputAmount:l,setFromBlockchain:p,setToBlockchain:u,setFromToken:c,setToToken:m,setInputAmount:f}=z(),g=y().fetchStatus,d=y().blockchains(),h=y().tokens(),k=KS(),{updateIframe:S,updateCampaignMode:C}=y(),T=y().isInCampaignMode(),v=VS(),{findToken:w}=y(),A=i(()=>{let b={};for(let[V,le]of e.entries())V.startsWith("utm_")&&(b[V]=le);let E=e.get("fromAmount"),x=e.get("fromBlockchain"),W=e.get("fromToken"),$=e.get("toBlockchain"),I=e.get("toToken"),R=e.get("autoConnect"),ee=e.get("clientUrl"),oe=e.get("liquiditySources"),B=e.get("blockchain");return{fromAmount:E,fromBlockchain:x,fromToken:W,toBlockchain:$,toToken:I,autoConnect:R,clientUrl:ee,liquiditySources:oe,utmQueryParams:b,blockchain:B}},"getUrlSearchParams"),M=i(b=>{for(let E in b)b[E]||delete b[E];o(b,{replace:!0})},"updateUrlSearchParams");Oa(()=>{let{autoConnect:b,clientUrl:E,utmQueryParams:x,blockchain:W}=A();k&&g==="success"&&M({fromBlockchain:n?.name,fromToken:Fa(a),toBlockchain:r?.name,toToken:Fa(s),fromAmount:l,autoConnect:b??void 0,clientUrl:E??void 0,blockchain:W??void 0,liquiditySources:T?v.current:void 0,...x})},[t.pathname,l,n,a,r,s,T]),Oa(()=>{if(!k)return;let b=A();if(!v.current&&b.liquiditySources&&(v.current=b.liquiditySources),b.fromAmount&&f(b.fromAmount),g==="success"){let E=d.find(I=>I.name===b.fromBlockchain),x=b.fromToken&&E?w($a(b.fromToken,E)):void 0,W=d.find(I=>I.name===b.toBlockchain),$=b.toToken&&W?w($a(b.toToken,W)):void 0;E&&(p(E),x&&c({token:x,meta:{blockchains:d,tokens:h}})),W&&(u(W),$&&m({token:$,meta:{blockchains:d,tokens:h}}))}},[g]),Oa(()=>{let{clientUrl:b,liquiditySources:E}=A();S("clientUrl",b||void 0),C("liquiditySources",E?.split(",")??void 0)},[])}i(za,"useSyncUrlAndStore");import{i18n as At}from"@lingui/core";import{Alert as pk,Button as Uu,darkTheme as ck,Divider as Cn,DoneIcon as uk,MessageBox as mk,styled as dk,TextField as fk,Typography as gk}from"@rango-dev/ui";import Se,{useEffect as hk,useState as qr}from"react";import{useNavigate as yk,useSearchParams as Sk}from"react-router-dom";import{ChevronRightIcon as YS,Divider as uu,Image as ZS,Typography as mu}from"@rango-dev/ui";import ht from"react";import{darkTheme as su,styled as Qa}from"@rango-dev/ui";var lu=Qa("div",{display:"flex",justifyContent:"space-between",width:"100%",height:"$40",padding:"$4 $10",borderRadius:"$sm",cursor:"pointer",alignItems:"center",backgroundColor:"$neutral300",[`.${su} &`]:{backgroundColor:"$neutral400"},"&:hover":{backgroundColor:"$secondary100",[`.${su} &`]:{backgroundColor:"$neutral500"}},variants:{disabled:{true:{cursor:"default","&:hover":{borderColor:"$neutral300","& svg":{color:"$neutral700"}}}}}}),pu=Qa("div",{display:"flex",flexDirection:"column",width:"100%",".title_typography":{textTransform:"capitalize"}}),cu=Qa("div",{display:"flex"});function qa(t){let{onClick:e,value:o,title:n,hasLogo:r,placeholder:a,disabled:s}=t;return ht.createElement(pu,null,ht.createElement(mu,{size:"large",variant:"label"},n),ht.createElement(uu,{size:10}),ht.createElement(lu,{onClick:s?void 0:e,disabled:s},ht.createElement(cu,null,r&&ht.createElement(ht.Fragment,null,ht.createElement(ZS,{src:o?.logo,size:16,useAsPlaceholder:!o?.logo,type:"circular"}),ht.createElement(uu,{size:4,direction:"horizontal"})),ht.createElement(mu,{className:"title_typography",size:"medium",variant:"label"},o?.name||a)),ht.createElement(YS,{size:12,color:"black"})))}i(qa,"BlockchainSelectorButton");import{i18n as Ga}from"@lingui/core";import{Button as JS,Divider as yn,ExternalLinkIcon as RS,Image as eC,Typography as zo}from"@rango-dev/ui";import We from"react";function du(t,e){if(e.type==="COSMOS")return"";let o=e.info?.addressUrl;return!o||!t?"":o.replace("{wallet}",t)}i(du,"generateExplorerLink");import{darkTheme as Uo,styled as fu}from"@rango-dev/ui";var Ha=fu("a",{textDecoration:"none",color:"$colors$neutral700",[`.${Uo} &`]:{color:"$colors$neutral900"},"& svg":{marginLeft:"$4",color:"$colors$neutral700",[`.${Uo} &`]:{color:"$colors$neutral900"}},variants:{hasHover:{true:{"&:hover":{color:"$colors$secondary550",[`.${Uo} &`]:{color:"$colors$secondary500"},"& svg":{color:"$colors$secondary550",[`.${Uo} &`]:{color:"$colors$secondary500"}}}},false:{}}}}),gu=fu("div",{display:"flex",justifyContent:"center",flexDirection:"column",alignItems:"center",textAlign:"center","& ._blockchain-name, & ._coin-source":{color:"$colors$neutral600",[`.${Uo} &`]:{color:"$colors$neutral800"}},"& ._coin-source-name, & ._custom-token-description":{color:"$colors$neutral700",[`.${Uo} &`]:{color:"$colors$neutral900"}}});function Va(t){let{open:e,onClose:o,token:n,onSubmitClick:r,blockchain:a}=t,s=du(n.address,a);return We.createElement(J,{open:e,dismissible:!0,onClose:o,container:N()},We.createElement(gu,null,We.createElement(eC,{src:n.image,size:45,type:"circular"}),We.createElement(zo,{variant:"title",size:"medium"},n.name),We.createElement(zo,{variant:"body",size:"small",className:"_blockchain-name"},a.displayName),We.createElement(yn,{size:4}),We.createElement(zo,{variant:"body",size:"medium"},s?We.createElement(Ha,{hasHover:!0,href:s,target:"_blank",rel:"nofollow noreferrer"},n.address,We.createElement(RS,{size:12,color:"gray"})):We.createElement(Ha,null,n.address)),We.createElement(yn,{size:4}),n.coinSource&&We.createElement(zo,{className:"_coin-source",variant:"body",size:"xsmall"},Ga.t("via")," ",We.createElement(zo,{className:"_coin-source-name",variant:"body",size:"xsmall"},n.coinSource)),We.createElement(yn,{size:"32"}),We.createElement(zo,{size:"medium",variant:"body",className:"_custom-token-description"},Ga.t("This token doesn't appear on the active token list(s). Make sure this is the token that you want to trade."))),We.createElement(yn,{size:40}),We.createElement(yn,{size:10}),We.createElement(JS,{id:"widget-custom-token-modal-import-btn",variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:r},Ga.t("Import")))}i(Va,"CustomTokenModal");import{useManager as nk}from"@rango-dev/queue-manager-react";import{BottomLogo as rk,Divider as Du,Header as ik}from"@rango-dev/ui";import Le,{useEffect as fs,useRef as _u,useState as ak}from"react";import{useRef as tC}from"react";function $r(){return window.self!==window.top}i($r,"isAppLoadedIntoIframe");function Ka(){let t=tC(null),{iframe:e}=y(),o=$r()&&e.clientUrl,n=i(s=>{o&&window.top?.postMessage(s,e.clientUrl)},"send");return{send:n,connectHeightObserver:i(s=>{t.current=new ResizeObserver(l=>{for(let p of l)n({type:"widget_height",data:{height:p.contentRect.height}})}),t.current.observe(s)},"connectHeightObserver"),disconnectHeightObserver:i(()=>{t.current&&(t.current.disconnect(),t.current=null)},"disconnectHeightObserver")}}i(Ka,"useIframe");import{useNavigate as oC}from"react-router-dom";function Ye(){let t=oC();return()=>t(-1)}i(Ye,"useNavigateBack");import{createTheme as es,darkTheme as hC,lightTheme as yC}from"@rango-dev/ui";import{useEffect as SC,useState as CC}from"react";import{theme as fC,darkColors as gC}from"@rango-dev/ui";import Ja from"react";function nC(t){return t.startsWith("#")&&(t=t.slice(1)),t.length===3?`#${t.split("").reduce(function(n,r){return n+r+r},"")}`:`#${t}`}i(nC,"expandShortHexColor");function rC(t){return/[0-9]+$/.test(t)}i(rC,"isOverridingColor");function iC(t,e){return t.padStart(e,"0")}i(iC,"pad");function ja(t){let e=Math.min(Math.max(Math.round(t),0),255);return iC(e.toString(16),2)}i(ja,"intToHex");function aC(t){return`#${ja(t.red)}${ja(t.green)}${ja(t.blue)}`}i(aC,"rgbToHex");function sC(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(sC,"hexToRGB");function lC(t,e){let o=1-.11*e;return{red:t.red*o,green:t.green*o,blue:t.blue*o}}i(lC,"generateShade");function pC(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(pC,"generateTint");function cC(t){return hu(t,lC)}i(cC,"calculateShades");function uC(t){return hu(t,pC)}i(uC,"calculateTints");function hu(t,e){let o=sC(t),n=[];for(let r=1;r<9;r++)n.push(aC(e(o,r)));return n}i(hu,"calculateColors");function Xa(t,e,o){let a=uC(t).reverse().concat(t),s=cC(t),l=a.concat(s),p={},u=l.length;for(let c=0;c<u;c++){let m=100+(o?u-1-c:c)*50;p[`${e}${m}`]=l[c]}return p}i(Xa,"createTintsAndShades");function Ya(t,e,o){let n={...t};for(let r in e){let a=e[r],s=r==="neutral"&&!!o?.reverseNeutralRange;if(!["background","foreground"].includes(r)&&!rC(r)){let p=nC(a);Object.assign(n,Xa(p,r,s))}}return{...n,...e}}i(Ya,"expandToGenerateThemeColors");var yu=i(t=>String.fromCharCode(t+(t>25?39:97)),"toAlphabeticChar"),mC=i(t=>{let e="",o;for(o=Math.abs(t);o>52;o=o/52|0)e=yu(o%52)+e;return yu(o%52)+e},"toAlphabeticName"),dC=i((t,e)=>{let o=e.length;for(;o;)t=t*33^e.charCodeAt(--o);return t},"toPhash"),Za=i(t=>mC(dC(5381,JSON.stringify(t))>>>0),"toHash");function Ra(t){let e=fC.colors,o={...e,...gC},n,r;if(t?.light){let s={colors:Ya(e,t.light)};n={id:`${ma}-light-${Za(s)}`,tokens:s}}if(t?.dark){let s={colors:Ya(o,t.dark,{reverseNeutralRange:!0})};r={id:`${ma}-dark-${Za(s)}`,tokens:s}}return{light:n,dark:r}}i(Ra,"customizedThemeTokens");function Su(t,e){if(t.length<=1)return t.map(({element:n,key:r})=>Ja.cloneElement(n,{key:r}));let o=[];return t.forEach((n,r)=>{let{element:a,key:s}=n;if(o.push(Ja.cloneElement(a,{key:s})),r<t.length-1){let l=`divider-${r}`;o.push(Ja.cloneElement(e,{key:l}))}}),o}i(Su,"joinList");function Cu(){return window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches}i(Cu,"doesWindowPreferDarkColorScheme");function Qo(t){let{colors:e,fontFamily:o=yp,borderRadius:n=Qp,secondaryBorderRadius:r=qp}=t,[a,s]=CC(Cu()?"dark":"light"),{theme:l}=y(),{dark:p,light:u}=Ra(e),c=es({shadows:t.shadows||{},radii:{primary:`${n}px`,secondary:`${r}px`},fonts:{widget:o}}),m=[c.className,yC.className],f=[c.className,hC.className];if(u){let d=es(u.id,u.tokens);m.push(d.className)}if(p){let d=es(p.id,p.tokens);f.push(d.className)}return SC(()=>{let d=i(h=>{h.matches?s("dark"):s("light")},"switchThemeListener");return Cu()&&s("dark"),window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",d),()=>{window.matchMedia("(prefers-color-scheme: dark)").removeEventListener("change",d)}},[]),{activeTheme:i(()=>{let d=m.join(" "),h=f.join(" ");return l==="auto"?a==="dark"?h:d:l==="dark"?h:d},"getActiveTheme"),mode:l==="auto"?a:l}}i(Qo,"useTheme");var ut=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 ku}from"@lingui/core";import{Alert as kC,Button as TC}from"@rango-dev/ui";import Tu from"react";function ts(t){return Tu.createElement(kC,{action:Tu.createElement(TC,{id:"widget-active-tab-btn",onClick:t.onActivateTab,variant:"contained",size:"xxsmall",type:"warning"},ku.t("Activate this tab")),type:"warning",variant:"alarm",title:ku.t("Another tab is open and handles transactions.")})}i(ts,"ActivateTabAlert");import{i18n as os}from"@lingui/core";import{Button as vC,Divider as wC,MessageBox as bC}from"@rango-dev/ui";import Fr from"react";function ns(t){let{open:e,onClose:o,onConfirm:n}=t;return Fr.createElement(J,{open:e,dismissible:!0,onClose:o,container:N()},Fr.createElement(bC,{title:os.t("Activate current tab"),type:"warning",description:os.t("Currently, some transactions are running and being handled by other browser tab. If you activate this tab, all transactions that are already in the transaction sign step will expire.")},Fr.createElement(wC,{size:20}),Fr.createElement(vC,{id:"widget-modal-confirm-activate-tab-btn",variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:n},os.t("Confirm"))))}i(ns,"ActivateTabModal");import{ChevronLeftIcon as xC}from"@rango-dev/ui";import vu from"react";function rs(t){return vu.createElement(It,{id:"widget-header-back-icon-btn",variant:"ghost",size:"small",onClick:t.onClick},vu.createElement(xC,{color:"black",size:16}))}i(rs,"BackButton");import{i18n as EC}from"@lingui/core";import{Button as IC,Typography as AC}from"@rango-dev/ui";import is from"react";function as(t){return is.createElement(Vt,null,is.createElement(IC,{id:"widget-header-cancel-btn",variant:"ghost",onClick:t.onClick,size:"xsmall"},is.createElement(AC,{variant:"label",size:"medium",color:"error500"},EC.t("Cancel"))))}i(as,"CancelButton");import{i18n as NC}from"@lingui/core";import{Image as WC,Tooltip as MC,WalletIcon as LC}from"@rango-dev/ui";import ho from"react";function ss(t){let{list:e}=ft(),o=e.filter(r=>r.state==="connected"),n=o.length?ho.createElement("div",{className:gc()},o.map(r=>ho.createElement(kr,{key:r.title},ho.createElement(WC,{src:r.image,size:14})))):NC.t("Connect Wallet");return ho.createElement(MC,{container:t.container,side:"bottom",content:n},ho.createElement(It,{id:"widget-header-wallet-icon-btn",variant:"ghost",size:"small",onClick:t.onClick},t.isConnected&&ho.createElement(uc,null),ho.createElement(LC,{size:18,color:"black"})))}i(ss,"WalletButton");import{i18n as Ur}from"@lingui/core";import{NotificationsIcon as jC,Popover as XC,SettingsIcon as YC,Tooltip as zr,TransactionIcon as ZC}from"@rango-dev/ui";import Me from"react";import{Notifications as _C}from"@rango-dev/ui";import $C from"react";import{useNavigate as FC}from"react-router-dom";import{create as BC}from"zustand";import{persist as PC,subscribeWithSelector as DC}from"zustand/middleware";var be=Gt(BC()(PC(DC((t,e)=>({isSynced:!1,notifications:[],setNotification:(o,n)=>{let r=n.steps[0],a=n.steps[n.steps.length-1],s={event:o,creationTime:Date.now(),requestId:n.requestId,route:{creationTime:parseInt(n.creationTime),from:{blockchain:r.fromBlockchain,address:r.fromSymbolAddress,symbol:r.fromSymbol},to:{blockchain:a.toBlockchain,address:a.toSymbolAddress,symbol:a.toSymbol}}},l=e().notifications.filter(p=>p.requestId!==n.requestId);t(()=>({notifications:[...l,s]}))},removeNotification:o=>{t(n=>({notifications:n.notifications.filter(r=>r.requestId!==o)}))},getNotifications:()=>{let{isSynced:o,notifications:n}=e();return o?n.sort((r,a)=>r.route.creationTime&&!a.route.creationTime?-1:!r.route.creationTime&&a.route.creationTime?1:!r.route.creationTime&&!a.route.creationTime?a.creationTime-r.creationTime:a.route.creationTime-r.route.creationTime):[]},syncNotifications:o=>{let{isSynced:n,notifications:r}=e();if(!n){let a=[];r.forEach(s=>{o.some(p=>p.swap.requestId===s.requestId)&&a.push(s)}),t({isSynced:!0,notifications:a})}},clearNotifications:()=>t({notifications:[]})})),{name:"notification",skipHydration:!0,partialize:({isSynced:t,...e})=>e,version:1,migrate:(t,e)=>{if(e===0){let o=t.notifications;t.notifications=o.filter(n=>!n.read).map(({read:n,...r})=>r)}return t}})));function ls(){let t=FC(),{getNotifications:e,clearNotifications:o}=be(),n=e(),r=y().blockchains(),{findToken:a}=y();return $C.createElement(_C,{list:n,getBlockchainImage:l=>cp(l,r)??"",getTokenImage:l=>a(l)?.image??"",onClickItem:i(l=>{t(`${D.swaps}/${l}`)},"onClickItem"),onClearAll:o})}i(ls,"NotificationContent");import{useManager as OC}from"@rango-dev/queue-manager-react";import{InProgressIcon as UC}from"@rango-dev/ui";import wu from"react";var zC=i(()=>{let{manager:t}=OC();return ut(t).map(({swap:o})=>o).find(o=>o.status==="running")?wu.createElement(fc,null,wu.createElement(UC,{color:"info",size:6})):null},"InProgressTransactionBadge"),bu=zC;import{EventSeverity as QC}from"@rango-dev/queue-manager-rango-preset";import{Typography as qC}from"@rango-dev/ui";import xu from"react";function Eu(){let{getNotifications:t}=be(),e=t(),o=e.length,n=!!e.find(r=>r.event.messageSeverity===QC.WARNING);return o?xu.createElement(mc,{isSever:n},xu.createElement(qC,{variant:"body",size:"xsmall",color:"$background"},o)):null}i(Eu,"NotificationsBadge");import{RefreshProgressButton as HC}from"@rango-dev/ui";import ps,{useEffect as GC,useState as Iu}from"react";var VC=1e3,Au=60,KC=100;function Or({onClick:t}){let[e,o]=Iu(0),[n,r]=Iu(!1),a=i(p=>{document.hidden&&p&&s(p)},"handleVisibilityChange");GC(()=>{let p;return t?p=window.setInterval(()=>{o(u=>u+1),e===Au&&l()},VC):s(p),document.addEventListener("visibilitychange",()=>a(p)),()=>{document.removeEventListener("visibilitychange",()=>a(p)),p&&clearInterval(p)}},[e,t]);let s=i(p=>{p&&clearInterval(p),o(0)},"clearTimeout"),l=i(()=>{t?.(),o(0),r(!0)},"handleRefreshClick");return ps.createElement(It,{id:"widget-header-refresh-icon-btn",variant:"ghost",size:"small",style:{paddingTop:0,paddingBottom:0},onClick:l,disabled:!t},ps.createElement(dc,{onTransitionEnd:()=>r(!1),isRefetched:n},ps.createElement(HC,{size:22,color:t?"black":"gray",progress:e/Au*KC})))}i(Or,"RefreshButton");function yo(t){let{onClickRefresh:e,onClickHistory:o,onClickSettings:n,hidden:r=[],container:a}=t,{config:{features:s}}=y(),l=je("notification",s)||r.includes("notifications");return Me.createElement(Me.Fragment,null,!r.includes("refresh")&&Me.createElement(zr,{container:a||N(),side:"top",content:Ur.t("Refresh")},Me.createElement(Or,{onClick:e})),!l&&Me.createElement(XC,{align:"end",alignOffset:-88,sideOffset:15,collisionPadding:{right:20,left:20},container:N(),content:Me.createElement(ls,null)},Me.createElement("div",null,Me.createElement(zr,{container:N(),side:"top",content:Ur.t("Notifications")},Me.createElement(It,{id:"widget-header-notification-icon-btn",size:"small",variant:"ghost"},Me.createElement(jC,{size:18,color:"black"}),Me.createElement(Eu,null))))),!r.includes("settings")&&Me.createElement(zr,{container:N(),side:"top",content:Ur.t("Settings")},Me.createElement(It,{id:"widget-header-setting-icon-btn",size:"small",variant:"ghost",onClick:n},Me.createElement(YC,{size:18,color:"black"}))),!r.includes("history")&&Me.createElement(zr,{container:N(),side:"top",content:Ur.t("History")},Me.createElement(It,{id:"widget-header-history-icon-btn",size:"small",variant:"ghost",onClick:o},Me.createElement(ZC,{size:18,color:"black"}),Me.createElement(bu,null))))}i(yo,"HeaderButtons");import{i18n as cs}from"@lingui/core";import{Divider as Wu,MessageBox as ek,RefreshIcon as tk}from"@rango-dev/ui";import qo from"react";import{Button as JC,styled as RC}from"@rango-dev/ui";var Nu=RC(JC,{"& span":{display:"flex",justifyContent:"center",alignItems:"center"}});function us(t){let{open:e,onClose:o}=t;return qo.createElement(J,{open:e,dismissible:!0,onClose:o,container:N()},qo.createElement(ek,{title:cs.t("Something went wrong"),type:"error",description:cs.t("Something went wrong. Please refresh the app.")},qo.createElement(Wu,{size:30}),qo.createElement(Nu,{variant:"outlined",size:"large",type:"primary",fullWidth:!0,onClick:()=>location.reload()},qo.createElement(tk,{size:20,color:"primary"}),qo.createElement(Wu,{size:4,direction:"horizontal"}),cs.t("Refresh"))))}i(us,"RefreshModal");function ms(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(ms,"onScrollContentAttachStatusToContainer");import{css as ok,styled as ds}from"@rango-dev/ui";var Mu="700px",Qr=ok({borderRadius:"$primary",display:"flex",flexDirection:"column",overflow:"hidden",boxShadow:"$mainContainer"}),Lu=ds("div",{position:"relative",width:"100vw",minWidth:"300px",maxWidth:"390px",backgroundColor:"$background",variants:{height:{auto:{height:"auto",maxHeight:Mu},fixed:{height:Mu}}}}),Bu=ds("div",{position:"relative",overflow:"hidden",flexGrow:1,display:"flex",flexDirection:"column",padding:0,overflowY:"auto"}),Pu=ds("div",{padding:"0 $20 $10","& .footer__alert":{paddingTop:"$10"},"& .footer__logo":{opacity:0,transition:"opacity 1s ease-in-out","&.logo__show":{opacity:1},"&.logo__hidden":{visibility:"hidden"}}});function ne(t){let{connectHeightObserver:e,disconnectHeightObserver:o}=Ka(),{children:n,header:r,footer:a,height:s="fixed"}=t,{fetchStatus:l}=y(),[p,u]=ak(!1),c=Z.use.connectedWallets(),{config:{features:m,theme:f}}=y(),{watermark:g}=se(),d=g==="FULL",{activeTheme:h}=Qo(f||{}),k=je("connectWalletButton",m),{isActiveTab:S,tabManagerInitiated:C,showActivateTabModal:T,setShowActivateTabModal:v,activateCurrentTab:w}=se(),A=Ye(),{manager:M}=nk(),E=ut(M).map(({swap:ee})=>ee).some(ee=>ee.status==="running"),x=i(()=>w(lo.forceClaim,E),"onActivateTab"),W=i(()=>{r.onWallet?.()},"onConnectWallet"),$=typeof r.hasBackButton>"u"||r.hasBackButton,I=_u(null),R=_u(null);return fs(()=>($r()&&R.current&&e(R.current),()=>{o()}),[]),fs(()=>(I.current?.addEventListener("scroll",ms),()=>{I.current?.removeEventListener("scroll",ms)}),[]),fs(()=>{u(l==="failed")},[l]),Le.createElement(Lu,{height:s,id:$e.SWAP_BOX_ID,className:`${h()} ${Qr()}`,ref:R},Le.createElement(ik,{prefix:$?Le.createElement(rs,{onClick:()=>{A(),r.onBack&&r.onBack()}}):null,title:r.title,suffix:Le.createElement(Le.Fragment,null,r.suffix,r.onWallet&&!k&&Le.createElement(ss,{container:N(),onClick:W,isConnected:!!c?.length}),r.onCancel&&Le.createElement(as,{onClick:r.onCancel}))}),Le.createElement(Bu,{ref:I},n),Le.createElement(ns,{open:T,onClose:()=>v(!1),onConfirm:x}),Le.createElement(Pu,null,Le.createElement("div",{className:"footer__content"},C&&!S&&Le.createElement("div",{className:"footer__alert"},Le.createElement(ts,{onActivateTab:x}),Le.createElement(Du,{size:10})),a),Le.createElement(Du,{size:12}),Le.createElement("div",{className:`footer__logo ${d?"logo__show":"logo__hidden"}`},Le.createElement(rk,null))),Le.createElement(us,{open:p,onClose:()=>u(!1)}))}i(ne,"Layout");import{styled as sk}from"@rango-dev/ui";var $u="$20 $20 $10 $20",Sn=sk("div",{padding:$u,overflowY:"auto",flexGrow:1});import{styled as lk}from"@rango-dev/ui";var re=lk("div",{display:"flex",flexDirection:"column",padding:"20px 20px 10px",flexGrow:1,variants:{view:{true:{flexGrow:1,overflow:"hidden"}},compact:{true:{padding:0}}}});import{i18n as Ho}from"@lingui/core";import{useState as Fu}from"react";function Ou(){let[t,e]=Fu(!1),[o,n]=Fu(void 0),{findToken:r}=y(),a=y().customTokens();function s(p,u){switch(p){case"duplicated":return{title:Ho.t("Duplicate Token"),message:Ho.t("The address you entered is duplicate, please enter a new address.")};case"token-exist":return{title:Ho.t("Token Already Exists"),message:Ho.t("There's no need to add this token again because it already exists and is supported by us.")};case"not-found":return{title:Ho.t("Token Not Found"),message:Ho.t({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:p,tokenAddress:u})=>{e(!0);try{if(a.some(d=>d.address?.toLowerCase()===u.toLowerCase())){let d=s("duplicated");n(d);return}let m=await Et().getCustomToken({blockchain:p,address:u});if(!m||!m.token||m.error){let d=s("not-found",p);n(d);return}let f=m.token;if(r({blockchain:f.blockchain,address:f.address,symbol:f.symbol})){let d=s("token-exist");n(d);return}return f}catch(c){throw n(void 0),new Error(c.message)}finally{e(!1)}},"fetchCustomToken"),loading:t,error:o}}i(Ou,"useFetchCustomToken");var Ck=dk("div",{display:"flex",justifyContent:"space-between",flexDirection:"column",flex:1,"& ._text-field":{padding:"$4 $10",backgroundColor:"$neutral300",[`.${ck} &`]:{backgroundColor:"$neutral400"},borderRadius:"$sm",height:"$40"}}),kk=1e3;function zu(){let t=yk(),[e]=Sk(),o=Ye(),{setCustomToken:n}=y(),r=y().blockchains(),a=e.get("blockchain")||"",s=nn(a,r),[l,p]=qr(""),[u,c]=qr(!1),[m,f]=qr(),{fetchCustomToken:g,loading:d,error:h}=Ou(),[k,S]=qr(""),C=!!s&&No(s,l),T=!s||!l||!C,v=i(async()=>{if(s)try{let M=await g({blockchain:a,tokenAddress:l});S(""),M&&f(M)}catch(M){M.message==="Failed to fetch"&&(S(At.t("Network Error")),c(!0))}},"getCustomToken"),w=i(()=>{h&&p(""),c(!1)},"closeErrorModal"),A=i(async()=>{k&&setTimeout(async()=>{await v()},kk),w()},"handleErrorModalButtonClick");return hk(()=>{h&&c(!0)},[h]),Se.createElement(ne,{header:{title:At.t("Add Custom Token")}},Se.createElement(re,null,Se.createElement(Ck,null,Se.createElement("div",null,Se.createElement(qa,{onClick:()=>t(D.blockchains,{replace:!0}),hasLogo:!!s?.logo,value:s?{name:s.displayName,logo:s.logo}:void 0,title:At.t("Select chain"),placeholder:At.t("Select chain")}),Se.createElement(Cn,{size:"24"}),Se.createElement(gk,{size:"large",variant:"label"},At.t("Enter Address")),Se.createElement(Cn,{size:10}),Se.createElement(fk,{fullWidth:!0,disabled:!s,variant:"contained",placeholder:At.t("Enter token address"),size:"large",value:l,suffix:!!l&&C&&Se.createElement(uk,{color:"success",size:12}),onChange:M=>p(M.target.value)}),!C&&!!l&&Se.createElement(Se.Fragment,null,Se.createElement(Cn,{size:4}),Se.createElement(pk,{type:"error",variant:"alarm",title:"Invalid Address"}))),Se.createElement(Uu,{id:"widget-add-custom-token-import-btn",disabled:T,type:"primary",variant:"contained",loading:d,size:"large",onClick:v},At.t("Import"))),Se.createElement(J,{open:u,dismissible:!0,onClose:w,container:N()},Se.createElement(mk,{title:h?.title||k,type:"error",description:h?.message||At.t("Failed Network, Please retry.")},Se.createElement(Cn,{size:40}),Se.createElement(Cn,{size:10}),Se.createElement(Uu,{id:`widget-add-custom-token-${k?"retry":"add-another"}-btn`,variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:A},k?At.t("Retry"):At.t("Add another custom token")))),s&&m&&Se.createElement(Va,{blockchain:s,token:m,onSubmitClick:()=>{m&&(n(m),f(void 0),o())},onClose:()=>f(void 0),open:!!s&&!!m})))}i(zu,"AddCustomTokenPage");import{i18n as qs}from"@lingui/core";import{useManager as nv}from"@rango-dev/queue-manager-react";import{Alert as $d,Button as rv,css as Gs,Divider as Hs,IconButton as Fd,styled as iv,Typography as av,WalletIcon as sv}from"@rango-dev/ui";import Ie,{useEffect as Ci,useLayoutEffect as lv,useRef as pv,useState as Ln}from"react";import{useNavigate as cv}from"react-router-dom";import{i18n as So}from"@lingui/core";import{Alert as gm,BalanceErrors as Vk,Button as hm,ChevronLeftIcon as Kk,Divider as Jr,MessageBox as jk,Typography as vs}from"@rango-dev/ui";import j,{useCallback as Xk,useEffect as ym,useMemo as Yk,useState as Co}from"react";import{useNavigate as Zk}from"react-router-dom";import{i18n as Hr}from"@lingui/core";function Gr(t){switch(t.type){case 0:return Hr.t("Route has been updated.");case 3:return Hr.t("Output amount changed to {newOutputAmount} ({percentageChange}% change).",{newOutputAmount:t.newOutputAmount,percentageChange:t.percentageChange});case 1:return Hr.t("Route swappers has been updated.");case 2:return Hr.t("Route internal coins has been updated.");default:return""}}i(Gr,"getQuoteUpdateWarningMessage");import{i18n as Ss}from"@lingui/core";import{Alert as Ek,ChevronDownIcon as Ik,CloseIcon as Ak,Divider as ju,IconButton as Xu,PasteIcon as Nk,Typography as Wk,WalletIcon as Mk}from"@rango-dev/ui";import Be,{useEffect as Lk,useRef as Bk}from"react";import Xr,{useRef as bk}from"react";import*as Go from"@radix-ui/react-collapsible";import{keyframes as Qu,styled as Vr}from"@rango-dev/ui";var gs=300,vk=Qu({from:{height:0},to:{height:"var(--radix-collapsible-content-height)"}}),wk=Qu({from:{height:"var(--radix-collapsible-content-height)"},to:{height:0}}),qu=Vr(Go.Root,{borderRadius:"$sm",overflow:"hidden",variants:{selected:{true:{outlineWidth:1,outlineColor:"$secondary500",outlineStyle:"solid"}}}}),hs=Vr(Go.Trigger,{padding:"$0",border:"none",outline:"none",width:"100%",backgroundColor:"transparent",fontFamily:"inherit",cursor:"pointer"}),Kr=Vr(Go.Content,{overflow:"hidden",variants:{open:{true:{animation:`${vk} ${gs}ms ease-out`},false:{animation:`${wk} ${gs}ms ease-out`}}}}),jr=Vr("div",{transition:`all ${gs}ms ease`,display:"flex",alignItems:"center",variants:{orientation:{down:{transform:"rotate(0)"},up:{transform:"rotate(180deg)"}}}});function Yr(t){let{open:e,hasSelected:o,onOpenChange:n,children:r,onClickTrigger:a,trigger:s,triggerAnchor:l}=t,p=bk(null);return Xr.createElement(qu,{ref:p,className:"collapsible_root",selected:o&&e,open:e,onOpenChange:n},l==="top"&&Xr.createElement(hs,{className:"collapsible_trigger",onClick:a},s),Xr.createElement(Kr,{className:"collapsible_content",open:e},r),l==="bottom"&&Xr.createElement(hs,{className:"collapsible_trigger",onClick:a},s))}i(Yr,"CustomCollapsible");import{darkTheme as Hu,styled as ys,TextField as xk}from"@rango-dev/ui";var Gu=ys("div",{padding:"$10 $0","& .button__content":{display:"flex",alignItems:"center"},"& .alarms":{paddingTop:"$5"},"& .collapsible_content":{backgroundColor:"$neutral100"},"& .collapsible_root":{backgroundColor:"$neutral100"}}),Vu=ys(xk,{backgroundColor:"$neutral100",padding:"$15"}),Ku=ys("div",{width:"100%",borderRadius:"$sm",display:"flex",padding:"$15",justifyContent:"space-between",alignItems:"center",$$color:"$colors$neutral100",[`.${Hu} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",borderBottomRightRadius:"0",borderBottomLeftRadius:"0","&:focus-visible":{$$background:"$colors$secondary100",[`.${Hu} &`]:{$$background:"$colors$info700"},backgroundColor:"$$background",outline:0}});function Yu(t){let{blockchain:e,handleOpenChange:o,open:n}=t,{customDestination:r,setCustomDestination:a}=z(),{config:s}=y(),l=y().blockchains(),p=tr(e.name,l),u=Bk(null),c=s?.defaultCustomDestinations?.[e.name],m=navigator?.userAgent.includes("Firefox"),g=n&&!!r&&e&&!No(e,r),d=i(()=>{a("")},"handleClear"),h=i(async S=>{if(S.preventDefault(),navigator.clipboard!==void 0){let C=await navigator.clipboard.readText();a(C),u?.current?.focus()}},"handlePaste"),k=i(()=>r?Be.createElement(Xu,{id:"widget-custom-destination-close-icon-btn",onClick:d,variant:"ghost"},Be.createElement(Ak,{size:12,color:"gray"})):m?null:Be.createElement(Xu,{id:"widget-custom-destination-paste-icon-btn",onClick:h,variant:"ghost"},Be.createElement(Nk,{size:16})),"renderSuffix");return Lk(()=>{!!c&&r===null&&(a(c),o(!0))},[c]),Be.createElement(Gu,null,Be.createElement(Yr,{onOpenChange:o,hasSelected:!0,open:n,triggerAnchor:"top",trigger:Be.createElement(Ku,null,Be.createElement("div",{className:"button__content"},Be.createElement(Mk,{size:18,color:"info"}),Be.createElement(ju,{size:4,direction:"horizontal"}),Be.createElement(Wk,{variant:"label",size:"medium",color:n?"$neutral600":void 0},Ss.t("Send to a different address"))),Be.createElement(jr,{orientation:n?"up":"down"},Be.createElement(Ik,{size:10,color:"secondary"}))),onClickTrigger:()=>o(!n)},Be.createElement(Vu,{ref:u,style:{padding:0,paddingRight:r?"8px":"5px"},autoFocus:!r,placeholder:Ss.t("Enter {blockchainName} address",{blockchainName:p}),value:r||"",suffix:k(),onChange:S=>{let C=S.target.value;a(C)}})),g&&Be.createElement(Be.Fragment,null,Be.createElement(ju,{size:4}),Be.createElement(Ek,{variant:"alarm",type:"error",title:Ss.t({values:{destination:r},id:"Address {destination} doesn't match the blockchain address pattern."})})))}i(Yu,"CustomDestination");import{css as Pk,darkTheme as Cs,IconButton as Dk,styled as Dt}from"@rango-dev/ui";var Zu=Dt("div",{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center"}),Ju=Dt("div",{display:"flex",justifyContent:"space-evenly",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5",height:"100%"}),_k=Dt("button",{borderRadius:"$xm",padding:"$10",border:"0",display:"flex",justifyContent:"center",$$color:"$colors$neutral100",[`.${Cs} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",alignItems:"center",cursor:"pointer",width:110,position:"relative","&:hover":{$$color:"$colors$secondary100",[`.${Cs} &`]:{$$color:"$colors$neutral100"},backgroundColor:"$$color"},"&:focus-visible":{$$color:"$colors$secondary100",[`.${Cs} &`]:{$$color:"$colors$info700"},backgroundColor:"$$color",outline:0},variants:{selected:{true:{outlineWidth:1,outlineColor:"$secondary",outlineStyle:"solid"}}}}),Ru=Dt(_k,{alignSelf:"stretch",minHeight:"93px"}),em=Dt("div",{padding:"$20 $20 $15 $20",display:"flex",justifyContent:"center",alignItems:"center",backgroundColor:"$neutral200",position:"relative",width:"100%"}),tm=Dt(Dk,{position:"absolute",left:"$20"}),om=Dt("div",{paddingTop:"$20"}),nm=Pk({display:"flex",justifyContent:"space-evenly",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5",height:"100%"}),rm=Dt("div",{display:"flex"}),im=Dt("div",{overflow:"visible",width:"100%"});import{i18n as um}from"@lingui/core";import{warn as zk}from"@rango-dev/logging-core";import{Divider as Qk,SelectableWallet as qk,Typography as mm,WalletState as dm}from"@rango-dev/ui";import Ze,{useEffect as fm,useState as Tn}from"react";import{Image as Ok,MessageBox as Uk}from"@rango-dev/ui";import kn from"react";import{keyframes as $k,styled as ks}from"@rango-dev/ui";var am=ks("div",{position:"relative"}),Fk=$k({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}),sm=ks("div",{position:"absolute",border:"2px solid rgba(0, 0, 0, 0.1)",borderTop:"2px solid $info500",borderRadius:"$lg",width:"$45",height:"$45",animation:`${Fk} 1s linear infinite`,top:0,bottom:0,right:0,left:0}),lm=ks("div",{"& img":{borderRadius:"50%"}});import{i18n as Vo}from"@lingui/core";function pm(t,e){switch(t){case"in-progress":return{type:"loading",title:Vo.t({id:"Add {blockchainDisplayName} Chain",values:{blockchainDisplayName:e}}),description:Vo.t({id:"Please approve the experimental chain pop-up in your wallet.",values:{blockchainDisplayName:e}})};case"completed":return{type:"success",title:Vo.t({id:"{blockchainDisplayName} Chain Added",values:{blockchainDisplayName:e}}),description:Vo.t({id:"The {blockchainDisplayName} chain has been successfully added to your wallet.",values:{blockchainDisplayName:e}})};case"rejected":return{type:"error",title:Vo.t("Request Rejected"),description:Vo.t({id:"You've rejected adding {blockchainDisplayName} chain to your wallet.",values:{blockchainDisplayName:e}})};default:throw new Error(`Showing information about an experimentation chain status needs to be defined first. status: ${t}`)}}i(pm,"generateMessageByStatus");function cm(t){let{status:e,displayName:o,image:n}=t,r=pm(e,o),a=e=="in-progress";return kn.createElement(Uk,{type:r.type,title:r.title,description:r.description,icon:a?kn.createElement(am,null,kn.createElement(lm,null,kn.createElement(Ok,{src:n,size:45})),kn.createElement(sm,null)):void 0})}i(cm,"ExperimentalChainStatus");var Hk=7,Gk=3e3;function Ts(t){let{chain:e,isSelected:o,selectWallet:n,limit:r,onShowMore:a}=t,s=se.use.isActiveTab(),l=Z.use.connectedWallets(),{blockchains:p}=y(),[u,c]=Tn(),[m,f]=Tn(null),[g,d]=Tn(!1),[h,k]=Tn(null),{suggestAndConnect:S}=Zr(),{handleDisconnect:C}=Ht(),{list:T}=ft({chain:e}),[v,w]=Tn(T),A=T.length,M=r&&A-r>0,b=i(async x=>{d(!1),k("in-progress");try{await S(x.walletType,x.chain),k("completed")}catch{k("rejected")}},"addExperimentalChain");fm(()=>{w(x=>{let W=T.findIndex($=>o($.type,e));return M&&W>1?[T[W]].concat(T.filter(($,I)=>I!==W)):x.map($=>T.find(I=>I.type===$.type)??$)})},[JSON.stringify(T)]);let E=document.getElementById($e.SWAP_BOX_ID);return fm(()=>{let x=null;return(h==="completed"||h==="rejected")&&(x=setTimeout(()=>k(null),Gk)),()=>{x&&clearTimeout(x)}},[h]),Ze.createElement(Ze.Fragment,null,v.slice(0,r).map(x=>{let W=_p({connectedWallets:l,walletType:x.type,chain:e}),$=W?dr(W,Hk):"",I=ur(p(),e),R=!l.find(le=>le.walletType===x.type&&le.chain===e),ee=I&&R&&x.state===dm.CONNECTED,oe=ee?um.t({id:"Add {chain} chain",values:{chain:e}}):$,B=i(async()=>{x.state===dm.DISCONNECTED?c(x):x.namespaces&&!$?(await C(x.type),c(x)):ee?(f({walletType:x.type,chain:e,address:W??""}),d(!0)):n({walletType:x.type,chain:e,address:W??""})},"onSelectableWalletClick"),V=m?.chain?tr(m.chain,p()):void 0;return Ze.createElement(Ze.Fragment,{key:`${x.title}_${V}`},!!m&&Ze.createElement(J,{open:!!m&&g,container:E,onClose:()=>{f(null)}},Ze.createElement(Ea,{displayName:V,onConfirm:()=>{b(m)}})),h&&Ze.createElement(J,{open:!!h,onClose:k.bind(null,null),container:E},Ze.createElement(cm,{status:h,displayName:V,image:x.image}),Ze.createElement(Qk,{direction:"vertical",size:32})),Ze.createElement(qk,{key:x.type,description:oe,onClick:B,selected:o(x.type,e),disabled:!s,...x}))}),Ze.createElement(mo,{wallet:u,onClose:()=>{c(void 0)},onConnect:x=>{t.onConnect&&x.status==="connected"&&(u?.type?t.onConnect(u.type):zk(new Error("The selected wallet hasn't been detected after the connection process finished. It usually shouldn't happen.")))}}),M&&Ze.createElement(Ru,{selected:!1,onClick:a},Ze.createElement(mm,{variant:"label",size:"medium"},um.t("Show more wallets"),Ze.createElement(mm,{variant:"label",size:"medium",color:"$primary"},"\xA0+",A-(r??0)))))}i(Ts,"WalletList");var Jk=2;function Sm(t){let{open:e,onClose:o,onCancel:n,onCheckBalance:r,loading:a}=t,s=Zk(),l=y().blockchains(),{selectedQuote:p,setSelectedWallets:u,quoteWalletsConfirmed:c,setQuoteWalletConfirmed:m,customDestination:f,setCustomDestination:g}=z(),{connectedWallets:d,selectWallets:h}=Z(),{config:k}=y(),[S,C]=Co(""),[T,v]=Co([]),[w,A]=Co(""),[M,b]=Co(null),[E,x]=Co(!!f),W=Yk(()=>io({filter:"all",quote:p}),[p]),$=io({filter:"required",quote:p}),I=l.find(_=>_.name===p?.swaps[p?.swaps.length-1].to.blockchain),R=i(_=>$.includes(_),"isWalletRequiredFor"),ee=Xk(()=>d.filter(_=>_.selected&&W.includes(_.chain)),[d,W]),[oe,B]=Co(ee()),[V,le]=Co([]),Y=i((_,Q)=>le(G=>G.concat({blockchain:_,walletType:Q})),"addNextSelectedWallets"),ae=T.length>0,ge=i((_,Q)=>!!oe.find(G=>G.walletType===_&&G.chain===Q&&G.selected&&(R(Q)||!R(Q)&&!f)),"isSelected"),ve=i((_,Q,G)=>{let pe=!1;return _.map(ce=>{if(ce.chain===Q){let de=ce.selected;return!pe&&G?(pe=!0,de=!0):G||(de=!1),{...ce,selected:de}}return ce})},"updateSelectableWallets"),U=i(_=>{x(_),_?R(I?.name??"")||B(Q=>ve(Q,I?.name||"",!1)):(g(""),B(Q=>ve(Q,I?.name||"",!0)))},"handleCustomDestinationCollapsibleOpenChange"),Ke=i(_=>{if(S&&C(""),ge(_.walletType,_.chain))return;let G=d.find(pe=>pe.walletType===_.walletType&&pe.chain===_.chain);G&&(n(),_.chain===I?.name&&E&&!R(I.name)&&(x(!1),g(null)),B(pe=>pe.filter(ce=>ce.chain!==_.chain).concat({...G,selected:!0})))},"onChange"),vt=i(()=>{let _=oe.filter(Q=>Q.selected);h(_),u(_),m(!0),o()},"onConfirmBalance"),lt=i(async()=>{v([]),A(""),b(null);let _=await r?.({selectedWallets:oe.filter(G=>G.selected),customDestination:f}),Q=_.warnings;Q?.balance?.messages&&v(Q.balance.messages),Q?.quoteUpdate&&b(Q.quoteUpdate),_.error&&A(Bc(_.error)),!_.error&&!Q?.balance?.messages.length?vt():v(Q?.balance?.messages??[])},"onConfirmWallets");ym(()=>{B(_=>{let Q=[];return _.forEach(G=>{!d.some(ce=>ce.chain===G.chain&&ce.walletType===G.walletType&&ce.address===G.address)||Q.push(G)}),Q=Q.concat(d.filter(G=>!!!Q.find(ce=>ce.chain===G.chain)&&G.selected&&W.includes(G.chain))),Q})},[d,W]),ym(()=>{let _=[];V.length>0&&(V.forEach(Q=>{let G=d.find(pe=>pe.chain===Q.blockchain&&pe.walletType===Q.walletType);G?Ke(G):_.push(Q)}),le(_))},[d,V]);let wt=document.getElementById($e.SWAP_BOX_ID);return j.createElement(J,{open:e,onClose:()=>{c||s("../",{replace:!0}),o()},dismissible:!S,container:wt,...!S&&{styles:{container:{height:"100%"}},footer:j.createElement(rm,null,j.createElement(hm,{id:"widget-confirm-wallet-modal-confirm-btn",loading:a,disabled:Zc(a,E,f,p,oe,I),onClick:lt,variant:"contained",type:"primary",fullWidth:!0,size:"large"},So.t("Confirm")))},...S&&{styles:{container:{height:"100%",padding:"$0"}},header:j.createElement(em,null,j.createElement(tm,{id:"widget-confirm-wallet-modal-navigate-back-icon-btn",variant:"ghost",onClick:C.bind(null,"")},j.createElement(Kk,{size:16})),j.createElement(vs,{variant:"headline",size:"small"},So.t({id:"Your {blockchainName} wallets",values:{blockchainName:pt(S,l)}})))},anchor:"center"},j.createElement(J,{open:ae,onClose:v.bind(null,[]),container:wt},j.createElement(jk,{title:So.t("Insufficient account balance"),type:"error",description:j.createElement(Vk,{messages:T??[]})},j.createElement(hm,{id:"widget-confirm-wallet-modal-proceed-anyway-btn",variant:"outlined",size:"large",type:"primary",fullWidth:!0,onClick:vt},So.t("Proceed anyway")))),S&&j.createElement(om,null,j.createElement("div",{className:nm()},j.createElement(Ts,{chain:S,isSelected:ge,selectWallet:Ke,onShowMore:()=>C(S),onConnect:_=>{Y(S,_)}}))),!S&&j.createElement(j.Fragment,null,w&&j.createElement(j.Fragment,null,j.createElement(gm,{variant:"alarm",type:"error",title:So.t(w)}),j.createElement(Jr,{size:12})),M&&j.createElement(j.Fragment,null,j.createElement(gm,{variant:"alarm",type:"warning",title:Gr(M)}),j.createElement(Jr,{size:12})),j.createElement(im,null,W.map((_,Q)=>{let G=l.find(he=>he.name===_),pe=`wallet-${Q}`,ce=Q===W.length-1,de=ce&&I&&k?.customDestination!==!1;return j.createElement("div",{key:pe},j.createElement(Zu,null,j.createElement(vs,{variant:"title",size:"xmedium"},So.t({id:"Your {blockchainName} wallets",values:{blockchainName:G?.shortName}})),j.createElement(vs,{variant:"label",color:"$neutral700",size:"medium"},So.t({id:"You need to connect a {blockchainName} wallet.",values:{blockchainName:G?.shortName}}))),j.createElement(Jr,{size:24}),j.createElement(Ju,null,j.createElement(Ts,{chain:_,isSelected:ge,selectWallet:Ke,limit:Jk,onShowMore:()=>C(G?.name??""),onConnect:he=>{Y(_,he)}})),!ce&&j.createElement(Jr,{size:32}),de&&j.createElement(Yu,{blockchain:I,open:E,handleOpenChange:U}))}))))}i(Sm,"ConfirmWalletsModal");import{i18n as yT}from"@lingui/core";import{Alert as ST,Button as CT,InfoIcon as kT}from"@rango-dev/ui";import ot from"react";import{Alert as tT,Button as oT,Divider as xs,NoRouteIcon as nT,RefreshIcon as rT,Typography as xm}from"@rango-dev/ui";import tt from"react";import{i18n as Cm}from"@lingui/core";var Rk=24,eT=60;function km(t,e,o,n){return t?.type===1?{alert:{type:"warning",text:te().genericServerError,action:{onClick:n,title:Cm.t("Retry")}},description:""}:e.length?{alert:{type:"warning",text:te().liquiditySourcesError.title,action:{onClick:()=>o(!0),title:Cm.t("Reset")}},description:te().liquiditySourcesError.description}:t?.type===0&&t.diagnosisMessage?{alert:{type:"error",text:t.diagnosisMessage,action:null},description:""}:{alert:null,description:te().noResultError.description}}i(km,"makeInfo");var ws=(o=>(o[o.small=Rk]="small",o[o.large=eT]="large",o))(ws||{}),bs=(o=>(o.small="small",o.large="medium",o))(bs||{});import{styled as Rr}from"@rango-dev/ui";var Tm=Rr("div",{display:"flex",flexDirection:"column",alignItems:"center"}),vm=Rr("div",{variants:{size:{small:{},large:{maxWidth:"316px"}}}}),wm=Rr("div",{variants:{size:{small:{width:"100%"},large:{}}}}),bm=Rr("div",{padding:"$6 $0"});function vn(t){let{fetch:e,error:o,size:n="small"}=t,r=y().getDisabledLiquiditySources(),a=y().toggleAllLiquiditySources,s=y().swappers(),l=km(o,r,()=>a(s,!0),e);return tt.createElement(Tm,null,tt.createElement(nT,{size:ws[n],color:"gray"}),tt.createElement(xs,{size:4}),tt.createElement(xm,{variant:"title",size:bs[n]},te().noResultError.title),n==="large"&&tt.createElement(xs,{size:4}),!!l.description&&tt.createElement(vm,{size:n},tt.createElement(xm,{variant:"body",size:"small",align:"center",color:"neutral700"},l.description)),tt.createElement(xs,{size:n==="large"?"24":"4"}),!!l.alert&&tt.createElement(wm,{size:n},tt.createElement(tT,{type:l.alert.type,title:l.alert.text,titleAlign:"left",action:l.alert.action&&tt.createElement(oT,{size:"xsmall",id:"widget-no-result-alert-btn",type:l.alert.type,prefix:tt.createElement(bm,null,tt.createElement(rT,{size:8})),onClick:l.alert.action.onClick},l.alert.action.title),variant:"alarm"})))}i(vn,"NoResult");import{i18n as wn}from"@lingui/core";import{Button as aT,Divider as sT,MessageBox as lT,Typography as pT,WarningIcon as cT}from"@rango-dev/ui";import _t from"react";import{Typography as Nm}from"@rango-dev/ui";import Is from"react";import{darkTheme as iT,styled as ei}from"@rango-dev/ui";var Em=ei("div",{width:"100%"}),Es=ei("div",{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"$5",width:"100%"}),Im=ei("div",{display:"flex",padding:"$5 0",justifyContent:"space-between",alignItems:"center",width:"100%","._title":{$$color:"$colors$neutral600",[`.${iT} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),Am=ei("div",{padding:"$2",alignSelf:"flex-start",cursor:"pointer"});function Wm(t){let{title:e,value:o,valueColor:n}=t;return Is.createElement(Im,null,Is.createElement(Nm,{size:"medium",variant:"label",className:"_title"},e),Is.createElement(Nm,{size:"large",variant:"label",color:n||"foreground"},`${n?"%":"$"}${o}`))}i(Wm,"QuoteErrorsModalItem");function Mm(t){let{open:e,onClose:o,onConfirm:n,warning:r,confirmationDisabled:a}=t,s=r.warningLevel==="high"?"error":"warning",l=[{title:wn.t("Swapping"),value:L(r.inputUsdValue,4,4)},{title:wn.t("Gas cost"),value:L(r.totalFee,2,2)},{title:wn.t("Receiving"),value:L(r.outputUsdValue,4,4)},{title:wn.t("Price impact"),value:L(r.priceImpact,2,2),valueColor:`${s}500`}];return _t.createElement(J,{footer:_t.createElement(aT,{id:"widget-high-value-loss-warning-modal-confirm-btn",type:"primary",size:"large",prefix:_t.createElement(cT,null),fullWidth:!0,disabled:a,onClick:n},te().highValueLossError.confirmMessage),open:e,onClose:o,container:N()},_t.createElement(lT,{type:s,title:te().highValueLossError.impactTitle,description:te().highValueLossError.description}),_t.createElement(Es,null,_t.createElement(sT,{size:"4"}),_t.createElement(pT,{size:"small",variant:"title"},wn.t("Details")),_t.createElement(Es,null,l.map((p,u)=>_t.createElement(Wm,{key:u,...p})))))}i(Mm,"HighValueLossWarningModal");import{i18n as As}from"@lingui/core";function Lm(t,e){let o={alertType:"warning",title:"",action:null};return e?(o.alertType="error",e.type===3&&(o.title=e.recommendation),e.type===4&&(o.title=As.t({id:"You need to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:e.minRequiredSlippage}}),o.action="change-settings"),o):t?(t.type===0&&(Pt(t.priceImpact)==="high"&&(o.alertType="error"),o.action="show-info",o.title=te().highValueLossError.title),t.type===1&&(o.title=te().unknownPriceError.title),t.type===2&&(o.title=As.t({id:"We recommend you to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:t.minRequiredSlippage}}),o.action="change-settings"),t.type===3&&(o.title=As.t("Caution, your slippage is high."),o.action="change-settings"),o):null}i(Lm,"makeAlerts");import{i18n as Ko}from"@lingui/core";import{Button as Bm,Divider as Pm,MessageBox as uT,Typography as mT}from"@rango-dev/ui";import ko from"react";import{useNavigate as dT}from"react-router-dom";function Dm(t){let{customSlippage:e,slippage:o}=y(),{open:n,onClose:r,onConfirm:a,warning:s,confirmationDisabled:l}=t,p=dT(),u=e??o;return ko.createElement(J,{anchor:"bottom",open:n,prefix:ko.createElement(Bm,{size:"small",id:"widget-slippage-warning-modal-change-settings-btn",variant:"ghost",onClick:()=>p("../"+D.settings)},ko.createElement(mT,{variant:"label",size:"medium",color:"$neutral900"},Ko.t("Change settings"))),container:N(),onClose:r},ko.createElement(uT,{type:"warning",title:s.type===3?Ko.t("High slippage"):Ko.t("Low slippage"),description:s.type===3?Ko.t({id:" Caution, your slippage is high (={userSlippage}). Your trade may be front run.",values:{userSlippage:u}}):Ko.t({id:"We recommend you to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:s.minRequiredSlippage}})},ko.createElement(Pm,{size:18}),ko.createElement(Pm,{size:32}),ko.createElement(Bm,{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(Dm,"SlippageWarningModal");import{Button as fT,MessageBox as gT,WarningIcon as hT}from"@rango-dev/ui";import ti from"react";function _m(t){let{open:e,onClose:o,onConfirm:n,confirmationDisabled:r}=t;return ti.createElement(J,{footer:ti.createElement(fT,{id:"widget-unknown-price-warning-modal-confirm-btn",type:"primary",size:"large",prefix:ti.createElement(hT,null),fullWidth:!0,disabled:r,onClick:n},te().unknownPriceError.confirmMessage),open:e,onClose:o,container:N()},ti.createElement(gT,{type:"warning",title:te().unknownPriceError.impactTitle,description:te().unknownPriceError.description}))}i(_m,"UnknownPriceWarningModal");function bn(t){let{warning:e,error:o,couldChangeSettings:n,showWarningModal:r,confirmationDisabled:a,refetchQuote:s,onOpenWarningModal:l,onCloseWarningModal:p,onConfirmWarningModal:u,onChangeSettings:c}=t,m={confirmationDisabled:a,open:r,onClose:p,onConfirm:u},f=o?.type===0||o?.type===1,g=Lm(e,o?.type===3||o?.type===4?o:null);return g&&!n&&(g.action=null),ot.createElement(ot.Fragment,null,f&&ot.createElement(vn,{error:o,fetch:s}),!!g&&ot.createElement(Em,null,ot.createElement(ST,{title:g.title,type:g.alertType,variant:"alarm",...g.action==="show-info"&&{action:ot.createElement(Am,{onClick:l},ot.createElement(kT,{size:12,color:"gray"}))},...g.action==="change-settings"&&{action:ot.createElement(CT,{id:"widget-quote-warning-error-change-settings-btn",size:"xxsmall",type:g.alertType,onClick:c},yT.t("Change"))}})),e&&ot.createElement(ot.Fragment,null,e.type===0&&ot.createElement(Mm,{...m,warning:e}),(e.type===3||e.type===2)&&ot.createElement(Dm,{...m,warning:e}),e.type===1&&ot.createElement(_m,{...m,warning:e})))}i(bn,"QuoteWarningsAndErrors");import ZT from"bignumber.js";import gi from"react";import{i18n as To}from"@lingui/core";import{Alert as FT,Divider as Xo,FullExpandedQuote as OT,InfoIcon as UT,NumericTooltip as gd,QuoteTag as zT,StepDetails as QT,TokenAmount as qT,Typography as Yo}from"@rango-dev/ui";import _s from"bignumber.js";import F,{useRef as HT,useState as GT}from"react";import{styled as Ns}from"@rango-dev/ui";var Ws=Ns("div",{width:"100%","& .position-top__skeleton":{paddingTop:"$10"}}),$m=Ns("div",{paddingBottom:"$15",variants:{dense:{true:{paddingBottom:0}}}}),Fm=Ns("div",{width:"100%",display:"flex"});import*as oi from"@radix-ui/react-collapsible";import{Button as TT,css as xn,darkTheme as xe,Image as Om,styled as qe,Typography as vT}from"@rango-dev/ui";var wT=300,Um=qe(oi.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"}}]}),zm=xn({padding:"$10 $15"}),Qm=qe(TT,{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"}}}),qm=qe("div",{borderRadius:"$xm",display:"flex",flexDirection:"column",alignItems:"start",justifyContent:"space-between",color:"$foreground",boxSizing:"border-box",position:"relative",variants:{selected:{true:{},false:{$$color:"$colors$neutral200",[`.${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"}}}}]}),Hm=xn({width:"100%",padding:"$15 $15 $10 $15"}),Gm=xn({display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingBottom:"$10",position:"relative"}),jo=xn({display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",".blockchainImage":{marginLeft:"-$8"}}),Vm=xn({display:"flex",alignItems:"center",".usd-value":{$$color:"$colors$neutral600",[`.${xe} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),Km=qe(oi.Trigger,{display:"flex",width:"100%",justifyContent:"space-between",alignItems:"center",height:"$36",padding:"$10 $15",boxSizing:"border-box",cursor:"pointer",border:"none",outline:"none",backgroundColor:"transparent",variants:{error:{true:{[`& ${Om}`]:{border:"1px $warning500 solid",borderRadius:"100%"}},false:{[`& ${Om}`]:{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"}}}),jm=qe("div",{width:"18px",height:"18px",borderRadius:"100%",display:"flex",justifyContent:"center",alignItems:"center",border:"1.5px transparent solid",img:{borderRadius:"100%"},variants:{state:{error:{borderColor:"$error500"},warning:{borderColor:"$warning500"}}}}),Xm=qe(Kr,{width:"100%",background:"inherit"}),Ms=qe("div",{display:"flex",justifyContent:"center",alignItems:"center",padding:"$2",transition:`all ${wT}ms ease`,variants:{orientation:{down:{transform:"rotate(0)"},up:{transform:"rotate(180deg)"}}}}),IF=qe("div",{height:"$12",marginLeft:"$10",marginRight:"$10",borderLeft:"1px solid $foreground"}),Ym=qe("div",{display:"flex",justifyContent:"center",margin:"0 $15",borderTop:"1px solid",$$color:"$colors$neutral300",[`.${xe} &`]:{$$color:"$colors$neutral400"},borderColor:"$$color"}),Zm=qe("div",{width:"$16",height:"$16",justifyContent:"center",alignItems:"center",display:"flex"}),Ls=qe(vT,{overflow:"hidden",textOverflow:"ellipsis",letterSpacing:.4}),Jm=qe("div",{display:"flex",flexWrap:"wrap"}),Bs=qe("div",{width:"18px",height:"18px",borderRadius:"100%",backgroundColor:"$background",cursor:"default",display:"flex",justifyContent:"center",alignItems:"center",border:"1.5px transparent solid",variants:{state:{error:{borderColor:"$error500"},warning:{borderColor:"$warning500"}}}}),Rm=qe("div",{display:"flex"}),ni=qe("div",{width:"100%",borderTopWidth:"1px",borderTopStyle:"solid",borderTopColor:"$neutral",margin:"$5 0",[`.${xe} &`]:{borderTopColor:"$neutral800"}});import{i18n as Nt}from"@lingui/core";import{ChevronDownIcon as xT,CloseIcon as ET,Divider as ai,IconButton as IT,NumericTooltip as AT,QuoteCost as NT,Typography as yt}from"@rango-dev/ui";import X,{useState as nd}from"react";import{css as bT,styled as ri}from"@rango-dev/ui";var ii=ri("div",{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"$5 0","&.total_payable_fee":{padding:"$12 0"}}),Ps=ri("div",{width:"100%",borderTop:"1px solid $neutral300",margin:"$10 0"}),ed=ri("div",{padding:"$20 0",display:"flex",flexDirection:"column","& .collapsible_trigger":{display:"flex",alignItems:"center"}}),td=ri("div",{padding:"$20 $20 $10",textAlign:"center",position:"relative","._icon-button":{position:"absolute",zIndex:10,top:"$16",right:"$16"}}),od=bT({display:"flex",flexDirection:"row",alignItems:"center",padding:"$5","&:hover":{"& ._typography, & svg":{color:"$secondary"}}});var WT=i(t=>t.fee.isZero()?null:X.createElement(ii,null,X.createElement(yt,{variant:"label",size:"medium",color:"neutral600"},t.label),X.createElement(yt,{variant:"label",size:"medium"},"$",L(t.fee,4,4))),"NonPayableFee");function rd(t){let[e,o]=nd(!1),[n,r]=nd(!1),{steps:a,quote:s,fee:l,time:p,feeWarning:u,showModalFee:c}=t,m=s?.swaps??[],f=N(),g=Oc(m);return X.createElement(X.Fragment,null,X.createElement(NT,{onClickFee:c?d=>{d.stopPropagation(),o(!e)}:void 0,fee:l,feeWarning:u,time:p,steps:a,tooltipGas:c?Nt.t("View more info"):void 0,tooltipContainer:f}),X.createElement(J,{container:f,open:e,header:X.createElement(td,null,X.createElement(yt,{variant:"title",size:"medium"},Nt.t("Gas & Fee Explanation")),X.createElement(IT,{id:"widget-quote-cost-details-modal-close-icon-btn",onClick:()=>o(!1),variant:"ghost"},X.createElement(ET,{color:"gray",size:14}))),onClose:()=>{o(!1)}},X.createElement(ed,null,X.createElement(yt,{variant:"title",size:"small"},Nt.t("Details")),X.createElement(ai,{size:10}),Object.entries(g.payable).flatMap(([d,h])=>h.map((k,S)=>{let C=`payable-fee-${S}`,T=Ba(k);return X.createElement(ii,{key:C},X.createElement(yt,{variant:"label",size:"medium",color:"neutral600"},Na(d,Nt.t)),X.createElement(AT,{content:k.amount,container:f},X.createElement(yt,{variant:"label",size:"medium"},L(k.amount,2,2)," ",k.asset.symbol," ($",L(T,4,4),")")))})),X.createElement(ii,{className:"total_payable_fee"},X.createElement(yt,{variant:"label",size:"medium"},Nt.t("Total Payable Fee")),X.createElement(yt,{variant:"label",size:"medium"},"$",L(l,4,4))),X.createElement(Ps,null),Object.keys(g.nonePayable).length&&X.createElement(Yr,{triggerAnchor:"bottom",onClickTrigger:()=>r(d=>!d),trigger:X.createElement("div",{className:od()},X.createElement(yt,{size:"small",variant:"body",color:"neutral700"},n?Nt.t("Hide non-payable fees"):Nt.t("Show non-payable fees")),X.createElement(ai,{size:4,direction:"horizontal"}),X.createElement(jr,{orientation:n?"up":"down"},X.createElement(xT,{size:12,color:"gray"}))),open:n},X.createElement(yt,{size:"small",variant:"title"},Nt.t("Description")),X.createElement(ai,{size:4}),X.createElement(yt,{size:"small",variant:"body",color:"neutral700"},Nt.t(`The following fees are considered in the transaction output and
2
- you won\u2019t need to pay extra gas for them.`)),X.createElement(ai,{size:10}),Object.entries(g.nonePayable).map(([d,h],k)=>{let S=Fc(h),C=Na(d,Nt.t),T=`non-payable-fee-${k}`;return X.createElement(WT,{key:T,fee:S,label:C})}),X.createElement(Ps,null)))))}i(rd,"QuoteCostDetails");import{i18n as sd}from"@lingui/core";import{TokenAmount as ld}from"@rango-dev/ui";import si from"react";import{css as MT,styled as LT}from"@rango-dev/ui";var id=LT("div",{position:"relative",display:"flex",flexDirection:"column",width:"100%"}),ad=MT({height:"14px",marginLeft:"14px",position:"absolute",borderLeft:"1px solid $foreground",top:"42%"});function En(t){let{from:e,to:o,percentageChange:n,warningLevel:r}=t;return si.createElement(id,null,si.createElement(ld,{direction:"horizontal",label:sd.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}}),si.createElement("div",{className:ad()}),si.createElement(ld,{direction:"horizontal",tooltipContainer:N(),label:sd.t("Estimated output"),type:"output",price:{value:o.price.value,usdValue:o.price.usdValue,realValue:o.price.realValue,realUsdValue:o.price.realUsdValue},token:{displayName:o.token.displayName,image:o.token.image},chain:{image:o.chain.image},percentageChange:n,warningLevel:r}))}i(En,"QuoteSummary");import{i18n as dd}from"@lingui/core";import{ChevronDownIcon as DT,ChevronRightIcon as _T,Divider as Ds,Image as $T,Tooltip as mi,Typography as pi}from"@rango-dev/ui";import O from"react";import{useLayoutEffect as BT,useState as In}from"react";var pd=480,cd=768,ud=1024,md=1200,PT=i(()=>{let[t,e]=In(!1),[o,n]=In(!1),[r,a]=In(!1),[s,l]=In(!1),[p,u]=In(!1),c=i(()=>{e(window.innerWidth<=pd),n(window.innerWidth>pd&&window.innerWidth<=cd),a(window.innerWidth>cd&&window.innerWidth<=ud),l(window.innerWidth>ud&&window.innerWidth<=md),u(window.innerWidth>md)},"handleResize");return BT(()=>(c(),window.addEventListener("resize",c),()=>window.removeEventListener("resize",c)),[]),{isMobile:t,isTablet:o,isNotebook:r,isLargeScreen:s,isExtraLargeScreen:p}},"useScreenDetect"),li=PT;var ci=4,ui=6,An=i(t=>{let{content:e,src:o,className:n,open:r,state:a,container:s}=t,l=s||N();return O.createElement(mi,{container:l,side:"bottom",sideOffset:4,open:r,content:e},O.createElement(jm,{className:n,state:a},O.createElement($T,{src:o,size:16})))},"ImageComponent");function fd(t){let{quoteRef:e,selected:o,setExpanded:n,steps:r,expanded:a,type:s,container:l}=t,p=l||N(),u=r.length,c=ou(r),{isTablet:m,isMobile:f}=li();return O.createElement(Km,{listItem:s==="list-item",ref:g=>e.current=g,selected:o,onClick:g=>{g.stopPropagation(),n(d=>!d)}},O.createElement("div",{className:jo()},O.createElement(pi,{variant:"body",size:"xsmall"},dd.t("Via:")),O.createElement(Ds,{direction:"horizontal",size:4}),r.map((g,d)=>{let h=`item-${d}`,k=O.createElement(Ms,null,O.createElement(_T,{size:12,color:"black"}));return f||m?O.createElement(O.Fragment,{key:h},O.createElement(An,{content:g.swapper.displayName,src:g.swapper.image,state:g.state,container:l}),d!==u-1&&O.createElement(O.Fragment,null,k)):O.createElement(O.Fragment,{key:h},u<=ci||u>ci&&d<ci-1?O.createElement(O.Fragment,null,O.createElement(An,{content:g.swapper.displayName,src:g.swapper.image,state:g.state,container:l}),d!==u-1&&O.createElement(O.Fragment,null,k)):d===ci-1&&O.createElement(mi,{container:p,side:"bottom",align:"end",sideOffset:4,content:O.createElement("div",{className:jo()},k,r.map((S,C)=>{let T=`image-${C}`;return C>=d&&O.createElement(O.Fragment,{key:T},O.createElement(An,{content:S.swapper.displayName,src:S.swapper.image,state:S.state,open:!1}),C!==u-1&&O.createElement(O.Fragment,null,k))}))},O.createElement(Bs,{state:r.find((S,C)=>C>=d&&(S.state==="error"||S.state==="warning"))?.state},O.createElement(pi,{size:"xsmall",variant:"body"},"+",u-d))))})),O.createElement("div",{className:jo()},O.createElement("div",{className:"blockchains_section"},O.createElement("div",{className:jo()},O.createElement(pi,{variant:"body",size:"xsmall"},dd.t("Chains:")),O.createElement(Ds,{direction:"horizontal",size:4}),c.map((g,d)=>O.createElement(O.Fragment,{key:g.displayName},c.length<=ui||c.length>ui&&d<ui-1?O.createElement(mi,{container:p,side:"bottom",content:g.displayName,sideOffset:4},O.createElement(An,{content:"",src:g.image,open:!1,className:d!==0?"blockchainImage":""})):d===ui-1&&O.createElement(mi,{container:p,side:"bottom",align:"end",sideOffset:4,content:O.createElement("div",{className:jo()},c.map((h,k)=>k>=d&&O.createElement(An,{key:h.displayName,content:"",src:h.image,open:!1,className:k>d?"blockchainImage":"",container:l})))},O.createElement(Bs,{className:"blockchainImage"},O.createElement(pi,{size:"xsmall",variant:"body"},"+",c.length-d))))),O.createElement(Ds,{direction:"horizontal",size:32}))),O.createElement(Ms,{orientation:a?"up":"down"},O.createElement(DT,{size:12,color:"black"}))))}i(fd,"QuoteTrigger");function $s(t){let{quote:e,input:o,output:n,error:r,warning:a,type:s,selected:l=!1,tagHidden:p=!0,showModalFee:u=!0,onClickAllRoutes:c,fullExpandedMode:m=!1,container:f}=t,g=y().blockchains(),{findToken:d}=y(),h=y().swappers(),{customSlippage:k,slippage:S}=y(),C=k||S,[T,v]=GT(t.expanded),w=HT(null),A=L(o.value,6,6),M=L(n.value,6,6),b=n.usdValue?L(n.usdValue,4,4):"",E=ct(o.usdValue,n.usdValue??null),x=L(E,2,2),W=Pt(E??0),$=i((ge,ve)=>ge.map((U,Ke)=>{let vt,lt=r?.type===3&&r.swap.swapperId===U.swapperId,wt=r?.type===4&&r.recommendedSlippages?.has(Ke),_=a?.type===2&&a.recommendedSlippages?.has(Ke),Q=lt||wt,G=_;Q?vt="error":G&&(vt="warning");let pe=Q?To.t("Slippage Error"):To.t("Slippage Warning");return lt&&(pe=To.t("Bridge Limit Error")),{swapper:{displayName:on(U.swapperId,h)??"",image:U.swapperLogo},from:{token:{displayName:U.from.symbol,image:U.from.logo},chain:{displayName:pt(U.from.blockchain,g)??"",image:U.from.blockchainLogo},price:{value:Ke===0&&!ve?L(o.value,6,6):L(U.fromAmount,6,6),usdValue:L((U.from.usdPrice??0)*parseFloat(U.fromAmount),4,4),realValue:Ke===0?o.value:U.fromAmount,realUsdValue:new _s(U.from.usdPrice??0).multipliedBy(U.fromAmount).toString()}},to:{token:{displayName:U.to.symbol,image:U.to.logo},chain:{displayName:pt(U.to.blockchain,g)||"",image:U.to.blockchainLogo},price:{value:L(U.toAmount,6,6),usdValue:L((U.to.usdPrice??0)*parseFloat(U.toAmount),4,4),realValue:U.toAmount,realUsdValue:new _s(U.to.usdPrice??0).multipliedBy(U.toAmount).toString()}},state:vt,alerts:Q||G?F.createElement($m,{dense:m},F.createElement(FT,{variant:"alarm",type:Q?"error":"warning",title:pe,footer:F.createElement(Fm,null,lt&&F.createElement("div",null,F.createElement(Yo,{size:"xsmall",variant:"body",color:"neutral900"},r.fromAmountRangeError),F.createElement(Xo,{direction:"vertical",size:2}),F.createElement(Yo,{size:"xsmall",variant:"body",color:"neutral900"},To.t({id:"Yours: {amount} {symbol}",values:{amount:L(U.fromAmount,6,6),symbol:U?.from.symbol}}))),(wt||_)&&!lt&&F.createElement("div",null,F.createElement(Yo,{size:"xsmall",variant:"body",color:"neutral900"},To.t({id:"Minimum required slippage: {minRequiredSlippage}",values:{...r?.type===4&&{minRequiredSlippage:r.recommendedSlippages?.get(Ke)},...a?.type===2&&{minRequiredSlippage:a.recommendedSlippages?.get(Ke)}}})),F.createElement(Xo,{direction:"vertical",size:2}),F.createElement(Yo,{size:"xsmall",variant:"body",color:"neutral900"},To.t({id:"Yours: {userSlippage}",values:{userSlippage:C}}))))})):void 0,time:sn(U.estimatedTimeInSeconds),fee:L(La(U,d),2,2),internalSwaps:U.internalSwaps?$(U.internalSwaps):void 0}}),"getQuoteSteps"),I=$(e?.swaps??[]),R=I.length,ee=f||N(),oe=ru(t.quote.tags||[]),B=!!c,V=sn(ar(e?.swaps)),le=Wr(e?.swaps??[],d),Y=L(le,2,2),ae=le.gte(new _s(Lc));return m?F.createElement(OT,{selected:l,fee:Y,time:V,tooltipContainer:an(),steps:I,tags:oe,feeWarning:ae,percentageChange:x,warningLevel:W,outputPrice:{value:M,usdValue:b,realValue:n.value,realUsdValue:n.usdValue}}):F.createElement(qm,{selected:l,listItem:s==="list-item",basic:s==="basic"},F.createElement("div",{className:Hm()},!p&&oe.length?F.createElement(F.Fragment,null,F.createElement(Rm,null,oe.map((ge,ve)=>{let U=`${ge.value}_${ve}`;return F.createElement(F.Fragment,{key:U},F.createElement(zT,{label:ge.label,value:ge.value}),F.createElement(Xo,{size:4,direction:"horizontal"}))})),F.createElement(ni,null),!B&&F.createElement(Xo,{size:4})):null,F.createElement("div",{id:"portal-root",className:Gm()},F.createElement(rd,{quote:e,time:V,fee:Y,feeWarning:ae,showModalFee:u,steps:R}),B&&F.createElement(Qm,{onClick:ge=>{ge.stopPropagation(),c()},size:"xxsmall",type:"secondary",variant:"default",css:{paddingLeft:"$10",paddingRight:"$10",paddingTop:"$5",paddingBottom:"$5"}},F.createElement(Yo,{color:"secondary",variant:"body",size:"xsmall",className:"allRoutesLabel"},To.t("See All Routes")))),s==="basic"&&F.createElement("div",{className:Vm()},F.createElement(Zm,null,F.createElement(UT,{size:12,color:"gray"})),F.createElement(Jm,null,F.createElement(Ls,{size:"small",variant:"body"},`${A} ${I[0].from.token.displayName} = `),F.createElement(gd,{content:n.value,container:ee,open:n.value?void 0:!1},F.createElement(Ls,{size:"small",variant:"body"},"\xA0",`${M} ${I[I.length-1].to.token.displayName}`))),F.createElement(gd,{content:n.usdValue,container:ee},F.createElement(Xo,{size:2,direction:"horizontal"}),F.createElement(Yo,{color:"$neutral600",size:"xsmall",variant:"body"},`($${b})`))),s==="list-item"&&F.createElement(qT,{tooltipContainer:ee,type:"output",direction:"vertical",price:{value:M,usdValue:b,realValue:n.value,realUsdValue:n.usdValue},token:{displayName:I[R-1].to.token.displayName,image:I[R-1].to.token.image},chain:{image:I[R-1].to.chain.image},percentageChange:x,warningLevel:W}),s==="swap-preview"&&F.createElement(F.Fragment,null,F.createElement(En,{from:I[0].from,to:I[R-1].to,percentageChange:x,warningLevel:W}),F.createElement(Xo,{size:4}))),F.createElement(Um,{selected:l,listItem:s==="list-item",open:T,className:"quote_container",onOpenChange:v},F.createElement(fd,{type:s,quoteRef:w,selected:l,setExpanded:v,container:ee,expanded:T,steps:I}),F.createElement(Xm,{open:T},F.createElement(Ym,null),F.createElement("div",{className:zm()},I.map((ge,ve)=>{let U=`item-${ve}`;return F.createElement(QT,{type:"quote-details",key:U,tooltipContainer:ee,step:ge,hasSeparator:ve!==I.length-1,state:ge.state})})))))}i($s,"Quote");import{Divider as XT,Skeleton as YT}from"@rango-dev/ui";import Ft from"react";import{darkTheme as VT,styled as di}from"@rango-dev/ui";var hd=di("div",{$$color:"$colors$neutral100",[`.${VT} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",borderBottomLeftRadius:"$xm",borderBottomRightRadius:"$xm",padding:"$15",variants:{rounded:{true:{borderRadius:"$xm"}},expanded:{true:{paddingBottom:"3px"},false:{paddingBottom:"$12"}}}}),yd=di("div",{paddingTop:"$2"}),Sd=di("div",{paddingLeft:"$8"}),Cd=di("div",{borderLeft:"1px dashed $foreground",minHeight:" 0",margin:"0px 11.5px",alignSelf:"stretch",variants:{hideSeparator:{true:{minHeight:"unset",height:"0"}}}});import{ChainToken as Nd,Divider as St,Skeleton as nt}from"@rango-dev/ui";import q from"react";import{css as KT,styled as $t}from"@rango-dev/ui";var Fs=$t("div",{display:"flex"}),kd=$t("div",{padding:"$10 $0 $20"}),Td=$t("div",{padding:"14px $0 $20 $0",display:"flex",flexDirection:"column"}),vd=$t("div",{display:"flex",justifyContent:"start",alignItems:"center"}),wd=$t("div",{display:"flex",justifyContent:"space-between",alignItems:"end"}),bd=$t("div",{height:"$24",marginLeft:"13px",borderLeft:"1px solid $neutral700"}),xd=$t("div",{width:"65%",display:"flex",justifyContent:"start"}),Ed=$t("div",{display:"flex",flexDirection:"column",alignItems:"start",flexGrow:1,maxWidth:"148px"}),Id=$t("div",{padding:"$15 $0 $15 $0"}),Ad=KT({display:"flex",justifyContent:"space-between",alignItems:"center"});function Nn(t){let{type:e,tagHidden:o=!0}=t,n=q.createElement(wd,null,q.createElement(xd,null,q.createElement(Nd,{loading:!0,size:"medium",chainImage:"",tokenImage:""}),q.createElement(St,{size:8,direction:"horizontal"}),q.createElement(Ed,null,q.createElement(nt,{height:10,width:60,variant:"rounded"}),q.createElement(St,{size:4}),q.createElement(nt,{height:15,variant:"rounded"}))),q.createElement(nt,{height:12,width:64,variant:"rounded"})),r=e==="basic"&&!o;return q.createElement("div",null,!o&&q.createElement(q.Fragment,null,q.createElement(Fs,null,q.createElement(nt,{width:65,height:20,variant:"rounded"}),q.createElement(St,{size:4,direction:"horizontal"}),q.createElement(nt,{width:65,height:20,variant:"rounded"}),q.createElement(St,{size:4,direction:"horizontal"}),q.createElement(nt,{width:65,height:20,variant:"rounded"})),q.createElement(ni,null),!r&&q.createElement(St,{size:4})),q.createElement("div",{className:Ad()},q.createElement(Fs,null,q.createElement(nt,{width:60,height:10,variant:"rounded"}),q.createElement(St,{size:4,direction:"horizontal"}),q.createElement(nt,{width:60,height:10,variant:"rounded"}),q.createElement(St,{size:4,direction:"horizontal"}),q.createElement(nt,{width:60,height:10,variant:"rounded"})),r&&q.createElement(nt,{width:85,height:24,variant:"rounded"})),e==="basic"&&q.createElement(kd,null,q.createElement(nt,{height:15,width:148,variant:"rounded"})),e==="list-item"&&q.createElement(Td,null,q.createElement(vd,null,q.createElement(Nd,{loading:!0,size:"medium",chainImage:"",tokenImage:""}),q.createElement(St,{direction:"horizontal",size:4}),q.createElement(nt,{height:15,width:150,variant:"rounded"})),q.createElement(St,{size:10}),q.createElement(nt,{height:10,width:184,variant:"rounded"})),e==="swap-preview"&&q.createElement(q.Fragment,null,q.createElement(St,{size:4}),q.createElement(Id,null,n,q.createElement(bd,null),n),q.createElement(St,{size:12})))}i(Nn,"QuoteSummarySkeleton");import{ChainToken as Pd,Divider as Us,NextIcon as jT,Skeleton as fi}from"@rango-dev/ui";import Ee from"react";import{styled as Wn}from"@rango-dev/ui";var Wd=Wn("div",{display:"flex",alignItems:"start"}),Md=Wn("div",{flexGrow:1,paddingTop:"$5",paddingBottom:"$10",display:"flex",alignItems:"center",variants:{extraSpace:{true:{paddingBottom:"$40"}}}}),Os=Wn("div",{display:"flex",alignItems:"center",flexGrow:1}),Ld=Wn("div",{margin:"$0 $2",padding:"$4",display:"flex",justifyContent:"center",alignItems:"center"}),Bd=Wn("div",{display:"flex",alignItems:"center"});function Wt(t){let{separator:e=!0}=t;return Ee.createElement(Ee.Fragment,null,Ee.createElement(Bd,null,Ee.createElement(fi,{height:22,width:22,variant:"circular"}),Ee.createElement(Us,{direction:"horizontal",size:8}),Ee.createElement(fi,{height:15,width:148,variant:"rounded"})),Ee.createElement(Wd,null,Ee.createElement(Cd,{hideSeparator:!e}),Ee.createElement(Md,{extraSpace:e},Ee.createElement(Os,null,Ee.createElement(Pd,{size:"small",loading:!0,chainImage:"",tokenImage:""}),Ee.createElement(Us,{direction:"horizontal",size:8}),Ee.createElement(fi,{height:12,variant:"rounded"})),Ee.createElement(Ld,null,Ee.createElement(jT,{color:"gray",size:16})),Ee.createElement(Os,null,Ee.createElement(Pd,{size:"small",loading:!0,chainImage:"",tokenImage:""}),Ee.createElement(Us,{direction:"horizontal",size:8}),Ee.createElement(fi,{height:12,variant:"rounded"})))))}i(Wt,"StepSkeleton");function Mn(t){let{type:e,expanded:o,tagHidden:n=!1}=t;return Ft.createElement(hd,{expanded:o,rounded:e!=="basic"},Ft.createElement(Nn,{type:e,tagHidden:n}),Ft.createElement(yd,null,Ft.createElement(YT,{height:15,variant:"rounded"})),o&&Ft.createElement(Sd,null,Ft.createElement(XT,{size:24}),Ft.createElement(Wt,null),Ft.createElement(Wt,null),Ft.createElement(Wt,{separator:!1})))}i(Mn,"QuoteSkeleton");function vo(t){let{quote:e,type:o,loading:n,error:r,warning:a,expanded:s=!1,tagHidden:l,onClick:p,showModalFee:u,selected:c,onClickAllRoutes:m,fullExpandedMode:f=!1,container:g}=t,{inputAmount:d,inputUsdValue:h,toToken:k}=z(),S=e?.outputAmount?new ZT(e?.outputAmount):null,C=e?.outputAmount?jt(e?.outputAmount,go(e)||k?.usdPrice):null,v=!(r&&(r.type===0||r.type===1))&&e&&!n;return n?gi.createElement(Ws,null,gi.createElement(Mn,{tagHidden:l,type:o,expanded:s})):v?gi.createElement(Ws,{onClick:()=>p?.(e)},gi.createElement($s,{quote:e,error:r,container:g,showModalFee:u,warning:a,tagHidden:l,selected:c,type:o,expanded:s,onClickAllRoutes:m,fullExpandedMode:f,input:{value:d,usdValue:h?.toString()??""},output:{value:S?.toString()??"",usdValue:C?.toString()??""}})):null}i(vo,"QuoteInfo");import{calculatePendingSwap as tv}from"@rango-dev/queue-manager-rango-preset";import{useEffect as ov}from"react";import{useRef as JT,useState as RT}from"react";var ev=2e3;function hi({request:t}){let[e,o]=RT(!1),n=JT(null),r=i(()=>n.current?.abort(),"cancelFetch"),a=i(async l=>(await new Promise(p=>setTimeout(p,ev)),await s(l,!1)),"retryFetch"),s=i(async(l,p=!1)=>{r(),n.current=new AbortController,o(!0);try{let u=await t(l,{signal:n.current.signal});return n.current=null,u}catch(u){if(p)return await a(l);throw u}finally{o(!1)}},"fetch");return{fetch:s,loading:e,cancelFetch:r}}i(hi,"useFetch");function Dd(){let{fetch:t,loading:e,cancelFetch:o}=hi({request:async(n,r)=>await Et().confirmRoute(n,r)});return{fetch:t,loading:e,cancelFetch:o}}i(Dd,"useFetchConfirmQuote");function yi(t){if(!t.swaps)throw new Error(te().noResultError.title,{cause:{type:0,diagnosisMessage:t.diagnosisMessages?.[0]}});let e=zs(t.swaps);if(e)throw new Error(e.message,{cause:e.options})}i(yi,"throwErrorIfResponseIsNotValid");function zs(t){if(Dc(t)){let{swap:n,recommendation:r,fromAmountRangeError:a}=_c(t);return{message:"bridge limit error",options:{type:3,swap:n,recommendation:r,fromAmountRangeError:a}}}let o=Uc(t);if(o){let n=Mr(t);return{message:"",options:{type:4,recommendedSlippages:o,minRequiredSlippage:n}}}return null}i(zs,"getQuoteError");function _d(t,e,o){let n=!1;t&&(n=tu(t,e));let r={quote:null,quoteUpdate:null,balance:null},a=Fo(e,{fromToken:o.fromToken,toToken:o.toToken,findToken:o.findToken,userSlippage:o.userSlippage});a&&(r.quote=a),t&&n&&(Vc(t,e)?r.quoteUpdate={type:3,newOutputAmount:L($o(e)),percentageChange:L(ct($o(t)??"",$o(e)??""),null,2)}:Pa(t,e)?r.quoteUpdate={type:0}:Da(t,e)?r.quoteUpdate={type:1}:_a(t,e)&&(r.quoteUpdate={type:2}));let s=Kc(e,o.selectedWallets,o.meta.blockchains);return s.length===0||(r.balance={messages:s}),r}i(_d,"generateWarnings");function Si(t){return t?.code==="ERR_CANCELED"?{swap:null,error:{type:2},warnings:null}:t.cause?{swap:null,error:t.cause,warnings:null}:{swap:null,error:{type:1},warnings:null}}i(Si,"handleQuoteErrors");function Qs(){let{fromToken:t,toToken:e,inputAmount:o,setSelectedQuote:n,selectedQuote:r,customDestination:a,setQuoteWarningsConfirmed:s,resetAlerts:l}=z(),{slippage:p,customSlippage:u}=y(),c=y().getDisabledLiquiditySources(),m=y().blockchains(),f=y().tokens(),{findToken:g}=y(),d=u||p,{fetch:h,cancelFetch:k,loading:S}=Dd();return ov(()=>k,[]),{loading:S,fetch:i(async T=>{let v=T.selectedWallets,w=T?.customDestination??a;if(!t||!e||!o)return{quote:null,swap:null,error:null,warnings:null};let A=v.reduce((b,E)=>(b[E.chain]=E.address,b),{}),M={requestId:r?.requestId||"",selectedWallets:A,destination:w||void 0};try{return await h(M,!0).then(b=>{let{result:E}=b;if(!E)throw new Error("Error fetching updated route");yi({diagnosisMessages:E.diagnosisMessages,requestId:E.requestId,swaps:E.result?.swaps});let x={outputAmount:E.result?.outputAmount,requestId:E.requestId,resultType:E.result?.resultType,swaps:E.result?.swaps||[],validationStatus:E.validationStatus,requestAmount:E.requestAmount};n(x);let W={slippage:d.toString(),disabledSwappersGroups:c},$=_d(r??void 0,x,{fromToken:t,toToken:e,meta:{blockchains:m},findToken:g,selectedWallets:v,userSlippage:d});$.quoteUpdate&&s(!1),l();let I=!!$.balance,R=tv(o.toString(),E,Hc(v),W,!I,{blockchains:m,tokens:f});return{quote:x,swap:R,error:null,warnings:$}})}catch(b){return Si(b)}},"fetch"),cancelFetch:k}}i(Qs,"useConfirmSwap");var uv=iv("div",{width:"100%",display:"flex",justifyContent:"space-between",[`& ${Fd}`]:{width:"$48",height:"$48"}}),mv=Gs({flexGrow:1,paddingRight:"$10"}),dv=Gs({width:"$24",height:"$24",display:"flex",justifyContent:"center",alignItems:"center"}),fv=Gs({display:"flex",justifyContent:"space-between",alignItems:"center"});function Od(){let{selectedQuote:t,setInputAmount:e,selectedWallets:o,quoteWalletsConfirmed:n,customDestination:r,quoteWarningsConfirmed:a}=z(),s=cv(),[l,p]=Ln(""),u=!n,[c,m]=Ln(!1),[f,g]=Ln(!1),{isActiveTab:d}=se(),h=y().getDisabledLiquiditySources(),k=pv(h),{manager:S}=nv(),{fetch:C,loading:T,cancelFetch:v}=Qs(),[w,A]=Ln({swap:null,error:null,warnings:null}),[M,b]=Ln(!1),E=i(async({selectedWallets:B,customDestination:V})=>{let le=await C?.({selectedWallets:B,customDestination:V});return A(le),le},"onConfirmSwap"),x=i(async()=>{if(w.swap&&n)try{await S?.create("swap",{swapDetails:w.swap},{id:w.swap.requestId});let B=`../${D.swaps}/${w.swap.requestId}`;s(B,{replace:!0}),setTimeout(()=>{e("")},0)}catch(B){p("Error: "+B?.message)}},"addNewSwap"),W=i(async()=>{g(!0),await x(),g(!1)},"onConfirm"),$=i(async()=>{w?.warnings?.quote&&!a?b(!0):await W()},"onStartConfirmSwap"),I=i(async()=>{A({error:null,swap:null,warnings:null}),C({selectedWallets:o,customDestination:r}).then(B=>{A(B)}).catch(B=>console.error(B))},"onRefresh");Ci(()=>{!!k.current.length&&!h.length&&I(),k.current=h},[h.length]),Ci(()=>{u&&v()},[u]),Ci(()=>{u&&m(u)},[u]),Ci(()=>{u||C({selectedWallets:o,customDestination:r}).then(B=>A(B)).catch(B=>console.error(B))},[]),lv(()=>{t?.requestId||s(`../${location.search}`)},[t?.requestId]);let R=w.warnings?.quote??null,ee=w.error,oe=[];if(l&&oe.push(Ie.createElement($d,{type:"error",variant:"alarm",title:l})),w.warnings?.quoteUpdate&&oe.push(Ie.createElement($d,{variant:"alarm",type:"warning",title:w.warnings.quoteUpdate&&Gr(w.warnings.quoteUpdate)})),R||ee){let B=`../${D.settings}`;oe.push(Ie.createElement(bn,{warning:R,error:ee,couldChangeSettings:!1,refetchQuote:I,showWarningModal:M,confirmationDisabled:!d,onOpenWarningModal:()=>b(!0),onCloseWarningModal:()=>b(!1),onConfirmWarningModal:async()=>{b(!1),await x()},onChangeSettings:()=>s(B)}))}return Ie.createElement(ne,{header:{title:qs.t("Confirm Swap"),onWallet:()=>{let B=`../${D.wallets}`;s(B)}},footer:Ie.createElement(uv,null,Ie.createElement("div",{className:mv()},Ie.createElement(rv,{id:"widget-confirm-swap-start-btn",variant:"contained",type:"primary",size:"large",fullWidth:!0,loading:T||f,disabled:!!w.error||!d,onClick:$},qs.t("Start Swap"))),Ie.createElement(Fd,{id:"widget-confirm-swap-wallet-icon-btn",variant:"contained",type:"primary",size:"large",loading:T||f,disabled:!d,onClick:m.bind(null,!0)},Ie.createElement(sv,{size:24})))},c&&Ie.createElement(Sm,{open:c,onClose:()=>m(!1),onCancel:v,loading:T,onCheckBalance:E}),Ie.createElement(re,null,Ie.createElement("div",{className:fv()},Ie.createElement(av,{variant:"title",size:"small"},qs.t("You get")),Ie.createElement("div",{className:dv()},Ie.createElement(Or,{onClick:!T&&!c&&!M?I:void 0}))),Ie.createElement(Hs,{size:"12"}),Su(oe.map((B,V)=>({element:B,key:`alert-${V}`})),Ie.createElement(Hs,{size:10})),oe.length>0?Ie.createElement(Hs,{size:10}):null,Ie.createElement(vo,{quote:t,type:"swap-preview",expanded:!0,tagHidden:!0,error:w.error,loading:T,warning:w.warnings?.quote??null})))}i(Od,"ConfirmSwapPage");import{i18n as Ot}from"@lingui/core";import{Button as rl,CustomTokensZeroStateDarkIcon as Bv,CustomTokensZeroStateIcon as Pv,DeleteIcon as Dv,Divider as _n,IconButton as _v,MessageBox as $v,NotFound as Fv,styled as al}from"@rango-dev/ui";import fe,{useState as il}from"react";import{useNavigate as Ov}from"react-router-dom";import{CloseIcon as hv,IconButton as yv,SearchIcon as Sv,TextField as Cv}from"@rango-dev/ui";import Bn from"react";import{styled as gv}from"@rango-dev/ui";var Ud=gv("div",{width:"$24",height:"$24",display:"flex",alignItems:"center",justifyContent:"center"});function Ct(t){let{variant:e,fullWidth:o,color:n,size:r,onChange:a,value:s,style:l,setValue:p,...u}=t;return Bn.createElement(Cv,{prefix:Bn.createElement(Ud,null,Bn.createElement(Sv,{color:"black"})),suffix:!!s.length&&Bn.createElement(yv,{variant:"ghost",onClick:()=>p?.(""),size:"small"},Bn.createElement(hv,{color:"gray",size:10})),fullWidth:o,color:n,variant:e,style:{padding:10,borderRadius:25,alignItems:"center",...l},size:r,value:s,onChange:a,...u})}i(Ct,"SearchInput");import{i18n as ol}from"@lingui/core";import{darkTheme as Zd,Divider as Jo,ExternalLinkIcon as Ev,Image as Iv,ListItemButton as Av,NotFound as Nv,PinIcon as Wv,Skeleton as Jd,Typography as vi,VirtualizedList as Mv}from"@rango-dev/ui";import H,{useEffect as Rd,useState as ef}from"react";import{useWallets as kv}from"@rango-dev/wallets-react";import{useEffect as Tv,useRef as vv,useState as wv}from"react";function Vs(t){let{connectedWallets:e}=Z(),{getWalletInfo:o}=kv(),n=vv([]),[r,a]=wv(0);return Tv(()=>{let s=i(p=>{p.type==="disconnect"&&o(p.payload.walletType).supportedChains.some(m=>m.name===t)&&a(m=>m+1)},"handleWalletEvent");return yr.on("walletEvent",s),t?(e.filter(p=>p.chain===t).forEach(p=>{let{walletType:u}=p,c=n.current.includes(u);p.loading&&!c?n.current=n.current.concat(u):!p.loading&&c&&(n.current=n.current.filter(m=>m!==u),a(m=>m+1))}),()=>yr.off("walletEvent",s)):a(p=>p+1)},[e,t,o]),{balanceKey:r}}i(Vs,"useObserveBalanceChanges");import{Divider as Xd,ListItem as xv,Skeleton as Pn}from"@rango-dev/ui";import kt from"react";import{css as Zo,darkTheme as zd,ImageContainer as bv,styled as mt,Typography as Qd}from"@rango-dev/ui";var Ks=Zo({position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:100,overflow:"hidden"}),js=Zo({position:"relative",height:12,width:"30%",maxWidth:"150px"}),Xs=Zo({position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",bottom:"-8px"}),Ys=Zo({transform:"translateY(12px)",visibility:"hidden",display:"flex","& a":{display:"flex",justifyContent:"center",alignItems:"center",fontSize:"$12",lineHeight:"$16",$$color:"$colors$neutral600",[`.${zd} &`]:{$$color:"$colors$neutral700"},color:"$$color",textDecoration:"none"}}),Zs=Zo({}),Js=Zo(),qd=mt("div",{display:"flex",flexDirection:"column",flexGrow:1,overflow:"hidden",justifyContent:"center"}),Rs=mt("div",{display:"flex",alignItems:"center","._typography":{textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:100,overflow:"hidden"}}),ki=mt("ul",{flexGrow:1,padding:0,margin:0,listStyle:"none","& li":{alignItems:"none","&:hover":{[`& .${js}`]:{[`& .${Ys}`]:{position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",visibility:"visible"},[`& .${Zs}`]:{bottom:"-15px"},[`& .${Ks}`]:{position:"absolute",transform:"translateY(-12px)",visibility:"hidden"},[`& .${Xs}`]:{position:"absolute",transform:"translateY(-12px)",bottom:"-10px"}}}}}),el=mt("div",{paddingLeft:"$5",paddingRight:"$5",borderRadius:"$md",display:"flex",alignItems:"center"}),tl=mt(Qd,{}),Hd=mt("div",{textAlign:"right",width:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",[`& .${Js}`]:{$$color:"$colors$neutral600",[`.${zd} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),Ti=mt("div",{display:"flex",alignItems:"end",flexDirection:"column"}),LU=mt("div",{display:"flex",alignItems:"center"}),Gd=mt("div",{position:"relative",[`& ${bv}`]:{borderRadius:"$xm",overflow:"hidden"}}),Vd=mt("div",{position:"absolute",backgroundColor:"$neutral100",padding:"$4",borderRadius:"50%",bottom:-6,right:-6}),Kd=mt(Qd,{width:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}),jd=mt("a",{"& svg:hover":{color:"$colors$info"}});function Yd(t){return kt.createElement(ki,null,Array.from(Array(t.size),e=>kt.createElement(xv,{key:e,hasDivider:!0,start:kt.createElement(Pn,{variant:"circular",width:35,height:35}),end:kt.createElement(Ti,null,kt.createElement(Pn,{variant:"text",size:"large",width:70}),kt.createElement(Xd,{size:4}),kt.createElement(Pn,{variant:"text",size:"medium",width:50})),title:kt.createElement("div",null,kt.createElement(Pn,{variant:"text",size:"large",width:90}),kt.createElement(Xd,{size:4}),kt.createElement(Pn,{variant:"text",size:"medium",width:90}))})))}i(Yd,"LoadingTokenList");var nl=20,Lv=i(t=>{let{address:e,name:o,url:n,token:r,customCssForTag:a,customCssForTagTitle:s}=t,l=e.length;return H.createElement("div",{className:js()},o?H.createElement("div",{className:Ks()},o):H.createElement(Rs,{className:Xs()},H.createElement(vi,{variant:"title",size:"xmedium"},r.symbol),H.createElement(Jo,{direction:"horizontal",size:4}),H.createElement(el,{css:a},H.createElement(tl,{variant:"body",size:"xsmall",css:s},r.blockchain))),!!e&&H.createElement("div",{className:`${Ys()} ${!o&&Zs()}`},l>10?`${e.slice(0,5)}...${e.slice(l-6,l)}`:e," ",H.createElement(Jo,{size:4,direction:"horizontal"}),H.createElement(jd,{href:n,target:"_blank",rel:"nofollow noreferrer",onClick:p=>p.stopPropagation()},H.createElement(Ev,{size:12}))))},"renderDesc");function Dn(t){let{list:e,searchedFor:o="",onChange:n,selectedBlockchain:r,showTitle:a=!0,action:s}=t,[l,p]=ef(e),u=y().fetchStatus,c=y().blockchains(),[m,f]=ef(!0),{getBalanceFor:g,loading:d}=Z(),{isTokenPinned:h}=y(),{balanceKey:k}=Vs(r),S=i(()=>{p(e.slice(0,l.length+nl))},"loadNextPage");Rd(()=>{f(e.length>l.length)},[l.length]),Rd(()=>{p(e.slice(0,nl))},[e.length,r,k]);let C=i(v=>{let w=mr(g(v));return s?s(v):d?H.createElement(Ti,null,H.createElement(Jd,{variant:"text",size:"large",width:70}),H.createElement(Jo,{size:4}),H.createElement(Jd,{variant:"text",size:"medium",width:50})):w&&H.createElement(Hd,null,H.createElement(Kd,{variant:"title",size:"small"},w.amount),H.createElement("div",null),w.usdValue&&H.createElement(vi,{variant:"body",className:Js(),size:"xsmall"},`$${w.usdValue}`))},"endRenderer"),T=i(()=>H.createElement(Mv,{endReached:m?S:void 0,itemContent:v=>{let w=l[v],A=w.address||"",M=c.find(W=>W.name===w.blockchain),b=Xa(M.color,"main"),E={$$color:b.main150,[`.${Zd} &`]:{$$color:b.main750},backgroundColor:"$$color"},x={$$color:b.main750,[`.${Zd} &`]:{$$color:b.main150},color:"$$color"};return H.createElement("div",{style:{paddingRight:5}},H.createElement(Av,{style:{width:"100%",overflow:"hidden",height:"60px"},"tab-index":v,key:`${w.symbol}${w.address}`,id:`${w.symbol}${w.address}`,className:"widget-token-list-item-btn",hasDivider:!0,onClick:()=>n&&n(l[v]),start:H.createElement(Gd,null,H.createElement(Iv,{src:w.image,size:30}),t.type!=="custom-token"&&h(w,t.type)&&H.createElement(Vd,null,H.createElement(Wv,{size:12,color:"gray"}))),title:M?.type==="COSMOS"||w.name||!w.name&&!A?H.createElement(Rs,null,H.createElement(vi,{variant:"title",size:"xmedium"},w.symbol),H.createElement(Jo,{direction:"horizontal",size:4}),H.createElement(el,{css:E},H.createElement(tl,{variant:"body",size:"xsmall",css:x},w.blockchain))):void 0,description:M?.info&&A&&M.type!=="COSMOS"?Lv({address:A,token:l[v],customCssForTag:E,customCssForTagTitle:x,name:w.name,url:M.info.addressUrl.split("{wallet}").join(A)}):w.name||void 0,end:C(w)}))},totalCount:l.length,key:`${r}-${o}-${k}`}),"renderList");return H.createElement(H.Fragment,null,a&&H.createElement(H.Fragment,null,H.createElement(vi,{variant:"label",size:"large"},ol.t("Select Token")),H.createElement(Jo,{size:4})),H.createElement(qd,null,H.createElement(Jo,{size:4}),u==="loading"&&H.createElement(Yd,{size:nl}),u==="success"&&(l.length?H.createElement(ki,{as:"ul"},T()):!!o&&H.createElement(Nv,{title:ol.t("No results found"),description:ol.t("Try using different keywords")}))))}i(Dn,"TokenList");var Uv=al("div",{display:"flex",justifyContent:"space-between",flexDirection:"column",flex:1}),zv=al("div",{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",flex:"0.75"}),Qv=al(_v,{"&:hover":{"& svg":{color:"$secondary550"}}});function tf(){let[t,e]=il(""),{deleteCustomToken:o}=y(),n=y().customTokens(),{fromToken:r,toToken:a,setFromToken:s,setToToken:l}=z(),{mode:p}=Qo({}),u=Ov(),[c,m]=il(!1),[f,g]=il(),d=i(C=>{let T=C.target.value;e(T)},"handleSearch"),h=p==="dark",k=n.filter(C=>et(C.symbol,t)||et(C.address||"",t)||et(C.name||"",t)),S=i(()=>{if(f){let C=a?_e(a):null,T=r?_e(r):null,v=_e(f);C===v?l({token:null}):T===v&&s({token:null}),o(f)}m(!1)},"handleDeleteCustomToken");return fe.createElement(ne,{header:{title:Ot.t("Custom Tokens")}},fe.createElement(re,null,fe.createElement(Uv,null,n.length?fe.createElement(fe.Fragment,null,fe.createElement(Ct,{value:t,setValue:e,fullWidth:!0,color:"light",variant:"contained",placeholder:Ot.t("Search Token"),onChange:d}),fe.createElement(_n,{size:16}),fe.createElement(Dn,{list:k,type:"custom-token",searchedFor:t,showTitle:!1,action:C=>fe.createElement(Qv,{id:"widget-custom-token-delete-icon-btn",variant:"ghost",onClick:()=>{m(!0),g(C)}},fe.createElement(Dv,{size:12,color:"gray"}))})):fe.createElement(zv,null,fe.createElement(Fv,{icon:h?fe.createElement(Bv,{size:200}):fe.createElement(Pv,{size:200}),title:Ot.t("No custom tokens"),description:Ot.t("press the button to add your custom token")})),fe.createElement(_n,{size:20}),fe.createElement(rl,{id:"widget-custom-token-add-btn",type:"primary",variant:"contained",size:"large",onClick:()=>u(D.addCustomTokens)},Ot.t("Add Custom Token"))),fe.createElement(J,{open:c,dismissible:!0,onClose:()=>m(!1),container:N()},fe.createElement($v,{title:Ot.t("Delete Custom Token"),type:"error",description:Ot.t("Are you sure you want to Delete this Token?")},fe.createElement(_n,{size:40}),fe.createElement(_n,{size:10}),fe.createElement(rl,{fullWidth:!0,id:"widget-custom-token-delete-modal-yes-btn",variant:"contained",type:"primary",size:"large",onClick:S},Ot.t("Yes, Delete it")),fe.createElement(_n,{size:12}),fe.createElement(rl,{id:"widget-custom-token-delete-modal-no-btn",fullWidth:!0,variant:"outlined",type:"primary",size:"large",onClick:()=>m(!1)},Ot.t("No, Continue"))))))}i(tf,"CustomTokensPage");import{i18n as Ge}from"@lingui/core";import{useManager as sw}from"@rango-dev/queue-manager-react";import{Button as dl,darkTheme as lw,Divider as bo,MessageBox as pw,NotFound as cw,styled as fl,Typography as xi}from"@rango-dev/ui";import{TransactionStatus as On}from"rango-types";import ie,{useMemo as Tf,useState as Ei}from"react";import{useNavigate as uw}from"react-router-dom";import{FilterIcon as Xv,Popover as Yv}from"@rango-dev/ui";import wo from"react";import{css as qv,darkTheme as wi,IconButton as Hv,styled as $n}from"@rango-dev/ui";var sl=$n("div",{position:"relative","&::before":{position:"absolute",right:"1px",top:"-1px",width:"$8",height:"$8",borderRadius:"100%",backgroundColor:"$neutral300",[`.${wi} &`]:{backgroundColor:"$neutral400"},padding:"$2"},variants:{isSelect:{true:{"&::before":{content:""}}}}}),of=$n(Hv,{width:"$36",height:"$36",position:"relative",padding:"0",overflow:"unset",backgroundColor:"$neutral300",[`.${wi} &`]:{backgroundColor:"$neutral400"},"&:hover":{backgroundColor:"$secondary100",[`.${wi} &`]:{backgroundColor:"$neutral"},[`& ${sl}::before`]:{backgroundColor:"$secondary100",[`.${wi} &`]:{backgroundColor:"$neutral"}}},variants:{isSelect:{true:{border:"1px solid $secondary"}}}}),nf=$n("div",{position:"absolute",width:"$6",height:"$6",display:"flex",justifyContent:"center",alignItems:"center",borderRadius:"3px",top:"$0",right:"1px",backgroundColor:"$secondary500"}),rf=$n("div",{padding:"$15",borderRadius:"$sm",width:"248px",backgroundColor:"$background",zIndex:10}),af=qv({display:"flex",justifyContent:"space-between",alignItems:"center"}),sf=$n("ul",{margin:0,listStyle:"none",height:"100%",padding:0,".item-start-container":{paddingRight:"0 !important"}});import{i18n as lf}from"@lingui/core";import{Button as Gv,Divider as pf,ListItemButton as Vv,Radio as Kv,RadioRoot as jv,Typography as cf}from"@rango-dev/ui";import rt from"react";function uf(t){let{filterBy:e,onClickItem:o}=t;return rt.createElement(rf,null,rt.createElement("div",{className:af()},rt.createElement(cf,{size:"small",variant:"body"},lf.t("Status")),rt.createElement(Gv,{id:"widget-filter-selector-reset-btn",variant:"ghost",size:"xxsmall",onClick:()=>o("")},lf.t("Reset"))),rt.createElement(pf,{size:10}),rt.createElement(jv,{value:e},rt.createElement(sf,null,t.list.map((n,r)=>rt.createElement(Vv,{key:n.id,style:{height:"40px",width:"100%"},selected:!1,hasDivider:t.list.length-1!=r,id:n.id,title:rt.createElement(rt.Fragment,null,rt.createElement(pf,{direction:"horizontal",size:4}),rt.createElement(cf,{size:"medium",variant:"body"},n.title)),start:rt.createElement(Kv,{value:n.id}),onClick:o})))))}i(uf,"FilterSelectorContent");function ll(t){let{onClickItem:e,onOpenChange:o,filterBy:n,list:r,open:a}=t;return wo.createElement("div",null,wo.createElement(Yv,{open:a,align:"end",onOpenChange:o,container:N(),content:wo.createElement(uf,{list:r,filterBy:n,onClickItem:s=>{e(s),o(!1)}})},wo.createElement(of,{id:"widget-filter-selector-filter-icon-btn",variant:"default",isSelect:!!n,onClick:()=>o(!t.open)},wo.createElement(sl,{isSelect:!!n},wo.createElement(Xv,{size:16,color:"black"}),!!n&&wo.createElement(nf,null)))))}i(ll,"FilterSelector");import{i18n as Rv}from"@lingui/core";import{Divider as hf,GroupedVirtualizedList as ew,Skeleton as tw,SwapListItem as yf,Typography as ow}from"@rango-dev/ui";import He,{useCallback as Sf,useEffect as nw,useRef as rw,useState as iw}from"react";function mf(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(mf,"calculateGroupsSoFar");import{css as Zv,darkTheme as Jv,styled as Fn}from"@rango-dev/ui";var pl=Zv(),df=Fn("div",{display:"flex",justifyContent:"center",alignItems:"center",padding:"$5"}),cl=Fn("div",{width:"100%",display:"flex",flexDirection:"column",backgroundColor:"$background",padding:"$10 $5 0 $5",[`& .${pl}`]:{$$color:"$colors$neutral600",[`.${Jv} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),ul=Fn("div",{display:"flex",justifyContent:"flex-start",padding:"$2"}),ff=Fn("div",{gap:"$10",display:"flex",flexDirection:"column"}),gf=Fn("div",{height:"100%",display:"flex",justifyContent:"center",alignItems:"center"});var aw=10;function ml(t){let{list:e,onSwapClick:o,groupBy:n,isLoading:r}=t,[a,s]=iw([]),l=rw(0),{swaps:p,groupCounts:u,groups:c}=n(e),m=Sf(mf,[]),f=Sf(()=>{let g=e.length-l.current;g&&(l.current+=Math.min(g,aw),s(m(u,l.current)))},[e.length]);if(nw(()=>{r||f()},[r,f]),r){let g=[1,2];return He.createElement(He.Fragment,null,[g,g].map((h,k)=>He.createElement(cl,{key:k},He.createElement(ul,null,He.createElement(tw,{variant:"text",width:60,size:"small"}),He.createElement(hf,{size:16})),He.createElement(hf,{size:4}),He.createElement(ff,null,h.map((C,T)=>He.createElement(yf,{isLoading:!0,key:T}))))))}return He.createElement(ew,{endReached:()=>{l.current<e.length&&f()},groupCounts:a,groupContent:g=>He.createElement(cl,null,He.createElement(ul,null,He.createElement(ow,{variant:"label",size:"medium",className:pl()},c[g]))),itemContent:(g,d)=>{let h=p[g];if(!h)return null;let k=h.steps[0],S=h.steps[h.steps.length-1];return He.createElement(df,{key:h.requestId},He.createElement(yf,{requestId:h.requestId,creationTime:h.creationTime,status:h.status,onClick:o,tooltipContainer:N(),onlyShowTime:c[d]===Rv.t("Today"),swapTokenData:{from:{token:{image:k.fromLogo,displayName:k.fromSymbol},blockchain:{image:k.fromBlockchainLogo||""},amount:L(h.inputAmount,6,6),realAmount:h.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(ml,"HistoryGroupedList");import{i18n as bi}from"@lingui/core";import Cf from"dayjs";var kf=i(t=>{let e=new Map([["today",{title:bi.t("Today"),swaps:[]}],["week",{title:bi.t("This week"),swaps:[]}],["month",{title:bi.t("This month"),swaps:[]}],["year",{title:bi.t("This year"),swaps:[]}]]);function o(p,u){e.has(p)||e.set(p,{title:p,swaps:[]}),e.get(p)?.swaps.push(u)}i(o,"addYearsToOutput");let n=Cf();t.forEach(p=>{let u=Number(p.creationTime),c=Cf(u);if(n.isSame(c,"day"))e.get("today")?.swaps.push(p);else if(n.isSame(c,"week"))e.get("week")?.swaps.push(p);else if(n.isSame(c,"month"))e.get("month")?.swaps.push(p);else if(n.isSame(c,"year"))e.get("year")?.swaps.push(p);else{let m=new Date(u).getFullYear().toString();o(m,p)}});let r=Array.from(e.values()).filter(p=>p.swaps.length>0),a=r.flatMap(p=>p.swaps),s=r.map(p=>p.swaps.length),l=r.map(p=>p.title);return{swaps:a,groupCounts:s,groups:l}},"groupSwapsByDate");var mw=fl("div",{overflowY:"visible",width:"100%",display:"flex",flexDirection:"column",gap:15,height:"100%"}),dw=fl("div",{display:"flex",justifyContent:"center",alignItems:"center"}),fw=fl("div",{"._typography":{color:"$neutral700",[`.${lw}&`]:{color:"$neutral900"}}}),gw=[{id:On.SUCCESS,title:Ge.t("Complete")},{id:On.RUNNING,title:Ge.t("Running")},{id:On.FAILED,title:Ge.t("Failed")}],hw=i((t,e)=>t?.length?t.filter(o=>bt(o.fromBlockchain,e)||bt(o.toBlockchain,e)||bt(o.toSymbol,e)||bt(o.fromSymbol,e)).length:!1,"isStepContainsText");function vf(){let t=uw(),{manager:e,state:o}=sw(),n=ut(e).map(({swap:T})=>T),[r,a]=Ei(""),[s,l]=Ei(!1),p=!o.loadedFromPersistor,[u,c]=Ei(""),[m,f]=Ei(!1),g=i(T=>{let v=T.target.value;a(v)},"handleSearch"),d=Tf(()=>!r&&!u?n:n.filter(T=>{let{inputAmount:v,status:w,steps:A,requestId:M}=T;return(!r||bt(v,r)||bt(w,r)||hw(A,r)||bt(M,r))&&(!u||u===w)}),[n,r,u]),h=!d?.length&&!p,k=i(()=>f(!1),"onCloseModal"),S=i(async()=>{try{await e?.clearQueue(),f(!1)}catch(T){console.log(T)}},"onClear"),C=Tf(()=>!n.some(T=>T.status===On.SUCCESS||T.status===On.FAILED),[n]);return ie.createElement(ne,{header:{title:Ge.t("History"),suffix:ie.createElement(Vt,null,ie.createElement(dl,{id:"widget-history-clear-btn",disabled:C,variant:"ghost",size:"xsmall",onClick:()=>f(!0)},ie.createElement(xi,{size:"medium",variant:"label",color:"error"},Ge.t("Clear"))))}},ie.createElement(re,null,ie.createElement(dw,null,ie.createElement(Ct,{setValue:a,fullWidth:!0,variant:"contained",placeholder:Ge.t("Search Transaction"),autoFocus:!0,onChange:g,style:{height:36},value:r}),ie.createElement(bo,{size:10,direction:"horizontal"}),ie.createElement(ll,{filterBy:u,open:s,onOpenChange:T=>l(T),onClickItem:T=>c(T),list:gw})),ie.createElement(bo,{size:"16"}),ie.createElement(mw,null,h&&ie.createElement(gf,null,ie.createElement(bo,{size:32}),ie.createElement(cw,{title:r?Ge.t("No results found"):Ge.t("No transactions"),titleColor:r?void 0:"$info",hasIcon:!!r,description:r?Ge.t("Try using different keywords"):Ge.t("Your transaction history is stored locally and will appear here after you start a swap")})),!h&&ie.createElement(ml,{list:d,onSwapClick:t,groupBy:kf,isLoading:p}))),ie.createElement(J,{open:m,onClose:k,container:N()},ie.createElement(bo,{size:20}),ie.createElement(pw,{type:"warning",title:Ge.t("Clear Transaction History"),description:ie.createElement(fw,null,ie.createElement(xi,{variant:"body",size:"medium"},Ge.t("Proceeding will remove all successful and failed transactions from the widget. Do you want to continue?")),ie.createElement(bo,{size:"24"}),ie.createElement(xi,{variant:"body",size:"small"},Ge.t("Note: This does not erase your transaction history on the chain; it only removes them here.")))}),ie.createElement(bo,{size:30}),ie.createElement(dl,{id:"widget-history-clear-modal-yes-btn",variant:"contained",type:"primary",size:"large",onClick:S},Ge.t("Yes, Clear the history")),ie.createElement(bo,{size:10}),ie.createElement(dl,{id:"widget-history-clear-modal-no-btn",variant:"outlined",type:"primary",size:"large",onClick:k},ie.createElement(xi,{variant:"title",size:"medium",color:"primary"},Ge.t("No, Cancel")))))}i(vf,"HistoryPage");import{i18n as Dw}from"@lingui/core";import{Button as _w,Divider as zf,styled as $w,WarningIcon as Fw}from"@rango-dev/ui";import Ow from"bignumber.js";import Je,{useEffect as Qf,useState as qf}from"react";import{useNavigate as Uw}from"react-router-dom";import{i18n as vw}from"@lingui/core";import{Header as ww}from"@rango-dev/ui";import Rt,{useEffect as bw,useState as xw}from"react";import{i18n as Sw}from"@lingui/core";import{Divider as hl,FullExpandedQuote as Cw,Typography as kw}from"@rango-dev/ui";import Ce from"react";import{styled as gl}from"@rango-dev/ui";var wf=gl("div",{display:"flex",justifyContent:"center",flexDirection:"column",height:"100%"}),bf=gl("div",{display:"flex",justifyContent:"space-between",alignItems:"center"}),xf=gl("div",{width:"146px"});import{i18n as Un}from"@lingui/core";import{Select as yw}from"@rango-dev/ui";import Ef from"react";function Ii(t){let{updateQuotePartialState:e,sortStrategy:o}=z(),n=[{value:"SMART",label:Un.t("Smart Routing")},{value:"FEE",label:Un.t("Lowest Fee")},{value:"SPEED",label:Un.t("Fastest Transfer")},{value:"NET_OUTPUT",label:Un.t("Maximum Return")},{value:"PRICE",label:Un.t("Maximum Output")}];return Ef.createElement(xf,null,Ef.createElement(yw,{container:t.container,options:n,value:o,handleItemClick:r=>{e("sortStrategy",r.value)},variant:"filled"}))}i(Ii,"SelectStrategy");var If=3;function zn(t){let{loading:e,onClickOnQuote:o,fetch:n,showModalFee:r,hasSort:a=!0,fullExpandedMode:s=!1,container:l}=t,{selectedQuote:p,quotes:u,updateQuotePartialState:c,fromToken:m,toToken:f,sortStrategy:g,error:d}=z(),{slippage:h,customSlippage:k}=y(),{findToken:S}=y(),C=l||N(),T=!!u&&u.results.length,v=k??h,w=i(b=>{if(!m||!f||!u)return null;let E={requestAmount:u.requestAmount,validationStatus:null,...b};return Fo(E,{fromToken:m,toToken:f,userSlippage:v,findToken:S})},"getQuoteWarning"),A=d?.type===0||d?.type===1,M=u?.results?Pr(g,u?.results):[];return Ce.createElement(Ce.Fragment,null,a&&Ce.createElement(Ce.Fragment,null,Ce.createElement(bf,null,Ce.createElement(kw,{size:"xmedium",variant:"title"},Sw.t("Sort by")),Ce.createElement(Ii,{container:C})),Ce.createElement(hl,{size:"10"})),e&&Array.from({length:If},(b,E)=>Ce.createElement(Ce.Fragment,{key:E},s?Ce.createElement(Cw,{loading:!0}):Ce.createElement(Mn,{tagHidden:!1,type:"list-item",expanded:!1}),E!==If-1&&Ce.createElement(hl,{size:16}))),!e&&Ce.createElement(Ce.Fragment,null,T?M.map((b,E)=>{let x=w(b),W=zs(b.swaps),$=M.length-1===E;return Ce.createElement(Ce.Fragment,{key:b.requestId},Ce.createElement(vo,{showModalFee:r,container:C,selected:p?.requestId===b.requestId,tagHidden:!1,quote:{...b,requestAmount:u.requestAmount,validationStatus:null},loading:e,error:W?.options||null,warning:x,fullExpandedMode:s,onClick:I=>{W||c("warning",x),c("error",W?.options||null),o(I)},type:"list-item"}),!$&&Ce.createElement(hl,{size:16}))}):A&&Ce.createElement(wf,null,Ce.createElement(vn,{size:s?"large":"small",error:d,fetch:n}))))}i(zn,"Quotes");import{darkTheme as Tw,styled as Af}from"@rango-dev/ui";var Nf=Af("div",{transition:"width 0.2s, opacity 0.2s, margin-left 0.2s",height:"700px",width:"390px",opacity:1,marginLeft:"$16",backgroundColor:"$neutral100",[`.${Tw} &`]:{backgroundColor:"$neutral300"},variants:{expandMode:{default:{width:"390px"},full:{width:"719px"}}},"&.is-hidden":{width:0,height:0,opacity:0,marginLeft:0}}),Wf=Af("div",{position:"relative",overflow:"hidden",padding:"$20",flexGrow:1,display:"flex",flexDirection:"column",overflowY:"auto",borderRadius:"$primary",backgroundColor:"$background"});var Ew=100;function yl(t){let{fetch:e,loading:o,onClickOnQuote:n,onClickRefresh:r,isVisible:a}=t,[s,l]=xw(!1),p=s?"":"is-hidden",{config:u}=y(),c=u?.variant==="full-expanded",m=an();return bw(()=>{let f=null;return a?f=setTimeout(()=>{l(!0)},Ew):(l(!1),f&&clearTimeout(f)),()=>{f&&clearTimeout(f)}},[a]),Rt.createElement(Nf,{expandMode:u?.variant==="full-expanded"?"full":"default",className:`${p} ${Qr()}`,id:$e.EXPANDED_BOX_ID},Rt.createElement(ww,{title:vw.t("Routes"),suffix:Rt.createElement(Rt.Fragment,null,Rt.createElement(Ii,{container:m}),Rt.createElement(yo,{container:m,onClickRefresh:r,hidden:["history","notifications","settings"]}))}),Rt.createElement(Wf,null,Rt.createElement(zn,{showModalFee:!1,fetch:e,hasSort:!1,loading:o,container:an(),onClickOnQuote:n,fullExpandedMode:c})))}i(yl,"ExpandedQuotes");import{i18n as $f}from"@lingui/core";import{SwapInput as Ff}from"@rango-dev/ui";import Qn from"react";import{ReverseIcon as Nw}from"@rango-dev/ui";import Cl from"react";import{keyframes as Iw,styled as Mf}from"@rango-dev/ui";var Sl=450,Aw=Iw({"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)"}}),Lf=Mf("div",{position:"absolute",bottom:"-12px",left:"50%",transform:"translate(-50%, 10%)",cursor:"pointer"}),Bf=Mf("div",{borderRadius:"$md",border:"3px solid $background",background:"$neutral100",width:"$24",height:"$24",display:"flex",justifyContent:"center",alignItems:"center",color:"$foreground","&.rotate":{"& svg":{animation:`${Aw} ${Sl}ms ease-in-out forwards`}},"&:hover":{color:"$secondary500",transform:"translateY(1px) scale(1.04)",boxShadow:"1px 1px 1px 1px rgba(0, 0, 0, 0.05)"}});function kl(){let t=z.use.switchFromAndTo();return Cl.createElement(Lf,null,Cl.createElement(Bf,{onClick:e=>{let o=e.currentTarget;o.classList.add("rotate"),setTimeout(()=>{o.classList.remove("rotate")},Sl),t()}},Cl.createElement(Nw,{size:12})))}i(kl,"SwitchFromAndToButton");import{styled as Pf}from"@rango-dev/ui";var Df=Pf("div",{display:"flex",flexDirection:"column",gap:"$5",alignSelf:"stretch"}),_f=Pf("div",{position:"relative"});function Tl(t){let{fetchingQuote:e,fetchMetaStatus:o,onClickToken:n,isExpandable:r}=t,{fromToken:a,fromBlockchain:s,toToken:l,toBlockchain:p,setInputAmount:u,inputAmount:c,inputUsdValue:m,outputAmount:f,outputUsdValue:g,selectedQuote:d}=z(),{connectedWallets:h,getBalanceFor:k}=Z(),S=a?k(a):null,C=mr(S)?.amount??"0",T=s&&a?L(S?.amount,S?.decimals):"0",v=!!s&&$p(h,s.name),w=!Ma(d,c,m),A=!Ma(d,c,g),M=!m||!g||!g.gt(0)?null:ct(m.toString(),g.toString());return Qn.createElement(Df,null,Qn.createElement(_f,null,Qn.createElement(Ff,{label:$f.t("From"),mode:"From",onInputChange:u,balance:C,chain:{displayName:s?.displayName||"",image:s?.logo||""},token:{displayName:a?.symbol||"",image:a?.image||""},onClickToken:()=>n("from"),price:{value:c,usdValue:w?void 0:L(m,4,4),realUsdValue:w?void 0:m?.toString(),error:w?te().unknownPriceError.impactTitle:void 0},disabled:o==="failed",loading:o==="loading",loadingBalance:v,tooltipContainer:N(),onSelectMaxBalance:()=>{u(T.split(",").join(""))},anyWalletConnected:h.length>0}),Qn.createElement(kl,null)),Qn.createElement(Ff,{sharpBottomStyle:!r&&(!!d||e),label:$f.t("To"),mode:"To",fetchingQuote:e,chain:{displayName:p?.displayName||"",image:p?.logo||""},token:{displayName:l?.symbol||"",image:l?.image||""},percentageChange:L(ct(m,g),2,2),warningLevel:Pt(M??0),price:{value:L(f,6,6),usdValue:A?void 0:L(g,4,4),realValue:f?.toString(),realUsdValue:A?void 0:g?.toString(),error:A?te().unknownPriceError.impactTitle:void 0},onClickToken:()=>n("to"),disabled:o==="failed",loading:o==="loading",tooltipContainer:N()}))}i(Tl,"Inputs");import{useCallback as Ww,useEffect as Mw,useRef as Lw,useState as Bw}from"react";function Of(){let{fetch:t,loading:e,cancelFetch:o}=hi({request:async(n,r)=>await Et().getAllRoutes(n,r)});return{fetch:t,loading:e,cancelFetch:o}}i(Of,"useFetchAllQuotes");var Pw=600;function Ai({refetchQuote:t}){let{fetch:e,cancelFetch:o}=Of(),{excludeLiquiditySources:n,features:r,enableCentralizedSwappers:a}=y().config,s=Z.use.connectedWallets(),{fromToken:l,toToken:p,inputAmount:u,inputUsdValue:c,selectedQuote:m,sortStrategy:f,resetQuote:g,error:d,warning:h,setSelectedQuote:k,updateQuotePartialState:S}=z(),{slippage:C,customSlippage:T,affiliatePercent:v,affiliateRef:w,affiliateWallets:A,fetchStatus:M}=y(),b=y().getLiquiditySources(),E=y().getDisabledLiquiditySources(),x=y().excludeLiquiditySources(),{findToken:W}=y(),[$,I]=Bw(!0),R=Lw(u),ee=T??C,B=!l||!p||ao(l,p)||!ln(u),V=i(ae=>{I(ae)},"resetState"),le=i(ae=>{let{fromToken:ge,toToken:ve,inputAmount:U,liquiditySources:Ke,excludeLiquiditySources:vt,disabledLiquiditySources:lt,slippage:wt,affiliateRef:_,affiliatePercent:Q,affiliateWallets:G}=ae;if($||V(!0),!B&&ge&&ve){g();let pe=qc({fromToken:ge,toToken:ve,inputAmount:U,liquiditySources:Ke,excludeLiquiditySources:vt,disabledLiquiditySources:lt,wallets:s,slippage:wt,affiliateRef:_,affiliatePercent:Q,affiliateWallets:G,enableCentralizedSwappers:a});Vp("experimentalRoute",r)&&(pe.experimental=!0),e(pe).then(ce=>{let de=Pr(f,ce.results),he=nu(m,de,ce.requestAmount);I(!1),S("quotes",ce),k(he),yi({diagnosisMessages:ce.diagnosisMessages,requestId:he?.requestId||"",swaps:he?.swaps});let Rn=go(he)||ve?.usdPrice,ro=hn(he)||ge?.usdPrice,ea=he&&Fo(he,{fromToken:{...ge,usdPrice:ro},toToken:{...ve,usdPrice:Rn},userSlippage:ee,findToken:W});S("warning",ea)}).catch(ce=>{let{error:de}=Si(ce);(de?.type===0||de?.type===1)&&g(),de?.type!==2&&(S("error",de),I(!1))})}},"fetch"),Y=Ww(wp(ae=>{le(ae)},Pw),[B]);return Mw(()=>{if(!t){I(!1);return}if(M!=="success")return;if(B){I(!1),(m||d||h)&&g();return}if(!ln(u)||c?.eq(0)){V(!1),o();return}g(),V(!0);let ae=le;return R.current&&R.current!=u&&(ae=Y),R.current=u,ae({inputAmount:u,fromToken:l,toToken:p,liquiditySources:b,excludeLiquiditySources:x,disabledLiquiditySources:E,slippage:ee,affiliateRef:w,affiliatePercent:v,affiliateWallets:A}),o},[M,u,l?.symbol,l?.address,l?.blockchain,p?.symbol,p?.address,p?.blockchain,B,b?.length,n,E.length,ee,w,v,JSON.stringify(A)]),{fetch:()=>le({inputAmount:u,fromToken:l,toToken:p,liquiditySources:b,excludeLiquiditySources:x,disabledLiquiditySources:E,slippage:ee,affiliateRef:w,affiliatePercent:v,affiliateWallets:A}),loading:$}}i(Ai,"useSwapInput");function Uf(t,e){let o=!1,n={preventDefault(){o=!0},...t.payload===void 0&&{payload:t.payload}};ye.emit("uiEvent",{type:t.type,payload:n}),o||e()}i(Uf,"emitPreventableEvent");var zw=$w("div",{display:"flex",alignItems:"flex-start",maxHeight:700,"& .footer__alert":{paddingTop:"0 !important"}}),Qw=300;function Hf(){let t=Uw(),{fromToken:e,toToken:o,inputAmount:n,selectedQuote:r,refetchQuote:a,error:s,warning:l,quotes:p,setSelectedQuote:u,resetQuoteWallets:c,setQuoteWarningsConfirmed:m,updateQuotePartialState:f}=z(),[g,d]=qf(!1),{isLargeScreen:h,isExtraLargeScreen:k}=li(),{fetch:S,loading:C}=Ai({refetchQuote:a}),{config:T,fetchStatus:v}=y(),{connectedWallets:w}=Z(),{isActiveTab:A}=se(),[M,b]=qf(!1),x=$c({fetchMetaStatus:v,fetchingQuote:C,inputAmount:n,quote:r,anyWalletConnected:w.length>0,error:s,warning:l,needsToWarnEthOnPath:!1}),W=Hp(h,k,T?.variant),$=!!n&&!!e&&!!o&&new Ow(n).gt(0)&&!Jc(e,o),I=$&&v==="success"&&C,oe=(!W||W&&p?.results.length)&&(l||s);Qf(()=>{c(),f("refetchQuote",!0)},[]),Qf(()=>{d($)},[$]);let B=(r||s)&&!M?S:void 0,V=i(Y=>{W&&g?(d(!1),setTimeout(()=>{t(Y)},Qw)):t(Y)},"onHandleNavigation"),le=i(Y=>{r?.requestId!==Y.requestId&&(b(!1),u(Y))},"onClickOnQuote");return Je.createElement(zw,null,Je.createElement(ne,{height:"auto",footer:Je.createElement(_w,{id:`widget-swap-${x.action}-btn`,type:"primary",size:"large",disabled:x.disabled||!A,prefix:x.action==="confirm-warning"&&Je.createElement(Fw,null),fullWidth:!0,onClick:()=>{x.action==="connect-wallet"?Uf({type:"clickConnectWallet"},()=>V(D.wallets)):x.action==="confirm-warning"?b(!0):V(D.confirmSwap)}},x.title),header:{onWallet:()=>{V(D.wallets)},hasBackButton:!1,title:T.title||Dw.t("Swap"),suffix:Je.createElement(yo,{hidden:W?["refresh"]:void 0,onClickRefresh:B,onClickHistory:()=>V(D.swaps),onClickSettings:()=>{V(D.settings)}})}},Je.createElement(re,null,Je.createElement(Tl,{fetchingQuote:I,fetchMetaStatus:v,isExpandable:W,onClickToken:Y=>{V(Y==="from"?D.fromSwap:D.toSwap)}}),Je.createElement(zf,{size:"2"}),W?null:Je.createElement(vo,{quote:r,loading:I,error:s,tagHidden:!1,warning:l,type:"basic",onClickAllRoutes:p&&p.results.length>1?()=>{f("refetchQuote",!1),V(D.routes)}:void 0}),oe?Je.createElement(Je.Fragment,null,Je.createElement(zf,{size:"10"}),Je.createElement(bn,{warning:l,error:s,couldChangeSettings:!0,refetchQuote:S,showWarningModal:M,confirmationDisabled:!A,onOpenWarningModal:()=>b(!0),onCloseWarningModal:()=>b(!1),onConfirmWarningModal:()=>{b(!1),m(!0),V(D.confirmSwap)},onChangeSettings:()=>V(D.settings)})):null)),W?Je.createElement(yl,{loading:I,onClickOnQuote:le,fetch:S,onClickRefresh:B,isVisible:g}):null)}i(Hf,"Home");import{i18n as Gf}from"@lingui/core";import{Alert as qw,Divider as Hw,List as Gw,ListItemButton as Vw,Radio as Kw,RadioRoot as jw,Typography as Xw}from"@rango-dev/ui";import Mt from"react";function eo(){let{setLanguage:t,language:e,config:o}=y(),n=Yp,r=o?.language||Mo;return{activeLanguage:e||r,languages:n,defaultLanguage:r,changeLanguage:a=>t(a||Mo),resetLanguage:()=>t(null)}}i(eo,"useLanguage");function Vf(){let{activeLanguage:t,changeLanguage:e,languages:o}=eo(),n=Ye(),r=o.map(a=>{let{local:s,label:l,SVGFlag:p}=a;return{id:`widget-setting-languages-${s}-item-btn`,value:s,title:Mt.createElement(Xw,{variant:"title",size:"xmedium"},l),onClick:()=>{e(a.local),n()},end:Mt.createElement(Kw,{value:s}),start:Mt.createElement(p,null)}});return Mt.createElement(ne,{header:{title:Gf.t("Language")}},Mt.createElement(re,null,Mt.createElement(qw,{type:"warning",variant:"alarm",title:"Warning: We are using machine translation, so the translations may be inaccurate."}),Mt.createElement(Hw,{size:"8"}),Mt.createElement(jw,{value:t},Mt.createElement(Gw,{type:Mt.createElement(Vw,{title:Gf.t("language"),id:"_",onClick:()=>console.log()}),items:r}))))}i(Vf,"LanguagePage");import{i18n as Ut}from"@lingui/core";import{Button as eb,Checkbox as tb,Image as ob,ListItemButton as nb,NotFound as rb,Typography as ib}from"@rango-dev/ui";import Ve,{useState as ab}from"react";import{Checkbox as Jw,Skeleton as jf}from"@rango-dev/ui";import Hn from"react";import{styled as vl}from"@rango-dev/ui";var qn=vl("ul",{padding:"$15 $5 0",margin:0,listStyle:"none",height:"100%",overflowY:"auto",variants:{disabled:{true:{pointerEvents:"none"}}}}),wl=vl("div",{width:80,display:"flex",justifyContent:"flex-end"}),bl=vl("div",{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%"});import{ListItem as Yw,styled as Zw}from"@rango-dev/ui";var Kf=Zw(Yw,{height:61});var Rw=30;function xl(){return Hn.createElement(qn,null,Array.from(Array(Rw),(t,e)=>Hn.createElement(Kf,{hasDivider:!0,key:e,start:Hn.createElement(jf,{variant:"circular",width:35,height:35}),title:Hn.createElement(jf,{variant:"text",size:"large",width:90}),end:Hn.createElement(Jw,{checked:!1})})))}i(xl,"LoadingLiquiditySourceList");function El({sourceType:t}){let e=y().fetchStatus,o=y().swappers(),n=y().getDisabledLiquiditySources(),[r,a]=ab(""),s=y().toggleLiquiditySource,l=y().isInCampaignMode(),p=hr(o,n),u={Exchanges:Ut.t("Exchanges"),Bridges:Ut.t("Bridges")},c=[];t==="Exchanges"&&c.push("DEX"),t==="Bridges"&&c.push("BRIDGE","AGGREGATOR","OFF_CHAIN");let m=p.filter(S=>c.includes(S.type)),f=m.length===m.filter(S=>S.selected).length,g=i(()=>{m.forEach(S=>{f?s(S.groupTitle):S.selected||s(S.groupTitle)})},"toggleAllSources"),d=m.map(S=>{let{selected:C,groupTitle:T,logo:v,id:w,...A}=S;return{id:`widget-setting-liquidity-source-${w.toLowerCase().replace(/\s+/g,"-")}-item-btn`,start:Ve.createElement(ob,{src:v,size:22,type:"circular"}),onClick:()=>{l||s(T)},end:Ve.createElement(tb,{checked:C,disabled:l}),title:Ve.createElement(ib,{variant:"title",size:"xmedium"},Ut.t(T)),selected:C,groupTitle:T,logo:v,...A}}),h=i(S=>{let C=S.target.value;a(C)},"handleSearch"),k=d;return r&&(k=d.filter(S=>bt(S.groupTitle,r))),Ve.createElement(ne,{header:{title:Ut.t(t),suffix:Ve.createElement(wl,null,Ve.createElement(eb,{id:`widget-liquidity-source-${f?"deselect-all":"select-all"}-btn`,variant:"ghost",size:"xsmall",onClick:g},f?Ut.t("Deselect all"):Ut.t("Select all")))}},Ve.createElement(re,{view:!0},Ve.createElement(Ct,{value:r,setValue:a,fullWidth:!0,color:"light",variant:"contained",placeholder:Ut.t("Search {sourceType}",{sourceType:u[t]}),onChange:h}),e==="loading"&&Ve.createElement(xl,null),!k.length&&r?Ve.createElement(bl,null,Ve.createElement(rb,{title:Ut.t("No results found"),description:Ut.t("Try using different keywords")})):e==="success"&&Ve.createElement(qn,{disabled:l},k.map(S=>{let{groupTitle:C,...T}=S;return Ve.createElement(Ve.Fragment,{key:S.id},Ve.createElement(nb,{style:{height:"61px"},...T,selected:!1,hasDivider:!0}))}))))}i(El,"LiquiditySourcePage");import{i18n as sb}from"@lingui/core";import Ni from"react";import{useNavigate as lb}from"react-router-dom";function Xf(){let t=lb(),e=Ye(),{selectedQuote:o,refetchQuote:n,setSelectedQuote:r,updateQuotePartialState:a,error:s}=z(),{fetch:l,loading:p}=Ai({refetchQuote:n}),u=i(f=>{r(f),a("refetchQuote",!1),e()},"onClickOnQuote"),c=`../${D.settings}`,m=`../${D.wallets}`;return Ni.createElement(ne,{header:{onWallet:()=>{t(m),a("refetchQuote",!0)},onBack:()=>{a("refetchQuote",!1)},title:sb.t("Routes"),suffix:Ni.createElement(yo,{onClickRefresh:o||s?l:void 0,hidden:["notifications","history"],onClickSettings:()=>{t(c),a("refetchQuote",!0)}})}},Ni.createElement(re,null,Ni.createElement(zn,{fetch:l,loading:p,onClickOnQuote:u})))}i(Xf,"RoutesPage");import{i18n as og}from"@lingui/core";import{Divider as ng,getCategoriesCount as Sb,SelectableCategoryList as Cb}from"@rango-dev/ui";import zt,{useState as rg}from"react";import{useNavigate as kb}from"react-router-dom";import{i18n as Il}from"@lingui/core";import{Divider as mb,Image as db,ListItemButton as fb,NotFound as gb,Typography as tg}from"@rango-dev/ui";import it,{useEffect as hb,useState as yb}from"react";var Yf=i((t,e,o)=>t.filter(n=>ir(n.type,o)).filter(n=>et(n.name,e)||et(n.displayName,e)),"filterBlockchains");import{ImageContainer as pb,styled as Zf}from"@rango-dev/ui";var Jf=Zf("div",{display:"flex",flexDirection:"column",overflow:"hidden",height:"100%",justifyContent:"center"}),Wi=Zf(Sn,{padding:0,margin:0,listStyle:"none",[`& ${pb}`]:{borderRadius:"$xm",overflow:"hidden"}});import{ListItem as cb,Skeleton as Rf}from"@rango-dev/ui";import Mi from"react";var ub=20;function eg(){return Mi.createElement(Wi,null,Array.from(Array(ub),t=>Mi.createElement(cb,{key:t,hasDivider:!0,start:Mi.createElement(Rf,{variant:"circular",width:35,height:35}),title:Mi.createElement(Rf,{variant:"text",size:"large",width:90})})))}i(eg,"LoadingBlockchainList");function Al(t){let{list:e,searchedFor:o,onChange:n,blockchainCategory:r,showTitle:a=!0}=t,[s,l]=yb(e),{fetchStatus:p}=y();hb(()=>{l([...Yf(e,o,r)])},[e,o,r]);let u=i(()=>!s.length&&o?it.createElement(gb,{title:Il.t("No results found"),description:Il.t("Try using different keywords")}):it.createElement(Wi,{as:"ul",key:`${r}-${o}`},s.map(c=>it.createElement(fb,{key:`${c.name}-${c.chainId}`,className:"widget-blockchain-list-item-btn",hasDivider:!0,onClick:()=>n(c),start:it.createElement(db,{src:c.logo,size:30}),title:it.createElement(tg,{variant:"title",size:"medium"},c.displayName),id:c.name}))),"renderList");return it.createElement(it.Fragment,null,a&&it.createElement(it.Fragment,null,it.createElement(tg,{variant:"label",size:"large"},Il.t("Select Chain")),it.createElement(mb,{size:4})),it.createElement(Jf,null,p==="loading"&&it.createElement(eg,null),p==="success"&&u()))}i(Al,"BlockchainList");function Li(t){let{type:e}=t,o=Ye(),[n,r]=rg(""),[a,s]=rg("ALL"),l=z.use.setToBlockchain(),p=z.use.setFromBlockchain(),{fetchStatus:u}=y(),c=kb(),m=y().blockchains({type:e}),f=Sb(m),g=!t.hideCategory&&f!==1;return zt.createElement(ne,{header:{title:og.t("Select Chain")}},zt.createElement(re,{view:!0},g&&zt.createElement(zt.Fragment,null,zt.createElement(Cb,{setCategory:s,category:a,blockchains:m,isLoading:u==="loading"}),zt.createElement(ng,{size:24})),zt.createElement(Ct,{value:n,autoFocus:!0,placeholder:og.t("Search Chain"),color:"light",variant:"contained",size:"large",setValue:()=>r(""),onChange:d=>r(d.target.value)}),zt.createElement(ng,{size:16}),zt.createElement(Al,{list:m,showTitle:e!=="custom-token",searchedFor:n,blockchainCategory:a,onChange:d=>{e==="custom-token"?c(`..?blockchain=${d.name}`,{replace:!0}):(e==="source"?p(d):l(d),o())}})))}i(Li,"SelectBlockchainPage");import{i18n as Pi}from"@lingui/core";import{Divider as cg}from"@rango-dev/ui";import xo,{useState as Ab}from"react";import{useNavigate as Nb}from"react-router-dom";import{i18n as Ml}from"@lingui/core";import{BlockchainsChip as Bi,Divider as lg,Image as pg,Skeleton as xb,Tooltip as Eb,Typography as Ll}from"@rango-dev/ui";import Pe from"react";import{useEffect as wb}from"react";var ig=["ETH","COSMOS","OSMOSIS"];function Nl(t,e,o){let n=JSON.parse(JSON.stringify(t)),r=[];if(n.sort(Tb),o?.limit&&t.length>o.limit){let a=o.limit,s=e;if(e.length<=o.limit){let l=o.limit-e.length;for(let p=0;p<=l;p++){let u=n[p];s=s.filter(c=>u.name!==c)}}n.sort(vb(s)),r=n.splice(a)}return{list:n,more:r}}i(Nl,"prepare");function Tb(t,e){let o=ig,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(Tb,"sortByMostUsedBlockchains");function vb(t){return i(function(o,n){let r=t.findIndex(p=>p===o.name),a=t.findIndex(p=>p===n.name),s=r>-1,l=a>-1;return s&&l?r>a?1:-1:t.includes(o.name)?-1:t.includes(n.name)?1:0},"sortByPreferred")}i(vb,"generateSortByPreferredBlockchainsFor");function ag(t,e){return!!e.list.find(o=>o.name===t)}i(ag,"isInVisibleList");function Wl(t,e){let{preferredBlockchains:o,addPreferredBlockchain:n}=y();wb(()=>{if(e?.selected){let a=Nl(t,o,e);ag(e.selected,a)||n(e?.selected)}},[e?.selected]);let r=Nl(t,o,e);return{list:r.list,more:r.more,history:[]}}i(Wl,"usePrepareBlockchainList");import{styled as bb}from"@rango-dev/ui";var sg=bb("div",{display:"grid",gap:"$10",gridTemplateColumns:"repeat(6, minmax(0, 1fr))"});var Ib=12;function Bl(t){let{blockchains:e,type:o,blockchain:n,onChange:r,onMoreClick:a}=t,s=Wl(e,{limit:10,selected:n?.name}),{fetchStatus:l}=y(),p=z.use.resetToBlockchain(),u=z.use.resetFromBlockchain(),c=s.more.length>0,m=s.more.length===1,f=!m&&c;return Pe.createElement(Pe.Fragment,null,Pe.createElement(lg,{size:12}),Pe.createElement(Ll,{variant:"label",size:"large"},Ml.t("Select Chain")),Pe.createElement(lg,{size:12}),Pe.createElement(sg,null,l==="loading"&&Array.from(Array(Ib),g=>Pe.createElement(xb,{key:g,variant:"rounded",height:50})),l==="success"&&Pe.createElement(Pe.Fragment,null,Pe.createElement(Bi,{selected:!n,onClick:()=>{o==="from"?u():p()}},Pe.createElement(Ll,{variant:"body",size:"xsmall",color:"secondary500"},Ml.t("All"))),s.list.map(g=>Pe.createElement(Eb,{key:g.name,content:g.shortName,side:"bottom",sideOffset:2,container:N()},Pe.createElement(Bi,{key:g.name,selected:!!n&&n.name===g.name,onClick:()=>r(g)},Pe.createElement(pg,{src:g.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(pg,{src:s.more[0].logo,size:30})):null,f?Pe.createElement(Bi,{onClick:a,key:"more-blockchains"},Pe.createElement(Ll,{variant:"body",size:"xsmall",color:"secondary500"},Ml._("More +{count}",{count:s.more.length}))):null)))}i(Bl,"BlockchainsSection");function Pl(t){let{type:e}=t,o=Nb(),n=Ye(),{fromBlockchain:r,toBlockchain:a,setFromToken:s,setToToken:l,setFromBlockchain:p,setToBlockchain:u}=z(),c=Z.use.getBalanceFor(),[m,f]=Ab(""),d=(e==="source"?r:a)?.name??"",h=y().blockchains({type:e}),k=y().tokens({type:e,blockchain:d,searchFor:m,getBalanceFor:c}),S=i(v=>{e==="source"?p(v):u(v)},"updateBlockchain"),C=i(v=>{e==="source"?s({token:v,meta:{blockchains:h,tokens:k}}):l({token:v,meta:{blockchains:h,tokens:k}})},"updateToken"),T={source:Pi.t("Source"),destination:Pi.t("Destination")};return xo.createElement(ne,{header:{title:Pi.t("Swap {type}",{type:T[e]})}},xo.createElement(re,null,xo.createElement(Bl,{blockchains:h,type:e=="source"?"from":"to",blockchain:e==="source"?r:a,onMoreClick:()=>o(D.blockchains),onChange:v=>{S(v)}}),xo.createElement(cg,{size:24}),xo.createElement(Ct,{value:m,autoFocus:!0,placeholder:Pi.t("Search Token"),color:"light",variant:"contained",size:"large",setValue:()=>f(""),onChange:v=>f(v.target.value)}),xo.createElement(cg,{size:16}),xo.createElement(Dn,{list:k,selectedBlockchain:d,searchedFor:m,type:e,onChange:v=>{C(v);let w=h.find(A=>v.blockchain===A.name);w&&S(w),n()}})))}i(Pl,"SelectSwapItemsPage");import{i18n as $l}from"@lingui/core";import{Alert as tx,Button as ox,styled as nx}from"@rango-dev/ui";import Eo from"react";import{useInRouterContext as rx,useSearchParams as ix}from"react-router-dom";import{i18n as hg}from"@lingui/core";import{Divider as yg,InfoIcon as Bb,SlippageIcon as Pb,TextField as Db,Tooltip as _b,Typography as Sg}from"@rango-dev/ui";import at from"react";import{Chip as Wb,styled as Gn,TextField as Mb}from"@rango-dev/ui";var ug=Gn("div",{paddingTop:"$5",padding:"$10 $5"}),mg=Gn("div",{display:"flex",flexWrap:"wrap",gap:"$10",[`& ${Mb}`]:{flex:"1 1 0",maxWidth:"127px",minWidth:"85px"}}),dg=Gn("div",{display:"flex",justifyContent:"start",alignItems:"center",paddingBottom:"$10"}),Di=Gn("div",{maxWidth:"280px",padding:"$10"}),fg=Gn(Wb,{width:"61px",flexShrink:0});import{i18n as Dl}from"@lingui/core";import{Typography as Lb}from"@rango-dev/ui";import Vn from"react";function gg(){return Vn.createElement(Di,null,Vn.createElement(Lb,{variant:"label",size:"medium",color:"neutral700"},Dl.t("Your transaction will be reverted if the price changes unfavorably by more than this percentage."),Vn.createElement("br",null),Vn.createElement("br",null),Vn.createElement("b",null,Dl.t("Warning")),":\xA0",Dl.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(gg,"SlippageTooltipContent");function _l(){let{slippage:t,setSlippage:e,customSlippage:o,setCustomSlippage:n}=y();return at.createElement(ug,null,at.createElement(dg,null,at.createElement(Pb,{size:16,color:"gray"}),at.createElement(yg,{direction:"horizontal",size:4}),at.createElement(Sg,{variant:"title",size:"xmedium"},hg.t("Slippage tolerance per swap")),at.createElement(yg,{direction:"horizontal",size:4}),at.createElement(_b,{container:N(),side:"top",sideOffset:4,content:at.createElement(gg,null)},at.createElement(Bb,{color:"gray"}))),at.createElement(mg,null,Zp.map((r,a)=>{let s=`slippage-${a}`;return at.createElement(fg,{key:s,onClick:()=>{o&&n(null),e(r)},selected:!o&&r===t,label:`${r.toString()}%`})}),at.createElement(Db,{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>=tc&&s<=ec?n(s):n(null)},suffix:o&&at.createElement(Sg,{variant:"body",size:"small"},"%"),placeholder:hg.t("Custom")})))}i(_l,"Slippage");import{i18n as dt}from"@lingui/core";import{AutoThemeIcon as Cg,BridgesIcon as $b,ChevronRightIcon as _i,DarkModeIcon as kg,Divider as Kn,ExchangeIcon as Fb,InfinityIcon as Ob,InfoIcon as Ub,LanguageIcon as zb,LightModeIcon as Tg,List as Qb,ListItem as qb,ListItemButton as Hb,Skeleton as Gb,styled as Vb,Switch as Kb,Tabs as jb,TargetIcon as Xb,Tooltip as Yb,Typography as Re}from"@rango-dev/ui";import P from"react";import{useNavigate as Zb}from"react-router-dom";var Jb=Vb("div",{width:"202px",height:"$40"}),Rb=[{id:"light",icon:P.createElement(Tg,{color:"black",size:24}),tooltip:P.createElement(Re,{size:"xsmall",variant:"body"},dt.t("Light"))},{id:"dark",icon:P.createElement(kg,{color:"black",size:24}),tooltip:P.createElement(Re,{size:"xsmall",variant:"body"},dt.t("Dark"))},{id:"auto",icon:P.createElement(Cg,{color:"black",size:24}),tooltip:P.createElement(Re,{size:"xsmall",variant:"body"},dt.t("Auto"))}],ex=i(t=>{let e={color:"gray",size:16};switch(t){case"auto":return P.createElement(Cg,{...e});case"dark":return P.createElement(kg,{...e});default:return P.createElement(Tg,{...e})}},"getThemeIcon");function vg(){let t=Zb(),{theme:e}=y().config,{setTheme:o,theme:n}=y(),{activeLanguage:r,languages:a}=eo(),s=a.find(B=>B.local===r)?.label,l=y().fetchStatus,p=y().swappers(),u=y().getDisabledLiquiditySources(),{config:{features:c}}=y(),m=y().customTokens(),f=je("theme",c),g=je("liquiditySource",c),d=je("language",c),h=je("customTokens",c),k=y().infiniteApprove,S=y().toggleInfiniteApprove,C=hr(p,u),T=C.filter(B=>["BRIDGE","AGGREGATOR","OFF_CHAIN"].includes(B.type)),v=T.length,w=T.filter(B=>B.selected).length,A=C.filter(B=>B.type==="DEX"),M=A.length,b=A.filter(B=>B.selected).length,E=i((B,V)=>{switch(l){case"loading":return P.createElement(Gb,{variant:"text",size:"medium",width:50});case"failed":return P.createElement(Re,{variant:"body",size:"medium",color:"$error500"},dt.t("Loading failed"));default:return P.createElement(Re,{variant:"body",size:"medium"},`${B} / ${V}`)}},"handleSwapperEndItem"),x={id:"widget-setting-bridge-item-btn",title:P.createElement(Re,{variant:"title",size:"xmedium"},dt.t("Bridges")),end:P.createElement(P.Fragment,null,E(w,v),P.createElement(Kn,{direction:"horizontal",size:8}),P.createElement(_i,{color:"black"})),onClick:()=>t(D.bridges),start:P.createElement($b,{color:"gray",size:16})},W={id:"widget-setting-exchange-item-btn",title:P.createElement(Re,{variant:"title",size:"xmedium"},dt.t("Exchanges")),end:P.createElement(P.Fragment,null,E(b,M),P.createElement(Kn,{direction:"horizontal",size:8}),P.createElement(_i,{color:"black"})),start:P.createElement(Fb,{color:"gray",size:16}),onClick:()=>t(D.exchanges)},$={id:"widget-setting-custom-tokens-item-btn",title:P.createElement(Re,{variant:"title",size:"xmedium"},dt.t("Custom Tokens")),end:P.createElement(P.Fragment,null,P.createElement(Re,{variant:"body",size:"medium"},`${m.length}`),P.createElement(Kn,{direction:"horizontal",size:8}),P.createElement(_i,{color:"black"})),start:P.createElement(Xb,{color:"gray",size:16}),onClick:()=>t(D.customTokens)},I={id:"widget-setting-language-item-btn",title:P.createElement(Re,{variant:"title",size:"xmedium"},dt.t("Language")),start:P.createElement(zb,{color:"gray",size:16}),end:P.createElement(P.Fragment,null,P.createElement(Re,{variant:"body",size:"medium"},s),P.createElement(Kn,{direction:"horizontal",size:8}),P.createElement(_i,{color:"black"})),onClick:()=>t(D.languages)},R={id:"widget-setting-infinite-approval-item-btn",title:P.createElement(P.Fragment,null,P.createElement(Re,{variant:"title",size:"xmedium"},dt.t("Infinite approval")),P.createElement(Kn,{direction:"horizontal",size:4}),P.createElement(Yb,{side:"top",sideOffset:4,container:N(),content:P.createElement(Di,null,P.createElement(Re,{variant:"label",size:"medium",color:"neutral700"},P.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.")))},P.createElement(Ub,{color:"gray"}))),start:P.createElement(Ob,{color:"gray",size:16}),end:P.createElement(Kb,{checked:k}),onClick:S},ee={id:"widget-setting-theme-item-btn",type:P.createElement(qb,null),title:P.createElement(Re,{variant:"title",size:"xmedium"},dt.t("Theme")),end:P.createElement(Jb,null,P.createElement(jb,{container:N(),items:Rb,value:n,onChange:B=>o(B.id),type:"primary",borderRadius:"small"})),start:ex(n)},oe=g?[]:[x,W];return h||oe.push($),d||oe.push(I),oe.push(R),!e?.singleTheme&&!f&&oe.push(ee),P.createElement(Qb,{type:P.createElement(Hb,{hasDivider:!0,id:"_",onClick:()=>console.log()}),items:oe})}i(vg,"SettingsLists");var ax=nx("div",{paddingLeft:"$8"});function wg(){let{isInCampaignMode:t,updateCampaignMode:e}=y(),o=t(),[,n]=ix(),r=rx(),a=i(()=>{r&&o&&(n(s=>(s.delete("liquiditySources"),s),{replace:!0}),e("liquiditySources",void 0))},"onClick");return Eo.createElement(ne,{header:{title:$l.t("Settings")}},Eo.createElement(re,null,o&&Eo.createElement(tx,{type:"info",variant:"alarm",title:$l.t("Currently, you're in campaign mode with restrictions on liquidity sources. Would you like to switch out of this mode and make use of all available liquidity sources?"),action:Eo.createElement(ax,null,Eo.createElement(ox,{id:"widget-setting-exit-campaign-mode-btn",type:"secondary",size:"small",onClick:a},$l.t("Reset")))}),Eo.createElement(_l,null),Eo.createElement(vg,null)))}i(wg,"SettingsPage");import{i18n as Kx}from"@lingui/core";import{cancelSwap as jx}from"@rango-dev/queue-manager-rango-preset";import{useManager as Xx}from"@rango-dev/queue-manager-react";import{Alert as Yx}from"@rango-dev/ui";import ep from"react";import{useParams as Zx}from"react-router-dom";import{i18n as st}from"@lingui/core";import{getCurrentBlockchainOfOrNull as Ax,getCurrentStep as Nx,getRelatedWalletOrNull as Wx}from"@rango-dev/queue-manager-rango-preset";import{Button as eh,CopyIcon as Mx,Divider as Lx,DoneIcon as Bx,IconButton as Px,QuoteCost as Dx,RangoExplorerIcon as _x,StepDetails as $x,Tooltip as th,Typography as Io,useCopyToClipboard as Fx}from"@rango-dev/ui";import{useWallets as Ox}from"@rango-dev/wallets-react";import oh from"bignumber.js";import{PendingSwapNetworkStatus as Gi}from"rango-types";import K,{useEffect as nh,useRef as Ux,useState as rh}from"react";import{useNavigate as zx}from"react-router-dom";import{i18n as to}from"@lingui/core";var sx=[to.t("Sunday"),to.t("Monday"),to.t("Tuesday"),to.t("Wednesday"),to.t("Thursday"),to.t("Friday"),to.t("Saturday")];function bg(t){let e=new Date(t),o=e.getDate(),n=e.toLocaleString("default",{month:"long"}),r=e.getFullYear();return`${e.getDay()===new Date().getDay()?to.t("Today"):`${sx[e.getDay()]} ${o} ${n} ${r}`}, ${new Date(t).toLocaleTimeString()}`}i(bg,"timeSince");function xg(t){return t.finishTime?bg(parseInt(t.finishTime)):bg(parseInt(t.creationTime))}i(xg,"getSwapDate");import{PendingSwapNetworkStatus as Oi}from"rango-types";import Ui from"react";import{i18n as $i}from"@lingui/core";import{Button as Eg,Divider as Fl,MessageBox as lx}from"@rango-dev/ui";import oo from"react";var Ig=i(({onCancel:t,onClose:e})=>oo.createElement(oo.Fragment,null,oo.createElement(Fl,{size:20}),oo.createElement(lx,{type:"error",title:$i.t("Cancel Swap"),description:$i.t("Are you sure you want to cancel this swap?")}),oo.createElement(Fl,{size:32}),oo.createElement(Eg,{variant:"contained",id:"widget-swap-details-modal-cancel-swap-yes-btn",type:"primary",size:"large",onClick:t},$i.t("Yes, Cancel it")),oo.createElement(Fl,{size:12}),oo.createElement(Eg,{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 Fi}from"@lingui/core";import{Button as Ag,Divider as Ol,MessageBox as px,Typography as cx}from"@rango-dev/ui";import Qt from"react";var Ng=i(({onDelete:t,onClose:e})=>Qt.createElement(Qt.Fragment,null,Qt.createElement(Ol,{size:20}),Qt.createElement(px,{type:"error",title:Fi.t("Delete Transaction"),description:Fi.t("Are you sure you want to delete this swap?")}),Qt.createElement(Ol,{size:32}),Qt.createElement(Ag,{id:"widget-swap-details-modal-delete-swap-yes-btn",variant:"contained",type:"primary",size:"large",onClick:t},Fi.t("Yes, Delete it")),Qt.createElement(Ol,{size:12}),Qt.createElement(Ag,{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"},Fi.t("No, Cancel")))),"DeleteContent");import{i18n as Ul}from"@lingui/core";import{PendingSwapNetworkStatus as zl}from"rango-types";var Ql={[zl.WaitingForNetworkChange]:{type:"loading",title:Ul.t("Change Network")},[zl.WaitingForConnectingWallet]:{type:"warning",title:Ul.t("Connect Wallet")},[zl.NetworkChanged]:{type:"success",title:Ul.t("Network Changed")}};import{warn as ux}from"@rango-dev/logging-core";import{MessageBox as mx,Wallet as dx}from"@rango-dev/ui";import{useWallets as fx}from"@rango-dev/wallets-react";import Ro,{useState as gx}from"react";import{styled as Wg}from"@rango-dev/ui";var Mg=Wg("div",{display:"flex",justifyContent:"center"}),o5=Wg("div",{maxWidth:280,"& ._typography":{wordWrap:"break-word",display:"block"}});var Lg=i(t=>{let{type:e,title:o,currentStepWallet:n,message:r,showWalletButton:a,walletButtonDisabled:s}=t,[l,p]=gx(),{getWalletInfo:u,state:c}=fx(),m=n?.walletType,f=m?pn(c(m)):null,g=m?u(m):null,d=a&&!!m&&!!f&&!!g,{list:h}=ft(),k=i(()=>{if(m){let S=h.find(C=>C.type===m);S?p(S):ux(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(mx,{type:e,title:o,description:r}),d&&Ro.createElement(Mg,null,Ro.createElement(dx,{container:N(),title:g.name,image:g.img,type:m,state:f,link:g.installLink,disabled:s,onClick:k})),Ro.createElement(mo,{wallet:l,onClose:()=>{p(void 0)}}))},"WalletStateContent");function ql(t){let{state:e,onClose:o,onDelete:n,onCancel:r,currentStepWallet:a,message:s,walletButtonDisabled:l}=t,p=e===Oi.WaitingForNetworkChange||e===Oi.WaitingForConnectingWallet||e===Oi.NetworkChanged;return Ui.createElement(J,{open:!!e,onClose:o,container:document.getElementById($e.SWAP_BOX_ID)||document.body},p&&Ui.createElement(Lg,{type:Ql[e].type,title:Ql[e].title,currentStepWallet:a,message:s,walletButtonDisabled:l,showWalletButton:e!==Oi.WaitingForNetworkChange}),e==="delete"&&Ui.createElement(Ng,{onClose:o,onDelete:n}),e==="cancel"&&Ui.createElement(Ig,{onClose:o,onCancel:r}))}i(ql,"SwapDetailsModal");import{i18n as jn}from"@lingui/core";import{Button as Hl,Divider as zi,MessageBox as Bg,TokenAmount as hx,Typography as Gl}from"@rango-dev/ui";import Oe from"react";import{useNavigate as yx}from"react-router-dom";function Vl(t){let{open:e,onClose:o,status:n,priceValue:r,usdValue:a,realUsdValue:s,realValue:l,token:p,chain:u,percentageChange:c,description:m,diagnosisUrl:f}=t,g=yx();return Oe.createElement(J,{open:e,onClose:o,container:document.getElementById($e.SWAP_BOX_ID)||document.body},n==="success"?Oe.createElement(Bg,{type:"success",title:jn.t("Swap Successful")},Oe.createElement(hx,{direction:"vertical",tooltipContainer:N(),type:"output",centerAlign:!0,price:{value:r,usdValue:a,realUsdValue:s,realValue:l},token:p,chain:u,percentageChange:c}),Oe.createElement(zi,{size:12}),Oe.createElement(Gl,{variant:"body",size:"medium",color:"neutral700",align:"center"},m)):Oe.createElement(Bg,{type:"error",title:jn.t("Transaction Failed"),description:m}),Oe.createElement(zi,{size:32}),n==="success"&&Oe.createElement(Hl,{id:"widget-swap-details-modal-done-btn",variant:"contained",type:"primary",size:"large",onClick:()=>{g("../../")}},Oe.createElement(Gl,{variant:"title",size:"medium",color:"neutral100"},jn.t("Done"))),Oe.createElement(zi,{size:12}),f&&Oe.createElement(Oe.Fragment,null,Oe.createElement(Hl,{variant:"contained",id:"widget-swap-detail-modal-diagnosis-btn",type:"primary",size:"large",onClick:()=>window.open(f,"_blank")},jn.t("Diagnosis")),Oe.createElement(zi,{size:12})),Oe.createElement(Hl,{id:"widget-swap-details-modal-see-details-btn",variant:"outlined",type:"primary",size:"large",onClick:o},Oe.createElement(Gl,{variant:"title",size:"medium",color:"primary"},jn.t("See Details"))))}i(Vl,"SwapDetailsCompleteModal");import Ix from"react";import{i18n as wx}from"@lingui/core";import{Alert as Yg,IconButton as bx,LinkIcon as xx}from"@rango-dev/ui";import no,{Fragment as Ex}from"react";import{Alert as Cx,ChevronDownIcon as kx,IconButton as Tx}from"@rango-dev/ui";import tn,{useState as vx}from"react";import{css as Xn,darkTheme as Pg,styled as qt,Typography as Sx}from"@rango-dev/ui";var Dg=qt("div",{display:"flex",flexDirection:"column",flexGrow:1,overflow:"hidden"}),Qi=qt("div",{width:"100%","& ._icon-button":{"&:hover":{"& svg":{color:"$secondary550",[`.${Pg} &`]:{color:"$secondary500"}}}}}),_g=qt(Sn,{padding:"$0 $20 $20 $20"}),O5=qt("div",{display:"flex",flexDirection:"column",gap:"$10"}),$g=qt("div",{height:"450px",display:"flex",alignItems:"center",justifyContent:"center"}),U5=qt("div",{display:"flex",justifyContent:"center",width:"100%",paddingTop:"33%",flex:1}),en=Xn({display:"flex",width:"100%",justifyContent:"space-between",alignItems:"center",padding:"$10 $20",borderBottom:"1px solid",$$color:"$colors$neutral300",[`.${Pg} &`]:{$$color:"$colors$neutral400"},borderColor:"$$color",color:"$neutral500"}),Fg=Xn({padding:"$5 0"}),qi=Xn({display:"flex",justifyContent:"center",alignItems:"center",height:"$24"}),Og=Xn({display:"flex",width:"100%",padding:"$15 $20 $20",flexDirection:"column",alignItems:"start"}),Ug=Xn({width:"100%",padding:"0 $20 $10"}),zg=qt("a",{fontSize:"$16",fontWeight:"$400",color:"$neutral700",display:"flex",alignItems:"center",justifyContent:"center"}),Qg=qt("div",{display:"flex",flexDirection:"column",gap:"$5"}),Hi=qt(Sx,{wordBreak:"break-word"});import{styled as Kl}from"@rango-dev/ui";var qg=Kl("div",{display:"flex",flexDirection:"column",gap:"$10"}),Hg=Kl("div",{transition:"transform 0.3s ease-in-out",variants:{rotated:{true:{transform:"rotate(180deg)"}}}}),Gg=Kl("div",{transition:"max-height 0.3s ease-in-out",maxHeight:"0px",overflow:"hidden",variants:{open:{true:{maxHeight:"200px"}}}});function Vg(t){let{message:e}=t,[o,n]=vx(!1);return tn.createElement(Cx,{type:"error",title:e.shortMessage,containerStyles:{"& .footer":{paddingTop:"$0"}},action:e.detailedMessage.content&&tn.createElement(Tx,{onClick:()=>n(r=>!r),variant:"ghost",size:"xsmall"},tn.createElement(Hg,{rotated:o},tn.createElement(kx,{size:12,color:"gray"}))),footer:tn.createElement(Gg,{open:o},tn.createElement(Hi,{variant:"body",size:"xsmall",color:"neutral700"},e.detailedMessage.content))})}i(Vg,"FailedAlert");import{i18n as Kg}from"@lingui/core";import{Alert as jl,Button as jg}from"@rango-dev/ui";import{PendingSwapNetworkStatus as Xl}from"rango-types";import Yn from"react";function Xg(t){let{switchNetwork:e,setNetworkModal:o,message:n,showNetworkModal:r}=t;return e?Yn.createElement(jl,{type:"warning",title:n.shortMessage,action:Yn.createElement(jg,{id:"widget-swap-details-warning-alert-change-network-btn",size:"xxsmall",type:"warning",onClick:()=>{o(Xl.WaitingForNetworkChange),e().catch(a=>{console.log(a)})}},Kg.t("Change"))}):r===Xl.WaitingForConnectingWallet?Yn.createElement(jl,{type:"warning",title:n.shortMessage,action:Yn.createElement(jg,{id:"widget-swap-details-warning-alert-connect-wallet-btn",size:"xxsmall",type:"warning",onClick:()=>{o(Xl.WaitingForConnectingWallet)}},Kg.t("Connect"))}):Yn.createElement(jl,{type:"warning",title:n.shortMessage})}i(Xg,"WarningAlert");function Yl(t){let{switchNetwork:e,showNetworkModal:o,setNetworkModal:n,message:r,step:a,hasAlreadyProceededToSign:s}=t,l=gn(a),p=a.status==="waitingForApproval"&&!l,u=a.status==="running"&&!l,c=u&&!s||p&&!a.explorerUrl?.length;return no.createElement(qg,null,a.explorerUrl?.map((m,f,g)=>{let d=f+m.url,h=f===g.length-1,k=(h&&u||p)&&!c,S=h&&a.status==="failed";return no.createElement(Ex,{key:d},no.createElement(Yg,{type:h&&(k&&"loading"||S&&"error")||"success",title:m.description?`${m.description} Tx`:wx.t("View transaction"),action:m.url&&no.createElement(bx,{id:"widget-swap-details-tx-link-icon-btn",variant:"ghost",size:"xsmall",onClick:()=>window.open(m.url,"_blank")},no.createElement(xx,{size:12}))}))}),c&&no.createElement(Yg,{type:"loading",title:r.shortMessage}),a.status!=="failed"&&l&&no.createElement(Xg,{switchNetwork:e,showNetworkModal:o,setNetworkModal:n,message:r}),a.status==="failed"&&no.createElement(Vg,{message:r}))}i(Yl,"SwapDetailsAlerts");var Zg=2e3;var Jg=i(({swap:t,blockchains:e,swappers:o,...n})=>{let r=t.hasAlreadyProceededToSign!==!1;return t.steps.map((a,s)=>{let l=s===0?t.inputAmount:t.steps[s-1].outputAmount||t.steps[s-1].expectedOutputAmountHumanReadable;return{from:{token:{displayName:a.fromSymbol,image:a.fromLogo??""},chain:{displayName:pt(a.fromBlockchain,e)??"",image:a.fromBlockchainLogo??""},price:{value:L(l,6,6),realValue:l??""}},to:{token:{displayName:a.toSymbol,image:a.toLogo},chain:{displayName:pt(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(p=>({from:{chain:{displayName:pt(p.fromBlockchain,e)??"",image:p.fromBlockchainLogo??""}},to:{chain:{displayName:pt(p.toBlockchain,e)??"",image:p.toBlockchainLogo??""}},swapper:{displayName:on(p.swapperId,o)??"",image:p.swapperLogo??"",type:p.swapperType}})):[],alerts:Ix.createElement(Yl,{step:a,hasAlreadyProceededToSign:r,...n})}})},"getSteps");function Rg(t){if(gn(t)&&t.status!=="failed"&&t.status!=="success")return"warning";switch(t.status){case"created":return"default";case"approved":case"waitingForApproval":case"running":return"in-progress";case"failed":return"error";case"success":return"completed"}}i(Rg,"getStepState");function Zl(t){let{swap:e,requestId:o,onDelete:n,onCancel:r}=t,{canSwitchNetworkTo:a,connect:s,getWalletInfo:l}=Ox(),p=y().blockchains(),u=y().swappers(),{findToken:c}=y(),m=z.use.retry(),f=se.use.isActiveTab(),g=zx(),[d,h]=Fx(Zg),k=Ux(null),[S,C]=rh(null),[T,v]=rh(null),w=i(()=>{r(),C(null)},"onCancel"),A=be.use.getNotifications(),M=be.use.removeNotification(),b=A(),E=Nx(e),x=E?.networkStatus;nh(()=>{b.find(he=>he.requestId===e.requestId)&&(e.status==="success"||e.status==="failed"?(v(e.status),M(e.requestId)):T&&v(null))},[e.status,e.requestId]),nh(()=>{B?C(Gi.WaitingForNetworkChange):x===Gi.WaitingForConnectingWallet||x===Gi.NetworkChanged?C(x):C(null)},[x]);let W=Xc(e),$=E?Ax(e,E):null,I=E?Wx(e,E):null,R=xg(e),ee=Yc(e),oe=i(de=>!!l(de)?.mobileWallet,"isMobileWallet"),B=x===Gi.WaitingForNetworkChange&&!!$&&!!I?.walletType&&(oe(I.walletType)||a(I.walletType,$)),V=B?s.bind(null,I.walletType,$):void 0,le=jc(e,E),Y=Jg({swap:e,switchNetwork:V,showNetworkModal:x,setNetworkModal:C,message:le,blockchains:p,swappers:u}),ae=Y.length,[ge,ve]=[e.steps[0],e.steps[ae-1]],U=ve.outputAmount||ve.expectedOutputAmountHumanReadable,Ke=e.steps.reduce((de,he)=>de+parseFloat(he.feeInUsd||""),0),vt=e.steps.find(de=>de.diagnosisUrl)?.diagnosisUrl,lt=L(parseFloat(U||"0")*(ve.toUsdPrice||0),4,4),wt=L(parseFloat(e.inputAmount)*(ge.fromUsdPrice||0),4,4),_=U?new oh(U).multipliedBy(ve.toUsdPrice||0).toString():"",Q=new oh(e.inputAmount).multipliedBy(ge.fromUsdPrice||0).toString(),G=ct(wt,lt),pe=le.detailedMessage.content||le.shortMessage,ce=e.status==="success"?st.t({id:"You have received {amount} {token} in {conciseAddress} wallet on {chain} chain.",values:{amount:L(U,6,6),token:Y[ae-1].to.token.displayName,conciseAddress:dr(e.wallets[Y[ae-1].to.chain.displayName]?.address||""),chain:Y[ae-1].to.chain.displayName}}):K.createElement(Qg,null,K.createElement(Io,{variant:"body",size:"medium",color:"neutral700",align:"center"},pe?"":st.t("Transaction was not sent."),W?`${st.t({id:"{amount} {symbol} on {blockchain} remains in your wallet.",values:{amount:W.outputAmount,symbol:W.symbol,blockchain:W.blockchain}})}`:""),pe&&K.createElement(Hi,{align:"center",variant:"body",size:"medium",color:"neutral700"},K.createElement("b",null,"Reason:")," ",pe));return K.createElement(ne,{header:{title:st.t("Swap Details"),onCancel:e.status==="running"?()=>C("cancel"):void 0,suffix:e.status!=="running"&&K.createElement(Vt,null,K.createElement(eh,{id:"widget-swap-details-delete-btn",variant:"ghost",type:"error",size:"xsmall",onClick:()=>C("delete")},K.createElement(Io,{size:"medium",variant:"label",color:"error"},st.t("Delete"))))},footer:ee&&!T&&K.createElement(eh,{fullWidth:!0,id:"widget-swap-details-try-again-btn",variant:"contained",type:"primary",size:"large",onClick:()=>{let de=Br(e,p,c);m(de),setTimeout(()=>{g("../../")},0)}},st.t("Try again"))},K.createElement(re,{compact:!0,view:!0},K.createElement(Qi,null,K.createElement("div",{className:en()},K.createElement(Io,{variant:"label",size:"large",color:"neutral700"},`${st.t("Request ID")}`),K.createElement("div",{className:qi()},K.createElement(Io,{variant:"label",size:"small",color:"neutral700"},o),K.createElement(th,{container:N(),content:d?st.t("Copied To Clipboard"):st.t("Copy Request ID"),open:d||void 0,side:"bottom",alignOffset:-16,align:"end"},K.createElement(Px,{id:"widget-swap-details-done-copy-icon-btn",variant:"ghost",onClick:h.bind(null,o||"")},d?K.createElement(Bx,{size:16,color:"secondary"}):K.createElement(Mx,{size:16,color:"gray"}))),K.createElement(zg,{target:"_blank",href:`${gp}/swap/${o}`},K.createElement(th,{container:N(),content:st.t("View on Rango Explorer"),side:"bottom"},K.createElement(_x,{size:20}))))),K.createElement("div",{className:en()},K.createElement(Io,{variant:"label",size:"large",color:"neutral700"},e.finishTime?st.t("Finished at"):st.t("Created at")),K.createElement(Io,{variant:"label",size:"small",color:"neutral700"},R))),K.createElement("div",{className:Og()},K.createElement(Dx,{fee:L(String(Ke),2,2),time:sn(ar(e.steps)),steps:ae}),K.createElement(En,{from:{price:{value:L(e.inputAmount,6,6),usdValue:wt,realUsdValue:Q,realValue:e.inputAmount},token:{displayName:Y[0].from.token.displayName,image:Y[0].from.token.image},chain:{image:Y[0].from.chain.image,displayName:Y[0].from.chain.displayName}},to:{price:{value:L(U,6,6),usdValue:lt,realUsdValue:_,realValue:U||""},token:{displayName:Y[ae-1].to.token.displayName,image:Y[ae-1].to.token.image},chain:{image:Y[ae-1].to.chain.image,displayName:Y[ae-1].to.chain.displayName}},percentageChange:L(G,2,2),warningLevel:Pt(G??0)})),K.createElement("div",{className:Ug()},K.createElement(Io,{variant:"title",size:"small"},st.t("Swaps steps"))),K.createElement(Lx,{size:8}),K.createElement(_g,{ref:k},Y.map((de,he)=>{let Rn=he,ro=Rg(e.steps[he]),ea=ro==="error"||ro==="in-progress"||ro==="warning"||ro==="completed"&&he===Y.length-1;return K.createElement($x,{key:Rn,step:de,type:"swap-progress",ref:k,state:ro,hasSeparator:he!==0,tabIndex:Rn,isFocused:ea,tooltipContainer:N()})}))),K.createElement(ql,{state:S,onClose:()=>C(null),onCancel:w,onDelete:n,message:le.detailedMessage.content,currentStepWallet:I,walletButtonDisabled:!f}),K.createElement(Vl,{open:!!T,diagnosisUrl:vt,onClose:()=>v(null),status:e.status==="success"?"success":"failed",priceValue:L(U,6,6),usdValue:lt,realUsdValue:_,realValue:U||"",percentageChange:L(G,2,2),token:{displayName:Y[ae-1].to.token.displayName,image:Y[ae-1].to.token.image},chain:{image:Y[ae-1].to.chain.image},description:ce}))}i(Zl,"SwapDetails");import{i18n as Ki}from"@lingui/core";import{Divider as sh,NotFound as Vx,Skeleton as Jn,Typography as ji}from"@rango-dev/ui";import ke from"react";import{i18n as Qx}from"@lingui/core";import{Divider as qx,Skeleton as Hx,Typography as Gx}from"@rango-dev/ui";import Te from"react";import{css as Tt,styled as Jl}from"@rango-dev/ui";var ih=Jl("div",{width:"100%",height:"100%",padding:"$10 $20"}),Zn=Jl("div",{backgroundColor:"$neutral100",borderRadius:"$xm",padding:"$10 $15"}),Vi=Jl("div",{width:"0px",height:"$20",borderLeft:"1px dashed $neutral700",marginLeft:"25px"}),J4=Tt({display:"flex",justifyContent:"space-between",alignItems:"center"}),R4=Tt({display:"flex",justifyContent:"space-between",alignItems:"center"}),e8=Tt({paddingTop:"$15",display:"flex"}),t8=Tt({padding:"$15 $0"}),o8=Tt({width:"0px",height:"$16",borderLeft:"1px solid $neutral400",marginLeft:"13px"}),n8=Tt({paddingBottom:"$10"}),r8=Tt({display:"flex",justifyContent:"start",alignItems:"center"}),i8=Tt({paddingTop:"$5",display:"flex",alignItems:"center"}),a8=Tt({display:"flex",alignItems:"center"}),s8=Tt({padding:"$4 $6",display:"flex",justifyContent:"center",alignItems:"center"}),ah=Tt({display:"flex",paddingTop:"$10",paddingBottom:"$5"});function Rl(){return Te.createElement(ih,null,Te.createElement(Nn,{type:"swap-preview"}),Te.createElement("div",{className:"swaps-steps"},Te.createElement(Gx,{variant:"title",size:"small"},Qx.t("Swaps steps"))),Te.createElement(Te.Fragment,null,Te.createElement(Zn,null,Te.createElement(Wt,{separator:!1}),Te.createElement("div",{className:ah()},Te.createElement(qx,{direction:"horizontal",size:20}),Te.createElement(Hx,{height:22,variant:"rectangular"}))),Te.createElement(Vi,null),Te.createElement(Zn,null,Te.createElement(Wt,{separator:!1})),Te.createElement(Vi,null),Te.createElement(Zn,null,Te.createElement(Wt,{separator:!1})),Te.createElement(Vi,null),Te.createElement(Zn,null,Te.createElement(Wt,{separator:!1}))))}i(Rl,"LoadingSwapDetails");function lh(t){let{requestId:e,showSkeleton:o}=t;return ke.createElement(ne,{header:{title:Ki.t("Swap Details"),suffix:ke.createElement(Vt,null)}},o&&ke.createElement(Dg,null,ke.createElement(Qi,null,ke.createElement("div",{className:en()},ke.createElement(ji,{variant:"label",size:"large",color:"neutral700"},`${Ki.t("Request ID")}`),ke.createElement("div",{className:qi()},ke.createElement(ji,{variant:"label",size:"small",color:"neutral700"},ke.createElement(Jn,{width:60,height:10,variant:"rounded"})),ke.createElement(sh,{direction:"horizontal",size:4}),ke.createElement(Jn,{width:16,height:16,variant:"rectangular"}),ke.createElement(sh,{direction:"horizontal",size:4}),ke.createElement(Jn,{width:16,height:16,variant:"rectangular"}))),ke.createElement("div",{className:en()},ke.createElement(ji,{className:Fg(),variant:"label",size:"large",color:"neutral700"},ke.createElement(Jn,{width:60,height:10,variant:"rounded"})),ke.createElement(ji,{variant:"label",size:"small",color:"neutral700"},ke.createElement(Jn,{width:60,height:10,variant:"rounded"})))),ke.createElement(Rl,null)),!o&&ke.createElement($g,null,ke.createElement(Vx,{title:Ki.t("Not found"),description:Ki.t({id:"Swap with request ID = {requestId} not found.",values:{requestId:e}})})))}i(lh,"SwapDetailsPlaceholder");function ph(){let{manager:t,state:e}=Xx(),o=!e.loadedFromPersistor,n=ut(t),{requestId:r}=Zx(),a=Ye(),{fetchStatus:s}=y();if(!r)return ep.createElement(Yx,{containerStyles:{margin:"20px"},type:"error",title:Kx.t("The request ID is necessary to display the swap details.")});let l=o||s==="loading",p=r?n.find(({swap:f})=>f.requestId===r):void 0,u=i(()=>{if(p?.id){let f=t?.get(p.id);f&&jx(f)}},"onCancel"),c=i(async()=>{if(p?.id)try{t?.deleteQueue(p.id),a()}catch(f){console.log(f)}},"onDelete"),m=p?.swap;return!m||l?ep.createElement(lh,{requestId:r,showSkeleton:l}):ep.createElement(Zl,{swap:m,requestId:r,onCancel:u,onDelete:c})}i(ph,"SwapDetailsPage");import{i18n as ch}from"@lingui/core";import{Divider as Jx,getCategoriesCount as Rx,SelectableCategoryList as eE,styled as mh,Typography as tE,Wallet as oE}from"@rango-dev/ui";import Lt,{useState as uh}from"react";var nE=mh("div",{display:"flex",justifyContent:"center",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5"}),rE=mh(re,{textAlign:"center"});function dh(){let{fetchStatus:t}=y(),[e,o]=uh("ALL"),n=y().blockchains(),{config:r}=y(),[a,s]=uh(),l=se.use.isActiveTab(),{list:p}=ft(),u=Op(p,n),m=Rx(u)!==1,f=Up(p,e),g=i(d=>{Ep(p,r.multiWallets)||s(d)},"handleWalletItemClick");return Lt.createElement(ne,{header:{title:ch.t("Connect Wallets")}},Lt.createElement(rE,null,m&&Lt.createElement(Lt.Fragment,null,Lt.createElement(eE,{setCategory:o,category:e,blockchains:u,isLoading:t==="loading"}),Lt.createElement(Jx,{size:24})),Lt.createElement(tE,{variant:"title",size:"xmedium",align:"center"},ch.t("Choose a wallet to connect.")),Lt.createElement(nE,null,f.map((d,h)=>{let k=`wallet-${h}-${d.type}`;return Lt.createElement(oE,{key:k,...d,container:N(),onClick:()=>g(d),isLoading:t==="loading",disabled:!l})}),Lt.createElement(mo,{wallet:a,onClose:()=>{s(void 0)}}))))}i(dh,"WalletsPage");function fh(){return au(),za(),iE([{path:D.home,element:De.createElement(Hf,null)},{path:D.routes,element:De.createElement(Xf,null)},{path:D.fromSwap,children:[{index:!0,element:De.createElement(Pl,{type:"source"})},{path:D.blockchains,element:De.createElement(Li,{type:"source"})}]},{path:D.toSwap,children:[{index:!0,element:De.createElement(Pl,{type:"destination"})},{path:D.blockchains,element:De.createElement(Li,{type:"destination"})}]},{path:D.settings,children:[{index:!0,element:De.createElement(wg,null)},{path:D.languages,element:De.createElement(Vf,null)},{path:D.exchanges,element:De.createElement(El,{sourceType:"Exchanges"})},{path:D.bridges,element:De.createElement(El,{sourceType:"Bridges"})},{path:D.customTokens,children:[{index:!0,element:De.createElement(tf,null)},{path:D.addCustomTokens,children:[{index:!0,element:De.createElement(zu,null)},{path:D.blockchains,element:De.createElement(Li,{hideCategory:!0,type:"custom-token"})}]}]}]},{path:D.swaps,children:[{index:!0,element:De.createElement(vf,null)},{path:D.swapDetails,element:De.createElement(ph,null)}]},{path:D.wallets,element:De.createElement(dh,null)},{path:D.confirmSwap,element:De.createElement(Od,null)}])}i(fh,"AppRoutes");import{useQueueManager as fE}from"@rango-dev/queue-manager-rango-preset";import{splitWalletNetwork as gE}from"@rango-dev/wallets-shared";import{isEvmBlockchain as hE}from"rango-sdk";import{useContext as yE,useEffect as Th,useState as vh}from"react";import{globalCss as aE}from"@rango-dev/ui";var gh=i(()=>aE({"@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 hh(){let{setWatermark:t}=se();return{fetchApiConfig:i(async()=>{let o=await fetch(`${Bt("BASE_URL")}/meta/dapp/config?apiKey=${Bt("API_KEY")}`);if(!o.ok)throw new Error(`Request failed with status: ${o.status} `);let n=await o.json();t(n.config.watermark)},"fetchApiConfig")}}i(hh,"useFetchApiConfig");import{useWallets as sE}from"@rango-dev/wallets-react";import{useEffect as lE,useRef as pE}from"react";function yh(){let{connect:t,state:e}=sE(),o=pE({}),{fetchStatus:n}=y(),r=new URLSearchParams(location.search).get("autoConnect")||"",a=e(r);lE(()=>{n==="success"&&r&&a.installed&&!a.connecting&&!a.connected&&!o.current[r]&&(o.current[r]=!0,t(r))},[a,n])}i(yh,"useForceAutoConnect");import{isApprovalTX as cE,RouteEventType as Sh,StepEventType as Ch,StepExecutionEventStatus as uE,WidgetEvents as Xi}from"@rango-dev/queue-manager-rango-preset";import{useEffect as kh}from"react";function tp(){let t=Z.use.connectedWallets(),e=Z.use.getWalletsDetails(),o=be.use.setNotification(),{findToken:n}=y();kh(()=>{let r=i(a=>{let{event:s,step:l,route:p}=a;if(s.type===Ch.TX_EXECUTION&&s.status===uE.TX_SENT&&!cE(l)||s.type===Ch.SUCCEEDED){let c=t.find(f=>f.chain===l?.fromBlockchain),m=l?.fromBlockchain!==l?.toBlockchain&&t.find(f=>f.chain===l?.toBlockchain);c&&e([c],n),m&&e([m],n)}o(s,p)},"handleStepEvent");return ye.on(Xi.StepEvent,r),()=>ye.off(Xi.StepEvent,r)},[ye,t]),kh(()=>{let r=i(a=>{let{event:s,route:l}=a;(s.type===Sh.FAILED||s.type===Sh.SUCCEEDED)&&o(s,l)},"handleRouteEvent");return ye.on(Xi.RouteEvent,r),()=>ye.off(Xi.RouteEvent,r)},[ye])}i(tp,"useSubscribeToWidgetEvents");import{useManager as mE}from"@rango-dev/queue-manager-react";import{useEffect as dE}from"react";function op(){let{isSynced:t,syncNotifications:e}=be(),{manager:o,state:n}=mE();dE(()=>{be.persist.hasHydrated()&&n.loadedFromPersistor&&!t&&e(ut(o))},[be.persist.hasHydrated(),n.loadedFromPersistor,t])}i(op,"useSyncNotifications");function np(){yh(),gh(),tp(),op();let t=y().blockchains(),{canSwitchNetworkTo:e}=Zr(),[o,n]=vh(""),[r,a]=vh(),s=yE(Er),l=t.filter(hE),{fetchApiConfig:p}=hh();Th(()=>()=>iu(),[]),fE({lastConnectedWallet:o,clearDisconnectedWallet:()=>{a(void 0)},disconnectedWallet:r,evmChains:l,canSwitchNetworkTo:e}),Th(()=>(lo.init(),be.persist.hasHydrated()||be.persist.rehydrate(),s.onConnectWallet(n),s.onDisconnectWallet(u=>{a(u),u===gE(o)?.[0]&&n("")}),p().catch(console.log),lo.destroy),[])}i(np,"useBootstrap");import{styled as SE}from"@rango-dev/ui";var wh=SE("div",{fontFamily:"$widget",boxSizing:"border-box",textAlign:"left","& *, *::before, *::after":{boxSizing:"inherit"},"& *:focus-visible":{outlineColor:"$info500",transition:"none"},"& ul, ol, li":{listStyleType:"none"}});function Yi(){np();let{config:t}=y(),{activeTheme:e}=Qo(t?.theme||{}),{activeLanguage:o}=eo();return rp.createElement(CE,{language:o},rp.createElement(wh,{id:"swap-container",className:e()},rp.createElement(fh,null)))}i(Yi,"Main");import{setSolanaSignerConfig as OE}from"@rango-dev/signer-solana";import ap,{useEffect as Nh,useMemo as UE}from"react";import{useState as kE}from"react";var TE=i(()=>{let[t,e]=kE(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=xp(a);if(s){let l=o(s);e(l)}},"handleLoadCustomFont")}},"useFontLoader"),bh=TE;import{checkWaitingForNetworkChange as vE,makeQueueDefinition as wE}from"@rango-dev/queue-manager-rango-preset";import{Provider as bE}from"@rango-dev/queue-manager-react";import{useWallets as xE}from"@rango-dev/wallets-react";import{convertEvmBlockchainMetaToEvmChainInfo as EE}from"@rango-dev/wallets-shared";import{isEvmBlockchain as IE}from"rango-types";import AE,{useMemo as NE}from"react";function WE(t){let{providers:e,getSigners:o,state:n,connect:r,canSwitchNetworkTo:a,getWalletInfo:s}=xE(),l=NE(()=>wE({API_KEY:t.apiKey||Bt("API_KEY"),BASE_URL:Bt("BASE_URL"),emitter:{emit:ye.emit}}),[t.apiKey]),p=y().blockchains(),c={blockchains:Z.use.connectedWallets().map(T=>({accounts:[T],name:T.chain}))},m=i(async(T,v)=>{if(a(T,v))return r(T,v)},"switchNetwork"),f=i(T=>!!s(T).mobileWallet,"isMobileWallet"),g=p.filter(T=>T.enabled).reduce((T,v)=>(T[v.name]=v,T),{}),d=p.filter(IE),h=i(T=>{let{supportedChains:v}=s(T);return pr(v)},"getSupportedChainNames"),k=e(),S={meta:{blockchains:g,evmBasedChains:d,evmNetworkChainInfo:EE(d),getSupportedChainNames:h},getSigners:o,wallets:c,providers:k,switchNetwork:m,canSwitchNetworkTo:a,connect:r,state:n,isMobileWallet:f},C=se.use.isActiveTab();return AE.createElement(bE,{queuesDefs:[l],context:S,onPersistedDataLoaded:T=>{vE(T)},isPaused:!C},t.children)}i(WE,"QueueManager");var xh=WE;import{useManager as DE}from"@rango-dev/queue-manager-react";import _E,{createContext as $E,useContext as FE}from"react";function Eh(){let{findToken:t}=y(),e=y().blockchains(),o=y().tokens(),{setFromBlockchain:n,setFromToken:r,setToBlockchain:a,setToToken:s,setInputAmount:l}=z();return i(u=>{let{fromBlockchain:c,fromToken:m,toBlockchain:f,toToken:g,requestAmount:d}=u,h={blockchains:e,tokens:o};if(c!==void 0){let k=e.find(S=>S.name===c)??null;n(k)}if(m!==void 0){let k=m?t(m)??null:null;r({meta:h,token:k})}if(f!==void 0){let k=e.find(S=>S.name===f)??null;a(k)}if(g!==void 0){let k=g?t(g)??null:null;s({meta:h,token:k})}d!==void 0&&l(d)},"updateQuoteInputs")}i(Eh,"useUpdateQuoteInputs");import{cancelSwap as ME,getCurrentBlockchainOfOrNull as LE,getCurrentStep as BE,getRelatedWalletOrNull as PE}from"@rango-dev/queue-manager-rango-preset";var Zi=class{static{i(this,"WidgetHistory")}constructor(e,o){this.manager=e,this.actions=o}getAllSwaps(){return ut(this.manager)}getCurrentStep(e){return this.getCurrentStepInfo(e).step}getCurrentStepWallet(e){return this.getCurrentStepInfo(e).wallet}getCurrentStepNetwork(e){return this.getCurrentStepInfo(e).network}retry(e,o){let n=Br(e,o.blockchains,this.actions.findToken);return this.actions.retrySwap(n)}cancel(e){let o=this.manager?.get(e);o&&ME(o)}getCurrentStepInfo(e){let o=BE(e);return{step:o,wallet:o?PE(e,o):null,network:o?LE(e,o):null}}};var Ih=$E(void 0);function ip(t){let{manager:e}=DE(),o=se.use.isActiveTab(),n=z.use.retry(),{findToken:r}=y(),a=new Zi(e,{retrySwap:n,findToken:r}),s=Z.use.connectedWallets(),l=Z.use.loading(),p=Bp(s),u=Z.use.getWalletsDetails(),c=y().blockchains(),m=y().tokens(),f=y().swappers(),g=y().fetchStatus,d=eo().resetLanguage,h=be().getNotifications(),k=be().clearNotifications,S=Eh(),{fromBlockchain:C,toBlockchain:T,fromToken:v,toToken:w,inputAmount:A}=z(),M={isActiveTab:o,setCurrentTabAsActive:lo.forceClaim,history:a,wallets:{isLoading:l,details:s,totalBalance:p,refetch:b=>u(b,r)},meta:{blockchains:c,tokens:m,swappers:f,loadingStatus:g,findToken:r},resetLanguage:d,notifications:{list:h,clearAll:k},quote:{quoteInputs:{fromBlockchain:C?.name??null,fromToken:v?{symbol:v.symbol,blockchain:v.blockchain,address:v.address}:null,toBlockchain:T?.name??null,toToken:w?{symbol:w.symbol,blockchain:w.blockchain,address:w.address}:null,requestAmount:A},updateQuoteInputs:S}};return _E.createElement(Ih.Provider,{value:M},t.children)}i(ip,"WidgetInfo");function Ah(){let t=FE(Ih);if(!t)throw new Error("useWidget can only be used within the WidgetProvider component");return t}i(Ah,"useWidget");function Ji(t){let{onUpdateState:e,config:o}=t,n=t.config?.theme?.fontFamily,{handleLoadCustomFont:r}=bh();return Nh(()=>{n&&r(n)},[n]),UE(()=>{zp({API_KEY:o?.apiKey||nr,BASE_URL:o?.apiUrl||fp})},[o.apiKey,o.apiUrl]),Nh(()=>{t.config?.signers?.customSolanaRPC&&OE("customRPC",t.config.signers.customSolanaRPC)},[t.config?.signers?.customSolanaRPC]),ap.createElement(Ir,{config:o,onUpdateState:e},ap.createElement(xh,{apiKey:o.apiKey},ap.createElement(ip,null,t.children)))}i(Ji,"WidgetProvider");function Wh(t){let e=t.config?.externalWallets;return Ri.createElement(Mc,null,e?Ri.createElement(Yi,null):Ri.createElement(Ji,{config:t.config??ra},Ri.createElement(Yi,null)))}i(Wh,"Widget");function Mh(){let{on:t,off:e}=ye;return{on:t,off:e}}i(Mh,"useWidgetEvents");var yj={DerivationPath:mn,Namespaces:un,isOnDerivationPath:fn,isOnNamespace:dn};export{q3 as EventSeverity,so as MainEvents,R3 as Networks,oj as PendingSwapNetworkStatus,ha as QuoteEventTypes,H3 as RouteEventType,ia as SUPPORTED_FONTS,yj as StatefulConnect,G3 as StepEventType,V3 as StepExecutionBlockedEventStatus,K3 as StepExecutionEventStatus,$e as UI_ID,ya as UiEventTypes,Sr as WalletEventTypes,Z3 as WalletEvents,ej as WalletTypes,Wh as Widget,so as WidgetEvents,Ji as WidgetProvider,Ir as WidgetWallets,Ra as customizedThemeTokens,X3 as readAccountAddress,Ht as useStatefulConnect,ft as useWalletList,Zr as useWallets,Ah as useWidget,Mh as useWidgetEvents,yr as widgetEventEmitter};
1
+ var Mh=Object.defineProperty;var i=(t,e)=>Mh(t,"name",{value:e,configurable:!0});import{EventSeverity as x3,RouteEventType as b3,StepEventType as E3,StepExecutionBlockedEventStatus as I3,StepExecutionEventStatus as A3}from"@rango-dev/queue-manager-rango-preset";import{legacyReadAccountAddress as W3}from"@rango-dev/wallets-core/legacy";import{useWallets as Zr,Events as L3}from"@rango-dev/wallets-react";import{Networks as P3,WalletTypes as D3}from"@rango-dev/wallets-shared";import{PendingSwapNetworkStatus as $3}from"rango-types";import{Divider as lS}from"@rango-dev/ui";import uo,{useEffect as pS,useRef as cS,useState as Ec}from"react";import{WalletState as Lh}from"@rango-dev/ui";import{useWallets as Bh}from"@rango-dev/wallets-react";import{useReducer as Ph}from"react";function sp(t){return!!t.derivationPath}i(sp,"isStateOnDerivationPathStep");function lp(t){return!!t.namespace}i(lp,"isStateOnNamespace");var er={status:"init",namespace:null,derivationPath:null};function pp(t,e){switch(e.type){case"needsNamespace":return{...t,status:"namespace",namespace:e.payload,derivationPath:null};case"needsDerivationPath":return{...t,status:"derivationPath",derivationPath:e.payload};case"reset":return er;case"resetDerivation":return t.namespace?{...t,derivationPath:null,status:"namespace"}:er;default:throw new Error("Action hasn't been defined.")}}i(pp,"reducer");function Ht(){let{state:t,disconnect:e,connect:o}=Bh(),[n,r]=Ph(pp,er),a=i(async(c,m,f)=>{r({type:"reset"});try{return await o(c,void 0,m),{status:"connected"}}catch(g){let d=g?.message?`Error: ${g.message}`:"An unknown error happened during connecting wallet.";throw new Error(d,{cause:g})}},"runConnect"),s=i(async(c,m)=>{if(c.state===Lh.DISCONNECTED){if(!c.namespaces)return await a(c.type,void 0,m);let g=c.namespaces.length>1,d=c.needsDerivationPath;return g?(r({type:"needsNamespace",payload:{providerType:c.type,providerImage:c.image,availableNamespaces:c.namespaces,singleNamespace:c.singleNamespace}}),{status:"namespace"}):d?(r({type:"needsDerivationPath",payload:{providerType:c.type,providerImage:c.image,namespace:c.namespaces[0]}}),{status:"derivation-path"}):await a(c.type,c.namespaces.map(h=>({namespace:h})),m)}return m?.disconnectIfConnected?(await u(c.type),{status:"disconnected"}):{status:"disconnected-unhandled"}},"handleConnect"),l=i(async(c,m)=>{let f=c.singleNamespace,g=c.needsDerivationPath,d=m[0];if(!d)throw new Error("To confirm a namespace, you should select at least one namespace.");if(f&&g)return r({type:"needsDerivationPath",payload:{providerType:c.type,providerImage:c.image,namespace:d}}),{status:"derivation-path"};if(!lp(n))throw new Error("Something went wrong on handling namespace. Please retry.");let h=n.namespace.providerType,k=m.map(S=>({namespace:S}));return await a(h,k)},"handleNamespace"),p=i(async c=>{if(!c)throw new Error("Derivation path is empty. Please make sure you've filled the field correctly.");if(!sp(n))throw new Error("It seems you are filling derivation path without setting namespace before doing that. Please retry to connect.");let m=n.derivationPath.providerType,g=[{namespace:n.derivationPath.namespace,derivationPath:c}];return await a(m,g)},"handleDerivationPath"),u=i(async c=>{let m=t(c);return m.connected||m.connecting?(await e(c),{status:"disconnected"}):{status:"noop"}},"handleDisconnect");return{handleConnect:s,handleDisconnect:u,handleNamespace:l,handleDerivationPath:p,getState:()=>n,resetState:c=>{r(c==="derivation"?{type:"resetDerivation"}:{type:"reset"})}}}i(Ht,"useStatefulConnect");import{WalletState as Sa}from"@rango-dev/ui";import{useWallets as by}from"@rango-dev/wallets-react";import{detectMobileScreens as Ey,KEPLR_COMPATIBLE_WALLETS as Iy,WalletTypes as Lo}from"@rango-dev/wallets-shared";import{useCallback as Ay,useEffect as Ny}from"react";import gy,{createContext as hy,useContext as yy,useEffect as Sy,useRef as Cy}from"react";import{create as dy}from"zustand";import{persist as fy}from"zustand/middleware";var oa=class{static{i(this,"CacheService")}#e=new Map;get(e){return this.#e.get(e)}set(e,o){this.#e.set(e,o)}remove(e){this.#e.delete(e)}clear(){this.#e.clear()}},Ao=new oa;function tr(t,e){return e.find(o=>o.name===t)?.displayName}i(tr,"getBlockchainDisplayNameFor");function pt(t,e){return e.find(o=>o.name===t)?.shortName}i(pt,"getBlockchainShortNameFor");function cp(t,e){return e.find(o=>o.name===t)?.logo}i(cp,"getBlockchainImage");function on(t,e){return e.find(o=>o.id===t)?.title}i(on,"getSwapperDisplayName");function nn(t,e){return e.find(o=>o.name===t)??null}i(nn,"findBlockchain");function na(t,e){if(!e||!t)return!1;for(let o of e.feeAssets)if(t?.blockchain===o?.blockchain&&t?.symbol===o?.symbol&&t?.address===o?.address)return!0;return!1}i(na,"isTokenNative");function _e(t){return`${t.blockchain.toLowerCase()}-${t.symbol.toLowerCase()}-${(t.address??"").toLowerCase()}`}i(_e,"createTokenHash");function No(t,e){return t.addressPatterns.filter(r=>new RegExp(r).test(e)).length>0}i(No,"isValidTokenAddress");function rn(t){let{config:e,meta:o}=t,n={},r=e.tokens,a=i(l=>{l.forEach(p=>{typeof p!="string"&&(p=_e(p));let u=o.tokensMapByTokenHash.get(p);u&&(n[p]=u)})},"addTokens");if(Array.isArray(r))return r.length>0?(a(r),Object.values(n)):Array.from(o.tokensMapByTokenHash.values());if(!r)return Array.from(o.tokensMapByTokenHash.values());let s;if(e.blockchains?.length)s=e.blockchains;else{s=Object.keys(r);let l=new Set(s);Object.keys(o.tokensMapByBlockchainName).forEach(p=>{l.has(p)||a(o.tokensMapByBlockchainName[p])})}return s.forEach(l=>{let p=r[l];if(!p&&o.tokensMapByBlockchainName?.[l]){a(o.tokensMapByBlockchainName[l]);return}p&&(p.isExcluded?(a(o.tokensMapByBlockchainName[l]),p.tokens.forEach(u=>{let c=_e(u);delete n[c]})):a(p.tokens))}),Object.values(n)}i(rn,"matchTokensFromConfigWithMeta");function or(t){let{config:e}=t,o=e.from?.blockchains||[],n=e.to?.blockchains||[];if(!o.length||!n.length)return[];let r=[...o,...n],a=new Set(r);return Array.from(a)}i(or,"getSupportedBlockchainsFromConfig");var ra={apiKey:"",title:void 0,multiWallets:!0,excludeLiquiditySources:!0,customDestination:!0,variant:"default",trezorManifest:{appUrl:"https://widget.rango.exchange/",email:"hi+trezorwidget@rango.exchange"}},Dh={clientUrl:void 0},_h={liquiditySources:void 0},up=i((t,e,o)=>({config:{...ra,...t},iframe:Dh,campaignMode:_h,getLiquiditySources:()=>{let{config:n,campaignMode:r}=o();return r.liquiditySources?.length?r.liquiditySources:n.liquiditySources??[]},getDisabledLiquiditySources:()=>{let{disabledLiquiditySources:n,campaignMode:r}=o();return r.liquiditySources?.length?[]:n},excludeLiquiditySources:()=>{let{config:n,campaignMode:r}=o();return r.liquiditySources?.length?!1:!!n.excludeLiquiditySources},isInCampaignMode:()=>{let{campaignMode:n}=o();return!!n.liquiditySources?.length},updateConfig:n=>{let r=o().config,{_tokensMapByTokenHash:a,_tokensMapByBlockchainName:s}=o(),l=rn({type:"source",config:{blockchains:n.from?.blockchains,tokens:n.from?.tokens},meta:{tokensMapByBlockchainName:s,tokensMapByTokenHash:a}}),p=rn({type:"destination",config:{blockchains:n.to?.blockchains,tokens:n.to?.tokens},meta:{tokensMapByBlockchainName:s,tokensMapByTokenHash:a}});Ao.set("supportedSourceTokens",l),Ao.set("supportedDestinationTokens",p),e({config:{...r,...n}})},updateCampaignMode:(n,r)=>{let a=o().campaignMode;e({campaignMode:{...a,[n]:r}})},updateIframe:(n,r)=>{let a=o().iframe;e({iframe:{...a,[n]:r}})}}),"createConfigSlice");import{TransactionType as mp}from"rango-types";var dp=[mp.EVM,mp.SOLANA];import{RangoClient as Zh}from"rango-sdk";import{UI_ID as $h}from"@rango-dev/ui";var nr="c6381a79-2817-4602-83bf-6a641a409e32",fp="https://api.rango.exchange",gp="https://explorer.rango.exchange",$e={SWAP_BOX_ID:"rango-swap-box",EXPANDED_BOX_ID:"rango-expanded-box",...$h};import{BlockchainCategories as Hh,WalletState as bt}from"@rango-dev/ui";import{legacyReadAccountAddress as Gh}from"@rango-dev/wallets-core/legacy";import{detectInstallLink as Vh,getCosmosExperimentalChainInfo as Kh,isEvmAddress as jh,KEPLR_COMPATIBLE_WALLETS as vI,Networks as Ap}from"@rango-dev/wallets-shared";import ca from"bignumber.js";import{isCosmosBlockchain as Xh}from"rango-types";import Fh from"bignumber.js";var Ue=new Fh(0);import{WalletTypes as Oh}from"@rango-dev/wallets-shared";var hp=[Oh.LEAP];import{BlockchainCategories as aa,WalletState as qh}from"@rango-dev/ui";import{TransactionType as rr}from"rango-sdk";var yp="Roboto",ia=[{name:"Roboto",value:"Roboto",url:""},{name:"Times New Roman",value:"Times New Roman",url:"https://fonts.cdnfonts.com/css/times-new-roman"},{name:"Arial",value:"Arial",url:""},{name:"Open Sans",value:"Open Sans",url:"https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,300..800;1,300..800&display=swap"},{name:"Noto Sans",value:"Noto Sans",url:"https://fonts.googleapis.com/css2?family=Noto+Sans:ital,wght@0,100..900;1,100..900&display=swap"},{name:"Montserrat",value:"Montserrat",url:"https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100..900;1,100..900&display=swap"},{name:"Poppins",value:"Poppins",url:"https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap"},{name:"Roboto Condensed",value:"Roboto Condensed",url:"https://fonts.googleapis.com/css2?family=Roboto+Condensed:ital,wght@0,100..900;1,100..900&display=swap"},{name:"Roboto Mono",value:"Roboto Mono",url:"https://fonts.googleapis.com/css2?family=Roboto+Mono:ital,wght@0,100..700;1,100..700&display=swap"},{name:"Oswald",value:"Oswald",url:"https://fonts.googleapis.com/css2?family=Oswald:wght@200..700&display=swap"},{name:"Raleway",value:"Raleway",url:"https://fonts.googleapis.com/css2?family=Raleway:ital,wght@0,100..900;1,100..900&display=swap"},{name:"Sedan",value:"Sedan",url:"https://fonts.googleapis.com/css2?family=Sedan:ital@0;1&display=swap"},{name:"Inter",value:"Inter",url:"https://fonts.googleapis.com/css2?family=Inter:wght@100..900&display=swap"},{name:"Rubik",value:"Rubik",url:"https://fonts.googleapis.com/css2?family=Rubik:ital,wght@0,300..900;1,300..900&display=swap"},{name:"Lora",value:"Lora",url:"https://fonts.googleapis.com/css2?family=Lora:ital,wght@0,400..700;1,400..700&display=swap"},{name:"Barlow Condensed",value:"Barlow Condensed",url:"https://fonts.googleapis.com/css2?family=Barlow+Condensed:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap"}];function Wo(t){return Array.from(new Set(t))}i(Wo,"removeDuplicateFrom");function pa(t,e){return t.length===e.length&&t.every((o,n)=>o===e[n])}i(pa,"areEqual");function wp(t,e){let o;return n;function n(...r){o&&clearTimeout(o),o=setTimeout(()=>{o=null,t(...r)},e)}}i(wp,"debounce");function et(t,e){return t.toLowerCase().indexOf(e.toLowerCase())>-1}i(et,"containsText");function kp(t,e){return t.toLowerCase()===e.toLowerCase()}i(kp,"exactText");function Tp(t,e){return t.toLowerCase().startsWith(e.toLowerCase())}i(Tp,"startWithText");var N=i(()=>document.getElementById($e.SWAP_BOX_ID),"getContainer"),an=i(()=>document.getElementById($e.EXPANDED_BOX_ID),"getExpanded");function vp(t,e,o){let n=!!e&&kp(e,t),r=!!o&&kp(o,t);return n!==r?n?-1:1:0}i(vp,"compareExactMatchText");function sa(t,e,o){let n=!!e&&et(e,t),r=!!o&&et(o,t);return n!==r?n?-1:1:n&&r&&e?.length!==o?.length?e?.length-o?.length:0}i(sa,"compareContainsText");function la(t,e,o){let n=!!e&&Tp(e,t),r=!!o&&Tp(o,t);return n!==r?n?-1:1:n&&r&&e?.length!==o?.length?e?.length-o?.length:0}i(la,"compareStartWithText");function xp(t,e,o){if(!o)return 0;let n=vp(o,t.symbol,e.symbol);if(n)return n;if(o.length>=3){let r=vp(o,t.name,e.name);if(r)return r}if(o.length>=2){let r=la(o,t.symbol,e.symbol);if(r)return r}if(o.length>=3){let r=sa(o,t.symbol,e.symbol);if(r)return r}if(o.length>=3){let r=la(o,t.name,e.name);if(r)return r}if(o.length>=3){let r=sa(o,t.name,e.name);if(r!==0)return r}if(o.length>=4){let r=la(o,t.address,e.address);if(r)return r}if(o.length>=4){let r=sa(o,t.address,e.address);if(r!==0)return r}return 0}i(xp,"compareWithSearchFor");var ir=i((t,e)=>{switch(e){case aa.ALL:return!0;case aa.UTXO:return t===rr.TRANSFER;case aa.OTHER:return t!==rr.TRANSFER&&t!==rr.COSMOS&&t!==rr.EVM;default:return t===e}},"isBlockchainTypeInCategory"),bp=i(t=>ia.find(o=>o.value===t)?.url,"getFontUrlByName");function Ep(t,e){let o=!!t.find(n=>n.state===qh.CONNECTED);return e===!1&&o}i(Ep,"isSingleWalletActive");import{BigNumber as Ip}from"bignumber.js";var sn=i(t=>{let e=Math.floor(t%60/15)*15,o=parseInt((t/60).toString());return o>=60?`${Math.floor(o/5)*5}:00`:`${o.toString().padStart(2,"0")}:${e.toString().padStart(2,"0")}`},"roundedSecondsToString"),L=i((t,e=null,o=null)=>{if(t==null||t==="")return"";let n=new Ip(t),r=1,a=1e3;for(let s=0;s<60;s++)if(new Ip(n.toFixed(s,r)).eq(n)){a=s;break}if(n.gte(1e4))return n.toFormat(0,r);if(n.gte(1e3)||n.gte(100))return n.toFormat(Math.min(a,Math.min(o||100,Math.max(e||0,1))),r);if(n.gte(1))return n.toFormat(Math.min(a,Math.min(o||100,Math.max(e||0,2))),r);if(n.gte(.01))return n.toFormat(Math.min(a,Math.min(o||100,Math.max(e||0,4))),r);for(let s=e||4;s<17;s++)if(n.gte(Math.pow(10,-s)))return n.toFormat(Math.min(a,Math.min(o||100,Math.max(e||0,s))),r);return n.isEqualTo(0)?"0":n.toFormat(Math.min(a,Math.min(o||100,Math.max(e||0,8))),r)},"numberToString");var ar=i(t=>t?.reduce((e,o)=>e+(o.estimatedTimeInSeconds??0),0)||0,"totalArrivalTime");var xt=i((t,e)=>t.toLowerCase().indexOf(e.toLowerCase())>-1,"containsText"),ln=i(t=>!!t&&parseFloat(t)>0,"isPositiveNumber");function pn(t){switch(!0){case t.connected:return bt.CONNECTED;case t.connecting:return bt.CONNECTING;case!t.installed:return bt.NOT_INSTALLED;default:return bt.DISCONNECTED}}i(pn,"mapStatusToWalletState");function Np(t,e,o,n){return o.filter(r=>!hp.includes(r)).filter(r=>{let{supportedChains:a,isContractWallet:s}=e(r),{installed:l,network:p}=t(r);return s&&(!l||!!n&&p!==n)?!1:n?!!a.find(c=>c.name===n):!0}).map(r=>{let{name:a,img:s,installLink:l,showOnMobile:p,namespaces:u,singleNamespace:c,supportedChains:m,needsDerivationPath:f}=e(r),g=Wo(m.map(h=>h.type)),d=pn(t(r));return{title:a,image:s,link:Vh(l),state:d,type:r,showOnMobile:p,namespaces:u,singleNamespace:c,blockchainTypes:g,needsDerivationPath:f}})}i(Np,"mapWalletTypesToWalletInfo");function pr(t){if(!t)return null;let e=[];return e=t.map(o=>o.name),e}i(pr,"walletAndSupportedChainsNames");function Wp(t,e,o,n,r){let a=[];function s(p,u){if(!!!a.find(m=>m.chain===p)){let m={address:u,chain:p,walletType:t};a.push(m)}}i(s,"addAccount");let l=n||[];return e.forEach(p=>{let{address:u,network:c}=Gh(p),m=l.length>0,f=l.includes(c),g=c===Ap.Unknown;if(m&&!f&&!g)return;let h=c===Ap.Unknown&&jh(u);if(g&&!h)return;o.includes(c)||h?r?s(c,u.toLowerCase()):l.filter(C=>o.includes(C)).forEach(C=>{s(C,u.toLowerCase())}):s(c,u)}),a}i(Wp,"prepareAccountsForWalletStore");function 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:p}=r;p.forEach((u,c)=>{let m=u.from.blockchain,f=u.to.blockchain,g=a===o.swaps.length-1,d=c===p.length-1;(!g&&!d||g&&l!==m||e==="all")&&n.add(m),e==="all"&&n.add(f)})}e==="all"&&n.add(l)}),Array.from(n)}i(io,"getQuoteWallets");function cr(t,e){return t.address===e.address&&t.chain===e.chain&&t.walletType===e.walletType}i(cr,"isAccountAndWalletMatched");function Mp(t,e){let{blockChain:o,balances:n=[]}=t;return n?.map(r=>({chain:o,symbol:r.asset.symbol,ticker:r.asset.symbol,address:r.asset.address||null,rawAmount:r.amount.amount,decimal:r.amount.decimals,amount:new ca(r.amount.amount).shiftedBy(-r.amount.decimals).toFixed(),logo:"",usdPrice:e(r.asset)?.usdPrice||null}))||[]}i(Mp,"makeBalanceFor");function Lp(t){return{...t,loading:!1,error:!0}}i(Lp,"resetConnectedWalletState");var Bp=i(t=>{let e=new Set,n=t?.reduce((a,s)=>a.findIndex(l=>l.address===s.address&&l.chain===s.chain)===-1?[...a,s]:a,[])?.map(a=>{let s={name:a.chain,accounts:[]};return e.has(a.address)||e.add(a.address),e.forEach(l=>{a.address===l&&s.accounts.push(a)}),s}),r=L(n?.flatMap(a=>a.accounts)?.flatMap(a=>a?.balances)?.map(a=>new ca(a?.amount||Ue).multipliedBy(a?.usdPrice||0))?.reduce((a,s)=>a.plus(s),Ue)||Ue).toString();return Yh(r)},"calculateWalletUsdValue");function Yh(t){let e=t.toString().split(".");return e[0]=e[0].replace(/\B(?=(\d{3})+(?!\d))/g,","),e.join(".")}i(Yh,"numberWithThousandSeparator");var ur=i((t,e)=>{let o=Kh(Object.entries(t).map(([,n])=>n).filter(Xh));return o&&o[e]?.experimental},"isExperimentalChain");function mr(t){return t?{...t,amount:L(t.amount,8,8),usdValue:L(t.usdValue,4,4)}:null}i(mr,"formatBalance");function Pp(t,e){return t?.usdValue||e?.usdValue?parseFloat(e?.usdValue||"0")-parseFloat(t?.usdValue||"0"):t?.amount||e?.amount?parseFloat(e?.amount||"0")-parseFloat(t?.amount||"0"):0}i(Pp,"compareTokenBalance");function ao(t,e){return t?.blockchain===e?.blockchain&&t?.symbol.toLowerCase()===e?.symbol.toLowerCase()&&t?.address?.toLowerCase()===e?.address?.toLowerCase()}i(ao,"areTokensEqual");function Dp(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(Dp,"sortWalletsBasedOnConnectionState");function dr(t,e=8,o=3){if(t.length<2*e+o)return t;let n=t.slice(0,e),r=t.slice(-e);return`${n}${".".repeat(o)}${r}`}i(dr,"getConciseAddress");function _p({chain:t,connectedWallets:e,walletType:o}){return e.find(n=>n.walletType===o&&n.chain===t)?.address}i(_p,"getAddress");function fr(t){return t.flatMap(e=>e.balances).reduce((e,o)=>{let n={amount:o?.amount??"",decimals:o?.decimal??0,usdValue:o?.usdPrice?new ca(o?.usdPrice??Ue).multipliedBy(o?.amount).toString():""},r=o?_e({symbol:o.symbol,blockchain:o.chain,address:o.address}):null,a=r?e[r]:null;return r&&(!a||a&&a.amount<n.amount)&&(e[r]=n),e},{})}i(fr,"makeTokensBalance");var $p=i((t,e)=>!!t.find(o=>o.chain===e&&o.loading),"isFetchingBalance");function Fp(t){return t.map(e=>e.state).join("-")}i(Fp,"hashWalletsState");function Op(t,e){let o=new Set;return t.forEach(r=>{r.blockchainTypes.forEach(a=>{o.add(a)})}),e.filter(r=>o.has(r.type))}i(Op,"filterBlockchainsByWalletTypes");function Up(t,e){return e===Hh.ALL?t:t.filter(o=>{for(let n of o.blockchainTypes)if(ir(n,e))return!0;return!1})}i(Up,"filterWalletsByCategory");var ua={API_KEY:nr};function Bt(t){return ua[t]||""}i(Bt,"getConfig");function zp(t){let e;return typeof structuredClone=="function"?e=structuredClone(t):e=JSON.parse(JSON.stringify(t)),ua=e,ua}i(zp,"initConfig");var Qp=20,qp=25,ma="theme-widget",da=i((t,e)=>{let o=!1;if(e&&t){if(Array.isArray(e))o=!e.some(n=>ao(n,t));else if(!Array.isArray(e)&&e[t.blockchain]){o=e[t.blockchain].tokens.some(r=>ao(r,t));let n=e[t.blockchain].isExcluded;return!n&&!o||n&&o}}return o},"isTokenExcludedInConfig"),fa=i((t,e)=>t&&e&&!e.includes(t.name),"isBlockchainExcludedInConfig"),Hp=i((t,e,o)=>o==="expanded"&&(t||e)||o==="full-expanded"&&e,"isVariantExpandable");var gr,Et=i(()=>gr||(gr=new Zh(Bt("API_KEY"),Bt("BASE_URL")),gr),"httpService");function hr(t,e){let o=t.map(a=>a.swapperGroup),n=[];return Wo(t.map(a=>a.swapperGroup)).map(a=>{let s=t.find(l=>l.swapperGroup===a);if(s){let l=!0;o&&(l=o.some(p=>p===s.swapperGroup)),l&&s.types.map(p=>{n.push({id:s.swapperGroup,groupTitle:s.swapperGroup,logo:s.logo,type:p,selected:!e.includes(s.swapperGroup)})})}}),n}i(hr,"getUniqueSwappersGroups");function Gp(t,e){return t.swapperGroup<e.swapperGroup?-1:t.swapperGroup>e.swapperGroup?1:0}i(Gp,"sortLiquiditySourcesByGroupTitle");function je(t,e){return e?.[t]==="hidden"}i(je,"isFeatureHidden");function Vp(t,e){return e?.[t]==="enabled"}i(Vp,"isFeatureEnabled");var Kp=i((t,e,o)=>je("customTokens",o)?t:t.concat(e),"addCustomTokensToSupportedTokens");var jp=i((t,e)=>({_blockchainsMapByName:new Map,_tokensMapByTokenHash:new Map,_tokensMapByBlockchainName:{},_popularTokens:[],_swappers:[],fetchStatus:"loading",blockchains:o=>{let n=e()._blockchainsMapByName,r=Array.from(n?.values()||[]);if(!o||!o?.type)return r;let a=e().config;if(o.type==="custom-token"){let p=or({config:a}),u=r;return p.length>0&&(u=u.filter(c=>p.includes(c.name))),u.filter(c=>dp.includes(c.type))}let s=(o.type==="source"?a.from?.blockchains:a.to?.blockchains)??[];return r.filter(p=>!(s.length>0&&!s.includes(p.name)))},tokens:o=>{let{_tokensMapByTokenHash:n,_tokensMapByBlockchainName:r,config:a,_customTokens:s}=e(),l=Array.from(n.values()),p=e()._blockchainsMapByName;if(!o||!o.type)return l;let u=o.type==="source"?"from":"to",c=o.type==="source"?"supportedSourceTokens":"supportedDestinationTokens",m=Ao.get(c);m?.length||(m=rn({type:o.type,config:{blockchains:a[u]?.blockchains,tokens:a[u]?.tokens},meta:{tokensMapByTokenHash:n,tokensMapByBlockchainName:r}}),Ao.set(c,m)),m=Kp(m,s,a.features);let f=e().blockchains({type:o.type});return m.filter(d=>o.blockchain&&d.blockchain!==o.blockchain||!f.some(h=>h.name===d.blockchain)?!1:o.searchFor?!!(et(d.symbol,o.searchFor)||et(d.address||"",o.searchFor)||et(d.name||"",o.searchFor)):!0).sort((d,h)=>{let k=e().isTokenPinned(d,o.type),S=e().isTokenPinned(h,o.type);if(k!==S)return k?-1:1;if(o.getBalanceFor){let A=o.getBalanceFor(d),M=o.getBalanceFor(h),x=Pp(A,M);if(x!==0)return x}let C=p.get(d.blockchain),T=p.get(h.blockchain),v=na(d,C),w=na(h,T);if(v!==w)return v?-1:1;if(d.isPopular!==h.isPopular)return d.isPopular?-1:1;if(o.searchFor){let A=xp(d,h,o.searchFor);if(A)return A}return d.isSecondaryCoin!==h.isSecondaryCoin?d.isSecondaryCoin?1:-1:C&&T?C.sort-T.sort:0})},findToken:o=>{let n=e()._tokensMapByTokenHash,r=e().customTokens(),a=_e(o),s=n.get(a);return s||(s=r.find(l=>_e(l)===a)),s},isTokenPinned:(o,n)=>!!(n==="source"?e().config.from?.pinnedTokens:e().config.to?.pinnedTokens)?.some(s=>ao(s,o)),swappers:()=>{let{config:o,campaignMode:n}=e(),r=n.liquiditySources?.length?n.liquiditySources:null,a=r??o.liquiditySources,s=r?!1:o.excludeLiquiditySources;return e()._swappers.filter(u=>{let c=a?.includes(u.swapperGroup);return s||!a||a.length===0?!c:c}).sort(Gp)},fetch:async()=>{try{let{enableCentralizedSwappers:o}=e().config,n=await Et().getAllMetadata({enableCentralizedSwappers:o});t({fetchStatus:"success"});let r=new Map,a=new Map,s={},l=[],p=n.popularTokens,u=n.swappers,c=new Set;n.tokens.forEach(f=>{c.add(f.blockchain),l.push(f)}),n.blockchains.sort((f,g)=>f.sort-g.sort).forEach(f=>{f.enabled&&c.has(f.name)&&r.set(f.name,f)}),l.forEach(f=>{let g=_e(f);s[f.blockchain]||(s[f.blockchain]=[]),a.set(g,f),s[f.blockchain].push(g)}),t({_blockchainsMapByName:r,_tokensMapByTokenHash:a,_tokensMapByBlockchainName:s,_popularTokens:p,_swappers:u})}catch(o){throw t({fetchStatus:"failed"}),o}}}),"createDataSlice");import{Chinese as Jh,English as Rh,Finland as ey,French as ty,German as oy,Greece as ny,Italian as ry,Japanese as iy,Netherlands as ay,Poland as sy,Portuguese as ly,Russian as py,Spanish as cy,Swedish as uy,Ukrainian as my}from"@rango-dev/ui";var Xp=[{title:"English",label:"English",local:"en",SVGFlag:Rh},{title:"Spanish",label:"Espa\xF1ol",local:"es",SVGFlag:cy},{title:"French",label:"Fran\xE7ais",local:"fr",SVGFlag:ty},{title:"Japanese",label:"\u65E5\u672C\u8A9E",local:"ja",SVGFlag:iy},{title:"Portuguese",label:"Portugu\xEAs",local:"pt",SVGFlag:ly},{title:"Chinese",label:"\u4E2D\u56FD\u4EBA",local:"zh",SVGFlag:Jh},{title:"Russian",label:"\u0420\u0443\u0441\u0441\u043A\u0438\u0439",local:"ru",SVGFlag:py},{title:"German",label:"Deutsch",local:"de",SVGFlag:oy},{title:"Ukrainian",label:"\u0423\u043A\u0440\u0430\u0457\u043D\u0456",local:"uk",SVGFlag:my},{title:"Swedish",label:"svenska",local:"sv",SVGFlag:uy},{title:"Finnish",label:"Suomalainen",local:"fi",SVGFlag:ey},{title:"Dutch",label:"Nederlands",local:"nl",SVGFlag:ay},{title:"Greek",label:"Grieks",local:"el",SVGFlag:ny},{title:"Italian",label:"Italiana",local:"it",SVGFlag:ry},{title:"Polish",label:"Polski",local:"pl",SVGFlag:sy}],Mo="en";var Yp=[.5,1,3],Zp=1,Jp=5,Rp=100,ec=0;var tc=i((t,e)=>({disabledLiquiditySources:[],theme:"auto",language:null,preferredBlockchains:[],slippage:Zp,customSlippage:null,infiniteApprove:!1,affiliateRef:null,affiliatePercent:null,affiliateWallets:null,_customTokens:[],addPreferredBlockchain:o=>{let n=e().preferredBlockchains;if(n.find((s,l)=>{let p=s===o,u=l<=9;return p&&u}))return;let a=n.filter(s=>!(s===o));t(()=>({preferredBlockchains:[o,...a]}))},setSlippage:o=>t(()=>({slippage:o})),setCustomSlippage:o=>t(()=>({customSlippage:o})),setAffiliateRef:o=>t(()=>({affiliateRef:o})),setAffiliatePercent:o=>t(()=>({affiliatePercent:o})),setAffiliateWallets:o=>t(()=>({affiliateWallets:o})),toggleAllLiquiditySources:(o,n)=>t(r=>{if(n)return{disabledLiquiditySources:[]};let a=Wo(o.map(s=>s.swapperGroup));return a.length===r.disabledLiquiditySources.length?{disabledLiquiditySources:[]}:{disabledLiquiditySources:a}}),toggleInfiniteApprove:()=>t(o=>({infiniteApprove:!o.infiniteApprove})),toggleLiquiditySource:o=>t(n=>n.disabledLiquiditySources.includes(o)?{disabledLiquiditySources:n.disabledLiquiditySources.filter(r=>r!=o)}:{disabledLiquiditySources:n.disabledLiquiditySources.concat(o)}),setTheme:o=>t(()=>({theme:o})),setLanguage:o=>t(()=>({language:o})),updateSettings:o=>{let{features:n,theme:r}=o,a=je("theme",n),s=je("language",n),l=je("liquiditySource",n),p=r?.singleTheme,u=o?.__UNSTABLE_OR_INTERNAL__?.autoUpdateSettings;t({...a&&{theme:o.theme?.mode||"auto"},...p&&{theme:o.theme?.mode||"light"},...s&&{language:o.language||Mo},...l&&{disabledLiquiditySources:o.liquiditySources||[]},...u&&{language:o.language||Mo}})},setCustomToken:o=>t(n=>({_customTokens:[o,...n._customTokens]})),deleteCustomToken:o=>t(n=>({_customTokens:n._customTokens.filter(r=>r.address!==o.address)})),customTokens:()=>{let o=e().config,n=e()._customTokens,r=or({config:o});return r.length?n.filter(a=>r.includes(a.blockchain)):n}}),"createSettingsSlice");function oc(t){return dy()(fy((...e)=>({...jp(...e),...tc(...e),...up(t,...e)}),{name:"user-settings",skipHydration:!0,partialize:e=>({_customTokens:e._customTokens,theme:e.theme,language:e.language,affiliatePercent:e.affiliatePercent,affiliateRef:e.affiliateRef,affiliateWallets:e.affiliateWallets,slippage:e.slippage,customSlippage:e.customSlippage,infiniteApprove:e.infiniteApprove,preferredBlockchains:e.preferredBlockchains,disabledLiquiditySources:e.disabledLiquiditySources})}))}i(oc,"createAppStore");var nc=hy(null);function y(){let t=yy(nc);if(Sy(()=>{t&&!t.persist.hasHydrated()&&t.persist.rehydrate()},[]),!t)throw new Error("Missing AppStoreContext.Provider in the tree");return t()}i(y,"useAppStore");function rc(t){let e=Cy();return e.current||(e.current=oc(t.config)),gy.createElement(nc.Provider,{value:e.current},t.children)}i(rc,"AppStoreProvider");import{create as vy}from"zustand";import{subscribeWithSelector as wy}from"zustand/middleware";import ky from"mitt";var ye=ky(),yr={on:ye.on,off:ye.off};import{WidgetEvents as ic}from"@rango-dev/queue-manager-rango-preset";var ha=(o=>(o.QUOTE_INPUT_UPDATE="quoteInputUpdate",o.QUOTE_OUTPUT_UPDATE="quoteOutputUpdate",o))(ha||{}),Sr=(o=>(o.CONNECT="connect",o.DISCONNECT="disconnect",o))(Sr||{}),ya=(e=>(e.CLICK_CONNECT_WALLET="clickConnectWallet",e))(ya||{}),so=(a=>(a[a.RouteEvent=ic.RouteEvent]="RouteEvent",a[a.StepEvent=ic.StepEvent]="StepEvent",a.QuoteEvent="quoteEvent",a.WalletEvent="walletEvent",a.UiEvent="uiEvent",a))(so||{});var Ty=i(t=>{let e=t;e.use={};for(let o of Object.keys(e.getState()))e.use[o]=()=>e(n=>n[o]);return e},"createSelectors"),Gt=Ty;var Z=Gt(vy()(wy((t,e)=>({connectedWallets:[],balances:{},loading:!1,connectWallet:(o,n)=>{ye.emit("walletEvent",{type:"connect",payload:{walletType:o[0].walletType,accounts:o}});let r=e().getWalletsDetails;t(a=>({loading:!0,connectedWallets:a.connectedWallets.filter(s=>s.walletType!==o[0].walletType).concat(o.map(s=>{let l=!a.connectedWallets.some(p=>p.chain===s.chain&&p.selected&&p.walletType!==s.walletType);return{balances:[],address:s.address,chain:s.chain,explorerUrl:null,walletType:s.walletType,selected:l,loading:!0,error:!1}}))})),r(o,n)},disconnectWallet:o=>{t(n=>{n.connectedWallets.find(l=>l.walletType===o)&&ye.emit("walletEvent",{type:"disconnect",payload:{walletType:o}});let r=n.connectedWallets.filter(l=>l.selected&&l.walletType!==o).map(l=>l.chain),a=n.connectedWallets.filter(l=>l.walletType!==o).map(l=>r.includes(l.chain)?l:(r.push(l.chain),{...l,selected:!0}));return{balances:fr(a),connectedWallets:a}})},selectWallets:o=>t(n=>({connectedWallets:n.connectedWallets.map(r=>{let a=!!o.find(l=>l.chain===r.chain&&l.walletType!==r.walletType&&r.selected),s=!!o.find(l=>l.chain===r.chain&&l.walletType===r.walletType&&!r.selected);return a?{...r,selected:!1}:s?{...r,selected:!0}:r})})),clearConnectedWallet:()=>t(()=>({connectedWallets:[],selectedWallets:[]})),getWalletsDetails:async(o,n,r=!0)=>{let a=e().getWalletsDetails;t(s=>({loading:!0,connectedWallets:s.connectedWallets.map(l=>o.find(p=>cr(p,l))?{...l,loading:!0}:l)}));try{let s=o.map(({address:u,chain:c})=>({address:u,blockchain:c})),p=(await Et().getWalletsDetails(s)).wallets;if(p)t(u=>{let c=u.connectedWallets.map(f=>{let g=o.find(h=>cr(h,f)),d=p.find(h=>h.address===f.address&&h.blockChain===f.chain);return d?.failed&&g&&r&&a([g],n,!1),g&&d?{...f,explorerUrl:d.explorerUrl,balances:Mp(d,n),loading:!1,error:!1}:f});return{loading:!1,balances:fr(c),connectedWallets:c}});else throw new Error("Wallet not found")}catch{t(l=>{let p=l.connectedWallets.map(c=>o.find(m=>cr(m,c))?Lp(c):c);return{loading:!1,balances:fr(p),connectedWallets:p}})}},getBalanceFor:o=>{let{balances:n}=e(),r=_e(o);return n[r]??null}}))));import{allProviders as xy}from"@rango-dev/provider-all";function Cr(t,e){let o=xy({walletconnect2:{WC_PROJECT_ID:e?.walletConnectProjectId||"",DISABLE_MODAL_AND_OPEN_LINK:e?.walletConnectListedDesktopWalletLink},selectedProviders:t,trezor:e?.trezorManifest?{manifest:e.trezorManifest}:void 0});if(t){let n=[];return t.forEach(r=>{if(typeof r=="string"){let a=o.find(s=>s.config.type===r);a?n.push(a):console.warn(`Couldn't find ${r} provider. Please make sure you are passing the correct name.`)}else n.push(r)}),n}return o}i(Cr,"matchAndGenerateProviders");function ac(t,e){return Cr(t,e).map(r=>r.config.type)}i(ac,"configWalletsToWalletName");var Wy=Object.values(Lo);function ft(t){let{chain:e}=t||{},{config:o}=y(),{state:n,getWalletInfo:r}=by(),{connectedWallets:a}=Z(),s=y().blockchains(),{handleDisconnect:l}=Ht(),p=ac(o?.wallets,{trezorManifest:o?.trezorManifest,walletConnectProjectId:o?.walletConnectProjectId,walletConnectListedDesktopWalletLink:o.__UNSTABLE_OR_INTERNAL__?.walletConnectListedDesktopWalletLink})||Wy,u=Np(n,r,p,e);u=Ey()?u.filter(h=>h.showOnMobile!==!1&&n(h.type).installed):u;let c=Dp(u),m=i(h=>!a.find(k=>k.walletType===h&&k.chain===e),"isExperimentalChainNotAdded"),f=Ay(()=>{let h=u?.filter(k=>k.state===Sa.CONNECTING)||[];for(let k of h)l(k.type)},[Fp(u)]);Ny(()=>()=>{f()},[]);let g=i(h=>{let k=h.find(C=>C.type===Lo.DEFAULT);return!k||k.state===Sa.NOT_INSTALLED?!1:h.filter(C=>C.state!=Sa.NOT_INSTALLED&&![Lo.DEFAULT,Lo.WALLET_CONNECT_2,Lo.LEDGER].includes(C.type)&&r(C.type).supportedChains.filter(T=>T.type=="EVM").length>0).length==0},"shouldShowDefaultInjectedWallet"),d=i((h,k,S)=>ur(S,k)&&m(h)&&!Iy.includes(h)||h==Lo.DEFAULT&&!g(u),"shouldExcludeWallet");return{list:c.filter(h=>!d(h.type,e??"",s)),terminateConnectingWallets:f}}i(ft,"useWalletList");import{Modal as By}from"@rango-dev/ui";import Py from"react";import{create as Ly}from"zustand";var sc="rango-widget";var cn=class{constructor(e){this.state="not-initiated";this.events={};this.init=()=>{this.initEvents(),this.tryClaim()};this.forceClaim=()=>{if(!this.isClaimed()){let e={name:"force-claim",candidateId:this.tabId};this.channel.postMessage(e),setTimeout(()=>{this.isClaimed()||this.claim()},300)}};this.isClaimed=()=>this.state==="claimed";this.destroy=()=>{this.channel.removeEventListener("message",this.handleMessageEvent),document.removeEventListener("visibilitychange",this.handleVisibilityChange),document.removeEventListener("resume",this.handleResume)};this.handleMessageEvent=e=>{let o=e.data.name;switch(o){case"ping":this.claimedByCurrentTab(e.data.pingAt);break;case"pong":this.alreadyClaimedByAnotherTab();break;case"force-claim":this.forceRelease(e.data.candidateId);break;case"force-release":this.tabId===e.data.candidateId&&this.claim();break;default:throw new Error(`${o} is not supported.`)}};this.handleVisibilityChange=async()=>{document.visibilityState==="visible"&&await this.tryClaim()};this.handleResume=async()=>{this.isClaimed()&&(await this.tryClaim(),this.isClaimed()||this.events.onRelease?.())};this.channel=new BroadcastChannel(sc),this.tabId=Math.trunc(Math.random()*1e5),this.events=e}static{i(this,"TabManager")}initEvents(){this.channel.addEventListener("message",this.handleMessageEvent),document.addEventListener("visibilitychange",this.handleVisibilityChange),document.addEventListener("resume",this.handleResume)}claimedByCurrentTab(e){let o=this.lastTryClaim&&this.lastTryClaim<e;if(this.isClaimed()||o){let n={name:"pong"};this.channel.postMessage(n);return}}alreadyClaimedByAnotherTab(){this.resetLastCheck()}async tryClaim(){return this.setLastCheck(),new Promise(e=>{setTimeout(()=>{this.check(),e()},300)})}check(){this.state==="not-initiated"&&this.events.onInit?.(),this.lastTryClaim?(this.claim(),this.resetLastCheck()):this.state="not-claimed"}claim(){this.state="claimed",this.events.onClaim?.()}setLastCheck(){this.lastTryClaim=Date.now();let e={name:"ping",pingAt:this.lastTryClaim};this.channel.postMessage(e)}resetLastCheck(){this.lastTryClaim=void 0}forceRelease(e){if(this.isClaimed()){this.state="not-claimed",this.events.onRelease?.();let o={name:"force-release",candidateId:e};this.channel.postMessage(o)}}};var se=Gt(Ly()((t,e)=>({isActiveTab:!1,tabManagerInitiated:!1,showActivateTabModal:!1,watermark:"NONE",fetchingApiConfig:!1,activateCurrentTab:(o,n)=>{let{showActivateTabModal:r}=e();!r&&n?t({showActivateTabModal:!0}):(r||!n)&&o()},setShowActivateTabModal:o=>{t({showActivateTabModal:o})},setWatermark:o=>{t({watermark:o})}}))),lo=new cn({onInit:()=>se.setState({tabManagerInitiated:!0}),onClaim:()=>se.setState({isActiveTab:!0,showActivateTabModal:!1}),onRelease:()=>se.setState({isActiveTab:!1})});function J(t){let{watermark:e}=se();return Py.createElement(By,{hasWatermark:e==="FULL",...t},t.children)}i(J,"WatermarkedModal");import{i18n as Ca}from"@lingui/core";import{Button as Uy,Checkbox as zy,Divider as Qy,Image as yc,ListItemButton as qy,MessageBox as Hy,Radio as Gy,RadioRoot as Vy}from"@rango-dev/ui";import{namespaces as Sc}from"@rango-dev/wallets-shared";import we,{useMemo as Ky,useState as jy}from"react";import{css as Dy,darkTheme as pc,IconButton as _y,styled as po}from"@rango-dev/ui";var It=po(_y,{width:"$24",position:"relative",padding:"0",overflow:"unset","&:hover":{backgroundColor:"$secondary100",[`.${pc} &`]:{backgroundColor:"$neutral"}}}),cc=po("div",{position:"absolute",background:"$secondary500",[`.${pc} &`]:{$$color:"$colors$secondary250"},width:"$6",height:"$6",borderRadius:"$lg",right:"$4",border:"1px solid $surface100"}),Vt=po("div",{display:"flex",justifyContent:"flex-end",minWidth:"$40",button:{padding:0}}),uc=po("div",{position:"absolute",width:"14px",height:"14px",display:"flex",justifyContent:"center",alignItems:"center",borderRadius:"7px",top:"$0",right:"$0",variants:{isSever:{true:{backgroundColor:"$error500"},false:{backgroundColor:"$secondary500"}}}}),mc=po("div",{padding:"$2",variants:{isRefetched:{true:{transform:"rotate(360deg)",transition:"transform 1s ease-in-out"}}}}),dc=po("div",{position:"absolute",right:"$4",top:"$4",backgroundColor:"$background",borderRadius:"100%"}),fc=Dy({display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center"}),kr=po("div",{borderRadius:"100%",border:"1.5px transparent solid","&:not(:first-child)":{marginLeft:"-$6"},img:{borderRadius:"100%"}});import{keyframes as $y,styled as Tr}from"@rango-dev/ui";var bA=Tr("div",{borderRadius:"$lg",width:"$45",height:"$45",backgroundColor:"$success300",display:"flex",justifyContent:"center",alignItems:"center"}),Bo=Tr("div",{position:"relative"}),Fy=$y({"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:`${Fy} 1s linear infinite`,top:0,bottom:0,right:0,left:0}),vr=Tr("div",{"& img":{borderRadius:"50%"}});function gc(t,e){return t.find(o=>o.name===e)?.logo}i(gc,"getBlockchainLogo");import{styled as Oy}from"@rango-dev/ui";var hc=Oy("ul",{padding:0,paddingTop:"$4",paddingBottom:"$4"});function un(t){let{singleNamespace:e,availableNamespaces:o,providerImage:n}=t.value,[r,a]=jy([]),s=y().blockchains(),l=Ky(()=>o?.map(c=>({name:c,logo:gc(s,Sc[c].mainBlockchain),title:Sc[c].title})),[o]),p=i(c=>{a(e?[c]:m=>m.includes(c)?m.filter(f=>f!==c):m.concat(c))},"onSelect"),u=i(c=>e?we.createElement(Vy,{value:r?.[0]},c):we.createElement(we.Fragment,null,c),"wrapRadioRoot");return we.createElement(we.Fragment,null,we.createElement(Qy,{size:20}),we.createElement(Hy,{type:"info",title:Ca.t("Select chain types"),description:Ca.t("This wallet supports multiple chains. Select which chain you'd like to connect to."),icon:we.createElement(Bo,null,we.createElement(kr,null,we.createElement(yc,{src:n,size:45})),we.createElement(Po,null))}),we.createElement(hc,null,u(we.createElement(we.Fragment,null,l?.map(c=>we.createElement(qy,{key:c.name,id:c.name,title:c.title,hasDivider:!0,style:{height:60},onClick:()=>p(c.name),start:we.createElement(yc,{src:c.logo,size:22}),end:e?we.createElement(Gy,{value:c.name}):we.createElement(zy,{checked:r.includes(c.name)})}))))),we.createElement(Uy,{id:"widget-name-space-confirm-btn",type:"primary",disabled:!r.length,onClick:()=>t.onConfirm(r)},Ca.t("Confirm")))}i(un,"Namespaces");import{i18n as Do}from"@lingui/core";import{Button as Zy,Divider as Tc,Image as Jy,MessageBox as Ry,Select as eS,TextField as tS}from"@rango-dev/ui";import ze,{useEffect as oS,useState as vc}from"react";import{namespaces as Xy}from"@rango-dev/wallets-shared";var wr={id:"custom",label:"Custom",generateDerivationPath:t=>t};function ka(t){let e=t?Xy[t].derivationPaths:null;return e?[...e,wr]:[]}i(ka,"getDerivationPaths");import{styled as Cc,Typography as Yy}from"@rango-dev/ui";var kc=Cc("div",{paddingTop:"$30",paddingBottom:"$30",zIndex:10}),Ta=Cc(Yy,{paddingLeft:"$10"}),va={height:"$40",backgroundColor:"$neutral200",borderRadius:"$sm"};var wc="0";function mn(t){let{onConfirm:e}=t,{namespace:o,providerImage:n,providerType:r}=t.value,[a,s]=vc(null),[l,p]=vc(wc),u=a===wr.id,c=ka(o),m=i(({value:g})=>{let d=c?.find(h=>h.id===g);d&&(a===wr.id&&Number.isNaN(Number(l))&&p(wc),s(d.id))},"handleDerivationPathItemClick"),f=i(()=>{let g=c.find(d=>d.id===a);if(g)e(g.generateDerivationPath(l));else throw new Error("selectedDerivationPath can not be undefined")},"handleConfirm");return oS(()=>{s(ka(o)[0]?.id||null)},[o]),ze.createElement(ze.Fragment,null,ze.createElement(Tc,{size:20}),ze.createElement(Ry,{type:"info",title:Do.t("Select Derivation Path"),description:Do.t({id:"In order to connect to {type}, you must first select a Derivation Path",values:{type:r}}),icon:ze.createElement(Bo,null,ze.createElement(vr,null,ze.createElement(Jy,{src:n,size:45})),ze.createElement(Po,null))}),ze.createElement(kc,null,ze.createElement(Ta,{variant:"body",size:"xsmall",color:"$neutral600"},Do.t("Choose Derivation Path Template")),ze.createElement(eS,{value:a||"",options:c.map(g=>({value:g.id,label:g.label})),variant:"filled",handleItemClick:m,styles:{trigger:va}}),ze.createElement(Tc,{size:20}),ze.createElement(Ta,{variant:"body",size:"xsmall",color:"$neutral600"},u?Do.t("Enter Path"):Do.t("Enter Index")),ze.createElement(tS,{type:u?"text":"number",variant:"contained",value:l,onChange:g=>p(g.target.value),style:va})),ze.createElement(Zy,{id:"widget-derivation-path-confirm-btn",type:"primary",onClick:f,disabled:!c||!a||!l},Do.t("Confirm")))}i(mn,"DerivationPath");import{i18n as _o}from"@lingui/core";import{Image as nS,MessageBox as wa,WalletState as rS}from"@rango-dev/ui";import{useWallets as iS}from"@rango-dev/wallets-react";import co from"react";function xa(t){let{wallet:e,error:o}=t,{type:n,image:r}=e,{state:a}=iS();return pn(a(n))===rS.CONNECTED?co.createElement(wa,{type:"success",title:_o.t("Wallet Connected"),description:_o.t("Your wallet is connected, you can use it to swap.")}):o?co.createElement(wa,{type:"error",title:_o.t("Failed to Connect"),description:o||_o.t("Your wallet is not connected. Please try again.")}):co.createElement(wa,{type:"loading",title:_o.t("Connecting to your wallet"),description:_o.t("Click connect in your wallet popup."),icon:co.createElement(Bo,null,co.createElement(vr,null,co.createElement(nS,{src:r,size:45})),co.createElement(Po,null))})}i(xa,"ConnectStatus");import{i18n as ba}from"@lingui/core";import{Button as aS,Divider as xc,MessageBox as sS}from"@rango-dev/ui";import xr from"react";function Ea(t){let{displayName:e,onConfirm:o}=t;return xr.createElement(sS,{title:ba.t({id:"Add {blockchainDisplayName} Chain",values:{blockchainDisplayName:e}}),type:"warning",description:ba.t({id:"Would you like to add the {blockchainDisplayName} experimental chain to your wallet?",values:{blockchainDisplayName:e}})},xr.createElement(xc,{size:18}),xr.createElement(xc,{size:32}),xr.createElement(aS,{id:"widget-experimental-chain-confirm-btn",onClick:o,variant:"outlined",type:"primary",fullWidth:!0,size:"large"},ba.t("Confirm")))}i(Ea,"ExperimentalChain");function bc(t,e){return t().status==="init"&&!!e}i(bc,"isOnStatus");function dn(t){return t().status==="namespace"}i(dn,"isOnNamespace");function fn(t){return t().status==="derivationPath"}i(fn,"isOnDerivationPath");var uS=3e3,mS=300;function mo(t){let e=cS(),[o,n]=Ec(!1),[r,a]=Ec(),s=i(S=>{a(S.message)},"catchErrorOnHandle"),{terminateConnectingWallets:l}=ft(),{handleConnect:p,handleDerivationPath:u,handleNamespace:c,getState:m,resetState:f}=Ht(),g=i(S=>{c(t.wallet,S).catch(s)},"handleConfirmNamespaces"),d=i(S=>{if(!S)throw new Error("Derivation path is empty. Please make sure you've filled the field correctly.");u(S).catch(s)},"handleDerivationPathConfirm"),h=i(()=>{n(!1)},"handleClosingModal"),k=i(()=>{a(void 0),f(),n(!1),e.current&&clearTimeout(e.current)},"resetModalState");return pS(()=>{if(t.wallet){k();let S=!1,C=!0,T=i(()=>{setTimeout(()=>{C=!1,S||n(!0)},mS)},"beforeConnecting"),v=i(w=>{let A=w.status==="connected",M=["disconnected","disconnected-unhandled"].includes(w.status);["namespace","derivation-path"].includes(w.status)||(S=!0),A&&!C?e.current=setTimeout(h,uS):M&&h(),t.onConnect&&t.onConnect(w)},"afterConnected");T(),p(t.wallet,{disconnectIfConnected:!0}).then(v).catch(s)}},[t.wallet]),uo.createElement(J,{open:o,onClose:h,onExit:()=>{k(),l(),t.onClose&&t.onClose()},container:N()},bc(m,t.wallet)&&uo.createElement(uo.Fragment,null,uo.createElement(xa,{wallet:{type:t.wallet.type,image:t.wallet.image},error:r}),uo.createElement(lS,{direction:"vertical",size:32})),dn(m)&&uo.createElement(un,{onConfirm:g,value:m().namespace}),fn(m)&&uo.createElement(mn,{onConfirm:d,value:m().derivationPath}))}i(mo,"StatefulConnectModal");import{Events as Aa,Provider as fS}from"@rango-dev/wallets-react";import{isEvmBlockchain as gS}from"rango-sdk";import br,{createContext as hS,useEffect as Ac,useMemo as yS,useRef as Nc}from"react";import{useEffect as dS}from"react";function Ic(t){return t.map(e=>typeof e=="string"?e:e.config.type).join("-")}i(Ic,"hashProviders");function Ia(t,e){let o=Z.use.clearConnectedWallet(),n=Cr(t,e);return dS(()=>{o(),n=Cr(t,e)},[Ic(t??[]),e?.walletConnectProjectId,e?.walletConnectListedDesktopWalletLink]),{providers:n}}i(Ia,"useWalletProviders");var Er=hS({onConnectWallet:()=>{},onDisconnectWallet:()=>{}});function SS(t){let{updateConfig:e,updateSettings:o,fetch:n,fetchStatus:r}=y(),a=y().blockchains(),{findToken:s}=y(),l=y().config,p={walletConnectProjectId:l?.walletConnectProjectId,trezorManifest:l?.trezorManifest,walletConnectListedDesktopWalletLink:t.config.__UNSTABLE_OR_INTERNAL__?.walletConnectListedDesktopWalletLink},{providers:u}=Ia(l.wallets,p),{connectWallet:c,disconnectWallet:m}=Z(),f=Nc(),g=Nc();Ac(()=>{n().catch(console.log)},[]),Ac(()=>{t.config&&(e(t.config),o(t.config),window.__rango={config:l,dappConfig:t.config})},[t.config,r]);let d=a.filter(gS).map(C=>C.name),h=i((C,T,v,w,A)=>{if(T===Aa.ACCOUNTS)if(v){let M=pr(A.supportedBlockchains),x=Wp(C,v,d,M,A.isContractWallet);x.length&&c(x,s)}else m(C),g.current?g.current(C):console.warn("onDisconnectWallet handler hasn't been set. Are you sure?");if(T===Aa.ACCOUNTS&&w.connected){let M=`${C}-${w.network}-${v}`;w.connected&&(f.current?f.current(M):console.warn("onConnectWallet handler hasn't been set. Are you sure?"))}if(T===Aa.NETWORK&&w.network){let M=`${C}-${w.network}`;f.current?f.current(M):console.warn("onConnectWallet handler hasn't been set. Are you sure?")}t.onUpdateState&&t.onUpdateState(C,T,v,w,A)},"onUpdateState"),k=se.use.isActiveTab(),S=yS(()=>({onConnectWallet:C=>{f.current=C},onDisconnectWallet:C=>{g.current=C}}),[]);return br.createElement(Er.Provider,{value:S},br.createElement(fS,{allBlockChains:a,providers:u,onUpdateState:h,autoConnect:!!k},t.children))}i(SS,"Main");function Ir(t){let{config:e,...o}=t;return br.createElement(rc,{config:e},br.createElement(SS,{...o,config:e}))}i(Ir,"WidgetWallets");import Ri from"react";import CS,{Fragment as kS}from"react";import{MemoryRouter as TS,useInRouterContext as vS}from"react-router";function Wc({children:t}){let o=vS()?kS:TS;return CS.createElement(o,null,t)}i(Wc,"AppRouter");import{I18nManager as eE}from"@rango-dev/ui";import rp from"react";import De from"react";import{useRoutes as Ub}from"react-router-dom";var D={home:"/",fromSwap:"from-swap",toSwap:"to-swap",blockchains:"blockchains",settings:"settings",customTokens:"custom-tokens",addCustomTokens:"add-custom-tokens",liquiditySources:"liquidity-sources",bridges:"bridges",exchanges:"exchanges",languages:"languages",swaps:"swaps",wallets:"wallets",confirmSwap:"confirm-swap",swapDetails:":requestId",routes:"routes"};import{useEffect as Oo,useRef as _r}from"react";import Xe from"bignumber.js";import{create as bS}from"zustand";import{subscribeWithSelector as ES}from"zustand/middleware";import{getLastSuccessfulStep as xS}from"@rango-dev/queue-manager-rango-preset";import BW from"bignumber.js";function Na(t,e){return{"Network Fee":e("Network Fee"),"Swapper Fee":e("Protocol Fee"),"Affiliate Fee":e("Affiliate Fee"),"Outbound network fee":e("Outbound Fee"),"Rango Fee":e("Rango Fee")}[t]}i(Na,"getFeeLabel");var Wa=["RECOMMENDED","CENTRALIZED","LOWEST_FEE","FASTEST","HIGH_IMPACT"],Mc=30;import{i18n as gt}from"@lingui/core";import{RouteEventType as SW}from"@rango-dev/queue-manager-rango-preset";import Qe from"bignumber.js";import{PendingSwapNetworkStatus as Nr}from"rango-types";import{i18n as Fe}from"@lingui/core";var te=i(()=>({genericServerError:Fe.t("Failed Network, Please retry your swap."),liquiditySourcesError:{title:Fe.t("Please reset your liquidity sources."),description:Fe.t("You have limited the liquidity sources and this might result in Rango finding no routes. Please consider resetting your liquidity sources.")},noResultError:{title:Fe.t("No Routes Found."),description:Fe.t("Reasons why Rango couldn't find a route: low liquidity on token, very low input amount or no routes available for the selected input/output token combination.")},bridgeLimitErrors:{increaseAmount:Fe.t("Bridge Limit Error: Please increase your amount."),decreaseAmount:Fe.t("Bridge Limit Error: Please decrease your amount.")},highValueLossError:{impactTitle:Fe.t("High Price Impact"),title:Fe.t("Price impact is too high!"),description:Fe.t("The price impact is significantly higher than the allowed amount."),confirmMessage:Fe.t("Confirm high price impact")},quoteUpdatedWithHighValueLoss:{title:Fe.t("Route updated and price impact is too high, try again later!")},unknownPriceError:{impactTitle:Fe.t("USD Price Unknown"),title:Fe.t("USD Price Unknown, Cannot calculate Price Impact."),description:Fe.t("USD Price Unknown, Cannot calculate Price Impact. The price impact may be higher than usual. Are you sure to continue the Swap?"),confirmMessage:Fe.t("Confirm USD Price Unknown")}}),"errorMessages");function Lc(t){switch(t.type){case 0:return t.diagnosisMessage??te().noResultError.title;case 1:return te().genericServerError;default:return""}}i(Lc,"getQuoteErrorMessage");import{i18n as Ar}from"@lingui/core";var fo=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 Bc(t,e){return(parseInt(e.toFixed(2)||"0")<=-10&&t?.gte(new Qe(400))||parseInt(e.toFixed(2)||"0")<=-5&&t?.gte(new Qe(1e3)))??!1}i(Bc,"hasHighValueLoss");function Pc(t){return(t||[]).filter(e=>{let o=e.fromAmountMinValue?new Qe(e.fromAmountMinValue):null,n=e.fromAmountMaxValue?new Qe(e.fromAmountMaxValue):null;return e.fromAmountRestrictionType==="EXCLUSIVE"?o?.gte(e.fromAmount)||n?.lte(e.fromAmount):o?.gt(e.fromAmount)||n?.lt(e.fromAmount)}).length>0}i(Pc,"hasLimitError");function Dc(t){let e=(t||[]).filter(l=>{let p=l.fromAmountMinValue?new Qe(l.fromAmountMinValue):null,u=l.fromAmountMaxValue?new Qe(l.fromAmountMaxValue):null;return l.fromAmountRestrictionType==="EXCLUSIVE"?p?.gte(l.fromAmount)||u?.lte(l.fromAmount):p?.gt(l.fromAmount)||u?.lt(l.fromAmount)})[0],o=e.fromAmountMinValue?new Qe(e.fromAmountMinValue):null,n=e.fromAmountMaxValue?new Qe(e.fromAmountMaxValue):null,r=e.fromAmountRestrictionType==="EXCLUSIVE",a="",s="";return!r&&o&&o.gt(e.fromAmount)?(a=gt.t({id:"Required: >= {min} {symbol}",values:{min:L(o,6,6),symbol:e.from.symbol}}),s=te().bridgeLimitErrors.increaseAmount):r&&o&&o.gte(e.fromAmount)&&(a=gt.t({id:"Required: > {min} {symbol}",values:{min:L(o,6,6),symbol:e.from.symbol}}),s=te().bridgeLimitErrors.increaseAmount),!r&&n&&n.lt(e.fromAmount)?(a=gt.t({id:"Required: <= {max} {symbol}",values:{max:L(n,6,6),symbol:e.from.symbol}}),s=te().bridgeLimitErrors.decreaseAmount):r&&n&&n.lte(e.fromAmount)&&(a=gt.t({id:"Required: < {max} {symbol}",values:{max:L(n,6,6),symbol:e.from.symbol}}),s=te().bridgeLimitErrors.decreaseAmount),{swap:e,fromAmountRangeError:a,recommendation:s}}i(Dc,"getLimitErrorMessage");function _c(t){let{fetchMetaStatus:e,anyWalletConnected:o,fetchingQuote:n,inputAmount:r,quote:a,warning:s,error:l,needsToWarnEthOnPath:p}=t;return e!=="success"?{title:fo().connectWallet,action:"connect-wallet",disabled:!0}:o?n||!a||l||!r||r==="0"?{title:fo().swap,action:"confirm-swap",disabled:!0}:s?{title:fo().swapAnyway,action:"confirm-warning",disabled:!1}:p?{title:fo().ethWarning,action:"confirm-warning",disabled:!1}:{title:fo().swap,action:"confirm-swap",disabled:!1}:{title:fo().connectWallet,action:"connect-wallet",disabled:!1}}i(_c,"getSwapButtonState");function Ma(t,e,o){let n=parseFloat(e||"0");return!(t&&(!o||o.lte(Ue))&&e&&e!=="0"&&n!==0)}i(Ma,"canComputePriceImpact");function La(t,e){let o=Ue;for(let n=0;n<t.fee.length;n++){let r=t.fee[n];if(r.expenseType==="DECREASE_FROM_OUTPUT")continue;let a=e(r.asset)?.usdPrice||null;o=o.plus(new Qe(r.amount).multipliedBy(a||0))}return o}i(La,"getUsdFeeOfStep");function Wr(t,e){return t.reduce((o,n)=>o.plus(La(n,e)),Ue)}i(Wr,"getTotalFeeInUsd");function Ba(t){let e=Ue;return e=e.plus(new Qe(t.amount).multipliedBy(t.price||0)),e}i(Ba,"getUsdFee");function $c(t){return t.reduce((e,o)=>e.plus(Ba(o)),Ue)}i($c,"getTotalFeesInUsd");function Fc(t){return t.reduce((e,o)=>{for(let n of o.fee){let r=n.name,a=n.expenseType!=="DECREASE_FROM_OUTPUT"?e.payable:e.nonePayable;a[r]=[...a[r]||[],n]}return e},{payable:{},nonePayable:{}})}i(Fc,"getFeesGroup");function Oc(t){let e=new Map;return t.forEach((o,n)=>{o.recommendedSlippage?.error&&e.set(n,o.recommendedSlippage.slippage)}),e.size>0?e:null}i(Oc,"checkSlippageErrors");function Uc(t,e){let o=new Map;return t?.swaps.forEach((n,r)=>{n.recommendedSlippage?.slippage&&parseFloat(n.recommendedSlippage.slippage)>e&&o.set(r,n.recommendedSlippage.slippage)}),o.size>0?o:null}i(Uc,"checkSlippageWarnings");function Mr(t){return t.map(o=>o.recommendedSlippage)?.map(o=>o?.slippage||"0")?.filter(o=>parseFloat(o)>0)?.sort((o,n)=>parseFloat(n)-parseFloat(o))?.find(()=>!0)||null}i(Mr,"getMinRequiredSlippage");function zc(t,e){return e?parseFloat(t)>=parseFloat(e):!0}i(zc,"hasProperSlippage");function Qc(t){let{fromToken:e,toToken:o,inputAmount:n,wallets:r,selectedWallets:a,disabledLiquiditySources:s,liquiditySources:l,excludeLiquiditySources:p,slippage:u,affiliateRef:c,affiliatePercent:m,affiliateWallets:f,destination:g,enableCentralizedSwappers:d}=t,h=a?.reduce((C,T)=>(C[T.chain]=T.address,C),{}),k=[];return r?.forEach(C=>{k.push({blockchain:C.chain,addresses:[C.address]})}),{amount:n.toString(),affiliateRef:c??void 0,affiliatePercent:m??void 0,affiliateWallets:f??void 0,from:{address:e.address,blockchain:e.blockchain,symbol:e.symbol},to:{address:o.address,blockchain:o.blockchain,symbol:o.symbol},connectedWallets:k,selectedWallets:h??{},slippage:u.toString(),...g&&{destination:g},...p&&{swapperGroups:s.concat(l??[]),swappersGroupsExclude:!0},...!p&&{swapperGroups:l?.filter(C=>!s.includes(C)),swappersGroupsExclude:!1},enableCentralizedSwappers:d}}i(Qc,"createQuoteRequestBody");function qc(t){return t.reduce((o,n)=>(o[n.chain]={address:n.address,walletType:n.walletType},o),{})}i(qc,"getWalletsForNewSwap");function $o(t){return t?.outputAmount||null}i($o,"getQuoteOutputAmount");function Hc(t,e){return new Qe(e).div(new Qe(t)).minus(1).multipliedBy(100).toNumber()}i(Hc,"getPercentageChange");function Gc(t,e){let o=$o(t),n=$o(e);if(!o||!n)return!1;let r=ct(o,n);return r?r<=-1:!0}i(Gc,"isOutputAmountChangedALot");function Vc(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=>Jc(s,n)||[]).filter(s=>!s.ok).map(s=>{let l=s.asset.symbol,p=L(new Qe(s.currentAmount.amount).shiftedBy(-s.currentAmount.decimals),8,8),u=L(new Qe(s.requiredAmount.amount).shiftedBy(-s.requiredAmount.decimals),8,8),c="";return s.reason==="FEE"&&(c=gt.t(" for network fee")),s.reason==="INPUT_ASSET"&&(c=gt.t(" for swap")),s.reason==="FEE_AND_INPUT_ASSET"&&(c=gt.t(" for input and network fee")),gt.t({id:"Needs \u2248 {requiredAmount} {symbol}{reason}, but you have {currentAmount} {symbol} in your {blockchain} wallet.",values:{requiredAmount:u,symbol:l,reason:c,currentAmount:p,blockchain:pt(s.asset.blockchain,o)}})})}i(Vc,"generateBalanceWarnings");function jt(t,e){return(t?new Qe(t):Ue).multipliedBy(e||0)}i(jt,"calcOutputUsdValue");function gn(t){return!!t&&t.networkStatus!==null&&t.networkStatus!==Nr.NetworkChanged}i(gn,"isNetworkStatusInWarningState");function Kc(t,e){let o="bellow button or",n=t.extraMessage,r=t.extraMessageDetail;if(t.networkStatusExtraMessageDetail?.includes(o)&&(t.networkStatusExtraMessageDetail=t.networkStatusExtraMessageDetail.replace(o,"")),gn(e))switch(n=t.networkStatusExtraMessage||"",r=t.networkStatusExtraMessageDetail||"",e?.networkStatus){case Nr.WaitingForConnectingWallet:n=n||gt.t("Waiting for connecting wallet");break;case Nr.WaitingForQueue:n=n||gt.t("Waiting for other running tasks to be finished");break;case Nr.WaitingForNetworkChange:n=n||gt.t("Waiting for changing wallet network");break;default:n=n||"";break}r=r||"",n=n||"";let s=n?.indexOf("code")!==-1&&n?.indexOf("reason")!==-1;return{shortMessage:n,detailedMessage:{content:r,long:s}}}i(Kc,"getSwapMessages");function jc(t){let e=null;if(t.status==="failed"){let o=t.steps.slice().reverse().filter(n=>n.status==="success")[0];o&&(e={blockchain:o.toBlockchain,symbol:o.toSymbol,outputAmount:o.outputAmount,address:o.toSymbolAddress})}return e}i(jc,"getLastConvertedTokenInFailedSwap");function Xc(t){return t.status==="failed"}i(Xc,"shouldRetrySwap");function Yc(t,e,o,n,r,a){if(!n||t)return!0;let s=io({filter:"all",quote:n}),l=io({filter:"required",quote:n}),p=s.every(m=>r.some(f=>f.chain===m)),u=l.every(m=>r.some(f=>f.chain===m)),c=o&&a?No(a,o):!1;return!e&&!p||e&&!o||e&&!!o&&(!c||!u)}i(Yc,"isConfirmSwapDisabled");function Zc(t,e){return t.blockchain===e.blockchain&&t.symbol===e.symbol&&t.address===e.address}i(Zc,"isTokensIdentical");function go(t){let e=t?.swaps||[];return e[e.length-1].to.usdPrice}i(go,"getQuoteToTokenUsdPrice");function hn(t){return(t?.swaps||[])[0].from.usdPrice}i(hn,"getQuoteFromTokenUsdPrice");function Pa(t,e){let o=t?.swaps||[],n=e?.swaps||[];return o.length!==n.length}i(Pa,"isNumberOfSwapsChanged");function Da(t,e){let o=t?.swaps.map(r=>r.swapperId)||[],n=e?.swaps.map(r=>r.swapperId)||[];return!pa(o,n)}i(Da,"isQuoteSwappersUpdated");function _a(t,e){let o=t?.swaps.map(r=>r.to.symbol)||[],n=e?.swaps.map(r=>r.to.symbol)||[];return!pa(o,n)}i(_a,"isQuoteInternalCoinsUpdated");function eu(t,e){return Pa(t,e)||Da(t,e)||_a(t,e)}i(eu,"isQuoteChanged");function Jc(t,e){if(e===null)return null;let o=e?.find(n=>n.blockchain===t.chain)?.wallets.find(n=>n.address?.toLowerCase()===t.address.toLowerCase());return o?o.requiredAssets:null}i(Jc,"getRequiredBalanceOfWallet");function Pt(t){let e;return t<=-3&&t>-10?e="low":t<=-10&&(e="high"),e}i(Pt,"getPriceImpactLevel");function Br(t,e,o){let n=t.steps[0],r=t.steps[t.steps.length-1],a=xS(t.steps),s={blockchain:r.toBlockchain,symbol:r.toSymbol,address:r.toSymbolAddress},l=nn(a?a.toBlockchain:n.fromBlockchain,e),p=nn(r.toBlockchain,e),u=o(a?{blockchain:l?.name??"",symbol:a.toSymbol,address:a.toSymbolAddress}:{blockchain:l?.name??"",symbol:n.fromSymbol,address:n.fromSymbolAddress}),c=o(s),m=a?a.outputAmount??"":t.inputAmount;return{fromBlockchain:l,fromToken:u,toBlockchain:p,toToken:c,inputAmount:m}}i(Br,"createRetryQuote");function Fo(t,e){let{fromToken:o,toToken:n,findToken:r,userSlippage:a}=e,s=jt(t.requestAmount,hn(t)||o?.usdPrice),l=jt(t.outputAmount,go(t)||n?.usdPrice);if(t&&s&&l){let c=ct(s.toString(),l.toString());if(!!c&&Bc(s,c)){let f=Wr(t?.swaps,r),g=Pt(c);return{type:0,inputUsdValue:s,outputUsdValue:l,priceImpact:c,totalFee:f,warningLevel:g}}}else if(t&&(!s||!l))return{type:1};let p=Mr(t.swaps),u=a>Jp;if(zc(e.userSlippage.toString(),p)){if(u&&parseFloat(p??"0")<a)return{type:3,slippage:a.toString()}}else return{type:2,recommendedSlippages:Uc(t,a),minRequiredSlippage:p};return null}i(Fo,"generateQuoteWarnings");function ct(t,e){let o=typeof e=="string"?parseFloat(e)<=0:!e?.gt(0),n=!t||!e||o?null:Hc(t.toString(),e.toString());return n&&n<0?n:null}i(ct,"getPriceImpact");var tu=i(t=>{let e=new Set,o=[];return t.forEach(n=>{e.has(n.from.chain.displayName)||(e.add(n.from.chain.displayName),o.push(n.from.chain)),e.has(n.to.chain.displayName)||(e.add(n.to.chain.displayName),o.push(n.to.chain))}),o},"getUniqueBlockchains"),Pr=i((t,e)=>e.sort((o,n)=>{let r=i(u=>u.scores?.find(c=>c.preferenceType===t)?.score??0,"getScore"),a=r(o),s=r(n);if(a!==s)return s-a;let l=o.requestId.toLowerCase(),p=n.requestId.toLowerCase();return l.localeCompare(p)}),"sortQuotesBy"),ou=i((t,e,o)=>{if(!e.length)return null;if(!t)return{requestAmount:o,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"),nu=i(t=>{let e=i((o,n)=>{let r=Wa.indexOf(o.value),a=Wa.indexOf(n.value);return r!==-1&&a!==-1?r-a:r!==-1?-1:a!==-1?1:0},"customSort");return t.sort(e)},"sortTags");var Dr=i((t,e)=>t?.usdPrice?new Xe(e||Ue).multipliedBy(t?.usdPrice||0):null,"getUsdValue"),z=Gt(bS()(ES(t=>({fromBlockchain:null,fromToken:null,inputAmount:"",outputAmount:null,inputUsdValue:new Xe(0),outputUsdValue:new Xe(0),toBlockchain:null,toToken:null,refetchQuote:!0,sortStrategy:"SMART",selectedQuote:null,quotes:null,error:null,warning:null,quoteWalletsConfirmed:!1,selectedWallets:[],customDestination:null,quoteWarningsConfirmed:!1,updateQuotePartialState:(e,o)=>t(n=>({...n,[e]:o})),setSelectedQuote:e=>t(o=>{let n=null,r=Ue,a=o.inputUsdValue;return ln(o.inputAmount)?(e&&(n=e?.outputAmount?new Xe(e?.outputAmount):null,a=jt(o.inputAmount,hn(e)||o.fromToken?.usdPrice),r=jt(e.outputAmount,go(e)||o.toToken?.usdPrice)),{selectedQuote:e,...!!e&&{outputAmount:n,outputUsdValue:r,inputUsdValue:a}}):{}}),resetAlerts:()=>t(()=>({error:null,warning:null})),resetQuote:()=>t(()=>({selectedQuote:null,outputAmount:null,outputUsdValue:new Xe(0),quotes:null,refetchQuote:!0,error:null,warning:null})),setFromBlockchain:e=>{t(o=>o.fromBlockchain?.name===e?.name?{}:{fromBlockchain:e,inputUsdValue:new Xe(0),...o.fromToken&&{selectedQuote:null,fromToken:null,outputAmount:null,outputUsdValue:new Xe(0)}})},setFromToken:e=>t(o=>({fromToken:e.token,...e.token&&{fromBlockchain:e.meta.blockchains.find(n=>n.name===e.token.blockchain)??null},...!!o.inputAmount&&{inputUsdValue:Dr(e.token,o.inputAmount)}})),setToBlockchain:e=>{t(o=>o.toBlockchain?.name===e?.name?{}:{toBlockchain:e,...o.toToken&&{selectedQuote:null,toToken:null,outputAmount:null,outputUsdValue:new Xe(0)}})},setToToken:e=>t(()=>({toToken:e.token,...e.token&&{toBlockchain:e.meta.blockchains.find(o=>o.name===e.token.blockchain)??null}})),setInputAmount:e=>{t(o=>({inputAmount:e,...!e&&{outputAmount:null,outputUsdValue:new Xe(0),selectedQuote:null},...!!o.fromToken&&{inputUsdValue:Dr(o.fromToken,e)}}))},retry:e=>{let{fromBlockchain:o,fromToken:n,toBlockchain:r,toToken:a,inputAmount:s}=e;t({fromBlockchain:o,fromToken:n,inputAmount:s,outputAmount:null,inputUsdValue:Dr(n??null,s),outputUsdValue:new Xe(0),toBlockchain:r,toToken:a,selectedQuote:null})},switchFromAndTo:()=>t(e=>({fromBlockchain:e.toBlockchain,fromToken:e.toToken,toBlockchain:e.fromBlockchain,toToken:e.fromToken,inputAmount:e.outputAmount?.toString()||"",inputUsdValue:e.toToken?Dr(e.toToken,e.outputAmount?.toString()||""):new Xe(0)})),resetFromBlockchain:()=>t(()=>({fromToken:null,fromBlockchain:null,outputUsdValue:new Xe(0),inputUsdValue:new Xe(0),inputAmount:"",outputAmount:null,selectedQuote:null})),resetToBlockchain:()=>t(()=>({toToken:null,toBlockchain:null,outputAmount:null,outputUsdValue:new Xe(0),selectedQuote:null})),setQuoteWalletConfirmed:e=>t({quoteWalletsConfirmed:e}),setSelectedWallets:e=>t({selectedWallets:e}),setCustomDestination:e=>t({customDestination:e}),resetQuoteWallets:()=>t({quoteWalletsConfirmed:!1,selectedWallets:[],customDestination:null}),setQuoteWarningsConfirmed:e=>t({quoteWarningsConfirmed:e})})))),ru=z.subscribe((t,e)=>{(t.fromBlockchain!==e.fromBlockchain||t.fromToken!==e.fromToken||t.toBlockchain!==e.toBlockchain||t.toToken!==e.toToken||t.inputAmount!==e.inputAmount)&&ye.emit("quoteEvent",{type:"quoteInputUpdate",payload:{fromBlockchain:t.fromBlockchain?.name,toBlockchain:t.toBlockchain?.name,fromToken:t.fromToken?{symbol:t.fromToken.symbol,name:t.fromToken.name,address:t.fromToken.address}:void 0,toToken:t.toToken?{symbol:t.toToken.symbol,name:t.toToken.name,address:t.toToken.address}:void 0,requestAmount:t.inputAmount}}),t.selectedQuote?.requestId!==e.selectedQuote?.requestId&&ye.emit("quoteEvent",{type:"quoteOutputUpdate",payload:t.selectedQuote?{requestAmount:t.selectedQuote.requestAmount,swaps:t.selectedQuote.swaps,outputAmount:t.selectedQuote.outputAmount,resultType:t.selectedQuote.resultType,tags:t.selectedQuote.tags}:null})});function iu(){let{setInputAmount:t,setToToken:e,setToBlockchain:o,setFromBlockchain:n,resetQuote:r,setFromToken:a,fromToken:s,toToken:l,fromBlockchain:p,toBlockchain:u}=z(),c=y().config,m=y().fetchStatus,f=y().blockchains(),g=y().tokens(),{findToken:d}=y(),{setAffiliateRef:h,setAffiliatePercent:k,setAffiliateWallets:S}=y(),C=c?.from?.tokens,T=c?.from?.blockchains,v=c?.to?.tokens,w=c?.to?.blockchains,A=_r(void 0),M=_r(void 0),x=_r(void 0),E=_r(void 0);Oo(()=>{typeof c.amount<"u"&&t(c.amount.toString())},[c?.amount]),Oo(()=>{if(m==="success"){r();let b=f.find(I=>I.name===c?.from?.blockchain),W=c?.from?.token,$=W&&d(W);(b||!b&&x.current)&&n(b??null),$?a({token:$,meta:{blockchains:f,tokens:g}}):!$&&A.current&&a({token:null}),x.current=c?.from?.blockchain,A.current=c?.from?.token}},[c?.from?.token?.symbol,c?.from?.token?.address,c?.from?.token?.blockchain,c?.from?.blockchain,m]),Oo(()=>{da(s,C)&&a({token:null}),fa(p,T)&&n(null)},[C,T]),Oo(()=>{da(l,v)&&a({token:null}),fa(u,w)&&o(null)},[v,w]),Oo(()=>{if(m==="success"){r();let b=f.find(I=>I.name===c?.to?.blockchain),W=c?.to?.token,$=W&&d(W);(b||!b&&E.current)&&o(b??null),$?e({token:$,meta:{blockchains:f,tokens:g}}):!$&&M.current&&e({token:null}),E.current=c?.to?.blockchain,M.current=c?.to?.token}},[c?.to?.token?.symbol,c?.to?.token?.address,c?.to?.token?.blockchain,c?.to?.blockchain,m]),Oo(()=>{h(c?.affiliate?.ref??null),k(c?.affiliate?.percent??null),S(c?.affiliate?.wallets??null)},[c?.affiliate?.ref,c?.affiliate?.percent,c?.affiliate?.wallets])}i(iu,"useSyncStoresWithConfig");import{useEffect as Oa,useRef as IS}from"react";import{useInRouterContext as AS,useLocation as NS,useSearchParams as WS}from"react-router-dom";function $a(t,e){let o=t.split("--");return{blockchain:e.name,address:o?.[1]||null,symbol:o[0]}}i($a,"convertTokenSearchParamToAsset");function Fa(t){if(t)return`${t.symbol}${t.address?`--${t.address}`:""}`}i(Fa,"tokenToSearchParam");function za(){let t=NS(),[e,o]=WS(),{fromBlockchain:n,toBlockchain:r,fromToken:a,toToken:s,inputAmount:l,setFromBlockchain:p,setToBlockchain:u,setFromToken:c,setToToken:m,setInputAmount:f}=z(),g=y().fetchStatus,d=y().blockchains(),h=y().tokens(),k=AS(),{updateIframe:S,updateCampaignMode:C}=y(),T=y().isInCampaignMode(),v=IS(),{findToken:w}=y(),A=i(()=>{let x={};for(let[V,le]of e.entries())V.startsWith("utm_")&&(x[V]=le);let E=e.get("fromAmount"),b=e.get("fromBlockchain"),W=e.get("fromToken"),$=e.get("toBlockchain"),I=e.get("toToken"),R=e.get("autoConnect"),ee=e.get("clientUrl"),oe=e.get("liquiditySources"),B=e.get("blockchain");return{fromAmount:E,fromBlockchain:b,fromToken:W,toBlockchain:$,toToken:I,autoConnect:R,clientUrl:ee,liquiditySources:oe,utmQueryParams:x,blockchain:B}},"getUrlSearchParams"),M=i(x=>{for(let E in x)x[E]||delete x[E];o(x,{replace:!0})},"updateUrlSearchParams");Oa(()=>{let{autoConnect:x,clientUrl:E,utmQueryParams:b,blockchain:W}=A();k&&g==="success"&&M({fromBlockchain:n?.name,fromToken:Fa(a),toBlockchain:r?.name,toToken:Fa(s),fromAmount:l,autoConnect:x??void 0,clientUrl:E??void 0,blockchain:W??void 0,liquiditySources:T?v.current:void 0,...b})},[t.pathname,l,n,a,r,s,T]),Oa(()=>{if(!k)return;let x=A();if(!v.current&&x.liquiditySources&&(v.current=x.liquiditySources),x.fromAmount&&f(x.fromAmount),g==="success"){let E=d.find(I=>I.name===x.fromBlockchain),b=x.fromToken&&E?w($a(x.fromToken,E)):void 0,W=d.find(I=>I.name===x.toBlockchain),$=x.toToken&&W?w($a(x.toToken,W)):void 0;E&&(p(E),b&&c({token:b,meta:{blockchains:d,tokens:h}})),W&&(u(W),$&&m({token:$,meta:{blockchains:d,tokens:h}}))}},[g]),Oa(()=>{let{clientUrl:x,liquiditySources:E}=A();S("clientUrl",x||void 0),C("liquiditySources",E?.split(",")??void 0)},[])}i(za,"useSyncUrlAndStore");import{i18n as At}from"@lingui/core";import{Alert as HC,Button as Ou,darkTheme as GC,Divider as Cn,DoneIcon as VC,MessageBox as KC,styled as jC,TextField as XC,Typography as YC}from"@rango-dev/ui";import Se,{useEffect as ZC,useState as qr}from"react";import{useNavigate as JC,useSearchParams as RC}from"react-router-dom";import{ChevronRightIcon as MS,Divider as cu,Image as LS,Typography as uu}from"@rango-dev/ui";import ht from"react";import{darkTheme as au,styled as Qa}from"@rango-dev/ui";var su=Qa("div",{display:"flex",justifyContent:"space-between",width:"100%",height:"$40",padding:"$4 $10",borderRadius:"$sm",cursor:"pointer",alignItems:"center",backgroundColor:"$neutral300",[`.${au} &`]:{backgroundColor:"$neutral400"},"&:hover":{backgroundColor:"$secondary100",[`.${au} &`]:{backgroundColor:"$neutral500"}},variants:{disabled:{true:{cursor:"default","&:hover":{borderColor:"$neutral300","& svg":{color:"$neutral700"}}}}}}),lu=Qa("div",{display:"flex",flexDirection:"column",width:"100%",".title_typography":{textTransform:"capitalize"}}),pu=Qa("div",{display:"flex"});function qa(t){let{onClick:e,value:o,title:n,hasLogo:r,placeholder:a,disabled:s}=t;return ht.createElement(lu,null,ht.createElement(uu,{size:"large",variant:"label"},n),ht.createElement(cu,{size:10}),ht.createElement(su,{onClick:s?void 0:e,disabled:s},ht.createElement(pu,null,r&&ht.createElement(ht.Fragment,null,ht.createElement(LS,{src:o?.logo,size:16,useAsPlaceholder:!o?.logo,type:"circular"}),ht.createElement(cu,{size:4,direction:"horizontal"})),ht.createElement(uu,{className:"title_typography",size:"medium",variant:"label"},o?.name||a)),ht.createElement(MS,{size:12,color:"black"})))}i(qa,"BlockchainSelectorButton");import{i18n as Ga}from"@lingui/core";import{Button as BS,Divider as yn,ExternalLinkIcon as PS,Image as DS,Typography as zo}from"@rango-dev/ui";import We from"react";function mu(t,e){if(e.type==="COSMOS")return"";let o=e.info?.addressUrl;return!o||!t?"":o.replace("{wallet}",t)}i(mu,"generateExplorerLink");import{darkTheme as Uo,styled as du}from"@rango-dev/ui";var Ha=du("a",{textDecoration:"none",color:"$colors$neutral700",[`.${Uo} &`]:{color:"$colors$neutral900"},"& svg":{marginLeft:"$4",color:"$colors$neutral700",[`.${Uo} &`]:{color:"$colors$neutral900"}},variants:{hasHover:{true:{"&:hover":{color:"$colors$secondary550",[`.${Uo} &`]:{color:"$colors$secondary500"},"& svg":{color:"$colors$secondary550",[`.${Uo} &`]:{color:"$colors$secondary500"}}}},false:{}}}}),fu=du("div",{display:"flex",justifyContent:"center",flexDirection:"column",alignItems:"center",textAlign:"center","& ._blockchain-name, & ._coin-source":{color:"$colors$neutral600",[`.${Uo} &`]:{color:"$colors$neutral800"}},"& ._coin-source-name, & ._custom-token-description":{color:"$colors$neutral700",[`.${Uo} &`]:{color:"$colors$neutral900"}}});function Va(t){let{open:e,onClose:o,token:n,onSubmitClick:r,blockchain:a}=t,s=mu(n.address,a);return We.createElement(J,{open:e,dismissible:!0,onClose:o,container:N()},We.createElement(fu,null,We.createElement(DS,{src:n.image,size:45,type:"circular"}),We.createElement(zo,{variant:"title",size:"medium"},n.name),We.createElement(zo,{variant:"body",size:"small",className:"_blockchain-name"},a.displayName),We.createElement(yn,{size:4}),We.createElement(zo,{variant:"body",size:"medium"},s?We.createElement(Ha,{hasHover:!0,href:s,target:"_blank",rel:"nofollow noreferrer"},n.address,We.createElement(PS,{size:12,color:"gray"})):We.createElement(Ha,null,n.address)),We.createElement(yn,{size:4}),n.coinSource&&We.createElement(zo,{className:"_coin-source",variant:"body",size:"xsmall"},Ga.t("via")," ",We.createElement(zo,{className:"_coin-source-name",variant:"body",size:"xsmall"},n.coinSource)),We.createElement(yn,{size:"32"}),We.createElement(zo,{size:"medium",variant:"body",className:"_custom-token-description"},Ga.t("This token doesn't appear on the active token list(s). Make sure this is the token that you want to trade."))),We.createElement(yn,{size:40}),We.createElement(yn,{size:10}),We.createElement(BS,{id:"widget-custom-token-modal-import-btn",variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:r},Ga.t("Import")))}i(Va,"CustomTokenModal");import{useManager as FC}from"@rango-dev/queue-manager-react";import{BottomLogo as OC,Divider as Pu,Header as UC}from"@rango-dev/ui";import Le,{useEffect as fs,useRef as Du,useState as zC}from"react";import{useRef as _S}from"react";function $r(){return window.self!==window.top}i($r,"isAppLoadedIntoIframe");function Ka(){let t=_S(null),{iframe:e}=y(),o=$r()&&e.clientUrl,n=i(s=>{o&&window.top?.postMessage(s,e.clientUrl)},"send");return{send:n,connectHeightObserver:i(s=>{t.current=new ResizeObserver(l=>{for(let p of l)n({type:"widget_height",data:{height:p.contentRect.height}})}),t.current.observe(s)},"connectHeightObserver"),disconnectHeightObserver:i(()=>{t.current&&(t.current.disconnect(),t.current=null)},"disconnectHeightObserver")}}i(Ka,"useIframe");import{useNavigate as $S}from"react-router-dom";function Ye(){let t=$S();return()=>t(-1)}i(Ye,"useNavigateBack");import{createTheme as es,darkTheme as ZS,lightTheme as JS}from"@rango-dev/ui";import{useEffect as RS,useState as eC}from"react";import{theme as XS,darkColors as YS}from"@rango-dev/ui";import Ja from"react";function FS(t){return t.startsWith("#")&&(t=t.slice(1)),t.length===3?`#${t.split("").reduce(function(n,r){return n+r+r},"")}`:`#${t}`}i(FS,"expandShortHexColor");function OS(t){return/[0-9]+$/.test(t)}i(OS,"isOverridingColor");function US(t,e){return t.padStart(e,"0")}i(US,"pad");function ja(t){let e=Math.min(Math.max(Math.round(t),0),255);return US(e.toString(16),2)}i(ja,"intToHex");function zS(t){return`#${ja(t.red)}${ja(t.green)}${ja(t.blue)}`}i(zS,"rgbToHex");function QS(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(QS,"hexToRGB");function qS(t,e){let o=1-.11*e;return{red:t.red*o,green:t.green*o,blue:t.blue*o}}i(qS,"generateShade");function HS(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(HS,"generateTint");function GS(t){return gu(t,qS)}i(GS,"calculateShades");function VS(t){return gu(t,HS)}i(VS,"calculateTints");function gu(t,e){let o=QS(t),n=[];for(let r=1;r<9;r++)n.push(zS(e(o,r)));return n}i(gu,"calculateColors");function Xa(t,e,o){let a=VS(t).reverse().concat(t),s=GS(t),l=a.concat(s),p={},u=l.length;for(let c=0;c<u;c++){let m=100+(o?u-1-c:c)*50;p[`${e}${m}`]=l[c]}return p}i(Xa,"createTintsAndShades");function Ya(t,e,o){let n={...t};for(let r in e){let a=e[r],s=r==="neutral"&&!!o?.reverseNeutralRange;if(!["background","foreground"].includes(r)&&!OS(r)){let p=FS(a);Object.assign(n,Xa(p,r,s))}}return{...n,...e}}i(Ya,"expandToGenerateThemeColors");var hu=i(t=>String.fromCharCode(t+(t>25?39:97)),"toAlphabeticChar"),KS=i(t=>{let e="",o;for(o=Math.abs(t);o>52;o=o/52|0)e=hu(o%52)+e;return hu(o%52)+e},"toAlphabeticName"),jS=i((t,e)=>{let o=e.length;for(;o;)t=t*33^e.charCodeAt(--o);return t},"toPhash"),Za=i(t=>KS(jS(5381,JSON.stringify(t))>>>0),"toHash");function Ra(t){let e=XS.colors,o={...e,...YS},n,r;if(t?.light){let s={colors:Ya(e,t.light)};n={id:`${ma}-light-${Za(s)}`,tokens:s}}if(t?.dark){let s={colors:Ya(o,t.dark,{reverseNeutralRange:!0})};r={id:`${ma}-dark-${Za(s)}`,tokens:s}}return{light:n,dark:r}}i(Ra,"customizedThemeTokens");function yu(t,e){if(t.length<=1)return t.map(({element:n,key:r})=>Ja.cloneElement(n,{key:r}));let o=[];return t.forEach((n,r)=>{let{element:a,key:s}=n;if(o.push(Ja.cloneElement(a,{key:s})),r<t.length-1){let l=`divider-${r}`;o.push(Ja.cloneElement(e,{key:l}))}}),o}i(yu,"joinList");function Su(){return window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches}i(Su,"doesWindowPreferDarkColorScheme");function Qo(t){let{colors:e,fontFamily:o=yp,borderRadius:n=Qp,secondaryBorderRadius:r=qp}=t,[a,s]=eC(Su()?"dark":"light"),{theme:l}=y(),{dark:p,light:u}=Ra(e),c=es({shadows:t.shadows||{},radii:{primary:`${n}px`,secondary:`${r}px`},fonts:{widget:o}}),m=[c.className,JS.className],f=[c.className,ZS.className];if(u){let d=es(u.id,u.tokens);m.push(d.className)}if(p){let d=es(p.id,p.tokens);f.push(d.className)}return RS(()=>{let d=i(h=>{h.matches?s("dark"):s("light")},"switchThemeListener");return Su()&&s("dark"),window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",d),()=>{window.matchMedia("(prefers-color-scheme: dark)").removeEventListener("change",d)}},[]),{activeTheme:i(()=>{let d=m.join(" "),h=f.join(" ");return l==="auto"?a==="dark"?h:d:l==="dark"?h:d},"getActiveTheme"),mode:l==="auto"?a:l}}i(Qo,"useTheme");var ut=i(t=>{let e=[];return t?.getAll().forEach((o,n)=>{let r=o.list.getStorage();r?.swapDetails&&e.push({id:n,swap:r?.swapDetails})}),e.sort((o,n)=>Number(n.swap.creationTime)-Number(o.swap.creationTime))},"getPendingSwaps");import{i18n as Cu}from"@lingui/core";import{Alert as tC,Button as oC}from"@rango-dev/ui";import ku from"react";function ts(t){return ku.createElement(tC,{action:ku.createElement(oC,{id:"widget-active-tab-btn",onClick:t.onActivateTab,variant:"contained",size:"xxsmall",type:"warning"},Cu.t("Activate this tab")),type:"warning",variant:"alarm",title:Cu.t("Another tab is open and handles transactions.")})}i(ts,"ActivateTabAlert");import{i18n as os}from"@lingui/core";import{Button as nC,Divider as rC,MessageBox as iC}from"@rango-dev/ui";import Fr from"react";function ns(t){let{open:e,onClose:o,onConfirm:n}=t;return Fr.createElement(J,{open:e,dismissible:!0,onClose:o,container:N()},Fr.createElement(iC,{title:os.t("Activate current tab"),type:"warning",description:os.t("Currently, some transactions are running and being handled by other browser tab. If you activate this tab, all transactions that are already in the transaction sign step will expire.")},Fr.createElement(rC,{size:20}),Fr.createElement(nC,{id:"widget-modal-confirm-activate-tab-btn",variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:n},os.t("Confirm"))))}i(ns,"ActivateTabModal");import{ChevronLeftIcon as aC}from"@rango-dev/ui";import Tu from"react";function rs(t){return Tu.createElement(It,{id:"widget-header-back-icon-btn",variant:"ghost",size:"small",onClick:t.onClick},Tu.createElement(aC,{color:"black",size:16}))}i(rs,"BackButton");import{i18n as sC}from"@lingui/core";import{Button as lC,Typography as pC}from"@rango-dev/ui";import is from"react";function as(t){return is.createElement(Vt,null,is.createElement(lC,{id:"widget-header-cancel-btn",variant:"ghost",onClick:t.onClick,size:"xsmall"},is.createElement(pC,{variant:"label",size:"medium",color:"error500"},sC.t("Cancel"))))}i(as,"CancelButton");import{i18n as cC}from"@lingui/core";import{Image as uC,Tooltip as mC,WalletIcon as dC}from"@rango-dev/ui";import ho from"react";function ss(t){let{list:e}=ft(),o=e.filter(r=>r.state==="connected"),n=o.length?ho.createElement("div",{className:fc()},o.map(r=>ho.createElement(kr,{key:r.title},ho.createElement(uC,{src:r.image,size:14})))):cC.t("Connect Wallet");return ho.createElement(mC,{container:t.container,side:"bottom",content:n},ho.createElement(It,{id:"widget-header-wallet-icon-btn",variant:"ghost",size:"small",onClick:t.onClick},t.isConnected&&ho.createElement(cc,null),ho.createElement(dC,{size:18,color:"black"})))}i(ss,"WalletButton");import{i18n as Ur}from"@lingui/core";import{NotificationsIcon as NC,Popover as WC,SettingsIcon as MC,Tooltip as zr,TransactionIcon as LC}from"@rango-dev/ui";import Me from"react";import{Notifications as yC}from"@rango-dev/ui";import SC from"react";import{useNavigate as CC}from"react-router-dom";import{create as fC}from"zustand";import{persist as gC,subscribeWithSelector as hC}from"zustand/middleware";var xe=Gt(fC()(gC(hC((t,e)=>({isSynced:!1,notifications:[],setNotification:(o,n)=>{let r=n.steps[0],a=n.steps[n.steps.length-1],s={event:o,creationTime:Date.now(),requestId:n.requestId,route:{creationTime:parseInt(n.creationTime),from:{blockchain:r.fromBlockchain,address:r.fromSymbolAddress,symbol:r.fromSymbol},to:{blockchain:a.toBlockchain,address:a.toSymbolAddress,symbol:a.toSymbol}}},l=e().notifications.filter(p=>p.requestId!==n.requestId);t(()=>({notifications:[...l,s]}))},removeNotification:o=>{t(n=>({notifications:n.notifications.filter(r=>r.requestId!==o)}))},getNotifications:()=>{let{isSynced:o,notifications:n}=e();return o?n.sort((r,a)=>r.route.creationTime&&!a.route.creationTime?-1:!r.route.creationTime&&a.route.creationTime?1:!r.route.creationTime&&!a.route.creationTime?a.creationTime-r.creationTime:a.route.creationTime-r.route.creationTime):[]},syncNotifications:o=>{let{isSynced:n,notifications:r}=e();if(!n){let a=[];r.forEach(s=>{o.some(p=>p.swap.requestId===s.requestId)&&a.push(s)}),t({isSynced:!0,notifications:a})}},clearNotifications:()=>t({notifications:[]})})),{name:"notification",skipHydration:!0,partialize:({isSynced:t,...e})=>e,version:1,migrate:(t,e)=>{if(e===0){let o=t.notifications;t.notifications=o.filter(n=>!n.read).map(({read:n,...r})=>r)}return t}})));function ls(){let t=CC(),{getNotifications:e,clearNotifications:o}=xe(),n=e(),r=y().blockchains(),{findToken:a}=y();return SC.createElement(yC,{list:n,getBlockchainImage:l=>cp(l,r)??"",getTokenImage:l=>a(l)?.image??"",onClickItem:i(l=>{t(`${D.swaps}/${l}`)},"onClickItem"),onClearAll:o})}i(ls,"NotificationContent");import{useManager as kC}from"@rango-dev/queue-manager-react";import{InProgressIcon as TC}from"@rango-dev/ui";import vu from"react";var vC=i(()=>{let{manager:t}=kC();return ut(t).map(({swap:o})=>o).find(o=>o.status==="running")?vu.createElement(dc,null,vu.createElement(TC,{color:"info",size:6})):null},"InProgressTransactionBadge"),wu=vC;import{EventSeverity as wC}from"@rango-dev/queue-manager-rango-preset";import{Typography as xC}from"@rango-dev/ui";import xu from"react";function bu(){let{getNotifications:t}=xe(),e=t(),o=e.length,n=!!e.find(r=>r.event.messageSeverity===wC.WARNING);return o?xu.createElement(uc,{isSever:n},xu.createElement(xC,{variant:"body",size:"xsmall",color:"$background"},o)):null}i(bu,"NotificationsBadge");import{RefreshProgressButton as bC}from"@rango-dev/ui";import ps,{useEffect as EC,useState as Eu}from"react";var IC=1e3,Iu=60,AC=100;function Or({onClick:t}){let[e,o]=Eu(0),[n,r]=Eu(!1),a=i(p=>{document.hidden&&p&&s(p)},"handleVisibilityChange");EC(()=>{let p;return t?p=window.setInterval(()=>{o(u=>u+1),e===Iu&&l()},IC):s(p),document.addEventListener("visibilitychange",()=>a(p)),()=>{document.removeEventListener("visibilitychange",()=>a(p)),p&&clearInterval(p)}},[e,t]);let s=i(p=>{p&&clearInterval(p),o(0)},"clearTimeout"),l=i(()=>{t?.(),o(0),r(!0)},"handleRefreshClick");return ps.createElement(It,{id:"widget-header-refresh-icon-btn",variant:"ghost",size:"small",style:{paddingTop:0,paddingBottom:0},onClick:l,disabled:!t},ps.createElement(mc,{onTransitionEnd:()=>r(!1),isRefetched:n},ps.createElement(bC,{size:22,color:t?"black":"gray",progress:e/Iu*AC})))}i(Or,"RefreshButton");function yo(t){let{onClickRefresh:e,onClickHistory:o,onClickSettings:n,hidden:r=[],container:a}=t,{config:{features:s}}=y(),l=je("notification",s)||r.includes("notifications");return Me.createElement(Me.Fragment,null,!r.includes("refresh")&&Me.createElement(zr,{container:a||N(),side:"top",content:Ur.t("Refresh")},Me.createElement(Or,{onClick:e})),!l&&Me.createElement(WC,{align:"end",alignOffset:-88,sideOffset:15,collisionPadding:{right:20,left:20},container:N(),content:Me.createElement(ls,null)},Me.createElement("div",null,Me.createElement(zr,{container:N(),side:"top",content:Ur.t("Notifications")},Me.createElement(It,{id:"widget-header-notification-icon-btn",size:"small",variant:"ghost"},Me.createElement(NC,{size:18,color:"black"}),Me.createElement(bu,null))))),!r.includes("settings")&&Me.createElement(zr,{container:N(),side:"top",content:Ur.t("Settings")},Me.createElement(It,{id:"widget-header-setting-icon-btn",size:"small",variant:"ghost",onClick:n},Me.createElement(MC,{size:18,color:"black"}))),!r.includes("history")&&Me.createElement(zr,{container:N(),side:"top",content:Ur.t("History")},Me.createElement(It,{id:"widget-header-history-icon-btn",size:"small",variant:"ghost",onClick:o},Me.createElement(LC,{size:18,color:"black"}),Me.createElement(wu,null))))}i(yo,"HeaderButtons");import{i18n as cs}from"@lingui/core";import{Divider as Nu,MessageBox as DC,RefreshIcon as _C}from"@rango-dev/ui";import qo from"react";import{Button as BC,styled as PC}from"@rango-dev/ui";var Au=PC(BC,{"& span":{display:"flex",justifyContent:"center",alignItems:"center"}});function us(t){let{open:e,onClose:o}=t;return qo.createElement(J,{open:e,dismissible:!0,onClose:o,container:N()},qo.createElement(DC,{title:cs.t("Something went wrong"),type:"error",description:cs.t("Something went wrong. Please refresh the app.")},qo.createElement(Nu,{size:30}),qo.createElement(Au,{variant:"outlined",size:"large",type:"primary",fullWidth:!0,onClick:()=>location.reload()},qo.createElement(_C,{size:20,color:"primary"}),qo.createElement(Nu,{size:4,direction:"horizontal"}),cs.t("Refresh"))))}i(us,"RefreshModal");function ms(t){let e=t.target;if(e){let o=e.scrollTop,n=N();o>1?n.classList.add("rng-scrolled"):n.classList.remove("rng-scrolled")}}i(ms,"onScrollContentAttachStatusToContainer");import{css as $C,styled as ds}from"@rango-dev/ui";var Wu="700px",Qr=$C({borderRadius:"$primary",display:"flex",flexDirection:"column",overflow:"hidden",boxShadow:"$mainContainer"}),Mu=ds("div",{position:"relative",width:"100vw",minWidth:"300px",maxWidth:"390px",backgroundColor:"$background",variants:{height:{auto:{height:"auto",maxHeight:Wu},fixed:{height:Wu}}}}),Lu=ds("div",{position:"relative",overflow:"hidden",flexGrow:1,display:"flex",flexDirection:"column",padding:0,overflowY:"auto"}),Bu=ds("div",{padding:"0 $20 $10","& .footer__alert":{paddingTop:"$10"},"& .footer__logo":{opacity:0,transition:"opacity 1s ease-in-out","&.logo__show":{opacity:1},"&.logo__hidden":{visibility:"hidden"}}});function ne(t){let{connectHeightObserver:e,disconnectHeightObserver:o}=Ka(),{children:n,header:r,footer:a,height:s="fixed"}=t,{fetchStatus:l}=y(),[p,u]=zC(!1),c=Z.use.connectedWallets(),{config:{features:m,theme:f}}=y(),{watermark:g}=se(),d=g==="FULL",{activeTheme:h}=Qo(f||{}),k=je("connectWalletButton",m),{isActiveTab:S,tabManagerInitiated:C,showActivateTabModal:T,setShowActivateTabModal:v,activateCurrentTab:w}=se(),A=Ye(),{manager:M}=FC(),E=ut(M).map(({swap:ee})=>ee).some(ee=>ee.status==="running"),b=i(()=>w(lo.forceClaim,E),"onActivateTab"),W=i(()=>{r.onWallet?.()},"onConnectWallet"),$=typeof r.hasBackButton>"u"||r.hasBackButton,I=Du(null),R=Du(null);return fs(()=>($r()&&R.current&&e(R.current),()=>{o()}),[]),fs(()=>(I.current?.addEventListener("scroll",ms),()=>{I.current?.removeEventListener("scroll",ms)}),[]),fs(()=>{u(l==="failed")},[l]),Le.createElement(Mu,{height:s,id:$e.SWAP_BOX_ID,className:`${h()} ${Qr()}`,ref:R},Le.createElement(UC,{prefix:$?Le.createElement(rs,{onClick:()=>{A(),r.onBack&&r.onBack()}}):null,title:r.title,suffix:Le.createElement(Le.Fragment,null,r.suffix,r.onWallet&&!k&&Le.createElement(ss,{container:N(),onClick:W,isConnected:!!c?.length}),r.onCancel&&Le.createElement(as,{onClick:r.onCancel}))}),Le.createElement(Lu,{ref:I},n),Le.createElement(ns,{open:T,onClose:()=>v(!1),onConfirm:b}),Le.createElement(Bu,null,Le.createElement("div",{className:"footer__content"},C&&!S&&Le.createElement("div",{className:"footer__alert"},Le.createElement(ts,{onActivateTab:b}),Le.createElement(Pu,{size:10})),a),Le.createElement(Pu,{size:12}),Le.createElement("div",{className:`footer__logo ${d?"logo__show":"logo__hidden"}`},Le.createElement(OC,null))),Le.createElement(us,{open:p,onClose:()=>u(!1)}))}i(ne,"Layout");import{styled as QC}from"@rango-dev/ui";var _u="$20 $20 $10 $20",Sn=QC("div",{padding:_u,overflowY:"auto",flexGrow:1});import{styled as qC}from"@rango-dev/ui";var re=qC("div",{display:"flex",flexDirection:"column",padding:"20px 20px 10px",flexGrow:1,variants:{view:{true:{flexGrow:1,overflow:"hidden"}},compact:{true:{padding:0}}}});import{i18n as Ho}from"@lingui/core";import{useState as $u}from"react";function Fu(){let[t,e]=$u(!1),[o,n]=$u(void 0),{findToken:r}=y(),a=y().customTokens();function s(p,u){switch(p){case"duplicated":return{title:Ho.t("Duplicate Token"),message:Ho.t("The address you entered is duplicate, please enter a new address.")};case"token-exist":return{title:Ho.t("Token Already Exists"),message:Ho.t("There's no need to add this token again because it already exists and is supported by us.")};case"not-found":return{title:Ho.t("Token Not Found"),message:Ho.t({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:p,tokenAddress:u})=>{e(!0);try{if(a.some(d=>d.address?.toLowerCase()===u.toLowerCase())){let d=s("duplicated");n(d);return}let m=await Et().getCustomToken({blockchain:p,address:u});if(!m||!m.token||m.error){let d=s("not-found",p);n(d);return}let f=m.token;if(r({blockchain:f.blockchain,address:f.address,symbol:f.symbol})){let d=s("token-exist");n(d);return}return f}catch(c){throw n(void 0),new Error(c.message)}finally{e(!1)}},"fetchCustomToken"),loading:t,error:o}}i(Fu,"useFetchCustomToken");var ek=jC("div",{display:"flex",justifyContent:"space-between",flexDirection:"column",flex:1,"& ._text-field":{padding:"$4 $10",backgroundColor:"$neutral300",[`.${GC} &`]:{backgroundColor:"$neutral400"},borderRadius:"$sm",height:"$40"}}),tk=1e3;function Uu(){let t=JC(),[e]=RC(),o=Ye(),{setCustomToken:n}=y(),r=y().blockchains(),a=e.get("blockchain")||"",s=nn(a,r),[l,p]=qr(""),[u,c]=qr(!1),[m,f]=qr(),{fetchCustomToken:g,loading:d,error:h}=Fu(),[k,S]=qr(""),C=!!s&&No(s,l),T=!s||!l||!C,v=i(async()=>{if(s)try{let M=await g({blockchain:a,tokenAddress:l});S(""),M&&f(M)}catch(M){M.message==="Failed to fetch"&&(S(At.t("Network Error")),c(!0))}},"getCustomToken"),w=i(()=>{h&&p(""),c(!1)},"closeErrorModal"),A=i(async()=>{k&&setTimeout(async()=>{await v()},tk),w()},"handleErrorModalButtonClick");return ZC(()=>{h&&c(!0)},[h]),Se.createElement(ne,{header:{title:At.t("Add Custom Token")}},Se.createElement(re,null,Se.createElement(ek,null,Se.createElement("div",null,Se.createElement(qa,{onClick:()=>t(D.blockchains,{replace:!0}),hasLogo:!!s?.logo,value:s?{name:s.displayName,logo:s.logo}:void 0,title:At.t("Select chain"),placeholder:At.t("Select chain")}),Se.createElement(Cn,{size:"24"}),Se.createElement(YC,{size:"large",variant:"label"},At.t("Enter Address")),Se.createElement(Cn,{size:10}),Se.createElement(XC,{fullWidth:!0,disabled:!s,variant:"contained",placeholder:At.t("Enter token address"),size:"large",value:l,suffix:!!l&&C&&Se.createElement(VC,{color:"success",size:12}),onChange:M=>p(M.target.value)}),!C&&!!l&&Se.createElement(Se.Fragment,null,Se.createElement(Cn,{size:4}),Se.createElement(HC,{type:"error",variant:"alarm",title:"Invalid Address"}))),Se.createElement(Ou,{id:"widget-add-custom-token-import-btn",disabled:T,type:"primary",variant:"contained",loading:d,size:"large",onClick:v},At.t("Import"))),Se.createElement(J,{open:u,dismissible:!0,onClose:w,container:N()},Se.createElement(KC,{title:h?.title||k,type:"error",description:h?.message||At.t("Failed Network, Please retry.")},Se.createElement(Cn,{size:40}),Se.createElement(Cn,{size:10}),Se.createElement(Ou,{id:`widget-add-custom-token-${k?"retry":"add-another"}-btn`,variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:A},k?At.t("Retry"):At.t("Add another custom token")))),s&&m&&Se.createElement(Va,{blockchain:s,token:m,onSubmitClick:()=>{m&&(n(m),f(void 0),o())},onClose:()=>f(void 0),open:!!s&&!!m})))}i(Uu,"AddCustomTokenPage");import{i18n as qs}from"@lingui/core";import{useManager as FT}from"@rango-dev/queue-manager-react";import{Alert as _d,Button as OT,css as Gs,Divider as Hs,IconButton as $d,styled as UT,Typography as zT,WalletIcon as QT}from"@rango-dev/ui";import Ie,{useEffect as Ci,useLayoutEffect as qT,useRef as HT,useState as Ln}from"react";import{useNavigate as GT}from"react-router-dom";import{i18n as So}from"@lingui/core";import{Alert as fm,BalanceErrors as Ik,Button as gm,ChevronLeftIcon as Ak,Divider as Jr,MessageBox as Nk,Typography as vs}from"@rango-dev/ui";import j,{useCallback as Wk,useEffect as hm,useMemo as Mk,useState as Co}from"react";import{useNavigate as Lk}from"react-router-dom";import{i18n as Hr}from"@lingui/core";function Gr(t){switch(t.type){case 0:return Hr.t("Route has been updated.");case 3:return Hr.t("Output amount changed to {newOutputAmount} ({percentageChange}% change).",{newOutputAmount:t.newOutputAmount,percentageChange:t.percentageChange});case 1:return Hr.t("Route swappers has been updated.");case 2:return Hr.t("Route internal coins has been updated.");default:return""}}i(Gr,"getQuoteUpdateWarningMessage");import{i18n as Ss}from"@lingui/core";import{Alert as sk,ChevronDownIcon as lk,CloseIcon as pk,Divider as Ku,IconButton as ju,PasteIcon as ck,Typography as uk,WalletIcon as mk}from"@rango-dev/ui";import Be,{useEffect as dk,useRef as fk}from"react";import Xr,{useRef as ik}from"react";import*as Go from"@radix-ui/react-collapsible";import{keyframes as zu,styled as Vr}from"@rango-dev/ui";var gs=300,nk=zu({from:{height:0},to:{height:"var(--radix-collapsible-content-height)"}}),rk=zu({from:{height:"var(--radix-collapsible-content-height)"},to:{height:0}}),Qu=Vr(Go.Root,{borderRadius:"$sm",overflow:"hidden",variants:{selected:{true:{outlineWidth:1,outlineColor:"$secondary500",outlineStyle:"solid"}}}}),hs=Vr(Go.Trigger,{padding:"$0",border:"none",outline:"none",width:"100%",backgroundColor:"transparent",fontFamily:"inherit",cursor:"pointer"}),Kr=Vr(Go.Content,{overflow:"hidden",variants:{open:{true:{animation:`${nk} ${gs}ms ease-out`},false:{animation:`${rk} ${gs}ms ease-out`}}}}),jr=Vr("div",{transition:`all ${gs}ms ease`,display:"flex",alignItems:"center",variants:{orientation:{down:{transform:"rotate(0)"},up:{transform:"rotate(180deg)"}}}});function Yr(t){let{open:e,hasSelected:o,onOpenChange:n,children:r,onClickTrigger:a,trigger:s,triggerAnchor:l}=t,p=ik(null);return Xr.createElement(Qu,{ref:p,className:"collapsible_root",selected:o&&e,open:e,onOpenChange:n},l==="top"&&Xr.createElement(hs,{className:"collapsible_trigger",onClick:a},s),Xr.createElement(Kr,{className:"collapsible_content",open:e},r),l==="bottom"&&Xr.createElement(hs,{className:"collapsible_trigger",onClick:a},s))}i(Yr,"CustomCollapsible");import{darkTheme as qu,styled as ys,TextField as ak}from"@rango-dev/ui";var Hu=ys("div",{padding:"$10 $0","& .button__content":{display:"flex",alignItems:"center"},"& .alarms":{paddingTop:"$5"},"& .collapsible_content":{backgroundColor:"$neutral100"},"& .collapsible_root":{backgroundColor:"$neutral100"}}),Gu=ys(ak,{backgroundColor:"$neutral100",padding:"$15"}),Vu=ys("div",{width:"100%",borderRadius:"$sm",display:"flex",padding:"$15",justifyContent:"space-between",alignItems:"center",$$color:"$colors$neutral100",[`.${qu} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",borderBottomRightRadius:"0",borderBottomLeftRadius:"0","&:focus-visible":{$$background:"$colors$secondary100",[`.${qu} &`]:{$$background:"$colors$info700"},backgroundColor:"$$background",outline:0}});function Xu(t){let{blockchain:e,handleOpenChange:o,open:n}=t,{customDestination:r,setCustomDestination:a}=z(),{config:s}=y(),l=y().blockchains(),p=tr(e.name,l),u=fk(null),c=s?.defaultCustomDestinations?.[e.name],m=navigator?.userAgent.includes("Firefox"),g=n&&!!r&&e&&!No(e,r),d=i(()=>{a("")},"handleClear"),h=i(async S=>{if(S.preventDefault(),navigator.clipboard!==void 0){let C=await navigator.clipboard.readText();a(C),u?.current?.focus()}},"handlePaste"),k=i(()=>r?Be.createElement(ju,{id:"widget-custom-destination-close-icon-btn",onClick:d,variant:"ghost"},Be.createElement(pk,{size:12,color:"gray"})):m?null:Be.createElement(ju,{id:"widget-custom-destination-paste-icon-btn",onClick:h,variant:"ghost"},Be.createElement(ck,{size:16})),"renderSuffix");return dk(()=>{!!c&&r===null&&(a(c),o(!0))},[c]),Be.createElement(Hu,null,Be.createElement(Yr,{onOpenChange:o,hasSelected:!0,open:n,triggerAnchor:"top",trigger:Be.createElement(Vu,null,Be.createElement("div",{className:"button__content"},Be.createElement(mk,{size:18,color:"info"}),Be.createElement(Ku,{size:4,direction:"horizontal"}),Be.createElement(uk,{variant:"label",size:"medium",color:n?"$neutral600":void 0},Ss.t("Send to a different address"))),Be.createElement(jr,{orientation:n?"up":"down"},Be.createElement(lk,{size:10,color:"secondary"}))),onClickTrigger:()=>o(!n)},Be.createElement(Gu,{ref:u,style:{padding:0,paddingRight:r?"8px":"5px"},autoFocus:!r,placeholder:Ss.t("Enter {blockchainName} address",{blockchainName:p}),value:r||"",suffix:k(),onChange:S=>{let C=S.target.value;a(C)}})),g&&Be.createElement(Be.Fragment,null,Be.createElement(Ku,{size:4}),Be.createElement(sk,{variant:"alarm",type:"error",title:Ss.t({values:{destination:r},id:"Address {destination} doesn't match the blockchain address pattern."})})))}i(Xu,"CustomDestination");import{css as gk,darkTheme as Cs,IconButton as hk,styled as Dt}from"@rango-dev/ui";var Yu=Dt("div",{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center"}),Zu=Dt("div",{display:"flex",justifyContent:"space-evenly",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5",height:"100%"}),yk=Dt("button",{borderRadius:"$xm",padding:"$10",border:"0",display:"flex",justifyContent:"center",$$color:"$colors$neutral100",[`.${Cs} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",alignItems:"center",cursor:"pointer",width:110,position:"relative","&:hover":{$$color:"$colors$secondary100",[`.${Cs} &`]:{$$color:"$colors$neutral100"},backgroundColor:"$$color"},"&:focus-visible":{$$color:"$colors$secondary100",[`.${Cs} &`]:{$$color:"$colors$info700"},backgroundColor:"$$color",outline:0},variants:{selected:{true:{outlineWidth:1,outlineColor:"$secondary",outlineStyle:"solid"}}}}),Ju=Dt(yk,{alignSelf:"stretch",minHeight:"93px"}),Ru=Dt("div",{padding:"$20 $20 $15 $20",display:"flex",justifyContent:"center",alignItems:"center",backgroundColor:"$neutral200",position:"relative",width:"100%"}),em=Dt(hk,{position:"absolute",left:"$20"}),tm=Dt("div",{paddingTop:"$20"}),om=gk({display:"flex",justifyContent:"space-evenly",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5",height:"100%"}),nm=Dt("div",{display:"flex"}),rm=Dt("div",{overflow:"visible",width:"100%"});import{i18n as cm}from"@lingui/core";import{warn as vk}from"@rango-dev/logging-core";import{Divider as wk,SelectableWallet as xk,Typography as um,WalletState as mm}from"@rango-dev/ui";import Ze,{useEffect as dm,useState as Tn}from"react";import{Image as kk,MessageBox as Tk}from"@rango-dev/ui";import kn from"react";import{keyframes as Sk,styled as ks}from"@rango-dev/ui";var im=ks("div",{position:"relative"}),Ck=Sk({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}),am=ks("div",{position:"absolute",border:"2px solid rgba(0, 0, 0, 0.1)",borderTop:"2px solid $info500",borderRadius:"$lg",width:"$45",height:"$45",animation:`${Ck} 1s linear infinite`,top:0,bottom:0,right:0,left:0}),sm=ks("div",{"& img":{borderRadius:"50%"}});import{i18n as Vo}from"@lingui/core";function lm(t,e){switch(t){case"in-progress":return{type:"loading",title:Vo.t({id:"Add {blockchainDisplayName} Chain",values:{blockchainDisplayName:e}}),description:Vo.t({id:"Please approve the experimental chain pop-up in your wallet.",values:{blockchainDisplayName:e}})};case"completed":return{type:"success",title:Vo.t({id:"{blockchainDisplayName} Chain Added",values:{blockchainDisplayName:e}}),description:Vo.t({id:"The {blockchainDisplayName} chain has been successfully added to your wallet.",values:{blockchainDisplayName:e}})};case"rejected":return{type:"error",title:Vo.t("Request Rejected"),description:Vo.t({id:"You've rejected adding {blockchainDisplayName} chain to your wallet.",values:{blockchainDisplayName:e}})};default:throw new Error(`Showing information about an experimentation chain status needs to be defined first. status: ${t}`)}}i(lm,"generateMessageByStatus");function pm(t){let{status:e,displayName:o,image:n}=t,r=lm(e,o),a=e=="in-progress";return kn.createElement(Tk,{type:r.type,title:r.title,description:r.description,icon:a?kn.createElement(im,null,kn.createElement(sm,null,kn.createElement(kk,{src:n,size:45})),kn.createElement(am,null)):void 0})}i(pm,"ExperimentalChainStatus");var bk=7,Ek=3e3;function Ts(t){let{chain:e,isSelected:o,selectWallet:n,limit:r,onShowMore:a}=t,s=se.use.isActiveTab(),l=Z.use.connectedWallets(),{blockchains:p}=y(),[u,c]=Tn(),[m,f]=Tn(null),[g,d]=Tn(!1),[h,k]=Tn(null),{suggestAndConnect:S}=Zr(),{handleDisconnect:C}=Ht(),{list:T}=ft({chain:e}),[v,w]=Tn(T),A=T.length,M=r&&A-r>0,x=i(async b=>{d(!1),k("in-progress");try{await S(b.walletType,b.chain),k("completed")}catch{k("rejected")}},"addExperimentalChain");dm(()=>{w(b=>{let W=T.findIndex($=>o($.type,e));return M&&W>1?[T[W]].concat(T.filter(($,I)=>I!==W)):b.map($=>T.find(I=>I.type===$.type)??$)})},[JSON.stringify(T)]);let E=document.getElementById($e.SWAP_BOX_ID);return dm(()=>{let b=null;return(h==="completed"||h==="rejected")&&(b=setTimeout(()=>k(null),Ek)),()=>{b&&clearTimeout(b)}},[h]),Ze.createElement(Ze.Fragment,null,v.slice(0,r).map(b=>{let W=_p({connectedWallets:l,walletType:b.type,chain:e}),$=W?dr(W,bk):"",I=ur(p(),e),R=!l.find(le=>le.walletType===b.type&&le.chain===e),ee=I&&R&&b.state===mm.CONNECTED,oe=ee?cm.t({id:"Add {chain} chain",values:{chain:e}}):$,B=i(async()=>{b.state===mm.DISCONNECTED?c(b):b.namespaces&&!$?(await C(b.type),c(b)):ee?(f({walletType:b.type,chain:e,address:W??""}),d(!0)):n({walletType:b.type,chain:e,address:W??""})},"onSelectableWalletClick"),V=m?.chain?tr(m.chain,p()):void 0;return Ze.createElement(Ze.Fragment,{key:`${b.title}_${V}`},!!m&&Ze.createElement(J,{open:!!m&&g,container:E,onClose:()=>{f(null)}},Ze.createElement(Ea,{displayName:V,onConfirm:()=>{x(m)}})),h&&Ze.createElement(J,{open:!!h,onClose:k.bind(null,null),container:E},Ze.createElement(pm,{status:h,displayName:V,image:b.image}),Ze.createElement(wk,{direction:"vertical",size:32})),Ze.createElement(xk,{key:b.type,description:oe,onClick:B,selected:o(b.type,e),disabled:!s,...b}))}),Ze.createElement(mo,{wallet:u,onClose:()=>{c(void 0)},onConnect:b=>{t.onConnect&&b.status==="connected"&&(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&&Ze.createElement(Ju,{selected:!1,onClick:a},Ze.createElement(um,{variant:"label",size:"medium"},cm.t("Show more wallets"),Ze.createElement(um,{variant:"label",size:"medium",color:"$primary"},"\xA0+",A-(r??0)))))}i(Ts,"WalletList");var Bk=2;function ym(t){let{open:e,onClose:o,onCancel:n,onCheckBalance:r,loading:a}=t,s=Lk(),l=y().blockchains(),{selectedQuote:p,setSelectedWallets:u,quoteWalletsConfirmed:c,setQuoteWalletConfirmed:m,customDestination:f,setCustomDestination:g}=z(),{connectedWallets:d,selectWallets:h}=Z(),{config:k}=y(),[S,C]=Co(""),[T,v]=Co([]),[w,A]=Co(""),[M,x]=Co(null),[E,b]=Co(!!f),W=Mk(()=>io({filter:"all",quote:p}),[p]),$=io({filter:"required",quote:p}),I=l.find(_=>_.name===p?.swaps[p?.swaps.length-1].to.blockchain),R=i(_=>$.includes(_),"isWalletRequiredFor"),ee=Wk(()=>d.filter(_=>_.selected&&W.includes(_.chain)),[d,W]),[oe,B]=Co(ee()),[V,le]=Co([]),Y=i((_,Q)=>le(G=>G.concat({blockchain:_,walletType:Q})),"addNextSelectedWallets"),ae=T.length>0,ge=i((_,Q)=>!!oe.find(G=>G.walletType===_&&G.chain===Q&&G.selected&&(R(Q)||!R(Q)&&!f)),"isSelected"),ve=i((_,Q,G)=>{let pe=!1;return _.map(ce=>{if(ce.chain===Q){let de=ce.selected;return!pe&&G?(pe=!0,de=!0):G||(de=!1),{...ce,selected:de}}return ce})},"updateSelectableWallets"),U=i(_=>{b(_),_?R(I?.name??"")||B(Q=>ve(Q,I?.name||"",!1)):(g(""),B(Q=>ve(Q,I?.name||"",!0)))},"handleCustomDestinationCollapsibleOpenChange"),Ke=i(_=>{if(S&&C(""),ge(_.walletType,_.chain))return;let G=d.find(pe=>pe.walletType===_.walletType&&pe.chain===_.chain);G&&(n(),_.chain===I?.name&&E&&!R(I.name)&&(b(!1),g(null)),B(pe=>pe.filter(ce=>ce.chain!==_.chain).concat({...G,selected:!0})))},"onChange"),vt=i(()=>{let _=oe.filter(Q=>Q.selected);h(_),u(_),m(!0),o()},"onConfirmBalance"),lt=i(async()=>{v([]),A(""),x(null);let _=await r?.({selectedWallets:oe.filter(G=>G.selected),customDestination:f}),Q=_.warnings;Q?.balance?.messages&&v(Q.balance.messages),Q?.quoteUpdate&&x(Q.quoteUpdate),_.error&&A(Lc(_.error)),!_.error&&!Q?.balance?.messages.length?vt():v(Q?.balance?.messages??[])},"onConfirmWallets");hm(()=>{B(_=>{let Q=[];return _.forEach(G=>{!d.some(ce=>ce.chain===G.chain&&ce.walletType===G.walletType&&ce.address===G.address)||Q.push(G)}),Q=Q.concat(d.filter(G=>!!!Q.find(ce=>ce.chain===G.chain)&&G.selected&&W.includes(G.chain))),Q})},[d,W]),hm(()=>{let _=[];V.length>0&&(V.forEach(Q=>{let G=d.find(pe=>pe.chain===Q.blockchain&&pe.walletType===Q.walletType);G?Ke(G):_.push(Q)}),le(_))},[d,V]);let wt=document.getElementById($e.SWAP_BOX_ID);return j.createElement(J,{open:e,onClose:()=>{c||s("../",{replace:!0}),o()},dismissible:!S,container:wt,...!S&&{styles:{container:{height:"100%"}},footer:j.createElement(nm,null,j.createElement(gm,{id:"widget-confirm-wallet-modal-confirm-btn",loading:a,disabled:Yc(a,E,f,p,oe,I),onClick:lt,variant:"contained",type:"primary",fullWidth:!0,size:"large"},So.t("Confirm")))},...S&&{styles:{container:{height:"100%",padding:"$0"}},header:j.createElement(Ru,null,j.createElement(em,{id:"widget-confirm-wallet-modal-navigate-back-icon-btn",variant:"ghost",onClick:C.bind(null,"")},j.createElement(Ak,{size:16})),j.createElement(vs,{variant:"headline",size:"small"},So.t({id:"Your {blockchainName} wallets",values:{blockchainName:pt(S,l)}})))},anchor:"center"},j.createElement(J,{open:ae,onClose:v.bind(null,[]),container:wt},j.createElement(Nk,{title:So.t("Insufficient account balance"),type:"error",description:j.createElement(Ik,{messages:T??[]})},j.createElement(gm,{id:"widget-confirm-wallet-modal-proceed-anyway-btn",variant:"outlined",size:"large",type:"primary",fullWidth:!0,onClick:vt},So.t("Proceed anyway")))),S&&j.createElement(tm,null,j.createElement("div",{className:om()},j.createElement(Ts,{chain:S,isSelected:ge,selectWallet:Ke,onShowMore:()=>C(S),onConnect:_=>{Y(S,_)}}))),!S&&j.createElement(j.Fragment,null,w&&j.createElement(j.Fragment,null,j.createElement(fm,{variant:"alarm",type:"error",title:So.t(w)}),j.createElement(Jr,{size:12})),M&&j.createElement(j.Fragment,null,j.createElement(fm,{variant:"alarm",type:"warning",title:Gr(M)}),j.createElement(Jr,{size:12})),j.createElement(rm,null,W.map((_,Q)=>{let G=l.find(he=>he.name===_),pe=`wallet-${Q}`,ce=Q===W.length-1,de=ce&&I&&k?.customDestination!==!1;return j.createElement("div",{key:pe},j.createElement(Yu,null,j.createElement(vs,{variant:"title",size:"xmedium"},So.t({id:"Your {blockchainName} wallets",values:{blockchainName:G?.shortName}})),j.createElement(vs,{variant:"label",color:"$neutral700",size:"medium"},So.t({id:"You need to connect a {blockchainName} wallet.",values:{blockchainName:G?.shortName}}))),j.createElement(Jr,{size:24}),j.createElement(Zu,null,j.createElement(Ts,{chain:_,isSelected:ge,selectWallet:Ke,limit:Bk,onShowMore:()=>C(G?.name??""),onConnect:he=>{Y(_,he)}})),!ce&&j.createElement(Jr,{size:32}),de&&j.createElement(Xu,{blockchain:I,open:E,handleOpenChange:U}))}))))}i(ym,"ConfirmWalletsModal");import{i18n as Jk}from"@lingui/core";import{Alert as Rk,Button as eT,InfoIcon as tT}from"@rango-dev/ui";import ot from"react";import{Alert as _k,Button as $k,Divider as bs,NoRouteIcon as Fk,RefreshIcon as Ok,Typography as xm}from"@rango-dev/ui";import tt from"react";import{i18n as Sm}from"@lingui/core";var Pk=24,Dk=60;function Cm(t,e,o,n){return t?.type===1?{alert:{type:"warning",text:te().genericServerError,action:{onClick:n,title:Sm.t("Retry")}},description:""}:e.length?{alert:{type:"warning",text:te().liquiditySourcesError.title,action:{onClick:()=>o(!0),title:Sm.t("Reset")}},description:te().liquiditySourcesError.description}:t?.type===0&&t.diagnosisMessage?{alert:{type:"error",text:t.diagnosisMessage,action:null},description:""}:{alert:null,description:te().noResultError.description}}i(Cm,"makeInfo");var ws=(o=>(o[o.small=Pk]="small",o[o.large=Dk]="large",o))(ws||{}),xs=(o=>(o.small="small",o.large="medium",o))(xs||{});import{styled as Rr}from"@rango-dev/ui";var km=Rr("div",{display:"flex",flexDirection:"column",alignItems:"center"}),Tm=Rr("div",{variants:{size:{small:{},large:{maxWidth:"316px"}}}}),vm=Rr("div",{variants:{size:{small:{width:"100%"},large:{}}}}),wm=Rr("div",{padding:"$6 $0"});function vn(t){let{fetch:e,error:o,size:n="small"}=t,r=y().getDisabledLiquiditySources(),a=y().toggleAllLiquiditySources,s=y().swappers(),l=Cm(o,r,()=>a(s,!0),e);return tt.createElement(km,null,tt.createElement(Fk,{size:ws[n],color:"gray"}),tt.createElement(bs,{size:4}),tt.createElement(xm,{variant:"title",size:xs[n]},te().noResultError.title),n==="large"&&tt.createElement(bs,{size:4}),!!l.description&&tt.createElement(Tm,{size:n},tt.createElement(xm,{variant:"body",size:"small",align:"center",color:"neutral700"},l.description)),tt.createElement(bs,{size:n==="large"?"24":"4"}),!!l.alert&&tt.createElement(vm,{size:n},tt.createElement(_k,{type:l.alert.type,title:l.alert.text,titleAlign:"left",action:l.alert.action&&tt.createElement($k,{size:"xsmall",id:"widget-no-result-alert-btn",type:l.alert.type,prefix:tt.createElement(wm,null,tt.createElement(Ok,{size:8})),onClick:l.alert.action.onClick},l.alert.action.title),variant:"alarm"})))}i(vn,"NoResult");import{i18n as wn}from"@lingui/core";import{Button as zk,Divider as Qk,MessageBox as qk,Typography as Hk,WarningIcon as Gk}from"@rango-dev/ui";import _t from"react";import{Typography as Am}from"@rango-dev/ui";import Is from"react";import{darkTheme as Uk,styled as ei}from"@rango-dev/ui";var bm=ei("div",{width:"100%"}),Es=ei("div",{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"$5",width:"100%"}),Em=ei("div",{display:"flex",padding:"$5 0",justifyContent:"space-between",alignItems:"center",width:"100%","._title":{$$color:"$colors$neutral600",[`.${Uk} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),Im=ei("div",{padding:"$2",alignSelf:"flex-start",cursor:"pointer"});function Nm(t){let{title:e,value:o,valueColor:n}=t;return Is.createElement(Em,null,Is.createElement(Am,{size:"medium",variant:"label",className:"_title"},e),Is.createElement(Am,{size:"large",variant:"label",color:n||"foreground"},`${n?"%":"$"}${o}`))}i(Nm,"QuoteErrorsModalItem");function Wm(t){let{open:e,onClose:o,onConfirm:n,warning:r,confirmationDisabled:a}=t,s=r.warningLevel==="high"?"error":"warning",l=[{title:wn.t("Swapping"),value:L(r.inputUsdValue,4,4)},{title:wn.t("Gas cost"),value:L(r.totalFee,2,2)},{title:wn.t("Receiving"),value:L(r.outputUsdValue,4,4)},{title:wn.t("Price impact"),value:L(r.priceImpact,2,2),valueColor:`${s}500`}];return _t.createElement(J,{footer:_t.createElement(zk,{id:"widget-high-value-loss-warning-modal-confirm-btn",type:"primary",size:"large",prefix:_t.createElement(Gk,null),fullWidth:!0,disabled:a,onClick:n},te().highValueLossError.confirmMessage),open:e,onClose:o,container:N()},_t.createElement(qk,{type:s,title:te().highValueLossError.impactTitle,description:te().highValueLossError.description}),_t.createElement(Es,null,_t.createElement(Qk,{size:"4"}),_t.createElement(Hk,{size:"small",variant:"title"},wn.t("Details")),_t.createElement(Es,null,l.map((p,u)=>_t.createElement(Nm,{key:u,...p})))))}i(Wm,"HighValueLossWarningModal");import{i18n as As}from"@lingui/core";function Mm(t,e){let o={alertType:"warning",title:"",action:null};return e?(o.alertType="error",e.type===3&&(o.title=e.recommendation),e.type===4&&(o.title=As.t({id:"You need to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:e.minRequiredSlippage}}),o.action="change-settings"),o):t?(t.type===0&&(Pt(t.priceImpact)==="high"&&(o.alertType="error"),o.action="show-info",o.title=te().highValueLossError.title),t.type===1&&(o.title=te().unknownPriceError.title),t.type===2&&(o.title=As.t({id:"We recommend you to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:t.minRequiredSlippage}}),o.action="change-settings"),t.type===3&&(o.title=As.t("Caution, your slippage is high."),o.action="change-settings"),o):null}i(Mm,"makeAlerts");import{i18n as Ko}from"@lingui/core";import{Button as Lm,Divider as Bm,MessageBox as Vk,Typography as Kk}from"@rango-dev/ui";import ko from"react";import{useNavigate as jk}from"react-router-dom";function Pm(t){let{customSlippage:e,slippage:o}=y(),{open:n,onClose:r,onConfirm:a,warning:s,confirmationDisabled:l}=t,p=jk(),u=e??o;return ko.createElement(J,{anchor:"bottom",open:n,prefix:ko.createElement(Lm,{size:"small",id:"widget-slippage-warning-modal-change-settings-btn",variant:"ghost",onClick:()=>p("../"+D.settings)},ko.createElement(Kk,{variant:"label",size:"medium",color:"$neutral900"},Ko.t("Change settings"))),container:N(),onClose:r},ko.createElement(Vk,{type:"warning",title:s.type===3?Ko.t("High slippage"):Ko.t("Low slippage"),description:s.type===3?Ko.t({id:" Caution, your slippage is high (={userSlippage}). Your trade may be front run.",values:{userSlippage:u}}):Ko.t({id:"We recommend you to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:s.minRequiredSlippage}})},ko.createElement(Bm,{size:18}),ko.createElement(Bm,{size:32}),ko.createElement(Lm,{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(Pm,"SlippageWarningModal");import{Button as Xk,MessageBox as Yk,WarningIcon as Zk}from"@rango-dev/ui";import ti from"react";function Dm(t){let{open:e,onClose:o,onConfirm:n,confirmationDisabled:r}=t;return ti.createElement(J,{footer:ti.createElement(Xk,{id:"widget-unknown-price-warning-modal-confirm-btn",type:"primary",size:"large",prefix:ti.createElement(Zk,null),fullWidth:!0,disabled:r,onClick:n},te().unknownPriceError.confirmMessage),open:e,onClose:o,container:N()},ti.createElement(Yk,{type:"warning",title:te().unknownPriceError.impactTitle,description:te().unknownPriceError.description}))}i(Dm,"UnknownPriceWarningModal");function xn(t){let{warning:e,error:o,couldChangeSettings:n,showWarningModal:r,confirmationDisabled:a,refetchQuote:s,onOpenWarningModal:l,onCloseWarningModal:p,onConfirmWarningModal:u,onChangeSettings:c}=t,m={confirmationDisabled:a,open:r,onClose:p,onConfirm:u},f=o?.type===0||o?.type===1,g=Mm(e,o?.type===3||o?.type===4?o:null);return g&&!n&&(g.action=null),ot.createElement(ot.Fragment,null,f&&ot.createElement(vn,{error:o,fetch:s}),!!g&&ot.createElement(bm,null,ot.createElement(Rk,{title:g.title,type:g.alertType,variant:"alarm",...g.action==="show-info"&&{action:ot.createElement(Im,{onClick:l},ot.createElement(tT,{size:12,color:"gray"}))},...g.action==="change-settings"&&{action:ot.createElement(eT,{id:"widget-quote-warning-error-change-settings-btn",size:"xxsmall",type:g.alertType,onClick:c},Jk.t("Change"))}})),e&&ot.createElement(ot.Fragment,null,e.type===0&&ot.createElement(Wm,{...m,warning:e}),(e.type===3||e.type===2)&&ot.createElement(Pm,{...m,warning:e}),e.type===1&&ot.createElement(Dm,{...m,warning:e})))}i(xn,"QuoteWarningsAndErrors");import LT from"bignumber.js";import gi from"react";import{i18n as To}from"@lingui/core";import{Alert as CT,Divider as Xo,FullExpandedQuote as kT,InfoIcon as TT,NumericTooltip as fd,QuoteTag as vT,StepDetails as wT,TokenAmount as xT,Typography as Yo}from"@rango-dev/ui";import _s from"bignumber.js";import F,{useRef as bT,useState as ET}from"react";import{styled as Ns}from"@rango-dev/ui";var Ws=Ns("div",{width:"100%","& .position-top__skeleton":{paddingTop:"$10"}}),_m=Ns("div",{paddingBottom:"$15",variants:{dense:{true:{paddingBottom:0}}}}),$m=Ns("div",{width:"100%",display:"flex"});import*as oi from"@radix-ui/react-collapsible";import{Button as oT,css as bn,darkTheme as be,Image as Fm,styled as qe,Typography as nT}from"@rango-dev/ui";var rT=300,Om=qe(oi.Root,{display:"flex",flexDirection:"column",alignItems:"start",overflowX:"auto",overflowY:"hidden",width:"100%",borderRadius:"$xm",variants:{selected:{true:{},false:{$$color:"$colors$neutral400",[`.${be} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"}},listItem:{true:{$$color:"$colors$neutral400",[`.${be} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"},false:{}}},compoundVariants:[{listItem:!1,selected:!0,css:{$$color:"$colors$secondary200",[`.${be} &`]:{$$color:"$colors$secondary800"},backgroundColor:"$$color"}}]}),Um=bn({padding:"$10 $15"}),zm=qe(oT,{backgroundColor:"transparent",border:"1px solid $secondary550",[`.${be} &`]:{border:"1px solid $secondary"},transition:"background-color 0.3s ease","&:hover":{backgroundColor:"$secondary550",[`.${be} &`]:{backgroundColor:"$secondary"},".allRoutesLabel":{$$color:"$colors$background",[`.${be} &`]:{$$color:"$colors$foreground"},color:"$$color",transition:"color 0.3s ease"}}}),Qm=qe("div",{borderRadius:"$xm",display:"flex",flexDirection:"column",alignItems:"start",justifyContent:"space-between",color:"$foreground",boxSizing:"border-box",position:"relative",variants:{selected:{true:{},false:{$$color:"$colors$neutral200",[`.${be} &`]:{$$color:"$colors$neutral500"},backgroundColor:"$$color"}},basic:{true:{borderTopRightRadius:"0",borderTopLeftRadius:"0"}},listItem:{true:{$$color:"$colors$neutral200",[`.${be} &`]:{$$color:"$colors$neutral500"},backgroundColor:"$$color","&:hover":{"& .quote_container":{"& button":{backgroundColor:"$neutral500",[`.${be} &`]:{backgroundColor:"$neutral200"}},backgroundColor:"$neutral500",[`.${be} &`]:{backgroundColor:"$neutral200"}},backgroundColor:"$neutral300",[`.${be} &`]:{backgroundColor:"$neutral400"}},cursor:"pointer"},false:{}}},compoundVariants:[{listItem:!0,selected:!0,css:{outline:"1px solid $secondary"}},{listItem:!1,selected:!0,css:{$$color:"$colors$secondary100",[`.${be} &`]:{$$color:"$colors$secondary550"},backgroundColor:"$$color","&:hover":{backgroundColor:"$$color"}}},{listItem:!0,selected:!1,css:{cursor:"pointer","&:hover":{backgroundColor:"$neutral300",[`.${be} &`]:{backgroundColor:"$neutral400"}}}}]}),qm=bn({width:"100%",padding:"$15 $15 $10 $15"}),Hm=bn({display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingBottom:"$10",position:"relative"}),jo=bn({display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",".blockchainImage":{marginLeft:"-$8"}}),Gm=bn({display:"flex",alignItems:"center",".usd-value":{$$color:"$colors$neutral600",[`.${be} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),Vm=qe(oi.Trigger,{display:"flex",width:"100%",justifyContent:"space-between",alignItems:"center",height:"$36",padding:"$10 $15",boxSizing:"border-box",cursor:"pointer",border:"none",outline:"none",backgroundColor:"transparent",variants:{error:{true:{[`& ${Fm}`]:{border:"1px $warning500 solid",borderRadius:"100%"}},false:{[`& ${Fm}`]:{border:"1px transparent solid",borderRadius:"100%"}}},selected:{true:{},false:{$$color:"$colors$neutral400",[`.${be} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"}},listItem:{true:{$$color:"$colors$neutral400",[`.${be} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"},false:{}}},compoundVariants:[{listItem:!1,selected:!0,css:{$$color:"$colors$secondary200",[`.${be} &`]:{$$color:"$colors$secondary800"},backgroundColor:"$$color"}}],".blockchains_section":{display:"none"},"@xs":{".blockchains_section":{display:"block"}}}),Km=qe("div",{width:"18px",height:"18px",borderRadius:"100%",display:"flex",justifyContent:"center",alignItems:"center",border:"1.5px transparent solid",img:{borderRadius:"100%"},variants:{state:{error:{borderColor:"$error500"},warning:{borderColor:"$warning500"}}}}),jm=qe(Kr,{width:"100%",background:"inherit"}),Ms=qe("div",{display:"flex",justifyContent:"center",alignItems:"center",padding:"$2",transition:`all ${rT}ms ease`,variants:{orientation:{down:{transform:"rotate(0)"},up:{transform:"rotate(180deg)"}}}}),l1=qe("div",{height:"$12",marginLeft:"$10",marginRight:"$10",borderLeft:"1px solid $foreground"}),Xm=qe("div",{display:"flex",justifyContent:"center",margin:"0 $15",borderTop:"1px solid",$$color:"$colors$neutral300",[`.${be} &`]:{$$color:"$colors$neutral400"},borderColor:"$$color"}),Ym=qe("div",{width:"$16",height:"$16",justifyContent:"center",alignItems:"center",display:"flex"}),Ls=qe(nT,{overflow:"hidden",textOverflow:"ellipsis",letterSpacing:.4}),Zm=qe("div",{display:"flex",flexWrap:"wrap"}),Bs=qe("div",{width:"18px",height:"18px",borderRadius:"100%",backgroundColor:"$background",cursor:"default",display:"flex",justifyContent:"center",alignItems:"center",border:"1.5px transparent solid",variants:{state:{error:{borderColor:"$error500"},warning:{borderColor:"$warning500"}}}}),Jm=qe("div",{display:"flex"}),ni=qe("div",{width:"100%",borderTopWidth:"1px",borderTopStyle:"solid",borderTopColor:"$neutral",margin:"$5 0",[`.${be} &`]:{borderTopColor:"$neutral800"}});import{i18n as Nt}from"@lingui/core";import{ChevronDownIcon as aT,CloseIcon as sT,Divider as ai,IconButton as lT,NumericTooltip as pT,QuoteCost as cT,Typography as yt}from"@rango-dev/ui";import X,{useState as od}from"react";import{css as iT,styled as ri}from"@rango-dev/ui";var ii=ri("div",{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"$5 0","&.total_payable_fee":{padding:"$12 0"}}),Ps=ri("div",{width:"100%",borderTop:"1px solid $neutral300",margin:"$10 0"}),Rm=ri("div",{padding:"$20 0",display:"flex",flexDirection:"column","& .collapsible_trigger":{display:"flex",alignItems:"center"}}),ed=ri("div",{padding:"$20 $20 $10",textAlign:"center",position:"relative","._icon-button":{position:"absolute",zIndex:10,top:"$16",right:"$16"}}),td=iT({display:"flex",flexDirection:"row",alignItems:"center",padding:"$5","&:hover":{"& ._typography, & svg":{color:"$secondary"}}});var uT=i(t=>t.fee.isZero()?null:X.createElement(ii,null,X.createElement(yt,{variant:"label",size:"medium",color:"neutral600"},t.label),X.createElement(yt,{variant:"label",size:"medium"},"$",L(t.fee,4,4))),"NonPayableFee");function nd(t){let[e,o]=od(!1),[n,r]=od(!1),{steps:a,quote:s,fee:l,time:p,feeWarning:u,showModalFee:c}=t,m=s?.swaps??[],f=N(),g=Fc(m);return X.createElement(X.Fragment,null,X.createElement(cT,{onClickFee:c?d=>{d.stopPropagation(),o(!e)}:void 0,fee:l,feeWarning:u,time:p,steps:a,tooltipGas:c?Nt.t("View more info"):void 0,tooltipContainer:f}),X.createElement(J,{container:f,open:e,header:X.createElement(ed,null,X.createElement(yt,{variant:"title",size:"medium"},Nt.t("Gas & Fee Explanation")),X.createElement(lT,{id:"widget-quote-cost-details-modal-close-icon-btn",onClick:()=>o(!1),variant:"ghost"},X.createElement(sT,{color:"gray",size:14}))),onClose:()=>{o(!1)}},X.createElement(Rm,null,X.createElement(yt,{variant:"title",size:"small"},Nt.t("Details")),X.createElement(ai,{size:10}),Object.entries(g.payable).flatMap(([d,h])=>h.map((k,S)=>{let C=`payable-fee-${S}`,T=Ba(k);return X.createElement(ii,{key:C},X.createElement(yt,{variant:"label",size:"medium",color:"neutral600"},Na(d,Nt.t)),X.createElement(pT,{content:k.amount,container:f},X.createElement(yt,{variant:"label",size:"medium"},L(k.amount,2,2)," ",k.asset.symbol," ($",L(T,4,4),")")))})),X.createElement(ii,{className:"total_payable_fee"},X.createElement(yt,{variant:"label",size:"medium"},Nt.t("Total Payable Fee")),X.createElement(yt,{variant:"label",size:"medium"},"$",L(l,4,4))),X.createElement(Ps,null),Object.keys(g.nonePayable).length&&X.createElement(Yr,{triggerAnchor:"bottom",onClickTrigger:()=>r(d=>!d),trigger:X.createElement("div",{className:td()},X.createElement(yt,{size:"small",variant:"body",color:"neutral700"},n?Nt.t("Hide non-payable fees"):Nt.t("Show non-payable fees")),X.createElement(ai,{size:4,direction:"horizontal"}),X.createElement(jr,{orientation:n?"up":"down"},X.createElement(aT,{size:12,color:"gray"}))),open:n},X.createElement(yt,{size:"small",variant:"title"},Nt.t("Description")),X.createElement(ai,{size:4}),X.createElement(yt,{size:"small",variant:"body",color:"neutral700"},Nt.t(`The following fees are considered in the transaction output and
2
+ you won\u2019t need to pay extra gas for them.`)),X.createElement(ai,{size:10}),Object.entries(g.nonePayable).map(([d,h],k)=>{let S=$c(h),C=Na(d,Nt.t),T=`non-payable-fee-${k}`;return X.createElement(uT,{key:T,fee:S,label:C})}),X.createElement(Ps,null)))))}i(nd,"QuoteCostDetails");import{i18n as ad}from"@lingui/core";import{TokenAmount as sd}from"@rango-dev/ui";import si from"react";import{css as mT,styled as dT}from"@rango-dev/ui";var rd=dT("div",{position:"relative",display:"flex",flexDirection:"column",width:"100%"}),id=mT({height:"14px",marginLeft:"14px",position:"absolute",borderLeft:"1px solid $foreground",top:"42%"});function En(t){let{from:e,to:o,percentageChange:n,warningLevel:r}=t;return si.createElement(rd,null,si.createElement(sd,{direction:"horizontal",label:ad.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}}),si.createElement("div",{className:id()}),si.createElement(sd,{direction:"horizontal",tooltipContainer:N(),label:ad.t("Estimated output"),type:"output",price:{value:o.price.value,usdValue:o.price.usdValue,realValue:o.price.realValue,realUsdValue:o.price.realUsdValue},token:{displayName:o.token.displayName,image:o.token.image},chain:{image:o.chain.image},percentageChange:n,warningLevel:r}))}i(En,"QuoteSummary");import{i18n as md}from"@lingui/core";import{ChevronDownIcon as hT,ChevronRightIcon as yT,Divider as Ds,Image as ST,Tooltip as mi,Typography as pi}from"@rango-dev/ui";import O from"react";import{useLayoutEffect as fT,useState as In}from"react";var ld=480,pd=768,cd=1024,ud=1200,gT=i(()=>{let[t,e]=In(!1),[o,n]=In(!1),[r,a]=In(!1),[s,l]=In(!1),[p,u]=In(!1),c=i(()=>{e(window.innerWidth<=ld),n(window.innerWidth>ld&&window.innerWidth<=pd),a(window.innerWidth>pd&&window.innerWidth<=cd),l(window.innerWidth>cd&&window.innerWidth<=ud),u(window.innerWidth>ud)},"handleResize");return fT(()=>(c(),window.addEventListener("resize",c),()=>window.removeEventListener("resize",c)),[]),{isMobile:t,isTablet:o,isNotebook:r,isLargeScreen:s,isExtraLargeScreen:p}},"useScreenDetect"),li=gT;var ci=4,ui=6,An=i(t=>{let{content:e,src:o,className:n,open:r,state:a,container:s}=t,l=s||N();return O.createElement(mi,{container:l,side:"bottom",sideOffset:4,open:r,content:e},O.createElement(Km,{className:n,state:a},O.createElement(ST,{src:o,size:16})))},"ImageComponent");function dd(t){let{quoteRef:e,selected:o,setExpanded:n,steps:r,expanded:a,type:s,container:l}=t,p=l||N(),u=r.length,c=tu(r),{isTablet:m,isMobile:f}=li();return O.createElement(Vm,{listItem:s==="list-item",ref:g=>e.current=g,selected:o,onClick:g=>{g.stopPropagation(),n(d=>!d)}},O.createElement("div",{className:jo()},O.createElement(pi,{variant:"body",size:"xsmall"},md.t("Via:")),O.createElement(Ds,{direction:"horizontal",size:4}),r.map((g,d)=>{let h=`item-${d}`,k=O.createElement(Ms,null,O.createElement(yT,{size:12,color:"black"}));return f||m?O.createElement(O.Fragment,{key:h},O.createElement(An,{content:g.swapper.displayName,src:g.swapper.image,state:g.state,container:l}),d!==u-1&&O.createElement(O.Fragment,null,k)):O.createElement(O.Fragment,{key:h},u<=ci||u>ci&&d<ci-1?O.createElement(O.Fragment,null,O.createElement(An,{content:g.swapper.displayName,src:g.swapper.image,state:g.state,container:l}),d!==u-1&&O.createElement(O.Fragment,null,k)):d===ci-1&&O.createElement(mi,{container:p,side:"bottom",align:"end",sideOffset:4,content:O.createElement("div",{className:jo()},k,r.map((S,C)=>{let T=`image-${C}`;return C>=d&&O.createElement(O.Fragment,{key:T},O.createElement(An,{content:S.swapper.displayName,src:S.swapper.image,state:S.state,open:!1}),C!==u-1&&O.createElement(O.Fragment,null,k))}))},O.createElement(Bs,{state:r.find((S,C)=>C>=d&&(S.state==="error"||S.state==="warning"))?.state},O.createElement(pi,{size:"xsmall",variant:"body"},"+",u-d))))})),O.createElement("div",{className:jo()},O.createElement("div",{className:"blockchains_section"},O.createElement("div",{className:jo()},O.createElement(pi,{variant:"body",size:"xsmall"},md.t("Chains:")),O.createElement(Ds,{direction:"horizontal",size:4}),c.map((g,d)=>O.createElement(O.Fragment,{key:g.displayName},c.length<=ui||c.length>ui&&d<ui-1?O.createElement(mi,{container:p,side:"bottom",content:g.displayName,sideOffset:4},O.createElement(An,{content:"",src:g.image,open:!1,className:d!==0?"blockchainImage":""})):d===ui-1&&O.createElement(mi,{container:p,side:"bottom",align:"end",sideOffset:4,content:O.createElement("div",{className:jo()},c.map((h,k)=>k>=d&&O.createElement(An,{key:h.displayName,content:"",src:h.image,open:!1,className:k>d?"blockchainImage":"",container:l})))},O.createElement(Bs,{className:"blockchainImage"},O.createElement(pi,{size:"xsmall",variant:"body"},"+",c.length-d))))),O.createElement(Ds,{direction:"horizontal",size:32}))),O.createElement(Ms,{orientation:a?"up":"down"},O.createElement(hT,{size:12,color:"black"}))))}i(dd,"QuoteTrigger");function $s(t){let{quote:e,input:o,output:n,error:r,warning:a,type:s,selected:l=!1,tagHidden:p=!0,showModalFee:u=!0,onClickAllRoutes:c,fullExpandedMode:m=!1,container:f}=t,g=y().blockchains(),{findToken:d}=y(),h=y().swappers(),{customSlippage:k,slippage:S}=y(),C=k||S,[T,v]=ET(t.expanded),w=bT(null),A=L(o.value,6,6),M=L(n.value,6,6),x=n.usdValue?L(n.usdValue,4,4):"",E=ct(o.usdValue,n.usdValue??null),b=L(E,2,2),W=Pt(E??0),$=i((ge,ve)=>ge.map((U,Ke)=>{let vt,lt=r?.type===3&&r.swap.swapperId===U.swapperId,wt=r?.type===4&&r.recommendedSlippages?.has(Ke),_=a?.type===2&&a.recommendedSlippages?.has(Ke),Q=lt||wt,G=_;Q?vt="error":G&&(vt="warning");let pe=Q?To.t("Slippage Error"):To.t("Slippage Warning");return lt&&(pe=To.t("Bridge Limit Error")),{swapper:{displayName:on(U.swapperId,h)??"",image:U.swapperLogo},from:{token:{displayName:U.from.symbol,image:U.from.logo},chain:{displayName:pt(U.from.blockchain,g)??"",image:U.from.blockchainLogo},price:{value:Ke===0&&!ve?L(o.value,6,6):L(U.fromAmount,6,6),usdValue:L((U.from.usdPrice??0)*parseFloat(U.fromAmount),4,4),realValue:Ke===0?o.value:U.fromAmount,realUsdValue:new _s(U.from.usdPrice??0).multipliedBy(U.fromAmount).toString()}},to:{token:{displayName:U.to.symbol,image:U.to.logo},chain:{displayName:pt(U.to.blockchain,g)||"",image:U.to.blockchainLogo},price:{value:L(U.toAmount,6,6),usdValue:L((U.to.usdPrice??0)*parseFloat(U.toAmount),4,4),realValue:U.toAmount,realUsdValue:new _s(U.to.usdPrice??0).multipliedBy(U.toAmount).toString()}},state:vt,alerts:Q||G?F.createElement(_m,{dense:m},F.createElement(CT,{variant:"alarm",type:Q?"error":"warning",title:pe,footer:F.createElement($m,null,lt&&F.createElement("div",null,F.createElement(Yo,{size:"xsmall",variant:"body",color:"neutral900"},r.fromAmountRangeError),F.createElement(Xo,{direction:"vertical",size:2}),F.createElement(Yo,{size:"xsmall",variant:"body",color:"neutral900"},To.t({id:"Yours: {amount} {symbol}",values:{amount:L(U.fromAmount,6,6),symbol:U?.from.symbol}}))),(wt||_)&&!lt&&F.createElement("div",null,F.createElement(Yo,{size:"xsmall",variant:"body",color:"neutral900"},To.t({id:"Minimum required slippage: {minRequiredSlippage}",values:{...r?.type===4&&{minRequiredSlippage:r.recommendedSlippages?.get(Ke)},...a?.type===2&&{minRequiredSlippage:a.recommendedSlippages?.get(Ke)}}})),F.createElement(Xo,{direction:"vertical",size:2}),F.createElement(Yo,{size:"xsmall",variant:"body",color:"neutral900"},To.t({id:"Yours: {userSlippage}",values:{userSlippage:C}}))))})):void 0,time:sn(U.estimatedTimeInSeconds),fee:L(La(U,d),2,2),internalSwaps:U.internalSwaps?$(U.internalSwaps):void 0}}),"getQuoteSteps"),I=$(e?.swaps??[]),R=I.length,ee=f||N(),oe=nu(t.quote.tags||[]),B=!!c,V=sn(ar(e?.swaps)),le=Wr(e?.swaps??[],d),Y=L(le,2,2),ae=le.gte(new _s(Mc));return m?F.createElement(kT,{selected:l,fee:Y,time:V,tooltipContainer:an(),steps:I,tags:oe,feeWarning:ae,percentageChange:b,warningLevel:W,outputPrice:{value:M,usdValue:x,realValue:n.value,realUsdValue:n.usdValue}}):F.createElement(Qm,{selected:l,listItem:s==="list-item",basic:s==="basic"},F.createElement("div",{className:qm()},!p&&oe.length?F.createElement(F.Fragment,null,F.createElement(Jm,null,oe.map((ge,ve)=>{let U=`${ge.value}_${ve}`;return F.createElement(F.Fragment,{key:U},F.createElement(vT,{label:ge.label,value:ge.value}),F.createElement(Xo,{size:4,direction:"horizontal"}))})),F.createElement(ni,null),!B&&F.createElement(Xo,{size:4})):null,F.createElement("div",{id:"portal-root",className:Hm()},F.createElement(nd,{quote:e,time:V,fee:Y,feeWarning:ae,showModalFee:u,steps:R}),B&&F.createElement(zm,{onClick:ge=>{ge.stopPropagation(),c()},size:"xxsmall",type:"secondary",variant:"default",css:{paddingLeft:"$10",paddingRight:"$10",paddingTop:"$5",paddingBottom:"$5"}},F.createElement(Yo,{color:"secondary",variant:"body",size:"xsmall",className:"allRoutesLabel"},To.t("See All Routes")))),s==="basic"&&F.createElement("div",{className:Gm()},F.createElement(Ym,null,F.createElement(TT,{size:12,color:"gray"})),F.createElement(Zm,null,F.createElement(Ls,{size:"small",variant:"body"},`${A} ${I[0].from.token.displayName} = `),F.createElement(fd,{content:n.value,container:ee,open:n.value?void 0:!1},F.createElement(Ls,{size:"small",variant:"body"},"\xA0",`${M} ${I[I.length-1].to.token.displayName}`))),F.createElement(fd,{content:n.usdValue,container:ee},F.createElement(Xo,{size:2,direction:"horizontal"}),F.createElement(Yo,{color:"$neutral600",size:"xsmall",variant:"body"},`($${x})`))),s==="list-item"&&F.createElement(xT,{tooltipContainer:ee,type:"output",direction:"vertical",price:{value:M,usdValue:x,realValue:n.value,realUsdValue:n.usdValue},token:{displayName:I[R-1].to.token.displayName,image:I[R-1].to.token.image},chain:{image:I[R-1].to.chain.image},percentageChange:b,warningLevel:W}),s==="swap-preview"&&F.createElement(F.Fragment,null,F.createElement(En,{from:I[0].from,to:I[R-1].to,percentageChange:b,warningLevel:W}),F.createElement(Xo,{size:4}))),F.createElement(Om,{selected:l,listItem:s==="list-item",open:T,className:"quote_container",onOpenChange:v},F.createElement(dd,{type:s,quoteRef:w,selected:l,setExpanded:v,container:ee,expanded:T,steps:I}),F.createElement(jm,{open:T},F.createElement(Xm,null),F.createElement("div",{className:Um()},I.map((ge,ve)=>{let U=`item-${ve}`;return F.createElement(wT,{type:"quote-details",key:U,tooltipContainer:ee,step:ge,hasSeparator:ve!==I.length-1,state:ge.state})})))))}i($s,"Quote");import{Divider as WT,Skeleton as MT}from"@rango-dev/ui";import Ft from"react";import{darkTheme as IT,styled as di}from"@rango-dev/ui";var gd=di("div",{$$color:"$colors$neutral100",[`.${IT} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",borderBottomLeftRadius:"$xm",borderBottomRightRadius:"$xm",padding:"$15",variants:{rounded:{true:{borderRadius:"$xm"}},expanded:{true:{paddingBottom:"3px"},false:{paddingBottom:"$12"}}}}),hd=di("div",{paddingTop:"$2"}),yd=di("div",{paddingLeft:"$8"}),Sd=di("div",{borderLeft:"1px dashed $foreground",minHeight:" 0",margin:"0px 11.5px",alignSelf:"stretch",variants:{hideSeparator:{true:{minHeight:"unset",height:"0"}}}});import{ChainToken as Ad,Divider as St,Skeleton as nt}from"@rango-dev/ui";import q from"react";import{css as AT,styled as $t}from"@rango-dev/ui";var Fs=$t("div",{display:"flex"}),Cd=$t("div",{padding:"$10 $0 $20"}),kd=$t("div",{padding:"14px $0 $20 $0",display:"flex",flexDirection:"column"}),Td=$t("div",{display:"flex",justifyContent:"start",alignItems:"center"}),vd=$t("div",{display:"flex",justifyContent:"space-between",alignItems:"end"}),wd=$t("div",{height:"$24",marginLeft:"13px",borderLeft:"1px solid $neutral700"}),xd=$t("div",{width:"65%",display:"flex",justifyContent:"start"}),bd=$t("div",{display:"flex",flexDirection:"column",alignItems:"start",flexGrow:1,maxWidth:"148px"}),Ed=$t("div",{padding:"$15 $0 $15 $0"}),Id=AT({display:"flex",justifyContent:"space-between",alignItems:"center"});function Nn(t){let{type:e,tagHidden:o=!0}=t,n=q.createElement(vd,null,q.createElement(xd,null,q.createElement(Ad,{loading:!0,size:"medium",chainImage:"",tokenImage:""}),q.createElement(St,{size:8,direction:"horizontal"}),q.createElement(bd,null,q.createElement(nt,{height:10,width:60,variant:"rounded"}),q.createElement(St,{size:4}),q.createElement(nt,{height:15,variant:"rounded"}))),q.createElement(nt,{height:12,width:64,variant:"rounded"})),r=e==="basic"&&!o;return q.createElement("div",null,!o&&q.createElement(q.Fragment,null,q.createElement(Fs,null,q.createElement(nt,{width:65,height:20,variant:"rounded"}),q.createElement(St,{size:4,direction:"horizontal"}),q.createElement(nt,{width:65,height:20,variant:"rounded"}),q.createElement(St,{size:4,direction:"horizontal"}),q.createElement(nt,{width:65,height:20,variant:"rounded"})),q.createElement(ni,null),!r&&q.createElement(St,{size:4})),q.createElement("div",{className:Id()},q.createElement(Fs,null,q.createElement(nt,{width:60,height:10,variant:"rounded"}),q.createElement(St,{size:4,direction:"horizontal"}),q.createElement(nt,{width:60,height:10,variant:"rounded"}),q.createElement(St,{size:4,direction:"horizontal"}),q.createElement(nt,{width:60,height:10,variant:"rounded"})),r&&q.createElement(nt,{width:85,height:24,variant:"rounded"})),e==="basic"&&q.createElement(Cd,null,q.createElement(nt,{height:15,width:148,variant:"rounded"})),e==="list-item"&&q.createElement(kd,null,q.createElement(Td,null,q.createElement(Ad,{loading:!0,size:"medium",chainImage:"",tokenImage:""}),q.createElement(St,{direction:"horizontal",size:4}),q.createElement(nt,{height:15,width:150,variant:"rounded"})),q.createElement(St,{size:10}),q.createElement(nt,{height:10,width:184,variant:"rounded"})),e==="swap-preview"&&q.createElement(q.Fragment,null,q.createElement(St,{size:4}),q.createElement(Ed,null,n,q.createElement(wd,null),n),q.createElement(St,{size:12})))}i(Nn,"QuoteSummarySkeleton");import{ChainToken as Bd,Divider as Us,NextIcon as NT,Skeleton as fi}from"@rango-dev/ui";import Ee from"react";import{styled as Wn}from"@rango-dev/ui";var Nd=Wn("div",{display:"flex",alignItems:"start"}),Wd=Wn("div",{flexGrow:1,paddingTop:"$5",paddingBottom:"$10",display:"flex",alignItems:"center",variants:{extraSpace:{true:{paddingBottom:"$40"}}}}),Os=Wn("div",{display:"flex",alignItems:"center",flexGrow:1}),Md=Wn("div",{margin:"$0 $2",padding:"$4",display:"flex",justifyContent:"center",alignItems:"center"}),Ld=Wn("div",{display:"flex",alignItems:"center"});function Wt(t){let{separator:e=!0}=t;return Ee.createElement(Ee.Fragment,null,Ee.createElement(Ld,null,Ee.createElement(fi,{height:22,width:22,variant:"circular"}),Ee.createElement(Us,{direction:"horizontal",size:8}),Ee.createElement(fi,{height:15,width:148,variant:"rounded"})),Ee.createElement(Nd,null,Ee.createElement(Sd,{hideSeparator:!e}),Ee.createElement(Wd,{extraSpace:e},Ee.createElement(Os,null,Ee.createElement(Bd,{size:"small",loading:!0,chainImage:"",tokenImage:""}),Ee.createElement(Us,{direction:"horizontal",size:8}),Ee.createElement(fi,{height:12,variant:"rounded"})),Ee.createElement(Md,null,Ee.createElement(NT,{color:"gray",size:16})),Ee.createElement(Os,null,Ee.createElement(Bd,{size:"small",loading:!0,chainImage:"",tokenImage:""}),Ee.createElement(Us,{direction:"horizontal",size:8}),Ee.createElement(fi,{height:12,variant:"rounded"})))))}i(Wt,"StepSkeleton");function Mn(t){let{type:e,expanded:o,tagHidden:n=!1}=t;return Ft.createElement(gd,{expanded:o,rounded:e!=="basic"},Ft.createElement(Nn,{type:e,tagHidden:n}),Ft.createElement(hd,null,Ft.createElement(MT,{height:15,variant:"rounded"})),o&&Ft.createElement(yd,null,Ft.createElement(WT,{size:24}),Ft.createElement(Wt,null),Ft.createElement(Wt,null),Ft.createElement(Wt,{separator:!1})))}i(Mn,"QuoteSkeleton");function vo(t){let{quote:e,type:o,loading:n,error:r,warning:a,expanded:s=!1,tagHidden:l,onClick:p,showModalFee:u,selected:c,onClickAllRoutes:m,fullExpandedMode:f=!1,container:g}=t,{inputAmount:d,inputUsdValue:h,toToken:k}=z(),S=e?.outputAmount?new LT(e?.outputAmount):null,C=e?.outputAmount?jt(e?.outputAmount,go(e)||k?.usdPrice):null,v=!(r&&(r.type===0||r.type===1))&&e&&!n;return n?gi.createElement(Ws,null,gi.createElement(Mn,{tagHidden:l,type:o,expanded:s})):v?gi.createElement(Ws,{onClick:()=>p?.(e)},gi.createElement($s,{quote:e,error:r,container:g,showModalFee:u,warning:a,tagHidden:l,selected:c,type:o,expanded:s,onClickAllRoutes:m,fullExpandedMode:f,input:{value:d,usdValue:h?.toString()??""},output:{value:S?.toString()??"",usdValue:C?.toString()??""}})):null}i(vo,"QuoteInfo");import{calculatePendingSwap as _T}from"@rango-dev/queue-manager-rango-preset";import{useEffect as $T}from"react";import{useRef as BT,useState as PT}from"react";var DT=2e3;function hi({request:t}){let[e,o]=PT(!1),n=BT(null),r=i(()=>n.current?.abort(),"cancelFetch"),a=i(async l=>(await new Promise(p=>setTimeout(p,DT)),await s(l,!1)),"retryFetch"),s=i(async(l,p=!1)=>{r(),n.current=new AbortController,o(!0);try{let u=await t(l,{signal:n.current.signal});return n.current=null,u}catch(u){if(p)return await a(l);throw u}finally{o(!1)}},"fetch");return{fetch:s,loading:e,cancelFetch:r}}i(hi,"useFetch");function Pd(){let{fetch:t,loading:e,cancelFetch:o}=hi({request:async(n,r)=>await Et().confirmRoute(n,r)});return{fetch:t,loading:e,cancelFetch:o}}i(Pd,"useFetchConfirmQuote");function yi(t){if(!t.swaps)throw new Error(te().noResultError.title,{cause:{type:0,diagnosisMessage:t.diagnosisMessages?.[0]}});let e=zs(t.swaps);if(e)throw new Error(e.message,{cause:e.options})}i(yi,"throwErrorIfResponseIsNotValid");function zs(t){if(Pc(t)){let{swap:n,recommendation:r,fromAmountRangeError:a}=Dc(t);return{message:"bridge limit error",options:{type:3,swap:n,recommendation:r,fromAmountRangeError:a}}}let o=Oc(t);if(o){let n=Mr(t);return{message:"",options:{type:4,recommendedSlippages:o,minRequiredSlippage:n}}}return null}i(zs,"getQuoteError");function Dd(t,e,o){let n=!1;t&&(n=eu(t,e));let r={quote:null,quoteUpdate:null,balance:null},a=Fo(e,{fromToken:o.fromToken,toToken:o.toToken,findToken:o.findToken,userSlippage:o.userSlippage});a&&(r.quote=a),t&&n&&(Gc(t,e)?r.quoteUpdate={type:3,newOutputAmount:L($o(e)),percentageChange:L(ct($o(t)??"",$o(e)??""),null,2)}:Pa(t,e)?r.quoteUpdate={type:0}:Da(t,e)?r.quoteUpdate={type:1}:_a(t,e)&&(r.quoteUpdate={type:2}));let s=Vc(e,o.selectedWallets,o.meta.blockchains);return s.length===0||(r.balance={messages:s}),r}i(Dd,"generateWarnings");function Si(t){return t?.code==="ERR_CANCELED"?{swap:null,error:{type:2},warnings:null}:t.cause?{swap:null,error:t.cause,warnings:null}:{swap:null,error:{type:1},warnings:null}}i(Si,"handleQuoteErrors");function Qs(){let{fromToken:t,toToken:e,inputAmount:o,setSelectedQuote:n,selectedQuote:r,customDestination:a,setQuoteWarningsConfirmed:s,resetAlerts:l}=z(),{slippage:p,customSlippage:u}=y(),c=y().getDisabledLiquiditySources(),m=y().blockchains(),f=y().tokens(),{findToken:g}=y(),d=u||p,{fetch:h,cancelFetch:k,loading:S}=Pd();return $T(()=>k,[]),{loading:S,fetch:i(async T=>{let v=T.selectedWallets,w=T?.customDestination??a;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:r?.requestId||"",selectedWallets:A,destination:w||void 0};try{return await h(M,!0).then(x=>{let{result:E}=x;if(!E)throw new Error("Error fetching updated route");yi({diagnosisMessages:E.diagnosisMessages,requestId:E.requestId,swaps:E.result?.swaps});let b={outputAmount:E.result?.outputAmount,requestId:E.requestId,resultType:E.result?.resultType,swaps:E.result?.swaps||[],validationStatus:E.validationStatus,requestAmount:E.requestAmount};n(b);let W={slippage:d.toString(),disabledSwappersGroups:c},$=Dd(r??void 0,b,{fromToken:t,toToken:e,meta:{blockchains:m},findToken:g,selectedWallets:v,userSlippage:d});$.quoteUpdate&&s(!1),l();let I=!!$.balance,R=_T(o.toString(),E,qc(v),W,!I,{blockchains:m,tokens:f});return{quote:b,swap:R,error:null,warnings:$}})}catch(x){return Si(x)}},"fetch"),cancelFetch:k}}i(Qs,"useConfirmSwap");var VT=UT("div",{width:"100%",display:"flex",justifyContent:"space-between",[`& ${$d}`]:{width:"$48",height:"$48"}}),KT=Gs({flexGrow:1,paddingRight:"$10"}),jT=Gs({width:"$24",height:"$24",display:"flex",justifyContent:"center",alignItems:"center"}),XT=Gs({display:"flex",justifyContent:"space-between",alignItems:"center"});function Fd(){let{selectedQuote:t,setInputAmount:e,selectedWallets:o,quoteWalletsConfirmed:n,customDestination:r,quoteWarningsConfirmed:a}=z(),s=GT(),[l,p]=Ln(""),u=!n,[c,m]=Ln(!1),[f,g]=Ln(!1),{isActiveTab:d}=se(),h=y().getDisabledLiquiditySources(),k=HT(h),{manager:S}=FT(),{fetch:C,loading:T,cancelFetch:v}=Qs(),[w,A]=Ln({swap:null,error:null,warnings:null}),[M,x]=Ln(!1),E=i(async({selectedWallets:B,customDestination:V})=>{let le=await C?.({selectedWallets:B,customDestination:V});return A(le),le},"onConfirmSwap"),b=i(async()=>{if(w.swap&&n)try{await S?.create("swap",{swapDetails:w.swap},{id:w.swap.requestId});let B=`../${D.swaps}/${w.swap.requestId}`;s(B,{replace:!0}),setTimeout(()=>{e("")},0)}catch(B){p("Error: "+B?.message)}},"addNewSwap"),W=i(async()=>{g(!0),await b(),g(!1)},"onConfirm"),$=i(async()=>{w?.warnings?.quote&&!a?x(!0):await W()},"onStartConfirmSwap"),I=i(async()=>{A({error:null,swap:null,warnings:null}),C({selectedWallets:o,customDestination:r}).then(B=>{A(B)}).catch(B=>console.error(B))},"onRefresh");Ci(()=>{!!k.current.length&&!h.length&&I(),k.current=h},[h.length]),Ci(()=>{u&&v()},[u]),Ci(()=>{u&&m(u)},[u]),Ci(()=>{u||C({selectedWallets:o,customDestination:r}).then(B=>A(B)).catch(B=>console.error(B))},[]),qT(()=>{t?.requestId||s(`../${location.search}`)},[t?.requestId]);let R=w.warnings?.quote??null,ee=w.error,oe=[];if(l&&oe.push(Ie.createElement(_d,{type:"error",variant:"alarm",title:l})),w.warnings?.quoteUpdate&&oe.push(Ie.createElement(_d,{variant:"alarm",type:"warning",title:w.warnings.quoteUpdate&&Gr(w.warnings.quoteUpdate)})),R||ee){let B=`../${D.settings}`;oe.push(Ie.createElement(xn,{warning:R,error:ee,couldChangeSettings:!1,refetchQuote:I,showWarningModal:M,confirmationDisabled:!d,onOpenWarningModal:()=>x(!0),onCloseWarningModal:()=>x(!1),onConfirmWarningModal:async()=>{x(!1),await b()},onChangeSettings:()=>s(B)}))}return Ie.createElement(ne,{header:{title:qs.t("Confirm Swap"),onWallet:()=>{let B=`../${D.wallets}`;s(B)}},footer:Ie.createElement(VT,null,Ie.createElement("div",{className:KT()},Ie.createElement(OT,{id:"widget-confirm-swap-start-btn",variant:"contained",type:"primary",size:"large",fullWidth:!0,loading:T||f,disabled:!!w.error||!d,onClick:$},qs.t("Start Swap"))),Ie.createElement($d,{id:"widget-confirm-swap-wallet-icon-btn",variant:"contained",type:"primary",size:"large",loading:T||f,disabled:!d,onClick:m.bind(null,!0)},Ie.createElement(QT,{size:24})))},c&&Ie.createElement(ym,{open:c,onClose:()=>m(!1),onCancel:v,loading:T,onCheckBalance:E}),Ie.createElement(re,null,Ie.createElement("div",{className:XT()},Ie.createElement(zT,{variant:"title",size:"small"},qs.t("You get")),Ie.createElement("div",{className:jT()},Ie.createElement(Or,{onClick:!T&&!c&&!M?I:void 0}))),Ie.createElement(Hs,{size:"12"}),yu(oe.map((B,V)=>({element:B,key:`alert-${V}`})),Ie.createElement(Hs,{size:10})),oe.length>0?Ie.createElement(Hs,{size:10}):null,Ie.createElement(vo,{quote:t,type:"swap-preview",expanded:!0,tagHidden:!0,error:w.error,loading:T,warning:w.warnings?.quote??null})))}i(Fd,"ConfirmSwapPage");import{i18n as Ot}from"@lingui/core";import{Button as rl,CustomTokensZeroStateDarkIcon as fv,CustomTokensZeroStateIcon as gv,DeleteIcon as hv,Divider as _n,IconButton as yv,MessageBox as Sv,NotFound as Cv,styled as al}from"@rango-dev/ui";import fe,{useState as il}from"react";import{useNavigate as kv}from"react-router-dom";import{CloseIcon as ZT,IconButton as JT,SearchIcon as RT,TextField as ev}from"@rango-dev/ui";import Bn from"react";import{styled as YT}from"@rango-dev/ui";var Od=YT("div",{width:"$24",height:"$24",display:"flex",alignItems:"center",justifyContent:"center"});function Ct(t){let{variant:e,fullWidth:o,color:n,size:r,onChange:a,value:s,style:l,setValue:p,...u}=t;return Bn.createElement(ev,{prefix:Bn.createElement(Od,null,Bn.createElement(RT,{color:"black"})),suffix:!!s.length&&Bn.createElement(JT,{variant:"ghost",onClick:()=>p?.(""),size:"small"},Bn.createElement(ZT,{color:"gray",size:10})),fullWidth:o,color:n,variant:e,style:{padding:10,borderRadius:25,alignItems:"center",...l},size:r,value:s,onChange:a,...u})}i(Ct,"SearchInput");import{i18n as ol}from"@lingui/core";import{darkTheme as Yd,Divider as Jo,ExternalLinkIcon as sv,Image as lv,ListItemButton as pv,NotFound as cv,PinIcon as uv,Skeleton as Zd,Typography as vi,VirtualizedList as mv}from"@rango-dev/ui";import H,{useEffect as Jd,useState as Rd}from"react";import{useWallets as tv}from"@rango-dev/wallets-react";import{useEffect as ov,useRef as nv,useState as rv}from"react";function Vs(t){let{connectedWallets:e}=Z(),{getWalletInfo:o}=tv(),n=nv([]),[r,a]=rv(0);return ov(()=>{let s=i(p=>{p.type==="disconnect"&&o(p.payload.walletType).supportedChains.some(m=>m.name===t)&&a(m=>m+1)},"handleWalletEvent");return yr.on("walletEvent",s),t?(e.filter(p=>p.chain===t).forEach(p=>{let{walletType:u}=p,c=n.current.includes(u);p.loading&&!c?n.current=n.current.concat(u):!p.loading&&c&&(n.current=n.current.filter(m=>m!==u),a(m=>m+1))}),()=>yr.off("walletEvent",s)):a(p=>p+1)},[e,t,o]),{balanceKey:r}}i(Vs,"useObserveBalanceChanges");import{Divider as jd,ListItem as av,Skeleton as Pn}from"@rango-dev/ui";import kt from"react";import{css as Zo,darkTheme as Ud,ImageContainer as iv,styled as mt,Typography as zd}from"@rango-dev/ui";var Ks=Zo({position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:100,overflow:"hidden"}),js=Zo({position:"relative",height:12,width:"30%",maxWidth:"150px"}),Xs=Zo({position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",bottom:"-8px"}),Ys=Zo({transform:"translateY(12px)",visibility:"hidden",display:"flex","& a":{display:"flex",justifyContent:"center",alignItems:"center",fontSize:"$12",lineHeight:"$16",$$color:"$colors$neutral600",[`.${Ud} &`]:{$$color:"$colors$neutral700"},color:"$$color",textDecoration:"none"}}),Zs=Zo({}),Js=Zo(),Qd=mt("div",{display:"flex",flexDirection:"column",flexGrow:1,overflow:"hidden",justifyContent:"center"}),Rs=mt("div",{display:"flex",alignItems:"center","._typography":{textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:100,overflow:"hidden"}}),ki=mt("ul",{flexGrow:1,padding:0,margin:0,listStyle:"none","& li":{alignItems:"none","&:hover":{[`& .${js}`]:{[`& .${Ys}`]:{position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",visibility:"visible"},[`& .${Zs}`]:{bottom:"-15px"},[`& .${Ks}`]:{position:"absolute",transform:"translateY(-12px)",visibility:"hidden"},[`& .${Xs}`]:{position:"absolute",transform:"translateY(-12px)",bottom:"-10px"}}}}}),el=mt("div",{paddingLeft:"$5",paddingRight:"$5",borderRadius:"$md",display:"flex",alignItems:"center"}),tl=mt(zd,{}),qd=mt("div",{textAlign:"right",width:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",[`& .${Js}`]:{$$color:"$colors$neutral600",[`.${Ud} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),Ti=mt("div",{display:"flex",alignItems:"end",flexDirection:"column"}),dU=mt("div",{display:"flex",alignItems:"center"}),Hd=mt("div",{position:"relative",[`& ${iv}`]:{borderRadius:"$xm",overflow:"hidden"}}),Gd=mt("div",{position:"absolute",backgroundColor:"$neutral100",padding:"$4",borderRadius:"50%",bottom:-6,right:-6}),Vd=mt(zd,{width:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}),Kd=mt("a",{"& svg:hover":{color:"$colors$info"}});function Xd(t){return kt.createElement(ki,null,Array.from(Array(t.size),e=>kt.createElement(av,{key:e,hasDivider:!0,start:kt.createElement(Pn,{variant:"circular",width:35,height:35}),end:kt.createElement(Ti,null,kt.createElement(Pn,{variant:"text",size:"large",width:70}),kt.createElement(jd,{size:4}),kt.createElement(Pn,{variant:"text",size:"medium",width:50})),title:kt.createElement("div",null,kt.createElement(Pn,{variant:"text",size:"large",width:90}),kt.createElement(jd,{size:4}),kt.createElement(Pn,{variant:"text",size:"medium",width:90}))})))}i(Xd,"LoadingTokenList");var nl=20,dv=i(t=>{let{address:e,name:o,url:n,token:r,customCssForTag:a,customCssForTagTitle:s}=t,l=e.length;return H.createElement("div",{className:js()},o?H.createElement("div",{className:Ks()},o):H.createElement(Rs,{className:Xs()},H.createElement(vi,{variant:"title",size:"xmedium"},r.symbol),H.createElement(Jo,{direction:"horizontal",size:4}),H.createElement(el,{css:a},H.createElement(tl,{variant:"body",size:"xsmall",css:s},r.blockchain))),!!e&&H.createElement("div",{className:`${Ys()} ${!o&&Zs()}`},l>10?`${e.slice(0,5)}...${e.slice(l-6,l)}`:e," ",H.createElement(Jo,{size:4,direction:"horizontal"}),H.createElement(Kd,{href:n,target:"_blank",rel:"nofollow noreferrer",onClick:p=>p.stopPropagation()},H.createElement(sv,{size:12}))))},"renderDesc");function Dn(t){let{list:e,searchedFor:o="",onChange:n,selectedBlockchain:r,showTitle:a=!0,action:s}=t,[l,p]=Rd(e),u=y().fetchStatus,c=y().blockchains(),[m,f]=Rd(!0),{getBalanceFor:g,loading:d}=Z(),{isTokenPinned:h}=y(),{balanceKey:k}=Vs(r),S=i(()=>{p(e.slice(0,l.length+nl))},"loadNextPage");Jd(()=>{f(e.length>l.length)},[l.length]),Jd(()=>{p(e.slice(0,nl))},[e.length,r,k]);let C=i(v=>{let w=mr(g(v));return s?s(v):d?H.createElement(Ti,null,H.createElement(Zd,{variant:"text",size:"large",width:70}),H.createElement(Jo,{size:4}),H.createElement(Zd,{variant:"text",size:"medium",width:50})):w&&H.createElement(qd,null,H.createElement(Vd,{variant:"title",size:"small"},w.amount),H.createElement("div",null),w.usdValue&&H.createElement(vi,{variant:"body",className:Js(),size:"xsmall"},`$${w.usdValue}`))},"endRenderer"),T=i(()=>H.createElement(mv,{endReached:m?S:void 0,itemContent:v=>{let w=l[v],A=w.address||"",M=c.find(W=>W.name===w.blockchain),x=Xa(M.color,"main"),E={$$color:x.main150,[`.${Yd} &`]:{$$color:x.main750},backgroundColor:"$$color"},b={$$color:x.main750,[`.${Yd} &`]:{$$color:x.main150},color:"$$color"};return H.createElement("div",{style:{paddingRight:5}},H.createElement(pv,{style:{width:"100%",overflow:"hidden",height:"60px"},"tab-index":v,key:`${w.symbol}${w.address}`,id:`${w.symbol}${w.address}`,className:"widget-token-list-item-btn",hasDivider:!0,onClick:()=>n&&n(l[v]),start:H.createElement(Hd,null,H.createElement(lv,{src:w.image,size:30}),t.type!=="custom-token"&&h(w,t.type)&&H.createElement(Gd,null,H.createElement(uv,{size:12,color:"gray"}))),title:M?.type==="COSMOS"||w.name||!w.name&&!A?H.createElement(Rs,null,H.createElement(vi,{variant:"title",size:"xmedium"},w.symbol),H.createElement(Jo,{direction:"horizontal",size:4}),H.createElement(el,{css:E},H.createElement(tl,{variant:"body",size:"xsmall",css:b},w.blockchain))):void 0,description:M?.info&&A&&M.type!=="COSMOS"?dv({address:A,token:l[v],customCssForTag:E,customCssForTagTitle:b,name:w.name,url:M.info.addressUrl.split("{wallet}").join(A)}):w.name||void 0,end:C(w)}))},totalCount:l.length,key:`${r}-${o}-${k}`}),"renderList");return H.createElement(H.Fragment,null,a&&H.createElement(H.Fragment,null,H.createElement(vi,{variant:"label",size:"large"},ol.t("Select Token")),H.createElement(Jo,{size:4})),H.createElement(Qd,null,H.createElement(Jo,{size:4}),u==="loading"&&H.createElement(Xd,{size:nl}),u==="success"&&(l.length?H.createElement(ki,{as:"ul"},T()):!!o&&H.createElement(cv,{title:ol.t("No results found"),description:ol.t("Try using different keywords")}))))}i(Dn,"TokenList");var Tv=al("div",{display:"flex",justifyContent:"space-between",flexDirection:"column",flex:1}),vv=al("div",{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",flex:"0.75"}),wv=al(yv,{"&:hover":{"& svg":{color:"$secondary550"}}});function ef(){let[t,e]=il(""),{deleteCustomToken:o}=y(),n=y().customTokens(),{fromToken:r,toToken:a,setFromToken:s,setToToken:l}=z(),{mode:p}=Qo({}),u=kv(),[c,m]=il(!1),[f,g]=il(),d=i(C=>{let T=C.target.value;e(T)},"handleSearch"),h=p==="dark",k=n.filter(C=>et(C.symbol,t)||et(C.address||"",t)||et(C.name||"",t)),S=i(()=>{if(f){let C=a?_e(a):null,T=r?_e(r):null,v=_e(f);C===v?l({token:null}):T===v&&s({token:null}),o(f)}m(!1)},"handleDeleteCustomToken");return fe.createElement(ne,{header:{title:Ot.t("Custom Tokens")}},fe.createElement(re,null,fe.createElement(Tv,null,n.length?fe.createElement(fe.Fragment,null,fe.createElement(Ct,{value:t,setValue:e,fullWidth:!0,color:"light",variant:"contained",placeholder:Ot.t("Search Token"),onChange:d}),fe.createElement(_n,{size:16}),fe.createElement(Dn,{list:k,type:"custom-token",searchedFor:t,showTitle:!1,action:C=>fe.createElement(wv,{id:"widget-custom-token-delete-icon-btn",variant:"ghost",onClick:()=>{m(!0),g(C)}},fe.createElement(hv,{size:12,color:"gray"}))})):fe.createElement(vv,null,fe.createElement(Cv,{icon:h?fe.createElement(fv,{size:200}):fe.createElement(gv,{size:200}),title:Ot.t("No custom tokens"),description:Ot.t("press the button to add your custom token")})),fe.createElement(_n,{size:20}),fe.createElement(rl,{id:"widget-custom-token-add-btn",type:"primary",variant:"contained",size:"large",onClick:()=>u(D.addCustomTokens)},Ot.t("Add Custom Token"))),fe.createElement(J,{open:c,dismissible:!0,onClose:()=>m(!1),container:N()},fe.createElement(Sv,{title:Ot.t("Delete Custom Token"),type:"error",description:Ot.t("Are you sure you want to Delete this Token?")},fe.createElement(_n,{size:40}),fe.createElement(_n,{size:10}),fe.createElement(rl,{fullWidth:!0,id:"widget-custom-token-delete-modal-yes-btn",variant:"contained",type:"primary",size:"large",onClick:S},Ot.t("Yes, Delete it")),fe.createElement(_n,{size:12}),fe.createElement(rl,{id:"widget-custom-token-delete-modal-no-btn",fullWidth:!0,variant:"outlined",type:"primary",size:"large",onClick:()=>m(!1)},Ot.t("No, Continue"))))))}i(ef,"CustomTokensPage");import{i18n as Ge}from"@lingui/core";import{useManager as Qv}from"@rango-dev/queue-manager-react";import{Button as dl,darkTheme as qv,Divider as xo,MessageBox as Hv,NotFound as Gv,styled as fl,Typography as bi}from"@rango-dev/ui";import{TransactionStatus as On}from"rango-types";import ie,{useMemo as kf,useState as Ei}from"react";import{useNavigate as Vv}from"react-router-dom";import{FilterIcon as Wv,Popover as Mv}from"@rango-dev/ui";import wo from"react";import{css as xv,darkTheme as wi,IconButton as bv,styled as $n}from"@rango-dev/ui";var sl=$n("div",{position:"relative","&::before":{position:"absolute",right:"1px",top:"-1px",width:"$8",height:"$8",borderRadius:"100%",backgroundColor:"$neutral300",[`.${wi} &`]:{backgroundColor:"$neutral400"},padding:"$2"},variants:{isSelect:{true:{"&::before":{content:""}}}}}),tf=$n(bv,{width:"$36",height:"$36",position:"relative",padding:"0",overflow:"unset",backgroundColor:"$neutral300",[`.${wi} &`]:{backgroundColor:"$neutral400"},"&:hover":{backgroundColor:"$secondary100",[`.${wi} &`]:{backgroundColor:"$neutral"},[`& ${sl}::before`]:{backgroundColor:"$secondary100",[`.${wi} &`]:{backgroundColor:"$neutral"}}},variants:{isSelect:{true:{border:"1px solid $secondary"}}}}),of=$n("div",{position:"absolute",width:"$6",height:"$6",display:"flex",justifyContent:"center",alignItems:"center",borderRadius:"3px",top:"$0",right:"1px",backgroundColor:"$secondary500"}),nf=$n("div",{padding:"$15",borderRadius:"$sm",width:"248px",backgroundColor:"$background",zIndex:10}),rf=xv({display:"flex",justifyContent:"space-between",alignItems:"center"}),af=$n("ul",{margin:0,listStyle:"none",height:"100%",padding:0,".item-start-container":{paddingRight:"0 !important"}});import{i18n as sf}from"@lingui/core";import{Button as Ev,Divider as lf,ListItemButton as Iv,Radio as Av,RadioRoot as Nv,Typography as pf}from"@rango-dev/ui";import rt from"react";function cf(t){let{filterBy:e,onClickItem:o}=t;return rt.createElement(nf,null,rt.createElement("div",{className:rf()},rt.createElement(pf,{size:"small",variant:"body"},sf.t("Status")),rt.createElement(Ev,{id:"widget-filter-selector-reset-btn",variant:"ghost",size:"xxsmall",onClick:()=>o("")},sf.t("Reset"))),rt.createElement(lf,{size:10}),rt.createElement(Nv,{value:e},rt.createElement(af,null,t.list.map((n,r)=>rt.createElement(Iv,{key:n.id,style:{height:"40px",width:"100%"},selected:!1,hasDivider:t.list.length-1!=r,id:n.id,title:rt.createElement(rt.Fragment,null,rt.createElement(lf,{direction:"horizontal",size:4}),rt.createElement(pf,{size:"medium",variant:"body"},n.title)),start:rt.createElement(Av,{value:n.id}),onClick:o})))))}i(cf,"FilterSelectorContent");function ll(t){let{onClickItem:e,onOpenChange:o,filterBy:n,list:r,open:a}=t;return wo.createElement("div",null,wo.createElement(Mv,{open:a,align:"end",onOpenChange:o,container:N(),content:wo.createElement(cf,{list:r,filterBy:n,onClickItem:s=>{e(s),o(!1)}})},wo.createElement(tf,{id:"widget-filter-selector-filter-icon-btn",variant:"default",isSelect:!!n,onClick:()=>o(!t.open)},wo.createElement(sl,{isSelect:!!n},wo.createElement(Wv,{size:16,color:"black"}),!!n&&wo.createElement(of,null)))))}i(ll,"FilterSelector");import{i18n as Pv}from"@lingui/core";import{Divider as gf,GroupedVirtualizedList as Dv,Skeleton as _v,SwapListItem as hf,Typography as $v}from"@rango-dev/ui";import He,{useCallback as yf,useEffect as Fv,useRef as Ov,useState as Uv}from"react";function uf(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(uf,"calculateGroupsSoFar");import{css as Lv,darkTheme as Bv,styled as Fn}from"@rango-dev/ui";var pl=Lv(),mf=Fn("div",{display:"flex",justifyContent:"center",alignItems:"center",padding:"$5"}),cl=Fn("div",{width:"100%",display:"flex",flexDirection:"column",backgroundColor:"$background",padding:"$10 $5 0 $5",[`& .${pl}`]:{$$color:"$colors$neutral600",[`.${Bv} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),ul=Fn("div",{display:"flex",justifyContent:"flex-start",padding:"$2"}),df=Fn("div",{gap:"$10",display:"flex",flexDirection:"column"}),ff=Fn("div",{height:"100%",display:"flex",justifyContent:"center",alignItems:"center"});var zv=10;function ml(t){let{list:e,onSwapClick:o,groupBy:n,isLoading:r}=t,[a,s]=Uv([]),l=Ov(0),{swaps:p,groupCounts:u,groups:c}=n(e),m=yf(uf,[]),f=yf(()=>{let g=e.length-l.current;g&&(l.current+=Math.min(g,zv),s(m(u,l.current)))},[e.length]);if(Fv(()=>{r||f()},[r,f]),r){let g=[1,2];return He.createElement(He.Fragment,null,[g,g].map((h,k)=>He.createElement(cl,{key:k},He.createElement(ul,null,He.createElement(_v,{variant:"text",width:60,size:"small"}),He.createElement(gf,{size:16})),He.createElement(gf,{size:4}),He.createElement(df,null,h.map((C,T)=>He.createElement(hf,{isLoading:!0,key:T}))))))}return He.createElement(Dv,{endReached:()=>{l.current<e.length&&f()},groupCounts:a,groupContent:g=>He.createElement(cl,null,He.createElement(ul,null,He.createElement($v,{variant:"label",size:"medium",className:pl()},c[g]))),itemContent:(g,d)=>{let h=p[g];if(!h)return null;let k=h.steps[0],S=h.steps[h.steps.length-1];return He.createElement(mf,{key:h.requestId},He.createElement(hf,{requestId:h.requestId,creationTime:h.creationTime,status:h.status,onClick:o,tooltipContainer:N(),onlyShowTime:c[d]===Pv.t("Today"),swapTokenData:{from:{token:{image:k.fromLogo,displayName:k.fromSymbol},blockchain:{image:k.fromBlockchainLogo||""},amount:L(h.inputAmount,6,6),realAmount:h.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(ml,"HistoryGroupedList");import{i18n as xi}from"@lingui/core";import Sf from"dayjs";var Cf=i(t=>{let e=new Map([["today",{title:xi.t("Today"),swaps:[]}],["week",{title:xi.t("This week"),swaps:[]}],["month",{title:xi.t("This month"),swaps:[]}],["year",{title:xi.t("This year"),swaps:[]}]]);function o(p,u){e.has(p)||e.set(p,{title:p,swaps:[]}),e.get(p)?.swaps.push(u)}i(o,"addYearsToOutput");let n=Sf();t.forEach(p=>{let u=Number(p.creationTime),c=Sf(u);if(n.isSame(c,"day"))e.get("today")?.swaps.push(p);else if(n.isSame(c,"week"))e.get("week")?.swaps.push(p);else if(n.isSame(c,"month"))e.get("month")?.swaps.push(p);else if(n.isSame(c,"year"))e.get("year")?.swaps.push(p);else{let m=new Date(u).getFullYear().toString();o(m,p)}});let r=Array.from(e.values()).filter(p=>p.swaps.length>0),a=r.flatMap(p=>p.swaps),s=r.map(p=>p.swaps.length),l=r.map(p=>p.title);return{swaps:a,groupCounts:s,groups:l}},"groupSwapsByDate");var Kv=fl("div",{overflowY:"visible",width:"100%",display:"flex",flexDirection:"column",gap:15,height:"100%"}),jv=fl("div",{display:"flex",justifyContent:"center",alignItems:"center"}),Xv=fl("div",{"._typography":{color:"$neutral700",[`.${qv}&`]:{color:"$neutral900"}}}),Yv=[{id:On.SUCCESS,title:Ge.t("Complete")},{id:On.RUNNING,title:Ge.t("Running")},{id:On.FAILED,title:Ge.t("Failed")}],Zv=i((t,e)=>t?.length?t.filter(o=>xt(o.fromBlockchain,e)||xt(o.toBlockchain,e)||xt(o.toSymbol,e)||xt(o.fromSymbol,e)).length:!1,"isStepContainsText");function Tf(){let t=Vv(),{manager:e,state:o}=Qv(),n=ut(e).map(({swap:T})=>T),[r,a]=Ei(""),[s,l]=Ei(!1),p=!o.loadedFromPersistor,[u,c]=Ei(""),[m,f]=Ei(!1),g=i(T=>{let v=T.target.value;a(v)},"handleSearch"),d=kf(()=>!r&&!u?n:n.filter(T=>{let{inputAmount:v,status:w,steps:A,requestId:M}=T;return(!r||xt(v,r)||xt(w,r)||Zv(A,r)||xt(M,r))&&(!u||u===w)}),[n,r,u]),h=!d?.length&&!p,k=i(()=>f(!1),"onCloseModal"),S=i(async()=>{try{await e?.clearQueue(),f(!1)}catch(T){console.log(T)}},"onClear"),C=kf(()=>!n.some(T=>T.status===On.SUCCESS||T.status===On.FAILED),[n]);return ie.createElement(ne,{header:{title:Ge.t("History"),suffix:ie.createElement(Vt,null,ie.createElement(dl,{id:"widget-history-clear-btn",disabled:C,variant:"ghost",size:"xsmall",onClick:()=>f(!0)},ie.createElement(bi,{size:"medium",variant:"label",color:"error"},Ge.t("Clear"))))}},ie.createElement(re,null,ie.createElement(jv,null,ie.createElement(Ct,{setValue:a,fullWidth:!0,variant:"contained",placeholder:Ge.t("Search Transaction"),autoFocus:!0,onChange:g,style:{height:36},value:r}),ie.createElement(xo,{size:10,direction:"horizontal"}),ie.createElement(ll,{filterBy:u,open:s,onOpenChange:T=>l(T),onClickItem:T=>c(T),list:Yv})),ie.createElement(xo,{size:"16"}),ie.createElement(Kv,null,h&&ie.createElement(ff,null,ie.createElement(xo,{size:32}),ie.createElement(Gv,{title:r?Ge.t("No results found"):Ge.t("No transactions"),titleColor:r?void 0:"$info",hasIcon:!!r,description:r?Ge.t("Try using different keywords"):Ge.t("Your transaction history is stored locally and will appear here after you start a swap")})),!h&&ie.createElement(ml,{list:d,onSwapClick:t,groupBy:Cf,isLoading:p}))),ie.createElement(J,{open:m,onClose:k,container:N()},ie.createElement(xo,{size:20}),ie.createElement(Hv,{type:"warning",title:Ge.t("Clear Transaction History"),description:ie.createElement(Xv,null,ie.createElement(bi,{variant:"body",size:"medium"},Ge.t("Proceeding will remove all successful and failed transactions from the widget. Do you want to continue?")),ie.createElement(xo,{size:"24"}),ie.createElement(bi,{variant:"body",size:"small"},Ge.t("Note: This does not erase your transaction history on the chain; it only removes them here.")))}),ie.createElement(xo,{size:30}),ie.createElement(dl,{id:"widget-history-clear-modal-yes-btn",variant:"contained",type:"primary",size:"large",onClick:S},Ge.t("Yes, Clear the history")),ie.createElement(xo,{size:10}),ie.createElement(dl,{id:"widget-history-clear-modal-no-btn",variant:"outlined",type:"primary",size:"large",onClick:k},ie.createElement(bi,{variant:"title",size:"medium",color:"primary"},Ge.t("No, Cancel")))))}i(Tf,"HistoryPage");import{i18n as hw}from"@lingui/core";import{Button as yw,Divider as Uf,styled as Sw,WarningIcon as Cw}from"@rango-dev/ui";import kw from"bignumber.js";import Je,{useEffect as zf,useState as Qf}from"react";import{useNavigate as Tw}from"react-router-dom";import{i18n as nw}from"@lingui/core";import{Header as rw}from"@rango-dev/ui";import Rt,{useEffect as iw,useState as aw}from"react";import{i18n as Rv}from"@lingui/core";import{Divider as hl,FullExpandedQuote as ew,Typography as tw}from"@rango-dev/ui";import Ce from"react";import{styled as gl}from"@rango-dev/ui";var vf=gl("div",{display:"flex",justifyContent:"center",flexDirection:"column",height:"100%"}),wf=gl("div",{display:"flex",justifyContent:"space-between",alignItems:"center"}),xf=gl("div",{width:"146px"});import{i18n as Un}from"@lingui/core";import{Select as Jv}from"@rango-dev/ui";import bf from"react";function Ii(t){let{updateQuotePartialState:e,sortStrategy:o}=z(),n=[{value:"SMART",label:Un.t("Smart Routing")},{value:"FEE",label:Un.t("Lowest Fee")},{value:"SPEED",label:Un.t("Fastest Transfer")},{value:"NET_OUTPUT",label:Un.t("Maximum Return")},{value:"PRICE",label:Un.t("Maximum Output")}];return bf.createElement(xf,null,bf.createElement(Jv,{container:t.container,options:n,value:o,handleItemClick:r=>{e("sortStrategy",r.value)},variant:"filled"}))}i(Ii,"SelectStrategy");var Ef=3;function zn(t){let{loading:e,onClickOnQuote:o,fetch:n,showModalFee:r,hasSort:a=!0,fullExpandedMode:s=!1,container:l}=t,{selectedQuote:p,quotes:u,updateQuotePartialState:c,fromToken:m,toToken:f,sortStrategy:g,error:d}=z(),{slippage:h,customSlippage:k}=y(),{findToken:S}=y(),C=l||N(),T=!!u&&u.results.length,v=k??h,w=i(x=>{if(!m||!f||!u)return null;let E={requestAmount:u.requestAmount,validationStatus:null,...x};return Fo(E,{fromToken:m,toToken:f,userSlippage:v,findToken:S})},"getQuoteWarning"),A=d?.type===0||d?.type===1,M=u?.results?Pr(g,u?.results):[];return Ce.createElement(Ce.Fragment,null,a&&Ce.createElement(Ce.Fragment,null,Ce.createElement(wf,null,Ce.createElement(tw,{size:"xmedium",variant:"title"},Rv.t("Sort by")),Ce.createElement(Ii,{container:C})),Ce.createElement(hl,{size:"10"})),e&&Array.from({length:Ef},(x,E)=>Ce.createElement(Ce.Fragment,{key:E},s?Ce.createElement(ew,{loading:!0}):Ce.createElement(Mn,{tagHidden:!1,type:"list-item",expanded:!1}),E!==Ef-1&&Ce.createElement(hl,{size:16}))),!e&&Ce.createElement(Ce.Fragment,null,T?M.map((x,E)=>{let b=w(x),W=zs(x.swaps),$=M.length-1===E;return Ce.createElement(Ce.Fragment,{key:x.requestId},Ce.createElement(vo,{showModalFee:r,container:C,selected:p?.requestId===x.requestId,tagHidden:!1,quote:{...x,requestAmount:u.requestAmount,validationStatus:null},loading:e,error:W?.options||null,warning:b,fullExpandedMode:s,onClick:I=>{W||c("warning",b),c("error",W?.options||null),o(I)},type:"list-item"}),!$&&Ce.createElement(hl,{size:16}))}):A&&Ce.createElement(vf,null,Ce.createElement(vn,{size:s?"large":"small",error:d,fetch:n}))))}i(zn,"Quotes");import{darkTheme as ow,styled as If}from"@rango-dev/ui";var Af=If("div",{transition:"width 0.2s, opacity 0.2s, margin-left 0.2s",height:"700px",width:"390px",opacity:1,marginLeft:"$16",backgroundColor:"$neutral100",[`.${ow} &`]:{backgroundColor:"$neutral300"},variants:{expandMode:{default:{width:"390px"},full:{width:"719px"}}},"&.is-hidden":{width:0,height:0,opacity:0,marginLeft:0}}),Nf=If("div",{position:"relative",overflow:"hidden",padding:"$20",flexGrow:1,display:"flex",flexDirection:"column",overflowY:"auto",borderRadius:"$primary",backgroundColor:"$background"});var sw=100;function yl(t){let{fetch:e,loading:o,onClickOnQuote:n,onClickRefresh:r,isVisible:a}=t,[s,l]=aw(!1),p=s?"":"is-hidden",{config:u}=y(),c=u?.variant==="full-expanded",m=an();return iw(()=>{let f=null;return a?f=setTimeout(()=>{l(!0)},sw):(l(!1),f&&clearTimeout(f)),()=>{f&&clearTimeout(f)}},[a]),Rt.createElement(Af,{expandMode:u?.variant==="full-expanded"?"full":"default",className:`${p} ${Qr()}`,id:$e.EXPANDED_BOX_ID},Rt.createElement(rw,{title:nw.t("Routes"),suffix:Rt.createElement(Rt.Fragment,null,Rt.createElement(Ii,{container:m}),Rt.createElement(yo,{container:m,onClickRefresh:r,hidden:["history","notifications","settings"]}))}),Rt.createElement(Nf,null,Rt.createElement(zn,{showModalFee:!1,fetch:e,hasSort:!1,loading:o,container:an(),onClickOnQuote:n,fullExpandedMode:c})))}i(yl,"ExpandedQuotes");import{i18n as _f}from"@lingui/core";import{SwapInput as $f}from"@rango-dev/ui";import Qn from"react";import{ReverseIcon as cw}from"@rango-dev/ui";import Cl from"react";import{keyframes as lw,styled as Wf}from"@rango-dev/ui";var Sl=450,pw=lw({"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)"}}),Mf=Wf("div",{position:"absolute",bottom:"-12px",left:"50%",transform:"translate(-50%, 10%)",cursor:"pointer"}),Lf=Wf("div",{borderRadius:"$md",border:"3px solid $background",background:"$neutral100",width:"$24",height:"$24",display:"flex",justifyContent:"center",alignItems:"center",color:"$foreground","&.rotate":{"& svg":{animation:`${pw} ${Sl}ms ease-in-out forwards`}},"&:hover":{color:"$secondary500",transform:"translateY(1px) scale(1.04)",boxShadow:"1px 1px 1px 1px rgba(0, 0, 0, 0.05)"}});function kl(){let t=z.use.switchFromAndTo();return Cl.createElement(Mf,null,Cl.createElement(Lf,{onClick:e=>{let o=e.currentTarget;o.classList.add("rotate"),setTimeout(()=>{o.classList.remove("rotate")},Sl),t()}},Cl.createElement(cw,{size:12})))}i(kl,"SwitchFromAndToButton");import{styled as Bf}from"@rango-dev/ui";var Pf=Bf("div",{display:"flex",flexDirection:"column",gap:"$5",alignSelf:"stretch"}),Df=Bf("div",{position:"relative"});function Tl(t){let{fetchingQuote:e,fetchMetaStatus:o,onClickToken:n,isExpandable:r}=t,{fromToken:a,fromBlockchain:s,toToken:l,toBlockchain:p,setInputAmount:u,inputAmount:c,inputUsdValue:m,outputAmount:f,outputUsdValue:g,selectedQuote:d}=z(),{connectedWallets:h,getBalanceFor:k}=Z(),S=a?k(a):null,C=mr(S)?.amount??"0",T=s&&a?L(S?.amount,S?.decimals):"0",v=!!s&&$p(h,s.name),w=!Ma(d,c,m),A=!Ma(d,c,g),M=!m||!g||!g.gt(0)?null:ct(m.toString(),g.toString());return Qn.createElement(Pf,null,Qn.createElement(Df,null,Qn.createElement($f,{label:_f.t("From"),mode:"From",onInputChange:u,balance:C,chain:{displayName:s?.displayName||"",image:s?.logo||""},token:{displayName:a?.symbol||"",image:a?.image||""},onClickToken:()=>n("from"),price:{value:c,usdValue:w?void 0:L(m,4,4),realUsdValue:w?void 0:m?.toString(),error:w?te().unknownPriceError.impactTitle:void 0},disabled:o==="failed",loading:o==="loading",loadingBalance:v,tooltipContainer:N(),onSelectMaxBalance:()=>{u(T.split(",").join(""))},anyWalletConnected:h.length>0}),Qn.createElement(kl,null)),Qn.createElement($f,{sharpBottomStyle:!r&&(!!d||e),label:_f.t("To"),mode:"To",fetchingQuote:e,chain:{displayName:p?.displayName||"",image:p?.logo||""},token:{displayName:l?.symbol||"",image:l?.image||""},percentageChange:L(ct(m,g),2,2),warningLevel:Pt(M??0),price:{value:L(f,6,6),usdValue:A?void 0:L(g,4,4),realValue:f?.toString(),realUsdValue:A?void 0:g?.toString(),error:A?te().unknownPriceError.impactTitle:void 0},onClickToken:()=>n("to"),disabled:o==="failed",loading:o==="loading",tooltipContainer:N()}))}i(Tl,"Inputs");import{useCallback as uw,useEffect as mw,useRef as dw,useState as fw}from"react";function Ff(){let{fetch:t,loading:e,cancelFetch:o}=hi({request:async(n,r)=>await Et().getAllRoutes(n,r)});return{fetch:t,loading:e,cancelFetch:o}}i(Ff,"useFetchAllQuotes");var gw=600;function Ai({refetchQuote:t}){let{fetch:e,cancelFetch:o}=Ff(),{excludeLiquiditySources:n,features:r,enableCentralizedSwappers:a}=y().config,s=Z.use.connectedWallets(),{fromToken:l,toToken:p,inputAmount:u,inputUsdValue:c,selectedQuote:m,sortStrategy:f,resetQuote:g,error:d,warning:h,setSelectedQuote:k,updateQuotePartialState:S}=z(),{slippage:C,customSlippage:T,affiliatePercent:v,affiliateRef:w,affiliateWallets:A,fetchStatus:M}=y(),x=y().getLiquiditySources(),E=y().getDisabledLiquiditySources(),b=y().excludeLiquiditySources(),{findToken:W}=y(),[$,I]=fw(!0),R=dw(u),ee=T??C,B=!l||!p||ao(l,p)||!ln(u),V=i(ae=>{I(ae)},"resetState"),le=i(ae=>{let{fromToken:ge,toToken:ve,inputAmount:U,liquiditySources:Ke,excludeLiquiditySources:vt,disabledLiquiditySources:lt,slippage:wt,affiliateRef:_,affiliatePercent:Q,affiliateWallets:G}=ae;if($||V(!0),!B&&ge&&ve){g();let pe=Qc({fromToken:ge,toToken:ve,inputAmount:U,liquiditySources:Ke,excludeLiquiditySources:vt,disabledLiquiditySources:lt,wallets:s,slippage:wt,affiliateRef:_,affiliatePercent:Q,affiliateWallets:G,enableCentralizedSwappers:a});Vp("experimentalRoute",r)&&(pe.experimental=!0),e(pe).then(ce=>{let de=Pr(f,ce.results),he=ou(m,de,ce.requestAmount);I(!1),S("quotes",ce),k(he),yi({diagnosisMessages:ce.diagnosisMessages,requestId:he?.requestId||"",swaps:he?.swaps});let Rn=go(he)||ve?.usdPrice,ro=hn(he)||ge?.usdPrice,ea=he&&Fo(he,{fromToken:{...ge,usdPrice:ro},toToken:{...ve,usdPrice:Rn},userSlippage:ee,findToken:W});S("warning",ea)}).catch(ce=>{let{error:de}=Si(ce);(de?.type===0||de?.type===1)&&g(),de?.type!==2&&(S("error",de),I(!1))})}},"fetch"),Y=uw(wp(ae=>{le(ae)},gw),[B]);return mw(()=>{if(!t){I(!1);return}if(M!=="success")return;if(B){I(!1),(m||d||h)&&g();return}if(!ln(u)||c?.eq(0)){V(!1),o();return}g(),V(!0);let ae=le;return R.current&&R.current!=u&&(ae=Y),R.current=u,ae({inputAmount:u,fromToken:l,toToken:p,liquiditySources:x,excludeLiquiditySources:b,disabledLiquiditySources:E,slippage:ee,affiliateRef:w,affiliatePercent:v,affiliateWallets:A}),o},[M,u,l?.symbol,l?.address,l?.blockchain,p?.symbol,p?.address,p?.blockchain,B,x?.length,n,E.length,ee,w,v,JSON.stringify(A)]),{fetch:()=>le({inputAmount:u,fromToken:l,toToken:p,liquiditySources:x,excludeLiquiditySources:b,disabledLiquiditySources:E,slippage:ee,affiliateRef:w,affiliatePercent:v,affiliateWallets:A}),loading:$}}i(Ai,"useSwapInput");function Of(t,e){let o=!1,n={preventDefault(){o=!0},...t.payload===void 0&&{payload:t.payload}};ye.emit("uiEvent",{type:t.type,payload:n}),o||e()}i(Of,"emitPreventableEvent");var vw=Sw("div",{display:"flex",alignItems:"flex-start",maxHeight:700,"& .footer__alert":{paddingTop:"0 !important"}}),ww=300;function qf(){let t=Tw(),{fromToken:e,toToken:o,inputAmount:n,selectedQuote:r,refetchQuote:a,error:s,warning:l,quotes:p,setSelectedQuote:u,resetQuoteWallets:c,setQuoteWarningsConfirmed:m,updateQuotePartialState:f}=z(),[g,d]=Qf(!1),{isLargeScreen:h,isExtraLargeScreen:k}=li(),{fetch:S,loading:C}=Ai({refetchQuote:a}),{config:T,fetchStatus:v}=y(),{connectedWallets:w}=Z(),{isActiveTab:A}=se(),[M,x]=Qf(!1),b=_c({fetchMetaStatus:v,fetchingQuote:C,inputAmount:n,quote:r,anyWalletConnected:w.length>0,error:s,warning:l,needsToWarnEthOnPath:!1}),W=Hp(h,k,T?.variant),$=!!n&&!!e&&!!o&&new kw(n).gt(0)&&!Zc(e,o),I=$&&v==="success"&&C,oe=(!W||W&&p?.results.length)&&(l||s);zf(()=>{c(),f("refetchQuote",!0)},[]),zf(()=>{d($)},[$]);let B=(r||s)&&!M?S:void 0,V=i(Y=>{W&&g?(d(!1),setTimeout(()=>{t(Y)},ww)):t(Y)},"onHandleNavigation"),le=i(Y=>{r?.requestId!==Y.requestId&&(x(!1),u(Y))},"onClickOnQuote");return Je.createElement(vw,null,Je.createElement(ne,{height:"auto",footer:Je.createElement(yw,{id:`widget-swap-${b.action}-btn`,type:"primary",size:"large",disabled:b.disabled||!A,prefix:b.action==="confirm-warning"&&Je.createElement(Cw,null),fullWidth:!0,onClick:()=>{b.action==="connect-wallet"?Of({type:"clickConnectWallet"},()=>V(D.wallets)):b.action==="confirm-warning"?x(!0):V(D.confirmSwap)}},b.title),header:{onWallet:()=>{V(D.wallets)},hasBackButton:!1,title:T.title||hw.t("Swap"),suffix:Je.createElement(yo,{hidden:W?["refresh"]:void 0,onClickRefresh:B,onClickHistory:()=>V(D.swaps),onClickSettings:()=>{V(D.settings)}})}},Je.createElement(re,null,Je.createElement(Tl,{fetchingQuote:I,fetchMetaStatus:v,isExpandable:W,onClickToken:Y=>{V(Y==="from"?D.fromSwap:D.toSwap)}}),Je.createElement(Uf,{size:"2"}),W?null:Je.createElement(vo,{quote:r,loading:I,error:s,tagHidden:!1,warning:l,type:"basic",onClickAllRoutes:p&&p.results.length>1?()=>{f("refetchQuote",!1),V(D.routes)}:void 0}),oe?Je.createElement(Je.Fragment,null,Je.createElement(Uf,{size:"10"}),Je.createElement(xn,{warning:l,error:s,couldChangeSettings:!0,refetchQuote:S,showWarningModal:M,confirmationDisabled:!A,onOpenWarningModal:()=>x(!0),onCloseWarningModal:()=>x(!1),onConfirmWarningModal:()=>{x(!1),m(!0),V(D.confirmSwap)},onChangeSettings:()=>V(D.settings)})):null)),W?Je.createElement(yl,{loading:I,onClickOnQuote:le,fetch:S,onClickRefresh:B,isVisible:g}):null)}i(qf,"Home");import{i18n as Hf}from"@lingui/core";import{Alert as xw,Divider as bw,List as Ew,ListItemButton as Iw,Radio as Aw,RadioRoot as Nw,Typography as Ww}from"@rango-dev/ui";import Mt from"react";function eo(){let{setLanguage:t,language:e,config:o}=y(),n=Xp,r=o?.language||Mo;return{activeLanguage:e||r,languages:n,defaultLanguage:r,changeLanguage:a=>t(a||Mo),resetLanguage:()=>t(null)}}i(eo,"useLanguage");function Gf(){let{activeLanguage:t,changeLanguage:e,languages:o}=eo(),n=Ye(),r=o.map(a=>{let{local:s,label:l,SVGFlag:p}=a;return{id:`widget-setting-languages-${s}-item-btn`,value:s,title:Mt.createElement(Ww,{variant:"title",size:"xmedium"},l),onClick:()=>{e(a.local),n()},end:Mt.createElement(Aw,{value:s}),start:Mt.createElement(p,null)}});return Mt.createElement(ne,{header:{title:Hf.t("Language")}},Mt.createElement(re,null,Mt.createElement(xw,{type:"warning",variant:"alarm",title:"Warning: We are using machine translation, so the translations may be inaccurate."}),Mt.createElement(bw,{size:"8"}),Mt.createElement(Nw,{value:t},Mt.createElement(Ew,{type:Mt.createElement(Iw,{title:Hf.t("language"),id:"_",onClick:()=>console.log()}),items:r}))))}i(Gf,"LanguagePage");import{i18n as Ut}from"@lingui/core";import{Button as Dw,Checkbox as _w,Image as $w,ListItemButton as Fw,NotFound as Ow,Typography as Uw}from"@rango-dev/ui";import Ve,{useState as zw}from"react";import{Checkbox as Bw,Skeleton as Kf}from"@rango-dev/ui";import Hn from"react";import{styled as vl}from"@rango-dev/ui";var qn=vl("ul",{padding:"$15 $5 0",margin:0,listStyle:"none",height:"100%",overflowY:"auto",variants:{disabled:{true:{pointerEvents:"none"}}}}),wl=vl("div",{width:80,display:"flex",justifyContent:"flex-end"}),xl=vl("div",{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%"});import{ListItem as Mw,styled as Lw}from"@rango-dev/ui";var Vf=Lw(Mw,{height:61});var Pw=30;function bl(){return Hn.createElement(qn,null,Array.from(Array(Pw),(t,e)=>Hn.createElement(Vf,{hasDivider:!0,key:e,start:Hn.createElement(Kf,{variant:"circular",width:35,height:35}),title:Hn.createElement(Kf,{variant:"text",size:"large",width:90}),end:Hn.createElement(Bw,{checked:!1})})))}i(bl,"LoadingLiquiditySourceList");function El({sourceType:t}){let e=y().fetchStatus,o=y().swappers(),n=y().getDisabledLiquiditySources(),[r,a]=zw(""),s=y().toggleLiquiditySource,l=y().isInCampaignMode(),p=hr(o,n),u={Exchanges:Ut.t("Exchanges"),Bridges:Ut.t("Bridges")},c=[];t==="Exchanges"&&c.push("DEX"),t==="Bridges"&&c.push("BRIDGE","AGGREGATOR","OFF_CHAIN");let m=p.filter(S=>c.includes(S.type)),f=m.length===m.filter(S=>S.selected).length,g=i(()=>{m.forEach(S=>{f?s(S.groupTitle):S.selected||s(S.groupTitle)})},"toggleAllSources"),d=m.map(S=>{let{selected:C,groupTitle:T,logo:v,id:w,...A}=S;return{id:`widget-setting-liquidity-source-${w.toLowerCase().replace(/\s+/g,"-")}-item-btn`,start:Ve.createElement($w,{src:v,size:22,type:"circular"}),onClick:()=>{l||s(T)},end:Ve.createElement(_w,{checked:C,disabled:l}),title:Ve.createElement(Uw,{variant:"title",size:"xmedium"},Ut.t(T)),selected:C,groupTitle:T,logo:v,...A}}),h=i(S=>{let C=S.target.value;a(C)},"handleSearch"),k=d;return r&&(k=d.filter(S=>xt(S.groupTitle,r))),Ve.createElement(ne,{header:{title:Ut.t(t),suffix:Ve.createElement(wl,null,Ve.createElement(Dw,{id:`widget-liquidity-source-${f?"deselect-all":"select-all"}-btn`,variant:"ghost",size:"xsmall",onClick:g},f?Ut.t("Deselect all"):Ut.t("Select all")))}},Ve.createElement(re,{view:!0},Ve.createElement(Ct,{value:r,setValue:a,fullWidth:!0,color:"light",variant:"contained",placeholder:Ut.t("Search {sourceType}",{sourceType:u[t]}),onChange:h}),e==="loading"&&Ve.createElement(bl,null),!k.length&&r?Ve.createElement(xl,null,Ve.createElement(Ow,{title:Ut.t("No results found"),description:Ut.t("Try using different keywords")})):e==="success"&&Ve.createElement(qn,{disabled:l},k.map(S=>{let{groupTitle:C,...T}=S;return Ve.createElement(Ve.Fragment,{key:S.id},Ve.createElement(Fw,{style:{height:"61px"},...T,selected:!1,hasDivider:!0}))}))))}i(El,"LiquiditySourcePage");import{i18n as Qw}from"@lingui/core";import Ni from"react";import{useNavigate as qw}from"react-router-dom";function jf(){let t=qw(),e=Ye(),{selectedQuote:o,refetchQuote:n,setSelectedQuote:r,updateQuotePartialState:a,error:s}=z(),{fetch:l,loading:p}=Ai({refetchQuote:n}),u=i(f=>{r(f),a("refetchQuote",!1),e()},"onClickOnQuote"),c=`../${D.settings}`,m=`../${D.wallets}`;return Ni.createElement(ne,{header:{onWallet:()=>{t(m),a("refetchQuote",!0)},onBack:()=>{a("refetchQuote",!1)},title:Qw.t("Routes"),suffix:Ni.createElement(yo,{onClickRefresh:o||s?l:void 0,hidden:["notifications","history"],onClickSettings:()=>{t(c),a("refetchQuote",!0)}})}},Ni.createElement(re,null,Ni.createElement(zn,{fetch:l,loading:p,onClickOnQuote:u})))}i(jf,"RoutesPage");import{i18n as tg}from"@lingui/core";import{Divider as og,getCategoriesCount as Rw,SelectableCategoryList as ex}from"@rango-dev/ui";import zt,{useState as ng}from"react";import{useNavigate as tx}from"react-router-dom";import{i18n as Il}from"@lingui/core";import{Divider as Kw,Image as jw,ListItemButton as Xw,NotFound as Yw,Typography as eg}from"@rango-dev/ui";import it,{useEffect as Zw,useState as Jw}from"react";var Xf=i((t,e,o)=>t.filter(n=>ir(n.type,o)).filter(n=>et(n.name,e)||et(n.displayName,e)),"filterBlockchains");import{ImageContainer as Hw,styled as Yf}from"@rango-dev/ui";var Zf=Yf("div",{display:"flex",flexDirection:"column",overflow:"hidden",height:"100%",justifyContent:"center"}),Wi=Yf(Sn,{padding:0,margin:0,listStyle:"none",[`& ${Hw}`]:{borderRadius:"$xm",overflow:"hidden"}});import{ListItem as Gw,Skeleton as Jf}from"@rango-dev/ui";import Mi from"react";var Vw=20;function Rf(){return Mi.createElement(Wi,null,Array.from(Array(Vw),t=>Mi.createElement(Gw,{key:t,hasDivider:!0,start:Mi.createElement(Jf,{variant:"circular",width:35,height:35}),title:Mi.createElement(Jf,{variant:"text",size:"large",width:90})})))}i(Rf,"LoadingBlockchainList");function Al(t){let{list:e,searchedFor:o,onChange:n,blockchainCategory:r,showTitle:a=!0}=t,[s,l]=Jw(e),{fetchStatus:p}=y();Zw(()=>{l([...Xf(e,o,r)])},[e,o,r]);let u=i(()=>!s.length&&o?it.createElement(Yw,{title:Il.t("No results found"),description:Il.t("Try using different keywords")}):it.createElement(Wi,{as:"ul",key:`${r}-${o}`},s.map(c=>it.createElement(Xw,{key:`${c.name}-${c.chainId}`,className:"widget-blockchain-list-item-btn",hasDivider:!0,onClick:()=>n(c),start:it.createElement(jw,{src:c.logo,size:30}),title:it.createElement(eg,{variant:"title",size:"medium"},c.displayName),id:c.name}))),"renderList");return it.createElement(it.Fragment,null,a&&it.createElement(it.Fragment,null,it.createElement(eg,{variant:"label",size:"large"},Il.t("Select Chain")),it.createElement(Kw,{size:4})),it.createElement(Zf,null,p==="loading"&&it.createElement(Rf,null),p==="success"&&u()))}i(Al,"BlockchainList");function Li(t){let{type:e}=t,o=Ye(),[n,r]=ng(""),[a,s]=ng("ALL"),l=z.use.setToBlockchain(),p=z.use.setFromBlockchain(),{fetchStatus:u}=y(),c=tx(),m=y().blockchains({type:e}),f=Rw(m),g=!t.hideCategory&&f!==1;return zt.createElement(ne,{header:{title:tg.t("Select Chain")}},zt.createElement(re,{view:!0},g&&zt.createElement(zt.Fragment,null,zt.createElement(ex,{setCategory:s,category:a,blockchains:m,isLoading:u==="loading"}),zt.createElement(og,{size:24})),zt.createElement(Ct,{value:n,autoFocus:!0,placeholder:tg.t("Search Chain"),color:"light",variant:"contained",size:"large",setValue:()=>r(""),onChange:d=>r(d.target.value)}),zt.createElement(og,{size:16}),zt.createElement(Al,{list:m,showTitle:e!=="custom-token",searchedFor:n,blockchainCategory:a,onChange:d=>{e==="custom-token"?c(`..?blockchain=${d.name}`,{replace:!0}):(e==="source"?p(d):l(d),o())}})))}i(Li,"SelectBlockchainPage");import{i18n as Pi}from"@lingui/core";import{Divider as pg}from"@rango-dev/ui";import bo,{useState as px}from"react";import{useNavigate as cx}from"react-router-dom";import{i18n as Ml}from"@lingui/core";import{BlockchainsChip as Bi,Divider as sg,Image as lg,Skeleton as ax,Tooltip as sx,Typography as Ll}from"@rango-dev/ui";import Pe from"react";import{useEffect as rx}from"react";var rg=["ETH","COSMOS","OSMOSIS"];function Nl(t,e,o){let n=JSON.parse(JSON.stringify(t)),r=[];if(n.sort(ox),o?.limit&&t.length>o.limit){let a=o.limit,s=e;if(e.length<=o.limit){let l=o.limit-e.length;for(let p=0;p<=l;p++){let u=n[p];s=s.filter(c=>u.name!==c)}}n.sort(nx(s)),r=n.splice(a)}return{list:n,more:r}}i(Nl,"prepare");function ox(t,e){let o=rg,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(ox,"sortByMostUsedBlockchains");function nx(t){return i(function(o,n){let r=t.findIndex(p=>p===o.name),a=t.findIndex(p=>p===n.name),s=r>-1,l=a>-1;return s&&l?r>a?1:-1:t.includes(o.name)?-1:t.includes(n.name)?1:0},"sortByPreferred")}i(nx,"generateSortByPreferredBlockchainsFor");function ig(t,e){return!!e.list.find(o=>o.name===t)}i(ig,"isInVisibleList");function Wl(t,e){let{preferredBlockchains:o,addPreferredBlockchain:n}=y();rx(()=>{if(e?.selected){let a=Nl(t,o,e);ig(e.selected,a)||n(e?.selected)}},[e?.selected]);let r=Nl(t,o,e);return{list:r.list,more:r.more,history:[]}}i(Wl,"usePrepareBlockchainList");import{styled as ix}from"@rango-dev/ui";var ag=ix("div",{display:"grid",gap:"$10",gridTemplateColumns:"repeat(6, minmax(0, 1fr))"});var lx=12;function Bl(t){let{blockchains:e,type:o,blockchain:n,onChange:r,onMoreClick:a}=t,s=Wl(e,{limit:10,selected:n?.name}),{fetchStatus:l}=y(),p=z.use.resetToBlockchain(),u=z.use.resetFromBlockchain(),c=s.more.length>0,m=s.more.length===1,f=!m&&c;return Pe.createElement(Pe.Fragment,null,Pe.createElement(sg,{size:12}),Pe.createElement(Ll,{variant:"label",size:"large"},Ml.t("Select Chain")),Pe.createElement(sg,{size:12}),Pe.createElement(ag,null,l==="loading"&&Array.from(Array(lx),g=>Pe.createElement(ax,{key:g,variant:"rounded",height:50})),l==="success"&&Pe.createElement(Pe.Fragment,null,Pe.createElement(Bi,{selected:!n,onClick:()=>{o==="from"?u():p()}},Pe.createElement(Ll,{variant:"body",size:"xsmall",color:"secondary500"},Ml.t("All"))),s.list.map(g=>Pe.createElement(sx,{key:g.name,content:g.shortName,side:"bottom",sideOffset:2,container:N()},Pe.createElement(Bi,{key:g.name,selected:!!n&&n.name===g.name,onClick:()=>r(g)},Pe.createElement(lg,{src:g.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(lg,{src:s.more[0].logo,size:30})):null,f?Pe.createElement(Bi,{onClick:a,key:"more-blockchains"},Pe.createElement(Ll,{variant:"body",size:"xsmall",color:"secondary500"},Ml._("More +{count}",{count:s.more.length}))):null)))}i(Bl,"BlockchainsSection");function Pl(t){let{type:e}=t,o=cx(),n=Ye(),{fromBlockchain:r,toBlockchain:a,setFromToken:s,setToToken:l,setFromBlockchain:p,setToBlockchain:u}=z(),c=Z.use.getBalanceFor(),[m,f]=px(""),d=(e==="source"?r:a)?.name??"",h=y().blockchains({type:e}),k=y().tokens({type:e,blockchain:d,searchFor:m,getBalanceFor:c}),S=i(v=>{e==="source"?p(v):u(v)},"updateBlockchain"),C=i(v=>{e==="source"?s({token:v,meta:{blockchains:h,tokens:k}}):l({token:v,meta:{blockchains:h,tokens:k}})},"updateToken"),T={source:Pi.t("Source"),destination:Pi.t("Destination")};return bo.createElement(ne,{header:{title:Pi.t("Swap {type}",{type:T[e]})}},bo.createElement(re,null,bo.createElement(Bl,{blockchains:h,type:e=="source"?"from":"to",blockchain:e==="source"?r:a,onMoreClick:()=>o(D.blockchains),onChange:v=>{S(v)}}),bo.createElement(pg,{size:24}),bo.createElement(Ct,{value:m,autoFocus:!0,placeholder:Pi.t("Search Token"),color:"light",variant:"contained",size:"large",setValue:()=>f(""),onChange:v=>f(v.target.value)}),bo.createElement(pg,{size:16}),bo.createElement(Dn,{list:k,selectedBlockchain:d,searchedFor:m,type:e,onChange:v=>{C(v);let w=h.find(A=>v.blockchain===A.name);w&&S(w),n()}})))}i(Pl,"SelectSwapItemsPage");import{i18n as $l}from"@lingui/core";import{Alert as _x,Button as $x,styled as Fx}from"@rango-dev/ui";import Eo from"react";import{useInRouterContext as Ox,useSearchParams as Ux}from"react-router-dom";import{i18n as gg}from"@lingui/core";import{Divider as hg,InfoIcon as fx,SlippageIcon as gx,TextField as hx,Tooltip as yx,Typography as yg}from"@rango-dev/ui";import at from"react";import{Chip as ux,styled as Gn,TextField as mx}from"@rango-dev/ui";var cg=Gn("div",{paddingTop:"$5",padding:"$10 $5"}),ug=Gn("div",{display:"flex",flexWrap:"wrap",gap:"$10",[`& ${mx}`]:{flex:"1 1 0",maxWidth:"127px",minWidth:"85px"}}),mg=Gn("div",{display:"flex",justifyContent:"start",alignItems:"center",paddingBottom:"$10"}),Di=Gn("div",{maxWidth:"280px",padding:"$10"}),dg=Gn(ux,{width:"61px",flexShrink:0});import{i18n as Dl}from"@lingui/core";import{Typography as dx}from"@rango-dev/ui";import Vn from"react";function fg(){return Vn.createElement(Di,null,Vn.createElement(dx,{variant:"label",size:"medium",color:"neutral700"},Dl.t("Your transaction will be reverted if the price changes unfavorably by more than this percentage."),Vn.createElement("br",null),Vn.createElement("br",null),Vn.createElement("b",null,Dl.t("Warning")),":\xA0",Dl.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(fg,"SlippageTooltipContent");function _l(){let{slippage:t,setSlippage:e,customSlippage:o,setCustomSlippage:n}=y();return at.createElement(cg,null,at.createElement(mg,null,at.createElement(gx,{size:16,color:"gray"}),at.createElement(hg,{direction:"horizontal",size:4}),at.createElement(yg,{variant:"title",size:"xmedium"},gg.t("Slippage tolerance per swap")),at.createElement(hg,{direction:"horizontal",size:4}),at.createElement(yx,{container:N(),side:"top",sideOffset:4,content:at.createElement(fg,null)},at.createElement(fx,{color:"gray"}))),at.createElement(ug,null,Yp.map((r,a)=>{let s=`slippage-${a}`;return at.createElement(dg,{key:s,onClick:()=>{o&&n(null),e(r)},selected:!o&&r===t,label:`${r.toString()}%`})}),at.createElement(hx,{type:"number",min:"0.01",max:"30",step:"0.01",fullWidth:!0,variant:"contained",value:o===null?"":o,color:"dark",onChange:r=>{let a=r.target.value,s=parseFloat(a);s>=ec&&s<=Rp?n(s):n(null)},suffix:o&&at.createElement(yg,{variant:"body",size:"small"},"%"),placeholder:gg.t("Custom")})))}i(_l,"Slippage");import{i18n as dt}from"@lingui/core";import{AutoThemeIcon as Sg,BridgesIcon as Sx,ChevronRightIcon as _i,DarkModeIcon as Cg,Divider as Kn,ExchangeIcon as Cx,InfinityIcon as kx,InfoIcon as Tx,LanguageIcon as vx,LightModeIcon as kg,List as wx,ListItem as xx,ListItemButton as bx,Skeleton as Ex,styled as Ix,Switch as Ax,Tabs as Nx,TargetIcon as Wx,Tooltip as Mx,Typography as Re}from"@rango-dev/ui";import P from"react";import{useNavigate as Lx}from"react-router-dom";var Bx=Ix("div",{width:"202px",height:"$40"}),Px=[{id:"light",icon:P.createElement(kg,{color:"black",size:24}),tooltip:P.createElement(Re,{size:"xsmall",variant:"body"},dt.t("Light"))},{id:"dark",icon:P.createElement(Cg,{color:"black",size:24}),tooltip:P.createElement(Re,{size:"xsmall",variant:"body"},dt.t("Dark"))},{id:"auto",icon:P.createElement(Sg,{color:"black",size:24}),tooltip:P.createElement(Re,{size:"xsmall",variant:"body"},dt.t("Auto"))}],Dx=i(t=>{let e={color:"gray",size:16};switch(t){case"auto":return P.createElement(Sg,{...e});case"dark":return P.createElement(Cg,{...e});default:return P.createElement(kg,{...e})}},"getThemeIcon");function Tg(){let t=Lx(),{theme:e}=y().config,{setTheme:o,theme:n}=y(),{activeLanguage:r,languages:a}=eo(),s=a.find(B=>B.local===r)?.label,l=y().fetchStatus,p=y().swappers(),u=y().getDisabledLiquiditySources(),{config:{features:c}}=y(),m=y().customTokens(),f=je("theme",c),g=je("liquiditySource",c),d=je("language",c),h=je("customTokens",c),k=y().infiniteApprove,S=y().toggleInfiniteApprove,C=hr(p,u),T=C.filter(B=>["BRIDGE","AGGREGATOR","OFF_CHAIN"].includes(B.type)),v=T.length,w=T.filter(B=>B.selected).length,A=C.filter(B=>B.type==="DEX"),M=A.length,x=A.filter(B=>B.selected).length,E=i((B,V)=>{switch(l){case"loading":return P.createElement(Ex,{variant:"text",size:"medium",width:50});case"failed":return P.createElement(Re,{variant:"body",size:"medium",color:"$error500"},dt.t("Loading failed"));default:return P.createElement(Re,{variant:"body",size:"medium"},`${B} / ${V}`)}},"handleSwapperEndItem"),b={id:"widget-setting-bridge-item-btn",title:P.createElement(Re,{variant:"title",size:"xmedium"},dt.t("Bridges")),end:P.createElement(P.Fragment,null,E(w,v),P.createElement(Kn,{direction:"horizontal",size:8}),P.createElement(_i,{color:"black"})),onClick:()=>t(D.bridges),start:P.createElement(Sx,{color:"gray",size:16})},W={id:"widget-setting-exchange-item-btn",title:P.createElement(Re,{variant:"title",size:"xmedium"},dt.t("Exchanges")),end:P.createElement(P.Fragment,null,E(x,M),P.createElement(Kn,{direction:"horizontal",size:8}),P.createElement(_i,{color:"black"})),start:P.createElement(Cx,{color:"gray",size:16}),onClick:()=>t(D.exchanges)},$={id:"widget-setting-custom-tokens-item-btn",title:P.createElement(Re,{variant:"title",size:"xmedium"},dt.t("Custom Tokens")),end:P.createElement(P.Fragment,null,P.createElement(Re,{variant:"body",size:"medium"},`${m.length}`),P.createElement(Kn,{direction:"horizontal",size:8}),P.createElement(_i,{color:"black"})),start:P.createElement(Wx,{color:"gray",size:16}),onClick:()=>t(D.customTokens)},I={id:"widget-setting-language-item-btn",title:P.createElement(Re,{variant:"title",size:"xmedium"},dt.t("Language")),start:P.createElement(vx,{color:"gray",size:16}),end:P.createElement(P.Fragment,null,P.createElement(Re,{variant:"body",size:"medium"},s),P.createElement(Kn,{direction:"horizontal",size:8}),P.createElement(_i,{color:"black"})),onClick:()=>t(D.languages)},R={id:"widget-setting-infinite-approval-item-btn",title:P.createElement(P.Fragment,null,P.createElement(Re,{variant:"title",size:"xmedium"},dt.t("Infinite approval")),P.createElement(Kn,{direction:"horizontal",size:4}),P.createElement(Mx,{side:"top",sideOffset:4,container:N(),content:P.createElement(Di,null,P.createElement(Re,{variant:"label",size:"medium",color:"neutral700"},P.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.")))},P.createElement(Tx,{color:"gray"}))),start:P.createElement(kx,{color:"gray",size:16}),end:P.createElement(Ax,{checked:k}),onClick:S},ee={id:"widget-setting-theme-item-btn",type:P.createElement(xx,null),title:P.createElement(Re,{variant:"title",size:"xmedium"},dt.t("Theme")),end:P.createElement(Bx,null,P.createElement(Nx,{container:N(),items:Px,value:n,onChange:B=>o(B.id),type:"primary",borderRadius:"small"})),start:Dx(n)},oe=g?[]:[b,W];return h||oe.push($),d||oe.push(I),oe.push(R),!e?.singleTheme&&!f&&oe.push(ee),P.createElement(wx,{type:P.createElement(bx,{hasDivider:!0,id:"_",onClick:()=>console.log()}),items:oe})}i(Tg,"SettingsLists");var zx=Fx("div",{paddingLeft:"$8"});function vg(){let{isInCampaignMode:t,updateCampaignMode:e}=y(),o=t(),[,n]=Ux(),r=Ox(),a=i(()=>{r&&o&&(n(s=>(s.delete("liquiditySources"),s),{replace:!0}),e("liquiditySources",void 0))},"onClick");return Eo.createElement(ne,{header:{title:$l.t("Settings")}},Eo.createElement(re,null,o&&Eo.createElement(_x,{type:"info",variant:"alarm",title:$l.t("Currently, you're in campaign mode with restrictions on liquidity sources. Would you like to switch out of this mode and make use of all available liquidity sources?"),action:Eo.createElement(zx,null,Eo.createElement($x,{id:"widget-setting-exit-campaign-mode-btn",type:"secondary",size:"small",onClick:a},$l.t("Reset")))}),Eo.createElement(_l,null),Eo.createElement(Tg,null)))}i(vg,"SettingsPage");import{i18n as Ab}from"@lingui/core";import{cancelSwap as Nb}from"@rango-dev/queue-manager-rango-preset";import{useManager as Wb}from"@rango-dev/queue-manager-react";import{Alert as Mb}from"@rango-dev/ui";import ep from"react";import{useParams as Lb}from"react-router-dom";import{i18n as st}from"@lingui/core";import{getCurrentBlockchainOfOrNull as pb,getCurrentStep as cb,getRelatedWalletOrNull as ub}from"@rango-dev/queue-manager-rango-preset";import{Button as Rg,CopyIcon as mb,Divider as db,DoneIcon as fb,IconButton as gb,QuoteCost as hb,RangoExplorerIcon as yb,StepDetails as Sb,Tooltip as eh,Typography as Io,useCopyToClipboard as Cb}from"@rango-dev/ui";import{useWallets as kb}from"@rango-dev/wallets-react";import th from"bignumber.js";import{PendingSwapNetworkStatus as Gi}from"rango-types";import K,{useEffect as oh,useRef as Tb,useState as nh}from"react";import{useNavigate as vb}from"react-router-dom";import{i18n as to}from"@lingui/core";var Qx=[to.t("Sunday"),to.t("Monday"),to.t("Tuesday"),to.t("Wednesday"),to.t("Thursday"),to.t("Friday"),to.t("Saturday")];function wg(t){let e=new Date(t),o=e.getDate(),n=e.toLocaleString("default",{month:"long"}),r=e.getFullYear();return`${e.getDay()===new Date().getDay()?to.t("Today"):`${Qx[e.getDay()]} ${o} ${n} ${r}`}, ${new Date(t).toLocaleTimeString()}`}i(wg,"timeSince");function xg(t){return t.finishTime?wg(parseInt(t.finishTime)):wg(parseInt(t.creationTime))}i(xg,"getSwapDate");import{PendingSwapNetworkStatus as Oi}from"rango-types";import Ui from"react";import{i18n as $i}from"@lingui/core";import{Button as bg,Divider as Fl,MessageBox as qx}from"@rango-dev/ui";import oo from"react";var Eg=i(({onCancel:t,onClose:e})=>oo.createElement(oo.Fragment,null,oo.createElement(Fl,{size:20}),oo.createElement(qx,{type:"error",title:$i.t("Cancel Swap"),description:$i.t("Are you sure you want to cancel this swap?")}),oo.createElement(Fl,{size:32}),oo.createElement(bg,{variant:"contained",id:"widget-swap-details-modal-cancel-swap-yes-btn",type:"primary",size:"large",onClick:t},$i.t("Yes, Cancel it")),oo.createElement(Fl,{size:12}),oo.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 Fi}from"@lingui/core";import{Button as Ig,Divider as Ol,MessageBox as Hx,Typography as Gx}from"@rango-dev/ui";import Qt from"react";var Ag=i(({onDelete:t,onClose:e})=>Qt.createElement(Qt.Fragment,null,Qt.createElement(Ol,{size:20}),Qt.createElement(Hx,{type:"error",title:Fi.t("Delete Transaction"),description:Fi.t("Are you sure you want to delete this swap?")}),Qt.createElement(Ol,{size:32}),Qt.createElement(Ig,{id:"widget-swap-details-modal-delete-swap-yes-btn",variant:"contained",type:"primary",size:"large",onClick:t},Fi.t("Yes, Delete it")),Qt.createElement(Ol,{size:12}),Qt.createElement(Ig,{id:"widget-swap-details-modal-delete-swap-no-btn",variant:"outlined",type:"primary",size:"large",onClick:e},Qt.createElement(Gx,{variant:"title",size:"medium",color:"primary"},Fi.t("No, Cancel")))),"DeleteContent");import{i18n as Ul}from"@lingui/core";import{PendingSwapNetworkStatus as zl}from"rango-types";var Ql={[zl.WaitingForNetworkChange]:{type:"loading",title:Ul.t("Change Network")},[zl.WaitingForConnectingWallet]:{type:"warning",title:Ul.t("Connect Wallet")},[zl.NetworkChanged]:{type:"success",title:Ul.t("Network Changed")}};import{warn as Vx}from"@rango-dev/logging-core";import{MessageBox as Kx,Wallet as jx}from"@rango-dev/ui";import{useWallets as Xx}from"@rango-dev/wallets-react";import Ro,{useState as Yx}from"react";import{styled as Ng}from"@rango-dev/ui";var Wg=Ng("div",{display:"flex",justifyContent:"center"}),$2=Ng("div",{maxWidth:280,"& ._typography":{wordWrap:"break-word",display:"block"}});var Mg=i(t=>{let{type:e,title:o,currentStepWallet:n,message:r,showWalletButton:a,walletButtonDisabled:s}=t,[l,p]=Yx(),{getWalletInfo:u,state:c}=Xx(),m=n?.walletType,f=m?pn(c(m)):null,g=m?u(m):null,d=a&&!!m&&!!f&&!!g,{list:h}=ft(),k=i(()=>{if(m){let S=h.find(C=>C.type===m);S?p(S):Vx(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(Kx,{type:e,title:o,description:r}),d&&Ro.createElement(Wg,null,Ro.createElement(jx,{container:N(),title:g.name,image:g.img,type:m,state:f,link:g.installLink,disabled:s,onClick:k})),Ro.createElement(mo,{wallet:l,onClose:()=>{p(void 0)}}))},"WalletStateContent");function ql(t){let{state:e,onClose:o,onDelete:n,onCancel:r,currentStepWallet:a,message:s,walletButtonDisabled:l}=t,p=e===Oi.WaitingForNetworkChange||e===Oi.WaitingForConnectingWallet||e===Oi.NetworkChanged;return Ui.createElement(J,{open:!!e,onClose:o,container:document.getElementById($e.SWAP_BOX_ID)||document.body},p&&Ui.createElement(Mg,{type:Ql[e].type,title:Ql[e].title,currentStepWallet:a,message:s,walletButtonDisabled:l,showWalletButton:e!==Oi.WaitingForNetworkChange}),e==="delete"&&Ui.createElement(Ag,{onClose:o,onDelete:n}),e==="cancel"&&Ui.createElement(Eg,{onClose:o,onCancel:r}))}i(ql,"SwapDetailsModal");import{i18n as jn}from"@lingui/core";import{Button as Hl,Divider as zi,MessageBox as Lg,TokenAmount as Zx,Typography as Gl}from"@rango-dev/ui";import Oe from"react";import{useNavigate as Jx}from"react-router-dom";function Vl(t){let{open:e,onClose:o,status:n,priceValue:r,usdValue:a,realUsdValue:s,realValue:l,token:p,chain:u,percentageChange:c,description:m,diagnosisUrl:f}=t,g=Jx();return Oe.createElement(J,{open:e,onClose:o,container:document.getElementById($e.SWAP_BOX_ID)||document.body},n==="success"?Oe.createElement(Lg,{type:"success",title:jn.t("Swap Successful")},Oe.createElement(Zx,{direction:"vertical",tooltipContainer:N(),type:"output",centerAlign:!0,price:{value:r,usdValue:a,realUsdValue:s,realValue:l},token:p,chain:u,percentageChange:c}),Oe.createElement(zi,{size:12}),Oe.createElement(Gl,{variant:"body",size:"medium",color:"neutral700",align:"center"},m)):Oe.createElement(Lg,{type:"error",title:jn.t("Transaction Failed"),description:m}),Oe.createElement(zi,{size:32}),n==="success"&&Oe.createElement(Hl,{id:"widget-swap-details-modal-done-btn",variant:"contained",type:"primary",size:"large",onClick:()=>{g("../../")}},Oe.createElement(Gl,{variant:"title",size:"medium",color:"neutral100"},jn.t("Done"))),Oe.createElement(zi,{size:12}),f&&Oe.createElement(Oe.Fragment,null,Oe.createElement(Hl,{variant:"contained",id:"widget-swap-detail-modal-diagnosis-btn",type:"primary",size:"large",onClick:()=>window.open(f,"_blank")},jn.t("Diagnosis")),Oe.createElement(zi,{size:12})),Oe.createElement(Hl,{id:"widget-swap-details-modal-see-details-btn",variant:"outlined",type:"primary",size:"large",onClick:o},Oe.createElement(Gl,{variant:"title",size:"medium",color:"primary"},jn.t("See Details"))))}i(Vl,"SwapDetailsCompleteModal");import lb from"react";import{i18n as rb}from"@lingui/core";import{Alert as Xg,IconButton as ib,LinkIcon as ab}from"@rango-dev/ui";import no,{Fragment as sb}from"react";import{Alert as eb,ChevronDownIcon as tb,IconButton as ob}from"@rango-dev/ui";import tn,{useState as nb}from"react";import{css as Xn,darkTheme as Bg,styled as qt,Typography as Rx}from"@rango-dev/ui";var Pg=qt("div",{display:"flex",flexDirection:"column",flexGrow:1,overflow:"hidden"}),Qi=qt("div",{width:"100%","& ._icon-button":{"&:hover":{"& svg":{color:"$secondary550",[`.${Bg} &`]:{color:"$secondary500"}}}}}),Dg=qt(Sn,{padding:"$0 $20 $20 $20"}),k5=qt("div",{display:"flex",flexDirection:"column",gap:"$10"}),_g=qt("div",{height:"450px",display:"flex",alignItems:"center",justifyContent:"center"}),T5=qt("div",{display:"flex",justifyContent:"center",width:"100%",paddingTop:"33%",flex:1}),en=Xn({display:"flex",width:"100%",justifyContent:"space-between",alignItems:"center",padding:"$10 $20",borderBottom:"1px solid",$$color:"$colors$neutral300",[`.${Bg} &`]:{$$color:"$colors$neutral400"},borderColor:"$$color",color:"$neutral500"}),$g=Xn({padding:"$5 0"}),qi=Xn({display:"flex",justifyContent:"center",alignItems:"center",height:"$24"}),Fg=Xn({display:"flex",width:"100%",padding:"$15 $20 $20",flexDirection:"column",alignItems:"start"}),Og=Xn({width:"100%",padding:"0 $20 $10"}),Ug=qt("a",{fontSize:"$16",fontWeight:"$400",color:"$neutral700",display:"flex",alignItems:"center",justifyContent:"center"}),zg=qt("div",{display:"flex",flexDirection:"column",gap:"$5"}),Hi=qt(Rx,{wordBreak:"break-word"});import{styled as Kl}from"@rango-dev/ui";var Qg=Kl("div",{display:"flex",flexDirection:"column",gap:"$10"}),qg=Kl("div",{transition:"transform 0.3s ease-in-out",variants:{rotated:{true:{transform:"rotate(180deg)"}}}}),Hg=Kl("div",{transition:"max-height 0.3s ease-in-out",maxHeight:"0px",overflow:"hidden",variants:{open:{true:{maxHeight:"200px"}}}});function Gg(t){let{message:e}=t,[o,n]=nb(!1);return tn.createElement(eb,{type:"error",title:e.shortMessage,containerStyles:{"& .footer":{paddingTop:"$0"}},action:e.detailedMessage.content&&tn.createElement(ob,{onClick:()=>n(r=>!r),variant:"ghost",size:"xsmall"},tn.createElement(qg,{rotated:o},tn.createElement(tb,{size:12,color:"gray"}))),footer:tn.createElement(Hg,{open:o},tn.createElement(Hi,{variant:"body",size:"xsmall",color:"neutral700"},e.detailedMessage.content))})}i(Gg,"FailedAlert");import{i18n as Vg}from"@lingui/core";import{Alert as jl,Button as Kg}from"@rango-dev/ui";import{PendingSwapNetworkStatus as Xl}from"rango-types";import Yn from"react";function jg(t){let{switchNetwork:e,setNetworkModal:o,message:n,showNetworkModal:r}=t;return e?Yn.createElement(jl,{type:"warning",title:n.shortMessage,action:Yn.createElement(Kg,{id:"widget-swap-details-warning-alert-change-network-btn",size:"xxsmall",type:"warning",onClick:()=>{o(Xl.WaitingForNetworkChange),e().catch(a=>{console.log(a)})}},Vg.t("Change"))}):r===Xl.WaitingForConnectingWallet?Yn.createElement(jl,{type:"warning",title:n.shortMessage,action:Yn.createElement(Kg,{id:"widget-swap-details-warning-alert-connect-wallet-btn",size:"xxsmall",type:"warning",onClick:()=>{o(Xl.WaitingForConnectingWallet)}},Vg.t("Connect"))}):Yn.createElement(jl,{type:"warning",title:n.shortMessage})}i(jg,"WarningAlert");function Yl(t){let{switchNetwork:e,showNetworkModal:o,setNetworkModal:n,message:r,step:a,hasAlreadyProceededToSign:s}=t,l=gn(a),p=a.status==="waitingForApproval"&&!l,u=a.status==="running"&&!l,c=u&&!s||p&&!a.explorerUrl?.length;return no.createElement(Qg,null,a.explorerUrl?.map((m,f,g)=>{let d=f+m.url,h=f===g.length-1,k=(h&&u||p)&&!c,S=h&&a.status==="failed";return no.createElement(sb,{key:d},no.createElement(Xg,{type:h&&(k&&"loading"||S&&"error")||"success",title:m.description?`${m.description} Tx`:rb.t("View transaction"),action:m.url&&no.createElement(ib,{id:"widget-swap-details-tx-link-icon-btn",variant:"ghost",size:"xsmall",onClick:()=>window.open(m.url,"_blank")},no.createElement(ab,{size:12}))}))}),c&&no.createElement(Xg,{type:"loading",title:r.shortMessage}),a.status!=="failed"&&l&&no.createElement(jg,{switchNetwork:e,showNetworkModal:o,setNetworkModal:n,message:r}),a.status==="failed"&&no.createElement(Gg,{message:r}))}i(Yl,"SwapDetailsAlerts");var Yg=2e3;var Zg=i(({swap:t,blockchains:e,swappers:o,...n})=>{let r=t.hasAlreadyProceededToSign!==!1;return t.steps.map((a,s)=>{let l=s===0?t.inputAmount:t.steps[s-1].outputAmount||t.steps[s-1].expectedOutputAmountHumanReadable;return{from:{token:{displayName:a.fromSymbol,image:a.fromLogo??""},chain:{displayName:pt(a.fromBlockchain,e)??"",image:a.fromBlockchainLogo??""},price:{value:L(l,6,6),realValue:l??""}},to:{token:{displayName:a.toSymbol,image:a.toLogo},chain:{displayName:pt(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(p=>({from:{chain:{displayName:pt(p.fromBlockchain,e)??"",image:p.fromBlockchainLogo??""}},to:{chain:{displayName:pt(p.toBlockchain,e)??"",image:p.toBlockchainLogo??""}},swapper:{displayName:on(p.swapperId,o)??"",image:p.swapperLogo??"",type:p.swapperType}})):[],alerts:lb.createElement(Yl,{step:a,hasAlreadyProceededToSign:r,...n})}})},"getSteps");function Jg(t){if(gn(t)&&t.status!=="failed"&&t.status!=="success")return"warning";switch(t.status){case"created":return"default";case"approved":case"waitingForApproval":case"running":return"in-progress";case"failed":return"error";case"success":return"completed"}}i(Jg,"getStepState");function Zl(t){let{swap:e,requestId:o,onDelete:n,onCancel:r}=t,{canSwitchNetworkTo:a,connect:s,getWalletInfo:l}=kb(),p=y().blockchains(),u=y().swappers(),{findToken:c}=y(),m=z.use.retry(),f=se.use.isActiveTab(),g=vb(),[d,h]=Cb(Yg),k=Tb(null),[S,C]=nh(null),[T,v]=nh(null),w=i(()=>{r(),C(null)},"onCancel"),A=xe.use.getNotifications(),M=xe.use.removeNotification(),x=A(),E=cb(e),b=E?.networkStatus;oh(()=>{x.find(he=>he.requestId===e.requestId)&&(e.status==="success"||e.status==="failed"?(v(e.status),M(e.requestId)):T&&v(null))},[e.status,e.requestId]),oh(()=>{B?C(Gi.WaitingForNetworkChange):b===Gi.WaitingForConnectingWallet||b===Gi.NetworkChanged?C(b):C(null)},[b]);let W=jc(e),$=E?pb(e,E):null,I=E?ub(e,E):null,R=xg(e),ee=Xc(e),oe=i(de=>!!l(de)?.mobileWallet,"isMobileWallet"),B=b===Gi.WaitingForNetworkChange&&!!$&&!!I?.walletType&&(oe(I.walletType)||a(I.walletType,$)),V=B?s.bind(null,I.walletType,$):void 0,le=Kc(e,E),Y=Zg({swap:e,switchNetwork:V,showNetworkModal:b,setNetworkModal:C,message:le,blockchains:p,swappers:u}),ae=Y.length,[ge,ve]=[e.steps[0],e.steps[ae-1]],U=ve.outputAmount||ve.expectedOutputAmountHumanReadable,Ke=e.steps.reduce((de,he)=>de+parseFloat(he.feeInUsd||""),0),vt=e.steps.find(de=>de.diagnosisUrl)?.diagnosisUrl,lt=L(parseFloat(U||"0")*(ve.toUsdPrice||0),4,4),wt=L(parseFloat(e.inputAmount)*(ge.fromUsdPrice||0),4,4),_=U?new th(U).multipliedBy(ve.toUsdPrice||0).toString():"",Q=new th(e.inputAmount).multipliedBy(ge.fromUsdPrice||0).toString(),G=ct(wt,lt),pe=le.detailedMessage.content||le.shortMessage,ce=e.status==="success"?st.t({id:"You have received {amount} {token} in {conciseAddress} wallet on {chain} chain.",values:{amount:L(U,6,6),token:Y[ae-1].to.token.displayName,conciseAddress:dr(e.wallets[Y[ae-1].to.chain.displayName]?.address||""),chain:Y[ae-1].to.chain.displayName}}):K.createElement(zg,null,K.createElement(Io,{variant:"body",size:"medium",color:"neutral700",align:"center"},pe?"":st.t("Transaction was not sent."),W?`${st.t({id:"{amount} {symbol} on {blockchain} remains in your wallet.",values:{amount:W.outputAmount,symbol:W.symbol,blockchain:W.blockchain}})}`:""),pe&&K.createElement(Hi,{align:"center",variant:"body",size:"medium",color:"neutral700"},K.createElement("b",null,"Reason:")," ",pe));return K.createElement(ne,{header:{title:st.t("Swap Details"),onCancel:e.status==="running"?()=>C("cancel"):void 0,suffix:e.status!=="running"&&K.createElement(Vt,null,K.createElement(Rg,{id:"widget-swap-details-delete-btn",variant:"ghost",type:"error",size:"xsmall",onClick:()=>C("delete")},K.createElement(Io,{size:"medium",variant:"label",color:"error"},st.t("Delete"))))},footer:ee&&!T&&K.createElement(Rg,{fullWidth:!0,id:"widget-swap-details-try-again-btn",variant:"contained",type:"primary",size:"large",onClick:()=>{let de=Br(e,p,c);m(de),setTimeout(()=>{g("../../")},0)}},st.t("Try again"))},K.createElement(re,{compact:!0,view:!0},K.createElement(Qi,null,K.createElement("div",{className:en()},K.createElement(Io,{variant:"label",size:"large",color:"neutral700"},`${st.t("Request ID")}`),K.createElement("div",{className:qi()},K.createElement(Io,{variant:"label",size:"small",color:"neutral700"},o),K.createElement(eh,{container:N(),content:d?st.t("Copied To Clipboard"):st.t("Copy Request ID"),open:d||void 0,side:"bottom",alignOffset:-16,align:"end"},K.createElement(gb,{id:"widget-swap-details-done-copy-icon-btn",variant:"ghost",onClick:h.bind(null,o||"")},d?K.createElement(fb,{size:16,color:"secondary"}):K.createElement(mb,{size:16,color:"gray"}))),K.createElement(Ug,{target:"_blank",href:`${gp}/swap/${o}`},K.createElement(eh,{container:N(),content:st.t("View on Rango Explorer"),side:"bottom"},K.createElement(yb,{size:20}))))),K.createElement("div",{className:en()},K.createElement(Io,{variant:"label",size:"large",color:"neutral700"},e.finishTime?st.t("Finished at"):st.t("Created at")),K.createElement(Io,{variant:"label",size:"small",color:"neutral700"},R))),K.createElement("div",{className:Fg()},K.createElement(hb,{fee:L(String(Ke),2,2),time:sn(ar(e.steps)),steps:ae}),K.createElement(En,{from:{price:{value:L(e.inputAmount,6,6),usdValue:wt,realUsdValue:Q,realValue:e.inputAmount},token:{displayName:Y[0].from.token.displayName,image:Y[0].from.token.image},chain:{image:Y[0].from.chain.image,displayName:Y[0].from.chain.displayName}},to:{price:{value:L(U,6,6),usdValue:lt,realUsdValue:_,realValue:U||""},token:{displayName:Y[ae-1].to.token.displayName,image:Y[ae-1].to.token.image},chain:{image:Y[ae-1].to.chain.image,displayName:Y[ae-1].to.chain.displayName}},percentageChange:L(G,2,2),warningLevel:Pt(G??0)})),K.createElement("div",{className:Og()},K.createElement(Io,{variant:"title",size:"small"},st.t("Swaps steps"))),K.createElement(db,{size:8}),K.createElement(Dg,{ref:k},Y.map((de,he)=>{let Rn=he,ro=Jg(e.steps[he]),ea=ro==="error"||ro==="in-progress"||ro==="warning"||ro==="completed"&&he===Y.length-1;return K.createElement(Sb,{key:Rn,step:de,type:"swap-progress",ref:k,state:ro,hasSeparator:he!==0,tabIndex:Rn,isFocused:ea,tooltipContainer:N()})}))),K.createElement(ql,{state:S,onClose:()=>C(null),onCancel:w,onDelete:n,message:le.detailedMessage.content,currentStepWallet:I,walletButtonDisabled:!f}),K.createElement(Vl,{open:!!T,diagnosisUrl:vt,onClose:()=>v(null),status:e.status==="success"?"success":"failed",priceValue:L(U,6,6),usdValue:lt,realUsdValue:_,realValue:U||"",percentageChange:L(G,2,2),token:{displayName:Y[ae-1].to.token.displayName,image:Y[ae-1].to.token.image},chain:{image:Y[ae-1].to.chain.image},description:ce}))}i(Zl,"SwapDetails");import{i18n as Ki}from"@lingui/core";import{Divider as ah,NotFound as Ib,Skeleton as Jn,Typography as ji}from"@rango-dev/ui";import ke from"react";import{i18n as wb}from"@lingui/core";import{Divider as xb,Skeleton as bb,Typography as Eb}from"@rango-dev/ui";import Te from"react";import{css as Tt,styled as Jl}from"@rango-dev/ui";var rh=Jl("div",{width:"100%",height:"100%",padding:"$10 $20"}),Zn=Jl("div",{backgroundColor:"$neutral100",borderRadius:"$xm",padding:"$10 $15"}),Vi=Jl("div",{width:"0px",height:"$20",borderLeft:"1px dashed $neutral700",marginLeft:"25px"}),B4=Tt({display:"flex",justifyContent:"space-between",alignItems:"center"}),P4=Tt({display:"flex",justifyContent:"space-between",alignItems:"center"}),D4=Tt({paddingTop:"$15",display:"flex"}),_4=Tt({padding:"$15 $0"}),$4=Tt({width:"0px",height:"$16",borderLeft:"1px solid $neutral400",marginLeft:"13px"}),F4=Tt({paddingBottom:"$10"}),O4=Tt({display:"flex",justifyContent:"start",alignItems:"center"}),U4=Tt({paddingTop:"$5",display:"flex",alignItems:"center"}),z4=Tt({display:"flex",alignItems:"center"}),Q4=Tt({padding:"$4 $6",display:"flex",justifyContent:"center",alignItems:"center"}),ih=Tt({display:"flex",paddingTop:"$10",paddingBottom:"$5"});function Rl(){return Te.createElement(rh,null,Te.createElement(Nn,{type:"swap-preview"}),Te.createElement("div",{className:"swaps-steps"},Te.createElement(Eb,{variant:"title",size:"small"},wb.t("Swaps steps"))),Te.createElement(Te.Fragment,null,Te.createElement(Zn,null,Te.createElement(Wt,{separator:!1}),Te.createElement("div",{className:ih()},Te.createElement(xb,{direction:"horizontal",size:20}),Te.createElement(bb,{height:22,variant:"rectangular"}))),Te.createElement(Vi,null),Te.createElement(Zn,null,Te.createElement(Wt,{separator:!1})),Te.createElement(Vi,null),Te.createElement(Zn,null,Te.createElement(Wt,{separator:!1})),Te.createElement(Vi,null),Te.createElement(Zn,null,Te.createElement(Wt,{separator:!1}))))}i(Rl,"LoadingSwapDetails");function sh(t){let{requestId:e,showSkeleton:o}=t;return ke.createElement(ne,{header:{title:Ki.t("Swap Details"),suffix:ke.createElement(Vt,null)}},o&&ke.createElement(Pg,null,ke.createElement(Qi,null,ke.createElement("div",{className:en()},ke.createElement(ji,{variant:"label",size:"large",color:"neutral700"},`${Ki.t("Request ID")}`),ke.createElement("div",{className:qi()},ke.createElement(ji,{variant:"label",size:"small",color:"neutral700"},ke.createElement(Jn,{width:60,height:10,variant:"rounded"})),ke.createElement(ah,{direction:"horizontal",size:4}),ke.createElement(Jn,{width:16,height:16,variant:"rectangular"}),ke.createElement(ah,{direction:"horizontal",size:4}),ke.createElement(Jn,{width:16,height:16,variant:"rectangular"}))),ke.createElement("div",{className:en()},ke.createElement(ji,{className:$g(),variant:"label",size:"large",color:"neutral700"},ke.createElement(Jn,{width:60,height:10,variant:"rounded"})),ke.createElement(ji,{variant:"label",size:"small",color:"neutral700"},ke.createElement(Jn,{width:60,height:10,variant:"rounded"})))),ke.createElement(Rl,null)),!o&&ke.createElement(_g,null,ke.createElement(Ib,{title:Ki.t("Not found"),description:Ki.t({id:"Swap with request ID = {requestId} not found.",values:{requestId:e}})})))}i(sh,"SwapDetailsPlaceholder");function lh(){let{manager:t,state:e}=Wb(),o=!e.loadedFromPersistor,n=ut(t),{requestId:r}=Lb(),a=Ye(),{fetchStatus:s}=y();if(!r)return ep.createElement(Mb,{containerStyles:{margin:"20px"},type:"error",title:Ab.t("The request ID is necessary to display the swap details.")});let l=o||s==="loading",p=r?n.find(({swap:f})=>f.requestId===r):void 0,u=i(()=>{if(p?.id){let f=t?.get(p.id);f&&Nb(f)}},"onCancel"),c=i(async()=>{if(p?.id)try{t?.deleteQueue(p.id),a()}catch(f){console.log(f)}},"onDelete"),m=p?.swap;return!m||l?ep.createElement(sh,{requestId:r,showSkeleton:l}):ep.createElement(Zl,{swap:m,requestId:r,onCancel:u,onDelete:c})}i(lh,"SwapDetailsPage");import{i18n as ph}from"@lingui/core";import{Divider as Bb,getCategoriesCount as Pb,SelectableCategoryList as Db,styled as uh,Typography as _b,Wallet as $b}from"@rango-dev/ui";import Lt,{useState as ch}from"react";var Fb=uh("div",{display:"flex",justifyContent:"center",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5"}),Ob=uh(re,{textAlign:"center"});function mh(){let{fetchStatus:t}=y(),[e,o]=ch("ALL"),n=y().blockchains(),{config:r}=y(),[a,s]=ch(),l=se.use.isActiveTab(),{list:p}=ft(),u=Op(p,n),m=Pb(u)!==1,f=Up(p,e),g=i(d=>{Ep(p,r.multiWallets)||s(d)},"handleWalletItemClick");return Lt.createElement(ne,{header:{title:ph.t("Connect Wallets")}},Lt.createElement(Ob,null,m&&Lt.createElement(Lt.Fragment,null,Lt.createElement(Db,{setCategory:o,category:e,blockchains:u,isLoading:t==="loading"}),Lt.createElement(Bb,{size:24})),Lt.createElement(_b,{variant:"title",size:"xmedium",align:"center"},ph.t("Choose a wallet to connect.")),Lt.createElement(Fb,null,f.map((d,h)=>{let k=`wallet-${h}-${d.type}`;return Lt.createElement($b,{key:k,...d,container:N(),onClick:()=>g(d),isLoading:t==="loading",disabled:!l})}),Lt.createElement(mo,{wallet:a,onClose:()=>{s(void 0)}}))))}i(mh,"WalletsPage");function dh(){return iu(),za(),Ub([{path:D.home,element:De.createElement(qf,null)},{path:D.routes,element:De.createElement(jf,null)},{path:D.fromSwap,children:[{index:!0,element:De.createElement(Pl,{type:"source"})},{path:D.blockchains,element:De.createElement(Li,{type:"source"})}]},{path:D.toSwap,children:[{index:!0,element:De.createElement(Pl,{type:"destination"})},{path:D.blockchains,element:De.createElement(Li,{type:"destination"})}]},{path:D.settings,children:[{index:!0,element:De.createElement(vg,null)},{path:D.languages,element:De.createElement(Gf,null)},{path:D.exchanges,element:De.createElement(El,{sourceType:"Exchanges"})},{path:D.bridges,element:De.createElement(El,{sourceType:"Bridges"})},{path:D.customTokens,children:[{index:!0,element:De.createElement(ef,null)},{path:D.addCustomTokens,children:[{index:!0,element:De.createElement(Uu,null)},{path:D.blockchains,element:De.createElement(Li,{hideCategory:!0,type:"custom-token"})}]}]}]},{path:D.swaps,children:[{index:!0,element:De.createElement(Tf,null)},{path:D.swapDetails,element:De.createElement(lh,null)}]},{path:D.wallets,element:De.createElement(mh,null)},{path:D.confirmSwap,element:De.createElement(Fd,null)}])}i(dh,"AppRoutes");import{useQueueManager as Xb}from"@rango-dev/queue-manager-rango-preset";import{splitWalletNetwork as Yb}from"@rango-dev/wallets-shared";import{isEvmBlockchain as Zb}from"rango-sdk";import{useContext as Jb,useEffect as kh,useState as Th}from"react";import{globalCss as zb}from"@rango-dev/ui";var fh=i(()=>zb({"@import":"url('https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap')"})(),"globalFont");function gh(){let{setWatermark:t}=se();return{fetchApiConfig:i(async()=>{let o=await fetch(`${Bt("BASE_URL")}/meta/dapp/config?apiKey=${Bt("API_KEY")}`);if(!o.ok)throw new Error(`Request failed with status: ${o.status} `);let n=await o.json();t(n.config.watermark)},"fetchApiConfig")}}i(gh,"useFetchApiConfig");import{useWallets as Qb}from"@rango-dev/wallets-react";import{useEffect as qb,useRef as Hb}from"react";function hh(){let{connect:t,state:e}=Qb(),o=Hb({}),{fetchStatus:n}=y(),r=new URLSearchParams(location.search).get("autoConnect")||"",a=e(r);qb(()=>{n==="success"&&r&&a.installed&&!a.connecting&&!a.connected&&!o.current[r]&&(o.current[r]=!0,t(r))},[a,n])}i(hh,"useForceAutoConnect");import{isApprovalTX as Gb,RouteEventType as yh,StepEventType as Sh,StepExecutionEventStatus as Vb,WidgetEvents as Xi}from"@rango-dev/queue-manager-rango-preset";import{useEffect as Ch}from"react";function tp(){let t=Z.use.connectedWallets(),e=Z.use.getWalletsDetails(),o=xe.use.setNotification(),{findToken:n}=y();Ch(()=>{let r=i(a=>{let{event:s,step:l,route:p}=a;if(s.type===Sh.TX_EXECUTION&&s.status===Vb.TX_SENT&&!Gb(l)||s.type===Sh.SUCCEEDED){let c=t.find(f=>f.chain===l?.fromBlockchain),m=l?.fromBlockchain!==l?.toBlockchain&&t.find(f=>f.chain===l?.toBlockchain);c&&e([c],n),m&&e([m],n)}o(s,p)},"handleStepEvent");return ye.on(Xi.StepEvent,r),()=>ye.off(Xi.StepEvent,r)},[ye,t]),Ch(()=>{let r=i(a=>{let{event:s,route:l}=a;(s.type===yh.FAILED||s.type===yh.SUCCEEDED)&&o(s,l)},"handleRouteEvent");return ye.on(Xi.RouteEvent,r),()=>ye.off(Xi.RouteEvent,r)},[ye])}i(tp,"useSubscribeToWidgetEvents");import{useManager as Kb}from"@rango-dev/queue-manager-react";import{useEffect as jb}from"react";function op(){let{isSynced:t,syncNotifications:e}=xe(),{manager:o,state:n}=Kb();jb(()=>{xe.persist.hasHydrated()&&n.loadedFromPersistor&&!t&&e(ut(o))},[xe.persist.hasHydrated(),n.loadedFromPersistor,t])}i(op,"useSyncNotifications");function np(){hh(),fh(),tp(),op();let t=y().blockchains(),{canSwitchNetworkTo:e}=Zr(),[o,n]=Th(""),[r,a]=Th(),s=Jb(Er),l=t.filter(Zb),{fetchApiConfig:p}=gh();kh(()=>()=>ru(),[]),Xb({lastConnectedWallet:o,clearDisconnectedWallet:()=>{a(void 0)},disconnectedWallet:r,evmChains:l,canSwitchNetworkTo:e}),kh(()=>(lo.init(),xe.persist.hasHydrated()||xe.persist.rehydrate(),s.onConnectWallet(n),s.onDisconnectWallet(u=>{a(u),u===Yb(o)?.[0]&&n("")}),p().catch(console.log),lo.destroy),[])}i(np,"useBootstrap");import{styled as Rb}from"@rango-dev/ui";var vh=Rb("div",{fontFamily:"$widget",boxSizing:"border-box",textAlign:"left","& *, *::before, *::after":{boxSizing:"inherit"},"& *:focus-visible":{outlineColor:"$info500",transition:"none"},"& ul, ol, li":{listStyleType:"none"}});function Yi(){np();let{config:t}=y(),{activeTheme:e}=Qo(t?.theme||{}),{activeLanguage:o}=eo();return rp.createElement(eE,{language:o},rp.createElement(vh,{id:"swap-container",className:e()},rp.createElement(dh,null)))}i(Yi,"Main");import{setSolanaSignerConfig as kE}from"@rango-dev/signer-solana";import ap,{useEffect as Ah,useMemo as TE}from"react";import{useState as tE}from"react";var oE=i(()=>{let[t,e]=tE(null),o=i(a=>{let s=document.createElement("link");return s.href=a,s.rel="stylesheet",document.head.appendChild(s),s},"loadFont"),n=i(()=>{t&&(document.head.removeChild(t),e(null))},"unloadFont");return{handleLoadCustomFont:i(a=>{n();let s=bp(a);if(s){let l=o(s);e(l)}},"handleLoadCustomFont")}},"useFontLoader"),wh=oE;import{checkWaitingForNetworkChange as nE,makeQueueDefinition as rE}from"@rango-dev/queue-manager-rango-preset";import{Provider as iE}from"@rango-dev/queue-manager-react";import{useWallets as aE}from"@rango-dev/wallets-react";import{convertEvmBlockchainMetaToEvmChainInfo as sE}from"@rango-dev/wallets-shared";import{isEvmBlockchain as lE}from"rango-types";import pE,{useMemo as cE}from"react";function uE(t){let{providers:e,getSigners:o,state:n,connect:r,canSwitchNetworkTo:a,getWalletInfo:s}=aE(),l=cE(()=>rE({API_KEY:t.apiKey||Bt("API_KEY"),BASE_URL:Bt("BASE_URL"),emitter:{emit:ye.emit}}),[t.apiKey]),p=y().blockchains(),c={blockchains:Z.use.connectedWallets().map(T=>({accounts:[T],name:T.chain}))},m=i(async(T,v)=>{if(a(T,v))return r(T,v)},"switchNetwork"),f=i(T=>!!s(T).mobileWallet,"isMobileWallet"),g=p.filter(T=>T.enabled).reduce((T,v)=>(T[v.name]=v,T),{}),d=p.filter(lE),h=i(T=>{let{supportedChains:v}=s(T);return pr(v)},"getSupportedChainNames"),k=e(),S={meta:{blockchains:g,evmBasedChains:d,evmNetworkChainInfo:sE(d),getSupportedChainNames:h},getSigners:o,wallets:c,providers:k,switchNetwork:m,canSwitchNetworkTo:a,connect:r,state:n,isMobileWallet:f},C=se.use.isActiveTab();return pE.createElement(iE,{queuesDefs:[l],context:S,onPersistedDataLoaded:T=>{nE(T)},isPaused:!C},t.children)}i(uE,"QueueManager");var xh=uE;import{useManager as hE}from"@rango-dev/queue-manager-react";import yE,{createContext as SE,useContext as CE}from"react";function bh(){let{findToken:t}=y(),e=y().blockchains(),o=y().tokens(),{setFromBlockchain:n,setFromToken:r,setToBlockchain:a,setToToken:s,setInputAmount:l}=z();return i(u=>{let{fromBlockchain:c,fromToken:m,toBlockchain:f,toToken:g,requestAmount:d}=u,h={blockchains:e,tokens:o};if(c!==void 0){let k=e.find(S=>S.name===c)??null;n(k)}if(m!==void 0){let k=m?t(m)??null:null;r({meta:h,token:k})}if(f!==void 0){let k=e.find(S=>S.name===f)??null;a(k)}if(g!==void 0){let k=g?t(g)??null:null;s({meta:h,token:k})}d!==void 0&&l(d)},"updateQuoteInputs")}i(bh,"useUpdateQuoteInputs");import{cancelSwap as mE,getCurrentBlockchainOfOrNull as dE,getCurrentStep as fE,getRelatedWalletOrNull as gE}from"@rango-dev/queue-manager-rango-preset";var Zi=class{static{i(this,"WidgetHistory")}constructor(e,o){this.manager=e,this.actions=o}getAllSwaps(){return ut(this.manager)}getCurrentStep(e){return this.getCurrentStepInfo(e).step}getCurrentStepWallet(e){return this.getCurrentStepInfo(e).wallet}getCurrentStepNetwork(e){return this.getCurrentStepInfo(e).network}retry(e,o){let n=Br(e,o.blockchains,this.actions.findToken);return this.actions.retrySwap(n)}cancel(e){let o=this.manager?.get(e);o&&mE(o)}getCurrentStepInfo(e){let o=fE(e);return{step:o,wallet:o?gE(e,o):null,network:o?dE(e,o):null}}};var Eh=SE(void 0);function ip(t){let{manager:e}=hE(),o=se.use.isActiveTab(),n=z.use.retry(),{findToken:r}=y(),a=new Zi(e,{retrySwap:n,findToken:r}),s=Z.use.connectedWallets(),l=Z.use.loading(),p=Bp(s),u=Z.use.getWalletsDetails(),c=y().blockchains(),m=y().tokens(),f=y().swappers(),g=y().fetchStatus,d=eo().resetLanguage,h=xe().getNotifications(),k=xe().clearNotifications,S=bh(),{fromBlockchain:C,toBlockchain:T,fromToken:v,toToken:w,inputAmount:A}=z(),M={isActiveTab:o,setCurrentTabAsActive:lo.forceClaim,history:a,wallets:{isLoading:l,details:s,totalBalance:p,refetch:x=>u(x,r)},meta:{blockchains:c,tokens:m,swappers:f,loadingStatus:g,findToken:r},resetLanguage:d,notifications:{list:h,clearAll:k},quote:{quoteInputs:{fromBlockchain:C?.name??null,fromToken:v?{symbol:v.symbol,blockchain:v.blockchain,address:v.address}:null,toBlockchain:T?.name??null,toToken:w?{symbol:w.symbol,blockchain:w.blockchain,address:w.address}:null,requestAmount:A},updateQuoteInputs:S}};return yE.createElement(Eh.Provider,{value:M},t.children)}i(ip,"WidgetInfo");function Ih(){let t=CE(Eh);if(!t)throw new Error("useWidget can only be used within the WidgetProvider component");return t}i(Ih,"useWidget");function Ji(t){let{onUpdateState:e,config:o}=t,n=t.config?.theme?.fontFamily,{handleLoadCustomFont:r}=wh();return Ah(()=>{n&&r(n)},[n]),TE(()=>{zp({API_KEY:o?.apiKey||nr,BASE_URL:o?.apiUrl||fp})},[o.apiKey,o.apiUrl]),Ah(()=>{t.config?.signers?.customSolanaRPC&&kE("customRPC",t.config.signers.customSolanaRPC)},[t.config?.signers?.customSolanaRPC]),ap.createElement(Ir,{config:o,onUpdateState:e},ap.createElement(xh,{apiKey:o.apiKey},ap.createElement(ip,null,t.children)))}i(Ji,"WidgetProvider");function Nh(t){let e=t.config?.externalWallets;return Ri.createElement(Wc,null,e?Ri.createElement(Yi,null):Ri.createElement(Ji,{config:t.config??ra},Ri.createElement(Yi,null)))}i(Nh,"Widget");function Wh(){let{on:t,off:e}=ye;return{on:t,off:e}}i(Wh,"useWidgetEvents");var J3={DerivationPath:mn,Namespaces:un,isOnDerivationPath:fn,isOnNamespace:dn};export{x3 as EventSeverity,so as MainEvents,P3 as Networks,$3 as PendingSwapNetworkStatus,ha as QuoteEventTypes,b3 as RouteEventType,ia as SUPPORTED_FONTS,J3 as StatefulConnect,E3 as StepEventType,I3 as StepExecutionBlockedEventStatus,A3 as StepExecutionEventStatus,$e as UI_ID,ya as UiEventTypes,Sr as WalletEventTypes,L3 as WalletEvents,D3 as WalletTypes,Nh as Widget,so as WidgetEvents,Ji as WidgetProvider,Ir as WidgetWallets,Ra as customizedThemeTokens,W3 as readAccountAddress,Ht as useStatefulConnect,ft as useWalletList,Zr as useWallets,Ih as useWidget,Wh as useWidgetEvents,yr as widgetEventEmitter};
3
3
  //# sourceMappingURL=index.js.map