@nexus-cross/dapp-ui 1.3.4-beta.6 → 1.3.4-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
`);j("");var vo=require("react/jsx-runtime");function wr({env:e,theme:t="dark",mobileBreakpoint:n=768,domain:o,children:r}){let i=Rn(`(max-width: ${n}px)`),[a,s]=Cn.useState(!1),c=Cn.useCallback(()=>s(!1),[]),d=He(e),f=Cn.useMemo(()=>({env:d,theme:t,isMobile:i,open:a,domain:o,close:c}),[d,t,i,a,o,c]);return(0,vo.jsx)(br.Provider,{value:f,children:i?(0,vo.jsx)(ka.Drawer.Root,{direction:"right",open:a,onOpenChange:s,noBodyStyles:!0,children:r},"drawer"):(0,vo.jsx)(ya.Root,{open:a,onOpenChange:s,children:r},"popover")})}var Ta=H(require("@radix-ui/react-popover"),1),Na=require("vaul");var $e=require("react/jsx-runtime");function Sa({size:e=18}){return(0,$e.jsxs)("svg",{className:"al-trigger-icon",width:e,height:e,viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,$e.jsx)("rect",{width:"4",height:"4",rx:"2",fill:"currentColor"}),(0,$e.jsx)("rect",{x:"7",width:"4",height:"4",rx:"2",fill:"currentColor"}),(0,$e.jsx)("rect",{x:"14",width:"4",height:"4",rx:"2",fill:"currentColor"}),(0,$e.jsx)("rect",{y:"7",width:"4",height:"4",rx:"2",fill:"currentColor"}),(0,$e.jsx)("rect",{x:"7",y:"7",width:"4",height:"4",rx:"2",fill:"currentColor"}),(0,$e.jsx)("rect",{x:"14",y:"7",width:"4",height:"4",rx:"2",fill:"currentColor"}),(0,$e.jsx)("rect",{y:"14",width:"4",height:"4",rx:"2",fill:"currentColor"}),(0,$e.jsx)("rect",{x:"7",y:"14",width:"4",height:"4",rx:"2",fill:"currentColor"}),(0,$e.jsx)("rect",{x:"14",y:"14",width:"4",height:"4",rx:"2",fill:"currentColor"})]})}function Ra(){return(0,$e.jsx)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,$e.jsx)("path",{d:"M12 19L5 12M5 12L12 5M5 12H19",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function Ca(){return(0,$e.jsx)("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,$e.jsx)("path",{d:"M15 5L5 15M5 5L15 15",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}var Wn=require("react/jsx-runtime");function xr({asChild:e,children:t,className:n,style:o}){let{isMobile:r,theme:i}=wo(),a=t!=null,s=e??!0,c=n?`al-trigger-btn ${n}`:"al-trigger-btn",d=a?t:(0,Wn.jsx)("button",{type:"button",className:c,"data-theme":i,style:o,children:(0,Wn.jsx)(Sa,{size:18})});return r?(0,Wn.jsx)(Na.Drawer.Trigger,{asChild:s,children:d}):(0,Wn.jsx)(Ta.Trigger,{asChild:s,children:d})}var ln=H(require("react"),1),yo=H(require("@radix-ui/react-popover"),1),sn=require("vaul");var La=require("@tanstack/react-query");var Ia={dev:"https://stg-contents.crosstoken.io/frontend/common/app-launcher/app-launcher-v2.json",stage:"https://stg-contents.crosstoken.io/frontend/common/app-launcher/app-launcher-v2.json",production:"https://contents.crosstoken.io/frontend/common/app-launcher/app-launcher-v2.json"};var Tc="https://stg-contents.crosstoken.io/frontend/common/app-launcher/icons",Nc="https://contents.crosstoken.io/frontend/common/app-launcher/icons";function mt(e,t){return`${e==="production"?Nc:Tc}/${t}.png`}function Ea(e){let t=e==="production"?"production":"stage";return{version:"0.0.1-fallback",items:[{id:"gametoken-cross",label:"Gametoken",description:"Trade game tokens easily using CROSS.",url:{dev:"https://stg.onechain.nexus/gametoken",stage:"https://stg.onechain.nexus/gametoken",production:"https://www.onechain.nexus/gametoken"},iconUrl:mt(t,"game-token"),order:1e3,type:"gametoken",badge:null,isNew:!1,serviceStatus:"available"},{id:"forge",label:"Forge",description:"Launch Your Game, Ignite the Market",url:{dev:"https://stg.onechain.nexus/forge",stage:"https://stg.onechain.nexus/forge",production:"https://onechain.nexus/forge"},iconUrl:mt(t,"forge"),order:4e3,type:"forge",badge:null,isNew:!0,serviceStatus:"available"},{id:"crossd",label:"Bridge",description:"The first decentralized exchange on the CROSS network.",url:{dev:"https://stg.crossdefi.io/swap-bridge",stage:"https://stg.crossdefi.io/swap-bridge",production:"https://www.crossdefi.io/swap-bridge"},iconUrl:mt(t,"crossd"),order:5e3,type:"crossd",badge:null,isNew:!1,serviceStatus:"ending"},{id:"prediction",label:"Prediction",description:"Prediction market",url:{dev:"https://stg-prediction.crossdefi.io",stage:"https://stg-prediction.crossdefi.io",production:"https://prediction.crossdefi.io/"},iconUrl:mt(t,"prediction"),order:6e3,type:"prediction",badge:null,isNew:!0,serviceStatus:"available"},{id:"rewards",label:"Rewards",description:"Deposit CROSS and earn rewards. Grow together.",url:{dev:"https://stg.onechain.nexus/rewards",stage:"https://stg.onechain.nexus/rewards",production:"https://onechain.nexus/rewards"},iconUrl:mt(t,"reward"),order:7e3,type:"rewards",badge:null,isNew:!1,serviceStatus:"ending"},{id:"cross-staking",label:"Staking",description:"Stake CROSS and earn rewards.",url:{dev:"https://stg-stake.ogfcorp.com",stage:"https://stg-stake.ogfcorp.com",production:"https://stake.ogfcorp.com"},iconUrl:mt(t,"cross-staking"),order:7500,type:"cross-staking",badge:null,isNew:!0,serviceStatus:"available"},{id:"nft",label:"NFT",description:"Trade and collect NFTs in the CROSS ecosystem.",url:{dev:"https://stg.crossnft.io/",stage:"https://stg.crossnft.io/",production:"https://www.crossnft.io/"},iconUrl:mt(t,"nft"),order:8e3,type:"nft",badge:null,isNew:!1,serviceStatus:"available"},{id:"play",label:"Quest",description:"Discover and play games on CROSS.",url:{dev:"https://stg.onechain.nexus/quest",stage:"https://stg.onechain.nexus/quest",production:"https://www.onechain.nexus/quest"},iconUrl:mt(t,"play"),order:8500,type:"play",badge:null,isNew:!0,serviceStatus:"available"},{id:"shop",label:"Shop",description:"Game Payment Platform & In-Game Currency Store.",url:{dev:"https://stg.onechain.nexus/shop",stage:"https://stg.onechain.nexus/shop",production:"https://www.onechain.nexus/shop"},iconUrl:mt(t,"shop"),order:9e3,type:"shop",badge:null,isNew:!1,serviceStatus:"available"},{id:"points",label:"Points",description:"Dive into CROSS World, Earn CROSS Points",url:{dev:"https://stg.onechain.nexus/points",stage:"https://stg.onechain.nexus/points",production:"https://onechain.nexus/points"},iconUrl:mt(t,"point"),order:1e4,type:"points",badge:null,isNew:!1,serviceStatus:"available"},{id:"explorer",label:"Explorer",description:"View transactions, blocks, and token data on the CROSS network.",url:{dev:"https://stg-explorer.onechain.nexus",stage:"https://stg-explorer.onechain.nexus",production:"https://explorer.onechain.nexus"},iconUrl:mt(t,"explorer"),order:12e3,type:"explorer",badge:null,isNew:!1,serviceStatus:"available"},{id:"wave",label:"Wave",description:"Stream, support, and earn in the CROSS ecosystem.",url:{dev:"https://stg.onechain.nexus/wave",stage:"https://stg.onechain.nexus/wave",production:"https://www.onechain.nexus/wave"},iconUrl:mt(t,"wave"),order:11e4,type:"wave",badge:null,isNew:!1,serviceStatus:"available"}]}}function Dn(e){let t=He(e);return(0,La.useQuery)({queryKey:["global-menu",t],queryFn:async({signal:n})=>{try{let o=await fetch(Ia[t],{cache:"no-store",signal:n});if(!o.ok)throw new Error(`Failed to fetch global menu: ${o.status}`);return o.json()}catch(o){if(n.aborted)throw o;return Ea(t)}},staleTime:0,gcTime:0,retry:!1,refetchOnMount:!0})}function vr(e){return e.serviceStatus==="ending"||e.serviceStatus==="comingSoon"?e.serviceStatus:"available"}function Pa(e,t){return typeof e=="string"?e:e[t]??e.production??e.stage??e.dev}function Fa(e){return[...e].sort((t,n)=>{let o=Aa(t)-Aa(n);return o!==0?o:t.order-n.order})}function Aa(e){let t=vr(e);return t==="comingSoon"?0:t==="ending"?2:1}function se(...e){return e.filter(Boolean).join(" ")}var pe=require("react/jsx-runtime");function Ic(e){return e.id==="cross-staking"||e.type==="cross-staking"}function yr({align:e="end",sideOffset:t=8,className:n}){let{env:o,theme:r,isMobile:i,domain:a,close:s}=wo(),{data:c}=Dn(o),d=ln.useMemo(()=>Fa(c?.items??[]),[c?.items]),f=8,h=ln.useRef(null),g=ln.useCallback(y=>{h.current={x:y.clientX,y:y.clientY}},[]),u=typeof window<"u"?window.location.pathname:"",v=ln.useCallback((y,E)=>{if(h.current){let R=y.clientX-h.current.x,k=y.clientY-h.current.y;if(h.current=null,Math.abs(R)>f||Math.abs(k)>f)return}let m=E.url[o]??E.url.production,C=Ba(m,a);if(!C)try{let R=new URL(m).pathname;if(u===R||u.startsWith(R+"/")){s();return}}catch{}C?window.open(m,"_blank","noopener,noreferrer"):window.location.href=m,s()},[o,a,s,u]),b=y=>{let E=y.url[o]??y.url.production,m=Ba(E,a),C=vr(y),R=C==="ending",k=Pa(y.iconUrl,o),T=!1;if(!m)try{let G=new URL(E).pathname;T=u===G||u.startsWith(G+"/")}catch{T=!1}return(0,pe.jsx)("button",{type:"button",className:"al-grid-item","data-active":T||void 0,"data-service-status":C,onPointerDown:g,onClick:G=>v(G,y),children:(0,pe.jsxs)("div",{className:"al-grid-item-left",children:[(0,pe.jsxs)("div",{className:"al-grid-item-icon",children:[(0,pe.jsx)("img",{src:k,alt:y.label,width:24,height:24,loading:"lazy"}),y.isNew&&(0,pe.jsx)("span",{className:"al-status-ribbon al-status-ribbon-new",children:"N"})]}),(0,pe.jsxs)("span",{className:"al-grid-item-text",children:[(0,pe.jsx)("span",{className:"al-grid-item-label",children:y.label}),R&&(0,pe.jsx)("span",{className:"al-grid-item-status-text",children:"(End Soon)"}),y.badge&&!Ic(y)&&(0,pe.jsx)("span",{className:"al-badge al-badge-list",children:y.badge})]})]})},y.id)},w=(0,pe.jsx)("div",{className:"al-menu","data-theme":r,children:(0,pe.jsx)("div",{className:"al-grid",children:d.map(b)})});return i?(0,pe.jsxs)(sn.Drawer.Portal,{children:[(0,pe.jsx)(sn.Drawer.Overlay,{className:"al-drawer-overlay"}),(0,pe.jsxs)(sn.Drawer.Content,{className:se("al-drawer-content",n),"data-theme":r,children:[(0,pe.jsxs)("div",{className:"al-drawer-header",children:[(0,pe.jsx)(sn.Drawer.Close,{className:"al-drawer-close",children:(0,pe.jsx)(Ra,{})}),(0,pe.jsx)(sn.Drawer.Title,{className:"al-drawer-title",children:"CROSS Services"}),(0,pe.jsx)(sn.Drawer.Close,{className:"al-drawer-close",children:(0,pe.jsx)(Ca,{})})]}),(0,pe.jsx)("div",{className:"al-drawer-body",children:w})]})]}):(0,pe.jsx)(yo.Portal,{children:(0,pe.jsx)(yo.Content,{align:e,sideOffset:t,className:se("al-popover-content",n),"data-theme":r,children:w})})}function Ba(e,t){try{let n=new URL(e).hostname;return typeof window>"u"?!0:n!==(t??window.location.hostname)}catch{return!1}}var Je=H(require("react"),1),_l=H(require("@radix-ui/react-popover"),1),Ml=require("vaul");var ko=require("react"),kr=(0,ko.createContext)(null);function Zt(){let e=(0,ko.useContext)(kr);if(!e)throw new Error("WalletInfo compound components must be used within <WalletInfo>");return e}var So=(o=>(o.CROSSx="crossx",o.MetaMask="io.metamask",o.Binance="com.binance.wallet",o))(So||{}),zn={crossx:{name:"CROSSx",iconUrl:"https://contents.crosstoken.io/wallet/token/images/tCROSS.svg"},"io.metamask":{name:"MetaMask",iconUrl:"https://upload.wikimedia.org/wikipedia/commons/3/36/MetaMask_Fox.svg"},"com.binance.wallet":{name:"Binance Wallet",iconUrl:"https://public.bnbstatic.com/static/images/common/favicon.ico"}};var Ti=H(require("react"),1);var V=require("react/jsx-runtime");function _a({size:e=16,className:t}){return(0,V.jsxs)("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t,children:[(0,V.jsx)("path",{d:"M12.6667 4.66667V2.66667C12.6667 2.48986 12.5964 2.32029 12.4714 2.19526C12.3464 2.07024 12.1768 2 12 2H3.33333C2.97971 2 2.64057 2.14048 2.39052 2.39052C2.14048 2.64057 2 2.97971 2 3.33333C2 3.68696 2.14048 4.02609 2.39052 4.27614C2.64057 4.52619 2.97971 4.66667 3.33333 4.66667H13.3333C13.5101 4.66667 13.6797 4.7369 13.8047 4.86193C13.9298 4.98695 14 5.15652 14 5.33333V8M14 8H12C11.6464 8 11.3072 8.14048 11.0572 8.39052C10.8071 8.64057 10.6667 8.97971 10.6667 9.33333C10.6667 9.68696 10.8071 10.0261 11.0572 10.2761C11.3072 10.5262 11.6464 10.6667 12 10.6667H14C14.1768 10.6667 14.3464 10.5964 14.4714 10.4714C14.5964 10.3464 14.6667 10.1768 14.6667 10V8.66667C14.6667 8.48986 14.5964 8.32029 14.4714 8.19526C14.3464 8.07024 14.1768 8 14 8Z",stroke:"currentColor",strokeWidth:1.33333,strokeLinecap:"round",strokeLinejoin:"round"}),(0,V.jsx)("path",{d:"M2 3.33325V12.6666C2 13.0202 2.14048 13.3593 2.39052 13.6094C2.64057 13.8594 2.97971 13.9999 3.33333 13.9999H13.3333C13.5101 13.9999 13.6797 13.9297 13.8047 13.8047C13.9298 13.6796 14 13.5101 14 13.3333V10.6666",stroke:"currentColor",strokeWidth:1.33333,strokeLinecap:"round",strokeLinejoin:"round"})]})}function Gn({size:e=16,className:t}){return(0,V.jsx)("svg",{width:e,height:e,viewBox:"4 4 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t,children:(0,V.jsx)("path",{d:"M9.40284 17.0647H4.85156V4.84656H17.0697V9.39783H15.4407V6.47565H6.48066V15.4356H9.40284V17.0647ZM21.5192 12.5644H12.5592V21.5244H21.5192V12.5644ZM23.1483 10.9353V23.1535H10.9301V10.9353H23.1483Z",fill:"currentColor"})})}function cn({size:e=16,className:t}){return(0,V.jsx)("svg",{width:e,height:e,viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t,children:(0,V.jsx)("path",{d:"M11.6667 3.5L5.25 9.91667L2.33334 7",stroke:"currentColor",strokeWidth:1.16667,strokeLinecap:"round",strokeLinejoin:"round"})})}function Bt({size:e=24,className:t}){return(0,V.jsx)("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t,children:(0,V.jsx)("path",{d:"M18 6L6 18M6 6l12 12",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})})}function Ma({size:e=20,className:t}){return(0,V.jsxs)("svg",{width:e,height:e,viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t,children:[(0,V.jsx)("path",{d:"M7.5 17.5H4.167A1.667 1.667 0 012.5 15.833V4.167A1.667 1.667 0 014.167 2.5H7.5",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"}),(0,V.jsx)("path",{d:"M13.333 14.167L17.5 10l-4.167-4.167M17.5 10H7.5",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"})]})}function Ro({size:e=20,className:t}){return(0,V.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 20 20",fill:"none",className:t,children:(0,V.jsx)("path",{d:"M7.91305 10.8327C8.60341 10.8327 9.16305 11.3924 9.16305 12.0827V16.2458C9.16305 16.9361 8.60341 17.4958 7.91305 17.4958H3.75C3.05964 17.4958 2.5 16.9361 2.5 16.2458L2.5 12.0827C2.5 11.3924 3.05964 10.8327 3.75 10.8327H7.91305ZM14.1685 17.4958H12.5027V15.83H14.1685V17.4958ZM17.5 17.4958H15.8342V15.83H17.5V17.4958ZM4.16576 12.4985V15.83H7.49729V12.4985H4.16576ZM12.5027 15.83H10.8369V14.1642H12.5027V15.83ZM15.8342 15.83H14.1685V14.1642H15.8342V15.83ZM14.1685 14.1642H12.5027V12.4985H14.1685V14.1642ZM17.5 14.1642H15.8342V12.4985H17.5V14.1642ZM12.5027 12.4985H10.8369V10.8327H12.5027V12.4985ZM15.8342 12.4985H14.1685V10.8327H15.8342V12.4985ZM7.91305 2.50391C8.60341 2.50391 9.16305 3.06355 9.16305 3.75391V7.91696C9.16305 8.60731 8.60341 9.16696 7.91305 9.16696H3.75C3.05964 9.16696 2.5 8.60731 2.5 7.91696L2.5 3.75391C2.5 3.06355 3.05964 2.50391 3.75 2.50391L7.91305 2.50391ZM16.2419 2.50391C16.9322 2.50391 17.4919 3.06355 17.4919 3.75391V7.91696C17.4919 8.60731 16.9322 9.16696 16.2419 9.16696H12.0788C11.3885 9.16696 10.8288 8.60731 10.8288 7.91696V3.75391C10.8288 3.06355 11.3885 2.50391 12.0788 2.50391L16.2419 2.50391ZM4.16576 4.16967L4.16576 7.50119L7.49729 7.50119L7.49729 4.16967L4.16576 4.16967ZM12.4946 4.16967V7.50119H15.8261V4.16967H12.4946Z",fill:"currentColor",fillOpacity:1})})}function dn({size:e=20,className:t}){return(0,V.jsx)("svg",{width:e,height:e,viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t,children:(0,V.jsx)("path",{d:"M12.5 15L7.5 10L12.5 5",stroke:"currentColor",strokeWidth:1.67,strokeLinecap:"round",strokeLinejoin:"round"})})}function pn({size:e=20,className:t}){return(0,V.jsx)("svg",{width:e,height:e,viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t,children:(0,V.jsx)("path",{d:"M5 8L10 13L15 8",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})})}function Oa({size:e=16,className:t}){return(0,V.jsxs)("svg",{width:e,height:e,viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t,children:[(0,V.jsx)("path",{d:"M1.667 10S4.167 4.167 10 4.167 18.333 10 18.333 10 15.833 15.833 10 15.833 1.667 10 1.667 10z",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"}),(0,V.jsx)("path",{d:"M10 12.5a2.5 2.5 0 100-5 2.5 2.5 0 000 5z",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"})]})}function Wa({size:e=16,className:t}){return(0,V.jsxs)("svg",{width:e,height:e,viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t,children:[(0,V.jsx)("path",{d:"M14.95 14.95A8.283 8.283 0 0110 16.667c-5.833 0-8.333-5.833-8.333-5.833a15.238 15.238 0 014.183-4.884m3.267-1.55A7.55 7.55 0 0110 4.167c5.833 0 8.333 5.833 8.333 5.833a15.28 15.28 0 01-1.783 2.633M11.767 11.767a2.5 2.5 0 11-3.534-3.534",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"}),(0,V.jsx)("path",{d:"M1.667 1.667l16.666 16.666",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"})]})}function Da({size:e=42,className:t}){return(0,V.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 42 42",fill:"none",className:t,children:(0,V.jsx)("path",{d:"M20.7314 2C31.0766 2 39.4628 10.3863 39.4629 20.7314C39.4629 31.0766 31.0766 39.4629 20.7314 39.4629C10.3863 39.4628 2 31.0766 2 20.7314C2.00007 10.3864 10.3864 2.00007 20.7314 2ZM20.5938 30.0586L21.1084 30.5732L21.623 30.0586V25.2471H21.1084C20.9344 25.2471 20.7626 25.235 20.5938 25.2158V30.0586ZM16.4834 24.6611L14.6514 26.4922L15.3799 27.2207L17.1797 25.4209L18.3193 24.2803C18.0487 24.0673 17.8025 23.8251 17.5869 23.5566L16.4834 24.6611ZM26.8691 27.2207L27.5967 26.4922L26.3516 25.2471H24.8955L26.8691 27.2207ZM11.2666 20.7314L11.7822 21.2471H16.624C16.6048 21.0781 16.5938 20.9065 16.5938 20.7324C16.5938 20.5585 16.6049 20.3866 16.624 20.2178H11.7812L11.2666 20.7314ZM20.5938 11.4053V16.2471C20.7626 16.2279 20.9345 16.2178 21.1084 16.2178H21.623V11.4053L21.1084 10.8906L20.5938 11.4053ZM14.6514 15.0029L16.4521 16.8027L17.5732 17.9238C17.7874 17.6546 18.0315 17.4104 18.3008 17.1963L15.3799 14.2754L14.6514 15.0029ZM25.0371 16.1074L24.9268 16.2178H26.3818L27.5957 15.0029L26.8682 14.2754L25.0371 16.1074Z",fill:"#019D92",stroke:"white",strokeWidth:4})})}function za({size:e=20,className:t}){return(0,V.jsx)("svg",{width:e,height:e,viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t,children:(0,V.jsx)("path",{d:"M9.19133 10.8077C9.04905 10.6657 8.87947 10.554 8.69283 10.4792L2.78881 8.11167C2.71832 8.08338 2.65816 8.03421 2.61642 7.97075C2.57468 7.90729 2.55335 7.83258 2.5553 7.75665C2.55724 7.68072 2.58237 7.6072 2.6273 7.54596C2.67224 7.48472 2.73483 7.4387 2.80668 7.41406L16.9525 2.5747C17.0185 2.55087 17.0899 2.54632 17.1583 2.56159C17.2268 2.57685 17.2895 2.6113 17.3391 2.66089C17.3887 2.71049 17.4231 2.77319 17.4384 2.84165C17.4536 2.9101 17.4491 2.9815 17.4253 3.04746L12.5859 17.1933C12.5613 17.2651 12.5152 17.3277 12.454 17.3727C12.3928 17.4176 12.3192 17.4427 12.2433 17.4447C12.1674 17.4466 12.0927 17.4253 12.0292 17.3835C11.9658 17.3418 11.9166 17.2817 11.8883 17.2112L9.52073 11.3056C9.44567 11.1191 9.33362 10.9498 9.19133 10.8077ZM9.19133 10.8077L17.3367 2.66404",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"})})}function Ga({size:e=20,className:t}){return(0,V.jsx)("svg",{width:e,height:e,viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t,children:(0,V.jsx)("path",{d:"M10.8333 14.1667V7.5M15 14.1667V4.16667M2.5 2.5V15.8333C2.5 16.2754 2.67559 16.6993 2.98816 17.0118C3.30072 17.3244 3.72464 17.5 4.16667 17.5H17.5M6.66667 14.1667V11.6667",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"})})}function Ua({size:e=20,className:t}){return(0,V.jsx)("svg",{width:e,height:e,viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t,children:(0,V.jsx)("path",{d:"M6.6665 9.99984H13.3332M9.99984 6.6665V13.3332M18.3332 9.99984C18.3332 14.6022 14.6022 18.3332 9.99984 18.3332C5.39746 18.3332 1.6665 14.6022 1.6665 9.99984C1.6665 5.39746 5.39746 1.6665 9.99984 1.6665C14.6022 1.6665 18.3332 5.39746 18.3332 9.99984Z",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"})})}function Ha({size:e=20,className:t}){return(0,V.jsx)("svg",{width:e,height:e,viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t,children:(0,V.jsx)("path",{d:"M6.667 2.5 3.333 5.833 6.667 9.167M3.333 5.833h13.334M13.333 17.5l3.334-3.333-3.334-3.334M16.667 14.167H3.333",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"})})}function $a({size:e=20,className:t}){return(0,V.jsxs)("svg",{width:e,height:e,viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t,children:[(0,V.jsx)("circle",{cx:"10",cy:"10",r:"10",fill:"currentColor"}),(0,V.jsx)("path",{d:"M6 10.2L8.6 12.8L14 7.2",stroke:"var(--ds-accent-primary-on, #ffffff)",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round"})]})}var O=H(require("react"),1);var Xt=H(require("bignumber.js"),1);function Ec(e){let t=e.length;for(;t>0&&e.charCodeAt(t-1)===48;)t--;return t>0&&e.charCodeAt(t-1)===46&&t--,e.slice(0,t)}function Jt(e,t){if(!e||e==="0")return"0.00";let n=new Xt.default(e).shiftedBy(-t),o=n.isGreaterThanOrEqualTo(1)?2:4;return n.toFormat(o,Xt.default.ROUND_DOWN)}function lt(e){return e.length<=10?e:`${e.slice(0,6)}...${e.slice(-4)}`}function Sr(e){let t=typeof e=="string"?parseFloat(e):e;if(Number.isNaN(t)||t===0)return"$0.00";let n=t>=1?2:4,o=Math.pow(10,n);return`$${(Math.floor(t*o)/o).toLocaleString("en-US",{minimumFractionDigits:n,maximumFractionDigits:n})}`}function ja(e,t,n){let r=new Xt.default(e).shiftedBy(-t).multipliedBy(new Xt.default(n));return r.isZero()||r.isNaN()?"$0.00":`$${(r.integerValue(Xt.default.ROUND_DOWN).isGreaterThanOrEqualTo(1)?r.decimalPlaces(2,Xt.default.ROUND_DOWN):r.decimalPlaces(4,Xt.default.ROUND_DOWN)).toFormat()}`}function Va(e){if(e===""||e===null||e===void 0)return{displayValue:"0",isLowerBound:!1};let t=typeof e=="number"?e.toString():e;if(t==="0"||t==="0.0")return{displayValue:"0",isLowerBound:!1};let n=t;if(n.includes("e")||n.includes("E")){let a=Number(n);if(!Number.isFinite(a)||a===0)return{displayValue:"0",isLowerBound:!1};n=Ec(a.toFixed(18))}let[o="0",r=""]=n.split(".");if(Number(o)>=1){let a=r.slice(0,2).padEnd(2,"0");return{displayValue:`${Number(o).toLocaleString("en-US")}.${a}`,isLowerBound:!1}}return r.length<4?{displayValue:`${o}.${r}`,isLowerBound:!1}:r.slice(0,4)==="0000"?{displayValue:"0.0001",isLowerBound:!0}:{displayValue:`0.${r.slice(0,4)}`,isLowerBound:!1}}var qa=require("react"),Ka=require("@tanstack/react-query");var tt={dev:"https://stg-wallet-server.crosstoken.io/api",stage:"https://stg-wallet-server.crosstoken.io/api",production:"https://wallet-server.crosstoken.io/api"},Se={dev:{cross:612044,bsc:97},stage:{cross:612044,bsc:97},production:{cross:612055,bsc:56}},Tn="https://terms.crosstoken.io/docs/cross-terms-of-use",Co="https://terms.crosstoken.io/docs/nexus-privacy-policy";var Lc="send:chain-info";function Ac(e){if("data"in e&&e.data!==void 0){let t=e.data;if(Array.isArray(t)){let n=t[0];if(!n)throw new Error("Chain info payload is empty.");return n}return t}return e}function Rr(e,...t){let n=e.replace(/\/+$/,""),o=t.map(r=>r.replace(/^\/+|\/+$/g,"")).filter(Boolean);return[n,...o].join("/")}function Pc(e,t,n,o){if(o)return t===Se[e].cross?Qa(t,o):n?.explorer_url?Rr(n.explorer_url,n.explorer_postfix?.transaction??"tx",o):Fc(e,t,o)}function Qa(e,t){return Rr("https://explorer.onechain.nexus",String(e),"tx",t)}function Fc(e,t,n){let o=Se[e];if(t===o.cross)return Qa(t,n);if(t===o.bsc)return Rr(e==="production"?"https://bscscan.com":"https://testnet.bscscan.com","tx",n)}function To(e,t,n,o=!0){let r=tt[e],i=(0,Ka.useQuery)({queryKey:[Lc,e,t],queryFn:async({signal:c})=>{let d=await fetch(`${r}/v1/public/chain/info/${t}`,{cache:"no-store",signal:c});if(!d.ok)throw new Error(`Failed to fetch chain info: ${d.status}`);let f=await d.json();if("code"in f&&f.code!==void 0&&f.code!==200)throw new Error(`Chain info API error: ${f.code}`);return Ac(f)},enabled:o,staleTime:300*1e3}),a=i.data;return{transactionUrl:(0,qa.useMemo)(()=>Pc(e,t,a,n),[t,a,e,n]),chainInfo:a,...i}}var Ya="0x0000000000000000000000000000000000000001";var Bc="0xa9059cbb",_c=/^0x[a-fA-F0-9]{40}$/,Mc="nexus-cross:dapp-ui:send:recent:",Za=10;function Oc(e){let t=e.length;for(;t>0&&e.charCodeAt(t-1)===48;)t--;return e.slice(0,t)}function Un(e){return e.toLowerCase()}function _t(e){return _c.test(e)}function en(e){return Un(e.address)===Ya}function Cr(e){return`${Mc}${e.toLowerCase()}`}function Nn(e){if(typeof window>"u")return[];try{let t=window.localStorage.getItem(Cr(e));if(!t)return[];let n=JSON.parse(t);return Array.isArray(n)?n.filter(o=>o!==null&&typeof o=="object"&&_t(o.address)&&typeof o.updatedAt=="number").slice(0,Za):[]}catch{return[]}}function Tr(e,t){if(typeof window>"u")return[];let n=Un(t),o=[{address:n,updatedAt:Date.now()},...Nn(e).filter(r=>r.address!==n)].slice(0,Za);try{window.localStorage.setItem(Cr(e),JSON.stringify(o))}catch{return Nn(e)}return o}function Nr(e){if(!(typeof window>"u"))try{window.localStorage.removeItem(Cr(e))}catch{}}function $t(e,t){let n=e.trim();if(!n)return{error:"Enter an amount."};if(!/^\d+(\.\d*)?$/.test(n))return{error:"Enter a valid amount."};let[o="0",r=""]=n.split(".");if(r.length>t)return{error:`Max ${t} decimal places.`};let i=BigInt(o||"0"),a=r.padEnd(t,"0"),s=a?BigInt(a):0n,c=10n**BigInt(t),d=i*c+s;return d<=0n?{error:"Amount must be greater than 0."}:{value:d}}function Hn(e,t){let n=BigInt(e||"0"),o=10n**BigInt(t),r=n/o,i=n%o;if(i===0n)return r.toString();let a=Oc(i.toString().padStart(t,"0"));return`${r.toString()}.${a}`}function Ir(e,t){let n=e.replace(/^0x/,"").toLowerCase().padStart(64,"0"),o=t.toString(16).padStart(64,"0");return`${Bc}${n}${o}`}function No(e,t,n=10){if(t<=0)return e.toString();let o=10n**BigInt(t),r=e/o,i=e%o;if(i===0n)return r.toString();let s=i.toString().padStart(t,"0").slice(0,Math.max(0,Math.min(n,t)));return s=s.replace(/0+$/,""),s?`${r.toString()}.${s}`:r.toString()}function Er(e,t){return No(e,t,6)}function Xa(e){return No(e,9,2)}function Ja(e){return e.toLocaleString("en-US")}function Io(e){return e===56||e===97}function Eo(e){return e.gasPrice??e.maxFeePerGas}function ei(e,t=!1){return t?Eo(e)!==void 0?"legacy":null:e.maxFeePerGas!==void 0?"dynamic":e.gasPrice!==void 0?"legacy":null}function Lo(e,t=!1){if(t){let n=Eo(e);return n!==void 0?e.gasLimit*n:null}return e.maxFeePerGas!==void 0?e.gasLimit*e.maxFeePerGas:e.gasPrice!==void 0?e.gasLimit*e.gasPrice:null}function Ao(e){return!Number.isFinite(e)||e<=0?"$0.00":`$${e.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}`}function ti(e,t=0){if(t>4||e===null||e===void 0)return"";if(typeof e=="string")return e.toLowerCase();if(typeof e!="object")return"";let n=e,o=[];return typeof n.name=="string"&&o.push(n.name),typeof n.shortMessage=="string"&&o.push(n.shortMessage),typeof n.message=="string"&&o.push(n.message),typeof n.details=="string"&&o.push(n.details),n.cause!==void 0&&o.push(ti(n.cause,t+1)),o.join(`
|
|
6
6
|
`).toLowerCase()}function Wc(e){if(e instanceof Error)return e.message;if(typeof e=="string")return e;if(e&&typeof e=="object"){let t=e;if(typeof t.shortMessage=="string")return t.shortMessage;if(typeof t.message=="string")return t.message}return""}function Lr(e,t={},n="Failed to send transaction."){let o=ti(e);if(!o)return n;let r=t.nativeSymbol?.trim()||"gas token",i=t.networkName?.trim();if(o.includes("user rejected")||o.includes("userrejected")||o.includes("user denied")||o.includes("user cancelled")||o.includes("user canceled")||o.includes("action_rejected")||o.includes("rejected by user"))return"Transaction was cancelled.";if(o.includes("insufficientfunds")||o.includes("insufficient funds")||o.includes("exceeds the balance of the account")||o.includes("insufficient balance for transfer")){let a=i?` on ${i}`:"";return`Not enough ${r} to cover the gas fee.Please top up your ${r} balance and try again.`}return o.includes("transaction underpriced")||o.includes("replacement transaction underpriced")||o.includes("fee too low")?"Gas fee was too low for the network. Please try again.":o.includes("nonce too low")||o.includes("nonce has already been used")||o.includes("nonce too high")?"Pending transactions are out of order. Refresh the page and try again.":o.includes("execution reverted")||o.includes("contractfunctionrevertederror")||o.includes("contractfunctionexecutionerror")?"The transaction was rejected by the contract. The recipient or token may be invalid.":o.match(/chain \d+ is not configured/)?"This network is not registered in the app. Contact support.":o.includes("http request failed")||o.includes("failed to fetch")||o.includes("network request failed")||o.includes("timeout")||o.includes("econnreset")||o.includes("rpc error")||o.includes("429")?"Network connection failed. Check your internet and try again.":o.includes("estimategas")||o.includes("gas estimation failed")?"Could not estimate the gas fee. The recipient address or amount may be invalid.":Wc(e)||n}var Dc=2000000000n,zc=1000000000n;async function Po(e,t,n){let o=new AbortController,r=setTimeout(()=>o.abort(),8e3),i=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",id:1,method:t,params:n}),signal:o.signal}).finally(()=>clearTimeout(r));if(!i.ok)throw new Error(`RPC ${t} HTTP ${i.status}`);let a=await i.json();if(a.error)throw new Error(`RPC ${t}: ${a.error.message}`);if(a.result===void 0)throw new Error(`RPC ${t}: empty result`);return a.result}function Fo(e){return BigInt(e)}function Gc(e){return`0x${e.toString(16)}`}function Uc(e){let t={to:e.to};return e.from&&(t.from=e.from),e.value!==void 0&&e.value>0n&&(t.value=Gc(e.value)),e.data&&(t.data=e.data),t}function Hc(e){return e===56||e===97}async function ni(e){try{let t=await Po(e,"eth_gasPrice",[]);return{gasPrice:Fo(t)}}catch{return{gasPrice:Dc}}}async function $c(e,t){let n=zc;try{let o=await Po(e,"eth_maxPriorityFeePerGas",[]);n=Fo(o)}catch{}return{maxFeePerGas:t+n,maxPriorityFeePerGas:n}}async function jc(e,t){if(t)return ni(e);let n;try{n=(await Po(e,"eth_getBlockByNumber",["latest",!1]))?.baseFeePerGas}catch{}return n?$c(e,Fo(n)):ni(e)}async function oi(e,t){let n=Hc(t.chainId),o=Uc(t),[r,i]=await Promise.all([Po(e,"eth_estimateGas",[o]),jc(e,n)]);return{gasLimit:Fo(r),gasPrice:i.gasPrice,maxFeePerGas:i.maxFeePerGas,maxPriorityFeePerGas:i.maxPriorityFeePerGas}}function ri(e){let{estimateGas:t,sendTransaction:n,getTransactionReceipt:o}=e;return{canSend:!!n,canEstimateGas(r){return!!t||!!r},async estimateGas(r,i){if(t)return t(r);if(i)return oi(i,r);throw new Error("Gas estimation is not available.")},async sendTransaction(r){if(!n)throw new Error("Sending is not available for this wallet.");return n(r)},getTransactionReceipt:o}}var Vc=1500,qc=120;function ai(e){return!!(e.token||e.recipient||e.amount)}function Ar({recipient:e,amount:t,token:n,balanceRaw:o}){let r={},i=e.trim(),a=$t(t,n.quantity.decimals),s;return i?_t(i)||(r.recipient="Enter a valid EVM recipient address."):r.recipient="Enter a recipient address.","error"in a?r.amount=a.error:(s=a.value,s>o&&(r.amount="Amount exceeds available balance.")),!en(n)&&!_t(n.address)&&(r.token="Token contract address is invalid."),{errors:r,rawAmount:r.amount?void 0:s,recipient:i&&_t(i)?i:void 0}}function Pr({token:e,walletAddress:t,recipient:n,rawAmount:o}){let r=t;return en(e)?{to:n,value:o,chainId:e.chainId,from:r}:{to:Un(e.address),data:Ir(n,o),value:0n,chainId:e.chainId,from:r}}function Kc(e){let{status:t}=e;return t==="reverted"||t==="0x0"||t===0||t===0n||t===!1}var Qc=e=>new Promise(t=>setTimeout(t,e));async function ii({repository:e,args:t,chainId:n,onSubmitted:o,pollIntervalMs:r=Vc,pollMaxAttempts:i=qc}){let a=await e.sendTransaction(t);o(a);let{getTransactionReceipt:s}=e;if(!s)return"success";for(let c=0;c<i;c+=1){let d=await s({hash:a,chainId:n}).catch(()=>null);if(d)return Kc(d)?"reverted":"success";await Qc(r)}return"timeout"}var si=["token","recipient","amount","review"];function li(e){let{env:t,walletAddress:n,accountName:o,accounts:r=[],initialStep:i="recipient",token:a,tokens:s=[],onTokenChange:c,sendTransaction:d,getTransactionReceipt:f,estimateGas:h,getTokenPriceUsd:g,onSubmitted:u,onSuccess:v,onFailed:b,onExit:w,onOutlink:y}=e,E=O.useMemo(()=>ri({sendTransaction:d,getTransactionReceipt:f,estimateGas:h}),[d,f,h]),[m,C]=O.useState(a);O.useEffect(()=>{C(a)},[a.address,a.chainId]);let[R,k]=O.useState(i),[T,G]=O.useState(""),[F,K]=O.useState(""),[D,Q]=O.useState({}),[A,ae]=O.useState("idle"),[B,Y]=O.useState(""),[ye,de]=O.useState(""),[J,be]=O.useState(null),[ue,Z]=O.useState(!1),[z,ee]=O.useState(""),ze=O.useRef(0),[ve,gt]=O.useState(null),[Be,Yt]=O.useState(""),[ht,et]=O.useState(()=>Nn(n)),Gt=O.useMemo(()=>He(t),[t]),{transactionUrl:_e,chainInfo:Re}=To(Gt,m.chainId,B||void 0,!0),dt=Re?.currency_symbol??"",Me=Re?.name??`Chain ID ${m.chainId}`,Ge=O.useRef({nativeSymbol:dt||void 0,networkName:Me,tokenSymbol:m.symbol});Ge.current={nativeSymbol:dt||void 0,networkName:Me,tokenSymbol:m.symbol};let Ce=O.useMemo(()=>BigInt(m.quantity.numeric||"0"),[m.quantity.numeric]),Lt=O.useMemo(()=>Jt(m.quantity.numeric,m.quantity.decimals),[m.quantity.numeric,m.quantity.decimals]),bt=g?.(m),At=O.useMemo(()=>{if(bt===void 0)return;let N=parseFloat(F.replace(/,/g,""));return Number.isFinite(N)?N*bt:0},[F,bt]);O.useEffect(()=>{K(""),Q({})},[m.address,m.chainId]),O.useEffect(()=>{ze.current+=1,be(null),ee(""),Z(!1)},[m.address,m.chainId,T,F]),O.useEffect(()=>{et(Nn(n))},[n]);let nt=O.useCallback(N=>{G(N),Q(te=>({...te,recipient:void 0}))},[]),Pt=O.useCallback(N=>{K(N),Q(te=>({...te,amount:void 0}))},[]),ot=O.useCallback(()=>{K(Lt.replace(/,/g,"")),Q(N=>({...N,amount:void 0}))},[Lt]),Te=O.useCallback(N=>{C(N),c?.(N),k("recipient")},[c]),rt=O.useCallback(()=>k("token"),[]),pt=O.useCallback(()=>{k(N=>{if(N==="result")return"review";if(N===i)return w?.(),N;let te=si.indexOf(N);return te<=0?(w?.(),N):si[te-1]})},[i,w]),Ve=O.useCallback(()=>{let{errors:N}=Ar({recipient:T,amount:"1",token:m,balanceRaw:Ce});if(N.recipient){Q(te=>({...te,recipient:N.recipient}));return}Q(te=>({...te,recipient:void 0})),k("amount")},[T,m,Ce]),wt=O.useCallback(N=>{G(N),Q(te=>({...te,recipient:void 0})),k("amount")},[]),ke=O.useCallback(()=>{let N=Ar({recipient:T,amount:F,token:m,balanceRaw:Ce});Q(N.errors),!(ai(N.errors)||N.rawAmount===void 0||!N.recipient)&&(gt(N.rawAmount),Yt(N.recipient),be(null),ee(""),ae("idle"),k("review"))},[T,F,m,Ce]);O.useEffect(()=>{if(R!=="review"||!Be||ve===null||J!==null||ue||z||!E.canEstimateGas(Re?.rpc))return;let N=++ze.current;Z(!0),ee(""),(async()=>{try{let te=Pr({token:m,walletAddress:n,recipient:Be,rawAmount:ve}),we=await E.estimateGas(te,Re?.rpc);if(ze.current!==N)return;be(we)}catch(te){if(ze.current!==N)return;ee(Lr(te,Ge.current,"Failed to estimate gas."))}finally{ze.current===N&&Z(!1)}})()},[R,Be,ve,J,ue,z,E,Re?.rpc,m,n]);let Le=O.useMemo(()=>{if(!en(m)||!J||ve===null)return!1;let N=Lo(J,Io(m.chainId));return N===null?!1:ve+N>Ce},[m,J,ve,Ce]),Ft=O.useCallback(async()=>{if(!(!Be||ve===null)&&!Le){de(""),Y(""),ae("submitting");try{let N="",te=await ii({repository:E,args:Pr({token:m,walletAddress:n,recipient:Be,rawAmount:ve}),chainId:m.chainId,onSubmitted:we=>{N=we,Y(we),ae("confirming"),et(Tr(n,Be)),u?.({txHash:we,chainId:m.chainId,amount:F,tokenSymbol:m.symbol,recipient:Be})}});if(te==="success")ae("success"),N&&v?v?.(N):k("result");else if(te==="reverted"){let we="Transaction reverted on-chain.";ae("error"),de(we),N&&b?b({txHash:N,chainId:m.chainId,message:we}):k("result")}else{let we="Transaction receipt was not found. Please check again later.";ae("error"),de(we),N&&b?b({txHash:N,chainId:m.chainId,message:we}):k("result")}}catch(N){ae("error"),de(Lr(N,{nativeSymbol:dt||void 0,networkName:Me,tokenSymbol:m.symbol})),k("result")}}},[E,Be,ve,Le,m,F,n,u,v,b,dt,Me]),[xt,qe]=O.useState(!1),ft=O.useRef(void 0);O.useEffect(()=>()=>clearTimeout(ft.current),[]);let vt=O.useCallback(async()=>{if(B)try{await navigator.clipboard.writeText(B),qe(!0),clearTimeout(ft.current),ft.current=setTimeout(()=>qe(!1),2e3)}catch{}},[B]),Ae=O.useCallback(()=>{if(!_e||!B)return;let N=at=>{typeof window<"u"&&window.open(at,"_blank","noopener,noreferrer")};if(!y){N(_e);return}let te=y(_e,{category:"send",origin:"send-transaction",payload:{chainId:m.chainId,txHash:B}});if(te&&typeof te.then=="function"){let at=typeof window<"u"?window.open("","_blank","noopener,noreferrer"):null;te.then(Ut=>{if(Ut===null){at?.close();return}let it=Ut??_e;if(at)try{at.location.href=it}catch{at.close(),N(it)}else N(it)});return}let we=te;we!==null&&N(we??_e)},[y,m.chainId,_e,B]),Oe=O.useCallback(()=>{de(""),Y(""),ae("idle"),be(null),ee(""),k("review")},[]);return{step:R,status:A,token:m,tokens:s.length>0?s:[m],recipient:T,amount:F,amountUsd:At,fieldErrors:D,error:ye,txHash:B,gasEstimate:J,gasLoading:ue,gasError:z,insufficientGas:Le,reviewRawAmount:ve,reviewRecipient:Be,recentAddresses:ht,accounts:r,accountName:o,walletAddress:n,resolvedEnv:Gt,transactionUrl:_e,networkName:Me,nativeSymbol:dt,nativeDecimals:Re?.currency_decimals??m.quantity.decimals,balanceRaw:Ce,balanceText:Lt,priceUsd:bt,canSelectToken:(s.length>0?s:[m]).length>1,canSend:E.canSend,getTokenPriceUsd:g,setRecipient:nt,setAmount:Pt,setMax:ot,selectToken:Te,goToTokenSelect:rt,selectRecipient:wt,submitRecipient:Ve,submitAmount:ke,confirmSend:Ft,retry:Oe,back:pt,hashCopied:xt,copyHash:vt,openTransaction:Ae}}var kt=H(require("react"),1);var Mt=require("react/jsx-runtime");function ci({flow:e}){let{amount:t,setAmount:n,amountUsd:o,balanceText:r,balanceRaw:i,token:a,setMax:s}=e,c=kt.useRef(null),d=kt.useCallback(()=>{requestAnimationFrame(()=>{let b=c.current;if(!b)return;let w=b.value.length;b.setSelectionRange(w,w)})},[]);kt.useEffect(()=>{c.current?.focus(),d()},[d]),kt.useEffect(()=>{t===""&&(g(!1),d())},[t,d]);let f=kt.useMemo(()=>{let b=$t(t,a.quantity.decimals);return"value"in b&&b.value>i},[t,a.quantity.decimals,i]),[h,g]=kt.useState(!1),u=!h&&t===""?"0.00":t,v=t.trim()===""||t.trim()==="0";return(0,Mt.jsx)("div",{className:"sf-body sf-amount",children:(0,Mt.jsxs)("div",{className:"sf-amount-center",children:[(0,Mt.jsx)("span",{className:"sf-amount-usd",children:o!==void 0?Ao(o):"\xA0"}),(0,Mt.jsx)("div",{className:"sf-amount-input-wrap","data-over":f||void 0,"data-empty":v||void 0,onClick:()=>c.current?.focus(),children:(0,Mt.jsx)("input",{ref:c,className:"sf-amount-input",value:u,onChange:b=>{let w=b.target.value;if(h)n(w);else if(t===""){if(w.length<4)return;g(!0);let y=w.startsWith("0.00")?w.slice(4):w;n(y)}else g(!0),n(w)},placeholder:"0.00",inputMode:"decimal",autoComplete:"off","aria-label":`Amount in ${a.symbol}`,size:1})}),(0,Mt.jsxs)("div",{className:"sf-amount-balance",children:[(0,Mt.jsx)("span",{children:"Balance:"}),(0,Mt.jsxs)("button",{type:"button",className:"sf-amount-max",onClick:s,children:[r," ",a.symbol]})]})]})})}var St=H(require("react"),1);var Yc=new Set(["0xff42c13d927a6b9265236619161accb227b6d452","0x9364ea6790f6e0ecfaa5164085f2a7de34ec55fb"].map(e=>e.toLowerCase()));function pi(e){return Yc.has(e.toLowerCase())}var Fr={dev:"https://stg-bonding-curve-api.crosstoken.io/api",stage:"https://stg-bonding-curve-api.crosstoken.io/api",production:"https://bonding-curve-api.crosstoken.io/api"},di={cross:"https://contents.crosstoken.io/wallet/token/images/CROSS.svg",bsc:"https://contents.crosstoken.io/wallet/token/images/BSC.svg"};function $n(e,t){let n=Se[e];if(t===n.cross)return di.cross;if(t===n.bsc)return di.bsc}var Zc={dev:"https://dev-portrait.crosstoken.io",stage:"https://dev-portrait.crosstoken.io",production:"https://portrait.crosstoken.io"};function jt(e,t,n={}){if(!t||!t.startsWith("0x"))return;let{size:o=120,bg:r,format:i="png"}=n,a=Zc[e],s=r?`&bg=${r}`:"";return`${a}/portrait/evm/${t}.${i}?size=${o}${s}`}var Fe=require("react/jsx-runtime");function fi({size:e=20,className:t}){return(0,Fe.jsxs)("svg",{width:e,height:e,viewBox:"0 0 20 20",fill:"none",className:t,"aria-hidden":"true",children:[(0,Fe.jsx)("circle",{cx:"9",cy:"9",r:"6",stroke:"currentColor",strokeWidth:"1.7"}),(0,Fe.jsx)("path",{d:"m17 17-3.2-3.2",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round"})]})}function ui({size:e=20,className:t}){return(0,Fe.jsx)("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",className:t,"aria-hidden":"true",children:(0,Fe.jsx)("path",{d:"M9 2h6a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1H9a1 1 0 0 1-1-1V3a1 1 0 0 1 1-1zM8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2h-2M12 11v6M9 14h6",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round"})})}function mi({size:e=20,className:t}){return(0,Fe.jsxs)("svg",{width:e,height:e,viewBox:"0 0 20 20",fill:"none",className:t,"aria-hidden":"true",children:[(0,Fe.jsx)("circle",{cx:"10",cy:"10",r:"10",fill:"currentColor",opacity:"0.12"}),(0,Fe.jsx)("path",{d:"M7 7l6 6M13 7l-6 6",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round"})]})}function gi({size:e=16,className:t}){return(0,Fe.jsx)("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"none",className:t,"aria-hidden":"true",children:(0,Fe.jsx)("path",{d:"M8 3v10m0 0 4-4m-4 4-4-4",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})})}function hi({size:e=56,className:t}){return(0,Fe.jsxs)("svg",{width:e,height:e,viewBox:"0 0 56 56",fill:"none",className:t,"aria-hidden":"true",children:[(0,Fe.jsx)("circle",{cx:"28",cy:"28",r:"28",fill:"var(--ds-accent-primary-default, #00b4b7)"}),(0,Fe.jsx)("path",{d:"M17 28.5 24.2 35.5 39 20.5",stroke:"var(--ds-accent-primary-on, #ffffff)",strokeWidth:"4",strokeLinecap:"round",strokeLinejoin:"round"})]})}function bi({size:e=56,className:t}){return(0,Fe.jsxs)("svg",{width:e,height:e,viewBox:"0 0 56 56",fill:"none",className:t,"aria-hidden":"true",children:[(0,Fe.jsx)("circle",{cx:"28",cy:"28",r:"28",fill:"var(--ds-system-red-default, #da0b2e)"}),(0,Fe.jsx)("path",{d:"M20 20 36 36m0-16L20 36",stroke:"#ffffff",strokeWidth:"4",strokeLinecap:"round"})]})}var oe=require("react/jsx-runtime");function wi(e,t){return e.name||`Account ${(e.index??t)+1}`}function xi(e){return e.trim().slice(0,1).toUpperCase()||"A"}function vi(e){return e.toLowerCase()}function yi({flow:e}){let{recipient:t,setRecipient:n,fieldErrors:o,recentAddresses:r,accounts:i,walletAddress:a,resolvedEnv:s,selectRecipient:c}=e,d=St.useMemo(()=>i.filter(m=>m.address.toLowerCase()!==a.toLowerCase()),[i,a]),f=d.length>0,h=St.useMemo(()=>new Map(d.map((m,C)=>[vi(m.address),{account:m,index:C}])),[d]),[g,u]=St.useState("recent"),v=St.useRef(null);St.useEffect(()=>{v.current?.focus()},[]);let b="1A1A2E",w=St.useCallback(async()=>{try{let m=await navigator.clipboard.readText();m&&n(m.trim())}catch{}},[n]),y=t.trim().length>0,E=_t(t.trim());return(0,oe.jsxs)("div",{className:"sf-recipient",children:[(0,oe.jsxs)("div",{className:"sf-recipient-top",children:[(0,oe.jsxs)("div",{className:"sf-address-field","data-filled":y||void 0,"data-invalid":o.recipient||void 0,children:[(0,oe.jsx)("textarea",{ref:v,className:"sf-address-input",value:t,onChange:m=>n(m.target.value),placeholder:"Enter the recipient's address",autoComplete:"off",spellCheck:!1,"aria-label":"Recipient address",rows:y?2:1}),y?(0,oe.jsx)("button",{type:"button",className:"sf-address-action",onClick:()=>n(""),"aria-label":"Clear",children:(0,oe.jsx)(mi,{size:20})}):(0,oe.jsx)("button",{type:"button",className:"sf-address-action",onClick:w,"aria-label":"Paste from clipboard",children:(0,oe.jsx)(ui,{size:20})})]}),o.recipient&&(0,oe.jsx)("p",{className:"sf-field-error",role:"alert",children:o.recipient}),(0,oe.jsxs)("div",{className:"sf-tabs",role:"tablist",children:[(0,oe.jsx)("button",{type:"button",role:"tab",className:"sf-tab","data-active":g==="recent"||void 0,"aria-selected":g==="recent",onClick:()=>u("recent"),children:"Recent"}),f&&(0,oe.jsx)("button",{type:"button",role:"tab",className:"sf-tab","data-active":g==="account"||void 0,"aria-selected":g==="account",onClick:()=>u("account"),children:"My Account"})]})]}),(0,oe.jsx)("div",{className:"sf-address-list",children:g==="account"&&f?d.map((m,C)=>{let R=wi(m,C),k=jt(s,m.address,{size:56,bg:b});return(0,oe.jsxs)("button",{type:"button",className:"sf-address-row",onClick:()=>c(m.address),children:[(0,oe.jsxs)("span",{className:"sf-address-avatar",children:[k&&(0,oe.jsx)("img",{src:k,alt:"",width:40,height:40,draggable:!1,onError:T=>{T.currentTarget.style.display="none"}}),(0,oe.jsx)("span",{className:"sf-address-avatar-fallback",children:xi(R)})]}),(0,oe.jsxs)("span",{className:"sf-address-meta",children:[(0,oe.jsx)("span",{className:"sf-address-name",children:R}),(0,oe.jsx)("span",{className:"sf-address-value",children:lt(m.address)})]})]},m.address)}):r.length>0?r.map(m=>{let C=h.get(vi(m.address)),R=C?wi(C.account,C.index):lt(m.address),k=jt(s,m.address,{size:56,bg:b});return(0,oe.jsxs)("button",{type:"button",className:"sf-address-row",onClick:()=>c(m.address),children:[(0,oe.jsxs)("span",{className:"sf-address-avatar",children:[k&&(0,oe.jsx)("img",{src:k,alt:"",width:40,height:40,draggable:!1,onError:T=>{T.currentTarget.style.display="none"}}),(0,oe.jsx)("span",{className:"sf-address-avatar-fallback",children:xi(R)})]}),(0,oe.jsxs)("span",{className:"sf-address-meta",children:[(0,oe.jsx)("span",{className:"sf-address-name",children:R}),(0,oe.jsx)("span",{className:"sf-address-value",children:lt(m.address)})]})]},m.address)}):(0,oe.jsx)("div",{className:"sf-empty",children:"No send history"})}),y&&!E&&!o.recipient&&(0,oe.jsx)("p",{className:"sf-field-error",role:"alert",children:"Enter a valid EVM recipient address."})]})}var ge=require("react/jsx-runtime");function Si({flow:e}){let{status:t,txHash:n,error:o,copyHash:r,hashCopied:i,openTransaction:a}=e,s=t==="error",c=t==="success";return s?(0,ge.jsxs)("div",{className:"sf-body sf-result sf-result--error",children:[(0,ge.jsx)("span",{className:"sf-result-icon",children:(0,ge.jsx)(bi,{size:56})}),(0,ge.jsxs)("div",{className:"sf-result-copy",children:[(0,ge.jsx)("h3",{className:"sf-result-title",children:"Transaction Failed"}),(0,ge.jsx)("p",{className:"sf-result-desc",children:o||"Something went wrong. Please try again."})]}),n&&(0,ge.jsx)(ki,{txHash:n,hashCopied:i,onCopy:r,onOpen:a})]}):(0,ge.jsxs)("div",{className:"sf-body sf-result",children:[(0,ge.jsx)("span",{className:"sf-result-icon","data-pending":!c||void 0,children:c?(0,ge.jsx)(hi,{size:56}):(0,ge.jsx)("span",{className:"sf-result-spinner"})}),(0,ge.jsxs)("div",{className:"sf-result-copy",children:[(0,ge.jsx)("h3",{className:"sf-result-title",children:c?"Transaction Complete":"Transaction in Progress"}),(0,ge.jsx)("p",{className:"sf-result-desc",children:c?"Your transfer was sent successfully.":"Transfer in progress. Waiting for confirmation."})]}),n&&(0,ge.jsx)(ki,{txHash:n,hashCopied:i,onCopy:r,onOpen:a})]})}function ki({txHash:e,hashCopied:t,onCopy:n,onOpen:o}){return(0,ge.jsxs)("div",{className:"sf-result-hash-card",children:[(0,ge.jsx)("span",{className:"sf-result-hash-label",children:"Transaction Hash"}),(0,ge.jsxs)("div",{className:"sf-result-hash-row",children:[(0,ge.jsx)("button",{type:"button",className:"sf-result-hash-link",onClick:o,"aria-label":"Open transaction in explorer",children:lt(e)}),(0,ge.jsx)("button",{type:"button",className:"sf-result-copy-btn",onClick:n,"aria-label":"Copy transaction hash",children:t?(0,ge.jsx)(cn,{size:16}):"Copy"})]})]})}var X=require("react/jsx-runtime"),Bo="\u2014";function Ri({flow:e}){let{token:t,reviewRawAmount:n,reviewRecipient:o,accountName:r,accounts:i,walletAddress:a,networkName:s,nativeSymbol:c,nativeDecimals:d,gasEstimate:f,gasLoading:h,gasError:g,insufficientGas:u,error:v,resolvedEnv:b}=e,w=en(t),y=n!==null?No(n,t.quantity.decimals):"",E=r?.trim()||`Account ${(i[0]?.index??0)+1}`,m=jt(b,a,{size:56,bg:"1A1A2E"}),C=c||(w?t.symbol:""),R=Io(t.chainId),k=f?ei(f,R):null,T=f?Lo(f,R):null,G=A=>A!==null&&C?`${Er(A,d)} ${C}`:Bo,F=A=>A!==void 0?`${Xa(A)} Gwei`:Bo,K=(()=>{if(!w||!f||T===null||n===null)return Bo;let A=n+T;return`${Er(A,d)} ${C||t.symbol}`})(),D=A=>h?"\u2026":A,Q=[{label:"Est. Tx Fee",value:D(G(T))},...k==="dynamic"?[{label:"Max Priority Fee",value:D(F(f?.maxPriorityFeePerGas))},{label:"Max Gas Fee",value:D(F(f?.maxFeePerGas))}]:k==="legacy"?[{label:"Gas Price",value:D(F(f?Eo(f):void 0))}]:[],{label:"Gas Limit",value:D(f?Ja(f.gasLimit):Bo)}];return(0,X.jsxs)("div",{className:"sf-body sf-review",children:[(0,X.jsxs)("div",{className:"sf-review-amount",children:[(0,X.jsx)("img",{className:"sf-review-amount-icon",src:t.icon_url,alt:"",width:40,height:40,draggable:!1,onError:A=>{A.currentTarget.src="https://contents.crosstoken.io/wallet/token/images/FT.png"}}),(0,X.jsxs)("span",{className:"sf-review-amount-value",children:[y,(0,X.jsx)("span",{className:"sf-review-amount-symbol",children:t.symbol})]})]}),(0,X.jsxs)("div",{className:"sf-review-parties",children:[(0,X.jsxs)("div",{className:"sf-review-card sf-review-party",children:[(0,X.jsx)("span",{className:"sf-review-party-label",children:"From"}),(0,X.jsxs)("div",{className:"sf-review-party-head",children:[(0,X.jsx)("span",{className:"sf-review-party-avatar",children:m&&(0,X.jsx)("img",{src:m,alt:"",width:28,height:28,draggable:!1,onError:A=>{A.currentTarget.style.display="none"}})}),(0,X.jsx)("span",{className:"sf-review-party-name",children:E})]}),(0,X.jsx)("span",{className:"sf-review-party-addr",children:a})]}),(0,X.jsx)("span",{className:"sf-review-arrow","aria-hidden":!0,children:(0,X.jsx)(gi,{size:16})}),(0,X.jsxs)("div",{className:"sf-review-card sf-review-party",children:[(0,X.jsx)("span",{className:"sf-review-party-label",children:"To"}),(0,X.jsx)("span",{className:"sf-review-party-addr",children:o})]})]}),(0,X.jsxs)("section",{className:"sf-review-card",children:[(0,X.jsx)("h3",{className:"sf-review-section-title",children:"Summary"}),(0,X.jsxs)("div",{className:"sf-review-row",children:[(0,X.jsx)("span",{className:"sf-review-row-label",children:"Network"}),(0,X.jsx)("span",{className:"sf-review-row-value",children:s})]}),Q.map(A=>(0,X.jsxs)("div",{className:"sf-review-row",children:[(0,X.jsx)("span",{className:"sf-review-row-label",children:A.label}),(0,X.jsx)("span",{className:"sf-review-row-value",children:A.value})]},A.label))]}),(0,X.jsxs)("section",{className:"sf-review-card",children:[(0,X.jsx)("h3",{className:"sf-review-section-title",children:"Total"}),(0,X.jsxs)("div",{className:"sf-review-row",children:[(0,X.jsx)("span",{className:"sf-review-row-label",children:"Total Amount"}),(0,X.jsxs)("span",{className:"sf-review-row-value",children:[y," ",t.symbol]})]}),w&&(0,X.jsxs)("div",{className:"sf-review-row",children:[(0,X.jsx)("span",{className:"sf-review-row-label",children:"Max. Total Amount"}),(0,X.jsx)("span",{className:"sf-review-row-value",children:D(K)})]})]}),u&&!g&&!v&&(0,X.jsxs)("div",{className:"sf-message sf-message--error",role:"alert",children:["Not enough ",C||t.symbol," to cover the amount plus the network fee. Reduce the amount and try again."]}),(g||v)&&(0,X.jsx)("div",{className:"sf-message sf-message--error",role:"alert",children:g||v})]})}var _o=H(require("react"),1);var We=require("react/jsx-runtime");function Ci({flow:e}){let[t,n]=_o.useState(""),o=t.trim().toLowerCase(),r=_o.useMemo(()=>o?e.tokens.filter(i=>i.symbol.toLowerCase().includes(o)||i.name.toLowerCase().includes(o)):e.tokens,[e.tokens,o]);return(0,We.jsxs)("div",{className:"sf-body sf-token-select",children:[(0,We.jsxs)("div",{className:"sf-search",children:[(0,We.jsx)(fi,{size:20}),(0,We.jsx)("input",{className:"sf-search-input",value:t,onChange:i=>n(i.target.value),placeholder:"Search Tokens",autoComplete:"off",spellCheck:!1,"aria-label":"Search tokens"})]}),(0,We.jsxs)("div",{className:"sf-token-list",children:[r.map(i=>{let a=`${i.chainId}:${i.address.toLowerCase()}`,s=$n(e.resolvedEnv,i.chainId),c=e.getTokenPriceUsd?.(i);return(0,We.jsxs)("button",{type:"button",className:"sf-token-row",onClick:()=>e.selectToken(i),children:[(0,We.jsxs)("span",{className:"sf-token-left",children:[(0,We.jsxs)("span",{className:"sf-token-icon-wrap",children:[(0,We.jsx)("img",{className:"sf-token-icon",src:i.icon_url,alt:"",width:40,height:40,loading:"lazy",draggable:!1,onError:d=>{d.currentTarget.src="https://contents.crosstoken.io/wallet/token/images/FT.png"}}),s&&(0,We.jsx)("img",{className:"sf-token-chain-badge",src:s,alt:"","aria-hidden":!0,width:16,height:16,loading:"lazy",draggable:!1,onError:d=>{d.currentTarget.style.display="none"}})]}),(0,We.jsx)("span",{className:"sf-token-name",children:i.symbol})]}),(0,We.jsxs)("span",{className:"sf-token-right",children:[(0,We.jsx)("span",{className:"sf-token-balance",children:Jt(i.quantity.numeric,i.quantity.decimals)}),c!==void 0&&(0,We.jsx)("span",{className:"sf-token-price",children:Ao(c)})]})]},a)}),r.length===0&&(0,We.jsx)("div",{className:"sf-empty",children:"No tokens found"})]})]})}j(`.sf-root{display:flex;flex-direction:column;flex:1;min-height:0;font-family:inherit}.sf-header{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:24px;flex-shrink:0;position:relative;border-bottom:1px solid var(--ds-border-default, rgba(0, 0, 0, .07))}.sf-header .sf-header-btn:last-child{position:absolute;top:24px;right:24px}.sf-header-btn{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;flex-shrink:0;padding:0;border:none;background:transparent;color:var(--ds-content-low, rgba(0, 0, 0, .4));cursor:pointer;filter:none;transition:color .15s ease}.sf-header-btn:hover{color:var(--ds-content-high, rgba(0, 0, 0, .85));filter:none}.sf-header-title{position:absolute;left:50%;transform:translate(-50%);text-align:center;font-family:inherit;font-size:18px;font-weight:600;line-height:1.5;letter-spacing:-.01em;color:var(--ds-content-highest, #000000);pointer-events:none}.sf-body{flex:1;min-height:0;overflow-y:auto;overflow-x:hidden;scrollbar-width:thin;scrollbar-color:rgba(255,255,255,.15) transparent;overscroll-behavior:contain}[data-theme=light] .sf-body{scrollbar-color:rgba(0,0,0,.12) transparent}.sf-body::-webkit-scrollbar{width:4px;height:4px}.sf-body::-webkit-scrollbar-track,.sf-body::-webkit-scrollbar-corner{background:transparent}.sf-body::-webkit-scrollbar-thumb{border-radius:4px;background:#ffffff26}.sf-body::-webkit-scrollbar-thumb:hover{background:#ffffff40}[data-theme=light] .sf-body::-webkit-scrollbar-thumb{background:#0000001f}[data-theme=light] .sf-body::-webkit-scrollbar-thumb:hover{background:#0003}.sf-empty{padding:32px 0;text-align:center;font-family:inherit;font-size:14px;color:var(--ds-content-low, rgba(0, 0, 0, .4))}.sf-field-error{margin:8px 24px 0;font-family:inherit;font-size:12px;line-height:1.5;color:var(--ds-system-red-default, #da0b2e)}.sf-message--error{margin:16px 0 0;padding:12px 16px;background:var(--ds-system-red-low, #ffeeee);color:var(--ds-system-red-high, #d20609);font-family:inherit;font-size:13px;line-height:1.5;border-radius:12px;width:100%;box-sizing:border-box}.sf-footer{display:flex;flex-shrink:0;padding:16px 24px 24px}.sf-footer:empty{display:none}.sf-footer-row{display:flex;gap:8px;width:100%}.sf-footer-row .sf-btn,.sf-footer-row .sf-btn--secondary{flex:1 1 0;min-width:0}.sf-footer>.sf-btn{width:100%}.sf-btn{appearance:none;display:inline-flex;align-items:center;justify-content:center;flex:1;height:48px;padding:0 24px;border:none;border-radius:12px;font-family:inherit;font-size:16px;font-weight:600;line-height:1.5;letter-spacing:-.01em;cursor:pointer;transition:background-color .15s ease,transform .1s ease}.sf-btn--primary{background:var(--ds-accent-primary-default, #00b4b7);color:var(--ds-accent-primary-on, #ffffff)}.sf-btn--primary:hover:not(:disabled):not([data-disabled]){background:var(--ds-accent-primary-high, #00a0a2)}.sf-btn--primary:active:not(:disabled):not([data-disabled]){transform:scale(.97)}.sf-btn--primary[data-disabled],.sf-btn--primary:disabled{background:var(--ds-accent-primary-default, #00b4b7);color:var(--ds-accent-primary-on, #ffffff);cursor:default;opacity:.5}.sf-btn--secondary{flex:0 0 120px;background:var(--ds-surface-default, #ffffff);border:1px solid var(--ds-border-default, rgba(0, 0, 0, .07));color:var(--ds-content-high, rgba(0, 0, 0, .85))}.sf-token-select{padding:0;display:flex;flex-direction:column}.sf-token-select .sf-search{margin:16px 24px}.sf-token-select .sf-token-list{width:100%;margin-top:0}.sf-search{display:flex;align-items:center;gap:8px;padding:12px 16px;border-radius:12px;border:1.5px solid transparent;background:var(--ds-surface-medium, #f5f7fa);color:var(--ds-content-low, rgba(0, 0, 0, .4));box-sizing:border-box;transition:border-color .15s ease}.sf-search:hover{border-color:var(--ds-border-medium, rgba(0, 0, 0, .18))}.sf-search:focus-within{border-color:var(--ds-accent-primary-default, #00b4b7)}.sf-search-input{flex:1;min-width:0;border:none;background:transparent;outline:none;font-family:inherit;font-size:16px;font-weight:500;line-height:1.5;letter-spacing:-.01em;color:var(--ds-content-high, rgba(0, 0, 0, .85))}.sf-search-input::placeholder{color:var(--ds-content-low, rgba(0, 0, 0, .4))}.sf-token-list{display:flex;flex-direction:column;margin-top:8px}.sf-token-row{display:flex;align-items:center;justify-content:space-between;gap:8px;width:100%;padding:12px 24px;border:none;background:transparent;cursor:pointer;text-align:left;font-family:inherit;border-radius:0;box-sizing:border-box;transition:background-color .15s ease}.sf-token-row:hover{background:var(--ds-surface-medium, rgba(0, 0, 0, .04))}.sf-token-left{display:flex;align-items:center;gap:16px;min-width:0}.sf-token-icon-wrap{position:relative;width:40px;height:40px;flex-shrink:0}.sf-token-icon{width:40px;height:40px;border-radius:0;object-fit:contain}.sf-token-chain-badge{position:absolute;right:-2px;bottom:-2px;width:16px;height:16px;border-radius:50%;object-fit:cover}.sf-token-name{font-family:inherit;font-size:16px;font-weight:600;line-height:1.5;letter-spacing:-.01em;color:var(--ds-content-high, rgba(0, 0, 0, .85));white-space:nowrap}.sf-token-right{display:flex;flex-direction:column;align-items:flex-end;flex-shrink:0}.sf-token-balance{font-family:inherit;font-size:16px;font-weight:600;line-height:1.5;letter-spacing:-.01em;color:var(--ds-content-highest, #000000);white-space:nowrap}.sf-token-price{font-family:inherit;font-size:14px;font-weight:500;line-height:1.5;letter-spacing:-.01em;color:var(--ds-content-low, rgba(0, 0, 0, .4));white-space:nowrap}.sf-recipient{display:flex;flex-direction:column;flex:1;min-height:0}.sf-recipient-top{display:flex;flex-direction:column;flex-shrink:0;padding:16px 24px 0}.sf-address-field{display:flex;align-items:center;gap:8px;padding:12px;border-radius:12px;border:1.5px solid transparent;background:var(--ds-surface-medium, #f5f7fa);transition:border-color .15s ease;box-sizing:border-box}.sf-address-field:hover{border-color:var(--ds-border-medium, rgba(0, 0, 0, .18))}.sf-address-field:focus-within{border-color:var(--ds-accent-primary-default, #00b4b7)}.sf-address-field[data-filled]{border-color:var(--ds-accent-primary-default, #00b4b7)}.sf-address-field[data-invalid]{border-color:var(--ds-system-red-default, #da0b2e)}.sf-address-input{flex:1;min-width:0;border:none;background:transparent;outline:none;resize:none;overflow:hidden;font-family:inherit;font-size:16px;font-weight:500;line-height:1.5;letter-spacing:-.01em;color:var(--ds-content-high, rgba(0, 0, 0, .85));word-break:break-word;overflow-wrap:anywhere}.sf-address-input::placeholder{color:var(--ds-content-low, rgba(0, 0, 0, .4))}.sf-address-action{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;flex-shrink:0;padding:0;border:none;background:transparent;border-radius:6px;color:var(--ds-content-low, rgba(0, 0, 0, .4));cursor:pointer;transition:color .15s ease}.sf-address-action:hover{color:var(--ds-content-high, rgba(0, 0, 0, .85))}.sf-address-field[data-filled] .sf-address-action{border-radius:9999px}.sf-tabs{display:flex;gap:0;margin:16px 0 0}.sf-tab{position:relative;padding:8px 12px;border:none;background:transparent;cursor:pointer;font-family:inherit;font-size:16px;font-weight:600;letter-spacing:-.01em;color:var(--ds-content-low, rgba(0, 0, 0, .4))}.sf-tab[data-active]{color:var(--ds-accent-primary-high, #00a0a2)}.sf-tab[data-active]:after{content:"";position:absolute;left:0;right:0;bottom:-1px;height:3px;border-radius:9999px;background:var(--ds-accent-primary-high, #00a0a2)}.sf-address-list{display:flex;flex-direction:column;flex:1;min-height:0;width:100%;margin-top:8px;overflow-y:auto;overflow-x:hidden;overscroll-behavior:contain;scrollbar-width:thin;scrollbar-color:rgba(255,255,255,.15) transparent}[data-theme=light] .sf-address-list{scrollbar-color:rgba(0,0,0,.12) transparent}.sf-address-list::-webkit-scrollbar{width:4px}.sf-address-list::-webkit-scrollbar-track{background:transparent}.sf-address-list::-webkit-scrollbar-thumb{border-radius:4px;background:#ffffff26}[data-theme=light] .sf-address-list::-webkit-scrollbar-thumb{background:#0000001f}.sf-address-row{display:flex;align-items:center;gap:16px;width:100%;padding:12px 24px;border:none;background:transparent;cursor:pointer;text-align:left;font-family:inherit;border-radius:0;box-sizing:border-box;transition:background-color .15s ease}.sf-address-row:hover{background:var(--ds-surface-medium, rgba(0, 0, 0, .04))}.sf-address-avatar{position:relative;display:inline-flex;align-items:center;justify-content:center;width:32px;height:32px;flex-shrink:0;border-radius:50%;overflow:hidden;background:var(--ds-surface-high, #edf1f2);color:var(--ds-content-medium, rgba(0, 0, 0, .65));font-size:14px;font-weight:600}.sf-address-avatar img{position:absolute;inset:0;z-index:1;width:100%;height:100%;object-fit:cover}.sf-address-avatar-fallback{position:relative;z-index:0}.sf-address-meta{display:flex;flex-direction:column;min-width:0}.sf-address-name{font-family:inherit;font-size:16px;font-weight:600;line-height:1.5;letter-spacing:-.01em;color:var(--ds-content-high, rgba(0, 0, 0, .85));white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.sf-address-value{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;font-size:14px;font-weight:500;line-height:1.5;letter-spacing:-.01em;color:var(--ds-content-low, rgba(0, 0, 0, .4))}.wi-drawer-content .sf-header{padding:16px}.wi-drawer-content .sf-header .sf-header-btn:last-child{top:16px;right:16px}.wi-drawer-content .sf-token-select{padding:0}.wi-drawer-content .sf-token-select .sf-search{margin:16px}.wi-drawer-content .sf-token-row{padding:12px 16px}.wi-drawer-content .sf-recipient-top{padding:16px 16px 0}.wi-drawer-content .sf-address-row{padding:12px 16px}.wi-drawer-content .sf-footer{padding:12px 16px 24px}.wi-drawer-content .sf-field-error,.wi-drawer-content .sf-message--error{margin:16px 0 0;width:auto}.sf-amount{display:flex;flex-direction:column}.sf-amount-center{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:flex-start;gap:8px;padding:64px 24px 48px;text-align:center}.sf-amount-usd{font-family:inherit;font-size:14px;font-weight:400;line-height:1.5;letter-spacing:-.01em;color:var(--ds-content-low, rgba(0, 0, 0, .4));min-height:21px}.sf-amount-input-wrap{display:flex;justify-content:center;max-width:100%}.sf-amount-input{width:auto;max-width:100%;border:none;background:transparent;outline:none;text-align:center;font-family:inherit;font-size:40px;font-weight:700;line-height:1.25;letter-spacing:-.01em;color:var(--ds-content-highest, #000000);field-sizing:content}.sf-amount-input-wrap[data-empty] .sf-amount-input,.sf-amount-input::placeholder{color:var(--ds-content-low, rgba(0, 0, 0, .4))}.sf-amount-input-wrap[data-over] .sf-amount-input{color:var(--ds-system-red-default, #da0b2e)}.sf-amount-balance{display:inline-flex;align-items:center;gap:4px;font-family:inherit;font-size:14px;font-weight:400;letter-spacing:-.01em;color:var(--ds-content-low, rgba(0, 0, 0, .4))}.sf-amount-max{border:none;background:transparent;padding:0;cursor:pointer;font:inherit;color:var(--ds-content-medium, rgba(0, 0, 0, .65));text-decoration:underline;text-underline-offset:2px;transition:color .15s ease}.sf-amount-max:hover{color:var(--ds-content-high, rgba(0, 0, 0, .85))}.wi-drawer-content .sf-amount-center{padding:64px 16px 48px}.sf-review{display:flex;flex-direction:column;gap:16px;padding:24px}.sf-review-amount{display:flex;align-items:center;gap:12px;padding:0;background:transparent}.sf-review-amount-icon{width:40px;height:40px;border-radius:0;object-fit:contain;flex-shrink:0}.sf-review-amount-value{display:inline-flex;flex-direction:column;align-items:flex-start;gap:0;font-family:inherit;font-size:16px;font-weight:600;line-height:1.5;letter-spacing:-.01em;color:var(--ds-content-highest, #000000);word-break:break-all}.sf-review-amount-symbol{font-size:12px;font-weight:400;line-height:1.5;color:var(--ds-content-medium, rgba(0, 0, 0, .65))}.sf-review-parties{position:relative;display:flex;flex-direction:column;gap:0}.sf-review-arrow{position:relative;z-index:1;display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;margin:-4px auto;border-radius:50%;background:var(--ds-surface-default, #ffffff);border:1px solid var(--ds-border-medium, rgba(0, 0, 0, .18));color:var(--ds-content-medium, rgba(0, 0, 0, .65))}.sf-review-card{display:flex;flex-direction:column;gap:8px;padding:16px;border-radius:12px;background:var(--ds-surface-medium, #f5f7fa)}.sf-review-party-label{font-family:inherit;font-size:12px;font-weight:500;line-height:1.5;letter-spacing:-.01em;color:var(--ds-content-medium, rgba(0, 0, 0, .65))}.sf-review-party-head{display:flex;align-items:center;gap:8px}.sf-review-party-avatar{display:inline-flex;width:24px;height:24px;border-radius:50%;overflow:hidden;background:var(--ds-surface-high, #edf1f2);flex-shrink:0}.sf-review-party-avatar img{width:100%;height:100%;object-fit:cover}.sf-review-party-name{font-family:inherit;font-size:14px;font-weight:600;line-height:1.5;letter-spacing:-.01em;color:var(--ds-content-high, rgba(0, 0, 0, .85))}.sf-review-party-addr{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;font-size:12px;font-weight:400;line-height:1.5;letter-spacing:-.01em;color:var(--ds-content-medium, rgba(0, 0, 0, .65));word-break:break-all}.sf-review-section-title{margin:0 0 4px;font-family:inherit;font-size:16px;font-weight:600;letter-spacing:-.01em;color:var(--ds-content-highest, #000000)}.sf-review-row{display:flex;flex-direction:column;align-items:flex-start;gap:4px}.sf-review-row-label{font-family:inherit;font-size:12px;font-weight:400;line-height:1.5;letter-spacing:-.01em;color:var(--ds-content-medium, rgba(0, 0, 0, .65))}.sf-review-row-value{font-family:inherit;font-size:14px;font-weight:500;line-height:1.5;letter-spacing:-.01em;color:var(--ds-content-high, rgba(0, 0, 0, .85));text-align:left;word-break:break-all}.wi-drawer-content .sf-review{padding:16px}.sf-result{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:20px;padding:48px 24px;text-align:center}.sf-result-icon{display:inline-flex;align-items:center;justify-content:center;width:56px;height:56px}.sf-result-spinner{width:56px;height:56px;border-radius:50%;border:4px solid var(--ds-border-medium, rgba(0, 0, 0, .18));border-top-color:var(--ds-accent-primary-default, #00b4b7);animation:sf-spin .8s linear infinite}@keyframes sf-spin{to{transform:rotate(360deg)}}.sf-result-copy{display:flex;flex-direction:column;gap:8px}.sf-result-title{margin:0;font-family:inherit;font-size:18px;font-weight:600;letter-spacing:-.01em;color:var(--ds-content-highest, #000000)}.sf-result-desc{margin:0;font-family:inherit;font-size:14px;font-weight:400;line-height:1.5;letter-spacing:-.01em;color:var(--ds-content-medium, rgba(0, 0, 0, .65))}.sf-result-hash-card{display:flex;flex-direction:column;gap:8px;width:100%;padding:16px;border-radius:12px;background:var(--ds-surface-medium, #f5f7fa);text-align:left}.sf-result-hash-label{font-family:inherit;font-size:12px;font-weight:500;letter-spacing:-.01em;color:var(--ds-content-medium, rgba(0, 0, 0, .65))}.sf-result-hash-row{display:flex;align-items:center;justify-content:space-between;gap:8px}.sf-result-hash-link{border:none;background:transparent;padding:0;cursor:pointer;font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;font-size:14px;color:var(--ds-accent-primary-high, #00a0a2)}.sf-result-copy-btn{display:inline-flex;align-items:center;justify-content:center;min-width:44px;height:28px;padding:0 10px;border:1px solid var(--ds-border-default, rgba(0, 0, 0, .07));border-radius:8px;background:var(--ds-surface-default, #ffffff);cursor:pointer;font-family:inherit;font-size:12px;font-weight:500;color:var(--ds-content-high, rgba(0, 0, 0, .85))}
|
|
7
7
|
`);var he=require("react/jsx-runtime"),Xc={token:"Send",recipient:"Send",amount:"Send",review:"Sign Transaction",result:""};function jn({onClose:e,onBackToWallet:t,onConfirmSuccess:n,onSuccess:o,className:r,...i}){let a=Ti.useCallback(y=>{o?.(y),n?.(y)},[n,o]),c=li({...i,onSuccess:o||n?a:void 0,onExit:t}),{step:d,status:f}=c,h=_t(c.recipient.trim()),g=$t(c.amount,c.token.quantity.decimals),u="value"in g&&g.value<=c.balanceRaw,v=f==="submitting"||f==="confirming",b=d!=="result",w=Xc[d]??"";return(0,he.jsxs)("div",{className:se("sf-root",r),"data-step":d,children:[(0,he.jsxs)("header",{className:"sf-header",children:[b?(0,he.jsx)("button",{type:"button",className:"sf-header-btn",onClick:c.back,"aria-label":"Back",children:(0,he.jsx)(dn,{size:24})}):(0,he.jsx)("span",{className:"sf-header-btn","aria-hidden":!0}),(0,he.jsx)("span",{className:"sf-header-title",children:w}),(0,he.jsx)("button",{type:"button",className:"sf-header-btn",onClick:e,"aria-label":"Close",children:(0,he.jsx)(Bt,{size:24})})]}),d==="token"&&(0,he.jsx)(Ci,{flow:c}),d==="recipient"&&(0,he.jsx)(yi,{flow:c}),d==="amount"&&(0,he.jsx)(ci,{flow:c}),d==="review"&&(0,he.jsx)(Ri,{flow:c}),d==="result"&&(0,he.jsx)(Si,{flow:c}),(0,he.jsxs)("footer",{className:"sf-footer","data-step":d,children:[d==="recipient"&&(0,he.jsx)("button",{type:"button",className:"sf-btn sf-btn--primary",onClick:c.submitRecipient,"data-disabled":!h||void 0,"aria-disabled":!h,children:"Next"}),d==="amount"&&(0,he.jsx)("button",{type:"button",className:"sf-btn sf-btn--primary",onClick:c.submitAmount,"data-disabled":!u||void 0,"aria-disabled":!u,children:"Next"}),d==="review"&&(0,he.jsxs)("div",{className:"sf-footer-row",children:[(0,he.jsx)("button",{type:"button",className:"sf-btn sf-btn--secondary",onClick:c.back,disabled:v,children:"Cancel"}),(0,he.jsx)("button",{type:"button",className:"sf-btn sf-btn--primary",onClick:c.confirmSend,disabled:v||!c.canSend||c.insufficientGas,children:v?"Sending...":"Send"})]}),d==="result"&&f==="success"&&(0,he.jsx)("button",{type:"button",className:"sf-btn sf-btn--primary",onClick:()=>n?.(c.txHash||void 0),children:"All done"}),d==="result"&&f==="error"&&(0,he.jsx)("button",{type:"button",className:"sf-btn sf-btn--primary",onClick:c.retry,children:"Try Again"})]})]})}var Ni=H(require("@radix-ui/react-popover"),1),Ii=require("vaul");var fn=require("react/jsx-runtime");function Ei({asChild:e,className:t,children:n}){let{isMobile:o,theme:r,walletAddress:i}=Zt(),a=n!=null,s=e??!0,c=a?n:(0,fn.jsxs)("button",{type:"button",className:se("wi-trigger-btn",t),"data-theme":r,"data-mobile":o||void 0,children:[(0,fn.jsx)(_a,{size:o?14:16}),(0,fn.jsx)("span",{className:"wi-trigger-address",children:lt(i)})]});return o?(0,fn.jsx)(Ii.Drawer.Trigger,{asChild:s,children:c}):(0,fn.jsx)(Ni.Trigger,{asChild:s,children:c})}var W=H(require("react"),1),er=H(require("@radix-ui/react-popover"),1),Jn=require("vaul");var Pn=H(require("bignumber.js"),1);var Li=require("@tanstack/react-query"),Ai=require("react");var Mo="user-balance";async function Jc(e,t,n,o){let r=new URLSearchParams({networkId:`eip155:${t}`,account:n}),i=await fetch(`${e}/v1/public/token/balance?${r}`,{cache:"no-store",signal:o});if(!i.ok)throw new Error(`Failed to fetch token balance: ${i.status}`);let a=await i.json();if(a.code!==200)throw new Error(`Token balance API error: ${a.code}`);return a.data}function Vt(e,t,n=!0){let o=tt[e],r=Se[e],i=[r.cross,r.bsc],a=(0,Li.useQueries)({queries:i.map(f=>({queryKey:[Mo,e,t,f],queryFn:({signal:h})=>Jc(o,f,t,h),enabled:!!t&&n,staleTime:0,refetchInterval:n?5e3:!1}))}),s=a.some(f=>f.isLoading),c=a.some(f=>f.isError);return{tokens:(0,Ai.useMemo)(()=>{let f=[];for(let h of a)h.data&&f.push(...h.data);return f},[a]),isLoading:s,isError:c}}var Oo=require("@tanstack/react-query"),Pi=require("react");var ed="forge-holdings",td="forge-token-image";async function nd(e,t,n){let o=await fetch(`${e}/v1/users/${t}/holdings`,{cache:"no-store",signal:n});if(!o.ok)throw new Error(`Failed to fetch forge holdings: ${o.status}`);let r=await o.json();if(!r.success)throw new Error("Forge holdings API error");return r.data.items}async function od(e,t,n){let o=await fetch(`${e}/v1/tokens/${t}`,{cache:"no-store",signal:n});if(!o.ok)return{address:t,image_url:""};let r=await o.json();return r.success?{address:t,image_url:r.data.token.image_url}:{address:t,image_url:""}}function Fi(e,t,n=!0){let o=Fr[e],{data:r,...i}=(0,Oo.useQuery)({queryKey:[ed,e,t],queryFn:({signal:a})=>nd(o,t,a),enabled:!!t&&n,staleTime:0,refetchInterval:n?5e3:!1});return{holdings:r??[],...i}}function Bi(e,t,n=!0){let o=Fr[e],r=(0,Oo.useQueries)({queries:t.map(a=>({queryKey:[td,e,a],queryFn:({signal:s})=>od(o,a,s),enabled:n,staleTime:1/0}))});return{imageMap:(0,Pi.useMemo)(()=>{let a=new Map;for(let s of r)s.data&&a.set(s.data.address,s.data.image_url);return a},[r])}}var _i=require("@tanstack/react-query"),Mi=require("react");var Wo="token-stats";function Rt(e,t){return`${e}:${t.toLowerCase()}`}function qt(e,t=!0){let n=tt[e],{data:o,...r}=(0,_i.useQuery)({queryKey:[Wo,e],queryFn:async({signal:a})=>{let s=await fetch(`${n}/v1/public/token/stats`,{cache:"no-store",signal:a});if(!s.ok)throw new Error(`Failed to fetch token stats: ${s.status}`);let c=await s.json();if(c.code!==200)throw new Error(`Token stats API error: ${c.code}`);return c},enabled:t,staleTime:3e4});return{statsMap:(0,Mi.useMemo)(()=>{let a=new Map;if(!o?.data)return a;for(let s of o.data){let c=Rt(s.chain_id,s.address);a.set(c,s)}return a},[o]),...r}}var Oi=require("@tanstack/react-query"),rd="crossd-apy",ad="https://crossd-dashboard-api.crossdefi.io/api/v1/overview";function Wi(){let{data:e,...t}=(0,Oi.useQuery)({queryKey:[rd],queryFn:async({signal:n})=>{let o=await fetch(ad,{cache:"no-store",signal:n});if(!o.ok)throw new Error(`Failed to fetch CROSSD overview: ${o.status}`);let r=await o.json();if(r.code!==200)throw new Error(`CROSSD overview API error: ${r.code}`);let i=parseFloat(r.data.est_last_epoch_apy);if(!Number.isFinite(i))throw new Error("CROSSD overview returned a non-numeric APY");return i*100},staleTime:6e4});return{apyPercent:e??null,...t}}var Di=require("@tanstack/react-query"),zi=require("react");var id="token-info";function Br(e,t){return`${t.toLowerCase()}_${e}`}function Gi(e,t=!0){let n=tt[e],{data:o,...r}=(0,Di.useQuery)({queryKey:[id,e],queryFn:async({signal:a})=>{let s=await fetch(`${n}/v1/public/token/info`,{cache:"no-store",signal:a});if(!s.ok)throw new Error(`Failed to fetch token info: ${s.status}`);let c=await s.json();if(c.code!==200)throw new Error(`Token info API error: ${c.code}`);return c},enabled:t,staleTime:1/0});return{categoryMap:(0,zi.useMemo)(()=>{let a=new Map;if(!o?.data)return a;for(let s of o.data){let c=Br(s.chain_id,s.address);a.set(c,s.category)}return a},[o]),...r}}var Ui=require("react"),Do=H(require("bignumber.js"),1);function Hi(e,t,n){let{tokens:o,isLoading:r}=Vt(e,t,n),{statsMap:i}=qt(e,n);return(0,Ui.useMemo)(()=>{let a=new Do.default(0);for(let f of o){let h=i.get(Rt(f.chainId,f.address));if(!h)continue;let u=new Do.default(f.quantity.numeric).shiftedBy(-f.quantity.decimals).multipliedBy(new Do.default(h.price));u.isNaN()||(a=a.plus(u))}let s=a.toFixed(),{displayValue:c,isLowerBound:d}=Va(s);return{totalUsd:s,displayValue:c,isLowerBound:d,isLoading:r}},[o,i,r])}var El=require("qrcode.react");function Ze(e,t,n,o){if(!o||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||e.defaultPrevented)return;e.preventDefault();let r;try{r=o(t,n)}catch(d){console.error("[dapp-ui] onOutlink threw:",d);return}let i=d=>{typeof window>"u"||window.open(d,"_blank","noopener,noreferrer")};if((d=>!!d&&(typeof d=="object"||typeof d=="function")&&typeof d.then=="function")(r)){let d=typeof window<"u"?window.open("","_blank","noopener,noreferrer"):null,f=h=>{if(h===null){d?.close();return}let g=h??t;if(d)try{d.location.href=g}catch{d.close(),i(g)}else i(g)};r.then(f,h=>{console.error("[dapp-ui] onOutlink rejected:",h),d?.close()});return}let s=r;if(s===null)return;i(s??t)}var hn=H(require("react"),1),tl=require("vaul");var zo=require("react"),Vn=(0,zo.createContext)(null);function je(){let e=(0,zo.useContext)(Vn);if(!e)throw new Error("WalletPortfolio compound components must be used within <WalletPortfolio>");return e}var $i=require("vaul");var _r=require("react/jsx-runtime");function ji({asChild:e,children:t}){let{walletAddress:n}=je(),o=t!=null,r=e??!0,i=o?t:(0,_r.jsx)("button",{type:"button",children:lt(n)});return(0,_r.jsx)($i.Drawer.Trigger,{asChild:r,children:i})}var Yn=require("vaul");var De=H(require("react"),1),Js=require("@tanstack/react-query");var Ne=require("react/jsx-runtime");function Vi({size:e=22,className:t}){return(0,Ne.jsx)("svg",{width:e,height:e,viewBox:"0 0 22 22",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t,children:(0,Ne.jsx)("path",{d:"M14 4L7 11L14 18",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})})}function qi({size:e=22,className:t}){return(0,Ne.jsxs)("svg",{width:e,height:e,viewBox:"0 0 22 22",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t,children:[(0,Ne.jsx)("path",{d:"M18.333 3.667v5.5h-5.5",stroke:"currentColor",strokeWidth:1.833,strokeLinecap:"round",strokeLinejoin:"round"}),(0,Ne.jsx)("path",{d:"M16.17 13.75a7.333 7.333 0 11-1.54-7.59L18.333 9.167",stroke:"currentColor",strokeWidth:1.833,strokeLinecap:"round",strokeLinejoin:"round"})]})}function Ki({size:e=16,className:t}){return(0,Ne.jsxs)("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t,children:[(0,Ne.jsx)("path",{d:"M5.333 5.333V4a1.333 1.333 0 011.334-1.333h5.333A1.333 1.333 0 0113.333 4v5.333a1.333 1.333 0 01-1.333 1.334h-1.333",stroke:"currentColor",strokeWidth:1.333,strokeLinecap:"round",strokeLinejoin:"round"}),(0,Ne.jsx)("path",{d:"M4 5.333h5.333c.737 0 1.334.597 1.334 1.334V12c0 .736-.597 1.333-1.334 1.333H4A1.333 1.333 0 012.667 12V6.667C2.667 5.93 3.263 5.333 4 5.333z",stroke:"currentColor",strokeWidth:1.333,strokeLinecap:"round",strokeLinejoin:"round"})]})}function Qi({size:e=16,className:t}){return(0,Ne.jsx)("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t,children:(0,Ne.jsx)("path",{d:"M13.333 4L6 11.333 2.667 8",stroke:"currentColor",strokeWidth:1.667,strokeLinecap:"round",strokeLinejoin:"round"})})}function Yi({size:e=48,className:t}){return(0,Ne.jsxs)("svg",{width:e,height:e,viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t,children:[(0,Ne.jsx)("circle",{cx:"24",cy:"24",r:"24",fill:"currentColor"}),(0,Ne.jsx)("path",{d:"M14 24.5l6.6 6.6L34.5 17.5",stroke:"var(--wp-claim-success-mark, #ffffff)",strokeWidth:4,strokeLinecap:"round",strokeLinejoin:"round"})]})}function Ct({size:e=12,className:t}){return(0,Ne.jsxs)("svg",{width:e,height:e,viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t,"aria-hidden":"true",children:[(0,Ne.jsx)("path",{d:"M5 2H2.5A1.5 1.5 0 0 0 1 3.5V9.5A1.5 1.5 0 0 0 2.5 11H8.5A1.5 1.5 0 0 0 10 9.5V7",stroke:"currentColor",strokeWidth:1.2,strokeLinecap:"round",strokeLinejoin:"round"}),(0,Ne.jsx)("path",{d:"M7 1H11V5",stroke:"currentColor",strokeWidth:1.2,strokeLinecap:"round",strokeLinejoin:"round"}),(0,Ne.jsx)("path",{d:"M11 1L6 6",stroke:"currentColor",strokeWidth:1.2,strokeLinecap:"round",strokeLinejoin:"round"})]})}var ct=H(require("bignumber.js"),1),sd=/^(\d{4}-\d{2}-\d{2})/;function Zi(e){if(!e||e.length===0)return;let t=new Map,n;for(let{key:r,cumulative:i}of e.map(a=>({key:sd.exec(a.reference_date)?.[1],cumulative:a.cumulative_earned})).filter(a=>!!a.key&&a.cumulative!=null).sort((a,s)=>a.key<s.key?-1:a.key>s.key?1:0))t.set(r,i),n=r;if(n===void 0)return;let o=new Date().toISOString().slice(0,10);return t.get(o)??t.get(n)}function Go(e){return e.length<=12?e:`${e.slice(0,6)}...${e.slice(-4)}`}function Xi(e){return e.length<=13?e:`${e.slice(0,6)}...${e.slice(-4)}`}var ld="0xe00e8bf3";function Ji(e,t){let n=typeof e=="bigint"?e:BigInt(e);if(n<0n)throw new Error("poolId must be non-negative");if(t<0n)throw new Error("amount must be non-negative");let o=n.toString(16).padStart(64,"0"),r=t.toString(16).padStart(64,"0");return`${ld}${o}${r}`}function Mr(e){return!e||e<=0n?"0":new ct.default(e.toString()).shiftedBy(-9).toFormat(2,ct.default.ROUND_DOWN).replace(/(\.\d*?[1-9])0+$/,"$1").replace(/\.0+$/,"")}function es(e){return!e||e<=0n?"0":new ct.default(e.toString()).toFormat(0,ct.default.ROUND_DOWN)}function ts(e){if(!e||e<=0n)return"0";let t=new ct.default(e.toString()).shiftedBy(-18),n=t.isLessThan(1e-4)?7:4;return t.toFormat(n,ct.default.ROUND_DOWN).replace(/(\.\d*?[1-9])0+$/,"$1").replace(/\.0+$/,"")}function Tt(e,t){let n=new ct.default(e).shiftedBy(-t);return!n.isFinite()||n.isZero()?"0":n.isGreaterThanOrEqualTo(1)?n.toFormat(2,ct.default.ROUND_DOWN):n.toFormat(4,ct.default.ROUND_DOWN)}function Or(e){return Tt(e,0)}function tn(e,t,n){let o=new ct.default(n||"0");if(!o.isFinite()||o.isLessThanOrEqualTo(0))return null;let r=new ct.default(e||"0").shiftedBy(-t).times(o);return r.isFinite()?`$${r.toFormat(2,ct.default.ROUND_DOWN)}`:null}var ys=H(require("react"),1);var ls=require("@tanstack/react-query"),Wr=require("react");var In={dev:"https://stg-cross-game-reward-api.crosstoken.io/api",stage:"https://stg-cross-game-reward-api.crosstoken.io/api",production:"https://cross-game-reward-api.crosstoken.io/api"},ns={dev:"https://stg.onechain.nexus",stage:"https://stg.onechain.nexus",production:"https://onechain.nexus"},os={dev:"https://stg.onechain.nexus/points",stage:"https://stg.onechain.nexus/points",production:"https://www.onechain.nexus/points"},Uo={dev:"https://stg-bonding-curve-api.crosstoken.io/api",stage:"https://stg-bonding-curve-api.crosstoken.io/api",production:"https://bonding-curve-api.crosstoken.io/api"},rs={dev:"https://stg.onechain.nexus",stage:"https://stg.onechain.nexus",production:"https://onechain.nexus"},En={dev:"https://stg-posa-api.crosstoken.io/api/v1",stage:"https://stg-posa-api.crosstoken.io/api/v1",production:"https://posa-api.crosstoken.io/api/v1"},qn={dev:"https://dev-stake.ogfcorp.com",stage:"https://stg-stake.ogfcorp.com",production:"https://stake.ogfcorp.com"},as={dev:`${qn.dev}/portfolio`,stage:`${qn.stage}/portfolio`,production:`${qn.production}/portfolio`},is={dev:"https://stg-game-swap-api.cross.nexus/v1",stage:"https://stg-game-swap-api.cross.nexus/v1",production:"https://game-swap-api.cross.nexus/v1"},ss={dev:"https://stg.onechain.nexus",stage:"https://stg.onechain.nexus",production:"https://onechain.nexus"},Ot={dev:"https://stg-contents.crosstoken.io/frontend/common/app-launcher/icons",stage:"https://stg-contents.crosstoken.io/frontend/common/app-launcher/icons",production:"https://contents.crosstoken.io/frontend/common/app-launcher/icons"};var cd="wp:reward-pools";function Ln(e,t=!0){let n=In[e],{data:o,...r}=(0,ls.useQuery)({queryKey:[cd,e],queryFn:async({signal:s})=>{let c=await fetch(`${n}/v1/pools`,{cache:"no-store",signal:s});if(!c.ok)throw new Error(`Failed to fetch pools: ${c.status}`);let d=await c.json();if(d.code!==200)throw new Error(`Pools API error: ${d.code}`);return d},enabled:t,staleTime:0}),i=(0,Wr.useMemo)(()=>o?.data.pools.filter(s=>s.pool_type==="CrossPool")??[],[o]),a=(0,Wr.useMemo)(()=>o?.data.pools.filter(s=>s.pool_type==="GamePool")??[],[o]);return{crossPools:i,gamePools:a,allPools:o?.data.pools??[],...r}}var cs=require("@tanstack/react-query"),ds=require("react");var dd="wp:user-deposits";function Ho(e,t,n=!0){let o=In[e],r=n&&!!t,{data:i,...a}=(0,cs.useQuery)({queryKey:[dd,e,t],queryFn:async({signal:c})=>{let d=await fetch(`${o}/v1/users/${t}/deposits`,{cache:"no-store",signal:c});if(!d.ok)throw new Error(`Deposits fetch failed: ${d.status}`);let f=await d.json();if(f.code!==200)throw new Error(`Deposits API error: ${f.code}`);return f},enabled:r,staleTime:0});return{depositMap:(0,ds.useMemo)(()=>{let c=new Map;if(!i?.data.user_deposits)return c;for(let d of i.data.user_deposits)c.set(d.pool_address.toLowerCase(),d);return c},[i]),deposits:i?.data.user_deposits??[],...a}}var ps=require("@tanstack/react-query"),fs=require("react");var pd="wp:token-info";function $o(e,t=!0){let n=tt[e],o=Se[e].cross,{data:r,...i}=(0,ps.useQuery)({queryKey:[pd,e],queryFn:async({signal:d})=>{let f=await fetch(`${n}/v1/public/token/info`,{cache:"no-store",signal:d});if(!f.ok)throw new Error(`Failed to fetch token info: ${f.status}`);let h=await f.json();if(h.code!==200)throw new Error(`Token info API error: ${h.code}`);return h},enabled:t,staleTime:300*1e3}),{byChainAddr:a,byChainSym:s}=(0,fs.useMemo)(()=>{let d=new Map,f=new Map;if(!r?.data)return{byChainAddr:d,byChainSym:f};for(let h of r.data){let g=h.address.toLowerCase();d.set(`${h.chain_id}:${g}`,h),d.set(g,h);let u=h.symbol.replace(/^t/,"").toUpperCase(),v=`${h.chain_id}:${u}`;f.has(v)||f.set(v,h),f.has(u)||f.set(u,h)}return{byChainAddr:d,byChainSym:f}},[r]);return{getTokenImage:(d,f)=>{let h=d.toLowerCase(),g=a.get(`${o}:${h}`);if(g?.image)return g.image;let u=a.get(h);if(u?.image)return u.image;if(f){let v=f.replace(/^t/,"").toUpperCase(),b=s.get(`${o}:${v}`);if(b?.image)return b.image;let w=s.get(v);if(w?.image)return w.image}return""},...i}}var ms=require("@tanstack/react-query"),Qn=require("react");var fd="0x70a08231",ud="0x18160ddd",md="0x313ce567",gd=8e3;async function hd(e,t,n,o){let r=new AbortController,i=setTimeout(()=>r.abort(),gd);o&&o.addEventListener("abort",()=>r.abort(),{once:!0});let a=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",id:1,method:t,params:n}),signal:r.signal}).finally(()=>clearTimeout(i));if(!a.ok)throw new Error(`RPC ${t} HTTP ${a.status}`);let s=await a.json();if(s.error)throw new Error(`RPC ${t}: ${s.error.message}`);if(s.result===void 0)throw new Error(`RPC ${t}: empty result`);return s.result}function bd(e){return e.toLowerCase().replace(/^0x/,"").padStart(64,"0")}function Kn(e){if(!(!e||e==="0x"))try{return BigInt(e)}catch{return}}async function un(e,t,n,o){try{return await hd(e,"eth_call",[{to:t,data:n},"latest"],o)}catch{return}}async function wd(e,t,n,o){let[r,i,a]=await Promise.all([un(e,n,fd+bd(t),o),un(e,n,ud,o),un(e,n,md,o)]),s=Kn(r);if(s===void 0)return null;let c=Kn(a);return{balance:s,totalSupply:Kn(i),decimals:c!==void 0?Number(c):void 0}}async function Dr(e,t){let n=Se[e].cross,o=await fetch(`${tt[e]}/v1/public/chain/info/${n}`,{cache:"no-store",signal:t});if(!o.ok)return;let r=await o.json();return("data"in r&&r.data!==void 0?Array.isArray(r.data)?r.data[0]:r.data:r)?.rpc||void 0}async function us(e,t,n,o){if(!t||n.length===0)return{};let r;try{r=await Dr(e,o)}catch{r=void 0}if(!r)return{};let i=await Promise.all(n.map(async s=>[s.toLowerCase(),await wd(r,t,s,o)])),a={};for(let[s,c]of i)c&&(a[s]=c);return a}var xd="wp:withdraw-token-meta",vd="0xc89039c5",yd="0x95d89b41",kd="0x313ce567";function Sd(e){if(!(!e||e==="0x"))try{let t=e.replace(/^0x/,""),n=Number(BigInt("0x"+t.slice(64,128)));if(!Number.isFinite(n)||n<=0||n>64)return;let o=t.slice(128,128+n*2),r="";for(let i=0;i<o.length;i+=2)r+=String.fromCharCode(parseInt(o.slice(i,i+2),16));return r||void 0}catch{return}}function Rd(e){if(!e||e==="0x")return;let n="0x"+e.replace(/^0x/,"").padStart(64,"0").slice(24,64);return/^0x[a-f0-9]{40}$/.test(n)&&n!=="0x0000000000000000000000000000000000000000"?n:void 0}async function Cd(e,t,n){if(t.length===0)return{};let o;try{o=await Dr(e,n)}catch{o=void 0}if(!o)return{};let r=await Promise.all(t.map(async a=>{let s=Rd(await un(o,a,vd,n));if(!s)return[a.toLowerCase(),null];let[c,d]=await Promise.all([un(o,s,yd,n),un(o,s,kd,n)]),f=Sd(c),h=Kn(d);return f?[a.toLowerCase(),{tokenAddress:s,symbol:f,decimals:h!==void 0?Number(h):18}]:[a.toLowerCase(),null]})),i={};for(let[a,s]of r)s&&(i[a]=s);return i}function jo(e,t,n=!0){let r=n&&!!t,{allPools:i}=Ln(e,r),{deposits:a}=Ho(e,t,r),s=(0,Qn.useMemo)(()=>{let g=new Map;for(let u of i)g.set(u.pool_address.toLowerCase(),u);return g},[i]),c=(0,Qn.useMemo)(()=>a.filter(g=>{try{return BigInt(g.deposited_amount||"0")>0n}catch{return!1}}),[a]),d=(0,Qn.useMemo)(()=>c.map(g=>g.pool_address.toLowerCase()).filter(g=>!s.has(g)).sort(),[c,s]),{data:f}=(0,ms.useQuery)({queryKey:[xd,e,d],queryFn:({signal:g})=>Cd(e,d,g),enabled:r&&d.length>0,staleTime:1440*60*1e3});return{positions:(0,Qn.useMemo)(()=>{let g=[];for(let u of c){let v=u.pool_address.toLowerCase(),b=s.get(v);if(b){g.push({poolId:u.pool_id,poolAddress:u.pool_address,poolType:b.pool_type,tokenSymbol:b.deposit_token.symbol,tokenAddress:b.deposit_token.address,decimals:b.deposit_token.decimals,price:b.deposit_token.price,depositedRaw:u.deposited_amount});continue}let w=f?.[v];w&&g.push({poolId:u.pool_id,poolAddress:u.pool_address,poolType:"Unknown",tokenSymbol:w.symbol,tokenAddress:w.tokenAddress,decimals:w.decimals,depositedRaw:u.deposited_amount})}return g},[c,s,f])}}var nn=require("react/jsx-runtime");function Wt({title:e,icon:t,iconFit:n="cover",isEmpty:o,children:r}){return(0,nn.jsxs)("div",{className:"wp-svc-card",children:[(0,nn.jsxs)("div",{className:"wp-svc-card-head",children:[(0,nn.jsx)("img",{className:"wp-svc-card-icon",src:t,alt:"",style:{objectFit:n}}),(0,nn.jsx)("span",{className:"wp-svc-card-title",children:e})]}),o?(0,nn.jsx)("div",{className:"wp-svc-empty",children:"No assets yet"}):(0,nn.jsx)("div",{className:"wp-svc-items",children:r})]})}var xe=H(require("react"),1);var S=require("react/jsx-runtime"),Td=/^\d*\.?\d{0,2}$/,Nd=[100n,1000n,2000n],Id=400;function Ed(e,t){if(t==="loading")return"Estimating...";if(!e||t==="error"||t==="unavailable")return"Wallet estimate";let n=e.maxFeePerGas??e.gasPrice;return!n||n<=0n||e.gasLimit<=0n?"Wallet estimate":`${ts(e.gasLimit*n)} CROSS`}function zr(e,t,n){return n==="loading"?"Estimating...":n==="error"||n==="unavailable"?"-":`${e} ${t}`.trim()}function gs({position:e,size:t}){return e.icon?(0,S.jsx)("img",{src:e.icon,alt:"",width:t,height:t}):(0,S.jsx)("span",{children:e.tokenSymbol.slice(0,1)})}function Vo({open:e,status:t,positions:n,initialPoolAddress:o,walletAddress:r,txHash:i,error:a,copied:s=!1,estimateWithdraw:c,onClose:d,onConfirm:f,onCopyHash:h}){let[g,u]=xe.useState(void 0),[v,b]=xe.useState(""),[w,y]=xe.useState(null),[E,m]=xe.useState("idle"),C=xe.useRef(0),R=xe.useRef(void 0),k=xe.useMemo(()=>{let z=(g??o)?.toLowerCase();return n.find(ee=>ee.poolAddress.toLowerCase()===z)??n[0]??null},[n,g,o]),T=xe.useMemo(()=>{try{return BigInt(k?.depositedRaw??"0")}catch{return 0n}},[k?.depositedRaw]),G=k?.decimals??18,F=xe.useMemo(()=>{let z=$t(v,G);return"value"in z?z.value:null},[v,G]),K=F!==null&&F>T,D=t==="confirm"&&!!k&&F!==null&&F>0n&&!K,Q=xe.useCallback(()=>{b(""),y(null),m(c?"idle":"unavailable"),C.current+=1},[]);xe.useEffect(()=>{e&&(u(o),Q())},[e]);let A=xe.useCallback(z=>{t==="confirm"&&(u(z.poolAddress),Q())},[t,Q]);xe.useEffect(()=>{if(!e||t!=="confirm")return;if(clearTimeout(R.current),!c||!k){m("unavailable");return}if(F===null||F<=0n||K){C.current+=1,y(null),m("idle");return}let z=C.current+1;return C.current=z,m("loading"),R.current=setTimeout(()=>{c(k,F).then(ee=>{C.current===z&&(y(ee??null),m(ee?"ready":"unavailable"))}).catch(()=>{C.current===z&&(y(null),m("error"))})},Id),()=>clearTimeout(R.current)},[e,t,F,K,c,k]);let ae=xe.useCallback(z=>{let ee=z.target.value.replace(/,/g,"");(ee===""||Td.test(ee))&&b(ee)},[]),B=xe.useCallback(z=>{b(Hn(z.toString(),G))},[G]),Y=xe.useCallback(z=>{let ee=10n**BigInt(G),ve=(F??0n)+z*ee;B(ve>T?T:ve)},[F,G,T,B]),ye=xe.useCallback(()=>{B(T)},[T,B]);if(!e||!k)return null;let de=t==="submitting",J=Mr(w?.maxPriorityFeePerGas),be=Mr(w?.maxFeePerGas??w?.gasPrice),ue=es(w?.gasLimit),Z=Tt(k.depositedRaw,G);return(0,S.jsx)("div",{className:"wp-claim-overlay",role:"presentation",onMouseDown:z=>{z.target===z.currentTarget&&!de&&d()},children:(0,S.jsxs)("section",{className:"wp-claim-sheet",role:"dialog","aria-modal":"true","aria-labelledby":"wp-withdraw-title","data-status":t,"data-vaul-no-drag":!0,children:[(0,S.jsx)("div",{className:"wp-claim-grabber","aria-hidden":!0,children:(0,S.jsx)("span",{})}),(0,S.jsxs)("div",{className:"wp-claim-content wp-withdraw-content",children:[t==="success"&&i?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)("span",{className:"wp-claim-icon wp-claim-icon--success","aria-hidden":!0,children:(0,S.jsx)(Yi,{})}),(0,S.jsxs)("div",{className:"wp-claim-copy",children:[(0,S.jsx)("h3",{id:"wp-withdraw-title",className:"wp-claim-title",children:"Withdraw Submitted!"}),(0,S.jsx)("p",{className:"wp-claim-desc",children:"Your withdrawal request has been submitted. Balances will update shortly after the transaction settles."})]}),(0,S.jsx)("div",{className:"wp-claim-list","aria-label":"Withdraw transaction",children:(0,S.jsxs)("div",{className:"wp-claim-list-item",children:[(0,S.jsx)("span",{children:"Tx Hash"}),(0,S.jsxs)("button",{type:"button",className:"wp-claim-hash",onClick:h,"aria-label":"Copy transaction hash",children:[(0,S.jsx)("strong",{children:Xi(i)}),s?(0,S.jsx)(Qi,{}):(0,S.jsx)(Ki,{})]})]})})]}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)("div",{className:"wp-claim-heading",children:[(0,S.jsx)("h3",{id:"wp-withdraw-title",className:"wp-claim-title",children:t==="error"?"Withdraw Failed":"Withdraw"}),t==="error"&&(0,S.jsx)("p",{className:"wp-claim-error-message",children:a||"The withdraw request could not be completed."})]}),n.length>1&&(0,S.jsx)("div",{className:"wp-withdraw-token-list",role:"listbox","aria-label":"Withdrawable tokens",children:n.map(z=>{let ee=z.poolAddress.toLowerCase()===k.poolAddress.toLowerCase();return(0,S.jsxs)("button",{type:"button",role:"option","aria-selected":ee,className:"wp-withdraw-token","data-selected":ee||void 0,disabled:de,onClick:()=>A(z),children:[(0,S.jsx)("span",{className:"wp-withdraw-token-icon","aria-hidden":!0,children:(0,S.jsx)(gs,{position:z,size:28})}),(0,S.jsx)("span",{className:"wp-withdraw-token-symbol",children:z.tokenSymbol}),(0,S.jsx)("span",{className:"wp-withdraw-token-amount",children:Tt(z.depositedRaw,z.decimals)})]},z.poolAddress)})}),(0,S.jsxs)("div",{className:"wp-claim-reward-card","aria-label":"Deposited balance",children:[(0,S.jsx)("span",{className:"wp-claim-reward-token","aria-hidden":!0,children:(0,S.jsx)(gs,{position:k,size:28})}),(0,S.jsx)("strong",{className:"wp-claim-reward-symbol",children:k.tokenSymbol}),(0,S.jsx)("strong",{className:"wp-claim-reward-amount",children:Z})]}),(0,S.jsxs)("div",{className:"wp-withdraw-amount-card",children:[(0,S.jsxs)("div",{className:"wp-withdraw-amount-row",children:[(0,S.jsx)("input",{className:"wp-withdraw-input",type:"text",inputMode:"decimal",autoComplete:"off",placeholder:"0",value:v,disabled:de,onChange:ae,"aria-label":`Withdraw amount (${k.tokenSymbol})`,"aria-invalid":K||void 0}),(0,S.jsx)("span",{className:"wp-withdraw-input-symbol",children:k.tokenSymbol})]}),K&&(0,S.jsx)("p",{className:"wp-claim-error-message",children:"Amount exceeds deposited balance."}),(0,S.jsxs)("div",{className:"wp-withdraw-quick-row",role:"group","aria-label":"Quick amounts",children:[Nd.map(z=>(0,S.jsxs)("button",{type:"button",className:"wp-withdraw-quick",disabled:de,onClick:()=>Y(z),children:["+",z.toString()]},z.toString())),(0,S.jsx)("button",{type:"button",className:"wp-withdraw-quick",disabled:de,onClick:ye,children:"MAX"})]})]}),(0,S.jsxs)("div",{className:"wp-claim-account-card","aria-label":"Withdraw gas fee",children:[(0,S.jsxs)("div",{className:"wp-claim-account-row",children:[(0,S.jsxs)("div",{className:"wp-claim-account",children:[(0,S.jsx)("span",{className:"wp-claim-account-avatar","aria-hidden":!0}),(0,S.jsxs)("strong",{children:[k.tokenSymbol," Pool"]})]}),(0,S.jsx)("span",{children:Go(r)})]}),(0,S.jsx)("span",{className:"wp-claim-divider","aria-hidden":!0}),(0,S.jsxs)("div",{className:"wp-claim-detail-list",children:[(0,S.jsxs)("div",{className:"wp-claim-detail-row",children:[(0,S.jsx)("span",{children:"Est. Tx Fee"}),(0,S.jsx)("strong",{children:Ed(w,E)})]}),(0,S.jsxs)("div",{className:"wp-claim-detail-row wp-claim-detail-row--sub",children:[(0,S.jsx)("span",{children:"Priority Fee Per Gas"}),(0,S.jsx)("strong",{children:zr(J,"Gwei",E)})]}),(0,S.jsxs)("div",{className:"wp-claim-detail-row wp-claim-detail-row--sub",children:[(0,S.jsx)("span",{children:"Max Fee Per Gas"}),(0,S.jsx)("strong",{children:zr(be,"Gwei",E)})]}),(0,S.jsxs)("div",{className:"wp-claim-detail-row wp-claim-detail-row--sub",children:[(0,S.jsx)("span",{children:"Gas Limit"}),(0,S.jsx)("strong",{children:zr(ue,"",E)})]})]})]})]}),(0,S.jsxs)("div",{className:"wp-claim-actions","data-count":t==="confirm"||t==="error"?2:1,children:[(t==="confirm"||t==="error")&&(0,S.jsx)("button",{type:"button",className:"wp-claim-secondary",onClick:d,children:t==="error"?"Close":"Cancel"}),(0,S.jsxs)("button",{type:"button",className:"wp-claim-primary",onClick:()=>{if(t==="success"){d();return}k&&F!==null&&F>0n&&!K&&f(k,F,w)},disabled:de||(t==="confirm"||t==="error")&&(F===null||F<=0n||K),children:[t==="success"&&"Done",t==="submitting"&&(0,S.jsx)("span",{className:"wp-claim-button-spinner","aria-label":"Waiting"}),t==="error"&&"Try Again",t==="confirm"&&"Withdraw Now"]})]})]}),(0,S.jsx)("div",{className:"wp-claim-home-indicator","aria-hidden":!0,children:(0,S.jsx)("span",{})})]})})}var Ie=H(require("react"),1),xs=require("@tanstack/react-query");var hs=require("@tanstack/react-query");var Ld="wp:reward-factory-info";function bs(e,t=!0){let n=In[e],{data:o,...r}=(0,hs.useQuery)({queryKey:[Ld,e],queryFn:async({signal:i})=>{let a=await fetch(`${n}/v1/factory/info`,{cache:"no-store",signal:i});if(!a.ok)throw new Error(`Factory info fetch failed: ${a.status}`);let s=await a.json();if(s.code!==200)throw new Error(`Factory info API error: ${s.code}`);return s},enabled:t,staleTime:0});return{factoryInfo:o?.data??null,routerAddress:o?.data.router_address??"",...r}}var Ad="wp:";function ws(e){return/^0x[a-fA-F0-9]{40}$/.test(e)?e:null}function qo(){let{env:e,walletAddress:t,sendTransaction:n,estimateGas:o}=je(),r=!!t,i=!!n,a=(0,xs.useQueryClient)(),{routerAddress:s}=bs(e,r&&i),c=ws(s),[d,f]=Ie.useState(!1),[h,g]=Ie.useState(void 0),[u,v]=Ie.useState("confirm"),[b,w]=Ie.useState(),[y,E]=Ie.useState(""),[m,C]=Ie.useState(!1),R=Ie.useRef(void 0);Ie.useEffect(()=>()=>clearTimeout(R.current),[]);let k=Ie.useCallback((A,ae)=>c?{to:c,value:0n,data:Ji(A,ae),chainId:Se[e].cross}:null,[e,c]),T=Ie.useCallback(()=>{a.invalidateQueries({predicate:A=>typeof A.queryKey[0]=="string"&&A.queryKey[0].startsWith(Ad)})},[a]),G=Ie.useCallback(A=>{g(A),f(!0),v("confirm"),w(void 0),E(""),C(!1)},[]),F=Ie.useCallback(()=>{u!=="submitting"&&(f(!1),g(void 0),v("confirm"),w(void 0),E(""),C(!1),u==="success"&&T())},[u,T]),K=Ie.useCallback(async(A,ae)=>{if(!o)return null;let B=k(A.poolId,ae),Y=ws(t);return!B||!Y?null:o({...B,from:Y})},[k,o,t]),D=Ie.useCallback(async()=>{if(!(!b||typeof navigator>"u"||!navigator.clipboard))try{await navigator.clipboard.writeText(b),C(!0),clearTimeout(R.current),R.current=setTimeout(()=>C(!1),1400)}catch{C(!1)}},[b]),Q=Ie.useCallback(async(A,ae,B)=>{if(!n){v("error"),E("Withdraw is not available for this wallet.");return}if(!c){v("error"),E("Withdraw contract address is not available.");return}try{v("submitting"),E("");let Y=k(A.poolId,ae);if(!Y){v("error"),E("Withdraw contract address is not available.");return}let ye=await n({...Y,gas:B?.gasLimit&&B.gasLimit>0n?B.gasLimit:void 0,maxFeePerGas:B?.maxFeePerGas&&B.maxFeePerGas>0n?B.maxFeePerGas:void 0,maxPriorityFeePerGas:B?.maxPriorityFeePerGas&&B.maxPriorityFeePerGas>0n?B.maxPriorityFeePerGas:void 0});w(ye),v("success"),T()}catch(Y){v("error"),E(Y instanceof Error?Y.message:"Failed to request withdraw.")}},[k,T,c,n]);return{canWithdrawInline:i,isOpen:d,initialPoolAddress:h,status:u,txHash:b,error:y,copied:m,hasEstimator:!!o,openWithdraw:G,closeWithdraw:F,estimateWithdraw:K,confirmWithdraw:Q,copyHash:D}}var Ko=H(require("bignumber.js"),1),q=require("react/jsx-runtime"),Pd="CROSS Rewards";function vs(e){return new Ko.default(e||"0").isGreaterThan(0)}function ks(){let{env:e,walletAddress:t,onOutlink:n}=je(),o=!!t,{allPools:r}=Ln(e,o),{depositMap:i}=Ho(e,t,o),{getTokenImage:a}=$o(e,o),s=qo(),{positions:c}=jo(e,t,o&&s.canWithdrawInline),d=ys.useMemo(()=>c.filter(u=>u.poolType==="CrossPool").map(u=>({...u,icon:a(u.tokenAddress,u.tokenSymbol)})),[c,a]),f=(u,v)=>`${ns[e]}/rewards/${u.pool_address}?action=${v}`,h=`${Ot[e]}/reward.png`,g=r.filter(u=>{let v=i.get(u.pool_address.toLowerCase()),b=v?.deposited_amount??"0",w=v?.claimable_reward??"0";return!(new Ko.default(b).isZero()&&new Ko.default(w).isZero())});return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Wt,{title:Pd,icon:h,isEmpty:g.length===0,children:g.map(u=>{let v=i.get(u.pool_address.toLowerCase()),b=v?.deposited_amount??"0",w=v?.claimable_reward??"0",y=f(u,"withdraw"),E=f(u,"claim"),m=a(u.deposit_token.address,u.deposit_token.symbol),C=u.reward_tokens[0],R=C?a(C.address,C.symbol):"",k=u.reward_tokens.map(B=>B.symbol),T=k.length>0?`${u.deposit_token.symbol}-${k.join("/")}`:u.deposit_token.symbol,G=C?Tt(w,C.decimals):"0",F=C?.symbol??"Reward",K=tn(b,u.deposit_token.decimals,u.deposit_token.price),D=C?tn(w,C.decimals,C.price):null,Q=!!v&&vs(w),A=!!v&&vs(b),ae=s.canWithdrawInline&&d.some(B=>B.poolAddress.toLowerCase()===u.pool_address.toLowerCase());return(0,q.jsxs)("article",{className:"wp-item","data-side":"reward",children:[(0,q.jsxs)("div",{className:"wp-item-body",children:[(0,q.jsxs)("div",{className:"wp-item-line",children:[(0,q.jsx)("span",{className:"wp-item-label",children:"Pool (Deposit - Earn)"}),(0,q.jsxs)("div",{className:"wp-svc-token",children:[(0,q.jsxs)("span",{className:"wp-token-stack","aria-hidden":!0,children:[m&&(0,q.jsx)("img",{className:"wp-svc-token-icon",src:m,alt:""}),R&&(0,q.jsx)("img",{className:"wp-svc-token-icon",src:R,alt:""})]}),(0,q.jsx)("span",{children:T})]})]}),(0,q.jsxs)("div",{className:"wp-item-line",children:[(0,q.jsx)("span",{className:"wp-item-label",children:"Deposited"}),(0,q.jsxs)("div",{className:"wp-svc-token wp-svc-token--amount",children:[m&&(0,q.jsx)("img",{className:"wp-svc-token-icon",src:m,alt:""}),(0,q.jsxs)("div",{className:"wp-svc-amount",children:[(0,q.jsx)("span",{className:"wp-svc-amount-main",children:Tt(b,u.deposit_token.decimals)}),K&&(0,q.jsx)("span",{className:"wp-item-usd",children:K})]})]})]}),(0,q.jsxs)("div",{className:"wp-item-line",children:[(0,q.jsxs)("span",{className:"wp-item-label",children:["Claimable (",F,")"]}),(0,q.jsxs)("div",{className:"wp-svc-token wp-svc-token--amount",children:[R&&(0,q.jsx)("img",{className:"wp-svc-token-icon",src:R,alt:""}),(0,q.jsxs)("div",{className:"wp-svc-amount",children:[(0,q.jsx)("span",{className:"wp-svc-amount-main",children:G}),D&&(0,q.jsx)("span",{className:"wp-item-usd",children:D})]})]})]})]}),(0,q.jsxs)("div",{className:"wp-item-tags",children:[ae?(0,q.jsx)("button",{type:"button",className:"wp-tag wp-tag--muted","data-disabled":!A||void 0,"aria-disabled":!A||void 0,onClick:()=>{A&&s.openWithdraw(u.pool_address)},children:(0,q.jsx)("span",{className:"wp-tag-label",children:"Withdraw"})}):(0,q.jsxs)("a",{className:"wp-tag wp-tag--muted",href:y,target:"_blank",rel:"noopener noreferrer",onClick:B=>Ze(B,y,{category:"portfolio",origin:"portfolio-rewards",payload:{pool:u,userDeposit:v}},n),children:[(0,q.jsx)("span",{className:"wp-tag-label",children:"Withdraw"}),(0,q.jsx)(Ct,{size:12,className:"wp-tag-icon"})]}),(0,q.jsxs)("a",{className:"wp-tag wp-tag--mint","data-disabled":!Q||void 0,"aria-disabled":!Q||void 0,href:Q?E:void 0,target:Q?"_blank":void 0,rel:Q?"noopener noreferrer":void 0,onClick:B=>{if(!Q){B.preventDefault();return}Ze(B,E,{category:"portfolio",origin:"portfolio-rewards",payload:{pool:u,userDeposit:v}},n)},children:[(0,q.jsx)("span",{className:"wp-tag-label",children:"Claim"}),(0,q.jsx)(Ct,{size:12,className:"wp-tag-icon"})]})]})]},u.pool_address)})}),(0,q.jsx)(Vo,{open:s.isOpen,status:s.status,positions:d,initialPoolAddress:s.initialPoolAddress,walletAddress:t,txHash:s.txHash,error:s.error,copied:s.copied,estimateWithdraw:s.hasEstimator?s.estimateWithdraw:void 0,onClose:s.closeWithdraw,onConfirm:s.confirmWithdraw,onCopyHash:s.copyHash})]})}var Ss=H(require("react"),1);var ce=require("react/jsx-runtime"),Fd="Points";function Rs(){let{env:e,walletAddress:t,onOutlink:n}=je(),o=!!t,{getTokenImage:r}=$o(e,o),i=qo(),{positions:a}=jo(e,t,o),s=Ss.useMemo(()=>a.filter(f=>f.poolType!=="CrossPool").map(f=>({...f,icon:r(f.tokenAddress,f.tokenSymbol)})),[a,r]),c=`${Ot[e]}/point.png`,d=os[e];return(0,ce.jsxs)(ce.Fragment,{children:[(0,ce.jsx)(Wt,{title:Fd,icon:c,isEmpty:s.length===0,children:s.map(f=>{let h=f.price?tn(f.depositedRaw,f.decimals,f.price):null;return(0,ce.jsxs)("article",{className:"wp-item","data-side":"reward",children:[(0,ce.jsxs)("div",{className:"wp-item-body",children:[(0,ce.jsxs)("div",{className:"wp-item-line",children:[(0,ce.jsx)("span",{className:"wp-item-label",children:"Token"}),(0,ce.jsxs)("div",{className:"wp-svc-token",children:[f.icon&&(0,ce.jsx)("img",{className:"wp-svc-token-icon",src:f.icon,alt:""}),(0,ce.jsx)("span",{children:f.tokenSymbol})]})]}),(0,ce.jsxs)("div",{className:"wp-item-line",children:[(0,ce.jsx)("span",{className:"wp-item-label",children:"Deposited"}),(0,ce.jsxs)("div",{className:"wp-svc-token wp-svc-token--amount",children:[f.icon&&(0,ce.jsx)("img",{className:"wp-svc-token-icon",src:f.icon,alt:""}),(0,ce.jsxs)("div",{className:"wp-svc-amount",children:[(0,ce.jsx)("span",{className:"wp-svc-amount-main",children:Tt(f.depositedRaw,f.decimals)}),h&&(0,ce.jsx)("span",{className:"wp-item-usd",children:h})]})]})]})]}),(0,ce.jsx)("div",{className:"wp-item-tags",children:i.canWithdrawInline?(0,ce.jsx)("button",{type:"button",className:"wp-tag wp-tag--muted",onClick:()=>i.openWithdraw(f.poolAddress),children:(0,ce.jsx)("span",{className:"wp-tag-label",children:"Withdraw"})}):(0,ce.jsxs)("a",{className:"wp-tag wp-tag--muted",href:d,target:"_blank",rel:"noopener noreferrer",onClick:g=>Ze(g,d,{category:"portfolio",origin:"portfolio-points",payload:{position:f}},n),children:[(0,ce.jsx)("span",{className:"wp-tag-label",children:"Withdraw"}),(0,ce.jsx)(Ct,{size:12,className:"wp-tag-icon"})]})})]},f.poolAddress)})}),(0,ce.jsx)(Vo,{open:i.isOpen,status:i.status,positions:s,initialPoolAddress:i.initialPoolAddress,walletAddress:t,txHash:i.txHash,error:i.error,copied:i.copied,estimateWithdraw:i.hasEstimator?i.estimateWithdraw:void 0,onClose:i.closeWithdraw,onConfirm:i.confirmWithdraw,onCopyHash:i.copyHash})]})}var Ur=H(require("react"),1);var Cs=require("@tanstack/react-query");var Bd="wp:stake-info";function Ts(e,t,n=!0){let o=En[e],r=n&&!!t,{data:i,...a}=(0,Cs.useQuery)({queryKey:[Bd,e,t],queryFn:async({signal:c})=>{let d=await fetch(`${o}/stake/${t}`,{cache:"no-store",signal:c});if(!d.ok)throw new Error(`Stake info fetch failed: ${d.status}`);let f=await d.json();if(f.code!==0&&f.code!==200)throw new Error(`Stake info API error: ${f.code}`);return f},enabled:r,staleTime:0});return{stakeInfo:i?.data,...a}}var Ns=require("@tanstack/react-query");var _d="wp:stake-rewards",Md=31;function Is(e,t,n=!0){let o=En[e],r=n&&!!t,{data:i,...a}=(0,Ns.useQuery)({queryKey:[_d,e,t],queryFn:async({signal:s})=>{let c=await fetch(`${o}/rewards/${t}?limit=${Md}`,{cache:"no-store",signal:s});if(!c.ok)throw new Error(`Stake rewards fetch failed: ${c.status}`);let d=await c.json();if(d.code!==0&&d.code!==200)throw new Error(`Stake rewards API error: ${d.code}`);return d.data?.data??[]},enabled:r,staleTime:0});return{latestReward:i?.[0]??null,aprAccrued:Zi(i),...a}}var Es=require("@tanstack/react-query");var Od="wp:network-stats";function Ls(e,t=!0){let n=En[e],{data:o,...r}=(0,Es.useQuery)({queryKey:[Od,e],queryFn:async({signal:a})=>{let s=await fetch(`${n}/network/stats`,{cache:"no-store",signal:a});if(!s.ok)throw new Error(`Network stats fetch failed: ${s.status}`);let c=await s.json();if(c.code!==0&&c.code!==200)throw new Error(`Network stats API error: ${c.code}`);return c},enabled:t,staleTime:0});return{networkStats:o?.data,...r}}var As=require("@tanstack/react-query"),Wd="wp:staking-onchain";function Ps(e,t,n=!0){let o=n&&!!t&&!!e,{data:r,...i}=(0,As.useQuery)({queryKey:[Wd,e],queryFn:async()=>{if(!t)throw new Error("stakingRewardsReader not provided");return t(e)},enabled:o,staleTime:0});return{onchain:r,...i}}var Gr=require("react"),_s=H(require("bignumber.js"),1);function Fs(e){return e?.trim().toUpperCase()==="CROSS"}function Bs(e){return new _s.default(e||"0").isGreaterThan(0)}function Qo(e,t,n=!0){let{allPools:o}=Ln(e,n),r=(0,Gr.useMemo)(()=>{for(let d of o)for(let f of[d.deposit_token,...d.reward_tokens])if(Fs(f?.symbol)&&Bs(f.price))return f.price},[o]),i=n&&r===void 0,{tokens:a}=Vt(e,t,i),{statsMap:s}=qt(e,i),c=Se[e].cross;return(0,Gr.useMemo)(()=>{if(r)return r;let d=a.find(f=>f.chainId===c&&Fs(f.symbol));if(d){let f=s.get(Rt(d.chainId,d.address));if(f&&Bs(f.price))return f.price}return"0"},[r,a,s,c])}var Kt=H(require("bignumber.js"),1),le=require("react/jsx-runtime"),Dd="CROSS Staking";function Ms(e){if(!e)return"\u2014";let t=new Kt.default(e);return t.isFinite()?`${t.toFormat(2,Kt.default.ROUND_DOWN)}%`:"\u2014"}function Os(){let{env:e,walletAddress:t,onOutlink:n,stakingRewardsReader:o}=je(),r=!!t,{stakeInfo:i}=Ts(e,t,r),{latestReward:a,aprAccrued:s}=Is(e,t,r),{networkStats:c}=Ls(e,r),{onchain:d}=Ps(t,o,r),f=Qo(e,t,r),h=`${Ot[e]}/cross-staking.png`,g=as[e],u=i?.total_stake??"0",v=Ur.useMemo(()=>d?new Kt.default(d.earnedWei.toString()).shiftedBy(-18).toString(10):a?.cumulative_earned??i?.rewards_earned??"0",[d,a,i]),b=Ur.useMemo(()=>d?new Kt.default(d.stakedWei.toString()).shiftedBy(-18):new Kt.default(u),[d,u]),w=s!==void 0?new Kt.default(s):void 0,y=i?.days_since_first_stake,E=w!==void 0&&w.isFinite()&&b.isGreaterThan(0)&&y!==null&&y!==void 0?w.div(b).times(365).div(Math.max(1,y)).times(100):void 0,m=!(new Kt.default(u).isZero()&&new Kt.default(v).isZero()),C=qn[e],R=tn(u,0,f),k=tn(v,0,f);return(0,le.jsx)(Wt,{title:Dd,icon:h,iconFit:"contain",isEmpty:!1,children:(0,le.jsxs)("article",{className:"wp-item","data-side":"stake",children:[(0,le.jsx)("div",{className:"wp-item-body",children:m?(0,le.jsxs)(le.Fragment,{children:[(0,le.jsxs)("div",{className:"wp-item-line",children:[(0,le.jsx)("span",{className:"wp-item-label",children:"Staked"}),(0,le.jsxs)("div",{className:"wp-svc-amount",children:[(0,le.jsxs)("span",{className:"wp-svc-amount-main",children:[Or(u)," CROSS"]}),R&&(0,le.jsx)("span",{className:"wp-item-usd",children:R})]})]}),(0,le.jsxs)("div",{className:"wp-item-line",children:[(0,le.jsx)("span",{className:"wp-item-label",children:"Rewards Earned"}),(0,le.jsxs)("div",{className:"wp-svc-amount",children:[(0,le.jsxs)("span",{className:"wp-svc-amount-main",children:[Or(v)," CROSS"]}),k&&(0,le.jsx)("span",{className:"wp-item-usd",children:k})]})]}),(0,le.jsxs)("div",{className:"wp-item-line",children:[(0,le.jsx)("span",{className:"wp-item-label",children:"My APR"}),(0,le.jsx)("span",{children:Ms(E?.toString(10))})]})]}):(0,le.jsxs)("div",{className:"wp-item-line",children:[(0,le.jsx)("span",{className:"wp-item-label",children:"Delegation APR"}),(0,le.jsx)("span",{children:Ms(c?.apr)})]})}),(0,le.jsx)("div",{className:"wp-item-tags",children:(0,le.jsxs)("a",{className:"wp-tag wp-tag--mint",href:m?g:C,target:"_blank",rel:"noopener noreferrer",onClick:T=>Ze(T,m?g:C,{category:"portfolio",origin:"portfolio-stake",payload:{stakeInfo:i,networkStats:c}},n),children:[(0,le.jsx)("span",{className:"wp-tag-label",children:m?"Manage":"Stake Now"}),(0,le.jsx)(Ct,{size:12,className:"wp-tag-icon"})]})})]})})}var Hr=H(require("react"),1);var Ws=require("@tanstack/react-query");var zd="wp:game-swap-pools";function Ds(e,t,n=!0){let o=is[e],r=n&&!!t,{data:i,...a}=(0,Ws.useQuery)({queryKey:[zd,e,t],queryFn:async({signal:s})=>{let c=await fetch(`${o}/addresses/${t}/portfolio`,{cache:"no-store",signal:s});if(!c.ok)throw new Error(`Game-swap portfolio fetch failed: ${c.status}`);return(await c.json()).pools??[]},enabled:r,staleTime:0});return{pools:i??[],...a}}var zs=require("@tanstack/react-query");var Gd="wp:game-swap-lp-balances";function Gs(e,t,n,o){let r=[...n].map(c=>c.toLowerCase()).sort(),i=!!t&&r.length>0,{data:a,...s}=(0,zs.useQuery)({queryKey:[Gd,e,t,r,!!o],queryFn:async({signal:c})=>{let d=o?await o(r):await us(e,t,r,c),f={};for(let[h,g]of Object.entries(d))f[h.toLowerCase()]=g;return f},enabled:i,staleTime:0});return{balances:a??{},...s}}var Nt=H(require("bignumber.js"),1),fe=require("react/jsx-runtime"),Ud="Gametoken LP",Hs=18,Hd=new Nt.default("0.0001");function Us(e){return e?.trim().toUpperCase()==="CROSS"}function $d(e){return e&&e>0?e:Hs}function jd(e){let t=Us(e.token_a?.symbol)&&!Us(e.token_b?.symbol),n=t?e.reserve_a:e.reserve_b,o=$d(t?e.token_a?.decimals:e.token_b?.decimals),r=new Nt.default(n||"0").shiftedBy(-o);return!r.isFinite()||r.isLessThanOrEqualTo(0)?new Nt.default(0):r.times(2)}function Vd(e,t){let n=e.token_a?.symbol?.trim()||"TOKEN",o=e.token_b?.symbol?.trim()||"CROSS",r=t?.decimals??Hs,i,a;if(t&&t.totalSupply&&t.totalSupply>BigInt(0)){let s=new Nt.default(t.balance.toString()),c=new Nt.default(t.totalSupply.toString()),d=s.div(c);i=d.times(100);let f=d.times(jd(e));if(f.isGreaterThan(0)){let h=new Nt.default(e.quote_usd??e.cross_usd??"0");a=h.isGreaterThan(0)?`$${f.times(h).toFormat(2,Nt.default.ROUND_DOWN)}`:`${f.toFormat(4,Nt.default.ROUND_DOWN)} CROSS`}}return{pool:e,tokenASymbol:n,tokenBSymbol:o,info:t,lpAmountRaw:t?.balance.toString(),lpDecimals:r,sharePercent:i,valueText:a}}function $s(){let{env:e,walletAddress:t,onOutlink:n,lpBalanceReader:o}=je(),r=!!t,{pools:i}=Ds(e,t,r),a=Hr.useMemo(()=>i.map(g=>g.pair_address).filter(Boolean),[i]),{balances:s}=Gs(e,t,a,o),c=`${Ot[e]}/dex.png`,d=Object.keys(s).length>0,f=Hr.useMemo(()=>{let g=i.map(u=>Vd(u,s[u.pair_address?.toLowerCase()]));return d?g.filter(u=>u.lpAmountRaw?new Nt.default(u.lpAmountRaw).shiftedBy(-u.lpDecimals).isGreaterThanOrEqualTo(Hd):!1):g},[i,s,d]),h=g=>{let u=g.token_a?.address??g.pair_address;return`${ss[e]}/tokens/${u}?trade=deposit`};return(0,fe.jsx)(Wt,{title:Ud,icon:c,iconFit:"contain",isEmpty:f.length===0,children:f.map(g=>{let{pool:u}=g,v=h(u),b=`${g.tokenASymbol} / ${g.tokenBSymbol}`,w=u.token_a?.logo_url,y=u.token_b?.logo_url;return(0,fe.jsxs)("article",{className:"wp-item","data-side":"game-swap",children:[(0,fe.jsxs)("div",{className:"wp-item-body",children:[(0,fe.jsxs)("div",{className:"wp-item-line",children:[(0,fe.jsx)("span",{className:"wp-item-label",children:"Pool"}),(0,fe.jsxs)("div",{className:"wp-svc-token",children:[(0,fe.jsxs)("span",{className:"wp-token-stack","aria-hidden":!0,children:[w&&(0,fe.jsx)("img",{className:"wp-svc-token-icon",src:w,alt:""}),y&&(0,fe.jsx)("img",{className:"wp-svc-token-icon",src:y,alt:""})]}),(0,fe.jsx)("span",{children:b})]})]}),g.lpAmountRaw!==void 0&&(0,fe.jsxs)("div",{className:"wp-item-line",children:[(0,fe.jsx)("span",{className:"wp-item-label",children:"My LP"}),(0,fe.jsxs)("span",{children:[Tt(g.lpAmountRaw,g.lpDecimals)," LP"]})]}),g.sharePercent!==void 0&&(0,fe.jsxs)("div",{className:"wp-item-line",children:[(0,fe.jsx)("span",{className:"wp-item-label",children:"Pool Share"}),(0,fe.jsxs)("span",{children:[g.sharePercent.toFormat(2,Nt.default.ROUND_DOWN),"%"]})]}),g.valueText!==void 0&&(0,fe.jsxs)("div",{className:"wp-item-line",children:[(0,fe.jsx)("span",{className:"wp-item-label",children:"Value"}),(0,fe.jsx)("span",{children:g.valueText})]})]}),(0,fe.jsx)("div",{className:"wp-item-tags",children:(0,fe.jsxs)("a",{className:"wp-tag wp-tag--mint",href:v,target:"_blank",rel:"noopener noreferrer",onClick:E=>Ze(E,v,{category:"portfolio",origin:"portfolio-game-swap",payload:{pool:u}},n),children:[(0,fe.jsx)("span",{className:"wp-tag-label",children:"Manage"}),(0,fe.jsx)(Ct,{size:12,className:"wp-tag-icon"})]})})]},u.pair_address)})})}var Qt=H(require("bignumber.js"),1),Ys=require("react");var js=require("@tanstack/react-query");var qd="wp:forge-pools";function Vs(e,t,n=!0){let o=Uo[e],r=n&&!!t,{data:i,...a}=(0,js.useQuery)({queryKey:[qd,e,t],queryFn:async()=>{let c=await fetch(`${o}/v1/users/${t}/pools`,{cache:"no-store"});if(!c.ok)throw new Error(`forge pools fetch failed: ${c.status}`);return(await c.json()).data?.items??[]},enabled:r,staleTime:0}),s=i??[];return{pools:s,isEmpty:s.length===0,...a}}var qs=require("@tanstack/react-query"),Ks=require("react");var Kd="wp:forge-token-detail";async function Qd(e,t){let n=await fetch(`${e}/v1/tokens/${t}`,{cache:"no-store"});return n.ok?(await n.json())?.data?.token??null:null}function Qs(e,t,n=!0){let o=Uo[e],r=(0,qs.useQueries)({queries:t.map(s=>({queryKey:[Kd,e,s],queryFn:()=>Qd(o,s),enabled:n&&!!s,staleTime:3e4}))}),i=(0,Ks.useMemo)(()=>{let s=new Map;for(let c=0;c<r.length;c++){let d=r[c]?.data,f=t[c];d&&f&&s.set(f.toLowerCase(),d)}return s},[r,t]),a=r.some(s=>s.isLoading);return{detailMap:i,isLoading:a}}var me=require("react/jsx-runtime"),Yd="Forge",Zs=18,Zd="https://contents.crosstoken.io/wallet/token/images/FT.png";function Xd(e){if(!e||e==="0")return"0";let t=new Qt.default(e).shiftedBy(-Zs);return t.isZero()?"0":t.isGreaterThanOrEqualTo(1)?t.toFormat(2,Qt.default.ROUND_DOWN):t.toFormat(4,Qt.default.ROUND_DOWN)}function Jd(e){let t=Number(e);return!Number.isFinite(t)||t<=0?"0%":t>=1?`${(Math.floor(t*100)/100).toFixed(2)}%`:`${(Math.floor(t*1e4)/1e4).toFixed(4)}%`}function ep(e,t,n){let o=new Qt.default(n||"0");if(!o.isGreaterThan(0))return null;let r=new Qt.default(e.total_supply||"0"),i=new Qt.default(e.lp_balance||"0"),a=new Qt.default(t?.reserve_b||"0").shiftedBy(-Zs);if(!r.isGreaterThan(0)||!i.isGreaterThan(0)||!a.isGreaterThan(0))return null;let s=a.times(2),d=i.div(r).times(s).times(o);return d.isFinite()?`$${d.toFormat(2,Qt.default.ROUND_DOWN)}`:null}function Xs(){let{env:e,walletAddress:t,onOutlink:n}=je(),o=!!t,{pools:r,isEmpty:i}=Vs(e,t,o),a=(0,Ys.useMemo)(()=>r.map(h=>h.token.address),[r]),{detailMap:s}=Qs(e,a,o&&a.length>0),c=Qo(e,t,o),d=h=>`${rs[e]}/forge/token/${h.token.address}`,f=`${Ot[e]}/forge.png`;return(0,me.jsx)(Wt,{title:Yd,icon:f,iconFit:"contain",isEmpty:i,children:r.map(h=>{let g=s.get(h.token.address.toLowerCase()),u=g?.image_url||g?.image||h.token.image||Zd,v=g?.symbol||h.token.symbol,b=d(h),w=ep(h,g,c);return(0,me.jsxs)("a",{className:"wp-item","data-side":"lp",href:b,target:"_blank",rel:"noopener noreferrer",onClick:y=>Ze(y,b,{category:"portfolio",origin:"portfolio-forge",payload:{pool:h,tokenDetail:g}},n),children:[(0,me.jsxs)("div",{className:"wp-item-body",children:[(0,me.jsxs)("div",{className:"wp-item-line",children:[(0,me.jsx)("span",{className:"wp-item-label",children:"Asset"}),(0,me.jsxs)("div",{className:"wp-svc-token",children:[(0,me.jsx)("img",{className:"wp-svc-token-icon",src:u,alt:""}),(0,me.jsx)("span",{children:v}),g?.name&&(0,me.jsx)("span",{className:"wp-token-subtle",children:g.name})]})]}),(0,me.jsxs)("div",{className:"wp-item-line",children:[(0,me.jsx)("span",{className:"wp-item-label",children:"LP Balance"}),(0,me.jsx)("div",{className:"wp-svc-token wp-svc-token--amount",children:(0,me.jsxs)("div",{className:"wp-svc-amount",children:[(0,me.jsx)("span",{className:"wp-svc-amount-main",children:Xd(h.lp_balance)}),w&&(0,me.jsx)("span",{className:"wp-item-usd",children:w})]})})]}),(0,me.jsxs)("div",{className:"wp-item-line",children:[(0,me.jsx)("span",{className:"wp-item-label",children:"Ownership"}),(0,me.jsx)("span",{className:"wp-line-value",children:Jd(h.pool_ownership)})]})]}),(0,me.jsx)("div",{className:"wp-item-tags",children:(0,me.jsxs)("span",{className:"wp-tag wp-tag--muted",children:[(0,me.jsx)("span",{className:"wp-tag-label",children:"Withdraw"}),(0,me.jsx)(Ct,{size:12,className:"wp-tag-icon"})]})})]},h.pair_address)})})}j(`.wp-fullscreen[data-theme=dark],.wp-embed[data-theme=dark]{--wp-bg: var(--ds-bg-default, #202530);--wp-header-bg: var(--ds-surface-default, #252b39);--wp-card: var(--ds-surface-medium, #252b39);--wp-control: #292f40;--wp-border: var(--ds-border-default, #292f40);--wp-panel-border: var(--ds-border-medium, rgba(255, 255, 255, .18));--wp-panel-shadow: 0px 4px 30px -1px rgba(0, 0, 0, .28);--wp-text: var(--ds-content-highest, #ffffff);--wp-text-60: var(--ds-content-high, rgba(255, 255, 255, .85));--wp-text-40: var(--ds-content-medium, rgba(255, 255, 255, .65));--wp-text-30: var(--ds-content-low, rgba(255, 255, 255, .4));--wp-chrome-text: #ffffff;--wp-tooltip-bg: #151a23;--wp-tooltip-text: #ffffff;--wp-mint: var(--ds-accent-primary-default, #00a0a2);--wp-green: var(--ds-accent-primary-default, #00a0a2);--wp-accent-soft: var(--ds-accent-primary-low, rgba(0, 160, 162, .14));--wp-red: var(--ds-system-red-default, #e70077);--wp-blue: #0488fc;--wp-purple: #7346f3;--wp-orange: #ff9d00;--wp-claim-primary: #9b8cef;--wp-claim-primary-text: #202530;--wp-claim-secondary-bg: var(--wp-control);--wp-claim-success: #00d4aa;--wp-claim-success-soft: rgba(0, 212, 170, .18);--wp-claim-error: #ff3aa3;--wp-claim-error-soft: rgba(255, 58, 163, .16)}.wp-fullscreen[data-theme=light],.wp-embed[data-theme=light]{--wp-bg: var(--ds-bg-dim, #f5f7fa);--wp-header-bg: var(--ds-surface-default, #ffffff);--wp-card: var(--ds-surface-default, #ffffff);--wp-control: var(--ds-surface-medium, #f5f7fa);--wp-border: var(--ds-border-default, rgba(0, 0, 0, .07));--wp-panel-border: var(--ds-border-medium, rgba(0, 0, 0, .18));--wp-panel-shadow: 0px 4px 30px -1px rgba(0, 0, 0, .15);--wp-text: var(--ds-content-highest, #000000);--wp-text-60: var(--ds-content-high, rgba(0, 0, 0, .85));--wp-text-40: var(--ds-content-medium, rgba(0, 0, 0, .65));--wp-text-30: var(--ds-content-low, rgba(0, 0, 0, .4));--wp-chrome-text: var(--ds-content-high, rgba(0, 0, 0, .85));--wp-card-shadow: none;--wp-tooltip-bg: #192023;--wp-tooltip-text: #ffffff;--wp-mint: var(--ds-accent-primary-default, #00a0a2);--wp-green: var(--ds-accent-primary-default, #00a0a2);--wp-accent-soft: var(--ds-accent-primary-low, #e7f9f8);--wp-red: var(--ds-system-red-default, #e70077);--wp-blue: #0488fc;--wp-purple: #7346f3;--wp-orange: #ff9d00;--wp-claim-primary: #7346f3;--wp-claim-primary-text: #ffffff;--wp-claim-secondary-bg: #ffffff;--wp-claim-success: #019d92;--wp-claim-success-soft: rgba(1, 157, 146, .15);--wp-claim-error: #e70077;--wp-claim-error-soft: rgba(231, 0, 119, .12)}.wp-fullscreen{position:fixed!important;inset:0!important;width:100%!important;height:100dvh!important;max-height:100dvh!important;z-index:50;background:var(--wp-bg);display:flex;flex-direction:column;overflow:hidden;font-family:inherit;font-feature-settings:"calt" 0,"lnum" 1,"pnum" 1;box-sizing:border-box;-webkit-font-smoothing:antialiased;color:var(--wp-chrome-text)}.wp-embed{width:100%;height:100%;min-height:0;background:var(--wp-bg);display:flex;flex-direction:column;overflow:hidden;position:relative;font-family:inherit;font-feature-settings:"calt" 0,"lnum" 1,"pnum" 1;box-sizing:border-box;-webkit-font-smoothing:antialiased;color:var(--wp-chrome-text)}.wp-overlay{position:fixed;inset:0;z-index:49;background:#0009}.wp-header{display:flex;align-items:center;justify-content:space-between;gap:12px;min-height:73px;padding:24px;position:relative;border-bottom:1px solid var(--wp-border);background:var(--wp-header-bg);color:var(--wp-chrome-text);flex-shrink:0;box-sizing:border-box}.wp-fullscreen .wp-header{height:60px;min-height:60px;padding:11px 20px;border-bottom:none;background:transparent}.wp-fullscreen .wp-header-btn{width:22px;height:22px;color:var(--wp-chrome-text)}.wp-fullscreen .wp-header-btn:hover{color:var(--wp-chrome-text)}.wp-header-btn{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;padding:0;border:none;background:transparent;cursor:pointer;color:var(--ds-content-low, rgba(0, 0, 0, .4));flex-shrink:0;transition:color .15s ease}.wp-header-btn:hover{color:var(--ds-content-high, rgba(0, 0, 0, .85))}.wp-header-edge{display:flex;align-items:center;width:24px;min-width:24px}.wp-header-edge--right{justify-content:flex-end}.wp-header-edge--right .wp-header-btn{position:absolute;top:24px;right:24px}.wp-header-spacer{display:block;width:24px;height:24px}.wp-header-avatar{width:38px;height:38px;flex-shrink:0;border-radius:50%;overflow:hidden;display:inline-flex;align-items:center;justify-content:center;background:var(--wp-header-avatar-bg)}.wp-header-avatar-img{width:30px;height:30px;object-fit:cover;display:block}.wp-fullscreen[data-theme=dark] .wp-header-avatar,.wp-embed[data-theme=dark] .wp-header-avatar{--wp-header-avatar-bg: hsl(221.3 24.6% 25.5%)}.wp-fullscreen[data-theme=light] .wp-header-avatar,.wp-embed[data-theme=light] .wp-header-avatar{--wp-header-avatar-bg: rgba(18, 18, 18, .1)}.wp-refresh-btn{position:relative}.wp-refresh-badge{position:absolute;top:-6px;right:-8px;min-width:16px;height:16px;padding:0 4px;border-radius:8px;background:var(--wp-mint);color:#fff;font-size:10px;font-weight:600;line-height:16px;text-align:center}.wp-spin-once{animation:wp-spin-once .6s ease-in-out}@keyframes wp-spin-once{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.wp-header-title{flex:1;font-family:inherit;font-size:18px;font-weight:600;line-height:1.5;letter-spacing:-.01em;text-align:center;color:var(--ds-content-highest, #000000);margin:0}.wp-header-account{flex:1;display:flex;align-items:center;gap:12px;min-width:0}.wp-header-account-meta{display:flex;flex-direction:column;justify-content:center;min-width:0;gap:2px}.wp-header-wallet-name{min-width:0;font-family:inherit;font-size:15px;font-weight:600;line-height:1.4;letter-spacing:0;color:var(--wp-text);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.wp-header-address-btn{display:inline-flex;align-items:center;gap:4px;align-self:flex-start;max-width:100%;padding:0;border:0;background:transparent;cursor:pointer;font:inherit}.wp-header-address{min-width:0;font-size:12px;font-weight:400;line-height:1.4;letter-spacing:0;color:var(--wp-text-40);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.wp-header-address-copy{display:inline-flex;align-items:center;flex-shrink:0;color:var(--wp-text-40);transition:color .15s ease}.wp-header-address-btn:hover .wp-header-address-copy{color:var(--wp-text-60)}.wp-header-address-copy[data-copied=true]{color:var(--wp-mint)}.wp-top{flex-shrink:0;padding:0 16px 16px;display:flex;flex-direction:column;gap:16px}.wp-identity{display:flex;flex-direction:column;gap:8px}.wp-address{display:inline-flex;align-items:center;gap:8px}.wp-address-label{font-size:12px;font-weight:400;line-height:1.4;color:var(--wp-text-40)}.wp-address-chevron{display:inline-flex;align-items:center;color:var(--wp-text-40)}.wp-total{font-size:28px;font-weight:600;line-height:1.3;color:var(--wp-text);margin:0}.wp-asset{display:flex;flex-direction:column;gap:8px}.wp-asset-head{display:flex;align-items:center;gap:4px}.wp-asset-head-label{font-size:12px;font-weight:400;line-height:1.4;color:var(--wp-text-40)}.wp-asset-head-icon{display:inline-flex;color:var(--wp-text-40)}.wp-bar{display:flex;height:20px;border-radius:4px;overflow:hidden}.wp-bar-seg{display:flex;align-items:center;justify-content:center;min-width:8px}.wp-bar-seg-pct{font-size:10px;font-weight:400;line-height:1.3;color:#fff;white-space:nowrap}.wp-legend{display:flex;align-items:center;justify-content:center;gap:16px;flex-wrap:wrap}.wp-legend-item{display:flex;align-items:center;gap:4px}.wp-legend-dot{width:8px;height:8px;border-radius:50%;flex-shrink:0}.wp-legend-label{font-size:12px;font-weight:400;line-height:1.4;color:var(--wp-text-40)}.wp-tabs{flex-shrink:0;padding:8px 16px}.wp-tabs-inner{display:flex;align-items:center;padding:0 2px}.wp-tabs-list{display:flex;gap:20px;flex:1}.wp-tab{display:flex;flex-direction:column;align-items:center;justify-content:space-between;height:44px;padding-top:12px;background:transparent;border:none;cursor:pointer}.wp-tab-text{font-size:14px;font-weight:600;line-height:1.4;color:var(--wp-text-30);white-space:nowrap}.wp-tab[data-active=true] .wp-tab-text{color:var(--wp-mint)}.wp-tab-bar{width:20px;height:4px;border-radius:2px;background:var(--wp-mint);opacity:0}.wp-tab[data-active=true] .wp-tab-bar{opacity:1}.wp-tabs-filter-wrap{position:relative;display:flex;align-items:center;width:44px;height:44px;flex-shrink:0}.wp-tabs-filter-grad{position:absolute;inset:0;background:linear-gradient(to left,var(--wp-bg) 74%,transparent);pointer-events:none}.wp-tabs-filter{position:relative;display:inline-flex;align-items:center;justify-content:center;width:44px;height:44px;padding:0;border:none;background:transparent;cursor:pointer;color:var(--wp-text-40)}.wp-body{flex:1;min-height:0;overflow-y:auto;overflow-x:hidden;overscroll-behavior:contain;scrollbar-width:thin;scrollbar-color:var(--wp-border) transparent}.wp-body::-webkit-scrollbar{width:4px}.wp-body::-webkit-scrollbar-track{background:transparent}.wp-body::-webkit-scrollbar-thumb{background:var(--wp-border);border-radius:4px}.wp-body-inner{padding:16px 16px 32px;display:flex;flex-direction:column;gap:32px}.wp-fullscreen .wp-body-inner{padding-top:8px;gap:24px}.wp-summary-card{display:flex;flex-direction:column;gap:8px;width:100%;padding:0;border-radius:0;background:transparent;box-shadow:none;box-sizing:border-box}.wp-summary-head{position:relative;display:flex;align-items:center;justify-content:flex-start;gap:4px}.wp-summary-label{font-size:14px;font-weight:400;line-height:1.5;letter-spacing:0;color:var(--wp-text-40);white-space:nowrap}.wp-address{display:inline-flex;align-items:center;gap:8px;min-width:0}.wp-address-avatar{width:16px;height:16px;border-radius:50%;flex-shrink:0;background:radial-gradient(circle at 68% 34%,#ff78d1 0 18%,transparent 19%),radial-gradient(circle at 34% 66%,#00d4aa 0 20%,transparent 21%),linear-gradient(135deg,#7346f3,#0488fc)}.wp-address-label{font-size:12px;font-weight:400;line-height:1.4;letter-spacing:0;color:var(--wp-text-40);white-space:nowrap}.wp-address-chevron{display:inline-flex;align-items:center;color:var(--wp-text-40);flex-shrink:0}.wp-summary-badge{display:inline-flex;align-items:center;justify-content:center;padding:4px 8px;border-radius:999px;background:#019d921a;color:var(--wp-mint);font-size:12px;font-weight:400;line-height:1.4;letter-spacing:0;white-space:nowrap}.wp-summary-estimate{position:relative;display:inline-flex;align-items:center;gap:6px;flex-shrink:0}.wp-estimate-info{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;padding:0;border:0;border-radius:50%;background:transparent;color:var(--wp-text-40);cursor:help}.wp-estimate-tooltip{position:absolute;top:calc(100% + 8px);left:0;right:auto;z-index:3;display:flex;flex-direction:column;gap:8px;width:min(280px,calc(100vw - 48px));padding:12px;border-radius:8px;background:var(--wp-tooltip-bg);box-shadow:0 12px 32px #0000003d;color:var(--wp-tooltip-text);font-size:12px;font-weight:400;line-height:1.4;letter-spacing:0;text-align:left;white-space:normal;opacity:0;pointer-events:none;transform:translateY(-4px);visibility:hidden;transition:opacity .15s ease,transform .15s ease,visibility .15s ease}.wp-estimate-tooltip-title{display:block;font-size:12px;font-weight:600;line-height:1.3}.wp-estimate-tooltip-group{display:flex;flex-direction:column;gap:4px}.wp-estimate-tooltip-item{display:block;color:#ffffffc7}.wp-estimate-tooltip-item:before{content:"- "}.wp-estimate-info:hover .wp-estimate-tooltip,.wp-estimate-info:focus .wp-estimate-tooltip,.wp-estimate-info:focus-visible .wp-estimate-tooltip{opacity:1;transform:translateY(0);visibility:visible}.wp-total{font-family:var( --wp-total-font-family, Sora, Inter, system-ui, -apple-system, sans-serif );font-size:36px;font-weight:600;line-height:1.25;letter-spacing:0;color:var(--wp-text);margin:0}.wp-svc-card{display:flex;flex-direction:column;gap:12px;width:100%}.wp-svc-card-head{display:flex;align-items:center;gap:6px}.wp-svc-card-icon{width:24px;height:24px;border-radius:4px;flex-shrink:0;object-fit:cover}.wp-svc-card-title{font-size:16px;font-weight:600;line-height:1.5;letter-spacing:0;color:var(--wp-text-60);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.wp-svc-items{display:flex;flex-direction:column;gap:8px;width:100%;padding:0;border-radius:0;background:transparent;box-shadow:none;box-sizing:border-box}.wp-item{position:relative;display:flex;flex-direction:column;gap:20px;width:100%;padding:12px;border-radius:12px;background:var(--wp-card);box-shadow:var(--wp-card-shadow, none);box-sizing:border-box;color:inherit;text-decoration:none;cursor:pointer;outline:none;transition:opacity .15s ease}.wp-item+.wp-item{padding-top:12px;border-top:0}.wp-item:hover{opacity:.88}.wp-item-body{display:flex;flex-direction:column;gap:12px;min-width:0}.wp-order-head{display:flex;align-items:center;width:100%}.wp-item-line{display:flex;align-items:center;justify-content:space-between;gap:12px;width:100%;min-height:21px;min-width:0}.wp-item-label{flex-shrink:0;font-size:14px;font-weight:500;line-height:1.5;letter-spacing:0;color:var(--wp-text-30);white-space:nowrap}.wp-line-value,.wp-order-side{min-width:0;overflow:hidden;font-size:14px;font-weight:500;line-height:1.5;letter-spacing:0;color:var(--wp-text-60);text-align:right;text-overflow:ellipsis;white-space:nowrap}.wp-order-side--buy{color:var(--wp-mint)}.wp-order-side--sell{color:var(--wp-red)}.wp-svc-token{display:flex;align-items:center;justify-content:flex-end;gap:6px;min-width:0;min-height:21px}.wp-svc-token>span{font-size:14px;font-weight:500;line-height:1.5;letter-spacing:0;color:var(--wp-text-60);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.wp-svc-token-icon{width:16px;height:16px;border-radius:50%;flex-shrink:0;object-fit:cover}.wp-svc-token--amount{align-items:flex-start}.wp-svc-token--amount>.wp-svc-token-icon{margin-top:2.5px}.wp-token-stack{display:inline-flex;align-items:center;justify-content:flex-end;width:29px;min-width:29px;overflow:visible}.wp-token-stack .wp-svc-token-icon+.wp-svc-token-icon{margin-left:-3.5px}.wp-token-subtle,.wp-item-usd{color:var(--wp-text-30)!important}.wp-svc-amount{display:flex;flex-direction:column;align-items:flex-end;justify-content:center;gap:1px;min-width:0}.wp-svc-amount-main{font-size:14px;font-weight:500;line-height:1.5;letter-spacing:0;color:var(--wp-text-60);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:100%}.wp-svc-amount .wp-item-usd{font-size:12px;font-weight:500;line-height:1.35}.wp-order-token{display:flex;align-items:center;gap:8px;min-width:0}.wp-order-token .wp-svc-token-icon{width:32px;height:32px}.wp-order-token-meta{display:flex;min-width:0;flex-direction:column;justify-content:center}.wp-order-token-symbol{overflow:hidden;color:var(--wp-text-60);font-size:14px;font-weight:500;line-height:1.5;text-overflow:ellipsis;white-space:nowrap}.wp-order-token-pair{overflow:hidden;color:var(--wp-text-30);font-size:12px;font-weight:500;line-height:1.5;text-overflow:ellipsis;white-space:nowrap}.wp-item-tags{display:flex;align-items:stretch;gap:8px;width:100%}.wp-tag{appearance:none;display:inline-flex;flex:1 1 0;align-items:center;justify-content:center;gap:0;min-width:0;min-height:33px;padding:6px 10px;border-radius:6px;border:0;background:var(--wp-control);font-family:inherit;font-size:14px;font-weight:600;line-height:1.5;letter-spacing:0;color:var(--wp-text-40);text-align:center;text-decoration:none;white-space:nowrap;box-sizing:border-box;transition:background-color .15s ease,border-color .15s ease,color .15s ease,transform .15s ease}a.wp-tag,button.wp-tag{cursor:pointer}.wp-tag:hover{background:var(--wp-control);transform:none}.wp-tag:focus-visible{outline:2px solid var(--wp-mint);outline-offset:2px}.wp-tag[aria-disabled=true],.wp-tag[data-disabled]{cursor:default;opacity:.48;pointer-events:none}.wp-tag-label{display:inline-flex;align-items:center}.wp-tag-icon{display:none}.wp-tag:hover .wp-tag-icon{transform:none}.wp-tag--mint{color:var(--wp-mint);background:var(--wp-accent-soft)}.wp-tag--mint:hover{background:var(--wp-accent-soft)}.wp-tag--muted{color:var(--wp-text-40)}.wp-svc-empty{display:flex;align-items:center;justify-content:center;min-height:74px;padding:20px 16px;background:var(--wp-card);border-radius:12px;box-shadow:var(--wp-card-shadow, none);font-size:13px;font-weight:400;line-height:1.3;letter-spacing:0;color:var(--wp-text-30);box-sizing:border-box}.wp-claim-overlay{position:absolute;inset:0;z-index:8;display:flex;align-items:flex-end;justify-content:center;background:#00000094;box-sizing:border-box}.wp-claim-sheet{display:flex;flex-direction:column;width:100%;max-width:375px;max-height:calc(100% - 24px);overflow:hidden;border-radius:24px 24px 0 0;background:var(--wp-bg);color:var(--wp-text);box-shadow:0 -18px 48px #00000042;animation:wp-claim-slide-up .22s ease-out}@keyframes wp-claim-slide-up{0%{transform:translateY(18px);opacity:0}to{transform:translateY(0);opacity:1}}.wp-claim-grabber{display:flex;align-items:flex-start;justify-content:center;height:38px;min-height:38px;padding-top:12px;box-sizing:border-box}.wp-claim-grabber span{display:block;width:52px;height:5px;border-radius:999px;background:var(--wp-control)}.wp-claim-content{display:flex;flex-direction:column;align-items:center;gap:16px;width:100%;padding:20px;box-sizing:border-box}.wp-claim-icon{display:inline-flex;align-items:center;justify-content:center;width:64px;height:64px;border-radius:50%;flex-shrink:0}.wp-claim-icon--success{background:var(--wp-claim-success-soft);color:var(--wp-claim-success)}.wp-claim-icon--pending{background:#9b8cef29;color:var(--wp-claim-primary)}.wp-claim-icon--error{background:var(--wp-claim-error-soft);color:var(--wp-claim-error);font-size:30px;font-weight:600;line-height:1}.wp-claim-icon--token{background:#00d4aa29}.wp-claim-icon--token img{width:48px;height:48px;border-radius:50%;object-fit:cover}.wp-claim-icon--token span{display:inline-flex;align-items:center;justify-content:center;width:48px;height:48px;border-radius:50%;background:var(--wp-mint);color:#101820;font-size:18px;font-weight:600}.wp-claim-spinner{width:36px;height:36px;border-radius:50%;border:3px solid rgba(155,140,239,.28);border-top-color:var(--wp-claim-primary);animation:wp-claim-spin .8s linear infinite}@keyframes wp-claim-spin{to{transform:rotate(360deg)}}.wp-claim-copy{display:flex;flex-direction:column;align-items:center;gap:16px;width:100%;text-align:center}.wp-claim-title{margin:0;font-size:20px;font-weight:600;line-height:1.3;letter-spacing:0;color:var(--wp-text)}.wp-claim-desc{max-width:335px;margin:0;font-size:13px;font-weight:400;line-height:1.3;letter-spacing:0;color:var(--wp-text-40)}.wp-claim-heading{display:flex;flex-direction:column;align-items:flex-start;gap:8px;width:100%}.wp-claim-error-message{margin:0;color:var(--wp-claim-error);font-size:13px;font-weight:400;line-height:1.3;letter-spacing:0}.wp-claim-reward-card{display:flex;align-items:center;justify-content:space-between;gap:8px;width:100%;min-height:60px;padding:16px;border-radius:8px;background:var(--wp-card);box-sizing:border-box}.wp-claim-reward-token{display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;border-radius:50%;flex-shrink:0;overflow:hidden;background:var(--wp-control)}.wp-claim-reward-token img{width:28px;height:28px;object-fit:cover}.wp-claim-reward-token span{display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;background:var(--wp-mint);color:#101820;font-size:13px;font-weight:600;line-height:1}.wp-claim-reward-symbol{flex:1 1 auto;min-width:0;overflow:hidden;color:var(--wp-text);font-size:18px;font-weight:600;line-height:1.3;letter-spacing:0;text-overflow:ellipsis;white-space:nowrap}.wp-claim-reward-amount{flex-shrink:0;color:var(--wp-text);font-size:20px;font-weight:600;line-height:1.3;letter-spacing:0;white-space:nowrap}.wp-claim-account-card{display:flex;flex-direction:column;gap:12px;width:100%;padding:16px;border-radius:8px;background:var(--wp-card);box-sizing:border-box}.wp-claim-account-row{display:flex;align-items:center;justify-content:space-between;gap:4px;width:100%;min-height:40px}.wp-claim-account-row>span{flex-shrink:0;color:var(--wp-text-40);font-size:14px;font-weight:400;line-height:1.3;letter-spacing:0;white-space:nowrap}.wp-claim-account{display:flex;align-items:center;gap:8px;min-width:0}.wp-claim-account strong{overflow:hidden;color:var(--wp-text);font-size:15px;font-weight:600;line-height:1.6;letter-spacing:0;text-overflow:ellipsis;white-space:nowrap}.wp-claim-account-avatar{width:32px;height:32px;border-radius:50%;flex-shrink:0;background:radial-gradient(circle at 30% 28%,#d87aff 0 12%,transparent 13%),radial-gradient(circle at 68% 28%,#f0a1ff 0 12%,transparent 13%),radial-gradient(circle at 32% 70%,#b561e7 0 13%,transparent 14%),radial-gradient(circle at 70% 70%,#d4a2ff 0 13%,transparent 14%),radial-gradient(circle at 50% 50%,#8c4fc4 0 18%,transparent 19%),#4a315f;box-shadow:inset 0 0 0 3.37px var(--wp-control)}.wp-claim-divider{display:block;width:100%;height:1px;background:var(--wp-border)}.wp-claim-detail-list{display:flex;flex-direction:column;gap:8px;width:100%}.wp-claim-detail-row{display:flex;align-items:center;justify-content:space-between;gap:20px;width:100%;min-height:20px}.wp-claim-detail-row>span{min-width:0;color:var(--wp-text-40);font-size:13px;font-weight:400;line-height:1.3;letter-spacing:0;white-space:nowrap}.wp-claim-detail-row--sub>span:before{content:"";display:inline-block;width:3px;height:3px;margin:0 8px 3px;background:currentColor}.wp-claim-detail-row strong{min-width:0;overflow:hidden;color:var(--wp-text);font-size:13px;font-weight:400;line-height:1.3;letter-spacing:0;text-align:right;text-overflow:ellipsis;white-space:nowrap}.wp-claim-list{display:flex;flex-direction:column;gap:8px;width:100%;padding-bottom:8px}.wp-claim-list-item{display:flex;align-items:center;justify-content:space-between;gap:16px;min-height:56px;padding:8px 16px;border-radius:8px;background:var(--wp-card);box-sizing:border-box}.wp-claim-list-item>span{flex-shrink:0;font-size:14px;font-weight:400;line-height:1.3;color:var(--wp-text-40);white-space:nowrap}.wp-claim-list-item strong{display:inline-flex;align-items:center;justify-content:flex-end;gap:4px;min-width:0;overflow:hidden;color:var(--wp-text);font-size:14px;font-weight:400;line-height:1.3;text-align:right;text-overflow:ellipsis;white-space:nowrap}.wp-claim-list-item img{width:16px;height:16px;border-radius:50%;flex-shrink:0}.wp-claim-hash{appearance:none;display:inline-flex;align-items:center;justify-content:flex-end;gap:4px;min-width:0;padding:0;border:none;background:transparent;color:var(--wp-text);cursor:pointer;font:inherit}.wp-claim-hash svg{flex-shrink:0;color:var(--wp-text-60)}.wp-claim-gas-card{display:flex;flex-direction:column;gap:4px;width:100%;padding:14px 16px;border-radius:8px;border:1px solid var(--wp-border);background:var(--wp-card);box-sizing:border-box}.wp-claim-gas-row{display:flex;align-items:center;justify-content:space-between;gap:16px;min-height:28px}.wp-claim-gas-row>span{min-width:0;font-size:12px;font-weight:400;line-height:1.3;color:var(--wp-text-40)}.wp-claim-gas-row strong{min-width:0;overflow:hidden;color:var(--wp-text);font-size:12px;font-weight:400;line-height:1.3;text-align:right;text-overflow:ellipsis;white-space:nowrap}.wp-claim-gas-row--primary{min-height:32px}.wp-claim-gas-row--primary>span,.wp-claim-gas-row--primary strong{font-size:14px;color:var(--wp-text)}.wp-claim-fee-label{position:relative;display:inline-flex;align-items:center;text-decoration:underline dotted;text-underline-offset:3px;cursor:help;overflow:visible!important}.wp-claim-fee-tooltip{position:absolute;left:0;bottom:calc(100% + 8px);z-index:2;width:min(260px,calc(100vw - 64px));padding:10px 12px;border-radius:8px;background:var(--wp-tooltip-bg);color:var(--wp-tooltip-text);box-shadow:0 12px 32px #0000003d;font-size:11px;font-weight:400;line-height:1.4;text-align:left;text-decoration:none;white-space:normal;opacity:0;pointer-events:none;transform:translateY(4px);visibility:hidden;transition:opacity .15s ease,transform .15s ease,visibility .15s ease}.wp-claim-fee-label:hover .wp-claim-fee-tooltip,.wp-claim-fee-label:focus .wp-claim-fee-tooltip,.wp-claim-fee-label:focus-visible .wp-claim-fee-tooltip{opacity:1;transform:translateY(0);visibility:visible}.wp-claim-actions{display:flex;align-items:center;gap:8px;width:100%}.wp-claim-primary,.wp-claim-secondary{appearance:none;display:inline-flex;align-items:center;justify-content:center;width:100%;min-width:0;height:52px;padding:0 24px;border:none;border-radius:40px;font-family:inherit;font-size:15px;font-weight:600;line-height:1.3;letter-spacing:0;white-space:nowrap;cursor:pointer}.wp-claim-primary{background:var(--wp-claim-primary);color:var(--wp-claim-primary-text)}.wp-claim-primary:disabled{cursor:default;opacity:.72}.wp-claim-secondary{background:var(--wp-claim-secondary-bg, var(--wp-control));color:var(--wp-claim-primary)}.wp-claim-actions[data-count="2"] .wp-claim-primary{flex:1 1 0}.wp-claim-actions[data-count="2"] .wp-claim-secondary{flex:0 0 120px}.wp-claim-button-spinner{width:16px;height:16px;border-radius:50%;border:2px solid rgba(32,37,48,.28);border-top-color:var(--wp-claim-primary-text);animation:wp-claim-spin .8s linear infinite}.wp-claim-home-indicator{display:flex;align-items:flex-end;justify-content:center;height:34px;min-height:34px;padding-bottom:8px;box-sizing:border-box}.wp-claim-home-indicator span{display:block;width:134px;height:5px;border-radius:16px;background:var(--wp-text-40)}@media(max-width:359px){.wp-header{gap:12px;padding:0 12px}.wp-total{font-size:24px}.wp-body-inner{padding:0 12px 128px;gap:20px}.wp-svc-items,.wp-claim-content{padding:18px 14px}.wp-item-line{gap:10px}.wp-svc-token>span{max-width:168px}}.wp-sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}.wi-drawer-content .wp-header,.wi-portfolio-body .wp-header{padding:16px}.wi-drawer-content .wp-header-edge--right .wp-header-btn,.wi-portfolio-body .wp-header-edge--right .wp-header-btn{top:16px;right:16px}.wp-withdraw-amount-card{display:flex;flex-direction:column;gap:12px;width:100%;padding:16px;border-radius:8px;background:var(--wp-card);box-sizing:border-box}.wp-withdraw-amount-row{display:flex;align-items:center;gap:8px;width:100%}.wp-withdraw-input{flex:1 1 auto;min-width:0;padding:0;border:none;background:transparent;color:var(--wp-text);font-family:inherit;font-size:24px;font-weight:600;line-height:1.3;letter-spacing:0;text-align:left;outline:none}.wp-withdraw-input::placeholder{color:var(--wp-text-30)}.wp-withdraw-input[aria-invalid=true]{color:var(--wp-claim-error)}.wp-withdraw-input-symbol{flex-shrink:0;color:var(--wp-text-40);font-size:15px;font-weight:600;line-height:1.3}.wp-withdraw-quick-row{display:flex;align-items:center;gap:8px;width:100%}.wp-withdraw-quick{appearance:none;flex:1 1 0;min-width:0;height:32px;padding:0 10px;border:1px solid var(--wp-border);border-radius:999px;background:transparent;color:var(--wp-text-60);font-family:inherit;font-size:13px;font-weight:600;line-height:1;white-space:nowrap;cursor:pointer}.wp-withdraw-quick:hover:not(:disabled){border-color:var(--wp-claim-primary);color:var(--wp-claim-primary)}.wp-withdraw-quick:disabled{cursor:default;opacity:.5}.wp-withdraw-content{overflow-y:auto}.wp-withdraw-token-list{display:flex;flex-direction:column;gap:8px;width:100%;max-height:216px;overflow-y:auto}.wp-withdraw-token{appearance:none;display:flex;align-items:center;gap:10px;width:100%;min-height:52px;padding:10px 12px;border:1px solid var(--wp-border);border-radius:8px;background:var(--wp-card);color:var(--wp-text);font-family:inherit;text-align:left;cursor:pointer;box-sizing:border-box}.wp-withdraw-token[data-selected]{border-color:var(--wp-claim-primary);box-shadow:inset 0 0 0 1px var(--wp-claim-primary)}.wp-withdraw-token:disabled{cursor:default;opacity:.6}.wp-withdraw-token-icon{display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;border-radius:50%;flex-shrink:0;overflow:hidden;background:var(--wp-control)}.wp-withdraw-token-icon img{width:28px;height:28px;object-fit:cover}.wp-withdraw-token-icon span{display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;background:var(--wp-mint);color:#101820;font-size:13px;font-weight:600;line-height:1}.wp-withdraw-token-symbol{flex:1 1 auto;min-width:0;overflow:hidden;font-size:15px;font-weight:600;line-height:1.3;text-overflow:ellipsis;white-space:nowrap}.wp-withdraw-token-amount{flex-shrink:0;color:var(--wp-text-40);font-size:13px;font-weight:500;line-height:1.3;white-space:nowrap}
|
|
8
|
-
`);var re=require("react/jsx-runtime"),$r=5,tp="wp:";function mn({env:e,theme:t="light",walletAddress:n,walletName:o,onBack:r,showHeader:i=!0,variant:a="embed",className:s,onOutlink:c,lpBalanceReader:d,stakingRewardsReader:f,sendTransaction:h,estimateGas:g,sections:u}){let v=He(e),b=De.useCallback(Y=>!u||u.includes(Y),[u]),w=!!n,y=(0,Js.useQueryClient)(),[E,m]=De.useState($r),[C,R]=De.useState(!1),[k,T]=De.useState(!1),G=De.useRef(void 0),F=De.useCallback(()=>{y.invalidateQueries({predicate:Y=>typeof Y.queryKey[0]=="string"&&Y.queryKey[0].startsWith(tp)})},[y]),K=De.useCallback(()=>{F(),R(!0),setTimeout(()=>R(!1),600),m($r)},[F]);De.useEffect(()=>{if(!w)return;let Y=setInterval(()=>{m(ye=>ye<=1?(K(),$r):ye-1)},1e3);return()=>clearInterval(Y)},[w,K]);let D=De.useCallback(()=>{r?.()},[r]),Q=w?jt(v,n,{size:64}):void 0,A=De.useCallback(async()=>{if(!(k||!n))try{await navigator.clipboard.writeText(n),T(!0),clearTimeout(G.current),G.current=setTimeout(()=>T(!1),2e3)}catch{}},[n,k]);De.useEffect(()=>()=>clearTimeout(G.current),[]);let ae=De.useMemo(()=>({env:v,theme:t,open:!0,walletAddress:n,close:D,onOutlink:c,lpBalanceReader:d,stakingRewardsReader:f,sendTransaction:h,estimateGas:g}),[v,t,n,D,c,d,f,h,g]),B=(0,re.jsxs)(re.Fragment,{children:[i&&(0,re.jsxs)("div",{className:"wp-header",children:[(0,re.jsxs)("div",{className:"wp-header-account",children:[r&&(0,re.jsx)("button",{type:"button",className:"wp-header-btn","aria-label":"Back",onClick:r,children:(0,re.jsx)(Vi,{})}),(0,re.jsx)("span",{className:"wp-header-avatar","aria-hidden":!0,children:Q&&(0,re.jsx)("img",{src:Q,alt:"",className:"wp-header-avatar-img",draggable:!1})}),(o||n)&&(0,re.jsxs)("div",{className:"wp-header-account-meta",children:[o&&(0,re.jsx)("span",{className:"wp-header-wallet-name",title:o,children:o}),n&&(0,re.jsxs)("button",{type:"button",className:"wp-header-address-btn",onClick:A,"aria-label":"Copy wallet address",children:[(0,re.jsx)("span",{className:"wp-header-address",children:Go(n)}),(0,re.jsx)("span",{className:"wp-header-address-copy","data-copied":k,children:k?(0,re.jsx)(cn,{size:14}):(0,re.jsx)(Gn,{size:14})})]})]})]}),(0,re.jsxs)("button",{type:"button",className:"wp-header-btn wp-refresh-btn","aria-label":"Refresh portfolio",onClick:K,children:[(0,re.jsx)(qi,{className:C?"wp-spin-once":void 0}),w&&(0,re.jsx)("span",{className:"wp-refresh-badge",children:E})]})]}),(0,re.jsx)("div",{className:"wp-body",children:(0,re.jsxs)("div",{className:"wp-body-inner",children:[b("rewards")&&(0,re.jsx)(ks,{}),b("points")&&(0,re.jsx)(Rs,{}),b("staking")&&(0,re.jsx)(Os,{}),b("gameSwap")&&(0,re.jsx)($s,{}),b("forge")&&(0,re.jsx)(Xs,{})]})})]});return(0,re.jsx)(Vn.Provider,{value:ae,children:a==="none"?B:(0,re.jsx)("div",{className:se(a==="fullscreen"?"wp-fullscreen":"wp-embed",s),"data-theme":t,children:B})})}var gn=require("react/jsx-runtime");function el({className:e}){let{env:t,theme:n,walletAddress:o,close:r,onOutlink:i,lpBalanceReader:a,stakingRewardsReader:s}=je();return(0,gn.jsxs)(Yn.Drawer.Portal,{children:[(0,gn.jsx)(Yn.Drawer.Overlay,{className:"wp-overlay"}),(0,gn.jsxs)(Yn.Drawer.Content,{className:se("wp-fullscreen",e),"data-theme":n,children:[(0,gn.jsx)(Yn.Drawer.Title,{className:"wp-sr-only",children:"Portfolio"}),(0,gn.jsx)(mn,{env:t,theme:n,walletAddress:o,onBack:r,variant:"none",onOutlink:i,lpBalanceReader:a,stakingRewardsReader:s})]})]})}var jr=require("react/jsx-runtime");function np({env:e,theme:t="light",walletAddress:n,open:o,onOpenChange:r,onOutlink:i,lpBalanceReader:a,stakingRewardsReader:s,sendTransaction:c,estimateGas:d,children:f}){let h=He(e),g=o!==void 0,[u,v]=hn.useState(!1),b=g?o:u,w=hn.useCallback(m=>{g||v(m),r?.(m)},[g,r]),y=hn.useCallback(()=>w(!1),[w]),E=hn.useMemo(()=>({env:h,theme:t,open:b,walletAddress:n,close:y,onOutlink:i,lpBalanceReader:a,stakingRewardsReader:s,sendTransaction:c,estimateGas:d}),[h,t,b,n,y,i,a,s,c,d]);return(0,jr.jsx)(Vn.Provider,{value:E,children:(0,jr.jsx)(tl.Drawer.Root,{direction:"bottom",open:b,onOpenChange:w,noBodyStyles:!0,children:f})})}var Vr=Object.assign(np,{Trigger:ji,Content:el});var qr=["rewards","points","staking","gameSwap","forge"];var I=H(require("react"),1),bn=require("react-dom"),Et=H(require("bignumber.js"),1);var Xe=require("react/jsx-runtime");function nl({size:e=20,className:t}){return(0,Xe.jsxs)("svg",{width:e,height:e,viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t,"aria-hidden":"true",children:[(0,Xe.jsx)("circle",{cx:"9",cy:"9",r:"6",stroke:"currentColor",strokeWidth:1.7}),(0,Xe.jsx)("path",{d:"m17 17-3.2-3.2",stroke:"currentColor",strokeWidth:1.7,strokeLinecap:"round"})]})}function ol({size:e=16,className:t}){return(0,Xe.jsx)("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t,children:(0,Xe.jsx)("path",{d:"M2.667 8a5.333 5.333 0 1 0 1.562-3.771L2.667 5.79M2.667 2.667v3.124h3.124M8 5.333V8l1.667 1",stroke:"currentColor",strokeWidth:1.333,strokeLinecap:"round",strokeLinejoin:"round"})})}function rl({size:e=16,className:t}){return(0,Xe.jsx)("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t,children:(0,Xe.jsx)("path",{d:"M2.667 4h4M9.333 4h4M6.667 2.667v2.666M2.667 12h4M9.333 12h4M9.333 10.667v2.666M2.667 8h1.666M7 8h6.333M4.333 6.667v2.666",stroke:"currentColor",strokeWidth:1.333,strokeLinecap:"round",strokeLinejoin:"round"})})}function al({size:e=20,className:t}){return(0,Xe.jsx)("svg",{width:e,height:e,viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t,children:(0,Xe.jsx)("path",{d:"M10 4.167v11.666M4.167 10 10 15.833 15.833 10",stroke:"currentColor",strokeWidth:1.667,strokeLinecap:"round",strokeLinejoin:"round"})})}function il({size:e=16,className:t}){return(0,Xe.jsx)("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t,"aria-hidden":"true",children:(0,Xe.jsx)("path",{d:"M3.333 8h9.334M8.667 4l4 4-4 4",stroke:"currentColor",strokeWidth:1.333,strokeLinecap:"round",strokeLinejoin:"round"})})}function sl({size:e=12,className:t}){return(0,Xe.jsx)("svg",{width:e,height:e,viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t,children:(0,Xe.jsx)("path",{d:"M3.5 2 1.5 4l2 2M1.5 4h9M8.5 10l2-2-2-2M10.5 8h-9",stroke:"currentColor",strokeWidth:1.2,strokeLinecap:"round",strokeLinejoin:"round"})})}var P=H(require("react"),1);var Kr=H(require("bignumber.js"),1);function ll(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function cl(e){return!e.isFinite()||e.isNaN()||e.lte(0)?"":e.decimalPlaces(6,Kr.default.ROUND_DOWN).toFixed()}function op(e){return e.fromToken.symbol.toLowerCase()===e.toToken.symbol.toLowerCase()||e.fromToken.chainId===e.toToken.chainId&&e.fromToken.address.toLowerCase()===e.toToken.address.toLowerCase()}function rp(e){let t=e.fromToken.priceUsd,n=e.toToken.priceUsd,o=e.lastChangedBy==="to"?e.toAmount:e.fromAmount,r=new Kr.default(o||"0");return!r.isFinite()||r.isNaN()||r.lte(0)?{fromAmount:e.fromAmount,toAmount:e.toAmount}:ll(t)&&ll(n)?e.lastChangedBy==="to"?{fromAmount:cl(r.multipliedBy(n).dividedBy(t))}:{toAmount:cl(r.multipliedBy(t).dividedBy(n))}:op(e)?e.lastChangedBy==="to"?{fromAmount:e.toAmount}:{toAmount:e.fromAmount}:{fromAmount:e.lastChangedBy==="to"?"":e.fromAmount,toAmount:e.lastChangedBy==="from"?"":e.toAmount}}function dl({getQuote:e,submitBridge:t}){return{canQuote:!!e,canSubmit:!!t,async getQuote(n){return e?e(n):rp(n)},async submitBridge(n){if(!t)throw new Error("Bridge submit handler is not configured.");return t(n)}}}var pl=15,ap=18,gl="cross_bridge_terms_accepted",ip=3600*24*365;function sp(e){let t=e.replace(/[^\d.]/g,""),n=t.indexOf(".");n!==-1&&(t=t.slice(0,n+1)+t.slice(n+1).replace(/\./g,""));let o=t.indexOf(".");if(o===-1)return t.slice(0,pl);let r=t.slice(0,o).slice(0,pl),i=t.slice(o+1).slice(0,ap);return`${r}.${i}`}function lp(){return typeof document>"u"?!1:document.cookie.split(";").map(e=>e.trim()).some(e=>e===`${gl}=true`)}function cp(){if(typeof document>"u")return;let e=typeof window<"u"&&window.location.protocol==="https:"?"; Secure":"";document.cookie=[`${gl}=true`,"Path=/",`Max-Age=${ip}`,"SameSite=Lax",e].filter(Boolean).join("; ")}function dp(e){let t=Number(e??"0");if(!Number.isFinite(t)||t<.1)return"1";let n=o=>Math.floor(o*100)/100;if(t<3){let o=n(t*3);return String(o<1?1:o)}return"10"}function fl(e){let t=e.toUpperCase();return t.startsWith("T")&&t.slice(1).startsWith("CROSS")?t.slice(1):t}function pp(e,t){if(!e||!t||e.chainId!==t.chainId)return!1;let n=new Set([fl(e.symbol),fl(t.symbol)]);return n.has("CROSS")&&n.has("CROSSD")}function It(e,t){return!!e&&!!t&&e.chainId===t.chainId&&e.address.toLowerCase()===t.address.toLowerCase()}function Yo(e){return e[0]}function Qr(e,t,n,o){if(n&&!It(n,t))return n;let r=t?o?.(t,e):void 0;if(r?.length)return r[0];if(!t)return e[1]??Yo(e);let i=e.findIndex(s=>It(s,t)),a=i>=0?e[i+1]:void 0;return a&&!It(a,t)?a:e.find(s=>!It(s,t))??t}function ul({fromToken:e,toToken:t,fromAmount:n,toAmount:o,lastChangedBy:r,slippage:i}){return{fromToken:e,toToken:t,fromAmount:n,toAmount:o,lastChangedBy:r,slippage:i}}function Zo(e,t=0){if(!e||t>5)return[];if(typeof e=="string")return[e];if(!(e instanceof Error)&&typeof e!="object")return[String(e)];let n=e;return[...[e instanceof Error?e.name:n.name,e instanceof Error?e.message:n.message,n.shortMessage,n.details,n.code].filter(r=>typeof r=="string"||typeof r=="number").map(String),...Zo(n.cause,t+1),...Zo(n.data,t+1),...Zo(n.error,t+1)]}function Yr(e){let t=Zo(e).join(" ").toLowerCase(),n=t.includes("signature_failed")&&(t.includes("\uD0C0\uC785 \uB370\uC774\uD130 \uC11C\uBA85\uC5D0 \uC2E4\uD328")||t.includes("typed data")||t.includes("signtypeddata"));return t.includes("4001")||t.includes("err_user_rejected")||t.includes("userrejectedrequesterror")||t.includes("user rejected")||t.includes("user denied")||t.includes("user cancelled")||t.includes("user canceled")||t.includes("rejected the request")||t.includes("request rejected")||t.includes("action_rejected")||t.includes("rejected by user")||n}function ml(e,t){return Yr(e)?"Transaction request was rejected.":(e instanceof Error?e.message:typeof e=="string"?e:"").split(`
|
|
8
|
+
`);var re=require("react/jsx-runtime"),$r=2,tp="wp:";function mn({env:e,theme:t="light",walletAddress:n,walletName:o,onBack:r,showHeader:i=!0,variant:a="embed",className:s,onOutlink:c,lpBalanceReader:d,stakingRewardsReader:f,sendTransaction:h,estimateGas:g,sections:u}){let v=He(e),b=De.useCallback(Y=>!u||u.includes(Y),[u]),w=!!n,y=(0,Js.useQueryClient)(),[E,m]=De.useState($r),[C,R]=De.useState(!1),[k,T]=De.useState(!1),G=De.useRef(void 0),F=De.useCallback(()=>{y.invalidateQueries({predicate:Y=>typeof Y.queryKey[0]=="string"&&Y.queryKey[0].startsWith(tp)})},[y]),K=De.useCallback(()=>{F(),R(!0),setTimeout(()=>R(!1),600),m($r)},[F]);De.useEffect(()=>{if(!w)return;let Y=setInterval(()=>{m(ye=>ye<=1?(K(),$r):ye-1)},1e3);return()=>clearInterval(Y)},[w,K]);let D=De.useCallback(()=>{r?.()},[r]),Q=w?jt(v,n,{size:64}):void 0,A=De.useCallback(async()=>{if(!(k||!n))try{await navigator.clipboard.writeText(n),T(!0),clearTimeout(G.current),G.current=setTimeout(()=>T(!1),2e3)}catch{}},[n,k]);De.useEffect(()=>()=>clearTimeout(G.current),[]);let ae=De.useMemo(()=>({env:v,theme:t,open:!0,walletAddress:n,close:D,onOutlink:c,lpBalanceReader:d,stakingRewardsReader:f,sendTransaction:h,estimateGas:g}),[v,t,n,D,c,d,f,h,g]),B=(0,re.jsxs)(re.Fragment,{children:[i&&(0,re.jsxs)("div",{className:"wp-header",children:[(0,re.jsxs)("div",{className:"wp-header-account",children:[r&&(0,re.jsx)("button",{type:"button",className:"wp-header-btn","aria-label":"Back",onClick:r,children:(0,re.jsx)(Vi,{})}),(0,re.jsx)("span",{className:"wp-header-avatar","aria-hidden":!0,children:Q&&(0,re.jsx)("img",{src:Q,alt:"",className:"wp-header-avatar-img",draggable:!1})}),(o||n)&&(0,re.jsxs)("div",{className:"wp-header-account-meta",children:[o&&(0,re.jsx)("span",{className:"wp-header-wallet-name",title:o,children:o}),n&&(0,re.jsxs)("button",{type:"button",className:"wp-header-address-btn",onClick:A,"aria-label":"Copy wallet address",children:[(0,re.jsx)("span",{className:"wp-header-address",children:Go(n)}),(0,re.jsx)("span",{className:"wp-header-address-copy","data-copied":k,children:k?(0,re.jsx)(cn,{size:14}):(0,re.jsx)(Gn,{size:14})})]})]})]}),(0,re.jsxs)("button",{type:"button",className:"wp-header-btn wp-refresh-btn","aria-label":"Refresh portfolio",onClick:K,children:[(0,re.jsx)(qi,{className:C?"wp-spin-once":void 0}),w&&(0,re.jsx)("span",{className:"wp-refresh-badge",children:E})]})]}),(0,re.jsx)("div",{className:"wp-body",children:(0,re.jsxs)("div",{className:"wp-body-inner",children:[b("rewards")&&(0,re.jsx)(ks,{}),b("points")&&(0,re.jsx)(Rs,{}),b("staking")&&(0,re.jsx)(Os,{}),b("gameSwap")&&(0,re.jsx)($s,{}),b("forge")&&(0,re.jsx)(Xs,{})]})})]});return(0,re.jsx)(Vn.Provider,{value:ae,children:a==="none"?B:(0,re.jsx)("div",{className:se(a==="fullscreen"?"wp-fullscreen":"wp-embed",s),"data-theme":t,children:B})})}var gn=require("react/jsx-runtime");function el({className:e}){let{env:t,theme:n,walletAddress:o,close:r,onOutlink:i,lpBalanceReader:a,stakingRewardsReader:s}=je();return(0,gn.jsxs)(Yn.Drawer.Portal,{children:[(0,gn.jsx)(Yn.Drawer.Overlay,{className:"wp-overlay"}),(0,gn.jsxs)(Yn.Drawer.Content,{className:se("wp-fullscreen",e),"data-theme":n,children:[(0,gn.jsx)(Yn.Drawer.Title,{className:"wp-sr-only",children:"Portfolio"}),(0,gn.jsx)(mn,{env:t,theme:n,walletAddress:o,onBack:r,variant:"none",onOutlink:i,lpBalanceReader:a,stakingRewardsReader:s})]})]})}var jr=require("react/jsx-runtime");function np({env:e,theme:t="light",walletAddress:n,open:o,onOpenChange:r,onOutlink:i,lpBalanceReader:a,stakingRewardsReader:s,sendTransaction:c,estimateGas:d,children:f}){let h=He(e),g=o!==void 0,[u,v]=hn.useState(!1),b=g?o:u,w=hn.useCallback(m=>{g||v(m),r?.(m)},[g,r]),y=hn.useCallback(()=>w(!1),[w]),E=hn.useMemo(()=>({env:h,theme:t,open:b,walletAddress:n,close:y,onOutlink:i,lpBalanceReader:a,stakingRewardsReader:s,sendTransaction:c,estimateGas:d}),[h,t,b,n,y,i,a,s,c,d]);return(0,jr.jsx)(Vn.Provider,{value:E,children:(0,jr.jsx)(tl.Drawer.Root,{direction:"bottom",open:b,onOpenChange:w,noBodyStyles:!0,children:f})})}var Vr=Object.assign(np,{Trigger:ji,Content:el});var qr=["rewards","points","staking","gameSwap","forge"];var I=H(require("react"),1),bn=require("react-dom"),Et=H(require("bignumber.js"),1);var Xe=require("react/jsx-runtime");function nl({size:e=20,className:t}){return(0,Xe.jsxs)("svg",{width:e,height:e,viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t,"aria-hidden":"true",children:[(0,Xe.jsx)("circle",{cx:"9",cy:"9",r:"6",stroke:"currentColor",strokeWidth:1.7}),(0,Xe.jsx)("path",{d:"m17 17-3.2-3.2",stroke:"currentColor",strokeWidth:1.7,strokeLinecap:"round"})]})}function ol({size:e=16,className:t}){return(0,Xe.jsx)("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t,children:(0,Xe.jsx)("path",{d:"M2.667 8a5.333 5.333 0 1 0 1.562-3.771L2.667 5.79M2.667 2.667v3.124h3.124M8 5.333V8l1.667 1",stroke:"currentColor",strokeWidth:1.333,strokeLinecap:"round",strokeLinejoin:"round"})})}function rl({size:e=16,className:t}){return(0,Xe.jsx)("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t,children:(0,Xe.jsx)("path",{d:"M2.667 4h4M9.333 4h4M6.667 2.667v2.666M2.667 12h4M9.333 12h4M9.333 10.667v2.666M2.667 8h1.666M7 8h6.333M4.333 6.667v2.666",stroke:"currentColor",strokeWidth:1.333,strokeLinecap:"round",strokeLinejoin:"round"})})}function al({size:e=20,className:t}){return(0,Xe.jsx)("svg",{width:e,height:e,viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t,children:(0,Xe.jsx)("path",{d:"M10 4.167v11.666M4.167 10 10 15.833 15.833 10",stroke:"currentColor",strokeWidth:1.667,strokeLinecap:"round",strokeLinejoin:"round"})})}function il({size:e=16,className:t}){return(0,Xe.jsx)("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t,"aria-hidden":"true",children:(0,Xe.jsx)("path",{d:"M3.333 8h9.334M8.667 4l4 4-4 4",stroke:"currentColor",strokeWidth:1.333,strokeLinecap:"round",strokeLinejoin:"round"})})}function sl({size:e=12,className:t}){return(0,Xe.jsx)("svg",{width:e,height:e,viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t,children:(0,Xe.jsx)("path",{d:"M3.5 2 1.5 4l2 2M1.5 4h9M8.5 10l2-2-2-2M10.5 8h-9",stroke:"currentColor",strokeWidth:1.2,strokeLinecap:"round",strokeLinejoin:"round"})})}var P=H(require("react"),1);var Kr=H(require("bignumber.js"),1);function ll(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function cl(e){return!e.isFinite()||e.isNaN()||e.lte(0)?"":e.decimalPlaces(6,Kr.default.ROUND_DOWN).toFixed()}function op(e){return e.fromToken.symbol.toLowerCase()===e.toToken.symbol.toLowerCase()||e.fromToken.chainId===e.toToken.chainId&&e.fromToken.address.toLowerCase()===e.toToken.address.toLowerCase()}function rp(e){let t=e.fromToken.priceUsd,n=e.toToken.priceUsd,o=e.lastChangedBy==="to"?e.toAmount:e.fromAmount,r=new Kr.default(o||"0");return!r.isFinite()||r.isNaN()||r.lte(0)?{fromAmount:e.fromAmount,toAmount:e.toAmount}:ll(t)&&ll(n)?e.lastChangedBy==="to"?{fromAmount:cl(r.multipliedBy(n).dividedBy(t))}:{toAmount:cl(r.multipliedBy(t).dividedBy(n))}:op(e)?e.lastChangedBy==="to"?{fromAmount:e.toAmount}:{toAmount:e.fromAmount}:{fromAmount:e.lastChangedBy==="to"?"":e.fromAmount,toAmount:e.lastChangedBy==="from"?"":e.toAmount}}function dl({getQuote:e,submitBridge:t}){return{canQuote:!!e,canSubmit:!!t,async getQuote(n){return e?e(n):rp(n)},async submitBridge(n){if(!t)throw new Error("Bridge submit handler is not configured.");return t(n)}}}var pl=15,ap=18,gl="cross_bridge_terms_accepted",ip=3600*24*365;function sp(e){let t=e.replace(/[^\d.]/g,""),n=t.indexOf(".");n!==-1&&(t=t.slice(0,n+1)+t.slice(n+1).replace(/\./g,""));let o=t.indexOf(".");if(o===-1)return t.slice(0,pl);let r=t.slice(0,o).slice(0,pl),i=t.slice(o+1).slice(0,ap);return`${r}.${i}`}function lp(){return typeof document>"u"?!1:document.cookie.split(";").map(e=>e.trim()).some(e=>e===`${gl}=true`)}function cp(){if(typeof document>"u")return;let e=typeof window<"u"&&window.location.protocol==="https:"?"; Secure":"";document.cookie=[`${gl}=true`,"Path=/",`Max-Age=${ip}`,"SameSite=Lax",e].filter(Boolean).join("; ")}function dp(e){let t=Number(e??"0");if(!Number.isFinite(t)||t<.1)return"1";let n=o=>Math.floor(o*100)/100;if(t<3){let o=n(t*3);return String(o<1?1:o)}return"10"}function fl(e){let t=e.toUpperCase();return t.startsWith("T")&&t.slice(1).startsWith("CROSS")?t.slice(1):t}function pp(e,t){if(!e||!t||e.chainId!==t.chainId)return!1;let n=new Set([fl(e.symbol),fl(t.symbol)]);return n.has("CROSS")&&n.has("CROSSD")}function It(e,t){return!!e&&!!t&&e.chainId===t.chainId&&e.address.toLowerCase()===t.address.toLowerCase()}function Yo(e){return e[0]}function Qr(e,t,n,o){if(n&&!It(n,t))return n;let r=t?o?.(t,e):void 0;if(r?.length)return r[0];if(!t)return e[1]??Yo(e);let i=e.findIndex(s=>It(s,t)),a=i>=0?e[i+1]:void 0;return a&&!It(a,t)?a:e.find(s=>!It(s,t))??t}function ul({fromToken:e,toToken:t,fromAmount:n,toAmount:o,lastChangedBy:r,slippage:i}){return{fromToken:e,toToken:t,fromAmount:n,toAmount:o,lastChangedBy:r,slippage:i}}function Zo(e,t=0){if(!e||t>5)return[];if(typeof e=="string")return[e];if(!(e instanceof Error)&&typeof e!="object")return[String(e)];let n=e;return[...[e instanceof Error?e.name:n.name,e instanceof Error?e.message:n.message,n.shortMessage,n.details,n.code].filter(r=>typeof r=="string"||typeof r=="number").map(String),...Zo(n.cause,t+1),...Zo(n.data,t+1),...Zo(n.error,t+1)]}function Yr(e){let t=Zo(e).join(" ").toLowerCase(),n=t.includes("signature_failed")&&(t.includes("\uD0C0\uC785 \uB370\uC774\uD130 \uC11C\uBA85\uC5D0 \uC2E4\uD328")||t.includes("typed data")||t.includes("signtypeddata"));return t.includes("4001")||t.includes("err_user_rejected")||t.includes("userrejectedrequesterror")||t.includes("user rejected")||t.includes("user denied")||t.includes("user cancelled")||t.includes("user canceled")||t.includes("rejected the request")||t.includes("request rejected")||t.includes("action_rejected")||t.includes("rejected by user")||n}function ml(e,t){return Yr(e)?"Transaction request was rejected.":(e instanceof Error?e.message:typeof e=="string"?e:"").split(`
|
|
9
9
|
`)[0]?.trim()||t}function hl(e){let{tokens:t,initialFromToken:n,initialToToken:o,getToTokens:r,getApproval:i,approveBridge:a,history:s=[],initialSlippage:c="1",termsUrl:d=Tn,getQuote:f,submitBridge:h,onSubmitted:g,onSuccess:u,onFailed:v,onExit:b}=e,w=P.useMemo(()=>dl({getQuote:f,submitBridge:h}),[f,h]),[y,E]=P.useState("form"),[m,C]=P.useState(n??Yo(t)),[R,k]=P.useState(()=>Qr(t,n??Yo(t),o,r)),[T,G]=P.useState(""),[F,K]=P.useState(""),[D,Q]=P.useState("from"),[A,ae]=P.useState(c),[B,Y]=P.useState(null),ye=P.useMemo(()=>pp(m,R),[m,R]),de=P.useMemo(()=>ye?"1":A==="auto"?dp(B?.priceImpact):A,[ye,A,B?.priceImpact]),[J,be]=P.useState(""),[ue,Z]=P.useState("idle"),[z,ee]=P.useState(""),[ze,ve]=P.useState(null),[gt,Be]=P.useState([]),[Yt,ht]=P.useState(!1),[et,Gt]=P.useState(lp),[_e,Re]=P.useState(null),[dt,Me]=P.useState(!1),[Ge,Ce]=P.useState(null),[Lt,bt]=P.useState(null),[At,nt]=P.useState(!1),[Pt,ot]=P.useState(!1),Te=P.useRef(0),rt=P.useRef(null),pt=P.useCallback(()=>{rt.current&&(clearTimeout(rt.current),rt.current=null)},[]),Ve=P.useCallback(_=>{pt(),bt(_)},[pt]);P.useEffect(()=>pt,[pt]),P.useEffect(()=>{let _=t.find(Ke=>It(Ke,m))??Yo(t),Pe=_?r?.(_,t):void 0,$=Pe?.find(Ke=>It(Ke,R))??(Pe?void 0:t.find(Ke=>It(Ke,R)))??Qr(t,_,void 0,r);C(_),k($)},[r,t,m,R]);let wt=P.useCallback((_,Pe)=>{let $=sp(_);if(!$){Te.current+=1,G(""),K(""),Q(Pe),Y(null),be(""),Z("idle");return}Pe==="from"?G($):K($),Q(Pe),be("")},[]),ke=P.useCallback(()=>{Te.current+=1,G(""),K(""),Q("from"),Y(null),be(""),ee(""),Z("idle"),Re(null),Me(!1),Ce(null),nt(!1),Ve(null)},[Ve]),Le=P.useCallback(_=>{It(_,m)||(C(_),k(Qr(t,_,void 0,r)),ke())},[m,r,ke,t]),Ft=P.useCallback(_=>{It(_,R)||It(_,m)||(k(_),ke())},[m,ke,R]),xt=P.useMemo(()=>m?r?.(m,t)??t.filter(_=>!It(_,m)):[],[m,r,t]),qe=P.useCallback(()=>{m?.balance&&wt(m.balance,"from")},[m?.balance,wt]),ft=P.useCallback(()=>{!m||!R||(C(R),k(m),ke())},[m,ke,R]),vt=P.useCallback(()=>{Te.current+=1,G(""),K(""),Q("from"),Y(null),be(""),ee("")},[]);P.useEffect(()=>{if(!m||!R)return;if(!T&&!F){Y(null),be(""),Z($=>$==="quoting"?"idle":$);return}let _=++Te.current,Pe=ul({fromToken:m,toToken:R,fromAmount:T,toAmount:F,lastChangedBy:D,slippage:A});Z($=>$==="submitting"?$:w.canQuote?"quoting":"idle"),(async()=>{try{let $=await w.getQuote(Pe);if(Te.current!==_)return;$.fromAmount!==void 0&&D==="to"&&G($.fromAmount),$.toAmount!==void 0&&D==="from"&&K($.toAmount),Y($.summary??null),be($.error??"")}catch($){if(Te.current!==_)return;be($ instanceof Error?$.message:"Failed to quote bridge.")}finally{Te.current===_&&Z($=>$==="quoting"?"idle":$)}})()},[T,m,D,w,A,F,R]);let Ae=P.useCallback(()=>!m||!R?null:ul({fromToken:m,toToken:R,fromAmount:T,toAmount:F,lastChangedBy:D,slippage:de}),[de,T,m,D,F,R]),Oe=P.useCallback(async(_,Pe)=>{ee(""),nt(!1),Me(!1),Z("submitting");try{if(!Pe?.skipApprovalCheck&&i){let Ke=await i(_);if(Ke){Re(Ke),Ce(_),Z("idle");return}}Re(null),Ce(null),Ve("processing");let $=await w.submitBridge(_);ve($),Z("success"),Be(Ke=>[{id:$.txHash,timestamp:new Date().toISOString(),txHash:$.txHash,fromToken:$.fromToken,toToken:$.toToken,fromAmount:$.fromAmount,toAmount:$.toAmount,summary:B??void 0,status:"pending"},...Ke.filter(ut=>ut.txHash!==$.txHash)]),vt(),ot(!0),Ve(null),nt(!0),g?.($),u?.($)}catch($){if(Ve(null),Yr($)){Z("idle");return}let Ke=ml($,"Failed to submit bridge.");ee(Ke),Z("error"),v?.({message:Ke})}},[i,v,g,u,w,vt,Ve,B]),N=P.useCallback(async()=>{if(J)return;let _=Ae();if(_){if(!et){Ce(_),ht(!0);return}await Oe(_)}},[Ae,J,Oe,et]),te=P.useCallback(async()=>{let _=Ge??Ae();_&&(cp(),Gt(!0),ht(!1),await Oe(_))},[Ae,Ge,Oe]),we=P.useCallback(()=>{ht(!1),Ce(null)},[]),at=P.useCallback(async()=>{if(!(ue==="submitting"||!_e||!Ge||!a)){ee(""),Z("submitting");try{await a(Ge,_e),Re(null),Z("idle"),Me(!0)}catch(_){if(Yr(_)){Z("idle");return}let Pe=ml(_,"Failed to approve token.");ee(Pe),Z("error"),v?.({message:Pe})}}},[_e,a,v,Ge,Oe,ue]),Ut=P.useCallback(()=>{ue!=="submitting"&&(Re(null),Me(!1),Ce(null),Z("idle"))},[ue]),it=P.useCallback(async()=>{if(ue==="submitting")return;let _=Ge??Ae();if(!_){Me(!1),ee("Bridge input is no longer available. Please try again."),Z("error");return}Me(!1),await Oe(_,{skipApprovalCheck:!0})},[Ae,Ge,Oe,ue]),vn=P.useCallback(()=>{nt(!1)},[]),Ht=P.useCallback(_=>{E(_),_==="history"&&ot(!1)},[]),yn=P.useCallback(()=>{if(y==="history"){Ht("form");return}b?.()},[b,Ht,y]),co=P.useMemo(()=>[...s,...gt.filter(_=>!s.some(Pe=>Pe.txHash===_.txHash))],[s,gt]);return{step:y,setStep:Ht,status:ue,error:z,quoteError:J,fromToken:m,toToken:R,tokens:t,availableToTokens:xt,fromAmount:T,toAmount:F,lastChangedBy:D,slippage:A,effectiveSlippage:de,slippageLocked:ye,setSlippage:ae,summary:B,history:co,submitted:ze,canSubmit:w.canSubmit,termsOpen:Yt,approvalInfo:_e,approvalSuccessOpen:dt,approveBridge:a,pendingSubmitInput:Ge,submitToast:Lt,successDialogOpen:At,dismissSuccessDialog:vn,hasNewHistory:Pt,termsUrl:d,setFromToken:C,setToToken:k,selectFromToken:Le,selectToToken:Ft,setAmount:wt,setMax:qe,swapTokens:ft,submit:N,confirmTerms:te,cancelTerms:we,confirmApproval:at,cancelApproval:Ut,continueAfterApproval:it,back:yn}}j(`.bf-root{--bf-bg: var(--ds-bg-default, #1e232e);--bf-surface: var(--ds-surface-medium, rgba(255, 255, 255, .05));--bf-surface-hover: var(--ds-surface-high, rgba(255, 255, 255, .08));--bf-border: var(--ds-border-default, rgba(255, 255, 255, .07));--bf-text-high: var(--ds-content-high, rgba(255, 255, 255, .85));--bf-text-medium: var(--ds-content-medium, rgba(255, 255, 255, .65));--bf-text-low: var(--ds-content-low, rgba(255, 255, 255, .4));--bf-toast-bg: #1e232e;--bf-toast-color: rgba(255, 255, 255, .85);position:relative;display:flex;flex:1;min-height:0;flex-direction:column;overflow:hidden;background:var(--bf-bg);color:var(--ds-content-highest, #ffffff);font-family:inherit}[data-theme=dark].wi-popover-content .bf-root,[data-theme=dark].wi-drawer-content .bf-root{--bf-bg: var(--ds-bg-default, #121212);--bf-surface: var(--ds-surface-medium, rgba(255, 255, 255, .05));--bf-surface-hover: var(--ds-surface-high, rgba(255, 255, 255, .1));--bf-border: var(--ds-border-default, rgba(255, 255, 255, .05));--bf-text-high: var(--ds-content-high, rgba(255, 255, 255, .85));--bf-text-medium: var(--ds-content-medium, rgba(255, 255, 255, .7));--bf-text-low: var(--ds-content-low, rgba(255, 255, 255, .5))}[data-theme=light].wi-popover-content .bf-root,[data-theme=light].wi-drawer-content .bf-root{--bf-bg: var(--ds-bg-default, #ffffff);--bf-surface: var(--ds-surface-medium, rgba(18, 18, 18, .05));--bf-surface-hover: var(--ds-surface-high, rgba(18, 18, 18, .1));--bf-border: var(--ds-border-default, rgba(18, 18, 18, .05));--bf-text-high: var(--ds-content-high, rgba(18, 18, 18, .85));--bf-text-medium: var(--ds-content-medium, rgba(18, 18, 18, .7));--bf-text-low: var(--ds-content-low, rgba(18, 18, 18, .5))}.bf-root[data-view=history]{background:var(--ds-bg-dim, #f5f7fa);color:var(--ds-content-high, rgba(0, 0, 0, .85))}.bf-header{position:relative;display:flex;flex-shrink:0;align-items:center;justify-content:space-between;padding:24px;border-bottom:1px solid var(--bf-border);background:var(--ds-bg-default, var(--bf-bg));box-sizing:border-box}.bf-root[data-view=history] .bf-header{padding:24px;border-bottom-color:var(--ds-border-default, rgba(0, 0, 0, .07));background:var(--ds-surface-default, #ffffff)}.bf-header-btn{display:inline-flex;width:24px;height:24px;flex-shrink:0;align-items:center;justify-content:center;padding:0;border:0;background:transparent;color:var(--ds-content-low, rgba(0, 0, 0, .4));cursor:pointer;transition:color .15s ease}.bf-header-btn:hover{color:var(--ds-content-high, rgba(0, 0, 0, .85))}.bf-header .bf-header-btn:last-child{position:absolute;top:24px;right:24px}.bf-header-title{position:absolute;left:50%;transform:translate(-50%);font-size:18px;font-weight:600;line-height:1.5;letter-spacing:-.01em;color:var(--bf-text-high);white-space:nowrap}.bf-root[data-view=history] .bf-header-title{color:var(--ds-content-highest, #000000)}.bf-body,.bf-history-body{flex:1;min-height:0;overflow-y:auto;overflow-x:hidden;scrollbar-width:thin;box-sizing:border-box}.bf-body{padding:24px}.bf-history-body{display:flex;flex-direction:column;gap:12px;padding:24px;background:var(--ds-bg-dim, #f5f7fa)}.bf-toolbar{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:12px}.bf-chip{display:inline-flex;align-items:center;gap:4px;min-height:33px;padding:6px 8px;border:0;border-radius:12px;background:var(--bf-surface);color:var(--bf-text-medium);font:inherit;font-size:14px;font-weight:600;line-height:1.5;letter-spacing:-.01em;cursor:pointer}.bf-chip:hover:not(:disabled){color:var(--bf-text-high);background:var(--bf-surface-hover)}.bf-chip:disabled{cursor:default}.bf-chip-history{position:relative}.bf-chip-dot{position:absolute;top:4px;right:4px;width:6px;height:6px;border-radius:999px;background:var(--ds-system-red-default, #da0b2e)}.bf-swap-card{position:relative;display:flex;flex-direction:column;gap:12px;margin-bottom:12px}.bf-field-error{margin-top:-4px;color:var(--ds-system-red-default, #ff2b5f);font-size:13px;font-weight:500;line-height:1.5;letter-spacing:0}.bf-amount-panel{display:flex;min-height:110px;flex-direction:column;gap:8px;padding:16px;border:1px solid transparent;border-radius:12px;background:var(--bf-surface);box-sizing:border-box;transition:border-color .2s ease}.bf-amount-panel:hover{border-color:var(--bf-border)}.bf-amount-head{display:flex;align-items:center;justify-content:space-between;gap:8px;color:var(--bf-text-high);font-size:14px;font-weight:500;line-height:1.5;letter-spacing:-.01em}.bf-balance{display:inline-flex;align-items:center;justify-content:flex-end;gap:4px;min-width:0;color:var(--bf-text-low);font-size:12px;white-space:nowrap}.bf-amount-main{display:flex;align-items:center;justify-content:space-between;gap:12px}.bf-amount-input-wrap{display:flex;min-width:0;flex:1;flex-direction:column;gap:4px}.bf-amount-input{width:100%;min-width:0;padding:0;border:0;background:transparent;color:var(--bf-text-high);font:inherit;font-size:18px;font-weight:600;line-height:1.5;letter-spacing:-.01em;outline:none}.bf-amount-input::placeholder{color:var(--ds-content-lowest, rgba(0, 0, 0, .25))}.bf-amount-usd{overflow:hidden;color:var(--bf-text-low);font-size:12px;font-weight:500;line-height:1.5;letter-spacing:-.01em;white-space:nowrap;text-overflow:ellipsis}.bf-token-pill{display:inline-flex;flex-shrink:0;align-items:center;gap:6px;min-height:33px;padding:6px 8px 6px 6px;border:1px solid var(--bf-border);border-radius:9999px;background:var(--bf-bg);color:var(--bf-text-high);font:inherit;font-size:14px;font-weight:600;line-height:1.5;letter-spacing:-.01em;cursor:pointer}.bf-token-pill:hover:not(:disabled):not([data-locked=true]){background:var(--bf-surface-hover)}.bf-token-pill:disabled{cursor:default;opacity:.6}.bf-token-pill[data-locked=true]{cursor:default}.bf-token-icon{position:relative;display:inline-flex;flex-shrink:0;align-items:center;justify-content:center;overflow:hidden;border-radius:0;background:var(--ds-accent-primary-default, #00ceb2);color:var(--ds-accent-primary-on, #000000);font-size:11px;font-weight:700}.bf-token-icon[data-has-image=true]{background:transparent}.bf-token-icon img{width:100%;height:100%;border-radius:0;object-fit:cover}.bf-token-fallback{line-height:1}.bf-token-picker-overlay{--bf-bg: #1e232e;--bf-surface: rgba(255, 255, 255, .05);--bf-surface-hover: rgba(255, 255, 255, .08);--bf-border: rgba(255, 255, 255, .07);--bf-text-high: rgba(255, 255, 255, .85);--bf-text-medium: rgba(255, 255, 255, .65);--bf-text-low: rgba(255, 255, 255, .4);position:fixed;inset:0;z-index:100002;display:flex;align-items:center;justify-content:center;padding:24px;background:#00000085;pointer-events:auto;box-sizing:border-box}.bf-token-picker-overlay[data-theme=light]{--bf-bg: #ffffff;--bf-surface: rgba(18, 18, 18, .05);--bf-surface-hover: rgba(18, 18, 18, .08);--bf-border: rgba(18, 18, 18, .07);--bf-text-high: rgba(18, 18, 18, .85);--bf-text-medium: rgba(18, 18, 18, .65);--bf-text-low: rgba(18, 18, 18, .4)}.bf-token-picker{display:flex;width:min(480px,calc(100vw - 48px));height:min(466px,calc(100dvh - 48px));max-height:calc(100dvh - 48px);min-height:0;flex-direction:column;overflow:hidden;border:1px solid var(--bf-border);border-radius:24px;background:var(--bf-bg);color:var(--bf-text-high);box-shadow:0 24px 80px #0006;box-sizing:border-box}.bf-token-picker-handle{display:none}.bf-token-picker-head{position:relative;display:flex;min-height:73px;flex-shrink:0;align-items:center;justify-content:flex-start;padding:24px 56px 24px 24px;border-bottom:1px solid var(--bf-border);box-sizing:border-box}.bf-token-picker-head h3{margin:0;color:var(--bf-text-high);font-size:20px;font-weight:600;line-height:1.25;letter-spacing:0}.bf-token-picker-close{position:absolute;top:24px;right:24px;display:inline-flex;width:24px;height:24px;align-items:center;justify-content:center;padding:0;border:0;background:transparent;color:var(--bf-text-medium);cursor:pointer}.bf-token-picker-close:hover{color:var(--bf-text-high)}.bf-token-search{display:flex;min-height:48px;flex-shrink:0;align-items:center;gap:8px;margin:16px 24px;padding:12px 16px;border:1px solid transparent;border-radius:12px;background:var(--ds-surface-medium, rgba(18, 18, 18, .05));color:var(--bf-text-low);box-sizing:border-box}.bf-token-search:focus-within{border-color:var(--ds-accent-primary-default, #00ceb2)}.bf-token-search input{width:100%;min-width:0;padding:0;border:0;outline:0;background:transparent;color:var(--bf-text-high);font:inherit;font-size:16px;font-weight:500;line-height:1.5;letter-spacing:0}.bf-token-search input::placeholder{color:var(--bf-text-low)}.bf-token-list{display:flex;min-height:0;flex:1;flex-direction:column;gap:0;overflow-y:auto;overflow-x:hidden;padding:0 24px 24px;scrollbar-width:thin;box-sizing:border-box}.bf-token-row{position:relative;display:flex;width:100%;min-height:69px;align-items:center;justify-content:space-between;gap:12px;padding:12px;border:1px solid transparent;border-radius:12px;background:transparent;color:inherit;font:inherit;text-align:left;cursor:pointer;box-sizing:border-box}.bf-token-row:hover:not([data-selected=true]){background:var(--ds-surface-medium, rgba(18, 18, 18, .05))}.bf-token-row[data-selected=true]{border-color:var(--ds-accent-primary-default, #00b4b7);background:var(--ds-surface-medium, rgba(18, 18, 18, .05))}.bf-token-row-left{display:inline-flex;min-width:0;align-items:center;gap:16px}.bf-token-meta{display:flex;min-width:0;flex-direction:column}.bf-token-symbol{overflow:hidden;color:var(--bf-text-high);font-size:16px;font-weight:600;line-height:1.5;letter-spacing:0;text-overflow:ellipsis;white-space:nowrap}.bf-token-name{overflow:hidden;color:var(--bf-text-low);font-size:12px;font-weight:500;line-height:1.5;letter-spacing:0;text-overflow:ellipsis;white-space:nowrap}.bf-token-row-right{display:flex;min-width:86px;max-width:42%;flex-shrink:0;flex-direction:column;align-items:flex-end}.bf-token-balance,.bf-token-price{max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.bf-token-balance{color:var(--bf-text-high);font-size:14px;font-weight:600;line-height:1.5;letter-spacing:0}.bf-token-price{color:var(--bf-text-low);font-size:12px;font-weight:500;line-height:1.5;letter-spacing:0}.bf-token-row[data-selected=true] .bf-token-symbol{color:var(--bf-text-high)}.bf-token-row[data-selected=true] .bf-token-balance{color:var(--bf-text-high);font-size:16px}.bf-token-row[data-selected=true] .bf-token-price{color:var(--bf-text-low);font-size:14px}.bf-token-empty{padding:32px 16px;color:var(--bf-text-low);font-size:14px;font-weight:500;line-height:1.5;text-align:center}.bf-slippage-overlay{position:fixed;inset:0;z-index:100002;display:flex;align-items:center;justify-content:center;padding:24px;background:#00000085;pointer-events:auto;box-sizing:border-box}.bf-slippage-dialog{display:flex;width:min(480px,calc(100vw - 48px));height:auto;min-height:min(316px,calc(100dvh - 48px));max-height:calc(100dvh - 48px);flex-direction:column;overflow:hidden;border:1px solid var(--ds-border-medium, rgba(0, 0, 0, .18));border-radius:24px;background:var(--ds-surface-default, #ffffff);color:var(--ds-content-highest, #000000);box-shadow:var(--ds-shadow-modal, 0 4px 30px -1px rgba(0, 0, 0, .15));box-sizing:border-box}.bf-slippage-head{position:relative;display:flex;min-height:73px;flex-shrink:0;align-items:center;justify-content:flex-start;padding:24px 56px 24px 24px;border-bottom:1px solid var(--ds-border-default, rgba(0, 0, 0, .07));background:var(--ds-surface-default, #ffffff);box-sizing:border-box}.bf-slippage-head h3{margin:0;color:var(--ds-content-highest, #000000);font-size:20px;font-weight:600;line-height:1.25;letter-spacing:0}.bf-slippage-close{position:absolute;top:24px;right:24px;display:inline-flex;width:24px;height:24px;align-items:center;justify-content:center;padding:0;border:0;background:transparent;color:var(--ds-content-low, rgba(0, 0, 0, .4));cursor:pointer}.bf-slippage-close:hover{color:var(--ds-content-high, rgba(0, 0, 0, .85))}.bf-slippage-body{display:flex;flex:1;min-height:0;flex-direction:column;gap:24px;padding:24px;box-sizing:border-box}.bf-slippage-desc{margin:0;color:var(--ds-content-medium, rgba(0, 0, 0, .65));font-size:14px;font-weight:500;line-height:1.5;letter-spacing:-.01em}.bf-slippage-controls{display:flex;flex-direction:column;gap:12px;width:100%}.bf-slippage-presets{display:flex;gap:8px;width:100%}.bf-slippage-preset{appearance:none;display:inline-flex;flex:1 1 0;min-width:0;min-height:48px;align-items:center;justify-content:center;padding:12px 8px;border:1px solid transparent;border-radius:12px;background:var(--ds-surface-medium, #f5f7fa);color:var(--ds-content-medium, rgba(0, 0, 0, .65));font:inherit;font-size:16px;font-weight:600;line-height:1.5;letter-spacing:-.01em;cursor:pointer;box-sizing:border-box}.bf-slippage-preset:hover,.bf-slippage-preset[data-selected=true]{border-color:var(--ds-accent-primary-default, #00b4b7);background:var(--ds-accent-primary-low, #e7f9f8)}.bf-slippage-custom{display:flex;min-height:48px;align-items:center;gap:8px;padding:12px;border:1px solid transparent;border-radius:12px;background:var(--ds-surface-medium, #f5f7fa);color:var(--ds-content-high, rgba(0, 0, 0, .85));box-sizing:border-box}.bf-slippage-custom:focus-within,.bf-slippage-custom[data-selected=true]{border-color:var(--ds-accent-primary-default, #00b4b7)}.bf-slippage-custom input{width:100%;min-width:0;padding:0;border:0;outline:0;background:transparent;color:var(--ds-content-high, rgba(0, 0, 0, .85));font:inherit;font-size:16px;font-weight:500;line-height:1.5;letter-spacing:-.01em}.bf-slippage-custom input::placeholder{color:var(--ds-content-lowest, rgba(0, 0, 0, .25))}.bf-slippage-custom span:not(.bf-sr-only){flex-shrink:0;color:var(--ds-content-high, rgba(0, 0, 0, .85));font-size:16px;font-weight:500;line-height:1.5;letter-spacing:-.01em}.bf-slippage-apply{appearance:none;margin-top:auto;width:100%;min-height:48px;padding:12px;border:0;border-radius:12px;background:var(--ds-accent-primary-default, #00b4b7);color:var(--ds-accent-primary-on-primary, #ffffff);font:inherit;font-size:16px;font-weight:600;line-height:1.5;letter-spacing:-.01em;cursor:pointer;box-sizing:border-box}.bf-slippage-apply:hover{filter:brightness(.96)}.bf-slippage-apply:disabled{cursor:not-allowed;opacity:.5;filter:none}.bf-slippage-message{margin:0;font-size:14px;font-weight:500;line-height:1.5;letter-spacing:-.01em}.bf-slippage-message[data-variant=warning]{color:var(--ds-system-orange-high, #e56f00)}.bf-slippage-message[data-variant=error]{color:var(--ds-system-red-default, #da0b2e)}.bf-action-modal-overlay{--bf-bg: var(--ds-bg-default, #1e232e);--bf-surface: var(--ds-surface-medium, rgba(255, 255, 255, .05));--bf-surface-hover: var(--ds-surface-high, rgba(255, 255, 255, .08));--bf-border: var(--ds-border-default, rgba(255, 255, 255, .12));--bf-text-high: var(--ds-content-high, rgba(255, 255, 255, .92));--bf-text-medium: var(--ds-content-medium, rgba(255, 255, 255, .65));--bf-text-low: var(--ds-content-low, rgba(255, 255, 255, .4));position:fixed;inset:0;z-index:100003;display:flex;align-items:center;justify-content:center;padding:24px;background:#040912b8;pointer-events:auto;box-sizing:border-box}.bf-action-modal-overlay[data-theme=light]{--bf-bg: var(--ds-bg-default, #ffffff);--bf-surface: var(--ds-surface-medium, rgba(18, 18, 18, .05));--bf-surface-hover: var(--ds-surface-high, rgba(18, 18, 18, .1));--bf-border: var(--ds-border-default, rgba(18, 18, 18, .08));--bf-text-high: var(--ds-content-high, rgba(18, 18, 18, .85));--bf-text-medium: var(--ds-content-medium, rgba(18, 18, 18, .65));--bf-text-low: var(--ds-content-low, rgba(18, 18, 18, .4))}.bf-action-modal{display:flex;width:min(480px,calc(100vw - 48px));flex-direction:column;align-items:center;gap:24px;padding:48px 24px 24px;border:1px solid var(--bf-border);border-radius:24px;background:var(--bf-bg);color:#fff;box-shadow:0 24px 80px #00000073;box-sizing:border-box}.bf-action-modal h3{width:100%;margin:0;color:var(--bf-text-high);font-size:24px;font-weight:700;line-height:1.25;text-align:center;letter-spacing:0}.bf-action-modal-desc{max-width:380px;margin:0;color:var(--bf-text-low);font-size:15px;font-weight:500;line-height:1.45;text-align:center;letter-spacing:0}.bf-terms-check-row{display:grid;width:100%;min-height:56px;grid-template-columns:20px minmax(0,1fr);align-items:center;column-gap:12px;padding:14px 16px;border:none;border-radius:12px;background:var(--bf-surface);color:var(--bf-text-medium);font-size:16px;font-weight:700;line-height:1.4;box-sizing:border-box}.bf-terms-check-button{appearance:none;display:inline-flex;min-width:0;width:20px;height:20px;align-items:center;justify-content:center;padding:0;border:0;background:transparent;color:inherit;font:inherit;text-align:left;cursor:pointer;touch-action:manipulation}.bf-terms-copy{display:flex;width:100%;min-width:0;align-items:baseline;justify-content:space-between;column-gap:12px;row-gap:4px;flex-wrap:wrap}.bf-terms-label{min-width:0}.bf-terms-check-button:focus-visible .bf-terms-checkbox{outline:2px solid var(--ds-accent-primary-default, #00ceb2);outline-offset:2px}.bf-terms-checkbox{position:relative;display:inline-flex;width:20px;height:20px;align-items:center;justify-content:center;border:1px solid rgba(124,143,180,.72);border-radius:5px;background:transparent;box-sizing:border-box}.bf-terms-checkbox[data-checked=true]{border-color:var(--ds-accent-primary-default, #00ceb2);background:var(--ds-accent-primary-default, #00ceb2)}.bf-terms-checkbox[data-checked=true]:after{width:8px;height:4px;border:solid var(--ds-accent-primary-on, #000000);border-width:0 0 2px 2px;content:"";transform:rotate(-45deg) translate(1px,-1px)}.bf-terms-check-row a{position:relative;z-index:1;color:var(--ds-accent-primary-default, #00ceb2);font-size:14px;font-weight:700;text-decoration:none;white-space:nowrap}.bf-terms-privacy{max-width:380px;margin:0;color:var(--bf-text-low);font-size:15px;font-weight:500;line-height:1.45;text-align:center;letter-spacing:0}.bf-action-primary,.bf-action-secondary{display:inline-flex;width:100%;min-height:56px;align-items:center;justify-content:center;padding:14px 16px;border:0;border-radius:12px;font:inherit;font-size:18px;font-weight:700;line-height:1.4;letter-spacing:0;cursor:pointer}.bf-action-primary{background:var(--ds-accent-primary-default, #00ceb2);color:var(--ds-accent-primary-on, #000000)}.bf-action-primary:disabled{cursor:not-allowed;opacity:.35}.bf-action-primary[aria-busy=true]{gap:8px;opacity:1}.bf-action-button-spinner{width:18px;height:18px;border:2px solid rgba(0,0,0,.22);border-top-color:currentColor;border-right-color:currentColor;border-radius:999px;animation:bf-loading-spin .9s linear infinite}.bf-action-secondary{background:var(--bf-surface);color:var(--bf-text-low)}.bf-action-secondary:disabled{cursor:not-allowed;opacity:.5}.bf-approve-address-box{display:flex;width:100%;flex-direction:column;gap:10px;padding:16px;border:1px solid var(--bf-border);border-radius:12px;background:var(--bf-surface);box-sizing:border-box}.bf-approve-address-box>span{color:var(--bf-text-low);font-size:14px;font-weight:700;line-height:1.4}.bf-approve-address-box>div{display:flex;min-width:0;align-items:center;justify-content:space-between;gap:12px}.bf-approve-address-box strong{min-width:0;overflow:hidden;color:var(--bf-text-high);font-size:15px;font-weight:500;line-height:1.5;text-overflow:ellipsis;white-space:nowrap}.bf-copy-button{flex-shrink:0;min-width:48px;min-height:32px;padding:6px 10px;border:1px solid rgba(0,206,178,.65);border-radius:8px;background:transparent;color:var(--ds-accent-primary-default, #00ceb2);font:inherit;font-size:12px;font-weight:700;line-height:1.2;cursor:pointer}.bf-copy-button:disabled{cursor:not-allowed;opacity:.45}.bf-action-buttons{display:grid;width:100%;grid-template-columns:1fr 1fr;gap:12px}.bf-approval-success-modal{gap:28px}.bf-success-mark{position:relative;display:inline-flex;width:96px;height:96px;flex-shrink:0;align-items:center;justify-content:center;border:12px solid rgba(0,206,178,.12);border-radius:999px;background:#00ceb2a8;box-shadow:0 0 0 10px #00ceb20f;box-sizing:border-box}.bf-success-mark:after{width:34px;height:18px;border:solid #ffffff;border-width:0 0 6px 6px;content:"";transform:rotate(-45deg) translate(2px,-3px)}.bf-status-toast{position:absolute;right:16px;bottom:14px;left:16px;z-index:5;display:flex;align-items:center;gap:12px;min-height:52px;padding:12px;border-radius:12px;background:var(--bf-toast-bg, #1e232e);color:var(--bf-toast-color, rgba(255, 255, 255, .85));box-shadow:0 8px 24px #0000003d;box-sizing:border-box}.bf-status-toast-icon{display:inline-flex;width:28px;height:28px;flex-shrink:0;align-items:center;justify-content:center;border-radius:999px}.bf-status-spinner{width:20px;height:20px;border:3px solid rgba(255,255,255,.18);border-top-color:var(--ds-accent-primary-default, #00ceb2);border-right-color:var(--ds-accent-primary-default, #00ceb2);border-radius:999px;animation:bf-loading-spin .9s linear infinite}.bf-status-check{position:relative;width:20px;height:20px;border-radius:999px;background:var(--ds-accent-primary-default, #00ceb2)}.bf-status-check:after{position:absolute;top:6px;left:5px;width:8px;height:4px;border:solid var(--ds-accent-primary-on, #000000);border-width:0 0 2px 2px;content:"";transform:rotate(-45deg)}.bf-status-toast-copy{display:flex;min-width:0;flex:1;flex-direction:column}.bf-status-toast-copy strong,.bf-status-toast-copy span{overflow:hidden;text-overflow:ellipsis}.bf-status-toast-copy strong{color:#fff;font-size:14px;font-weight:600;line-height:1.5;letter-spacing:-.01em}.bf-status-toast-copy span{color:var(--bf-toast-color, rgba(255, 255, 255, .85));font-size:12px;font-weight:400;line-height:1.5;letter-spacing:-.01em}.bf-status-toast[data-variant=success] .bf-status-toast-copy span{color:var(--ds-accent-primary-on-inverted, #00e8c9)}.bf-status-toast[data-variant=error]{border:1px solid rgba(255,43,95,.28);background:var(--bf-toast-bg, #1e232e)}.bf-status-toast[data-variant=error] .bf-status-toast-copy strong{color:#fff}.bf-status-error-mark{display:inline-flex;width:24px;height:24px;align-items:center;justify-content:center;border-radius:999px;background:var(--ds-system-red-default, #ff2b5f);color:#fff;font-size:14px;font-weight:700;line-height:1}.bf-status-toast[data-variant=error] .bf-status-toast-copy span{color:#ffffffe0}.bf-success-overlay{--bf-bg: var(--ds-bg-default, #1e232e);--bf-border: var(--ds-border-default, rgba(255, 255, 255, .12));--bf-text-high: var(--ds-content-high, rgba(255, 255, 255, .92));--bf-text-medium: var(--ds-content-medium, rgba(255, 255, 255, .65));position:fixed;inset:0;z-index:100003;display:flex;align-items:center;justify-content:center;padding:24px;background:#000000b8;pointer-events:auto;box-sizing:border-box}.bf-success-overlay[data-theme=light]{--bf-bg: #ffffff;--bf-border: rgba(18, 18, 18, .08);--bf-text-high: rgba(18, 18, 18, .85);--bf-text-medium: rgba(18, 18, 18, .65);--bf-text-low: rgba(18, 18, 18, .4)}.bf-success-modal{display:flex;width:min(480px,calc(100vw - 48px));flex-direction:column;overflow:hidden;border:1px solid var(--bf-border);border-radius:24px;background:var(--bf-bg);color:var(--bf-text-high);box-shadow:0 24px 80px #00000073;box-sizing:border-box}.bf-success-head{display:flex;min-height:73px;align-items:center;justify-content:space-between;gap:16px;padding:24px;border-bottom:1px solid var(--ds-border-default, rgba(0, 0, 0, .07));box-sizing:border-box}.bf-success-head h3{min-width:0;margin:0;overflow:hidden;color:var(--ds-content-highest, #000000);font-size:20px;font-weight:600;line-height:1.25;text-overflow:ellipsis;white-space:nowrap}.bf-success-close{display:inline-flex;width:24px;height:24px;flex-shrink:0;align-items:center;justify-content:center;padding:0;border:0;background:transparent;color:var(--ds-content-low, rgba(0, 0, 0, .4));cursor:pointer}.bf-success-close:hover{color:var(--ds-content-high, rgba(0, 0, 0, .85))}.bf-success-body{display:flex;flex-direction:column;align-items:center;gap:24px;padding:40px 24px 24px;box-sizing:border-box}.bf-success-copy{display:flex;width:100%;flex-direction:column;align-items:center;gap:4px;color:var(--bf-text-medium);text-align:center}.bf-success-copy strong{color:var(--bf-text-high);font-size:24px;font-weight:700;line-height:1.25;letter-spacing:0}.bf-success-copy span{color:var(--bf-text-medium);font-size:15px;font-weight:500;line-height:1.5;letter-spacing:0}.bf-success-route{display:flex;align-items:center;justify-content:center;gap:12px}.bf-success-route .bf-token-icon{width:48px!important;height:48px!important;background:transparent;font-size:18px}.bf-success-route-arrow{color:var(--bf-text-low);font-size:24px;font-weight:500;line-height:1}.bf-success-ok{display:inline-flex;width:100%;min-height:48px;align-items:center;justify-content:center;padding:12px;border:0;border-radius:12px;background:#00b4b7e0;color:#fff;font:inherit;font-size:16px;font-weight:600;line-height:1.5;letter-spacing:-.01em;cursor:pointer}@media(max-width:767px){.bf-success-body{padding:40px 24px 24px}.bf-success-copy strong{font-size:22px}.bf-success-copy span{font-size:14px}.bf-success-mark{width:88px;height:88px}.bf-success-route .bf-token-icon{width:44px!important;height:44px!important}}@keyframes bf-loading-spin{to{transform:rotate(360deg)}}.bf-swap-toggle{position:absolute;top:100px;left:50%;z-index:1;display:inline-flex;width:32px;height:32px;align-items:center;justify-content:center;padding:0;border:0;border-radius:9999px;background:var(--ds-accent-primary-default, #00ceb2);color:var(--ds-accent-primary-on, #000000);box-shadow:0 1px 5px #0000001f;cursor:pointer}.bf-swap-card[data-has-from-error=true] .bf-swap-toggle{top:132px}.bf-details{display:flex;flex-direction:column;gap:24px}.bf-exchange-rate{display:flex;width:100%;align-items:center;justify-content:center;gap:4px;padding:0 0 24px;border:0;background:transparent;color:var(--bf-text-low);font:inherit;font-size:12px;font-weight:500;line-height:1.5;letter-spacing:-.01em;cursor:pointer}.bf-exchange-rate:hover{color:var(--bf-text-medium)}.bf-detail-section,.bf-history-card{display:flex;flex-direction:column;gap:12px;padding:0;border-radius:12px;background:transparent;box-sizing:border-box}.bf-liquidity{display:flex;flex-direction:column;gap:12px;padding:16px;border-radius:12px;background:var(--bf-surface);box-sizing:border-box}.bf-root[data-view=history] .bf-liquidity,.bf-root[data-view=history] .bf-detail-section,.bf-root[data-view=history] .bf-history-card{background:var(--ds-surface-default, #ffffff)}.bf-detail-section h3{margin:0;color:var(--bf-text-high);font-size:16px;font-weight:600;line-height:1.5;letter-spacing:-.01em}.bf-tx-fee-section{gap:12px}.bf-tx-fee-head{display:flex;align-items:center;justify-content:space-between;gap:12px}.bf-collapse-head{display:flex;align-items:center;justify-content:space-between;gap:12px;width:100%;margin:0;padding:0;background:none;border:none;color:inherit;font:inherit;text-align:left;cursor:pointer}.bf-detail-section[data-open=true] .bf-collapse-head{padding-bottom:12px;border-bottom:1px solid var(--bf-border)}.bf-collapse-chevron{flex-shrink:0;color:var(--bf-text-low);transition:transform .2s ease}.bf-detail-section[data-open=true] .bf-collapse-chevron{transform:rotate(180deg)}.bf-collapse-body{display:flex;flex-direction:column;gap:14px}.bf-root[data-view=history] .bf-detail-section[data-open=true] .bf-collapse-head{border-bottom-color:var(--ds-border-default, rgba(0, 0, 0, .07))}.bf-root[data-view=history] .bf-collapse-chevron{color:var(--ds-content-low, rgba(0, 0, 0, .4))}.bf-tx-fee-total{display:inline-flex;align-items:center;justify-content:flex-end;gap:8px;min-width:0;color:var(--bf-text-medium);font-size:14px;font-weight:600;line-height:1.4;text-align:right}.bf-tx-fee-total>span[data-delegated=true]{text-decoration:line-through;text-decoration-thickness:2px;text-decoration-color:currentColor}.bf-fee-delegated{display:inline-flex;align-items:center;justify-content:center;min-height:24px;padding:2px 8px;border-radius:6px;background:#379cff2e;color:#4eb3ff;font-size:10px;font-weight:500;line-height:1.3;white-space:nowrap}.bf-tx-fee-token{width:16px;height:16px;flex-shrink:0;border-radius:999px;object-fit:cover}.bf-info-card{gap:14px}.bf-info-section{display:flex;flex-direction:column;gap:10px}.bf-info-section+.bf-info-section{padding-top:2px}.bf-info-section h4{margin:0;color:var(--bf-text-high);font-size:14px;font-weight:600;line-height:1.5}.bf-root[data-view=history] .bf-detail-section h3,.bf-root[data-view=history] .bf-info-section h4{color:var(--ds-content-high, rgba(0, 0, 0, .85))}.bf-info-rows{display:flex;flex-direction:column;gap:8px}.bf-info-row{display:flex;align-items:center;justify-content:space-between;gap:12px;min-width:0;font-size:12px;font-weight:500;line-height:1.5;letter-spacing:-.01em}.bf-liquidity-head{display:flex;align-items:center;justify-content:space-between;gap:12px;min-width:0;font-size:14px;font-weight:500;line-height:1.5;letter-spacing:-.01em}.bf-info-label{display:inline-flex;align-items:center;gap:6px;min-width:0;color:var(--bf-text-low)}.bf-tree-marker{width:10px;flex-shrink:0;color:var(--bf-text-low)}.bf-info-value{min-width:0;color:var(--bf-text-medium);text-align:right}.bf-info-route,.bf-info-value-token{display:inline-flex;align-items:center;gap:4px}.bf-info-route .bf-token-icon,.bf-info-value-token .bf-token-icon{flex-shrink:0}.bf-info-route-arrow{color:var(--bf-text-medium)}.bf-root[data-view=history] .bf-info-route-arrow{color:var(--ds-content-medium, rgba(0, 0, 0, .65))}.bf-info-value[data-tone=accent]{color:var(--ds-accent-primary-high, #00a0a2)}.bf-info-value[data-tone=warning]{color:var(--ds-system-orange-high, #e56f00)}.bf-root[data-view=history] .bf-info-label,.bf-root[data-view=history] .bf-liquidity-head,.bf-root[data-view=history] .bf-tree-marker{color:var(--ds-content-low, rgba(0, 0, 0, .4))}.bf-root[data-view=history] .bf-info-value{color:var(--ds-content-medium, rgba(0, 0, 0, .65))}.bf-root[data-view=history] .bf-info-value[data-tone=accent]{color:var(--ds-accent-primary-high, #00a0a2)}.bf-root[data-view=history] .bf-info-value[data-tone=warning]{color:var(--ds-system-orange-high, #e56f00)}.bf-liquidity-status{display:inline-flex;align-items:center;gap:6px;padding:4px 12px;border-radius:999px;font-size:13px;font-weight:600;line-height:1.4;white-space:nowrap}.bf-liquidity-status:before{content:"";display:inline-block;width:7px;height:7px;border-radius:50%;flex-shrink:0}.bf-liquidity-status[data-status=normal],.bf-liquidity-status:not([data-status]){background:#00ceb21f;color:var(--ds-accent-primary-default, #00ceb2)}.bf-liquidity-status[data-status=normal]:before,.bf-liquidity-status:not([data-status]):before{background:var(--ds-accent-primary-default, #00ceb2)}.bf-liquidity-status[data-status=low]{background:#e56f001f;color:#e56f00}.bf-liquidity-status[data-status=low]:before{background:#e56f00}.bf-liquidity-status[data-status=rebalancing]{background:#da0b2e1a;color:#da0b2e}.bf-liquidity-status[data-status=rebalancing]:before{background:#da0b2e}.bf-liquidity-track{height:8px;overflow:hidden;border-radius:999px;background:var(--bf-surface-hover)}.bf-liquidity-track span{display:block;height:100%;border-radius:inherit;background:var(--ds-accent-primary-default, #00ceb2)}.bf-error{padding:12px;border-radius:12px;background:#da0b2e1f;color:var(--ds-system-red-default, #da0b2e);font-size:13px;line-height:1.4}.bf-footer{display:flex;flex-shrink:0;flex-direction:column;align-items:center;gap:10px;padding:12px 24px 24px;background:var(--ds-bg-default, var(--bf-bg))}.bf-next{width:100%;min-height:48px;padding:12px;border:0;border-radius:12px;background:var(--ds-accent-primary-default, #00ceb2);color:var(--ds-accent-primary-on, #000000);font:inherit;font-size:16px;font-weight:600;line-height:1.5;letter-spacing:-.01em;cursor:pointer}.bf-next:disabled{cursor:default;opacity:.6}.bf-powered{display:inline-flex;align-items:center;gap:3px;color:var(--bf-text-low);font-size:12px;font-weight:500;line-height:1.5;letter-spacing:-.01em;text-decoration:none}.bf-powered:focus-visible{border-radius:4px;outline:2px solid var(--ds-accent-primary-default, #00ceb2);outline-offset:2px}.bf-powered-brand{text-decoration:underline;text-underline-offset:2px}.bf-history-tabs{display:flex;align-items:center;gap:4px;width:100%}.bf-history-tab{position:relative;display:inline-flex;min-height:37px;align-items:center;justify-content:center;padding:8px 12px;border:0;background:transparent;color:var(--ds-content-lowest, rgba(0, 0, 0, .25));font:inherit;font-size:16px;font-weight:600;line-height:1.5;letter-spacing:0;cursor:pointer}.bf-history-tab[data-active=true]{color:var(--ds-accent-primary-high, #00a0a2)}.bf-history-tab[data-active=true]:after{position:absolute;right:8px;bottom:0;left:8px;height:3px;border-radius:999px;background:var(--ds-accent-primary-high, #00a0a2);content:""}.bf-history-tab-dot{position:absolute;top:8px;right:4px;width:6px;height:6px;border-radius:999px;background:var(--ds-system-red-default, #da0b2e)}.bf-history-list{display:flex;flex-direction:column;gap:12px}.bf-history-item{display:flex;flex-direction:column;gap:8px;padding:12px;border-radius:12px;background:var(--ds-surface-default, #ffffff);box-sizing:border-box}.bf-history-item-head,.bf-history-meta,.bf-history-route,.bf-history-route-token{display:inline-flex;align-items:center}.bf-history-item-head{justify-content:space-between;gap:12px;width:100%}.bf-history-status{display:inline-flex;min-height:24px;align-items:center;justify-content:center;padding:3px 8px;border-radius:4px;background:var(--ds-system-orange-low, #fcf5e9);color:var(--ds-system-orange-high, #e56f00);font-size:12px;font-weight:500;line-height:1.5;letter-spacing:0;white-space:nowrap}.bf-history-status[data-status=completed]{background:var(--ds-system-green-low, #e7f9f8);color:var(--ds-system-green-high, #00a0a2)}.bf-history-status[data-status=failed]{background:var(--ds-system-red-low, rgba(218, 11, 46, .12));color:var(--ds-system-red-default, #da0b2e)}.bf-history-time{min-width:0;color:var(--ds-content-low, rgba(0, 0, 0, .4));font-size:12px;font-weight:500;line-height:1.5;letter-spacing:0;text-align:right;white-space:nowrap}.bf-history-item-body{display:flex;flex-direction:column;gap:4px}.bf-history-amount{color:var(--ds-content-high, rgba(0, 0, 0, .85));font-size:16px;font-weight:600;line-height:1.5;letter-spacing:0}.bf-history-meta{justify-content:space-between;gap:12px;min-width:0}.bf-history-usd{min-width:0;color:var(--ds-content-low, rgba(0, 0, 0, .4));font-size:12px;font-weight:500;line-height:1.5;letter-spacing:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.bf-history-route{justify-content:flex-end;gap:4px;min-width:0;color:var(--ds-content-high, rgba(0, 0, 0, .85));font-size:12px;font-weight:600;line-height:1.5;letter-spacing:0}.bf-history-route-token{gap:4px;min-width:0}.bf-history-route-token span:last-child{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.bf-history-route-arrow{flex-shrink:0;color:var(--ds-content-low, rgba(0, 0, 0, .4))}.bf-empty{padding:32px 16px;text-align:center;color:var(--ds-content-low, rgba(0, 0, 0, .4));font-size:14px}.bf-sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}@media(max-width:767px){.bf-token-picker-overlay{align-items:flex-end;padding:0}.bf-token-picker{width:100%;max-height:82dvh;min-height:min(520px,82dvh);border-right:0;border-bottom:0;border-left:0;border-radius:24px 24px 0 0}.bf-token-picker-handle{display:block;width:40px;height:4px;flex-shrink:0;align-self:center;margin:10px 0 0;border-radius:999px;background:#ffffff38}.bf-token-picker-head{min-height:55px;padding:12px 56px 16px 24px;border-bottom:0}.bf-token-picker-close{top:13px}.bf-token-search{margin:0 16px 12px}.bf-token-list{padding:0 16px 16px}.bf-slippage-overlay{align-items:flex-end;padding:0}.bf-slippage-dialog{width:100%;height:auto;min-height:316px;max-height:82dvh;border-right:0;border-bottom:0;border-left:0;border-radius:24px 24px 0 0}}.wi-drawer-content .bf-header{padding:16px}.wi-drawer-content .bf-header .bf-header-btn:last-child{top:16px;right:16px}.wi-drawer-content .bf-body,.wi-drawer-content .bf-history-body{padding:16px}
|
|
10
10
|
`);var l=require("react/jsx-runtime"),kl=I.createContext(void 0);function An(){return I.useContext(kl)}function fp(e){let[t,n]=I.useState(void 0);return I.useEffect(()=>{let o=e.current;if(!o)return;let r=()=>{let a=o.closest("[data-theme]");n(a?.getAttribute("data-theme")??void 0)};r();let i=new MutationObserver(r);return i.observe(document.documentElement,{attributes:!0,subtree:!0,attributeFilter:["data-theme"]}),()=>i.disconnect()},[e]),t}var bl=[{value:"0.1",label:"0.1%"},{value:"0.5",label:"0.5%"},{value:"1",label:"1%"},{value:"5",label:"5%"}],up={dev:"https://dev.crossdefi.io",stage:"https://stg.crossdefi.io",production:"https://crossdefi.io"},mp=[{value:"all",label:"ALL"},{value:"completed",label:"Completed"},{value:"pending",label:"Pending"}];function gp(e,t){return e==="auto"?t?`Auto ${t}%`:"Auto":e?`${e}%`:"1%"}function wl(e){let t=e.replace(/[^\d.]/g,""),[n="",...o]=t.split("."),r=o.join("");return o.length===0?n:`${n}.${r.slice(0,2)}`}function hp(e){return`${e.chainId}:${e.address.toLowerCase()}`}function Sl(e){let t=Number(e);return Number.isFinite(t)?t.toLocaleString("en-US",{maximumFractionDigits:t>=1?2:6}):e||"0"}function xl(e,t){let n=Number(e||"0"),o=t?.priceUsd??0;return`\u2248 $${(Number.isFinite(n)?n*o:0).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})} USD`}function bp(e,t=6){if(!e)return e;let[n,o=""]=e.split(".");if(!o)return n;let r=o.slice(0,t).replace(/0+$/,"");return r?`${n}.${r}`:n}function wp(e,t){if(!t)return!1;let n=new Et.default(e||"0"),o=new Et.default(t.balance||"0");return!n.isFinite()||!o.isFinite()?!1:n.isGreaterThan(o)}function xp(e){if(e.priceUsd===void 0)return null;let t=new Et.default(e.balance||"0");return t.isFinite()?`\u2248 $${t.multipliedBy(e.priceUsd).toFormat(2)} USD`:null}function vp(e){if(e.priceUsd===void 0)return null;let t=new Et.default(e.priceUsd);return t.isFinite()?`$${t.toFormat(t.isLessThan(1)?4:2)}`:null}function Rl(e){if(!e.isFinite()||e.isNaN())return"0";let n=e.decimalPlaces(6,Et.default.ROUND_DOWN).toFixed(6).replace(/\.?0+$/,""),[o="0",r]=n.split("."),i=new Et.default(o||"0").toFormat(0);return r?`${i}.${r}`:i}function yp(e){return e.length<=14?e:`${e.slice(0,6)}...${e.slice(-6)}`}function kp(e){let t=new Date(e);if(Number.isNaN(t.getTime()))return e;let n=o=>o.toString().padStart(2,"0");return[`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}`,`${n(t.getHours())}:${n(t.getMinutes())}:${n(t.getSeconds())}`].join(" ")}function Sp(e){let t=new Et.default(e||"0");return!t.isFinite()||t.isNaN()?e||"0":Rl(t)}function Rp(e,t){if(t?.priceUsd===void 0)return null;let n=new Et.default(e||"0").multipliedBy(t.priceUsd);return!n.isFinite()||n.isNaN()?null:`$${n.toFormat(2)}`}function Jo(e){return e.status==="success"?"completed":e.status==="failed"?"failed":"pending"}function Cp(e,t){return t==="all"?!0:Jo(e)===t}function Tp(e){return e==="completed"?"Completed":e==="failed"?"Failed":"Pending"}function vl(e){return e===56||e===97?"BSC":e===612044||e===5555?"CROSS":`Chain ${e}`}function Cl(e,t){return!!e&&!!t&&e.chainId===t.chainId&&e.address.toLowerCase()===t.address.toLowerCase()}function Tl(e,t){if(!(!e||!t))return e.chainId===t.chainId?"swap":Cl(e,t)||e.symbol.toLowerCase()===t.symbol.toLowerCase()?"bridge":"swap-bridge"}function Nl(e){return e==="swap"||e==="deposit-swap"||e==="swap-withdraw"}function Xo(e){return!e||e==="0"||Number(e)===0}function Np(e){let t=e.trim().toLowerCase();return t?t.startsWith("minimum ")?{from:e}:t.startsWith("available ")&&t.includes("or more")?{to:e}:t.includes("insufficient balance")||t.includes("not enough balance")||t.includes("exceeds balance")||t.includes("insufficient network fee")?{from:e}:t.includes("insufficient liquidity")||t.includes("not enough liquidity")?{to:e}:{}:{}}function Ip(e){let t=e.fromToken,n=e.toToken,o=Tl(t,n),r=e.fromAmount||"0",i=e.toAmount||"0",a=o!==void 0&&!Nl(o),s=o!==void 0&&o!=="bridge";return{pathType:o,bridgeInfo:a?[{label:"Route",value:t&&n?`${vl(t.chainId)} \u2192 ${vl(n.chainId)}`:"-"},{label:"Validator Fee",value:Xo(r)?"0":"Free",tone:Xo(r)?"default":"accent"},{label:"Network Fee",value:Xo(r)?"0":"Free",tone:Xo(r)?"default":"accent"}]:void 0,swapInfo:s?[t&&n?{label:"Route",value:"",routeTokens:[{symbol:t.symbol,iconUrl:t.iconUrl},{symbol:n.symbol,iconUrl:n.iconUrl}]}:{label:"Route",value:"-"},{label:"Price Impact",value:"0%"},{label:"In Amount",value:r,valueToken:t?{symbol:t.symbol,iconUrl:t.iconUrl}:void 0},{label:"Swap Fee",value:"0",valueToken:t?{symbol:t.symbol,iconUrl:t.iconUrl}:void 0},{label:"Out Amount",value:i,valueToken:n?{symbol:n.symbol,iconUrl:n.iconUrl}:void 0}]:void 0,txFee:[{label:"Priority Fee Per Gas",value:"0 Gwei"},{label:"Max Fee Per Gas",value:"0 Gwei"},{label:"Gas Limit",value:"0"}],txFeeInfo:{estTxFee:"0",isDelegateFee:!1}}}function Zn({token:e,size:t=20}){let n=e?.iconUrl;return(0,l.jsx)("span",{className:"bf-token-icon","data-has-image":!!n?"true":"false",style:{width:t,height:t},children:n?(0,l.jsx)("img",{src:n,alt:"",width:t,height:t,draggable:!1}):(0,l.jsx)("span",{className:"bf-token-fallback",children:e?.symbol?.slice(0,1)??"?"})})}function yl({label:e,token:t,amount:n,usd:o,onAmountChange:r,onTokenClick:i,locked:a=!1}){return(0,l.jsxs)("section",{className:"bf-amount-panel",children:[(0,l.jsxs)("div",{className:"bf-amount-head",children:[(0,l.jsx)("span",{children:e}),(0,l.jsxs)("span",{className:"bf-balance",children:[Sl(t?.balance??"0")," ",t?.symbol??""]})]}),(0,l.jsxs)("div",{className:"bf-amount-main",children:[(0,l.jsxs)("label",{className:"bf-amount-input-wrap",children:[(0,l.jsxs)("span",{className:"bf-sr-only",children:[e," amount"]}),(0,l.jsx)("input",{type:"text",inputMode:"decimal",value:n,onChange:s=>r(s.target.value),placeholder:"0",className:"bf-amount-input"}),(0,l.jsx)("span",{className:"bf-amount-usd",children:o})]}),(0,l.jsxs)("button",{type:"button",className:"bf-token-pill",onClick:a?void 0:i,disabled:!a&&!i,"data-locked":a?"true":void 0,"aria-label":`Select ${e.toLowerCase()} token`,children:[(0,l.jsx)(Zn,{token:t}),(0,l.jsx)("span",{children:t?.symbol??"Select"}),!a&&(0,l.jsx)(pn,{size:16})]})]})]})}function Ep({flow:e,side:t,onClose:n}){let o=I.useId(),[r,i]=I.useState(""),[a,s]=I.useState(null),c=An(),d=t==="from"?e.fromToken:e.toToken;I.useEffect(()=>{s(document.body)},[]),I.useEffect(()=>{let u=v=>{v.key==="Escape"&&n()};return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[n]);let f=I.useMemo(()=>t==="from"?e.tokens:e.availableToTokens,[e.availableToTokens,e.tokens,t]),h=I.useMemo(()=>{let u=r.trim().toLowerCase();return u?f.filter(v=>v.symbol.toLowerCase().includes(u)||v.name.toLowerCase().includes(u)):f},[r,f]),g=I.useCallback(u=>{t==="from"?e.selectFromToken(u):e.selectToToken(u),n()},[e,n,t]);return a?(0,bn.createPortal)((0,l.jsx)("div",{className:"bf-token-picker-overlay","data-theme":c,role:"presentation",onMouseDown:u=>{u.target===u.currentTarget&&n()},children:(0,l.jsxs)("section",{className:"bf-token-picker",role:"dialog","aria-modal":"true","aria-labelledby":o,children:[(0,l.jsx)("span",{className:"bf-token-picker-handle","aria-hidden":"true"}),(0,l.jsxs)("header",{className:"bf-token-picker-head",children:[(0,l.jsx)("h3",{id:o,children:"Select a token"}),(0,l.jsx)("button",{type:"button",className:"bf-token-picker-close",onClick:n,"aria-label":"Close token selector",children:(0,l.jsx)(Bt,{size:24})})]}),(0,l.jsxs)("label",{className:"bf-token-search",children:[(0,l.jsx)(nl,{size:20}),(0,l.jsx)("span",{className:"bf-sr-only",children:"Search tokens"}),(0,l.jsx)("input",{value:r,onChange:u=>i(u.target.value),placeholder:"Search Tokens",autoComplete:"off",spellCheck:!1})]}),(0,l.jsxs)("div",{className:"bf-token-list",children:[h.map(u=>{let v=Cl(u,d),b=v?vp(u):xp(u);return(0,l.jsxs)("button",{type:"button",className:"bf-token-row","data-selected":v?"true":"false",onClick:()=>g(u),children:[(0,l.jsxs)("span",{className:"bf-token-row-left",children:[(0,l.jsx)(Zn,{token:u,size:40}),(0,l.jsxs)("span",{className:"bf-token-meta",children:[(0,l.jsx)("span",{className:"bf-token-symbol",children:u.symbol}),!v&&(0,l.jsx)("span",{className:"bf-token-name",children:u.name})]})]}),(0,l.jsxs)("span",{className:"bf-token-row-right",children:[(0,l.jsxs)("span",{className:"bf-token-balance",children:[Sl(u.balance),v?null:` ${u.symbol}`]}),b&&(0,l.jsx)("span",{className:"bf-token-price",children:b})]})]},hp(u))}),h.length===0&&(0,l.jsx)("div",{className:"bf-token-empty",children:"No tokens found"})]})]})}),a):null}function Lp({flow:e,onClose:t}){let n=I.useId(),[o,r]=I.useState(null),i=bl.find(b=>b.value===e.slippage),[a,s]=I.useState(e.slippage&&!i?e.slippage:""),c=a.trim()!==""&&a.trim()!==".",d=c?Number(a):NaN,f=Number.isFinite(d)&&d>50,h=Number.isFinite(d)&&d>5&&!f,g=b=>{e.setSlippage(b),t()},u=()=>{!c||f||(e.setSlippage(wl(a)),t())};if(I.useEffect(()=>{r(document.body)},[]),I.useEffect(()=>{let b=w=>{w.key==="Escape"&&t()};return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[t]),!o)return null;let v=An();return(0,bn.createPortal)((0,l.jsx)("div",{className:"bf-slippage-overlay","data-theme":v,role:"presentation",onMouseDown:b=>{b.target===b.currentTarget&&t()},children:(0,l.jsxs)("section",{className:"bf-slippage-dialog",role:"dialog","aria-modal":"true","aria-labelledby":n,children:[(0,l.jsxs)("header",{className:"bf-slippage-head",children:[(0,l.jsx)("h3",{id:n,children:"Slippage Settings"}),(0,l.jsx)("button",{type:"button",className:"bf-slippage-close",onClick:t,"aria-label":"Close slippage settings",children:(0,l.jsx)(Bt,{size:24})})]}),(0,l.jsxs)("div",{className:"bf-slippage-body",children:[(0,l.jsx)("p",{className:"bf-slippage-desc",children:"The maximum price difference you are willing to accept before the transaction is reverted. Higher slippage increases the chance of execution but may result in a worse price."}),(0,l.jsxs)("div",{className:"bf-slippage-controls",children:[(0,l.jsx)("div",{className:"bf-slippage-presets",children:bl.map(b=>(0,l.jsx)("button",{type:"button",className:"bf-slippage-preset","data-selected":!c&&e.slippage===b.value?"true":"false",onClick:()=>g(b.value),children:b.label},b.value))}),(0,l.jsxs)("label",{className:"bf-slippage-custom","data-selected":c?"true":"false",children:[(0,l.jsx)("span",{className:"bf-sr-only",children:"Custom slippage percent"}),(0,l.jsx)("input",{value:a,onChange:b=>{s(wl(b.target.value))},onKeyDown:b=>{b.key==="Enter"&&(b.preventDefault(),u())},inputMode:"decimal",placeholder:"Enter custom slippage",autoComplete:"off",spellCheck:!1}),(0,l.jsx)("span",{"aria-hidden":"true",children:"%"})]})]}),f?(0,l.jsx)("p",{className:"bf-slippage-message","data-variant":"error",children:"Slippage cannot exceed 50%."}):h?(0,l.jsx)("p",{className:"bf-slippage-message","data-variant":"warning",children:"Your transaction may be frontrun due to high slippage."}):null,c&&(0,l.jsx)("button",{type:"button",className:"bf-slippage-apply",onClick:u,disabled:f,children:"Apply"})]})]})}),o)}function Ap({flow:e}){let t=I.useId(),[n,o]=I.useState(!1),[r,i]=I.useState(null),a=An();return I.useEffect(()=>{i(document.body)},[]),I.useEffect(()=>{let s=c=>{c.key==="Escape"&&e.cancelTerms()};return document.addEventListener("keydown",s),()=>document.removeEventListener("keydown",s)},[e]),!r||!e.termsOpen?null:(0,bn.createPortal)((0,l.jsx)("div",{className:"bf-action-modal-overlay","data-theme":a,role:"presentation",onPointerDown:s=>{s.target===s.currentTarget&&e.cancelTerms()},children:(0,l.jsxs)("section",{className:"bf-action-modal bf-terms-modal",role:"dialog","aria-modal":"true","aria-labelledby":t,children:[(0,l.jsx)("h3",{id:t,children:"Agree to Terms of Service"}),(0,l.jsx)("p",{className:"bf-action-modal-desc",children:"Please make sure to review the Terms of Service before using CROSSD."}),(0,l.jsxs)("div",{className:"bf-terms-check-row","data-checked":n?"true":"false",children:[(0,l.jsx)("button",{type:"button",className:"bf-terms-check-button",role:"checkbox","aria-checked":n,"aria-label":"Agree to Terms of Use",onClick:()=>o(s=>!s),children:(0,l.jsx)("span",{className:"bf-terms-checkbox","data-checked":n?"true":"false","aria-hidden":"true"})}),(0,l.jsxs)("div",{className:"bf-terms-copy",children:[(0,l.jsx)("span",{className:"bf-terms-label",children:"Agree to Terms of Use"}),e.termsUrl&&(0,l.jsx)("a",{href:e.termsUrl,target:"_blank",rel:"noreferrer",children:"Terms of Service"})]})]}),(0,l.jsx)("p",{className:"bf-terms-privacy",children:"I have read and acknowledged the Privacy Policy to use CROSSD"}),(0,l.jsx)("button",{type:"button",className:"bf-action-primary",disabled:!n||e.status==="submitting",onClick:e.confirmTerms,children:"Confirm"})]})}),r)}function Pp({value:e,disabled:t=!1}){let[n,o]=I.useState(!1);return(0,l.jsx)("button",{type:"button",className:"bf-copy-button","aria-label":"Copy token address",disabled:t,onClick:()=>{t||navigator.clipboard?.writeText(e).then(()=>{o(!0),window.setTimeout(()=>o(!1),1200)})},children:n?"OK":"Copy"})}function Fp({flow:e,approval:t}){let n=I.useId(),[o,r]=I.useState(null),i=An();if(I.useEffect(()=>{r(document.body)},[]),I.useEffect(()=>{let c=d=>{e.status!=="submitting"&&d.key==="Escape"&&e.cancelApproval()};return document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c)},[e]),!o)return null;let a=e.status==="submitting"||!e.approveBridge,s=e.status==="submitting";return(0,bn.createPortal)((0,l.jsx)("div",{className:"bf-action-modal-overlay","data-theme":i,role:"presentation",children:(0,l.jsxs)("section",{className:"bf-action-modal bf-approve-modal",role:"dialog","aria-modal":"true","aria-labelledby":n,children:[(0,l.jsxs)("h3",{id:n,children:["Approve ",t.token.symbol]}),(0,l.jsx)(Zn,{token:t.token,size:72}),(0,l.jsxs)("div",{className:"bf-approve-address-box",children:[(0,l.jsx)("span",{children:"Token Address"}),(0,l.jsxs)("div",{children:[(0,l.jsx)("strong",{children:t.tokenAddress}),(0,l.jsx)(Pp,{value:t.tokenAddress,disabled:s})]})]}),(0,l.jsxs)("div",{className:"bf-action-buttons",children:[(0,l.jsx)("button",{type:"button",className:"bf-action-secondary",onClick:e.cancelApproval,disabled:e.status==="submitting",children:"Cancel"}),(0,l.jsxs)("button",{type:"button",className:"bf-action-primary",onClick:e.confirmApproval,disabled:a,"aria-busy":s,children:[s&&(0,l.jsx)("span",{className:"bf-action-button-spinner","aria-hidden":"true"}),(0,l.jsx)("span",{children:s?"Approving...":"Approve"})]})]})]})}),o)}function Bp({flow:e}){let t=I.useId(),[n,o]=I.useState(null),r=An();if(I.useEffect(()=>{o(document.body)},[]),I.useEffect(()=>{if(!e.approvalSuccessOpen)return;let a=s=>{s.key==="Escape"&&e.cancelApproval()};return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a)},[e]),!n||!e.approvalSuccessOpen)return null;let i=e.status==="submitting";return(0,bn.createPortal)((0,l.jsx)("div",{className:"bf-action-modal-overlay","data-theme":r,role:"presentation",children:(0,l.jsxs)("section",{className:"bf-action-modal bf-approval-success-modal",role:"dialog","aria-modal":"true","aria-labelledby":t,children:[(0,l.jsx)("h3",{id:t,children:"Approval Success"}),(0,l.jsx)("span",{className:"bf-success-mark","aria-hidden":"true"}),(0,l.jsxs)("p",{className:"bf-action-modal-desc",children:["Token approval confirmed successfully.",(0,l.jsx)("br",{}),"Please continue to the next step."]}),(0,l.jsxs)("div",{className:"bf-action-buttons",children:[(0,l.jsx)("button",{type:"button",className:"bf-action-secondary",onClick:e.cancelApproval,disabled:i,children:"Cancel"}),(0,l.jsxs)("button",{type:"button",className:"bf-action-primary",onClick:e.continueAfterApproval,disabled:i,"aria-busy":i,children:[i&&(0,l.jsx)("span",{className:"bf-action-button-spinner","aria-hidden":"true"}),(0,l.jsx)("span",{children:i?"Continuing...":"Continue"})]})]})]})}),n)}function _p({fromAmount:e,toAmount:t,fromToken:n,toToken:o}){let[r,i]=I.useState(!1),a=I.useMemo(()=>{let d=new Et.default(e||"0"),f=new Et.default(t||"0");return!d.isFinite()||!f.isFinite()||d.lte(0)||f.lte(0)?null:r?d.dividedBy(f):f.dividedBy(d)},[e,r,t]);if(!a||!n||!o||n.symbol===o.symbol)return null;let s=r?o.symbol:n.symbol,c=r?n.symbol:o.symbol;return(0,l.jsxs)("button",{type:"button",className:"bf-exchange-rate",onClick:()=>i(d=>!d),children:[(0,l.jsxs)("span",{children:["1 ",s]}),(0,l.jsx)(sl,{size:12}),(0,l.jsxs)("span",{children:[Rl(a)," ",c]})]})}function Mp({flow:e}){return e.submitToast?(0,l.jsxs)("div",{className:"bf-status-toast","data-variant":"processing",role:"status","aria-live":"polite",children:[(0,l.jsx)("span",{className:"bf-status-toast-icon","aria-hidden":"true",children:(0,l.jsx)("span",{className:"bf-status-spinner"})}),(0,l.jsxs)("span",{className:"bf-status-toast-copy",children:[(0,l.jsx)("strong",{children:"Transaction Processing"}),(0,l.jsx)("span",{children:"Your transaction is being processed on the blockchain"})]})]}):null}function Op({message:e}){let[t,n]=I.useState(!1);return I.useEffect(()=>{if(!e){n(!1);return}n(!0);let o=window.setTimeout(()=>{n(!1)},3500);return()=>window.clearTimeout(o)},[e]),!e||!t?null:(0,l.jsxs)("div",{className:"bf-status-toast","data-variant":"error",role:"alert","aria-live":"assertive",children:[(0,l.jsx)("span",{className:"bf-status-toast-icon","aria-hidden":"true",children:(0,l.jsx)("span",{className:"bf-status-error-mark",children:"!"})}),(0,l.jsxs)("span",{className:"bf-status-toast-copy",children:[(0,l.jsx)("strong",{children:"Error"}),(0,l.jsx)("span",{children:e})]})]})}function Wp(e){switch(e){case"swap":case"deposit-swap":case"swap-withdraw":return"Swap Transaction Sent";case"bridge":return"Bridge Transaction Sent";case"swap-bridge":return"Swap & Bridge Transaction Sent";case"bridge-swap":return"Bridge & Swap Transaction Sent";default:return"Transaction Sent"}}function Dp({flow:e}){let t=I.useId(),[n,o]=I.useState(null),r=e.submitted,i=An();return I.useEffect(()=>{o(document.body)},[]),I.useEffect(()=>{if(!e.successDialogOpen)return;let a=s=>{s.key==="Escape"&&e.dismissSuccessDialog()};return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a)},[e]),!n||!e.successDialogOpen||!r?null:(0,bn.createPortal)((0,l.jsx)("div",{className:"bf-success-overlay","data-theme":i,role:"presentation",children:(0,l.jsx)("section",{className:"bf-success-modal",role:"dialog","aria-modal":"true","aria-labelledby":t,children:(0,l.jsxs)("div",{className:"bf-success-body",children:[(0,l.jsx)("span",{className:"bf-success-mark","aria-hidden":"true"}),(0,l.jsxs)("div",{className:"bf-success-copy",children:[(0,l.jsx)("strong",{id:t,children:Wp(r.pathType)}),(0,l.jsx)("span",{children:"Please check the results in the history."})]}),(0,l.jsx)("div",{className:"bf-success-route","aria-hidden":"true",children:(r.routeTokens&&r.routeTokens.length>0?r.routeTokens:[{symbol:r.fromToken.symbol,iconUrl:r.fromToken.iconUrl},{symbol:r.toToken.symbol,iconUrl:r.toToken.iconUrl}]).map((a,s)=>(0,l.jsxs)(I.Fragment,{children:[s>0&&(0,l.jsx)("span",{className:"bf-success-route-arrow",children:"\u2192"}),(0,l.jsx)(Zr,{token:a,size:43})]},`${a.symbol}-${s}`))}),(0,l.jsx)("button",{type:"button",className:"bf-success-ok",onClick:e.dismissSuccessDialog,children:"OK"})]})})}),n)}function Zr({token:e,size:t=16}){let n=!!e.iconUrl;return(0,l.jsx)("span",{className:"bf-token-icon","data-has-image":n?"true":"false",style:{width:t,height:t},children:e.iconUrl?(0,l.jsx)("img",{src:e.iconUrl,alt:"",width:t,height:t,draggable:!1}):(0,l.jsx)("span",{className:"bf-token-fallback",children:e.symbol?.slice(0,1)??"?"})})}function zp({row:e}){return e.routeTokens&&e.routeTokens.length>0?(0,l.jsx)("span",{className:"bf-info-route",children:e.routeTokens.map((t,n)=>(0,l.jsxs)(I.Fragment,{children:[n>0&&(0,l.jsx)("span",{className:"bf-info-route-arrow","aria-hidden":"true",children:"\u2192"}),(0,l.jsx)(Zr,{token:t})]},`${t.symbol}-${n}`))}):e.valueToken?(0,l.jsxs)("span",{className:"bf-info-value-token",children:[(0,l.jsx)(Zr,{token:e.valueToken}),(0,l.jsx)("span",{children:e.value})]}):(0,l.jsx)(l.Fragment,{children:e.value})}function Il({rows:e}){return!e||e.length===0?null:(0,l.jsx)("div",{className:"bf-info-rows",children:e.map((t,n)=>(0,l.jsxs)("div",{className:"bf-info-row",children:[(0,l.jsxs)("span",{className:"bf-info-label",children:[(0,l.jsx)("span",{className:"bf-tree-marker",children:n===e.length-1?"\u2514":"\u251C"}),(0,l.jsx)("span",{children:t.label})]}),(0,l.jsx)("span",{className:"bf-info-value","data-tone":t.tone??"default",children:(0,l.jsx)(zp,{row:t})})]},`${t.label}-${t.value}`))})}function Gp(e,t,n){return e.pathType==="bridge"?"Bridge Info":Nl(e.pathType)?"Swap Info":t&&n?"Swap & Bridge Info":t?"Bridge Info":"Swap Info"}function Up({summary:e}){let t=!!e.bridgeInfo?.length,n=!!e.swapInfo?.length,o=t&&n,r=e.pathType==="bridge-swap"?["bridge","swap"]:["swap","bridge"];return(0,l.jsx)(l.Fragment,{children:r.map(i=>{let a=i==="swap"?e.swapInfo:e.bridgeInfo;return a?.length?(0,l.jsxs)("div",{className:"bf-info-section",children:[o&&(0,l.jsx)("h4",{children:i==="swap"?"Swap Info":"Bridge Info"}),(0,l.jsx)(Il,{rows:a})]},i):null})})}function Hp({summary:e}){let t=!!e.bridgeInfo?.length,n=!!e.swapInfo?.length,o=!!e.txFee?.length,r=Gp(e,t,n),[i,a]=I.useState(!0),[s,c]=I.useState(!0);return(0,l.jsxs)("div",{className:"bf-details",children:[e.liquidity&&(0,l.jsxs)("section",{className:"bf-liquidity",children:[(0,l.jsxs)("div",{className:"bf-liquidity-head",children:[(0,l.jsx)("span",{children:e.liquidity.label??"Available Liquidity"}),(0,l.jsx)("span",{className:"bf-liquidity-status","data-status":e.liquidity.status,children:e.liquidity.status??"Normal"})]}),(0,l.jsx)("div",{className:"bf-liquidity-track",children:(0,l.jsx)("span",{style:{width:`${e.liquidity.percentage??50}%`}})})]}),(t||n)&&(0,l.jsxs)("section",{className:"bf-detail-section bf-info-card","data-open":i?"true":"false",children:[(0,l.jsxs)("button",{type:"button",className:"bf-collapse-head","aria-expanded":i,onClick:()=>a(d=>!d),children:[(0,l.jsx)("h3",{children:r}),(0,l.jsx)(pn,{size:16,className:"bf-collapse-chevron"})]}),i&&(0,l.jsx)("div",{className:"bf-collapse-body",children:(0,l.jsx)(Up,{summary:e})})]}),o&&(0,l.jsxs)("section",{className:"bf-detail-section bf-tx-fee-section","data-open":s?"true":"false",children:[(0,l.jsxs)("button",{type:"button",className:"bf-collapse-head bf-tx-fee-head","aria-expanded":s,onClick:()=>c(d=>!d),children:[(0,l.jsx)("h3",{children:"Est. Tx Fee"}),(0,l.jsxs)("div",{className:"bf-tx-fee-total",children:[e.txFeeInfo?.isDelegateFee&&(0,l.jsx)("span",{className:"bf-fee-delegated",children:"Fee Delegated"}),e.txFeeInfo?.tokenIconUrl&&(0,l.jsx)("img",{className:"bf-tx-fee-token",src:e.txFeeInfo.tokenIconUrl,alt:e.txFeeInfo.tokenSymbol??"",width:16,height:16,draggable:!1}),(0,l.jsx)("span",{"data-delegated":e.txFeeInfo?.isDelegateFee&&Number(e.txFeeInfo?.estTxFee)>0?"true":void 0,children:bp(e.txFeeInfo?.estTxFee??"0")}),(0,l.jsx)(pn,{size:16,className:"bf-collapse-chevron"})]})]}),s&&(0,l.jsx)("div",{className:"bf-collapse-body",children:(0,l.jsx)(Il,{rows:e.txFee})})]})]})}function $p({item:e}){let t=Jo(e),n=Rp(e.fromAmount,e.fromToken);return(0,l.jsxs)("article",{className:"bf-history-item",children:[(0,l.jsxs)("div",{className:"bf-history-item-head",children:[(0,l.jsx)("span",{className:"bf-history-status","data-status":t,children:Tp(t)}),(0,l.jsx)("time",{className:"bf-history-time",dateTime:e.timestamp,children:kp(e.timestamp)})]}),(0,l.jsxs)("div",{className:"bf-history-item-body",children:[(0,l.jsxs)("strong",{className:"bf-history-amount",children:[Sp(e.fromAmount)," ",e.fromToken.symbol]}),(0,l.jsxs)("div",{className:"bf-history-meta",children:[(0,l.jsx)("span",{className:"bf-history-usd",children:n??yp(e.txHash)}),(0,l.jsxs)("span",{className:"bf-history-route",children:[(0,l.jsxs)("span",{className:"bf-history-route-token",children:[(0,l.jsx)(Zn,{token:e.fromToken,size:16}),(0,l.jsx)("span",{children:e.fromToken.symbol})]}),(0,l.jsx)(il,{size:16,className:"bf-history-route-arrow"}),(0,l.jsxs)("span",{className:"bf-history-route-token",children:[(0,l.jsx)(Zn,{token:e.toToken,size:16}),(0,l.jsx)("span",{children:e.toToken.symbol})]})]})]})]})]})}function jp({flow:e}){let[t,n]=I.useState("all"),o=e.history.some(a=>Jo(a)==="pending"),r=e.history.filter(a=>Cp(a,t)),i=t==="all"?"No bridge history yet.":`No ${t} bridge history.`;return(0,l.jsxs)("main",{className:"bf-history-body",children:[(0,l.jsx)("nav",{className:"bf-history-tabs","aria-label":"Bridge history filters",children:mp.map(a=>(0,l.jsxs)("button",{type:"button",className:"bf-history-tab","data-active":t===a.value?"true":"false",onClick:()=>n(a.value),children:[(0,l.jsx)("span",{children:a.label}),a.value==="pending"&&o&&(0,l.jsx)("span",{className:"bf-history-tab-dot","aria-hidden":"true"})]},a.value))}),r.length>0?(0,l.jsx)("div",{className:"bf-history-list",children:r.map(a=>(0,l.jsx)($p,{item:a},a.id||a.txHash))}):(0,l.jsx)("div",{className:"bf-empty",children:i})]})}function Vp({flow:e,env:t}){let[n,o]=I.useState(null),[r,i]=I.useState(!1),[a,s]=I.useState(0),d=!!(e.fromAmount.trim()||e.toAmount.trim())?e.summary??Ip(e):null,f=up[t],h=Np(e.quoteError),g=wp(e.fromAmount,e.fromToken),u=g?"Insufficient balance":h.from,v=e.quoteError&&!h.from&&!h.to?e.quoteError:"",b=e.error||v,w=e.history.some(m=>Jo(m)==="pending"),E=(d?.pathType??Tl(e.fromToken,e.toToken))!=="bridge";return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("main",{className:"bf-body",children:[(0,l.jsxs)("div",{className:"bf-toolbar",children:[(0,l.jsxs)("button",{type:"button",className:"bf-chip bf-chip-history",onClick:()=>e.setStep("history"),children:[(0,l.jsx)(ol,{}),(0,l.jsx)("span",{children:"History"}),(w||e.hasNewHistory)&&(0,l.jsx)("span",{className:"bf-chip-dot","aria-hidden":"true"})]}),E&&(0,l.jsxs)("button",{type:"button",className:"bf-chip",onClick:()=>i(!0),disabled:e.slippageLocked,"aria-haspopup":"dialog","aria-expanded":r,children:[(0,l.jsx)(rl,{}),(0,l.jsx)("span",{children:e.slippageLocked?"Auto 1%":gp(e.slippage,e.effectiveSlippage)})]})]}),(0,l.jsxs)("div",{className:"bf-swap-card","data-has-from-error":u?"true":"false",children:[(0,l.jsx)(yl,{label:"From",token:e.fromToken,amount:e.fromAmount,usd:xl(e.fromAmount,e.fromToken),onAmountChange:m=>e.setAmount(m,"from"),onTokenClick:()=>o("from")}),u&&(0,l.jsx)("div",{className:"bf-field-error",children:u}),(0,l.jsx)("button",{type:"button",className:"bf-swap-toggle",onClick:()=>{e.swapTokens(),s(m=>m+360)},style:{transform:`translateX(-50%) rotate(${a}deg)`,transition:"transform 0.2s ease"},children:(0,l.jsx)(al,{size:22})}),(0,l.jsx)(yl,{label:"To",token:e.toToken,amount:e.toAmount,usd:xl(e.toAmount,e.toToken),onAmountChange:m=>e.setAmount(m,"to"),onTokenClick:()=>o("to"),locked:e.availableToTokens.length<=1}),h.to&&(0,l.jsx)("div",{className:"bf-field-error",children:h.to})]}),(0,l.jsx)(_p,{fromAmount:e.fromAmount,toAmount:e.toAmount,fromToken:e.fromToken,toToken:e.toToken}),d&&(0,l.jsx)(Hp,{summary:d})]}),(0,l.jsxs)("footer",{className:"bf-footer",children:[(0,l.jsx)("button",{type:"button",className:"bf-next",onClick:e.submit,disabled:e.status==="submitting"||!!e.quoteError||g,children:e.status==="submitting"?"Processing...":"Next"}),(0,l.jsxs)("a",{className:"bf-powered",href:f,target:"_blank",rel:"noreferrer",children:["Powered by ",(0,l.jsx)("span",{className:"bf-powered-brand",children:"CROSS DeFi"})]})]}),n&&(0,l.jsx)(Ep,{flow:e,side:n,onClose:()=>o(null)}),r&&(0,l.jsx)(Lp,{flow:e,onClose:()=>i(!1)}),(0,l.jsx)(Ap,{flow:e}),e.approvalInfo&&(0,l.jsx)(Fp,{flow:e,approval:e.approvalInfo}),(0,l.jsx)(Bp,{flow:e}),(0,l.jsx)(Mp,{flow:e}),(0,l.jsx)(Op,{message:e.submitToast?"":b}),(0,l.jsx)(Dp,{flow:e})]})}function Xn({onClose:e,onBackToWallet:t,env:n,className:o,...r}){let i=I.useMemo(()=>He(n),[n]),a=hl({...r,onExit:t}),s=I.useRef(null),c=fp(s),d=a.step==="history"?"History":"Swap & Bridge";return(0,l.jsx)(kl.Provider,{value:c,children:(0,l.jsxs)("div",{ref:s,className:se("bf-root",o),"data-view":a.step,"data-status":a.status,children:[(0,l.jsxs)("header",{className:"bf-header",children:[(0,l.jsx)("button",{type:"button",className:"bf-header-btn",onClick:a.back,"aria-label":"Back",children:(0,l.jsx)(dn,{size:24})}),(0,l.jsx)("span",{className:"bf-header-title",children:d}),(0,l.jsx)("button",{type:"button",className:"bf-header-btn",onClick:e,"aria-label":"Close",children:(0,l.jsx)(Bt,{size:24})})]}),a.step==="history"?(0,l.jsx)(jp,{flow:a}):(0,l.jsx)(Vp,{flow:a,env:i})]})})}var p=require("react/jsx-runtime"),qp="On-ramp is not available in your region.";function Xr(e,t,n){let o=Se[e],r=n.toUpperCase();if(t===o.cross&&r.includes("CROSSD"))return 0;if(t===o.cross&&r==="CROSS")return 1;if(t===o.bsc&&r==="CROSS")return 2}function Kp(e){return parseInt(e.split(":")[1],10)}function Qp(e){let t=e.lastIndexOf(".");return t===-1?{main:e,decimal:""}:{main:e.slice(0,t),decimal:e.slice(t)}}function Yp(e){let t=e.toLowerCase().replace(/^0x/,""),n=t.length>=8?t.slice(0,8):t.padEnd(8,"0"),o=parseInt(n.slice(0,4),16)%360,r=(o+60+parseInt(n.slice(4,8),16)%120)%360;return`linear-gradient(135deg, hsl(${o} 85% 65%), hsl(${r} 80% 55%))`}function Ll({align:e="end",sideOffset:t=12,className:n,children:o}){let{env:r,theme:i,isMobile:a,open:s,drawerDirection:c,modal:d,showBalance:f,showForgeToken:h,showGameToken:g,showQR:u,showBridge:v,qrLogoSrc:b,walletAddress:w,accountName:y,sendAccounts:E,profileImageUrl:m,preferredTokens:C,close:R,onSelectWallet:k,onCopyAddress:T,onBuy:G,onDisconnect:F,disconnectLabel:K,termsUrl:D,termsLabel:Q,privacyUrl:A,privacyLabel:ae,portalStyle:B,navContent:Y,navPosition:ye,footerContent:de,view:J,setView:be,selectedSendToken:ue,setSelectedSendToken:Z,showPortfolio:z,portfolioTitle:ee,portfolioSections:ze,showTotalAssets:ve,totalAssetsLabel:gt,sendTransaction:Be,getTransactionReceipt:Yt,estimateGas:ht,onOutlink:et,lpBalanceReader:Gt,stakingRewardsReader:_e,bridgeTokens:Re,bridgeHistory:dt,getBridgeQuote:Me,getBridgeToTokens:Ge,getBridgeApproval:Ce,approveBridge:Lt,submitBridge:bt,onReceive:At,onBridge:nt,onSend:Pt,onBuyDisabledMessage:ot,onBridgeDisabledMessage:Te,onSendDisabledMessage:rt}=Zt(),[pt,Ve]=W.useState(null),wt=W.useRef(void 0),ke=W.useCallback(x=>{Ve(x),clearTimeout(wt.current),wt.current=setTimeout(()=>Ve(null),4e3)},[]);W.useEffect(()=>()=>clearTimeout(wt.current),[]);let Le=!!ot,Ft=W.useCallback(()=>{if(Le){ke(ot);return}let x=G?.();x&&typeof x.then=="function"&&x.catch(()=>{ke(ot??qp)})},[Le,ot,G,ke]),xt=!!Te,qe=!!rt,{tokens:ft,isLoading:vt}=Vt(r,w,s&&f),{statsMap:Ae}=qt(r,f),{apyPercent:Oe}=Wi(),{categoryMap:N}=Gi(r,f),te=f&&ve,{displayValue:we,isLowerBound:at,isLoading:Ut}=Hi(r,w,s&&te),[it,vn]=W.useState(!1),Ht=W.useRef(null),[yn,co]=W.useState(0),{holdings:_,isLoading:Pe}=Fi(r,w,s&&f&&h),$=W.useMemo(()=>_.map(x=>x.token),[_]),{imageMap:Ke}=Bi(r,$,h&&_.length>0),ut=W.useMemo(()=>{let x=[],M=[],ne=[],Ye=new Map((C??[]).map((ie,Ue)=>[`${Kp(ie.chainId)}:${ie.address.toLowerCase()}`,Ue]));for(let ie of ft){let Ue=Xr(r,ie.chainId,ie.symbol)!==void 0,yt=`${ie.chainId}:${ie.address.toLowerCase()}`,an=Ye.get(yt),gr=new Pn.default(ie.quantity.numeric).shiftedBy(-ie.quantity.decimals);if(Ue)x.push(ie);else if(an!==void 0)M.push(ie);else if(gr.isGreaterThan(0)){if(!g&&N.get(Br(ie.chainId,ie.address))==="game")continue;ne.push(ie)}}return x.sort((ie,Ue)=>{let yt=Xr(r,ie.chainId,ie.symbol)??99,an=Xr(r,Ue.chainId,Ue.symbol)??99;return yt-an}),M.sort((ie,Ue)=>{let yt=Ye.get(`${ie.chainId}:${ie.address.toLowerCase()}`)??99,an=Ye.get(`${Ue.chainId}:${Ue.address.toLowerCase()}`)??99;return yt-an}),ne.sort((ie,Ue)=>{let yt=Ae.get(Rt(ie.chainId,ie.address)),an=Ae.get(Rt(Ue.chainId,Ue.address)),gr=new Pn.default(ie.quantity.numeric).shiftedBy(-ie.quantity.decimals).multipliedBy(yt?.price??0);return new Pn.default(Ue.quantity.numeric).shiftedBy(-Ue.quantity.decimals).multipliedBy(an?.price??0).minus(gr).toNumber()}),[...x,...M,...ne]},[ft,r,Ae,g,N,C]),ra=W.useMemo(()=>{if(!h)return[];let x=new Set(ft.map(M=>M.address.toLowerCase()));return[..._].filter(M=>!x.has(M.token.toLowerCase())).sort((M,ne)=>{let Ye=new Pn.default(M.value);return new Pn.default(ne.value).minus(Ye).toNumber()})},[_,h,ft]),rn=W.useRef(!1),[Qe,Bn]=W.useState(null),kn=W.useRef(void 0),aa=Qe?.chainId??ue?.chainId??ut[0]?.chainId??0,{transactionUrl:lr}=To(r,aa,Qe?.txHash,!!(Qe?.txHash&&aa)),st=W.useCallback(x=>{rn.current=!0,be(x)},[be]),[tc,cr]=W.useState("recipient"),po=W.useCallback(()=>{Z(null),cr("recipient"),st("wallet")},[Z,st]),dr=W.useCallback((x,M="recipient")=>{if(qe){ke(rt);return}cr(M),Z(x),st("send")},[qe,rt,ke,Z,st]),nc=W.useCallback(()=>{if(xt){ke(Te);return}if(nt){nt();return}st("bridge")},[xt,Te,nt,st,ke]),oc=W.useCallback(x=>{clearTimeout(kn.current),Z(null),st("wallet"),Bn({status:"pending",txHash:x.txHash,chainId:x.chainId,description:`${x.amount} ${x.tokenSymbol} to ${lt(x.recipient)}`})},[Z,st]),rc=W.useCallback(x=>{let M=ue?.chainId;Z(null),st("wallet"),!(!x||!M)&&(Bn(ne=>({status:"success",txHash:x,chainId:M,description:ne?.txHash===x?ne.description:"Tap to see your transaction"})),clearTimeout(kn.current),kn.current=setTimeout(()=>Bn(null),5e3))},[ue?.chainId,Z,st]),ac=W.useCallback(x=>{let M=x.txHash;M&&(Bn({status:"error",txHash:M,chainId:x.chainId,description:x.message}),clearTimeout(kn.current),kn.current=setTimeout(()=>Bn(null),5e3))},[]),_n=W.useMemo(()=>{if(At)return At;if(u)return()=>st("qr")},[At,u,st]),pr=W.useMemo(()=>{if(Pt)return Pt;if(ut.length===0)return;let x=ut[0];return()=>dr(x,"token")},[Pt,ut,dr]),ic=W.useCallback(()=>{if(qe){ke(rt);return}pr?.()},[qe,rt,pr,ke]);W.useEffect(()=>{s||(rn.current=!1,cr("recipient"))},[s]);let ia=W.useRef(null);W.useEffect(()=>{let x=ia.current;if(!x||!a)return;let M=ne=>{ne.pointerType==="touch"&&ne.stopPropagation()};return x.addEventListener("pointerdown",M),()=>x.removeEventListener("pointerdown",M)},[a]);let[Sn,sa]=W.useState(!1),fr=W.useRef(void 0),[Mn,On]=W.useState(!1);W.useEffect(()=>{if(!Mn)return;let x=()=>On(!1),M=Ye=>{Ye.key==="Escape"&&On(!1)},ne=setTimeout(()=>{document.addEventListener("mousedown",x,!0),document.addEventListener("keydown",M,!0)},0);return()=>{clearTimeout(ne),document.removeEventListener("mousedown",x,!0),document.removeEventListener("keydown",M,!0)}},[Mn]),W.useEffect(()=>{On(!1)},[w]),W.useEffect(()=>()=>clearTimeout(fr.current),[]),W.useEffect(()=>()=>clearTimeout(kn.current),[]),W.useEffect(()=>{let x=Ht.current;if(!x||de===null){co(0);return}let M=()=>{co(x.offsetHeight)};if(M(),typeof ResizeObserver>"u")return;let ne=new ResizeObserver(M);return ne.observe(x),()=>ne.disconnect()},[de]);let la=W.useCallback(async()=>{if(!Sn)try{await navigator.clipboard.writeText(w),sa(!0),clearTimeout(fr.current),fr.current=setTimeout(()=>sa(!1),2e3),T?.(w,!0)}catch{T?.(w,!1)}},[w,T,Sn]),fo=W.useCallback(x=>{x.currentTarget.setAttribute("data-loaded","true")},[]),ca=W.useMemo(()=>({background:Yp(w)}),[w]),uo=W.useMemo(()=>m||jt(r,w,{size:120,bg:i==="dark"?"1A1A2E":"F3F6F8"}),[m,r,w,i]),ur=W.useMemo(()=>Qp(we),[we]),da=D||A?(0,p.jsxs)("div",{className:"wi-legal-links",children:[D&&(0,p.jsx)("a",{className:"wi-legal-link",href:D,target:"_blank",rel:"noopener noreferrer",onClick:x=>Ze(x,D,{category:"terms",origin:"terms"},et),children:Q}),D&&A&&(0,p.jsx)("span",{className:"wi-legal-sep","aria-hidden":!0,children:"\xB7"}),A&&(0,p.jsx)("a",{className:"wi-legal-link",href:A,target:"_blank",rel:"noopener noreferrer",onClick:x=>Ze(x,A,{category:"privacy",origin:"privacy"},et),children:ae})]}):null,pa=F?(0,p.jsxs)("button",{type:"button",className:"wi-disconnect-btn",onClick:()=>{F(),R()},children:[(0,p.jsx)(Ma,{size:16}),(0,p.jsx)("span",{className:"wi-disconnect-label",children:K})]}):null,sc=f&&!Y?(0,p.jsxs)("div",{className:"wi-action-row","aria-label":"Wallet actions",children:[(0,p.jsxs)("button",{type:"button",className:se("wi-action-card",Le&&"wi-action-card--dimmed"),onClick:Ft,disabled:!G&&!Le,"aria-disabled":Le||void 0,"aria-label":"Buy",children:[(0,p.jsx)(Ua,{size:20}),(0,p.jsx)("span",{children:"Buy"})]}),v?(0,p.jsxs)("button",{type:"button",className:se("wi-action-card",xt&&"wi-action-card--dimmed"),onClick:nc,"aria-disabled":xt||void 0,"aria-label":"Bridge",children:[(0,p.jsx)(Ha,{size:20}),(0,p.jsx)("span",{children:"Bridge"})]}):(0,p.jsxs)("button",{type:"button",className:"wi-action-card",onClick:_n,disabled:!_n,"aria-label":"Receive",children:[(0,p.jsx)(Ro,{size:20}),(0,p.jsx)("span",{children:"Receive"})]}),(0,p.jsxs)("button",{type:"button",className:se("wi-action-card",qe&&"wi-action-card--dimmed"),onClick:ic,disabled:!qe&&!pr,"aria-disabled":qe||void 0,"aria-label":"Send",children:[(0,p.jsx)(za,{size:20}),(0,p.jsx)("span",{children:"Send"})]}),z?(0,p.jsxs)("button",{type:"button",className:"wi-action-card",onClick:()=>st("portfolio"),"aria-label":"View portfolio",children:[(0,p.jsx)(Ga,{size:20}),(0,p.jsx)("span",{children:"Portfolio"})]}):v?(0,p.jsxs)("button",{type:"button",className:"wi-action-card",onClick:_n,disabled:!_n,"aria-label":"Receive",children:[(0,p.jsx)(Ro,{size:20}),(0,p.jsx)("span",{children:"Receive"})]}):null]}):null,lc=(0,p.jsxs)("div",{className:se("wi-view-inner",rn.current&&"wi-view-wallet"),children:[te&&(0,p.jsxs)("div",{className:"wi-total-section",children:[(0,p.jsxs)("div",{className:"wi-total-head",children:[(0,p.jsx)("span",{className:"wi-total-label",children:gt}),(0,p.jsx)("span",{role:"button",tabIndex:0,className:"wi-total-eye",onClick:x=>{x.stopPropagation(),vn(M=>!M)},onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),x.stopPropagation(),vn(M=>!M))},"aria-label":it?"Show balance":"Hide balance",children:it?(0,p.jsx)(Wa,{}):(0,p.jsx)(Oa,{})})]}),(0,p.jsx)("div",{className:"wi-total-body",children:Ut?(0,p.jsx)("div",{className:"wi-skeleton-block wi-total-skeleton",style:{width:160,height:42}}):(0,p.jsx)("div",{className:"wi-total-value","data-hidden":it||void 0,children:it?(0,p.jsx)("span",{className:"wi-total-mask",children:"\u2022\u2022\u2022\u2022\u2022\u2022"}):(0,p.jsxs)(p.Fragment,{children:[at&&(0,p.jsx)("span",{className:"wi-total-lte",children:"\u2264"}),(0,p.jsx)("span",{className:"wi-total-currency",children:"$"}),(0,p.jsx)("span",{className:"wi-total-amount",children:ur.main}),ur.decimal&&(0,p.jsx)("span",{className:"wi-total-decimal",children:ur.decimal})]})})})]}),ye==="top"&&(Y?(0,p.jsx)("div",{className:"wi-nav-fixed",children:Y}):sc),f&&(0,p.jsx)("div",{ref:ia,className:"wi-scrollable-body","data-vaul-no-drag":!0,children:(0,p.jsxs)("div",{className:"wi-token-list",children:[vt&&Array.from({length:5},(x,M)=>(0,p.jsxs)("div",{className:"wi-skeleton-item",children:[(0,p.jsxs)("div",{className:"wi-skeleton-left",children:[(0,p.jsx)("div",{className:"wi-skeleton-block wi-skeleton-icon"}),(0,p.jsxs)("div",{className:"wi-skeleton-lines",children:[(0,p.jsx)("div",{className:"wi-skeleton-block",style:{width:64,height:14}}),(0,p.jsx)("div",{className:"wi-skeleton-block",style:{width:80,height:12}})]})]}),(0,p.jsxs)("div",{className:"wi-skeleton-right",children:[(0,p.jsx)("div",{className:"wi-skeleton-block",style:{width:72,height:14}}),(0,p.jsx)("div",{className:"wi-skeleton-block",style:{width:48,height:12}})]})]},M)),!vt&&ut.length===0&&!h&&(0,p.jsx)("div",{className:"wi-empty",children:"No Tokens Found"}),ut.map(x=>{let M=Ae.get(Rt(x.chainId,x.address)),ne=M?parseFloat(M.percent_change_24h):null,Ye=ne!==null&&ne>=0,ie=$n(r,x.chainId),Ue=pi(x.address);return(0,p.jsxs)("button",{type:"button",className:"wi-token-item wi-token-item--button",onClick:()=>dr(x),"aria-label":`Send ${x.symbol}`,children:[(0,p.jsxs)("div",{className:"wi-token-left",children:[(0,p.jsxs)("div",{className:"wi-token-icon-wrap",children:[(0,p.jsx)("img",{src:x.icon_url,alt:x.symbol,className:"wi-token-icon",width:32,height:32,loading:"lazy",draggable:!1,onLoad:fo,onError:yt=>{yt.currentTarget.src="https://contents.crosstoken.io/wallet/token/images/FT.png"}}),ie&&(0,p.jsx)("img",{src:ie,alt:"","aria-hidden":!0,className:"wi-token-chain-badge",width:14,height:14,loading:"lazy",draggable:!1,onError:yt=>{yt.currentTarget.style.display="none"}})]}),(0,p.jsxs)("div",{className:"wi-token-info",children:[(0,p.jsxs)("span",{className:"wi-token-name-row",children:[(0,p.jsx)("span",{className:"wi-token-name",children:x.symbol}),Ue&&Oe!==null&&(0,p.jsx)("span",{className:"wi-token-apy",children:`APY ${Oe>=0?"+":"-"}${(Oe>=0?Math.floor:Math.ceil)(Math.abs(Oe)*100)/100}%`})]}),M&&(0,p.jsxs)("div",{className:"wi-token-price-row",children:[(0,p.jsx)("span",{className:"wi-token-price",children:Sr(M.price)}),(0,p.jsx)("span",{className:"wi-token-change","data-positive":Ye,"data-zero":ne===0||void 0,children:ne!==null&&(ne===0?"0%":`${Ye?"+":"-"}${(Ye?Math.floor:Math.ceil)(Math.abs(ne)*100)/100}%`)})]})]})]}),(0,p.jsxs)("div",{className:"wi-token-right",children:[(0,p.jsx)("span",{className:"wi-token-balance",children:Jt(x.quantity.numeric,x.quantity.decimals)}),M&&(0,p.jsx)("span",{className:"wi-token-value",children:ja(x.quantity.numeric,x.quantity.decimals,M.price)})]})]},`${x.address}-${x.chainId}`)}),h&&Pe&&Array.from({length:3},(x,M)=>(0,p.jsxs)("div",{className:"wi-skeleton-item",children:[(0,p.jsxs)("div",{className:"wi-skeleton-left",children:[(0,p.jsx)("div",{className:"wi-skeleton-block wi-skeleton-icon"}),(0,p.jsxs)("div",{className:"wi-skeleton-lines",children:[(0,p.jsx)("div",{className:"wi-skeleton-block",style:{width:64,height:14}}),(0,p.jsx)("div",{className:"wi-skeleton-block",style:{width:80,height:12}})]})]}),(0,p.jsxs)("div",{className:"wi-skeleton-right",children:[(0,p.jsx)("div",{className:"wi-skeleton-block",style:{width:72,height:14}}),(0,p.jsx)("div",{className:"wi-skeleton-block",style:{width:48,height:12}})]})]},`forge-sk-${M}`)),h&&!Pe&&!vt&&ut.length===0&&ra.length===0&&(0,p.jsx)("div",{className:"wi-empty",children:"No Tokens Found"}),h&&ra.map(x=>{let M=Ke.get(x.token)||"",ne=$n(r,Se[r].cross);return(0,p.jsxs)("div",{className:"wi-token-item",children:[(0,p.jsxs)("div",{className:"wi-token-left",children:[(0,p.jsxs)("div",{className:"wi-token-icon-wrap",children:[(0,p.jsx)("img",{src:M||"https://contents.crosstoken.io/wallet/token/images/FT.png",alt:x.token_name,className:"wi-token-icon",width:32,height:32,loading:"lazy",draggable:!1,onLoad:fo,onError:Ye=>{Ye.currentTarget.src="https://contents.crosstoken.io/wallet/token/images/FT.png"}}),ne&&(0,p.jsx)("img",{src:ne,alt:"","aria-hidden":!0,className:"wi-token-chain-badge",width:14,height:14,loading:"lazy",draggable:!1,onError:Ye=>{Ye.currentTarget.style.display="none"}})]}),(0,p.jsxs)("div",{className:"wi-token-info",children:[(0,p.jsx)("span",{className:"wi-token-name",children:x.token_name}),(0,p.jsx)("div",{className:"wi-token-price-row",children:(0,p.jsxs)("span",{className:"wi-token-price",children:[Jt(x.current_price,18)," CROSS"]})})]})]}),(0,p.jsxs)("div",{className:"wi-token-right",children:[(0,p.jsx)("span",{className:"wi-token-balance",children:Jt(x.balance,18)}),(0,p.jsx)("span",{className:"wi-token-value",children:Sr(x.current_value_usd)})]})]},`forge-${x.token}`)})]})}),ye==="bottom"&&Y&&(0,p.jsx)("div",{className:"wi-nav-fixed",children:Y}),pa&&(0,p.jsx)("div",{className:"wi-wallet-disconnect-row",children:pa})]},"wallet"),cc=z?(0,p.jsx)("div",{className:se("wi-view-inner wi-portfolio-body",rn.current&&"wi-view-portfolio"),children:(0,p.jsx)(mn,{env:r,theme:i,walletAddress:w,showHeader:!1,onOutlink:et,lpBalanceReader:Gt,stakingRewardsReader:_e,sendTransaction:Be,estimateGas:ht,sections:ze})},"portfolio"):null,dc=ue?(0,p.jsx)("div",{className:se("wi-view-inner wi-send-body",rn.current&&"wi-view-send"),children:(0,p.jsx)(jn,{env:r,theme:i,walletAddress:w,accountName:y,accounts:E,initialStep:tc,token:ue,tokens:ut,onTokenChange:Z,sendTransaction:Be,getTransactionReceipt:Yt,estimateGas:ht,getTokenPriceUsd:x=>{let M=Ae.get(Rt(x.chainId,x.address));if(!M?.price)return;let ne=parseFloat(M.price);return Number.isFinite(ne)?ne:void 0},onClose:R,onBackToWallet:po,onSubmitted:oc,onSuccess:rc,onFailed:ac,onOutlink:et})},"send"):null,pc=W.useMemo(()=>Re||ut.map(x=>{let M=Ae.get(Rt(x.chainId,x.address)),ne=M?.price?parseFloat(M.price):void 0;return{name:x.name,symbol:x.symbol,chainId:x.chainId,address:x.address,decimals:x.quantity.decimals,balance:Hn(x.quantity.numeric,x.quantity.decimals),iconUrl:x.icon_url,priceUsd:Number.isFinite(ne)?ne:void 0}}),[Re,Ae,ut]),fc=(0,p.jsx)("div",{className:se("wi-view-inner wi-bridge-body",rn.current&&"wi-view-send"),children:(0,p.jsx)(Xn,{env:r,walletAddress:w,tokens:pc,history:dt,termsUrl:D,getQuote:Me,getToTokens:Ge,getApproval:Ce,approveBridge:Lt,submitBridge:bt,onClose:R,onBackToWallet:po})},"bridge"),mr=!!k&&y?.trim().toLowerCase()!=="my wallet",fa=(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)("span",{className:"wi-receive-avatar",children:[(0,p.jsx)("span",{className:"wi-avatar-fallback",style:ca}),uo&&(0,p.jsx)("img",{src:uo,alt:"",className:"wi-avatar-img",width:24,height:24,draggable:!1,onLoad:fo,onError:x=>{x.currentTarget.style.display="none"}})]}),(0,p.jsx)("span",{className:"wi-receive-account-name",children:y??"Account 1"}),mr&&(0,p.jsx)("span",{className:"wi-receive-chevron","data-open":Mn,"aria-hidden":"true",children:(0,p.jsx)(pn,{size:16})})]}),uc=(0,p.jsxs)("div",{className:se("wi-view-inner wi-qr-body",rn.current&&"wi-view-qr"),children:[(0,p.jsxs)("div",{className:"wi-receive-section",children:[mr?(0,p.jsx)("button",{type:"button",className:"wi-receive-account wi-receive-account--btn",onClick:()=>{On(!0),k?.()},"aria-label":"Switch account",children:fa}):(0,p.jsx)("div",{className:"wi-receive-account",children:fa}),(0,p.jsxs)("div",{className:"wi-qr-block",children:[(0,p.jsxs)("div",{className:"wi-qr-box",children:[(0,p.jsx)(El.QRCodeSVG,{value:w,size:180,level:"H",marginSize:2,...b&&{imageSettings:{src:b,height:33,width:33,excavate:!0}}}),!b&&(0,p.jsx)("div",{className:"wi-qr-logo",children:(0,p.jsx)(Da,{size:33})})]}),(0,p.jsx)("p",{className:"wi-qr-address",children:w})]}),(0,p.jsxs)("button",{type:"button",className:"wi-qr-copy-btn",onClick:la,children:[(0,p.jsx)("span",{className:"wi-qr-copy-icon",children:Sn?(0,p.jsx)(cn,{size:16}):(0,p.jsx)(Gn,{size:16})}),(0,p.jsx)("span",{className:"wi-qr-copy-text",children:Sn?"Copied!":"Copy address"})]})]}),da&&(0,p.jsx)("div",{className:"wi-receive-footer",children:da})]},"qr"),mc=J==="qr"||J==="portfolio"||J==="send"||J==="bridge",ua=de!==null?(0,p.jsx)("div",{className:"wi-builtin-footer",children:de}):null,ma=(0,p.jsxs)("div",{className:"wi-account-text",children:[mr?(0,p.jsxs)("button",{type:"button",className:"wi-account-row wi-account-row--btn",onClick:()=>{On(!0),k?.()},"aria-label":"Switch account","aria-expanded":Mn,children:[(0,p.jsx)("span",{className:"wi-account-name",children:y??"Account 1"}),(0,p.jsx)("span",{className:"wi-account-switch","data-open":Mn,"aria-hidden":"true",children:(0,p.jsx)(pn,{size:20})})]}):(0,p.jsx)("div",{className:"wi-account-row",children:(0,p.jsx)("span",{className:"wi-account-name",children:y??"Account 1"})}),(0,p.jsxs)("button",{type:"button",className:"wi-address-row-btn",onClick:la,"aria-label":"Copy address",children:[(0,p.jsx)("span",{className:"wi-account-address",children:lt(w)}),(0,p.jsx)("span",{className:"wi-account-copy","data-copied":Sn,children:Sn?(0,p.jsx)(cn,{size:12}):(0,p.jsx)(Gn,{size:12})})]})]}),ga=(0,p.jsxs)(p.Fragment,{children:[o,J==="qr"?(0,p.jsx)("div",{className:"wi-sticky-header",children:(0,p.jsxs)("div",{className:"wi-header wi-header--receive",children:[(0,p.jsx)("button",{type:"button",className:"wi-header-back",onClick:po,"aria-label":"Back",children:(0,p.jsx)(dn,{size:24})}),(0,p.jsx)("span",{className:"wi-receive-title",children:"Receive"}),(0,p.jsx)("button",{type:"button",className:"wi-header-action",onClick:R,"aria-label":"Close",children:(0,p.jsx)(Bt,{size:24})})]})}):J==="send"||J==="bridge"?null:mc?(0,p.jsxs)("div",{className:"wi-sticky-header",children:[(0,p.jsxs)("div",{className:"wi-header wi-header--wallet wi-header--sub-account",children:[(0,p.jsx)("button",{type:"button",className:"wi-header-back",onClick:po,"aria-label":"Back",children:(0,p.jsx)(dn,{size:24})}),(0,p.jsx)("div",{className:"wi-account-block wi-account-block--sub-account",children:ma}),(0,p.jsx)("button",{type:"button",className:"wi-header-action",onClick:R,"aria-label":"Close",children:(0,p.jsx)(Bt,{size:24})})]}),(0,p.jsx)("hr",{className:"wi-divider"})]}):(0,p.jsxs)("div",{className:"wi-sticky-header",children:[(0,p.jsxs)("div",{className:"wi-header wi-header--wallet",children:[(0,p.jsxs)("div",{className:"wi-account-block",children:[(0,p.jsxs)("div",{className:"wi-avatar",children:[(0,p.jsx)("div",{className:"wi-avatar-fallback",style:ca}),uo&&(0,p.jsx)("img",{src:uo,alt:"",className:"wi-avatar-img",width:28,height:28,draggable:!1,onLoad:fo,onError:x=>{x.currentTarget.style.display="none"}})]}),ma]}),(0,p.jsxs)("div",{className:"wi-header-actions",children:[u&&v&&(0,p.jsx)("button",{type:"button",className:"wi-header-action wi-header-action--qr",onClick:_n,"aria-label":"Show QR code",children:(0,p.jsx)(Ro,{size:20})}),(0,p.jsx)("button",{type:"button",className:"wi-header-action",onClick:R,"aria-label":"Close",children:(0,p.jsx)(Bt,{size:24})})]})]}),(0,p.jsx)("hr",{className:"wi-divider"})]}),(0,p.jsxs)("div",{className:"wi-view-container",children:[J==="wallet"&&lc,J==="qr"&&uc,J==="portfolio"&&cc,J==="send"&&dc,J==="bridge"&&fc]}),J==="wallet"&&pt&&(0,p.jsx)("div",{className:"wi-action-toast",role:"status","aria-live":"polite",children:pt}),J==="wallet"&&Qe&&(0,p.jsxs)("a",{className:"wi-send-toast",href:lr??"#",target:"_blank",rel:"noopener noreferrer",onClick:x=>{if(!lr){x.preventDefault();return}Ze(x,lr,{category:"send",origin:"send-transaction",payload:{chainId:Qe.chainId,txHash:Qe.txHash}},et)},children:[(0,p.jsx)("span",{className:"wi-send-toast-icon","data-status":Qe.status,"aria-hidden":!0,children:Qe.status==="pending"?(0,p.jsx)("span",{className:"wi-send-toast-spinner"}):Qe.status==="error"?(0,p.jsx)("span",{className:"wi-send-toast-error-dot"}):(0,p.jsx)($a,{size:20})}),(0,p.jsxs)("span",{className:"wi-send-toast-copy",children:[(0,p.jsx)("span",{className:"wi-send-toast-title",children:Qe.status==="pending"?"Sending...":Qe.status==="error"?"Send failed":"Send complete"}),(0,p.jsx)("span",{className:"wi-send-toast-desc",children:Qe.status==="pending"||Qe.status==="error"?Qe.description:"Tap to see your transaction"})]})]}),ua&&J!=="portfolio"&&J!=="send"&&(0,p.jsx)("div",{className:"wi-sticky-footer",children:(0,p.jsx)("div",{className:"wi-footer",ref:Ht,children:ua})})]}),ha={...B,...yn>0?{"--wi-footer-height":`${yn}px`}:null};return a?(0,p.jsxs)(Jn.Drawer.Portal,{children:[d&&(0,p.jsx)(Jn.Drawer.Overlay,{className:"wi-drawer-overlay"}),(0,p.jsxs)(Jn.Drawer.Content,{className:se("wi-drawer-content",n),"data-theme":i,"data-vaul-no-drag":c==="left"||c==="right"?!0:void 0,style:ha,"data-direction":c,"data-no-balance":!f||void 0,"data-has-footer":yn>0||void 0,"data-view":J,children:[(0,p.jsx)(Jn.Drawer.Title,{className:"wi-sr-only",children:"My Wallet"}),ga]})]}):(0,p.jsxs)(p.Fragment,{children:[d&&s&&(0,p.jsx)("div",{className:"wi-drawer-overlay",onClick:R}),(0,p.jsx)(er.Portal,{children:(0,p.jsx)(er.Content,{align:e,sideOffset:t,className:se("wi-popover-content",n),"data-theme":i,style:ha,"data-no-balance":!f||void 0,"data-has-footer":yn>0||void 0,"data-view":J,children:ga})})]})}var Al=H(require("react"),1);function Pl({position:e="top",children:t}){let{setNavContent:n,setNavPosition:o}=Zt();return Al.useEffect(()=>(n(t),o(e),()=>n(null)),[t,e,n,o]),null}var Fl=H(require("react"),1);function Bl({children:e}){let{setFooterContent:t}=Zt();return Fl.useEffect(()=>(t(e),()=>t(null)),[e,t]),null}j(`[data-theme=dark].wi-popover-content,[data-theme=dark].wi-drawer-content{--wi-primary: var(--ds-accent-primary-default, #019d92);--wi-secondary: var(--ds-system-red-default, #e70077);--wi-surface-bg: var(--ds-bg-default, #121212);--wi-surface-default: var(--ds-surface-medium, rgba(255, 255, 255, .05));--wi-surface-subtle: var(--ds-surface-high, rgba(255, 255, 255, .1));--wi-border-default: var(--ds-border-default, rgba(255, 255, 255, .05));--wi-border-subtle: var(--ds-border-medium, rgba(255, 255, 255, .1));--wi-texticon-primary: var(--ds-content-highest, #ffffff);--wi-texticon-secondary: var(--ds-content-medium, rgba(255, 255, 255, .7));--wi-texticon-tertiary: var(--ds-content-low, rgba(255, 255, 255, .5));--wi-on-primary: var(--ds-accent-primary-on, #ffffff);--wi-error: var(--ds-system-red-default, #e70077);--wi-shadow: 0 2px 16px -2px rgba(0, 0, 0, .4)}[data-theme=light].wi-popover-content,[data-theme=light].wi-drawer-content{--wi-primary: var(--ds-accent-primary-default, #019d92);--wi-secondary: var(--ds-system-red-default, #e70077);--wi-surface-bg: var(--ds-bg-default, #ffffff);--wi-surface-default: var(--ds-surface-medium, rgba(18, 18, 18, .05));--wi-surface-subtle: var(--ds-surface-high, rgba(18, 18, 18, .1));--wi-border-default: var(--ds-border-default, rgba(18, 18, 18, .05));--wi-border-subtle: var(--ds-border-medium, rgba(18, 18, 18, .1));--wi-texticon-primary: var(--ds-content-highest, #121212);--wi-texticon-secondary: var(--ds-content-medium, rgba(18, 18, 18, .7));--wi-texticon-tertiary: var(--ds-content-low, rgba(18, 18, 18, .5));--wi-on-primary: var(--ds-accent-primary-on, #ffffff);--wi-error: var(--ds-system-red-default, #e70077);--wi-shadow: 0 2px 16px -2px rgba(0, 0, 0, .15)}
|
|
11
11
|
`);j(`.wi-trigger-btn{display:inline-flex;align-items:center;gap:8px;padding:8px 16px;border:1px solid rgba(255,255,255,.2);background:#1a2332;border-radius:9999px;cursor:pointer;color:#fff;font-family:inherit;font-size:16px;font-weight:500;line-height:24px;letter-spacing:-.3125px;transition:opacity .15s ease}.wi-trigger-btn:hover{opacity:.85}.wi-trigger-btn[data-theme=light]{background:#f3f6f8;border-color:#1212121a;color:#121212}.wi-trigger-btn[data-mobile]{font-size:14px;padding:6px 12px;gap:6px;line-height:20px}.wi-trigger-address{white-space:nowrap}.wi-divider{height:1px;background:var(--wi-border-default);margin:0;border:none;flex-shrink:0}[data-theme=light] .wi-divider{background:#1212121a}[data-theme=dark] .wi-divider{background:#ffffff1a}
|