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