@aori/mega-swap-widget 0.1.14 → 0.1.15
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-PKQLLSWV.cjs +2 -0
- package/dist/SwapFormHorizontal-TN7TRDH6.js +2 -0
- package/dist/SwapFormSplit-P3SM3A7K.cjs +2 -0
- package/dist/SwapFormSplit-ULDMGQV4.js +2 -0
- package/dist/chunk-62ZNAMP7.js +2 -0
- package/dist/{chunk-VRMEGTLO.js → chunk-GQ63BSRF.js} +1 -1
- package/dist/chunk-OPACGOVQ.cjs +2 -0
- package/dist/{chunk-TACQNUAS.cjs → chunk-RRDWIVV4.cjs} +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +2 -2
- package/package.json +1 -1
- package/dist/SwapFormHorizontal-5FJ7TQEX.cjs +0 -2
- package/dist/SwapFormHorizontal-FTHBLXVI.js +0 -2
- package/dist/SwapFormSplit-KDPORX7U.cjs +0 -2
- package/dist/SwapFormSplit-NYM2CDOV.js +0 -2
- package/dist/chunk-C5M5T5TV.cjs +0 -2
- package/dist/chunk-KDM36OCB.js +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; }"use client";
|
|
2
|
+
"use client";var _chunkRRDWIVV4cjs = require('./chunk-RRDWIVV4.cjs');var _chunkOPACGOVQcjs = require('./chunk-OPACGOVQ.cjs');var _chunkKJGKWM6Ycjs = require('./chunk-KJGKWM6Y.cjs');var _chunkOOKW3V5Mcjs = require('./chunk-OOKW3V5M.cjs');var _chunk4DL25Q57cjs = require('./chunk-4DL25Q57.cjs');require('./chunk-KH57FLST.cjs');var _chunkTN27ALOVcjs = require('./chunk-TN27ALOV.cjs');var _chunkTTVEGOCZcjs = require('./chunk-TTVEGOCZ.cjs');require('./chunk-NVCIA743.cjs');var _chunk34N36GUDcjs = require('./chunk-34N36GUD.cjs');require('./chunk-T3I3AJXV.cjs');var _react = require('react');var _shallow = require('zustand/react/shallow');var _jsxruntime = require('react/jsx-runtime');var q=()=>{},ze=({onSwapSubmitted:we,onSwapInitiated:he,onBackToSwap:k,onMoreChainsClick:Ee,startPolling:ve,trackNativeTransaction:be})=>{let{web3ConnectionType:Le,hasConnectHandler:xe,lockBase:O,lockQuote:I,disableInverting:Se,swapButtonVariant:R,tokenDisplay:V,tokenBadgeOrientation:A,widgetType:Ce,assetMenuVariant:ye}=_chunkTTVEGOCZcjs.b.call(void 0, ),{effectiveInputTokens:ke,effectiveOutputTokens:Ae}=_chunk4DL25Q57cjs.a.call(void 0, ),v=ke.length===1,b=Ae.length===1,D=V==="pill"||V==="ghost",F=Ce==="compact",{baseToken:t,quoteToken:o,baseAmount:i,quoteAmount:u,isBaseGasToken:M,isQuoteGasToken:Pe,isWrappingPair:a,isUnwrappingPair:l,baseBalance:g,quoteBalance:_e,setBaseAmount:y,setQuoteAmount:c,swapTokens:j,clearForm:G}=_chunkTN27ALOVcjs.e.call(void 0, ),{rfqQuote:Je,status:Ke,handleInputChange:B,ensureForParams:z,stop:Xe,clear:x,refresh:E}=_chunkOPACGOVQcjs.f.call(void 0, ),{address:p}=_chunk34N36GUDcjs.a.call(void 0, ),{openConnectModal:Te}=_chunkOPACGOVQcjs.h.call(void 0, ),{isRecipientInputOpen:W,txStatus:L,view:S,selectedChainFilterChainId:_}=_chunkTTVEGOCZcjs.d.call(void 0, _shallow.useShallow.call(void 0, s=>({isRecipientInputOpen:s.isRecipientInputOpen,txStatus:s.txStatus,view:s.view,selectedChainFilterChainId:_nullishCoalesce(_optionalChain([s, 'access', _2 => _2.selectedChainFilter, 'optionalAccess', _3 => _3.chainId]), () => (null))}))),[P,qe]=_react.useState.call(void 0, null),[T,J]=_react.useState.call(void 0, null),Ne=_react.useRef.call(void 0, !1),n=!1,Oe=_react.useMemo.call(void 0, ()=>!t||!o||typeof i!="number"||!u||!p||parseFloat(g.formatted)<i?null:{base:t,quote:o,baseAmount:i,quoteAmount:u,userAddress:p},[t,o,i,u,p,g.formatted]),Ie=_react.useCallback.call(void 0, s=>{J(s),_chunkTTVEGOCZcjs.d.getState().startTracking(s)},[]),Re=_react.useCallback.call(void 0, ()=>{Ne.current=!0,E()},[E]);_react.useEffect.call(void 0, ()=>{if(P===null&&!(!t||!o)){if(!i||i<=0){B({amount:null,inputToken:t,outputToken:o,setOutputAmount:c});return}if(a||l){c(i);return}B({amount:i,inputToken:t,outputToken:o,setOutputAmount:c})}},[P,i,t,o,a,l,B,c]);let $=_react.useCallback.call(void 0, ()=>{_chunkTTVEGOCZcjs.d.getState().setView("baseSelection")},[]),Q=_react.useCallback.call(void 0, ()=>{_chunkTTVEGOCZcjs.d.getState().setView("quoteSelection")},[]),Fe=_react.useCallback.call(void 0, ()=>{x(),j(),y(null),c(null)},[x,j,y,c]),Me=_react.useCallback.call(void 0, async()=>{if(!g.formatted||!t||!o)return;let s=parseFloat(g.formatted);if(!s||s<=0)return;let f;if(M){let C=await _chunkOPACGOVQcjs.i.call(void 0, t.chainId,_nullishCoalesce(p, () => (void 0)),g.raw);if(f=Math.max(0,s-C),f<=0)return}else f=s*.9999999999;a||l?(y(f),c(f),x()):(y(f),c(null),z({inputToken:t,outputToken:o,inputAmount:f.toString(),setOutputAmount:C=>c(C)}))},[g.formatted,g.raw,t,o,p,M,a,l,y,c,x,z]),Be=_react.useCallback.call(void 0, ()=>{x(),G()},[x,G]),K=g.formatted?parseFloat(g.formatted):null,We=!!(i||u),X=ye==="split",Y=X&&(S==="baseSelection"||S==="baseChainSelection"),Z=X&&(S==="quoteSelection"||S==="quoteChainSelection"),ee=_react.useCallback.call(void 0, s=>{let C=_chunkTTVEGOCZcjs.d.getState().view==="baseChainSelection"?"base":"quote";_chunkTTVEGOCZcjs.d.getState().setChainFilter({chainId:s,side:C}),_chunkTTVEGOCZcjs.d.getState().pushRecentChain(s),_chunkTTVEGOCZcjs.d.getState().transitionToView(C==="base"?"baseSelection":"quoteSelection","chainSelection")},[]),$e=_react.useCallback.call(void 0, ()=>{_chunkTTVEGOCZcjs.d.getState().transitionToView("baseChainSelection","chainSelection")},[]),Qe=_react.useCallback.call(void 0, ()=>{_chunkTTVEGOCZcjs.d.getState().transitionToView("quoteChainSelection","chainSelection")},[]),He=_optionalChain([t, 'optionalAccess', _4 => _4.price])&&i?`$${(t.price*i).toFixed(2)}`:"$0.00",Ue=_optionalChain([o, 'optionalAccess', _5 => _5.price])&&u?`$${(o.price*u).toFixed(2)}`:"$0.00",te=P==="trackingTx"&&!!T&&!!t&&!!o&&!!i&&!!u,oe={backgroundColor:R==="default"?"var(--widget-primary)":"transparent",color:R==="default"?"var(--widget-primary-foreground)":"var(--widget-primary)",border:R!=="default"?"1px solid var(--widget-primary)":"none",borderRadius:"var(--widget-radius)"};return _jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col w-full",children:[te&&T&&t&&o&&i&&u?_jsxruntime.jsx.call(void 0, "div",{className:"flex-1 min-h-0 overflow-hidden",children:_jsxruntime.jsx.call(void 0, _chunkOPACGOVQcjs.w,{orderHash:T,base:t,quote:o,baseAmount:i,quoteAmount:u,status:L})}):_jsxruntime.jsxs.call(void 0, "div",{className:`grid grid-cols-[1fr_auto_1fr] items-stretch px-4 ${F?"pt-3 pb-1":"pt-4 pb-2"} gap-2`,children:[_jsxruntime.jsx.call(void 0, "div",{className:`relative flex flex-col gap-1 p-3 rounded-lg overflow-hidden ${Y?"h-[380px]":""}`,style:{border:"1px solid var(--widget-border)",backgroundColor:"var(--widget-card)"},children:Y?S==="baseChainSelection"?_jsxruntime.jsx.call(void 0, _chunkOOKW3V5Mcjs.a,{toggle:_nullishCoalesce(k, () => (q)),side:"base",onChainSelect:ee}):_jsxruntime.jsx.call(void 0, _chunkKJGKWM6Ycjs.a,{toggle:_nullishCoalesce(k, () => (q)),side:"base",otherAsset:o,onMoreChainsClick:$e,selectedChainFilter:_}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[D?F?_jsxruntime.jsxs.call(void 0, "div",{className:`flex items-center gap-2 ${A==="right"?"flex-row-reverse":"flex-row"}`,children:[_jsxruntime.jsx.call(void 0, _chunkOPACGOVQcjs.k,{toggle:$,side:"base",asset:t,isPlacingOrder:n||O||v,hideDropdown:v}),_jsxruntime.jsx.call(void 0, "div",{className:"flex-1 min-w-0",children:_jsxruntime.jsx.call(void 0, _chunkOPACGOVQcjs.j,{side:"base",asset:_nullishCoalesce(t, () => (null)),otherAsset:_nullishCoalesce(o, () => (null)),isPlacingOrder:n,isWrappingPair:a,isUnwrappingPair:l})})]}):_jsxruntime.jsxs.call(void 0, "div",{className:`flex flex-col ${A==="right"?"items-end":"items-start"}`,children:[_jsxruntime.jsx.call(void 0, _chunkOPACGOVQcjs.k,{toggle:$,side:"base",asset:t,isPlacingOrder:n||O||v,hideDropdown:v}),_jsxruntime.jsx.call(void 0, _chunkOPACGOVQcjs.j,{side:"base",asset:_nullishCoalesce(t, () => (null)),otherAsset:_nullishCoalesce(o, () => (null)),isPlacingOrder:n,isWrappingPair:a,isUnwrappingPair:l})]}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, _chunkOPACGOVQcjs.k,{toggle:$,side:"base",asset:t,isPlacingOrder:n||O||v,hideDropdown:v}),_jsxruntime.jsx.call(void 0, _chunkOPACGOVQcjs.j,{side:"base",asset:_nullishCoalesce(t, () => (null)),otherAsset:_nullishCoalesce(o, () => (null)),isPlacingOrder:n,isWrappingPair:a,isUnwrappingPair:l})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center justify-between",children:[_jsxruntime.jsx.call(void 0, "span",{className:"font-sans text-xs",style:{color:"var(--widget-muted-foreground)"},children:He}),p&&K!==null&&K>0&&_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:Me,disabled:n,className:"flex items-center rounded-full px-2 py-0.5 text-xs font-medium uppercase cursor-pointer disabled:opacity-40 transition-colors bg-(--widget-primary) text-(--widget-primary-foreground) hover:bg-(--widget-foreground) hover:text-(--widget-card)",children:"Max"})]})]})}),_jsxruntime.jsx.call(void 0, "div",{className:"flex items-center justify-center px-1",children:Se?_jsxruntime.jsx.call(void 0, "div",{className:"flex h-8 w-8 items-center justify-center opacity-20",children:_jsxruntime.jsx.call(void 0, "span",{className:"text-sm",style:{color:"var(--widget-muted-foreground)"},children:"\u2192"})}):_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:Fe,"aria-label":"Swap input and output tokens",className:"flex h-8 w-8 items-center justify-center rounded-full cursor-pointer transition-colors bg-(--widget-card) text-(--widget-muted-foreground) hover:bg-(--widget-secondary) hover:text-(--widget-foreground)",style:{border:"1px solid var(--widget-border)"},children:_jsxruntime.jsx.call(void 0, _chunkOPACGOVQcjs.m,{className:"w-3.5 h-3.5"})})}),_jsxruntime.jsx.call(void 0, "div",{className:`relative flex flex-col gap-1 p-3 rounded-lg overflow-hidden ${Z?"h-[380px]":""}`,style:{border:"1px solid var(--widget-border)",backgroundColor:"var(--widget-card)"},children:Z?S==="quoteChainSelection"?_jsxruntime.jsx.call(void 0, _chunkOOKW3V5Mcjs.a,{toggle:_nullishCoalesce(k, () => (q)),side:"quote",onChainSelect:ee}):_jsxruntime.jsx.call(void 0, _chunkKJGKWM6Ycjs.a,{toggle:_nullishCoalesce(k, () => (q)),side:"quote",otherAsset:t,onMoreChainsClick:Qe,selectedChainFilter:_}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[D?F?_jsxruntime.jsxs.call(void 0, "div",{className:`flex items-center gap-2 ${A==="right"?"flex-row-reverse":"flex-row"}`,children:[_jsxruntime.jsx.call(void 0, _chunkOPACGOVQcjs.k,{toggle:Q,side:"quote",asset:o,isPlacingOrder:n||I||b,hideDropdown:b}),_jsxruntime.jsx.call(void 0, "div",{className:"flex-1 min-w-0",children:_jsxruntime.jsx.call(void 0, _chunkOPACGOVQcjs.j,{side:"quote",asset:_nullishCoalesce(o, () => (null)),otherAsset:_nullishCoalesce(t, () => (null)),isPlacingOrder:n,isWrappingPair:a,isUnwrappingPair:l})})]}):_jsxruntime.jsxs.call(void 0, "div",{className:`flex flex-col ${A==="right"?"items-end":"items-start"}`,children:[_jsxruntime.jsx.call(void 0, _chunkOPACGOVQcjs.k,{toggle:Q,side:"quote",asset:o,isPlacingOrder:n||I||b,hideDropdown:b}),_jsxruntime.jsx.call(void 0, _chunkOPACGOVQcjs.j,{side:"quote",asset:_nullishCoalesce(o, () => (null)),otherAsset:_nullishCoalesce(t, () => (null)),isPlacingOrder:n,isWrappingPair:a,isUnwrappingPair:l})]}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, _chunkOPACGOVQcjs.k,{toggle:Q,side:"quote",asset:o,isPlacingOrder:n||I||b,hideDropdown:b}),_jsxruntime.jsx.call(void 0, _chunkOPACGOVQcjs.j,{side:"quote",asset:_nullishCoalesce(o, () => (null)),otherAsset:_nullishCoalesce(t, () => (null)),isPlacingOrder:n,isWrappingPair:a,isUnwrappingPair:l})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center justify-between",children:[_jsxruntime.jsx.call(void 0, "span",{className:"font-sans text-xs",style:{color:"var(--widget-muted-foreground)"},children:Ue}),We&&_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:Be,disabled:n,className:"flex items-center rounded-full px-2 py-0.5 text-xs font-medium uppercase cursor-pointer disabled:opacity-40 transition-colors text-(--widget-muted-foreground) hover:bg-(--widget-secondary)",children:"Clear"})]})]})})]}),_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-row items-center w-full overflow-hidden px-4",style:{borderTop:W?"1px solid var(--widget-border)":"none",maxHeight:W?"60px":"0px",opacity:W?1:0,transition:"max-height 0.3s ease, opacity 0.3s ease"},children:_jsxruntime.jsx.call(void 0, _chunkOPACGOVQcjs.l,{})}),_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, _chunkRRDWIVV4cjs.a,{})}),_jsxruntime.jsx.call(void 0, "div",{className:`relative ${te?"px-0":"px-4"} py-4`,children:p&&t&&o&&i&&i>0?_jsxruntime.jsx.call(void 0, _chunkOPACGOVQcjs.v,{base:t,baseAmount:i,quote:o,quoteAmount:_nullishCoalesce(u, () => (0)),userAddress:p,isWrappingPair:a,isUnwrappingPair:l,isBaseGasToken:M,isQuoteGasToken:Pe,reviewActionProps:Oe,reviewState:P,setReviewState:qe,trackedOrderHash:T,setTrackedOrderHash:J,onSwapSubmitted:we,onSwapInitiated:he,onOrderSubmitted:Ie,onStaleQuoteRestart:Re,txStatus:L,startPolling:ve,trackNativeTransaction:be}):!p&&xe?_jsxruntime.jsx.call(void 0, "button",{onClick:()=>Te(),className:"w-full py-3 text-sm font-medium cursor-pointer transition-opacity hover:opacity-80",style:oe,children:"Connect Wallet"}):_jsxruntime.jsx.call(void 0, "button",{disabled:!0,className:"w-full py-3 text-sm font-medium transition-colors disabled:opacity-40 cursor-not-allowed",style:oe,children:p?"Enter Amount":"Connect Wallet"})})]})},vt= exports.default =ze;exports.default = vt;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use client";import{a as ue}from"./chunk-GQ63BSRF.js";import{f as ne,h as ae,i as de,j as w,k as h,l as ce,m as pe,v as me,w as ge}from"./chunk-62ZNAMP7.js";import{a as H}from"./chunk-DNOZXHWQ.js";import{a as U}from"./chunk-5ETKDN5C.js";import{a as le}from"./chunk-BKAIYAE7.js";import"./chunk-OPN7WCJR.js";import{e as re}from"./chunk-7ZT3SGKA.js";import{b as ie,d}from"./chunk-GGP6UREO.js";import"./chunk-SJMURCHX.js";import{a as se}from"./chunk-46H44R7V.js";import"./chunk-73CB2I7U.js";import{useCallback as m,useEffect as Ve,useMemo as De,useRef as je,useState as fe}from"react";import{useShallow as Ge}from"zustand/react/shallow";import{Fragment as N,jsx as e,jsxs as r}from"react/jsx-runtime";var q=()=>{},ze=({onSwapSubmitted:we,onSwapInitiated:he,onBackToSwap:k,onMoreChainsClick:Ee,startPolling:ve,trackNativeTransaction:be})=>{let{web3ConnectionType:Le,hasConnectHandler:xe,lockBase:O,lockQuote:I,disableInverting:Se,swapButtonVariant:R,tokenDisplay:V,tokenBadgeOrientation:A,widgetType:Ce,assetMenuVariant:ye}=ie(),{effectiveInputTokens:ke,effectiveOutputTokens:Ae}=le(),v=ke.length===1,b=Ae.length===1,D=V==="pill"||V==="ghost",F=Ce==="compact",{baseToken:t,quoteToken:o,baseAmount:i,quoteAmount:u,isBaseGasToken:M,isQuoteGasToken:Pe,isWrappingPair:a,isUnwrappingPair:l,baseBalance:g,quoteBalance:_e,setBaseAmount:y,setQuoteAmount:c,swapTokens:j,clearForm:G}=re(),{rfqQuote:Je,status:Ke,handleInputChange:B,ensureForParams:z,stop:Xe,clear:x,refresh:E}=ne(),{address:p}=se(),{openConnectModal:Te}=ae(),{isRecipientInputOpen:W,txStatus:L,view:S,selectedChainFilterChainId:_}=d(Ge(s=>({isRecipientInputOpen:s.isRecipientInputOpen,txStatus:s.txStatus,view:s.view,selectedChainFilterChainId:s.selectedChainFilter?.chainId??null}))),[P,qe]=fe(null),[T,J]=fe(null),Ne=je(!1),n=!1,Oe=De(()=>!t||!o||typeof i!="number"||!u||!p||parseFloat(g.formatted)<i?null:{base:t,quote:o,baseAmount:i,quoteAmount:u,userAddress:p},[t,o,i,u,p,g.formatted]),Ie=m(s=>{J(s),d.getState().startTracking(s)},[]),Re=m(()=>{Ne.current=!0,E()},[E]);Ve(()=>{if(P===null&&!(!t||!o)){if(!i||i<=0){B({amount:null,inputToken:t,outputToken:o,setOutputAmount:c});return}if(a||l){c(i);return}B({amount:i,inputToken:t,outputToken:o,setOutputAmount:c})}},[P,i,t,o,a,l,B,c]);let $=m(()=>{d.getState().setView("baseSelection")},[]),Q=m(()=>{d.getState().setView("quoteSelection")},[]),Fe=m(()=>{x(),j(),y(null),c(null)},[x,j,y,c]),Me=m(async()=>{if(!g.formatted||!t||!o)return;let s=parseFloat(g.formatted);if(!s||s<=0)return;let f;if(M){let C=await de(t.chainId,p??void 0,g.raw);if(f=Math.max(0,s-C),f<=0)return}else f=s*.9999999999;a||l?(y(f),c(f),x()):(y(f),c(null),z({inputToken:t,outputToken:o,inputAmount:f.toString(),setOutputAmount:C=>c(C)}))},[g.formatted,g.raw,t,o,p,M,a,l,y,c,x,z]),Be=m(()=>{x(),G()},[x,G]),K=g.formatted?parseFloat(g.formatted):null,We=!!(i||u),X=ye==="split",Y=X&&(S==="baseSelection"||S==="baseChainSelection"),Z=X&&(S==="quoteSelection"||S==="quoteChainSelection"),ee=m(s=>{let C=d.getState().view==="baseChainSelection"?"base":"quote";d.getState().setChainFilter({chainId:s,side:C}),d.getState().pushRecentChain(s),d.getState().transitionToView(C==="base"?"baseSelection":"quoteSelection","chainSelection")},[]),$e=m(()=>{d.getState().transitionToView("baseChainSelection","chainSelection")},[]),Qe=m(()=>{d.getState().transitionToView("quoteChainSelection","chainSelection")},[]),He=t?.price&&i?`$${(t.price*i).toFixed(2)}`:"$0.00",Ue=o?.price&&u?`$${(o.price*u).toFixed(2)}`:"$0.00",te=P==="trackingTx"&&!!T&&!!t&&!!o&&!!i&&!!u,oe={backgroundColor:R==="default"?"var(--widget-primary)":"transparent",color:R==="default"?"var(--widget-primary-foreground)":"var(--widget-primary)",border:R!=="default"?"1px solid var(--widget-primary)":"none",borderRadius:"var(--widget-radius)"};return r("div",{className:"flex flex-col w-full",children:[te&&T&&t&&o&&i&&u?e("div",{className:"flex-1 min-h-0 overflow-hidden",children:e(ge,{orderHash:T,base:t,quote:o,baseAmount:i,quoteAmount:u,status:L})}):r("div",{className:`grid grid-cols-[1fr_auto_1fr] items-stretch px-4 ${F?"pt-3 pb-1":"pt-4 pb-2"} gap-2`,children:[e("div",{className:`relative flex flex-col gap-1 p-3 rounded-lg overflow-hidden ${Y?"h-[380px]":""}`,style:{border:"1px solid var(--widget-border)",backgroundColor:"var(--widget-card)"},children:Y?S==="baseChainSelection"?e(U,{toggle:k??q,side:"base",onChainSelect:ee}):e(H,{toggle:k??q,side:"base",otherAsset:o,onMoreChainsClick:$e,selectedChainFilter:_}):r(N,{children:[D?F?r("div",{className:`flex items-center gap-2 ${A==="right"?"flex-row-reverse":"flex-row"}`,children:[e(h,{toggle:$,side:"base",asset:t,isPlacingOrder:n||O||v,hideDropdown:v}),e("div",{className:"flex-1 min-w-0",children:e(w,{side:"base",asset:t??null,otherAsset:o??null,isPlacingOrder:n,isWrappingPair:a,isUnwrappingPair:l})})]}):r("div",{className:`flex flex-col ${A==="right"?"items-end":"items-start"}`,children:[e(h,{toggle:$,side:"base",asset:t,isPlacingOrder:n||O||v,hideDropdown:v}),e(w,{side:"base",asset:t??null,otherAsset:o??null,isPlacingOrder:n,isWrappingPair:a,isUnwrappingPair:l})]}):r(N,{children:[e(h,{toggle:$,side:"base",asset:t,isPlacingOrder:n||O||v,hideDropdown:v}),e(w,{side:"base",asset:t??null,otherAsset:o??null,isPlacingOrder:n,isWrappingPair:a,isUnwrappingPair:l})]}),r("div",{className:"flex items-center justify-between",children:[e("span",{className:"font-sans text-xs",style:{color:"var(--widget-muted-foreground)"},children:He}),p&&K!==null&&K>0&&e("button",{type:"button",onClick:Me,disabled:n,className:"flex items-center rounded-full px-2 py-0.5 text-xs font-medium uppercase cursor-pointer disabled:opacity-40 transition-colors bg-(--widget-primary) text-(--widget-primary-foreground) hover:bg-(--widget-foreground) hover:text-(--widget-card)",children:"Max"})]})]})}),e("div",{className:"flex items-center justify-center px-1",children:Se?e("div",{className:"flex h-8 w-8 items-center justify-center opacity-20",children:e("span",{className:"text-sm",style:{color:"var(--widget-muted-foreground)"},children:"\u2192"})}):e("button",{type:"button",onClick:Fe,"aria-label":"Swap input and output tokens",className:"flex h-8 w-8 items-center justify-center rounded-full cursor-pointer transition-colors bg-(--widget-card) text-(--widget-muted-foreground) hover:bg-(--widget-secondary) hover:text-(--widget-foreground)",style:{border:"1px solid var(--widget-border)"},children:e(pe,{className:"w-3.5 h-3.5"})})}),e("div",{className:`relative flex flex-col gap-1 p-3 rounded-lg overflow-hidden ${Z?"h-[380px]":""}`,style:{border:"1px solid var(--widget-border)",backgroundColor:"var(--widget-card)"},children:Z?S==="quoteChainSelection"?e(U,{toggle:k??q,side:"quote",onChainSelect:ee}):e(H,{toggle:k??q,side:"quote",otherAsset:t,onMoreChainsClick:Qe,selectedChainFilter:_}):r(N,{children:[D?F?r("div",{className:`flex items-center gap-2 ${A==="right"?"flex-row-reverse":"flex-row"}`,children:[e(h,{toggle:Q,side:"quote",asset:o,isPlacingOrder:n||I||b,hideDropdown:b}),e("div",{className:"flex-1 min-w-0",children:e(w,{side:"quote",asset:o??null,otherAsset:t??null,isPlacingOrder:n,isWrappingPair:a,isUnwrappingPair:l})})]}):r("div",{className:`flex flex-col ${A==="right"?"items-end":"items-start"}`,children:[e(h,{toggle:Q,side:"quote",asset:o,isPlacingOrder:n||I||b,hideDropdown:b}),e(w,{side:"quote",asset:o??null,otherAsset:t??null,isPlacingOrder:n,isWrappingPair:a,isUnwrappingPair:l})]}):r(N,{children:[e(h,{toggle:Q,side:"quote",asset:o,isPlacingOrder:n||I||b,hideDropdown:b}),e(w,{side:"quote",asset:o??null,otherAsset:t??null,isPlacingOrder:n,isWrappingPair:a,isUnwrappingPair:l})]}),r("div",{className:"flex items-center justify-between",children:[e("span",{className:"font-sans text-xs",style:{color:"var(--widget-muted-foreground)"},children:Ue}),We&&e("button",{type:"button",onClick:Be,disabled:n,className:"flex items-center rounded-full px-2 py-0.5 text-xs font-medium uppercase cursor-pointer disabled:opacity-40 transition-colors text-(--widget-muted-foreground) hover:bg-(--widget-secondary)",children:"Clear"})]})]})})]}),e("div",{className:"flex flex-row items-center w-full overflow-hidden px-4",style:{borderTop:W?"1px solid var(--widget-border)":"none",maxHeight:W?"60px":"0px",opacity:W?1:0,transition:"max-height 0.3s ease, opacity 0.3s ease"},children:e(ce,{})}),e("div",{className:"px-4",style:{borderTop:"1px solid var(--widget-border)",borderBottom:"1px solid var(--widget-border)"},children:e(ue,{})}),e("div",{className:`relative ${te?"px-0":"px-4"} py-4`,children:p&&t&&o&&i&&i>0?e(me,{base:t,baseAmount:i,quote:o,quoteAmount:u??0,userAddress:p,isWrappingPair:a,isUnwrappingPair:l,isBaseGasToken:M,isQuoteGasToken:Pe,reviewActionProps:Oe,reviewState:P,setReviewState:qe,trackedOrderHash:T,setTrackedOrderHash:J,onSwapSubmitted:we,onSwapInitiated:he,onOrderSubmitted:Ie,onStaleQuoteRestart:Re,txStatus:L,startPolling:ve,trackNativeTransaction:be}):!p&&xe?e("button",{onClick:()=>Te(),className:"w-full py-3 text-sm font-medium cursor-pointer transition-opacity hover:opacity-80",style:oe,children:"Connect Wallet"}):e("button",{disabled:!0,className:"w-full py-3 text-sm font-medium transition-colors disabled:opacity-40 cursor-not-allowed",style:oe,children:p?"Enter Amount":"Connect Wallet"})})]})},vt=ze;export{vt as default};
|
|
@@ -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; }"use client";
|
|
2
|
+
"use client";var _chunkOPACGOVQcjs = require('./chunk-OPACGOVQ.cjs');var _chunkKJGKWM6Ycjs = require('./chunk-KJGKWM6Y.cjs');var _chunkOOKW3V5Mcjs = require('./chunk-OOKW3V5M.cjs');var _chunk4DL25Q57cjs = require('./chunk-4DL25Q57.cjs');require('./chunk-KH57FLST.cjs');var _chunkTN27ALOVcjs = require('./chunk-TN27ALOV.cjs');var _chunkTTVEGOCZcjs = require('./chunk-TTVEGOCZ.cjs');var _chunkNVCIA743cjs = require('./chunk-NVCIA743.cjs');var _chunk34N36GUDcjs = require('./chunk-34N36GUD.cjs');require('./chunk-T3I3AJXV.cjs');var _react = require('react');var _shallow = require('zustand/react/shallow');var _jsxruntime = require('react/jsx-runtime');var be=()=>{},ot=({onSwapSubmitted:Se,onSwapInitiated:ye,onBackToSwap:j,onMoreChainsClick:at,startPolling:Ne,trackNativeTransaction:Ce})=>{let{web3ConnectionType:it,hasConnectHandler:ke,lockBase:R,lockQuote:F,disableInverting:Ae,swapButtonVariant:I,tokenDisplay:G,tokenBadgeOrientation:A,widgetType:Te,assetMenuVariant:Pe}=_chunkTTVEGOCZcjs.b.call(void 0, ),{effectiveInputTokens:Oe,effectiveOutputTokens:qe}=_chunk4DL25Q57cjs.a.call(void 0, ),y=Oe.length===1,N=qe.length===1,z=G==="pill"||G==="ghost",T=Te==="compact",{baseToken:d,quoteToken:u,baseAmount:i,quoteAmount:n,isBaseGasToken:M,isQuoteGasToken:Re,isWrappingPair:p,isUnwrappingPair:m,baseBalance:v,setBaseAmount:k,setQuoteAmount:g,swapTokens:L,clearForm:_}=_chunkTN27ALOVcjs.e.call(void 0, ),{handleInputChange:$,ensureForParams:J,clear:C,refresh:K,liquidityError:Fe,routingError:Ie}=_chunkOPACGOVQcjs.f.call(void 0, ),{address:f}=_chunk34N36GUDcjs.a.call(void 0, ),{openConnectModal:Me}=_chunkOPACGOVQcjs.h.call(void 0, ),{isRecipientInputOpen:B,txStatus:X,view:w,selectedChainFilterChainId:$e}=_chunkTTVEGOCZcjs.d.call(void 0, _shallow.useShallow.call(void 0, a=>({isRecipientInputOpen:a.isRecipientInputOpen,txStatus:a.txStatus,view:a.view,selectedChainFilterChainId:_nullishCoalesce(a.selectedChainFilterChainId, () => (null))}))),[P,Be]=_react.useState.call(void 0, null),[O,Y]=_react.useState.call(void 0, null),We=_react.useRef.call(void 0, !1),r=!1,Qe=_react.useMemo.call(void 0, ()=>!d||!u||typeof i!="number"||!n||!f||parseFloat(v.formatted)<i?null:{base:d,quote:u,baseAmount:i,quoteAmount:n,userAddress:f},[d,u,i,n,f,v.formatted]),De=_react.useCallback.call(void 0, a=>{Y(a),_chunkTTVEGOCZcjs.d.getState().startTracking(a)},[]),Ue=_react.useCallback.call(void 0, ()=>{We.current=!0,K()},[K]);_react.useEffect.call(void 0, ()=>{if(P===null&&!(!d||!u)){if(!i||i<=0){$({amount:null,inputToken:d,outputToken:u,setOutputAmount:g});return}if(p||m){g(i);return}$({amount:i,inputToken:d,outputToken:u,setOutputAmount:g})}},[P,i,d,u,p,m,$,g]);let Z=i&&n&&parseFloat(n.toString())?parseFloat(i.toString())/parseFloat(n.toString()):0,W=_react.useCallback.call(void 0, ()=>{_chunkTTVEGOCZcjs.d.getState().setView("baseSelection")},[]),Q=_react.useCallback.call(void 0, ()=>{_chunkTTVEGOCZcjs.d.getState().setView("quoteSelection")},[]),Ve=_react.useCallback.call(void 0, ()=>{C(),L(),k(null),g(null)},[C,L,k,g]),He=_react.useCallback.call(void 0, async()=>{if(!v.formatted||!d||!u)return;let a=parseFloat(v.formatted);if(!a||a<=0)return;let l;if(M){let h=await _chunkOPACGOVQcjs.i.call(void 0, d.chainId,_nullishCoalesce(f, () => (void 0)),v.raw);if(l=Math.max(0,a-h),l<=0)return}else l=a*.9999999999;p||m?(k(l),g(l),C()):(k(l),g(null),J({inputToken:d,outputToken:u,inputAmount:l.toString(),setOutputAmount:h=>g(h)}))},[v.formatted,v.raw,d,u,f,M,p,m,k,g,C,J]),Ee=_react.useCallback.call(void 0, ()=>{C(),_()},[C,_]),ee=v.formatted?parseFloat(v.formatted):null,je=!!(i||n),s=d,o=u,Ge=_optionalChain([s, 'optionalAccess', _2 => _2.price])&&i?`$${(s.price*i).toFixed(2)}`:"$0.00",ze=_optionalChain([o, 'optionalAccess', _3 => _3.price])&&n?`$${(o.price*n).toFixed(2)}`:"$0.00",Le=!!(s&&o&&i&&n),_e=Fe||Ie,te=P==="trackingTx"&&!!O&&!!s&&!!o&&!!i&&!!n,D=Pe==="split",U=D&&(w==="baseSelection"||w==="quoteSelection"||w==="baseChainSelection"||w==="quoteChainSelection"),V=w==="baseSelection"||w==="baseChainSelection"?"base":"quote",Je=V==="base"?o:s,se=_react.useRef.call(void 0, null),[Ke,Xe]=_react.useState.call(void 0, 380);_react.useEffect.call(void 0, ()=>{if(!D)return;let a=se.current;if(!a)return;let l=new ResizeObserver(h=>{for(let et of h)Xe(et.contentRect.height)});return l.observe(a),()=>l.disconnect()},[D]);let Ye=_react.useCallback.call(void 0, a=>{let h=_chunkTTVEGOCZcjs.d.getState().view==="baseChainSelection"?"base":"quote";_chunkTTVEGOCZcjs.d.getState().setChainFilter({chainId:a,side:h}),_chunkTTVEGOCZcjs.d.getState().pushRecentChain(a),_chunkTTVEGOCZcjs.d.getState().transitionToView(h==="base"?"baseSelection":"quoteSelection","chainSelection")},[]),Ze=_react.useCallback.call(void 0, ()=>{let a=_chunkTTVEGOCZcjs.d.getState().view;a==="baseSelection"?_chunkTTVEGOCZcjs.d.getState().transitionToView("baseChainSelection","chainSelection"):a==="quoteSelection"&&_chunkTTVEGOCZcjs.d.getState().transitionToView("quoteChainSelection","chainSelection")},[]),oe={backgroundColor:I==="default"?"var(--widget-primary)":"transparent",color:I==="default"?"var(--widget-primary-foreground)":"var(--widget-primary)",border:I!=="default"?"1px solid var(--widget-primary)":"none",borderRadius:"var(--widget-radius)"};return _jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-row w-full",children:[_jsxruntime.jsxs.call(void 0, "div",{ref:se,className:"flex flex-col flex-1 min-w-0",style:{borderRight:"1px solid var(--widget-border)"},children:[te&&O&&s&&o&&i&&n?_jsxruntime.jsx.call(void 0, "div",{className:"flex-1 min-h-0 overflow-hidden",children:_jsxruntime.jsx.call(void 0, _chunkOPACGOVQcjs.w,{orderHash:O,base:s,quote:o,baseAmount:i,quoteAmount:n,status:X})}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsxs.call(void 0, "div",{className:`relative ${T?"px-4 pt-3 pb-1":"px-4 pt-4 pb-2"}`,style:{borderBottom:"1px solid var(--widget-border)"},children:[z?T?_jsxruntime.jsxs.call(void 0, "div",{className:`flex items-center gap-2 ${A==="right"?"flex-row-reverse":"flex-row"}`,children:[_jsxruntime.jsx.call(void 0, _chunkOPACGOVQcjs.k,{toggle:W,side:"base",asset:s,isPlacingOrder:r||R||y,hideDropdown:y}),_jsxruntime.jsx.call(void 0, "div",{className:"flex-1 min-w-0",children:_jsxruntime.jsx.call(void 0, _chunkOPACGOVQcjs.j,{side:"base",asset:_nullishCoalesce(s, () => (null)),otherAsset:_nullishCoalesce(o, () => (null)),isPlacingOrder:r,isWrappingPair:p,isUnwrappingPair:m})})]}):_jsxruntime.jsxs.call(void 0, "div",{className:`flex flex-col ${A==="right"?"items-end":"items-start"}`,children:[_jsxruntime.jsx.call(void 0, _chunkOPACGOVQcjs.k,{toggle:W,side:"base",asset:s,isPlacingOrder:r||R||y,hideDropdown:y}),_jsxruntime.jsx.call(void 0, _chunkOPACGOVQcjs.j,{side:"base",asset:_nullishCoalesce(s, () => (null)),otherAsset:_nullishCoalesce(o, () => (null)),isPlacingOrder:r,isWrappingPair:p,isUnwrappingPair:m})]}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, _chunkOPACGOVQcjs.k,{toggle:W,side:"base",asset:s,isPlacingOrder:r||R||y,hideDropdown:y}),_jsxruntime.jsx.call(void 0, _chunkOPACGOVQcjs.j,{side:"base",asset:_nullishCoalesce(s, () => (null)),otherAsset:_nullishCoalesce(o, () => (null)),isPlacingOrder:r,isWrappingPair:p,isUnwrappingPair:m})]}),_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:Ge}),f&&ee!==null&&ee>0&&_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:He,disabled:r,className:"absolute bottom-3 right-4 flex items-center rounded-full px-3 py-0.5 text-xs font-medium uppercase cursor-pointer disabled:opacity-40 bg-(--widget-primary) text-(--widget-primary-foreground) hover:bg-(--widget-foreground) hover:text-(--widget-card) transition-colors",children:"Max"})]})]}),!Ae&&_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:Ve,"aria-label":"Swap input and output tokens",className:"flex h-8 w-8 items-center justify-center rounded-full cursor-pointer bg-(--widget-card) text-(--widget-muted-foreground) hover:bg-(--widget-secondary) hover:text-(--widget-foreground) transition-colors",style:{border:"1px solid var(--widget-border)"},children:_jsxruntime.jsx.call(void 0, _chunkOPACGOVQcjs.m,{className:"w-3.5 h-3.5"})})}),_jsxruntime.jsxs.call(void 0, "div",{className:`relative ${T?"px-4 pt-4 pb-1":"px-4 pt-6 pb-2"}`,children:[z?T?_jsxruntime.jsxs.call(void 0, "div",{className:`flex items-center gap-2 ${A==="right"?"flex-row-reverse":"flex-row"}`,children:[_jsxruntime.jsx.call(void 0, _chunkOPACGOVQcjs.k,{toggle:Q,side:"quote",asset:o,isPlacingOrder:r||F||N,hideDropdown:N}),_jsxruntime.jsx.call(void 0, "div",{className:"flex-1 min-w-0",children:_jsxruntime.jsx.call(void 0, _chunkOPACGOVQcjs.j,{side:"quote",asset:_nullishCoalesce(o, () => (null)),otherAsset:_nullishCoalesce(s, () => (null)),isPlacingOrder:r,isWrappingPair:p,isUnwrappingPair:m})})]}):_jsxruntime.jsxs.call(void 0, "div",{className:`flex flex-col ${A==="right"?"items-end":"items-start"}`,children:[_jsxruntime.jsx.call(void 0, _chunkOPACGOVQcjs.k,{toggle:Q,side:"quote",asset:o,isPlacingOrder:r||F||N,hideDropdown:N}),_jsxruntime.jsx.call(void 0, _chunkOPACGOVQcjs.j,{side:"quote",asset:_nullishCoalesce(o, () => (null)),otherAsset:_nullishCoalesce(s, () => (null)),isPlacingOrder:r,isWrappingPair:p,isUnwrappingPair:m})]}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, _chunkOPACGOVQcjs.k,{toggle:Q,side:"quote",asset:o,isPlacingOrder:r||F||N,hideDropdown:N}),_jsxruntime.jsx.call(void 0, _chunkOPACGOVQcjs.j,{side:"quote",asset:_nullishCoalesce(o, () => (null)),otherAsset:_nullishCoalesce(s, () => (null)),isPlacingOrder:r,isWrappingPair:p,isUnwrappingPair:m})]}),_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:ze}),je&&_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:Ee,disabled:r,className:"absolute bottom-2 right-4 flex items-center rounded-full px-3 py-0.5 text-xs font-medium uppercase cursor-pointer disabled:opacity-40 text-(--widget-muted-foreground) hover:bg-(--widget-secondary) transition-colors",children:"Clear"})]})]})]}),_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-row items-center w-full overflow-hidden",style:{borderTop:B?"1px solid var(--widget-border)":"none",maxHeight:B?"60px":"0px",opacity:B?1:0,transition:"max-height 0.3s ease, opacity 0.3s ease"},children:_jsxruntime.jsx.call(void 0, _chunkOPACGOVQcjs.l,{})}),_jsxruntime.jsx.call(void 0, "div",{className:`relative ${te?"px-0":"px-4"} py-4`,children:f&&s&&o&&i&&i>0?_jsxruntime.jsx.call(void 0, _chunkOPACGOVQcjs.v,{base:s,baseAmount:i,quote:o,quoteAmount:_nullishCoalesce(n, () => (0)),userAddress:f,isWrappingPair:p,isUnwrappingPair:m,isBaseGasToken:M,isQuoteGasToken:Re,reviewActionProps:Qe,reviewState:P,setReviewState:Be,trackedOrderHash:O,setTrackedOrderHash:Y,onSwapSubmitted:Se,onSwapInitiated:ye,onOrderSubmitted:De,onStaleQuoteRestart:Ue,txStatus:X,startPolling:Ne,trackNativeTransaction:Ce}):!f&&ke?_jsxruntime.jsx.call(void 0, "button",{onClick:()=>Me(),className:"w-full py-3 text-sm font-medium cursor-pointer transition-opacity hover:opacity-80",style:oe,children:"Connect Wallet"}):_jsxruntime.jsx.call(void 0, "button",{disabled:!0,className:"w-full py-3 text-sm font-medium transition-colors disabled:opacity-40 cursor-not-allowed",style:oe,children:f?"Enter Amount":"Connect Wallet"})})]}),_jsxruntime.jsx.call(void 0, "div",{className:`flex flex-col transition-all duration-300 ${U?"flex-1 min-w-0":"w-48 shrink-0"}`,style:{backgroundColor:"var(--widget-background)",...U?{height:`${Ke}px`}:{}},children:U?_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-col overflow-hidden p-2",style:{height:"100%"},children:w==="baseChainSelection"||w==="quoteChainSelection"?_jsxruntime.jsx.call(void 0, _chunkOOKW3V5Mcjs.a,{toggle:_nullishCoalesce(j, () => (be)),side:V,onChainSelect:Ye}):_jsxruntime.jsx.call(void 0, _chunkKJGKWM6Ycjs.a,{toggle:_nullishCoalesce(j, () => (be)),side:V,otherAsset:Je,onMoreChainsClick:Ze,selectedChainFilter:$e})}):_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-3 px-4 py-4",children:[_jsxruntime.jsx.call(void 0, "span",{className:"text-2xs uppercase tracking-wider font-medium",style:{color:"var(--widget-muted-foreground)"},children:"Quote Details"}),Le&&s&&o?_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-0.5",children:[_jsxruntime.jsx.call(void 0, "span",{className:"text-2xs",style:{color:"var(--widget-muted-foreground)"},children:"Rate"}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center gap-1",children:[_jsxruntime.jsx.call(void 0, _chunkNVCIA743cjs.O,{asset:o,size:"3xs",noChain:!0}),_jsxruntime.jsxs.call(void 0, "span",{className:"font-sans text-xs uppercase",children:["1 ",o.symbol]})]}),_jsxruntime.jsx.call(void 0, "div",{className:"flex items-center gap-1 pl-4",children:_jsxruntime.jsxs.call(void 0, "span",{className:"text-2xs",style:{color:"var(--widget-muted-foreground)"},children:["= ",Z.toFixed(6)]})}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center gap-1 pl-4",children:[_jsxruntime.jsx.call(void 0, _chunkNVCIA743cjs.O,{asset:s,size:"3xs",noChain:!0}),_jsxruntime.jsx.call(void 0, "span",{className:"font-sans text-xs uppercase",children:s.symbol})]})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-2",style:{borderTop:"1px solid var(--widget-border)",paddingTop:"0.5rem"},children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex justify-between items-center",children:[_jsxruntime.jsx.call(void 0, "span",{className:"text-2xs",style:{color:"var(--widget-muted-foreground)"},children:"USD Value"}),_jsxruntime.jsxs.call(void 0, "span",{className:"font-sans text-xs",children:["$",s.price?(s.price*Z*parseFloat(n.toString())).toFixed(2):"\u2014"]})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex justify-between items-center",children:[_jsxruntime.jsx.call(void 0, "span",{className:"text-2xs",style:{color:"var(--widget-muted-foreground)"},children:"Order Type"}),_jsxruntime.jsx.call(void 0, "span",{className:"text-2xs font-sans",style:{color:"var(--widget-foreground)"},children:"RFQ"})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex justify-between items-center",children:[_jsxruntime.jsx.call(void 0, "span",{className:"text-2xs",style:{color:"var(--widget-muted-foreground)"},children:"Fill"}),_jsxruntime.jsx.call(void 0, "span",{className:"text-2xs",style:{color:"var(--widget-primary)"},children:"Exact"})]}),s.chainId!==o.chainId&&_jsxruntime.jsxs.call(void 0, "div",{className:"flex justify-between items-center",children:[_jsxruntime.jsx.call(void 0, "span",{className:"text-2xs",style:{color:"var(--widget-muted-foreground)"},children:"Route"}),_jsxruntime.jsx.call(void 0, "span",{className:"text-2xs font-sans",children:"Cross-chain"})]})]})]}):_e?_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-1",children:[_jsxruntime.jsx.call(void 0, _chunkNVCIA743cjs.W,{className:"h-6 w-6",style:{color:"var(--widget-destructive)"}}),_jsxruntime.jsx.call(void 0, "span",{className:"text-2xs",style:{color:"var(--widget-destructive)"},children:"Quote not found"})]}):_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-2 mt-2",children:[[...Array(4)].map((a,l)=>_jsxruntime.jsx.call(void 0, "div",{className:"h-3 rounded animate-pulse",style:{backgroundColor:"var(--widget-muted)",width:l%2===0?"80%":"60%",opacity:.5}},l)),_jsxruntime.jsx.call(void 0, "span",{className:"text-2xs mt-1",style:{color:"var(--widget-muted-foreground)",opacity:.5},children:"Enter an amount"})]})]})})]})},At= exports.default =ot;exports.default = At;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use client";import{f as re,h as de,i as ue,j as b,k as S,l as pe,m as me,v as ge,w as fe}from"./chunk-62ZNAMP7.js";import{a as ve}from"./chunk-DNOZXHWQ.js";import{a as xe}from"./chunk-5ETKDN5C.js";import{a as ce}from"./chunk-BKAIYAE7.js";import"./chunk-OPN7WCJR.js";import{e as le}from"./chunk-7ZT3SGKA.js";import{b as ae,d as c}from"./chunk-GGP6UREO.js";import{O as H,W as ie}from"./chunk-SJMURCHX.js";import{a as ne}from"./chunk-46H44R7V.js";import"./chunk-73CB2I7U.js";import{useCallback as x,useEffect as we,useMemo as tt,useRef as he,useState as E}from"react";import{useShallow as st}from"zustand/react/shallow";import{Fragment as q,jsx as e,jsxs as t}from"react/jsx-runtime";var be=()=>{},ot=({onSwapSubmitted:Se,onSwapInitiated:ye,onBackToSwap:j,onMoreChainsClick:at,startPolling:Ne,trackNativeTransaction:Ce})=>{let{web3ConnectionType:it,hasConnectHandler:ke,lockBase:R,lockQuote:F,disableInverting:Ae,swapButtonVariant:I,tokenDisplay:G,tokenBadgeOrientation:A,widgetType:Te,assetMenuVariant:Pe}=ae(),{effectiveInputTokens:Oe,effectiveOutputTokens:qe}=ce(),y=Oe.length===1,N=qe.length===1,z=G==="pill"||G==="ghost",T=Te==="compact",{baseToken:d,quoteToken:u,baseAmount:i,quoteAmount:n,isBaseGasToken:M,isQuoteGasToken:Re,isWrappingPair:p,isUnwrappingPair:m,baseBalance:v,setBaseAmount:k,setQuoteAmount:g,swapTokens:L,clearForm:_}=le(),{handleInputChange:$,ensureForParams:J,clear:C,refresh:K,liquidityError:Fe,routingError:Ie}=re(),{address:f}=ne(),{openConnectModal:Me}=de(),{isRecipientInputOpen:B,txStatus:X,view:w,selectedChainFilterChainId:$e}=c(st(a=>({isRecipientInputOpen:a.isRecipientInputOpen,txStatus:a.txStatus,view:a.view,selectedChainFilterChainId:a.selectedChainFilterChainId??null}))),[P,Be]=E(null),[O,Y]=E(null),We=he(!1),r=!1,Qe=tt(()=>!d||!u||typeof i!="number"||!n||!f||parseFloat(v.formatted)<i?null:{base:d,quote:u,baseAmount:i,quoteAmount:n,userAddress:f},[d,u,i,n,f,v.formatted]),De=x(a=>{Y(a),c.getState().startTracking(a)},[]),Ue=x(()=>{We.current=!0,K()},[K]);we(()=>{if(P===null&&!(!d||!u)){if(!i||i<=0){$({amount:null,inputToken:d,outputToken:u,setOutputAmount:g});return}if(p||m){g(i);return}$({amount:i,inputToken:d,outputToken:u,setOutputAmount:g})}},[P,i,d,u,p,m,$,g]);let Z=i&&n&&parseFloat(n.toString())?parseFloat(i.toString())/parseFloat(n.toString()):0,W=x(()=>{c.getState().setView("baseSelection")},[]),Q=x(()=>{c.getState().setView("quoteSelection")},[]),Ve=x(()=>{C(),L(),k(null),g(null)},[C,L,k,g]),He=x(async()=>{if(!v.formatted||!d||!u)return;let a=parseFloat(v.formatted);if(!a||a<=0)return;let l;if(M){let h=await ue(d.chainId,f??void 0,v.raw);if(l=Math.max(0,a-h),l<=0)return}else l=a*.9999999999;p||m?(k(l),g(l),C()):(k(l),g(null),J({inputToken:d,outputToken:u,inputAmount:l.toString(),setOutputAmount:h=>g(h)}))},[v.formatted,v.raw,d,u,f,M,p,m,k,g,C,J]),Ee=x(()=>{C(),_()},[C,_]),ee=v.formatted?parseFloat(v.formatted):null,je=!!(i||n),s=d,o=u,Ge=s?.price&&i?`$${(s.price*i).toFixed(2)}`:"$0.00",ze=o?.price&&n?`$${(o.price*n).toFixed(2)}`:"$0.00",Le=!!(s&&o&&i&&n),_e=Fe||Ie,te=P==="trackingTx"&&!!O&&!!s&&!!o&&!!i&&!!n,D=Pe==="split",U=D&&(w==="baseSelection"||w==="quoteSelection"||w==="baseChainSelection"||w==="quoteChainSelection"),V=w==="baseSelection"||w==="baseChainSelection"?"base":"quote",Je=V==="base"?o:s,se=he(null),[Ke,Xe]=E(380);we(()=>{if(!D)return;let a=se.current;if(!a)return;let l=new ResizeObserver(h=>{for(let et of h)Xe(et.contentRect.height)});return l.observe(a),()=>l.disconnect()},[D]);let Ye=x(a=>{let h=c.getState().view==="baseChainSelection"?"base":"quote";c.getState().setChainFilter({chainId:a,side:h}),c.getState().pushRecentChain(a),c.getState().transitionToView(h==="base"?"baseSelection":"quoteSelection","chainSelection")},[]),Ze=x(()=>{let a=c.getState().view;a==="baseSelection"?c.getState().transitionToView("baseChainSelection","chainSelection"):a==="quoteSelection"&&c.getState().transitionToView("quoteChainSelection","chainSelection")},[]),oe={backgroundColor:I==="default"?"var(--widget-primary)":"transparent",color:I==="default"?"var(--widget-primary-foreground)":"var(--widget-primary)",border:I!=="default"?"1px solid var(--widget-primary)":"none",borderRadius:"var(--widget-radius)"};return t("div",{className:"flex flex-row w-full",children:[t("div",{ref:se,className:"flex flex-col flex-1 min-w-0",style:{borderRight:"1px solid var(--widget-border)"},children:[te&&O&&s&&o&&i&&n?e("div",{className:"flex-1 min-h-0 overflow-hidden",children:e(fe,{orderHash:O,base:s,quote:o,baseAmount:i,quoteAmount:n,status:X})}):t(q,{children:[t("div",{className:`relative ${T?"px-4 pt-3 pb-1":"px-4 pt-4 pb-2"}`,style:{borderBottom:"1px solid var(--widget-border)"},children:[z?T?t("div",{className:`flex items-center gap-2 ${A==="right"?"flex-row-reverse":"flex-row"}`,children:[e(S,{toggle:W,side:"base",asset:s,isPlacingOrder:r||R||y,hideDropdown:y}),e("div",{className:"flex-1 min-w-0",children:e(b,{side:"base",asset:s??null,otherAsset:o??null,isPlacingOrder:r,isWrappingPair:p,isUnwrappingPair:m})})]}):t("div",{className:`flex flex-col ${A==="right"?"items-end":"items-start"}`,children:[e(S,{toggle:W,side:"base",asset:s,isPlacingOrder:r||R||y,hideDropdown:y}),e(b,{side:"base",asset:s??null,otherAsset:o??null,isPlacingOrder:r,isWrappingPair:p,isUnwrappingPair:m})]}):t(q,{children:[e(S,{toggle:W,side:"base",asset:s,isPlacingOrder:r||R||y,hideDropdown:y}),e(b,{side:"base",asset:s??null,otherAsset:o??null,isPlacingOrder:r,isWrappingPair:p,isUnwrappingPair:m})]}),t("div",{className:"mb-1 flex w-full flex-row items-center justify-between",children:[e("p",{className:"font-sans text-sm",style:{color:"var(--widget-muted-foreground)"},children:Ge}),f&&ee!==null&&ee>0&&e("button",{type:"button",onClick:He,disabled:r,className:"absolute bottom-3 right-4 flex items-center rounded-full px-3 py-0.5 text-xs font-medium uppercase cursor-pointer disabled:opacity-40 bg-(--widget-primary) text-(--widget-primary-foreground) hover:bg-(--widget-foreground) hover:text-(--widget-card) transition-colors",children:"Max"})]})]}),!Ae&&e("div",{className:"flex justify-center -my-4 relative z-10",children:e("button",{type:"button",onClick:Ve,"aria-label":"Swap input and output tokens",className:"flex h-8 w-8 items-center justify-center rounded-full cursor-pointer bg-(--widget-card) text-(--widget-muted-foreground) hover:bg-(--widget-secondary) hover:text-(--widget-foreground) transition-colors",style:{border:"1px solid var(--widget-border)"},children:e(me,{className:"w-3.5 h-3.5"})})}),t("div",{className:`relative ${T?"px-4 pt-4 pb-1":"px-4 pt-6 pb-2"}`,children:[z?T?t("div",{className:`flex items-center gap-2 ${A==="right"?"flex-row-reverse":"flex-row"}`,children:[e(S,{toggle:Q,side:"quote",asset:o,isPlacingOrder:r||F||N,hideDropdown:N}),e("div",{className:"flex-1 min-w-0",children:e(b,{side:"quote",asset:o??null,otherAsset:s??null,isPlacingOrder:r,isWrappingPair:p,isUnwrappingPair:m})})]}):t("div",{className:`flex flex-col ${A==="right"?"items-end":"items-start"}`,children:[e(S,{toggle:Q,side:"quote",asset:o,isPlacingOrder:r||F||N,hideDropdown:N}),e(b,{side:"quote",asset:o??null,otherAsset:s??null,isPlacingOrder:r,isWrappingPair:p,isUnwrappingPair:m})]}):t(q,{children:[e(S,{toggle:Q,side:"quote",asset:o,isPlacingOrder:r||F||N,hideDropdown:N}),e(b,{side:"quote",asset:o??null,otherAsset:s??null,isPlacingOrder:r,isWrappingPair:p,isUnwrappingPair:m})]}),t("div",{className:"flex w-full flex-row items-center justify-between",children:[e("p",{className:"font-sans text-sm",style:{color:"var(--widget-muted-foreground)"},children:ze}),je&&e("button",{type:"button",onClick:Ee,disabled:r,className:"absolute bottom-2 right-4 flex items-center rounded-full px-3 py-0.5 text-xs font-medium uppercase cursor-pointer disabled:opacity-40 text-(--widget-muted-foreground) hover:bg-(--widget-secondary) transition-colors",children:"Clear"})]})]})]}),e("div",{className:"flex flex-row items-center w-full overflow-hidden",style:{borderTop:B?"1px solid var(--widget-border)":"none",maxHeight:B?"60px":"0px",opacity:B?1:0,transition:"max-height 0.3s ease, opacity 0.3s ease"},children:e(pe,{})}),e("div",{className:`relative ${te?"px-0":"px-4"} py-4`,children:f&&s&&o&&i&&i>0?e(ge,{base:s,baseAmount:i,quote:o,quoteAmount:n??0,userAddress:f,isWrappingPair:p,isUnwrappingPair:m,isBaseGasToken:M,isQuoteGasToken:Re,reviewActionProps:Qe,reviewState:P,setReviewState:Be,trackedOrderHash:O,setTrackedOrderHash:Y,onSwapSubmitted:Se,onSwapInitiated:ye,onOrderSubmitted:De,onStaleQuoteRestart:Ue,txStatus:X,startPolling:Ne,trackNativeTransaction:Ce}):!f&&ke?e("button",{onClick:()=>Me(),className:"w-full py-3 text-sm font-medium cursor-pointer transition-opacity hover:opacity-80",style:oe,children:"Connect Wallet"}):e("button",{disabled:!0,className:"w-full py-3 text-sm font-medium transition-colors disabled:opacity-40 cursor-not-allowed",style:oe,children:f?"Enter Amount":"Connect Wallet"})})]}),e("div",{className:`flex flex-col transition-all duration-300 ${U?"flex-1 min-w-0":"w-48 shrink-0"}`,style:{backgroundColor:"var(--widget-background)",...U?{height:`${Ke}px`}:{}},children:U?e("div",{className:"flex flex-col overflow-hidden p-2",style:{height:"100%"},children:w==="baseChainSelection"||w==="quoteChainSelection"?e(xe,{toggle:j??be,side:V,onChainSelect:Ye}):e(ve,{toggle:j??be,side:V,otherAsset:Je,onMoreChainsClick:Ze,selectedChainFilter:$e})}):t("div",{className:"flex flex-col gap-3 px-4 py-4",children:[e("span",{className:"text-2xs uppercase tracking-wider font-medium",style:{color:"var(--widget-muted-foreground)"},children:"Quote Details"}),Le&&s&&o?t(q,{children:[t("div",{className:"flex flex-col gap-0.5",children:[e("span",{className:"text-2xs",style:{color:"var(--widget-muted-foreground)"},children:"Rate"}),t("div",{className:"flex items-center gap-1",children:[e(H,{asset:o,size:"3xs",noChain:!0}),t("span",{className:"font-sans text-xs uppercase",children:["1 ",o.symbol]})]}),e("div",{className:"flex items-center gap-1 pl-4",children:t("span",{className:"text-2xs",style:{color:"var(--widget-muted-foreground)"},children:["= ",Z.toFixed(6)]})}),t("div",{className:"flex items-center gap-1 pl-4",children:[e(H,{asset:s,size:"3xs",noChain:!0}),e("span",{className:"font-sans text-xs uppercase",children:s.symbol})]})]}),t("div",{className:"flex flex-col gap-2",style:{borderTop:"1px solid var(--widget-border)",paddingTop:"0.5rem"},children:[t("div",{className:"flex justify-between items-center",children:[e("span",{className:"text-2xs",style:{color:"var(--widget-muted-foreground)"},children:"USD Value"}),t("span",{className:"font-sans text-xs",children:["$",s.price?(s.price*Z*parseFloat(n.toString())).toFixed(2):"\u2014"]})]}),t("div",{className:"flex justify-between items-center",children:[e("span",{className:"text-2xs",style:{color:"var(--widget-muted-foreground)"},children:"Order Type"}),e("span",{className:"text-2xs font-sans",style:{color:"var(--widget-foreground)"},children:"RFQ"})]}),t("div",{className:"flex justify-between items-center",children:[e("span",{className:"text-2xs",style:{color:"var(--widget-muted-foreground)"},children:"Fill"}),e("span",{className:"text-2xs",style:{color:"var(--widget-primary)"},children:"Exact"})]}),s.chainId!==o.chainId&&t("div",{className:"flex justify-between items-center",children:[e("span",{className:"text-2xs",style:{color:"var(--widget-muted-foreground)"},children:"Route"}),e("span",{className:"text-2xs font-sans",children:"Cross-chain"})]})]})]}):_e?t("div",{className:"flex flex-col gap-1",children:[e(ie,{className:"h-6 w-6",style:{color:"var(--widget-destructive)"}}),e("span",{className:"text-2xs",style:{color:"var(--widget-destructive)"},children:"Quote not found"})]}):t("div",{className:"flex flex-col gap-2 mt-2",children:[[...Array(4)].map((a,l)=>e("div",{className:"h-3 rounded animate-pulse",style:{backgroundColor:"var(--widget-muted)",width:l%2===0?"80%":"60%",opacity:.5}},l)),e("span",{className:"text-2xs mt-1",style:{color:"var(--widget-muted-foreground)",opacity:.5},children:"Enter an amount"})]})]})})]})},At=ot;export{At as default};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import{a as xn}from"./chunk-OPN7WCJR.js";import{e as Ne}from"./chunk-7ZT3SGKA.js";import{b as Ae,c as Ut,d as se}from"./chunk-GGP6UREO.js";import{E as De,F as rt,H as qe,I as Et,J as st,N as ge,O as te,P as ee,S as we,T as $t,U as _e,V as K,X as Pt,Y as Me,a as Le,c as B,h as et,k as We,m as Fe,o as ke,q as At,r as re,s as kt,t as tt,v as nt,w as Nt,x as It}from"./chunk-SJMURCHX.js";import{a as he}from"./chunk-46H44R7V.js";import{b as bn}from"./chunk-73CB2I7U.js";import{useQueryClient as Cn}from"@tanstack/react-query";import{useCallback as Sn,useEffect as _t,useRef as Ot}from"react";function Rn(e){if(e.length===0)return 5e3;let c=Math.max(...e.map(o=>B(o)?.blockTimeMs??2e3));return Math.min(5e3,Math.max(1e3,c*2+1e3))}var Tn=()=>{let{address:e}=he(),t=Ut(),n=Cn(),i=Ot(null),c=Ot(!0),o=Sn(a=>{if(!e)return;let f=[...new Set(a.tokens.map(u=>u.asset.chainId))],d=Rn(f);i.current&&(clearTimeout(i.current),i.current=null),i.current=setTimeout(async()=>{if(i.current=null,!!c.current)try{let u=a.tokens.map(m=>({chainId:m.asset.chainId,tokenAddress:m.asset.address})),s=await Et(e,u);if(s.balances.length===0)return;if(a.tokens.length>=2){let m=a.tokens[0].asset,p=a.tokens[1].asset,h=st.swap(e,m.chainId,m.address,p.chainId,p.address);n.setQueryData(h,s)}let r=st.bulk(e,t),S=n.getQueryData(r);if(S){let m=S.balances.map(p=>s.balances.find(x=>x.chainId===p.chainId&&x.token.toLowerCase()===p.token.toLowerCase())??p);for(let p of s.balances)m.some(h=>h.chainId===p.chainId&&h.token.toLowerCase()===p.token.toLowerCase())||m.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=m.findIndex(l=>l.chainId===p.asset.chainId&&l.token.toLowerCase()===p.asset.address.toLowerCase());x!==-1&&(m[x]={...m[x],balance:"0",shiftedBalance:"0"})}n.setQueryData(r,{balances:m})}}catch{}},d)},[e,t,n]);return _t(()=>(c.current=!0,()=>{c.current=!1,i.current&&(clearTimeout(i.current),i.current=null)}),[]),{triggerBalanceUpdate:o}},ot=class extends EventTarget{emit(t){this.dispatchEvent(new CustomEvent("balance-update",{detail:t}))}},at=new ot,Ve=()=>e=>at.emit(e),os=()=>{let{triggerBalanceUpdate:e}=Tn();_t(()=>{let t=n=>{e(n.detail)};return at.addEventListener("balance-update",t),()=>at.removeEventListener("balance-update",t)},[e])};import{createContext as An,useCallback as ie,useContext as kn,useEffect as Mt,useMemo as Nn,useRef as oe,useState as xe}from"react";import{formatUnits as In,parseUnits as En}from"viem";import{jsx as _n}from"react/jsx-runtime";var Wt=An(void 0),Lt=1e4,$n=3e4,Pn=1e3,Un=2;function On(e){return e.find(n=>n.routeSteps?.[0]?.type==="AORI_V1")??e[0]}var fs=({children:e,recipient:t})=>{let{address:n}=he(),i=t||n,[c,o]=xe("idle"),[a,f]=xe("idle"),[d,u]=xe(null),[s,r]=xe(null),[S,m]=xe(!1),[p,h]=xe(!1),[x,l]=xe(!1),v=oe(null),T=oe(null),g=oe(null),U=oe(null),M=oe(null),y=oe(0),k=oe(0),F=oe(0),N=oe(!1),I=oe(new Map),E=ie(()=>{g.current&&clearTimeout(g.current),U.current&&clearTimeout(U.current),M.current&&clearTimeout(M.current),g.current=null,U.current=null,M.current=null},[]),$=ie(()=>{E(),v.current=null,y.current=0,o(()=>N.current?"fresh":"idle")},[E]),_=ie(()=>{$(),T.current=null,u(null),r(null),m(!1),h(!1),l(!1),I.current.clear(),o("idle"),f("idle")},[$]),X=ie(C=>{if(!C)return;U.current&&clearTimeout(U.current);let w=Math.max(0,C+$n-Date.now());U.current=setTimeout(()=>{o(O=>O==="idle"?"idle":"stale")},w)},[]),Z=ie(async(C,w)=>{let{inputToken:O,outputToken:P,inputAmount:G,setOutputAmount:de}=C;if(!O||!P||!G||parseFloat(G)<=0||Date.now()-(k.current||0)<Lt-10)return;let ae=++y.current;try{if(!O?.decimals||!P?.decimals)return;let H=rt(O.chainId)||B(O.chainId)?.key||"",ne=rt(P.chainId)||B(P.chainId)?.key||"";if(!H||!ne)throw new Error("Unknown chain");let pe=En(G.toString(),O.decimals).toString(),fe={srcChainKey:H,dstChainKey:ne,srcTokenAddress:nt(O.address),dstTokenAddress:nt(P.address),amount:pe,srcWalletAddress:n||"0x0000000000000000000000000000000000000000",dstWalletAddress:i||n||"0x0000000000000000000000000000000000000000",options:{amountType:"EXACT_SRC_AMOUNT",feeTolerance:{type:"PERCENT",amount:2}}};k.current=Date.now();let J=await fetch(`${We()}/quotes`,{method:"POST",headers:Fe(),body:JSON.stringify(fe),signal:AbortSignal.timeout(15e3)});if(!J.ok){let V=(await J.json().catch(()=>({})))?.message||J.statusText;throw Object.assign(new Error(V),{status:J.status})}let me=await J.json();if(ae!==y.current||v.current!==w)return;let Pe=me.quotes??[],be=On(Pe);if(!be)throw Object.assign(new Error("No quotes returned"),{emptyQuotes:!0});let Te=Number(In(At(be.dstAmount),P.decimals));typeof de=="function"&&de(Te),be._receivedAt=Date.now(),u(be),r(null),m(!1),o("fresh"),X(be._receivedAt),w&&I.current.delete(w)}catch(H){if(ae!==y.current||v.current!==w)return;let ne=H?.status,pe=H instanceof Error?H.message:"",fe=!!H?.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>=Un){h(!0),E(),v.current=null;return}}if(pe.toLowerCase().includes("order cap exceeded")){l(!0),E(),v.current=null;return}if(pe.toLowerCase().includes("insufficient executor balance")){m(!0),E(),v.current=null;return}r(H instanceof Error?H.message:"Unknown error")}},[n,i,X,E]),L=ie((C,w)=>{E(),T.current=C,k.current=0,I.current.delete(w),m(!1),h(!1),l(!1),r(null),o("polling");let O=async()=>{v.current===w&&(await Z(C,w),v.current===w&&(g.current=setTimeout(O,Lt)))};O()},[E,Z]),A=ie(C=>{if(!C?.inputToken||!C?.outputToken||!C?.inputAmount||parseFloat(C.inputAmount)<=0){$();return}let w=T.current;if(w&&w.inputToken?.address===C.inputToken?.address&&w.inputToken?.chainId===C.inputToken?.chainId&&w.outputToken?.address===C.outputToken?.address&&w.outputToken?.chainId===C.outputToken?.chainId&&w.inputAmount===C.inputAmount&&v.current)return;let P=Date.now();if(P-F.current<100)return;F.current=P;let G=`${Date.now()}-${Math.random().toString(36).slice(2)}`;v.current=G,L(C,G)},[L,$]),W=ie(({amount:C,inputToken:w,outputToken:O,setOutputAmount:P})=>{P(null),M.current&&clearTimeout(M.current),!C||C===0?(f("idle"),$(),u(null),r(null),m(!1),h(!1),l(!1)):(f("typing"),$(),u(null),m(!1),h(!1),l(!1),r(null),M.current=setTimeout(()=>{f("settled"),w&&O&&C>0&&A({inputToken:w,outputToken:O,inputAmount:C.toString(),setOutputAmount:P})},Pn))},[$,A]),q=ie(()=>{let C=T.current;if(!C)return;u(null);let w=`${Date.now()}-${Math.random().toString(36).slice(2)}`;v.current=w,o("refreshing"),typeof C.setOutputAmount=="function"&&C.setOutputAmount(null),L(C,w)},[L]);Mt(()=>{N.current=!!d},[d]),Mt(()=>()=>E(),[E]);let Q=Nn(()=>({status:c,inputState:a,rfqQuote:d,error:s,liquidityError:S,routingError:p,sizeCapError:x,ensureForParams:A,stop:$,refresh:q,clear:_,handleInputChange:W}),[c,a,d,s,S,p,x,A,$,q,_,W]);return _n(Wt.Provider,{value:Q,children:e})},Be=()=>{let e=kn(Wt);if(e===void 0)throw new Error("useRfq must be used within an RfqProvider");return e};import{createContext as Mn,useContext as Ln}from"react";var Wn=Mn({openConnectModal:()=>{}}),hs=()=>Ln(Wn);var Fn={1:.001,42161:5e-5,10:5e-5,8453:5e-5,56:5e-5,143:.001,988:1e-6,9745:1e-5,4326:5e-5,30:5e-6},Dn=1e-4,qn=150000n,Vn=3n,Bn=1n;async function bs(e,t,n){let i=Fn[e]??Dn;try{let c=qe(e),o=await c.getGasPrice(),a=qn,f="fallback";if(t&&n){let S=B(e)?.wrappedAsset?.address;if(S)try{a=await c.estimateGas({account:t,to:S,value:BigInt(n)}),f="simulation"}catch{f="fallback (simulation failed)"}}let d=o*a*Vn/Bn,u=Number(d)/1e18,s=Math.max(u,i);return console.log("[estimateGasBuffer]",{chainId:e,gasPrice:`${Number(o)/1e9} gwei`,gasEstimate:Number(a),estimateSource:f,rawCostETH:u.toFixed(10),minBuffer:i,finalBuffer:s.toFixed(10),usedFloor:s===i}),s}catch(c){return console.warn("[estimateGasBuffer] RPC error, using minBuffer:",i,c),i}}import{useCallback as it,useEffect as Ie,useRef as Qe,useState as ct}from"react";import{jsx as Ee,jsxs as zn}from"react/jsx-runtime";var Qn=20,jn=({side:e,asset:t,otherAsset:n,isPlacingOrder:i,isWrappingPair:c,isUnwrappingPair:o})=>{let{baseAmount:a,quoteAmount:f,setBaseAmount:d,setQuoteAmount:u}=Ne(),{amountInputVariant:s,hideAmountInputSymbol:r,widgetType:S}=Ae(),m=S==="compact",[p,h]=e==="base"?[d,u]:[u,d],x=!t||e==="quote"||i,l=m?32:s==="default"?64:32,[v,T]=ct(l),[g,U]=ct(""),M=Qe(null),y=Qe(null),k=Qe(null),F=Qe(null),N="USD",I=e==="base"?a:f,[E,$]=ct(!1),_=it(()=>{if(s!=="default"){T(l);return}if(!M.current||!y.current||!k.current)return;let L=M.current.offsetWidth,A=20,W=l;for(;W>20&&(y.current.style.fontSize=`${W}px`,k.current.style.fontSize=`${W}px`,!(y.current.offsetWidth+k.current.offsetWidth+A<=L));)W-=1;T(W)},[s,l]),X=it(L=>{L.key==="."&&g.includes(".")&&L.preventDefault()},[g]),Z=it(L=>{let A=L.target.value;if(A==="."&&(A="0."),!/^\d*\.?\d*$/.test(A)||(A.match(/\./g)||[]).length>1)return;if(A.length>1&&A[0]==="0"&&A[1]!=="."&&(A=A.replace(/^0+/,"")||"0"),t?.decimals!==void 0&&A.includes(".")){let[,q]=A.split(".");if(q&&q.length>t.decimals)return}if(A.length>Qn)return;U(A);let W=parseFloat(A);A!==g&&(A===""||A==="0."||A.endsWith(".")?(p(null),e==="base"&&h(null)):!Number.isNaN(W)&&W>=0&&p(W),e==="base"&&u(null),(o||c)&&u(W||0))},[g,p,e,u,t?.decimals,h,o,c]);return Ie(()=>{let L=q=>{if(q===null)return"";let Q=t?.decimals;if(Q===void 0)return"";let C=q.toString();if(/e/i.test(C)&&(C=Number(q).toLocaleString("en-US",{useGrouping:!1,maximumFractionDigits:Q})),C.includes(".")){let[w,O]=C.split("."),P=O.slice(0,Q);return P?`${w}.${P}`:w}return C};if(I===null){g==="0."||g!==""&&g.endsWith(".")||U("");return}if(!x&&(g.endsWith(".")||g.match(/\.\d*0$/)||g==="0"||g==="0.")&&g!=="")return;let W=parseFloat(g)||0;(g===""||Math.abs(W-I)>1e-10)&&U(L(I))},[I,t?.decimals,g,x]),Ie(()=>{_()},[g,_]),Ie(()=>{$(!0)},[]),Ie(()=>{E&&_()},[E,_]),Ie(()=>{y.current&&F.current&&(F.current.style.width=`${y.current.offsetWidth}px`)},[g]),Ie(()=>{if(!E)return;let L=new ResizeObserver(()=>{E&&_()});return M.current&&L.observe(M.current),()=>L.disconnect()},[E,_]),Ee("div",{ref:M,style:{fontSize:`${v}px`,transition:"font-size 0.05s ease-in-out"},className:`mt-2 box-border font-sans flex ${m?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:()=>F.current?.focus(),children:zn("div",{className:"relative flex w-full items-center",children:[Ee("label",{htmlFor:`${e}Amount`,className:"sr-only",children:e==="base"?"Input token amount":"Output token amount"}),Ee("input",{ref:F,type:"text",inputMode:"decimal",placeholder:"0",autoComplete:"off",id:`${e}Amount`,value:g,onWheel:L=>L.target.blur(),onKeyDown:X,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}),Ee("span",{style:{transition:"width 0.15s ease-in-out"},ref:y,className:"pointer-events-none absolute flex whitespace-nowrap invisible",children:g||0}),!r&&s!=="normal"&&Ee("span",{ref:k,className:"ml-2 font-thin uppercase",style:{color:"var(--widget-foreground)",opacity:.5,fontSize:`${v}px`},children:t?.symbol?t.symbol.length>6?`${t.symbol.slice(0,6)}...`:t.symbol:N}),(r||s==="normal")&&Ee("span",{ref:k,className:"hidden"})]})})},As=jn;import{Fragment as lt,jsx as D,jsxs as ce}from"react/jsx-runtime";var Gn=({toggle:e,side:t,asset:n,isPlacingOrder:i,hideDropdown:c})=>{let{baseBalance:o,quoteBalance:a}=Ne(),{tokenDisplay:f,tokenBadgeOrientation:d,widgetType:u}=Ae(),s=u==="compact",r=s?"h-10":"h-13",S=s?"h-10 w-10":"h-13 w-13",m=t==="base"?o.formatted?(()=>{let h=parseFloat(o.formatted);return h>=1e4?ke(h):h.toFixed(4)})():void 0:a.formatted?(()=>{let h=parseFloat(a.formatted);return h>=1e4?ke(h):h.toFixed(4)})():void 0,p={role:"button",tabIndex:i?-1:0,"aria-disabled":i,"aria-label":`Select ${t==="base"?"input":"output"} token${n?`: ${n.symbol}`:""}`,onClick:i?void 0:e,onKeyDown:i?void 0:h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),e())}};return f==="pill"?D("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?ce(lt,{children:[D(ge,{chain:n.chainId,size:"xs"}),D(te,{className:"rounded-full",asset:n,size:"xxs",noChain:!0}),D("span",{className:"text-xs font-thin uppercase",children:n.symbol}),!c&&D(_e,{className:"w-1.5 opacity-60",style:{color:"var(--widget-secondary-foreground)"}})]}):ce(lt,{children:[D("span",{className:"text-xs opacity-70",children:"Select"}),!c&&D(_e,{className:"w-1.5 opacity-60",style:{color:"var(--widget-secondary-foreground)"}})]})}):f==="ghost"?ce("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?ce(lt,{children:[D(ge,{chain:n.chainId,size:"xs"}),D(te,{className:"rounded-full",asset:n,size:"xxs",noChain:!0}),D("span",{className:"text-sm font-thin uppercase",children:n.symbol})]}):D("span",{className:"text-sm",style:{color:"var(--widget-muted-foreground)"},children:"Select token"}),!c&&D(_e,{className:"w-1.5 opacity-50"})]}):D("div",{...p,className:`relative ${r} w-full cursor-pointer text-xl duration-100 ease-linear`,style:{border:"1px solid var(--widget-border)",backgroundColor:"var(--widget-secondary)",borderTopLeftRadius:"9999px",borderBottomLeftRadius:"9999px",borderTopRightRadius:"var(--widget-radius)",borderBottomRightRadius:"var(--widget-radius)"},children:D("div",{className:"relative flex h-full w-full flex-row items-center",children:n?ce("div",{className:"relative flex h-full w-full flex-row items-center",children:[D("div",{className:`${S} pl-px flex items-center justify-center`,children:D(te,{className:"rounded-full",asset:n,size:"lg"})}),ce("div",{className:"flex h-full w-full flex-row items-center justify-between pl-2.5 pr-7",children:[ce("div",{className:"flex h-full flex-col justify-center gap-0.5",children:[D("p",{className:"text-base font-thin uppercase",style:{color:"var(--widget-secondary-foreground)"},children:n.symbol}),ce("span",{className:"text-xs font-sans",style:{color:"var(--widget-muted-foreground)"},children:[n.address?.slice(0,6),"...",n.address?.slice(-4)]})]}),m!==void 0&&ce("div",{className:"flex flex-col text-right",children:[D("p",{className:"text-2xs",style:{color:"var(--widget-muted-foreground)"},children:"Balance"}),D("span",{className:"font-sans text-xs tabular-nums",style:{color:"var(--widget-foreground)",opacity:.5},children:m})]})]}),!c&&D(_e,{className:"absolute right-3 top-1/2 w-1.5 translate-y-[-50%]",style:{color:"var(--widget-secondary-foreground)",opacity:.6}})]}):D("div",{className:"flex h-full w-full items-center justify-center",children:D("span",{className:"text-sm",style:{color:"var(--widget-secondary-foreground)",opacity:.7},children:"Select token"})})})})},Ps=Gn;var Dt=bn(xn(),1);import{useState as je,useEffect as ze}from"react";import{jsx as Y,jsxs as Ft}from"react/jsx-runtime";var Hn=()=>{let[e,t]=je(null),[n,i]=je(""),c=It(n,1e3),[o,a]=je(!1),[f,d]=je("");ze(()=>{se.getState().setRecipient(e)},[e]),ze(()=>{i(e||"")},[e]);let u=r=>{let S=r.target.value;o&&(a(!1),d(""),t(null)),i(S),S===""&&t(null)};ze(()=>{c===""||!c?(a(!1),d(""),t(null)):Nt(c)?(a(!1),d(""),t(c)):(a(!0),d("Invalid wallet address..."),t(null),i(""))},[c]),ze(()=>{if(o){let r=setTimeout(()=>{t(null),i(""),a(!1),d("")},2e3);return()=>clearTimeout(r)}},[o]);let s=()=>{t(null),i(""),a(!1),d("")};return Y("div",{className:"w-full",children:Ft("div",{className:"relative flex flex-row items-center",children:[Y("input",{type:"password",style:{display:"none"},"aria-hidden":"true",tabIndex:-1}),Y("label",{htmlFor:"recipient-address",className:"sr-only",children:"Recipient wallet address"}),Y("div",{className:"absolute left-3 flex h-6 w-6 items-end justify-center overflow-hidden rounded-full",style:{backgroundColor:"var(--widget-secondary)"},children:e&&!o?Y("img",{className:"h-full w-full rounded-full object-cover",src:(0,Dt.makeGradient)(e),alt:"Recipient avatar"}):Y($t,{className:"h-5 w-5",style:{color:o?"var(--widget-destructive)":"var(--widget-muted-foreground)"}})}),Y("div",{className:"absolute left-12 top-1.5 -translate-y-1 text-xs font-medium opacity-60",style:{color:o?"var(--widget-destructive)":"var(--widget-muted-foreground)"},"aria-hidden":"true",children:"To:"}),Y("input",{id:"recipient-address",className:"font-sans block h-10 w-full items-center pl-12 pt-4 pr-8 text-xs",style:{backgroundColor:o?"color-mix(in srgb, var(--widget-destructive) 10%, transparent)":"transparent",color:o?"var(--widget-destructive)":"var(--widget-foreground)",outline:"none",opacity:o?.9:1},placeholder:o?f:"Enter recipient address...",value:n,onChange:u,spellCheck:!1,"aria-invalid":o,"aria-describedby":o?"recipient-error":void 0}),o&&Y("span",{id:"recipient-error",className:"sr-only",children:f}),e&&!o&&Ft("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:[Y("svg",{className:"h-2.5 w-2.5",viewBox:"0 -0.5 21 21",fill:"none",children:Y("g",{fill:"currentColor",fillRule:"evenodd",children:Y("polygon",{points:"375.0183 90 384 98.554 382.48065 100 373.5 91.446 364.5183 100 363 98.554 371.98065 90 363 81.446 364.5183 80 373.5 88.554 382.48065 80 384 81.446",transform:"translate(-363 -80)"})})}),Y("span",{className:"sr-only",children:"Clear recipient"})]})]})})},Fs=Hn;import{jsx as qt,jsxs as Kn}from"react/jsx-runtime";function Vs(e){return Kn("svg",{width:"485",height:"484",viewBox:"0 0 485 484",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[qt("path",{d:"M265.974 52.8127C270.567 50.9299 273.227 53.6338 275.917 56.1595C301.879 80.5364 327.828 104.927 353.786 129.308C380.101 154.024 406.44 178.715 432.721 203.467C436.002 206.557 440.744 209.272 438.226 215.021C435.865 220.415 430.758 219.123 426.424 219.124C305.965 219.169 185.506 219.163 65.0464 219.166C53.0995 219.166 49.0676 215.225 49.0125 203.316C48.9563 191.154 48.9813 178.991 48.9973 166.829C49.0119 155.717 53.3581 151.358 64.4131 151.358C127.892 151.357 191.37 151.364 254.849 151.368C262.591 151.368 262.645 151.344 262.588 143.559C262.388 116.237 262.191 88.914 261.918 61.5922C261.883 58.0834 262.161 54.9042 265.974 52.8127Z",fill:"currentColor"}),qt("path",{d:"M80.5649 300.432C71.3447 291.747 62.4175 283.264 53.4064 274.87C50.4552 272.122 47.8959 269.327 49.7894 264.946C51.6154 260.72 55.4624 260.923 59.1682 260.923C164.476 260.927 269.785 260.932 375.093 260.935C391.422 260.935 407.752 260.9 424.081 260.933C434.679 260.955 438.994 265.286 439.015 275.854C439.04 288.517 439.048 301.181 439.013 313.845C438.985 324.225 434.466 328.73 424.01 328.732C360.359 328.741 296.707 328.729 233.056 328.714C225.392 328.713 225.368 328.686 225.426 336.583C225.628 363.741 225.815 390.9 226.101 418.057C226.142 421.935 225.905 425.512 221.852 427.329C217.686 429.197 214.934 426.578 212.212 424.02C172.068 386.302 131.922 348.587 91.7738 310.874C88.1374 307.459 84.4753 304.07 80.5649 300.432Z",fill:"currentColor"})]})}import{signTypedData as Yn}from"viem/actions";function Bt(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 Vt(e){if(e.chain?.id)return e.chain.id;let t=e.getChainId?.();return t!=null?await t:null}var Xn=async(e,t)=>{try{if(await Vt(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 Vt(e)===t}catch(n){throw Bt(n)?new Error("User rejected the chain switch request"):new Error(`Please switch your wallet to the required network (Chain ID: ${t})`)}},$e=class extends Error{constructor(t){super(t||"Quote expired before submission"),this.name="QuoteStaleError"}},Qt=async e=>{let{quote:t,signatureStep:n,userAddress:i,walletClient:c,validateBeforeSubmit:o}=e;if(!c)throw new Error("Wallet client not available");if(n.type!=="SIGNATURE"||!n.signature?.typedData)throw new Error("Invalid signature step");try{let a=n.signature.typedData,f={...a.message};for(let r of["inputAmount","outputAmount","startTime","endTime"])f[r]!=null&&(f[r]=BigInt(f[r]));let d=a.domain;if(d.chainId!=null){let r=Number(d.chainId);await Xn(c,r)}let u=await Yn(c,{account:i,domain:d,types:a.types,primaryType:a.primaryType,message:f});if(o){let r=o();if(!r.canSubmit)throw new $e(r.reason)}let s=await fetch(`${We()}/submit-signature`,{method:"POST",headers:Fe(),body:JSON.stringify({quoteId:t.id,signatures:[u]})});if(!s.ok){let r=await s.json().catch(()=>({}));throw new Error(r?.message||`Submit failed: ${s.status}`)}return{quoteId:t.id,signature:u}}catch(a){throw a instanceof $e?a:Bt(a)?new Error("User rejected the signing request"):a instanceof Error&&a.message.includes("chain")?new Error("Chain switching failed. Please manually switch to the correct network."):a}};var jt="vt_submitted_quotes";var ut=()=>{try{let e=localStorage.getItem(jt);return e?JSON.parse(e):[]}catch{return[]}},zt=e=>{try{localStorage.setItem(jt,JSON.stringify(e))}catch{}},Zn=e=>{let t=Date.now(),n=typeof e=="string"?new Date(e).getTime():e>9999999999?e:e*1e3;return t<n+3e4},Jn=e=>ut().some(t=>t.quoteId===e),dt=(e,t)=>Jn(e)?{canSubmit:!1,reason:"Order already submitted"}:Zn(t)?{canSubmit:!0}:{canSubmit:!1,reason:"Quote has expired"},Gt=(e,t)=>{let n=typeof t=="string"?new Date(t).getTime():t,i=ut();i.push({quoteId:e,submittedAt:Date.now(),createdAt:n}),zt(i)},Ht=()=>{let e=ut(),t=Date.now(),n=300*1e3,i=e.filter(c=>t-c.submittedAt<n);i.length!==e.length&&zt(i)};import{useMutation as er}from"@tanstack/react-query";import{waitForTransactionReceipt as tr}from"@wagmi/core";import{wethAbi as nr}from"abitype/abis";import{useConfig as rr}from"wagmi";function Kt(){let e=rr();return er({mutationFn:async({chainId:t,accountAddress:n,amountRaw:i,writeContractAsync:c})=>{let o=B(t);if(!o)throw new Error(`No wrapping contract for chain ${t}`);let a=o.wrappedAsset.address,f=await c({abi:nr,functionName:"withdraw",address:a,account:n,args:[i],chainId:t});if((await tr(e,{hash:f,chainId:t,confirmations:1,pollingInterval:4e3})).status!=="success")throw new Error("Unwrap transaction did not get successful receipt");return{success:!0,hash:f}}})}import{useMutation as sr}from"@tanstack/react-query";import{waitForTransactionReceipt as or}from"@wagmi/core";import{wethAbi as ar}from"abitype/abis";import{useConfig as ir}from"wagmi";function Yt(){let e=ir();return sr({mutationFn:async({chainId:t,accountAddress:n,amountRaw:i,writeContractAsync:c})=>{let o=B(t);if(!o)throw new Error(`No wrapping contract for chain ${t}`);let a=o.wrappedAsset.address,f=await c({abi:ar,functionName:"deposit",address:a,account:n,value:i,chainId:t});if((await or(e,{hash:f,chainId:t,confirmations:1,pollingInterval:4e3})).status!=="success")throw new Error("Wrap transaction did not get successful receipt");return{success:!0,hash:f}}})}import{useCallback as ue,useEffect as Re,useRef as hn,useState as jr}from"react";import{useChainId as zr}from"wagmi";import{useEffect as Xt,useState as cr,useCallback as Zt,useRef as pt}from"react";import{useAccount as lr,useChainId as ur,useSwitchChain as dr}from"wagmi";import{jsx as ve,jsxs as ft}from"react/jsx-runtime";var pr=15e3,Ge="chain",fr=({needsChainSwitch:e,requiredChain:t,reviewState:n,goToNextStep:i,cancel:c})=>{let o=re(Ge,n),[a,f]=cr("pending"),d=pt(!1),u=pt(!1),s=pt(null),r=ur(),{switchChainAsync:S}=dr(),{status:m,isReconnecting:p}=lr(),h=Zt(()=>{s.current&&(clearTimeout(s.current),s.current=null)},[]),x=Zt(async()=>{if(!(d.current||u.current||m!=="connected"||p)){d.current=!0,u.current=!0,f("pending"),s.current=setTimeout(()=>{d.current&&(f("error"),d.current=!1)},pr);try{await S({chainId:t.chainId}),h(),f("success"),i(Ge,n)}catch{h(),f("error")}finally{d.current=!1}}},[S,m,p,t.chainId,i,n,h]);Xt(()=>{d.current||u.current||n===Ge&&a==="pending"&&m==="connected"&&!p&&(e&&r!==t.chainId?x():(f("success"),i(Ge,n)))},[n,a,e,r,t.chainId,m,p,x,i]),Xt(()=>()=>h(),[h]);let l=()=>{a==="error"&&(u.current=!1,f("pending"))},v=!o&&a==="error",T=!o&&(a==="pending"||a==="error"),g=v?"var(--widget-status-failed)":"var(--widget-primary)";return ft("div",{className:"flex w-full flex-row justify-between space-x-3",children:[ve("button",{type:"button",className:`inline-flex h-12 w-full items-center justify-center text-sm font-sans font-medium transition duration-150 ${v?"cursor-pointer":"cursor-not-allowed"}`,style:{backgroundColor:`color-mix(in srgb, ${g} 12%, transparent)`,border:`1px solid color-mix(in srgb, ${g} 20%, transparent)`,color:g,borderRadius:"var(--widget-radius)"},onClick:v?l:void 0,children:ft("div",{className:"flex h-10 w-full flex-row items-center space-x-3 px-4",children:[ve(ge,{chain:t.chainId,size:"xs"}),ve("p",{className:"whitespace-nowrap",children:v?"Retry Switch":`Switch to ${t.name}`}),ve("div",{className:"flex flex-1 border-t",style:{borderColor:"var(--widget-border)"}}),ft("div",{className:"flex h-6 w-3 items-center justify-center rounded-full",children:[!o&&a==="pending"&&ve(K,{size:"5"}),(o||a==="success")&&ve(ee,{className:"h-8 w-8"}),v&&ve(we,{className:"h-[12px] w-[12px]"})]})]})}),T&&ve("button",{type:"button",className:"inline-flex h-12 items-center justify-center px-8 text-sm font-sans font-medium transition duration-150 cursor-pointer",style:{backgroundColor:"color-mix(in srgb, var(--widget-status-failed) 12%, transparent)",border:"1px solid color-mix(in srgb, var(--widget-status-failed) 20%, transparent)",color:"var(--widget-status-failed)",borderRadius:"var(--widget-radius)"},onClick:c,children:"Cancel"})]})},Jt=fr;import{waitForTransactionReceipt as gt,getGasPrice as wr}from"@wagmi/core";import{useCallback as He,useEffect as Ke,useState as hr,useRef as sn}from"react";import{erc20Abi as Ye,decodeFunctionData as vr,encodeFunctionData as on,maxUint256 as yr}from"viem";import{useAccount as br,useConfig as xr,useSendTransaction as Cr,useSwitchChain as Sr,useWalletClient as Rr}from"wagmi";import{useEffect as en,useRef as tn,useState as nn}from"react";import{jsx as gr}from"react/jsx-runtime";var mr=({startTime:e,onExpired:t})=>{let[n,i]=nn(30),[c,o]=nn(!1),a=tn(!1),f=tn(t);f.current=t,en(()=>{a.current=!1},[e]),en(()=>{let u=()=>{let r=Date.now(),m=(e>9999999999?e:e*1e3)+30*1e3,p=Math.max(0,m-r),h=Math.floor(p/1e3);if(h<=0){i(0),a.current||(a.current=!0,o(!0),f.current());return}i(h),o(!1)};if(c)return;u();let s=setInterval(u,1e3);return()=>clearInterval(s)},[e,c]);let d=u=>{let s=Math.floor(u/60),r=u%60;return`${s.toString().padStart(2,"0")}:${r.toString().padStart(2,"0")}`};return c?null:gr("span",{className:"text-xs font-sans",children:d(n)})},rn=mr;import{jsx as le,jsxs as mt}from"react/jsx-runtime";function Tr(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 Ar(e,t,n,i,c){let o=e.transaction?.encoded,a=o?.to??e.to,f=o?.data??e.data,d=o?.value??e.value;if(!a)throw new Error('Transaction step missing "to" address');let u=o?.chainId,s=e.chainKey||c,r=u||(s?De(s):void 0);if(!r)throw new Error(`Unknown chain: ${s}`);let S=et()[r],m=await n({account:t,chain:S,to:a,data:f||"0x",value:BigInt(d||"0")});return await gt(i,{hash:m,chainId:r}),m}async function kr(e,t,n,i,c){let o=e.transaction?.encoded,a=o?.to??e.to,f=o?.data??e.data;if(!a||!f)return!1;let d,u;try{let{functionName:T,args:g}=vr({abi:Ye,data:f});if(T!=="approve"||!g||g.length<2)return!1;d=g[0],u=g[1]}catch{return!1}let s=e.chainKey||c.srcChainKey,r=o?.chainId||(s?De(s):void 0);if(!r)return!1;let m=await qe(r).readContract({address:a,abi:Ye,functionName:"allowance",args:[t,d]});if(m>=u)return!0;let p=et()[r],h=await wr(i,{chainId:r}),x={account:t,chain:p,to:a,value:0n,gas:150000n,gasPrice:h};if(m>0n){let T=on({abi:Ye,functionName:"approve",args:[d,0n]}),g=await n({...x,data:T});await gt(i,{hash:g,chainId:r})}let l=on({abi:Ye,functionName:"approve",args:[d,yr]}),v=await n({...x,data:l});return await gt(i,{hash:v,chainId:r}),!0}var Nr=({base:e,baseAmount:t,quote:n,quoteAmount:i,userAddress:c,reviewState:o,goToNextStep:a,cancel:f,isWrappingPair:d,isUnwrappingPair:u,restartSigningFlow:s,onSwapInitiated:r,onOrderSubmitted:S,onSwapSubmitted:m,startPolling:p,trackNativeTransaction:h})=>{let x=re(ye,o),[l,v]=hr("idle"),T=sn(!1),g=sn(null),U=xr(),{isReconnecting:M}=br(),{rfqQuote:y,stop:k,refresh:F}=Be(),{data:N}=Rr({chainId:e.chainId}),{switchChain:I}=Sr(),{sendTransactionAsync:E}=Cr(),$=y?._receivedAt??0,_=He(()=>$?Date.now()>=$+30*1e3:!1,[$]),X=He(async()=>{if(T.current||l!=="idle")return;if(!y?.id||!y?._receivedAt){v("error");return}if(!dt(y.id,y._receivedAt).canSubmit){v("stale");return}T.current=!0;try{if(!N)throw new Error("Wallet client not available");Ht();let w=y.userSteps??[],O;for(let P of w)if(P.type==="TRANSACTION"){v("submitting");let G=P.chainKey||y.srcChainKey,de=G?De(G):void 0;if(de&&N.chain?.id!==de&&(await I({chainId:de}),await new Promise(ae=>setTimeout(ae,800))),await kr(P,c,E,U,y))continue;O=await Ar(P,c,E,U,y.srcChainKey),h(O,P.description||`Tx on ${G}`)}else P.type==="SIGNATURE"&&(v("signing"),await Qt({quote:y,signatureStep:P,userAddress:c,walletClient:N,validateBeforeSubmit:()=>dt(y.id,y._receivedAt)}));Gt(y.id,y._receivedAt),S?.(y.id),p(y.id,{baseToken:e,quoteToken:n}),r?.(),k(),v("success"),a(ye,o),m?.(y.id)}catch(w){if(w instanceof $e){T.current=!1,s?s(!0):v("stale");return}else w instanceof Error&&Tr(w),v("error")}finally{T.current=!1}},[l,y,N,e,n,c,k,p,a,o,m,I,E,r,S,h,U,s]);Ke(()=>{if(o===ye&&k(),x&&l!=="success"){v("success"),a(ye,o);return}if(l==="success"){a(ye,o);return}if(o===ye&&l==="idle"&&!y?.id){v("refreshingQuote"),F();return}if(o===ye&&l==="idle"&&N&&!T.current&&!M){let C=y?.id||null;C&&g.current!==C&&(g.current=C,X())}},[x,o,l,N,M,X,a,y?.id,F,k]),Ke(()=>{l==="refreshingQuote"&&y?.id&&v("idle")},[l,y?.id]),Ke(()=>{o!==ye&&(g.current=null)},[o]),Ke(()=>{let C=setInterval(()=>{_()&&!T.current&&l!=="submitting"&&l!=="success"&&v("stale")},1e3);return()=>clearInterval(C)},[_,l]);let Z=()=>{l==="error"&&!T.current&&(g.current=null,v("idle"))},L=He(()=>{g.current=null,v("refreshingQuote"),F()},[F]),A=He(()=>{s?s(!0):f()},[s,f]),W=()=>l==="error"?"Retry swap":l==="signing"?"Sign Swap Order":l==="submitting"?"Submitting...":l==="refreshingQuote"?"Refreshing Quote...":l==="stale"?"Quote Stale":"Sign & Submit",q=!x&&(l==="error"||l==="stale"),Q=q?"var(--widget-status-failed)":"var(--widget-primary)";return mt("div",{className:"flex w-full flex-row justify-between space-x-3",children:[le("button",{type:"button",className:`inline-flex h-12 w-full items-center justify-center text-sm font-sans font-medium transition duration-150 ${q?"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&&l==="error"?Z:l==="stale"?A:void 0,children:mt("div",{className:"flex h-10 w-full flex-row items-center space-x-3 px-4",children:[le(te,{asset:e,size:"xs",noChain:!0}),le("p",{className:"whitespace-nowrap",children:W()}),le("div",{className:"flex flex-1 border-t",style:{borderColor:"var(--widget-border)"}}),$>0&&l!=="success"&&l!=="error"&&l!=="stale"&&le(rn,{startTime:$,onExpired:()=>v("stale")}),mt("div",{className:"flex h-6 w-3 items-center justify-center rounded-full",children:[!x&&(l==="idle"||l==="signing"||l==="submitting"||l==="refreshingQuote")&&le(K,{size:"5"}),(x||l==="success")&&le(ee,{className:"h-8 w-8"}),!x&&(l==="error"||l==="stale")&&le(we,{className:"h-[12px] w-[12px]"})]})]})}),!x&&(l==="error"||l==="stale")&&le("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:f,children:"Cancel"})]})},an=Nr;import{useEffect as Ir}from"react";import{jsx as j,jsxs as un}from"react/jsx-runtime";var Er=()=>un("svg",{className:"w-3 h-3 shrink-0",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[j("path",{d:"M18 13V19C18 20.1046 17.1046 21 16 21H5C3.89543 21 3 20.1046 3 19V8C3 6.89543 3.89543 6 5 6H11",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),j("path",{d:"M15 3H21V9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),j("path",{d:"M10 14L21 3",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),$r="trackingTx",cn={pending:{icon:j(K,{size:"5"}),buttonText:"Trade Pending",showNewSwap:!1,statusVar:"var(--widget-primary)",clickable:!1},received:{icon:j(K,{size:"5"}),buttonText:"Trade Received",showNewSwap:!1,statusVar:"var(--widget-primary)",clickable:!1},completed:{icon:j(ee,{className:"h-5 w-5"}),buttonText:"View Transaction",showNewSwap:!1,statusVar:"var(--widget-status-completed)",clickable:!0},failed:{icon:j(Me,{}),buttonText:"Retry Swap",showNewSwap:!0,statusVar:"var(--widget-status-failed)",clickable:!0},cancelled:{icon:j(Me,{}),buttonText:"View Transaction",showNewSwap:!1,statusVar:"var(--widget-status-failed)",clickable:!0}},Pr=({orderHash:e,base:t,quote:n,baseAmount:i,quoteAmount:c,reviewState:o,onNewSwap:a,onRetry:f,status:d})=>{let u=re($r,o),s=cn[d]||cn.pending,r=se(p=>p.explorerUrl);Ir(()=>{if(d==="completed"){let p=setTimeout(a,15e3);return()=>clearTimeout(p)}},[d,a]);let S=()=>{d==="failed"?f():(d==="completed"||d==="cancelled")&&r&&window.open(r,"_blank","noopener,noreferrer")},m=s.statusVar;return j("div",{className:"flex flex-row justify-between space-x-3 w-full px-4",children:j("button",{type:"button",className:`inline-flex h-12 w-full items-center justify-center text-sm font-sans font-medium transition duration-150 ${s.clickable?"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:s.clickable?S:void 0,children:un("div",{className:"flex h-10 w-full flex-row items-center space-x-3 px-4",children:[j("div",{className:"flex h-6 w-6 items-center justify-center rounded-full overflow-hidden shrink-0",children:s.icon}),j("p",{className:"whitespace-nowrap",children:s.buttonText}),j("div",{className:"flex flex-1 border-t",style:{borderColor:"var(--widget-border)"}}),s.clickable&&j("div",{className:"flex h-6 w-6 items-center justify-center",children:d==="failed"?j(Pt,{}):j(Er,{})})]})})})},ln=Pr;import{useCallback as dn,useEffect as pn,useState as Ur,useRef as wt}from"react";import{parseUnits as Or}from"viem";import{useAccount as _r,useWriteContract as Mr}from"wagmi";import{jsx as Ce,jsxs as ht}from"react/jsx-runtime";var Lr=15e3,Xe="unwrapping",Wr=({needsToUnwrap:e,amount:t,chainId:n,token:i,reviewState:c,setReviewState:o,goToNextStep:a,cancel:f,delayedClose:d})=>{let u=re(Xe,c),[s,r]=Ur("idle"),S=Kt(),{writeContractAsync:m}=Mr(),{address:p}=he(),h=Ve(),x=wt(!1),l=wt(!1),v=wt(null),{status:T}=_r(),g=dn(()=>{v.current&&(clearTimeout(v.current),v.current=null)},[]),U=dn(async()=>{if(!(x.current||l.current||!p||T!=="connected")){x.current=!0,l.current=!0,r("pending"),v.current=setTimeout(()=>{x.current&&(r("error"),x.current=!1)},Lr);try{let N=B(n);if(!N)throw new Error(`No config for chain ${n}`);let I=N.wrappedAsset.decimals??N.nativeAsset.decimals,E=Or(t.toString(),I);await S.mutateAsync({chainId:n,accountAddress:p,amountRaw:E,writeContractAsync:m});let $={symbol:N.nativeAsset.symbol,name:N.nativeAsset.name,address:Le,decimals:N.nativeAsset.decimals,chainId:n},_={symbol:N.wrappedAsset.symbol,name:N.wrappedAsset.name,address:N.wrappedAsset.address,decimals:N.wrappedAsset.decimals,chainId:n};h({type:"unwrap",tokens:[{asset:$,userAddress:p},{asset:_,userAddress:p}]}),g(),r("success"),a(Xe,c),await d()}catch{g(),r("error")}finally{x.current=!1}}},[p,T,n,t,S,m,h,a,c,d,g]);pn(()=>{x.current||l.current||c===Xe&&s==="idle"&&T==="connected"&&(e?U():(r("success"),a(Xe,c)))},[c,s,e,T,U,a]),pn(()=>()=>g(),[g]);let M=()=>{s==="error"&&(l.current=!1,r("idle"))},y=!u&&s==="error",k=!u&&(s==="pending"||s==="idle"||s==="error"),F=y?"var(--widget-status-failed)":"var(--widget-primary)";return ht("div",{className:"flex w-full flex-row justify-between space-x-3",children:[Ce("button",{type:"button",className:`inline-flex h-12 w-full items-center justify-center text-sm font-sans font-medium transition duration-150 ${y?"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:y?M:void 0,children:ht("div",{className:"flex h-10 w-full flex-row items-center space-x-3 px-4",children:[Ce("p",{className:"whitespace-nowrap",children:y?"Retry Unwrap":i?`Unwrap ${i.symbol}`:"Unwrap Native Token"}),Ce("div",{className:"flex flex-1 border-t",style:{borderColor:"var(--widget-border)"}}),ht("div",{className:"flex h-6 w-3 items-center justify-center rounded-full",children:[!u&&(s==="pending"||s==="idle")&&Ce(K,{size:"5"}),(u||s==="success")&&Ce(ee,{className:"h-8 w-8"}),y&&Ce(we,{className:"h-[12px] w-[12px]"})]})]})}),k&&Ce("button",{type:"button",className:"inline-flex h-12 items-center justify-center px-8 text-sm font-sans font-medium transition duration-150 cursor-pointer",style:{backgroundColor:"color-mix(in srgb, var(--widget-status-failed) 12%, transparent)",border:"1px solid color-mix(in srgb, var(--widget-status-failed) 20%, transparent)",color:"var(--widget-status-failed)",borderRadius:"var(--widget-radius)"},onClick:f,children:"Cancel"})]})},fn=Wr;import{useCallback as mn,useEffect as gn,useState as Fr,useRef as vt}from"react";import{parseUnits as Dr}from"viem";import{useAccount as qr,useWriteContract as Vr}from"wagmi";import{jsx as Se,jsxs as yt}from"react/jsx-runtime";var Br=15e3,Ze="wrapping",Qr=({needsToWrap:e,amount:t,chainId:n,token:i,reviewState:c,setReviewState:o,goToNextStep:a,cancel:f,delayedClose:d,isWrappingPair:u})=>{let s=re(Ze,c),[r,S]=Fr("idle"),m=Yt(),{writeContractAsync:p}=Vr(),{address:h}=he(),x=Ve(),l=vt(!1),v=vt(!1),T=vt(null),{status:g}=qr(),U=mn(()=>{T.current&&(clearTimeout(T.current),T.current=null)},[]),M=mn(async()=>{if(!(l.current||v.current||!h||g!=="connected")){l.current=!0,v.current=!0,S("pending"),T.current=setTimeout(()=>{l.current&&(S("error"),l.current=!1)},Br);try{let I=B(n);if(!I)throw new Error(`No config for chain ${n}`);let E=Dr(t.toString(),I.nativeAsset.decimals);await m.mutateAsync({chainId:n,accountAddress:h,amountRaw:E,writeContractAsync:p});let $={symbol:I.nativeAsset.symbol,name:I.nativeAsset.name,address:Le,decimals:I.nativeAsset.decimals,chainId:n},_={symbol:I.wrappedAsset.symbol,name:I.wrappedAsset.name,address:I.wrappedAsset.address,decimals:I.wrappedAsset.decimals,chainId:n};x({type:"wrap",tokens:[{asset:$,userAddress:h},{asset:_,userAddress:h}]}),U(),S("success"),a(Ze,c),u&&await d()}catch{U(),S("error")}finally{l.current=!1}}},[h,g,n,t,m,p,x,a,c,d,u,U]);gn(()=>{l.current||v.current||c===Ze&&r==="idle"&&g==="connected"&&(e?M():(S("success"),a(Ze,c)))},[c,r,e,g,M,a]),gn(()=>()=>U(),[U]);let y=()=>{r==="error"&&(v.current=!1,S("idle"))},k=!s&&r==="error",F=!s&&(r==="pending"||r==="idle"||r==="error"),N=k?"var(--widget-status-failed)":"var(--widget-primary)";return yt("div",{className:"flex w-full flex-row justify-between space-x-3",children:[Se("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:yt("div",{className:"flex h-10 w-full flex-row items-center space-x-3 px-4",children:[Se("p",{className:"whitespace-nowrap",children:k?"Retry Wrap":i?`Wrap ${i.symbol}`:"Wrap Native Token"}),Se("div",{className:"flex flex-1 border-t",style:{borderColor:"var(--widget-border)"}}),yt("div",{className:"flex h-6 w-3 items-center justify-center rounded-full",children:[!s&&(r==="pending"||r==="idle")&&Se(K,{size:"5"}),(s||r==="success")&&Se(ee,{className:"h-8 w-8"}),k&&Se(we,{className:"h-[12px] w-[12px]"})]})]})}),F&&Se("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:f,children:"Cancel"})]})},wn=Qr;import{jsx as z,jsxs as Gr}from"react/jsx-runtime";var Sa=({base:e,baseAmount:t,quote:n,quoteAmount:i,userAddress:c,isWrappingPair:o,isUnwrappingPair:a,isBaseGasToken:f,isQuoteGasToken:d,reviewActionProps:u,reviewState:s,setReviewState:r,trackedOrderHash:S,setTrackedOrderHash:m,txStatus:p,onSwapSubmitted:h,onSwapInitiated:x,onOrderSubmitted:l,onStaleQuoteRestart:v,setExitHandler:T,setRetryHandler:g,startPolling:U,trackNativeTransaction:M})=>{let{rfqQuote:y,status:k,liquidityError:F,routingError:N,sizeCapError:I,stop:E,clear:$}=Be(),{clearForm:_}=Ne(),X=zr(),{swapButtonVariant:Z,widgetType:L}=Ae(),A=L==="compact",[W,q]=jr(!1),Q=hn(!1),C=hn(null),w=o,O=a,P=!o&&!a,G=X!==e?.chainId&&(w||O||P),de=B(e.chainId),Je={chainId:e.chainId,name:de?.displayName??`Chain ${e.chainId}`},ae=ue((V,Oe)=>{if(Oe!==V)return;if(V==="chain"){if(w){r("wrapping");return}if(O){r("unwrapping");return}r("signingOrder");return}if(V==="signingOrder"){r("trackingTx");return}if(V==="wrapping"){if(!o){r("signingOrder");return}r("wrapSuccess");return}if(V==="unwrapping"){r("wrapSuccess");return}let Tt=kt(V);Tt&&r(Tt)},[r,o,w,O,P]),H=ue(()=>G?"chain":w?"wrapping":O?"unwrapping":P?"signingOrder":null,[G,w,O,P]),ne=ue(()=>{r(null),_()},[_,r]),pe=ue(async()=>{r("wrapSuccess");for(let V=0;V<3;V++)await tt(700);ne()},[ne,r]),fe=ue(async()=>{$(),r("cancelled");for(let V=0;V<3;V++)await tt(500);ne()},[$,ne,r]),J=ue(()=>{S&&(se.getState().stopTracking(),$(),r(null),m(null),_())},[S,$,r,m,_]),me=ue(()=>{r(null),m(null),Q.current=!0,v?.()},[r,m,v]),Pe=ue(()=>{u&&r(H())},[H,u,r]),be=ue((V=!1)=>{V?(Q.current=!0,r(null),v?.()):(r(null),C.current=setTimeout(()=>{u&&(r(H()),q(!1))},100))},[r,u,H,v]);Re(()=>{s!==null&&E()},[s,E]),Re(()=>{s!==null&&W&&q(!1)},[s,W]),Re(()=>{T?.(J)},[T,J]),Re(()=>(se.getState().setExitHandler(J),()=>se.getState().setExitHandler(null)),[J]),Re(()=>{g?.(me)},[g,me]),Re(()=>()=>{C.current&&clearTimeout(C.current)},[]),Re(()=>{Q.current&&k==="fresh"&&y?.id&&(Q.current=!1,r("signingOrder"))},[k,y?.id,r]);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)"}}},Ue=`w-full ${A?"py-2":"py-3"} text-sm font-sans font-medium transition-colors cursor-pointer mt-1`;if(s===null&&!o&&!a){if(W)return z("button",{className:Ue,disabled:!0,style:{...Te(!1),opacity:.6,cursor:"not-allowed"},children:"Getting fresh quote..."});let V=()=>F?"Insufficient Liquidity":N?"Route Not Available":I?"Size Cap Exceeded":!y&&k==="polling"?"Getting Quote...":y?"Swap":"Enter Amount",Oe=!!u;return z("button",{onClick:Oe?Pe:void 0,disabled:!Oe,className:`${Ue} disabled:opacity-40 disabled:cursor-not-allowed`,style:Te(Oe),children:V()})}return s===null&&a?z("button",{onClick:u?Pe:void 0,disabled:!u,className:`${Ue} disabled:opacity-40 disabled:cursor-not-allowed`,style:Te(!!u),children:"Unwrap"}):s===null&&o?z("button",{onClick:u?Pe:void 0,disabled:!u,className:`${Ue} disabled:opacity-40 disabled:cursor-not-allowed`,style:Te(!!u),children:"Wrap"}):s==="success"?z("div",{className:"flex flex-col gap-2 w-full",children:z("button",{className:`w-full ${A?"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"?z("div",{className:"flex flex-col gap-2 w-full",children:z("button",{className:`w-full ${A?"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:o?"Wrapped Successfully":"Unwrapped Successfully"})}):s==="cancelled"?z("div",{className:"flex flex-col gap-2 w-full",children:z("button",{onClick:ne,className:`w-full ${A?"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"})}):Gr("div",{className:"flex w-full",children:[s==="chain"&&G&&z(Jt,{requiredChain:Je,needsChainSwitch:G&&X!==e.chainId,reviewState:s,goToNextStep:ae,cancel:fe}),s==="wrapping"&&w&&z(wn,{needsToWrap:w,amount:t,chainId:e.chainId,token:e,reviewState:s,setReviewState:r,goToNextStep:ae,cancel:fe,delayedClose:pe,isWrappingPair:o}),s==="unwrapping"&&O&&z(fn,{needsToUnwrap:O,amount:t,chainId:e.chainId,token:e,reviewState:s,setReviewState:r,goToNextStep:ae,cancel:fe,delayedClose:pe}),s==="signingOrder"&&P&&z(an,{base:e,baseAmount:t,quote:n,quoteAmount:i,userAddress:c,reviewState:s,goToNextStep:ae,cancel:fe,restartSigningFlow:be,onSwapInitiated:x,onOrderSubmitted:l,isWrappingPair:o,isUnwrappingPair:a,onSwapSubmitted:h,startPolling:U,trackNativeTransaction:M}),s==="trackingTx"&&S&&z(ln,{orderHash:S,base:e,quote:n,baseAmount:t,quoteAmount:i,reviewState:s,status:p,onNewSwap:J,onRetry:me}),s&&!["chain","wrapping","unwrapping","approval","signingOrder","trackingTx","success","wrapSuccess","cancelled"].includes(s)&&z("button",{disabled:!0,className:`w-full ${A?"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 bt(e){try{let t=new URL(e).pathname.split("/"),n=t[t.length-1];return n&&n.startsWith("0x")?n:null}catch{return null}}import{useState as xt,useCallback as Hr,useRef as Ct,useEffect as St}from"react";import{useShallow as Kr}from"zustand/react/shallow";import{jsx as b,jsxs as R}from"react/jsx-runtime";var vn={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)"},Yr=({status:e})=>{let t=vn[e]??vn.pending;switch(e){case"completed":return b(ee,{className:"h-6 w-6"});case"failed":case"cancelled":return b(Me,{className:"h-6 w-6"});default:return b(K,{size:"5",color:t})}};function Xr(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 yn(e){let t=e.length;return t<=4?48:t<=6?40:t<=8?34:28}var Rt=()=>R("svg",{className:"w-3 h-3 shrink-0",style:{color:"var(--widget-secondary-foreground)"},viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[b("path",{d:"M18 13V19C18 20.1046 17.1046 21 16 21H5C3.89543 21 3 20.1046 3 19V8C3 6.89543 3.89543 6 5 6H11",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),b("path",{d:"M15 3H21V9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),b("path",{d:"M10 14L21 3",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),Zr=()=>R("svg",{className:"w-3 h-3 shrink-0",viewBox:"0 0 195 321",fill:"var(--widget-secondary-foreground)",xmlns:"http://www.w3.org/2000/svg",children:[b("path",{fillRule:"evenodd",d:"M195,189C195,207.02,195,225.04,194.7,243.21C193.68,244.78,192.9,246.17,192.25,247.63C189.71,253.38,187.74,259.46,184.6,264.86C169.44,290.97,147.86,309.46,118.54,318.86C116.44,319.55,114.72,320.27,113,321C97.65,321,82.29,321,66.36,320.66C64.21,319.86,62.64,319.4,60.77,318.73C34.51,310.12,15.56,293.82,4.22,268.85C3.68,267.66,2.1,266.94,1,266C1,242.31,1,218.62,1.29,194.79C2.84,192.16,4.11,189.7,5.34,187.22C18.42,160.94,39.89,144.07,66.64,133.63C76.92,129.62,87.87,127.33,98.67,124.2C97.79,123.24,96.8,121.93,95.59,120.86C85.84,112.3,75.95,103.89,66.3,95.21C55.93,85.86,45.02,76.96,35.71,66.63C21.14,50.5,20.04,23.08,45.41,9.57C50.08,7.08,55.12,5.26,59.93,3.03C60.76,2.64,61.32,1.69,62,1C86.69,1,111.38,1,136.23,1.32C138.04,2.32,139.67,3.01,141.32,3.67C147.64,6.19,154.12,8.39,160.26,11.32C166.83,14.45,172.19,19.18,175.44,25.95C179.39,34.19,178.09,43.36,172.05,49.56C165.75,56.03,157.21,57.8,148.78,52.89C142.4,49.17,136.86,43.96,131.1,39.23C122.63,32.28,115.05,23.88,105.74,18.38C87.78,7.76,68.84,9.07,51.16,19.53C38.68,26.91,36.37,41.4,45.53,52.71C50.38,58.69,56.45,64,62.83,68.36C87.15,84.99,111.86,101.05,136.34,117.44C162.56,135,183.88,156.57,193.26,187.79C193.42,188.32,194.4,188.6,195,189ZM77.06,146.49C61.39,155.71,51.27,169.26,45.93,186.5C39.48,207.32,39.44,228.5,42.93,249.76C45.84,267.48,53.16,282.95,66.59,295.39C83.82,311.34,108.85,312.86,127.37,298.41C138.98,289.35,146.05,277.03,149.48,263.04C161.53,213.92,148.4,171.97,112.16,137.05C111.13,136.06,108.71,135.6,107.31,136.05C97.38,139.22,87.54,142.7,77.06,146.49Z"}),b("path",{d:"M118.83,199C121.61,197.69,122.77,198.41,122.77,201.27C122.71,217.43,122.78,233.58,122.65,249.73C122.65,250.83,121.43,251.92,120.77,253.01C119.97,252.05,118.63,251.17,118.45,250.1C116.32,237.7,113.36,235.12,100.61,235.02C98.12,235,95.62,234.98,93.12,235.01C81.26,235.16,77.72,238.3,75.94,249.84C75.74,251.15,74.39,252.28,73.57,253.49C73.11,253.23,72.64,252.98,72.17,252.73C72.17,234.81,72.17,216.88,72.17,198.96C72.49,198.62,72.81,198.28,73.13,197.93C74.09,198.95,75.72,199.85,75.92,201C78.13,213.8,80.95,216.26,94.05,216.3C97.38,216.31,100.72,216.44,104.04,216.27C113.28,215.79,117.15,212.05,118.22,202.81C118.35,201.65,118.47,200.49,118.83,199Z"})]}),Jr=({orderHash:e,base:t,quote:n,baseAmount:i,quoteAmount:c,status:o})=>{let[a,f]=xt(!1),[d,u]=xt(!0),s=Ct(null),r=Ct(Date.now()),[S,m]=xt(null),p=Ct(null),{isRecipientInputOpen:h,recipient:x,explorerUrl:l}=se(Kr(w=>({isRecipientInputOpen:w.isRecipientInputOpen,recipient:w.recipient,explorerUrl:w.explorerUrl})));St(()=>{o==="received"&&(s.current=Date.now())},[o]),St(()=>{if(o==="completed"&&!S){let w=s.current||r.current;m((Date.now()-w)/1e3)}},[o,S]),St(()=>()=>{p.current&&clearTimeout(p.current)},[]);let v=Hr(()=>{if(!navigator.clipboard?.writeText)return;let w=l?bt(l)??e:e;navigator.clipboard.writeText(w).then(()=>{f(!0),p.current&&clearTimeout(p.current),p.current=setTimeout(()=>f(!1),2e3)}).catch(()=>{})},[e,l]),T=ke(i),g=ke(c),U=o==="completed"||o==="failed"||o==="cancelled",M=!U,y=i&&c?i/c:0,k=y>0&&y<1,F=k?1/y:y,N=k?t:n,I=k?n:t,E=t?.price?`\u2248 $${(k?t.price:t.price*y).toFixed(2)}`:"",$=B(t.chainId),_=B(n.chainId),X=$?.displayName??`Chain ${t.chainId}`,Z=_?.displayName??`Chain ${n.chainId}`,L=t.chainId!==n.chainId,A=$?.estimatedTimeMs??0,W=_?.estimatedTimeMs??0,q=(L?A+W:A)/1e3,Q=l?bt(l)??e:e,C=`${Q.slice(0,6)} \u2026 ${Q.slice(-4)}`;return R("div",{className:"relative w-full flex flex-col",children:[R("div",{className:"mx-4 mt-2",style:{backgroundColor:"var(--widget-secondary)"},children:[b("div",{className:"p-5",children:R("div",{className:"flex items-center justify-between",children:[R("div",{children:[R("div",{className:"flex items-center gap-3 mb-3",children:[b(te,{asset:t,size:"md",noChain:!0}),R("div",{children:[b("p",{className:"text-xl font-thin uppercase",style:{color:"var(--widget-foreground)"},children:t.symbol}),b("p",{className:"text-xs",style:{color:"var(--widget-muted-foreground)"},children:t.name})]})]}),R("div",{className:"inline-flex items-center gap-1.5 rounded-full px-2.5 py-1",style:{backgroundColor:"color-mix(in srgb, var(--widget-muted-foreground) 20%, transparent)",border:"1px solid color-mix(in srgb, var(--widget-muted-foreground) 30%, transparent)"},children:[b(ge,{chain:t.chainId,size:"xs"}),b("span",{className:"text-xs pt-0.5",style:{color:"var(--widget-muted-foreground)"},children:X})]})]}),R("div",{className:"text-right",children:[b("p",{className:"font-thin tracking-tight font-sans",style:{color:"var(--widget-foreground)",fontSize:`${yn(T)}px`,transition:"font-size 0.1s ease-out"},children:T}),t.price&&R("p",{className:"text-xs mt-1 font-sans",style:{color:"var(--widget-muted-foreground)"},children:["$",(t.price*i).toFixed(2)]})]})]})}),R("div",{className:"relative",children:[b("div",{style:{borderTop:"1px solid var(--widget-border)"}}),b("div",{className:"absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2",children:b("div",{className:"w-10 h-10 rounded-full flex items-center justify-center",style:{backgroundColor:"var(--widget-secondary)",border:"1px solid var(--widget-border)"},children:b(Yr,{status:o})})})]}),b("div",{className:"p-5",children:R("div",{className:"flex items-center justify-between",children:[R("div",{children:[R("div",{className:"flex items-center gap-3 mb-3",children:[b(te,{asset:n,size:"md",noChain:!0}),R("div",{children:[b("p",{className:"text-xl font-thin uppercase",style:{color:"var(--widget-foreground)"},children:n.symbol}),b("p",{className:"text-xs",style:{color:"var(--widget-muted-foreground)"},children:n.name})]})]}),R("div",{className:"inline-flex items-center gap-1.5 rounded-full px-2.5 py-1",style:{backgroundColor:"color-mix(in srgb, var(--widget-muted-foreground) 20%, transparent)",border:"1px solid color-mix(in srgb, var(--widget-muted-foreground) 30%, transparent)"},children:[b(ge,{chain:n.chainId,size:"xs"}),b("span",{className:"text-xs pt-0.5",style:{color:"var(--widget-muted-foreground)"},children:Z})]})]}),R("div",{className:"text-right",children:[b("p",{className:"font-thin tracking-tight font-sans",style:{color:"var(--widget-foreground)",fontSize:`${yn(g)}px`,transition:"font-size 0.1s ease-out"},children:g}),n.price&&R("p",{className:"text-xs mt-1 font-sans",style:{color:"var(--widget-muted-foreground)"},children:["$",(n.price*c).toFixed(2)]})]})]})})]}),h&&x&&b("div",{className:"mx-4 mt-2 px-5 pb-2",children:R("div",{className:"flex items-center gap-2 p-2 rounded-full",style:{backgroundColor:"var(--widget-secondary)"},children:[b("div",{className:"flex h-5 w-5 items-center justify-center overflow-hidden rounded-full",style:{backgroundColor:"var(--widget-muted)"},children:b("span",{className:"text-2xs",children:"\u{1F464}"})}),b("span",{className:"text-xs",style:{color:"var(--widget-muted-foreground)"},children:"To:"}),R("span",{className:"text-xs font-sans",style:{color:"var(--widget-foreground)"},children:[x.slice(0,6),"...",x.slice(-4)]})]})}),R("div",{className:"px-4 mt-4",style:{borderTop:"1px solid var(--widget-border)",borderBottom:"1px solid var(--widget-border)"},children:[b("div",{className:"relative box-border flex flex-row h-8 w-full items-center cursor-pointer",role:"button",tabIndex:0,onClick:()=>u(!d),onKeyDown:w=>{(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),u(!d))},children:b("div",{className:"flex h-full items-center w-full overflow-hidden",style:{color:"var(--widget-muted-foreground)"},children:R("div",{className:"translate-y-px font-sans flex w-full flex-row items-center justify-between",children:[R("div",{className:"flex flex-row items-center gap-2 whitespace-nowrap",children:[R("div",{className:"flex flex-row items-center gap-1",children:[b(te,{asset:N,size:"3xs",noChain:!0,className:"mb-0.5"}),R("span",{className:"text-xs uppercase",style:{color:"var(--widget-muted-foreground)"},children:["1 ",N.symbol]})]}),b("span",{className:"text-xs",style:{color:"var(--widget-muted-foreground)"},children:"="}),R("div",{className:"flex flex-row items-center gap-1",children:[b(te,{asset:I,size:"3xs",noChain:!0,className:"mb-0.5"}),R("span",{className:"text-xs uppercase",style:{color:"var(--widget-muted-foreground)"},children:[Xr(F)," ",I.symbol]})]}),b("span",{className:"text-xs",style:{color:"var(--widget-muted-foreground)"},children:E})]}),b("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"})]})})}),b("div",{className:"overflow-hidden transition-all duration-200",style:{maxHeight:d?"200px":"0px",opacity:d?1:0},children:R("div",{className:"flex flex-col gap-1 pb-1.5 font-sans",children:[R("div",{className:"flex justify-between text-2xs",style:{color:"var(--widget-muted-foreground)"},children:[b("span",{children:"USD Value"}),R("span",{style:{color:"var(--widget-secondary-foreground)"},children:["$",t.price?(t.price*i).toFixed(2):"\u2014"]})]}),R("div",{className:"flex justify-between text-2xs",style:{color:"var(--widget-muted-foreground)"},children:[b("span",{style:{color:"var(--widget-muted-foreground)"},children:"Order Type"}),b("span",{style:{color:"var(--widget-secondary-foreground)"},children:"RFQ (Limit)"})]}),R("div",{className:"flex justify-between items-center text-2xs",style:{color:"var(--widget-muted-foreground)"},children:[b("span",{children:"Transaction"}),l?R("a",{href:l,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 transition-colors hover:opacity-80",style:{color:"var(--widget-secondary-foreground)"},children:[b("span",{children:a?"Copied!":C}),b(Rt,{})]}):R("button",{type:"button",onClick:v,className:"flex items-center gap-1 cursor-pointer transition-colors",style:{color:"var(--widget-secondary-foreground)"},children:[b("span",{style:{color:"var(--widget-secondary-foreground)"},children:a?"Copied!":C}),b(Rt,{})]})]}),R("div",{className:"flex justify-between text-2xs",style:{color:"var(--widget-muted-foreground)"},children:[b("span",{children:U?"Speed":"Est. Time"}),b("span",{style:{color:"var(--widget-secondary-foreground)"},children:S?`${S.toFixed(2)}s`:q>0?`~${q}s`:"\u2014"})]}),R("div",{className:"flex justify-between items-center text-2xs",style:{color:"var(--widget-muted-foreground)"},children:[b("span",{children:"Route"}),R("a",{href:"https://www.aori.io",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 transition-colors hover:opacity-80",style:{color:"var(--widget-secondary-foreground)"},children:[b(Zr,{}),"Aori",b(Rt,{})]})]})]})})]})]})},Ua=Jr;export{Tn as a,Ve as b,os as c,bt as d,fs as e,Be as f,Wn as g,hs as h,bs as i,As as j,Ps as k,Fs as l,Vs as m,Xn as n,Qt as o,Zn as p,dt as q,Gt as r,Ht as s,Kt as t,Yt as u,Sa as v,Ua as w};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{f as F}from"./chunk-
|
|
2
|
+
import{f as F}from"./chunk-62ZNAMP7.js";import{e as _}from"./chunk-7ZT3SGKA.js";import{b as k}from"./chunk-GGP6UREO.js";import{O as u,W as m,c as g}from"./chunk-SJMURCHX.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};
|