@aori/mega-swap-widget 0.1.12 → 0.1.13
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/SwapFormHorizontal-MEYPUSEU.js +2 -0
- package/dist/SwapFormHorizontal-QI3GS2BO.cjs +2 -0
- package/dist/SwapFormSplit-7VZ7IIJR.js +2 -0
- package/dist/SwapFormSplit-LI3MH5YB.cjs +2 -0
- package/dist/{chunk-CQPWVWB5.cjs → chunk-E7O7PKZA.cjs} +1 -1
- package/dist/chunk-GF37SKBJ.js +2 -0
- package/dist/chunk-HFX3K3RG.cjs +2 -0
- package/dist/{chunk-VO6ZLNGC.js → chunk-MVF5PRDZ.js} +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +1 -2
- package/dist/index.d.ts +1 -2
- package/dist/index.js +2 -2
- package/package.json +1 -1
- package/dist/SwapFormHorizontal-U5O4EPZX.js +0 -2
- package/dist/SwapFormHorizontal-XMIT4CPK.cjs +0 -2
- package/dist/SwapFormSplit-JSYDRTHF.cjs +0 -2
- package/dist/SwapFormSplit-T2WEJH2P.js +0 -2
- package/dist/chunk-LHEXDAQ2.js +0 -2
- package/dist/chunk-ZV4XHNYV.cjs +0 -2
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{a as wt}from"./chunk-VO6ZLNGC.js";import{a as zt,b as Mt,c as He,d as Ve,e as ye,f as gt,g as Se,h as pe,i as we,j as ut,k as ft,l as Lt,m as Ft,n as Ht,o as Vt,p as Dt,q as $t,r as jt,s as Ut,t as _t,u as Qt,v as Gt,w as Kt,x as mt,y as ht}from"./chunk-LHEXDAQ2.js";import{a as pt}from"./chunk-PFQ7GSLH.js";import"./chunk-OPN7WCJR.js";import{a as Bt,b as Et,c as qt,d as De,e as xe}from"./chunk-FWH744XA.js";import{a as tt,b as he,d as a}from"./chunk-XCPMBMS7.js";import{B as Ae,H as lt,M as ct,b as it,d as rt,g as at,j as ot,l as nt,n as st,y as dt}from"./chunk-NNNQNB5T.js";import{a as X}from"./chunk-46H44R7V.js";import"./chunk-73CB2I7U.js";import yi,{useMemo as Tt}from"react";import{Suspense as de,lazy as fe,useCallback as ke,useEffect as ze,useRef as Qe,useState as yt}from"react";import{useShallow as di}from"zustand/react/shallow";import{useCallback as ue,useEffect as We,useMemo as Yt,useRef as Pe,useState as Oe}from"react";import{useShallow as Zt}from"zustand/react/shallow";import{Fragment as $e,jsx as s,jsxs as U}from"react/jsx-runtime";var Jt=new Set([10,8453,42161,534352,59144,324]),Xt=4e-4,ei=.003;async function ti(e){let t=Jt.has(e)?Xt:ei;try{let u=await lt(e).getGasPrice()*350000n*3n/2n,M=Number(u)/1e18;return Math.max(M,t)}catch{return t}}var ii=({onSwapSubmitted:e,onSwapComplete:t,onSwapInitiated:d})=>{let{web3ConnectionType:o,hasConnectHandler:n,lockBase:h,lockQuote:u,disableInverting:M,tokenDisplay:H,tokenBadgeOrientation:z,widgetType:c}=he(),{effectiveInputTokens:V,effectiveOutputTokens:D}=pt(),I=V.length===1,R=D.length===1,E=H==="pill"||H==="ghost",W=c==="compact",G=W?"px-4 pt-3 pb-1":"px-4 pt-4 pb-2",w=W?"px-4 pt-4 pb-1":"px-4 pt-6 pb-2",{baseToken:i,quoteToken:r,baseAmount:f,quoteAmount:b,isBaseGasToken:v,isQuoteGasToken:N,isWrappingPair:p,isUnwrappingPair:x,baseBalance:P,quoteBalance:B,setBaseAmount:q,setQuoteAmount:y,swapTokens:_,clearForm:$}=xe(),{rfqQuote:K,status:S,handleInputChange:L,ensureForParams:le,stop:Q,clear:k,refresh:Y}=ye(),{address:O}=X(),{openConnectModal:ie}=Se(),{isRecipientInputOpen:re,txStatus:ae}=a(Zt(T=>({isRecipientInputOpen:T.isRecipientInputOpen,txStatus:T.txStatus}))),[C,ce]=Oe(null),[j,oe]=Oe(null),ne=Pe(!1),A=!1,ve=C!==null,me=Pe("");We(()=>{let T=`${i?.address}-${i?.chainId}|${r?.address}-${r?.chainId}`;me.current&&me.current!==T&&(C!==null||K!==null||S==="polling")&&(ce(null),oe(null),k(),$()),me.current=T},[i?.address,i?.chainId,r?.address,r?.chainId,C,K,S,k,$]);let Be=Pe(!1),[Te,se]=Oe(1);We(()=>{let T=C==="trackingTx"&&!!j&&!!i&&!!r&&!!f&&!!b;if(Be.current!==T){se(0);let J=setTimeout(()=>se(1),50);return Be.current=T,()=>clearTimeout(J)}},[C,j,i,r,f,b]);let Ie=Pe(C),[Re,be]=Oe(1);We(()=>{if(Ie.current!==C){be(0);let T=setTimeout(()=>be(1),50);return Ie.current=C,()=>clearTimeout(T)}},[C]);let Ne=Yt(()=>!i||!r||typeof f!="number"||!b||!O||parseFloat(P.formatted)<f?null:{base:i,quote:r,baseAmount:f,quoteAmount:b,userAddress:O},[i,r,f,b,O,P.formatted]),Ee=ue(T=>{oe(T),a.getState().startTracking(T)},[]),qe=ue(()=>{ne.current=!0,Y()},[Y]);We(()=>{if(C===null&&!(!i||!r)){if(!f||f<=0){L({amount:null,inputToken:i,outputToken:r,setOutputAmount:y});return}if(p||x){y(f);return}L({amount:f,inputToken:i,outputToken:r,setOutputAmount:y})}},[C,f,i,r,p,x,L,y]);let g=ue(()=>{a.getState().setView("baseSelection")},[]),Z=ue(()=>{a.getState().setView("quoteSelection")},[]),ge=ue(()=>{k(),_(),q(null),y(null)},[k,_,q,y]),Le=ue(async()=>{if(!P.formatted||!i||!r)return;let T=parseFloat(P.formatted);if(!T||T<=0)return;let J;if(v){let Fe=await ti(i.chainId);if(J=Math.max(0,T-Fe),J<=0)return}else J=T*.9999999999;p||x?(q(J),y(J),k()):(q(J),y(null),le({inputToken:i,outputToken:r,inputAmount:J.toString(),setOutputAmount:Fe=>y(Fe)}))},[P.formatted,i,r,v,p,x,q,y,k,le]),At=ue(()=>{k(),$()},[k,$]),Xe=P.formatted?parseFloat(P.formatted):null,Wt=!!(f||b),Pt=i?.price&&f?`$${(i.price*f).toFixed(2)}`:"$0.00",Ot=r?.price&&b?`$${(r.price*b).toFixed(2)}`:"$0.00",et=C==="trackingTx"&&!!j&&!!i&&!!r&&!!f&&!!b;return U("div",{className:"flex flex-col w-full",children:[s("div",{style:{opacity:Te,transition:"opacity 0.3s ease-out"},children:et&&j&&i&&r&&f&&b?s("div",{className:"overflow-hidden",children:s(ht,{orderHash:j,base:i,quote:r,baseAmount:f,quoteAmount:b,status:ae})}):U($e,{children:[U("div",{className:`relative ${G}`,style:{borderBottom:"1px solid var(--widget-border)"},children:[E?W?U("div",{className:`flex items-center gap-2 mb-2 ${z==="right"?"flex-row-reverse":"flex-row"}`,children:[s(we,{toggle:g,side:"base",asset:i,isPlacingOrder:A||h||I,hideDropdown:I}),s("div",{className:"flex-1 min-w-0",children:s(pe,{side:"base",asset:i??null,otherAsset:r??null,isPlacingOrder:A,isWrappingPair:p,isUnwrappingPair:x})})]}):U("div",{className:`flex flex-col ${z==="right"?"items-end":"items-start"}`,children:[s(we,{toggle:g,side:"base",asset:i,isPlacingOrder:A||h||I,hideDropdown:I}),s(pe,{side:"base",asset:i??null,otherAsset:r??null,isPlacingOrder:A,isWrappingPair:p,isUnwrappingPair:x})]}):U($e,{children:[s(we,{toggle:g,side:"base",asset:i,isPlacingOrder:A||h||I,hideDropdown:I}),s(pe,{side:"base",asset:i??null,otherAsset:r??null,isPlacingOrder:A,isWrappingPair:p,isUnwrappingPair:x})]}),U("div",{className:"mb-1 flex w-full flex-row items-center justify-between",children:[s("p",{className:"font-sans text-sm",style:{color:"var(--widget-muted-foreground)"},children:Pt}),O&&Xe!==null&&Xe>0&&s("button",{type:"button",onClick:Le,disabled:A,className:"absolute bottom-3 right-4 flex items-center px-3 py-0.5 text-xs font-medium uppercase cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed transition-colors bg-(--widget-primary) text-(--widget-primary-foreground) hover:bg-(--widget-foreground) hover:text-(--widget-card)",style:{borderRadius:"var(--widget-radius)"},children:"Max"})]})]}),!M&&s("div",{className:"flex justify-center -my-4 relative z-10",children:s("button",{type:"button",onClick:ge,disabled:ve,"aria-label":"Swap input and output tokens",className:`flex h-8 w-8 items-center justify-center rounded-full transition-colors bg-(--widget-card) ${ve?"cursor-not-allowed opacity-40 pointer-events-none":"cursor-pointer text-(--widget-muted-foreground) hover:bg-(--widget-secondary) hover:text-(--widget-foreground)"}`,style:{border:"1px solid var(--widget-border)"},children:s(ft,{className:"w-3.5 h-3.5"})})}),U("div",{className:`relative ${w}`,children:[E?W?U("div",{className:`flex items-center gap-2 ${z==="right"?"flex-row-reverse":"flex-row"}`,children:[s(we,{toggle:Z,side:"quote",asset:r,isPlacingOrder:A||u||R,hideDropdown:R}),s("div",{className:"flex-1 min-w-0",children:s(pe,{side:"quote",asset:r??null,otherAsset:i??null,isPlacingOrder:A,isWrappingPair:p,isUnwrappingPair:x})})]}):U("div",{className:`flex flex-col ${z==="right"?"items-end":"items-start"}`,children:[s(we,{toggle:Z,side:"quote",asset:r,isPlacingOrder:A||u||R,hideDropdown:R}),s(pe,{side:"quote",asset:r??null,otherAsset:i??null,isPlacingOrder:A,isWrappingPair:p,isUnwrappingPair:x})]}):U($e,{children:[s(we,{toggle:Z,side:"quote",asset:r,isPlacingOrder:A||u||R,hideDropdown:R}),s(pe,{side:"quote",asset:r??null,otherAsset:i??null,isPlacingOrder:A,isWrappingPair:p,isUnwrappingPair:x})]}),U("div",{className:"flex w-full flex-row items-center justify-between",children:[s("p",{className:"font-sans text-sm",style:{color:"var(--widget-muted-foreground)"},children:Ot}),Wt&&s("button",{type:"button",onClick:At,disabled:A,className:"absolute bottom-2 right-4 flex items-center px-3 py-0.5 text-xs font-medium uppercase cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed transition-colors text-(--widget-muted-foreground) hover:bg-(--widget-secondary)",style:{borderRadius:"var(--widget-radius)"},children:"Clear"})]})]}),s("div",{className:"flex flex-row items-center w-full overflow-hidden",style:{borderTop:re?"1px solid var(--widget-border)":"none",maxHeight:re?"60px":"0px",opacity:re?1:0,transition:"max-height 0.3s ease, opacity 0.3s ease"},children:s(ut,{})}),s("div",{className:"px-4",style:{borderTop:"1px solid var(--widget-border)",borderBottom:"1px solid var(--widget-border)"},children:s(wt,{})})]})}),s("div",{className:`relative ${et?"px-0 pb-4":"px-4"} ${W?"py-2":"py-4"}`,style:{opacity:Re,transition:"opacity 0.3s ease-out"},children:O&&i&&r&&f&&f>0?s(mt,{base:i,baseAmount:f,quote:r,quoteAmount:b??0,userAddress:O,isWrappingPair:p,isUnwrappingPair:x,isBaseGasToken:v,isQuoteGasToken:N,reviewActionProps:Ne,reviewState:C,setReviewState:ce,trackedOrderHash:j,setTrackedOrderHash:oe,onSwapSubmitted:e,onSwapComplete:t,onSwapInitiated:d,onOrderSubmitted:Ee,onStaleQuoteRestart:qe,txStatus:ae}):!O&&n?s("button",{onClick:()=>ie(),className:`w-full ${W?"py-2":"py-3"} text-sm font-sans font-medium cursor-pointer transition-opacity hover:opacity-80`,style:{backgroundColor:"var(--widget-primary)",color:"var(--widget-primary-foreground)",borderRadius:"var(--widget-radius)"},children:"Connect Wallet"}):s("button",{disabled:!0,className:`w-full ${W?"py-2":"py-3"} text-sm font-sans font-medium transition-colors disabled:opacity-40 cursor-not-allowed`,style:{backgroundColor:"var(--widget-primary)",color:"var(--widget-primary-foreground)",borderRadius:"var(--widget-radius)"},children:O?"Enter Amount":"Connect Wallet"})})]})},vt=ii;import{jsx as F,jsxs as je}from"react/jsx-runtime";var bt=()=>je("div",{className:"flex flex-col w-full",children:[je("div",{className:"relative px-4 pt-4 pb-2",style:{borderBottom:"1px solid var(--widget-border)"},children:[F("div",{className:"h-12 w-full animate-pulse",style:{backgroundColor:"var(--widget-secondary)",borderRadius:"0.25rem"}}),F("div",{className:"mt-2 h-20 w-2/3 animate-pulse",style:{backgroundColor:"var(--widget-secondary)",opacity:.5,borderRadius:"0.25rem"}}),F("div",{className:"mt-1 mb-1 flex w-full items-center justify-between",children:F("div",{className:"h-4 w-12 animate-pulse",style:{backgroundColor:"var(--widget-secondary)",opacity:.4,borderRadius:"0.25rem"}})})]}),F("div",{className:"flex justify-center -my-4 relative z-10",children:F("div",{className:"h-8 w-8",style:{border:"1px solid var(--widget-border)",backgroundColor:"var(--widget-card)",borderRadius:"9999px"}})}),je("div",{className:"relative px-4 pt-6 pb-2",children:[F("div",{className:"h-12 w-full animate-pulse",style:{backgroundColor:"var(--widget-secondary)",borderRadius:"0.25rem"}}),F("div",{className:"mt-2 h-20 w-2/3 animate-pulse",style:{backgroundColor:"var(--widget-secondary)",opacity:.5,borderRadius:"0.25rem"}}),F("div",{className:"mt-1 mb-1 flex w-full items-center justify-between",children:F("div",{className:"h-4 w-12 animate-pulse",style:{backgroundColor:"var(--widget-secondary)",opacity:.4,borderRadius:"0.25rem"}})})]}),F("div",{className:"px-4",style:{height:"28px",borderTop:"1px solid var(--widget-border)",borderBottom:"1px solid var(--widget-border)"}}),F("div",{className:"relative px-4 py-4",children:F("div",{className:"w-full animate-pulse",style:{height:"44px",backgroundColor:"var(--widget-secondary)",borderRadius:"var(--widget-radius)",opacity:.6}})})]});import{useEffect as ri,useState as Ue}from"react";import{useShallow as ai}from"zustand/react/shallow";import{Fragment as si,jsx as m,jsxs as ee}from"react/jsx-runtime";var oi=({targetText:e,isError:t})=>{let{displayText:d,suffix:o,characterColors:n}=dt(e,t);return ee(si,{children:[d.split("").map((h,u)=>m("span",{style:n[u]?{color:"var(--widget-destructive)"}:void 0,children:h},u)),m("span",{style:{color:t?"var(--widget-destructive)":"var(--widget-muted-foreground)",opacity:t?.5:1},children:o})]})},ni=({headerText:e,onBackClick:t,isSameChain:d,isWrappingPair:o,isUnwrappingPair:n,hasLowLiquidity:h,hasInsufficientLiquidity:u,hasRoutingError:M,hasSizeCapError:H,hasInsufficientBalance:z})=>{let c=a(S=>S.view),{isRecipientInputOpen:V,hasAllowanceError:D,hoveredChainName:I,isTrackingTx:R,txStatus:E,walletTab:W}=a(ai(S=>({isRecipientInputOpen:S.isRecipientInputOpen,hasAllowanceError:S.hasAllowanceError,hoveredChainName:S.hoveredChainName,isTrackingTx:S.isTrackingTx,txStatus:S.txStatus,walletTab:S.walletTab}))),{swapHeaderVariant:G,walletButtonEnabled:w}=he(),{isConnected:i}=X(),[r,f]=Ue(!1);ri(()=>f(!0),[]);let[b,v]=Ue(!1),[N,p]=Ue(!1),x=`${c}-${b}-${N}-${V}-${I||"none"}`,B=(()=>{if(R&&E)switch(E){case"pending":return"Trade Pending";case"received":return"Trade Received";case"completed":return"Trade Filled";case"failed":return"Trade Failed";case"cancelled":return"Trade Cancelled";default:return"Processing Trade"}if(I&&(c==="baseSelection"||c==="quoteSelection"||c==="baseChainSelection"||c==="quoteChainSelection"))return I;if(c==="swap"&&N)return"View Transaction History";if(c==="swap"&&b)return V?"Remove Custom Recipient":"Add Custom Recipient";switch(c){case"wallet":return"Wallet";case"activity":return"Activity";case"baseSelection":return"Select Source Token";case"quoteSelection":return"Select Destination Token";case"baseChainSelection":return"Select Source Chain";case"quoteChainSelection":return"Select Destination Chain";default:if(c==="swap"){if(D&&!o&&!n)return"Allowance check failed";if(H&&!o&&!n)return"Size limit exceeded";if(u&&!o&&!n)return"Insufficient Liquidity";if(M&&!o&&!n)return"Route Not Found";if(h&&!o&&!n)return"High Price Impact";if(z&&!o&&!n)return"Insufficient Balance"}return d&&!o&&!n?"Swap":o?"Wrap":n?"Unwrap":e}})(),q=!R&&c==="swap"&&!b&&(D&&!o&&!n||H&&!o&&!n||u&&!o&&!n||M&&!o&&!n||h&&!o&&!n||z&&!o&&!n),y={pending:"var(--widget-primary)",received:"var(--widget-primary)",completed:"var(--widget-status-completed)",failed:"var(--widget-status-failed)",cancelled:"var(--widget-status-failed)"},_=()=>!R||!E?null:y[E]??null,$=()=>R?m("button",{onClick:()=>a.getState().exitHandler?.(),"aria-label":"Close trade status",className:"size-4 -translate-y-0.5 flex cursor-pointer items-center justify-center transition-colors text-(--widget-muted-foreground) opacity-60 hover:text-(--widget-foreground) hover:opacity-100",children:ee("svg",{className:"size-3.5",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[m("path",{d:"M18 6L6 18",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),m("path",{d:"M6 6L18 18",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}):c==="swap"?ee("div",{className:"flex items-center gap-2",children:[w&&r&&i&&m("button",{onClick:()=>a.getState().setView("activity"),onMouseEnter:()=>p(!0),onMouseLeave:()=>p(!1),"aria-label":"Open activity",className:"size-4 -translate-y-0.5 flex cursor-pointer items-center justify-center rounded-full transition-colors text-(--widget-muted-foreground) opacity-60 hover:text-(--widget-foreground) hover:opacity-100",children:ee("svg",{className:"size-3.5",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[m("path",{d:"M12 8V12L14.5 14.5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),m("path",{d:"M3.05 11A9 9 0 1 1 3.05 13",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}),m("path",{d:"M1 7.5L3.05 11L6.5 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}),m("button",{onClick:()=>a.getState().toggleRecipientInput(),onMouseEnter:()=>v(!0),onMouseLeave:()=>v(!1),"aria-label":V?"Remove custom recipient":"Add custom recipient",className:`size-4 -translate-y-0.5 flex cursor-pointer items-center justify-center rounded-full transition-colors hover:text-(--widget-foreground) hover:opacity-100 ${V?"text-(--widget-destructive) opacity-80":"text-(--widget-muted-foreground) opacity-60"}`,children:ee("svg",{className:"size-3.5",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[m("path",{d:"M2 7.75C1.58579 7.75 1.25 8.08579 1.25 8.5C1.25 8.91421 1.58579 9.25 2 9.25V7.75ZM2 8.5V9.25H13.5V8.5V7.75H2V8.5Z",fill:"currentColor"}),m("path",{d:"M6 16.5H8",stroke:"currentColor",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"butt",strokeLinejoin:"miter"}),m("path",{d:"M10.5 16.5H14.5",stroke:"currentColor",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"butt",strokeLinejoin:"miter"}),m("path",{d:"M22 12.03V16.11C22 20.5 22 20.5 17.56 20.5H6.44C2 20.5 2 20.5 2 16.11V7.89C2 3.5 2 3.5 6.44 3.5H13.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"miter"}),ee("g",{style:{transform:`rotate(${V?"45deg":"0deg"})`,transformOrigin:"18.75px 6.75px",transition:"transform 150ms ease-out"},children:[m("path",{d:"M15 6.75H22.5",stroke:"currentColor",strokeWidth:"1.5"}),m("path",{d:"M18.75 10.5V3",stroke:"currentColor",strokeWidth:"1.5"})]})]})})]}):ee("button",{onClick:()=>t?t():a.getState().setView("swap"),className:"flex cursor-pointer items-center justify-center whitespace-nowrap h-6 transition-colors text-(--widget-muted-foreground) opacity-70 hover:text-(--widget-foreground) hover:opacity-100",children:[m("span",{className:"pr-1",children:"\u2190"}),m("span",{className:"text-sm",children:"Back"})]}),K=_();return G==="none"?null:ee("div",{className:"w-full pt-3 px-2 font-sans text-base flex flex-row justify-between h-6 shrink-0",children:[c==="wallet"?ee("div",{className:"flex items-center gap-1 font-sans uppercase -translate-y-0.5 text-xs",children:[m("button",{type:"button",onClick:()=>a.getState().setWalletTab("wallet"),className:"cursor-pointer transition-colors",style:{color:W==="wallet"?"var(--widget-foreground)":"var(--widget-muted-foreground)"},children:m("span",{children:"Wallet"})}),m("button",{type:"button",onClick:()=>a.getState().setWalletTab("activity"),className:"cursor-pointer transition-colors",style:{color:W==="activity"?"var(--widget-foreground)":"var(--widget-muted-foreground)"},children:"Activity"})]}):m("div",{className:"font-sans uppercase -translate-y-0.5 text-xs flex items-center",children:m("span",{className:"relative",style:{color:K||"var(--widget-foreground)"},children:m(oi,{targetText:B,isError:q??!1})},x)}),m("div",{className:"flex flex-row items-center",children:$()})]})},_e=ni;import{Fragment as fi,jsx as l,jsxs as Me}from"react/jsx-runtime";var xt=fe(()=>import("./AssetSelectionMenu-F2JUPXHM.js")),St=fe(()=>import("./ChainSelectionMenu-BGZDH2WA.js")),li=fe(()=>import("./SwapFormHorizontal-U5O4EPZX.js")),ci=fe(()=>import("./SwapFormSplit-T2WEJH2P.js")),gi=fe(()=>import("./WidgetWalletPanel-7L7E7IA5.js").then(e=>({default:e.WidgetWalletPanel}))),pi=fe(()=>import("./WalletPlaceholderPanel-Z4JCFCNV.js").then(e=>({default:e.WalletPlaceholderPanel}))),wi=fe(()=>import("./WidgetWalletTradeHistory-ES3FEDM7.js").then(e=>({default:e.WidgetWalletTradeHistory}))),ui=({onSwapSubmitted:e,onSwapComplete:t,cardStyles:d,cardWidth:o})=>{let{baseToken:n,quoteToken:h,baseAmount:u,quoteAmount:M,baseBalance:H,isWrappingPair:z,isUnwrappingPair:c,isRegistryLoading:V}=xe(),{liquidityError:D,routingError:I,sizeCapError:R,stop:E,clear:W}=ye(),G=!!(u&&H.formatted&&parseFloat(H.formatted)<u),w=a(g=>g.view),{isTransitioning:i,isRecipientInputOpen:r,recipient:f,selectedChainFilterChainId:b}=a(di(g=>({isTransitioning:g.isTransitioning,isRecipientInputOpen:g.isRecipientInputOpen,recipient:g.recipient,selectedChainFilterChainId:g.selectedChainFilter?.chainId??null}))),v=Qe(null),N=Qe(null),[p,x]=yt(null);He(),ze(()=>()=>{v.current&&clearTimeout(v.current),N.current&&clearTimeout(N.current)},[]),ze(()=>{a.getState().resetUI()},[]),ze(()=>{if(i)return v.current=setTimeout(()=>{a.getState().setIsTransitioning(!1),v.current=null},20),()=>{v.current&&(clearTimeout(v.current),v.current=null)}},[i]);let P=ke((g,Z="navigation")=>{N.current&&(clearTimeout(N.current),N.current=null,x(null)),a.getState().view!=="swap"&&g!=="swap"?(a.getState().setView(g),a.getState().setIsTransitioning(!1)):a.getState().transitionToView(g,Z)},[]),B=ke(()=>{v.current&&(clearTimeout(v.current),v.current=null),N.current&&(clearTimeout(N.current),N.current=null);let g=a.getState().view;x(g),a.getState().setChainFilter(null),a.getState().setView("swap"),a.getState().setIsTransitioning(!1),a.getState().resetAssetSelection(),N.current=setTimeout(()=>{x(null),N.current=null},200)},[]),q=ke(g=>{let ge=w==="baseChainSelection"?"base":"quote";a.getState().setChainFilter({chainId:g,side:ge}),a.getState().pushRecentChain(g),P(ge==="base"?"baseSelection":"quoteSelection","chainSelection")},[w,P]),y=ke(()=>{let g=a.getState().view;g==="baseSelection"?P("baseChainSelection","chainSelection"):g==="quoteSelection"&&P("quoteChainSelection","chainSelection")},[P]),_=ke(()=>{E(),W()},[E,W]),$=n&&h?n.chainId===h.chainId:!0,K=()=>{switch(w){case"wallet":return"Wallet";case"baseSelection":return"Select Input Token";case"quoteSelection":return"Select Output Token";case"baseChainSelection":case"quoteChainSelection":return"Select Chain";default:return"Swap"}},{assetMenuVariant:S,widgetType:L,customWalletUI:le}=he(),Q=w==="baseSelection"||w==="quoteSelection",k=w==="baseChainSelection"||w==="quoteChainSelection",Y=S==="split"&&(L==="default"||L==="compact"),O=S==="split"&&(L==="horizontal"||L==="split"),ie=S==="default",re=w==="swap"||Q||k||w==="wallet"||w==="activity",ae=p==="baseSelection"||p==="quoteSelection",C=p==="baseChainSelection"||p==="quoteChainSelection",ce=Q||ae,j=k||C,oe=Q&&!i,ne=k&&!i,A=Q?w:p,ve=A==="baseSelection"?"base":"quote",me=A==="baseSelection"?h:n,Te=(k?w:p)==="baseChainSelection"?"base":"quote",se=g=>({backgroundColor:"var(--widget-background)",opacity:g?1:0,transform:g?"translateY(0)":"translateY(6px)",transition:"opacity 200ms ease-in-out, transform 200ms ease-in-out"}),Ie=ie&&(Q||k||w==="wallet"||w==="activity"||p!=null),Re=V?l(bt,{}):L==="horizontal"?l(de,{fallback:null,children:l(li,{onSwapSubmitted:e,onSwapComplete:t,onSwapInitiated:_,onBackToSwap:O?B:void 0,onMoreChainsClick:O?y:void 0})}):L==="split"?l(de,{fallback:null,children:l(ci,{onSwapSubmitted:e,onSwapComplete:t,onSwapInitiated:_,onBackToSwap:O?B:void 0,onMoreChainsClick:O?y:void 0})}):l(vt,{onSwapSubmitted:e,onSwapComplete:t,onSwapInitiated:_}),be=d??{},Ne=Qe(null),[Ee,qe]=yt(420);return ze(()=>{if(!Y)return;let g=Ne.current;if(!g)return;let Z=new ResizeObserver(ge=>{for(let Le of ge)qe(Le.contentRect.height)});return Z.observe(g),()=>Z.disconnect()},[Y]),Y?Me(fi,{children:[Me("div",{ref:Ne,className:"flex flex-col w-full overflow-hidden transition-colors duration-300",style:{flex:"1 1 0",minWidth:0,...be},children:[l(_e,{headerText:"Swap",onBackClick:B,isSameChain:$,isWrappingPair:z,isUnwrappingPair:c,hasLowLiquidity:D,hasInsufficientLiquidity:D,hasRoutingError:I,hasSizeCapError:R,hasInsufficientBalance:G}),l("div",{className:"overflow-hidden",children:Re})]}),(ce||j)&&l("div",{className:"flex flex-col overflow-hidden shrink-0",style:{width:o,height:`${Ee}px`,...be,...se((Q||k)&&!i)},children:Q||ae?l(de,{fallback:null,children:l(xt,{toggle:B,side:ve,otherAsset:me,onMoreChainsClick:y,selectedChainFilter:b})}):l(de,{fallback:null,children:l(St,{toggle:B,side:Te,onChainSelect:q})})})]}):Me("div",{className:"flex flex-col w-full",style:{overflow:"hidden",position:"relative"},children:[l(_e,{headerText:K(),onBackClick:B,isSameChain:$,isWrappingPair:z,isUnwrappingPair:c,hasLowLiquidity:D,hasInsufficientLiquidity:D,hasRoutingError:I,hasSizeCapError:R,hasInsufficientBalance:G}),Me("div",{className:"relative overflow-hidden",children:[re&&l("div",{className:"overflow-hidden",style:Ie?{pointerEvents:"none"}:void 0,children:Re}),(w==="wallet"||p==="wallet")&&l("div",{className:"absolute inset-0 overflow-hidden z-20",style:se(w==="wallet"&&!i),children:l(de,{fallback:null,children:le==="none"?l(pi,{}):l(gi,{})})}),(w==="activity"||p==="activity")&&l("div",{className:"absolute inset-0 overflow-y-auto z-20",style:se(w==="activity"&&!i),children:l(de,{fallback:null,children:l(wi,{isActive:w==="activity"})})}),ie&&ce&&l("div",{className:"absolute inset-0 overflow-hidden z-20",style:se(oe),children:l(de,{fallback:null,children:l(xt,{toggle:B,side:ve,otherAsset:me,onMoreChainsClick:y,selectedChainFilter:b})})}),ie&&j&&l("div",{className:"absolute inset-0 overflow-hidden z-20",style:se(ne),children:l(de,{fallback:null,children:l(St,{toggle:B,side:Te,onChainSelect:q})})})]})]})},kt=({onSwapSubmitted:e,onSwapComplete:t,defaultBaseToken:d,defaultQuoteToken:o,onBaseTokenChange:n,onQuoteTokenChange:h,cardStyles:u,cardWidth:M})=>{let{address:H}=X(),z=a(c=>c.recipient);return l(De,{defaultBaseToken:d,defaultQuoteToken:o,onBaseTokenChange:n,onQuoteTokenChange:h,children:l(Ve,{recipient:z,children:l(ui,{onSwapSubmitted:e,onSwapComplete:t,cardStyles:u,cardWidth:M})})})};import{createContext as mi,useContext as hi}from"react";var Ge={background:"#ffffff",foreground:"#0a0a0a",card:"#ffffff","card-foreground":"#0a0a0a",popover:"#ffffff","popover-foreground":"#0a0a0a",primary:"#171717","primary-foreground":"#fafafa",secondary:"#f5f5f5","secondary-foreground":"#171717",muted:"#f5f5f5","muted-foreground":"#737373",accent:"#f5f5f5","accent-foreground":"#171717",destructive:"#e7000b","destructive-foreground":"#ffffff",border:"#e5e5e5",input:"#e5e5e5",ring:"#a1a1a1",radius:"0.625rem","border-style":"dotted","status-pending":"#a1a1aa","status-received":"#f59e0b","status-completed":"#10b981","status-failed":"#ef4444"},Ce={background:"#0a0a0a",foreground:"#fafafa",card:"#171717","card-foreground":"#fafafa",popover:"#262626","popover-foreground":"#fafafa",primary:"#e5e5e5","primary-foreground":"#171717",secondary:"#262626","secondary-foreground":"#fafafa",muted:"#262626","muted-foreground":"#a1a1a1",accent:"#404040","accent-foreground":"#fafafa",destructive:"#ff6467","destructive-foreground":"#fafafa",border:"#282828",input:"#343434",ring:"#737373",radius:"0.625rem","border-style":"dotted","status-pending":"#a1a1aa","status-received":"#fbbf24","status-completed":"#2dd4bf","status-failed":"#fb7185"};function Ke(e){let t={"--widget-background":e.background,"--widget-foreground":e.foreground,"--widget-card":e.card,"--widget-card-foreground":e["card-foreground"],"--widget-popover":e.popover,"--widget-popover-foreground":e["popover-foreground"],"--widget-primary":e.primary,"--widget-primary-foreground":e["primary-foreground"],"--widget-secondary":e.secondary,"--widget-secondary-foreground":e["secondary-foreground"],"--widget-muted":e.muted,"--widget-muted-foreground":e["muted-foreground"],"--widget-accent":e.accent,"--widget-accent-foreground":e["accent-foreground"],"--widget-destructive":e.destructive,"--widget-destructive-foreground":e["destructive-foreground"],"--widget-border":e.border,"--widget-input":e.input,"--widget-ring":e.ring,"--widget-radius":e.radius,"--widget-border-style":e["border-style"]||"dotted"};return t["--widget-font-sans"]=e["font-sans"]||"inherit",t["--widget-font-mono"]=e["font-mono"]||"inherit",t["--widget-shadow-color"]=e["shadow-color"]||"oklch(0 0 0)",t["--widget-shadow-opacity"]=e["shadow-opacity"]||"0.1",t["--widget-shadow-blur"]=e["shadow-blur"]||"3px",t["--widget-shadow-spread"]=e["shadow-spread"]||"0px",t["--widget-shadow-offset-x"]=e["shadow-offset-x"]||"0",t["--widget-shadow-offset-y"]=e["shadow-offset-y"]||"1px",t["--widget-letter-spacing"]=e["letter-spacing"]||"normal",t["--widget-status-pending"]=e["status-pending"]||"#a1a1aa",t["--widget-status-received"]=e["status-received"]||"#fbbf24",t["--widget-status-completed"]=e["status-completed"]||"#2dd4bf",t["--widget-status-failed"]=e["status-failed"]||"#fb7185",t}import{jsx as bi}from"react/jsx-runtime";var Ct=mi(Ce);function Ye({theme:e,children:t}){return bi(Ct.Provider,{value:e,children:t})}function vi(){return hi(Ct)}import{jsx as te,jsxs as Rt}from"react/jsx-runtime";var xi=[],Si=[],ki=[],It=[],Ci=[],Ti=[],Ii=`
|
|
2
|
+
import{a as Ee}from"./chunk-MVF5PRDZ.js";import{a as Ke,b as Yt,c as Zt,d as Re,e as Jt,f as At,g as Oe,h as Ot,i as ut,j as wt,k as Ne,l as Ie,m as Xe,n as ti,o as ei,p as ii,q as ri,r as ai,s as oi,t as ni,u as We,v as Me}from"./chunk-GF37SKBJ.js";import{a as Pe}from"./chunk-PFQ7GSLH.js";import"./chunk-OPN7WCJR.js";import{a as Ye,b as Ze,c as Je,d as Xt,e as Rt}from"./chunk-FWH744XA.js";import{a as ue,b as vt,c as Ae,d as p}from"./chunk-XCPMBMS7.js";import{B as Dt,H as ke,K as Ce,M as Te,b as we,d as fe,g as me,j as he,k as ve,l as be,m as ye,n as xe,y as Se}from"./chunk-NNNQNB5T.js";import{a as Y}from"./chunk-46H44R7V.js";import"./chunk-73CB2I7U.js";import Li,{useMemo as _e}from"react";import{Suspense as lt,lazy as ht,useCallback as Pt,useEffect as mt,useRef as bt,useState as He}from"react";import{useShallow as Ti}from"zustand/react/shallow";var si=["SUCCEEDED","FAILED","COMPLETED","CANCELLED"];async function te(t,e,r={}){let{onStatusChange:a,onComplete:o,onError:d,interval:g=4e3,timeout:A=3e5,txHash:M,signal:P}=r,l=null,n=Date.now(),C=0,z=8,u=null,R=M?`?txHash=${M}`:"";return new Promise((x,S)=>{let c=async()=>{try{if(P?.aborted){u&&clearTimeout(u),S(new DOMException("Polling aborted","AbortError"));return}if(Date.now()-n>A){u&&clearTimeout(u);let w=new Error("Order status polling timed out");d?.(w),S(w);return}let v=await fetch(`${e}/status/${t}${R}`,{headers:ye(),signal:P});if(v.status===404){u=setTimeout(c,g);return}if(!v.ok)throw new Error(`Failed to fetch order status: ${await v.text()}`);let i=await v.json();if(!i||typeof i!="object"||!i.status)throw new Error(`Invalid status response format: ${JSON.stringify(i)}`);C=0;let s=i.status.toUpperCase();if(s!==l&&(l=s,a?.(i)),si.includes(s)){u&&clearTimeout(u),o?.(i),x(i);return}u=setTimeout(c,g)}catch(v){if(v instanceof Error&&v.name==="AbortError"){u&&clearTimeout(u),S(v);return}if(++C>=z){u&&clearTimeout(u);let i=v instanceof Error?v:new Error(String(v));d?.(i),S(i);return}u=setTimeout(c,g)}};c()})}import{useCallback as qt,useEffect as di,useRef as $t}from"react";function ze(t){let e=t.toUpperCase();return e==="SUCCEEDED"||e==="COMPLETED"?"completed":e==="FAILED"?"failed":e==="CANCELLED"?"cancelled":e==="PROCESSING"?"received":"pending"}var ee=t=>{let e=$t(new Map),r=$t(new Map),a=$t(new Map),o=$t(0),d=qt(()=>++o.current,[]),{address:g}=Y(),A=Yt(),M=qt((n,C)=>{if(e.current.get(n))return;C&&r.current.set(n,C),e.current.set(n,!0);let z=o.current,u=new AbortController;a.current.set(n,u);let R=C?.baseToken?.chainId===1;te(n,ve(),{interval:R?1e3:500,timeout:3e5,signal:u.signal,onStatusChange:x=>{if(!x?.status)return;let S=ze(x.status);if(t?.(n,S,x.explorerUrl),S==="completed"&&g){let c=r.current.get(n);if(c&&(c.baseToken||c.quoteToken)){let v=[];c.baseToken&&v.push({asset:c.baseToken,userAddress:g}),c.quoteToken&&v.push({asset:c.quoteToken,userAddress:g}),A({type:"swap",tokens:v})}}["completed","failed","cancelled"].includes(S)&&(e.current.delete(n),r.current.delete(n)),z!==o.current&&(e.current.delete(n),r.current.delete(n))},onComplete:x=>{x?.status&&t?.(n,ze(x.status),x.explorerUrl),e.current.delete(n),r.current.delete(n)},onError:()=>{e.current.delete(n),r.current.delete(n)}}).catch(x=>{x instanceof Error&&x.name==="AbortError"||(e.current.delete(n),r.current.delete(n),a.current.delete(n))})},[g,A,t]),P=qt(n=>{let C=a.current.get(n);C&&(C.abort(),a.current.delete(n)),d(),e.current.delete(n),r.current.delete(n)},[d]),l=qt(()=>{for(let n of a.current.values())n.abort();a.current.clear(),d(),e.current.clear(),r.current.clear()},[d]);return di(()=>()=>l(),[l]),{startPolling:M,stopPolling:P,stopAllPolling:l,isPolling:n=>e.current.has(n)}};import{useCallback as Be,useRef as pi}from"react";import{createContext as li,useContext as ci}from"react";var gi=li({registerTransaction:()=>{},enabled:!1}),ie=()=>ci(gi);function Le(){let{registerTransaction:t,enabled:e}=ie(),r=pi(new Set),a=Be((d,g)=>{!e||r.current.has(d)||(r.current.add(d),t(d,g))},[e,t]),o=Be((d,g)=>{!e||r.current.has(d)||(r.current.add(d),t(d,g))},[e,t]);return{trackOrderTransaction:a,trackNativeTransaction:o,txTrackingEnabled:e}}import{useCallback as ft,useEffect as Ut,useMemo as ui,useRef as _t,useState as jt}from"react";import{useShallow as wi}from"zustand/react/shallow";import{Fragment as re,jsx as f,jsxs as Z}from"react/jsx-runtime";var fi=new Set([10,8453,42161,534352,59144,324]),mi=4e-4,hi=.003;async function vi(t){let e=fi.has(t)?mi:hi;try{let g=await ke(t).getGasPrice()*350000n*3n/2n,A=Number(g)/1e18;return Math.max(A,e)}catch{return e}}var bi=({onSwapSubmitted:t,onSwapInitiated:e,startPolling:r,trackNativeTransaction:a})=>{let{web3ConnectionType:o,hasConnectHandler:d,lockBase:g,lockQuote:A,disableInverting:M,tokenDisplay:P,tokenBadgeOrientation:l,widgetType:n}=vt(),{effectiveInputTokens:C,effectiveOutputTokens:z}=Pe(),u=C.length===1,R=z.length===1,x=P==="pill"||P==="ghost",S=n==="compact",c=S?"px-4 pt-3 pb-1":"px-4 pt-4 pb-2",v=S?"px-4 pt-4 pb-1":"px-4 pt-6 pb-2",{baseToken:i,quoteToken:s,baseAmount:w,quoteAmount:m,isBaseGasToken:O,isQuoteGasToken:W,isWrappingPair:E,isUnwrappingPair:B,baseBalance:H,quoteBalance:ct,setBaseAmount:D,setQuoteAmount:N,swapTokens:tt,clearForm:G}=Rt(),{rfqQuote:I,status:J,handleInputChange:V,ensureForParams:ot,stop:nt,clear:F,refresh:st}=At(),{address:$}=Y(),{openConnectModal:dt}=Ot(),{isRecipientInputOpen:U,txStatus:gt}=p(wi(T=>({isRecipientInputOpen:T.isRecipientInputOpen,txStatus:T.txStatus}))),[k,K]=jt(null),[_,j]=jt(null),yt=_t(!1),L=!1,xt=k!==null,St=_t("");Ut(()=>{let T=`${i?.address}-${i?.chainId}|${s?.address}-${s?.chainId}`;St.current&&St.current!==T&&(k!==null||I!==null||J==="polling")&&(K(null),j(null),F(),G()),St.current=T},[i?.address,i?.chainId,s?.address,s?.chainId,k,I,J,F,G]);let kt=_t(!1),[Nt,It]=jt(1);Ut(()=>{let T=k==="trackingTx"&&!!_&&!!i&&!!s&&!!w&&!!m;if(kt.current!==T){It(0);let X=setTimeout(()=>It(1),50);return kt.current=T,()=>clearTimeout(X)}},[k,_,i,s,w,m]);let Wt=_t(k),[Mt,Ct]=jt(1);Ut(()=>{if(Wt.current!==k){Ct(0);let T=setTimeout(()=>Ct(1),50);return Wt.current=k,()=>clearTimeout(T)}},[k]);let zt=ui(()=>!i||!s||typeof w!="number"||!m||!$||parseFloat(H.formatted)<w?null:{base:i,quote:s,baseAmount:w,quoteAmount:m,userAddress:$},[i,s,w,m,$,H.formatted]),pe=ft(T=>{j(T),p.getState().startTracking(T)},[]),Bt=ft(()=>{yt.current=!0,st()},[st]);Ut(()=>{if(k===null&&!(!i||!s)){if(!w||w<=0){V({amount:null,inputToken:i,outputToken:s,setOutputAmount:N});return}if(E||B){N(w);return}V({amount:w,inputToken:i,outputToken:s,setOutputAmount:N})}},[k,w,i,s,E,B,V,N]);let it=ft(()=>{p.getState().setView("baseSelection")},[]),Tt=ft(()=>{p.getState().setView("quoteSelection")},[]),Lt=ft(()=>{F(),tt(),D(null),N(null)},[F,tt,D,N]),Vt=ft(async()=>{if(!H.formatted||!i||!s)return;let T=parseFloat(H.formatted);if(!T||T<=0)return;let X;if(O){let pt=await vi(i.chainId);if(X=Math.max(0,T-pt),X<=0)return}else X=T*.9999999999;E||B?(D(X),N(X),F()):(D(X),N(null),ot({inputToken:i,outputToken:s,inputAmount:X.toString(),setOutputAmount:pt=>N(pt)}))},[H.formatted,i,s,O,E,B,D,N,F,ot]),Ft=ft(()=>{F(),G()},[F,G]),Ht=H.formatted?parseFloat(H.formatted):null,Gt=!!(w||m),b=i?.price&&w?`$${(i.price*w).toFixed(2)}`:"$0.00",et=s?.price&&m?`$${(s.price*m).toFixed(2)}`:"$0.00",q=k==="trackingTx"&&!!_&&!!i&&!!s&&!!w&&!!m;return Z("div",{className:"flex flex-col w-full",children:[f("div",{style:{opacity:Nt,transition:"opacity 0.3s ease-out"},children:q&&_&&i&&s&&w&&m?f("div",{className:"overflow-hidden",children:f(Me,{orderHash:_,base:i,quote:s,baseAmount:w,quoteAmount:m,status:gt})}):Z(re,{children:[Z("div",{className:`relative ${c}`,style:{borderBottom:"1px solid var(--widget-border)"},children:[x?S?Z("div",{className:`flex items-center gap-2 mb-2 ${l==="right"?"flex-row-reverse":"flex-row"}`,children:[f(wt,{toggle:it,side:"base",asset:i,isPlacingOrder:L||g||u,hideDropdown:u}),f("div",{className:"flex-1 min-w-0",children:f(ut,{side:"base",asset:i??null,otherAsset:s??null,isPlacingOrder:L,isWrappingPair:E,isUnwrappingPair:B})})]}):Z("div",{className:`flex flex-col ${l==="right"?"items-end":"items-start"}`,children:[f(wt,{toggle:it,side:"base",asset:i,isPlacingOrder:L||g||u,hideDropdown:u}),f(ut,{side:"base",asset:i??null,otherAsset:s??null,isPlacingOrder:L,isWrappingPair:E,isUnwrappingPair:B})]}):Z(re,{children:[f(wt,{toggle:it,side:"base",asset:i,isPlacingOrder:L||g||u,hideDropdown:u}),f(ut,{side:"base",asset:i??null,otherAsset:s??null,isPlacingOrder:L,isWrappingPair:E,isUnwrappingPair:B})]}),Z("div",{className:"mb-1 flex w-full flex-row items-center justify-between",children:[f("p",{className:"font-sans text-sm",style:{color:"var(--widget-muted-foreground)"},children:b}),$&&Ht!==null&&Ht>0&&f("button",{type:"button",onClick:Vt,disabled:L,className:"absolute bottom-3 right-4 flex items-center px-3 py-0.5 text-xs font-medium uppercase cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed transition-colors bg-(--widget-primary) text-(--widget-primary-foreground) hover:bg-(--widget-foreground) hover:text-(--widget-card)",style:{borderRadius:"var(--widget-radius)"},children:"Max"})]})]}),!M&&f("div",{className:"flex justify-center -my-4 relative z-10",children:f("button",{type:"button",onClick:Lt,disabled:xt,"aria-label":"Swap input and output tokens",className:`flex h-8 w-8 items-center justify-center rounded-full transition-colors bg-(--widget-card) ${xt?"cursor-not-allowed opacity-40 pointer-events-none":"cursor-pointer text-(--widget-muted-foreground) hover:bg-(--widget-secondary) hover:text-(--widget-foreground)"}`,style:{border:"1px solid var(--widget-border)"},children:f(Ie,{className:"w-3.5 h-3.5"})})}),Z("div",{className:`relative ${v}`,children:[x?S?Z("div",{className:`flex items-center gap-2 ${l==="right"?"flex-row-reverse":"flex-row"}`,children:[f(wt,{toggle:Tt,side:"quote",asset:s,isPlacingOrder:L||A||R,hideDropdown:R}),f("div",{className:"flex-1 min-w-0",children:f(ut,{side:"quote",asset:s??null,otherAsset:i??null,isPlacingOrder:L,isWrappingPair:E,isUnwrappingPair:B})})]}):Z("div",{className:`flex flex-col ${l==="right"?"items-end":"items-start"}`,children:[f(wt,{toggle:Tt,side:"quote",asset:s,isPlacingOrder:L||A||R,hideDropdown:R}),f(ut,{side:"quote",asset:s??null,otherAsset:i??null,isPlacingOrder:L,isWrappingPair:E,isUnwrappingPair:B})]}):Z(re,{children:[f(wt,{toggle:Tt,side:"quote",asset:s,isPlacingOrder:L||A||R,hideDropdown:R}),f(ut,{side:"quote",asset:s??null,otherAsset:i??null,isPlacingOrder:L,isWrappingPair:E,isUnwrappingPair:B})]}),Z("div",{className:"flex w-full flex-row items-center justify-between",children:[f("p",{className:"font-sans text-sm",style:{color:"var(--widget-muted-foreground)"},children:et}),Gt&&f("button",{type:"button",onClick:Ft,disabled:L,className:"absolute bottom-2 right-4 flex items-center px-3 py-0.5 text-xs font-medium uppercase cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed transition-colors text-(--widget-muted-foreground) hover:bg-(--widget-secondary)",style:{borderRadius:"var(--widget-radius)"},children:"Clear"})]})]}),f("div",{className:"flex flex-row items-center w-full overflow-hidden",style:{borderTop:U?"1px solid var(--widget-border)":"none",maxHeight:U?"60px":"0px",opacity:U?1:0,transition:"max-height 0.3s ease, opacity 0.3s ease"},children:f(Ne,{})}),f("div",{className:"px-4",style:{borderTop:"1px solid var(--widget-border)",borderBottom:"1px solid var(--widget-border)"},children:f(Ee,{})})]})}),f("div",{className:`relative ${q?"px-0 pb-4":"px-4"} ${S?"py-2":"py-4"}`,style:{opacity:Mt,transition:"opacity 0.3s ease-out"},children:$&&i&&s&&w&&w>0?f(We,{base:i,baseAmount:w,quote:s,quoteAmount:m??0,userAddress:$,isWrappingPair:E,isUnwrappingPair:B,isBaseGasToken:O,isQuoteGasToken:W,reviewActionProps:zt,reviewState:k,setReviewState:K,trackedOrderHash:_,setTrackedOrderHash:j,onSwapSubmitted:t,onSwapInitiated:e,onOrderSubmitted:pe,onStaleQuoteRestart:Bt,txStatus:gt,startPolling:r,trackNativeTransaction:a}):!$&&d?f("button",{onClick:()=>dt(),className:`w-full ${S?"py-2":"py-3"} text-sm font-sans font-medium cursor-pointer transition-opacity hover:opacity-80`,style:{backgroundColor:"var(--widget-primary)",color:"var(--widget-primary-foreground)",borderRadius:"var(--widget-radius)"},children:"Connect Wallet"}):f("button",{disabled:!0,className:`w-full ${S?"py-2":"py-3"} text-sm font-sans font-medium transition-colors disabled:opacity-40 cursor-not-allowed`,style:{backgroundColor:"var(--widget-primary)",color:"var(--widget-primary-foreground)",borderRadius:"var(--widget-radius)"},children:$?"Enter Amount":"Connect Wallet"})})]})},Ve=bi;import{jsx as Q,jsxs as ae}from"react/jsx-runtime";var Fe=()=>ae("div",{className:"flex flex-col w-full",children:[ae("div",{className:"relative px-4 pt-4 pb-2",style:{borderBottom:"1px solid var(--widget-border)"},children:[Q("div",{className:"h-12 w-full animate-pulse",style:{backgroundColor:"var(--widget-secondary)",borderRadius:"0.25rem"}}),Q("div",{className:"mt-2 h-20 w-2/3 animate-pulse",style:{backgroundColor:"var(--widget-secondary)",opacity:.5,borderRadius:"0.25rem"}}),Q("div",{className:"mt-1 mb-1 flex w-full items-center justify-between",children:Q("div",{className:"h-4 w-12 animate-pulse",style:{backgroundColor:"var(--widget-secondary)",opacity:.4,borderRadius:"0.25rem"}})})]}),Q("div",{className:"flex justify-center -my-4 relative z-10",children:Q("div",{className:"h-8 w-8",style:{border:"1px solid var(--widget-border)",backgroundColor:"var(--widget-card)",borderRadius:"9999px"}})}),ae("div",{className:"relative px-4 pt-6 pb-2",children:[Q("div",{className:"h-12 w-full animate-pulse",style:{backgroundColor:"var(--widget-secondary)",borderRadius:"0.25rem"}}),Q("div",{className:"mt-2 h-20 w-2/3 animate-pulse",style:{backgroundColor:"var(--widget-secondary)",opacity:.5,borderRadius:"0.25rem"}}),Q("div",{className:"mt-1 mb-1 flex w-full items-center justify-between",children:Q("div",{className:"h-4 w-12 animate-pulse",style:{backgroundColor:"var(--widget-secondary)",opacity:.4,borderRadius:"0.25rem"}})})]}),Q("div",{className:"px-4",style:{height:"28px",borderTop:"1px solid var(--widget-border)",borderBottom:"1px solid var(--widget-border)"}}),Q("div",{className:"relative px-4 py-4",children:Q("div",{className:"w-full animate-pulse",style:{height:"44px",backgroundColor:"var(--widget-secondary)",borderRadius:"var(--widget-radius)",opacity:.6}})})]});import{useEffect as yi,useState as oe}from"react";import{useShallow as xi}from"zustand/react/shallow";import{Fragment as Ci,jsx as y,jsxs as rt}from"react/jsx-runtime";var Si=({targetText:t,isError:e})=>{let{displayText:r,suffix:a,characterColors:o}=Se(t,e);return rt(Ci,{children:[r.split("").map((d,g)=>y("span",{style:o[g]?{color:"var(--widget-destructive)"}:void 0,children:d},g)),y("span",{style:{color:e?"var(--widget-destructive)":"var(--widget-muted-foreground)",opacity:e?.5:1},children:a})]})},ki=({headerText:t,onBackClick:e,isSameChain:r,isWrappingPair:a,isUnwrappingPair:o,hasLowLiquidity:d,hasInsufficientLiquidity:g,hasRoutingError:A,hasSizeCapError:M,hasInsufficientBalance:P})=>{let l=p(I=>I.view),{isRecipientInputOpen:n,hasAllowanceError:C,hoveredChainName:z,isTrackingTx:u,txStatus:R,walletTab:x}=p(xi(I=>({isRecipientInputOpen:I.isRecipientInputOpen,hasAllowanceError:I.hasAllowanceError,hoveredChainName:I.hoveredChainName,isTrackingTx:I.isTrackingTx,txStatus:I.txStatus,walletTab:I.walletTab}))),{swapHeaderVariant:S,walletButtonEnabled:c}=vt(),{isConnected:v}=Y(),[i,s]=oe(!1);yi(()=>s(!0),[]);let[w,m]=oe(!1),[O,W]=oe(!1),E=`${l}-${w}-${O}-${n}-${z||"none"}`,H=(()=>{if(u&&R)switch(R){case"pending":return"Trade Pending";case"received":return"Trade Received";case"completed":return"Trade Filled";case"failed":return"Trade Failed";case"cancelled":return"Trade Cancelled";default:return"Processing Trade"}if(z&&(l==="baseSelection"||l==="quoteSelection"||l==="baseChainSelection"||l==="quoteChainSelection"))return z;if(l==="swap"&&O)return"View Transaction History";if(l==="swap"&&w)return n?"Remove Custom Recipient":"Add Custom Recipient";switch(l){case"wallet":return"Wallet";case"activity":return"Activity";case"baseSelection":return"Select Source Token";case"quoteSelection":return"Select Destination Token";case"baseChainSelection":return"Select Source Chain";case"quoteChainSelection":return"Select Destination Chain";default:if(l==="swap"){if(C&&!a&&!o)return"Allowance check failed";if(M&&!a&&!o)return"Size limit exceeded";if(g&&!a&&!o)return"Insufficient Liquidity";if(A&&!a&&!o)return"Route Not Found";if(d&&!a&&!o)return"High Price Impact";if(P&&!a&&!o)return"Insufficient Balance"}return r&&!a&&!o?"Swap":a?"Wrap":o?"Unwrap":t}})(),ct=!u&&l==="swap"&&!w&&(C&&!a&&!o||M&&!a&&!o||g&&!a&&!o||A&&!a&&!o||d&&!a&&!o||P&&!a&&!o),D={pending:"var(--widget-primary)",received:"var(--widget-primary)",completed:"var(--widget-status-completed)",failed:"var(--widget-status-failed)",cancelled:"var(--widget-status-failed)"},N=()=>!u||!R?null:D[R]??null,tt=()=>u?y("button",{onClick:()=>p.getState().exitHandler?.(),"aria-label":"Close trade status",className:"size-4 -translate-y-0.5 flex cursor-pointer items-center justify-center transition-colors text-(--widget-muted-foreground) opacity-60 hover:text-(--widget-foreground) hover:opacity-100",children:rt("svg",{className:"size-3.5",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[y("path",{d:"M18 6L6 18",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),y("path",{d:"M6 6L18 18",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}):l==="swap"?rt("div",{className:"flex items-center gap-2",children:[c&&i&&v&&y("button",{onClick:()=>p.getState().setView("activity"),onMouseEnter:()=>W(!0),onMouseLeave:()=>W(!1),"aria-label":"Open activity",className:"size-4 -translate-y-0.5 flex cursor-pointer items-center justify-center rounded-full transition-colors text-(--widget-muted-foreground) opacity-60 hover:text-(--widget-foreground) hover:opacity-100",children:rt("svg",{className:"size-3.5",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[y("path",{d:"M12 8V12L14.5 14.5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),y("path",{d:"M3.05 11A9 9 0 1 1 3.05 13",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}),y("path",{d:"M1 7.5L3.05 11L6.5 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}),y("button",{onClick:()=>p.getState().toggleRecipientInput(),onMouseEnter:()=>m(!0),onMouseLeave:()=>m(!1),"aria-label":n?"Remove custom recipient":"Add custom recipient",className:`size-4 -translate-y-0.5 flex cursor-pointer items-center justify-center rounded-full transition-colors hover:text-(--widget-foreground) hover:opacity-100 ${n?"text-(--widget-destructive) opacity-80":"text-(--widget-muted-foreground) opacity-60"}`,children:rt("svg",{className:"size-3.5",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[y("path",{d:"M2 7.75C1.58579 7.75 1.25 8.08579 1.25 8.5C1.25 8.91421 1.58579 9.25 2 9.25V7.75ZM2 8.5V9.25H13.5V8.5V7.75H2V8.5Z",fill:"currentColor"}),y("path",{d:"M6 16.5H8",stroke:"currentColor",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"butt",strokeLinejoin:"miter"}),y("path",{d:"M10.5 16.5H14.5",stroke:"currentColor",strokeWidth:"1.5",strokeMiterlimit:"10",strokeLinecap:"butt",strokeLinejoin:"miter"}),y("path",{d:"M22 12.03V16.11C22 20.5 22 20.5 17.56 20.5H6.44C2 20.5 2 20.5 2 16.11V7.89C2 3.5 2 3.5 6.44 3.5H13.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"miter"}),rt("g",{style:{transform:`rotate(${n?"45deg":"0deg"})`,transformOrigin:"18.75px 6.75px",transition:"transform 150ms ease-out"},children:[y("path",{d:"M15 6.75H22.5",stroke:"currentColor",strokeWidth:"1.5"}),y("path",{d:"M18.75 10.5V3",stroke:"currentColor",strokeWidth:"1.5"})]})]})})]}):rt("button",{onClick:()=>e?e():p.getState().setView("swap"),className:"flex cursor-pointer items-center justify-center whitespace-nowrap h-6 transition-colors text-(--widget-muted-foreground) opacity-70 hover:text-(--widget-foreground) hover:opacity-100",children:[y("span",{className:"pr-1",children:"\u2190"}),y("span",{className:"text-sm",children:"Back"})]}),G=N();return S==="none"?null:rt("div",{className:"w-full pt-3 px-2 font-sans text-base flex flex-row justify-between h-6 shrink-0",children:[l==="wallet"?rt("div",{className:"flex items-center gap-1 font-sans uppercase -translate-y-0.5 text-xs",children:[y("button",{type:"button",onClick:()=>p.getState().setWalletTab("wallet"),className:"cursor-pointer transition-colors",style:{color:x==="wallet"?"var(--widget-foreground)":"var(--widget-muted-foreground)"},children:y("span",{children:"Wallet"})}),y("button",{type:"button",onClick:()=>p.getState().setWalletTab("activity"),className:"cursor-pointer transition-colors",style:{color:x==="activity"?"var(--widget-foreground)":"var(--widget-muted-foreground)"},children:"Activity"})]}):y("div",{className:"font-sans uppercase -translate-y-0.5 text-xs flex items-center",children:y("span",{className:"relative",style:{color:G||"var(--widget-foreground)"},children:y(Si,{targetText:H,isError:ct??!1})},E)}),y("div",{className:"flex flex-row items-center",children:tt()})]})},ne=ki;import{Fragment as Ii,jsx as h,jsxs as Qt}from"react/jsx-runtime";var De=ht(()=>import("./AssetSelectionMenu-F2JUPXHM.js")),qe=ht(()=>import("./ChainSelectionMenu-BGZDH2WA.js")),Ai=ht(()=>import("./SwapFormHorizontal-MEYPUSEU.js")),Ri=ht(()=>import("./SwapFormSplit-7VZ7IIJR.js")),Oi=ht(()=>import("./WidgetWalletPanel-7L7E7IA5.js").then(t=>({default:t.WidgetWalletPanel}))),Pi=ht(()=>import("./WalletPlaceholderPanel-Z4JCFCNV.js").then(t=>({default:t.WalletPlaceholderPanel}))),Ei=ht(()=>import("./WidgetWalletTradeHistory-ES3FEDM7.js").then(t=>({default:t.WidgetWalletTradeHistory}))),Ni=({onSwapSubmitted:t,onSwapComplete:e,cardStyles:r,cardWidth:a})=>{let{baseToken:o,quoteToken:d,baseAmount:g,quoteAmount:A,baseBalance:M,isWrappingPair:P,isUnwrappingPair:l,isRegistryLoading:n}=Rt(),{liquidityError:C,routingError:z,sizeCapError:u,stop:R,clear:x}=At(),S=!!(g&&M.formatted&&parseFloat(M.formatted)<g),c=p(b=>b.view),{isTransitioning:v,isRecipientInputOpen:i,recipient:s,selectedChainFilterChainId:w}=p(Ti(b=>({isTransitioning:b.isTransitioning,isRecipientInputOpen:b.isRecipientInputOpen,recipient:b.recipient,selectedChainFilterChainId:b.selectedChainFilter?.chainId??null}))),m=bt(null),O=bt(null),[W,E]=He(null),{address:B}=Y(),H=Ae();Ce(B,H),Zt();let{trackOrderTransaction:ct,trackNativeTransaction:D}=Le(),N=bt(o),tt=bt(d),G=bt(e);mt(()=>{N.current=o},[o]),mt(()=>{tt.current=d},[d]),mt(()=>{G.current=e},[e]);let{startPolling:I}=ee((b,et,q)=>{if(p.getState().setTxStatus(et),q&&p.getState().setExplorerUrl(q),et==="completed"){let T=N.current,X=tt.current;if(ct(b,`Swap ${T?.symbol??"?"} \u2192 ${X?.symbol??"?"}`),q){let pt=Re(q);pt&&fetch(`https://api.aori.io/data/details/${pt}`).then(Kt=>Kt.json()).then(Kt=>G.current?.({quoteId:b,aoriOrderHash:pt,explorerUrl:q,details:Kt})).catch(()=>{})}}});mt(()=>()=>{m.current&&clearTimeout(m.current),O.current&&clearTimeout(O.current)},[]),mt(()=>{p.getState().resetUI()},[]),mt(()=>{if(v)return m.current=setTimeout(()=>{p.getState().setIsTransitioning(!1),m.current=null},20),()=>{m.current&&(clearTimeout(m.current),m.current=null)}},[v]);let J=Pt((b,et="navigation")=>{O.current&&(clearTimeout(O.current),O.current=null,E(null)),p.getState().view!=="swap"&&b!=="swap"?(p.getState().setView(b),p.getState().setIsTransitioning(!1)):p.getState().transitionToView(b,et)},[]),V=Pt(()=>{m.current&&(clearTimeout(m.current),m.current=null),O.current&&(clearTimeout(O.current),O.current=null);let b=p.getState().view;E(b),p.getState().setChainFilter(null),p.getState().setView("swap"),p.getState().setIsTransitioning(!1),p.getState().resetAssetSelection(),O.current=setTimeout(()=>{E(null),O.current=null},200)},[]),ot=Pt(b=>{let q=c==="baseChainSelection"?"base":"quote";p.getState().setChainFilter({chainId:b,side:q}),p.getState().pushRecentChain(b),J(q==="base"?"baseSelection":"quoteSelection","chainSelection")},[c,J]),nt=Pt(()=>{let b=p.getState().view;b==="baseSelection"?J("baseChainSelection","chainSelection"):b==="quoteSelection"&&J("quoteChainSelection","chainSelection")},[J]),F=Pt(()=>{R(),x()},[R,x]),st=o&&d?o.chainId===d.chainId:!0,$=()=>{switch(c){case"wallet":return"Wallet";case"baseSelection":return"Select Input Token";case"quoteSelection":return"Select Output Token";case"baseChainSelection":case"quoteChainSelection":return"Select Chain";default:return"Swap"}},{assetMenuVariant:dt,widgetType:U,customWalletUI:gt}=vt(),k=c==="baseSelection"||c==="quoteSelection",K=c==="baseChainSelection"||c==="quoteChainSelection",_=dt==="split"&&(U==="default"||U==="compact"),j=dt==="split"&&(U==="horizontal"||U==="split"),yt=dt==="default",L=c==="swap"||k||K||c==="wallet"||c==="activity",xt=W==="baseSelection"||W==="quoteSelection",St=W==="baseChainSelection"||W==="quoteChainSelection",kt=k||xt,Nt=K||St,It=k&&!v,Wt=K&&!v,Mt=k?c:W,Ct=Mt==="baseSelection"?"base":"quote",zt=Mt==="baseSelection"?d:o,Bt=(K?c:W)==="baseChainSelection"?"base":"quote",it=b=>({backgroundColor:"var(--widget-background)",opacity:b?1:0,transform:b?"translateY(0)":"translateY(6px)",transition:"opacity 200ms ease-in-out, transform 200ms ease-in-out"}),Tt=yt&&(k||K||c==="wallet"||c==="activity"||W!=null),Lt=n?h(Fe,{}):U==="horizontal"?h(lt,{fallback:null,children:h(Ai,{onSwapSubmitted:t,onSwapInitiated:F,onBackToSwap:j?V:void 0,onMoreChainsClick:j?nt:void 0,startPolling:I,trackNativeTransaction:D})}):U==="split"?h(lt,{fallback:null,children:h(Ri,{onSwapSubmitted:t,onSwapInitiated:F,onBackToSwap:j?V:void 0,onMoreChainsClick:j?nt:void 0,startPolling:I,trackNativeTransaction:D})}):h(Ve,{onSwapSubmitted:t,onSwapInitiated:F,startPolling:I,trackNativeTransaction:D}),Vt=r??{},Ft=bt(null),[Ht,Gt]=He(420);return mt(()=>{if(!_)return;let b=Ft.current;if(!b)return;let et=new ResizeObserver(q=>{for(let T of q)Gt(T.contentRect.height)});return et.observe(b),()=>et.disconnect()},[_]),_?Qt(Ii,{children:[Qt("div",{ref:Ft,className:"flex flex-col w-full overflow-hidden transition-colors duration-300",style:{flex:"1 1 0",minWidth:0,...Vt},children:[h(ne,{headerText:"Swap",onBackClick:V,isSameChain:st,isWrappingPair:P,isUnwrappingPair:l,hasLowLiquidity:C,hasInsufficientLiquidity:C,hasRoutingError:z,hasSizeCapError:u,hasInsufficientBalance:S}),h("div",{className:"overflow-hidden",children:Lt})]}),(kt||Nt)&&h("div",{className:"flex flex-col overflow-hidden shrink-0",style:{width:a,height:`${Ht}px`,...Vt,...it((k||K)&&!v)},children:k||xt?h(lt,{fallback:null,children:h(De,{toggle:V,side:Ct,otherAsset:zt,onMoreChainsClick:nt,selectedChainFilter:w})}):h(lt,{fallback:null,children:h(qe,{toggle:V,side:Bt,onChainSelect:ot})})})]}):Qt("div",{className:"flex flex-col w-full",style:{overflow:"hidden",position:"relative"},children:[h(ne,{headerText:$(),onBackClick:V,isSameChain:st,isWrappingPair:P,isUnwrappingPair:l,hasLowLiquidity:C,hasInsufficientLiquidity:C,hasRoutingError:z,hasSizeCapError:u,hasInsufficientBalance:S}),Qt("div",{className:"relative overflow-hidden",children:[L&&h("div",{className:"overflow-hidden",style:Tt?{pointerEvents:"none"}:void 0,children:Lt}),(c==="wallet"||W==="wallet")&&h("div",{className:"absolute inset-0 overflow-hidden z-20",style:it(c==="wallet"&&!v),children:h(lt,{fallback:null,children:gt==="none"?h(Pi,{}):h(Oi,{})})}),(c==="activity"||W==="activity")&&h("div",{className:"absolute inset-0 overflow-y-auto z-20",style:it(c==="activity"&&!v),children:h(lt,{fallback:null,children:h(Ei,{isActive:c==="activity"})})}),yt&&kt&&h("div",{className:"absolute inset-0 overflow-hidden z-20",style:it(It),children:h(lt,{fallback:null,children:h(De,{toggle:V,side:Ct,otherAsset:zt,onMoreChainsClick:nt,selectedChainFilter:w})})}),yt&&Nt&&h("div",{className:"absolute inset-0 overflow-hidden z-20",style:it(Wt),children:h(lt,{fallback:null,children:h(qe,{toggle:V,side:Bt,onChainSelect:ot})})})]})]})},$e=({onSwapSubmitted:t,onSwapComplete:e,defaultBaseToken:r,defaultQuoteToken:a,onBaseTokenChange:o,onQuoteTokenChange:d,cardStyles:g,cardWidth:A})=>{let{address:M}=Y(),P=p(l=>l.recipient);return h(Xt,{defaultBaseToken:r,defaultQuoteToken:a,onBaseTokenChange:o,onQuoteTokenChange:d,children:h(Jt,{recipient:P,children:h(Ni,{onSwapSubmitted:t,onSwapComplete:e,cardStyles:g,cardWidth:A})})})};import{createContext as Wi,useContext as Mi}from"react";var se={background:"#ffffff",foreground:"#0a0a0a",card:"#ffffff","card-foreground":"#0a0a0a",popover:"#ffffff","popover-foreground":"#0a0a0a",primary:"#171717","primary-foreground":"#fafafa",secondary:"#f5f5f5","secondary-foreground":"#171717",muted:"#f5f5f5","muted-foreground":"#737373",accent:"#f5f5f5","accent-foreground":"#171717",destructive:"#e7000b","destructive-foreground":"#ffffff",border:"#e5e5e5",input:"#e5e5e5",ring:"#a1a1a1",radius:"0.625rem","border-style":"dotted","status-pending":"#a1a1aa","status-received":"#f59e0b","status-completed":"#10b981","status-failed":"#ef4444"},Et={background:"#0a0a0a",foreground:"#fafafa",card:"#171717","card-foreground":"#fafafa",popover:"#262626","popover-foreground":"#fafafa",primary:"#e5e5e5","primary-foreground":"#171717",secondary:"#262626","secondary-foreground":"#fafafa",muted:"#262626","muted-foreground":"#a1a1a1",accent:"#404040","accent-foreground":"#fafafa",destructive:"#ff6467","destructive-foreground":"#fafafa",border:"#282828",input:"#343434",ring:"#737373",radius:"0.625rem","border-style":"dotted","status-pending":"#a1a1aa","status-received":"#fbbf24","status-completed":"#2dd4bf","status-failed":"#fb7185"};function de(t){let e={"--widget-background":t.background,"--widget-foreground":t.foreground,"--widget-card":t.card,"--widget-card-foreground":t["card-foreground"],"--widget-popover":t.popover,"--widget-popover-foreground":t["popover-foreground"],"--widget-primary":t.primary,"--widget-primary-foreground":t["primary-foreground"],"--widget-secondary":t.secondary,"--widget-secondary-foreground":t["secondary-foreground"],"--widget-muted":t.muted,"--widget-muted-foreground":t["muted-foreground"],"--widget-accent":t.accent,"--widget-accent-foreground":t["accent-foreground"],"--widget-destructive":t.destructive,"--widget-destructive-foreground":t["destructive-foreground"],"--widget-border":t.border,"--widget-input":t.input,"--widget-ring":t.ring,"--widget-radius":t.radius,"--widget-border-style":t["border-style"]||"dotted"};return e["--widget-font-sans"]=t["font-sans"]||"inherit",e["--widget-font-mono"]=t["font-mono"]||"inherit",e["--widget-shadow-color"]=t["shadow-color"]||"oklch(0 0 0)",e["--widget-shadow-opacity"]=t["shadow-opacity"]||"0.1",e["--widget-shadow-blur"]=t["shadow-blur"]||"3px",e["--widget-shadow-spread"]=t["shadow-spread"]||"0px",e["--widget-shadow-offset-x"]=t["shadow-offset-x"]||"0",e["--widget-shadow-offset-y"]=t["shadow-offset-y"]||"1px",e["--widget-letter-spacing"]=t["letter-spacing"]||"normal",e["--widget-status-pending"]=t["status-pending"]||"#a1a1aa",e["--widget-status-received"]=t["status-received"]||"#fbbf24",e["--widget-status-completed"]=t["status-completed"]||"#2dd4bf",e["--widget-status-failed"]=t["status-failed"]||"#fb7185",e}import{jsx as Bi}from"react/jsx-runtime";var Ue=Wi(Et);function le({theme:t,children:e}){return Bi(Ue.Provider,{value:t,children:e})}function zi(){return Mi(Ue)}import{jsx as at,jsxs as Qe}from"react/jsx-runtime";var Vi=[],Fi=[],Hi=[],je=[],Di=[],qi=[],$i=`
|
|
3
3
|
.aori-widget .text-2xs { font-size: 0.75rem; }
|
|
4
4
|
.aori-widget .text-3xs { font-size: 0.68rem; }
|
|
5
5
|
.aori-widget ::-webkit-scrollbar { width: 0px; height: 0px; display: none; }
|
|
@@ -7,4 +7,4 @@ import{a as wt}from"./chunk-VO6ZLNGC.js";import{a as zt,b as Mt,c as He,d as Ve,
|
|
|
7
7
|
.aori-widget input:focus, .aori-widget input:focus-visible,
|
|
8
8
|
.aori-widget button:focus, .aori-widget button:focus-visible,
|
|
9
9
|
.aori-widget select:focus, .aori-widget select:focus-visible { outline: none; }
|
|
10
|
-
`,
|
|
10
|
+
`,ce=class extends Li.Component{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?Qe("div",{style:{padding:"1.5rem",textAlign:"center",color:"var(--widget-foreground, #888)",fontFamily:"system-ui, sans-serif"},children:[at("p",{style:{margin:"0 0 0.75rem",fontSize:"0.875rem"},children:"Something went wrong."}),at("button",{type:"button",onClick:()=>this.setState({hasError:!1}),style:{padding:"0.375rem 1rem",fontSize:"0.8125rem",cursor:"pointer",border:"1px solid currentColor",borderRadius:"0.25rem",background:"transparent",color:"inherit"},children:"Retry"})]}):this.props.children}};function Ui(t){let e=t.theme.mode==="light"?se:Et,r=t.theme.mode==="light"?t.theme.light:t.theme.dark;return r?{...e,...r}:e}function _i({config:t,className:e,onSwapSubmitted:r,onSwapComplete:a,onBaseTokenChange:o,onQuoteTokenChange:d,onRequestConnect:g,onRequestAccount:A,customWalletUI:M="builtin"}){be(t.apiKey),xe(t.rpcOverrides),he(t.vtApiBaseUrl);let P=Ui(t),l=t.appearance?.widgetType??"default",n=t.appearance?.tokenDisplay??"default",C=t.appearance?.tokenBadgeOrientation??"left",z=t.appearance?.assetMenuVariant??"default",u=t.appearance?.amountInputVariant??"default",R=t.appearance?.hideAmountInputSymbol??!1,x=t.appearance?.swapButtonVariant??"default",S=t.appearance?.swapHeaderVariant??"default",c=t.appearance?.quoteLoaderVariant??"default",v=t.appearance?.walletButtonEnabled??!0,i=t.appearance?.fillContainer??!1,s=t.appearance?.hideBorder??!1,w=de(P),m=z==="split"&&(l==="default"||l==="compact"),O=p(j=>j.view==="baseSelection"||j.view==="quoteSelection"||j.view==="baseChainSelection"||j.view==="quoteChainSelection"),W=l==="compact"?"22rem":"24rem",B=m?{maxWidth:O?l==="compact"?"46rem":"49rem":W,transition:"max-width 0.3s ease",height:"auto",overflow:"visible",display:"flex",gap:"1rem",alignItems:"stretch",backgroundColor:"transparent",border:"none",borderRadius:0,boxShadow:"none",padding:0}:{width:"100%",...i?{}:{maxWidth:l==="split"||l==="horizontal"?"48rem":l==="compact"?"22rem":"24rem"},height:"auto",overflow:"hidden"},H={boxSizing:"border-box",backgroundColor:"var(--widget-background)",color:"var(--widget-foreground)",borderRadius:"var(--widget-radius)",...s?{border:"none"}:{borderWidth:"1px",borderStyle:"var(--widget-border-style)",borderColor:"var(--widget-border)"},boxShadow:"var(--widget-shadow-offset-x) var(--widget-shadow-offset-y) var(--widget-shadow-blur) var(--widget-shadow-spread) color-mix(in srgb, var(--widget-shadow-color) calc(var(--widget-shadow-opacity) * 100%), transparent)",padding:"0.25rem 0.5rem",paddingTop:"0.25rem"},ct=t.tokens?.enabledChains??Vi,D=t.tokens?.supportedInputTokens??Fi,N=t.tokens?.supportedOutputTokens??Hi,tt=t.tokens?.supportedInputChains??je,G=t.tokens?.supportedOutputChains??je,I=t.tokens?.prioritizedInputTokens??Di,J=t.tokens?.prioritizedInputChains??qi,V=t.tokens?.inputSelectionSearch??!0,ot=t.tokens?.outputSelectionSearch??!0,nt=t.tokens?.showInputSelectionTokenBalances??!0,F=t.tokens?.showOutputSelectionTokenBalances??!0,st=t.tokens?.lockBase??!1,$=t.tokens?.lockQuote??!1,dt=t.tokens?.disableInverting??!1,U=t.settings?.defaultSlippage??.01,gt=!!g,k=_e(()=>({apiKey:t.apiKey,web3ConnectionType:"custom",enabledChains:ct,supportedInputTokens:D,supportedOutputTokens:N,supportedInputChains:tt,supportedOutputChains:G,prioritizedInputTokens:I,prioritizedInputChains:J,inputSelectionSearch:V,outputSelectionSearch:ot,showInputSelectionTokenBalances:nt,showOutputSelectionTokenBalances:F,lockBase:st,lockQuote:$,disableInverting:dt,defaultSlippage:U,widgetType:l,tokenDisplay:n,tokenBadgeOrientation:C,assetMenuVariant:z,amountInputVariant:u,hideAmountInputSymbol:R,swapButtonVariant:x,swapHeaderVariant:S,quoteLoaderVariant:c,walletButtonEnabled:v,hasConnectHandler:gt,customWalletUI:M}),[t.apiKey,ct,D,N,tt,G,I,J,V,ot,nt,F,st,$,dt,U,l,n,C,z,u,R,x,S,c,v,gt,M]),K=_e(()=>g?{openConnectModal:g,openAccountModal:A}:null,[g,A]),_=at(Te,{children:at(ue.Provider,{value:k,children:at(le,{theme:P,children:Qe("div",{className:`aori-widget${e?` ${e}`:""}`,style:{...w,"--font-sans":"var(--widget-font-sans)","--font-mono":"var(--widget-font-mono)",fontFamily:"var(--widget-font-sans)",letterSpacing:"var(--widget-letter-spacing)",width:"100%",...B,position:"relative",...m?{}:H},children:[at("style",{dangerouslySetInnerHTML:{__html:$i}}),at(ce,{children:at($e,{onSwapSubmitted:r,onSwapComplete:a,defaultBaseToken:t.tokens?.defaultBase,defaultQuoteToken:t.tokens?.defaultQuote,onBaseTokenChange:o,onQuoteTokenChange:d,cardStyles:m?H:void 0,cardWidth:m?W:void 0})})]})})})});return K?at(Oe.Provider,{value:K,children:_}):_}import{jsx as Qi}from"react/jsx-runtime";function ji(){let{openConnectModal:t}=Ot(),{isConnected:e,address:r}=Y(),a=e&&r?`${r.slice(0,6)}...${r.slice(-4)}`:"Connect";return Qi("button",{type:"button",onClick:()=>t(),className:"h-8 cursor-pointer px-3 text-xs font-bold uppercase tracking-wide transition-colors duration-150 border border-border rounded-sm bg-card text-foreground hover:bg-secondary hover:border-foreground/20",children:a})}import{http as Ge,fallback as Gi}from"wagmi";function Ki(t){let e=Object.entries(we);return Object.fromEntries(e.map(([r,a])=>{let o=t?.[Number(r)],d=o?Array.isArray(o)?o:[o]:[],g=d.length>0?[...d,...a.rpcUrls]:a.rpcUrls;return[r,g.length>1?Gi(g.map(A=>Ge(A,{batch:{batchSize:50,wait:50}}))):Ge(g[0],{batch:{batchSize:50,wait:50}})]}))}var Yi=fe().map(t=>t.wagmiChain);import{useMemo as ge}from"react";var Zi=t=>{let{tokenRegistry:e,isLoadingRegistry:r,error:a}=Dt();return{tokens:ge(()=>e.filter(d=>d.chainId===t),[e,t]),isLoading:r,error:a}},Ji=(t,e)=>{let{tokenRegistry:r}=Dt();return ge(()=>!t||!r.length?!1:r.some(a=>a.address.toLowerCase()===t.toLowerCase()&&a.chainId===e),[r,t,e])},Xi=(t,e)=>{let{getToken:r}=Dt();return ge(()=>{if(!(!t||!e))return r(e,t)},[r,t,e])},Ma=me();export{Xe as ChainSwitch,ji as ConnectButton,Jt as RfqProvider,ti as SignSwap,Xt as SwapFormProvider,_i as SwapWidget,le as WidgetThemeProvider,Ki as buildTransports,ii as canSubmitOrder,ai as cleanupOldSubmissions,Et as defaultDarkTheme,se as defaultLightTheme,ei as isQuoteFresh,ri as markOrderAsSubmitted,te as pollOrderStatus,de as themeToCSS,Ke as useBalanceEventListener,Zt as useBalanceEventSubscription,Yt as useEmitBalanceEvent,Ji as useIsTokenSupported,ee as useOrderStatusPolling,At as useRfq,Je as useSwapForm,Rt as useSwapFormContext,Xi as useTokenByAddress,Ze as useTokenSelection,Ye as useTokenSelectionStore,Zi as useTokensForChain,ie as useTransactionRegistry,oi as useUnwrapToken,Ot as useWalletModal,Y as useWalletState,p as useWidgetSwapUIStore,zi as useWidgetTheme,ni as useWrapToken,Yi as wagmiChains};
|
package/package.json
CHANGED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
"use client";import{a as le}from"./chunk-VO6ZLNGC.js";import{e as se,g as re,h as f,i as w,j as de,k as ue,x as ce,y as pe}from"./chunk-LHEXDAQ2.js";import{a as Q}from"./chunk-MJMI6IZW.js";import{a as H}from"./chunk-W63DXT5E.js";import{a as ae}from"./chunk-PFQ7GSLH.js";import"./chunk-OPN7WCJR.js";import{e as ne}from"./chunk-FWH744XA.js";import{b as oe,d}from"./chunk-XCPMBMS7.js";import"./chunk-NNNQNB5T.js";import{a as ie}from"./chunk-46H44R7V.js";import"./chunk-73CB2I7U.js";import{useCallback as p,useEffect as He,useMemo as Ue,useRef as De,useState as me}from"react";import{useShallow as Ve}from"zustand/react/shallow";import{Fragment as N,jsx as e,jsxs as r}from"react/jsx-runtime";var q=()=>{},je=({onSwapSubmitted:ge,onSwapComplete:fe,onSwapInitiated:we,onBackToSwap:y,onMoreChainsClick:Ee})=>{let{web3ConnectionType:Ge,hasConnectHandler:he,lockBase:T,lockQuote:I,disableInverting:ve,swapButtonVariant:R,tokenDisplay:U,tokenBadgeOrientation:k,widgetType:be,assetMenuVariant:Se}=oe(),{effectiveInputTokens:xe,effectiveOutputTokens:Ce}=ae(),h=xe.length===1,v=Ce.length===1,D=U==="pill"||U==="ghost",F=be==="compact",{baseToken:t,quoteToken:o,baseAmount:i,quoteAmount:u,isBaseGasToken:ye,isQuoteGasToken:ke,isWrappingPair:a,isUnwrappingPair:l,baseBalance:g,quoteBalance:ze,setBaseAmount:x,setQuoteAmount:c,swapTokens:V,clearForm:j}=ne(),{rfqQuote:Le,status:_e,handleInputChange:M,ensureForParams:E,stop:Je,clear:b,refresh:G}=se(),{address:m}=ie(),{openConnectModal:Ae}=re(),{isRecipientInputOpen:W,txStatus:z,view:S,selectedChainFilterChainId:L}=d(Ve(n=>({isRecipientInputOpen:n.isRecipientInputOpen,txStatus:n.txStatus,view:n.view,selectedChainFilterChainId:n.selectedChainFilter?.chainId??null}))),[A,Pe]=me(null),[P,_]=me(null),Oe=De(!1),s=!1,qe=Ue(()=>!t||!o||typeof i!="number"||!u||!m||parseFloat(g.formatted)<i?null:{base:t,quote:o,baseAmount:i,quoteAmount:u,userAddress:m},[t,o,i,u,m,g.formatted]),Ne=p(n=>{_(n),d.getState().startTracking(n)},[]),Te=p(()=>{Oe.current=!0,G()},[G]);He(()=>{if(A===null&&!(!t||!o)){if(!i||i<=0){M({amount:null,inputToken:t,outputToken:o,setOutputAmount:c});return}if(a||l){c(i);return}M({amount:i,inputToken:t,outputToken:o,setOutputAmount:c})}},[A,i,t,o,a,l,M,c]);let B=p(()=>{d.getState().setView("baseSelection")},[]),$=p(()=>{d.getState().setView("quoteSelection")},[]),Ie=p(()=>{b(),V(),x(null),c(null)},[b,V,x,c]),Re=p(()=>{if(!g.formatted||!t||!o)return;let n=parseFloat(g.formatted);if(!n||n<=0)return;let C=n*.9999999999;a||l?(x(C),c(C),b()):(x(C),c(null),E({inputToken:t,outputToken:o,inputAmount:C.toString(),setOutputAmount:O=>c(O)}))},[g.formatted,t,o,a,l,x,c,b,E]),Fe=p(()=>{b(),j()},[b,j]),J=g.formatted?parseFloat(g.formatted):null,Me=!!(i||u),K=Se==="split",X=K&&(S==="baseSelection"||S==="baseChainSelection"),Y=K&&(S==="quoteSelection"||S==="quoteChainSelection"),Z=p(n=>{let O=d.getState().view==="baseChainSelection"?"base":"quote";d.getState().setChainFilter({chainId:n,side:O}),d.getState().pushRecentChain(n),d.getState().transitionToView(O==="base"?"baseSelection":"quoteSelection","chainSelection")},[]),We=p(()=>{d.getState().transitionToView("baseChainSelection","chainSelection")},[]),Be=p(()=>{d.getState().transitionToView("quoteChainSelection","chainSelection")},[]),$e=t?.price&&i?`$${(t.price*i).toFixed(2)}`:"$0.00",Qe=o?.price&&u?`$${(o.price*u).toFixed(2)}`:"$0.00",ee=A==="trackingTx"&&!!P&&!!t&&!!o&&!!i&&!!u,te={backgroundColor:R==="default"?"var(--widget-primary)":"transparent",color:R==="default"?"var(--widget-primary-foreground)":"var(--widget-primary)",border:R!=="default"?"1px solid var(--widget-primary)":"none",borderRadius:"var(--widget-radius)"};return r("div",{className:"flex flex-col w-full",children:[ee&&P&&t&&o&&i&&u?e("div",{className:"flex-1 min-h-0 overflow-hidden",children:e(pe,{orderHash:P,base:t,quote:o,baseAmount:i,quoteAmount:u,status:z})}):r("div",{className:`grid grid-cols-[1fr_auto_1fr] items-stretch px-4 ${F?"pt-3 pb-1":"pt-4 pb-2"} gap-2`,children:[e("div",{className:`relative flex flex-col gap-1 p-3 rounded-lg overflow-hidden ${X?"h-[380px]":""}`,style:{border:"1px solid var(--widget-border)",backgroundColor:"var(--widget-card)"},children:X?S==="baseChainSelection"?e(H,{toggle:y??q,side:"base",onChainSelect:Z}):e(Q,{toggle:y??q,side:"base",otherAsset:o,onMoreChainsClick:We,selectedChainFilter:L}):r(N,{children:[D?F?r("div",{className:`flex items-center gap-2 ${k==="right"?"flex-row-reverse":"flex-row"}`,children:[e(w,{toggle:B,side:"base",asset:t,isPlacingOrder:s||T||h,hideDropdown:h}),e("div",{className:"flex-1 min-w-0",children:e(f,{side:"base",asset:t??null,otherAsset:o??null,isPlacingOrder:s,isWrappingPair:a,isUnwrappingPair:l})})]}):r("div",{className:`flex flex-col ${k==="right"?"items-end":"items-start"}`,children:[e(w,{toggle:B,side:"base",asset:t,isPlacingOrder:s||T||h,hideDropdown:h}),e(f,{side:"base",asset:t??null,otherAsset:o??null,isPlacingOrder:s,isWrappingPair:a,isUnwrappingPair:l})]}):r(N,{children:[e(w,{toggle:B,side:"base",asset:t,isPlacingOrder:s||T||h,hideDropdown:h}),e(f,{side:"base",asset:t??null,otherAsset:o??null,isPlacingOrder:s,isWrappingPair:a,isUnwrappingPair:l})]}),r("div",{className:"flex items-center justify-between",children:[e("span",{className:"font-sans text-xs",style:{color:"var(--widget-muted-foreground)"},children:$e}),m&&J!==null&&J>0&&e("button",{type:"button",onClick:Re,disabled:s,className:"flex items-center rounded-full px-2 py-0.5 text-xs font-medium uppercase cursor-pointer disabled:opacity-40 transition-colors bg-(--widget-primary) text-(--widget-primary-foreground) hover:bg-(--widget-foreground) hover:text-(--widget-card)",children:"Max"})]})]})}),e("div",{className:"flex items-center justify-center px-1",children:ve?e("div",{className:"flex h-8 w-8 items-center justify-center opacity-20",children:e("span",{className:"text-sm",style:{color:"var(--widget-muted-foreground)"},children:"\u2192"})}):e("button",{type:"button",onClick:Ie,"aria-label":"Swap input and output tokens",className:"flex h-8 w-8 items-center justify-center rounded-full cursor-pointer transition-colors bg-(--widget-card) text-(--widget-muted-foreground) hover:bg-(--widget-secondary) hover:text-(--widget-foreground)",style:{border:"1px solid var(--widget-border)"},children:e(ue,{className:"w-3.5 h-3.5"})})}),e("div",{className:`relative flex flex-col gap-1 p-3 rounded-lg overflow-hidden ${Y?"h-[380px]":""}`,style:{border:"1px solid var(--widget-border)",backgroundColor:"var(--widget-card)"},children:Y?S==="quoteChainSelection"?e(H,{toggle:y??q,side:"quote",onChainSelect:Z}):e(Q,{toggle:y??q,side:"quote",otherAsset:t,onMoreChainsClick:Be,selectedChainFilter:L}):r(N,{children:[D?F?r("div",{className:`flex items-center gap-2 ${k==="right"?"flex-row-reverse":"flex-row"}`,children:[e(w,{toggle:$,side:"quote",asset:o,isPlacingOrder:s||I||v,hideDropdown:v}),e("div",{className:"flex-1 min-w-0",children:e(f,{side:"quote",asset:o??null,otherAsset:t??null,isPlacingOrder:s,isWrappingPair:a,isUnwrappingPair:l})})]}):r("div",{className:`flex flex-col ${k==="right"?"items-end":"items-start"}`,children:[e(w,{toggle:$,side:"quote",asset:o,isPlacingOrder:s||I||v,hideDropdown:v}),e(f,{side:"quote",asset:o??null,otherAsset:t??null,isPlacingOrder:s,isWrappingPair:a,isUnwrappingPair:l})]}):r(N,{children:[e(w,{toggle:$,side:"quote",asset:o,isPlacingOrder:s||I||v,hideDropdown:v}),e(f,{side:"quote",asset:o??null,otherAsset:t??null,isPlacingOrder:s,isWrappingPair:a,isUnwrappingPair:l})]}),r("div",{className:"flex items-center justify-between",children:[e("span",{className:"font-sans text-xs",style:{color:"var(--widget-muted-foreground)"},children:Qe}),Me&&e("button",{type:"button",onClick:Fe,disabled:s,className:"flex items-center rounded-full px-2 py-0.5 text-xs font-medium uppercase cursor-pointer disabled:opacity-40 transition-colors text-(--widget-muted-foreground) hover:bg-(--widget-secondary)",children:"Clear"})]})]})})]}),e("div",{className:"flex flex-row items-center w-full overflow-hidden px-4",style:{borderTop:W?"1px solid var(--widget-border)":"none",maxHeight:W?"60px":"0px",opacity:W?1:0,transition:"max-height 0.3s ease, opacity 0.3s ease"},children:e(de,{})}),e("div",{className:"px-4",style:{borderTop:"1px solid var(--widget-border)",borderBottom:"1px solid var(--widget-border)"},children:e(le,{})}),e("div",{className:`relative ${ee?"px-0":"px-4"} py-4`,children:m&&t&&o&&i&&i>0?e(ce,{base:t,baseAmount:i,quote:o,quoteAmount:u??0,userAddress:m,isWrappingPair:a,isUnwrappingPair:l,isBaseGasToken:ye,isQuoteGasToken:ke,reviewActionProps:qe,reviewState:A,setReviewState:Pe,trackedOrderHash:P,setTrackedOrderHash:_,onSwapSubmitted:ge,onSwapComplete:fe,onSwapInitiated:we,onOrderSubmitted:Ne,onStaleQuoteRestart:Te,txStatus:z}):!m&&he?e("button",{onClick:()=>Ae(),className:"w-full py-3 text-sm font-medium cursor-pointer transition-opacity hover:opacity-80",style:te,children:"Connect Wallet"}):e("button",{disabled:!0,className:"w-full py-3 text-sm font-medium transition-colors disabled:opacity-40 cursor-not-allowed",style:te,children:m?"Enter Amount":"Connect Wallet"})})]})},ft=je;export{ft as default};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }"use client";
|
|
2
|
-
"use client";var _chunkCQPWVWB5cjs = require('./chunk-CQPWVWB5.cjs');var _chunkZV4XHNYVcjs = require('./chunk-ZV4XHNYV.cjs');var _chunkR36QQMHJcjs = require('./chunk-R36QQMHJ.cjs');var _chunkN2SES3FPcjs = require('./chunk-N2SES3FP.cjs');var _chunkGIDTBDDCcjs = require('./chunk-GIDTBDDC.cjs');require('./chunk-KH57FLST.cjs');var _chunkGK3MOEYUcjs = require('./chunk-GK3MOEYU.cjs');var _chunk3PGCHNG2cjs = require('./chunk-3PGCHNG2.cjs');require('./chunk-4S3B2JQY.cjs');var _chunk34N36GUDcjs = require('./chunk-34N36GUD.cjs');require('./chunk-T3I3AJXV.cjs');var _react = require('react');var _shallow = require('zustand/react/shallow');var _jsxruntime = require('react/jsx-runtime');var q=()=>{},je=({onSwapSubmitted:ge,onSwapComplete:fe,onSwapInitiated:we,onBackToSwap:y,onMoreChainsClick:Ee})=>{let{web3ConnectionType:Ge,hasConnectHandler:he,lockBase:T,lockQuote:I,disableInverting:ve,swapButtonVariant:R,tokenDisplay:U,tokenBadgeOrientation:k,widgetType:be,assetMenuVariant:Se}=_chunk3PGCHNG2cjs.b.call(void 0, ),{effectiveInputTokens:xe,effectiveOutputTokens:Ce}=_chunkGIDTBDDCcjs.a.call(void 0, ),h=xe.length===1,v=Ce.length===1,D=U==="pill"||U==="ghost",F=be==="compact",{baseToken:t,quoteToken:o,baseAmount:i,quoteAmount:u,isBaseGasToken:ye,isQuoteGasToken:ke,isWrappingPair:a,isUnwrappingPair:l,baseBalance:g,quoteBalance:ze,setBaseAmount:x,setQuoteAmount:c,swapTokens:V,clearForm:j}=_chunkGK3MOEYUcjs.e.call(void 0, ),{rfqQuote:Le,status:_e,handleInputChange:M,ensureForParams:E,stop:Je,clear:b,refresh:G}=_chunkZV4XHNYVcjs.e.call(void 0, ),{address:m}=_chunk34N36GUDcjs.a.call(void 0, ),{openConnectModal:Ae}=_chunkZV4XHNYVcjs.g.call(void 0, ),{isRecipientInputOpen:W,txStatus:z,view:S,selectedChainFilterChainId:L}=_chunk3PGCHNG2cjs.d.call(void 0, _shallow.useShallow.call(void 0, n=>({isRecipientInputOpen:n.isRecipientInputOpen,txStatus:n.txStatus,view:n.view,selectedChainFilterChainId:_nullishCoalesce(_optionalChain([n, 'access', _2 => _2.selectedChainFilter, 'optionalAccess', _3 => _3.chainId]), () => (null))}))),[A,Pe]=_react.useState.call(void 0, null),[P,_]=_react.useState.call(void 0, null),Oe=_react.useRef.call(void 0, !1),s=!1,qe=_react.useMemo.call(void 0, ()=>!t||!o||typeof i!="number"||!u||!m||parseFloat(g.formatted)<i?null:{base:t,quote:o,baseAmount:i,quoteAmount:u,userAddress:m},[t,o,i,u,m,g.formatted]),Ne=_react.useCallback.call(void 0, n=>{_(n),_chunk3PGCHNG2cjs.d.getState().startTracking(n)},[]),Te=_react.useCallback.call(void 0, ()=>{Oe.current=!0,G()},[G]);_react.useEffect.call(void 0, ()=>{if(A===null&&!(!t||!o)){if(!i||i<=0){M({amount:null,inputToken:t,outputToken:o,setOutputAmount:c});return}if(a||l){c(i);return}M({amount:i,inputToken:t,outputToken:o,setOutputAmount:c})}},[A,i,t,o,a,l,M,c]);let B=_react.useCallback.call(void 0, ()=>{_chunk3PGCHNG2cjs.d.getState().setView("baseSelection")},[]),$=_react.useCallback.call(void 0, ()=>{_chunk3PGCHNG2cjs.d.getState().setView("quoteSelection")},[]),Ie=_react.useCallback.call(void 0, ()=>{b(),V(),x(null),c(null)},[b,V,x,c]),Re=_react.useCallback.call(void 0, ()=>{if(!g.formatted||!t||!o)return;let n=parseFloat(g.formatted);if(!n||n<=0)return;let C=n*.9999999999;a||l?(x(C),c(C),b()):(x(C),c(null),E({inputToken:t,outputToken:o,inputAmount:C.toString(),setOutputAmount:O=>c(O)}))},[g.formatted,t,o,a,l,x,c,b,E]),Fe=_react.useCallback.call(void 0, ()=>{b(),j()},[b,j]),J=g.formatted?parseFloat(g.formatted):null,Me=!!(i||u),K=Se==="split",X=K&&(S==="baseSelection"||S==="baseChainSelection"),Y=K&&(S==="quoteSelection"||S==="quoteChainSelection"),Z=_react.useCallback.call(void 0, n=>{let O=_chunk3PGCHNG2cjs.d.getState().view==="baseChainSelection"?"base":"quote";_chunk3PGCHNG2cjs.d.getState().setChainFilter({chainId:n,side:O}),_chunk3PGCHNG2cjs.d.getState().pushRecentChain(n),_chunk3PGCHNG2cjs.d.getState().transitionToView(O==="base"?"baseSelection":"quoteSelection","chainSelection")},[]),We=_react.useCallback.call(void 0, ()=>{_chunk3PGCHNG2cjs.d.getState().transitionToView("baseChainSelection","chainSelection")},[]),Be=_react.useCallback.call(void 0, ()=>{_chunk3PGCHNG2cjs.d.getState().transitionToView("quoteChainSelection","chainSelection")},[]),$e=_optionalChain([t, 'optionalAccess', _4 => _4.price])&&i?`$${(t.price*i).toFixed(2)}`:"$0.00",Qe=_optionalChain([o, 'optionalAccess', _5 => _5.price])&&u?`$${(o.price*u).toFixed(2)}`:"$0.00",ee=A==="trackingTx"&&!!P&&!!t&&!!o&&!!i&&!!u,te={backgroundColor:R==="default"?"var(--widget-primary)":"transparent",color:R==="default"?"var(--widget-primary-foreground)":"var(--widget-primary)",border:R!=="default"?"1px solid var(--widget-primary)":"none",borderRadius:"var(--widget-radius)"};return _jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col w-full",children:[ee&&P&&t&&o&&i&&u?_jsxruntime.jsx.call(void 0, "div",{className:"flex-1 min-h-0 overflow-hidden",children:_jsxruntime.jsx.call(void 0, _chunkZV4XHNYVcjs.y,{orderHash:P,base:t,quote:o,baseAmount:i,quoteAmount:u,status:z})}):_jsxruntime.jsxs.call(void 0, "div",{className:`grid grid-cols-[1fr_auto_1fr] items-stretch px-4 ${F?"pt-3 pb-1":"pt-4 pb-2"} gap-2`,children:[_jsxruntime.jsx.call(void 0, "div",{className:`relative flex flex-col gap-1 p-3 rounded-lg overflow-hidden ${X?"h-[380px]":""}`,style:{border:"1px solid var(--widget-border)",backgroundColor:"var(--widget-card)"},children:X?S==="baseChainSelection"?_jsxruntime.jsx.call(void 0, _chunkN2SES3FPcjs.a,{toggle:_nullishCoalesce(y, () => (q)),side:"base",onChainSelect:Z}):_jsxruntime.jsx.call(void 0, _chunkR36QQMHJcjs.a,{toggle:_nullishCoalesce(y, () => (q)),side:"base",otherAsset:o,onMoreChainsClick:We,selectedChainFilter:L}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[D?F?_jsxruntime.jsxs.call(void 0, "div",{className:`flex items-center gap-2 ${k==="right"?"flex-row-reverse":"flex-row"}`,children:[_jsxruntime.jsx.call(void 0, _chunkZV4XHNYVcjs.i,{toggle:B,side:"base",asset:t,isPlacingOrder:s||T||h,hideDropdown:h}),_jsxruntime.jsx.call(void 0, "div",{className:"flex-1 min-w-0",children:_jsxruntime.jsx.call(void 0, _chunkZV4XHNYVcjs.h,{side:"base",asset:_nullishCoalesce(t, () => (null)),otherAsset:_nullishCoalesce(o, () => (null)),isPlacingOrder:s,isWrappingPair:a,isUnwrappingPair:l})})]}):_jsxruntime.jsxs.call(void 0, "div",{className:`flex flex-col ${k==="right"?"items-end":"items-start"}`,children:[_jsxruntime.jsx.call(void 0, _chunkZV4XHNYVcjs.i,{toggle:B,side:"base",asset:t,isPlacingOrder:s||T||h,hideDropdown:h}),_jsxruntime.jsx.call(void 0, _chunkZV4XHNYVcjs.h,{side:"base",asset:_nullishCoalesce(t, () => (null)),otherAsset:_nullishCoalesce(o, () => (null)),isPlacingOrder:s,isWrappingPair:a,isUnwrappingPair:l})]}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, _chunkZV4XHNYVcjs.i,{toggle:B,side:"base",asset:t,isPlacingOrder:s||T||h,hideDropdown:h}),_jsxruntime.jsx.call(void 0, _chunkZV4XHNYVcjs.h,{side:"base",asset:_nullishCoalesce(t, () => (null)),otherAsset:_nullishCoalesce(o, () => (null)),isPlacingOrder:s,isWrappingPair:a,isUnwrappingPair:l})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center justify-between",children:[_jsxruntime.jsx.call(void 0, "span",{className:"font-sans text-xs",style:{color:"var(--widget-muted-foreground)"},children:$e}),m&&J!==null&&J>0&&_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:Re,disabled:s,className:"flex items-center rounded-full px-2 py-0.5 text-xs font-medium uppercase cursor-pointer disabled:opacity-40 transition-colors bg-(--widget-primary) text-(--widget-primary-foreground) hover:bg-(--widget-foreground) hover:text-(--widget-card)",children:"Max"})]})]})}),_jsxruntime.jsx.call(void 0, "div",{className:"flex items-center justify-center px-1",children:ve?_jsxruntime.jsx.call(void 0, "div",{className:"flex h-8 w-8 items-center justify-center opacity-20",children:_jsxruntime.jsx.call(void 0, "span",{className:"text-sm",style:{color:"var(--widget-muted-foreground)"},children:"\u2192"})}):_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:Ie,"aria-label":"Swap input and output tokens",className:"flex h-8 w-8 items-center justify-center rounded-full cursor-pointer transition-colors bg-(--widget-card) text-(--widget-muted-foreground) hover:bg-(--widget-secondary) hover:text-(--widget-foreground)",style:{border:"1px solid var(--widget-border)"},children:_jsxruntime.jsx.call(void 0, _chunkZV4XHNYVcjs.k,{className:"w-3.5 h-3.5"})})}),_jsxruntime.jsx.call(void 0, "div",{className:`relative flex flex-col gap-1 p-3 rounded-lg overflow-hidden ${Y?"h-[380px]":""}`,style:{border:"1px solid var(--widget-border)",backgroundColor:"var(--widget-card)"},children:Y?S==="quoteChainSelection"?_jsxruntime.jsx.call(void 0, _chunkN2SES3FPcjs.a,{toggle:_nullishCoalesce(y, () => (q)),side:"quote",onChainSelect:Z}):_jsxruntime.jsx.call(void 0, _chunkR36QQMHJcjs.a,{toggle:_nullishCoalesce(y, () => (q)),side:"quote",otherAsset:t,onMoreChainsClick:Be,selectedChainFilter:L}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[D?F?_jsxruntime.jsxs.call(void 0, "div",{className:`flex items-center gap-2 ${k==="right"?"flex-row-reverse":"flex-row"}`,children:[_jsxruntime.jsx.call(void 0, _chunkZV4XHNYVcjs.i,{toggle:$,side:"quote",asset:o,isPlacingOrder:s||I||v,hideDropdown:v}),_jsxruntime.jsx.call(void 0, "div",{className:"flex-1 min-w-0",children:_jsxruntime.jsx.call(void 0, _chunkZV4XHNYVcjs.h,{side:"quote",asset:_nullishCoalesce(o, () => (null)),otherAsset:_nullishCoalesce(t, () => (null)),isPlacingOrder:s,isWrappingPair:a,isUnwrappingPair:l})})]}):_jsxruntime.jsxs.call(void 0, "div",{className:`flex flex-col ${k==="right"?"items-end":"items-start"}`,children:[_jsxruntime.jsx.call(void 0, _chunkZV4XHNYVcjs.i,{toggle:$,side:"quote",asset:o,isPlacingOrder:s||I||v,hideDropdown:v}),_jsxruntime.jsx.call(void 0, _chunkZV4XHNYVcjs.h,{side:"quote",asset:_nullishCoalesce(o, () => (null)),otherAsset:_nullishCoalesce(t, () => (null)),isPlacingOrder:s,isWrappingPair:a,isUnwrappingPair:l})]}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, _chunkZV4XHNYVcjs.i,{toggle:$,side:"quote",asset:o,isPlacingOrder:s||I||v,hideDropdown:v}),_jsxruntime.jsx.call(void 0, _chunkZV4XHNYVcjs.h,{side:"quote",asset:_nullishCoalesce(o, () => (null)),otherAsset:_nullishCoalesce(t, () => (null)),isPlacingOrder:s,isWrappingPair:a,isUnwrappingPair:l})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center justify-between",children:[_jsxruntime.jsx.call(void 0, "span",{className:"font-sans text-xs",style:{color:"var(--widget-muted-foreground)"},children:Qe}),Me&&_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:Fe,disabled:s,className:"flex items-center rounded-full px-2 py-0.5 text-xs font-medium uppercase cursor-pointer disabled:opacity-40 transition-colors text-(--widget-muted-foreground) hover:bg-(--widget-secondary)",children:"Clear"})]})]})})]}),_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-row items-center w-full overflow-hidden px-4",style:{borderTop:W?"1px solid var(--widget-border)":"none",maxHeight:W?"60px":"0px",opacity:W?1:0,transition:"max-height 0.3s ease, opacity 0.3s ease"},children:_jsxruntime.jsx.call(void 0, _chunkZV4XHNYVcjs.j,{})}),_jsxruntime.jsx.call(void 0, "div",{className:"px-4",style:{borderTop:"1px solid var(--widget-border)",borderBottom:"1px solid var(--widget-border)"},children:_jsxruntime.jsx.call(void 0, _chunkCQPWVWB5cjs.a,{})}),_jsxruntime.jsx.call(void 0, "div",{className:`relative ${ee?"px-0":"px-4"} py-4`,children:m&&t&&o&&i&&i>0?_jsxruntime.jsx.call(void 0, _chunkZV4XHNYVcjs.x,{base:t,baseAmount:i,quote:o,quoteAmount:_nullishCoalesce(u, () => (0)),userAddress:m,isWrappingPair:a,isUnwrappingPair:l,isBaseGasToken:ye,isQuoteGasToken:ke,reviewActionProps:qe,reviewState:A,setReviewState:Pe,trackedOrderHash:P,setTrackedOrderHash:_,onSwapSubmitted:ge,onSwapComplete:fe,onSwapInitiated:we,onOrderSubmitted:Ne,onStaleQuoteRestart:Te,txStatus:z}):!m&&he?_jsxruntime.jsx.call(void 0, "button",{onClick:()=>Ae(),className:"w-full py-3 text-sm font-medium cursor-pointer transition-opacity hover:opacity-80",style:te,children:"Connect Wallet"}):_jsxruntime.jsx.call(void 0, "button",{disabled:!0,className:"w-full py-3 text-sm font-medium transition-colors disabled:opacity-40 cursor-not-allowed",style:te,children:m?"Enter Amount":"Connect Wallet"})})]})},ft= exports.default =je;exports.default = ft;
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }"use client";
|
|
2
|
-
"use client";var _chunkZV4XHNYVcjs = require('./chunk-ZV4XHNYV.cjs');var _chunkR36QQMHJcjs = require('./chunk-R36QQMHJ.cjs');var _chunkN2SES3FPcjs = require('./chunk-N2SES3FP.cjs');var _chunkGIDTBDDCcjs = require('./chunk-GIDTBDDC.cjs');require('./chunk-KH57FLST.cjs');var _chunkGK3MOEYUcjs = require('./chunk-GK3MOEYU.cjs');var _chunk3PGCHNG2cjs = require('./chunk-3PGCHNG2.cjs');var _chunk4S3B2JQYcjs = require('./chunk-4S3B2JQY.cjs');var _chunk34N36GUDcjs = require('./chunk-34N36GUD.cjs');require('./chunk-T3I3AJXV.cjs');var _react = require('react');var _shallow = require('zustand/react/shallow');var _jsxruntime = require('react/jsx-runtime');var we=()=>{},tt=({onSwapSubmitted:he,onSwapComplete:be,onSwapInitiated:Se,onBackToSwap:E,onMoreChainsClick:st})=>{let{web3ConnectionType:ot,hasConnectHandler:ye,lockBase:R,lockQuote:F,disableInverting:Ce,swapButtonVariant:I,tokenDisplay:j,tokenBadgeOrientation:A,widgetType:Ne,assetMenuVariant:ke}=_chunk3PGCHNG2cjs.b.call(void 0, ),{effectiveInputTokens:Ae,effectiveOutputTokens:Pe}=_chunkGIDTBDDCcjs.a.call(void 0, ),S=Ae.length===1,y=Pe.length===1,z=j==="pill"||j==="ghost",P=Ne==="compact",{baseToken:d,quoteToken:c,baseAmount:a,quoteAmount:n,isBaseGasToken:Te,isQuoteGasToken:Oe,isWrappingPair:u,isUnwrappingPair:p,baseBalance:w,setBaseAmount:k,setQuoteAmount:g,swapTokens:G,clearForm:L}=_chunkGK3MOEYUcjs.e.call(void 0, ),{handleInputChange:M,ensureForParams:_,clear:C,refresh:J,liquidityError:qe,routingError:Re}=_chunkZV4XHNYVcjs.e.call(void 0, ),{address:v}=_chunk34N36GUDcjs.a.call(void 0, ),{openConnectModal:Fe}=_chunkZV4XHNYVcjs.g.call(void 0, ),{isRecipientInputOpen:$,txStatus:K,view:x,selectedChainFilterChainId:Ie}=_chunk3PGCHNG2cjs.d.call(void 0, _shallow.useShallow.call(void 0, i=>({isRecipientInputOpen:i.isRecipientInputOpen,txStatus:i.txStatus,view:i.view,selectedChainFilterChainId:_nullishCoalesce(i.selectedChainFilterChainId, () => (null))}))),[T,Me]=_react.useState.call(void 0, null),[O,X]=_react.useState.call(void 0, null),$e=_react.useRef.call(void 0, !1),r=!1,We=_react.useMemo.call(void 0, ()=>!d||!c||typeof a!="number"||!n||!v||parseFloat(w.formatted)<a?null:{base:d,quote:c,baseAmount:a,quoteAmount:n,userAddress:v},[d,c,a,n,v,w.formatted]),Be=_react.useCallback.call(void 0, i=>{X(i),_chunk3PGCHNG2cjs.d.getState().startTracking(i)},[]),De=_react.useCallback.call(void 0, ()=>{$e.current=!0,J()},[J]);_react.useEffect.call(void 0, ()=>{if(T===null&&!(!d||!c)){if(!a||a<=0){M({amount:null,inputToken:d,outputToken:c,setOutputAmount:g});return}if(u||p){g(a);return}M({amount:a,inputToken:d,outputToken:c,setOutputAmount:g})}},[T,a,d,c,u,p,M,g]);let Y=a&&n&&parseFloat(n.toString())?parseFloat(a.toString())/parseFloat(n.toString()):0,W=_react.useCallback.call(void 0, ()=>{_chunk3PGCHNG2cjs.d.getState().setView("baseSelection")},[]),B=_react.useCallback.call(void 0, ()=>{_chunk3PGCHNG2cjs.d.getState().setView("quoteSelection")},[]),Qe=_react.useCallback.call(void 0, ()=>{C(),G(),k(null),g(null)},[C,G,k,g]),Ue=_react.useCallback.call(void 0, ()=>{if(!w.formatted||!d||!c)return;let i=parseFloat(w.formatted);if(!i||i<=0)return;let m=i*.9999999999;u||p?(k(m),g(m),C()):(k(m),g(null),_({inputToken:d,outputToken:c,inputAmount:m.toString(),setOutputAmount:N=>g(N)}))},[w.formatted,d,c,u,p,k,g,C,_]),Ve=_react.useCallback.call(void 0, ()=>{C(),L()},[C,L]),Z=w.formatted?parseFloat(w.formatted):null,He=!!(a||n),s=d,o=c,Ee=_optionalChain([s, 'optionalAccess', _2 => _2.price])&&a?`$${(s.price*a).toFixed(2)}`:"$0.00",je=_optionalChain([o, 'optionalAccess', _3 => _3.price])&&n?`$${(o.price*n).toFixed(2)}`:"$0.00",ze=!!(s&&o&&a&&n),Ge=qe||Re,ee=T==="trackingTx"&&!!O&&!!s&&!!o&&!!a&&!!n,D=ke==="split",Q=D&&(x==="baseSelection"||x==="quoteSelection"||x==="baseChainSelection"||x==="quoteChainSelection"),U=x==="baseSelection"||x==="baseChainSelection"?"base":"quote",Le=U==="base"?o:s,te=_react.useRef.call(void 0, null),[_e,Je]=_react.useState.call(void 0, 380);_react.useEffect.call(void 0, ()=>{if(!D)return;let i=te.current;if(!i)return;let m=new ResizeObserver(N=>{for(let Ye of N)Je(Ye.contentRect.height)});return m.observe(i),()=>m.disconnect()},[D]);let Ke=_react.useCallback.call(void 0, i=>{let N=_chunk3PGCHNG2cjs.d.getState().view==="baseChainSelection"?"base":"quote";_chunk3PGCHNG2cjs.d.getState().setChainFilter({chainId:i,side:N}),_chunk3PGCHNG2cjs.d.getState().pushRecentChain(i),_chunk3PGCHNG2cjs.d.getState().transitionToView(N==="base"?"baseSelection":"quoteSelection","chainSelection")},[]),Xe=_react.useCallback.call(void 0, ()=>{let i=_chunk3PGCHNG2cjs.d.getState().view;i==="baseSelection"?_chunk3PGCHNG2cjs.d.getState().transitionToView("baseChainSelection","chainSelection"):i==="quoteSelection"&&_chunk3PGCHNG2cjs.d.getState().transitionToView("quoteChainSelection","chainSelection")},[]),se={backgroundColor:I==="default"?"var(--widget-primary)":"transparent",color:I==="default"?"var(--widget-primary-foreground)":"var(--widget-primary)",border:I!=="default"?"1px solid var(--widget-primary)":"none",borderRadius:"var(--widget-radius)"};return _jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-row w-full",children:[_jsxruntime.jsxs.call(void 0, "div",{ref:te,className:"flex flex-col flex-1 min-w-0",style:{borderRight:"1px solid var(--widget-border)"},children:[ee&&O&&s&&o&&a&&n?_jsxruntime.jsx.call(void 0, "div",{className:"flex-1 min-h-0 overflow-hidden",children:_jsxruntime.jsx.call(void 0, _chunkZV4XHNYVcjs.y,{orderHash:O,base:s,quote:o,baseAmount:a,quoteAmount:n,status:K})}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsxs.call(void 0, "div",{className:`relative ${P?"px-4 pt-3 pb-1":"px-4 pt-4 pb-2"}`,style:{borderBottom:"1px solid var(--widget-border)"},children:[z?P?_jsxruntime.jsxs.call(void 0, "div",{className:`flex items-center gap-2 ${A==="right"?"flex-row-reverse":"flex-row"}`,children:[_jsxruntime.jsx.call(void 0, _chunkZV4XHNYVcjs.i,{toggle:W,side:"base",asset:s,isPlacingOrder:r||R||S,hideDropdown:S}),_jsxruntime.jsx.call(void 0, "div",{className:"flex-1 min-w-0",children:_jsxruntime.jsx.call(void 0, _chunkZV4XHNYVcjs.h,{side:"base",asset:_nullishCoalesce(s, () => (null)),otherAsset:_nullishCoalesce(o, () => (null)),isPlacingOrder:r,isWrappingPair:u,isUnwrappingPair:p})})]}):_jsxruntime.jsxs.call(void 0, "div",{className:`flex flex-col ${A==="right"?"items-end":"items-start"}`,children:[_jsxruntime.jsx.call(void 0, _chunkZV4XHNYVcjs.i,{toggle:W,side:"base",asset:s,isPlacingOrder:r||R||S,hideDropdown:S}),_jsxruntime.jsx.call(void 0, _chunkZV4XHNYVcjs.h,{side:"base",asset:_nullishCoalesce(s, () => (null)),otherAsset:_nullishCoalesce(o, () => (null)),isPlacingOrder:r,isWrappingPair:u,isUnwrappingPair:p})]}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, _chunkZV4XHNYVcjs.i,{toggle:W,side:"base",asset:s,isPlacingOrder:r||R||S,hideDropdown:S}),_jsxruntime.jsx.call(void 0, _chunkZV4XHNYVcjs.h,{side:"base",asset:_nullishCoalesce(s, () => (null)),otherAsset:_nullishCoalesce(o, () => (null)),isPlacingOrder:r,isWrappingPair:u,isUnwrappingPair:p})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"mb-1 flex w-full flex-row items-center justify-between",children:[_jsxruntime.jsx.call(void 0, "p",{className:"font-sans text-sm",style:{color:"var(--widget-muted-foreground)"},children:Ee}),v&&Z!==null&&Z>0&&_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:Ue,disabled:r,className:"absolute bottom-3 right-4 flex items-center rounded-full px-3 py-0.5 text-xs font-medium uppercase cursor-pointer disabled:opacity-40 bg-(--widget-primary) text-(--widget-primary-foreground) hover:bg-(--widget-foreground) hover:text-(--widget-card) transition-colors",children:"Max"})]})]}),!Ce&&_jsxruntime.jsx.call(void 0, "div",{className:"flex justify-center -my-4 relative z-10",children:_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:Qe,"aria-label":"Swap input and output tokens",className:"flex h-8 w-8 items-center justify-center rounded-full cursor-pointer bg-(--widget-card) text-(--widget-muted-foreground) hover:bg-(--widget-secondary) hover:text-(--widget-foreground) transition-colors",style:{border:"1px solid var(--widget-border)"},children:_jsxruntime.jsx.call(void 0, _chunkZV4XHNYVcjs.k,{className:"w-3.5 h-3.5"})})}),_jsxruntime.jsxs.call(void 0, "div",{className:`relative ${P?"px-4 pt-4 pb-1":"px-4 pt-6 pb-2"}`,children:[z?P?_jsxruntime.jsxs.call(void 0, "div",{className:`flex items-center gap-2 ${A==="right"?"flex-row-reverse":"flex-row"}`,children:[_jsxruntime.jsx.call(void 0, _chunkZV4XHNYVcjs.i,{toggle:B,side:"quote",asset:o,isPlacingOrder:r||F||y,hideDropdown:y}),_jsxruntime.jsx.call(void 0, "div",{className:"flex-1 min-w-0",children:_jsxruntime.jsx.call(void 0, _chunkZV4XHNYVcjs.h,{side:"quote",asset:_nullishCoalesce(o, () => (null)),otherAsset:_nullishCoalesce(s, () => (null)),isPlacingOrder:r,isWrappingPair:u,isUnwrappingPair:p})})]}):_jsxruntime.jsxs.call(void 0, "div",{className:`flex flex-col ${A==="right"?"items-end":"items-start"}`,children:[_jsxruntime.jsx.call(void 0, _chunkZV4XHNYVcjs.i,{toggle:B,side:"quote",asset:o,isPlacingOrder:r||F||y,hideDropdown:y}),_jsxruntime.jsx.call(void 0, _chunkZV4XHNYVcjs.h,{side:"quote",asset:_nullishCoalesce(o, () => (null)),otherAsset:_nullishCoalesce(s, () => (null)),isPlacingOrder:r,isWrappingPair:u,isUnwrappingPair:p})]}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, _chunkZV4XHNYVcjs.i,{toggle:B,side:"quote",asset:o,isPlacingOrder:r||F||y,hideDropdown:y}),_jsxruntime.jsx.call(void 0, _chunkZV4XHNYVcjs.h,{side:"quote",asset:_nullishCoalesce(o, () => (null)),otherAsset:_nullishCoalesce(s, () => (null)),isPlacingOrder:r,isWrappingPair:u,isUnwrappingPair:p})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex w-full flex-row items-center justify-between",children:[_jsxruntime.jsx.call(void 0, "p",{className:"font-sans text-sm",style:{color:"var(--widget-muted-foreground)"},children:je}),He&&_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:Ve,disabled:r,className:"absolute bottom-2 right-4 flex items-center rounded-full px-3 py-0.5 text-xs font-medium uppercase cursor-pointer disabled:opacity-40 text-(--widget-muted-foreground) hover:bg-(--widget-secondary) transition-colors",children:"Clear"})]})]})]}),_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-row items-center w-full overflow-hidden",style:{borderTop:$?"1px solid var(--widget-border)":"none",maxHeight:$?"60px":"0px",opacity:$?1:0,transition:"max-height 0.3s ease, opacity 0.3s ease"},children:_jsxruntime.jsx.call(void 0, _chunkZV4XHNYVcjs.j,{})}),_jsxruntime.jsx.call(void 0, "div",{className:`relative ${ee?"px-0":"px-4"} py-4`,children:v&&s&&o&&a&&a>0?_jsxruntime.jsx.call(void 0, _chunkZV4XHNYVcjs.x,{base:s,baseAmount:a,quote:o,quoteAmount:_nullishCoalesce(n, () => (0)),userAddress:v,isWrappingPair:u,isUnwrappingPair:p,isBaseGasToken:Te,isQuoteGasToken:Oe,reviewActionProps:We,reviewState:T,setReviewState:Me,trackedOrderHash:O,setTrackedOrderHash:X,onSwapSubmitted:he,onSwapComplete:be,onSwapInitiated:Se,onOrderSubmitted:Be,onStaleQuoteRestart:De,txStatus:K}):!v&&ye?_jsxruntime.jsx.call(void 0, "button",{onClick:()=>Fe(),className:"w-full py-3 text-sm font-medium cursor-pointer transition-opacity hover:opacity-80",style:se,children:"Connect Wallet"}):_jsxruntime.jsx.call(void 0, "button",{disabled:!0,className:"w-full py-3 text-sm font-medium transition-colors disabled:opacity-40 cursor-not-allowed",style:se,children:v?"Enter Amount":"Connect Wallet"})})]}),_jsxruntime.jsx.call(void 0, "div",{className:`flex flex-col transition-all duration-300 ${Q?"flex-1 min-w-0":"w-48 shrink-0"}`,style:{backgroundColor:"var(--widget-background)",...Q?{height:`${_e}px`}:{}},children:Q?_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-col overflow-hidden p-2",style:{height:"100%"},children:x==="baseChainSelection"||x==="quoteChainSelection"?_jsxruntime.jsx.call(void 0, _chunkN2SES3FPcjs.a,{toggle:_nullishCoalesce(E, () => (we)),side:U,onChainSelect:Ke}):_jsxruntime.jsx.call(void 0, _chunkR36QQMHJcjs.a,{toggle:_nullishCoalesce(E, () => (we)),side:U,otherAsset:Le,onMoreChainsClick:Xe,selectedChainFilter:Ie})}):_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-3 px-4 py-4",children:[_jsxruntime.jsx.call(void 0, "span",{className:"text-2xs uppercase tracking-wider font-medium",style:{color:"var(--widget-muted-foreground)"},children:"Quote Details"}),ze&&s&&o?_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-0.5",children:[_jsxruntime.jsx.call(void 0, "span",{className:"text-2xs",style:{color:"var(--widget-muted-foreground)"},children:"Rate"}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center gap-1",children:[_jsxruntime.jsx.call(void 0, _chunk4S3B2JQYcjs.O,{asset:o,size:"3xs",noChain:!0}),_jsxruntime.jsxs.call(void 0, "span",{className:"font-sans text-xs uppercase",children:["1 ",o.symbol]})]}),_jsxruntime.jsx.call(void 0, "div",{className:"flex items-center gap-1 pl-4",children:_jsxruntime.jsxs.call(void 0, "span",{className:"text-2xs",style:{color:"var(--widget-muted-foreground)"},children:["= ",Y.toFixed(6)]})}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center gap-1 pl-4",children:[_jsxruntime.jsx.call(void 0, _chunk4S3B2JQYcjs.O,{asset:s,size:"3xs",noChain:!0}),_jsxruntime.jsx.call(void 0, "span",{className:"font-sans text-xs uppercase",children:s.symbol})]})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-2",style:{borderTop:"1px solid var(--widget-border)",paddingTop:"0.5rem"},children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex justify-between items-center",children:[_jsxruntime.jsx.call(void 0, "span",{className:"text-2xs",style:{color:"var(--widget-muted-foreground)"},children:"USD Value"}),_jsxruntime.jsxs.call(void 0, "span",{className:"font-sans text-xs",children:["$",s.price?(s.price*Y*parseFloat(n.toString())).toFixed(2):"\u2014"]})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex justify-between items-center",children:[_jsxruntime.jsx.call(void 0, "span",{className:"text-2xs",style:{color:"var(--widget-muted-foreground)"},children:"Order Type"}),_jsxruntime.jsx.call(void 0, "span",{className:"text-2xs font-sans",style:{color:"var(--widget-foreground)"},children:"RFQ"})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex justify-between items-center",children:[_jsxruntime.jsx.call(void 0, "span",{className:"text-2xs",style:{color:"var(--widget-muted-foreground)"},children:"Fill"}),_jsxruntime.jsx.call(void 0, "span",{className:"text-2xs",style:{color:"var(--widget-primary)"},children:"Exact"})]}),s.chainId!==o.chainId&&_jsxruntime.jsxs.call(void 0, "div",{className:"flex justify-between items-center",children:[_jsxruntime.jsx.call(void 0, "span",{className:"text-2xs",style:{color:"var(--widget-muted-foreground)"},children:"Route"}),_jsxruntime.jsx.call(void 0, "span",{className:"text-2xs font-sans",children:"Cross-chain"})]})]})]}):Ge?_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-1",children:[_jsxruntime.jsx.call(void 0, _chunk4S3B2JQYcjs.W,{className:"h-6 w-6",style:{color:"var(--widget-destructive)"}}),_jsxruntime.jsx.call(void 0, "span",{className:"text-2xs",style:{color:"var(--widget-destructive)"},children:"Quote not found"})]}):_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-2 mt-2",children:[[...Array(4)].map((i,m)=>_jsxruntime.jsx.call(void 0, "div",{className:"h-3 rounded animate-pulse",style:{backgroundColor:"var(--widget-muted)",width:m%2===0?"80%":"60%",opacity:.5}},m)),_jsxruntime.jsx.call(void 0, "span",{className:"text-2xs mt-1",style:{color:"var(--widget-muted-foreground)",opacity:.5},children:"Enter an amount"})]})]})})]})},Ct= exports.default =tt;exports.default = Ct;
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
"use client";import{e as ne,g as le,h,i as b,j as ce,k as ue,x as pe,y as me}from"./chunk-LHEXDAQ2.js";import{a as ge}from"./chunk-MJMI6IZW.js";import{a as fe}from"./chunk-W63DXT5E.js";import{a as de}from"./chunk-PFQ7GSLH.js";import"./chunk-OPN7WCJR.js";import{e as re}from"./chunk-FWH744XA.js";import{b as oe,d as l}from"./chunk-XCPMBMS7.js";import{O as V,W as ae}from"./chunk-NNNQNB5T.js";import{a as ie}from"./chunk-46H44R7V.js";import"./chunk-73CB2I7U.js";import{useCallback as f,useEffect as ve,useMemo as Ze,useRef as xe,useState as H}from"react";import{useShallow as et}from"zustand/react/shallow";import{Fragment as q,jsx as e,jsxs as t}from"react/jsx-runtime";var we=()=>{},tt=({onSwapSubmitted:he,onSwapComplete:be,onSwapInitiated:Se,onBackToSwap:E,onMoreChainsClick:st})=>{let{web3ConnectionType:ot,hasConnectHandler:ye,lockBase:R,lockQuote:F,disableInverting:Ce,swapButtonVariant:I,tokenDisplay:j,tokenBadgeOrientation:A,widgetType:Ne,assetMenuVariant:ke}=oe(),{effectiveInputTokens:Ae,effectiveOutputTokens:Pe}=de(),S=Ae.length===1,y=Pe.length===1,z=j==="pill"||j==="ghost",P=Ne==="compact",{baseToken:d,quoteToken:c,baseAmount:a,quoteAmount:n,isBaseGasToken:Te,isQuoteGasToken:Oe,isWrappingPair:u,isUnwrappingPair:p,baseBalance:w,setBaseAmount:k,setQuoteAmount:g,swapTokens:G,clearForm:L}=re(),{handleInputChange:M,ensureForParams:_,clear:C,refresh:J,liquidityError:qe,routingError:Re}=ne(),{address:v}=ie(),{openConnectModal:Fe}=le(),{isRecipientInputOpen:$,txStatus:K,view:x,selectedChainFilterChainId:Ie}=l(et(i=>({isRecipientInputOpen:i.isRecipientInputOpen,txStatus:i.txStatus,view:i.view,selectedChainFilterChainId:i.selectedChainFilterChainId??null}))),[T,Me]=H(null),[O,X]=H(null),$e=xe(!1),r=!1,We=Ze(()=>!d||!c||typeof a!="number"||!n||!v||parseFloat(w.formatted)<a?null:{base:d,quote:c,baseAmount:a,quoteAmount:n,userAddress:v},[d,c,a,n,v,w.formatted]),Be=f(i=>{X(i),l.getState().startTracking(i)},[]),De=f(()=>{$e.current=!0,J()},[J]);ve(()=>{if(T===null&&!(!d||!c)){if(!a||a<=0){M({amount:null,inputToken:d,outputToken:c,setOutputAmount:g});return}if(u||p){g(a);return}M({amount:a,inputToken:d,outputToken:c,setOutputAmount:g})}},[T,a,d,c,u,p,M,g]);let Y=a&&n&&parseFloat(n.toString())?parseFloat(a.toString())/parseFloat(n.toString()):0,W=f(()=>{l.getState().setView("baseSelection")},[]),B=f(()=>{l.getState().setView("quoteSelection")},[]),Qe=f(()=>{C(),G(),k(null),g(null)},[C,G,k,g]),Ue=f(()=>{if(!w.formatted||!d||!c)return;let i=parseFloat(w.formatted);if(!i||i<=0)return;let m=i*.9999999999;u||p?(k(m),g(m),C()):(k(m),g(null),_({inputToken:d,outputToken:c,inputAmount:m.toString(),setOutputAmount:N=>g(N)}))},[w.formatted,d,c,u,p,k,g,C,_]),Ve=f(()=>{C(),L()},[C,L]),Z=w.formatted?parseFloat(w.formatted):null,He=!!(a||n),s=d,o=c,Ee=s?.price&&a?`$${(s.price*a).toFixed(2)}`:"$0.00",je=o?.price&&n?`$${(o.price*n).toFixed(2)}`:"$0.00",ze=!!(s&&o&&a&&n),Ge=qe||Re,ee=T==="trackingTx"&&!!O&&!!s&&!!o&&!!a&&!!n,D=ke==="split",Q=D&&(x==="baseSelection"||x==="quoteSelection"||x==="baseChainSelection"||x==="quoteChainSelection"),U=x==="baseSelection"||x==="baseChainSelection"?"base":"quote",Le=U==="base"?o:s,te=xe(null),[_e,Je]=H(380);ve(()=>{if(!D)return;let i=te.current;if(!i)return;let m=new ResizeObserver(N=>{for(let Ye of N)Je(Ye.contentRect.height)});return m.observe(i),()=>m.disconnect()},[D]);let Ke=f(i=>{let N=l.getState().view==="baseChainSelection"?"base":"quote";l.getState().setChainFilter({chainId:i,side:N}),l.getState().pushRecentChain(i),l.getState().transitionToView(N==="base"?"baseSelection":"quoteSelection","chainSelection")},[]),Xe=f(()=>{let i=l.getState().view;i==="baseSelection"?l.getState().transitionToView("baseChainSelection","chainSelection"):i==="quoteSelection"&&l.getState().transitionToView("quoteChainSelection","chainSelection")},[]),se={backgroundColor:I==="default"?"var(--widget-primary)":"transparent",color:I==="default"?"var(--widget-primary-foreground)":"var(--widget-primary)",border:I!=="default"?"1px solid var(--widget-primary)":"none",borderRadius:"var(--widget-radius)"};return t("div",{className:"flex flex-row w-full",children:[t("div",{ref:te,className:"flex flex-col flex-1 min-w-0",style:{borderRight:"1px solid var(--widget-border)"},children:[ee&&O&&s&&o&&a&&n?e("div",{className:"flex-1 min-h-0 overflow-hidden",children:e(me,{orderHash:O,base:s,quote:o,baseAmount:a,quoteAmount:n,status:K})}):t(q,{children:[t("div",{className:`relative ${P?"px-4 pt-3 pb-1":"px-4 pt-4 pb-2"}`,style:{borderBottom:"1px solid var(--widget-border)"},children:[z?P?t("div",{className:`flex items-center gap-2 ${A==="right"?"flex-row-reverse":"flex-row"}`,children:[e(b,{toggle:W,side:"base",asset:s,isPlacingOrder:r||R||S,hideDropdown:S}),e("div",{className:"flex-1 min-w-0",children:e(h,{side:"base",asset:s??null,otherAsset:o??null,isPlacingOrder:r,isWrappingPair:u,isUnwrappingPair:p})})]}):t("div",{className:`flex flex-col ${A==="right"?"items-end":"items-start"}`,children:[e(b,{toggle:W,side:"base",asset:s,isPlacingOrder:r||R||S,hideDropdown:S}),e(h,{side:"base",asset:s??null,otherAsset:o??null,isPlacingOrder:r,isWrappingPair:u,isUnwrappingPair:p})]}):t(q,{children:[e(b,{toggle:W,side:"base",asset:s,isPlacingOrder:r||R||S,hideDropdown:S}),e(h,{side:"base",asset:s??null,otherAsset:o??null,isPlacingOrder:r,isWrappingPair:u,isUnwrappingPair:p})]}),t("div",{className:"mb-1 flex w-full flex-row items-center justify-between",children:[e("p",{className:"font-sans text-sm",style:{color:"var(--widget-muted-foreground)"},children:Ee}),v&&Z!==null&&Z>0&&e("button",{type:"button",onClick:Ue,disabled:r,className:"absolute bottom-3 right-4 flex items-center rounded-full px-3 py-0.5 text-xs font-medium uppercase cursor-pointer disabled:opacity-40 bg-(--widget-primary) text-(--widget-primary-foreground) hover:bg-(--widget-foreground) hover:text-(--widget-card) transition-colors",children:"Max"})]})]}),!Ce&&e("div",{className:"flex justify-center -my-4 relative z-10",children:e("button",{type:"button",onClick:Qe,"aria-label":"Swap input and output tokens",className:"flex h-8 w-8 items-center justify-center rounded-full cursor-pointer bg-(--widget-card) text-(--widget-muted-foreground) hover:bg-(--widget-secondary) hover:text-(--widget-foreground) transition-colors",style:{border:"1px solid var(--widget-border)"},children:e(ue,{className:"w-3.5 h-3.5"})})}),t("div",{className:`relative ${P?"px-4 pt-4 pb-1":"px-4 pt-6 pb-2"}`,children:[z?P?t("div",{className:`flex items-center gap-2 ${A==="right"?"flex-row-reverse":"flex-row"}`,children:[e(b,{toggle:B,side:"quote",asset:o,isPlacingOrder:r||F||y,hideDropdown:y}),e("div",{className:"flex-1 min-w-0",children:e(h,{side:"quote",asset:o??null,otherAsset:s??null,isPlacingOrder:r,isWrappingPair:u,isUnwrappingPair:p})})]}):t("div",{className:`flex flex-col ${A==="right"?"items-end":"items-start"}`,children:[e(b,{toggle:B,side:"quote",asset:o,isPlacingOrder:r||F||y,hideDropdown:y}),e(h,{side:"quote",asset:o??null,otherAsset:s??null,isPlacingOrder:r,isWrappingPair:u,isUnwrappingPair:p})]}):t(q,{children:[e(b,{toggle:B,side:"quote",asset:o,isPlacingOrder:r||F||y,hideDropdown:y}),e(h,{side:"quote",asset:o??null,otherAsset:s??null,isPlacingOrder:r,isWrappingPair:u,isUnwrappingPair:p})]}),t("div",{className:"flex w-full flex-row items-center justify-between",children:[e("p",{className:"font-sans text-sm",style:{color:"var(--widget-muted-foreground)"},children:je}),He&&e("button",{type:"button",onClick:Ve,disabled:r,className:"absolute bottom-2 right-4 flex items-center rounded-full px-3 py-0.5 text-xs font-medium uppercase cursor-pointer disabled:opacity-40 text-(--widget-muted-foreground) hover:bg-(--widget-secondary) transition-colors",children:"Clear"})]})]})]}),e("div",{className:"flex flex-row items-center w-full overflow-hidden",style:{borderTop:$?"1px solid var(--widget-border)":"none",maxHeight:$?"60px":"0px",opacity:$?1:0,transition:"max-height 0.3s ease, opacity 0.3s ease"},children:e(ce,{})}),e("div",{className:`relative ${ee?"px-0":"px-4"} py-4`,children:v&&s&&o&&a&&a>0?e(pe,{base:s,baseAmount:a,quote:o,quoteAmount:n??0,userAddress:v,isWrappingPair:u,isUnwrappingPair:p,isBaseGasToken:Te,isQuoteGasToken:Oe,reviewActionProps:We,reviewState:T,setReviewState:Me,trackedOrderHash:O,setTrackedOrderHash:X,onSwapSubmitted:he,onSwapComplete:be,onSwapInitiated:Se,onOrderSubmitted:Be,onStaleQuoteRestart:De,txStatus:K}):!v&&ye?e("button",{onClick:()=>Fe(),className:"w-full py-3 text-sm font-medium cursor-pointer transition-opacity hover:opacity-80",style:se,children:"Connect Wallet"}):e("button",{disabled:!0,className:"w-full py-3 text-sm font-medium transition-colors disabled:opacity-40 cursor-not-allowed",style:se,children:v?"Enter Amount":"Connect Wallet"})})]}),e("div",{className:`flex flex-col transition-all duration-300 ${Q?"flex-1 min-w-0":"w-48 shrink-0"}`,style:{backgroundColor:"var(--widget-background)",...Q?{height:`${_e}px`}:{}},children:Q?e("div",{className:"flex flex-col overflow-hidden p-2",style:{height:"100%"},children:x==="baseChainSelection"||x==="quoteChainSelection"?e(fe,{toggle:E??we,side:U,onChainSelect:Ke}):e(ge,{toggle:E??we,side:U,otherAsset:Le,onMoreChainsClick:Xe,selectedChainFilter:Ie})}):t("div",{className:"flex flex-col gap-3 px-4 py-4",children:[e("span",{className:"text-2xs uppercase tracking-wider font-medium",style:{color:"var(--widget-muted-foreground)"},children:"Quote Details"}),ze&&s&&o?t(q,{children:[t("div",{className:"flex flex-col gap-0.5",children:[e("span",{className:"text-2xs",style:{color:"var(--widget-muted-foreground)"},children:"Rate"}),t("div",{className:"flex items-center gap-1",children:[e(V,{asset:o,size:"3xs",noChain:!0}),t("span",{className:"font-sans text-xs uppercase",children:["1 ",o.symbol]})]}),e("div",{className:"flex items-center gap-1 pl-4",children:t("span",{className:"text-2xs",style:{color:"var(--widget-muted-foreground)"},children:["= ",Y.toFixed(6)]})}),t("div",{className:"flex items-center gap-1 pl-4",children:[e(V,{asset:s,size:"3xs",noChain:!0}),e("span",{className:"font-sans text-xs uppercase",children:s.symbol})]})]}),t("div",{className:"flex flex-col gap-2",style:{borderTop:"1px solid var(--widget-border)",paddingTop:"0.5rem"},children:[t("div",{className:"flex justify-between items-center",children:[e("span",{className:"text-2xs",style:{color:"var(--widget-muted-foreground)"},children:"USD Value"}),t("span",{className:"font-sans text-xs",children:["$",s.price?(s.price*Y*parseFloat(n.toString())).toFixed(2):"\u2014"]})]}),t("div",{className:"flex justify-between items-center",children:[e("span",{className:"text-2xs",style:{color:"var(--widget-muted-foreground)"},children:"Order Type"}),e("span",{className:"text-2xs font-sans",style:{color:"var(--widget-foreground)"},children:"RFQ"})]}),t("div",{className:"flex justify-between items-center",children:[e("span",{className:"text-2xs",style:{color:"var(--widget-muted-foreground)"},children:"Fill"}),e("span",{className:"text-2xs",style:{color:"var(--widget-primary)"},children:"Exact"})]}),s.chainId!==o.chainId&&t("div",{className:"flex justify-between items-center",children:[e("span",{className:"text-2xs",style:{color:"var(--widget-muted-foreground)"},children:"Route"}),e("span",{className:"text-2xs font-sans",children:"Cross-chain"})]})]})]}):Ge?t("div",{className:"flex flex-col gap-1",children:[e(ae,{className:"h-6 w-6",style:{color:"var(--widget-destructive)"}}),e("span",{className:"text-2xs",style:{color:"var(--widget-destructive)"},children:"Quote not found"})]}):t("div",{className:"flex flex-col gap-2 mt-2",children:[[...Array(4)].map((i,m)=>e("div",{className:"h-3 rounded animate-pulse",style:{backgroundColor:"var(--widget-muted)",width:m%2===0?"80%":"60%",opacity:.5}},m)),e("span",{className:"text-2xs mt-1",style:{color:"var(--widget-muted-foreground)",opacity:.5},children:"Enter an amount"})]})]})})]})},Ct=tt;export{Ct as default};
|
package/dist/chunk-LHEXDAQ2.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import{a as Ir}from"./chunk-OPN7WCJR.js";import{e as Ue}from"./chunk-FWH744XA.js";import{b as Ie,c as Lt,d as ee}from"./chunk-XCPMBMS7.js";import{E as Qe,F as it,H as $t,I as Pt,J as ct,N as ve,O as te,P as Z,S as be,T as Ut,U as We,V as X,X as Mt,Y as _e,a as qe,c as Q,h as st,k as Oe,m as $e,o as Pe,q as Nt,r as se,s as Et,t as ot,v as at,w as It,x as Ot}from"./chunk-NNNQNB5T.js";import{a as oe}from"./chunk-46H44R7V.js";import{b as Er}from"./chunk-73CB2I7U.js";import{useQueryClient as Or}from"@tanstack/react-query";import{useCallback as $r,useEffect as Vt,useRef as Dt}from"react";function Pr(e){if(e.length===0)return 5e3;let l=Math.max(...e.map(s=>Q(s)?.blockTimeMs??2e3));return Math.min(5e3,Math.max(1e3,l*2+1e3))}var Ur=()=>{let{address:e}=oe(),t=Lt(),n=Or(),c=Dt(null),l=Dt(!0),s=$r(a=>{if(!e)return;let y=[...new Set(a.tokens.map(d=>d.asset.chainId))],p=Pr(y);c.current&&(clearTimeout(c.current),c.current=null),c.current=setTimeout(async()=>{if(c.current=null,!!l.current)try{let d=a.tokens.map(w=>({chainId:w.asset.chainId,tokenAddress:w.asset.address})),o=await Pt(e,d);if(o.balances.length===0)return;if(a.tokens.length>=2){let w=a.tokens[0].asset,u=a.tokens[1].asset,h=ct.swap(e,w.chainId,w.address,u.chainId,u.address);n.setQueryData(h,o)}let r=ct.bulk(e,t),v=n.getQueryData(r);if(v){let w=v.balances.map(u=>o.balances.find(m=>m.chainId===u.chainId&&m.token.toLowerCase()===u.token.toLowerCase())??u);for(let u of o.balances)w.some(h=>h.chainId===u.chainId&&h.token.toLowerCase()===u.token.toLowerCase())||w.push(u);for(let u of a.tokens)if(!o.balances.some(m=>m.chainId===u.asset.chainId&&m.token.toLowerCase()===u.asset.address.toLowerCase())){let m=w.findIndex(i=>i.chainId===u.asset.chainId&&i.token.toLowerCase()===u.asset.address.toLowerCase());m!==-1&&(w[m]={...w[m],balance:"0",shiftedBalance:"0"})}n.setQueryData(r,{balances:w})}}catch{}},p)},[e,t,n]);return Vt(()=>(l.current=!0,()=>{l.current=!1,c.current&&(clearTimeout(c.current),c.current=null)}),[]),{triggerBalanceUpdate:s}},lt=class extends EventTarget{emit(t){this.dispatchEvent(new CustomEvent("balance-update",{detail:t}))}},ut=new lt,Me=()=>e=>ut.emit(e),gs=()=>{let{triggerBalanceUpdate:e}=Ur();Vt(()=>{let t=n=>{e(n.detail)};return ut.addEventListener("balance-update",t),()=>ut.removeEventListener("balance-update",t)},[e])};import{createContext as Mr,useCallback as pe,useContext as Lr,useEffect as Wt,useMemo as Dr,useRef as ae,useState as Re}from"react";import{formatUnits as Vr,parseUnits as Wr}from"viem";import{jsx as Qr}from"react/jsx-runtime";var Ft=Mr(void 0),_t=1e4,_r=3e4,Fr=1e3,Br=2;function qr(e){return e.find(n=>n.routeSteps?.[0]?.type==="AORI_V1")??e[0]}var Ss=({children:e,recipient:t})=>{let{address:n}=oe(),c=t||n,[l,s]=Re("idle"),[a,y]=Re("idle"),[p,d]=Re(null),[o,r]=Re(null),[v,w]=Re(!1),[u,h]=Re(!1),[m,i]=Re(!1),g=ae(null),S=ae(null),f=ae(null),A=ae(null),O=ae(null),b=ae(0),$=ae(0),D=ae(0),E=ae(!1),I=ae(new Map),P=pe(()=>{f.current&&clearTimeout(f.current),A.current&&clearTimeout(A.current),O.current&&clearTimeout(O.current),f.current=null,A.current=null,O.current=null},[]),U=pe(()=>{P(),g.current=null,b.current=0,s(()=>E.current?"fresh":"idle")},[P]),V=pe(()=>{U(),S.current=null,d(null),r(null),w(!1),h(!1),i(!1),I.current.clear(),s("idle"),y("idle")},[U]),G=pe(T=>{if(!T)return;A.current&&clearTimeout(A.current);let x=Math.max(0,T+_r-Date.now());A.current=setTimeout(()=>{s(L=>L==="idle"?"idle":"stale")},x)},[]),re=pe(async(T,x)=>{let{inputToken:L,outputToken:N,inputAmount:q,setOutputAmount:J}=T;if(!L||!N||!q||parseFloat(q)<=0||Date.now()-($.current||0)<_t-10)return;let Se=++b.current;try{if(!L?.decimals||!N?.decimals)return;let K=it(L.chainId)||Q(L.chainId)?.key||"",ie=it(N.chainId)||Q(N.chainId)?.key||"";if(!K||!ie)throw new Error("Unknown chain");let ne=Wr(q.toString(),L.decimals).toString(),ce={srcChainKey:K,dstChainKey:ie,srcTokenAddress:at(L.address),dstTokenAddress:at(N.address),amount:ne,srcWalletAddress:n||"0x0000000000000000000000000000000000000000",dstWalletAddress:c||n||"0x0000000000000000000000000000000000000000",options:{amountType:"EXACT_SRC_AMOUNT",feeTolerance:{type:"PERCENT",amount:2}}};$.current=Date.now();let le=await fetch(`${Oe()}/quotes`,{method:"POST",headers:$e(),body:JSON.stringify(ce),signal:AbortSignal.timeout(15e3)});if(!le.ok){let Ee=(await le.json().catch(()=>({})))?.message||le.statusText;throw Object.assign(new Error(Ee),{status:le.status})}let ue=await le.json();if(Se!==b.current||g.current!==x)return;let Te=ue.quotes??[],de=qr(Te);if(!de)throw Object.assign(new Error("No quotes returned"),{emptyQuotes:!0});let Ve=Number(Vr(Nt(de.dstAmount),N.decimals));typeof J=="function"&&J(Ve),de._receivedAt=Date.now(),d(de),r(null),w(!1),s("fresh"),G(de._receivedAt),x&&I.current.delete(x)}catch(K){if(Se!==b.current||g.current!==x)return;let ie=K?.status,ne=K instanceof Error?K.message:"",ce=!!K?.emptyQuotes;if((ie===400||ce||ne.includes("Quote request failed"))&&x){let ue=(I.current.get(x)||0)+1;if(I.current.set(x,ue),ue>=Br){h(!0),P(),g.current=null;return}}if(ne.toLowerCase().includes("order cap exceeded")){i(!0),P(),g.current=null;return}if(ne.toLowerCase().includes("insufficient executor balance")){w(!0),P(),g.current=null;return}r(K instanceof Error?K.message:"Unknown error")}},[n,c,G,P]),M=pe((T,x)=>{P(),S.current=T,$.current=0,I.current.delete(x),w(!1),h(!1),i(!1),r(null),s("polling");let L=async()=>{g.current===x&&(await re(T,x),g.current===x&&(f.current=setTimeout(L,_t)))};L()},[P,re]),k=pe(T=>{if(!T?.inputToken||!T?.outputToken||!T?.inputAmount||parseFloat(T.inputAmount)<=0){U();return}let x=S.current;if(x&&x.inputToken?.address===T.inputToken?.address&&x.inputToken?.chainId===T.inputToken?.chainId&&x.outputToken?.address===T.outputToken?.address&&x.outputToken?.chainId===T.outputToken?.chainId&&x.inputAmount===T.inputAmount&&g.current)return;let N=Date.now();if(N-D.current<100)return;D.current=N;let q=`${Date.now()}-${Math.random().toString(36).slice(2)}`;g.current=q,M(T,q)},[M,U]),_=pe(({amount:T,inputToken:x,outputToken:L,setOutputAmount:N})=>{N(null),O.current&&clearTimeout(O.current),!T||T===0?(y("idle"),U(),d(null),r(null),w(!1),h(!1),i(!1)):(y("typing"),U(),d(null),w(!1),h(!1),i(!1),r(null),O.current=setTimeout(()=>{y("settled"),x&&L&&T>0&&k({inputToken:x,outputToken:L,inputAmount:T.toString(),setOutputAmount:N})},Fr))},[U,k]),B=pe(()=>{let T=S.current;if(!T)return;d(null);let x=`${Date.now()}-${Math.random().toString(36).slice(2)}`;g.current=x,s("refreshing"),typeof T.setOutputAmount=="function"&&T.setOutputAmount(null),M(T,x)},[M]);Wt(()=>{E.current=!!p},[p]),Wt(()=>()=>P(),[P]);let z=Dr(()=>({status:l,inputState:a,rfqQuote:p,error:o,liquidityError:v,routingError:u,sizeCapError:m,ensureForParams:k,stop:U,refresh:B,clear:V,handleInputChange:_}),[l,a,p,o,v,u,m,k,U,B,V,_]);return Qr(Ft.Provider,{value:z,children:e})},ze=()=>{let e=Lr(Ft);if(e===void 0)throw new Error("useRfq must be used within an RfqProvider");return e};import{createContext as zr,useContext as jr}from"react";var Hr=zr({openConnectModal:()=>{}}),ks=()=>jr(Hr);import{useCallback as dt,useEffect as Le,useRef as je,useState as pt}from"react";import{jsx as De,jsxs as Xr}from"react/jsx-runtime";var Gr=20,Kr=({side:e,asset:t,otherAsset:n,isPlacingOrder:c,isWrappingPair:l,isUnwrappingPair:s})=>{let{baseAmount:a,quoteAmount:y,setBaseAmount:p,setQuoteAmount:d}=Ue(),{amountInputVariant:o,hideAmountInputSymbol:r,widgetType:v}=Ie(),w=v==="compact",[u,h]=e==="base"?[p,d]:[d,p],m=!t||e==="quote"||c,i=w?32:o==="default"?64:32,[g,S]=pt(i),[f,A]=pt(""),O=je(null),b=je(null),$=je(null),D=je(null),E="USD",I=e==="base"?a:y,[P,U]=pt(!1),V=dt(()=>{if(o!=="default"){S(i);return}if(!O.current||!b.current||!$.current)return;let M=O.current.offsetWidth,k=20,_=i;for(;_>20&&(b.current.style.fontSize=`${_}px`,$.current.style.fontSize=`${_}px`,!(b.current.offsetWidth+$.current.offsetWidth+k<=M));)_-=1;S(_)},[o,i]),G=dt(M=>{M.key==="."&&f.includes(".")&&M.preventDefault()},[f]),re=dt(M=>{let k=M.target.value;if(k==="."&&(k="0."),!/^\d*\.?\d*$/.test(k)||(k.match(/\./g)||[]).length>1)return;if(k.length>1&&k[0]==="0"&&k[1]!=="."&&(k=k.replace(/^0+/,"")||"0"),t?.decimals!==void 0&&k.includes(".")){let[,B]=k.split(".");if(B&&B.length>t.decimals)return}if(k.length>Gr)return;A(k);let _=parseFloat(k);k!==f&&(k===""||k==="0."||k.endsWith(".")?(u(null),e==="base"&&h(null)):!Number.isNaN(_)&&_>=0&&u(_),e==="base"&&d(null),(s||l)&&d(_||0))},[f,u,e,d,t?.decimals,h,s,l]);return Le(()=>{let M=B=>{if(B===null)return"";let z=t?.decimals;if(z===void 0)return"";let T=B.toString();if(/e/i.test(T)&&(T=Number(B).toLocaleString("en-US",{useGrouping:!1,maximumFractionDigits:z})),T.includes(".")){let[x,L]=T.split("."),N=L.slice(0,z);return N?`${x}.${N}`:x}return T};if(I===null){f==="0."||f!==""&&f.endsWith(".")||A("");return}if(!m&&(f.endsWith(".")||f.match(/\.\d*0$/)||f==="0"||f==="0.")&&f!=="")return;let _=parseFloat(f)||0;(f===""||Math.abs(_-I)>1e-10)&&A(M(I))},[I,t?.decimals,f,m]),Le(()=>{V()},[f,V]),Le(()=>{U(!0)},[]),Le(()=>{P&&V()},[P,V]),Le(()=>{b.current&&D.current&&(D.current.style.width=`${b.current.offsetWidth}px`)},[f]),Le(()=>{if(!P)return;let M=new ResizeObserver(()=>{P&&V()});return O.current&&M.observe(O.current),()=>M.disconnect()},[P,V]),De("div",{ref:O,style:{fontSize:`${g}px`,transition:"font-size 0.05s ease-in-out"},className:`mt-2 box-border font-sans flex ${w?o==="normal"?"h-12 my-1":"h-10 my-0.5":o==="normal"?"h-12 my-1":"h-20 my-1"} w-full flex-row items-center ${m?"cursor-default":"cursor-text"}`,onClick:()=>D.current?.focus(),children:Xr("div",{className:"relative flex w-full items-center",children:[De("label",{htmlFor:`${e}Amount`,className:"sr-only",children:e==="base"?"Input token amount":"Output token amount"}),De("input",{ref:D,type:"text",inputMode:"decimal",placeholder:"0",autoComplete:"off",id:`${e}Amount`,value:f,onWheel:M=>M.target.blur(),onKeyDown:G,onChange:re,style:{transition:"width 0.15s ease-in-out",color:"var(--widget-foreground)",WebkitTextFillColor:"var(--widget-foreground)",opacity:1},className:"flex min-w-[45px] whitespace-nowrap bg-transparent placeholder:opacity-50 font-sans font-thin",disabled:m}),De("span",{style:{transition:"width 0.15s ease-in-out"},ref:b,className:"pointer-events-none absolute flex whitespace-nowrap invisible",children:f||0}),!r&&o!=="normal"&&De("span",{ref:$,className:"ml-2 font-thin uppercase",style:{color:"var(--widget-foreground)",opacity:.5,fontSize:`${g}px`},children:t?.symbol?t.symbol.length>6?`${t.symbol.slice(0,6)}...`:t.symbol:E}),(r||o==="normal")&&De("span",{ref:$,className:"hidden"})]})})},Ps=Kr;import{Fragment as ft,jsx as W,jsxs as fe}from"react/jsx-runtime";var Yr=({toggle:e,side:t,asset:n,isPlacingOrder:c,hideDropdown:l})=>{let{baseBalance:s,quoteBalance:a}=Ue(),{tokenDisplay:y,tokenBadgeOrientation:p,widgetType:d}=Ie(),o=d==="compact",r=o?"h-10":"h-13",v=o?"h-10 w-10":"h-13 w-13",w=t==="base"?s.formatted?(()=>{let h=parseFloat(s.formatted);return h>=1e4?Pe(h):h.toFixed(4)})():void 0:a.formatted?(()=>{let h=parseFloat(a.formatted);return h>=1e4?Pe(h):h.toFixed(4)})():void 0,u={role:"button",tabIndex:c?-1:0,"aria-disabled":c,"aria-label":`Select ${t==="base"?"input":"output"} token${n?`: ${n.symbol}`:""}`,onClick:c?void 0:e,onKeyDown:c?void 0:h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),e())}};return y==="pill"?W("div",{...u,className:`inline-flex items-center gap-1.5 h-7 px-2.5 rounded-full cursor-pointer transition-colors ${p==="right"?"ml-auto":""}`,style:{border:"1px solid var(--widget-border)",backgroundColor:"var(--widget-secondary)",color:"var(--widget-secondary-foreground)"},children:n?fe(ft,{children:[W(ve,{chain:n.chainId,size:"xs"}),W(te,{className:"rounded-full",asset:n,size:"xxs",noChain:!0}),W("span",{className:"text-xs font-thin uppercase",children:n.symbol}),!l&&W(We,{className:"w-1.5 opacity-60",style:{color:"var(--widget-secondary-foreground)"}})]}):fe(ft,{children:[W("span",{className:"text-xs opacity-70",children:"Select"}),!l&&W(We,{className:"w-1.5 opacity-60",style:{color:"var(--widget-secondary-foreground)"}})]})}):y==="ghost"?fe("div",{...u,className:"inline-flex items-center gap-1.5 cursor-pointer transition-opacity hover:opacity-70 py-1",style:{color:"var(--widget-foreground)"},children:[n?fe(ft,{children:[W(ve,{chain:n.chainId,size:"xs"}),W(te,{className:"rounded-full",asset:n,size:"xxs",noChain:!0}),W("span",{className:"text-sm font-thin uppercase",children:n.symbol})]}):W("span",{className:"text-sm",style:{color:"var(--widget-muted-foreground)"},children:"Select token"}),!l&&W(We,{className:"w-1.5 opacity-50"})]}):W("div",{...u,className:`relative ${r} w-full cursor-pointer text-xl duration-100 ease-linear`,style:{border:"1px solid var(--widget-border)",backgroundColor:"var(--widget-secondary)",borderTopLeftRadius:"9999px",borderBottomLeftRadius:"9999px",borderTopRightRadius:"var(--widget-radius)",borderBottomRightRadius:"var(--widget-radius)"},children:W("div",{className:"relative flex h-full w-full flex-row items-center",children:n?fe("div",{className:"relative flex h-full w-full flex-row items-center",children:[W("div",{className:`${v} pl-px flex items-center justify-center`,children:W(te,{className:"rounded-full",asset:n,size:"lg"})}),fe("div",{className:"flex h-full w-full flex-row items-center justify-between pl-2.5 pr-7",children:[fe("div",{className:"flex h-full flex-col justify-center gap-0.5",children:[W("p",{className:"text-base font-thin uppercase",style:{color:"var(--widget-secondary-foreground)"},children:n.symbol}),fe("span",{className:"text-xs font-sans",style:{color:"var(--widget-muted-foreground)"},children:[n.address?.slice(0,6),"...",n.address?.slice(-4)]})]}),w!==void 0&&fe("div",{className:"flex flex-col text-right",children:[W("p",{className:"text-2xs",style:{color:"var(--widget-muted-foreground)"},children:"Balance"}),W("span",{className:"font-sans text-xs tabular-nums",style:{color:"var(--widget-foreground)",opacity:.5},children:w})]})]}),!l&&W(We,{className:"absolute right-3 top-1/2 w-1.5 translate-y-[-50%]",style:{color:"var(--widget-secondary-foreground)",opacity:.6}})]}):W("div",{className:"flex h-full w-full items-center justify-center",children:W("span",{className:"text-sm",style:{color:"var(--widget-secondary-foreground)",opacity:.7},children:"Select token"})})})})},Ws=Yr;var qt=Er(Ir(),1);import{useState as He,useEffect as Ge}from"react";import{jsx as Y,jsxs as Bt}from"react/jsx-runtime";var Jr=()=>{let[e,t]=He(null),[n,c]=He(""),l=Ot(n,1e3),[s,a]=He(!1),[y,p]=He("");Ge(()=>{ee.getState().setRecipient(e)},[e]),Ge(()=>{c(e||"")},[e]);let d=r=>{let v=r.target.value;s&&(a(!1),p(""),t(null)),c(v),v===""&&t(null)};Ge(()=>{l===""||!l?(a(!1),p(""),t(null)):It(l)?(a(!1),p(""),t(l)):(a(!0),p("Invalid wallet address..."),t(null),c(""))},[l]),Ge(()=>{if(s){let r=setTimeout(()=>{t(null),c(""),a(!1),p("")},2e3);return()=>clearTimeout(r)}},[s]);let o=()=>{t(null),c(""),a(!1),p("")};return Y("div",{className:"w-full",children:Bt("div",{className:"relative flex flex-row items-center",children:[Y("input",{type:"password",style:{display:"none"},"aria-hidden":"true",tabIndex:-1}),Y("label",{htmlFor:"recipient-address",className:"sr-only",children:"Recipient wallet address"}),Y("div",{className:"absolute left-3 flex h-6 w-6 items-end justify-center overflow-hidden rounded-full",style:{backgroundColor:"var(--widget-secondary)"},children:e&&!s?Y("img",{className:"h-full w-full rounded-full object-cover",src:(0,qt.makeGradient)(e),alt:"Recipient avatar"}):Y(Ut,{className:"h-5 w-5",style:{color:s?"var(--widget-destructive)":"var(--widget-muted-foreground)"}})}),Y("div",{className:"absolute left-12 top-1.5 -translate-y-1 text-xs font-medium opacity-60",style:{color:s?"var(--widget-destructive)":"var(--widget-muted-foreground)"},"aria-hidden":"true",children:"To:"}),Y("input",{id:"recipient-address",className:"font-sans block h-10 w-full items-center pl-12 pt-4 pr-8 text-xs",style:{backgroundColor:s?"color-mix(in srgb, var(--widget-destructive) 10%, transparent)":"transparent",color:s?"var(--widget-destructive)":"var(--widget-foreground)",outline:"none",opacity:s?.9:1},placeholder:s?y:"Enter recipient address...",value:n,onChange:d,spellCheck:!1,"aria-invalid":s,"aria-describedby":s?"recipient-error":void 0}),s&&Y("span",{id:"recipient-error",className:"sr-only",children:y}),e&&!s&&Bt("button",{type:"button",className:"absolute right-2 top-1/2 -translate-y-1/2 cursor-pointer flex items-center justify-center h-4 w-4 rounded-full transition-colors hover:[color:var(--widget-destructive)]",style:{color:"var(--widget-muted-foreground)"},onClick:o,"aria-label":"Clear recipient",children:[Y("svg",{className:"h-2.5 w-2.5",viewBox:"0 -0.5 21 21",fill:"none",children:Y("g",{fill:"currentColor",fillRule:"evenodd",children:Y("polygon",{points:"375.0183 90 384 98.554 382.48065 100 373.5 91.446 364.5183 100 363 98.554 371.98065 90 363 81.446 364.5183 80 373.5 88.554 382.48065 80 384 81.446",transform:"translate(-363 -80)"})})}),Y("span",{className:"sr-only",children:"Clear recipient"})]})]})})},js=Jr;import{jsx as Qt,jsxs as Zr}from"react/jsx-runtime";function Ks(e){return Zr("svg",{width:"485",height:"484",viewBox:"0 0 485 484",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[Qt("path",{d:"M265.974 52.8127C270.567 50.9299 273.227 53.6338 275.917 56.1595C301.879 80.5364 327.828 104.927 353.786 129.308C380.101 154.024 406.44 178.715 432.721 203.467C436.002 206.557 440.744 209.272 438.226 215.021C435.865 220.415 430.758 219.123 426.424 219.124C305.965 219.169 185.506 219.163 65.0464 219.166C53.0995 219.166 49.0676 215.225 49.0125 203.316C48.9563 191.154 48.9813 178.991 48.9973 166.829C49.0119 155.717 53.3581 151.358 64.4131 151.358C127.892 151.357 191.37 151.364 254.849 151.368C262.591 151.368 262.645 151.344 262.588 143.559C262.388 116.237 262.191 88.914 261.918 61.5922C261.883 58.0834 262.161 54.9042 265.974 52.8127Z",fill:"currentColor"}),Qt("path",{d:"M80.5649 300.432C71.3447 291.747 62.4175 283.264 53.4064 274.87C50.4552 272.122 47.8959 269.327 49.7894 264.946C51.6154 260.72 55.4624 260.923 59.1682 260.923C164.476 260.927 269.785 260.932 375.093 260.935C391.422 260.935 407.752 260.9 424.081 260.933C434.679 260.955 438.994 265.286 439.015 275.854C439.04 288.517 439.048 301.181 439.013 313.845C438.985 324.225 434.466 328.73 424.01 328.732C360.359 328.741 296.707 328.729 233.056 328.714C225.392 328.713 225.368 328.686 225.426 336.583C225.628 363.741 225.815 390.9 226.101 418.057C226.142 421.935 225.905 425.512 221.852 427.329C217.686 429.197 214.934 426.578 212.212 424.02C172.068 386.302 131.922 348.587 91.7738 310.874C88.1374 307.459 84.4753 304.07 80.5649 300.432Z",fill:"currentColor"})]})}var en=["SUCCEEDED","FAILED","COMPLETED","CANCELLED"];async function zt(e,t,n={}){let{onStatusChange:c,onComplete:l,onError:s,interval:a=4e3,timeout:y=3e5,txHash:p,signal:d}=n,o=null,r=Date.now(),v=0,w=8,u=null,h=p?`?txHash=${p}`:"";return new Promise((m,i)=>{let g=async()=>{try{if(d?.aborted){u&&clearTimeout(u),i(new DOMException("Polling aborted","AbortError"));return}if(Date.now()-r>y){u&&clearTimeout(u);let O=new Error("Order status polling timed out");s?.(O),i(O);return}let S=await fetch(`${t}/status/${e}${h}`,{headers:$e(),signal:d});if(S.status===404){u=setTimeout(g,a);return}if(!S.ok)throw new Error(`Failed to fetch order status: ${await S.text()}`);let f=await S.json();if(!f||typeof f!="object"||!f.status)throw new Error(`Invalid status response format: ${JSON.stringify(f)}`);v=0;let A=f.status.toUpperCase();if(A!==o&&(o=A,c?.(f)),en.includes(A)){u&&clearTimeout(u),l?.(f),m(f);return}u=setTimeout(g,a)}catch(S){if(S instanceof Error&&S.name==="AbortError"){u&&clearTimeout(u),i(S);return}if(++v>=w){u&&clearTimeout(u);let f=S instanceof Error?S:new Error(String(S));s?.(f),i(f);return}u=setTimeout(g,a)}};g()})}import{useCallback as Ke,useEffect as tn,useRef as Xe}from"react";function jt(e){let t=e.toUpperCase();return t==="SUCCEEDED"||t==="COMPLETED"?"completed":t==="FAILED"?"failed":t==="CANCELLED"?"cancelled":t==="PROCESSING"?"received":"pending"}var Ht=e=>{let t=Xe(new Map),n=Xe(new Map),c=Xe(new Map),l=Xe(0),s=Ke(()=>++l.current,[]),{address:a}=oe(),y=Me(),p=Ke((r,v)=>{if(t.current.get(r))return;v&&n.current.set(r,v),t.current.set(r,!0);let w=l.current,u=new AbortController;c.current.set(r,u);let h=v?.baseToken?.chainId===1;zt(r,Oe(),{interval:h?1e3:500,timeout:3e5,signal:u.signal,onStatusChange:m=>{if(!m?.status)return;let i=jt(m.status);if(e?.(r,i,m.explorerUrl),i==="completed"&&a){let g=n.current.get(r);if(g&&(g.baseToken||g.quoteToken)){let S=[];g.baseToken&&S.push({asset:g.baseToken,userAddress:a}),g.quoteToken&&S.push({asset:g.quoteToken,userAddress:a}),y({type:"swap",tokens:S})}}["completed","failed","cancelled"].includes(i)&&(t.current.delete(r),n.current.delete(r)),w!==l.current&&(t.current.delete(r),n.current.delete(r))},onComplete:m=>{m?.status&&e?.(r,jt(m.status),m.explorerUrl),t.current.delete(r),n.current.delete(r)},onError:()=>{t.current.delete(r),n.current.delete(r)}}).catch(m=>{m instanceof Error&&m.name==="AbortError"||(t.current.delete(r),n.current.delete(r),c.current.delete(r))})},[a,y,e]),d=Ke(r=>{let v=c.current.get(r);v&&(v.abort(),c.current.delete(r)),s(),t.current.delete(r),n.current.delete(r)},[s]),o=Ke(()=>{for(let r of c.current.values())r.abort();c.current.clear(),s(),t.current.clear(),n.current.clear()},[s]);return tn(()=>()=>o(),[o]),{startPolling:p,stopPolling:d,stopAllPolling:o,isPolling:r=>t.current.has(r)}};function Fe(e){try{let t=new URL(e).pathname.split("/"),n=t[t.length-1];return n&&n.startsWith("0x")?n:null}catch{return null}}import{createContext as rn,useContext as nn}from"react";var sn=rn({registerTransaction:()=>{},enabled:!1}),Gt=()=>nn(sn);import{signTypedData as on}from"viem/actions";function Xt(e){return e instanceof Error?e.name==="UserRejectedRequestError"||e.message.includes("User rejected")||e.message.includes("rejected")||e.message.includes("denied")||e.message.includes("cancelled")||e.message.includes("canceled"):!1}async function Kt(e){if(e.chain?.id)return e.chain.id;let t=e.getChainId?.();return t!=null?await t:null}var an=async(e,t)=>{try{if(await Kt(e)===t)return!0;if(e.request)await e.request({method:"wallet_switchEthereumChain",params:[{chainId:`0x${t.toString(16)}`}]});else if(e.switchChain)await e.switchChain({id:t});else if(e.send)await e.send("wallet_switchEthereumChain",[{chainId:`0x${t.toString(16)}`}]);else throw new Error("Wallet doesn't support chain switching");return await Kt(e)===t}catch(n){throw Xt(n)?new Error("User rejected the chain switch request"):new Error(`Please switch your wallet to the required network (Chain ID: ${t})`)}},Yt=async e=>{let{quote:t,signatureStep:n,userAddress:c,walletClient:l}=e;if(!l)throw new Error("Wallet client not available");if(n.type!=="SIGNATURE"||!n.signature?.typedData)throw new Error("Invalid signature step");try{let s=n.signature.typedData,a={...s.message};for(let o of["inputAmount","outputAmount","startTime","endTime"])a[o]!=null&&(a[o]=BigInt(a[o]));let y=s.domain;if(y.chainId!=null){let o=Number(y.chainId);await an(l,o)}let p=await on(l,{account:c,domain:y,types:s.types,primaryType:s.primaryType,message:a}),d=await fetch(`${Oe()}/submit-signature`,{method:"POST",headers:$e(),body:JSON.stringify({quoteId:t.id,signatures:[p]})});if(!d.ok){let o=await d.json().catch(()=>({}));throw new Error(o?.message||`Submit failed: ${d.status}`)}return{quoteId:t.id,signature:p}}catch(s){throw Xt(s)?new Error("User rejected the signing request"):s instanceof Error&&s.message.includes("chain")?new Error("Chain switching failed. Please manually switch to the correct network."):s}};var Jt="vt_submitted_quotes";var mt=()=>{try{let e=localStorage.getItem(Jt);return e?JSON.parse(e):[]}catch{return[]}},Zt=e=>{try{localStorage.setItem(Jt,JSON.stringify(e))}catch{}},cn=e=>{let t=Date.now(),n=typeof e=="string"?new Date(e).getTime():e>9999999999?e:e*1e3;return t<n+3e4},ln=e=>mt().some(t=>t.quoteId===e),er=(e,t)=>ln(e)?{canSubmit:!1,reason:"Order already submitted"}:cn(t)?{canSubmit:!0}:{canSubmit:!1,reason:"Quote has expired"},tr=(e,t)=>{let n=typeof t=="string"?new Date(t).getTime():t,c=mt();c.push({quoteId:e,submittedAt:Date.now(),createdAt:n}),Zt(c)},rr=()=>{let e=mt(),t=Date.now(),n=300*1e3,c=e.filter(l=>t-l.submittedAt<n);c.length!==e.length&&Zt(c)};import{useMutation as un}from"@tanstack/react-query";import{waitForTransactionReceipt as dn}from"@wagmi/core";import{wethAbi as pn}from"abitype/abis";import{useConfig as fn}from"wagmi";function nr(){let e=fn();return un({mutationFn:async({chainId:t,accountAddress:n,amountRaw:c,writeContractAsync:l})=>{let s=Q(t);if(!s)throw new Error(`No wrapping contract for chain ${t}`);let a=s.wrappedAsset.address,y=await l({abi:pn,functionName:"withdraw",address:a,account:n,args:[c],chainId:t});if((await dn(e,{hash:y,chainId:t,confirmations:1,pollingInterval:4e3})).status!=="success")throw new Error("Unwrap transaction did not get successful receipt");return{success:!0,hash:y}}})}import{useMutation as mn}from"@tanstack/react-query";import{waitForTransactionReceipt as gn}from"@wagmi/core";import{wethAbi as wn}from"abitype/abis";import{useConfig as hn}from"wagmi";function sr(){let e=hn();return mn({mutationFn:async({chainId:t,accountAddress:n,amountRaw:c,writeContractAsync:l})=>{let s=Q(t);if(!s)throw new Error(`No wrapping contract for chain ${t}`);let a=s.wrappedAsset.address,y=await l({abi:wn,functionName:"deposit",address:a,account:n,value:c,chainId:t});if((await gn(e,{hash:y,chainId:t,confirmations:1,pollingInterval:4e3})).status!=="success")throw new Error("Wrap transaction did not get successful receipt");return{success:!0,hash:y}}})}import{useCallback as ge,useEffect as Ne,useRef as Ar,useState as ts}from"react";import{useChainId as rs}from"wagmi";import{useCallback as or,useRef as yn}from"react";function ar(){let{registerTransaction:e,enabled:t}=Gt(),n=yn(new Set),c=or((s,a)=>{!t||n.current.has(s)||(n.current.add(s),e(s,a))},[t,e]),l=or((s,a)=>{!t||n.current.has(s)||(n.current.add(s),e(s,a))},[t,e]);return{trackOrderTransaction:c,trackNativeTransaction:l,txTrackingEnabled:t}}import{useEffect as ir,useState as vn,useCallback as cr,useRef as gt}from"react";import{useAccount as bn,useChainId as xn,useSwitchChain as Cn}from"wagmi";import{jsx as xe,jsxs as wt}from"react/jsx-runtime";var Sn=15e3,Ye="chain",Tn=({needsChainSwitch:e,requiredChain:t,reviewState:n,goToNextStep:c,cancel:l})=>{let s=se(Ye,n),[a,y]=vn("pending"),p=gt(!1),d=gt(!1),o=gt(null),r=xn(),{switchChainAsync:v}=Cn(),{status:w,isReconnecting:u}=bn(),h=cr(()=>{o.current&&(clearTimeout(o.current),o.current=null)},[]),m=cr(async()=>{if(!(p.current||d.current||w!=="connected"||u)){p.current=!0,d.current=!0,y("pending"),o.current=setTimeout(()=>{p.current&&(y("error"),p.current=!1)},Sn);try{await v({chainId:t.chainId}),h(),y("success"),c(Ye,n)}catch{h(),y("error")}finally{p.current=!1}}},[v,w,u,t.chainId,c,n,h]);ir(()=>{p.current||d.current||n===Ye&&a==="pending"&&w==="connected"&&!u&&(e&&r!==t.chainId?m():(y("success"),c(Ye,n)))},[n,a,e,r,t.chainId,w,u,m,c]),ir(()=>()=>h(),[h]);let i=()=>{a==="error"&&(d.current=!1,y("pending"))},g=!s&&a==="error",S=!s&&(a==="pending"||a==="error"),f=g?"var(--widget-status-failed)":"var(--widget-primary)";return wt("div",{className:"flex w-full flex-row justify-between space-x-3",children:[xe("button",{type:"button",className:`inline-flex h-12 w-full items-center justify-center text-sm font-sans font-medium transition duration-150 ${g?"cursor-pointer":"cursor-not-allowed"}`,style:{backgroundColor:`color-mix(in srgb, ${f} 12%, transparent)`,border:`1px solid color-mix(in srgb, ${f} 20%, transparent)`,color:f,borderRadius:"var(--widget-radius)"},onClick:g?i:void 0,children:wt("div",{className:"flex h-10 w-full flex-row items-center space-x-3 px-4",children:[xe(ve,{chain:t.chainId,size:"xs"}),xe("p",{className:"whitespace-nowrap",children:g?"Retry Switch":`Switch to ${t.name}`}),xe("div",{className:"flex flex-1 border-t",style:{borderColor:"var(--widget-border)"}}),wt("div",{className:"flex h-6 w-3 items-center justify-center rounded-full",children:[!s&&a==="pending"&&xe(X,{size:"5"}),(s||a==="success")&&xe(Z,{className:"h-8 w-8"}),g&&xe(be,{className:"h-[12px] w-[12px]"})]})]})}),S&&xe("button",{type:"button",className:"inline-flex h-12 items-center justify-center px-8 text-sm font-sans font-medium transition duration-150 cursor-pointer",style:{backgroundColor:"color-mix(in srgb, var(--widget-status-failed) 12%, transparent)",border:"1px solid color-mix(in srgb, var(--widget-status-failed) 20%, transparent)",color:"var(--widget-status-failed)",borderRadius:"var(--widget-radius)"},onClick:l,children:"Cancel"})]})},lr=Tn;import{waitForTransactionReceipt as gr}from"@wagmi/core";import{useCallback as Je,useEffect as Ze,useState as kn,useRef as mr}from"react";import{erc20Abi as ht,decodeFunctionData as Nn,encodeFunctionData as En}from"viem";import{useAccount as In,useConfig as On,useSendTransaction as $n,useSwitchChain as Pn,useWalletClient as Un}from"wagmi";import{useEffect as ur,useRef as dr,useState as pr}from"react";import{jsx as An}from"react/jsx-runtime";var Rn=({startTime:e,onExpired:t})=>{let[n,c]=pr(30),[l,s]=pr(!1),a=dr(!1),y=dr(t);y.current=t,ur(()=>{a.current=!1},[e]),ur(()=>{let d=()=>{let r=Date.now(),w=(e>9999999999?e:e*1e3)+30*1e3,u=Math.max(0,w-r),h=Math.floor(u/1e3);if(h<=0){c(0),a.current||(a.current=!0,s(!0),y.current());return}c(h),s(!1)};if(l)return;d();let o=setInterval(d,1e3);return()=>clearInterval(o)},[e,l]);let p=d=>{let o=Math.floor(d/60),r=d%60;return`${o.toString().padStart(2,"0")}:${r.toString().padStart(2,"0")}`};return l?null:An("span",{className:"text-xs font-sans",children:p(n)})},fr=Rn;import{jsx as me,jsxs as yt}from"react/jsx-runtime";function Mn(e){return e.name==="UserRejectedRequestError"||e.message.includes("User rejected")||e.message.includes("rejected")||e.message.includes("denied")||e.message.includes("cancelled")||e.message.includes("canceled")}var Ce="signingOrder";async function Ln(e,t,n,c,l){let s=e.transaction?.encoded,a=s?.to??e.to,y=s?.data??e.data,p=s?.value??e.value;if(!a)throw new Error('Transaction step missing "to" address');let d=s?.chainId,o=e.chainKey||l,r=d||(o?Qe(o):void 0);if(!r)throw new Error(`Unknown chain: ${o}`);let v=st()[r],w=await n({account:t,chain:v,to:a,data:y||"0x",value:BigInt(p||"0")});return await gr(c,{hash:w,chainId:r}),w}async function Dn(e,t,n,c,l){let s=e.transaction?.encoded,a=s?.to??e.to,y=s?.data??e.data;if(!(!a||!y))try{let{args:p}=Nn({abi:ht,data:y});if(!p||p.length<2)return;let d=p[0],o=e.chainKey||l.srcChainKey,r=s?.chainId||(o?Qe(o):void 0);if(!r)return;if(await $t(r).readContract({address:a,abi:ht,functionName:"allowance",args:[t,d]})>0n){let u=En({abi:ht,functionName:"approve",args:[d,0n]}),h=st()[r],m=await n({account:t,chain:h,to:a,data:u,value:0n});await gr(c,{hash:m,chainId:r})}}catch{}}var Vn=({base:e,baseAmount:t,quote:n,quoteAmount:c,userAddress:l,reviewState:s,goToNextStep:a,cancel:y,isWrappingPair:p,isUnwrappingPair:d,restartSigningFlow:o,onSwapInitiated:r,onOrderSubmitted:v,onSwapSubmitted:w,startPolling:u,trackNativeTransaction:h})=>{let m=se(Ce,s),[i,g]=kn("idle"),S=mr(!1),f=mr(null),A=On(),{isReconnecting:O}=In(),{rfqQuote:b,stop:$,refresh:D}=ze(),{data:E}=Un({chainId:e.chainId}),{switchChain:I}=Pn(),{sendTransactionAsync:P}=$n(),U=b?._receivedAt??0,V=Je(()=>U?Date.now()>=U+30*1e3:!1,[U]),G=Je(async()=>{if(S.current||i!=="idle")return;if(!b?.id||!b?._receivedAt){g("error");return}if(!er(b.id,b._receivedAt).canSubmit){g("stale");return}S.current=!0;try{if(!E)throw new Error("Wallet client not available");rr();let x=b.userSteps??[],L;for(let N of x)if(N.type==="TRANSACTION"){g("submitting");let q=N.chainKey||b.srcChainKey,J=q?Qe(q):void 0;J&&E.chain?.id!==J&&(await I({chainId:J}),await new Promise(K=>setTimeout(K,800)));let we=(N.transaction?.encoded?.to??N.to)?.toLowerCase(),Se=b.srcToken?.address?.toLowerCase();we&&Se&&we===Se&&await Dn(N,l,P,A,b),L=await Ln(N,l,P,A,b.srcChainKey),h(L,N.description||`Tx on ${q}`)}else N.type==="SIGNATURE"&&(g("signing"),await Yt({quote:b,signatureStep:N,userAddress:l,walletClient:E}));tr(b.id,b._receivedAt),v?.(b.id),u(b.id,{baseToken:e,quoteToken:n}),r?.(),$(),g("success"),a(Ce,s),w?.(b.id)}catch(x){x instanceof Error&&Mn(x),g("error")}finally{S.current=!1}},[i,b,E,e,n,l,$,u,a,s,w,I,P,r,v,h,A]);Ze(()=>{if(s===Ce&&$(),m&&i!=="success"){g("success"),a(Ce,s);return}if(i==="success"){a(Ce,s);return}if(s===Ce&&i==="idle"&&!b?.id){g("refreshingQuote"),D();return}if(s===Ce&&i==="idle"&&E&&!S.current&&!O){let T=b?.id||null;T&&f.current!==T&&(f.current=T,G())}},[m,s,i,E,O,G,a,b?.id,D,$]),Ze(()=>{i==="refreshingQuote"&&b?.id&&g("idle")},[i,b?.id]),Ze(()=>{s!==Ce&&(f.current=null)},[s]),Ze(()=>{let T=setInterval(()=>{V()&&!S.current&&i!=="submitting"&&i!=="success"&&g("stale")},1e3);return()=>clearInterval(T)},[V,i]);let re=()=>{i==="error"&&!S.current&&(f.current=null,g("idle"))},M=Je(()=>{f.current=null,g("refreshingQuote"),D()},[D]),k=Je(()=>{o?o(!0):y()},[o,y]),_=()=>i==="error"?"Retry swap":i==="signing"?"Sign Swap Order":i==="submitting"?"Submitting...":i==="refreshingQuote"?"Refreshing Quote...":i==="stale"?"Quote Stale":"Sign & Submit",B=!m&&(i==="error"||i==="stale"),z=B?"var(--widget-status-failed)":"var(--widget-primary)";return yt("div",{className:"flex w-full flex-row justify-between space-x-3",children:[me("button",{type:"button",className:`inline-flex h-12 w-full items-center justify-center text-sm font-sans font-medium transition duration-150 ${B?"cursor-pointer":"cursor-not-allowed"}`,style:{backgroundColor:`color-mix(in srgb, ${z} 12%, transparent)`,border:`1px solid color-mix(in srgb, ${z} 20%, transparent)`,color:z,borderRadius:"var(--widget-radius)"},onClick:!m&&i==="error"?re:i==="stale"?k:void 0,children:yt("div",{className:"flex h-10 w-full flex-row items-center space-x-3 px-4",children:[me(te,{asset:e,size:"xs",noChain:!0}),me("p",{className:"whitespace-nowrap",children:_()}),me("div",{className:"flex flex-1 border-t",style:{borderColor:"var(--widget-border)"}}),U>0&&i!=="success"&&i!=="error"&&i!=="stale"&&me(fr,{startTime:U,onExpired:()=>g("stale")}),yt("div",{className:"flex h-6 w-3 items-center justify-center rounded-full",children:[!m&&(i==="idle"||i==="signing"||i==="submitting"||i==="refreshingQuote")&&me(X,{size:"5"}),(m||i==="success")&&me(Z,{className:"h-8 w-8"}),!m&&(i==="error"||i==="stale")&&me(be,{className:"h-[12px] w-[12px]"})]})]})}),!m&&(i==="error"||i==="stale")&&me("button",{type:"button",className:"inline-flex h-12 items-center justify-center px-8 text-sm font-sans font-medium transition duration-150 cursor-pointer",style:{backgroundColor:"color-mix(in srgb, var(--widget-status-failed) 12%, transparent)",border:"1px solid color-mix(in srgb, var(--widget-status-failed) 20%, transparent)",color:"var(--widget-status-failed)",borderRadius:"var(--widget-radius)"},onClick:y,children:"Cancel"})]})},wr=Vn;import{useEffect as Wn}from"react";import{jsx as j,jsxs as vr}from"react/jsx-runtime";var _n=()=>vr("svg",{className:"w-3 h-3 shrink-0",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[j("path",{d:"M18 13V19C18 20.1046 17.1046 21 16 21H5C3.89543 21 3 20.1046 3 19V8C3 6.89543 3.89543 6 5 6H11",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),j("path",{d:"M15 3H21V9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),j("path",{d:"M10 14L21 3",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),Fn="trackingTx",hr={pending:{icon:j(X,{size:"5"}),buttonText:"Trade Pending",showNewSwap:!1,statusVar:"var(--widget-primary)",clickable:!1},received:{icon:j(X,{size:"5"}),buttonText:"Trade Received",showNewSwap:!1,statusVar:"var(--widget-primary)",clickable:!1},completed:{icon:j(Z,{className:"h-5 w-5"}),buttonText:"View Transaction",showNewSwap:!1,statusVar:"var(--widget-status-completed)",clickable:!0},failed:{icon:j(_e,{}),buttonText:"Retry Swap",showNewSwap:!0,statusVar:"var(--widget-status-failed)",clickable:!0},cancelled:{icon:j(_e,{}),buttonText:"View Transaction",showNewSwap:!1,statusVar:"var(--widget-status-failed)",clickable:!0}},Bn=({orderHash:e,base:t,quote:n,baseAmount:c,quoteAmount:l,reviewState:s,onNewSwap:a,onRetry:y,status:p})=>{let d=se(Fn,s),o=hr[p]||hr.pending,r=ee(u=>u.explorerUrl);Wn(()=>{if(p==="completed"){let u=setTimeout(a,15e3);return()=>clearTimeout(u)}},[p,a]);let v=()=>{p==="failed"?y():(p==="completed"||p==="cancelled")&&r&&window.open(r,"_blank","noopener,noreferrer")},w=o.statusVar;return j("div",{className:"flex flex-row justify-between space-x-3 w-full px-4",children:j("button",{type:"button",className:`inline-flex h-12 w-full items-center justify-center text-sm font-sans font-medium transition duration-150 ${o.clickable?"cursor-pointer":"cursor-not-allowed"}`,style:{backgroundColor:`color-mix(in srgb, ${w} 12%, transparent)`,border:`1px solid color-mix(in srgb, ${w} 20%, transparent)`,color:w,borderRadius:"var(--widget-radius)"},onClick:o.clickable?v:void 0,children:vr("div",{className:"flex h-10 w-full flex-row items-center space-x-3 px-4",children:[j("div",{className:"flex h-6 w-6 items-center justify-center rounded-full overflow-hidden shrink-0",children:o.icon}),j("p",{className:"whitespace-nowrap",children:o.buttonText}),j("div",{className:"flex flex-1 border-t",style:{borderColor:"var(--widget-border)"}}),o.clickable&&j("div",{className:"flex h-6 w-6 items-center justify-center",children:p==="failed"?j(Mt,{}):j(_n,{})})]})})})},yr=Bn;import{useCallback as br,useEffect as xr,useState as qn,useRef as vt}from"react";import{parseUnits as Qn}from"viem";import{useAccount as zn,useWriteContract as jn}from"wagmi";import{jsx as Ae,jsxs as bt}from"react/jsx-runtime";var Hn=15e3,et="unwrapping",Gn=({needsToUnwrap:e,amount:t,chainId:n,token:c,reviewState:l,setReviewState:s,goToNextStep:a,cancel:y,delayedClose:p})=>{let d=se(et,l),[o,r]=qn("idle"),v=nr(),{writeContractAsync:w}=jn(),{address:u}=oe(),h=Me(),m=vt(!1),i=vt(!1),g=vt(null),{status:S}=zn(),f=br(()=>{g.current&&(clearTimeout(g.current),g.current=null)},[]),A=br(async()=>{if(!(m.current||i.current||!u||S!=="connected")){m.current=!0,i.current=!0,r("pending"),g.current=setTimeout(()=>{m.current&&(r("error"),m.current=!1)},Hn);try{let E=Q(n);if(!E)throw new Error(`No config for chain ${n}`);let I=E.wrappedAsset.decimals??E.nativeAsset.decimals,P=Qn(t.toString(),I);await v.mutateAsync({chainId:n,accountAddress:u,amountRaw:P,writeContractAsync:w});let U={symbol:E.nativeAsset.symbol,name:E.nativeAsset.name,address:qe,decimals:E.nativeAsset.decimals,chainId:n},V={symbol:E.wrappedAsset.symbol,name:E.wrappedAsset.name,address:E.wrappedAsset.address,decimals:E.wrappedAsset.decimals,chainId:n};h({type:"unwrap",tokens:[{asset:U,userAddress:u},{asset:V,userAddress:u}]}),f(),r("success"),a(et,l),await p()}catch{f(),r("error")}finally{m.current=!1}}},[u,S,n,t,v,w,h,a,l,p,f]);xr(()=>{m.current||i.current||l===et&&o==="idle"&&S==="connected"&&(e?A():(r("success"),a(et,l)))},[l,o,e,S,A,a]),xr(()=>()=>f(),[f]);let O=()=>{o==="error"&&(i.current=!1,r("idle"))},b=!d&&o==="error",$=!d&&(o==="pending"||o==="idle"||o==="error"),D=b?"var(--widget-status-failed)":"var(--widget-primary)";return bt("div",{className:"flex w-full flex-row justify-between space-x-3",children:[Ae("button",{type:"button",className:`inline-flex h-12 w-full items-center justify-center text-sm font-sans font-medium transition duration-150 ${b?"cursor-pointer":"cursor-not-allowed"}`,style:{backgroundColor:`color-mix(in srgb, ${D} 12%, transparent)`,border:`1px solid color-mix(in srgb, ${D} 20%, transparent)`,color:D,borderRadius:"var(--widget-radius)"},onClick:b?O:void 0,children:bt("div",{className:"flex h-10 w-full flex-row items-center space-x-3 px-4",children:[Ae("p",{className:"whitespace-nowrap",children:b?"Retry Unwrap":c?`Unwrap ${c.symbol}`:"Unwrap Native Token"}),Ae("div",{className:"flex flex-1 border-t",style:{borderColor:"var(--widget-border)"}}),bt("div",{className:"flex h-6 w-3 items-center justify-center rounded-full",children:[!d&&(o==="pending"||o==="idle")&&Ae(X,{size:"5"}),(d||o==="success")&&Ae(Z,{className:"h-8 w-8"}),b&&Ae(be,{className:"h-[12px] w-[12px]"})]})]})}),$&&Ae("button",{type:"button",className:"inline-flex h-12 items-center justify-center px-8 text-sm font-sans font-medium transition duration-150 cursor-pointer",style:{backgroundColor:"color-mix(in srgb, var(--widget-status-failed) 12%, transparent)",border:"1px solid color-mix(in srgb, var(--widget-status-failed) 20%, transparent)",color:"var(--widget-status-failed)",borderRadius:"var(--widget-radius)"},onClick:y,children:"Cancel"})]})},Cr=Gn;import{useCallback as Sr,useEffect as Tr,useState as Kn,useRef as xt}from"react";import{parseUnits as Xn}from"viem";import{useAccount as Yn,useWriteContract as Jn}from"wagmi";import{jsx as ke,jsxs as Ct}from"react/jsx-runtime";var Zn=15e3,tt="wrapping",es=({needsToWrap:e,amount:t,chainId:n,token:c,reviewState:l,setReviewState:s,goToNextStep:a,cancel:y,delayedClose:p,isWrappingPair:d})=>{let o=se(tt,l),[r,v]=Kn("idle"),w=sr(),{writeContractAsync:u}=Jn(),{address:h}=oe(),m=Me(),i=xt(!1),g=xt(!1),S=xt(null),{status:f}=Yn(),A=Sr(()=>{S.current&&(clearTimeout(S.current),S.current=null)},[]),O=Sr(async()=>{if(!(i.current||g.current||!h||f!=="connected")){i.current=!0,g.current=!0,v("pending"),S.current=setTimeout(()=>{i.current&&(v("error"),i.current=!1)},Zn);try{let I=Q(n);if(!I)throw new Error(`No config for chain ${n}`);let P=Xn(t.toString(),I.nativeAsset.decimals);await w.mutateAsync({chainId:n,accountAddress:h,amountRaw:P,writeContractAsync:u});let U={symbol:I.nativeAsset.symbol,name:I.nativeAsset.name,address:qe,decimals:I.nativeAsset.decimals,chainId:n},V={symbol:I.wrappedAsset.symbol,name:I.wrappedAsset.name,address:I.wrappedAsset.address,decimals:I.wrappedAsset.decimals,chainId:n};m({type:"wrap",tokens:[{asset:U,userAddress:h},{asset:V,userAddress:h}]}),A(),v("success"),a(tt,l),d&&await p()}catch{A(),v("error")}finally{i.current=!1}}},[h,f,n,t,w,u,m,a,l,p,d,A]);Tr(()=>{i.current||g.current||l===tt&&r==="idle"&&f==="connected"&&(e?O():(v("success"),a(tt,l)))},[l,r,e,f,O,a]),Tr(()=>()=>A(),[A]);let b=()=>{r==="error"&&(g.current=!1,v("idle"))},$=!o&&r==="error",D=!o&&(r==="pending"||r==="idle"||r==="error"),E=$?"var(--widget-status-failed)":"var(--widget-primary)";return Ct("div",{className:"flex w-full flex-row justify-between space-x-3",children:[ke("button",{type:"button",className:`inline-flex h-12 w-full items-center justify-center text-sm font-sans font-medium transition duration-150 ${$?"cursor-pointer":"cursor-not-allowed"}`,style:{backgroundColor:`color-mix(in srgb, ${E} 12%, transparent)`,border:`1px solid color-mix(in srgb, ${E} 20%, transparent)`,color:E,borderRadius:"var(--widget-radius)"},onClick:$?b:void 0,children:Ct("div",{className:"flex h-10 w-full flex-row items-center space-x-3 px-4",children:[ke("p",{className:"whitespace-nowrap",children:$?"Retry Wrap":c?`Wrap ${c.symbol}`:"Wrap Native Token"}),ke("div",{className:"flex flex-1 border-t",style:{borderColor:"var(--widget-border)"}}),Ct("div",{className:"flex h-6 w-3 items-center justify-center rounded-full",children:[!o&&(r==="pending"||r==="idle")&&ke(X,{size:"5"}),(o||r==="success")&&ke(Z,{className:"h-8 w-8"}),$&&ke(be,{className:"h-[12px] w-[12px]"})]})]})}),D&&ke("button",{type:"button",className:"inline-flex h-12 items-center justify-center px-8 text-sm font-sans font-medium transition duration-150 cursor-pointer",style:{backgroundColor:"color-mix(in srgb, var(--widget-status-failed) 12%, transparent)",border:"1px solid color-mix(in srgb, var(--widget-status-failed) 20%, transparent)",color:"var(--widget-status-failed)",borderRadius:"var(--widget-radius)"},onClick:y,children:"Cancel"})]})},Rr=es;import{jsx as H,jsxs as ns}from"react/jsx-runtime";var Ha=({base:e,baseAmount:t,quote:n,quoteAmount:c,userAddress:l,isWrappingPair:s,isUnwrappingPair:a,isBaseGasToken:y,isQuoteGasToken:p,reviewActionProps:d,reviewState:o,setReviewState:r,trackedOrderHash:v,setTrackedOrderHash:w,txStatus:u,onSwapSubmitted:h,onSwapComplete:m,onSwapInitiated:i,onOrderSubmitted:g,onStaleQuoteRestart:S,setExitHandler:f,setRetryHandler:A})=>{let{rfqQuote:O,status:b,liquidityError:$,routingError:D,sizeCapError:E,stop:I,clear:P}=ze(),{clearForm:U}=Ue(),V=rs(),{swapButtonVariant:G,widgetType:re}=Ie(),M=re==="compact",{trackOrderTransaction:k,trackNativeTransaction:_}=ar(),{startPolling:B}=Ht((F,he,ye)=>{if(ee.getState().setTxStatus(he),ye&&ee.getState().setExplorerUrl(ye),he==="completed"&&(k(F,`Swap ${e.symbol} \u2192 ${n.symbol}`),ye)){let rt=Fe(ye);rt&&fetch(`https://api.aori.io/data/details/${rt}`).then(nt=>nt.json()).then(nt=>m?.({quoteId:F,aoriOrderHash:rt,explorerUrl:ye,details:nt})).catch(()=>{})}}),[z,T]=ts(!1),x=Ar(!1),L=Ar(null),N=s,q=a,J=!s&&!a,we=V!==e?.chainId&&(N||q||J),Se=Q(e.chainId),K={chainId:e.chainId,name:Se?.displayName??`Chain ${e.chainId}`},ie=ge((F,he)=>{if(he!==F)return;if(F==="chain"){if(N){r("wrapping");return}if(q){r("unwrapping");return}r("signingOrder");return}if(F==="signingOrder"){r("trackingTx");return}if(F==="wrapping"){if(!s){r("signingOrder");return}r("wrapSuccess");return}if(F==="unwrapping"){r("wrapSuccess");return}let ye=Et(F);ye&&r(ye)},[r,s,N,q,J]),ne=ge(()=>we?"chain":N?"wrapping":q?"unwrapping":J?"signingOrder":null,[we,N,q,J]),ce=ge(()=>{r(null),U()},[U,r]),le=ge(async()=>{r("wrapSuccess");for(let F=0;F<3;F++)await ot(700);ce()},[ce,r]),ue=ge(async()=>{P(),r("cancelled");for(let F=0;F<3;F++)await ot(500);ce()},[P,ce,r]),Te=ge(()=>{v&&(ee.getState().stopTracking(),r(null),w(null),U())},[v,r,w,U]),de=ge(()=>{r(null),w(null),x.current=!0,S?.()},[r,w,S]),Ve=ge(()=>{d&&r(ne())},[ne,d,r]),kt=ge((F=!1)=>{F?(x.current=!0,r(null),S?.()):(r(null),L.current=setTimeout(()=>{d&&(r(ne()),T(!1))},100))},[r,d,ne,S]);Ne(()=>{o!==null&&I()},[o,I]),Ne(()=>{o!==null&&z&&T(!1)},[o,z]),Ne(()=>{f?.(Te)},[f,Te]),Ne(()=>(ee.getState().setExitHandler(Te),()=>ee.getState().setExitHandler(null)),[Te]),Ne(()=>{A?.(de)},[A,de]),Ne(()=>()=>{L.current&&clearTimeout(L.current)},[]),Ne(()=>{x.current&&b==="fresh"&&O?.id&&(x.current=!1,r("signingOrder"))},[b,O?.id,r]);let Ee=F=>{if(!F)return{backgroundColor:G==="default"?"var(--widget-muted)":"transparent",color:"var(--widget-muted-foreground)",border:G!=="default"?"1px solid var(--widget-border)":"none",borderRadius:"var(--widget-radius)"};switch(G){case"outline":return{backgroundColor:"transparent",color:"var(--widget-primary)",border:"1px solid var(--widget-primary)",borderRadius:"var(--widget-radius)"};case"ghost":return{backgroundColor:"transparent",color:"var(--widget-primary)",border:"none",borderRadius:"var(--widget-radius)"};default:return{backgroundColor:"var(--widget-primary)",color:"var(--widget-primary-foreground)",borderRadius:"var(--widget-radius)"}}},Be=`w-full ${M?"py-2":"py-3"} text-sm font-sans font-medium transition-colors cursor-pointer mt-1`;if(o===null&&!s&&!a){if(z)return H("button",{className:Be,disabled:!0,style:{...Ee(!1),opacity:.6,cursor:"not-allowed"},children:"Getting fresh quote..."});let F=()=>$?"Insufficient Liquidity":D?"Route Not Available":E?"Size Cap Exceeded":!O&&b==="polling"?"Getting Quote...":O?"Swap":"Enter Amount",he=!!d;return H("button",{onClick:he?Ve:void 0,disabled:!he,className:`${Be} disabled:opacity-40 disabled:cursor-not-allowed`,style:Ee(he),children:F()})}return o===null&&a?H("button",{onClick:d?Ve:void 0,disabled:!d,className:`${Be} disabled:opacity-40 disabled:cursor-not-allowed`,style:Ee(!!d),children:"Unwrap"}):o===null&&s?H("button",{onClick:d?Ve:void 0,disabled:!d,className:`${Be} disabled:opacity-40 disabled:cursor-not-allowed`,style:Ee(!!d),children:"Wrap"}):o==="success"?H("div",{className:"flex flex-col gap-2 w-full",children:H("button",{className:`w-full ${M?"py-2":"py-3"} text-sm font-sans font-medium cursor-default`,style:{backgroundColor:"color-mix(in srgb, var(--widget-status-completed) 15%, transparent)",color:"var(--widget-status-completed)",border:"1px solid color-mix(in srgb, var(--widget-status-completed) 20%, transparent)",borderRadius:"var(--widget-radius)"},children:"Order Placed"})}):o==="wrapSuccess"?H("div",{className:"flex flex-col gap-2 w-full",children:H("button",{className:`w-full ${M?"py-2":"py-3"} text-sm font-sans font-medium cursor-default`,style:{backgroundColor:"color-mix(in srgb, var(--widget-status-completed) 15%, transparent)",color:"var(--widget-status-completed)",border:"1px solid color-mix(in srgb, var(--widget-status-completed) 20%, transparent)",borderRadius:"var(--widget-radius)"},children:s?"Wrapped Successfully":"Unwrapped Successfully"})}):o==="cancelled"?H("div",{className:"flex flex-col gap-2 w-full",children:H("button",{onClick:ce,className:`w-full ${M?"py-2":"py-3"} text-sm font-sans font-medium cursor-pointer`,style:{backgroundColor:"color-mix(in srgb, var(--widget-status-failed) 15%, transparent)",color:"var(--widget-status-failed)",border:"1px solid color-mix(in srgb, var(--widget-status-failed) 20%, transparent)",borderRadius:"var(--widget-radius)"},children:"Order Cancelled"})}):ns("div",{className:"flex w-full",children:[o==="chain"&&we&&H(lr,{requiredChain:K,needsChainSwitch:we&&V!==e.chainId,reviewState:o,goToNextStep:ie,cancel:ue}),o==="wrapping"&&N&&H(Rr,{needsToWrap:N,amount:t,chainId:e.chainId,token:e,reviewState:o,setReviewState:r,goToNextStep:ie,cancel:ue,delayedClose:le,isWrappingPair:s}),o==="unwrapping"&&q&&H(Cr,{needsToUnwrap:q,amount:t,chainId:e.chainId,token:e,reviewState:o,setReviewState:r,goToNextStep:ie,cancel:ue,delayedClose:le}),o==="signingOrder"&&J&&H(wr,{base:e,baseAmount:t,quote:n,quoteAmount:c,userAddress:l,reviewState:o,goToNextStep:ie,cancel:ue,restartSigningFlow:kt,onSwapInitiated:i,onOrderSubmitted:g,isWrappingPair:s,isUnwrappingPair:a,onSwapSubmitted:h,startPolling:B,trackNativeTransaction:_}),o==="trackingTx"&&v&&H(yr,{orderHash:v,base:e,quote:n,baseAmount:t,quoteAmount:c,reviewState:o,status:u,onNewSwap:Te,onRetry:de}),o&&!["chain","wrapping","unwrapping","approval","signingOrder","trackingTx","success","wrapSuccess","cancelled"].includes(o)&&H("button",{disabled:!0,className:`w-full ${M?"py-2":"py-3"} text-sm font-sans font-medium`,style:{backgroundColor:"var(--widget-muted)",color:"var(--widget-muted-foreground)",borderRadius:"var(--widget-radius)"},children:"Processing..."})]})};import{useState as St,useCallback as ss,useRef as Tt,useEffect as Rt}from"react";import{useShallow as os}from"zustand/react/shallow";import{jsx as C,jsxs as R}from"react/jsx-runtime";var kr={pending:"var(--widget-status-pending)",received:"var(--widget-status-received)",completed:"var(--widget-status-completed)",failed:"var(--widget-status-failed)",cancelled:"var(--widget-status-failed)"},as=({status:e})=>{let t=kr[e]??kr.pending;switch(e){case"completed":return C(Z,{className:"h-6 w-6"});case"failed":case"cancelled":return C(_e,{className:"h-6 w-6"});default:return C(X,{size:"5",color:t})}};function is(e){if(e===0)return"0";let t=Math.abs(e);return t>=1e9?`${(e/1e9).toFixed(2)}B`:t>=1e6?`${(e/1e6).toFixed(2)}M`:t>=1e4?`${(e/1e3).toFixed(2)}K`:t>=1e3?e.toFixed(1):t>=100?e.toFixed(2):t>=1?e.toFixed(4):e.toFixed(6)}function Nr(e){let t=e.length;return t<=4?48:t<=6?40:t<=8?34:28}var At=()=>R("svg",{className:"w-3 h-3 shrink-0",style:{color:"var(--widget-secondary-foreground)"},viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[C("path",{d:"M18 13V19C18 20.1046 17.1046 21 16 21H5C3.89543 21 3 20.1046 3 19V8C3 6.89543 3.89543 6 5 6H11",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),C("path",{d:"M15 3H21V9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),C("path",{d:"M10 14L21 3",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),cs=()=>R("svg",{className:"w-3 h-3 shrink-0",viewBox:"0 0 195 321",fill:"var(--widget-secondary-foreground)",xmlns:"http://www.w3.org/2000/svg",children:[C("path",{fillRule:"evenodd",d:"M195,189C195,207.02,195,225.04,194.7,243.21C193.68,244.78,192.9,246.17,192.25,247.63C189.71,253.38,187.74,259.46,184.6,264.86C169.44,290.97,147.86,309.46,118.54,318.86C116.44,319.55,114.72,320.27,113,321C97.65,321,82.29,321,66.36,320.66C64.21,319.86,62.64,319.4,60.77,318.73C34.51,310.12,15.56,293.82,4.22,268.85C3.68,267.66,2.1,266.94,1,266C1,242.31,1,218.62,1.29,194.79C2.84,192.16,4.11,189.7,5.34,187.22C18.42,160.94,39.89,144.07,66.64,133.63C76.92,129.62,87.87,127.33,98.67,124.2C97.79,123.24,96.8,121.93,95.59,120.86C85.84,112.3,75.95,103.89,66.3,95.21C55.93,85.86,45.02,76.96,35.71,66.63C21.14,50.5,20.04,23.08,45.41,9.57C50.08,7.08,55.12,5.26,59.93,3.03C60.76,2.64,61.32,1.69,62,1C86.69,1,111.38,1,136.23,1.32C138.04,2.32,139.67,3.01,141.32,3.67C147.64,6.19,154.12,8.39,160.26,11.32C166.83,14.45,172.19,19.18,175.44,25.95C179.39,34.19,178.09,43.36,172.05,49.56C165.75,56.03,157.21,57.8,148.78,52.89C142.4,49.17,136.86,43.96,131.1,39.23C122.63,32.28,115.05,23.88,105.74,18.38C87.78,7.76,68.84,9.07,51.16,19.53C38.68,26.91,36.37,41.4,45.53,52.71C50.38,58.69,56.45,64,62.83,68.36C87.15,84.99,111.86,101.05,136.34,117.44C162.56,135,183.88,156.57,193.26,187.79C193.42,188.32,194.4,188.6,195,189ZM77.06,146.49C61.39,155.71,51.27,169.26,45.93,186.5C39.48,207.32,39.44,228.5,42.93,249.76C45.84,267.48,53.16,282.95,66.59,295.39C83.82,311.34,108.85,312.86,127.37,298.41C138.98,289.35,146.05,277.03,149.48,263.04C161.53,213.92,148.4,171.97,112.16,137.05C111.13,136.06,108.71,135.6,107.31,136.05C97.38,139.22,87.54,142.7,77.06,146.49Z"}),C("path",{d:"M118.83,199C121.61,197.69,122.77,198.41,122.77,201.27C122.71,217.43,122.78,233.58,122.65,249.73C122.65,250.83,121.43,251.92,120.77,253.01C119.97,252.05,118.63,251.17,118.45,250.1C116.32,237.7,113.36,235.12,100.61,235.02C98.12,235,95.62,234.98,93.12,235.01C81.26,235.16,77.72,238.3,75.94,249.84C75.74,251.15,74.39,252.28,73.57,253.49C73.11,253.23,72.64,252.98,72.17,252.73C72.17,234.81,72.17,216.88,72.17,198.96C72.49,198.62,72.81,198.28,73.13,197.93C74.09,198.95,75.72,199.85,75.92,201C78.13,213.8,80.95,216.26,94.05,216.3C97.38,216.31,100.72,216.44,104.04,216.27C113.28,215.79,117.15,212.05,118.22,202.81C118.35,201.65,118.47,200.49,118.83,199Z"})]}),ls=({orderHash:e,base:t,quote:n,baseAmount:c,quoteAmount:l,status:s})=>{let[a,y]=St(!1),[p,d]=St(!0),o=Tt(null),r=Tt(Date.now()),[v,w]=St(null),u=Tt(null),{isRecipientInputOpen:h,recipient:m,explorerUrl:i}=ee(os(x=>({isRecipientInputOpen:x.isRecipientInputOpen,recipient:x.recipient,explorerUrl:x.explorerUrl})));Rt(()=>{s==="received"&&(o.current=Date.now())},[s]),Rt(()=>{if(s==="completed"&&!v){let x=o.current||r.current;w((Date.now()-x)/1e3)}},[s,v]),Rt(()=>()=>{u.current&&clearTimeout(u.current)},[]);let g=ss(()=>{if(!navigator.clipboard?.writeText)return;let x=i?Fe(i)??e:e;navigator.clipboard.writeText(x).then(()=>{y(!0),u.current&&clearTimeout(u.current),u.current=setTimeout(()=>y(!1),2e3)}).catch(()=>{})},[e,i]),S=Pe(c),f=Pe(l),A=s==="completed"||s==="failed"||s==="cancelled",O=!A,b=c&&l?c/l:0,$=b>0&&b<1,D=$?1/b:b,E=$?t:n,I=$?n:t,P=t?.price?`\u2248 $${($?t.price:t.price*b).toFixed(2)}`:"",U=Q(t.chainId),V=Q(n.chainId),G=U?.displayName??`Chain ${t.chainId}`,re=V?.displayName??`Chain ${n.chainId}`,M=t.chainId!==n.chainId,k=U?.estimatedTimeMs??0,_=V?.estimatedTimeMs??0,B=(M?k+_:k)/1e3,z=i?Fe(i)??e:e,T=`${z.slice(0,6)} \u2026 ${z.slice(-4)}`;return R("div",{className:"relative w-full flex flex-col",children:[R("div",{className:"mx-4 mt-2",style:{backgroundColor:"var(--widget-secondary)"},children:[C("div",{className:"p-5",children:R("div",{className:"flex items-center justify-between",children:[R("div",{children:[R("div",{className:"flex items-center gap-3 mb-3",children:[C(te,{asset:t,size:"md",noChain:!0}),R("div",{children:[C("p",{className:"text-xl font-thin uppercase",style:{color:"var(--widget-foreground)"},children:t.symbol}),C("p",{className:"text-xs",style:{color:"var(--widget-muted-foreground)"},children:t.name})]})]}),R("div",{className:"inline-flex items-center gap-1.5 rounded-full px-2.5 py-1",style:{backgroundColor:"color-mix(in srgb, var(--widget-muted-foreground) 20%, transparent)",border:"1px solid color-mix(in srgb, var(--widget-muted-foreground) 30%, transparent)"},children:[C(ve,{chain:t.chainId,size:"xs"}),C("span",{className:"text-xs pt-0.5",style:{color:"var(--widget-muted-foreground)"},children:G})]})]}),R("div",{className:"text-right",children:[C("p",{className:"font-thin tracking-tight font-sans",style:{color:"var(--widget-foreground)",fontSize:`${Nr(S)}px`,transition:"font-size 0.1s ease-out"},children:S}),t.price&&R("p",{className:"text-xs mt-1 font-sans",style:{color:"var(--widget-muted-foreground)"},children:["$",(t.price*c).toFixed(2)]})]})]})}),R("div",{className:"relative",children:[C("div",{style:{borderTop:"1px solid var(--widget-border)"}}),C("div",{className:"absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2",children:C("div",{className:"w-10 h-10 rounded-full flex items-center justify-center",style:{backgroundColor:"var(--widget-secondary)",border:"1px solid var(--widget-border)"},children:C(as,{status:s})})})]}),C("div",{className:"p-5",children:R("div",{className:"flex items-center justify-between",children:[R("div",{children:[R("div",{className:"flex items-center gap-3 mb-3",children:[C(te,{asset:n,size:"md",noChain:!0}),R("div",{children:[C("p",{className:"text-xl font-thin uppercase",style:{color:"var(--widget-foreground)"},children:n.symbol}),C("p",{className:"text-xs",style:{color:"var(--widget-muted-foreground)"},children:n.name})]})]}),R("div",{className:"inline-flex items-center gap-1.5 rounded-full px-2.5 py-1",style:{backgroundColor:"color-mix(in srgb, var(--widget-muted-foreground) 20%, transparent)",border:"1px solid color-mix(in srgb, var(--widget-muted-foreground) 30%, transparent)"},children:[C(ve,{chain:n.chainId,size:"xs"}),C("span",{className:"text-xs pt-0.5",style:{color:"var(--widget-muted-foreground)"},children:re})]})]}),R("div",{className:"text-right",children:[C("p",{className:"font-thin tracking-tight font-sans",style:{color:"var(--widget-foreground)",fontSize:`${Nr(f)}px`,transition:"font-size 0.1s ease-out"},children:f}),n.price&&R("p",{className:"text-xs mt-1 font-sans",style:{color:"var(--widget-muted-foreground)"},children:["$",(n.price*l).toFixed(2)]})]})]})})]}),h&&m&&C("div",{className:"mx-4 mt-2 px-5 pb-2",children:R("div",{className:"flex items-center gap-2 p-2 rounded-full",style:{backgroundColor:"var(--widget-secondary)"},children:[C("div",{className:"flex h-5 w-5 items-center justify-center overflow-hidden rounded-full",style:{backgroundColor:"var(--widget-muted)"},children:C("span",{className:"text-2xs",children:"\u{1F464}"})}),C("span",{className:"text-xs",style:{color:"var(--widget-muted-foreground)"},children:"To:"}),R("span",{className:"text-xs font-sans",style:{color:"var(--widget-foreground)"},children:[m.slice(0,6),"...",m.slice(-4)]})]})}),R("div",{className:"px-4 mt-4",style:{borderTop:"1px solid var(--widget-border)",borderBottom:"1px solid var(--widget-border)"},children:[C("div",{className:"relative box-border flex flex-row h-8 w-full items-center cursor-pointer",role:"button",tabIndex:0,onClick:()=>d(!p),onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),d(!p))},children:C("div",{className:"flex h-full items-center w-full overflow-hidden",style:{color:"var(--widget-muted-foreground)"},children:R("div",{className:"translate-y-px font-sans flex w-full flex-row items-center justify-between",children:[R("div",{className:"flex flex-row items-center gap-2 whitespace-nowrap",children:[R("div",{className:"flex flex-row items-center gap-1",children:[C(te,{asset:E,size:"3xs",noChain:!0,className:"mb-0.5"}),R("span",{className:"text-xs uppercase",style:{color:"var(--widget-muted-foreground)"},children:["1 ",E.symbol]})]}),C("span",{className:"text-xs",style:{color:"var(--widget-muted-foreground)"},children:"="}),R("div",{className:"flex flex-row items-center gap-1",children:[C(te,{asset:I,size:"3xs",noChain:!0,className:"mb-0.5"}),R("span",{className:"text-xs uppercase",style:{color:"var(--widget-muted-foreground)"},children:[is(D)," ",I.symbol]})]}),C("span",{className:"text-xs",style:{color:"var(--widget-muted-foreground)"},children:P})]}),C("span",{className:"text-xs ml-2 transition-transform duration-200 shrink-0",style:{color:"var(--widget-muted-foreground)",transform:p?"rotate(180deg)":"rotate(0deg)",display:"inline-block"},children:"\u25BE"})]})})}),C("div",{className:"overflow-hidden transition-all duration-200",style:{maxHeight:p?"200px":"0px",opacity:p?1:0},children:R("div",{className:"flex flex-col gap-1 pb-1.5 font-sans",children:[R("div",{className:"flex justify-between text-2xs",style:{color:"var(--widget-muted-foreground)"},children:[C("span",{children:"USD Value"}),R("span",{style:{color:"var(--widget-secondary-foreground)"},children:["$",t.price?(t.price*c).toFixed(2):"\u2014"]})]}),R("div",{className:"flex justify-between text-2xs",style:{color:"var(--widget-muted-foreground)"},children:[C("span",{style:{color:"var(--widget-muted-foreground)"},children:"Order Type"}),C("span",{style:{color:"var(--widget-secondary-foreground)"},children:"RFQ (Limit)"})]}),R("div",{className:"flex justify-between items-center text-2xs",style:{color:"var(--widget-muted-foreground)"},children:[C("span",{children:"Transaction"}),i?R("a",{href:i,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 transition-colors hover:opacity-80",style:{color:"var(--widget-secondary-foreground)"},children:[C("span",{children:a?"Copied!":T}),C(At,{})]}):R("button",{type:"button",onClick:g,className:"flex items-center gap-1 cursor-pointer transition-colors",style:{color:"var(--widget-secondary-foreground)"},children:[C("span",{style:{color:"var(--widget-secondary-foreground)"},children:a?"Copied!":T}),C(At,{})]})]}),R("div",{className:"flex justify-between text-2xs",style:{color:"var(--widget-muted-foreground)"},children:[C("span",{children:A?"Speed":"Est. Time"}),C("span",{style:{color:"var(--widget-secondary-foreground)"},children:v?`${v.toFixed(2)}s`:B>0?`~${B}s`:"\u2014"})]}),R("div",{className:"flex justify-between items-center text-2xs",style:{color:"var(--widget-muted-foreground)"},children:[C("span",{children:"Route"}),R("a",{href:"https://www.aori.io",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 transition-colors hover:opacity-80",style:{color:"var(--widget-secondary-foreground)"},children:[C(cs,{}),"Aori",C(At,{})]})]})]})})]})]})},ri=ls;export{Ur as a,Me as b,gs as c,Ss as d,ze as e,Hr as f,ks as g,Ps as h,Ws as i,js as j,Ks as k,zt as l,Ht as m,Fe as n,Gt as o,an as p,Yt as q,cn as r,er as s,tr as t,rr as u,nr as v,sr as w,Ha as x,ri as y};
|