@aori/mega-swap-widget 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/README.md +9 -1
  2. package/dist/AssetSelectionMenu-4E576X3D.cjs +2 -0
  3. package/dist/AssetSelectionMenu-ZFY7XFRX.js +2 -0
  4. package/dist/ChainSelectionMenu-SKXLHK3S.js +2 -0
  5. package/dist/ChainSelectionMenu-VU3SIBVL.cjs +2 -0
  6. package/dist/{SwapFormHorizontal-XMZKEAIL.js → SwapFormHorizontal-GI4X7ISS.js} +1 -1
  7. package/dist/{SwapFormHorizontal-ACRBI6GC.cjs → SwapFormHorizontal-V557YBX2.cjs} +1 -1
  8. package/dist/{SwapFormSplit-SOC2XMBW.js → SwapFormSplit-52RBMJIO.js} +1 -1
  9. package/dist/{SwapFormSplit-XHAGOXQX.cjs → SwapFormSplit-PQCS3BPT.cjs} +1 -1
  10. package/dist/{WidgetWalletPanel-KZFLFLUD.js → WidgetWalletPanel-XYV3YL4I.js} +1 -1
  11. package/dist/{WidgetWalletPanel-FQDNFYFL.cjs → WidgetWalletPanel-YBMN5KZH.cjs} +1 -1
  12. package/dist/{chunk-F7IECVJU.js → chunk-4BQRVCQR.js} +1 -1
  13. package/dist/{chunk-Z2BLIAFE.js → chunk-4LJJMEOG.js} +1 -1
  14. package/dist/{chunk-JSWDMAZQ.js → chunk-726CI6GC.js} +1 -1
  15. package/dist/{chunk-XUTR7YYC.cjs → chunk-DUIRZSBV.cjs} +1 -1
  16. package/dist/{chunk-CHDFHEPH.js → chunk-EW2OR6CJ.js} +1 -1
  17. package/dist/{chunk-TWJY6EY4.js → chunk-FDQKBTWP.js} +1 -1
  18. package/dist/{chunk-E44WNKS4.cjs → chunk-HTWUZKYO.cjs} +1 -1
  19. package/dist/{chunk-BX3KCZRT.cjs → chunk-LXEKOQAG.cjs} +1 -1
  20. package/dist/{chunk-NQ4QSGGF.cjs → chunk-MCT3UZTP.cjs} +1 -1
  21. package/dist/{chunk-537OMWA3.cjs → chunk-UZWGYG2S.cjs} +1 -1
  22. package/dist/{chunk-4XEJKRRM.js → chunk-XYF2YBR3.js} +1 -1
  23. package/dist/{chunk-C3X6NJIB.cjs → chunk-XZRXVBSB.cjs} +1 -1
  24. package/dist/index.cjs +2 -2
  25. package/dist/index.js +1 -1
  26. package/package.json +1 -1
  27. package/dist/AssetSelectionMenu-INISSBWT.js +0 -2
  28. package/dist/AssetSelectionMenu-ZT2PDBHV.cjs +0 -2
  29. package/dist/ChainSelectionMenu-N65VG257.js +0 -2
  30. package/dist/ChainSelectionMenu-URYJUECJ.cjs +0 -2
