@rango-dev/widget-embedded 0.35.1-next.3 → 0.36.0
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/components/NoResult/NoResult.helpers.d.ts +1 -1
- package/dist/components/NoResult/NoResult.helpers.d.ts.map +1 -1
- package/dist/components/SameTokensWarning/SameTokensWarning.d.ts +3 -0
- package/dist/components/SameTokensWarning/SameTokensWarning.d.ts.map +1 -0
- package/dist/components/SameTokensWarning/SameTokensWarning.styles.d.ts +161 -0
- package/dist/components/SameTokensWarning/SameTokensWarning.styles.d.ts.map +1 -0
- package/dist/components/SameTokensWarning/index.d.ts +2 -0
- package/dist/components/SameTokensWarning/index.d.ts.map +1 -0
- package/dist/containers/Wallets/Wallets.d.ts.map +1 -1
- package/dist/hooks/useWalletList.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +4 -4
- package/dist/pages/Home.d.ts.map +1 -1
- package/dist/store/slices/config.d.ts.map +1 -1
- package/dist/types/config.d.ts +10 -0
- package/dist/types/config.d.ts.map +1 -1
- package/dist/utils/providers.d.ts +1 -0
- package/dist/utils/providers.d.ts.map +1 -1
- package/dist/widget-embedded.build.json +1 -1
- package/package.json +7 -7
- package/src/components/NoResult/NoResult.helpers.ts +2 -5
- package/src/components/SameTokensWarning/SameTokensWarning.styles.ts +7 -0
- package/src/components/SameTokensWarning/SameTokensWarning.tsx +31 -0
- package/src/components/SameTokensWarning/index.ts +1 -0
- package/src/containers/Wallets/Wallets.tsx +1 -0
- package/src/hooks/useWalletList.ts +1 -0
- package/src/pages/Home.tsx +3 -0
- package/src/store/slices/config.ts +4 -0
- package/src/types/config.ts +11 -0
- package/src/utils/providers.ts +4 -0
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 Jr,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 Ec}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 tr={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 tr;case"resetDerivation":return t.namespace?{...t,derivationPath:null,status:"namespace"}:tr;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,tr),a=i(async(c,m,g)=>{r({type:"reset"});try{return await o(c,void 0,m),{status:"connected"}}catch(f){let d=f?.message?`Error: ${f.message}`:"An unknown error happened during connecting wallet.";throw new Error(d,{cause:f})}},"runConnect"),s=i(async(c,m)=>{if(c.state===Bh.DISCONNECTED){if(!c.namespaces)return await a(c.type,void 0,m);let f=c.namespaces.length>1,d=c.needsDerivationPath;return f?(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 g=c.singleNamespace,f=c.needsDerivationPath,d=m[0];if(!d)throw new Error("To confirm a namespace, you should select at least one namespace.");if(g&&f)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,C=m.map(S=>({namespace:S}));return await a(h,C)},"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,f=[{namespace:n.derivationPath.namespace,derivationPath:c}];return await a(m,f)},"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 Bo}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 or(t,e){return e.find(o=>o.name===t)?.displayName}i(or,"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 nn(t,e){return e.find(o=>o.id===t)?.title}i(nn,"getSwapperDisplayName");function rn(t,e){return e.find(o=>o.name===t)??null}i(rn,"findBlockchain");function 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 De(t){return`${t.blockchain.toLowerCase()}-${t.symbol.toLowerCase()}-${(t.address??"").toLowerCase()}`}i(De,"createTokenHash");function No(t,e){return t.addressPatterns.filter(r=>new RegExp(r).test(e)).length>0}i(No,"isValidTokenAddress");function an(t){let{config:e,meta:o}=t,n={},r=e.tokens,a=i(l=>{l.forEach(p=>{typeof p!="string"&&(p=De(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=De(u);delete n[c]})):a(p.tokens))}),Object.values(n)}i(an,"matchTokensFromConfigWithMeta");function nr(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(nr,"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=an({type:"source",config:{blockchains:n.from?.blockchains,tokens:n.from?.tokens},meta:{tokensMapByBlockchainName:s,tokensMapByTokenHash:a}}),p=an({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 rr="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 ir}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"),sn=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 ar=i((t,e)=>{switch(e){case aa.ALL:return!0;case aa.UTXO:return t===ir.TRANSFER;case aa.OTHER:return t!==ir.TRANSFER&&t!==ir.COSMOS&&t!==ir.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 ln=i(t=>{let e=Math.floor(t%60/15)*15,o=parseInt((t/60).toString());return o>=60?`${Math.floor(o/5)*5}:00`:`${o.toString().padStart(2,"0")}:${e.toString().padStart(2,"0")}`},"roundedSecondsToString"),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 sr=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"),pn=i(t=>!!t&&parseFloat(t)>0,"isPositiveNumber");function cn(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(cn,"mapStatusToWalletState");function Np(t,e,o,n){return o.filter(r=>!hp.includes(r)).filter(r=>{let{supportedChains:a,isContractWallet:s}=e(r),{installed:l,network:p}=t(r);return s&&(!l||!!n&&p!==n)?!1:n?!!a.find(c=>c.name===n):!0}).map(r=>{let{name:a,img:s,installLink:l,showOnMobile:p,namespaces:u,singleNamespace:c,supportedChains:m,needsDerivationPath:g}=e(r),f=Wo(m.map(h=>h.type)),d=cn(t(r));return{title:a,image:s,link:Kh(l),state:d,type:r,showOnMobile:p,namespaces:u,singleNamespace:c,blockchainTypes:f,needsDerivationPath:g}})}i(Np,"mapWalletTypesToWalletInfo");function cr(t){if(!t)return null;let e=[];return e=t.map(o=>o.name),e}i(cr,"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,g=l.includes(c),f=c===Ap.Unknown;if(m&&!g&&!f)return;let h=c===Ap.Unknown&&Xh(u);if(f&&!h)return;o.includes(c)||h?r?s(c,u.toLowerCase()):l.filter(k=>o.includes(k)).forEach(k=>{s(k,u.toLowerCase())}):s(c,u)}),a}i(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,g=u.to.blockchain,f=a===o.swaps.length-1,d=c===p.length-1;(!f&&!d||f&&l!==m||e==="all")&&n.add(m),e==="all"&&n.add(g)})}e==="all"&&n.add(l)}),Array.from(n)}i(io,"getQuoteWallets");function ur(t,e){return t.address===e.address&&t.chain===e.chain&&t.walletType===e.walletType}i(ur,"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 mr=i((t,e)=>{let o=jh(Object.entries(t).map(([,n])=>n).filter(Yh));return o&&o[e]?.experimental},"isExperimentalChain");function dr(t){return t?{...t,amount:L(t.amount,8,8),usdValue:L(t.usdValue,4,4)}:null}i(dr,"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 fr(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(fr,"getConciseAddress");function _p({chain:t,connectedWallets:e,walletType:o}){return e.find(n=>n.walletType===o&&n.chain===t)?.address}i(_p,"getAddress");function gr(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?De({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(gr,"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(ar(n,e))return!0;return!1})}i(Up,"filterWalletsByCategory");var ua={API_KEY:rr};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 hr,Et=i(()=>hr||(hr=new Jh(Bt("API_KEY"),Bt("BASE_URL")),hr),"httpService");function yr(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(yr,"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 Mo(t,e){return e?.[t]==="enabled"}i(Mo,"isRoutingEnabled");var Vp=i((t,e,o)=>je("customTokens",o)?t:t.concat(e),"addCustomTokensToSupportedTokens");var Kp=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=nr({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=an({type:o.type,config:{blockchains:a[u]?.blockchains,tokens:a[u]?.tokens},meta:{tokensMapByTokenHash:n,tokensMapByBlockchainName:r}}),Ao.set(c,m)),m=Vp(m,s,a.features);let g=e().blockchains({type:o.type});return m.filter(d=>o.blockchain&&d.blockchain!==o.blockchain||!g.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 C=e().isTokenPinned(d,o.type),S=e().isTokenPinned(h,o.type);if(C!==S)return C?-1:1;if(o.getBalanceFor){let I=o.getBalanceFor(d),M=o.getBalanceFor(h),b=Pp(I,M);if(b!==0)return b}let k=p.get(d.blockchain),T=p.get(h.blockchain),v=na(d,k),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 I=bp(d,h,o.searchFor);if(I)return I}return d.isSecondaryCoin!==h.isSecondaryCoin?d.isSecondaryCoin?1:-1:k&&T?k.sort-T.sort:0})},findToken:o=>{let n=e()._tokensMapByTokenHash,r=e().customTokens(),a=De(o),s=n.get(a);return s||(s=r.find(l=>De(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{routing:o}=e().config,n=Mo("enableCentralizedSwappers",o),r=await Et().getAllMetadata({enableCentralizedSwappers:n});t({fetchStatus:"success"});let a=new Map,s=new Map,l={},p=[],u=r.popularTokens,c=r.swappers,m=new Set;r.tokens.forEach(f=>{m.add(f.blockchain),p.push(f)}),r.blockchains.sort((f,d)=>f.sort-d.sort).forEach(f=>{f.enabled&&m.has(f.name)&&a.set(f.name,f)}),p.forEach(f=>{let d=De(f);l[f.blockchain]||(l[f.blockchain]=[]),s.set(d,f),l[f.blockchain].push(d)}),t({_blockchainsMapByName:a,_tokensMapByTokenHash:s,_tokensMapByBlockchainName:l,_popularTokens:u,_swappers:c})}catch(o){throw t({fetchStatus:"failed"}),o}}}),"createDataSlice");import{Bengali as Rh,Catalonia as ey,Chinese as jp,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 Xp=[{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:jp},{title:"Chinese (Traditional)",label:"\u4E2D\u6587\uFF08\u7E41\u9AD4)",local:"zh-TW",SVGFlag:jp},{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}],Lo="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||Lo},...l&&{disabledLiquiditySources:o.liquiditySources||[]},...u&&{language:o.language||Lo}})},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=nr({config:o});return r.length?n.filter(a=>r.includes(a.blockchain)):n}}),"createSettingsSlice");function oc(t){return Ly()(By((...e)=>({...Kp(...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=Dy(null);function y(){let t=_y(nc);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 rc(t){let e=Fy();return e.current||(e.current=oc(t.config)),Py.createElement(nc.Provider,{value:e.current},t.children)}i(rc,"AppStoreProvider");import{create as zy}from"zustand";import{subscribeWithSelector as Qy}from"zustand/middleware";import Oy from"mitt";var he=Oy(),Sr={on:he.on,off:he.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||{}),Cr=(o=>(o.CONNECT="connect",o.DISCONNECT="disconnect",o))(Cr||{}),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 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 R=Gt(zy()(Qy((t,e)=>({connectedWallets:[],balances:{},loading:!1,connectWallet:(o,n)=>{he.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)&&he.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:gr(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=>ur(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(g=>{let f=o.find(h=>ur(h,g)),d=p.find(h=>h.address===g.address&&h.blockChain===g.chain);return d?.failed&&f&&r&&a([f],n,!1),f&&d?{...g,explorerUrl:d.explorerUrl,balances:Mp(d,n),loading:!1,error:!1}:g});return{loading:!1,balances:gr(c),connectedWallets:c}});else throw new Error("Wallet not found")}catch{t(l=>{let p=l.connectedWallets.map(c=>o.find(m=>ur(m,c))?Lp(c):c);return{loading:!1,balances:gr(p),connectedWallets:p}})}},getBalanceFor:o=>{let{balances:n}=e(),r=De(o);return n[r]??null}}))));import{allProviders as qy}from"@rango-dev/provider-all";function kr(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(kr,"matchAndGenerateProviders");function ac(t,e){return kr(t,e).map(r=>r.config.type)}i(ac,"configWalletsToWalletName");var Xy=Object.values(Bo);function ft(t){let{chain:e}=t||{},{config:o}=y(),{state:n,getWalletInfo:r}=Hy(),{connectedWallets:a}=R(),s=y().blockchains(),{handleDisconnect:l}=Ht(),p=ac(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(C=>C.walletType===h&&C.chain===e),"isExperimentalChainNotAdded"),g=Ky(()=>{let h=u?.filter(C=>C.state===Sa.CONNECTING)||[];for(let C of h)l(C.type)},[Fp(u)]);jy(()=>()=>{g()},[]);let f=i(h=>{let C=h.find(k=>k.type===Bo.DEFAULT);return!C||C.state===Sa.NOT_INSTALLED?!1:h.filter(k=>k.state!=Sa.NOT_INSTALLED&&![Bo.DEFAULT,Bo.WALLET_CONNECT_2,Bo.LEDGER].includes(k.type)&&r(k.type).supportedChains.filter(T=>T.type=="EVM").length>0).length==0},"shouldShowDefaultInjectedWallet"),d=i((h,C,S)=>mr(S,C)&&m(h)&&!Vy.includes(h)||h==Bo.DEFAULT&&!f(u),"shouldExcludeWallet");return{list:c.filter(h=>!d(h.type,e??"",s)),terminateConnectingWallets:g}}i(ft,"useWalletList");import{Modal as Jy}from"@rango-dev/ui";import Ry from"react";import{create as Zy}from"zustand";var sc="rango-widget";var un=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(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 un({onInit:()=>se.setState({tabManagerInitiated:!0}),onClaim:()=>se.setState({isActiveTab:!0,showActivateTabModal:!1}),onRelease:()=>se.setState({isActiveTab:!1})});function ee(t){let{watermark:e}=se();return Ry.createElement(Jy,{hasWatermark:e==="FULL",...t},t.children)}i(ee,"WatermarkedModal");import{i18n as Ca}from"@lingui/core";import{Button as iS,Checkbox as aS,Divider as sS,Image as yc,ListItemButton as lS,MessageBox as pS,Radio as cS,RadioRoot as uS}from"@rango-dev/ui";import{namespaces as Sc}from"@rango-dev/wallets-shared";import Te,{useMemo as mS,useState as dS}from"react";import{css as eS,darkTheme as pc,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",[`.${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=eS({display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center"}),Tr=po("div",{borderRadius:"100%",border:"1.5px transparent solid","&:not(:first-child)":{marginLeft:"-$6"},img:{borderRadius:"100%"}});import{keyframes as oS,styled as vr}from"@rango-dev/ui";var HA=vr("div",{borderRadius:"$lg",width:"$45",height:"$45",backgroundColor:"$success300",display:"flex",justifyContent:"center",alignItems:"center"}),Po=vr("div",{position:"relative"}),nS=oS({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}),Do=vr("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}),wr=vr("div",{"& img":{borderRadius:"50%"}});function gc(t,e){return t.find(o=>o.name===e)?.logo}i(gc,"getBlockchainLogo");import{styled as rS}from"@rango-dev/ui";var hc=rS("ul",{padding:0,paddingTop:"$4",paddingBottom:"$4"});function mn(t){let{singleNamespace:e,availableNamespaces:o,providerImage:n}=t.value,[r,a]=dS([]),s=y().blockchains(),l=mS(()=>o?.map(c=>({name:c,logo:gc(s,Sc[c].mainBlockchain),title:Sc[c].title})),[o]),p=i(c=>{a(e?[c]:m=>m.includes(c)?m.filter(g=>g!==c):m.concat(c))},"onSelect"),u=i(c=>e?Te.createElement(uS,{value:r?.[0]},c):Te.createElement(Te.Fragment,null,c),"wrapRadioRoot");return Te.createElement(Te.Fragment,null,Te.createElement(sS,{size:20}),Te.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:Te.createElement(Po,null,Te.createElement(Tr,null,Te.createElement(yc,{src:n,size:45})),Te.createElement(Do,null))}),Te.createElement(hc,null,u(Te.createElement(Te.Fragment,null,l?.map(c=>Te.createElement(lS,{key:c.name,id:c.name,title:c.title,hasDivider:!0,style:{height:60},onClick:()=>p(c.name),start:Te.createElement(yc,{src:c.logo,size:22}),end:e?Te.createElement(cS,{value:c.name}):Te.createElement(aS,{checked:r.includes(c.name)})}))))),Te.createElement(iS,{id:"widget-name-space-confirm-btn",type:"primary",disabled:!r.length,onClick:()=>t.onConfirm(r)},Ca.t("Confirm")))}i(mn,"Namespaces");import{i18n as _o}from"@lingui/core";import{Button as hS,Divider as Tc,Image as yS,MessageBox as SS,Select as CS,TextField as kS}from"@rango-dev/ui";import ze,{useEffect as TS,useState as vc}from"react";import{namespaces as fS}from"@rango-dev/wallets-shared";var br={id:"custom",label:"Custom",generateDerivationPath:t=>t};function ka(t){let e=t?fS[t].derivationPaths:null;return e?[...e,br]:[]}i(ka,"getDerivationPaths");import{styled as Cc,Typography as gS}from"@rango-dev/ui";var kc=Cc("div",{paddingTop:"$30",paddingBottom:"$30",zIndex:10}),Ta=Cc(gS,{paddingLeft:"$10"}),va={height:"$40",backgroundColor:"$neutral200",borderRadius:"$sm"};var wc="0";function dn(t){let{onConfirm:e}=t,{namespace:o,providerImage:n,providerType:r}=t.value,[a,s]=vc(null),[l,p]=vc(wc),u=a===br.id,c=ka(o),m=i(({value:f})=>{let d=c?.find(h=>h.id===f);d&&(a===br.id&&Number.isNaN(Number(l))&&p(wc),s(d.id))},"handleDerivationPathItemClick"),g=i(()=>{let f=c.find(d=>d.id===a);if(f)e(f.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(Tc,{size:20}),ze.createElement(SS,{type:"info",title:_o.t("Select Derivation Path"),description:_o.t({id:"In order to connect to {type}, you must first select a Derivation Path",values:{type:r}}),icon:ze.createElement(Po,null,ze.createElement(wr,null,ze.createElement(yS,{src:n,size:45})),ze.createElement(Do,null))}),ze.createElement(kc,null,ze.createElement(Ta,{variant:"body",size:"xsmall",color:"$neutral600"},_o.t("Choose Derivation Path Template")),ze.createElement(CS,{value:a||"",options:c.map(f=>({value:f.id,label:f.label})),variant:"filled",handleItemClick:m,styles:{trigger:va}}),ze.createElement(Tc,{size:20}),ze.createElement(Ta,{variant:"body",size:"xsmall",color:"$neutral600"},u?_o.t("Enter Path"):_o.t("Enter Index")),ze.createElement(kS,{type:u?"text":"number",variant:"contained",value:l,onChange:f=>p(f.target.value),style:va})),ze.createElement(hS,{id:"widget-derivation-path-confirm-btn",type:"primary",onClick:g,disabled:!c||!a||!l},_o.t("Confirm")))}i(dn,"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 cn(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(Po,null,co.createElement(wr,null,co.createElement(vS,{src:r,size:45})),co.createElement(Do,null))})}i(ba,"ConnectStatus");import{i18n as xa}from"@lingui/core";import{Button as xS,Divider as bc,MessageBox as ES}from"@rango-dev/ui";import xr from"react";function Ea(t){let{displayName:e,onConfirm:o}=t;return xr.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}})},xr.createElement(bc,{size:18}),xr.createElement(bc,{size:32}),xr.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 xc(t,e){return t().status==="init"&&!!e}i(xc,"isOnStatus");function fn(t){return t().status==="namespace"}i(fn,"isOnNamespace");function gn(t){return t().status==="derivationPath"}i(gn,"isOnDerivationPath");var WS=3e3,MS=300;function mo(t){let e=NS(),[o,n]=Ec(!1),[r,a]=Ec(),s=i(S=>{a(S.message)},"catchErrorOnHandle"),{terminateConnectingWallets:l}=ft(),{handleConnect:p,handleDerivationPath:u,handleNamespace:c,getState:m,resetState:g}=Ht(),f=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"),C=i(()=>{a(void 0),g(),n(!1),e.current&&clearTimeout(e.current)},"resetModalState");return AS(()=>{if(t.wallet){C();let S=!1,k=!0,T=i(()=>{setTimeout(()=>{k=!1,S||n(!0)},MS)},"beforeConnecting"),v=i(w=>{let I=w.status==="connected",M=["disconnected","disconnected-unhandled"].includes(w.status);["namespace","derivation-path"].includes(w.status)||(S=!0),I&&!k?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(ee,{open:o,onClose:h,onExit:()=>{C(),l(),t.onClose&&t.onClose()},container:N()},xc(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})),fn(m)&&uo.createElement(mn,{onConfirm:f,value:m().namespace}),gn(m)&&uo.createElement(dn,{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 Er,{createContext as DS,useEffect as Ac,useMemo as _S,useRef as Nc}from"react";import{useEffect as LS}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=R.use.clearConnectedWallet(),n=kr(t,e);return LS(()=>{o(),n=kr(t,e)},[Ic(t??[]),e?.walletConnectProjectId,e?.walletConnectListedDesktopWalletLink]),{providers:n}}i(Ia,"useWalletProviders");var Ir=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}=R(),g=Nc(),f=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(PS).map(k=>k.name),h=i((k,T,v,w,I)=>{if(T===Aa.ACCOUNTS)if(v){let M=cr(I.supportedBlockchains),b=Wp(k,v,d,M,I.isContractWallet);b.length&&c(b,s)}else m(k),f.current?f.current(k):console.warn("onDisconnectWallet handler hasn't been set. Are you sure?");if(T===Aa.ACCOUNTS&&w.connected){let M=`${k}-${w.network}-${v}`;w.connected&&(g.current?g.current(M):console.warn("onConnectWallet handler hasn't been set. Are you sure?"))}if(T===Aa.NETWORK&&w.network){let M=`${k}-${w.network}`;g.current?g.current(M):console.warn("onConnectWallet handler hasn't been set. Are you sure?")}t.onUpdateState&&t.onUpdateState(k,T,v,w,I)},"onUpdateState"),C=se.use.isActiveTab(),S=_S(()=>({onConnectWallet:k=>{g.current=k},onDisconnectWallet:k=>{f.current=k}}),[]);return Er.createElement(Ir.Provider,{value:S},Er.createElement(BS,{allBlockChains:a,providers:u,onUpdateState:h,autoConnect:!!C},t.children))}i($S,"Main");function Ar(t){let{config:e,...o}=t;return Er.createElement(rc,{config:e},Er.createElement($S,{...o,config:e}))}i(Ar,"WidgetWallets");import ea from"react";import FS,{Fragment as OS}from"react";import{MemoryRouter as US,useInRouterContext as zS}from"react-router";function Wc({children:t}){let o=zS()?OS:US;return FS.createElement(o,null,t)}i(Wc,"AppRouter");import{I18nManager as CE}from"@rango-dev/ui";import rp from"react";import Be from"react";import{useRoutes as iE}from"react-router-dom";var _={home:"/",fromSwap:"from-swap",toSwap:"to-swap",blockchains:"blockchains",settings:"settings",customTokens:"custom-tokens",addCustomTokens:"add-custom-tokens",liquiditySources:"liquidity-sources",bridges:"bridges",exchanges:"exchanges",languages:"languages",swaps:"swaps",wallets:"wallets",confirmSwap:"confirm-swap",swapDetails:":requestId",routes:"routes"};import{useEffect as Uo,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"],Mc=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 Wr}from"rango-types";import{i18n as $e}from"@lingui/core";var te=i(()=>({genericServerError:$e.t("Failed Network, Please retry your swap."),liquiditySourcesError:{title:$e.t("Please reset your liquidity sources."),description:$e.t("You have limited the liquidity sources and this might result in Rango finding no routes. Please consider resetting your liquidity sources.")},noResultError:{title:$e.t("No Routes Found."),description:$e.t("Reasons why Rango couldn't find a route: low liquidity on token, very low input amount or no routes available for the selected input/output token combination.")},bridgeLimitErrors:{increaseAmount:$e.t("Bridge Limit Error: Please increase your amount."),decreaseAmount:$e.t("Bridge Limit Error: Please decrease your amount.")},highValueLossError:{impactTitle:$e.t("High Price Impact"),title:$e.t("Price impact is too high!"),description:$e.t("The price impact is significantly higher than the allowed amount."),confirmMessage:$e.t("Confirm high price impact")},quoteUpdatedWithHighValueLoss:{title:$e.t("Route updated and price impact is too high, try again later!")},unknownPriceError:{impactTitle:$e.t("USD Price Unknown"),title:$e.t("USD Price Unknown, Cannot calculate Price Impact."),description:$e.t("USD Price Unknown, Cannot calculate Price Impact. The price impact may be higher than usual. Are you sure to continue the Swap?"),confirmMessage:$e.t("Confirm USD Price Unknown")}}),"errorMessages");function 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 Nr}from"@lingui/core";var fo=i(()=>({connectWallet:Nr.t("Connect Wallet"),swap:Nr.t("Swap"),swapAnyway:Nr.t("Swap anyway"),ethWarning:Nr.t("The route goes through Ethereum. Continue?")}),"swapButtonTitles");function 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 Mr(t,e){return t.reduce((o,n)=>o.plus(La(n,e)),Ue)}i(Mr,"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 Lr(t){return t.map(o=>o.recommendedSlippage)?.map(o=>o?.slippage||"0")?.filter(o=>parseFloat(o)>0)?.sort((o,n)=>parseFloat(n)-parseFloat(o))?.find(()=>!0)||null}i(Lr,"getMinRequiredSlippage");function zc(t,e){return e?parseFloat(t)>=parseFloat(e):!0}i(zc,"hasProperSlippage");function Qc(t){let{fromToken:e,toToken:o,inputAmount:n,wallets:r,selectedWallets:a,disabledLiquiditySources:s,liquiditySources:l,excludeLiquiditySources:p,slippage:u,affiliateRef:c,affiliatePercent:m,affiliateWallets:g,destination:f}=t,d=a?.reduce((S,k)=>(S[k.chain]=k.address,S),{}),h=[];return r?.forEach(S=>{h.push({blockchain:S.chain,addresses:[S.address]})}),{amount:n.toString(),affiliateRef:c??void 0,affiliatePercent:m??void 0,affiliateWallets:g??void 0,from:{address:e.address,blockchain:e.blockchain,symbol:e.symbol},to:{address:o.address,blockchain:o.blockchain,symbol:o.symbol},connectedWallets:h,selectedWallets:d??{},slippage:u.toString(),...f&&{destination:f},...p&&{swapperGroups:s.concat(l??[]),swappersGroupsExclude:!0},...!p&&{swapperGroups:l?.filter(S=>!s.includes(S)),swappersGroupsExclude:!1}}}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 Fo(t){return t?.outputAmount||null}i(Fo,"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=Fo(t),n=Fo(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 hn(t){return!!t&&t.networkStatus!==null&&t.networkStatus!==Wr.NetworkChanged}i(hn,"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,"")),hn(e))switch(n=t.networkStatusExtraMessage||"",r=t.networkStatusExtraMessageDetail||"",e?.networkStatus){case Wr.WaitingForConnectingWallet:n=n||gt.t("Waiting for connecting wallet");break;case Wr.WaitingForQueue:n=n||gt.t("Waiting for other running tasks to be finished");break;case Wr.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(g=>g.chain===m)),u=l.every(m=>r.some(g=>g.chain===m)),c=o&&a?No(a,o):!1;return!e&&!p||e&&!o||e&&!!o&&(!c||!u)}i(Yc,"isConfirmSwapDisabled");function Zc(t,e){return t.blockchain===e.blockchain&&t.symbol===e.symbol&&t.address===e.address}i(Zc,"isTokensIdentical");function go(t){let e=t?.swaps||[];return e[e.length-1].to.usdPrice}i(go,"getQuoteToTokenUsdPrice");function yn(t){return(t?.swaps||[])[0].from.usdPrice}i(yn,"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 Pr(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=rn(a?a.toBlockchain:n.fromBlockchain,e),p=rn(r.toBlockchain,e),u=o(a?{blockchain:l?.name??"",symbol:a.toSymbol,address:a.toSymbolAddress}:{blockchain:l?.name??"",symbol:n.fromSymbol,address:n.fromSymbolAddress}),c=o(s),m=a?a.outputAmount??"":t.inputAmount;return{fromBlockchain:l,fromToken:u,toBlockchain:p,toToken:c,inputAmount:m}}i(Pr,"createRetryQuote");function Oo(t,e){let{fromToken:o,toToken:n,findToken:r,userSlippage:a}=e,s=jt(t.requestAmount,yn(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 g=Mr(t?.swaps,r),f=Pt(c);return{type:0,inputUsdValue:s,outputUsdValue:l,priceImpact:c,totalFee:g,warningLevel:f}}}else if(t&&(!s||!l))return{type:1};let p=Lr(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(Oo,"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"),Dr=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 _r=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 pn(o.inputAmount)?(e&&(n=e?.outputAmount?new Xe(e?.outputAmount):null,a=jt(o.inputAmount,yn(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:_r(e.token,o.inputAmount)}})),setToBlockchain:e=>{t(o=>o.toBlockchain?.name===e?.name?{}:{toBlockchain:e,...o.toToken&&{selectedQuote:null,toToken:null,outputAmount:null,outputUsdValue:new 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:_r(o.fromToken,e)}}))},retry:e=>{let{fromBlockchain:o,fromToken:n,toBlockchain:r,toToken:a,inputAmount:s}=e;t({fromBlockchain:o,fromToken:n,inputAmount:s,outputAmount:null,inputUsdValue:_r(n??null,s),outputUsdValue:new 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?_r(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)&&he.emit("quoteEvent",{type:"quoteInputUpdate",payload:{fromBlockchain:t.fromBlockchain?.name,toBlockchain:t.toBlockchain?.name,fromToken:t.fromToken?{symbol:t.fromToken.symbol,name:t.fromToken.name,address:t.fromToken.address}:void 0,toToken:t.toToken?{symbol:t.toToken.symbol,name:t.toToken.name,address:t.toToken.address}:void 0,requestAmount:t.inputAmount}}),t.selectedQuote?.requestId!==e.selectedQuote?.requestId&&he.emit("quoteEvent",{type:"quoteOutputUpdate",payload:t.selectedQuote?{requestAmount:t.selectedQuote.requestAmount,swaps:t.selectedQuote.swaps,outputAmount:t.selectedQuote.outputAmount,resultType:t.selectedQuote.resultType,tags:t.selectedQuote.tags}:null})});function iu(){let{setInputAmount:t,setToToken:e,setToBlockchain:o,setFromBlockchain:n,resetQuote:r,setFromToken:a,fromToken:s,toToken:l,fromBlockchain:p,toBlockchain:u}=z(),c=y().config,m=y().fetchStatus,g=y().blockchains(),f=y().tokens(),{findToken:d}=y(),{setAffiliateRef:h,setAffiliatePercent:C,setAffiliateWallets:S}=y(),k=c?.from?.tokens,T=c?.from?.blockchains,v=c?.to?.tokens,w=c?.to?.blockchains,I=$r(void 0),M=$r(void 0),b=$r(void 0),E=$r(void 0);Uo(()=>{typeof c.amount<"u"&&t(c.amount.toString())},[c?.amount]),Uo(()=>{if(m==="success"){r();let x=g.find(A=>A.name===c?.from?.blockchain),W=c?.from?.token,D=W&&d(W);(x||!x&&b.current)&&n(x??null),D?a({token:D,meta:{blockchains:g,tokens:f}}):!D&&I.current&&a({token:null}),b.current=c?.from?.blockchain,I.current=c?.from?.token}},[c?.from?.token?.symbol,c?.from?.token?.address,c?.from?.token?.blockchain,c?.from?.blockchain,m]),Uo(()=>{da(s,k)&&a({token:null}),fa(p,T)&&n(null)},[k,T]),Uo(()=>{da(l,v)&&a({token:null}),fa(u,w)&&o(null)},[v,w]),Uo(()=>{if(m==="success"){r();let x=g.find(A=>A.name===c?.to?.blockchain),W=c?.to?.token,D=W&&d(W);(x||!x&&E.current)&&o(x??null),D?e({token:D,meta:{blockchains:g,tokens:f}}):!D&&M.current&&e({token:null}),E.current=c?.to?.blockchain,M.current=c?.to?.token}},[c?.to?.token?.symbol,c?.to?.token?.address,c?.to?.token?.blockchain,c?.to?.blockchain,m]),Uo(()=>{h(c?.affiliate?.ref??null),C(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 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:g}=z(),f=y().fetchStatus,d=y().blockchains(),h=y().tokens(),C=KS(),{updateIframe:S,updateCampaignMode:k}=y(),T=y().isInCampaignMode(),v=VS(),{findToken:w}=y(),I=i(()=>{let b={};for(let[K,me]of e.entries())K.startsWith("utm_")&&(b[K]=me);let E=e.get("fromAmount"),x=e.get("fromBlockchain"),W=e.get("fromToken"),D=e.get("toBlockchain"),A=e.get("toToken"),Z=e.get("autoConnect"),ae=e.get("clientUrl"),J=e.get("liquiditySources"),B=e.get("blockchain");return{fromAmount:E,fromBlockchain:x,fromToken:W,toBlockchain:D,toToken:A,autoConnect:Z,clientUrl:ae,liquiditySources:J,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}=I();C&&f==="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(!C)return;let b=I();if(!v.current&&b.liquiditySources&&(v.current=b.liquiditySources),b.fromAmount&&g(b.fromAmount),f==="success"){let E=d.find(A=>A.name===b.fromBlockchain),x=b.fromToken&&E?w($a(b.fromToken,E)):void 0,W=d.find(A=>A.name===b.toBlockchain),D=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),D&&m({token:D,meta:{blockchains:d,tokens:h}}))}},[f]),Oa(()=>{let{clientUrl:b,liquiditySources:E}=I();S("clientUrl",b||void 0),k("liquiditySources",E?.split(",")??void 0)},[])}i(za,"useSyncUrlAndStore");import{i18n as At}from"@lingui/core";import{Alert as pk,Button as Ou,darkTheme as ck,Divider as kn,DoneIcon as uk,MessageBox as mk,styled as dk,TextField as fk,Typography as gk}from"@rango-dev/ui";import ye,{useEffect as hk,useState as Hr}from"react";import{useNavigate as yk,useSearchParams as Sk}from"react-router-dom";import{ChevronRightIcon as YS,Divider as cu,Image as ZS,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(ZS,{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(YS,{size:12,color:"black"})))}i(qa,"BlockchainSelectorButton");import{i18n as Ga}from"@lingui/core";import{Button as JS,Divider as Sn,ExternalLinkIcon as RS,Image as eC,Typography as Qo}from"@rango-dev/ui";import Ae 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 zo,styled as du}from"@rango-dev/ui";var Ha=du("a",{textDecoration:"none",color:"$colors$neutral700",[`.${zo} &`]:{color:"$colors$neutral900"},"& svg":{marginLeft:"$4",color:"$colors$neutral700",[`.${zo} &`]:{color:"$colors$neutral900"}},variants:{hasHover:{true:{"&:hover":{color:"$colors$secondary550",[`.${zo} &`]:{color:"$colors$secondary500"},"& svg":{color:"$colors$secondary550",[`.${zo} &`]:{color:"$colors$secondary500"}}}},false:{}}}}),fu=du("div",{display:"flex",justifyContent:"center",flexDirection:"column",alignItems:"center",textAlign:"center","& ._blockchain-name, & ._coin-source":{color:"$colors$neutral600",[`.${zo} &`]:{color:"$colors$neutral800"}},"& ._coin-source-name, & ._custom-token-description":{color:"$colors$neutral700",[`.${zo} &`]:{color:"$colors$neutral900"}}});function Va(t){let{open:e,onClose:o,token:n,onSubmitClick:r,blockchain:a}=t,s=mu(n.address,a);return Ae.createElement(ee,{open:e,dismissible:!0,onClose:o,container:N()},Ae.createElement(fu,null,Ae.createElement(eC,{src:n.image,size:45,type:"circular"}),Ae.createElement(Qo,{variant:"title",size:"medium"},n.name),Ae.createElement(Qo,{variant:"body",size:"small",className:"_blockchain-name"},a.displayName),Ae.createElement(Sn,{size:4}),Ae.createElement(Qo,{variant:"body",size:"medium"},s?Ae.createElement(Ha,{hasHover:!0,href:s,target:"_blank",rel:"nofollow noreferrer"},n.address,Ae.createElement(RS,{size:12,color:"gray"})):Ae.createElement(Ha,null,n.address)),Ae.createElement(Sn,{size:4}),n.coinSource&&Ae.createElement(Qo,{className:"_coin-source",variant:"body",size:"xsmall"},Ga.t("via")," ",Ae.createElement(Qo,{className:"_coin-source-name",variant:"body",size:"xsmall"},n.coinSource)),Ae.createElement(Sn,{size:"32"}),Ae.createElement(Qo,{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."))),Ae.createElement(Sn,{size:40}),Ae.createElement(Sn,{size:10}),Ae.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 Pu,Header as ik}from"@rango-dev/ui";import We,{useEffect as fs,useRef as Du,useState as ak}from"react";import{useRef as tC}from"react";function Fr(){return window.self!==window.top}i(Fr,"isAppLoadedIntoIframe");function Ka(){let t=tC(null),{iframe:e}=y(),o=Fr()&&e.clientUrl,n=i(s=>{o&&window.top?.postMessage(s,e.clientUrl)},"send");return{send:n,connectHeightObserver:i(s=>{t.current=new ResizeObserver(l=>{for(let 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 gu(t,lC)}i(cC,"calculateShades");function uC(t){return gu(t,pC)}i(uC,"calculateTints");function gu(t,e){let o=sC(t),n=[];for(let r=1;r<9;r++)n.push(aC(e(o,r)));return n}i(gu,"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 hu=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=hu(o%52)+e;return hu(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 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]=CC(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,yC.className],g=[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);g.push(d.className)}return SC(()=>{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=g.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 kC,Button as TC}from"@rango-dev/ui";import ku from"react";function ts(t){return ku.createElement(kC,{action:ku.createElement(TC,{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 vC,Divider as wC,MessageBox as bC}from"@rango-dev/ui";import Or from"react";function ns(t){let{open:e,onClose:o,onConfirm:n}=t;return Or.createElement(ee,{open:e,dismissible:!0,onClose:o,container:N()},Or.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.")},Or.createElement(wC,{size:20}),Or.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 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(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:fc()},o.map(r=>ho.createElement(Tr,{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(cc,null),ho.createElement(LC,{size:18,color:"black"})))}i(ss,"WalletButton");import{i18n as zr}from"@lingui/core";import{NotificationsIcon as jC,Popover as XC,SettingsIcon as YC,Tooltip as Qr,TransactionIcon as ZC}from"@rango-dev/ui";import Ne 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 ve=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}=ve(),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(`${_.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 vu from"react";var zC=i(()=>{let{manager:t}=OC();return ut(t).map(({swap:o})=>o).find(o=>o.status==="running")?vu.createElement(dc,null,vu.createElement(UC,{color:"info",size:6})):null},"InProgressTransactionBadge"),wu=zC;import{EventSeverity as QC}from"@rango-dev/queue-manager-rango-preset";import{Typography as qC}from"@rango-dev/ui";import bu from"react";function xu(){let{getNotifications:t}=ve(),e=t(),o=e.length,n=!!e.find(r=>r.event.messageSeverity===QC.WARNING);return o?bu.createElement(uc,{isSever:n},bu.createElement(qC,{variant:"body",size:"xsmall",color:"$background"},o)):null}i(xu,"NotificationsBadge");import{RefreshProgressButton as HC}from"@rango-dev/ui";import ps,{useEffect as GC,useState as Eu}from"react";var VC=1e3,Iu=60,KC=100;function Ur({onClick:t}){let[e,o]=Eu(0),[n,r]=Eu(!1),a=i(p=>{document.hidden&&p&&s(p)},"handleVisibilityChange");GC(()=>{let p;return t?p=window.setInterval(()=>{o(u=>u+1),e===Iu&&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(mc,{onTransitionEnd:()=>r(!1),isRefetched:n},ps.createElement(HC,{size:22,color:t?"black":"gray",progress:e/Iu*KC})))}i(Ur,"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 Ne.createElement(Ne.Fragment,null,!r.includes("refresh")&&Ne.createElement(Qr,{container:a||N(),side:"top",content:zr.t("Refresh")},Ne.createElement(Ur,{onClick:e})),!l&&Ne.createElement(XC,{align:"end",alignOffset:-88,sideOffset:15,collisionPadding:{right:20,left:20},container:N(),content:Ne.createElement(ls,null)},Ne.createElement("div",null,Ne.createElement(Qr,{container:N(),side:"top",content:zr.t("Notifications")},Ne.createElement(It,{id:"widget-header-notification-icon-btn",size:"small",variant:"ghost"},Ne.createElement(jC,{size:18,color:"black"}),Ne.createElement(xu,null))))),!r.includes("settings")&&Ne.createElement(Qr,{container:N(),side:"top",content:zr.t("Settings")},Ne.createElement(It,{id:"widget-header-setting-icon-btn",size:"small",variant:"ghost",onClick:n},Ne.createElement(YC,{size:18,color:"black"}))),!r.includes("history")&&Ne.createElement(Qr,{container:N(),side:"top",content:zr.t("History")},Ne.createElement(It,{id:"widget-header-history-icon-btn",size:"small",variant:"ghost",onClick:o},Ne.createElement(ZC,{size:18,color:"black"}),Ne.createElement(wu,null))))}i(yo,"HeaderButtons");import{i18n as cs}from"@lingui/core";import{Divider as Nu,MessageBox as ek,RefreshIcon as tk}from"@rango-dev/ui";import Ho from"react";import{Button as JC,styled as RC}from"@rango-dev/ui";var Au=RC(JC,{"& span":{display:"flex",justifyContent:"center",alignItems:"center"}});function us(t){let{open:e,onClose:o}=t;return Ho.createElement(ee,{open:e,dismissible:!0,onClose:o,container:N()},Ho.createElement(ek,{title:cs.t("Something went wrong"),type:"error",description:cs.t("Something went wrong. Please refresh the app.")},Ho.createElement(Nu,{size:30}),Ho.createElement(Au,{variant:"outlined",size:"large",type:"primary",fullWidth:!0,onClick:()=>location.reload()},Ho.createElement(tk,{size:20,color:"primary"}),Ho.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 ok,styled as ds}from"@rango-dev/ui";var Wu="700px",qr=ok({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 oe(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=R.use.connectedWallets(),{config:{features:m,theme:g}}=y(),{watermark:f}=se(),d=f==="FULL",{activeTheme:h}=qo(g||{}),C=je("connectWalletButton",m),{isActiveTab:S,tabManagerInitiated:k,showActivateTabModal:T,setShowActivateTabModal:v,activateCurrentTab:w}=se(),I=Ye(),{manager:M}=nk(),E=ut(M).map(({swap:ae})=>ae).some(ae=>ae.status==="running"),x=i(()=>w(lo.forceClaim,E),"onActivateTab"),W=i(()=>{r.onWallet?.()},"onConnectWallet"),D=typeof r.hasBackButton>"u"||r.hasBackButton,A=Du(null),Z=Du(null);return fs(()=>(Fr()&&Z.current&&e(Z.current),()=>{o()}),[]),fs(()=>(A.current?.addEventListener("scroll",ms),()=>{A.current?.removeEventListener("scroll",ms)}),[]),fs(()=>{u(l==="failed")},[l]),We.createElement(Mu,{height:s,id:_e.SWAP_BOX_ID,className:`${h()} ${qr()}`,ref:Z},We.createElement(ik,{prefix:D?We.createElement(rs,{onClick:()=>{I(),r.onBack&&r.onBack()}}):null,title:r.title,suffix:We.createElement(We.Fragment,null,r.suffix,r.onWallet&&!C&&We.createElement(ss,{container:N(),onClick:W,isConnected:!!c?.length}),r.onCancel&&We.createElement(as,{onClick:r.onCancel}))}),We.createElement(Lu,{ref:A},n),We.createElement(ns,{open:T,onClose:()=>v(!1),onConfirm:x}),We.createElement(Bu,null,We.createElement("div",{className:"footer__content"},k&&!S&&We.createElement("div",{className:"footer__alert"},We.createElement(ts,{onActivateTab:x}),We.createElement(Pu,{size:10})),a),We.createElement(Pu,{size:12}),We.createElement("div",{className:`footer__logo ${d?"logo__show":"logo__hidden"}`},We.createElement(rk,null))),We.createElement(us,{open:p,onClose:()=>u(!1)}))}i(oe,"Layout");import{styled as sk}from"@rango-dev/ui";var _u="$20 $20 $10 $20",Cn=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 Go}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:Go.t("Duplicate Token"),message:Go.t("The address you entered is duplicate, please enter a new address.")};case"token-exist":return{title:Go.t("Token Already Exists"),message:Go.t("There's no need to add this token again because it already exists and is supported by us.")};case"not-found":return{title:Go.t("Token Not Found"),message:Go.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 g=m.token;if(r({blockchain:g.blockchain,address:g.address,symbol:g.symbol})){let d=s("token-exist");n(d);return}return g}catch(c){throw n(void 0),new Error(c.message)}finally{e(!1)}},"fetchCustomToken"),loading:t,error:o}}i(Fu,"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 Uu(){let t=yk(),[e]=Sk(),o=Ye(),{setCustomToken:n}=y(),r=y().blockchains(),a=e.get("blockchain")||"",s=rn(a,r),[l,p]=Hr(""),[u,c]=Hr(!1),[m,g]=Hr(),{fetchCustomToken:f,loading:d,error:h}=Fu(),[C,S]=Hr(""),k=!!s&&No(s,l),T=!s||!l||!k,v=i(async()=>{if(s)try{let M=await f({blockchain:a,tokenAddress:l});S(""),M&&g(M)}catch(M){M.message==="Failed to fetch"&&(S(At.t("Network Error")),c(!0))}},"getCustomToken"),w=i(()=>{h&&p(""),c(!1)},"closeErrorModal"),I=i(async()=>{C&&setTimeout(async()=>{await v()},kk),w()},"handleErrorModalButtonClick");return hk(()=>{h&&c(!0)},[h]),ye.createElement(oe,{header:{title:At.t("Add Custom Token")}},ye.createElement(re,null,ye.createElement(Ck,null,ye.createElement("div",null,ye.createElement(qa,{onClick:()=>t(_.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")}),ye.createElement(kn,{size:"24"}),ye.createElement(gk,{size:"large",variant:"label"},At.t("Enter Address")),ye.createElement(kn,{size:10}),ye.createElement(fk,{fullWidth:!0,disabled:!s,variant:"contained",placeholder:At.t("Enter token address"),size:"large",value:l,suffix:!!l&&k&&ye.createElement(uk,{color:"success",size:12}),onChange:M=>p(M.target.value)}),!k&&!!l&&ye.createElement(ye.Fragment,null,ye.createElement(kn,{size:4}),ye.createElement(pk,{type:"error",variant:"alarm",title:"Invalid Address"}))),ye.createElement(Ou,{id:"widget-add-custom-token-import-btn",disabled:T,type:"primary",variant:"contained",loading:d,size:"large",onClick:v},At.t("Import"))),ye.createElement(ee,{open:u,dismissible:!0,onClose:w,container:N()},ye.createElement(mk,{title:h?.title||C,type:"error",description:h?.message||At.t("Failed Network, Please retry.")},ye.createElement(kn,{size:40}),ye.createElement(kn,{size:10}),ye.createElement(Ou,{id:`widget-add-custom-token-${C?"retry":"add-another"}-btn`,variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:I},C?At.t("Retry"):At.t("Add another custom token")))),s&&m&&ye.createElement(Va,{blockchain:s,token:m,onSubmitClick:()=>{m&&(n(m),g(void 0),o())},onClose:()=>g(void 0),open:!!s&&!!m})))}i(Uu,"AddCustomTokenPage");import{i18n as qs}from"@lingui/core";import{useManager as nv}from"@rango-dev/queue-manager-react";import{Alert as _d,Button as rv,css as Gs,Divider as Hs,IconButton as $d,styled as iv,Typography as av,WalletIcon as sv}from"@rango-dev/ui";import xe,{useEffect as ki,useLayoutEffect as lv,useRef as pv,useState as Bn}from"react";import{useNavigate as cv}from"react-router-dom";import{i18n as So}from"@lingui/core";import{Alert as fm,BalanceErrors as Vk,Button as gm,ChevronLeftIcon as Kk,Divider as Rr,MessageBox as jk,Typography as vs}from"@rango-dev/ui";import X,{useCallback as Xk,useEffect as hm,useMemo as Yk,useState as Co}from"react";import{useNavigate as Zk}from"react-router-dom";import{i18n as Gr}from"@lingui/core";function Vr(t){switch(t.type){case 0:return Gr.t("Route has been updated.");case 3:return Gr.t("Output amount changed to {newOutputAmount} ({percentageChange}% change).",{newOutputAmount:t.newOutputAmount,percentageChange:t.percentageChange});case 1:return Gr.t("Route swappers has been updated.");case 2:return Gr.t("Route internal coins has been updated.");default:return""}}i(Vr,"getQuoteUpdateWarningMessage");import{i18n as Ss}from"@lingui/core";import{Alert as Ek,ChevronDownIcon as Ik,CloseIcon as Ak,Divider as Ku,IconButton as ju,PasteIcon as Nk,Typography as Wk,WalletIcon as Mk}from"@rango-dev/ui";import Me,{useEffect as Lk,useRef as Bk}from"react";import Yr,{useRef as bk}from"react";import*as Vo from"@radix-ui/react-collapsible";import{keyframes as zu,styled as Kr}from"@rango-dev/ui";var gs=300,vk=zu({from:{height:0},to:{height:"var(--radix-collapsible-content-height)"}}),wk=zu({from:{height:"var(--radix-collapsible-content-height)"},to:{height:0}}),Qu=Kr(Vo.Root,{borderRadius:"$sm",overflow:"hidden",variants:{selected:{true:{outlineWidth:1,outlineColor:"$secondary500",outlineStyle:"solid"}}}}),hs=Kr(Vo.Trigger,{padding:"$0",border:"none",outline:"none",width:"100%",backgroundColor:"transparent",fontFamily:"inherit",cursor:"pointer"}),jr=Kr(Vo.Content,{overflow:"hidden",variants:{open:{true:{animation:`${vk} ${gs}ms ease-out`},false:{animation:`${wk} ${gs}ms ease-out`}}}}),Xr=Kr("div",{transition:`all ${gs}ms ease`,display:"flex",alignItems:"center",variants:{orientation:{down:{transform:"rotate(0)"},up:{transform:"rotate(180deg)"}}}});function Zr(t){let{open:e,hasSelected:o,onOpenChange:n,children:r,onClickTrigger:a,trigger:s,triggerAnchor:l}=t,p=bk(null);return Yr.createElement(Qu,{ref:p,className:"collapsible_root",selected:o&&e,open:e,onOpenChange:n},l==="top"&&Yr.createElement(hs,{className:"collapsible_trigger",onClick:a},s),Yr.createElement(jr,{className:"collapsible_content",open:e},r),l==="bottom"&&Yr.createElement(hs,{className:"collapsible_trigger",onClick:a},s))}i(Zr,"CustomCollapsible");import{darkTheme as qu,styled as ys,TextField as xk}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(xk,{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=or(e.name,l),u=Bk(null),c=s?.defaultCustomDestinations?.[e.name],m=navigator?.userAgent.includes("Firefox"),f=n&&!!r&&e&&!No(e,r),d=i(()=>{a("")},"handleClear"),h=i(async S=>{if(S.preventDefault(),navigator.clipboard!==void 0){let k=await navigator.clipboard.readText();a(k),u?.current?.focus()}},"handlePaste"),C=i(()=>r?Me.createElement(ju,{id:"widget-custom-destination-close-icon-btn",onClick:d,variant:"ghost"},Me.createElement(Ak,{size:12,color:"gray"})):m?null:Me.createElement(ju,{id:"widget-custom-destination-paste-icon-btn",onClick:h,variant:"ghost"},Me.createElement(Nk,{size:16})),"renderSuffix");return Lk(()=>{!!c&&r===null&&(a(c),o(!0))},[c]),Me.createElement(Hu,null,Me.createElement(Zr,{onOpenChange:o,hasSelected:!0,open:n,triggerAnchor:"top",trigger:Me.createElement(Vu,null,Me.createElement("div",{className:"button__content"},Me.createElement(Mk,{size:18,color:"info"}),Me.createElement(Ku,{size:4,direction:"horizontal"}),Me.createElement(Wk,{variant:"label",size:"medium",color:n?"$neutral600":void 0},Ss.t("Send to a different address"))),Me.createElement(Xr,{orientation:n?"up":"down"},Me.createElement(Ik,{size:10,color:"secondary"}))),onClickTrigger:()=>o(!n)},Me.createElement(Gu,{ref:u,style:{padding:0,paddingRight:r?"8px":"5px"},autoFocus:!r,placeholder:Ss.t("Enter {blockchainName} address",{blockchainName:p}),value:r||"",suffix:C(),onChange:S=>{let k=S.target.value;a(k)}})),f&&Me.createElement(Me.Fragment,null,Me.createElement(Ku,{size:4}),Me.createElement(Ek,{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 Pk,darkTheme as Cs,IconButton as Dk,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%"}),_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"}}}}),Ju=Dt(_k,{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(Dk,{position:"absolute",left:"$20"}),tm=Dt("div",{paddingTop:"$20"}),om=Pk({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 zk}from"@rango-dev/logging-core";import{Divider as Qk,SelectableWallet as qk,Typography as um,WalletState as mm}from"@rango-dev/ui";import Ze,{useEffect as dm,useState as vn}from"react";import{Image as Ok,MessageBox as Uk}from"@rango-dev/ui";import Tn from"react";import{keyframes as $k,styled as ks}from"@rango-dev/ui";var im=ks("div",{position:"relative"}),Fk=$k({"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:`${Fk} 1s linear infinite`,top:0,bottom:0,right:0,left:0}),sm=ks("div",{"& img":{borderRadius:"50%"}});import{i18n as Ko}from"@lingui/core";function lm(t,e){switch(t){case"in-progress":return{type:"loading",title:Ko.t({id:"Add {blockchainDisplayName} Chain",values:{blockchainDisplayName:e}}),description:Ko.t({id:"Please approve the experimental chain pop-up in your wallet.",values:{blockchainDisplayName:e}})};case"completed":return{type:"success",title:Ko.t({id:"{blockchainDisplayName} Chain Added",values:{blockchainDisplayName:e}}),description:Ko.t({id:"The {blockchainDisplayName} chain has been successfully added to your wallet.",values:{blockchainDisplayName:e}})};case"rejected":return{type:"error",title:Ko.t("Request Rejected"),description:Ko.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 Tn.createElement(Uk,{type:r.type,title:r.title,description:r.description,icon:a?Tn.createElement(im,null,Tn.createElement(sm,null,Tn.createElement(Ok,{src:n,size:45})),Tn.createElement(am,null)):void 0})}i(pm,"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=R.use.connectedWallets(),{blockchains:p}=y(),[u,c]=vn(),[m,g]=vn(null),[f,d]=vn(!1),[h,C]=vn(null),{suggestAndConnect:S}=Jr(),{handleDisconnect:k}=Ht(),{list:T}=ft({chain:e}),[v,w]=vn(T),I=T.length,M=r&&I-r>0,b=i(async x=>{d(!1),C("in-progress");try{await S(x.walletType,x.chain),C("completed")}catch{C("rejected")}},"addExperimentalChain");dm(()=>{w(x=>{let W=T.findIndex(D=>o(D.type,e));return M&&W>1?[T[W]].concat(T.filter((D,A)=>A!==W)):x.map(D=>T.find(A=>A.type===D.type)??D)})},[JSON.stringify(T)]);let E=document.getElementById(_e.SWAP_BOX_ID);return dm(()=>{let x=null;return(h==="completed"||h==="rejected")&&(x=setTimeout(()=>C(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}),D=W?fr(W,Hk):"",A=mr(p(),e),Z=!l.find(me=>me.walletType===x.type&&me.chain===e),ae=A&&Z&&x.state===mm.CONNECTED,J=ae?cm.t({id:"Add {chain} chain",values:{chain:e}}):D,B=i(async()=>{x.state===mm.DISCONNECTED?c(x):x.namespaces&&!D?(await k(x.type),c(x)):ae?(g({walletType:x.type,chain:e,address:W??""}),d(!0)):n({walletType:x.type,chain:e,address:W??""})},"onSelectableWalletClick"),K=m?.chain?or(m.chain,p()):void 0;return Ze.createElement(Ze.Fragment,{key:`${x.title}_${K}`},!!m&&Ze.createElement(ee,{open:!!m&&f,container:E,onClose:()=>{g(null)}},Ze.createElement(Ea,{displayName:K,onConfirm:()=>{b(m)}})),h&&Ze.createElement(ee,{open:!!h,onClose:C.bind(null,null),container:E},Ze.createElement(pm,{status:h,displayName:K,image:x.image}),Ze.createElement(Qk,{direction:"vertical",size:32})),Ze.createElement(qk,{key:x.type,description:J,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(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+",I-(r??0)))))}i(Ts,"WalletList");var Jk=2;function ym(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:g,setCustomDestination:f}=z(),{connectedWallets:d,selectWallets:h}=R(),{config:C}=y(),[S,k]=Co(""),[T,v]=Co([]),[w,I]=Co(""),[M,b]=Co(null),[E,x]=Co(!!g),W=Yk(()=>io({filter:"all",quote:p}),[p]),D=io({filter:"required",quote:p}),A=l.find($=>$.name===p?.swaps[p?.swaps.length-1].to.blockchain),Z=i($=>D.includes($),"isWalletRequiredFor"),ae=Xk(()=>d.filter($=>$.selected&&W.includes($.chain)),[d,W]),[J,B]=Co(ae()),[K,me]=Co([]),V=i(($,Q)=>me(H=>H.concat({blockchain:$,walletType:Q})),"addNextSelectedWallets"),fe=T.length>0,ge=i(($,Q)=>!!J.find(H=>H.walletType===$&&H.chain===Q&&H.selected&&(Z(Q)||!Z(Q)&&!g)),"isSelected"),Pe=i(($,Q,H)=>{let ne=!1;return $.map(le=>{if(le.chain===Q){let pe=le.selected;return!ne&&H?(ne=!0,pe=!0):H||(pe=!1),{...le,selected:pe}}return le})},"updateSelectableWallets"),U=i($=>{x($),$?Z(A?.name??"")||B(Q=>Pe(Q,A?.name||"",!1)):(f(""),B(Q=>Pe(Q,A?.name||"",!0)))},"handleCustomDestinationCollapsibleOpenChange"),Ke=i($=>{if(S&&k(""),ge($.walletType,$.chain))return;let H=d.find(ne=>ne.walletType===$.walletType&&ne.chain===$.chain);H&&(n(),$.chain===A?.name&&E&&!Z(A.name)&&(x(!1),f(null)),B(ne=>ne.filter(le=>le.chain!==$.chain).concat({...H,selected:!0})))},"onChange"),vt=i(()=>{let $=J.filter(Q=>Q.selected);h($),u($),m(!0),o()},"onConfirmBalance"),lt=i(async()=>{v([]),I(""),b(null);let $=await r?.({selectedWallets:J.filter(H=>H.selected),customDestination:g}),Q=$.warnings;Q?.balance?.messages&&v(Q.balance.messages),Q?.quoteUpdate&&b(Q.quoteUpdate),$.error&&I(Lc($.error)),!$.error&&!Q?.balance?.messages.length?vt():v(Q?.balance?.messages??[])},"onConfirmWallets");hm(()=>{B($=>{let Q=[];return $.forEach(H=>{!d.some(le=>le.chain===H.chain&&le.walletType===H.walletType&&le.address===H.address)||Q.push(H)}),Q=Q.concat(d.filter(H=>!!!Q.find(le=>le.chain===H.chain)&&H.selected&&W.includes(H.chain))),Q})},[d,W]),hm(()=>{let $=[];K.length>0&&(K.forEach(Q=>{let H=d.find(ne=>ne.chain===Q.blockchain&&ne.walletType===Q.walletType);H?Ke(H):$.push(Q)}),me($))},[d,K]);let wt=document.getElementById(_e.SWAP_BOX_ID);return X.createElement(ee,{open:e,onClose:()=>{c||s("../",{replace:!0}),o()},dismissible:!S,container:wt,...!S&&{styles:{container:{height:"100%"}},footer:X.createElement(nm,null,X.createElement(gm,{id:"widget-confirm-wallet-modal-confirm-btn",loading:a,disabled:Yc(a,E,g,p,J,A),onClick:lt,variant:"contained",type:"primary",fullWidth:!0,size:"large"},So.t("Confirm")))},...S&&{styles:{container:{height:"100%",padding:"$0"}},header:X.createElement(Ru,null,X.createElement(em,{id:"widget-confirm-wallet-modal-navigate-back-icon-btn",variant:"ghost",onClick:k.bind(null,"")},X.createElement(Kk,{size:16})),X.createElement(vs,{variant:"headline",size:"small"},So.t({id:"Your {blockchainName} wallets",values:{blockchainName:pt(S,l)}})))},anchor:"center"},X.createElement(ee,{open:fe,onClose:v.bind(null,[]),container:wt},X.createElement(jk,{title:So.t("Insufficient account balance"),type:"error",description:X.createElement(Vk,{messages:T??[]})},X.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&&X.createElement(tm,null,X.createElement("div",{className:om()},X.createElement(Ts,{chain:S,isSelected:ge,selectWallet:Ke,onShowMore:()=>k(S),onConnect:$=>{V(S,$)}}))),!S&&X.createElement(X.Fragment,null,w&&X.createElement(X.Fragment,null,X.createElement(fm,{variant:"alarm",type:"error",title:So.t(w)}),X.createElement(Rr,{size:12})),M&&X.createElement(X.Fragment,null,X.createElement(fm,{variant:"alarm",type:"warning",title:Vr(M)}),X.createElement(Rr,{size:12})),X.createElement(rm,null,W.map(($,Q)=>{let H=l.find(Oe=>Oe.name===$),ne=`wallet-${Q}`,le=Q===W.length-1,pe=le&&A&&C?.customDestination!==!1;return X.createElement("div",{key:ne},X.createElement(Yu,null,X.createElement(vs,{variant:"title",size:"xmedium"},So.t({id:"Your {blockchainName} wallets",values:{blockchainName:H?.shortName}})),X.createElement(vs,{variant:"label",color:"$neutral700",size:"medium"},So.t({id:"You need to connect a {blockchainName} wallet.",values:{blockchainName:H?.shortName}}))),X.createElement(Rr,{size:24}),X.createElement(Zu,null,X.createElement(Ts,{chain:$,isSelected:ge,selectWallet:Ke,limit:Jk,onShowMore:()=>k(H?.name??""),onConnect:Oe=>{V($,Oe)}})),!le&&X.createElement(Rr,{size:32}),pe&&X.createElement(Xu,{blockchain:A,open:E,handleOpenChange:U}))}))))}i(ym,"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 bm}from"@rango-dev/ui";import tt from"react";import{i18n as Sm}from"@lingui/core";var Rk=24,eT=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=Rk]="small",o[o.large=eT]="large",o))(ws||{}),bs=(o=>(o.small="small",o.large="medium",o))(bs||{});import{styled as ei}from"@rango-dev/ui";var km=ei("div",{display:"flex",flexDirection:"column",alignItems:"center"}),Tm=ei("div",{variants:{size:{small:{},large:{maxWidth:"316px"}}}}),vm=ei("div",{variants:{size:{small:{width:"100%"},large:{}}}}),wm=ei("div",{padding:"$6 $0"});function wn(t){let{fetch:e,error:o,size:n="small"}=t,r=y().getDisabledLiquiditySources(),a=y().toggleAllLiquiditySources,s=y().swappers(),l=Cm(o,r,()=>a(s,!0),e);return tt.createElement(km,null,tt.createElement(nT,{size:ws[n],color:"gray"}),tt.createElement(xs,{size:4}),tt.createElement(bm,{variant:"title",size:bs[n]},te().noResultError.title),n==="large"&&tt.createElement(xs,{size:4}),!!l.description&&tt.createElement(Tm,{size:n},tt.createElement(bm,{variant:"body",size:"small",align:"center",color:"neutral700"},l.description)),tt.createElement(xs,{size:n==="large"?"24":"4"}),!!l.alert&&tt.createElement(vm,{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(wm,null,tt.createElement(rT,{size:8})),onClick:l.alert.action.onClick},l.alert.action.title),variant:"alarm"})))}i(wn,"NoResult");import{i18n as bn}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 Am}from"@rango-dev/ui";import Is from"react";import{darkTheme as iT,styled as ti}from"@rango-dev/ui";var xm=ti("div",{width:"100%"}),Es=ti("div",{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"$5",width:"100%"}),Em=ti("div",{display:"flex",padding:"$5 0",justifyContent:"space-between",alignItems:"center",width:"100%","._title":{$$color:"$colors$neutral600",[`.${iT} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),Im=ti("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:bn.t("Swapping"),value:L(r.inputUsdValue,4,4)},{title:bn.t("Gas cost"),value:L(r.totalFee,2,2)},{title:bn.t("Receiving"),value:L(r.outputUsdValue,4,4)},{title:bn.t("Price impact"),value:L(r.priceImpact,2,2),valueColor:`${s}500`}];return _t.createElement(ee,{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"},bn.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 jo}from"@lingui/core";import{Button as Lm,Divider as Bm,MessageBox as uT,Typography as mT}from"@rango-dev/ui";import ko from"react";import{useNavigate as dT}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=dT(),u=e??o;return ko.createElement(ee,{anchor:"bottom",open:n,prefix:ko.createElement(Lm,{size:"small",id:"widget-slippage-warning-modal-change-settings-btn",variant:"ghost",onClick:()=>p("../"+_.settings)},ko.createElement(mT,{variant:"label",size:"medium",color:"$neutral900"},jo.t("Change settings"))),container:N(),onClose:r},ko.createElement(uT,{type:"warning",title:s.type===3?jo.t("High slippage"):jo.t("Low slippage"),description:s.type===3?jo.t({id:" Caution, your slippage is high (={userSlippage}). Your trade may be front run.",values:{userSlippage:u}}):jo.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},jo.t("Confirm anyway"))))}i(Pm,"SlippageWarningModal");import{Button as fT,MessageBox as gT,WarningIcon as hT}from"@rango-dev/ui";import oi from"react";function Dm(t){let{open:e,onClose:o,onConfirm:n,confirmationDisabled:r}=t;return oi.createElement(ee,{footer:oi.createElement(fT,{id:"widget-unknown-price-warning-modal-confirm-btn",type:"primary",size:"large",prefix:oi.createElement(hT,null),fullWidth:!0,disabled:r,onClick:n},te().unknownPriceError.confirmMessage),open:e,onClose:o,container:N()},oi.createElement(gT,{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},g=o?.type===0||o?.type===1,f=Mm(e,o?.type===3||o?.type===4?o:null);return f&&!n&&(f.action=null),ot.createElement(ot.Fragment,null,g&&ot.createElement(wn,{error:o,fetch:s}),!!f&&ot.createElement(xm,null,ot.createElement(ST,{title:f.title,type:f.alertType,variant:"alarm",...f.action==="show-info"&&{action:ot.createElement(Im,{onClick:l},ot.createElement(kT,{size:12,color:"gray"}))},...f.action==="change-settings"&&{action:ot.createElement(CT,{id:"widget-quote-warning-error-change-settings-btn",size:"xxsmall",type:f.alertType,onClick:c},yT.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 ZT from"bignumber.js";import hi from"react";import{i18n as To}from"@lingui/core";import{Alert as FT,Divider as Yo,FullExpandedQuote as OT,InfoIcon as UT,NumericTooltip as fd,QuoteTag as zT,StepDetails as QT,TokenAmount as qT,Typography as Zo}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}}}}),$m=Ns("div",{width:"100%",display:"flex"});import*as ni from"@radix-ui/react-collapsible";import{Button as TT,css as En,darkTheme as we,Image as Fm,styled as qe,Typography as vT}from"@rango-dev/ui";var wT=300,Om=qe(ni.Root,{display:"flex",flexDirection:"column",alignItems:"start",overflowX:"auto",overflowY:"hidden",width:"100%",borderRadius:"$xm",variants:{selected:{true:{},false:{$$color:"$colors$neutral400",[`.${we} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"}},listItem:{true:{$$color:"$colors$neutral400",[`.${we} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"},false:{}}},compoundVariants:[{listItem:!1,selected:!0,css:{$$color:"$colors$secondary200",[`.${we} &`]:{$$color:"$colors$secondary800"},backgroundColor:"$$color"}}]}),Um=En({padding:"$10 $15"}),zm=qe(TT,{backgroundColor:"transparent",border:"1px solid $secondary550",[`.${we} &`]:{border:"1px solid $secondary"},transition:"background-color 0.3s ease","&:hover":{backgroundColor:"$secondary550",[`.${we} &`]:{backgroundColor:"$secondary"},".allRoutesLabel":{$$color:"$colors$background",[`.${we} &`]:{$$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",[`.${we} &`]:{$$color:"$colors$neutral500"},backgroundColor:"$$color"}},basic:{true:{borderTopRightRadius:"0",borderTopLeftRadius:"0"}},listItem:{true:{$$color:"$colors$neutral200",[`.${we} &`]:{$$color:"$colors$neutral500"},backgroundColor:"$$color","&:hover":{"& .quote_container":{"& button":{backgroundColor:"$neutral500",[`.${we} &`]:{backgroundColor:"$neutral200"}},backgroundColor:"$neutral500",[`.${we} &`]:{backgroundColor:"$neutral200"}},backgroundColor:"$neutral300",[`.${we} &`]:{backgroundColor:"$neutral400"}},cursor:"pointer"},false:{}}},compoundVariants:[{listItem:!0,selected:!0,css:{outline:"1px solid $secondary"}},{listItem:!1,selected:!0,css:{$$color:"$colors$secondary100",[`.${we} &`]:{$$color:"$colors$secondary550"},backgroundColor:"$$color","&:hover":{backgroundColor:"$$color"}}},{listItem:!0,selected:!1,css:{cursor:"pointer","&:hover":{backgroundColor:"$neutral300",[`.${we} &`]:{backgroundColor:"$neutral400"}}}}]}),qm=En({width:"100%",padding:"$15 $15 $10 $15"}),Hm=En({display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingBottom:"$10",position:"relative"}),Xo=En({display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",".blockchainImage":{marginLeft:"-$8"}}),Gm=En({display:"flex",alignItems:"center",".usd-value":{$$color:"$colors$neutral600",[`.${we} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),Vm=qe(ni.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",[`.${we} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"}},listItem:{true:{$$color:"$colors$neutral400",[`.${we} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"},false:{}}},compoundVariants:[{listItem:!1,selected:!0,css:{$$color:"$colors$secondary200",[`.${we} &`]:{$$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(jr,{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"}),Xm=qe("div",{display:"flex",justifyContent:"center",margin:"0 $15",borderTop:"1px solid",$$color:"$colors$neutral300",[`.${we} &`]:{$$color:"$colors$neutral400"},borderColor:"$$color"}),Ym=qe("div",{width:"$16",height:"$16",justifyContent:"center",alignItems:"center",display:"flex"}),Ls=qe(vT,{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"}),ri=qe("div",{width:"100%",borderTopWidth:"1px",borderTopStyle:"solid",borderTopColor:"$neutral",margin:"$5 0",[`.${we} &`]:{borderTopColor:"$neutral800"}});import{i18n as Nt}from"@lingui/core";import{ChevronDownIcon as xT,CloseIcon as ET,Divider as si,IconButton as IT,NumericTooltip as AT,QuoteCost as NT,Typography as yt}from"@rango-dev/ui";import Y,{useState as od}from"react";import{css as bT,styled as ii}from"@rango-dev/ui";var ai=ii("div",{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"$5 0","&.total_payable_fee":{padding:"$12 0"}}),Ps=ii("div",{width:"100%",borderTop:"1px solid $neutral300",margin:"$10 0"}),Rm=ii("div",{padding:"$20 0",display:"flex",flexDirection:"column","& .collapsible_trigger":{display:"flex",alignItems:"center"}}),ed=ii("div",{padding:"$20 $20 $10",textAlign:"center",position:"relative","._icon-button":{position:"absolute",zIndex:10,top:"$16",right:"$16"}}),td=bT({display:"flex",flexDirection:"row",alignItems:"center",padding:"$5","&:hover":{"& ._typography, & svg":{color:"$secondary"}}});var WT=i(t=>t.fee.isZero()?null:Y.createElement(ai,null,Y.createElement(yt,{variant:"label",size:"medium",color:"neutral600"},t.label),Y.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??[],g=N(),f=Fc(m);return Y.createElement(Y.Fragment,null,Y.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:g}),Y.createElement(ee,{container:g,open:e,header:Y.createElement(ed,null,Y.createElement(yt,{variant:"title",size:"medium"},Nt.t("Gas & Fee Explanation")),Y.createElement(IT,{id:"widget-quote-cost-details-modal-close-icon-btn",onClick:()=>o(!1),variant:"ghost"},Y.createElement(ET,{color:"gray",size:14}))),onClose:()=>{o(!1)}},Y.createElement(Rm,null,Y.createElement(yt,{variant:"title",size:"small"},Nt.t("Details")),Y.createElement(si,{size:10}),Object.entries(f.payable).flatMap(([d,h])=>h.map((C,S)=>{let k=`payable-fee-${S}`,T=Ba(C);return Y.createElement(ai,{key:k},Y.createElement(yt,{variant:"label",size:"medium",color:"neutral600"},Na(d,Nt.t)),Y.createElement(AT,{content:C.amount,container:g},Y.createElement(yt,{variant:"label",size:"medium"},L(C.amount,2,2)," ",C.asset.symbol," ($",L(T,4,4),")")))})),Y.createElement(ai,{className:"total_payable_fee"},Y.createElement(yt,{variant:"label",size:"medium"},Nt.t("Total Payable Fee")),Y.createElement(yt,{variant:"label",size:"medium"},"$",L(l,4,4))),Y.createElement(Ps,null),Object.keys(f.nonePayable).length&&Y.createElement(Zr,{triggerAnchor:"bottom",onClickTrigger:()=>r(d=>!d),trigger:Y.createElement("div",{className:td()},Y.createElement(yt,{size:"small",variant:"body",color:"neutral700"},n?Nt.t("Hide non-payable fees"):Nt.t("Show non-payable fees")),Y.createElement(si,{size:4,direction:"horizontal"}),Y.createElement(Xr,{orientation:n?"up":"down"},Y.createElement(xT,{size:12,color:"gray"}))),open:n},Y.createElement(yt,{size:"small",variant:"title"},Nt.t("Description")),Y.createElement(si,{size:4}),Y.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.`)),Y.createElement(si,{size:10}),Object.entries(f.nonePayable).map(([d,h],C)=>{let S=$c(h),k=Na(d,Nt.t),T=`non-payable-fee-${C}`;return Y.createElement(WT,{key:T,fee:S,label:k})}),Y.createElement(Ps,null)))))}i(nd,"QuoteCostDetails");import{i18n as ad}from"@lingui/core";import{TokenAmount as sd}from"@rango-dev/ui";import li from"react";import{css as MT,styled as LT}from"@rango-dev/ui";var rd=LT("div",{position:"relative",display:"flex",flexDirection:"column",width:"100%"}),id=MT({height:"14px",marginLeft:"14px",position:"absolute",borderLeft:"1px solid $foreground",top:"42%"});function In(t){let{from:e,to:o,percentageChange:n,warningLevel:r}=t;return li.createElement(rd,null,li.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}}),li.createElement("div",{className:id()}),li.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(In,"QuoteSummary");import{i18n as md}from"@lingui/core";import{ChevronDownIcon as DT,ChevronRightIcon as _T,Divider as Ds,Image as $T,Tooltip as di,Typography as ci}from"@rango-dev/ui";import O from"react";import{useLayoutEffect as BT,useState as An}from"react";var ld=480,pd=768,cd=1024,ud=1200,PT=i(()=>{let[t,e]=An(!1),[o,n]=An(!1),[r,a]=An(!1),[s,l]=An(!1),[p,u]=An(!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 BT(()=>(c(),window.addEventListener("resize",c),()=>window.removeEventListener("resize",c)),[]),{isMobile:t,isTablet:o,isNotebook:r,isLargeScreen:s,isExtraLargeScreen:p}},"useScreenDetect"),pi=PT;var ui=4,mi=6,Nn=i(t=>{let{content:e,src:o,className:n,open:r,state:a,container:s}=t,l=s||N();return O.createElement(di,{container:l,side:"bottom",sideOffset:4,open:r,content:e},O.createElement(Km,{className:n,state:a},O.createElement($T,{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:g}=pi();return O.createElement(Vm,{listItem:s==="list-item",ref:f=>e.current=f,selected:o,onClick:f=>{f.stopPropagation(),n(d=>!d)}},O.createElement("div",{className:Xo()},O.createElement(ci,{variant:"body",size:"xsmall"},md.t("Via:")),O.createElement(Ds,{direction:"horizontal",size:4}),r.map((f,d)=>{let h=`item-${d}`,C=O.createElement(Ms,null,O.createElement(_T,{size:12,color:"black"}));return g||m?O.createElement(O.Fragment,{key:h},O.createElement(Nn,{content:f.swapper.displayName,src:f.swapper.image,state:f.state,container:l}),d!==u-1&&O.createElement(O.Fragment,null,C)):O.createElement(O.Fragment,{key:h},u<=ui||u>ui&&d<ui-1?O.createElement(O.Fragment,null,O.createElement(Nn,{content:f.swapper.displayName,src:f.swapper.image,state:f.state,container:l}),d!==u-1&&O.createElement(O.Fragment,null,C)):d===ui-1&&O.createElement(di,{container:p,side:"bottom",align:"end",sideOffset:4,content:O.createElement("div",{className:Xo()},C,r.map((S,k)=>{let T=`image-${k}`;return k>=d&&O.createElement(O.Fragment,{key:T},O.createElement(Nn,{content:S.swapper.displayName,src:S.swapper.image,state:S.state,open:!1}),k!==u-1&&O.createElement(O.Fragment,null,C))}))},O.createElement(Bs,{state:r.find((S,k)=>k>=d&&(S.state==="error"||S.state==="warning"))?.state},O.createElement(ci,{size:"xsmall",variant:"body"},"+",u-d))))})),O.createElement("div",{className:Xo()},O.createElement("div",{className:"blockchains_section"},O.createElement("div",{className:Xo()},O.createElement(ci,{variant:"body",size:"xsmall"},md.t("Chains:")),O.createElement(Ds,{direction:"horizontal",size:4}),c.map((f,d)=>O.createElement(O.Fragment,{key:f.displayName},c.length<=mi||c.length>mi&&d<mi-1?O.createElement(di,{container:p,side:"bottom",content:f.displayName,sideOffset:4},O.createElement(Nn,{content:"",src:f.image,open:!1,className:d!==0?"blockchainImage":""})):d===mi-1&&O.createElement(di,{container:p,side:"bottom",align:"end",sideOffset:4,content:O.createElement("div",{className:Xo()},c.map((h,C)=>C>=d&&O.createElement(Nn,{key:h.displayName,content:"",src:h.image,open:!1,className:C>d?"blockchainImage":"",container:l})))},O.createElement(Bs,{className:"blockchainImage"},O.createElement(ci,{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(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:g}=t,f=y().blockchains(),{findToken:d}=y(),h=y().swappers(),{customSlippage:C,slippage:S}=y(),k=C||S,[T,v]=GT(t.expanded),w=HT(null),I=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),D=i((ge,Pe)=>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,H=$;Q?vt="error":H&&(vt="warning");let ne=Q?To.t("Slippage Error"):To.t("Slippage Warning");return lt&&(ne=To.t("Bridge Limit Error")),{swapper:{displayName:nn(U.swapperId,h)??"",image:U.swapperLogo},from:{token:{displayName:U.from.symbol,image:U.from.logo},chain:{displayName:pt(U.from.blockchain,f)??"",image:U.from.blockchainLogo},price:{value:Ke===0&&!Pe?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,f)||"",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||H?F.createElement(_m,{dense:m},F.createElement(FT,{variant:"alarm",type:Q?"error":"warning",title:ne,footer:F.createElement($m,null,lt&&F.createElement("div",null,F.createElement(Zo,{size:"xsmall",variant:"body",color:"neutral900"},r.fromAmountRangeError),F.createElement(Yo,{direction:"vertical",size:2}),F.createElement(Zo,{size:"xsmall",variant:"body",color:"neutral900"},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(Zo,{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(Yo,{direction:"vertical",size:2}),F.createElement(Zo,{size:"xsmall",variant:"body",color:"neutral900"},To.t({id:"Yours: {userSlippage}",values:{userSlippage:k}}))))})):void 0,time:ln(U.estimatedTimeInSeconds),fee:L(La(U,d),2,2),internalSwaps:U.internalSwaps?D(U.internalSwaps):void 0}}),"getQuoteSteps"),A=D(e?.swaps??[]),Z=A.length,ae=g||N(),J=nu(t.quote.tags||[]),B=!!c,K=ln(sr(e?.swaps)),me=Mr(e?.swaps??[],d),V=L(me,2,2),fe=me.gte(new _s(Mc));return m?F.createElement(OT,{selected:l,fee:V,time:K,tooltipContainer:sn(),steps:A,tags:J,feeWarning:fe,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:qm()},!p&&J.length?F.createElement(F.Fragment,null,F.createElement(Jm,null,J.map((ge,Pe)=>{let U=`${ge.value}_${Pe}`;return F.createElement(F.Fragment,{key:U},F.createElement(zT,{label:ge.label,value:ge.value}),F.createElement(Yo,{size:4,direction:"horizontal"}))})),F.createElement(ri,null),!B&&F.createElement(Yo,{size:4})):null,F.createElement("div",{id:"portal-root",className:Hm()},F.createElement(nd,{quote:e,time:K,fee:V,feeWarning:fe,showModalFee:u,steps:Z}),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(Zo,{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(UT,{size:12,color:"gray"})),F.createElement(Zm,null,F.createElement(Ls,{size:"small",variant:"body"},`${I} ${A[0].from.token.displayName} = `),F.createElement(fd,{content:n.value,container:ae,open:n.value?void 0:!1},F.createElement(Ls,{size:"small",variant:"body"},"\xA0",`${M} ${A[A.length-1].to.token.displayName}`))),F.createElement(fd,{content:n.usdValue,container:ae},F.createElement(Yo,{size:2,direction:"horizontal"}),F.createElement(Zo,{color:"$neutral600",size:"xsmall",variant:"body"},`($${b})`))),s==="list-item"&&F.createElement(qT,{tooltipContainer:ae,type:"output",direction:"vertical",price:{value:M,usdValue:b,realValue:n.value,realUsdValue:n.usdValue},token:{displayName:A[Z-1].to.token.displayName,image:A[Z-1].to.token.image},chain:{image:A[Z-1].to.chain.image},percentageChange:x,warningLevel:W}),s==="swap-preview"&&F.createElement(F.Fragment,null,F.createElement(In,{from:A[0].from,to:A[Z-1].to,percentageChange:x,warningLevel:W}),F.createElement(Yo,{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:ae,expanded:T,steps:A}),F.createElement(jm,{open:T},F.createElement(Xm,null),F.createElement("div",{className:Um()},A.map((ge,Pe)=>{let U=`item-${Pe}`;return F.createElement(QT,{type:"quote-details",key:U,tooltipContainer:ae,step:ge,hasSeparator:Pe!==A.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 fi}from"@rango-dev/ui";var gd=fi("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"}}}}),hd=fi("div",{paddingTop:"$2"}),yd=fi("div",{paddingLeft:"$8"}),Sd=fi("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 KT,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"}),bd=$t("div",{width:"65%",display:"flex",justifyContent:"start"}),xd=$t("div",{display:"flex",flexDirection:"column",alignItems:"start",flexGrow:1,maxWidth:"148px"}),Ed=$t("div",{padding:"$15 $0 $15 $0"}),Id=KT({display:"flex",justifyContent:"space-between",alignItems:"center"});function Wn(t){let{type:e,tagHidden:o=!0}=t,n=q.createElement(vd,null,q.createElement(bd,null,q.createElement(Ad,{loading:!0,size:"medium",chainImage:"",tokenImage:""}),q.createElement(St,{size:8,direction:"horizontal"}),q.createElement(xd,null,q.createElement(nt,{height:10,width:60,variant:"rounded"}),q.createElement(St,{size:4}),q.createElement(nt,{height:15,variant:"rounded"}))),q.createElement(nt,{height:12,width:64,variant:"rounded"})),r=e==="basic"&&!o;return q.createElement("div",null,!o&&q.createElement(q.Fragment,null,q.createElement(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(ri,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(Wn,"QuoteSummarySkeleton");import{ChainToken as Bd,Divider as Us,NextIcon as jT,Skeleton as gi}from"@rango-dev/ui";import be from"react";import{styled as Mn}from"@rango-dev/ui";var Nd=Mn("div",{display:"flex",alignItems:"start"}),Wd=Mn("div",{flexGrow:1,paddingTop:"$5",paddingBottom:"$10",display:"flex",alignItems:"center",variants:{extraSpace:{true:{paddingBottom:"$40"}}}}),Os=Mn("div",{display:"flex",alignItems:"center",flexGrow:1}),Md=Mn("div",{margin:"$0 $2",padding:"$4",display:"flex",justifyContent:"center",alignItems:"center"}),Ld=Mn("div",{display:"flex",alignItems:"center"});function Wt(t){let{separator:e=!0}=t;return be.createElement(be.Fragment,null,be.createElement(Ld,null,be.createElement(gi,{height:22,width:22,variant:"circular"}),be.createElement(Us,{direction:"horizontal",size:8}),be.createElement(gi,{height:15,width:148,variant:"rounded"})),be.createElement(Nd,null,be.createElement(Sd,{hideSeparator:!e}),be.createElement(Wd,{extraSpace:e},be.createElement(Os,null,be.createElement(Bd,{size:"small",loading:!0,chainImage:"",tokenImage:""}),be.createElement(Us,{direction:"horizontal",size:8}),be.createElement(gi,{height:12,variant:"rounded"})),be.createElement(Md,null,be.createElement(jT,{color:"gray",size:16})),be.createElement(Os,null,be.createElement(Bd,{size:"small",loading:!0,chainImage:"",tokenImage:""}),be.createElement(Us,{direction:"horizontal",size:8}),be.createElement(gi,{height:12,variant:"rounded"})))))}i(Wt,"StepSkeleton");function Ln(t){let{type:e,expanded:o,tagHidden:n=!1}=t;return Ft.createElement(gd,{expanded:o,rounded:e!=="basic"},Ft.createElement(Wn,{type:e,tagHidden:n}),Ft.createElement(hd,null,Ft.createElement(YT,{height:15,variant:"rounded"})),o&&Ft.createElement(yd,null,Ft.createElement(XT,{size:24}),Ft.createElement(Wt,null),Ft.createElement(Wt,null),Ft.createElement(Wt,{separator:!1})))}i(Ln,"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:g=!1,container:f}=t,{inputAmount:d,inputUsdValue:h,toToken:C}=z(),S=e?.outputAmount?new ZT(e?.outputAmount):null,k=e?.outputAmount?jt(e?.outputAmount,go(e)||C?.usdPrice):null,v=!(r&&(r.type===0||r.type===1))&&e&&!n;return n?hi.createElement(Ws,null,hi.createElement(Ln,{tagHidden:l,type:o,expanded:s})):v?hi.createElement(Ws,{onClick:()=>p?.(e)},hi.createElement($s,{quote:e,error:r,container:f,showModalFee:u,warning:a,tagHidden:l,selected:c,type:o,expanded:s,onClickAllRoutes:m,fullExpandedMode:g,input:{value:d,usdValue:h?.toString()??""},output:{value:S?.toString()??"",usdValue:k?.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 yi({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(yi,"useFetch");function Pd(){let{fetch:t,loading:e,cancelFetch:o}=yi({request:async(n,r)=>await Et().confirmRoute(n,r)});return{fetch:t,loading:e,cancelFetch:o}}i(Pd,"useFetchConfirmQuote");function Si(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(Si,"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=Lr(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=Oo(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(Fo(e)),percentageChange:L(ct(Fo(t)??"",Fo(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 Ci(t){return t?.code==="ERR_CANCELED"?{swap:null,error:{type:2},warnings:null}:t.cause?{swap:null,error:t.cause,warnings:null}:t?.code==="ERR_BAD_REQUEST"?{swap:null,error:{type:0,diagnosisMessage:t.response.data.error},warnings:null}:{swap:null,error:{type:1},warnings:null}}i(Ci,"handleQuoteErrors");function Qs(){let{fromToken:t,toToken:e,inputAmount:o,setSelectedQuote:n,selectedQuote:r,customDestination:a,setQuoteWarningsConfirmed:s,resetAlerts:l}=z(),{slippage:p,customSlippage:u}=y(),c=y().getDisabledLiquiditySources(),m=y().blockchains(),g=y().tokens(),{findToken:f}=y(),d=u||p,{fetch:h,cancelFetch:C,loading:S}=Pd();return ov(()=>C,[]),{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 I=v.reduce((b,E)=>(b[E.chain]=E.address,b),{}),M={requestId:r?.requestId||"",selectedWallets:I,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");Si({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=Dd(r??void 0,x,{fromToken:t,toToken:e,meta:{blockchains:m},findToken:f,selectedWallets:v,userSlippage:d});D.quoteUpdate&&s(!1),l();let A=!!D.balance,Z=tv(o.toString(),E,qc(v),W,!A,{blockchains:m,tokens:g});return{quote:x,swap:Z,error:null,warnings:D}})}catch(b){return Ci(b)}},"fetch"),cancelFetch:C}}i(Qs,"useConfirmSwap");var uv=iv("div",{width:"100%",display:"flex",justifyContent:"space-between",[`& ${$d}`]:{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 Fd(){let{selectedQuote:t,setInputAmount:e,selectedWallets:o,quoteWalletsConfirmed:n,customDestination:r,quoteWarningsConfirmed:a}=z(),s=cv(),[l,p]=Bn(""),u=!n,[c,m]=Bn(!1),[g,f]=Bn(!1),{isActiveTab:d}=se(),h=y().getDisabledLiquiditySources(),C=pv(h),{manager:S}=nv(),{fetch:k,loading:T,cancelFetch:v}=Qs(),[w,I]=Bn({swap:null,error:null,warnings:null}),[M,b]=Bn(!1),E=i(async({selectedWallets:B,customDestination:K})=>{let me=await k?.({selectedWallets:B,customDestination:K});return I(me),me},"onConfirmSwap"),x=i(async()=>{if(w.swap&&n)try{await S?.create("swap",{swapDetails:w.swap},{id:w.swap.requestId});let B=`../${_.swaps}/${w.swap.requestId}`;s(B,{replace:!0}),setTimeout(()=>{e("")},0)}catch(B){p("Error: "+B?.message)}},"addNewSwap"),W=i(async()=>{f(!0),await x(),f(!1)},"onConfirm"),D=i(async()=>{w?.warnings?.quote&&!a?b(!0):await W()},"onStartConfirmSwap"),A=i(async()=>{I({error:null,swap:null,warnings:null}),k({selectedWallets:o,customDestination:r}).then(B=>{I(B)}).catch(B=>console.error(B))},"onRefresh");ki(()=>{!!C.current.length&&!h.length&&A(),C.current=h},[h.length]),ki(()=>{u&&v()},[u]),ki(()=>{u&&m(u)},[u]),ki(()=>{u||k({selectedWallets:o,customDestination:r}).then(B=>I(B)).catch(B=>console.error(B))},[]),lv(()=>{t?.requestId||s(`../${location.search}`)},[t?.requestId]);let Z=w.warnings?.quote??null,ae=w.error,J=[];if(l&&J.push(xe.createElement(_d,{type:"error",variant:"alarm",title:l})),w.warnings?.quoteUpdate&&J.push(xe.createElement(_d,{variant:"alarm",type:"warning",title:w.warnings.quoteUpdate&&Vr(w.warnings.quoteUpdate)})),Z||ae){let B=`../${_.settings}`;J.push(xe.createElement(xn,{warning:Z,error:ae,couldChangeSettings:!1,refetchQuote:A,showWarningModal:M,confirmationDisabled:!d,onOpenWarningModal:()=>b(!0),onCloseWarningModal:()=>b(!1),onConfirmWarningModal:async()=>{b(!1),await x()},onChangeSettings:()=>s(B)}))}return xe.createElement(oe,{header:{title:qs.t("Confirm Swap"),onWallet:()=>{let B=`../${_.wallets}`;s(B)}},footer:xe.createElement(uv,null,xe.createElement("div",{className:mv()},xe.createElement(rv,{id:"widget-confirm-swap-start-btn",variant:"contained",type:"primary",size:"large",fullWidth:!0,loading:T||g,disabled:!!w.error||!d,onClick:D},qs.t("Start Swap"))),xe.createElement($d,{id:"widget-confirm-swap-wallet-icon-btn",variant:"contained",type:"primary",size:"large",loading:T||g,disabled:!d,onClick:m.bind(null,!0)},xe.createElement(sv,{size:24})))},c&&xe.createElement(ym,{open:c,onClose:()=>m(!1),onCancel:v,loading:T,onCheckBalance:E}),xe.createElement(re,null,xe.createElement("div",{className:fv()},xe.createElement(av,{variant:"title",size:"small"},qs.t("You get")),xe.createElement("div",{className:dv()},xe.createElement(Ur,{onClick:!T&&!c&&!M?A:void 0}))),xe.createElement(Hs,{size:"12"}),yu(J.map((B,K)=>({element:B,key:`alert-${K}`})),xe.createElement(Hs,{size:10})),J.length>0?xe.createElement(Hs,{size:10}):null,xe.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 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 de,{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 Pn from"react";import{styled as gv}from"@rango-dev/ui";var Od=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 Pn.createElement(Cv,{prefix:Pn.createElement(Od,null,Pn.createElement(Sv,{color:"black"})),suffix:!!s.length&&Pn.createElement(yv,{variant:"ghost",onClick:()=>p?.(""),size:"small"},Pn.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 Yd,Divider as Ro,ExternalLinkIcon as Ev,Image as Iv,ListItemButton as Av,NotFound as Nv,PinIcon as Wv,Skeleton as Zd,Typography as wi,VirtualizedList as Mv}from"@rango-dev/ui";import G,{useEffect as Jd,useState as Rd}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}=R(),{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 Sr.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))}),()=>Sr.off("walletEvent",s)):a(p=>p+1)},[e,t,o]),{balanceKey:r}}i(Vs,"useObserveBalanceChanges");import{Divider as jd,ListItem as xv,Skeleton as Dn}from"@rango-dev/ui";import kt from"react";import{css as Jo,darkTheme as Ud,ImageContainer as bv,styled as mt,Typography as zd}from"@rango-dev/ui";var Ks=Jo({position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:100,overflow:"hidden"}),js=Jo({position:"relative",height:12,width:"30%",maxWidth:"150px"}),Xs=Jo({position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",bottom:"-8px"}),Ys=Jo({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=Jo({}),Js=Jo(),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"}}),Ti=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"}}),vi=mt("div",{display:"flex",alignItems:"end",flexDirection:"column"}),LU=mt("div",{display:"flex",alignItems:"center"}),Hd=mt("div",{position:"relative",[`& ${bv}`]:{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(Ti,null,Array.from(Array(t.size),e=>kt.createElement(xv,{key:e,hasDivider:!0,start:kt.createElement(Dn,{variant:"circular",width:35,height:35}),end:kt.createElement(vi,null,kt.createElement(Dn,{variant:"text",size:"large",width:70}),kt.createElement(jd,{size:4}),kt.createElement(Dn,{variant:"text",size:"medium",width:50})),title:kt.createElement("div",null,kt.createElement(Dn,{variant:"text",size:"large",width:90}),kt.createElement(jd,{size:4}),kt.createElement(Dn,{variant:"text",size:"medium",width:90}))})))}i(Xd,"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 G.createElement("div",{className:js()},o?G.createElement("div",{className:Ks()},o):G.createElement(Rs,{className:Xs()},G.createElement(wi,{variant:"title",size:"xmedium"},r.symbol),G.createElement(Ro,{direction:"horizontal",size:4}),G.createElement(el,{css:a},G.createElement(tl,{variant:"body",size:"xsmall",css:s},r.blockchain))),!!e&&G.createElement("div",{className:`${Ys()} ${!o&&Zs()}`},l>10?`${e.slice(0,5)}...${e.slice(l-6,l)}`:e," ",G.createElement(Ro,{size:4,direction:"horizontal"}),G.createElement(Kd,{href:n,target:"_blank",rel:"nofollow noreferrer",onClick:p=>p.stopPropagation()},G.createElement(Ev,{size:12}))))},"renderDesc");function _n(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,g]=Rd(!0),{getBalanceFor:f,loading:d}=R(),{isTokenPinned:h}=y(),{balanceKey:C}=Vs(r),S=i(()=>{p(e.slice(0,l.length+nl))},"loadNextPage");Jd(()=>{g(e.length>l.length)},[l.length]),Jd(()=>{p(e.slice(0,nl))},[e.length,r,C]);let k=i(v=>{let w=dr(f(v));return s?s(v):d?G.createElement(vi,null,G.createElement(Zd,{variant:"text",size:"large",width:70}),G.createElement(Ro,{size:4}),G.createElement(Zd,{variant:"text",size:"medium",width:50})):w&&G.createElement(qd,null,G.createElement(Vd,{variant:"title",size:"small"},w.amount),G.createElement("div",null),w.usdValue&&G.createElement(wi,{variant:"body",className:Js(),size:"xsmall"},`$${w.usdValue}`))},"endRenderer"),T=i(()=>G.createElement(Mv,{endReached:m?S:void 0,itemContent:v=>{let w=l[v],I=w.address||"",M=c.find(W=>W.name===w.blockchain),b=Xa(M.color,"main"),E={$$color:b.main150,[`.${Yd} &`]:{$$color:b.main750},backgroundColor:"$$color"},x={$$color:b.main750,[`.${Yd} &`]:{$$color:b.main150},color:"$$color"};return G.createElement("div",{style:{paddingRight:5}},G.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:G.createElement(Hd,null,G.createElement(Iv,{src:w.image,size:30}),t.type!=="custom-token"&&h(w,t.type)&&G.createElement(Gd,null,G.createElement(Wv,{size:12,color:"gray"}))),title:M?.type==="COSMOS"||w.name||!w.name&&!I?G.createElement(Rs,null,G.createElement(wi,{variant:"title",size:"xmedium"},w.symbol),G.createElement(Ro,{direction:"horizontal",size:4}),G.createElement(el,{css:E},G.createElement(tl,{variant:"body",size:"xsmall",css:x},w.blockchain))):void 0,description:M?.info&&I&&M.type!=="COSMOS"?Lv({address:I,token:l[v],customCssForTag:E,customCssForTagTitle:x,name:w.name,url:M.info.addressUrl.split("{wallet}").join(I)}):w.name||void 0,end:k(w)}))},totalCount:l.length,key:`${r}-${o}-${C}`}),"renderList");return G.createElement(G.Fragment,null,a&&G.createElement(G.Fragment,null,G.createElement(wi,{variant:"label",size:"large"},ol.t("Select Token")),G.createElement(Ro,{size:4})),G.createElement(Qd,null,G.createElement(Ro,{size:4}),u==="loading"&&G.createElement(Xd,{size:nl}),u==="success"&&(l.length?G.createElement(Ti,{as:"ul"},T()):!!o&&G.createElement(Nv,{title:ol.t("No results found"),description:ol.t("Try using different keywords")}))))}i(_n,"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 ef(){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),[g,f]=il(),d=i(k=>{let T=k.target.value;e(T)},"handleSearch"),h=p==="dark",C=n.filter(k=>et(k.symbol,t)||et(k.address||"",t)||et(k.name||"",t)),S=i(()=>{if(g){let k=a?De(a):null,T=r?De(r):null,v=De(g);k===v?l({token:null}):T===v&&s({token:null}),o(g)}m(!1)},"handleDeleteCustomToken");return de.createElement(oe,{header:{title:Ot.t("Custom Tokens")}},de.createElement(re,null,de.createElement(Uv,null,n.length?de.createElement(de.Fragment,null,de.createElement(Ct,{value:t,setValue:e,fullWidth:!0,color:"light",variant:"contained",placeholder:Ot.t("Search Token"),onChange:d}),de.createElement($n,{size:16}),de.createElement(_n,{list:C,type:"custom-token",searchedFor:t,showTitle:!1,action:k=>de.createElement(Qv,{id:"widget-custom-token-delete-icon-btn",variant:"ghost",onClick:()=>{m(!0),f(k)}},de.createElement(Dv,{size:12,color:"gray"}))})):de.createElement(zv,null,de.createElement(Fv,{icon:h?de.createElement(Bv,{size:200}):de.createElement(Pv,{size:200}),title:Ot.t("No custom tokens"),description:Ot.t("press the button to add your custom token")})),de.createElement($n,{size:20}),de.createElement(rl,{id:"widget-custom-token-add-btn",type:"primary",variant:"contained",size:"large",onClick:()=>u(_.addCustomTokens)},Ot.t("Add Custom Token"))),de.createElement(ee,{open:c,dismissible:!0,onClose:()=>m(!1),container:N()},de.createElement($v,{title:Ot.t("Delete Custom Token"),type:"error",description:Ot.t("Are you sure you want to Delete this Token?")},de.createElement($n,{size:40}),de.createElement($n,{size:10}),de.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")),de.createElement($n,{size:12}),de.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 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 Ei}from"@rango-dev/ui";import{TransactionStatus as Un}from"rango-types";import ie,{useMemo as kf,useState as Ii}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 bi,IconButton as Hv,styled as Fn}from"@rango-dev/ui";var sl=Fn("div",{position:"relative","&::before":{position:"absolute",right:"1px",top:"-1px",width:"$8",height:"$8",borderRadius:"100%",backgroundColor:"$neutral300",[`.${bi} &`]:{backgroundColor:"$neutral400"},padding:"$2"},variants:{isSelect:{true:{"&::before":{content:""}}}}}),tf=Fn(Hv,{width:"$36",height:"$36",position:"relative",padding:"0",overflow:"unset",backgroundColor:"$neutral300",[`.${bi} &`]:{backgroundColor:"$neutral400"},"&:hover":{backgroundColor:"$secondary100",[`.${bi} &`]:{backgroundColor:"$neutral"},[`& ${sl}::before`]:{backgroundColor:"$secondary100",[`.${bi} &`]:{backgroundColor:"$neutral"}}},variants:{isSelect:{true:{border:"1px solid $secondary"}}}}),of=Fn("div",{position:"absolute",width:"$6",height:"$6",display:"flex",justifyContent:"center",alignItems:"center",borderRadius:"3px",top:"$0",right:"1px",backgroundColor:"$secondary500"}),nf=Fn("div",{padding:"$15",borderRadius:"$sm",width:"248px",backgroundColor:"$background",zIndex:10}),rf=qv({display:"flex",justifyContent:"space-between",alignItems:"center"}),af=Fn("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 Gv,Divider as lf,ListItemButton as Vv,Radio as Kv,RadioRoot as jv,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(Gv,{id:"widget-filter-selector-reset-btn",variant:"ghost",size:"xxsmall",onClick:()=>o("")},sf.t("Reset"))),rt.createElement(lf,{size:10}),rt.createElement(jv,{value:e},rt.createElement(af,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(lf,{direction:"horizontal",size:4}),rt.createElement(pf,{size:"medium",variant:"body"},n.title)),start:rt.createElement(Kv,{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(Yv,{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(Xv,{size:16,color:"black"}),!!n&&wo.createElement(of,null)))))}i(ll,"FilterSelector");import{i18n as Rv}from"@lingui/core";import{Divider as gf,GroupedVirtualizedList as ew,Skeleton as tw,SwapListItem as hf,Typography as ow}from"@rango-dev/ui";import He,{useCallback as yf,useEffect as nw,useRef as rw,useState as iw}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 Zv,darkTheme as Jv,styled as On}from"@rango-dev/ui";var pl=Zv(),mf=On("div",{display:"flex",justifyContent:"center",alignItems:"center",padding:"$5"}),cl=On("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=On("div",{display:"flex",justifyContent:"flex-start",padding:"$2"}),df=On("div",{gap:"$10",display:"flex",flexDirection:"column"}),ff=On("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=yf(uf,[]),g=yf(()=>{let f=e.length-l.current;f&&(l.current+=Math.min(f,aw),s(m(u,l.current)))},[e.length]);if(nw(()=>{r||g()},[r,g]),r){let f=[1,2];return He.createElement(He.Fragment,null,[f,f].map((h,C)=>He.createElement(cl,{key:C},He.createElement(ul,null,He.createElement(tw,{variant:"text",width:60,size:"small"}),He.createElement(gf,{size:16})),He.createElement(gf,{size:4}),He.createElement(df,null,h.map((k,T)=>He.createElement(hf,{isLoading:!0,key:T}))))))}return He.createElement(ew,{endReached:()=>{l.current<e.length&&g()},groupCounts:a,groupContent:f=>He.createElement(cl,null,He.createElement(ul,null,He.createElement(ow,{variant:"label",size:"medium",className:pl()},c[f]))),itemContent:(f,d)=>{let h=p[f];if(!h)return null;let C=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]===Rv.t("Today"),swapTokenData:{from:{token:{image:C.fromLogo,displayName:C.fromSymbol},blockchain:{image:C.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 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:Un.SUCCESS,title:Ge.t("Complete")},{id:Un.RUNNING,title:Ge.t("Running")},{id:Un.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 Tf(){let t=uw(),{manager:e,state:o}=sw(),n=ut(e).map(({swap:T})=>T),[r,a]=Ii(""),[s,l]=Ii(!1),p=!o.loadedFromPersistor,[u,c]=Ii(""),[m,g]=Ii(!1),f=i(T=>{let v=T.target.value;a(v)},"handleSearch"),d=kf(()=>!r&&!u?n:n.filter(T=>{let{inputAmount:v,status:w,steps:I,requestId:M}=T;return(!r||bt(v,r)||bt(w,r)||hw(I,r)||bt(M,r))&&(!u||u===w)}),[n,r,u]),h=!d?.length&&!p,C=i(()=>g(!1),"onCloseModal"),S=i(async()=>{try{await e?.clearQueue(),g(!1)}catch(T){console.log(T)}},"onClear"),k=kf(()=>!n.some(T=>T.status===Un.SUCCESS||T.status===Un.FAILED),[n]);return ie.createElement(oe,{header:{title:Ge.t("History"),suffix:ie.createElement(Vt,null,ie.createElement(dl,{id:"widget-history-clear-btn",disabled:k,variant:"ghost",size:"xsmall",onClick:()=>g(!0)},ie.createElement(Ei,{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:f,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(ff,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:Cf,isLoading:p}))),ie.createElement(ee,{open:m,onClose:C,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(Ei,{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(Ei,{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:C},ie.createElement(Ei,{variant:"title",size:"medium",color:"primary"},Ge.t("No, Cancel")))))}i(Tf,"HistoryPage");import{i18n as Dw}from"@lingui/core";import{Button as _w,Divider as Uf,styled as $w,WarningIcon as Fw}from"@rango-dev/ui";import Ow from"bignumber.js";import Je,{useEffect as zf,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 Se 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"}),bf=gl("div",{width:"146px"});import{i18n as zn}from"@lingui/core";import{Select as yw}from"@rango-dev/ui";import xf from"react";function Ai(t){let{updateQuotePartialState:e,sortStrategy:o}=z(),n=[{value:"SMART",label:zn.t("Smart Routing")},{value:"FEE",label:zn.t("Lowest Fee")},{value:"SPEED",label:zn.t("Fastest Transfer")},{value:"NET_OUTPUT",label:zn.t("Maximum Return")},{value:"PRICE",label:zn.t("Maximum Output")}];return xf.createElement(bf,null,xf.createElement(yw,{container:t.container,options:n,value:o,handleItemClick:r=>{e("sortStrategy",r.value)},variant:"filled"}))}i(Ai,"SelectStrategy");var Ef=3;function Qn(t){let{loading:e,onClickOnQuote:o,fetch:n,showModalFee:r,hasSort:a=!0,fullExpandedMode:s=!1,container:l}=t,{selectedQuote:p,quotes:u,updateQuotePartialState:c,fromToken:m,toToken:g,sortStrategy:f,error:d}=z(),{slippage:h,customSlippage:C}=y(),{findToken:S}=y(),k=l||N(),T=!!u&&u.results.length,v=C??h,w=i(b=>{if(!m||!g||!u)return null;let E={requestAmount:u.requestAmount,validationStatus:null,...b};return Oo(E,{fromToken:m,toToken:g,userSlippage:v,findToken:S})},"getQuoteWarning"),I=d?.type===0||d?.type===1,M=u?.results?Dr(f,u?.results):[];return Se.createElement(Se.Fragment,null,a&&Se.createElement(Se.Fragment,null,Se.createElement(wf,null,Se.createElement(kw,{size:"xmedium",variant:"title"},Sw.t("Sort by")),Se.createElement(Ai,{container:k})),Se.createElement(hl,{size:"10"})),e&&Array.from({length:Ef},(b,E)=>Se.createElement(Se.Fragment,{key:E},s?Se.createElement(Cw,{loading:!0}):Se.createElement(Ln,{tagHidden:!1,type:"list-item",expanded:!1}),E!==Ef-1&&Se.createElement(hl,{size:16}))),!e&&Se.createElement(Se.Fragment,null,T?M.map((b,E)=>{let x=w(b),W=zs(b.swaps),D=M.length-1===E;return Se.createElement(Se.Fragment,{key:b.requestId},Se.createElement(vo,{showModalFee:r,container:k,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:A=>{W||c("warning",x),c("error",W?.options||null),o(A)},type:"list-item"}),!D&&Se.createElement(hl,{size:16}))}):I&&Se.createElement(vf,null,Se.createElement(wn,{size:s?"large":"small",error:d,fetch:n}))))}i(Qn,"Quotes");import{darkTheme as Tw,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",[`.${Tw} &`]:{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 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=sn();return bw(()=>{let g=null;return a?g=setTimeout(()=>{l(!0)},Ew):(l(!1),g&&clearTimeout(g)),()=>{g&&clearTimeout(g)}},[a]),Rt.createElement(Af,{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(Ai,{container:m}),Rt.createElement(yo,{container:m,onClickRefresh:r,hidden:["history","notifications","settings"]}))}),Rt.createElement(Nf,null,Rt.createElement(Qn,{showModalFee:!1,fetch:e,hasSort:!1,loading:o,container:sn(),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 Nw}from"@rango-dev/ui";import Cl from"react";import{keyframes as Iw,styled as Wf}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)"}}),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:`${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(Mf,null,Cl.createElement(Lf,{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 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:g,outputUsdValue:f,selectedQuote:d}=z(),{connectedWallets:h,getBalanceFor:C}=R(),S=a?C(a):null,k=dr(S)?.amount??"0",T=s&&a?L(S?.amount,S?.decimals):"0",v=!!s&&$p(h,s.name),w=!Ma(d,c,m),I=!Ma(d,c,f),M=!m||!f||!f.gt(0)?null:ct(m.toString(),f.toString());return qn.createElement(Pf,null,qn.createElement(Df,null,qn.createElement($f,{label:_f.t("From"),mode:"From",onInputChange:u,balance:k,chain:{displayName:s?.displayName||"",image:s?.logo||""},token:{displayName:a?.symbol||"",image:a?.image||""},onClickToken:()=>n("from"),price:{value:c,usdValue: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,f),2,2),warningLevel:Pt(M??0),price:{value:L(g,6,6),usdValue:I?void 0:L(f,4,4),realValue:g?.toString(),realUsdValue:I?void 0:f?.toString(),error:I?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 Ff(){let{fetch:t,loading:e,cancelFetch:o}=yi({request:async(n,r)=>await Et().getAllRoutes(n,r)});return{fetch:t,loading:e,cancelFetch:o}}i(Ff,"useFetchAllQuotes");var Pw=600;function Ni({refetchQuote:t}){let{fetch:e,cancelFetch:o}=Ff(),{excludeLiquiditySources:n,routing:r}=y().config,a=R.use.connectedWallets(),{fromToken:s,toToken:l,inputAmount:p,inputUsdValue:u,selectedQuote:c,sortStrategy:m,resetQuote:g,error:f,warning:d,setSelectedQuote:h,updateQuotePartialState:C}=z(),{slippage:S,customSlippage:k,affiliatePercent:T,affiliateRef:v,affiliateWallets:w,fetchStatus:I}=y(),M=y().getLiquiditySources(),b=y().getDisabledLiquiditySources(),E=y().excludeLiquiditySources(),{findToken:x}=y(),[W,D]=Bw(!0),A=Lw(p),Z=k??S,J=!s||!l||ao(s,l)||!pn(p),B=i(V=>{D(V)},"resetState"),K=i(V=>{let{fromToken:fe,toToken:ge,inputAmount:Pe,liquiditySources:U,excludeLiquiditySources:Ke,disabledLiquiditySources:vt,slippage:lt,affiliateRef:wt,affiliatePercent:$,affiliateWallets:Q}=V;if(W||B(!0),!J&&fe&&ge){g();let H=Qc({fromToken:fe,toToken:ge,inputAmount:Pe,liquiditySources:U,excludeLiquiditySources:Ke,disabledLiquiditySources:vt,wallets:a,slippage:lt,affiliateRef:wt,affiliatePercent:$,affiliateWallets:Q});Mo("experimental",r)&&(H.experimental=!0),Mo("avoidNativeFee",r)&&(H.avoidNativeFee=!0),Mo("enableCentralizedSwappers",r)&&(H.enableCentralizedSwappers=!0),r?.maxLength&&(H.maxLength=r.maxLength),e(H).then(ne=>{let le=Dr(m,ne.results),pe=ou(c,le,ne.requestAmount);D(!1),C("quotes",ne),h(pe),Si({diagnosisMessages:ne.diagnosisMessages,requestId:pe?.requestId||"",swaps:pe?.swaps});let Oe=go(pe)||ge?.usdPrice,er=yn(pe)||fe?.usdPrice,ro=pe&&Oo(pe,{fromToken:{...fe,usdPrice:er},toToken:{...ge,usdPrice:Oe},userSlippage:Z,findToken:x});C("warning",ro)}).catch(ne=>{let{error:le}=Ci(ne);(le?.type===0||le?.type===1)&&g(),le?.type!==2&&(C("error",le),D(!1))})}},"fetch"),me=Ww(wp(V=>{K(V)},Pw),[J]);return Mw(()=>{if(!t){D(!1);return}if(I!=="success")return;if(J){D(!1),(c||f||d)&&g();return}if(!pn(p)||u?.eq(0)){B(!1),o();return}g(),B(!0);let V=K;return A.current&&A.current!=p&&(V=me),A.current=p,V({inputAmount:p,fromToken:s,toToken:l,liquiditySources:M,excludeLiquiditySources:E,disabledLiquiditySources:b,slippage:Z,affiliateRef:v,affiliatePercent:T,affiliateWallets:w}),o},[I,p,s?.symbol,s?.address,s?.blockchain,l?.symbol,l?.address,l?.blockchain,J,M?.length,n,b.length,Z,v,T,JSON.stringify(w)]),{fetch:()=>K({inputAmount:p,fromToken:s,toToken:l,liquiditySources:M,excludeLiquiditySources:E,disabledLiquiditySources:b,slippage:Z,affiliateRef:v,affiliatePercent:T,affiliateWallets:w}),loading:W}}i(Ni,"useSwapInput");function Of(t,e){let o=!1,n={preventDefault(){o=!0},...t.payload===void 0&&{payload:t.payload}};he.emit("uiEvent",{type:t.type,payload:n}),o||e()}i(Of,"emitPreventableEvent");var zw=$w("div",{display:"flex",alignItems:"flex-start",maxHeight:700,"& .footer__alert":{paddingTop:"0 !important"}}),Qw=300;function qf(){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:g}=z(),[f,d]=Qf(!1),{isLargeScreen:h,isExtraLargeScreen:C}=pi(),{fetch:S,loading:k}=Ni({refetchQuote:a}),{config:T,fetchStatus:v}=y(),{connectedWallets:w}=R(),{isActiveTab:I}=se(),[M,b]=Qf(!1),x=_c({fetchMetaStatus:v,fetchingQuote:k,inputAmount:n,quote:r,anyWalletConnected:w.length>0,error:s,warning:l,needsToWarnEthOnPath:!1}),W=Hp(h,C,T?.variant),D=!!n&&!!e&&!!o&&new Ow(n).gt(0)&&!Zc(e,o),A=D&&v==="success"&&k,J=(!W||W&&p?.results.length)&&(l||s);zf(()=>{c(),g("refetchQuote",!0)},[]),zf(()=>{d(D)},[D]);let B=(r||s)&&!M?S:void 0,K=i(V=>{W&&f?(d(!1),setTimeout(()=>{t(V)},Qw)):t(V)},"onHandleNavigation"),me=i(V=>{r?.requestId!==V.requestId&&(b(!1),u(V))},"onClickOnQuote");return Je.createElement(zw,null,Je.createElement(oe,{height:"auto",footer:Je.createElement(_w,{id:`widget-swap-${x.action}-btn`,type:"primary",size:"large",disabled:x.disabled||!I,prefix:x.action==="confirm-warning"&&Je.createElement(Fw,null),fullWidth:!0,onClick:()=>{x.action==="connect-wallet"?Of({type:"clickConnectWallet"},()=>K(_.wallets)):x.action==="confirm-warning"?b(!0):K(_.confirmSwap)}},x.title),header:{onWallet:()=>{K(_.wallets)},hasBackButton:!1,title:T.title||Dw.t("Swap"),suffix:Je.createElement(yo,{hidden:W?["refresh"]:void 0,onClickRefresh:B,onClickHistory:()=>K(_.swaps),onClickSettings:()=>{K(_.settings)}})}},Je.createElement(re,null,Je.createElement(Tl,{fetchingQuote:A,fetchMetaStatus:v,isExpandable:W,onClickToken:V=>{K(V==="from"?_.fromSwap:_.toSwap)}}),Je.createElement(Uf,{size:"2"}),W?null:Je.createElement(vo,{quote:r,loading:A,error:s,tagHidden:!1,warning:l,type:"basic",onClickAllRoutes:p&&p.results.length>1?()=>{g("refetchQuote",!1),K(_.routes)}:void 0}),J?Je.createElement(Je.Fragment,null,Je.createElement(Uf,{size:"10"}),Je.createElement(xn,{warning:l,error:s,couldChangeSettings:!0,refetchQuote:S,showWarningModal:M,confirmationDisabled:!I,onOpenWarningModal:()=>b(!0),onCloseWarningModal:()=>b(!1),onConfirmWarningModal:()=>{b(!1),m(!0),K(_.confirmSwap)},onChangeSettings:()=>K(_.settings)})):null)),W?Je.createElement(yl,{loading:A,onClickOnQuote:me,fetch:S,onClickRefresh:B,isVisible:f}):null)}i(qf,"Home");import{i18n as Hf}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=Xp,r=o?.language||Lo;return{activeLanguage:e||r,languages:n,defaultLanguage:r,changeLanguage:a=>t(a||Lo),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(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(oe,{header:{title:Hf.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:Hf.t("language"),id:"_",onClick:()=>console.log()}),items:r}))))}i(Gf,"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 Kf}from"@rango-dev/ui";import Gn from"react";import{styled as vl}from"@rango-dev/ui";var Hn=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 Vf=Zw(Yw,{height:61});var Rw=30;function xl(){return Gn.createElement(Hn,null,Array.from(Array(Rw),(t,e)=>Gn.createElement(Vf,{hasDivider:!0,key:e,start:Gn.createElement(Kf,{variant:"circular",width:35,height:35}),title:Gn.createElement(Kf,{variant:"text",size:"large",width:90}),end:Gn.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=yr(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)),g=m.length===m.filter(S=>S.selected).length,f=i(()=>{m.forEach(S=>{g?s(S.groupTitle):S.selected||s(S.groupTitle)})},"toggleAllSources"),d=m.map(S=>{let{selected:k,groupTitle:T,logo:v,id:w,...I}=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:k,disabled:l}),title:Ve.createElement(ib,{variant:"title",size:"xmedium"},Ut.t(T)),selected:k,groupTitle:T,logo:v,...I}}),h=i(S=>{let k=S.target.value;a(k)},"handleSearch"),C=d;return r&&(C=d.filter(S=>bt(S.groupTitle,r))),Ve.createElement(oe,{header:{title:Ut.t(t),suffix:Ve.createElement(wl,null,Ve.createElement(eb,{id:`widget-liquidity-source-${g?"deselect-all":"select-all"}-btn`,variant:"ghost",size:"xsmall",onClick:f},g?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),!C.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(Hn,{disabled:l},C.map(S=>{let{groupTitle:k,...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 Wi from"react";import{useNavigate as lb}from"react-router-dom";function jf(){let t=lb(),e=Ye(),{selectedQuote:o,refetchQuote:n,setSelectedQuote:r,updateQuotePartialState:a,error:s}=z(),{fetch:l,loading:p}=Ni({refetchQuote:n}),u=i(g=>{r(g),a("refetchQuote",!1),e()},"onClickOnQuote"),c=`../${_.settings}`,m=`../${_.wallets}`;return Wi.createElement(oe,{header:{onWallet:()=>{t(m),a("refetchQuote",!0)},onBack:()=>{a("refetchQuote",!1)},title:sb.t("Routes"),suffix:Wi.createElement(yo,{onClickRefresh:o||s?l:void 0,hidden:["notifications","history"],onClickSettings:()=>{t(c),a("refetchQuote",!0)}})}},Wi.createElement(re,null,Wi.createElement(Qn,{fetch:l,loading:p,onClickOnQuote:u})))}i(jf,"RoutesPage");import{i18n as tg}from"@lingui/core";import{Divider as og,getCategoriesCount as Sb,SelectableCategoryList as Cb}from"@rango-dev/ui";import zt,{useState as ng}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 eg}from"@rango-dev/ui";import it,{useEffect as hb,useState as yb}from"react";var Xf=i((t,e,o)=>t.filter(n=>ar(n.type,o)).filter(n=>et(n.name,e)||et(n.displayName,e)),"filterBlockchains");import{ImageContainer as pb,styled as Yf}from"@rango-dev/ui";var Zf=Yf("div",{display:"flex",flexDirection:"column",overflow:"hidden",height:"100%",justifyContent:"center"}),Mi=Yf(Cn,{padding:0,margin:0,listStyle:"none",[`& ${pb}`]:{borderRadius:"$xm",overflow:"hidden"}});import{ListItem as cb,Skeleton as Jf}from"@rango-dev/ui";import Li from"react";var ub=20;function Rf(){return Li.createElement(Mi,null,Array.from(Array(ub),t=>Li.createElement(cb,{key:t,hasDivider:!0,start:Li.createElement(Jf,{variant:"circular",width:35,height:35}),title:Li.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]=yb(e),{fetchStatus:p}=y();hb(()=>{l([...Xf(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(Mi,{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(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(mb,{size:4})),it.createElement(Zf,null,p==="loading"&&it.createElement(Rf,null),p==="success"&&u()))}i(Al,"BlockchainList");function Bi(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=kb(),m=y().blockchains({type:e}),g=Sb(m),f=!t.hideCategory&&g!==1;return zt.createElement(oe,{header:{title:tg.t("Select Chain")}},zt.createElement(re,{view:!0},f&&zt.createElement(zt.Fragment,null,zt.createElement(Cb,{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(Bi,"SelectBlockchainPage");import{i18n as Di}from"@lingui/core";import{Divider as pg}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 Pi,Divider as sg,Image as lg,Skeleton as xb,Tooltip as Eb,Typography as Ll}from"@rango-dev/ui";import Le from"react";import{useEffect as wb}from"react";var rg=["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=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(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 ig(t,e){return!!e.list.find(o=>o.name===t)}i(ig,"isInVisibleList");function Wl(t,e){let{preferredBlockchains:o,addPreferredBlockchain:n}=y();wb(()=>{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 bb}from"@rango-dev/ui";var ag=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,g=!m&&c;return Le.createElement(Le.Fragment,null,Le.createElement(sg,{size:12}),Le.createElement(Ll,{variant:"label",size:"large"},Ml.t("Select Chain")),Le.createElement(sg,{size:12}),Le.createElement(ag,null,l==="loading"&&Array.from(Array(Ib),f=>Le.createElement(xb,{key:f,variant:"rounded",height:50})),l==="success"&&Le.createElement(Le.Fragment,null,Le.createElement(Pi,{selected:!n,onClick:()=>{o==="from"?u():p()}},Le.createElement(Ll,{variant:"body",size:"xsmall",color:"secondary500"},Ml.t("All"))),s.list.map(f=>Le.createElement(Eb,{key:f.name,content:f.shortName,side:"bottom",sideOffset:2,container:N()},Le.createElement(Pi,{key:f.name,selected:!!n&&n.name===f.name,onClick:()=>r(f)},Le.createElement(lg,{src:f.logo,size:30})))),m?Le.createElement(Pi,{key:s.more[0].name,selected:!!n&&n.name===s.more[0].name,onClick:()=>r(s.more[0])},Le.createElement(lg,{src:s.more[0].logo,size:30})):null,g?Le.createElement(Pi,{onClick:a,key:"more-blockchains"},Le.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=R.use.getBalanceFor(),[m,g]=Ab(""),d=(e==="source"?r:a)?.name??"",h=y().blockchains({type:e}),C=y().tokens({type:e,blockchain:d,searchFor:m,getBalanceFor:c}),S=i(v=>{e==="source"?p(v):u(v)},"updateBlockchain"),k=i(v=>{e==="source"?s({token:v,meta:{blockchains:h,tokens:C}}):l({token:v,meta:{blockchains:h,tokens:C}})},"updateToken"),T={source:Di.t("Source"),destination:Di.t("Destination")};return xo.createElement(oe,{header:{title:Di.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(_.blockchains),onChange:v=>{S(v)}}),xo.createElement(pg,{size:24}),xo.createElement(Ct,{value:m,autoFocus:!0,placeholder:Di.t("Search Token"),color:"light",variant:"contained",size:"large",setValue:()=>g(""),onChange:v=>g(v.target.value)}),xo.createElement(pg,{size:16}),xo.createElement(_n,{list:C,selectedBlockchain:d,searchedFor:m,type:e,onChange:v=>{k(v);let w=h.find(I=>v.blockchain===I.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 gg}from"@lingui/core";import{Divider as hg,InfoIcon as Bb,SlippageIcon as Pb,TextField as Db,Tooltip as _b,Typography as yg}from"@rango-dev/ui";import at from"react";import{Chip as Wb,styled as Vn,TextField as Mb}from"@rango-dev/ui";var cg=Vn("div",{paddingTop:"$5",padding:"$10 $5"}),ug=Vn("div",{display:"flex",flexWrap:"wrap",gap:"$10",[`& ${Mb}`]:{flex:"1 1 0",maxWidth:"127px",minWidth:"85px"}}),mg=Vn("div",{display:"flex",justifyContent:"start",alignItems:"center",paddingBottom:"$10"}),_i=Vn("div",{maxWidth:"280px",padding:"$10"}),dg=Vn(Wb,{width:"61px",flexShrink:0});import{i18n as Dl}from"@lingui/core";import{Typography as Lb}from"@rango-dev/ui";import Kn from"react";function fg(){return Kn.createElement(_i,null,Kn.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."),Kn.createElement("br",null),Kn.createElement("br",null),Kn.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(Pb,{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(_b,{container:N(),side:"top",sideOffset:4,content:at.createElement(fg,null)},at.createElement(Bb,{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(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>=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 $b,ChevronRightIcon as $i,DarkModeIcon as Cg,Divider as jn,ExchangeIcon as Fb,InfinityIcon as Ob,InfoIcon as Ub,LanguageIcon as zb,LightModeIcon as kg,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(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"))}],ex=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=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(),g=je("theme",c),f=je("liquiditySource",c),d=je("language",c),h=je("customTokens",c),C=y().infiniteApprove,S=y().toggleInfiniteApprove,k=yr(p,u),T=k.filter(B=>["BRIDGE","AGGREGATOR","OFF_CHAIN"].includes(B.type)),v=T.length,w=T.filter(B=>B.selected).length,I=k.filter(B=>B.type==="DEX"),M=I.length,b=I.filter(B=>B.selected).length,E=i((B,K)=>{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} / ${K}`)}},"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(jn,{direction:"horizontal",size:8}),P.createElement($i,{color:"black"})),onClick:()=>t(_.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(jn,{direction:"horizontal",size:8}),P.createElement($i,{color:"black"})),start:P.createElement(Fb,{color:"gray",size:16}),onClick:()=>t(_.exchanges)},D={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(jn,{direction:"horizontal",size:8}),P.createElement($i,{color:"black"})),start:P.createElement(Xb,{color:"gray",size:16}),onClick:()=>t(_.customTokens)},A={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(jn,{direction:"horizontal",size:8}),P.createElement($i,{color:"black"})),onClick:()=>t(_.languages)},Z={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(jn,{direction:"horizontal",size:4}),P.createElement(Yb,{side:"top",sideOffset:4,container:N(),content:P.createElement(_i,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:C}),onClick:S},ae={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)},J=f?[]:[x,W];return h||J.push(D),d||J.push(A),J.push(Z),!e?.singleTheme&&!g&&J.push(ae),P.createElement(Qb,{type:P.createElement(Hb,{hasDivider:!0,id:"_",onClick:()=>console.log()}),items:J})}i(Tg,"SettingsLists");var ax=nx("div",{paddingLeft:"$8"});function vg(){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(oe,{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(Tg,null)))}i(vg,"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 Rg,CopyIcon as Mx,Divider as Lx,DoneIcon as Bx,IconButton as Px,QuoteCost as Dx,RangoExplorerIcon as _x,StepDetails as $x,Tooltip as eh,Typography as Io,useCopyToClipboard as Fx}from"@rango-dev/ui";import{useWallets as Ox}from"@rango-dev/wallets-react";import th from"bignumber.js";import{PendingSwapNetworkStatus as Vi}from"rango-types";import j,{useEffect as oh,useRef as Ux,useState as nh}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 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"):`${sx[e.getDay()]} ${o} ${n} ${r}`}, ${new Date(t).toLocaleTimeString()}`}i(wg,"timeSince");function bg(t){return t.finishTime?wg(parseInt(t.finishTime)):wg(parseInt(t.creationTime))}i(bg,"getSwapDate");import{PendingSwapNetworkStatus as Ui}from"rango-types";import zi from"react";import{i18n as Fi}from"@lingui/core";import{Button as xg,Divider as Fl,MessageBox as lx}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(lx,{type:"error",title:Fi.t("Cancel Swap"),description:Fi.t("Are you sure you want to cancel this swap?")}),oo.createElement(Fl,{size:32}),oo.createElement(xg,{variant:"contained",id:"widget-swap-details-modal-cancel-swap-yes-btn",type:"primary",size:"large",onClick:t},Fi.t("Yes, Cancel it")),oo.createElement(Fl,{size:12}),oo.createElement(xg,{id:"widget-swap-details-modal-cancel-swap-no-btn",variant:"outlined",type:"primary",size:"large",onClick:e},Fi.t("No, Continue"))),"CancelContent");import{i18n as Oi}from"@lingui/core";import{Button as Ig,Divider as Ol,MessageBox as px,Typography as cx}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(px,{type:"error",title:Oi.t("Delete Transaction"),description:Oi.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},Oi.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(cx,{variant:"title",size:"medium",color:"primary"},Oi.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 en,{useState as gx}from"react";import{styled as Ng}from"@rango-dev/ui";var Wg=Ng("div",{display:"flex",justifyContent:"center"}),o5=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]=gx(),{getWalletInfo:u,state:c}=fx(),m=n?.walletType,g=m?cn(c(m)):null,f=m?u(m):null,d=a&&!!m&&!!g&&!!f,{list:h}=ft(),C=i(()=>{if(m){let S=h.find(k=>k.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 en.createElement(en.Fragment,null,en.createElement(mx,{type:e,title:o,description:r}),d&&en.createElement(Wg,null,en.createElement(dx,{container:N(),title:f.name,image:f.img,type:m,state:g,link:f.installLink,disabled:s,onClick:C})),en.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===Ui.WaitingForNetworkChange||e===Ui.WaitingForConnectingWallet||e===Ui.NetworkChanged;return zi.createElement(ee,{open:!!e,onClose:o,container:document.getElementById(_e.SWAP_BOX_ID)||document.body},p&&zi.createElement(Mg,{type:Ql[e].type,title:Ql[e].title,currentStepWallet:a,message:s,walletButtonDisabled:l,showWalletButton:e!==Ui.WaitingForNetworkChange}),e==="delete"&&zi.createElement(Ag,{onClose:o,onDelete:n}),e==="cancel"&&zi.createElement(Eg,{onClose:o,onCancel:r}))}i(ql,"SwapDetailsModal");import{i18n as Xn}from"@lingui/core";import{Button as Hl,Divider as Qi,MessageBox as Lg,TokenAmount as hx,Typography as Gl}from"@rango-dev/ui";import Fe 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:g}=t,f=yx();return Fe.createElement(ee,{open:e,onClose:o,container:document.getElementById(_e.SWAP_BOX_ID)||document.body},n==="success"?Fe.createElement(Lg,{type:"success",title:Xn.t("Swap Successful")},Fe.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}),Fe.createElement(Qi,{size:12}),Fe.createElement(Gl,{variant:"body",size:"medium",color:"neutral700",align:"center"},m)):Fe.createElement(Lg,{type:"error",title:Xn.t("Transaction Failed"),description:m}),Fe.createElement(Qi,{size:32}),n==="success"&&Fe.createElement(Hl,{id:"widget-swap-details-modal-done-btn",variant:"contained",type:"primary",size:"large",onClick:()=>{f("../../")}},Fe.createElement(Gl,{variant:"title",size:"medium",color:"neutral100"},Xn.t("Done"))),Fe.createElement(Qi,{size:12}),g&&Fe.createElement(Fe.Fragment,null,Fe.createElement(Hl,{variant:"contained",id:"widget-swap-detail-modal-diagnosis-btn",type:"primary",size:"large",onClick:()=>window.open(g,"_blank")},Xn.t("Diagnosis")),Fe.createElement(Qi,{size:12})),Fe.createElement(Hl,{id:"widget-swap-details-modal-see-details-btn",variant:"outlined",type:"primary",size:"large",onClick:o},Fe.createElement(Gl,{variant:"title",size:"medium",color:"primary"},Xn.t("See Details"))))}i(Vl,"SwapDetailsCompleteModal");import Ix from"react";import{i18n as wx}from"@lingui/core";import{Alert as Xg,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 on,{useState as vx}from"react";import{css as Yn,darkTheme as Bg,styled as qt,Typography as Sx}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(Cn,{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}),tn=Yn({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=Yn({padding:"$5 0"}),Hi=Yn({display:"flex",justifyContent:"center",alignItems:"center",height:"$24"}),Fg=Yn({display:"flex",width:"100%",padding:"$15 $20 $20",flexDirection:"column",alignItems:"start"}),Og=Yn({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"}),Gi=qt(Sx,{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]=vx(!1);return on.createElement(Cx,{type:"error",title:e.shortMessage,containerStyles:{"& .footer":{paddingTop:"$0"}},action:e.detailedMessage.content&&on.createElement(Tx,{onClick:()=>n(r=>!r),variant:"ghost",size:"xsmall"},on.createElement(qg,{rotated:o},on.createElement(kx,{size:12,color:"gray"}))),footer:on.createElement(Hg,{open:o},on.createElement(Gi,{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 Zn from"react";function jg(t){let{switchNetwork:e,setNetworkModal:o,message:n,showNetworkModal:r}=t;return e?Zn.createElement(jl,{type:"warning",title:n.shortMessage,action:Zn.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?Zn.createElement(jl,{type:"warning",title:n.shortMessage,action:Zn.createElement(Kg,{id:"widget-swap-details-warning-alert-connect-wallet-btn",size:"xxsmall",type:"warning",onClick:()=>{o(Xl.WaitingForConnectingWallet)}},Vg.t("Connect"))}):Zn.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=hn(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,g,f)=>{let d=g+m.url,h=g===f.length-1,C=(h&&u||p)&&!c,S=h&&a.status==="failed";return no.createElement(Ex,{key:d},no.createElement(Xg,{type:h&&(C&&"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(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:nn(a.swapperId,o)??"",image:a.swapperLogo??"",type:a.swapperType},internalSwaps:a.internalSwaps?a.internalSwaps.map(p=>({from:{chain:{displayName:pt(p.fromBlockchain,e)??"",image:p.fromBlockchainLogo??""}},to:{chain:{displayName:pt(p.toBlockchain,e)??"",image:p.toBlockchainLogo??""}},swapper:{displayName:nn(p.swapperId,o)??"",image:p.swapperLogo??"",type:p.swapperType}})):[],alerts:Ix.createElement(Yl,{step:a,hasAlreadyProceededToSign:r,...n})}})},"getSteps");function Jg(t){if(hn(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}=Ox(),p=y().blockchains(),u=y().swappers(),{findToken:c}=y(),m=z.use.retry(),g=se.use.isActiveTab(),f=zx(),[d,h]=Fx(Yg),C=Ux(null),[S,k]=nh(null),[T,v]=nh(null),w=i(()=>{r(),k(null)},"onCancel"),I=ve.use.getNotifications(),M=ve.use.removeNotification(),b=I(),E=Nx(e),x=E?.networkStatus;oh(()=>{b.find(Oe=>Oe.requestId===e.requestId)&&(e.status==="success"||e.status==="failed"?(v(e.status),M(e.requestId)):T&&v(null))},[e.status,e.requestId]),oh(()=>{B?k(Vi.WaitingForNetworkChange):x===Vi.WaitingForConnectingWallet||x===Vi.NetworkChanged?k(x):k(null)},[x]);let W=jc(e),D=E?Ax(e,E):null,A=E?Wx(e,E):null,Z=bg(e),ae=Xc(e),J=i(pe=>!!l(pe)?.mobileWallet,"isMobileWallet"),B=x===Vi.WaitingForNetworkChange&&!!D&&!!A?.walletType&&(J(A.walletType)||a(A.walletType,D)),K=B?s.bind(null,A.walletType,D):void 0,me=Kc(e,E),V=Zg({swap:e,switchNetwork:K,showNetworkModal:x,setNetworkModal:k,message:me,blockchains:p,swappers:u}),fe=V.length,[ge,Pe]=[e.steps[0],e.steps[fe-1]],U=Pe.outputAmount||Pe.expectedOutputAmountHumanReadable,Ke=e.steps.reduce((pe,Oe)=>pe+parseFloat(Oe.feeInUsd||""),0),vt=e.steps.find(pe=>pe.diagnosisUrl)?.diagnosisUrl,lt=L(parseFloat(U||"0")*(Pe.toUsdPrice||0),4,4),wt=L(parseFloat(e.inputAmount)*(ge.fromUsdPrice||0),4,4),$=U?new th(U).multipliedBy(Pe.toUsdPrice||0).toString():"",Q=new th(e.inputAmount).multipliedBy(ge.fromUsdPrice||0).toString(),H=ct(wt,lt),ne=me.detailedMessage.content||me.shortMessage,le=e.status==="success"?st.t({id:"You have received {amount} {token} in {conciseAddress} wallet on {chain} chain.",values:{amount:L(U,6,6),token:V[fe-1].to.token.displayName,conciseAddress:fr(e.wallets[V[fe-1].to.chain.displayName]?.address||""),chain:V[fe-1].to.chain.displayName}}):j.createElement(zg,null,j.createElement(Io,{variant:"body",size:"medium",color:"neutral700",align:"center"},ne?"":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}})}`:""),ne&&j.createElement(Gi,{align:"center",variant:"body",size:"medium",color:"neutral700"},j.createElement("b",null,"Reason:")," ",ne));return j.createElement(oe,{header:{title:st.t("Swap Details"),onCancel:e.status==="running"?()=>k("cancel"):void 0,suffix:e.status!=="running"&&j.createElement(Vt,null,j.createElement(Rg,{id:"widget-swap-details-delete-btn",variant:"ghost",type:"error",size:"xsmall",onClick:()=>k("delete")},j.createElement(Io,{size:"medium",variant:"label",color:"error"},st.t("Delete"))))},footer:ae&&!T&&j.createElement(Rg,{fullWidth:!0,id:"widget-swap-details-try-again-btn",variant:"contained",type:"primary",size:"large",onClick:()=>{let pe=Pr(e,p,c);m(pe),setTimeout(()=>{f("../../")},0)}},st.t("Try again"))},j.createElement(re,{compact:!0,view:!0},j.createElement(qi,null,j.createElement("div",{className:tn()},j.createElement(Io,{variant:"label",size:"large",color:"neutral700"},`${st.t("Request ID")}`),j.createElement("div",{className:Hi()},j.createElement(Io,{variant:"label",size:"small",color:"neutral700"},o),j.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"},j.createElement(Px,{id:"widget-swap-details-done-copy-icon-btn",variant:"ghost",onClick:h.bind(null,o||"")},d?j.createElement(Bx,{size:16,color:"secondary"}):j.createElement(Mx,{size:16,color:"gray"}))),j.createElement(Ug,{target:"_blank",href:`${gp}/swap/${o}`},j.createElement(eh,{container:N(),content:st.t("View on Rango Explorer"),side:"bottom"},j.createElement(_x,{size:20}))))),j.createElement("div",{className:tn()},j.createElement(Io,{variant:"label",size:"large",color:"neutral700"},e.finishTime?st.t("Finished at"):st.t("Created at")),j.createElement(Io,{variant:"label",size:"small",color:"neutral700"},Z))),j.createElement("div",{className:Fg()},j.createElement(Dx,{fee:L(String(Ke),2,2),time:ln(sr(e.steps)),steps:fe}),j.createElement(In,{from:{price:{value:L(e.inputAmount,6,6),usdValue:wt,realUsdValue:Q,realValue:e.inputAmount},token:{displayName:V[0].from.token.displayName,image:V[0].from.token.image},chain:{image:V[0].from.chain.image,displayName:V[0].from.chain.displayName}},to:{price:{value:L(U,6,6),usdValue:lt,realUsdValue:$,realValue:U||""},token:{displayName:V[fe-1].to.token.displayName,image:V[fe-1].to.token.image},chain:{image:V[fe-1].to.chain.image,displayName:V[fe-1].to.chain.displayName}},percentageChange:L(H,2,2),warningLevel:Pt(H??0)})),j.createElement("div",{className:Og()},j.createElement(Io,{variant:"title",size:"small"},st.t("Swaps steps"))),j.createElement(Lx,{size:8}),j.createElement(Dg,{ref:C},V.map((pe,Oe)=>{let er=Oe,ro=Jg(e.steps[Oe]),Mh=ro==="error"||ro==="in-progress"||ro==="warning"||ro==="completed"&&Oe===V.length-1;return j.createElement($x,{key:er,step:pe,type:"swap-progress",ref:C,state:ro,hasSeparator:Oe!==0,tabIndex:er,isFocused:Mh,tooltipContainer:N()})}))),j.createElement(ql,{state:S,onClose:()=>k(null),onCancel:w,onDelete:n,message:me.detailedMessage.content,currentStepWallet:A,walletButtonDisabled:!g}),j.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(H,2,2),token:{displayName:V[fe-1].to.token.displayName,image:V[fe-1].to.token.image},chain:{image:V[fe-1].to.chain.image},description:le}))}i(Zl,"SwapDetails");import{i18n as ji}from"@lingui/core";import{Divider as ah,NotFound as Vx,Skeleton as Rn,Typography as Xi}from"@rango-dev/ui";import Ce from"react";import{i18n as Qx}from"@lingui/core";import{Divider as qx,Skeleton as Hx,Typography as Gx}from"@rango-dev/ui";import ke from"react";import{css as Tt,styled as Jl}from"@rango-dev/ui";var rh=Jl("div",{width:"100%",height:"100%",padding:"$10 $20"}),Jn=Jl("div",{backgroundColor:"$neutral100",borderRadius:"$xm",padding:"$10 $15"}),Ki=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"}),ih=Tt({display:"flex",paddingTop:"$10",paddingBottom:"$5"});function Rl(){return ke.createElement(rh,null,ke.createElement(Wn,{type:"swap-preview"}),ke.createElement("div",{className:"swaps-steps"},ke.createElement(Gx,{variant:"title",size:"small"},Qx.t("Swaps steps"))),ke.createElement(ke.Fragment,null,ke.createElement(Jn,null,ke.createElement(Wt,{separator:!1}),ke.createElement("div",{className:ih()},ke.createElement(qx,{direction:"horizontal",size:20}),ke.createElement(Hx,{height:22,variant:"rectangular"}))),ke.createElement(Ki,null),ke.createElement(Jn,null,ke.createElement(Wt,{separator:!1})),ke.createElement(Ki,null),ke.createElement(Jn,null,ke.createElement(Wt,{separator:!1})),ke.createElement(Ki,null),ke.createElement(Jn,null,ke.createElement(Wt,{separator:!1}))))}i(Rl,"LoadingSwapDetails");function sh(t){let{requestId:e,showSkeleton:o}=t;return Ce.createElement(oe,{header:{title:ji.t("Swap Details"),suffix:Ce.createElement(Vt,null)}},o&&Ce.createElement(Pg,null,Ce.createElement(qi,null,Ce.createElement("div",{className:tn()},Ce.createElement(Xi,{variant:"label",size:"large",color:"neutral700"},`${ji.t("Request ID")}`),Ce.createElement("div",{className:Hi()},Ce.createElement(Xi,{variant:"label",size:"small",color:"neutral700"},Ce.createElement(Rn,{width:60,height:10,variant:"rounded"})),Ce.createElement(ah,{direction:"horizontal",size:4}),Ce.createElement(Rn,{width:16,height:16,variant:"rectangular"}),Ce.createElement(ah,{direction:"horizontal",size:4}),Ce.createElement(Rn,{width:16,height:16,variant:"rectangular"}))),Ce.createElement("div",{className:tn()},Ce.createElement(Xi,{className:$g(),variant:"label",size:"large",color:"neutral700"},Ce.createElement(Rn,{width:60,height:10,variant:"rounded"})),Ce.createElement(Xi,{variant:"label",size:"small",color:"neutral700"},Ce.createElement(Rn,{width:60,height:10,variant:"rounded"})))),Ce.createElement(Rl,null)),!o&&Ce.createElement(_g,null,Ce.createElement(Vx,{title:ji.t("Not found"),description:ji.t({id:"Swap with request ID = {requestId} not found.",values:{requestId:e}})})))}i(sh,"SwapDetailsPlaceholder");function lh(){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:g})=>g.requestId===r):void 0,u=i(()=>{if(p?.id){let g=t?.get(p.id);g&&jx(g)}},"onCancel"),c=i(async()=>{if(p?.id)try{t?.deleteQueue(p.id),a()}catch(g){console.log(g)}},"onDelete"),m=p?.swap;return!m||l?ep.createElement(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 Jx,getCategoriesCount as Rx,SelectableCategoryList as eE,styled as uh,Typography as tE,Wallet as oE}from"@rango-dev/ui";import Lt,{useState as ch}from"react";var nE=uh("div",{display:"flex",justifyContent:"center",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5"}),rE=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=Rx(u)!==1,g=Up(p,e),f=i(d=>{Ep(p,r.multiWallets)||s(d)},"handleWalletItemClick");return Lt.createElement(oe,{header:{title:ph.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"},ph.t("Choose a wallet to connect.")),Lt.createElement(nE,null,g.map((d,h)=>{let C=`wallet-${h}-${d.type}`;return Lt.createElement(oE,{key:C,...d,container:N(),onClick:()=>f(d),isLoading:t==="loading",disabled:!l})}),Lt.createElement(mo,{wallet:a,onClose:()=>{s(void 0)}}))))}i(mh,"WalletsPage");function dh(){return iu(),za(),iE([{path:_.home,element:Be.createElement(qf,null)},{path:_.routes,element:Be.createElement(jf,null)},{path:_.fromSwap,children:[{index:!0,element:Be.createElement(Pl,{type:"source"})},{path:_.blockchains,element:Be.createElement(Bi,{type:"source"})}]},{path:_.toSwap,children:[{index:!0,element:Be.createElement(Pl,{type:"destination"})},{path:_.blockchains,element:Be.createElement(Bi,{type:"destination"})}]},{path:_.settings,children:[{index:!0,element:Be.createElement(vg,null)},{path:_.languages,element:Be.createElement(Gf,null)},{path:_.exchanges,element:Be.createElement(El,{sourceType:"Exchanges"})},{path:_.bridges,element:Be.createElement(El,{sourceType:"Bridges"})},{path:_.customTokens,children:[{index:!0,element:Be.createElement(ef,null)},{path:_.addCustomTokens,children:[{index:!0,element:Be.createElement(Uu,null)},{path:_.blockchains,element:Be.createElement(Bi,{hideCategory:!0,type:"custom-token"})}]}]}]},{path:_.swaps,children:[{index:!0,element:Be.createElement(Tf,null)},{path:_.swapDetails,element:Be.createElement(lh,null)}]},{path:_.wallets,element:Be.createElement(mh,null)},{path:_.confirmSwap,element:Be.createElement(Fd,null)}])}i(dh,"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 kh,useState as Th}from"react";import{globalCss as aE}from"@rango-dev/ui";var fh=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 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 sE}from"@rango-dev/wallets-react";import{useEffect as lE,useRef as pE}from"react";function hh(){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(hh,"useForceAutoConnect");import{isApprovalTX as cE,RouteEventType as yh,StepEventType as Sh,StepExecutionEventStatus as uE,WidgetEvents as Yi}from"@rango-dev/queue-manager-rango-preset";import{useEffect as Ch}from"react";function tp(){let t=R.use.connectedWallets(),e=R.use.getWalletsDetails(),o=ve.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===uE.TX_SENT&&!cE(l)||s.type===Sh.SUCCEEDED){let c=t.find(g=>g.chain===l?.fromBlockchain),m=l?.fromBlockchain!==l?.toBlockchain&&t.find(g=>g.chain===l?.toBlockchain);c&&e([c],n),m&&e([m],n)}o(s,p)},"handleStepEvent");return he.on(Yi.StepEvent,r),()=>he.off(Yi.StepEvent,r)},[he,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 he.on(Yi.RouteEvent,r),()=>he.off(Yi.RouteEvent,r)},[he])}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}=ve(),{manager:o,state:n}=mE();dE(()=>{ve.persist.hasHydrated()&&n.loadedFromPersistor&&!t&&e(ut(o))},[ve.persist.hasHydrated(),n.loadedFromPersistor,t])}i(op,"useSyncNotifications");function np(){hh(),fh(),tp(),op();let t=y().blockchains(),{canSwitchNetworkTo:e}=Jr(),[o,n]=Th(""),[r,a]=Th(),s=yE(Ir),l=t.filter(hE),{fetchApiConfig:p}=gh();kh(()=>()=>ru(),[]),fE({lastConnectedWallet:o,clearDisconnectedWallet:()=>{a(void 0)},disconnectedWallet:r,evmChains:l,canSwitchNetworkTo:e}),kh(()=>(lo.init(),ve.persist.hasHydrated()||ve.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 vh=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 Zi(){np();let{config:t}=y(),{activeTheme:e}=qo(t?.theme||{}),{activeLanguage:o}=eo();return rp.createElement(CE,{language:o},rp.createElement(vh,{id:"swap-container",className:e()},rp.createElement(dh,null)))}i(Zi,"Main");import{setSolanaSignerConfig as OE}from"@rango-dev/signer-solana";import ap,{useEffect as Ah,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"),wh=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:he.emit}}),[t.apiKey]),p=y().blockchains(),c={blockchains:R.use.connectedWallets().map(T=>({accounts:[T],name:T.chain}))},m=i(async(T,v)=>{if(a(T,v))return r(T,v)},"switchNetwork"),g=i(T=>!!s(T).mobileWallet,"isMobileWallet"),f=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 cr(v)},"getSupportedChainNames"),C=e(),S={meta:{blockchains:f,evmBasedChains:d,evmNetworkChainInfo:EE(d),getSupportedChainNames:h},getSigners:o,wallets:c,providers:C,switchNetwork:m,canSwitchNetworkTo:a,connect:r,state:n,isMobileWallet:g},k=se.use.isActiveTab();return AE.createElement(bE,{queuesDefs:[l],context:S,onPersistedDataLoaded:T=>{vE(T)},isPaused:!k},t.children)}i(WE,"QueueManager");var bh=WE;import{useManager as DE}from"@rango-dev/queue-manager-react";import _E,{createContext as $E,useContext as FE}from"react";function xh(){let{findToken:t}=y(),e=y().blockchains(),o=y().tokens(),{setFromBlockchain:n,setFromToken:r,setToBlockchain:a,setToToken:s,setInputAmount:l}=z();return i(u=>{let{fromBlockchain:c,fromToken:m,toBlockchain:g,toToken:f,requestAmount:d}=u,h={blockchains:e,tokens:o};if(c!==void 0){let C=e.find(S=>S.name===c)??null;n(C)}if(m!==void 0){let C=m?t(m)??null:null;r({meta:h,token:C})}if(g!==void 0){let C=e.find(S=>S.name===g)??null;a(C)}if(f!==void 0){let C=f?t(f)??null:null;s({meta:h,token:C})}d!==void 0&&l(d)},"updateQuoteInputs")}i(xh,"useUpdateQuoteInputs");import{cancelSwap as ME,getCurrentBlockchainOfOrNull as LE,getCurrentStep as BE,getRelatedWalletOrNull as PE}from"@rango-dev/queue-manager-rango-preset";var Ji=class{static{i(this,"WidgetHistory")}constructor(e,o){this.manager=e,this.actions=o}getAllSwaps(){return 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=Pr(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 Eh=$E(void 0);function ip(t){let{manager:e}=DE(),o=se.use.isActiveTab(),n=z.use.retry(),{findToken:r}=y(),a=new Ji(e,{retrySwap:n,findToken:r}),s=R.use.connectedWallets(),l=R.use.loading(),p=Bp(s),u=R.use.getWalletsDetails(),c=y().blockchains(),m=y().tokens(),g=y().swappers(),f=y().fetchStatus,d=eo().resetLanguage,h=ve().getNotifications(),C=ve().clearNotifications,S=xh(),{fromBlockchain:k,toBlockchain:T,fromToken:v,toToken:w,inputAmount:I}=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:g,loadingStatus:f,findToken:r},resetLanguage:d,notifications:{list:h,clearAll:C},quote:{quoteInputs:{fromBlockchain:k?.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:I},updateQuoteInputs:S}};return _E.createElement(Eh.Provider,{value:M},t.children)}i(ip,"WidgetInfo");function Ih(){let t=FE(Eh);if(!t)throw new Error("useWidget can only be used within the WidgetProvider component");return t}i(Ih,"useWidget");function Ri(t){let{onUpdateState:e,config:o}=t,n=t.config?.theme?.fontFamily,{handleLoadCustomFont:r}=wh();return Ah(()=>{n&&r(n)},[n]),UE(()=>{zp({API_KEY:o?.apiKey||rr,BASE_URL:o?.apiUrl||fp})},[o.apiKey,o.apiUrl]),Ah(()=>{t.config?.signers?.customSolanaRPC&&OE("customRPC",t.config.signers.customSolanaRPC)},[t.config?.signers?.customSolanaRPC]),ap.createElement(Ar,{config:o,onUpdateState:e},ap.createElement(bh,{apiKey:o.apiKey},ap.createElement(ip,null,t.children)))}i(Ri,"WidgetProvider");function Nh(t){let e=t.config?.externalWallets;return ea.createElement(Wc,null,e?ea.createElement(Zi,null):ea.createElement(Ri,{config:t.config??ra},ea.createElement(Zi,null)))}i(Nh,"Widget");function Wh(){let{on:t,off:e}=he;return{on:t,off:e}}i(Wh,"useWidgetEvents");var yj={DerivationPath:dn,Namespaces:mn,isOnDerivationPath:gn,isOnNamespace:fn};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,Cr as WalletEventTypes,Z3 as WalletEvents,ej as WalletTypes,Nh as Widget,so as WidgetEvents,Ri as WidgetProvider,Ar as WidgetWallets,Ra as customizedThemeTokens,X3 as readAccountAddress,Ht as useStatefulConnect,ft as useWalletList,Jr as useWallets,Ih as useWidget,Wh as useWidgetEvents,Sr as widgetEventEmitter};
|
|
1
|
+
var $h=Object.defineProperty;var i=(t,e)=>$h(t,"name",{value:e,configurable:!0});import{EventSeverity as uj,RouteEventType as mj,StepEventType as dj,StepExecutionBlockedEventStatus as fj,StepExecutionEventStatus as gj}from"@rango-dev/queue-manager-rango-preset";import{legacyReadAccountAddress as yj}from"@rango-dev/wallets-core/legacy";import{useWallets as Rr,Events as Cj}from"@rango-dev/wallets-react";import{Networks as Tj,WalletTypes as vj}from"@rango-dev/wallets-shared";import{PendingSwapNetworkStatus as bj}from"rango-types";import{Divider as LS}from"@rango-dev/ui";import uo,{useEffect as BS,useRef as PS,useState as Nc}from"react";import{WalletState as Fh}from"@rango-dev/ui";import{useWallets as Oh}from"@rango-dev/wallets-react";import{useReducer as Uh}from"react";function cp(t){return!!t.derivationPath}i(cp,"isStateOnDerivationPathStep");function up(t){return!!t.namespace}i(up,"isStateOnNamespace");var or={status:"init",namespace:null,derivationPath:null};function mp(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 or;case"resetDerivation":return t.namespace?{...t,derivationPath:null,status:"namespace"}:or;default:throw new Error("Action hasn't been defined.")}}i(mp,"reducer");function Gt(){let{state:t,disconnect:e,connect:o}=Oh(),[n,r]=Uh(mp,or),a=i(async(c,m,g)=>{r({type:"reset"});try{return await o(c,void 0,m),{status:"connected"}}catch(f){let d=f?.message?`Error: ${f.message}`:"An unknown error happened during connecting wallet.";throw new Error(d,{cause:f})}},"runConnect"),s=i(async(c,m)=>{if(c.state===Fh.DISCONNECTED){if(!c.namespaces)return await a(c.type,void 0,m);let f=c.namespaces.length>1,d=c.needsDerivationPath;return f?(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 g=c.singleNamespace,f=c.needsDerivationPath,d=m[0];if(!d)throw new Error("To confirm a namespace, you should select at least one namespace.");if(g&&f)return r({type:"needsDerivationPath",payload:{providerType:c.type,providerImage:c.image,namespace:d}}),{status:"derivation-path"};if(!up(n))throw new Error("Something went wrong on handling namespace. Please retry.");let h=n.namespace.providerType,C=m.map(S=>({namespace:S}));return await a(h,C)},"handleNamespace"),p=i(async c=>{if(!c)throw new Error("Derivation path is empty. Please make sure you've filled the field correctly.");if(!cp(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,f=[{namespace:n.derivationPath.namespace,derivationPath:c}];return await a(m,f)},"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(Gt,"useStatefulConnect");import{WalletState as Ca}from"@rango-dev/ui";import{useWallets as Xy}from"@rango-dev/wallets-react";import{detectMobileScreens as Yy,KEPLR_COMPATIBLE_WALLETS as Zy,WalletTypes as Po}from"@rango-dev/wallets-shared";import{useCallback as Jy,useEffect as Ry}from"react";import Oy,{createContext as Uy,useContext as zy,useEffect as Qy,useRef as qy}from"react";import{create as $y}from"zustand";import{persist as Fy}from"zustand/middleware";var na=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()}},No=new na;function nr(t,e){return e.find(o=>o.name===t)?.displayName}i(nr,"getBlockchainDisplayNameFor");function pt(t,e){return e.find(o=>o.name===t)?.shortName}i(pt,"getBlockchainShortNameFor");function dp(t,e){return e.find(o=>o.name===t)?.logo}i(dp,"getBlockchainImage");function rn(t,e){return e.find(o=>o.id===t)?.title}i(rn,"getSwapperDisplayName");function an(t,e){return e.find(o=>o.name===t)??null}i(an,"findBlockchain");function ra(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(ra,"isTokenNative");function De(t){return`${t.blockchain.toLowerCase()}-${t.symbol.toLowerCase()}-${(t.address??"").toLowerCase()}`}i(De,"createTokenHash");function Wo(t,e){return t.addressPatterns.filter(r=>new RegExp(r).test(e)).length>0}i(Wo,"isValidTokenAddress");function sn(t){let{config:e,meta:o}=t,n={},r=e.tokens,a=i(l=>{l.forEach(p=>{typeof p!="string"&&(p=De(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=De(u);delete n[c]})):a(p.tokens))}),Object.values(n)}i(sn,"matchTokensFromConfigWithMeta");function rr(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(rr,"getSupportedBlockchainsFromConfig");var ia={apiKey:"",title:void 0,multiWallets:!0,excludeLiquiditySources:!0,customDestination:!0,variant:"default",trezorManifest:{appUrl:"https://widget.rango.exchange/",email:"hi+trezorwidget@rango.exchange"},tonConnect:{manifestUrl:"https://raw.githubusercontent.com/rango-exchange/rango-types/main/assets/manifests/tonconnect-manifest.json"}},zh={clientUrl:void 0},Qh={liquiditySources:void 0},fp=i((t,e,o)=>({config:{...ia,...t},iframe:zh,campaignMode:Qh,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=sn({type:"source",config:{blockchains:n.from?.blockchains,tokens:n.from?.tokens},meta:{tokensMapByBlockchainName:s,tokensMapByTokenHash:a}}),p=sn({type:"destination",config:{blockchains:n.to?.blockchains,tokens:n.to?.tokens},meta:{tokensMapByBlockchainName:s,tokensMapByTokenHash:a}});No.set("supportedSourceTokens",l),No.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 gp}from"rango-types";var hp=[gp.EVM,gp.SOLANA];import{RangoClient as ny}from"rango-sdk";import{UI_ID as qh}from"@rango-dev/ui";var ir="c6381a79-2817-4602-83bf-6a641a409e32",yp="https://api.rango.exchange",Sp="https://explorer.rango.exchange",_e={SWAP_BOX_ID:"rango-swap-box",EXPANDED_BOX_ID:"rango-expanded-box",...qh};import{BlockchainCategories as Yh,WalletState as xt}from"@rango-dev/ui";import{legacyReadAccountAddress as Zh}from"@rango-dev/wallets-core/legacy";import{detectInstallLink as Jh,getCosmosExperimentalChainInfo as Rh,isEvmAddress as ey,KEPLR_COMPATIBLE_WALLETS as YI,Networks as Mp}from"@rango-dev/wallets-shared";import ua from"bignumber.js";import{isCosmosBlockchain as ty}from"rango-types";import Hh from"bignumber.js";var Ue=new Hh(0);import{WalletTypes as Gh}from"@rango-dev/wallets-shared";var Cp=[Gh.LEAP];import{BlockchainCategories as sa,WalletState as Xh}from"@rango-dev/ui";import{TransactionType as ar}from"rango-sdk";var kp="Roboto",aa=[{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 Mo(t){return Array.from(new Set(t))}i(Mo,"removeDuplicateFrom");function ca(t,e){return t.length===e.length&&t.every((o,n)=>o===e[n])}i(ca,"areEqual");function Ep(t,e){let o;return n;function n(...r){o&&clearTimeout(o),o=setTimeout(()=>{o=null,t(...r)},e)}}i(Ep,"debounce");function et(t,e){return t.toLowerCase().indexOf(e.toLowerCase())>-1}i(et,"containsText");function wp(t,e){return t.toLowerCase()===e.toLowerCase()}i(wp,"exactText");function bp(t,e){return t.toLowerCase().startsWith(e.toLowerCase())}i(bp,"startWithText");var N=i(()=>document.getElementById(_e.SWAP_BOX_ID),"getContainer"),ln=i(()=>document.getElementById(_e.EXPANDED_BOX_ID),"getExpanded");function xp(t,e,o){let n=!!e&&wp(e,t),r=!!o&&wp(o,t);return n!==r?n?-1:1:0}i(xp,"compareExactMatchText");function la(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(la,"compareContainsText");function pa(t,e,o){let n=!!e&&bp(e,t),r=!!o&&bp(o,t);return n!==r?n?-1:1:n&&r&&e?.length!==o?.length?e?.length-o?.length:0}i(pa,"compareStartWithText");function Ip(t,e,o){if(!o)return 0;let n=xp(o,t.symbol,e.symbol);if(n)return n;if(o.length>=3){let r=xp(o,t.name,e.name);if(r)return r}if(o.length>=2){let r=pa(o,t.symbol,e.symbol);if(r)return r}if(o.length>=3){let r=la(o,t.symbol,e.symbol);if(r)return r}if(o.length>=3){let r=pa(o,t.name,e.name);if(r)return r}if(o.length>=3){let r=la(o,t.name,e.name);if(r!==0)return r}if(o.length>=4){let r=pa(o,t.address,e.address);if(r)return r}if(o.length>=4){let r=la(o,t.address,e.address);if(r!==0)return r}return 0}i(Ip,"compareWithSearchFor");var sr=i((t,e)=>{switch(e){case sa.ALL:return!0;case sa.UTXO:return t===ar.TRANSFER;case sa.OTHER:return t!==ar.TRANSFER&&t!==ar.COSMOS&&t!==ar.EVM;default:return t===e}},"isBlockchainTypeInCategory"),Ap=i(t=>aa.find(o=>o.value===t)?.url,"getFontUrlByName");function Np(t,e){let o=!!t.find(n=>n.state===Xh.CONNECTED);return e===!1&&o}i(Np,"isSingleWalletActive");import{BigNumber as Wp}from"bignumber.js";var pn=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 Wp(t),r=1,a=1e3;for(let s=0;s<60;s++)if(new Wp(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 lr=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"),cn=i(t=>!!t&&parseFloat(t)>0,"isPositiveNumber");function un(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(un,"mapStatusToWalletState");function Lp(t,e,o,n){return o.filter(r=>!Cp.includes(r)).filter(r=>{let{supportedChains:a,isContractWallet:s}=e(r),{installed:l,network:p}=t(r);return s&&(!l||!!n&&p!==n)?!1:n?!!a.find(c=>c.name===n):!0}).map(r=>{let{name:a,img:s,installLink:l,showOnMobile:p,namespaces:u,singleNamespace:c,supportedChains:m,needsDerivationPath:g}=e(r),f=Mo(m.map(h=>h.type)),d=un(t(r));return{title:a,image:s,link:Jh(l),state:d,type:r,showOnMobile:p,namespaces:u,singleNamespace:c,blockchainTypes:f,needsDerivationPath:g}})}i(Lp,"mapWalletTypesToWalletInfo");function ur(t){if(!t)return null;let e=[];return e=t.map(o=>o.name),e}i(ur,"walletAndSupportedChainsNames");function Bp(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}=Zh(p),m=l.length>0,g=l.includes(c),f=c===Mp.Unknown;if(m&&!g&&!f)return;let h=c===Mp.Unknown&&ey(u);if(f&&!h)return;o.includes(c)||h?r?s(c,u.toLowerCase()):l.filter(k=>o.includes(k)).forEach(k=>{s(k,u.toLowerCase())}):s(c,u)}),a}i(Bp,"prepareAccountsForWalletStore");function ao(t){let{filter:e,quote:o}=t,n=new Set;return o?.swaps.forEach((r,a)=>{let s=r.from.blockchain,l=r.to.blockchain;if(n.add(s),r.internalSwaps){let{internalSwaps:p}=r;p.forEach((u,c)=>{let m=u.from.blockchain,g=u.to.blockchain,f=a===o.swaps.length-1,d=c===p.length-1;(!f&&!d||f&&l!==m||e==="all")&&n.add(m),e==="all"&&n.add(g)})}e==="all"&&n.add(l)}),Array.from(n)}i(ao,"getQuoteWallets");function mr(t,e){return t.address===e.address&&t.chain===e.chain&&t.walletType===e.walletType}i(mr,"isAccountAndWalletMatched");function Pp(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 ua(r.amount.amount).shiftedBy(-r.amount.decimals).toFixed(),logo:"",usdPrice:e(r.asset)?.usdPrice||null}))||[]}i(Pp,"makeBalanceFor");function Dp(t){return{...t,loading:!1,error:!0}}i(Dp,"resetConnectedWalletState");var _p=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 ua(a?.amount||Ue).multipliedBy(a?.usdPrice||0))?.reduce((a,s)=>a.plus(s),Ue)||Ue).toString();return oy(r)},"calculateWalletUsdValue");function oy(t){let e=t.toString().split(".");return e[0]=e[0].replace(/\B(?=(\d{3})+(?!\d))/g,","),e.join(".")}i(oy,"numberWithThousandSeparator");var dr=i((t,e)=>{let o=Rh(Object.entries(t).map(([,n])=>n).filter(ty));return o&&o[e]?.experimental},"isExperimentalChain");function fr(t){return t?{...t,amount:L(t.amount,8,8),usdValue:L(t.usdValue,4,4)}:null}i(fr,"formatBalance");function $p(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($p,"compareTokenBalance");function Bt(t,e){return t?.blockchain===e?.blockchain&&t?.symbol.toLowerCase()===e?.symbol.toLowerCase()&&t?.address?.toLowerCase()===e?.address?.toLowerCase()}i(Bt,"areTokensEqual");function Fp(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(Fp,"sortWalletsBasedOnConnectionState");function gr(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(gr,"getConciseAddress");function Op({chain:t,connectedWallets:e,walletType:o}){return e.find(n=>n.walletType===o&&n.chain===t)?.address}i(Op,"getAddress");function hr(t){return t.flatMap(e=>e.balances).reduce((e,o)=>{let n={amount:o?.amount??"",decimals:o?.decimal??0,usdValue:o?.usdPrice?new ua(o?.usdPrice??Ue).multipliedBy(o?.amount).toString():""},r=o?De({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(hr,"makeTokensBalance");var Up=i((t,e)=>!!t.find(o=>o.chain===e&&o.loading),"isFetchingBalance");function zp(t){return t.map(e=>e.state).join("-")}i(zp,"hashWalletsState");function Qp(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(Qp,"filterBlockchainsByWalletTypes");function qp(t,e){return e===Yh.ALL?t:t.filter(o=>{for(let n of o.blockchainTypes)if(sr(n,e))return!0;return!1})}i(qp,"filterWalletsByCategory");var ma={API_KEY:ir};function Pt(t){return ma[t]||""}i(Pt,"getConfig");function Hp(t){let e;return typeof structuredClone=="function"?e=structuredClone(t):e=JSON.parse(JSON.stringify(t)),ma=e,ma}i(Hp,"initConfig");var Gp=20,Vp=25,da="theme-widget",fa=i((t,e)=>{let o=!1;if(e&&t){if(Array.isArray(e))o=!e.some(n=>Bt(n,t));else if(!Array.isArray(e)&&e[t.blockchain]){o=e[t.blockchain].tokens.some(r=>Bt(r,t));let n=e[t.blockchain].isExcluded;return!n&&!o||n&&o}}return o},"isTokenExcludedInConfig"),ga=i((t,e)=>t&&e&&!e.includes(t.name),"isBlockchainExcludedInConfig"),Kp=i((t,e,o)=>o==="expanded"&&(t||e)||o==="full-expanded"&&e,"isVariantExpandable");var yr,Et=i(()=>yr||(yr=new ny(Pt("API_KEY"),Pt("BASE_URL")),yr),"httpService");function Sr(t,e){let o=t.map(a=>a.swapperGroup),n=[];return Mo(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(Sr,"getUniqueSwappersGroups");function jp(t,e){return t.swapperGroup<e.swapperGroup?-1:t.swapperGroup>e.swapperGroup?1:0}i(jp,"sortLiquiditySourcesByGroupTitle");function Xe(t,e){return e?.[t]==="hidden"}i(Xe,"isFeatureHidden");function Lo(t,e){return e?.[t]==="enabled"}i(Lo,"isRoutingEnabled");var Xp=i((t,e,o)=>Xe("customTokens",o)?t:t.concat(e),"addCustomTokensToSupportedTokens");var Yp=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=rr({config:a}),u=r;return p.length>0&&(u=u.filter(c=>p.includes(c.name))),u.filter(c=>hp.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=No.get(c);m?.length||(m=sn({type:o.type,config:{blockchains:a[u]?.blockchains,tokens:a[u]?.tokens},meta:{tokensMapByTokenHash:n,tokensMapByBlockchainName:r}}),No.set(c,m)),m=Xp(m,s,a.features);let g=e().blockchains({type:o.type});return m.filter(d=>o.blockchain&&d.blockchain!==o.blockchain||!g.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 C=e().isTokenPinned(d,o.type),S=e().isTokenPinned(h,o.type);if(C!==S)return C?-1:1;if(o.getBalanceFor){let I=o.getBalanceFor(d),M=o.getBalanceFor(h),b=$p(I,M);if(b!==0)return b}let k=p.get(d.blockchain),T=p.get(h.blockchain),v=ra(d,k),w=ra(h,T);if(v!==w)return v?-1:1;if(d.isPopular!==h.isPopular)return d.isPopular?-1:1;if(o.searchFor){let I=Ip(d,h,o.searchFor);if(I)return I}return d.isSecondaryCoin!==h.isSecondaryCoin?d.isSecondaryCoin?1:-1:k&&T?k.sort-T.sort:0})},findToken:o=>{let n=e()._tokensMapByTokenHash,r=e().customTokens(),a=De(o),s=n.get(a);return s||(s=r.find(l=>De(l)===a)),s},isTokenPinned:(o,n)=>!!(n==="source"?e().config.from?.pinnedTokens:e().config.to?.pinnedTokens)?.some(s=>Bt(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(jp)},fetch:async()=>{try{let{routing:o}=e().config,n=Lo("enableCentralizedSwappers",o),r=await Et().getAllMetadata({enableCentralizedSwappers:n});t({fetchStatus:"success"});let a=new Map,s=new Map,l={},p=[],u=r.popularTokens,c=r.swappers,m=new Set;r.tokens.forEach(f=>{m.add(f.blockchain),p.push(f)}),r.blockchains.sort((f,d)=>f.sort-d.sort).forEach(f=>{f.enabled&&m.has(f.name)&&a.set(f.name,f)}),p.forEach(f=>{let d=De(f);l[f.blockchain]||(l[f.blockchain]=[]),s.set(d,f),l[f.blockchain].push(d)}),t({_blockchainsMapByName:a,_tokensMapByTokenHash:s,_tokensMapByBlockchainName:l,_popularTokens:u,_swappers:c})}catch(o){throw t({fetchStatus:"failed"}),o}}}),"createDataSlice");import{Bengali as ry,Catalonia as iy,Chinese as Zp,Denmark as ay,English as sy,Finland as ly,French as py,German as cy,Greece as uy,Hungary as my,India as dy,Indonesian as fy,Italian as gy,Japanese as hy,Korea as yy,Lithuania as Sy,Malay as Cy,Netherlands as ky,Pakistan as Ty,Philippines as vy,Poland as wy,Portuguese as by,Russian as xy,SaudiArabia as Ey,Serbia as Iy,Slovakia as Ay,SouthAfrica as Ny,Spanish as Wy,Swahili as My,Swedish as Ly,Thai as By,Turkish as Py,Ukrainian as Dy,Vietnamese as _y}from"@rango-dev/ui";var Jp=[{title:"Afrikaans",label:"Afrikaans",local:"af",SVGFlag:Ny},{title:"Arabic",label:"\u0639\u0631\u0628\u064A",local:"ar",SVGFlag:Ey},{title:"Bengali",label:"\u09AC\u09BE\u0982\u09B2\u09BE",local:"bn",SVGFlag:ry},{title:"Catalan",label:"Catal\xE0",local:"ca",SVGFlag:iy},{title:"Chinese (Simplified)",label:"\u7B80\u4F53\u4E2D\u6587",local:"zh-CN",SVGFlag:Zp},{title:"Chinese (Traditional)",label:"\u4E2D\u6587\uFF08\u7E41\u9AD4)",local:"zh-TW",SVGFlag:Zp},{title:"Danish",label:"Dansk",local:"da",SVGFlag:ay},{title:"Dutch",label:"Nederlands",local:"nl",SVGFlag:ky},{title:"English",label:"English",local:"en",SVGFlag:sy},{title:"Filipino",label:"Filipino",local:"fil",SVGFlag:vy},{title:"Finnish",label:"Suomalainen",local:"fi",SVGFlag:ly},{title:"French",label:"Fran\xE7ais",local:"fr",SVGFlag:py},{title:"German",label:"Deutsch",local:"de",SVGFlag:cy},{title:"Greek",label:"\u03B5\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AC",local:"el",SVGFlag:uy},{title:"Hindi",label:"\u0939\u093F\u0902\u0926\u0940",local:"hi",SVGFlag:dy},{title:"Hungarian",label:"Magyar",local:"hu",SVGFlag:my},{title:"Indonesian",label:"Indonesia",local:"id",SVGFlag:fy},{title:"Italian",label:"Italiana",local:"it",SVGFlag:gy},{title:"Japanese",label:"\u65E5\u672C\u8A9E",local:"ja",SVGFlag:hy},{title:"Korean",label:"\uD55C\uAD6D\uC778",local:"ko",SVGFlag:yy},{title:"Lithuanian",label:"Lietuvi\u0173",local:"lt",SVGFlag:Sy},{title:"Malay",label:"Melayu",local:"ms",SVGFlag:Cy},{title:"Polish",label:"Polski",local:"pl",SVGFlag:wy},{title:"Portuguese",label:"Portugu\xEAs",local:"pt",SVGFlag:by},{title:"Russian",label:"\u0420\u0443\u0441\u0441\u043A\u0438\u0439",local:"ru",SVGFlag:xy},{title:"Serbian",label:"C\u0440\u043F\u0441\u043A\u0438",local:"sr",SVGFlag:Iy},{title:"Slovak",label:"Slovensk\xFD",local:"sk",SVGFlag:Ay},{title:"Spanish",label:"Espa\xF1ol",local:"es",SVGFlag:Wy},{title:"Swahili",label:"Kiswahili",local:"sw",SVGFlag:My},{title:"Swedish",label:"Svenska",local:"sv",SVGFlag:Ly},{title:"Thai",label:"\u0E41\u0E1A\u0E1A\u0E44\u0E17\u0E22",local:"th",SVGFlag:By},{title:"Turkish",label:"T\xFCrk\xE7e",local:"tr",SVGFlag:Py},{title:"Ukrainian",label:"Y\u043A\u0440\u0430\u0457\u043D\u0456",local:"uk",SVGFlag:Dy},{title:"Urdu",label:"\u0627\u0631\u062F\u0648",local:"ur",SVGFlag:Ty},{title:"Vietnamese",label:"Ti\u1EBFng Vi\u1EC7t",local:"vi",SVGFlag:_y}],Bo="en";var Rp=[.5,1,3],ec=1,tc=5,oc=100,nc=0;var rc=i((t,e)=>({disabledLiquiditySources:[],theme:"auto",language:null,preferredBlockchains:[],slippage:ec,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=Mo(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=Xe("theme",n),s=Xe("language",n),l=Xe("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||Bo},...l&&{disabledLiquiditySources:o.liquiditySources||[]},...u&&{language:o.language||Bo}})},setCustomToken:o=>t(n=>({_customTokens:[o,...n._customTokens]})),deleteCustomToken:o=>t(n=>({_customTokens:n._customTokens.filter(r=>r.address!==o.address)})),customTokens:()=>{let o=e().config,n=e()._customTokens,r=rr({config:o});return r.length?n.filter(a=>r.includes(a.blockchain)):n}}),"createSettingsSlice");function ic(t){return $y()(Fy((...e)=>({...Yp(...e),...rc(...e),...fp(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(ic,"createAppStore");var ac=Uy(null);function y(){let t=zy(ac);if(Qy(()=>{t&&!t.persist.hasHydrated()&&t.persist.rehydrate()},[]),!t)throw new Error("Missing AppStoreContext.Provider in the tree");return t()}i(y,"useAppStore");function sc(t){let e=qy();return e.current||(e.current=ic(t.config)),Oy.createElement(ac.Provider,{value:e.current},t.children)}i(sc,"AppStoreProvider");import{create as Vy}from"zustand";import{subscribeWithSelector as Ky}from"zustand/middleware";import Hy from"mitt";var he=Hy(),Cr={on:he.on,off:he.off};import{WidgetEvents as lc}from"@rango-dev/queue-manager-rango-preset";var ya=(o=>(o.QUOTE_INPUT_UPDATE="quoteInputUpdate",o.QUOTE_OUTPUT_UPDATE="quoteOutputUpdate",o))(ya||{}),kr=(o=>(o.CONNECT="connect",o.DISCONNECT="disconnect",o))(kr||{}),Sa=(e=>(e.CLICK_CONNECT_WALLET="clickConnectWallet",e))(Sa||{}),so=(a=>(a[a.RouteEvent=lc.RouteEvent]="RouteEvent",a[a.StepEvent=lc.StepEvent]="StepEvent",a.QuoteEvent="quoteEvent",a.WalletEvent="walletEvent",a.UiEvent="uiEvent",a))(so||{});var Gy=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"),Vt=Gy;var R=Vt(Vy()(Ky((t,e)=>({connectedWallets:[],balances:{},loading:!1,connectWallet:(o,n)=>{he.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)&&he.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:hr(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=>mr(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(g=>{let f=o.find(h=>mr(h,g)),d=p.find(h=>h.address===g.address&&h.blockChain===g.chain);return d?.failed&&f&&r&&a([f],n,!1),f&&d?{...g,explorerUrl:d.explorerUrl,balances:Pp(d,n),loading:!1,error:!1}:g});return{loading:!1,balances:hr(c),connectedWallets:c}});else throw new Error("Wallet not found")}catch{t(l=>{let p=l.connectedWallets.map(c=>o.find(m=>mr(m,c))?Dp(c):c);return{loading:!1,balances:hr(p),connectedWallets:p}})}},getBalanceFor:o=>{let{balances:n}=e(),r=De(o);return n[r]??null}}))));import{allProviders as jy}from"@rango-dev/provider-all";function Tr(t,e){let o=jy({walletconnect2:{WC_PROJECT_ID:e?.walletConnectProjectId||"",DISABLE_MODAL_AND_OPEN_LINK:e?.walletConnectListedDesktopWalletLink},selectedProviders:t,trezor:e?.trezorManifest?{manifest:e.trezorManifest}:void 0,tonConnect:e?.tonConnect?.manifestUrl?{manifestUrl:e?.tonConnect.manifestUrl}: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(Tr,"matchAndGenerateProviders");function pc(t,e){return Tr(t,e).map(r=>r.config.type)}i(pc,"configWalletsToWalletName");var eS=Object.values(Po);function ft(t){let{chain:e}=t||{},{config:o}=y(),{state:n,getWalletInfo:r}=Xy(),{connectedWallets:a}=R(),s=y().blockchains(),{handleDisconnect:l}=Gt(),p=pc(o?.wallets,{trezorManifest:o?.trezorManifest,walletConnectProjectId:o?.walletConnectProjectId,walletConnectListedDesktopWalletLink:o.__UNSTABLE_OR_INTERNAL__?.walletConnectListedDesktopWalletLink,tonConnect:o.tonConnect})||eS,u=Lp(n,r,p,e);u=Yy()?u.filter(h=>h.showOnMobile!==!1&&n(h.type).installed):u;let c=Fp(u),m=i(h=>!a.find(C=>C.walletType===h&&C.chain===e),"isExperimentalChainNotAdded"),g=Jy(()=>{let h=u?.filter(C=>C.state===Ca.CONNECTING)||[];for(let C of h)l(C.type)},[zp(u)]);Ry(()=>()=>{g()},[]);let f=i(h=>{let C=h.find(k=>k.type===Po.DEFAULT);return!C||C.state===Ca.NOT_INSTALLED?!1:h.filter(k=>k.state!=Ca.NOT_INSTALLED&&![Po.DEFAULT,Po.WALLET_CONNECT_2,Po.LEDGER].includes(k.type)&&r(k.type).supportedChains.filter(T=>T.type=="EVM").length>0).length==0},"shouldShowDefaultInjectedWallet"),d=i((h,C,S)=>dr(S,C)&&m(h)&&!Zy.includes(h)||h==Po.DEFAULT&&!f(u),"shouldExcludeWallet");return{list:c.filter(h=>!d(h.type,e??"",s)),terminateConnectingWallets:g}}i(ft,"useWalletList");import{Modal as nS}from"@rango-dev/ui";import rS from"react";import{create as oS}from"zustand";var cc="rango-widget";var mn=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(cc),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=Vt(oS()((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 mn({onInit:()=>se.setState({tabManagerInitiated:!0}),onClaim:()=>se.setState({isActiveTab:!0,showActivateTabModal:!1}),onRelease:()=>se.setState({isActiveTab:!1})});function ee(t){let{watermark:e}=se();return rS.createElement(nS,{hasWatermark:e==="FULL",...t},t.children)}i(ee,"WatermarkedModal");import{i18n as ka}from"@lingui/core";import{Button as cS,Checkbox as uS,Divider as mS,Image as kc,ListItemButton as dS,MessageBox as fS,Radio as gS,RadioRoot as hS}from"@rango-dev/ui";import{namespaces as Tc}from"@rango-dev/wallets-shared";import Te,{useMemo as yS,useState as SS}from"react";import{css as iS,darkTheme as mc,IconButton as aS,styled as po}from"@rango-dev/ui";var It=po(aS,{width:"$24",position:"relative",padding:"0",overflow:"unset","&:hover":{backgroundColor:"$secondary100",[`.${mc} &`]:{backgroundColor:"$neutral"}}}),dc=po("div",{position:"absolute",background:"$secondary500",[`.${mc} &`]:{$$color:"$colors$secondary250"},width:"$6",height:"$6",borderRadius:"$lg",right:"$4",border:"1px solid $surface100"}),Kt=po("div",{display:"flex",justifyContent:"flex-end",minWidth:"$40",button:{padding:0}}),fc=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"}}}}),gc=po("div",{padding:"$2",variants:{isRefetched:{true:{transform:"rotate(360deg)",transition:"transform 1s ease-in-out"}}}}),hc=po("div",{position:"absolute",right:"$4",top:"$4",backgroundColor:"$background",borderRadius:"100%"}),yc=iS({display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center"}),vr=po("div",{borderRadius:"100%",border:"1.5px transparent solid","&:not(:first-child)":{marginLeft:"-$6"},img:{borderRadius:"100%"}});import{keyframes as sS,styled as wr}from"@rango-dev/ui";var RA=wr("div",{borderRadius:"$lg",width:"$45",height:"$45",backgroundColor:"$success300",display:"flex",justifyContent:"center",alignItems:"center"}),Do=wr("div",{position:"relative"}),lS=sS({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}),_o=wr("div",{position:"absolute",border:"2px solid rgba(0, 0, 0, 0.1)",borderTop:"2px solid $info500",borderRadius:"$lg",width:"$45",height:"$45",animation:`${lS} 1s linear infinite`,top:0,bottom:0,right:0,left:0}),br=wr("div",{"& img":{borderRadius:"50%"}});function Sc(t,e){return t.find(o=>o.name===e)?.logo}i(Sc,"getBlockchainLogo");import{styled as pS}from"@rango-dev/ui";var Cc=pS("ul",{padding:0,paddingTop:"$4",paddingBottom:"$4"});function dn(t){let{singleNamespace:e,availableNamespaces:o,providerImage:n}=t.value,[r,a]=SS([]),s=y().blockchains(),l=yS(()=>o?.map(c=>({name:c,logo:Sc(s,Tc[c].mainBlockchain),title:Tc[c].title})),[o]),p=i(c=>{a(e?[c]:m=>m.includes(c)?m.filter(g=>g!==c):m.concat(c))},"onSelect"),u=i(c=>e?Te.createElement(hS,{value:r?.[0]},c):Te.createElement(Te.Fragment,null,c),"wrapRadioRoot");return Te.createElement(Te.Fragment,null,Te.createElement(mS,{size:20}),Te.createElement(fS,{type:"info",title:ka.t("Select chain types"),description:ka.t("This wallet supports multiple chains. Select which chain you'd like to connect to."),icon:Te.createElement(Do,null,Te.createElement(vr,null,Te.createElement(kc,{src:n,size:45})),Te.createElement(_o,null))}),Te.createElement(Cc,null,u(Te.createElement(Te.Fragment,null,l?.map(c=>Te.createElement(dS,{key:c.name,id:c.name,title:c.title,hasDivider:!0,style:{height:60},onClick:()=>p(c.name),start:Te.createElement(kc,{src:c.logo,size:22}),end:e?Te.createElement(gS,{value:c.name}):Te.createElement(uS,{checked:r.includes(c.name)})}))))),Te.createElement(cS,{id:"widget-name-space-confirm-btn",type:"primary",disabled:!r.length,onClick:()=>t.onConfirm(r)},ka.t("Confirm")))}i(dn,"Namespaces");import{i18n as $o}from"@lingui/core";import{Button as TS,Divider as bc,Image as vS,MessageBox as wS,Select as bS,TextField as xS}from"@rango-dev/ui";import ze,{useEffect as ES,useState as xc}from"react";import{namespaces as CS}from"@rango-dev/wallets-shared";var xr={id:"custom",label:"Custom",generateDerivationPath:t=>t};function Ta(t){let e=t?CS[t].derivationPaths:null;return e?[...e,xr]:[]}i(Ta,"getDerivationPaths");import{styled as vc,Typography as kS}from"@rango-dev/ui";var wc=vc("div",{paddingTop:"$30",paddingBottom:"$30",zIndex:10}),va=vc(kS,{paddingLeft:"$10"}),wa={height:"$40",backgroundColor:"$neutral200",borderRadius:"$sm"};var Ec="0";function fn(t){let{onConfirm:e}=t,{namespace:o,providerImage:n,providerType:r}=t.value,[a,s]=xc(null),[l,p]=xc(Ec),u=a===xr.id,c=Ta(o),m=i(({value:f})=>{let d=c?.find(h=>h.id===f);d&&(a===xr.id&&Number.isNaN(Number(l))&&p(Ec),s(d.id))},"handleDerivationPathItemClick"),g=i(()=>{let f=c.find(d=>d.id===a);if(f)e(f.generateDerivationPath(l));else throw new Error("selectedDerivationPath can not be undefined")},"handleConfirm");return ES(()=>{s(Ta(o)[0]?.id||null)},[o]),ze.createElement(ze.Fragment,null,ze.createElement(bc,{size:20}),ze.createElement(wS,{type:"info",title:$o.t("Select Derivation Path"),description:$o.t({id:"In order to connect to {type}, you must first select a Derivation Path",values:{type:r}}),icon:ze.createElement(Do,null,ze.createElement(br,null,ze.createElement(vS,{src:n,size:45})),ze.createElement(_o,null))}),ze.createElement(wc,null,ze.createElement(va,{variant:"body",size:"xsmall",color:"$neutral600"},$o.t("Choose Derivation Path Template")),ze.createElement(bS,{value:a||"",options:c.map(f=>({value:f.id,label:f.label})),variant:"filled",handleItemClick:m,styles:{trigger:wa}}),ze.createElement(bc,{size:20}),ze.createElement(va,{variant:"body",size:"xsmall",color:"$neutral600"},u?$o.t("Enter Path"):$o.t("Enter Index")),ze.createElement(xS,{type:u?"text":"number",variant:"contained",value:l,onChange:f=>p(f.target.value),style:wa})),ze.createElement(TS,{id:"widget-derivation-path-confirm-btn",type:"primary",onClick:g,disabled:!c||!a||!l},$o.t("Confirm")))}i(fn,"DerivationPath");import{i18n as Fo}from"@lingui/core";import{Image as IS,MessageBox as ba,WalletState as AS}from"@rango-dev/ui";import{useWallets as NS}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}=NS();return un(a(n))===AS.CONNECTED?co.createElement(ba,{type:"success",title:Fo.t("Wallet Connected"),description:Fo.t("Your wallet is connected, you can use it to swap.")}):o?co.createElement(ba,{type:"error",title:Fo.t("Failed to Connect"),description:o||Fo.t("Your wallet is not connected. Please try again.")}):co.createElement(ba,{type:"loading",title:Fo.t("Connecting to your wallet"),description:Fo.t("Click connect in your wallet popup."),icon:co.createElement(Do,null,co.createElement(br,null,co.createElement(IS,{src:r,size:45})),co.createElement(_o,null))})}i(xa,"ConnectStatus");import{i18n as Ea}from"@lingui/core";import{Button as WS,Divider as Ic,MessageBox as MS}from"@rango-dev/ui";import Er from"react";function Ia(t){let{displayName:e,onConfirm:o}=t;return Er.createElement(MS,{title:Ea.t({id:"Add {blockchainDisplayName} Chain",values:{blockchainDisplayName:e}}),type:"warning",description:Ea.t({id:"Would you like to add the {blockchainDisplayName} experimental chain to your wallet?",values:{blockchainDisplayName:e}})},Er.createElement(Ic,{size:18}),Er.createElement(Ic,{size:32}),Er.createElement(WS,{id:"widget-experimental-chain-confirm-btn",onClick:o,variant:"outlined",type:"primary",fullWidth:!0,size:"large"},Ea.t("Confirm")))}i(Ia,"ExperimentalChain");function Ac(t,e){return t().status==="init"&&!!e}i(Ac,"isOnStatus");function gn(t){return t().status==="namespace"}i(gn,"isOnNamespace");function hn(t){return t().status==="derivationPath"}i(hn,"isOnDerivationPath");var DS=3e3,_S=300;function mo(t){let e=PS(),[o,n]=Nc(!1),[r,a]=Nc(),s=i(S=>{a(S.message)},"catchErrorOnHandle"),{terminateConnectingWallets:l}=ft(),{handleConnect:p,handleDerivationPath:u,handleNamespace:c,getState:m,resetState:g}=Gt(),f=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"),C=i(()=>{a(void 0),g(),n(!1),e.current&&clearTimeout(e.current)},"resetModalState");return BS(()=>{if(t.wallet){C();let S=!1,k=!0,T=i(()=>{setTimeout(()=>{k=!1,S||n(!0)},_S)},"beforeConnecting"),v=i(w=>{let I=w.status==="connected",M=["disconnected","disconnected-unhandled"].includes(w.status);["namespace","derivation-path"].includes(w.status)||(S=!0),I&&!k?e.current=setTimeout(h,DS):M&&h(),t.onConnect&&t.onConnect(w)},"afterConnected");T(),p(t.wallet,{disconnectIfConnected:!0}).then(v).catch(s)}},[t.wallet]),uo.createElement(ee,{open:o,onClose:h,onExit:()=>{C(),l(),t.onClose&&t.onClose()},container:N()},Ac(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})),gn(m)&&uo.createElement(dn,{onConfirm:f,value:m().namespace}),hn(m)&&uo.createElement(fn,{onConfirm:d,value:m().derivationPath}))}i(mo,"StatefulConnectModal");import{Events as Na,Provider as FS}from"@rango-dev/wallets-react";import{isEvmBlockchain as OS}from"rango-sdk";import Ir,{createContext as US,useEffect as Mc,useMemo as zS,useRef as Lc}from"react";import{useEffect as $S}from"react";function Wc(t){return t.map(e=>typeof e=="string"?e:e.config.type).join("-")}i(Wc,"hashProviders");function Aa(t,e){let o=R.use.clearConnectedWallet(),n=Tr(t,e);return $S(()=>{o(),n=Tr(t,e)},[Wc(t??[]),e?.walletConnectProjectId,e?.walletConnectListedDesktopWalletLink]),{providers:n}}i(Aa,"useWalletProviders");var Ar=US({onConnectWallet:()=>{},onDisconnectWallet:()=>{}});function QS(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,tonConnect:l.tonConnect,walletConnectListedDesktopWalletLink:t.config.__UNSTABLE_OR_INTERNAL__?.walletConnectListedDesktopWalletLink},{providers:u}=Aa(l.wallets,p),{connectWallet:c,disconnectWallet:m}=R(),g=Lc(),f=Lc();Mc(()=>{n().catch(console.log)},[]),Mc(()=>{t.config&&(e(t.config),o(t.config),window.__rango={config:l,dappConfig:t.config})},[t.config,r]);let d=a.filter(OS).map(k=>k.name),h=i((k,T,v,w,I)=>{if(T===Na.ACCOUNTS)if(v){let M=ur(I.supportedBlockchains),b=Bp(k,v,d,M,I.isContractWallet);b.length&&c(b,s)}else m(k),f.current?f.current(k):console.warn("onDisconnectWallet handler hasn't been set. Are you sure?");if(T===Na.ACCOUNTS&&w.connected){let M=`${k}-${w.network}-${v}`;w.connected&&(g.current?g.current(M):console.warn("onConnectWallet handler hasn't been set. Are you sure?"))}if(T===Na.NETWORK&&w.network){let M=`${k}-${w.network}`;g.current?g.current(M):console.warn("onConnectWallet handler hasn't been set. Are you sure?")}t.onUpdateState&&t.onUpdateState(k,T,v,w,I)},"onUpdateState"),C=se.use.isActiveTab(),S=zS(()=>({onConnectWallet:k=>{g.current=k},onDisconnectWallet:k=>{f.current=k}}),[]);return Ir.createElement(Ar.Provider,{value:S},Ir.createElement(FS,{allBlockChains:a,providers:u,onUpdateState:h,autoConnect:!!C},t.children))}i(QS,"Main");function Nr(t){let{config:e,...o}=t;return Ir.createElement(sc,{config:e},Ir.createElement(QS,{...o,config:e}))}i(Nr,"WidgetWallets");import ta from"react";import qS,{Fragment as HS}from"react";import{MemoryRouter as GS,useInRouterContext as VS}from"react-router";function Bc({children:t}){let o=VS()?HS:GS;return qS.createElement(o,null,t)}i(Bc,"AppRouter");import{I18nManager as AE}from"@rango-dev/ui";import sp from"react";import Be from"react";import{useRoutes as fE}from"react-router-dom";var _={home:"/",fromSwap:"from-swap",toSwap:"to-swap",blockchains:"blockchains",settings:"settings",customTokens:"custom-tokens",addCustomTokens:"add-custom-tokens",liquiditySources:"liquidity-sources",bridges:"bridges",exchanges:"exchanges",languages:"languages",swaps:"swaps",wallets:"wallets",confirmSwap:"confirm-swap",swapDetails:":requestId",routes:"routes"};import{useEffect as zo,useRef as Fr}from"react";import Ye from"bignumber.js";import{create as XS}from"zustand";import{subscribeWithSelector as YS}from"zustand/middleware";import{getLastSuccessfulStep as jS}from"@rango-dev/queue-manager-rango-preset";import sM from"bignumber.js";function Wa(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(Wa,"getFeeLabel");var Ma=["RECOMMENDED","CENTRALIZED","LOWEST_FEE","FASTEST","HIGH_IMPACT"],Pc=30;import{i18n as gt}from"@lingui/core";import{RouteEventType as VW}from"@rango-dev/queue-manager-rango-preset";import Qe from"bignumber.js";import{PendingSwapNetworkStatus as Mr}from"rango-types";import{i18n as $e}from"@lingui/core";var te=i(()=>({genericServerError:$e.t("Failed Network, Please retry your swap."),liquiditySourcesError:{title:$e.t("Please reset your liquidity sources."),description:$e.t("You have limited the liquidity sources and this might result in Rango finding no routes. Please consider resetting your liquidity sources.")},noResultError:{title:$e.t("No Routes Found."),description:$e.t("Reasons why Rango couldn't find a route: low liquidity on token, very low input amount or no routes available for the selected input/output token combination.")},bridgeLimitErrors:{increaseAmount:$e.t("Bridge Limit Error: Please increase your amount."),decreaseAmount:$e.t("Bridge Limit Error: Please decrease your amount.")},highValueLossError:{impactTitle:$e.t("High Price Impact"),title:$e.t("Price impact is too high!"),description:$e.t("The price impact is significantly higher than the allowed amount."),confirmMessage:$e.t("Confirm high price impact")},quoteUpdatedWithHighValueLoss:{title:$e.t("Route updated and price impact is too high, try again later!")},unknownPriceError:{impactTitle:$e.t("USD Price Unknown"),title:$e.t("USD Price Unknown, Cannot calculate Price Impact."),description:$e.t("USD Price Unknown, Cannot calculate Price Impact. The price impact may be higher than usual. Are you sure to continue the Swap?"),confirmMessage:$e.t("Confirm USD Price Unknown")}}),"errorMessages");function Dc(t){switch(t.type){case 0:return t.diagnosisMessage??te().noResultError.title;case 1:return te().genericServerError;default:return""}}i(Dc,"getQuoteErrorMessage");import{i18n as Wr}from"@lingui/core";var fo=i(()=>({connectWallet:Wr.t("Connect Wallet"),swap:Wr.t("Swap"),swapAnyway:Wr.t("Swap anyway"),ethWarning:Wr.t("The route goes through Ethereum. Continue?")}),"swapButtonTitles");function _c(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(_c,"hasHighValueLoss");function $c(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($c,"hasLimitError");function Fc(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(Fc,"getLimitErrorMessage");function Oc(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(Oc,"getSwapButtonState");function La(t,e,o){let n=parseFloat(e||"0");return!(t&&(!o||o.lte(Ue))&&e&&e!=="0"&&n!==0)}i(La,"canComputePriceImpact");function Ba(t,e){let o=Ue;for(let n=0;n<t.fee.length;n++){let r=t.fee[n];if(r.expenseType==="DECREASE_FROM_OUTPUT")continue;let a=e(r.asset)?.usdPrice||null;o=o.plus(new Qe(r.amount).multipliedBy(a||0))}return o}i(Ba,"getUsdFeeOfStep");function Lr(t,e){return t.reduce((o,n)=>o.plus(Ba(n,e)),Ue)}i(Lr,"getTotalFeeInUsd");function Pa(t){let e=Ue;return e=e.plus(new Qe(t.amount).multipliedBy(t.price||0)),e}i(Pa,"getUsdFee");function Uc(t){return t.reduce((e,o)=>e.plus(Pa(o)),Ue)}i(Uc,"getTotalFeesInUsd");function zc(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(zc,"getFeesGroup");function Qc(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(Qc,"checkSlippageErrors");function qc(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(qc,"checkSlippageWarnings");function Br(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(Br,"getMinRequiredSlippage");function Hc(t,e){return e?parseFloat(t)>=parseFloat(e):!0}i(Hc,"hasProperSlippage");function Gc(t){let{fromToken:e,toToken:o,inputAmount:n,wallets:r,selectedWallets:a,disabledLiquiditySources:s,liquiditySources:l,excludeLiquiditySources:p,slippage:u,affiliateRef:c,affiliatePercent:m,affiliateWallets:g,destination:f}=t,d=a?.reduce((S,k)=>(S[k.chain]=k.address,S),{}),h=[];return r?.forEach(S=>{h.push({blockchain:S.chain,addresses:[S.address]})}),{amount:n.toString(),affiliateRef:c??void 0,affiliatePercent:m??void 0,affiliateWallets:g??void 0,from:{address:e.address,blockchain:e.blockchain,symbol:e.symbol},to:{address:o.address,blockchain:o.blockchain,symbol:o.symbol},connectedWallets:h,selectedWallets:d??{},slippage:u.toString(),...f&&{destination:f},...p&&{swapperGroups:s.concat(l??[]),swappersGroupsExclude:!0},...!p&&{swapperGroups:l?.filter(S=>!s.includes(S)),swappersGroupsExclude:!1}}}i(Gc,"createQuoteRequestBody");function Vc(t){return t.reduce((o,n)=>(o[n.chain]={address:n.address,walletType:n.walletType},o),{})}i(Vc,"getWalletsForNewSwap");function Oo(t){return t?.outputAmount||null}i(Oo,"getQuoteOutputAmount");function Kc(t,e){return new Qe(e).div(new Qe(t)).minus(1).multipliedBy(100).toNumber()}i(Kc,"getPercentageChange");function jc(t,e){let o=Oo(t),n=Oo(e);if(!o||!n)return!1;let r=ct(o,n);return r?r<=-1:!0}i(jc,"isOutputAmountChangedALot");function Xc(t,e,o){let n=t.validationStatus,r=ao({filter:"required",quote:t});return e.sort((s,l)=>r.indexOf(s.chain)-r.indexOf(l.chain)).flatMap(s=>tu(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(Xc,"generateBalanceWarnings");function Xt(t,e){return(t?new Qe(t):Ue).multipliedBy(e||0)}i(Xt,"calcOutputUsdValue");function yn(t){return!!t&&t.networkStatus!==null&&t.networkStatus!==Mr.NetworkChanged}i(yn,"isNetworkStatusInWarningState");function Yc(t,e){let o="bellow button or",n=t.extraMessage,r=t.extraMessageDetail;if(t.networkStatusExtraMessageDetail?.includes(o)&&(t.networkStatusExtraMessageDetail=t.networkStatusExtraMessageDetail.replace(o,"")),yn(e))switch(n=t.networkStatusExtraMessage||"",r=t.networkStatusExtraMessageDetail||"",e?.networkStatus){case Mr.WaitingForConnectingWallet:n=n||gt.t("Waiting for connecting wallet");break;case Mr.WaitingForQueue:n=n||gt.t("Waiting for other running tasks to be finished");break;case Mr.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(Yc,"getSwapMessages");function Zc(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(Zc,"getLastConvertedTokenInFailedSwap");function Jc(t){return t.status==="failed"}i(Jc,"shouldRetrySwap");function Rc(t,e,o,n,r,a){if(!n||t)return!0;let s=ao({filter:"all",quote:n}),l=ao({filter:"required",quote:n}),p=s.every(m=>r.some(g=>g.chain===m)),u=l.every(m=>r.some(g=>g.chain===m)),c=o&&a?Wo(a,o):!1;return!e&&!p||e&&!o||e&&!!o&&(!c||!u)}i(Rc,"isConfirmSwapDisabled");function eu(t,e){return t.blockchain===e.blockchain&&t.symbol===e.symbol&&t.address===e.address}i(eu,"isTokensIdentical");function go(t){let e=t?.swaps||[];return e[e.length-1].to.usdPrice}i(go,"getQuoteToTokenUsdPrice");function Sn(t){return(t?.swaps||[])[0].from.usdPrice}i(Sn,"getQuoteFromTokenUsdPrice");function Da(t,e){let o=t?.swaps||[],n=e?.swaps||[];return o.length!==n.length}i(Da,"isNumberOfSwapsChanged");function _a(t,e){let o=t?.swaps.map(r=>r.swapperId)||[],n=e?.swaps.map(r=>r.swapperId)||[];return!ca(o,n)}i(_a,"isQuoteSwappersUpdated");function $a(t,e){let o=t?.swaps.map(r=>r.to.symbol)||[],n=e?.swaps.map(r=>r.to.symbol)||[];return!ca(o,n)}i($a,"isQuoteInternalCoinsUpdated");function nu(t,e){return Da(t,e)||_a(t,e)||$a(t,e)}i(nu,"isQuoteChanged");function tu(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(tu,"getRequiredBalanceOfWallet");function Dt(t){let e;return t<=-3&&t>-10?e="low":t<=-10&&(e="high"),e}i(Dt,"getPriceImpactLevel");function Dr(t,e,o){let n=t.steps[0],r=t.steps[t.steps.length-1],a=jS(t.steps),s={blockchain:r.toBlockchain,symbol:r.toSymbol,address:r.toSymbolAddress},l=an(a?a.toBlockchain:n.fromBlockchain,e),p=an(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(Dr,"createRetryQuote");function Uo(t,e){let{fromToken:o,toToken:n,findToken:r,userSlippage:a}=e,s=Xt(t.requestAmount,Sn(t)||o?.usdPrice),l=Xt(t.outputAmount,go(t)||n?.usdPrice);if(t&&s&&l){let c=ct(s.toString(),l.toString());if(!!c&&_c(s,c)){let g=Lr(t?.swaps,r),f=Dt(c);return{type:0,inputUsdValue:s,outputUsdValue:l,priceImpact:c,totalFee:g,warningLevel:f}}}else if(t&&(!s||!l))return{type:1};let p=Br(t.swaps),u=a>tc;if(Hc(e.userSlippage.toString(),p)){if(u&&parseFloat(p??"0")<a)return{type:3,slippage:a.toString()}}else return{type:2,recommendedSlippages:qc(t,a),minRequiredSlippage:p};return null}i(Uo,"generateQuoteWarnings");function ct(t,e){let o=typeof e=="string"?parseFloat(e)<=0:!e?.gt(0),n=!t||!e||o?null:Kc(t.toString(),e.toString());return n&&n<0?n:null}i(ct,"getPriceImpact");var ru=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"),_r=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"),iu=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"),au=i(t=>{let e=i((o,n)=>{let r=Ma.indexOf(o.value),a=Ma.indexOf(n.value);return r!==-1&&a!==-1?r-a:r!==-1?-1:a!==-1?1:0},"customSort");return t.sort(e)},"sortTags");var $r=i((t,e)=>t?.usdPrice?new Ye(e||Ue).multipliedBy(t?.usdPrice||0):null,"getUsdValue"),F=Vt(XS()(YS(t=>({fromBlockchain:null,fromToken:null,inputAmount:"",outputAmount:null,inputUsdValue:new Ye(0),outputUsdValue:new Ye(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 cn(o.inputAmount)?(e&&(n=e?.outputAmount?new Ye(e?.outputAmount):null,a=Xt(o.inputAmount,Sn(e)||o.fromToken?.usdPrice),r=Xt(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 Ye(0),quotes:null,refetchQuote:!0,error:null,warning:null})),setFromBlockchain:e=>{t(o=>o.fromBlockchain?.name===e?.name?{}:{fromBlockchain:e,inputUsdValue:new Ye(0),...o.fromToken&&{selectedQuote:null,fromToken:null,outputAmount:null,outputUsdValue:new Ye(0)}})},setFromToken:e=>t(o=>({fromToken:e.token,...e.token&&{fromBlockchain:e.meta.blockchains.find(n=>n.name===e.token.blockchain)??null},...!!o.inputAmount&&{inputUsdValue:$r(e.token,o.inputAmount)}})),setToBlockchain:e=>{t(o=>o.toBlockchain?.name===e?.name?{}:{toBlockchain:e,...o.toToken&&{selectedQuote:null,toToken:null,outputAmount:null,outputUsdValue:new Ye(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 Ye(0),selectedQuote:null},...!!o.fromToken&&{inputUsdValue:$r(o.fromToken,e)}}))},retry:e=>{let{fromBlockchain:o,fromToken:n,toBlockchain:r,toToken:a,inputAmount:s}=e;t({fromBlockchain:o,fromToken:n,inputAmount:s,outputAmount:null,inputUsdValue:$r(n??null,s),outputUsdValue:new Ye(0),toBlockchain:r,toToken:a,selectedQuote:null})},switchFromAndTo:()=>t(e=>({fromBlockchain:e.toBlockchain,fromToken:e.toToken,toBlockchain:e.fromBlockchain,toToken:e.fromToken,inputAmount:e.outputAmount?.toString()||"",inputUsdValue:e.toToken?$r(e.toToken,e.outputAmount?.toString()||""):new Ye(0)})),resetFromBlockchain:()=>t(()=>({fromToken:null,fromBlockchain:null,outputUsdValue:new Ye(0),inputUsdValue:new Ye(0),inputAmount:"",outputAmount:null,selectedQuote:null})),resetToBlockchain:()=>t(()=>({toToken:null,toBlockchain:null,outputAmount:null,outputUsdValue:new Ye(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})})))),su=F.subscribe((t,e)=>{(t.fromBlockchain!==e.fromBlockchain||t.fromToken!==e.fromToken||t.toBlockchain!==e.toBlockchain||t.toToken!==e.toToken||t.inputAmount!==e.inputAmount)&&he.emit("quoteEvent",{type:"quoteInputUpdate",payload:{fromBlockchain:t.fromBlockchain?.name,toBlockchain:t.toBlockchain?.name,fromToken:t.fromToken?{symbol:t.fromToken.symbol,name:t.fromToken.name,address:t.fromToken.address}:void 0,toToken:t.toToken?{symbol:t.toToken.symbol,name:t.toToken.name,address:t.toToken.address}:void 0,requestAmount:t.inputAmount}}),t.selectedQuote?.requestId!==e.selectedQuote?.requestId&&he.emit("quoteEvent",{type:"quoteOutputUpdate",payload:t.selectedQuote?{requestAmount:t.selectedQuote.requestAmount,swaps:t.selectedQuote.swaps,outputAmount:t.selectedQuote.outputAmount,resultType:t.selectedQuote.resultType,tags:t.selectedQuote.tags}:null})});function lu(){let{setInputAmount:t,setToToken:e,setToBlockchain:o,setFromBlockchain:n,resetQuote:r,setFromToken:a,fromToken:s,toToken:l,fromBlockchain:p,toBlockchain:u}=F(),c=y().config,m=y().fetchStatus,g=y().blockchains(),f=y().tokens(),{findToken:d}=y(),{setAffiliateRef:h,setAffiliatePercent:C,setAffiliateWallets:S}=y(),k=c?.from?.tokens,T=c?.from?.blockchains,v=c?.to?.tokens,w=c?.to?.blockchains,I=Fr(void 0),M=Fr(void 0),b=Fr(void 0),E=Fr(void 0);zo(()=>{typeof c.amount<"u"&&t(c.amount.toString())},[c?.amount]),zo(()=>{if(m==="success"){r();let x=g.find(A=>A.name===c?.from?.blockchain),W=c?.from?.token,D=W&&d(W);(x||!x&&b.current)&&n(x??null),D?a({token:D,meta:{blockchains:g,tokens:f}}):!D&&I.current&&a({token:null}),b.current=c?.from?.blockchain,I.current=c?.from?.token}},[c?.from?.token?.symbol,c?.from?.token?.address,c?.from?.token?.blockchain,c?.from?.blockchain,m]),zo(()=>{fa(s,k)&&a({token:null}),ga(p,T)&&n(null)},[k,T]),zo(()=>{fa(l,v)&&a({token:null}),ga(u,w)&&o(null)},[v,w]),zo(()=>{if(m==="success"){r();let x=g.find(A=>A.name===c?.to?.blockchain),W=c?.to?.token,D=W&&d(W);(x||!x&&E.current)&&o(x??null),D?e({token:D,meta:{blockchains:g,tokens:f}}):!D&&M.current&&e({token:null}),E.current=c?.to?.blockchain,M.current=c?.to?.token}},[c?.to?.token?.symbol,c?.to?.token?.address,c?.to?.token?.blockchain,c?.to?.blockchain,m]),zo(()=>{h(c?.affiliate?.ref??null),C(c?.affiliate?.percent??null),S(c?.affiliate?.wallets??null)},[c?.affiliate?.ref,c?.affiliate?.percent,c?.affiliate?.wallets])}i(lu,"useSyncStoresWithConfig");import{useEffect as Ua,useRef as ZS}from"react";import{useInRouterContext as JS,useLocation as RS,useSearchParams as eC}from"react-router-dom";function Fa(t,e){let o=t.split("--");return{blockchain:e.name,address:o?.[1]||null,symbol:o[0]}}i(Fa,"convertTokenSearchParamToAsset");function Oa(t){if(t)return`${t.symbol}${t.address?`--${t.address}`:""}`}i(Oa,"tokenToSearchParam");function Qa(){let t=RS(),[e,o]=eC(),{fromBlockchain:n,toBlockchain:r,fromToken:a,toToken:s,inputAmount:l,setFromBlockchain:p,setToBlockchain:u,setFromToken:c,setToToken:m,setInputAmount:g}=F(),f=y().fetchStatus,d=y().blockchains(),h=y().tokens(),C=JS(),{updateIframe:S,updateCampaignMode:k}=y(),T=y().isInCampaignMode(),v=ZS(),{findToken:w}=y(),I=i(()=>{let b={};for(let[K,me]of e.entries())K.startsWith("utm_")&&(b[K]=me);let E=e.get("fromAmount"),x=e.get("fromBlockchain"),W=e.get("fromToken"),D=e.get("toBlockchain"),A=e.get("toToken"),Z=e.get("autoConnect"),ae=e.get("clientUrl"),J=e.get("liquiditySources"),B=e.get("blockchain");return{fromAmount:E,fromBlockchain:x,fromToken:W,toBlockchain:D,toToken:A,autoConnect:Z,clientUrl:ae,liquiditySources:J,utmQueryParams:b,blockchain:B}},"getUrlSearchParams"),M=i(b=>{for(let E in b)b[E]||delete b[E];o(b,{replace:!0})},"updateUrlSearchParams");Ua(()=>{let{autoConnect:b,clientUrl:E,utmQueryParams:x,blockchain:W}=I();C&&f==="success"&&M({fromBlockchain:n?.name,fromToken:Oa(a),toBlockchain:r?.name,toToken:Oa(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]),Ua(()=>{if(!C)return;let b=I();if(!v.current&&b.liquiditySources&&(v.current=b.liquiditySources),b.fromAmount&&g(b.fromAmount),f==="success"){let E=d.find(A=>A.name===b.fromBlockchain),x=b.fromToken&&E?w(Fa(b.fromToken,E)):void 0,W=d.find(A=>A.name===b.toBlockchain),D=b.toToken&&W?w(Fa(b.toToken,W)):void 0;E&&(p(E),x&&c({token:x,meta:{blockchains:d,tokens:h}})),W&&(u(W),D&&m({token:D,meta:{blockchains:d,tokens:h}}))}},[f]),Ua(()=>{let{clientUrl:b,liquiditySources:E}=I();S("clientUrl",b||void 0),k("liquiditySources",E?.split(",")??void 0)},[])}i(Qa,"useSyncUrlAndStore");import{i18n as At}from"@lingui/core";import{Alert as fk,Button as Qu,darkTheme as gk,Divider as Tn,DoneIcon as hk,MessageBox as yk,styled as Sk,TextField as Ck,Typography as kk}from"@rango-dev/ui";import ye,{useEffect as Tk,useState as Gr}from"react";import{useNavigate as vk,useSearchParams as wk}from"react-router-dom";import{ChevronRightIcon as tC,Divider as du,Image as oC,Typography as fu}from"@rango-dev/ui";import ht from"react";import{darkTheme as pu,styled as qa}from"@rango-dev/ui";var cu=qa("div",{display:"flex",justifyContent:"space-between",width:"100%",height:"$40",padding:"$4 $10",borderRadius:"$sm",cursor:"pointer",alignItems:"center",backgroundColor:"$neutral300",[`.${pu} &`]:{backgroundColor:"$neutral400"},"&:hover":{backgroundColor:"$secondary100",[`.${pu} &`]:{backgroundColor:"$neutral500"}},variants:{disabled:{true:{cursor:"default","&:hover":{borderColor:"$neutral300","& svg":{color:"$neutral700"}}}}}}),uu=qa("div",{display:"flex",flexDirection:"column",width:"100%",".title_typography":{textTransform:"capitalize"}}),mu=qa("div",{display:"flex"});function Ha(t){let{onClick:e,value:o,title:n,hasLogo:r,placeholder:a,disabled:s}=t;return ht.createElement(uu,null,ht.createElement(fu,{size:"large",variant:"label"},n),ht.createElement(du,{size:10}),ht.createElement(cu,{onClick:s?void 0:e,disabled:s},ht.createElement(mu,null,r&&ht.createElement(ht.Fragment,null,ht.createElement(oC,{src:o?.logo,size:16,useAsPlaceholder:!o?.logo,type:"circular"}),ht.createElement(du,{size:4,direction:"horizontal"})),ht.createElement(fu,{className:"title_typography",size:"medium",variant:"label"},o?.name||a)),ht.createElement(tC,{size:12,color:"black"})))}i(Ha,"BlockchainSelectorButton");import{i18n as Va}from"@lingui/core";import{Button as nC,Divider as Cn,ExternalLinkIcon as rC,Image as iC,Typography as qo}from"@rango-dev/ui";import Ae from"react";function gu(t,e){if(e.type==="COSMOS")return"";let o=e.info?.addressUrl;return!o||!t?"":o.replace("{wallet}",t)}i(gu,"generateExplorerLink");import{darkTheme as Qo,styled as hu}from"@rango-dev/ui";var Ga=hu("a",{textDecoration:"none",color:"$colors$neutral700",[`.${Qo} &`]:{color:"$colors$neutral900"},"& svg":{marginLeft:"$4",color:"$colors$neutral700",[`.${Qo} &`]:{color:"$colors$neutral900"}},variants:{hasHover:{true:{"&:hover":{color:"$colors$secondary550",[`.${Qo} &`]:{color:"$colors$secondary500"},"& svg":{color:"$colors$secondary550",[`.${Qo} &`]:{color:"$colors$secondary500"}}}},false:{}}}}),yu=hu("div",{display:"flex",justifyContent:"center",flexDirection:"column",alignItems:"center",textAlign:"center","& ._blockchain-name, & ._coin-source":{color:"$colors$neutral600",[`.${Qo} &`]:{color:"$colors$neutral800"}},"& ._coin-source-name, & ._custom-token-description":{color:"$colors$neutral700",[`.${Qo} &`]:{color:"$colors$neutral900"}}});function Ka(t){let{open:e,onClose:o,token:n,onSubmitClick:r,blockchain:a}=t,s=gu(n.address,a);return Ae.createElement(ee,{open:e,dismissible:!0,onClose:o,container:N()},Ae.createElement(yu,null,Ae.createElement(iC,{src:n.image,size:45,type:"circular"}),Ae.createElement(qo,{variant:"title",size:"medium"},n.name),Ae.createElement(qo,{variant:"body",size:"small",className:"_blockchain-name"},a.displayName),Ae.createElement(Cn,{size:4}),Ae.createElement(qo,{variant:"body",size:"medium"},s?Ae.createElement(Ga,{hasHover:!0,href:s,target:"_blank",rel:"nofollow noreferrer"},n.address,Ae.createElement(rC,{size:12,color:"gray"})):Ae.createElement(Ga,null,n.address)),Ae.createElement(Cn,{size:4}),n.coinSource&&Ae.createElement(qo,{className:"_coin-source",variant:"body",size:"xsmall"},Va.t("via")," ",Ae.createElement(qo,{className:"_coin-source-name",variant:"body",size:"xsmall"},n.coinSource)),Ae.createElement(Cn,{size:"32"}),Ae.createElement(qo,{size:"medium",variant:"body",className:"_custom-token-description"},Va.t("This token doesn't appear on the active token list(s). Make sure this is the token that you want to trade."))),Ae.createElement(Cn,{size:40}),Ae.createElement(Cn,{size:10}),Ae.createElement(nC,{id:"widget-custom-token-modal-import-btn",variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:r},Va.t("Import")))}i(Ka,"CustomTokenModal");import{useManager as lk}from"@rango-dev/queue-manager-react";import{BottomLogo as pk,Divider as $u,Header as ck}from"@rango-dev/ui";import We,{useEffect as gs,useRef as Fu,useState as uk}from"react";import{useRef as aC}from"react";function Or(){return window.self!==window.top}i(Or,"isAppLoadedIntoIframe");function ja(){let t=aC(null),{iframe:e}=y(),o=Or()&&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(ja,"useIframe");import{useNavigate as sC}from"react-router-dom";function Ze(){let t=sC();return()=>t(-1)}i(Ze,"useNavigateBack");import{createTheme as ts,darkTheme as TC,lightTheme as vC}from"@rango-dev/ui";import{useEffect as wC,useState as bC}from"react";import{theme as CC,darkColors as kC}from"@rango-dev/ui";import Ra from"react";function lC(t){return t.startsWith("#")&&(t=t.slice(1)),t.length===3?`#${t.split("").reduce(function(n,r){return n+r+r},"")}`:`#${t}`}i(lC,"expandShortHexColor");function pC(t){return/[0-9]+$/.test(t)}i(pC,"isOverridingColor");function cC(t,e){return t.padStart(e,"0")}i(cC,"pad");function Xa(t){let e=Math.min(Math.max(Math.round(t),0),255);return cC(e.toString(16),2)}i(Xa,"intToHex");function uC(t){return`#${Xa(t.red)}${Xa(t.green)}${Xa(t.blue)}`}i(uC,"rgbToHex");function mC(t){let e=parseInt(t.slice(1,3),16),o=parseInt(t.slice(3,5),16),n=parseInt(t.slice(5,7),16);return{red:e,green:o,blue:n}}i(mC,"hexToRGB");function dC(t,e){let o=1-.11*e;return{red:t.red*o,green:t.green*o,blue:t.blue*o}}i(dC,"generateShade");function fC(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(fC,"generateTint");function gC(t){return Su(t,dC)}i(gC,"calculateShades");function hC(t){return Su(t,fC)}i(hC,"calculateTints");function Su(t,e){let o=mC(t),n=[];for(let r=1;r<9;r++)n.push(uC(e(o,r)));return n}i(Su,"calculateColors");function Ya(t,e,o){let a=hC(t).reverse().concat(t),s=gC(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(Ya,"createTintsAndShades");function Za(t,e,o){let n={...t};for(let r in e){let a=e[r],s=r==="neutral"&&!!o?.reverseNeutralRange;if(!["background","foreground"].includes(r)&&!pC(r)){let p=lC(a);Object.assign(n,Ya(p,r,s))}}return{...n,...e}}i(Za,"expandToGenerateThemeColors");var Cu=i(t=>String.fromCharCode(t+(t>25?39:97)),"toAlphabeticChar"),yC=i(t=>{let e="",o;for(o=Math.abs(t);o>52;o=o/52|0)e=Cu(o%52)+e;return Cu(o%52)+e},"toAlphabeticName"),SC=i((t,e)=>{let o=e.length;for(;o;)t=t*33^e.charCodeAt(--o);return t},"toPhash"),Ja=i(t=>yC(SC(5381,JSON.stringify(t))>>>0),"toHash");function es(t){let e=CC.colors,o={...e,...kC},n,r;if(t?.light){let s={colors:Za(e,t.light)};n={id:`${da}-light-${Ja(s)}`,tokens:s}}if(t?.dark){let s={colors:Za(o,t.dark,{reverseNeutralRange:!0})};r={id:`${da}-dark-${Ja(s)}`,tokens:s}}return{light:n,dark:r}}i(es,"customizedThemeTokens");function ku(t,e){if(t.length<=1)return t.map(({element:n,key:r})=>Ra.cloneElement(n,{key:r}));let o=[];return t.forEach((n,r)=>{let{element:a,key:s}=n;if(o.push(Ra.cloneElement(a,{key:s})),r<t.length-1){let l=`divider-${r}`;o.push(Ra.cloneElement(e,{key:l}))}}),o}i(ku,"joinList");function Tu(){return window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches}i(Tu,"doesWindowPreferDarkColorScheme");function Ho(t){let{colors:e,fontFamily:o=kp,borderRadius:n=Gp,secondaryBorderRadius:r=Vp}=t,[a,s]=bC(Tu()?"dark":"light"),{theme:l}=y(),{dark:p,light:u}=es(e),c=ts({shadows:t.shadows||{},radii:{primary:`${n}px`,secondary:`${r}px`},fonts:{widget:o}}),m=[c.className,vC.className],g=[c.className,TC.className];if(u){let d=ts(u.id,u.tokens);m.push(d.className)}if(p){let d=ts(p.id,p.tokens);g.push(d.className)}return wC(()=>{let d=i(h=>{h.matches?s("dark"):s("light")},"switchThemeListener");return Tu()&&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=g.join(" ");return l==="auto"?a==="dark"?h:d:l==="dark"?h:d},"getActiveTheme"),mode:l==="auto"?a:l}}i(Ho,"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 vu}from"@lingui/core";import{Alert as xC,Button as EC}from"@rango-dev/ui";import wu from"react";function os(t){return wu.createElement(xC,{action:wu.createElement(EC,{id:"widget-active-tab-btn",onClick:t.onActivateTab,variant:"contained",size:"xxsmall",type:"warning"},vu.t("Activate this tab")),type:"warning",variant:"alarm",title:vu.t("Another tab is open and handles transactions.")})}i(os,"ActivateTabAlert");import{i18n as ns}from"@lingui/core";import{Button as IC,Divider as AC,MessageBox as NC}from"@rango-dev/ui";import Ur from"react";function rs(t){let{open:e,onClose:o,onConfirm:n}=t;return Ur.createElement(ee,{open:e,dismissible:!0,onClose:o,container:N()},Ur.createElement(NC,{title:ns.t("Activate current tab"),type:"warning",description:ns.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.")},Ur.createElement(AC,{size:20}),Ur.createElement(IC,{id:"widget-modal-confirm-activate-tab-btn",variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:n},ns.t("Confirm"))))}i(rs,"ActivateTabModal");import{ChevronLeftIcon as WC}from"@rango-dev/ui";import bu from"react";function is(t){return bu.createElement(It,{id:"widget-header-back-icon-btn",variant:"ghost",size:"small",onClick:t.onClick},bu.createElement(WC,{color:"black",size:16}))}i(is,"BackButton");import{i18n as MC}from"@lingui/core";import{Button as LC,Typography as BC}from"@rango-dev/ui";import as from"react";function ss(t){return as.createElement(Kt,null,as.createElement(LC,{id:"widget-header-cancel-btn",variant:"ghost",onClick:t.onClick,size:"xsmall"},as.createElement(BC,{variant:"label",size:"medium",color:"error500"},MC.t("Cancel"))))}i(ss,"CancelButton");import{i18n as PC}from"@lingui/core";import{Image as DC,Tooltip as _C,WalletIcon as $C}from"@rango-dev/ui";import ho from"react";function ls(t){let{list:e}=ft(),o=e.filter(r=>r.state==="connected"),n=o.length?ho.createElement("div",{className:yc()},o.map(r=>ho.createElement(vr,{key:r.title},ho.createElement(DC,{src:r.image,size:14})))):PC.t("Connect Wallet");return ho.createElement(_C,{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(dc,null),ho.createElement($C,{size:18,color:"black"})))}i(ls,"WalletButton");import{i18n as Qr}from"@lingui/core";import{NotificationsIcon as RC,Popover as ek,SettingsIcon as tk,Tooltip as qr,TransactionIcon as ok}from"@rango-dev/ui";import Ne from"react";import{Notifications as zC}from"@rango-dev/ui";import QC from"react";import{useNavigate as qC}from"react-router-dom";import{create as FC}from"zustand";import{persist as OC,subscribeWithSelector as UC}from"zustand/middleware";var ve=Vt(FC()(OC(UC((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 ps(){let t=qC(),{getNotifications:e,clearNotifications:o}=ve(),n=e(),r=y().blockchains(),{findToken:a}=y();return QC.createElement(zC,{list:n,getBlockchainImage:l=>dp(l,r)??"",getTokenImage:l=>a(l)?.image??"",onClickItem:i(l=>{t(`${_.swaps}/${l}`)},"onClickItem"),onClearAll:o})}i(ps,"NotificationContent");import{useManager as HC}from"@rango-dev/queue-manager-react";import{InProgressIcon as GC}from"@rango-dev/ui";import xu from"react";var VC=i(()=>{let{manager:t}=HC();return ut(t).map(({swap:o})=>o).find(o=>o.status==="running")?xu.createElement(hc,null,xu.createElement(GC,{color:"info",size:6})):null},"InProgressTransactionBadge"),Eu=VC;import{EventSeverity as KC}from"@rango-dev/queue-manager-rango-preset";import{Typography as jC}from"@rango-dev/ui";import Iu from"react";function Au(){let{getNotifications:t}=ve(),e=t(),o=e.length,n=!!e.find(r=>r.event.messageSeverity===KC.WARNING);return o?Iu.createElement(fc,{isSever:n},Iu.createElement(jC,{variant:"body",size:"xsmall",color:"$background"},o)):null}i(Au,"NotificationsBadge");import{RefreshProgressButton as XC}from"@rango-dev/ui";import cs,{useEffect as YC,useState as Nu}from"react";var ZC=1e3,Wu=60,JC=100;function zr({onClick:t}){let[e,o]=Nu(0),[n,r]=Nu(!1),a=i(p=>{document.hidden&&p&&s(p)},"handleVisibilityChange");YC(()=>{let p;return t?p=window.setInterval(()=>{o(u=>u+1),e===Wu&&l()},ZC):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 cs.createElement(It,{id:"widget-header-refresh-icon-btn",variant:"ghost",size:"small",style:{paddingTop:0,paddingBottom:0},onClick:l,disabled:!t},cs.createElement(gc,{onTransitionEnd:()=>r(!1),isRefetched:n},cs.createElement(XC,{size:22,color:t?"black":"gray",progress:e/Wu*JC})))}i(zr,"RefreshButton");function yo(t){let{onClickRefresh:e,onClickHistory:o,onClickSettings:n,hidden:r=[],container:a}=t,{config:{features:s}}=y(),l=Xe("notification",s)||r.includes("notifications");return Ne.createElement(Ne.Fragment,null,!r.includes("refresh")&&Ne.createElement(qr,{container:a||N(),side:"top",content:Qr.t("Refresh")},Ne.createElement(zr,{onClick:e})),!l&&Ne.createElement(ek,{align:"end",alignOffset:-88,sideOffset:15,collisionPadding:{right:20,left:20},container:N(),content:Ne.createElement(ps,null)},Ne.createElement("div",null,Ne.createElement(qr,{container:N(),side:"top",content:Qr.t("Notifications")},Ne.createElement(It,{id:"widget-header-notification-icon-btn",size:"small",variant:"ghost"},Ne.createElement(RC,{size:18,color:"black"}),Ne.createElement(Au,null))))),!r.includes("settings")&&Ne.createElement(qr,{container:N(),side:"top",content:Qr.t("Settings")},Ne.createElement(It,{id:"widget-header-setting-icon-btn",size:"small",variant:"ghost",onClick:n},Ne.createElement(tk,{size:18,color:"black"}))),!r.includes("history")&&Ne.createElement(qr,{container:N(),side:"top",content:Qr.t("History")},Ne.createElement(It,{id:"widget-header-history-icon-btn",size:"small",variant:"ghost",onClick:o},Ne.createElement(ok,{size:18,color:"black"}),Ne.createElement(Eu,null))))}i(yo,"HeaderButtons");import{i18n as us}from"@lingui/core";import{Divider as Lu,MessageBox as ik,RefreshIcon as ak}from"@rango-dev/ui";import Go from"react";import{Button as nk,styled as rk}from"@rango-dev/ui";var Mu=rk(nk,{"& span":{display:"flex",justifyContent:"center",alignItems:"center"}});function ms(t){let{open:e,onClose:o}=t;return Go.createElement(ee,{open:e,dismissible:!0,onClose:o,container:N()},Go.createElement(ik,{title:us.t("Something went wrong"),type:"error",description:us.t("Something went wrong. Please refresh the app.")},Go.createElement(Lu,{size:30}),Go.createElement(Mu,{variant:"outlined",size:"large",type:"primary",fullWidth:!0,onClick:()=>location.reload()},Go.createElement(ak,{size:20,color:"primary"}),Go.createElement(Lu,{size:4,direction:"horizontal"}),us.t("Refresh"))))}i(ms,"RefreshModal");function ds(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(ds,"onScrollContentAttachStatusToContainer");import{css as sk,styled as fs}from"@rango-dev/ui";var Bu="700px",Hr=sk({borderRadius:"$primary",display:"flex",flexDirection:"column",overflow:"hidden",boxShadow:"$mainContainer"}),Pu=fs("div",{position:"relative",width:"100vw",minWidth:"300px",maxWidth:"390px",backgroundColor:"$background",variants:{height:{auto:{height:"auto",maxHeight:Bu},fixed:{height:Bu}}}}),Du=fs("div",{position:"relative",overflow:"hidden",flexGrow:1,display:"flex",flexDirection:"column",padding:0,overflowY:"auto"}),_u=fs("div",{padding:"0 $20 $10","& .footer__alert":{paddingTop:"$10"},"& .footer__logo":{opacity:0,transition:"opacity 1s ease-in-out","&.logo__show":{opacity:1},"&.logo__hidden":{visibility:"hidden"}}});function oe(t){let{connectHeightObserver:e,disconnectHeightObserver:o}=ja(),{children:n,header:r,footer:a,height:s="fixed"}=t,{fetchStatus:l}=y(),[p,u]=uk(!1),c=R.use.connectedWallets(),{config:{features:m,theme:g}}=y(),{watermark:f}=se(),d=f==="FULL",{activeTheme:h}=Ho(g||{}),C=Xe("connectWalletButton",m),{isActiveTab:S,tabManagerInitiated:k,showActivateTabModal:T,setShowActivateTabModal:v,activateCurrentTab:w}=se(),I=Ze(),{manager:M}=lk(),E=ut(M).map(({swap:ae})=>ae).some(ae=>ae.status==="running"),x=i(()=>w(lo.forceClaim,E),"onActivateTab"),W=i(()=>{r.onWallet?.()},"onConnectWallet"),D=typeof r.hasBackButton>"u"||r.hasBackButton,A=Fu(null),Z=Fu(null);return gs(()=>(Or()&&Z.current&&e(Z.current),()=>{o()}),[]),gs(()=>(A.current?.addEventListener("scroll",ds),()=>{A.current?.removeEventListener("scroll",ds)}),[]),gs(()=>{u(l==="failed")},[l]),We.createElement(Pu,{height:s,id:_e.SWAP_BOX_ID,className:`${h()} ${Hr()}`,ref:Z},We.createElement(ck,{prefix:D?We.createElement(is,{onClick:()=>{I(),r.onBack&&r.onBack()}}):null,title:r.title,suffix:We.createElement(We.Fragment,null,r.suffix,r.onWallet&&!C&&We.createElement(ls,{container:N(),onClick:W,isConnected:!!c?.length}),r.onCancel&&We.createElement(ss,{onClick:r.onCancel}))}),We.createElement(Du,{ref:A},n),We.createElement(rs,{open:T,onClose:()=>v(!1),onConfirm:x}),We.createElement(_u,null,We.createElement("div",{className:"footer__content"},k&&!S&&We.createElement("div",{className:"footer__alert"},We.createElement(os,{onActivateTab:x}),We.createElement($u,{size:10})),a),We.createElement($u,{size:12}),We.createElement("div",{className:`footer__logo ${d?"logo__show":"logo__hidden"}`},We.createElement(pk,null))),We.createElement(ms,{open:p,onClose:()=>u(!1)}))}i(oe,"Layout");import{styled as mk}from"@rango-dev/ui";var Ou="$20 $20 $10 $20",kn=mk("div",{padding:Ou,overflowY:"auto",flexGrow:1});import{styled as dk}from"@rango-dev/ui";var re=dk("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 Vo}from"@lingui/core";import{useState as Uu}from"react";function zu(){let[t,e]=Uu(!1),[o,n]=Uu(void 0),{findToken:r}=y(),a=y().customTokens();function s(p,u){switch(p){case"duplicated":return{title:Vo.t("Duplicate Token"),message:Vo.t("The address you entered is duplicate, please enter a new address.")};case"token-exist":return{title:Vo.t("Token Already Exists"),message:Vo.t("There's no need to add this token again because it already exists and is supported by us.")};case"not-found":return{title:Vo.t("Token Not Found"),message:Vo.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 g=m.token;if(r({blockchain:g.blockchain,address:g.address,symbol:g.symbol})){let d=s("token-exist");n(d);return}return g}catch(c){throw n(void 0),new Error(c.message)}finally{e(!1)}},"fetchCustomToken"),loading:t,error:o}}i(zu,"useFetchCustomToken");var bk=Sk("div",{display:"flex",justifyContent:"space-between",flexDirection:"column",flex:1,"& ._text-field":{padding:"$4 $10",backgroundColor:"$neutral300",[`.${gk} &`]:{backgroundColor:"$neutral400"},borderRadius:"$sm",height:"$40"}}),xk=1e3;function qu(){let t=vk(),[e]=wk(),o=Ze(),{setCustomToken:n}=y(),r=y().blockchains(),a=e.get("blockchain")||"",s=an(a,r),[l,p]=Gr(""),[u,c]=Gr(!1),[m,g]=Gr(),{fetchCustomToken:f,loading:d,error:h}=zu(),[C,S]=Gr(""),k=!!s&&Wo(s,l),T=!s||!l||!k,v=i(async()=>{if(s)try{let M=await f({blockchain:a,tokenAddress:l});S(""),M&&g(M)}catch(M){M.message==="Failed to fetch"&&(S(At.t("Network Error")),c(!0))}},"getCustomToken"),w=i(()=>{h&&p(""),c(!1)},"closeErrorModal"),I=i(async()=>{C&&setTimeout(async()=>{await v()},xk),w()},"handleErrorModalButtonClick");return Tk(()=>{h&&c(!0)},[h]),ye.createElement(oe,{header:{title:At.t("Add Custom Token")}},ye.createElement(re,null,ye.createElement(bk,null,ye.createElement("div",null,ye.createElement(Ha,{onClick:()=>t(_.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")}),ye.createElement(Tn,{size:"24"}),ye.createElement(kk,{size:"large",variant:"label"},At.t("Enter Address")),ye.createElement(Tn,{size:10}),ye.createElement(Ck,{fullWidth:!0,disabled:!s,variant:"contained",placeholder:At.t("Enter token address"),size:"large",value:l,suffix:!!l&&k&&ye.createElement(hk,{color:"success",size:12}),onChange:M=>p(M.target.value)}),!k&&!!l&&ye.createElement(ye.Fragment,null,ye.createElement(Tn,{size:4}),ye.createElement(fk,{type:"error",variant:"alarm",title:"Invalid Address"}))),ye.createElement(Qu,{id:"widget-add-custom-token-import-btn",disabled:T,type:"primary",variant:"contained",loading:d,size:"large",onClick:v},At.t("Import"))),ye.createElement(ee,{open:u,dismissible:!0,onClose:w,container:N()},ye.createElement(yk,{title:h?.title||C,type:"error",description:h?.message||At.t("Failed Network, Please retry.")},ye.createElement(Tn,{size:40}),ye.createElement(Tn,{size:10}),ye.createElement(Qu,{id:`widget-add-custom-token-${C?"retry":"add-another"}-btn`,variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:I},C?At.t("Retry"):At.t("Add another custom token")))),s&&m&&ye.createElement(Ka,{blockchain:s,token:m,onSubmitClick:()=>{m&&(n(m),g(void 0),o())},onClose:()=>g(void 0),open:!!s&&!!m})))}i(qu,"AddCustomTokenPage");import{i18n as Hs}from"@lingui/core";import{useManager as lv}from"@rango-dev/queue-manager-react";import{Alert as Od,Button as pv,css as Vs,Divider as Gs,IconButton as Ud,styled as cv,Typography as uv,WalletIcon as mv}from"@rango-dev/ui";import xe,{useEffect as Ti,useLayoutEffect as dv,useRef as fv,useState as Pn}from"react";import{useNavigate as gv}from"react-router-dom";import{i18n as So}from"@lingui/core";import{Alert as ym,BalanceErrors as Zk,Button as Sm,ChevronLeftIcon as Jk,Divider as ei,MessageBox as Rk,Typography as ws}from"@rango-dev/ui";import X,{useCallback as eT,useEffect as Cm,useMemo as tT,useState as Co}from"react";import{useNavigate as oT}from"react-router-dom";import{i18n as Vr}from"@lingui/core";function Kr(t){switch(t.type){case 0:return Vr.t("Route has been updated.");case 3:return Vr.t("Output amount changed to {newOutputAmount} ({percentageChange}% change).",{newOutputAmount:t.newOutputAmount,percentageChange:t.percentageChange});case 1:return Vr.t("Route swappers has been updated.");case 2:return Vr.t("Route internal coins has been updated.");default:return""}}i(Kr,"getQuoteUpdateWarningMessage");import{i18n as Cs}from"@lingui/core";import{Alert as Mk,ChevronDownIcon as Lk,CloseIcon as Bk,Divider as Yu,IconButton as Zu,PasteIcon as Pk,Typography as Dk,WalletIcon as _k}from"@rango-dev/ui";import Me,{useEffect as $k,useRef as Fk}from"react";import Zr,{useRef as Nk}from"react";import*as Ko from"@radix-ui/react-collapsible";import{keyframes as Hu,styled as jr}from"@rango-dev/ui";var hs=300,Ik=Hu({from:{height:0},to:{height:"var(--radix-collapsible-content-height)"}}),Ak=Hu({from:{height:"var(--radix-collapsible-content-height)"},to:{height:0}}),Gu=jr(Ko.Root,{borderRadius:"$sm",overflow:"hidden",variants:{selected:{true:{outlineWidth:1,outlineColor:"$secondary500",outlineStyle:"solid"}}}}),ys=jr(Ko.Trigger,{padding:"$0",border:"none",outline:"none",width:"100%",backgroundColor:"transparent",fontFamily:"inherit",cursor:"pointer"}),Xr=jr(Ko.Content,{overflow:"hidden",variants:{open:{true:{animation:`${Ik} ${hs}ms ease-out`},false:{animation:`${Ak} ${hs}ms ease-out`}}}}),Yr=jr("div",{transition:`all ${hs}ms ease`,display:"flex",alignItems:"center",variants:{orientation:{down:{transform:"rotate(0)"},up:{transform:"rotate(180deg)"}}}});function Jr(t){let{open:e,hasSelected:o,onOpenChange:n,children:r,onClickTrigger:a,trigger:s,triggerAnchor:l}=t,p=Nk(null);return Zr.createElement(Gu,{ref:p,className:"collapsible_root",selected:o&&e,open:e,onOpenChange:n},l==="top"&&Zr.createElement(ys,{className:"collapsible_trigger",onClick:a},s),Zr.createElement(Xr,{className:"collapsible_content",open:e},r),l==="bottom"&&Zr.createElement(ys,{className:"collapsible_trigger",onClick:a},s))}i(Jr,"CustomCollapsible");import{darkTheme as Vu,styled as Ss,TextField as Wk}from"@rango-dev/ui";var Ku=Ss("div",{padding:"$10 $0","& .button__content":{display:"flex",alignItems:"center"},"& .alarms":{paddingTop:"$5"},"& .collapsible_content":{backgroundColor:"$neutral100"},"& .collapsible_root":{backgroundColor:"$neutral100"}}),ju=Ss(Wk,{backgroundColor:"$neutral100",padding:"$15"}),Xu=Ss("div",{width:"100%",borderRadius:"$sm",display:"flex",padding:"$15",justifyContent:"space-between",alignItems:"center",$$color:"$colors$neutral100",[`.${Vu} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",borderBottomRightRadius:"0",borderBottomLeftRadius:"0","&:focus-visible":{$$background:"$colors$secondary100",[`.${Vu} &`]:{$$background:"$colors$info700"},backgroundColor:"$$background",outline:0}});function Ju(t){let{blockchain:e,handleOpenChange:o,open:n}=t,{customDestination:r,setCustomDestination:a}=F(),{config:s}=y(),l=y().blockchains(),p=nr(e.name,l),u=Fk(null),c=s?.defaultCustomDestinations?.[e.name],m=navigator?.userAgent.includes("Firefox"),f=n&&!!r&&e&&!Wo(e,r),d=i(()=>{a("")},"handleClear"),h=i(async S=>{if(S.preventDefault(),navigator.clipboard!==void 0){let k=await navigator.clipboard.readText();a(k),u?.current?.focus()}},"handlePaste"),C=i(()=>r?Me.createElement(Zu,{id:"widget-custom-destination-close-icon-btn",onClick:d,variant:"ghost"},Me.createElement(Bk,{size:12,color:"gray"})):m?null:Me.createElement(Zu,{id:"widget-custom-destination-paste-icon-btn",onClick:h,variant:"ghost"},Me.createElement(Pk,{size:16})),"renderSuffix");return $k(()=>{!!c&&r===null&&(a(c),o(!0))},[c]),Me.createElement(Ku,null,Me.createElement(Jr,{onOpenChange:o,hasSelected:!0,open:n,triggerAnchor:"top",trigger:Me.createElement(Xu,null,Me.createElement("div",{className:"button__content"},Me.createElement(_k,{size:18,color:"info"}),Me.createElement(Yu,{size:4,direction:"horizontal"}),Me.createElement(Dk,{variant:"label",size:"medium",color:n?"$neutral600":void 0},Cs.t("Send to a different address"))),Me.createElement(Yr,{orientation:n?"up":"down"},Me.createElement(Lk,{size:10,color:"secondary"}))),onClickTrigger:()=>o(!n)},Me.createElement(ju,{ref:u,style:{padding:0,paddingRight:r?"8px":"5px"},autoFocus:!r,placeholder:Cs.t("Enter {blockchainName} address",{blockchainName:p}),value:r||"",suffix:C(),onChange:S=>{let k=S.target.value;a(k)}})),f&&Me.createElement(Me.Fragment,null,Me.createElement(Yu,{size:4}),Me.createElement(Mk,{variant:"alarm",type:"error",title:Cs.t({values:{destination:r},id:"Address {destination} doesn't match the blockchain address pattern."})})))}i(Ju,"CustomDestination");import{css as Ok,darkTheme as ks,IconButton as Uk,styled as _t}from"@rango-dev/ui";var Ru=_t("div",{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center"}),em=_t("div",{display:"flex",justifyContent:"space-evenly",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5",height:"100%"}),zk=_t("button",{borderRadius:"$xm",padding:"$10",border:"0",display:"flex",justifyContent:"center",$$color:"$colors$neutral100",[`.${ks} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",alignItems:"center",cursor:"pointer",width:110,position:"relative","&:hover":{$$color:"$colors$secondary100",[`.${ks} &`]:{$$color:"$colors$neutral100"},backgroundColor:"$$color"},"&:focus-visible":{$$color:"$colors$secondary100",[`.${ks} &`]:{$$color:"$colors$info700"},backgroundColor:"$$color",outline:0},variants:{selected:{true:{outlineWidth:1,outlineColor:"$secondary",outlineStyle:"solid"}}}}),tm=_t(zk,{alignSelf:"stretch",minHeight:"93px"}),om=_t("div",{padding:"$20 $20 $15 $20",display:"flex",justifyContent:"center",alignItems:"center",backgroundColor:"$neutral200",position:"relative",width:"100%"}),nm=_t(Uk,{position:"absolute",left:"$20"}),rm=_t("div",{paddingTop:"$20"}),im=Ok({display:"flex",justifyContent:"space-evenly",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5",height:"100%"}),am=_t("div",{display:"flex"}),sm=_t("div",{overflow:"visible",width:"100%"});import{i18n as dm}from"@lingui/core";import{warn as Vk}from"@rango-dev/logging-core";import{Divider as Kk,SelectableWallet as jk,Typography as fm,WalletState as gm}from"@rango-dev/ui";import Je,{useEffect as hm,useState as wn}from"react";import{Image as Hk,MessageBox as Gk}from"@rango-dev/ui";import vn from"react";import{keyframes as Qk,styled as Ts}from"@rango-dev/ui";var lm=Ts("div",{position:"relative"}),qk=Qk({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}),pm=Ts("div",{position:"absolute",border:"2px solid rgba(0, 0, 0, 0.1)",borderTop:"2px solid $info500",borderRadius:"$lg",width:"$45",height:"$45",animation:`${qk} 1s linear infinite`,top:0,bottom:0,right:0,left:0}),cm=Ts("div",{"& img":{borderRadius:"50%"}});import{i18n as jo}from"@lingui/core";function um(t,e){switch(t){case"in-progress":return{type:"loading",title:jo.t({id:"Add {blockchainDisplayName} Chain",values:{blockchainDisplayName:e}}),description:jo.t({id:"Please approve the experimental chain pop-up in your wallet.",values:{blockchainDisplayName:e}})};case"completed":return{type:"success",title:jo.t({id:"{blockchainDisplayName} Chain Added",values:{blockchainDisplayName:e}}),description:jo.t({id:"The {blockchainDisplayName} chain has been successfully added to your wallet.",values:{blockchainDisplayName:e}})};case"rejected":return{type:"error",title:jo.t("Request Rejected"),description:jo.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(um,"generateMessageByStatus");function mm(t){let{status:e,displayName:o,image:n}=t,r=um(e,o),a=e=="in-progress";return vn.createElement(Gk,{type:r.type,title:r.title,description:r.description,icon:a?vn.createElement(lm,null,vn.createElement(cm,null,vn.createElement(Hk,{src:n,size:45})),vn.createElement(pm,null)):void 0})}i(mm,"ExperimentalChainStatus");var Xk=7,Yk=3e3;function vs(t){let{chain:e,isSelected:o,selectWallet:n,limit:r,onShowMore:a}=t,s=se.use.isActiveTab(),l=R.use.connectedWallets(),{blockchains:p}=y(),[u,c]=wn(),[m,g]=wn(null),[f,d]=wn(!1),[h,C]=wn(null),{suggestAndConnect:S}=Rr(),{handleDisconnect:k}=Gt(),{list:T}=ft({chain:e}),[v,w]=wn(T),I=T.length,M=r&&I-r>0,b=i(async x=>{d(!1),C("in-progress");try{await S(x.walletType,x.chain),C("completed")}catch{C("rejected")}},"addExperimentalChain");hm(()=>{w(x=>{let W=T.findIndex(D=>o(D.type,e));return M&&W>1?[T[W]].concat(T.filter((D,A)=>A!==W)):x.map(D=>T.find(A=>A.type===D.type)??D)})},[JSON.stringify(T)]);let E=document.getElementById(_e.SWAP_BOX_ID);return hm(()=>{let x=null;return(h==="completed"||h==="rejected")&&(x=setTimeout(()=>C(null),Yk)),()=>{x&&clearTimeout(x)}},[h]),Je.createElement(Je.Fragment,null,v.slice(0,r).map(x=>{let W=Op({connectedWallets:l,walletType:x.type,chain:e}),D=W?gr(W,Xk):"",A=dr(p(),e),Z=!l.find(me=>me.walletType===x.type&&me.chain===e),ae=A&&Z&&x.state===gm.CONNECTED,J=ae?dm.t({id:"Add {chain} chain",values:{chain:e}}):D,B=i(async()=>{x.state===gm.DISCONNECTED?c(x):x.namespaces&&!D?(await k(x.type),c(x)):ae?(g({walletType:x.type,chain:e,address:W??""}),d(!0)):n({walletType:x.type,chain:e,address:W??""})},"onSelectableWalletClick"),K=m?.chain?nr(m.chain,p()):void 0;return Je.createElement(Je.Fragment,{key:`${x.title}_${K}`},!!m&&Je.createElement(ee,{open:!!m&&f,container:E,onClose:()=>{g(null)}},Je.createElement(Ia,{displayName:K,onConfirm:()=>{b(m)}})),h&&Je.createElement(ee,{open:!!h,onClose:C.bind(null,null),container:E},Je.createElement(mm,{status:h,displayName:K,image:x.image}),Je.createElement(Kk,{direction:"vertical",size:32})),Je.createElement(jk,{key:x.type,description:J,onClick:B,selected:o(x.type,e),disabled:!s,...x}))}),Je.createElement(mo,{wallet:u,onClose:()=>{c(void 0)},onConnect:x=>{t.onConnect&&x.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&&Je.createElement(tm,{selected:!1,onClick:a},Je.createElement(fm,{variant:"label",size:"medium"},dm.t("Show more wallets"),Je.createElement(fm,{variant:"label",size:"medium",color:"$primary"},"\xA0+",I-(r??0)))))}i(vs,"WalletList");var nT=2;function km(t){let{open:e,onClose:o,onCancel:n,onCheckBalance:r,loading:a}=t,s=oT(),l=y().blockchains(),{selectedQuote:p,setSelectedWallets:u,quoteWalletsConfirmed:c,setQuoteWalletConfirmed:m,customDestination:g,setCustomDestination:f}=F(),{connectedWallets:d,selectWallets:h}=R(),{config:C}=y(),[S,k]=Co(""),[T,v]=Co([]),[w,I]=Co(""),[M,b]=Co(null),[E,x]=Co(!!g),W=tT(()=>ao({filter:"all",quote:p}),[p]),D=ao({filter:"required",quote:p}),A=l.find($=>$.name===p?.swaps[p?.swaps.length-1].to.blockchain),Z=i($=>D.includes($),"isWalletRequiredFor"),ae=eT(()=>d.filter($=>$.selected&&W.includes($.chain)),[d,W]),[J,B]=Co(ae()),[K,me]=Co([]),V=i(($,Q)=>me(H=>H.concat({blockchain:$,walletType:Q})),"addNextSelectedWallets"),fe=T.length>0,ge=i(($,Q)=>!!J.find(H=>H.walletType===$&&H.chain===Q&&H.selected&&(Z(Q)||!Z(Q)&&!g)),"isSelected"),Pe=i(($,Q,H)=>{let ne=!1;return $.map(le=>{if(le.chain===Q){let pe=le.selected;return!ne&&H?(ne=!0,pe=!0):H||(pe=!1),{...le,selected:pe}}return le})},"updateSelectableWallets"),z=i($=>{x($),$?Z(A?.name??"")||B(Q=>Pe(Q,A?.name||"",!1)):(f(""),B(Q=>Pe(Q,A?.name||"",!0)))},"handleCustomDestinationCollapsibleOpenChange"),je=i($=>{if(S&&k(""),ge($.walletType,$.chain))return;let H=d.find(ne=>ne.walletType===$.walletType&&ne.chain===$.chain);H&&(n(),$.chain===A?.name&&E&&!Z(A.name)&&(x(!1),f(null)),B(ne=>ne.filter(le=>le.chain!==$.chain).concat({...H,selected:!0})))},"onChange"),vt=i(()=>{let $=J.filter(Q=>Q.selected);h($),u($),m(!0),o()},"onConfirmBalance"),lt=i(async()=>{v([]),I(""),b(null);let $=await r?.({selectedWallets:J.filter(H=>H.selected),customDestination:g}),Q=$.warnings;Q?.balance?.messages&&v(Q.balance.messages),Q?.quoteUpdate&&b(Q.quoteUpdate),$.error&&I(Dc($.error)),!$.error&&!Q?.balance?.messages.length?vt():v(Q?.balance?.messages??[])},"onConfirmWallets");Cm(()=>{B($=>{let Q=[];return $.forEach(H=>{!d.some(le=>le.chain===H.chain&&le.walletType===H.walletType&&le.address===H.address)||Q.push(H)}),Q=Q.concat(d.filter(H=>!!!Q.find(le=>le.chain===H.chain)&&H.selected&&W.includes(H.chain))),Q})},[d,W]),Cm(()=>{let $=[];K.length>0&&(K.forEach(Q=>{let H=d.find(ne=>ne.chain===Q.blockchain&&ne.walletType===Q.walletType);H?je(H):$.push(Q)}),me($))},[d,K]);let wt=document.getElementById(_e.SWAP_BOX_ID);return X.createElement(ee,{open:e,onClose:()=>{c||s("../",{replace:!0}),o()},dismissible:!S,container:wt,...!S&&{styles:{container:{height:"100%"}},footer:X.createElement(am,null,X.createElement(Sm,{id:"widget-confirm-wallet-modal-confirm-btn",loading:a,disabled:Rc(a,E,g,p,J,A),onClick:lt,variant:"contained",type:"primary",fullWidth:!0,size:"large"},So.t("Confirm")))},...S&&{styles:{container:{height:"100%",padding:"$0"}},header:X.createElement(om,null,X.createElement(nm,{id:"widget-confirm-wallet-modal-navigate-back-icon-btn",variant:"ghost",onClick:k.bind(null,"")},X.createElement(Jk,{size:16})),X.createElement(ws,{variant:"headline",size:"small"},So.t({id:"Your {blockchainName} wallets",values:{blockchainName:pt(S,l)}})))},anchor:"center"},X.createElement(ee,{open:fe,onClose:v.bind(null,[]),container:wt},X.createElement(Rk,{title:So.t("Insufficient account balance"),type:"error",description:X.createElement(Zk,{messages:T??[]})},X.createElement(Sm,{id:"widget-confirm-wallet-modal-proceed-anyway-btn",variant:"outlined",size:"large",type:"primary",fullWidth:!0,onClick:vt},So.t("Proceed anyway")))),S&&X.createElement(rm,null,X.createElement("div",{className:im()},X.createElement(vs,{chain:S,isSelected:ge,selectWallet:je,onShowMore:()=>k(S),onConnect:$=>{V(S,$)}}))),!S&&X.createElement(X.Fragment,null,w&&X.createElement(X.Fragment,null,X.createElement(ym,{variant:"alarm",type:"error",title:So.t(w)}),X.createElement(ei,{size:12})),M&&X.createElement(X.Fragment,null,X.createElement(ym,{variant:"alarm",type:"warning",title:Kr(M)}),X.createElement(ei,{size:12})),X.createElement(sm,null,W.map(($,Q)=>{let H=l.find(Oe=>Oe.name===$),ne=`wallet-${Q}`,le=Q===W.length-1,pe=le&&A&&C?.customDestination!==!1;return X.createElement("div",{key:ne},X.createElement(Ru,null,X.createElement(ws,{variant:"title",size:"xmedium"},So.t({id:"Your {blockchainName} wallets",values:{blockchainName:H?.shortName}})),X.createElement(ws,{variant:"label",color:"$neutral700",size:"medium"},So.t({id:"You need to connect a {blockchainName} wallet.",values:{blockchainName:H?.shortName}}))),X.createElement(ei,{size:24}),X.createElement(em,null,X.createElement(vs,{chain:$,isSelected:ge,selectWallet:je,limit:nT,onShowMore:()=>k(H?.name??""),onConnect:Oe=>{V($,Oe)}})),!le&&X.createElement(ei,{size:32}),pe&&X.createElement(Ju,{blockchain:A,open:E,handleOpenChange:z}))}))))}i(km,"ConfirmWalletsModal");import{i18n as vT}from"@lingui/core";import{Alert as wT,Button as bT,InfoIcon as xT}from"@rango-dev/ui";import ot from"react";import{Alert as aT,Button as sT,Divider as Es,NoRouteIcon as lT,RefreshIcon as pT,Typography as Im}from"@rango-dev/ui";import tt from"react";import{i18n as Tm}from"@lingui/core";var rT=24,iT=60;function vm(t,e,o,n){return t?.type===1?{alert:{type:"warning",text:te().genericServerError,action:{onClick:n,title:Tm.t("Retry")}},description:""}:e.length?{alert:{type:"warning",text:te().liquiditySourcesError.title,action:{onClick:()=>o(!0),title:Tm.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(vm,"makeInfo");var bs=(o=>(o[o.small=rT]="small",o[o.large=iT]="large",o))(bs||{}),xs=(o=>(o.small="small",o.large="medium",o))(xs||{});import{styled as ti}from"@rango-dev/ui";var wm=ti("div",{display:"flex",flexDirection:"column",alignItems:"center"}),bm=ti("div",{variants:{size:{small:{},large:{maxWidth:"316px"}}}}),xm=ti("div",{variants:{size:{small:{width:"100%"},large:{}}}}),Em=ti("div",{padding:"$6 $0"});function bn(t){let{fetch:e,error:o,size:n="small"}=t,r=y().getDisabledLiquiditySources(),a=y().toggleAllLiquiditySources,s=y().swappers(),l=vm(o,r,()=>a(s,!0),e);return tt.createElement(wm,null,tt.createElement(lT,{size:bs[n],color:"gray"}),tt.createElement(Es,{size:4}),tt.createElement(Im,{variant:"title",size:xs[n]},te().noResultError.title),n==="large"&&tt.createElement(Es,{size:4}),!!l.description&&tt.createElement(bm,{size:n},tt.createElement(Im,{variant:"body",size:"small",align:"center",color:"neutral700"},l.description)),tt.createElement(Es,{size:n==="large"?"24":"4"}),!!l.alert&&tt.createElement(xm,{size:n},tt.createElement(aT,{type:l.alert.type,title:l.alert.text,titleAlign:"left",action:l.alert.action&&tt.createElement(sT,{size:"xsmall",id:"widget-no-result-alert-btn",type:l.alert.type,prefix:tt.createElement(Em,null,tt.createElement(pT,{size:8})),onClick:l.alert.action.onClick},l.alert.action.title),variant:"alarm"})))}i(bn,"NoResult");import{i18n as xn}from"@lingui/core";import{Button as uT,Divider as mT,MessageBox as dT,Typography as fT,WarningIcon as gT}from"@rango-dev/ui";import $t from"react";import{Typography as Mm}from"@rango-dev/ui";import As from"react";import{darkTheme as cT,styled as oi}from"@rango-dev/ui";var Am=oi("div",{width:"100%"}),Is=oi("div",{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"$5",width:"100%"}),Nm=oi("div",{display:"flex",padding:"$5 0",justifyContent:"space-between",alignItems:"center",width:"100%","._title":{$$color:"$colors$neutral600",[`.${cT} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),Wm=oi("div",{padding:"$2",alignSelf:"flex-start",cursor:"pointer"});function Lm(t){let{title:e,value:o,valueColor:n}=t;return As.createElement(Nm,null,As.createElement(Mm,{size:"medium",variant:"label",className:"_title"},e),As.createElement(Mm,{size:"large",variant:"label",color:n||"foreground"},`${n?"%":"$"}${o}`))}i(Lm,"QuoteErrorsModalItem");function Bm(t){let{open:e,onClose:o,onConfirm:n,warning:r,confirmationDisabled:a}=t,s=r.warningLevel==="high"?"error":"warning",l=[{title:xn.t("Swapping"),value:L(r.inputUsdValue,4,4)},{title:xn.t("Gas cost"),value:L(r.totalFee,2,2)},{title:xn.t("Receiving"),value:L(r.outputUsdValue,4,4)},{title:xn.t("Price impact"),value:L(r.priceImpact,2,2),valueColor:`${s}500`}];return $t.createElement(ee,{footer:$t.createElement(uT,{id:"widget-high-value-loss-warning-modal-confirm-btn",type:"primary",size:"large",prefix:$t.createElement(gT,null),fullWidth:!0,disabled:a,onClick:n},te().highValueLossError.confirmMessage),open:e,onClose:o,container:N()},$t.createElement(dT,{type:s,title:te().highValueLossError.impactTitle,description:te().highValueLossError.description}),$t.createElement(Is,null,$t.createElement(mT,{size:"4"}),$t.createElement(fT,{size:"small",variant:"title"},xn.t("Details")),$t.createElement(Is,null,l.map((p,u)=>$t.createElement(Lm,{key:u,...p})))))}i(Bm,"HighValueLossWarningModal");import{i18n as Ns}from"@lingui/core";function Pm(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=Ns.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&&(Dt(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=Ns.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=Ns.t("Caution, your slippage is high."),o.action="change-settings"),o):null}i(Pm,"makeAlerts");import{i18n as Xo}from"@lingui/core";import{Button as Dm,Divider as _m,MessageBox as hT,Typography as yT}from"@rango-dev/ui";import ko from"react";import{useNavigate as ST}from"react-router-dom";function $m(t){let{customSlippage:e,slippage:o}=y(),{open:n,onClose:r,onConfirm:a,warning:s,confirmationDisabled:l}=t,p=ST(),u=e??o;return ko.createElement(ee,{anchor:"bottom",open:n,prefix:ko.createElement(Dm,{size:"small",id:"widget-slippage-warning-modal-change-settings-btn",variant:"ghost",onClick:()=>p("../"+_.settings)},ko.createElement(yT,{variant:"label",size:"medium",color:"$neutral900"},Xo.t("Change settings"))),container:N(),onClose:r},ko.createElement(hT,{type:"warning",title:s.type===3?Xo.t("High slippage"):Xo.t("Low slippage"),description:s.type===3?Xo.t({id:" Caution, your slippage is high (={userSlippage}). Your trade may be front run.",values:{userSlippage:u}}):Xo.t({id:"We recommend you to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:s.minRequiredSlippage}})},ko.createElement(_m,{size:18}),ko.createElement(_m,{size:32}),ko.createElement(Dm,{id:"widget-slippage-warning-modal-confirm-anyway-btn",size:"large",type:"primary",variant:"contained",fullWidth:!0,disabled:l,onClick:a},Xo.t("Confirm anyway"))))}i($m,"SlippageWarningModal");import{Button as CT,MessageBox as kT,WarningIcon as TT}from"@rango-dev/ui";import ni from"react";function Fm(t){let{open:e,onClose:o,onConfirm:n,confirmationDisabled:r}=t;return ni.createElement(ee,{footer:ni.createElement(CT,{id:"widget-unknown-price-warning-modal-confirm-btn",type:"primary",size:"large",prefix:ni.createElement(TT,null),fullWidth:!0,disabled:r,onClick:n},te().unknownPriceError.confirmMessage),open:e,onClose:o,container:N()},ni.createElement(kT,{type:"warning",title:te().unknownPriceError.impactTitle,description:te().unknownPriceError.description}))}i(Fm,"UnknownPriceWarningModal");function En(t){let{warning:e,error:o,couldChangeSettings:n,showWarningModal:r,confirmationDisabled:a,refetchQuote:s,onOpenWarningModal:l,onCloseWarningModal:p,onConfirmWarningModal:u,onChangeSettings:c}=t,m={confirmationDisabled:a,open:r,onClose:p,onConfirm:u},g=o?.type===0||o?.type===1,f=Pm(e,o?.type===3||o?.type===4?o:null);return f&&!n&&(f.action=null),ot.createElement(ot.Fragment,null,g&&ot.createElement(bn,{error:o,fetch:s}),!!f&&ot.createElement(Am,null,ot.createElement(wT,{title:f.title,type:f.alertType,variant:"alarm",...f.action==="show-info"&&{action:ot.createElement(Wm,{onClick:l},ot.createElement(xT,{size:12,color:"gray"}))},...f.action==="change-settings"&&{action:ot.createElement(bT,{id:"widget-quote-warning-error-change-settings-btn",size:"xxsmall",type:f.alertType,onClick:c},vT.t("Change"))}})),e&&ot.createElement(ot.Fragment,null,e.type===0&&ot.createElement(Bm,{...m,warning:e}),(e.type===3||e.type===2)&&ot.createElement($m,{...m,warning:e}),e.type===1&&ot.createElement(Fm,{...m,warning:e})))}i(En,"QuoteWarningsAndErrors");import ov from"bignumber.js";import yi from"react";import{i18n as To}from"@lingui/core";import{Alert as qT,Divider as Zo,FullExpandedQuote as HT,InfoIcon as GT,NumericTooltip as yd,QuoteTag as VT,StepDetails as KT,TokenAmount as jT,Typography as Jo}from"@rango-dev/ui";import $s from"bignumber.js";import O,{useRef as XT,useState as YT}from"react";import{styled as Ws}from"@rango-dev/ui";var Ms=Ws("div",{width:"100%","& .position-top__skeleton":{paddingTop:"$10"}}),Om=Ws("div",{paddingBottom:"$15",variants:{dense:{true:{paddingBottom:0}}}}),Um=Ws("div",{width:"100%",display:"flex"});import*as ri from"@radix-ui/react-collapsible";import{Button as ET,css as In,darkTheme as we,Image as zm,styled as qe,Typography as IT}from"@rango-dev/ui";var AT=300,Qm=qe(ri.Root,{display:"flex",flexDirection:"column",alignItems:"start",overflowX:"auto",overflowY:"hidden",width:"100%",borderRadius:"$xm",variants:{selected:{true:{},false:{$$color:"$colors$neutral400",[`.${we} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"}},listItem:{true:{$$color:"$colors$neutral400",[`.${we} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"},false:{}}},compoundVariants:[{listItem:!1,selected:!0,css:{$$color:"$colors$secondary200",[`.${we} &`]:{$$color:"$colors$secondary800"},backgroundColor:"$$color"}}]}),qm=In({padding:"$10 $15"}),Hm=qe(ET,{backgroundColor:"transparent",border:"1px solid $secondary550",[`.${we} &`]:{border:"1px solid $secondary"},transition:"background-color 0.3s ease","&:hover":{backgroundColor:"$secondary550",[`.${we} &`]:{backgroundColor:"$secondary"},".allRoutesLabel":{$$color:"$colors$background",[`.${we} &`]:{$$color:"$colors$foreground"},color:"$$color",transition:"color 0.3s ease"}}}),Gm=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",[`.${we} &`]:{$$color:"$colors$neutral500"},backgroundColor:"$$color"}},basic:{true:{borderTopRightRadius:"0",borderTopLeftRadius:"0"}},listItem:{true:{$$color:"$colors$neutral200",[`.${we} &`]:{$$color:"$colors$neutral500"},backgroundColor:"$$color","&:hover":{"& .quote_container":{"& button":{backgroundColor:"$neutral500",[`.${we} &`]:{backgroundColor:"$neutral200"}},backgroundColor:"$neutral500",[`.${we} &`]:{backgroundColor:"$neutral200"}},backgroundColor:"$neutral300",[`.${we} &`]:{backgroundColor:"$neutral400"}},cursor:"pointer"},false:{}}},compoundVariants:[{listItem:!0,selected:!0,css:{outline:"1px solid $secondary"}},{listItem:!1,selected:!0,css:{$$color:"$colors$secondary100",[`.${we} &`]:{$$color:"$colors$secondary550"},backgroundColor:"$$color","&:hover":{backgroundColor:"$$color"}}},{listItem:!0,selected:!1,css:{cursor:"pointer","&:hover":{backgroundColor:"$neutral300",[`.${we} &`]:{backgroundColor:"$neutral400"}}}}]}),Vm=In({width:"100%",padding:"$15 $15 $10 $15"}),Km=In({display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingBottom:"$10",position:"relative"}),Yo=In({display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",".blockchainImage":{marginLeft:"-$8"}}),jm=In({display:"flex",alignItems:"center",".usd-value":{$$color:"$colors$neutral600",[`.${we} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),Xm=qe(ri.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:{[`& ${zm}`]:{border:"1px $warning500 solid",borderRadius:"100%"}},false:{[`& ${zm}`]:{border:"1px transparent solid",borderRadius:"100%"}}},selected:{true:{},false:{$$color:"$colors$neutral400",[`.${we} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"}},listItem:{true:{$$color:"$colors$neutral400",[`.${we} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"},false:{}}},compoundVariants:[{listItem:!1,selected:!0,css:{$$color:"$colors$secondary200",[`.${we} &`]:{$$color:"$colors$secondary800"},backgroundColor:"$$color"}}],".blockchains_section":{display:"none"},"@xs":{".blockchains_section":{display:"block"}}}),Ym=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"}}}}),Zm=qe(Xr,{width:"100%",background:"inherit"}),Ls=qe("div",{display:"flex",justifyContent:"center",alignItems:"center",padding:"$2",transition:`all ${AT}ms ease`,variants:{orientation:{down:{transform:"rotate(0)"},up:{transform:"rotate(180deg)"}}}}),_F=qe("div",{height:"$12",marginLeft:"$10",marginRight:"$10",borderLeft:"1px solid $foreground"}),Jm=qe("div",{display:"flex",justifyContent:"center",margin:"0 $15",borderTop:"1px solid",$$color:"$colors$neutral300",[`.${we} &`]:{$$color:"$colors$neutral400"},borderColor:"$$color"}),Rm=qe("div",{width:"$16",height:"$16",justifyContent:"center",alignItems:"center",display:"flex"}),Bs=qe(IT,{overflow:"hidden",textOverflow:"ellipsis",letterSpacing:.4}),ed=qe("div",{display:"flex",flexWrap:"wrap"}),Ps=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"}}}}),td=qe("div",{display:"flex"}),ii=qe("div",{width:"100%",borderTopWidth:"1px",borderTopStyle:"solid",borderTopColor:"$neutral",margin:"$5 0",[`.${we} &`]:{borderTopColor:"$neutral800"}});import{i18n as Nt}from"@lingui/core";import{ChevronDownIcon as WT,CloseIcon as MT,Divider as li,IconButton as LT,NumericTooltip as BT,QuoteCost as PT,Typography as yt}from"@rango-dev/ui";import Y,{useState as id}from"react";import{css as NT,styled as ai}from"@rango-dev/ui";var si=ai("div",{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"$5 0","&.total_payable_fee":{padding:"$12 0"}}),Ds=ai("div",{width:"100%",borderTop:"1px solid $neutral300",margin:"$10 0"}),od=ai("div",{padding:"$20 0",display:"flex",flexDirection:"column","& .collapsible_trigger":{display:"flex",alignItems:"center"}}),nd=ai("div",{padding:"$20 $20 $10",textAlign:"center",position:"relative","._icon-button":{position:"absolute",zIndex:10,top:"$16",right:"$16"}}),rd=NT({display:"flex",flexDirection:"row",alignItems:"center",padding:"$5","&:hover":{"& ._typography, & svg":{color:"$secondary"}}});var DT=i(t=>t.fee.isZero()?null:Y.createElement(si,null,Y.createElement(yt,{variant:"label",size:"medium",color:"neutral600"},t.label),Y.createElement(yt,{variant:"label",size:"medium"},"$",L(t.fee,4,4))),"NonPayableFee");function ad(t){let[e,o]=id(!1),[n,r]=id(!1),{steps:a,quote:s,fee:l,time:p,feeWarning:u,showModalFee:c}=t,m=s?.swaps??[],g=N(),f=zc(m);return Y.createElement(Y.Fragment,null,Y.createElement(PT,{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:g}),Y.createElement(ee,{container:g,open:e,header:Y.createElement(nd,null,Y.createElement(yt,{variant:"title",size:"medium"},Nt.t("Gas & Fee Explanation")),Y.createElement(LT,{id:"widget-quote-cost-details-modal-close-icon-btn",onClick:()=>o(!1),variant:"ghost"},Y.createElement(MT,{color:"gray",size:14}))),onClose:()=>{o(!1)}},Y.createElement(od,null,Y.createElement(yt,{variant:"title",size:"small"},Nt.t("Details")),Y.createElement(li,{size:10}),Object.entries(f.payable).flatMap(([d,h])=>h.map((C,S)=>{let k=`payable-fee-${S}`,T=Pa(C);return Y.createElement(si,{key:k},Y.createElement(yt,{variant:"label",size:"medium",color:"neutral600"},Wa(d,Nt.t)),Y.createElement(BT,{content:C.amount,container:g},Y.createElement(yt,{variant:"label",size:"medium"},L(C.amount,2,2)," ",C.asset.symbol," ($",L(T,4,4),")")))})),Y.createElement(si,{className:"total_payable_fee"},Y.createElement(yt,{variant:"label",size:"medium"},Nt.t("Total Payable Fee")),Y.createElement(yt,{variant:"label",size:"medium"},"$",L(l,4,4))),Y.createElement(Ds,null),Object.keys(f.nonePayable).length&&Y.createElement(Jr,{triggerAnchor:"bottom",onClickTrigger:()=>r(d=>!d),trigger:Y.createElement("div",{className:rd()},Y.createElement(yt,{size:"small",variant:"body",color:"neutral700"},n?Nt.t("Hide non-payable fees"):Nt.t("Show non-payable fees")),Y.createElement(li,{size:4,direction:"horizontal"}),Y.createElement(Yr,{orientation:n?"up":"down"},Y.createElement(WT,{size:12,color:"gray"}))),open:n},Y.createElement(yt,{size:"small",variant:"title"},Nt.t("Description")),Y.createElement(li,{size:4}),Y.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.`)),Y.createElement(li,{size:10}),Object.entries(f.nonePayable).map(([d,h],C)=>{let S=Uc(h),k=Wa(d,Nt.t),T=`non-payable-fee-${C}`;return Y.createElement(DT,{key:T,fee:S,label:k})}),Y.createElement(Ds,null)))))}i(ad,"QuoteCostDetails");import{i18n as pd}from"@lingui/core";import{TokenAmount as cd}from"@rango-dev/ui";import pi from"react";import{css as _T,styled as $T}from"@rango-dev/ui";var sd=$T("div",{position:"relative",display:"flex",flexDirection:"column",width:"100%"}),ld=_T({height:"14px",marginLeft:"14px",position:"absolute",borderLeft:"1px solid $foreground",top:"42%"});function An(t){let{from:e,to:o,percentageChange:n,warningLevel:r}=t;return pi.createElement(sd,null,pi.createElement(cd,{direction:"horizontal",label:pd.t("Swap input"),type:"input",tooltipContainer:N(),price:{value:e.price.value,usdValue:e.price.usdValue,realValue:e.price.realValue,realUsdValue:e.price.realUsdValue},token:{displayName:e.token.displayName,image:e.token.image},chain:{image:e.chain.image}}),pi.createElement("div",{className:ld()}),pi.createElement(cd,{direction:"horizontal",tooltipContainer:N(),label:pd.t("Estimated output"),type:"output",price:{value:o.price.value,usdValue:o.price.usdValue,realValue:o.price.realValue,realUsdValue:o.price.realUsdValue},token:{displayName:o.token.displayName,image:o.token.image},chain:{image:o.chain.image},percentageChange:n,warningLevel:r}))}i(An,"QuoteSummary");import{i18n as gd}from"@lingui/core";import{ChevronDownIcon as UT,ChevronRightIcon as zT,Divider as _s,Image as QT,Tooltip as fi,Typography as ui}from"@rango-dev/ui";import U from"react";import{useLayoutEffect as FT,useState as Nn}from"react";var ud=480,md=768,dd=1024,fd=1200,OT=i(()=>{let[t,e]=Nn(!1),[o,n]=Nn(!1),[r,a]=Nn(!1),[s,l]=Nn(!1),[p,u]=Nn(!1),c=i(()=>{e(window.innerWidth<=ud),n(window.innerWidth>ud&&window.innerWidth<=md),a(window.innerWidth>md&&window.innerWidth<=dd),l(window.innerWidth>dd&&window.innerWidth<=fd),u(window.innerWidth>fd)},"handleResize");return FT(()=>(c(),window.addEventListener("resize",c),()=>window.removeEventListener("resize",c)),[]),{isMobile:t,isTablet:o,isNotebook:r,isLargeScreen:s,isExtraLargeScreen:p}},"useScreenDetect"),ci=OT;var mi=4,di=6,Wn=i(t=>{let{content:e,src:o,className:n,open:r,state:a,container:s}=t,l=s||N();return U.createElement(fi,{container:l,side:"bottom",sideOffset:4,open:r,content:e},U.createElement(Ym,{className:n,state:a},U.createElement(QT,{src:o,size:16})))},"ImageComponent");function hd(t){let{quoteRef:e,selected:o,setExpanded:n,steps:r,expanded:a,type:s,container:l}=t,p=l||N(),u=r.length,c=ru(r),{isTablet:m,isMobile:g}=ci();return U.createElement(Xm,{listItem:s==="list-item",ref:f=>e.current=f,selected:o,onClick:f=>{f.stopPropagation(),n(d=>!d)}},U.createElement("div",{className:Yo()},U.createElement(ui,{variant:"body",size:"xsmall"},gd.t("Via:")),U.createElement(_s,{direction:"horizontal",size:4}),r.map((f,d)=>{let h=`item-${d}`,C=U.createElement(Ls,null,U.createElement(zT,{size:12,color:"black"}));return g||m?U.createElement(U.Fragment,{key:h},U.createElement(Wn,{content:f.swapper.displayName,src:f.swapper.image,state:f.state,container:l}),d!==u-1&&U.createElement(U.Fragment,null,C)):U.createElement(U.Fragment,{key:h},u<=mi||u>mi&&d<mi-1?U.createElement(U.Fragment,null,U.createElement(Wn,{content:f.swapper.displayName,src:f.swapper.image,state:f.state,container:l}),d!==u-1&&U.createElement(U.Fragment,null,C)):d===mi-1&&U.createElement(fi,{container:p,side:"bottom",align:"end",sideOffset:4,content:U.createElement("div",{className:Yo()},C,r.map((S,k)=>{let T=`image-${k}`;return k>=d&&U.createElement(U.Fragment,{key:T},U.createElement(Wn,{content:S.swapper.displayName,src:S.swapper.image,state:S.state,open:!1}),k!==u-1&&U.createElement(U.Fragment,null,C))}))},U.createElement(Ps,{state:r.find((S,k)=>k>=d&&(S.state==="error"||S.state==="warning"))?.state},U.createElement(ui,{size:"xsmall",variant:"body"},"+",u-d))))})),U.createElement("div",{className:Yo()},U.createElement("div",{className:"blockchains_section"},U.createElement("div",{className:Yo()},U.createElement(ui,{variant:"body",size:"xsmall"},gd.t("Chains:")),U.createElement(_s,{direction:"horizontal",size:4}),c.map((f,d)=>U.createElement(U.Fragment,{key:f.displayName},c.length<=di||c.length>di&&d<di-1?U.createElement(fi,{container:p,side:"bottom",content:f.displayName,sideOffset:4},U.createElement(Wn,{content:"",src:f.image,open:!1,className:d!==0?"blockchainImage":""})):d===di-1&&U.createElement(fi,{container:p,side:"bottom",align:"end",sideOffset:4,content:U.createElement("div",{className:Yo()},c.map((h,C)=>C>=d&&U.createElement(Wn,{key:h.displayName,content:"",src:h.image,open:!1,className:C>d?"blockchainImage":"",container:l})))},U.createElement(Ps,{className:"blockchainImage"},U.createElement(ui,{size:"xsmall",variant:"body"},"+",c.length-d))))),U.createElement(_s,{direction:"horizontal",size:32}))),U.createElement(Ls,{orientation:a?"up":"down"},U.createElement(UT,{size:12,color:"black"}))))}i(hd,"QuoteTrigger");function Fs(t){let{quote:e,input:o,output:n,error:r,warning:a,type:s,selected:l=!1,tagHidden:p=!0,showModalFee:u=!0,onClickAllRoutes:c,fullExpandedMode:m=!1,container:g}=t,f=y().blockchains(),{findToken:d}=y(),h=y().swappers(),{customSlippage:C,slippage:S}=y(),k=C||S,[T,v]=YT(t.expanded),w=XT(null),I=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=Dt(E??0),D=i((ge,Pe)=>ge.map((z,je)=>{let vt,lt=r?.type===3&&r.swap.swapperId===z.swapperId,wt=r?.type===4&&r.recommendedSlippages?.has(je),$=a?.type===2&&a.recommendedSlippages?.has(je),Q=lt||wt,H=$;Q?vt="error":H&&(vt="warning");let ne=Q?To.t("Slippage Error"):To.t("Slippage Warning");return lt&&(ne=To.t("Bridge Limit Error")),{swapper:{displayName:rn(z.swapperId,h)??"",image:z.swapperLogo},from:{token:{displayName:z.from.symbol,image:z.from.logo},chain:{displayName:pt(z.from.blockchain,f)??"",image:z.from.blockchainLogo},price:{value:je===0&&!Pe?L(o.value,6,6):L(z.fromAmount,6,6),usdValue:L((z.from.usdPrice??0)*parseFloat(z.fromAmount),4,4),realValue:je===0?o.value:z.fromAmount,realUsdValue:new $s(z.from.usdPrice??0).multipliedBy(z.fromAmount).toString()}},to:{token:{displayName:z.to.symbol,image:z.to.logo},chain:{displayName:pt(z.to.blockchain,f)||"",image:z.to.blockchainLogo},price:{value:L(z.toAmount,6,6),usdValue:L((z.to.usdPrice??0)*parseFloat(z.toAmount),4,4),realValue:z.toAmount,realUsdValue:new $s(z.to.usdPrice??0).multipliedBy(z.toAmount).toString()}},state:vt,alerts:Q||H?O.createElement(Om,{dense:m},O.createElement(qT,{variant:"alarm",type:Q?"error":"warning",title:ne,footer:O.createElement(Um,null,lt&&O.createElement("div",null,O.createElement(Jo,{size:"xsmall",variant:"body",color:"neutral900"},r.fromAmountRangeError),O.createElement(Zo,{direction:"vertical",size:2}),O.createElement(Jo,{size:"xsmall",variant:"body",color:"neutral900"},To.t({id:"Yours: {amount} {symbol}",values:{amount:L(z.fromAmount,6,6),symbol:z?.from.symbol}}))),(wt||$)&&!lt&&O.createElement("div",null,O.createElement(Jo,{size:"xsmall",variant:"body",color:"neutral900"},To.t({id:"Minimum required slippage: {minRequiredSlippage}",values:{...r?.type===4&&{minRequiredSlippage:r.recommendedSlippages?.get(je)},...a?.type===2&&{minRequiredSlippage:a.recommendedSlippages?.get(je)}}})),O.createElement(Zo,{direction:"vertical",size:2}),O.createElement(Jo,{size:"xsmall",variant:"body",color:"neutral900"},To.t({id:"Yours: {userSlippage}",values:{userSlippage:k}}))))})):void 0,time:pn(z.estimatedTimeInSeconds),fee:L(Ba(z,d),2,2),internalSwaps:z.internalSwaps?D(z.internalSwaps):void 0}}),"getQuoteSteps"),A=D(e?.swaps??[]),Z=A.length,ae=g||N(),J=au(t.quote.tags||[]),B=!!c,K=pn(lr(e?.swaps)),me=Lr(e?.swaps??[],d),V=L(me,2,2),fe=me.gte(new $s(Pc));return m?O.createElement(HT,{selected:l,fee:V,time:K,tooltipContainer:ln(),steps:A,tags:J,feeWarning:fe,percentageChange:x,warningLevel:W,outputPrice:{value:M,usdValue:b,realValue:n.value,realUsdValue:n.usdValue}}):O.createElement(Gm,{selected:l,listItem:s==="list-item",basic:s==="basic"},O.createElement("div",{className:Vm()},!p&&J.length?O.createElement(O.Fragment,null,O.createElement(td,null,J.map((ge,Pe)=>{let z=`${ge.value}_${Pe}`;return O.createElement(O.Fragment,{key:z},O.createElement(VT,{label:ge.label,value:ge.value}),O.createElement(Zo,{size:4,direction:"horizontal"}))})),O.createElement(ii,null),!B&&O.createElement(Zo,{size:4})):null,O.createElement("div",{id:"portal-root",className:Km()},O.createElement(ad,{quote:e,time:K,fee:V,feeWarning:fe,showModalFee:u,steps:Z}),B&&O.createElement(Hm,{onClick:ge=>{ge.stopPropagation(),c()},size:"xxsmall",type:"secondary",variant:"default",css:{paddingLeft:"$10",paddingRight:"$10",paddingTop:"$5",paddingBottom:"$5"}},O.createElement(Jo,{color:"secondary",variant:"body",size:"xsmall",className:"allRoutesLabel"},To.t("See All Routes")))),s==="basic"&&O.createElement("div",{className:jm()},O.createElement(Rm,null,O.createElement(GT,{size:12,color:"gray"})),O.createElement(ed,null,O.createElement(Bs,{size:"small",variant:"body"},`${I} ${A[0].from.token.displayName} = `),O.createElement(yd,{content:n.value,container:ae,open:n.value?void 0:!1},O.createElement(Bs,{size:"small",variant:"body"},"\xA0",`${M} ${A[A.length-1].to.token.displayName}`))),O.createElement(yd,{content:n.usdValue,container:ae},O.createElement(Zo,{size:2,direction:"horizontal"}),O.createElement(Jo,{color:"$neutral600",size:"xsmall",variant:"body"},`($${b})`))),s==="list-item"&&O.createElement(jT,{tooltipContainer:ae,type:"output",direction:"vertical",price:{value:M,usdValue:b,realValue:n.value,realUsdValue:n.usdValue},token:{displayName:A[Z-1].to.token.displayName,image:A[Z-1].to.token.image},chain:{image:A[Z-1].to.chain.image},percentageChange:x,warningLevel:W}),s==="swap-preview"&&O.createElement(O.Fragment,null,O.createElement(An,{from:A[0].from,to:A[Z-1].to,percentageChange:x,warningLevel:W}),O.createElement(Zo,{size:4}))),O.createElement(Qm,{selected:l,listItem:s==="list-item",open:T,className:"quote_container",onOpenChange:v},O.createElement(hd,{type:s,quoteRef:w,selected:l,setExpanded:v,container:ae,expanded:T,steps:A}),O.createElement(Zm,{open:T},O.createElement(Jm,null),O.createElement("div",{className:qm()},A.map((ge,Pe)=>{let z=`item-${Pe}`;return O.createElement(KT,{type:"quote-details",key:z,tooltipContainer:ae,step:ge,hasSeparator:Pe!==A.length-1,state:ge.state})})))))}i(Fs,"Quote");import{Divider as ev,Skeleton as tv}from"@rango-dev/ui";import Ot from"react";import{darkTheme as ZT,styled as gi}from"@rango-dev/ui";var Sd=gi("div",{$$color:"$colors$neutral100",[`.${ZT} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",borderBottomLeftRadius:"$xm",borderBottomRightRadius:"$xm",padding:"$15",variants:{rounded:{true:{borderRadius:"$xm"}},expanded:{true:{paddingBottom:"3px"},false:{paddingBottom:"$12"}}}}),Cd=gi("div",{paddingTop:"$2"}),kd=gi("div",{paddingLeft:"$8"}),Td=gi("div",{borderLeft:"1px dashed $foreground",minHeight:" 0",margin:"0px 11.5px",alignSelf:"stretch",variants:{hideSeparator:{true:{minHeight:"unset",height:"0"}}}});import{ChainToken as Md,Divider as St,Skeleton as nt}from"@rango-dev/ui";import q from"react";import{css as JT,styled as Ft}from"@rango-dev/ui";var Os=Ft("div",{display:"flex"}),vd=Ft("div",{padding:"$10 $0 $20"}),wd=Ft("div",{padding:"14px $0 $20 $0",display:"flex",flexDirection:"column"}),bd=Ft("div",{display:"flex",justifyContent:"start",alignItems:"center"}),xd=Ft("div",{display:"flex",justifyContent:"space-between",alignItems:"end"}),Ed=Ft("div",{height:"$24",marginLeft:"13px",borderLeft:"1px solid $neutral700"}),Id=Ft("div",{width:"65%",display:"flex",justifyContent:"start"}),Ad=Ft("div",{display:"flex",flexDirection:"column",alignItems:"start",flexGrow:1,maxWidth:"148px"}),Nd=Ft("div",{padding:"$15 $0 $15 $0"}),Wd=JT({display:"flex",justifyContent:"space-between",alignItems:"center"});function Mn(t){let{type:e,tagHidden:o=!0}=t,n=q.createElement(xd,null,q.createElement(Id,null,q.createElement(Md,{loading:!0,size:"medium",chainImage:"",tokenImage:""}),q.createElement(St,{size:8,direction:"horizontal"}),q.createElement(Ad,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(Os,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(ii,null),!r&&q.createElement(St,{size:4})),q.createElement("div",{className:Wd()},q.createElement(Os,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(vd,null,q.createElement(nt,{height:15,width:148,variant:"rounded"})),e==="list-item"&&q.createElement(wd,null,q.createElement(bd,null,q.createElement(Md,{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(Nd,null,n,q.createElement(Ed,null),n),q.createElement(St,{size:12})))}i(Mn,"QuoteSummarySkeleton");import{ChainToken as _d,Divider as zs,NextIcon as RT,Skeleton as hi}from"@rango-dev/ui";import be from"react";import{styled as Ln}from"@rango-dev/ui";var Ld=Ln("div",{display:"flex",alignItems:"start"}),Bd=Ln("div",{flexGrow:1,paddingTop:"$5",paddingBottom:"$10",display:"flex",alignItems:"center",variants:{extraSpace:{true:{paddingBottom:"$40"}}}}),Us=Ln("div",{display:"flex",alignItems:"center",flexGrow:1}),Pd=Ln("div",{margin:"$0 $2",padding:"$4",display:"flex",justifyContent:"center",alignItems:"center"}),Dd=Ln("div",{display:"flex",alignItems:"center"});function Wt(t){let{separator:e=!0}=t;return be.createElement(be.Fragment,null,be.createElement(Dd,null,be.createElement(hi,{height:22,width:22,variant:"circular"}),be.createElement(zs,{direction:"horizontal",size:8}),be.createElement(hi,{height:15,width:148,variant:"rounded"})),be.createElement(Ld,null,be.createElement(Td,{hideSeparator:!e}),be.createElement(Bd,{extraSpace:e},be.createElement(Us,null,be.createElement(_d,{size:"small",loading:!0,chainImage:"",tokenImage:""}),be.createElement(zs,{direction:"horizontal",size:8}),be.createElement(hi,{height:12,variant:"rounded"})),be.createElement(Pd,null,be.createElement(RT,{color:"gray",size:16})),be.createElement(Us,null,be.createElement(_d,{size:"small",loading:!0,chainImage:"",tokenImage:""}),be.createElement(zs,{direction:"horizontal",size:8}),be.createElement(hi,{height:12,variant:"rounded"})))))}i(Wt,"StepSkeleton");function Bn(t){let{type:e,expanded:o,tagHidden:n=!1}=t;return Ot.createElement(Sd,{expanded:o,rounded:e!=="basic"},Ot.createElement(Mn,{type:e,tagHidden:n}),Ot.createElement(Cd,null,Ot.createElement(tv,{height:15,variant:"rounded"})),o&&Ot.createElement(kd,null,Ot.createElement(ev,{size:24}),Ot.createElement(Wt,null),Ot.createElement(Wt,null),Ot.createElement(Wt,{separator:!1})))}i(Bn,"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:g=!1,container:f}=t,{inputAmount:d,inputUsdValue:h,toToken:C}=F(),S=e?.outputAmount?new ov(e?.outputAmount):null,k=e?.outputAmount?Xt(e?.outputAmount,go(e)||C?.usdPrice):null,v=!(r&&(r.type===0||r.type===1))&&e&&!n;return n?yi.createElement(Ms,null,yi.createElement(Bn,{tagHidden:l,type:o,expanded:s})):v?yi.createElement(Ms,{onClick:()=>p?.(e)},yi.createElement(Fs,{quote:e,error:r,container:f,showModalFee:u,warning:a,tagHidden:l,selected:c,type:o,expanded:s,onClickAllRoutes:m,fullExpandedMode:g,input:{value:d,usdValue:h?.toString()??""},output:{value:S?.toString()??"",usdValue:k?.toString()??""}})):null}i(vo,"QuoteInfo");import{calculatePendingSwap as av}from"@rango-dev/queue-manager-rango-preset";import{useEffect as sv}from"react";import{useRef as nv,useState as rv}from"react";var iv=2e3;function Si({request:t}){let[e,o]=rv(!1),n=nv(null),r=i(()=>n.current?.abort(),"cancelFetch"),a=i(async l=>(await new Promise(p=>setTimeout(p,iv)),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(Si,"useFetch");function $d(){let{fetch:t,loading:e,cancelFetch:o}=Si({request:async(n,r)=>await Et().confirmRoute(n,r)});return{fetch:t,loading:e,cancelFetch:o}}i($d,"useFetchConfirmQuote");function Ci(t){if(!t.swaps)throw new Error(te().noResultError.title,{cause:{type:0,diagnosisMessage:t.diagnosisMessages?.[0]}});let e=Qs(t.swaps);if(e)throw new Error(e.message,{cause:e.options})}i(Ci,"throwErrorIfResponseIsNotValid");function Qs(t){if($c(t)){let{swap:n,recommendation:r,fromAmountRangeError:a}=Fc(t);return{message:"bridge limit error",options:{type:3,swap:n,recommendation:r,fromAmountRangeError:a}}}let o=Qc(t);if(o){let n=Br(t);return{message:"",options:{type:4,recommendedSlippages:o,minRequiredSlippage:n}}}return null}i(Qs,"getQuoteError");function Fd(t,e,o){let n=!1;t&&(n=nu(t,e));let r={quote:null,quoteUpdate:null,balance:null},a=Uo(e,{fromToken:o.fromToken,toToken:o.toToken,findToken:o.findToken,userSlippage:o.userSlippage});a&&(r.quote=a),t&&n&&(jc(t,e)?r.quoteUpdate={type:3,newOutputAmount:L(Oo(e)),percentageChange:L(ct(Oo(t)??"",Oo(e)??""),null,2)}:Da(t,e)?r.quoteUpdate={type:0}:_a(t,e)?r.quoteUpdate={type:1}:$a(t,e)&&(r.quoteUpdate={type:2}));let s=Xc(e,o.selectedWallets,o.meta.blockchains);return s.length===0||(r.balance={messages:s}),r}i(Fd,"generateWarnings");function ki(t){return t?.code==="ERR_CANCELED"?{swap:null,error:{type:2},warnings:null}:t.cause?{swap:null,error:t.cause,warnings:null}:t?.code==="ERR_BAD_REQUEST"?{swap:null,error:{type:0,diagnosisMessage:t.response.data.error},warnings:null}:{swap:null,error:{type:1},warnings:null}}i(ki,"handleQuoteErrors");function qs(){let{fromToken:t,toToken:e,inputAmount:o,setSelectedQuote:n,selectedQuote:r,customDestination:a,setQuoteWarningsConfirmed:s,resetAlerts:l}=F(),{slippage:p,customSlippage:u}=y(),c=y().getDisabledLiquiditySources(),m=y().blockchains(),g=y().tokens(),{findToken:f}=y(),d=u||p,{fetch:h,cancelFetch:C,loading:S}=$d();return sv(()=>C,[]),{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 I=v.reduce((b,E)=>(b[E.chain]=E.address,b),{}),M={requestId:r?.requestId||"",selectedWallets:I,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");Ci({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=Fd(r??void 0,x,{fromToken:t,toToken:e,meta:{blockchains:m},findToken:f,selectedWallets:v,userSlippage:d});D.quoteUpdate&&s(!1),l();let A=!!D.balance,Z=av(o.toString(),E,Vc(v),W,!A,{blockchains:m,tokens:g});return{quote:x,swap:Z,error:null,warnings:D}})}catch(b){return ki(b)}},"fetch"),cancelFetch:C}}i(qs,"useConfirmSwap");var hv=cv("div",{width:"100%",display:"flex",justifyContent:"space-between",[`& ${Ud}`]:{width:"$48",height:"$48"}}),yv=Vs({flexGrow:1,paddingRight:"$10"}),Sv=Vs({width:"$24",height:"$24",display:"flex",justifyContent:"center",alignItems:"center"}),Cv=Vs({display:"flex",justifyContent:"space-between",alignItems:"center"});function zd(){let{selectedQuote:t,setInputAmount:e,selectedWallets:o,quoteWalletsConfirmed:n,customDestination:r,quoteWarningsConfirmed:a}=F(),s=gv(),[l,p]=Pn(""),u=!n,[c,m]=Pn(!1),[g,f]=Pn(!1),{isActiveTab:d}=se(),h=y().getDisabledLiquiditySources(),C=fv(h),{manager:S}=lv(),{fetch:k,loading:T,cancelFetch:v}=qs(),[w,I]=Pn({swap:null,error:null,warnings:null}),[M,b]=Pn(!1),E=i(async({selectedWallets:B,customDestination:K})=>{let me=await k?.({selectedWallets:B,customDestination:K});return I(me),me},"onConfirmSwap"),x=i(async()=>{if(w.swap&&n)try{await S?.create("swap",{swapDetails:w.swap},{id:w.swap.requestId});let B=`../${_.swaps}/${w.swap.requestId}`;s(B,{replace:!0}),setTimeout(()=>{e("")},0)}catch(B){p("Error: "+B?.message)}},"addNewSwap"),W=i(async()=>{f(!0),await x(),f(!1)},"onConfirm"),D=i(async()=>{w?.warnings?.quote&&!a?b(!0):await W()},"onStartConfirmSwap"),A=i(async()=>{I({error:null,swap:null,warnings:null}),k({selectedWallets:o,customDestination:r}).then(B=>{I(B)}).catch(B=>console.error(B))},"onRefresh");Ti(()=>{!!C.current.length&&!h.length&&A(),C.current=h},[h.length]),Ti(()=>{u&&v()},[u]),Ti(()=>{u&&m(u)},[u]),Ti(()=>{u||k({selectedWallets:o,customDestination:r}).then(B=>I(B)).catch(B=>console.error(B))},[]),dv(()=>{t?.requestId||s(`../${location.search}`)},[t?.requestId]);let Z=w.warnings?.quote??null,ae=w.error,J=[];if(l&&J.push(xe.createElement(Od,{type:"error",variant:"alarm",title:l})),w.warnings?.quoteUpdate&&J.push(xe.createElement(Od,{variant:"alarm",type:"warning",title:w.warnings.quoteUpdate&&Kr(w.warnings.quoteUpdate)})),Z||ae){let B=`../${_.settings}`;J.push(xe.createElement(En,{warning:Z,error:ae,couldChangeSettings:!1,refetchQuote:A,showWarningModal:M,confirmationDisabled:!d,onOpenWarningModal:()=>b(!0),onCloseWarningModal:()=>b(!1),onConfirmWarningModal:async()=>{b(!1),await x()},onChangeSettings:()=>s(B)}))}return xe.createElement(oe,{header:{title:Hs.t("Confirm Swap"),onWallet:()=>{let B=`../${_.wallets}`;s(B)}},footer:xe.createElement(hv,null,xe.createElement("div",{className:yv()},xe.createElement(pv,{id:"widget-confirm-swap-start-btn",variant:"contained",type:"primary",size:"large",fullWidth:!0,loading:T||g,disabled:!!w.error||!d,onClick:D},Hs.t("Start Swap"))),xe.createElement(Ud,{id:"widget-confirm-swap-wallet-icon-btn",variant:"contained",type:"primary",size:"large",loading:T||g,disabled:!d,onClick:m.bind(null,!0)},xe.createElement(mv,{size:24})))},c&&xe.createElement(km,{open:c,onClose:()=>m(!1),onCancel:v,loading:T,onCheckBalance:E}),xe.createElement(re,null,xe.createElement("div",{className:Cv()},xe.createElement(uv,{variant:"title",size:"small"},Hs.t("You get")),xe.createElement("div",{className:Sv()},xe.createElement(zr,{onClick:!T&&!c&&!M?A:void 0}))),xe.createElement(Gs,{size:"12"}),ku(J.map((B,K)=>({element:B,key:`alert-${K}`})),xe.createElement(Gs,{size:10})),J.length>0?xe.createElement(Gs,{size:10}):null,xe.createElement(vo,{quote:t,type:"swap-preview",expanded:!0,tagHidden:!0,error:w.error,loading:T,warning:w.warnings?.quote??null})))}i(zd,"ConfirmSwapPage");import{i18n as Ut}from"@lingui/core";import{Button as il,CustomTokensZeroStateDarkIcon as Fv,CustomTokensZeroStateIcon as Ov,DeleteIcon as Uv,Divider as Fn,IconButton as zv,MessageBox as Qv,NotFound as qv,styled as sl}from"@rango-dev/ui";import de,{useState as al}from"react";import{useNavigate as Hv}from"react-router-dom";import{CloseIcon as Tv,IconButton as vv,SearchIcon as wv,TextField as bv}from"@rango-dev/ui";import Dn from"react";import{styled as kv}from"@rango-dev/ui";var Qd=kv("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 Dn.createElement(bv,{prefix:Dn.createElement(Qd,null,Dn.createElement(wv,{color:"black"})),suffix:!!s.length&&Dn.createElement(vv,{variant:"ghost",onClick:()=>p?.(""),size:"small"},Dn.createElement(Tv,{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 nl}from"@lingui/core";import{darkTheme as Rd,Divider as en,ExternalLinkIcon as Mv,Image as Lv,ListItemButton as Bv,NotFound as Pv,PinIcon as Dv,Skeleton as ef,Typography as bi,VirtualizedList as _v}from"@rango-dev/ui";import G,{useEffect as tf,useState as of}from"react";import{useWallets as xv}from"@rango-dev/wallets-react";import{useEffect as Ev,useRef as Iv,useState as Av}from"react";function Ks(t){let{connectedWallets:e}=R(),{getWalletInfo:o}=xv(),n=Iv([]),[r,a]=Av(0);return Ev(()=>{let s=i(p=>{p.type==="disconnect"&&o(p.payload.walletType).supportedChains.some(m=>m.name===t)&&a(m=>m+1)},"handleWalletEvent");return Cr.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))}),()=>Cr.off("walletEvent",s)):a(p=>p+1)},[e,t,o]),{balanceKey:r}}i(Ks,"useObserveBalanceChanges");import{Divider as Zd,ListItem as Wv,Skeleton as _n}from"@rango-dev/ui";import kt from"react";import{css as Ro,darkTheme as qd,ImageContainer as Nv,styled as mt,Typography as Hd}from"@rango-dev/ui";var js=Ro({position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:100,overflow:"hidden"}),Xs=Ro({position:"relative",height:12,width:"30%",maxWidth:"150px"}),Ys=Ro({position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",bottom:"-8px"}),Zs=Ro({transform:"translateY(12px)",visibility:"hidden",display:"flex","& a":{display:"flex",justifyContent:"center",alignItems:"center",fontSize:"$12",lineHeight:"$16",$$color:"$colors$neutral600",[`.${qd} &`]:{$$color:"$colors$neutral700"},color:"$$color",textDecoration:"none"}}),Js=Ro({}),Rs=Ro(),Gd=mt("div",{display:"flex",flexDirection:"column",flexGrow:1,overflow:"hidden",justifyContent:"center"}),el=mt("div",{display:"flex",alignItems:"center","._typography":{textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:100,overflow:"hidden"}}),vi=mt("ul",{flexGrow:1,padding:0,margin:0,listStyle:"none","& li":{alignItems:"none","&:hover":{[`& .${Xs}`]:{[`& .${Zs}`]:{position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",visibility:"visible"},[`& .${Js}`]:{bottom:"-15px"},[`& .${js}`]:{position:"absolute",transform:"translateY(-12px)",visibility:"hidden"},[`& .${Ys}`]:{position:"absolute",transform:"translateY(-12px)",bottom:"-10px"}}}}}),tl=mt("div",{paddingLeft:"$5",paddingRight:"$5",borderRadius:"$md",display:"flex",alignItems:"center"}),ol=mt(Hd,{}),Vd=mt("div",{textAlign:"right",width:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",[`& .${Rs}`]:{$$color:"$colors$neutral600",[`.${qd} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),wi=mt("div",{display:"flex",alignItems:"end",flexDirection:"column"}),zU=mt("div",{display:"flex",alignItems:"center"}),Kd=mt("div",{position:"relative",[`& ${Nv}`]:{borderRadius:"$xm",overflow:"hidden"}}),jd=mt("div",{position:"absolute",backgroundColor:"$neutral100",padding:"$4",borderRadius:"50%",bottom:-6,right:-6}),Xd=mt(Hd,{width:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}),Yd=mt("a",{"& svg:hover":{color:"$colors$info"}});function Jd(t){return kt.createElement(vi,null,Array.from(Array(t.size),e=>kt.createElement(Wv,{key:e,hasDivider:!0,start:kt.createElement(_n,{variant:"circular",width:35,height:35}),end:kt.createElement(wi,null,kt.createElement(_n,{variant:"text",size:"large",width:70}),kt.createElement(Zd,{size:4}),kt.createElement(_n,{variant:"text",size:"medium",width:50})),title:kt.createElement("div",null,kt.createElement(_n,{variant:"text",size:"large",width:90}),kt.createElement(Zd,{size:4}),kt.createElement(_n,{variant:"text",size:"medium",width:90}))})))}i(Jd,"LoadingTokenList");var rl=20,$v=i(t=>{let{address:e,name:o,url:n,token:r,customCssForTag:a,customCssForTagTitle:s}=t,l=e.length;return G.createElement("div",{className:Xs()},o?G.createElement("div",{className:js()},o):G.createElement(el,{className:Ys()},G.createElement(bi,{variant:"title",size:"xmedium"},r.symbol),G.createElement(en,{direction:"horizontal",size:4}),G.createElement(tl,{css:a},G.createElement(ol,{variant:"body",size:"xsmall",css:s},r.blockchain))),!!e&&G.createElement("div",{className:`${Zs()} ${!o&&Js()}`},l>10?`${e.slice(0,5)}...${e.slice(l-6,l)}`:e," ",G.createElement(en,{size:4,direction:"horizontal"}),G.createElement(Yd,{href:n,target:"_blank",rel:"nofollow noreferrer",onClick:p=>p.stopPropagation()},G.createElement(Mv,{size:12}))))},"renderDesc");function $n(t){let{list:e,searchedFor:o="",onChange:n,selectedBlockchain:r,showTitle:a=!0,action:s}=t,[l,p]=of(e),u=y().fetchStatus,c=y().blockchains(),[m,g]=of(!0),{getBalanceFor:f,loading:d}=R(),{isTokenPinned:h}=y(),{balanceKey:C}=Ks(r),S=i(()=>{p(e.slice(0,l.length+rl))},"loadNextPage");tf(()=>{g(e.length>l.length)},[l.length]),tf(()=>{p(e.slice(0,rl))},[e.length,r,C]);let k=i(v=>{let w=fr(f(v));return s?s(v):d?G.createElement(wi,null,G.createElement(ef,{variant:"text",size:"large",width:70}),G.createElement(en,{size:4}),G.createElement(ef,{variant:"text",size:"medium",width:50})):w&&G.createElement(Vd,null,G.createElement(Xd,{variant:"title",size:"small"},w.amount),G.createElement("div",null),w.usdValue&&G.createElement(bi,{variant:"body",className:Rs(),size:"xsmall"},`$${w.usdValue}`))},"endRenderer"),T=i(()=>G.createElement(_v,{endReached:m?S:void 0,itemContent:v=>{let w=l[v],I=w.address||"",M=c.find(W=>W.name===w.blockchain),b=Ya(M.color,"main"),E={$$color:b.main150,[`.${Rd} &`]:{$$color:b.main750},backgroundColor:"$$color"},x={$$color:b.main750,[`.${Rd} &`]:{$$color:b.main150},color:"$$color"};return G.createElement("div",{style:{paddingRight:5}},G.createElement(Bv,{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:G.createElement(Kd,null,G.createElement(Lv,{src:w.image,size:30}),t.type!=="custom-token"&&h(w,t.type)&&G.createElement(jd,null,G.createElement(Dv,{size:12,color:"gray"}))),title:M?.type==="COSMOS"||w.name||!w.name&&!I?G.createElement(el,null,G.createElement(bi,{variant:"title",size:"xmedium"},w.symbol),G.createElement(en,{direction:"horizontal",size:4}),G.createElement(tl,{css:E},G.createElement(ol,{variant:"body",size:"xsmall",css:x},w.blockchain))):void 0,description:M?.info&&I&&M.type!=="COSMOS"?$v({address:I,token:l[v],customCssForTag:E,customCssForTagTitle:x,name:w.name,url:M.info.addressUrl.split("{wallet}").join(I)}):w.name||void 0,end:k(w)}))},totalCount:l.length,key:`${r}-${o}-${C}`}),"renderList");return G.createElement(G.Fragment,null,a&&G.createElement(G.Fragment,null,G.createElement(bi,{variant:"label",size:"large"},nl.t("Select Token")),G.createElement(en,{size:4})),G.createElement(Gd,null,G.createElement(en,{size:4}),u==="loading"&&G.createElement(Jd,{size:rl}),u==="success"&&(l.length?G.createElement(vi,{as:"ul"},T()):!!o&&G.createElement(Pv,{title:nl.t("No results found"),description:nl.t("Try using different keywords")}))))}i($n,"TokenList");var Gv=sl("div",{display:"flex",justifyContent:"space-between",flexDirection:"column",flex:1}),Vv=sl("div",{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",flex:"0.75"}),Kv=sl(zv,{"&:hover":{"& svg":{color:"$secondary550"}}});function nf(){let[t,e]=al(""),{deleteCustomToken:o}=y(),n=y().customTokens(),{fromToken:r,toToken:a,setFromToken:s,setToToken:l}=F(),{mode:p}=Ho({}),u=Hv(),[c,m]=al(!1),[g,f]=al(),d=i(k=>{let T=k.target.value;e(T)},"handleSearch"),h=p==="dark",C=n.filter(k=>et(k.symbol,t)||et(k.address||"",t)||et(k.name||"",t)),S=i(()=>{if(g){let k=a?De(a):null,T=r?De(r):null,v=De(g);k===v?l({token:null}):T===v&&s({token:null}),o(g)}m(!1)},"handleDeleteCustomToken");return de.createElement(oe,{header:{title:Ut.t("Custom Tokens")}},de.createElement(re,null,de.createElement(Gv,null,n.length?de.createElement(de.Fragment,null,de.createElement(Ct,{value:t,setValue:e,fullWidth:!0,color:"light",variant:"contained",placeholder:Ut.t("Search Token"),onChange:d}),de.createElement(Fn,{size:16}),de.createElement($n,{list:C,type:"custom-token",searchedFor:t,showTitle:!1,action:k=>de.createElement(Kv,{id:"widget-custom-token-delete-icon-btn",variant:"ghost",onClick:()=>{m(!0),f(k)}},de.createElement(Uv,{size:12,color:"gray"}))})):de.createElement(Vv,null,de.createElement(qv,{icon:h?de.createElement(Fv,{size:200}):de.createElement(Ov,{size:200}),title:Ut.t("No custom tokens"),description:Ut.t("press the button to add your custom token")})),de.createElement(Fn,{size:20}),de.createElement(il,{id:"widget-custom-token-add-btn",type:"primary",variant:"contained",size:"large",onClick:()=>u(_.addCustomTokens)},Ut.t("Add Custom Token"))),de.createElement(ee,{open:c,dismissible:!0,onClose:()=>m(!1),container:N()},de.createElement(Qv,{title:Ut.t("Delete Custom Token"),type:"error",description:Ut.t("Are you sure you want to Delete this Token?")},de.createElement(Fn,{size:40}),de.createElement(Fn,{size:10}),de.createElement(il,{fullWidth:!0,id:"widget-custom-token-delete-modal-yes-btn",variant:"contained",type:"primary",size:"large",onClick:S},Ut.t("Yes, Delete it")),de.createElement(Fn,{size:12}),de.createElement(il,{id:"widget-custom-token-delete-modal-no-btn",fullWidth:!0,variant:"outlined",type:"primary",size:"large",onClick:()=>m(!1)},Ut.t("No, Continue"))))))}i(nf,"CustomTokensPage");import{i18n as Ge}from"@lingui/core";import{useManager as mw}from"@rango-dev/queue-manager-react";import{Button as fl,darkTheme as dw,Divider as bo,MessageBox as fw,NotFound as gw,styled as gl,Typography as Ii}from"@rango-dev/ui";import{TransactionStatus as zn}from"rango-types";import ie,{useMemo as wf,useState as Ai}from"react";import{useNavigate as hw}from"react-router-dom";import{FilterIcon as ew,Popover as tw}from"@rango-dev/ui";import wo from"react";import{css as jv,darkTheme as xi,IconButton as Xv,styled as On}from"@rango-dev/ui";var ll=On("div",{position:"relative","&::before":{position:"absolute",right:"1px",top:"-1px",width:"$8",height:"$8",borderRadius:"100%",backgroundColor:"$neutral300",[`.${xi} &`]:{backgroundColor:"$neutral400"},padding:"$2"},variants:{isSelect:{true:{"&::before":{content:""}}}}}),rf=On(Xv,{width:"$36",height:"$36",position:"relative",padding:"0",overflow:"unset",backgroundColor:"$neutral300",[`.${xi} &`]:{backgroundColor:"$neutral400"},"&:hover":{backgroundColor:"$secondary100",[`.${xi} &`]:{backgroundColor:"$neutral"},[`& ${ll}::before`]:{backgroundColor:"$secondary100",[`.${xi} &`]:{backgroundColor:"$neutral"}}},variants:{isSelect:{true:{border:"1px solid $secondary"}}}}),af=On("div",{position:"absolute",width:"$6",height:"$6",display:"flex",justifyContent:"center",alignItems:"center",borderRadius:"3px",top:"$0",right:"1px",backgroundColor:"$secondary500"}),sf=On("div",{padding:"$15",borderRadius:"$sm",width:"248px",backgroundColor:"$background",zIndex:10}),lf=jv({display:"flex",justifyContent:"space-between",alignItems:"center"}),pf=On("ul",{margin:0,listStyle:"none",height:"100%",padding:0,".item-start-container":{paddingRight:"0 !important"}});import{i18n as cf}from"@lingui/core";import{Button as Yv,Divider as uf,ListItemButton as Zv,Radio as Jv,RadioRoot as Rv,Typography as mf}from"@rango-dev/ui";import rt from"react";function df(t){let{filterBy:e,onClickItem:o}=t;return rt.createElement(sf,null,rt.createElement("div",{className:lf()},rt.createElement(mf,{size:"small",variant:"body"},cf.t("Status")),rt.createElement(Yv,{id:"widget-filter-selector-reset-btn",variant:"ghost",size:"xxsmall",onClick:()=>o("")},cf.t("Reset"))),rt.createElement(uf,{size:10}),rt.createElement(Rv,{value:e},rt.createElement(pf,null,t.list.map((n,r)=>rt.createElement(Zv,{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(uf,{direction:"horizontal",size:4}),rt.createElement(mf,{size:"medium",variant:"body"},n.title)),start:rt.createElement(Jv,{value:n.id}),onClick:o})))))}i(df,"FilterSelectorContent");function pl(t){let{onClickItem:e,onOpenChange:o,filterBy:n,list:r,open:a}=t;return wo.createElement("div",null,wo.createElement(tw,{open:a,align:"end",onOpenChange:o,container:N(),content:wo.createElement(df,{list:r,filterBy:n,onClickItem:s=>{e(s),o(!1)}})},wo.createElement(rf,{id:"widget-filter-selector-filter-icon-btn",variant:"default",isSelect:!!n,onClick:()=>o(!t.open)},wo.createElement(ll,{isSelect:!!n},wo.createElement(ew,{size:16,color:"black"}),!!n&&wo.createElement(af,null)))))}i(pl,"FilterSelector");import{i18n as rw}from"@lingui/core";import{Divider as Sf,GroupedVirtualizedList as iw,Skeleton as aw,SwapListItem as Cf,Typography as sw}from"@rango-dev/ui";import He,{useCallback as kf,useEffect as lw,useRef as pw,useState as cw}from"react";function ff(t,e){let o=[],n=0;do{let r=t[n];o.push(Math.min(r,e)),e-=r,n++}while(e>0&&n<=t.length);return o}i(ff,"calculateGroupsSoFar");import{css as ow,darkTheme as nw,styled as Un}from"@rango-dev/ui";var cl=ow(),gf=Un("div",{display:"flex",justifyContent:"center",alignItems:"center",padding:"$5"}),ul=Un("div",{width:"100%",display:"flex",flexDirection:"column",backgroundColor:"$background",padding:"$10 $5 0 $5",[`& .${cl}`]:{$$color:"$colors$neutral600",[`.${nw} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),ml=Un("div",{display:"flex",justifyContent:"flex-start",padding:"$2"}),hf=Un("div",{gap:"$10",display:"flex",flexDirection:"column"}),yf=Un("div",{height:"100%",display:"flex",justifyContent:"center",alignItems:"center"});var uw=10;function dl(t){let{list:e,onSwapClick:o,groupBy:n,isLoading:r}=t,[a,s]=cw([]),l=pw(0),{swaps:p,groupCounts:u,groups:c}=n(e),m=kf(ff,[]),g=kf(()=>{let f=e.length-l.current;f&&(l.current+=Math.min(f,uw),s(m(u,l.current)))},[e.length]);if(lw(()=>{r||g()},[r,g]),r){let f=[1,2];return He.createElement(He.Fragment,null,[f,f].map((h,C)=>He.createElement(ul,{key:C},He.createElement(ml,null,He.createElement(aw,{variant:"text",width:60,size:"small"}),He.createElement(Sf,{size:16})),He.createElement(Sf,{size:4}),He.createElement(hf,null,h.map((k,T)=>He.createElement(Cf,{isLoading:!0,key:T}))))))}return He.createElement(iw,{endReached:()=>{l.current<e.length&&g()},groupCounts:a,groupContent:f=>He.createElement(ul,null,He.createElement(ml,null,He.createElement(sw,{variant:"label",size:"medium",className:cl()},c[f]))),itemContent:(f,d)=>{let h=p[f];if(!h)return null;let C=h.steps[0],S=h.steps[h.steps.length-1];return He.createElement(gf,{key:h.requestId},He.createElement(Cf,{requestId:h.requestId,creationTime:h.creationTime,status:h.status,onClick:o,tooltipContainer:N(),onlyShowTime:c[d]===rw.t("Today"),swapTokenData:{from:{token:{image:C.fromLogo,displayName:C.fromSymbol},blockchain:{image:C.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(dl,"HistoryGroupedList");import{i18n as Ei}from"@lingui/core";import Tf from"dayjs";var vf=i(t=>{let e=new Map([["today",{title:Ei.t("Today"),swaps:[]}],["week",{title:Ei.t("This week"),swaps:[]}],["month",{title:Ei.t("This month"),swaps:[]}],["year",{title:Ei.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=Tf();t.forEach(p=>{let u=Number(p.creationTime),c=Tf(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 yw=gl("div",{overflowY:"visible",width:"100%",display:"flex",flexDirection:"column",gap:15,height:"100%"}),Sw=gl("div",{display:"flex",justifyContent:"center",alignItems:"center"}),Cw=gl("div",{"._typography":{color:"$neutral700",[`.${dw}&`]:{color:"$neutral900"}}}),kw=[{id:zn.SUCCESS,title:Ge.t("Complete")},{id:zn.RUNNING,title:Ge.t("Running")},{id:zn.FAILED,title:Ge.t("Failed")}],Tw=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 bf(){let t=hw(),{manager:e,state:o}=mw(),n=ut(e).map(({swap:T})=>T),[r,a]=Ai(""),[s,l]=Ai(!1),p=!o.loadedFromPersistor,[u,c]=Ai(""),[m,g]=Ai(!1),f=i(T=>{let v=T.target.value;a(v)},"handleSearch"),d=wf(()=>!r&&!u?n:n.filter(T=>{let{inputAmount:v,status:w,steps:I,requestId:M}=T;return(!r||bt(v,r)||bt(w,r)||Tw(I,r)||bt(M,r))&&(!u||u===w)}),[n,r,u]),h=!d?.length&&!p,C=i(()=>g(!1),"onCloseModal"),S=i(async()=>{try{await e?.clearQueue(),g(!1)}catch(T){console.log(T)}},"onClear"),k=wf(()=>!n.some(T=>T.status===zn.SUCCESS||T.status===zn.FAILED),[n]);return ie.createElement(oe,{header:{title:Ge.t("History"),suffix:ie.createElement(Kt,null,ie.createElement(fl,{id:"widget-history-clear-btn",disabled:k,variant:"ghost",size:"xsmall",onClick:()=>g(!0)},ie.createElement(Ii,{size:"medium",variant:"label",color:"error"},Ge.t("Clear"))))}},ie.createElement(re,null,ie.createElement(Sw,null,ie.createElement(Ct,{setValue:a,fullWidth:!0,variant:"contained",placeholder:Ge.t("Search Transaction"),autoFocus:!0,onChange:f,style:{height:36},value:r}),ie.createElement(bo,{size:10,direction:"horizontal"}),ie.createElement(pl,{filterBy:u,open:s,onOpenChange:T=>l(T),onClickItem:T=>c(T),list:kw})),ie.createElement(bo,{size:"16"}),ie.createElement(yw,null,h&&ie.createElement(yf,null,ie.createElement(bo,{size:32}),ie.createElement(gw,{title:r?Ge.t("No results found"):Ge.t("No transactions"),titleColor:r?void 0:"$info",hasIcon:!!r,description:r?Ge.t("Try using different keywords"):Ge.t("Your transaction history is stored locally and will appear here after you start a swap")})),!h&&ie.createElement(dl,{list:d,onSwapClick:t,groupBy:vf,isLoading:p}))),ie.createElement(ee,{open:m,onClose:C,container:N()},ie.createElement(bo,{size:20}),ie.createElement(fw,{type:"warning",title:Ge.t("Clear Transaction History"),description:ie.createElement(Cw,null,ie.createElement(Ii,{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(Ii,{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(fl,{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(fl,{id:"widget-history-clear-modal-no-btn",variant:"outlined",type:"primary",size:"large",onClick:C},ie.createElement(Ii,{variant:"title",size:"medium",color:"primary"},Ge.t("No, Cancel")))))}i(bf,"HistoryPage");import{i18n as Hw}from"@lingui/core";import{Button as Gw,Divider as Gf,styled as Vw,WarningIcon as Kw}from"@rango-dev/ui";import jw from"bignumber.js";import Ve,{useEffect as Vf,useState as Kf}from"react";import{useNavigate as Xw}from"react-router-dom";import{i18n as Ef}from"@lingui/core";import{Alert as ww,Divider as hl,NoRouteIcon as bw,Typography as xw}from"@rango-dev/ui";import xo from"react";import{styled as vw}from"@rango-dev/ui";var xf=vw("div",{display:"flex",flexDirection:"column",alignItems:"center"});function yl(){let{fromToken:t,toToken:e}=F();return!!t&&!!e&&Bt(t,e)?xo.createElement(xf,null,xo.createElement(hl,{size:10}),xo.createElement(bw,{size:24,color:"gray"}),xo.createElement(hl,{size:4}),xo.createElement(xw,{variant:"title",size:"small"},Ef.t("No Routes Found")),xo.createElement(hl,{size:4}),xo.createElement(ww,{title:Ef.t("You cannot use the same token for From and To."),type:"warning",variant:"alarm"})):null}i(yl,"SameTokensWarning");import{i18n as Mw}from"@lingui/core";import{Header as Lw}from"@rango-dev/ui";import eo,{useEffect as Bw,useState as Pw}from"react";import{i18n as Iw}from"@lingui/core";import{Divider as Cl,FullExpandedQuote as Aw,Typography as Nw}from"@rango-dev/ui";import Se from"react";import{styled as Sl}from"@rango-dev/ui";var If=Sl("div",{display:"flex",justifyContent:"center",flexDirection:"column",height:"100%"}),Af=Sl("div",{display:"flex",justifyContent:"space-between",alignItems:"center"}),Nf=Sl("div",{width:"146px"});import{i18n as Qn}from"@lingui/core";import{Select as Ew}from"@rango-dev/ui";import Wf from"react";function Ni(t){let{updateQuotePartialState:e,sortStrategy:o}=F(),n=[{value:"SMART",label:Qn.t("Smart Routing")},{value:"FEE",label:Qn.t("Lowest Fee")},{value:"SPEED",label:Qn.t("Fastest Transfer")},{value:"NET_OUTPUT",label:Qn.t("Maximum Return")},{value:"PRICE",label:Qn.t("Maximum Output")}];return Wf.createElement(Nf,null,Wf.createElement(Ew,{container:t.container,options:n,value:o,handleItemClick:r=>{e("sortStrategy",r.value)},variant:"filled"}))}i(Ni,"SelectStrategy");var Mf=3;function qn(t){let{loading:e,onClickOnQuote:o,fetch:n,showModalFee:r,hasSort:a=!0,fullExpandedMode:s=!1,container:l}=t,{selectedQuote:p,quotes:u,updateQuotePartialState:c,fromToken:m,toToken:g,sortStrategy:f,error:d}=F(),{slippage:h,customSlippage:C}=y(),{findToken:S}=y(),k=l||N(),T=!!u&&u.results.length,v=C??h,w=i(b=>{if(!m||!g||!u)return null;let E={requestAmount:u.requestAmount,validationStatus:null,...b};return Uo(E,{fromToken:m,toToken:g,userSlippage:v,findToken:S})},"getQuoteWarning"),I=d?.type===0||d?.type===1,M=u?.results?_r(f,u?.results):[];return Se.createElement(Se.Fragment,null,a&&Se.createElement(Se.Fragment,null,Se.createElement(Af,null,Se.createElement(Nw,{size:"xmedium",variant:"title"},Iw.t("Sort by")),Se.createElement(Ni,{container:k})),Se.createElement(Cl,{size:"10"})),e&&Array.from({length:Mf},(b,E)=>Se.createElement(Se.Fragment,{key:E},s?Se.createElement(Aw,{loading:!0}):Se.createElement(Bn,{tagHidden:!1,type:"list-item",expanded:!1}),E!==Mf-1&&Se.createElement(Cl,{size:16}))),!e&&Se.createElement(Se.Fragment,null,T?M.map((b,E)=>{let x=w(b),W=Qs(b.swaps),D=M.length-1===E;return Se.createElement(Se.Fragment,{key:b.requestId},Se.createElement(vo,{showModalFee:r,container:k,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:A=>{W||c("warning",x),c("error",W?.options||null),o(A)},type:"list-item"}),!D&&Se.createElement(Cl,{size:16}))}):I&&Se.createElement(If,null,Se.createElement(bn,{size:s?"large":"small",error:d,fetch:n}))))}i(qn,"Quotes");import{darkTheme as Ww,styled as Lf}from"@rango-dev/ui";var Bf=Lf("div",{transition:"width 0.2s, opacity 0.2s, margin-left 0.2s",height:"700px",width:"390px",opacity:1,marginLeft:"$16",backgroundColor:"$neutral100",[`.${Ww} &`]:{backgroundColor:"$neutral300"},variants:{expandMode:{default:{width:"390px"},full:{width:"719px"}}},"&.is-hidden":{width:0,height:0,opacity:0,marginLeft:0}}),Pf=Lf("div",{position:"relative",overflow:"hidden",padding:"$20",flexGrow:1,display:"flex",flexDirection:"column",overflowY:"auto",borderRadius:"$primary",backgroundColor:"$background"});var Dw=100;function kl(t){let{fetch:e,loading:o,onClickOnQuote:n,onClickRefresh:r,isVisible:a}=t,[s,l]=Pw(!1),p=s?"":"is-hidden",{config:u}=y(),c=u?.variant==="full-expanded",m=ln();return Bw(()=>{let g=null;return a?g=setTimeout(()=>{l(!0)},Dw):(l(!1),g&&clearTimeout(g)),()=>{g&&clearTimeout(g)}},[a]),eo.createElement(Bf,{expandMode:u?.variant==="full-expanded"?"full":"default",className:`${p} ${Hr()}`,id:_e.EXPANDED_BOX_ID},eo.createElement(Lw,{title:Mw.t("Routes"),suffix:eo.createElement(eo.Fragment,null,eo.createElement(Ni,{container:m}),eo.createElement(yo,{container:m,onClickRefresh:r,hidden:["history","notifications","settings"]}))}),eo.createElement(Pf,null,eo.createElement(qn,{showModalFee:!1,fetch:e,hasSort:!1,loading:o,container:ln(),onClickOnQuote:n,fullExpandedMode:c})))}i(kl,"ExpandedQuotes");import{i18n as zf}from"@lingui/core";import{SwapInput as Qf}from"@rango-dev/ui";import Hn from"react";import{ReverseIcon as Fw}from"@rango-dev/ui";import vl from"react";import{keyframes as _w,styled as Df}from"@rango-dev/ui";var Tl=450,$w=_w({"0%":{transform:"rotateX(0deg) rotateY(0deg) rotateZ(0deg)"},"33%":{transform:"rotateX(0deg) rotateZ(78deg) rotateY(66deg)"},"66%":{transform:"rotateX(0deg) rotateZ(163deg) rotateY(66deg)"},"100%":{transform:"rotateX(0deg) rotateZ(180deg) rotateY(0deg)"}}),_f=Df("div",{position:"absolute",bottom:"-12px",left:"50%",transform:"translate(-50%, 10%)",cursor:"pointer"}),$f=Df("div",{borderRadius:"$md",border:"3px solid $background",background:"$neutral100",width:"$24",height:"$24",display:"flex",justifyContent:"center",alignItems:"center",color:"$foreground","&.rotate":{"& svg":{animation:`${$w} ${Tl}ms ease-in-out forwards`}},"&:hover":{color:"$secondary500",transform:"translateY(1px) scale(1.04)",boxShadow:"1px 1px 1px 1px rgba(0, 0, 0, 0.05)"}});function wl(){let t=F.use.switchFromAndTo();return vl.createElement(_f,null,vl.createElement($f,{onClick:e=>{let o=e.currentTarget;o.classList.add("rotate"),setTimeout(()=>{o.classList.remove("rotate")},Tl),t()}},vl.createElement(Fw,{size:12})))}i(wl,"SwitchFromAndToButton");import{styled as Ff}from"@rango-dev/ui";var Of=Ff("div",{display:"flex",flexDirection:"column",gap:"$5",alignSelf:"stretch"}),Uf=Ff("div",{position:"relative"});function bl(t){let{fetchingQuote:e,fetchMetaStatus:o,onClickToken:n,isExpandable:r}=t,{fromToken:a,fromBlockchain:s,toToken:l,toBlockchain:p,setInputAmount:u,inputAmount:c,inputUsdValue:m,outputAmount:g,outputUsdValue:f,selectedQuote:d}=F(),{connectedWallets:h,getBalanceFor:C}=R(),S=a?C(a):null,k=fr(S)?.amount??"0",T=s&&a?L(S?.amount,S?.decimals):"0",v=!!s&&Up(h,s.name),w=!La(d,c,m),I=!La(d,c,f),M=!m||!f||!f.gt(0)?null:ct(m.toString(),f.toString());return Hn.createElement(Of,null,Hn.createElement(Uf,null,Hn.createElement(Qf,{label:zf.t("From"),mode:"From",onInputChange:u,balance:k,chain:{displayName:s?.displayName||"",image:s?.logo||""},token:{displayName:a?.symbol||"",image:a?.image||""},onClickToken:()=>n("from"),price:{value: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}),Hn.createElement(wl,null)),Hn.createElement(Qf,{sharpBottomStyle:!r&&(!!d||e),label:zf.t("To"),mode:"To",fetchingQuote:e,chain:{displayName:p?.displayName||"",image:p?.logo||""},token:{displayName:l?.symbol||"",image:l?.image||""},percentageChange:L(ct(m,f),2,2),warningLevel:Dt(M??0),price:{value:L(g,6,6),usdValue:I?void 0:L(f,4,4),realValue:g?.toString(),realUsdValue:I?void 0:f?.toString(),error:I?te().unknownPriceError.impactTitle:void 0},onClickToken:()=>n("to"),disabled:o==="failed",loading:o==="loading",tooltipContainer:N()}))}i(bl,"Inputs");import{useCallback as Ow,useEffect as Uw,useRef as zw,useState as Qw}from"react";function qf(){let{fetch:t,loading:e,cancelFetch:o}=Si({request:async(n,r)=>await Et().getAllRoutes(n,r)});return{fetch:t,loading:e,cancelFetch:o}}i(qf,"useFetchAllQuotes");var qw=600;function Wi({refetchQuote:t}){let{fetch:e,cancelFetch:o}=qf(),{excludeLiquiditySources:n,routing:r}=y().config,a=R.use.connectedWallets(),{fromToken:s,toToken:l,inputAmount:p,inputUsdValue:u,selectedQuote:c,sortStrategy:m,resetQuote:g,error:f,warning:d,setSelectedQuote:h,updateQuotePartialState:C}=F(),{slippage:S,customSlippage:k,affiliatePercent:T,affiliateRef:v,affiliateWallets:w,fetchStatus:I}=y(),M=y().getLiquiditySources(),b=y().getDisabledLiquiditySources(),E=y().excludeLiquiditySources(),{findToken:x}=y(),[W,D]=Qw(!0),A=zw(p),Z=k??S,J=!s||!l||Bt(s,l)||!cn(p),B=i(V=>{D(V)},"resetState"),K=i(V=>{let{fromToken:fe,toToken:ge,inputAmount:Pe,liquiditySources:z,excludeLiquiditySources:je,disabledLiquiditySources:vt,slippage:lt,affiliateRef:wt,affiliatePercent:$,affiliateWallets:Q}=V;if(W||B(!0),!J&&fe&&ge){g();let H=Gc({fromToken:fe,toToken:ge,inputAmount:Pe,liquiditySources:z,excludeLiquiditySources:je,disabledLiquiditySources:vt,wallets:a,slippage:lt,affiliateRef:wt,affiliatePercent:$,affiliateWallets:Q});Lo("experimental",r)&&(H.experimental=!0),Lo("avoidNativeFee",r)&&(H.avoidNativeFee=!0),Lo("enableCentralizedSwappers",r)&&(H.enableCentralizedSwappers=!0),r?.maxLength&&(H.maxLength=r.maxLength),e(H).then(ne=>{let le=_r(m,ne.results),pe=iu(c,le,ne.requestAmount);D(!1),C("quotes",ne),h(pe),Ci({diagnosisMessages:ne.diagnosisMessages,requestId:pe?.requestId||"",swaps:pe?.swaps});let Oe=go(pe)||ge?.usdPrice,tr=Sn(pe)||fe?.usdPrice,io=pe&&Uo(pe,{fromToken:{...fe,usdPrice:tr},toToken:{...ge,usdPrice:Oe},userSlippage:Z,findToken:x});C("warning",io)}).catch(ne=>{let{error:le}=ki(ne);(le?.type===0||le?.type===1)&&g(),le?.type!==2&&(C("error",le),D(!1))})}},"fetch"),me=Ow(Ep(V=>{K(V)},qw),[J]);return Uw(()=>{if(!t){D(!1);return}if(I!=="success")return;if(J){D(!1),(c||f||d)&&g();return}if(!cn(p)||u?.eq(0)){B(!1),o();return}g(),B(!0);let V=K;return A.current&&A.current!=p&&(V=me),A.current=p,V({inputAmount:p,fromToken:s,toToken:l,liquiditySources:M,excludeLiquiditySources:E,disabledLiquiditySources:b,slippage:Z,affiliateRef:v,affiliatePercent:T,affiliateWallets:w}),o},[I,p,s?.symbol,s?.address,s?.blockchain,l?.symbol,l?.address,l?.blockchain,J,M?.length,n,b.length,Z,v,T,JSON.stringify(w)]),{fetch:()=>K({inputAmount:p,fromToken:s,toToken:l,liquiditySources:M,excludeLiquiditySources:E,disabledLiquiditySources:b,slippage:Z,affiliateRef:v,affiliatePercent:T,affiliateWallets:w}),loading:W}}i(Wi,"useSwapInput");function Hf(t,e){let o=!1,n={preventDefault(){o=!0},...t.payload===void 0&&{payload:t.payload}};he.emit("uiEvent",{type:t.type,payload:n}),o||e()}i(Hf,"emitPreventableEvent");var Yw=Vw("div",{display:"flex",alignItems:"flex-start",maxHeight:700,"& .footer__alert":{paddingTop:"0 !important"}}),Zw=300;function jf(){let t=Xw(),{fromToken:e,toToken:o,inputAmount:n,selectedQuote:r,refetchQuote:a,error:s,warning:l,quotes:p,setSelectedQuote:u,resetQuoteWallets:c,setQuoteWarningsConfirmed:m,updateQuotePartialState:g}=F(),[f,d]=Kf(!1),{isLargeScreen:h,isExtraLargeScreen:C}=ci(),{fetch:S,loading:k}=Wi({refetchQuote:a}),{config:T,fetchStatus:v}=y(),{connectedWallets:w}=R(),{isActiveTab:I}=se(),[M,b]=Kf(!1),x=Oc({fetchMetaStatus:v,fetchingQuote:k,inputAmount:n,quote:r,anyWalletConnected:w.length>0,error:s,warning:l,needsToWarnEthOnPath:!1}),W=Kp(h,C,T?.variant),D=!!n&&!!e&&!!o&&new jw(n).gt(0)&&!eu(e,o),A=D&&v==="success"&&k,J=(!W||W&&p?.results.length)&&(l||s);Vf(()=>{c(),g("refetchQuote",!0)},[]),Vf(()=>{d(D)},[D]);let B=(r||s)&&!M?S:void 0,K=i(V=>{W&&f?(d(!1),setTimeout(()=>{t(V)},Zw)):t(V)},"onHandleNavigation"),me=i(V=>{r?.requestId!==V.requestId&&(b(!1),u(V))},"onClickOnQuote");return Ve.createElement(Yw,null,Ve.createElement(oe,{height:"auto",footer:Ve.createElement(Gw,{id:`widget-swap-${x.action}-btn`,type:"primary",size:"large",disabled:x.disabled||!I,prefix:x.action==="confirm-warning"&&Ve.createElement(Kw,null),fullWidth:!0,onClick:()=>{x.action==="connect-wallet"?Hf({type:"clickConnectWallet"},()=>K(_.wallets)):x.action==="confirm-warning"?b(!0):K(_.confirmSwap)}},x.title),header:{onWallet:()=>{K(_.wallets)},hasBackButton:!1,title:T.title||Hw.t("Swap"),suffix:Ve.createElement(yo,{hidden:W?["refresh"]:void 0,onClickRefresh:B,onClickHistory:()=>K(_.swaps),onClickSettings:()=>{K(_.settings)}})}},Ve.createElement(re,null,Ve.createElement(bl,{fetchingQuote:A,fetchMetaStatus:v,isExpandable:W,onClickToken:V=>{K(V==="from"?_.fromSwap:_.toSwap)}}),Ve.createElement(Gf,{size:"2"}),W?null:Ve.createElement(vo,{quote:r,loading:A,error:s,tagHidden:!1,warning:l,type:"basic",onClickAllRoutes:p&&p.results.length>1?()=>{g("refetchQuote",!1),K(_.routes)}:void 0}),J?Ve.createElement(Ve.Fragment,null,Ve.createElement(Gf,{size:"10"}),Ve.createElement(En,{warning:l,error:s,couldChangeSettings:!0,refetchQuote:S,showWarningModal:M,confirmationDisabled:!I,onOpenWarningModal:()=>b(!0),onCloseWarningModal:()=>b(!1),onConfirmWarningModal:()=>{b(!1),m(!0),K(_.confirmSwap)},onChangeSettings:()=>K(_.settings)})):null,Ve.createElement(yl,null))),W?Ve.createElement(kl,{loading:A,onClickOnQuote:me,fetch:S,onClickRefresh:B,isVisible:f}):null)}i(jf,"Home");import{i18n as Xf}from"@lingui/core";import{Alert as Jw,Divider as Rw,List as eb,ListItemButton as tb,Radio as ob,RadioRoot as nb,Typography as rb}from"@rango-dev/ui";import Mt from"react";function to(){let{setLanguage:t,language:e,config:o}=y(),n=Jp,r=o?.language||Bo;return{activeLanguage:e||r,languages:n,defaultLanguage:r,changeLanguage:a=>t(a||Bo),resetLanguage:()=>t(null)}}i(to,"useLanguage");function Yf(){let{activeLanguage:t,changeLanguage:e,languages:o}=to(),n=Ze(),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(rb,{variant:"title",size:"xmedium"},l),onClick:()=>{e(a.local),n()},end:Mt.createElement(ob,{value:s}),start:Mt.createElement(p,null)}});return Mt.createElement(oe,{header:{title:Xf.t("Language")}},Mt.createElement(re,null,Mt.createElement(Jw,{type:"warning",variant:"alarm",title:"Warning: We are using machine translation, so the translations may be inaccurate."}),Mt.createElement(Rw,{size:"8"}),Mt.createElement(nb,{value:t},Mt.createElement(eb,{type:Mt.createElement(tb,{title:Xf.t("language"),id:"_",onClick:()=>console.log()}),items:r}))))}i(Yf,"LanguagePage");import{i18n as zt}from"@lingui/core";import{Button as pb,Checkbox as cb,Image as ub,ListItemButton as mb,NotFound as db,Typography as fb}from"@rango-dev/ui";import Ke,{useState as gb}from"react";import{Checkbox as sb,Skeleton as Jf}from"@rango-dev/ui";import Vn from"react";import{styled as xl}from"@rango-dev/ui";var Gn=xl("ul",{padding:"$15 $5 0",margin:0,listStyle:"none",height:"100%",overflowY:"auto",variants:{disabled:{true:{pointerEvents:"none"}}}}),El=xl("div",{width:80,display:"flex",justifyContent:"flex-end"}),Il=xl("div",{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%"});import{ListItem as ib,styled as ab}from"@rango-dev/ui";var Zf=ab(ib,{height:61});var lb=30;function Al(){return Vn.createElement(Gn,null,Array.from(Array(lb),(t,e)=>Vn.createElement(Zf,{hasDivider:!0,key:e,start:Vn.createElement(Jf,{variant:"circular",width:35,height:35}),title:Vn.createElement(Jf,{variant:"text",size:"large",width:90}),end:Vn.createElement(sb,{checked:!1})})))}i(Al,"LoadingLiquiditySourceList");function Nl({sourceType:t}){let e=y().fetchStatus,o=y().swappers(),n=y().getDisabledLiquiditySources(),[r,a]=gb(""),s=y().toggleLiquiditySource,l=y().isInCampaignMode(),p=Sr(o,n),u={Exchanges:zt.t("Exchanges"),Bridges:zt.t("Bridges")},c=[];t==="Exchanges"&&c.push("DEX"),t==="Bridges"&&c.push("BRIDGE","AGGREGATOR","OFF_CHAIN");let m=p.filter(S=>c.includes(S.type)),g=m.length===m.filter(S=>S.selected).length,f=i(()=>{m.forEach(S=>{g?s(S.groupTitle):S.selected||s(S.groupTitle)})},"toggleAllSources"),d=m.map(S=>{let{selected:k,groupTitle:T,logo:v,id:w,...I}=S;return{id:`widget-setting-liquidity-source-${w.toLowerCase().replace(/\s+/g,"-")}-item-btn`,start:Ke.createElement(ub,{src:v,size:22,type:"circular"}),onClick:()=>{l||s(T)},end:Ke.createElement(cb,{checked:k,disabled:l}),title:Ke.createElement(fb,{variant:"title",size:"xmedium"},zt.t(T)),selected:k,groupTitle:T,logo:v,...I}}),h=i(S=>{let k=S.target.value;a(k)},"handleSearch"),C=d;return r&&(C=d.filter(S=>bt(S.groupTitle,r))),Ke.createElement(oe,{header:{title:zt.t(t),suffix:Ke.createElement(El,null,Ke.createElement(pb,{id:`widget-liquidity-source-${g?"deselect-all":"select-all"}-btn`,variant:"ghost",size:"xsmall",onClick:f},g?zt.t("Deselect all"):zt.t("Select all")))}},Ke.createElement(re,{view:!0},Ke.createElement(Ct,{value:r,setValue:a,fullWidth:!0,color:"light",variant:"contained",placeholder:zt.t("Search {sourceType}",{sourceType:u[t]}),onChange:h}),e==="loading"&&Ke.createElement(Al,null),!C.length&&r?Ke.createElement(Il,null,Ke.createElement(db,{title:zt.t("No results found"),description:zt.t("Try using different keywords")})):e==="success"&&Ke.createElement(Gn,{disabled:l},C.map(S=>{let{groupTitle:k,...T}=S;return Ke.createElement(Ke.Fragment,{key:S.id},Ke.createElement(mb,{style:{height:"61px"},...T,selected:!1,hasDivider:!0}))}))))}i(Nl,"LiquiditySourcePage");import{i18n as hb}from"@lingui/core";import Mi from"react";import{useNavigate as yb}from"react-router-dom";function Rf(){let t=yb(),e=Ze(),{selectedQuote:o,refetchQuote:n,setSelectedQuote:r,updateQuotePartialState:a,error:s}=F(),{fetch:l,loading:p}=Wi({refetchQuote:n}),u=i(g=>{r(g),a("refetchQuote",!1),e()},"onClickOnQuote"),c=`../${_.settings}`,m=`../${_.wallets}`;return Mi.createElement(oe,{header:{onWallet:()=>{t(m),a("refetchQuote",!0)},onBack:()=>{a("refetchQuote",!1)},title:hb.t("Routes"),suffix:Mi.createElement(yo,{onClickRefresh:o||s?l:void 0,hidden:["notifications","history"],onClickSettings:()=>{t(c),a("refetchQuote",!0)}})}},Mi.createElement(re,null,Mi.createElement(qn,{fetch:l,loading:p,onClickOnQuote:u})))}i(Rf,"RoutesPage");import{i18n as ag}from"@lingui/core";import{Divider as sg,getCategoriesCount as Ib,SelectableCategoryList as Ab}from"@rango-dev/ui";import Qt,{useState as lg}from"react";import{useNavigate as Nb}from"react-router-dom";import{i18n as Wl}from"@lingui/core";import{Divider as Tb,Image as vb,ListItemButton as wb,NotFound as bb,Typography as ig}from"@rango-dev/ui";import it,{useEffect as xb,useState as Eb}from"react";var eg=i((t,e,o)=>t.filter(n=>sr(n.type,o)).filter(n=>et(n.name,e)||et(n.displayName,e)),"filterBlockchains");import{ImageContainer as Sb,styled as tg}from"@rango-dev/ui";var og=tg("div",{display:"flex",flexDirection:"column",overflow:"hidden",height:"100%",justifyContent:"center"}),Li=tg(kn,{padding:0,margin:0,listStyle:"none",[`& ${Sb}`]:{borderRadius:"$xm",overflow:"hidden"}});import{ListItem as Cb,Skeleton as ng}from"@rango-dev/ui";import Bi from"react";var kb=20;function rg(){return Bi.createElement(Li,null,Array.from(Array(kb),t=>Bi.createElement(Cb,{key:t,hasDivider:!0,start:Bi.createElement(ng,{variant:"circular",width:35,height:35}),title:Bi.createElement(ng,{variant:"text",size:"large",width:90})})))}i(rg,"LoadingBlockchainList");function Ml(t){let{list:e,searchedFor:o,onChange:n,blockchainCategory:r,showTitle:a=!0}=t,[s,l]=Eb(e),{fetchStatus:p}=y();xb(()=>{l([...eg(e,o,r)])},[e,o,r]);let u=i(()=>!s.length&&o?it.createElement(bb,{title:Wl.t("No results found"),description:Wl.t("Try using different keywords")}):it.createElement(Li,{as:"ul",key:`${r}-${o}`},s.map(c=>it.createElement(wb,{key:`${c.name}-${c.chainId}`,className:"widget-blockchain-list-item-btn",hasDivider:!0,onClick:()=>n(c),start:it.createElement(vb,{src:c.logo,size:30}),title:it.createElement(ig,{variant:"title",size:"medium"},c.displayName),id:c.name}))),"renderList");return it.createElement(it.Fragment,null,a&&it.createElement(it.Fragment,null,it.createElement(ig,{variant:"label",size:"large"},Wl.t("Select Chain")),it.createElement(Tb,{size:4})),it.createElement(og,null,p==="loading"&&it.createElement(rg,null),p==="success"&&u()))}i(Ml,"BlockchainList");function Pi(t){let{type:e}=t,o=Ze(),[n,r]=lg(""),[a,s]=lg("ALL"),l=F.use.setToBlockchain(),p=F.use.setFromBlockchain(),{fetchStatus:u}=y(),c=Nb(),m=y().blockchains({type:e}),g=Ib(m),f=!t.hideCategory&&g!==1;return Qt.createElement(oe,{header:{title:ag.t("Select Chain")}},Qt.createElement(re,{view:!0},f&&Qt.createElement(Qt.Fragment,null,Qt.createElement(Ab,{setCategory:s,category:a,blockchains:m,isLoading:u==="loading"}),Qt.createElement(sg,{size:24})),Qt.createElement(Ct,{value:n,autoFocus:!0,placeholder:ag.t("Search Chain"),color:"light",variant:"contained",size:"large",setValue:()=>r(""),onChange:d=>r(d.target.value)}),Qt.createElement(sg,{size:16}),Qt.createElement(Ml,{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(Pi,"SelectBlockchainPage");import{i18n as _i}from"@lingui/core";import{Divider as fg}from"@rango-dev/ui";import Eo,{useState as $b}from"react";import{useNavigate as Fb}from"react-router-dom";import{i18n as Pl}from"@lingui/core";import{BlockchainsChip as Di,Divider as mg,Image as dg,Skeleton as Pb,Tooltip as Db,Typography as Dl}from"@rango-dev/ui";import Le from"react";import{useEffect as Lb}from"react";var pg=["ETH","COSMOS","OSMOSIS"];function Ll(t,e,o){let n=JSON.parse(JSON.stringify(t)),r=[];if(n.sort(Wb),o?.limit&&t.length>o.limit){let a=o.limit,s=e;if(e.length<=o.limit){let l=o.limit-e.length;for(let p=0;p<=l;p++){let u=n[p];s=s.filter(c=>u.name!==c)}}n.sort(Mb(s)),r=n.splice(a)}return{list:n,more:r}}i(Ll,"prepare");function Wb(t,e){let o=pg,n=o.findIndex(l=>l===t.name),r=o.findIndex(l=>l===e.name),a=n>-1,s=r>-1;return a&&s?n>r?1:-1:a?-1:s?1:0}i(Wb,"sortByMostUsedBlockchains");function Mb(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(Mb,"generateSortByPreferredBlockchainsFor");function cg(t,e){return!!e.list.find(o=>o.name===t)}i(cg,"isInVisibleList");function Bl(t,e){let{preferredBlockchains:o,addPreferredBlockchain:n}=y();Lb(()=>{if(e?.selected){let a=Ll(t,o,e);cg(e.selected,a)||n(e?.selected)}},[e?.selected]);let r=Ll(t,o,e);return{list:r.list,more:r.more,history:[]}}i(Bl,"usePrepareBlockchainList");import{styled as Bb}from"@rango-dev/ui";var ug=Bb("div",{display:"grid",gap:"$10",gridTemplateColumns:"repeat(6, minmax(0, 1fr))"});var _b=12;function _l(t){let{blockchains:e,type:o,blockchain:n,onChange:r,onMoreClick:a}=t,s=Bl(e,{limit:10,selected:n?.name}),{fetchStatus:l}=y(),p=F.use.resetToBlockchain(),u=F.use.resetFromBlockchain(),c=s.more.length>0,m=s.more.length===1,g=!m&&c;return Le.createElement(Le.Fragment,null,Le.createElement(mg,{size:12}),Le.createElement(Dl,{variant:"label",size:"large"},Pl.t("Select Chain")),Le.createElement(mg,{size:12}),Le.createElement(ug,null,l==="loading"&&Array.from(Array(_b),f=>Le.createElement(Pb,{key:f,variant:"rounded",height:50})),l==="success"&&Le.createElement(Le.Fragment,null,Le.createElement(Di,{selected:!n,onClick:()=>{o==="from"?u():p()}},Le.createElement(Dl,{variant:"body",size:"xsmall",color:"secondary500"},Pl.t("All"))),s.list.map(f=>Le.createElement(Db,{key:f.name,content:f.shortName,side:"bottom",sideOffset:2,container:N()},Le.createElement(Di,{key:f.name,selected:!!n&&n.name===f.name,onClick:()=>r(f)},Le.createElement(dg,{src:f.logo,size:30})))),m?Le.createElement(Di,{key:s.more[0].name,selected:!!n&&n.name===s.more[0].name,onClick:()=>r(s.more[0])},Le.createElement(dg,{src:s.more[0].logo,size:30})):null,g?Le.createElement(Di,{onClick:a,key:"more-blockchains"},Le.createElement(Dl,{variant:"body",size:"xsmall",color:"secondary500"},Pl._("More +{count}",{count:s.more.length}))):null)))}i(_l,"BlockchainsSection");function $l(t){let{type:e}=t,o=Fb(),n=Ze(),{fromBlockchain:r,toBlockchain:a,setFromToken:s,setToToken:l,setFromBlockchain:p,setToBlockchain:u}=F(),c=R.use.getBalanceFor(),[m,g]=$b(""),d=(e==="source"?r:a)?.name??"",h=y().blockchains({type:e}),C=y().tokens({type:e,blockchain:d,searchFor:m,getBalanceFor:c}),S=i(v=>{e==="source"?p(v):u(v)},"updateBlockchain"),k=i(v=>{e==="source"?s({token:v,meta:{blockchains:h,tokens:C}}):l({token:v,meta:{blockchains:h,tokens:C}})},"updateToken"),T={source:_i.t("Source"),destination:_i.t("Destination")};return Eo.createElement(oe,{header:{title:_i.t("Swap {type}",{type:T[e]})}},Eo.createElement(re,null,Eo.createElement(_l,{blockchains:h,type:e=="source"?"from":"to",blockchain:e==="source"?r:a,onMoreClick:()=>o(_.blockchains),onChange:v=>{S(v)}}),Eo.createElement(fg,{size:24}),Eo.createElement(Ct,{value:m,autoFocus:!0,placeholder:_i.t("Search Token"),color:"light",variant:"contained",size:"large",setValue:()=>g(""),onChange:v=>g(v.target.value)}),Eo.createElement(fg,{size:16}),Eo.createElement($n,{list:C,selectedBlockchain:d,searchedFor:m,type:e,onChange:v=>{k(v);let w=h.find(I=>v.blockchain===I.name);w&&S(w),n()}})))}i($l,"SelectSwapItemsPage");import{i18n as Ul}from"@lingui/core";import{Alert as cx,Button as ux,styled as mx}from"@rango-dev/ui";import Io from"react";import{useInRouterContext as dx,useSearchParams as fx}from"react-router-dom";import{i18n as kg}from"@lingui/core";import{Divider as Tg,InfoIcon as Qb,SlippageIcon as qb,TextField as Hb,Tooltip as Gb,Typography as vg}from"@rango-dev/ui";import at from"react";import{Chip as Ob,styled as Kn,TextField as Ub}from"@rango-dev/ui";var gg=Kn("div",{paddingTop:"$5",padding:"$10 $5"}),hg=Kn("div",{display:"flex",flexWrap:"wrap",gap:"$10",[`& ${Ub}`]:{flex:"1 1 0",maxWidth:"127px",minWidth:"85px"}}),yg=Kn("div",{display:"flex",justifyContent:"start",alignItems:"center",paddingBottom:"$10"}),$i=Kn("div",{maxWidth:"280px",padding:"$10"}),Sg=Kn(Ob,{width:"61px",flexShrink:0});import{i18n as Fl}from"@lingui/core";import{Typography as zb}from"@rango-dev/ui";import jn from"react";function Cg(){return jn.createElement($i,null,jn.createElement(zb,{variant:"label",size:"medium",color:"neutral700"},Fl.t("Your transaction will be reverted if the price changes unfavorably by more than this percentage."),jn.createElement("br",null),jn.createElement("br",null),jn.createElement("b",null,Fl.t("Warning")),":\xA0",Fl.t("This setting is applied to each step (e.g. 1Inch, Thorchain, etc.), meaning only that specific step will be reverted, not the entire route.")))}i(Cg,"SlippageTooltipContent");function Ol(){let{slippage:t,setSlippage:e,customSlippage:o,setCustomSlippage:n}=y();return at.createElement(gg,null,at.createElement(yg,null,at.createElement(qb,{size:16,color:"gray"}),at.createElement(Tg,{direction:"horizontal",size:4}),at.createElement(vg,{variant:"title",size:"xmedium"},kg.t("Slippage tolerance per swap")),at.createElement(Tg,{direction:"horizontal",size:4}),at.createElement(Gb,{container:N(),side:"top",sideOffset:4,content:at.createElement(Cg,null)},at.createElement(Qb,{color:"gray"}))),at.createElement(hg,null,Rp.map((r,a)=>{let s=`slippage-${a}`;return at.createElement(Sg,{key:s,onClick:()=>{o&&n(null),e(r)},selected:!o&&r===t,label:`${r.toString()}%`})}),at.createElement(Hb,{type:"number",min:"0.01",max:"30",step:"0.01",fullWidth:!0,variant:"contained",value:o===null?"":o,color:"dark",onChange:r=>{let a=r.target.value,s=parseFloat(a);s>=nc&&s<=oc?n(s):n(null)},suffix:o&&at.createElement(vg,{variant:"body",size:"small"},"%"),placeholder:kg.t("Custom")})))}i(Ol,"Slippage");import{i18n as dt}from"@lingui/core";import{AutoThemeIcon as wg,BridgesIcon as Vb,ChevronRightIcon as Fi,DarkModeIcon as bg,Divider as Xn,ExchangeIcon as Kb,InfinityIcon as jb,InfoIcon as Xb,LanguageIcon as Yb,LightModeIcon as xg,List as Zb,ListItem as Jb,ListItemButton as Rb,Skeleton as ex,styled as tx,Switch as ox,Tabs as nx,TargetIcon as rx,Tooltip as ix,Typography as Re}from"@rango-dev/ui";import P from"react";import{useNavigate as ax}from"react-router-dom";var sx=tx("div",{width:"202px",height:"$40"}),lx=[{id:"light",icon:P.createElement(xg,{color:"black",size:24}),tooltip:P.createElement(Re,{size:"xsmall",variant:"body"},dt.t("Light"))},{id:"dark",icon:P.createElement(bg,{color:"black",size:24}),tooltip:P.createElement(Re,{size:"xsmall",variant:"body"},dt.t("Dark"))},{id:"auto",icon:P.createElement(wg,{color:"black",size:24}),tooltip:P.createElement(Re,{size:"xsmall",variant:"body"},dt.t("Auto"))}],px=i(t=>{let e={color:"gray",size:16};switch(t){case"auto":return P.createElement(wg,{...e});case"dark":return P.createElement(bg,{...e});default:return P.createElement(xg,{...e})}},"getThemeIcon");function Eg(){let t=ax(),{theme:e}=y().config,{setTheme:o,theme:n}=y(),{activeLanguage:r,languages:a}=to(),s=a.find(B=>B.local===r)?.label,l=y().fetchStatus,p=y().swappers(),u=y().getDisabledLiquiditySources(),{config:{features:c}}=y(),m=y().customTokens(),g=Xe("theme",c),f=Xe("liquiditySource",c),d=Xe("language",c),h=Xe("customTokens",c),C=y().infiniteApprove,S=y().toggleInfiniteApprove,k=Sr(p,u),T=k.filter(B=>["BRIDGE","AGGREGATOR","OFF_CHAIN"].includes(B.type)),v=T.length,w=T.filter(B=>B.selected).length,I=k.filter(B=>B.type==="DEX"),M=I.length,b=I.filter(B=>B.selected).length,E=i((B,K)=>{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} / ${K}`)}},"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(Xn,{direction:"horizontal",size:8}),P.createElement(Fi,{color:"black"})),onClick:()=>t(_.bridges),start:P.createElement(Vb,{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(Xn,{direction:"horizontal",size:8}),P.createElement(Fi,{color:"black"})),start:P.createElement(Kb,{color:"gray",size:16}),onClick:()=>t(_.exchanges)},D={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(Xn,{direction:"horizontal",size:8}),P.createElement(Fi,{color:"black"})),start:P.createElement(rx,{color:"gray",size:16}),onClick:()=>t(_.customTokens)},A={id:"widget-setting-language-item-btn",title:P.createElement(Re,{variant:"title",size:"xmedium"},dt.t("Language")),start:P.createElement(Yb,{color:"gray",size:16}),end:P.createElement(P.Fragment,null,P.createElement(Re,{variant:"body",size:"medium"},s),P.createElement(Xn,{direction:"horizontal",size:8}),P.createElement(Fi,{color:"black"})),onClick:()=>t(_.languages)},Z={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(Xn,{direction:"horizontal",size:4}),P.createElement(ix,{side:"top",sideOffset:4,container:N(),content:P.createElement($i,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(Xb,{color:"gray"}))),start:P.createElement(jb,{color:"gray",size:16}),end:P.createElement(ox,{checked:C}),onClick:S},ae={id:"widget-setting-theme-item-btn",type:P.createElement(Jb,null),title:P.createElement(Re,{variant:"title",size:"xmedium"},dt.t("Theme")),end:P.createElement(sx,null,P.createElement(nx,{container:N(),items:lx,value:n,onChange:B=>o(B.id),type:"primary",borderRadius:"small"})),start:px(n)},J=f?[]:[x,W];return h||J.push(D),d||J.push(A),J.push(Z),!e?.singleTheme&&!g&&J.push(ae),P.createElement(Zb,{type:P.createElement(Rb,{hasDivider:!0,id:"_",onClick:()=>console.log()}),items:J})}i(Eg,"SettingsLists");var gx=mx("div",{paddingLeft:"$8"});function Ig(){let{isInCampaignMode:t,updateCampaignMode:e}=y(),o=t(),[,n]=fx(),r=dx(),a=i(()=>{r&&o&&(n(s=>(s.delete("liquiditySources"),s),{replace:!0}),e("liquiditySources",void 0))},"onClick");return Io.createElement(oe,{header:{title:Ul.t("Settings")}},Io.createElement(re,null,o&&Io.createElement(cx,{type:"info",variant:"alarm",title:Ul.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:Io.createElement(gx,null,Io.createElement(ux,{id:"widget-setting-exit-campaign-mode-btn",type:"secondary",size:"small",onClick:a},Ul.t("Reset")))}),Io.createElement(Ol,null),Io.createElement(Eg,null)))}i(Ig,"SettingsPage");import{i18n as oE}from"@lingui/core";import{cancelSwap as nE}from"@rango-dev/queue-manager-rango-preset";import{useManager as rE}from"@rango-dev/queue-manager-react";import{Alert as iE}from"@rango-dev/ui";import np from"react";import{useParams as aE}from"react-router-dom";import{i18n as st}from"@lingui/core";import{getCurrentBlockchainOfOrNull as $x,getCurrentStep as Fx,getRelatedWalletOrNull as Ox}from"@rango-dev/queue-manager-rango-preset";import{Button as rh,CopyIcon as Ux,Divider as zx,DoneIcon as Qx,IconButton as qx,QuoteCost as Hx,RangoExplorerIcon as Gx,StepDetails as Vx,Tooltip as ih,Typography as Ao,useCopyToClipboard as Kx}from"@rango-dev/ui";import{useWallets as jx}from"@rango-dev/wallets-react";import ah from"bignumber.js";import{PendingSwapNetworkStatus as Ki}from"rango-types";import j,{useEffect as sh,useRef as Xx,useState as lh}from"react";import{useNavigate as Yx}from"react-router-dom";import{i18n as oo}from"@lingui/core";var hx=[oo.t("Sunday"),oo.t("Monday"),oo.t("Tuesday"),oo.t("Wednesday"),oo.t("Thursday"),oo.t("Friday"),oo.t("Saturday")];function Ag(t){let e=new Date(t),o=e.getDate(),n=e.toLocaleString("default",{month:"long"}),r=e.getFullYear();return`${e.getDay()===new Date().getDay()?oo.t("Today"):`${hx[e.getDay()]} ${o} ${n} ${r}`}, ${new Date(t).toLocaleTimeString()}`}i(Ag,"timeSince");function Ng(t){return t.finishTime?Ag(parseInt(t.finishTime)):Ag(parseInt(t.creationTime))}i(Ng,"getSwapDate");import{PendingSwapNetworkStatus as zi}from"rango-types";import Qi from"react";import{i18n as Oi}from"@lingui/core";import{Button as Wg,Divider as zl,MessageBox as yx}from"@rango-dev/ui";import no from"react";var Mg=i(({onCancel:t,onClose:e})=>no.createElement(no.Fragment,null,no.createElement(zl,{size:20}),no.createElement(yx,{type:"error",title:Oi.t("Cancel Swap"),description:Oi.t("Are you sure you want to cancel this swap?")}),no.createElement(zl,{size:32}),no.createElement(Wg,{variant:"contained",id:"widget-swap-details-modal-cancel-swap-yes-btn",type:"primary",size:"large",onClick:t},Oi.t("Yes, Cancel it")),no.createElement(zl,{size:12}),no.createElement(Wg,{id:"widget-swap-details-modal-cancel-swap-no-btn",variant:"outlined",type:"primary",size:"large",onClick:e},Oi.t("No, Continue"))),"CancelContent");import{i18n as Ui}from"@lingui/core";import{Button as Lg,Divider as Ql,MessageBox as Sx,Typography as Cx}from"@rango-dev/ui";import qt from"react";var Bg=i(({onDelete:t,onClose:e})=>qt.createElement(qt.Fragment,null,qt.createElement(Ql,{size:20}),qt.createElement(Sx,{type:"error",title:Ui.t("Delete Transaction"),description:Ui.t("Are you sure you want to delete this swap?")}),qt.createElement(Ql,{size:32}),qt.createElement(Lg,{id:"widget-swap-details-modal-delete-swap-yes-btn",variant:"contained",type:"primary",size:"large",onClick:t},Ui.t("Yes, Delete it")),qt.createElement(Ql,{size:12}),qt.createElement(Lg,{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"},Ui.t("No, Cancel")))),"DeleteContent");import{i18n as ql}from"@lingui/core";import{PendingSwapNetworkStatus as Hl}from"rango-types";var Gl={[Hl.WaitingForNetworkChange]:{type:"loading",title:ql.t("Change Network")},[Hl.WaitingForConnectingWallet]:{type:"warning",title:ql.t("Connect Wallet")},[Hl.NetworkChanged]:{type:"success",title:ql.t("Network Changed")}};import{warn as kx}from"@rango-dev/logging-core";import{MessageBox as Tx,Wallet as vx}from"@rango-dev/ui";import{useWallets as wx}from"@rango-dev/wallets-react";import tn,{useState as bx}from"react";import{styled as Pg}from"@rango-dev/ui";var Dg=Pg("div",{display:"flex",justifyContent:"center"}),b5=Pg("div",{maxWidth:280,"& ._typography":{wordWrap:"break-word",display:"block"}});var _g=i(t=>{let{type:e,title:o,currentStepWallet:n,message:r,showWalletButton:a,walletButtonDisabled:s}=t,[l,p]=bx(),{getWalletInfo:u,state:c}=wx(),m=n?.walletType,g=m?un(c(m)):null,f=m?u(m):null,d=a&&!!m&&!!g&&!!f,{list:h}=ft(),C=i(()=>{if(m){let S=h.find(k=>k.type===m);S?p(S):kx(new Error(`It seems requested wallet to be connected is not available in the list. requested wallet: ${S}`))}},"handleWalletItemClick");return tn.createElement(tn.Fragment,null,tn.createElement(Tx,{type:e,title:o,description:r}),d&&tn.createElement(Dg,null,tn.createElement(vx,{container:N(),title:f.name,image:f.img,type:m,state:g,link:f.installLink,disabled:s,onClick:C})),tn.createElement(mo,{wallet:l,onClose:()=>{p(void 0)}}))},"WalletStateContent");function Vl(t){let{state:e,onClose:o,onDelete:n,onCancel:r,currentStepWallet:a,message:s,walletButtonDisabled:l}=t,p=e===zi.WaitingForNetworkChange||e===zi.WaitingForConnectingWallet||e===zi.NetworkChanged;return Qi.createElement(ee,{open:!!e,onClose:o,container:document.getElementById(_e.SWAP_BOX_ID)||document.body},p&&Qi.createElement(_g,{type:Gl[e].type,title:Gl[e].title,currentStepWallet:a,message:s,walletButtonDisabled:l,showWalletButton:e!==zi.WaitingForNetworkChange}),e==="delete"&&Qi.createElement(Bg,{onClose:o,onDelete:n}),e==="cancel"&&Qi.createElement(Mg,{onClose:o,onCancel:r}))}i(Vl,"SwapDetailsModal");import{i18n as Yn}from"@lingui/core";import{Button as Kl,Divider as qi,MessageBox as $g,TokenAmount as xx,Typography as jl}from"@rango-dev/ui";import Fe from"react";import{useNavigate as Ex}from"react-router-dom";function Xl(t){let{open:e,onClose:o,status:n,priceValue:r,usdValue:a,realUsdValue:s,realValue:l,token:p,chain:u,percentageChange:c,description:m,diagnosisUrl:g}=t,f=Ex();return Fe.createElement(ee,{open:e,onClose:o,container:document.getElementById(_e.SWAP_BOX_ID)||document.body},n==="success"?Fe.createElement($g,{type:"success",title:Yn.t("Swap Successful")},Fe.createElement(xx,{direction:"vertical",tooltipContainer:N(),type:"output",centerAlign:!0,price:{value:r,usdValue:a,realUsdValue:s,realValue:l},token:p,chain:u,percentageChange:c}),Fe.createElement(qi,{size:12}),Fe.createElement(jl,{variant:"body",size:"medium",color:"neutral700",align:"center"},m)):Fe.createElement($g,{type:"error",title:Yn.t("Transaction Failed"),description:m}),Fe.createElement(qi,{size:32}),n==="success"&&Fe.createElement(Kl,{id:"widget-swap-details-modal-done-btn",variant:"contained",type:"primary",size:"large",onClick:()=>{f("../../")}},Fe.createElement(jl,{variant:"title",size:"medium",color:"neutral100"},Yn.t("Done"))),Fe.createElement(qi,{size:12}),g&&Fe.createElement(Fe.Fragment,null,Fe.createElement(Kl,{variant:"contained",id:"widget-swap-detail-modal-diagnosis-btn",type:"primary",size:"large",onClick:()=>window.open(g,"_blank")},Yn.t("Diagnosis")),Fe.createElement(qi,{size:12})),Fe.createElement(Kl,{id:"widget-swap-details-modal-see-details-btn",variant:"outlined",type:"primary",size:"large",onClick:o},Fe.createElement(jl,{variant:"title",size:"medium",color:"primary"},Yn.t("See Details"))))}i(Xl,"SwapDetailsCompleteModal");import _x from"react";import{i18n as Lx}from"@lingui/core";import{Alert as eh,IconButton as Bx,LinkIcon as Px}from"@rango-dev/ui";import ro,{Fragment as Dx}from"react";import{Alert as Ax,ChevronDownIcon as Nx,IconButton as Wx}from"@rango-dev/ui";import nn,{useState as Mx}from"react";import{css as Zn,darkTheme as Fg,styled as Ht,Typography as Ix}from"@rango-dev/ui";var Og=Ht("div",{display:"flex",flexDirection:"column",flexGrow:1,overflow:"hidden"}),Hi=Ht("div",{width:"100%","& ._icon-button":{"&:hover":{"& svg":{color:"$secondary550",[`.${Fg} &`]:{color:"$secondary500"}}}}}),Ug=Ht(kn,{padding:"$0 $20 $20 $20"}),s4=Ht("div",{display:"flex",flexDirection:"column",gap:"$10"}),zg=Ht("div",{height:"450px",display:"flex",alignItems:"center",justifyContent:"center"}),l4=Ht("div",{display:"flex",justifyContent:"center",width:"100%",paddingTop:"33%",flex:1}),on=Zn({display:"flex",width:"100%",justifyContent:"space-between",alignItems:"center",padding:"$10 $20",borderBottom:"1px solid",$$color:"$colors$neutral300",[`.${Fg} &`]:{$$color:"$colors$neutral400"},borderColor:"$$color",color:"$neutral500"}),Qg=Zn({padding:"$5 0"}),Gi=Zn({display:"flex",justifyContent:"center",alignItems:"center",height:"$24"}),qg=Zn({display:"flex",width:"100%",padding:"$15 $20 $20",flexDirection:"column",alignItems:"start"}),Hg=Zn({width:"100%",padding:"0 $20 $10"}),Gg=Ht("a",{fontSize:"$16",fontWeight:"$400",color:"$neutral700",display:"flex",alignItems:"center",justifyContent:"center"}),Vg=Ht("div",{display:"flex",flexDirection:"column",gap:"$5"}),Vi=Ht(Ix,{wordBreak:"break-word"});import{styled as Yl}from"@rango-dev/ui";var Kg=Yl("div",{display:"flex",flexDirection:"column",gap:"$10"}),jg=Yl("div",{transition:"transform 0.3s ease-in-out",variants:{rotated:{true:{transform:"rotate(180deg)"}}}}),Xg=Yl("div",{transition:"max-height 0.3s ease-in-out",maxHeight:"0px",overflow:"hidden",variants:{open:{true:{maxHeight:"200px"}}}});function Yg(t){let{message:e}=t,[o,n]=Mx(!1);return nn.createElement(Ax,{type:"error",title:e.shortMessage,containerStyles:{"& .footer":{paddingTop:"$0"}},action:e.detailedMessage.content&&nn.createElement(Wx,{onClick:()=>n(r=>!r),variant:"ghost",size:"xsmall"},nn.createElement(jg,{rotated:o},nn.createElement(Nx,{size:12,color:"gray"}))),footer:nn.createElement(Xg,{open:o},nn.createElement(Vi,{variant:"body",size:"xsmall",color:"neutral700"},e.detailedMessage.content))})}i(Yg,"FailedAlert");import{i18n as Zg}from"@lingui/core";import{Alert as Zl,Button as Jg}from"@rango-dev/ui";import{PendingSwapNetworkStatus as Jl}from"rango-types";import Jn from"react";function Rg(t){let{switchNetwork:e,setNetworkModal:o,message:n,showNetworkModal:r}=t;return e?Jn.createElement(Zl,{type:"warning",title:n.shortMessage,action:Jn.createElement(Jg,{id:"widget-swap-details-warning-alert-change-network-btn",size:"xxsmall",type:"warning",onClick:()=>{o(Jl.WaitingForNetworkChange),e().catch(a=>{console.log(a)})}},Zg.t("Change"))}):r===Jl.WaitingForConnectingWallet?Jn.createElement(Zl,{type:"warning",title:n.shortMessage,action:Jn.createElement(Jg,{id:"widget-swap-details-warning-alert-connect-wallet-btn",size:"xxsmall",type:"warning",onClick:()=>{o(Jl.WaitingForConnectingWallet)}},Zg.t("Connect"))}):Jn.createElement(Zl,{type:"warning",title:n.shortMessage})}i(Rg,"WarningAlert");function Rl(t){let{switchNetwork:e,showNetworkModal:o,setNetworkModal:n,message:r,step:a,hasAlreadyProceededToSign:s}=t,l=yn(a),p=a.status==="waitingForApproval"&&!l,u=a.status==="running"&&!l,c=u&&!s||p&&!a.explorerUrl?.length;return ro.createElement(Kg,null,a.explorerUrl?.map((m,g,f)=>{let d=g+m.url,h=g===f.length-1,C=(h&&u||p)&&!c,S=h&&a.status==="failed";return ro.createElement(Dx,{key:d},ro.createElement(eh,{type:h&&(C&&"loading"||S&&"error")||"success",title:m.description?`${m.description} Tx`:Lx.t("View transaction"),action:m.url&&ro.createElement(Bx,{id:"widget-swap-details-tx-link-icon-btn",variant:"ghost",size:"xsmall",onClick:()=>window.open(m.url,"_blank")},ro.createElement(Px,{size:12}))}))}),c&&ro.createElement(eh,{type:"loading",title:r.shortMessage}),a.status!=="failed"&&l&&ro.createElement(Rg,{switchNetwork:e,showNetworkModal:o,setNetworkModal:n,message:r}),a.status==="failed"&&ro.createElement(Yg,{message:r}))}i(Rl,"SwapDetailsAlerts");var th=2e3;var oh=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:rn(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:rn(p.swapperId,o)??"",image:p.swapperLogo??"",type:p.swapperType}})):[],alerts:_x.createElement(Rl,{step:a,hasAlreadyProceededToSign:r,...n})}})},"getSteps");function nh(t){if(yn(t)&&t.status!=="failed"&&t.status!=="success")return"warning";switch(t.status){case"created":return"default";case"approved":case"waitingForApproval":case"running":return"in-progress";case"failed":return"error";case"success":return"completed"}}i(nh,"getStepState");function ep(t){let{swap:e,requestId:o,onDelete:n,onCancel:r}=t,{canSwitchNetworkTo:a,connect:s,getWalletInfo:l}=jx(),p=y().blockchains(),u=y().swappers(),{findToken:c}=y(),m=F.use.retry(),g=se.use.isActiveTab(),f=Yx(),[d,h]=Kx(th),C=Xx(null),[S,k]=lh(null),[T,v]=lh(null),w=i(()=>{r(),k(null)},"onCancel"),I=ve.use.getNotifications(),M=ve.use.removeNotification(),b=I(),E=Fx(e),x=E?.networkStatus;sh(()=>{b.find(Oe=>Oe.requestId===e.requestId)&&(e.status==="success"||e.status==="failed"?(v(e.status),M(e.requestId)):T&&v(null))},[e.status,e.requestId]),sh(()=>{B?k(Ki.WaitingForNetworkChange):x===Ki.WaitingForConnectingWallet||x===Ki.NetworkChanged?k(x):k(null)},[x]);let W=Zc(e),D=E?$x(e,E):null,A=E?Ox(e,E):null,Z=Ng(e),ae=Jc(e),J=i(pe=>!!l(pe)?.mobileWallet,"isMobileWallet"),B=x===Ki.WaitingForNetworkChange&&!!D&&!!A?.walletType&&(J(A.walletType)||a(A.walletType,D)),K=B?s.bind(null,A.walletType,D):void 0,me=Yc(e,E),V=oh({swap:e,switchNetwork:K,showNetworkModal:x,setNetworkModal:k,message:me,blockchains:p,swappers:u}),fe=V.length,[ge,Pe]=[e.steps[0],e.steps[fe-1]],z=Pe.outputAmount||Pe.expectedOutputAmountHumanReadable,je=e.steps.reduce((pe,Oe)=>pe+parseFloat(Oe.feeInUsd||""),0),vt=e.steps.find(pe=>pe.diagnosisUrl)?.diagnosisUrl,lt=L(parseFloat(z||"0")*(Pe.toUsdPrice||0),4,4),wt=L(parseFloat(e.inputAmount)*(ge.fromUsdPrice||0),4,4),$=z?new ah(z).multipliedBy(Pe.toUsdPrice||0).toString():"",Q=new ah(e.inputAmount).multipliedBy(ge.fromUsdPrice||0).toString(),H=ct(wt,lt),ne=me.detailedMessage.content||me.shortMessage,le=e.status==="success"?st.t({id:"You have received {amount} {token} in {conciseAddress} wallet on {chain} chain.",values:{amount:L(z,6,6),token:V[fe-1].to.token.displayName,conciseAddress:gr(e.wallets[V[fe-1].to.chain.displayName]?.address||""),chain:V[fe-1].to.chain.displayName}}):j.createElement(Vg,null,j.createElement(Ao,{variant:"body",size:"medium",color:"neutral700",align:"center"},ne?"":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}})}`:""),ne&&j.createElement(Vi,{align:"center",variant:"body",size:"medium",color:"neutral700"},j.createElement("b",null,"Reason:")," ",ne));return j.createElement(oe,{header:{title:st.t("Swap Details"),onCancel:e.status==="running"?()=>k("cancel"):void 0,suffix:e.status!=="running"&&j.createElement(Kt,null,j.createElement(rh,{id:"widget-swap-details-delete-btn",variant:"ghost",type:"error",size:"xsmall",onClick:()=>k("delete")},j.createElement(Ao,{size:"medium",variant:"label",color:"error"},st.t("Delete"))))},footer:ae&&!T&&j.createElement(rh,{fullWidth:!0,id:"widget-swap-details-try-again-btn",variant:"contained",type:"primary",size:"large",onClick:()=>{let pe=Dr(e,p,c);m(pe),setTimeout(()=>{f("../../")},0)}},st.t("Try again"))},j.createElement(re,{compact:!0,view:!0},j.createElement(Hi,null,j.createElement("div",{className:on()},j.createElement(Ao,{variant:"label",size:"large",color:"neutral700"},`${st.t("Request ID")}`),j.createElement("div",{className:Gi()},j.createElement(Ao,{variant:"label",size:"small",color:"neutral700"},o),j.createElement(ih,{container:N(),content:d?st.t("Copied To Clipboard"):st.t("Copy Request ID"),open:d||void 0,side:"bottom",alignOffset:-16,align:"end"},j.createElement(qx,{id:"widget-swap-details-done-copy-icon-btn",variant:"ghost",onClick:h.bind(null,o||"")},d?j.createElement(Qx,{size:16,color:"secondary"}):j.createElement(Ux,{size:16,color:"gray"}))),j.createElement(Gg,{target:"_blank",href:`${Sp}/swap/${o}`},j.createElement(ih,{container:N(),content:st.t("View on Rango Explorer"),side:"bottom"},j.createElement(Gx,{size:20}))))),j.createElement("div",{className:on()},j.createElement(Ao,{variant:"label",size:"large",color:"neutral700"},e.finishTime?st.t("Finished at"):st.t("Created at")),j.createElement(Ao,{variant:"label",size:"small",color:"neutral700"},Z))),j.createElement("div",{className:qg()},j.createElement(Hx,{fee:L(String(je),2,2),time:pn(lr(e.steps)),steps:fe}),j.createElement(An,{from:{price:{value:L(e.inputAmount,6,6),usdValue:wt,realUsdValue:Q,realValue:e.inputAmount},token:{displayName:V[0].from.token.displayName,image:V[0].from.token.image},chain:{image:V[0].from.chain.image,displayName:V[0].from.chain.displayName}},to:{price:{value:L(z,6,6),usdValue:lt,realUsdValue:$,realValue:z||""},token:{displayName:V[fe-1].to.token.displayName,image:V[fe-1].to.token.image},chain:{image:V[fe-1].to.chain.image,displayName:V[fe-1].to.chain.displayName}},percentageChange:L(H,2,2),warningLevel:Dt(H??0)})),j.createElement("div",{className:Hg()},j.createElement(Ao,{variant:"title",size:"small"},st.t("Swaps steps"))),j.createElement(zx,{size:8}),j.createElement(Ug,{ref:C},V.map((pe,Oe)=>{let tr=Oe,io=nh(e.steps[Oe]),_h=io==="error"||io==="in-progress"||io==="warning"||io==="completed"&&Oe===V.length-1;return j.createElement(Vx,{key:tr,step:pe,type:"swap-progress",ref:C,state:io,hasSeparator:Oe!==0,tabIndex:tr,isFocused:_h,tooltipContainer:N()})}))),j.createElement(Vl,{state:S,onClose:()=>k(null),onCancel:w,onDelete:n,message:me.detailedMessage.content,currentStepWallet:A,walletButtonDisabled:!g}),j.createElement(Xl,{open:!!T,diagnosisUrl:vt,onClose:()=>v(null),status:e.status==="success"?"success":"failed",priceValue:L(z,6,6),usdValue:lt,realUsdValue:$,realValue:z||"",percentageChange:L(H,2,2),token:{displayName:V[fe-1].to.token.displayName,image:V[fe-1].to.token.image},chain:{image:V[fe-1].to.chain.image},description:le}))}i(ep,"SwapDetails");import{i18n as Xi}from"@lingui/core";import{Divider as uh,NotFound as tE,Skeleton as er,Typography as Yi}from"@rango-dev/ui";import Ce from"react";import{i18n as Zx}from"@lingui/core";import{Divider as Jx,Skeleton as Rx,Typography as eE}from"@rango-dev/ui";import ke from"react";import{css as Tt,styled as tp}from"@rango-dev/ui";var ph=tp("div",{width:"100%",height:"100%",padding:"$10 $20"}),Rn=tp("div",{backgroundColor:"$neutral100",borderRadius:"$xm",padding:"$10 $15"}),ji=tp("div",{width:"0px",height:"$20",borderLeft:"1px dashed $neutral700",marginLeft:"25px"}),k8=Tt({display:"flex",justifyContent:"space-between",alignItems:"center"}),T8=Tt({display:"flex",justifyContent:"space-between",alignItems:"center"}),v8=Tt({paddingTop:"$15",display:"flex"}),w8=Tt({padding:"$15 $0"}),b8=Tt({width:"0px",height:"$16",borderLeft:"1px solid $neutral400",marginLeft:"13px"}),x8=Tt({paddingBottom:"$10"}),E8=Tt({display:"flex",justifyContent:"start",alignItems:"center"}),I8=Tt({paddingTop:"$5",display:"flex",alignItems:"center"}),A8=Tt({display:"flex",alignItems:"center"}),N8=Tt({padding:"$4 $6",display:"flex",justifyContent:"center",alignItems:"center"}),ch=Tt({display:"flex",paddingTop:"$10",paddingBottom:"$5"});function op(){return ke.createElement(ph,null,ke.createElement(Mn,{type:"swap-preview"}),ke.createElement("div",{className:"swaps-steps"},ke.createElement(eE,{variant:"title",size:"small"},Zx.t("Swaps steps"))),ke.createElement(ke.Fragment,null,ke.createElement(Rn,null,ke.createElement(Wt,{separator:!1}),ke.createElement("div",{className:ch()},ke.createElement(Jx,{direction:"horizontal",size:20}),ke.createElement(Rx,{height:22,variant:"rectangular"}))),ke.createElement(ji,null),ke.createElement(Rn,null,ke.createElement(Wt,{separator:!1})),ke.createElement(ji,null),ke.createElement(Rn,null,ke.createElement(Wt,{separator:!1})),ke.createElement(ji,null),ke.createElement(Rn,null,ke.createElement(Wt,{separator:!1}))))}i(op,"LoadingSwapDetails");function mh(t){let{requestId:e,showSkeleton:o}=t;return Ce.createElement(oe,{header:{title:Xi.t("Swap Details"),suffix:Ce.createElement(Kt,null)}},o&&Ce.createElement(Og,null,Ce.createElement(Hi,null,Ce.createElement("div",{className:on()},Ce.createElement(Yi,{variant:"label",size:"large",color:"neutral700"},`${Xi.t("Request ID")}`),Ce.createElement("div",{className:Gi()},Ce.createElement(Yi,{variant:"label",size:"small",color:"neutral700"},Ce.createElement(er,{width:60,height:10,variant:"rounded"})),Ce.createElement(uh,{direction:"horizontal",size:4}),Ce.createElement(er,{width:16,height:16,variant:"rectangular"}),Ce.createElement(uh,{direction:"horizontal",size:4}),Ce.createElement(er,{width:16,height:16,variant:"rectangular"}))),Ce.createElement("div",{className:on()},Ce.createElement(Yi,{className:Qg(),variant:"label",size:"large",color:"neutral700"},Ce.createElement(er,{width:60,height:10,variant:"rounded"})),Ce.createElement(Yi,{variant:"label",size:"small",color:"neutral700"},Ce.createElement(er,{width:60,height:10,variant:"rounded"})))),Ce.createElement(op,null)),!o&&Ce.createElement(zg,null,Ce.createElement(tE,{title:Xi.t("Not found"),description:Xi.t({id:"Swap with request ID = {requestId} not found.",values:{requestId:e}})})))}i(mh,"SwapDetailsPlaceholder");function dh(){let{manager:t,state:e}=rE(),o=!e.loadedFromPersistor,n=ut(t),{requestId:r}=aE(),a=Ze(),{fetchStatus:s}=y();if(!r)return np.createElement(iE,{containerStyles:{margin:"20px"},type:"error",title:oE.t("The request ID is necessary to display the swap details.")});let l=o||s==="loading",p=r?n.find(({swap:g})=>g.requestId===r):void 0,u=i(()=>{if(p?.id){let g=t?.get(p.id);g&&nE(g)}},"onCancel"),c=i(async()=>{if(p?.id)try{t?.deleteQueue(p.id),a()}catch(g){console.log(g)}},"onDelete"),m=p?.swap;return!m||l?np.createElement(mh,{requestId:r,showSkeleton:l}):np.createElement(ep,{swap:m,requestId:r,onCancel:u,onDelete:c})}i(dh,"SwapDetailsPage");import{i18n as fh}from"@lingui/core";import{Divider as sE,getCategoriesCount as lE,SelectableCategoryList as pE,styled as hh,Typography as cE,Wallet as uE}from"@rango-dev/ui";import Lt,{useState as gh}from"react";var mE=hh("div",{display:"flex",justifyContent:"center",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5"}),dE=hh(re,{textAlign:"center"});function yh(){let{fetchStatus:t}=y(),[e,o]=gh("ALL"),n=y().blockchains(),{config:r}=y(),[a,s]=gh(),l=se.use.isActiveTab(),{list:p}=ft(),u=Qp(p,n),m=lE(u)!==1,g=qp(p,e),f=i(d=>{Np(p,r.multiWallets)||s(d)},"handleWalletItemClick");return Lt.createElement(oe,{header:{title:fh.t("Connect Wallets")}},Lt.createElement(dE,null,m&&Lt.createElement(Lt.Fragment,null,Lt.createElement(pE,{setCategory:o,category:e,blockchains:u,isLoading:t==="loading"}),Lt.createElement(sE,{size:24})),Lt.createElement(cE,{variant:"title",size:"xmedium",align:"center"},fh.t("Choose a wallet to connect.")),Lt.createElement(mE,null,g.map((d,h)=>{let C=`wallet-${h}-${d.type}`;return Lt.createElement(uE,{key:C,...d,container:N(),onClick:()=>f(d),isLoading:t==="loading",disabled:!l})}),Lt.createElement(mo,{wallet:a,onClose:()=>{s(void 0)}}))))}i(yh,"WalletsPage");function Sh(){return lu(),Qa(),fE([{path:_.home,element:Be.createElement(jf,null)},{path:_.routes,element:Be.createElement(Rf,null)},{path:_.fromSwap,children:[{index:!0,element:Be.createElement($l,{type:"source"})},{path:_.blockchains,element:Be.createElement(Pi,{type:"source"})}]},{path:_.toSwap,children:[{index:!0,element:Be.createElement($l,{type:"destination"})},{path:_.blockchains,element:Be.createElement(Pi,{type:"destination"})}]},{path:_.settings,children:[{index:!0,element:Be.createElement(Ig,null)},{path:_.languages,element:Be.createElement(Yf,null)},{path:_.exchanges,element:Be.createElement(Nl,{sourceType:"Exchanges"})},{path:_.bridges,element:Be.createElement(Nl,{sourceType:"Bridges"})},{path:_.customTokens,children:[{index:!0,element:Be.createElement(nf,null)},{path:_.addCustomTokens,children:[{index:!0,element:Be.createElement(qu,null)},{path:_.blockchains,element:Be.createElement(Pi,{hideCategory:!0,type:"custom-token"})}]}]}]},{path:_.swaps,children:[{index:!0,element:Be.createElement(bf,null)},{path:_.swapDetails,element:Be.createElement(dh,null)}]},{path:_.wallets,element:Be.createElement(yh,null)},{path:_.confirmSwap,element:Be.createElement(zd,null)}])}i(Sh,"AppRoutes");import{useQueueManager as wE}from"@rango-dev/queue-manager-rango-preset";import{splitWalletNetwork as bE}from"@rango-dev/wallets-shared";import{isEvmBlockchain as xE}from"rango-sdk";import{useContext as EE,useEffect as xh,useState as Eh}from"react";import{globalCss as gE}from"@rango-dev/ui";var Ch=i(()=>gE({"@import":"url('https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap')"})(),"globalFont");function kh(){let{setWatermark:t}=se();return{fetchApiConfig:i(async()=>{let o=await fetch(`${Pt("BASE_URL")}/meta/dapp/config?apiKey=${Pt("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(kh,"useFetchApiConfig");import{useWallets as hE}from"@rango-dev/wallets-react";import{useEffect as yE,useRef as SE}from"react";function Th(){let{connect:t,state:e}=hE(),o=SE({}),{fetchStatus:n}=y(),r=new URLSearchParams(location.search).get("autoConnect")||"",a=e(r);yE(()=>{n==="success"&&r&&a.installed&&!a.connecting&&!a.connected&&!o.current[r]&&(o.current[r]=!0,t(r))},[a,n])}i(Th,"useForceAutoConnect");import{isApprovalTX as CE,RouteEventType as vh,StepEventType as wh,StepExecutionEventStatus as kE,WidgetEvents as Zi}from"@rango-dev/queue-manager-rango-preset";import{useEffect as bh}from"react";function rp(){let t=R.use.connectedWallets(),e=R.use.getWalletsDetails(),o=ve.use.setNotification(),{findToken:n}=y();bh(()=>{let r=i(a=>{let{event:s,step:l,route:p}=a;if(s.type===wh.TX_EXECUTION&&s.status===kE.TX_SENT&&!CE(l)||s.type===wh.SUCCEEDED){let c=t.find(g=>g.chain===l?.fromBlockchain),m=l?.fromBlockchain!==l?.toBlockchain&&t.find(g=>g.chain===l?.toBlockchain);c&&e([c],n),m&&e([m],n)}o(s,p)},"handleStepEvent");return he.on(Zi.StepEvent,r),()=>he.off(Zi.StepEvent,r)},[he,t]),bh(()=>{let r=i(a=>{let{event:s,route:l}=a;(s.type===vh.FAILED||s.type===vh.SUCCEEDED)&&o(s,l)},"handleRouteEvent");return he.on(Zi.RouteEvent,r),()=>he.off(Zi.RouteEvent,r)},[he])}i(rp,"useSubscribeToWidgetEvents");import{useManager as TE}from"@rango-dev/queue-manager-react";import{useEffect as vE}from"react";function ip(){let{isSynced:t,syncNotifications:e}=ve(),{manager:o,state:n}=TE();vE(()=>{ve.persist.hasHydrated()&&n.loadedFromPersistor&&!t&&e(ut(o))},[ve.persist.hasHydrated(),n.loadedFromPersistor,t])}i(ip,"useSyncNotifications");function ap(){Th(),Ch(),rp(),ip();let t=y().blockchains(),{canSwitchNetworkTo:e}=Rr(),[o,n]=Eh(""),[r,a]=Eh(),s=EE(Ar),l=t.filter(xE),{fetchApiConfig:p}=kh();xh(()=>()=>su(),[]),wE({lastConnectedWallet:o,clearDisconnectedWallet:()=>{a(void 0)},disconnectedWallet:r,evmChains:l,canSwitchNetworkTo:e}),xh(()=>(lo.init(),ve.persist.hasHydrated()||ve.persist.rehydrate(),s.onConnectWallet(n),s.onDisconnectWallet(u=>{a(u),u===bE(o)?.[0]&&n("")}),p().catch(console.log),lo.destroy),[])}i(ap,"useBootstrap");import{styled as IE}from"@rango-dev/ui";var Ih=IE("div",{fontFamily:"$widget",boxSizing:"border-box",textAlign:"left","& *, *::before, *::after":{boxSizing:"inherit"},"& *:focus-visible":{outlineColor:"$info500",transition:"none"},"& ul, ol, li":{listStyleType:"none"}});function Ji(){ap();let{config:t}=y(),{activeTheme:e}=Ho(t?.theme||{}),{activeLanguage:o}=to();return sp.createElement(AE,{language:o},sp.createElement(Ih,{id:"swap-container",className:e()},sp.createElement(Sh,null)))}i(Ji,"Main");import{setSolanaSignerConfig as jE}from"@rango-dev/signer-solana";import pp,{useEffect as Bh,useMemo as XE}from"react";import{useState as NE}from"react";var WE=i(()=>{let[t,e]=NE(null),o=i(a=>{let s=document.createElement("link");return s.href=a,s.rel="stylesheet",document.head.appendChild(s),s},"loadFont"),n=i(()=>{t&&(document.head.removeChild(t),e(null))},"unloadFont");return{handleLoadCustomFont:i(a=>{n();let s=Ap(a);if(s){let l=o(s);e(l)}},"handleLoadCustomFont")}},"useFontLoader"),Ah=WE;import{checkWaitingForNetworkChange as ME,makeQueueDefinition as LE}from"@rango-dev/queue-manager-rango-preset";import{Provider as BE}from"@rango-dev/queue-manager-react";import{useWallets as PE}from"@rango-dev/wallets-react";import{convertEvmBlockchainMetaToEvmChainInfo as DE}from"@rango-dev/wallets-shared";import{isEvmBlockchain as _E}from"rango-types";import $E,{useMemo as FE}from"react";function OE(t){let{providers:e,getSigners:o,state:n,connect:r,canSwitchNetworkTo:a,getWalletInfo:s}=PE(),l=FE(()=>LE({API_KEY:t.apiKey||Pt("API_KEY"),BASE_URL:Pt("BASE_URL"),emitter:{emit:he.emit}}),[t.apiKey]),p=y().blockchains(),c={blockchains:R.use.connectedWallets().map(T=>({accounts:[T],name:T.chain}))},m=i(async(T,v)=>{if(a(T,v))return r(T,v)},"switchNetwork"),g=i(T=>!!s(T).mobileWallet,"isMobileWallet"),f=p.filter(T=>T.enabled).reduce((T,v)=>(T[v.name]=v,T),{}),d=p.filter(_E),h=i(T=>{let{supportedChains:v}=s(T);return ur(v)},"getSupportedChainNames"),C=e(),S={meta:{blockchains:f,evmBasedChains:d,evmNetworkChainInfo:DE(d),getSupportedChainNames:h},getSigners:o,wallets:c,providers:C,switchNetwork:m,canSwitchNetworkTo:a,connect:r,state:n,isMobileWallet:g},k=se.use.isActiveTab();return $E.createElement(BE,{queuesDefs:[l],context:S,onPersistedDataLoaded:T=>{ME(T)},isPaused:!k},t.children)}i(OE,"QueueManager");var Nh=OE;import{useManager as HE}from"@rango-dev/queue-manager-react";import GE,{createContext as VE,useContext as KE}from"react";function Wh(){let{findToken:t}=y(),e=y().blockchains(),o=y().tokens(),{setFromBlockchain:n,setFromToken:r,setToBlockchain:a,setToToken:s,setInputAmount:l}=F();return i(u=>{let{fromBlockchain:c,fromToken:m,toBlockchain:g,toToken:f,requestAmount:d}=u,h={blockchains:e,tokens:o};if(c!==void 0){let C=e.find(S=>S.name===c)??null;n(C)}if(m!==void 0){let C=m?t(m)??null:null;r({meta:h,token:C})}if(g!==void 0){let C=e.find(S=>S.name===g)??null;a(C)}if(f!==void 0){let C=f?t(f)??null:null;s({meta:h,token:C})}d!==void 0&&l(d)},"updateQuoteInputs")}i(Wh,"useUpdateQuoteInputs");import{cancelSwap as UE,getCurrentBlockchainOfOrNull as zE,getCurrentStep as QE,getRelatedWalletOrNull as qE}from"@rango-dev/queue-manager-rango-preset";var Ri=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=Dr(e,o.blockchains,this.actions.findToken);return this.actions.retrySwap(n)}cancel(e){let o=this.manager?.get(e);o&&UE(o)}getCurrentStepInfo(e){let o=QE(e);return{step:o,wallet:o?qE(e,o):null,network:o?zE(e,o):null}}};var Mh=VE(void 0);function lp(t){let{manager:e}=HE(),o=se.use.isActiveTab(),n=F.use.retry(),{findToken:r}=y(),a=new Ri(e,{retrySwap:n,findToken:r}),s=R.use.connectedWallets(),l=R.use.loading(),p=_p(s),u=R.use.getWalletsDetails(),c=y().blockchains(),m=y().tokens(),g=y().swappers(),f=y().fetchStatus,d=to().resetLanguage,h=ve().getNotifications(),C=ve().clearNotifications,S=Wh(),{fromBlockchain:k,toBlockchain:T,fromToken:v,toToken:w,inputAmount:I}=F(),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:g,loadingStatus:f,findToken:r},resetLanguage:d,notifications:{list:h,clearAll:C},quote:{quoteInputs:{fromBlockchain:k?.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:I},updateQuoteInputs:S}};return GE.createElement(Mh.Provider,{value:M},t.children)}i(lp,"WidgetInfo");function Lh(){let t=KE(Mh);if(!t)throw new Error("useWidget can only be used within the WidgetProvider component");return t}i(Lh,"useWidget");function ea(t){let{onUpdateState:e,config:o}=t,n=t.config?.theme?.fontFamily,{handleLoadCustomFont:r}=Ah();return Bh(()=>{n&&r(n)},[n]),XE(()=>{Hp({API_KEY:o?.apiKey||ir,BASE_URL:o?.apiUrl||yp})},[o.apiKey,o.apiUrl]),Bh(()=>{t.config?.signers?.customSolanaRPC&&jE("customRPC",t.config.signers.customSolanaRPC)},[t.config?.signers?.customSolanaRPC]),pp.createElement(Nr,{config:o,onUpdateState:e},pp.createElement(Nh,{apiKey:o.apiKey},pp.createElement(lp,null,t.children)))}i(ea,"WidgetProvider");function Ph(t){let e=t.config?.externalWallets;return ta.createElement(Bc,null,e?ta.createElement(Ji,null):ta.createElement(ea,{config:t.config??ia},ta.createElement(Ji,null)))}i(Ph,"Widget");function Dh(){let{on:t,off:e}=he;return{on:t,off:e}}i(Dh,"useWidgetEvents");var Oj={DerivationPath:fn,Namespaces:dn,isOnDerivationPath:hn,isOnNamespace:gn};export{uj as EventSeverity,so as MainEvents,Tj as Networks,bj as PendingSwapNetworkStatus,ya as QuoteEventTypes,mj as RouteEventType,aa as SUPPORTED_FONTS,Oj as StatefulConnect,dj as StepEventType,fj as StepExecutionBlockedEventStatus,gj as StepExecutionEventStatus,_e as UI_ID,Sa as UiEventTypes,kr as WalletEventTypes,Cj as WalletEvents,vj as WalletTypes,Ph as Widget,so as WidgetEvents,ea as WidgetProvider,Nr as WidgetWallets,es as customizedThemeTokens,yj as readAccountAddress,Gt as useStatefulConnect,ft as useWalletList,Rr as useWallets,Lh as useWidget,Dh as useWidgetEvents,Cr as widgetEventEmitter};
|
|
3
3
|
//# sourceMappingURL=index.js.map
|