@aori/mega-swap-widget 0.1.2 → 0.1.4

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.
Files changed (59) hide show
  1. package/README.md +31 -0
  2. package/dist/AssetSelectionMenu-KOJBN3OR.js +2 -0
  3. package/dist/AssetSelectionMenu-M7HHUUWM.cjs +2 -0
  4. package/dist/ChainSelectionMenu-EJANKMWU.cjs +2 -0
  5. package/dist/ChainSelectionMenu-YCFDREZO.js +2 -0
  6. package/dist/SwapFormHorizontal-6YSJJM2S.cjs +2 -0
  7. package/dist/SwapFormHorizontal-E32W3PHA.js +2 -0
  8. package/dist/SwapFormSplit-6Y2B4VU3.cjs +2 -0
  9. package/dist/SwapFormSplit-M4YIQNAW.js +2 -0
  10. package/dist/WidgetWalletPanel-LKFDBFYR.cjs +2 -0
  11. package/dist/WidgetWalletPanel-T5L5224H.js +2 -0
  12. package/dist/WidgetWalletTradeHistory-PZLWJ2IK.js +2 -0
  13. package/dist/WidgetWalletTradeHistory-SDYMU4HL.cjs +2 -0
  14. package/dist/chunk-3RAZPKY5.js +2 -0
  15. package/dist/chunk-4CM44UII.cjs +2 -0
  16. package/dist/chunk-52HJQZWW.cjs +2 -0
  17. package/dist/chunk-5WTODHGO.cjs +2 -0
  18. package/dist/chunk-7QJJOVSV.js +2 -0
  19. package/dist/chunk-BJYKILHS.cjs +2 -0
  20. package/dist/chunk-EXGKQSDI.cjs +2 -0
  21. package/dist/chunk-GDIG4JLQ.cjs +2 -0
  22. package/dist/chunk-JVRQLJXZ.js +2 -0
  23. package/dist/chunk-SBQ3EQ2U.js +2 -0
  24. package/dist/chunk-SE6JOLEM.cjs +27 -0
  25. package/dist/chunk-TCAVGM6Y.cjs +2 -0
  26. package/dist/chunk-VI4ISTPB.js +2 -0
  27. package/dist/chunk-ZA7N764R.js +2 -0
  28. package/dist/chunk-ZFVYFTDI.js +2 -0
  29. package/dist/chunk-ZKDVXDQF.cjs +2 -0
  30. package/dist/chunk-ZWGBVGLP.js +2 -0
  31. package/dist/chunk-ZWNDO5OZ.js +27 -0
  32. package/dist/index.cjs +2 -2
  33. package/dist/index.css +1 -1
  34. package/dist/index.d.cts +3 -1
  35. package/dist/index.d.ts +3 -1
  36. package/dist/index.js +2 -2
  37. package/package.json +1 -1
  38. package/dist/AssetSelectionMenu-4E576X3D.cjs +0 -2
  39. package/dist/AssetSelectionMenu-ZFY7XFRX.js +0 -2
  40. package/dist/ChainSelectionMenu-SKXLHK3S.js +0 -2
  41. package/dist/ChainSelectionMenu-VU3SIBVL.cjs +0 -2
  42. package/dist/SwapFormHorizontal-GI4X7ISS.js +0 -2
  43. package/dist/SwapFormHorizontal-V557YBX2.cjs +0 -2
  44. package/dist/SwapFormSplit-52RBMJIO.js +0 -2
  45. package/dist/SwapFormSplit-PQCS3BPT.cjs +0 -2
  46. package/dist/WidgetWalletPanel-XYV3YL4I.js +0 -2
  47. package/dist/WidgetWalletPanel-YBMN5KZH.cjs +0 -2
  48. package/dist/chunk-4BQRVCQR.js +0 -2
  49. package/dist/chunk-4LJJMEOG.js +0 -2
  50. package/dist/chunk-726CI6GC.js +0 -2
  51. package/dist/chunk-DUIRZSBV.cjs +0 -2
  52. package/dist/chunk-EW2OR6CJ.js +0 -27
  53. package/dist/chunk-FDQKBTWP.js +0 -2
  54. package/dist/chunk-HTWUZKYO.cjs +0 -2
  55. package/dist/chunk-LXEKOQAG.cjs +0 -27
  56. package/dist/chunk-MCT3UZTP.cjs +0 -2
  57. package/dist/chunk-UZWGYG2S.cjs +0 -2
  58. package/dist/chunk-XYF2YBR3.js +0 -2
  59. package/dist/chunk-XZRXVBSB.cjs +0 -2
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
2
+ var _chunkSE6JOLEMcjs = require('./chunk-SE6JOLEM.cjs');var _react = require('react');var h=_react.createContext.call(void 0, {apiKey:void 0,web3ConnectionType:"custom",enabledChains:[],supportedInputTokens:[],supportedOutputTokens:[],supportedInputChains:[],supportedOutputChains:[],inputSelectionSearch:!0,outputSelectionSearch:!0,showInputSelectionTokenBalances:!0,showOutputSelectionTokenBalances:!0,lockBase:!1,lockQuote:!1,disableInverting:!1,defaultSlippage:.01,widgetType:"default",tokenDisplay:"default",tokenBadgeOrientation:"left",assetMenuVariant:"default",amountInputVariant:"default",hideAmountInputSymbol:!1,swapButtonVariant:"default",swapHeaderVariant:"default",quoteLoaderVariant:"default",walletButtonEnabled:!0,hasConnectHandler:!1,customWalletUI:"builtin"});function s(){let e=_react.useContext.call(void 0, h);return _react.useMemo.call(void 0, ()=>e.widgetType==="compact"?{...e,amountInputVariant:"normal"}:e,[e])}function w(){let{availableChainIds:e}=_chunkSE6JOLEMcjs.G.call(void 0, ),{enabledChains:a,supportedInputTokens:o,supportedOutputTokens:u}=s();return _react.useMemo.call(void 0, ()=>{let t=e,r=o.length>0,p=u.length>0;if(r&&p){let i=new Set([...o.map(n=>n.chainId),...u.map(n=>n.chainId)]);t=t.filter(n=>i.has(n))}else a.length>0&&(t=t.filter(i=>a.includes(i)));return t},[e,a,o,u])}exports.a = h; exports.b = s; exports.c = w;
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ import{G as l}from"./chunk-ZWNDO5OZ.js";import{createContext as d,useContext as c,useMemo as f}from"react";var h=d({apiKey:void 0,web3ConnectionType:"custom",enabledChains:[],supportedInputTokens:[],supportedOutputTokens:[],supportedInputChains:[],supportedOutputChains:[],inputSelectionSearch:!0,outputSelectionSearch:!0,showInputSelectionTokenBalances:!0,showOutputSelectionTokenBalances:!0,lockBase:!1,lockQuote:!1,disableInverting:!1,defaultSlippage:.01,widgetType:"default",tokenDisplay:"default",tokenBadgeOrientation:"left",assetMenuVariant:"default",amountInputVariant:"default",hideAmountInputSymbol:!1,swapButtonVariant:"default",swapHeaderVariant:"default",quoteLoaderVariant:"default",walletButtonEnabled:!0,hasConnectHandler:!1,customWalletUI:"builtin"});function s(){let e=c(h);return f(()=>e.widgetType==="compact"?{...e,amountInputVariant:"normal"}:e,[e])}import{useMemo as m}from"react";function w(){let{availableChainIds:e}=l(),{enabledChains:a,supportedInputTokens:o,supportedOutputTokens:u}=s();return m(()=>{let t=e,r=o.length>0,p=u.length>0;if(r&&p){let i=new Set([...o.map(n=>n.chainId),...u.map(n=>n.chainId)]);t=t.filter(n=>i.has(n))}else a.length>0&&(t=t.filter(i=>a.includes(i)));return t},[e,a,o,u])}export{h as a,s as b,w as c};
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ import{c as g}from"./chunk-VI4ISTPB.js";import{M as p,e as c,x as m}from"./chunk-ZWNDO5OZ.js";import h,{useCallback as C,useState as b}from"react";import{jsx as o,jsxs as t}from"react/jsx-runtime";var y=({toggle:x,side:w,onChainSelect:i,onChainHover:l,containerHeight:N})=>{let[a,d]=b(""),r=m(a,300),v=g(),s=c(v),u=h.useMemo(()=>{if(!r)return s;let e=r.toLowerCase();return s.filter(n=>n.displayName.toLowerCase().includes(e)||n.name.toLowerCase().includes(e)||n.id.toString().includes(e))},[s,r]),f=C(e=>i(e),[i]);return t("div",{className:"w-full h-full flex flex-col",children:[o("div",{className:"flex-shrink-0",children:t("div",{className:"relative mt-1",children:[o("input",{className:"w-full h-10 px-4 text-sm",style:{backgroundColor:"var(--widget-card)",color:"var(--widget-card-foreground)",border:"1px solid var(--widget-border)"},placeholder:"Search chains by name or chain ID...",autoComplete:"off",value:a,onChange:e=>d(e.target.value.toLowerCase())}),a&&o("button",{type:"button",onClick:()=>d(""),className:"absolute right-2 top-1/2 -translate-y-1/2 cursor-pointer rounded-full px-2 py-1 text-xs",style:{backgroundColor:"var(--widget-secondary)",color:"var(--widget-secondary-foreground)",border:"1px solid var(--widget-border)"},children:"clear"})]})}),t("div",{className:"flex-1 min-h-0 overflow-auto mt-2",style:{backgroundColor:"var(--widget-background)"},children:[o("p",{className:"my-2 ml-4 text-xs",style:{color:"var(--widget-muted-foreground)"},children:a?"Search Results":"Available Chains"}),u.length===0?o("div",{className:"px-4 py-3 text-sm",style:{color:"var(--widget-muted-foreground)"},children:"Chain Not Found"}):u.map(e=>t("button",{type:"button",className:"w-full flex items-center justify-between p-3 cursor-pointer transition-colors",style:{borderBottom:"1px solid var(--widget-border)"},onClick:()=>f(e.id),onMouseEnter:()=>l?.(e.displayName),onMouseLeave:()=>l?.(null),children:[t("div",{className:"flex items-center space-x-3 min-w-0 flex-1",children:[o("div",{className:"flex-shrink-0",children:o(p,{chain:e.id,size:"md"})}),o("span",{className:"text-base font-medium truncate",style:{color:"var(--widget-foreground)"},children:e.displayName})]}),t("span",{className:"text-xs font-mono",style:{color:"var(--widget-muted-foreground)"},children:["Chain ID: ",e.id]})]},e.id))]})]})},M=y;export{M as a};
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ import{e as g}from"./chunk-JVRQLJXZ.js";import{f as y}from"./chunk-7QJJOVSV.js";import{b as w}from"./chunk-VI4ISTPB.js";import{N as m,V as f}from"./chunk-ZWNDO5OZ.js";import E,{useEffect as $,useState as j}from"react";import{jsx as e,jsxs as t}from"react/jsx-runtime";function x(a){if(a===0)return"0";let o=Math.abs(a);return o>=1e4?a.toFixed(0):o>=1e3?a.toFixed(1):o>=100?a.toFixed(2):o>=1?a.toFixed(4):o>=.01?a.toFixed(6):a.toExponential(3)}var N=E.memo(()=>{let[a,o]=j(!1),{liquidityError:b,routingError:h}=g(),{baseAmount:r,baseToken:s,quoteAmount:l,quoteToken:i}=y(),{quoteLoaderVariant:p,widgetType:F}=w(),u=F==="compact",n=r&&l&&parseFloat(l.toString())?parseFloat(r.toString())/parseFloat(l.toString()):0,v=b||h,c=s&&i&&r&&parseFloat(r.toString())&&l;return $(()=>{p==="expanded"&&c&&o(!0)},[p,c]),p==="none"?null:p==="default"?e("div",{className:`relative box-border flex flex-row pt-1 h-8 w-full items-center${u?" justify-start overflow-x-auto":" justify-center"}`,children:e("div",{className:`flex h-full items-center${u?" min-w-max":" w-full overflow-hidden"}`,style:{color:"var(--widget-foreground)"},children:s&&i?r&&parseFloat(r.toString())?l?t("div",{className:"translate-y-px font-mono flex flex-row items-center gap-2 whitespace-nowrap",children:[t("div",{className:"flex flex-row items-center gap-1",children:[e(m,{asset:i,size:"3xs",noChain:!0,className:"mb-0.5"}),t("span",{className:"text-xs uppercase",children:["1 ",i?.symbol]})]}),e("span",{className:"text-xs",style:{color:"var(--widget-muted-foreground)"},children:"="}),t("div",{className:"flex flex-row items-center gap-1",children:[e(m,{asset:s,size:"3xs",noChain:!0,className:"mb-0.5"}),t("span",{className:"text-xs uppercase",children:[x(n)," ",s?.symbol]})]}),e("span",{className:"text-xs",style:{color:"var(--widget-muted-foreground)"},children:s?.price?`\u2248 $${(s.price*n).toFixed(2)}`:""})]}):v?t("div",{className:"flex h-full w-full flex-row pb-1 items-center justify-between",children:[e("p",{className:"text-xs",style:{color:"var(--widget-destructive)"},children:"Quote not found"}),e(f,{className:"h-8 w-8",style:{color:"var(--widget-destructive)"}})]}):t("div",{className:"flex h-full w-full flex-row pb-1 items-center justify-between",children:[e("p",{className:"text-xs",style:{color:"var(--widget-accent)"},children:"Searching For Quote"}),e(f,{className:"h-8 w-8",style:{color:"var(--widget-accent)"}})]}):e("div",{className:"text-xs pb-1",style:{color:"var(--widget-foreground)",opacity:.4},children:"Enter Amount"}):e("div",{className:"text-xs pb-1",style:{color:"var(--widget-foreground)",opacity:.4},children:"Enter Amount"})})}):t("div",{className:"flex flex-col w-full",children:[e("div",{className:`relative box-border flex flex-row pt-1 h-8 w-full items-center cursor-pointer${u?" overflow-x-auto":""}`,role:"button",tabIndex:0,onClick:()=>c&&o(d=>!d),onKeyDown:d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),c&&o(S=>!S))},children:e("div",{className:`flex h-full items-center${u?" min-w-max overflow-x-auto":" w-full overflow-hidden"}`,style:{color:"var(--widget-foreground)"},children:s&&i?r&&parseFloat(r.toString())?l?t("div",{className:"translate-y-px font-mono flex w-full flex-row items-center justify-between",children:[t("div",{className:"flex flex-row items-center gap-2 whitespace-nowrap",children:[t("div",{className:"flex flex-row items-center gap-1",children:[e(m,{asset:i,size:"3xs",noChain:!0,className:"mb-0.5"}),t("span",{className:"text-xs uppercase",children:["1 ",i?.symbol]})]}),e("span",{className:"text-xs",style:{color:"var(--widget-muted-foreground)"},children:"="}),t("div",{className:"flex flex-row items-center gap-1",children:[e(m,{asset:s,size:"3xs",noChain:!0,className:"mb-0.5"}),t("span",{className:"text-xs uppercase",children:[x(n)," ",s?.symbol]})]}),e("span",{className:"text-xs",style:{color:"var(--widget-muted-foreground)"},children:s?.price?`\u2248 $${(s.price*n).toFixed(2)}`:""})]}),e("span",{className:"text-xs ml-2 transition-transform duration-200 shrink-0",style:{color:"var(--widget-muted-foreground)",transform:a?"rotate(180deg)":"rotate(0deg)",display:"inline-block"},children:"\u25BE"})]}):v?t("div",{className:"flex h-full w-full flex-row pb-1 items-center justify-between",children:[e("p",{className:"text-xs",style:{color:"var(--widget-destructive)"},children:"Quote not found"}),e(f,{className:"h-8 w-8",style:{color:"var(--widget-destructive)"}})]}):t("div",{className:"flex h-full w-full flex-row pb-1 items-center justify-between",children:[e("p",{className:"text-xs",style:{color:"var(--widget-accent)"},children:"Searching For Quote"}),e(f,{className:"h-8 w-8",style:{color:"var(--widget-accent)"}})]}):e("div",{className:"text-xs pb-1",style:{color:"var(--widget-foreground)",opacity:.4},children:"Enter Amount"}):e("div",{className:"text-xs pb-1",style:{color:"var(--widget-foreground)",opacity:.4},children:"Enter Amount"})})}),e("div",{className:"overflow-hidden transition-all duration-200",style:{maxHeight:a&&c?"80px":"0px",opacity:a&&c?1:0},children:t("div",{className:"flex flex-col gap-0.5 pb-1 font-mono",children:[t("div",{className:"flex justify-between text-2xs",style:{color:"var(--widget-muted-foreground)"},children:[e("span",{children:"USD Value"}),t("span",{children:["$",s?.price&&l?(s.price*n*parseFloat(l.toString())).toFixed(2):"\u2014"]})]}),t("div",{className:"flex justify-between text-2xs",style:{color:"var(--widget-muted-foreground)"},children:[e("span",{children:"Rate"}),e("span",{className:"uppercase",children:n>0?`${x(n)} ${s?.symbol??""}`:"\u2014"})]}),t("div",{className:"flex justify-between text-2xs",style:{color:"var(--widget-muted-foreground)"},children:[e("span",{children:"Order Type"}),e("span",{children:"RFQ (Exact Fill)"})]})]})})]})});N.displayName="QuoteLoader";var R=N;export{R as a};
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
2
+ var _chunkBJYKILHScjs = require('./chunk-BJYKILHS.cjs');var _chunkTCAVGM6Ycjs = require('./chunk-TCAVGM6Y.cjs');var _react = require('react');function m(){let{supportedInputTokens:t,supportedOutputTokens:n,supportedInputChains:o,supportedOutputChains:u}=_chunkTCAVGM6Ycjs.b.call(void 0, ),e=_chunkBJYKILHScjs.c.call(void 0, i=>i.isInverted);return _react.useMemo.call(void 0, ()=>({effectiveInputTokens:e?n:t,effectiveOutputTokens:e?t:n,effectiveInputChains:e?u:o,effectiveOutputChains:e?o:u}),[e,t,n,o,u])}exports.a = m;
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ import{a as le}from"./chunk-SBQ3EQ2U.js";import{c as g,f as ie}from"./chunk-7QJJOVSV.js";import{b as K,c as re}from"./chunk-VI4ISTPB.js";import{D as ee,E as se,F as te,J as ae,M as ne,N as A,e as J,i as N,u as x,v as X,x as Z}from"./chunk-ZWNDO5OZ.js";import{a as oe}from"./chunk-46H44R7V.js";import L,{useCallback as de,useEffect as Ae,useMemo as $}from"react";import{useShallow as Te}from"zustand/react/shallow";import Ne from"react";import{jsx as C,jsxs as T}from"react/jsx-runtime";var G=Ne.memo(({asset:o,otherAsset:i,handleFormSelection:c,getToken:_})=>{let{token:w}=te(o.chainId,o.address),S=_(o.chainId,o.address),a=w||S||o.assetInfo;if(!a)return null;let p=a.price!=null&&o.decimals!==void 0?x(a,o.balance,o.decimals):null;return T("button",{type:"button",className:"w-full flex items-center justify-between p-3 cursor-pointer",style:{borderBottom:"1px solid var(--widget-border)"},onClick:()=>c(a,i),children:[T("div",{className:"flex items-center space-x-3 min-w-0 flex-1",children:[C(A,{asset:a,size:"md",className:"flex-shrink-0"}),T("div",{className:"flex flex-col items-start min-w-0 flex-1",children:[C("span",{className:"text-base font-medium",style:{color:"var(--widget-foreground)"},children:a.symbol.length>20?`${a.symbol.substring(0,20)}...`:a.symbol}),C("span",{className:"text-sm",style:{color:"var(--widget-foreground)",opacity:.6},children:a.name.length>20?`${a.name.substring(0,20)}...`:a.name})]})]}),T("div",{className:"flex flex-col items-end text-right flex-shrink-0",children:[C("span",{className:"text-xs font-mono",style:{color:"var(--widget-foreground)",opacity:.5},children:"Balance:"}),C("span",{className:"text-xs font-mono",style:{color:"var(--widget-foreground)"},children:p!=null?`$${p.toFixed(2)}`:"\u2014"})]})]},`${a.chainId}-${a.address}`)},(o,i)=>o.asset.address===i.asset.address&&o.asset.chainId===i.asset.chainId&&o.asset.balance===i.asset.balance&&o.asset.assetInfo?.price===i.asset.assetInfo?.price&&o.otherAsset.address===i.otherAsset.address);G.displayName="AssetSelectionBalanceItem";import{jsx as n,jsxs as f}from"react/jsx-runtime";var Le=({toggle:o,side:i,otherAsset:c,containerHeight:_,onChainHover:w,onMoreChainsClick:S,selectedChainFilter:a})=>{let{address:W}=oe(),{assetSelectionSearch:p,assetSelectionChain:u,assetSelectionCategory:ce,recentChainIds:q}=g(Te(e=>({assetSelectionSearch:e.assetSelectionSearch,assetSelectionChain:e.assetSelectionChain,assetSelectionCategory:e.assetSelectionCategory,recentChainIds:e.recentChainIds}))),B=Z(p,300),y=re(),{inputSelectionSearch:ue,outputSelectionSearch:me,showInputSelectionTokenBalances:fe,showOutputSelectionTokenBalances:pe}=K(),{effectiveInputTokens:ge,effectiveOutputTokens:he,effectiveInputChains:we,effectiveOutputChains:be}=le(),ye=i==="base"?ue:me,ve=i==="base"?fe:pe,{setBaseToken:V,setQuoteToken:j}=ie(),v=i==="base"?ge:he,b=i==="base"?we:be,M=b.length===1,I=$(()=>{if(v.length===0)return null;let e=new Set;for(let s of v)e.add(`${s.chainId}-${s.address.toLowerCase()}`);return e},[v]);Ae(()=>{M?g.getState().setAssetSelectionChain(b[0]):a&&g.getState().setAssetSelectionChain(a)},[a,M,b]);let Ie=L.useMemo(()=>{let r=b.length>0?new Set(b):null,t=J(y).filter(l=>!r||r.has(l.id)).map(l=>({chainId:l.id,name:l.displayName})),d=new Map(t.map(l=>[l.chainId,l])),m=[],h=new Set,U=d.get(4326);U&&(m.push(U),h.add(4326));for(let l of q){if(m.length>=5)break;if(h.has(l))continue;let Y=d.get(l);Y&&(m.push(Y),h.add(l))}for(let l of t){if(m.length>=5)break;h.has(l.chainId)||m.push(l)}return m},[y,q,b]),{enrichedTokens:D,isLoading:xe}=se(u==="all"?"all":u),{tokenRegistry:O,getToken:E}=ee(),Ce=$(()=>{let e=new Set;for(let s of O)e.add(`${s.chainId}-${s.address.toLowerCase()}`);return e},[O]),R=$(()=>I?D.filter(e=>I.has(`${e.chainId}-${e.address.toLowerCase()}`)):D,[D,I]),F=$(()=>c?R.filter(e=>!(e.chainId===c.chainId&&e.address.toLowerCase()===c.address.toLowerCase())):R,[R,c]),H=L.useMemo(()=>{if(!B)return F;let e=B.toLowerCase();return F.filter(s=>(s.symbol||"").toLowerCase().includes(e)||(s.name||"").toLowerCase().includes(e)||s.address.toLowerCase().includes(e))},[F,B]),P=L.useMemo(()=>{let e=u==="all"?(H||[]).filter(t=>y.includes(t.chainId)):H||[],s=new Set;return[...e.filter(t=>{let d=`${t.chainId}-${t.address.toLowerCase()}`;return s.has(d)?!1:(s.add(d),!0)})].sort((t,d)=>{let m=N(t),h=N(d);return m&&!h?-1:!m&&h?1:t.marketCap&&!d.marketCap?-1:!t.marketCap&&d.marketCap?1:!t.marketCap&&!d.marketCap?0:d.marketCap-t.marketCap})},[H,u,y]),{balances:k,isLoading:Se}=ae(W,y,void 0,v.length>0?v:void 0),Q=L.useMemo(()=>{if(!k)return[];let e=u==="all"?k:k.filter(r=>r.chainId===u),s=new Set;return e.filter(r=>{let t=`${r.chainId}-${(r.address||"").toLowerCase()}`;return s.has(t)?!1:(s.add(t),!0)})},[k,u]),ke=de(e=>{let s=e.target.value.toLowerCase(),r=X(s),t=g.getState();r?(t.setAssetSelectionSearch(r),t.setAssetSelectionAddressInput(r)):(t.setAssetSelectionAddressInput(""),t.setAssetSelectionSearch(s))},[]),z=de(async e=>{i==="base"?await V(e):i==="quote"&&await j(e),o()},[o,i,V,j]);return f("div",{className:"w-full h-full flex flex-col pt-2.5",children:[!M&&f("div",{className:"flex flex-row justify-between py-1 flex-shrink-0 h-10",children:[n("button",{type:"button",className:"flex flex-row items-center w-full h-full px-2.5 whitespace-nowrap font-bold uppercase text-xs cursor-pointer",style:{backgroundColor:u==="all"&&!a?"var(--widget-primary)":"var(--widget-secondary)",color:u==="all"&&!a?"var(--widget-primary-foreground)":"var(--widget-secondary-foreground)",border:"1px solid var(--widget-border)",borderRadius:"var(--widget-radius) 0 0 var(--widget-radius)"},onClick:e=>{e.stopPropagation(),g.getState().setAssetSelectionChain("all")},onMouseEnter:()=>w?.("All Chains"),onMouseLeave:()=>w?.(null),children:"All"}),Ie.map((e,s)=>n("button",{type:"button",className:"flex items-center justify-center px-2 w-full cursor-pointer",style:{backgroundColor:u===e.chainId?"var(--widget-primary)":"var(--widget-secondary)",color:u===e.chainId?"var(--widget-primary-foreground)":"var(--widget-secondary-foreground)",borderTop:"1px solid var(--widget-border)",borderBottom:"1px solid var(--widget-border)",borderLeft:s===0?"none":"1px solid var(--widget-border)",borderRight:"1px solid var(--widget-border)"},onClick:r=>{r.stopPropagation(),g.getState().setAssetSelectionChain(e.chainId)},onMouseEnter:()=>w?.(e.name),onMouseLeave:()=>w?.(null),children:n("div",{className:"mb-px h-4 w-4",children:n(ne,{chain:e.chainId,size:"xs"})})},e.chainId)),S&&n("button",{type:"button",className:"flex flex-row cursor-pointer items-center w-full h-full px-2.5 whitespace-nowrap uppercase font-bold text-xs",style:{backgroundColor:"var(--widget-secondary)",color:"var(--widget-secondary-foreground)",border:"1px solid var(--widget-border)",borderRadius:"0 var(--widget-radius) var(--widget-radius) 0"},onClick:e=>{e.stopPropagation(),S()},children:"More"})]}),ye&&n("div",{className:"flex-shrink-0",children:f("div",{className:"relative mt-1",children:[n("input",{className:"w-full h-10 px-4 text-sm",style:{backgroundColor:"var(--widget-card)",color:"var(--widget-card-foreground)",border:"1px solid var(--widget-border)"},placeholder:"Search tokens by name, symbol, or address...",autoComplete:"off",value:p,onChange:ke}),p&&n("button",{type:"button",onClick:()=>g.getState().setAssetSelectionSearch(""),className:"absolute right-2 top-1/2 -translate-y-1/2 cursor-pointer rounded-full px-2 py-1 text-xs",style:{backgroundColor:"var(--widget-secondary)",color:"var(--widget-secondary-foreground)",border:"1px solid var(--widget-border)"},children:"clear"})]})}),f("div",{className:"flex-1 min-h-0 overflow-auto mt-2",style:{backgroundColor:"var(--widget-background)"},children:[ve&&!Se&&Q.length>0&&!p&&ce==="all"&&f("div",{children:[n("p",{className:"my-1 ml-4 text-xs",style:{color:"var(--widget-muted-foreground)"},children:"Your Tokens"}),Q.filter(e=>!e.assetInfo||c&&e.assetInfo.chainId===c.chainId&&e.assetInfo.address.toLowerCase()===c.address.toLowerCase()?!1:I?I.has(`${e.assetInfo.chainId}-${e.assetInfo.address.toLowerCase()}`):N(e.assetInfo)||Ce.has(`${e.assetInfo.chainId}-${e.assetInfo.address.toLowerCase()}`)).sort((e,s)=>{let r=E(e.chainId,e.address)||e.assetInfo,t=E(s.chainId,s.address)||s.assetInfo,d=r&&e.decimals!==void 0?x(r,e.balance,e.decimals):0;return(t&&s.decimals!==void 0?x(t,s.balance,s.decimals):0)-d}).map(e=>!e.assetInfo||!c?null:n(G,{asset:e,otherAsset:c,handleFormSelection:z,getToken:E},`${e.assetInfo.chainId}-${e.assetInfo.address}`))]}),n("p",{className:"my-2 ml-4 text-xs",style:{color:"var(--widget-muted-foreground)"},children:p?"Search Results":"Supported Tokens"}),xe?n("div",{className:"flex items-center justify-center p-8",children:n("span",{style:{color:"var(--widget-muted-foreground)"},children:"Loading tokens..."})}):P.length===0?n("div",{className:"px-4 py-3 text-sm",style:{color:"var(--widget-muted-foreground)"},children:"Token Not Found"}):P.map(e=>f("div",{role:"button",tabIndex:0,className:"w-full flex items-center justify-between p-3 cursor-pointer",style:{borderBottom:"1px solid var(--widget-border)"},onClick:()=>z(e),onKeyDown:s=>{(s.key==="Enter"||s.key===" ")&&(s.preventDefault(),z(e))},children:[f("div",{className:"flex items-center space-x-3 min-w-0 flex-1",children:[n(A,{asset:e,size:"md",className:"flex-shrink-0"}),f("div",{className:"flex flex-col items-start min-w-0 flex-1",children:[n("span",{className:"text-base font-medium truncate",style:{color:"var(--widget-foreground)"},children:(e.symbol||"").length>20?`${e.symbol.substring(0,20)}...`:e.symbol||"\u2014"}),n("span",{className:"text-sm truncate",style:{color:"var(--widget-muted-foreground)"},children:(e.name||"").length>20?`${e.name.substring(0,20)}...`:e.name||"\u2014"})]})]}),f("div",{className:"flex flex-col items-end text-right flex-shrink-0",children:[n("span",{className:"text-xs font-mono",style:{color:"var(--widget-foreground)"},children:e.price?`$${e.price>=999999?`${(e.price/1e6).toFixed(2)}M`:e.price.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:e.price<1?5:2})}`:"\u2014"}),f("span",{className:"text-xs font-mono",style:{color:"var(--widget-muted-foreground)"},children:[e.address?.slice(0,6),"...",e.address?.slice(-4)]})]})]},`${e.chainId}-${e.address}`))]})]})},Je=Le;export{Je as a};