@aori/mega-swap-widget 0.1.11 → 0.1.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/dist/AssetSelectionMenu-F2JUPXHM.js +2 -0
  2. package/dist/AssetSelectionMenu-U7S42AGB.cjs +2 -0
  3. package/dist/ChainSelectionMenu-BGZDH2WA.js +2 -0
  4. package/dist/ChainSelectionMenu-QGLWZEIZ.cjs +2 -0
  5. package/dist/SwapFormHorizontal-MEYPUSEU.js +2 -0
  6. package/dist/SwapFormHorizontal-QI3GS2BO.cjs +2 -0
  7. package/dist/SwapFormSplit-7VZ7IIJR.js +2 -0
  8. package/dist/SwapFormSplit-LI3MH5YB.cjs +2 -0
  9. package/dist/{WidgetWalletPanel-VUT4LF65.js → WidgetWalletPanel-7L7E7IA5.js} +1 -1
  10. package/dist/{WidgetWalletPanel-HH26O3HT.cjs → WidgetWalletPanel-B3VZ6AIJ.cjs} +1 -1
  11. package/dist/WidgetWalletTradeHistory-AQOIIO2U.cjs +2 -0
  12. package/dist/WidgetWalletTradeHistory-ES3FEDM7.js +2 -0
  13. package/dist/{chunk-D7GULMHE.cjs → chunk-3PGCHNG2.cjs} +1 -1
  14. package/dist/{chunk-K3RTTHBS.cjs → chunk-4S3B2JQY.cjs} +3 -3
  15. package/dist/{chunk-LSB5IXLW.js → chunk-6BEXSHIC.js} +1 -1
  16. package/dist/chunk-E7O7PKZA.cjs +2 -0
  17. package/dist/{chunk-YO5D6L5W.js → chunk-FWH744XA.js} +1 -1
  18. package/dist/chunk-GF37SKBJ.js +2 -0
  19. package/dist/{chunk-TWVI6PZS.cjs → chunk-GIDTBDDC.cjs} +1 -1
  20. package/dist/{chunk-PSCWQFVY.cjs → chunk-GK3MOEYU.cjs} +1 -1
  21. package/dist/chunk-HFX3K3RG.cjs +2 -0
  22. package/dist/{chunk-UR3Q7FG5.js → chunk-MJMI6IZW.js} +1 -1
  23. package/dist/chunk-MVF5PRDZ.js +2 -0
  24. package/dist/{chunk-WZCWYOCN.cjs → chunk-N2SES3FP.cjs} +1 -1
  25. package/dist/{chunk-QAOZRRSH.js → chunk-NNNQNB5T.js} +5 -5
  26. package/dist/{chunk-UHG7ZIWD.js → chunk-PFQ7GSLH.js} +1 -1
  27. package/dist/{chunk-EKSQTNKS.cjs → chunk-R36QQMHJ.cjs} +1 -1
  28. package/dist/{chunk-CNE67IQ3.cjs → chunk-TLVNPEBL.cjs} +1 -1
  29. package/dist/{chunk-IKTTT66M.js → chunk-W63DXT5E.js} +1 -1
  30. package/dist/{chunk-GPT4NHM5.js → chunk-XCPMBMS7.js} +1 -1
  31. package/dist/index.cjs +2 -2
  32. package/dist/index.d.cts +1 -2
  33. package/dist/index.d.ts +1 -2
  34. package/dist/index.js +2 -2
  35. package/package.json +1 -1
  36. package/dist/AssetSelectionMenu-CYWW5K6R.js +0 -2
  37. package/dist/AssetSelectionMenu-TPSIEBBB.cjs +0 -2
  38. package/dist/ChainSelectionMenu-HFJGI6E5.js +0 -2
  39. package/dist/ChainSelectionMenu-UNMEPKRI.cjs +0 -2
  40. package/dist/SwapFormHorizontal-4OU37V6U.js +0 -2
  41. package/dist/SwapFormHorizontal-WBAPDDJF.cjs +0 -2
  42. package/dist/SwapFormSplit-I2HXRXPP.cjs +0 -2
  43. package/dist/SwapFormSplit-UGIUUA5V.js +0 -2
  44. package/dist/WidgetWalletTradeHistory-NL23HIOJ.cjs +0 -2
  45. package/dist/WidgetWalletTradeHistory-VAH2FU7S.js +0 -2
  46. package/dist/chunk-2VOK7L7P.js +0 -2
  47. package/dist/chunk-46JMXEHJ.cjs +0 -2
  48. package/dist/chunk-XTJC3IX6.cjs +0 -2
  49. package/dist/chunk-YIRIKYAW.js +0 -2
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import{B as E,E as N,O as A,o as R,p as W}from"./chunk-QAOZRRSH.js";import{a as S}from"./chunk-46H44R7V.js";import{useCallback as se,useRef as oe,useState as ne}from"react";import{useCallback as M,useEffect as Q,useMemo as Z,useRef as z,useState as w}from"react";var O="https://api.aori.io",b=50,G=100,D="0xFAfDdbb3FC7688494971a79cc65DCa3EF82079E7",U="megaeth";function K(e,s){let o=N(e.inputChain),r=N(e.outputChain),u=o?s(o,e.inputToken)??null:null,c=r?s(r,e.outputToken)??null:null;return{orderHash:e.orderHash,quoteId:e.orderHash,status:e.status.toLowerCase(),eventType:e.status.toLowerCase(),inputToken:e.inputToken,inputAmount:e.inputAmount,inputChain:e.inputChain,outputToken:e.outputToken,outputAmount:e.outputAmount,outputChain:e.outputChain,timestamp:e.timestamp,createdAt:e.startTime,srcTx:e.srcTx,dstTx:e.dstTx,explorerUrl:`https://aoriscan.io/order/${e.orderHash}`,enrichedTokens:{base:u,quote:c}}}function P(e,s){let{getToken:o}=E(),[r,u]=w([]),[c,f]=w(!1),[p,h]=w(null),[d,m]=w(b),n=z(null),i=M(async()=>{if(!e)return;n.current?.abort();let g=new AbortController;n.current=g,f(!0),h(null);try{let y={offerer:e,limit:String(G),page:"0"},[L,I]=await Promise.all([fetch(`${O}/data/query?${new URLSearchParams({...y,inputChain:U,inputToken:D})}`,{signal:g.signal}),fetch(`${O}/data/query?${new URLSearchParams({...y,outputChain:U,outputToken:D})}`,{signal:g.signal})]),_=L?.ok?await L.json():null,$=I?.ok?await I.json():null,H=new Set,C=[];for(let x of[..._?.orders??[],...$?.orders??[]])H.has(x.orderHash)||(H.add(x.orderHash),C.push(x));C.sort((x,V)=>V.timestamp-x.timestamp),u(C),m(b)}catch(y){if(y?.name==="AbortError")return;h(y?.message??"Failed to load order history")}finally{g.signal.aborted||f(!1)}},[e]);Q(()=>{if(!s||!e){u([]),m(b);return}return i(),()=>n.current?.abort()},[s,e,i]);let v=d<r.length,q=M(async()=>{v&&m(g=>Math.min(g+b,r.length))},[v,r.length]);return{orders:Z(()=>r.slice(0,d).map(g=>K(g,o)),[r,d,o]),isLoading:c,error:p,hasMore:v,loadMore:q,totalOrders:r.length}}import{useState as X}from"react";import{jsx as t,jsxs as l}from"react/jsx-runtime";var J=()=>l("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:[t("circle",{cx:"5",cy:"5",r:"4",stroke:"currentColor",strokeWidth:"1.2"}),t("path",{d:"M3 5.2L4.3 6.5L7 3.5",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})]}),Y=()=>l("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:[t("circle",{cx:"5",cy:"5",r:"4",stroke:"currentColor",strokeWidth:"1.2"}),t("path",{d:"M3.5 3.5L6.5 6.5M6.5 3.5L3.5 6.5",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round"})]}),ee=()=>l("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:[t("circle",{cx:"5",cy:"5",r:"4",stroke:"currentColor",strokeWidth:"1.2"}),t("path",{d:"M5 3V5.5L6.5 6.5",stroke:"currentColor",strokeWidth:"1",strokeLinecap:"round"})]}),F=()=>l("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:[t("circle",{cx:"5",cy:"5",r:"4",stroke:"currentColor",strokeWidth:"1.2"}),t("circle",{cx:"5",cy:"5",r:"1.5",fill:"currentColor"})]}),te=e=>{switch((e||"").toLowerCase()){case"completed":case"settled":case"success":case"swapped":case"swap":return{icon:t(J,{}),color:"var(--widget-primary)"};case"received":return{icon:t(F,{}),color:"var(--widget-accent)"};case"failed":case"error":case"expired":return{icon:t(Y,{}),color:"var(--widget-destructive)"};case"pending":case"created":case"placed":return{icon:t(ee,{}),color:"var(--widget-muted-foreground)"};default:return{icon:t(F,{}),color:"var(--widget-muted-foreground)"}}},re=e=>{switch((e||"").toLowerCase()){case"completed":case"settled":case"success":case"swapped":case"swap":return"color-mix(in srgb, var(--widget-primary) 5%, transparent)";case"failed":case"error":case"expired":return"color-mix(in srgb, var(--widget-destructive) 5%, transparent)";case"pending":case"created":case"placed":return"color-mix(in srgb, var(--widget-accent) 5%, transparent)";default:return"var(--widget-secondary)"}},k=(e,s)=>{try{let o=parseFloat(e||"0");if(isNaN(o)||o===0)return"0";let r=s?.decimals??18;return R(o/10**r)}catch{return"0"}},B=({order:e,baseToken:s,quoteToken:o})=>{let[r,u]=X(!1),c=e?.status||e?.eventType||"unknown",{icon:f,color:p}=te(c),d=(i=>{if(!i)return{date:"",time:""};let v=new Date(typeof i=="number"?i:Number(i)||i);return{date:v.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),time:v.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",timeZone:"UTC",hour12:!1})+" UTC"}})(e?.timestamp||e?.createdAt||""),m=s?{asset:s,symbol:s.symbol,amount:k(e?.inputAmount,s)}:{asset:null,symbol:(e?.inputToken||"").slice(0,6)+"...",amount:k(e?.inputAmount,null)},n=o?{asset:o,symbol:o.symbol,amount:k(e?.outputAmount,o)}:{asset:null,symbol:(e?.outputToken||"").slice(0,6)+"...",amount:k(e?.outputAmount,null)};return l("a",{href:e?.explorerUrl||"#",target:"_blank",rel:"noopener noreferrer",className:"group flex flex-col cursor-pointer transition-all duration-200 ease-in-out no-underline",style:{border:"1px var(--widget-border-style) var(--widget-border)",backgroundColor:r?re(c):"transparent",marginBottom:"0.5rem",padding:"0.25rem"},onMouseEnter:()=>u(!0),onMouseLeave:()=>u(!1),children:[l("div",{className:"flex flex-row items-center justify-between space-x-1",children:[l("div",{className:"flex flex-row items-center space-x-1",children:[t("div",{className:"-translate-y-px",style:{color:p},children:f}),t("p",{className:"text-2xs font-sans uppercase",style:{color:p},children:c})]}),l("div",{className:"flex flex-row items-center space-x-2",children:[l("span",{className:"text-2xs font-sans",style:{color:r?"var(--widget-foreground)":"var(--widget-muted-foreground)"},children:["\xAC ",W(e?.quoteId||e?.orderHash||"")]}),t("svg",{className:"w-2.5 -translate-y-px opacity-70 group-hover:rotate-[-45deg] group-hover:opacity-100 duration-200",style:{color:"var(--widget-foreground)"},viewBox:"0 0 684 684",fill:"none",children:t("path",{d:"M0.666687 384.667L519.92 384.667L281.627 622.96L342 683.333L683.333 342L342 0.666687L281.627 61.04L519.92 299.333L0.666687 299.333V384.667Z",fill:"currentColor"})})]})]}),l("div",{className:"flex flex-row items-center justify-between pr-2",style:{backgroundColor:r?"transparent":"var(--widget-secondary)"},children:[t("div",{className:"flex flex-col w-full h-full p-2",children:t("div",{className:"flex h-8 w-full items-center justify-between px-2",children:l("div",{className:"flex items-center space-x-1",children:[t(A,{asset:m.asset,size:"xs",className:"h-3 w-3"}),l("div",{className:"flex flex-col",children:[t("span",{className:"text-sm h-4",style:{color:"var(--widget-muted-foreground)"},children:m.amount}),t("span",{className:"text-xs",style:{color:"var(--widget-foreground)"},children:m.symbol})]}),t("span",{className:"px-1",style:{color:"var(--widget-muted-foreground)"},children:"\u2192"}),t(A,{asset:n.asset,size:"xs",className:"h-3 w-3"}),l("div",{className:"flex flex-col",children:[t("span",{className:"text-sm h-4",style:{color:"var(--widget-muted-foreground)"},children:n.amount}),t("span",{className:"text-xs",style:{color:"var(--widget-foreground)"},children:n.symbol})]})]})})}),l("div",{className:"flex flex-col items-end text-right shrink-0",children:[t("span",{className:"text-2xs font-sans whitespace-nowrap",style:{color:"var(--widget-muted-foreground)"},children:d.date}),d.time&&t("span",{className:"text-2xs font-sans whitespace-nowrap",style:{color:"var(--widget-muted-foreground)",opacity:.6},children:d.time})]})]})]})};import{Fragment as ae,jsx as a,jsxs as T}from"react/jsx-runtime";var j=()=>T("div",{className:"mt-2 flex flex-col",style:{height:"4rem",border:"1px var(--widget-border-style) var(--widget-border)",backgroundColor:"var(--widget-secondary)"},children:[T("div",{className:"flex items-center space-x-2 p-2",children:[a("div",{className:"h-4 w-4 rounded",style:{backgroundColor:"var(--widget-muted)"}}),a("div",{className:"h-3 w-24 rounded",style:{backgroundColor:"var(--widget-muted)"}})]}),T("div",{className:"flex h-8 w-full items-center justify-between px-4",children:[a("div",{className:"flex items-center space-x-1",children:[4,16,10,4,16,10].map((e,s)=>a("div",{className:"h-3 rounded",style:{width:`${e*4}px`,backgroundColor:"var(--widget-muted)"}},s))}),a("div",{className:"h-3 w-10 rounded",style:{backgroundColor:"var(--widget-muted)"}})]})]}),be=({isActive:e})=>{let{address:s}=S(),{orders:o,isLoading:r,error:u,hasMore:c,loadMore:f}=P(s,e),[p,h]=ne(!1),d=oe(null),m=se(async n=>{let i=n.currentTarget;if(i.scrollTop+i.clientHeight>=i.scrollHeight-100&&!r&&!p&&c){h(!0);try{await f()}finally{h(!1)}}},[r,p,c,f]);return s?u?a("div",{className:"flex items-center justify-center p-4",children:a("p",{className:"text-sm",style:{color:"var(--widget-destructive)"},children:"Error loading activity"})}):a("div",{ref:d,className:"flex flex-col flex-1 min-h-0 overflow-y-auto p-2",onScroll:m,style:{backgroundColor:"transparent"},children:r?Array.from({length:5}).map((n,i)=>a(j,{},i)):o.length===0?a("div",{className:"flex flex-col items-center justify-center h-full p-6",children:a("p",{className:"text-sm",style:{color:"var(--widget-muted-foreground)"},children:"No Activity"})}):T(ae,{children:[o.map(n=>a(B,{order:n,baseToken:n.enrichedTokens?.base??null,quoteToken:n.enrichedTokens?.quote??null},n.orderHash)),p&&a(j,{})]})}):a("div",{className:"flex items-center justify-center p-4",children:a("p",{className:"text-sm",style:{color:"var(--widget-muted-foreground)"},children:"Connect your wallet to view activity"})})};export{be as a};
2
+ import{B as E,E as N,O as A,o as R,p as W}from"./chunk-NNNQNB5T.js";import{a as S}from"./chunk-46H44R7V.js";import{useCallback as se,useRef as oe,useState as ne}from"react";import{useCallback as M,useEffect as Q,useMemo as Z,useRef as z,useState as w}from"react";var O="https://api.aori.io",b=50,G=100,D="0xFAfDdbb3FC7688494971a79cc65DCa3EF82079E7",U="megaeth";function K(e,s){let o=N(e.inputChain),r=N(e.outputChain),u=o?s(o,e.inputToken)??null:null,c=r?s(r,e.outputToken)??null:null;return{orderHash:e.orderHash,quoteId:e.orderHash,status:e.status.toLowerCase(),eventType:e.status.toLowerCase(),inputToken:e.inputToken,inputAmount:e.inputAmount,inputChain:e.inputChain,outputToken:e.outputToken,outputAmount:e.outputAmount,outputChain:e.outputChain,timestamp:e.timestamp,createdAt:e.startTime,srcTx:e.srcTx,dstTx:e.dstTx,explorerUrl:`https://aoriscan.io/order/${e.orderHash}`,enrichedTokens:{base:u,quote:c}}}function P(e,s){let{getToken:o}=E(),[r,u]=w([]),[c,f]=w(!1),[p,h]=w(null),[d,m]=w(b),n=z(null),i=M(async()=>{if(!e)return;n.current?.abort();let g=new AbortController;n.current=g,f(!0),h(null);try{let y={offerer:e,limit:String(G),page:"0"},[L,I]=await Promise.all([fetch(`${O}/data/query?${new URLSearchParams({...y,inputChain:U,inputToken:D})}`,{signal:g.signal}),fetch(`${O}/data/query?${new URLSearchParams({...y,outputChain:U,outputToken:D})}`,{signal:g.signal})]),_=L?.ok?await L.json():null,$=I?.ok?await I.json():null,H=new Set,C=[];for(let x of[..._?.orders??[],...$?.orders??[]])H.has(x.orderHash)||(H.add(x.orderHash),C.push(x));C.sort((x,V)=>V.timestamp-x.timestamp),u(C),m(b)}catch(y){if(y?.name==="AbortError")return;h(y?.message??"Failed to load order history")}finally{g.signal.aborted||f(!1)}},[e]);Q(()=>{if(!s||!e){u([]),m(b);return}return i(),()=>n.current?.abort()},[s,e,i]);let v=d<r.length,q=M(async()=>{v&&m(g=>Math.min(g+b,r.length))},[v,r.length]);return{orders:Z(()=>r.slice(0,d).map(g=>K(g,o)),[r,d,o]),isLoading:c,error:p,hasMore:v,loadMore:q,totalOrders:r.length}}import{useState as X}from"react";import{jsx as t,jsxs as l}from"react/jsx-runtime";var J=()=>l("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:[t("circle",{cx:"5",cy:"5",r:"4",stroke:"currentColor",strokeWidth:"1.2"}),t("path",{d:"M3 5.2L4.3 6.5L7 3.5",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})]}),Y=()=>l("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:[t("circle",{cx:"5",cy:"5",r:"4",stroke:"currentColor",strokeWidth:"1.2"}),t("path",{d:"M3.5 3.5L6.5 6.5M6.5 3.5L3.5 6.5",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round"})]}),ee=()=>l("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:[t("circle",{cx:"5",cy:"5",r:"4",stroke:"currentColor",strokeWidth:"1.2"}),t("path",{d:"M5 3V5.5L6.5 6.5",stroke:"currentColor",strokeWidth:"1",strokeLinecap:"round"})]}),F=()=>l("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:[t("circle",{cx:"5",cy:"5",r:"4",stroke:"currentColor",strokeWidth:"1.2"}),t("circle",{cx:"5",cy:"5",r:"1.5",fill:"currentColor"})]}),te=e=>{switch((e||"").toLowerCase()){case"completed":case"settled":case"success":case"swapped":case"swap":return{icon:t(J,{}),color:"var(--widget-primary)"};case"received":return{icon:t(F,{}),color:"var(--widget-accent)"};case"failed":case"error":case"expired":return{icon:t(Y,{}),color:"var(--widget-destructive)"};case"pending":case"created":case"placed":return{icon:t(ee,{}),color:"var(--widget-muted-foreground)"};default:return{icon:t(F,{}),color:"var(--widget-muted-foreground)"}}},re=e=>{switch((e||"").toLowerCase()){case"completed":case"settled":case"success":case"swapped":case"swap":return"color-mix(in srgb, var(--widget-primary) 5%, transparent)";case"failed":case"error":case"expired":return"color-mix(in srgb, var(--widget-destructive) 5%, transparent)";case"pending":case"created":case"placed":return"color-mix(in srgb, var(--widget-accent) 5%, transparent)";default:return"var(--widget-secondary)"}},k=(e,s)=>{try{let o=parseFloat(e||"0");if(isNaN(o)||o===0)return"0";let r=s?.decimals??18;return R(o/10**r)}catch{return"0"}},B=({order:e,baseToken:s,quoteToken:o})=>{let[r,u]=X(!1),c=e?.status||e?.eventType||"unknown",{icon:f,color:p}=te(c),d=(i=>{if(!i)return{date:"",time:""};let v=new Date(typeof i=="number"?i:Number(i)||i);return{date:v.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),time:v.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",timeZone:"UTC",hour12:!1})+" UTC"}})(e?.timestamp||e?.createdAt||""),m=s?{asset:s,symbol:s.symbol,amount:k(e?.inputAmount,s)}:{asset:null,symbol:(e?.inputToken||"").slice(0,6)+"...",amount:k(e?.inputAmount,null)},n=o?{asset:o,symbol:o.symbol,amount:k(e?.outputAmount,o)}:{asset:null,symbol:(e?.outputToken||"").slice(0,6)+"...",amount:k(e?.outputAmount,null)};return l("a",{href:e?.explorerUrl||"#",target:"_blank",rel:"noopener noreferrer",className:"group flex flex-col cursor-pointer transition-all duration-200 ease-in-out no-underline",style:{border:"1px var(--widget-border-style) var(--widget-border)",backgroundColor:r?re(c):"transparent",marginBottom:"0.5rem",padding:"0.25rem"},onMouseEnter:()=>u(!0),onMouseLeave:()=>u(!1),children:[l("div",{className:"flex flex-row items-center justify-between space-x-1",children:[l("div",{className:"flex flex-row items-center space-x-1",children:[t("div",{className:"-translate-y-px",style:{color:p},children:f}),t("p",{className:"text-2xs font-sans uppercase",style:{color:p},children:c})]}),l("div",{className:"flex flex-row items-center space-x-2",children:[l("span",{className:"text-2xs font-sans",style:{color:r?"var(--widget-foreground)":"var(--widget-muted-foreground)"},children:["\xAC ",W(e?.quoteId||e?.orderHash||"")]}),t("svg",{className:"w-2.5 -translate-y-px opacity-70 group-hover:rotate-[-45deg] group-hover:opacity-100 duration-200",style:{color:"var(--widget-foreground)"},viewBox:"0 0 684 684",fill:"none",children:t("path",{d:"M0.666687 384.667L519.92 384.667L281.627 622.96L342 683.333L683.333 342L342 0.666687L281.627 61.04L519.92 299.333L0.666687 299.333V384.667Z",fill:"currentColor"})})]})]}),l("div",{className:"flex flex-row items-center justify-between pr-2",style:{backgroundColor:r?"transparent":"var(--widget-secondary)"},children:[t("div",{className:"flex flex-col w-full h-full p-2",children:t("div",{className:"flex h-8 w-full items-center justify-between px-2",children:l("div",{className:"flex items-center space-x-1",children:[t(A,{asset:m.asset,size:"xs",className:"h-3 w-3"}),l("div",{className:"flex flex-col",children:[t("span",{className:"text-sm h-4",style:{color:"var(--widget-muted-foreground)"},children:m.amount}),t("span",{className:"text-xs",style:{color:"var(--widget-foreground)"},children:m.symbol})]}),t("span",{className:"px-1",style:{color:"var(--widget-muted-foreground)"},children:"\u2192"}),t(A,{asset:n.asset,size:"xs",className:"h-3 w-3"}),l("div",{className:"flex flex-col",children:[t("span",{className:"text-sm h-4",style:{color:"var(--widget-muted-foreground)"},children:n.amount}),t("span",{className:"text-xs",style:{color:"var(--widget-foreground)"},children:n.symbol})]})]})})}),l("div",{className:"flex flex-col items-end text-right shrink-0",children:[t("span",{className:"text-2xs font-sans whitespace-nowrap",style:{color:"var(--widget-muted-foreground)"},children:d.date}),d.time&&t("span",{className:"text-2xs font-sans whitespace-nowrap",style:{color:"var(--widget-muted-foreground)",opacity:.6},children:d.time})]})]})]})};import{Fragment as ae,jsx as a,jsxs as T}from"react/jsx-runtime";var j=()=>T("div",{className:"mt-2 flex flex-col",style:{height:"4rem",border:"1px var(--widget-border-style) var(--widget-border)",backgroundColor:"var(--widget-secondary)"},children:[T("div",{className:"flex items-center space-x-2 p-2",children:[a("div",{className:"h-4 w-4 rounded",style:{backgroundColor:"var(--widget-muted)"}}),a("div",{className:"h-3 w-24 rounded",style:{backgroundColor:"var(--widget-muted)"}})]}),T("div",{className:"flex h-8 w-full items-center justify-between px-4",children:[a("div",{className:"flex items-center space-x-1",children:[4,16,10,4,16,10].map((e,s)=>a("div",{className:"h-3 rounded",style:{width:`${e*4}px`,backgroundColor:"var(--widget-muted)"}},s))}),a("div",{className:"h-3 w-10 rounded",style:{backgroundColor:"var(--widget-muted)"}})]})]}),be=({isActive:e})=>{let{address:s}=S(),{orders:o,isLoading:r,error:u,hasMore:c,loadMore:f}=P(s,e),[p,h]=ne(!1),d=oe(null),m=se(async n=>{let i=n.currentTarget;if(i.scrollTop+i.clientHeight>=i.scrollHeight-100&&!r&&!p&&c){h(!0);try{await f()}finally{h(!1)}}},[r,p,c,f]);return s?u?a("div",{className:"flex items-center justify-center p-4",children:a("p",{className:"text-sm",style:{color:"var(--widget-destructive)"},children:"Error loading activity"})}):a("div",{ref:d,className:"flex flex-col flex-1 min-h-0 overflow-y-auto p-2",onScroll:m,style:{backgroundColor:"transparent"},children:r?Array.from({length:5}).map((n,i)=>a(j,{},i)):o.length===0?a("div",{className:"flex flex-col items-center justify-center h-full p-6",children:a("p",{className:"text-sm",style:{color:"var(--widget-muted-foreground)"},children:"No Activity"})}):T(ae,{children:[o.map(n=>a(B,{order:n,baseToken:n.enrichedTokens?.base??null,quoteToken:n.enrichedTokens?.quote??null},n.orderHash)),p&&a(j,{})]})}):a("div",{className:"flex items-center justify-center p-4",children:a("p",{className:"text-sm",style:{color:"var(--widget-muted-foreground)"},children:"Connect your wallet to view activity"})})};export{be as a};
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }"use client";
2
+ var _chunkHFX3K3RGcjs = require('./chunk-HFX3K3RG.cjs');var _chunkGK3MOEYUcjs = require('./chunk-GK3MOEYU.cjs');var _chunk3PGCHNG2cjs = require('./chunk-3PGCHNG2.cjs');var _chunk4S3B2JQYcjs = require('./chunk-4S3B2JQY.cjs');var _react = require('react'); var _react2 = _interopRequireDefault(_react);var _jsxruntime = require('react/jsx-runtime');var q=()=>_jsxruntime.jsxs.call(void 0, "svg",{className:"w-3 h-3 shrink-0",style:{color:"var(--widget-secondary-foreground)"},viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[_jsxruntime.jsx.call(void 0, "path",{d:"M18 13V19C18 20.1046 17.1046 21 16 21H5C3.89543 21 3 20.1046 3 19V8C3 6.89543 3.89543 6 5 6H11",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),_jsxruntime.jsx.call(void 0, "path",{d:"M15 3H21V9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),_jsxruntime.jsx.call(void 0, "path",{d:"M10 14L21 3",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),V=()=>_jsxruntime.jsxs.call(void 0, "svg",{className:"w-3 h-3 shrink-0",viewBox:"0 0 195 321",fill:"var(--widget-secondary-foreground)",xmlns:"http://www.w3.org/2000/svg",children:[_jsxruntime.jsx.call(void 0, "path",{fillRule:"evenodd",d:"M195,189C195,207.02,195,225.04,194.7,243.21C193.68,244.78,192.9,246.17,192.25,247.63C189.71,253.38,187.74,259.46,184.6,264.86C169.44,290.97,147.86,309.46,118.54,318.86C116.44,319.55,114.72,320.27,113,321C97.65,321,82.29,321,66.36,320.66C64.21,319.86,62.64,319.4,60.77,318.73C34.51,310.12,15.56,293.82,4.22,268.85C3.68,267.66,2.1,266.94,1,266C1,242.31,1,218.62,1.29,194.79C2.84,192.16,4.11,189.7,5.34,187.22C18.42,160.94,39.89,144.07,66.64,133.63C76.92,129.62,87.87,127.33,98.67,124.2C97.79,123.24,96.8,121.93,95.59,120.86C85.84,112.3,75.95,103.89,66.3,95.21C55.93,85.86,45.02,76.96,35.71,66.63C21.14,50.5,20.04,23.08,45.41,9.57C50.08,7.08,55.12,5.26,59.93,3.03C60.76,2.64,61.32,1.69,62,1C86.69,1,111.38,1,136.23,1.32C138.04,2.32,139.67,3.01,141.32,3.67C147.64,6.19,154.12,8.39,160.26,11.32C166.83,14.45,172.19,19.18,175.44,25.95C179.39,34.19,178.09,43.36,172.05,49.56C165.75,56.03,157.21,57.8,148.78,52.89C142.4,49.17,136.86,43.96,131.1,39.23C122.63,32.28,115.05,23.88,105.74,18.38C87.78,7.76,68.84,9.07,51.16,19.53C38.68,26.91,36.37,41.4,45.53,52.71C50.38,58.69,56.45,64,62.83,68.36C87.15,84.99,111.86,101.05,136.34,117.44C162.56,135,183.88,156.57,193.26,187.79C193.42,188.32,194.4,188.6,195,189ZM77.06,146.49C61.39,155.71,51.27,169.26,45.93,186.5C39.48,207.32,39.44,228.5,42.93,249.76C45.84,267.48,53.16,282.95,66.59,295.39C83.82,311.34,108.85,312.86,127.37,298.41C138.98,289.35,146.05,277.03,149.48,263.04C161.53,213.92,148.4,171.97,112.16,137.05C111.13,136.06,108.71,135.6,107.31,136.05C97.38,139.22,87.54,142.7,77.06,146.49Z"}),_jsxruntime.jsx.call(void 0, "path",{d:"M118.83,199C121.61,197.69,122.77,198.41,122.77,201.27C122.71,217.43,122.78,233.58,122.65,249.73C122.65,250.83,121.43,251.92,120.77,253.01C119.97,252.05,118.63,251.17,118.45,250.1C116.32,237.7,113.36,235.12,100.61,235.02C98.12,235,95.62,234.98,93.12,235.01C81.26,235.16,77.72,238.3,75.94,249.84C75.74,251.15,74.39,252.28,73.57,253.49C73.11,253.23,72.64,252.98,72.17,252.73C72.17,234.81,72.17,216.88,72.17,198.96C72.49,198.62,72.81,198.28,73.13,197.93C74.09,198.95,75.72,199.85,75.92,201C78.13,213.8,80.95,216.26,94.05,216.3C97.38,216.31,100.72,216.44,104.04,216.27C113.28,215.79,117.15,212.05,118.22,202.81C118.35,201.65,118.47,200.49,118.83,199Z"})]});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=_react2.default.memo(()=>{let[o,r]=_react.useState.call(void 0, !1),{liquidityError:L,routingError:S}=_chunkHFX3K3RGcjs.f.call(void 0, ),{baseAmount:n,baseToken:s,quoteAmount:i,quoteToken:a}=_chunkGK3MOEYUcjs.e.call(void 0, ),{quoteLoaderVariant:f,widgetType:T}=_chunk3PGCHNG2cjs.b.call(void 0, ),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=_optionalChain([s, 'optionalAccess', _2 => _2.price])?`\u2248 $${(x?s.price:s.price*l).toFixed(2)}`:"",M=s&&a&&s.chainId!==a.chainId,h=s?_nullishCoalesce(_optionalChain([_chunk4S3B2JQYcjs.c.call(void 0, s.chainId), 'optionalAccess', _3 => _3.estimatedTimeMs]), () => (0)):0,$=a?_nullishCoalesce(_optionalChain([_chunk4S3B2JQYcjs.c.call(void 0, a.chainId), 'optionalAccess', _4 => _4.estimatedTimeMs]), () => (0)):0,N=(M?h+$:h)/1e3,b=L||S,d=s&&a&&n&&parseFloat(n.toString())&&i;return _react.useEffect.call(void 0, ()=>{f==="expanded"&&d&&r(!0)},[f,d]),f==="none"?null:f==="default"?_jsxruntime.jsx.call(void 0, "div",{className:`relative box-border flex flex-row h-8 w-full items-center${p?" justify-start overflow-x-auto":" justify-center"}`,children:_jsxruntime.jsx.call(void 0, "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?_jsxruntime.jsxs.call(void 0, "div",{className:"translate-y-px font-sans flex flex-row items-center gap-2 whitespace-nowrap",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-row items-center gap-1",children:[_jsxruntime.jsx.call(void 0, _chunk4S3B2JQYcjs.O,{asset:v,size:"3xs",noChain:!0,className:"mb-0.5"}),_jsxruntime.jsxs.call(void 0, "span",{className:"text-xs uppercase",style:{color:"var(--widget-muted-foreground)"},children:["1 ",_optionalChain([v, 'optionalAccess', _5 => _5.symbol])]})]}),_jsxruntime.jsx.call(void 0, "span",{className:"text-xs",style:{color:"var(--widget-muted-foreground)"},children:"="}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-row items-center gap-1",children:[_jsxruntime.jsx.call(void 0, _chunk4S3B2JQYcjs.O,{asset:w,size:"3xs",noChain:!0,className:"mb-0.5"}),_jsxruntime.jsxs.call(void 0, "span",{className:"text-xs uppercase",style:{color:"var(--widget-muted-foreground)"},children:[j(C)," ",_optionalChain([w, 'optionalAccess', _6 => _6.symbol])]})]}),_jsxruntime.jsx.call(void 0, "span",{className:"text-xs",style:{color:"var(--widget-muted-foreground)"},children:y})]}):b?_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-full w-full flex-row pb-1 items-center justify-between",children:[_jsxruntime.jsx.call(void 0, "p",{className:"text-xs",style:{color:"var(--widget-destructive)"},children:"Quote not found"}),_jsxruntime.jsx.call(void 0, _chunk4S3B2JQYcjs.W,{className:"h-8 w-8",style:{color:"var(--widget-destructive)"}})]}):_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-full w-full flex-row pb-1 items-center justify-between",children:[_jsxruntime.jsx.call(void 0, "p",{className:"text-xs",style:{color:"var(--widget-accent)"},children:"Searching For Quote"}),_jsxruntime.jsx.call(void 0, _chunk4S3B2JQYcjs.W,{className:"h-8 w-8",style:{color:"var(--widget-accent)"}})]}):_jsxruntime.jsx.call(void 0, "div",{className:"text-xs pb-1",style:{color:"var(--widget-muted-foreground)"},children:"Enter Amount"}):_jsxruntime.jsx.call(void 0, "div",{className:"text-xs pb-1",style:{color:"var(--widget-muted-foreground)"},children:"Enter Amount"})})}):_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col w-full",children:[_jsxruntime.jsx.call(void 0, "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:_jsxruntime.jsx.call(void 0, "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?_jsxruntime.jsxs.call(void 0, "div",{className:"translate-y-px font-sans flex w-full flex-row items-center justify-between",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-row items-center gap-2 whitespace-nowrap",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-row items-center gap-1",children:[_jsxruntime.jsx.call(void 0, _chunk4S3B2JQYcjs.O,{asset:v,size:"3xs",noChain:!0,className:"mb-0.5"}),_jsxruntime.jsxs.call(void 0, "span",{className:"text-xs uppercase",style:{color:"var(--widget-muted-foreground)"},children:["1 ",_optionalChain([v, 'optionalAccess', _7 => _7.symbol])]})]}),_jsxruntime.jsx.call(void 0, "span",{className:"text-xs",style:{color:"var(--widget-muted-foreground)"},children:"="}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-row items-center gap-1",children:[_jsxruntime.jsx.call(void 0, _chunk4S3B2JQYcjs.O,{asset:w,size:"3xs",noChain:!0,className:"mb-0.5"}),_jsxruntime.jsxs.call(void 0, "span",{className:"text-xs uppercase",style:{color:"var(--widget-muted-foreground)"},children:[j(C)," ",_optionalChain([w, 'optionalAccess', _8 => _8.symbol])]})]}),_jsxruntime.jsx.call(void 0, "span",{className:"text-xs",style:{color:"var(--widget-muted-foreground)"},children:y})]}),_jsxruntime.jsx.call(void 0, "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?_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-full w-full flex-row pb-1 items-center justify-between",children:[_jsxruntime.jsx.call(void 0, "p",{className:"text-xs",style:{color:"var(--widget-destructive)"},children:"Quote not found"}),_jsxruntime.jsx.call(void 0, _chunk4S3B2JQYcjs.W,{className:"h-8 w-8",style:{color:"var(--widget-destructive)"}})]}):_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-full w-full flex-row pb-1 items-center justify-between",children:[_jsxruntime.jsx.call(void 0, "p",{className:"text-xs",style:{color:"var(--widget-accent)"},children:"Searching For Quote"}),_jsxruntime.jsx.call(void 0, _chunk4S3B2JQYcjs.W,{className:"h-8 w-8",style:{color:"var(--widget-accent)"}})]}):_jsxruntime.jsx.call(void 0, "div",{className:"text-xs pb-1",style:{color:"var(--widget-muted-foreground)"},children:"Enter Amount"}):_jsxruntime.jsx.call(void 0, "div",{className:"text-xs pb-1",style:{color:"var(--widget-muted-foreground)"},children:"Enter Amount"})})}),_jsxruntime.jsx.call(void 0, "div",{className:"overflow-hidden transition-all duration-200",style:{maxHeight:o&&d?"120px":"0px",opacity:o&&d?1:0},children:_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-1 pb-1.5 font-sans",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex justify-between text-2xs",style:{color:"var(--widget-muted-foreground)"},children:[_jsxruntime.jsx.call(void 0, "span",{children:"USD Value"}),_jsxruntime.jsxs.call(void 0, "span",{style:{color:"var(--widget-secondary-foreground)"},children:["$",_optionalChain([s, 'optionalAccess', _9 => _9.price])&&i?(s.price*l*parseFloat(i.toString())).toFixed(2):"\u2014"]})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex justify-between text-2xs",style:{color:"var(--widget-muted-foreground)"},children:[_jsxruntime.jsx.call(void 0, "span",{children:"Estimated Time"}),_jsxruntime.jsx.call(void 0, "span",{style:{color:"var(--widget-secondary-foreground)"},children:N>0?`${N.toFixed(2)}s`:"\u2014"})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex justify-between text-2xs",style:{color:"var(--widget-muted-foreground)"},children:[_jsxruntime.jsx.call(void 0, "span",{children:"Order Type"}),_jsxruntime.jsx.call(void 0, "span",{style:{color:"var(--widget-secondary-foreground)"},children:"RFQ (Limit)"})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex justify-between items-center text-2xs",style:{color:"var(--widget-muted-foreground)"},children:[_jsxruntime.jsx.call(void 0, "span",{children:"Route"}),_jsxruntime.jsxs.call(void 0, "a",{href:"https://www.aori.io",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 transition-colors hover:opacity-80",style:{color:"var(--widget-secondary-foreground)"},children:[_jsxruntime.jsx.call(void 0, V,{}),"Aori",_jsxruntime.jsx.call(void 0, q,{})]})]})]})})]})});E.displayName="QuoteLoader";var O=E;exports.a = O;
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import{d as C}from"./chunk-GPT4NHM5.js";import{A as Q,L as U,c as w,z as x}from"./chunk-QAOZRRSH.js";import{a as W}from"./chunk-46H44R7V.js";import{create as ee}from"zustand";import{useCallback as D,useEffect as te,useRef as oe}from"react";var F=ee()(c=>({baseToken:null,quoteToken:null,setBaseTokenDirect:i=>c({baseToken:i}),setQuoteTokenDirect:i=>c({quoteToken:i}),swapTokensDirect:()=>c(i=>({baseToken:i.quoteToken,quoteToken:i.baseToken}))}));function G(c){let{data:i,isLoading:m}=x(),o=F(),f=oe(!1),e=c?.defaultBaseToken??null,r=c?.defaultQuoteToken??null;te(()=>{if(!i||i.length===0||f.current)return;f.current=!0;let u=T=>i.find(p=>p.chainId===T.chainId&&p.address.toLowerCase()===T.address.toLowerCase())??null,a=e?u(e):null,l=r?u(r):null;a&&l&&a.chainId===l.chainId&&a.address.toLowerCase()===l.address.toLowerCase()?(o.setBaseTokenDirect(a),o.setQuoteTokenDirect(null)):(o.setBaseTokenDirect(a),o.setQuoteTokenDirect(l))},[i,e,r,o]);let A=D(u=>{if(!u){o.setBaseTokenDirect(null);return}let a=F.getState();a.quoteToken&&u.chainId===a.quoteToken.chainId&&u.address.toLowerCase()===a.quoteToken.address.toLowerCase()?o.swapTokensDirect():o.setBaseTokenDirect(u)},[o]),S=D(u=>{if(!u){o.setQuoteTokenDirect(null);return}let a=F.getState();a.baseToken&&u.chainId===a.baseToken.chainId&&u.address.toLowerCase()===a.baseToken.address.toLowerCase()?o.swapTokensDirect():o.setQuoteTokenDirect(u)},[o]),h=D(()=>{o.swapTokensDirect()},[o]);return{baseToken:o.baseToken,quoteToken:o.quoteToken,setBaseToken:A,setQuoteToken:S,swapTokens:h,isLoading:m}}import{useCallback as k,useMemo as d}from"react";import{parseUnits as E}from"viem";import{useShallow as ne}from"zustand/react/shallow";var M=(c,i,m,o)=>{let{address:f}=W(),{baseToken:e,quoteToken:r,setBaseToken:A,setQuoteToken:S,swapTokens:h,isLoading:u}=G({defaultBaseToken:c,defaultQuoteToken:i}),{baseAmount:a,quoteAmount:l,setBaseAmount:T,setQuoteAmount:p,clearAmounts:v}=C(ne(t=>({baseAmount:t.baseAmount,quoteAmount:t.quoteAmount,setBaseAmount:t.setBaseAmount,setQuoteAmount:t.setQuoteAmount,clearAmounts:t.clearAmounts}))),{data:y}=Q(e?.address,e?.chainId),{data:P}=Q(r?.address,r?.chainId),n=d(()=>{if(!e)return null;let t=y?.price??e.price;return t===e.price?e:{...e,price:t}},[e,y?.price]),s=d(()=>{if(!r)return null;let t=P?.price??r.price;return t===r.price?r:{...r,price:t}},[r,P?.price]),{baseBalance:B,quoteBalance:b,isLoading:R}=U(f,n,s),g=d(()=>!B||B.raw==="0"?null:B,[B]),I=d(()=>!b||b.raw==="0"?null:b,[b]),q=d(()=>{if(!n?.chainId)return!1;let t=w(n.chainId);return n.address.toLowerCase()===t?.gasToken.address?.toLowerCase()},[n]),L=d(()=>{if(!s?.chainId)return!1;let t=w(s.chainId);return s.address.toLowerCase()===t?.gasToken.address?.toLowerCase()},[s]),O=d(()=>{if(!q||!n?.chainId||!s||n.chainId!==s.chainId||n.chainId===988)return!1;let t=w(n.chainId);return s.address.toLowerCase()===t?.wrappedAsset.address?.toLowerCase()},[q,n,s]),z=d(()=>{if(!n?.chainId||!s||!L||n.chainId!==s.chainId||n.chainId===988)return!1;let t=w(n.chainId);return n.address.toLowerCase()===t?.wrappedAsset.address?.toLowerCase()},[n,s,L]),H=d(()=>({raw:g?.raw??"0",formatted:g?.formatted??"0"}),[g]),J=d(()=>({raw:I?.raw??"0",formatted:I?.formatted??"0"}),[I]),K=d(()=>!n||typeof a!="number"||n.decimals===void 0||n.decimals===null?null:E(a.toFixed(n.decimals),n.decimals).toString(),[n,a]),V=d(()=>!s||typeof l!="number"||s.decimals===void 0||s.decimals===null?null:E(l.toFixed(s.decimals),s.decimals).toString(),[s,l]),X=k(async t=>{A(t),p(null),m?.(t)},[A,p,m]),Y=k(async t=>{S(t),o?.(t)},[S,o]),Z=k(t=>T(t),[T]),_=k(t=>p(t),[p]),$=k(()=>{h(),C.getState().toggleInverted(),r&&m?.(r),e&&o?.(e)},[h,e,r,m,o]),j=k(()=>v(),[v]);return{baseToken:n,baseAmount:a,quoteToken:s,quoteAmount:l,isBaseGasToken:q,isQuoteGasToken:L,isWrappingPair:O,isUnwrappingPair:z,baseBalance:H,quoteBalance:J,baseAmountRaw:K,quoteAmountRaw:V,isBaseBalanceLoading:R,isQuoteBalanceLoading:R,isRegistryLoading:u,setBaseToken:X,setQuoteToken:Y,setBaseAmount:Z,setQuoteAmount:_,swapTokens:$,clearForm:j}};import{createContext as se,useContext as ae,useMemo as re}from"react";import{jsx as ie}from"react/jsx-runtime";var N=se(null),Ie=({children:c,defaultBaseToken:i,defaultQuoteToken:m,onBaseTokenChange:o,onQuoteTokenChange:f})=>{let e=M(i,m,o,f),r=re(()=>e,[e.baseToken,e.quoteToken,e.baseAmount,e.quoteAmount,e.isBaseGasToken,e.isQuoteGasToken,e.isWrappingPair,e.isUnwrappingPair,e.baseBalance,e.quoteBalance,e.baseAmountRaw,e.quoteAmountRaw,e.isBaseBalanceLoading,e.isQuoteBalanceLoading,e.setBaseToken,e.setQuoteToken,e.setBaseAmount,e.setQuoteAmount,e.swapTokens,e.clearForm,e.isRegistryLoading]);return ie(N.Provider,{value:r,children:c})},qe=()=>{let c=ae(N);if(!c)throw new Error("useSwapFormContext must be used within SwapFormProvider");return c};export{F as a,G as b,M as c,Ie as d,qe as e};
2
+ import{d as C}from"./chunk-XCPMBMS7.js";import{A as Q,L as U,c as w,z as x}from"./chunk-NNNQNB5T.js";import{a as W}from"./chunk-46H44R7V.js";import{create as ee}from"zustand";import{useCallback as D,useEffect as te,useRef as oe}from"react";var F=ee()(c=>({baseToken:null,quoteToken:null,setBaseTokenDirect:i=>c({baseToken:i}),setQuoteTokenDirect:i=>c({quoteToken:i}),swapTokensDirect:()=>c(i=>({baseToken:i.quoteToken,quoteToken:i.baseToken}))}));function G(c){let{data:i,isLoading:m}=x(),o=F(),f=oe(!1),e=c?.defaultBaseToken??null,r=c?.defaultQuoteToken??null;te(()=>{if(!i||i.length===0||f.current)return;f.current=!0;let u=T=>i.find(p=>p.chainId===T.chainId&&p.address.toLowerCase()===T.address.toLowerCase())??null,a=e?u(e):null,l=r?u(r):null;a&&l&&a.chainId===l.chainId&&a.address.toLowerCase()===l.address.toLowerCase()?(o.setBaseTokenDirect(a),o.setQuoteTokenDirect(null)):(o.setBaseTokenDirect(a),o.setQuoteTokenDirect(l))},[i,e,r,o]);let A=D(u=>{if(!u){o.setBaseTokenDirect(null);return}let a=F.getState();a.quoteToken&&u.chainId===a.quoteToken.chainId&&u.address.toLowerCase()===a.quoteToken.address.toLowerCase()?o.swapTokensDirect():o.setBaseTokenDirect(u)},[o]),S=D(u=>{if(!u){o.setQuoteTokenDirect(null);return}let a=F.getState();a.baseToken&&u.chainId===a.baseToken.chainId&&u.address.toLowerCase()===a.baseToken.address.toLowerCase()?o.swapTokensDirect():o.setQuoteTokenDirect(u)},[o]),h=D(()=>{o.swapTokensDirect()},[o]);return{baseToken:o.baseToken,quoteToken:o.quoteToken,setBaseToken:A,setQuoteToken:S,swapTokens:h,isLoading:m}}import{useCallback as k,useMemo as d}from"react";import{parseUnits as E}from"viem";import{useShallow as ne}from"zustand/react/shallow";var M=(c,i,m,o)=>{let{address:f}=W(),{baseToken:e,quoteToken:r,setBaseToken:A,setQuoteToken:S,swapTokens:h,isLoading:u}=G({defaultBaseToken:c,defaultQuoteToken:i}),{baseAmount:a,quoteAmount:l,setBaseAmount:T,setQuoteAmount:p,clearAmounts:v}=C(ne(t=>({baseAmount:t.baseAmount,quoteAmount:t.quoteAmount,setBaseAmount:t.setBaseAmount,setQuoteAmount:t.setQuoteAmount,clearAmounts:t.clearAmounts}))),{data:y}=Q(e?.address,e?.chainId),{data:P}=Q(r?.address,r?.chainId),n=d(()=>{if(!e)return null;let t=y?.price??e.price;return t===e.price?e:{...e,price:t}},[e,y?.price]),s=d(()=>{if(!r)return null;let t=P?.price??r.price;return t===r.price?r:{...r,price:t}},[r,P?.price]),{baseBalance:B,quoteBalance:b,isLoading:R}=U(f,n,s),g=d(()=>!B||B.raw==="0"?null:B,[B]),I=d(()=>!b||b.raw==="0"?null:b,[b]),q=d(()=>{if(!n?.chainId)return!1;let t=w(n.chainId);return n.address.toLowerCase()===t?.gasToken.address?.toLowerCase()},[n]),L=d(()=>{if(!s?.chainId)return!1;let t=w(s.chainId);return s.address.toLowerCase()===t?.gasToken.address?.toLowerCase()},[s]),O=d(()=>{if(!q||!n?.chainId||!s||n.chainId!==s.chainId||n.chainId===988)return!1;let t=w(n.chainId);return s.address.toLowerCase()===t?.wrappedAsset.address?.toLowerCase()},[q,n,s]),z=d(()=>{if(!n?.chainId||!s||!L||n.chainId!==s.chainId||n.chainId===988)return!1;let t=w(n.chainId);return n.address.toLowerCase()===t?.wrappedAsset.address?.toLowerCase()},[n,s,L]),H=d(()=>({raw:g?.raw??"0",formatted:g?.formatted??"0"}),[g]),J=d(()=>({raw:I?.raw??"0",formatted:I?.formatted??"0"}),[I]),K=d(()=>!n||typeof a!="number"||n.decimals===void 0||n.decimals===null?null:E(a.toFixed(n.decimals),n.decimals).toString(),[n,a]),V=d(()=>!s||typeof l!="number"||s.decimals===void 0||s.decimals===null?null:E(l.toFixed(s.decimals),s.decimals).toString(),[s,l]),X=k(async t=>{A(t),p(null),m?.(t)},[A,p,m]),Y=k(async t=>{S(t),o?.(t)},[S,o]),Z=k(t=>T(t),[T]),_=k(t=>p(t),[p]),$=k(()=>{h(),C.getState().toggleInverted(),r&&m?.(r),e&&o?.(e)},[h,e,r,m,o]),j=k(()=>v(),[v]);return{baseToken:n,baseAmount:a,quoteToken:s,quoteAmount:l,isBaseGasToken:q,isQuoteGasToken:L,isWrappingPair:O,isUnwrappingPair:z,baseBalance:H,quoteBalance:J,baseAmountRaw:K,quoteAmountRaw:V,isBaseBalanceLoading:R,isQuoteBalanceLoading:R,isRegistryLoading:u,setBaseToken:X,setQuoteToken:Y,setBaseAmount:Z,setQuoteAmount:_,swapTokens:$,clearForm:j}};import{createContext as se,useContext as ae,useMemo as re}from"react";import{jsx as ie}from"react/jsx-runtime";var N=se(null),Ie=({children:c,defaultBaseToken:i,defaultQuoteToken:m,onBaseTokenChange:o,onQuoteTokenChange:f})=>{let e=M(i,m,o,f),r=re(()=>e,[e.baseToken,e.quoteToken,e.baseAmount,e.quoteAmount,e.isBaseGasToken,e.isQuoteGasToken,e.isWrappingPair,e.isUnwrappingPair,e.baseBalance,e.quoteBalance,e.baseAmountRaw,e.quoteAmountRaw,e.isBaseBalanceLoading,e.isQuoteBalanceLoading,e.setBaseToken,e.setQuoteToken,e.setBaseAmount,e.setQuoteAmount,e.swapTokens,e.clearForm,e.isRegistryLoading]);return ie(N.Provider,{value:r,children:c})},qe=()=>{let c=ae(N);if(!c)throw new Error("useSwapFormContext must be used within SwapFormProvider");return c};export{F as a,G as b,M as c,Ie as d,qe as e};
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ import{a as bn}from"./chunk-OPN7WCJR.js";import{e as Ne}from"./chunk-FWH744XA.js";import{b as Ae,c as $t,d as se}from"./chunk-XCPMBMS7.js";import{E as qe,F as tt,H as kt,I as Nt,J as nt,N as ge,O as te,P as ee,S as we,T as It,U as Ue,V as K,X as Et,Y as Me,a as We,c as B,h as Ze,k as Le,m as _e,o as ke,q as St,r as re,s as Rt,t as Je,v as et,w as Tt,x as At}from"./chunk-NNNQNB5T.js";import{a as he}from"./chunk-46H44R7V.js";import{b as yn}from"./chunk-73CB2I7U.js";import{useQueryClient as xn}from"@tanstack/react-query";import{useCallback as Cn,useEffect as Pt,useRef as Ot}from"react";function Sn(e){if(e.length===0)return 5e3;let l=Math.max(...e.map(r=>B(r)?.blockTimeMs??2e3));return Math.min(5e3,Math.max(1e3,l*2+1e3))}var Rn=()=>{let{address:e}=he(),t=$t(),n=xn(),c=Ot(null),l=Ot(!0),r=Cn(a=>{if(!e)return;let v=[...new Set(a.tokens.map(u=>u.asset.chainId))],d=Sn(v);c.current&&(clearTimeout(c.current),c.current=null),c.current=setTimeout(async()=>{if(c.current=null,!!l.current)try{let u=a.tokens.map(f=>({chainId:f.asset.chainId,tokenAddress:f.asset.address})),s=await Nt(e,u);if(s.balances.length===0)return;if(a.tokens.length>=2){let f=a.tokens[0].asset,p=a.tokens[1].asset,g=nt.swap(e,f.chainId,f.address,p.chainId,p.address);n.setQueryData(g,s)}let o=nt.bulk(e,t),S=n.getQueryData(o);if(S){let f=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)f.some(g=>g.chainId===p.chainId&&g.token.toLowerCase()===p.token.toLowerCase())||f.push(p);for(let p of a.tokens)if(!s.balances.some(x=>x.chainId===p.asset.chainId&&x.token.toLowerCase()===p.asset.address.toLowerCase())){let x=f.findIndex(i=>i.chainId===p.asset.chainId&&i.token.toLowerCase()===p.asset.address.toLowerCase());x!==-1&&(f[x]={...f[x],balance:"0",shiftedBalance:"0"})}n.setQueryData(o,{balances:f})}}catch{}},d)},[e,t,n]);return Pt(()=>(l.current=!0,()=>{l.current=!1,c.current&&(clearTimeout(c.current),c.current=null)}),[]),{triggerBalanceUpdate:r}},rt=class extends EventTarget{emit(t){this.dispatchEvent(new CustomEvent("balance-update",{detail:t}))}},st=new rt,De=()=>e=>st.emit(e),Jr=()=>{let{triggerBalanceUpdate:e}=Rn();Pt(()=>{let t=n=>{e(n.detail)};return st.addEventListener("balance-update",t),()=>st.removeEventListener("balance-update",t)},[e])};import{createContext as Tn,useCallback as ie,useContext as An,useEffect as Ut,useMemo as kn,useRef as oe,useState as xe}from"react";import{formatUnits as Nn,parseUnits as In}from"viem";import{jsx as Un}from"react/jsx-runtime";var Wt=Tn(void 0),Mt=1e4,En=3e4,$n=1e3,On=2;function Pn(e){return e.find(n=>n.routeSteps?.[0]?.type==="AORI_V1")??e[0]}var is=({children:e,recipient:t})=>{let{address:n}=he(),c=t||n,[l,r]=xe("idle"),[a,v]=xe("idle"),[d,u]=xe(null),[s,o]=xe(null),[S,f]=xe(!1),[p,g]=xe(!1),[x,i]=xe(!1),h=oe(null),A=oe(null),m=oe(null),O=oe(null),W=oe(null),y=oe(0),k=oe(0),q=oe(0),N=oe(!1),I=oe(new Map),E=ie(()=>{m.current&&clearTimeout(m.current),O.current&&clearTimeout(O.current),W.current&&clearTimeout(W.current),m.current=null,O.current=null,W.current=null},[]),U=ie(()=>{E(),h.current=null,y.current=0,r(()=>N.current?"fresh":"idle")},[E]),M=ie(()=>{U(),A.current=null,u(null),o(null),f(!1),g(!1),i(!1),I.current.clear(),r("idle"),v("idle")},[U]),Y=ie(C=>{if(!C)return;O.current&&clearTimeout(O.current);let w=Math.max(0,C+En-Date.now());O.current=setTimeout(()=>{r(P=>P==="idle"?"idle":"stale")},w)},[]),Z=ie(async(C,w)=>{let{inputToken:P,outputToken:$,inputAmount:H,setOutputAmount:de}=C;if(!P||!$||!H||parseFloat(H)<=0||Date.now()-(k.current||0)<Mt-10)return;let ae=++y.current;try{if(!P?.decimals||!$?.decimals)return;let G=tt(P.chainId)||B(P.chainId)?.key||"",ne=tt($.chainId)||B($.chainId)?.key||"";if(!G||!ne)throw new Error("Unknown chain");let pe=In(H.toString(),P.decimals).toString(),fe={srcChainKey:G,dstChainKey:ne,srcTokenAddress:et(P.address),dstTokenAddress:et($.address),amount:pe,srcWalletAddress:n||"0x0000000000000000000000000000000000000000",dstWalletAddress:c||n||"0x0000000000000000000000000000000000000000",options:{amountType:"EXACT_SRC_AMOUNT",feeTolerance:{type:"PERCENT",amount:2}}};k.current=Date.now();let J=await fetch(`${Le()}/quotes`,{method:"POST",headers:_e(),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||h.current!==w)return;let $e=me.quotes??[],be=Pn($e);if(!be)throw Object.assign(new Error("No quotes returned"),{emptyQuotes:!0});let Te=Number(Nn(St(be.dstAmount),$.decimals));typeof de=="function"&&de(Te),be._receivedAt=Date.now(),u(be),o(null),f(!1),r("fresh"),Y(be._receivedAt),w&&I.current.delete(w)}catch(G){if(ae!==y.current||h.current!==w)return;let ne=G?.status,pe=G instanceof Error?G.message:"",fe=!!G?.emptyQuotes;if((ne===400||fe||pe.includes("Quote request failed"))&&w){let me=(I.current.get(w)||0)+1;if(I.current.set(w,me),me>=On){g(!0),E(),h.current=null;return}}if(pe.toLowerCase().includes("order cap exceeded")){i(!0),E(),h.current=null;return}if(pe.toLowerCase().includes("insufficient executor balance")){f(!0),E(),h.current=null;return}o(G instanceof Error?G.message:"Unknown error")}},[n,c,Y,E]),L=ie((C,w)=>{E(),A.current=C,k.current=0,I.current.delete(w),f(!1),g(!1),i(!1),o(null),r("polling");let P=async()=>{h.current===w&&(await Z(C,w),h.current===w&&(m.current=setTimeout(P,Mt)))};P()},[E,Z]),T=ie(C=>{if(!C?.inputToken||!C?.outputToken||!C?.inputAmount||parseFloat(C.inputAmount)<=0){U();return}let w=A.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&&h.current)return;let $=Date.now();if($-q.current<100)return;q.current=$;let H=`${Date.now()}-${Math.random().toString(36).slice(2)}`;h.current=H,L(C,H)},[L,U]),_=ie(({amount:C,inputToken:w,outputToken:P,setOutputAmount:$})=>{$(null),W.current&&clearTimeout(W.current),!C||C===0?(v("idle"),U(),u(null),o(null),f(!1),g(!1),i(!1)):(v("typing"),U(),u(null),f(!1),g(!1),i(!1),o(null),W.current=setTimeout(()=>{v("settled"),w&&P&&C>0&&T({inputToken:w,outputToken:P,inputAmount:C.toString(),setOutputAmount:$})},$n))},[U,T]),F=ie(()=>{let C=A.current;if(!C)return;u(null);let w=`${Date.now()}-${Math.random().toString(36).slice(2)}`;h.current=w,r("refreshing"),typeof C.setOutputAmount=="function"&&C.setOutputAmount(null),L(C,w)},[L]);Ut(()=>{N.current=!!d},[d]),Ut(()=>()=>E(),[E]);let Q=kn(()=>({status:l,inputState:a,rfqQuote:d,error:s,liquidityError:S,routingError:p,sizeCapError:x,ensureForParams:T,stop:U,refresh:F,clear:M,handleInputChange:_}),[l,a,d,s,S,p,x,T,U,F,M,_]);return Un(Wt.Provider,{value:Q,children:e})},Fe=()=>{let e=An(Wt);if(e===void 0)throw new Error("useRfq must be used within an RfqProvider");return e};import{createContext as Mn,useContext as Wn}from"react";var Ln=Mn({openConnectModal:()=>{}}),ds=()=>Wn(Ln);import{useCallback as ot,useEffect as Ie,useRef as Ve,useState as at}from"react";import{jsx as Ee,jsxs as Dn}from"react/jsx-runtime";var _n=20,qn=({side:e,asset:t,otherAsset:n,isPlacingOrder:c,isWrappingPair:l,isUnwrappingPair:r})=>{let{baseAmount:a,quoteAmount:v,setBaseAmount:d,setQuoteAmount:u}=Ne(),{amountInputVariant:s,hideAmountInputSymbol:o,widgetType:S}=Ae(),f=S==="compact",[p,g]=e==="base"?[d,u]:[u,d],x=!t||e==="quote"||c,i=f?32:s==="default"?64:32,[h,A]=at(i),[m,O]=at(""),W=Ve(null),y=Ve(null),k=Ve(null),q=Ve(null),N="USD",I=e==="base"?a:v,[E,U]=at(!1),M=ot(()=>{if(s!=="default"){A(i);return}if(!W.current||!y.current||!k.current)return;let L=W.current.offsetWidth,T=20,_=i;for(;_>20&&(y.current.style.fontSize=`${_}px`,k.current.style.fontSize=`${_}px`,!(y.current.offsetWidth+k.current.offsetWidth+T<=L));)_-=1;A(_)},[s,i]),Y=ot(L=>{L.key==="."&&m.includes(".")&&L.preventDefault()},[m]),Z=ot(L=>{let T=L.target.value;if(T==="."&&(T="0."),!/^\d*\.?\d*$/.test(T)||(T.match(/\./g)||[]).length>1)return;if(T.length>1&&T[0]==="0"&&T[1]!=="."&&(T=T.replace(/^0+/,"")||"0"),t?.decimals!==void 0&&T.includes(".")){let[,F]=T.split(".");if(F&&F.length>t.decimals)return}if(T.length>_n)return;O(T);let _=parseFloat(T);T!==m&&(T===""||T==="0."||T.endsWith(".")?(p(null),e==="base"&&g(null)):!Number.isNaN(_)&&_>=0&&p(_),e==="base"&&u(null),(r||l)&&u(_||0))},[m,p,e,u,t?.decimals,g,r,l]);return Ie(()=>{let L=F=>{if(F===null)return"";let Q=t?.decimals;if(Q===void 0)return"";let C=F.toString();if(/e/i.test(C)&&(C=Number(F).toLocaleString("en-US",{useGrouping:!1,maximumFractionDigits:Q})),C.includes(".")){let[w,P]=C.split("."),$=P.slice(0,Q);return $?`${w}.${$}`:w}return C};if(I===null){m==="0."||m!==""&&m.endsWith(".")||O("");return}if(!x&&(m.endsWith(".")||m.match(/\.\d*0$/)||m==="0"||m==="0.")&&m!=="")return;let _=parseFloat(m)||0;(m===""||Math.abs(_-I)>1e-10)&&O(L(I))},[I,t?.decimals,m,x]),Ie(()=>{M()},[m,M]),Ie(()=>{U(!0)},[]),Ie(()=>{E&&M()},[E,M]),Ie(()=>{y.current&&q.current&&(q.current.style.width=`${y.current.offsetWidth}px`)},[m]),Ie(()=>{if(!E)return;let L=new ResizeObserver(()=>{E&&M()});return W.current&&L.observe(W.current),()=>L.disconnect()},[E,M]),Ee("div",{ref:W,style:{fontSize:`${h}px`,transition:"font-size 0.05s ease-in-out"},className:`mt-2 box-border font-sans flex ${f?s==="normal"?"h-12 my-1":"h-10 my-0.5":s==="normal"?"h-12 my-1":"h-20 my-1"} w-full flex-row items-center ${x?"cursor-default":"cursor-text"}`,onClick:()=>q.current?.focus(),children:Dn("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:q,type:"text",inputMode:"decimal",placeholder:"0",autoComplete:"off",id:`${e}Amount`,value:m,onWheel:L=>L.target.blur(),onKeyDown:Y,onChange:Z,style:{transition:"width 0.15s ease-in-out",color:"var(--widget-foreground)",WebkitTextFillColor:"var(--widget-foreground)",opacity:1},className:"flex min-w-[45px] whitespace-nowrap bg-transparent placeholder:opacity-50 font-sans font-thin",disabled:x}),Ee("span",{style:{transition:"width 0.15s ease-in-out"},ref:y,className:"pointer-events-none absolute flex whitespace-nowrap invisible",children:m||0}),!o&&s!=="normal"&&Ee("span",{ref:k,className:"ml-2 font-thin uppercase",style:{color:"var(--widget-foreground)",opacity:.5,fontSize:`${h}px`},children:t?.symbol?t.symbol.length>6?`${t.symbol.slice(0,6)}...`:t.symbol:N}),(o||s==="normal")&&Ee("span",{ref:k,className:"hidden"})]})})},hs=qn;import{Fragment as it,jsx as D,jsxs as ce}from"react/jsx-runtime";var Fn=({toggle:e,side:t,asset:n,isPlacingOrder:c,hideDropdown:l})=>{let{baseBalance:r,quoteBalance:a}=Ne(),{tokenDisplay:v,tokenBadgeOrientation:d,widgetType:u}=Ae(),s=u==="compact",o=s?"h-10":"h-13",S=s?"h-10 w-10":"h-13 w-13",f=t==="base"?r.formatted?(()=>{let g=parseFloat(r.formatted);return g>=1e4?ke(g):g.toFixed(4)})():void 0:a.formatted?(()=>{let g=parseFloat(a.formatted);return g>=1e4?ke(g):g.toFixed(4)})():void 0,p={role:"button",tabIndex:c?-1:0,"aria-disabled":c,"aria-label":`Select ${t==="base"?"input":"output"} token${n?`: ${n.symbol}`:""}`,onClick:c?void 0:e,onKeyDown:c?void 0:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),e())}};return v==="pill"?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(it,{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}),!l&&D(Ue,{className:"w-1.5 opacity-60",style:{color:"var(--widget-secondary-foreground)"}})]}):ce(it,{children:[D("span",{className:"text-xs opacity-70",children:"Select"}),!l&&D(Ue,{className:"w-1.5 opacity-60",style:{color:"var(--widget-secondary-foreground)"}})]})}):v==="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(it,{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"}),!l&&D(Ue,{className:"w-1.5 opacity-50"})]}):D("div",{...p,className:`relative ${o} w-full cursor-pointer text-xl duration-100 ease-linear`,style:{border:"1px solid var(--widget-border)",backgroundColor:"var(--widget-secondary)",borderTopLeftRadius:"9999px",borderBottomLeftRadius:"9999px",borderTopRightRadius:"var(--widget-radius)",borderBottomRightRadius:"var(--widget-radius)"},children: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)]})]}),f!==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:f})]})]}),!l&&D(Ue,{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"})})})})},Ss=Fn;var _t=yn(bn(),1);import{useState as Be,useEffect as Qe}from"react";import{jsx as X,jsxs as Lt}from"react/jsx-runtime";var Vn=()=>{let[e,t]=Be(null),[n,c]=Be(""),l=At(n,1e3),[r,a]=Be(!1),[v,d]=Be("");Qe(()=>{se.getState().setRecipient(e)},[e]),Qe(()=>{c(e||"")},[e]);let u=o=>{let S=o.target.value;r&&(a(!1),d(""),t(null)),c(S),S===""&&t(null)};Qe(()=>{l===""||!l?(a(!1),d(""),t(null)):Tt(l)?(a(!1),d(""),t(l)):(a(!0),d("Invalid wallet address..."),t(null),c(""))},[l]),Qe(()=>{if(r){let o=setTimeout(()=>{t(null),c(""),a(!1),d("")},2e3);return()=>clearTimeout(o)}},[r]);let s=()=>{t(null),c(""),a(!1),d("")};return X("div",{className:"w-full",children:Lt("div",{className:"relative flex flex-row items-center",children:[X("input",{type:"password",style:{display:"none"},"aria-hidden":"true",tabIndex:-1}),X("label",{htmlFor:"recipient-address",className:"sr-only",children:"Recipient wallet address"}),X("div",{className:"absolute left-3 flex h-6 w-6 items-end justify-center overflow-hidden rounded-full",style:{backgroundColor:"var(--widget-secondary)"},children:e&&!r?X("img",{className:"h-full w-full rounded-full object-cover",src:(0,_t.makeGradient)(e),alt:"Recipient avatar"}):X(It,{className:"h-5 w-5",style:{color:r?"var(--widget-destructive)":"var(--widget-muted-foreground)"}})}),X("div",{className:"absolute left-12 top-1.5 -translate-y-1 text-xs font-medium opacity-60",style:{color:r?"var(--widget-destructive)":"var(--widget-muted-foreground)"},"aria-hidden":"true",children:"To:"}),X("input",{id:"recipient-address",className:"font-sans block h-10 w-full items-center pl-12 pt-4 pr-8 text-xs",style:{backgroundColor:r?"color-mix(in srgb, var(--widget-destructive) 10%, transparent)":"transparent",color:r?"var(--widget-destructive)":"var(--widget-foreground)",outline:"none",opacity:r?.9:1},placeholder:r?v:"Enter recipient address...",value:n,onChange:u,spellCheck:!1,"aria-invalid":r,"aria-describedby":r?"recipient-error":void 0}),r&&X("span",{id:"recipient-error",className:"sr-only",children:v}),e&&!r&&Lt("button",{type:"button",className:"absolute right-2 top-1/2 -translate-y-1/2 cursor-pointer flex items-center justify-center h-4 w-4 rounded-full transition-colors hover:[color:var(--widget-destructive)]",style:{color:"var(--widget-muted-foreground)"},onClick:s,"aria-label":"Clear recipient",children:[X("svg",{className:"h-2.5 w-2.5",viewBox:"0 -0.5 21 21",fill:"none",children:X("g",{fill:"currentColor",fillRule:"evenodd",children:X("polygon",{points:"375.0183 90 384 98.554 382.48065 100 373.5 91.446 364.5183 100 363 98.554 371.98065 90 363 81.446 364.5183 80 373.5 88.554 382.48065 80 384 81.446",transform:"translate(-363 -80)"})})}),X("span",{className:"sr-only",children:"Clear recipient"})]})]})})},Es=Vn;import{jsx as qt,jsxs as Bn}from"react/jsx-runtime";function Ps(e){return Bn("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 Qn}from"viem/actions";function Ft(e){return e instanceof Error?e.name==="UserRejectedRequestError"||e.message.includes("User rejected")||e.message.includes("rejected")||e.message.includes("denied")||e.message.includes("cancelled")||e.message.includes("canceled"):!1}async function Dt(e){if(e.chain?.id)return e.chain.id;let t=e.getChainId?.();return t!=null?await t:null}var jn=async(e,t)=>{try{if(await Dt(e)===t)return!0;if(e.request)await e.request({method:"wallet_switchEthereumChain",params:[{chainId:`0x${t.toString(16)}`}]});else if(e.switchChain)await e.switchChain({id:t});else if(e.send)await e.send("wallet_switchEthereumChain",[{chainId:`0x${t.toString(16)}`}]);else throw new Error("Wallet doesn't support chain switching");return await Dt(e)===t}catch(n){throw Ft(n)?new Error("User rejected the chain switch request"):new Error(`Please switch your wallet to the required network (Chain ID: ${t})`)}},Vt=async e=>{let{quote:t,signatureStep:n,userAddress:c,walletClient:l}=e;if(!l)throw new Error("Wallet client not available");if(n.type!=="SIGNATURE"||!n.signature?.typedData)throw new Error("Invalid signature step");try{let r=n.signature.typedData,a={...r.message};for(let s of["inputAmount","outputAmount","startTime","endTime"])a[s]!=null&&(a[s]=BigInt(a[s]));let v=r.domain;if(v.chainId!=null){let s=Number(v.chainId);await jn(l,s)}let d=await Qn(l,{account:c,domain:v,types:r.types,primaryType:r.primaryType,message:a}),u=await fetch(`${Le()}/submit-signature`,{method:"POST",headers:_e(),body:JSON.stringify({quoteId:t.id,signatures:[d]})});if(!u.ok){let s=await u.json().catch(()=>({}));throw new Error(s?.message||`Submit failed: ${u.status}`)}return{quoteId:t.id,signature:d}}catch(r){throw Ft(r)?new Error("User rejected the signing request"):r instanceof Error&&r.message.includes("chain")?new Error("Chain switching failed. Please manually switch to the correct network."):r}};var Bt="vt_submitted_quotes";var ct=()=>{try{let e=localStorage.getItem(Bt);return e?JSON.parse(e):[]}catch{return[]}},Qt=e=>{try{localStorage.setItem(Bt,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},Hn=e=>ct().some(t=>t.quoteId===e),jt=(e,t)=>Hn(e)?{canSubmit:!1,reason:"Order already submitted"}:zn(t)?{canSubmit:!0}:{canSubmit:!1,reason:"Quote has expired"},zt=(e,t)=>{let n=typeof t=="string"?new Date(t).getTime():t,c=ct();c.push({quoteId:e,submittedAt:Date.now(),createdAt:n}),Qt(c)},Ht=()=>{let e=ct(),t=Date.now(),n=300*1e3,c=e.filter(l=>t-l.submittedAt<n);c.length!==e.length&&Qt(c)};import{useMutation as Gn}from"@tanstack/react-query";import{waitForTransactionReceipt as Kn}from"@wagmi/core";import{wethAbi as Xn}from"abitype/abis";import{useConfig as Yn}from"wagmi";function Gt(){let e=Yn();return Gn({mutationFn:async({chainId:t,accountAddress:n,amountRaw:c,writeContractAsync:l})=>{let r=B(t);if(!r)throw new Error(`No wrapping contract for chain ${t}`);let a=r.wrappedAsset.address,v=await l({abi:Xn,functionName:"withdraw",address:a,account:n,args:[c],chainId:t});if((await Kn(e,{hash:v,chainId:t,confirmations:1,pollingInterval:4e3})).status!=="success")throw new Error("Unwrap transaction did not get successful receipt");return{success:!0,hash:v}}})}import{useMutation as Zn}from"@tanstack/react-query";import{waitForTransactionReceipt as Jn}from"@wagmi/core";import{wethAbi as er}from"abitype/abis";import{useConfig as tr}from"wagmi";function Kt(){let e=tr();return Zn({mutationFn:async({chainId:t,accountAddress:n,amountRaw:c,writeContractAsync:l})=>{let r=B(t);if(!r)throw new Error(`No wrapping contract for chain ${t}`);let a=r.wrappedAsset.address,v=await l({abi:er,functionName:"deposit",address:a,account:n,value:c,chainId:t});if((await Jn(e,{hash:v,chainId:t,confirmations:1,pollingInterval:4e3})).status!=="success")throw new Error("Wrap transaction did not get successful receipt");return{success:!0,hash:v}}})}import{useCallback as ue,useEffect as Re,useRef as wn,useState as qr}from"react";import{useChainId as Dr}from"wagmi";import{useEffect as Xt,useState as nr,useCallback as Yt,useRef as lt}from"react";import{useAccount as rr,useChainId as sr,useSwitchChain as or}from"wagmi";import{jsx as ve,jsxs as ut}from"react/jsx-runtime";var ar=15e3,je="chain",ir=({needsChainSwitch:e,requiredChain:t,reviewState:n,goToNextStep:c,cancel:l})=>{let r=re(je,n),[a,v]=nr("pending"),d=lt(!1),u=lt(!1),s=lt(null),o=sr(),{switchChainAsync:S}=or(),{status:f,isReconnecting:p}=rr(),g=Yt(()=>{s.current&&(clearTimeout(s.current),s.current=null)},[]),x=Yt(async()=>{if(!(d.current||u.current||f!=="connected"||p)){d.current=!0,u.current=!0,v("pending"),s.current=setTimeout(()=>{d.current&&(v("error"),d.current=!1)},ar);try{await S({chainId:t.chainId}),g(),v("success"),c(je,n)}catch{g(),v("error")}finally{d.current=!1}}},[S,f,p,t.chainId,c,n,g]);Xt(()=>{d.current||u.current||n===je&&a==="pending"&&f==="connected"&&!p&&(e&&o!==t.chainId?x():(v("success"),c(je,n)))},[n,a,e,o,t.chainId,f,p,x,c]),Xt(()=>()=>g(),[g]);let i=()=>{a==="error"&&(u.current=!1,v("pending"))},h=!r&&a==="error",A=!r&&(a==="pending"||a==="error"),m=h?"var(--widget-status-failed)":"var(--widget-primary)";return ut("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 ${h?"cursor-pointer":"cursor-not-allowed"}`,style:{backgroundColor:`color-mix(in srgb, ${m} 12%, transparent)`,border:`1px solid color-mix(in srgb, ${m} 20%, transparent)`,color:m,borderRadius:"var(--widget-radius)"},onClick:h?i:void 0,children:ut("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:h?"Retry Switch":`Switch to ${t.name}`}),ve("div",{className:"flex flex-1 border-t",style:{borderColor:"var(--widget-border)"}}),ut("div",{className:"flex h-6 w-3 items-center justify-center rounded-full",children:[!r&&a==="pending"&&ve(K,{size:"5"}),(r||a==="success")&&ve(ee,{className:"h-8 w-8"}),h&&ve(we,{className:"h-[12px] w-[12px]"})]})]})}),A&&ve("button",{type:"button",className:"inline-flex h-12 items-center justify-center px-8 text-sm font-sans font-medium transition duration-150 cursor-pointer",style:{backgroundColor:"color-mix(in srgb, var(--widget-status-failed) 12%, transparent)",border:"1px solid color-mix(in srgb, var(--widget-status-failed) 20%, transparent)",color:"var(--widget-status-failed)",borderRadius:"var(--widget-radius)"},onClick:l,children:"Cancel"})]})},Zt=ir;import{waitForTransactionReceipt as pt,getGasPrice as ur}from"@wagmi/core";import{useCallback as ze,useEffect as He,useState as dr,useRef as rn}from"react";import{erc20Abi as Ge,decodeFunctionData as pr,encodeFunctionData as sn,maxUint256 as fr}from"viem";import{useAccount as mr,useConfig as gr,useSendTransaction as wr,useSwitchChain as hr,useWalletClient as vr}from"wagmi";import{useEffect as Jt,useRef as en,useState as tn}from"react";import{jsx as lr}from"react/jsx-runtime";var cr=({startTime:e,onExpired:t})=>{let[n,c]=tn(30),[l,r]=tn(!1),a=en(!1),v=en(t);v.current=t,Jt(()=>{a.current=!1},[e]),Jt(()=>{let u=()=>{let o=Date.now(),f=(e>9999999999?e:e*1e3)+30*1e3,p=Math.max(0,f-o),g=Math.floor(p/1e3);if(g<=0){c(0),a.current||(a.current=!0,r(!0),v.current());return}c(g),r(!1)};if(l)return;u();let s=setInterval(u,1e3);return()=>clearInterval(s)},[e,l]);let d=u=>{let s=Math.floor(u/60),o=u%60;return`${s.toString().padStart(2,"0")}:${o.toString().padStart(2,"0")}`};return l?null:lr("span",{className:"text-xs font-sans",children:d(n)})},nn=cr;import{jsx as le,jsxs as dt}from"react/jsx-runtime";function yr(e){return e.name==="UserRejectedRequestError"||e.message.includes("User rejected")||e.message.includes("rejected")||e.message.includes("denied")||e.message.includes("cancelled")||e.message.includes("canceled")}var ye="signingOrder";async function br(e,t,n,c,l){let r=e.transaction?.encoded,a=r?.to??e.to,v=r?.data??e.data,d=r?.value??e.value;if(!a)throw new Error('Transaction step missing "to" address');let u=r?.chainId,s=e.chainKey||l,o=u||(s?qe(s):void 0);if(!o)throw new Error(`Unknown chain: ${s}`);let S=Ze()[o],f=await n({account:t,chain:S,to:a,data:v||"0x",value:BigInt(d||"0")});return await pt(c,{hash:f,chainId:o}),f}async function xr(e,t,n,c,l){let r=e.transaction?.encoded,a=r?.to??e.to,v=r?.data??e.data;if(!a||!v)return!1;let d,u;try{let{functionName:A,args:m}=pr({abi:Ge,data:v});if(A!=="approve"||!m||m.length<2)return!1;d=m[0],u=m[1]}catch{return!1}let s=e.chainKey||l.srcChainKey,o=r?.chainId||(s?qe(s):void 0);if(!o)return!1;let f=await kt(o).readContract({address:a,abi:Ge,functionName:"allowance",args:[t,d]});if(f>=u)return!0;let p=Ze()[o],g=await ur(c,{chainId:o}),x={account:t,chain:p,to:a,value:0n,gas:150000n,gasPrice:g};if(f>0n){let A=sn({abi:Ge,functionName:"approve",args:[d,0n]}),m=await n({...x,data:A});await pt(c,{hash:m,chainId:o})}let i=sn({abi:Ge,functionName:"approve",args:[d,fr]}),h=await n({...x,data:i});return await pt(c,{hash:h,chainId:o}),!0}var Cr=({base:e,baseAmount:t,quote:n,quoteAmount:c,userAddress:l,reviewState:r,goToNextStep:a,cancel:v,isWrappingPair:d,isUnwrappingPair:u,restartSigningFlow:s,onSwapInitiated:o,onOrderSubmitted:S,onSwapSubmitted:f,startPolling:p,trackNativeTransaction:g})=>{let x=re(ye,r),[i,h]=dr("idle"),A=rn(!1),m=rn(null),O=gr(),{isReconnecting:W}=mr(),{rfqQuote:y,stop:k,refresh:q}=Fe(),{data:N}=vr({chainId:e.chainId}),{switchChain:I}=hr(),{sendTransactionAsync:E}=wr(),U=y?._receivedAt??0,M=ze(()=>U?Date.now()>=U+30*1e3:!1,[U]),Y=ze(async()=>{if(A.current||i!=="idle")return;if(!y?.id||!y?._receivedAt){h("error");return}if(!jt(y.id,y._receivedAt).canSubmit){h("stale");return}A.current=!0;try{if(!N)throw new Error("Wallet client not available");Ht();let w=y.userSteps??[],P;for(let $ of w)if($.type==="TRANSACTION"){h("submitting");let H=$.chainKey||y.srcChainKey,de=H?qe(H):void 0;if(de&&N.chain?.id!==de&&(await I({chainId:de}),await new Promise(ae=>setTimeout(ae,800))),await xr($,l,E,O,y))continue;P=await br($,l,E,O,y.srcChainKey),g(P,$.description||`Tx on ${H}`)}else $.type==="SIGNATURE"&&(h("signing"),await Vt({quote:y,signatureStep:$,userAddress:l,walletClient:N}));zt(y.id,y._receivedAt),S?.(y.id),p(y.id,{baseToken:e,quoteToken:n}),o?.(),k(),h("success"),a(ye,r),f?.(y.id)}catch(w){w instanceof Error&&yr(w),h("error")}finally{A.current=!1}},[i,y,N,e,n,l,k,p,a,r,f,I,E,o,S,g,O]);He(()=>{if(r===ye&&k(),x&&i!=="success"){h("success"),a(ye,r);return}if(i==="success"){a(ye,r);return}if(r===ye&&i==="idle"&&!y?.id){h("refreshingQuote"),q();return}if(r===ye&&i==="idle"&&N&&!A.current&&!W){let C=y?.id||null;C&&m.current!==C&&(m.current=C,Y())}},[x,r,i,N,W,Y,a,y?.id,q,k]),He(()=>{i==="refreshingQuote"&&y?.id&&h("idle")},[i,y?.id]),He(()=>{r!==ye&&(m.current=null)},[r]),He(()=>{let C=setInterval(()=>{M()&&!A.current&&i!=="submitting"&&i!=="success"&&h("stale")},1e3);return()=>clearInterval(C)},[M,i]);let Z=()=>{i==="error"&&!A.current&&(m.current=null,h("idle"))},L=ze(()=>{m.current=null,h("refreshingQuote"),q()},[q]),T=ze(()=>{s?s(!0):v()},[s,v]),_=()=>i==="error"?"Retry swap":i==="signing"?"Sign Swap Order":i==="submitting"?"Submitting...":i==="refreshingQuote"?"Refreshing Quote...":i==="stale"?"Quote Stale":"Sign & Submit",F=!x&&(i==="error"||i==="stale"),Q=F?"var(--widget-status-failed)":"var(--widget-primary)";return dt("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 ${F?"cursor-pointer":"cursor-not-allowed"}`,style:{backgroundColor:`color-mix(in srgb, ${Q} 12%, transparent)`,border:`1px solid color-mix(in srgb, ${Q} 20%, transparent)`,color:Q,borderRadius:"var(--widget-radius)"},onClick:!x&&i==="error"?Z:i==="stale"?T:void 0,children:dt("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:_()}),le("div",{className:"flex flex-1 border-t",style:{borderColor:"var(--widget-border)"}}),U>0&&i!=="success"&&i!=="error"&&i!=="stale"&&le(nn,{startTime:U,onExpired:()=>h("stale")}),dt("div",{className:"flex h-6 w-3 items-center justify-center rounded-full",children:[!x&&(i==="idle"||i==="signing"||i==="submitting"||i==="refreshingQuote")&&le(K,{size:"5"}),(x||i==="success")&&le(ee,{className:"h-8 w-8"}),!x&&(i==="error"||i==="stale")&&le(we,{className:"h-[12px] w-[12px]"})]})]})}),!x&&(i==="error"||i==="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:v,children:"Cancel"})]})},on=Cr;import{useEffect as Sr}from"react";import{jsx as j,jsxs as ln}from"react/jsx-runtime";var Rr=()=>ln("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"})]}),Tr="trackingTx",an={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}},Ar=({orderHash:e,base:t,quote:n,baseAmount:c,quoteAmount:l,reviewState:r,onNewSwap:a,onRetry:v,status:d})=>{let u=re(Tr,r),s=an[d]||an.pending,o=se(p=>p.explorerUrl);Sr(()=>{if(d==="completed"){let p=setTimeout(a,15e3);return()=>clearTimeout(p)}},[d,a]);let S=()=>{d==="failed"?v():(d==="completed"||d==="cancelled")&&o&&window.open(o,"_blank","noopener,noreferrer")},f=s.statusVar;return 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, ${f} 12%, transparent)`,border:`1px solid color-mix(in srgb, ${f} 20%, transparent)`,color:f,borderRadius:"var(--widget-radius)"},onClick:s.clickable?S:void 0,children:ln("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(Et,{}):j(Rr,{})})]})})})},cn=Ar;import{useCallback as un,useEffect as dn,useState as kr,useRef as ft}from"react";import{parseUnits as Nr}from"viem";import{useAccount as Ir,useWriteContract as Er}from"wagmi";import{jsx as Ce,jsxs as mt}from"react/jsx-runtime";var $r=15e3,Ke="unwrapping",Or=({needsToUnwrap:e,amount:t,chainId:n,token:c,reviewState:l,setReviewState:r,goToNextStep:a,cancel:v,delayedClose:d})=>{let u=re(Ke,l),[s,o]=kr("idle"),S=Gt(),{writeContractAsync:f}=Er(),{address:p}=he(),g=De(),x=ft(!1),i=ft(!1),h=ft(null),{status:A}=Ir(),m=un(()=>{h.current&&(clearTimeout(h.current),h.current=null)},[]),O=un(async()=>{if(!(x.current||i.current||!p||A!=="connected")){x.current=!0,i.current=!0,o("pending"),h.current=setTimeout(()=>{x.current&&(o("error"),x.current=!1)},$r);try{let N=B(n);if(!N)throw new Error(`No config for chain ${n}`);let I=N.wrappedAsset.decimals??N.nativeAsset.decimals,E=Nr(t.toString(),I);await S.mutateAsync({chainId:n,accountAddress:p,amountRaw:E,writeContractAsync:f});let U={symbol:N.nativeAsset.symbol,name:N.nativeAsset.name,address:We,decimals:N.nativeAsset.decimals,chainId:n},M={symbol:N.wrappedAsset.symbol,name:N.wrappedAsset.name,address:N.wrappedAsset.address,decimals:N.wrappedAsset.decimals,chainId:n};g({type:"unwrap",tokens:[{asset:U,userAddress:p},{asset:M,userAddress:p}]}),m(),o("success"),a(Ke,l),await d()}catch{m(),o("error")}finally{x.current=!1}}},[p,A,n,t,S,f,g,a,l,d,m]);dn(()=>{x.current||i.current||l===Ke&&s==="idle"&&A==="connected"&&(e?O():(o("success"),a(Ke,l)))},[l,s,e,A,O,a]),dn(()=>()=>m(),[m]);let W=()=>{s==="error"&&(i.current=!1,o("idle"))},y=!u&&s==="error",k=!u&&(s==="pending"||s==="idle"||s==="error"),q=y?"var(--widget-status-failed)":"var(--widget-primary)";return mt("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, ${q} 12%, transparent)`,border:`1px solid color-mix(in srgb, ${q} 20%, transparent)`,color:q,borderRadius:"var(--widget-radius)"},onClick:y?W:void 0,children:mt("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":c?`Unwrap ${c.symbol}`:"Unwrap Native Token"}),Ce("div",{className:"flex flex-1 border-t",style:{borderColor:"var(--widget-border)"}}),mt("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:v,children:"Cancel"})]})},pn=Or;import{useCallback as fn,useEffect as mn,useState as Pr,useRef as gt}from"react";import{parseUnits as Ur}from"viem";import{useAccount as Mr,useWriteContract as Wr}from"wagmi";import{jsx as Se,jsxs as wt}from"react/jsx-runtime";var Lr=15e3,Xe="wrapping",_r=({needsToWrap:e,amount:t,chainId:n,token:c,reviewState:l,setReviewState:r,goToNextStep:a,cancel:v,delayedClose:d,isWrappingPair:u})=>{let s=re(Xe,l),[o,S]=Pr("idle"),f=Kt(),{writeContractAsync:p}=Wr(),{address:g}=he(),x=De(),i=gt(!1),h=gt(!1),A=gt(null),{status:m}=Mr(),O=fn(()=>{A.current&&(clearTimeout(A.current),A.current=null)},[]),W=fn(async()=>{if(!(i.current||h.current||!g||m!=="connected")){i.current=!0,h.current=!0,S("pending"),A.current=setTimeout(()=>{i.current&&(S("error"),i.current=!1)},Lr);try{let I=B(n);if(!I)throw new Error(`No config for chain ${n}`);let E=Ur(t.toString(),I.nativeAsset.decimals);await f.mutateAsync({chainId:n,accountAddress:g,amountRaw:E,writeContractAsync:p});let U={symbol:I.nativeAsset.symbol,name:I.nativeAsset.name,address:We,decimals:I.nativeAsset.decimals,chainId:n},M={symbol:I.wrappedAsset.symbol,name:I.wrappedAsset.name,address:I.wrappedAsset.address,decimals:I.wrappedAsset.decimals,chainId:n};x({type:"wrap",tokens:[{asset:U,userAddress:g},{asset:M,userAddress:g}]}),O(),S("success"),a(Xe,l),u&&await d()}catch{O(),S("error")}finally{i.current=!1}}},[g,m,n,t,f,p,x,a,l,d,u,O]);mn(()=>{i.current||h.current||l===Xe&&o==="idle"&&m==="connected"&&(e?W():(S("success"),a(Xe,l)))},[l,o,e,m,W,a]),mn(()=>()=>O(),[O]);let y=()=>{o==="error"&&(h.current=!1,S("idle"))},k=!s&&o==="error",q=!s&&(o==="pending"||o==="idle"||o==="error"),N=k?"var(--widget-status-failed)":"var(--widget-primary)";return wt("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:wt("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":c?`Wrap ${c.symbol}`:"Wrap Native Token"}),Se("div",{className:"flex flex-1 border-t",style:{borderColor:"var(--widget-border)"}}),wt("div",{className:"flex h-6 w-3 items-center justify-center rounded-full",children:[!s&&(o==="pending"||o==="idle")&&Se(K,{size:"5"}),(s||o==="success")&&Se(ee,{className:"h-8 w-8"}),k&&Se(we,{className:"h-[12px] w-[12px]"})]})]})}),q&&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:v,children:"Cancel"})]})},gn=_r;import{jsx as z,jsxs as Fr}from"react/jsx-runtime";var ma=({base:e,baseAmount:t,quote:n,quoteAmount:c,userAddress:l,isWrappingPair:r,isUnwrappingPair:a,isBaseGasToken:v,isQuoteGasToken:d,reviewActionProps:u,reviewState:s,setReviewState:o,trackedOrderHash:S,setTrackedOrderHash:f,txStatus:p,onSwapSubmitted:g,onSwapInitiated:x,onOrderSubmitted:i,onStaleQuoteRestart:h,setExitHandler:A,setRetryHandler:m,startPolling:O,trackNativeTransaction:W})=>{let{rfqQuote:y,status:k,liquidityError:q,routingError:N,sizeCapError:I,stop:E,clear:U}=Fe(),{clearForm:M}=Ne(),Y=Dr(),{swapButtonVariant:Z,widgetType:L}=Ae(),T=L==="compact",[_,F]=qr(!1),Q=wn(!1),C=wn(null),w=r,P=a,$=!r&&!a,H=Y!==e?.chainId&&(w||P||$),de=B(e.chainId),Ye={chainId:e.chainId,name:de?.displayName??`Chain ${e.chainId}`},ae=ue((V,Pe)=>{if(Pe!==V)return;if(V==="chain"){if(w){o("wrapping");return}if(P){o("unwrapping");return}o("signingOrder");return}if(V==="signingOrder"){o("trackingTx");return}if(V==="wrapping"){if(!r){o("signingOrder");return}o("wrapSuccess");return}if(V==="unwrapping"){o("wrapSuccess");return}let Ct=Rt(V);Ct&&o(Ct)},[o,r,w,P,$]),G=ue(()=>H?"chain":w?"wrapping":P?"unwrapping":$?"signingOrder":null,[H,w,P,$]),ne=ue(()=>{o(null),M()},[M,o]),pe=ue(async()=>{o("wrapSuccess");for(let V=0;V<3;V++)await Je(700);ne()},[ne,o]),fe=ue(async()=>{U(),o("cancelled");for(let V=0;V<3;V++)await Je(500);ne()},[U,ne,o]),J=ue(()=>{S&&(se.getState().stopTracking(),o(null),f(null),M())},[S,o,f,M]),me=ue(()=>{o(null),f(null),Q.current=!0,h?.()},[o,f,h]),$e=ue(()=>{u&&o(G())},[G,u,o]),be=ue((V=!1)=>{V?(Q.current=!0,o(null),h?.()):(o(null),C.current=setTimeout(()=>{u&&(o(G()),F(!1))},100))},[o,u,G,h]);Re(()=>{s!==null&&E()},[s,E]),Re(()=>{s!==null&&_&&F(!1)},[s,_]),Re(()=>{A?.(J)},[A,J]),Re(()=>(se.getState().setExitHandler(J),()=>se.getState().setExitHandler(null)),[J]),Re(()=>{m?.(me)},[m,me]),Re(()=>()=>{C.current&&clearTimeout(C.current)},[]),Re(()=>{Q.current&&k==="fresh"&&y?.id&&(Q.current=!1,o("signingOrder"))},[k,y?.id,o]);let Te=V=>{if(!V)return{backgroundColor:Z==="default"?"var(--widget-muted)":"transparent",color:"var(--widget-muted-foreground)",border:Z!=="default"?"1px solid var(--widget-border)":"none",borderRadius:"var(--widget-radius)"};switch(Z){case"outline":return{backgroundColor:"transparent",color:"var(--widget-primary)",border:"1px solid var(--widget-primary)",borderRadius:"var(--widget-radius)"};case"ghost":return{backgroundColor:"transparent",color:"var(--widget-primary)",border:"none",borderRadius:"var(--widget-radius)"};default:return{backgroundColor:"var(--widget-primary)",color:"var(--widget-primary-foreground)",borderRadius:"var(--widget-radius)"}}},Oe=`w-full ${T?"py-2":"py-3"} text-sm font-sans font-medium transition-colors cursor-pointer mt-1`;if(s===null&&!r&&!a){if(_)return z("button",{className:Oe,disabled:!0,style:{...Te(!1),opacity:.6,cursor:"not-allowed"},children:"Getting fresh quote..."});let V=()=>q?"Insufficient Liquidity":N?"Route Not Available":I?"Size Cap Exceeded":!y&&k==="polling"?"Getting Quote...":y?"Swap":"Enter Amount",Pe=!!u;return z("button",{onClick:Pe?$e:void 0,disabled:!Pe,className:`${Oe} disabled:opacity-40 disabled:cursor-not-allowed`,style:Te(Pe),children:V()})}return s===null&&a?z("button",{onClick:u?$e:void 0,disabled:!u,className:`${Oe} disabled:opacity-40 disabled:cursor-not-allowed`,style:Te(!!u),children:"Unwrap"}):s===null&&r?z("button",{onClick:u?$e:void 0,disabled:!u,className:`${Oe} 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 ${T?"py-2":"py-3"} text-sm font-sans font-medium cursor-default`,style:{backgroundColor:"color-mix(in srgb, var(--widget-status-completed) 15%, transparent)",color:"var(--widget-status-completed)",border:"1px solid color-mix(in srgb, var(--widget-status-completed) 20%, transparent)",borderRadius:"var(--widget-radius)"},children:"Order Placed"})}):s==="wrapSuccess"?z("div",{className:"flex flex-col gap-2 w-full",children:z("button",{className:`w-full ${T?"py-2":"py-3"} text-sm font-sans font-medium cursor-default`,style:{backgroundColor:"color-mix(in srgb, var(--widget-status-completed) 15%, transparent)",color:"var(--widget-status-completed)",border:"1px solid color-mix(in srgb, var(--widget-status-completed) 20%, transparent)",borderRadius:"var(--widget-radius)"},children:r?"Wrapped Successfully":"Unwrapped Successfully"})}):s==="cancelled"?z("div",{className:"flex flex-col gap-2 w-full",children:z("button",{onClick:ne,className:`w-full ${T?"py-2":"py-3"} text-sm font-sans font-medium cursor-pointer`,style:{backgroundColor:"color-mix(in srgb, var(--widget-status-failed) 15%, transparent)",color:"var(--widget-status-failed)",border:"1px solid color-mix(in srgb, var(--widget-status-failed) 20%, transparent)",borderRadius:"var(--widget-radius)"},children:"Order Cancelled"})}):Fr("div",{className:"flex w-full",children:[s==="chain"&&H&&z(Zt,{requiredChain:Ye,needsChainSwitch:H&&Y!==e.chainId,reviewState:s,goToNextStep:ae,cancel:fe}),s==="wrapping"&&w&&z(gn,{needsToWrap:w,amount:t,chainId:e.chainId,token:e,reviewState:s,setReviewState:o,goToNextStep:ae,cancel:fe,delayedClose:pe,isWrappingPair:r}),s==="unwrapping"&&P&&z(pn,{needsToUnwrap:P,amount:t,chainId:e.chainId,token:e,reviewState:s,setReviewState:o,goToNextStep:ae,cancel:fe,delayedClose:pe}),s==="signingOrder"&&$&&z(on,{base:e,baseAmount:t,quote:n,quoteAmount:c,userAddress:l,reviewState:s,goToNextStep:ae,cancel:fe,restartSigningFlow:be,onSwapInitiated:x,onOrderSubmitted:i,isWrappingPair:r,isUnwrappingPair:a,onSwapSubmitted:g,startPolling:O,trackNativeTransaction:W}),s==="trackingTx"&&S&&z(cn,{orderHash:S,base:e,quote:n,baseAmount:t,quoteAmount:c,reviewState:s,status:p,onNewSwap:J,onRetry:me}),s&&!["chain","wrapping","unwrapping","approval","signingOrder","trackingTx","success","wrapSuccess","cancelled"].includes(s)&&z("button",{disabled:!0,className:`w-full ${T?"py-2":"py-3"} text-sm font-sans font-medium`,style:{backgroundColor:"var(--widget-muted)",color:"var(--widget-muted-foreground)",borderRadius:"var(--widget-radius)"},children:"Processing..."})]})};function ht(e){try{let t=new URL(e).pathname.split("/"),n=t[t.length-1];return n&&n.startsWith("0x")?n:null}catch{return null}}import{useState as vt,useCallback as Vr,useRef as yt,useEffect as bt}from"react";import{useShallow as Br}from"zustand/react/shallow";import{jsx as b,jsxs as R}from"react/jsx-runtime";var hn={pending:"var(--widget-status-pending)",received:"var(--widget-status-received)",completed:"var(--widget-status-completed)",failed:"var(--widget-status-failed)",cancelled:"var(--widget-status-failed)"},Qr=({status:e})=>{let t=hn[e]??hn.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 jr(e){if(e===0)return"0";let t=Math.abs(e);return t>=1e9?`${(e/1e9).toFixed(2)}B`:t>=1e6?`${(e/1e6).toFixed(2)}M`:t>=1e4?`${(e/1e3).toFixed(2)}K`:t>=1e3?e.toFixed(1):t>=100?e.toFixed(2):t>=1?e.toFixed(4):e.toFixed(6)}function vn(e){let t=e.length;return t<=4?48:t<=6?40:t<=8?34:28}var xt=()=>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"})]}),Hr=({orderHash:e,base:t,quote:n,baseAmount:c,quoteAmount:l,status:r})=>{let[a,v]=vt(!1),[d,u]=vt(!0),s=yt(null),o=yt(Date.now()),[S,f]=vt(null),p=yt(null),{isRecipientInputOpen:g,recipient:x,explorerUrl:i}=se(Br(w=>({isRecipientInputOpen:w.isRecipientInputOpen,recipient:w.recipient,explorerUrl:w.explorerUrl})));bt(()=>{r==="received"&&(s.current=Date.now())},[r]),bt(()=>{if(r==="completed"&&!S){let w=s.current||o.current;f((Date.now()-w)/1e3)}},[r,S]),bt(()=>()=>{p.current&&clearTimeout(p.current)},[]);let h=Vr(()=>{if(!navigator.clipboard?.writeText)return;let w=i?ht(i)??e:e;navigator.clipboard.writeText(w).then(()=>{v(!0),p.current&&clearTimeout(p.current),p.current=setTimeout(()=>v(!1),2e3)}).catch(()=>{})},[e,i]),A=ke(c),m=ke(l),O=r==="completed"||r==="failed"||r==="cancelled",W=!O,y=c&&l?c/l:0,k=y>0&&y<1,q=k?1/y:y,N=k?t:n,I=k?n:t,E=t?.price?`\u2248 $${(k?t.price:t.price*y).toFixed(2)}`:"",U=B(t.chainId),M=B(n.chainId),Y=U?.displayName??`Chain ${t.chainId}`,Z=M?.displayName??`Chain ${n.chainId}`,L=t.chainId!==n.chainId,T=U?.estimatedTimeMs??0,_=M?.estimatedTimeMs??0,F=(L?T+_:T)/1e3,Q=i?ht(i)??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:Y})]})]}),R("div",{className:"text-right",children:[b("p",{className:"font-thin tracking-tight font-sans",style:{color:"var(--widget-foreground)",fontSize:`${vn(A)}px`,transition:"font-size 0.1s ease-out"},children:A}),t.price&&R("p",{className:"text-xs mt-1 font-sans",style:{color:"var(--widget-muted-foreground)"},children:["$",(t.price*c).toFixed(2)]})]})]})}),R("div",{className:"relative",children:[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(Qr,{status:r})})})]}),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:`${vn(m)}px`,transition:"font-size 0.1s ease-out"},children:m}),n.price&&R("p",{className:"text-xs mt-1 font-sans",style:{color:"var(--widget-muted-foreground)"},children:["$",(n.price*l).toFixed(2)]})]})]})})]}),g&&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:[jr(q)," ",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*c).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"}),i?R("a",{href:i,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 transition-colors hover:opacity-80",style:{color:"var(--widget-secondary-foreground)"},children:[b("span",{children:a?"Copied!":C}),b(xt,{})]}):R("button",{type:"button",onClick:h,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(xt,{})]})]}),R("div",{className:"flex justify-between text-2xs",style:{color:"var(--widget-muted-foreground)"},children:[b("span",{children:O?"Speed":"Est. Time"}),b("span",{style:{color:"var(--widget-secondary-foreground)"},children:S?`${S.toFixed(2)}s`:F>0?`~${F}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(xt,{})]})]})]})})]})]})},Ra=Hr;export{Rn as a,De as b,Jr as c,ht as d,is as e,Fe as f,Ln as g,ds as h,hs as i,Ss as j,Es as k,Ps as l,jn as m,Vt as n,zn as o,jt as p,zt as q,Ht as r,Gt as s,Kt as t,ma as u,Ra as v};
@@ -1,2 +1,2 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
2
- var _chunkD7GULMHEcjs = require('./chunk-D7GULMHE.cjs');var _react = require('react');function C(){let{supportedInputTokens:t,supportedOutputTokens:i,supportedInputChains:n,supportedOutputChains:o,prioritizedInputTokens:p,prioritizedInputChains:u}=_chunkD7GULMHEcjs.b.call(void 0, ),e=_chunkD7GULMHEcjs.d.call(void 0, f=>f.isInverted);return _react.useMemo.call(void 0, ()=>({effectiveInputTokens:e?i:t,effectiveOutputTokens:e?t:i,effectiveInputChains:e?o:n,effectiveOutputChains:e?n:o,effectivePrioritizedInputTokens:e?[]:p,effectivePrioritizedInputChains:e?[]:u}),[e,t,i,n,o,p,u])}exports.a = C;
2
+ var _chunk3PGCHNG2cjs = require('./chunk-3PGCHNG2.cjs');var _react = require('react');function C(){let{supportedInputTokens:t,supportedOutputTokens:i,supportedInputChains:n,supportedOutputChains:o,prioritizedInputTokens:p,prioritizedInputChains:u}=_chunk3PGCHNG2cjs.b.call(void 0, ),e=_chunk3PGCHNG2cjs.d.call(void 0, f=>f.isInverted);return _react.useMemo.call(void 0, ()=>({effectiveInputTokens:e?i:t,effectiveOutputTokens:e?t:i,effectiveInputChains:e?o:n,effectiveOutputChains:e?n:o,effectivePrioritizedInputTokens:e?[]:p,effectivePrioritizedInputChains:e?[]:u}),[e,t,i,n,o,p,u])}exports.a = C;
@@ -1,2 +1,2 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }"use client";
2
- var _chunkD7GULMHEcjs = require('./chunk-D7GULMHE.cjs');var _chunkK3RTTHBScjs = require('./chunk-K3RTTHBS.cjs');var _chunk34N36GUDcjs = require('./chunk-34N36GUD.cjs');var _zustand = require('zustand');var _react = require('react');var F=_zustand.create.call(void 0, )(c=>({baseToken:null,quoteToken:null,setBaseTokenDirect:i=>c({baseToken:i}),setQuoteTokenDirect:i=>c({quoteToken:i}),swapTokensDirect:()=>c(i=>({baseToken:i.quoteToken,quoteToken:i.baseToken}))}));function G(c){let{data:i,isLoading:m}=_chunkK3RTTHBScjs.z.call(void 0, ),o=F(),f=_react.useRef.call(void 0, !1),e=_nullishCoalesce(_optionalChain([c, 'optionalAccess', _2 => _2.defaultBaseToken]), () => (null)),r=_nullishCoalesce(_optionalChain([c, 'optionalAccess', _3 => _3.defaultQuoteToken]), () => (null));_react.useEffect.call(void 0, ()=>{if(!i||i.length===0||f.current)return;f.current=!0;let u=T=>_nullishCoalesce(i.find(p=>p.chainId===T.chainId&&p.address.toLowerCase()===T.address.toLowerCase()), () => (null)),a=e?u(e):null,l=r?u(r):null;a&&l&&a.chainId===l.chainId&&a.address.toLowerCase()===l.address.toLowerCase()?(o.setBaseTokenDirect(a),o.setQuoteTokenDirect(null)):(o.setBaseTokenDirect(a),o.setQuoteTokenDirect(l))},[i,e,r,o]);let A=_react.useCallback.call(void 0, u=>{if(!u){o.setBaseTokenDirect(null);return}let a=F.getState();a.quoteToken&&u.chainId===a.quoteToken.chainId&&u.address.toLowerCase()===a.quoteToken.address.toLowerCase()?o.swapTokensDirect():o.setBaseTokenDirect(u)},[o]),S=_react.useCallback.call(void 0, u=>{if(!u){o.setQuoteTokenDirect(null);return}let a=F.getState();a.baseToken&&u.chainId===a.baseToken.chainId&&u.address.toLowerCase()===a.baseToken.address.toLowerCase()?o.swapTokensDirect():o.setQuoteTokenDirect(u)},[o]),h=_react.useCallback.call(void 0, ()=>{o.swapTokensDirect()},[o]);return{baseToken:o.baseToken,quoteToken:o.quoteToken,setBaseToken:A,setQuoteToken:S,swapTokens:h,isLoading:m}}var _viem = require('viem');var _shallow = require('zustand/react/shallow');var M=(c,i,m,o)=>{let{address:f}=_chunk34N36GUDcjs.a.call(void 0, ),{baseToken:e,quoteToken:r,setBaseToken:A,setQuoteToken:S,swapTokens:h,isLoading:u}=G({defaultBaseToken:c,defaultQuoteToken:i}),{baseAmount:a,quoteAmount:l,setBaseAmount:T,setQuoteAmount:p,clearAmounts:v}=_chunkD7GULMHEcjs.d.call(void 0, _shallow.useShallow.call(void 0, t=>({baseAmount:t.baseAmount,quoteAmount:t.quoteAmount,setBaseAmount:t.setBaseAmount,setQuoteAmount:t.setQuoteAmount,clearAmounts:t.clearAmounts}))),{data:y}=_chunkK3RTTHBScjs.A.call(void 0, _optionalChain([e, 'optionalAccess', _4 => _4.address]),_optionalChain([e, 'optionalAccess', _5 => _5.chainId])),{data:P}=_chunkK3RTTHBScjs.A.call(void 0, _optionalChain([r, 'optionalAccess', _6 => _6.address]),_optionalChain([r, 'optionalAccess', _7 => _7.chainId])),n=_react.useMemo.call(void 0, ()=>{if(!e)return null;let t=_nullishCoalesce(_optionalChain([y, 'optionalAccess', _8 => _8.price]), () => (e.price));return t===e.price?e:{...e,price:t}},[e,_optionalChain([y, 'optionalAccess', _9 => _9.price])]),s=_react.useMemo.call(void 0, ()=>{if(!r)return null;let t=_nullishCoalesce(_optionalChain([P, 'optionalAccess', _10 => _10.price]), () => (r.price));return t===r.price?r:{...r,price:t}},[r,_optionalChain([P, 'optionalAccess', _11 => _11.price])]),{baseBalance:B,quoteBalance:b,isLoading:R}=_chunkK3RTTHBScjs.L.call(void 0, f,n,s),g=_react.useMemo.call(void 0, ()=>!B||B.raw==="0"?null:B,[B]),I=_react.useMemo.call(void 0, ()=>!b||b.raw==="0"?null:b,[b]),q=_react.useMemo.call(void 0, ()=>{if(!_optionalChain([n, 'optionalAccess', _12 => _12.chainId]))return!1;let t=_chunkK3RTTHBScjs.c.call(void 0, n.chainId);return n.address.toLowerCase()===_optionalChain([t, 'optionalAccess', _13 => _13.gasToken, 'access', _14 => _14.address, 'optionalAccess', _15 => _15.toLowerCase, 'call', _16 => _16()])},[n]),L=_react.useMemo.call(void 0, ()=>{if(!_optionalChain([s, 'optionalAccess', _17 => _17.chainId]))return!1;let t=_chunkK3RTTHBScjs.c.call(void 0, s.chainId);return s.address.toLowerCase()===_optionalChain([t, 'optionalAccess', _18 => _18.gasToken, 'access', _19 => _19.address, 'optionalAccess', _20 => _20.toLowerCase, 'call', _21 => _21()])},[s]),O=_react.useMemo.call(void 0, ()=>{if(!q||!_optionalChain([n, 'optionalAccess', _22 => _22.chainId])||!s||n.chainId!==s.chainId||n.chainId===988)return!1;let t=_chunkK3RTTHBScjs.c.call(void 0, n.chainId);return s.address.toLowerCase()===_optionalChain([t, 'optionalAccess', _23 => _23.wrappedAsset, 'access', _24 => _24.address, 'optionalAccess', _25 => _25.toLowerCase, 'call', _26 => _26()])},[q,n,s]),z=_react.useMemo.call(void 0, ()=>{if(!_optionalChain([n, 'optionalAccess', _27 => _27.chainId])||!s||!L||n.chainId!==s.chainId||n.chainId===988)return!1;let t=_chunkK3RTTHBScjs.c.call(void 0, n.chainId);return n.address.toLowerCase()===_optionalChain([t, 'optionalAccess', _28 => _28.wrappedAsset, 'access', _29 => _29.address, 'optionalAccess', _30 => _30.toLowerCase, 'call', _31 => _31()])},[n,s,L]),H=_react.useMemo.call(void 0, ()=>({raw:_nullishCoalesce(_optionalChain([g, 'optionalAccess', _32 => _32.raw]), () => ("0")),formatted:_nullishCoalesce(_optionalChain([g, 'optionalAccess', _33 => _33.formatted]), () => ("0"))}),[g]),J=_react.useMemo.call(void 0, ()=>({raw:_nullishCoalesce(_optionalChain([I, 'optionalAccess', _34 => _34.raw]), () => ("0")),formatted:_nullishCoalesce(_optionalChain([I, 'optionalAccess', _35 => _35.formatted]), () => ("0"))}),[I]),K=_react.useMemo.call(void 0, ()=>!n||typeof a!="number"||n.decimals===void 0||n.decimals===null?null:_viem.parseUnits.call(void 0, a.toFixed(n.decimals),n.decimals).toString(),[n,a]),V=_react.useMemo.call(void 0, ()=>!s||typeof l!="number"||s.decimals===void 0||s.decimals===null?null:_viem.parseUnits.call(void 0, l.toFixed(s.decimals),s.decimals).toString(),[s,l]),X=_react.useCallback.call(void 0, async t=>{A(t),p(null),_optionalChain([m, 'optionalCall', _36 => _36(t)])},[A,p,m]),Y=_react.useCallback.call(void 0, async t=>{S(t),_optionalChain([o, 'optionalCall', _37 => _37(t)])},[S,o]),Z=_react.useCallback.call(void 0, t=>T(t),[T]),_=_react.useCallback.call(void 0, t=>p(t),[p]),$=_react.useCallback.call(void 0, ()=>{h(),_chunkD7GULMHEcjs.d.getState().toggleInverted(),r&&_optionalChain([m, 'optionalCall', _38 => _38(r)]),e&&_optionalChain([o, 'optionalCall', _39 => _39(e)])},[h,e,r,m,o]),j=_react.useCallback.call(void 0, ()=>v(),[v]);return{baseToken:n,baseAmount:a,quoteToken:s,quoteAmount:l,isBaseGasToken:q,isQuoteGasToken:L,isWrappingPair:O,isUnwrappingPair:z,baseBalance:H,quoteBalance:J,baseAmountRaw:K,quoteAmountRaw:V,isBaseBalanceLoading:R,isQuoteBalanceLoading:R,isRegistryLoading:u,setBaseToken:X,setQuoteToken:Y,setBaseAmount:Z,setQuoteAmount:_,swapTokens:$,clearForm:j}};var _jsxruntime = require('react/jsx-runtime');var N=_react.createContext.call(void 0, null),Ie= exports.d =({children:c,defaultBaseToken:i,defaultQuoteToken:m,onBaseTokenChange:o,onQuoteTokenChange:f})=>{let e=M(i,m,o,f),r=_react.useMemo.call(void 0, ()=>e,[e.baseToken,e.quoteToken,e.baseAmount,e.quoteAmount,e.isBaseGasToken,e.isQuoteGasToken,e.isWrappingPair,e.isUnwrappingPair,e.baseBalance,e.quoteBalance,e.baseAmountRaw,e.quoteAmountRaw,e.isBaseBalanceLoading,e.isQuoteBalanceLoading,e.setBaseToken,e.setQuoteToken,e.setBaseAmount,e.setQuoteAmount,e.swapTokens,e.clearForm,e.isRegistryLoading]);return _jsxruntime.jsx.call(void 0, N.Provider,{value:r,children:c})},qe= exports.e =()=>{let c=_react.useContext.call(void 0, N);if(!c)throw new Error("useSwapFormContext must be used within SwapFormProvider");return c};exports.a = F; exports.b = G; exports.c = M; exports.d = Ie; exports.e = qe;
2
+ var _chunk3PGCHNG2cjs = require('./chunk-3PGCHNG2.cjs');var _chunk4S3B2JQYcjs = require('./chunk-4S3B2JQY.cjs');var _chunk34N36GUDcjs = require('./chunk-34N36GUD.cjs');var _zustand = require('zustand');var _react = require('react');var F=_zustand.create.call(void 0, )(c=>({baseToken:null,quoteToken:null,setBaseTokenDirect:i=>c({baseToken:i}),setQuoteTokenDirect:i=>c({quoteToken:i}),swapTokensDirect:()=>c(i=>({baseToken:i.quoteToken,quoteToken:i.baseToken}))}));function G(c){let{data:i,isLoading:m}=_chunk4S3B2JQYcjs.z.call(void 0, ),o=F(),f=_react.useRef.call(void 0, !1),e=_nullishCoalesce(_optionalChain([c, 'optionalAccess', _2 => _2.defaultBaseToken]), () => (null)),r=_nullishCoalesce(_optionalChain([c, 'optionalAccess', _3 => _3.defaultQuoteToken]), () => (null));_react.useEffect.call(void 0, ()=>{if(!i||i.length===0||f.current)return;f.current=!0;let u=T=>_nullishCoalesce(i.find(p=>p.chainId===T.chainId&&p.address.toLowerCase()===T.address.toLowerCase()), () => (null)),a=e?u(e):null,l=r?u(r):null;a&&l&&a.chainId===l.chainId&&a.address.toLowerCase()===l.address.toLowerCase()?(o.setBaseTokenDirect(a),o.setQuoteTokenDirect(null)):(o.setBaseTokenDirect(a),o.setQuoteTokenDirect(l))},[i,e,r,o]);let A=_react.useCallback.call(void 0, u=>{if(!u){o.setBaseTokenDirect(null);return}let a=F.getState();a.quoteToken&&u.chainId===a.quoteToken.chainId&&u.address.toLowerCase()===a.quoteToken.address.toLowerCase()?o.swapTokensDirect():o.setBaseTokenDirect(u)},[o]),S=_react.useCallback.call(void 0, u=>{if(!u){o.setQuoteTokenDirect(null);return}let a=F.getState();a.baseToken&&u.chainId===a.baseToken.chainId&&u.address.toLowerCase()===a.baseToken.address.toLowerCase()?o.swapTokensDirect():o.setQuoteTokenDirect(u)},[o]),h=_react.useCallback.call(void 0, ()=>{o.swapTokensDirect()},[o]);return{baseToken:o.baseToken,quoteToken:o.quoteToken,setBaseToken:A,setQuoteToken:S,swapTokens:h,isLoading:m}}var _viem = require('viem');var _shallow = require('zustand/react/shallow');var M=(c,i,m,o)=>{let{address:f}=_chunk34N36GUDcjs.a.call(void 0, ),{baseToken:e,quoteToken:r,setBaseToken:A,setQuoteToken:S,swapTokens:h,isLoading:u}=G({defaultBaseToken:c,defaultQuoteToken:i}),{baseAmount:a,quoteAmount:l,setBaseAmount:T,setQuoteAmount:p,clearAmounts:v}=_chunk3PGCHNG2cjs.d.call(void 0, _shallow.useShallow.call(void 0, t=>({baseAmount:t.baseAmount,quoteAmount:t.quoteAmount,setBaseAmount:t.setBaseAmount,setQuoteAmount:t.setQuoteAmount,clearAmounts:t.clearAmounts}))),{data:y}=_chunk4S3B2JQYcjs.A.call(void 0, _optionalChain([e, 'optionalAccess', _4 => _4.address]),_optionalChain([e, 'optionalAccess', _5 => _5.chainId])),{data:P}=_chunk4S3B2JQYcjs.A.call(void 0, _optionalChain([r, 'optionalAccess', _6 => _6.address]),_optionalChain([r, 'optionalAccess', _7 => _7.chainId])),n=_react.useMemo.call(void 0, ()=>{if(!e)return null;let t=_nullishCoalesce(_optionalChain([y, 'optionalAccess', _8 => _8.price]), () => (e.price));return t===e.price?e:{...e,price:t}},[e,_optionalChain([y, 'optionalAccess', _9 => _9.price])]),s=_react.useMemo.call(void 0, ()=>{if(!r)return null;let t=_nullishCoalesce(_optionalChain([P, 'optionalAccess', _10 => _10.price]), () => (r.price));return t===r.price?r:{...r,price:t}},[r,_optionalChain([P, 'optionalAccess', _11 => _11.price])]),{baseBalance:B,quoteBalance:b,isLoading:R}=_chunk4S3B2JQYcjs.L.call(void 0, f,n,s),g=_react.useMemo.call(void 0, ()=>!B||B.raw==="0"?null:B,[B]),I=_react.useMemo.call(void 0, ()=>!b||b.raw==="0"?null:b,[b]),q=_react.useMemo.call(void 0, ()=>{if(!_optionalChain([n, 'optionalAccess', _12 => _12.chainId]))return!1;let t=_chunk4S3B2JQYcjs.c.call(void 0, n.chainId);return n.address.toLowerCase()===_optionalChain([t, 'optionalAccess', _13 => _13.gasToken, 'access', _14 => _14.address, 'optionalAccess', _15 => _15.toLowerCase, 'call', _16 => _16()])},[n]),L=_react.useMemo.call(void 0, ()=>{if(!_optionalChain([s, 'optionalAccess', _17 => _17.chainId]))return!1;let t=_chunk4S3B2JQYcjs.c.call(void 0, s.chainId);return s.address.toLowerCase()===_optionalChain([t, 'optionalAccess', _18 => _18.gasToken, 'access', _19 => _19.address, 'optionalAccess', _20 => _20.toLowerCase, 'call', _21 => _21()])},[s]),O=_react.useMemo.call(void 0, ()=>{if(!q||!_optionalChain([n, 'optionalAccess', _22 => _22.chainId])||!s||n.chainId!==s.chainId||n.chainId===988)return!1;let t=_chunk4S3B2JQYcjs.c.call(void 0, n.chainId);return s.address.toLowerCase()===_optionalChain([t, 'optionalAccess', _23 => _23.wrappedAsset, 'access', _24 => _24.address, 'optionalAccess', _25 => _25.toLowerCase, 'call', _26 => _26()])},[q,n,s]),z=_react.useMemo.call(void 0, ()=>{if(!_optionalChain([n, 'optionalAccess', _27 => _27.chainId])||!s||!L||n.chainId!==s.chainId||n.chainId===988)return!1;let t=_chunk4S3B2JQYcjs.c.call(void 0, n.chainId);return n.address.toLowerCase()===_optionalChain([t, 'optionalAccess', _28 => _28.wrappedAsset, 'access', _29 => _29.address, 'optionalAccess', _30 => _30.toLowerCase, 'call', _31 => _31()])},[n,s,L]),H=_react.useMemo.call(void 0, ()=>({raw:_nullishCoalesce(_optionalChain([g, 'optionalAccess', _32 => _32.raw]), () => ("0")),formatted:_nullishCoalesce(_optionalChain([g, 'optionalAccess', _33 => _33.formatted]), () => ("0"))}),[g]),J=_react.useMemo.call(void 0, ()=>({raw:_nullishCoalesce(_optionalChain([I, 'optionalAccess', _34 => _34.raw]), () => ("0")),formatted:_nullishCoalesce(_optionalChain([I, 'optionalAccess', _35 => _35.formatted]), () => ("0"))}),[I]),K=_react.useMemo.call(void 0, ()=>!n||typeof a!="number"||n.decimals===void 0||n.decimals===null?null:_viem.parseUnits.call(void 0, a.toFixed(n.decimals),n.decimals).toString(),[n,a]),V=_react.useMemo.call(void 0, ()=>!s||typeof l!="number"||s.decimals===void 0||s.decimals===null?null:_viem.parseUnits.call(void 0, l.toFixed(s.decimals),s.decimals).toString(),[s,l]),X=_react.useCallback.call(void 0, async t=>{A(t),p(null),_optionalChain([m, 'optionalCall', _36 => _36(t)])},[A,p,m]),Y=_react.useCallback.call(void 0, async t=>{S(t),_optionalChain([o, 'optionalCall', _37 => _37(t)])},[S,o]),Z=_react.useCallback.call(void 0, t=>T(t),[T]),_=_react.useCallback.call(void 0, t=>p(t),[p]),$=_react.useCallback.call(void 0, ()=>{h(),_chunk3PGCHNG2cjs.d.getState().toggleInverted(),r&&_optionalChain([m, 'optionalCall', _38 => _38(r)]),e&&_optionalChain([o, 'optionalCall', _39 => _39(e)])},[h,e,r,m,o]),j=_react.useCallback.call(void 0, ()=>v(),[v]);return{baseToken:n,baseAmount:a,quoteToken:s,quoteAmount:l,isBaseGasToken:q,isQuoteGasToken:L,isWrappingPair:O,isUnwrappingPair:z,baseBalance:H,quoteBalance:J,baseAmountRaw:K,quoteAmountRaw:V,isBaseBalanceLoading:R,isQuoteBalanceLoading:R,isRegistryLoading:u,setBaseToken:X,setQuoteToken:Y,setBaseAmount:Z,setQuoteAmount:_,swapTokens:$,clearForm:j}};var _jsxruntime = require('react/jsx-runtime');var N=_react.createContext.call(void 0, null),Ie= exports.d =({children:c,defaultBaseToken:i,defaultQuoteToken:m,onBaseTokenChange:o,onQuoteTokenChange:f})=>{let e=M(i,m,o,f),r=_react.useMemo.call(void 0, ()=>e,[e.baseToken,e.quoteToken,e.baseAmount,e.quoteAmount,e.isBaseGasToken,e.isQuoteGasToken,e.isWrappingPair,e.isUnwrappingPair,e.baseBalance,e.quoteBalance,e.baseAmountRaw,e.quoteAmountRaw,e.isBaseBalanceLoading,e.isQuoteBalanceLoading,e.setBaseToken,e.setQuoteToken,e.setBaseAmount,e.setQuoteAmount,e.swapTokens,e.clearForm,e.isRegistryLoading]);return _jsxruntime.jsx.call(void 0, N.Provider,{value:r,children:c})},qe= exports.e =()=>{let c=_react.useContext.call(void 0, N);if(!c)throw new Error("useSwapFormContext must be used within SwapFormProvider");return c};exports.a = F; exports.b = G; exports.c = M; exports.d = Ie; exports.e = qe;
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } async function _asyncOptionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = await fn(value); } else if (op === 'call' || op === 'optionalCall') { value = await fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }"use client";
2
+ var _chunkKH57FLSTcjs = require('./chunk-KH57FLST.cjs');var _chunkGK3MOEYUcjs = require('./chunk-GK3MOEYU.cjs');var _chunk3PGCHNG2cjs = require('./chunk-3PGCHNG2.cjs');var _chunk4S3B2JQYcjs = require('./chunk-4S3B2JQY.cjs');var _chunk34N36GUDcjs = require('./chunk-34N36GUD.cjs');var _chunkT3I3AJXVcjs = require('./chunk-T3I3AJXV.cjs');var _reactquery = require('@tanstack/react-query');var _react = require('react');function Sn(e){if(e.length===0)return 5e3;let l=Math.max(...e.map(r=>_nullishCoalesce(_optionalChain([_chunk4S3B2JQYcjs.c.call(void 0, r), 'optionalAccess', _2 => _2.blockTimeMs]), () => (2e3))));return Math.min(5e3,Math.max(1e3,l*2+1e3))}var Rn=()=>{let{address:e}=_chunk34N36GUDcjs.a.call(void 0, ),t=_chunk3PGCHNG2cjs.c.call(void 0, ),n=_reactquery.useQueryClient.call(void 0, ),c=_react.useRef.call(void 0, null),l=_react.useRef.call(void 0, !0),r=_react.useCallback.call(void 0, a=>{if(!e)return;let v=[...new Set(a.tokens.map(u=>u.asset.chainId))],d=Sn(v);c.current&&(clearTimeout(c.current),c.current=null),c.current=setTimeout(async()=>{if(c.current=null,!!l.current)try{let u=a.tokens.map(f=>({chainId:f.asset.chainId,tokenAddress:f.asset.address})),s=await _chunk4S3B2JQYcjs.I.call(void 0, e,u);if(s.balances.length===0)return;if(a.tokens.length>=2){let f=a.tokens[0].asset,p=a.tokens[1].asset,g=_chunk4S3B2JQYcjs.J.swap(e,f.chainId,f.address,p.chainId,p.address);n.setQueryData(g,s)}let o=_chunk4S3B2JQYcjs.J.bulk(e,t),S=n.getQueryData(o);if(S){let f=S.balances.map(p=>_nullishCoalesce(s.balances.find(x=>x.chainId===p.chainId&&x.token.toLowerCase()===p.token.toLowerCase()), () => (p)));for(let p of s.balances)f.some(g=>g.chainId===p.chainId&&g.token.toLowerCase()===p.token.toLowerCase())||f.push(p);for(let p of a.tokens)if(!s.balances.some(x=>x.chainId===p.asset.chainId&&x.token.toLowerCase()===p.asset.address.toLowerCase())){let x=f.findIndex(i=>i.chainId===p.asset.chainId&&i.token.toLowerCase()===p.asset.address.toLowerCase());x!==-1&&(f[x]={...f[x],balance:"0",shiftedBalance:"0"})}n.setQueryData(o,{balances:f})}}catch (e2){}},d)},[e,t,n]);return _react.useEffect.call(void 0, ()=>(l.current=!0,()=>{l.current=!1,c.current&&(clearTimeout(c.current),c.current=null)}),[]),{triggerBalanceUpdate:r}},rt=class extends EventTarget{emit(t){this.dispatchEvent(new CustomEvent("balance-update",{detail:t}))}},st=new rt,De= exports.b =()=>e=>st.emit(e),Jr= exports.c =()=>{let{triggerBalanceUpdate:e}=Rn();_react.useEffect.call(void 0, ()=>{let t=n=>{e(n.detail)};return st.addEventListener("balance-update",t),()=>st.removeEventListener("balance-update",t)},[e])};var _viem = require('viem');var _jsxruntime = require('react/jsx-runtime');var Wt=_react.createContext.call(void 0, void 0),Mt=1e4,En=3e4,$n=1e3,On=2;function Pn(e){return _nullishCoalesce(e.find(n=>_optionalChain([n, 'access', _3 => _3.routeSteps, 'optionalAccess', _4 => _4[0], 'optionalAccess', _5 => _5.type])==="AORI_V1"), () => (e[0]))}var is=({children:e,recipient:t})=>{let{address:n}=_chunk34N36GUDcjs.a.call(void 0, ),c=t||n,[l,r]=_react.useState.call(void 0, "idle"),[a,v]=_react.useState.call(void 0, "idle"),[d,u]=_react.useState.call(void 0, null),[s,o]=_react.useState.call(void 0, null),[S,f]=_react.useState.call(void 0, !1),[p,g]=_react.useState.call(void 0, !1),[x,i]=_react.useState.call(void 0, !1),h=_react.useRef.call(void 0, null),A=_react.useRef.call(void 0, null),m=_react.useRef.call(void 0, null),O=_react.useRef.call(void 0, null),W=_react.useRef.call(void 0, null),y=_react.useRef.call(void 0, 0),k=_react.useRef.call(void 0, 0),q=_react.useRef.call(void 0, 0),N=_react.useRef.call(void 0, !1),I=_react.useRef.call(void 0, new Map),E=_react.useCallback.call(void 0, ()=>{m.current&&clearTimeout(m.current),O.current&&clearTimeout(O.current),W.current&&clearTimeout(W.current),m.current=null,O.current=null,W.current=null},[]),U=_react.useCallback.call(void 0, ()=>{E(),h.current=null,y.current=0,r(()=>N.current?"fresh":"idle")},[E]),M=_react.useCallback.call(void 0, ()=>{U(),A.current=null,u(null),o(null),f(!1),g(!1),i(!1),I.current.clear(),r("idle"),v("idle")},[U]),Y=_react.useCallback.call(void 0, C=>{if(!C)return;O.current&&clearTimeout(O.current);let w=Math.max(0,C+En-Date.now());O.current=setTimeout(()=>{r(P=>P==="idle"?"idle":"stale")},w)},[]),Z=_react.useCallback.call(void 0, async(C,w)=>{let{inputToken:P,outputToken:$,inputAmount:H,setOutputAmount:de}=C;if(!P||!$||!H||parseFloat(H)<=0||Date.now()-(k.current||0)<Mt-10)return;let ae=++y.current;try{if(!_optionalChain([P, 'optionalAccess', _6 => _6.decimals])||!_optionalChain([$, 'optionalAccess', _7 => _7.decimals]))return;let G=_chunk4S3B2JQYcjs.F.call(void 0, P.chainId)||_optionalChain([_chunk4S3B2JQYcjs.c.call(void 0, P.chainId), 'optionalAccess', _8 => _8.key])||"",ne=_chunk4S3B2JQYcjs.F.call(void 0, $.chainId)||_optionalChain([_chunk4S3B2JQYcjs.c.call(void 0, $.chainId), 'optionalAccess', _9 => _9.key])||"";if(!G||!ne)throw new Error("Unknown chain");let pe=_viem.parseUnits.call(void 0, H.toString(),P.decimals).toString(),fe={srcChainKey:G,dstChainKey:ne,srcTokenAddress:_chunk4S3B2JQYcjs.v.call(void 0, P.address),dstTokenAddress:_chunk4S3B2JQYcjs.v.call(void 0, $.address),amount:pe,srcWalletAddress:n||"0x0000000000000000000000000000000000000000",dstWalletAddress:c||n||"0x0000000000000000000000000000000000000000",options:{amountType:"EXACT_SRC_AMOUNT",feeTolerance:{type:"PERCENT",amount:2}}};k.current=Date.now();let J=await fetch(`${_chunk4S3B2JQYcjs.k.call(void 0, )}/quotes`,{method:"POST",headers:_chunk4S3B2JQYcjs.m.call(void 0, ),body:JSON.stringify(fe),signal:AbortSignal.timeout(15e3)});if(!J.ok){let V=await _asyncOptionalChain([(await J.json().catch(()=>({}))), 'optionalAccess', async _10 => _10.message])||J.statusText;throw Object.assign(new Error(V),{status:J.status})}let me=await J.json();if(ae!==y.current||h.current!==w)return;let $e=_nullishCoalesce(me.quotes, () => ([])),be=Pn($e);if(!be)throw Object.assign(new Error("No quotes returned"),{emptyQuotes:!0});let Te=Number(_viem.formatUnits.call(void 0, _chunk4S3B2JQYcjs.q.call(void 0, be.dstAmount),$.decimals));typeof de=="function"&&de(Te),be._receivedAt=Date.now(),u(be),o(null),f(!1),r("fresh"),Y(be._receivedAt),w&&I.current.delete(w)}catch(G){if(ae!==y.current||h.current!==w)return;let ne=_optionalChain([G, 'optionalAccess', _11 => _11.status]),pe=G instanceof Error?G.message:"",fe=!!_optionalChain([G, 'optionalAccess', _12 => _12.emptyQuotes]);if((ne===400||fe||pe.includes("Quote request failed"))&&w){let me=(I.current.get(w)||0)+1;if(I.current.set(w,me),me>=On){g(!0),E(),h.current=null;return}}if(pe.toLowerCase().includes("order cap exceeded")){i(!0),E(),h.current=null;return}if(pe.toLowerCase().includes("insufficient executor balance")){f(!0),E(),h.current=null;return}o(G instanceof Error?G.message:"Unknown error")}},[n,c,Y,E]),L=_react.useCallback.call(void 0, (C,w)=>{E(),A.current=C,k.current=0,I.current.delete(w),f(!1),g(!1),i(!1),o(null),r("polling");let P=async()=>{h.current===w&&(await Z(C,w),h.current===w&&(m.current=setTimeout(P,Mt)))};P()},[E,Z]),T=_react.useCallback.call(void 0, C=>{if(!_optionalChain([C, 'optionalAccess', _13 => _13.inputToken])||!_optionalChain([C, 'optionalAccess', _14 => _14.outputToken])||!_optionalChain([C, 'optionalAccess', _15 => _15.inputAmount])||parseFloat(C.inputAmount)<=0){U();return}let w=A.current;if(w&&_optionalChain([w, 'access', _16 => _16.inputToken, 'optionalAccess', _17 => _17.address])===_optionalChain([C, 'access', _18 => _18.inputToken, 'optionalAccess', _19 => _19.address])&&_optionalChain([w, 'access', _20 => _20.inputToken, 'optionalAccess', _21 => _21.chainId])===_optionalChain([C, 'access', _22 => _22.inputToken, 'optionalAccess', _23 => _23.chainId])&&_optionalChain([w, 'access', _24 => _24.outputToken, 'optionalAccess', _25 => _25.address])===_optionalChain([C, 'access', _26 => _26.outputToken, 'optionalAccess', _27 => _27.address])&&_optionalChain([w, 'access', _28 => _28.outputToken, 'optionalAccess', _29 => _29.chainId])===_optionalChain([C, 'access', _30 => _30.outputToken, 'optionalAccess', _31 => _31.chainId])&&w.inputAmount===C.inputAmount&&h.current)return;let $=Date.now();if($-q.current<100)return;q.current=$;let H=`${Date.now()}-${Math.random().toString(36).slice(2)}`;h.current=H,L(C,H)},[L,U]),_=_react.useCallback.call(void 0, ({amount:C,inputToken:w,outputToken:P,setOutputAmount:$})=>{$(null),W.current&&clearTimeout(W.current),!C||C===0?(v("idle"),U(),u(null),o(null),f(!1),g(!1),i(!1)):(v("typing"),U(),u(null),f(!1),g(!1),i(!1),o(null),W.current=setTimeout(()=>{v("settled"),w&&P&&C>0&&T({inputToken:w,outputToken:P,inputAmount:C.toString(),setOutputAmount:$})},$n))},[U,T]),F=_react.useCallback.call(void 0, ()=>{let C=A.current;if(!C)return;u(null);let w=`${Date.now()}-${Math.random().toString(36).slice(2)}`;h.current=w,r("refreshing"),typeof C.setOutputAmount=="function"&&C.setOutputAmount(null),L(C,w)},[L]);_react.useEffect.call(void 0, ()=>{N.current=!!d},[d]),_react.useEffect.call(void 0, ()=>()=>E(),[E]);let Q=_react.useMemo.call(void 0, ()=>({status:l,inputState:a,rfqQuote:d,error:s,liquidityError:S,routingError:p,sizeCapError:x,ensureForParams:T,stop:U,refresh:F,clear:M,handleInputChange:_}),[l,a,d,s,S,p,x,T,U,F,M,_]);return _jsxruntime.jsx.call(void 0, Wt.Provider,{value:Q,children:e})},Fe= exports.f =()=>{let e=_react.useContext.call(void 0, Wt);if(e===void 0)throw new Error("useRfq must be used within an RfqProvider");return e};var Ln=_react.createContext.call(void 0, {openConnectModal:()=>{}}),ds= exports.h =()=>_react.useContext.call(void 0, Ln);var _n=20,qn=({side:e,asset:t,otherAsset:n,isPlacingOrder:c,isWrappingPair:l,isUnwrappingPair:r})=>{let{baseAmount:a,quoteAmount:v,setBaseAmount:d,setQuoteAmount:u}=_chunkGK3MOEYUcjs.e.call(void 0, ),{amountInputVariant:s,hideAmountInputSymbol:o,widgetType:S}=_chunk3PGCHNG2cjs.b.call(void 0, ),f=S==="compact",[p,g]=e==="base"?[d,u]:[u,d],x=!t||e==="quote"||c,i=f?32:s==="default"?64:32,[h,A]=_react.useState.call(void 0, i),[m,O]=_react.useState.call(void 0, ""),W=_react.useRef.call(void 0, null),y=_react.useRef.call(void 0, null),k=_react.useRef.call(void 0, null),q=_react.useRef.call(void 0, null),N="USD",I=e==="base"?a:v,[E,U]=_react.useState.call(void 0, !1),M=_react.useCallback.call(void 0, ()=>{if(s!=="default"){A(i);return}if(!W.current||!y.current||!k.current)return;let L=W.current.offsetWidth,T=20,_=i;for(;_>20&&(y.current.style.fontSize=`${_}px`,k.current.style.fontSize=`${_}px`,!(y.current.offsetWidth+k.current.offsetWidth+T<=L));)_-=1;A(_)},[s,i]),Y=_react.useCallback.call(void 0, L=>{L.key==="."&&m.includes(".")&&L.preventDefault()},[m]),Z=_react.useCallback.call(void 0, L=>{let T=L.target.value;if(T==="."&&(T="0."),!/^\d*\.?\d*$/.test(T)||(T.match(/\./g)||[]).length>1)return;if(T.length>1&&T[0]==="0"&&T[1]!=="."&&(T=T.replace(/^0+/,"")||"0"),_optionalChain([t, 'optionalAccess', _32 => _32.decimals])!==void 0&&T.includes(".")){let[,F]=T.split(".");if(F&&F.length>t.decimals)return}if(T.length>_n)return;O(T);let _=parseFloat(T);T!==m&&(T===""||T==="0."||T.endsWith(".")?(p(null),e==="base"&&g(null)):!Number.isNaN(_)&&_>=0&&p(_),e==="base"&&u(null),(r||l)&&u(_||0))},[m,p,e,u,_optionalChain([t, 'optionalAccess', _33 => _33.decimals]),g,r,l]);return _react.useEffect.call(void 0, ()=>{let L=F=>{if(F===null)return"";let Q=_optionalChain([t, 'optionalAccess', _34 => _34.decimals]);if(Q===void 0)return"";let C=F.toString();if(/e/i.test(C)&&(C=Number(F).toLocaleString("en-US",{useGrouping:!1,maximumFractionDigits:Q})),C.includes(".")){let[w,P]=C.split("."),$=P.slice(0,Q);return $?`${w}.${$}`:w}return C};if(I===null){m==="0."||m!==""&&m.endsWith(".")||O("");return}if(!x&&(m.endsWith(".")||m.match(/\.\d*0$/)||m==="0"||m==="0.")&&m!=="")return;let _=parseFloat(m)||0;(m===""||Math.abs(_-I)>1e-10)&&O(L(I))},[I,_optionalChain([t, 'optionalAccess', _35 => _35.decimals]),m,x]),_react.useEffect.call(void 0, ()=>{M()},[m,M]),_react.useEffect.call(void 0, ()=>{U(!0)},[]),_react.useEffect.call(void 0, ()=>{E&&M()},[E,M]),_react.useEffect.call(void 0, ()=>{y.current&&q.current&&(q.current.style.width=`${y.current.offsetWidth}px`)},[m]),_react.useEffect.call(void 0, ()=>{if(!E)return;let L=new ResizeObserver(()=>{E&&M()});return W.current&&L.observe(W.current),()=>L.disconnect()},[E,M]),_jsxruntime.jsx.call(void 0, "div",{ref:W,style:{fontSize:`${h}px`,transition:"font-size 0.05s ease-in-out"},className:`mt-2 box-border font-sans flex ${f?s==="normal"?"h-12 my-1":"h-10 my-0.5":s==="normal"?"h-12 my-1":"h-20 my-1"} w-full flex-row items-center ${x?"cursor-default":"cursor-text"}`,onClick:()=>_optionalChain([q, 'access', _36 => _36.current, 'optionalAccess', _37 => _37.focus, 'call', _38 => _38()]),children:_jsxruntime.jsxs.call(void 0, "div",{className:"relative flex w-full items-center",children:[_jsxruntime.jsx.call(void 0, "label",{htmlFor:`${e}Amount`,className:"sr-only",children:e==="base"?"Input token amount":"Output token amount"}),_jsxruntime.jsx.call(void 0, "input",{ref:q,type:"text",inputMode:"decimal",placeholder:"0",autoComplete:"off",id:`${e}Amount`,value:m,onWheel:L=>L.target.blur(),onKeyDown:Y,onChange:Z,style:{transition:"width 0.15s ease-in-out",color:"var(--widget-foreground)",WebkitTextFillColor:"var(--widget-foreground)",opacity:1},className:"flex min-w-[45px] whitespace-nowrap bg-transparent placeholder:opacity-50 font-sans font-thin",disabled:x}),_jsxruntime.jsx.call(void 0, "span",{style:{transition:"width 0.15s ease-in-out"},ref:y,className:"pointer-events-none absolute flex whitespace-nowrap invisible",children:m||0}),!o&&s!=="normal"&&_jsxruntime.jsx.call(void 0, "span",{ref:k,className:"ml-2 font-thin uppercase",style:{color:"var(--widget-foreground)",opacity:.5,fontSize:`${h}px`},children:_optionalChain([t, 'optionalAccess', _39 => _39.symbol])?t.symbol.length>6?`${t.symbol.slice(0,6)}...`:t.symbol:N}),(o||s==="normal")&&_jsxruntime.jsx.call(void 0, "span",{ref:k,className:"hidden"})]})})},hs= exports.i =qn;var Fn=({toggle:e,side:t,asset:n,isPlacingOrder:c,hideDropdown:l})=>{let{baseBalance:r,quoteBalance:a}=_chunkGK3MOEYUcjs.e.call(void 0, ),{tokenDisplay:v,tokenBadgeOrientation:d,widgetType:u}=_chunk3PGCHNG2cjs.b.call(void 0, ),s=u==="compact",o=s?"h-10":"h-13",S=s?"h-10 w-10":"h-13 w-13",f=t==="base"?r.formatted?(()=>{let g=parseFloat(r.formatted);return g>=1e4?_chunk4S3B2JQYcjs.o.call(void 0, g):g.toFixed(4)})():void 0:a.formatted?(()=>{let g=parseFloat(a.formatted);return g>=1e4?_chunk4S3B2JQYcjs.o.call(void 0, g):g.toFixed(4)})():void 0,p={role:"button",tabIndex:c?-1:0,"aria-disabled":c,"aria-label":`Select ${t==="base"?"input":"output"} token${n?`: ${n.symbol}`:""}`,onClick:c?void 0:e,onKeyDown:c?void 0:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),e())}};return v==="pill"?_jsxruntime.jsx.call(void 0, "div",{...p,className:`inline-flex items-center gap-1.5 h-7 px-2.5 rounded-full cursor-pointer transition-colors ${d==="right"?"ml-auto":""}`,style:{border:"1px solid var(--widget-border)",backgroundColor:"var(--widget-secondary)",color:"var(--widget-secondary-foreground)"},children:n?_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, _chunk4S3B2JQYcjs.N,{chain:n.chainId,size:"xs"}),_jsxruntime.jsx.call(void 0, _chunk4S3B2JQYcjs.O,{className:"rounded-full",asset:n,size:"xxs",noChain:!0}),_jsxruntime.jsx.call(void 0, "span",{className:"text-xs font-thin uppercase",children:n.symbol}),!l&&_jsxruntime.jsx.call(void 0, _chunk4S3B2JQYcjs.U,{className:"w-1.5 opacity-60",style:{color:"var(--widget-secondary-foreground)"}})]}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "span",{className:"text-xs opacity-70",children:"Select"}),!l&&_jsxruntime.jsx.call(void 0, _chunk4S3B2JQYcjs.U,{className:"w-1.5 opacity-60",style:{color:"var(--widget-secondary-foreground)"}})]})}):v==="ghost"?_jsxruntime.jsxs.call(void 0, "div",{...p,className:"inline-flex items-center gap-1.5 cursor-pointer transition-opacity hover:opacity-70 py-1",style:{color:"var(--widget-foreground)"},children:[n?_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, _chunk4S3B2JQYcjs.N,{chain:n.chainId,size:"xs"}),_jsxruntime.jsx.call(void 0, _chunk4S3B2JQYcjs.O,{className:"rounded-full",asset:n,size:"xxs",noChain:!0}),_jsxruntime.jsx.call(void 0, "span",{className:"text-sm font-thin uppercase",children:n.symbol})]}):_jsxruntime.jsx.call(void 0, "span",{className:"text-sm",style:{color:"var(--widget-muted-foreground)"},children:"Select token"}),!l&&_jsxruntime.jsx.call(void 0, _chunk4S3B2JQYcjs.U,{className:"w-1.5 opacity-50"})]}):_jsxruntime.jsx.call(void 0, "div",{...p,className:`relative ${o} w-full cursor-pointer text-xl duration-100 ease-linear`,style:{border:"1px solid var(--widget-border)",backgroundColor:"var(--widget-secondary)",borderTopLeftRadius:"9999px",borderBottomLeftRadius:"9999px",borderTopRightRadius:"var(--widget-radius)",borderBottomRightRadius:"var(--widget-radius)"},children:_jsxruntime.jsx.call(void 0, "div",{className:"relative flex h-full w-full flex-row items-center",children:n?_jsxruntime.jsxs.call(void 0, "div",{className:"relative flex h-full w-full flex-row items-center",children:[_jsxruntime.jsx.call(void 0, "div",{className:`${S} pl-px flex items-center justify-center`,children:_jsxruntime.jsx.call(void 0, _chunk4S3B2JQYcjs.O,{className:"rounded-full",asset:n,size:"lg"})}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-full w-full flex-row items-center justify-between pl-2.5 pr-7",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-full flex-col justify-center gap-0.5",children:[_jsxruntime.jsx.call(void 0, "p",{className:"text-base font-thin uppercase",style:{color:"var(--widget-secondary-foreground)"},children:n.symbol}),_jsxruntime.jsxs.call(void 0, "span",{className:"text-xs font-sans",style:{color:"var(--widget-muted-foreground)"},children:[_optionalChain([n, 'access', _40 => _40.address, 'optionalAccess', _41 => _41.slice, 'call', _42 => _42(0,6)]),"...",_optionalChain([n, 'access', _43 => _43.address, 'optionalAccess', _44 => _44.slice, 'call', _45 => _45(-4)])]})]}),f!==void 0&&_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col text-right",children:[_jsxruntime.jsx.call(void 0, "p",{className:"text-2xs",style:{color:"var(--widget-muted-foreground)"},children:"Balance"}),_jsxruntime.jsx.call(void 0, "span",{className:"font-sans text-xs tabular-nums",style:{color:"var(--widget-foreground)",opacity:.5},children:f})]})]}),!l&&_jsxruntime.jsx.call(void 0, _chunk4S3B2JQYcjs.U,{className:"absolute right-3 top-1/2 w-1.5 translate-y-[-50%]",style:{color:"var(--widget-secondary-foreground)",opacity:.6}})]}):_jsxruntime.jsx.call(void 0, "div",{className:"flex h-full w-full items-center justify-center",children:_jsxruntime.jsx.call(void 0, "span",{className:"text-sm",style:{color:"var(--widget-secondary-foreground)",opacity:.7},children:"Select token"})})})})},Ss= exports.j =Fn;var _t=_chunkT3I3AJXVcjs.b.call(void 0, _chunkKH57FLSTcjs.a.call(void 0, ),1);var Vn=()=>{let[e,t]=_react.useState.call(void 0, null),[n,c]=_react.useState.call(void 0, ""),l=_chunk4S3B2JQYcjs.x.call(void 0, n,1e3),[r,a]=_react.useState.call(void 0, !1),[v,d]=_react.useState.call(void 0, "");_react.useEffect.call(void 0, ()=>{_chunk3PGCHNG2cjs.d.getState().setRecipient(e)},[e]),_react.useEffect.call(void 0, ()=>{c(e||"")},[e]);let u=o=>{let S=o.target.value;r&&(a(!1),d(""),t(null)),c(S),S===""&&t(null)};_react.useEffect.call(void 0, ()=>{l===""||!l?(a(!1),d(""),t(null)):_chunk4S3B2JQYcjs.w.call(void 0, l)?(a(!1),d(""),t(l)):(a(!0),d("Invalid wallet address..."),t(null),c(""))},[l]),_react.useEffect.call(void 0, ()=>{if(r){let o=setTimeout(()=>{t(null),c(""),a(!1),d("")},2e3);return()=>clearTimeout(o)}},[r]);let s=()=>{t(null),c(""),a(!1),d("")};return _jsxruntime.jsx.call(void 0, "div",{className:"w-full",children:_jsxruntime.jsxs.call(void 0, "div",{className:"relative flex flex-row items-center",children:[_jsxruntime.jsx.call(void 0, "input",{type:"password",style:{display:"none"},"aria-hidden":"true",tabIndex:-1}),_jsxruntime.jsx.call(void 0, "label",{htmlFor:"recipient-address",className:"sr-only",children:"Recipient wallet address"}),_jsxruntime.jsx.call(void 0, "div",{className:"absolute left-3 flex h-6 w-6 items-end justify-center overflow-hidden rounded-full",style:{backgroundColor:"var(--widget-secondary)"},children:e&&!r?_jsxruntime.jsx.call(void 0, "img",{className:"h-full w-full rounded-full object-cover",src:(0,_t.makeGradient)(e),alt:"Recipient avatar"}):_jsxruntime.jsx.call(void 0, _chunk4S3B2JQYcjs.T,{className:"h-5 w-5",style:{color:r?"var(--widget-destructive)":"var(--widget-muted-foreground)"}})}),_jsxruntime.jsx.call(void 0, "div",{className:"absolute left-12 top-1.5 -translate-y-1 text-xs font-medium opacity-60",style:{color:r?"var(--widget-destructive)":"var(--widget-muted-foreground)"},"aria-hidden":"true",children:"To:"}),_jsxruntime.jsx.call(void 0, "input",{id:"recipient-address",className:"font-sans block h-10 w-full items-center pl-12 pt-4 pr-8 text-xs",style:{backgroundColor:r?"color-mix(in srgb, var(--widget-destructive) 10%, transparent)":"transparent",color:r?"var(--widget-destructive)":"var(--widget-foreground)",outline:"none",opacity:r?.9:1},placeholder:r?v:"Enter recipient address...",value:n,onChange:u,spellCheck:!1,"aria-invalid":r,"aria-describedby":r?"recipient-error":void 0}),r&&_jsxruntime.jsx.call(void 0, "span",{id:"recipient-error",className:"sr-only",children:v}),e&&!r&&_jsxruntime.jsxs.call(void 0, "button",{type:"button",className:"absolute right-2 top-1/2 -translate-y-1/2 cursor-pointer flex items-center justify-center h-4 w-4 rounded-full transition-colors hover:[color:var(--widget-destructive)]",style:{color:"var(--widget-muted-foreground)"},onClick:s,"aria-label":"Clear recipient",children:[_jsxruntime.jsx.call(void 0, "svg",{className:"h-2.5 w-2.5",viewBox:"0 -0.5 21 21",fill:"none",children:_jsxruntime.jsx.call(void 0, "g",{fill:"currentColor",fillRule:"evenodd",children:_jsxruntime.jsx.call(void 0, "polygon",{points:"375.0183 90 384 98.554 382.48065 100 373.5 91.446 364.5183 100 363 98.554 371.98065 90 363 81.446 364.5183 80 373.5 88.554 382.48065 80 384 81.446",transform:"translate(-363 -80)"})})}),_jsxruntime.jsx.call(void 0, "span",{className:"sr-only",children:"Clear recipient"})]})]})})},Es= exports.k =Vn;function Ps(e){return _jsxruntime.jsxs.call(void 0, "svg",{width:"485",height:"484",viewBox:"0 0 485 484",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[_jsxruntime.jsx.call(void 0, "path",{d:"M265.974 52.8127C270.567 50.9299 273.227 53.6338 275.917 56.1595C301.879 80.5364 327.828 104.927 353.786 129.308C380.101 154.024 406.44 178.715 432.721 203.467C436.002 206.557 440.744 209.272 438.226 215.021C435.865 220.415 430.758 219.123 426.424 219.124C305.965 219.169 185.506 219.163 65.0464 219.166C53.0995 219.166 49.0676 215.225 49.0125 203.316C48.9563 191.154 48.9813 178.991 48.9973 166.829C49.0119 155.717 53.3581 151.358 64.4131 151.358C127.892 151.357 191.37 151.364 254.849 151.368C262.591 151.368 262.645 151.344 262.588 143.559C262.388 116.237 262.191 88.914 261.918 61.5922C261.883 58.0834 262.161 54.9042 265.974 52.8127Z",fill:"currentColor"}),_jsxruntime.jsx.call(void 0, "path",{d:"M80.5649 300.432C71.3447 291.747 62.4175 283.264 53.4064 274.87C50.4552 272.122 47.8959 269.327 49.7894 264.946C51.6154 260.72 55.4624 260.923 59.1682 260.923C164.476 260.927 269.785 260.932 375.093 260.935C391.422 260.935 407.752 260.9 424.081 260.933C434.679 260.955 438.994 265.286 439.015 275.854C439.04 288.517 439.048 301.181 439.013 313.845C438.985 324.225 434.466 328.73 424.01 328.732C360.359 328.741 296.707 328.729 233.056 328.714C225.392 328.713 225.368 328.686 225.426 336.583C225.628 363.741 225.815 390.9 226.101 418.057C226.142 421.935 225.905 425.512 221.852 427.329C217.686 429.197 214.934 426.578 212.212 424.02C172.068 386.302 131.922 348.587 91.7738 310.874C88.1374 307.459 84.4753 304.07 80.5649 300.432Z",fill:"currentColor"})]})}var _actions = require('viem/actions');function Ft(e){return e instanceof Error?e.name==="UserRejectedRequestError"||e.message.includes("User rejected")||e.message.includes("rejected")||e.message.includes("denied")||e.message.includes("cancelled")||e.message.includes("canceled"):!1}async function Dt(e){if(_optionalChain([e, 'access', _46 => _46.chain, 'optionalAccess', _47 => _47.id]))return e.chain.id;let t=_optionalChain([e, 'access', _48 => _48.getChainId, 'optionalCall', _49 => _49()]);return t!=null?await t:null}var jn=async(e,t)=>{try{if(await Dt(e)===t)return!0;if(e.request)await e.request({method:"wallet_switchEthereumChain",params:[{chainId:`0x${t.toString(16)}`}]});else if(e.switchChain)await e.switchChain({id:t});else if(e.send)await e.send("wallet_switchEthereumChain",[{chainId:`0x${t.toString(16)}`}]);else throw new Error("Wallet doesn't support chain switching");return await Dt(e)===t}catch(n){throw Ft(n)?new Error("User rejected the chain switch request"):new Error(`Please switch your wallet to the required network (Chain ID: ${t})`)}},Vt= exports.n =async e=>{let{quote:t,signatureStep:n,userAddress:c,walletClient:l}=e;if(!l)throw new Error("Wallet client not available");if(n.type!=="SIGNATURE"||!_optionalChain([n, 'access', _50 => _50.signature, 'optionalAccess', _51 => _51.typedData]))throw new Error("Invalid signature step");try{let r=n.signature.typedData,a={...r.message};for(let s of["inputAmount","outputAmount","startTime","endTime"])a[s]!=null&&(a[s]=BigInt(a[s]));let v=r.domain;if(v.chainId!=null){let s=Number(v.chainId);await jn(l,s)}let d=await _actions.signTypedData.call(void 0, l,{account:c,domain:v,types:r.types,primaryType:r.primaryType,message:a}),u=await fetch(`${_chunk4S3B2JQYcjs.k.call(void 0, )}/submit-signature`,{method:"POST",headers:_chunk4S3B2JQYcjs.m.call(void 0, ),body:JSON.stringify({quoteId:t.id,signatures:[d]})});if(!u.ok){let s=await u.json().catch(()=>({}));throw new Error(_optionalChain([s, 'optionalAccess', _52 => _52.message])||`Submit failed: ${u.status}`)}return{quoteId:t.id,signature:d}}catch(r){throw Ft(r)?new Error("User rejected the signing request"):r instanceof Error&&r.message.includes("chain")?new Error("Chain switching failed. Please manually switch to the correct network."):r}};var Bt="vt_submitted_quotes";var ct=()=>{try{let e=localStorage.getItem(Bt);return e?JSON.parse(e):[]}catch (e3){return[]}},Qt=e=>{try{localStorage.setItem(Bt,JSON.stringify(e))}catch (e4){}},zn= exports.o =e=>{let t=Date.now(),n=typeof e=="string"?new Date(e).getTime():e>9999999999?e:e*1e3;return t<n+3e4},Hn=e=>ct().some(t=>t.quoteId===e),jt= exports.p =(e,t)=>Hn(e)?{canSubmit:!1,reason:"Order already submitted"}:zn(t)?{canSubmit:!0}:{canSubmit:!1,reason:"Quote has expired"},zt= exports.q =(e,t)=>{let n=typeof t=="string"?new Date(t).getTime():t,c=ct();c.push({quoteId:e,submittedAt:Date.now(),createdAt:n}),Qt(c)},Ht= exports.r =()=>{let e=ct(),t=Date.now(),n=300*1e3,c=e.filter(l=>t-l.submittedAt<n);c.length!==e.length&&Qt(c)};var _core = require('@wagmi/core');var _abis = require('abitype/abis');var _wagmi = require('wagmi');function Gt(){let e=_wagmi.useConfig.call(void 0, );return _reactquery.useMutation.call(void 0, {mutationFn:async({chainId:t,accountAddress:n,amountRaw:c,writeContractAsync:l})=>{let r=_chunk4S3B2JQYcjs.c.call(void 0, t);if(!r)throw new Error(`No wrapping contract for chain ${t}`);let a=r.wrappedAsset.address,v=await l({abi:_abis.wethAbi,functionName:"withdraw",address:a,account:n,args:[c],chainId:t});if((await _core.waitForTransactionReceipt.call(void 0, e,{hash:v,chainId:t,confirmations:1,pollingInterval:4e3})).status!=="success")throw new Error("Unwrap transaction did not get successful receipt");return{success:!0,hash:v}}})}function Kt(){let e=_wagmi.useConfig.call(void 0, );return _reactquery.useMutation.call(void 0, {mutationFn:async({chainId:t,accountAddress:n,amountRaw:c,writeContractAsync:l})=>{let r=_chunk4S3B2JQYcjs.c.call(void 0, t);if(!r)throw new Error(`No wrapping contract for chain ${t}`);let a=r.wrappedAsset.address,v=await l({abi:_abis.wethAbi,functionName:"deposit",address:a,account:n,value:c,chainId:t});if((await _core.waitForTransactionReceipt.call(void 0, e,{hash:v,chainId:t,confirmations:1,pollingInterval:4e3})).status!=="success")throw new Error("Wrap transaction did not get successful receipt");return{success:!0,hash:v}}})}var ar=15e3,je="chain",ir=({needsChainSwitch:e,requiredChain:t,reviewState:n,goToNextStep:c,cancel:l})=>{let r=_chunk4S3B2JQYcjs.r.call(void 0, je,n),[a,v]=_react.useState.call(void 0, "pending"),d=_react.useRef.call(void 0, !1),u=_react.useRef.call(void 0, !1),s=_react.useRef.call(void 0, null),o=_wagmi.useChainId.call(void 0, ),{switchChainAsync:S}=_wagmi.useSwitchChain.call(void 0, ),{status:f,isReconnecting:p}=_wagmi.useAccount.call(void 0, ),g=_react.useCallback.call(void 0, ()=>{s.current&&(clearTimeout(s.current),s.current=null)},[]),x=_react.useCallback.call(void 0, async()=>{if(!(d.current||u.current||f!=="connected"||p)){d.current=!0,u.current=!0,v("pending"),s.current=setTimeout(()=>{d.current&&(v("error"),d.current=!1)},ar);try{await S({chainId:t.chainId}),g(),v("success"),c(je,n)}catch (e5){g(),v("error")}finally{d.current=!1}}},[S,f,p,t.chainId,c,n,g]);_react.useEffect.call(void 0, ()=>{d.current||u.current||n===je&&a==="pending"&&f==="connected"&&!p&&(e&&o!==t.chainId?x():(v("success"),c(je,n)))},[n,a,e,o,t.chainId,f,p,x,c]),_react.useEffect.call(void 0, ()=>()=>g(),[g]);let i=()=>{a==="error"&&(u.current=!1,v("pending"))},h=!r&&a==="error",A=!r&&(a==="pending"||a==="error"),m=h?"var(--widget-status-failed)":"var(--widget-primary)";return _jsxruntime.jsxs.call(void 0, "div",{className:"flex w-full flex-row justify-between space-x-3",children:[_jsxruntime.jsx.call(void 0, "button",{type:"button",className:`inline-flex h-12 w-full items-center justify-center text-sm font-sans font-medium transition duration-150 ${h?"cursor-pointer":"cursor-not-allowed"}`,style:{backgroundColor:`color-mix(in srgb, ${m} 12%, transparent)`,border:`1px solid color-mix(in srgb, ${m} 20%, transparent)`,color:m,borderRadius:"var(--widget-radius)"},onClick:h?i:void 0,children:_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-10 w-full flex-row items-center space-x-3 px-4",children:[_jsxruntime.jsx.call(void 0, _chunk4S3B2JQYcjs.N,{chain:t.chainId,size:"xs"}),_jsxruntime.jsx.call(void 0, "p",{className:"whitespace-nowrap",children:h?"Retry Switch":`Switch to ${t.name}`}),_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-1 border-t",style:{borderColor:"var(--widget-border)"}}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-6 w-3 items-center justify-center rounded-full",children:[!r&&a==="pending"&&_jsxruntime.jsx.call(void 0, _chunk4S3B2JQYcjs.V,{size:"5"}),(r||a==="success")&&_jsxruntime.jsx.call(void 0, _chunk4S3B2JQYcjs.P,{className:"h-8 w-8"}),h&&_jsxruntime.jsx.call(void 0, _chunk4S3B2JQYcjs.S,{className:"h-[12px] w-[12px]"})]})]})}),A&&_jsxruntime.jsx.call(void 0, "button",{type:"button",className:"inline-flex h-12 items-center justify-center px-8 text-sm font-sans font-medium transition duration-150 cursor-pointer",style:{backgroundColor:"color-mix(in srgb, var(--widget-status-failed) 12%, transparent)",border:"1px solid color-mix(in srgb, var(--widget-status-failed) 20%, transparent)",color:"var(--widget-status-failed)",borderRadius:"var(--widget-radius)"},onClick:l,children:"Cancel"})]})},Zt=ir;var cr=({startTime:e,onExpired:t})=>{let[n,c]=_react.useState.call(void 0, 30),[l,r]=_react.useState.call(void 0, !1),a=_react.useRef.call(void 0, !1),v=_react.useRef.call(void 0, t);v.current=t,_react.useEffect.call(void 0, ()=>{a.current=!1},[e]),_react.useEffect.call(void 0, ()=>{let u=()=>{let o=Date.now(),f=(e>9999999999?e:e*1e3)+30*1e3,p=Math.max(0,f-o),g=Math.floor(p/1e3);if(g<=0){c(0),a.current||(a.current=!0,r(!0),v.current());return}c(g),r(!1)};if(l)return;u();let s=setInterval(u,1e3);return()=>clearInterval(s)},[e,l]);let d=u=>{let s=Math.floor(u/60),o=u%60;return`${s.toString().padStart(2,"0")}:${o.toString().padStart(2,"0")}`};return l?null:_jsxruntime.jsx.call(void 0, "span",{className:"text-xs font-sans",children:d(n)})},nn=cr;function yr(e){return e.name==="UserRejectedRequestError"||e.message.includes("User rejected")||e.message.includes("rejected")||e.message.includes("denied")||e.message.includes("cancelled")||e.message.includes("canceled")}var ye="signingOrder";async function br(e,t,n,c,l){let r=_optionalChain([e, 'access', _53 => _53.transaction, 'optionalAccess', _54 => _54.encoded]),a=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _55 => _55.to]), () => (e.to)),v=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _56 => _56.data]), () => (e.data)),d=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _57 => _57.value]), () => (e.value));if(!a)throw new Error('Transaction step missing "to" address');let u=_optionalChain([r, 'optionalAccess', _58 => _58.chainId]),s=e.chainKey||l,o=u||(s?_chunk4S3B2JQYcjs.E.call(void 0, s):void 0);if(!o)throw new Error(`Unknown chain: ${s}`);let S=_chunk4S3B2JQYcjs.h.call(void 0, )[o],f=await n({account:t,chain:S,to:a,data:v||"0x",value:BigInt(d||"0")});return await _core.waitForTransactionReceipt.call(void 0, c,{hash:f,chainId:o}),f}async function xr(e,t,n,c,l){let r=_optionalChain([e, 'access', _59 => _59.transaction, 'optionalAccess', _60 => _60.encoded]),a=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _61 => _61.to]), () => (e.to)),v=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _62 => _62.data]), () => (e.data));if(!a||!v)return!1;let d,u;try{let{functionName:A,args:m}=_viem.decodeFunctionData.call(void 0, {abi:_viem.erc20Abi,data:v});if(A!=="approve"||!m||m.length<2)return!1;d=m[0],u=m[1]}catch (e6){return!1}let s=e.chainKey||l.srcChainKey,o=_optionalChain([r, 'optionalAccess', _63 => _63.chainId])||(s?_chunk4S3B2JQYcjs.E.call(void 0, s):void 0);if(!o)return!1;let f=await _chunk4S3B2JQYcjs.H.call(void 0, o).readContract({address:a,abi:_viem.erc20Abi,functionName:"allowance",args:[t,d]});if(f>=u)return!0;let p=_chunk4S3B2JQYcjs.h.call(void 0, )[o],g=await _core.getGasPrice.call(void 0, c,{chainId:o}),x={account:t,chain:p,to:a,value:0n,gas:150000n,gasPrice:g};if(f>0n){let A=_viem.encodeFunctionData.call(void 0, {abi:_viem.erc20Abi,functionName:"approve",args:[d,0n]}),m=await n({...x,data:A});await _core.waitForTransactionReceipt.call(void 0, c,{hash:m,chainId:o})}let i=_viem.encodeFunctionData.call(void 0, {abi:_viem.erc20Abi,functionName:"approve",args:[d,_viem.maxUint256]}),h=await n({...x,data:i});return await _core.waitForTransactionReceipt.call(void 0, c,{hash:h,chainId:o}),!0}var Cr=({base:e,baseAmount:t,quote:n,quoteAmount:c,userAddress:l,reviewState:r,goToNextStep:a,cancel:v,isWrappingPair:d,isUnwrappingPair:u,restartSigningFlow:s,onSwapInitiated:o,onOrderSubmitted:S,onSwapSubmitted:f,startPolling:p,trackNativeTransaction:g})=>{let x=_chunk4S3B2JQYcjs.r.call(void 0, ye,r),[i,h]=_react.useState.call(void 0, "idle"),A=_react.useRef.call(void 0, !1),m=_react.useRef.call(void 0, null),O=_wagmi.useConfig.call(void 0, ),{isReconnecting:W}=_wagmi.useAccount.call(void 0, ),{rfqQuote:y,stop:k,refresh:q}=Fe(),{data:N}=_wagmi.useWalletClient.call(void 0, {chainId:e.chainId}),{switchChain:I}=_wagmi.useSwitchChain.call(void 0, ),{sendTransactionAsync:E}=_wagmi.useSendTransaction.call(void 0, ),U=_nullishCoalesce(_optionalChain([y, 'optionalAccess', _64 => _64._receivedAt]), () => (0)),M=_react.useCallback.call(void 0, ()=>U?Date.now()>=U+30*1e3:!1,[U]),Y=_react.useCallback.call(void 0, async()=>{if(A.current||i!=="idle")return;if(!_optionalChain([y, 'optionalAccess', _65 => _65.id])||!_optionalChain([y, 'optionalAccess', _66 => _66._receivedAt])){h("error");return}if(!jt(y.id,y._receivedAt).canSubmit){h("stale");return}A.current=!0;try{if(!N)throw new Error("Wallet client not available");Ht();let w=_nullishCoalesce(y.userSteps, () => ([])),P;for(let $ of w)if($.type==="TRANSACTION"){h("submitting");let H=$.chainKey||y.srcChainKey,de=H?_chunk4S3B2JQYcjs.E.call(void 0, H):void 0;if(de&&_optionalChain([N, 'access', _67 => _67.chain, 'optionalAccess', _68 => _68.id])!==de&&(await I({chainId:de}),await new Promise(ae=>setTimeout(ae,800))),await xr($,l,E,O,y))continue;P=await br($,l,E,O,y.srcChainKey),g(P,$.description||`Tx on ${H}`)}else $.type==="SIGNATURE"&&(h("signing"),await Vt({quote:y,signatureStep:$,userAddress:l,walletClient:N}));zt(y.id,y._receivedAt),_optionalChain([S, 'optionalCall', _69 => _69(y.id)]),p(y.id,{baseToken:e,quoteToken:n}),_optionalChain([o, 'optionalCall', _70 => _70()]),k(),h("success"),a(ye,r),_optionalChain([f, 'optionalCall', _71 => _71(y.id)])}catch(w){w instanceof Error&&yr(w),h("error")}finally{A.current=!1}},[i,y,N,e,n,l,k,p,a,r,f,I,E,o,S,g,O]);_react.useEffect.call(void 0, ()=>{if(r===ye&&k(),x&&i!=="success"){h("success"),a(ye,r);return}if(i==="success"){a(ye,r);return}if(r===ye&&i==="idle"&&!_optionalChain([y, 'optionalAccess', _72 => _72.id])){h("refreshingQuote"),q();return}if(r===ye&&i==="idle"&&N&&!A.current&&!W){let C=_optionalChain([y, 'optionalAccess', _73 => _73.id])||null;C&&m.current!==C&&(m.current=C,Y())}},[x,r,i,N,W,Y,a,_optionalChain([y, 'optionalAccess', _74 => _74.id]),q,k]),_react.useEffect.call(void 0, ()=>{i==="refreshingQuote"&&_optionalChain([y, 'optionalAccess', _75 => _75.id])&&h("idle")},[i,_optionalChain([y, 'optionalAccess', _76 => _76.id])]),_react.useEffect.call(void 0, ()=>{r!==ye&&(m.current=null)},[r]),_react.useEffect.call(void 0, ()=>{let C=setInterval(()=>{M()&&!A.current&&i!=="submitting"&&i!=="success"&&h("stale")},1e3);return()=>clearInterval(C)},[M,i]);let Z=()=>{i==="error"&&!A.current&&(m.current=null,h("idle"))},L=_react.useCallback.call(void 0, ()=>{m.current=null,h("refreshingQuote"),q()},[q]),T=_react.useCallback.call(void 0, ()=>{s?s(!0):v()},[s,v]),_=()=>i==="error"?"Retry swap":i==="signing"?"Sign Swap Order":i==="submitting"?"Submitting...":i==="refreshingQuote"?"Refreshing Quote...":i==="stale"?"Quote Stale":"Sign & Submit",F=!x&&(i==="error"||i==="stale"),Q=F?"var(--widget-status-failed)":"var(--widget-primary)";return _jsxruntime.jsxs.call(void 0, "div",{className:"flex w-full flex-row justify-between space-x-3",children:[_jsxruntime.jsx.call(void 0, "button",{type:"button",className:`inline-flex h-12 w-full items-center justify-center text-sm font-sans font-medium transition duration-150 ${F?"cursor-pointer":"cursor-not-allowed"}`,style:{backgroundColor:`color-mix(in srgb, ${Q} 12%, transparent)`,border:`1px solid color-mix(in srgb, ${Q} 20%, transparent)`,color:Q,borderRadius:"var(--widget-radius)"},onClick:!x&&i==="error"?Z:i==="stale"?T:void 0,children:_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-10 w-full flex-row items-center space-x-3 px-4",children:[_jsxruntime.jsx.call(void 0, _chunk4S3B2JQYcjs.O,{asset:e,size:"xs",noChain:!0}),_jsxruntime.jsx.call(void 0, "p",{className:"whitespace-nowrap",children:_()}),_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-1 border-t",style:{borderColor:"var(--widget-border)"}}),U>0&&i!=="success"&&i!=="error"&&i!=="stale"&&_jsxruntime.jsx.call(void 0, nn,{startTime:U,onExpired:()=>h("stale")}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-6 w-3 items-center justify-center rounded-full",children:[!x&&(i==="idle"||i==="signing"||i==="submitting"||i==="refreshingQuote")&&_jsxruntime.jsx.call(void 0, _chunk4S3B2JQYcjs.V,{size:"5"}),(x||i==="success")&&_jsxruntime.jsx.call(void 0, _chunk4S3B2JQYcjs.P,{className:"h-8 w-8"}),!x&&(i==="error"||i==="stale")&&_jsxruntime.jsx.call(void 0, _chunk4S3B2JQYcjs.S,{className:"h-[12px] w-[12px]"})]})]})}),!x&&(i==="error"||i==="stale")&&_jsxruntime.jsx.call(void 0, "button",{type:"button",className:"inline-flex h-12 items-center justify-center px-8 text-sm font-sans font-medium transition duration-150 cursor-pointer",style:{backgroundColor:"color-mix(in srgb, var(--widget-status-failed) 12%, transparent)",border:"1px solid color-mix(in srgb, var(--widget-status-failed) 20%, transparent)",color:"var(--widget-status-failed)",borderRadius:"var(--widget-radius)"},onClick:v,children:"Cancel"})]})},on=Cr;var Rr=()=>_jsxruntime.jsxs.call(void 0, "svg",{className:"w-3 h-3 shrink-0",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[_jsxruntime.jsx.call(void 0, "path",{d:"M18 13V19C18 20.1046 17.1046 21 16 21H5C3.89543 21 3 20.1046 3 19V8C3 6.89543 3.89543 6 5 6H11",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),_jsxruntime.jsx.call(void 0, "path",{d:"M15 3H21V9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),_jsxruntime.jsx.call(void 0, "path",{d:"M10 14L21 3",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),Tr="trackingTx",an={pending:{icon:_jsxruntime.jsx.call(void 0, _chunk4S3B2JQYcjs.V,{size:"5"}),buttonText:"Trade Pending",showNewSwap:!1,statusVar:"var(--widget-primary)",clickable:!1},received:{icon:_jsxruntime.jsx.call(void 0, _chunk4S3B2JQYcjs.V,{size:"5"}),buttonText:"Trade Received",showNewSwap:!1,statusVar:"var(--widget-primary)",clickable:!1},completed:{icon:_jsxruntime.jsx.call(void 0, _chunk4S3B2JQYcjs.P,{className:"h-5 w-5"}),buttonText:"View Transaction",showNewSwap:!1,statusVar:"var(--widget-status-completed)",clickable:!0},failed:{icon:_jsxruntime.jsx.call(void 0, _chunk4S3B2JQYcjs.Y,{}),buttonText:"Retry Swap",showNewSwap:!0,statusVar:"var(--widget-status-failed)",clickable:!0},cancelled:{icon:_jsxruntime.jsx.call(void 0, _chunk4S3B2JQYcjs.Y,{}),buttonText:"View Transaction",showNewSwap:!1,statusVar:"var(--widget-status-failed)",clickable:!0}},Ar=({orderHash:e,base:t,quote:n,baseAmount:c,quoteAmount:l,reviewState:r,onNewSwap:a,onRetry:v,status:d})=>{let u=_chunk4S3B2JQYcjs.r.call(void 0, Tr,r),s=an[d]||an.pending,o=_chunk3PGCHNG2cjs.d.call(void 0, p=>p.explorerUrl);_react.useEffect.call(void 0, ()=>{if(d==="completed"){let p=setTimeout(a,15e3);return()=>clearTimeout(p)}},[d,a]);let S=()=>{d==="failed"?v():(d==="completed"||d==="cancelled")&&o&&window.open(o,"_blank","noopener,noreferrer")},f=s.statusVar;return _jsxruntime.jsx.call(void 0, "div",{className:"flex flex-row justify-between space-x-3 w-full px-4",children:_jsxruntime.jsx.call(void 0, "button",{type:"button",className:`inline-flex h-12 w-full items-center justify-center text-sm font-sans font-medium transition duration-150 ${s.clickable?"cursor-pointer":"cursor-not-allowed"}`,style:{backgroundColor:`color-mix(in srgb, ${f} 12%, transparent)`,border:`1px solid color-mix(in srgb, ${f} 20%, transparent)`,color:f,borderRadius:"var(--widget-radius)"},onClick:s.clickable?S:void 0,children:_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-10 w-full flex-row items-center space-x-3 px-4",children:[_jsxruntime.jsx.call(void 0, "div",{className:"flex h-6 w-6 items-center justify-center rounded-full overflow-hidden shrink-0",children:s.icon}),_jsxruntime.jsx.call(void 0, "p",{className:"whitespace-nowrap",children:s.buttonText}),_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-1 border-t",style:{borderColor:"var(--widget-border)"}}),s.clickable&&_jsxruntime.jsx.call(void 0, "div",{className:"flex h-6 w-6 items-center justify-center",children:d==="failed"?_jsxruntime.jsx.call(void 0, _chunk4S3B2JQYcjs.X,{}):_jsxruntime.jsx.call(void 0, Rr,{})})]})})})},cn=Ar;var $r=15e3,Ke="unwrapping",Or=({needsToUnwrap:e,amount:t,chainId:n,token:c,reviewState:l,setReviewState:r,goToNextStep:a,cancel:v,delayedClose:d})=>{let u=_chunk4S3B2JQYcjs.r.call(void 0, Ke,l),[s,o]=_react.useState.call(void 0, "idle"),S=Gt(),{writeContractAsync:f}=_wagmi.useWriteContract.call(void 0, ),{address:p}=_chunk34N36GUDcjs.a.call(void 0, ),g=De(),x=_react.useRef.call(void 0, !1),i=_react.useRef.call(void 0, !1),h=_react.useRef.call(void 0, null),{status:A}=_wagmi.useAccount.call(void 0, ),m=_react.useCallback.call(void 0, ()=>{h.current&&(clearTimeout(h.current),h.current=null)},[]),O=_react.useCallback.call(void 0, async()=>{if(!(x.current||i.current||!p||A!=="connected")){x.current=!0,i.current=!0,o("pending"),h.current=setTimeout(()=>{x.current&&(o("error"),x.current=!1)},$r);try{let N=_chunk4S3B2JQYcjs.c.call(void 0, n);if(!N)throw new Error(`No config for chain ${n}`);let I=_nullishCoalesce(N.wrappedAsset.decimals, () => (N.nativeAsset.decimals)),E=_viem.parseUnits.call(void 0, t.toString(),I);await S.mutateAsync({chainId:n,accountAddress:p,amountRaw:E,writeContractAsync:f});let U={symbol:N.nativeAsset.symbol,name:N.nativeAsset.name,address:_chunk4S3B2JQYcjs.a,decimals:N.nativeAsset.decimals,chainId:n},M={symbol:N.wrappedAsset.symbol,name:N.wrappedAsset.name,address:N.wrappedAsset.address,decimals:N.wrappedAsset.decimals,chainId:n};g({type:"unwrap",tokens:[{asset:U,userAddress:p},{asset:M,userAddress:p}]}),m(),o("success"),a(Ke,l),await d()}catch (e7){m(),o("error")}finally{x.current=!1}}},[p,A,n,t,S,f,g,a,l,d,m]);_react.useEffect.call(void 0, ()=>{x.current||i.current||l===Ke&&s==="idle"&&A==="connected"&&(e?O():(o("success"),a(Ke,l)))},[l,s,e,A,O,a]),_react.useEffect.call(void 0, ()=>()=>m(),[m]);let W=()=>{s==="error"&&(i.current=!1,o("idle"))},y=!u&&s==="error",k=!u&&(s==="pending"||s==="idle"||s==="error"),q=y?"var(--widget-status-failed)":"var(--widget-primary)";return _jsxruntime.jsxs.call(void 0, "div",{className:"flex w-full flex-row justify-between space-x-3",children:[_jsxruntime.jsx.call(void 0, "button",{type:"button",className:`inline-flex h-12 w-full items-center justify-center text-sm font-sans font-medium transition duration-150 ${y?"cursor-pointer":"cursor-not-allowed"}`,style:{backgroundColor:`color-mix(in srgb, ${q} 12%, transparent)`,border:`1px solid color-mix(in srgb, ${q} 20%, transparent)`,color:q,borderRadius:"var(--widget-radius)"},onClick:y?W:void 0,children:_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-10 w-full flex-row items-center space-x-3 px-4",children:[_jsxruntime.jsx.call(void 0, "p",{className:"whitespace-nowrap",children:y?"Retry Unwrap":c?`Unwrap ${c.symbol}`:"Unwrap Native Token"}),_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-1 border-t",style:{borderColor:"var(--widget-border)"}}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-6 w-3 items-center justify-center rounded-full",children:[!u&&(s==="pending"||s==="idle")&&_jsxruntime.jsx.call(void 0, _chunk4S3B2JQYcjs.V,{size:"5"}),(u||s==="success")&&_jsxruntime.jsx.call(void 0, _chunk4S3B2JQYcjs.P,{className:"h-8 w-8"}),y&&_jsxruntime.jsx.call(void 0, _chunk4S3B2JQYcjs.S,{className:"h-[12px] w-[12px]"})]})]})}),k&&_jsxruntime.jsx.call(void 0, "button",{type:"button",className:"inline-flex h-12 items-center justify-center px-8 text-sm font-sans font-medium transition duration-150 cursor-pointer",style:{backgroundColor:"color-mix(in srgb, var(--widget-status-failed) 12%, transparent)",border:"1px solid color-mix(in srgb, var(--widget-status-failed) 20%, transparent)",color:"var(--widget-status-failed)",borderRadius:"var(--widget-radius)"},onClick:v,children:"Cancel"})]})},pn=Or;var Lr=15e3,Xe="wrapping",_r=({needsToWrap:e,amount:t,chainId:n,token:c,reviewState:l,setReviewState:r,goToNextStep:a,cancel:v,delayedClose:d,isWrappingPair:u})=>{let s=_chunk4S3B2JQYcjs.r.call(void 0, Xe,l),[o,S]=_react.useState.call(void 0, "idle"),f=Kt(),{writeContractAsync:p}=_wagmi.useWriteContract.call(void 0, ),{address:g}=_chunk34N36GUDcjs.a.call(void 0, ),x=De(),i=_react.useRef.call(void 0, !1),h=_react.useRef.call(void 0, !1),A=_react.useRef.call(void 0, null),{status:m}=_wagmi.useAccount.call(void 0, ),O=_react.useCallback.call(void 0, ()=>{A.current&&(clearTimeout(A.current),A.current=null)},[]),W=_react.useCallback.call(void 0, async()=>{if(!(i.current||h.current||!g||m!=="connected")){i.current=!0,h.current=!0,S("pending"),A.current=setTimeout(()=>{i.current&&(S("error"),i.current=!1)},Lr);try{let I=_chunk4S3B2JQYcjs.c.call(void 0, n);if(!I)throw new Error(`No config for chain ${n}`);let E=_viem.parseUnits.call(void 0, t.toString(),I.nativeAsset.decimals);await f.mutateAsync({chainId:n,accountAddress:g,amountRaw:E,writeContractAsync:p});let U={symbol:I.nativeAsset.symbol,name:I.nativeAsset.name,address:_chunk4S3B2JQYcjs.a,decimals:I.nativeAsset.decimals,chainId:n},M={symbol:I.wrappedAsset.symbol,name:I.wrappedAsset.name,address:I.wrappedAsset.address,decimals:I.wrappedAsset.decimals,chainId:n};x({type:"wrap",tokens:[{asset:U,userAddress:g},{asset:M,userAddress:g}]}),O(),S("success"),a(Xe,l),u&&await d()}catch (e8){O(),S("error")}finally{i.current=!1}}},[g,m,n,t,f,p,x,a,l,d,u,O]);_react.useEffect.call(void 0, ()=>{i.current||h.current||l===Xe&&o==="idle"&&m==="connected"&&(e?W():(S("success"),a(Xe,l)))},[l,o,e,m,W,a]),_react.useEffect.call(void 0, ()=>()=>O(),[O]);let y=()=>{o==="error"&&(h.current=!1,S("idle"))},k=!s&&o==="error",q=!s&&(o==="pending"||o==="idle"||o==="error"),N=k?"var(--widget-status-failed)":"var(--widget-primary)";return _jsxruntime.jsxs.call(void 0, "div",{className:"flex w-full flex-row justify-between space-x-3",children:[_jsxruntime.jsx.call(void 0, "button",{type:"button",className:`inline-flex h-12 w-full items-center justify-center text-sm font-sans font-medium transition duration-150 ${k?"cursor-pointer":"cursor-not-allowed"}`,style:{backgroundColor:`color-mix(in srgb, ${N} 12%, transparent)`,border:`1px solid color-mix(in srgb, ${N} 20%, transparent)`,color:N,borderRadius:"var(--widget-radius)"},onClick:k?y:void 0,children:_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-10 w-full flex-row items-center space-x-3 px-4",children:[_jsxruntime.jsx.call(void 0, "p",{className:"whitespace-nowrap",children:k?"Retry Wrap":c?`Wrap ${c.symbol}`:"Wrap Native Token"}),_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-1 border-t",style:{borderColor:"var(--widget-border)"}}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex h-6 w-3 items-center justify-center rounded-full",children:[!s&&(o==="pending"||o==="idle")&&_jsxruntime.jsx.call(void 0, _chunk4S3B2JQYcjs.V,{size:"5"}),(s||o==="success")&&_jsxruntime.jsx.call(void 0, _chunk4S3B2JQYcjs.P,{className:"h-8 w-8"}),k&&_jsxruntime.jsx.call(void 0, _chunk4S3B2JQYcjs.S,{className:"h-[12px] w-[12px]"})]})]})}),q&&_jsxruntime.jsx.call(void 0, "button",{type:"button",className:"inline-flex h-12 items-center justify-center px-8 text-sm font-sans font-medium transition duration-150 cursor-pointer",style:{backgroundColor:"color-mix(in srgb, var(--widget-status-failed) 12%, transparent)",border:"1px solid color-mix(in srgb, var(--widget-status-failed) 20%, transparent)",color:"var(--widget-status-failed)",borderRadius:"var(--widget-radius)"},onClick:v,children:"Cancel"})]})},gn=_r;var ma=({base:e,baseAmount:t,quote:n,quoteAmount:c,userAddress:l,isWrappingPair:r,isUnwrappingPair:a,isBaseGasToken:v,isQuoteGasToken:d,reviewActionProps:u,reviewState:s,setReviewState:o,trackedOrderHash:S,setTrackedOrderHash:f,txStatus:p,onSwapSubmitted:g,onSwapInitiated:x,onOrderSubmitted:i,onStaleQuoteRestart:h,setExitHandler:A,setRetryHandler:m,startPolling:O,trackNativeTransaction:W})=>{let{rfqQuote:y,status:k,liquidityError:q,routingError:N,sizeCapError:I,stop:E,clear:U}=Fe(),{clearForm:M}=_chunkGK3MOEYUcjs.e.call(void 0, ),Y=_wagmi.useChainId.call(void 0, ),{swapButtonVariant:Z,widgetType:L}=_chunk3PGCHNG2cjs.b.call(void 0, ),T=L==="compact",[_,F]=_react.useState.call(void 0, !1),Q=_react.useRef.call(void 0, !1),C=_react.useRef.call(void 0, null),w=r,P=a,$=!r&&!a,H=Y!==_optionalChain([e, 'optionalAccess', _77 => _77.chainId])&&(w||P||$),de=_chunk4S3B2JQYcjs.c.call(void 0, e.chainId),Ye={chainId:e.chainId,name:_nullishCoalesce(_optionalChain([de, 'optionalAccess', _78 => _78.displayName]), () => (`Chain ${e.chainId}`))},ae=_react.useCallback.call(void 0, (V,Pe)=>{if(Pe!==V)return;if(V==="chain"){if(w){o("wrapping");return}if(P){o("unwrapping");return}o("signingOrder");return}if(V==="signingOrder"){o("trackingTx");return}if(V==="wrapping"){if(!r){o("signingOrder");return}o("wrapSuccess");return}if(V==="unwrapping"){o("wrapSuccess");return}let Ct=_chunk4S3B2JQYcjs.s.call(void 0, V);Ct&&o(Ct)},[o,r,w,P,$]),G=_react.useCallback.call(void 0, ()=>H?"chain":w?"wrapping":P?"unwrapping":$?"signingOrder":null,[H,w,P,$]),ne=_react.useCallback.call(void 0, ()=>{o(null),M()},[M,o]),pe=_react.useCallback.call(void 0, async()=>{o("wrapSuccess");for(let V=0;V<3;V++)await _chunk4S3B2JQYcjs.t.call(void 0, 700);ne()},[ne,o]),fe=_react.useCallback.call(void 0, async()=>{U(),o("cancelled");for(let V=0;V<3;V++)await _chunk4S3B2JQYcjs.t.call(void 0, 500);ne()},[U,ne,o]),J=_react.useCallback.call(void 0, ()=>{S&&(_chunk3PGCHNG2cjs.d.getState().stopTracking(),o(null),f(null),M())},[S,o,f,M]),me=_react.useCallback.call(void 0, ()=>{o(null),f(null),Q.current=!0,_optionalChain([h, 'optionalCall', _79 => _79()])},[o,f,h]),$e=_react.useCallback.call(void 0, ()=>{u&&o(G())},[G,u,o]),be=_react.useCallback.call(void 0, (V=!1)=>{V?(Q.current=!0,o(null),_optionalChain([h, 'optionalCall', _80 => _80()])):(o(null),C.current=setTimeout(()=>{u&&(o(G()),F(!1))},100))},[o,u,G,h]);_react.useEffect.call(void 0, ()=>{s!==null&&E()},[s,E]),_react.useEffect.call(void 0, ()=>{s!==null&&_&&F(!1)},[s,_]),_react.useEffect.call(void 0, ()=>{_optionalChain([A, 'optionalCall', _81 => _81(J)])},[A,J]),_react.useEffect.call(void 0, ()=>(_chunk3PGCHNG2cjs.d.getState().setExitHandler(J),()=>_chunk3PGCHNG2cjs.d.getState().setExitHandler(null)),[J]),_react.useEffect.call(void 0, ()=>{_optionalChain([m, 'optionalCall', _82 => _82(me)])},[m,me]),_react.useEffect.call(void 0, ()=>()=>{C.current&&clearTimeout(C.current)},[]),_react.useEffect.call(void 0, ()=>{Q.current&&k==="fresh"&&_optionalChain([y, 'optionalAccess', _83 => _83.id])&&(Q.current=!1,o("signingOrder"))},[k,_optionalChain([y, 'optionalAccess', _84 => _84.id]),o]);let Te=V=>{if(!V)return{backgroundColor:Z==="default"?"var(--widget-muted)":"transparent",color:"var(--widget-muted-foreground)",border:Z!=="default"?"1px solid var(--widget-border)":"none",borderRadius:"var(--widget-radius)"};switch(Z){case"outline":return{backgroundColor:"transparent",color:"var(--widget-primary)",border:"1px solid var(--widget-primary)",borderRadius:"var(--widget-radius)"};case"ghost":return{backgroundColor:"transparent",color:"var(--widget-primary)",border:"none",borderRadius:"var(--widget-radius)"};default:return{backgroundColor:"var(--widget-primary)",color:"var(--widget-primary-foreground)",borderRadius:"var(--widget-radius)"}}},Oe=`w-full ${T?"py-2":"py-3"} text-sm font-sans font-medium transition-colors cursor-pointer mt-1`;if(s===null&&!r&&!a){if(_)return _jsxruntime.jsx.call(void 0, "button",{className:Oe,disabled:!0,style:{...Te(!1),opacity:.6,cursor:"not-allowed"},children:"Getting fresh quote..."});let V=()=>q?"Insufficient Liquidity":N?"Route Not Available":I?"Size Cap Exceeded":!y&&k==="polling"?"Getting Quote...":y?"Swap":"Enter Amount",Pe=!!u;return _jsxruntime.jsx.call(void 0, "button",{onClick:Pe?$e:void 0,disabled:!Pe,className:`${Oe} disabled:opacity-40 disabled:cursor-not-allowed`,style:Te(Pe),children:V()})}return s===null&&a?_jsxruntime.jsx.call(void 0, "button",{onClick:u?$e:void 0,disabled:!u,className:`${Oe} disabled:opacity-40 disabled:cursor-not-allowed`,style:Te(!!u),children:"Unwrap"}):s===null&&r?_jsxruntime.jsx.call(void 0, "button",{onClick:u?$e:void 0,disabled:!u,className:`${Oe} disabled:opacity-40 disabled:cursor-not-allowed`,style:Te(!!u),children:"Wrap"}):s==="success"?_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-col gap-2 w-full",children:_jsxruntime.jsx.call(void 0, "button",{className:`w-full ${T?"py-2":"py-3"} text-sm font-sans font-medium cursor-default`,style:{backgroundColor:"color-mix(in srgb, var(--widget-status-completed) 15%, transparent)",color:"var(--widget-status-completed)",border:"1px solid color-mix(in srgb, var(--widget-status-completed) 20%, transparent)",borderRadius:"var(--widget-radius)"},children:"Order Placed"})}):s==="wrapSuccess"?_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-col gap-2 w-full",children:_jsxruntime.jsx.call(void 0, "button",{className:`w-full ${T?"py-2":"py-3"} text-sm font-sans font-medium cursor-default`,style:{backgroundColor:"color-mix(in srgb, var(--widget-status-completed) 15%, transparent)",color:"var(--widget-status-completed)",border:"1px solid color-mix(in srgb, var(--widget-status-completed) 20%, transparent)",borderRadius:"var(--widget-radius)"},children:r?"Wrapped Successfully":"Unwrapped Successfully"})}):s==="cancelled"?_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-col gap-2 w-full",children:_jsxruntime.jsx.call(void 0, "button",{onClick:ne,className:`w-full ${T?"py-2":"py-3"} text-sm font-sans font-medium cursor-pointer`,style:{backgroundColor:"color-mix(in srgb, var(--widget-status-failed) 15%, transparent)",color:"var(--widget-status-failed)",border:"1px solid color-mix(in srgb, var(--widget-status-failed) 20%, transparent)",borderRadius:"var(--widget-radius)"},children:"Order Cancelled"})}):_jsxruntime.jsxs.call(void 0, "div",{className:"flex w-full",children:[s==="chain"&&H&&_jsxruntime.jsx.call(void 0, Zt,{requiredChain:Ye,needsChainSwitch:H&&Y!==e.chainId,reviewState:s,goToNextStep:ae,cancel:fe}),s==="wrapping"&&w&&_jsxruntime.jsx.call(void 0, gn,{needsToWrap:w,amount:t,chainId:e.chainId,token:e,reviewState:s,setReviewState:o,goToNextStep:ae,cancel:fe,delayedClose:pe,isWrappingPair:r}),s==="unwrapping"&&P&&_jsxruntime.jsx.call(void 0, pn,{needsToUnwrap:P,amount:t,chainId:e.chainId,token:e,reviewState:s,setReviewState:o,goToNextStep:ae,cancel:fe,delayedClose:pe}),s==="signingOrder"&&$&&_jsxruntime.jsx.call(void 0, on,{base:e,baseAmount:t,quote:n,quoteAmount:c,userAddress:l,reviewState:s,goToNextStep:ae,cancel:fe,restartSigningFlow:be,onSwapInitiated:x,onOrderSubmitted:i,isWrappingPair:r,isUnwrappingPair:a,onSwapSubmitted:g,startPolling:O,trackNativeTransaction:W}),s==="trackingTx"&&S&&_jsxruntime.jsx.call(void 0, cn,{orderHash:S,base:e,quote:n,baseAmount:t,quoteAmount:c,reviewState:s,status:p,onNewSwap:J,onRetry:me}),s&&!["chain","wrapping","unwrapping","approval","signingOrder","trackingTx","success","wrapSuccess","cancelled"].includes(s)&&_jsxruntime.jsx.call(void 0, "button",{disabled:!0,className:`w-full ${T?"py-2":"py-3"} text-sm font-sans font-medium`,style:{backgroundColor:"var(--widget-muted)",color:"var(--widget-muted-foreground)",borderRadius:"var(--widget-radius)"},children:"Processing..."})]})};function ht(e){try{let t=new URL(e).pathname.split("/"),n=t[t.length-1];return n&&n.startsWith("0x")?n:null}catch (e9){return null}}var _shallow = require('zustand/react/shallow');var hn={pending:"var(--widget-status-pending)",received:"var(--widget-status-received)",completed:"var(--widget-status-completed)",failed:"var(--widget-status-failed)",cancelled:"var(--widget-status-failed)"},Qr=({status:e})=>{let t=_nullishCoalesce(hn[e], () => (hn.pending));switch(e){case"completed":return _jsxruntime.jsx.call(void 0, _chunk4S3B2JQYcjs.P,{className:"h-6 w-6"});case"failed":case"cancelled":return _jsxruntime.jsx.call(void 0, _chunk4S3B2JQYcjs.Y,{className:"h-6 w-6"});default:return _jsxruntime.jsx.call(void 0, _chunk4S3B2JQYcjs.V,{size:"5",color:t})}};function jr(e){if(e===0)return"0";let t=Math.abs(e);return t>=1e9?`${(e/1e9).toFixed(2)}B`:t>=1e6?`${(e/1e6).toFixed(2)}M`:t>=1e4?`${(e/1e3).toFixed(2)}K`:t>=1e3?e.toFixed(1):t>=100?e.toFixed(2):t>=1?e.toFixed(4):e.toFixed(6)}function vn(e){let t=e.length;return t<=4?48:t<=6?40:t<=8?34:28}var xt=()=>_jsxruntime.jsxs.call(void 0, "svg",{className:"w-3 h-3 shrink-0",style:{color:"var(--widget-secondary-foreground)"},viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[_jsxruntime.jsx.call(void 0, "path",{d:"M18 13V19C18 20.1046 17.1046 21 16 21H5C3.89543 21 3 20.1046 3 19V8C3 6.89543 3.89543 6 5 6H11",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),_jsxruntime.jsx.call(void 0, "path",{d:"M15 3H21V9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),_jsxruntime.jsx.call(void 0, "path",{d:"M10 14L21 3",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),zr=()=>_jsxruntime.jsxs.call(void 0, "svg",{className:"w-3 h-3 shrink-0",viewBox:"0 0 195 321",fill:"var(--widget-secondary-foreground)",xmlns:"http://www.w3.org/2000/svg",children:[_jsxruntime.jsx.call(void 0, "path",{fillRule:"evenodd",d:"M195,189C195,207.02,195,225.04,194.7,243.21C193.68,244.78,192.9,246.17,192.25,247.63C189.71,253.38,187.74,259.46,184.6,264.86C169.44,290.97,147.86,309.46,118.54,318.86C116.44,319.55,114.72,320.27,113,321C97.65,321,82.29,321,66.36,320.66C64.21,319.86,62.64,319.4,60.77,318.73C34.51,310.12,15.56,293.82,4.22,268.85C3.68,267.66,2.1,266.94,1,266C1,242.31,1,218.62,1.29,194.79C2.84,192.16,4.11,189.7,5.34,187.22C18.42,160.94,39.89,144.07,66.64,133.63C76.92,129.62,87.87,127.33,98.67,124.2C97.79,123.24,96.8,121.93,95.59,120.86C85.84,112.3,75.95,103.89,66.3,95.21C55.93,85.86,45.02,76.96,35.71,66.63C21.14,50.5,20.04,23.08,45.41,9.57C50.08,7.08,55.12,5.26,59.93,3.03C60.76,2.64,61.32,1.69,62,1C86.69,1,111.38,1,136.23,1.32C138.04,2.32,139.67,3.01,141.32,3.67C147.64,6.19,154.12,8.39,160.26,11.32C166.83,14.45,172.19,19.18,175.44,25.95C179.39,34.19,178.09,43.36,172.05,49.56C165.75,56.03,157.21,57.8,148.78,52.89C142.4,49.17,136.86,43.96,131.1,39.23C122.63,32.28,115.05,23.88,105.74,18.38C87.78,7.76,68.84,9.07,51.16,19.53C38.68,26.91,36.37,41.4,45.53,52.71C50.38,58.69,56.45,64,62.83,68.36C87.15,84.99,111.86,101.05,136.34,117.44C162.56,135,183.88,156.57,193.26,187.79C193.42,188.32,194.4,188.6,195,189ZM77.06,146.49C61.39,155.71,51.27,169.26,45.93,186.5C39.48,207.32,39.44,228.5,42.93,249.76C45.84,267.48,53.16,282.95,66.59,295.39C83.82,311.34,108.85,312.86,127.37,298.41C138.98,289.35,146.05,277.03,149.48,263.04C161.53,213.92,148.4,171.97,112.16,137.05C111.13,136.06,108.71,135.6,107.31,136.05C97.38,139.22,87.54,142.7,77.06,146.49Z"}),_jsxruntime.jsx.call(void 0, "path",{d:"M118.83,199C121.61,197.69,122.77,198.41,122.77,201.27C122.71,217.43,122.78,233.58,122.65,249.73C122.65,250.83,121.43,251.92,120.77,253.01C119.97,252.05,118.63,251.17,118.45,250.1C116.32,237.7,113.36,235.12,100.61,235.02C98.12,235,95.62,234.98,93.12,235.01C81.26,235.16,77.72,238.3,75.94,249.84C75.74,251.15,74.39,252.28,73.57,253.49C73.11,253.23,72.64,252.98,72.17,252.73C72.17,234.81,72.17,216.88,72.17,198.96C72.49,198.62,72.81,198.28,73.13,197.93C74.09,198.95,75.72,199.85,75.92,201C78.13,213.8,80.95,216.26,94.05,216.3C97.38,216.31,100.72,216.44,104.04,216.27C113.28,215.79,117.15,212.05,118.22,202.81C118.35,201.65,118.47,200.49,118.83,199Z"})]}),Hr=({orderHash:e,base:t,quote:n,baseAmount:c,quoteAmount:l,status:r})=>{let[a,v]=_react.useState.call(void 0, !1),[d,u]=_react.useState.call(void 0, !0),s=_react.useRef.call(void 0, null),o=_react.useRef.call(void 0, Date.now()),[S,f]=_react.useState.call(void 0, null),p=_react.useRef.call(void 0, null),{isRecipientInputOpen:g,recipient:x,explorerUrl:i}=_chunk3PGCHNG2cjs.d.call(void 0, _shallow.useShallow.call(void 0, w=>({isRecipientInputOpen:w.isRecipientInputOpen,recipient:w.recipient,explorerUrl:w.explorerUrl})));_react.useEffect.call(void 0, ()=>{r==="received"&&(s.current=Date.now())},[r]),_react.useEffect.call(void 0, ()=>{if(r==="completed"&&!S){let w=s.current||o.current;f((Date.now()-w)/1e3)}},[r,S]),_react.useEffect.call(void 0, ()=>()=>{p.current&&clearTimeout(p.current)},[]);let h=_react.useCallback.call(void 0, ()=>{if(!_optionalChain([navigator, 'access', _85 => _85.clipboard, 'optionalAccess', _86 => _86.writeText]))return;let w=i?_nullishCoalesce(ht(i), () => (e)):e;navigator.clipboard.writeText(w).then(()=>{v(!0),p.current&&clearTimeout(p.current),p.current=setTimeout(()=>v(!1),2e3)}).catch(()=>{})},[e,i]),A=_chunk4S3B2JQYcjs.o.call(void 0, c),m=_chunk4S3B2JQYcjs.o.call(void 0, l),O=r==="completed"||r==="failed"||r==="cancelled",W=!O,y=c&&l?c/l:0,k=y>0&&y<1,q=k?1/y:y,N=k?t:n,I=k?n:t,E=_optionalChain([t, 'optionalAccess', _87 => _87.price])?`\u2248 $${(k?t.price:t.price*y).toFixed(2)}`:"",U=_chunk4S3B2JQYcjs.c.call(void 0, t.chainId),M=_chunk4S3B2JQYcjs.c.call(void 0, n.chainId),Y=_nullishCoalesce(_optionalChain([U, 'optionalAccess', _88 => _88.displayName]), () => (`Chain ${t.chainId}`)),Z=_nullishCoalesce(_optionalChain([M, 'optionalAccess', _89 => _89.displayName]), () => (`Chain ${n.chainId}`)),L=t.chainId!==n.chainId,T=_nullishCoalesce(_optionalChain([U, 'optionalAccess', _90 => _90.estimatedTimeMs]), () => (0)),_=_nullishCoalesce(_optionalChain([M, 'optionalAccess', _91 => _91.estimatedTimeMs]), () => (0)),F=(L?T+_:T)/1e3,Q=i?_nullishCoalesce(ht(i), () => (e)):e,C=`${Q.slice(0,6)} \u2026 ${Q.slice(-4)}`;return _jsxruntime.jsxs.call(void 0, "div",{className:"relative w-full flex flex-col",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"mx-4 mt-2",style:{backgroundColor:"var(--widget-secondary)"},children:[_jsxruntime.jsx.call(void 0, "div",{className:"p-5",children:_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center justify-between",children:[_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center gap-3 mb-3",children:[_jsxruntime.jsx.call(void 0, _chunk4S3B2JQYcjs.O,{asset:t,size:"md",noChain:!0}),_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "p",{className:"text-xl font-thin uppercase",style:{color:"var(--widget-foreground)"},children:t.symbol}),_jsxruntime.jsx.call(void 0, "p",{className:"text-xs",style:{color:"var(--widget-muted-foreground)"},children:t.name})]})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"inline-flex items-center gap-1.5 rounded-full px-2.5 py-1",style:{backgroundColor:"color-mix(in srgb, var(--widget-muted-foreground) 20%, transparent)",border:"1px solid color-mix(in srgb, var(--widget-muted-foreground) 30%, transparent)"},children:[_jsxruntime.jsx.call(void 0, _chunk4S3B2JQYcjs.N,{chain:t.chainId,size:"xs"}),_jsxruntime.jsx.call(void 0, "span",{className:"text-xs pt-0.5",style:{color:"var(--widget-muted-foreground)"},children:Y})]})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"text-right",children:[_jsxruntime.jsx.call(void 0, "p",{className:"font-thin tracking-tight font-sans",style:{color:"var(--widget-foreground)",fontSize:`${vn(A)}px`,transition:"font-size 0.1s ease-out"},children:A}),t.price&&_jsxruntime.jsxs.call(void 0, "p",{className:"text-xs mt-1 font-sans",style:{color:"var(--widget-muted-foreground)"},children:["$",(t.price*c).toFixed(2)]})]})]})}),_jsxruntime.jsxs.call(void 0, "div",{className:"relative",children:[_jsxruntime.jsx.call(void 0, "div",{style:{borderTop:"1px solid var(--widget-border)"}}),_jsxruntime.jsx.call(void 0, "div",{className:"absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2",children:_jsxruntime.jsx.call(void 0, "div",{className:"w-10 h-10 rounded-full flex items-center justify-center",style:{backgroundColor:"var(--widget-secondary)",border:"1px solid var(--widget-border)"},children:_jsxruntime.jsx.call(void 0, Qr,{status:r})})})]}),_jsxruntime.jsx.call(void 0, "div",{className:"p-5",children:_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center justify-between",children:[_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center gap-3 mb-3",children:[_jsxruntime.jsx.call(void 0, _chunk4S3B2JQYcjs.O,{asset:n,size:"md",noChain:!0}),_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "p",{className:"text-xl font-thin uppercase",style:{color:"var(--widget-foreground)"},children:n.symbol}),_jsxruntime.jsx.call(void 0, "p",{className:"text-xs",style:{color:"var(--widget-muted-foreground)"},children:n.name})]})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"inline-flex items-center gap-1.5 rounded-full px-2.5 py-1",style:{backgroundColor:"color-mix(in srgb, var(--widget-muted-foreground) 20%, transparent)",border:"1px solid color-mix(in srgb, var(--widget-muted-foreground) 30%, transparent)"},children:[_jsxruntime.jsx.call(void 0, _chunk4S3B2JQYcjs.N,{chain:n.chainId,size:"xs"}),_jsxruntime.jsx.call(void 0, "span",{className:"text-xs pt-0.5",style:{color:"var(--widget-muted-foreground)"},children:Z})]})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"text-right",children:[_jsxruntime.jsx.call(void 0, "p",{className:"font-thin tracking-tight font-sans",style:{color:"var(--widget-foreground)",fontSize:`${vn(m)}px`,transition:"font-size 0.1s ease-out"},children:m}),n.price&&_jsxruntime.jsxs.call(void 0, "p",{className:"text-xs mt-1 font-sans",style:{color:"var(--widget-muted-foreground)"},children:["$",(n.price*l).toFixed(2)]})]})]})})]}),g&&x&&_jsxruntime.jsx.call(void 0, "div",{className:"mx-4 mt-2 px-5 pb-2",children:_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center gap-2 p-2 rounded-full",style:{backgroundColor:"var(--widget-secondary)"},children:[_jsxruntime.jsx.call(void 0, "div",{className:"flex h-5 w-5 items-center justify-center overflow-hidden rounded-full",style:{backgroundColor:"var(--widget-muted)"},children:_jsxruntime.jsx.call(void 0, "span",{className:"text-2xs",children:"\u{1F464}"})}),_jsxruntime.jsx.call(void 0, "span",{className:"text-xs",style:{color:"var(--widget-muted-foreground)"},children:"To:"}),_jsxruntime.jsxs.call(void 0, "span",{className:"text-xs font-sans",style:{color:"var(--widget-foreground)"},children:[x.slice(0,6),"...",x.slice(-4)]})]})}),_jsxruntime.jsxs.call(void 0, "div",{className:"px-4 mt-4",style:{borderTop:"1px solid var(--widget-border)",borderBottom:"1px solid var(--widget-border)"},children:[_jsxruntime.jsx.call(void 0, "div",{className:"relative box-border flex flex-row h-8 w-full items-center cursor-pointer",role:"button",tabIndex:0,onClick:()=>u(!d),onKeyDown:w=>{(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),u(!d))},children:_jsxruntime.jsx.call(void 0, "div",{className:"flex h-full items-center w-full overflow-hidden",style:{color:"var(--widget-muted-foreground)"},children:_jsxruntime.jsxs.call(void 0, "div",{className:"translate-y-px font-sans flex w-full flex-row items-center justify-between",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-row items-center gap-2 whitespace-nowrap",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-row items-center gap-1",children:[_jsxruntime.jsx.call(void 0, _chunk4S3B2JQYcjs.O,{asset:N,size:"3xs",noChain:!0,className:"mb-0.5"}),_jsxruntime.jsxs.call(void 0, "span",{className:"text-xs uppercase",style:{color:"var(--widget-muted-foreground)"},children:["1 ",N.symbol]})]}),_jsxruntime.jsx.call(void 0, "span",{className:"text-xs",style:{color:"var(--widget-muted-foreground)"},children:"="}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-row items-center gap-1",children:[_jsxruntime.jsx.call(void 0, _chunk4S3B2JQYcjs.O,{asset:I,size:"3xs",noChain:!0,className:"mb-0.5"}),_jsxruntime.jsxs.call(void 0, "span",{className:"text-xs uppercase",style:{color:"var(--widget-muted-foreground)"},children:[jr(q)," ",I.symbol]})]}),_jsxruntime.jsx.call(void 0, "span",{className:"text-xs",style:{color:"var(--widget-muted-foreground)"},children:E})]}),_jsxruntime.jsx.call(void 0, "span",{className:"text-xs ml-2 transition-transform duration-200 shrink-0",style:{color:"var(--widget-muted-foreground)",transform:d?"rotate(180deg)":"rotate(0deg)",display:"inline-block"},children:"\u25BE"})]})})}),_jsxruntime.jsx.call(void 0, "div",{className:"overflow-hidden transition-all duration-200",style:{maxHeight:d?"200px":"0px",opacity:d?1:0},children:_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-1 pb-1.5 font-sans",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex justify-between text-2xs",style:{color:"var(--widget-muted-foreground)"},children:[_jsxruntime.jsx.call(void 0, "span",{children:"USD Value"}),_jsxruntime.jsxs.call(void 0, "span",{style:{color:"var(--widget-secondary-foreground)"},children:["$",t.price?(t.price*c).toFixed(2):"\u2014"]})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex justify-between text-2xs",style:{color:"var(--widget-muted-foreground)"},children:[_jsxruntime.jsx.call(void 0, "span",{style:{color:"var(--widget-muted-foreground)"},children:"Order Type"}),_jsxruntime.jsx.call(void 0, "span",{style:{color:"var(--widget-secondary-foreground)"},children:"RFQ (Limit)"})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex justify-between items-center text-2xs",style:{color:"var(--widget-muted-foreground)"},children:[_jsxruntime.jsx.call(void 0, "span",{children:"Transaction"}),i?_jsxruntime.jsxs.call(void 0, "a",{href:i,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 transition-colors hover:opacity-80",style:{color:"var(--widget-secondary-foreground)"},children:[_jsxruntime.jsx.call(void 0, "span",{children:a?"Copied!":C}),_jsxruntime.jsx.call(void 0, xt,{})]}):_jsxruntime.jsxs.call(void 0, "button",{type:"button",onClick:h,className:"flex items-center gap-1 cursor-pointer transition-colors",style:{color:"var(--widget-secondary-foreground)"},children:[_jsxruntime.jsx.call(void 0, "span",{style:{color:"var(--widget-secondary-foreground)"},children:a?"Copied!":C}),_jsxruntime.jsx.call(void 0, xt,{})]})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex justify-between text-2xs",style:{color:"var(--widget-muted-foreground)"},children:[_jsxruntime.jsx.call(void 0, "span",{children:O?"Speed":"Est. Time"}),_jsxruntime.jsx.call(void 0, "span",{style:{color:"var(--widget-secondary-foreground)"},children:S?`${S.toFixed(2)}s`:F>0?`~${F}s`:"\u2014"})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex justify-between items-center text-2xs",style:{color:"var(--widget-muted-foreground)"},children:[_jsxruntime.jsx.call(void 0, "span",{children:"Route"}),_jsxruntime.jsxs.call(void 0, "a",{href:"https://www.aori.io",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 transition-colors hover:opacity-80",style:{color:"var(--widget-secondary-foreground)"},children:[_jsxruntime.jsx.call(void 0, zr,{}),"Aori",_jsxruntime.jsx.call(void 0, xt,{})]})]})]})})]})]})},Ra= exports.v =Hr;exports.a = Rn; exports.b = De; exports.c = Jr; exports.d = ht; exports.e = is; exports.f = Fe; exports.g = Ln; exports.h = ds; exports.i = hs; exports.j = Ss; exports.k = Es; exports.l = Ps; exports.m = jn; exports.n = Vt; exports.o = zn; exports.p = jt; exports.q = zt; exports.r = Ht; exports.s = Gt; exports.t = Kt; exports.u = ma; exports.v = Ra;