@aori/mega-swap-widget 0.1.7 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AssetSelectionMenu-CYWW5K6R.js +2 -0
- package/dist/AssetSelectionMenu-TPSIEBBB.cjs +2 -0
- package/dist/ChainSelectionMenu-HFJGI6E5.js +2 -0
- package/dist/ChainSelectionMenu-UNMEPKRI.cjs +2 -0
- package/dist/{SwapFormHorizontal-DXO6F5JC.js → SwapFormHorizontal-LARQUSNO.js} +1 -1
- package/dist/{SwapFormHorizontal-2JDBQ4PM.cjs → SwapFormHorizontal-YL3X2UA7.cjs} +1 -1
- package/dist/{SwapFormSplit-C5Z6MUBP.cjs → SwapFormSplit-JT3OYCFP.cjs} +1 -1
- package/dist/{SwapFormSplit-FORONC7U.js → SwapFormSplit-USJFORFM.js} +1 -1
- package/dist/{WidgetWalletPanel-H2MQ4HNZ.cjs → WidgetWalletPanel-HH26O3HT.cjs} +1 -1
- package/dist/WidgetWalletPanel-VUT4LF65.js +2 -0
- package/dist/WidgetWalletTradeHistory-NL23HIOJ.cjs +2 -0
- package/dist/WidgetWalletTradeHistory-VAH2FU7S.js +2 -0
- package/dist/{chunk-XEB3SYOB.js → chunk-7PT7UNJY.js} +1 -1
- package/dist/{chunk-JC6VVDA3.cjs → chunk-CNE67IQ3.cjs} +1 -1
- package/dist/chunk-CT7CRJLC.js +2 -0
- package/dist/{chunk-TXQ6Q4S3.cjs → chunk-D7GULMHE.cjs} +1 -1
- package/dist/chunk-DLA3C645.cjs +2 -0
- package/dist/{chunk-4SV4EZY2.cjs → chunk-EKSQTNKS.cjs} +1 -1
- package/dist/{chunk-74M7ZIF5.js → chunk-GPT4NHM5.js} +1 -1
- package/dist/{chunk-IKVRF6NO.js → chunk-IKTTT66M.js} +1 -1
- package/dist/{chunk-T2K2NOGZ.cjs → chunk-K3RTTHBS.cjs} +3 -3
- package/dist/{chunk-N7IYXS4X.cjs → chunk-KI6AVCXD.cjs} +1 -1
- package/dist/{chunk-3AQO6NMO.js → chunk-LSB5IXLW.js} +1 -1
- package/dist/{chunk-T2JA5EHN.cjs → chunk-PSCWQFVY.cjs} +1 -1
- package/dist/{chunk-DUMYILH6.js → chunk-QAOZRRSH.js} +3 -3
- package/dist/{chunk-EDQ3SNQJ.cjs → chunk-TWVI6PZS.cjs} +1 -1
- package/dist/{chunk-BJXIGJVO.js → chunk-UHG7ZIWD.js} +1 -1
- package/dist/{chunk-565H4OUG.js → chunk-UR3Q7FG5.js} +1 -1
- package/dist/{chunk-I7TSQM4Y.cjs → chunk-WZCWYOCN.cjs} +1 -1
- package/dist/{chunk-2UW2RRTC.js → chunk-YO5D6L5W.js} +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.css +1 -1
- package/dist/index.js +2 -2
- package/package.json +1 -1
- package/dist/AssetSelectionMenu-2ILVPQBL.js +0 -2
- package/dist/AssetSelectionMenu-VK275DDY.cjs +0 -2
- package/dist/ChainSelectionMenu-2B6QTSXZ.cjs +0 -2
- package/dist/ChainSelectionMenu-UYQJ6BP3.js +0 -2
- package/dist/WidgetWalletPanel-5EAZBMPR.js +0 -2
- package/dist/WidgetWalletTradeHistory-M4RTYZPY.js +0 -2
- package/dist/WidgetWalletTradeHistory-VUR6C4BW.cjs +0 -2
- package/dist/chunk-GIWNS54F.cjs +0 -2
- package/dist/chunk-K5X3YHME.js +0 -2
package/dist/chunk-K5X3YHME.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import{a as Tr}from"./chunk-OPN7WCJR.js";import{e as Ie}from"./chunk-2UW2RRTC.js";import{b as Ae,c as It,d as ee}from"./chunk-74M7ZIF5.js";import{E as rt,F as nt,H as kt,I as st,M as we,N as se,O as Z,R as he,S as Nt,T as We,U as K,W as Et,X as De,a as Fe,c as q,h as Ct,k as ke,m as Ne,o as Ee,q as St,r as ae,s as Tt,t as et,v as tt,w as Rt,x as At}from"./chunk-DUMYILH6.js";import{a as ie}from"./chunk-46H44R7V.js";import{b as Sr}from"./chunk-73CB2I7U.js";import{useQueryClient as Rr}from"@tanstack/react-query";import{useCallback as Ar,useEffect as Pt,useRef as Ot}from"react";function kr(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 Nr=()=>{let{address:e}=ie(),t=It(),r=Rr(),c=Ot(null),l=Ot(!0),s=Ar(a=>{if(!e)return;let v=[...new Set(a.tokens.map(d=>d.asset.chainId))],m=kr(v);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 kt(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=st.swap(e,w.chainId,w.address,u.chainId,u.address);r.setQueryData(h,o)}let n=st.bulk(e,t),y=r.getQueryData(n);if(y){let w=y.balances.map(u=>o.balances.find(g=>g.chainId===u.chainId&&g.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(g=>g.chainId===u.asset.chainId&&g.token.toLowerCase()===u.asset.address.toLowerCase())){let g=w.findIndex(i=>i.chainId===u.asset.chainId&&i.token.toLowerCase()===u.asset.address.toLowerCase());g!==-1&&(w[g]={...w[g],balance:"0",shiftedBalance:"0"})}r.setQueryData(n,{balances:w})}}catch{}},m)},[e,t,r]);return Pt(()=>(l.current=!0,()=>{l.current=!1,c.current&&(clearTimeout(c.current),c.current=null)}),[]),{triggerBalanceUpdate:s}},ot=class extends EventTarget{emit(t){this.dispatchEvent(new CustomEvent("balance-update",{detail:t}))}},at=new ot,Oe=()=>e=>at.emit(e),is=()=>{let{triggerBalanceUpdate:e}=Nr();Pt(()=>{let t=r=>{e(r.detail)};return at.addEventListener("balance-update",t),()=>at.removeEventListener("balance-update",t)},[e])};import{createContext as Er,useCallback as de,useContext as Ir,useEffect as $t,useMemo as Or,useRef as ce,useState as be}from"react";import{formatUnits as Pr,parseUnits as $r}from"viem";import{jsx as Dr}from"react/jsx-runtime";var Mt=Er(void 0),Ut=1e4,Ur=3e4,Mr=1e3,Lr=2;function Wr(e){return e.find(r=>r.routeSteps?.[0]?.type==="AORI_V1")??e[0]}var gs=({children:e,recipient:t})=>{let{address:r}=ie(),c=t||r,[l,s]=be("idle"),[a,v]=be("idle"),[m,d]=be(null),[o,n]=be(null),[y,w]=be(!1),[u,h]=be(!1),[g,i]=be(!1),p=ce(null),x=ce(null),f=ce(null),k=ce(null),P=ce(null),S=ce(0),U=ce(0),W=ce(0),N=ce(!1),E=ce(new Map),I=de(()=>{f.current&&clearTimeout(f.current),k.current&&clearTimeout(k.current),P.current&&clearTimeout(P.current),f.current=null,k.current=null,P.current=null},[]),M=de(()=>{I(),p.current=null,S.current=0,s(()=>N.current?"fresh":"idle")},[I]),D=de(()=>{M(),x.current=null,d(null),n(null),w(!1),h(!1),i(!1),E.current.clear(),s("idle"),v("idle")},[M]),Y=de(C=>{if(!C)return;k.current&&clearTimeout(k.current);let R=Math.max(0,C+Ur-Date.now());k.current=setTimeout(()=>{s($=>$==="idle"?"idle":"stale")},R)},[]),H=de(async(C,R)=>{let{inputToken:$,outputToken:O,inputAmount:z,setOutputAmount:te}=C;if(!$||!O||!z||parseFloat(z)<=0||Date.now()-(U.current||0)<Ut-10)return;let _e=++S.current;try{if(!$?.decimals||!O?.decimals)return;let G=nt($.chainId)||q($.chainId)?.key||"",le=nt(O.chainId)||q(O.chainId)?.key||"";if(!G||!le)throw new Error("Unknown chain");let re=$r(z.toString(),$.decimals).toString(),Te={srcChainKey:G,dstChainKey:le,srcTokenAddress:tt($.address),dstTokenAddress:tt(O.address),amount:re,srcWalletAddress:r||"0x0000000000000000000000000000000000000000",dstWalletAddress:c||r||"0x0000000000000000000000000000000000000000",options:{amountType:"EXACT_SRC_AMOUNT",feeTolerance:{type:"PERCENT",amount:2}}};U.current=Date.now();let ne=await fetch(`${ke()}/quotes`,{method:"POST",headers:Ne(),body:JSON.stringify(Te),signal:AbortSignal.timeout(15e3)});if(!ne.ok){let Re=(await ne.json().catch(()=>({})))?.message||ne.statusText;throw Object.assign(new Error(Re),{status:ne.status})}let oe=await ne.json();if(_e!==S.current||p.current!==R)return;let Ue=oe.quotes??[],ue=Wr(Ue);if(!ue)throw Object.assign(new Error("No quotes returned"),{emptyQuotes:!0});let Ze=Number(Pr(St(ue.dstAmount),O.decimals));typeof te=="function"&&te(Ze),ue._receivedAt=Date.now(),d(ue),n(null),w(!1),s("fresh"),Y(ue._receivedAt),R&&E.current.delete(R)}catch(G){if(_e!==S.current||p.current!==R)return;let le=G?.status,re=G instanceof Error?G.message:"",Te=!!G?.emptyQuotes;if((le===400||Te||re.includes("Quote request failed"))&&R){let oe=(E.current.get(R)||0)+1;if(E.current.set(R,oe),oe>=Lr){h(!0),I(),p.current=null;return}}if(re.toLowerCase().includes("order cap exceeded")){i(!0),I(),p.current=null;return}if(re.toLowerCase().includes("insufficient executor balance")){w(!0),I(),p.current=null;return}n(G instanceof Error?G.message:"Unknown error")}},[r,c,Y,I]),L=de((C,R)=>{I(),x.current=C,U.current=0,E.current.delete(R),w(!1),h(!1),i(!1),n(null),s("polling");let $=async()=>{p.current===R&&(await H(C,R),p.current===R&&(f.current=setTimeout($,Ut)))};$()},[I,H]),T=de(C=>{if(!C?.inputToken||!C?.outputToken||!C?.inputAmount||parseFloat(C.inputAmount)<=0){M();return}let R=x.current;if(R&&R.inputToken?.address===C.inputToken?.address&&R.inputToken?.chainId===C.inputToken?.chainId&&R.outputToken?.address===C.outputToken?.address&&R.outputToken?.chainId===C.outputToken?.chainId&&R.inputAmount===C.inputAmount&&p.current)return;let O=Date.now();if(O-W.current<100)return;W.current=O;let z=`${Date.now()}-${Math.random().toString(36).slice(2)}`;p.current=z,L(C,z)},[L,M]),F=de(({amount:C,inputToken:R,outputToken:$,setOutputAmount:O})=>{O(null),P.current&&clearTimeout(P.current),!C||C===0?(v("idle"),M(),d(null),n(null),w(!1),h(!1),i(!1)):(v("typing"),M(),d(null),w(!1),h(!1),i(!1),n(null),P.current=setTimeout(()=>{v("settled"),R&&$&&C>0&&T({inputToken:R,outputToken:$,inputAmount:C.toString(),setOutputAmount:O})},Mr))},[M,T]),B=de(()=>{let C=x.current;if(!C)return;d(null);let R=`${Date.now()}-${Math.random().toString(36).slice(2)}`;p.current=R,s("refreshing"),typeof C.setOutputAmount=="function"&&C.setOutputAmount(null),L(C,R)},[L]);$t(()=>{N.current=!!m},[m]),$t(()=>()=>I(),[I]);let J=Or(()=>({status:l,inputState:a,rfqQuote:m,error:o,liquidityError:y,routingError:u,sizeCapError:g,ensureForParams:T,stop:M,refresh:B,clear:D,handleInputChange:F}),[l,a,m,o,y,u,g,T,M,B,D,F]);return Dr(Mt.Provider,{value:J,children:e})},Be=()=>{let e=Ir(Mt);if(e===void 0)throw new Error("useRfq must be used within an RfqProvider");return e};import{createContext as Vr,useContext as _r}from"react";var Fr=Vr({openConnectModal:()=>{}}),ys=()=>_r(Fr);import{useCallback as it,useEffect as Pe,useRef as qe,useState as ct}from"react";import{jsx as $e,jsxs as zr}from"react/jsx-runtime";var Br=20,qr=({side:e,asset:t,otherAsset:r,isPlacingOrder:c,isWrappingPair:l,isUnwrappingPair:s})=>{let{baseAmount:a,quoteAmount:v,setBaseAmount:m,setQuoteAmount:d}=Ie(),{amountInputVariant:o,hideAmountInputSymbol:n,widgetType:y}=Ae(),w=y==="compact",[u,h]=e==="base"?[m,d]:[d,m],g=!t||e==="quote"||c,i=w?32:o==="default"?64:32,[p,x]=ct(i),[f,k]=ct(""),P=qe(null),S=qe(null),U=qe(null),W=qe(null),N="USD",E=e==="base"?a:v,[I,M]=ct(!1),D=it(()=>{if(o!=="default"){x(i);return}if(!P.current||!S.current||!U.current)return;let L=P.current.offsetWidth,T=20,F=i;for(;F>20&&(S.current.style.fontSize=`${F}px`,U.current.style.fontSize=`${F}px`,!(S.current.offsetWidth+U.current.offsetWidth+T<=L));)F-=1;x(F)},[o,i]),Y=it(L=>{L.key==="."&&f.includes(".")&&L.preventDefault()},[f]),H=it(L=>{let T=L.target.value;if(T==="."&&(T="0."),!/^\d*\.?\d*$/.test(T)||(T.match(/\./g)||[]).length>1)return;if(T.length>1&&T[0]==="0"&&T[1]!=="."&&(T=T.replace(/^0+/,"")||"0"),t?.decimals!==void 0&&T.includes(".")){let[,B]=T.split(".");if(B&&B.length>t.decimals)return}if(T.length>Br)return;k(T);let F=parseFloat(T);T!==f&&(T===""||T==="0."||T.endsWith(".")?(u(null),e==="base"&&h(null)):!Number.isNaN(F)&&F>=0&&u(F),e==="base"&&d(null),(s||l)&&d(F||0))},[f,u,e,d,t?.decimals,h,s,l]);return Pe(()=>{let L=B=>{if(B===null)return"";let J=t?.decimals;if(J===void 0)return"";let C=B.toString();if(/e/i.test(C)&&(C=Number(B).toLocaleString("en-US",{useGrouping:!1,maximumFractionDigits:J})),C.includes(".")){let[R,$]=C.split("."),O=$.slice(0,J);return O?`${R}.${O}`:R}return C};if(E===null){f==="0."||f!==""&&f.endsWith(".")||k("");return}if(!g&&(f.endsWith(".")||f.match(/\.\d*0$/)||f==="0"||f==="0.")&&f!=="")return;let F=parseFloat(f)||0;(f===""||Math.abs(F-E)>1e-10)&&k(L(E))},[E,t?.decimals,f,g]),Pe(()=>{D()},[f,D]),Pe(()=>{M(!0)},[]),Pe(()=>{I&&D()},[I,D]),Pe(()=>{S.current&&W.current&&(W.current.style.width=`${S.current.offsetWidth}px`)},[f]),Pe(()=>{if(!I)return;let L=new ResizeObserver(()=>{I&&D()});return P.current&&L.observe(P.current),()=>L.disconnect()},[I,D]),$e("div",{ref:P,style:{fontSize:`${p}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 ${g?"cursor-default":"cursor-text"}`,onClick:()=>W.current?.focus(),children:zr("div",{className:"relative flex w-full items-center",children:[$e("label",{htmlFor:`${e}Amount`,className:"sr-only",children:e==="base"?"Input token amount":"Output token amount"}),$e("input",{ref:W,type:"text",inputMode:"decimal",placeholder:"0",autoComplete:"off",id:`${e}Amount`,value:f,onWheel:L=>L.target.blur(),onKeyDown:Y,onChange:H,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:g}),$e("span",{style:{transition:"width 0.15s ease-in-out"},ref:S,className:"pointer-events-none absolute flex whitespace-nowrap invisible",children:f||0}),!n&&o!=="normal"&&$e("span",{ref:U,className:"ml-2 font-thin uppercase",style:{color:"var(--widget-foreground)",opacity:.5,fontSize:`${p}px`},children:t?.symbol?t.symbol.length>6?`${t.symbol.slice(0,6)}...`:t.symbol:N}),(n||o==="normal")&&$e("span",{ref:U,className:"hidden"})]})})},Rs=qr;import{Fragment as lt,jsx as V,jsxs as pe}from"react/jsx-runtime";var Qr=({toggle:e,side:t,asset:r,isPlacingOrder:c,hideDropdown:l})=>{let{baseBalance:s,quoteBalance:a}=Ie(),{tokenDisplay:v,tokenBadgeOrientation:m,widgetType:d}=Ae(),o=d==="compact",n=o?"h-10":"h-11",y=o?"h-10 w-10":"h-11 w-11",w=t==="base"?s.formatted?(()=>{let h=parseFloat(s.formatted);return h>=1e8?Ee(h):h.toFixed(3)})():void 0:a.formatted?(()=>{let h=parseFloat(a.formatted);return h>=1e8?Ee(h):h.toFixed(3)})():void 0,u={role:"button",tabIndex:c?-1:0,"aria-disabled":c,"aria-label":`Select ${t==="base"?"input":"output"} token${r?`: ${r.symbol}`:""}`,onClick:c?void 0:e,onKeyDown:c?void 0:h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),e())}};return v==="pill"?V("div",{...u,className:`inline-flex items-center gap-1.5 h-7 px-2.5 rounded-full cursor-pointer transition-colors ${m==="right"?"ml-auto":""}`,style:{border:"1px solid var(--widget-border)",backgroundColor:"var(--widget-secondary)",color:"var(--widget-secondary-foreground)"},children:r?pe(lt,{children:[V(we,{chain:r.chainId,size:"xs"}),V(se,{className:"rounded-full",asset:r,size:"xxs",noChain:!0}),V("span",{className:"text-xs font-thin uppercase",children:r.symbol}),!l&&V(We,{className:"w-1.5 opacity-60",style:{color:"var(--widget-secondary-foreground)"}})]}):pe(lt,{children:[V("span",{className:"text-xs opacity-70",children:"Select"}),!l&&V(We,{className:"w-1.5 opacity-60",style:{color:"var(--widget-secondary-foreground)"}})]})}):v==="ghost"?pe("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:[r?pe(lt,{children:[V(we,{chain:r.chainId,size:"xs"}),V(se,{className:"rounded-full",asset:r,size:"xxs",noChain:!0}),V("span",{className:"text-sm font-thin uppercase",children:r.symbol})]}):V("span",{className:"text-sm",style:{color:"var(--widget-muted-foreground)"},children:"Select token"}),!l&&V(We,{className:"w-1.5 opacity-50"})]}):V("div",{...u,className:`relative ${n} 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:V("div",{className:"relative flex h-full w-full flex-row items-center",children:r?pe("div",{className:"relative flex h-full w-full flex-row items-center",children:[V("div",{className:`${y} pl-px flex items-center justify-center`,children:V(se,{className:"rounded-full",asset:r,size:"md"})}),pe("div",{className:"flex h-full w-full flex-row items-center justify-between pl-1.5 pr-7",children:[pe("div",{className:"flex h-full flex-col justify-center",children:[V("p",{className:"text-sm font-thin uppercase",style:{color:"var(--widget-secondary-foreground)"},children:r.symbol}),pe("span",{className:"text-2xs font-sans",style:{color:"var(--widget-muted-foreground)"},children:[r.address?.slice(0,6),"...",r.address?.slice(-4)]})]}),w!==void 0&&pe("div",{className:"flex flex-col text-right",children:[V("p",{className:"text-2xs",style:{color:"var(--widget-muted-foreground)"},children:"Balance"}),V("span",{className:"font-sans text-xs tabular-nums",style:{color:"var(--widget-foreground)",opacity:.5},children:w})]})]}),!l&&V(We,{className:"absolute right-3 top-1/2 w-1.5 translate-y-[-50%]",style:{color:"var(--widget-secondary-foreground)",opacity:.6}})]}):V("div",{className:"flex h-full w-full items-center justify-center",children:V("span",{className:"text-sm",style:{color:"var(--widget-secondary-foreground)",opacity:.7},children:"Select token"})})})})},Os=Qr;var Wt=Sr(Tr(),1);import{useState as ze,useEffect as Qe}from"react";import{jsx as X,jsxs as Lt}from"react/jsx-runtime";var jr=()=>{let[e,t]=ze(null),[r,c]=ze(""),l=At(r,1e3),[s,a]=ze(!1),[v,m]=ze("");Qe(()=>{ee.getState().setRecipient(e)},[e]),Qe(()=>{c(e||"")},[e]);let d=n=>{let y=n.target.value;s&&(a(!1),m(""),t(null)),c(y),y===""&&t(null)};Qe(()=>{l===""||!l?(a(!1),m(""),t(null)):Rt(l)?(a(!1),m(""),t(l)):(a(!0),m("Invalid wallet address..."),t(null),c(""))},[l]),Qe(()=>{if(s){let n=setTimeout(()=>{t(null),c(""),a(!1),m("")},2e3);return()=>clearTimeout(n)}},[s]);let o=()=>{t(null),c(""),a(!1),m("")};return X("div",{className:"w-full",children:Lt("div",{className:"relative flex flex-row items-center",children:[X("input",{type:"password",style:{display:"none"},"aria-hidden":"true",tabIndex:-1}),X("label",{htmlFor:"recipient-address",className:"sr-only",children:"Recipient wallet address"}),X("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?X("img",{className:"h-full w-full rounded-full object-cover",src:(0,Wt.makeGradient)(e),alt:"Recipient avatar"}):X(Nt,{className:"h-5 w-5",style:{color:s?"var(--widget-destructive)":"var(--widget-muted-foreground)"}})}),X("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:"}),X("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?v:"Enter recipient address...",value:r,onChange:d,spellCheck:!1,"aria-invalid":s,"aria-describedby":s?"recipient-error":void 0}),s&&X("span",{id:"recipient-error",className:"sr-only",children:v}),e&&!s&&Lt("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:[X("svg",{className:"h-2.5 w-2.5",viewBox:"0 -0.5 21 21",fill:"none",children:X("g",{fill:"currentColor",fillRule:"evenodd",children:X("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)"})})}),X("span",{className:"sr-only",children:"Clear recipient"})]})]})})},Ds=jr;import{jsx as Dt,jsxs as Hr}from"react/jsx-runtime";function Fs(e){return Hr("svg",{width:"485",height:"484",viewBox:"0 0 485 484",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[Dt("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"}),Dt("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 Gr=["SUCCEEDED","FAILED","COMPLETED","CANCELLED"];async function Vt(e,t,r={}){let{onStatusChange:c,onComplete:l,onError:s,interval:a=4e3,timeout:v=3e5,txHash:m,signal:d}=r,o=null,n=Date.now(),y=0,w=8,u=null,h=m?`?txHash=${m}`:"";return new Promise((g,i)=>{let p=async()=>{try{if(d?.aborted){u&&clearTimeout(u),i(new DOMException("Polling aborted","AbortError"));return}if(Date.now()-n>v){u&&clearTimeout(u);let P=new Error("Order status polling timed out");s?.(P),i(P);return}let x=await fetch(`${t}/status/${e}${h}`,{headers:Ne(),signal:d});if(x.status===404){u=setTimeout(p,a);return}if(!x.ok)throw new Error(`Failed to fetch order status: ${await x.text()}`);let f=await x.json();if(!f||typeof f!="object"||!f.status)throw new Error(`Invalid status response format: ${JSON.stringify(f)}`);y=0;let k=f.status.toUpperCase();if(k!==o&&(o=k,c?.(f)),Gr.includes(k)){u&&clearTimeout(u),l?.(f),g(f);return}u=setTimeout(p,a)}catch(x){if(x instanceof Error&&x.name==="AbortError"){u&&clearTimeout(u),i(x);return}if(++y>=w){u&&clearTimeout(u);let f=x instanceof Error?x:new Error(String(x));s?.(f),i(f);return}u=setTimeout(p,a)}};p()})}import{useCallback as je,useEffect as Kr,useRef as He}from"react";function _t(e){let t=e.toUpperCase();return t==="SUCCEEDED"||t==="COMPLETED"?"completed":t==="FAILED"?"failed":t==="CANCELLED"?"cancelled":t==="PROCESSING"?"received":"pending"}var Ft=e=>{let t=He(new Map),r=He(new Map),c=He(new Map),l=He(0),s=je(()=>++l.current,[]),{address:a}=ie(),v=Oe(),m=je((n,y)=>{if(t.current.get(n))return;y&&r.current.set(n,y),t.current.set(n,!0);let w=l.current,u=new AbortController;c.current.set(n,u);let h=y?.baseToken?.chainId===1;Vt(n,ke(),{interval:h?1e3:500,timeout:3e5,signal:u.signal,onStatusChange:g=>{if(!g?.status)return;let i=_t(g.status);if(e?.(n,i,g.explorerUrl),i==="completed"&&a){let p=r.current.get(n);if(p&&(p.baseToken||p.quoteToken)){let x=[];p.baseToken&&x.push({asset:p.baseToken,userAddress:a}),p.quoteToken&&x.push({asset:p.quoteToken,userAddress:a}),v({type:"swap",tokens:x})}}["completed","failed","cancelled"].includes(i)&&(t.current.delete(n),r.current.delete(n)),w!==l.current&&(t.current.delete(n),r.current.delete(n))},onComplete:g=>{g?.status&&e?.(n,_t(g.status),g.explorerUrl),t.current.delete(n),r.current.delete(n)},onError:()=>{t.current.delete(n),r.current.delete(n)}}).catch(g=>{g instanceof Error&&g.name==="AbortError"||(t.current.delete(n),r.current.delete(n),c.current.delete(n))})},[a,v,e]),d=je(n=>{let y=c.current.get(n);y&&(y.abort(),c.current.delete(n)),s(),t.current.delete(n),r.current.delete(n)},[s]),o=je(()=>{for(let n of c.current.values())n.abort();c.current.clear(),s(),t.current.clear(),r.current.clear()},[s]);return Kr(()=>()=>o(),[o]),{startPolling:m,stopPolling:d,stopAllPolling:o,isPolling:n=>t.current.has(n)}};import{createContext as Xr,useContext as Yr}from"react";var Jr=Xr({registerTransaction:()=>{},enabled:!1}),Bt=()=>Yr(Jr);import{signTypedData as Zr}from"viem/actions";function zt(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 qt(e){if(e.chain?.id)return e.chain.id;let t=e.getChainId?.();return t!=null?await t:null}var en=async(e,t)=>{try{if(await qt(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 qt(e)===t}catch(r){throw zt(r)?new Error("User rejected the chain switch request"):new Error(`Please switch your wallet to the required network (Chain ID: ${t})`)}},Qt=async e=>{let{quote:t,signatureStep:r,userAddress:c,walletClient:l}=e;if(!l)throw new Error("Wallet client not available");if(r.type!=="SIGNATURE"||!r.signature?.typedData)throw new Error("Invalid signature step");try{let s=r.signature.typedData,a={...s.message};for(let o of["inputAmount","outputAmount","startTime","endTime"])a[o]!=null&&(a[o]=BigInt(a[o]));let v=s.domain;if(v.chainId!=null){let o=Number(v.chainId);await en(l,o)}let m=await Zr(l,{account:c,domain:v,types:s.types,primaryType:s.primaryType,message:a}),d=await fetch(`${ke()}/submit-signature`,{method:"POST",headers:Ne(),body:JSON.stringify({quoteId:t.id,signatures:[m]})});if(!d.ok){let o=await d.json().catch(()=>({}));throw new Error(o?.message||`Submit failed: ${d.status}`)}return{quoteId:t.id,signature:m}}catch(s){throw zt(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 ut=()=>{try{let e=localStorage.getItem(jt);return e?JSON.parse(e):[]}catch{return[]}},Ht=e=>{try{localStorage.setItem(jt,JSON.stringify(e))}catch{}},tn=e=>{let t=Date.now(),r=typeof e=="string"?new Date(e).getTime():e>9999999999?e:e*1e3;return t<r+3e4},rn=e=>ut().some(t=>t.quoteId===e),Gt=(e,t)=>rn(e)?{canSubmit:!1,reason:"Order already submitted"}:tn(t)?{canSubmit:!0}:{canSubmit:!1,reason:"Quote has expired"},Kt=(e,t)=>{let r=typeof t=="string"?new Date(t).getTime():t,c=ut();c.push({quoteId:e,submittedAt:Date.now(),createdAt:r}),Ht(c)},Xt=()=>{let e=ut(),t=Date.now(),r=300*1e3,c=e.filter(l=>t-l.submittedAt<r);c.length!==e.length&&Ht(c)};import{useMutation as nn}from"@tanstack/react-query";import{waitForTransactionReceipt as sn}from"@wagmi/core";import{wethAbi as on}from"abitype/abis";import{useConfig as an}from"wagmi";function Yt(){let e=an();return nn({mutationFn:async({chainId:t,accountAddress:r,amountRaw:c,writeContractAsync:l})=>{let s=q(t);if(!s)throw new Error(`No wrapping contract for chain ${t}`);let a=s.wrappedAsset.address,v=await l({abi:on,functionName:"withdraw",address:a,account:r,args:[c],chainId:t});if((await sn(e,{hash:v,chainId:t,confirmations:1,pollingInterval:4e3})).status!=="success")throw new Error("Unwrap transaction did not get successful receipt");return{success:!0,hash:v}}})}import{useMutation as cn}from"@tanstack/react-query";import{waitForTransactionReceipt as ln}from"@wagmi/core";import{wethAbi as un}from"abitype/abis";import{useConfig as dn}from"wagmi";function Jt(){let e=dn();return cn({mutationFn:async({chainId:t,accountAddress:r,amountRaw:c,writeContractAsync:l})=>{let s=q(t);if(!s)throw new Error(`No wrapping contract for chain ${t}`);let a=s.wrappedAsset.address,v=await l({abi:un,functionName:"deposit",address:a,account:r,value:c,chainId:t});if((await ln(e,{hash:v,chainId:t,confirmations:1,pollingInterval:4e3})).status!=="success")throw new Error("Wrap transaction did not get successful receipt");return{success:!0,hash:v}}})}import{useCallback as me,useEffect as Se,useRef as yr,useState as Hn}from"react";import{useChainId as Gn}from"wagmi";import{useCallback as Zt,useRef as pn}from"react";function er(){let{registerTransaction:e,enabled:t}=Bt(),r=pn(new Set),c=Zt((s,a)=>{!t||r.current.has(s)||(r.current.add(s),e(s,a))},[t,e]),l=Zt((s,a)=>{!t||r.current.has(s)||(r.current.add(s),e(s,a))},[t,e]);return{trackOrderTransaction:c,trackNativeTransaction:l,txTrackingEnabled:t}}import{useEffect as tr,useState as fn,useCallback as rr,useRef as dt}from"react";import{useAccount as mn,useChainId as gn,useSwitchChain as wn}from"wagmi";import{jsx as ve,jsxs as pt}from"react/jsx-runtime";var hn=15e3,Ge="chain",vn=({needsChainSwitch:e,requiredChain:t,reviewState:r,goToNextStep:c,cancel:l})=>{let s=ae(Ge,r),[a,v]=fn("pending"),m=dt(!1),d=dt(!1),o=dt(null),n=gn(),{switchChainAsync:y}=wn(),{status:w,isReconnecting:u}=mn(),h=rr(()=>{o.current&&(clearTimeout(o.current),o.current=null)},[]),g=rr(async()=>{if(!(m.current||d.current||w!=="connected"||u)){m.current=!0,d.current=!0,v("pending"),o.current=setTimeout(()=>{m.current&&(v("error"),m.current=!1)},hn);try{await y({chainId:t.chainId}),h(),v("success"),c(Ge,r)}catch{h(),v("error")}finally{m.current=!1}}},[y,w,u,t.chainId,c,r,h]);tr(()=>{m.current||d.current||r===Ge&&a==="pending"&&w==="connected"&&!u&&(e&&n!==t.chainId?g():(v("success"),c(Ge,r)))},[r,a,e,n,t.chainId,w,u,g,c]),tr(()=>()=>h(),[h]);let i=()=>{a==="error"&&(d.current=!1,v("pending"))},p=!s&&a==="error",x=!s&&(a==="pending"||a==="error"),f=p?"var(--widget-status-failed)":"var(--widget-primary)";return pt("div",{className:"flex w-full flex-row justify-between space-x-3",children:[ve("button",{type:"button",className:`inline-flex h-12 w-full items-center justify-center text-sm font-sans font-medium transition duration-150 ${p?"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:p?i:void 0,children:pt("div",{className:"flex h-10 w-full flex-row items-center space-x-3 px-4",children:[ve(we,{chain:t.chainId,size:"xs"}),ve("p",{className:"whitespace-nowrap",children:p?"Retry Switch":`Switch to ${t.name}`}),ve("div",{className:"flex flex-1 border-t",style:{borderColor:"var(--widget-border)"}}),pt("div",{className:"flex h-6 w-3 items-center justify-center rounded-full",children:[!s&&a==="pending"&&ve(K,{size:"5"}),(s||a==="success")&&ve(Z,{className:"h-8 w-8"}),p&&ve(he,{className:"h-[12px] w-[12px]"})]})]})}),x&&ve("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"})]})},nr=vn;import{waitForTransactionReceipt as xn}from"@wagmi/core";import{useCallback as Ke,useEffect as Xe,useState as Cn,useRef as cr}from"react";import{useAccount as Sn,useConfig as Tn,useSendTransaction as Rn,useSwitchChain as An,useWalletClient as kn}from"wagmi";import{useEffect as sr,useRef as or,useState as ar}from"react";import{jsx as bn}from"react/jsx-runtime";var yn=({startTime:e,onExpired:t})=>{let[r,c]=ar(30),[l,s]=ar(!1),a=or(!1),v=or(t);v.current=t,sr(()=>{a.current=!1},[e]),sr(()=>{let d=()=>{let n=Date.now(),w=(e>9999999999?e:e*1e3)+30*1e3,u=Math.max(0,w-n),h=Math.floor(u/1e3);if(h<=0){c(0),a.current||(a.current=!0,s(!0),v.current());return}c(h),s(!1)};if(l)return;d();let o=setInterval(d,1e3);return()=>clearInterval(o)},[e,l]);let m=d=>{let o=Math.floor(d/60),n=d%60;return`${o.toString().padStart(2,"0")}:${n.toString().padStart(2,"0")}`};return l?null:bn("span",{className:"text-xs font-sans",children:m(r)})},ir=yn;import{jsx as fe,jsxs as ft}from"react/jsx-runtime";function Nn(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 ye="signingOrder";async function En(e,t,r,c,l){let s=e.transaction?.encoded,a=s?.to??e.to,v=s?.data??e.data,m=s?.value??e.value;if(!a)throw new Error('Transaction step missing "to" address');let d=s?.chainId,o=e.chainKey||l,n=d||(o?rt(o):void 0);if(!n)throw new Error(`Unknown chain: ${o}`);let y=Ct()[n],w=await r({account:t,chain:y,to:a,data:v||"0x",value:BigInt(m||"0")});return await xn(c,{hash:w,chainId:n}),w}var In=({base:e,baseAmount:t,quote:r,quoteAmount:c,userAddress:l,reviewState:s,goToNextStep:a,cancel:v,isWrappingPair:m,isUnwrappingPair:d,restartSigningFlow:o,onSwapInitiated:n,onOrderSubmitted:y,onSwapComplete:w,startPolling:u,trackNativeTransaction:h})=>{let g=ae(ye,s),[i,p]=Cn("idle"),x=cr(!1),f=cr(null),k=Tn(),{isReconnecting:P}=Sn(),{rfqQuote:S,stop:U,refresh:W}=Be(),{data:N}=kn({chainId:e.chainId}),{switchChain:E}=An(),{sendTransactionAsync:I}=Rn(),M=S?._receivedAt??0,D=Ke(()=>M?Date.now()>=M+30*1e3:!1,[M]),Y=Ke(async()=>{if(x.current||!["idle","error"].includes(i))return;if(!S?.id||!S?._receivedAt){p("error");return}if(!Gt(S.id,S._receivedAt).canSubmit){p("stale");return}x.current=!0;try{if(!N)throw new Error("Wallet client not available");Xt();let R=S.userSteps??[],$;for(let O of R)if(O.type==="TRANSACTION"){p("submitting");let z=O.chainKey||S.srcChainKey,te=z?rt(z):void 0;te&&N.chain?.id!==te&&(await E({chainId:te}),await new Promise(Ve=>setTimeout(Ve,800))),$=await En(O,l,I,k,S.srcChainKey),h($,O.description||`Tx on ${z}`)}else O.type==="SIGNATURE"&&(p("signing"),await Qt({quote:S,signatureStep:O,userAddress:l,walletClient:N}));Kt(S.id,S._receivedAt),y?.(S.id),u(S.id,{baseToken:e,quoteToken:r}),n?.(),U(),p("success"),a(ye,s),w?.(S.id)}catch(R){R instanceof Error&&Nn(R),p("error")}finally{x.current=!1}},[i,S,N,e,r,l,U,u,a,s,w,E,I,n,y,h,k]);Xe(()=>{if(s===ye&&U(),g&&i!=="success"){p("success"),a(ye,s);return}if(i==="success"){a(ye,s);return}if(s===ye&&i==="idle"&&!S?.id){p("refreshingQuote"),W();return}if(s===ye&&i==="idle"&&N&&!x.current&&!P){let C=S?.id||null;C&&f.current!==C&&(f.current=C,Y())}},[g,s,i,N,P,Y,a,S?.id,W,U]),Xe(()=>{i==="refreshingQuote"&&S?.id&&p("idle")},[i,S?.id]),Xe(()=>{s!==ye&&(f.current=null)},[s]),Xe(()=>{let C=setInterval(()=>{D()&&!x.current&&i!=="submitting"&&i!=="success"&&p("stale")},1e3);return()=>clearInterval(C)},[D,i]);let H=()=>{i==="error"&&!x.current&&(f.current=null,p("idle"))},L=Ke(()=>{f.current=null,p("refreshingQuote"),W()},[W]),T=Ke(()=>{o?o(!0):v()},[o,v]),F=()=>i==="error"?"Retry swap":i==="signing"?"Sign Swap Order":i==="submitting"?"Submitting...":i==="refreshingQuote"?"Refreshing Quote...":i==="stale"?"Quote Stale":"Sign & Submit",B=!g&&(i==="error"||i==="stale"),J=B?"var(--widget-status-failed)":"var(--widget-primary)";return ft("div",{className:"flex w-full flex-row justify-between space-x-3",children:[fe("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, ${J} 12%, transparent)`,border:`1px solid color-mix(in srgb, ${J} 20%, transparent)`,color:J,borderRadius:"var(--widget-radius)"},onClick:!g&&i==="error"?H:i==="stale"?T:void 0,children:ft("div",{className:"flex h-10 w-full flex-row items-center space-x-3 px-4",children:[fe(se,{asset:e,size:"xs",noChain:!0}),fe("p",{className:"whitespace-nowrap",children:F()}),fe("div",{className:"flex flex-1 border-t",style:{borderColor:"var(--widget-border)"}}),M>0&&i!=="success"&&i!=="error"&&i!=="stale"&&fe(ir,{startTime:M,onExpired:()=>p("stale")}),ft("div",{className:"flex h-6 w-3 items-center justify-center rounded-full",children:[!g&&(i==="idle"||i==="signing"||i==="submitting"||i==="refreshingQuote")&&fe(K,{size:"5"}),(g||i==="success")&&fe(Z,{className:"h-8 w-8"}),!g&&(i==="error"||i==="stale")&&fe(he,{className:"h-[12px] w-[12px]"})]})]})}),!g&&i==="error"&&fe("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:v,children:"Cancel"})]})},lr=In;import{useEffect as On}from"react";import{jsx as Q,jsxs as pr}from"react/jsx-runtime";var Pn=()=>pr("svg",{className:"w-3 h-3 shrink-0",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[Q("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"}),Q("path",{d:"M15 3H21V9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),Q("path",{d:"M10 14L21 3",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),$n="trackingTx",ur={pending:{icon:Q(K,{size:"5"}),buttonText:"Trade Pending",showNewSwap:!1,statusVar:"var(--widget-primary)",clickable:!1},received:{icon:Q(K,{size:"5"}),buttonText:"Trade Received",showNewSwap:!1,statusVar:"var(--widget-primary)",clickable:!1},completed:{icon:Q(Z,{className:"h-5 w-5"}),buttonText:"View Transaction",showNewSwap:!1,statusVar:"var(--widget-status-completed)",clickable:!0},failed:{icon:Q(De,{}),buttonText:"Retry Swap",showNewSwap:!0,statusVar:"var(--widget-status-failed)",clickable:!0},cancelled:{icon:Q(De,{}),buttonText:"View Transaction",showNewSwap:!1,statusVar:"var(--widget-status-failed)",clickable:!0}},Un=({orderHash:e,base:t,quote:r,baseAmount:c,quoteAmount:l,reviewState:s,onNewSwap:a,onRetry:v,status:m})=>{let d=ae($n,s),o=ur[m]||ur.pending,n=ee(u=>u.explorerUrl);On(()=>{if(m==="completed"){let u=setTimeout(a,15e3);return()=>clearTimeout(u)}},[m,a]);let y=()=>{m==="failed"?v():(m==="completed"||m==="cancelled")&&n&&window.open(n,"_blank","noopener,noreferrer")},w=o.statusVar;return Q("div",{className:"flex flex-row justify-between space-x-3 w-full px-4",children:Q("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?y:void 0,children:pr("div",{className:"flex h-10 w-full flex-row items-center space-x-3 px-4",children:[Q("div",{className:"flex h-6 w-6 items-center justify-center rounded-full overflow-hidden shrink-0",children:o.icon}),Q("p",{className:"whitespace-nowrap",children:o.buttonText}),Q("div",{className:"flex flex-1 border-t",style:{borderColor:"var(--widget-border)"}}),o.clickable&&Q("div",{className:"flex h-6 w-6 items-center justify-center",children:m==="failed"?Q(Et,{}):Q(Pn,{})})]})})})},dr=Un;import{useCallback as fr,useEffect as mr,useState as Mn,useRef as mt}from"react";import{parseUnits as Ln}from"viem";import{useAccount as Wn,useWriteContract as Dn}from"wagmi";import{jsx as xe,jsxs as gt}from"react/jsx-runtime";var Vn=15e3,Ye="unwrapping",_n=({needsToUnwrap:e,amount:t,chainId:r,token:c,reviewState:l,setReviewState:s,goToNextStep:a,cancel:v,delayedClose:m})=>{let d=ae(Ye,l),[o,n]=Mn("idle"),y=Yt(),{writeContractAsync:w}=Dn(),{address:u}=ie(),h=Oe(),g=mt(!1),i=mt(!1),p=mt(null),{status:x}=Wn(),f=fr(()=>{p.current&&(clearTimeout(p.current),p.current=null)},[]),k=fr(async()=>{if(!(g.current||i.current||!u||x!=="connected")){g.current=!0,i.current=!0,n("pending"),p.current=setTimeout(()=>{g.current&&(n("error"),g.current=!1)},Vn);try{let N=q(r);if(!N)throw new Error(`No config for chain ${r}`);let E=N.wrappedAsset.decimals??N.nativeAsset.decimals,I=Ln(t.toString(),E);await y.mutateAsync({chainId:r,accountAddress:u,amountRaw:I,writeContractAsync:w});let M={symbol:N.nativeAsset.symbol,name:N.nativeAsset.name,address:Fe,decimals:N.nativeAsset.decimals,chainId:r},D={symbol:N.wrappedAsset.symbol,name:N.wrappedAsset.name,address:N.wrappedAsset.address,decimals:N.wrappedAsset.decimals,chainId:r};h({type:"unwrap",tokens:[{asset:M,userAddress:u},{asset:D,userAddress:u}]}),f(),n("success"),a(Ye,l),await m()}catch{f(),n("error")}finally{g.current=!1}}},[u,x,r,t,y,w,h,a,l,m,f]);mr(()=>{g.current||i.current||l===Ye&&o==="idle"&&x==="connected"&&(e?k():(n("success"),a(Ye,l)))},[l,o,e,x,k,a]),mr(()=>()=>f(),[f]);let P=()=>{o==="error"&&(i.current=!1,n("idle"))},S=!d&&o==="error",U=!d&&(o==="pending"||o==="idle"||o==="error"),W=S?"var(--widget-status-failed)":"var(--widget-primary)";return gt("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 ${S?"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:S?P:void 0,children:gt("div",{className:"flex h-10 w-full flex-row items-center space-x-3 px-4",children:[xe("p",{className:"whitespace-nowrap",children:S?"Retry Unwrap":c?`Unwrap ${c.symbol}`:"Unwrap Native Token"}),xe("div",{className:"flex flex-1 border-t",style:{borderColor:"var(--widget-border)"}}),gt("div",{className:"flex h-6 w-3 items-center justify-center rounded-full",children:[!d&&(o==="pending"||o==="idle")&&xe(K,{size:"5"}),(d||o==="success")&&xe(Z,{className:"h-8 w-8"}),S&&xe(he,{className:"h-[12px] w-[12px]"})]})]})}),U&&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:v,children:"Cancel"})]})},gr=_n;import{useCallback as wr,useEffect as hr,useState as Fn,useRef as wt}from"react";import{parseUnits as Bn}from"viem";import{useAccount as qn,useWriteContract as zn}from"wagmi";import{jsx as Ce,jsxs as ht}from"react/jsx-runtime";var Qn=15e3,Je="wrapping",jn=({needsToWrap:e,amount:t,chainId:r,token:c,reviewState:l,setReviewState:s,goToNextStep:a,cancel:v,delayedClose:m,isWrappingPair:d})=>{let o=ae(Je,l),[n,y]=Fn("idle"),w=Jt(),{writeContractAsync:u}=zn(),{address:h}=ie(),g=Oe(),i=wt(!1),p=wt(!1),x=wt(null),{status:f}=qn(),k=wr(()=>{x.current&&(clearTimeout(x.current),x.current=null)},[]),P=wr(async()=>{if(!(i.current||p.current||!h||f!=="connected")){i.current=!0,p.current=!0,y("pending"),x.current=setTimeout(()=>{i.current&&(y("error"),i.current=!1)},Qn);try{let E=q(r);if(!E)throw new Error(`No config for chain ${r}`);let I=Bn(t.toString(),E.nativeAsset.decimals);await w.mutateAsync({chainId:r,accountAddress:h,amountRaw:I,writeContractAsync:u});let M={symbol:E.nativeAsset.symbol,name:E.nativeAsset.name,address:Fe,decimals:E.nativeAsset.decimals,chainId:r},D={symbol:E.wrappedAsset.symbol,name:E.wrappedAsset.name,address:E.wrappedAsset.address,decimals:E.wrappedAsset.decimals,chainId:r};g({type:"wrap",tokens:[{asset:M,userAddress:h},{asset:D,userAddress:h}]}),k(),y("success"),a(Je,l),d&&await m()}catch{k(),y("error")}finally{i.current=!1}}},[h,f,r,t,w,u,g,a,l,m,d,k]);hr(()=>{i.current||p.current||l===Je&&n==="idle"&&f==="connected"&&(e?P():(y("success"),a(Je,l)))},[l,n,e,f,P,a]),hr(()=>()=>k(),[k]);let S=()=>{n==="error"&&(p.current=!1,y("idle"))},U=!o&&n==="error",W=!o&&(n==="pending"||n==="idle"||n==="error"),N=U?"var(--widget-status-failed)":"var(--widget-primary)";return ht("div",{className:"flex w-full flex-row justify-between space-x-3",children:[Ce("button",{type:"button",className:`inline-flex h-12 w-full items-center justify-center text-sm font-sans font-medium transition duration-150 ${U?"cursor-pointer":"cursor-not-allowed"}`,style:{backgroundColor:`color-mix(in srgb, ${N} 12%, transparent)`,border:`1px solid color-mix(in srgb, ${N} 20%, transparent)`,color:N,borderRadius:"var(--widget-radius)"},onClick:U?S:void 0,children:ht("div",{className:"flex h-10 w-full flex-row items-center space-x-3 px-4",children:[Ce("p",{className:"whitespace-nowrap",children:U?"Retry Wrap":c?`Wrap ${c.symbol}`:"Wrap Native Token"}),Ce("div",{className:"flex flex-1 border-t",style:{borderColor:"var(--widget-border)"}}),ht("div",{className:"flex h-6 w-3 items-center justify-center rounded-full",children:[!o&&(n==="pending"||n==="idle")&&Ce(K,{size:"5"}),(o||n==="success")&&Ce(Z,{className:"h-8 w-8"}),U&&Ce(he,{className:"h-[12px] w-[12px]"})]})]})}),W&&Ce("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:v,children:"Cancel"})]})},vr=jn;import{jsx as j,jsxs as Kn}from"react/jsx-runtime";var $a=({base:e,baseAmount:t,quote:r,quoteAmount:c,userAddress:l,isWrappingPair:s,isUnwrappingPair:a,isBaseGasToken:v,isQuoteGasToken:m,reviewActionProps:d,reviewState:o,setReviewState:n,trackedOrderHash:y,setTrackedOrderHash:w,txStatus:u,onSwapComplete:h,onSwapInitiated:g,onOrderSubmitted:i,onStaleQuoteRestart:p,setExitHandler:x,setRetryHandler:f})=>{let{rfqQuote:k,status:P,liquidityError:S,routingError:U,sizeCapError:W,stop:N,clear:E}=Be(),{clearForm:I}=Ie(),M=Gn(),{swapButtonVariant:D,widgetType:Y}=Ae(),H=Y==="compact",{trackOrderTransaction:L,trackNativeTransaction:T}=er(),{startPolling:F}=Ft((_,ge,Le)=>{ee.getState().setTxStatus(ge),Le&&ee.getState().setExplorerUrl(Le),ge==="completed"&&L(_,`Swap ${e.symbol} \u2192 ${r.symbol}`)}),[B,J]=Hn(!1),C=yr(!1),R=yr(null),$=s,O=a,z=!s&&!a,te=M!==e?.chainId&&($||O||z),Ve=q(e.chainId),_e={chainId:e.chainId,name:Ve?.displayName??`Chain ${e.chainId}`},G=me((_,ge)=>{if(ge!==_)return;if(_==="chain"){if($){n("wrapping");return}if(O){n("unwrapping");return}n("signingOrder");return}if(_==="signingOrder"){n("trackingTx");return}if(_==="wrapping"){if(!s){n("signingOrder");return}n("wrapSuccess");return}if(_==="unwrapping"){n("wrapSuccess");return}let Le=Tt(_);Le&&n(Le)},[n,s,$,O,z]),le=me(()=>te?"chain":$?"wrapping":O?"unwrapping":z?"signingOrder":null,[te,$,O,z]),re=me(()=>{n(null),I()},[I,n]),Te=me(async()=>{n("wrapSuccess");for(let _=0;_<3;_++)await et(700);re()},[re,n]),ne=me(async()=>{E(),n("cancelled");for(let _=0;_<3;_++)await et(500);re()},[E,re,n]),oe=me(()=>{y&&(ee.getState().stopTracking(),n(null),w(null),I())},[y,n,w,I]),Ue=me(()=>{n(null),w(null),C.current=!0,p?.()},[n,w,p]),ue=me(()=>{d&&n(le())},[le,d,n]),Ze=me((_=!1)=>{_?(C.current=!0,n(null),p?.()):(n(null),R.current=setTimeout(()=>{d&&(n(le()),J(!1))},100))},[n,d,le,p]);Se(()=>{o!==null&&N()},[o,N]),Se(()=>{o!==null&&B&&J(!1)},[o,B]),Se(()=>{x?.(oe)},[x,oe]),Se(()=>(ee.getState().setExitHandler(oe),()=>ee.getState().setExitHandler(null)),[oe]),Se(()=>{f?.(Ue)},[f,Ue]),Se(()=>()=>{R.current&&clearTimeout(R.current)},[]),Se(()=>{C.current&&P==="fresh"&&k?.id&&(C.current=!1,n("signingOrder"))},[P,k?.id,n]);let Me=_=>{if(!_)return{backgroundColor:D==="default"?"var(--widget-muted)":"transparent",color:"var(--widget-muted-foreground)",border:D!=="default"?"1px solid var(--widget-border)":"none",borderRadius:"var(--widget-radius)"};switch(D){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)"}}},Re=`w-full ${H?"py-2":"py-3"} text-sm font-sans font-medium transition-colors cursor-pointer mt-1`;if(o===null&&!s&&!a){if(B)return j("button",{className:Re,disabled:!0,style:{...Me(!1),opacity:.6,cursor:"not-allowed"},children:"Getting fresh quote..."});let _=()=>S?"Insufficient Liquidity":U?"Route Not Available":W?"Size Cap Exceeded":!k&&P==="polling"?"Getting Quote...":k?"Swap":"Enter Amount",ge=!!d;return j("button",{onClick:ge?ue:void 0,disabled:!ge,className:`${Re} disabled:opacity-40 disabled:cursor-not-allowed`,style:Me(ge),children:_()})}return o===null&&a?j("button",{onClick:d?ue:void 0,disabled:!d,className:`${Re} disabled:opacity-40 disabled:cursor-not-allowed`,style:Me(!!d),children:"Unwrap"}):o===null&&s?j("button",{onClick:d?ue:void 0,disabled:!d,className:`${Re} disabled:opacity-40 disabled:cursor-not-allowed`,style:Me(!!d),children:"Wrap"}):o==="success"?j("div",{className:"flex flex-col gap-2 w-full",children:j("button",{className:`w-full ${H?"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"?j("div",{className:"flex flex-col gap-2 w-full",children:j("button",{className:`w-full ${H?"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"?j("div",{className:"flex flex-col gap-2 w-full",children:j("button",{onClick:re,className:`w-full ${H?"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"})}):Kn("div",{className:"flex w-full",children:[o==="chain"&&te&&j(nr,{requiredChain:_e,needsChainSwitch:te&&M!==e.chainId,reviewState:o,goToNextStep:G,cancel:ne}),o==="wrapping"&&$&&j(vr,{needsToWrap:$,amount:t,chainId:e.chainId,token:e,reviewState:o,setReviewState:n,goToNextStep:G,cancel:ne,delayedClose:Te,isWrappingPair:s}),o==="unwrapping"&&O&&j(gr,{needsToUnwrap:O,amount:t,chainId:e.chainId,token:e,reviewState:o,setReviewState:n,goToNextStep:G,cancel:ne,delayedClose:Te}),o==="signingOrder"&&z&&j(lr,{base:e,baseAmount:t,quote:r,quoteAmount:c,userAddress:l,reviewState:o,goToNextStep:G,cancel:ne,restartSigningFlow:Ze,onSwapInitiated:g,onOrderSubmitted:i,isWrappingPair:s,isUnwrappingPair:a,onSwapComplete:h,startPolling:F,trackNativeTransaction:T}),o==="trackingTx"&&y&&j(dr,{orderHash:y,base:e,quote:r,baseAmount:t,quoteAmount:c,reviewState:o,status:u,onNewSwap:oe,onRetry:Ue}),o&&!["chain","wrapping","unwrapping","approval","signingOrder","trackingTx","success","wrapSuccess","cancelled"].includes(o)&&j("button",{disabled:!0,className:`w-full ${H?"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 vt,useCallback as Xn,useRef as yt,useEffect as bt}from"react";import{useShallow as Yn}from"zustand/react/shallow";import{jsx as b,jsxs as A}from"react/jsx-runtime";var br={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)"},Jn=({status:e})=>{let t=br[e]??br.pending;switch(e){case"completed":return b(Z,{className:"h-6 w-6"});case"failed":case"cancelled":return b(De,{className:"h-6 w-6"});default:return b(K,{size:"5",color:t})}};function Zn(e){if(e===0)return"0";let t=Math.abs(e);return t>=1e4?e.toFixed(0):t>=1e3?e.toFixed(1):t>=100?e.toFixed(2):t>=1?e.toFixed(4):t>=.01?e.toFixed(6):e.toExponential(3)}function xr(e){try{let t=new URL(e).pathname.split("/"),r=t[t.length-1];return r&&r.startsWith("0x")?r:null}catch{return null}}function Cr(e){let t=e.length;return t<=4?48:t<=6?40:t<=8?34:28}var xt=()=>A("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:[b("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"}),b("path",{d:"M15 3H21V9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),b("path",{d:"M10 14L21 3",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),es=()=>A("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:[b("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"}),b("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"})]}),ts=({orderHash:e,base:t,quote:r,baseAmount:c,quoteAmount:l,status:s})=>{let[a,v]=vt(!1),[m,d]=vt(!0),o=yt(null),n=yt(Date.now()),[y,w]=vt(null),u=yt(null),{isRecipientInputOpen:h,recipient:g,explorerUrl:i}=ee(Yn(T=>({isRecipientInputOpen:T.isRecipientInputOpen,recipient:T.recipient,explorerUrl:T.explorerUrl})));bt(()=>{s==="received"&&(o.current=Date.now())},[s]),bt(()=>{if(s==="completed"&&!y){let T=o.current||n.current;w((Date.now()-T)/1e3)}},[s,y]),bt(()=>()=>{u.current&&clearTimeout(u.current)},[]);let p=Xn(()=>{if(!navigator.clipboard?.writeText)return;let T=i?xr(i)??e:e;navigator.clipboard.writeText(T).then(()=>{v(!0),u.current&&clearTimeout(u.current),u.current=setTimeout(()=>v(!1),2e3)}).catch(()=>{})},[e,i]),x=Ee(c),f=Ee(l),k=s==="completed"||s==="failed"||s==="cancelled",P=!k,S=c&&l?c/l:0,U=q(t.chainId),W=q(r.chainId),N=U?.displayName??`Chain ${t.chainId}`,E=W?.displayName??`Chain ${r.chainId}`,I=t.chainId!==r.chainId,M=U?.estimatedTimeMs??0,D=W?.estimatedTimeMs??0,Y=(I?M+D:M)/1e3,H=i?xr(i)??e:e,L=`${H.slice(0,6)} \u2026 ${H.slice(-4)}`;return A("div",{className:"relative w-full flex flex-col",children:[A("div",{className:"mx-4 mt-2",style:{backgroundColor:"var(--widget-secondary)"},children:[b("div",{className:"p-5",children:A("div",{className:"flex items-center justify-between",children:[A("div",{children:[A("div",{className:"flex items-center gap-3 mb-3",children:[b(se,{asset:t,size:"md",noChain:!0}),A("div",{children:[b("p",{className:"text-xl font-thin uppercase",style:{color:"var(--widget-foreground)"},children:t.symbol}),b("p",{className:"text-xs",style:{color:"var(--widget-muted-foreground)"},children:t.name})]})]}),A("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:[b(we,{chain:t.chainId,size:"xs"}),b("span",{className:"text-xs pt-0.5",style:{color:"var(--widget-muted-foreground)"},children:N})]})]}),A("div",{className:"text-right",children:[b("p",{className:"font-thin tracking-tight font-sans",style:{color:"var(--widget-foreground)",fontSize:`${Cr(x)}px`,transition:"font-size 0.1s ease-out"},children:x}),t.price&&A("p",{className:"text-xs mt-1 font-sans",style:{color:"var(--widget-muted-foreground)"},children:["$",(t.price*c).toFixed(2)]})]})]})}),A("div",{className:"relative",children:[b("div",{style:{borderTop:"1px solid var(--widget-border)"}}),b("div",{className:"absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2",children:b("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:b(Jn,{status:s})})})]}),b("div",{className:"p-5",children:A("div",{className:"flex items-center justify-between",children:[A("div",{children:[A("div",{className:"flex items-center gap-3 mb-3",children:[b(se,{asset:r,size:"md",noChain:!0}),A("div",{children:[b("p",{className:"text-xl font-thin uppercase",style:{color:"var(--widget-foreground)"},children:r.symbol}),b("p",{className:"text-xs",style:{color:"var(--widget-muted-foreground)"},children:r.name})]})]}),A("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:[b(we,{chain:r.chainId,size:"xs"}),b("span",{className:"text-xs pt-0.5",style:{color:"var(--widget-muted-foreground)"},children:E})]})]}),A("div",{className:"text-right",children:[b("p",{className:"font-thin tracking-tight font-sans",style:{color:"var(--widget-foreground)",fontSize:`${Cr(f)}px`,transition:"font-size 0.1s ease-out"},children:f}),r.price&&A("p",{className:"text-xs mt-1 font-sans",style:{color:"var(--widget-muted-foreground)"},children:["$",(r.price*l).toFixed(2)]})]})]})})]}),h&&g&&b("div",{className:"mx-4 mt-2 px-5 pb-2",children:A("div",{className:"flex items-center gap-2 p-2 rounded-full",style:{backgroundColor:"var(--widget-secondary)"},children:[b("div",{className:"flex h-5 w-5 items-center justify-center overflow-hidden rounded-full",style:{backgroundColor:"var(--widget-muted)"},children:b("span",{className:"text-2xs",children:"\u{1F464}"})}),b("span",{className:"text-xs",style:{color:"var(--widget-muted-foreground)"},children:"To:"}),A("span",{className:"text-xs font-sans",style:{color:"var(--widget-foreground)"},children:[g.slice(0,6),"...",g.slice(-4)]})]})}),A("div",{className:"px-4 mt-4",style:{borderTop:"1px solid var(--widget-border)",borderBottom:"1px solid var(--widget-border)"},children:[b("div",{className:"relative box-border flex flex-row h-8 w-full items-center cursor-pointer",role:"button",tabIndex:0,onClick:()=>d(!m),onKeyDown:T=>{(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),d(!m))},children:b("div",{className:"flex h-full items-center w-full overflow-hidden",style:{color:"var(--widget-muted-foreground)"},children:A("div",{className:"translate-y-px font-sans flex w-full flex-row items-center justify-between",children:[A("div",{className:"flex flex-row items-center gap-2 whitespace-nowrap",children:[A("div",{className:"flex flex-row items-center gap-1",children:[b(se,{asset:r,size:"3xs",noChain:!0,className:"mb-0.5"}),A("span",{className:"text-xs uppercase",style:{color:"var(--widget-muted-foreground)"},children:["1 ",r.symbol]})]}),b("span",{className:"text-xs",style:{color:"var(--widget-muted-foreground)"},children:"="}),A("div",{className:"flex flex-row items-center gap-1",children:[b(se,{asset:t,size:"3xs",noChain:!0,className:"mb-0.5"}),A("span",{className:"text-xs uppercase",style:{color:"var(--widget-muted-foreground)"},children:[Zn(S)," ",t.symbol]})]}),b("span",{className:"text-xs",style:{color:"var(--widget-muted-foreground)"},children:t.price?`\u2248 $${(t.price*S).toFixed(2)}`:""})]}),b("span",{className:"text-xs ml-2 transition-transform duration-200 shrink-0",style:{color:"var(--widget-muted-foreground)",transform:m?"rotate(180deg)":"rotate(0deg)",display:"inline-block"},children:"\u25BE"})]})})}),b("div",{className:"overflow-hidden transition-all duration-200",style:{maxHeight:m?"200px":"0px",opacity:m?1:0},children:A("div",{className:"flex flex-col gap-1 pb-1 font-sans",children:[A("div",{className:"flex justify-between text-2xs",style:{color:"var(--widget-muted-foreground)"},children:[b("span",{children:"USD Value"}),A("span",{style:{color:"var(--widget-secondary-foreground)"},children:["$",t.price?(t.price*c).toFixed(2):"\u2014"]})]}),A("div",{className:"flex justify-between text-2xs",style:{color:"var(--widget-muted-foreground)"},children:[b("span",{style:{color:"var(--widget-muted-foreground)"},children:"Order Type"}),b("span",{style:{color:"var(--widget-secondary-foreground)"},children:"RFQ (Limit)"})]}),A("div",{className:"flex justify-between items-center text-2xs",style:{color:"var(--widget-muted-foreground)"},children:[b("span",{children:"Transaction"}),i?A("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:[b("span",{children:a?"Copied!":L}),b(xt,{})]}):A("button",{type:"button",onClick:p,className:"flex items-center gap-1 cursor-pointer transition-colors",style:{color:"var(--widget-secondary-foreground)"},children:[b("span",{style:{color:"var(--widget-secondary-foreground)"},children:a?"Copied!":L}),b(xt,{})]})]}),A("div",{className:"flex justify-between text-2xs",style:{color:"var(--widget-muted-foreground)"},children:[b("span",{children:k?"Speed":"Est. Time"}),b("span",{style:{color:"var(--widget-secondary-foreground)"},children:y?`${y.toFixed(2)}s`:Y>0?`~${Y}s`:"\u2014"})]}),A("div",{className:"flex justify-between items-center text-2xs",style:{color:"var(--widget-muted-foreground)"},children:[b("span",{children:"Route"}),A("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:[b(es,{}),"Aori",b(xt,{})]})]})]})})]})]})},Fa=ts;export{Nr as a,Oe as b,is as c,gs as d,Be as e,Fr as f,ys as g,Rs as h,Os as i,Ds as j,Fs as k,Vt as l,Ft as m,Bt as n,en as o,Qt as p,tn as q,Gt as r,Kt as s,Xt as t,Yt as u,Jt as v,$a as w,Fa as x};
|