@rango-dev/widget-embedded 0.51.1-next.7 → 0.51.1-next.8
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/Layout/Layout.constants.d.ts +5 -3
- package/dist/components/Layout/Layout.constants.d.ts.map +1 -1
- package/dist/components/Layout/Layout.d.ts.map +1 -1
- package/dist/components/Layout/Layout.styles.d.ts.map +1 -1
- package/dist/containers/App/App.styles.d.ts.map +1 -1
- package/dist/hooks/useScreenDetect.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +4 -4
- package/dist/widget-embedded.build.json +1 -1
- package/package.json +2 -2
- package/src/components/Layout/Layout.constants.ts +5 -3
- package/src/components/Layout/Layout.styles.ts +12 -5
- package/src/components/Layout/Layout.tsx +18 -32
- package/src/containers/App/App.styles.ts +1 -0
- package/src/hooks/useScreenDetect.ts +7 -1
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var CC=Object.defineProperty;var i=(t,e)=>CC(t,"name",{value:e,configurable:!0});import{EventSeverity as wee,RouteEventType as vee,StepEventType as xee,StepExecutionBlockedEventStatus as bee,StepExecutionEventStatus as Eee}from"@rango-dev/queue-manager-rango-preset";import{legacyReadAccountAddress as Aee}from"@rango-dev/wallets-core/legacy";import{useWallets as Zi,Events as Bee}from"@rango-dev/wallets-react";import{Networks as Mee,WalletTypes as Lee}from"@rango-dev/wallets-shared";import{PendingSwapNetworkStatus as _ee}from"rango-types";import{Divider as Uk}from"@rango-dev/ui";import po,{useEffect as zk,useRef as Qk,useState as kd}from"react";import{WalletState as TC}from"@rango-dev/ui";import{useWallets as kC}from"@rango-dev/wallets-react";import{useReducer as wC}from"react";function Up(t){return!!t.derivationPath}i(Up,"isStateOnDerivationPathStep");function zp(t){return!!t.namespace}i(zp,"isStateOnNamespace");var ei={status:"init",namespace:null,derivationPath:null,selectedNamespaces:null};function Qp(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"detached":return{...t,status:"detached",namespace:{targetWallet:e.payload.targetWallet},selectedNamespaces:e.payload.selectedNamespaces};case"reset":return ei;case"resetDerivation":return t.namespace?{...t,derivationPath:null,status:"namespace"}:ei;default:throw new Error("Action hasn't been defined.")}}i(Qp,"reducer");function Ro(){let{state:t,disconnect:e,connect:o}=kC(),[n,r]=wC(Qp,ei),a=i(async(m,f,h)=>{r({type:"reset"});try{let g=f?.map(d=>({...d,network:void 0}));return await o(m,g),{status:"connected"}}catch(g){let d=g?.message?`Error: ${g.message}`:"An unknown error happened during connecting wallet.";throw new Error(d,{cause:g})}},"runConnect"),s=i(async(m,f)=>{if(m.state===TC.DISCONNECTED){let g=!!m.isHub,d=g?m.properties?.find(y=>y.name==="namespaces")?.value:m.needsNamespace,S=g?m.properties?.find(y=>y.name==="derivationPath")?.value:m.needsDerivationPath;if(!d?.data?.length)return await a(m.type,void 0,f);if(d?.data.length&&d.data.length>1)return r({type:"needsNamespace",payload:{targetWallet:m,defaultSelectedChains:f?.defaultSelectedChains}}),{status:"namespace"};if(d?.data.length===1&&d.data[0]){if(S){let y=d.data[0];return r({type:"needsDerivationPath",payload:{providerType:m.type,providerImage:m.image,namespace:y.value}}),{status:"derivation-path"}}return await a(m.type,d?.data?.map(y=>({namespace:y.value})),f)}}if(m.isHub){let g=m.properties?.find(d=>d.name==="namespaces")?.value;if(g?.data.length&&g.data.length>1)return r({type:"detached",payload:{targetWallet:m,selectedNamespaces:null}}),{status:"Detached"}}return f?.disconnectIfConnected?(await u(m),{status:"disconnected"}):{status:"disconnected-unhandled"}},"handleConnect"),c=i(async(m,f)=>{let h=!!m.isHub,g=h?m.properties?.find(k=>k.name==="namespaces")?.value:m.needsNamespace,d=h?m.properties?.find(k=>k.name==="derivationPath")?.value:m.needsDerivationPath,S=g?.selection==="single",y=f[0];if(!y)throw new Error("To confirm a namespace, you should select at least one namespace.");if(S&&d)return r({type:"needsDerivationPath",payload:{providerType:m.type,providerImage:m.image,namespace:y}}),{status:"derivation-path"};if(!zp(n))throw new Error("Something went wrong on handling namespace. Please retry.");let C=f.map(k=>({namespace:k}));return r({type:"detached",payload:{targetWallet:m,selectedNamespaces:C??null}}),{status:"Detached"}},"handleNamespace"),l=i(async(m,f)=>{if(!f)throw new Error("Derivation path is empty. Please make sure you've filled the field correctly.");if(!Up(n))throw new Error("It seems you are filling derivation path without setting namespace before doing that. Please retry to connect.");let h=n.derivationPath.providerType,d=[{namespace:n.derivationPath.namespace,derivationPath:f}],y=!!m.isHub?m.properties?.find(C=>C.name==="namespaces")?.value:m.needsNamespace;return y?.data&&y.data.length>1?(r({type:"detached",payload:{targetWallet:m,selectedNamespaces:d??null,derivationPath:f}}),{status:"Detached"}):await a(h,d)},"handleDerivationPath"),p=i(()=>n,"getState"),u=i(async m=>{let f=t(m.type);return f.connected||f.connecting?(await e(m.type),Ao(p)?(r({type:"needsNamespace",payload:{targetWallet:m}}),{status:"namespace"}):{status:"disconnected"}):{status:"noop"}},"handleDisconnect");return{handleConnect:s,handleDisconnect:u,handleNamespace:c,handleDerivationPath:l,getState:p,resetState:m=>{r(m==="derivation"?{type:"resetDerivation"}:{type:"reset"})}}}i(Ro,"useStatefulConnect");import{WalletState as Is}from"@rango-dev/ui";import{useWallets as LT}from"@rango-dev/wallets-react";import{detectMobileScreens as PT,KEPLR_COMPATIBLE_WALLETS as _T,WalletTypes as Jn}from"@rango-dev/wallets-shared";import{useCallback as DT,useEffect as $T}from"react";import AT,{createContext as NT,useContext as BT,useEffect as WT,useRef as MT}from"react";import{create as ET}from"zustand";import{persist as IT}from"zustand/middleware";import{allProviders as vC}from"@rango-dev/provider-all";var rs=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()}},en=new rs;import{defineVersions as qp,pickVersion as Gp,Provider as is}from"@rango-dev/wallets-core";function Vp({allProviders:t,configWallets:e}){if(e){let o=[];return e.forEach(n=>{if(typeof n=="string"){let r=t.find(a=>{let s=as(a);return s instanceof is?s.id===n:s.config.type===n});r?o.push(r):console.warn(`Couldn't find ${n} provider. Please make sure you are passing the correct name.`)}else n instanceof is?o.push(qp().version("1.0.0",n).build()):o.push(qp().version("0.0.0",n).build())}),o}return t}i(Vp,"matchAndGenerateProviders");function as(t){try{return Gp(t,"1.0.0")[1]}catch{return Gp(t,"0.0.0")[1]}}i(as,"pickProviderVersionWithFallbackToLegacy");function Kp(t){return t.map(o=>as(o)).map(o=>o instanceof is?o.id:o.config.type)}i(Kp,"configWalletsToWalletName");function ti(t,e){return e.find(o=>o.name===t)?.displayName}i(ti,"getBlockchainDisplayNameFor");function ht(t,e){return e.find(o=>o.name===t)?.shortName}i(ht,"getBlockchainShortNameFor");function jp(t,e){return e.find(o=>o.name===t)?.logo}i(jp,"getBlockchainImage");function Hn(t,e){return e.find(o=>o.id===t)?.title}i(Hn,"getSwapperDisplayName");function No(t,e){return e.find(o=>o.name===t)??null}i(No,"findBlockchain");function ss(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(ss,"isTokenNative");function yt(t){return`${t.blockchain.toLowerCase()}-${t.symbol.toLowerCase()}-${(t.address??"").toLowerCase()}`}i(yt,"createTokenHash");function tn(t,e){return t.addressPatterns.filter(r=>new RegExp(r).test(e)).length>0}i(tn,"isValidTokenAddress");function qn(t){let{config:e,meta:o}=t,n={},r=e.tokens,a=i(c=>{c.forEach(l=>{typeof l!="string"&&(l=yt(l));let p=o.tokensMapByTokenHash.get(l);p&&(n[l]=p)})},"addTokens");if(Array.isArray(r))return r.length>0?(a(r),Object.values(n)):Array.from(o.tokensMapByTokenHash.values());if(!r)return Array.from(o.tokensMapByTokenHash.values());let s;if(e.blockchains?.length)s=e.blockchains;else{s=Object.keys(r);let c=new Set(s);Object.keys(o.tokensMapByBlockchainName).forEach(l=>{let p=o.tokensMapByBlockchainName[l];!c.has(l)&&p&&a(p)})}return s.forEach(c=>{let l=r[c];if(!l&&o.tokensMapByBlockchainName?.[c]){a(o.tokensMapByBlockchainName[c]);return}l&&(l.isExcluded&&o.tokensMapByBlockchainName[c]?(a(o.tokensMapByBlockchainName[c]),l.tokens.forEach(p=>{let u=yt(p);delete n[u]})):a(l.tokens))}),Object.values(n)}i(qn,"matchTokensFromConfigWithMeta");function oi(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(oi,"getSupportedBlockchainsFromConfig");function Yp(t){return{walletConnectProjectId:t?.walletConnectProjectId,trezorManifest:t?.trezorManifest,tonConnect:t?.tonConnect,walletConnectListedDesktopWalletLink:t.__UNSTABLE_OR_INTERNAL__?.walletConnectListedDesktopWalletLink}}i(Yp,"makeProvidersOptionsFromConfig");var on={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"}},xC={clientUrl:void 0},bC={liquiditySources:void 0};function Xp(t){let e=Yp(t),o={walletconnect2:{WC_PROJECT_ID:e?.walletConnectProjectId||"",DISABLE_MODAL_AND_OPEN_LINK:e?.walletConnectListedDesktopWalletLink},selectedProviders:t.wallets,trezor:e?.trezorManifest?{manifest:e.trezorManifest}:void 0,tonConnect:e?.tonConnect?.manifestUrl?{manifestUrl:e?.tonConnect.manifestUrl}:void 0};return vC(o).map(a=>a())}i(Xp,"generateProviders");var Zp=i((t,e,o)=>{let n=Xp({...on,...t});return{config:{...on,...t},iframe:xC,campaignMode:bC,allProviders:n,getLiquiditySources:()=>{let{config:r,campaignMode:a}=o();return a.liquiditySources?.length?a.liquiditySources:r.liquiditySources??[]},getDisabledLiquiditySources:()=>{let{disabledLiquiditySources:r,campaignMode:a}=o();return a.liquiditySources?.length?[]:r},excludeLiquiditySources:()=>{let{config:r,campaignMode:a}=o();return a.liquiditySources?.length?!1:!!r.excludeLiquiditySources},isInCampaignMode:()=>{let{campaignMode:r}=o();return!!r.liquiditySources?.length},updateConfig:r=>{let a=o().config,{_tokensMapByTokenHash:s,_tokensMapByBlockchainName:c}=o(),l=qn({type:"source",config:{blockchains:r.from?.blockchains,tokens:r.from?.tokens},meta:{tokensMapByBlockchainName:c,tokensMapByTokenHash:s}}),p=qn({type:"destination",config:{blockchains:r.to?.blockchains,tokens:r.to?.tokens},meta:{tokensMapByBlockchainName:c,tokensMapByTokenHash:s}});en.set("supportedSourceTokens",l),en.set("supportedDestinationTokens",p),e({config:{...a,...r}})},updateCampaignMode:(r,a)=>{let s=o().campaignMode;e({campaignMode:{...s,[r]:a}})},updateIframe:(r,a)=>{let s=o().iframe;e({iframe:{...s,[r]:a}})},buildAndSetProviders:()=>{let{config:r}=o(),a=Xp(r);e({allProviders:a})},getAvailableProviders:()=>{let{allProviders:r,config:a}=o(),s=Yp(a);return Vp({allProviders:r,configWallets:a.wallets,options:s})}}},"createConfigSlice");import{TransactionType as Jp}from"rango-types";var Rp=[Jp.EVM,Jp.SOLANA],ni="https://raw.githubusercontent.com/rango-exchange/assets/refs/heads/main/common/unknown-image.png";import{RangoClient as zC}from"rango-sdk";import{UI_ID as EC}from"@rango-dev/ui";var ri="c6381a79-2817-4602-83bf-6a641a409e32",eu="https://api.rango.exchange",tu="https://explorer.rango.exchange",et={SWAP_BOX_ID:"rango-swap-box",EXPANDED_BOX_ID:"rango-expanded-box",...EC};import{BlockchainCategories as LC,WalletState as lt}from"@rango-dev/ui";import{legacyReadAccountAddress as PC}from"@rango-dev/wallets-core/legacy";import{detectInstallLink as _C,getCosmosExperimentalChainInfo as DC,isEvmAddress as $C,KEPLR_COMPATIBLE_WALLETS as NW,Networks as wu}from"@rango-dev/wallets-shared";import rn from"bignumber.js";import{isCosmosBlockchain as FC}from"rango-types";import IC from"bignumber.js";var de=new IC(0);import{WalletTypes as AC}from"@rango-dev/wallets-shared";var Bo="~",ou=[AC.LEAP];import{BlockchainCategories as cs,WalletState as MC}from"@rango-dev/ui";import{TransactionType as ii}from"rango-sdk";var nu="Roboto",ls=[{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 nn(t){return Array.from(new Set(t))}i(nn,"removeDuplicateFrom");function ai(t,e){let o;return n;function n(...r){o&&clearTimeout(o),o=setTimeout(()=>{o=null,t(...r)},e)}}i(ai,"debounce");function st(t,e){return t.toLowerCase().indexOf(e.toLowerCase())>-1}i(st,"containsText");function au(t,e){return t.toLowerCase()===e.toLowerCase()}i(au,"exactText");function su(t,e){return t.toLowerCase().startsWith(e.toLowerCase())}i(su,"startWithText");var B=i(()=>document.getElementById(et.SWAP_BOX_ID),"getContainer"),Wo=i(()=>document.getElementById(et.EXPANDED_BOX_ID),"getExpanded");function lu(t,e,o){let n=!!e&&au(e,t),r=!!o&&au(o,t);return n!==r?n?-1:1:0}i(lu,"compareExactMatchText");function ps(t,e,o){let n=!!e&&st(e,t),r=!!o&&st(o,t);return n!==r?n?-1:1:n&&r&&e?.length!==o?.length?e?.length-o?.length:0}i(ps,"compareContainsText");function us(t,e,o){let n=!!e&&su(e,t),r=!!o&&su(o,t);return n!==r?n?-1:1:n&&r&&e?.length!==o?.length?e?.length-o?.length:0}i(us,"compareStartWithText");function cu(t,e,o){if(!o)return 0;let n=lu(o,t.symbol,e.symbol);if(n)return n;if(o.length>=3){let r=lu(o,t.name,e.name);if(r)return r}if(o.length>=2){let r=us(o,t.symbol,e.symbol);if(r)return r}if(o.length>=3){let r=ps(o,t.symbol,e.symbol);if(r)return r}if(o.length>=3){let r=us(o,t.name,e.name);if(r)return r}if(o.length>=3){let r=ps(o,t.name,e.name);if(r!==0)return r}if(o.length>=4){let r=us(o,t.address,e.address);if(r)return r}if(o.length>=4){let r=ps(o,t.address,e.address);if(r!==0)return r}return 0}i(cu,"compareWithSearchFor");var si=i((t,e)=>{switch(e){case cs.ALL:return!0;case cs.UTXO:return t===ii.TRANSFER;case cs.OTHER:return t!==ii.TRANSFER&&t!==ii.COSMOS&&t!==ii.EVM;default:return t===e}},"isBlockchainTypeInCategory"),pu=i(t=>ls.find(o=>o.value===t)?.url,"getFontUrlByName");function uu(t,e){let o=!!t.find(n=>n.state===MC.CONNECTED);return e===!1&&o}i(uu,"isSingleWalletActive");function du(){let t,e;return(o,n)=>((!e||!t||t!==n)&&(t=n,e=o()),e)}i(du,"memoizedResult");import{BigNumber as Tu}from"bignumber.js";function mu(t){return t.replace(/^0+(?=\d)/g,"")}i(mu,"removeLeadingZeros");function fu(t){return t.replace(/^\.(\d+)/,"0.$1")}i(fu,"ensureLeadingZeroForDecimal");function gu(t){return t.replace(/\B(?=(\d{3})+(?!\d))/g,",")}i(gu,"formatThousandsWithCommas");function hu(t){return t.replace(/\s+/g,"-")}i(hu,"replaceSpacesWithDash");function yu(t){return t.replace(/(\.\d*?[1-9])0+$/,"$1").replace(/\.0+$/,"")}i(yu,"stripTrailingZeros");function li(t){return/^0+(?:\.0+)?$/.test(t)}i(li,"isZeroValue");function Su(t,e=2){let o=`^(?:0|[1-9]\\d*)(?:\\.\\d{1,${e}})?$`;return new RegExp(o).test(t)}i(Su,"isValidCurrencyFormat");function Cu(t){return/\d+$/.test(t)}i(Cu,"isColorKeyOverridden");var Gn=i(t=>{let e=Math.floor(t%60/15)*15,o=parseInt((t/60).toString());return o>=60?`${Math.floor(o/5)*5}:00`:`${o.toString().padStart(2,"0")}:${e.toString().padStart(2,"0")}`},"roundedSecondsToString"),P=i((t,e=null,o=null)=>{if(t==null||t==="")return"";let n=new Tu(t),r=1,a=1e3;for(let s=0;s<60;s++)if(new Tu(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 ci=i(t=>t?.reduce((e,o)=>e+(o.estimatedTimeInSeconds??0),0)||0,"totalArrivalTime");var Pt=i((t,e)=>t.toLowerCase().indexOf(e.toLowerCase())>-1,"containsText"),Vn=i(t=>!!t&&parseFloat(t)>0,"isPositiveNumber");function ku(t){return li(t)?"0":yu(t)}i(ku,"sanitizeInputAmount");function Kn(t,e){return UC(t,e)?lt.PARTIALLY_CONNECTED:e.connected?lt.CONNECTED:e.connecting?lt.CONNECTING:e.installed?lt.DISCONNECTED:lt.NOT_INSTALLED}i(Kn,"getWalletConnectionStatus");function vu(t,e,o,n){return o.filter(r=>!ou.includes(r)).filter(r=>{let{supportedChains:a,isContractWallet:s}=e(r),{installed:c,network:l}=t(r);return s&&(!c||!!n&&l!==n)?!1:n?!!a.find(u=>u.name===n):!0}).map(r=>{let{name:a,img:s,installLink:c,showOnMobile:l,needsNamespace:p,supportedChains:u,needsDerivationPath:m,properties:f,isHub:h}=e(r),g=nn(u.map(S=>S.type)),d=Kn(e(r),t(r));return{title:a,image:s,link:_C(c),state:d,type:r,showOnMobile:l,needsNamespace:p,blockchainTypes:g,needsDerivationPath:m,properties:f,isHub:h}})}i(vu,"mapWalletTypesToWalletInfo");function jn(t){if(!t)return null;let e=[];return e=t.map(o=>o.name),e}i(jn,"walletAndSupportedChainsNames");function ms(t,e,o,n,r){let a=[];function s(l,p,u){if(!!!a.find(f=>f.chain===l)){let f={address:p,chain:l,walletType:t,isContractWallet:u??!1};a.push(f)}}i(s,"addAccount");let c=n||[];return e.forEach(l=>{let{address:p,network:u}=PC(l),m=c.length>0,f=c.includes(u),h=u===wu.Unknown;if(m&&!f&&!h)return;let d=u===wu.Unknown&&$C(p);if(h&&!d)return;o.includes(u)||d?r?s(u,p.toLowerCase(),r):c.filter(C=>o.includes(C)).forEach(C=>{s(C,p.toLowerCase())}):s(u,p)}),a}i(ms,"prepareAccountsForWalletStore");function Mo(t){let{filter:e,quote:o}=t,n=new Set;return o?.swaps.forEach((r,a)=>{let s=r.from.blockchain,c=r.to.blockchain;if(n.add(s),r.internalSwaps){let{internalSwaps:l}=r;l.forEach((p,u)=>{let m=p.from.blockchain,f=p.to.blockchain,h=a===o.swaps.length-1,g=u===l.length-1;(!h&&!g||h&&c!==m||e==="all")&&n.add(m),e==="all"&&n.add(f)})}e==="all"&&n.add(c)}),Array.from(n)}i(Mo,"getQuoteChains");function Xn(t,e){return t.address===e.address&&t.chain===e.chain&&t.walletType===e.walletType}i(Xn,"isAccountAndWalletMatched");var xu=i(t=>{let e=Object.values(t).reduce((o,n)=>{let r=n.usdValue?ds(n.usdValue,n.decimals):de.toFixed();return o.plus(r)},new rn(de));return OC(e.toString())},"calculateWalletUsdValue");function OC(t){let e=t.toString().split(".");return e[0]&&(e[0]=gu(e[0])),e.join(".")}i(OC,"numberWithThousandSeparator");var di=i((t,e)=>{let o=DC(Object.entries(t).map(([,n])=>n).filter(FC));return o&&!!o[e]?.experimental},"isExperimentalChain");function ds(t,e){return new rn(t).shiftedBy(-e).toFixed()}i(ds,"representAmountInNumber");function mi(t){if(!t)return null;let e=ds(t.amount,t.decimals),o=t.usdValue?ds(t.usdValue,t.decimals):null,n=P(e,8,8),r=o?P(o,4,4):null;return t?{...t,amount:n,usdValue:r}:null}i(mi,"formatBalance");function bu(t,e){if(t?.usdValue||e?.usdValue){let o=t&&t.usdValue?new rn(t.usdValue).shiftedBy(-t.decimals):de,n=e&&e.usdValue?new rn(e.usdValue).shiftedBy(-e.decimals):de;return o.isEqualTo(n)?0:o.isGreaterThan(n)?-1:1}if(t?.amount||e?.amount){let o=t&&t.amount?new rn(t.amount).shiftedBy(-t.decimals):de,n=e&&e.amount?new rn(e.amount).shiftedBy(-e.decimals):de;return o.isEqualTo(n)?0:o.isGreaterThan(n)?-1:1}return 0}i(bu,"compareTokenBalance");function qt(t,e){return t?.blockchain===e?.blockchain&&t?.symbol.toLowerCase()===e?.symbol.toLowerCase()&&t?.address?.toLowerCase()===e?.address?.toLowerCase()}i(qt,"areTokensEqual");function Eu(t){return t.sort((e,o)=>+(o.state===lt.CONNECTED)-+(e.state===lt.CONNECTED)||+(o.state===lt.PARTIALLY_CONNECTED)-+(e.state===lt.PARTIALLY_CONNECTED)||+(o.state===lt.DISCONNECTED||o.state===lt.CONNECTING)-+(e.state===lt.DISCONNECTED||e.state===lt.CONNECTING))}i(Eu,"sortWalletsBasedOnConnectionState");function lo(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(lo,"getConciseAddress");function Iu({chain:t,connectedWallets:e,walletType:o}){return e.find(n=>n.walletType===o&&n.chain===t)?.address}i(Iu,"getAddress");var Au=i((t,e)=>!!t.find(o=>o.chain===e&&o.loading),"isFetchingBalance");function Nu(t){return t.map(e=>e.state).join("-")}i(Nu,"hashWalletsState");function Bu(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(Bu,"filterBlockchainsByWalletTypes");function Wu(t,e){return e===LC.ALL?t:t.filter(o=>{for(let n of o.blockchainTypes)if(si(n,e))return!0;return!1})}i(Wu,"filterWalletsByCategory");function UC(t,e){if(!t.isHub||!t.needsNamespace||!e.connected)return!1;let n=t.needsNamespace.data.filter(r=>!r.unsupported);return t.needsNamespace.selection==="multiple"&&n.some(r=>!e.namespaces?.get(r.value)?.connected)}i(UC,"checkIsWalletPartiallyConnected");var fs={API_KEY:ri};function Gt(t){return fs[t]||""}i(Gt,"getConfig");function Mu(t){let e;return typeof structuredClone=="function"?e=structuredClone(t):e=JSON.parse(JSON.stringify(t)),fs=e,fs}i(Mu,"initConfig");var Lu=20,Pu=25,gs="theme-widget",hs=i((t,e)=>{let o=!1;if(e&&t){if(Array.isArray(e))o=!e.some(n=>qt(n,t));else if(!Array.isArray(e)){let n=e[t.blockchain];if(n){o=!!n.tokens.some(a=>qt(a,t));let r=n.isExcluded;return!r&&!o||r&&o}}}return o},"isTokenExcludedInConfig"),ys=i((t,e)=>t&&e&&!e.includes(t.name),"isBlockchainExcludedInConfig"),_u=i((t,e,o)=>o==="expanded"&&(t||e)||o==="full-expanded"&&e,"isVariantExpandable");var fi,ct=i(()=>fi||(fi=new zC(Gt("API_KEY"),Gt("BASE_URL")),fi),"httpService");import{i18n as $u}from"@lingui/core";var gi=[.5,1,3],hi=1,an=5,Yn=30,yi=0;var Ze=(a=>(a[a.NO_RESULT=0]="NO_RESULT",a[a.REQUEST_FAILED=1]="REQUEST_FAILED",a[a.REQUEST_CANCELED=2]="REQUEST_CANCELED",a[a.BRIDGE_LIMIT=3]="BRIDGE_LIMIT",a[a.INSUFFICIENT_SLIPPAGE=4]="INSUFFICIENT_SLIPPAGE",a))(Ze||{});import{WidgetEvents as Du}from"@rango-dev/queue-manager-rango-preset";var Ss=(o=>(o.QUOTE_INPUT_UPDATE="quoteInputUpdate",o.QUOTE_OUTPUT_UPDATE="quoteOutputUpdate",o))(Ss||{}),Cs=(o=>(o.CONNECT="connect",o.DISCONNECT="disconnect",o))(Cs||{}),Ts=(e=>(e.CLICK_CONNECT_WALLET="clickConnectWallet",e))(Ts||{}),sn=(a=>(a[a.RouteEvent=Du.RouteEvent]="RouteEvent",a[a.StepEvent=Du.StepEvent]="StepEvent",a.QuoteEvent="quoteEvent",a.WalletEvent="walletEvent",a.UiEvent="uiEvent",a))(sn||{});function Si(t,e){let o=t.map(a=>a.swapperGroup),n=[];return nn(t.map(a=>a.swapperGroup)).map(a=>{let s=t.find(c=>c.swapperGroup===a);if(s){let c=!0;o&&(c=o.some(l=>l===s.swapperGroup)),c&&s.types.map(l=>{n.push({id:s.swapperGroup,groupTitle:s.swapperGroup,logo:s.logo,type:l,selected:!e.includes(s.swapperGroup)})})}}),n}i(Si,"getUniqueSwappersGroups");function Fu(t,e){return t.swapperGroup<e.swapperGroup?-1:t.swapperGroup>e.swapperGroup?1:0}i(Fu,"sortLiquiditySourcesByGroupTitle");function tt(t,e){return e?.[t]==="hidden"}i(tt,"isFeatureHidden");function ln(t,e){return e?.[t]==="enabled"}i(ln,"isRoutingEnabled");var Ou=i((t,e,o)=>tt("customTokens",o)?t:t.concat(e),"addCustomTokensToSupportedTokens");function cn(t){return t==yi?{type:"error",message:$u.t("Slippage must be greater than or equal to 0.01")}:t>an&&t<=Yn?{type:"warning",message:$u.t("Your transaction is at risk of being frontrun due to high slippage tolerance."),quoteValidation:{type:3,slippage:t.toString()}}:null}i(cn,"getSlippageValidation");var Uu=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 l=oi({config:a}),p=r;return l.length>0&&(p=p.filter(u=>l.includes(u.name))),p.filter(u=>Rp.includes(u.type))}let s=(o.type==="source"?a.from?.blockchains:a.to?.blockchains)??[];return r.filter(l=>!(s.length>0&&!s.includes(l.name)))},tokens:o=>{let{_tokensMapByTokenHash:n,_tokensMapByBlockchainName:r,config:a,_customTokens:s}=e(),c=Array.from(n.values()),l=e()._blockchainsMapByName;if(!o||!o.type)return c;let p=o.type==="source"?"from":"to",u=o.type==="source"?"supportedSourceTokens":"supportedDestinationTokens",m=en.get(u);m?.length||(m=qn({type:o.type,config:{blockchains:a[p]?.blockchains,tokens:a[p]?.tokens},meta:{tokensMapByTokenHash:n,tokensMapByBlockchainName:r}}),en.set(u,m)),m=Ou(m,s,a.features);let f=e().blockchains({type:o.type});return m.filter(g=>o.blockchain&&g.blockchain!==o.blockchain||!f.some(d=>d.name===g.blockchain)?!1:o.searchFor?!!(st(g.symbol,o.searchFor)||st(g.address||"",o.searchFor)||st(g.name||"",o.searchFor)):!0).sort((g,d)=>{let S=e().isTokenPinned(g,o.type),y=e().isTokenPinned(d,o.type);if(S!==y)return S?-1:1;if(o.getBalanceFor){let I=o.getBalanceFor(g),A=o.getBalanceFor(d),b=bu(I,A);if(b!==0)return b}let C=l.get(g.blockchain),k=l.get(d.blockchain),w=ss(g,C),x=ss(d,k);if(w!==x)return w?-1:1;if(g.isPopular!==d.isPopular)return g.isPopular?-1:1;if(o.searchFor){let I=cu(g,d,o.searchFor);if(I)return I}return g.isSecondaryCoin!==d.isSecondaryCoin?g.isSecondaryCoin?1:-1:C&&k?C.sort-k.sort:0})},findToken:o=>{let n=e()._tokensMapByTokenHash,r=e().customTokens(),a=yt(o),s=n.get(a);return s||(s=r.find(c=>yt(c)===a)),s},findNativeToken:o=>{let n=o.feeAssets[0];return e().findToken({blockchain:o.name,address:n.address,symbol:n.symbol})},isTokenPinned:(o,n)=>!!(n==="source"?e().config.from?.pinnedTokens:e().config.to?.pinnedTokens)?.some(s=>qt(s,o)),swappers:()=>{let{config:o,campaignMode:n}=e(),r=n.liquiditySources?.length?n.liquiditySources:null,a=r??o.liquiditySources,s=r?!1:o.excludeLiquiditySources;return e()._swappers.filter(p=>{let u=a?.includes(p.swapperGroup);return s||!a||a.length===0?!u:u}).sort(Fu)},fetch:async()=>{try{let{routing:o}=e().config,n=ln("enableCentralizedSwappers",o),r=await ct().getAllMetadata({enableCentralizedSwappers:n});t({fetchStatus:"success"});let a=new Map,s=new Map,c={},l=[],p=r.popularTokens,u=r.swappers.filter(h=>h.enabled),m=new Set;r.tokens.forEach(h=>{m.add(h.blockchain),l.push(h)}),r.blockchains.sort((h,g)=>h.sort-g.sort).forEach(h=>{h.enabled&&m.has(h.name)&&a.set(h.name,h)}),l.forEach(h=>{let g=yt(h);c[h.blockchain]||(c[h.blockchain]=[]),s.set(g,h),c[h.blockchain]?.push(g)}),t({_blockchainsMapByName:a,_tokensMapByTokenHash:s,_tokensMapByBlockchainName:c,_popularTokens:p,_swappers:u})}catch(o){throw t({fetchStatus:"failed"}),o}}}),"createDataSlice");import{Bengali as QC,Catalonia as HC,Chinese as zu,Denmark as qC,English as GC,Finland as VC,French as KC,German as jC,Greece as XC,Hungary as YC,India as ZC,Indonesian as JC,Italian as RC,Japanese as eT,Korea as tT,Lithuania as oT,Malay as nT,Netherlands as rT,Pakistan as iT,Philippines as aT,Poland as sT,Portuguese as lT,Russian as cT,SaudiArabia as pT,Serbia as uT,Slovakia as dT,SouthAfrica as mT,Spanish as fT,Swahili as gT,Swedish as hT,Thai as yT,Turkish as ST,Ukrainian as CT,Vietnamese as TT}from"@rango-dev/ui";var Qu=[{title:"Afrikaans",label:"Afrikaans",local:"af",SVGFlag:mT},{title:"Arabic",label:"\u0639\u0631\u0628\u064A",local:"ar",SVGFlag:pT},{title:"Bengali",label:"\u09AC\u09BE\u0982\u09B2\u09BE",local:"bn",SVGFlag:QC},{title:"Catalan",label:"Catal\xE0",local:"ca",SVGFlag:HC},{title:"Chinese (Simplified)",label:"\u7B80\u4F53\u4E2D\u6587",local:"zh-CN",SVGFlag:zu},{title:"Chinese (Traditional)",label:"\u4E2D\u6587\uFF08\u7E41\u9AD4)",local:"zh-TW",SVGFlag:zu},{title:"Danish",label:"Dansk",local:"da",SVGFlag:qC},{title:"Dutch",label:"Nederlands",local:"nl",SVGFlag:rT},{title:"English",label:"English",local:"en",SVGFlag:GC},{title:"Filipino",label:"Filipino",local:"fil",SVGFlag:aT},{title:"Finnish",label:"Suomalainen",local:"fi",SVGFlag:VC},{title:"French",label:"Fran\xE7ais",local:"fr",SVGFlag:KC},{title:"German",label:"Deutsch",local:"de",SVGFlag:jC},{title:"Greek",label:"\u03B5\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AC",local:"el",SVGFlag:XC},{title:"Hindi",label:"\u0939\u093F\u0902\u0926\u0940",local:"hi",SVGFlag:ZC},{title:"Hungarian",label:"Magyar",local:"hu",SVGFlag:YC},{title:"Indonesian",label:"Indonesia",local:"id",SVGFlag:JC},{title:"Italian",label:"Italiana",local:"it",SVGFlag:RC},{title:"Japanese",label:"\u65E5\u672C\u8A9E",local:"ja",SVGFlag:eT},{title:"Korean",label:"\uD55C\uAD6D\uC778",local:"ko",SVGFlag:tT},{title:"Lithuanian",label:"Lietuvi\u0173",local:"lt",SVGFlag:oT},{title:"Malay",label:"Melayu",local:"ms",SVGFlag:nT},{title:"Polish",label:"Polski",local:"pl",SVGFlag:sT},{title:"Portuguese",label:"Portugu\xEAs",local:"pt",SVGFlag:lT},{title:"Russian",label:"\u0420\u0443\u0441\u0441\u043A\u0438\u0439",local:"ru",SVGFlag:cT},{title:"Serbian",label:"C\u0440\u043F\u0441\u043A\u0438",local:"sr",SVGFlag:uT},{title:"Slovak",label:"Slovensk\xFD",local:"sk",SVGFlag:dT},{title:"Spanish",label:"Espa\xF1ol",local:"es",SVGFlag:fT},{title:"Swahili",label:"Kiswahili",local:"sw",SVGFlag:gT},{title:"Swedish",label:"Svenska",local:"sv",SVGFlag:hT},{title:"Thai",label:"\u0E41\u0E1A\u0E1A\u0E44\u0E17\u0E22",local:"th",SVGFlag:yT},{title:"Turkish",label:"T\xFCrk\xE7e",local:"tr",SVGFlag:ST},{title:"Ukrainian",label:"Y\u043A\u0440\u0430\u0457\u043D\u0456",local:"uk",SVGFlag:CT},{title:"Urdu",label:"\u0627\u0631\u062F\u0648",local:"ur",SVGFlag:iT},{title:"Vietnamese",label:"Ti\u1EBFng Vi\u1EC7t",local:"vi",SVGFlag:TT}],pn="en";var Hu=i((t,e)=>({disabledLiquiditySources:[],theme:"auto",language:null,preferredBlockchains:[],slippage:hi,customSlippage:null,infiniteApprove:!1,affiliateRef:null,affiliatePercent:null,affiliateWallets:null,_customTokens:[],quoteTokensRate:"default",changeQuoteTokensRate:()=>t(o=>({quoteTokensRate:o.quoteTokensRate==="default"?"reversed":"default"})),addPreferredBlockchain:o=>{let n=e().preferredBlockchains;if(n.find((s,c)=>{let l=s===o,p=c<=9;return l&&p}))return;let a=n.filter(s=>!(s===o));t(()=>({preferredBlockchains:[o,...a]}))},setSlippage:o=>t(()=>({slippage:o})),setCustomSlippage:o=>t(()=>({customSlippage:o})),setAffiliateRef:o=>t(()=>({affiliateRef:o})),setAffiliatePercent:o=>t(()=>({affiliatePercent:o})),setAffiliateWallets:o=>t(()=>({affiliateWallets:o})),toggleAllLiquiditySources:(o,n)=>t(r=>{if(n)return{disabledLiquiditySources:[]};let a=nn(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=tt("theme",n),s=tt("language",n),c=tt("liquiditySource",n),l=r?.singleTheme,p=o?.__UNSTABLE_OR_INTERNAL__?.autoUpdateSettings;t({...a&&{theme:o.theme?.mode||"auto"},...l&&{theme:o.theme?.mode||"light"},...s&&{language:o.language||pn},...c&&{disabledLiquiditySources:o.liquiditySources||[]},...p&&{language:o.language||pn}})},setCustomToken:o=>{e().fetchCustomTokensBalances({tokens:[o],connectedWallets:e().connectedWallets}),t(n=>({_customTokens:[o,...n._customTokens]}))},deleteCustomToken:o=>t(n=>({_customTokens:n._customTokens.filter(r=>r.address!==o.address)})),customTokens:()=>{let o=e().config,n=e()._customTokens,r=oi({config:o});return r.length?n.filter(a=>r.includes(a.blockchain)):n}}),"createSettingsSlice");import Es from"bignumber.js";import kT from"mitt";var we=kT(),wT={on:we.on,off:we.off};var qu=i(t=>(e,o,n)=>t(i((...a)=>{let[s,...c]=a;e(l=>({...typeof s=="function"?s(l):s,lastUpdatedAt:+new Date}),...c)},"modifedSet"),o,n),"keepLastUpdated");import Gu from"bignumber.js";function Vt(t){return`${t.blockchain}${Bo}${t.address}${Bo}${t.symbol}`}i(Vt,"createAssetKey");function Vu(t,e){return`${Vt(e)}${Bo}${t}`}i(Vu,"createBalanceKey");function Zn(t){let[e,o,n]=t.split(Bo);return!e||!o||!n?null:{address:o==="null"?null:o,blockchain:e,symbol:n}}i(Zn,"extractAssetFromBalanceKey");function ws(t,e,o){return e.balances?.forEach(n=>{let r=n.price??t.findToken(n.asset)?.usdPrice;t._aggregatedBalances[Vt(n.asset)]?.forEach(s=>{o[s]&&(o[s]={...o[s],usdValue:r?new Gu(r??de).multipliedBy(o[s].amount).toString():""})})}),o}i(ws,"computeNextBalancesWithNewPrices");function vs(t,e){let o={};return t.balances?.forEach(n=>{let r=Vu(t.address,n.asset),a=n.amount.amount,s=n.amount.decimals,c=n.price??e().findToken(n.asset)?.usdPrice,l=c?new Gu(c??de).multipliedBy(a).toString():"",p={amount:a,decimals:s,usdValue:l};o[r]=p}),o}i(vs,"createBalanceStateForNewAccount");function xs(t,e){for(let o in e){let n=Zn(o);if(n){let r=Vt(n);t[r]||(t[r]=[]),t[r].includes(o)||(t[r]=[...t[r],o])}}return t}i(xs,"updateAggregatedBalanceStateForNewAccount");function vT(t,e){let o=Zn(e);if(!o)return t;let n=Vt(o);return t[n]&&(t[n]=t[n].filter(r=>r!==e)),t}i(vT,"removeBalanceFromAggregatedBalance");function bs(t,e,o){let n=t.connectedWallets.filter(l=>l.walletType===e);t.connectedWallets.forEach(l=>{l.walletType!==e&&(n=n.filter(p=>!(p.chain===l.chain&&p.address===l.address)))}),o?.chains&&o.chains.length>0&&(n=n.filter(l=>o.chains?.includes(l.chain))),o?.namespaces&&o.namespaces.length>0&&(n=n.filter(l=>l.namespace?o.namespaces?.includes(l.namespace):!1));let r={},a=t._aggregatedBalances,s=t._balances;return Object.keys(s).forEach(l=>{let p=Zn(l);if(!p)return;!!n.find(m=>Vu(m.address,{address:p.address,blockchain:m.chain,symbol:p.symbol})===l)?a=vT(a,l):s[l]&&(r[l]=s[l])}),{_balances:r,_aggregatedBalances:a}}i(bs,"computeNextStateAfterWalletBalanceRemoval");function xT(t,e){return e.find(o=>t.address===o.address&&t.chain===o.blockChain)}i(xT,"matchWalletDetailsWithConnectedWallet");var bT=du(),Ku=qu((t,e)=>({_balances:{},_aggregatedBalances:{},connectedWallets:[],fetchingWallets:!1,lastUpdatedAt:+new Date,setConnectedWalletAsRefetching:o=>{t(n=>({fetchingWallets:!0,connectedWallets:n.connectedWallets.map(r=>o.find(a=>Xn(a,r))?{...r,loading:!0,error:!1}:r)}))},setConnectedWalletRetrievedData:(o,n)=>{t(r=>({fetchingWallets:!1,connectedWallets:r.connectedWallets.map(a=>o.find(s=>Xn(s,a))?{...a,loading:!1,error:!1,explorerUrl:xT(a,n)?.explorerUrl||a.explorerUrl}:a)}))},setConnectedWalletHasError:o=>{t(n=>({fetchingWallets:!1,connectedWallets:n.connectedWallets.map(r=>o.find(a=>Xn(a,r))?{...r,loading:!1,error:!0}:r)}))},addConnectedWallet:(o,n,r)=>{let a=e().connectedWallets,s=o.filter(c=>!a.some(l=>Xn(c,l)));if(s.length>0){let c=s.map(l=>{let p=!a.some(u=>u.chain===l.chain&&u.selected&&u.walletType!==l.walletType);return{address:l.address,chain:l.chain,isContractWallet:l.isContractWallet,explorerUrl:null,walletType:l.walletType,selected:p,namespace:n,derivationPath:r,loading:!1,error:!1}});t(l=>({connectedWallets:[...l.connectedWallets.filter(u=>!c.some(m=>m.walletType===u.walletType&&m.chain===u.chain)),...c]}))}},fetchCustomTokensBalances:async o=>{let{tokens:n,connectedWallets:r}=o,a=n.reduce((l,p)=>((l[p.blockchain]||=[]).push(p),l),{}),s=new Set,c=r.reduce((l,p)=>{let u=`${p.address}-${p.chain}`;return s.has(u)||(s.add(u),a[p.chain]&&(l[p.address]||(l[p.address]=[]),l[p.address]?.push(...a[p.chain]||[]))),l},{});Object.entries(c).forEach(async([l,p])=>{try{let{balances:u}=await ct().getMultipleTokenBalance({assets:p.map(({symbol:m,address:f,blockchain:h})=>({symbol:m,address:f,blockchain:h})),walletAddress:l});if(u){let m=e()._balances,f=e()._aggregatedBalances;u.forEach(h=>{if(parseFloat(h.amount.amount)===0)return;let g={blockChain:h.asset.blockchain,balances:[h],address:l},d={_aggregatedBalances:e()._aggregatedBalances,findToken:e().findToken};ws(d,g,m);let S=vs(g,e);f=xs(f,S),m={...m,...S}}),t(h=>({_balances:{...h._balances,...m},_aggregatedBalances:f}))}}catch(u){console.error(u)}})},setWalletsAsSelected:o=>{let n=e().connectedWallets.map(r=>{let a=!!o.find(c=>c.chain===r.chain&&c.walletType!==r.walletType&&r.selected),s=!!o.find(c=>c.chain===r.chain&&c.walletType===r.walletType&&!r.selected);return a?{...r,selected:!1}:s?{...r,selected:!0}:r});t({connectedWallets:n})},newWalletConnected:async(o,n,r)=>{let a=o[0];a&&(we.emit("walletEvent",{type:"connect",payload:{walletType:a.walletType,accounts:o}}),e().addConnectedWallet(o,n,r),e().fetchBalances(o))},removeBalancesForWallet:(o,n)=>{let r={_balances:e()._balances,_aggregatedBalances:e()._aggregatedBalances,connectedWallets:e().connectedWallets},{_balances:a,_aggregatedBalances:s}=bs(r,o,n);t({_balances:a,_aggregatedBalances:s})},disconnectNamespaces:(o,n)=>{if(e().connectedWallets.find(a=>a.walletType===o)){e().removeBalancesForWallet(o,{namespaces:n}),e()._changeSelectedWalletIfNeededOnRemove(o,{namespaces:n});let a=e().connectedWallets.filter(s=>s.namespace?!(s.walletType===o&&n.includes(s.namespace)):!0);t({connectedWallets:a})}},disconnectWallet:o=>{let n=e().connectedWallets.find(r=>r.walletType===o);if(we.emit("walletEvent",{type:"disconnect",payload:{walletType:o}}),n){e().removeBalancesForWallet(o),e()._changeSelectedWalletIfNeededOnRemove(o);let r=e().connectedWallets.filter(a=>a.walletType!==o);t({connectedWallets:r})}},_changeSelectedWalletIfNeededOnRemove:(o,n)=>{let r=e().connectedWallets;n?.namespaces&&n.namespaces.length>0&&(r=r.filter(s=>!!s.namespace&&n.namespaces?.includes(s.namespace)));let a=r.filter(s=>s.selected&&s.walletType===o).map(s=>s.chain);if(a.length>0){let s=e().connectedWallets.map(c=>a.includes(c.chain)?(a=a.filter(l=>l!==c.chain),{...c,selected:!0}):c);t({connectedWallets:s})}},clearConnectedWallet:()=>t({connectedWallets:[]}),fetchBalances:async(o,n)=>{let{shouldFetchCustomTokens:r=!0,selectedCustomTokens:a}=n||{};await e().fetchMainTokensBalances(o),r&&e().fetchCustomTokensBalances({tokens:a??e().customTokens(),connectedWallets:o})},fetchMainTokensBalances:async(o,n)=>{if(o.length===0||!o[0])return;let r=o[0].walletType;e().setConnectedWalletAsRefetching(o);let a=o.map(l=>({address:l.address,blockchain:l.chain})),s;try{s=await ct().getWalletsDetails(a)}catch(l){e().setConnectedWalletHasError(o),console.error(`Request for fetching balances failed. cause: ${l}`);return}let c=s.wallets;if(c){let l=e()._balances,p=e()._aggregatedBalances;c.forEach(m=>{if(m.failed)return;let f={_balances:l,_aggregatedBalances:p,connectedWallets:e().connectedWallets,findToken:e().findToken};ws(f,m,l);let{_balances:h,_aggregatedBalances:g}=bs(f,r,{chains:[m.blockChain]});if(p=g,l=h,!e().connectedWallets.find(S=>S.walletType===r&&S.address===m.address&&S.chain===m.blockChain))return;let d=vs(m,e);p=xs(p,d),l={...l,...d}}),t(m=>({_balances:{...m._balances,...l},_aggregatedBalances:p})),e().setConnectedWalletRetrievedData(o,c);let{retryOnFailedBalances:u=!0}=n||{};if(u){let m=c.filter(f=>f.failed).map(f=>({chain:f.blockChain,walletType:r,address:f.address}));m.length>0&&await e().fetchMainTokensBalances(m,{retryOnFailedBalances:!1})}}else e().setConnectedWalletHasError(o),console.error("We couldn't fetch your account balances. Seem there is no information on blockchain for them yet.")},getBalances:()=>e()._balances,getBalanceFor:o=>{let n=e().getBalances(),r=Vt(o),a=e()._aggregatedBalances[r]||[];if(a.length===0||!a[0])return null;let s=a[0];if(a.length===1&&n[s])return n[s];let c=n[a[0]];if(!c)return null;let l=c;return a.forEach(p=>{let u=n[p];if(!u)return;let m=new Es(u.amount),f=new Es(l.amount);m.isGreaterThan(f)&&(l=u)}),l},getBalancesForWalletAddress:o=>{let n=e().getBalances();return Object.keys(n).reduce((s,c)=>{let l=n[c],[,,,p]=c.split(Bo);return l&&p===o&&(s[c]=l),s},{})},getConnectedWalletsDetails:()=>bT(()=>e().connectedWallets.map(n=>{let r=e().getBalancesForWalletAddress(n.address),a=Object.keys(r);return{...n,balances:a.reduce((s,c)=>{let l=r[c],p=Zn(c);if(p&&p.blockchain===n.chain&&l){let u=e().findToken(p),m=l?.amount?new Es(l.amount).shiftedBy(-l.decimals):de;s.push({chain:n.chain,symbol:p.symbol,ticker:p.symbol,address:p.address,rawAmount:l.amount,decimal:l.decimals,amount:m.toString(),isSupported:!!u,logo:u?.image||null,usdPrice:u?.usdPrice||null})}return s},[])}}),e().lastUpdatedAt)}));function ju(t){return ET()(IT((...e)=>({...Ku(...e),...Uu(...e),...Hu(...e),...Zp(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,quoteTokensRate:e.quoteTokensRate}),version:1,migrate:(e,o)=>{let n=e;return o===0&&(n._customTokens=n._customTokens.map(r=>({...r,warning:!0}))),n}}))}i(ju,"createAppStore");var Xu=NT(null);function T(){let t=BT(Xu);if(WT(()=>{t&&!t.persist.hasHydrated()&&t.persist.rehydrate()},[]),!t)throw new Error("Missing AppStoreContext.Provider in the tree");return t()}i(T,"useAppStore");function Yu(t){let e=MT();return e.current||(e.current=ju(t.config)),AT.createElement(Xu.Provider,{value:e.current},t.children)}i(Yu,"AppStoreProvider");function vt(t){let{chain:e}=t||{},{connectedWallets:o,getAvailableProviders:n}=T(),{state:r,getWalletInfo:a}=LT(),s=T().blockchains(),{handleDisconnect:c}=Ro(),l=Kp(n()),p=vu(r,a,l,e);p=PT()?p.filter(d=>d.showOnMobile!==!1&&r(d.type).installed):p;let u=Eu(p),m=i(d=>!o.find(S=>S.walletType===d&&S.chain===e),"isExperimentalChainNotAdded"),f=DT(()=>{let d=p?.filter(S=>S.state===Is.CONNECTING)||[];for(let S of d)c(S)},[Nu(p)]);$T(()=>()=>{f()},[]);let h=i(d=>{let S=d.find(C=>C.type===Jn.DEFAULT);return!S||S.state===Is.NOT_INSTALLED?!1:d.filter(C=>C.state!=Is.NOT_INSTALLED&&![Jn.DEFAULT,Jn.WALLET_CONNECT_2,Jn.LEDGER].includes(C.type)&&a(C.type).supportedChains.filter(k=>k.type=="EVM").length>0).length==0},"shouldShowDefaultInjectedWallet"),g=i((d,S,y)=>di(y,S)&&m(d)&&!_T.includes(d)||d==Jn.DEFAULT&&!h(p),"shouldExcludeWallet");return{list:u.filter(d=>!g(d.type,e??"",s)),terminateConnectingWallets:f}}i(vt,"useWalletList");import{Modal as zT}from"@rango-dev/ui";import QT from"react";import{create as UT}from"zustand";var Zu="rango-widget";var Rn=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(Zu),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 OT=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"),co=OT;var re=co(UT()((t,e)=>({isActiveTab:!1,tabManagerInitiated:!1,showActivateTabModal:!1,watermark:"NONE",showProfileBanner:!1,fetchingApiConfig:!1,showCompactTokenSelector:!1,activateCurrentTab:(o,n)=>{let{showActivateTabModal:r}=e();!r&&n?t({showActivateTabModal:!0}):(r||!n)&&o()},setShowActivateTabModal:o=>{t({showActivateTabModal:o})},setWatermark:o=>{t({watermark:o})},setShowProfileBanner:o=>{t({showProfileBanner:o})},setShowCompactTokenSelector:o=>{t({showCompactTokenSelector:o})}}))),Po=new Rn({onInit:()=>re.setState({tabManagerInitiated:!0}),onClaim:()=>re.setState({isActiveTab:!0,showActivateTabModal:!1}),onRelease:()=>re.setState({isActiveTab:!1})});function R(t){let{watermark:e}=re();return QT.createElement(zT,{hasWatermark:e==="FULL",...t},t.children)}i(R,"WatermarkedModal");import{i18n as mn}from"@lingui/core";import{Alert as ok,Button as nk,Divider as fn,Image as rk,MessageBox as ik,RadioRoot as ak,WalletImageContainer as sk}from"@rango-dev/ui";import le,{useEffect as lk,useMemo as ck,useState as pk}from"react";import{i18n as VT}from"@lingui/core";import{Typography as id}from"@rango-dev/ui";import un from"react";function Ci(t,e){return t.find(o=>o.name===e)?.logo}i(Ci,"getBlockchainLogo");import{darkTheme as HT,Image as qT,styled as Kt,Typography as GT}from"@rango-dev/ui";var Ti=Kt("li",{backgroundColor:"$neutral200",padding:"$16",borderRadius:"$sm",variants:{clickable:{true:{cursor:"pointer"}},hasError:{true:{background:"$error100",[`.${HT} &`]:{backgroundColor:"$error700"}}},unsupported:{true:{cursor:"not-allowed",paddingTop:"$8",paddingBottom:"$8"}}}}),ki=Kt("div",{display:"flex",gap:"$8",alignItems:"center"}),Ru=Kt("div",{flex:"1",display:"flex",flexDirection:"column",justifyContent:"space-between",height:"$40",variants:{showSupportedChains:{true:{justifyContent:"space-between"},false:{justifyContent:"center"}}}}),ed=Kt("div",{flex:"1",display:"flex",alignItems:"center",gap:"$4",opacity:"0.5"}),td=Kt("div",{display:"flex",gap:"$6",alignItems:"center"}),od=Kt("div",{paddingLeft:"48px"}),nd=Kt("div",{display:"flex",gap:"$2",cursor:"pointer",alignItems:"center",width:"fit-content"}),rd=Kt(GT,{maxWidth:"100px"}),wi=Kt(qT,{variants:{disabled:{true:{opacity:"0.5"}}}});function vi(t){let{namespace:e}=t,o=T().blockchains();return un.createElement(Ti,{unsupported:!0},un.createElement(ki,null,un.createElement(wi,{src:Ci(o,e.id),size:40,disabled:!0}),un.createElement(ed,null,un.createElement(id,{variant:"label",size:"large"},e.label),un.createElement(id,{variant:"body",size:"xsmall"},VT.t("(Currently not supported)")))))}i(vi,"NamespaceUnsupportedItem");import{Checkbox as RT,Radio as ek}from"@rango-dev/ui";import Ws from"react";import{i18n as Bs}from"@lingui/core";import{ChevronDownIcon as jT,ChevronUpIcon as XT,Divider as YT,Typography as er}from"@rango-dev/ui";import Ne,{useEffect as ZT,useState as JT}from"react";import{Image as sd,Tooltip as ld,Typography as KT}from"@rango-dev/ui";import _t from"react";import{styled as ad}from"@rango-dev/ui";var As=ad("div",{display:"flex",alignItems:"center",padding:0,margin:0}),xi=ad("div",{marginLeft:"-5px",listStyleType:"none",backgroundColor:"$background",borderRadius:"$lg",minWidth:"15px",height:"15px",variants:{firstItem:{true:{marginLeft:0}}},display:"flex",alignItems:"center",justifyContent:"center"});var Ns=3;function cd(t){let{chains:e}=t;return _t.createElement(As,{id:"widget-supported-chains-container"},e.slice(0,Ns).map((o,n)=>_t.createElement(ld,{key:o.name,container:B(),side:"bottom",align:"start",content:o.name,sideOffset:4},_t.createElement(xi,{firstItem:n===0},_t.createElement(sd,{src:o.logo,size:15})))),e.length>Ns&&_t.createElement(ld,{container:B(),side:"bottom",align:"start",sideOffset:4,content:_t.createElement(As,null,e.map((o,n)=>_t.createElement(xi,{key:o.name,firstItem:n===0},_t.createElement(sd,{src:o.logo,size:15}))))},_t.createElement(xi,null,_t.createElement(KT,{variant:"body",size:"xsmall"},"+",e.length-Ns))))}i(cd,"SupportedChainsList");function _o(t){let{namespace:e,error:o,suffix:n,connected:r,address:a,onClick:s}=t,[c,l]=JT(!1),p=T().blockchains();ZT(()=>l(!1),[o]);let u=e.getSupportedChains(p),m=!o&&!r&&u.length>1;return Ne.createElement(Ti,{hasError:!!o,clickable:!!s,onClick:s},Ne.createElement(ki,null,Ne.createElement(wi,{src:Ci(p,e.id),size:40}),Ne.createElement(Ru,{showSupportedChains:m||r||!!o},Ne.createElement(td,null,Ne.createElement(er,{variant:"label",size:"large"},e.label),r&&Ne.createElement(er,{variant:"body",size:"small",color:"success500"},Bs.t("Connected")),!!o&&Ne.createElement(er,{variant:"body",size:"small",color:"error500"},Bs.t("Connection failed"))),m&&Ne.createElement(cd,{chains:u}),r&&Ne.createElement(rd,{variant:"body",size:"small",color:"neutral700"},a),o&&Ne.createElement(nd,{onClick:()=>l(f=>!f)},Ne.createElement(er,{variant:"body",size:"small",color:"neutral700",style:{textDecoration:"underline",userSelect:"none",textDecorationSkipInk:"none"}},Bs.t("See why")),c?Ne.createElement(XT,{size:12,color:"gray"}):Ne.createElement(jT,{size:12,color:"gray"}))),n),!!o&&c&&Ne.createElement(Ne.Fragment,null,Ne.createElement(YT,{size:4}),Ne.createElement(od,null,Ne.createElement(er,{variant:"body",size:"small",color:"neutral700"},o))))}i(_o,"NamespaceItem");function pd(t){let{onClick:e,type:o,namespace:n}=t;return Ws.createElement(_o,{namespace:n,onClick:e,suffix:o==="radio"?Ws.createElement(ek,{value:n.value}):Ws.createElement(RT,{checked:t.value})})}i(pd,"NamespaceListItem");import{Button as tk,styled as ud}from"@rango-dev/ui";var bi=ud("ul",{padding:0,paddingBottom:"$20",margin:0}),dn=ud(tk,{minHeight:"$40"});function tr(t){let{targetWallet:e}=t.value,o=e.properties?.find(d=>d.name==="namespaces"),n=e.isHub,r=e.isHub?o?.value.selection==="single":e.needsNamespace?.selection==="single",a=n?o?.value:e.needsNamespace,s=e.image,c=T().blockchains(),[l,p]=pk([]),u=ck(()=>a?.data.filter(d=>!d.unsupported),[e?.type]),m=i(d=>{p(r?[d]:S=>S.includes(d)?S.filter(y=>y!==d):S.concat(d))},"onSelect"),f=u?.length===l.length,h=i(()=>{if(r)throw new Error("onSelectAll should not be called on single selection mode.");f?p([]):u&&p(u.map(d=>d.value))},"onSelectAll"),g=i(d=>r?le.createElement(ak,{value:l?.[0]},d):le.createElement(le.Fragment,null,d),"wrapRadioRoot");return lk(()=>{if(!r&&u)if(t.value.defaultSelectedChains?.length){let d=u.filter(S=>S.getSupportedChains(c).some(y=>t.value.defaultSelectedChains?.includes(y.name)));p(d.map(S=>S.value))}else p(u.map(d=>d.value))},[]),le.createElement(le.Fragment,null,le.createElement(ik,{type:"info",title:mn.t("Connect {wallet}",{wallet:e.title}),description:mn.t("This wallet supports multiple chains. Choose which chains you\u2019d like to connect."),icon:le.createElement(sk,null,le.createElement(rk,{src:s,size:45}))}),r?le.createElement(le.Fragment,null,le.createElement(fn,{size:20}),le.createElement(ok,{id:"widget-wallet-stateful-connect-alert",variant:"alarm",type:"info",title:mn.t("This wallet can only connect to one chain at a time. ")}),le.createElement(fn,{size:30})):le.createElement(le.Fragment,null,le.createElement(fn,{size:30}),le.createElement(nk,{style:{marginLeft:"auto"},id:"widget-name-space-select-all-btn",size:"xsmall",variant:"ghost",type:"primary",onClick:h},f?mn.t("Deselect all"):mn.t("Select all")),le.createElement(fn,{size:10})),le.createElement(bi,null,g(le.createElement(le.Fragment,null,a?.data.map((d,S,y)=>le.createElement(le.Fragment,{key:d.id},d.unsupported?le.createElement(vi,{namespace:d}):le.createElement(pd,{value:l.includes(d.value),namespace:d,type:r?"radio":"checkbox",onClick:()=>m(d.value)}),S!==y.length-1&&le.createElement(fn,{size:10})))))),le.createElement(fn,{size:20}),le.createElement(dn,{id:"widget-name-space-confirm-btn",type:"primary",disabled:!l.length,onClick:()=>t.onConfirm(l)},mn.t("Connect")))}i(tr,"Namespaces");import{i18n as or}from"@lingui/core";import{Alert as yk,Button as Sk,Divider as gn,Image as Ck,MessageBox as Tk,WalletImageContainer as kk}from"@rango-dev/ui";import{useWallets as wk}from"@rango-dev/wallets-react";import me from"react";import{styled as uk}from"@rango-dev/ui";var dd=uk("div",{display:"flex",justifyContent:"end"});import{i18n as Ms}from"@lingui/core";import{Button as dk,Spinner as mk}from"@rango-dev/ui";import Ls,{useLayoutEffect as fk,useRef as gk,useState as hk}from"react";function md(t){let{namespace:e,initialConnect:o,disabled:n,state:r,handleConnect:a,handleDisconnect:s}=t,[c,l]=hk(null),p=gk(!1);fk(()=>{o&&!p.current&&u()},[]);let u=i(async g=>{try{p.current=!0,await a(g)}catch(d){l(d)}finally{p.current=!1}},"handleConnectNamespace"),m=i(async()=>{l(null),r.connected?await s():u({shouldAskForDerivationPath:!0})},"handleButtonClick"),f=i(()=>{let g=r.accounts?.[0]?.split(":"),d=g?.[g.length-1];return!r.connected||!d?null:lo(d)},"getConnectedAddress"),h=i(()=>r.connected?Ms.t("Disconnect"):c?Ms.t("Try again"):Ms.t("Connect"),"getButtonText");return Ls.createElement(_o,{namespace:e,connected:r.connected,error:c?.message,address:f(),suffix:r.connecting?Ls.createElement(mk,{color:"info"}):Ls.createElement(dk,{id:"widget-name-space-connect-btn",variant:"ghost",type:r.connected?"error":"primary",size:"xsmall",onClick:async()=>m(),disabled:n},h())})}i(md,"NamespaceDetachedItem");function nr(t){let{value:e,selectedNamespaces:o,onConfirm:n,confirmText:r=or.t("Done"),onDisconnectWallet:a,navigateToDerivationPath:s}=t,{targetWallet:c}=e,{connect:l,disconnect:p,state:u}=wk(),m=c.type,f=u(m),h=c.properties?.find(w=>w.name==="namespaces"),g=c.properties?.find(w=>w.name==="derivationPath"),d=h?.value.selection==="single",S=i(async(w,x)=>{d&&await p(m),g&&x?.shouldAskForDerivationPath?s(w):await l(m,[{namespace:w,network:"",derivationPath:x?.derivationPath??void 0}])},"handleConnectNamespace"),y=i(async w=>{await p(m,[w])},"handleDisconnectNamespace"),C=i(()=>d?me.createElement(me.Fragment,null,me.createElement(gn,{size:20}),me.createElement(yk,{id:"widget-wallet-stateful-connect-alert",variant:"alarm",type:"info",title:or.t("This wallet can only connect to one chain at a time.")}),me.createElement(gn,{size:30})):me.createElement(me.Fragment,null,me.createElement(gn,{size:30}),me.createElement(dd,null,me.createElement(Sk,{id:"widget-detached-disconnect-wallet-btn",variant:"ghost",type:"error",size:"xsmall",disabled:f.connecting||!f.connected,onClick:a},or.t("Disconnect wallet"))),me.createElement(gn,{size:16})),"renderNamespaceListHeader"),k=i(w=>{if(w.unsupported)return me.createElement(vi,{namespace:w});let x=o?.find(b=>b.namespace===w.value),I=f.namespaces?.get(w.value);if(!I)throw new Error(`State for ${w.value} was not found!`);let A=d&&f.connecting;return me.createElement(md,{namespace:w,initialConnect:!!x,disabled:A,state:I,handleConnect:async b=>S(w.value,{derivationPath:x?.derivationPath,shouldAskForDerivationPath:b?.shouldAskForDerivationPath}),handleDisconnect:async()=>y(w.value)})},"renderNamespaceItem");return me.createElement(me.Fragment,null,me.createElement(Tk,{type:"info",title:or.t("Connect {wallet}",{wallet:c.type}),description:or.t("This wallet supports multiple chains. Choose which chains you\u2019d like to connect or disconnect."),icon:me.createElement(kk,null,me.createElement(Ck,{src:c.image,size:45}))}),C(),me.createElement(bi,{id:"widget-detached-namespace-list"},c.needsNamespace?.data.map((w,x,I)=>me.createElement(me.Fragment,{key:w.id},k(w),x!==I.length-1&&me.createElement(gn,{size:10})))),me.createElement(gn,{size:20}),me.createElement(dn,{id:"widget-name-space-confirm-btn",type:"primary",onClick:n},r))}i(nr,"Detached");import{i18n as hn}from"@lingui/core";import{Divider as Ek,Image as Ik,MessageBox as Ak,Select as Nk,TextField as Bk}from"@rango-dev/ui";import xt,{useEffect as Wk,useState as gd}from"react";import{namespaces as vk}from"@rango-dev/wallets-shared";var Ei={id:"custom",label:"Custom",generateDerivationPath:t=>t};function Ps(t){let e=t?vk[t]?.derivationPaths:null;return e?[...e,Ei]:[]}i(Ps,"getDerivationPaths");import{Button as xk,styled as _s,Typography as bk}from"@rango-dev/ui";var fd=_s("div",{paddingTop:"$30",paddingBottom:"$30",zIndex:10}),Ds=_s(bk,{paddingLeft:"$10"}),$s={height:"$40",backgroundColor:"$neutral200",borderRadius:"$sm"},t_=_s(xk,{minHeight:"$40"});var hd="0";function rr(t){let{onConfirm:e}=t,{namespace:o,providerImage:n,providerType:r}=t.value,[a,s]=gd(null),[c,l]=gd(hd),p=a===Ei.id,u=Ps(o),m=i(({value:h})=>{let g=u?.find(d=>d.id===h);g&&(a===Ei.id&&Number.isNaN(Number(c))&&l(hd),s(g.id))},"handleDerivationPathItemClick"),f=i(()=>{let h=u.find(g=>g.id===a);if(h)e(h.generateDerivationPath(c));else throw new Error("selectedDerivationPath can not be undefined")},"handleConfirm");return Wk(()=>{s(Ps(o)[0]?.id||null)},[o]),xt.createElement(xt.Fragment,null,xt.createElement(Ak,{type:"info",title:hn.t("Select Derivation Path"),description:hn.t({id:"In order to connect to {type}, you must first select a Derivation Path",values:{type:r}}),icon:xt.createElement(Ik,{src:n,size:45})}),xt.createElement(fd,{className:"_derivation_path_inputs_container"},xt.createElement(Ds,{variant:"body",size:"xsmall",color:"$neutral600",className:"_derivation_path_input_label"},hn.t("Choose Derivation Path Template")),xt.createElement(Nk,{id:"widget-derivation-path-template-select",value:a||"",options:u.map(h=>({value:h.id,label:h.label})),variant:"filled",handleItemClick:m,styles:{trigger:$s}}),xt.createElement(Ek,{size:20}),xt.createElement(Ds,{variant:"body",size:"xsmall",color:"$neutral600",className:"_derivation_path_input_label"},p?hn.t("Enter Path"):hn.t("Enter Index")),xt.createElement(Bk,{id:"widget-derivation-path-template-input",type:p?"text":"number",variant:"contained",value:c,onChange:h=>l(h.target.value),style:$s})),xt.createElement(dn,{id:"widget-derivation-path-confirm-btn",type:"primary",onClick:f,disabled:!u||!a||!c},hn.t("Confirm")))}i(rr,"DerivationPath");import{i18n as yn}from"@lingui/core";import{Image as Pk,MessageBox as Os,WalletImageContainer as _k,WalletState as Dk}from"@rango-dev/ui";import{useWallets as $k}from"@rango-dev/wallets-react";import Do from"react";import{keyframes as Mk,styled as Fs}from"@rango-dev/ui";var d_=Fs("div",{borderRadius:"$lg",width:"$45",height:"$45",backgroundColor:"$success300",display:"flex",justifyContent:"center",alignItems:"center"}),yd=Fs("div",{position:"relative"}),Lk=Mk({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}),Sd=Fs("div",{position:"absolute",border:"2px solid rgba(0, 0, 0, 0.1)",borderTop:"2px solid $info500",borderRadius:"$lg",width:"$45",height:"$45",animation:`${Lk} 1s linear infinite`,top:0,bottom:0,right:0,left:0});function Us(t){let{wallet:e,error:o}=t,{type:n,image:r}=e,{state:a,getWalletInfo:s}=$k();return Kn(s(n),a(n))===Dk.CONNECTED?Do.createElement(Os,{type:"success",title:yn.t("Wallet Connected"),description:yn.t("Your wallet is connected, you can use it to swap.")}):o?Do.createElement(Os,{type:"error",title:yn.t("Failed to Connect"),description:o||yn.t("Your wallet is not connected. Please try again.")}):Do.createElement(Os,{type:"loading",title:yn.t("Connecting to your wallet"),description:yn.t("Click connect in your wallet popup."),icon:Do.createElement(yd,null,Do.createElement(_k,null,Do.createElement(Pk,{src:r,size:45})),Do.createElement(Sd,null))})}i(Us,"ConnectStatus");import{i18n as zs}from"@lingui/core";import{Button as Fk,Divider as Cd,MessageBox as Ok}from"@rango-dev/ui";import Ii from"react";function Qs(t){let{displayName:e,onConfirm:o,id:n}=t;return Ii.createElement(Ok,{id:n,title:zs.t({id:"Add {blockchainDisplayName} Chain",values:{blockchainDisplayName:e}}),type:"warning",description:zs.t({id:"Would you like to add the {blockchainDisplayName} experimental chain to your wallet?",values:{blockchainDisplayName:e}})},Ii.createElement(Cd,{size:18}),Ii.createElement(Cd,{size:32}),Ii.createElement(Fk,{id:"widget-experimental-chain-confirm-btn",onClick:o,variant:"outlined",type:"primary",fullWidth:!0,size:"large"},zs.t("Confirm")))}i(Qs,"ExperimentalChain");function Td(t,e){return t().status==="init"&&!!e}i(Td,"isOnStatus");function ir(t){return t().status==="namespace"}i(ir,"isOnNamespace");function ar(t){return t().status==="derivationPath"}i(ar,"isOnDerivationPath");function Ao(t){return t().status==="detached"}i(Ao,"isOnDetached");var Hk=3e3,qk=300;function sr(t){let e=Qk(),[o,n]=kd(!1),[r,a]=kd(),s=i(x=>{a(x.message)},"catchErrorOnHandle"),{terminateConnectingWallets:c}=vt(),{handleConnect:l,handleDerivationPath:p,handleNamespace:u,getState:m,resetState:f,handleDisconnect:h}=Ro(),g=i(x=>{u(t.wallet,x).then(k).catch(s)},"handleConfirmNamespaces"),d=i(()=>{y()},"handleDetachedConfirm"),S=i(x=>{if(!x)throw new Error("Derivation path is empty. Please make sure you've filled the field correctly.");p(t.wallet,x).then(k).catch(s)},"handleDerivationPathConfirm"),y=i(()=>{n(!1)},"handleClosingModal"),C=i(()=>{a(void 0),f(),n(!1),e.current&&clearTimeout(e.current)},"resetModalState"),k=i((x,I)=>{let A=x.status==="connected",b=["disconnected","disconnected-unhandled"].includes(x.status);A?(t.onConnect?.(),I||(e.current=setTimeout(y,Hk))):b&&y()},"afterConnected"),w=i(x=>{t.wallet?.needsDerivationPath&&u(t.wallet,[x])},"handleNavigateToDerivationPath");return zk(()=>{if(t.wallet){C();let x=!1,I=!0;i(()=>{setTimeout(()=>{I=!1,x||n(!0)},qk)},"beforeConnecting")(),l(t.wallet,{disconnectIfConnected:!0,defaultSelectedChains:t.options?.defaultSelectedChains}).then(b=>{["namespace","Detached","derivation-path"].includes(b.status)||(x=!0),k(b,I)}).catch(s)}},[t.wallet]),po.createElement(R,{id:t.id,open:o,onClose:y,onExit:()=>{C(),c(),t.onClose&&t.onClose()},container:B()},Td(m,t.wallet)&&po.createElement(po.Fragment,null,po.createElement(Us,{wallet:{type:t.wallet.type,image:t.wallet.image},error:r}),po.createElement(Uk,{direction:"vertical",size:32})),ir(m)&&po.createElement(tr,{onConfirm:g,value:m().namespace}),ar(m)&&po.createElement(rr,{onConfirm:S,value:m().derivationPath}),Ao(m)&&po.createElement(nr,{onConfirm:d,onDisconnectWallet:()=>void h(m().namespace.targetWallet),value:m().namespace,selectedNamespaces:m().selectedNamespaces,navigateToDerivationPath:w}))}i(sr,"StatefulConnectModal");import es from"react";import Gk,{Fragment as Vk}from"react";import{MemoryRouter as Kk,useInRouterContext as jk}from"react-router";function Ai({children:t}){let o=jk()?Vk:Kk;return Gk.createElement(o,null,t)}i(Ai,"AppRouter");import{I18nManager as X0}from"@rango-dev/ui";import _p from"react";import Qe from"react";import{useRoutes as I0}from"react-router-dom";var F={home:"/",fromSwap:"from-swap",toSwap:"to-swap",blockchains:"blockchains",settings:"settings",customTokens:"custom-tokens",addCustomTokens:"add-custom-tokens",liquiditySources:"liquidity-sources",bridges:"bridges",exchanges:"exchanges",languages:"languages",swaps:"swaps",wallets:"wallets",confirmSwap:"confirm-swap",swapDetails:":requestId",routes:"routes"};import{useEffect as Cn,useRef as _i}from"react";import nt from"bignumber.js";import{create as em}from"zustand";import{subscribeWithSelector as tm}from"zustand/middleware";import{createContext as Xk,useContext as Yk}from"react";var wd=Xk({swapMode:"swap",isMultiMode:!1});function ot(){let{swapMode:t,isMultiMode:e}=Yk(wd);return{swapMode:t,isMultiMode:e}}i(ot,"useSwapMode");import{i18n as Ct}from"@lingui/core";import{getRelatedWalletOrNull as Rk,RouteEventType as ND}from"@rango-dev/queue-manager-rango-preset";import qe from"bignumber.js";import{PendingSwapNetworkStatus as cr}from"rango-types";import{i18n as He}from"@lingui/core";var ie=i(()=>({genericServerError:He.t("Failed Network, Please retry your swap."),liquiditySourcesError:{title:He.t("Please reset your liquidity sources."),description:He.t("You have limited the liquidity sources and this might result in Rango finding no routes. Please consider resetting your liquidity sources.")},noResultError:{title:He.t("No Routes Found."),description:He.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:He.t("Bridge Limit Error: Please increase your amount."),decreaseAmount:He.t("Bridge Limit Error: Please decrease your amount.")},highValueLossError:{impactTitle:He.t("High Price Impact"),title:He.t("Price impact is too high!"),description:He.t("The price impact is significantly higher than the allowed amount."),confirmMessage:He.t("Confirm high price impact")},quoteUpdatedWithHighValueLoss:{title:He.t("Route updated and price impact is too high, try again later!")},unknownPriceError:{impactTitle:He.t("USD Price Unknown"),title:He.t("USD Price Unknown, Cannot calculate Price Impact."),description:He.t("USD Price Unknown, Cannot calculate Price Impact. The price impact may be higher than usual. Are you sure to continue the Swap?"),confirmMessage:He.t("Confirm USD Price Unknown")}}),"errorMessages");function vd(t){return t.type===0?t.diagnosisMessage??ie().noResultError.title:t.type===1?t.diagnosisMessage??ie().genericServerError:""}i(vd,"getQuoteErrorMessage");import{i18n as Ni}from"@lingui/core";var $o=i(()=>({connectWallet:Ni.t("Connect Wallet"),swap:Ni.t("Swap"),swapAnyway:Ni.t("Swap anyway"),ethWarning:Ni.t("The route goes through Ethereum. Continue?")}),"swapButtonTitles");function Hs(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(Hs,"getFeeLabel");var qs=["RECOMMENDED","CENTRALIZED","LOWEST_FEE","FASTEST","HIGH_IMPACT"],xd=100,bd=30,Ed=15,Id=60;var Ad=[{threshold:-10,minInput:400},{threshold:-5,minInput:1e3}],Nd=[{threshold:-1,minInput:1e3},{threshold:-2,minInput:500}];import{getLastSuccessfulStep as Jk}from"@rango-dev/queue-manager-rango-preset";import gD from"bignumber.js";function Wd(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(Wd,"getRequiredBalanceOfWallet");function Xt(t){let e;return t<=-3&&t>-10?e="low":t<=-10&&(e="high"),e}i(Xt,"getPriceImpactLevel");function Bi(t,e,o){let n=t.steps[0],r=t.steps[t.steps.length-1],a=Jk(t.steps);if(!r||!n)return{fromBlockchain:null,fromToken:void 0,toBlockchain:null,toToken:void 0,inputAmount:""};let s={blockchain:r.toBlockchain,symbol:r.toSymbol,address:r.toSymbolAddress},c=No(a?a.toBlockchain:n.fromBlockchain,e),l=No(r.toBlockchain,e),p=o(a?{blockchain:c?.name??"",symbol:a.toSymbol,address:a.toSymbolAddress}:{blockchain:c?.name??"",symbol:n.fromSymbol,address:n.fromSymbolAddress}),u=o(s),m=a?a.outputAmount??"":t.inputAmount;return{fromBlockchain:c,fromToken:p,toBlockchain:l,toToken:u,inputAmount:m}}i(Bi,"createRetryQuote");function Sn(t){let{previousQuote:e,currentQuote:o,findToken:n,userSlippage:r}=t,a=lr(o),s=St(o);if(o&&a&&s){let p=jt(a.toString(),s.toString());if(!!p&&Dd(a,p)){let m=Mi(o?.swaps,n),f=Xt(p);return{type:0,inputUsdValue:a,outputUsdValue:s,priceImpact:p,totalFee:m,warningLevel:f}}}if(e&&Od(e,o))return{type:4,usdValueChange:P(St(o)?.minus(St(e)??0).toString()??"0",null,2),percentageChange:P(jt(St(e)??"1",St(o)??"1"),null,2)};if(o&&(!a||!s))return{type:1};let c=Li(o.swaps),l=r>an;if(Fd(t.userSlippage.toString(),c)){if(l&&parseFloat(c??"0")<r)return{type:3,slippage:r.toString()}}else return{type:2,recommendedSlippages:$d(o,r),minRequiredSlippage:c};return null}i(Sn,"generateQuoteWarnings");function Md(t){return![4].includes(t.type)}i(Md,"isQuoteWarningConfirmationRequired");function jt(t,e){let o=typeof e=="string"?parseFloat(e)<=0:!e?.gt(0),n=!t||!e||o?null:Gs(t.toString(),e.toString());return n&&n<0?n:null}i(jt,"getPriceImpact");var Ld=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"),Wi=i((t,e)=>e.sort((o,n)=>{let r=i(p=>p.scores?.find(u=>u.preferenceType===t)?.score??0,"getScore"),a=r(o),s=r(n);if(a!==s)return s-a;let c=o.requestId.toLowerCase(),l=n.requestId.toLowerCase();return c.localeCompare(l)}),"sortQuotesBy"),Pd=i((t,e,o)=>{let n=e[0];if(!e.length||!n)return null;if(!t)return{requestAmount:o,validationStatus:null,...n};let r=new Set(t.swaps.map(s=>s.swapperId)),a=e.find(s=>{let c=new Set(s.swaps.map(l=>l.swapperId));return Array.from(r).every(l=>c.has(l))});return{requestAmount:o,validationStatus:null,...a||n}},"getDefaultQuote"),_d=i(t=>{let e=i((o,n)=>{let r=qs.indexOf(o.value),a=qs.indexOf(n.value);return r!==-1&&a!==-1?r-a:r!==-1?-1:a!==-1?1:0},"customSort");return t.sort(e)},"sortTags");function Dd(t,e){if(!t)return!1;let o=parseInt(e.toFixed(2)||"0");return Ad.some(({threshold:n,minInput:r})=>o<=n&&t.gte(new qe(r)))}i(Dd,"hasHighValueLoss");function Ud(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(Ud,"hasLimitError");function zd(t){let e=(t||[]).filter(c=>{let l=c.fromAmountMinValue?new qe(c.fromAmountMinValue):null,p=c.fromAmountMaxValue?new qe(c.fromAmountMaxValue):null;return c.fromAmountRestrictionType==="EXCLUSIVE"?l?.gte(c.fromAmount)||p?.lte(c.fromAmount):l?.gt(c.fromAmount)||p?.lt(c.fromAmount)})[0];if(!e)return{swap:void 0,fromAmountRangeError:"",recommendation:""};let 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=Ct.t({id:"Required: >= {min} {symbol}",values:{min:P(o,6,6),symbol:e.from.symbol}}),s=ie().bridgeLimitErrors.increaseAmount):r&&o&&o.gte(e.fromAmount)&&(a=Ct.t({id:"Required: > {min} {symbol}",values:{min:P(o,6,6),symbol:e.from.symbol}}),s=ie().bridgeLimitErrors.increaseAmount),!r&&n&&n.lt(e.fromAmount)?(a=Ct.t({id:"Required: <= {max} {symbol}",values:{max:P(n,6,6),symbol:e.from.symbol}}),s=ie().bridgeLimitErrors.decreaseAmount):r&&n&&n.lte(e.fromAmount)&&(a=Ct.t({id:"Required: < {max} {symbol}",values:{max:P(n,6,6),symbol:e.from.symbol}}),s=ie().bridgeLimitErrors.decreaseAmount),{swap:e,fromAmountRangeError:a,recommendation:s}}i(zd,"getLimitErrorMessage");function Qd(t){let{fetchMetaStatus:e,anyWalletConnected:o,fetchingQuote:n,inputAmount:r,quote:a,warning:s,error:c,needsToWarnEthOnPath:l}=t;return e!=="success"?{title:$o().connectWallet,action:"connect-wallet",disabled:!0}:o?n||!a||c||!r||r==="0"?{title:$o().swap,action:"confirm-swap",disabled:!0}:s?{title:$o().swapAnyway,action:"confirm-warning",disabled:!1}:l?{title:$o().ethWarning,action:"confirm-warning",disabled:!1}:{title:$o().swap,action:"confirm-swap",disabled:!1}:{title:$o().connectWallet,action:"connect-wallet",disabled:!1}}i(Qd,"getSwapButtonState");function Vs(t,e,o){let n=parseFloat(e||"0");return!(t&&(!o||o.lte(de))&&e&&e!=="0"&&n!==0)}i(Vs,"canComputePriceImpact");function Ks(t,e){let o=de;for(let n=0;n<t.fee.length;n++){let r=t.fee[n];if(!r||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(Ks,"getUsdFeeOfStep");function Mi(t,e){return t.reduce((o,n)=>o.plus(Ks(n,e)),de)}i(Mi,"getTotalFeeInUsd");function js(t){let e=de,o=new qe(t.price||0);return e=e.plus(new qe(t.amount).multipliedBy(o)),e}i(js,"getUsdFee");function Hd(t){return t.reduce((e,o)=>e.plus(js(o)),de)}i(Hd,"getTotalFeesInUsd");function qd(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(qd,"getFeesGroup");function Gd(t){let e=new Map;return t.forEach((o,n)=>{o.recommendedSlippage?.error&&e.set(n,o.recommendedSlippage.slippage)}),e.size>0?Object.fromEntries(e):null}i(Gd,"checkSlippageErrors");function $d(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?Object.fromEntries(o):null}i($d,"checkSlippageWarnings");function Li(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(Li,"getMinRequiredSlippage");function Fd(t,e){return e?parseFloat(t)>=parseFloat(e):!0}i(Fd,"hasProperSlippage");function Vd(t){let{fromToken:e,toToken:o,inputAmount:n,wallets:r,selectedWallets:a,disabledLiquiditySources:s,liquiditySources:c,excludeLiquiditySources:l,slippage:p,affiliateRef:u,affiliatePercent:m,affiliateWallets:f,destination:h,contractCall:g}=t,d=a?.reduce((C,k)=>(C[k.chain]=k.address,C),{}),S=[];return r?.forEach(C=>{S.push({blockchain:C.chain,addresses:[C.address]})}),{amount:n.toString(),affiliateRef:u??void 0,affiliatePercent:m??void 0,affiliateWallets:f??void 0,from:{address:e.address,blockchain:e.blockchain,symbol:e.symbol},to:{address:o.address,blockchain:o.blockchain,symbol:o.symbol},connectedWallets:S,selectedWallets:d??{},slippage:p.toString(),contractCall:g,...h&&{destination:h},...l&&{swapperGroups:s.concat(c??[]),swappersGroupsExclude:!0},...!l&&{swapperGroups:c?.filter(C=>!s.includes(C)),swappersGroupsExclude:!1}}}i(Vd,"createQuoteRequestBody");function Kd(t){return t.reduce((o,n)=>(o[n.chain]={address:n.address,walletType:n.walletType,derivationPath:n.derivationPath},o),{})}i(Kd,"getWalletsForNewSwap");function lr(t){let e=t.requestAmount,o=t.swaps[0]?.from.usdPrice;if(!(!e||!o))return new qe(e).multipliedBy(o)}i(lr,"getUsdInputFrom");function St(t){let e=t?.outputAmount||null,o=t.swaps[t.swaps.length-1]?.to.usdPrice;if(!(!e||!o))return new qe(e).multipliedBy(o)}i(St,"getUsdOutputFrom");function Gs(t,e){return new qe(e).div(new qe(t)).minus(1).multipliedBy(xd).toNumber()}i(Gs,"getPercentageChange");function Od(t,e){let o=lr(t),n=St(t),r=St(e);if(!o||!n||!r)return!1;let a=Gs(n.toString(),r.toString());return Nd.some(({threshold:s,minInput:c})=>a<=s&&o.isGreaterThanOrEqualTo(c))}i(Od,"isOutputAmountChangedExcessively");function jd(t,e,o){let n=t.validationStatus,r=Mo({filter:"required",quote:t});return e.sort((s,c)=>r.indexOf(s.chain)-r.indexOf(c.chain)).flatMap(s=>Wd(s,n)||[]).filter(s=>!s.ok).map(s=>{let c=s.asset.symbol,l=P(new qe(s.currentAmount.amount).shiftedBy(-s.currentAmount.decimals),8,8),p=P(new qe(s.requiredAmount.amount).shiftedBy(-s.requiredAmount.decimals),8,8),u="";return s.reason==="FEE"&&(u=Ct.t(" for network fee")),s.reason==="INPUT_ASSET"&&(u=Ct.t(" for swap")),s.reason==="FEE_AND_INPUT_ASSET"&&(u=Ct.t(" for input and network fee")),Ct.t({id:"Needs \u2248 {requiredAmount} {symbol}{reason}, but you have {currentAmount} {symbol} in your {blockchain} wallet.",values:{requiredAmount:p,symbol:c,reason:u,currentAmount:l,blockchain:ht(s.asset.blockchain,o)}})})}i(jd,"generateBalanceWarnings");function pr(t){return!!t&&t.networkStatus!==null&&t.networkStatus!==cr.NetworkChanged}i(pr,"isNetworkStatusInWarningState");function Xd(t,e,o){let n="bellow button or",r=t.extraMessage,a=t.extraMessageDetail;if(t.networkStatusExtraMessageDetail?.includes(n)&&(t.networkStatusExtraMessageDetail=t.networkStatusExtraMessageDetail.replace(n,"")),pr(e)){r=t.networkStatusExtraMessage||"",a=t.networkStatusExtraMessageDetail||"";let p=(e?Rk(t,e):null)?.walletType,u=p?o?.(p)?.name:null;switch(e?.networkStatus){case cr.WaitingForConnectingWallet:r=u?Ct.t("Connect {wallet}",{wallet:u}):r;break;case cr.WaitingForQueue:r=r||Ct.t("Waiting for other running tasks to be finished");break;case cr.WaitingForNetworkChange:r=r||Ct.t("Waiting for changing wallet network");break;case cr.NetworkChangeFailed:r=r||Ct.t("The network switch could not be completed. Please try again, or switch the network manually in your wallet.");break;default:r=r||"";break}}a=a||"",r=r||"";let c=r?.indexOf("code")!==-1&&r?.indexOf("reason")!==-1;return{shortMessage:r,detailedMessage:{content:a,long:c}}}i(Xd,"getSwapMessages");function Yd(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(Yd,"getLastConvertedTokenInFailedSwap");function Zd(t){return t.status==="failed"}i(Zd,"shouldRetrySwap");function Jd(t,e,o,n,r,a){if(!n||t)return!0;let s=Mo({filter:"all",quote:n}),c=Mo({filter:"required",quote:n}),l=s.every(m=>r.some(f=>f.chain===m)),p=c.every(m=>r.some(f=>f.chain===m)),u=o&&a?tn(a,o):!1;return!e&&!l||e&&!o||e&&!!o&&(!u||!p)}i(Jd,"isConfirmSwapDisabled");function Rd(t,e){return t.blockchain===e.blockchain&&t.symbol===e.symbol&&t.address===e.address}i(Rd,"isTokensIdentical");var Pi=i((t,e)=>t?.usdPrice?new nt(e||de).multipliedBy(t?.usdPrice||0):null,"getUsdValue"),om=i(t=>({fromBlockchain:null,fromToken:null,inputAmount:"",outputAmount:null,inputUsdValue:new nt(0),outputUsdValue:new nt(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=de,a=o.inputUsdValue;return Vn(o.inputAmount)?(e&&(n=e?.outputAmount?new nt(e?.outputAmount):null,a=lr(e)??de,r=St(e)??de),{selectedQuote:e,...!!e&&{outputAmount:n,outputUsdValue:r,inputUsdValue:a}}):{}}),resetAlerts:()=>t(()=>({error:null,warning:null})),resetQuote:()=>t(()=>({selectedQuote:null,outputAmount:null,outputUsdValue:new nt(0),quotes:null,refetchQuote:!0,error:null,warning:null})),setFromBlockchain:e=>{t(o=>o.fromBlockchain?.name===e?.name?{}:{fromBlockchain:e,inputUsdValue:new nt(0),...o.fromToken&&{selectedQuote:null,fromToken:null,outputAmount:null,outputUsdValue:new nt(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:Pi(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 nt(0)}})},setToToken:e=>t(()=>({toToken:e.token,...e.token&&{toBlockchain:e.meta.blockchains.find(o=>o.name===e.token.blockchain)??null}})),sanitizeInputAmount:e=>{let o=ku(e);t(()=>({inputAmount:o}))},setInputAmount:e=>{let o=e;li(e)||(o=mu(o),o=fu(o)),t(n=>({inputAmount:o,...!o&&{outputAmount:null,outputUsdValue:new nt(0),selectedQuote:null},...!!n.fromToken&&{inputUsdValue:Pi(n.fromToken,o)}}))},retry:e=>{let{fromBlockchain:o,fromToken:n,toBlockchain:r,toToken:a,inputAmount:s}=e;t({fromBlockchain:o,fromToken:n,inputAmount:s,outputAmount:null,inputUsdValue:Pi(n??null,s),outputUsdValue:new nt(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?Pi(e.toToken,e.outputAmount?.toString()||""):new nt(0)})),resetFromBlockchain:()=>t(()=>({fromToken:null,fromBlockchain:null,outputUsdValue:new nt(0),inputUsdValue:new nt(0),inputAmount:"",outputAmount:null,selectedQuote:null})),resetToBlockchain:()=>t(()=>({toToken:null,toBlockchain:null,outputAmount:null,outputUsdValue:new nt(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})}),"initializer"),nm=em()(tm(om)),rm=em()(tm(om)),ew=co(nm),tw=co(rm);function z(){let{swapMode:t}=ot();return co(t==="refuel"?rm:nm)}i(z,"useQuoteStore");var im=i((t,e)=>{(t.fromBlockchain!==e.fromBlockchain||t.fromToken!==e.fromToken||t.toBlockchain!==e.toBlockchain||t.toToken!==e.toToken||t.inputAmount!==e.inputAmount)&&we.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&&we.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})},"subscribeCallback"),am=ew.subscribe(im),sm=tw.subscribe(im);function lm(){let{setInputAmount:t,setToToken:e,setToBlockchain:o,setFromBlockchain:n,resetQuote:r,setFromToken:a,fromToken:s,toToken:c,fromBlockchain:l,toBlockchain:p}=z()(),u=T().config,m=T().fetchStatus,f=T().blockchains(),{findToken:h}=T(),{setAffiliateRef:g,setAffiliatePercent:d,setAffiliateWallets:S}=T(),y=u?.from?.tokens,C=u?.from?.blockchains,k=u?.to?.tokens,w=u?.to?.blockchains,x=_i(void 0),I=_i(void 0),A=_i(void 0),b=_i(void 0);Cn(()=>{typeof u.amount<"u"&&t(u.amount.toString())},[u?.amount]),Cn(()=>{if(m==="success"){r();let E=f.find(W=>W.name===u?.from?.blockchain),v=u?.from?.token,N=v&&h(v);(E||!E&&A.current)&&n(E??null),N?a({token:N,meta:{blockchains:f}}):!N&&x.current&&a({token:null}),A.current=u?.from?.blockchain,x.current=u?.from?.token}},[u?.from?.token?.symbol,u?.from?.token?.address,u?.from?.token?.blockchain,u?.from?.blockchain,m]),Cn(()=>{hs(s,y)&&a({token:null}),ys(l,C)&&n(null)},[y,C]),Cn(()=>{hs(c,k)&&a({token:null}),ys(p,w)&&o(null)},[k,w]),Cn(()=>{if(m==="success"){r();let E=f.find(W=>W.name===u?.to?.blockchain),v=u?.to?.token,N=v&&h(v);(E||!E&&b.current)&&o(E??null),N?e({token:N,meta:{blockchains:f}}):!N&&I.current&&e({token:null}),b.current=u?.to?.blockchain,I.current=u?.to?.token}},[u?.to?.token?.symbol,u?.to?.token?.address,u?.to?.token?.blockchain,u?.to?.blockchain,m]),Cn(()=>{g(u?.affiliate?.ref??null),d(u?.affiliate?.percent??null),S(u?.affiliate?.wallets??null)},[u?.affiliate?.ref,u?.affiliate?.percent,u?.affiliate?.wallets])}i(lm,"useSyncStoresWithConfig");import{useEffect as Zs,useRef as ow}from"react";import{useInRouterContext as nw,useLocation as rw,useSearchParams as iw}from"react-router-dom";function Xs(t,e){let o=t.split("--");return o[0]?{blockchain:e.name,address:o?.[1]||null,symbol:o[0]}:null}i(Xs,"convertTokenSearchParamToAsset");function Ys(t){if(t)return`${t.symbol}${t.address?`--${t.address}`:""}`}i(Ys,"tokenToSearchParam");function Rs(){let t=rw(),[e,o]=iw(),{fromBlockchain:n,toBlockchain:r,fromToken:a,toToken:s,inputAmount:c,setFromBlockchain:l,setToBlockchain:p,setFromToken:u,setToToken:m,setInputAmount:f}=z()(),h=T().fetchStatus,g=T().blockchains(),d=nw(),{updateIframe:S,updateCampaignMode:y}=T(),C=T().isInCampaignMode(),k=ow(),{findToken:w}=T(),x=i(()=>{let A={};for(let[M,ee]of e.entries())M.startsWith("utm_")&&(A[M]=ee);let b=e.get("fromAmount"),E=e.get("fromBlockchain"),v=e.get("fromToken"),N=e.get("toBlockchain"),W=e.get("toToken"),D=e.get("autoConnect"),H=e.get("clientUrl"),X=e.get("liquiditySources"),Y=e.get("blockchain");return{fromAmount:b,fromBlockchain:E,fromToken:v,toBlockchain:N,toToken:W,autoConnect:D,clientUrl:H,liquiditySources:X,utmQueryParams:A,blockchain:Y}},"getUrlSearchParams"),I=i(A=>{for(let b in A)A[b]||delete A[b];o(A,{replace:!0})},"updateUrlSearchParams");Zs(()=>{let{autoConnect:A,clientUrl:b,utmQueryParams:E,blockchain:v}=x();d&&h==="success"&&I({fromBlockchain:n?.name,fromToken:Ys(a),toBlockchain:r?.name,toToken:Ys(s),fromAmount:c,autoConnect:A??void 0,clientUrl:b??void 0,blockchain:v??void 0,liquiditySources:C?k.current:void 0,...E})},[t.pathname,c,n,a,r,s,C,h]),Zs(()=>{if(!d)return;let A=x();if(!k.current&&A.liquiditySources&&(k.current=A.liquiditySources),A.fromAmount&&f(A.fromAmount),h==="success"){let b=g.find(H=>H.name===A.fromBlockchain),E=A.fromToken&&b&&Xs(A.fromToken,b),v=E?w(E):void 0,N=g.find(H=>H.name===A.toBlockchain),W=A.toToken&&N&&Xs(A.toToken,N),D=W?w(W):void 0;b&&(l(b),v&&u({token:v,meta:{blockchains:g}})),N&&(p(N),D&&m({token:D,meta:{blockchains:g}}))}},[h]),Zs(()=>{let{clientUrl:A,liquiditySources:b}=x();S("clientUrl",A||void 0),y("liquiditySources",b?.split(",")??void 0)},[])}i(Rs,"useSyncUrlAndStore");import{i18n as vn}from"@lingui/core";import{Alert as Bv,Button as Wv,darkTheme as Mv,Divider as Nl,DoneIcon as Lv,styled as Pv,TextField as _v,Typography as Dv}from"@rango-dev/ui";import Ve,{useState as $v}from"react";import{useNavigate as Fv,useSearchParams as Ov}from"react-router-dom";import{ChevronRightIcon as aw,Divider as mm,Image as sw,Typography as fm}from"@rango-dev/ui";import bt from"react";import{darkTheme as cm,styled as el}from"@rango-dev/ui";var pm=el("div",{display:"flex",justifyContent:"space-between",width:"100%",height:"$40",padding:"$4 $10",borderRadius:"$sm",cursor:"pointer",alignItems:"center",backgroundColor:"$neutral300",[`.${cm} &`]:{backgroundColor:"$neutral400"},"&:hover":{backgroundColor:"$secondary100",[`.${cm} &`]:{backgroundColor:"$neutral500"}},variants:{disabled:{true:{cursor:"default","&:hover":{borderColor:"$neutral300","& svg":{color:"$neutral700"}}}}}}),um=el("div",{display:"flex",flexDirection:"column",width:"100%",".title_typography":{textTransform:"capitalize"}}),dm=el("div",{display:"flex"});function tl(t){let{onClick:e,value:o,title:n,hasLogo:r,placeholder:a,disabled:s}=t;return bt.createElement(um,null,bt.createElement(fm,{size:"large",variant:"label"},n),bt.createElement(mm,{size:10}),bt.createElement(pm,{onClick:s?void 0:e,disabled:s,id:"widget-blockchain-selector-container"},bt.createElement(dm,null,r&&bt.createElement(bt.Fragment,null,bt.createElement(sw,{src:o?.logo,size:16,useAsPlaceholder:!o?.logo,type:"circular"}),bt.createElement(mm,{size:4,direction:"horizontal"})),bt.createElement(fm,{className:"title_typography",size:"medium",variant:"label"},o?.name||a)),bt.createElement(aw,{size:12,color:"black"})))}i(tl,"BlockchainSelectorButton");import{i18n as il}from"@lingui/core";import{Button as gw,Divider as Tm,MessageBox as hw}from"@rango-dev/ui";import uo,{useEffect as km,useState as al}from"react";import{i18n as Di}from"@lingui/core";import{Divider as Fo,ExternalLinkIcon as pw,Image as uw,InfoIcon as dw,Tooltip as mw,Typography as dr}from"@rango-dev/ui";import fe from"react";var gm="https://blog.rango.exchange/understanding-the-risks-of-using-custom-token-contract-addresses-96022308eca4";function hm(t,e){if(e.type==="COSMOS")return"";let o=e.info?.addressUrl;return!o||!t?"":o.replace("{wallet}",t)}i(hm,"generateExplorerLink");import{Button as lw,darkTheme as Tn,styled as ur,Typography as cw}from"@rango-dev/ui";var ol=ur("a",{textDecoration:"none",color:"$colors$neutral700",[`.${Tn} &`]:{color:"$colors$neutral900"},"& svg":{marginLeft:"$4",color:"$colors$neutral700",[`.${Tn} &`]:{color:"$colors$neutral900"}},variants:{hasHover:{true:{"&:hover":{color:"$colors$secondary550",[`.${Tn} &`]:{color:"$colors$secondary500"},"& svg":{color:"$colors$secondary550",[`.${Tn} &`]:{color:"$colors$secondary500"}}}},false:{}}}}),ym=ur("div",{display:"flex",justifyContent:"center",flexDirection:"column",alignItems:"center",textAlign:"center","& ._blockchain-name, & ._coin-source":{color:"$colors$neutral600",[`.${Tn} &`]:{color:"$colors$neutral800"}},"& ._coin-source-name, & ._custom-token-description":{color:"$colors$neutral700",[`.${Tn} &`]:{color:"$colors$neutral900"}}}),nl=ur(lw,{minHeight:"$40"}),Sm=ur(cw,{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"96px"}),Cm=ur("div",{display:"flex",justifyContent:"center",alignItems:"center"});var fw=9;function rl(t){let{open:e,onClose:o,token:n,onExit:r,onSubmitClick:a,blockchain:s}=t,c=hm(n.address,s),l=i(()=>window.open(gm,"_blank"),"onClickLearnMore");return fe.createElement(R,{open:e,id:"widget-custom-token-watermarked-modal",dismissible:!0,onClose:o,onExit:r,container:B()},fe.createElement(ym,null,fe.createElement(uw,{src:n.image===""?ni:n.image,size:45,type:"circular"}),fe.createElement(Fo,{size:4}),fe.createElement(Cm,null,fe.createElement(Sm,{variant:"title",size:"medium"},n.symbol),n.symbol.length>fw&&fe.createElement(mw,{content:n.symbol,container:B()},fe.createElement(dw,{size:12,color:"gray"}))),fe.createElement(dr,{variant:"body",size:"small",className:"_blockchain-name"},s.displayName),fe.createElement(Fo,{size:4}),fe.createElement(dr,{variant:"body",size:"medium"},c?fe.createElement(ol,{hasHover:!0,href:c,target:"_blank",rel:"nofollow noreferrer"},n.address,fe.createElement(pw,{size:12,color:"gray"})):fe.createElement(ol,null,n.address)),fe.createElement(Fo,{size:4}),n.coinSource&&fe.createElement(dr,{className:"_coin-source",variant:"body",size:"xsmall"},Di.t("via")," ",fe.createElement(dr,{className:"_coin-source-name",variant:"body",size:"xsmall"},n.coinSource)),fe.createElement(Fo,{size:"32"}),fe.createElement(dr,{size:"medium",variant:"body",className:"_custom-token-description"},Di.t("This token is not part of our verified token list. please verify its source and make sure to understand all associated risks before proceeding."))),fe.createElement(Fo,{size:40}),fe.createElement(Fo,{size:10}),fe.createElement(nl,{id:"widget-custom-token-modal-import-btn",variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:a},Di.t("Import Anyway")),fe.createElement(Fo,{size:10}),fe.createElement(nl,{id:"widget-custom-token-modal-learn-more-btn",variant:"outlined",size:"large",type:"primary",fullWidth:!0,onClick:l},Di.t("Learn More")))}i(rl,"CustomTokenModal");function mr(t){let{token:e,blockchain:o,error:n,address:r,fetchCustomToken:a,onCloseErrorModal:s,onImport:c,onExitErrorModal:l,onExitImportModal:p}=t,{setCustomToken:u}=T(),[m,f]=al(!1),[h,g]=al(!1),[d,S]=al(!1),y=i(()=>{o&&a?.({blockchain:o.name,tokenAddress:r})},"getCustomToken"),C=i(()=>{n?.type!=="network-error"&&s?.(),f(!1)},"closeErrorModal"),k=i(()=>{S(!0),C()},"handleErrorModalButtonClick"),w=i(()=>{d&&n?.type==="network-error"&&(S(!1),y()),l()},"handleExit"),x=i(()=>{e&&(u(e),c())},"handleSubmit");return km(()=>{n&&f(!0)},[n]),km(()=>{o&&e&&g(!0)},[o,e]),uo.createElement(uo.Fragment,null,uo.createElement(R,{open:m,dismissible:!0,id:"widget-add-custom-token-modal",onClose:C,onExit:w,container:B()},uo.createElement(hw,{title:n?.title??"",type:"error",description:n?.message||il.t("Failed Network, Please retry.")},uo.createElement(Tm,{size:40}),uo.createElement(Tm,{size:10}),uo.createElement(gw,{id:`widget-add-custom-token-${n?.type==="network-error"?"retry":"add-another"}-btn`,variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:k},n?.type==="network-error"?il.t("Retry"):il.t("Add another custom token")))),o&&e&&uo.createElement(rl,{blockchain:o,token:e,onSubmitClick:x,onClose:()=>g(!1),open:h,onExit:p}))}i(mr,"ImportCustomToken");import{useManager as xv}from"@rango-dev/queue-manager-react";import{BottomLogo as bv,Divider as ef,Header as Ev}from"@rango-dev/ui";import We,{useEffect as Gi,useLayoutEffect as Iv,useRef as tf,useState as of}from"react";import{useRef as yw}from"react";function fr(){return window.self!==window.top}i(fr,"isAppLoadedIntoIframe");function sl(){let t=yw(null),{iframe:e}=T(),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(c=>{for(let l of c)n({type:"widget_height",data:{height:l.contentRect.height}})}),t.current.observe(s)},"connectHeightObserver"),disconnectHeightObserver:i(()=>{t.current&&(t.current.disconnect(),t.current=null)},"disconnectHeightObserver")}}i(sl,"useIframe");import{useNavigate as Sw}from"react-router-dom";function Ge(){let t=Sw();return()=>t(-1)}i(Ge,"useNavigateBack");import{useLayoutEffect as Cw,useState as gr}from"react";var wm=480,vm=768,xm=1024,bm=1200,Tw=i(()=>{let[t,e]=gr(!1),[o,n]=gr(!1),[r,a]=gr(!1),[s,c]=gr(!1),[l,p]=gr(!1),u=i(()=>{e(window.innerWidth<=wm),n(window.innerWidth>wm&&window.innerWidth<=vm),a(window.innerWidth>vm&&window.innerWidth<=xm),c(window.innerWidth>xm&&window.innerWidth<=bm),p(window.innerWidth>bm)},"handleResize");return Cw(()=>(u(),window.addEventListener("resize",u),()=>window.removeEventListener("resize",u)),[]),{isMobile:t,isTablet:o,isNotebook:r,isLargeScreen:s,isExtraLargeScreen:l}},"useScreenDetect"),kn=Tw;import{createTheme as fl,darkTheme as Lw,lightTheme as Pw}from"@rango-dev/ui";import{useEffect as _w,useState as Dw}from"react";import{theme as Ww,darkColors as Mw}from"@rango-dev/ui";import dl from"react";var $i=16,Fi=255,Em=.11;function kw(t){return t.startsWith("#")&&(t=t.slice(1)),t.length===3?`#${t.split("").reduce(function(n,r){return n+r+r},"")}`:`#${t}`}i(kw,"expandShortHexColor");function ww(t,e){return t.padStart(e,"0")}i(ww,"pad");function ll(t){let e=Math.min(Math.max(Math.round(t),0),Fi);return ww(e.toString($i),2)}i(ll,"intToHex");function vw(t){return`#${ll(t.red)}${ll(t.green)}${ll(t.blue)}`}i(vw,"rgbToHex");function xw(t){let e=parseInt(t.slice(1,3),$i),o=parseInt(t.slice(3,5),$i),n=parseInt(t.slice(5,7),$i);return{red:e,green:o,blue:n}}i(xw,"hexToRGB");function bw(t,e){let o=1-Em*e;return{red:t.red*o,green:t.green*o,blue:t.blue*o}}i(bw,"generateShade");function Ew(t,e){let o=Em*e;return{red:t.red+(Fi-t.red)*o,green:t.green+(Fi-t.green)*o,blue:t.blue+(Fi-t.blue)*o}}i(Ew,"generateTint");function Iw(t){return Im(t,bw)}i(Iw,"calculateShades");function Aw(t){return Im(t,Ew)}i(Aw,"calculateTints");function Im(t,e){let o=xw(t),n=[];for(let r=1;r<9;r++)n.push(vw(e(o,r)));return n}i(Im,"calculateColors");function cl(t,e,o){let a=Aw(t).reverse().concat(t),s=Iw(t),c=a.concat(s),l={},p=c.length;for(let u=0;u<p;u++){let m=100+(o?p-1-u:u)*50,f=c[u];f&&(l[`${e}${m}`]=f)}return l}i(cl,"createTintsAndShades");function pl(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)&&!Cu(r)){let l=kw(a);Object.assign(n,cl(l,r,s))}}return{...n,...e}}i(pl,"expandToGenerateThemeColors");var Am=i(t=>String.fromCharCode(t+(t>25?39:97)),"toAlphabeticChar"),Nw=i(t=>{let e="",o;for(o=Math.abs(t);o>52;o=o/52|0)e=Am(o%52)+e;return Am(o%52)+e},"toAlphabeticName"),Bw=i((t,e)=>{let o=e.length;for(;o;)t=t*33^e.charCodeAt(--o);return t},"toPhash"),ul=i(t=>Nw(Bw(5381,JSON.stringify(t))>>>0),"toHash");function ml(t){let e=Ww.colors,o={...e,...Mw},n,r;if(t?.light){let s={colors:pl(e,t.light)};n={id:`${gs}-light-${ul(s)}`,tokens:s}}if(t?.dark){let s={colors:pl(o,t.dark,{reverseNeutralRange:!0})};r={id:`${gs}-dark-${ul(s)}`,tokens:s}}return{light:n,dark:r}}i(ml,"customizedThemeTokens");function Nm(t,e){if(t.length<=1)return t.map(({element:n,key:r})=>dl.cloneElement(n,{key:r}));let o=[];return t.forEach((n,r)=>{let{element:a,key:s}=n;if(o.push(dl.cloneElement(a,{key:s})),r<t.length-1){let c=`divider-${r}`;o.push(dl.cloneElement(e,{key:c}))}}),o}i(Nm,"joinList");function Bm(){return window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches}i(Bm,"doesWindowPreferDarkColorScheme");function mo(t){let{colors:e,fontFamily:o=nu,borderRadius:n=Lu,secondaryBorderRadius:r=Pu}=t,[a,s]=Dw(Bm()?"dark":"light"),{theme:c}=T(),{dark:l,light:p}=ml(e),u=fl({shadows:t.shadows||{},radii:{primary:`${n}px`,secondary:`${r}px`},fonts:{widget:o}}),m=[u.className,Pw.className],f=[u.className,Lw.className];if(p){let g=fl(p.id,p.tokens);m.push(g.className)}if(l){let g=fl(l.id,l.tokens);f.push(g.className)}return _w(()=>{let g=i(d=>{d.matches?s("dark"):s("light")},"switchThemeListener");return Bm()&&s("dark"),window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",g),()=>{window.matchMedia("(prefers-color-scheme: dark)").removeEventListener("change",g)}},[]),{activeTheme:i(()=>{let g=m.join(" "),d=f.join(" ");return c==="auto"?a==="dark"?d:g:c==="dark"?d:g},"getActiveTheme"),mode:c==="auto"?a:c}}i(mo,"useTheme");var Tt=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 Wm}from"@lingui/core";import{Alert as $w,Button as Fw}from"@rango-dev/ui";import Mm from"react";function gl(t){return Mm.createElement($w,{action:Mm.createElement(Fw,{id:"widget-active-tab-btn",onClick:t.onActivateTab,variant:"contained",size:"xxsmall",type:"warning"},Wm.t("Activate this tab")),type:"warning",variant:"alarm",title:Wm.t("Another tab is open and handles transactions.")})}i(gl,"ActivateTabAlert");import{i18n as hl}from"@lingui/core";import{Button as Ow,Divider as Uw,MessageBox as zw}from"@rango-dev/ui";import Oi from"react";function yl(t){let{open:e,onClose:o,onConfirm:n}=t;return Oi.createElement(R,{open:e,dismissible:!0,onClose:o,id:"widget-active-tab-modal",container:B()},Oi.createElement(zw,{title:hl.t("Activate current tab"),type:"warning",description:hl.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.")},Oi.createElement(Uw,{size:20}),Oi.createElement(Ow,{id:"widget-modal-confirm-activate-tab-btn",variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:n},hl.t("Confirm"))))}i(yl,"ActivateTabModal");import{ChevronLeftIcon as qw}from"@rango-dev/ui";import Um from"react";import{css as Qw,darkTheme as Lm,IconButton as Hw,styled as Oo}from"@rango-dev/ui";var Dt=Oo(Hw,{width:"$24",position:"relative",padding:"0",overflow:"unset","&:hover":{backgroundColor:"$secondary100",[`.${Lm} &`]:{backgroundColor:"$neutral"}}}),Pm=Oo("div",{position:"absolute",background:"$secondary500",[`.${Lm} &`]:{$$color:"$colors$secondary250"},width:"$6",height:"$6",borderRadius:"$lg",right:"$4",border:"1px solid $surface100"}),fo=Oo("div",{display:"flex",justifyContent:"flex-end",minWidth:"$40",button:{padding:0}}),_m=Oo("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"}}}}),Dm=Oo("div",{padding:"$2",variants:{isRefetched:{true:{transform:"rotate(360deg)",transition:"transform 1s ease-in-out"}}}}),$m=Oo("div",{position:"absolute",right:"$4",top:"$4",backgroundColor:"$background",borderRadius:"100%"}),Fm=Qw({display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center"}),Om=Oo("div",{borderRadius:"100%",border:"1.5px transparent solid","&:not(:first-child)":{marginLeft:"-$6"},img:{borderRadius:"100%"}});function Sl(t){return Um.createElement(Dt,{id:"widget-header-back-icon-btn",variant:"ghost",size:"small",onClick:t.onClick},Um.createElement(qw,{color:"black",size:16}))}i(Sl,"BackButton");import{i18n as Gw}from"@lingui/core";import{Button as Vw,Typography as Kw}from"@rango-dev/ui";import Cl from"react";function Tl(t){return Cl.createElement(fo,null,Cl.createElement(Vw,{id:"widget-header-cancel-btn",variant:"ghost",onClick:t.onClick,size:"xsmall"},Cl.createElement(Kw,{variant:"label",size:"medium",color:"error500"},Gw.t("Cancel"))))}i(Tl,"CancelButton");import{i18n as jw}from"@lingui/core";import{Image as Xw,Tooltip as Yw,WalletIcon as Zw,WalletState as zm}from"@rango-dev/ui";import Uo from"react";function kl(t){let{list:e}=vt(),o=e.filter(r=>r.state===zm.CONNECTED||r.state===zm.PARTIALLY_CONNECTED),n=o.length?Uo.createElement("div",{className:Fm()},o.map(r=>Uo.createElement(Om,{key:r.title},Uo.createElement(Xw,{src:r.image,size:14})))):jw.t("Connect Wallet");return Uo.createElement(Yw,{container:t.container,side:"bottom",content:n},Uo.createElement(Dt,{id:"widget-header-wallet-icon-btn",variant:"ghost",size:"small",onClick:t.onClick},t.isConnected&&Uo.createElement(Pm,null),Uo.createElement(Zw,{size:18,color:"black"})))}i(kl,"WalletButton");import{i18n as zi}from"@lingui/core";import{NotificationsIcon as mv,Popover as fv,SettingsIcon as gv,Tooltip as Qi,TransactionIcon as hv}from"@rango-dev/ui";import Pe from"react";import{Notifications as tv}from"@rango-dev/ui";import ov from"react";import{useNavigate as nv}from"react-router-dom";import{create as Jw}from"zustand";import{persist as Rw,subscribeWithSelector as ev}from"zustand/middleware";var Be=co(Jw()(Rw(ev((t,e)=>({isSynced:!1,notifications:[],setNotification:(o,n)=>{let r=n.steps[0],a=n.steps[n.steps.length-1];if(!r||!a)return;let 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}}},c=e().notifications.filter(l=>l.requestId!==n.requestId);t(()=>({notifications:[...c,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(l=>l.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 wl(){let t=nv(),{getNotifications:e,clearNotifications:o}=Be(),n=e(),r=T().blockchains(),{findToken:a}=T();return ov.createElement(tv,{id:"widget-notifications-container",list:n,getBlockchainImage:c=>jp(c,r),getTokenImage:c=>a(c)?.image,onClickItem:i(c=>{t(`${F.swaps}/${c}`)},"onClickItem"),onClearAll:o})}i(wl,"NotificationContent");import{useManager as rv}from"@rango-dev/queue-manager-react";import{InProgressIcon as iv}from"@rango-dev/ui";import Qm from"react";var av=i(()=>{let{manager:t}=rv();return Tt(t).map(({swap:o})=>o).find(o=>o.status==="running")?Qm.createElement($m,{id:"widget-header-history-badge-container"},Qm.createElement(iv,{color:"info",size:6})):null},"InProgressTransactionBadge"),Hm=av;import{EventSeverity as sv}from"@rango-dev/queue-manager-rango-preset";import{Typography as lv}from"@rango-dev/ui";import qm from"react";function Gm(){let{getNotifications:t}=Be(),e=t(),o=e.length,n=!!e.find(r=>r.event.messageSeverity===sv.WARNING);return o?qm.createElement(_m,{isSever:n},qm.createElement(lv,{variant:"body",size:"xsmall",color:"$background",id:"widget-header-notifications-badge-container"},o)):null}i(Gm,"NotificationsBadge");import{RefreshProgressButton as cv}from"@rango-dev/ui";import vl,{useEffect as pv,useState as Vm}from"react";var uv=1e3,Km=60,dv=100;function Ui({onClick:t}){let[e,o]=Vm(0),[n,r]=Vm(!1),a=i(l=>{document.hidden&&l&&s(l)},"handleVisibilityChange");pv(()=>{let l;return t?l=window.setInterval(()=>{o(p=>p+1),e===Km&&c()},uv):s(l),document.addEventListener("visibilitychange",()=>a(l)),()=>{document.removeEventListener("visibilitychange",()=>a(l)),l&&clearInterval(l)}},[e,t]);let s=i(l=>{l&&clearInterval(l),o(0)},"clearTimeout"),c=i(()=>{t?.(),o(0),r(!0)},"handleRefreshClick");return vl.createElement(Dt,{id:"widget-header-refresh-icon-btn",variant:"ghost",size:"small",style:{paddingTop:0,paddingBottom:0},onClick:c,disabled:!t},vl.createElement(Dm,{onTransitionEnd:()=>r(!1),isRefetched:n},vl.createElement(cv,{size:22,color:t?"black":"gray",progress:e/Km*dv})))}i(Ui,"RefreshButton");function zo(t){let{onClickRefresh:e,onClickHistory:o,onClickSettings:n,hidden:r=[],container:a}=t,{config:{features:s}}=T(),c=tt("notification",s)||r.includes("notifications");return Pe.createElement(Pe.Fragment,null,!r.includes("refresh")&&Pe.createElement(Qi,{container:a||B(),side:"top",content:zi.t("Refresh")},Pe.createElement(Ui,{onClick:e})),!c&&Pe.createElement(fv,{align:"end",alignOffset:-88,sideOffset:15,collisionPadding:{right:20,left:20},container:B(),content:Pe.createElement(wl,null)},Pe.createElement("div",null,Pe.createElement(Qi,{container:B(),side:"top",content:zi.t("Notifications")},Pe.createElement(Dt,{id:"widget-header-notification-icon-btn",size:"small",variant:"ghost"},Pe.createElement(mv,{size:18,color:"black"}),Pe.createElement(Gm,null))))),!r.includes("settings")&&Pe.createElement(Qi,{container:B(),side:"top",content:zi.t("Settings")},Pe.createElement(Dt,{id:"widget-header-setting-icon-btn",size:"small",variant:"ghost",onClick:n},Pe.createElement(gv,{size:18,color:"black"}))),!r.includes("history")&&Pe.createElement(Qi,{container:B(),side:"top",content:zi.t("History")},Pe.createElement(Dt,{id:"widget-header-history-icon-btn",size:"small",variant:"ghost",onClick:o},Pe.createElement(hv,{size:18,color:"black"}),Pe.createElement(Hm,null))))}i(zo,"HeaderButtons");import{i18n as xl}from"@lingui/core";import{Divider as Xm,MessageBox as Cv,RefreshIcon as Tv}from"@rango-dev/ui";import wn from"react";import{Button as yv,styled as Sv}from"@rango-dev/ui";var jm=Sv(yv,{"& span":{display:"flex",justifyContent:"center",alignItems:"center"}});function bl(t){let{open:e,onClose:o}=t;return wn.createElement(R,{open:e,dismissible:!0,onClose:o,id:"widget-refresh-modal",container:B()},wn.createElement(Cv,{title:xl.t("Something went wrong"),type:"error",description:xl.t("Something went wrong. Please refresh the app.")},wn.createElement(Xm,{size:30}),wn.createElement(jm,{variant:"outlined",id:"widget-refresh-modal-refresh-btn",size:"large",type:"primary",fullWidth:!0,onClick:()=>location.reload()},wn.createElement(Tv,{size:20,color:"primary"}),wn.createElement(Xm,{size:4,direction:"horizontal"}),xl.t("Refresh"))))}i(bl,"RefreshModal");function El(t){let e=t.target;if(e){let o=e.scrollTop,n=B();o>1?n.classList.add("rng-scrolled"):n.classList.remove("rng-scrolled")}}i(El,"onScrollContentAttachStatusToContainer");import{css as wv,styled as Hi}from"@rango-dev/ui";var qi=wv({borderRadius:"$primary",display:"flex",flexDirection:"column",overflow:"hidden",boxShadow:"$mainContainer"}),Ym=Hi("div",{position:"relative",width:"100vw",minWidth:"300px",maxWidth:"390px",backgroundColor:"$background",variants:{height:{auto:{height:"auto",maxHeight:700},fixed:{minHeight:425,maxHeight:700,height:700}},showBanner:{true:{overflow:"visible"}}}}),Zm=Hi("div",{position:"relative",overflow:"hidden",flexGrow:1,display:"flex",flexDirection:"column",padding:0,overflowY:"auto"}),Jm=Hi("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"}}}),Rm=Hi("div",{width:"100%",position:"absolute",bottom:"-$10",transform:"translateY(100%)",overflow:"hidden"});function se(t){let{connectHeightObserver:e,disconnectHeightObserver:o}=sl(),{children:n,header:r,footer:a,height:s="fixed"}=t,{fetchStatus:c,connectedWallets:l,config:{__UNSTABLE_OR_INTERNAL__:p}}=T(),[u,m]=of(!1),{config:{features:f,theme:h}}=T(),{watermark:g,setShowCompactTokenSelector:d}=re(),S=g==="FULL",{activeTheme:y}=mo(h||{}),[C,k]=of(!1),w=tt("connectWalletButton",f),{isActiveTab:x,tabManagerInitiated:I,showActivateTabModal:A,setShowActivateTabModal:b,activateCurrentTab:E}=re(),v=Ge(),{manager:N}=xv(),{isTablet:W,isMobile:D}=kn(),X=Tt(N).map(({swap:ce})=>ce).some(ce=>ce.status==="running"),Y=i(()=>E(Po.forceClaim,X),"onActivateTab"),M=i(()=>{r.onWallet?.()},"onConnectWallet"),ee=typeof r.hasBackButton>"u"||r.hasBackButton,J=tf(null),te=tf(null);return Gi(()=>{let ce=(p?.swapBoxBanner?.routes?.length??0)===0,Oe=!!p?.swapBoxBanner?.routes?.some(ne=>location.pathname.endsWith(ne));k(!!p?.swapBoxBanner&&(ce||Oe))},[p?.swapBoxBanner?.routes?.toString(),location.pathname]),Gi(()=>(fr()&&te.current&&e(te.current),()=>{o()}),[]),Gi(()=>(J.current?.addEventListener("scroll",El),()=>{J.current?.removeEventListener("scroll",El)}),[]),Gi(()=>{m(c==="failed")},[c]),Iv(()=>{let ce=s==="auto"||!te.current||fr(),Oe=D||W,ne=i(()=>{ce||(Oe?te.current.style.height=`${window.innerHeight-te.current.offsetTop}px`:te.current.style.height=`${700}px`,d(parseFloat(te.current.style.height)<640))},"handler");return ne(),window.addEventListener("resize",ne),()=>window.removeEventListener("resize",ne)},[s,D,W]),We.createElement(Ym,{height:s,id:et.SWAP_BOX_ID,className:`${y()} ${qi()}`,ref:te,showBanner:C},We.createElement(Ev,{prefix:ee?We.createElement(Sl,{onClick:()=>{v(),r.onBack?.()}}):null,title:r.title,suffix:We.createElement(We.Fragment,null,r.suffix,r.onWallet&&!w&&We.createElement(kl,{container:B(),onClick:M,isConnected:!!l?.length}),r.onCancel&&We.createElement(Tl,{onClick:r.onCancel}))}),We.createElement(Zm,{ref:J},n),We.createElement(yl,{open:A,onClose:()=>b(!1),onConfirm:Y}),We.createElement(Jm,null,We.createElement("div",{className:"footer__content"},I&&!x&&We.createElement("div",{className:"footer__alert"},We.createElement(gl,{onActivateTab:Y}),We.createElement(ef,{size:10})),a),We.createElement(ef,{size:12}),We.createElement("div",{className:`footer__logo ${S?"logo__show":"logo__hidden"}`},We.createElement(bv,null))),C&&We.createElement(Rm,null,p?.swapBoxBanner?.element),We.createElement(bl,{open:u,onClose:()=>m(!1)}))}i(se,"Layout");import{styled as Av}from"@rango-dev/ui";var nf="$20 $20 $10 $20",Il=Av("div",{padding:nf,overflowY:"auto",flexGrow:1});import{styled as Nv}from"@rango-dev/ui";var ue=Nv("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 Al}from"react";function rf(){let[t,e]=Al(!1),[o,n]=Al(null),[r,a]=Al(null),{findToken:s}=T(),c=T().customTokens(),l=i(()=>{a(null),e(!1),n(null)},"resetState");function p(m,f){switch(m){case"duplicated":return{type:m,title:go.t("Duplicate Token"),message:go.t("The address you entered is duplicate, please enter a new address.")};case"token-exist":return{type:m,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{type:m,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:f}})};case"network-error":return{type:m,title:go.t("Network error"),message:go.t("An error occurred while retrieving token data.")}}}return i(p,"produceErrorMessage"),{fetchCustomToken:i(async({blockchain:m,tokenAddress:f})=>{e(!0);try{if(c.some(y=>y.address?.toLowerCase()===f.toLowerCase())){let y=p("duplicated");n(y);return}let g=await ct().getCustomToken({blockchain:m,address:f});if(!g||!g.token||g.error){let y=p("not-found",m);n(y);return}let d=g.token;if(s({blockchain:d.blockchain,address:d.address,symbol:d.symbol})){let y=p("token-exist");n(y);return}return a({...d,warning:!0})}catch(h){if(h.code==="ERR_BAD_REQUEST"){let g=p("not-found",m);n(g);return}n(p("network-error"));return}finally{e(!1)}},"fetchCustomToken"),token:r,loading:t,error:o,resetState:l}}i(rf,"useFetchCustomToken");var Uv=Pv("div",{display:"flex",justifyContent:"space-between",flexDirection:"column",flex:1,"& ._text-field":{padding:"$4 $12",backgroundColor:"$neutral300","& input":{padding:"0"},[`.${Mv} &`]:{backgroundColor:"$neutral400"},borderRadius:"$sm",height:"$40"}});function af(){let t=Fv(),[e]=Ov(),o=Ge(),n=T().blockchains(),r=e.get("blockchain")||"",a=No(r,n),[s,c]=$v(""),{fetchCustomToken:l,token:p,loading:u,error:m,resetState:f}=rf(),h=!!a&&tn(a,s),g=!a||!s||!h,d=i(()=>{a&&l({blockchain:r,tokenAddress:s})},"getCustomToken");return Ve.createElement(se,{header:{title:vn.t("Add Custom Token")}},Ve.createElement(ue,null,Ve.createElement(Uv,null,Ve.createElement("div",null,Ve.createElement(tl,{onClick:()=>t(F.blockchains,{replace:!0}),hasLogo:!!a?.logo,value:a?{name:a.displayName,logo:a.logo}:void 0,title:vn.t("Select chain"),placeholder:vn.t("Select chain")}),Ve.createElement(Nl,{size:"24"}),Ve.createElement(Dv,{size:"large",variant:"label"},vn.t("Enter Address")),Ve.createElement(Nl,{size:10}),Ve.createElement(_v,{fullWidth:!0,id:"widget-add-custom-token-token-address-input",disabled:!a,variant:"contained",placeholder:vn.t("Enter token address"),size:"large",value:s,suffix:!!s&&h&&Ve.createElement(Lv,{color:"success",size:12}),onChange:S=>c(S.target.value)}),!h&&!!s&&Ve.createElement(Ve.Fragment,null,Ve.createElement(Nl,{size:4}),Ve.createElement(Bv,{id:"widget-add-custom-token-invalid-address-alert",type:"error",variant:"alarm",title:"Invalid Address"}))),Ve.createElement(Wv,{id:"widget-add-custom-token-import-btn",disabled:g,type:"primary",variant:"contained",loading:u,size:"large",onClick:d},vn.t("Import"))),Ve.createElement(mr,{token:p,blockchain:a??void 0,address:s,error:m??void 0,fetchCustomToken:l,onCloseErrorModal:()=>{m?.type!=="network-error"&&c("")},onImport:o,onExitErrorModal:f,onExitImportModal:f})))}i(af,"AddCustomTokenPage");import{i18n as pc}from"@lingui/core";import{useManager as Ib}from"@rango-dev/queue-manager-react";import{Alert as Ab,Button as Nb,css as dc,Divider as uc,IconButton as jg,styled as Bb,Typography as Wb,WalletIcon as Mb}from"@rango-dev/ui";import $e,{useEffect as Sa,useLayoutEffect as Lb,useRef as Pb,useState as Ir}from"react";import{useNavigate as _b}from"react-router-dom";import{i18n as Qo}from"@lingui/core";import{Alert as dx,BalanceErrors as mx,Button as Mf,ChevronLeftIcon as fx,Divider as $l,MessageBox as gx,Typography as Fl}from"@rango-dev/ui";import ae,{useCallback as hx,useEffect as Lf,useMemo as yx,useState as In}from"react";import{useNavigate as Sx}from"react-router-dom";import{i18n as Ll}from"@lingui/core";import{Alert as Gv,ChevronDownIcon as Vv,CloseIcon as Kv,Divider as mf,IconButton as ff,PasteIcon as jv,Typography as Xv,WalletIcon as Yv}from"@rango-dev/ui";import _e,{useEffect as Zv,useRef as Jv}from"react";import Xi,{useRef as Hv}from"react";import*as xn from"@radix-ui/react-collapsible";import{keyframes as sf,styled as Vi}from"@rango-dev/ui";var Bl=300,zv=sf({from:{height:0},to:{height:"var(--radix-collapsible-content-height)"}}),Qv=sf({from:{height:"var(--radix-collapsible-content-height)"},to:{height:0}}),lf=Vi(xn.Root,{borderRadius:"$sm",overflow:"hidden",variants:{selected:{true:{outlineWidth:1,outlineColor:"$secondary500",outlineStyle:"solid"}}}}),Wl=Vi(xn.Trigger,{padding:"$0",border:"none",outline:"none",width:"100%",backgroundColor:"transparent",fontFamily:"inherit",cursor:"pointer"}),Ki=Vi(xn.Content,{overflow:"hidden",variants:{open:{true:{animation:`${zv} ${Bl}ms ease-out`},false:{animation:`${Qv} ${Bl}ms ease-out`}}}}),ji=Vi("div",{transition:`all ${Bl}ms ease`,display:"flex",alignItems:"center",variants:{orientation:{down:{transform:"rotate(0)"},up:{transform:"rotate(180deg)"}}}});function Yi(t){let{open:e,hasSelected:o,onOpenChange:n,children:r,onClickTrigger:a,trigger:s,triggerAnchor:c}=t,l=Hv(null);return Xi.createElement(lf,{ref:l,className:"collapsible_root",selected:o&&e,open:e,onOpenChange:n},c==="top"&&Xi.createElement(Wl,{className:"collapsible_trigger",onClick:a},s),Xi.createElement(Ki,{className:"collapsible_content",open:e},r),c==="bottom"&&Xi.createElement(Wl,{className:"collapsible_trigger",onClick:a},s))}i(Yi,"CustomCollapsible");import{darkTheme as cf,styled as Ml,TextField as qv}from"@rango-dev/ui";var pf=Ml("div",{padding:"$10 $0","& .button__content":{display:"flex",alignItems:"center"},"& .alarms":{paddingTop:"$5"},"& .collapsible_content":{backgroundColor:"$neutral100"},"& .collapsible_root":{backgroundColor:"$neutral100"},"& input":{padding:"$15"}}),uf=Ml(qv,{backgroundColor:"$neutral100"}),df=Ml("div",{width:"100%",borderRadius:"$sm",display:"flex",padding:"$15",justifyContent:"space-between",alignItems:"center",$$color:"$colors$neutral100",[`.${cf} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",borderBottomRightRadius:"0",borderBottomLeftRadius:"0","&:focus-visible":{$$background:"$colors$secondary100",[`.${cf} &`]:{$$background:"$colors$info700"},backgroundColor:"$$background",outline:0}});function gf(t){let{blockchain:e,handleOpenChange:o,open:n}=t,{customDestination:r,setCustomDestination:a}=z()(),{config:s}=T(),c=T().blockchains(),l=ti(e.name,c),p=Jv(null),u=s?.defaultCustomDestinations?.[e.name],m=navigator?.userAgent.includes("Firefox"),h=n&&!!r&&e&&!tn(e,r),g=i(()=>{a("")},"handleClear"),d=i(async y=>{if(y.preventDefault(),navigator.clipboard!==void 0){let C=await navigator.clipboard.readText();a(C),p?.current?.focus()}},"handlePaste"),S=i(()=>r?_e.createElement(ff,{id:"widget-custom-destination-close-icon-btn",onClick:g,variant:"ghost"},_e.createElement(Kv,{size:12,color:"gray"})):m?null:_e.createElement(ff,{id:"widget-custom-destination-paste-icon-btn",onClick:d,variant:"ghost"},_e.createElement(jv,{size:16})),"renderSuffix");return Zv(()=>{!!u&&r===null&&(a(u),o(!0))},[u]),_e.createElement(pf,null,_e.createElement(Yi,{onOpenChange:o,hasSelected:!0,open:n,triggerAnchor:"top",trigger:_e.createElement(df,{id:"widget-custom-destination-collapsible-btn"},_e.createElement("div",{className:"button__content"},_e.createElement(Yv,{size:18,color:"info"}),_e.createElement(mf,{size:4,direction:"horizontal"}),_e.createElement(Xv,{variant:"label",size:"medium",color:n?"$neutral600":void 0},Ll.t("Send to a different address"))),_e.createElement(ji,{orientation:n?"up":"down"},_e.createElement(Vv,{size:10,color:"secondary"}))),onClickTrigger:()=>o(!n)},_e.createElement(uf,{id:"widget-custom-destination-blockchain-address-input",ref:p,style:{padding:0,paddingRight:r?"8px":"5px"},autoFocus:!r,placeholder:Ll.t("Enter {blockchainName} address",{blockchainName:l}),value:r||"",suffix:S(),onChange:y=>{let C=y.target.value;a(C)}})),h&&_e.createElement(_e.Fragment,null,_e.createElement(mf,{size:4}),_e.createElement(Gv,{variant:"alarm",type:"error",title:Ll.t({values:{destination:r},id:"Address {destination} doesn't match the blockchain address pattern."})})))}i(gf,"CustomDestination");import{css as Rv,IconButton as ex,SelectableWalletButton as tx,styled as ho}from"@rango-dev/ui";var hf=ho("div",{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center"}),yf=ho("div",{display:"flex",justifyContent:"space-evenly",alignItems:"center",columnGap:"$5",rowGap:"$10",flexWrap:"wrap",paddingTop:"$5",height:"100%"}),Sf=ho(tx,{justifyContent:"center"}),Cf=ho("div",{padding:"$20 $20 $15 $20",display:"flex",justifyContent:"center",alignItems:"center",backgroundColor:"$neutral200",position:"relative",width:"100%"}),Tf=ho(ex,{position:"absolute",left:"$20"}),kf=ho("div",{paddingTop:"$20"}),wf=Rv({display:"flex",justifyContent:"space-evenly",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5",height:"100%"}),vf=ho("div",{display:"flex"}),xf=ho("div",{overflow:"visible",width:"100%"});import{i18n as _l}from"@lingui/core";import{warn as ax}from"@rango-dev/logging-core";import{Divider as sx,makeInfo as lx,SelectableWallet as cx,Typography as Bf,WalletState as En}from"@rango-dev/ui";import rt,{useEffect as Wf,useState as Sr}from"react";import{Image as rx,MessageBox as ix}from"@rango-dev/ui";import yr from"react";import{keyframes as ox,styled as Pl}from"@rango-dev/ui";var bf=Pl("div",{position:"relative"}),nx=ox({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}),Ef=Pl("div",{position:"absolute",border:"2px solid rgba(0, 0, 0, 0.1)",borderTop:"2px solid $info500",borderRadius:"$lg",width:"$45",height:"$45",animation:`${nx} 1s linear infinite`,top:0,bottom:0,right:0,left:0}),If=Pl("div",{"& img":{borderRadius:"50%"}});import{i18n as bn}from"@lingui/core";function Af(t,e){switch(t){case"in-progress":return{type:"loading",title:bn.t({id:"Add {blockchainDisplayName} Chain",values:{blockchainDisplayName:e}}),description:bn.t({id:"Please approve the experimental chain pop-up in your wallet.",values:{blockchainDisplayName:e}})};case"completed":return{type:"success",title:bn.t({id:"{blockchainDisplayName} Chain Added",values:{blockchainDisplayName:e}}),description:bn.t({id:"The {blockchainDisplayName} chain has been successfully added to your wallet.",values:{blockchainDisplayName:e}})};case"rejected":return{type:"error",title:bn.t("Request Rejected"),description:bn.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(Af,"generateMessageByStatus");function Nf(t){let{status:e,displayName:o,image:n}=t,r=Af(e,o),a=e=="in-progress";return yr.createElement(ix,{type:r.type,title:r.title,description:r.description,icon:a?yr.createElement(bf,null,yr.createElement(If,null,yr.createElement(rx,{src:n,size:45})),yr.createElement(Ef,null)):void 0})}i(Nf,"ExperimentalChainStatus");var px=7,ux=3e3;function Dl(t){let{chain:e,quoteChains:o,isSelected:n,selectWallet:r,limit:a,onShowMore:s}=t,c=re.use.isActiveTab(),{blockchains:l,connectedWallets:p}=T(),[u,m]=Sr(),[f,h]=Sr(null),[g,d]=Sr(!1),[S,y]=Sr(null),{suggestAndConnect:C}=Zi(),{list:k}=vt({chain:e}),[w,x]=Sr(k),I=k.length,A=a&&I-a>0,b=i(async v=>{d(!1),y("in-progress");try{await C(v.walletType,v.chain),y("completed")}catch{y("rejected")}},"addExperimentalChain");Wf(()=>{x(v=>{let N=k.findIndex(W=>n(W.type,e));return A&&N>1?[k[N]].concat(k.filter((W,D)=>D!==N)):v.map(W=>k.find(D=>D.type===W.type)??W)})},[JSON.stringify(k)]);let E=document.getElementById(et.SWAP_BOX_ID);return Wf(()=>{let v=null;return(S==="completed"||S==="rejected")&&(v=setTimeout(()=>y(null),ux)),()=>{v&&clearTimeout(v)}},[S]),rt.createElement(rt.Fragment,null,w.slice(0,a).map(v=>{let N=Iu({connectedWallets:p,walletType:v.type,chain:e}),W=v.state===En.CONNECTED||v.state===En.PARTIALLY_CONNECTED,D=N?lo(N,px):"",H=W&&!!v.needsNamespace&&!D,X=di(l(),e),Y=!p.find(ne=>ne.walletType===v.type&&ne.chain===e),M=X&&Y&&v.state===En.CONNECTED,ee=i(async()=>{v.state===En.DISCONNECTED||H?m(v):M?(h({walletType:v.type,chain:e,address:N??""}),d(!0)):r({walletType:v.type,chain:e,address:N??""})},"onSelectableWalletClick"),J=lx(v.state),te=i(()=>M?_l.t({id:"Add {chain} chain",values:{chain:e}}):H?_l.t("Chain not connected"):D||J.description,"getWalletDescription"),ce=i(()=>v.state===En.CONNECTED||v.state===En.PARTIALLY_CONNECTED?H?"neutral600":"neutral700":J.color,"getWalletDescriptionColor"),Oe=f?.chain?ti(f.chain,l()):void 0;return rt.createElement(rt.Fragment,{key:`${v.title}_${Oe}`},!!f&&rt.createElement(R,{id:"widget-wallets-list-watermarked-modal",open:!!f&&g,container:E,onClose:()=>{h(null)}},rt.createElement(Qs,{id:"widget-wallets-list-experimental-chain-container",displayName:Oe,onConfirm:()=>{b(f)}})),S&&rt.createElement(R,{id:"widget-wallets-list-experimental-chain-watermarked-modal",open:!!S,onClose:y.bind(null,null),container:E},rt.createElement(Nf,{status:S,displayName:Oe,image:v.image}),rt.createElement(sx,{direction:"vertical",size:32})),rt.createElement(cx,{key:v.type,id:"widget-wallets-list-selectable-wallet-btn",description:te(),descriptionColor:ce(),onClick:ee,selected:n(v.type,e),disabled:!c,...v}))}),rt.createElement(sr,{id:"widget-wallets-list-stateful-connect-modal",wallet:u,options:{defaultSelectedChains:o||[e]},onClose:()=>{m(void 0)},onConnect:()=>{t.onConnect&&(u?.type?t.onConnect(u.type):ax(new Error("The selected wallet hasn't been detected after the connection process finished. It usually shouldn't happen.")))}}),A&&rt.createElement(Sf,{selected:!1,onClick:s,id:"widget-wallets-list-show-more-wallets-btn"},rt.createElement(Bf,{variant:"label",size:"medium"},_l.t("Show more wallets"),rt.createElement(Bf,{variant:"label",size:"medium",color:"$primary"},"\xA0+",I-(a??0)))))}i(Dl,"WalletList");var Cx=2;function Pf(t){let{open:e,onClose:o,onCancel:n,onCheckBalance:r,loading:a}=t,s=Sx(),c=T().blockchains(),{selectedQuote:l,setSelectedWallets:p,quoteWalletsConfirmed:u,setQuoteWalletConfirmed:m,customDestination:f,setCustomDestination:h}=z()(),{config:g,connectedWallets:d,setWalletsAsSelected:S}=T(),[y,C]=In(""),[k,w]=In([]),[x,I]=In(""),[A,b]=In(!!f),E=yx(()=>Mo({filter:"all",quote:l}),[l]),v=Mo({filter:"required",quote:l}),N=c.find($=>$.name===l?.swaps[l?.swaps.length-1]?.to.blockchain),W=i($=>v.includes($),"isWalletRequiredFor"),D=hx(()=>d.filter($=>$.selected&&E.includes($.chain)),[d,E]),[H,X]=In(D()),[Y,M]=In([]),ee=i(($,U)=>M(G=>G.concat({blockchain:$,walletType:U})),"addNextSelectedWallets"),J=k.length>0,te=i(($,U)=>!!H.find(G=>G.walletType===$&&G.chain===U&&G.selected&&(W(U)||!W(U)&&!f)),"isSelected"),ce=i(($,U,G)=>{let pe=!1;return $.map(Q=>{if(Q.chain===U){let j=Q.selected;return!pe&&G?(pe=!0,j=!0):G||(j=!1),{...Q,selected:j}}return Q})},"updateSelectableWallets"),Oe=i($=>{b($),$?W(N?.name??"")||X(U=>ce(U,N?.name||"",!1)):(h(""),X(U=>ce(U,N?.name||"",!0)))},"handleCustomDestinationCollapsibleOpenChange"),ne=i($=>{if(y&&C(""),te($.walletType,$.chain))return;let G=d.find(pe=>pe.walletType===$.walletType&&pe.chain===$.chain);G&&(n(),$.chain===N?.name&&A&&!W(N.name)&&(b(!1),h(null)),X(pe=>pe.filter(Q=>Q.chain!==$.chain).concat({...G,selected:!0})))},"onChange"),wt=i(()=>{let $=H.filter(U=>U.selected);S($),p($),m(!0),o()},"onConfirmBalance"),gt=i(async()=>{w([]),I("");let $=await r?.({selectedWallets:H.filter(G=>G.selected),customDestination:f}),U=$.warnings;U?.balance?.messages&&w(U.balance.messages),$.error&&I(vd($.error)),!$.error&&!U?.balance?.messages.length?wt():w(U?.balance?.messages??[])},"onConfirmWallets");Lf(()=>{X($=>{let U=[];return $.forEach(G=>{!d.some(Q=>Q.chain===G.chain&&Q.walletType===G.walletType&&Q.address===G.address)||U.push(G)}),U=U.concat(d.filter(G=>!!!U.find(Q=>Q.chain===G.chain)&&G.selected&&E.includes(G.chain))),U})},[d,E]),Lf(()=>{let $=[];Y.length>0&&(Y.forEach(U=>{let G=d.find(pe=>pe.chain===U.blockchain&&pe.walletType===U.walletType);G?ne(G):$.push(U)}),M($))},[d,Y]);let Wt=document.getElementById(et.SWAP_BOX_ID);return ae.createElement(R,{id:"widget-confirm-wallets-modal",open:e,onClose:()=>{u||s("../",{replace:!0}),o()},dismissible:!y,container:Wt,...!y&&{styles:{container:{height:"100%"}},footer:ae.createElement(vf,null,ae.createElement(Mf,{id:"widget-confirm-wallet-modal-confirm-btn",loading:a,disabled:Jd(a,A,f,l,H,N),onClick:gt,variant:"contained",type:"primary",fullWidth:!0,size:"large"},Qo.t("Confirm")))},...y&&{styles:{container:{height:"100%",padding:"$0"}},header:ae.createElement(Cf,null,ae.createElement(Tf,{id:"widget-confirm-wallet-modal-navigate-back-icon-btn",variant:"ghost",onClick:C.bind(null,"")},ae.createElement(fx,{size:16})),ae.createElement(Fl,{variant:"headline",size:"small"},Qo.t({id:"Your {blockchainName} wallets",values:{blockchainName:ht(y,c)}})))},anchor:"center"},ae.createElement(R,{id:'"widget-confirm-wallets-insufficient-account-balance-modal',open:J,onClose:w.bind(null,[]),container:Wt},ae.createElement(gx,{title:Qo.t("Insufficient account balance"),type:"error",description:ae.createElement(mx,{messages:k??[]})},ae.createElement(Mf,{id:"widget-confirm-wallet-modal-proceed-anyway-btn",variant:"outlined",size:"large",type:"primary",fullWidth:!0,onClick:wt},Qo.t("Proceed anyway")))),y&&ae.createElement(kf,null,ae.createElement("div",{className:wf()},ae.createElement(Dl,{chain:y,quoteChains:E,isSelected:te,selectWallet:ne,onShowMore:()=>C(y),onConnect:$=>{ee(y,$)}}))),!y&&ae.createElement(ae.Fragment,null,x&&ae.createElement(ae.Fragment,null,ae.createElement(dx,{id:"widget-confirm-wallet-modal-error-alert",variant:"alarm",type:"error",title:Qo.t(x)}),ae.createElement($l,{size:12})),ae.createElement(xf,null,E.map(($,U)=>{let G=c.find(K=>K.name===$),pe=`wallet-${U}`,Q=U===E.length-1,j=Q&&N&&g?.customDestination!==!1;return ae.createElement("div",{key:pe},ae.createElement(hf,null,ae.createElement(Fl,{variant:"title",size:"xmedium"},Qo.t({id:"Your {blockchainName} wallets",values:{blockchainName:G?.shortName}})),ae.createElement(Fl,{variant:"label",color:"$neutral700",size:"medium"},Qo.t({id:"You need to connect a {blockchainName} wallet.",values:{blockchainName:G?.shortName}}))),ae.createElement($l,{size:24}),ae.createElement(yf,null,ae.createElement(Dl,{chain:$,quoteChains:E,isSelected:te,selectWallet:ne,limit:Cx,onShowMore:()=>C(G?.name??""),onConnect:K=>{ee($,K)}})),!Q&&ae.createElement($l,{size:32}),j&&ae.createElement(gf,{blockchain:N,open:A,handleOpenChange:Oe}))}))))}i(Pf,"ConfirmWalletsModal");import{i18n as Gx}from"@lingui/core";import{Alert as Vx,Button as Kx,Divider as eg,InfoIcon as jx}from"@rango-dev/ui";import Ue from"react";import{Alert as wx,Button as vx,Divider as zl,NoRouteIcon as xx,RefreshIcon as bx,Typography as zf}from"@rango-dev/ui";import pt from"react";import{i18n as _f}from"@lingui/core";var Tx=24,kx=60;function Df(t,e,o,n){return t?.type===1?{alert:{type:"warning",text:ie().genericServerError,action:{onClick:n,title:_f.t("Retry")}},description:""}:e.length?{alert:{type:"warning",text:ie().liquiditySourcesError.title,action:{onClick:()=>o(!0),title:_f.t("Reset")}},description:ie().liquiditySourcesError.description}:t?.type===0&&t.diagnosisMessage?{alert:{type:"error",text:t.diagnosisMessage,action:null},description:""}:{alert:null,description:ie().noResultError.description}}i(Df,"makeInfo");var Ol=(o=>(o[o.small=Tx]="small",o[o.large=kx]="large",o))(Ol||{}),Ul=(o=>(o.small="small",o.large="medium",o))(Ul||{});import{styled as Ji}from"@rango-dev/ui";var $f=Ji("div",{display:"flex",flexDirection:"column",alignItems:"center"}),Ff=Ji("div",{variants:{size:{small:{},large:{maxWidth:"316px"}}}}),Of=Ji("div",{variants:{size:{small:{width:"100%"},large:{}}}}),Uf=Ji("div",{padding:"$6 $0"});function Cr(t){let{fetch:e,error:o,size:n="small",skipAlerts:r}=t,a=T().getDisabledLiquiditySources(),s=T().toggleAllLiquiditySources,c=T().swappers(),l=Df(o,a,()=>s(c,!0),e);return r&&(l.alert=null),pt.createElement($f,{id:"widget-no-result-container"},pt.createElement(xx,{size:Ol[n],color:"gray"}),pt.createElement(zl,{size:4}),pt.createElement(zf,{variant:"title",size:Ul[n]},ie().noResultError.title),n==="large"&&pt.createElement(zl,{size:4}),!!l.description&&pt.createElement(Ff,{size:n},pt.createElement(zf,{variant:"body",size:"small",align:"center",color:"neutral700"},l.description)),pt.createElement(zl,{size:n==="large"?"24":"4"}),!!l.alert&&pt.createElement(Of,{size:n},pt.createElement(wx,{id:"widget-no-result-alert",type:l.alert.type,title:l.alert.text,titleAlign:"left",action:l.alert.action&&pt.createElement(vx,{size:"xsmall",id:"widget-no-result-alert-btn",type:l.alert.type,prefix:pt.createElement(Uf,null,pt.createElement(bx,{size:8})),onClick:l.alert.action.onClick},l.alert.action.title),variant:"alarm"})))}i(Cr,"NoResult");import{i18n as Tr}from"@lingui/core";import{Button as Lx,Divider as Px,MessageBox as _x,Typography as Dx,WarningIcon as $x}from"@rango-dev/ui";import Yt from"react";import{InfoIcon as Nx,Tooltip as Bx,Typography as Wx}from"@rango-dev/ui";import An from"react";import{Button as Ex,darkTheme as Ix,styled as Ho,Typography as Ax}from"@rango-dev/ui";var Qf=Ho("div",{width:"100%"}),Ql=Ho("div",{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"$5",width:"100%"}),Hf=Ho("div",{display:"flex",padding:"$5 0",justifyContent:"space-between",alignItems:"center",width:"100%","._title":{$$color:"$colors$neutral600",[`.${Ix} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),qf=Ho("div",{display:"flex",justifyContent:"center",alignItems:"center",gap:"$2"}),Gf=Ho(Ax,{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"250px"}),Vf=Ho("div",{padding:"$2",alignSelf:"flex-start",cursor:"pointer"}),Kf=Ho(Ex,{"& ._text":{gap:"$5",display:"flex",alignItems:"center",justifyContent:"center"}});var Mx=35;function jf(t){let{title:e,value:o,valueColor:n}=t,r=B();return An.createElement(Hf,null,An.createElement(Wx,{size:"medium",variant:"label",className:"_title"},e),An.createElement(qf,null,An.createElement(Gf,{size:"large",variant:"label",color:n||"foreground"},`${n?"%":"$"}${o}`),o.length>Mx&&An.createElement(Bx,{content:o,container:r},An.createElement(Nx,{size:12,color:"gray"}))))}i(jf,"QuoteErrorsModalItem");function Xf(t){let{open:e,onClose:o,onConfirm:n,warning:r,confirmationDisabled:a}=t,s=r.warningLevel==="high"?"error":"warning",c=[{title:Tr.t("Swapping"),value:P(r.inputUsdValue)},{title:Tr.t("Gas cost"),value:P(r.totalFee,2,2)},{title:Tr.t("Receiving"),value:P(r.outputUsdValue)},{title:Tr.t("Price impact"),value:P(r.priceImpact,2,2),valueColor:`${s}500`}];return Yt.createElement(R,{id:"widget-high-value-loss-warning-modal",footer:Yt.createElement(Lx,{id:"widget-high-value-loss-warning-modal-confirm-btn",type:"primary",size:"large",prefix:Yt.createElement($x,null),fullWidth:!0,disabled:a,onClick:n},ie().highValueLossError.confirmMessage),open:e,onClose:o,container:B()},Yt.createElement(_x,{type:s,title:ie().highValueLossError.impactTitle,description:ie().highValueLossError.description}),Yt.createElement(Ql,null,Yt.createElement(Px,{size:"4"}),Yt.createElement(Dx,{size:"small",variant:"title"},Tr.t("Details")),Yt.createElement(Ql,null,c.map((l,p)=>Yt.createElement(jf,{key:p,...l})))))}i(Xf,"HighValueLossWarningModal");import{i18n as Nn}from"@lingui/core";function Yf(t,e){let o={alertType:"warning",title:"",action:null,actionButtonTitle:null};if(e)return o.alertType="error",e.type===3&&(o.title=e.recommendation),e.type===4&&(o.title=Nn.t({id:"You need to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:e.minRequiredSlippage}}),o.action="change-slippage",o.actionButtonTitle=Nn.t("Increase")),o;if(t){switch(t.type){case 0:{Xt(t.priceImpact)==="high"&&(o.alertType="error"),o.action="show-info",o.title=ie().highValueLossError.title;break}case 4:{o.title=Nn.t({id:"Output amount changed by {percentageChange}% (${usdValueChange}).",values:{percentageChange:t.percentageChange,usdValueChange:t.usdValueChange}});break}case 1:{o.title=ie().unknownPriceError.title;break}case 2:{o.title=Nn.t({id:"We recommend you to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:t.minRequiredSlippage}}),o.action="change-slippage",o.actionButtonTitle=Nn.t("Increase");break}case 3:{o.title=Nn.t("Caution, your slippage is high."),o.action="change-settings";break}default:break}return o}return null}i(Yf,"makeAlerts");function Zf(t,e){return e?.type===4?Number(e.minRequiredSlippage):t?.type===2?Number(t.minRequiredSlippage):null}i(Zf,"getRequiredSlippage");import{i18n as Bn}from"@lingui/core";import{Button as Fx,Divider as Hl,MessageBox as Ox,WarningIcon as Ux}from"@rango-dev/ui";import Co from"react";import{useNavigate as zx}from"react-router-dom";function Jf(t){let{open:e,onClose:o,onConfirm:n,warning:r,confirmationDisabled:a}=t,s=zx();return Co.createElement(R,{id:"widget-slippage-warning-modal",anchor:"bottom",open:e,container:B(),onClose:o},Co.createElement(Ox,{type:"warning",title:r.type===3?Bn.t("High slippage"):Bn.t("Low slippage"),description:r.type===3?Bn.t("Caution, your slippage is high. Your trade may be front run."):Bn.t({id:"We recommend you to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:r.minRequiredSlippage}})},Co.createElement(Hl,{size:18}),Co.createElement(Hl,{size:32}),Co.createElement(Kf,{id:"widget-slippage-warning-modal-confirm-anyway-btn",size:"large",type:"primary",variant:"contained",fullWidth:!0,disabled:a,onClick:n},Co.createElement(Ux,{color:"white",size:16}),Bn.t("Swap anyway")),Co.createElement(Hl,{size:10}),Co.createElement(Fx,{id:"widget-slippage-warning-modal-change-slippage-btn",size:"large",type:"primary",variant:"outlined",fullWidth:!0,disabled:a,onClick:()=>s("../"+F.settings)},Bn.t("Change Slippage"))))}i(Jf,"SlippageWarningModal");import{Button as Qx,MessageBox as Hx,WarningIcon as qx}from"@rango-dev/ui";import Ri from"react";function Rf(t){let{open:e,onClose:o,onConfirm:n,confirmationDisabled:r}=t;return Ri.createElement(R,{id:"widget-unknown-price-warning-modal",footer:Ri.createElement(Qx,{id:"widget-unknown-price-warning-modal-confirm-btn",type:"primary",size:"large",prefix:Ri.createElement(qx,null),fullWidth:!0,disabled:r,onClick:n},ie().unknownPriceError.confirmMessage),open:e,onClose:o,container:B()},Ri.createElement(Hx,{type:"warning",title:ie().unknownPriceError.impactTitle,description:ie().unknownPriceError.description}))}i(Rf,"UnknownPriceWarningModal");function kr(t){let{warning:e,error:o,couldChangeSettings:n,showWarningModal:r,confirmationDisabled:a,skipAlerts:s,refetchQuote:c,onOpenWarningModal:l,onCloseWarningModal:p,onConfirmWarningModal:u,onChangeSettings:m,onChangeSlippage:f}=t,h={confirmationDisabled:a,open:r,onClose:p,onConfirm:u},g=o?.type===0||o?.type===1,d=Yf(e,o?.type===3||o?.type===4?o:null);d&&!n&&(d.action=null);let S=!!d&&!s,y=i(C=>{if(C==="change-slippage"){let k=o?.type===3||o?.type===4?o:null,w=Zf(e,k);f?.(w)}else C==="change-settings"&&m()},"onclickActionButton");return Ue.createElement(Ue.Fragment,null,g&&Ue.createElement(Ue.Fragment,null,Ue.createElement(eg,{size:10}),Ue.createElement(Cr,{skipAlerts:s,error:o,fetch:c})),S&&Ue.createElement(Qf,null,Ue.createElement(eg,{size:10}),Ue.createElement(Vx,{id:"widget-quote-warning-and-errors-alert",title:d.title,type:d.alertType,variant:"alarm",...d.action==="show-info"&&{action:Ue.createElement(Vf,{onClick:l},Ue.createElement(jx,{size:12,color:"gray"}))},...(d.action==="change-settings"||d.action==="change-slippage")&&{action:Ue.createElement(Kx,{id:"widget-quote-warning-error-change-settings-btn",size:"xxsmall",type:d.alertType,onClick:()=>y(d.action)},d.actionButtonTitle||Gx.t("Change"))}})),e&&Ue.createElement(Ue.Fragment,null,e.type===0&&Ue.createElement(Xf,{...h,warning:e}),(e.type===3||e.type===2)&&Ue.createElement(Jf,{...h,warning:e}),e.type===1&&Ue.createElement(Rf,{...h,warning:e})))}i(kr,"QuoteWarningsAndErrors");import Tb from"bignumber.js";import fa from"react";import{i18n as qo}from"@lingui/core";import{Alert as cb,Divider as Mn,FullExpandedQuote as pb,InfoIcon as ec,NumericTooltip as tc,QuoteTag as ub,StepDetails as db,TokenAmount as mb,Typography as Ln,useIsTruncated as oc}from"@rango-dev/ui";import nc from"bignumber.js";import O,{useRef as ua,useState as fb}from"react";import{styled as ql}from"@rango-dev/ui";var Gl=ql("div",{width:"100%","& .position-top__skeleton":{paddingTop:"$10"}}),tg=ql("div",{paddingBottom:"$15","& .from-amount-text":{wordBreak:"break-word"},variants:{dense:{true:{paddingBottom:0}}}}),og=ql("div",{width:"100%",display:"flex"});import*as ea from"@radix-ui/react-collapsible";import{Button as Xx,css as ta,darkTheme as De,Image as ng,styled as Ke,Typography as Vl}from"@rango-dev/ui";var Yx=300,rg=Ke(ea.Root,{display:"flex",flexDirection:"column",alignItems:"start",overflowX:"auto",overflowY:"hidden",width:"100%",borderRadius:"$xm",variants:{selected:{true:{},false:{$$color:"$colors$neutral400",[`.${De} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"}},listItem:{true:{$$color:"$colors$neutral400",[`.${De} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"},false:{}}},compoundVariants:[{listItem:!1,selected:!0,css:{$$color:"$colors$secondary200",[`.${De} &`]:{$$color:"$colors$secondary800"},backgroundColor:"$$color"}}]}),ig=ta({padding:"$10 $15"}),ag=Ke(Xx,{backgroundColor:"transparent",border:"1px solid $secondary550",[`.${De} &`]:{border:"1px solid $secondary"},transition:"background-color 0.3s ease","&:hover":{backgroundColor:"$secondary550",[`.${De} &`]:{backgroundColor:"$secondary"},".allRoutesLabel":{$$color:"$colors$background",[`.${De} &`]:{$$color:"$colors$foreground"},color:"$$color",transition:"color 0.3s ease"}}}),sg=Ke("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",[`.${De} &`]:{$$color:"$colors$neutral500"},backgroundColor:"$$color"}},basic:{true:{borderTopRightRadius:"0",borderTopLeftRadius:"0"}},listItem:{true:{$$color:"$colors$neutral200",[`.${De} &`]:{$$color:"$colors$neutral500"},backgroundColor:"$$color","&:hover":{"& .quote_container":{"& button":{backgroundColor:"$neutral500",[`.${De} &`]:{backgroundColor:"$neutral200"}},backgroundColor:"$neutral500",[`.${De} &`]:{backgroundColor:"$neutral200"}},backgroundColor:"$neutral300",[`.${De} &`]:{backgroundColor:"$neutral400"}},cursor:"pointer"},false:{}}},compoundVariants:[{listItem:!0,selected:!0,css:{outline:"1px solid $secondary"}},{listItem:!1,selected:!0,css:{$$color:"$colors$secondary100",[`.${De} &`]:{$$color:"$colors$secondary550"},backgroundColor:"$$color","&:hover":{backgroundColor:"$$color"}}},{listItem:!0,selected:!1,css:{cursor:"pointer","&:hover":{backgroundColor:"$neutral300",[`.${De} &`]:{backgroundColor:"$neutral400"}}}}]}),lg=ta({width:"100%",padding:"$15 $15 $10 $15"}),cg=ta({display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingBottom:"$10",position:"relative"}),Wn=ta({display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",".blockchainImage":{marginLeft:"-$8"}}),pg=Ke(ea.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:{[`& ${ng}`]:{border:"1px $warning500 solid",borderRadius:"100%"}},false:{[`& ${ng}`]:{border:"1px transparent solid",borderRadius:"100%"}}},selected:{true:{},false:{$$color:"$colors$neutral400",[`.${De} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"}},listItem:{true:{$$color:"$colors$neutral400",[`.${De} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"},false:{}}},compoundVariants:[{listItem:!1,selected:!0,css:{$$color:"$colors$secondary200",[`.${De} &`]:{$$color:"$colors$secondary800"},backgroundColor:"$$color"}}],".blockchains_section":{display:"none"},"@xs":{".blockchains_section":{display:"block"}}}),ug=Ke("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"}}}}),dg=Ke(Ki,{width:"100%",background:"inherit"}),Kl=Ke("div",{display:"flex",justifyContent:"center",alignItems:"center",padding:"$2",transition:`all ${Yx}ms ease`,variants:{orientation:{down:{transform:"rotate(0)"},up:{transform:"rotate(180deg)"}}}}),xH=Ke("div",{height:"$12",marginLeft:"$10",marginRight:"$10",borderLeft:"1px solid $foreground"}),mg=Ke("div",{display:"flex",justifyContent:"center",margin:"0 $15",borderTop:"1px solid",$$color:"$colors$neutral300",[`.${De} &`]:{$$color:"$colors$neutral400"},borderColor:"$$color"}),fg=Ke("div",{display:"flex",flexDirection:"row",alignItems:"center",gap:"$2",flex:"1 1 auto",minWidth:0}),jl=Ke(Vl,{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"$30"}),Xl=Ke(Vl,{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0,flex:"0 1 auto"}),Yl=Ke("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"}}}}),gg=Ke("div",{display:"flex"}),oa=Ke("div",{width:"100%",borderTopWidth:"1px",borderTopStyle:"solid",borderTopColor:"$neutral",margin:"$5 0",[`.${De} &`]:{borderTopColor:"$neutral800"}}),hg=Ke(Vl,{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:"0 1 auto",minWidth:0,flexShrink:3});import{i18n as $t}from"@lingui/core";import{ChevronDownIcon as Jx,CloseIcon as Rx,Divider as ia,IconButton as eb,NumericTooltip as tb,QuoteCost as ob,Typography as Et}from"@rango-dev/ui";import Z,{useState as Tg}from"react";import{css as Zx,styled as na}from"@rango-dev/ui";var ra=na("div",{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"$5 0","&.total_payable_fee":{padding:"$12 0"}}),Zl=na("div",{width:"100%",borderTop:"1px solid $neutral300",margin:"$10 0"}),yg=na("div",{padding:"$20 0",display:"flex",flexDirection:"column","& .collapsible_trigger":{display:"flex",alignItems:"center"}}),Sg=na("div",{padding:"$20 $20 $10",position:"relative","._icon-button":{position:"absolute",zIndex:10,top:"$16",right:"$16"}}),Cg=Zx({display:"flex",flexDirection:"row",alignItems:"center",padding:"$5","&:hover":{"& ._typography, & svg":{color:"$secondary"}}});var nb=i(t=>t.fee.isZero()?null:Z.createElement(ra,null,Z.createElement(Et,{variant:"label",size:"medium",color:"neutral600"},t.label),Z.createElement(Et,{variant:"label",size:"medium"},"$",P(t.fee,4,4))),"NonPayableFee");function Jl(t){let[e,o]=Tg(!1),[n,r]=Tg(!1),{steps:a,quote:s,fee:c,time:l,feeWarning:p,timeWarning:u,showModalFee:m,fullExpandedMode:f=!1}=t,h=s?.swaps??[],g=f?Wo():B(),d=qd(h),S=P(c,2,2);return Z.createElement(Z.Fragment,null,Z.createElement(ob,{onClickFee:m?y=>{y.stopPropagation(),o(!e)}:void 0,fee:S,feeWarning:p,timeWarning:u,time:l,steps:a,tooltipGas:m?$t.t("View more info"):void 0,tooltipContainer:g}),Z.createElement(R,{id:"widget-quote-cost-explanation-modal",container:g,open:e,anchor:f?"center":"bottom",styles:{container:{maxWidth:f?"484px":"unset"}},header:Z.createElement(Sg,{style:{textAlign:f?"left":"center"}},Z.createElement(Et,{variant:"title",size:"medium"},$t.t("Gas & Fee Explanation")),Z.createElement(eb,{id:"widget-quote-cost-details-modal-close-icon-btn",onClick:()=>o(!1),variant:"ghost"},Z.createElement(Rx,{color:"gray",size:14}))),onClose:()=>{o(!1)}},Z.createElement(yg,null,Z.createElement(Et,{variant:"title",size:"small"},$t.t("Details")),Z.createElement(ia,{size:10}),Object.entries(d.payable).flatMap(([y,C])=>C.map((k,w)=>{let x=`payable-fee-${w}`,I=js(k);return Z.createElement(ra,{key:x},Z.createElement(Et,{variant:"label",size:"medium",color:"neutral600"},Hs(y,$t.t)),Z.createElement(tb,{content:k.amount,container:g},Z.createElement(Et,{variant:"label",size:"medium"},P(k.amount,2,2),k.asset.symbol," ($",P(I,4,4),")")))})),Z.createElement(ra,{className:"total_payable_fee"},Z.createElement(Et,{variant:"label",size:"medium"},$t.t("Total Payable Fee")),Z.createElement(Et,{variant:"label",size:"medium"},"$",P(c,4,4))),Z.createElement(Zl,null),!!Object.keys(d.nonePayable).length&&Z.createElement(Yi,{triggerAnchor:"bottom",onClickTrigger:()=>r(y=>!y),trigger:Z.createElement("div",{className:Cg()},Z.createElement(Et,{size:"small",variant:"body",color:"neutral700"},n?$t.t("Hide non-payable fees"):$t.t("Show non-payable fees")),Z.createElement(ia,{size:4,direction:"horizontal"}),Z.createElement(ji,{orientation:n?"up":"down"},Z.createElement(Jx,{size:12,color:"gray"}))),open:n},Z.createElement(Et,{size:"small",variant:"title"},$t.t("Description")),Z.createElement(ia,{size:4}),Z.createElement(Et,{size:"small",variant:"body",color:"neutral700"},$t.t(`The following fees are considered in the transaction output and
|
|
2
|
-
you won\u2019t need to pay extra gas for them.`)),Z.createElement(ia,{size:10}),Object.entries(d.nonePayable).map(([y,C],k)=>{let w=Hd(C),x=Hs(y,$t.t),I=`non-payable-fee-${k}`;return Z.createElement(nb,{key:I,fee:w,label:x})}),Z.createElement(Zl,null)))))}i(Jl,"QuoteCostDetails");import{i18n as vg}from"@lingui/core";import{TokenAmount as xg}from"@rango-dev/ui";import aa from"react";import{css as rb,styled as ib}from"@rango-dev/ui";var kg=ib("div",{position:"relative",display:"flex",flexDirection:"column",width:"100%"}),wg=rb({height:"14px",marginLeft:"14px",position:"absolute",borderLeft:"1px solid $foreground",top:"42%"});function wr(t){let{from:e,to:o,percentageChange:n,warningLevel:r}=t;return aa.createElement(kg,null,aa.createElement(xg,{direction:"horizontal",label:vg.t("Swap input"),id:"widget-quote-summary-swap-input",type:"input",tooltipContainer:B(),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}}),aa.createElement("div",{className:wg()}),aa.createElement(xg,{id:"widget-quote-summary-estimated-input",direction:"horizontal",tooltipContainer:B(),label:vg.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(wr,"QuoteSummary");import{i18n as bg}from"@lingui/core";import{ChevronDownIcon as ab,ChevronRightIcon as sb,Divider as Rl,Image as lb,Tooltip as pa,Typography as sa}from"@rango-dev/ui";import q from"react";var la=4,ca=6,vr=i(t=>{let{content:e,src:o,className:n,open:r,state:a,container:s}=t,c=s||B();return q.createElement(pa,{container:c,side:"bottom",sideOffset:4,open:r,content:e},q.createElement(ug,{className:n,state:a},q.createElement(lb,{src:o,size:16})))},"ImageComponent");function Eg(t){let{quoteRef:e,selected:o,setExpanded:n,steps:r,expanded:a,type:s,container:c}=t,l=c||B(),p=r.length,u=Ld(r),{isTablet:m,isMobile:f}=kn();return q.createElement(pg,{className:"widget-quote-trigger-btn",listItem:s==="list-item",ref:h=>e.current=h,selected:o,onClick:h=>{h.stopPropagation(),n(g=>!g)}},q.createElement("div",{className:Wn()},q.createElement(sa,{variant:"body",size:"xsmall"},bg.t("Via:")),q.createElement(Rl,{direction:"horizontal",size:4}),r.map((h,g)=>{let d=`item-${g}`,S=q.createElement(Kl,null,q.createElement(sb,{size:12,color:"black"}));return f||m?q.createElement(q.Fragment,{key:d},q.createElement(vr,{content:h.swapper.displayName,src:h.swapper.image??"",state:h.state,container:c}),g!==p-1&&q.createElement(q.Fragment,null,S)):q.createElement(q.Fragment,{key:d},p<=la||p>la&&g<la-1?q.createElement(q.Fragment,null,q.createElement(vr,{content:h.swapper.displayName,src:h.swapper.image??"",state:h.state,container:c}),g!==p-1&&q.createElement(q.Fragment,null,S)):g===la-1&&q.createElement(pa,{container:l,side:"bottom",align:"end",sideOffset:4,content:q.createElement("div",{className:Wn()},S,r.map((y,C)=>{let k=`image-${C}`;return C>=g&&q.createElement(q.Fragment,{key:k},q.createElement(vr,{content:y.swapper.displayName,src:y.swapper.image??"",state:y.state,open:!1}),C!==p-1&&q.createElement(q.Fragment,null,S))}))},q.createElement(Yl,{state:r.find((y,C)=>C>=g&&(y.state==="error"||y.state==="warning"))?.state},q.createElement(sa,{size:"xsmall",variant:"body"},"+",p-g))))})),q.createElement("div",{className:Wn()},q.createElement("div",{className:"blockchains_section"},q.createElement("div",{className:Wn()},q.createElement(sa,{variant:"body",size:"xsmall"},bg.t("Chains:")),q.createElement(Rl,{direction:"horizontal",size:4}),u.map((h,g)=>q.createElement(q.Fragment,{key:h.displayName},u.length<=ca||u.length>ca&&g<ca-1?q.createElement(pa,{container:l,side:"bottom",content:h.displayName,sideOffset:4},q.createElement(vr,{content:"",src:h.image??"",open:!1,className:g!==0?"blockchainImage":""})):g===ca-1&&q.createElement(pa,{container:l,side:"bottom",align:"end",sideOffset:4,content:q.createElement("div",{className:Wn()},u.map((d,S)=>S>=g&&q.createElement(vr,{key:d.displayName,content:"",src:d.image??"",open:!1,className:S>g?"blockchainImage":"",container:c})))},q.createElement(Yl,{className:"blockchainImage"},q.createElement(sa,{size:"xsmall",variant:"body"},"+",u.length-g))))),q.createElement(Rl,{direction:"horizontal",size:32}))),q.createElement(Kl,{orientation:a?"up":"down"},q.createElement(ab,{size:12,color:"black"}))))}i(Eg,"QuoteTrigger");function rc(t){let{quote:e,input:o,output:n,error:r,warning:a,type:s,selected:c=!1,tagHidden:l=!0,showModalFee:p=!0,onClickAllRoutes:u,fullExpandedMode:m=!1,container:f}=t,h=T().blockchains(),{findToken:g}=T(),d=T().swappers(),{customSlippage:S,slippage:y}=T(),C=S||y,[k,w]=fb(t.expanded),x=ua(null),I=P(n.value,6,6),A=n.usdValue?P(n.usdValue,4,4):"",b=jt(o.usdValue,n.usdValue??null),E=P(b,2,2),v=Xt(b??0),N=i((Q,j)=>Q.map((K,Ie)=>{let Ae,je=r?.type===3&&r.swap.swapperId===K.swapperId,Mt=r?.type===4&&!!r.recommendedSlippages?.[Ie],so=a?.type===2&&!!a.recommendedSlippages?.[Ie],Io=je||Mt,zn=so;Io?Ae="error":zn&&(Ae="warning");let Rr=Io?qo.t("Slippage Error"):qo.t("Slippage Warning");return je&&(Rr=qo.t("Bridge Limit Error")),{swapper:{displayName:Hn(K.swapperId,d)??"",image:K.swapperLogo},from:{token:{displayName:K.from.symbol,image:K.from.logo},chain:{displayName:ht(K.from.blockchain,h)??"",image:K.from.blockchainLogo},price:{value:Ie===0&&!j?P(o.value,6,6):P(K.fromAmount,6,6),usdValue:P((K.from.usdPrice??0)*parseFloat(K.fromAmount),4,4),realValue:Ie===0?o.value:K.fromAmount,realUsdValue:new nc(K.from.usdPrice??0).multipliedBy(K.fromAmount).toString()}},to:{token:{displayName:K.to.symbol,image:K.to.logo},chain:{displayName:ht(K.to.blockchain,h)||"",image:K.to.blockchainLogo},price:{value:P(K.toAmount,6,6),usdValue:P((K.to.usdPrice??0)*parseFloat(K.toAmount),4,4),realValue:K.toAmount,realUsdValue:new nc(K.to.usdPrice??0).multipliedBy(K.toAmount).toString()}},state:Ae,alerts:Io||zn?O.createElement(tg,{dense:m},O.createElement(cb,{variant:"alarm",type:Io?"error":"warning",title:Rr,id:"widget-quote-footer-step-alarm-alert",footer:O.createElement(og,null,je&&O.createElement("div",null,O.createElement(Ln,{size:"xsmall",variant:"body",color:"neutral900"},r.fromAmountRangeError),O.createElement(Mn,{direction:"vertical",size:2}),O.createElement(Ln,{size:"xsmall",variant:"body",className:"from-amount-text",color:"neutral900"},qo.t({id:"Yours: {amount} {symbol}",values:{amount:P(K.fromAmount,6,6),symbol:K?.from.symbol}}))),(Mt||so)&&!je&&O.createElement("div",null,O.createElement(Ln,{size:"xsmall",variant:"body",color:"neutral900"},qo.t({id:"Minimum suggested slippage: {minRequiredSlippage}",values:{...r?.type===4&&{minRequiredSlippage:r.recommendedSlippages?.[Ie]},...a?.type===2&&{minRequiredSlippage:a.recommendedSlippages?.[Ie]}}})),O.createElement(Mn,{direction:"vertical",size:2}),O.createElement(Ln,{size:"xsmall",variant:"body",color:"neutral900"},qo.t({id:"Yours: {userSlippage}",values:{userSlippage:C}}))))})):void 0,time:Gn(K.estimatedTimeInSeconds),fee:P(Ks(K,g),2,2),internalSwaps:K.internalSwaps?N(K.internalSwaps):void 0}}),"getQuoteSteps"),W=N(e?.swaps??[]),D=W.length,H=f||B(),X=_d(t.quote.tags||[]),Y=!!u,M=ci(e?.swaps),ee=Gn(M),J=Mi(e?.swaps??[],g),te=P(J,2,2),ce=J.gte(new nc(bd)),Oe=M/Id>=Ed,ne=ua(null),wt=oc(o.value,ne),gt=ua(null),Wt=oc(n.value,gt),$=ua(null),U=oc(A,$),G=W[D-1],pe=W[0];return!pe||!G?null:m?O.createElement(pb,{selected:c,fee:te,time:ee,tooltipContainer:Wo(),steps:W,tags:X,id:"widget-quote-full-expanded-quote-container",quoteCost:O.createElement(Jl,{quote:e,fullExpandedMode:!0,time:ee,fee:J,feeWarning:ce,timeWarning:Oe,showModalFee:p,steps:D}),percentageChange:E,warningLevel:v,outputPrice:{value:I,usdValue:A,realValue:n.value,realUsdValue:n.usdValue}}):O.createElement(sg,{id:"widget-quote-summary-container",selected:c,listItem:s==="list-item",basic:s==="basic"},O.createElement("div",{className:lg()},!l&&X.length?O.createElement(O.Fragment,null,O.createElement(gg,null,X.map((Q,j)=>{let K=`${Q.value}_${j}`;return O.createElement(O.Fragment,{key:K},O.createElement(ub,{label:Q.label,value:Q.value}),O.createElement(Mn,{size:4,direction:"horizontal"}))})),O.createElement(oa,null),!Y&&O.createElement(Mn,{size:4})):null,O.createElement("div",{id:"portal-root",className:cg()},O.createElement(Jl,{quote:e,time:ee,fee:J,feeWarning:ce,timeWarning:Oe,showModalFee:p,steps:D}),Y&&O.createElement(ag,{onClick:Q=>{Q.stopPropagation(),u()},id:"widget-quote-all-routes-btn",size:"xxsmall",type:"secondary",variant:"default",css:{paddingLeft:"$10",paddingRight:"$10",paddingTop:"$5",paddingBottom:"$5"}},O.createElement(Ln,{color:"secondary",variant:"body",size:"xsmall",className:"allRoutesLabel"},qo.t("See All Routes")))),s==="basic"&&O.createElement(fg,null,O.createElement(Xl,{ref:ne,size:"small",variant:"body"},o.value),wt&&O.createElement(tc,{content:o.value,container:H,open:o.value?void 0:!1},O.createElement(ec,{size:12,color:"gray"})),O.createElement(jl,{size:"small",variant:"body"},W[0]?.from.token.displayName),O.createElement(Ln,{size:"small",variant:"body"},"="),O.createElement(Xl,{ref:gt,size:"small",variant:"body"},n.value),Wt&&O.createElement(tc,{content:n.value,container:H,open:n.value?void 0:!1},O.createElement(ec,{size:12,color:"gray"})),O.createElement(jl,{size:"small",variant:"body"},G?.to.token.displayName),O.createElement(Mn,{size:2,direction:"horizontal"}),O.createElement(hg,{ref:$,color:"$neutral600",size:"xsmall",variant:"body"},`($${A})`),U&&O.createElement(tc,{content:n.usdValue,container:H},O.createElement(ec,{size:12,color:"gray"}))),s==="list-item"&&O.createElement(mb,{id:"widget-quote-token-amount-container",tooltipContainer:H,type:"output",direction:"vertical",price:{value:I,usdValue:A,realValue:n.value,realUsdValue:n.usdValue},token:{displayName:G.to.token.displayName,image:G.to.token.image},chain:{image:G.to.chain.image},percentageChange:E,warningLevel:v}),s==="swap-preview"&&O.createElement(O.Fragment,null,O.createElement(wr,{from:pe.from,to:G.to,percentageChange:E,warningLevel:v}),O.createElement(Mn,{size:4}))),O.createElement(rg,{selected:c,listItem:s==="list-item",open:k,className:"quote_container",onOpenChange:w},O.createElement(Eg,{type:s,quoteRef:x,selected:c,setExpanded:w,container:H,expanded:k,steps:W}),O.createElement(dg,{open:k},O.createElement(mg,null),O.createElement("div",{className:ig()},W.map((Q,j)=>{let K=`item-${j}`;return O.createElement(db,{type:"quote-details",className:"widget-quote-step-details-container",key:K,tooltipContainer:H,step:Q,hasSeparator:j!==W.length-1,state:Q.state})})))))}i(rc,"Quote");import{Divider as Sb,Skeleton as Cb}from"@rango-dev/ui";import eo from"react";import{darkTheme as gb,styled as da}from"@rango-dev/ui";var Ig=da("div",{$$color:"$colors$neutral100",[`.${gb} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",borderBottomLeftRadius:"$xm",borderBottomRightRadius:"$xm",padding:"$15",variants:{rounded:{true:{borderRadius:"$xm"}},expanded:{true:{paddingBottom:"3px"},false:{paddingBottom:"$12"}}}}),Ag=da("div",{paddingTop:"$2"}),Ng=da("div",{paddingLeft:"$8"}),Bg=da("div",{borderLeft:"1px dashed $foreground",minHeight:" 0",margin:"0px 11.5px",alignSelf:"stretch",variants:{hideSeparator:{true:{minHeight:"unset",height:"0"}}}});import{ChainToken as Ug,Divider as It,Skeleton as ut}from"@rango-dev/ui";import V from"react";import{css as hb,styled as Rt}from"@rango-dev/ui";var ic=Rt("div",{display:"flex"}),Wg=Rt("div",{padding:"$10 $0 $20"}),Mg=Rt("div",{padding:"14px $0 $20 $0",display:"flex",flexDirection:"column"}),Lg=Rt("div",{display:"flex",justifyContent:"start",alignItems:"center"}),Pg=Rt("div",{display:"flex",justifyContent:"space-between",alignItems:"end"}),_g=Rt("div",{height:"$24",marginLeft:"13px",borderLeft:"1px solid $neutral700"}),Dg=Rt("div",{width:"65%",display:"flex",justifyContent:"start"}),$g=Rt("div",{display:"flex",flexDirection:"column",alignItems:"start",flexGrow:1,maxWidth:"148px"}),Fg=Rt("div",{padding:"$15 $0 $15 $0"}),Og=hb({display:"flex",justifyContent:"space-between",alignItems:"center"});function xr(t){let{type:e,tagHidden:o=!0}=t,n=V.createElement(Pg,null,V.createElement(Dg,null,V.createElement(Ug,{loading:!0,size:"medium"}),V.createElement(It,{size:8,direction:"horizontal"}),V.createElement($g,null,V.createElement(ut,{height:10,width:60,variant:"rounded"}),V.createElement(It,{size:4}),V.createElement(ut,{height:15,variant:"rounded"}))),V.createElement(ut,{height:12,width:64,variant:"rounded"})),r=e==="basic"&&!o;return V.createElement("div",null,!o&&V.createElement(V.Fragment,null,V.createElement(ic,null,V.createElement(ut,{width:65,height:20,variant:"rounded"}),V.createElement(It,{size:4,direction:"horizontal"}),V.createElement(ut,{width:65,height:20,variant:"rounded"}),V.createElement(It,{size:4,direction:"horizontal"}),V.createElement(ut,{width:65,height:20,variant:"rounded"})),V.createElement(oa,null),!r&&V.createElement(It,{size:4})),V.createElement("div",{className:Og()},V.createElement(ic,null,V.createElement(ut,{width:60,height:10,variant:"rounded"}),V.createElement(It,{size:4,direction:"horizontal"}),V.createElement(ut,{width:60,height:10,variant:"rounded"}),V.createElement(It,{size:4,direction:"horizontal"}),V.createElement(ut,{width:60,height:10,variant:"rounded"})),r&&V.createElement(ut,{width:85,height:24,variant:"rounded"})),e==="basic"&&V.createElement(Wg,null,V.createElement(ut,{height:15,width:148,variant:"rounded"})),e==="list-item"&&V.createElement(Mg,null,V.createElement(Lg,null,V.createElement(Ug,{loading:!0,size:"medium"}),V.createElement(It,{direction:"horizontal",size:4}),V.createElement(ut,{height:15,width:150,variant:"rounded"})),V.createElement(It,{size:10}),V.createElement(ut,{height:10,width:184,variant:"rounded"})),e==="swap-preview"&&V.createElement(V.Fragment,null,V.createElement(It,{size:4}),V.createElement(Fg,null,n,V.createElement(_g,null),n),V.createElement(It,{size:12})))}i(xr,"QuoteSummarySkeleton");import{ChainToken as Gg,Divider as sc,NextIcon as yb,Skeleton as ma}from"@rango-dev/ui";import Me from"react";import{styled as br}from"@rango-dev/ui";var zg=br("div",{display:"flex",alignItems:"start"}),Qg=br("div",{flexGrow:1,paddingTop:"$5",paddingBottom:"$10",display:"flex",alignItems:"center",variants:{extraSpace:{true:{paddingBottom:"$40"}}}}),ac=br("div",{display:"flex",alignItems:"center",flexGrow:1}),Hg=br("div",{margin:"$0 $2",padding:"$4",display:"flex",justifyContent:"center",alignItems:"center"}),qg=br("div",{display:"flex",alignItems:"center"});function Ft(t){let{separator:e=!0}=t;return Me.createElement(Me.Fragment,null,Me.createElement(qg,null,Me.createElement(ma,{height:22,width:22,variant:"circular"}),Me.createElement(sc,{direction:"horizontal",size:8}),Me.createElement(ma,{height:15,width:148,variant:"rounded"})),Me.createElement(zg,null,Me.createElement(Bg,{hideSeparator:!e}),Me.createElement(Qg,{extraSpace:e},Me.createElement(ac,null,Me.createElement(Gg,{size:"small",loading:!0}),Me.createElement(sc,{direction:"horizontal",size:8}),Me.createElement(ma,{height:12,variant:"rounded"})),Me.createElement(Hg,null,Me.createElement(yb,{color:"gray",size:16})),Me.createElement(ac,null,Me.createElement(Gg,{size:"small",loading:!0}),Me.createElement(sc,{direction:"horizontal",size:8}),Me.createElement(ma,{height:12,variant:"rounded"})))))}i(Ft,"StepSkeleton");function Er(t){let{type:e,expanded:o,tagHidden:n=!1}=t;return eo.createElement(Ig,{expanded:o,rounded:e!=="basic"},eo.createElement(xr,{type:e,tagHidden:n}),eo.createElement(Ag,null,eo.createElement(Cb,{height:15,variant:"rounded"})),o&&eo.createElement(Ng,null,eo.createElement(Sb,{size:24}),eo.createElement(Ft,null),eo.createElement(Ft,null),eo.createElement(Ft,{separator:!1})))}i(Er,"QuoteSkeleton");function Go(t){let{quote:e,type:o,loading:n,error:r,warning:a,expanded:s=!1,tagHidden:c,onClick:l,showModalFee:p,selected:u,id:m,onClickAllRoutes:f,fullExpandedMode:h=!1,container:g}=t,{inputAmount:d,inputUsdValue:S}=z()(),y=e?.outputAmount?new Tb(e?.outputAmount):null,C=e?St(e):null,w=!(r&&(r.type===0||r.type===1))&&e&&!n;return n?fa.createElement(Gl,null,fa.createElement(Er,{tagHidden:c,type:o,expanded:s})):w?fa.createElement(Gl,{onClick:()=>l?.(e),id:m},fa.createElement(rc,{quote:e,error:r,container:g,showModalFee:p,warning:a,tagHidden:c,selected:u,type:o,expanded:s,onClickAllRoutes:f,fullExpandedMode:h,input:{value:d,usdValue:S?.toString()??""},output:{value:y?.toString()??"",usdValue:C?.toString()??""}})):null}i(Go,"QuoteInfo");import{warn as xb}from"@rango-dev/logging-core";import{calculatePendingSwap as bb}from"@rango-dev/queue-manager-rango-preset";import{useEffect as Eb}from"react";import{useRef as kb,useState as wb}from"react";var vb=2e3;function ga({request:t}){let[e,o]=wb(!1),n=kb(null),r=i(()=>n.current?.abort(),"cancelFetch"),a=i(async c=>(await new Promise(l=>setTimeout(l,vb)),await s(c,!1)),"retryFetch"),s=i(async(c,l=!1)=>{r(),n.current=new AbortController,o(!0);try{let p=await t(c,{signal:n.current.signal});return n.current=null,p}catch(p){if(l)return await a(c);throw p}finally{o(!1)}},"fetch");return{fetch:s,loading:e,cancelFetch:r}}i(ga,"useFetch");function Vg(){let{fetch:t,loading:e,cancelFetch:o}=ga({request:async(n,r)=>await ct().confirmRoute(n,r)});return{fetch:t,loading:e,cancelFetch:o}}i(Vg,"useFetchConfirmQuote");function ha(t){if(!t.swaps)throw new Error(ie().noResultError.title,{cause:{type:0,diagnosisMessage:t.diagnosisMessages?.[0]}});let e=lc(t.swaps);if(e)throw new Error(e.message,{cause:e.options})}i(ha,"throwErrorIfResponseIsNotValid");function lc(t){if(Ud(t)){let{swap:n,fromAmountRangeError:r,recommendation:a}=zd(t);return n?{message:"bridge limit error",options:{type:3,swap:n,recommendation:a,fromAmountRangeError:r}}:null}let o=Gd(t);if(o){let n=Li(t);return{message:"",options:{type:4,recommendedSlippages:o,minRequiredSlippage:n}}}return null}i(lc,"getQuoteError");function Kg(t){let{currentQuote:e,previousQuote:o,meta:n,selectedWallets:r,userSlippage:a,findToken:s}=t,c={quote:null,balance:null},l=Sn({previousQuote:o,currentQuote:e,findToken:s,userSlippage:a});l&&(c.quote=l);let p=jd(e,r,n.blockchains);return p.length===0||(c.balance={messages:p}),c}i(Kg,"generateWarnings");function ya(t){return t?.code==="ERR_CANCELED"?{type:2}:t.cause?t.cause:t?.code==="ERR_BAD_REQUEST"?{type:0,diagnosisMessage:t.response.data.error}:{type:1,diagnosisMessage:t.message}}i(ya,"handleQuoteErrors");function cc(){let{fromToken:t,toToken:e,inputAmount:o,inputUsdValue:n,setSelectedQuote:r,selectedQuote:a,customDestination:s,resetAlerts:c}=z()(),{slippage:l,customSlippage:p}=T(),u=T().getDisabledLiquiditySources(),m=T().blockchains(),f=T().tokens(),{findToken:h}=T(),{swapMode:g}=ot(),d=p||l,{fetch:S,cancelFetch:y,loading:C}=Vg();return Eb(()=>y,[]),{loading:C,fetch:i(async w=>{let x=w.selectedWallets,I=w?.customDestination??s;if(!t||!e||!o)return{quote:null,swap:null,error:null,warnings:null};let A=x.reduce((E,v)=>(E[v.chain]=v.address,E),{}),b={requestId:a?.requestId||"",selectedWallets:A,destination:I||void 0};try{return await S(b,!0).then(E=>{let{result:v}=E;if(!v)throw new Error(E.error??"Error fetching updated quote");ha({diagnosisMessages:v.diagnosisMessages,requestId:v.requestId,swaps:v.result?.swaps});let N={outputAmount:v.result?.outputAmount,requestId:v.requestId,resultType:v.result?.resultType,swaps:v.result?.swaps||[],validationStatus:v.validationStatus,requestAmount:v.requestAmount};r(N);let W={slippage:d.toString(),disabledSwappersGroups:u},D=Kg({previousQuote:a??void 0,currentQuote:N,meta:{blockchains:m},selectedWallets:x,userSlippage:d,inputUsdValue:n,findToken:h});c();let H=!!D.balance,X=bb({inputAmount:o.toString(),bestRoute:v,wallets:Kd(x),settings:W,validateBalanceOrFee:!H,meta:{blockchains:m,tokens:f},swapMode:g});return{quote:N,swap:X,error:null,warnings:D}})}catch(E){let v=ya(E);return v.type!==2&&xb(new Error("confirm swap error"),{tags:{...v,type:Ze[v.type],initialQuote:a,requestBody:b}}),{swap:null,error:v,warnings:null}}},"fetch"),cancelFetch:y}}i(cc,"useConfirmSwap");var Db=Bb("div",{width:"100%",display:"flex",justifyContent:"space-between",[`& ${jg}`]:{width:"$48",height:"$48"}}),$b=dc({flexGrow:1,paddingRight:"$10"}),Fb=dc({width:"$24",height:"$24",display:"flex",justifyContent:"center",alignItems:"center"}),Ob=dc({display:"flex",justifyContent:"space-between",alignItems:"center"});function Xg(){let{selectedQuote:t,setInputAmount:e,selectedWallets:o,quoteWalletsConfirmed:n,customDestination:r,quoteWarningsConfirmed:a}=z()(),s=_b(),[c,l]=Ir(""),p=!n,[u,m]=Ir(!1),[f,h]=Ir(!1),{isActiveTab:g}=re(),d=T().getDisabledLiquiditySources(),S=Pb(d),{manager:y}=Ib(),{fetch:C,loading:k,cancelFetch:w}=cc(),[x,I]=Ir({swap:null,error:null,warnings:null}),[A,b]=Ir(!1),E=i(async({selectedWallets:M,customDestination:ee})=>{let J=await C?.({selectedWallets:M,customDestination:ee});return I(J),J},"onConfirmSwap"),v=i(async()=>{if(x.swap&&n)try{await y?.create("swap",{swapDetails:x.swap},{id:x.swap.requestId});let M=`../${F.swaps}/${x.swap.requestId}`;s(M,{replace:!0}),setTimeout(()=>{e("")},0)}catch(M){l("Error: "+M?.message)}},"addNewSwap"),N=i(async()=>{h(!0),await v(),h(!1)},"onConfirm"),W=i(async()=>{x.warnings?.quote&&Md(x.warnings.quote)&&!a?b(!0):await N()},"onStartConfirmSwap"),D=i(async()=>{I({error:null,swap:null,warnings:null}),C({selectedWallets:o,customDestination:r}).then(M=>{I(M)}).catch(M=>console.error(M))},"onRefresh");Sa(()=>{!!S.current.length&&!d.length&&D(),S.current=d},[d.length]),Sa(()=>{p&&w()},[p]),Sa(()=>{p&&m(p)},[p]),Sa(()=>{p||C({selectedWallets:o,customDestination:r}).then(M=>I(M)).catch(M=>console.error(M))},[]),Lb(()=>{t?.requestId||s(`../${location.search}`)},[t?.requestId]);let H=x.warnings?.quote??null,X=x.error,Y=[];if(c&&Y.push($e.createElement(Ab,{id:"widget-confirm-swap-db-error-alert",type:"error",variant:"alarm",title:c})),H||X){let M=`../${F.settings}`;Y.push($e.createElement(kr,{warning:H,error:X,couldChangeSettings:!1,refetchQuote:D,skipAlerts:X?.type===4||H?.type===2,showWarningModal:A,confirmationDisabled:!g,onOpenWarningModal:()=>b(!0),onCloseWarningModal:()=>b(!1),onConfirmWarningModal:async()=>{b(!1),await v()},onChangeSettings:()=>s(M)}))}return $e.createElement(se,{header:{title:pc.t("Confirm Swap"),onWallet:()=>{let M=`../${F.wallets}`;s(M)}},footer:$e.createElement(Db,null,$e.createElement("div",{className:$b()},$e.createElement(Nb,{id:"widget-confirm-swap-start-btn",variant:"contained",type:"primary",size:"large",fullWidth:!0,loading:k||f,disabled:!!x.error||!g,onClick:W},pc.t("Start Swap"))),$e.createElement(jg,{id:"widget-confirm-swap-wallet-icon-btn",variant:"contained",type:"primary",size:"large",loading:k||f,disabled:!g,onClick:m.bind(null,!0)},$e.createElement(Mb,{size:24})))},u&&$e.createElement(Pf,{open:u,onClose:()=>m(!1),onCancel:w,loading:k,onCheckBalance:E}),$e.createElement(ue,null,$e.createElement("div",{className:Ob()},$e.createElement(Wb,{variant:"title",size:"small"},pc.t("You get")),$e.createElement("div",{className:Fb()},$e.createElement(Ui,{onClick:!k&&!u&&!A?D:void 0}))),$e.createElement(uc,{size:"12"}),Nm(Y.map((M,ee)=>({element:M,key:`alert-${ee}`})),$e.createElement(uc,{size:10})),Y.length>0?$e.createElement(uc,{size:10}):null,$e.createElement(Go,{quote:t,type:"swap-preview",id:"widget-confirm-swap-quote-container",expanded:!0,tagHidden:!0,error:x.error,loading:k,warning:x.warnings?.quote??null})))}i(Xg,"ConfirmSwapPage");import{i18n as oo}from"@lingui/core";import{Button as xc,CustomTokensZeroStateDarkIcon as iE,CustomTokensZeroStateIcon as aE,DeleteIcon as sE,Divider as Mr,IconButton as lE,MessageBox as cE,NotFound as pE,styled as Ec}from"@rango-dev/ui";import ye,{useState as bc}from"react";import{useNavigate as uE}from"react-router-dom";import{CloseIcon as Ub,IconButton as zb,SearchIcon as Qb,TextField as Hb}from"@rango-dev/ui";import Pn from"react";import{styled as Yg}from"@rango-dev/ui";var Zg=Yg("div",{width:"$24",height:"$24",display:"flex",alignItems:"center",justifyContent:"center"}),Jg=Yg("div",{width:"100%","& ._text-field":{paddingLeft:"$10","& input":{paddingLeft:"$2",paddingTop:"$12",paddingBottom:"$12"}}});function At(t){let{variant:e,fullWidth:o,color:n,size:r,onChange:a,value:s,style:c,setValue:l,suffix:p,id:u,...m}=t,f=s.length?Pn.createElement(zb,{id:`${u}\u06F0icon-btn`,variant:"ghost",onClick:()=>l?.(""),size:"small"},Pn.createElement(Ub,{color:"gray",size:10})):null;return p&&(f=p),Pn.createElement(Jg,null,Pn.createElement(Hb,{prefix:Pn.createElement(Zg,null,Pn.createElement(Qb,{color:"black"})),id:u,suffix:f,fullWidth:o,color:n,variant:e,style:{borderRadius:25,alignItems:"center",...c},size:r,value:s,onChange:a,...m}))}i(At,"SearchInput");import{i18n as vc}from"@lingui/core";import{Button as Kb,CustomTokenWarning as jb,darkTheme as ph,Divider as to,ExternalLinkIcon as Xb,Image as Yb,ListItem as Zb,NotFound as Jb,PinIcon as Rb,Skeleton as Vo,Typography as Br,VirtualizedList as eE}from"@rango-dev/ui";import L,{useState as tE}from"react";import{useTranslation as oE}from"react-i18next";import{Divider as lh,ListItem as Vb,Skeleton as Nr}from"@rango-dev/ui";import Nt from"react";import{css as _n,darkTheme as mc,ImageContainer as qb,ListItemButton as Gb,styled as it,Typography as Rg}from"@rango-dev/ui";var fc=_n({position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:100,overflow:"hidden"}),gc=_n({position:"relative",height:12,width:"30%",maxWidth:"150px"}),hc=_n({position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",bottom:"-8px"}),yc=_n({transform:"translateY(12px)",visibility:"hidden",display:"flex","& a":{display:"flex",justifyContent:"center",alignItems:"center",fontSize:"$12",lineHeight:"$16",$$color:"$colors$neutral600",[`.${mc} &`]:{$$color:"$colors$neutral700"},color:"$$color",textDecoration:"none"}}),Sc=_n({}),Cc=_n(),eh=it("div",{display:"flex",flexDirection:"column",flexGrow:1,overflow:"hidden",justifyContent:"center"}),Tc=it("div",{display:"flex",alignItems:"center","._typography":{textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:100,overflow:"hidden"}}),Ca=it("ul",{flexGrow:1,padding:0,margin:0,listStyle:"none","& li":{alignItems:"none","&:hover":{[`& .${gc}`]:{[`& .${yc}`]:{position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",visibility:"visible"},[`& .${Sc}`]:{bottom:"-15px"},[`& .${fc}`]:{position:"absolute",transform:"translateY(-12px)",visibility:"hidden"},[`& .${hc}`]:{position:"absolute",transform:"translateY(-12px)",bottom:"-10px"}}}}}),th=it(Gb,{variants:{customToken:{true:{"&:hover":{cursor:"unset"}}}}}),kc=it("div",{paddingLeft:"$5",paddingRight:"$5",borderRadius:"$md",display:"flex",alignItems:"center"}),wc=it(Rg,{}),oh=it("div",{textAlign:"right",width:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",[`& .${Cc}`]:{$$color:"$colors$neutral600",[`.${mc} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),Ar=it("div",{display:"flex",alignItems:"end",flexDirection:"column"}),CV=it("div",{display:"flex",alignItems:"center"}),nh=it("div",{position:"relative",[`& ${qb}`]:{borderRadius:"$xm",overflow:"hidden"}}),rh=it("div",{position:"absolute",backgroundColor:"$neutral100",padding:"$4",borderRadius:"50%",bottom:-6,right:-6}),ih=it(Rg,{width:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}),ah=it("a",{"& svg:hover":{color:"$colors$info"}}),sh=it("div",{paddingRight:"$5","& .widget-token-list-item-btn":{width:"100%",overflow:"hidden",height:"60px"},"& .widget-token-list-item-import-btn":{height:"$20",padding:"0 $10","& ._text":{display:"flex",justifyContent:"center",alignItems:"center"},"& ._typography":{[`.${mc} &`]:{color:"$foreground"}}}});function ch(t){return Nt.createElement(Ca,null,Array.from(Array(t.size),e=>Nt.createElement(Vb,{key:e,hasDivider:!0,start:Nt.createElement(Nr,{variant:"circular",width:35,height:35}),end:Nt.createElement(Ar,null,Nt.createElement(Nr,{variant:"text",size:"large",width:70}),Nt.createElement(lh,{size:4}),Nt.createElement(Nr,{variant:"text",size:"medium",width:50})),title:Nt.createElement("div",null,Nt.createElement(Nr,{variant:"text",size:"large",width:90}),Nt.createElement(lh,{size:4}),Nt.createElement(Nr,{variant:"text",size:"medium",width:90}))})))}i(ch,"LoadingTokenList");var nE=20,rE=i(t=>{let{address:e,name:o,url:n,token:r,customCssForTag:a,customCssForTagTitle:s}=t,c=e.length;return L.createElement("div",{className:gc()},o?L.createElement("div",{className:fc()},o):L.createElement(Tc,{className:hc()},L.createElement(Br,{variant:"title",size:"xmedium"},r.symbol),L.createElement(to,{direction:"horizontal",size:4}),L.createElement(kc,{css:a},L.createElement(wc,{variant:"body",size:"xsmall",css:s},r.blockchain))),!!e&&L.createElement("div",{className:`${yc()} ${!o&&Sc()}`},c>10?`${e.slice(0,5)}...${e.slice(c-6,c)}`:e," ",L.createElement(to,{size:4,direction:"horizontal"}),L.createElement(ah,{href:n,target:"_blank",rel:"nofollow noreferrer",onClick:l=>l.stopPropagation()},L.createElement(Xb,{size:12}))))},"renderDesc");function Wr(t){let{list:e,searchedFor:o="",onChange:n,selectedBlockchain:r,showTitle:a=!0,action:s,type:c,showWarning:l=!0}=t,p=T().fetchStatus,u=T().blockchains(),{getBalanceFor:m,fetchingWallets:f}=T(),{isTokenPinned:h}=T(),{setFromToken:g,setToToken:d}=z()(),{t:S}=oE(),y=Ge(),[C,k]=tE(null),w=i(()=>{c==="source"?g({token:C,meta:{blockchains:u}}):d({token:C,meta:{blockchains:u}})},"updateToken"),x=i(()=>{w(),y()},"handleImportToken"),I=i(E=>{if(E.customToken){let{customToken:N,...W}=E;return L.createElement(Kb,{variant:"contained",type:"primary",size:"small",className:"widget-token-list-item-import-btn",onClick:i(H=>{H.stopPropagation(),k({...W,warning:!0})},"handleClick")},L.createElement(Br,{variant:"body",size:"xsmall",color:"background"},S("import")))}let v=mi(m(E));return s?s(E):f?L.createElement(Ar,null,L.createElement(Vo,{variant:"text",size:"large",width:70}),L.createElement(to,{size:4}),L.createElement(Vo,{variant:"text",size:"medium",width:50})):v&&L.createElement(oh,null,L.createElement(ih,{variant:"title",size:"small"},v.amount),L.createElement("div",null),v.usdValue&&L.createElement(Br,{variant:"body",className:Cc(),size:"xsmall"},`$${v.usdValue}`))},"endRenderer"),A=i(()=>L.createElement(eE,{itemContent:E=>{let v=e[E];if(v==="skeleton")return L.createElement(Zb,{hasDivider:!0,start:L.createElement(Vo,{variant:"circular",width:35,height:35}),end:L.createElement(Ar,null,L.createElement(Vo,{variant:"text",size:"large",width:70}),L.createElement(to,{size:4}),L.createElement(Vo,{variant:"text",size:"medium",width:50})),title:L.createElement("div",null,L.createElement(Vo,{variant:"text",size:"large",width:90}),L.createElement(to,{size:4}),L.createElement(Vo,{variant:"text",size:"medium",width:90}))});let N=u.find(M=>M.name===v?.blockchain);if(!N||!v)return null;let W=v.address,D=cl(N.color,"main"),H={$$color:D.main150,[`.${ph} &`]:{$$color:D.main750},backgroundColor:"$$color"},X={$$color:D.main750,[`.${ph} &`]:{$$color:D.main150},color:"$$color"},Y=i(()=>{typeof v!="string"&&!v.customToken&&n?.(v)},"handleClick");return L.createElement(sh,null,L.createElement(th,{"tab-index":E,key:`${v.symbol}${W}`,id:`${v.symbol}${W}`,className:"widget-token-list-item-btn",hasDivider:!0,customToken:v?.customToken,onClick:Y,start:L.createElement(nh,null,L.createElement(Yb,{src:v.image===""?ni:v.image,size:30}),t.type!=="custom-token"&&v&&h(v,t.type)&&L.createElement(rh,null,L.createElement(Rb,{size:12,color:"gray"}))),title:N.type==="COSMOS"||v.name||!v.name&&!W?L.createElement(Tc,null,L.createElement(Br,{variant:"title",size:"xmedium"},v.symbol),L.createElement(to,{direction:"horizontal",size:4}),L.createElement(kc,{css:H},L.createElement(wc,{variant:"body",size:"xsmall",css:X},v.blockchain)),l&&v.warning&&L.createElement(L.Fragment,null,L.createElement(to,{direction:"horizontal",size:4}),L.createElement(jb,{container:B()}))):void 0,description:typeof v!="string"&&N.info&&W&&N.type!=="COSMOS"?rE({address:W,token:v,customCssForTag:H,customCssForTagTitle:X,name:v.name,url:N.info.addressUrl.split("{wallet}").join(W)}):v.name||void 0,end:I(v)}))},totalCount:e.length,key:`${r}-${o}`}),"renderList"),b=C?No(C?.blockchain,u):null;return L.createElement(L.Fragment,null,a&&L.createElement(L.Fragment,null,L.createElement(Br,{variant:"label",size:"large"},vc.t("Select Token")),L.createElement(to,{size:4})),L.createElement(eh,null,L.createElement(to,{size:4}),p==="loading"&&L.createElement(ch,{size:nE}),p==="success"&&(e.length?L.createElement(L.Fragment,null,L.createElement(mr,{token:C,address:C?.address??"",blockchain:b??void 0,onImport:x,onExitErrorModal:()=>k(null),onExitImportModal:()=>k(null)}),L.createElement(Ca,{as:"ul"},A())):!!o&&L.createElement(Jb,{title:vc.t("No results found"),description:vc.t("Try using different keywords")}))))}i(Wr,"TokenList");var dE=Ec("div",{display:"flex",justifyContent:"space-between",flexDirection:"column",flex:1}),mE=Ec("div",{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",flex:"0.75"}),fE=Ec(lE,{"&:hover":{"& svg":{color:"$secondary550"}}});function uh(){let[t,e]=bc(""),{deleteCustomToken:o}=T(),n=T().customTokens(),{fromToken:r,toToken:a,setFromToken:s,setToToken:c}=z()(),{mode:l}=mo({}),p=uE(),[u,m]=bc(!1),[f,h]=bc(),g=i(C=>{let k=C.target.value;e(k)},"handleSearch"),d=l==="dark",S=n.filter(C=>st(C.symbol,t)||st(C.address||"",t)||st(C.name||"",t)),y=i(()=>{if(f){let C=a?yt(a):null,k=r?yt(r):null,w=yt(f);C===w?c({token:null}):k===w&&s({token:null}),o(f)}m(!1)},"handleDeleteCustomToken");return ye.createElement(se,{header:{title:oo.t("Custom Tokens")}},ye.createElement(ue,null,ye.createElement(dE,null,n.length?ye.createElement(ye.Fragment,null,ye.createElement(At,{id:"widget-custom-tokens-search-token-input",value:t,setValue:e,fullWidth:!0,color:"light",variant:"contained",placeholder:oo.t("Search Token"),onChange:g}),ye.createElement(Mr,{size:16}),ye.createElement(Wr,{list:S,type:"custom-token",searchedFor:t,showTitle:!1,showWarning:!1,action:C=>ye.createElement(fE,{id:"widget-custom-token-delete-icon-btn",variant:"ghost",onClick:()=>{m(!0),h(C)}},ye.createElement(sE,{size:12,color:"gray"}))})):ye.createElement(mE,null,ye.createElement(pE,{icon:d?ye.createElement(iE,{size:200}):ye.createElement(aE,{size:200}),title:oo.t("No custom tokens"),description:oo.t("press the button to add your custom token")})),ye.createElement(Mr,{size:20}),ye.createElement(xc,{id:"widget-custom-token-add-btn",type:"primary",variant:"contained",size:"large",onClick:()=>p(F.addCustomTokens)},oo.t("Add Custom Token"))),ye.createElement(R,{open:u,id:"widget-custom-tokens-delete-modal",dismissible:!0,onClose:()=>m(!1),container:B()},ye.createElement(cE,{title:oo.t("Delete Custom Token"),type:"error",description:oo.t("Are you sure you want to Delete this Token?")},ye.createElement(Mr,{size:40}),ye.createElement(Mr,{size:10}),ye.createElement(xc,{fullWidth:!0,id:"widget-custom-token-delete-modal-yes-btn",variant:"contained",type:"primary",size:"large",onClick:y},oo.t("Yes, Delete it")),ye.createElement(Mr,{size:12}),ye.createElement(xc,{id:"widget-custom-token-delete-modal-no-btn",fullWidth:!0,variant:"outlined",type:"primary",size:"large",onClick:()=>m(!1)},oo.t("No, Continue"))))))}i(uh,"CustomTokensPage");import{i18n as Fe}from"@lingui/core";import{useManager as PE}from"@rango-dev/queue-manager-react";import{Button as Lc,darkTheme as _E,Divider as To,MessageBox as DE,NotFound as $E,styled as Pc,Tabs as FE,Typography as wa}from"@rango-dev/ui";import{TransactionStatus as _r}from"rango-types";import oe,{useMemo as Bh,useState as Dr}from"react";import{useNavigate as OE}from"react-router-dom";import{FilterIcon as kE,Popover as wE}from"@rango-dev/ui";import Ko from"react";import{css as gE,darkTheme as Ta,IconButton as hE,styled as Lr}from"@rango-dev/ui";var Ic=Lr("div",{position:"relative","&::before":{position:"absolute",right:"1px",top:"-1px",width:"$8",height:"$8",borderRadius:"100%",backgroundColor:"$neutral300",[`.${Ta} &`]:{backgroundColor:"$neutral400"},padding:"$2"},variants:{isSelect:{true:{"&::before":{content:""}}}}}),dh=Lr(hE,{width:"$36",height:"$36",position:"relative",padding:"0",overflow:"unset",backgroundColor:"$neutral300",[`.${Ta} &`]:{backgroundColor:"$neutral400"},"&:hover":{backgroundColor:"$secondary100",[`.${Ta} &`]:{backgroundColor:"$neutral"},[`& ${Ic}::before`]:{backgroundColor:"$secondary100",[`.${Ta} &`]:{backgroundColor:"$neutral"}}},variants:{isSelect:{true:{border:"1px solid $secondary"}}}}),mh=Lr("div",{position:"absolute",width:"$6",height:"$6",display:"flex",justifyContent:"center",alignItems:"center",borderRadius:"3px",top:"$0",right:"1px",backgroundColor:"$secondary500"}),fh=Lr("div",{padding:"$15",borderRadius:"$sm",width:"248px",backgroundColor:"$background",zIndex:10}),gh=gE({display:"flex",justifyContent:"space-between",alignItems:"center"}),hh=Lr("ul",{margin:0,listStyle:"none",height:"100%",padding:0,".item-start-container":{paddingRight:"0 !important"}});import{i18n as yh}from"@lingui/core";import{Button as yE,Divider as Sh,ListItemButton as SE,Radio as CE,RadioRoot as TE,Typography as Ch}from"@rango-dev/ui";import dt from"react";function Th(t){let{filterBy:e,onClickItem:o}=t;return dt.createElement(fh,null,dt.createElement("div",{className:gh()},dt.createElement(Ch,{size:"small",variant:"body"},yh.t("Status")),dt.createElement(yE,{id:"widget-filter-selector-reset-btn",variant:"ghost",size:"xxsmall",onClick:()=>o("")},yh.t("Reset"))),dt.createElement(Sh,{size:10}),dt.createElement(TE,{value:e},dt.createElement(hh,null,t.list.map((n,r)=>dt.createElement(SE,{key:n.id,className:"widget-filter-selector-list-item-btn",style:{height:"40px",width:"100%"},selected:!1,hasDivider:t.list.length-1!=r,id:n.id,title:dt.createElement(dt.Fragment,null,dt.createElement(Sh,{direction:"horizontal",size:4}),dt.createElement(Ch,{size:"medium",variant:"body"},n.title)),start:dt.createElement(CE,{value:n.id}),onClick:o})))))}i(Th,"FilterSelectorContent");function Ac(t){let{onClickItem:e,onOpenChange:o,filterBy:n,list:r,open:a}=t;return Ko.createElement("div",null,Ko.createElement(wE,{open:a,align:"end",onOpenChange:o,container:B(),content:Ko.createElement(Th,{list:r,filterBy:n,onClickItem:s=>{e(s),o(!1)}})},Ko.createElement(dh,{id:"widget-filter-selector-filter-icon-btn",variant:"default",isSelect:!!n,onClick:()=>o(!t.open)},Ko.createElement(Ic,{isSelect:!!n},Ko.createElement(kE,{size:16,color:"black"}),!!n&&Ko.createElement(mh,null)))))}i(Ac,"FilterSelector");import{i18n as bE}from"@lingui/core";import{getCurrentStep as EE}from"@rango-dev/queue-manager-rango-preset";import{Divider as bh,GroupedVirtualizedList as IE,Skeleton as AE,SwapListItem as Eh,Typography as NE}from"@rango-dev/ui";import Je,{useCallback as Ih,useEffect as BE,useRef as WE,useState as ME}from"react";function kh(t,e){let o=[],n=0;do{let r=t[n];r&&(o.push(Math.min(r,e)),e-=r),n++}while(e>0&&n<=t.length);return o}i(kh,"calculateGroupsSoFar");import{css as vE,darkTheme as xE,styled as Pr}from"@rango-dev/ui";var Nc=vE(),wh=Pr("div",{display:"flex",justifyContent:"center",alignItems:"center",padding:"$5"}),Bc=Pr("div",{width:"100%",display:"flex",flexDirection:"column",backgroundColor:"$background",padding:"$10 $5 0 $5",[`& .${Nc}`]:{$$color:"$colors$neutral600",[`.${xE} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),Wc=Pr("div",{display:"flex",justifyContent:"flex-start",padding:"$2"}),vh=Pr("div",{gap:"$10",display:"flex",flexDirection:"column"}),xh=Pr("div",{height:"100%",display:"flex",justifyContent:"center",alignItems:"center"});var LE=10;function Mc(t){let{list:e,onSwapClick:o,groupBy:n,isLoading:r}=t,[a,s]=ME([]),c=WE(0),{swaps:l,groupCounts:p,groups:u}=n(e),m=Ih(kh,[]),f=Ih(()=>{let h=e.length-c.current;h&&(c.current+=Math.min(h,LE),s(m(p,c.current)))},[e.length]);if(BE(()=>{r||f()},[r,f]),r){let h=[1,2];return Je.createElement(Je.Fragment,null,[h,h].map((d,S)=>Je.createElement(Bc,{key:S},Je.createElement(Wc,null,Je.createElement(AE,{variant:"text",width:60,size:"small"}),Je.createElement(bh,{size:16})),Je.createElement(bh,{size:4}),Je.createElement(vh,null,d.map((C,k)=>Je.createElement(Eh,{isLoading:!0,key:k}))))))}return Je.createElement(IE,{endReached:()=>{c.current<e.length&&f()},groupCounts:a,groupContent:h=>Je.createElement(Bc,null,Je.createElement(Wc,null,Je.createElement(NE,{variant:"label",size:"medium",className:Nc()},u[h]))),itemContent:(h,g)=>{let d=l[h];if(!d)return null;let S=EE(d),y=d.steps[0],C=d.steps[d.steps.length-1];return!y||!C?null:Je.createElement(wh,{key:d.requestId},Je.createElement(Eh,{className:"widget-history-group-list-swap-item-btn",requestId:d.requestId,creationTime:d.creationTime,status:d.status,onClick:o,currentStep:S,tooltipContainer:B(),onlyShowTime:u[g]===bE.t("Today"),swapTokenData:{from:{token:{image:y.fromLogo,displayName:y.fromSymbol},blockchain:{image:y.fromBlockchainLogo||""},amount:P(d.inputAmount,6,6),realAmount:d.inputAmount},to:{token:{image:C.toLogo,displayName:C.toSymbol},blockchain:{image:C.toBlockchainLogo||""},amount:P(C.outputAmount||C.expectedOutputAmountHumanReadable||"",6,6),realAmount:C.outputAmount||C.expectedOutputAmountHumanReadable||""}}}))}})}i(Mc,"HistoryGroupedList");import{i18n as ka}from"@lingui/core";import Ah from"dayjs";var Nh=i(t=>{let e=new Map([["today",{title:ka.t("Today"),swaps:[]}],["week",{title:ka.t("This week"),swaps:[]}],["month",{title:ka.t("This month"),swaps:[]}],["year",{title:ka.t("This year"),swaps:[]}]]);function o(l,p){e.has(l)||e.set(l,{title:l,swaps:[]}),e.get(l)?.swaps.push(p)}i(o,"addYearsToOutput");let n=Ah();t.forEach(l=>{let p=Number(l.creationTime),u=Ah(p);if(n.isSame(u,"day"))e.get("today")?.swaps.push(l);else if(n.isSame(u,"week"))e.get("week")?.swaps.push(l);else if(n.isSame(u,"month"))e.get("month")?.swaps.push(l);else if(n.isSame(u,"year"))e.get("year")?.swaps.push(l);else{let m=new Date(p).getFullYear().toString();o(m,l)}});let r=Array.from(e.values()).filter(l=>l.swaps.length>0),a=r.flatMap(l=>l.swaps),s=r.map(l=>l.swaps.length),c=r.map(l=>l.title);return{swaps:a,groupCounts:s,groups:c}},"groupSwapsByDate");var UE=Pc("div",{overflowY:"visible",width:"100%",display:"flex",flexDirection:"column",gap:15,height:"100%"}),zE=Pc("div",{display:"flex",justifyContent:"center",alignItems:"center"}),QE=Pc("div",{"._typography":{color:"$neutral700",[`.${_E}&`]:{color:"$neutral900"}}}),HE=i((t,e)=>t?.length?t.filter(o=>Pt(o.fromBlockchain,e)||Pt(o.toBlockchain,e)||Pt(o.toSymbol,e)||Pt(o.fromSymbol,e)).length:!1,"isStepContainsText");function Wh(){let t=OE(),{manager:e,state:o}=PE(),n=Tt(e).map(({swap:b})=>b),[r,a]=Dr(""),[s,c]=Dr(!1),l=!o.loadedFromPersistor,[p,u]=Dr(""),[m,f]=Dr(!1),[h,g]=Dr("all"),d=i(b=>{let E=b.target.value;a(E)},"handleSearch"),{isMultiMode:S}=ot(),y=[{id:_r.SUCCESS,title:Fe.t("Complete")},{id:_r.RUNNING,title:Fe.t("Running")},{id:_r.FAILED,title:Fe.t("Failed")}],C=[{id:"all",title:Fe.t("All")},{id:"swap",title:Fe.t("Swap")},{id:"refuel",title:Fe.t("Refuel")}],k=Bh(()=>!r&&!p&&h==="all"?n:n.filter(b=>{let{inputAmount:E,status:v,steps:N,requestId:W,mode:D}=b;return(!r||Pt(E,r)||Pt(v,r)||HE(N,r)||Pt(W,r))&&(!p||p===v)&&(h==="all"?!0:h==="swap"?!D||D==="swap":h==="refuel"?D==="refuel":!1)}),[n,r,p,h]),w=!k?.length&&!l,x=i(()=>f(!1),"onCloseModal"),I=i(async()=>{try{await e?.clearQueue(),f(!1)}catch(b){console.log(b)}},"onClear"),A=Bh(()=>!n.some(b=>b.status===_r.SUCCESS||b.status===_r.FAILED),[n]);return oe.createElement(se,{header:{title:Fe.t("History"),suffix:oe.createElement(fo,null,oe.createElement(Lc,{id:"widget-history-clear-btn",disabled:A,variant:"ghost",size:"xsmall",onClick:()=>f(!0)},oe.createElement(wa,{size:"medium",variant:"label",color:"error"},Fe.t("Clear"))))}},oe.createElement(ue,null,oe.createElement(zE,null,oe.createElement(At,{setValue:a,fullWidth:!0,variant:"contained",placeholder:Fe.t("Search Transaction"),id:"widget-history-search-transaction-input",autoFocus:!0,onChange:d,style:{height:36},value:r}),oe.createElement(To,{size:10,direction:"horizontal"}),oe.createElement(Ac,{filterBy:p,open:s,onOpenChange:b=>c(b),onClickItem:b=>u(b),list:y})),oe.createElement(To,{size:"16"}),S&&!l&&oe.createElement(oe.Fragment,null,oe.createElement(FE,{items:C,onChange:b=>g(b.id),value:h,type:"secondary"}),oe.createElement(To,{size:"12"})),oe.createElement(UE,null,w&&oe.createElement(xh,null,oe.createElement(To,{size:32}),oe.createElement($E,{title:r?Fe.t("No results found"):Fe.t("No transactions"),titleColor:r?void 0:"$info",hasIcon:!!r,description:r?Fe.t("Try using different keywords"):Fe.t("Your transaction history is stored locally and will appear here after you start a swap")})),!w&&oe.createElement(Mc,{list:k,onSwapClick:t,groupBy:Nh,isLoading:l}))),oe.createElement(R,{open:m,onClose:x,id:"widget-history-clear-modal",container:B()},oe.createElement(To,{size:20}),oe.createElement(DE,{type:"warning",title:Fe.t("Clear Transaction History"),description:oe.createElement(QE,null,oe.createElement(wa,{variant:"body",size:"medium"},Fe.t("Proceeding will remove all successful and failed transactions from the widget. Do you want to continue?")),oe.createElement(To,{size:"24"}),oe.createElement(wa,{variant:"body",size:"small"},Fe.t("Note: This does not erase your transaction history on the chain; it only removes them here.")))}),oe.createElement(To,{size:30}),oe.createElement(Lc,{id:"widget-history-clear-modal-yes-btn",variant:"contained",type:"primary",size:"large",onClick:I},Fe.t("Yes, Clear the history")),oe.createElement(To,{size:10}),oe.createElement(Lc,{id:"widget-history-clear-modal-no-btn",variant:"outlined",type:"primary",size:"large",onClick:x},oe.createElement(wa,{variant:"title",size:"medium",color:"primary"},Fe.t("No, Cancel")))))}i(Wh,"HistoryPage");import{i18n as sy}from"@lingui/core";import{Button as bI,Divider as jc,styled as EI,WarningIcon as II}from"@rango-dev/ui";import AI from"bignumber.js";import Ce,{useEffect as ly,useState as cy}from"react";import{useNavigate as NI}from"react-router-dom";import{i18n as Lh}from"@lingui/core";import{Alert as GE,Divider as _c,NoRouteIcon as VE,Typography as KE}from"@rango-dev/ui";import jo from"react";import{styled as qE}from"@rango-dev/ui";var Mh=qE("div",{display:"flex",flexDirection:"column",alignItems:"center"});function Dc(){let{fromToken:t,toToken:e}=z()();return!!t&&!!e&&qt(t,e)?jo.createElement(Mh,null,jo.createElement(_c,{size:10}),jo.createElement(VE,{size:24,color:"gray"}),jo.createElement(_c,{size:4}),jo.createElement(KE,{variant:"title",size:"small"},Lh.t("No Routes Found")),jo.createElement(_c,{size:4}),jo.createElement(GE,{title:Lh.t("You cannot use the same token for From and To."),type:"warning",variant:"alarm"})):null}i(Dc,"SameTokensWarning");import{Alert as jE,Button as XE}from"@rango-dev/ui";import _h from"react";import{i18n as va}from"@lingui/core";function Ph(t){let e=null;return t===yi?(e={alertType:"error",action:"reset-slippage",actionButtonTitle:va.t("Reset"),title:va.t("Slippage cannot be set lower than 0.01%.")},e):t>an?(e={alertType:"warning",action:"change-settings",actionButtonTitle:va.t("Change"),title:va.t("Caution, your slippage is high!")},e):null}i(Ph,"makeAlerts");function Dh(t){let{slippage:e,customSlippage:o,setSlippage:n,setCustomSlippage:r}=T(),{onChangeSettings:a}=t,c=Ph(o!==null?o:e),l=i(p=>{p==="reset-slippage"?(n(hi),r(null)):p==="change-settings"&&a()},"onClickActionButton");return c?_h.createElement(jE,{title:c.title,type:c.alertType,variant:"alarm",action:_h.createElement(XE,{id:"widget-slippage-warning-error-change-settings-or-reset-slippage-btn",size:"xxsmall",type:c.alertType,onClick:()=>l(c.action)},c.actionButtonTitle)}):null}i(Dh,"SlippageWarningsAndErrors");import{i18n as eI}from"@lingui/core";import{IconButton as tI,ReverseIcon as oI,Skeleton as nI,Tooltip as rI,Typography as $r}from"@rango-dev/ui";import mt from"react";import xa from"bignumber.js";function Fh(t){let{error:e,isDarkTheme:o,warning:n}=t,{quoteError:r,slippageError:a}=e,{quoteWarning:s,slippageWarning:c}=n,l=!!a||r?.type===4,p=!!c||s?.type===2;return l?"$error500":p?"$warning500":o?"$neutral600":"$neutral700"}i(Fh,"getSlippageColor");function Oh(t){let{toTokenUsdPrice:e,fromTokenUsdPrice:o}=t;if(!e||!o)return{rawValue:"0",displayValue:"0"};let n=new xa(e),r=new xa(o),a=n.dividedBy(r),s;return a.isLessThan(1)?s=a.toFixed(14).replace(/\.?0+$/,""):a.toFixed(0).length>10?s=a.toFixed(0).slice(0,10):s=a.toFixed(2),{displayValue:s,rawValue:a.toFixed()}}i(Oh,"getUsdExchangeRate");function Uh(t,e){let o=new xa(t).multipliedBy(e);return o.isLessThan(.001)?"$0":`$${o.decimalPlaces(2,xa.ROUND_DOWN).toFormat(2)}`}i(Uh,"formatTokenValueInUsd");import{darkTheme as JE,styled as Fc,Typography as RE}from"@rango-dev/ui";var zh=Fc("div",{display:"flex",padding:"$4",justifyContent:"space-between",alignItems:"center"}),Qh=Fc("div",{display:"flex",alignItems:"center",gap:"$2","& .rate-text":{color:"$neutral700",[`.${JE} &`]:{color:"$neutral700"}},"& ._icon-button":{transform:"rotate(90deg)",width:"$16",height:"$16"}}),Oc=Fc(RE,{maxWidth:"$32",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"});function Uc(t){let{slippage:e,customSlippage:o,quoteTokensRate:n,changeQuoteTokensRate:r}=T(),{quoteError:a,quoteWarning:s,fromToken:c,toToken:l,quote:p,loading:u}=t,m=o!==null?o:e,{mode:f}=mo({}),h=cn(m),g=f==="dark",d=n==="default",S={quoteError:a,slippageError:h?.type==="error"?h.message:null},y={quoteWarning:s,slippageWarning:h?.type==="warning"?h.message:null},C=p?.swaps[0]?.from||c,k=p?.swaps[p?.swaps.length-1]?.to||l,w=d?C:k,x=d?k:C,I=Number(d?p?.outputAmount:p?.requestAmount),A=Number(d?p?.requestAmount:p?.outputAmount),b=I||w.usdPrice,E=A||x.usdPrice,{rawValue:v,displayValue:N}=Oh({toTokenUsdPrice:E,fromTokenUsdPrice:b});return mt.createElement(zh,null,mt.createElement($r,{variant:S||y?"label":"body",size:S||y?"medium":"small",color:Fh({error:S,warning:y,isDarkTheme:g})},eI.t("Slippage:")," ",m,"%"),u?mt.createElement(nI,{height:16,width:104,variant:"rounded"}):b&&E&&mt.createElement(Qh,null,mt.createElement($r,{className:"rate-text",variant:"body",size:"small"},"1"),mt.createElement(Oc,{className:"rate-text",variant:"body",size:"small"},x.symbol),mt.createElement(tI,{id:"widget-home-page-change-rate-button",onClick:r},mt.createElement(oI,{size:14,color:"secondary"})),mt.createElement(rI,{container:B(),side:"top",sideOffset:4,content:mt.createElement($r,{className:"rate-text",variant:"body",size:"small"},v)},mt.createElement($r,{className:"rate-text",variant:"body",size:"small"},N)),mt.createElement(Oc,{className:"rate-text",variant:"body",size:"small"},w.symbol),w.usdPrice&&mt.createElement($r,{color:"neutral600",variant:"body",size:"small"},"~",Uh(Number(v),w.usdPrice))))}i(Uc,"SwapMetrics");import{i18n as pI}from"@lingui/core";import{Header as uI}from"@rango-dev/ui";import ko,{useEffect as dI,useState as mI}from"react";import{i18n as aI}from"@lingui/core";import{Divider as Qc,FullExpandedQuote as sI,Typography as lI}from"@rango-dev/ui";import ve from"react";import{styled as zc}from"@rango-dev/ui";var Hh=zc("div",{display:"flex",justifyContent:"center",flexDirection:"column",height:"100%"}),qh=zc("div",{display:"flex",justifyContent:"space-between",alignItems:"center"}),Gh=zc("div",{width:"146px"});import{i18n as Fr}from"@lingui/core";import{Select as iI}from"@rango-dev/ui";import Vh from"react";function ba(t){let{updateQuotePartialState:e,sortStrategy:o}=z()(),n=[{value:"SMART",label:Fr.t("Smart Routing")},{value:"FEE",label:Fr.t("Lowest Fee")},{value:"SPEED",label:Fr.t("Fastest Transfer")},{value:"NET_OUTPUT",label:Fr.t("Maximum Return")},{value:"PRICE",label:Fr.t("Maximum Output")}];return Vh.createElement(Gh,null,Vh.createElement(iI,{id:"widget-quotes-strategy-select",container:t.container,options:n,value:o,handleItemClick:r=>{e("sortStrategy",r.value)},variant:"filled"}))}i(ba,"SelectStrategy");var Kh=3;function Or(t){let{loading:e,onClickOnQuote:o,fetch:n,showModalFee:r,hasSort:a=!0,fullExpandedMode:s=!1,container:c}=t,{selectedQuote:l,quotes:p,updateQuotePartialState:u,fromToken:m,toToken:f,sortStrategy:h,error:g}=z()(),{slippage:d,customSlippage:S}=T(),{findToken:y}=T(),C=c||B(),k=!!p&&p.results.length,w=S??d,x=i(b=>{if(!m||!f||!p)return null;let E={requestAmount:p.requestAmount,validationStatus:null,...b};return Sn({currentQuote:E,userSlippage:w,findToken:y})},"getQuoteWarning"),I=g?.type===0||g?.type===1,A=p?.results?Wi(h,p?.results):[];return ve.createElement(ve.Fragment,null,a&&ve.createElement(ve.Fragment,null,ve.createElement(qh,null,ve.createElement(lI,{size:"xmedium",variant:"title"},aI.t("Sort by")),ve.createElement(ba,{container:C})),ve.createElement(Qc,{size:"10"})),e&&Array.from({length:Kh},(b,E)=>ve.createElement(ve.Fragment,{key:E},s?ve.createElement(sI,{loading:!0}):ve.createElement(Er,{tagHidden:!1,type:"list-item",expanded:!1}),E!==Kh-1&&ve.createElement(Qc,{size:16}))),!e&&ve.createElement(ve.Fragment,null,k?A.map((b,E)=>{let v=x(b),N=lc(b.swaps),W=A.length-1===E;return ve.createElement(ve.Fragment,{key:b.requestId},ve.createElement(Go,{id:"widget-quotes-quote-info-container",showModalFee:r,container:C,selected:l?.requestId===b.requestId,tagHidden:!1,quote:{...b,requestAmount:p.requestAmount,validationStatus:null},loading:e,error:N?.options||null,warning:v,fullExpandedMode:s,onClick:D=>{N||u("warning",v),u("error",N?.options||null),o(D)},type:"list-item"}),!W&&ve.createElement(Qc,{size:16}))}):I&&ve.createElement(Hh,null,ve.createElement(Cr,{size:s?"large":"small",error:g,fetch:n}))))}i(Or,"Quotes");import{darkTheme as cI,styled as jh}from"@rango-dev/ui";var Xh=jh("div",{transition:"width 0.2s, opacity 0.2s, margin-left 0.2s",height:"700px",width:"390px",position:"relative",opacity:1,marginLeft:"$16",backgroundColor:"$neutral100",[`.${cI} &`]:{backgroundColor:"$neutral300"},variants:{expandMode:{default:{width:"390px"},full:{width:"719px"}}},"&.is-hidden":{width:0,height:0,opacity:0,marginLeft:0}}),Yh=jh("div",{position:"relative",overflow:"hidden",padding:"$20",flexGrow:1,display:"flex",flexDirection:"column",overflowY:"auto",borderRadius:"$primary",backgroundColor:"$background"});var fI=100;function Hc(t){let{fetch:e,loading:o,onClickOnQuote:n,onClickRefresh:r,isVisible:a}=t,[s,c]=mI(!1),l=s?"":"is-hidden",{config:p}=T(),u=p?.variant==="full-expanded",m=Wo();return dI(()=>{let f=null;return a?f=setTimeout(()=>{c(!0)},fI):(c(!1),f&&clearTimeout(f)),()=>{f&&clearTimeout(f)}},[a]),ko.createElement(Xh,{expandMode:p?.variant==="full-expanded"?"full":"default",className:`${l} ${qi()} widget-expanded-quotes-container`,id:et.EXPANDED_BOX_ID},ko.createElement(uI,{title:pI.t("Routes"),suffix:ko.createElement(ko.Fragment,null,ko.createElement(ba,{container:m}),ko.createElement(zo,{container:m,onClickRefresh:r,hidden:["history","notifications","settings"]}))}),ko.createElement(Yh,null,ko.createElement(Or,{showModalFee:!0,fetch:e,hasSort:!1,loading:o,container:Wo(),onClickOnQuote:n,fullExpandedMode:u})))}i(Hc,"ExpandedQuotes");import{i18n as ny}from"@lingui/core";import{SwapInput as ry}from"@rango-dev/ui";import SI from"bignumber.js";import Ur from"react";import{ReverseIcon as yI}from"@rango-dev/ui";import Gc from"react";import{keyframes as gI,styled as Zh}from"@rango-dev/ui";var qc=450,hI=gI({"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)"}}),Jh=Zh("div",{position:"absolute",bottom:"-12px",left:"50%",transform:"translate(-50%, 10%)",cursor:"pointer"}),Rh=Zh("div",{borderRadius:"$md",border:"3px solid $background",background:"$neutral100",width:"$24",height:"$24",display:"flex",justifyContent:"center",alignItems:"center",color:"$foreground","&.rotate":{"& svg":{animation:`${hI} ${qc}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 Vc(){let t=z().use.switchFromAndTo();return Gc.createElement(Jh,null,Gc.createElement(Rh,{id:"widget-switch-from-and-to-btn",onClick:e=>{let o=e.currentTarget;o.classList.add("rotate"),setTimeout(()=>{o.classList.remove("rotate")},qc),t()}},Gc.createElement(yI,{size:12})))}i(Vc,"SwitchFromAndToButton");import{styled as ey}from"@rango-dev/ui";var ty=ey("div",{display:"flex",flexDirection:"column",gap:"$5",alignSelf:"stretch"}),oy=ey("div",{position:"relative"});function Kc(t){let{fetchingQuote:e,fetchMetaStatus:o,onClickToken:n,isExpandable:r}=t,{fromToken:a,fromBlockchain:s,toToken:c,toBlockchain:l,setInputAmount:p,sanitizeInputAmount:u,inputAmount:m,inputUsdValue:f,outputAmount:h,outputUsdValue:g,selectedQuote:d}=z()(),{swapMode:S}=ot(),{connectedWallets:y,getBalanceFor:C}=T(),k=a?C(a):null,w=mi(k)?.amount??"0",x=k?new SI(k.amount).shiftedBy(-k.decimals):de,I=!!s&&Au(y,s.name),A=!Vs(d,m,f),b=!Vs(d,m,g),E=!f||!g||!g.gt(0)?null:jt(f.toString(),g.toString());return Ur.createElement(ty,null,Ur.createElement(oy,null,Ur.createElement(ry,{label:ny.t("From"),id:"widget-swap-from",mode:"From",onInputChange:p,onInputBlur:u,balance:w,chain:{displayName:s?.displayName||"",image:s?.logo},token:{displayName:a?.symbol||"",image:a?.image,securityWarning:!!a?.warning},onClickToken:()=>n("from"),price:{value:m,usdValue:A?void 0:P(f,4,4),realUsdValue:A?void 0:f?.toString(),error:A?ie().unknownPriceError.impactTitle:void 0},disabled:o==="failed",loading:o==="loading",loadingBalance:I,tooltipContainer:B(),onSelectMaxBalance:()=>{let v=P(x,k?.decimals),N=k?.amount?v.split(",").join(""):"";p(N)},anyWalletConnected:y.length>0}),S==="swap"&&Ur.createElement(Vc,null)),Ur.createElement(ry,{selectionType:S==="swap"?"token":"chain",sharpBottomStyle:!r&&(!!d||e),label:ny.t("To"),mode:"To",id:"widget-swap-to-input",fetchingQuote:e,chain:{displayName:l?.displayName||"",image:l?.logo},token:{displayName:c?.symbol||"",image:c?.image,securityWarning:!!c?.warning},percentageChange:P(jt(f,g),2,2),warningLevel:Xt(E??0),price:{value:P(h,6,6),usdValue:b?void 0:P(g,4,4),realValue:h?.toString(),realUsdValue:b?void 0:g?.toString(),error:b?ie().unknownPriceError.impactTitle:void 0},onClickToken:()=>n("to"),disabled:o==="failed",loading:o==="loading",tooltipContainer:B()}))}i(Kc,"Inputs");import{warn as CI}from"@rango-dev/logging-core";import{useCallback as TI,useEffect as kI,useRef as wI,useState as vI}from"react";function iy(){let{fetch:t,loading:e,cancelFetch:o}=ga({request:async(n,r)=>await ct().getAllRoutes(n,r)});return{fetch:t,loading:e,cancelFetch:o}}i(iy,"useFetchAllQuotes");var xI=600;function Ea({refetchQuote:t}){let{fetch:e,cancelFetch:o}=iy(),{excludeLiquiditySources:n,routing:r}=T().config,{connectedWallets:a}=T(),c=a.some(ne=>ne.isContractWallet),{fromToken:l,toToken:p,inputAmount:u,inputUsdValue:m,selectedQuote:f,sortStrategy:h,resetQuote:g,error:d,warning:S,setSelectedQuote:y,updateQuotePartialState:C}=z()(),{slippage:k,customSlippage:w,affiliatePercent:x,affiliateRef:I,affiliateWallets:A,fetchStatus:b}=T(),E=T().getLiquiditySources(),v=T().getDisabledLiquiditySources(),N=T().excludeLiquiditySources(),{findToken:W}=T(),{swapMode:D}=ot(),[H,X]=vI(!0),Y=wI(u),M=w??k,J=!l||!p||qt(l,p)||!Vn(u),te=i(ne=>{X(ne)},"resetState"),ce=i(ne=>{let{fromToken:wt,toToken:gt,inputAmount:Wt,liquiditySources:$,excludeLiquiditySources:U,disabledLiquiditySources:G,slippage:pe,affiliateRef:Q,affiliatePercent:j,affiliateWallets:K}=ne;if(H||te(!0),!J&&wt&>){g();let Ie=Vd({fromToken:wt,toToken:gt,inputAmount:Wt,liquiditySources:$,excludeLiquiditySources:U,disabledLiquiditySources:G,wallets:a,slippage:pe,affiliateRef:Q,affiliatePercent:j,affiliateWallets:K,contractCall:c});ln("experimental",r)&&(Ie.experimental=!0),ln("avoidNativeFee",r)&&(Ie.avoidNativeFee=!0),ln("enableCentralizedSwappers",r)&&(Ie.enableCentralizedSwappers=!0),r?.maxLength&&(Ie.maxLength=r.maxLength),D==="refuel"&&(Ie.maxLength=1),e(Ie).then(Ae=>{let je=Wi(h,Ae.results),Mt=Pd(f,je,Ae.requestAmount);X(!1),C("quotes",Ae),y(Mt),ha({diagnosisMessages:Ae.diagnosisMessages,requestId:Mt?.requestId||"",swaps:Mt?.swaps});let so=Mt&&Sn({currentQuote:Mt,userSlippage:M,findToken:W});C("warning",so)}).catch(Ae=>{let je=ya(Ae);(je.type===0||je.type===1)&&g(),je.type!==2&&(C("error",je),X(!1),CI(new Error("quote error"),{tags:{...je,type:Ze[je.type],requestBody:Ie}}))})}},"fetch"),Oe=TI(ai(ne=>{ce(ne)},xI),[J]);return kI(()=>{if(!t){X(!1);return}if(b!=="success")return;if(J){X(!1),(f||d||S)&&g();return}if(!Vn(u)&&m?.eq(0)){te(!1),o();return}g(),te(!0);let ne=ce;return Y.current&&Y.current!=u&&(ne=Oe),Y.current=u,ne({inputAmount:u,fromToken:l,toToken:p,liquiditySources:E,excludeLiquiditySources:N,disabledLiquiditySources:v,slippage:M,affiliateRef:I,affiliatePercent:x,affiliateWallets:A,contractCall:c}),o},[b,u,l?.symbol,l?.address,l?.blockchain,p?.symbol,p?.address,p?.blockchain,J,E?.length,n,v.length,M,I,x,c,JSON.stringify(A)]),{fetch:()=>ce({inputAmount:u,fromToken:l,toToken:p,liquiditySources:E,excludeLiquiditySources:N,disabledLiquiditySources:v,slippage:M,affiliateRef:I,affiliatePercent:x,affiliateWallets:A,contractCall:c}),loading:H}}i(Ea,"useSwapInput");function ay(t,e){let o=!1,n={preventDefault(){o=!0},...t.payload===void 0&&{payload:t.payload}};we.emit("uiEvent",{type:t.type,payload:n}),o||e()}i(ay,"emitPreventableEvent");var BI=EI("div",{display:"flex",alignItems:"flex-start",maxHeight:700,"& .footer__alert":{paddingTop:"0 !important"}}),WI=300;function py(){let t=NI(),{fromToken:e,toToken:o,inputAmount:n,selectedQuote:r,refetchQuote:a,error:s,warning:c,quotes:l,setSelectedQuote:p,resetQuoteWallets:u,setQuoteWarningsConfirmed:m,updateQuotePartialState:f}=z()(),[h,g]=cy(!1),{isLargeScreen:d,isExtraLargeScreen:S}=kn(),{fetch:y,loading:C}=Ea({refetchQuote:a}),{config:k,fetchStatus:w,connectedWallets:x,customSlippage:I,slippage:A,setSlippage:b,setCustomSlippage:E}=T(),{isActiveTab:v}=re(),[N,W]=cy(!1),D=I!==null?I:A,{swapMode:H}=ot(),X=cn(D),M=Qd({fetchMetaStatus:w,fetchingQuote:C,inputAmount:n,quote:r,anyWalletConnected:x.length>0,error:s,warning:c,needsToWarnEthOnPath:!1}),ee=_u(d,S,k?.variant),J=!!n&&!!e&&!!o&&new AI(n).gt(0)&&!Rd(e,o),te=J&&w==="success"&&C,ce=X?.quoteValidation||c,wt=(!ee||ee&&l?.results.length)&&(ce||s),gt=!!e&&!!o,Wt=gt&&!!X,$=(r||s)&&!N?y:void 0,U=i(j=>{ee&&h?(g(!1),setTimeout(()=>{t(j)},WI)):t(j)},"onHandleNavigation"),G=i(j=>{r?.requestId!==j.requestId&&(W(!1),p(j))},"onClickOnQuote"),pe=i(j=>{if(j){if(gi.includes(j)){b(j),E(null);return}E(j)}},"onChangeSlippage"),Q=i(j=>{U(j==="from"?F.fromSwap:H==="swap"?F.toSwap:F.toSwap+"/"+F.blockchains)},"handleInputTokenClick");return ly(()=>{u(),f("refetchQuote",!0)},[]),ly(()=>{g(J)},[J]),Ce.createElement(BI,null,Ce.createElement(se,{height:"auto",footer:Ce.createElement(bI,{id:`widget-swap-${M.action}-btn`,type:"primary",size:"large",disabled:M.disabled||!v,prefix:M.action==="confirm-warning"&&Ce.createElement(II,null),fullWidth:!0,onClick:()=>{M.action==="connect-wallet"?ay({type:"clickConnectWallet"},()=>U(F.wallets)):M.action==="confirm-warning"?W(!0):U(F.confirmSwap)}},M.title),header:{onWallet:()=>{U(F.wallets)},hasBackButton:!1,title:k.title||(H==="swap"?sy.t("Swap"):sy.t("Refuel")),suffix:Ce.createElement(zo,{hidden:ee?["refresh"]:void 0,onClickRefresh:$,onClickHistory:()=>U(F.swaps),onClickSettings:()=>{U(F.settings)}})}},Ce.createElement(ue,null,Ce.createElement(Kc,{fetchingQuote:te,fetchMetaStatus:w,isExpandable:ee,onClickToken:Q}),Ce.createElement(jc,{size:"2"}),ee?null:Ce.createElement(Go,{quote:r,loading:te,error:s,id:"widget-home-expandable-quote-container",tagHidden:!1,warning:ce,type:"basic",onClickAllRoutes:l&&l.results.length>1?()=>{f("refetchQuote",!1),U(F.routes)}:void 0}),gt&&Ce.createElement(Ce.Fragment,null,Ce.createElement(jc,{size:8}),Ce.createElement(Uc,{quoteError:s,quoteWarning:ce,fromToken:e,toToken:o,quote:r,loading:te})),wt?Ce.createElement(Ce.Fragment,null,Ce.createElement(kr,{warning:ce,error:s,skipAlerts:!!X,couldChangeSettings:!0,refetchQuote:y,showWarningModal:N,confirmationDisabled:!v,onOpenWarningModal:()=>W(!0),onCloseWarningModal:()=>W(!1),onChangeSlippage:pe,onConfirmWarningModal:()=>{W(!1),m(!0),U(F.confirmSwap)},onChangeSettings:()=>U(F.settings)})):null,Wt&&Ce.createElement(Ce.Fragment,null,Ce.createElement(jc,{size:"10"}),Ce.createElement(Dh,{onChangeSettings:()=>U(F.settings)})),Ce.createElement(Dc,null))),ee?Ce.createElement(Hc,{loading:te,onClickOnQuote:G,fetch:y,onClickRefresh:$,isVisible:h}):null)}i(py,"Home");import{i18n as uy}from"@lingui/core";import{Alert as MI,Divider as LI,List as PI,ListItemButton as _I,Radio as DI,RadioRoot as $I,Typography as FI}from"@rango-dev/ui";import Ot from"react";function wo(){let{setLanguage:t,language:e,config:o}=T(),n=Qu,r=o?.language||pn;return{activeLanguage:e||r,languages:n,defaultLanguage:r,changeLanguage:a=>t(a||pn),resetLanguage:()=>t(null)}}i(wo,"useLanguage");function dy(){let{activeLanguage:t,changeLanguage:e,languages:o}=wo(),n=Ge(),r=o.map(a=>{let{local:s,label:c,SVGFlag:l}=a;return{id:`widget-setting-languages-${s}-item-btn`,value:s,title:Ot.createElement(FI,{variant:"title",size:"xmedium"},c),onClick:()=>{e(a.local),n()},end:Ot.createElement(DI,{value:s}),start:Ot.createElement(l,null)}});return Ot.createElement(se,{header:{title:uy.t("Language")}},Ot.createElement(ue,null,Ot.createElement(MI,{type:"warning",id:"widget-language-machine-translation-alarm-alert",variant:"alarm",title:"Warning: We are using machine translation, so the translations may be inaccurate."}),Ot.createElement(LI,{size:"8"}),Ot.createElement($I,{value:t},Ot.createElement(PI,{type:Ot.createElement(_I,{title:uy.t("language"),className:"widget-language-list-item-btn",id:"_",onClick:()=>console.log()}),items:r}))))}i(dy,"LanguagePage");import{i18n as no}from"@lingui/core";import{Button as HI,Checkbox as qI,Image as GI,ListItemButton as VI,NotFound as KI,Typography as jI}from"@rango-dev/ui";import Re,{useState as XI}from"react";import{Checkbox as zI,Skeleton as fy}from"@rango-dev/ui";import Qr from"react";import{styled as Xc}from"@rango-dev/ui";var zr=Xc("ul",{padding:"$15 $5 0",margin:0,listStyle:"none",height:"100%",overflowY:"auto",variants:{disabled:{true:{pointerEvents:"none"}}}}),Yc=Xc("div",{width:80,display:"flex",justifyContent:"flex-end"}),Zc=Xc("div",{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%"});import{ListItem as OI,styled as UI}from"@rango-dev/ui";var my=UI(OI,{height:61});var QI=30;function Jc(){return Qr.createElement(zr,null,Array.from(Array(QI),(t,e)=>Qr.createElement(my,{hasDivider:!0,key:e,start:Qr.createElement(fy,{variant:"circular",width:35,height:35}),title:Qr.createElement(fy,{variant:"text",size:"large",width:90}),end:Qr.createElement(zI,{checked:!1})})))}i(Jc,"LoadingLiquiditySourceList");function Rc({sourceType:t}){let e=T().fetchStatus,o=T().swappers(),n=T().getDisabledLiquiditySources(),[r,a]=XI(""),s=T().toggleLiquiditySource,c=T().isInCampaignMode(),l=Si(o,n),p={Exchanges:no.t("Exchanges"),Bridges:no.t("Bridges")},u=[];t==="Exchanges"&&u.push("DEX"),t==="Bridges"&&u.push("BRIDGE","AGGREGATOR","OFF_CHAIN");let m=l.filter(y=>u.includes(y.type)),f=m.length===m.filter(y=>y.selected).length,h=i(()=>{m.forEach(y=>{f?s(y.groupTitle):y.selected||s(y.groupTitle)})},"toggleAllSources"),g=m.map(y=>{let{selected:C,groupTitle:k,logo:w,id:x,...I}=y;return{id:`widget-setting-liquidity-source-${hu(x.toLowerCase())}-item-btn`,start:Re.createElement(GI,{src:w,size:22,type:"circular"}),onClick:()=>{c||s(k)},end:Re.createElement(qI,{checked:C,disabled:c}),title:Re.createElement(jI,{variant:"title",size:"xmedium"},no.t(k)),selected:C,groupTitle:k,logo:w,...I}}),d=i(y=>{let C=y.target.value;a(C)},"handleSearch"),S=g;return r&&(S=g.filter(y=>Pt(y.groupTitle,r))),Re.createElement(se,{header:{title:no.t(t),suffix:Re.createElement(Yc,null,Re.createElement(HI,{id:`widget-liquidity-source-${f?"deselect-all":"select-all"}-btn`,variant:"ghost",size:"xsmall",onClick:h},f?no.t("Deselect all"):no.t("Select all")))}},Re.createElement(ue,{view:!0},Re.createElement(At,{value:r,setValue:a,id:"widget-liquidity-source-search-input",fullWidth:!0,color:"light",variant:"contained",placeholder:no.t("Search {sourceType}",{sourceType:p[t]}),onChange:d}),e==="loading"&&Re.createElement(Jc,null),!S.length&&r?Re.createElement(Zc,null,Re.createElement(KI,{title:no.t("No results found"),description:no.t("Try using different keywords")})):e==="success"&&Re.createElement(zr,{disabled:c,className:"widget-liquidity-source-list"},S.map(y=>{let{groupTitle:C,...k}=y;return Re.createElement(Re.Fragment,{key:y.id},Re.createElement(VI,{style:{height:"61px"},...k,selected:!1,className:"widget-liquidity-source-list-item-btn",hasDivider:!0}))}))))}i(Rc,"LiquiditySourcePage");import{i18n as YI}from"@lingui/core";import Ia from"react";import{useNavigate as ZI}from"react-router-dom";function gy(){let t=ZI(),e=Ge(),{selectedQuote:o,refetchQuote:n,setSelectedQuote:r,updateQuotePartialState:a,error:s}=z()(),{fetch:c,loading:l}=Ea({refetchQuote:n}),p=i(f=>{r(f),a("refetchQuote",!1),e()},"onClickOnQuote"),u=`../${F.settings}`,m=`../${F.wallets}`;return Ia.createElement(se,{header:{onWallet:()=>{t(m),a("refetchQuote",!0)},onBack:()=>{a("refetchQuote",!1)},title:YI.t("Routes"),suffix:Ia.createElement(zo,{onClickRefresh:o||s?c:void 0,hidden:["notifications","history"],onClickSettings:()=>{t(u),a("refetchQuote",!0)}})}},Ia.createElement(ue,null,Ia.createElement(Or,{fetch:c,loading:l,onClickOnQuote:p})))}i(gy,"RoutesPage");import{i18n as wy}from"@lingui/core";import{Divider as vy,getCategoriesCount as sA,SelectableCategoryList as lA}from"@rango-dev/ui";import ro,{useState as xy}from"react";import{useNavigate as cA}from"react-router-dom";import{i18n as ep}from"@lingui/core";import{Divider as tA,Image as oA,ListItemButton as nA,NotFound as rA,Typography as ky}from"@rango-dev/ui";import ft,{useEffect as iA,useState as aA}from"react";var hy=i((t,e,o)=>t.filter(n=>si(n.type,o)).filter(n=>st(n.name,e)||st(n.displayName,e)),"filterBlockchains");import{ImageContainer as JI,styled as yy}from"@rango-dev/ui";var Sy=yy("div",{display:"flex",flexDirection:"column",overflow:"hidden",height:"100%",justifyContent:"center"}),Aa=yy(Il,{padding:0,margin:0,listStyle:"none",[`& ${JI}`]:{borderRadius:"$xm",overflow:"hidden"}});import{ListItem as RI,Skeleton as Cy}from"@rango-dev/ui";import Na from"react";var eA=20;function Ty(){return Na.createElement(Aa,{id:"widget-blockchain-loading-list",as:"ul"},Array.from(Array(eA),t=>Na.createElement(RI,{key:t,hasDivider:!0,start:Na.createElement(Cy,{variant:"circular",width:35,height:35}),title:Na.createElement(Cy,{variant:"text",size:"large",width:90})})))}i(Ty,"LoadingBlockchainList");function tp(t){let{list:e,searchedFor:o,onChange:n,blockchainCategory:r,showTitle:a=!0}=t,[s,c]=aA(e),{fetchStatus:l}=T();iA(()=>{c([...hy(e,o,r)])},[e,o,r]);let p=i(()=>!s.length&&o?ft.createElement(rA,{title:ep.t("No results found"),description:ep.t("Try using different keywords")}):ft.createElement(Aa,{as:"ul",key:`${r}-${o}`,id:"widget-blockchain-list"},s.map(u=>ft.createElement(nA,{key:`${u.name}-${u.chainId}`,className:"widget-blockchain-list-item-btn",hasDivider:!0,onClick:()=>n(u),start:ft.createElement(oA,{src:u.logo,size:30}),title:ft.createElement(ky,{variant:"title",size:"medium"},u.displayName),id:u.name}))),"renderList");return ft.createElement(ft.Fragment,null,a&&ft.createElement(ft.Fragment,null,ft.createElement(ky,{variant:"label",size:"large"},ep.t("Select Chain")),ft.createElement(tA,{size:4})),ft.createElement(Sy,null,l==="loading"&&ft.createElement(Ty,null),l==="success"&&p()))}i(tp,"BlockchainList");function Ba(t){let{type:e}=t,o=Ge(),[n,r]=xy(""),[a,s]=xy("ALL"),c=z().use.setToBlockchain(),l=z().use.setFromBlockchain(),p=z().use.setToToken(),{fetchStatus:u,findNativeToken:m}=T(),f=cA(),{swapMode:h}=ot(),g=T().blockchains({type:e}),d=sA(g),S=!t.hideCategory&&d!==1,y=i(C=>{if(e==="custom-token")f(`..?blockchain=${C.name}`,{replace:!0});else{if(e==="source")l(C);else if(h==="swap")c(C);else{let k=m(C);k&&p({token:k,meta:{blockchains:g}})}o()}},"handleBlockchainChange");return ro.createElement(se,{header:{title:wy.t("Select Chain")}},ro.createElement(ue,{view:!0},S&&ro.createElement(ro.Fragment,null,ro.createElement(lA,{setCategory:s,category:a,blockchains:g,isLoading:u==="loading"}),ro.createElement(vy,{size:24})),ro.createElement(At,{value:n,autoFocus:!0,placeholder:wy.t("Search Chain"),id:"widget-select-blockchain-search-input",color:"light",variant:"contained",size:"large",setValue:()=>r(""),onChange:C=>r(C.target.value)}),ro.createElement(vy,{size:16}),ro.createElement(tp,{list:g,showTitle:e!=="custom-token",searchedFor:n,blockchainCategory:a,onChange:y})))}i(Ba,"SelectBlockchainPage");import{i18n as La}from"@lingui/core";import{Divider as Wy,Spinner as xA}from"@rango-dev/ui";import vo,{useEffect as bA,useState as EA}from"react";import{useNavigate as IA}from"react-router-dom";import{i18n as rp}from"@lingui/core";import{BlockchainsChip as Wa,Divider as Ay,Image as Ny,Skeleton as gA,Tooltip as hA,Typography as ip}from"@rango-dev/ui";import xe from"react";import{useEffect as dA}from"react";var by=["ETH","COSMOS","OSMOSIS"];function op(t,e,o){let n=JSON.parse(JSON.stringify(t)),r=[];if(n.sort(pA),o?.limit&&t.length>o.limit){let a=o.limit,s=e;if(e.length<=o.limit){let c=o.limit-e.length;for(let l=0;l<=c;l++){let p=n[l];s=s.filter(u=>p?.name!==u)}}n.sort(uA(s)),r=n.splice(a)}return{list:n,more:r}}i(op,"prepare");function pA(t,e){let o=by,n=o.findIndex(c=>c===t.name),r=o.findIndex(c=>c===e.name),a=n>-1,s=r>-1;return a&&s?n>r?1:-1:a?-1:s?1:0}i(pA,"sortByMostUsedBlockchains");function uA(t){return i(function(o,n){let r=t.findIndex(l=>l===o.name),a=t.findIndex(l=>l===n.name),s=r>-1,c=a>-1;return s&&c?r>a?1:-1:t.includes(o.name)?-1:t.includes(n.name)?1:0},"sortByPreferred")}i(uA,"generateSortByPreferredBlockchainsFor");function Ey(t,e){return!!e.list.find(o=>o.name===t)}i(Ey,"isInVisibleList");function np(t,e){let{preferredBlockchains:o,addPreferredBlockchain:n}=T();dA(()=>{if(e?.selected){let a=op(t,o,e);Ey(e.selected,a)||n(e?.selected)}},[e?.selected]);let r=op(t,o,e);return{list:r.list,more:r.more,history:[]}}i(np,"usePrepareBlockchainList");import{styled as mA}from"@rango-dev/ui";var Iy=mA("div",{display:"grid",gap:"$10",gridTemplateColumns:"repeat(6, minmax(0, 1fr))"});var yA=6,SA=12;function ap(t){let{blockchains:e,type:o,blockchain:n,onChange:r,onMoreClick:a}=t,{showCompactTokenSelector:s}=re(),c=np(e,{limit:s?4:10,selected:n?.name}),{fetchStatus:l}=T(),p=z().use.resetToBlockchain(),u=z().use.resetFromBlockchain(),m=c.more.length>0,f=c.more[0],h=c.more.length===1&&f,g=!h&&m;return xe.createElement(xe.Fragment,null,!s&&xe.createElement(xe.Fragment,null,xe.createElement(Ay,{size:12}),xe.createElement(ip,{variant:"label",size:"large"},rp.t("Select Chain"))),xe.createElement(Ay,{size:12}),xe.createElement(Iy,{id:"widget-blockchains-section-container"},l==="loading"&&Array.from(Array(s?yA:SA),(d,S)=>xe.createElement(gA,{key:S,variant:"rounded",height:50})),l==="success"&&xe.createElement(xe.Fragment,null,xe.createElement(Wa,{className:"widget-blockchains-section-all-btn",selected:!n,onClick:()=>{o==="from"?u():p()}},xe.createElement(ip,{variant:"body",size:"xsmall",color:"secondary500"},rp.t("All"))),c.list.map(d=>xe.createElement(hA,{key:d.name,content:d.shortName,side:"bottom",sideOffset:2,container:B()},xe.createElement(Wa,{className:"widget-blockchains-section-item-btn",key:d.name,selected:!!n&&n.name===d.name,onClick:()=>r(d)},xe.createElement(Ny,{src:d.logo,size:30})))),h?xe.createElement(Wa,{className:"widget-blockchains-section-only-item-btn",key:f.name,selected:!!n&&n.name===f.name,onClick:()=>r(f)},xe.createElement(Ny,{src:f.logo,size:30})):null,g?xe.createElement(Wa,{onClick:a,key:"more-blockchains",className:"widget-blockchains-section-more-items-btn"},xe.createElement(ip,{variant:"body",size:"xsmall",color:"secondary500"},rp._("More +{count}",{count:c.more.length}))):null)))}i(ap,"BlockchainsSection");import{useCallback as TA,useRef as kA,useState as sp}from"react";function lp(){let t=T().blockchains(),e=kA(null),{customTokens:o}=T(),[n,r]=sp(!1),[a,s]=sp([]),[c,l]=sp(null),p=i(async(f,h)=>{l(null),r(!0),s([]);try{let g=await ct().searchCustomTokens({query:f,blockchain:h},{signal:e.current?.signal}),d=new Set(o().map(C=>Vt(C))),S=new Set(t.map(C=>C.name)),y=g.tokens.filter(C=>S.has(C.blockchain)&&!d.has(Vt(C)));s(y),r(!1)}catch(g){l(g instanceof Error?g.message:"something went wrong"),s([]),g?.name!=="CanceledError"&&r(!1)}},"fetch"),u=TA(ai((f,h)=>{e.current?.signal.aborted||p(f,h)},600),[t.length]);return{fetch:(f,h)=>{e.current=new AbortController,s([]),r(!0),u(f,h)},cancel:i(()=>{e.current?.abort()},"cancel"),loading:n,tokens:a,error:c}}i(lp,"useSearchCustomTokens");function Ma(t,e,o){return o&&t.length===1&&t[0]?.address===e?!1:t.length<20&&e.trim().length>=3}i(Ma,"shouldSearchForCustomTokens");function By(t,e,o,n,r){let a=[...t];return Ma(t,o,r)&&(a=n?[...a,"skeleton","skeleton","skeleton"]:[...a,...e.map(s=>({...s,customToken:!0,warning:!0}))]),a}i(By,"prepareTokensList");function Pa(t){let{type:e}=t,o=IA(),n=Ge(),{fromBlockchain:r,toBlockchain:a,setFromToken:s,setToToken:c,setFromBlockchain:l,setToBlockchain:p}=z()(),{getBalanceFor:u}=T(),{fetch:m,loading:f,tokens:h,cancel:g}=lp(),[d,S]=EA(""),y=e==="source"?r:a,C=y?.name??"",k=T().blockchains({type:e}),w=T().tokens({type:e,blockchain:C,searchFor:d,getBalanceFor:u}),x=By(w,h,d,f,y?.name),I=i(E=>{e==="source"?l(E):p(E)},"updateBlockchain"),A=i(E=>{e==="source"?s({token:E,meta:{blockchains:k}}):c({token:E,meta:{blockchains:k}})},"updateToken"),b={source:La.t("Source"),destination:La.t("Destination")};return bA(()=>(Ma(w,d,y?.name)&&m(d,y?.name??void 0),()=>{g()}),[w.length,d,y?.name]),vo.createElement(se,{header:{title:La.t("Swap {type}",{type:b[e]})}},vo.createElement(ue,null,vo.createElement(ap,{blockchains:k,type:e=="source"?"from":"to",blockchain:e==="source"?r:a,onMoreClick:()=>o(F.blockchains),onChange:E=>{I(E)}}),vo.createElement(Wy,{size:24}),vo.createElement(At,{value:d,id:"widget-select-swap-item-search-input",autoFocus:!0,placeholder:La.t("Search Token"),color:"light",variant:"contained",size:"large",setValue:()=>S(""),onChange:E=>S(E.target.value),suffix:Ma(w,d,y?.name)&&f?vo.createElement(xA,{size:12,color:"secondary"}):void 0}),vo.createElement(Wy,{size:16}),vo.createElement(Wr,{list:x,selectedBlockchain:C,searchedFor:d,type:e,onChange:E=>{A(E);let v=k.find(N=>E.blockchain===N.name);v&&I(v),n()}})))}i(Pa,"SelectSwapItemsPage");import{i18n as dp}from"@lingui/core";import{Alert as eN,Button as tN,styled as oN}from"@rango-dev/ui";import Xo from"react";import{useInRouterContext as nN,useSearchParams as rN}from"react-router-dom";import{i18n as $y}from"@lingui/core";import{Alert as WA,Divider as pp,InfoIcon as MA,SlippageIcon as LA,TextField as PA,Tooltip as _A,Typography as Fy}from"@rango-dev/ui";import ze from"react";import{Chip as AA,styled as Hr,TextField as NA}from"@rango-dev/ui";var My=Hr("div",{paddingTop:"$5",padding:"$10 $5"}),Ly=Hr("div",{display:"flex",flexWrap:"wrap",gap:"$10",[`& ${NA}`]:{flex:"1 1 0",maxWidth:"127px",minWidth:"85px",paddingLeft:"$2"}}),Py=Hr("div",{display:"flex",justifyContent:"start",alignItems:"center",paddingBottom:"$10"}),_a=Hr("div",{maxWidth:"280px",padding:"$10"}),_y=Hr(AA,{width:"61px",flexShrink:0});import{i18n as cp}from"@lingui/core";import{Typography as BA}from"@rango-dev/ui";import qr from"react";function Dy(){return qr.createElement(_a,null,qr.createElement(BA,{variant:"label",size:"medium",color:"neutral700"},cp.t("Your transaction will be reverted if the price changes unfavorably by more than this percentage."),qr.createElement("br",null),qr.createElement("br",null),qr.createElement("b",null,cp.t("Warning")),":\xA0",cp.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(Dy,"SlippageTooltipContent");function up(){let{slippage:t,setSlippage:e,customSlippage:o,setCustomSlippage:n}=T(),r=o!==null?cn(o):null,a=i(l=>{let p=l.target.value,u=parseFloat(p);if(isNaN(u))return n(null);let m=u;u>Yn&&(m=Yn),n(m)},"onSlippageValueChange"),s=i(l=>{o!==null&&n(null),e(l)},"onClickSlippageChip"),c=i(l=>{let p=l.target,u=p.value;Su(u)||(p.value=u.slice(0,-1))},"onInput");return ze.createElement(My,null,ze.createElement(Py,null,ze.createElement(LA,{size:16,color:"gray"}),ze.createElement(pp,{direction:"horizontal",size:4}),ze.createElement(Fy,{variant:"title",size:"xmedium"},$y.t("Slippage tolerance per swap")),ze.createElement(pp,{direction:"horizontal",size:4}),ze.createElement(_A,{container:B(),side:"top",sideOffset:4,content:ze.createElement(Dy,null)},ze.createElement(MA,{color:"gray"}))),ze.createElement(Ly,null,gi.map((l,p)=>{let u=`slippage-${p}`;return ze.createElement(_y,{id:`widget-slippage-chip-${l.toString()}%-btn`,key:u,onClick:()=>s(l),selected:o===null&&l===t,label:`${l.toString()}%`})}),ze.createElement(PA,{type:"number",min:"0.01",max:"30",step:"0.01",status:r?.type||(o?"success":"default"),id:"widget-slippage-chip-text-input",onInput:c,fullWidth:!0,variant:"contained",value:o===null?"":o,color:"dark",onChange:a,suffix:o&&ze.createElement(Fy,{variant:"body",size:"small"},"%"),placeholder:$y.t("Custom")})),r&&ze.createElement(ze.Fragment,null,ze.createElement(pp,{size:10}),ze.createElement(WA,{id:"widget-slippage-alert",variant:"alarm",type:r.type,title:r.message})))}i(up,"Slippage");import{i18n as kt}from"@lingui/core";import{AutoThemeIcon as Oy,BridgesIcon as DA,ChevronRightIcon as Da,DarkModeIcon as Uy,Divider as Gr,ExchangeIcon as $A,InfinityIcon as FA,InfoIcon as OA,LanguageIcon as UA,LightModeIcon as zy,List as zA,ListItem as QA,ListItemButton as HA,Skeleton as qA,styled as GA,Switch as VA,Tabs as KA,TargetIcon as jA,Tooltip as XA,Typography as at}from"@rango-dev/ui";import _ from"react";import{useNavigate as YA}from"react-router-dom";var ZA=GA("div",{width:"202px",height:"$40"}),JA=[{id:"light",icon:_.createElement(zy,{color:"black",size:24}),tooltip:_.createElement(at,{size:"xsmall",variant:"body"},kt.t("Light"))},{id:"dark",icon:_.createElement(Uy,{color:"black",size:24}),tooltip:_.createElement(at,{size:"xsmall",variant:"body"},kt.t("Dark"))},{id:"auto",icon:_.createElement(Oy,{color:"black",size:24}),tooltip:_.createElement(at,{size:"xsmall",variant:"body"},kt.t("Auto"))}],RA=i(t=>{let e={color:"gray",size:16};switch(t){case"auto":return _.createElement(Oy,{...e});case"dark":return _.createElement(Uy,{...e});default:return _.createElement(zy,{...e})}},"getThemeIcon");function Qy(){let t=YA(),{theme:e}=T().config,{setTheme:o,theme:n}=T(),{activeLanguage:r,languages:a}=wo(),s=a.find(M=>M.local===r)?.label,c=T().fetchStatus,l=T().swappers(),p=T().getDisabledLiquiditySources(),{config:{features:u}}=T(),m=T().customTokens(),f=tt("theme",u),h=tt("liquiditySource",u),g=tt("language",u),d=tt("customTokens",u),S=T().infiniteApprove,y=T().toggleInfiniteApprove,C=Si(l,p),k=C.filter(M=>["BRIDGE","AGGREGATOR","OFF_CHAIN"].includes(M.type)),w=k.length,x=k.filter(M=>M.selected).length,I=C.filter(M=>M.type==="DEX"),A=I.length,b=I.filter(M=>M.selected).length,E=i((M,ee)=>{switch(c){case"loading":return _.createElement(qA,{variant:"text",size:"medium",width:50});case"failed":return _.createElement(at,{variant:"body",size:"medium",color:"$error500"},kt.t("Loading failed"));default:return _.createElement(at,{variant:"body",size:"medium"},`${M} / ${ee}`)}},"handleSwapperEndItem"),v={id:"widget-setting-bridge-item-btn",title:_.createElement(at,{variant:"title",size:"xmedium"},kt.t("Bridges")),end:_.createElement(_.Fragment,null,E(x,w),_.createElement(Gr,{direction:"horizontal",size:8}),_.createElement(Da,{color:"black"})),onClick:()=>t(F.bridges),start:_.createElement(DA,{color:"gray",size:16})},N={id:"widget-setting-exchange-item-btn",title:_.createElement(at,{variant:"title",size:"xmedium"},kt.t("Exchanges")),end:_.createElement(_.Fragment,null,E(b,A),_.createElement(Gr,{direction:"horizontal",size:8}),_.createElement(Da,{color:"black"})),start:_.createElement($A,{color:"gray",size:16}),onClick:()=>t(F.exchanges)},W={id:"widget-setting-custom-tokens-item-btn",title:_.createElement(at,{variant:"title",size:"xmedium"},kt.t("Custom Tokens")),end:_.createElement(_.Fragment,null,_.createElement(at,{variant:"body",size:"medium"},`${m.length}`),_.createElement(Gr,{direction:"horizontal",size:8}),_.createElement(Da,{color:"black"})),start:_.createElement(jA,{color:"gray",size:16}),onClick:()=>t(F.customTokens)},D={id:"widget-setting-language-item-btn",title:_.createElement(at,{variant:"title",size:"xmedium"},kt.t("Language")),start:_.createElement(UA,{color:"gray",size:16}),end:_.createElement(_.Fragment,null,_.createElement(at,{variant:"body",size:"medium"},s),_.createElement(Gr,{direction:"horizontal",size:8}),_.createElement(Da,{color:"black"})),onClick:()=>t(F.languages)},H={id:"widget-setting-infinite-approval-item-btn",title:_.createElement(_.Fragment,null,_.createElement(at,{variant:"title",size:"xmedium"},kt.t("Infinite approval")),_.createElement(Gr,{direction:"horizontal",size:4}),_.createElement(XA,{side:"top",sideOffset:4,container:B(),content:_.createElement(_a,null,_.createElement(at,{variant:"label",size:"medium",color:"neutral700"},_.createElement("b",null,kt.t("Warning")),":\xA0",kt.t("Enabling the 'Infinite approval' mode grants unrestricted access to underlying smart contracts, allowing them to utilize the approved token amount without limitations.")))},_.createElement(OA,{color:"gray"}))),start:_.createElement(FA,{color:"gray",size:16}),end:_.createElement(VA,{checked:S}),onClick:y},X={id:"widget-setting-theme-item-btn",type:_.createElement(QA,null),title:_.createElement(at,{variant:"title",size:"xmedium"},kt.t("Theme")),end:_.createElement(ZA,null,_.createElement(KA,{container:B(),items:JA,value:n,className:"widget-setting-theme-item-tabs-container",onChange:M=>o(M.id),type:"primary",borderRadius:"small"})),start:RA(n)},Y=h?[]:[v,N];return d||Y.push(W),g||Y.push(D),Y.push(H),!e?.singleTheme&&!f&&Y.push(X),_.createElement(zA,{type:_.createElement(HA,{className:"widget-settings-list-item-btn",hasDivider:!0,id:"_",onClick:()=>console.log()}),items:Y})}i(Qy,"SettingsLists");var iN=oN("div",{paddingLeft:"$8"});function Hy(){let{isInCampaignMode:t,updateCampaignMode:e}=T(),o=t(),[,n]=rN(),r=nN(),a=i(()=>{r&&o&&(n(s=>(s.delete("liquiditySources"),s),{replace:!0}),e("liquiditySources",void 0))},"onClick");return Xo.createElement(se,{header:{title:dp.t("Settings")}},Xo.createElement(ue,null,o&&Xo.createElement(eN,{type:"info",variant:"alarm",id:"widget-settings-campaign-mode-alert",title:dp.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:Xo.createElement(iN,null,Xo.createElement(tN,{id:"widget-setting-exit-campaign-mode-btn",type:"secondary",size:"small",onClick:a},dp.t("Reset")))}),Xo.createElement(up,null),Xo.createElement(Qy,null)))}i(Hy,"SettingsPage");import{i18n as g0}from"@lingui/core";import{cancelSwap as h0}from"@rango-dev/queue-manager-rango-preset";import{useManager as y0}from"@rango-dev/queue-manager-react";import{Alert as S0}from"@rango-dev/ui";import Np from"react";import{useParams as C0}from"react-router-dom";import{i18n as zt}from"@lingui/core";import{getCurrentNamespaceOfOrNull as t0,getCurrentStep as o0,getRelatedWalletOrNull as n0}from"@rango-dev/queue-manager-rango-preset";import{Button as $S,Divider as r0,QuoteCost as i0,StepDetails as a0,Typography as vp}from"@rango-dev/ui";import{useWallets as s0}from"@rango-dev/wallets-react";import FS from"bignumber.js";import{PendingSwapNetworkStatus as Fn}from"rango-types";import ke,{useEffect as xp,useRef as bp,useState as Ga}from"react";import{useNavigate as l0}from"react-router-dom";import{i18n as xo}from"@lingui/core";var aN=[xo.t("Sunday"),xo.t("Monday"),xo.t("Tuesday"),xo.t("Wednesday"),xo.t("Thursday"),xo.t("Friday"),xo.t("Saturday")];function qy(t){let e=new Date(t),o=e.getDate(),n=e.toLocaleString("default",{month:"long"}),r=e.getFullYear();return`${e.getDay()===new Date().getDay()?xo.t("Today"):`${aN[e.getDay()]} ${o} ${n} ${r}`}, ${new Date(t).toLocaleTimeString()}`}i(qy,"timeSince");function Gy(t){return t.finishTime?qy(parseInt(t.finishTime)):qy(parseInt(t.creationTime))}i(Gy,"getSwapDate");import Vr from"react";import{i18n as $a}from"@lingui/core";import{Button as Vy,Divider as mp,MessageBox as sN}from"@rango-dev/ui";import bo from"react";var Ky=i(({onCancel:t,onClose:e})=>bo.createElement(bo.Fragment,null,bo.createElement(mp,{size:20}),bo.createElement(sN,{type:"error",title:$a.t("Cancel Swap"),description:$a.t("Are you sure you want to cancel this swap?")}),bo.createElement(mp,{size:32}),bo.createElement(Vy,{variant:"contained",id:"widget-swap-details-modal-cancel-swap-yes-btn",type:"primary",size:"large",onClick:t},$a.t("Yes, Cancel it")),bo.createElement(mp,{size:12}),bo.createElement(Vy,{id:"widget-swap-details-modal-cancel-swap-no-btn",variant:"outlined",type:"primary",size:"large",onClick:e},$a.t("No, Continue"))),"CancelContent");import{i18n as Fa}from"@lingui/core";import{Button as jy,Divider as fp,MessageBox as lN,Typography as cN}from"@rango-dev/ui";import io from"react";var Xy=i(({onDelete:t,onClose:e})=>io.createElement(io.Fragment,null,io.createElement(fp,{size:20}),io.createElement(lN,{type:"error",title:Fa.t("Delete Transaction"),description:Fa.t("Are you sure you want to delete this swap?")}),io.createElement(fp,{size:32}),io.createElement(jy,{id:"widget-swap-details-modal-delete-swap-yes-btn",variant:"contained",type:"primary",size:"large",onClick:t},Fa.t("Yes, Delete it")),io.createElement(fp,{size:12}),io.createElement(jy,{id:"widget-swap-details-modal-delete-swap-no-btn",variant:"outlined",type:"primary",size:"large",onClick:e},io.createElement(cN,{variant:"title",size:"medium",color:"primary"},Fa.t("No, Cancel")))),"DeleteContent");import{i18n as pN}from"@lingui/core";import{Button as uN,Divider as dN,MessageBox as mN}from"@rango-dev/ui";import Yo from"react";var Yy=i(t=>{let{switchNetworkModalState:e,handleSwitchNetwork:o}=t;return Yo.createElement(Yo.Fragment,null,Yo.createElement(mN,{type:e.type,title:e.title,description:e.description}),e.type==="error"&&Yo.createElement(Yo.Fragment,null,Yo.createElement(dN,{size:"30"}),Yo.createElement(uN,{id:"widget-switch-network-try-again",type:"primary",size:"large",onClick:o},pN.t("Try Again"))))},"NetworkStateContent");import{getCurrentNamespaceOfOrNull as WN,getCurrentStep as MN,getRelatedWalletOrNull as LN}from"@rango-dev/queue-manager-rango-preset";import{WalletState as PN}from"@rango-dev/ui";import{useWallets as _N}from"@rango-dev/wallets-react";import nS from"react";import{i18n as Dn}from"@lingui/core";import{Alert as Ry,Button as hN,Checkbox as yN,Divider as za,Image as SN,MessageBox as CN,Spinner as TN,WarningIcon as kN}from"@rango-dev/ui";import{useWallets as wN}from"@rango-dev/wallets-react";import Se,{useState as vN}from"react";import{css as fN,darkTheme as gN,styled as gp}from"@rango-dev/ui";var Zy=fN({wordWrap:"break-word",display:"block"}),Jy=gp("img",{width:"100%"}),Oa=gp("div",{position:"relative"}),Ua=gp("span",{position:"absolute",top:0,right:0,borderRadius:"50%",width:"14px",height:"14px",display:"flex",padding:"$2",backgroundColor:"$warning300",[`.${gN} &`]:{$$color:"$warning600"}});var eS=i(t=>{let{wallet:e,namespace:o,onClose:n}=t,[r,a]=vN(null),{list:s}=vt(),c=re.use.isActiveTab(),{state:l,connect:p}=wN(),u=s.find(x=>x.type===e.walletType),m=u?.needsNamespace?.data.find(x=>x.value===o?.namespace);if(!u)return null;let f=l(e.walletType),h=u.isHub&&o?.namespace?f.namespaces?.get(o.namespace):null,g=f.connecting||h?.connecting,d=u.isHub?h?.connected:f.connected,S=i(()=>d?Dn.t("Done"):r?Dn.t("Try again"):Dn.t("Connect"),"getButtonTitle"),y=i(()=>g?Se.createElement(TN,{color:"info"}):r||d?null:Se.createElement(yN,{checked:!0,disabled:!0}),"getNamespaceSuffix"),C=i(async()=>{try{a(null),await p(u.type,o?.namespace?[{namespace:o?.namespace,network:void 0,derivationPath:e.derivationPath}]:void 0)}catch(x){a(x)}},"handleConnect"),k=i(async()=>{if(d){n();return}C()},"handleClickButton"),w=i(()=>{if(!d)return null;let x=u?.isHub?h?.accounts?.[0]?.split(":"):f?.accounts?.[0]?.split(":"),I=x?.[x?.length-1];return I?lo(I):null},"getAddress");return Se.createElement(Se.Fragment,null,Se.createElement(CN,{type:"warning",title:Dn.t("Connect {wallet}",{wallet:u.title}),description:Dn.t("The connection of your wallet or some networks has been disconnected. Connect to continue the swap"),icon:Se.createElement(Oa,null,Se.createElement(SN,{src:u.image,size:45}),Se.createElement(Ua,null,Se.createElement(kN,{color:"warning",size:10})))}),d&&!m&&Se.createElement(Se.Fragment,null,Se.createElement(za,{size:10}),Se.createElement(Ry,{type:"success",variant:"alarm",title:Dn.t("Wallet connected successfully.")})),r&&!m&&Se.createElement(Se.Fragment,null,Se.createElement(za,{size:10}),Se.createElement(Ry,{type:"error",title:r?.message,variant:"alarm"})),m&&Se.createElement(Se.Fragment,null,Se.createElement(za,{size:30}),Se.createElement(_o,{namespace:m,suffix:y(),error:r?.message,connected:d,address:w()})),Se.createElement(za,{size:"40"}),Se.createElement(hN,{loading:g,type:"primary",id:"widget-connect-wallet-btn",onClick:k,disabled:!c},S()))},"ConnectWalletContent");import{i18n as tS}from"@lingui/core";import{Button as xN,Divider as bN,Image as EN,MessageBox as IN,WarningIcon as AN}from"@rango-dev/ui";import{useWallets as NN}from"@rango-dev/wallets-react";import{detectInstallLink as BN}from"@rango-dev/wallets-shared";import ao from"react";var oS=i(t=>{let{walletType:e}=t,{getWalletInfo:o}=NN(),n=e?o(e):null;if(!n)return null;let r=i(()=>window.open(BN(n.installLink),"_blank"),"handleButtonClick");return ao.createElement(ao.Fragment,null,ao.createElement(IN,{type:"warning",title:tS.t("Install {wallet}",{wallet:n.name}),description:"Your wallet is not installed. Please install it to continue the swap. ",icon:ao.createElement(Oa,null,ao.createElement(EN,{src:n.img,size:45}),ao.createElement(Ua,null,ao.createElement(AN,{color:"warning",size:10})))}),ao.createElement(bN,{size:"40"}),ao.createElement(xN,{type:"primary",id:"widget-install-wallet-btn",onClick:r},tS.t("Install")))},"InstallWalletContent");var rS=i(t=>{let{swap:e,onClose:o}=t,{state:n,getWalletInfo:r}=_N(),a=MN(e),s=a?LN(e,a):null,c=s?.walletType,l=c?Kn(r(c),n(c)):null,p=a?WN(e,a):null;return c?l===PN.NOT_INSTALLED?nS.createElement(oS,{walletType:c}):nS.createElement(eS,{wallet:s,namespace:p,onClose:o}):null},"WalletStateContent");function hp(t){let{isOpen:e,state:o,switchNetworkModalState:n,onClose:r,onDelete:a,onCancel:s,swap:c,message:l,handleSwitchNetwork:p}=t;return Vr.createElement(R,{open:e,onClose:r,container:B()},o==="connectWallet"&&Vr.createElement(rS,{swap:c,message:l,onClose:r}),o==="switchNetwork"&&n&&Vr.createElement(Yy,{message:l,switchNetworkModalState:n,handleSwitchNetwork:p}),o==="delete"&&Vr.createElement(Xy,{onClose:r,onDelete:()=>{r(),a()}}),o==="cancel"&&Vr.createElement(Ky,{onClose:r,onCancel:()=>{r(),s()}}))}i(hp,"SwapDetailsModal");import{i18n as Kr}from"@lingui/core";import{Button as yp,Divider as jr,MessageBox as sS,TokenAmount as DN,Typography as lS}from"@rango-dev/ui";import Te from"react";import{Link as $N,useNavigate as FN}from"react-router-dom";var iS="https://raw.githubusercontent.com/rango-exchange/assets/main/banners/widget/profile.jpg",aS="/profile";function Sp(t){let{open:e,onClose:o,status:n,priceValue:r,usdValue:a,realUsdValue:s,realValue:c,token:l,chain:p,percentageChange:u,description:m,diagnosisUrl:f}=t,h=FN(),{showProfileBanner:g}=re();return Te.createElement(R,{open:e,onClose:o,id:"widget-swap-details-complete-modal",container:document.getElementById(et.SWAP_BOX_ID)||document.body},n==="success"?Te.createElement(sS,{type:"success",title:Kr.t("Swap Successful")},Te.createElement(DN,{direction:"vertical",tooltipContainer:B(),id:"widget-swap-details-complete-modal-success-token-amount-container",type:"output",centerAlign:!0,price:{value:r,usdValue:a,realUsdValue:s,realValue:c},token:l,chain:p,percentageChange:u}),Te.createElement(jr,{size:12}),Te.createElement(lS,{className:Zy(),variant:"body",size:"medium",color:"neutral700",align:"center"},m)):Te.createElement(sS,{type:"error",title:Kr.t("Transaction Failed"),description:m}),Te.createElement(jr,{size:30}),n==="success"&&Te.createElement(Te.Fragment,null,g&&Te.createElement(Te.Fragment,null,Te.createElement($N,{to:aS},Te.createElement(Jy,{src:iS,alt:"Profile Banner"})),Te.createElement(jr,{size:30})),Te.createElement(yp,{id:"widget-swap-details-modal-done-btn",variant:"contained",type:"primary",size:"large",onClick:()=>{h("../../")}},Kr.t("Done"))),Te.createElement(jr,{size:12}),f&&Te.createElement(Te.Fragment,null,Te.createElement(yp,{variant:"contained",id:"widget-swap-detail-modal-diagnosis-btn",type:"primary",size:"large",onClick:()=>window.open(f,"_blank")},Kr.t("Diagnosis")),Te.createElement(jr,{size:12})),Te.createElement(yp,{id:"widget-swap-details-modal-see-details-btn",variant:"outlined",type:"primary",size:"large",onClick:o},Te.createElement(lS,{variant:"title",size:"medium",color:"primary"},Kr.t("See Details"))))}i(Sp,"SwapDetailsCompleteModal");import{i18n as qa}from"@lingui/core";import{CopyIcon as YN,DoneIcon as ZN,IconButton as JN,RangoExplorerIcon as RN,Tooltip as WS,Typography as MS,useCopyToClipboard as e0}from"@rango-dev/ui";import Bt from"react";import XN from"react";import{i18n as GN}from"@lingui/core";import{Alert as IS,IconButton as VN,LinkIcon as KN}from"@rango-dev/ui";import Eo,{Fragment as jN}from"react";import{Alert as UN,ChevronDownIcon as zN,IconButton as QN}from"@rango-dev/ui";import $n,{useState as HN}from"react";import{css as Xr,darkTheme as cS,styled as Ut,Typography as ON}from"@rango-dev/ui";var pS=Ut(ue,{overflowY:"auto","& ._icon-button":{"&:hover":{"& svg":{color:"$secondary550",[`.${cS} &`]:{color:"$secondary500"}}}}}),uS=Ut("div",{display:"flex",flexDirection:"column",flexGrow:1,overflow:"hidden"}),dS=Ut("div",{position:"sticky",top:0,zIndex:10,backgroundColor:"$background"}),mS=Ut("div",{padding:"$0 $20 $20 $20"}),wY=Ut("div",{display:"flex",flexDirection:"column",gap:"$10"}),fS=Ut("div",{height:"450px",display:"flex",alignItems:"center",justifyContent:"center"}),vY=Ut("div",{display:"flex",justifyContent:"center",width:"100%",paddingTop:"33%",flex:1}),Zo=Xr({display:"flex",width:"100%",justifyContent:"space-between",alignItems:"center",padding:"$10 $20",borderBottom:"1px solid",$$color:"$colors$neutral300",[`.${cS} &`]:{$$color:"$colors$neutral400"},borderColor:"$$color",color:"$neutral500"}),gS=Xr({padding:"$5 0"}),Qa=Xr({display:"flex",justifyContent:"center",alignItems:"center",height:"$24"}),hS=Xr({display:"flex",width:"100%",padding:"$15 $20 $20",flexDirection:"column",alignItems:"start"}),yS=Xr({width:"100%",padding:"0 $20 $10"}),SS=Ut("a",{fontSize:"$16",fontWeight:"$400",color:"$neutral700",display:"flex",alignItems:"center",justifyContent:"center"}),CS=Ut("div",{display:"flex",flexDirection:"column",gap:"$5"}),Ha=Ut(ON,{wordBreak:"break-word"});import{styled as Cp}from"@rango-dev/ui";var TS=Cp("div",{display:"flex",flexDirection:"column",gap:"$10"}),kS=Cp("div",{transition:"transform 0.3s ease-in-out",variants:{rotated:{true:{transform:"rotate(180deg)"}}}}),wS=Cp("div",{transition:"max-height 0.3s ease-in-out",maxHeight:"0px",overflow:"hidden",variants:{open:{true:{maxHeight:"200px"}}}});function vS(t){let{message:e}=t,[o,n]=HN(!1);return $n.createElement(UN,{id:"widget-failed-swap-details-alert",type:"error",title:e.shortMessage,containerStyles:{"& .footer":{paddingTop:"$0"}},action:e.detailedMessage.content&&$n.createElement(QN,{id:"widget-swap-details-failed-btn",onClick:()=>n(r=>!r),variant:"ghost",size:"xsmall"},$n.createElement(kS,{rotated:o},$n.createElement(zN,{size:12,color:"gray"}))),footer:$n.createElement(wS,{open:o},$n.createElement(Ha,{variant:"body",size:"xsmall",color:"neutral700"},e.detailedMessage.content))})}i(vS,"FailedAlert");import{i18n as xS}from"@lingui/core";import{Alert as Tp,Button as bS}from"@rango-dev/ui";import{PendingSwapNetworkStatus as qN}from"rango-types";import Yr from"react";function ES(t){let{switchNetworkIsAvailable:e,handleSwitchNetworkClick:o,setNetworkModal:n,message:r,showNetworkModal:a}=t;return e?Yr.createElement(Tp,{type:"warning",id:"widget-swap-details-change-network-alert",title:r.shortMessage,action:Yr.createElement(bS,{id:"widget-swap-details-warning-alert-change-network-btn",size:"xxsmall",type:"warning",onClick:()=>{n("switchNetwork"),o()}},xS.t("Change"))}):a===qN.WaitingForConnectingWallet?Yr.createElement(Tp,{type:"warning",title:r.shortMessage,id:"widget-swap-details-warning-alert-connect-wallet-alert",action:Yr.createElement(bS,{id:"widget-swap-details-warning-alert-connect-wallet-btn",size:"xxsmall",type:"warning",onClick:()=>{n("connectWallet")}},xS.t("Connect"))}):Yr.createElement(Tp,{id:"widget-swap-details-short-alert",type:"warning",title:r.shortMessage})}i(ES,"WarningAlert");function kp(t){let{switchNetworkIsAvailable:e,handleSwitchNetworkClick:o,showNetworkModal:n,setNetworkModal:r,message:a,step:s,hasAlreadyProceededToSign:c}=t,l=pr(s),p=s.status==="waitingForApproval"&&!l,u=s.status==="running"&&!l,m=u&&!c||p&&!s.explorerUrl?.length;return Eo.createElement(TS,null,s.explorerUrl?.map((f,h,g)=>{let d=h+f.url,S=h===g.length-1,y=(S&&u||p)&&!m,C=S&&s.status==="failed";return Eo.createElement(jN,{key:d},Eo.createElement(IS,{id:"widget-swap-details-tx-alert",type:S&&(y&&"loading"||C&&"error")||"success",title:f.description?`${f.description} Tx`:GN.t("View transaction"),action:f.url&&Eo.createElement(VN,{id:"widget-swap-details-tx-link-icon-btn",variant:"ghost",size:"xsmall",onClick:()=>window.open(f.url,"_blank")},Eo.createElement(KN,{size:12}))}))}),m&&Eo.createElement(IS,{id:"widget-swap-details-loading-alert",type:"loading",title:a.shortMessage}),s.status!=="failed"&&l&&Eo.createElement(ES,{switchNetworkIsAvailable:e,handleSwitchNetworkClick:o,showNetworkModal:n,setNetworkModal:r,message:a}),s.status==="failed"&&Eo.createElement(vS,{message:a}))}i(kp,"SwapDetailsAlerts");var AS=2e3;var NS=i(({swap:t,blockchains:e,swappers:o,...n})=>{let r=t.hasAlreadyProceededToSign!==!1;return t.steps.map((a,s)=>{let c=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:ht(a.fromBlockchain,e)??"",image:a.fromBlockchainLogo??""},price:{value:P(c,6,6),realValue:c??""}},to:{token:{displayName:a.toSymbol,image:a.toLogo},chain:{displayName:ht(a.toBlockchain,e)??"",image:a.toBlockchainLogo??""},price:{value:P(a.outputAmount||a.expectedOutputAmountHumanReadable,6,6),realValue:a.outputAmount||a.expectedOutputAmountHumanReadable||""}},swapper:{displayName:Hn(a.swapperId,o)??"",image:a.swapperLogo??"",type:a.swapperType},internalSwaps:a.internalSwaps?a.internalSwaps.map(l=>({from:{chain:{displayName:ht(l.fromBlockchain,e)??"",image:l.fromBlockchainLogo??""}},to:{chain:{displayName:ht(l.toBlockchain,e)??"",image:l.toBlockchainLogo??""}},swapper:{displayName:Hn(l.swapperId,o)??"",image:l.swapperLogo??"",type:l.swapperType}})):[],alerts:XN.createElement(kp,{step:a,hasAlreadyProceededToSign:r,...n})}})},"getSteps");function BS(t){if(pr(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(BS,"getStepState");function LS(t){let{requestId:e}=t,[o,n]=e0(AS);return Bt.createElement(dS,{className:Zo()},Bt.createElement(MS,{variant:"label",size:"large",color:"neutral700"},qa.t("Request ID")),Bt.createElement("div",{className:Qa()},Bt.createElement(MS,{variant:"label",size:"small",color:"neutral700"},e),Bt.createElement(WS,{container:B(),content:o?qa.t("Copied To Clipboard"):qa.t("Copy Request ID"),open:o||void 0,side:"bottom",alignOffset:-16,align:"end"},Bt.createElement(JN,{id:"widget-swap-details-done-copy-icon-btn",variant:"ghost",onClick:n.bind(null,e||"")},o?Bt.createElement(ZN,{size:16,color:"secondary"}):Bt.createElement(YN,{size:16,color:"gray"}))),Bt.createElement(SS,{target:"_blank",href:`${tu}/swap/${e}`},Bt.createElement(WS,{container:B(),content:qa.t("View on Rango Explorer"),side:"bottom"},Bt.createElement(RN,{size:20})))))}i(LS,"RequestIdRow");import{i18n as PS}from"@lingui/core";import{Typography as _S}from"@rango-dev/ui";import wp from"react";function DS(t){let{date:e,isFinished:o}=t;return wp.createElement("div",{className:Zo()},wp.createElement(_S,{variant:"label",size:"large",color:"neutral700"},o?PS.t("Finished at"):PS.t("Created at")),wp.createElement(_S,{variant:"label",size:"small",color:"neutral700"},e))}i(DS,"SwapDateRow");var c0=3e3;function Ep(t){let{swap:e,requestId:o,onDelete:n,onCancel:r}=t,{canSwitchNetworkTo:a,connect:s,getWalletInfo:c}=s0(),l=T().blockchains(),p=T().swappers(),{findToken:u}=T(),m=z().use.retry(),f=l0(),h=bp(null),[g,d]=Ga(!1),[S,y]=Ga(null),[C,k]=Ga(null),[w,x]=Ga(null),I=bp(S),A=bp(C),b=Be.use.getNotifications(),E=Be.use.removeNotification(),v=b(),N=o0(e),W=N?.networkStatus,D=i(Le=>{d(!0),y(Le)},"handleChangeModalState"),H=i(()=>{d(!1)},"handleCloseModal"),X=i(()=>{k({type:"loading",title:zt.t("Change Network"),description:`We\u2019re switching the connected network to ${J?.network}. Please check your wallet.`})},"handleShowSwitchNetworkLoading"),Y=i(()=>{k({type:"success",title:zt.t("Network Changed"),description:"The network has been successfully changed."})},"handleShowSwitchNetworkSucceeded"),M=i(Le=>{k({type:"error",title:zt.t("Network Switch Failed"),description:Le?.message||pe.detailedMessage.content})},"handleShowSwitchNetworkFailed"),ee=Yd(e),J=N?t0(e,N):null,te=N?n0(e,N):null,ce=Gy(e),Oe=Zd(e),ne=i(Le=>!!c(Le)?.mobileWallet,"checkIsMobileWallet"),wt=!!W&&[Fn.WaitingForNetworkChange,Fn.NetworkChangeFailed].includes(W),gt=!!te?.walletType&&ne(te.walletType),Wt=!!te&&!!J&&a(te.walletType,J.network,J),$=!!J&&wt&&(gt||Wt),U=i(()=>{$&&(X(),s(te.walletType,[{namespace:J.namespace,network:J.network}]).then(()=>{Y()}).catch(Le=>{M(Le)}))},"handleSwitchNetwork"),G=i(()=>{D("switchNetwork"),U()},"handleSwitchNetworkClick"),pe=Xd(e,N,c),Q=NS({swap:e,switchNetworkIsAvailable:$,handleSwitchNetworkClick:G,showNetworkModal:W,setNetworkModal:D,message:pe,blockchains:l,swappers:p}),j=Q.length,[K,Ie]=[e.steps[0],e.steps[j-1]],Ae=Ie?.outputAmount||Ie?.expectedOutputAmountHumanReadable,je=e.steps.reduce((Le,Lt)=>Le+parseFloat(Lt.feeInUsd||""),0),Mt=e.steps.find(Le=>Le.diagnosisUrl)?.diagnosisUrl,so=P(parseFloat(Ae||"0")*(Ie?.toUsdPrice||0),4,4),Io=P(parseFloat(e.inputAmount)*(K?.fromUsdPrice||0),4,4),zn=Ae?new FS(Ae).multipliedBy(Ie.toUsdPrice||0).toString():"",Rr=new FS(e.inputAmount).multipliedBy(K?.fromUsdPrice||0).toString(),os=jt(Io,so),ns=pe.detailedMessage.content||pe.shortMessage,yC=e.status==="success"?zt.t({id:"You have received {amount} {token} in {conciseAddress} wallet on {chain} chain.",values:{amount:P(Ae,6,6),token:Q[j-1]?.to.token.displayName,conciseAddress:lo(e.wallets[Q[j-1]?.to.chain.displayName||""]?.address||""),chain:Q[j-1]?.to.chain.displayName}}):ke.createElement(CS,null,ke.createElement(vp,{variant:"body",size:"medium",color:"neutral700",align:"center"},ns?"":zt.t("Transaction was not sent."),ee?`${zt.t({id:"{amount} {symbol} on {blockchain} remains in your wallet.",values:{amount:ee.outputAmount,symbol:ee.symbol,blockchain:ee.blockchain}})}`:""),ns&&ke.createElement(Ha,{align:"center",variant:"body",size:"medium",color:"neutral700"},ke.createElement("b",null,"Reason:")," ",ns));return xp(()=>{v.find(Lt=>Lt.requestId===e.requestId)&&(e.status==="success"||e.status==="failed"?(x(e.status),E(e.requestId),H()):w&&x(null))},[e.status,e.requestId]),xp(()=>{if($){if(D("switchNetwork"),W===Fn.WaitingForNetworkChange){X();return}if(W===Fn.NetworkChangeFailed){M();return}return}if(W===Fn.WaitingForConnectingWallet){D("connectWallet");return}if(W===Fn.NetworkChanged){D("switchNetwork"),Y();return}S&&["connectWallet","switchNetwork"].includes(S)&&H()},[W]),xp(()=>{if(I.current=S,A.current=C,S==="switchNetwork"&&C?.type==="success"){let Le=setTimeout(()=>{I.current==="switchNetwork"&&A.current?.type==="success"&&H()},c0);return()=>clearTimeout(Le)}},[S,C]),ke.createElement(se,{header:{title:zt.t("Swap Details"),onCancel:e.status==="running"?()=>D("cancel"):void 0,suffix:e.status!=="running"&&ke.createElement(fo,null,ke.createElement($S,{id:"widget-swap-details-delete-btn",variant:"ghost",type:"error",size:"xsmall",onClick:()=>D("delete")},ke.createElement(vp,{size:"medium",variant:"label",color:"error"},zt.t("Delete"))))},footer:Oe&&!w&&ke.createElement($S,{fullWidth:!0,id:"widget-swap-details-try-again-btn",variant:"contained",type:"primary",size:"large",onClick:()=>{let Le=Bi(e,l,u);m(Le),setTimeout(()=>{f("../../")},0)}},zt.t("Try again"))},ke.createElement(pS,{compact:!0,ref:h},ke.createElement(LS,{requestId:o}),ke.createElement(DS,{date:ce,isFinished:!!e.finishTime}),ke.createElement("div",{className:hS()},ke.createElement(i0,{fee:P(String(je),2,2),time:Gn(ci(e.steps)),steps:j}),ke.createElement(wr,{from:{price:{value:P(e.inputAmount,6,6),usdValue:Io,realUsdValue:Rr,realValue:e.inputAmount},token:{displayName:Q[0]?.from.token.displayName||"",image:Q[0]?.from.token.image},chain:{image:Q[0]?.from.chain.image,displayName:Q[0]?.from.chain.displayName||""}},to:{price:{value:P(Ae,6,6),usdValue:so,realUsdValue:zn,realValue:Ae||""},token:{displayName:Q[j-1]?.to.token.displayName||"",image:Q[j-1]?.to.token.image},chain:{image:Q[j-1]?.to.chain.image,displayName:Q[j-1]?.to.chain.displayName||""}},percentageChange:P(os,2,2),warningLevel:Xt(os??0)})),ke.createElement("div",{className:yS()},ke.createElement(vp,{variant:"title",size:"small"},zt.t("Swaps steps"))),ke.createElement(r0,{size:8}),ke.createElement(mS,null,Q.map((Le,Lt)=>{let Op=Lt,Qn=e.steps[Lt]&&BS(e.steps[Lt]),SC=Qn==="error"||Qn==="in-progress"||Qn==="warning"||Qn==="completed"&&Lt===Q.length-1;return ke.createElement(a0,{className:"widget-swap-details-step-item-container",key:Op,step:Le,type:"swap-progress",ref:h,state:Qn,hasSeparator:Lt!==0,tabIndex:Op,isFocused:SC,tooltipContainer:B()})}))),ke.createElement(hp,{isOpen:g,state:S,switchNetworkModalState:C,onClose:H,onCancel:r,onDelete:n,message:pe.detailedMessage.content,swap:e,handleSwitchNetwork:G}),ke.createElement(Sp,{open:!!w,diagnosisUrl:Mt,onClose:()=>x(null),status:e.status==="success"?"success":"failed",priceValue:P(Ae,6,6),usdValue:so,realUsdValue:zn,realValue:Ae||"",percentageChange:P(os,2,2),token:{displayName:Q[j-1]?.to.token.displayName||"",image:Q[j-1]?.to.token.image},chain:{image:Q[j-1]?.to.chain.image},description:yC}))}i(Ep,"SwapDetails");import{i18n as Ka}from"@lingui/core";import{Divider as zS,NotFound as f0,Skeleton as Jr,Typography as ja}from"@rango-dev/ui";import Ee from"react";import{i18n as p0}from"@lingui/core";import{Divider as u0,Skeleton as d0,Typography as m0}from"@rango-dev/ui";import be from"react";import{css as Qt,styled as Ip}from"@rango-dev/ui";var OS=Ip("div",{width:"100%",height:"100%",padding:"$10 $20"}),Zr=Ip("div",{backgroundColor:"$neutral100",borderRadius:"$xm",padding:"$10 $15"}),Va=Ip("div",{width:"0px",height:"$20",borderLeft:"1px dashed $neutral700",marginLeft:"25px"}),Y7=Qt({display:"flex",justifyContent:"space-between",alignItems:"center"}),Z7=Qt({paddingTop:"$15",display:"flex"}),J7=Qt({padding:"$15 $0"}),R7=Qt({width:"0px",height:"$16",borderLeft:"1px solid $neutral400",marginLeft:"13px"}),e9=Qt({paddingBottom:"$10"}),t9=Qt({display:"flex",justifyContent:"start",alignItems:"center"}),o9=Qt({paddingTop:"$5",display:"flex",alignItems:"center"}),n9=Qt({display:"flex",alignItems:"center"}),r9=Qt({padding:"$4 $6",display:"flex",justifyContent:"center",alignItems:"center"}),US=Qt({display:"flex",paddingTop:"$10",paddingBottom:"$5"});function Ap(){return be.createElement(OS,null,be.createElement(xr,{type:"swap-preview"}),be.createElement("div",{className:"swaps-steps"},be.createElement(m0,{variant:"title",size:"small"},p0.t("Swaps steps"))),be.createElement(be.Fragment,null,be.createElement(Zr,null,be.createElement(Ft,{separator:!1}),be.createElement("div",{className:US()},be.createElement(u0,{direction:"horizontal",size:20}),be.createElement(d0,{height:22,variant:"rectangular"}))),be.createElement(Va,null),be.createElement(Zr,null,be.createElement(Ft,{separator:!1})),be.createElement(Va,null),be.createElement(Zr,null,be.createElement(Ft,{separator:!1})),be.createElement(Va,null),be.createElement(Zr,null,be.createElement(Ft,{separator:!1}))))}i(Ap,"LoadingSwapDetails");function QS(t){let{requestId:e,showSkeleton:o}=t;return Ee.createElement(se,{header:{title:Ka.t("Swap Details"),suffix:Ee.createElement(fo,null)}},o&&Ee.createElement(uS,null,Ee.createElement("div",{className:Zo()},Ee.createElement(ja,{variant:"label",size:"large",color:"neutral700"},`${Ka.t("Request ID")}`),Ee.createElement("div",{className:Qa()},Ee.createElement(ja,{variant:"label",size:"small",color:"neutral700"},Ee.createElement(Jr,{width:60,height:10,variant:"rounded"})),Ee.createElement(zS,{direction:"horizontal",size:4}),Ee.createElement(Jr,{width:16,height:16,variant:"rectangular"}),Ee.createElement(zS,{direction:"horizontal",size:4}),Ee.createElement(Jr,{width:16,height:16,variant:"rectangular"}))),Ee.createElement("div",{className:Zo()},Ee.createElement(ja,{className:gS(),variant:"label",size:"large",color:"neutral700"},Ee.createElement(Jr,{width:60,height:10,variant:"rounded"})),Ee.createElement(ja,{variant:"label",size:"small",color:"neutral700"},Ee.createElement(Jr,{width:60,height:10,variant:"rounded"}))),Ee.createElement(Ap,null)),!o&&Ee.createElement(fS,null,Ee.createElement(f0,{title:Ka.t("Not found"),description:Ka.t({id:"Swap with request ID = {requestId} not found.",values:{requestId:e}})})))}i(QS,"SwapDetailsPlaceholder");function HS(){let{manager:t,state:e}=y0(),o=!e.loadedFromPersistor,n=Tt(t),{requestId:r}=C0(),a=Ge(),{fetchStatus:s}=T();if(!r)return Np.createElement(S0,{containerStyles:{margin:"20px"},type:"error",title:g0.t("The request ID is necessary to display the swap details.")});let c=o||s==="loading",l=r?n.find(({swap:f})=>f.requestId===r):void 0,p=i(()=>{if(l?.id){let f=t?.get(l.id);f&&h0(f)}},"onCancel"),u=i(async()=>{if(l?.id)try{t?.deleteQueue(l.id),a()}catch(f){console.log(f)}},"onDelete"),m=l?.swap;return!m||c?Np.createElement(QS,{requestId:r,showSkeleton:c}):Np.createElement(Ep,{swap:m,requestId:r,onCancel:p,onDelete:u})}i(HS,"SwapDetailsPage");import{i18n as qS}from"@lingui/core";import{Divider as T0,getCategoriesCount as k0,SelectableCategoryList as w0,styled as VS,Typography as v0,Wallet as x0}from"@rango-dev/ui";import Ht,{useState as GS}from"react";var b0=VS("div",{display:"flex",justifyContent:"center",alignItems:"center",columnGap:"$5",rowGap:"$10",flexWrap:"wrap",paddingTop:"$5"}),E0=VS(ue,{textAlign:"center"});function KS(){let{fetchStatus:t}=T(),[e,o]=GS("ALL"),n=T().blockchains(),{config:r}=T(),[a,s]=GS(),c=re.use.isActiveTab(),{list:l}=vt(),p=Bu(l,n),m=k0(p)!==1,f=Wu(l,e),h=i(g=>{uu(l,r.multiWallets)||s(g)},"handleWalletItemClick");return Ht.createElement(se,{header:{title:qS.t("Connect Wallets")}},Ht.createElement(E0,null,m&&Ht.createElement(Ht.Fragment,null,Ht.createElement(w0,{setCategory:o,category:e,blockchains:p,isLoading:t==="loading"}),Ht.createElement(T0,{size:24})),Ht.createElement(v0,{variant:"title",size:"xmedium",align:"center"},qS.t("Choose a wallet to connect.")),Ht.createElement(b0,null,f.map((g,d)=>{let S=`wallet-${d}-${g.type}`;return Ht.createElement(x0,{key:S,...g,state:g.state,container:B(),onClick:()=>h(g),isLoading:t==="loading",disabled:!c})}),Ht.createElement(sr,{id:"widget-state-full-connect-modal",wallet:a,onClose:()=>{s(void 0)}}))))}i(KS,"WalletsPage");function jS(){return lm(),Rs(),I0([{path:F.home,element:Qe.createElement(py,null)},{path:F.routes,element:Qe.createElement(gy,null)},{path:F.fromSwap,children:[{index:!0,element:Qe.createElement(Pa,{type:"source"})},{path:F.blockchains,element:Qe.createElement(Ba,{type:"source"})}]},{path:F.toSwap,children:[{index:!0,element:Qe.createElement(Pa,{type:"destination"})},{path:F.blockchains,element:Qe.createElement(Ba,{type:"destination"})}]},{path:F.settings,children:[{index:!0,element:Qe.createElement(Hy,null)},{path:F.languages,element:Qe.createElement(dy,null)},{path:F.exchanges,element:Qe.createElement(Rc,{sourceType:"Exchanges"})},{path:F.bridges,element:Qe.createElement(Rc,{sourceType:"Bridges"})},{path:F.customTokens,children:[{index:!0,element:Qe.createElement(uh,null)},{path:F.addCustomTokens,children:[{index:!0,element:Qe.createElement(af,null)},{path:F.blockchains,element:Qe.createElement(Ba,{hideCategory:!0,type:"custom-token"})}]}]}]},{path:F.swaps,children:[{index:!0,element:Qe.createElement(Wh,null)},{path:F.swapDetails,element:Qe.createElement(HS,null)}]},{path:F.wallets,element:Qe.createElement(KS,null)},{path:F.confirmSwap,element:Qe.createElement(Xg,null)}])}i(jS,"AppRoutes");import{useQueueManager as G0}from"@rango-dev/queue-manager-rango-preset";import{isEvmBlockchain as V0}from"rango-sdk";import{useContext as K0,useEffect as Lp,useState as aC}from"react";import{Provider as L0}from"@rango-dev/wallets-react";import Xa,{createContext as P0,useEffect as RS,useMemo as _0,useRef as eC}from"react";import{useEffect as N0}from"react";import{Provider as A0}from"@rango-dev/wallets-core";function XS(t){return t.map(e=>typeof e=="string"?e:e instanceof A0?e.id:e.config.type).join("-")}i(XS,"hashProviders");function Bp(t,e){let{clearConnectedWallet:o,getAvailableProviders:n,buildAndSetProviders:r}=T(),a=n();return N0(()=>{o(),r()},[XS(t??[]),e?.walletConnectProjectId,e?.walletConnectListedDesktopWalletLink]),{providers:a}}i(Bp,"useWalletProviders");import{legacyFormatAddressWithNetwork as B0,legacyReadAccountAddress as YS}from"@rango-dev/wallets-core/legacy";import{Events as On}from"@rango-dev/wallets-react";import{isEvmBlockchain as W0}from"rango-sdk";function ZS(t){let{newWalletConnected:e,disconnectWallet:o,disconnectNamespaces:n,connectedWallets:r,removeBalancesForWallet:a,blockchains:s}=T(),{onConnectWalletHandler:c,onDisconnectWalletHandler:l}=t,p=s().filter(W0).map(d=>d.name),u=i((d,S)=>{let[y,,C,k,w]=d,x={walletType:y,network:k.network??void 0,accounts:C};c.current?c.current(x):console.warn("onConnectWallet handler hasn't been set. Are you sure?");let I=ms(y,C,p,S.supportedChainNames,w.isContractWallet);I.length&&e(I,w.namespace,k.derivationPath)},"onAccountsEvent"),m=i((d,S,y,C,k)=>{if(S===On.ACCOUNTS){let w=jn(k.supportedBlockchains);y&&u([d,S,y,C,k],{supportedChainNames:w})}S===On.PROVIDER_DISCONNECTED&&(o(d),l.current?l.current(d):console.warn("onDisconnectWallet handler hasn't been set. Are you sure?")),S===On.NAMESPACE_DISCONNECTED&&n(d,y)},"handleUpdatesForHub"),f=i((d,S,y,C,k)=>{if(S===On.ACCOUNTS){let w=jn(k.supportedBlockchains),x=[],I=[];if(y?.forEach(b=>{let{network:E}=YS(b);p.includes(E)?x.push(b):I.push(b)}),r.filter(b=>b.walletType===d).map(b=>B0(b.address,b.chain)).length>0){if(x.length>0){let b=ms(d,x,p,w,k.isContractWallet);a(d,{chains:b.map(E=>E.chain)})}I.length>0&&a(d,{chains:I.map(b=>{let{network:E}=YS(b);return E})})}y?u([d,S,y,C,k],{supportedChainNames:w}):(o(d),l.current?l.current(d):console.warn("onDisconnectWallet handler hasn't been set. Are you sure?"))}},"handleUpdatesForLegacy"),h=i((d,S,y,C,k)=>{if(S===On.CONNECTED&&y){let w={walletType:d,network:C.network??void 0,accounts:C.accounts??void 0};c.current?c.current(w):console.warn("onConnectWallet handler hasn't been set. Are you sure?")}if(S===On.NETWORK&&y){let w={walletType:d,network:y,accounts:C.accounts??void 0};c.current?c.current(w):console.warn("onConnectWallet handler hasn't been set. Are you sure?")}},"handleUpdatesForBoth");return{handler:i((d,S,y,C,k)=>{k.isHub?m(d,S,y,C,k):f(d,S,y,C,k),h(d,S,y,C,k)},"handler")}}i(ZS,"useUpdates");import{LegacyEvents as M0}from"@rango-dev/wallets-core/legacy";function JS(t,e){let[o,n,r,a,s]=e;n!==M0.PROVIDER_DISCONNECTED&&t(o,n,r,a,s)}i(JS,"propagateEvents");var Ya=P0({onConnectWallet:()=>{},onDisconnectWallet:()=>{}});function D0(t){let{updateConfig:e,updateSettings:o,fetch:n,fetchStatus:r}=T(),a=T().blockchains(),s=T().config,c={walletConnectProjectId:s?.walletConnectProjectId,trezorManifest:s?.trezorManifest,tonConnect:s.tonConnect,walletConnectListedDesktopWalletLink:t.config.__UNSTABLE_OR_INTERNAL__?.walletConnectListedDesktopWalletLink},{providers:l}=Bp(s.wallets,c),p=eC(),u=eC(),{handler:m}=ZS({onConnectWalletHandler:p,onDisconnectWalletHandler:u});RS(()=>{n().catch(console.log)},[]),RS(()=>{t.config&&(e(t.config),o(t.config),window.__rango={config:s,dappConfig:t.config})},[t.config,r]);let f=re.use.isActiveTab(),h=_0(()=>({onConnectWallet:g=>{p.current=g},onDisconnectWallet:g=>{u.current=g}}),[]);return Xa.createElement(Ya.Provider,{value:h},Xa.createElement(L0,{allBlockChains:a,providers:l,onUpdateState:(g,d,S,y,C)=>{let k=[g,d,S,y,C];m(...k),t.onUpdateState&&JS(t.onUpdateState,k)},autoConnect:!!f,configs:{wallets:s.wallets}},t.children))}i(D0,"Main");function Za(t){let{config:e,...o}=t;return Xa.createElement(Yu,{config:e},Xa.createElement(D0,{...o,config:e}))}i(Za,"WidgetWallets");import{globalCss as $0}from"@rango-dev/ui";var tC=i(()=>$0({"@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");import{useWallets as F0}from"@rango-dev/wallets-react";import{useEffect as O0,useRef as U0}from"react";function oC(){let{connect:t,state:e}=F0(),o=U0({}),{fetchStatus:n}=T(),r=new URLSearchParams(location.search).get("autoConnect")||"",a=e(r);O0(()=>{n==="success"&&r&&a.installed&&!a.connecting&&!a.connected&&!o.current[r]&&(o.current[r]=!0,t(r))},[a,n])}i(oC,"useForceAutoConnect");import{isApprovalTX as z0,RouteEventType as nC,StepEventType as rC,StepExecutionEventStatus as Q0,WidgetEvents as Ja}from"@rango-dev/queue-manager-rango-preset";import{useEffect as iC}from"react";function Wp(){let t=Be.use.setNotification(),{connectedWallets:e,fetchBalances:o,customTokens:n}=T();iC(()=>{let r=i(a=>{let{event:s,step:c,route:l}=a;if(s.type===rC.TX_EXECUTION&&s.status===Q0.TX_SENT&&!z0(c)||s.type===rC.SUCCEEDED){let u=[],m=l.wallets[c?.fromBlockchain];if(m){let f=e.find(h=>h.address?.toLocaleLowerCase()===m.address?.toLocaleLowerCase()&&h.walletType===m.walletType&&h.chain===c?.fromBlockchain);f&&u.push(f)}if(c?.fromBlockchain!==c?.toBlockchain){let f=l.wallets[c?.toBlockchain];if(f){let h=e.find(g=>g.address?.toLocaleLowerCase()===f.address?.toLocaleLowerCase()&&g.walletType===f.walletType&&g.chain===c?.toBlockchain);h&&u.push(h)}}if(u.length>0){let f=n(),g=[{blockchain:c.fromBlockchain,address:c.fromSymbolAddress,symbol:c.fromSymbol},{blockchain:c.toBlockchain,address:c.toSymbolAddress,symbol:c.toSymbol}].filter(d=>f.some(S=>S.blockchain===d.blockchain&&S.address?.toLocaleLowerCase()===d.address?.toLocaleLowerCase()&&S.symbol?.toLocaleLowerCase()===d.symbol?.toLocaleLowerCase()));o(u,{selectedCustomTokens:g,shouldFetchCustomTokens:g.length>0})}}t(s,l)},"handleStepEvent");return we.on(Ja.StepEvent,r),()=>we.off(Ja.StepEvent,r)},[we,e]),iC(()=>{let r=i(a=>{let{event:s,route:c}=a;(s.type===nC.FAILED||s.type===nC.SUCCEEDED)&&t(s,c)},"handleRouteEvent");return we.on(Ja.RouteEvent,r),()=>we.off(Ja.RouteEvent,r)},[we])}i(Wp,"useSubscribeToWidgetEvents");import{useManager as H0}from"@rango-dev/queue-manager-react";import{useEffect as q0}from"react";function Mp(){let{isSynced:t,syncNotifications:e}=Be(),{manager:o,state:n}=H0();q0(()=>{Be.persist.hasHydrated()&&n.loadedFromPersistor&&!t&&e(Tt(o))},[Be.persist.hasHydrated(),n.loadedFromPersistor,t])}i(Mp,"useSyncNotifications");function Pp(){oC(),tC(),Wp(),Mp();let t=T().blockchains(),{canSwitchNetworkTo:e}=Zi(),[o,n]=aC(null),[r,a]=aC(),s=K0(Ya),c=t.filter(V0);Lp(()=>()=>am(),[]),Lp(()=>()=>sm(),[]),G0({lastConnectedWallet:o,clearDisconnectedWallet:()=>{a(void 0)},disconnectedWallet:r,evmChains:c,canSwitchNetworkTo:e}),Lp(()=>(Po.init(),Be.persist.hasHydrated()||Be.persist.rehydrate(),s.onConnectWallet(l=>{n(p=>{if(!p||p.walletType!==l.walletType)return l;let u={...p};return l.network&&(u.network=l.network),l.accounts&&(u.accounts=l.accounts),u})}),s.onDisconnectWallet(l=>{a(l),n(p=>l===p?.walletType?null:p)}),Po.destroy),[])}i(Pp,"useBootstrap");import{styled as j0}from"@rango-dev/ui";var sC=j0("div",{fontFamily:"$widget",boxSizing:"border-box",textAlign:"left","& *, *::before, *::after":{boxSizing:"inherit"},"& *:focus-visible":{outlineColor:"$info500",transition:"none"},"& ul, ol, li":{listStyleType:"none"}});function Jo(){Pp();let{config:t}=T(),{activeTheme:e}=mo(t?.theme||{}),{activeLanguage:o}=wo();return _p.createElement(X0,{language:o},_p.createElement(sC,{id:"swap-container",className:e()},_p.createElement(jS,null)))}i(Jo,"Main");import{setSolanaSignerConfig as gB}from"@rango-dev/signer-solana";import $p,{useEffect as Fp,useMemo as hB}from"react";function lC(){let{setWatermark:t,setShowProfileBanner:e}=re();return{fetchApiConfig:i(async()=>{let n=await fetch(`${Gt("BASE_URL")}/meta/dapp/config?apiKey=${Gt("API_KEY")}`);if(!n.ok)throw new Error(`Request failed with status: ${n.status} `);let r=await n.json();t(r.config.watermark),e(r.config.banners.profile)},"fetchApiConfig")}}i(lC,"useFetchApiConfig");import{useState as Y0}from"react";var Z0=i(()=>{let[t,e]=Y0(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=pu(a);if(s){let c=o(s);e(c)}},"handleLoadCustomFont")}},"useFontLoader"),cC=Z0;import{checkWaitingForNetworkChange as J0,makeQueueDefinition as R0}from"@rango-dev/queue-manager-rango-preset";import{Provider as eB}from"@rango-dev/queue-manager-react";import{useWallets as tB}from"@rango-dev/wallets-react";import{convertEvmBlockchainMetaToEvmChainInfo as oB}from"@rango-dev/wallets-shared";import{isEvmBlockchain as nB}from"rango-types";import rB,{useMemo as iB}from"react";function aB(t){let{providers:e,getSigners:o,state:n,connect:r,canSwitchNetworkTo:a,getWalletInfo:s}=tB(),c=iB(()=>R0({API_KEY:t.apiKey||Gt("API_KEY"),BASE_URL:Gt("BASE_URL"),emitter:{emit:we.emit}}),[t.apiKey]),{blockchains:l,connectedWallets:p}=T(),u=l(),m={blockchains:p.map(w=>({accounts:[w],name:w.chain}))},f=i(async(w,x)=>a(w,x.network,x)?await r(w,[x]):void 0,"switchNetwork"),h=i(w=>!!s(w).mobileWallet,"isMobileWallet"),g=u.filter(w=>w.enabled).reduce((w,x)=>(w[x.name]=x,w),{}),d=u.filter(nB),S=i(w=>{let{supportedChains:x}=s(w);return jn(x)},"getSupportedChainNames"),y=e(),C={meta:{blockchains:g,evmBasedChains:d,evmNetworkChainInfo:oB(d),getSupportedChainNames:S},getSigners:o,wallets:m,providers:y,switchNetwork:f,canSwitchNetworkTo:a,state:n,isMobileWallet:h},k=re.use.isActiveTab();return rB.createElement(eB,{queuesDefs:[c],context:C,onPersistedDataLoaded:w=>{J0(w)},isPaused:!k},t.children)}i(aB,"QueueManager");var pC=aB;import{useManager as uB}from"@rango-dev/queue-manager-react";import dB,{createContext as mB,useContext as fB}from"react";function uC(){let{findToken:t}=T(),e=T().blockchains(),o=T().tokens(),{setFromBlockchain:n,setFromToken:r,setToBlockchain:a,setToToken:s,setInputAmount:c}=z()();return i(p=>{let{fromBlockchain:u,fromToken:m,toBlockchain:f,toToken:h,requestAmount:g}=p,d={blockchains:e,tokens:o};if(u!==void 0){let S=e.find(y=>y.name===u)??null;n(S)}if(m!==void 0){let S=m?t(m)??null:null;r({meta:d,token:S})}if(f!==void 0){let S=e.find(y=>y.name===f)??null;a(S)}if(h!==void 0){let S=h?t(h)??null:null;s({meta:d,token:S})}g!==void 0&&c(g)},"updateQuoteInputs")}i(uC,"useUpdateQuoteInputs");import{cancelSwap as sB,getCurrentNamespaceOfOrNull as lB,getCurrentStep as cB,getRelatedWalletOrNull as pB}from"@rango-dev/queue-manager-rango-preset";var Ra=class{static{i(this,"WidgetHistory")}constructor(e,o){this.manager=e,this.actions=o}getAllSwaps(){return Tt(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=Bi(e,o.blockchains,this.actions.findToken);return this.actions.retrySwap(n)}cancel(e){let o=this.manager?.get(e);o&&sB(o)}getCurrentStepInfo(e){let o=cB(e);return{step:o,wallet:o?pB(e,o):null,network:o?lB(e,o)?.network:null}}};var dC=mB(void 0);function Dp(t){let{manager:e}=uB(),o=re.use.isActiveTab(),n=z().use.retry(),{findToken:r,getBalances:a,getConnectedWalletsDetails:s,fetchBalances:c}=T(),l=new Ra(e,{retrySwap:n,findToken:r}),{fetchingWallets:p}=T(),u=xu(a()),m=T().blockchains(),f=T().tokens(),h=T().swappers(),g=T().fetchStatus,d=wo().resetLanguage,S=Be().getNotifications(),y=Be().clearNotifications,C=uC(),{fromBlockchain:k,toBlockchain:w,fromToken:x,toToken:I,inputAmount:A}=z()(),b={isActiveTab:o,setCurrentTabAsActive:Po.forceClaim,history:l,wallets:{isLoading:p,details:s(),totalBalance:u,refetch:async E=>c(E)},meta:{blockchains:m,tokens:f,swappers:h,loadingStatus:g,findToken:r},resetLanguage:d,notifications:{list:S,clearAll:y},quote:{quoteInputs:{fromBlockchain:k?.name??null,fromToken:x?{symbol:x.symbol,blockchain:x.blockchain,address:x.address}:null,toBlockchain:w?.name??null,toToken:I?{symbol:I.symbol,blockchain:I.blockchain,address:I.address}:null,requestAmount:A},updateQuoteInputs:C}};return dB.createElement(dC.Provider,{value:b},t.children)}i(Dp,"WidgetInfo");function mC(){let t=fB(dC);if(!t)throw new Error("useWidget can only be used within the WidgetProvider component");return t}i(mC,"useWidget");function Un(t){let{onUpdateState:e,config:o}=t,n=t.config?.theme?.fontFamily,{fetchApiConfig:r}=lC(),{handleLoadCustomFont:a}=cC();return Fp(()=>{r().catch(console.log)},[]),Fp(()=>{n&&a(n)},[n]),hB(()=>{Mu({API_KEY:o?.apiKey||ri,BASE_URL:o?.apiUrl||eu})},[o.apiKey,o.apiUrl]),Fp(()=>{t.config?.signers?.customSolanaRPC&&gB("customRPC",t.config.signers.customSolanaRPC)},[t.config?.signers?.customSolanaRPC]),$p.createElement(Za,{config:o,onUpdateState:e},$p.createElement(pC,{apiKey:o.apiKey},$p.createElement(Dp,null,t.children)))}i(Un,"WidgetProvider");function fC(t){let e=t.config?.externalWallets;return es.createElement(Ai,null,e?es.createElement(Jo,null):es.createElement(Un,{config:t.config??on},es.createElement(Jo,null)))}i(fC,"Refuel");import ts from"react";function gC(t){let e=t.config?.externalWallets;return ts.createElement(Ai,null,e?ts.createElement(Jo,null):ts.createElement(Un,{config:t.config??on},ts.createElement(Jo,null)))}i(gC,"Widget");function hC(){let{on:t,off:e}=we;return{on:t,off:e}}i(hC,"useWidgetEvents");var Ree={DerivationPath:rr,Namespaces:tr,Detached:nr,isOnDerivationPath:ar,isOnNamespace:ir,isOnDetached:Ao};export{wee as EventSeverity,sn as MainEvents,Mee as Networks,_ee as PendingSwapNetworkStatus,Ss as QuoteEventTypes,fC as Refuel,vee as RouteEventType,ls as SUPPORTED_FONTS,Ree as StatefulConnect,xee as StepEventType,bee as StepExecutionBlockedEventStatus,Eee as StepExecutionEventStatus,wd as SwapModeContext,et as UI_ID,Ts as UiEventTypes,Cs as WalletEventTypes,Bee as WalletEvents,Lee as WalletTypes,gC as Widget,sn as WidgetEvents,Un as WidgetProvider,Za as WidgetWallets,ml as customizedThemeTokens,as as pickProviderVersionWithFallbackToLegacy,Aee as readAccountAddress,Ro as useStatefulConnect,vt as useWalletList,Zi as useWallets,mC as useWidget,hC as useWidgetEvents,wT as widgetEventEmitter};
|
|
1
|
+
var vC=Object.defineProperty;var i=(t,e)=>vC(t,"name",{value:e,configurable:!0});import{EventSeverity as vee,RouteEventType as xee,StepEventType as bee,StepExecutionBlockedEventStatus as Eee,StepExecutionEventStatus as Iee}from"@rango-dev/queue-manager-rango-preset";import{legacyReadAccountAddress as Nee}from"@rango-dev/wallets-core/legacy";import{useWallets as Xi,Events as Wee}from"@rango-dev/wallets-react";import{Networks as Lee,WalletTypes as Pee}from"@rango-dev/wallets-shared";import{PendingSwapNetworkStatus as Dee}from"rango-types";import{Divider as qk}from"@rango-dev/ui";import po,{useEffect as Gk,useRef as Vk,useState as Td}from"react";import{WalletState as xC}from"@rango-dev/ui";import{useWallets as bC}from"@rango-dev/wallets-react";import{useReducer as EC}from"react";function Op(t){return!!t.derivationPath}i(Op,"isStateOnDerivationPathStep");function Up(t){return!!t.namespace}i(Up,"isStateOnNamespace");var Zr={status:"init",namespace:null,derivationPath:null,selectedNamespaces:null};function zp(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"detached":return{...t,status:"detached",namespace:{targetWallet:e.payload.targetWallet},selectedNamespaces:e.payload.selectedNamespaces};case"reset":return Zr;case"resetDerivation":return t.namespace?{...t,derivationPath:null,status:"namespace"}:Zr;default:throw new Error("Action hasn't been defined.")}}i(zp,"reducer");function Ro(){let{state:t,disconnect:e,connect:o}=bC(),[n,r]=EC(zp,Zr),a=i(async(m,f,h)=>{r({type:"reset"});try{let g=f?.map(d=>({...d,network:void 0}));return await o(m,g),{status:"connected"}}catch(g){let d=g?.message?`Error: ${g.message}`:"An unknown error happened during connecting wallet.";throw new Error(d,{cause:g})}},"runConnect"),s=i(async(m,f)=>{if(m.state===xC.DISCONNECTED){let g=!!m.isHub,d=g?m.properties?.find(y=>y.name==="namespaces")?.value:m.needsNamespace,S=g?m.properties?.find(y=>y.name==="derivationPath")?.value:m.needsDerivationPath;if(!d?.data?.length)return await a(m.type,void 0,f);if(d?.data.length&&d.data.length>1)return r({type:"needsNamespace",payload:{targetWallet:m,defaultSelectedChains:f?.defaultSelectedChains}}),{status:"namespace"};if(d?.data.length===1&&d.data[0]){if(S){let y=d.data[0];return r({type:"needsDerivationPath",payload:{providerType:m.type,providerImage:m.image,namespace:y.value}}),{status:"derivation-path"}}return await a(m.type,d?.data?.map(y=>({namespace:y.value})),f)}}if(m.isHub){let g=m.properties?.find(d=>d.name==="namespaces")?.value;if(g?.data.length&&g.data.length>1)return r({type:"detached",payload:{targetWallet:m,selectedNamespaces:null}}),{status:"Detached"}}return f?.disconnectIfConnected?(await u(m),{status:"disconnected"}):{status:"disconnected-unhandled"}},"handleConnect"),c=i(async(m,f)=>{let h=!!m.isHub,g=h?m.properties?.find(k=>k.name==="namespaces")?.value:m.needsNamespace,d=h?m.properties?.find(k=>k.name==="derivationPath")?.value:m.needsDerivationPath,S=g?.selection==="single",y=f[0];if(!y)throw new Error("To confirm a namespace, you should select at least one namespace.");if(S&&d)return r({type:"needsDerivationPath",payload:{providerType:m.type,providerImage:m.image,namespace:y}}),{status:"derivation-path"};if(!Up(n))throw new Error("Something went wrong on handling namespace. Please retry.");let C=f.map(k=>({namespace:k}));return r({type:"detached",payload:{targetWallet:m,selectedNamespaces:C??null}}),{status:"Detached"}},"handleNamespace"),l=i(async(m,f)=>{if(!f)throw new Error("Derivation path is empty. Please make sure you've filled the field correctly.");if(!Op(n))throw new Error("It seems you are filling derivation path without setting namespace before doing that. Please retry to connect.");let h=n.derivationPath.providerType,d=[{namespace:n.derivationPath.namespace,derivationPath:f}],y=!!m.isHub?m.properties?.find(C=>C.name==="namespaces")?.value:m.needsNamespace;return y?.data&&y.data.length>1?(r({type:"detached",payload:{targetWallet:m,selectedNamespaces:d??null,derivationPath:f}}),{status:"Detached"}):await a(h,d)},"handleDerivationPath"),p=i(()=>n,"getState"),u=i(async m=>{let f=t(m.type);return f.connected||f.connecting?(await e(m.type),Ao(p)?(r({type:"needsNamespace",payload:{targetWallet:m}}),{status:"namespace"}):{status:"disconnected"}):{status:"noop"}},"handleDisconnect");return{handleConnect:s,handleDisconnect:u,handleNamespace:c,handleDerivationPath:l,getState:p,resetState:m=>{r(m==="derivation"?{type:"resetDerivation"}:{type:"reset"})}}}i(Ro,"useStatefulConnect");import{WalletState as Es}from"@rango-dev/ui";import{useWallets as $T}from"@rango-dev/wallets-react";import{detectMobileScreens as FT,KEPLR_COMPATIBLE_WALLETS as OT,WalletTypes as Zn}from"@rango-dev/wallets-shared";import{useCallback as UT,useEffect as zT}from"react";import MT,{createContext as LT,useContext as PT,useEffect as _T,useRef as DT}from"react";import{create as BT}from"zustand";import{persist as WT}from"zustand/middleware";import{allProviders as IC}from"@rango-dev/provider-all";var ns=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()}},en=new ns;import{defineVersions as Qp,pickVersion as qp,Provider as rs}from"@rango-dev/wallets-core";function Gp({allProviders:t,configWallets:e}){if(e){let o=[];return e.forEach(n=>{if(typeof n=="string"){let r=t.find(a=>{let s=is(a);return s instanceof rs?s.id===n:s.config.type===n});r?o.push(r):console.warn(`Couldn't find ${n} provider. Please make sure you are passing the correct name.`)}else n instanceof rs?o.push(Qp().version("1.0.0",n).build()):o.push(Qp().version("0.0.0",n).build())}),o}return t}i(Gp,"matchAndGenerateProviders");function is(t){try{return qp(t,"1.0.0")[1]}catch{return qp(t,"0.0.0")[1]}}i(is,"pickProviderVersionWithFallbackToLegacy");function Vp(t){return t.map(o=>is(o)).map(o=>o instanceof rs?o.id:o.config.type)}i(Vp,"configWalletsToWalletName");function Jr(t,e){return e.find(o=>o.name===t)?.displayName}i(Jr,"getBlockchainDisplayNameFor");function ht(t,e){return e.find(o=>o.name===t)?.shortName}i(ht,"getBlockchainShortNameFor");function Kp(t,e){return e.find(o=>o.name===t)?.logo}i(Kp,"getBlockchainImage");function Hn(t,e){return e.find(o=>o.id===t)?.title}i(Hn,"getSwapperDisplayName");function No(t,e){return e.find(o=>o.name===t)??null}i(No,"findBlockchain");function as(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(as,"isTokenNative");function yt(t){return`${t.blockchain.toLowerCase()}-${t.symbol.toLowerCase()}-${(t.address??"").toLowerCase()}`}i(yt,"createTokenHash");function tn(t,e){return t.addressPatterns.filter(r=>new RegExp(r).test(e)).length>0}i(tn,"isValidTokenAddress");function Qn(t){let{config:e,meta:o}=t,n={},r=e.tokens,a=i(c=>{c.forEach(l=>{typeof l!="string"&&(l=yt(l));let p=o.tokensMapByTokenHash.get(l);p&&(n[l]=p)})},"addTokens");if(Array.isArray(r))return r.length>0?(a(r),Object.values(n)):Array.from(o.tokensMapByTokenHash.values());if(!r)return Array.from(o.tokensMapByTokenHash.values());let s;if(e.blockchains?.length)s=e.blockchains;else{s=Object.keys(r);let c=new Set(s);Object.keys(o.tokensMapByBlockchainName).forEach(l=>{let p=o.tokensMapByBlockchainName[l];!c.has(l)&&p&&a(p)})}return s.forEach(c=>{let l=r[c];if(!l&&o.tokensMapByBlockchainName?.[c]){a(o.tokensMapByBlockchainName[c]);return}l&&(l.isExcluded&&o.tokensMapByBlockchainName[c]?(a(o.tokensMapByBlockchainName[c]),l.tokens.forEach(p=>{let u=yt(p);delete n[u]})):a(l.tokens))}),Object.values(n)}i(Qn,"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");function Xp(t){return{walletConnectProjectId:t?.walletConnectProjectId,trezorManifest:t?.trezorManifest,tonConnect:t?.tonConnect,walletConnectListedDesktopWalletLink:t.__UNSTABLE_OR_INTERNAL__?.walletConnectListedDesktopWalletLink}}i(Xp,"makeProvidersOptionsFromConfig");var on={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"}},AC={clientUrl:void 0},NC={liquiditySources:void 0};function jp(t){let e=Xp(t),o={walletconnect2:{WC_PROJECT_ID:e?.walletConnectProjectId||"",DISABLE_MODAL_AND_OPEN_LINK:e?.walletConnectListedDesktopWalletLink},selectedProviders:t.wallets,trezor:e?.trezorManifest?{manifest:e.trezorManifest}:void 0,tonConnect:e?.tonConnect?.manifestUrl?{manifestUrl:e?.tonConnect.manifestUrl}:void 0};return IC(o).map(a=>a())}i(jp,"generateProviders");var Yp=i((t,e,o)=>{let n=jp({...on,...t});return{config:{...on,...t},iframe:AC,campaignMode:NC,allProviders:n,getLiquiditySources:()=>{let{config:r,campaignMode:a}=o();return a.liquiditySources?.length?a.liquiditySources:r.liquiditySources??[]},getDisabledLiquiditySources:()=>{let{disabledLiquiditySources:r,campaignMode:a}=o();return a.liquiditySources?.length?[]:r},excludeLiquiditySources:()=>{let{config:r,campaignMode:a}=o();return a.liquiditySources?.length?!1:!!r.excludeLiquiditySources},isInCampaignMode:()=>{let{campaignMode:r}=o();return!!r.liquiditySources?.length},updateConfig:r=>{let a=o().config,{_tokensMapByTokenHash:s,_tokensMapByBlockchainName:c}=o(),l=Qn({type:"source",config:{blockchains:r.from?.blockchains,tokens:r.from?.tokens},meta:{tokensMapByBlockchainName:c,tokensMapByTokenHash:s}}),p=Qn({type:"destination",config:{blockchains:r.to?.blockchains,tokens:r.to?.tokens},meta:{tokensMapByBlockchainName:c,tokensMapByTokenHash:s}});en.set("supportedSourceTokens",l),en.set("supportedDestinationTokens",p),e({config:{...a,...r}})},updateCampaignMode:(r,a)=>{let s=o().campaignMode;e({campaignMode:{...s,[r]:a}})},updateIframe:(r,a)=>{let s=o().iframe;e({iframe:{...s,[r]:a}})},buildAndSetProviders:()=>{let{config:r}=o(),a=jp(r);e({allProviders:a})},getAvailableProviders:()=>{let{allProviders:r,config:a}=o(),s=Xp(a);return Gp({allProviders:r,configWallets:a.wallets,options:s})}}},"createConfigSlice");import{TransactionType as Zp}from"rango-types";var Jp=[Zp.EVM,Zp.SOLANA],ei="https://raw.githubusercontent.com/rango-exchange/assets/refs/heads/main/common/unknown-image.png";import{RangoClient as GC}from"rango-sdk";import{UI_ID as BC}from"@rango-dev/ui";var ti="c6381a79-2817-4602-83bf-6a641a409e32",Rp="https://api.rango.exchange",eu="https://explorer.rango.exchange",Re={SWAP_BOX_ID:"rango-swap-box",EXPANDED_BOX_ID:"rango-expanded-box",...BC};import{BlockchainCategories as $C,WalletState as lt}from"@rango-dev/ui";import{legacyReadAccountAddress as FC}from"@rango-dev/wallets-core/legacy";import{detectInstallLink as OC,getCosmosExperimentalChainInfo as UC,isEvmAddress as zC,KEPLR_COMPATIBLE_WALLETS as WW,Networks as ku}from"@rango-dev/wallets-shared";import rn from"bignumber.js";import{isCosmosBlockchain as HC}from"rango-types";import WC from"bignumber.js";var pe=new WC(0);import{WalletTypes as MC}from"@rango-dev/wallets-shared";var Bo="~",tu=[MC.LEAP];import{BlockchainCategories as ls,WalletState as DC}from"@rango-dev/ui";import{TransactionType as oi}from"rango-sdk";var ou="Roboto",ss=[{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 nn(t){return Array.from(new Set(t))}i(nn,"removeDuplicateFrom");function ni(t,e){let o;return n;function n(...r){o&&clearTimeout(o),o=setTimeout(()=>{o=null,t(...r)},e)}}i(ni,"debounce");function st(t,e){return t.toLowerCase().indexOf(e.toLowerCase())>-1}i(st,"containsText");function iu(t,e){return t.toLowerCase()===e.toLowerCase()}i(iu,"exactText");function au(t,e){return t.toLowerCase().startsWith(e.toLowerCase())}i(au,"startWithText");var B=i(()=>document.getElementById(Re.SWAP_BOX_ID),"getContainer"),Wo=i(()=>document.getElementById(Re.EXPANDED_BOX_ID),"getExpanded");function su(t,e,o){let n=!!e&&iu(e,t),r=!!o&&iu(o,t);return n!==r?n?-1:1:0}i(su,"compareExactMatchText");function cs(t,e,o){let n=!!e&&st(e,t),r=!!o&&st(o,t);return n!==r?n?-1:1:n&&r&&e?.length!==o?.length?e?.length-o?.length:0}i(cs,"compareContainsText");function ps(t,e,o){let n=!!e&&au(e,t),r=!!o&&au(o,t);return n!==r?n?-1:1:n&&r&&e?.length!==o?.length?e?.length-o?.length:0}i(ps,"compareStartWithText");function lu(t,e,o){if(!o)return 0;let n=su(o,t.symbol,e.symbol);if(n)return n;if(o.length>=3){let r=su(o,t.name,e.name);if(r)return r}if(o.length>=2){let r=ps(o,t.symbol,e.symbol);if(r)return r}if(o.length>=3){let r=cs(o,t.symbol,e.symbol);if(r)return r}if(o.length>=3){let r=ps(o,t.name,e.name);if(r)return r}if(o.length>=3){let r=cs(o,t.name,e.name);if(r!==0)return r}if(o.length>=4){let r=ps(o,t.address,e.address);if(r)return r}if(o.length>=4){let r=cs(o,t.address,e.address);if(r!==0)return r}return 0}i(lu,"compareWithSearchFor");var ri=i((t,e)=>{switch(e){case ls.ALL:return!0;case ls.UTXO:return t===oi.TRANSFER;case ls.OTHER:return t!==oi.TRANSFER&&t!==oi.COSMOS&&t!==oi.EVM;default:return t===e}},"isBlockchainTypeInCategory"),cu=i(t=>ss.find(o=>o.value===t)?.url,"getFontUrlByName");function pu(t,e){let o=!!t.find(n=>n.state===DC.CONNECTED);return e===!1&&o}i(pu,"isSingleWalletActive");function uu(){let t,e;return(o,n)=>((!e||!t||t!==n)&&(t=n,e=o()),e)}i(uu,"memoizedResult");import{BigNumber as Cu}from"bignumber.js";function du(t){return t.replace(/^0+(?=\d)/g,"")}i(du,"removeLeadingZeros");function mu(t){return t.replace(/^\.(\d+)/,"0.$1")}i(mu,"ensureLeadingZeroForDecimal");function fu(t){return t.replace(/\B(?=(\d{3})+(?!\d))/g,",")}i(fu,"formatThousandsWithCommas");function gu(t){return t.replace(/\s+/g,"-")}i(gu,"replaceSpacesWithDash");function hu(t){return t.replace(/(\.\d*?[1-9])0+$/,"$1").replace(/\.0+$/,"")}i(hu,"stripTrailingZeros");function ii(t){return/^0+(?:\.0+)?$/.test(t)}i(ii,"isZeroValue");function yu(t,e=2){let o=`^(?:0|[1-9]\\d*)(?:\\.\\d{1,${e}})?$`;return new RegExp(o).test(t)}i(yu,"isValidCurrencyFormat");function Su(t){return/\d+$/.test(t)}i(Su,"isColorKeyOverridden");var qn=i(t=>{let e=Math.floor(t%60/15)*15,o=parseInt((t/60).toString());return o>=60?`${Math.floor(o/5)*5}:00`:`${o.toString().padStart(2,"0")}:${e.toString().padStart(2,"0")}`},"roundedSecondsToString"),P=i((t,e=null,o=null)=>{if(t==null||t==="")return"";let n=new Cu(t),r=1,a=1e3;for(let s=0;s<60;s++)if(new Cu(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 ai=i(t=>t?.reduce((e,o)=>e+(o.estimatedTimeInSeconds??0),0)||0,"totalArrivalTime");var Pt=i((t,e)=>t.toLowerCase().indexOf(e.toLowerCase())>-1,"containsText"),Gn=i(t=>!!t&&parseFloat(t)>0,"isPositiveNumber");function Tu(t){return ii(t)?"0":hu(t)}i(Tu,"sanitizeInputAmount");function Vn(t,e){return qC(t,e)?lt.PARTIALLY_CONNECTED:e.connected?lt.CONNECTED:e.connecting?lt.CONNECTING:e.installed?lt.DISCONNECTED:lt.NOT_INSTALLED}i(Vn,"getWalletConnectionStatus");function wu(t,e,o,n){return o.filter(r=>!tu.includes(r)).filter(r=>{let{supportedChains:a,isContractWallet:s}=e(r),{installed:c,network:l}=t(r);return s&&(!c||!!n&&l!==n)?!1:n?!!a.find(u=>u.name===n):!0}).map(r=>{let{name:a,img:s,installLink:c,showOnMobile:l,needsNamespace:p,supportedChains:u,needsDerivationPath:m,properties:f,isHub:h}=e(r),g=nn(u.map(S=>S.type)),d=Vn(e(r),t(r));return{title:a,image:s,link:OC(c),state:d,type:r,showOnMobile:l,needsNamespace:p,blockchainTypes:g,needsDerivationPath:m,properties:f,isHub:h}})}i(wu,"mapWalletTypesToWalletInfo");function Kn(t){if(!t)return null;let e=[];return e=t.map(o=>o.name),e}i(Kn,"walletAndSupportedChainsNames");function ds(t,e,o,n,r){let a=[];function s(l,p,u){if(!!!a.find(f=>f.chain===l)){let f={address:p,chain:l,walletType:t,isContractWallet:u??!1};a.push(f)}}i(s,"addAccount");let c=n||[];return e.forEach(l=>{let{address:p,network:u}=FC(l),m=c.length>0,f=c.includes(u),h=u===ku.Unknown;if(m&&!f&&!h)return;let d=u===ku.Unknown&&zC(p);if(h&&!d)return;o.includes(u)||d?r?s(u,p.toLowerCase(),r):c.filter(C=>o.includes(C)).forEach(C=>{s(C,p.toLowerCase())}):s(u,p)}),a}i(ds,"prepareAccountsForWalletStore");function Mo(t){let{filter:e,quote:o}=t,n=new Set;return o?.swaps.forEach((r,a)=>{let s=r.from.blockchain,c=r.to.blockchain;if(n.add(s),r.internalSwaps){let{internalSwaps:l}=r;l.forEach((p,u)=>{let m=p.from.blockchain,f=p.to.blockchain,h=a===o.swaps.length-1,g=u===l.length-1;(!h&&!g||h&&c!==m||e==="all")&&n.add(m),e==="all"&&n.add(f)})}e==="all"&&n.add(c)}),Array.from(n)}i(Mo,"getQuoteChains");function jn(t,e){return t.address===e.address&&t.chain===e.chain&&t.walletType===e.walletType}i(jn,"isAccountAndWalletMatched");var vu=i(t=>{let e=Object.values(t).reduce((o,n)=>{let r=n.usdValue?us(n.usdValue,n.decimals):pe.toFixed();return o.plus(r)},new rn(pe));return QC(e.toString())},"calculateWalletUsdValue");function QC(t){let e=t.toString().split(".");return e[0]&&(e[0]=fu(e[0])),e.join(".")}i(QC,"numberWithThousandSeparator");var ci=i((t,e)=>{let o=UC(Object.entries(t).map(([,n])=>n).filter(HC));return o&&!!o[e]?.experimental},"isExperimentalChain");function us(t,e){return new rn(t).shiftedBy(-e).toFixed()}i(us,"representAmountInNumber");function pi(t){if(!t)return null;let e=us(t.amount,t.decimals),o=t.usdValue?us(t.usdValue,t.decimals):null,n=P(e,8,8),r=o?P(o,4,4):null;return t?{...t,amount:n,usdValue:r}:null}i(pi,"formatBalance");function xu(t,e){if(t?.usdValue||e?.usdValue){let o=t&&t.usdValue?new rn(t.usdValue).shiftedBy(-t.decimals):pe,n=e&&e.usdValue?new rn(e.usdValue).shiftedBy(-e.decimals):pe;return o.isEqualTo(n)?0:o.isGreaterThan(n)?-1:1}if(t?.amount||e?.amount){let o=t&&t.amount?new rn(t.amount).shiftedBy(-t.decimals):pe,n=e&&e.amount?new rn(e.amount).shiftedBy(-e.decimals):pe;return o.isEqualTo(n)?0:o.isGreaterThan(n)?-1:1}return 0}i(xu,"compareTokenBalance");function qt(t,e){return t?.blockchain===e?.blockchain&&t?.symbol.toLowerCase()===e?.symbol.toLowerCase()&&t?.address?.toLowerCase()===e?.address?.toLowerCase()}i(qt,"areTokensEqual");function bu(t){return t.sort((e,o)=>+(o.state===lt.CONNECTED)-+(e.state===lt.CONNECTED)||+(o.state===lt.PARTIALLY_CONNECTED)-+(e.state===lt.PARTIALLY_CONNECTED)||+(o.state===lt.DISCONNECTED||o.state===lt.CONNECTING)-+(e.state===lt.DISCONNECTED||e.state===lt.CONNECTING))}i(bu,"sortWalletsBasedOnConnectionState");function lo(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(lo,"getConciseAddress");function Eu({chain:t,connectedWallets:e,walletType:o}){return e.find(n=>n.walletType===o&&n.chain===t)?.address}i(Eu,"getAddress");var Iu=i((t,e)=>!!t.find(o=>o.chain===e&&o.loading),"isFetchingBalance");function Au(t){return t.map(e=>e.state).join("-")}i(Au,"hashWalletsState");function Nu(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(Nu,"filterBlockchainsByWalletTypes");function Bu(t,e){return e===$C.ALL?t:t.filter(o=>{for(let n of o.blockchainTypes)if(ri(n,e))return!0;return!1})}i(Bu,"filterWalletsByCategory");function qC(t,e){if(!t.isHub||!t.needsNamespace||!e.connected)return!1;let n=t.needsNamespace.data.filter(r=>!r.unsupported);return t.needsNamespace.selection==="multiple"&&n.some(r=>!e.namespaces?.get(r.value)?.connected)}i(qC,"checkIsWalletPartiallyConnected");var ms={API_KEY:ti};function Gt(t){return ms[t]||""}i(Gt,"getConfig");function Wu(t){let e;return typeof structuredClone=="function"?e=structuredClone(t):e=JSON.parse(JSON.stringify(t)),ms=e,ms}i(Wu,"initConfig");var Mu=20,Lu=25,fs="theme-widget",gs=i((t,e)=>{let o=!1;if(e&&t){if(Array.isArray(e))o=!e.some(n=>qt(n,t));else if(!Array.isArray(e)){let n=e[t.blockchain];if(n){o=!!n.tokens.some(a=>qt(a,t));let r=n.isExcluded;return!r&&!o||r&&o}}}return o},"isTokenExcludedInConfig"),hs=i((t,e)=>t&&e&&!e.includes(t.name),"isBlockchainExcludedInConfig"),Pu=i((t,e,o)=>o==="expanded"&&(t||e)||o==="full-expanded"&&e,"isVariantExpandable");var ui,ct=i(()=>ui||(ui=new GC(Gt("API_KEY"),Gt("BASE_URL")),ui),"httpService");import{i18n as Du}from"@lingui/core";var di=[.5,1,3],mi=1,an=5,Xn=30,fi=0;var Ye=(a=>(a[a.NO_RESULT=0]="NO_RESULT",a[a.REQUEST_FAILED=1]="REQUEST_FAILED",a[a.REQUEST_CANCELED=2]="REQUEST_CANCELED",a[a.BRIDGE_LIMIT=3]="BRIDGE_LIMIT",a[a.INSUFFICIENT_SLIPPAGE=4]="INSUFFICIENT_SLIPPAGE",a))(Ye||{});import{WidgetEvents as _u}from"@rango-dev/queue-manager-rango-preset";var ys=(o=>(o.QUOTE_INPUT_UPDATE="quoteInputUpdate",o.QUOTE_OUTPUT_UPDATE="quoteOutputUpdate",o))(ys||{}),Ss=(o=>(o.CONNECT="connect",o.DISCONNECT="disconnect",o))(Ss||{}),Cs=(e=>(e.CLICK_CONNECT_WALLET="clickConnectWallet",e))(Cs||{}),sn=(a=>(a[a.RouteEvent=_u.RouteEvent]="RouteEvent",a[a.StepEvent=_u.StepEvent]="StepEvent",a.QuoteEvent="quoteEvent",a.WalletEvent="walletEvent",a.UiEvent="uiEvent",a))(sn||{});function gi(t,e){let o=t.map(a=>a.swapperGroup),n=[];return nn(t.map(a=>a.swapperGroup)).map(a=>{let s=t.find(c=>c.swapperGroup===a);if(s){let c=!0;o&&(c=o.some(l=>l===s.swapperGroup)),c&&s.types.map(l=>{n.push({id:s.swapperGroup,groupTitle:s.swapperGroup,logo:s.logo,type:l,selected:!e.includes(s.swapperGroup)})})}}),n}i(gi,"getUniqueSwappersGroups");function $u(t,e){return t.swapperGroup<e.swapperGroup?-1:t.swapperGroup>e.swapperGroup?1:0}i($u,"sortLiquiditySourcesByGroupTitle");function et(t,e){return e?.[t]==="hidden"}i(et,"isFeatureHidden");function ln(t,e){return e?.[t]==="enabled"}i(ln,"isRoutingEnabled");var Fu=i((t,e,o)=>et("customTokens",o)?t:t.concat(e),"addCustomTokensToSupportedTokens");function cn(t){return t==fi?{type:"error",message:Du.t("Slippage must be greater than or equal to 0.01")}:t>an&&t<=Xn?{type:"warning",message:Du.t("Your transaction is at risk of being frontrun due to high slippage tolerance."),quoteValidation:{type:3,slippage:t.toString()}}:null}i(cn,"getSlippageValidation");var Ou=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 l=Rr({config:a}),p=r;return l.length>0&&(p=p.filter(u=>l.includes(u.name))),p.filter(u=>Jp.includes(u.type))}let s=(o.type==="source"?a.from?.blockchains:a.to?.blockchains)??[];return r.filter(l=>!(s.length>0&&!s.includes(l.name)))},tokens:o=>{let{_tokensMapByTokenHash:n,_tokensMapByBlockchainName:r,config:a,_customTokens:s}=e(),c=Array.from(n.values()),l=e()._blockchainsMapByName;if(!o||!o.type)return c;let p=o.type==="source"?"from":"to",u=o.type==="source"?"supportedSourceTokens":"supportedDestinationTokens",m=en.get(u);m?.length||(m=Qn({type:o.type,config:{blockchains:a[p]?.blockchains,tokens:a[p]?.tokens},meta:{tokensMapByTokenHash:n,tokensMapByBlockchainName:r}}),en.set(u,m)),m=Fu(m,s,a.features);let f=e().blockchains({type:o.type});return m.filter(g=>o.blockchain&&g.blockchain!==o.blockchain||!f.some(d=>d.name===g.blockchain)?!1:o.searchFor?!!(st(g.symbol,o.searchFor)||st(g.address||"",o.searchFor)||st(g.name||"",o.searchFor)):!0).sort((g,d)=>{let S=e().isTokenPinned(g,o.type),y=e().isTokenPinned(d,o.type);if(S!==y)return S?-1:1;if(o.getBalanceFor){let I=o.getBalanceFor(g),A=o.getBalanceFor(d),b=xu(I,A);if(b!==0)return b}let C=l.get(g.blockchain),k=l.get(d.blockchain),w=as(g,C),x=as(d,k);if(w!==x)return w?-1:1;if(g.isPopular!==d.isPopular)return g.isPopular?-1:1;if(o.searchFor){let I=lu(g,d,o.searchFor);if(I)return I}return g.isSecondaryCoin!==d.isSecondaryCoin?g.isSecondaryCoin?1:-1:C&&k?C.sort-k.sort:0})},findToken:o=>{let n=e()._tokensMapByTokenHash,r=e().customTokens(),a=yt(o),s=n.get(a);return s||(s=r.find(c=>yt(c)===a)),s},findNativeToken:o=>{let n=o.feeAssets[0];return e().findToken({blockchain:o.name,address:n.address,symbol:n.symbol})},isTokenPinned:(o,n)=>!!(n==="source"?e().config.from?.pinnedTokens:e().config.to?.pinnedTokens)?.some(s=>qt(s,o)),swappers:()=>{let{config:o,campaignMode:n}=e(),r=n.liquiditySources?.length?n.liquiditySources:null,a=r??o.liquiditySources,s=r?!1:o.excludeLiquiditySources;return e()._swappers.filter(p=>{let u=a?.includes(p.swapperGroup);return s||!a||a.length===0?!u:u}).sort($u)},fetch:async()=>{try{let{routing:o}=e().config,n=ln("enableCentralizedSwappers",o),r=await ct().getAllMetadata({enableCentralizedSwappers:n});t({fetchStatus:"success"});let a=new Map,s=new Map,c={},l=[],p=r.popularTokens,u=r.swappers.filter(h=>h.enabled),m=new Set;r.tokens.forEach(h=>{m.add(h.blockchain),l.push(h)}),r.blockchains.sort((h,g)=>h.sort-g.sort).forEach(h=>{h.enabled&&m.has(h.name)&&a.set(h.name,h)}),l.forEach(h=>{let g=yt(h);c[h.blockchain]||(c[h.blockchain]=[]),s.set(g,h),c[h.blockchain]?.push(g)}),t({_blockchainsMapByName:a,_tokensMapByTokenHash:s,_tokensMapByBlockchainName:c,_popularTokens:p,_swappers:u})}catch(o){throw t({fetchStatus:"failed"}),o}}}),"createDataSlice");import{Bengali as VC,Catalonia as KC,Chinese as Uu,Denmark as jC,English as XC,Finland as YC,French as ZC,German as JC,Greece as RC,Hungary as eT,India as tT,Indonesian as oT,Italian as nT,Japanese as rT,Korea as iT,Lithuania as aT,Malay as sT,Netherlands as lT,Pakistan as cT,Philippines as pT,Poland as uT,Portuguese as dT,Russian as mT,SaudiArabia as fT,Serbia as gT,Slovakia as hT,SouthAfrica as yT,Spanish as ST,Swahili as CT,Swedish as TT,Thai as kT,Turkish as wT,Ukrainian as vT,Vietnamese as xT}from"@rango-dev/ui";var zu=[{title:"Afrikaans",label:"Afrikaans",local:"af",SVGFlag:yT},{title:"Arabic",label:"\u0639\u0631\u0628\u064A",local:"ar",SVGFlag:fT},{title:"Bengali",label:"\u09AC\u09BE\u0982\u09B2\u09BE",local:"bn",SVGFlag:VC},{title:"Catalan",label:"Catal\xE0",local:"ca",SVGFlag:KC},{title:"Chinese (Simplified)",label:"\u7B80\u4F53\u4E2D\u6587",local:"zh-CN",SVGFlag:Uu},{title:"Chinese (Traditional)",label:"\u4E2D\u6587\uFF08\u7E41\u9AD4)",local:"zh-TW",SVGFlag:Uu},{title:"Danish",label:"Dansk",local:"da",SVGFlag:jC},{title:"Dutch",label:"Nederlands",local:"nl",SVGFlag:lT},{title:"English",label:"English",local:"en",SVGFlag:XC},{title:"Filipino",label:"Filipino",local:"fil",SVGFlag:pT},{title:"Finnish",label:"Suomalainen",local:"fi",SVGFlag:YC},{title:"French",label:"Fran\xE7ais",local:"fr",SVGFlag:ZC},{title:"German",label:"Deutsch",local:"de",SVGFlag:JC},{title:"Greek",label:"\u03B5\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AC",local:"el",SVGFlag:RC},{title:"Hindi",label:"\u0939\u093F\u0902\u0926\u0940",local:"hi",SVGFlag:tT},{title:"Hungarian",label:"Magyar",local:"hu",SVGFlag:eT},{title:"Indonesian",label:"Indonesia",local:"id",SVGFlag:oT},{title:"Italian",label:"Italiana",local:"it",SVGFlag:nT},{title:"Japanese",label:"\u65E5\u672C\u8A9E",local:"ja",SVGFlag:rT},{title:"Korean",label:"\uD55C\uAD6D\uC778",local:"ko",SVGFlag:iT},{title:"Lithuanian",label:"Lietuvi\u0173",local:"lt",SVGFlag:aT},{title:"Malay",label:"Melayu",local:"ms",SVGFlag:sT},{title:"Polish",label:"Polski",local:"pl",SVGFlag:uT},{title:"Portuguese",label:"Portugu\xEAs",local:"pt",SVGFlag:dT},{title:"Russian",label:"\u0420\u0443\u0441\u0441\u043A\u0438\u0439",local:"ru",SVGFlag:mT},{title:"Serbian",label:"C\u0440\u043F\u0441\u043A\u0438",local:"sr",SVGFlag:gT},{title:"Slovak",label:"Slovensk\xFD",local:"sk",SVGFlag:hT},{title:"Spanish",label:"Espa\xF1ol",local:"es",SVGFlag:ST},{title:"Swahili",label:"Kiswahili",local:"sw",SVGFlag:CT},{title:"Swedish",label:"Svenska",local:"sv",SVGFlag:TT},{title:"Thai",label:"\u0E41\u0E1A\u0E1A\u0E44\u0E17\u0E22",local:"th",SVGFlag:kT},{title:"Turkish",label:"T\xFCrk\xE7e",local:"tr",SVGFlag:wT},{title:"Ukrainian",label:"Y\u043A\u0440\u0430\u0457\u043D\u0456",local:"uk",SVGFlag:vT},{title:"Urdu",label:"\u0627\u0631\u062F\u0648",local:"ur",SVGFlag:cT},{title:"Vietnamese",label:"Ti\u1EBFng Vi\u1EC7t",local:"vi",SVGFlag:xT}],pn="en";var Hu=i((t,e)=>({disabledLiquiditySources:[],theme:"auto",language:null,preferredBlockchains:[],slippage:mi,customSlippage:null,infiniteApprove:!1,affiliateRef:null,affiliatePercent:null,affiliateWallets:null,_customTokens:[],quoteTokensRate:"default",changeQuoteTokensRate:()=>t(o=>({quoteTokensRate:o.quoteTokensRate==="default"?"reversed":"default"})),addPreferredBlockchain:o=>{let n=e().preferredBlockchains;if(n.find((s,c)=>{let l=s===o,p=c<=9;return l&&p}))return;let a=n.filter(s=>!(s===o));t(()=>({preferredBlockchains:[o,...a]}))},setSlippage:o=>t(()=>({slippage:o})),setCustomSlippage:o=>t(()=>({customSlippage:o})),setAffiliateRef:o=>t(()=>({affiliateRef:o})),setAffiliatePercent:o=>t(()=>({affiliatePercent:o})),setAffiliateWallets:o=>t(()=>({affiliateWallets:o})),toggleAllLiquiditySources:(o,n)=>t(r=>{if(n)return{disabledLiquiditySources:[]};let a=nn(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=et("theme",n),s=et("language",n),c=et("liquiditySource",n),l=r?.singleTheme,p=o?.__UNSTABLE_OR_INTERNAL__?.autoUpdateSettings;t({...a&&{theme:o.theme?.mode||"auto"},...l&&{theme:o.theme?.mode||"light"},...s&&{language:o.language||pn},...c&&{disabledLiquiditySources:o.liquiditySources||[]},...p&&{language:o.language||pn}})},setCustomToken:o=>{e().fetchCustomTokensBalances({tokens:[o],connectedWallets:e().connectedWallets}),t(n=>({_customTokens:[o,...n._customTokens]}))},deleteCustomToken:o=>t(n=>({_customTokens:n._customTokens.filter(r=>r.address!==o.address)})),customTokens:()=>{let o=e().config,n=e()._customTokens,r=Rr({config:o});return r.length?n.filter(a=>r.includes(a.blockchain)):n}}),"createSettingsSlice");import bs from"bignumber.js";import bT from"mitt";var we=bT(),ET={on:we.on,off:we.off};var Qu=i(t=>(e,o,n)=>t(i((...a)=>{let[s,...c]=a;e(l=>({...typeof s=="function"?s(l):s,lastUpdatedAt:+new Date}),...c)},"modifedSet"),o,n),"keepLastUpdated");import qu from"bignumber.js";function Vt(t){return`${t.blockchain}${Bo}${t.address}${Bo}${t.symbol}`}i(Vt,"createAssetKey");function Gu(t,e){return`${Vt(e)}${Bo}${t}`}i(Gu,"createBalanceKey");function Yn(t){let[e,o,n]=t.split(Bo);return!e||!o||!n?null:{address:o==="null"?null:o,blockchain:e,symbol:n}}i(Yn,"extractAssetFromBalanceKey");function ks(t,e,o){return e.balances?.forEach(n=>{let r=n.price??t.findToken(n.asset)?.usdPrice;t._aggregatedBalances[Vt(n.asset)]?.forEach(s=>{o[s]&&(o[s]={...o[s],usdValue:r?new qu(r??pe).multipliedBy(o[s].amount).toString():""})})}),o}i(ks,"computeNextBalancesWithNewPrices");function ws(t,e){let o={};return t.balances?.forEach(n=>{let r=Gu(t.address,n.asset),a=n.amount.amount,s=n.amount.decimals,c=n.price??e().findToken(n.asset)?.usdPrice,l=c?new qu(c??pe).multipliedBy(a).toString():"",p={amount:a,decimals:s,usdValue:l};o[r]=p}),o}i(ws,"createBalanceStateForNewAccount");function vs(t,e){for(let o in e){let n=Yn(o);if(n){let r=Vt(n);t[r]||(t[r]=[]),t[r].includes(o)||(t[r]=[...t[r],o])}}return t}i(vs,"updateAggregatedBalanceStateForNewAccount");function IT(t,e){let o=Yn(e);if(!o)return t;let n=Vt(o);return t[n]&&(t[n]=t[n].filter(r=>r!==e)),t}i(IT,"removeBalanceFromAggregatedBalance");function xs(t,e,o){let n=t.connectedWallets.filter(l=>l.walletType===e);t.connectedWallets.forEach(l=>{l.walletType!==e&&(n=n.filter(p=>!(p.chain===l.chain&&p.address===l.address)))}),o?.chains&&o.chains.length>0&&(n=n.filter(l=>o.chains?.includes(l.chain))),o?.namespaces&&o.namespaces.length>0&&(n=n.filter(l=>l.namespace?o.namespaces?.includes(l.namespace):!1));let r={},a=t._aggregatedBalances,s=t._balances;return Object.keys(s).forEach(l=>{let p=Yn(l);if(!p)return;!!n.find(m=>Gu(m.address,{address:p.address,blockchain:m.chain,symbol:p.symbol})===l)?a=IT(a,l):s[l]&&(r[l]=s[l])}),{_balances:r,_aggregatedBalances:a}}i(xs,"computeNextStateAfterWalletBalanceRemoval");function AT(t,e){return e.find(o=>t.address===o.address&&t.chain===o.blockChain)}i(AT,"matchWalletDetailsWithConnectedWallet");var NT=uu(),Vu=Qu((t,e)=>({_balances:{},_aggregatedBalances:{},connectedWallets:[],fetchingWallets:!1,lastUpdatedAt:+new Date,setConnectedWalletAsRefetching:o=>{t(n=>({fetchingWallets:!0,connectedWallets:n.connectedWallets.map(r=>o.find(a=>jn(a,r))?{...r,loading:!0,error:!1}:r)}))},setConnectedWalletRetrievedData:(o,n)=>{t(r=>({fetchingWallets:!1,connectedWallets:r.connectedWallets.map(a=>o.find(s=>jn(s,a))?{...a,loading:!1,error:!1,explorerUrl:AT(a,n)?.explorerUrl||a.explorerUrl}:a)}))},setConnectedWalletHasError:o=>{t(n=>({fetchingWallets:!1,connectedWallets:n.connectedWallets.map(r=>o.find(a=>jn(a,r))?{...r,loading:!1,error:!0}:r)}))},addConnectedWallet:(o,n,r)=>{let a=e().connectedWallets,s=o.filter(c=>!a.some(l=>jn(c,l)));if(s.length>0){let c=s.map(l=>{let p=!a.some(u=>u.chain===l.chain&&u.selected&&u.walletType!==l.walletType);return{address:l.address,chain:l.chain,isContractWallet:l.isContractWallet,explorerUrl:null,walletType:l.walletType,selected:p,namespace:n,derivationPath:r,loading:!1,error:!1}});t(l=>({connectedWallets:[...l.connectedWallets.filter(u=>!c.some(m=>m.walletType===u.walletType&&m.chain===u.chain)),...c]}))}},fetchCustomTokensBalances:async o=>{let{tokens:n,connectedWallets:r}=o,a=n.reduce((l,p)=>((l[p.blockchain]||=[]).push(p),l),{}),s=new Set,c=r.reduce((l,p)=>{let u=`${p.address}-${p.chain}`;return s.has(u)||(s.add(u),a[p.chain]&&(l[p.address]||(l[p.address]=[]),l[p.address]?.push(...a[p.chain]||[]))),l},{});Object.entries(c).forEach(async([l,p])=>{try{let{balances:u}=await ct().getMultipleTokenBalance({assets:p.map(({symbol:m,address:f,blockchain:h})=>({symbol:m,address:f,blockchain:h})),walletAddress:l});if(u){let m=e()._balances,f=e()._aggregatedBalances;u.forEach(h=>{if(parseFloat(h.amount.amount)===0)return;let g={blockChain:h.asset.blockchain,balances:[h],address:l},d={_aggregatedBalances:e()._aggregatedBalances,findToken:e().findToken};ks(d,g,m);let S=ws(g,e);f=vs(f,S),m={...m,...S}}),t(h=>({_balances:{...h._balances,...m},_aggregatedBalances:f}))}}catch(u){console.error(u)}})},setWalletsAsSelected:o=>{let n=e().connectedWallets.map(r=>{let a=!!o.find(c=>c.chain===r.chain&&c.walletType!==r.walletType&&r.selected),s=!!o.find(c=>c.chain===r.chain&&c.walletType===r.walletType&&!r.selected);return a?{...r,selected:!1}:s?{...r,selected:!0}:r});t({connectedWallets:n})},newWalletConnected:async(o,n,r)=>{let a=o[0];a&&(we.emit("walletEvent",{type:"connect",payload:{walletType:a.walletType,accounts:o}}),e().addConnectedWallet(o,n,r),e().fetchBalances(o))},removeBalancesForWallet:(o,n)=>{let r={_balances:e()._balances,_aggregatedBalances:e()._aggregatedBalances,connectedWallets:e().connectedWallets},{_balances:a,_aggregatedBalances:s}=xs(r,o,n);t({_balances:a,_aggregatedBalances:s})},disconnectNamespaces:(o,n)=>{if(e().connectedWallets.find(a=>a.walletType===o)){e().removeBalancesForWallet(o,{namespaces:n}),e()._changeSelectedWalletIfNeededOnRemove(o,{namespaces:n});let a=e().connectedWallets.filter(s=>s.namespace?!(s.walletType===o&&n.includes(s.namespace)):!0);t({connectedWallets:a})}},disconnectWallet:o=>{let n=e().connectedWallets.find(r=>r.walletType===o);if(we.emit("walletEvent",{type:"disconnect",payload:{walletType:o}}),n){e().removeBalancesForWallet(o),e()._changeSelectedWalletIfNeededOnRemove(o);let r=e().connectedWallets.filter(a=>a.walletType!==o);t({connectedWallets:r})}},_changeSelectedWalletIfNeededOnRemove:(o,n)=>{let r=e().connectedWallets;n?.namespaces&&n.namespaces.length>0&&(r=r.filter(s=>!!s.namespace&&n.namespaces?.includes(s.namespace)));let a=r.filter(s=>s.selected&&s.walletType===o).map(s=>s.chain);if(a.length>0){let s=e().connectedWallets.map(c=>a.includes(c.chain)?(a=a.filter(l=>l!==c.chain),{...c,selected:!0}):c);t({connectedWallets:s})}},clearConnectedWallet:()=>t({connectedWallets:[]}),fetchBalances:async(o,n)=>{let{shouldFetchCustomTokens:r=!0,selectedCustomTokens:a}=n||{};await e().fetchMainTokensBalances(o),r&&e().fetchCustomTokensBalances({tokens:a??e().customTokens(),connectedWallets:o})},fetchMainTokensBalances:async(o,n)=>{if(o.length===0||!o[0])return;let r=o[0].walletType;e().setConnectedWalletAsRefetching(o);let a=o.map(l=>({address:l.address,blockchain:l.chain})),s;try{s=await ct().getWalletsDetails(a)}catch(l){e().setConnectedWalletHasError(o),console.error(`Request for fetching balances failed. cause: ${l}`);return}let c=s.wallets;if(c){let l=e()._balances,p=e()._aggregatedBalances;c.forEach(m=>{if(m.failed)return;let f={_balances:l,_aggregatedBalances:p,connectedWallets:e().connectedWallets,findToken:e().findToken};ks(f,m,l);let{_balances:h,_aggregatedBalances:g}=xs(f,r,{chains:[m.blockChain]});if(p=g,l=h,!e().connectedWallets.find(S=>S.walletType===r&&S.address===m.address&&S.chain===m.blockChain))return;let d=ws(m,e);p=vs(p,d),l={...l,...d}}),t(m=>({_balances:{...m._balances,...l},_aggregatedBalances:p})),e().setConnectedWalletRetrievedData(o,c);let{retryOnFailedBalances:u=!0}=n||{};if(u){let m=c.filter(f=>f.failed).map(f=>({chain:f.blockChain,walletType:r,address:f.address}));m.length>0&&await e().fetchMainTokensBalances(m,{retryOnFailedBalances:!1})}}else e().setConnectedWalletHasError(o),console.error("We couldn't fetch your account balances. Seem there is no information on blockchain for them yet.")},getBalances:()=>e()._balances,getBalanceFor:o=>{let n=e().getBalances(),r=Vt(o),a=e()._aggregatedBalances[r]||[];if(a.length===0||!a[0])return null;let s=a[0];if(a.length===1&&n[s])return n[s];let c=n[a[0]];if(!c)return null;let l=c;return a.forEach(p=>{let u=n[p];if(!u)return;let m=new bs(u.amount),f=new bs(l.amount);m.isGreaterThan(f)&&(l=u)}),l},getBalancesForWalletAddress:o=>{let n=e().getBalances();return Object.keys(n).reduce((s,c)=>{let l=n[c],[,,,p]=c.split(Bo);return l&&p===o&&(s[c]=l),s},{})},getConnectedWalletsDetails:()=>NT(()=>e().connectedWallets.map(n=>{let r=e().getBalancesForWalletAddress(n.address),a=Object.keys(r);return{...n,balances:a.reduce((s,c)=>{let l=r[c],p=Yn(c);if(p&&p.blockchain===n.chain&&l){let u=e().findToken(p),m=l?.amount?new bs(l.amount).shiftedBy(-l.decimals):pe;s.push({chain:n.chain,symbol:p.symbol,ticker:p.symbol,address:p.address,rawAmount:l.amount,decimal:l.decimals,amount:m.toString(),isSupported:!!u,logo:u?.image||null,usdPrice:u?.usdPrice||null})}return s},[])}}),e().lastUpdatedAt)}));function Ku(t){return BT()(WT((...e)=>({...Vu(...e),...Ou(...e),...Hu(...e),...Yp(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,quoteTokensRate:e.quoteTokensRate}),version:1,migrate:(e,o)=>{let n=e;return o===0&&(n._customTokens=n._customTokens.map(r=>({...r,warning:!0}))),n}}))}i(Ku,"createAppStore");var ju=LT(null);function T(){let t=PT(ju);if(_T(()=>{t&&!t.persist.hasHydrated()&&t.persist.rehydrate()},[]),!t)throw new Error("Missing AppStoreContext.Provider in the tree");return t()}i(T,"useAppStore");function Xu(t){let e=DT();return e.current||(e.current=Ku(t.config)),MT.createElement(ju.Provider,{value:e.current},t.children)}i(Xu,"AppStoreProvider");function vt(t){let{chain:e}=t||{},{connectedWallets:o,getAvailableProviders:n}=T(),{state:r,getWalletInfo:a}=$T(),s=T().blockchains(),{handleDisconnect:c}=Ro(),l=Vp(n()),p=wu(r,a,l,e);p=FT()?p.filter(d=>d.showOnMobile!==!1&&r(d.type).installed):p;let u=bu(p),m=i(d=>!o.find(S=>S.walletType===d&&S.chain===e),"isExperimentalChainNotAdded"),f=UT(()=>{let d=p?.filter(S=>S.state===Es.CONNECTING)||[];for(let S of d)c(S)},[Au(p)]);zT(()=>()=>{f()},[]);let h=i(d=>{let S=d.find(C=>C.type===Zn.DEFAULT);return!S||S.state===Es.NOT_INSTALLED?!1:d.filter(C=>C.state!=Es.NOT_INSTALLED&&![Zn.DEFAULT,Zn.WALLET_CONNECT_2,Zn.LEDGER].includes(C.type)&&a(C.type).supportedChains.filter(k=>k.type=="EVM").length>0).length==0},"shouldShowDefaultInjectedWallet"),g=i((d,S,y)=>ci(y,S)&&m(d)&&!OT.includes(d)||d==Zn.DEFAULT&&!h(p),"shouldExcludeWallet");return{list:u.filter(d=>!g(d.type,e??"",s)),terminateConnectingWallets:f}}i(vt,"useWalletList");import{Modal as GT}from"@rango-dev/ui";import VT from"react";import{create as qT}from"zustand";var Yu="rango-widget";var Jn=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(Yu),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 QT=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"),co=QT;var oe=co(qT()((t,e)=>({isActiveTab:!1,tabManagerInitiated:!1,showActivateTabModal:!1,watermark:"NONE",showProfileBanner:!1,fetchingApiConfig:!1,showCompactTokenSelector:!1,activateCurrentTab:(o,n)=>{let{showActivateTabModal:r}=e();!r&&n?t({showActivateTabModal:!0}):(r||!n)&&o()},setShowActivateTabModal:o=>{t({showActivateTabModal:o})},setWatermark:o=>{t({watermark:o})},setShowProfileBanner:o=>{t({showProfileBanner:o})},setShowCompactTokenSelector:o=>{t({showCompactTokenSelector:o})}}))),Po=new Jn({onInit:()=>oe.setState({tabManagerInitiated:!0}),onClaim:()=>oe.setState({isActiveTab:!0,showActivateTabModal:!1}),onRelease:()=>oe.setState({isActiveTab:!1})});function ee(t){let{watermark:e}=oe();return VT.createElement(GT,{hasWatermark:e==="FULL",...t},t.children)}i(ee,"WatermarkedModal");import{i18n as mn}from"@lingui/core";import{Alert as ak,Button as sk,Divider as fn,Image as lk,MessageBox as ck,RadioRoot as pk,WalletImageContainer as uk}from"@rango-dev/ui";import ae,{useEffect as dk,useMemo as mk,useState as fk}from"react";import{i18n as YT}from"@lingui/core";import{Typography as rd}from"@rango-dev/ui";import un from"react";function hi(t,e){return t.find(o=>o.name===e)?.logo}i(hi,"getBlockchainLogo");import{darkTheme as KT,Image as jT,styled as Kt,Typography as XT}from"@rango-dev/ui";var yi=Kt("li",{backgroundColor:"$neutral200",padding:"$16",borderRadius:"$sm",variants:{clickable:{true:{cursor:"pointer"}},hasError:{true:{background:"$error100",[`.${KT} &`]:{backgroundColor:"$error700"}}},unsupported:{true:{cursor:"not-allowed",paddingTop:"$8",paddingBottom:"$8"}}}}),Si=Kt("div",{display:"flex",gap:"$8",alignItems:"center"}),Ju=Kt("div",{flex:"1",display:"flex",flexDirection:"column",justifyContent:"space-between",height:"$40",variants:{showSupportedChains:{true:{justifyContent:"space-between"},false:{justifyContent:"center"}}}}),Ru=Kt("div",{flex:"1",display:"flex",alignItems:"center",gap:"$4",opacity:"0.5"}),ed=Kt("div",{display:"flex",gap:"$6",alignItems:"center"}),td=Kt("div",{paddingLeft:"48px"}),od=Kt("div",{display:"flex",gap:"$2",cursor:"pointer",alignItems:"center",width:"fit-content"}),nd=Kt(XT,{maxWidth:"100px"}),Ci=Kt(jT,{variants:{disabled:{true:{opacity:"0.5"}}}});function Ti(t){let{namespace:e}=t,o=T().blockchains();return un.createElement(yi,{unsupported:!0},un.createElement(Si,null,un.createElement(Ci,{src:hi(o,e.id),size:40,disabled:!0}),un.createElement(Ru,null,un.createElement(rd,{variant:"label",size:"large"},e.label),un.createElement(rd,{variant:"body",size:"xsmall"},YT.t("(Currently not supported)")))))}i(Ti,"NamespaceUnsupportedItem");import{Checkbox as nk,Radio as rk}from"@rango-dev/ui";import Bs from"react";import{i18n as Ns}from"@lingui/core";import{ChevronDownIcon as JT,ChevronUpIcon as RT,Divider as ek,Typography as Rn}from"@rango-dev/ui";import Ne,{useEffect as tk,useState as ok}from"react";import{Image as ad,Tooltip as sd,Typography as ZT}from"@rango-dev/ui";import _t from"react";import{styled as id}from"@rango-dev/ui";var Is=id("div",{display:"flex",alignItems:"center",padding:0,margin:0}),ki=id("div",{marginLeft:"-5px",listStyleType:"none",backgroundColor:"$background",borderRadius:"$lg",minWidth:"15px",height:"15px",variants:{firstItem:{true:{marginLeft:0}}},display:"flex",alignItems:"center",justifyContent:"center"});var As=3;function ld(t){let{chains:e}=t;return _t.createElement(Is,{id:"widget-supported-chains-container"},e.slice(0,As).map((o,n)=>_t.createElement(sd,{key:o.name,container:B(),side:"bottom",align:"start",content:o.name,sideOffset:4},_t.createElement(ki,{firstItem:n===0},_t.createElement(ad,{src:o.logo,size:15})))),e.length>As&&_t.createElement(sd,{container:B(),side:"bottom",align:"start",sideOffset:4,content:_t.createElement(Is,null,e.map((o,n)=>_t.createElement(ki,{key:o.name,firstItem:n===0},_t.createElement(ad,{src:o.logo,size:15}))))},_t.createElement(ki,null,_t.createElement(ZT,{variant:"body",size:"xsmall"},"+",e.length-As))))}i(ld,"SupportedChainsList");function _o(t){let{namespace:e,error:o,suffix:n,connected:r,address:a,onClick:s}=t,[c,l]=ok(!1),p=T().blockchains();tk(()=>l(!1),[o]);let u=e.getSupportedChains(p),m=!o&&!r&&u.length>1;return Ne.createElement(yi,{hasError:!!o,clickable:!!s,onClick:s},Ne.createElement(Si,null,Ne.createElement(Ci,{src:hi(p,e.id),size:40}),Ne.createElement(Ju,{showSupportedChains:m||r||!!o},Ne.createElement(ed,null,Ne.createElement(Rn,{variant:"label",size:"large"},e.label),r&&Ne.createElement(Rn,{variant:"body",size:"small",color:"success500"},Ns.t("Connected")),!!o&&Ne.createElement(Rn,{variant:"body",size:"small",color:"error500"},Ns.t("Connection failed"))),m&&Ne.createElement(ld,{chains:u}),r&&Ne.createElement(nd,{variant:"body",size:"small",color:"neutral700"},a),o&&Ne.createElement(od,{onClick:()=>l(f=>!f)},Ne.createElement(Rn,{variant:"body",size:"small",color:"neutral700",style:{textDecoration:"underline",userSelect:"none",textDecorationSkipInk:"none"}},Ns.t("See why")),c?Ne.createElement(RT,{size:12,color:"gray"}):Ne.createElement(JT,{size:12,color:"gray"}))),n),!!o&&c&&Ne.createElement(Ne.Fragment,null,Ne.createElement(ek,{size:4}),Ne.createElement(td,null,Ne.createElement(Rn,{variant:"body",size:"small",color:"neutral700"},o))))}i(_o,"NamespaceItem");function cd(t){let{onClick:e,type:o,namespace:n}=t;return Bs.createElement(_o,{namespace:n,onClick:e,suffix:o==="radio"?Bs.createElement(rk,{value:n.value}):Bs.createElement(nk,{checked:t.value})})}i(cd,"NamespaceListItem");import{Button as ik,styled as pd}from"@rango-dev/ui";var wi=pd("ul",{padding:0,paddingBottom:"$20",margin:0}),dn=pd(ik,{minHeight:"$40"});function er(t){let{targetWallet:e}=t.value,o=e.properties?.find(d=>d.name==="namespaces"),n=e.isHub,r=e.isHub?o?.value.selection==="single":e.needsNamespace?.selection==="single",a=n?o?.value:e.needsNamespace,s=e.image,c=T().blockchains(),[l,p]=fk([]),u=mk(()=>a?.data.filter(d=>!d.unsupported),[e?.type]),m=i(d=>{p(r?[d]:S=>S.includes(d)?S.filter(y=>y!==d):S.concat(d))},"onSelect"),f=u?.length===l.length,h=i(()=>{if(r)throw new Error("onSelectAll should not be called on single selection mode.");f?p([]):u&&p(u.map(d=>d.value))},"onSelectAll"),g=i(d=>r?ae.createElement(pk,{value:l?.[0]},d):ae.createElement(ae.Fragment,null,d),"wrapRadioRoot");return dk(()=>{if(!r&&u)if(t.value.defaultSelectedChains?.length){let d=u.filter(S=>S.getSupportedChains(c).some(y=>t.value.defaultSelectedChains?.includes(y.name)));p(d.map(S=>S.value))}else p(u.map(d=>d.value))},[]),ae.createElement(ae.Fragment,null,ae.createElement(ck,{type:"info",title:mn.t("Connect {wallet}",{wallet:e.title}),description:mn.t("This wallet supports multiple chains. Choose which chains you\u2019d like to connect."),icon:ae.createElement(uk,null,ae.createElement(lk,{src:s,size:45}))}),r?ae.createElement(ae.Fragment,null,ae.createElement(fn,{size:20}),ae.createElement(ak,{id:"widget-wallet-stateful-connect-alert",variant:"alarm",type:"info",title:mn.t("This wallet can only connect to one chain at a time. ")}),ae.createElement(fn,{size:30})):ae.createElement(ae.Fragment,null,ae.createElement(fn,{size:30}),ae.createElement(sk,{style:{marginLeft:"auto"},id:"widget-name-space-select-all-btn",size:"xsmall",variant:"ghost",type:"primary",onClick:h},f?mn.t("Deselect all"):mn.t("Select all")),ae.createElement(fn,{size:10})),ae.createElement(wi,null,g(ae.createElement(ae.Fragment,null,a?.data.map((d,S,y)=>ae.createElement(ae.Fragment,{key:d.id},d.unsupported?ae.createElement(Ti,{namespace:d}):ae.createElement(cd,{value:l.includes(d.value),namespace:d,type:r?"radio":"checkbox",onClick:()=>m(d.value)}),S!==y.length-1&&ae.createElement(fn,{size:10})))))),ae.createElement(fn,{size:20}),ae.createElement(dn,{id:"widget-name-space-confirm-btn",type:"primary",disabled:!l.length,onClick:()=>t.onConfirm(l)},mn.t("Connect")))}i(er,"Namespaces");import{i18n as tr}from"@lingui/core";import{Alert as kk,Button as wk,Divider as gn,Image as vk,MessageBox as xk,WalletImageContainer as bk}from"@rango-dev/ui";import{useWallets as Ek}from"@rango-dev/wallets-react";import de from"react";import{styled as gk}from"@rango-dev/ui";var ud=gk("div",{display:"flex",justifyContent:"end"});import{i18n as Ws}from"@lingui/core";import{Button as hk,Spinner as yk}from"@rango-dev/ui";import Ms,{useLayoutEffect as Sk,useRef as Ck,useState as Tk}from"react";function dd(t){let{namespace:e,initialConnect:o,disabled:n,state:r,handleConnect:a,handleDisconnect:s}=t,[c,l]=Tk(null),p=Ck(!1);Sk(()=>{o&&!p.current&&u()},[]);let u=i(async g=>{try{p.current=!0,await a(g)}catch(d){l(d)}finally{p.current=!1}},"handleConnectNamespace"),m=i(async()=>{l(null),r.connected?await s():u({shouldAskForDerivationPath:!0})},"handleButtonClick"),f=i(()=>{let g=r.accounts?.[0]?.split(":"),d=g?.[g.length-1];return!r.connected||!d?null:lo(d)},"getConnectedAddress"),h=i(()=>r.connected?Ws.t("Disconnect"):c?Ws.t("Try again"):Ws.t("Connect"),"getButtonText");return Ms.createElement(_o,{namespace:e,connected:r.connected,error:c?.message,address:f(),suffix:r.connecting?Ms.createElement(yk,{color:"info"}):Ms.createElement(hk,{id:"widget-name-space-connect-btn",variant:"ghost",type:r.connected?"error":"primary",size:"xsmall",onClick:async()=>m(),disabled:n},h())})}i(dd,"NamespaceDetachedItem");function or(t){let{value:e,selectedNamespaces:o,onConfirm:n,confirmText:r=tr.t("Done"),onDisconnectWallet:a,navigateToDerivationPath:s}=t,{targetWallet:c}=e,{connect:l,disconnect:p,state:u}=Ek(),m=c.type,f=u(m),h=c.properties?.find(w=>w.name==="namespaces"),g=c.properties?.find(w=>w.name==="derivationPath"),d=h?.value.selection==="single",S=i(async(w,x)=>{d&&await p(m),g&&x?.shouldAskForDerivationPath?s(w):await l(m,[{namespace:w,network:"",derivationPath:x?.derivationPath??void 0}])},"handleConnectNamespace"),y=i(async w=>{await p(m,[w])},"handleDisconnectNamespace"),C=i(()=>d?de.createElement(de.Fragment,null,de.createElement(gn,{size:20}),de.createElement(kk,{id:"widget-wallet-stateful-connect-alert",variant:"alarm",type:"info",title:tr.t("This wallet can only connect to one chain at a time.")}),de.createElement(gn,{size:30})):de.createElement(de.Fragment,null,de.createElement(gn,{size:30}),de.createElement(ud,null,de.createElement(wk,{id:"widget-detached-disconnect-wallet-btn",variant:"ghost",type:"error",size:"xsmall",disabled:f.connecting||!f.connected,onClick:a},tr.t("Disconnect wallet"))),de.createElement(gn,{size:16})),"renderNamespaceListHeader"),k=i(w=>{if(w.unsupported)return de.createElement(Ti,{namespace:w});let x=o?.find(b=>b.namespace===w.value),I=f.namespaces?.get(w.value);if(!I)throw new Error(`State for ${w.value} was not found!`);let A=d&&f.connecting;return de.createElement(dd,{namespace:w,initialConnect:!!x,disabled:A,state:I,handleConnect:async b=>S(w.value,{derivationPath:x?.derivationPath,shouldAskForDerivationPath:b?.shouldAskForDerivationPath}),handleDisconnect:async()=>y(w.value)})},"renderNamespaceItem");return de.createElement(de.Fragment,null,de.createElement(xk,{type:"info",title:tr.t("Connect {wallet}",{wallet:c.type}),description:tr.t("This wallet supports multiple chains. Choose which chains you\u2019d like to connect or disconnect."),icon:de.createElement(bk,null,de.createElement(vk,{src:c.image,size:45}))}),C(),de.createElement(wi,{id:"widget-detached-namespace-list"},c.needsNamespace?.data.map((w,x,I)=>de.createElement(de.Fragment,{key:w.id},k(w),x!==I.length-1&&de.createElement(gn,{size:10})))),de.createElement(gn,{size:20}),de.createElement(dn,{id:"widget-name-space-confirm-btn",type:"primary",onClick:n},r))}i(or,"Detached");import{i18n as hn}from"@lingui/core";import{Divider as Bk,Image as Wk,MessageBox as Mk,Select as Lk,TextField as Pk}from"@rango-dev/ui";import xt,{useEffect as _k,useState as fd}from"react";import{namespaces as Ik}from"@rango-dev/wallets-shared";var vi={id:"custom",label:"Custom",generateDerivationPath:t=>t};function Ls(t){let e=t?Ik[t]?.derivationPaths:null;return e?[...e,vi]:[]}i(Ls,"getDerivationPaths");import{Button as Ak,styled as Ps,Typography as Nk}from"@rango-dev/ui";var md=Ps("div",{paddingTop:"$30",paddingBottom:"$30",zIndex:10}),_s=Ps(Nk,{paddingLeft:"$10"}),Ds={height:"$40",backgroundColor:"$neutral200",borderRadius:"$sm"},n_=Ps(Ak,{minHeight:"$40"});var gd="0";function nr(t){let{onConfirm:e}=t,{namespace:o,providerImage:n,providerType:r}=t.value,[a,s]=fd(null),[c,l]=fd(gd),p=a===vi.id,u=Ls(o),m=i(({value:h})=>{let g=u?.find(d=>d.id===h);g&&(a===vi.id&&Number.isNaN(Number(c))&&l(gd),s(g.id))},"handleDerivationPathItemClick"),f=i(()=>{let h=u.find(g=>g.id===a);if(h)e(h.generateDerivationPath(c));else throw new Error("selectedDerivationPath can not be undefined")},"handleConfirm");return _k(()=>{s(Ls(o)[0]?.id||null)},[o]),xt.createElement(xt.Fragment,null,xt.createElement(Mk,{type:"info",title:hn.t("Select Derivation Path"),description:hn.t({id:"In order to connect to {type}, you must first select a Derivation Path",values:{type:r}}),icon:xt.createElement(Wk,{src:n,size:45})}),xt.createElement(md,{className:"_derivation_path_inputs_container"},xt.createElement(_s,{variant:"body",size:"xsmall",color:"$neutral600",className:"_derivation_path_input_label"},hn.t("Choose Derivation Path Template")),xt.createElement(Lk,{id:"widget-derivation-path-template-select",value:a||"",options:u.map(h=>({value:h.id,label:h.label})),variant:"filled",handleItemClick:m,styles:{trigger:Ds}}),xt.createElement(Bk,{size:20}),xt.createElement(_s,{variant:"body",size:"xsmall",color:"$neutral600",className:"_derivation_path_input_label"},p?hn.t("Enter Path"):hn.t("Enter Index")),xt.createElement(Pk,{id:"widget-derivation-path-template-input",type:p?"text":"number",variant:"contained",value:c,onChange:h=>l(h.target.value),style:Ds})),xt.createElement(dn,{id:"widget-derivation-path-confirm-btn",type:"primary",onClick:f,disabled:!u||!a||!c},hn.t("Confirm")))}i(nr,"DerivationPath");import{i18n as yn}from"@lingui/core";import{Image as Fk,MessageBox as Fs,WalletImageContainer as Ok,WalletState as Uk}from"@rango-dev/ui";import{useWallets as zk}from"@rango-dev/wallets-react";import Do from"react";import{keyframes as Dk,styled as $s}from"@rango-dev/ui";var f_=$s("div",{borderRadius:"$lg",width:"$45",height:"$45",backgroundColor:"$success300",display:"flex",justifyContent:"center",alignItems:"center"}),hd=$s("div",{position:"relative"}),$k=Dk({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}),yd=$s("div",{position:"absolute",border:"2px solid rgba(0, 0, 0, 0.1)",borderTop:"2px solid $info500",borderRadius:"$lg",width:"$45",height:"$45",animation:`${$k} 1s linear infinite`,top:0,bottom:0,right:0,left:0});function Os(t){let{wallet:e,error:o}=t,{type:n,image:r}=e,{state:a,getWalletInfo:s}=zk();return Vn(s(n),a(n))===Uk.CONNECTED?Do.createElement(Fs,{type:"success",title:yn.t("Wallet Connected"),description:yn.t("Your wallet is connected, you can use it to swap.")}):o?Do.createElement(Fs,{type:"error",title:yn.t("Failed to Connect"),description:o||yn.t("Your wallet is not connected. Please try again.")}):Do.createElement(Fs,{type:"loading",title:yn.t("Connecting to your wallet"),description:yn.t("Click connect in your wallet popup."),icon:Do.createElement(hd,null,Do.createElement(Ok,null,Do.createElement(Fk,{src:r,size:45})),Do.createElement(yd,null))})}i(Os,"ConnectStatus");import{i18n as Us}from"@lingui/core";import{Button as Hk,Divider as Sd,MessageBox as Qk}from"@rango-dev/ui";import xi from"react";function zs(t){let{displayName:e,onConfirm:o,id:n}=t;return xi.createElement(Qk,{id:n,title:Us.t({id:"Add {blockchainDisplayName} Chain",values:{blockchainDisplayName:e}}),type:"warning",description:Us.t({id:"Would you like to add the {blockchainDisplayName} experimental chain to your wallet?",values:{blockchainDisplayName:e}})},xi.createElement(Sd,{size:18}),xi.createElement(Sd,{size:32}),xi.createElement(Hk,{id:"widget-experimental-chain-confirm-btn",onClick:o,variant:"outlined",type:"primary",fullWidth:!0,size:"large"},Us.t("Confirm")))}i(zs,"ExperimentalChain");function Cd(t,e){return t().status==="init"&&!!e}i(Cd,"isOnStatus");function rr(t){return t().status==="namespace"}i(rr,"isOnNamespace");function ir(t){return t().status==="derivationPath"}i(ir,"isOnDerivationPath");function Ao(t){return t().status==="detached"}i(Ao,"isOnDetached");var Kk=3e3,jk=300;function ar(t){let e=Vk(),[o,n]=Td(!1),[r,a]=Td(),s=i(x=>{a(x.message)},"catchErrorOnHandle"),{terminateConnectingWallets:c}=vt(),{handleConnect:l,handleDerivationPath:p,handleNamespace:u,getState:m,resetState:f,handleDisconnect:h}=Ro(),g=i(x=>{u(t.wallet,x).then(k).catch(s)},"handleConfirmNamespaces"),d=i(()=>{y()},"handleDetachedConfirm"),S=i(x=>{if(!x)throw new Error("Derivation path is empty. Please make sure you've filled the field correctly.");p(t.wallet,x).then(k).catch(s)},"handleDerivationPathConfirm"),y=i(()=>{n(!1)},"handleClosingModal"),C=i(()=>{a(void 0),f(),n(!1),e.current&&clearTimeout(e.current)},"resetModalState"),k=i((x,I)=>{let A=x.status==="connected",b=["disconnected","disconnected-unhandled"].includes(x.status);A?(t.onConnect?.(),I||(e.current=setTimeout(y,Kk))):b&&y()},"afterConnected"),w=i(x=>{t.wallet?.needsDerivationPath&&u(t.wallet,[x])},"handleNavigateToDerivationPath");return Gk(()=>{if(t.wallet){C();let x=!1,I=!0;i(()=>{setTimeout(()=>{I=!1,x||n(!0)},jk)},"beforeConnecting")(),l(t.wallet,{disconnectIfConnected:!0,defaultSelectedChains:t.options?.defaultSelectedChains}).then(b=>{["namespace","Detached","derivation-path"].includes(b.status)||(x=!0),k(b,I)}).catch(s)}},[t.wallet]),po.createElement(ee,{id:t.id,open:o,onClose:y,onExit:()=>{C(),c(),t.onClose&&t.onClose()},container:B()},Cd(m,t.wallet)&&po.createElement(po.Fragment,null,po.createElement(Os,{wallet:{type:t.wallet.type,image:t.wallet.image},error:r}),po.createElement(qk,{direction:"vertical",size:32})),rr(m)&&po.createElement(er,{onConfirm:g,value:m().namespace}),ir(m)&&po.createElement(nr,{onConfirm:S,value:m().derivationPath}),Ao(m)&&po.createElement(or,{onConfirm:d,onDisconnectWallet:()=>void h(m().namespace.targetWallet),value:m().namespace,selectedNamespaces:m().selectedNamespaces,navigateToDerivationPath:w}))}i(ar,"StatefulConnectModal");import Ra from"react";import Xk,{Fragment as Yk}from"react";import{MemoryRouter as Zk,useInRouterContext as Jk}from"react-router";function bi({children:t}){let o=Jk()?Yk:Zk;return Xk.createElement(o,null,t)}i(bi,"AppRouter");import{I18nManager as Z0}from"@rango-dev/ui";import Pp from"react";import ze from"react";import{useRoutes as N0}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 Cn,useRef as Mi}from"react";import ot from"bignumber.js";import{create as Rd}from"zustand";import{subscribeWithSelector as em}from"zustand/middleware";import{createContext as Rk,useContext as ew}from"react";var kd=Rk({swapMode:"swap",isMultiMode:!1});function tt(){let{swapMode:t,isMultiMode:e}=ew(kd);return{swapMode:t,isMultiMode:e}}i(tt,"useSwapMode");import{i18n as Ct}from"@lingui/core";import{getRelatedWalletOrNull as nw,RouteEventType as WD}from"@rango-dev/queue-manager-rango-preset";import Qe from"bignumber.js";import{PendingSwapNetworkStatus as lr}from"rango-types";import{i18n as He}from"@lingui/core";var ne=i(()=>({genericServerError:He.t("Failed Network, Please retry your swap."),liquiditySourcesError:{title:He.t("Please reset your liquidity sources."),description:He.t("You have limited the liquidity sources and this might result in Rango finding no routes. Please consider resetting your liquidity sources.")},noResultError:{title:He.t("No Routes Found."),description:He.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:He.t("Bridge Limit Error: Please increase your amount."),decreaseAmount:He.t("Bridge Limit Error: Please decrease your amount.")},highValueLossError:{impactTitle:He.t("High Price Impact"),title:He.t("Price impact is too high!"),description:He.t("The price impact is significantly higher than the allowed amount."),confirmMessage:He.t("Confirm high price impact")},quoteUpdatedWithHighValueLoss:{title:He.t("Route updated and price impact is too high, try again later!")},unknownPriceError:{impactTitle:He.t("USD Price Unknown"),title:He.t("USD Price Unknown, Cannot calculate Price Impact."),description:He.t("USD Price Unknown, Cannot calculate Price Impact. The price impact may be higher than usual. Are you sure to continue the Swap?"),confirmMessage:He.t("Confirm USD Price Unknown")}}),"errorMessages");function wd(t){return t.type===0?t.diagnosisMessage??ne().noResultError.title:t.type===1?t.diagnosisMessage??ne().genericServerError:""}i(wd,"getQuoteErrorMessage");import{i18n as Ei}from"@lingui/core";var $o=i(()=>({connectWallet:Ei.t("Connect Wallet"),swap:Ei.t("Swap"),swapAnyway:Ei.t("Swap anyway"),ethWarning:Ei.t("The route goes through Ethereum. Continue?")}),"swapButtonTitles");function Hs(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(Hs,"getFeeLabel");var Qs=["RECOMMENDED","CENTRALIZED","LOWEST_FEE","FASTEST","HIGH_IMPACT"],vd=100,xd=30,bd=15,Ed=60;var Id=[{threshold:-10,minInput:400},{threshold:-5,minInput:1e3}],Ad=[{threshold:-1,minInput:1e3},{threshold:-2,minInput:500}];import{getLastSuccessfulStep as ow}from"@rango-dev/queue-manager-rango-preset";import yD from"bignumber.js";function Bd(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(Bd,"getRequiredBalanceOfWallet");function Xt(t){let e;return t<=-3&&t>-10?e="low":t<=-10&&(e="high"),e}i(Xt,"getPriceImpactLevel");function Ii(t,e,o){let n=t.steps[0],r=t.steps[t.steps.length-1],a=ow(t.steps);if(!r||!n)return{fromBlockchain:null,fromToken:void 0,toBlockchain:null,toToken:void 0,inputAmount:""};let s={blockchain:r.toBlockchain,symbol:r.toSymbol,address:r.toSymbolAddress},c=No(a?a.toBlockchain:n.fromBlockchain,e),l=No(r.toBlockchain,e),p=o(a?{blockchain:c?.name??"",symbol:a.toSymbol,address:a.toSymbolAddress}:{blockchain:c?.name??"",symbol:n.fromSymbol,address:n.fromSymbolAddress}),u=o(s),m=a?a.outputAmount??"":t.inputAmount;return{fromBlockchain:c,fromToken:p,toBlockchain:l,toToken:u,inputAmount:m}}i(Ii,"createRetryQuote");function Sn(t){let{previousQuote:e,currentQuote:o,findToken:n,userSlippage:r}=t,a=sr(o),s=St(o);if(o&&a&&s){let p=jt(a.toString(),s.toString());if(!!p&&_d(a,p)){let m=Ni(o?.swaps,n),f=Xt(p);return{type:0,inputUsdValue:a,outputUsdValue:s,priceImpact:p,totalFee:m,warningLevel:f}}}if(e&&Fd(e,o))return{type:4,usdValueChange:P(St(o)?.minus(St(e)??0).toString()??"0",null,2),percentageChange:P(jt(St(e)??"1",St(o)??"1"),null,2)};if(o&&(!a||!s))return{type:1};let c=Bi(o.swaps),l=r>an;if($d(t.userSlippage.toString(),c)){if(l&&parseFloat(c??"0")<r)return{type:3,slippage:r.toString()}}else return{type:2,recommendedSlippages:Dd(o,r),minRequiredSlippage:c};return null}i(Sn,"generateQuoteWarnings");function Wd(t){return![4].includes(t.type)}i(Wd,"isQuoteWarningConfirmationRequired");function jt(t,e){let o=typeof e=="string"?parseFloat(e)<=0:!e?.gt(0),n=!t||!e||o?null:qs(t.toString(),e.toString());return n&&n<0?n:null}i(jt,"getPriceImpact");var Md=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"),Ai=i((t,e)=>e.sort((o,n)=>{let r=i(p=>p.scores?.find(u=>u.preferenceType===t)?.score??0,"getScore"),a=r(o),s=r(n);if(a!==s)return s-a;let c=o.requestId.toLowerCase(),l=n.requestId.toLowerCase();return c.localeCompare(l)}),"sortQuotesBy"),Ld=i((t,e,o)=>{let n=e[0];if(!e.length||!n)return null;if(!t)return{requestAmount:o,validationStatus:null,...n};let r=new Set(t.swaps.map(s=>s.swapperId)),a=e.find(s=>{let c=new Set(s.swaps.map(l=>l.swapperId));return Array.from(r).every(l=>c.has(l))});return{requestAmount:o,validationStatus:null,...a||n}},"getDefaultQuote"),Pd=i(t=>{let e=i((o,n)=>{let r=Qs.indexOf(o.value),a=Qs.indexOf(n.value);return r!==-1&&a!==-1?r-a:r!==-1?-1:a!==-1?1:0},"customSort");return t.sort(e)},"sortTags");function _d(t,e){if(!t)return!1;let o=parseInt(e.toFixed(2)||"0");return Id.some(({threshold:n,minInput:r})=>o<=n&&t.gte(new Qe(r)))}i(_d,"hasHighValueLoss");function Od(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(Od,"hasLimitError");function Ud(t){let e=(t||[]).filter(c=>{let l=c.fromAmountMinValue?new Qe(c.fromAmountMinValue):null,p=c.fromAmountMaxValue?new Qe(c.fromAmountMaxValue):null;return c.fromAmountRestrictionType==="EXCLUSIVE"?l?.gte(c.fromAmount)||p?.lte(c.fromAmount):l?.gt(c.fromAmount)||p?.lt(c.fromAmount)})[0];if(!e)return{swap:void 0,fromAmountRangeError:"",recommendation:""};let 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=Ct.t({id:"Required: >= {min} {symbol}",values:{min:P(o,6,6),symbol:e.from.symbol}}),s=ne().bridgeLimitErrors.increaseAmount):r&&o&&o.gte(e.fromAmount)&&(a=Ct.t({id:"Required: > {min} {symbol}",values:{min:P(o,6,6),symbol:e.from.symbol}}),s=ne().bridgeLimitErrors.increaseAmount),!r&&n&&n.lt(e.fromAmount)?(a=Ct.t({id:"Required: <= {max} {symbol}",values:{max:P(n,6,6),symbol:e.from.symbol}}),s=ne().bridgeLimitErrors.decreaseAmount):r&&n&&n.lte(e.fromAmount)&&(a=Ct.t({id:"Required: < {max} {symbol}",values:{max:P(n,6,6),symbol:e.from.symbol}}),s=ne().bridgeLimitErrors.decreaseAmount),{swap:e,fromAmountRangeError:a,recommendation:s}}i(Ud,"getLimitErrorMessage");function zd(t){let{fetchMetaStatus:e,anyWalletConnected:o,fetchingQuote:n,inputAmount:r,quote:a,warning:s,error:c,needsToWarnEthOnPath:l}=t;return e!=="success"?{title:$o().connectWallet,action:"connect-wallet",disabled:!0}:o?n||!a||c||!r||r==="0"?{title:$o().swap,action:"confirm-swap",disabled:!0}:s?{title:$o().swapAnyway,action:"confirm-warning",disabled:!1}:l?{title:$o().ethWarning,action:"confirm-warning",disabled:!1}:{title:$o().swap,action:"confirm-swap",disabled:!1}:{title:$o().connectWallet,action:"connect-wallet",disabled:!1}}i(zd,"getSwapButtonState");function Gs(t,e,o){let n=parseFloat(e||"0");return!(t&&(!o||o.lte(pe))&&e&&e!=="0"&&n!==0)}i(Gs,"canComputePriceImpact");function Vs(t,e){let o=pe;for(let n=0;n<t.fee.length;n++){let r=t.fee[n];if(!r||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(Vs,"getUsdFeeOfStep");function Ni(t,e){return t.reduce((o,n)=>o.plus(Vs(n,e)),pe)}i(Ni,"getTotalFeeInUsd");function Ks(t){let e=pe,o=new Qe(t.price||0);return e=e.plus(new Qe(t.amount).multipliedBy(o)),e}i(Ks,"getUsdFee");function Hd(t){return t.reduce((e,o)=>e.plus(Ks(o)),pe)}i(Hd,"getTotalFeesInUsd");function Qd(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(Qd,"getFeesGroup");function qd(t){let e=new Map;return t.forEach((o,n)=>{o.recommendedSlippage?.error&&e.set(n,o.recommendedSlippage.slippage)}),e.size>0?Object.fromEntries(e):null}i(qd,"checkSlippageErrors");function Dd(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?Object.fromEntries(o):null}i(Dd,"checkSlippageWarnings");function Bi(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(Bi,"getMinRequiredSlippage");function $d(t,e){return e?parseFloat(t)>=parseFloat(e):!0}i($d,"hasProperSlippage");function Gd(t){let{fromToken:e,toToken:o,inputAmount:n,wallets:r,selectedWallets:a,disabledLiquiditySources:s,liquiditySources:c,excludeLiquiditySources:l,slippage:p,affiliateRef:u,affiliatePercent:m,affiliateWallets:f,destination:h,contractCall:g}=t,d=a?.reduce((C,k)=>(C[k.chain]=k.address,C),{}),S=[];return r?.forEach(C=>{S.push({blockchain:C.chain,addresses:[C.address]})}),{amount:n.toString(),affiliateRef:u??void 0,affiliatePercent:m??void 0,affiliateWallets:f??void 0,from:{address:e.address,blockchain:e.blockchain,symbol:e.symbol},to:{address:o.address,blockchain:o.blockchain,symbol:o.symbol},connectedWallets:S,selectedWallets:d??{},slippage:p.toString(),contractCall:g,...h&&{destination:h},...l&&{swapperGroups:s.concat(c??[]),swappersGroupsExclude:!0},...!l&&{swapperGroups:c?.filter(C=>!s.includes(C)),swappersGroupsExclude:!1}}}i(Gd,"createQuoteRequestBody");function Vd(t){return t.reduce((o,n)=>(o[n.chain]={address:n.address,walletType:n.walletType,derivationPath:n.derivationPath},o),{})}i(Vd,"getWalletsForNewSwap");function sr(t){let e=t.requestAmount,o=t.swaps[0]?.from.usdPrice;if(!(!e||!o))return new Qe(e).multipliedBy(o)}i(sr,"getUsdInputFrom");function St(t){let e=t?.outputAmount||null,o=t.swaps[t.swaps.length-1]?.to.usdPrice;if(!(!e||!o))return new Qe(e).multipliedBy(o)}i(St,"getUsdOutputFrom");function qs(t,e){return new Qe(e).div(new Qe(t)).minus(1).multipliedBy(vd).toNumber()}i(qs,"getPercentageChange");function Fd(t,e){let o=sr(t),n=St(t),r=St(e);if(!o||!n||!r)return!1;let a=qs(n.toString(),r.toString());return Ad.some(({threshold:s,minInput:c})=>a<=s&&o.isGreaterThanOrEqualTo(c))}i(Fd,"isOutputAmountChangedExcessively");function Kd(t,e,o){let n=t.validationStatus,r=Mo({filter:"required",quote:t});return e.sort((s,c)=>r.indexOf(s.chain)-r.indexOf(c.chain)).flatMap(s=>Bd(s,n)||[]).filter(s=>!s.ok).map(s=>{let c=s.asset.symbol,l=P(new Qe(s.currentAmount.amount).shiftedBy(-s.currentAmount.decimals),8,8),p=P(new Qe(s.requiredAmount.amount).shiftedBy(-s.requiredAmount.decimals),8,8),u="";return s.reason==="FEE"&&(u=Ct.t(" for network fee")),s.reason==="INPUT_ASSET"&&(u=Ct.t(" for swap")),s.reason==="FEE_AND_INPUT_ASSET"&&(u=Ct.t(" for input and network fee")),Ct.t({id:"Needs \u2248 {requiredAmount} {symbol}{reason}, but you have {currentAmount} {symbol} in your {blockchain} wallet.",values:{requiredAmount:p,symbol:c,reason:u,currentAmount:l,blockchain:ht(s.asset.blockchain,o)}})})}i(Kd,"generateBalanceWarnings");function cr(t){return!!t&&t.networkStatus!==null&&t.networkStatus!==lr.NetworkChanged}i(cr,"isNetworkStatusInWarningState");function jd(t,e,o){let n="bellow button or",r=t.extraMessage,a=t.extraMessageDetail;if(t.networkStatusExtraMessageDetail?.includes(n)&&(t.networkStatusExtraMessageDetail=t.networkStatusExtraMessageDetail.replace(n,"")),cr(e)){r=t.networkStatusExtraMessage||"",a=t.networkStatusExtraMessageDetail||"";let p=(e?nw(t,e):null)?.walletType,u=p?o?.(p)?.name:null;switch(e?.networkStatus){case lr.WaitingForConnectingWallet:r=u?Ct.t("Connect {wallet}",{wallet:u}):r;break;case lr.WaitingForQueue:r=r||Ct.t("Waiting for other running tasks to be finished");break;case lr.WaitingForNetworkChange:r=r||Ct.t("Waiting for changing wallet network");break;case lr.NetworkChangeFailed:r=r||Ct.t("The network switch could not be completed. Please try again, or switch the network manually in your wallet.");break;default:r=r||"";break}}a=a||"",r=r||"";let c=r?.indexOf("code")!==-1&&r?.indexOf("reason")!==-1;return{shortMessage:r,detailedMessage:{content:a,long:c}}}i(jd,"getSwapMessages");function Xd(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(Xd,"getLastConvertedTokenInFailedSwap");function Yd(t){return t.status==="failed"}i(Yd,"shouldRetrySwap");function Zd(t,e,o,n,r,a){if(!n||t)return!0;let s=Mo({filter:"all",quote:n}),c=Mo({filter:"required",quote:n}),l=s.every(m=>r.some(f=>f.chain===m)),p=c.every(m=>r.some(f=>f.chain===m)),u=o&&a?tn(a,o):!1;return!e&&!l||e&&!o||e&&!!o&&(!u||!p)}i(Zd,"isConfirmSwapDisabled");function Jd(t,e){return t.blockchain===e.blockchain&&t.symbol===e.symbol&&t.address===e.address}i(Jd,"isTokensIdentical");var Wi=i((t,e)=>t?.usdPrice?new ot(e||pe).multipliedBy(t?.usdPrice||0):null,"getUsdValue"),tm=i(t=>({fromBlockchain:null,fromToken:null,inputAmount:"",outputAmount:null,inputUsdValue:new ot(0),outputUsdValue:new ot(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=pe,a=o.inputUsdValue;return Gn(o.inputAmount)?(e&&(n=e?.outputAmount?new ot(e?.outputAmount):null,a=sr(e)??pe,r=St(e)??pe),{selectedQuote:e,...!!e&&{outputAmount:n,outputUsdValue:r,inputUsdValue:a}}):{}}),resetAlerts:()=>t(()=>({error:null,warning:null})),resetQuote:()=>t(()=>({selectedQuote:null,outputAmount:null,outputUsdValue:new ot(0),quotes:null,refetchQuote:!0,error:null,warning:null})),setFromBlockchain:e=>{t(o=>o.fromBlockchain?.name===e?.name?{}:{fromBlockchain:e,inputUsdValue:new ot(0),...o.fromToken&&{selectedQuote:null,fromToken:null,outputAmount:null,outputUsdValue:new ot(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:Wi(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 ot(0)}})},setToToken:e=>t(()=>({toToken:e.token,...e.token&&{toBlockchain:e.meta.blockchains.find(o=>o.name===e.token.blockchain)??null}})),sanitizeInputAmount:e=>{let o=Tu(e);t(()=>({inputAmount:o}))},setInputAmount:e=>{let o=e;ii(e)||(o=du(o),o=mu(o)),t(n=>({inputAmount:o,...!o&&{outputAmount:null,outputUsdValue:new ot(0),selectedQuote:null},...!!n.fromToken&&{inputUsdValue:Wi(n.fromToken,o)}}))},retry:e=>{let{fromBlockchain:o,fromToken:n,toBlockchain:r,toToken:a,inputAmount:s}=e;t({fromBlockchain:o,fromToken:n,inputAmount:s,outputAmount:null,inputUsdValue:Wi(n??null,s),outputUsdValue:new ot(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?Wi(e.toToken,e.outputAmount?.toString()||""):new ot(0)})),resetFromBlockchain:()=>t(()=>({fromToken:null,fromBlockchain:null,outputUsdValue:new ot(0),inputUsdValue:new ot(0),inputAmount:"",outputAmount:null,selectedQuote:null})),resetToBlockchain:()=>t(()=>({toToken:null,toBlockchain:null,outputAmount:null,outputUsdValue:new ot(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})}),"initializer"),om=Rd()(em(tm)),nm=Rd()(em(tm)),rw=co(om),iw=co(nm);function z(){let{swapMode:t}=tt();return co(t==="refuel"?nm:om)}i(z,"useQuoteStore");var rm=i((t,e)=>{(t.fromBlockchain!==e.fromBlockchain||t.fromToken!==e.fromToken||t.toBlockchain!==e.toBlockchain||t.toToken!==e.toToken||t.inputAmount!==e.inputAmount)&&we.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&&we.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})},"subscribeCallback"),im=rw.subscribe(rm),am=iw.subscribe(rm);function sm(){let{setInputAmount:t,setToToken:e,setToBlockchain:o,setFromBlockchain:n,resetQuote:r,setFromToken:a,fromToken:s,toToken:c,fromBlockchain:l,toBlockchain:p}=z()(),u=T().config,m=T().fetchStatus,f=T().blockchains(),{findToken:h}=T(),{setAffiliateRef:g,setAffiliatePercent:d,setAffiliateWallets:S}=T(),y=u?.from?.tokens,C=u?.from?.blockchains,k=u?.to?.tokens,w=u?.to?.blockchains,x=Mi(void 0),I=Mi(void 0),A=Mi(void 0),b=Mi(void 0);Cn(()=>{typeof u.amount<"u"&&t(u.amount.toString())},[u?.amount]),Cn(()=>{if(m==="success"){r();let E=f.find(M=>M.name===u?.from?.blockchain),v=u?.from?.token,N=v&&h(v);(E||!E&&A.current)&&n(E??null),N?a({token:N,meta:{blockchains:f}}):!N&&x.current&&a({token:null}),A.current=u?.from?.blockchain,x.current=u?.from?.token}},[u?.from?.token?.symbol,u?.from?.token?.address,u?.from?.token?.blockchain,u?.from?.blockchain,m]),Cn(()=>{gs(s,y)&&a({token:null}),hs(l,C)&&n(null)},[y,C]),Cn(()=>{gs(c,k)&&a({token:null}),hs(p,w)&&o(null)},[k,w]),Cn(()=>{if(m==="success"){r();let E=f.find(M=>M.name===u?.to?.blockchain),v=u?.to?.token,N=v&&h(v);(E||!E&&b.current)&&o(E??null),N?e({token:N,meta:{blockchains:f}}):!N&&I.current&&e({token:null}),b.current=u?.to?.blockchain,I.current=u?.to?.token}},[u?.to?.token?.symbol,u?.to?.token?.address,u?.to?.token?.blockchain,u?.to?.blockchain,m]),Cn(()=>{g(u?.affiliate?.ref??null),d(u?.affiliate?.percent??null),S(u?.affiliate?.wallets??null)},[u?.affiliate?.ref,u?.affiliate?.percent,u?.affiliate?.wallets])}i(sm,"useSyncStoresWithConfig");import{useEffect as Ys,useRef as aw}from"react";import{useInRouterContext as sw,useLocation as lw,useSearchParams as cw}from"react-router-dom";function js(t,e){let o=t.split("--");return o[0]?{blockchain:e.name,address:o?.[1]||null,symbol:o[0]}:null}i(js,"convertTokenSearchParamToAsset");function Xs(t){if(t)return`${t.symbol}${t.address?`--${t.address}`:""}`}i(Xs,"tokenToSearchParam");function Js(){let t=lw(),[e,o]=cw(),{fromBlockchain:n,toBlockchain:r,fromToken:a,toToken:s,inputAmount:c,setFromBlockchain:l,setToBlockchain:p,setFromToken:u,setToToken:m,setInputAmount:f}=z()(),h=T().fetchStatus,g=T().blockchains(),d=sw(),{updateIframe:S,updateCampaignMode:y}=T(),C=T().isInCampaignMode(),k=aw(),{findToken:w}=T(),x=i(()=>{let A={};for(let[W,Z]of e.entries())W.startsWith("utm_")&&(A[W]=Z);let b=e.get("fromAmount"),E=e.get("fromBlockchain"),v=e.get("fromToken"),N=e.get("toBlockchain"),M=e.get("toToken"),F=e.get("autoConnect"),H=e.get("clientUrl"),X=e.get("liquiditySources"),J=e.get("blockchain");return{fromAmount:b,fromBlockchain:E,fromToken:v,toBlockchain:N,toToken:M,autoConnect:F,clientUrl:H,liquiditySources:X,utmQueryParams:A,blockchain:J}},"getUrlSearchParams"),I=i(A=>{for(let b in A)A[b]||delete A[b];o(A,{replace:!0})},"updateUrlSearchParams");Ys(()=>{let{autoConnect:A,clientUrl:b,utmQueryParams:E,blockchain:v}=x();d&&h==="success"&&I({fromBlockchain:n?.name,fromToken:Xs(a),toBlockchain:r?.name,toToken:Xs(s),fromAmount:c,autoConnect:A??void 0,clientUrl:b??void 0,blockchain:v??void 0,liquiditySources:C?k.current:void 0,...E})},[t.pathname,c,n,a,r,s,C,h]),Ys(()=>{if(!d)return;let A=x();if(!k.current&&A.liquiditySources&&(k.current=A.liquiditySources),A.fromAmount&&f(A.fromAmount),h==="success"){let b=g.find(H=>H.name===A.fromBlockchain),E=A.fromToken&&b&&js(A.fromToken,b),v=E?w(E):void 0,N=g.find(H=>H.name===A.toBlockchain),M=A.toToken&&N&&js(A.toToken,N),F=M?w(M):void 0;b&&(l(b),v&&u({token:v,meta:{blockchains:g}})),N&&(p(N),F&&m({token:F,meta:{blockchains:g}}))}},[h]),Ys(()=>{let{clientUrl:A,liquiditySources:b}=x();S("clientUrl",A||void 0),y("liquiditySources",b?.split(",")??void 0)},[])}i(Js,"useSyncUrlAndStore");import{i18n as wn}from"@lingui/core";import{Alert as Bv,Button as Wv,darkTheme as Mv,Divider as Al,DoneIcon as Lv,styled as Pv,TextField as _v,Typography as Dv}from"@rango-dev/ui";import Ge,{useState as $v}from"react";import{useNavigate as Fv,useSearchParams as Ov}from"react-router-dom";import{ChevronRightIcon as pw,Divider as dm,Image as uw,Typography as mm}from"@rango-dev/ui";import bt from"react";import{darkTheme as lm,styled as Rs}from"@rango-dev/ui";var cm=Rs("div",{display:"flex",justifyContent:"space-between",width:"100%",height:"$40",padding:"$4 $10",borderRadius:"$sm",cursor:"pointer",alignItems:"center",backgroundColor:"$neutral300",[`.${lm} &`]:{backgroundColor:"$neutral400"},"&:hover":{backgroundColor:"$secondary100",[`.${lm} &`]:{backgroundColor:"$neutral500"}},variants:{disabled:{true:{cursor:"default","&:hover":{borderColor:"$neutral300","& svg":{color:"$neutral700"}}}}}}),pm=Rs("div",{display:"flex",flexDirection:"column",width:"100%",".title_typography":{textTransform:"capitalize"}}),um=Rs("div",{display:"flex"});function el(t){let{onClick:e,value:o,title:n,hasLogo:r,placeholder:a,disabled:s}=t;return bt.createElement(pm,null,bt.createElement(mm,{size:"large",variant:"label"},n),bt.createElement(dm,{size:10}),bt.createElement(cm,{onClick:s?void 0:e,disabled:s,id:"widget-blockchain-selector-container"},bt.createElement(um,null,r&&bt.createElement(bt.Fragment,null,bt.createElement(uw,{src:o?.logo,size:16,useAsPlaceholder:!o?.logo,type:"circular"}),bt.createElement(dm,{size:4,direction:"horizontal"})),bt.createElement(mm,{className:"title_typography",size:"medium",variant:"label"},o?.name||a)),bt.createElement(pw,{size:12,color:"black"})))}i(el,"BlockchainSelectorButton");import{i18n as rl}from"@lingui/core";import{Button as Cw,Divider as Cm,MessageBox as Tw}from"@rango-dev/ui";import uo,{useEffect as Tm,useState as il}from"react";import{i18n as Li}from"@lingui/core";import{Divider as Fo,ExternalLinkIcon as fw,Image as gw,InfoIcon as hw,Tooltip as yw,Typography as ur}from"@rango-dev/ui";import me from"react";var fm="https://blog.rango.exchange/understanding-the-risks-of-using-custom-token-contract-addresses-96022308eca4";function gm(t,e){if(e.type==="COSMOS")return"";let o=e.info?.addressUrl;return!o||!t?"":o.replace("{wallet}",t)}i(gm,"generateExplorerLink");import{Button as dw,darkTheme as Tn,styled as pr,Typography as mw}from"@rango-dev/ui";var tl=pr("a",{textDecoration:"none",color:"$colors$neutral700",[`.${Tn} &`]:{color:"$colors$neutral900"},"& svg":{marginLeft:"$4",color:"$colors$neutral700",[`.${Tn} &`]:{color:"$colors$neutral900"}},variants:{hasHover:{true:{"&:hover":{color:"$colors$secondary550",[`.${Tn} &`]:{color:"$colors$secondary500"},"& svg":{color:"$colors$secondary550",[`.${Tn} &`]:{color:"$colors$secondary500"}}}},false:{}}}}),hm=pr("div",{display:"flex",justifyContent:"center",flexDirection:"column",alignItems:"center",textAlign:"center","& ._blockchain-name, & ._coin-source":{color:"$colors$neutral600",[`.${Tn} &`]:{color:"$colors$neutral800"}},"& ._coin-source-name, & ._custom-token-description":{color:"$colors$neutral700",[`.${Tn} &`]:{color:"$colors$neutral900"}}}),ol=pr(dw,{minHeight:"$40"}),ym=pr(mw,{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"96px"}),Sm=pr("div",{display:"flex",justifyContent:"center",alignItems:"center"});var Sw=9;function nl(t){let{open:e,onClose:o,token:n,onExit:r,onSubmitClick:a,blockchain:s}=t,c=gm(n.address,s),l=i(()=>window.open(fm,"_blank"),"onClickLearnMore");return me.createElement(ee,{open:e,id:"widget-custom-token-watermarked-modal",dismissible:!0,onClose:o,onExit:r,container:B()},me.createElement(hm,null,me.createElement(gw,{src:n.image===""?ei:n.image,size:45,type:"circular"}),me.createElement(Fo,{size:4}),me.createElement(Sm,null,me.createElement(ym,{variant:"title",size:"medium"},n.symbol),n.symbol.length>Sw&&me.createElement(yw,{content:n.symbol,container:B()},me.createElement(hw,{size:12,color:"gray"}))),me.createElement(ur,{variant:"body",size:"small",className:"_blockchain-name"},s.displayName),me.createElement(Fo,{size:4}),me.createElement(ur,{variant:"body",size:"medium"},c?me.createElement(tl,{hasHover:!0,href:c,target:"_blank",rel:"nofollow noreferrer"},n.address,me.createElement(fw,{size:12,color:"gray"})):me.createElement(tl,null,n.address)),me.createElement(Fo,{size:4}),n.coinSource&&me.createElement(ur,{className:"_coin-source",variant:"body",size:"xsmall"},Li.t("via")," ",me.createElement(ur,{className:"_coin-source-name",variant:"body",size:"xsmall"},n.coinSource)),me.createElement(Fo,{size:"32"}),me.createElement(ur,{size:"medium",variant:"body",className:"_custom-token-description"},Li.t("This token is not part of our verified token list. please verify its source and make sure to understand all associated risks before proceeding."))),me.createElement(Fo,{size:40}),me.createElement(Fo,{size:10}),me.createElement(ol,{id:"widget-custom-token-modal-import-btn",variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:a},Li.t("Import Anyway")),me.createElement(Fo,{size:10}),me.createElement(ol,{id:"widget-custom-token-modal-learn-more-btn",variant:"outlined",size:"large",type:"primary",fullWidth:!0,onClick:l},Li.t("Learn More")))}i(nl,"CustomTokenModal");function dr(t){let{token:e,blockchain:o,error:n,address:r,fetchCustomToken:a,onCloseErrorModal:s,onImport:c,onExitErrorModal:l,onExitImportModal:p}=t,{setCustomToken:u}=T(),[m,f]=il(!1),[h,g]=il(!1),[d,S]=il(!1),y=i(()=>{o&&a?.({blockchain:o.name,tokenAddress:r})},"getCustomToken"),C=i(()=>{n?.type!=="network-error"&&s?.(),f(!1)},"closeErrorModal"),k=i(()=>{S(!0),C()},"handleErrorModalButtonClick"),w=i(()=>{d&&n?.type==="network-error"&&(S(!1),y()),l()},"handleExit"),x=i(()=>{e&&(u(e),c())},"handleSubmit");return Tm(()=>{n&&f(!0)},[n]),Tm(()=>{o&&e&&g(!0)},[o,e]),uo.createElement(uo.Fragment,null,uo.createElement(ee,{open:m,dismissible:!0,id:"widget-add-custom-token-modal",onClose:C,onExit:w,container:B()},uo.createElement(Tw,{title:n?.title??"",type:"error",description:n?.message||rl.t("Failed Network, Please retry.")},uo.createElement(Cm,{size:40}),uo.createElement(Cm,{size:10}),uo.createElement(Cw,{id:`widget-add-custom-token-${n?.type==="network-error"?"retry":"add-another"}-btn`,variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:k},n?.type==="network-error"?rl.t("Retry"):rl.t("Add another custom token")))),o&&e&&uo.createElement(nl,{blockchain:o,token:e,onSubmitClick:x,onClose:()=>g(!1),open:h,onExit:p}))}i(dr,"ImportCustomToken");import{useManager as xv}from"@rango-dev/queue-manager-react";import{BottomLogo as bv,Divider as ef,Header as Ev}from"@rango-dev/ui";import We,{useEffect as Qi,useLayoutEffect as Iv,useRef as tf,useState as of}from"react";import{useRef as kw}from"react";function Pi(){return window.self!==window.top}i(Pi,"isAppLoadedIntoIframe");function al(){let t=kw(null),{iframe:e}=T(),o=Pi()&&e.clientUrl,n=i(s=>{o&&window.top?.postMessage(s,e.clientUrl)},"send");return{send:n,connectHeightObserver:i(s=>{t.current=new ResizeObserver(c=>{for(let l of c)n({type:"widget_height",data:{height:l.contentRect.height}})}),t.current.observe(s)},"connectHeightObserver"),disconnectHeightObserver:i(()=>{t.current&&(t.current.disconnect(),t.current=null)},"disconnectHeightObserver")}}i(al,"useIframe");import{useNavigate as ww}from"react-router-dom";function qe(){let t=ww();return()=>t(-1)}i(qe,"useNavigateBack");import{createTheme as ml,darkTheme as _w,lightTheme as Dw}from"@rango-dev/ui";import{useEffect as $w,useState as Fw}from"react";import{theme as Lw,darkColors as Pw}from"@rango-dev/ui";import ul from"react";var _i=16,Di=255,km=.11;function vw(t){return t.startsWith("#")&&(t=t.slice(1)),t.length===3?`#${t.split("").reduce(function(n,r){return n+r+r},"")}`:`#${t}`}i(vw,"expandShortHexColor");function xw(t,e){return t.padStart(e,"0")}i(xw,"pad");function sl(t){let e=Math.min(Math.max(Math.round(t),0),Di);return xw(e.toString(_i),2)}i(sl,"intToHex");function bw(t){return`#${sl(t.red)}${sl(t.green)}${sl(t.blue)}`}i(bw,"rgbToHex");function Ew(t){let e=parseInt(t.slice(1,3),_i),o=parseInt(t.slice(3,5),_i),n=parseInt(t.slice(5,7),_i);return{red:e,green:o,blue:n}}i(Ew,"hexToRGB");function Iw(t,e){let o=1-km*e;return{red:t.red*o,green:t.green*o,blue:t.blue*o}}i(Iw,"generateShade");function Aw(t,e){let o=km*e;return{red:t.red+(Di-t.red)*o,green:t.green+(Di-t.green)*o,blue:t.blue+(Di-t.blue)*o}}i(Aw,"generateTint");function Nw(t){return wm(t,Iw)}i(Nw,"calculateShades");function Bw(t){return wm(t,Aw)}i(Bw,"calculateTints");function wm(t,e){let o=Ew(t),n=[];for(let r=1;r<9;r++)n.push(bw(e(o,r)));return n}i(wm,"calculateColors");function ll(t,e,o){let a=Bw(t).reverse().concat(t),s=Nw(t),c=a.concat(s),l={},p=c.length;for(let u=0;u<p;u++){let m=100+(o?p-1-u:u)*50,f=c[u];f&&(l[`${e}${m}`]=f)}return l}i(ll,"createTintsAndShades");function cl(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)&&!Su(r)){let l=vw(a);Object.assign(n,ll(l,r,s))}}return{...n,...e}}i(cl,"expandToGenerateThemeColors");var vm=i(t=>String.fromCharCode(t+(t>25?39:97)),"toAlphabeticChar"),Ww=i(t=>{let e="",o;for(o=Math.abs(t);o>52;o=o/52|0)e=vm(o%52)+e;return vm(o%52)+e},"toAlphabeticName"),Mw=i((t,e)=>{let o=e.length;for(;o;)t=t*33^e.charCodeAt(--o);return t},"toPhash"),pl=i(t=>Ww(Mw(5381,JSON.stringify(t))>>>0),"toHash");function dl(t){let e=Lw.colors,o={...e,...Pw},n,r;if(t?.light){let s={colors:cl(e,t.light)};n={id:`${fs}-light-${pl(s)}`,tokens:s}}if(t?.dark){let s={colors:cl(o,t.dark,{reverseNeutralRange:!0})};r={id:`${fs}-dark-${pl(s)}`,tokens:s}}return{light:n,dark:r}}i(dl,"customizedThemeTokens");function xm(t,e){if(t.length<=1)return t.map(({element:n,key:r})=>ul.cloneElement(n,{key:r}));let o=[];return t.forEach((n,r)=>{let{element:a,key:s}=n;if(o.push(ul.cloneElement(a,{key:s})),r<t.length-1){let c=`divider-${r}`;o.push(ul.cloneElement(e,{key:c}))}}),o}i(xm,"joinList");function bm(){return window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches}i(bm,"doesWindowPreferDarkColorScheme");function mo(t){let{colors:e,fontFamily:o=ou,borderRadius:n=Mu,secondaryBorderRadius:r=Lu}=t,[a,s]=Fw(bm()?"dark":"light"),{theme:c}=T(),{dark:l,light:p}=dl(e),u=ml({shadows:t.shadows||{},radii:{primary:`${n}px`,secondary:`${r}px`},fonts:{widget:o}}),m=[u.className,Dw.className],f=[u.className,_w.className];if(p){let g=ml(p.id,p.tokens);m.push(g.className)}if(l){let g=ml(l.id,l.tokens);f.push(g.className)}return $w(()=>{let g=i(d=>{d.matches?s("dark"):s("light")},"switchThemeListener");return bm()&&s("dark"),window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",g),()=>{window.matchMedia("(prefers-color-scheme: dark)").removeEventListener("change",g)}},[]),{activeTheme:i(()=>{let g=m.join(" "),d=f.join(" ");return c==="auto"?a==="dark"?d:g:c==="dark"?d:g},"getActiveTheme"),mode:c==="auto"?a:c}}i(mo,"useTheme");var Tt=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 Em}from"@lingui/core";import{Alert as Ow,Button as Uw}from"@rango-dev/ui";import Im from"react";function fl(t){return Im.createElement(Ow,{action:Im.createElement(Uw,{id:"widget-active-tab-btn",onClick:t.onActivateTab,variant:"contained",size:"xxsmall",type:"warning"},Em.t("Activate this tab")),type:"warning",variant:"alarm",title:Em.t("Another tab is open and handles transactions.")})}i(fl,"ActivateTabAlert");import{i18n as gl}from"@lingui/core";import{Button as zw,Divider as Hw,MessageBox as Qw}from"@rango-dev/ui";import $i from"react";function hl(t){let{open:e,onClose:o,onConfirm:n}=t;return $i.createElement(ee,{open:e,dismissible:!0,onClose:o,id:"widget-active-tab-modal",container:B()},$i.createElement(Qw,{title:gl.t("Activate current tab"),type:"warning",description:gl.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.")},$i.createElement(Hw,{size:20}),$i.createElement(zw,{id:"widget-modal-confirm-activate-tab-btn",variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:n},gl.t("Confirm"))))}i(hl,"ActivateTabModal");import{ChevronLeftIcon as Vw}from"@rango-dev/ui";import _m from"react";import{css as qw,darkTheme as Am,IconButton as Gw,styled as Oo}from"@rango-dev/ui";var Dt=Oo(Gw,{width:"$24",position:"relative",padding:"0",overflow:"unset","&:hover":{backgroundColor:"$secondary100",[`.${Am} &`]:{backgroundColor:"$neutral"}}}),Nm=Oo("div",{position:"absolute",background:"$secondary500",[`.${Am} &`]:{$$color:"$colors$secondary250"},width:"$6",height:"$6",borderRadius:"$lg",right:"$4",border:"1px solid $surface100"}),fo=Oo("div",{display:"flex",justifyContent:"flex-end",minWidth:"$40",button:{padding:0}}),Bm=Oo("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"}}}}),Wm=Oo("div",{padding:"$2",variants:{isRefetched:{true:{transform:"rotate(360deg)",transition:"transform 1s ease-in-out"}}}}),Mm=Oo("div",{position:"absolute",right:"$4",top:"$4",backgroundColor:"$background",borderRadius:"100%"}),Lm=qw({display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center"}),Pm=Oo("div",{borderRadius:"100%",border:"1.5px transparent solid","&:not(:first-child)":{marginLeft:"-$6"},img:{borderRadius:"100%"}});function yl(t){return _m.createElement(Dt,{id:"widget-header-back-icon-btn",variant:"ghost",size:"small",onClick:t.onClick},_m.createElement(Vw,{color:"black",size:16}))}i(yl,"BackButton");import{i18n as Kw}from"@lingui/core";import{Button as jw,Typography as Xw}from"@rango-dev/ui";import Sl from"react";function Cl(t){return Sl.createElement(fo,null,Sl.createElement(jw,{id:"widget-header-cancel-btn",variant:"ghost",onClick:t.onClick,size:"xsmall"},Sl.createElement(Xw,{variant:"label",size:"medium",color:"error500"},Kw.t("Cancel"))))}i(Cl,"CancelButton");import{i18n as Yw}from"@lingui/core";import{Image as Zw,Tooltip as Jw,WalletIcon as Rw,WalletState as Dm}from"@rango-dev/ui";import Uo from"react";function Tl(t){let{list:e}=vt(),o=e.filter(r=>r.state===Dm.CONNECTED||r.state===Dm.PARTIALLY_CONNECTED),n=o.length?Uo.createElement("div",{className:Lm()},o.map(r=>Uo.createElement(Pm,{key:r.title},Uo.createElement(Zw,{src:r.image,size:14})))):Yw.t("Connect Wallet");return Uo.createElement(Jw,{container:t.container,side:"bottom",content:n},Uo.createElement(Dt,{id:"widget-header-wallet-icon-btn",variant:"ghost",size:"small",onClick:t.onClick},t.isConnected&&Uo.createElement(Nm,null),Uo.createElement(Rw,{size:18,color:"black"})))}i(Tl,"WalletButton");import{i18n as Oi}from"@lingui/core";import{NotificationsIcon as gv,Popover as hv,SettingsIcon as yv,Tooltip as Ui,TransactionIcon as Sv}from"@rango-dev/ui";import Pe from"react";import{Notifications as nv}from"@rango-dev/ui";import rv from"react";import{useNavigate as iv}from"react-router-dom";import{create as ev}from"zustand";import{persist as tv,subscribeWithSelector as ov}from"zustand/middleware";var Be=co(ev()(tv(ov((t,e)=>({isSynced:!1,notifications:[],setNotification:(o,n)=>{let r=n.steps[0],a=n.steps[n.steps.length-1];if(!r||!a)return;let 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}}},c=e().notifications.filter(l=>l.requestId!==n.requestId);t(()=>({notifications:[...c,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(l=>l.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 kl(){let t=iv(),{getNotifications:e,clearNotifications:o}=Be(),n=e(),r=T().blockchains(),{findToken:a}=T();return rv.createElement(nv,{id:"widget-notifications-container",list:n,getBlockchainImage:c=>Kp(c,r),getTokenImage:c=>a(c)?.image,onClickItem:i(c=>{t(`${$.swaps}/${c}`)},"onClickItem"),onClearAll:o})}i(kl,"NotificationContent");import{useManager as av}from"@rango-dev/queue-manager-react";import{InProgressIcon as sv}from"@rango-dev/ui";import $m from"react";var lv=i(()=>{let{manager:t}=av();return Tt(t).map(({swap:o})=>o).find(o=>o.status==="running")?$m.createElement(Mm,{id:"widget-header-history-badge-container"},$m.createElement(sv,{color:"info",size:6})):null},"InProgressTransactionBadge"),Fm=lv;import{EventSeverity as cv}from"@rango-dev/queue-manager-rango-preset";import{Typography as pv}from"@rango-dev/ui";import Om from"react";function Um(){let{getNotifications:t}=Be(),e=t(),o=e.length,n=!!e.find(r=>r.event.messageSeverity===cv.WARNING);return o?Om.createElement(Bm,{isSever:n},Om.createElement(pv,{variant:"body",size:"xsmall",color:"$background",id:"widget-header-notifications-badge-container"},o)):null}i(Um,"NotificationsBadge");import{RefreshProgressButton as uv}from"@rango-dev/ui";import wl,{useEffect as dv,useState as zm}from"react";var mv=1e3,Hm=60,fv=100;function Fi({onClick:t}){let[e,o]=zm(0),[n,r]=zm(!1),a=i(l=>{document.hidden&&l&&s(l)},"handleVisibilityChange");dv(()=>{let l;return t?l=window.setInterval(()=>{o(p=>p+1),e===Hm&&c()},mv):s(l),document.addEventListener("visibilitychange",()=>a(l)),()=>{document.removeEventListener("visibilitychange",()=>a(l)),l&&clearInterval(l)}},[e,t]);let s=i(l=>{l&&clearInterval(l),o(0)},"clearTimeout"),c=i(()=>{t?.(),o(0),r(!0)},"handleRefreshClick");return wl.createElement(Dt,{id:"widget-header-refresh-icon-btn",variant:"ghost",size:"small",style:{paddingTop:0,paddingBottom:0},onClick:c,disabled:!t},wl.createElement(Wm,{onTransitionEnd:()=>r(!1),isRefetched:n},wl.createElement(uv,{size:22,color:t?"black":"gray",progress:e/Hm*fv})))}i(Fi,"RefreshButton");function zo(t){let{onClickRefresh:e,onClickHistory:o,onClickSettings:n,hidden:r=[],container:a}=t,{config:{features:s}}=T(),c=et("notification",s)||r.includes("notifications");return Pe.createElement(Pe.Fragment,null,!r.includes("refresh")&&Pe.createElement(Ui,{container:a||B(),side:"top",content:Oi.t("Refresh")},Pe.createElement(Fi,{onClick:e})),!c&&Pe.createElement(hv,{align:"end",alignOffset:-88,sideOffset:15,collisionPadding:{right:20,left:20},container:B(),content:Pe.createElement(kl,null)},Pe.createElement("div",null,Pe.createElement(Ui,{container:B(),side:"top",content:Oi.t("Notifications")},Pe.createElement(Dt,{id:"widget-header-notification-icon-btn",size:"small",variant:"ghost"},Pe.createElement(gv,{size:18,color:"black"}),Pe.createElement(Um,null))))),!r.includes("settings")&&Pe.createElement(Ui,{container:B(),side:"top",content:Oi.t("Settings")},Pe.createElement(Dt,{id:"widget-header-setting-icon-btn",size:"small",variant:"ghost",onClick:n},Pe.createElement(yv,{size:18,color:"black"}))),!r.includes("history")&&Pe.createElement(Ui,{container:B(),side:"top",content:Oi.t("History")},Pe.createElement(Dt,{id:"widget-header-history-icon-btn",size:"small",variant:"ghost",onClick:o},Pe.createElement(Sv,{size:18,color:"black"}),Pe.createElement(Fm,null))))}i(zo,"HeaderButtons");import{i18n as vl}from"@lingui/core";import{Divider as qm,MessageBox as kv,RefreshIcon as wv}from"@rango-dev/ui";import kn from"react";import{Button as Cv,styled as Tv}from"@rango-dev/ui";var Qm=Tv(Cv,{"& span":{display:"flex",justifyContent:"center",alignItems:"center"}});function xl(t){let{open:e,onClose:o}=t;return kn.createElement(ee,{open:e,dismissible:!0,onClose:o,id:"widget-refresh-modal",container:B()},kn.createElement(kv,{title:vl.t("Something went wrong"),type:"error",description:vl.t("Something went wrong. Please refresh the app.")},kn.createElement(qm,{size:30}),kn.createElement(Qm,{variant:"outlined",id:"widget-refresh-modal-refresh-btn",size:"large",type:"primary",fullWidth:!0,onClick:()=>location.reload()},kn.createElement(wv,{size:20,color:"primary"}),kn.createElement(qm,{size:4,direction:"horizontal"}),vl.t("Refresh"))))}i(xl,"RefreshModal");var Gm="700px",Vm="425px",Km="550px",jm="640px",Xm="800px";function bl(t){let e=t.target;if(e){let o=e.scrollTop,n=B();o>1?n.classList.add("rng-scrolled"):n.classList.remove("rng-scrolled")}}i(bl,"onScrollContentAttachStatusToContainer");import{css as vv,styled as zi}from"@rango-dev/ui";var Hi=vv({borderRadius:"$primary",display:"flex",flexDirection:"column",overflow:"hidden",boxShadow:"$mainContainer"}),Ym=zi("div",{position:"relative",width:"100vw",minWidth:"300px",maxWidth:"390px",backgroundColor:"$background",maxHeight:Gm,variants:{height:{auto:{height:"auto"},fixed:{height:"100%",minHeight:Vm,[`@media screen and (min-height: ${Xm})`]:{minHeight:Km}}},showBanner:{true:{overflow:"visible"}}}}),Zm=zi("div",{position:"relative",overflow:"hidden",flexGrow:1,display:"flex",flexDirection:"column",padding:0,overflowY:"auto"}),Jm=zi("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"}}}),Rm=zi("div",{width:"100%",position:"absolute",bottom:"-$10",transform:"translateY(100%)",overflow:"hidden"});function ie(t){let{connectHeightObserver:e,disconnectHeightObserver:o}=al(),{children:n,header:r,footer:a,height:s="fixed"}=t,{fetchStatus:c,connectedWallets:l,config:{__UNSTABLE_OR_INTERNAL__:p}}=T(),[u,m]=of(!1),{config:{features:f,theme:h}}=T(),{watermark:g}=oe(),d=g==="FULL",{activeTheme:S}=mo(h||{}),[y,C]=of(!1),k=et("connectWalletButton",f),{isActiveTab:w,tabManagerInitiated:x,showActivateTabModal:I,setShowActivateTabModal:A,activateCurrentTab:b,setShowCompactTokenSelector:E}=oe(),v=qe(),{manager:N}=xv(),F=Tt(N).map(({swap:Y})=>Y).some(Y=>Y.status==="running"),H=i(()=>b(Po.forceClaim,F),"onActivateTab"),X=i(()=>{r.onWallet?.()},"onConnectWallet"),J=typeof r.hasBackButton>"u"||r.hasBackButton,W=tf(null),Z=tf(null);return Qi(()=>{let Y=(p?.swapBoxBanner?.routes?.length??0)===0,ce=!!p?.swapBoxBanner?.routes?.some(fe=>location.pathname.endsWith(fe));C(!!p?.swapBoxBanner&&(Y||ce))},[p?.swapBoxBanner?.routes?.toString(),location.pathname]),Qi(()=>(Pi()&&Z.current&&e(Z.current),()=>{o()}),[]),Qi(()=>(W.current?.addEventListener("scroll",bl),()=>{W.current?.removeEventListener("scroll",bl)}),[]),Qi(()=>{m(c==="failed")},[c]),Iv(()=>{if(!Z.current)return;let Y=new ResizeObserver(ce=>{for(let fe of ce)fe.contentRect&&E(fe.contentRect.height<parseInt(jm))});return Y.observe(Z.current),()=>Y.disconnect()},[]),We.createElement(Ym,{height:s,id:Re.SWAP_BOX_ID,className:`${S()} ${Hi()}`,ref:Z,showBanner:y},We.createElement(Ev,{prefix:J?We.createElement(yl,{onClick:()=>{v(),r.onBack?.()}}):null,title:r.title,suffix:We.createElement(We.Fragment,null,r.suffix,r.onWallet&&!k&&We.createElement(Tl,{container:B(),onClick:X,isConnected:!!l?.length}),r.onCancel&&We.createElement(Cl,{onClick:r.onCancel}))}),We.createElement(Zm,{ref:W},n),We.createElement(hl,{open:I,onClose:()=>A(!1),onConfirm:H}),We.createElement(Jm,null,We.createElement("div",{className:"footer__content"},x&&!w&&We.createElement("div",{className:"footer__alert"},We.createElement(fl,{onActivateTab:H}),We.createElement(ef,{size:10})),a),We.createElement(ef,{size:12}),We.createElement("div",{className:`footer__logo ${d?"logo__show":"logo__hidden"}`},We.createElement(bv,null))),y&&We.createElement(Rm,null,p?.swapBoxBanner?.element),We.createElement(xl,{open:u,onClose:()=>m(!1)}))}i(ie,"Layout");import{styled as Av}from"@rango-dev/ui";var nf="$20 $20 $10 $20",El=Av("div",{padding:nf,overflowY:"auto",flexGrow:1});import{styled as Nv}from"@rango-dev/ui";var le=Nv("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 Il}from"react";function rf(){let[t,e]=Il(!1),[o,n]=Il(null),[r,a]=Il(null),{findToken:s}=T(),c=T().customTokens(),l=i(()=>{a(null),e(!1),n(null)},"resetState");function p(m,f){switch(m){case"duplicated":return{type:m,title:go.t("Duplicate Token"),message:go.t("The address you entered is duplicate, please enter a new address.")};case"token-exist":return{type:m,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{type:m,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:f}})};case"network-error":return{type:m,title:go.t("Network error"),message:go.t("An error occurred while retrieving token data.")}}}return i(p,"produceErrorMessage"),{fetchCustomToken:i(async({blockchain:m,tokenAddress:f})=>{e(!0);try{if(c.some(y=>y.address?.toLowerCase()===f.toLowerCase())){let y=p("duplicated");n(y);return}let g=await ct().getCustomToken({blockchain:m,address:f});if(!g||!g.token||g.error){let y=p("not-found",m);n(y);return}let d=g.token;if(s({blockchain:d.blockchain,address:d.address,symbol:d.symbol})){let y=p("token-exist");n(y);return}return a({...d,warning:!0})}catch(h){if(h.code==="ERR_BAD_REQUEST"){let g=p("not-found",m);n(g);return}n(p("network-error"));return}finally{e(!1)}},"fetchCustomToken"),token:r,loading:t,error:o,resetState:l}}i(rf,"useFetchCustomToken");var Uv=Pv("div",{display:"flex",justifyContent:"space-between",flexDirection:"column",flex:1,"& ._text-field":{padding:"$4 $12",backgroundColor:"$neutral300","& input":{padding:"0"},[`.${Mv} &`]:{backgroundColor:"$neutral400"},borderRadius:"$sm",height:"$40"}});function af(){let t=Fv(),[e]=Ov(),o=qe(),n=T().blockchains(),r=e.get("blockchain")||"",a=No(r,n),[s,c]=$v(""),{fetchCustomToken:l,token:p,loading:u,error:m,resetState:f}=rf(),h=!!a&&tn(a,s),g=!a||!s||!h,d=i(()=>{a&&l({blockchain:r,tokenAddress:s})},"getCustomToken");return Ge.createElement(ie,{header:{title:wn.t("Add Custom Token")}},Ge.createElement(le,null,Ge.createElement(Uv,null,Ge.createElement("div",null,Ge.createElement(el,{onClick:()=>t($.blockchains,{replace:!0}),hasLogo:!!a?.logo,value:a?{name:a.displayName,logo:a.logo}:void 0,title:wn.t("Select chain"),placeholder:wn.t("Select chain")}),Ge.createElement(Al,{size:"24"}),Ge.createElement(Dv,{size:"large",variant:"label"},wn.t("Enter Address")),Ge.createElement(Al,{size:10}),Ge.createElement(_v,{fullWidth:!0,id:"widget-add-custom-token-token-address-input",disabled:!a,variant:"contained",placeholder:wn.t("Enter token address"),size:"large",value:s,suffix:!!s&&h&&Ge.createElement(Lv,{color:"success",size:12}),onChange:S=>c(S.target.value)}),!h&&!!s&&Ge.createElement(Ge.Fragment,null,Ge.createElement(Al,{size:4}),Ge.createElement(Bv,{id:"widget-add-custom-token-invalid-address-alert",type:"error",variant:"alarm",title:"Invalid Address"}))),Ge.createElement(Wv,{id:"widget-add-custom-token-import-btn",disabled:g,type:"primary",variant:"contained",loading:u,size:"large",onClick:d},wn.t("Import"))),Ge.createElement(dr,{token:p,blockchain:a??void 0,address:s,error:m??void 0,fetchCustomToken:l,onCloseErrorModal:()=>{m?.type!=="network-error"&&c("")},onImport:o,onExitErrorModal:f,onExitImportModal:f})))}i(af,"AddCustomTokenPage");import{i18n as cc}from"@lingui/core";import{useManager as Nb}from"@rango-dev/queue-manager-react";import{Alert as Bb,Button as Wb,css as uc,Divider as pc,IconButton as Jg,styled as Mb,Typography as Lb,WalletIcon as Pb}from"@rango-dev/ui";import $e,{useEffect as ya,useLayoutEffect as _b,useRef as Db,useState as xr}from"react";import{useNavigate as $b}from"react-router-dom";import{i18n as Ho}from"@lingui/core";import{Alert as dx,BalanceErrors as mx,Button as Mf,ChevronLeftIcon as fx,Divider as Dl,MessageBox as gx,Typography as $l}from"@rango-dev/ui";import re,{useCallback as hx,useEffect as Lf,useMemo as yx,useState as En}from"react";import{useNavigate as Sx}from"react-router-dom";import{i18n as Ml}from"@lingui/core";import{Alert as Gv,ChevronDownIcon as Vv,CloseIcon as Kv,Divider as mf,IconButton as ff,PasteIcon as jv,Typography as Xv,WalletIcon as Yv}from"@rango-dev/ui";import _e,{useEffect as Zv,useRef as Jv}from"react";import Ki,{useRef as Qv}from"react";import*as vn from"@radix-ui/react-collapsible";import{keyframes as sf,styled as qi}from"@rango-dev/ui";var Nl=300,zv=sf({from:{height:0},to:{height:"var(--radix-collapsible-content-height)"}}),Hv=sf({from:{height:"var(--radix-collapsible-content-height)"},to:{height:0}}),lf=qi(vn.Root,{borderRadius:"$sm",overflow:"hidden",variants:{selected:{true:{outlineWidth:1,outlineColor:"$secondary500",outlineStyle:"solid"}}}}),Bl=qi(vn.Trigger,{padding:"$0",border:"none",outline:"none",width:"100%",backgroundColor:"transparent",fontFamily:"inherit",cursor:"pointer"}),Gi=qi(vn.Content,{overflow:"hidden",variants:{open:{true:{animation:`${zv} ${Nl}ms ease-out`},false:{animation:`${Hv} ${Nl}ms ease-out`}}}}),Vi=qi("div",{transition:`all ${Nl}ms ease`,display:"flex",alignItems:"center",variants:{orientation:{down:{transform:"rotate(0)"},up:{transform:"rotate(180deg)"}}}});function ji(t){let{open:e,hasSelected:o,onOpenChange:n,children:r,onClickTrigger:a,trigger:s,triggerAnchor:c}=t,l=Qv(null);return Ki.createElement(lf,{ref:l,className:"collapsible_root",selected:o&&e,open:e,onOpenChange:n},c==="top"&&Ki.createElement(Bl,{className:"collapsible_trigger",onClick:a},s),Ki.createElement(Gi,{className:"collapsible_content",open:e},r),c==="bottom"&&Ki.createElement(Bl,{className:"collapsible_trigger",onClick:a},s))}i(ji,"CustomCollapsible");import{darkTheme as cf,styled as Wl,TextField as qv}from"@rango-dev/ui";var pf=Wl("div",{padding:"$10 $0","& .button__content":{display:"flex",alignItems:"center"},"& .alarms":{paddingTop:"$5"},"& .collapsible_content":{backgroundColor:"$neutral100"},"& .collapsible_root":{backgroundColor:"$neutral100"},"& input":{padding:"$15"}}),uf=Wl(qv,{backgroundColor:"$neutral100"}),df=Wl("div",{width:"100%",borderRadius:"$sm",display:"flex",padding:"$15",justifyContent:"space-between",alignItems:"center",$$color:"$colors$neutral100",[`.${cf} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",borderBottomRightRadius:"0",borderBottomLeftRadius:"0","&:focus-visible":{$$background:"$colors$secondary100",[`.${cf} &`]:{$$background:"$colors$info700"},backgroundColor:"$$background",outline:0}});function gf(t){let{blockchain:e,handleOpenChange:o,open:n}=t,{customDestination:r,setCustomDestination:a}=z()(),{config:s}=T(),c=T().blockchains(),l=Jr(e.name,c),p=Jv(null),u=s?.defaultCustomDestinations?.[e.name],m=navigator?.userAgent.includes("Firefox"),h=n&&!!r&&e&&!tn(e,r),g=i(()=>{a("")},"handleClear"),d=i(async y=>{if(y.preventDefault(),navigator.clipboard!==void 0){let C=await navigator.clipboard.readText();a(C),p?.current?.focus()}},"handlePaste"),S=i(()=>r?_e.createElement(ff,{id:"widget-custom-destination-close-icon-btn",onClick:g,variant:"ghost"},_e.createElement(Kv,{size:12,color:"gray"})):m?null:_e.createElement(ff,{id:"widget-custom-destination-paste-icon-btn",onClick:d,variant:"ghost"},_e.createElement(jv,{size:16})),"renderSuffix");return Zv(()=>{!!u&&r===null&&(a(u),o(!0))},[u]),_e.createElement(pf,null,_e.createElement(ji,{onOpenChange:o,hasSelected:!0,open:n,triggerAnchor:"top",trigger:_e.createElement(df,{id:"widget-custom-destination-collapsible-btn"},_e.createElement("div",{className:"button__content"},_e.createElement(Yv,{size:18,color:"info"}),_e.createElement(mf,{size:4,direction:"horizontal"}),_e.createElement(Xv,{variant:"label",size:"medium",color:n?"$neutral600":void 0},Ml.t("Send to a different address"))),_e.createElement(Vi,{orientation:n?"up":"down"},_e.createElement(Vv,{size:10,color:"secondary"}))),onClickTrigger:()=>o(!n)},_e.createElement(uf,{id:"widget-custom-destination-blockchain-address-input",ref:p,style:{padding:0,paddingRight:r?"8px":"5px"},autoFocus:!r,placeholder:Ml.t("Enter {blockchainName} address",{blockchainName:l}),value:r||"",suffix:S(),onChange:y=>{let C=y.target.value;a(C)}})),h&&_e.createElement(_e.Fragment,null,_e.createElement(mf,{size:4}),_e.createElement(Gv,{variant:"alarm",type:"error",title:Ml.t({values:{destination:r},id:"Address {destination} doesn't match the blockchain address pattern."})})))}i(gf,"CustomDestination");import{css as Rv,IconButton as ex,SelectableWalletButton as tx,styled as ho}from"@rango-dev/ui";var hf=ho("div",{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center"}),yf=ho("div",{display:"flex",justifyContent:"space-evenly",alignItems:"center",columnGap:"$5",rowGap:"$10",flexWrap:"wrap",paddingTop:"$5",height:"100%"}),Sf=ho(tx,{justifyContent:"center"}),Cf=ho("div",{padding:"$20 $20 $15 $20",display:"flex",justifyContent:"center",alignItems:"center",backgroundColor:"$neutral200",position:"relative",width:"100%"}),Tf=ho(ex,{position:"absolute",left:"$20"}),kf=ho("div",{paddingTop:"$20"}),wf=Rv({display:"flex",justifyContent:"space-evenly",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5",height:"100%"}),vf=ho("div",{display:"flex"}),xf=ho("div",{overflow:"visible",width:"100%"});import{i18n as Pl}from"@lingui/core";import{warn as ax}from"@rango-dev/logging-core";import{Divider as sx,makeInfo as lx,SelectableWallet as cx,Typography as Bf,WalletState as bn}from"@rango-dev/ui";import nt,{useEffect as Wf,useState as fr}from"react";import{Image as rx,MessageBox as ix}from"@rango-dev/ui";import mr from"react";import{keyframes as ox,styled as Ll}from"@rango-dev/ui";var bf=Ll("div",{position:"relative"}),nx=ox({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}),Ef=Ll("div",{position:"absolute",border:"2px solid rgba(0, 0, 0, 0.1)",borderTop:"2px solid $info500",borderRadius:"$lg",width:"$45",height:"$45",animation:`${nx} 1s linear infinite`,top:0,bottom:0,right:0,left:0}),If=Ll("div",{"& img":{borderRadius:"50%"}});import{i18n as xn}from"@lingui/core";function Af(t,e){switch(t){case"in-progress":return{type:"loading",title:xn.t({id:"Add {blockchainDisplayName} Chain",values:{blockchainDisplayName:e}}),description:xn.t({id:"Please approve the experimental chain pop-up in your wallet.",values:{blockchainDisplayName:e}})};case"completed":return{type:"success",title:xn.t({id:"{blockchainDisplayName} Chain Added",values:{blockchainDisplayName:e}}),description:xn.t({id:"The {blockchainDisplayName} chain has been successfully added to your wallet.",values:{blockchainDisplayName:e}})};case"rejected":return{type:"error",title:xn.t("Request Rejected"),description:xn.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(Af,"generateMessageByStatus");function Nf(t){let{status:e,displayName:o,image:n}=t,r=Af(e,o),a=e=="in-progress";return mr.createElement(ix,{type:r.type,title:r.title,description:r.description,icon:a?mr.createElement(bf,null,mr.createElement(If,null,mr.createElement(rx,{src:n,size:45})),mr.createElement(Ef,null)):void 0})}i(Nf,"ExperimentalChainStatus");var px=7,ux=3e3;function _l(t){let{chain:e,quoteChains:o,isSelected:n,selectWallet:r,limit:a,onShowMore:s}=t,c=oe.use.isActiveTab(),{blockchains:l,connectedWallets:p}=T(),[u,m]=fr(),[f,h]=fr(null),[g,d]=fr(!1),[S,y]=fr(null),{suggestAndConnect:C}=Xi(),{list:k}=vt({chain:e}),[w,x]=fr(k),I=k.length,A=a&&I-a>0,b=i(async v=>{d(!1),y("in-progress");try{await C(v.walletType,v.chain),y("completed")}catch{y("rejected")}},"addExperimentalChain");Wf(()=>{x(v=>{let N=k.findIndex(M=>n(M.type,e));return A&&N>1?[k[N]].concat(k.filter((M,F)=>F!==N)):v.map(M=>k.find(F=>F.type===M.type)??M)})},[JSON.stringify(k)]);let E=document.getElementById(Re.SWAP_BOX_ID);return Wf(()=>{let v=null;return(S==="completed"||S==="rejected")&&(v=setTimeout(()=>y(null),ux)),()=>{v&&clearTimeout(v)}},[S]),nt.createElement(nt.Fragment,null,w.slice(0,a).map(v=>{let N=Eu({connectedWallets:p,walletType:v.type,chain:e}),M=v.state===bn.CONNECTED||v.state===bn.PARTIALLY_CONNECTED,F=N?lo(N,px):"",H=M&&!!v.needsNamespace&&!F,X=ci(l(),e),J=!p.find(ue=>ue.walletType===v.type&&ue.chain===e),W=X&&J&&v.state===bn.CONNECTED,Z=i(async()=>{v.state===bn.DISCONNECTED||H?m(v):W?(h({walletType:v.type,chain:e,address:N??""}),d(!0)):r({walletType:v.type,chain:e,address:N??""})},"onSelectableWalletClick"),Y=lx(v.state),ce=i(()=>W?Pl.t({id:"Add {chain} chain",values:{chain:e}}):H?Pl.t("Chain not connected"):F||Y.description,"getWalletDescription"),fe=i(()=>v.state===bn.CONNECTED||v.state===bn.PARTIALLY_CONNECTED?H?"neutral600":"neutral700":Y.color,"getWalletDescriptionColor"),at=f?.chain?Jr(f.chain,l()):void 0;return nt.createElement(nt.Fragment,{key:`${v.title}_${at}`},!!f&&nt.createElement(ee,{id:"widget-wallets-list-watermarked-modal",open:!!f&&g,container:E,onClose:()=>{h(null)}},nt.createElement(zs,{id:"widget-wallets-list-experimental-chain-container",displayName:at,onConfirm:()=>{b(f)}})),S&&nt.createElement(ee,{id:"widget-wallets-list-experimental-chain-watermarked-modal",open:!!S,onClose:y.bind(null,null),container:E},nt.createElement(Nf,{status:S,displayName:at,image:v.image}),nt.createElement(sx,{direction:"vertical",size:32})),nt.createElement(cx,{key:v.type,id:"widget-wallets-list-selectable-wallet-btn",description:ce(),descriptionColor:fe(),onClick:Z,selected:n(v.type,e),disabled:!c,...v}))}),nt.createElement(ar,{id:"widget-wallets-list-stateful-connect-modal",wallet:u,options:{defaultSelectedChains:o||[e]},onClose:()=>{m(void 0)},onConnect:()=>{t.onConnect&&(u?.type?t.onConnect(u.type):ax(new Error("The selected wallet hasn't been detected after the connection process finished. It usually shouldn't happen.")))}}),A&&nt.createElement(Sf,{selected:!1,onClick:s,id:"widget-wallets-list-show-more-wallets-btn"},nt.createElement(Bf,{variant:"label",size:"medium"},Pl.t("Show more wallets"),nt.createElement(Bf,{variant:"label",size:"medium",color:"$primary"},"\xA0+",I-(a??0)))))}i(_l,"WalletList");var Cx=2;function Pf(t){let{open:e,onClose:o,onCancel:n,onCheckBalance:r,loading:a}=t,s=Sx(),c=T().blockchains(),{selectedQuote:l,setSelectedWallets:p,quoteWalletsConfirmed:u,setQuoteWalletConfirmed:m,customDestination:f,setCustomDestination:h}=z()(),{config:g,connectedWallets:d,setWalletsAsSelected:S}=T(),[y,C]=En(""),[k,w]=En([]),[x,I]=En(""),[A,b]=En(!!f),E=yx(()=>Mo({filter:"all",quote:l}),[l]),v=Mo({filter:"required",quote:l}),N=c.find(D=>D.name===l?.swaps[l?.swaps.length-1]?.to.blockchain),M=i(D=>v.includes(D),"isWalletRequiredFor"),F=hx(()=>d.filter(D=>D.selected&&E.includes(D.chain)),[d,E]),[H,X]=En(F()),[J,W]=En([]),Z=i((D,U)=>W(G=>G.concat({blockchain:D,walletType:U})),"addNextSelectedWallets"),Y=k.length>0,ce=i((D,U)=>!!H.find(G=>G.walletType===D&&G.chain===U&&G.selected&&(M(U)||!M(U)&&!f)),"isSelected"),fe=i((D,U,G)=>{let se=!1;return D.map(Q=>{if(Q.chain===U){let j=Q.selected;return!se&&G?(se=!0,j=!0):G||(j=!1),{...Q,selected:j}}return Q})},"updateSelectableWallets"),at=i(D=>{b(D),D?M(N?.name??"")||X(U=>fe(U,N?.name||"",!1)):(h(""),X(U=>fe(U,N?.name||"",!0)))},"handleCustomDestinationCollapsibleOpenChange"),ue=i(D=>{if(y&&C(""),ce(D.walletType,D.chain))return;let G=d.find(se=>se.walletType===D.walletType&&se.chain===D.chain);G&&(n(),D.chain===N?.name&&A&&!M(N.name)&&(b(!1),h(null)),X(se=>se.filter(Q=>Q.chain!==D.chain).concat({...G,selected:!0})))},"onChange"),wt=i(()=>{let D=H.filter(U=>U.selected);S(D),p(D),m(!0),o()},"onConfirmBalance"),gt=i(async()=>{w([]),I("");let D=await r?.({selectedWallets:H.filter(G=>G.selected),customDestination:f}),U=D.warnings;U?.balance?.messages&&w(U.balance.messages),D.error&&I(wd(D.error)),!D.error&&!U?.balance?.messages.length?wt():w(U?.balance?.messages??[])},"onConfirmWallets");Lf(()=>{X(D=>{let U=[];return D.forEach(G=>{!d.some(Q=>Q.chain===G.chain&&Q.walletType===G.walletType&&Q.address===G.address)||U.push(G)}),U=U.concat(d.filter(G=>!!!U.find(Q=>Q.chain===G.chain)&&G.selected&&E.includes(G.chain))),U})},[d,E]),Lf(()=>{let D=[];J.length>0&&(J.forEach(U=>{let G=d.find(se=>se.chain===U.blockchain&&se.walletType===U.walletType);G?ue(G):D.push(U)}),W(D))},[d,J]);let Wt=document.getElementById(Re.SWAP_BOX_ID);return re.createElement(ee,{id:"widget-confirm-wallets-modal",open:e,onClose:()=>{u||s("../",{replace:!0}),o()},dismissible:!y,container:Wt,...!y&&{styles:{container:{height:"100%"}},footer:re.createElement(vf,null,re.createElement(Mf,{id:"widget-confirm-wallet-modal-confirm-btn",loading:a,disabled:Zd(a,A,f,l,H,N),onClick:gt,variant:"contained",type:"primary",fullWidth:!0,size:"large"},Ho.t("Confirm")))},...y&&{styles:{container:{height:"100%",padding:"$0"}},header:re.createElement(Cf,null,re.createElement(Tf,{id:"widget-confirm-wallet-modal-navigate-back-icon-btn",variant:"ghost",onClick:C.bind(null,"")},re.createElement(fx,{size:16})),re.createElement($l,{variant:"headline",size:"small"},Ho.t({id:"Your {blockchainName} wallets",values:{blockchainName:ht(y,c)}})))},anchor:"center"},re.createElement(ee,{id:'"widget-confirm-wallets-insufficient-account-balance-modal',open:Y,onClose:w.bind(null,[]),container:Wt},re.createElement(gx,{title:Ho.t("Insufficient account balance"),type:"error",description:re.createElement(mx,{messages:k??[]})},re.createElement(Mf,{id:"widget-confirm-wallet-modal-proceed-anyway-btn",variant:"outlined",size:"large",type:"primary",fullWidth:!0,onClick:wt},Ho.t("Proceed anyway")))),y&&re.createElement(kf,null,re.createElement("div",{className:wf()},re.createElement(_l,{chain:y,quoteChains:E,isSelected:ce,selectWallet:ue,onShowMore:()=>C(y),onConnect:D=>{Z(y,D)}}))),!y&&re.createElement(re.Fragment,null,x&&re.createElement(re.Fragment,null,re.createElement(dx,{id:"widget-confirm-wallet-modal-error-alert",variant:"alarm",type:"error",title:Ho.t(x)}),re.createElement(Dl,{size:12})),re.createElement(xf,null,E.map((D,U)=>{let G=c.find(K=>K.name===D),se=`wallet-${U}`,Q=U===E.length-1,j=Q&&N&&g?.customDestination!==!1;return re.createElement("div",{key:se},re.createElement(hf,null,re.createElement($l,{variant:"title",size:"xmedium"},Ho.t({id:"Your {blockchainName} wallets",values:{blockchainName:G?.shortName}})),re.createElement($l,{variant:"label",color:"$neutral700",size:"medium"},Ho.t({id:"You need to connect a {blockchainName} wallet.",values:{blockchainName:G?.shortName}}))),re.createElement(Dl,{size:24}),re.createElement(yf,null,re.createElement(_l,{chain:D,quoteChains:E,isSelected:ce,selectWallet:ue,limit:Cx,onShowMore:()=>C(G?.name??""),onConnect:K=>{Z(D,K)}})),!Q&&re.createElement(Dl,{size:32}),j&&re.createElement(gf,{blockchain:N,open:A,handleOpenChange:at}))}))))}i(Pf,"ConfirmWalletsModal");import{i18n as Gx}from"@lingui/core";import{Alert as Vx,Button as Kx,Divider as eg,InfoIcon as jx}from"@rango-dev/ui";import Oe from"react";import{Alert as wx,Button as vx,Divider as Ul,NoRouteIcon as xx,RefreshIcon as bx,Typography as zf}from"@rango-dev/ui";import pt from"react";import{i18n as _f}from"@lingui/core";var Tx=24,kx=60;function Df(t,e,o,n){return t?.type===1?{alert:{type:"warning",text:ne().genericServerError,action:{onClick:n,title:_f.t("Retry")}},description:""}:e.length?{alert:{type:"warning",text:ne().liquiditySourcesError.title,action:{onClick:()=>o(!0),title:_f.t("Reset")}},description:ne().liquiditySourcesError.description}:t?.type===0&&t.diagnosisMessage?{alert:{type:"error",text:t.diagnosisMessage,action:null},description:""}:{alert:null,description:ne().noResultError.description}}i(Df,"makeInfo");var Fl=(o=>(o[o.small=Tx]="small",o[o.large=kx]="large",o))(Fl||{}),Ol=(o=>(o.small="small",o.large="medium",o))(Ol||{});import{styled as Yi}from"@rango-dev/ui";var $f=Yi("div",{display:"flex",flexDirection:"column",alignItems:"center"}),Ff=Yi("div",{variants:{size:{small:{},large:{maxWidth:"316px"}}}}),Of=Yi("div",{variants:{size:{small:{width:"100%"},large:{}}}}),Uf=Yi("div",{padding:"$6 $0"});function gr(t){let{fetch:e,error:o,size:n="small",skipAlerts:r}=t,a=T().getDisabledLiquiditySources(),s=T().toggleAllLiquiditySources,c=T().swappers(),l=Df(o,a,()=>s(c,!0),e);return r&&(l.alert=null),pt.createElement($f,{id:"widget-no-result-container"},pt.createElement(xx,{size:Fl[n],color:"gray"}),pt.createElement(Ul,{size:4}),pt.createElement(zf,{variant:"title",size:Ol[n]},ne().noResultError.title),n==="large"&&pt.createElement(Ul,{size:4}),!!l.description&&pt.createElement(Ff,{size:n},pt.createElement(zf,{variant:"body",size:"small",align:"center",color:"neutral700"},l.description)),pt.createElement(Ul,{size:n==="large"?"24":"4"}),!!l.alert&&pt.createElement(Of,{size:n},pt.createElement(wx,{id:"widget-no-result-alert",type:l.alert.type,title:l.alert.text,titleAlign:"left",action:l.alert.action&&pt.createElement(vx,{size:"xsmall",id:"widget-no-result-alert-btn",type:l.alert.type,prefix:pt.createElement(Uf,null,pt.createElement(bx,{size:8})),onClick:l.alert.action.onClick},l.alert.action.title),variant:"alarm"})))}i(gr,"NoResult");import{i18n as hr}from"@lingui/core";import{Button as Lx,Divider as Px,MessageBox as _x,Typography as Dx,WarningIcon as $x}from"@rango-dev/ui";import Yt from"react";import{InfoIcon as Nx,Tooltip as Bx,Typography as Wx}from"@rango-dev/ui";import In from"react";import{Button as Ex,darkTheme as Ix,styled as Qo,Typography as Ax}from"@rango-dev/ui";var Hf=Qo("div",{width:"100%"}),zl=Qo("div",{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"$5",width:"100%"}),Qf=Qo("div",{display:"flex",padding:"$5 0",justifyContent:"space-between",alignItems:"center",width:"100%","._title":{$$color:"$colors$neutral600",[`.${Ix} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),qf=Qo("div",{display:"flex",justifyContent:"center",alignItems:"center",gap:"$2"}),Gf=Qo(Ax,{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"250px"}),Vf=Qo("div",{padding:"$2",alignSelf:"flex-start",cursor:"pointer"}),Kf=Qo(Ex,{"& ._text":{gap:"$5",display:"flex",alignItems:"center",justifyContent:"center"}});var Mx=35;function jf(t){let{title:e,value:o,valueColor:n}=t,r=B();return In.createElement(Qf,null,In.createElement(Wx,{size:"medium",variant:"label",className:"_title"},e),In.createElement(qf,null,In.createElement(Gf,{size:"large",variant:"label",color:n||"foreground"},`${n?"%":"$"}${o}`),o.length>Mx&&In.createElement(Bx,{content:o,container:r},In.createElement(Nx,{size:12,color:"gray"}))))}i(jf,"QuoteErrorsModalItem");function Xf(t){let{open:e,onClose:o,onConfirm:n,warning:r,confirmationDisabled:a}=t,s=r.warningLevel==="high"?"error":"warning",c=[{title:hr.t("Swapping"),value:P(r.inputUsdValue)},{title:hr.t("Gas cost"),value:P(r.totalFee,2,2)},{title:hr.t("Receiving"),value:P(r.outputUsdValue)},{title:hr.t("Price impact"),value:P(r.priceImpact,2,2),valueColor:`${s}500`}];return Yt.createElement(ee,{id:"widget-high-value-loss-warning-modal",footer:Yt.createElement(Lx,{id:"widget-high-value-loss-warning-modal-confirm-btn",type:"primary",size:"large",prefix:Yt.createElement($x,null),fullWidth:!0,disabled:a,onClick:n},ne().highValueLossError.confirmMessage),open:e,onClose:o,container:B()},Yt.createElement(_x,{type:s,title:ne().highValueLossError.impactTitle,description:ne().highValueLossError.description}),Yt.createElement(zl,null,Yt.createElement(Px,{size:"4"}),Yt.createElement(Dx,{size:"small",variant:"title"},hr.t("Details")),Yt.createElement(zl,null,c.map((l,p)=>Yt.createElement(jf,{key:p,...l})))))}i(Xf,"HighValueLossWarningModal");import{i18n as An}from"@lingui/core";function Yf(t,e){let o={alertType:"warning",title:"",action:null,actionButtonTitle:null};if(e)return o.alertType="error",e.type===3&&(o.title=e.recommendation),e.type===4&&(o.title=An.t({id:"You need to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:e.minRequiredSlippage}}),o.action="change-slippage",o.actionButtonTitle=An.t("Increase")),o;if(t){switch(t.type){case 0:{Xt(t.priceImpact)==="high"&&(o.alertType="error"),o.action="show-info",o.title=ne().highValueLossError.title;break}case 4:{o.title=An.t({id:"Output amount changed by {percentageChange}% (${usdValueChange}).",values:{percentageChange:t.percentageChange,usdValueChange:t.usdValueChange}});break}case 1:{o.title=ne().unknownPriceError.title;break}case 2:{o.title=An.t({id:"We recommend you to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:t.minRequiredSlippage}}),o.action="change-slippage",o.actionButtonTitle=An.t("Increase");break}case 3:{o.title=An.t("Caution, your slippage is high."),o.action="change-settings";break}default:break}return o}return null}i(Yf,"makeAlerts");function Zf(t,e){return e?.type===4?Number(e.minRequiredSlippage):t?.type===2?Number(t.minRequiredSlippage):null}i(Zf,"getRequiredSlippage");import{i18n as Nn}from"@lingui/core";import{Button as Fx,Divider as Hl,MessageBox as Ox,WarningIcon as Ux}from"@rango-dev/ui";import Co from"react";import{useNavigate as zx}from"react-router-dom";function Jf(t){let{open:e,onClose:o,onConfirm:n,warning:r,confirmationDisabled:a}=t,s=zx();return Co.createElement(ee,{id:"widget-slippage-warning-modal",anchor:"bottom",open:e,container:B(),onClose:o},Co.createElement(Ox,{type:"warning",title:r.type===3?Nn.t("High slippage"):Nn.t("Low slippage"),description:r.type===3?Nn.t("Caution, your slippage is high. Your trade may be front run."):Nn.t({id:"We recommend you to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:r.minRequiredSlippage}})},Co.createElement(Hl,{size:18}),Co.createElement(Hl,{size:32}),Co.createElement(Kf,{id:"widget-slippage-warning-modal-confirm-anyway-btn",size:"large",type:"primary",variant:"contained",fullWidth:!0,disabled:a,onClick:n},Co.createElement(Ux,{color:"white",size:16}),Nn.t("Swap anyway")),Co.createElement(Hl,{size:10}),Co.createElement(Fx,{id:"widget-slippage-warning-modal-change-slippage-btn",size:"large",type:"primary",variant:"outlined",fullWidth:!0,disabled:a,onClick:()=>s("../"+$.settings)},Nn.t("Change Slippage"))))}i(Jf,"SlippageWarningModal");import{Button as Hx,MessageBox as Qx,WarningIcon as qx}from"@rango-dev/ui";import Zi from"react";function Rf(t){let{open:e,onClose:o,onConfirm:n,confirmationDisabled:r}=t;return Zi.createElement(ee,{id:"widget-unknown-price-warning-modal",footer:Zi.createElement(Hx,{id:"widget-unknown-price-warning-modal-confirm-btn",type:"primary",size:"large",prefix:Zi.createElement(qx,null),fullWidth:!0,disabled:r,onClick:n},ne().unknownPriceError.confirmMessage),open:e,onClose:o,container:B()},Zi.createElement(Qx,{type:"warning",title:ne().unknownPriceError.impactTitle,description:ne().unknownPriceError.description}))}i(Rf,"UnknownPriceWarningModal");function yr(t){let{warning:e,error:o,couldChangeSettings:n,showWarningModal:r,confirmationDisabled:a,skipAlerts:s,refetchQuote:c,onOpenWarningModal:l,onCloseWarningModal:p,onConfirmWarningModal:u,onChangeSettings:m,onChangeSlippage:f}=t,h={confirmationDisabled:a,open:r,onClose:p,onConfirm:u},g=o?.type===0||o?.type===1,d=Yf(e,o?.type===3||o?.type===4?o:null);d&&!n&&(d.action=null);let S=!!d&&!s,y=i(C=>{if(C==="change-slippage"){let k=o?.type===3||o?.type===4?o:null,w=Zf(e,k);f?.(w)}else C==="change-settings"&&m()},"onclickActionButton");return Oe.createElement(Oe.Fragment,null,g&&Oe.createElement(Oe.Fragment,null,Oe.createElement(eg,{size:10}),Oe.createElement(gr,{skipAlerts:s,error:o,fetch:c})),S&&Oe.createElement(Hf,null,Oe.createElement(eg,{size:10}),Oe.createElement(Vx,{id:"widget-quote-warning-and-errors-alert",title:d.title,type:d.alertType,variant:"alarm",...d.action==="show-info"&&{action:Oe.createElement(Vf,{onClick:l},Oe.createElement(jx,{size:12,color:"gray"}))},...(d.action==="change-settings"||d.action==="change-slippage")&&{action:Oe.createElement(Kx,{id:"widget-quote-warning-error-change-settings-btn",size:"xxsmall",type:d.alertType,onClick:()=>y(d.action)},d.actionButtonTitle||Gx.t("Change"))}})),e&&Oe.createElement(Oe.Fragment,null,e.type===0&&Oe.createElement(Xf,{...h,warning:e}),(e.type===3||e.type===2)&&Oe.createElement(Jf,{...h,warning:e}),e.type===1&&Oe.createElement(Rf,{...h,warning:e})))}i(yr,"QuoteWarningsAndErrors");import wb from"bignumber.js";import ma from"react";import{i18n as qo}from"@lingui/core";import{Alert as ub,Divider as Wn,FullExpandedQuote as db,InfoIcon as Rl,NumericTooltip as ec,QuoteTag as mb,StepDetails as fb,TokenAmount as gb,Typography as Mn,useIsTruncated as tc}from"@rango-dev/ui";import oc from"bignumber.js";import O,{useRef as pa,useState as hb}from"react";import{styled as Ql}from"@rango-dev/ui";var ql=Ql("div",{width:"100%","& .position-top__skeleton":{paddingTop:"$10"}}),tg=Ql("div",{paddingBottom:"$15","& .from-amount-text":{wordBreak:"break-word"},variants:{dense:{true:{paddingBottom:0}}}}),og=Ql("div",{width:"100%",display:"flex"});import*as Ji from"@radix-ui/react-collapsible";import{Button as Xx,css as Ri,darkTheme as De,Image as ng,styled as Ve,Typography as Gl}from"@rango-dev/ui";var Yx=300,rg=Ve(Ji.Root,{display:"flex",flexDirection:"column",alignItems:"start",overflowX:"auto",overflowY:"hidden",width:"100%",borderRadius:"$xm",variants:{selected:{true:{},false:{$$color:"$colors$neutral400",[`.${De} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"}},listItem:{true:{$$color:"$colors$neutral400",[`.${De} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"},false:{}}},compoundVariants:[{listItem:!1,selected:!0,css:{$$color:"$colors$secondary200",[`.${De} &`]:{$$color:"$colors$secondary800"},backgroundColor:"$$color"}}]}),ig=Ri({padding:"$10 $15"}),ag=Ve(Xx,{backgroundColor:"transparent",border:"1px solid $secondary550",[`.${De} &`]:{border:"1px solid $secondary"},transition:"background-color 0.3s ease","&:hover":{backgroundColor:"$secondary550",[`.${De} &`]:{backgroundColor:"$secondary"},".allRoutesLabel":{$$color:"$colors$background",[`.${De} &`]:{$$color:"$colors$foreground"},color:"$$color",transition:"color 0.3s ease"}}}),sg=Ve("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",[`.${De} &`]:{$$color:"$colors$neutral500"},backgroundColor:"$$color"}},basic:{true:{borderTopRightRadius:"0",borderTopLeftRadius:"0"}},listItem:{true:{$$color:"$colors$neutral200",[`.${De} &`]:{$$color:"$colors$neutral500"},backgroundColor:"$$color","&:hover":{"& .quote_container":{"& button":{backgroundColor:"$neutral500",[`.${De} &`]:{backgroundColor:"$neutral200"}},backgroundColor:"$neutral500",[`.${De} &`]:{backgroundColor:"$neutral200"}},backgroundColor:"$neutral300",[`.${De} &`]:{backgroundColor:"$neutral400"}},cursor:"pointer"},false:{}}},compoundVariants:[{listItem:!0,selected:!0,css:{outline:"1px solid $secondary"}},{listItem:!1,selected:!0,css:{$$color:"$colors$secondary100",[`.${De} &`]:{$$color:"$colors$secondary550"},backgroundColor:"$$color","&:hover":{backgroundColor:"$$color"}}},{listItem:!0,selected:!1,css:{cursor:"pointer","&:hover":{backgroundColor:"$neutral300",[`.${De} &`]:{backgroundColor:"$neutral400"}}}}]}),lg=Ri({width:"100%",padding:"$15 $15 $10 $15"}),cg=Ri({display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingBottom:"$10",position:"relative"}),Bn=Ri({display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",".blockchainImage":{marginLeft:"-$8"}}),pg=Ve(Ji.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:{[`& ${ng}`]:{border:"1px $warning500 solid",borderRadius:"100%"}},false:{[`& ${ng}`]:{border:"1px transparent solid",borderRadius:"100%"}}},selected:{true:{},false:{$$color:"$colors$neutral400",[`.${De} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"}},listItem:{true:{$$color:"$colors$neutral400",[`.${De} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"},false:{}}},compoundVariants:[{listItem:!1,selected:!0,css:{$$color:"$colors$secondary200",[`.${De} &`]:{$$color:"$colors$secondary800"},backgroundColor:"$$color"}}],".blockchains_section":{display:"none"},"@xs":{".blockchains_section":{display:"block"}}}),ug=Ve("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"}}}}),dg=Ve(Gi,{width:"100%",background:"inherit"}),Vl=Ve("div",{display:"flex",justifyContent:"center",alignItems:"center",padding:"$2",transition:`all ${Yx}ms ease`,variants:{orientation:{down:{transform:"rotate(0)"},up:{transform:"rotate(180deg)"}}}}),wQ=Ve("div",{height:"$12",marginLeft:"$10",marginRight:"$10",borderLeft:"1px solid $foreground"}),mg=Ve("div",{display:"flex",justifyContent:"center",margin:"0 $15",borderTop:"1px solid",$$color:"$colors$neutral300",[`.${De} &`]:{$$color:"$colors$neutral400"},borderColor:"$$color"}),fg=Ve("div",{display:"flex",flexDirection:"row",alignItems:"center",gap:"$2",flex:"1 1 auto",minWidth:0}),Kl=Ve(Gl,{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"$30"}),jl=Ve(Gl,{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0,flex:"0 1 auto"}),Xl=Ve("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"}}}}),gg=Ve("div",{display:"flex"}),ea=Ve("div",{width:"100%",borderTopWidth:"1px",borderTopStyle:"solid",borderTopColor:"$neutral",margin:"$5 0",[`.${De} &`]:{borderTopColor:"$neutral800"}}),hg=Ve(Gl,{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:"0 1 auto",minWidth:0,flexShrink:3});import{i18n as $t}from"@lingui/core";import{ChevronDownIcon as Jx,CloseIcon as Rx,Divider as na,IconButton as eb,NumericTooltip as tb,QuoteCost as ob,Typography as Et}from"@rango-dev/ui";import R,{useState as Tg}from"react";import{css as Zx,styled as ta}from"@rango-dev/ui";var oa=ta("div",{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"$5 0","&.total_payable_fee":{padding:"$12 0"}}),Yl=ta("div",{width:"100%",borderTop:"1px solid $neutral300",margin:"$10 0"}),yg=ta("div",{padding:"$20 0",display:"flex",flexDirection:"column","& .collapsible_trigger":{display:"flex",alignItems:"center"}}),Sg=ta("div",{padding:"$20 $20 $10",position:"relative","._icon-button":{position:"absolute",zIndex:10,top:"$16",right:"$16"}}),Cg=Zx({display:"flex",flexDirection:"row",alignItems:"center",padding:"$5","&:hover":{"& ._typography, & svg":{color:"$secondary"}}});var nb=i(t=>t.fee.isZero()?null:R.createElement(oa,null,R.createElement(Et,{variant:"label",size:"medium",color:"neutral600"},t.label),R.createElement(Et,{variant:"label",size:"medium"},"$",P(t.fee,4,4))),"NonPayableFee");function Zl(t){let[e,o]=Tg(!1),[n,r]=Tg(!1),{steps:a,quote:s,fee:c,time:l,feeWarning:p,timeWarning:u,showModalFee:m,fullExpandedMode:f=!1}=t,h=s?.swaps??[],g=f?Wo():B(),d=Qd(h),S=P(c,2,2);return R.createElement(R.Fragment,null,R.createElement(ob,{onClickFee:m?y=>{y.stopPropagation(),o(!e)}:void 0,fee:S,feeWarning:p,timeWarning:u,time:l,steps:a,tooltipGas:m?$t.t("View more info"):void 0,tooltipContainer:g}),R.createElement(ee,{id:"widget-quote-cost-explanation-modal",container:g,open:e,anchor:f?"center":"bottom",styles:{container:{maxWidth:f?"484px":"unset"}},header:R.createElement(Sg,{style:{textAlign:f?"left":"center"}},R.createElement(Et,{variant:"title",size:"medium"},$t.t("Gas & Fee Explanation")),R.createElement(eb,{id:"widget-quote-cost-details-modal-close-icon-btn",onClick:()=>o(!1),variant:"ghost"},R.createElement(Rx,{color:"gray",size:14}))),onClose:()=>{o(!1)}},R.createElement(yg,null,R.createElement(Et,{variant:"title",size:"small"},$t.t("Details")),R.createElement(na,{size:10}),Object.entries(d.payable).flatMap(([y,C])=>C.map((k,w)=>{let x=`payable-fee-${w}`,I=Ks(k);return R.createElement(oa,{key:x},R.createElement(Et,{variant:"label",size:"medium",color:"neutral600"},Hs(y,$t.t)),R.createElement(tb,{content:k.amount,container:g},R.createElement(Et,{variant:"label",size:"medium"},P(k.amount,2,2),k.asset.symbol," ($",P(I,4,4),")")))})),R.createElement(oa,{className:"total_payable_fee"},R.createElement(Et,{variant:"label",size:"medium"},$t.t("Total Payable Fee")),R.createElement(Et,{variant:"label",size:"medium"},"$",P(c,4,4))),R.createElement(Yl,null),!!Object.keys(d.nonePayable).length&&R.createElement(ji,{triggerAnchor:"bottom",onClickTrigger:()=>r(y=>!y),trigger:R.createElement("div",{className:Cg()},R.createElement(Et,{size:"small",variant:"body",color:"neutral700"},n?$t.t("Hide non-payable fees"):$t.t("Show non-payable fees")),R.createElement(na,{size:4,direction:"horizontal"}),R.createElement(Vi,{orientation:n?"up":"down"},R.createElement(Jx,{size:12,color:"gray"}))),open:n},R.createElement(Et,{size:"small",variant:"title"},$t.t("Description")),R.createElement(na,{size:4}),R.createElement(Et,{size:"small",variant:"body",color:"neutral700"},$t.t(`The following fees are considered in the transaction output and
|
|
2
|
+
you won\u2019t need to pay extra gas for them.`)),R.createElement(na,{size:10}),Object.entries(d.nonePayable).map(([y,C],k)=>{let w=Hd(C),x=Hs(y,$t.t),I=`non-payable-fee-${k}`;return R.createElement(nb,{key:I,fee:w,label:x})}),R.createElement(Yl,null)))))}i(Zl,"QuoteCostDetails");import{i18n as vg}from"@lingui/core";import{TokenAmount as xg}from"@rango-dev/ui";import ra from"react";import{css as rb,styled as ib}from"@rango-dev/ui";var kg=ib("div",{position:"relative",display:"flex",flexDirection:"column",width:"100%"}),wg=rb({height:"14px",marginLeft:"14px",position:"absolute",borderLeft:"1px solid $foreground",top:"42%"});function Sr(t){let{from:e,to:o,percentageChange:n,warningLevel:r}=t;return ra.createElement(kg,null,ra.createElement(xg,{direction:"horizontal",label:vg.t("Swap input"),id:"widget-quote-summary-swap-input",type:"input",tooltipContainer:B(),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}}),ra.createElement("div",{className:wg()}),ra.createElement(xg,{id:"widget-quote-summary-estimated-input",direction:"horizontal",tooltipContainer:B(),label:vg.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(Sr,"QuoteSummary");import{i18n as Ng}from"@lingui/core";import{ChevronDownIcon as lb,ChevronRightIcon as cb,Divider as Jl,Image as pb,Tooltip as ca,Typography as aa}from"@rango-dev/ui";import q from"react";import{useLayoutEffect as ab,useState as Cr}from"react";var bg=480,Eg=768,Ig=1024,Ag=1200,sb=i(()=>{let[t,e]=Cr(!1),[o,n]=Cr(!1),[r,a]=Cr(!1),[s,c]=Cr(!1),[l,p]=Cr(!1),u=i(()=>{e(window.innerWidth<=bg),n(window.innerWidth>bg&&window.innerWidth<=Eg),a(window.innerWidth>Eg&&window.innerWidth<=Ig),c(window.innerWidth>Ig&&window.innerWidth<=Ag),p(window.innerWidth>Ag)},"handleResize");return ab(()=>(u(),window.addEventListener("resize",u),()=>window.removeEventListener("resize",u)),[]),{isMobile:t,isTablet:o,isNotebook:r,isLargeScreen:s,isExtraLargeScreen:l}},"useScreenDetect"),ia=sb;var sa=4,la=6,Tr=i(t=>{let{content:e,src:o,className:n,open:r,state:a,container:s}=t,c=s||B();return q.createElement(ca,{container:c,side:"bottom",sideOffset:4,open:r,content:e},q.createElement(ug,{className:n,state:a},q.createElement(pb,{src:o,size:16})))},"ImageComponent");function Bg(t){let{quoteRef:e,selected:o,setExpanded:n,steps:r,expanded:a,type:s,container:c}=t,l=c||B(),p=r.length,u=Md(r),{isTablet:m,isMobile:f}=ia();return q.createElement(pg,{className:"widget-quote-trigger-btn",listItem:s==="list-item",ref:h=>e.current=h,selected:o,onClick:h=>{h.stopPropagation(),n(g=>!g)}},q.createElement("div",{className:Bn()},q.createElement(aa,{variant:"body",size:"xsmall"},Ng.t("Via:")),q.createElement(Jl,{direction:"horizontal",size:4}),r.map((h,g)=>{let d=`item-${g}`,S=q.createElement(Vl,null,q.createElement(cb,{size:12,color:"black"}));return f||m?q.createElement(q.Fragment,{key:d},q.createElement(Tr,{content:h.swapper.displayName,src:h.swapper.image??"",state:h.state,container:c}),g!==p-1&&q.createElement(q.Fragment,null,S)):q.createElement(q.Fragment,{key:d},p<=sa||p>sa&&g<sa-1?q.createElement(q.Fragment,null,q.createElement(Tr,{content:h.swapper.displayName,src:h.swapper.image??"",state:h.state,container:c}),g!==p-1&&q.createElement(q.Fragment,null,S)):g===sa-1&&q.createElement(ca,{container:l,side:"bottom",align:"end",sideOffset:4,content:q.createElement("div",{className:Bn()},S,r.map((y,C)=>{let k=`image-${C}`;return C>=g&&q.createElement(q.Fragment,{key:k},q.createElement(Tr,{content:y.swapper.displayName,src:y.swapper.image??"",state:y.state,open:!1}),C!==p-1&&q.createElement(q.Fragment,null,S))}))},q.createElement(Xl,{state:r.find((y,C)=>C>=g&&(y.state==="error"||y.state==="warning"))?.state},q.createElement(aa,{size:"xsmall",variant:"body"},"+",p-g))))})),q.createElement("div",{className:Bn()},q.createElement("div",{className:"blockchains_section"},q.createElement("div",{className:Bn()},q.createElement(aa,{variant:"body",size:"xsmall"},Ng.t("Chains:")),q.createElement(Jl,{direction:"horizontal",size:4}),u.map((h,g)=>q.createElement(q.Fragment,{key:h.displayName},u.length<=la||u.length>la&&g<la-1?q.createElement(ca,{container:l,side:"bottom",content:h.displayName,sideOffset:4},q.createElement(Tr,{content:"",src:h.image??"",open:!1,className:g!==0?"blockchainImage":""})):g===la-1&&q.createElement(ca,{container:l,side:"bottom",align:"end",sideOffset:4,content:q.createElement("div",{className:Bn()},u.map((d,S)=>S>=g&&q.createElement(Tr,{key:d.displayName,content:"",src:d.image??"",open:!1,className:S>g?"blockchainImage":"",container:c})))},q.createElement(Xl,{className:"blockchainImage"},q.createElement(aa,{size:"xsmall",variant:"body"},"+",u.length-g))))),q.createElement(Jl,{direction:"horizontal",size:32}))),q.createElement(Vl,{orientation:a?"up":"down"},q.createElement(lb,{size:12,color:"black"}))))}i(Bg,"QuoteTrigger");function nc(t){let{quote:e,input:o,output:n,error:r,warning:a,type:s,selected:c=!1,tagHidden:l=!0,showModalFee:p=!0,onClickAllRoutes:u,fullExpandedMode:m=!1,container:f}=t,h=T().blockchains(),{findToken:g}=T(),d=T().swappers(),{customSlippage:S,slippage:y}=T(),C=S||y,[k,w]=hb(t.expanded),x=pa(null),I=P(n.value,6,6),A=n.usdValue?P(n.usdValue,4,4):"",b=jt(o.usdValue,n.usdValue??null),E=P(b,2,2),v=Xt(b??0),N=i((Q,j)=>Q.map((K,Ie)=>{let Ae,Ke=r?.type===3&&r.swap.swapperId===K.swapperId,Mt=r?.type===4&&!!r.recommendedSlippages?.[Ie],so=a?.type===2&&!!a.recommendedSlippages?.[Ie],Io=Ke||Mt,Un=so;Io?Ae="error":Un&&(Ae="warning");let Yr=Io?qo.t("Slippage Error"):qo.t("Slippage Warning");return Ke&&(Yr=qo.t("Bridge Limit Error")),{swapper:{displayName:Hn(K.swapperId,d)??"",image:K.swapperLogo},from:{token:{displayName:K.from.symbol,image:K.from.logo},chain:{displayName:ht(K.from.blockchain,h)??"",image:K.from.blockchainLogo},price:{value:Ie===0&&!j?P(o.value,6,6):P(K.fromAmount,6,6),usdValue:P((K.from.usdPrice??0)*parseFloat(K.fromAmount),4,4),realValue:Ie===0?o.value:K.fromAmount,realUsdValue:new oc(K.from.usdPrice??0).multipliedBy(K.fromAmount).toString()}},to:{token:{displayName:K.to.symbol,image:K.to.logo},chain:{displayName:ht(K.to.blockchain,h)||"",image:K.to.blockchainLogo},price:{value:P(K.toAmount,6,6),usdValue:P((K.to.usdPrice??0)*parseFloat(K.toAmount),4,4),realValue:K.toAmount,realUsdValue:new oc(K.to.usdPrice??0).multipliedBy(K.toAmount).toString()}},state:Ae,alerts:Io||Un?O.createElement(tg,{dense:m},O.createElement(ub,{variant:"alarm",type:Io?"error":"warning",title:Yr,id:"widget-quote-footer-step-alarm-alert",footer:O.createElement(og,null,Ke&&O.createElement("div",null,O.createElement(Mn,{size:"xsmall",variant:"body",color:"neutral900"},r.fromAmountRangeError),O.createElement(Wn,{direction:"vertical",size:2}),O.createElement(Mn,{size:"xsmall",variant:"body",className:"from-amount-text",color:"neutral900"},qo.t({id:"Yours: {amount} {symbol}",values:{amount:P(K.fromAmount,6,6),symbol:K?.from.symbol}}))),(Mt||so)&&!Ke&&O.createElement("div",null,O.createElement(Mn,{size:"xsmall",variant:"body",color:"neutral900"},qo.t({id:"Minimum suggested slippage: {minRequiredSlippage}",values:{...r?.type===4&&{minRequiredSlippage:r.recommendedSlippages?.[Ie]},...a?.type===2&&{minRequiredSlippage:a.recommendedSlippages?.[Ie]}}})),O.createElement(Wn,{direction:"vertical",size:2}),O.createElement(Mn,{size:"xsmall",variant:"body",color:"neutral900"},qo.t({id:"Yours: {userSlippage}",values:{userSlippage:C}}))))})):void 0,time:qn(K.estimatedTimeInSeconds),fee:P(Vs(K,g),2,2),internalSwaps:K.internalSwaps?N(K.internalSwaps):void 0}}),"getQuoteSteps"),M=N(e?.swaps??[]),F=M.length,H=f||B(),X=Pd(t.quote.tags||[]),J=!!u,W=ai(e?.swaps),Z=qn(W),Y=Ni(e?.swaps??[],g),ce=P(Y,2,2),fe=Y.gte(new oc(xd)),at=W/Ed>=bd,ue=pa(null),wt=tc(o.value,ue),gt=pa(null),Wt=tc(n.value,gt),D=pa(null),U=tc(A,D),G=M[F-1],se=M[0];return!se||!G?null:m?O.createElement(db,{selected:c,fee:ce,time:Z,tooltipContainer:Wo(),steps:M,tags:X,id:"widget-quote-full-expanded-quote-container",quoteCost:O.createElement(Zl,{quote:e,fullExpandedMode:!0,time:Z,fee:Y,feeWarning:fe,timeWarning:at,showModalFee:p,steps:F}),percentageChange:E,warningLevel:v,outputPrice:{value:I,usdValue:A,realValue:n.value,realUsdValue:n.usdValue}}):O.createElement(sg,{id:"widget-quote-summary-container",selected:c,listItem:s==="list-item",basic:s==="basic"},O.createElement("div",{className:lg()},!l&&X.length?O.createElement(O.Fragment,null,O.createElement(gg,null,X.map((Q,j)=>{let K=`${Q.value}_${j}`;return O.createElement(O.Fragment,{key:K},O.createElement(mb,{label:Q.label,value:Q.value}),O.createElement(Wn,{size:4,direction:"horizontal"}))})),O.createElement(ea,null),!J&&O.createElement(Wn,{size:4})):null,O.createElement("div",{id:"portal-root",className:cg()},O.createElement(Zl,{quote:e,time:Z,fee:Y,feeWarning:fe,timeWarning:at,showModalFee:p,steps:F}),J&&O.createElement(ag,{onClick:Q=>{Q.stopPropagation(),u()},id:"widget-quote-all-routes-btn",size:"xxsmall",type:"secondary",variant:"default",css:{paddingLeft:"$10",paddingRight:"$10",paddingTop:"$5",paddingBottom:"$5"}},O.createElement(Mn,{color:"secondary",variant:"body",size:"xsmall",className:"allRoutesLabel"},qo.t("See All Routes")))),s==="basic"&&O.createElement(fg,null,O.createElement(jl,{ref:ue,size:"small",variant:"body"},o.value),wt&&O.createElement(ec,{content:o.value,container:H,open:o.value?void 0:!1},O.createElement(Rl,{size:12,color:"gray"})),O.createElement(Kl,{size:"small",variant:"body"},M[0]?.from.token.displayName),O.createElement(Mn,{size:"small",variant:"body"},"="),O.createElement(jl,{ref:gt,size:"small",variant:"body"},n.value),Wt&&O.createElement(ec,{content:n.value,container:H,open:n.value?void 0:!1},O.createElement(Rl,{size:12,color:"gray"})),O.createElement(Kl,{size:"small",variant:"body"},G?.to.token.displayName),O.createElement(Wn,{size:2,direction:"horizontal"}),O.createElement(hg,{ref:D,color:"$neutral600",size:"xsmall",variant:"body"},`($${A})`),U&&O.createElement(ec,{content:n.usdValue,container:H},O.createElement(Rl,{size:12,color:"gray"}))),s==="list-item"&&O.createElement(gb,{id:"widget-quote-token-amount-container",tooltipContainer:H,type:"output",direction:"vertical",price:{value:I,usdValue:A,realValue:n.value,realUsdValue:n.usdValue},token:{displayName:G.to.token.displayName,image:G.to.token.image},chain:{image:G.to.chain.image},percentageChange:E,warningLevel:v}),s==="swap-preview"&&O.createElement(O.Fragment,null,O.createElement(Sr,{from:se.from,to:G.to,percentageChange:E,warningLevel:v}),O.createElement(Wn,{size:4}))),O.createElement(rg,{selected:c,listItem:s==="list-item",open:k,className:"quote_container",onOpenChange:w},O.createElement(Bg,{type:s,quoteRef:x,selected:c,setExpanded:w,container:H,expanded:k,steps:M}),O.createElement(dg,{open:k},O.createElement(mg,null),O.createElement("div",{className:ig()},M.map((Q,j)=>{let K=`item-${j}`;return O.createElement(fb,{type:"quote-details",className:"widget-quote-step-details-container",key:K,tooltipContainer:H,step:Q,hasSeparator:j!==M.length-1,state:Q.state})})))))}i(nc,"Quote");import{Divider as Tb,Skeleton as kb}from"@rango-dev/ui";import eo from"react";import{darkTheme as yb,styled as ua}from"@rango-dev/ui";var Wg=ua("div",{$$color:"$colors$neutral100",[`.${yb} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",borderBottomLeftRadius:"$xm",borderBottomRightRadius:"$xm",padding:"$15",variants:{rounded:{true:{borderRadius:"$xm"}},expanded:{true:{paddingBottom:"3px"},false:{paddingBottom:"$12"}}}}),Mg=ua("div",{paddingTop:"$2"}),Lg=ua("div",{paddingLeft:"$8"}),Pg=ua("div",{borderLeft:"1px dashed $foreground",minHeight:" 0",margin:"0px 11.5px",alignSelf:"stretch",variants:{hideSeparator:{true:{minHeight:"unset",height:"0"}}}});import{ChainToken as qg,Divider as It,Skeleton as ut}from"@rango-dev/ui";import V from"react";import{css as Sb,styled as Rt}from"@rango-dev/ui";var rc=Rt("div",{display:"flex"}),_g=Rt("div",{padding:"$10 $0 $20"}),Dg=Rt("div",{padding:"14px $0 $20 $0",display:"flex",flexDirection:"column"}),$g=Rt("div",{display:"flex",justifyContent:"start",alignItems:"center"}),Fg=Rt("div",{display:"flex",justifyContent:"space-between",alignItems:"end"}),Og=Rt("div",{height:"$24",marginLeft:"13px",borderLeft:"1px solid $neutral700"}),Ug=Rt("div",{width:"65%",display:"flex",justifyContent:"start"}),zg=Rt("div",{display:"flex",flexDirection:"column",alignItems:"start",flexGrow:1,maxWidth:"148px"}),Hg=Rt("div",{padding:"$15 $0 $15 $0"}),Qg=Sb({display:"flex",justifyContent:"space-between",alignItems:"center"});function kr(t){let{type:e,tagHidden:o=!0}=t,n=V.createElement(Fg,null,V.createElement(Ug,null,V.createElement(qg,{loading:!0,size:"medium"}),V.createElement(It,{size:8,direction:"horizontal"}),V.createElement(zg,null,V.createElement(ut,{height:10,width:60,variant:"rounded"}),V.createElement(It,{size:4}),V.createElement(ut,{height:15,variant:"rounded"}))),V.createElement(ut,{height:12,width:64,variant:"rounded"})),r=e==="basic"&&!o;return V.createElement("div",null,!o&&V.createElement(V.Fragment,null,V.createElement(rc,null,V.createElement(ut,{width:65,height:20,variant:"rounded"}),V.createElement(It,{size:4,direction:"horizontal"}),V.createElement(ut,{width:65,height:20,variant:"rounded"}),V.createElement(It,{size:4,direction:"horizontal"}),V.createElement(ut,{width:65,height:20,variant:"rounded"})),V.createElement(ea,null),!r&&V.createElement(It,{size:4})),V.createElement("div",{className:Qg()},V.createElement(rc,null,V.createElement(ut,{width:60,height:10,variant:"rounded"}),V.createElement(It,{size:4,direction:"horizontal"}),V.createElement(ut,{width:60,height:10,variant:"rounded"}),V.createElement(It,{size:4,direction:"horizontal"}),V.createElement(ut,{width:60,height:10,variant:"rounded"})),r&&V.createElement(ut,{width:85,height:24,variant:"rounded"})),e==="basic"&&V.createElement(_g,null,V.createElement(ut,{height:15,width:148,variant:"rounded"})),e==="list-item"&&V.createElement(Dg,null,V.createElement($g,null,V.createElement(qg,{loading:!0,size:"medium"}),V.createElement(It,{direction:"horizontal",size:4}),V.createElement(ut,{height:15,width:150,variant:"rounded"})),V.createElement(It,{size:10}),V.createElement(ut,{height:10,width:184,variant:"rounded"})),e==="swap-preview"&&V.createElement(V.Fragment,null,V.createElement(It,{size:4}),V.createElement(Hg,null,n,V.createElement(Og,null),n),V.createElement(It,{size:12})))}i(kr,"QuoteSummarySkeleton");import{ChainToken as Xg,Divider as ac,NextIcon as Cb,Skeleton as da}from"@rango-dev/ui";import Me from"react";import{styled as wr}from"@rango-dev/ui";var Gg=wr("div",{display:"flex",alignItems:"start"}),Vg=wr("div",{flexGrow:1,paddingTop:"$5",paddingBottom:"$10",display:"flex",alignItems:"center",variants:{extraSpace:{true:{paddingBottom:"$40"}}}}),ic=wr("div",{display:"flex",alignItems:"center",flexGrow:1}),Kg=wr("div",{margin:"$0 $2",padding:"$4",display:"flex",justifyContent:"center",alignItems:"center"}),jg=wr("div",{display:"flex",alignItems:"center"});function Ft(t){let{separator:e=!0}=t;return Me.createElement(Me.Fragment,null,Me.createElement(jg,null,Me.createElement(da,{height:22,width:22,variant:"circular"}),Me.createElement(ac,{direction:"horizontal",size:8}),Me.createElement(da,{height:15,width:148,variant:"rounded"})),Me.createElement(Gg,null,Me.createElement(Pg,{hideSeparator:!e}),Me.createElement(Vg,{extraSpace:e},Me.createElement(ic,null,Me.createElement(Xg,{size:"small",loading:!0}),Me.createElement(ac,{direction:"horizontal",size:8}),Me.createElement(da,{height:12,variant:"rounded"})),Me.createElement(Kg,null,Me.createElement(Cb,{color:"gray",size:16})),Me.createElement(ic,null,Me.createElement(Xg,{size:"small",loading:!0}),Me.createElement(ac,{direction:"horizontal",size:8}),Me.createElement(da,{height:12,variant:"rounded"})))))}i(Ft,"StepSkeleton");function vr(t){let{type:e,expanded:o,tagHidden:n=!1}=t;return eo.createElement(Wg,{expanded:o,rounded:e!=="basic"},eo.createElement(kr,{type:e,tagHidden:n}),eo.createElement(Mg,null,eo.createElement(kb,{height:15,variant:"rounded"})),o&&eo.createElement(Lg,null,eo.createElement(Tb,{size:24}),eo.createElement(Ft,null),eo.createElement(Ft,null),eo.createElement(Ft,{separator:!1})))}i(vr,"QuoteSkeleton");function Go(t){let{quote:e,type:o,loading:n,error:r,warning:a,expanded:s=!1,tagHidden:c,onClick:l,showModalFee:p,selected:u,id:m,onClickAllRoutes:f,fullExpandedMode:h=!1,container:g}=t,{inputAmount:d,inputUsdValue:S}=z()(),y=e?.outputAmount?new wb(e?.outputAmount):null,C=e?St(e):null,w=!(r&&(r.type===0||r.type===1))&&e&&!n;return n?ma.createElement(ql,null,ma.createElement(vr,{tagHidden:c,type:o,expanded:s})):w?ma.createElement(ql,{onClick:()=>l?.(e),id:m},ma.createElement(nc,{quote:e,error:r,container:g,showModalFee:p,warning:a,tagHidden:c,selected:u,type:o,expanded:s,onClickAllRoutes:f,fullExpandedMode:h,input:{value:d,usdValue:S?.toString()??""},output:{value:y?.toString()??"",usdValue:C?.toString()??""}})):null}i(Go,"QuoteInfo");import{warn as Eb}from"@rango-dev/logging-core";import{calculatePendingSwap as Ib}from"@rango-dev/queue-manager-rango-preset";import{useEffect as Ab}from"react";import{useRef as vb,useState as xb}from"react";var bb=2e3;function fa({request:t}){let[e,o]=xb(!1),n=vb(null),r=i(()=>n.current?.abort(),"cancelFetch"),a=i(async c=>(await new Promise(l=>setTimeout(l,bb)),await s(c,!1)),"retryFetch"),s=i(async(c,l=!1)=>{r(),n.current=new AbortController,o(!0);try{let p=await t(c,{signal:n.current.signal});return n.current=null,p}catch(p){if(l)return await a(c);throw p}finally{o(!1)}},"fetch");return{fetch:s,loading:e,cancelFetch:r}}i(fa,"useFetch");function Yg(){let{fetch:t,loading:e,cancelFetch:o}=fa({request:async(n,r)=>await ct().confirmRoute(n,r)});return{fetch:t,loading:e,cancelFetch:o}}i(Yg,"useFetchConfirmQuote");function ga(t){if(!t.swaps)throw new Error(ne().noResultError.title,{cause:{type:0,diagnosisMessage:t.diagnosisMessages?.[0]}});let e=sc(t.swaps);if(e)throw new Error(e.message,{cause:e.options})}i(ga,"throwErrorIfResponseIsNotValid");function sc(t){if(Od(t)){let{swap:n,fromAmountRangeError:r,recommendation:a}=Ud(t);return n?{message:"bridge limit error",options:{type:3,swap:n,recommendation:a,fromAmountRangeError:r}}:null}let o=qd(t);if(o){let n=Bi(t);return{message:"",options:{type:4,recommendedSlippages:o,minRequiredSlippage:n}}}return null}i(sc,"getQuoteError");function Zg(t){let{currentQuote:e,previousQuote:o,meta:n,selectedWallets:r,userSlippage:a,findToken:s}=t,c={quote:null,balance:null},l=Sn({previousQuote:o,currentQuote:e,findToken:s,userSlippage:a});l&&(c.quote=l);let p=Kd(e,r,n.blockchains);return p.length===0||(c.balance={messages:p}),c}i(Zg,"generateWarnings");function ha(t){return t?.code==="ERR_CANCELED"?{type:2}:t.cause?t.cause:t?.code==="ERR_BAD_REQUEST"?{type:0,diagnosisMessage:t.response.data.error}:{type:1,diagnosisMessage:t.message}}i(ha,"handleQuoteErrors");function lc(){let{fromToken:t,toToken:e,inputAmount:o,inputUsdValue:n,setSelectedQuote:r,selectedQuote:a,customDestination:s,resetAlerts:c}=z()(),{slippage:l,customSlippage:p}=T(),u=T().getDisabledLiquiditySources(),m=T().blockchains(),f=T().tokens(),{findToken:h}=T(),{swapMode:g}=tt(),d=p||l,{fetch:S,cancelFetch:y,loading:C}=Yg();return Ab(()=>y,[]),{loading:C,fetch:i(async w=>{let x=w.selectedWallets,I=w?.customDestination??s;if(!t||!e||!o)return{quote:null,swap:null,error:null,warnings:null};let A=x.reduce((E,v)=>(E[v.chain]=v.address,E),{}),b={requestId:a?.requestId||"",selectedWallets:A,destination:I||void 0};try{return await S(b,!0).then(E=>{let{result:v}=E;if(!v)throw new Error(E.error??"Error fetching updated quote");ga({diagnosisMessages:v.diagnosisMessages,requestId:v.requestId,swaps:v.result?.swaps});let N={outputAmount:v.result?.outputAmount,requestId:v.requestId,resultType:v.result?.resultType,swaps:v.result?.swaps||[],validationStatus:v.validationStatus,requestAmount:v.requestAmount};r(N);let M={slippage:d.toString(),disabledSwappersGroups:u},F=Zg({previousQuote:a??void 0,currentQuote:N,meta:{blockchains:m},selectedWallets:x,userSlippage:d,inputUsdValue:n,findToken:h});c();let H=!!F.balance,X=Ib({inputAmount:o.toString(),bestRoute:v,wallets:Vd(x),settings:M,validateBalanceOrFee:!H,meta:{blockchains:m,tokens:f},swapMode:g});return{quote:N,swap:X,error:null,warnings:F}})}catch(E){let v=ha(E);return v.type!==2&&Eb(new Error("confirm swap error"),{tags:{...v,type:Ye[v.type],initialQuote:a,requestBody:b}}),{swap:null,error:v,warnings:null}}},"fetch"),cancelFetch:y}}i(lc,"useConfirmSwap");var Fb=Mb("div",{width:"100%",display:"flex",justifyContent:"space-between",[`& ${Jg}`]:{width:"$48",height:"$48"}}),Ob=uc({flexGrow:1,paddingRight:"$10"}),Ub=uc({width:"$24",height:"$24",display:"flex",justifyContent:"center",alignItems:"center"}),zb=uc({display:"flex",justifyContent:"space-between",alignItems:"center"});function Rg(){let{selectedQuote:t,setInputAmount:e,selectedWallets:o,quoteWalletsConfirmed:n,customDestination:r,quoteWarningsConfirmed:a}=z()(),s=$b(),[c,l]=xr(""),p=!n,[u,m]=xr(!1),[f,h]=xr(!1),{isActiveTab:g}=oe(),d=T().getDisabledLiquiditySources(),S=Db(d),{manager:y}=Nb(),{fetch:C,loading:k,cancelFetch:w}=lc(),[x,I]=xr({swap:null,error:null,warnings:null}),[A,b]=xr(!1),E=i(async({selectedWallets:W,customDestination:Z})=>{let Y=await C?.({selectedWallets:W,customDestination:Z});return I(Y),Y},"onConfirmSwap"),v=i(async()=>{if(x.swap&&n)try{await y?.create("swap",{swapDetails:x.swap},{id:x.swap.requestId});let W=`../${$.swaps}/${x.swap.requestId}`;s(W,{replace:!0}),setTimeout(()=>{e("")},0)}catch(W){l("Error: "+W?.message)}},"addNewSwap"),N=i(async()=>{h(!0),await v(),h(!1)},"onConfirm"),M=i(async()=>{x.warnings?.quote&&Wd(x.warnings.quote)&&!a?b(!0):await N()},"onStartConfirmSwap"),F=i(async()=>{I({error:null,swap:null,warnings:null}),C({selectedWallets:o,customDestination:r}).then(W=>{I(W)}).catch(W=>console.error(W))},"onRefresh");ya(()=>{!!S.current.length&&!d.length&&F(),S.current=d},[d.length]),ya(()=>{p&&w()},[p]),ya(()=>{p&&m(p)},[p]),ya(()=>{p||C({selectedWallets:o,customDestination:r}).then(W=>I(W)).catch(W=>console.error(W))},[]),_b(()=>{t?.requestId||s(`../${location.search}`)},[t?.requestId]);let H=x.warnings?.quote??null,X=x.error,J=[];if(c&&J.push($e.createElement(Bb,{id:"widget-confirm-swap-db-error-alert",type:"error",variant:"alarm",title:c})),H||X){let W=`../${$.settings}`;J.push($e.createElement(yr,{warning:H,error:X,couldChangeSettings:!1,refetchQuote:F,skipAlerts:X?.type===4||H?.type===2,showWarningModal:A,confirmationDisabled:!g,onOpenWarningModal:()=>b(!0),onCloseWarningModal:()=>b(!1),onConfirmWarningModal:async()=>{b(!1),await v()},onChangeSettings:()=>s(W)}))}return $e.createElement(ie,{header:{title:cc.t("Confirm Swap"),onWallet:()=>{let W=`../${$.wallets}`;s(W)}},footer:$e.createElement(Fb,null,$e.createElement("div",{className:Ob()},$e.createElement(Wb,{id:"widget-confirm-swap-start-btn",variant:"contained",type:"primary",size:"large",fullWidth:!0,loading:k||f,disabled:!!x.error||!g,onClick:M},cc.t("Start Swap"))),$e.createElement(Jg,{id:"widget-confirm-swap-wallet-icon-btn",variant:"contained",type:"primary",size:"large",loading:k||f,disabled:!g,onClick:m.bind(null,!0)},$e.createElement(Pb,{size:24})))},u&&$e.createElement(Pf,{open:u,onClose:()=>m(!1),onCancel:w,loading:k,onCheckBalance:E}),$e.createElement(le,null,$e.createElement("div",{className:zb()},$e.createElement(Lb,{variant:"title",size:"small"},cc.t("You get")),$e.createElement("div",{className:Ub()},$e.createElement(Fi,{onClick:!k&&!u&&!A?F:void 0}))),$e.createElement(pc,{size:"12"}),xm(J.map((W,Z)=>({element:W,key:`alert-${Z}`})),$e.createElement(pc,{size:10})),J.length>0?$e.createElement(pc,{size:10}):null,$e.createElement(Go,{quote:t,type:"swap-preview",id:"widget-confirm-swap-quote-container",expanded:!0,tagHidden:!0,error:x.error,loading:k,warning:x.warnings?.quote??null})))}i(Rg,"ConfirmSwapPage");import{i18n as oo}from"@lingui/core";import{Button as vc,CustomTokensZeroStateDarkIcon as sE,CustomTokensZeroStateIcon as lE,DeleteIcon as cE,Divider as Nr,IconButton as pE,MessageBox as uE,NotFound as dE,styled as bc}from"@rango-dev/ui";import ye,{useState as xc}from"react";import{useNavigate as mE}from"react-router-dom";import{CloseIcon as Hb,IconButton as Qb,SearchIcon as qb,TextField as Gb}from"@rango-dev/ui";import Ln from"react";import{styled as eh}from"@rango-dev/ui";var th=eh("div",{width:"$24",height:"$24",display:"flex",alignItems:"center",justifyContent:"center"}),oh=eh("div",{width:"100%","& ._text-field":{paddingLeft:"$10","& input":{paddingLeft:"$2",paddingTop:"$12",paddingBottom:"$12"}}});function At(t){let{variant:e,fullWidth:o,color:n,size:r,onChange:a,value:s,style:c,setValue:l,suffix:p,id:u,...m}=t,f=s.length?Ln.createElement(Qb,{id:`${u}\u06F0icon-btn`,variant:"ghost",onClick:()=>l?.(""),size:"small"},Ln.createElement(Hb,{color:"gray",size:10})):null;return p&&(f=p),Ln.createElement(oh,null,Ln.createElement(Gb,{prefix:Ln.createElement(th,null,Ln.createElement(qb,{color:"black"})),id:u,suffix:f,fullWidth:o,color:n,variant:e,style:{borderRadius:25,alignItems:"center",...c},size:r,value:s,onChange:a,...m}))}i(At,"SearchInput");import{i18n as wc}from"@lingui/core";import{Button as Xb,CustomTokenWarning as Yb,darkTheme as fh,Divider as to,ExternalLinkIcon as Zb,Image as Jb,ListItem as Rb,NotFound as eE,PinIcon as tE,Skeleton as Vo,Typography as Ir,VirtualizedList as oE}from"@rango-dev/ui";import L,{useState as nE}from"react";import{useTranslation as rE}from"react-i18next";import{Divider as dh,ListItem as jb,Skeleton as Er}from"@rango-dev/ui";import Nt from"react";import{css as Pn,darkTheme as dc,ImageContainer as Vb,ListItemButton as Kb,styled as rt,Typography as nh}from"@rango-dev/ui";var mc=Pn({position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:100,overflow:"hidden"}),fc=Pn({position:"relative",height:12,width:"30%",maxWidth:"150px"}),gc=Pn({position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",bottom:"-8px"}),hc=Pn({transform:"translateY(12px)",visibility:"hidden",display:"flex","& a":{display:"flex",justifyContent:"center",alignItems:"center",fontSize:"$12",lineHeight:"$16",$$color:"$colors$neutral600",[`.${dc} &`]:{$$color:"$colors$neutral700"},color:"$$color",textDecoration:"none"}}),yc=Pn({}),Sc=Pn(),rh=rt("div",{display:"flex",flexDirection:"column",flexGrow:1,overflow:"hidden",justifyContent:"center"}),Cc=rt("div",{display:"flex",alignItems:"center","._typography":{textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:100,overflow:"hidden"}}),Sa=rt("ul",{flexGrow:1,padding:0,margin:0,listStyle:"none","& li":{alignItems:"none","&:hover":{[`& .${fc}`]:{[`& .${hc}`]:{position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",visibility:"visible"},[`& .${yc}`]:{bottom:"-15px"},[`& .${mc}`]:{position:"absolute",transform:"translateY(-12px)",visibility:"hidden"},[`& .${gc}`]:{position:"absolute",transform:"translateY(-12px)",bottom:"-10px"}}}}}),ih=rt(Kb,{variants:{customToken:{true:{"&:hover":{cursor:"unset"}}}}}),Tc=rt("div",{paddingLeft:"$5",paddingRight:"$5",borderRadius:"$md",display:"flex",alignItems:"center"}),kc=rt(nh,{}),ah=rt("div",{textAlign:"right",width:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",[`& .${Sc}`]:{$$color:"$colors$neutral600",[`.${dc} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),br=rt("div",{display:"flex",alignItems:"end",flexDirection:"column"}),TV=rt("div",{display:"flex",alignItems:"center"}),sh=rt("div",{position:"relative",[`& ${Vb}`]:{borderRadius:"$xm",overflow:"hidden"}}),lh=rt("div",{position:"absolute",backgroundColor:"$neutral100",padding:"$4",borderRadius:"50%",bottom:-6,right:-6}),ch=rt(nh,{width:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}),ph=rt("a",{"& svg:hover":{color:"$colors$info"}}),uh=rt("div",{paddingRight:"$5","& .widget-token-list-item-btn":{width:"100%",overflow:"hidden",height:"60px"},"& .widget-token-list-item-import-btn":{height:"$20",padding:"0 $10","& ._text":{display:"flex",justifyContent:"center",alignItems:"center"},"& ._typography":{[`.${dc} &`]:{color:"$foreground"}}}});function mh(t){return Nt.createElement(Sa,null,Array.from(Array(t.size),e=>Nt.createElement(jb,{key:e,hasDivider:!0,start:Nt.createElement(Er,{variant:"circular",width:35,height:35}),end:Nt.createElement(br,null,Nt.createElement(Er,{variant:"text",size:"large",width:70}),Nt.createElement(dh,{size:4}),Nt.createElement(Er,{variant:"text",size:"medium",width:50})),title:Nt.createElement("div",null,Nt.createElement(Er,{variant:"text",size:"large",width:90}),Nt.createElement(dh,{size:4}),Nt.createElement(Er,{variant:"text",size:"medium",width:90}))})))}i(mh,"LoadingTokenList");var iE=20,aE=i(t=>{let{address:e,name:o,url:n,token:r,customCssForTag:a,customCssForTagTitle:s}=t,c=e.length;return L.createElement("div",{className:fc()},o?L.createElement("div",{className:mc()},o):L.createElement(Cc,{className:gc()},L.createElement(Ir,{variant:"title",size:"xmedium"},r.symbol),L.createElement(to,{direction:"horizontal",size:4}),L.createElement(Tc,{css:a},L.createElement(kc,{variant:"body",size:"xsmall",css:s},r.blockchain))),!!e&&L.createElement("div",{className:`${hc()} ${!o&&yc()}`},c>10?`${e.slice(0,5)}...${e.slice(c-6,c)}`:e," ",L.createElement(to,{size:4,direction:"horizontal"}),L.createElement(ph,{href:n,target:"_blank",rel:"nofollow noreferrer",onClick:l=>l.stopPropagation()},L.createElement(Zb,{size:12}))))},"renderDesc");function Ar(t){let{list:e,searchedFor:o="",onChange:n,selectedBlockchain:r,showTitle:a=!0,action:s,type:c,showWarning:l=!0}=t,p=T().fetchStatus,u=T().blockchains(),{getBalanceFor:m,fetchingWallets:f}=T(),{isTokenPinned:h}=T(),{setFromToken:g,setToToken:d}=z()(),{t:S}=rE(),y=qe(),[C,k]=nE(null),w=i(()=>{c==="source"?g({token:C,meta:{blockchains:u}}):d({token:C,meta:{blockchains:u}})},"updateToken"),x=i(()=>{w(),y()},"handleImportToken"),I=i(E=>{if(E.customToken){let{customToken:N,...M}=E;return L.createElement(Xb,{variant:"contained",type:"primary",size:"small",className:"widget-token-list-item-import-btn",onClick:i(H=>{H.stopPropagation(),k({...M,warning:!0})},"handleClick")},L.createElement(Ir,{variant:"body",size:"xsmall",color:"background"},S("import")))}let v=pi(m(E));return s?s(E):f?L.createElement(br,null,L.createElement(Vo,{variant:"text",size:"large",width:70}),L.createElement(to,{size:4}),L.createElement(Vo,{variant:"text",size:"medium",width:50})):v&&L.createElement(ah,null,L.createElement(ch,{variant:"title",size:"small"},v.amount),L.createElement("div",null),v.usdValue&&L.createElement(Ir,{variant:"body",className:Sc(),size:"xsmall"},`$${v.usdValue}`))},"endRenderer"),A=i(()=>L.createElement(oE,{itemContent:E=>{let v=e[E];if(v==="skeleton")return L.createElement(Rb,{hasDivider:!0,start:L.createElement(Vo,{variant:"circular",width:35,height:35}),end:L.createElement(br,null,L.createElement(Vo,{variant:"text",size:"large",width:70}),L.createElement(to,{size:4}),L.createElement(Vo,{variant:"text",size:"medium",width:50})),title:L.createElement("div",null,L.createElement(Vo,{variant:"text",size:"large",width:90}),L.createElement(to,{size:4}),L.createElement(Vo,{variant:"text",size:"medium",width:90}))});let N=u.find(W=>W.name===v?.blockchain);if(!N||!v)return null;let M=v.address,F=ll(N.color,"main"),H={$$color:F.main150,[`.${fh} &`]:{$$color:F.main750},backgroundColor:"$$color"},X={$$color:F.main750,[`.${fh} &`]:{$$color:F.main150},color:"$$color"},J=i(()=>{typeof v!="string"&&!v.customToken&&n?.(v)},"handleClick");return L.createElement(uh,null,L.createElement(ih,{"tab-index":E,key:`${v.symbol}${M}`,id:`${v.symbol}${M}`,className:"widget-token-list-item-btn",hasDivider:!0,customToken:v?.customToken,onClick:J,start:L.createElement(sh,null,L.createElement(Jb,{src:v.image===""?ei:v.image,size:30}),t.type!=="custom-token"&&v&&h(v,t.type)&&L.createElement(lh,null,L.createElement(tE,{size:12,color:"gray"}))),title:N.type==="COSMOS"||v.name||!v.name&&!M?L.createElement(Cc,null,L.createElement(Ir,{variant:"title",size:"xmedium"},v.symbol),L.createElement(to,{direction:"horizontal",size:4}),L.createElement(Tc,{css:H},L.createElement(kc,{variant:"body",size:"xsmall",css:X},v.blockchain)),l&&v.warning&&L.createElement(L.Fragment,null,L.createElement(to,{direction:"horizontal",size:4}),L.createElement(Yb,{container:B()}))):void 0,description:typeof v!="string"&&N.info&&M&&N.type!=="COSMOS"?aE({address:M,token:v,customCssForTag:H,customCssForTagTitle:X,name:v.name,url:N.info.addressUrl.split("{wallet}").join(M)}):v.name||void 0,end:I(v)}))},totalCount:e.length,key:`${r}-${o}`}),"renderList"),b=C?No(C?.blockchain,u):null;return L.createElement(L.Fragment,null,a&&L.createElement(L.Fragment,null,L.createElement(Ir,{variant:"label",size:"large"},wc.t("Select Token")),L.createElement(to,{size:4})),L.createElement(rh,null,L.createElement(to,{size:4}),p==="loading"&&L.createElement(mh,{size:iE}),p==="success"&&(e.length?L.createElement(L.Fragment,null,L.createElement(dr,{token:C,address:C?.address??"",blockchain:b??void 0,onImport:x,onExitErrorModal:()=>k(null),onExitImportModal:()=>k(null)}),L.createElement(Sa,{as:"ul"},A())):!!o&&L.createElement(eE,{title:wc.t("No results found"),description:wc.t("Try using different keywords")}))))}i(Ar,"TokenList");var fE=bc("div",{display:"flex",justifyContent:"space-between",flexDirection:"column",flex:1}),gE=bc("div",{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",flex:"0.75"}),hE=bc(pE,{"&:hover":{"& svg":{color:"$secondary550"}}});function gh(){let[t,e]=xc(""),{deleteCustomToken:o}=T(),n=T().customTokens(),{fromToken:r,toToken:a,setFromToken:s,setToToken:c}=z()(),{mode:l}=mo({}),p=mE(),[u,m]=xc(!1),[f,h]=xc(),g=i(C=>{let k=C.target.value;e(k)},"handleSearch"),d=l==="dark",S=n.filter(C=>st(C.symbol,t)||st(C.address||"",t)||st(C.name||"",t)),y=i(()=>{if(f){let C=a?yt(a):null,k=r?yt(r):null,w=yt(f);C===w?c({token:null}):k===w&&s({token:null}),o(f)}m(!1)},"handleDeleteCustomToken");return ye.createElement(ie,{header:{title:oo.t("Custom Tokens")}},ye.createElement(le,null,ye.createElement(fE,null,n.length?ye.createElement(ye.Fragment,null,ye.createElement(At,{id:"widget-custom-tokens-search-token-input",value:t,setValue:e,fullWidth:!0,color:"light",variant:"contained",placeholder:oo.t("Search Token"),onChange:g}),ye.createElement(Nr,{size:16}),ye.createElement(Ar,{list:S,type:"custom-token",searchedFor:t,showTitle:!1,showWarning:!1,action:C=>ye.createElement(hE,{id:"widget-custom-token-delete-icon-btn",variant:"ghost",onClick:()=>{m(!0),h(C)}},ye.createElement(cE,{size:12,color:"gray"}))})):ye.createElement(gE,null,ye.createElement(dE,{icon:d?ye.createElement(sE,{size:200}):ye.createElement(lE,{size:200}),title:oo.t("No custom tokens"),description:oo.t("press the button to add your custom token")})),ye.createElement(Nr,{size:20}),ye.createElement(vc,{id:"widget-custom-token-add-btn",type:"primary",variant:"contained",size:"large",onClick:()=>p($.addCustomTokens)},oo.t("Add Custom Token"))),ye.createElement(ee,{open:u,id:"widget-custom-tokens-delete-modal",dismissible:!0,onClose:()=>m(!1),container:B()},ye.createElement(uE,{title:oo.t("Delete Custom Token"),type:"error",description:oo.t("Are you sure you want to Delete this Token?")},ye.createElement(Nr,{size:40}),ye.createElement(Nr,{size:10}),ye.createElement(vc,{fullWidth:!0,id:"widget-custom-token-delete-modal-yes-btn",variant:"contained",type:"primary",size:"large",onClick:y},oo.t("Yes, Delete it")),ye.createElement(Nr,{size:12}),ye.createElement(vc,{id:"widget-custom-token-delete-modal-no-btn",fullWidth:!0,variant:"outlined",type:"primary",size:"large",onClick:()=>m(!1)},oo.t("No, Continue"))))))}i(gh,"CustomTokensPage");import{i18n as Fe}from"@lingui/core";import{useManager as DE}from"@rango-dev/queue-manager-react";import{Button as Mc,darkTheme as $E,Divider as To,MessageBox as FE,NotFound as OE,styled as Lc,Tabs as UE,Typography as ka}from"@rango-dev/ui";import{TransactionStatus as Mr}from"rango-types";import te,{useMemo as Ph,useState as Lr}from"react";import{useNavigate as zE}from"react-router-dom";import{FilterIcon as vE,Popover as xE}from"@rango-dev/ui";import Ko from"react";import{css as yE,darkTheme as Ca,IconButton as SE,styled as Br}from"@rango-dev/ui";var Ec=Br("div",{position:"relative","&::before":{position:"absolute",right:"1px",top:"-1px",width:"$8",height:"$8",borderRadius:"100%",backgroundColor:"$neutral300",[`.${Ca} &`]:{backgroundColor:"$neutral400"},padding:"$2"},variants:{isSelect:{true:{"&::before":{content:""}}}}}),hh=Br(SE,{width:"$36",height:"$36",position:"relative",padding:"0",overflow:"unset",backgroundColor:"$neutral300",[`.${Ca} &`]:{backgroundColor:"$neutral400"},"&:hover":{backgroundColor:"$secondary100",[`.${Ca} &`]:{backgroundColor:"$neutral"},[`& ${Ec}::before`]:{backgroundColor:"$secondary100",[`.${Ca} &`]:{backgroundColor:"$neutral"}}},variants:{isSelect:{true:{border:"1px solid $secondary"}}}}),yh=Br("div",{position:"absolute",width:"$6",height:"$6",display:"flex",justifyContent:"center",alignItems:"center",borderRadius:"3px",top:"$0",right:"1px",backgroundColor:"$secondary500"}),Sh=Br("div",{padding:"$15",borderRadius:"$sm",width:"248px",backgroundColor:"$background",zIndex:10}),Ch=yE({display:"flex",justifyContent:"space-between",alignItems:"center"}),Th=Br("ul",{margin:0,listStyle:"none",height:"100%",padding:0,".item-start-container":{paddingRight:"0 !important"}});import{i18n as kh}from"@lingui/core";import{Button as CE,Divider as wh,ListItemButton as TE,Radio as kE,RadioRoot as wE,Typography as vh}from"@rango-dev/ui";import dt from"react";function xh(t){let{filterBy:e,onClickItem:o}=t;return dt.createElement(Sh,null,dt.createElement("div",{className:Ch()},dt.createElement(vh,{size:"small",variant:"body"},kh.t("Status")),dt.createElement(CE,{id:"widget-filter-selector-reset-btn",variant:"ghost",size:"xxsmall",onClick:()=>o("")},kh.t("Reset"))),dt.createElement(wh,{size:10}),dt.createElement(wE,{value:e},dt.createElement(Th,null,t.list.map((n,r)=>dt.createElement(TE,{key:n.id,className:"widget-filter-selector-list-item-btn",style:{height:"40px",width:"100%"},selected:!1,hasDivider:t.list.length-1!=r,id:n.id,title:dt.createElement(dt.Fragment,null,dt.createElement(wh,{direction:"horizontal",size:4}),dt.createElement(vh,{size:"medium",variant:"body"},n.title)),start:dt.createElement(kE,{value:n.id}),onClick:o})))))}i(xh,"FilterSelectorContent");function Ic(t){let{onClickItem:e,onOpenChange:o,filterBy:n,list:r,open:a}=t;return Ko.createElement("div",null,Ko.createElement(xE,{open:a,align:"end",onOpenChange:o,container:B(),content:Ko.createElement(xh,{list:r,filterBy:n,onClickItem:s=>{e(s),o(!1)}})},Ko.createElement(hh,{id:"widget-filter-selector-filter-icon-btn",variant:"default",isSelect:!!n,onClick:()=>o(!t.open)},Ko.createElement(Ec,{isSelect:!!n},Ko.createElement(vE,{size:16,color:"black"}),!!n&&Ko.createElement(yh,null)))))}i(Ic,"FilterSelector");import{i18n as IE}from"@lingui/core";import{getCurrentStep as AE}from"@rango-dev/queue-manager-rango-preset";import{Divider as Nh,GroupedVirtualizedList as NE,Skeleton as BE,SwapListItem as Bh,Typography as WE}from"@rango-dev/ui";import Ze,{useCallback as Wh,useEffect as ME,useRef as LE,useState as PE}from"react";function bh(t,e){let o=[],n=0;do{let r=t[n];r&&(o.push(Math.min(r,e)),e-=r),n++}while(e>0&&n<=t.length);return o}i(bh,"calculateGroupsSoFar");import{css as bE,darkTheme as EE,styled as Wr}from"@rango-dev/ui";var Ac=bE(),Eh=Wr("div",{display:"flex",justifyContent:"center",alignItems:"center",padding:"$5"}),Nc=Wr("div",{width:"100%",display:"flex",flexDirection:"column",backgroundColor:"$background",padding:"$10 $5 0 $5",[`& .${Ac}`]:{$$color:"$colors$neutral600",[`.${EE} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),Bc=Wr("div",{display:"flex",justifyContent:"flex-start",padding:"$2"}),Ih=Wr("div",{gap:"$10",display:"flex",flexDirection:"column"}),Ah=Wr("div",{height:"100%",display:"flex",justifyContent:"center",alignItems:"center"});var _E=10;function Wc(t){let{list:e,onSwapClick:o,groupBy:n,isLoading:r}=t,[a,s]=PE([]),c=LE(0),{swaps:l,groupCounts:p,groups:u}=n(e),m=Wh(bh,[]),f=Wh(()=>{let h=e.length-c.current;h&&(c.current+=Math.min(h,_E),s(m(p,c.current)))},[e.length]);if(ME(()=>{r||f()},[r,f]),r){let h=[1,2];return Ze.createElement(Ze.Fragment,null,[h,h].map((d,S)=>Ze.createElement(Nc,{key:S},Ze.createElement(Bc,null,Ze.createElement(BE,{variant:"text",width:60,size:"small"}),Ze.createElement(Nh,{size:16})),Ze.createElement(Nh,{size:4}),Ze.createElement(Ih,null,d.map((C,k)=>Ze.createElement(Bh,{isLoading:!0,key:k}))))))}return Ze.createElement(NE,{endReached:()=>{c.current<e.length&&f()},groupCounts:a,groupContent:h=>Ze.createElement(Nc,null,Ze.createElement(Bc,null,Ze.createElement(WE,{variant:"label",size:"medium",className:Ac()},u[h]))),itemContent:(h,g)=>{let d=l[h];if(!d)return null;let S=AE(d),y=d.steps[0],C=d.steps[d.steps.length-1];return!y||!C?null:Ze.createElement(Eh,{key:d.requestId},Ze.createElement(Bh,{className:"widget-history-group-list-swap-item-btn",requestId:d.requestId,creationTime:d.creationTime,status:d.status,onClick:o,currentStep:S,tooltipContainer:B(),onlyShowTime:u[g]===IE.t("Today"),swapTokenData:{from:{token:{image:y.fromLogo,displayName:y.fromSymbol},blockchain:{image:y.fromBlockchainLogo||""},amount:P(d.inputAmount,6,6),realAmount:d.inputAmount},to:{token:{image:C.toLogo,displayName:C.toSymbol},blockchain:{image:C.toBlockchainLogo||""},amount:P(C.outputAmount||C.expectedOutputAmountHumanReadable||"",6,6),realAmount:C.outputAmount||C.expectedOutputAmountHumanReadable||""}}}))}})}i(Wc,"HistoryGroupedList");import{i18n as Ta}from"@lingui/core";import Mh from"dayjs";var Lh=i(t=>{let e=new Map([["today",{title:Ta.t("Today"),swaps:[]}],["week",{title:Ta.t("This week"),swaps:[]}],["month",{title:Ta.t("This month"),swaps:[]}],["year",{title:Ta.t("This year"),swaps:[]}]]);function o(l,p){e.has(l)||e.set(l,{title:l,swaps:[]}),e.get(l)?.swaps.push(p)}i(o,"addYearsToOutput");let n=Mh();t.forEach(l=>{let p=Number(l.creationTime),u=Mh(p);if(n.isSame(u,"day"))e.get("today")?.swaps.push(l);else if(n.isSame(u,"week"))e.get("week")?.swaps.push(l);else if(n.isSame(u,"month"))e.get("month")?.swaps.push(l);else if(n.isSame(u,"year"))e.get("year")?.swaps.push(l);else{let m=new Date(p).getFullYear().toString();o(m,l)}});let r=Array.from(e.values()).filter(l=>l.swaps.length>0),a=r.flatMap(l=>l.swaps),s=r.map(l=>l.swaps.length),c=r.map(l=>l.title);return{swaps:a,groupCounts:s,groups:c}},"groupSwapsByDate");var HE=Lc("div",{overflowY:"visible",width:"100%",display:"flex",flexDirection:"column",gap:15,height:"100%"}),QE=Lc("div",{display:"flex",justifyContent:"center",alignItems:"center"}),qE=Lc("div",{"._typography":{color:"$neutral700",[`.${$E}&`]:{color:"$neutral900"}}}),GE=i((t,e)=>t?.length?t.filter(o=>Pt(o.fromBlockchain,e)||Pt(o.toBlockchain,e)||Pt(o.toSymbol,e)||Pt(o.fromSymbol,e)).length:!1,"isStepContainsText");function _h(){let t=zE(),{manager:e,state:o}=DE(),n=Tt(e).map(({swap:b})=>b),[r,a]=Lr(""),[s,c]=Lr(!1),l=!o.loadedFromPersistor,[p,u]=Lr(""),[m,f]=Lr(!1),[h,g]=Lr("all"),d=i(b=>{let E=b.target.value;a(E)},"handleSearch"),{isMultiMode:S}=tt(),y=[{id:Mr.SUCCESS,title:Fe.t("Complete")},{id:Mr.RUNNING,title:Fe.t("Running")},{id:Mr.FAILED,title:Fe.t("Failed")}],C=[{id:"all",title:Fe.t("All")},{id:"swap",title:Fe.t("Swap")},{id:"refuel",title:Fe.t("Refuel")}],k=Ph(()=>!r&&!p&&h==="all"?n:n.filter(b=>{let{inputAmount:E,status:v,steps:N,requestId:M,mode:F}=b;return(!r||Pt(E,r)||Pt(v,r)||GE(N,r)||Pt(M,r))&&(!p||p===v)&&(h==="all"?!0:h==="swap"?!F||F==="swap":h==="refuel"?F==="refuel":!1)}),[n,r,p,h]),w=!k?.length&&!l,x=i(()=>f(!1),"onCloseModal"),I=i(async()=>{try{await e?.clearQueue(),f(!1)}catch(b){console.log(b)}},"onClear"),A=Ph(()=>!n.some(b=>b.status===Mr.SUCCESS||b.status===Mr.FAILED),[n]);return te.createElement(ie,{header:{title:Fe.t("History"),suffix:te.createElement(fo,null,te.createElement(Mc,{id:"widget-history-clear-btn",disabled:A,variant:"ghost",size:"xsmall",onClick:()=>f(!0)},te.createElement(ka,{size:"medium",variant:"label",color:"error"},Fe.t("Clear"))))}},te.createElement(le,null,te.createElement(QE,null,te.createElement(At,{setValue:a,fullWidth:!0,variant:"contained",placeholder:Fe.t("Search Transaction"),id:"widget-history-search-transaction-input",autoFocus:!0,onChange:d,style:{height:36},value:r}),te.createElement(To,{size:10,direction:"horizontal"}),te.createElement(Ic,{filterBy:p,open:s,onOpenChange:b=>c(b),onClickItem:b=>u(b),list:y})),te.createElement(To,{size:"16"}),S&&!l&&te.createElement(te.Fragment,null,te.createElement(UE,{items:C,onChange:b=>g(b.id),value:h,type:"secondary"}),te.createElement(To,{size:"12"})),te.createElement(HE,null,w&&te.createElement(Ah,null,te.createElement(To,{size:32}),te.createElement(OE,{title:r?Fe.t("No results found"):Fe.t("No transactions"),titleColor:r?void 0:"$info",hasIcon:!!r,description:r?Fe.t("Try using different keywords"):Fe.t("Your transaction history is stored locally and will appear here after you start a swap")})),!w&&te.createElement(Wc,{list:k,onSwapClick:t,groupBy:Lh,isLoading:l}))),te.createElement(ee,{open:m,onClose:x,id:"widget-history-clear-modal",container:B()},te.createElement(To,{size:20}),te.createElement(FE,{type:"warning",title:Fe.t("Clear Transaction History"),description:te.createElement(qE,null,te.createElement(ka,{variant:"body",size:"medium"},Fe.t("Proceeding will remove all successful and failed transactions from the widget. Do you want to continue?")),te.createElement(To,{size:"24"}),te.createElement(ka,{variant:"body",size:"small"},Fe.t("Note: This does not erase your transaction history on the chain; it only removes them here.")))}),te.createElement(To,{size:30}),te.createElement(Mc,{id:"widget-history-clear-modal-yes-btn",variant:"contained",type:"primary",size:"large",onClick:I},Fe.t("Yes, Clear the history")),te.createElement(To,{size:10}),te.createElement(Mc,{id:"widget-history-clear-modal-no-btn",variant:"outlined",type:"primary",size:"large",onClick:x},te.createElement(ka,{variant:"title",size:"medium",color:"primary"},Fe.t("No, Cancel")))))}i(_h,"HistoryPage");import{i18n as uy}from"@lingui/core";import{Button as II,Divider as Kc,styled as AI,WarningIcon as NI}from"@rango-dev/ui";import BI from"bignumber.js";import Ce,{useEffect as dy,useState as my}from"react";import{useNavigate as WI}from"react-router-dom";import{i18n as $h}from"@lingui/core";import{Alert as KE,Divider as Pc,NoRouteIcon as jE,Typography as XE}from"@rango-dev/ui";import jo from"react";import{styled as VE}from"@rango-dev/ui";var Dh=VE("div",{display:"flex",flexDirection:"column",alignItems:"center"});function _c(){let{fromToken:t,toToken:e}=z()();return!!t&&!!e&&qt(t,e)?jo.createElement(Dh,null,jo.createElement(Pc,{size:10}),jo.createElement(jE,{size:24,color:"gray"}),jo.createElement(Pc,{size:4}),jo.createElement(XE,{variant:"title",size:"small"},$h.t("No Routes Found")),jo.createElement(Pc,{size:4}),jo.createElement(KE,{title:$h.t("You cannot use the same token for From and To."),type:"warning",variant:"alarm"})):null}i(_c,"SameTokensWarning");import{Alert as YE,Button as ZE}from"@rango-dev/ui";import Oh from"react";import{i18n as wa}from"@lingui/core";function Fh(t){let e=null;return t===fi?(e={alertType:"error",action:"reset-slippage",actionButtonTitle:wa.t("Reset"),title:wa.t("Slippage cannot be set lower than 0.01%.")},e):t>an?(e={alertType:"warning",action:"change-settings",actionButtonTitle:wa.t("Change"),title:wa.t("Caution, your slippage is high!")},e):null}i(Fh,"makeAlerts");function Uh(t){let{slippage:e,customSlippage:o,setSlippage:n,setCustomSlippage:r}=T(),{onChangeSettings:a}=t,c=Fh(o!==null?o:e),l=i(p=>{p==="reset-slippage"?(n(mi),r(null)):p==="change-settings"&&a()},"onClickActionButton");return c?Oh.createElement(YE,{title:c.title,type:c.alertType,variant:"alarm",action:Oh.createElement(ZE,{id:"widget-slippage-warning-error-change-settings-or-reset-slippage-btn",size:"xxsmall",type:c.alertType,onClick:()=>l(c.action)},c.actionButtonTitle)}):null}i(Uh,"SlippageWarningsAndErrors");import{i18n as oI}from"@lingui/core";import{IconButton as nI,ReverseIcon as rI,Skeleton as iI,Tooltip as aI,Typography as Pr}from"@rango-dev/ui";import mt from"react";import va from"bignumber.js";function Hh(t){let{error:e,isDarkTheme:o,warning:n}=t,{quoteError:r,slippageError:a}=e,{quoteWarning:s,slippageWarning:c}=n,l=!!a||r?.type===4,p=!!c||s?.type===2;return l?"$error500":p?"$warning500":o?"$neutral600":"$neutral700"}i(Hh,"getSlippageColor");function Qh(t){let{toTokenUsdPrice:e,fromTokenUsdPrice:o}=t;if(!e||!o)return{rawValue:"0",displayValue:"0"};let n=new va(e),r=new va(o),a=n.dividedBy(r),s;return a.isLessThan(1)?s=a.toFixed(14).replace(/\.?0+$/,""):a.toFixed(0).length>10?s=a.toFixed(0).slice(0,10):s=a.toFixed(2),{displayValue:s,rawValue:a.toFixed()}}i(Qh,"getUsdExchangeRate");function qh(t,e){let o=new va(t).multipliedBy(e);return o.isLessThan(.001)?"$0":`$${o.decimalPlaces(2,va.ROUND_DOWN).toFormat(2)}`}i(qh,"formatTokenValueInUsd");import{darkTheme as eI,styled as $c,Typography as tI}from"@rango-dev/ui";var Gh=$c("div",{display:"flex",padding:"$4",justifyContent:"space-between",alignItems:"center"}),Vh=$c("div",{display:"flex",alignItems:"center",gap:"$2","& .rate-text":{color:"$neutral700",[`.${eI} &`]:{color:"$neutral700"}},"& ._icon-button":{transform:"rotate(90deg)",width:"$16",height:"$16"}}),Fc=$c(tI,{maxWidth:"$32",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"});function Oc(t){let{slippage:e,customSlippage:o,quoteTokensRate:n,changeQuoteTokensRate:r}=T(),{quoteError:a,quoteWarning:s,fromToken:c,toToken:l,quote:p,loading:u}=t,m=o!==null?o:e,{mode:f}=mo({}),h=cn(m),g=f==="dark",d=n==="default",S={quoteError:a,slippageError:h?.type==="error"?h.message:null},y={quoteWarning:s,slippageWarning:h?.type==="warning"?h.message:null},C=p?.swaps[0]?.from||c,k=p?.swaps[p?.swaps.length-1]?.to||l,w=d?C:k,x=d?k:C,I=Number(d?p?.outputAmount:p?.requestAmount),A=Number(d?p?.requestAmount:p?.outputAmount),b=I||w.usdPrice,E=A||x.usdPrice,{rawValue:v,displayValue:N}=Qh({toTokenUsdPrice:E,fromTokenUsdPrice:b});return mt.createElement(Gh,null,mt.createElement(Pr,{variant:S||y?"label":"body",size:S||y?"medium":"small",color:Hh({error:S,warning:y,isDarkTheme:g})},oI.t("Slippage:")," ",m,"%"),u?mt.createElement(iI,{height:16,width:104,variant:"rounded"}):b&&E&&mt.createElement(Vh,null,mt.createElement(Pr,{className:"rate-text",variant:"body",size:"small"},"1"),mt.createElement(Fc,{className:"rate-text",variant:"body",size:"small"},x.symbol),mt.createElement(nI,{id:"widget-home-page-change-rate-button",onClick:r},mt.createElement(rI,{size:14,color:"secondary"})),mt.createElement(aI,{container:B(),side:"top",sideOffset:4,content:mt.createElement(Pr,{className:"rate-text",variant:"body",size:"small"},v)},mt.createElement(Pr,{className:"rate-text",variant:"body",size:"small"},N)),mt.createElement(Fc,{className:"rate-text",variant:"body",size:"small"},w.symbol),w.usdPrice&&mt.createElement(Pr,{color:"neutral600",variant:"body",size:"small"},"~",qh(Number(v),w.usdPrice))))}i(Oc,"SwapMetrics");import{i18n as dI}from"@lingui/core";import{Header as mI}from"@rango-dev/ui";import ko,{useEffect as fI,useState as gI}from"react";import{i18n as lI}from"@lingui/core";import{Divider as zc,FullExpandedQuote as cI,Typography as pI}from"@rango-dev/ui";import ve from"react";import{styled as Uc}from"@rango-dev/ui";var Kh=Uc("div",{display:"flex",justifyContent:"center",flexDirection:"column",height:"100%"}),jh=Uc("div",{display:"flex",justifyContent:"space-between",alignItems:"center"}),Xh=Uc("div",{width:"146px"});import{i18n as _r}from"@lingui/core";import{Select as sI}from"@rango-dev/ui";import Yh from"react";function xa(t){let{updateQuotePartialState:e,sortStrategy:o}=z()(),n=[{value:"SMART",label:_r.t("Smart Routing")},{value:"FEE",label:_r.t("Lowest Fee")},{value:"SPEED",label:_r.t("Fastest Transfer")},{value:"NET_OUTPUT",label:_r.t("Maximum Return")},{value:"PRICE",label:_r.t("Maximum Output")}];return Yh.createElement(Xh,null,Yh.createElement(sI,{id:"widget-quotes-strategy-select",container:t.container,options:n,value:o,handleItemClick:r=>{e("sortStrategy",r.value)},variant:"filled"}))}i(xa,"SelectStrategy");var Zh=3;function Dr(t){let{loading:e,onClickOnQuote:o,fetch:n,showModalFee:r,hasSort:a=!0,fullExpandedMode:s=!1,container:c}=t,{selectedQuote:l,quotes:p,updateQuotePartialState:u,fromToken:m,toToken:f,sortStrategy:h,error:g}=z()(),{slippage:d,customSlippage:S}=T(),{findToken:y}=T(),C=c||B(),k=!!p&&p.results.length,w=S??d,x=i(b=>{if(!m||!f||!p)return null;let E={requestAmount:p.requestAmount,validationStatus:null,...b};return Sn({currentQuote:E,userSlippage:w,findToken:y})},"getQuoteWarning"),I=g?.type===0||g?.type===1,A=p?.results?Ai(h,p?.results):[];return ve.createElement(ve.Fragment,null,a&&ve.createElement(ve.Fragment,null,ve.createElement(jh,null,ve.createElement(pI,{size:"xmedium",variant:"title"},lI.t("Sort by")),ve.createElement(xa,{container:C})),ve.createElement(zc,{size:"10"})),e&&Array.from({length:Zh},(b,E)=>ve.createElement(ve.Fragment,{key:E},s?ve.createElement(cI,{loading:!0}):ve.createElement(vr,{tagHidden:!1,type:"list-item",expanded:!1}),E!==Zh-1&&ve.createElement(zc,{size:16}))),!e&&ve.createElement(ve.Fragment,null,k?A.map((b,E)=>{let v=x(b),N=sc(b.swaps),M=A.length-1===E;return ve.createElement(ve.Fragment,{key:b.requestId},ve.createElement(Go,{id:"widget-quotes-quote-info-container",showModalFee:r,container:C,selected:l?.requestId===b.requestId,tagHidden:!1,quote:{...b,requestAmount:p.requestAmount,validationStatus:null},loading:e,error:N?.options||null,warning:v,fullExpandedMode:s,onClick:F=>{N||u("warning",v),u("error",N?.options||null),o(F)},type:"list-item"}),!M&&ve.createElement(zc,{size:16}))}):I&&ve.createElement(Kh,null,ve.createElement(gr,{size:s?"large":"small",error:g,fetch:n}))))}i(Dr,"Quotes");import{darkTheme as uI,styled as Jh}from"@rango-dev/ui";var Rh=Jh("div",{transition:"width 0.2s, opacity 0.2s, margin-left 0.2s",height:"700px",width:"390px",position:"relative",opacity:1,marginLeft:"$16",backgroundColor:"$neutral100",[`.${uI} &`]:{backgroundColor:"$neutral300"},variants:{expandMode:{default:{width:"390px"},full:{width:"719px"}}},"&.is-hidden":{width:0,height:0,opacity:0,marginLeft:0}}),ey=Jh("div",{position:"relative",overflow:"hidden",padding:"$20",flexGrow:1,display:"flex",flexDirection:"column",overflowY:"auto",borderRadius:"$primary",backgroundColor:"$background"});var hI=100;function Hc(t){let{fetch:e,loading:o,onClickOnQuote:n,onClickRefresh:r,isVisible:a}=t,[s,c]=gI(!1),l=s?"":"is-hidden",{config:p}=T(),u=p?.variant==="full-expanded",m=Wo();return fI(()=>{let f=null;return a?f=setTimeout(()=>{c(!0)},hI):(c(!1),f&&clearTimeout(f)),()=>{f&&clearTimeout(f)}},[a]),ko.createElement(Rh,{expandMode:p?.variant==="full-expanded"?"full":"default",className:`${l} ${Hi()} widget-expanded-quotes-container`,id:Re.EXPANDED_BOX_ID},ko.createElement(mI,{title:dI.t("Routes"),suffix:ko.createElement(ko.Fragment,null,ko.createElement(xa,{container:m}),ko.createElement(zo,{container:m,onClickRefresh:r,hidden:["history","notifications","settings"]}))}),ko.createElement(ey,null,ko.createElement(Dr,{showModalFee:!0,fetch:e,hasSort:!1,loading:o,container:Wo(),onClickOnQuote:n,fullExpandedMode:u})))}i(Hc,"ExpandedQuotes");import{i18n as sy}from"@lingui/core";import{SwapInput as ly}from"@rango-dev/ui";import TI from"bignumber.js";import $r from"react";import{ReverseIcon as CI}from"@rango-dev/ui";import qc from"react";import{keyframes as yI,styled as ty}from"@rango-dev/ui";var Qc=450,SI=yI({"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)"}}),oy=ty("div",{position:"absolute",bottom:"-12px",left:"50%",transform:"translate(-50%, 10%)",cursor:"pointer"}),ny=ty("div",{borderRadius:"$md",border:"3px solid $background",background:"$neutral100",width:"$24",height:"$24",display:"flex",justifyContent:"center",alignItems:"center",color:"$foreground","&.rotate":{"& svg":{animation:`${SI} ${Qc}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 Gc(){let t=z().use.switchFromAndTo();return qc.createElement(oy,null,qc.createElement(ny,{id:"widget-switch-from-and-to-btn",onClick:e=>{let o=e.currentTarget;o.classList.add("rotate"),setTimeout(()=>{o.classList.remove("rotate")},Qc),t()}},qc.createElement(CI,{size:12})))}i(Gc,"SwitchFromAndToButton");import{styled as ry}from"@rango-dev/ui";var iy=ry("div",{display:"flex",flexDirection:"column",gap:"$5",alignSelf:"stretch"}),ay=ry("div",{position:"relative"});function Vc(t){let{fetchingQuote:e,fetchMetaStatus:o,onClickToken:n,isExpandable:r}=t,{fromToken:a,fromBlockchain:s,toToken:c,toBlockchain:l,setInputAmount:p,sanitizeInputAmount:u,inputAmount:m,inputUsdValue:f,outputAmount:h,outputUsdValue:g,selectedQuote:d}=z()(),{swapMode:S}=tt(),{connectedWallets:y,getBalanceFor:C}=T(),k=a?C(a):null,w=pi(k)?.amount??"0",x=k?new TI(k.amount).shiftedBy(-k.decimals):pe,I=!!s&&Iu(y,s.name),A=!Gs(d,m,f),b=!Gs(d,m,g),E=!f||!g||!g.gt(0)?null:jt(f.toString(),g.toString());return $r.createElement(iy,null,$r.createElement(ay,null,$r.createElement(ly,{label:sy.t("From"),id:"widget-swap-from",mode:"From",onInputChange:p,onInputBlur:u,balance:w,chain:{displayName:s?.displayName||"",image:s?.logo},token:{displayName:a?.symbol||"",image:a?.image,securityWarning:!!a?.warning},onClickToken:()=>n("from"),price:{value:m,usdValue:A?void 0:P(f,4,4),realUsdValue:A?void 0:f?.toString(),error:A?ne().unknownPriceError.impactTitle:void 0},disabled:o==="failed",loading:o==="loading",loadingBalance:I,tooltipContainer:B(),onSelectMaxBalance:()=>{let v=P(x,k?.decimals),N=k?.amount?v.split(",").join(""):"";p(N)},anyWalletConnected:y.length>0}),S==="swap"&&$r.createElement(Gc,null)),$r.createElement(ly,{selectionType:S==="swap"?"token":"chain",sharpBottomStyle:!r&&(!!d||e),label:sy.t("To"),mode:"To",id:"widget-swap-to-input",fetchingQuote:e,chain:{displayName:l?.displayName||"",image:l?.logo},token:{displayName:c?.symbol||"",image:c?.image,securityWarning:!!c?.warning},percentageChange:P(jt(f,g),2,2),warningLevel:Xt(E??0),price:{value:P(h,6,6),usdValue:b?void 0:P(g,4,4),realValue:h?.toString(),realUsdValue:b?void 0:g?.toString(),error:b?ne().unknownPriceError.impactTitle:void 0},onClickToken:()=>n("to"),disabled:o==="failed",loading:o==="loading",tooltipContainer:B()}))}i(Vc,"Inputs");import{warn as kI}from"@rango-dev/logging-core";import{useCallback as wI,useEffect as vI,useRef as xI,useState as bI}from"react";function cy(){let{fetch:t,loading:e,cancelFetch:o}=fa({request:async(n,r)=>await ct().getAllRoutes(n,r)});return{fetch:t,loading:e,cancelFetch:o}}i(cy,"useFetchAllQuotes");var EI=600;function ba({refetchQuote:t}){let{fetch:e,cancelFetch:o}=cy(),{excludeLiquiditySources:n,routing:r}=T().config,{connectedWallets:a}=T(),c=a.some(ue=>ue.isContractWallet),{fromToken:l,toToken:p,inputAmount:u,inputUsdValue:m,selectedQuote:f,sortStrategy:h,resetQuote:g,error:d,warning:S,setSelectedQuote:y,updateQuotePartialState:C}=z()(),{slippage:k,customSlippage:w,affiliatePercent:x,affiliateRef:I,affiliateWallets:A,fetchStatus:b}=T(),E=T().getLiquiditySources(),v=T().getDisabledLiquiditySources(),N=T().excludeLiquiditySources(),{findToken:M}=T(),{swapMode:F}=tt(),[H,X]=bI(!0),J=xI(u),W=w??k,Y=!l||!p||qt(l,p)||!Gn(u),ce=i(ue=>{X(ue)},"resetState"),fe=i(ue=>{let{fromToken:wt,toToken:gt,inputAmount:Wt,liquiditySources:D,excludeLiquiditySources:U,disabledLiquiditySources:G,slippage:se,affiliateRef:Q,affiliatePercent:j,affiliateWallets:K}=ue;if(H||ce(!0),!Y&&wt&>){g();let Ie=Gd({fromToken:wt,toToken:gt,inputAmount:Wt,liquiditySources:D,excludeLiquiditySources:U,disabledLiquiditySources:G,wallets:a,slippage:se,affiliateRef:Q,affiliatePercent:j,affiliateWallets:K,contractCall:c});ln("experimental",r)&&(Ie.experimental=!0),ln("avoidNativeFee",r)&&(Ie.avoidNativeFee=!0),ln("enableCentralizedSwappers",r)&&(Ie.enableCentralizedSwappers=!0),r?.maxLength&&(Ie.maxLength=r.maxLength),F==="refuel"&&(Ie.maxLength=1),e(Ie).then(Ae=>{let Ke=Ai(h,Ae.results),Mt=Ld(f,Ke,Ae.requestAmount);X(!1),C("quotes",Ae),y(Mt),ga({diagnosisMessages:Ae.diagnosisMessages,requestId:Mt?.requestId||"",swaps:Mt?.swaps});let so=Mt&&Sn({currentQuote:Mt,userSlippage:W,findToken:M});C("warning",so)}).catch(Ae=>{let Ke=ha(Ae);(Ke.type===0||Ke.type===1)&&g(),Ke.type!==2&&(C("error",Ke),X(!1),kI(new Error("quote error"),{tags:{...Ke,type:Ye[Ke.type],requestBody:Ie}}))})}},"fetch"),at=wI(ni(ue=>{fe(ue)},EI),[Y]);return vI(()=>{if(!t){X(!1);return}if(b!=="success")return;if(Y){X(!1),(f||d||S)&&g();return}if(!Gn(u)&&m?.eq(0)){ce(!1),o();return}g(),ce(!0);let ue=fe;return J.current&&J.current!=u&&(ue=at),J.current=u,ue({inputAmount:u,fromToken:l,toToken:p,liquiditySources:E,excludeLiquiditySources:N,disabledLiquiditySources:v,slippage:W,affiliateRef:I,affiliatePercent:x,affiliateWallets:A,contractCall:c}),o},[b,u,l?.symbol,l?.address,l?.blockchain,p?.symbol,p?.address,p?.blockchain,Y,E?.length,n,v.length,W,I,x,c,JSON.stringify(A)]),{fetch:()=>fe({inputAmount:u,fromToken:l,toToken:p,liquiditySources:E,excludeLiquiditySources:N,disabledLiquiditySources:v,slippage:W,affiliateRef:I,affiliatePercent:x,affiliateWallets:A,contractCall:c}),loading:H}}i(ba,"useSwapInput");function py(t,e){let o=!1,n={preventDefault(){o=!0},...t.payload===void 0&&{payload:t.payload}};we.emit("uiEvent",{type:t.type,payload:n}),o||e()}i(py,"emitPreventableEvent");var MI=AI("div",{display:"flex",alignItems:"flex-start",maxHeight:700,"& .footer__alert":{paddingTop:"0 !important"}}),LI=300;function fy(){let t=WI(),{fromToken:e,toToken:o,inputAmount:n,selectedQuote:r,refetchQuote:a,error:s,warning:c,quotes:l,setSelectedQuote:p,resetQuoteWallets:u,setQuoteWarningsConfirmed:m,updateQuotePartialState:f}=z()(),[h,g]=my(!1),{isLargeScreen:d,isExtraLargeScreen:S}=ia(),{fetch:y,loading:C}=ba({refetchQuote:a}),{config:k,fetchStatus:w,connectedWallets:x,customSlippage:I,slippage:A,setSlippage:b,setCustomSlippage:E}=T(),{isActiveTab:v}=oe(),[N,M]=my(!1),F=I!==null?I:A,{swapMode:H}=tt(),X=cn(F),W=zd({fetchMetaStatus:w,fetchingQuote:C,inputAmount:n,quote:r,anyWalletConnected:x.length>0,error:s,warning:c,needsToWarnEthOnPath:!1}),Z=Pu(d,S,k?.variant),Y=!!n&&!!e&&!!o&&new BI(n).gt(0)&&!Jd(e,o),ce=Y&&w==="success"&&C,fe=X?.quoteValidation||c,wt=(!Z||Z&&l?.results.length)&&(fe||s),gt=!!e&&!!o,Wt=gt&&!!X,D=(r||s)&&!N?y:void 0,U=i(j=>{Z&&h?(g(!1),setTimeout(()=>{t(j)},LI)):t(j)},"onHandleNavigation"),G=i(j=>{r?.requestId!==j.requestId&&(M(!1),p(j))},"onClickOnQuote"),se=i(j=>{if(j){if(di.includes(j)){b(j),E(null);return}E(j)}},"onChangeSlippage"),Q=i(j=>{U(j==="from"?$.fromSwap:H==="swap"?$.toSwap:$.toSwap+"/"+$.blockchains)},"handleInputTokenClick");return dy(()=>{u(),f("refetchQuote",!0)},[]),dy(()=>{g(Y)},[Y]),Ce.createElement(MI,null,Ce.createElement(ie,{height:"auto",footer:Ce.createElement(II,{id:`widget-swap-${W.action}-btn`,type:"primary",size:"large",disabled:W.disabled||!v,prefix:W.action==="confirm-warning"&&Ce.createElement(NI,null),fullWidth:!0,onClick:()=>{W.action==="connect-wallet"?py({type:"clickConnectWallet"},()=>U($.wallets)):W.action==="confirm-warning"?M(!0):U($.confirmSwap)}},W.title),header:{onWallet:()=>{U($.wallets)},hasBackButton:!1,title:k.title||(H==="swap"?uy.t("Swap"):uy.t("Refuel")),suffix:Ce.createElement(zo,{hidden:Z?["refresh"]:void 0,onClickRefresh:D,onClickHistory:()=>U($.swaps),onClickSettings:()=>{U($.settings)}})}},Ce.createElement(le,null,Ce.createElement(Vc,{fetchingQuote:ce,fetchMetaStatus:w,isExpandable:Z,onClickToken:Q}),Ce.createElement(Kc,{size:"2"}),Z?null:Ce.createElement(Go,{quote:r,loading:ce,error:s,id:"widget-home-expandable-quote-container",tagHidden:!1,warning:fe,type:"basic",onClickAllRoutes:l&&l.results.length>1?()=>{f("refetchQuote",!1),U($.routes)}:void 0}),gt&&Ce.createElement(Ce.Fragment,null,Ce.createElement(Kc,{size:8}),Ce.createElement(Oc,{quoteError:s,quoteWarning:fe,fromToken:e,toToken:o,quote:r,loading:ce})),wt?Ce.createElement(Ce.Fragment,null,Ce.createElement(yr,{warning:fe,error:s,skipAlerts:!!X,couldChangeSettings:!0,refetchQuote:y,showWarningModal:N,confirmationDisabled:!v,onOpenWarningModal:()=>M(!0),onCloseWarningModal:()=>M(!1),onChangeSlippage:se,onConfirmWarningModal:()=>{M(!1),m(!0),U($.confirmSwap)},onChangeSettings:()=>U($.settings)})):null,Wt&&Ce.createElement(Ce.Fragment,null,Ce.createElement(Kc,{size:"10"}),Ce.createElement(Uh,{onChangeSettings:()=>U($.settings)})),Ce.createElement(_c,null))),Z?Ce.createElement(Hc,{loading:ce,onClickOnQuote:G,fetch:y,onClickRefresh:D,isVisible:h}):null)}i(fy,"Home");import{i18n as gy}from"@lingui/core";import{Alert as PI,Divider as _I,List as DI,ListItemButton as $I,Radio as FI,RadioRoot as OI,Typography as UI}from"@rango-dev/ui";import Ot from"react";function wo(){let{setLanguage:t,language:e,config:o}=T(),n=zu,r=o?.language||pn;return{activeLanguage:e||r,languages:n,defaultLanguage:r,changeLanguage:a=>t(a||pn),resetLanguage:()=>t(null)}}i(wo,"useLanguage");function hy(){let{activeLanguage:t,changeLanguage:e,languages:o}=wo(),n=qe(),r=o.map(a=>{let{local:s,label:c,SVGFlag:l}=a;return{id:`widget-setting-languages-${s}-item-btn`,value:s,title:Ot.createElement(UI,{variant:"title",size:"xmedium"},c),onClick:()=>{e(a.local),n()},end:Ot.createElement(FI,{value:s}),start:Ot.createElement(l,null)}});return Ot.createElement(ie,{header:{title:gy.t("Language")}},Ot.createElement(le,null,Ot.createElement(PI,{type:"warning",id:"widget-language-machine-translation-alarm-alert",variant:"alarm",title:"Warning: We are using machine translation, so the translations may be inaccurate."}),Ot.createElement(_I,{size:"8"}),Ot.createElement(OI,{value:t},Ot.createElement(DI,{type:Ot.createElement($I,{title:gy.t("language"),className:"widget-language-list-item-btn",id:"_",onClick:()=>console.log()}),items:r}))))}i(hy,"LanguagePage");import{i18n as no}from"@lingui/core";import{Button as GI,Checkbox as VI,Image as KI,ListItemButton as jI,NotFound as XI,Typography as YI}from"@rango-dev/ui";import Je,{useState as ZI}from"react";import{Checkbox as QI,Skeleton as Sy}from"@rango-dev/ui";import Or from"react";import{styled as jc}from"@rango-dev/ui";var Fr=jc("ul",{padding:"$15 $5 0",margin:0,listStyle:"none",height:"100%",overflowY:"auto",variants:{disabled:{true:{pointerEvents:"none"}}}}),Xc=jc("div",{width:80,display:"flex",justifyContent:"flex-end"}),Yc=jc("div",{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%"});import{ListItem as zI,styled as HI}from"@rango-dev/ui";var yy=HI(zI,{height:61});var qI=30;function Zc(){return Or.createElement(Fr,null,Array.from(Array(qI),(t,e)=>Or.createElement(yy,{hasDivider:!0,key:e,start:Or.createElement(Sy,{variant:"circular",width:35,height:35}),title:Or.createElement(Sy,{variant:"text",size:"large",width:90}),end:Or.createElement(QI,{checked:!1})})))}i(Zc,"LoadingLiquiditySourceList");function Jc({sourceType:t}){let e=T().fetchStatus,o=T().swappers(),n=T().getDisabledLiquiditySources(),[r,a]=ZI(""),s=T().toggleLiquiditySource,c=T().isInCampaignMode(),l=gi(o,n),p={Exchanges:no.t("Exchanges"),Bridges:no.t("Bridges")},u=[];t==="Exchanges"&&u.push("DEX"),t==="Bridges"&&u.push("BRIDGE","AGGREGATOR","OFF_CHAIN");let m=l.filter(y=>u.includes(y.type)),f=m.length===m.filter(y=>y.selected).length,h=i(()=>{m.forEach(y=>{f?s(y.groupTitle):y.selected||s(y.groupTitle)})},"toggleAllSources"),g=m.map(y=>{let{selected:C,groupTitle:k,logo:w,id:x,...I}=y;return{id:`widget-setting-liquidity-source-${gu(x.toLowerCase())}-item-btn`,start:Je.createElement(KI,{src:w,size:22,type:"circular"}),onClick:()=>{c||s(k)},end:Je.createElement(VI,{checked:C,disabled:c}),title:Je.createElement(YI,{variant:"title",size:"xmedium"},no.t(k)),selected:C,groupTitle:k,logo:w,...I}}),d=i(y=>{let C=y.target.value;a(C)},"handleSearch"),S=g;return r&&(S=g.filter(y=>Pt(y.groupTitle,r))),Je.createElement(ie,{header:{title:no.t(t),suffix:Je.createElement(Xc,null,Je.createElement(GI,{id:`widget-liquidity-source-${f?"deselect-all":"select-all"}-btn`,variant:"ghost",size:"xsmall",onClick:h},f?no.t("Deselect all"):no.t("Select all")))}},Je.createElement(le,{view:!0},Je.createElement(At,{value:r,setValue:a,id:"widget-liquidity-source-search-input",fullWidth:!0,color:"light",variant:"contained",placeholder:no.t("Search {sourceType}",{sourceType:p[t]}),onChange:d}),e==="loading"&&Je.createElement(Zc,null),!S.length&&r?Je.createElement(Yc,null,Je.createElement(XI,{title:no.t("No results found"),description:no.t("Try using different keywords")})):e==="success"&&Je.createElement(Fr,{disabled:c,className:"widget-liquidity-source-list"},S.map(y=>{let{groupTitle:C,...k}=y;return Je.createElement(Je.Fragment,{key:y.id},Je.createElement(jI,{style:{height:"61px"},...k,selected:!1,className:"widget-liquidity-source-list-item-btn",hasDivider:!0}))}))))}i(Jc,"LiquiditySourcePage");import{i18n as JI}from"@lingui/core";import Ea from"react";import{useNavigate as RI}from"react-router-dom";function Cy(){let t=RI(),e=qe(),{selectedQuote:o,refetchQuote:n,setSelectedQuote:r,updateQuotePartialState:a,error:s}=z()(),{fetch:c,loading:l}=ba({refetchQuote:n}),p=i(f=>{r(f),a("refetchQuote",!1),e()},"onClickOnQuote"),u=`../${$.settings}`,m=`../${$.wallets}`;return Ea.createElement(ie,{header:{onWallet:()=>{t(m),a("refetchQuote",!0)},onBack:()=>{a("refetchQuote",!1)},title:JI.t("Routes"),suffix:Ea.createElement(zo,{onClickRefresh:o||s?c:void 0,hidden:["notifications","history"],onClickSettings:()=>{t(u),a("refetchQuote",!0)}})}},Ea.createElement(le,null,Ea.createElement(Dr,{fetch:c,loading:l,onClickOnQuote:p})))}i(Cy,"RoutesPage");import{i18n as Ey}from"@lingui/core";import{Divider as Iy,getCategoriesCount as cA,SelectableCategoryList as pA}from"@rango-dev/ui";import ro,{useState as Ay}from"react";import{useNavigate as uA}from"react-router-dom";import{i18n as Rc}from"@lingui/core";import{Divider as nA,Image as rA,ListItemButton as iA,NotFound as aA,Typography as by}from"@rango-dev/ui";import ft,{useEffect as sA,useState as lA}from"react";var Ty=i((t,e,o)=>t.filter(n=>ri(n.type,o)).filter(n=>st(n.name,e)||st(n.displayName,e)),"filterBlockchains");import{ImageContainer as eA,styled as ky}from"@rango-dev/ui";var wy=ky("div",{display:"flex",flexDirection:"column",overflow:"hidden",height:"100%",justifyContent:"center"}),Ia=ky(El,{padding:0,margin:0,listStyle:"none",[`& ${eA}`]:{borderRadius:"$xm",overflow:"hidden"}});import{ListItem as tA,Skeleton as vy}from"@rango-dev/ui";import Aa from"react";var oA=20;function xy(){return Aa.createElement(Ia,{id:"widget-blockchain-loading-list",as:"ul"},Array.from(Array(oA),t=>Aa.createElement(tA,{key:t,hasDivider:!0,start:Aa.createElement(vy,{variant:"circular",width:35,height:35}),title:Aa.createElement(vy,{variant:"text",size:"large",width:90})})))}i(xy,"LoadingBlockchainList");function ep(t){let{list:e,searchedFor:o,onChange:n,blockchainCategory:r,showTitle:a=!0}=t,[s,c]=lA(e),{fetchStatus:l}=T();sA(()=>{c([...Ty(e,o,r)])},[e,o,r]);let p=i(()=>!s.length&&o?ft.createElement(aA,{title:Rc.t("No results found"),description:Rc.t("Try using different keywords")}):ft.createElement(Ia,{as:"ul",key:`${r}-${o}`,id:"widget-blockchain-list"},s.map(u=>ft.createElement(iA,{key:`${u.name}-${u.chainId}`,className:"widget-blockchain-list-item-btn",hasDivider:!0,onClick:()=>n(u),start:ft.createElement(rA,{src:u.logo,size:30}),title:ft.createElement(by,{variant:"title",size:"medium"},u.displayName),id:u.name}))),"renderList");return ft.createElement(ft.Fragment,null,a&&ft.createElement(ft.Fragment,null,ft.createElement(by,{variant:"label",size:"large"},Rc.t("Select Chain")),ft.createElement(nA,{size:4})),ft.createElement(wy,null,l==="loading"&&ft.createElement(xy,null),l==="success"&&p()))}i(ep,"BlockchainList");function Na(t){let{type:e}=t,o=qe(),[n,r]=Ay(""),[a,s]=Ay("ALL"),c=z().use.setToBlockchain(),l=z().use.setFromBlockchain(),p=z().use.setToToken(),{fetchStatus:u,findNativeToken:m}=T(),f=uA(),{swapMode:h}=tt(),g=T().blockchains({type:e}),d=cA(g),S=!t.hideCategory&&d!==1,y=i(C=>{if(e==="custom-token")f(`..?blockchain=${C.name}`,{replace:!0});else{if(e==="source")l(C);else if(h==="swap")c(C);else{let k=m(C);k&&p({token:k,meta:{blockchains:g}})}o()}},"handleBlockchainChange");return ro.createElement(ie,{header:{title:Ey.t("Select Chain")}},ro.createElement(le,{view:!0},S&&ro.createElement(ro.Fragment,null,ro.createElement(pA,{setCategory:s,category:a,blockchains:g,isLoading:u==="loading"}),ro.createElement(Iy,{size:24})),ro.createElement(At,{value:n,autoFocus:!0,placeholder:Ey.t("Search Chain"),id:"widget-select-blockchain-search-input",color:"light",variant:"contained",size:"large",setValue:()=>r(""),onChange:C=>r(C.target.value)}),ro.createElement(Iy,{size:16}),ro.createElement(ep,{list:g,showTitle:e!=="custom-token",searchedFor:n,blockchainCategory:a,onChange:y})))}i(Na,"SelectBlockchainPage");import{i18n as Ma}from"@lingui/core";import{Divider as _y,Spinner as EA}from"@rango-dev/ui";import vo,{useEffect as IA,useState as AA}from"react";import{useNavigate as NA}from"react-router-dom";import{i18n as np}from"@lingui/core";import{BlockchainsChip as Ba,Divider as My,Image as Ly,Skeleton as yA,Tooltip as SA,Typography as rp}from"@rango-dev/ui";import xe from"react";import{useEffect as fA}from"react";var Ny=["ETH","COSMOS","OSMOSIS"];function tp(t,e,o){let n=JSON.parse(JSON.stringify(t)),r=[];if(n.sort(dA),o?.limit&&t.length>o.limit){let a=o.limit,s=e;if(e.length<=o.limit){let c=o.limit-e.length;for(let l=0;l<=c;l++){let p=n[l];s=s.filter(u=>p?.name!==u)}}n.sort(mA(s)),r=n.splice(a)}return{list:n,more:r}}i(tp,"prepare");function dA(t,e){let o=Ny,n=o.findIndex(c=>c===t.name),r=o.findIndex(c=>c===e.name),a=n>-1,s=r>-1;return a&&s?n>r?1:-1:a?-1:s?1:0}i(dA,"sortByMostUsedBlockchains");function mA(t){return i(function(o,n){let r=t.findIndex(l=>l===o.name),a=t.findIndex(l=>l===n.name),s=r>-1,c=a>-1;return s&&c?r>a?1:-1:t.includes(o.name)?-1:t.includes(n.name)?1:0},"sortByPreferred")}i(mA,"generateSortByPreferredBlockchainsFor");function By(t,e){return!!e.list.find(o=>o.name===t)}i(By,"isInVisibleList");function op(t,e){let{preferredBlockchains:o,addPreferredBlockchain:n}=T();fA(()=>{if(e?.selected){let a=tp(t,o,e);By(e.selected,a)||n(e?.selected)}},[e?.selected]);let r=tp(t,o,e);return{list:r.list,more:r.more,history:[]}}i(op,"usePrepareBlockchainList");import{styled as gA}from"@rango-dev/ui";var Wy=gA("div",{display:"grid",gap:"$10",gridTemplateColumns:"repeat(6, minmax(0, 1fr))"});var CA=6,TA=12;function ip(t){let{blockchains:e,type:o,blockchain:n,onChange:r,onMoreClick:a}=t,{showCompactTokenSelector:s}=oe(),c=op(e,{limit:s?4:10,selected:n?.name}),{fetchStatus:l}=T(),p=z().use.resetToBlockchain(),u=z().use.resetFromBlockchain(),m=c.more.length>0,f=c.more[0],h=c.more.length===1&&f,g=!h&&m;return xe.createElement(xe.Fragment,null,!s&&xe.createElement(xe.Fragment,null,xe.createElement(My,{size:12}),xe.createElement(rp,{variant:"label",size:"large"},np.t("Select Chain"))),xe.createElement(My,{size:12}),xe.createElement(Wy,{id:"widget-blockchains-section-container"},l==="loading"&&Array.from(Array(s?CA:TA),(d,S)=>xe.createElement(yA,{key:S,variant:"rounded",height:50})),l==="success"&&xe.createElement(xe.Fragment,null,xe.createElement(Ba,{className:"widget-blockchains-section-all-btn",selected:!n,onClick:()=>{o==="from"?u():p()}},xe.createElement(rp,{variant:"body",size:"xsmall",color:"secondary500"},np.t("All"))),c.list.map(d=>xe.createElement(SA,{key:d.name,content:d.shortName,side:"bottom",sideOffset:2,container:B()},xe.createElement(Ba,{className:"widget-blockchains-section-item-btn",key:d.name,selected:!!n&&n.name===d.name,onClick:()=>r(d)},xe.createElement(Ly,{src:d.logo,size:30})))),h?xe.createElement(Ba,{className:"widget-blockchains-section-only-item-btn",key:f.name,selected:!!n&&n.name===f.name,onClick:()=>r(f)},xe.createElement(Ly,{src:f.logo,size:30})):null,g?xe.createElement(Ba,{onClick:a,key:"more-blockchains",className:"widget-blockchains-section-more-items-btn"},xe.createElement(rp,{variant:"body",size:"xsmall",color:"secondary500"},np._("More +{count}",{count:c.more.length}))):null)))}i(ip,"BlockchainsSection");import{useCallback as wA,useRef as vA,useState as ap}from"react";function sp(){let t=T().blockchains(),e=vA(null),{customTokens:o}=T(),[n,r]=ap(!1),[a,s]=ap([]),[c,l]=ap(null),p=i(async(f,h)=>{l(null),r(!0),s([]);try{let g=await ct().searchCustomTokens({query:f,blockchain:h},{signal:e.current?.signal}),d=new Set(o().map(C=>Vt(C))),S=new Set(t.map(C=>C.name)),y=g.tokens.filter(C=>S.has(C.blockchain)&&!d.has(Vt(C)));s(y),r(!1)}catch(g){l(g instanceof Error?g.message:"something went wrong"),s([]),g?.name!=="CanceledError"&&r(!1)}},"fetch"),u=wA(ni((f,h)=>{e.current?.signal.aborted||p(f,h)},600),[t.length]);return{fetch:(f,h)=>{e.current=new AbortController,s([]),r(!0),u(f,h)},cancel:i(()=>{e.current?.abort()},"cancel"),loading:n,tokens:a,error:c}}i(sp,"useSearchCustomTokens");function Wa(t,e,o){return o&&t.length===1&&t[0]?.address===e?!1:t.length<20&&e.trim().length>=3}i(Wa,"shouldSearchForCustomTokens");function Py(t,e,o,n,r){let a=[...t];return Wa(t,o,r)&&(a=n?[...a,"skeleton","skeleton","skeleton"]:[...a,...e.map(s=>({...s,customToken:!0,warning:!0}))]),a}i(Py,"prepareTokensList");function La(t){let{type:e}=t,o=NA(),n=qe(),{fromBlockchain:r,toBlockchain:a,setFromToken:s,setToToken:c,setFromBlockchain:l,setToBlockchain:p}=z()(),{getBalanceFor:u}=T(),{fetch:m,loading:f,tokens:h,cancel:g}=sp(),[d,S]=AA(""),y=e==="source"?r:a,C=y?.name??"",k=T().blockchains({type:e}),w=T().tokens({type:e,blockchain:C,searchFor:d,getBalanceFor:u}),x=Py(w,h,d,f,y?.name),I=i(E=>{e==="source"?l(E):p(E)},"updateBlockchain"),A=i(E=>{e==="source"?s({token:E,meta:{blockchains:k}}):c({token:E,meta:{blockchains:k}})},"updateToken"),b={source:Ma.t("Source"),destination:Ma.t("Destination")};return IA(()=>(Wa(w,d,y?.name)&&m(d,y?.name??void 0),()=>{g()}),[w.length,d,y?.name]),vo.createElement(ie,{header:{title:Ma.t("Swap {type}",{type:b[e]})}},vo.createElement(le,null,vo.createElement(ip,{blockchains:k,type:e=="source"?"from":"to",blockchain:e==="source"?r:a,onMoreClick:()=>o($.blockchains),onChange:E=>{I(E)}}),vo.createElement(_y,{size:24}),vo.createElement(At,{value:d,id:"widget-select-swap-item-search-input",autoFocus:!0,placeholder:Ma.t("Search Token"),color:"light",variant:"contained",size:"large",setValue:()=>S(""),onChange:E=>S(E.target.value),suffix:Wa(w,d,y?.name)&&f?vo.createElement(EA,{size:12,color:"secondary"}):void 0}),vo.createElement(_y,{size:16}),vo.createElement(Ar,{list:x,selectedBlockchain:C,searchedFor:d,type:e,onChange:E=>{A(E);let v=k.find(N=>E.blockchain===N.name);v&&I(v),n()}})))}i(La,"SelectSwapItemsPage");import{i18n as up}from"@lingui/core";import{Alert as oN,Button as nN,styled as rN}from"@rango-dev/ui";import Xo from"react";import{useInRouterContext as iN,useSearchParams as aN}from"react-router-dom";import{i18n as zy}from"@lingui/core";import{Alert as LA,Divider as cp,InfoIcon as PA,SlippageIcon as _A,TextField as DA,Tooltip as $A,Typography as Hy}from"@rango-dev/ui";import Ue from"react";import{Chip as BA,styled as Ur,TextField as WA}from"@rango-dev/ui";var Dy=Ur("div",{paddingTop:"$5",padding:"$10 $5"}),$y=Ur("div",{display:"flex",flexWrap:"wrap",gap:"$10",[`& ${WA}`]:{flex:"1 1 0",maxWidth:"127px",minWidth:"85px",paddingLeft:"$2"}}),Fy=Ur("div",{display:"flex",justifyContent:"start",alignItems:"center",paddingBottom:"$10"}),Pa=Ur("div",{maxWidth:"280px",padding:"$10"}),Oy=Ur(BA,{width:"61px",flexShrink:0});import{i18n as lp}from"@lingui/core";import{Typography as MA}from"@rango-dev/ui";import zr from"react";function Uy(){return zr.createElement(Pa,null,zr.createElement(MA,{variant:"label",size:"medium",color:"neutral700"},lp.t("Your transaction will be reverted if the price changes unfavorably by more than this percentage."),zr.createElement("br",null),zr.createElement("br",null),zr.createElement("b",null,lp.t("Warning")),":\xA0",lp.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(Uy,"SlippageTooltipContent");function pp(){let{slippage:t,setSlippage:e,customSlippage:o,setCustomSlippage:n}=T(),r=o!==null?cn(o):null,a=i(l=>{let p=l.target.value,u=parseFloat(p);if(isNaN(u))return n(null);let m=u;u>Xn&&(m=Xn),n(m)},"onSlippageValueChange"),s=i(l=>{o!==null&&n(null),e(l)},"onClickSlippageChip"),c=i(l=>{let p=l.target,u=p.value;yu(u)||(p.value=u.slice(0,-1))},"onInput");return Ue.createElement(Dy,null,Ue.createElement(Fy,null,Ue.createElement(_A,{size:16,color:"gray"}),Ue.createElement(cp,{direction:"horizontal",size:4}),Ue.createElement(Hy,{variant:"title",size:"xmedium"},zy.t("Slippage tolerance per swap")),Ue.createElement(cp,{direction:"horizontal",size:4}),Ue.createElement($A,{container:B(),side:"top",sideOffset:4,content:Ue.createElement(Uy,null)},Ue.createElement(PA,{color:"gray"}))),Ue.createElement($y,null,di.map((l,p)=>{let u=`slippage-${p}`;return Ue.createElement(Oy,{id:`widget-slippage-chip-${l.toString()}%-btn`,key:u,onClick:()=>s(l),selected:o===null&&l===t,label:`${l.toString()}%`})}),Ue.createElement(DA,{type:"number",min:"0.01",max:"30",step:"0.01",status:r?.type||(o?"success":"default"),id:"widget-slippage-chip-text-input",onInput:c,fullWidth:!0,variant:"contained",value:o===null?"":o,color:"dark",onChange:a,suffix:o&&Ue.createElement(Hy,{variant:"body",size:"small"},"%"),placeholder:zy.t("Custom")})),r&&Ue.createElement(Ue.Fragment,null,Ue.createElement(cp,{size:10}),Ue.createElement(LA,{id:"widget-slippage-alert",variant:"alarm",type:r.type,title:r.message})))}i(pp,"Slippage");import{i18n as kt}from"@lingui/core";import{AutoThemeIcon as Qy,BridgesIcon as FA,ChevronRightIcon as _a,DarkModeIcon as qy,Divider as Hr,ExchangeIcon as OA,InfinityIcon as UA,InfoIcon as zA,LanguageIcon as HA,LightModeIcon as Gy,List as QA,ListItem as qA,ListItemButton as GA,Skeleton as VA,styled as KA,Switch as jA,Tabs as XA,TargetIcon as YA,Tooltip as ZA,Typography as it}from"@rango-dev/ui";import _ from"react";import{useNavigate as JA}from"react-router-dom";var RA=KA("div",{width:"202px",height:"$40"}),eN=[{id:"light",icon:_.createElement(Gy,{color:"black",size:24}),tooltip:_.createElement(it,{size:"xsmall",variant:"body"},kt.t("Light"))},{id:"dark",icon:_.createElement(qy,{color:"black",size:24}),tooltip:_.createElement(it,{size:"xsmall",variant:"body"},kt.t("Dark"))},{id:"auto",icon:_.createElement(Qy,{color:"black",size:24}),tooltip:_.createElement(it,{size:"xsmall",variant:"body"},kt.t("Auto"))}],tN=i(t=>{let e={color:"gray",size:16};switch(t){case"auto":return _.createElement(Qy,{...e});case"dark":return _.createElement(qy,{...e});default:return _.createElement(Gy,{...e})}},"getThemeIcon");function Vy(){let t=JA(),{theme:e}=T().config,{setTheme:o,theme:n}=T(),{activeLanguage:r,languages:a}=wo(),s=a.find(W=>W.local===r)?.label,c=T().fetchStatus,l=T().swappers(),p=T().getDisabledLiquiditySources(),{config:{features:u}}=T(),m=T().customTokens(),f=et("theme",u),h=et("liquiditySource",u),g=et("language",u),d=et("customTokens",u),S=T().infiniteApprove,y=T().toggleInfiniteApprove,C=gi(l,p),k=C.filter(W=>["BRIDGE","AGGREGATOR","OFF_CHAIN"].includes(W.type)),w=k.length,x=k.filter(W=>W.selected).length,I=C.filter(W=>W.type==="DEX"),A=I.length,b=I.filter(W=>W.selected).length,E=i((W,Z)=>{switch(c){case"loading":return _.createElement(VA,{variant:"text",size:"medium",width:50});case"failed":return _.createElement(it,{variant:"body",size:"medium",color:"$error500"},kt.t("Loading failed"));default:return _.createElement(it,{variant:"body",size:"medium"},`${W} / ${Z}`)}},"handleSwapperEndItem"),v={id:"widget-setting-bridge-item-btn",title:_.createElement(it,{variant:"title",size:"xmedium"},kt.t("Bridges")),end:_.createElement(_.Fragment,null,E(x,w),_.createElement(Hr,{direction:"horizontal",size:8}),_.createElement(_a,{color:"black"})),onClick:()=>t($.bridges),start:_.createElement(FA,{color:"gray",size:16})},N={id:"widget-setting-exchange-item-btn",title:_.createElement(it,{variant:"title",size:"xmedium"},kt.t("Exchanges")),end:_.createElement(_.Fragment,null,E(b,A),_.createElement(Hr,{direction:"horizontal",size:8}),_.createElement(_a,{color:"black"})),start:_.createElement(OA,{color:"gray",size:16}),onClick:()=>t($.exchanges)},M={id:"widget-setting-custom-tokens-item-btn",title:_.createElement(it,{variant:"title",size:"xmedium"},kt.t("Custom Tokens")),end:_.createElement(_.Fragment,null,_.createElement(it,{variant:"body",size:"medium"},`${m.length}`),_.createElement(Hr,{direction:"horizontal",size:8}),_.createElement(_a,{color:"black"})),start:_.createElement(YA,{color:"gray",size:16}),onClick:()=>t($.customTokens)},F={id:"widget-setting-language-item-btn",title:_.createElement(it,{variant:"title",size:"xmedium"},kt.t("Language")),start:_.createElement(HA,{color:"gray",size:16}),end:_.createElement(_.Fragment,null,_.createElement(it,{variant:"body",size:"medium"},s),_.createElement(Hr,{direction:"horizontal",size:8}),_.createElement(_a,{color:"black"})),onClick:()=>t($.languages)},H={id:"widget-setting-infinite-approval-item-btn",title:_.createElement(_.Fragment,null,_.createElement(it,{variant:"title",size:"xmedium"},kt.t("Infinite approval")),_.createElement(Hr,{direction:"horizontal",size:4}),_.createElement(ZA,{side:"top",sideOffset:4,container:B(),content:_.createElement(Pa,null,_.createElement(it,{variant:"label",size:"medium",color:"neutral700"},_.createElement("b",null,kt.t("Warning")),":\xA0",kt.t("Enabling the 'Infinite approval' mode grants unrestricted access to underlying smart contracts, allowing them to utilize the approved token amount without limitations.")))},_.createElement(zA,{color:"gray"}))),start:_.createElement(UA,{color:"gray",size:16}),end:_.createElement(jA,{checked:S}),onClick:y},X={id:"widget-setting-theme-item-btn",type:_.createElement(qA,null),title:_.createElement(it,{variant:"title",size:"xmedium"},kt.t("Theme")),end:_.createElement(RA,null,_.createElement(XA,{container:B(),items:eN,value:n,className:"widget-setting-theme-item-tabs-container",onChange:W=>o(W.id),type:"primary",borderRadius:"small"})),start:tN(n)},J=h?[]:[v,N];return d||J.push(M),g||J.push(F),J.push(H),!e?.singleTheme&&!f&&J.push(X),_.createElement(QA,{type:_.createElement(GA,{className:"widget-settings-list-item-btn",hasDivider:!0,id:"_",onClick:()=>console.log()}),items:J})}i(Vy,"SettingsLists");var sN=rN("div",{paddingLeft:"$8"});function Ky(){let{isInCampaignMode:t,updateCampaignMode:e}=T(),o=t(),[,n]=aN(),r=iN(),a=i(()=>{r&&o&&(n(s=>(s.delete("liquiditySources"),s),{replace:!0}),e("liquiditySources",void 0))},"onClick");return Xo.createElement(ie,{header:{title:up.t("Settings")}},Xo.createElement(le,null,o&&Xo.createElement(oN,{type:"info",variant:"alarm",id:"widget-settings-campaign-mode-alert",title:up.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:Xo.createElement(sN,null,Xo.createElement(nN,{id:"widget-setting-exit-campaign-mode-btn",type:"secondary",size:"small",onClick:a},up.t("Reset")))}),Xo.createElement(pp,null),Xo.createElement(Vy,null)))}i(Ky,"SettingsPage");import{i18n as y0}from"@lingui/core";import{cancelSwap as S0}from"@rango-dev/queue-manager-rango-preset";import{useManager as C0}from"@rango-dev/queue-manager-react";import{Alert as T0}from"@rango-dev/ui";import Ap from"react";import{useParams as k0}from"react-router-dom";import{i18n as zt}from"@lingui/core";import{getCurrentNamespaceOfOrNull as n0,getCurrentStep as r0,getRelatedWalletOrNull as i0}from"@rango-dev/queue-manager-rango-preset";import{Button as zS,Divider as a0,QuoteCost as s0,StepDetails as l0,Typography as wp}from"@rango-dev/ui";import{useWallets as c0}from"@rango-dev/wallets-react";import HS from"bignumber.js";import{PendingSwapNetworkStatus as $n}from"rango-types";import ke,{useEffect as vp,useRef as xp,useState as qa}from"react";import{useNavigate as p0}from"react-router-dom";import{i18n as xo}from"@lingui/core";var lN=[xo.t("Sunday"),xo.t("Monday"),xo.t("Tuesday"),xo.t("Wednesday"),xo.t("Thursday"),xo.t("Friday"),xo.t("Saturday")];function jy(t){let e=new Date(t),o=e.getDate(),n=e.toLocaleString("default",{month:"long"}),r=e.getFullYear();return`${e.getDay()===new Date().getDay()?xo.t("Today"):`${lN[e.getDay()]} ${o} ${n} ${r}`}, ${new Date(t).toLocaleTimeString()}`}i(jy,"timeSince");function Xy(t){return t.finishTime?jy(parseInt(t.finishTime)):jy(parseInt(t.creationTime))}i(Xy,"getSwapDate");import Qr from"react";import{i18n as Da}from"@lingui/core";import{Button as Yy,Divider as dp,MessageBox as cN}from"@rango-dev/ui";import bo from"react";var Zy=i(({onCancel:t,onClose:e})=>bo.createElement(bo.Fragment,null,bo.createElement(dp,{size:20}),bo.createElement(cN,{type:"error",title:Da.t("Cancel Swap"),description:Da.t("Are you sure you want to cancel this swap?")}),bo.createElement(dp,{size:32}),bo.createElement(Yy,{variant:"contained",id:"widget-swap-details-modal-cancel-swap-yes-btn",type:"primary",size:"large",onClick:t},Da.t("Yes, Cancel it")),bo.createElement(dp,{size:12}),bo.createElement(Yy,{id:"widget-swap-details-modal-cancel-swap-no-btn",variant:"outlined",type:"primary",size:"large",onClick:e},Da.t("No, Continue"))),"CancelContent");import{i18n as $a}from"@lingui/core";import{Button as Jy,Divider as mp,MessageBox as pN,Typography as uN}from"@rango-dev/ui";import io from"react";var Ry=i(({onDelete:t,onClose:e})=>io.createElement(io.Fragment,null,io.createElement(mp,{size:20}),io.createElement(pN,{type:"error",title:$a.t("Delete Transaction"),description:$a.t("Are you sure you want to delete this swap?")}),io.createElement(mp,{size:32}),io.createElement(Jy,{id:"widget-swap-details-modal-delete-swap-yes-btn",variant:"contained",type:"primary",size:"large",onClick:t},$a.t("Yes, Delete it")),io.createElement(mp,{size:12}),io.createElement(Jy,{id:"widget-swap-details-modal-delete-swap-no-btn",variant:"outlined",type:"primary",size:"large",onClick:e},io.createElement(uN,{variant:"title",size:"medium",color:"primary"},$a.t("No, Cancel")))),"DeleteContent");import{i18n as dN}from"@lingui/core";import{Button as mN,Divider as fN,MessageBox as gN}from"@rango-dev/ui";import Yo from"react";var eS=i(t=>{let{switchNetworkModalState:e,handleSwitchNetwork:o}=t;return Yo.createElement(Yo.Fragment,null,Yo.createElement(gN,{type:e.type,title:e.title,description:e.description}),e.type==="error"&&Yo.createElement(Yo.Fragment,null,Yo.createElement(fN,{size:"30"}),Yo.createElement(mN,{id:"widget-switch-network-try-again",type:"primary",size:"large",onClick:o},dN.t("Try Again"))))},"NetworkStateContent");import{getCurrentNamespaceOfOrNull as LN,getCurrentStep as PN,getRelatedWalletOrNull as _N}from"@rango-dev/queue-manager-rango-preset";import{WalletState as DN}from"@rango-dev/ui";import{useWallets as $N}from"@rango-dev/wallets-react";import sS from"react";import{i18n as _n}from"@lingui/core";import{Alert as nS,Button as SN,Checkbox as CN,Divider as Ua,Image as TN,MessageBox as kN,Spinner as wN,WarningIcon as vN}from"@rango-dev/ui";import{useWallets as xN}from"@rango-dev/wallets-react";import Se,{useState as bN}from"react";import{css as hN,darkTheme as yN,styled as fp}from"@rango-dev/ui";var tS=hN({wordWrap:"break-word",display:"block"}),oS=fp("img",{width:"100%"}),Fa=fp("div",{position:"relative"}),Oa=fp("span",{position:"absolute",top:0,right:0,borderRadius:"50%",width:"14px",height:"14px",display:"flex",padding:"$2",backgroundColor:"$warning300",[`.${yN} &`]:{$$color:"$warning600"}});var rS=i(t=>{let{wallet:e,namespace:o,onClose:n}=t,[r,a]=bN(null),{list:s}=vt(),c=oe.use.isActiveTab(),{state:l,connect:p}=xN(),u=s.find(x=>x.type===e.walletType),m=u?.needsNamespace?.data.find(x=>x.value===o?.namespace);if(!u)return null;let f=l(e.walletType),h=u.isHub&&o?.namespace?f.namespaces?.get(o.namespace):null,g=f.connecting||h?.connecting,d=u.isHub?h?.connected:f.connected,S=i(()=>d?_n.t("Done"):r?_n.t("Try again"):_n.t("Connect"),"getButtonTitle"),y=i(()=>g?Se.createElement(wN,{color:"info"}):r||d?null:Se.createElement(CN,{checked:!0,disabled:!0}),"getNamespaceSuffix"),C=i(async()=>{try{a(null),await p(u.type,o?.namespace?[{namespace:o?.namespace,network:void 0,derivationPath:e.derivationPath}]:void 0)}catch(x){a(x)}},"handleConnect"),k=i(async()=>{if(d){n();return}C()},"handleClickButton"),w=i(()=>{if(!d)return null;let x=u?.isHub?h?.accounts?.[0]?.split(":"):f?.accounts?.[0]?.split(":"),I=x?.[x?.length-1];return I?lo(I):null},"getAddress");return Se.createElement(Se.Fragment,null,Se.createElement(kN,{type:"warning",title:_n.t("Connect {wallet}",{wallet:u.title}),description:_n.t("The connection of your wallet or some networks has been disconnected. Connect to continue the swap"),icon:Se.createElement(Fa,null,Se.createElement(TN,{src:u.image,size:45}),Se.createElement(Oa,null,Se.createElement(vN,{color:"warning",size:10})))}),d&&!m&&Se.createElement(Se.Fragment,null,Se.createElement(Ua,{size:10}),Se.createElement(nS,{type:"success",variant:"alarm",title:_n.t("Wallet connected successfully.")})),r&&!m&&Se.createElement(Se.Fragment,null,Se.createElement(Ua,{size:10}),Se.createElement(nS,{type:"error",title:r?.message,variant:"alarm"})),m&&Se.createElement(Se.Fragment,null,Se.createElement(Ua,{size:30}),Se.createElement(_o,{namespace:m,suffix:y(),error:r?.message,connected:d,address:w()})),Se.createElement(Ua,{size:"40"}),Se.createElement(SN,{loading:g,type:"primary",id:"widget-connect-wallet-btn",onClick:k,disabled:!c},S()))},"ConnectWalletContent");import{i18n as iS}from"@lingui/core";import{Button as EN,Divider as IN,Image as AN,MessageBox as NN,WarningIcon as BN}from"@rango-dev/ui";import{useWallets as WN}from"@rango-dev/wallets-react";import{detectInstallLink as MN}from"@rango-dev/wallets-shared";import ao from"react";var aS=i(t=>{let{walletType:e}=t,{getWalletInfo:o}=WN(),n=e?o(e):null;if(!n)return null;let r=i(()=>window.open(MN(n.installLink),"_blank"),"handleButtonClick");return ao.createElement(ao.Fragment,null,ao.createElement(NN,{type:"warning",title:iS.t("Install {wallet}",{wallet:n.name}),description:"Your wallet is not installed. Please install it to continue the swap. ",icon:ao.createElement(Fa,null,ao.createElement(AN,{src:n.img,size:45}),ao.createElement(Oa,null,ao.createElement(BN,{color:"warning",size:10})))}),ao.createElement(IN,{size:"40"}),ao.createElement(EN,{type:"primary",id:"widget-install-wallet-btn",onClick:r},iS.t("Install")))},"InstallWalletContent");var lS=i(t=>{let{swap:e,onClose:o}=t,{state:n,getWalletInfo:r}=$N(),a=PN(e),s=a?_N(e,a):null,c=s?.walletType,l=c?Vn(r(c),n(c)):null,p=a?LN(e,a):null;return c?l===DN.NOT_INSTALLED?sS.createElement(aS,{walletType:c}):sS.createElement(rS,{wallet:s,namespace:p,onClose:o}):null},"WalletStateContent");function gp(t){let{isOpen:e,state:o,switchNetworkModalState:n,onClose:r,onDelete:a,onCancel:s,swap:c,message:l,handleSwitchNetwork:p}=t;return Qr.createElement(ee,{open:e,onClose:r,container:B()},o==="connectWallet"&&Qr.createElement(lS,{swap:c,message:l,onClose:r}),o==="switchNetwork"&&n&&Qr.createElement(eS,{message:l,switchNetworkModalState:n,handleSwitchNetwork:p}),o==="delete"&&Qr.createElement(Ry,{onClose:r,onDelete:()=>{r(),a()}}),o==="cancel"&&Qr.createElement(Zy,{onClose:r,onCancel:()=>{r(),s()}}))}i(gp,"SwapDetailsModal");import{i18n as qr}from"@lingui/core";import{Button as hp,Divider as Gr,MessageBox as uS,TokenAmount as FN,Typography as dS}from"@rango-dev/ui";import Te from"react";import{Link as ON,useNavigate as UN}from"react-router-dom";var cS="https://raw.githubusercontent.com/rango-exchange/assets/main/banners/widget/profile.jpg",pS="/profile";function yp(t){let{open:e,onClose:o,status:n,priceValue:r,usdValue:a,realUsdValue:s,realValue:c,token:l,chain:p,percentageChange:u,description:m,diagnosisUrl:f}=t,h=UN(),{showProfileBanner:g}=oe();return Te.createElement(ee,{open:e,onClose:o,id:"widget-swap-details-complete-modal",container:document.getElementById(Re.SWAP_BOX_ID)||document.body},n==="success"?Te.createElement(uS,{type:"success",title:qr.t("Swap Successful")},Te.createElement(FN,{direction:"vertical",tooltipContainer:B(),id:"widget-swap-details-complete-modal-success-token-amount-container",type:"output",centerAlign:!0,price:{value:r,usdValue:a,realUsdValue:s,realValue:c},token:l,chain:p,percentageChange:u}),Te.createElement(Gr,{size:12}),Te.createElement(dS,{className:tS(),variant:"body",size:"medium",color:"neutral700",align:"center"},m)):Te.createElement(uS,{type:"error",title:qr.t("Transaction Failed"),description:m}),Te.createElement(Gr,{size:30}),n==="success"&&Te.createElement(Te.Fragment,null,g&&Te.createElement(Te.Fragment,null,Te.createElement(ON,{to:pS},Te.createElement(oS,{src:cS,alt:"Profile Banner"})),Te.createElement(Gr,{size:30})),Te.createElement(hp,{id:"widget-swap-details-modal-done-btn",variant:"contained",type:"primary",size:"large",onClick:()=>{h("../../")}},qr.t("Done"))),Te.createElement(Gr,{size:12}),f&&Te.createElement(Te.Fragment,null,Te.createElement(hp,{variant:"contained",id:"widget-swap-detail-modal-diagnosis-btn",type:"primary",size:"large",onClick:()=>window.open(f,"_blank")},qr.t("Diagnosis")),Te.createElement(Gr,{size:12})),Te.createElement(hp,{id:"widget-swap-details-modal-see-details-btn",variant:"outlined",type:"primary",size:"large",onClick:o},Te.createElement(dS,{variant:"title",size:"medium",color:"primary"},qr.t("See Details"))))}i(yp,"SwapDetailsCompleteModal");import{i18n as Qa}from"@lingui/core";import{CopyIcon as JN,DoneIcon as RN,IconButton as e0,RangoExplorerIcon as t0,Tooltip as _S,Typography as DS,useCopyToClipboard as o0}from"@rango-dev/ui";import Bt from"react";import ZN from"react";import{i18n as KN}from"@lingui/core";import{Alert as WS,IconButton as jN,LinkIcon as XN}from"@rango-dev/ui";import Eo,{Fragment as YN}from"react";import{Alert as HN,ChevronDownIcon as QN,IconButton as qN}from"@rango-dev/ui";import Dn,{useState as GN}from"react";import{css as Vr,darkTheme as mS,styled as Ut,Typography as zN}from"@rango-dev/ui";var fS=Ut(le,{overflowY:"auto","& ._icon-button":{"&:hover":{"& svg":{color:"$secondary550",[`.${mS} &`]:{color:"$secondary500"}}}}}),gS=Ut("div",{display:"flex",flexDirection:"column",flexGrow:1,overflow:"hidden"}),hS=Ut("div",{position:"sticky",top:0,zIndex:10,backgroundColor:"$background"}),yS=Ut("div",{padding:"$0 $20 $20 $20"}),vY=Ut("div",{display:"flex",flexDirection:"column",gap:"$10"}),SS=Ut("div",{height:"450px",display:"flex",alignItems:"center",justifyContent:"center"}),xY=Ut("div",{display:"flex",justifyContent:"center",width:"100%",paddingTop:"33%",flex:1}),Zo=Vr({display:"flex",width:"100%",justifyContent:"space-between",alignItems:"center",padding:"$10 $20",borderBottom:"1px solid",$$color:"$colors$neutral300",[`.${mS} &`]:{$$color:"$colors$neutral400"},borderColor:"$$color",color:"$neutral500"}),CS=Vr({padding:"$5 0"}),za=Vr({display:"flex",justifyContent:"center",alignItems:"center",height:"$24"}),TS=Vr({display:"flex",width:"100%",padding:"$15 $20 $20",flexDirection:"column",alignItems:"start"}),kS=Vr({width:"100%",padding:"0 $20 $10"}),wS=Ut("a",{fontSize:"$16",fontWeight:"$400",color:"$neutral700",display:"flex",alignItems:"center",justifyContent:"center"}),vS=Ut("div",{display:"flex",flexDirection:"column",gap:"$5"}),Ha=Ut(zN,{wordBreak:"break-word"});import{styled as Sp}from"@rango-dev/ui";var xS=Sp("div",{display:"flex",flexDirection:"column",gap:"$10"}),bS=Sp("div",{transition:"transform 0.3s ease-in-out",variants:{rotated:{true:{transform:"rotate(180deg)"}}}}),ES=Sp("div",{transition:"max-height 0.3s ease-in-out",maxHeight:"0px",overflow:"hidden",variants:{open:{true:{maxHeight:"200px"}}}});function IS(t){let{message:e}=t,[o,n]=GN(!1);return Dn.createElement(HN,{id:"widget-failed-swap-details-alert",type:"error",title:e.shortMessage,containerStyles:{"& .footer":{paddingTop:"$0"}},action:e.detailedMessage.content&&Dn.createElement(qN,{id:"widget-swap-details-failed-btn",onClick:()=>n(r=>!r),variant:"ghost",size:"xsmall"},Dn.createElement(bS,{rotated:o},Dn.createElement(QN,{size:12,color:"gray"}))),footer:Dn.createElement(ES,{open:o},Dn.createElement(Ha,{variant:"body",size:"xsmall",color:"neutral700"},e.detailedMessage.content))})}i(IS,"FailedAlert");import{i18n as AS}from"@lingui/core";import{Alert as Cp,Button as NS}from"@rango-dev/ui";import{PendingSwapNetworkStatus as VN}from"rango-types";import Kr from"react";function BS(t){let{switchNetworkIsAvailable:e,handleSwitchNetworkClick:o,setNetworkModal:n,message:r,showNetworkModal:a}=t;return e?Kr.createElement(Cp,{type:"warning",id:"widget-swap-details-change-network-alert",title:r.shortMessage,action:Kr.createElement(NS,{id:"widget-swap-details-warning-alert-change-network-btn",size:"xxsmall",type:"warning",onClick:()=>{n("switchNetwork"),o()}},AS.t("Change"))}):a===VN.WaitingForConnectingWallet?Kr.createElement(Cp,{type:"warning",title:r.shortMessage,id:"widget-swap-details-warning-alert-connect-wallet-alert",action:Kr.createElement(NS,{id:"widget-swap-details-warning-alert-connect-wallet-btn",size:"xxsmall",type:"warning",onClick:()=>{n("connectWallet")}},AS.t("Connect"))}):Kr.createElement(Cp,{id:"widget-swap-details-short-alert",type:"warning",title:r.shortMessage})}i(BS,"WarningAlert");function Tp(t){let{switchNetworkIsAvailable:e,handleSwitchNetworkClick:o,showNetworkModal:n,setNetworkModal:r,message:a,step:s,hasAlreadyProceededToSign:c}=t,l=cr(s),p=s.status==="waitingForApproval"&&!l,u=s.status==="running"&&!l,m=u&&!c||p&&!s.explorerUrl?.length;return Eo.createElement(xS,null,s.explorerUrl?.map((f,h,g)=>{let d=h+f.url,S=h===g.length-1,y=(S&&u||p)&&!m,C=S&&s.status==="failed";return Eo.createElement(YN,{key:d},Eo.createElement(WS,{id:"widget-swap-details-tx-alert",type:S&&(y&&"loading"||C&&"error")||"success",title:f.description?`${f.description} Tx`:KN.t("View transaction"),action:f.url&&Eo.createElement(jN,{id:"widget-swap-details-tx-link-icon-btn",variant:"ghost",size:"xsmall",onClick:()=>window.open(f.url,"_blank")},Eo.createElement(XN,{size:12}))}))}),m&&Eo.createElement(WS,{id:"widget-swap-details-loading-alert",type:"loading",title:a.shortMessage}),s.status!=="failed"&&l&&Eo.createElement(BS,{switchNetworkIsAvailable:e,handleSwitchNetworkClick:o,showNetworkModal:n,setNetworkModal:r,message:a}),s.status==="failed"&&Eo.createElement(IS,{message:a}))}i(Tp,"SwapDetailsAlerts");var MS=2e3;var LS=i(({swap:t,blockchains:e,swappers:o,...n})=>{let r=t.hasAlreadyProceededToSign!==!1;return t.steps.map((a,s)=>{let c=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:ht(a.fromBlockchain,e)??"",image:a.fromBlockchainLogo??""},price:{value:P(c,6,6),realValue:c??""}},to:{token:{displayName:a.toSymbol,image:a.toLogo},chain:{displayName:ht(a.toBlockchain,e)??"",image:a.toBlockchainLogo??""},price:{value:P(a.outputAmount||a.expectedOutputAmountHumanReadable,6,6),realValue:a.outputAmount||a.expectedOutputAmountHumanReadable||""}},swapper:{displayName:Hn(a.swapperId,o)??"",image:a.swapperLogo??"",type:a.swapperType},internalSwaps:a.internalSwaps?a.internalSwaps.map(l=>({from:{chain:{displayName:ht(l.fromBlockchain,e)??"",image:l.fromBlockchainLogo??""}},to:{chain:{displayName:ht(l.toBlockchain,e)??"",image:l.toBlockchainLogo??""}},swapper:{displayName:Hn(l.swapperId,o)??"",image:l.swapperLogo??"",type:l.swapperType}})):[],alerts:ZN.createElement(Tp,{step:a,hasAlreadyProceededToSign:r,...n})}})},"getSteps");function PS(t){if(cr(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(PS,"getStepState");function $S(t){let{requestId:e}=t,[o,n]=o0(MS);return Bt.createElement(hS,{className:Zo()},Bt.createElement(DS,{variant:"label",size:"large",color:"neutral700"},Qa.t("Request ID")),Bt.createElement("div",{className:za()},Bt.createElement(DS,{variant:"label",size:"small",color:"neutral700"},e),Bt.createElement(_S,{container:B(),content:o?Qa.t("Copied To Clipboard"):Qa.t("Copy Request ID"),open:o||void 0,side:"bottom",alignOffset:-16,align:"end"},Bt.createElement(e0,{id:"widget-swap-details-done-copy-icon-btn",variant:"ghost",onClick:n.bind(null,e||"")},o?Bt.createElement(RN,{size:16,color:"secondary"}):Bt.createElement(JN,{size:16,color:"gray"}))),Bt.createElement(wS,{target:"_blank",href:`${eu}/swap/${e}`},Bt.createElement(_S,{container:B(),content:Qa.t("View on Rango Explorer"),side:"bottom"},Bt.createElement(t0,{size:20})))))}i($S,"RequestIdRow");import{i18n as FS}from"@lingui/core";import{Typography as OS}from"@rango-dev/ui";import kp from"react";function US(t){let{date:e,isFinished:o}=t;return kp.createElement("div",{className:Zo()},kp.createElement(OS,{variant:"label",size:"large",color:"neutral700"},o?FS.t("Finished at"):FS.t("Created at")),kp.createElement(OS,{variant:"label",size:"small",color:"neutral700"},e))}i(US,"SwapDateRow");var u0=3e3;function bp(t){let{swap:e,requestId:o,onDelete:n,onCancel:r}=t,{canSwitchNetworkTo:a,connect:s,getWalletInfo:c}=c0(),l=T().blockchains(),p=T().swappers(),{findToken:u}=T(),m=z().use.retry(),f=p0(),h=xp(null),[g,d]=qa(!1),[S,y]=qa(null),[C,k]=qa(null),[w,x]=qa(null),I=xp(S),A=xp(C),b=Be.use.getNotifications(),E=Be.use.removeNotification(),v=b(),N=r0(e),M=N?.networkStatus,F=i(Le=>{d(!0),y(Le)},"handleChangeModalState"),H=i(()=>{d(!1)},"handleCloseModal"),X=i(()=>{k({type:"loading",title:zt.t("Change Network"),description:`We\u2019re switching the connected network to ${Y?.network}. Please check your wallet.`})},"handleShowSwitchNetworkLoading"),J=i(()=>{k({type:"success",title:zt.t("Network Changed"),description:"The network has been successfully changed."})},"handleShowSwitchNetworkSucceeded"),W=i(Le=>{k({type:"error",title:zt.t("Network Switch Failed"),description:Le?.message||se.detailedMessage.content})},"handleShowSwitchNetworkFailed"),Z=Xd(e),Y=N?n0(e,N):null,ce=N?i0(e,N):null,fe=Xy(e),at=Yd(e),ue=i(Le=>!!c(Le)?.mobileWallet,"checkIsMobileWallet"),wt=!!M&&[$n.WaitingForNetworkChange,$n.NetworkChangeFailed].includes(M),gt=!!ce?.walletType&&ue(ce.walletType),Wt=!!ce&&!!Y&&a(ce.walletType,Y.network,Y),D=!!Y&&wt&&(gt||Wt),U=i(()=>{D&&(X(),s(ce.walletType,[{namespace:Y.namespace,network:Y.network}]).then(()=>{J()}).catch(Le=>{W(Le)}))},"handleSwitchNetwork"),G=i(()=>{F("switchNetwork"),U()},"handleSwitchNetworkClick"),se=jd(e,N,c),Q=LS({swap:e,switchNetworkIsAvailable:D,handleSwitchNetworkClick:G,showNetworkModal:M,setNetworkModal:F,message:se,blockchains:l,swappers:p}),j=Q.length,[K,Ie]=[e.steps[0],e.steps[j-1]],Ae=Ie?.outputAmount||Ie?.expectedOutputAmountHumanReadable,Ke=e.steps.reduce((Le,Lt)=>Le+parseFloat(Lt.feeInUsd||""),0),Mt=e.steps.find(Le=>Le.diagnosisUrl)?.diagnosisUrl,so=P(parseFloat(Ae||"0")*(Ie?.toUsdPrice||0),4,4),Io=P(parseFloat(e.inputAmount)*(K?.fromUsdPrice||0),4,4),Un=Ae?new HS(Ae).multipliedBy(Ie.toUsdPrice||0).toString():"",Yr=new HS(e.inputAmount).multipliedBy(K?.fromUsdPrice||0).toString(),ts=jt(Io,so),os=se.detailedMessage.content||se.shortMessage,kC=e.status==="success"?zt.t({id:"You have received {amount} {token} in {conciseAddress} wallet on {chain} chain.",values:{amount:P(Ae,6,6),token:Q[j-1]?.to.token.displayName,conciseAddress:lo(e.wallets[Q[j-1]?.to.chain.displayName||""]?.address||""),chain:Q[j-1]?.to.chain.displayName}}):ke.createElement(vS,null,ke.createElement(wp,{variant:"body",size:"medium",color:"neutral700",align:"center"},os?"":zt.t("Transaction was not sent."),Z?`${zt.t({id:"{amount} {symbol} on {blockchain} remains in your wallet.",values:{amount:Z.outputAmount,symbol:Z.symbol,blockchain:Z.blockchain}})}`:""),os&&ke.createElement(Ha,{align:"center",variant:"body",size:"medium",color:"neutral700"},ke.createElement("b",null,"Reason:")," ",os));return vp(()=>{v.find(Lt=>Lt.requestId===e.requestId)&&(e.status==="success"||e.status==="failed"?(x(e.status),E(e.requestId),H()):w&&x(null))},[e.status,e.requestId]),vp(()=>{if(D){if(F("switchNetwork"),M===$n.WaitingForNetworkChange){X();return}if(M===$n.NetworkChangeFailed){W();return}return}if(M===$n.WaitingForConnectingWallet){F("connectWallet");return}if(M===$n.NetworkChanged){F("switchNetwork"),J();return}S&&["connectWallet","switchNetwork"].includes(S)&&H()},[M]),vp(()=>{if(I.current=S,A.current=C,S==="switchNetwork"&&C?.type==="success"){let Le=setTimeout(()=>{I.current==="switchNetwork"&&A.current?.type==="success"&&H()},u0);return()=>clearTimeout(Le)}},[S,C]),ke.createElement(ie,{header:{title:zt.t("Swap Details"),onCancel:e.status==="running"?()=>F("cancel"):void 0,suffix:e.status!=="running"&&ke.createElement(fo,null,ke.createElement(zS,{id:"widget-swap-details-delete-btn",variant:"ghost",type:"error",size:"xsmall",onClick:()=>F("delete")},ke.createElement(wp,{size:"medium",variant:"label",color:"error"},zt.t("Delete"))))},footer:at&&!w&&ke.createElement(zS,{fullWidth:!0,id:"widget-swap-details-try-again-btn",variant:"contained",type:"primary",size:"large",onClick:()=>{let Le=Ii(e,l,u);m(Le),setTimeout(()=>{f("../../")},0)}},zt.t("Try again"))},ke.createElement(fS,{compact:!0,ref:h},ke.createElement($S,{requestId:o}),ke.createElement(US,{date:fe,isFinished:!!e.finishTime}),ke.createElement("div",{className:TS()},ke.createElement(s0,{fee:P(String(Ke),2,2),time:qn(ai(e.steps)),steps:j}),ke.createElement(Sr,{from:{price:{value:P(e.inputAmount,6,6),usdValue:Io,realUsdValue:Yr,realValue:e.inputAmount},token:{displayName:Q[0]?.from.token.displayName||"",image:Q[0]?.from.token.image},chain:{image:Q[0]?.from.chain.image,displayName:Q[0]?.from.chain.displayName||""}},to:{price:{value:P(Ae,6,6),usdValue:so,realUsdValue:Un,realValue:Ae||""},token:{displayName:Q[j-1]?.to.token.displayName||"",image:Q[j-1]?.to.token.image},chain:{image:Q[j-1]?.to.chain.image,displayName:Q[j-1]?.to.chain.displayName||""}},percentageChange:P(ts,2,2),warningLevel:Xt(ts??0)})),ke.createElement("div",{className:kS()},ke.createElement(wp,{variant:"title",size:"small"},zt.t("Swaps steps"))),ke.createElement(a0,{size:8}),ke.createElement(yS,null,Q.map((Le,Lt)=>{let Fp=Lt,zn=e.steps[Lt]&&PS(e.steps[Lt]),wC=zn==="error"||zn==="in-progress"||zn==="warning"||zn==="completed"&&Lt===Q.length-1;return ke.createElement(l0,{className:"widget-swap-details-step-item-container",key:Fp,step:Le,type:"swap-progress",ref:h,state:zn,hasSeparator:Lt!==0,tabIndex:Fp,isFocused:wC,tooltipContainer:B()})}))),ke.createElement(gp,{isOpen:g,state:S,switchNetworkModalState:C,onClose:H,onCancel:r,onDelete:n,message:se.detailedMessage.content,swap:e,handleSwitchNetwork:G}),ke.createElement(yp,{open:!!w,diagnosisUrl:Mt,onClose:()=>x(null),status:e.status==="success"?"success":"failed",priceValue:P(Ae,6,6),usdValue:so,realUsdValue:Un,realValue:Ae||"",percentageChange:P(ts,2,2),token:{displayName:Q[j-1]?.to.token.displayName||"",image:Q[j-1]?.to.token.image},chain:{image:Q[j-1]?.to.chain.image},description:kC}))}i(bp,"SwapDetails");import{i18n as Va}from"@lingui/core";import{Divider as GS,NotFound as h0,Skeleton as Xr,Typography as Ka}from"@rango-dev/ui";import Ee from"react";import{i18n as d0}from"@lingui/core";import{Divider as m0,Skeleton as f0,Typography as g0}from"@rango-dev/ui";import be from"react";import{css as Ht,styled as Ep}from"@rango-dev/ui";var QS=Ep("div",{width:"100%",height:"100%",padding:"$10 $20"}),jr=Ep("div",{backgroundColor:"$neutral100",borderRadius:"$xm",padding:"$10 $15"}),Ga=Ep("div",{width:"0px",height:"$20",borderLeft:"1px dashed $neutral700",marginLeft:"25px"}),Z7=Ht({display:"flex",justifyContent:"space-between",alignItems:"center"}),J7=Ht({paddingTop:"$15",display:"flex"}),R7=Ht({padding:"$15 $0"}),e9=Ht({width:"0px",height:"$16",borderLeft:"1px solid $neutral400",marginLeft:"13px"}),t9=Ht({paddingBottom:"$10"}),o9=Ht({display:"flex",justifyContent:"start",alignItems:"center"}),n9=Ht({paddingTop:"$5",display:"flex",alignItems:"center"}),r9=Ht({display:"flex",alignItems:"center"}),i9=Ht({padding:"$4 $6",display:"flex",justifyContent:"center",alignItems:"center"}),qS=Ht({display:"flex",paddingTop:"$10",paddingBottom:"$5"});function Ip(){return be.createElement(QS,null,be.createElement(kr,{type:"swap-preview"}),be.createElement("div",{className:"swaps-steps"},be.createElement(g0,{variant:"title",size:"small"},d0.t("Swaps steps"))),be.createElement(be.Fragment,null,be.createElement(jr,null,be.createElement(Ft,{separator:!1}),be.createElement("div",{className:qS()},be.createElement(m0,{direction:"horizontal",size:20}),be.createElement(f0,{height:22,variant:"rectangular"}))),be.createElement(Ga,null),be.createElement(jr,null,be.createElement(Ft,{separator:!1})),be.createElement(Ga,null),be.createElement(jr,null,be.createElement(Ft,{separator:!1})),be.createElement(Ga,null),be.createElement(jr,null,be.createElement(Ft,{separator:!1}))))}i(Ip,"LoadingSwapDetails");function VS(t){let{requestId:e,showSkeleton:o}=t;return Ee.createElement(ie,{header:{title:Va.t("Swap Details"),suffix:Ee.createElement(fo,null)}},o&&Ee.createElement(gS,null,Ee.createElement("div",{className:Zo()},Ee.createElement(Ka,{variant:"label",size:"large",color:"neutral700"},`${Va.t("Request ID")}`),Ee.createElement("div",{className:za()},Ee.createElement(Ka,{variant:"label",size:"small",color:"neutral700"},Ee.createElement(Xr,{width:60,height:10,variant:"rounded"})),Ee.createElement(GS,{direction:"horizontal",size:4}),Ee.createElement(Xr,{width:16,height:16,variant:"rectangular"}),Ee.createElement(GS,{direction:"horizontal",size:4}),Ee.createElement(Xr,{width:16,height:16,variant:"rectangular"}))),Ee.createElement("div",{className:Zo()},Ee.createElement(Ka,{className:CS(),variant:"label",size:"large",color:"neutral700"},Ee.createElement(Xr,{width:60,height:10,variant:"rounded"})),Ee.createElement(Ka,{variant:"label",size:"small",color:"neutral700"},Ee.createElement(Xr,{width:60,height:10,variant:"rounded"}))),Ee.createElement(Ip,null)),!o&&Ee.createElement(SS,null,Ee.createElement(h0,{title:Va.t("Not found"),description:Va.t({id:"Swap with request ID = {requestId} not found.",values:{requestId:e}})})))}i(VS,"SwapDetailsPlaceholder");function KS(){let{manager:t,state:e}=C0(),o=!e.loadedFromPersistor,n=Tt(t),{requestId:r}=k0(),a=qe(),{fetchStatus:s}=T();if(!r)return Ap.createElement(T0,{containerStyles:{margin:"20px"},type:"error",title:y0.t("The request ID is necessary to display the swap details.")});let c=o||s==="loading",l=r?n.find(({swap:f})=>f.requestId===r):void 0,p=i(()=>{if(l?.id){let f=t?.get(l.id);f&&S0(f)}},"onCancel"),u=i(async()=>{if(l?.id)try{t?.deleteQueue(l.id),a()}catch(f){console.log(f)}},"onDelete"),m=l?.swap;return!m||c?Ap.createElement(VS,{requestId:r,showSkeleton:c}):Ap.createElement(bp,{swap:m,requestId:r,onCancel:p,onDelete:u})}i(KS,"SwapDetailsPage");import{i18n as jS}from"@lingui/core";import{Divider as w0,getCategoriesCount as v0,SelectableCategoryList as x0,styled as YS,Typography as b0,Wallet as E0}from"@rango-dev/ui";import Qt,{useState as XS}from"react";var I0=YS("div",{display:"flex",justifyContent:"center",alignItems:"center",columnGap:"$5",rowGap:"$10",flexWrap:"wrap",paddingTop:"$5"}),A0=YS(le,{textAlign:"center"});function ZS(){let{fetchStatus:t}=T(),[e,o]=XS("ALL"),n=T().blockchains(),{config:r}=T(),[a,s]=XS(),c=oe.use.isActiveTab(),{list:l}=vt(),p=Nu(l,n),m=v0(p)!==1,f=Bu(l,e),h=i(g=>{pu(l,r.multiWallets)||s(g)},"handleWalletItemClick");return Qt.createElement(ie,{header:{title:jS.t("Connect Wallets")}},Qt.createElement(A0,null,m&&Qt.createElement(Qt.Fragment,null,Qt.createElement(x0,{setCategory:o,category:e,blockchains:p,isLoading:t==="loading"}),Qt.createElement(w0,{size:24})),Qt.createElement(b0,{variant:"title",size:"xmedium",align:"center"},jS.t("Choose a wallet to connect.")),Qt.createElement(I0,null,f.map((g,d)=>{let S=`wallet-${d}-${g.type}`;return Qt.createElement(E0,{key:S,...g,state:g.state,container:B(),onClick:()=>h(g),isLoading:t==="loading",disabled:!c})}),Qt.createElement(ar,{id:"widget-state-full-connect-modal",wallet:a,onClose:()=>{s(void 0)}}))))}i(ZS,"WalletsPage");function JS(){return sm(),Js(),N0([{path:$.home,element:ze.createElement(fy,null)},{path:$.routes,element:ze.createElement(Cy,null)},{path:$.fromSwap,children:[{index:!0,element:ze.createElement(La,{type:"source"})},{path:$.blockchains,element:ze.createElement(Na,{type:"source"})}]},{path:$.toSwap,children:[{index:!0,element:ze.createElement(La,{type:"destination"})},{path:$.blockchains,element:ze.createElement(Na,{type:"destination"})}]},{path:$.settings,children:[{index:!0,element:ze.createElement(Ky,null)},{path:$.languages,element:ze.createElement(hy,null)},{path:$.exchanges,element:ze.createElement(Jc,{sourceType:"Exchanges"})},{path:$.bridges,element:ze.createElement(Jc,{sourceType:"Bridges"})},{path:$.customTokens,children:[{index:!0,element:ze.createElement(gh,null)},{path:$.addCustomTokens,children:[{index:!0,element:ze.createElement(af,null)},{path:$.blockchains,element:ze.createElement(Na,{hideCategory:!0,type:"custom-token"})}]}]}]},{path:$.swaps,children:[{index:!0,element:ze.createElement(_h,null)},{path:$.swapDetails,element:ze.createElement(KS,null)}]},{path:$.wallets,element:ze.createElement(ZS,null)},{path:$.confirmSwap,element:ze.createElement(Rg,null)}])}i(JS,"AppRoutes");import{useQueueManager as K0}from"@rango-dev/queue-manager-rango-preset";import{isEvmBlockchain as j0}from"rango-sdk";import{useContext as X0,useEffect as Mp,useState as pC}from"react";import{Provider as _0}from"@rango-dev/wallets-react";import ja,{createContext as D0,useEffect as nC,useMemo as $0,useRef as rC}from"react";import{useEffect as W0}from"react";import{Provider as B0}from"@rango-dev/wallets-core";function RS(t){return t.map(e=>typeof e=="string"?e:e instanceof B0?e.id:e.config.type).join("-")}i(RS,"hashProviders");function Np(t,e){let{clearConnectedWallet:o,getAvailableProviders:n,buildAndSetProviders:r}=T(),a=n();return W0(()=>{o(),r()},[RS(t??[]),e?.walletConnectProjectId,e?.walletConnectListedDesktopWalletLink]),{providers:a}}i(Np,"useWalletProviders");import{legacyFormatAddressWithNetwork as M0,legacyReadAccountAddress as eC}from"@rango-dev/wallets-core/legacy";import{Events as Fn}from"@rango-dev/wallets-react";import{isEvmBlockchain as L0}from"rango-sdk";function tC(t){let{newWalletConnected:e,disconnectWallet:o,disconnectNamespaces:n,connectedWallets:r,removeBalancesForWallet:a,blockchains:s}=T(),{onConnectWalletHandler:c,onDisconnectWalletHandler:l}=t,p=s().filter(L0).map(d=>d.name),u=i((d,S)=>{let[y,,C,k,w]=d,x={walletType:y,network:k.network??void 0,accounts:C};c.current?c.current(x):console.warn("onConnectWallet handler hasn't been set. Are you sure?");let I=ds(y,C,p,S.supportedChainNames,w.isContractWallet);I.length&&e(I,w.namespace,k.derivationPath)},"onAccountsEvent"),m=i((d,S,y,C,k)=>{if(S===Fn.ACCOUNTS){let w=Kn(k.supportedBlockchains);y&&u([d,S,y,C,k],{supportedChainNames:w})}S===Fn.PROVIDER_DISCONNECTED&&(o(d),l.current?l.current(d):console.warn("onDisconnectWallet handler hasn't been set. Are you sure?")),S===Fn.NAMESPACE_DISCONNECTED&&n(d,y)},"handleUpdatesForHub"),f=i((d,S,y,C,k)=>{if(S===Fn.ACCOUNTS){let w=Kn(k.supportedBlockchains),x=[],I=[];if(y?.forEach(b=>{let{network:E}=eC(b);p.includes(E)?x.push(b):I.push(b)}),r.filter(b=>b.walletType===d).map(b=>M0(b.address,b.chain)).length>0){if(x.length>0){let b=ds(d,x,p,w,k.isContractWallet);a(d,{chains:b.map(E=>E.chain)})}I.length>0&&a(d,{chains:I.map(b=>{let{network:E}=eC(b);return E})})}y?u([d,S,y,C,k],{supportedChainNames:w}):(o(d),l.current?l.current(d):console.warn("onDisconnectWallet handler hasn't been set. Are you sure?"))}},"handleUpdatesForLegacy"),h=i((d,S,y,C,k)=>{if(S===Fn.CONNECTED&&y){let w={walletType:d,network:C.network??void 0,accounts:C.accounts??void 0};c.current?c.current(w):console.warn("onConnectWallet handler hasn't been set. Are you sure?")}if(S===Fn.NETWORK&&y){let w={walletType:d,network:y,accounts:C.accounts??void 0};c.current?c.current(w):console.warn("onConnectWallet handler hasn't been set. Are you sure?")}},"handleUpdatesForBoth");return{handler:i((d,S,y,C,k)=>{k.isHub?m(d,S,y,C,k):f(d,S,y,C,k),h(d,S,y,C,k)},"handler")}}i(tC,"useUpdates");import{LegacyEvents as P0}from"@rango-dev/wallets-core/legacy";function oC(t,e){let[o,n,r,a,s]=e;n!==P0.PROVIDER_DISCONNECTED&&t(o,n,r,a,s)}i(oC,"propagateEvents");var Xa=D0({onConnectWallet:()=>{},onDisconnectWallet:()=>{}});function F0(t){let{updateConfig:e,updateSettings:o,fetch:n,fetchStatus:r}=T(),a=T().blockchains(),s=T().config,c={walletConnectProjectId:s?.walletConnectProjectId,trezorManifest:s?.trezorManifest,tonConnect:s.tonConnect,walletConnectListedDesktopWalletLink:t.config.__UNSTABLE_OR_INTERNAL__?.walletConnectListedDesktopWalletLink},{providers:l}=Np(s.wallets,c),p=rC(),u=rC(),{handler:m}=tC({onConnectWalletHandler:p,onDisconnectWalletHandler:u});nC(()=>{n().catch(console.log)},[]),nC(()=>{t.config&&(e(t.config),o(t.config),window.__rango={config:s,dappConfig:t.config})},[t.config,r]);let f=oe.use.isActiveTab(),h=$0(()=>({onConnectWallet:g=>{p.current=g},onDisconnectWallet:g=>{u.current=g}}),[]);return ja.createElement(Xa.Provider,{value:h},ja.createElement(_0,{allBlockChains:a,providers:l,onUpdateState:(g,d,S,y,C)=>{let k=[g,d,S,y,C];m(...k),t.onUpdateState&&oC(t.onUpdateState,k)},autoConnect:!!f,configs:{wallets:s.wallets}},t.children))}i(F0,"Main");function Ya(t){let{config:e,...o}=t;return ja.createElement(Xu,{config:e},ja.createElement(F0,{...o,config:e}))}i(Ya,"WidgetWallets");import{globalCss as O0}from"@rango-dev/ui";var iC=i(()=>O0({"@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");import{useWallets as U0}from"@rango-dev/wallets-react";import{useEffect as z0,useRef as H0}from"react";function aC(){let{connect:t,state:e}=U0(),o=H0({}),{fetchStatus:n}=T(),r=new URLSearchParams(location.search).get("autoConnect")||"",a=e(r);z0(()=>{n==="success"&&r&&a.installed&&!a.connecting&&!a.connected&&!o.current[r]&&(o.current[r]=!0,t(r))},[a,n])}i(aC,"useForceAutoConnect");import{isApprovalTX as Q0,RouteEventType as sC,StepEventType as lC,StepExecutionEventStatus as q0,WidgetEvents as Za}from"@rango-dev/queue-manager-rango-preset";import{useEffect as cC}from"react";function Bp(){let t=Be.use.setNotification(),{connectedWallets:e,fetchBalances:o,customTokens:n}=T();cC(()=>{let r=i(a=>{let{event:s,step:c,route:l}=a;if(s.type===lC.TX_EXECUTION&&s.status===q0.TX_SENT&&!Q0(c)||s.type===lC.SUCCEEDED){let u=[],m=l.wallets[c?.fromBlockchain];if(m){let f=e.find(h=>h.address?.toLocaleLowerCase()===m.address?.toLocaleLowerCase()&&h.walletType===m.walletType&&h.chain===c?.fromBlockchain);f&&u.push(f)}if(c?.fromBlockchain!==c?.toBlockchain){let f=l.wallets[c?.toBlockchain];if(f){let h=e.find(g=>g.address?.toLocaleLowerCase()===f.address?.toLocaleLowerCase()&&g.walletType===f.walletType&&g.chain===c?.toBlockchain);h&&u.push(h)}}if(u.length>0){let f=n(),g=[{blockchain:c.fromBlockchain,address:c.fromSymbolAddress,symbol:c.fromSymbol},{blockchain:c.toBlockchain,address:c.toSymbolAddress,symbol:c.toSymbol}].filter(d=>f.some(S=>S.blockchain===d.blockchain&&S.address?.toLocaleLowerCase()===d.address?.toLocaleLowerCase()&&S.symbol?.toLocaleLowerCase()===d.symbol?.toLocaleLowerCase()));o(u,{selectedCustomTokens:g,shouldFetchCustomTokens:g.length>0})}}t(s,l)},"handleStepEvent");return we.on(Za.StepEvent,r),()=>we.off(Za.StepEvent,r)},[we,e]),cC(()=>{let r=i(a=>{let{event:s,route:c}=a;(s.type===sC.FAILED||s.type===sC.SUCCEEDED)&&t(s,c)},"handleRouteEvent");return we.on(Za.RouteEvent,r),()=>we.off(Za.RouteEvent,r)},[we])}i(Bp,"useSubscribeToWidgetEvents");import{useManager as G0}from"@rango-dev/queue-manager-react";import{useEffect as V0}from"react";function Wp(){let{isSynced:t,syncNotifications:e}=Be(),{manager:o,state:n}=G0();V0(()=>{Be.persist.hasHydrated()&&n.loadedFromPersistor&&!t&&e(Tt(o))},[Be.persist.hasHydrated(),n.loadedFromPersistor,t])}i(Wp,"useSyncNotifications");function Lp(){aC(),iC(),Bp(),Wp();let t=T().blockchains(),{canSwitchNetworkTo:e}=Xi(),[o,n]=pC(null),[r,a]=pC(),s=X0(Xa),c=t.filter(j0);Mp(()=>()=>im(),[]),Mp(()=>()=>am(),[]),K0({lastConnectedWallet:o,clearDisconnectedWallet:()=>{a(void 0)},disconnectedWallet:r,evmChains:c,canSwitchNetworkTo:e}),Mp(()=>(Po.init(),Be.persist.hasHydrated()||Be.persist.rehydrate(),s.onConnectWallet(l=>{n(p=>{if(!p||p.walletType!==l.walletType)return l;let u={...p};return l.network&&(u.network=l.network),l.accounts&&(u.accounts=l.accounts),u})}),s.onDisconnectWallet(l=>{a(l),n(p=>l===p?.walletType?null:p)}),Po.destroy),[])}i(Lp,"useBootstrap");import{styled as Y0}from"@rango-dev/ui";var uC=Y0("div",{fontFamily:"$widget",boxSizing:"border-box",textAlign:"left",height:"100%","& *, *::before, *::after":{boxSizing:"inherit"},"& *:focus-visible":{outlineColor:"$info500",transition:"none"},"& ul, ol, li":{listStyleType:"none"}});function Jo(){Lp();let{config:t}=T(),{activeTheme:e}=mo(t?.theme||{}),{activeLanguage:o}=wo();return Pp.createElement(Z0,{language:o},Pp.createElement(uC,{id:"swap-container",className:e()},Pp.createElement(JS,null)))}i(Jo,"Main");import{setSolanaSignerConfig as yB}from"@rango-dev/signer-solana";import Dp,{useEffect as $p,useMemo as SB}from"react";function dC(){let{setWatermark:t,setShowProfileBanner:e}=oe();return{fetchApiConfig:i(async()=>{let n=await fetch(`${Gt("BASE_URL")}/meta/dapp/config?apiKey=${Gt("API_KEY")}`);if(!n.ok)throw new Error(`Request failed with status: ${n.status} `);let r=await n.json();t(r.config.watermark),e(r.config.banners.profile)},"fetchApiConfig")}}i(dC,"useFetchApiConfig");import{useState as J0}from"react";var R0=i(()=>{let[t,e]=J0(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=cu(a);if(s){let c=o(s);e(c)}},"handleLoadCustomFont")}},"useFontLoader"),mC=R0;import{checkWaitingForNetworkChange as eB,makeQueueDefinition as tB}from"@rango-dev/queue-manager-rango-preset";import{Provider as oB}from"@rango-dev/queue-manager-react";import{useWallets as nB}from"@rango-dev/wallets-react";import{convertEvmBlockchainMetaToEvmChainInfo as rB}from"@rango-dev/wallets-shared";import{isEvmBlockchain as iB}from"rango-types";import aB,{useMemo as sB}from"react";function lB(t){let{providers:e,getSigners:o,state:n,connect:r,canSwitchNetworkTo:a,getWalletInfo:s}=nB(),c=sB(()=>tB({API_KEY:t.apiKey||Gt("API_KEY"),BASE_URL:Gt("BASE_URL"),emitter:{emit:we.emit}}),[t.apiKey]),{blockchains:l,connectedWallets:p}=T(),u=l(),m={blockchains:p.map(w=>({accounts:[w],name:w.chain}))},f=i(async(w,x)=>a(w,x.network,x)?await r(w,[x]):void 0,"switchNetwork"),h=i(w=>!!s(w).mobileWallet,"isMobileWallet"),g=u.filter(w=>w.enabled).reduce((w,x)=>(w[x.name]=x,w),{}),d=u.filter(iB),S=i(w=>{let{supportedChains:x}=s(w);return Kn(x)},"getSupportedChainNames"),y=e(),C={meta:{blockchains:g,evmBasedChains:d,evmNetworkChainInfo:rB(d),getSupportedChainNames:S},getSigners:o,wallets:m,providers:y,switchNetwork:f,canSwitchNetworkTo:a,state:n,isMobileWallet:h},k=oe.use.isActiveTab();return aB.createElement(oB,{queuesDefs:[c],context:C,onPersistedDataLoaded:w=>{eB(w)},isPaused:!k},t.children)}i(lB,"QueueManager");var fC=lB;import{useManager as mB}from"@rango-dev/queue-manager-react";import fB,{createContext as gB,useContext as hB}from"react";function gC(){let{findToken:t}=T(),e=T().blockchains(),o=T().tokens(),{setFromBlockchain:n,setFromToken:r,setToBlockchain:a,setToToken:s,setInputAmount:c}=z()();return i(p=>{let{fromBlockchain:u,fromToken:m,toBlockchain:f,toToken:h,requestAmount:g}=p,d={blockchains:e,tokens:o};if(u!==void 0){let S=e.find(y=>y.name===u)??null;n(S)}if(m!==void 0){let S=m?t(m)??null:null;r({meta:d,token:S})}if(f!==void 0){let S=e.find(y=>y.name===f)??null;a(S)}if(h!==void 0){let S=h?t(h)??null:null;s({meta:d,token:S})}g!==void 0&&c(g)},"updateQuoteInputs")}i(gC,"useUpdateQuoteInputs");import{cancelSwap as cB,getCurrentNamespaceOfOrNull as pB,getCurrentStep as uB,getRelatedWalletOrNull as dB}from"@rango-dev/queue-manager-rango-preset";var Ja=class{static{i(this,"WidgetHistory")}constructor(e,o){this.manager=e,this.actions=o}getAllSwaps(){return Tt(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=Ii(e,o.blockchains,this.actions.findToken);return this.actions.retrySwap(n)}cancel(e){let o=this.manager?.get(e);o&&cB(o)}getCurrentStepInfo(e){let o=uB(e);return{step:o,wallet:o?dB(e,o):null,network:o?pB(e,o)?.network:null}}};var hC=gB(void 0);function _p(t){let{manager:e}=mB(),o=oe.use.isActiveTab(),n=z().use.retry(),{findToken:r,getBalances:a,getConnectedWalletsDetails:s,fetchBalances:c}=T(),l=new Ja(e,{retrySwap:n,findToken:r}),{fetchingWallets:p}=T(),u=vu(a()),m=T().blockchains(),f=T().tokens(),h=T().swappers(),g=T().fetchStatus,d=wo().resetLanguage,S=Be().getNotifications(),y=Be().clearNotifications,C=gC(),{fromBlockchain:k,toBlockchain:w,fromToken:x,toToken:I,inputAmount:A}=z()(),b={isActiveTab:o,setCurrentTabAsActive:Po.forceClaim,history:l,wallets:{isLoading:p,details:s(),totalBalance:u,refetch:async E=>c(E)},meta:{blockchains:m,tokens:f,swappers:h,loadingStatus:g,findToken:r},resetLanguage:d,notifications:{list:S,clearAll:y},quote:{quoteInputs:{fromBlockchain:k?.name??null,fromToken:x?{symbol:x.symbol,blockchain:x.blockchain,address:x.address}:null,toBlockchain:w?.name??null,toToken:I?{symbol:I.symbol,blockchain:I.blockchain,address:I.address}:null,requestAmount:A},updateQuoteInputs:C}};return fB.createElement(hC.Provider,{value:b},t.children)}i(_p,"WidgetInfo");function yC(){let t=hB(hC);if(!t)throw new Error("useWidget can only be used within the WidgetProvider component");return t}i(yC,"useWidget");function On(t){let{onUpdateState:e,config:o}=t,n=t.config?.theme?.fontFamily,{fetchApiConfig:r}=dC(),{handleLoadCustomFont:a}=mC();return $p(()=>{r().catch(console.log)},[]),$p(()=>{n&&a(n)},[n]),SB(()=>{Wu({API_KEY:o?.apiKey||ti,BASE_URL:o?.apiUrl||Rp})},[o.apiKey,o.apiUrl]),$p(()=>{t.config?.signers?.customSolanaRPC&&yB("customRPC",t.config.signers.customSolanaRPC)},[t.config?.signers?.customSolanaRPC]),Dp.createElement(Ya,{config:o,onUpdateState:e},Dp.createElement(fC,{apiKey:o.apiKey},Dp.createElement(_p,null,t.children)))}i(On,"WidgetProvider");function SC(t){let e=t.config?.externalWallets;return Ra.createElement(bi,null,e?Ra.createElement(Jo,null):Ra.createElement(On,{config:t.config??on},Ra.createElement(Jo,null)))}i(SC,"Refuel");import es from"react";function CC(t){let e=t.config?.externalWallets;return es.createElement(bi,null,e?es.createElement(Jo,null):es.createElement(On,{config:t.config??on},es.createElement(Jo,null)))}i(CC,"Widget");function TC(){let{on:t,off:e}=we;return{on:t,off:e}}i(TC,"useWidgetEvents");var ete={DerivationPath:nr,Namespaces:er,Detached:or,isOnDerivationPath:ir,isOnNamespace:rr,isOnDetached:Ao};export{vee as EventSeverity,sn as MainEvents,Lee as Networks,Dee as PendingSwapNetworkStatus,ys as QuoteEventTypes,SC as Refuel,xee as RouteEventType,ss as SUPPORTED_FONTS,ete as StatefulConnect,bee as StepEventType,Eee as StepExecutionBlockedEventStatus,Iee as StepExecutionEventStatus,kd as SwapModeContext,Re as UI_ID,Cs as UiEventTypes,Ss as WalletEventTypes,Wee as WalletEvents,Pee as WalletTypes,CC as Widget,sn as WidgetEvents,On as WidgetProvider,Ya as WidgetWallets,dl as customizedThemeTokens,is as pickProviderVersionWithFallbackToLegacy,Nee as readAccountAddress,Ro as useStatefulConnect,vt as useWalletList,Xi as useWallets,yC as useWidget,TC as useWidgetEvents,ET as widgetEventEmitter};
|
|
3
3
|
//# sourceMappingURL=index.js.map
|