@@ -1,2 +1,2 @@
1
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; } async function _asyncOptionalChain(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 = await fn(value); } else if (op === 'call' || op === 'optionalCall') { value = await fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }"use client";
2
- var _chunkKH57FLSTcjs = require('./chunk-KH57FLST.cjs');var _chunk537OMWA3cjs = require('./chunk-537OMWA3.cjs');var _chunkBX3KCZRTcjs = require('./chunk-BX3KCZRT.cjs');var _chunk34N36GUDcjs = require('./chunk-34N36GUD.cjs');var _chunkT3I3AJXVcjs = require('./chunk-T3I3AJXV.cjs');var _reactquery = require('@tanstack/react-query');var _react = require('react');function Sr(e){if(e.length===0)return 5e3;let u=Math.max(...e.map(r=>_nullishCoalesce(_optionalChain([_chunkBX3KCZRTcjs.e.call(void 0, r), 'optionalAccess', _2 => _2.blockTimeMs]), () => (2e3))));return Math.min(5e3,Math.max(1e3,u*2+1e3))}var Tr=()=>{let{address:e}=_chunk34N36GUDcjs.a.call(void 0, ),t=_chunkBX3KCZRTcjs._.call(void 0, ),s=_reactquery.useQueryClient.call(void 0, ),l=_react.useRef.call(void 0, null),u=_react.useRef.call(void 0, !0),r=_react.useCallback.call(void 0, a=>{if(!e)return;let h=[...new Set(a.tokens.map(p=>p.asset.chainId))],b=Sr(h);l.current&&(clearTimeout(l.current),l.current=null),l.current=setTimeout(async()=>{if(l.current=null,!!u.current)try{let p=a.tokens.map(f=>({chainId:f.asset.chainId,tokenAddress:f.asset.address})),i=await _chunkBX3KCZRTcjs.J.call(void 0, e,p);if(i.balances.length===0)return;if(a.tokens.length>=2){let f=a.tokens[0].asset,c=a.tokens[1].asset,x=_chunkBX3KCZRTcjs.K.swap(e,f.chainId,f.address,c.chainId,c.address);s.setQueryData(x,i)}let n=_chunkBX3KCZRTcjs.K.bulk(e,t),w=s.getQueryData(n);if(w){let f=w.balances.map(c=>_nullishCoalesce(i.balances.find(g=>g.chainId===c.chainId&&g.token.toLowerCase()===c.token.toLowerCase()), () => (c)));for(let c of i.balances)f.some(x=>x.chainId===c.chainId&&x.token.toLowerCase()===c.token.toLowerCase())||f.push(c);for(let c of a.tokens)if(!i.balances.some(g=>g.chainId===c.asset.chainId&&g.token.toLowerCase()===c.asset.address.toLowerCase())){let g=f.findIndex(o=>o.chainId===c.asset.chainId&&o.token.toLowerCase()===c.asset.address.toLowerCase());g!==-1&&(f[g]={...f[g],balance:"0",shiftedBalance:"0"})}s.setQueryData(n,{balances:f})}}catch (e2){}},b)},[e,t,s]);return _react.useEffect.call(void 0, ()=>(u.current=!0,()=>{u.current=!1,l.current&&(clearTimeout(l.current),l.current=null)}),[]),{triggerBalanceUpdate:r}},st=class extends EventTarget{emit(t){this.dispatchEvent(new CustomEvent("balance-update",{detail:t}))}},ot=new st,Ee= exports.b =()=>e=>ot.emit(e),ts= exports.c =()=>{let{triggerBalanceUpdate:e}=Tr();_react.useEffect.call(void 0, ()=>{let t=s=>{e(s.detail)};return ot.addEventListener("balance-update",t),()=>ot.removeEventListener("balance-update",t)},[e])};var _viem = require('viem');var _jsxruntime = require('react/jsx-runtime');var $t=_react.createContext.call(void 0, void 0),Pt=1e4,Ir=3e4,Or=1e3,Pr=2;function $r(e){return _nullishCoalesce(e.find(s=>_optionalChain([s, 'access', _3 => _3.routeSteps, 'optionalAccess', _4 => _4[0], 'optionalAccess', _5 => _5.type])==="AORI_V1"), () => (e[0]))}var ls=({children:e,recipient:t})=>{let{address:s}=_chunk34N36GUDcjs.a.call(void 0, ),l=t||s,[u,r]=_react.useState.call(void 0, "idle"),[a,h]=_react.useState.call(void 0, "idle"),[b,p]=_react.useState.call(void 0, null),[i,n]=_react.useState.call(void 0, null),[w,f]=_react.useState.call(void 0, !1),[c,x]=_react.useState.call(void 0, !1),[g,o]=_react.useState.call(void 0, !1),m=_react.useRef.call(void 0, null),y=_react.useRef.call(void 0, null),d=_react.useRef.call(void 0, null),T=_react.useRef.call(void 0, null),P=_react.useRef.call(void 0, null),C=_react.useRef.call(void 0, 0),$=_react.useRef.call(void 0, 0),L=_react.useRef.call(void 0, 0),N=_react.useRef.call(void 0, !1),E=_react.useRef.call(void 0, new Map),I=_react.useCallback.call(void 0, ()=>{d.current&&clearTimeout(d.current),T.current&&clearTimeout(T.current),P.current&&clearTimeout(P.current),d.current=null,T.current=null,P.current=null},[]),U=_react.useCallback.call(void 0, ()=>{I(),m.current=null,C.current=0,r(()=>N.current?"fresh":"idle")},[I]),B=_react.useCallback.call(void 0, ()=>{U(),y.current=null,p(null),n(null),f(!1),x(!1),o(!1),E.current.clear(),r("idle"),h("idle")},[U]),oe=_react.useCallback.call(void 0, v=>{if(!v)return;T.current&&clearTimeout(T.current);let S=Math.max(0,v+Ir-Date.now());T.current=setTimeout(()=>{r(O=>O==="idle"?"idle":"stale")},S)},[]),H=_react.useCallback.call(void 0, async(v,S)=>{let{inputToken:O,outputToken:A,inputAmount:q,setOutputAmount:Z}=v;if(!O||!A||!q||parseFloat(q)<=0||Date.now()-($.current||0)<Pt-10)return;let Be=++C.current;try{if(!_optionalChain([O, 'optionalAccess', _6 => _6.decimals])||!_optionalChain([A, 'optionalAccess', _7 => _7.decimals]))return;let z=_chunkBX3KCZRTcjs.C.call(void 0, O.chainId)||_optionalChain([_chunkBX3KCZRTcjs.e.call(void 0, O.chainId), 'optionalAccess', _8 => _8.key])||"",ie=_chunkBX3KCZRTcjs.C.call(void 0, A.chainId)||_optionalChain([_chunkBX3KCZRTcjs.e.call(void 0, A.chainId), 'optionalAccess', _9 => _9.key])||"";if(!z||!ie)throw new Error("Unknown chain");let ee=_viem.parseUnits.call(void 0, q.toString(),O.decimals).toString(),Ce={srcChainKey:z,dstChainKey:ie,srcTokenAddress:_chunkBX3KCZRTcjs.x.call(void 0, O.address),dstTokenAddress:_chunkBX3KCZRTcjs.x.call(void 0, A.address),amount:ee,srcWalletAddress:s||"0x0000000000000000000000000000000000000000",dstWalletAddress:l||s||"0x0000000000000000000000000000000000000000",options:{amountType:"EXACT_SRC_AMOUNT",feeTolerance:{type:"PERCENT",amount:2}}};$.current=Date.now();let te=await fetch(`${_chunkBX3KCZRTcjs.m.call(void 0, )}/quotes`,{method:"POST",headers:_chunkBX3KCZRTcjs.o.call(void 0, ),body:JSON.stringify(Ce),signal:AbortSignal.timeout(15e3)});if(!te.ok){let Se=await _asyncOptionalChain([(await te.json().catch(()=>({}))), 'optionalAccess', async _10 => _10.message])||te.statusText;throw Object.assign(new Error(Se),{status:te.status})}let me=await te.json();if(Be!==C.current||m.current!==S)return;let $e=_nullishCoalesce(me.quotes, () => ([])),ae=$r($e);if(!ae)throw Object.assign(new Error("No quotes returned"),{emptyQuotes:!0});let Je=Number(_viem.formatUnits.call(void 0, _chunkBX3KCZRTcjs.s.call(void 0, ae.dstAmount),A.decimals));typeof Z=="function"&&Z(Je),ae._receivedAt=Date.now(),p(ae),n(null),f(!1),r("fresh"),oe(ae._receivedAt),S&&E.current.delete(S)}catch(z){if(Be!==C.current||m.current!==S)return;let ie=_optionalChain([z, 'optionalAccess', _11 => _11.status]),ee=z instanceof Error?z.message:"",Ce=!!_optionalChain([z, 'optionalAccess', _12 => _12.emptyQuotes]);if((ie===400||Ce||ee.includes("Quote request failed"))&&S){let me=(E.current.get(S)||0)+1;if(E.current.set(S,me),me>=Pr){x(!0),I(),m.current=null;return}}if(ee.toLowerCase().includes("order cap exceeded")){o(!0),I(),m.current=null;return}if(ee.toLowerCase().includes("insufficient executor balance")){f(!0),I(),m.current=null;return}n(z instanceof Error?z.message:"Unknown error")}},[s,l,oe,I]),W=_react.useCallback.call(void 0, (v,S)=>{I(),y.current=v,$.current=0,E.current.delete(S),f(!1),x(!1),o(!1),n(null),r("polling");let O=async()=>{m.current===S&&(await H(v,S),m.current===S&&(d.current=setTimeout(O,Pt)))};O()},[I,H]),R=_react.useCallback.call(void 0, v=>{if(!_optionalChain([v, 'optionalAccess', _13 => _13.inputToken])||!_optionalChain([v, 'optionalAccess', _14 => _14.outputToken])||!_optionalChain([v, 'optionalAccess', _15 => _15.inputAmount])||parseFloat(v.inputAmount)<=0){U();return}let S=y.current;if(S&&_optionalChain([S, 'access', _16 => _16.inputToken, 'optionalAccess', _17 => _17.address])===_optionalChain([v, 'access', _18 => _18.inputToken, 'optionalAccess', _19 => _19.address])&&_optionalChain([S, 'access', _20 => _20.inputToken, 'optionalAccess', _21 => _21.chainId])===_optionalChain([v, 'access', _22 => _22.inputToken, 'optionalAccess', _23 => _23.chainId])&&_optionalChain([S, 'access', _24 => _24.outputToken, 'optionalAccess', _25 => _25.address])===_optionalChain([v, 'access', _26 => _26.outputToken, 'optionalAccess', _27 => _27.address])&&_optionalChain([S, 'access', _28 => _28.outputToken, 'optionalAccess', _29 => _29.chainId])===_optionalChain([v, 'access', _30 => _30.outputToken, 'optionalAccess', _31 => _31.chainId])&&S.inputAmount===v.inputAmount&&m.current)return;let A=Date.now();if(A-L.current<100)return;L.current=A;let q=`${Date.now()}-${Math.random().toString(36).slice(2)}`;m.current=q,W(v,q)},[W,U]),V=_react.useCallback.call(void 0, ({amount:v,inputToken:S,outputToken:O,setOutputAmount:A})=>{A(null),P.current&&clearTimeout(P.current),!v||v===0?(h("idle"),U(),p(null),n(null),f(!1),x(!1),o(!1)):(h("typing"),U(),p(null),f(!1),x(!1),o(!1),n(null),P.current=setTimeout(()=>{h("settled"),S&&O&&v>0&&R({inputToken:S,outputToken:O,inputAmount:v.toString(),setOutputAmount:A})},Or))},[U,R]),F=_react.useCallback.call(void 0, ()=>{let v=y.current;if(!v)return;p(null);let S=`${Date.now()}-${Math.random().toString(36).slice(2)}`;m.current=S,r("refreshing"),typeof v.setOutputAmount=="function"&&v.setOutputAmount(null),W(v,S)},[W]);_react.useEffect.call(void 0, ()=>{N.current=!!b},[b]),_react.useEffect.call(void 0, ()=>()=>I(),[I]);let X=_react.useMemo.call(void 0, ()=>({status:u,inputState:a,rfqQuote:b,error:i,liquidityError:w,routingError:c,sizeCapError:g,ensureForParams:R,stop:U,refresh:F,clear:B,handleInputChange:V}),[u,a,b,i,w,c,g,R,U,F,B,V]);return _jsxruntime.jsx.call(void 0, $t.Provider,{value:X,children:e})},Ve= exports.e =()=>{let e=_react.useContext.call(void 0, $t);if(e===void 0)throw new Error("useRfq must be used within an RfqProvider");return e};var Wr=_react.createContext.call(void 0, {openConnectModal:()=>{}}),ms= exports.g =()=>_react.useContext.call(void 0, Wr);var Lr=20,Br=({side:e,asset:t,otherAsset:s,isPlacingOrder:l,isWrappingPair:u,isUnwrappingPair:r})=>{let{baseAmount:a,quoteAmount:h,setBaseAmount:b,setQuoteAmount:p}=_chunk537OMWA3cjs.f.call(void 0, ),{amountInputVariant:i,hideAmountInputSymbol:n,widgetType:w}=_chunkBX3KCZRTcjs.b.call(void 0, ),f=w==="compact",[c,x]=e==="base"?[b,p]:[p,b],g=!t||e==="quote"||l,o=f?32:i==="default"?64:32,[m,y]=_react.useState.call(void 0, o),[d,T]=_react.useState.call(void 0, ""),P=_react.useRef.call(void 0, null),C=_react.useRef.call(void 0, null),$=_react.useRef.call(void 0, null),L=_react.useRef.call(void 0, null),N="USD",E=e==="base"?a:h,[I,U]=_react.useState.call(void 0, !1),B=_react.useCallback.call(void 0, ()=>{if(i!=="default"){y(o);return}if(!P.current||!C.current||!$.current)return;let W=P.current.offsetWidth,R=20,V=o;for(;V>20&&(C.current.style.fontSize=`${V}px`,$.current.style.fontSize=`${V}px`,!(C.current.offsetWidth+$.current.offsetWidth+R<=W));)V-=1;y(V)},[i,o]),oe=_react.useCallback.call(void 0, W=>{W.key==="."&&d.includes(".")&&W.preventDefault()},[d]),H=_react.useCallback.call(void 0, W=>{let R=W.target.value;if(R==="."&&(R="0."),!/^\d*\.?\d*$/.test(R)||(R.match(/\./g)||[]).length>1)return;if(R.length>1&&R[0]==="0"&&R[1]!=="."&&(R=R.replace(/^0+/,"")||"0"),_optionalChain([t, 'optionalAccess', _32 => _32.decimals])!==void 0&&R.includes(".")){let[,F]=R.split(".");if(F&&F.length>t.decimals)return}if(R.length>Lr)return;T(R);let V=parseFloat(R);R!==d&&(R===""||R==="0."||R.endsWith(".")?(c(null),e==="base"&&x(null)):!Number.isNaN(V)&&V>=0&&c(V),e==="base"&&p(null),(r||u)&&p(V||0))},[d,c,e,p,_optionalChain([t, 'optionalAccess', _33 => _33.decimals]),x,r,u]);return _react.useEffect.call(void 0, ()=>{let W=F=>{if(F===null)return"";let X=_optionalChain([t, 'optionalAccess', _34 => _34.decimals]);if(X===void 0)return"";let v=F.toString();if(/e/i.test(v)&&(v=Number(F).toLocaleString("en-US",{useGrouping:!1,maximumFractionDigits:X})),v.includes(".")){let[S,O]=v.split("."),A=O.slice(0,X);return A?`${S}.${A}`:S}return v};if(E===null){d==="0."||d!==""&&d.endsWith(".")||T("");return}if(!g&&(d.endsWith(".")||d.match(/\.\d*0$/)||d==="0"||d==="0.")&&d!=="")return;let V=parseFloat(d)||0;(d===""||Math.abs(V-E)>1e-10)&&T(W(E))},[E,_optionalChain([t, 'optionalAccess', _35 => _35.decimals]),d,g]),_react.useEffect.call(void 0, ()=>{B()},[d,B]),_react.useEffect.call(void 0, ()=>{U(!0)},[]),_react.useEffect.call(void 0, ()=>{I&&B()},[I,B]),_react.useEffect.call(void 0, ()=>{C.current&&L.current&&(L.current.style.width=`${C.current.offsetWidth}px`)},[d]),_react.useEffect.call(void 0, ()=>{if(!I)return;let W=new ResizeObserver(()=>{I&&B()});return P.current&&W.observe(P.current),()=>W.disconnect()},[I,B]),_jsxruntime.jsx.call(void 0, "div",{ref:P,style:{fontSize:`${m}px`,transition:"font-size 0.05s ease-in-out"},className:`mt-2 box-border flex ${f?i==="normal"?"h-12 my-1":"h-10 my-0.5":i==="normal"?"h-12 my-1":"h-20 my-1"} w-full flex-row items-center ${g?"cursor-default":"cursor-text"}`,onClick:()=>_optionalChain([L, 'access', _36 => _36.current, 'optionalAccess', _37 => _37.focus, 'call', _38 => _38()]),children:_jsxruntime.jsxs.call(void 0, "div",{className:"relative flex w-full items-center",children:[_jsxruntime.jsx.call(void 0, "label",{htmlFor:`${e}Amount`,className:"sr-only",children:e==="base"?"Input token amount":"Output token amount"}),_jsxruntime.jsx.call(void 0, "input",{ref:L,type:"text",inputMode:"decimal",placeholder:"0",autoComplete:"off",id:`${e}Amount`,value:d,onWheel:W=>W.target.blur(),onKeyDown:oe,onChange:H,style:{transition:"width 0.15s ease-in-out",color:"var(--widget-foreground)",WebkitTextFillColor:"var(--widget-foreground)",opacity:g?.4:1},className:"flex min-w-[45px] whitespace-nowrap bg-transparent placeholder:opacity-50",disabled:g}),_jsxruntime.jsx.call(void 0, "span",{style:{transition:"width 0.15s ease-in-out"},ref:C,className:"pointer-events-none absolute flex whitespace-nowrap invisible",children:d||0}),!n&&i!=="normal"&&_jsxruntime.jsx.call(void 0, "span",{ref:$,className:"ml-2 font-light uppercase",style:{color:"var(--widget-foreground)",opacity:.5,fontSize:`${m}px`},children:_optionalChain([t, 'optionalAccess', _39 => _39.symbol])?t.symbol.length>6?`${t.symbol.slice(0,6)}...`:t.symbol:N}),(n||i==="normal")&&_jsxruntime.jsx.call(void 0, "span",{ref:$,className:"hidden"})]})})},ys= exports.h =Br;var Vr=({toggle:e,side:t,asset:s,isPlacingOrder:l})=>{let{baseBalance:u,quoteBalance:r}=_chunk537OMWA3cjs.f.call(void 0, ),{tokenDisplay:a,tokenBadgeOrientation:h,widgetType:b}=_chunkBX3KCZRTcjs.b.call(void 0, ),p=b==="compact",i=p?"h-10":"h-12",n=p?"h-10 w-10":"h-12 w-12",w=t==="base"?u.formatted?(()=>{let c=parseFloat(u.formatted);return c>=1e8?_chunkBX3KCZRTcjs.q.call(void 0, c):c.toFixed(3)})():void 0:r.formatted?(()=>{let c=parseFloat(r.formatted);return c>=1e8?_chunkBX3KCZRTcjs.q.call(void 0, c):c.toFixed(3)})():void 0,f={role:"button",tabIndex:l?-1:0,"aria-disabled":l,"aria-label":`Select ${t==="base"?"input":"output"} token${s?`: ${s.symbol}`:""}`,onClick:l?void 0:e,onKeyDown:l?void 0:c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),e())}};return a==="pill"?_jsxruntime.jsx.call(void 0, "div",{...f,className:`inline-flex items-center gap-1.5 h-7 px-2.5 rounded-full cursor-pointer transition-colors ${h==="right"?"ml-auto":""}`,style:{border:"1px solid var(--widget-border)",backgroundColor:"var(--widget-secondary)",color:"var(--widget-secondary-foreground)"},children:s?_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, _chunkBX3KCZRTcjs.O,{chain:s.chainId,size:"xs"}),_jsxruntime.jsx.call(void 0, _chunkBX3KCZRTcjs.P,{className:"rounded-full",asset:s,size:"xxs",noChain:!0}),_jsxruntime.jsx.call(void 0, "span",{className:"text-xs font-medium uppercase",children:s.symbol}),_jsxruntime.jsx.call(void 0, _chunkBX3KCZRTcjs.V,{className:"w-1.5 opacity-60",style:{color:"var(--widget-secondary-foreground)"}})]}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "span",{className:"text-xs opacity-70",children:"Select"}),_jsxruntime.jsx.call(void 0, _chunkBX3KCZRTcjs.V,{className:"w-1.5 opacity-60",style:{color:"var(--widget-secondary-foreground)"}})]})}):a==="ghost"?_jsxruntime.jsxs.call(void 0, "div",{...f,className:"inline-flex items-center gap-1.5 cursor-pointer transition-opacity hover:opacity-70 py-1",style:{color:"var(--widget-foreground)"},children:[s?_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, _chunkBX3KCZRTcjs.O,{chain:s.chainId,size:"xs"}),_jsxruntime.jsx.call(void 0, _chunkBX3KCZRTcjs.P,{className:"rounded-full",asset:s,size:"xxs",noChain:!0}),_jsxruntime.jsx.call(void 0, "span",{className:"text-sm font-medium uppercase",children:s.symbol})]}):_jsxruntime.jsx.call(void 0, "span",{className:"text-sm",style:{color:"var(--widget-muted-foreground)"},children:"Select token"}),_jsxruntime.jsx.call(void 0, _chunkBX3KCZRTcjs.V,{className:"w-1.5 opacity-50"})]}):_jsxruntime.jsx.call(void 0, "div",{...f,className:`relative ${i} 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:_jsxruntime.jsx.call(void 0, "div",{className:"relative flex h-full w-full flex-row items-center",children:s?_jsxruntime.jsxs.call(void 0, "div",{className:"relative flex h-full w-full flex-row items-center",children:[_jsxruntime.jsx.call(void 0, "div",{className:`${n} pl-px flex items-center justify-center`,children:_jsxruntime.jsx.call(void 0, _chunkBX3KCZRTcjs.P,{className:"rounded-full",asset:s,size:"md"})}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-full w-full flex-row items-center justify-between pl-1.5 pr-7",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-full flex-col justify-center",children:[_jsxruntime.jsx.call(void 0, "p",{className:"text-sm font-medium uppercase",style:{color:"var(--widget-secondary-foreground)"},children:s.symbol}),_jsxruntime.jsxs.call(void 0, "span",{className:"text-2xs font-mono",style:{color:"var(--widget-secondary-foreground)",opacity:.6},children:[_optionalChain([s, 'access', _40 => _40.address, 'optionalAccess', _41 => _41.slice, 'call', _42 => _42(0,6)]),"...",_optionalChain([s, 'access', _43 => _43.address, 'optionalAccess', _44 => _44.slice, 'call', _45 => _45(-4)])]})]}),w!==void 0&&_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col text-right",children:[_jsxruntime.jsx.call(void 0, "p",{className:"text-2xs",style:{color:"var(--widget-secondary-foreground)",opacity:.5},children:"Balance"}),_jsxruntime.jsx.call(void 0, "span",{className:"font-mono text-xs tabular-nums",style:{color:"var(--widget-secondary-foreground)"},children:w})]})]}),_jsxruntime.jsx.call(void 0, _chunkBX3KCZRTcjs.V,{className:"absolute right-3 top-1/2 w-1.5 translate-y-[-50%]",style:{color:"var(--widget-secondary-foreground)",opacity:.6}})]}):_jsxruntime.jsx.call(void 0, "div",{className:"flex h-full w-full items-center justify-center",children:_jsxruntime.jsx.call(void 0, "span",{className:"text-sm",style:{color:"var(--widget-secondary-foreground)",opacity:.7},children:"Select token"})})})})},Rs= exports.i =Vr;var Mt=_chunkT3I3AJXVcjs.b.call(void 0, _chunkKH57FLSTcjs.a.call(void 0, ),1);var Fr=()=>{let[e,t]=_react.useState.call(void 0, null),[s,l]=_react.useState.call(void 0, ""),u=_chunkBX3KCZRTcjs.z.call(void 0, s,1e3),[r,a]=_react.useState.call(void 0, !1),[h,b]=_react.useState.call(void 0, "");_react.useEffect.call(void 0, ()=>{_chunk537OMWA3cjs.c.getState().setRecipient(e)},[e]),_react.useEffect.call(void 0, ()=>{l(e||"")},[e]);let p=n=>{let w=n.target.value;r&&(a(!1),b(""),t(null)),l(w),w===""&&t(null)};_react.useEffect.call(void 0, ()=>{u===""||!u?(a(!1),b(""),t(null)):_chunkBX3KCZRTcjs.y.call(void 0, u)?(a(!1),b(""),t(u)):(a(!0),b("Invalid wallet address..."),t(null),l(""))},[u]),_react.useEffect.call(void 0, ()=>{if(r){let n=setTimeout(()=>{t(null),l(""),a(!1),b("")},2e3);return()=>clearTimeout(n)}},[r]);let i=()=>{t(null),l(""),a(!1),b("")};return _jsxruntime.jsx.call(void 0, "div",{className:"w-full",children:_jsxruntime.jsxs.call(void 0, "div",{className:"relative flex flex-row items-center",children:[_jsxruntime.jsx.call(void 0, "input",{type:"password",style:{display:"none"},"aria-hidden":"true",tabIndex:-1}),_jsxruntime.jsx.call(void 0, "label",{htmlFor:"recipient-address",className:"sr-only",children:"Recipient wallet address"}),_jsxruntime.jsx.call(void 0, "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&&!r?_jsxruntime.jsx.call(void 0, "img",{className:"h-full w-full rounded-full object-cover",src:(0,Mt.makeGradient)(e),alt:"Recipient avatar"}):_jsxruntime.jsx.call(void 0, _chunkBX3KCZRTcjs.U,{className:"h-5 w-5",style:{color:r?"var(--widget-destructive)":"var(--widget-muted-foreground)"}})}),_jsxruntime.jsx.call(void 0, "div",{className:"absolute left-12 top-1.5 -translate-y-1 text-xs font-medium opacity-60",style:{color:r?"var(--widget-destructive)":"var(--widget-muted-foreground)"},"aria-hidden":"true",children:"To:"}),_jsxruntime.jsx.call(void 0, "input",{id:"recipient-address",className:"mono block h-10 w-full items-center pl-12 pt-4 pr-8 text-xs",style:{backgroundColor:r?"color-mix(in srgb, var(--widget-destructive) 10%, transparent)":"transparent",color:r?"var(--widget-destructive)":"var(--widget-foreground)",outline:"none",opacity:r?.9:1},placeholder:r?h:"Enter recipient address...",value:s,onChange:p,spellCheck:!1,"aria-invalid":r,"aria-describedby":r?"recipient-error":void 0}),r&&_jsxruntime.jsx.call(void 0, "span",{id:"recipient-error",className:"sr-only",children:h}),e&&!r&&_jsxruntime.jsxs.call(void 0, "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:i,"aria-label":"Clear recipient",children:[_jsxruntime.jsx.call(void 0, "svg",{className:"h-2.5 w-2.5",viewBox:"0 -0.5 21 21",fill:"none",children:_jsxruntime.jsx.call(void 0, "g",{fill:"currentColor",fillRule:"evenodd",children:_jsxruntime.jsx.call(void 0, "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)"})})}),_jsxruntime.jsx.call(void 0, "span",{className:"sr-only",children:"Clear recipient"})]})]})})},Ps= exports.j =Fr;var qr=["SUCCEEDED","FAILED","COMPLETED","CANCELLED"];async function Dt(e,t,s={}){let{onStatusChange:l,onComplete:u,onError:r,interval:a=4e3,timeout:h=3e5,txHash:b,signal:p}=s,i=null,n=Date.now(),w=0,f=8,c=null,x=b?`?txHash=${b}`:"";return new Promise((g,o)=>{let m=async()=>{try{if(_optionalChain([p, 'optionalAccess', _46 => _46.aborted])){c&&clearTimeout(c),o(new DOMException("Polling aborted","AbortError"));return}if(Date.now()-n>h){c&&clearTimeout(c);let P=new Error("Order status polling timed out");_optionalChain([r, 'optionalCall', _47 => _47(P)]),o(P);return}let y=await fetch(`${t}/status/${e}${x}`,{headers:_chunkBX3KCZRTcjs.o.call(void 0, ),signal:p});if(y.status===404){c=setTimeout(m,a);return}if(!y.ok)throw new Error(`Failed to fetch order status: ${await y.text()}`);let d=await y.json();if(!d||typeof d!="object"||!d.status)throw new Error(`Invalid status response format: ${JSON.stringify(d)}`);w=0;let T=d.status.toUpperCase();if(T!==i&&(i=T,_optionalChain([l, 'optionalCall', _48 => _48(d)])),qr.includes(T)){c&&clearTimeout(c),_optionalChain([u, 'optionalCall', _49 => _49(d)]),g(d);return}c=setTimeout(m,a)}catch(y){if(y instanceof Error&&y.name==="AbortError"){c&&clearTimeout(c),o(y);return}if(++w>=f){c&&clearTimeout(c);let d=y instanceof Error?y:new Error(String(y));_optionalChain([r, 'optionalCall', _50 => _50(d)]),o(d);return}c=setTimeout(m,a)}};m()})}function Wt(e){let t=e.toUpperCase();return t==="SUCCEEDED"||t==="COMPLETED"?"completed":t==="FAILED"?"failed":t==="CANCELLED"?"cancelled":t==="PROCESSING"?"received":"pending"}var Lt=e=>{let t=_react.useRef.call(void 0, new Map),s=_react.useRef.call(void 0, new Map),l=_react.useRef.call(void 0, new Map),u=_react.useRef.call(void 0, 0),r=_react.useCallback.call(void 0, ()=>++u.current,[]),{address:a}=_chunk34N36GUDcjs.a.call(void 0, ),h=Ee(),b=_react.useCallback.call(void 0, (n,w)=>{if(t.current.get(n))return;w&&s.current.set(n,w),t.current.set(n,!0);let f=u.current,c=new AbortController;l.current.set(n,c);let x=_optionalChain([w, 'optionalAccess', _51 => _51.baseToken, 'optionalAccess', _52 => _52.chainId])===1;Dt(n,_chunkBX3KCZRTcjs.m.call(void 0, ),{interval:x?1e3:500,timeout:3e5,signal:c.signal,onStatusChange:g=>{if(!_optionalChain([g, 'optionalAccess', _53 => _53.status]))return;let o=Wt(g.status);if(_optionalChain([e, 'optionalCall', _54 => _54(n,o)]),o==="completed"&&a){let m=s.current.get(n);if(m&&(m.baseToken||m.quoteToken)){let y=[];m.baseToken&&y.push({asset:m.baseToken,userAddress:a}),m.quoteToken&&y.push({asset:m.quoteToken,userAddress:a}),h({type:"swap",tokens:y})}}["completed","failed","cancelled"].includes(o)&&(t.current.delete(n),s.current.delete(n)),f!==u.current&&(t.current.delete(n),s.current.delete(n))},onComplete:g=>{_optionalChain([g, 'optionalAccess', _55 => _55.status])&&_optionalChain([e, 'optionalCall', _56 => _56(n,Wt(g.status))]),t.current.delete(n),s.current.delete(n)},onError:()=>{t.current.delete(n),s.current.delete(n)}}).catch(g=>{g instanceof Error&&g.name==="AbortError"||(t.current.delete(n),s.current.delete(n),l.current.delete(n))})},[a,h,e]),p=_react.useCallback.call(void 0, n=>{let w=l.current.get(n);w&&(w.abort(),l.current.delete(n)),r(),t.current.delete(n),s.current.delete(n)},[r]),i=_react.useCallback.call(void 0, ()=>{for(let n of l.current.values())n.abort();l.current.clear(),r(),t.current.clear(),s.current.clear()},[r]);return _react.useEffect.call(void 0, ()=>()=>i(),[i]),{startPolling:b,stopPolling:p,stopAllPolling:i,isPolling:n=>t.current.has(n)}};var Gr=_react.createContext.call(void 0, {registerTransaction:()=>{},enabled:!1}),Bt= exports.m =()=>_react.useContext.call(void 0, Gr);var _actions = require('viem/actions');function Vt(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 _t(e){if(_optionalChain([e, 'access', _57 => _57.chain, 'optionalAccess', _58 => _58.id]))return e.chain.id;let t=_optionalChain([e, 'access', _59 => _59.getChainId, 'optionalCall', _60 => _60()]);return t!=null?await t:null}var Hr=async(e,t)=>{try{if(await _t(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 _t(e)===t}catch(s){throw Vt(s)?new Error("User rejected the chain switch request"):new Error(`Please switch your wallet to the required network (Chain ID: ${t})`)}},Ft= exports.o =async e=>{let{quote:t,signatureStep:s,userAddress:l,walletClient:u}=e;if(!u)throw new Error("Wallet client not available");if(s.type!=="SIGNATURE"||!_optionalChain([s, 'access', _61 => _61.signature, 'optionalAccess', _62 => _62.typedData]))throw new Error("Invalid signature step");try{let r=s.signature.typedData,a={...r.message};for(let i of["inputAmount","outputAmount","startTime","endTime"])a[i]!=null&&(a[i]=BigInt(a[i]));let h=r.domain;if(h.chainId!=null){let i=Number(h.chainId);await Hr(u,i)}let b=await _actions.signTypedData.call(void 0, u,{account:l,domain:h,types:r.types,primaryType:r.primaryType,message:a}),p=await fetch(`${_chunkBX3KCZRTcjs.m.call(void 0, )}/submit-signature`,{method:"POST",headers:_chunkBX3KCZRTcjs.o.call(void 0, ),body:JSON.stringify({quoteId:t.id,signatures:[b]})});if(!p.ok){let i=await p.json().catch(()=>({}));throw new Error(_optionalChain([i, 'optionalAccess', _63 => _63.message])||`Submit failed: ${p.status}`)}return{quoteId:t.id,signature:b}}catch(r){throw Vt(r)?new Error("User rejected the signing request"):r instanceof Error&&r.message.includes("chain")?new Error("Chain switching failed. Please manually switch to the correct network."):r}};var qt="vt_submitted_quotes";var lt=()=>{try{let e=localStorage.getItem(qt);return e?JSON.parse(e):[]}catch (e3){return[]}},Qt=e=>{try{localStorage.setItem(qt,JSON.stringify(e))}catch (e4){}},Xr= exports.p =e=>{let t=Date.now(),s=typeof e=="string"?new Date(e).getTime():e>9999999999?e:e*1e3;return t<s+3e4},Yr=e=>lt().some(t=>t.quoteId===e),jt= exports.q =(e,t)=>Yr(e)?{canSubmit:!1,reason:"Order already submitted"}:Xr(t)?{canSubmit:!0}:{canSubmit:!1,reason:"Quote has expired"},zt= exports.r =(e,t)=>{let s=typeof t=="string"?new Date(t).getTime():t,l=lt();l.push({quoteId:e,submittedAt:Date.now(),createdAt:s}),Qt(l)},Gt= exports.s =()=>{let e=lt(),t=Date.now(),s=300*1e3,l=e.filter(u=>t-u.submittedAt<s);l.length!==e.length&&Qt(l)};var _core = require('@wagmi/core');var _abis = require('abitype/abis');var _wagmi = require('wagmi');function Kt(){let e=_wagmi.useConfig.call(void 0, );return _reactquery.useMutation.call(void 0, {mutationFn:async({chainId:t,accountAddress:s,amountRaw:l,writeContractAsync:u})=>{let r=_chunkBX3KCZRTcjs.e.call(void 0, t);if(!r)throw new Error(`No wrapping contract for chain ${t}`);let a=r.wrappedAsset.address,h=await u({abi:_abis.wethAbi,functionName:"withdraw",address:a,account:s,args:[l],chainId:t});if((await _core.waitForTransactionReceipt.call(void 0, e,{hash:h,chainId:t,confirmations:1,pollingInterval:4e3})).status!=="success")throw new Error("Unwrap transaction did not get successful receipt");return{success:!0,hash:h}}})}function Ht(){let e=_wagmi.useConfig.call(void 0, );return _reactquery.useMutation.call(void 0, {mutationFn:async({chainId:t,accountAddress:s,amountRaw:l,writeContractAsync:u})=>{let r=_chunkBX3KCZRTcjs.e.call(void 0, t);if(!r)throw new Error(`No wrapping contract for chain ${t}`);let a=r.wrappedAsset.address,h=await u({abi:_abis.wethAbi,functionName:"deposit",address:a,account:s,value:l,chainId:t});if((await _core.waitForTransactionReceipt.call(void 0, e,{hash:h,chainId:t,confirmations:1,pollingInterval:4e3})).status!=="success")throw new Error("Wrap transaction did not get successful receipt");return{success:!0,hash:h}}})}function Yt(){let{registerTransaction:e,enabled:t}=Bt(),s=_react.useRef.call(void 0, new Set),l=_react.useCallback.call(void 0, (r,a)=>{!t||s.current.has(r)||(s.current.add(r),e(r,a))},[t,e]),u=_react.useCallback.call(void 0, (r,a)=>{!t||s.current.has(r)||(s.current.add(r),e(r,a))},[t,e]);return{trackOrderTransaction:l,trackNativeTransaction:u,txTrackingEnabled:t}}var pn=15e3,Ge="chain",mn=({needsChainSwitch:e,requiredChain:t,reviewState:s,goToNextStep:l,cancel:u})=>{let r=_chunkBX3KCZRTcjs.t.call(void 0, Ge,s),[a,h]=_react.useState.call(void 0, "pending"),b=_react.useRef.call(void 0, !1),p=_react.useRef.call(void 0, !1),i=_react.useRef.call(void 0, null),n=_wagmi.useChainId.call(void 0, ),{switchChainAsync:w}=_wagmi.useSwitchChain.call(void 0, ),{status:f,isReconnecting:c}=_wagmi.useAccount.call(void 0, ),x=_react.useCallback.call(void 0, ()=>{i.current&&(clearTimeout(i.current),i.current=null)},[]),g=_react.useCallback.call(void 0, async()=>{if(!(b.current||p.current||f!=="connected"||c)){b.current=!0,p.current=!0,h("pending"),i.current=setTimeout(()=>{b.current&&(h("error"),b.current=!1)},pn);try{await w({chainId:t.chainId}),x(),h("success"),l(Ge,s)}catch (e5){x(),h("error")}finally{b.current=!1}}},[w,f,c,t.chainId,l,s,x]);_react.useEffect.call(void 0, ()=>{b.current||p.current||s===Ge&&a==="pending"&&f==="connected"&&!c&&(e&&n!==t.chainId?g():(h("success"),l(Ge,s)))},[s,a,e,n,t.chainId,f,c,g,l]),_react.useEffect.call(void 0, ()=>()=>x(),[x]);let o=()=>{a==="error"&&(p.current=!1,h("pending"))},m=!r&&a==="error",y=!r&&(a==="pending"||a==="error"),d=m?"var(--widget-status-failed)":"var(--widget-status-pending)";return _jsxruntime.jsxs.call(void 0, "div",{className:"flex w-full flex-row justify-between space-x-3",children:[_jsxruntime.jsx.call(void 0, "button",{type:"button",className:`inline-flex h-12 w-full items-center justify-center text-sm font-medium transition duration-150 ${m?"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:m?o:void 0,children:_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-10 w-full flex-row items-center space-x-3 px-4",children:[_jsxruntime.jsx.call(void 0, _chunkBX3KCZRTcjs.O,{chain:t.chainId,size:"xs"}),_jsxruntime.jsx.call(void 0, "p",{className:"whitespace-nowrap",children:m?"Retry Switch":`Switch to ${t.name}`}),_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-1 border-t",style:{borderColor:"var(--widget-border)"}}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-6 w-3 items-center justify-center rounded-full",children:[!r&&a==="pending"&&_jsxruntime.jsx.call(void 0, _chunkBX3KCZRTcjs.W,{size:"5"}),(r||a==="success")&&_jsxruntime.jsx.call(void 0, _chunkBX3KCZRTcjs.Q,{className:"h-8 w-8"}),m&&_jsxruntime.jsx.call(void 0, _chunkBX3KCZRTcjs.T,{className:"h-[12px] w-[12px]"})]})]})}),y&&_jsxruntime.jsx.call(void 0, "button",{type:"button",className:"inline-flex h-12 items-center justify-center px-8 text-sm 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:u,children:"Cancel"})]})},er=mn;var fn=({startTime:e,onExpired:t})=>{let[s,l]=_react.useState.call(void 0, 30),[u,r]=_react.useState.call(void 0, !1),a=_react.useRef.call(void 0, !1),h=_react.useRef.call(void 0, t);h.current=t,_react.useEffect.call(void 0, ()=>{a.current=!1},[e]),_react.useEffect.call(void 0, ()=>{let p=()=>{let n=Date.now(),f=(e>9999999999?e:e*1e3)+30*1e3,c=Math.max(0,f-n),x=Math.floor(c/1e3);if(x<=0){l(0),a.current||(a.current=!0,r(!0),h.current());return}l(x),r(!1)};if(u)return;p();let i=setInterval(p,1e3);return()=>clearInterval(i)},[e,u]);let b=p=>{let i=Math.floor(p/60),n=p%60;return`${i.toString().padStart(2,"0")}:${n.toString().padStart(2,"0")}`};return u?null:_jsxruntime.jsx.call(void 0, "span",{className:"text-xs font-mono",children:b(s)})},sr=fn;function Sn(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 be="signingOrder";async function Tn(e,t,s,l,u){let r=_optionalChain([e, 'access', _64 => _64.transaction, 'optionalAccess', _65 => _65.encoded]),a=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _66 => _66.to]), () => (e.to)),h=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _67 => _67.data]), () => (e.data)),b=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _68 => _68.value]), () => (e.value));if(!a)throw new Error('Transaction step missing "to" address');let p=_optionalChain([r, 'optionalAccess', _69 => _69.chainId]),i=e.chainKey||u,n=p||(i?_chunkBX3KCZRTcjs.B.call(void 0, i):void 0);if(!n)throw new Error(`Unknown chain: ${i}`);let w=_chunkBX3KCZRTcjs.j.call(void 0, )[n],f=await s({account:t,chain:w,to:a,data:h||"0x",value:BigInt(b||"0")});return await _core.waitForTransactionReceipt.call(void 0, l,{hash:f,chainId:n}),f}var Rn=({base:e,baseAmount:t,quote:s,quoteAmount:l,userAddress:u,reviewState:r,goToNextStep:a,cancel:h,isWrappingPair:b,isUnwrappingPair:p,restartSigningFlow:i,onSwapInitiated:n,onOrderSubmitted:w,onSwapComplete:f,startPolling:c,trackNativeTransaction:x})=>{let g=_chunkBX3KCZRTcjs.t.call(void 0, be,r),[o,m]=_react.useState.call(void 0, "idle"),y=_react.useRef.call(void 0, !1),d=_react.useRef.call(void 0, null),T=_wagmi.useConfig.call(void 0, ),{isReconnecting:P}=_wagmi.useAccount.call(void 0, ),{rfqQuote:C,stop:$,refresh:L}=Ve(),{data:N}=_wagmi.useWalletClient.call(void 0, {chainId:e.chainId}),{switchChain:E}=_wagmi.useSwitchChain.call(void 0, ),{sendTransactionAsync:I}=_wagmi.useSendTransaction.call(void 0, ),U=_nullishCoalesce(_optionalChain([C, 'optionalAccess', _70 => _70._receivedAt]), () => (0)),B=_react.useCallback.call(void 0, ()=>U?Date.now()>=U+30*1e3:!1,[U]),oe=_react.useCallback.call(void 0, async()=>{if(y.current||!["idle","error"].includes(o))return;if(!_optionalChain([C, 'optionalAccess', _71 => _71.id])||!_optionalChain([C, 'optionalAccess', _72 => _72._receivedAt])){m("error");return}if(!jt(C.id,C._receivedAt).canSubmit){m("stale");return}y.current=!0;try{if(!N)throw new Error("Wallet client not available");Gt();let S=_nullishCoalesce(C.userSteps, () => ([])),O;for(let A of S)if(A.type==="TRANSACTION"){m("submitting");let q=A.chainKey||C.srcChainKey,Z=q?_chunkBX3KCZRTcjs.B.call(void 0, q):void 0;Z&&_optionalChain([N, 'access', _73 => _73.chain, 'optionalAccess', _74 => _74.id])!==Z&&(await E({chainId:Z}),await new Promise(Le=>setTimeout(Le,800))),O=await Tn(A,u,I,T,C.srcChainKey),x(O,A.description||`Tx on ${q}`)}else A.type==="SIGNATURE"&&(m("signing"),await Ft({quote:C,signatureStep:A,userAddress:u,walletClient:N}));zt(C.id,C._receivedAt),_optionalChain([w, 'optionalCall', _75 => _75(C.id)]),c(C.id,{baseToken:e,quoteToken:s}),_optionalChain([n, 'optionalCall', _76 => _76()]),$(),m("success"),a(be,r),_optionalChain([f, 'optionalCall', _77 => _77(C.id)])}catch(S){S instanceof Error&&Sn(S)?(d.current=null,m("idle")):m("error")}finally{y.current=!1}},[o,C,N,e,s,u,$,c,a,r,f,E,I,n,w,x,T]);_react.useEffect.call(void 0, ()=>{if(r===be&&$(),g&&o!=="success"){m("success"),a(be,r);return}if(o==="success"){a(be,r);return}if(r===be&&o==="idle"&&!_optionalChain([C, 'optionalAccess', _78 => _78.id])){m("refreshingQuote"),L();return}if(r===be&&o==="idle"&&N&&!y.current&&!P){let v=_optionalChain([C, 'optionalAccess', _79 => _79.id])||null;v&&d.current!==v&&(d.current=v,oe())}},[g,r,o,N,P,oe,a,_optionalChain([C, 'optionalAccess', _80 => _80.id]),L,$]),_react.useEffect.call(void 0, ()=>{o==="refreshingQuote"&&_optionalChain([C, 'optionalAccess', _81 => _81.id])&&m("idle")},[o,_optionalChain([C, 'optionalAccess', _82 => _82.id])]),_react.useEffect.call(void 0, ()=>{r!==be&&(d.current=null)},[r]),_react.useEffect.call(void 0, ()=>{let v=setInterval(()=>{B()&&!y.current&&o!=="submitting"&&o!=="success"&&m("stale")},1e3);return()=>clearInterval(v)},[B,o]);let H=()=>{o==="error"&&!y.current&&(d.current=null,m("idle"))},W=_react.useCallback.call(void 0, ()=>{d.current=null,m("refreshingQuote"),L()},[L]),R=_react.useCallback.call(void 0, ()=>{i?i(!0):h()},[i,h]),V=()=>o==="error"?"Retry swap":o==="signing"?"Sign Swap Order":o==="submitting"?"Submitting...":o==="refreshingQuote"?"Refreshing Quote...":o==="stale"?"Quote Stale":"Sign & Submit",F=!g&&(o==="error"||o==="stale"),X=F?"var(--widget-status-failed)":"var(--widget-status-pending)";return _jsxruntime.jsxs.call(void 0, "div",{className:"flex w-full flex-row justify-between space-x-3",children:[_jsxruntime.jsx.call(void 0, "button",{type:"button",className:`inline-flex h-12 w-full items-center justify-center text-sm font-medium transition duration-150 ${F?"cursor-pointer":"cursor-not-allowed"}`,style:{backgroundColor:`color-mix(in srgb, ${X} 12%, transparent)`,border:`1px solid color-mix(in srgb, ${X} 20%, transparent)`,color:X,borderRadius:"var(--widget-radius)"},onClick:!g&&o==="error"?H:o==="stale"?R:void 0,children:_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-10 w-full flex-row items-center space-x-3 px-4",children:[_jsxruntime.jsx.call(void 0, _chunkBX3KCZRTcjs.P,{asset:e,size:"xs",noChain:!0}),_jsxruntime.jsx.call(void 0, "p",{className:"whitespace-nowrap",children:V()}),_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-1 border-t",style:{borderColor:"var(--widget-border)"}}),U>0&&o!=="success"&&o!=="error"&&o!=="stale"&&_jsxruntime.jsx.call(void 0, sr,{startTime:U,onExpired:()=>m("stale")}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-6 w-3 items-center justify-center rounded-full",children:[!g&&(o==="idle"||o==="signing"||o==="submitting"||o==="refreshingQuote")&&_jsxruntime.jsx.call(void 0, _chunkBX3KCZRTcjs.W,{size:"5"}),(g||o==="success")&&_jsxruntime.jsx.call(void 0, _chunkBX3KCZRTcjs.Q,{className:"h-8 w-8"}),!g&&(o==="error"||o==="stale")&&_jsxruntime.jsx.call(void 0, _chunkBX3KCZRTcjs.T,{className:"h-[12px] w-[12px]"})]})]})}),!g&&o==="error"&&_jsxruntime.jsx.call(void 0, "button",{type:"button",className:"inline-flex h-12 items-center justify-center px-8 text-sm 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:h,children:"Cancel"})]})},ir=Rn;var kn="trackingTx",ar={pending:{icon:_jsxruntime.jsx.call(void 0, _chunkBX3KCZRTcjs.W,{size:"5"}),buttonText:"Trade Pending",showNewSwap:!1,statusVar:"var(--widget-status-pending)",clickable:!1},received:{icon:_jsxruntime.jsx.call(void 0, _chunkBX3KCZRTcjs.W,{size:"5"}),buttonText:"Trade Received",showNewSwap:!1,statusVar:"var(--widget-status-received)",clickable:!1},completed:{icon:_jsxruntime.jsx.call(void 0, _chunkBX3KCZRTcjs.Q,{}),buttonText:"Continue Swapping",showNewSwap:!0,statusVar:"var(--widget-status-completed)",clickable:!0},failed:{icon:_jsxruntime.jsx.call(void 0, _chunkBX3KCZRTcjs.Z,{}),buttonText:"Retry Swap",showNewSwap:!0,statusVar:"var(--widget-status-failed)",clickable:!0},cancelled:{icon:_jsxruntime.jsx.call(void 0, _chunkBX3KCZRTcjs.Z,{}),buttonText:"Continue Swapping",showNewSwap:!0,statusVar:"var(--widget-status-failed)",clickable:!0}},Nn=({orderHash:e,base:t,quote:s,baseAmount:l,quoteAmount:u,reviewState:r,onNewSwap:a,onRetry:h,status:b})=>{let p=_chunkBX3KCZRTcjs.t.call(void 0, kn,r),i=ar[b]||ar.pending;_react.useEffect.call(void 0, ()=>{if(b==="completed"){let f=setTimeout(a,5e3);return()=>clearTimeout(f)}},[b,a]);let n=()=>{b==="failed"?h():i.showNewSwap&&a()},w=i.statusVar;return _jsxruntime.jsx.call(void 0, "div",{className:"flex flex-row justify-between space-x-3 w-full",children:_jsxruntime.jsx.call(void 0, "button",{type:"button",className:`inline-flex h-12 w-full items-center justify-center text-sm font-medium transition duration-150 ${i.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:i.showNewSwap?n:void 0,children:_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-10 w-full flex-row items-center space-x-3 px-4",children:[_jsxruntime.jsx.call(void 0, "div",{className:"flex h-6 w-6 items-center justify-center rounded-full",children:i.icon}),_jsxruntime.jsx.call(void 0, "p",{className:"whitespace-nowrap",children:i.buttonText}),_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-1 border-t",style:{borderColor:"var(--widget-border)"}}),i.showNewSwap&&_jsxruntime.jsx.call(void 0, "div",{className:"flex h-6 w-6 items-center justify-center",children:_jsxruntime.jsx.call(void 0, _chunkBX3KCZRTcjs.Y,{})})]})})})},cr=Nn;var Un=15e3,Xe="unwrapping",Mn=({needsToUnwrap:e,amount:t,chainId:s,token:l,reviewState:u,setReviewState:r,goToNextStep:a,cancel:h,delayedClose:b})=>{let p=_chunkBX3KCZRTcjs.t.call(void 0, Xe,u),[i,n]=_react.useState.call(void 0, "idle"),w=Kt(),{writeContractAsync:f}=_wagmi.useWriteContract.call(void 0, ),{address:c}=_chunk34N36GUDcjs.a.call(void 0, ),x=Ee(),g=_react.useRef.call(void 0, !1),o=_react.useRef.call(void 0, !1),m=_react.useRef.call(void 0, null),{status:y}=_wagmi.useAccount.call(void 0, ),d=_react.useCallback.call(void 0, ()=>{m.current&&(clearTimeout(m.current),m.current=null)},[]),T=_react.useCallback.call(void 0, async()=>{if(!(g.current||o.current||!c||y!=="connected")){g.current=!0,o.current=!0,n("pending"),m.current=setTimeout(()=>{g.current&&(n("error"),g.current=!1)},Un);try{let N=_chunkBX3KCZRTcjs.e.call(void 0, s);if(!N)throw new Error(`No config for chain ${s}`);let E=_nullishCoalesce(N.wrappedAsset.decimals, () => (N.nativeAsset.decimals)),I=_viem.parseUnits.call(void 0, t.toString(),E);await w.mutateAsync({chainId:s,accountAddress:c,amountRaw:I,writeContractAsync:f});let U={symbol:N.nativeAsset.symbol,name:N.nativeAsset.name,address:_chunkBX3KCZRTcjs.c,decimals:N.nativeAsset.decimals,chainId:s},B={symbol:N.wrappedAsset.symbol,name:N.wrappedAsset.name,address:N.wrappedAsset.address,decimals:N.wrappedAsset.decimals,chainId:s};x({type:"unwrap",tokens:[{asset:U,userAddress:c},{asset:B,userAddress:c}]}),d(),n("success"),a(Xe,u),await b()}catch (e6){d(),n("error")}finally{g.current=!1}}},[c,y,s,t,w,f,x,a,u,b,d]);_react.useEffect.call(void 0, ()=>{g.current||o.current||u===Xe&&i==="idle"&&y==="connected"&&(e?T():(n("success"),a(Xe,u)))},[u,i,e,y,T,a]),_react.useEffect.call(void 0, ()=>()=>d(),[d]);let P=()=>{i==="error"&&(o.current=!1,n("idle"))},C=!p&&i==="error",$=!p&&(i==="pending"||i==="idle"||i==="error"),L=C?"var(--widget-status-failed)":"var(--widget-status-pending)";return _jsxruntime.jsxs.call(void 0, "div",{className:"flex w-full flex-row justify-between space-x-3",children:[_jsxruntime.jsx.call(void 0, "button",{type:"button",className:`inline-flex h-12 w-full items-center justify-center text-sm font-medium transition duration-150 ${C?"cursor-pointer":"cursor-not-allowed"}`,style:{backgroundColor:`color-mix(in srgb, ${L} 12%, transparent)`,border:`1px solid color-mix(in srgb, ${L} 20%, transparent)`,color:L,borderRadius:"var(--widget-radius)"},onClick:C?P:void 0,children:_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-10 w-full flex-row items-center space-x-3 px-4",children:[_jsxruntime.jsx.call(void 0, "p",{className:"whitespace-nowrap",children:C?"Retry Unwrap":l?`Unwrap ${l.symbol}`:"Unwrap Native Token"}),_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-1 border-t",style:{borderColor:"var(--widget-border)"}}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-6 w-3 items-center justify-center rounded-full",children:[!p&&(i==="pending"||i==="idle")&&_jsxruntime.jsx.call(void 0, _chunkBX3KCZRTcjs.W,{size:"5"}),(p||i==="success")&&_jsxruntime.jsx.call(void 0, _chunkBX3KCZRTcjs.Q,{className:"h-8 w-8"}),C&&_jsxruntime.jsx.call(void 0, _chunkBX3KCZRTcjs.T,{className:"h-[12px] w-[12px]"})]})]})}),$&&_jsxruntime.jsx.call(void 0, "button",{type:"button",className:"inline-flex h-12 items-center justify-center px-8 text-sm 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:h,children:"Cancel"})]})},dr=Mn;var _n=15e3,Ye="wrapping",Vn=({needsToWrap:e,amount:t,chainId:s,token:l,reviewState:u,setReviewState:r,goToNextStep:a,cancel:h,delayedClose:b,isWrappingPair:p})=>{let i=_chunkBX3KCZRTcjs.t.call(void 0, Ye,u),[n,w]=_react.useState.call(void 0, "idle"),f=Ht(),{writeContractAsync:c}=_wagmi.useWriteContract.call(void 0, ),{address:x}=_chunk34N36GUDcjs.a.call(void 0, ),g=Ee(),o=_react.useRef.call(void 0, !1),m=_react.useRef.call(void 0, !1),y=_react.useRef.call(void 0, null),{status:d}=_wagmi.useAccount.call(void 0, ),T=_react.useCallback.call(void 0, ()=>{y.current&&(clearTimeout(y.current),y.current=null)},[]),P=_react.useCallback.call(void 0, async()=>{if(!(o.current||m.current||!x||d!=="connected")){o.current=!0,m.current=!0,w("pending"),y.current=setTimeout(()=>{o.current&&(w("error"),o.current=!1)},_n);try{let E=_chunkBX3KCZRTcjs.e.call(void 0, s);if(!E)throw new Error(`No config for chain ${s}`);let I=_viem.parseUnits.call(void 0, t.toString(),E.nativeAsset.decimals);await f.mutateAsync({chainId:s,accountAddress:x,amountRaw:I,writeContractAsync:c});let U={symbol:E.nativeAsset.symbol,name:E.nativeAsset.name,address:_chunkBX3KCZRTcjs.c,decimals:E.nativeAsset.decimals,chainId:s},B={symbol:E.wrappedAsset.symbol,name:E.wrappedAsset.name,address:E.wrappedAsset.address,decimals:E.wrappedAsset.decimals,chainId:s};g({type:"wrap",tokens:[{asset:U,userAddress:x},{asset:B,userAddress:x}]}),T(),w("success"),a(Ye,u),p&&await b()}catch (e7){T(),w("error")}finally{o.current=!1}}},[x,d,s,t,f,c,g,a,u,b,p,T]);_react.useEffect.call(void 0, ()=>{o.current||m.current||u===Ye&&n==="idle"&&d==="connected"&&(e?P():(w("success"),a(Ye,u)))},[u,n,e,d,P,a]),_react.useEffect.call(void 0, ()=>()=>T(),[T]);let C=()=>{n==="error"&&(m.current=!1,w("idle"))},$=!i&&n==="error",L=!i&&(n==="pending"||n==="idle"||n==="error"),N=$?"var(--widget-status-failed)":"var(--widget-status-pending)";return _jsxruntime.jsxs.call(void 0, "div",{className:"flex w-full flex-row justify-between space-x-3",children:[_jsxruntime.jsx.call(void 0, "button",{type:"button",className:`inline-flex h-12 w-full items-center justify-center text-sm font-medium transition duration-150 ${$?"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:$?C:void 0,children:_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-10 w-full flex-row items-center space-x-3 px-4",children:[_jsxruntime.jsx.call(void 0, "p",{className:"whitespace-nowrap",children:$?"Retry Wrap":l?`Wrap ${l.symbol}`:"Wrap Native Token"}),_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-1 border-t",style:{borderColor:"var(--widget-border)"}}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-6 w-3 items-center justify-center rounded-full",children:[!i&&(n==="pending"||n==="idle")&&_jsxruntime.jsx.call(void 0, _chunkBX3KCZRTcjs.W,{size:"5"}),(i||n==="success")&&_jsxruntime.jsx.call(void 0, _chunkBX3KCZRTcjs.Q,{className:"h-8 w-8"}),$&&_jsxruntime.jsx.call(void 0, _chunkBX3KCZRTcjs.T,{className:"h-[12px] w-[12px]"})]})]})}),L&&_jsxruntime.jsx.call(void 0, "button",{type:"button",className:"inline-flex h-12 items-center justify-center px-8 text-sm 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:h,children:"Cancel"})]})},fr=Vn;var Si=({base:e,baseAmount:t,quote:s,quoteAmount:l,userAddress:u,isWrappingPair:r,isUnwrappingPair:a,isBaseGasToken:h,isQuoteGasToken:b,reviewActionProps:p,reviewState:i,setReviewState:n,trackedOrderHash:w,setTrackedOrderHash:f,txStatus:c,onSwapComplete:x,onSwapInitiated:g,onOrderSubmitted:o,onStaleQuoteRestart:m,setExitHandler:y,setRetryHandler:d})=>{let{rfqQuote:T,status:P,liquidityError:C,routingError:$,sizeCapError:L,stop:N,clear:E}=Ve(),{clearForm:I}=_chunk537OMWA3cjs.f.call(void 0, ),U=_wagmi.useChainId.call(void 0, ),{swapButtonVariant:B,widgetType:oe}=_chunkBX3KCZRTcjs.b.call(void 0, ),H=oe==="compact",{trackOrderTransaction:W,trackNativeTransaction:R}=Yt(),{startPolling:V}=Lt((_,fe)=>{_chunk537OMWA3cjs.c.getState().setTxStatus(fe),fe==="completed"&&W(_,`Swap ${e.symbol} \u2192 ${s.symbol}`)}),[F,X]=_react.useState.call(void 0, !1),v=_react.useRef.call(void 0, !1),S=_react.useRef.call(void 0, null),O=r,A=a,q=!r&&!a,Z=U!==_optionalChain([e, 'optionalAccess', _83 => _83.chainId])&&(O||A||q),Le=_chunkBX3KCZRTcjs.e.call(void 0, e.chainId),Be={chainId:e.chainId,name:_nullishCoalesce(_optionalChain([Le, 'optionalAccess', _84 => _84.displayName]), () => (`Chain ${e.chainId}`))},z=_react.useCallback.call(void 0, (_,fe)=>{if(fe!==_)return;if(_==="chain"){if(O){n("wrapping");return}if(A){n("unwrapping");return}n("signingOrder");return}if(_==="signingOrder"){n("trackingTx");return}if(_==="wrapping"){if(!r){n("signingOrder");return}n("wrapSuccess");return}if(_==="unwrapping"){n("wrapSuccess");return}let yt=_chunkBX3KCZRTcjs.u.call(void 0, _);yt&&n(yt)},[n,r,O,A,q]),ie=_react.useCallback.call(void 0, ()=>Z?"chain":O?"wrapping":A?"unwrapping":q?"signingOrder":null,[Z,O,A,q]),ee=_react.useCallback.call(void 0, ()=>{n(null),I()},[I,n]),Ce=_react.useCallback.call(void 0, async()=>{n("wrapSuccess");for(let _=0;_<3;_++)await _chunkBX3KCZRTcjs.v.call(void 0, 700);ee()},[ee,n]),te=_react.useCallback.call(void 0, async()=>{E(),n("cancelled");for(let _=0;_<3;_++)await _chunkBX3KCZRTcjs.v.call(void 0, 500);ee()},[E,ee,n]),me=_react.useCallback.call(void 0, ()=>{w&&(_chunk537OMWA3cjs.c.getState().stopTracking(),n(null),f(null),I())},[w,n,f,I]),$e=_react.useCallback.call(void 0, ()=>{n(null),f(null),v.current=!0,_optionalChain([m, 'optionalCall', _85 => _85()])},[n,f,m]),ae=_react.useCallback.call(void 0, ()=>{p&&n(ie())},[ie,p,n]),Je=_react.useCallback.call(void 0, (_=!1)=>{_?(v.current=!0,n(null),_optionalChain([m, 'optionalCall', _86 => _86()])):(n(null),S.current=setTimeout(()=>{p&&(n(ie()),X(!1))},100))},[n,p,ie,m]);_react.useEffect.call(void 0, ()=>{i!==null&&N()},[i,N]),_react.useEffect.call(void 0, ()=>{i!==null&&F&&X(!1)},[i,F]),_react.useEffect.call(void 0, ()=>{_optionalChain([y, 'optionalCall', _87 => _87(me)])},[y,me]),_react.useEffect.call(void 0, ()=>{_optionalChain([d, 'optionalCall', _88 => _88($e)])},[d,$e]),_react.useEffect.call(void 0, ()=>()=>{S.current&&clearTimeout(S.current)},[]),_react.useEffect.call(void 0, ()=>{v.current&&P==="fresh"&&_optionalChain([T, 'optionalAccess', _89 => _89.id])&&(v.current=!1,n("signingOrder"))},[P,_optionalChain([T, 'optionalAccess', _90 => _90.id]),n]);let Ue=_=>{if(!_)return{backgroundColor:B==="default"?"var(--widget-muted)":"transparent",color:"var(--widget-muted-foreground)",border:B!=="default"?"1px solid var(--widget-border)":"none",borderRadius:"var(--widget-radius)"};switch(B){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)"}}},Se=`w-full ${H?"py-2":"py-3"} text-sm font-medium transition-colors cursor-pointer mt-1`;if(i===null&&!r&&!a){if(F)return _jsxruntime.jsx.call(void 0, "button",{className:Se,disabled:!0,style:{...Ue(!1),opacity:.6,cursor:"not-allowed"},children:"Getting fresh quote..."});let _=()=>C?"Insufficient Liquidity":$?"Route Not Available":L?"Size Cap Exceeded":!T&&P==="polling"?"Getting Quote...":T?"Swap":"Enter Amount",fe=!!p;return _jsxruntime.jsx.call(void 0, "button",{onClick:fe?ae:void 0,disabled:!fe,className:`${Se} disabled:opacity-40 disabled:cursor-not-allowed`,style:Ue(fe),children:_()})}return i===null&&a?_jsxruntime.jsx.call(void 0, "button",{onClick:p?ae:void 0,disabled:!p,className:`${Se} disabled:opacity-40 disabled:cursor-not-allowed`,style:Ue(!!p),children:"Unwrap"}):i===null&&r?_jsxruntime.jsx.call(void 0, "button",{onClick:p?ae:void 0,disabled:!p,className:`${Se} disabled:opacity-40 disabled:cursor-not-allowed`,style:Ue(!!p),children:"Wrap"}):i==="success"?_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-col gap-2 w-full",children:_jsxruntime.jsx.call(void 0, "button",{className:`w-full ${H?"py-2":"py-3"} text-sm 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"})}):i==="wrapSuccess"?_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-col gap-2 w-full",children:_jsxruntime.jsx.call(void 0, "button",{className:`w-full ${H?"py-2":"py-3"} text-sm 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:r?"Wrapped Successfully":"Unwrapped Successfully"})}):i==="cancelled"?_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-col gap-2 w-full",children:_jsxruntime.jsx.call(void 0, "button",{onClick:ee,className:`w-full ${H?"py-2":"py-3"} text-sm 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"})}):_jsxruntime.jsxs.call(void 0, "div",{className:"flex w-full",children:[i==="chain"&&Z&&_jsxruntime.jsx.call(void 0, er,{requiredChain:Be,needsChainSwitch:Z&&U!==e.chainId,reviewState:i,goToNextStep:z,cancel:te}),i==="wrapping"&&O&&_jsxruntime.jsx.call(void 0, fr,{needsToWrap:O,amount:t,chainId:e.chainId,token:e,reviewState:i,setReviewState:n,goToNextStep:z,cancel:te,delayedClose:Ce,isWrappingPair:r}),i==="unwrapping"&&A&&_jsxruntime.jsx.call(void 0, dr,{needsToUnwrap:A,amount:t,chainId:e.chainId,token:e,reviewState:i,setReviewState:n,goToNextStep:z,cancel:te,delayedClose:Ce}),i==="signingOrder"&&q&&_jsxruntime.jsx.call(void 0, ir,{base:e,baseAmount:t,quote:s,quoteAmount:l,userAddress:u,reviewState:i,goToNextStep:z,cancel:te,restartSigningFlow:Je,onSwapInitiated:g,onOrderSubmitted:o,isWrappingPair:r,isUnwrappingPair:a,onSwapComplete:x,startPolling:V,trackNativeTransaction:R}),i==="trackingTx"&&w&&_jsxruntime.jsx.call(void 0, cr,{orderHash:w,base:e,quote:s,baseAmount:t,quoteAmount:l,reviewState:i,status:c,onNewSwap:me,onRetry:$e}),i&&!["chain","wrapping","unwrapping","approval","signingOrder","trackingTx","success","wrapSuccess","cancelled"].includes(i)&&_jsxruntime.jsx.call(void 0, "button",{disabled:!0,className:`w-full ${H?"py-2":"py-3"} text-sm font-medium`,style:{backgroundColor:"var(--widget-muted)",color:"var(--widget-muted-foreground)",borderRadius:"var(--widget-radius)"},children:"Processing..."})]})};var _shallow = require('zustand/react/shallow');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)"},hr={pending:{title:"Trade Pending",subtitle:"Submitting to network"},received:{title:"Trade Received",subtitle:"Processing settlement"},completed:{title:"Trade Filled",subtitle:"Settlement complete"},failed:{title:"Trade Failed",subtitle:"Settlement unsuccessful"},cancelled:{title:"Trade Cancelled",subtitle:"Order was cancelled"}};function Gn(e){let t=_nullishCoalesce(br[e], () => (br.pending));return{textColor:t,bgColor:`color-mix(in srgb, ${t} 15%, transparent)`,borderColor:`color-mix(in srgb, ${t} 20%, transparent)`,cardBgColor:`color-mix(in srgb, ${t} 8%, transparent)`,cardBorderColor:`color-mix(in srgb, ${t} 15%, transparent)`,iconBgColor:`color-mix(in srgb, ${t} 12%, transparent)`,iconBorderColor:`color-mix(in srgb, ${t} 15%, transparent)`}}var Kn=({status:e})=>{switch(e){case"completed":return _jsxruntime.jsx.call(void 0, _chunkBX3KCZRTcjs.Q,{});case"failed":case"cancelled":return _jsxruntime.jsx.call(void 0, _chunkBX3KCZRTcjs.Z,{});default:return _jsxruntime.jsx.call(void 0, _chunkBX3KCZRTcjs.W,{size:"10"})}},Hn=({orderHash:e,base:t,quote:s,baseAmount:l,quoteAmount:u,status:r})=>{let[a,h]=_react.useState.call(void 0, !1),b=_react.useRef.call(void 0, null),p=_react.useRef.call(void 0, Date.now()),[i,n]=_react.useState.call(void 0, null),w=_react.useRef.call(void 0, null),{isRecipientInputOpen:f,recipient:c}=_chunk537OMWA3cjs.c.call(void 0, _shallow.useShallow.call(void 0, d=>({isRecipientInputOpen:d.isRecipientInputOpen,recipient:d.recipient})));_react.useEffect.call(void 0, ()=>{r==="received"&&(b.current=Date.now())},[r]),_react.useEffect.call(void 0, ()=>{if(r==="completed"&&!i){let d=b.current||p.current;n((Date.now()-d)/1e3)}},[r,i]),_react.useEffect.call(void 0, ()=>()=>{w.current&&clearTimeout(w.current)},[]);let x=_react.useCallback.call(void 0, ()=>{_optionalChain([navigator, 'access', _91 => _91.clipboard, 'optionalAccess', _92 => _92.writeText])&&navigator.clipboard.writeText(e).then(()=>{h(!0),w.current&&clearTimeout(w.current),w.current=setTimeout(()=>h(!1),2e3)}).catch(()=>{})},[e]),g=_nullishCoalesce(hr[r], () => (hr.pending)),o=Gn(r),m=_chunkBX3KCZRTcjs.q.call(void 0, l),y=_chunkBX3KCZRTcjs.q.call(void 0, u);return _jsxruntime.jsx.call(void 0, "div",{className:"relative w-full h-full overflow-hidden flex flex-col",style:{backgroundColor:o.bgColor,border:`1px var(--widget-border-style) ${o.borderColor}`,backdropFilter:"blur(8px)"},children:_jsxruntime.jsxs.call(void 0, "div",{className:"relative z-10 px-3 pt-5 pb-3 flex-1 flex flex-col",children:[_jsxruntime.jsx.call(void 0, "div",{className:"flex items-center justify-center mb-2",children:_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col items-center gap-1 text-center",children:[_jsxruntime.jsx.call(void 0, "div",{className:"flex h-10 w-10 items-center justify-center rounded-full border",style:{backgroundColor:o.iconBgColor,borderColor:o.iconBorderColor},children:_jsxruntime.jsx.call(void 0, "div",{className:"h-7 w-7 flex items-center justify-center",children:_jsxruntime.jsx.call(void 0, Kn,{status:r})})}),_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "h3",{className:"text-xl font-bold",style:{color:o.textColor},children:g.title}),_jsxruntime.jsx.call(void 0, "p",{className:"text-2xs uppercase tracking-wider",style:{color:o.textColor,opacity:.6},children:g.subtitle})]})]})}),_jsxruntime.jsx.call(void 0, "div",{className:"flex-1 flex flex-col justify-center",children:_jsxruntime.jsxs.call(void 0, "div",{className:"space-y-1.5",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center justify-between backdrop-blur-sm p-2.5 border transition-all duration-300",style:{backgroundColor:o.cardBgColor,borderColor:o.cardBorderColor},children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center gap-2.5",children:[_jsxruntime.jsx.call(void 0, _chunkBX3KCZRTcjs.P,{asset:t,size:"sm"}),_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "div",{className:"text-sm font-bold",style:{color:o.textColor},children:t.symbol}),_jsxruntime.jsx.call(void 0, "div",{className:"text-2xs",style:{color:o.textColor,opacity:.5},children:t.name})]})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"text-right",children:[_jsxruntime.jsx.call(void 0, "div",{className:"text-lg font-bold mono",style:{color:o.textColor},children:m}),t.price&&_jsxruntime.jsxs.call(void 0, "div",{className:"text-2xs mono",style:{color:o.textColor,opacity:.5},children:["$",(t.price*l).toFixed(2)]})]})]}),_jsxruntime.jsx.call(void 0, "div",{className:"flex justify-center pb-0.5 pt-1",children:_jsxruntime.jsx.call(void 0, "div",{className:"flex h-6 w-6 items-center justify-center rounded-full border",style:{backgroundColor:o.cardBgColor,borderColor:o.cardBorderColor},children:_jsxruntime.jsx.call(void 0, "span",{className:"text-base",style:{color:o.textColor},children:"\u2193"})})}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center justify-between backdrop-blur-sm p-2.5 border transition-all duration-300",style:{backgroundColor:o.cardBgColor,borderColor:o.cardBorderColor},children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center gap-2.5",children:[_jsxruntime.jsx.call(void 0, _chunkBX3KCZRTcjs.P,{asset:s,size:"sm"}),_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "div",{className:"text-sm font-bold",style:{color:o.textColor},children:s.symbol}),_jsxruntime.jsx.call(void 0, "div",{className:"text-2xs",style:{color:o.textColor,opacity:.5},children:s.name})]})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"text-right",children:[_jsxruntime.jsx.call(void 0, "div",{className:"text-lg font-bold mono",style:{color:o.textColor},children:y}),s.price&&_jsxruntime.jsxs.call(void 0, "div",{className:"text-2xs mono",style:{color:o.textColor,opacity:.5},children:["$",(s.price*u).toFixed(2)]})]})]}),f&&c&&_jsxruntime.jsxs.call(void 0, "div",{className:"mt-1.5",children:[_jsxruntime.jsx.call(void 0, "div",{className:"text-2xs mb-0.5 uppercase tracking-wider font-medium",style:{color:o.textColor,opacity:.5},children:"Recipient"}),_jsxruntime.jsx.call(void 0, "div",{className:"flex items-center backdrop-blur-sm p-2 border transition-all duration-300",style:{backgroundColor:o.cardBgColor,borderColor:o.cardBorderColor},children:_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center gap-2",children:[_jsxruntime.jsx.call(void 0, "div",{className:"flex h-5 w-5 items-center justify-center overflow-hidden rounded-full",style:{backgroundColor:o.iconBgColor},children:_jsxruntime.jsx.call(void 0, "span",{className:"text-2xs",children:"\u{1F464}"})}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col",children:[_jsxruntime.jsx.call(void 0, "div",{className:"text-2xs",style:{color:o.textColor,opacity:.5},children:"To:"}),_jsxruntime.jsxs.call(void 0, "div",{className:"text-xs mono",style:{color:o.textColor},children:[c.slice(0,6),"...",c.slice(-4)]})]})]})})]})]})}),_jsxruntime.jsxs.call(void 0, "div",{className:"mt-3 pt-2.5 space-y-1.5",style:{borderTop:`1px solid ${o.cardBorderColor}`},children:[_jsxruntime.jsxs.call(void 0, "div",{role:"button",tabIndex:0,onClick:x,onKeyDown:d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),x())},className:"flex items-center justify-between cursor-pointer group hover:opacity-80 transition-opacity",children:[_jsxruntime.jsx.call(void 0, "div",{className:"text-xs uppercase tracking-wider font-medium",style:{color:o.textColor,opacity:.5},children:a?"Copied!":r==="completed"||r==="failed"||r==="cancelled"?"Order Hash":r==="received"?"Received":"Pending"}),_jsxruntime.jsxs.call(void 0, "div",{className:"text-xs mono transition-colors",style:{color:o.textColor},children:[e.slice(0,6),"...",e.slice(-4)]})]}),r==="completed"&&i?_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center justify-between",children:[_jsxruntime.jsx.call(void 0, "div",{className:"text-xs uppercase tracking-wider font-medium",style:{color:o.textColor,opacity:.5},children:"Speed"}),_jsxruntime.jsxs.call(void 0, "div",{className:"text-base font-bold mono",style:{color:o.textColor},children:[i.toFixed(2),"s"]})]}):_jsxruntime.jsx.call(void 0, "div",{className:"h-5"})]})]})})},Oi= exports.w =Hn;exports.a = Tr; exports.b = Ee; exports.c = ts; exports.d = ls; exports.e = Ve; exports.f = Wr; exports.g = ms; exports.h = ys; exports.i = Rs; exports.j = Ps; exports.k = Dt; exports.l = Lt; exports.m = Bt; exports.n = Hr; exports.o = Ft; exports.p = Xr; exports.q = jt; exports.r = zt; exports.s = Gt; exports.t = Kt; exports.u = Ht; exports.v = Si; exports.w = Oi;
2
+ var _chunkKH57FLSTcjs = require('./chunk-KH57FLST.cjs');var _chunkUZWGYG2Scjs = require('./chunk-UZWGYG2S.cjs');var _chunkLXEKOQAGcjs = require('./chunk-LXEKOQAG.cjs');var _chunk34N36GUDcjs = require('./chunk-34N36GUD.cjs');var _chunkT3I3AJXVcjs = require('./chunk-T3I3AJXV.cjs');var _reactquery = require('@tanstack/react-query');var _react = require('react');function Sr(e){if(e.length===0)return 5e3;let u=Math.max(...e.map(r=>_nullishCoalesce(_optionalChain([_chunkLXEKOQAGcjs.e.call(void 0, r), 'optionalAccess', _2 => _2.blockTimeMs]), () => (2e3))));return Math.min(5e3,Math.max(1e3,u*2+1e3))}var Tr=()=>{let{address:e}=_chunk34N36GUDcjs.a.call(void 0, ),t=_chunkLXEKOQAGcjs._.call(void 0, ),s=_reactquery.useQueryClient.call(void 0, ),l=_react.useRef.call(void 0, null),u=_react.useRef.call(void 0, !0),r=_react.useCallback.call(void 0, a=>{if(!e)return;let h=[...new Set(a.tokens.map(p=>p.asset.chainId))],b=Sr(h);l.current&&(clearTimeout(l.current),l.current=null),l.current=setTimeout(async()=>{if(l.current=null,!!u.current)try{let p=a.tokens.map(f=>({chainId:f.asset.chainId,tokenAddress:f.asset.address})),i=await _chunkLXEKOQAGcjs.J.call(void 0, e,p);if(i.balances.length===0)return;if(a.tokens.length>=2){let f=a.tokens[0].asset,c=a.tokens[1].asset,x=_chunkLXEKOQAGcjs.K.swap(e,f.chainId,f.address,c.chainId,c.address);s.setQueryData(x,i)}let n=_chunkLXEKOQAGcjs.K.bulk(e,t),w=s.getQueryData(n);if(w){let f=w.balances.map(c=>_nullishCoalesce(i.balances.find(g=>g.chainId===c.chainId&&g.token.toLowerCase()===c.token.toLowerCase()), () => (c)));for(let c of i.balances)f.some(x=>x.chainId===c.chainId&&x.token.toLowerCase()===c.token.toLowerCase())||f.push(c);for(let c of a.tokens)if(!i.balances.some(g=>g.chainId===c.asset.chainId&&g.token.toLowerCase()===c.asset.address.toLowerCase())){let g=f.findIndex(o=>o.chainId===c.asset.chainId&&o.token.toLowerCase()===c.asset.address.toLowerCase());g!==-1&&(f[g]={...f[g],balance:"0",shiftedBalance:"0"})}s.setQueryData(n,{balances:f})}}catch (e2){}},b)},[e,t,s]);return _react.useEffect.call(void 0, ()=>(u.current=!0,()=>{u.current=!1,l.current&&(clearTimeout(l.current),l.current=null)}),[]),{triggerBalanceUpdate:r}},st=class extends EventTarget{emit(t){this.dispatchEvent(new CustomEvent("balance-update",{detail:t}))}},ot=new st,Ee= exports.b =()=>e=>ot.emit(e),ts= exports.c =()=>{let{triggerBalanceUpdate:e}=Tr();_react.useEffect.call(void 0, ()=>{let t=s=>{e(s.detail)};return ot.addEventListener("balance-update",t),()=>ot.removeEventListener("balance-update",t)},[e])};var _viem = require('viem');var _jsxruntime = require('react/jsx-runtime');var $t=_react.createContext.call(void 0, void 0),Pt=1e4,Ir=3e4,Or=1e3,Pr=2;function $r(e){return _nullishCoalesce(e.find(s=>_optionalChain([s, 'access', _3 => _3.routeSteps, 'optionalAccess', _4 => _4[0], 'optionalAccess', _5 => _5.type])==="AORI_V1"), () => (e[0]))}var ls=({children:e,recipient:t})=>{let{address:s}=_chunk34N36GUDcjs.a.call(void 0, ),l=t||s,[u,r]=_react.useState.call(void 0, "idle"),[a,h]=_react.useState.call(void 0, "idle"),[b,p]=_react.useState.call(void 0, null),[i,n]=_react.useState.call(void 0, null),[w,f]=_react.useState.call(void 0, !1),[c,x]=_react.useState.call(void 0, !1),[g,o]=_react.useState.call(void 0, !1),m=_react.useRef.call(void 0, null),y=_react.useRef.call(void 0, null),d=_react.useRef.call(void 0, null),T=_react.useRef.call(void 0, null),P=_react.useRef.call(void 0, null),C=_react.useRef.call(void 0, 0),$=_react.useRef.call(void 0, 0),L=_react.useRef.call(void 0, 0),N=_react.useRef.call(void 0, !1),E=_react.useRef.call(void 0, new Map),I=_react.useCallback.call(void 0, ()=>{d.current&&clearTimeout(d.current),T.current&&clearTimeout(T.current),P.current&&clearTimeout(P.current),d.current=null,T.current=null,P.current=null},[]),U=_react.useCallback.call(void 0, ()=>{I(),m.current=null,C.current=0,r(()=>N.current?"fresh":"idle")},[I]),B=_react.useCallback.call(void 0, ()=>{U(),y.current=null,p(null),n(null),f(!1),x(!1),o(!1),E.current.clear(),r("idle"),h("idle")},[U]),oe=_react.useCallback.call(void 0, v=>{if(!v)return;T.current&&clearTimeout(T.current);let S=Math.max(0,v+Ir-Date.now());T.current=setTimeout(()=>{r(O=>O==="idle"?"idle":"stale")},S)},[]),H=_react.useCallback.call(void 0, async(v,S)=>{let{inputToken:O,outputToken:A,inputAmount:q,setOutputAmount:Z}=v;if(!O||!A||!q||parseFloat(q)<=0||Date.now()-($.current||0)<Pt-10)return;let Be=++C.current;try{if(!_optionalChain([O, 'optionalAccess', _6 => _6.decimals])||!_optionalChain([A, 'optionalAccess', _7 => _7.decimals]))return;let z=_chunkLXEKOQAGcjs.C.call(void 0, O.chainId)||_optionalChain([_chunkLXEKOQAGcjs.e.call(void 0, O.chainId), 'optionalAccess', _8 => _8.key])||"",ie=_chunkLXEKOQAGcjs.C.call(void 0, A.chainId)||_optionalChain([_chunkLXEKOQAGcjs.e.call(void 0, A.chainId), 'optionalAccess', _9 => _9.key])||"";if(!z||!ie)throw new Error("Unknown chain");let ee=_viem.parseUnits.call(void 0, q.toString(),O.decimals).toString(),Ce={srcChainKey:z,dstChainKey:ie,srcTokenAddress:_chunkLXEKOQAGcjs.x.call(void 0, O.address),dstTokenAddress:_chunkLXEKOQAGcjs.x.call(void 0, A.address),amount:ee,srcWalletAddress:s||"0x0000000000000000000000000000000000000000",dstWalletAddress:l||s||"0x0000000000000000000000000000000000000000",options:{amountType:"EXACT_SRC_AMOUNT",feeTolerance:{type:"PERCENT",amount:2}}};$.current=Date.now();let te=await fetch(`${_chunkLXEKOQAGcjs.m.call(void 0, )}/quotes`,{method:"POST",headers:_chunkLXEKOQAGcjs.o.call(void 0, ),body:JSON.stringify(Ce),signal:AbortSignal.timeout(15e3)});if(!te.ok){let Se=await _asyncOptionalChain([(await te.json().catch(()=>({}))), 'optionalAccess', async _10 => _10.message])||te.statusText;throw Object.assign(new Error(Se),{status:te.status})}let me=await te.json();if(Be!==C.current||m.current!==S)return;let $e=_nullishCoalesce(me.quotes, () => ([])),ae=$r($e);if(!ae)throw Object.assign(new Error("No quotes returned"),{emptyQuotes:!0});let Je=Number(_viem.formatUnits.call(void 0, _chunkLXEKOQAGcjs.s.call(void 0, ae.dstAmount),A.decimals));typeof Z=="function"&&Z(Je),ae._receivedAt=Date.now(),p(ae),n(null),f(!1),r("fresh"),oe(ae._receivedAt),S&&E.current.delete(S)}catch(z){if(Be!==C.current||m.current!==S)return;let ie=_optionalChain([z, 'optionalAccess', _11 => _11.status]),ee=z instanceof Error?z.message:"",Ce=!!_optionalChain([z, 'optionalAccess', _12 => _12.emptyQuotes]);if((ie===400||Ce||ee.includes("Quote request failed"))&&S){let me=(E.current.get(S)||0)+1;if(E.current.set(S,me),me>=Pr){x(!0),I(),m.current=null;return}}if(ee.toLowerCase().includes("order cap exceeded")){o(!0),I(),m.current=null;return}if(ee.toLowerCase().includes("insufficient executor balance")){f(!0),I(),m.current=null;return}n(z instanceof Error?z.message:"Unknown error")}},[s,l,oe,I]),W=_react.useCallback.call(void 0, (v,S)=>{I(),y.current=v,$.current=0,E.current.delete(S),f(!1),x(!1),o(!1),n(null),r("polling");let O=async()=>{m.current===S&&(await H(v,S),m.current===S&&(d.current=setTimeout(O,Pt)))};O()},[I,H]),R=_react.useCallback.call(void 0, v=>{if(!_optionalChain([v, 'optionalAccess', _13 => _13.inputToken])||!_optionalChain([v, 'optionalAccess', _14 => _14.outputToken])||!_optionalChain([v, 'optionalAccess', _15 => _15.inputAmount])||parseFloat(v.inputAmount)<=0){U();return}let S=y.current;if(S&&_optionalChain([S, 'access', _16 => _16.inputToken, 'optionalAccess', _17 => _17.address])===_optionalChain([v, 'access', _18 => _18.inputToken, 'optionalAccess', _19 => _19.address])&&_optionalChain([S, 'access', _20 => _20.inputToken, 'optionalAccess', _21 => _21.chainId])===_optionalChain([v, 'access', _22 => _22.inputToken, 'optionalAccess', _23 => _23.chainId])&&_optionalChain([S, 'access', _24 => _24.outputToken, 'optionalAccess', _25 => _25.address])===_optionalChain([v, 'access', _26 => _26.outputToken, 'optionalAccess', _27 => _27.address])&&_optionalChain([S, 'access', _28 => _28.outputToken, 'optionalAccess', _29 => _29.chainId])===_optionalChain([v, 'access', _30 => _30.outputToken, 'optionalAccess', _31 => _31.chainId])&&S.inputAmount===v.inputAmount&&m.current)return;let A=Date.now();if(A-L.current<100)return;L.current=A;let q=`${Date.now()}-${Math.random().toString(36).slice(2)}`;m.current=q,W(v,q)},[W,U]),V=_react.useCallback.call(void 0, ({amount:v,inputToken:S,outputToken:O,setOutputAmount:A})=>{A(null),P.current&&clearTimeout(P.current),!v||v===0?(h("idle"),U(),p(null),n(null),f(!1),x(!1),o(!1)):(h("typing"),U(),p(null),f(!1),x(!1),o(!1),n(null),P.current=setTimeout(()=>{h("settled"),S&&O&&v>0&&R({inputToken:S,outputToken:O,inputAmount:v.toString(),setOutputAmount:A})},Or))},[U,R]),F=_react.useCallback.call(void 0, ()=>{let v=y.current;if(!v)return;p(null);let S=`${Date.now()}-${Math.random().toString(36).slice(2)}`;m.current=S,r("refreshing"),typeof v.setOutputAmount=="function"&&v.setOutputAmount(null),W(v,S)},[W]);_react.useEffect.call(void 0, ()=>{N.current=!!b},[b]),_react.useEffect.call(void 0, ()=>()=>I(),[I]);let X=_react.useMemo.call(void 0, ()=>({status:u,inputState:a,rfqQuote:b,error:i,liquidityError:w,routingError:c,sizeCapError:g,ensureForParams:R,stop:U,refresh:F,clear:B,handleInputChange:V}),[u,a,b,i,w,c,g,R,U,F,B,V]);return _jsxruntime.jsx.call(void 0, $t.Provider,{value:X,children:e})},Ve= exports.e =()=>{let e=_react.useContext.call(void 0, $t);if(e===void 0)throw new Error("useRfq must be used within an RfqProvider");return e};var Wr=_react.createContext.call(void 0, {openConnectModal:()=>{}}),ms= exports.g =()=>_react.useContext.call(void 0, Wr);var Lr=20,Br=({side:e,asset:t,otherAsset:s,isPlacingOrder:l,isWrappingPair:u,isUnwrappingPair:r})=>{let{baseAmount:a,quoteAmount:h,setBaseAmount:b,setQuoteAmount:p}=_chunkUZWGYG2Scjs.f.call(void 0, ),{amountInputVariant:i,hideAmountInputSymbol:n,widgetType:w}=_chunkLXEKOQAGcjs.b.call(void 0, ),f=w==="compact",[c,x]=e==="base"?[b,p]:[p,b],g=!t||e==="quote"||l,o=f?32:i==="default"?64:32,[m,y]=_react.useState.call(void 0, o),[d,T]=_react.useState.call(void 0, ""),P=_react.useRef.call(void 0, null),C=_react.useRef.call(void 0, null),$=_react.useRef.call(void 0, null),L=_react.useRef.call(void 0, null),N="USD",E=e==="base"?a:h,[I,U]=_react.useState.call(void 0, !1),B=_react.useCallback.call(void 0, ()=>{if(i!=="default"){y(o);return}if(!P.current||!C.current||!$.current)return;let W=P.current.offsetWidth,R=20,V=o;for(;V>20&&(C.current.style.fontSize=`${V}px`,$.current.style.fontSize=`${V}px`,!(C.current.offsetWidth+$.current.offsetWidth+R<=W));)V-=1;y(V)},[i,o]),oe=_react.useCallback.call(void 0, W=>{W.key==="."&&d.includes(".")&&W.preventDefault()},[d]),H=_react.useCallback.call(void 0, W=>{let R=W.target.value;if(R==="."&&(R="0."),!/^\d*\.?\d*$/.test(R)||(R.match(/\./g)||[]).length>1)return;if(R.length>1&&R[0]==="0"&&R[1]!=="."&&(R=R.replace(/^0+/,"")||"0"),_optionalChain([t, 'optionalAccess', _32 => _32.decimals])!==void 0&&R.includes(".")){let[,F]=R.split(".");if(F&&F.length>t.decimals)return}if(R.length>Lr)return;T(R);let V=parseFloat(R);R!==d&&(R===""||R==="0."||R.endsWith(".")?(c(null),e==="base"&&x(null)):!Number.isNaN(V)&&V>=0&&c(V),e==="base"&&p(null),(r||u)&&p(V||0))},[d,c,e,p,_optionalChain([t, 'optionalAccess', _33 => _33.decimals]),x,r,u]);return _react.useEffect.call(void 0, ()=>{let W=F=>{if(F===null)return"";let X=_optionalChain([t, 'optionalAccess', _34 => _34.decimals]);if(X===void 0)return"";let v=F.toString();if(/e/i.test(v)&&(v=Number(F).toLocaleString("en-US",{useGrouping:!1,maximumFractionDigits:X})),v.includes(".")){let[S,O]=v.split("."),A=O.slice(0,X);return A?`${S}.${A}`:S}return v};if(E===null){d==="0."||d!==""&&d.endsWith(".")||T("");return}if(!g&&(d.endsWith(".")||d.match(/\.\d*0$/)||d==="0"||d==="0.")&&d!=="")return;let V=parseFloat(d)||0;(d===""||Math.abs(V-E)>1e-10)&&T(W(E))},[E,_optionalChain([t, 'optionalAccess', _35 => _35.decimals]),d,g]),_react.useEffect.call(void 0, ()=>{B()},[d,B]),_react.useEffect.call(void 0, ()=>{U(!0)},[]),_react.useEffect.call(void 0, ()=>{I&&B()},[I,B]),_react.useEffect.call(void 0, ()=>{C.current&&L.current&&(L.current.style.width=`${C.current.offsetWidth}px`)},[d]),_react.useEffect.call(void 0, ()=>{if(!I)return;let W=new ResizeObserver(()=>{I&&B()});return P.current&&W.observe(P.current),()=>W.disconnect()},[I,B]),_jsxruntime.jsx.call(void 0, "div",{ref:P,style:{fontSize:`${m}px`,transition:"font-size 0.05s ease-in-out"},className:`mt-2 box-border flex ${f?i==="normal"?"h-12 my-1":"h-10 my-0.5":i==="normal"?"h-12 my-1":"h-20 my-1"} w-full flex-row items-center ${g?"cursor-default":"cursor-text"}`,onClick:()=>_optionalChain([L, 'access', _36 => _36.current, 'optionalAccess', _37 => _37.focus, 'call', _38 => _38()]),children:_jsxruntime.jsxs.call(void 0, "div",{className:"relative flex w-full items-center",children:[_jsxruntime.jsx.call(void 0, "label",{htmlFor:`${e}Amount`,className:"sr-only",children:e==="base"?"Input token amount":"Output token amount"}),_jsxruntime.jsx.call(void 0, "input",{ref:L,type:"text",inputMode:"decimal",placeholder:"0",autoComplete:"off",id:`${e}Amount`,value:d,onWheel:W=>W.target.blur(),onKeyDown:oe,onChange:H,style:{transition:"width 0.15s ease-in-out",color:"var(--widget-foreground)",WebkitTextFillColor:"var(--widget-foreground)",opacity:g?.4:1},className:"flex min-w-[45px] whitespace-nowrap bg-transparent placeholder:opacity-50",disabled:g}),_jsxruntime.jsx.call(void 0, "span",{style:{transition:"width 0.15s ease-in-out"},ref:C,className:"pointer-events-none absolute flex whitespace-nowrap invisible",children:d||0}),!n&&i!=="normal"&&_jsxruntime.jsx.call(void 0, "span",{ref:$,className:"ml-2 font-light uppercase",style:{color:"var(--widget-foreground)",opacity:.5,fontSize:`${m}px`},children:_optionalChain([t, 'optionalAccess', _39 => _39.symbol])?t.symbol.length>6?`${t.symbol.slice(0,6)}...`:t.symbol:N}),(n||i==="normal")&&_jsxruntime.jsx.call(void 0, "span",{ref:$,className:"hidden"})]})})},ys= exports.h =Br;var Vr=({toggle:e,side:t,asset:s,isPlacingOrder:l})=>{let{baseBalance:u,quoteBalance:r}=_chunkUZWGYG2Scjs.f.call(void 0, ),{tokenDisplay:a,tokenBadgeOrientation:h,widgetType:b}=_chunkLXEKOQAGcjs.b.call(void 0, ),p=b==="compact",i=p?"h-10":"h-12",n=p?"h-10 w-10":"h-12 w-12",w=t==="base"?u.formatted?(()=>{let c=parseFloat(u.formatted);return c>=1e8?_chunkLXEKOQAGcjs.q.call(void 0, c):c.toFixed(3)})():void 0:r.formatted?(()=>{let c=parseFloat(r.formatted);return c>=1e8?_chunkLXEKOQAGcjs.q.call(void 0, c):c.toFixed(3)})():void 0,f={role:"button",tabIndex:l?-1:0,"aria-disabled":l,"aria-label":`Select ${t==="base"?"input":"output"} token${s?`: ${s.symbol}`:""}`,onClick:l?void 0:e,onKeyDown:l?void 0:c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),e())}};return a==="pill"?_jsxruntime.jsx.call(void 0, "div",{...f,className:`inline-flex items-center gap-1.5 h-7 px-2.5 rounded-full cursor-pointer transition-colors ${h==="right"?"ml-auto":""}`,style:{border:"1px solid var(--widget-border)",backgroundColor:"var(--widget-secondary)",color:"var(--widget-secondary-foreground)"},children:s?_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, _chunkLXEKOQAGcjs.O,{chain:s.chainId,size:"xs"}),_jsxruntime.jsx.call(void 0, _chunkLXEKOQAGcjs.P,{className:"rounded-full",asset:s,size:"xxs",noChain:!0}),_jsxruntime.jsx.call(void 0, "span",{className:"text-xs font-medium uppercase",children:s.symbol}),_jsxruntime.jsx.call(void 0, _chunkLXEKOQAGcjs.V,{className:"w-1.5 opacity-60",style:{color:"var(--widget-secondary-foreground)"}})]}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "span",{className:"text-xs opacity-70",children:"Select"}),_jsxruntime.jsx.call(void 0, _chunkLXEKOQAGcjs.V,{className:"w-1.5 opacity-60",style:{color:"var(--widget-secondary-foreground)"}})]})}):a==="ghost"?_jsxruntime.jsxs.call(void 0, "div",{...f,className:"inline-flex items-center gap-1.5 cursor-pointer transition-opacity hover:opacity-70 py-1",style:{color:"var(--widget-foreground)"},children:[s?_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, _chunkLXEKOQAGcjs.O,{chain:s.chainId,size:"xs"}),_jsxruntime.jsx.call(void 0, _chunkLXEKOQAGcjs.P,{className:"rounded-full",asset:s,size:"xxs",noChain:!0}),_jsxruntime.jsx.call(void 0, "span",{className:"text-sm font-medium uppercase",children:s.symbol})]}):_jsxruntime.jsx.call(void 0, "span",{className:"text-sm",style:{color:"var(--widget-muted-foreground)"},children:"Select token"}),_jsxruntime.jsx.call(void 0, _chunkLXEKOQAGcjs.V,{className:"w-1.5 opacity-50"})]}):_jsxruntime.jsx.call(void 0, "div",{...f,className:`relative ${i} 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:_jsxruntime.jsx.call(void 0, "div",{className:"relative flex h-full w-full flex-row items-center",children:s?_jsxruntime.jsxs.call(void 0, "div",{className:"relative flex h-full w-full flex-row items-center",children:[_jsxruntime.jsx.call(void 0, "div",{className:`${n} pl-px flex items-center justify-center`,children:_jsxruntime.jsx.call(void 0, _chunkLXEKOQAGcjs.P,{className:"rounded-full",asset:s,size:"md"})}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-full w-full flex-row items-center justify-between pl-1.5 pr-7",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-full flex-col justify-center",children:[_jsxruntime.jsx.call(void 0, "p",{className:"text-sm font-medium uppercase",style:{color:"var(--widget-secondary-foreground)"},children:s.symbol}),_jsxruntime.jsxs.call(void 0, "span",{className:"text-2xs font-mono",style:{color:"var(--widget-secondary-foreground)",opacity:.6},children:[_optionalChain([s, 'access', _40 => _40.address, 'optionalAccess', _41 => _41.slice, 'call', _42 => _42(0,6)]),"...",_optionalChain([s, 'access', _43 => _43.address, 'optionalAccess', _44 => _44.slice, 'call', _45 => _45(-4)])]})]}),w!==void 0&&_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col text-right",children:[_jsxruntime.jsx.call(void 0, "p",{className:"text-2xs",style:{color:"var(--widget-secondary-foreground)",opacity:.5},children:"Balance"}),_jsxruntime.jsx.call(void 0, "span",{className:"font-mono text-xs tabular-nums",style:{color:"var(--widget-secondary-foreground)"},children:w})]})]}),_jsxruntime.jsx.call(void 0, _chunkLXEKOQAGcjs.V,{className:"absolute right-3 top-1/2 w-1.5 translate-y-[-50%]",style:{color:"var(--widget-secondary-foreground)",opacity:.6}})]}):_jsxruntime.jsx.call(void 0, "div",{className:"flex h-full w-full items-center justify-center",children:_jsxruntime.jsx.call(void 0, "span",{className:"text-sm",style:{color:"var(--widget-secondary-foreground)",opacity:.7},children:"Select token"})})})})},Rs= exports.i =Vr;var Mt=_chunkT3I3AJXVcjs.b.call(void 0, _chunkKH57FLSTcjs.a.call(void 0, ),1);var Fr=()=>{let[e,t]=_react.useState.call(void 0, null),[s,l]=_react.useState.call(void 0, ""),u=_chunkLXEKOQAGcjs.z.call(void 0, s,1e3),[r,a]=_react.useState.call(void 0, !1),[h,b]=_react.useState.call(void 0, "");_react.useEffect.call(void 0, ()=>{_chunkUZWGYG2Scjs.c.getState().setRecipient(e)},[e]),_react.useEffect.call(void 0, ()=>{l(e||"")},[e]);let p=n=>{let w=n.target.value;r&&(a(!1),b(""),t(null)),l(w),w===""&&t(null)};_react.useEffect.call(void 0, ()=>{u===""||!u?(a(!1),b(""),t(null)):_chunkLXEKOQAGcjs.y.call(void 0, u)?(a(!1),b(""),t(u)):(a(!0),b("Invalid wallet address..."),t(null),l(""))},[u]),_react.useEffect.call(void 0, ()=>{if(r){let n=setTimeout(()=>{t(null),l(""),a(!1),b("")},2e3);return()=>clearTimeout(n)}},[r]);let i=()=>{t(null),l(""),a(!1),b("")};return _jsxruntime.jsx.call(void 0, "div",{className:"w-full",children:_jsxruntime.jsxs.call(void 0, "div",{className:"relative flex flex-row items-center",children:[_jsxruntime.jsx.call(void 0, "input",{type:"password",style:{display:"none"},"aria-hidden":"true",tabIndex:-1}),_jsxruntime.jsx.call(void 0, "label",{htmlFor:"recipient-address",className:"sr-only",children:"Recipient wallet address"}),_jsxruntime.jsx.call(void 0, "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&&!r?_jsxruntime.jsx.call(void 0, "img",{className:"h-full w-full rounded-full object-cover",src:(0,Mt.makeGradient)(e),alt:"Recipient avatar"}):_jsxruntime.jsx.call(void 0, _chunkLXEKOQAGcjs.U,{className:"h-5 w-5",style:{color:r?"var(--widget-destructive)":"var(--widget-muted-foreground)"}})}),_jsxruntime.jsx.call(void 0, "div",{className:"absolute left-12 top-1.5 -translate-y-1 text-xs font-medium opacity-60",style:{color:r?"var(--widget-destructive)":"var(--widget-muted-foreground)"},"aria-hidden":"true",children:"To:"}),_jsxruntime.jsx.call(void 0, "input",{id:"recipient-address",className:"mono block h-10 w-full items-center pl-12 pt-4 pr-8 text-xs",style:{backgroundColor:r?"color-mix(in srgb, var(--widget-destructive) 10%, transparent)":"transparent",color:r?"var(--widget-destructive)":"var(--widget-foreground)",outline:"none",opacity:r?.9:1},placeholder:r?h:"Enter recipient address...",value:s,onChange:p,spellCheck:!1,"aria-invalid":r,"aria-describedby":r?"recipient-error":void 0}),r&&_jsxruntime.jsx.call(void 0, "span",{id:"recipient-error",className:"sr-only",children:h}),e&&!r&&_jsxruntime.jsxs.call(void 0, "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:i,"aria-label":"Clear recipient",children:[_jsxruntime.jsx.call(void 0, "svg",{className:"h-2.5 w-2.5",viewBox:"0 -0.5 21 21",fill:"none",children:_jsxruntime.jsx.call(void 0, "g",{fill:"currentColor",fillRule:"evenodd",children:_jsxruntime.jsx.call(void 0, "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)"})})}),_jsxruntime.jsx.call(void 0, "span",{className:"sr-only",children:"Clear recipient"})]})]})})},Ps= exports.j =Fr;var qr=["SUCCEEDED","FAILED","COMPLETED","CANCELLED"];async function Dt(e,t,s={}){let{onStatusChange:l,onComplete:u,onError:r,interval:a=4e3,timeout:h=3e5,txHash:b,signal:p}=s,i=null,n=Date.now(),w=0,f=8,c=null,x=b?`?txHash=${b}`:"";return new Promise((g,o)=>{let m=async()=>{try{if(_optionalChain([p, 'optionalAccess', _46 => _46.aborted])){c&&clearTimeout(c),o(new DOMException("Polling aborted","AbortError"));return}if(Date.now()-n>h){c&&clearTimeout(c);let P=new Error("Order status polling timed out");_optionalChain([r, 'optionalCall', _47 => _47(P)]),o(P);return}let y=await fetch(`${t}/status/${e}${x}`,{headers:_chunkLXEKOQAGcjs.o.call(void 0, ),signal:p});if(y.status===404){c=setTimeout(m,a);return}if(!y.ok)throw new Error(`Failed to fetch order status: ${await y.text()}`);let d=await y.json();if(!d||typeof d!="object"||!d.status)throw new Error(`Invalid status response format: ${JSON.stringify(d)}`);w=0;let T=d.status.toUpperCase();if(T!==i&&(i=T,_optionalChain([l, 'optionalCall', _48 => _48(d)])),qr.includes(T)){c&&clearTimeout(c),_optionalChain([u, 'optionalCall', _49 => _49(d)]),g(d);return}c=setTimeout(m,a)}catch(y){if(y instanceof Error&&y.name==="AbortError"){c&&clearTimeout(c),o(y);return}if(++w>=f){c&&clearTimeout(c);let d=y instanceof Error?y:new Error(String(y));_optionalChain([r, 'optionalCall', _50 => _50(d)]),o(d);return}c=setTimeout(m,a)}};m()})}function Wt(e){let t=e.toUpperCase();return t==="SUCCEEDED"||t==="COMPLETED"?"completed":t==="FAILED"?"failed":t==="CANCELLED"?"cancelled":t==="PROCESSING"?"received":"pending"}var Lt=e=>{let t=_react.useRef.call(void 0, new Map),s=_react.useRef.call(void 0, new Map),l=_react.useRef.call(void 0, new Map),u=_react.useRef.call(void 0, 0),r=_react.useCallback.call(void 0, ()=>++u.current,[]),{address:a}=_chunk34N36GUDcjs.a.call(void 0, ),h=Ee(),b=_react.useCallback.call(void 0, (n,w)=>{if(t.current.get(n))return;w&&s.current.set(n,w),t.current.set(n,!0);let f=u.current,c=new AbortController;l.current.set(n,c);let x=_optionalChain([w, 'optionalAccess', _51 => _51.baseToken, 'optionalAccess', _52 => _52.chainId])===1;Dt(n,_chunkLXEKOQAGcjs.m.call(void 0, ),{interval:x?1e3:500,timeout:3e5,signal:c.signal,onStatusChange:g=>{if(!_optionalChain([g, 'optionalAccess', _53 => _53.status]))return;let o=Wt(g.status);if(_optionalChain([e, 'optionalCall', _54 => _54(n,o)]),o==="completed"&&a){let m=s.current.get(n);if(m&&(m.baseToken||m.quoteToken)){let y=[];m.baseToken&&y.push({asset:m.baseToken,userAddress:a}),m.quoteToken&&y.push({asset:m.quoteToken,userAddress:a}),h({type:"swap",tokens:y})}}["completed","failed","cancelled"].includes(o)&&(t.current.delete(n),s.current.delete(n)),f!==u.current&&(t.current.delete(n),s.current.delete(n))},onComplete:g=>{_optionalChain([g, 'optionalAccess', _55 => _55.status])&&_optionalChain([e, 'optionalCall', _56 => _56(n,Wt(g.status))]),t.current.delete(n),s.current.delete(n)},onError:()=>{t.current.delete(n),s.current.delete(n)}}).catch(g=>{g instanceof Error&&g.name==="AbortError"||(t.current.delete(n),s.current.delete(n),l.current.delete(n))})},[a,h,e]),p=_react.useCallback.call(void 0, n=>{let w=l.current.get(n);w&&(w.abort(),l.current.delete(n)),r(),t.current.delete(n),s.current.delete(n)},[r]),i=_react.useCallback.call(void 0, ()=>{for(let n of l.current.values())n.abort();l.current.clear(),r(),t.current.clear(),s.current.clear()},[r]);return _react.useEffect.call(void 0, ()=>()=>i(),[i]),{startPolling:b,stopPolling:p,stopAllPolling:i,isPolling:n=>t.current.has(n)}};var Gr=_react.createContext.call(void 0, {registerTransaction:()=>{},enabled:!1}),Bt= exports.m =()=>_react.useContext.call(void 0, Gr);var _actions = require('viem/actions');function Vt(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 _t(e){if(_optionalChain([e, 'access', _57 => _57.chain, 'optionalAccess', _58 => _58.id]))return e.chain.id;let t=_optionalChain([e, 'access', _59 => _59.getChainId, 'optionalCall', _60 => _60()]);return t!=null?await t:null}var Hr=async(e,t)=>{try{if(await _t(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 _t(e)===t}catch(s){throw Vt(s)?new Error("User rejected the chain switch request"):new Error(`Please switch your wallet to the required network (Chain ID: ${t})`)}},Ft= exports.o =async e=>{let{quote:t,signatureStep:s,userAddress:l,walletClient:u}=e;if(!u)throw new Error("Wallet client not available");if(s.type!=="SIGNATURE"||!_optionalChain([s, 'access', _61 => _61.signature, 'optionalAccess', _62 => _62.typedData]))throw new Error("Invalid signature step");try{let r=s.signature.typedData,a={...r.message};for(let i of["inputAmount","outputAmount","startTime","endTime"])a[i]!=null&&(a[i]=BigInt(a[i]));let h=r.domain;if(h.chainId!=null){let i=Number(h.chainId);await Hr(u,i)}let b=await _actions.signTypedData.call(void 0, u,{account:l,domain:h,types:r.types,primaryType:r.primaryType,message:a}),p=await fetch(`${_chunkLXEKOQAGcjs.m.call(void 0, )}/submit-signature`,{method:"POST",headers:_chunkLXEKOQAGcjs.o.call(void 0, ),body:JSON.stringify({quoteId:t.id,signatures:[b]})});if(!p.ok){let i=await p.json().catch(()=>({}));throw new Error(_optionalChain([i, 'optionalAccess', _63 => _63.message])||`Submit failed: ${p.status}`)}return{quoteId:t.id,signature:b}}catch(r){throw Vt(r)?new Error("User rejected the signing request"):r instanceof Error&&r.message.includes("chain")?new Error("Chain switching failed. Please manually switch to the correct network."):r}};var qt="vt_submitted_quotes";var lt=()=>{try{let e=localStorage.getItem(qt);return e?JSON.parse(e):[]}catch (e3){return[]}},Qt=e=>{try{localStorage.setItem(qt,JSON.stringify(e))}catch (e4){}},Xr= exports.p =e=>{let t=Date.now(),s=typeof e=="string"?new Date(e).getTime():e>9999999999?e:e*1e3;return t<s+3e4},Yr=e=>lt().some(t=>t.quoteId===e),jt= exports.q =(e,t)=>Yr(e)?{canSubmit:!1,reason:"Order already submitted"}:Xr(t)?{canSubmit:!0}:{canSubmit:!1,reason:"Quote has expired"},zt= exports.r =(e,t)=>{let s=typeof t=="string"?new Date(t).getTime():t,l=lt();l.push({quoteId:e,submittedAt:Date.now(),createdAt:s}),Qt(l)},Gt= exports.s =()=>{let e=lt(),t=Date.now(),s=300*1e3,l=e.filter(u=>t-u.submittedAt<s);l.length!==e.length&&Qt(l)};var _core = require('@wagmi/core');var _abis = require('abitype/abis');var _wagmi = require('wagmi');function Kt(){let e=_wagmi.useConfig.call(void 0, );return _reactquery.useMutation.call(void 0, {mutationFn:async({chainId:t,accountAddress:s,amountRaw:l,writeContractAsync:u})=>{let r=_chunkLXEKOQAGcjs.e.call(void 0, t);if(!r)throw new Error(`No wrapping contract for chain ${t}`);let a=r.wrappedAsset.address,h=await u({abi:_abis.wethAbi,functionName:"withdraw",address:a,account:s,args:[l],chainId:t});if((await _core.waitForTransactionReceipt.call(void 0, e,{hash:h,chainId:t,confirmations:1,pollingInterval:4e3})).status!=="success")throw new Error("Unwrap transaction did not get successful receipt");return{success:!0,hash:h}}})}function Ht(){let e=_wagmi.useConfig.call(void 0, );return _reactquery.useMutation.call(void 0, {mutationFn:async({chainId:t,accountAddress:s,amountRaw:l,writeContractAsync:u})=>{let r=_chunkLXEKOQAGcjs.e.call(void 0, t);if(!r)throw new Error(`No wrapping contract for chain ${t}`);let a=r.wrappedAsset.address,h=await u({abi:_abis.wethAbi,functionName:"deposit",address:a,account:s,value:l,chainId:t});if((await _core.waitForTransactionReceipt.call(void 0, e,{hash:h,chainId:t,confirmations:1,pollingInterval:4e3})).status!=="success")throw new Error("Wrap transaction did not get successful receipt");return{success:!0,hash:h}}})}function Yt(){let{registerTransaction:e,enabled:t}=Bt(),s=_react.useRef.call(void 0, new Set),l=_react.useCallback.call(void 0, (r,a)=>{!t||s.current.has(r)||(s.current.add(r),e(r,a))},[t,e]),u=_react.useCallback.call(void 0, (r,a)=>{!t||s.current.has(r)||(s.current.add(r),e(r,a))},[t,e]);return{trackOrderTransaction:l,trackNativeTransaction:u,txTrackingEnabled:t}}var pn=15e3,Ge="chain",mn=({needsChainSwitch:e,requiredChain:t,reviewState:s,goToNextStep:l,cancel:u})=>{let r=_chunkLXEKOQAGcjs.t.call(void 0, Ge,s),[a,h]=_react.useState.call(void 0, "pending"),b=_react.useRef.call(void 0, !1),p=_react.useRef.call(void 0, !1),i=_react.useRef.call(void 0, null),n=_wagmi.useChainId.call(void 0, ),{switchChainAsync:w}=_wagmi.useSwitchChain.call(void 0, ),{status:f,isReconnecting:c}=_wagmi.useAccount.call(void 0, ),x=_react.useCallback.call(void 0, ()=>{i.current&&(clearTimeout(i.current),i.current=null)},[]),g=_react.useCallback.call(void 0, async()=>{if(!(b.current||p.current||f!=="connected"||c)){b.current=!0,p.current=!0,h("pending"),i.current=setTimeout(()=>{b.current&&(h("error"),b.current=!1)},pn);try{await w({chainId:t.chainId}),x(),h("success"),l(Ge,s)}catch (e5){x(),h("error")}finally{b.current=!1}}},[w,f,c,t.chainId,l,s,x]);_react.useEffect.call(void 0, ()=>{b.current||p.current||s===Ge&&a==="pending"&&f==="connected"&&!c&&(e&&n!==t.chainId?g():(h("success"),l(Ge,s)))},[s,a,e,n,t.chainId,f,c,g,l]),_react.useEffect.call(void 0, ()=>()=>x(),[x]);let o=()=>{a==="error"&&(p.current=!1,h("pending"))},m=!r&&a==="error",y=!r&&(a==="pending"||a==="error"),d=m?"var(--widget-status-failed)":"var(--widget-status-pending)";return _jsxruntime.jsxs.call(void 0, "div",{className:"flex w-full flex-row justify-between space-x-3",children:[_jsxruntime.jsx.call(void 0, "button",{type:"button",className:`inline-flex h-12 w-full items-center justify-center text-sm font-medium transition duration-150 ${m?"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:m?o:void 0,children:_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-10 w-full flex-row items-center space-x-3 px-4",children:[_jsxruntime.jsx.call(void 0, _chunkLXEKOQAGcjs.O,{chain:t.chainId,size:"xs"}),_jsxruntime.jsx.call(void 0, "p",{className:"whitespace-nowrap",children:m?"Retry Switch":`Switch to ${t.name}`}),_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-1 border-t",style:{borderColor:"var(--widget-border)"}}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-6 w-3 items-center justify-center rounded-full",children:[!r&&a==="pending"&&_jsxruntime.jsx.call(void 0, _chunkLXEKOQAGcjs.W,{size:"5"}),(r||a==="success")&&_jsxruntime.jsx.call(void 0, _chunkLXEKOQAGcjs.Q,{className:"h-8 w-8"}),m&&_jsxruntime.jsx.call(void 0, _chunkLXEKOQAGcjs.T,{className:"h-[12px] w-[12px]"})]})]})}),y&&_jsxruntime.jsx.call(void 0, "button",{type:"button",className:"inline-flex h-12 items-center justify-center px-8 text-sm 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:u,children:"Cancel"})]})},er=mn;var fn=({startTime:e,onExpired:t})=>{let[s,l]=_react.useState.call(void 0, 30),[u,r]=_react.useState.call(void 0, !1),a=_react.useRef.call(void 0, !1),h=_react.useRef.call(void 0, t);h.current=t,_react.useEffect.call(void 0, ()=>{a.current=!1},[e]),_react.useEffect.call(void 0, ()=>{let p=()=>{let n=Date.now(),f=(e>9999999999?e:e*1e3)+30*1e3,c=Math.max(0,f-n),x=Math.floor(c/1e3);if(x<=0){l(0),a.current||(a.current=!0,r(!0),h.current());return}l(x),r(!1)};if(u)return;p();let i=setInterval(p,1e3);return()=>clearInterval(i)},[e,u]);let b=p=>{let i=Math.floor(p/60),n=p%60;return`${i.toString().padStart(2,"0")}:${n.toString().padStart(2,"0")}`};return u?null:_jsxruntime.jsx.call(void 0, "span",{className:"text-xs font-mono",children:b(s)})},sr=fn;function Sn(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 be="signingOrder";async function Tn(e,t,s,l,u){let r=_optionalChain([e, 'access', _64 => _64.transaction, 'optionalAccess', _65 => _65.encoded]),a=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _66 => _66.to]), () => (e.to)),h=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _67 => _67.data]), () => (e.data)),b=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _68 => _68.value]), () => (e.value));if(!a)throw new Error('Transaction step missing "to" address');let p=_optionalChain([r, 'optionalAccess', _69 => _69.chainId]),i=e.chainKey||u,n=p||(i?_chunkLXEKOQAGcjs.B.call(void 0, i):void 0);if(!n)throw new Error(`Unknown chain: ${i}`);let w=_chunkLXEKOQAGcjs.j.call(void 0, )[n],f=await s({account:t,chain:w,to:a,data:h||"0x",value:BigInt(b||"0")});return await _core.waitForTransactionReceipt.call(void 0, l,{hash:f,chainId:n}),f}var Rn=({base:e,baseAmount:t,quote:s,quoteAmount:l,userAddress:u,reviewState:r,goToNextStep:a,cancel:h,isWrappingPair:b,isUnwrappingPair:p,restartSigningFlow:i,onSwapInitiated:n,onOrderSubmitted:w,onSwapComplete:f,startPolling:c,trackNativeTransaction:x})=>{let g=_chunkLXEKOQAGcjs.t.call(void 0, be,r),[o,m]=_react.useState.call(void 0, "idle"),y=_react.useRef.call(void 0, !1),d=_react.useRef.call(void 0, null),T=_wagmi.useConfig.call(void 0, ),{isReconnecting:P}=_wagmi.useAccount.call(void 0, ),{rfqQuote:C,stop:$,refresh:L}=Ve(),{data:N}=_wagmi.useWalletClient.call(void 0, {chainId:e.chainId}),{switchChain:E}=_wagmi.useSwitchChain.call(void 0, ),{sendTransactionAsync:I}=_wagmi.useSendTransaction.call(void 0, ),U=_nullishCoalesce(_optionalChain([C, 'optionalAccess', _70 => _70._receivedAt]), () => (0)),B=_react.useCallback.call(void 0, ()=>U?Date.now()>=U+30*1e3:!1,[U]),oe=_react.useCallback.call(void 0, async()=>{if(y.current||!["idle","error"].includes(o))return;if(!_optionalChain([C, 'optionalAccess', _71 => _71.id])||!_optionalChain([C, 'optionalAccess', _72 => _72._receivedAt])){m("error");return}if(!jt(C.id,C._receivedAt).canSubmit){m("stale");return}y.current=!0;try{if(!N)throw new Error("Wallet client not available");Gt();let S=_nullishCoalesce(C.userSteps, () => ([])),O;for(let A of S)if(A.type==="TRANSACTION"){m("submitting");let q=A.chainKey||C.srcChainKey,Z=q?_chunkLXEKOQAGcjs.B.call(void 0, q):void 0;Z&&_optionalChain([N, 'access', _73 => _73.chain, 'optionalAccess', _74 => _74.id])!==Z&&(await E({chainId:Z}),await new Promise(Le=>setTimeout(Le,800))),O=await Tn(A,u,I,T,C.srcChainKey),x(O,A.description||`Tx on ${q}`)}else A.type==="SIGNATURE"&&(m("signing"),await Ft({quote:C,signatureStep:A,userAddress:u,walletClient:N}));zt(C.id,C._receivedAt),_optionalChain([w, 'optionalCall', _75 => _75(C.id)]),c(C.id,{baseToken:e,quoteToken:s}),_optionalChain([n, 'optionalCall', _76 => _76()]),$(),m("success"),a(be,r),_optionalChain([f, 'optionalCall', _77 => _77(C.id)])}catch(S){S instanceof Error&&Sn(S)?(d.current=null,m("idle")):m("error")}finally{y.current=!1}},[o,C,N,e,s,u,$,c,a,r,f,E,I,n,w,x,T]);_react.useEffect.call(void 0, ()=>{if(r===be&&$(),g&&o!=="success"){m("success"),a(be,r);return}if(o==="success"){a(be,r);return}if(r===be&&o==="idle"&&!_optionalChain([C, 'optionalAccess', _78 => _78.id])){m("refreshingQuote"),L();return}if(r===be&&o==="idle"&&N&&!y.current&&!P){let v=_optionalChain([C, 'optionalAccess', _79 => _79.id])||null;v&&d.current!==v&&(d.current=v,oe())}},[g,r,o,N,P,oe,a,_optionalChain([C, 'optionalAccess', _80 => _80.id]),L,$]),_react.useEffect.call(void 0, ()=>{o==="refreshingQuote"&&_optionalChain([C, 'optionalAccess', _81 => _81.id])&&m("idle")},[o,_optionalChain([C, 'optionalAccess', _82 => _82.id])]),_react.useEffect.call(void 0, ()=>{r!==be&&(d.current=null)},[r]),_react.useEffect.call(void 0, ()=>{let v=setInterval(()=>{B()&&!y.current&&o!=="submitting"&&o!=="success"&&m("stale")},1e3);return()=>clearInterval(v)},[B,o]);let H=()=>{o==="error"&&!y.current&&(d.current=null,m("idle"))},W=_react.useCallback.call(void 0, ()=>{d.current=null,m("refreshingQuote"),L()},[L]),R=_react.useCallback.call(void 0, ()=>{i?i(!0):h()},[i,h]),V=()=>o==="error"?"Retry swap":o==="signing"?"Sign Swap Order":o==="submitting"?"Submitting...":o==="refreshingQuote"?"Refreshing Quote...":o==="stale"?"Quote Stale":"Sign & Submit",F=!g&&(o==="error"||o==="stale"),X=F?"var(--widget-status-failed)":"var(--widget-status-pending)";return _jsxruntime.jsxs.call(void 0, "div",{className:"flex w-full flex-row justify-between space-x-3",children:[_jsxruntime.jsx.call(void 0, "button",{type:"button",className:`inline-flex h-12 w-full items-center justify-center text-sm font-medium transition duration-150 ${F?"cursor-pointer":"cursor-not-allowed"}`,style:{backgroundColor:`color-mix(in srgb, ${X} 12%, transparent)`,border:`1px solid color-mix(in srgb, ${X} 20%, transparent)`,color:X,borderRadius:"var(--widget-radius)"},onClick:!g&&o==="error"?H:o==="stale"?R:void 0,children:_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-10 w-full flex-row items-center space-x-3 px-4",children:[_jsxruntime.jsx.call(void 0, _chunkLXEKOQAGcjs.P,{asset:e,size:"xs",noChain:!0}),_jsxruntime.jsx.call(void 0, "p",{className:"whitespace-nowrap",children:V()}),_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-1 border-t",style:{borderColor:"var(--widget-border)"}}),U>0&&o!=="success"&&o!=="error"&&o!=="stale"&&_jsxruntime.jsx.call(void 0, sr,{startTime:U,onExpired:()=>m("stale")}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-6 w-3 items-center justify-center rounded-full",children:[!g&&(o==="idle"||o==="signing"||o==="submitting"||o==="refreshingQuote")&&_jsxruntime.jsx.call(void 0, _chunkLXEKOQAGcjs.W,{size:"5"}),(g||o==="success")&&_jsxruntime.jsx.call(void 0, _chunkLXEKOQAGcjs.Q,{className:"h-8 w-8"}),!g&&(o==="error"||o==="stale")&&_jsxruntime.jsx.call(void 0, _chunkLXEKOQAGcjs.T,{className:"h-[12px] w-[12px]"})]})]})}),!g&&o==="error"&&_jsxruntime.jsx.call(void 0, "button",{type:"button",className:"inline-flex h-12 items-center justify-center px-8 text-sm 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:h,children:"Cancel"})]})},ir=Rn;var kn="trackingTx",ar={pending:{icon:_jsxruntime.jsx.call(void 0, _chunkLXEKOQAGcjs.W,{size:"5"}),buttonText:"Trade Pending",showNewSwap:!1,statusVar:"var(--widget-status-pending)",clickable:!1},received:{icon:_jsxruntime.jsx.call(void 0, _chunkLXEKOQAGcjs.W,{size:"5"}),buttonText:"Trade Received",showNewSwap:!1,statusVar:"var(--widget-status-received)",clickable:!1},completed:{icon:_jsxruntime.jsx.call(void 0, _chunkLXEKOQAGcjs.Q,{}),buttonText:"Continue Swapping",showNewSwap:!0,statusVar:"var(--widget-status-completed)",clickable:!0},failed:{icon:_jsxruntime.jsx.call(void 0, _chunkLXEKOQAGcjs.Z,{}),buttonText:"Retry Swap",showNewSwap:!0,statusVar:"var(--widget-status-failed)",clickable:!0},cancelled:{icon:_jsxruntime.jsx.call(void 0, _chunkLXEKOQAGcjs.Z,{}),buttonText:"Continue Swapping",showNewSwap:!0,statusVar:"var(--widget-status-failed)",clickable:!0}},Nn=({orderHash:e,base:t,quote:s,baseAmount:l,quoteAmount:u,reviewState:r,onNewSwap:a,onRetry:h,status:b})=>{let p=_chunkLXEKOQAGcjs.t.call(void 0, kn,r),i=ar[b]||ar.pending;_react.useEffect.call(void 0, ()=>{if(b==="completed"){let f=setTimeout(a,5e3);return()=>clearTimeout(f)}},[b,a]);let n=()=>{b==="failed"?h():i.showNewSwap&&a()},w=i.statusVar;return _jsxruntime.jsx.call(void 0, "div",{className:"flex flex-row justify-between space-x-3 w-full",children:_jsxruntime.jsx.call(void 0, "button",{type:"button",className:`inline-flex h-12 w-full items-center justify-center text-sm font-medium transition duration-150 ${i.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:i.showNewSwap?n:void 0,children:_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-10 w-full flex-row items-center space-x-3 px-4",children:[_jsxruntime.jsx.call(void 0, "div",{className:"flex h-6 w-6 items-center justify-center rounded-full",children:i.icon}),_jsxruntime.jsx.call(void 0, "p",{className:"whitespace-nowrap",children:i.buttonText}),_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-1 border-t",style:{borderColor:"var(--widget-border)"}}),i.showNewSwap&&_jsxruntime.jsx.call(void 0, "div",{className:"flex h-6 w-6 items-center justify-center",children:_jsxruntime.jsx.call(void 0, _chunkLXEKOQAGcjs.Y,{})})]})})})},cr=Nn;var Un=15e3,Xe="unwrapping",Mn=({needsToUnwrap:e,amount:t,chainId:s,token:l,reviewState:u,setReviewState:r,goToNextStep:a,cancel:h,delayedClose:b})=>{let p=_chunkLXEKOQAGcjs.t.call(void 0, Xe,u),[i,n]=_react.useState.call(void 0, "idle"),w=Kt(),{writeContractAsync:f}=_wagmi.useWriteContract.call(void 0, ),{address:c}=_chunk34N36GUDcjs.a.call(void 0, ),x=Ee(),g=_react.useRef.call(void 0, !1),o=_react.useRef.call(void 0, !1),m=_react.useRef.call(void 0, null),{status:y}=_wagmi.useAccount.call(void 0, ),d=_react.useCallback.call(void 0, ()=>{m.current&&(clearTimeout(m.current),m.current=null)},[]),T=_react.useCallback.call(void 0, async()=>{if(!(g.current||o.current||!c||y!=="connected")){g.current=!0,o.current=!0,n("pending"),m.current=setTimeout(()=>{g.current&&(n("error"),g.current=!1)},Un);try{let N=_chunkLXEKOQAGcjs.e.call(void 0, s);if(!N)throw new Error(`No config for chain ${s}`);let E=_nullishCoalesce(N.wrappedAsset.decimals, () => (N.nativeAsset.decimals)),I=_viem.parseUnits.call(void 0, t.toString(),E);await w.mutateAsync({chainId:s,accountAddress:c,amountRaw:I,writeContractAsync:f});let U={symbol:N.nativeAsset.symbol,name:N.nativeAsset.name,address:_chunkLXEKOQAGcjs.c,decimals:N.nativeAsset.decimals,chainId:s},B={symbol:N.wrappedAsset.symbol,name:N.wrappedAsset.name,address:N.wrappedAsset.address,decimals:N.wrappedAsset.decimals,chainId:s};x({type:"unwrap",tokens:[{asset:U,userAddress:c},{asset:B,userAddress:c}]}),d(),n("success"),a(Xe,u),await b()}catch (e6){d(),n("error")}finally{g.current=!1}}},[c,y,s,t,w,f,x,a,u,b,d]);_react.useEffect.call(void 0, ()=>{g.current||o.current||u===Xe&&i==="idle"&&y==="connected"&&(e?T():(n("success"),a(Xe,u)))},[u,i,e,y,T,a]),_react.useEffect.call(void 0, ()=>()=>d(),[d]);let P=()=>{i==="error"&&(o.current=!1,n("idle"))},C=!p&&i==="error",$=!p&&(i==="pending"||i==="idle"||i==="error"),L=C?"var(--widget-status-failed)":"var(--widget-status-pending)";return _jsxruntime.jsxs.call(void 0, "div",{className:"flex w-full flex-row justify-between space-x-3",children:[_jsxruntime.jsx.call(void 0, "button",{type:"button",className:`inline-flex h-12 w-full items-center justify-center text-sm font-medium transition duration-150 ${C?"cursor-pointer":"cursor-not-allowed"}`,style:{backgroundColor:`color-mix(in srgb, ${L} 12%, transparent)`,border:`1px solid color-mix(in srgb, ${L} 20%, transparent)`,color:L,borderRadius:"var(--widget-radius)"},onClick:C?P:void 0,children:_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-10 w-full flex-row items-center space-x-3 px-4",children:[_jsxruntime.jsx.call(void 0, "p",{className:"whitespace-nowrap",children:C?"Retry Unwrap":l?`Unwrap ${l.symbol}`:"Unwrap Native Token"}),_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-1 border-t",style:{borderColor:"var(--widget-border)"}}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-6 w-3 items-center justify-center rounded-full",children:[!p&&(i==="pending"||i==="idle")&&_jsxruntime.jsx.call(void 0, _chunkLXEKOQAGcjs.W,{size:"5"}),(p||i==="success")&&_jsxruntime.jsx.call(void 0, _chunkLXEKOQAGcjs.Q,{className:"h-8 w-8"}),C&&_jsxruntime.jsx.call(void 0, _chunkLXEKOQAGcjs.T,{className:"h-[12px] w-[12px]"})]})]})}),$&&_jsxruntime.jsx.call(void 0, "button",{type:"button",className:"inline-flex h-12 items-center justify-center px-8 text-sm 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:h,children:"Cancel"})]})},dr=Mn;var _n=15e3,Ye="wrapping",Vn=({needsToWrap:e,amount:t,chainId:s,token:l,reviewState:u,setReviewState:r,goToNextStep:a,cancel:h,delayedClose:b,isWrappingPair:p})=>{let i=_chunkLXEKOQAGcjs.t.call(void 0, Ye,u),[n,w]=_react.useState.call(void 0, "idle"),f=Ht(),{writeContractAsync:c}=_wagmi.useWriteContract.call(void 0, ),{address:x}=_chunk34N36GUDcjs.a.call(void 0, ),g=Ee(),o=_react.useRef.call(void 0, !1),m=_react.useRef.call(void 0, !1),y=_react.useRef.call(void 0, null),{status:d}=_wagmi.useAccount.call(void 0, ),T=_react.useCallback.call(void 0, ()=>{y.current&&(clearTimeout(y.current),y.current=null)},[]),P=_react.useCallback.call(void 0, async()=>{if(!(o.current||m.current||!x||d!=="connected")){o.current=!0,m.current=!0,w("pending"),y.current=setTimeout(()=>{o.current&&(w("error"),o.current=!1)},_n);try{let E=_chunkLXEKOQAGcjs.e.call(void 0, s);if(!E)throw new Error(`No config for chain ${s}`);let I=_viem.parseUnits.call(void 0, t.toString(),E.nativeAsset.decimals);await f.mutateAsync({chainId:s,accountAddress:x,amountRaw:I,writeContractAsync:c});let U={symbol:E.nativeAsset.symbol,name:E.nativeAsset.name,address:_chunkLXEKOQAGcjs.c,decimals:E.nativeAsset.decimals,chainId:s},B={symbol:E.wrappedAsset.symbol,name:E.wrappedAsset.name,address:E.wrappedAsset.address,decimals:E.wrappedAsset.decimals,chainId:s};g({type:"wrap",tokens:[{asset:U,userAddress:x},{asset:B,userAddress:x}]}),T(),w("success"),a(Ye,u),p&&await b()}catch (e7){T(),w("error")}finally{o.current=!1}}},[x,d,s,t,f,c,g,a,u,b,p,T]);_react.useEffect.call(void 0, ()=>{o.current||m.current||u===Ye&&n==="idle"&&d==="connected"&&(e?P():(w("success"),a(Ye,u)))},[u,n,e,d,P,a]),_react.useEffect.call(void 0, ()=>()=>T(),[T]);let C=()=>{n==="error"&&(m.current=!1,w("idle"))},$=!i&&n==="error",L=!i&&(n==="pending"||n==="idle"||n==="error"),N=$?"var(--widget-status-failed)":"var(--widget-status-pending)";return _jsxruntime.jsxs.call(void 0, "div",{className:"flex w-full flex-row justify-between space-x-3",children:[_jsxruntime.jsx.call(void 0, "button",{type:"button",className:`inline-flex h-12 w-full items-center justify-center text-sm font-medium transition duration-150 ${$?"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:$?C:void 0,children:_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-10 w-full flex-row items-center space-x-3 px-4",children:[_jsxruntime.jsx.call(void 0, "p",{className:"whitespace-nowrap",children:$?"Retry Wrap":l?`Wrap ${l.symbol}`:"Wrap Native Token"}),_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-1 border-t",style:{borderColor:"var(--widget-border)"}}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-6 w-3 items-center justify-center rounded-full",children:[!i&&(n==="pending"||n==="idle")&&_jsxruntime.jsx.call(void 0, _chunkLXEKOQAGcjs.W,{size:"5"}),(i||n==="success")&&_jsxruntime.jsx.call(void 0, _chunkLXEKOQAGcjs.Q,{className:"h-8 w-8"}),$&&_jsxruntime.jsx.call(void 0, _chunkLXEKOQAGcjs.T,{className:"h-[12px] w-[12px]"})]})]})}),L&&_jsxruntime.jsx.call(void 0, "button",{type:"button",className:"inline-flex h-12 items-center justify-center px-8 text-sm 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:h,children:"Cancel"})]})},fr=Vn;var Si=({base:e,baseAmount:t,quote:s,quoteAmount:l,userAddress:u,isWrappingPair:r,isUnwrappingPair:a,isBaseGasToken:h,isQuoteGasToken:b,reviewActionProps:p,reviewState:i,setReviewState:n,trackedOrderHash:w,setTrackedOrderHash:f,txStatus:c,onSwapComplete:x,onSwapInitiated:g,onOrderSubmitted:o,onStaleQuoteRestart:m,setExitHandler:y,setRetryHandler:d})=>{let{rfqQuote:T,status:P,liquidityError:C,routingError:$,sizeCapError:L,stop:N,clear:E}=Ve(),{clearForm:I}=_chunkUZWGYG2Scjs.f.call(void 0, ),U=_wagmi.useChainId.call(void 0, ),{swapButtonVariant:B,widgetType:oe}=_chunkLXEKOQAGcjs.b.call(void 0, ),H=oe==="compact",{trackOrderTransaction:W,trackNativeTransaction:R}=Yt(),{startPolling:V}=Lt((_,fe)=>{_chunkUZWGYG2Scjs.c.getState().setTxStatus(fe),fe==="completed"&&W(_,`Swap ${e.symbol} \u2192 ${s.symbol}`)}),[F,X]=_react.useState.call(void 0, !1),v=_react.useRef.call(void 0, !1),S=_react.useRef.call(void 0, null),O=r,A=a,q=!r&&!a,Z=U!==_optionalChain([e, 'optionalAccess', _83 => _83.chainId])&&(O||A||q),Le=_chunkLXEKOQAGcjs.e.call(void 0, e.chainId),Be={chainId:e.chainId,name:_nullishCoalesce(_optionalChain([Le, 'optionalAccess', _84 => _84.displayName]), () => (`Chain ${e.chainId}`))},z=_react.useCallback.call(void 0, (_,fe)=>{if(fe!==_)return;if(_==="chain"){if(O){n("wrapping");return}if(A){n("unwrapping");return}n("signingOrder");return}if(_==="signingOrder"){n("trackingTx");return}if(_==="wrapping"){if(!r){n("signingOrder");return}n("wrapSuccess");return}if(_==="unwrapping"){n("wrapSuccess");return}let yt=_chunkLXEKOQAGcjs.u.call(void 0, _);yt&&n(yt)},[n,r,O,A,q]),ie=_react.useCallback.call(void 0, ()=>Z?"chain":O?"wrapping":A?"unwrapping":q?"signingOrder":null,[Z,O,A,q]),ee=_react.useCallback.call(void 0, ()=>{n(null),I()},[I,n]),Ce=_react.useCallback.call(void 0, async()=>{n("wrapSuccess");for(let _=0;_<3;_++)await _chunkLXEKOQAGcjs.v.call(void 0, 700);ee()},[ee,n]),te=_react.useCallback.call(void 0, async()=>{E(),n("cancelled");for(let _=0;_<3;_++)await _chunkLXEKOQAGcjs.v.call(void 0, 500);ee()},[E,ee,n]),me=_react.useCallback.call(void 0, ()=>{w&&(_chunkUZWGYG2Scjs.c.getState().stopTracking(),n(null),f(null),I())},[w,n,f,I]),$e=_react.useCallback.call(void 0, ()=>{n(null),f(null),v.current=!0,_optionalChain([m, 'optionalCall', _85 => _85()])},[n,f,m]),ae=_react.useCallback.call(void 0, ()=>{p&&n(ie())},[ie,p,n]),Je=_react.useCallback.call(void 0, (_=!1)=>{_?(v.current=!0,n(null),_optionalChain([m, 'optionalCall', _86 => _86()])):(n(null),S.current=setTimeout(()=>{p&&(n(ie()),X(!1))},100))},[n,p,ie,m]);_react.useEffect.call(void 0, ()=>{i!==null&&N()},[i,N]),_react.useEffect.call(void 0, ()=>{i!==null&&F&&X(!1)},[i,F]),_react.useEffect.call(void 0, ()=>{_optionalChain([y, 'optionalCall', _87 => _87(me)])},[y,me]),_react.useEffect.call(void 0, ()=>{_optionalChain([d, 'optionalCall', _88 => _88($e)])},[d,$e]),_react.useEffect.call(void 0, ()=>()=>{S.current&&clearTimeout(S.current)},[]),_react.useEffect.call(void 0, ()=>{v.current&&P==="fresh"&&_optionalChain([T, 'optionalAccess', _89 => _89.id])&&(v.current=!1,n("signingOrder"))},[P,_optionalChain([T, 'optionalAccess', _90 => _90.id]),n]);let Ue=_=>{if(!_)return{backgroundColor:B==="default"?"var(--widget-muted)":"transparent",color:"var(--widget-muted-foreground)",border:B!=="default"?"1px solid var(--widget-border)":"none",borderRadius:"var(--widget-radius)"};switch(B){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)"}}},Se=`w-full ${H?"py-2":"py-3"} text-sm font-medium transition-colors cursor-pointer mt-1`;if(i===null&&!r&&!a){if(F)return _jsxruntime.jsx.call(void 0, "button",{className:Se,disabled:!0,style:{...Ue(!1),opacity:.6,cursor:"not-allowed"},children:"Getting fresh quote..."});let _=()=>C?"Insufficient Liquidity":$?"Route Not Available":L?"Size Cap Exceeded":!T&&P==="polling"?"Getting Quote...":T?"Swap":"Enter Amount",fe=!!p;return _jsxruntime.jsx.call(void 0, "button",{onClick:fe?ae:void 0,disabled:!fe,className:`${Se} disabled:opacity-40 disabled:cursor-not-allowed`,style:Ue(fe),children:_()})}return i===null&&a?_jsxruntime.jsx.call(void 0, "button",{onClick:p?ae:void 0,disabled:!p,className:`${Se} disabled:opacity-40 disabled:cursor-not-allowed`,style:Ue(!!p),children:"Unwrap"}):i===null&&r?_jsxruntime.jsx.call(void 0, "button",{onClick:p?ae:void 0,disabled:!p,className:`${Se} disabled:opacity-40 disabled:cursor-not-allowed`,style:Ue(!!p),children:"Wrap"}):i==="success"?_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-col gap-2 w-full",children:_jsxruntime.jsx.call(void 0, "button",{className:`w-full ${H?"py-2":"py-3"} text-sm 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"})}):i==="wrapSuccess"?_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-col gap-2 w-full",children:_jsxruntime.jsx.call(void 0, "button",{className:`w-full ${H?"py-2":"py-3"} text-sm 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:r?"Wrapped Successfully":"Unwrapped Successfully"})}):i==="cancelled"?_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-col gap-2 w-full",children:_jsxruntime.jsx.call(void 0, "button",{onClick:ee,className:`w-full ${H?"py-2":"py-3"} text-sm 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"})}):_jsxruntime.jsxs.call(void 0, "div",{className:"flex w-full",children:[i==="chain"&&Z&&_jsxruntime.jsx.call(void 0, er,{requiredChain:Be,needsChainSwitch:Z&&U!==e.chainId,reviewState:i,goToNextStep:z,cancel:te}),i==="wrapping"&&O&&_jsxruntime.jsx.call(void 0, fr,{needsToWrap:O,amount:t,chainId:e.chainId,token:e,reviewState:i,setReviewState:n,goToNextStep:z,cancel:te,delayedClose:Ce,isWrappingPair:r}),i==="unwrapping"&&A&&_jsxruntime.jsx.call(void 0, dr,{needsToUnwrap:A,amount:t,chainId:e.chainId,token:e,reviewState:i,setReviewState:n,goToNextStep:z,cancel:te,delayedClose:Ce}),i==="signingOrder"&&q&&_jsxruntime.jsx.call(void 0, ir,{base:e,baseAmount:t,quote:s,quoteAmount:l,userAddress:u,reviewState:i,goToNextStep:z,cancel:te,restartSigningFlow:Je,onSwapInitiated:g,onOrderSubmitted:o,isWrappingPair:r,isUnwrappingPair:a,onSwapComplete:x,startPolling:V,trackNativeTransaction:R}),i==="trackingTx"&&w&&_jsxruntime.jsx.call(void 0, cr,{orderHash:w,base:e,quote:s,baseAmount:t,quoteAmount:l,reviewState:i,status:c,onNewSwap:me,onRetry:$e}),i&&!["chain","wrapping","unwrapping","approval","signingOrder","trackingTx","success","wrapSuccess","cancelled"].includes(i)&&_jsxruntime.jsx.call(void 0, "button",{disabled:!0,className:`w-full ${H?"py-2":"py-3"} text-sm font-medium`,style:{backgroundColor:"var(--widget-muted)",color:"var(--widget-muted-foreground)",borderRadius:"var(--widget-radius)"},children:"Processing..."})]})};var _shallow = require('zustand/react/shallow');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)"},hr={pending:{title:"Trade Pending",subtitle:"Submitting to network"},received:{title:"Trade Received",subtitle:"Processing settlement"},completed:{title:"Trade Filled",subtitle:"Settlement complete"},failed:{title:"Trade Failed",subtitle:"Settlement unsuccessful"},cancelled:{title:"Trade Cancelled",subtitle:"Order was cancelled"}};function Gn(e){let t=_nullishCoalesce(br[e], () => (br.pending));return{textColor:t,bgColor:`color-mix(in srgb, ${t} 15%, transparent)`,borderColor:`color-mix(in srgb, ${t} 20%, transparent)`,cardBgColor:`color-mix(in srgb, ${t} 8%, transparent)`,cardBorderColor:`color-mix(in srgb, ${t} 15%, transparent)`,iconBgColor:`color-mix(in srgb, ${t} 12%, transparent)`,iconBorderColor:`color-mix(in srgb, ${t} 15%, transparent)`}}var Kn=({status:e})=>{switch(e){case"completed":return _jsxruntime.jsx.call(void 0, _chunkLXEKOQAGcjs.Q,{});case"failed":case"cancelled":return _jsxruntime.jsx.call(void 0, _chunkLXEKOQAGcjs.Z,{});default:return _jsxruntime.jsx.call(void 0, _chunkLXEKOQAGcjs.W,{size:"10"})}},Hn=({orderHash:e,base:t,quote:s,baseAmount:l,quoteAmount:u,status:r})=>{let[a,h]=_react.useState.call(void 0, !1),b=_react.useRef.call(void 0, null),p=_react.useRef.call(void 0, Date.now()),[i,n]=_react.useState.call(void 0, null),w=_react.useRef.call(void 0, null),{isRecipientInputOpen:f,recipient:c}=_chunkUZWGYG2Scjs.c.call(void 0, _shallow.useShallow.call(void 0, d=>({isRecipientInputOpen:d.isRecipientInputOpen,recipient:d.recipient})));_react.useEffect.call(void 0, ()=>{r==="received"&&(b.current=Date.now())},[r]),_react.useEffect.call(void 0, ()=>{if(r==="completed"&&!i){let d=b.current||p.current;n((Date.now()-d)/1e3)}},[r,i]),_react.useEffect.call(void 0, ()=>()=>{w.current&&clearTimeout(w.current)},[]);let x=_react.useCallback.call(void 0, ()=>{_optionalChain([navigator, 'access', _91 => _91.clipboard, 'optionalAccess', _92 => _92.writeText])&&navigator.clipboard.writeText(e).then(()=>{h(!0),w.current&&clearTimeout(w.current),w.current=setTimeout(()=>h(!1),2e3)}).catch(()=>{})},[e]),g=_nullishCoalesce(hr[r], () => (hr.pending)),o=Gn(r),m=_chunkLXEKOQAGcjs.q.call(void 0, l),y=_chunkLXEKOQAGcjs.q.call(void 0, u);return _jsxruntime.jsx.call(void 0, "div",{className:"relative w-full h-full overflow-hidden flex flex-col",style:{backgroundColor:o.bgColor,border:`1px var(--widget-border-style) ${o.borderColor}`,backdropFilter:"blur(8px)"},children:_jsxruntime.jsxs.call(void 0, "div",{className:"relative z-10 px-3 pt-5 pb-3 flex-1 flex flex-col",children:[_jsxruntime.jsx.call(void 0, "div",{className:"flex items-center justify-center mb-2",children:_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col items-center gap-1 text-center",children:[_jsxruntime.jsx.call(void 0, "div",{className:"flex h-10 w-10 items-center justify-center rounded-full border",style:{backgroundColor:o.iconBgColor,borderColor:o.iconBorderColor},children:_jsxruntime.jsx.call(void 0, "div",{className:"h-7 w-7 flex items-center justify-center",children:_jsxruntime.jsx.call(void 0, Kn,{status:r})})}),_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "h3",{className:"text-xl font-bold",style:{color:o.textColor},children:g.title}),_jsxruntime.jsx.call(void 0, "p",{className:"text-2xs uppercase tracking-wider",style:{color:o.textColor,opacity:.6},children:g.subtitle})]})]})}),_jsxruntime.jsx.call(void 0, "div",{className:"flex-1 flex flex-col justify-center",children:_jsxruntime.jsxs.call(void 0, "div",{className:"space-y-1.5",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center justify-between backdrop-blur-sm p-2.5 border transition-all duration-300",style:{backgroundColor:o.cardBgColor,borderColor:o.cardBorderColor},children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center gap-2.5",children:[_jsxruntime.jsx.call(void 0, _chunkLXEKOQAGcjs.P,{asset:t,size:"sm"}),_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "div",{className:"text-sm font-bold",style:{color:o.textColor},children:t.symbol}),_jsxruntime.jsx.call(void 0, "div",{className:"text-2xs",style:{color:o.textColor,opacity:.5},children:t.name})]})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"text-right",children:[_jsxruntime.jsx.call(void 0, "div",{className:"text-lg font-bold mono",style:{color:o.textColor},children:m}),t.price&&_jsxruntime.jsxs.call(void 0, "div",{className:"text-2xs mono",style:{color:o.textColor,opacity:.5},children:["$",(t.price*l).toFixed(2)]})]})]}),_jsxruntime.jsx.call(void 0, "div",{className:"flex justify-center pb-0.5 pt-1",children:_jsxruntime.jsx.call(void 0, "div",{className:"flex h-6 w-6 items-center justify-center rounded-full border",style:{backgroundColor:o.cardBgColor,borderColor:o.cardBorderColor},children:_jsxruntime.jsx.call(void 0, "span",{className:"text-base",style:{color:o.textColor},children:"\u2193"})})}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center justify-between backdrop-blur-sm p-2.5 border transition-all duration-300",style:{backgroundColor:o.cardBgColor,borderColor:o.cardBorderColor},children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center gap-2.5",children:[_jsxruntime.jsx.call(void 0, _chunkLXEKOQAGcjs.P,{asset:s,size:"sm"}),_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "div",{className:"text-sm font-bold",style:{color:o.textColor},children:s.symbol}),_jsxruntime.jsx.call(void 0, "div",{className:"text-2xs",style:{color:o.textColor,opacity:.5},children:s.name})]})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"text-right",children:[_jsxruntime.jsx.call(void 0, "div",{className:"text-lg font-bold mono",style:{color:o.textColor},children:y}),s.price&&_jsxruntime.jsxs.call(void 0, "div",{className:"text-2xs mono",style:{color:o.textColor,opacity:.5},children:["$",(s.price*u).toFixed(2)]})]})]}),f&&c&&_jsxruntime.jsxs.call(void 0, "div",{className:"mt-1.5",children:[_jsxruntime.jsx.call(void 0, "div",{className:"text-2xs mb-0.5 uppercase tracking-wider font-medium",style:{color:o.textColor,opacity:.5},children:"Recipient"}),_jsxruntime.jsx.call(void 0, "div",{className:"flex items-center backdrop-blur-sm p-2 border transition-all duration-300",style:{backgroundColor:o.cardBgColor,borderColor:o.cardBorderColor},children:_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center gap-2",children:[_jsxruntime.jsx.call(void 0, "div",{className:"flex h-5 w-5 items-center justify-center overflow-hidden rounded-full",style:{backgroundColor:o.iconBgColor},children:_jsxruntime.jsx.call(void 0, "span",{className:"text-2xs",children:"\u{1F464}"})}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col",children:[_jsxruntime.jsx.call(void 0, "div",{className:"text-2xs",style:{color:o.textColor,opacity:.5},children:"To:"}),_jsxruntime.jsxs.call(void 0, "div",{className:"text-xs mono",style:{color:o.textColor},children:[c.slice(0,6),"...",c.slice(-4)]})]})]})})]})]})}),_jsxruntime.jsxs.call(void 0, "div",{className:"mt-3 pt-2.5 space-y-1.5",style:{borderTop:`1px solid ${o.cardBorderColor}`},children:[_jsxruntime.jsxs.call(void 0, "div",{role:"button",tabIndex:0,onClick:x,onKeyDown:d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),x())},className:"flex items-center justify-between cursor-pointer group hover:opacity-80 transition-opacity",children:[_jsxruntime.jsx.call(void 0, "div",{className:"text-xs uppercase tracking-wider font-medium",style:{color:o.textColor,opacity:.5},children:a?"Copied!":r==="completed"||r==="failed"||r==="cancelled"?"Order Hash":r==="received"?"Received":"Pending"}),_jsxruntime.jsxs.call(void 0, "div",{className:"text-xs mono transition-colors",style:{color:o.textColor},children:[e.slice(0,6),"...",e.slice(-4)]})]}),r==="completed"&&i?_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center justify-between",children:[_jsxruntime.jsx.call(void 0, "div",{className:"text-xs uppercase tracking-wider font-medium",style:{color:o.textColor,opacity:.5},children:"Speed"}),_jsxruntime.jsxs.call(void 0, "div",{className:"text-base font-bold mono",style:{color:o.textColor},children:[i.toFixed(2),"s"]})]}):_jsxruntime.jsx.call(void 0, "div",{className:"h-5"})]})]})})},Oi= exports.w =Hn;exports.a = Tr; exports.b = Ee; exports.c = ts; exports.d = ls; exports.e = Ve; exports.f = Wr; exports.g = ms; exports.h = ys; exports.i = Rs; exports.j = Ps; exports.k = Dt; exports.l = Lt; exports.m = Bt; exports.n = Hr; exports.o = Ft; exports.p = Xr; exports.q = jt; exports.r = zt; exports.s = Gt; exports.t = Kt; exports.u = Ht; exports.v = Si; exports.w = Oi;
@@ -1,2 +1,2 @@
1
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
- var _chunkBX3KCZRTcjs = require('./chunk-BX3KCZRT.cjs');var _chunk34N36GUDcjs = require('./chunk-34N36GUD.cjs');var _zustand = require('zustand');var _react = require('react');var x=_zustand.create.call(void 0, )(n=>({baseToken:null,quoteToken:null,setBaseTokenDirect:e=>n({baseToken:e}),setQuoteTokenDirect:e=>n({quoteToken:e}),swapTokensDirect:()=>n(e=>({baseToken:e.quoteToken,quoteToken:e.baseToken}))}));function O(n){let{data:e,isLoading:c}=_chunkBX3KCZRTcjs.D.call(void 0, ),o=x(),T=_react.useRef.call(void 0, !1),t=_nullishCoalesce(_optionalChain([n, 'optionalAccess', _2 => _2.defaultBaseToken]), () => (null)),l=_nullishCoalesce(_optionalChain([n, 'optionalAccess', _3 => _3.defaultQuoteToken]), () => (null));_react.useEffect.call(void 0, ()=>{if(!e||e.length===0||T.current)return;T.current=!0;let u=k=>_nullishCoalesce(e.find(m=>m.chainId===k.chainId&&m.address.toLowerCase()===k.address.toLowerCase()), () => (null)),r=t?u(t):null,p=l?u(l):null;r&&p&&r.chainId===p.chainId&&r.address.toLowerCase()===p.address.toLowerCase()?(o.setBaseTokenDirect(r),o.setQuoteTokenDirect(null)):(o.setBaseTokenDirect(r),o.setQuoteTokenDirect(p))},[e,t,l,o]);let h=_react.useCallback.call(void 0, u=>{if(!u){o.setBaseTokenDirect(null);return}let r=x.getState();r.quoteToken&&u.chainId===r.quoteToken.chainId&&u.address.toLowerCase()===r.quoteToken.address.toLowerCase()?o.swapTokensDirect():o.setBaseTokenDirect(u)},[o]),f=_react.useCallback.call(void 0, u=>{if(!u){o.setQuoteTokenDirect(null);return}let r=x.getState();r.baseToken&&u.chainId===r.baseToken.chainId&&u.address.toLowerCase()===r.baseToken.address.toLowerCase()?o.swapTokensDirect():o.setQuoteTokenDirect(u)},[o]),w=_react.useCallback.call(void 0, ()=>{o.swapTokensDirect()},[o]);return{baseToken:o.baseToken,quoteToken:o.quoteToken,setBaseToken:h,setQuoteToken:f,swapTokens:w,isLoading:c}}var W=_zustand.create.call(void 0, )(n=>({view:"swap",isTransitioning:!1,transitionType:"navigation",selectedChainFilter:null,hoveredChainName:null,isRecipientInputOpen:!1,recipient:null,hasAllowanceError:!1,baseAmount:null,quoteAmount:null,isTrackingTx:!1,trackingOrderHash:null,txStatus:"pending",walletTab:"wallet",assetSelectionSearch:"",assetSelectionChain:"all",assetSelectionCategory:"all",assetSelectionAddressInput:"",recentChainIds:[],setView:e=>n({view:e,isTransitioning:!0,...e!=="wallet"&&{walletTab:"wallet"}}),setWalletTab:e=>n({walletTab:e}),setIsTransitioning:e=>n({isTransitioning:e}),transitionToView:(e,c="navigation")=>n({isTransitioning:!0,transitionType:c,view:e,...e!=="wallet"&&{walletTab:"wallet"}}),setChainFilter:e=>n({selectedChainFilter:e}),setHoveredChainName:e=>n({hoveredChainName:e}),toggleRecipientInput:()=>n(e=>({isRecipientInputOpen:!e.isRecipientInputOpen,recipient:e.isRecipientInputOpen?null:e.recipient})),setRecipient:e=>n({recipient:e}),setHasAllowanceError:e=>n({hasAllowanceError:e}),setBaseAmount:e=>n({baseAmount:e}),setQuoteAmount:e=>n({quoteAmount:e}),clearAmounts:()=>n({baseAmount:null,quoteAmount:null}),setIsTrackingTx:e=>n({isTrackingTx:e}),setTrackingOrderHash:e=>n({trackingOrderHash:e}),setTxStatus:e=>n({txStatus:e}),startTracking:e=>n({isTrackingTx:!0,trackingOrderHash:e,txStatus:"pending"}),stopTracking:()=>n({isTrackingTx:!1,trackingOrderHash:null,txStatus:"pending"}),setAssetSelectionSearch:e=>n({assetSelectionSearch:e}),setAssetSelectionChain:e=>n({assetSelectionChain:e}),setAssetSelectionCategory:e=>n({assetSelectionCategory:e}),setAssetSelectionAddressInput:e=>n({assetSelectionAddressInput:e}),pushRecentChain:e=>n(c=>{if(e===4326)return c;let T=c.recentChainIds.filter(t=>t!==e);return{recentChainIds:[e,...T].slice(0,3)}}),resetAssetSelection:()=>n({assetSelectionSearch:"",assetSelectionChain:"all",assetSelectionCategory:"all",assetSelectionAddressInput:""}),resetUI:()=>n({view:"swap",isTransitioning:!1,selectedChainFilter:null,hoveredChainName:null,isRecipientInputOpen:!1,recipient:null,hasAllowanceError:!1,baseAmount:null,quoteAmount:null,isTrackingTx:!1,trackingOrderHash:null,txStatus:"pending",walletTab:"wallet",assetSelectionSearch:"",assetSelectionChain:"all",assetSelectionCategory:"all",assetSelectionAddressInput:""})}));var _viem = require('viem');var _shallow = require('zustand/react/shallow');var U=(n,e,c,o)=>{let{address:T}=_chunk34N36GUDcjs.a.call(void 0, ),{baseToken:t,quoteToken:l,setBaseToken:h,setQuoteToken:f,swapTokens:w,isLoading:u}=O({defaultBaseToken:n,defaultQuoteToken:e}),{baseAmount:r,quoteAmount:p,setBaseAmount:k,setQuoteAmount:m,clearAmounts:F}=W(_shallow.useShallow.call(void 0, s=>({baseAmount:s.baseAmount,quoteAmount:s.quoteAmount,setBaseAmount:s.setBaseAmount,setQuoteAmount:s.setQuoteAmount,clearAmounts:s.clearAmounts}))),{data:Q}=_chunkBX3KCZRTcjs.E.call(void 0, _optionalChain([t, 'optionalAccess', _4 => _4.address]),_optionalChain([t, 'optionalAccess', _5 => _5.chainId])),{data:R}=_chunkBX3KCZRTcjs.E.call(void 0, _optionalChain([l, 'optionalAccess', _6 => _6.address]),_optionalChain([l, 'optionalAccess', _7 => _7.chainId])),a=_react.useMemo.call(void 0, ()=>{if(!t)return null;let s=_nullishCoalesce(_optionalChain([Q, 'optionalAccess', _8 => _8.price]), () => (t.price));return s===t.price?t:{...t,price:s}},[t,_optionalChain([Q, 'optionalAccess', _9 => _9.price])]),i=_react.useMemo.call(void 0, ()=>{if(!l)return null;let s=_nullishCoalesce(_optionalChain([R, 'optionalAccess', _10 => _10.price]), () => (l.price));return s===l.price?l:{...l,price:s}},[l,_optionalChain([R, 'optionalAccess', _11 => _11.price])]),{baseBalance:A,quoteBalance:I,isLoading:L}=_chunkBX3KCZRTcjs.M.call(void 0, T,a,i),b=_react.useMemo.call(void 0, ()=>!A||A.raw==="0"?null:A,[A]),C=_react.useMemo.call(void 0, ()=>!I||I.raw==="0"?null:I,[I]),v=_react.useMemo.call(void 0, ()=>{if(!_optionalChain([a, 'optionalAccess', _12 => _12.chainId]))return!1;let s=_chunkBX3KCZRTcjs.e.call(void 0, a.chainId);return a.address.toLowerCase()===_optionalChain([s, 'optionalAccess', _13 => _13.gasToken, 'access', _14 => _14.address, 'optionalAccess', _15 => _15.toLowerCase, 'call', _16 => _16()])},[a]),B=_react.useMemo.call(void 0, ()=>{if(!_optionalChain([i, 'optionalAccess', _17 => _17.chainId]))return!1;let s=_chunkBX3KCZRTcjs.e.call(void 0, i.chainId);return i.address.toLowerCase()===_optionalChain([s, 'optionalAccess', _18 => _18.gasToken, 'access', _19 => _19.address, 'optionalAccess', _20 => _20.toLowerCase, 'call', _21 => _21()])},[i]),V=_react.useMemo.call(void 0, ()=>{if(!v||!_optionalChain([a, 'optionalAccess', _22 => _22.chainId])||!i||a.chainId!==i.chainId||a.chainId===988)return!1;let s=_chunkBX3KCZRTcjs.e.call(void 0, a.chainId);return i.address.toLowerCase()===_optionalChain([s, 'optionalAccess', _23 => _23.wrappedAsset, 'access', _24 => _24.address, 'optionalAccess', _25 => _25.toLowerCase, 'call', _26 => _26()])},[v,a,i]),G=_react.useMemo.call(void 0, ()=>{if(!_optionalChain([a, 'optionalAccess', _27 => _27.chainId])||!i||!B||a.chainId!==i.chainId||a.chainId===988)return!1;let s=_chunkBX3KCZRTcjs.e.call(void 0, a.chainId);return a.address.toLowerCase()===_optionalChain([s, 'optionalAccess', _28 => _28.wrappedAsset, 'access', _29 => _29.address, 'optionalAccess', _30 => _30.toLowerCase, 'call', _31 => _31()])},[a,i,B]),M=_react.useMemo.call(void 0, ()=>({raw:_nullishCoalesce(_optionalChain([b, 'optionalAccess', _32 => _32.raw]), () => ("0")),formatted:_nullishCoalesce(_optionalChain([b, 'optionalAccess', _33 => _33.formatted]), () => ("0"))}),[b]),_=_react.useMemo.call(void 0, ()=>({raw:_nullishCoalesce(_optionalChain([C, 'optionalAccess', _34 => _34.raw]), () => ("0")),formatted:_nullishCoalesce(_optionalChain([C, 'optionalAccess', _35 => _35.formatted]), () => ("0"))}),[C]),z=_react.useMemo.call(void 0, ()=>!a||typeof r!="number"||a.decimals===void 0||a.decimals===null?null:_viem.parseUnits.call(void 0, r.toFixed(a.decimals),a.decimals).toString(),[a,r]),J=_react.useMemo.call(void 0, ()=>!i||typeof p!="number"||i.decimals===void 0||i.decimals===null?null:_viem.parseUnits.call(void 0, p.toFixed(i.decimals),i.decimals).toString(),[i,p]),K=_react.useCallback.call(void 0, async s=>{h(s),m(null),_optionalChain([c, 'optionalCall', _36 => _36(s)])},[h,m,c]),X=_react.useCallback.call(void 0, async s=>{f(s),_optionalChain([o, 'optionalCall', _37 => _37(s)])},[f,o]),Y=_react.useCallback.call(void 0, s=>k(s),[k]),Z=_react.useCallback.call(void 0, s=>m(s),[m]),$=_react.useCallback.call(void 0, ()=>{w(),l&&_optionalChain([c, 'optionalCall', _38 => _38(l)]),t&&_optionalChain([o, 'optionalCall', _39 => _39(t)])},[w,t,l,c,o]),j=_react.useCallback.call(void 0, ()=>F(),[F]);return{baseToken:a,baseAmount:r,quoteToken:i,quoteAmount:p,isBaseGasToken:v,isQuoteGasToken:B,isWrappingPair:V,isUnwrappingPair:G,baseBalance:M,quoteBalance:_,baseAmountRaw:z,quoteAmountRaw:J,isBaseBalanceLoading:L,isQuoteBalanceLoading:L,isRegistryLoading:u,setBaseToken:K,setQuoteToken:X,setBaseAmount:Y,setQuoteAmount:Z,swapTokens:$,clearForm:j}};var _jsxruntime = require('react/jsx-runtime');var N=_react.createContext.call(void 0, null),ye= exports.e =({children:n,defaultBaseToken:e,defaultQuoteToken:c,onBaseTokenChange:o,onQuoteTokenChange:T})=>{let t=U(e,c,o,T),l=_react.useMemo.call(void 0, ()=>t,[t.baseToken,t.quoteToken,t.baseAmount,t.quoteAmount,t.isBaseGasToken,t.isQuoteGasToken,t.isWrappingPair,t.isUnwrappingPair,t.baseBalance,t.quoteBalance,t.baseAmountRaw,t.quoteAmountRaw,t.isBaseBalanceLoading,t.isQuoteBalanceLoading,t.setBaseToken,t.setQuoteToken,t.setBaseAmount,t.setQuoteAmount,t.swapTokens,t.clearForm,t.isRegistryLoading]);return _jsxruntime.jsx.call(void 0, N.Provider,{value:l,children:n})},qe= exports.f =()=>{let n=_react.useContext.call(void 0, N);if(!n)throw new Error("useSwapFormContext must be used within SwapFormProvider");return n};exports.a = x; exports.b = O; exports.c = W; exports.d = U; exports.e = ye; exports.f = qe;
2
+ var _chunkLXEKOQAGcjs = require('./chunk-LXEKOQAG.cjs');var _chunk34N36GUDcjs = require('./chunk-34N36GUD.cjs');var _zustand = require('zustand');var _react = require('react');var x=_zustand.create.call(void 0, )(n=>({baseToken:null,quoteToken:null,setBaseTokenDirect:e=>n({baseToken:e}),setQuoteTokenDirect:e=>n({quoteToken:e}),swapTokensDirect:()=>n(e=>({baseToken:e.quoteToken,quoteToken:e.baseToken}))}));function O(n){let{data:e,isLoading:c}=_chunkLXEKOQAGcjs.D.call(void 0, ),o=x(),T=_react.useRef.call(void 0, !1),t=_nullishCoalesce(_optionalChain([n, 'optionalAccess', _2 => _2.defaultBaseToken]), () => (null)),l=_nullishCoalesce(_optionalChain([n, 'optionalAccess', _3 => _3.defaultQuoteToken]), () => (null));_react.useEffect.call(void 0, ()=>{if(!e||e.length===0||T.current)return;T.current=!0;let u=k=>_nullishCoalesce(e.find(m=>m.chainId===k.chainId&&m.address.toLowerCase()===k.address.toLowerCase()), () => (null)),r=t?u(t):null,p=l?u(l):null;r&&p&&r.chainId===p.chainId&&r.address.toLowerCase()===p.address.toLowerCase()?(o.setBaseTokenDirect(r),o.setQuoteTokenDirect(null)):(o.setBaseTokenDirect(r),o.setQuoteTokenDirect(p))},[e,t,l,o]);let h=_react.useCallback.call(void 0, u=>{if(!u){o.setBaseTokenDirect(null);return}let r=x.getState();r.quoteToken&&u.chainId===r.quoteToken.chainId&&u.address.toLowerCase()===r.quoteToken.address.toLowerCase()?o.swapTokensDirect():o.setBaseTokenDirect(u)},[o]),f=_react.useCallback.call(void 0, u=>{if(!u){o.setQuoteTokenDirect(null);return}let r=x.getState();r.baseToken&&u.chainId===r.baseToken.chainId&&u.address.toLowerCase()===r.baseToken.address.toLowerCase()?o.swapTokensDirect():o.setQuoteTokenDirect(u)},[o]),w=_react.useCallback.call(void 0, ()=>{o.swapTokensDirect()},[o]);return{baseToken:o.baseToken,quoteToken:o.quoteToken,setBaseToken:h,setQuoteToken:f,swapTokens:w,isLoading:c}}var W=_zustand.create.call(void 0, )(n=>({view:"swap",isTransitioning:!1,transitionType:"navigation",selectedChainFilter:null,hoveredChainName:null,isRecipientInputOpen:!1,recipient:null,hasAllowanceError:!1,baseAmount:null,quoteAmount:null,isTrackingTx:!1,trackingOrderHash:null,txStatus:"pending",walletTab:"wallet",assetSelectionSearch:"",assetSelectionChain:"all",assetSelectionCategory:"all",assetSelectionAddressInput:"",recentChainIds:[],setView:e=>n({view:e,isTransitioning:!0,...e!=="wallet"&&{walletTab:"wallet"}}),setWalletTab:e=>n({walletTab:e}),setIsTransitioning:e=>n({isTransitioning:e}),transitionToView:(e,c="navigation")=>n({isTransitioning:!0,transitionType:c,view:e,...e!=="wallet"&&{walletTab:"wallet"}}),setChainFilter:e=>n({selectedChainFilter:e}),setHoveredChainName:e=>n({hoveredChainName:e}),toggleRecipientInput:()=>n(e=>({isRecipientInputOpen:!e.isRecipientInputOpen,recipient:e.isRecipientInputOpen?null:e.recipient})),setRecipient:e=>n({recipient:e}),setHasAllowanceError:e=>n({hasAllowanceError:e}),setBaseAmount:e=>n({baseAmount:e}),setQuoteAmount:e=>n({quoteAmount:e}),clearAmounts:()=>n({baseAmount:null,quoteAmount:null}),setIsTrackingTx:e=>n({isTrackingTx:e}),setTrackingOrderHash:e=>n({trackingOrderHash:e}),setTxStatus:e=>n({txStatus:e}),startTracking:e=>n({isTrackingTx:!0,trackingOrderHash:e,txStatus:"pending"}),stopTracking:()=>n({isTrackingTx:!1,trackingOrderHash:null,txStatus:"pending"}),setAssetSelectionSearch:e=>n({assetSelectionSearch:e}),setAssetSelectionChain:e=>n({assetSelectionChain:e}),setAssetSelectionCategory:e=>n({assetSelectionCategory:e}),setAssetSelectionAddressInput:e=>n({assetSelectionAddressInput:e}),pushRecentChain:e=>n(c=>{if(e===4326)return c;let T=c.recentChainIds.filter(t=>t!==e);return{recentChainIds:[e,...T].slice(0,3)}}),resetAssetSelection:()=>n({assetSelectionSearch:"",assetSelectionChain:"all",assetSelectionCategory:"all",assetSelectionAddressInput:""}),resetUI:()=>n({view:"swap",isTransitioning:!1,selectedChainFilter:null,hoveredChainName:null,isRecipientInputOpen:!1,recipient:null,hasAllowanceError:!1,baseAmount:null,quoteAmount:null,isTrackingTx:!1,trackingOrderHash:null,txStatus:"pending",walletTab:"wallet",assetSelectionSearch:"",assetSelectionChain:"all",assetSelectionCategory:"all",assetSelectionAddressInput:""})}));var _viem = require('viem');var _shallow = require('zustand/react/shallow');var U=(n,e,c,o)=>{let{address:T}=_chunk34N36GUDcjs.a.call(void 0, ),{baseToken:t,quoteToken:l,setBaseToken:h,setQuoteToken:f,swapTokens:w,isLoading:u}=O({defaultBaseToken:n,defaultQuoteToken:e}),{baseAmount:r,quoteAmount:p,setBaseAmount:k,setQuoteAmount:m,clearAmounts:F}=W(_shallow.useShallow.call(void 0, s=>({baseAmount:s.baseAmount,quoteAmount:s.quoteAmount,setBaseAmount:s.setBaseAmount,setQuoteAmount:s.setQuoteAmount,clearAmounts:s.clearAmounts}))),{data:Q}=_chunkLXEKOQAGcjs.E.call(void 0, _optionalChain([t, 'optionalAccess', _4 => _4.address]),_optionalChain([t, 'optionalAccess', _5 => _5.chainId])),{data:R}=_chunkLXEKOQAGcjs.E.call(void 0, _optionalChain([l, 'optionalAccess', _6 => _6.address]),_optionalChain([l, 'optionalAccess', _7 => _7.chainId])),a=_react.useMemo.call(void 0, ()=>{if(!t)return null;let s=_nullishCoalesce(_optionalChain([Q, 'optionalAccess', _8 => _8.price]), () => (t.price));return s===t.price?t:{...t,price:s}},[t,_optionalChain([Q, 'optionalAccess', _9 => _9.price])]),i=_react.useMemo.call(void 0, ()=>{if(!l)return null;let s=_nullishCoalesce(_optionalChain([R, 'optionalAccess', _10 => _10.price]), () => (l.price));return s===l.price?l:{...l,price:s}},[l,_optionalChain([R, 'optionalAccess', _11 => _11.price])]),{baseBalance:A,quoteBalance:I,isLoading:L}=_chunkLXEKOQAGcjs.M.call(void 0, T,a,i),b=_react.useMemo.call(void 0, ()=>!A||A.raw==="0"?null:A,[A]),C=_react.useMemo.call(void 0, ()=>!I||I.raw==="0"?null:I,[I]),v=_react.useMemo.call(void 0, ()=>{if(!_optionalChain([a, 'optionalAccess', _12 => _12.chainId]))return!1;let s=_chunkLXEKOQAGcjs.e.call(void 0, a.chainId);return a.address.toLowerCase()===_optionalChain([s, 'optionalAccess', _13 => _13.gasToken, 'access', _14 => _14.address, 'optionalAccess', _15 => _15.toLowerCase, 'call', _16 => _16()])},[a]),B=_react.useMemo.call(void 0, ()=>{if(!_optionalChain([i, 'optionalAccess', _17 => _17.chainId]))return!1;let s=_chunkLXEKOQAGcjs.e.call(void 0, i.chainId);return i.address.toLowerCase()===_optionalChain([s, 'optionalAccess', _18 => _18.gasToken, 'access', _19 => _19.address, 'optionalAccess', _20 => _20.toLowerCase, 'call', _21 => _21()])},[i]),V=_react.useMemo.call(void 0, ()=>{if(!v||!_optionalChain([a, 'optionalAccess', _22 => _22.chainId])||!i||a.chainId!==i.chainId||a.chainId===988)return!1;let s=_chunkLXEKOQAGcjs.e.call(void 0, a.chainId);return i.address.toLowerCase()===_optionalChain([s, 'optionalAccess', _23 => _23.wrappedAsset, 'access', _24 => _24.address, 'optionalAccess', _25 => _25.toLowerCase, 'call', _26 => _26()])},[v,a,i]),G=_react.useMemo.call(void 0, ()=>{if(!_optionalChain([a, 'optionalAccess', _27 => _27.chainId])||!i||!B||a.chainId!==i.chainId||a.chainId===988)return!1;let s=_chunkLXEKOQAGcjs.e.call(void 0, a.chainId);return a.address.toLowerCase()===_optionalChain([s, 'optionalAccess', _28 => _28.wrappedAsset, 'access', _29 => _29.address, 'optionalAccess', _30 => _30.toLowerCase, 'call', _31 => _31()])},[a,i,B]),M=_react.useMemo.call(void 0, ()=>({raw:_nullishCoalesce(_optionalChain([b, 'optionalAccess', _32 => _32.raw]), () => ("0")),formatted:_nullishCoalesce(_optionalChain([b, 'optionalAccess', _33 => _33.formatted]), () => ("0"))}),[b]),_=_react.useMemo.call(void 0, ()=>({raw:_nullishCoalesce(_optionalChain([C, 'optionalAccess', _34 => _34.raw]), () => ("0")),formatted:_nullishCoalesce(_optionalChain([C, 'optionalAccess', _35 => _35.formatted]), () => ("0"))}),[C]),z=_react.useMemo.call(void 0, ()=>!a||typeof r!="number"||a.decimals===void 0||a.decimals===null?null:_viem.parseUnits.call(void 0, r.toFixed(a.decimals),a.decimals).toString(),[a,r]),J=_react.useMemo.call(void 0, ()=>!i||typeof p!="number"||i.decimals===void 0||i.decimals===null?null:_viem.parseUnits.call(void 0, p.toFixed(i.decimals),i.decimals).toString(),[i,p]),K=_react.useCallback.call(void 0, async s=>{h(s),m(null),_optionalChain([c, 'optionalCall', _36 => _36(s)])},[h,m,c]),X=_react.useCallback.call(void 0, async s=>{f(s),_optionalChain([o, 'optionalCall', _37 => _37(s)])},[f,o]),Y=_react.useCallback.call(void 0, s=>k(s),[k]),Z=_react.useCallback.call(void 0, s=>m(s),[m]),$=_react.useCallback.call(void 0, ()=>{w(),l&&_optionalChain([c, 'optionalCall', _38 => _38(l)]),t&&_optionalChain([o, 'optionalCall', _39 => _39(t)])},[w,t,l,c,o]),j=_react.useCallback.call(void 0, ()=>F(),[F]);return{baseToken:a,baseAmount:r,quoteToken:i,quoteAmount:p,isBaseGasToken:v,isQuoteGasToken:B,isWrappingPair:V,isUnwrappingPair:G,baseBalance:M,quoteBalance:_,baseAmountRaw:z,quoteAmountRaw:J,isBaseBalanceLoading:L,isQuoteBalanceLoading:L,isRegistryLoading:u,setBaseToken:K,setQuoteToken:X,setBaseAmount:Y,setQuoteAmount:Z,swapTokens:$,clearForm:j}};var _jsxruntime = require('react/jsx-runtime');var N=_react.createContext.call(void 0, null),ye= exports.e =({children:n,defaultBaseToken:e,defaultQuoteToken:c,onBaseTokenChange:o,onQuoteTokenChange:T})=>{let t=U(e,c,o,T),l=_react.useMemo.call(void 0, ()=>t,[t.baseToken,t.quoteToken,t.baseAmount,t.quoteAmount,t.isBaseGasToken,t.isQuoteGasToken,t.isWrappingPair,t.isUnwrappingPair,t.baseBalance,t.quoteBalance,t.baseAmountRaw,t.quoteAmountRaw,t.isBaseBalanceLoading,t.isQuoteBalanceLoading,t.setBaseToken,t.setQuoteToken,t.setBaseAmount,t.setQuoteAmount,t.swapTokens,t.clearForm,t.isRegistryLoading]);return _jsxruntime.jsx.call(void 0, N.Provider,{value:l,children:n})},qe= exports.f =()=>{let n=_react.useContext.call(void 0, N);if(!n)throw new Error("useSwapFormContext must be used within SwapFormProvider");return n};exports.a = x; exports.b = O; exports.c = W; exports.d = U; exports.e = ye; exports.f = qe;