@orbs-network/spot-react 1.1.24 → 1.1.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/spot-react/package.json.d.ts +1 -1
- package/dist/spot-react.js +1558 -1749
- package/dist/spot-react.umd.cjs +8 -8
- package/dist/spot-ui/src/lib/build-repermit-order-data.d.ts +1 -1
- package/dist/spot-ui/src/lib/build-repermit-order-data.d.ts.map +1 -1
- package/dist/spot-ui/src/lib/consts.d.ts +0 -26
- package/dist/spot-ui/src/lib/consts.d.ts.map +1 -1
- package/dist/spot-ui/src/lib/orders/v1-orders.d.ts.map +1 -1
- package/dist/spot-ui/src/lib/orders/v2-orders.d.ts.map +1 -1
- package/dist/spot-ui/src/lib/types.d.ts +2 -0
- package/dist/spot-ui/src/lib/types.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/spot-react.umd.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
(function(k,H){typeof exports=="object"&&typeof module<"u"?H(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],H):(k=typeof globalThis<"u"?globalThis:k||self,H(k.SpotReact={},k.jsxRuntime,k.React))})(this,(function(k,H,v){"use strict";var su=Object.defineProperty;var Ks=k=>{throw TypeError(k)};var iu=(k,H,v)=>H in k?su(k,H,{enumerable:!0,configurable:!0,writable:!0,value:v}):k[H]=v;var Pn=(k,H,v)=>iu(k,typeof H!="symbol"?H+"":H,v),yr=(k,H,v)=>H.has(k)||Ks("Cannot "+v);var l=(k,H,v)=>(yr(k,H,"read from private field"),v?v.call(k):H.get(k)),N=(k,H,v)=>H.has(k)?Ks("Cannot add the same private member more than once"):H instanceof WeakSet?H.add(k):H.set(k,v),_=(k,H,v,_t)=>(yr(k,H,"write to private field"),_t?_t.call(k,v):H.set(k,v),v),z=(k,H,v)=>(yr(k,H,"access private method"),v);var Fn=(k,H,v,_t)=>({set _(ue){_(k,H,ue,v)},get _(){return l(k,H,_t)}});var Ke,xt,Os,St,at,qt,Is,Kt,ot,Ht,ks,vt,Ms,Pt,Wt,Me,Ft,he,rn,Dt,Re,Je,_s,ve,X,sn,Te,Ot,Qt,Ve,ut,an,jt,zt,It,kt,ct,$t,ee,dn,gr,Ar,Er,br,Tr,wr,Cr,Hs,Bs,on,He,we,Mt,We,ft,Us,Ge,Le,un,Rs,Xe,dt,Pe,Ze,Ye,Dn,xr,Ls,Qe,Ns,se,lt,pt,Vt,Gt,ht,Xt,Zt,qs;function _t(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const ue=_t(v),$={SpookySwap:{chainName:"ftm",chainId:250,twapVersion:4,twapAddress:"0xd3B290FEB04E353d1821bc0a12397FdEa9a846C0",lensAddress:"0x0221EfDF1Fd3212AF87F23cceB7693a65fAF1d7f",takers:["0xDF406A27C58a8Cd6Fd43e143339bCE131216a913","0x504f6E10173249dD22491829D98862Cf81DeF79E"],bidDelaySeconds:60,minChunkSizeUsd:10,name:"SpookySwap",partner:"Orbs:TWAP:SpookySwap",exchangeAddress:"0xdF7CCd5fc7077E9de5f27a7b7bfDC837c82f8496",exchangeType:"ExchangeV2",pathfinderKey:""},SpookySwapSonic:{chainName:"sonic",chainId:146,twapVersion:4,twapAddress:"0x8963992816b4EafE5a22b7DB2A99513c18be9afA",lensAddress:"0x67e631F71232D63AcA98a2D5E9B2Bce5FCc39d5D",takers:["0xDF406A27C58a8Cd6Fd43e143339bCE131216a913","0x504f6E10173249dD22491829D98862Cf81DeF79E"],bidDelaySeconds:60,minChunkSizeUsd:10,name:"SpookySwapSonic",partner:"Orbs:TWAP:SpookySwap",exchangeAddress:"0x6699bE3aF75e5c1B807b1031dBde6dA9A67739F3",exchangeType:"ExchangeV2",pathfinderKey:""},QuickSwap:{chainName:"poly",chainId:137,twapVersion:4,twapAddress:"0x688C027B0f7FaCeFcBa73e472900d28c12C5bDF4",lensAddress:"0xe0D4E736fc76af7C256ae7652c8c1e850bfb7849",takers:["0xA05405b6340A7F43dC5835351BFC4f5b1F028359","0xE3Efef1563a5960ACc731F9e4d6f4cBf5bd87dcA"],bidDelaySeconds:60,minChunkSizeUsd:10,name:"QuickSwap",partner:"Orbs:TWAP:QuickSwap",exchangeAddress:"0x8FCc245209bE85C49D738D0CE5613F74E5d91E86",exchangeType:"ParaswapExchange",pathfinderKey:"QuickSwap,QuickSwapV3"},QuickSwapBase:{chainName:"base",chainId:8453,twapVersion:4,twapAddress:"0xc918bdC47264687796Cd54FE362FaC4f8b99Eb55",lensAddress:"0x6313188c1909b161074D62E43105faC9B756A23e",takers:["0xA05405b6340A7F43dC5835351BFC4f5b1F028359","0xE3Efef1563a5960ACc731F9e4d6f4cBf5bd87dcA"],bidDelaySeconds:60,minChunkSizeUsd:10,name:"QuickSwap",partner:"Orbs:TWAP:QuickSwap",exchangeAddress:"0xb7a3d74895bfd3aff6780525e36d79fcf26a895f",exchangeType:"ExchangeV2",pathfinderKey:""},Thena:{chainName:"bsc",chainId:56,twapVersion:4,twapAddress:"0xa6F7444D2b92Aa9F94a2165c77aAF2B671e63994",lensAddress:"0xEdB0c077fa87Fb21d050c619FF426798f8Fc1264",takers:["0xA05405b6340A7F43dC5835351BFC4f5b1F028359","0xE3Efef1563a5960ACc731F9e4d6f4cBf5bd87dcA"],bidDelaySeconds:60,minChunkSizeUsd:50,name:"Thena",partner:"Orbs:TWAP:Thena",exchangeAddress:"0x2B2fABDbfa4a15da0d351F947C14F4520db0bDc1",exchangeType:"ExchangeV2",pathfinderKey:"43,47"},PancakeSwap:{chainName:"bsc",chainId:56,twapVersion:4,twapAddress:"0xa6F7444D2b92Aa9F94a2165c77aAF2B671e63994",lensAddress:"0xEdB0c077fa87Fb21d050c619FF426798f8Fc1264",takers:["0xA05405b6340A7F43dC5835351BFC4f5b1F028359","0xE3Efef1563a5960ACc731F9e4d6f4cBf5bd87dcA"],bidDelaySeconds:60,minChunkSizeUsd:50,name:"PancakeSwap",partner:"Orbs:TWAP:PancakeSwap",exchangeAddress:"0x1A2bb6B75D58b740d88413ef4840D6fa3F637940",exchangeType:"P2Exchange",pathfinderKey:""},PancakeSwapArbitrum:{chainName:"arb",chainId:42161,twapVersion:4,twapAddress:"0x0B94dcC0EA2d1ee33Ab064DaC252de980a941eF3",lensAddress:"0x549e1fc9a47FCc0C5C2EbdfF31254cc49fF7164e",takers:["0xA05405b6340A7F43dC5835351BFC4f5b1F028359","0xE3Efef1563a5960ACc731F9e4d6f4cBf5bd87dcA"],bidDelaySeconds:60,minChunkSizeUsd:50,name:"PancakeSwap",partner:"Orbs:TWAP:PancakeSwap",exchangeAddress:"0xb37cB9A058c03081Ae6EF934313588cD53d408e7",exchangeType:"P2Exchange",pathfinderKey:""},PancakeSwapBase:{chainName:"base",chainId:8453,twapVersion:4,twapAddress:"0xc918bdC47264687796Cd54FE362FaC4f8b99Eb55",lensAddress:"0x6313188c1909b161074D62E43105faC9B756A23e",takers:["0xA05405b6340A7F43dC5835351BFC4f5b1F028359","0xE3Efef1563a5960ACc731F9e4d6f4cBf5bd87dcA"],bidDelaySeconds:60,minChunkSizeUsd:50,name:"PancakeSwap",partner:"Orbs:TWAP:PancakeSwap",exchangeAddress:"0xb37cB9A058c03081Ae6EF934313588cD53d408e7",exchangeType:"P2Exchange",pathfinderKey:""},PancakeSwapLinea:{chainName:"linea",chainId:59144,twapVersion:4,twapAddress:"0x48423e62acbfEF7779b5b4a5E7d6Fbd39E623d78",lensAddress:"0xe84CaEc86eCF3f0AB4267dC6130D9a5510e73DFb",takers:["0xA05405b6340A7F43dC5835351BFC4f5b1F028359","0xE3Efef1563a5960ACc731F9e4d6f4cBf5bd87dcA"],bidDelaySeconds:60,minChunkSizeUsd:100,name:"PancakeSwap",partner:"Orbs:TWAP:PancakeSwap",exchangeAddress:"0xb37cB9A058c03081Ae6EF934313588cD53d408e7",exchangeType:"P2Exchange",pathfinderKey:""},Lynex:{chainName:"linea",chainId:59144,twapVersion:4,twapAddress:"0x48423e62acbfEF7779b5b4a5E7d6Fbd39E623d78",lensAddress:"0xe84CaEc86eCF3f0AB4267dC6130D9a5510e73DFb",takers:["0xA05405b6340A7F43dC5835351BFC4f5b1F028359","0xE3Efef1563a5960ACc731F9e4d6f4cBf5bd87dcA"],bidDelaySeconds:60,minChunkSizeUsd:100,name:"Lynex",partner:"Orbs:TWAP:Lynex",exchangeAddress:"0x04C06C96d7D19977156016DD408B5992af0570a2",exchangeType:"ExchangeV2",pathfinderKey:"19,18"},SushiArb:{chainName:"arb",chainId:42161,twapVersion:4,twapAddress:"0x0B94dcC0EA2d1ee33Ab064DaC252de980a941eF3",lensAddress:"0x549e1fc9a47FCc0C5C2EbdfF31254cc49fF7164e",takers:["0xA05405b6340A7F43dC5835351BFC4f5b1F028359","0xE3Efef1563a5960ACc731F9e4d6f4cBf5bd87dcA"],bidDelaySeconds:60,minChunkSizeUsd:50,name:"SushiArb",partner:"Orbs:TWAP:Sushi",exchangeAddress:"0x04eB53119079FA779492720D1EfeAEBF0aF2e5ad",exchangeType:"ExchangeV2",pathfinderKey:""},SushiBase:{chainName:"base",chainId:8453,twapVersion:4,twapAddress:"0xc918bdC47264687796Cd54FE362FaC4f8b99Eb55",lensAddress:"0x6313188c1909b161074D62E43105faC9B756A23e",takers:["0xA05405b6340A7F43dC5835351BFC4f5b1F028359","0xE3Efef1563a5960ACc731F9e4d6f4cBf5bd87dcA"],bidDelaySeconds:60,minChunkSizeUsd:50,name:"SushiBase",partner:"Orbs:TWAP:Sushi",exchangeAddress:"0x04eB53119079FA779492720D1EfeAEBF0aF2e5ad",exchangeType:"ExchangeV2",pathfinderKey:""},SushiEth:{chainName:"eth",chainId:1,twapVersion:4,twapAddress:"0xb1ed8BCAD1EaC8a1DF0764700472391800D12946",lensAddress:"0x0967f448c4d4dbd14c355E635AE9CbF68cc44A60",takers:["0xA05405b6340A7F43dC5835351BFC4f5b1F028359","0xE3Efef1563a5960ACc731F9e4d6f4cBf5bd87dcA"],bidDelaySeconds:60,minChunkSizeUsd:200,name:"SushiEth",partner:"Orbs:TWAP:Sushi",exchangeAddress:"0x04eB53119079FA779492720D1EfeAEBF0aF2e5ad",exchangeType:"ExchangeV2",pathfinderKey:""},SushiKatana:{chainName:"katana",chainId:747474,twapVersion:4,twapAddress:"0xf2d96E7BE676153d202e1453804E2749923C7c5b",lensAddress:"0x1579EED0527781B1A748043AA1f59a3858Ace4a7",takers:["0xF74437A3Fc45a518640828E5D6A3E8c9A9BbDC3a","0x07A6C715063e94c0D95e809efefFCbF4EBEdfD55"],bidDelaySeconds:60,minChunkSizeUsd:50,name:"SushiKatana",partner:"Orbs:TWAP:Sushi",exchangeAddress:"0x92209481507e6B2d14C9b5b70Ed287024177220E",exchangeType:"ExchangeV2",pathfinderKey:""},DragonSwap:{chainId:1329,name:"DragonSwap"},SwapX:{chainName:"sonic",chainId:146,twapVersion:4,twapAddress:"0x8963992816b4EafE5a22b7DB2A99513c18be9afA",lensAddress:"0x67e631F71232D63AcA98a2D5E9B2Bce5FCc39d5D",takers:["0xDF406A27C58a8Cd6Fd43e143339bCE131216a913","0x504f6E10173249dD22491829D98862Cf81DeF79E"],bidDelaySeconds:60,minChunkSizeUsd:10,name:"SwapX",partner:"Orbs:TWAP:SwapX",exchangeAddress:"0xDA902994b7F7a1ecDd8De02E4a17dbFF2E6F67b7",exchangeType:"ExchangeV2",pathfinderKey:""},BlackholeAvax:{chainName:"avax",chainId:43114,twapVersion:4,twapAddress:"0xf77Ad005aBF7e31f669ce89a6568B2f39Ca92cDe",lensAddress:"0x48466B82Ce1575c5c9eCa168ac1090048dD47fA3",takers:["0xA05405b6340A7F43dC5835351BFC4f5b1F028359","0xE3Efef1563a5960ACc731F9e4d6f4cBf5bd87dcA"],bidDelaySeconds:60,minChunkSizeUsd:50,name:"BlackholeAvax",partner:"Orbs:TWAP:BlackholeAvax",exchangeAddress:"0xb7A3d74895bFD3Aff6780525e36D79FCf26a895F",exchangeType:"ExchangeV2"}},Ws=JSON.parse('[{"inputs":[{"internalType":"address","name":"_iweth","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint64","name":"id","type":"uint64"},{"indexed":true,"internalType":"address","name":"maker","type":"address"},{"indexed":true,"internalType":"address","name":"exchange","type":"address"},{"indexed":false,"internalType":"uint32","name":"slippagePercent","type":"uint32"},{"components":[{"internalType":"uint32","name":"time","type":"uint32"},{"internalType":"address","name":"taker","type":"address"},{"internalType":"address","name":"exchange","type":"address"},{"internalType":"uint256","name":"dstAmount","type":"uint256"},{"internalType":"uint256","name":"dstFee","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"indexed":false,"internalType":"struct OrderLib.Bid","name":"bid","type":"tuple"}],"name":"OrderBid","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint64","name":"id","type":"uint64"},{"indexed":true,"internalType":"address","name":"maker","type":"address"},{"indexed":false,"internalType":"address","name":"sender","type":"address"}],"name":"OrderCanceled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint64","name":"id","type":"uint64"},{"indexed":true,"internalType":"address","name":"maker","type":"address"},{"indexed":true,"internalType":"address","name":"exchange","type":"address"},{"indexed":false,"internalType":"address","name":"taker","type":"address"}],"name":"OrderCompleted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint64","name":"id","type":"uint64"},{"indexed":true,"internalType":"address","name":"maker","type":"address"},{"indexed":true,"internalType":"address","name":"exchange","type":"address"},{"components":[{"internalType":"address","name":"exchange","type":"address"},{"internalType":"address","name":"srcToken","type":"address"},{"internalType":"address","name":"dstToken","type":"address"},{"internalType":"uint256","name":"srcAmount","type":"uint256"},{"internalType":"uint256","name":"srcBidAmount","type":"uint256"},{"internalType":"uint256","name":"dstMinAmount","type":"uint256"},{"internalType":"uint32","name":"deadline","type":"uint32"},{"internalType":"uint32","name":"bidDelay","type":"uint32"},{"internalType":"uint32","name":"fillDelay","type":"uint32"},{"internalType":"bytes","name":"data","type":"bytes"}],"indexed":false,"internalType":"struct OrderLib.Ask","name":"ask","type":"tuple"}],"name":"OrderCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint64","name":"id","type":"uint64"},{"indexed":true,"internalType":"address","name":"maker","type":"address"},{"indexed":true,"internalType":"address","name":"exchange","type":"address"},{"indexed":false,"internalType":"address","name":"taker","type":"address"},{"indexed":false,"internalType":"uint256","name":"srcAmountIn","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"dstAmountOut","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"dstFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"srcFilledAmount","type":"uint256"}],"name":"OrderFilled","type":"event"},{"inputs":[],"name":"MIN_BID_DELAY_SECONDS","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MIN_OUTBID_PERCENT","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PERCENT_BASE","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"STALE_BID_SECONDS","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"STATUS_CANCELED","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"STATUS_COMPLETED","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"VERSION","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"exchange","type":"address"},{"internalType":"address","name":"srcToken","type":"address"},{"internalType":"address","name":"dstToken","type":"address"},{"internalType":"uint256","name":"srcAmount","type":"uint256"},{"internalType":"uint256","name":"srcBidAmount","type":"uint256"},{"internalType":"uint256","name":"dstMinAmount","type":"uint256"},{"internalType":"uint32","name":"deadline","type":"uint32"},{"internalType":"uint32","name":"bidDelay","type":"uint32"},{"internalType":"uint32","name":"fillDelay","type":"uint32"},{"internalType":"bytes","name":"data","type":"bytes"}],"internalType":"struct OrderLib.Ask","name":"_ask","type":"tuple"}],"name":"ask","outputs":[{"internalType":"uint64","name":"id","type":"uint64"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint64","name":"id","type":"uint64"},{"internalType":"address","name":"exchange","type":"address"},{"internalType":"uint256","name":"dstFee","type":"uint256"},{"internalType":"uint32","name":"slippagePercent","type":"uint32"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"bid","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"book","outputs":[{"internalType":"uint64","name":"id","type":"uint64"},{"internalType":"uint32","name":"status","type":"uint32"},{"internalType":"uint32","name":"time","type":"uint32"},{"internalType":"uint32","name":"filledTime","type":"uint32"},{"internalType":"uint256","name":"srcFilledAmount","type":"uint256"},{"internalType":"address","name":"maker","type":"address"},{"components":[{"internalType":"address","name":"exchange","type":"address"},{"internalType":"address","name":"srcToken","type":"address"},{"internalType":"address","name":"dstToken","type":"address"},{"internalType":"uint256","name":"srcAmount","type":"uint256"},{"internalType":"uint256","name":"srcBidAmount","type":"uint256"},{"internalType":"uint256","name":"dstMinAmount","type":"uint256"},{"internalType":"uint32","name":"deadline","type":"uint32"},{"internalType":"uint32","name":"bidDelay","type":"uint32"},{"internalType":"uint32","name":"fillDelay","type":"uint32"},{"internalType":"bytes","name":"data","type":"bytes"}],"internalType":"struct OrderLib.Ask","name":"ask","type":"tuple"},{"components":[{"internalType":"uint32","name":"time","type":"uint32"},{"internalType":"address","name":"taker","type":"address"},{"internalType":"address","name":"exchange","type":"address"},{"internalType":"uint256","name":"dstAmount","type":"uint256"},{"internalType":"uint256","name":"dstFee","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"internalType":"struct OrderLib.Bid","name":"bid","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64","name":"id","type":"uint64"}],"name":"cancel","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint64","name":"id","type":"uint64"}],"name":"fill","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"iweth","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"length","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"makerOrders","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64","name":"id","type":"uint64"}],"name":"order","outputs":[{"components":[{"internalType":"uint64","name":"id","type":"uint64"},{"internalType":"uint32","name":"status","type":"uint32"},{"internalType":"uint32","name":"time","type":"uint32"},{"internalType":"uint32","name":"filledTime","type":"uint32"},{"internalType":"uint256","name":"srcFilledAmount","type":"uint256"},{"internalType":"address","name":"maker","type":"address"},{"components":[{"internalType":"address","name":"exchange","type":"address"},{"internalType":"address","name":"srcToken","type":"address"},{"internalType":"address","name":"dstToken","type":"address"},{"internalType":"uint256","name":"srcAmount","type":"uint256"},{"internalType":"uint256","name":"srcBidAmount","type":"uint256"},{"internalType":"uint256","name":"dstMinAmount","type":"uint256"},{"internalType":"uint32","name":"deadline","type":"uint32"},{"internalType":"uint32","name":"bidDelay","type":"uint32"},{"internalType":"uint32","name":"fillDelay","type":"uint32"},{"internalType":"bytes","name":"data","type":"bytes"}],"internalType":"struct OrderLib.Ask","name":"ask","type":"tuple"},{"components":[{"internalType":"uint32","name":"time","type":"uint32"},{"internalType":"address","name":"taker","type":"address"},{"internalType":"address","name":"exchange","type":"address"},{"internalType":"uint256","name":"dstAmount","type":"uint256"},{"internalType":"uint256","name":"dstFee","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"internalType":"struct OrderLib.Bid","name":"bid","type":"tuple"}],"internalType":"struct OrderLib.Order","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"maker","type":"address"}],"name":"orderIdsByMaker","outputs":[{"internalType":"uint64[]","name":"","type":"uint64[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64","name":"id","type":"uint64"}],"name":"prune","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"status","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]'),Qs=[{type:"constructor",inputs:[],stateMutability:"nonpayable"},{type:"function",name:"DOMAIN_SEPARATOR",inputs:[],outputs:[{name:"",type:"bytes32",internalType:"bytes32"}],stateMutability:"view"},{type:"function",name:"cancel",inputs:[{name:"digests",type:"bytes32[]",internalType:"bytes32[]"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"eip712Domain",inputs:[],outputs:[{name:"fields",type:"bytes1",internalType:"bytes1"},{name:"name",type:"string",internalType:"string"},{name:"version",type:"string",internalType:"string"},{name:"chainId",type:"uint256",internalType:"uint256"},{name:"verifyingContract",type:"address",internalType:"address"},{name:"salt",type:"bytes32",internalType:"bytes32"},{name:"extensions",type:"uint256[]",internalType:"uint256[]"}],stateMutability:"view"},{type:"function",name:"hashTypedData",inputs:[{name:"structHash",type:"bytes32",internalType:"bytes32"}],outputs:[{name:"digest",type:"bytes32",internalType:"bytes32"}],stateMutability:"view"},{type:"function",name:"repermitWitnessTransferFrom",inputs:[{name:"permit",type:"tuple",internalType:"struct RePermitLib.RePermitTransferFrom",components:[{name:"permitted",type:"tuple",internalType:"struct RePermitLib.TokenPermissions",components:[{name:"token",type:"address",internalType:"address"},{name:"amount",type:"uint256",internalType:"uint256"}]},{name:"nonce",type:"uint256",internalType:"uint256"},{name:"deadline",type:"uint256",internalType:"uint256"}]},{name:"request",type:"tuple",internalType:"struct RePermitLib.TransferRequest",components:[{name:"to",type:"address",internalType:"address"},{name:"amount",type:"uint256",internalType:"uint256"}]},{name:"signer",type:"address",internalType:"address"},{name:"witness",type:"bytes32",internalType:"bytes32"},{name:"witnessTypeString",type:"string",internalType:"string"},{name:"signature",type:"bytes",internalType:"bytes"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"spent",inputs:[{name:"",type:"address",internalType:"address"},{name:"",type:"bytes32",internalType:"bytes32"}],outputs:[{name:"",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"event",name:"Cancel",inputs:[{name:"signer",type:"address",indexed:!0,internalType:"address"},{name:"digest",type:"bytes32",indexed:!1,internalType:"bytes32"}],anonymous:!1},{type:"event",name:"EIP712DomainChanged",inputs:[],anonymous:!1},{type:"event",name:"Spend",inputs:[{name:"signer",type:"address",indexed:!0,internalType:"address"},{name:"permitHash",type:"bytes32",indexed:!0,internalType:"bytes32"},{name:"token",type:"address",indexed:!0,internalType:"address"},{name:"to",type:"address",indexed:!1,internalType:"address"},{name:"amount",type:"uint256",indexed:!1,internalType:"uint256"},{name:"totalSpent",type:"uint256",indexed:!1,internalType:"uint256"}],anonymous:!1},{type:"error",name:"Canceled",inputs:[]},{type:"error",name:"Expired",inputs:[]},{type:"error",name:"InsufficientAllowance",inputs:[]},{type:"error",name:"InvalidShortString",inputs:[]},{type:"error",name:"InvalidSignature",inputs:[]},{type:"error",name:"SafeERC20FailedOperation",inputs:[{name:"token",type:"address",internalType:"address"}]},{type:"error",name:"StringTooLong",inputs:[{name:"str",type:"string",internalType:"string"}]}],js=Ws;var j=(e=>(e.TWAP="TWAP",e.LIMIT="LIMIT",e.STOP_LOSS="STOP_LOSS",e.TAKE_PROFIT="TAKE_PROFIT",e))(j||{}),fe=(e=>(e.Open="OPEN",e.Cancelled="CANCELLED",e.Completed="COMPLETED",e.Expired="EXPIRED",e))(fe||{}),Sr=(e=>(e.All="ALL",e.Open="OPEN",e.Cancelled="CANCELLED",e.Completed="COMPLETED",e.Expired="EXPIRED",e))(Sr||{}),Fe=(e=>(e[e.Minutes=6e4]="Minutes",e[e.Hours=36e5]="Hours",e[e.Weeks=6048e5]="Weeks",e[e.Days=864e5]="Days",e[e.Months=2592e6]="Months",e[e.Years=31536e6]="Years",e))(Fe||{}),V=(e=>(e.LIMIT="limit",e.TWAP_LIMIT="twap-limit",e.TWAP_MARKET="twap-market",e.TAKE_PROFIT_MARKET="take-profit-market",e.TAKE_PROFIT_LIMIT="take-profit-limit",e.STOP_LOSS_LIMIT="stop-loss-limit",e.STOP_LOSS_MARKET="stop-loss-market",e))(V||{}),Ne=(e=>(e.Arbidex="arbidex",e.Blackhole="blackhole",e.Chronos="chronos",e.Dragon="dragon",e.Kodiak="kodiak",e.Lynex="lynex",e.Nami="nami",e.Newera="newera",e.Omni="omni",e.Pancake="pancake",e.Quick="quick",e.Ramses="ramses",e.Shadow="shadow",e.Spark="spark",e.Spooky="spooky",e.Swapx="swapx",e.Teafi="teafi",e.Thena="thena",e.Yowie="yowie",e.Pangolin="pangolin",e.Sushiswap="sushiswap",e.Agent="agent",e))(Ne||{}),me=(e=>(e.EMPTY_LIMIT_PRICE="emptyLimitPrice",e.MAX_CHUNKS="maxChunksError",e.MIN_CHUNKS="minChunksError",e.MIN_TRADE_SIZE="minTradeSizeError",e.MAX_FILL_DELAY="maxFillDelayError",e.MIN_FILL_DELAY="minFillDelayError",e.MAX_ORDER_DURATION="maxDurationError",e.MIN_ORDER_DURATION="minDurationError",e.MISSING_LIMIT_PRICE="missingLimitPrice",e.STOP_LOSS_TRIGGER_PRICE_GREATER_THAN_MARKET_PRICE="StopLossTriggerPriceError",e.TRIGGER_LIMIT_PRICE_GREATER_THAN_TRIGGER_PRICE="triggerLimitPriceError",e.TAKE_PROFIT_TRIGGER_PRICE_LESS_THAN_MARKET_PRICE="TakeProfitTriggerPriceError",e.EMPTY_TRIGGER_PRICE="emptyTriggerPrice",e.INSUFFICIENT_BALANCE="insufficientFunds",e.MAX_ORDER_SIZE="maxOrderSize",e.MIN_TRADE_SIZE_ERROR="minTradeSizeError",e))(me||{});const re="0x0000000000000000000000000000000000000000",ye={eth:{id:1,name:"Ethereum",shortname:"eth",native:{address:re,symbol:"ETH",decimals:18,logoUrl:"https://app.1inch.io/assets/images/network-logos/ethereum.svg"},wToken:{symbol:"WETH",address:"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",decimals:18,logoUrl:"https://tokens-data.1inch.io/images/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2.png"},publicRpcUrl:"https://eth.llamarpc.com",logoUrl:"https://app.1inch.io/assets/images/network-logos/ethereum.svg",explorer:"https://etherscan.io",eip1559:!0},bsc:{id:56,name:"BinanceSmartChain",shortname:"bsc",native:{address:re,symbol:"BNB",decimals:18,logoUrl:"https://s2.coinmarketcap.com/static/img/coins/128x128/1839.png"},wToken:{symbol:"WBNB",address:"0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c",decimals:18,logoUrl:"https://s2.coinmarketcap.com/static/img/coins/128x128/1839.png"},publicRpcUrl:"https://bsc-dataseed.binance.org",logoUrl:"https://app.1inch.io/assets/images/network-logos/bsc_2.svg",explorer:"https://bscscan.com",eip1559:!1},poly:{id:137,name:"Polygon",shortname:"poly",native:{address:re,symbol:"POL",decimals:18,logoUrl:"https://s2.coinmarketcap.com/static/img/coins/64x64/28321.png"},wToken:{symbol:"WPOL",address:"0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270",decimals:18,logoUrl:"https://tokens-data.1inch.io/images/0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270.png"},publicRpcUrl:"https://polygon-rpc.com",logoUrl:"https://app.1inch.io/assets/images/network-logos/polygon.svg",explorer:"https://polygonscan.com",eip1559:!0},arb:{id:42161,name:"Arbitrum",shortname:"arb",native:{address:re,symbol:"ETH",decimals:18,logoUrl:"https://app.1inch.io/assets/images/network-logos/ethereum.svg"},wToken:{symbol:"WETH",address:"0x82af49447d8a07e3bd95bd0d56f35241523fbab1",decimals:18,logoUrl:"https://tokens-data.1inch.io/images/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2.png"},publicRpcUrl:"https://arb1.arbitrum.io/rpc",logoUrl:"https://app.1inch.io/assets/images/network-logos/arbitrum.svg",explorer:"https://arbiscan.io",eip1559:!0},sei:{id:1329,name:"Sei",shortname:"sei",native:{address:re,symbol:"SEI",decimals:18,logoUrl:"https://assets.coingecko.com/coins/images/28205/standard/Sei_Logo_-_Transparent.png"},wToken:{symbol:"WSEI",address:"0xE30feDd158A2e3b13e9badaeABaFc5516e95e8C7",decimals:18,logoUrl:"https://tokens-data.1inch.io/images/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2.png"},publicRpcUrl:"https://evm-rpc.sei-apis.com",logoUrl:"https://assets.coingecko.com/coins/images/28205/standard/Sei_Logo_-_Transparent.png",explorer:"https://seitrace.com",eip1559:!1},avax:{id:43114,name:"Avalanche",shortname:"avax",native:{address:re,symbol:"AVAX",decimals:18,logoUrl:"https://app.1inch.io/assets/images/network-logos/avalanche.svg"},wToken:{symbol:"WAVAX",address:"0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7",decimals:18,logoUrl:"https://tokens-data.1inch.io/images/0xb31f66aa3c1e785363f0875a1b74e27b85fd66c7.png"},publicRpcUrl:"https://api.avax.network/ext/bc/C/rpc",logoUrl:"https://app.1inch.io/assets/images/network-logos/avalanche.svg",explorer:"https://snowtrace.io",eip1559:!0},ftm:{id:250,name:"Fantom",shortname:"ftm",native:{address:re,symbol:"FTM",decimals:18,logoUrl:"https://app.1inch.io/assets/images/network-logos/fantom.svg"},wToken:{symbol:"WFTM",address:"0x21be370D5312f44cB42ce377BC9b8a0cEF1A4C83",decimals:18,logoUrl:"https://tokens-data.1inch.io/images/0x4e15361fd6b4bb609fa63c81a2be19d873717870.png"},publicRpcUrl:"https://rpc.ftm.tools",logoUrl:"https://app.1inch.io/assets/images/network-logos/fantom.svg",explorer:"https://ftmscan.com",eip1559:!0},base:{id:8453,name:"Base",shortname:"base",native:{address:re,symbol:"ETH",decimals:18,logoUrl:"https://s2.coinmarketcap.com/static/img/coins/128x128/1027.png"},wToken:{symbol:"WETH",address:"0x4200000000000000000000000000000000000006",decimals:18,logoUrl:"https://tokens-data.1inch.io/images/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2.png"},publicRpcUrl:"https://mainnet.base.org",logoUrl:"https://app.1inch.io/assets/images/network-logos/base.svg",explorer:"https://basescan.org",eip1559:!1},linea:{id:59144,name:"Linea",shortname:"linea",native:{address:re,symbol:"ETH",decimals:18,logoUrl:"https://app.1inch.io/assets/images/network-logos/ethereum.svg"},wToken:{symbol:"WETH",address:"0xe5D7C2a44FfDDf6b295A15c148167daaAf5Cf34f",decimals:18,logoUrl:"https://tokens-data.1inch.io/images/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2.png"},publicRpcUrl:"https://rpc.linea.build",logoUrl:"https://lineascan.build/images/logo.svg",explorer:"https://lineascan.build",eip1559:!1},zksync:{id:324,name:"zksync",shortname:"zksync",native:{address:re,symbol:"ETH",decimals:18,logoUrl:"https://app.1inch.io/assets/images/network-logos/ethereum.svg"},wToken:{symbol:"WETH",address:"0x5AEa5775959fBC2557Cc8789bC1bf90A239D9a91",decimals:18,logoUrl:"https://tokens-data.1inch.io/images/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2.png"},publicRpcUrl:"https://mainnet.era.zksync.io",logoUrl:"https://raw.githubusercontent.com/matter-labs/zksync/0a4ca2145a0c95b5bafa84c2f095c644907a8825/zkSyncLogo.svg",explorer:"https://explorer.zksync.io/",eip1559:!0},zkevm:{id:1101,name:"zkevm",shortname:"zkevm",native:{address:re,symbol:"ETH",decimals:18,logoUrl:"https://app.1inch.io/assets/images/network-logos/ethereum.svg"},wToken:{symbol:"WETH",address:"0x4F9A0e7FD2Bf6067db6994CF12E4495Df938E6e9",decimals:18,logoUrl:"https://tokens-data.1inch.io/images/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2.png"},publicRpcUrl:"https://zkevm-rpc.com",logoUrl:"https://user-images.githubusercontent.com/18598517/235932702-bc47eae5-d672-4dd9-9da2-8ea8f51a93f3.png",explorer:"https://zkevm.polygonscan.com/",eip1559:!0},manta:{id:169,name:"manta",shortname:"manta",native:{address:re,symbol:"ETH",decimals:18,logoUrl:"https://icons.llamao.fi/icons/chains/rsz_manta.jpg"},wToken:{symbol:"WETH",address:"0x0Dc808adcE2099A9F62AA87D9670745AbA741746",decimals:18,logoUrl:"https://tokens-data.1inch.io/images/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2.png"},publicRpcUrl:"https://pacific-rpc.manta.network/http",logoUrl:"https://icons.llamao.fi/icons/chains/rsz_manta.jpg",explorer:"https://manta.socialscan.io/",eip1559:!0},blast:{id:81457,name:"blast",shortname:"blast",native:{address:re,symbol:"ETH",decimals:18,logoUrl:"https://icons.llamao.fi/icons/chains/rsz_blast"},wToken:{symbol:"WETH",address:"0x4300000000000000000000000000000000000004",decimals:18,logoUrl:"https://tokens-data.1inch.io/images/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2.png"},publicRpcUrl:"https://rpc.ankr.com/blast",logoUrl:"https://icons.llamao.fi/icons/chains/rsz_blast",explorer:"https://blastscan.io/",eip1559:!0},sonic:{id:146,name:"sonic",shortname:"sonic",native:{address:re,symbol:"S",decimals:18,logoUrl:"https://icons.llamao.fi/icons/chains/rsz_sonic"},wToken:{symbol:"WS",address:"0x039e2fB66102314Ce7b64Ce5Ce3E5183bc94aD38",decimals:18,logoUrl:"https://icons.llamao.fi/icons/chains/rsz_sonic"},publicRpcUrl:"https://rpc.soniclabs.com",logoUrl:"https://icons.llamao.fi/icons/chains/rsz_sonic",explorer:"https://www.sonicscan.org/",eip1559:!0},scroll:{id:534352,name:"scroll",shortname:"scroll",native:{address:re,symbol:"ETH",decimals:18,logoUrl:"https://icons.llamao.fi/icons/chains/rsz_scroll"},wToken:{symbol:"WETH",address:"0x5300000000000000000000000000000000000004",decimals:18,logoUrl:"https://tokens-data.1inch.io/images/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2.png"},publicRpcUrl:"https://scroll-rpc.publicnode.com",logoUrl:"https://icons.llamao.fi/icons/chains/rsz_scroll",explorer:"https://scrollscan.com/",eip1559:!0},zircuit:{id:48900,name:"Zircuit",shortname:"zircuit",native:{address:re,symbol:"ETH",decimals:18,logoUrl:"https://app.1inch.io/assets/images/network-logos/ethereum.svg"},wToken:{symbol:"WETH",address:"0x4200000000000000000000000000000000000006",decimals:18,logoUrl:"https://tokens-data.1inch.io/images/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2.png"},publicRpcUrl:"https://zircuit-mainnet.drpc.org",logoUrl:"https://app.1inch.io/assets/images/network-logos/ethereum.svg",explorer:"https://explorer.zircuit.com/",eip1559:!0},flare:{id:14,name:"flare",shortname:"flare",native:{address:re,symbol:"FLR",decimals:18,logoUrl:"https://icons.llamao.fi/icons/chains/rsz_flare?w=48&h=48"},wToken:{symbol:"WFLR",address:"0x1D80c49BbBCd1C0911346656B529DF9E5c2F783d",decimals:18,logoUrl:"https://res.cloudinary.com/sparkdex/image/upload/q_100/v1/website-assets/coins/wflr?_a=DATAg1AAZAA0"},publicRpcUrl:"https://flare.network",logoUrl:"https://icons.llamao.fi/icons/chains/rsz_flare?w=48&h=48",explorer:"https://flarescan.com",eip1559:!0},cronosZkEvm:{id:388,name:"Cronos zkEVM",shortname:"cronosZkEvm",native:{address:"0x000000000000000000000000000000000000800a",symbol:"zkCRO",decimals:18,logoUrl:"https://cryptologos.cc/logos/cronos-cro-logo.png"},wToken:{symbol:"wzkCRO",address:"0xC1bF55EE54E16229d9b369a5502Bfe5fC9F20b6d",decimals:18,logoUrl:"https://cryptologos.cc/logos/cronos-cro-logo.png"},publicRpcUrl:"https://rpc.zkevm.cronos.org",logoUrl:"https://cryptologos.cc/logos/cronos-cro-logo.png",explorer:"https://explorer.zkevm.cronos.org",eip1559:!0},katana:{id:747474,name:"Katana",shortname:"katana",native:{address:re,symbol:"ETH",decimals:18,logoUrl:"https://katana.network/assets/katana-logo.svg"},wToken:{symbol:"WETH",address:"0xee7d8bcfb72bc1880d0cf19822eb0a2e6577ab62",decimals:18,logoUrl:"https://katana.network/assets/weth-logo.svg"},publicRpcUrl:"https://rpc.katanarpc.com",logoUrl:"https://katana.network/assets/katana-logo.svg",explorer:"https://explorer.katana.garden",eip1559:!0},bera:{id:80094,name:"Bera",shortname:"bera",native:{address:re,symbol:"BERA",decimals:18,logoUrl:"https://s2.coinmarketcap.com/static/img/coins/128x128/24647.png"},wToken:{symbol:"WBERA",address:"0x6969696969696969696969696969696969696969",decimals:18,logoUrl:"https://berascan.com/token/images/wrappedbera_ofc_64.png"},publicRpcUrl:"wss://rpc.berachain-apis.com",logoUrl:"https://katana.network/assets/katana-logo.svg",explorer:"https://berascan.com",eip1559:!0},monad:{id:143,name:"Monad",shortname:"monad",native:{address:re,symbol:"MONAD",decimals:18,logoUrl:"https://s2.coinmarketcap.com/static/img/coins/128x128/30495.png"},wToken:{symbol:"WMON",address:"0x3bd359c1119da7da1d913d1c4d2b7c461115433a",decimals:18,logoUrl:"https://assets.coingecko.com/coins/images/70784/standard/wmon.png?1766028904"},publicRpcUrl:"https://monad-mainnet.drpc.org",logoUrl:"https://s2.coinmarketcap.com/static/img/coins/128x128/30495.png",explorer:"https://monad.network",eip1559:!0},optimism:{id:10,name:"Optimism",shortname:"optimism",native:{address:re,symbol:"ETH",decimals:18,logoUrl:"https://s2.coinmarketcap.com/static/img/coins/128x128/11840.png"},wToken:{symbol:"WETH",address:"0x4200000000000000000000000000000000000006",decimals:18,logoUrl:"https://s2.coinmarketcap.com/static/img/coins/128x128/2396.png"},publicRpcUrl:"https://optimism.blockscout.com",logoUrl:"https://s2.coinmarketcap.com/static/img/coins/128x128/11840.png",explorer:"https://optimistic.etherscan.io",eip1559:!0},mantle:{id:5e3,name:"Mantle",shortname:"mantle",native:{address:re,symbol:"MNT",decimals:18,logoUrl:"https://s2.coinmarketcap.com/static/img/coins/128x128/27075.png"},wToken:{symbol:"WMNT",address:"0x78c1b0c915c4faa5fffa6cabf0219da63d7f4cb8",decimals:18,logoUrl:"https://s2.coinmarketcap.com/static/img/coins/128x128/27614.png"},publicRpcUrl:"https://rpc.mantle.xyz",logoUrl:"https://s2.coinmarketcap.com/static/img/coins/128x128/27075.png",explorer:"https://mantlescan.xyz",eip1559:!0}},On={version:"2.4.1"},zs="https://order-sink-dev.orbs.network",$s="https://order-sink.orbs.network",Vs="https://order-sink-v2.orbs.network",ln=On.version.split(".")[0],vr=e=>{const t=Number(ln)>=2;return e?zs:t?Vs:$s},In=300*1e3,pn=1440*60*60*1e3,Pr=300*1e3,Gs=new Date(In).getMinutes(),kn=e=>`https://hub.orbs.network/api/private/project_cm7nb67z86nyr01z12gs0fxpf/subgraphs/orbs-twap-${e}/prod/gn`,Be="https://hub.orbs.network/api/apikey/subgraphs/id",Xs={[ye.eth.id]:`${Be}/Bf7bvMYcJbDAvYWJmhMpHZ4cpFjqzkhK6GXXEpnPRq6`,[ye.bsc.id]:`${Be}/4NfXEi8rreQsnAr4aJ45RLCKgnjcWX46Lbt9SadiCcz6`,[ye.poly.id]:`${Be}/3PyRPWSvDnMowGbeBy7aNsvUkD5ZuxdXQw2RdJq4NdXi`,[ye.arb.id]:`${Be}/83bpQexEaqBjHaQbKoFTbtvCXuo5RudRkfLgtRUYqo2c`,[ye.base.id]:`${Be}/DFhaPQb3HATXkpsWNZw3gydYHehLBVEDiSk4iBdZJyps`,[ye.sei.id]:`${Be}/5zjzRnURzoddyFSZBw5E5NAM3oBgPq3NasTYbtMk6EL6`,[ye.linea.id]:`${Be}/6VsNPEYfFLPZCqdMMDadoXQjLHWJdjEwiD768GAtb7j6`,[ye.sonic.id]:`${Be}/DtBr6a5vsoDd2oAXdPszcn4gLgrr1XC68Q3AJQKXnNLV`,[ye.ftm.id]:`${Be}/DdRo1pmJkrJC9fjsjEBWnNE1uqrbh7Diz4tVKd7rfupp`,[ye.katana.id]:`${Be}/CGi9sDFMQcnBwF3C3NoCFqnaE34sssbgwPLTwiskSXmW`,[ye.avax.id]:`${Be}/FxZ1vMwE5Xy1qvKvZENUMz4vhW8Sh4vXJf9Vp7o17pTx`,[ye.bera.id]:kn("berachain"),[ye.flare.id]:kn("flare"),[ye.cronosZkEvm.id]:kn("cronos-zkevm")},Zs=["0x0000000000000000000000000000000000000000","0x0000000000000000000000000000000000001010","0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE","0x000000000000000000000000000000000000dEaD","0x000000000000000000000000000000000000800A","0x000000000000000000000000000000000000800a"],Mn="115792089237316195423570985008687907853269984665640564039457584007913129639935",Ae=e=>`${e.name}_${e.chainId}`,Ys={[Ae($.SushiArb)]:["0x846F2B29ef314bF3D667981b4ffdADc5B858312a","0x08c41f5D1C844061f6D952E25827eeAA576c6536"],[Ae($.SushiBase)]:["0x846F2B29ef314bF3D667981b4ffdADc5B858312a","0x08c41f5D1C844061f6D952E25827eeAA576c6536"],[Ae($.SushiEth)]:["0xc55943Fa6509004B2903ED8F8ab7347BfC47D0bA","0x08c41f5D1C844061f6D952E25827eeAA576c6536"],[Ae($.PancakeSwap)]:["0xb2BAFe188faD927240038cC4FfF2d771d8A58905","0xE2a0c3b9aD19A18c4bBa7fffBe5bC1b0E58Db1CE"],[Ae($.PancakeSwapArbitrum)]:["0xE20167871dB616DdfFD0Fd870d9bC068C350DD1F","0x807488ADAD033e95C438F998277bE654152594dc"],[Ae($.PancakeSwapBase)]:["0x10ed1F36e4eBE76E161c9AADDa20BE841bc0082c","0x3A9df3eE209b802D0337383f5abCe3204d623588"],[Ae($.PancakeSwapLinea)]:["0x3A9df3eE209b802D0337383f5abCe3204d623588"],[Ae($.QuickSwap)]:["0x26D0ec4Be402BCE03AAa8aAf0CF67e9428ba54eF"],[Ae($.Thena)]:["0xc2aBC02acd77Bb2407efA22348dA9afC8B375290"],[Ae($.Lynex)]:["0x72e3e1fD5D2Ee2F1C2Eb695206D490a1D45C3835"],[Ae($.DragonSwap)]:["0x101e1B65Bb516FB5f4547C80BAe0b51f1b8D7a22"],[Ae($.SpookySwapSonic)]:["0xAd97B770ad64aE47fc7d64B3bD820dCDbF9ff7DA"],[Ae($.SpookySwap)]:["0x3924d62219483015f982b160d48c0fa5Fd436Cba"],[Ae($.SwapX)]:["0xE5012eBDe5e26EE3Ea41992154731a03023CF274"]},_n={unit:Fe.Minutes,value:Gs},Fr="RePermitWitnessTransferFrom",Js={RePermitWitnessTransferFrom:[{name:"permitted",type:"TokenPermissions"},{name:"spender",type:"address"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"},{name:"witness",type:"Order"}],Exchange:[{name:"adapter",type:"address"},{name:"ref",type:"address"},{name:"share",type:"uint32"},{name:"data",type:"bytes"}],Input:[{name:"token",type:"address"},{name:"amount",type:"uint256"},{name:"maxAmount",type:"uint256"}],Order:[{name:"reactor",type:"address"},{name:"executor",type:"address"},{name:"exchange",type:"Exchange"},{name:"swapper",type:"address"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"},{name:"chainid",type:"uint256"},{name:"exclusivity",type:"uint32"},{name:"epoch",type:"uint32"},{name:"slippage",type:"uint32"},{name:"freshness",type:"uint32"},{name:"input",type:"Input"},{name:"output",type:"Output"}],Output:[{name:"token",type:"address"},{name:"limit",type:"uint256"},{name:"stop",type:"uint256"},{name:"recipient",type:"address"}],TokenPermissions:[{name:"token",type:"address"},{name:"amount",type:"uint256"}]},ei={RePermitWitnessTransferFrom:[{name:"permitted",type:"TokenPermissions"},{name:"spender",type:"address"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"},{name:"witness",type:"Order"}],Exchange:[{name:"adapter",type:"address"},{name:"ref",type:"address"},{name:"share",type:"uint32"},{name:"data",type:"bytes"}],Input:[{name:"token",type:"address"},{name:"amount",type:"uint256"},{name:"maxAmount",type:"uint256"}],Order:[{name:"reactor",type:"address"},{name:"executor",type:"address"},{name:"exchange",type:"Exchange"},{name:"swapper",type:"address"},{name:"nonce",type:"uint256"},{name:"start",type:"uint256"},{name:"deadline",type:"uint256"},{name:"chainid",type:"uint256"},{name:"exclusivity",type:"uint32"},{name:"epoch",type:"uint32"},{name:"slippage",type:"uint32"},{name:"freshness",type:"uint32"},{name:"input",type:"Input"},{name:"output",type:"Output"}],Output:[{name:"token",type:"address"},{name:"limit",type:"uint256"},{name:"triggerLower",type:"uint256"},{name:"triggerUpper",type:"uint256"},{name:"recipient",type:"address"}],TokenPermissions:[{name:"token",type:"address"},{name:"amount",type:"uint256"}]},ti="https://www.orbs.com/dtwap-and-dlimit-faq/",ni="https://www.orbs.com/dtwap-and-dlimit-faq/#dSLTP",ri="https://raw.githubusercontent.com/orbs-network/twap-ui/master/logo/orbslogo.svg",si="https://www.orbs.com/",ii="https://www.orbs.com/dtwap-dlimit-disclaimer";var Yt=(e=>(e.FRESHNESS="freshness",e.MIN_CHUNK_SIZE_USD="minChunkSizeUsd",e.ENV="env",e.DURATION="duration",e.IGNORE_ERRORS="ignore-errors",e))(Yt||{});const ai="-5",oi="10",ui="-10",ci="5";var di=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,Bn=Math.ceil,De=Math.floor,xe="[BigNumber Error] ",Dr=xe+"Number primitive has more than 15 significant digits: ",Ue=1e14,W=14,Un=9007199254740991,Rn=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],et=1e7,le=1e9;function Or(e){var t,n,r,s=F.prototype={constructor:F,toString:null,valueOf:null},i=new F(1),o=20,d=4,p=-7,h=21,C=-1e7,E=1e7,x=!1,P=1,I=0,O={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},M="0123456789abcdefghijklmnopqrstuvwxyz",B=!0;function F(a,u){var c,A,m,y,w,f,g,T,b=this;if(!(b instanceof F))return new F(a,u);if(u==null){if(a&&a._isBigNumber===!0){b.s=a.s,!a.c||a.e>E?b.c=b.e=null:a.e<C?b.c=[b.e=0]:(b.e=a.e,b.c=a.c.slice());return}if((f=typeof a=="number")&&a*0==0){if(b.s=1/a<0?(a=-a,-1):1,a===~~a){for(y=0,w=a;w>=10;w/=10,y++);y>E?b.c=b.e=null:(b.e=y,b.c=[a]);return}T=String(a)}else{if(!di.test(T=String(a)))return r(b,T,f);b.s=T.charCodeAt(0)==45?(T=T.slice(1),-1):1}(y=T.indexOf("."))>-1&&(T=T.replace(".","")),(w=T.search(/e/i))>0?(y<0&&(y=w),y+=+T.slice(w+1),T=T.substring(0,w)):y<0&&(y=T.length)}else{if(ne(u,2,M.length,"Base"),u==10&&B)return b=new F(a),Y(b,o+b.e+1,d);if(T=String(a),f=typeof a=="number"){if(a*0!=0)return r(b,T,f,u);if(b.s=1/a<0?(T=T.slice(1),-1):1,F.DEBUG&&T.replace(/^0\.0*|\./,"").length>15)throw Error(Dr+a)}else b.s=T.charCodeAt(0)===45?(T=T.slice(1),-1):1;for(c=M.slice(0,u),y=w=0,g=T.length;w<g;w++)if(c.indexOf(A=T.charAt(w))<0){if(A=="."){if(w>y){y=g;continue}}else if(!m&&(T==T.toUpperCase()&&(T=T.toLowerCase())||T==T.toLowerCase()&&(T=T.toUpperCase()))){m=!0,w=-1,y=0;continue}return r(b,String(a),f,u)}f=!1,T=n(T,u,10,b.s),(y=T.indexOf("."))>-1?T=T.replace(".",""):y=T.length}for(w=0;T.charCodeAt(w)===48;w++);for(g=T.length;T.charCodeAt(--g)===48;);if(T=T.slice(w,++g)){if(g-=w,f&&F.DEBUG&&g>15&&(a>Un||a!==De(a)))throw Error(Dr+b.s*a);if((y=y-w-1)>E)b.c=b.e=null;else if(y<C)b.c=[b.e=0];else{if(b.e=y,b.c=[],w=(y+1)%W,y<0&&(w+=W),w<g){for(w&&b.c.push(+T.slice(0,w)),g-=W;w<g;)b.c.push(+T.slice(w,w+=W));w=W-(T=T.slice(w)).length}else w-=g;for(;w--;T+="0");b.c.push(+T)}}else b.c=[b.e=0]}F.clone=Or,F.ROUND_UP=0,F.ROUND_DOWN=1,F.ROUND_CEIL=2,F.ROUND_FLOOR=3,F.ROUND_HALF_UP=4,F.ROUND_HALF_DOWN=5,F.ROUND_HALF_EVEN=6,F.ROUND_HALF_CEIL=7,F.ROUND_HALF_FLOOR=8,F.EUCLID=9,F.config=F.set=function(a){var u,c;if(a!=null)if(typeof a=="object"){if(a.hasOwnProperty(u="DECIMAL_PLACES")&&(c=a[u],ne(c,0,le,u),o=c),a.hasOwnProperty(u="ROUNDING_MODE")&&(c=a[u],ne(c,0,8,u),d=c),a.hasOwnProperty(u="EXPONENTIAL_AT")&&(c=a[u],c&&c.pop?(ne(c[0],-le,0,u),ne(c[1],0,le,u),p=c[0],h=c[1]):(ne(c,-le,le,u),p=-(h=c<0?-c:c))),a.hasOwnProperty(u="RANGE"))if(c=a[u],c&&c.pop)ne(c[0],-le,-1,u),ne(c[1],1,le,u),C=c[0],E=c[1];else if(ne(c,-le,le,u),c)C=-(E=c<0?-c:c);else throw Error(xe+u+" cannot be zero: "+c);if(a.hasOwnProperty(u="CRYPTO"))if(c=a[u],c===!!c)if(c)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))x=c;else throw x=!c,Error(xe+"crypto unavailable");else x=c;else throw Error(xe+u+" not true or false: "+c);if(a.hasOwnProperty(u="MODULO_MODE")&&(c=a[u],ne(c,0,9,u),P=c),a.hasOwnProperty(u="POW_PRECISION")&&(c=a[u],ne(c,0,le,u),I=c),a.hasOwnProperty(u="FORMAT"))if(c=a[u],typeof c=="object")O=c;else throw Error(xe+u+" not an object: "+c);if(a.hasOwnProperty(u="ALPHABET"))if(c=a[u],typeof c=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(c))B=c.slice(0,10)=="0123456789",M=c;else throw Error(xe+u+" invalid: "+c)}else throw Error(xe+"Object expected: "+a);return{DECIMAL_PLACES:o,ROUNDING_MODE:d,EXPONENTIAL_AT:[p,h],RANGE:[C,E],CRYPTO:x,MODULO_MODE:P,POW_PRECISION:I,FORMAT:O,ALPHABET:M}},F.isBigNumber=function(a){if(!a||a._isBigNumber!==!0)return!1;if(!F.DEBUG)return!0;var u,c,A=a.c,m=a.e,y=a.s;e:if({}.toString.call(A)=="[object Array]"){if((y===1||y===-1)&&m>=-le&&m<=le&&m===De(m)){if(A[0]===0){if(m===0&&A.length===1)return!0;break e}if(u=(m+1)%W,u<1&&(u+=W),String(A[0]).length==u){for(u=0;u<A.length;u++)if(c=A[u],c<0||c>=Ue||c!==De(c))break e;if(c!==0)return!0}}}else if(A===null&&m===null&&(y===null||y===1||y===-1))return!0;throw Error(xe+"Invalid BigNumber: "+a)},F.maximum=F.max=function(){return U(arguments,-1)},F.minimum=F.min=function(){return U(arguments,1)},F.random=(function(){var a=9007199254740992,u=Math.random()*a&2097151?function(){return De(Math.random()*a)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(c){var A,m,y,w,f,g=0,T=[],b=new F(i);if(c==null?c=o:ne(c,0,le),w=Bn(c/W),x)if(crypto.getRandomValues){for(A=crypto.getRandomValues(new Uint32Array(w*=2));g<w;)f=A[g]*131072+(A[g+1]>>>11),f>=9e15?(m=crypto.getRandomValues(new Uint32Array(2)),A[g]=m[0],A[g+1]=m[1]):(T.push(f%1e14),g+=2);g=w/2}else if(crypto.randomBytes){for(A=crypto.randomBytes(w*=7);g<w;)f=(A[g]&31)*281474976710656+A[g+1]*1099511627776+A[g+2]*4294967296+A[g+3]*16777216+(A[g+4]<<16)+(A[g+5]<<8)+A[g+6],f>=9e15?crypto.randomBytes(7).copy(A,g):(T.push(f%1e14),g+=7);g=w/7}else throw x=!1,Error(xe+"crypto unavailable");if(!x)for(;g<w;)f=u(),f<9e15&&(T[g++]=f%1e14);for(w=T[--g],c%=W,w&&c&&(f=Rn[W-c],T[g]=De(w/f)*f);T[g]===0;T.pop(),g--);if(g<0)T=[y=0];else{for(y=-1;T[0]===0;T.splice(0,1),y-=W);for(g=1,f=T[0];f>=10;f/=10,g++);g<W&&(y-=W-g)}return b.e=y,b.c=T,b}})(),F.sum=function(){for(var a=1,u=arguments,c=new F(u[0]);a<u.length;)c=c.plus(u[a++]);return c},n=(function(){var a="0123456789";function u(c,A,m,y){for(var w,f=[0],g,T=0,b=c.length;T<b;){for(g=f.length;g--;f[g]*=A);for(f[0]+=y.indexOf(c.charAt(T++)),w=0;w<f.length;w++)f[w]>m-1&&(f[w+1]==null&&(f[w+1]=0),f[w+1]+=f[w]/m|0,f[w]%=m)}return f.reverse()}return function(c,A,m,y,w){var f,g,T,b,D,R,L,G,ie=c.indexOf("."),de=o,J=d;for(ie>=0&&(b=I,I=0,c=c.replace(".",""),G=new F(A),R=G.pow(c.length-ie),I=b,G.c=u(ze(Ie(R.c),R.e,"0"),10,m,a),G.e=G.c.length),L=u(c,A,m,w?(f=M,a):(f=a,M)),T=b=L.length;L[--b]==0;L.pop());if(!L[0])return f.charAt(0);if(ie<0?--T:(R.c=L,R.e=T,R.s=y,R=t(R,G,de,J,m),L=R.c,D=R.r,T=R.e),g=T+de+1,ie=L[g],b=m/2,D=D||g<0||L[g+1]!=null,D=J<4?(ie!=null||D)&&(J==0||J==(R.s<0?3:2)):ie>b||ie==b&&(J==4||D||J==6&&L[g-1]&1||J==(R.s<0?8:7)),g<1||!L[0])c=D?ze(f.charAt(1),-de,f.charAt(0)):f.charAt(0);else{if(L.length=g,D)for(--m;++L[--g]>m;)L[g]=0,g||(++T,L=[1].concat(L));for(b=L.length;!L[--b];);for(ie=0,c="";ie<=b;c+=f.charAt(L[ie++]));c=ze(c,T,f.charAt(0))}return c}})(),t=(function(){function a(A,m,y){var w,f,g,T,b=0,D=A.length,R=m%et,L=m/et|0;for(A=A.slice();D--;)g=A[D]%et,T=A[D]/et|0,w=L*g+T*R,f=R*g+w%et*et+b,b=(f/y|0)+(w/et|0)+L*T,A[D]=f%y;return b&&(A=[b].concat(A)),A}function u(A,m,y,w){var f,g;if(y!=w)g=y>w?1:-1;else for(f=g=0;f<y;f++)if(A[f]!=m[f]){g=A[f]>m[f]?1:-1;break}return g}function c(A,m,y,w){for(var f=0;y--;)A[y]-=f,f=A[y]<m[y]?1:0,A[y]=f*w+A[y]-m[y];for(;!A[0]&&A.length>1;A.splice(0,1));}return function(A,m,y,w,f){var g,T,b,D,R,L,G,ie,de,J,te,ge,vn,fr,mr,je,cn,_e=A.s==m.s?1:-1,Ce=A.c,ae=m.c;if(!Ce||!Ce[0]||!ae||!ae[0])return new F(!A.s||!m.s||(Ce?ae&&Ce[0]==ae[0]:!ae)?NaN:Ce&&Ce[0]==0||!ae?_e*0:_e/0);for(ie=new F(_e),de=ie.c=[],T=A.e-m.e,_e=y+T+1,f||(f=Ue,T=Oe(A.e/W)-Oe(m.e/W),_e=_e/W|0),b=0;ae[b]==(Ce[b]||0);b++);if(ae[b]>(Ce[b]||0)&&T--,_e<0)de.push(1),D=!0;else{for(fr=Ce.length,je=ae.length,b=0,_e+=2,R=De(f/(ae[0]+1)),R>1&&(ae=a(ae,R,f),Ce=a(Ce,R,f),je=ae.length,fr=Ce.length),vn=je,J=Ce.slice(0,je),te=J.length;te<je;J[te++]=0);cn=ae.slice(),cn=[0].concat(cn),mr=ae[0],ae[1]>=f/2&&mr++;do{if(R=0,g=u(ae,J,je,te),g<0){if(ge=J[0],je!=te&&(ge=ge*f+(J[1]||0)),R=De(ge/mr),R>1)for(R>=f&&(R=f-1),L=a(ae,R,f),G=L.length,te=J.length;u(L,J,G,te)==1;)R--,c(L,je<G?cn:ae,G,f),G=L.length,g=1;else R==0&&(g=R=1),L=ae.slice(),G=L.length;if(G<te&&(L=[0].concat(L)),c(J,L,te,f),te=J.length,g==-1)for(;u(ae,J,je,te)<1;)R++,c(J,je<te?cn:ae,te,f),te=J.length}else g===0&&(R++,J=[0]);de[b++]=R,J[0]?J[te++]=Ce[vn]||0:(J=[Ce[vn]],te=1)}while((vn++<fr||J[0]!=null)&&_e--);D=J[0]!=null,de[0]||de.splice(0,1)}if(f==Ue){for(b=1,_e=de[0];_e>=10;_e/=10,b++);Y(ie,y+(ie.e=b+T*W-1)+1,w,D)}else ie.e=T,ie.r=+D;return ie}})();function K(a,u,c,A){var m,y,w,f,g;if(c==null?c=d:ne(c,0,8),!a.c)return a.toString();if(m=a.c[0],w=a.e,u==null)g=Ie(a.c),g=A==1||A==2&&(w<=p||w>=h)?fn(g,w):ze(g,w,"0");else if(a=Y(new F(a),u,c),y=a.e,g=Ie(a.c),f=g.length,A==1||A==2&&(u<=y||y<=p)){for(;f<u;g+="0",f++);g=fn(g,y)}else if(u-=w+(A===2&&y>w),g=ze(g,y,"0"),y+1>f){if(--u>0)for(g+=".";u--;g+="0");}else if(u+=y-f,u>0)for(y+1==f&&(g+=".");u--;g+="0");return a.s<0&&m?"-"+g:g}function U(a,u){for(var c,A,m=1,y=new F(a[0]);m<a.length;m++)A=new F(a[m]),(!A.s||(c=mt(y,A))===u||c===0&&y.s===u)&&(y=A);return y}function Z(a,u,c){for(var A=1,m=u.length;!u[--m];u.pop());for(m=u[0];m>=10;m/=10,A++);return(c=A+c*W-1)>E?a.c=a.e=null:c<C?a.c=[a.e=0]:(a.e=c,a.c=u),a}r=(function(){var a=/^(-?)0([xbo])(?=\w[\w.]*$)/i,u=/^([^.]+)\.$/,c=/^\.([^.]+)$/,A=/^-?(Infinity|NaN)$/,m=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(y,w,f,g){var T,b=f?w:w.replace(m,"");if(A.test(b))y.s=isNaN(b)?null:b<0?-1:1;else{if(!f&&(b=b.replace(a,function(D,R,L){return T=(L=L.toLowerCase())=="x"?16:L=="b"?2:8,!g||g==T?R:D}),g&&(T=g,b=b.replace(u,"$1").replace(c,"0.$1")),w!=b))return new F(b,T);if(F.DEBUG)throw Error(xe+"Not a"+(g?" base "+g:"")+" number: "+w);y.s=null}y.c=y.e=null}})();function Y(a,u,c,A){var m,y,w,f,g,T,b,D=a.c,R=Rn;if(D){e:{for(m=1,f=D[0];f>=10;f/=10,m++);if(y=u-m,y<0)y+=W,w=u,g=D[T=0],b=De(g/R[m-w-1]%10);else if(T=Bn((y+1)/W),T>=D.length)if(A){for(;D.length<=T;D.push(0));g=b=0,m=1,y%=W,w=y-W+1}else break e;else{for(g=f=D[T],m=1;f>=10;f/=10,m++);y%=W,w=y-W+m,b=w<0?0:De(g/R[m-w-1]%10)}if(A=A||u<0||D[T+1]!=null||(w<0?g:g%R[m-w-1]),A=c<4?(b||A)&&(c==0||c==(a.s<0?3:2)):b>5||b==5&&(c==4||A||c==6&&(y>0?w>0?g/R[m-w]:0:D[T-1])%10&1||c==(a.s<0?8:7)),u<1||!D[0])return D.length=0,A?(u-=a.e+1,D[0]=R[(W-u%W)%W],a.e=-u||0):D[0]=a.e=0,a;if(y==0?(D.length=T,f=1,T--):(D.length=T+1,f=R[W-y],D[T]=w>0?De(g/R[m-w]%R[w])*f:0),A)for(;;)if(T==0){for(y=1,w=D[0];w>=10;w/=10,y++);for(w=D[0]+=f,f=1;w>=10;w/=10,f++);y!=f&&(a.e++,D[0]==Ue&&(D[0]=1));break}else{if(D[T]+=f,D[T]!=Ue)break;D[T--]=0,f=1}for(y=D.length;D[--y]===0;D.pop());}a.e>E?a.c=a.e=null:a.e<C&&(a.c=[a.e=0])}return a}function oe(a){var u,c=a.e;return c===null?a.toString():(u=Ie(a.c),u=c<=p||c>=h?fn(u,c):ze(u,c,"0"),a.s<0?"-"+u:u)}return s.absoluteValue=s.abs=function(){var a=new F(this);return a.s<0&&(a.s=1),a},s.comparedTo=function(a,u){return mt(this,new F(a,u))},s.decimalPlaces=s.dp=function(a,u){var c,A,m,y=this;if(a!=null)return ne(a,0,le),u==null?u=d:ne(u,0,8),Y(new F(y),a+y.e+1,u);if(!(c=y.c))return null;if(A=((m=c.length-1)-Oe(this.e/W))*W,m=c[m])for(;m%10==0;m/=10,A--);return A<0&&(A=0),A},s.dividedBy=s.div=function(a,u){return t(this,new F(a,u),o,d)},s.dividedToIntegerBy=s.idiv=function(a,u){return t(this,new F(a,u),0,1)},s.exponentiatedBy=s.pow=function(a,u){var c,A,m,y,w,f,g,T,b,D=this;if(a=new F(a),a.c&&!a.isInteger())throw Error(xe+"Exponent not an integer: "+oe(a));if(u!=null&&(u=new F(u)),f=a.e>14,!D.c||!D.c[0]||D.c[0]==1&&!D.e&&D.c.length==1||!a.c||!a.c[0])return b=new F(Math.pow(+oe(D),f?a.s*(2-hn(a)):+oe(a))),u?b.mod(u):b;if(g=a.s<0,u){if(u.c?!u.c[0]:!u.s)return new F(NaN);A=!g&&D.isInteger()&&u.isInteger(),A&&(D=D.mod(u))}else{if(a.e>9&&(D.e>0||D.e<-1||(D.e==0?D.c[0]>1||f&&D.c[1]>=24e7:D.c[0]<8e13||f&&D.c[0]<=9999975e7)))return y=D.s<0&&hn(a)?-0:0,D.e>-1&&(y=1/y),new F(g?1/y:y);I&&(y=Bn(I/W+2))}for(f?(c=new F(.5),g&&(a.s=1),T=hn(a)):(m=Math.abs(+oe(a)),T=m%2),b=new F(i);;){if(T){if(b=b.times(D),!b.c)break;y?b.c.length>y&&(b.c.length=y):A&&(b=b.mod(u))}if(m){if(m=De(m/2),m===0)break;T=m%2}else if(a=a.times(c),Y(a,a.e+1,1),a.e>14)T=hn(a);else{if(m=+oe(a),m===0)break;T=m%2}D=D.times(D),y?D.c&&D.c.length>y&&(D.c.length=y):A&&(D=D.mod(u))}return A?b:(g&&(b=i.div(b)),u?b.mod(u):y?Y(b,I,d,w):b)},s.integerValue=function(a){var u=new F(this);return a==null?a=d:ne(a,0,8),Y(u,u.e+1,a)},s.isEqualTo=s.eq=function(a,u){return mt(this,new F(a,u))===0},s.isFinite=function(){return!!this.c},s.isGreaterThan=s.gt=function(a,u){return mt(this,new F(a,u))>0},s.isGreaterThanOrEqualTo=s.gte=function(a,u){return(u=mt(this,new F(a,u)))===1||u===0},s.isInteger=function(){return!!this.c&&Oe(this.e/W)>this.c.length-2},s.isLessThan=s.lt=function(a,u){return mt(this,new F(a,u))<0},s.isLessThanOrEqualTo=s.lte=function(a,u){return(u=mt(this,new F(a,u)))===-1||u===0},s.isNaN=function(){return!this.s},s.isNegative=function(){return this.s<0},s.isPositive=function(){return this.s>0},s.isZero=function(){return!!this.c&&this.c[0]==0},s.minus=function(a,u){var c,A,m,y,w=this,f=w.s;if(a=new F(a,u),u=a.s,!f||!u)return new F(NaN);if(f!=u)return a.s=-u,w.plus(a);var g=w.e/W,T=a.e/W,b=w.c,D=a.c;if(!g||!T){if(!b||!D)return b?(a.s=-u,a):new F(D?w:NaN);if(!b[0]||!D[0])return D[0]?(a.s=-u,a):new F(b[0]?w:d==3?-0:0)}if(g=Oe(g),T=Oe(T),b=b.slice(),f=g-T){for((y=f<0)?(f=-f,m=b):(T=g,m=D),m.reverse(),u=f;u--;m.push(0));m.reverse()}else for(A=(y=(f=b.length)<(u=D.length))?f:u,f=u=0;u<A;u++)if(b[u]!=D[u]){y=b[u]<D[u];break}if(y&&(m=b,b=D,D=m,a.s=-a.s),u=(A=D.length)-(c=b.length),u>0)for(;u--;b[c++]=0);for(u=Ue-1;A>f;){if(b[--A]<D[A]){for(c=A;c&&!b[--c];b[c]=u);--b[c],b[A]+=Ue}b[A]-=D[A]}for(;b[0]==0;b.splice(0,1),--T);return b[0]?Z(a,b,T):(a.s=d==3?-1:1,a.c=[a.e=0],a)},s.modulo=s.mod=function(a,u){var c,A,m=this;return a=new F(a,u),!m.c||!a.s||a.c&&!a.c[0]?new F(NaN):!a.c||m.c&&!m.c[0]?new F(m):(P==9?(A=a.s,a.s=1,c=t(m,a,0,3),a.s=A,c.s*=A):c=t(m,a,0,P),a=m.minus(c.times(a)),!a.c[0]&&P==1&&(a.s=m.s),a)},s.multipliedBy=s.times=function(a,u){var c,A,m,y,w,f,g,T,b,D,R,L,G,ie,de,J=this,te=J.c,ge=(a=new F(a,u)).c;if(!te||!ge||!te[0]||!ge[0])return!J.s||!a.s||te&&!te[0]&&!ge||ge&&!ge[0]&&!te?a.c=a.e=a.s=null:(a.s*=J.s,!te||!ge?a.c=a.e=null:(a.c=[0],a.e=0)),a;for(A=Oe(J.e/W)+Oe(a.e/W),a.s*=J.s,g=te.length,D=ge.length,g<D&&(G=te,te=ge,ge=G,m=g,g=D,D=m),m=g+D,G=[];m--;G.push(0));for(ie=Ue,de=et,m=D;--m>=0;){for(c=0,R=ge[m]%de,L=ge[m]/de|0,w=g,y=m+w;y>m;)T=te[--w]%de,b=te[w]/de|0,f=L*T+b*R,T=R*T+f%de*de+G[y]+c,c=(T/ie|0)+(f/de|0)+L*b,G[y--]=T%ie;G[y]=c}return c?++A:G.splice(0,1),Z(a,G,A)},s.negated=function(){var a=new F(this);return a.s=-a.s||null,a},s.plus=function(a,u){var c,A=this,m=A.s;if(a=new F(a,u),u=a.s,!m||!u)return new F(NaN);if(m!=u)return a.s=-u,A.minus(a);var y=A.e/W,w=a.e/W,f=A.c,g=a.c;if(!y||!w){if(!f||!g)return new F(m/0);if(!f[0]||!g[0])return g[0]?a:new F(f[0]?A:m*0)}if(y=Oe(y),w=Oe(w),f=f.slice(),m=y-w){for(m>0?(w=y,c=g):(m=-m,c=f),c.reverse();m--;c.push(0));c.reverse()}for(m=f.length,u=g.length,m-u<0&&(c=g,g=f,f=c,u=m),m=0;u;)m=(f[--u]=f[u]+g[u]+m)/Ue|0,f[u]=Ue===f[u]?0:f[u]%Ue;return m&&(f=[m].concat(f),++w),Z(a,f,w)},s.precision=s.sd=function(a,u){var c,A,m,y=this;if(a!=null&&a!==!!a)return ne(a,1,le),u==null?u=d:ne(u,0,8),Y(new F(y),a,u);if(!(c=y.c))return null;if(m=c.length-1,A=m*W+1,m=c[m]){for(;m%10==0;m/=10,A--);for(m=c[0];m>=10;m/=10,A++);}return a&&y.e+1>A&&(A=y.e+1),A},s.shiftedBy=function(a){return ne(a,-Un,Un),this.times("1e"+a)},s.squareRoot=s.sqrt=function(){var a,u,c,A,m,y=this,w=y.c,f=y.s,g=y.e,T=o+4,b=new F("0.5");if(f!==1||!w||!w[0])return new F(!f||f<0&&(!w||w[0])?NaN:w?y:1/0);if(f=Math.sqrt(+oe(y)),f==0||f==1/0?(u=Ie(w),(u.length+g)%2==0&&(u+="0"),f=Math.sqrt(+u),g=Oe((g+1)/2)-(g<0||g%2),f==1/0?u="5e"+g:(u=f.toExponential(),u=u.slice(0,u.indexOf("e")+1)+g),c=new F(u)):c=new F(f+""),c.c[0]){for(g=c.e,f=g+T,f<3&&(f=0);;)if(m=c,c=b.times(m.plus(t(y,m,T,1))),Ie(m.c).slice(0,f)===(u=Ie(c.c)).slice(0,f))if(c.e<g&&--f,u=u.slice(f-3,f+1),u=="9999"||!A&&u=="4999"){if(!A&&(Y(m,m.e+o+2,0),m.times(m).eq(y))){c=m;break}T+=4,f+=4,A=1}else{(!+u||!+u.slice(1)&&u.charAt(0)=="5")&&(Y(c,c.e+o+2,1),a=!c.times(c).eq(y));break}}return Y(c,c.e+o+1,d,a)},s.toExponential=function(a,u){return a!=null&&(ne(a,0,le),a++),K(this,a,u,1)},s.toFixed=function(a,u){return a!=null&&(ne(a,0,le),a=a+this.e+1),K(this,a,u)},s.toFormat=function(a,u,c){var A,m=this;if(c==null)a!=null&&u&&typeof u=="object"?(c=u,u=null):a&&typeof a=="object"?(c=a,a=u=null):c=O;else if(typeof c!="object")throw Error(xe+"Argument not an object: "+c);if(A=m.toFixed(a,u),m.c){var y,w=A.split("."),f=+c.groupSize,g=+c.secondaryGroupSize,T=c.groupSeparator||"",b=w[0],D=w[1],R=m.s<0,L=R?b.slice(1):b,G=L.length;if(g&&(y=f,f=g,g=y,G-=y),f>0&&G>0){for(y=G%f||f,b=L.substr(0,y);y<G;y+=f)b+=T+L.substr(y,f);g>0&&(b+=T+L.slice(y)),R&&(b="-"+b)}A=D?b+(c.decimalSeparator||"")+((g=+c.fractionGroupSize)?D.replace(new RegExp("\\d{"+g+"}\\B","g"),"$&"+(c.fractionGroupSeparator||"")):D):b}return(c.prefix||"")+A+(c.suffix||"")},s.toFraction=function(a){var u,c,A,m,y,w,f,g,T,b,D,R,L=this,G=L.c;if(a!=null&&(f=new F(a),!f.isInteger()&&(f.c||f.s!==1)||f.lt(i)))throw Error(xe+"Argument "+(f.isInteger()?"out of range: ":"not an integer: ")+oe(f));if(!G)return new F(L);for(u=new F(i),T=c=new F(i),A=g=new F(i),R=Ie(G),y=u.e=R.length-L.e-1,u.c[0]=Rn[(w=y%W)<0?W+w:w],a=!a||f.comparedTo(u)>0?y>0?u:T:f,w=E,E=1/0,f=new F(R),g.c[0]=0;b=t(f,u,0,1),m=c.plus(b.times(A)),m.comparedTo(a)!=1;)c=A,A=m,T=g.plus(b.times(m=T)),g=m,u=f.minus(b.times(m=u)),f=m;return m=t(a.minus(c),A,0,1),g=g.plus(m.times(T)),c=c.plus(m.times(A)),g.s=T.s=L.s,y=y*2,D=t(T,A,y,d).minus(L).abs().comparedTo(t(g,c,y,d).minus(L).abs())<1?[T,A]:[g,c],E=w,D},s.toNumber=function(){return+oe(this)},s.toPrecision=function(a,u){return a!=null&&ne(a,1,le),K(this,a,u,2)},s.toString=function(a){var u,c=this,A=c.s,m=c.e;return m===null?A?(u="Infinity",A<0&&(u="-"+u)):u="NaN":(a==null?u=m<=p||m>=h?fn(Ie(c.c),m):ze(Ie(c.c),m,"0"):a===10&&B?(c=Y(new F(c),o+m+1,d),u=ze(Ie(c.c),c.e,"0")):(ne(a,2,M.length,"Base"),u=n(ze(Ie(c.c),m,"0"),10,a,A,!0)),A<0&&c.c[0]&&(u="-"+u)),u},s.valueOf=s.toJSON=function(){return oe(this)},s._isBigNumber=!0,s[Symbol.toStringTag]="BigNumber",s[Symbol.for("nodejs.util.inspect.custom")]=s.valueOf,e!=null&&F.set(e),F}function Oe(e){var t=e|0;return e>0||e===t?t:t-1}function Ie(e){for(var t,n,r=1,s=e.length,i=e[0]+"";r<s;){for(t=e[r++]+"",n=W-t.length;n--;t="0"+t);i+=t}for(s=i.length;i.charCodeAt(--s)===48;);return i.slice(0,s+1||1)}function mt(e,t){var n,r,s=e.c,i=t.c,o=e.s,d=t.s,p=e.e,h=t.e;if(!o||!d)return null;if(n=s&&!s[0],r=i&&!i[0],n||r)return n?r?0:-d:o;if(o!=d)return o;if(n=o<0,r=p==h,!s||!i)return r?0:!s^n?1:-1;if(!r)return p>h^n?1:-1;for(d=(p=s.length)<(h=i.length)?p:h,o=0;o<d;o++)if(s[o]!=i[o])return s[o]>i[o]^n?1:-1;return p==h?0:p>h^n?1:-1}function ne(e,t,n,r){if(e<t||e>n||e!==De(e))throw Error(xe+(r||"Argument")+(typeof e=="number"?e<t||e>n?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function hn(e){var t=e.c.length-1;return Oe(e.e/W)==t&&e.c[t]%2!=0}function fn(e,t){return(e.length>1?e.charAt(0)+"."+e.slice(1):e)+(t<0?"e":"e+")+t}function ze(e,t,n){var r,s;if(t<0){for(s=n+".";++t;s+=n);e=s+e}else if(r=e.length,++t>r){for(s=n,t-=r;--t;s+=n);e+=s}else t<r&&(e=e.slice(0,t)+"."+e.slice(t));return e}var S=Or();function li(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}const pi={1:{dex:{agent:{type:"default:odos-v2",router:"0xCf5540fFFCdC3d510B18bFcA6d2b9987b0772559",adapter:"0xC1bB4d5071Fe7109ae2D67AE05826A3fe9116cfc",fee:"0x03A70aC8126340d3cd6b5828816172693C398661"},sushiswap:{type:"default:sushi",router:"0xAC4c6e212A361c968F1725b4d055b47E63F80b75",adapter:"0x2e43A28FAf083717CcD9B246d97C61E1Bc9914Df",fee:"0x28F6C9dBE21fFc146Af8d5D15c49Cf48F61140Dc"}}},10:{dex:{agent:{type:"default:odos-v2",router:"0xCa423977156BB05b13A2BA3b76Bc5419E2fE9680",adapter:"0xC5Aea83Fdd94A19fB2ce0B7207939C52825D3D3B",fee:"0x03A70aC8126340d3cd6b5828816172693C398661"}}},14:{dex:{spark:{type:"default:spark",router:"0x0f3D8a38D4c74afBebc2c42695642f0e3acb15D3",adapter:"0x00c7617C471Ef69124464CEc318a3b8CC90aE9A7",fee:"0xaeA8C3e1a129A77686E115b1a46D9aD8405F7D2b"}}},56:{dex:{agent:{type:"default:odos-v2",router:"0x89b8AA89FDd0507a99d334CBe3C808fAFC7d850E",adapter:"0x67Feba015c968c76cCB2EEabf197b4578640BE2C",fee:"0x03A70aC8126340d3cd6b5828816172693C398661"},thena:{type:"default:odos-v2",router:"0x89b8AA89FDd0507a99d334CBe3C808fAFC7d850E",adapter:"0x9E61dEabe996236814c28eC69ab2A7405cB6f03E",fee:"0x15eBc8b5b3877512FFF23650188694A9a8891FAc"},pancake:{type:"p2:pancakeswap-v2",router:"0xd9C500DfF816a1Da21A48A732d3498Bf09dc9AEB",permit2:"0x31c2F6fcFf4F8759b3Bd5Bf0e1084A055615c768",adapter:"0x52Ed96B1AEd25818B6A284b063b055488E012b73",fee:"0x37A957f10F458e0d7fDECBE2917971b57F15c927"},newera:{type:"default:odos-v2",router:"0x89b8AA89FDd0507a99d334CBe3C808fAFC7d850E",adapter:"0x6236a466CE5c368DC6686d69cAcf5561196B76ef",fee:"0x4E7454909eB6D539111D56b50d68897E933D2d11"}}},137:{dex:{agent:{type:"default:odos-v2",router:"0x4E3288c9ca110bCC82bf38F09A7b425c095d92Bf",adapter:"0x75A3d70Fa6d054d31C896b9Cf8AB06b1c1B829B8",fee:"0x03A70aC8126340d3cd6b5828816172693C398661"},quick:{type:"paraswap:paraswap-v5",router:"0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57",adapter:"0x727e1CbA41Ff1ff11C32fa43DAb499b4317A1b65",fee:"0xd207DC6a6dA88f27c8DB78201F974161b1d84b1f"},teafi:{type:"paraswap:paraswap-v5",router:"0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57",adapter:"0xF710D67C783D2C14671EC1c61B0683DCb996F5c3",fee:"0x04Ff96e2c4D62b5771795d307AD679a25b3D2D50"}}},143:{dex:{yowie:{type:"default:openocean-v2",router:"0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",adapter:"0xCA84Ab5a5A5bf2cff6AC0C835eF049365D13c6cB",fee:"0x6AF3eE77A3A3257777F5649aFa611b4C7Fd975Ef"},pangolin:{type:"default:kyber-v2",router:"0x6131B5fae19EA4f9D964eAc0408E4408b66337b5",adapter:"0xf42106eBf985bF49b39eba0114F57FA05e7B52eD",fee:"0xde92da99D188Ceb54A11ec711EF52D808A6260B5"}}},146:{dex:{agent:{type:"default:odos-v2",router:"0xaC041Df48dF9791B0654f1Dbbf2CC8450C5f2e9D",adapter:"0x58fD209C81D84739BaD9c72C082350d67E713EEa",fee:"0x03A70aC8126340d3cd6b5828816172693C398661"},spooky:{type:"default:magpie-v3",router:"0xc325856e5585823aaC0D1Fd46c35c608D95E65A9",adapter:"0x56083Eb47d4d7d520F4d2b4a0DC98BE56bb98068",fee:"0x840Df4684B35BC68BcdA3F6707A3c82A0D662f8b"},swapx:{type:"default:openocean-v2",router:"0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",adapter:"0xa7AE3ABf86C81cCEFEd6bE77045F2a32660c1B1c",fee:"0x6E03f7BC0f141894612AA017796096399623895F"},shadow:{type:"default:magpie-v3",router:"0xc325856e5585823aaC0D1Fd46c35c608D95E65A9",adapter:"0x1adEE94aBa11F19981130F77a1B2620b67e4409A",fee:"0xb9e3751fAF3187E1bC468E56a707a8A91754460e"}}},1329:{dex:{dragon:{type:"default:dragon",router:"0x11DA6463D6Cb5a03411Dbf5ab6f6bc3997Ac7428",adapter:"0x1e84A9f30607959d2d8b1a04171ef7D9522Ef502",fee:"0x0dc1E0525202b32e89bA78ed55b1e5cEdB751334"},nami:{type:"default:openocean-v2",router:"0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",adapter:"0xba56F9A7865d430c8293851D576b5728Ca711ff5",fee:"0xeB58450e23632003f013568703F54446070E2E80"}}},5e3:{dex:{agent:{type:"default:odos-v2",router:"0xD9F4e85489aDCD0bAF0Cd63b4231c6af58c26745",adapter:"0x9571D46B5A5AAb749E5aCd698D8F20814C7B23D3",fee:"0x03A70aC8126340d3cd6b5828816172693C398661"}}},8453:{dex:{agent:{type:"default:odos-v2",router:"0x19cEeAd7105607Cd444F5ad10dd51356436095a1",adapter:"0x5906C4dD71D5afFe1a8f0215409E912eB5d593AD",fee:"0x03A70aC8126340d3cd6b5828816172693C398661"},pancake:{type:"p2:pancakeswap-v2",router:"0xFE6508f0015C778Bdcc1fB5465bA5ebE224C9912",permit2:"0x31c2F6fcFf4F8759b3Bd5Bf0e1084A055615c768",adapter:"0xA7CcB11F1D20D1F915FC220F5Cb1646E4523bB75",fee:"0x37A957f10F458e0d7fDECBE2917971b57F15c927"},quick:{type:"default:kyber-v2",router:"0x6131B5fae19EA4f9D964eAc0408E4408b66337b5",adapter:"0x0438644898F69bfF1018Cb01a81877D14d3e6493",fee:"0xd207DC6a6dA88f27c8DB78201F974161b1d84b1f"},trebleswap:{type:"default:trebleswap",router:"0x347539D82A14C0A3a89769f1024774A545a151ac",adapter:"0x6f4938535879c668A797F2a6e9B912c54f9D43Cf",fee:"0x15fc883d7DF4e681Ddb9E43e7B1D8c61d4fC162C"},sushiswap:{type:"default:sushi",router:"0xAC4c6e212A361c968F1725b4d055b47E63F80b75",adapter:"0x2e43A28FAf083717CcD9B246d97C61E1Bc9914Df",fee:"0x28F6C9dBE21fFc146Af8d5D15c49Cf48F61140Dc"}}},42161:{dex:{agent:{type:"default:odos-v2",router:"0xa669e7A0d4b3e4Fa48af2dE86BD4CD7126Be4e13",adapter:"0x026B8977319F67078e932a08feAcB59182B5380f",fee:"0x03A70aC8126340d3cd6b5828816172693C398661"},arbidex:{type:"default:odos-v2",router:"0xa669e7A0d4b3e4Fa48af2dE86BD4CD7126Be4e13",adapter:"0xaA66173674F4331e7e672899B3E6aB1190450898",fee:"0xa0c11852f8A44e32F9EC10AD25986A53842f72Ca"},ramses:{type:"paraswap:paraswap-v5",router:"0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57",adapter:"0xf075352f43cd15bA51B0957A4465223EDf6b4Cd8",fee:"0xB5BaCB60ECDa0bEF809B2A26eC9B4B926835D7af"},omni:{type:"paraswap:paraswap-v5",router:"0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57",adapter:"0x41c925E8E4fC65136BDf5322824E0D8c20c4824e",fee:"0xba5291526c30B097E9F1Fd1Be301E2ab6E0782aa"},chronos:{type:"default:odos-v2",router:"0x19cEeAd7105607Cd444F5ad10dd51356436095a1",adapter:"0x6a6b8975d1b131EFd0a9b536766EE7E5d4a16CF2",fee:"0x5729af83240EFecAa18eafaAE82961c2DD045Dbe"},pancake:{type:"p2:pancakeswap-v2",router:"0xFE6508f0015C778Bdcc1fB5465bA5ebE224C9912",permit2:"0x31c2F6fcFf4F8759b3Bd5Bf0e1084A055615c768",adapter:"0xA7CcB11F1D20D1F915FC220F5Cb1646E4523bB75",fee:"0x37A957f10F458e0d7fDECBE2917971b57F15c927"},sushiswap:{type:"default:sushi",router:"0xAC4c6e212A361c968F1725b4d055b47E63F80b75",adapter:"0x2e43A28FAf083717CcD9B246d97C61E1Bc9914Df",fee:"0x28F6C9dBE21fFc146Af8d5D15c49Cf48F61140Dc"}}},43114:{dex:{agent:{type:"default:odos-v2",router:"0x88de50B233052e4Fb783d4F6db78Cc34fEa3e9FC",adapter:"0x4F48041842827823D3750399eCa2832fC2E29201",fee:"0x03A70aC8126340d3cd6b5828816172693C398661"},blackhole:{type:"default:kyber-v2",router:"0x6131B5fae19EA4f9D964eAc0408E4408b66337b5",adapter:"0xccdF1D6ce95FeC0F842197470CE8969A678B0A04",fee:"0x7f8B62520D9B5DA0ED517cc36e8dcb2a356f1928"},pangolin:{type:"default:kyber-v2",router:"0x6131B5fae19EA4f9D964eAc0408E4408b66337b5",adapter:"0xf42106eBf985bF49b39eba0114F57FA05e7B52eD",fee:"0xde92da99D188Ceb54A11ec711EF52D808A6260B5"}}},59144:{dex:{agent:{type:"default:odos-v2",router:"0x2d8879046f1559E53eb052E949e9544bCB72f414",adapter:"0x55E4da2cd634729064bEb294EC682Dc94f5c3f24",fee:"0x03A70aC8126340d3cd6b5828816172693C398661"},pancake:{type:"p2:pancakeswap-v2",router:"0xFE6508f0015C778Bdcc1fB5465bA5ebE224C9912",permit2:"0x31c2F6fcFf4F8759b3Bd5Bf0e1084A055615c768",adapter:"0xA7CcB11F1D20D1F915FC220F5Cb1646E4523bB75",fee:"0x37A957f10F458e0d7fDECBE2917971b57F15c927"},lynex:{type:"default:openocean",router:"0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",adapter:"0xd8bC1FF79a642e8D7Fbd0711374F287202fBb3AA",fee:"0xcb36ed1B1BfAD8F7FC9651f52d21f04A68677423"}}},80094:{dex:{kodiak:{type:"default:kodiak",router:"0x43Dac637c4383f91B4368041E7A8687da3806Cae",adapter:"0xcB16237c88A859d46Ae850B97d7D1bdECF482C06",fee:"0xBA47Ec15aFbCF6e7e9F52900632049530bB6bAe4"}}},747474:{dex:{sushiswap:{type:"default:sushi",router:"0xAC4c6e212A361c968F1725b4d055b47E63F80b75",adapter:"0x2e43A28FAf083717CcD9B246d97C61E1Bc9914Df",fee:"0x28F6C9dBE21fFc146Af8d5D15c49Cf48F61140Dc"}}},"*":{wm:"0x0005d5cE0dB57e5BE3b2b8b6FeB75f0ccd015000",repermit:"0x00002a9C4D9497df5Bd31768eC5d30eEf5405000",cosigner:"0x000ECFa392ecDEfEE6e2a5C095d39B7A32f1E000",reactor:"0x000000b33fE4fB9d999Dd684F79b110731c3d000",executor:"0x000642A0966d9bd49870D9519f76b5cf823f3000",refinery:"0x000E474c0D7084EAA35A501035E73269f4b009A5",salt:{wm:"0xc9b46eae42dfeba3222a0315bf682f33cd5cc9d60c9625642e88406f8415f152",repermit:"0x4871dc9008e605821ea9677b65ea2a60ffb774afb31e0dcaea2e192880096be7",cosigner:"0x1117fe6f4e25c9380d10b2b3314a1e9b33e5f65ba0e55e0c63d0640db0dd60a2",reactor:"0xec73677f3a465a9755d4c9eab9509b59a24613fdb8b78719682930373e9876f5",executor:"0x9abc67d936f79e493f1f14050c2f6adb87ec208ff7aaae2e7ae788a7cb4796d7",refinery:"0x9746de29f1dd31b2c8460d71e92a7aefa34911130e61f274f37776e598c48bec"}}};var Ln,Ir;function hi(){if(Ir)return Ln;Ir=1;const e=pi,t=s=>li(`./out/${s}.sol/${s}.abi.json`),n=()=>({wm:t("WM"),repermit:t("RePermit"),reactor:t("OrderReactor"),executor:t("Executor"),refinery:t("Refinery"),settler:t("Settler"),adapter:t("DefaultDexAdapter")});function r(s,i){if(!s)return;const{dex:o,...d}=e["*"]??{},p=e[s];if(!p)return;const{dex:h,...C}=p;if(!(i!=null&&i.trim()))return{...d,...C};const E=h==null?void 0:h[i];if(E)return{...d,...C,...E}}return Ln={config:r,abis:n,raw:e},Ln}var kr=hi();const Bt=(e,t)=>{if(!e||!t)return"";const n=S(10).pow(e||0);return S(t).times(n).idiv(n).div(n).toFixed()};S(0),S(1),S(10),S(1e18);function yt(e,t){return e==t||e.toLowerCase()==t.toLowerCase()}const Ut=e=>!!Zs.find(t=>yt(t,e||""));function fi(e){return[Fe.Years,Fe.Months,Fe.Weeks,Fe.Days,Fe.Hours,Fe.Minutes].find(n=>n<=e)||Fe.Minutes}const gt=e=>e?e.value*e.unit:0,mi=e=>!e||e==="NaN"?"0":S(e).decimalPlaces(0).toFixed(),At=e=>Object.values(ye).find(t=>t.id===e),yi=e=>{if(!e)return;const t=e.map(i=>Ae(i)),n=Object.entries(Ys).filter(([i])=>t.includes(i)).flatMap(([,i])=>i),r=e.map(i=>i.exchangeAddress),s=new Set([...r,...n].map(i=>i.toLowerCase()));return Array.from(s)},Nn=(e,t)=>e.version===1?(e.fillDelay||0)*1e3+xi(t):(e.fillDelay||0)*1e3,mn=e=>typeof window>"u"?null:new URLSearchParams(window.location.search).get(e),Mr=e=>Ur().filter(t=>t.name===e).map(t=>t.chainId),qn=(e="",t="",n=18,r=18)=>{if(!S(e||0).gt(0)||!S(t||0).gt(0))return"";const s=Bt(n,e),i=Bt(r,t);return S(i).div(s).toFixed()},_r=(e,t,n)=>{if(e.type===V.TWAP_MARKET)return"";const r=Bt(t,e.srcAmountPerTrade),s=Bt(n,e.dstMinAmountPerTrade);return S(s).div(r).toFixed()},Br=(e,t,n)=>{if(e.type===V.TWAP_MARKET)return"";const r=Bt(t,e.srcAmountPerTrade),s=Bt(n,e.triggerPricePerTrade);return S(s).div(r).toFixed()},gi=(e,t,n)=>{if(!e||!t||!n)return;const r=S(e).times(t),s=S(10).pow(n);return r.div(s).toFixed(0)},Ai=(e,t,n,r)=>{if(n||!r||!e||!t)return S(0).toString();const s=S(e).times(S(t)),i=S(10).pow(r),o=s.div(i);return S.max(1,o).integerValue(S.ROUND_FLOOR).toFixed(0)},Ei=(e,t,n,r)=>{if(e===j.TWAP||e===j.LIMIT)return"0";if(!r||!t||!n)return;const s=S(t).times(S(n)),i=S(10).pow(r),o=s.div(i);return S.max(1,o).integerValue(S.ROUND_FLOOR).toFixed(0)||"0"},bi=(e,t,n,r)=>{const s=gt(n)*2*t,i=mn(Yt.DURATION),o=fi(i?Number(i):s);return i?{unit:o,value:Number(S(Number(i)/o).toFixed(2))}:r||(e===j.LIMIT?{unit:Fe.Days,value:7}:e===j.STOP_LOSS||e===j.TAKE_PROFIT?{unit:Fe.Days,value:1}:{unit:o,value:Number(S(s/o).toFixed(2))})},Ti=(e,t,n)=>t!==j.TWAP?1:n!==void 0?n:Math.max(1,Math.ceil(e/2)),wi=(e,t,n)=>{if(!e||!t||!n)return 1;const s=S(t).times(e).div(n).integerValue(S.ROUND_FLOOR).toNumber();return Math.max(1,s)},Ci=(e,t)=>e+gt(t)+6e4,xi=e=>e.bidDelaySeconds*1e3*2,Si=(e="",t=0)=>!e||!t?"0":S(e).div(t).integerValue(S.ROUND_FLOOR).toFixed(0),vi=(e,t)=>({isError:!(e.unit===_n.unit&&e.value===_n.value)&>(e)*t>pn,value:Math.floor(pn/t)}),Pi=(e="",t="",n)=>{if(n===j.STOP_LOSS)return{isError:S(t||0).gte(S(e||0)),value:e}},Fi=(e="",t="",n)=>{if(n===j.TAKE_PROFIT)return{isError:S(t||0).lte(S(e||0)),value:e}},Di=(e="",t="",n=!1,r)=>{if(!n&&r===j.STOP_LOSS)return{isError:S(t||0).gte(S(e||0)),value:e}},Oi=(e="",t="",n=!1,r)=>{if(!n&&r===j.TAKE_PROFIT)return{isError:S(t||0).gte(S(e||0)),value:e}},Ii=(e,t)=>e===j.STOP_LOSS||e===j.TAKE_PROFIT?{isError:gt(t)>5184e6,value:5184e6}:{isError:gt(t)>pn,value:pn},ki=e=>({isError:gt(e)<Pr,value:Pr}),Mi=e=>({isError:gt(e)<In,value:In}),_i=(e,t,n)=>({isError:S(t||0).multipliedBy(e||0).isLessThan(n),value:n}),Bi=(e,t,n)=>({isError:n===j.TWAP&&S(e).isGreaterThan(t),value:t}),Ui=(e,t)=>{if(e===Ne.Pancake)switch(t){case 56:return $.PancakeSwap;case 42161:return $.PancakeSwapArbitrum;case 8453:return $.PancakeSwapBase;case 59144:return $.PancakeSwapLinea;default:return $.PancakeSwap}if(e===Ne.Sushiswap)switch(t){case 1:return $.SushiEth;case 42161:return $.SushiArb;case 8453:return $.SushiBase;case 747474:return $.SushiKatana;default:return $.SushiEth}if(e===Ne.Quick)switch(t){case 137:return $.QuickSwap;case 8453:return $.QuickSwapBase;default:return $.QuickSwap}if(e===Ne.Thena)switch(t){case 56:return $.Thena;default:return $.Thena}if(e===Ne.Spooky)switch(t){case 250:return $.SpookySwap;case 146:return $.SpookySwapSonic;default:return $.SpookySwap}if(e===Ne.Lynex)switch(t){case 59144:return $.Lynex;default:return $.Lynex}if(e===Ne.Swapx)switch(t){case 146:return $.SwapX;default:return $.SwapX}if(e===Ne.Blackhole)switch(t){case 43114:return $.BlackholeAvax;default:return $.BlackholeAvax}},Kn=(e,t=0)=>{const{abi:n,...r}=kr.config(t,e);if(!r.reactor)throw new Error(`Missing config for partner "${e}" on chain ${t}: reactor address not found`);return{...r,partner:e,twapConfig:Ui(e,t)}},Ur=()=>{const e=kr.raw;return Object.entries(e).filter(([t])=>t!=="*").flatMap(([t,n])=>{const r=n==null?void 0:n.dex;return!r||typeof r!="object"?[]:Object.entries(r).map(([s])=>({chainId:Number(t),name:s,config:Kn(s,Number(t))}))}).sort((t,n)=>t.name.localeCompare(n.name))},Rr=e=>{const t=mn(Yt.MIN_CHUNK_SIZE_USD);return t?parseInt(t):e},Ri=({marketPrice:e,typedInputAmount:t,srcUsd1Token:n,marketPriceLoading:r,triggerPriceError:s,limitPriceError:i,tradesError:o,fillDelayError:d,durationError:p,balanceError:h,minTradeSizeError:C})=>{if(!mn(Yt.IGNORE_ERRORS)&&!(S(e||0).isZero()||S(t||0).isZero()||S(n||"0").isZero()||r))return C||s||i||o||d||p||h},Lr=(e,t)=>{const n=Date.now().toString(),r=parseInt((e/1e3).toFixed(0)),s=mi(t/1e3),i=mn(Yt.FRESHNESS),o=i?parseInt(i):60;return{nonce:n,epoch:r,deadline:s,freshness:o}},Li=({chainId:e,srcToken:t,dstToken:n,srcAmount:r,deadlineMillis:s,fillDelayMillis:i,slippage:o,account:d,srcAmountPerTrade:p,dstMinAmountPerTrade:h="0",triggerAmountPerTrade:C="0",config:E,module:x})=>{const{nonce:P,epoch:I,deadline:O,freshness:M}=Lr(i,s),B=x===j.TAKE_PROFIT?Mn:C,F=x===j.TAKE_PROFIT?C:h,K={permitted:{token:t,amount:r},spender:E.reactor,nonce:P,deadline:O,witness:{reactor:E.reactor,executor:E.executor,exchange:{adapter:E.adapter,ref:E.fee,share:0,data:"0x"},swapper:d,nonce:P,deadline:O,chainid:e,exclusivity:0,epoch:I,slippage:o,freshness:M,input:{token:t,amount:p,maxAmount:r},output:{token:n,limit:S(F||0).toFixed(),stop:S(B||0).toFixed(),recipient:d}}};return{domain:{name:"RePermit",version:"1",chainId:e,verifyingContract:E.repermit},order:K,types:Js,primaryType:Fr}},Ni=({chainId:e,srcToken:t,dstToken:n,srcAmount:r,deadlineMillis:s,fillDelayMillis:i,slippage:o,account:d,srcAmountPerTrade:p,dstMinAmountPerTrade:h="0",triggerAmountPerTrade:C="0",config:E,module:x})=>{const{nonce:P,epoch:I,deadline:O,freshness:M}=Lr(i,s),B=Math.floor(Date.now()/1e3).toString(),F=h,K=x===j.STOP_LOSS?C:"0",U=x===j.TAKE_PROFIT?C:"0",Z={permitted:{token:t,amount:r},spender:E.reactor,nonce:P,deadline:O,witness:{reactor:E.reactor,executor:E.executor,exchange:{adapter:E.adapter,ref:E.fee,share:0,data:"0x"},swapper:d,nonce:P,start:B,deadline:O,chainid:e,exclusivity:0,epoch:I,slippage:o,freshness:M,input:{token:t,amount:p,maxAmount:r},output:{token:n,limit:S(F||0).toFixed(),triggerLower:S(K||0).toFixed(),triggerUpper:S(U||0).toFixed(),recipient:d}}};return{domain:{name:"RePermit",version:"1",chainId:e,verifyingContract:E.repermit},order:Z,types:ei,primaryType:Fr}},Nr=e=>Number(ln)>=2?Ni(e):Li(e),qi=`https://bi.orbs.network/putes/twap-ui-${.7}`;let Hn="unknown";function Ki(e){Hn=e}function Wn(){const e=Math.random().toString(36).substring(2,16),t=Math.random().toString(36).substring(2,16),n=Date.now().toString(36);return`id_${e+t+n}`}const Hi=(e,t,n)=>{var r,s,i,o,d,p,h,C,E;return{spotVersion:On.version,partner:e.partner,adapter:e.adapter,cosigner:e.cosigner,executor:e.executor,fee:e.fee,reactor:e.reactor,refinery:e.refinery,repermit:e.repermit,router:e.router,type:e.type,wm:e.wm,chainName:((r=e.twapConfig)==null?void 0:r.chainName)||"",chainId:n||0,twapVersion:((s=e.twapConfig)==null?void 0:s.twapVersion)||0,twapAddress:((i=e.twapConfig)==null?void 0:i.twapAddress)||"",lensAddress:((o=e.twapConfig)==null?void 0:o.lensAddress)||"",bidDelaySeconds:((d=e.twapConfig)==null?void 0:d.bidDelaySeconds)||0,minChunkSizeUsd:t,name:((p=e.twapConfig)==null?void 0:p.name)||"",exchangeAddress:((h=e.twapConfig)==null?void 0:h.exchangeAddress)||"",exchangeType:((C=e.twapConfig)==null?void 0:C.exchangeType)||"",pathfinderKey:((E=e.twapConfig)==null?void 0:E.pathfinderKey)||""}},qr=async e=>{try{await fetch(qi,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(e)}).then()}catch(t){console.error("Failed to send BI",t)}};class Wi{constructor(){Pn(this,"timeout");Pn(this,"config");Pn(this,"data",{_id:Wn()})}async updateAndSend(t={},n=!1,r){try{this.data={...this.data,...t},n?(await qr(this.data),r==null||r()):(clearTimeout(this.timeout),this.timeout=setTimeout(()=>{qr(this.data),r==null||r()},1e3))}catch(s){console.error("Failed to update and send BI",s)}}onCancelOrderRequest(t,n){this.updateAndSend({cancelOrderIdsV1:n===1?t:void 0,cancelOrderIdsV2:n===2?t:void 0,action:"cancel order",cancelOrderSuccess:!1,cancelOrderTxHash:void 0,actionError:void 0})}onCancelOrderSuccess(t){this.updateAndSend({cancelOrderTxHash:t,cancelOrderSuccess:!0})}onCancelOrderError(t){this.onTxError(t)}onWrapSuccess(t){this.updateAndSend({wrapTxHash:t})}onWrapRequest(){this.updateAndSend({action:"wrap"})}onWrapError(t){this.onTxError(t)}onApproveRequest(){this.updateAndSend({action:"approve"})}onApproveSuccess(t){this.updateAndSend({approvalTxHash:t})}onApproveError(t){this.onTxError(t)}onCrash(t){var n;this.updateAndSend({action:"crash",actionError:((n=t==null?void 0:t.message)==null?void 0:n.toLowerCase())||(t==null?void 0:t.toLowerCase())})}onTxError(t){var r;const n=((r=t==null?void 0:t.message)==null?void 0:r.toLowerCase())||(t==null?void 0:t.toLowerCase());this.updateAndSend({actionError:n})}onRequestOrder({account:t,chainId:n,module:r,srcToken:s,dstToken:i,fromTokenAmount:o,srcChunkAmount:d,minDstAmountOutPerTrade:p="",triggerPricePerTrade:h="",deadline:C,fillDelay:E,slippage:x,isMarketOrder:P,chunksAmount:I}){this.updateAndSend({toTokenAddress:i.address,toTokenSymbol:i.symbol,fromTokenAddress:s.address,fromTokenSymbol:s.symbol,fromTokenAmount:o,chunksAmount:I,srcChunkAmount:d,minDstAmountOutPerTrade:p,triggerPricePerTrade:h,deadline:C,fillDelay:E,slippage:x,chainId:n,walletAddress:t,module:r,orderType:P?"market":"limit",actionError:void 0})}onSignOrderRequest(t){this.updateAndSend({action:"sign order",order:t})}onSignOrderError(t){this.onTxError(t)}onSignOrderSuccess(t){this.updateAndSend({action:"sign order",signature:t})}init(t,n,r){var s;this.config=t,r!==((s=this.data)==null?void 0:s.chainId)&&(this.data={_id:Wn(),action:"module-import",uiVersion:Hn,...Hi(t,n,r),origin:window.location.origin},this.updateAndSend(this.data))}onCreateOrderError(t){this.onTxError(t)}onCreateOrderRequest(){this.updateAndSend({action:"create order"})}async onCreateOrderSuccess(t){this.updateAndSend({orderHash:t,orderSuccess:!0},void 0,()=>{this.data={_id:Wn(),action:"reset",uiVersion:Hn,origin:this.data.origin,spotVersion:On.version,partner:this.data.partner,adapter:this.data.adapter,cosigner:this.data.cosigner,executor:this.data.executor,fee:this.data.fee,reactor:this.data.reactor,refinery:this.data.refinery,repermit:this.data.repermit,router:this.data.router,type:this.data.type,wm:this.data.wm,chainName:this.data.chainName||"",chainId:this.data.chainId||0,twapVersion:this.data.twapVersion||0,twapAddress:this.data.twapAddress||"",lensAddress:this.data.lensAddress||"",bidDelaySeconds:this.data.bidDelaySeconds||0,minChunkSizeUsd:this.data.minChunkSizeUsd||0,name:this.data.name||"",exchangeAddress:this.data.exchangeAddress||"",exchangeType:this.data.exchangeType||"",pathfinderKey:this.data.pathfinderKey||""}})}onLoad(){this.updateAndSend({action:"module-import",origin:window.location.origin})}}const pe=new Wi,Qi=e=>{var d;const t=S(e.order.witness.output.limit||0).gt(1),n=e.order.witness.output.stop,r=e.order.witness.output.triggerUpper,s=S(n||0).eq(Mn)||S(r||0).gt(0),i=S(n||0).gt(0),o=((d=e.metadata.chunks)==null?void 0:d.length)||S(e.order.witness.input.maxAmount).div(S(e.order.witness.input.amount)).toNumber();return s?t?V.TAKE_PROFIT_LIMIT:V.TAKE_PROFIT_MARKET:i?t?V.STOP_LOSS_LIMIT:V.STOP_LOSS_MARKET:t?o>1&&t?V.TWAP_LIMIT:t?V.LIMIT:V.TWAP_MARKET:V.TWAP_MARKET},ji=e=>{var s;const t=((s=e.metadata.chunks)==null?void 0:s.filter(i=>i.status==="success").length)||0,n=e.metadata.expectedChunks||0,r=S(t).dividedBy(n).toNumber();return r>=.99?100:r<=0?0:Number((r*100).toFixed(2))},zi=(e,t)=>e.metadata.status==="completed"||t>=99?fe.Completed:["pending","eligible"].includes(e.metadata.status)?fe.Open:e.metadata.description.toLowerCase()==="cancelled by contract"?fe.Cancelled:fe.Expired,$i=e=>{var n;return(((n=e.metadata.chunks)==null?void 0:n.filter(r=>r.status==="success"))||[]).map(r=>({inAmount:r.inAmount,outAmount:r.outAmount,timestamp:new Date(r.timestamp).getTime(),txHash:r.txHash}))},Vi=(e,t)=>{var r;const n=e.length;return n>=t&&((r=e[n-1])==null?void 0:r.timestamp)||0},Gi=e=>S(e.metadata.displayOnlyInputTokenPriceUSD).dividedBy(1e18).toFixed(),Qn=e=>Number(e.order.witness.output.limit)===1?"":e.order.witness.output.limit,Xi=e=>{const{triggerLower:t="0",triggerUpper:n="0"}=e.order.witness.output,r=Qn(e),s=e.metadata.expectedChunks||1,i=S(n||0).gt(0);return{dstMinAmountPerTrade:r,triggerPricePerTrade:i?n:t,dstMinAmountTotal:S(r).multipliedBy(s).toFixed()}},Zi=e=>{const t=Qn(e),n=S(e.order.witness.output.stop||0).eq(Mn),r=e.metadata.expectedChunks||1;return{dstMinAmountPerTrade:n?"":t,triggerPricePerTrade:n?t:S(e.order.witness.output.stop||"").toFixed(),dstMinAmountTotal:n?"":S(t).multipliedBy(r).toFixed()}},Yi=e=>Number(ln)>=2?Xi(e):Zi(e),Kr=e=>{const t=ji(e),n=Qn(e),r=e.metadata.expectedChunks||1,s=$i(e),i=Qi(e);return{id:e.hash,hash:e.hash,version:2,type:i,maker:e.order.witness.swapper,progress:t,srcAmountFilled:s.reduce((o,d)=>o.plus(d.inAmount),new S(0)).toFixed()||"",dstAmountFilled:s.reduce((o,d)=>o.plus(d.outAmount),new S(0)).toFixed()||"",fills:s,srcTokenAddress:e.order.witness.input.token,dstTokenAddress:e.order.witness.output.token,orderDollarValueIn:Gi(e),fillDelay:e.order.witness.epoch*1e3,deadline:Number(e.order.deadline)*1e3,createdAt:new Date(e.timestamp).getTime(),srcAmount:e.order.witness.input.maxAmount,srcAmountPerTrade:e.order.witness.input.amount,totalTradesAmount:r,isMarketPrice:S(n||0).lte(1),chainId:e.order.witness.chainid,filledOrderTimestamp:Vi(s,r),status:zi(e,t),isTriggerPrice:i===V.TAKE_PROFIT_MARKET||i===V.TAKE_PROFIT_LIMIT||i===V.STOP_LOSS_LIMIT||i===V.STOP_LOSS_MARKET,rawOrder:e,...Yi(e)}},Ji=async({chainId:e,signal:t,account:n,exchange:r,isDev:s=!1})=>{try{if(!n)return[];const i=r?`&exchange=${r}`:"",d=await(await fetch(`${vr(s)}/orders?swapper=${n}&chainId=${e}${i}`,{signal:t})).json();return!d||!Array.isArray(d.orders)?[]:d.orders.map(Kr)}catch{return[]}},Hr=async(e,t,n=!1)=>{try{const r={signature:t,order:e,status:"pending"};pe.onCreateOrderRequest();const s=await fetch(`${vr(n)}/orders/new`,{method:"POST",body:JSON.stringify(r)}),i=await s.json().catch(()=>({}));if(!s.ok||!(i!=null&&i.success)){const d=(i==null?void 0:i.message)??s.statusText??"Request failed",p=(i==null?void 0:i.code)??s.status;throw new Error(`error:${d}, code:${p}`)}if(!i.signedOrder||typeof i.signedOrder!="object")throw new Error("Invalid API response: missing signedOrder");const o=Kr(i.signedOrder);return pe.onCreateOrderSuccess(o.id),o}catch(r){throw pe.onCreateOrderError(r),console.error(r),r}},$e=(e,t)=>e&&e.length?e.map(t||(n=>`${n}`)):void 0,ea=e=>{if(e)return Xs[e]},jn=async({chainId:e,buildQuery:t,extractResults:n,signal:r,retries:s=1,limit:i=1e3,page:o})=>{const d=ea(e);if(!d)throw new aa;const p=async E=>{let x=0;for(;x<=s;)try{const P=await fetch(d,{method:"POST",body:JSON.stringify({query:E}),signal:r,headers:{"Content-Type":"application/json"}});if(!P.ok)throw new Error(`HTTP error: ${P.status}`);const I=await P.json();if(I.errors)throw new Error(I.errors[0].message);return n(I)}catch(P){if(x===s)throw P;await new Promise(I=>setTimeout(I,500*2**x)),x++}return[]};let h=0;const C=[];if(o!==void 0){const E=t(o,i);try{return await p(E)}catch{console.warn(`Page ${o} failed, retrying one final time...`);try{return await p(E)}catch{return[]}}}for(;;){const E=t(h,i);let x;try{x=await p(E)}catch{console.warn(`Page ${h} failed, retrying one final time...`);try{x=await p(E)}catch{return C}}if(C.push(...x),x.length<i)break;h++}return C},Wr=e=>e.map(t=>({inAmount:t.srcAmountIn,outAmount:t.dstAmountOut,timestamp:t.timestamp,txHash:t.transactionHash})),Qr=(e,t)=>{const n=S(e||0).gt(1);return!n&&t===1?V.TWAP_MARKET:t>1&&n?V.TWAP_LIMIT:n?V.LIMIT:V.TWAP_MARKET},ta=(e,t,n,r)=>{var x;const s=Wr(n||[]),i=new S(e.ask_srcAmount||0).div(e.ask_srcBidAmount).integerValue(S.ROUND_FLOOR).toNumber(),d=(n==null?void 0:n.length)===i?(x=n==null?void 0:n[(n==null?void 0:n.length)-1])==null?void 0:x.timestamp:void 0,p=s.reduce((P,I)=>P.plus(I.inAmount),new S(0)).toFixed(),h=s.reduce((P,I)=>P.plus(I.outAmount),new S(0)).toFixed(),C=jr(e.ask_srcAmount,p),E=Qr(e.ask_dstMinAmount,i);return{version:1,isTriggerPrice:!1,id:e.Contract_id.toString(),hash:"",type:Qr(e.ask_dstMinAmount,i),srcTokenAddress:e.ask_srcToken,dstTokenAddress:e.ask_dstToken,exchangeAddress:e.exchange,twapAddress:e.twapAddress,maker:e.maker,progress:C,dstAmountFilled:h,srcAmountFilled:p,orderDollarValueIn:S(e.dollarValueIn||0).toFixed(6),srcAmount:e.ask_srcAmount,dstMinAmountTotal:S(e.ask_dstMinAmount).multipliedBy(i).toString(),fills:s,fillDelay:e.ask_fillDelay,deadline:e.ask_deadline*1e3,createdAt:new Date(e.timestamp).getTime(),dstMinAmountPerTrade:S(e.ask_dstMinAmount).eq(1)?"":e.ask_dstMinAmount,triggerPricePerTrade:"",srcAmountPerTrade:e.ask_srcBidAmount,txHash:e.transactionHash,totalTradesAmount:i,isMarketPrice:[V.TWAP_MARKET].includes(E),chainId:t,filledOrderTimestamp:d||0,status:r,rawOrder:e}},na=e=>{var E;if(!e)return"";const t=$e(e.accounts,x=>`"${x.toLowerCase()}"`),n=$e(yi(e.configs),x=>`"${x.toLowerCase()}"`),r=$e(e.inTokenSymbols,x=>`"${x.toUpperCase()}"`),s=$e(e.outTokenSymbols,x=>`"${x.toUpperCase()}"`),i=$e(e.inTokenAddresses,x=>`"${x.toLowerCase()}"`),o=$e(e.outTokenAddresses,x=>`"${x.toLowerCase()}"`),d=$e(e.transactionHashes,x=>`"${x.toLowerCase()}"`),p=$e(e.orderIds,x=>`"${x}"`),h=n!=null&&n.length?"":$e((E=e.configs)==null?void 0:E.map(x=>x.twapAddress),x=>`"${x.toLowerCase()}"`),C=e.minDollarValueIn;return[n?`exchange_in: [${n.join(", ")}]`:"",h?`twapAddress_in: [${h.join(", ")}]`:"",t?`maker_in: [${t.join(", ")}]`:"",d?`transactionHash_in: [${d.join(", ")}]`:"",p?`Contract_id_in: [${p.join(", ")}]`:"",C?`dollarValueIn_gte: ${C}`:"",r?`srcTokenSymbol_in: [${r.join(", ")}]`:"",s?`dstTokenSymbol_in: [${s.join(", ")}]`:"",i?`srcTokenAddress_in: [${i.join(", ")}]`:"",o?`dstTokenAddress_in: [${o.join(", ")}]`:"",e!=null&&e.startDate?`blockTimestamp_gte: ${e.startDate}`:"",e!=null&&e.endDate?`blockTimestamp_lte: ${e.endDate}`:"",(e==null?void 0:e.orderType)==="limit"?"ask_dstMinAmount_gt: 1":"",(e==null?void 0:e.orderType)==="market"?"ask_dstMinAmount_lte: 1":""].filter(Boolean).join(", ")};async function ra({chainId:e,signal:t,page:n,limit:r,filters:s}){const i=r||1e3,o=na(s);return await jn({chainId:e,signal:t,limit:i,page:n,buildQuery:(p,h)=>`
|
|
1
|
+
(function(k,H){typeof exports=="object"&&typeof module<"u"?H(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],H):(k=typeof globalThis<"u"?globalThis:k||self,H(k.SpotReact={},k.jsxRuntime,k.React))})(this,(function(k,H,S){"use strict";var tc=Object.defineProperty;var Ns=k=>{throw TypeError(k)};var nc=(k,H,S)=>H in k?tc(k,H,{enumerable:!0,configurable:!0,writable:!0,value:S}):k[H]=S;var Sn=(k,H,S)=>nc(k,typeof H!="symbol"?H+"":H,S),mr=(k,H,S)=>H.has(k)||Ns("Cannot "+S);var l=(k,H,S)=>(mr(k,H,"read from private field"),S?S.call(k):H.get(k)),N=(k,H,S)=>H.has(k)?Ns("Cannot add the same private member more than once"):H instanceof WeakSet?H.add(k):H.set(k,S),B=(k,H,S,Bt)=>(mr(k,H,"write to private field"),Bt?Bt.call(k,S):H.set(k,S),S),j=(k,H,S)=>(mr(k,H,"access private method"),S);var Fn=(k,H,S,Bt)=>({set _(ce){B(k,H,ce,S)},get _(){return l(k,H,Bt)}});var Ke,vt,Ps,xt,it,qt,Ds,Kt,ot,Ht,Os,St,Is,Ft,Wt,Me,Pt,fe,rn,Dt,Re,Je,ks,Se,X,sn,Ce,Ot,Qt,Ve,ct,an,jt,zt,It,kt,ut,$t,ee,dn,yr,gr,Ar,Er,br,Cr,Tr,qs,Ms,on,He,Te,Mt,We,ht,Bs,Ge,Le,cn,_s,Xe,dt,Fe,Ze,Ye,Pn,wr,Us,Qe,Rs,se,lt,pt,Vt,Gt,ft,Xt,Zt,Ls;function Bt(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const ce=Bt(S),z={SpookySwap:{chainName:"ftm",chainId:250,twapVersion:4,twapAddress:"0xd3B290FEB04E353d1821bc0a12397FdEa9a846C0",lensAddress:"0x0221EfDF1Fd3212AF87F23cceB7693a65fAF1d7f",takers:["0xDF406A27C58a8Cd6Fd43e143339bCE131216a913","0x504f6E10173249dD22491829D98862Cf81DeF79E"],bidDelaySeconds:60,minChunkSizeUsd:10,name:"SpookySwap",partner:"Orbs:TWAP:SpookySwap",exchangeAddress:"0xdF7CCd5fc7077E9de5f27a7b7bfDC837c82f8496",exchangeType:"ExchangeV2",pathfinderKey:""},SpookySwapSonic:{chainName:"sonic",chainId:146,twapVersion:4,twapAddress:"0x8963992816b4EafE5a22b7DB2A99513c18be9afA",lensAddress:"0x67e631F71232D63AcA98a2D5E9B2Bce5FCc39d5D",takers:["0xDF406A27C58a8Cd6Fd43e143339bCE131216a913","0x504f6E10173249dD22491829D98862Cf81DeF79E"],bidDelaySeconds:60,minChunkSizeUsd:10,name:"SpookySwapSonic",partner:"Orbs:TWAP:SpookySwap",exchangeAddress:"0x6699bE3aF75e5c1B807b1031dBde6dA9A67739F3",exchangeType:"ExchangeV2",pathfinderKey:""},QuickSwap:{chainName:"poly",chainId:137,twapVersion:4,twapAddress:"0x688C027B0f7FaCeFcBa73e472900d28c12C5bDF4",lensAddress:"0xe0D4E736fc76af7C256ae7652c8c1e850bfb7849",takers:["0xA05405b6340A7F43dC5835351BFC4f5b1F028359","0xE3Efef1563a5960ACc731F9e4d6f4cBf5bd87dcA"],bidDelaySeconds:60,minChunkSizeUsd:10,name:"QuickSwap",partner:"Orbs:TWAP:QuickSwap",exchangeAddress:"0x8FCc245209bE85C49D738D0CE5613F74E5d91E86",exchangeType:"ParaswapExchange",pathfinderKey:"QuickSwap,QuickSwapV3"},QuickSwapBase:{chainName:"base",chainId:8453,twapVersion:4,twapAddress:"0xc918bdC47264687796Cd54FE362FaC4f8b99Eb55",lensAddress:"0x6313188c1909b161074D62E43105faC9B756A23e",takers:["0xA05405b6340A7F43dC5835351BFC4f5b1F028359","0xE3Efef1563a5960ACc731F9e4d6f4cBf5bd87dcA"],bidDelaySeconds:60,minChunkSizeUsd:10,name:"QuickSwap",partner:"Orbs:TWAP:QuickSwap",exchangeAddress:"0xb7a3d74895bfd3aff6780525e36d79fcf26a895f",exchangeType:"ExchangeV2",pathfinderKey:""},Thena:{chainName:"bsc",chainId:56,twapVersion:4,twapAddress:"0xa6F7444D2b92Aa9F94a2165c77aAF2B671e63994",lensAddress:"0xEdB0c077fa87Fb21d050c619FF426798f8Fc1264",takers:["0xA05405b6340A7F43dC5835351BFC4f5b1F028359","0xE3Efef1563a5960ACc731F9e4d6f4cBf5bd87dcA"],bidDelaySeconds:60,minChunkSizeUsd:50,name:"Thena",partner:"Orbs:TWAP:Thena",exchangeAddress:"0x2B2fABDbfa4a15da0d351F947C14F4520db0bDc1",exchangeType:"ExchangeV2",pathfinderKey:"43,47"},PancakeSwap:{chainName:"bsc",chainId:56,twapVersion:4,twapAddress:"0xa6F7444D2b92Aa9F94a2165c77aAF2B671e63994",lensAddress:"0xEdB0c077fa87Fb21d050c619FF426798f8Fc1264",takers:["0xA05405b6340A7F43dC5835351BFC4f5b1F028359","0xE3Efef1563a5960ACc731F9e4d6f4cBf5bd87dcA"],bidDelaySeconds:60,minChunkSizeUsd:50,name:"PancakeSwap",partner:"Orbs:TWAP:PancakeSwap",exchangeAddress:"0x1A2bb6B75D58b740d88413ef4840D6fa3F637940",exchangeType:"P2Exchange",pathfinderKey:""},PancakeSwapArbitrum:{chainName:"arb",chainId:42161,twapVersion:4,twapAddress:"0x0B94dcC0EA2d1ee33Ab064DaC252de980a941eF3",lensAddress:"0x549e1fc9a47FCc0C5C2EbdfF31254cc49fF7164e",takers:["0xA05405b6340A7F43dC5835351BFC4f5b1F028359","0xE3Efef1563a5960ACc731F9e4d6f4cBf5bd87dcA"],bidDelaySeconds:60,minChunkSizeUsd:50,name:"PancakeSwap",partner:"Orbs:TWAP:PancakeSwap",exchangeAddress:"0xb37cB9A058c03081Ae6EF934313588cD53d408e7",exchangeType:"P2Exchange",pathfinderKey:""},PancakeSwapBase:{chainName:"base",chainId:8453,twapVersion:4,twapAddress:"0xc918bdC47264687796Cd54FE362FaC4f8b99Eb55",lensAddress:"0x6313188c1909b161074D62E43105faC9B756A23e",takers:["0xA05405b6340A7F43dC5835351BFC4f5b1F028359","0xE3Efef1563a5960ACc731F9e4d6f4cBf5bd87dcA"],bidDelaySeconds:60,minChunkSizeUsd:50,name:"PancakeSwap",partner:"Orbs:TWAP:PancakeSwap",exchangeAddress:"0xb37cB9A058c03081Ae6EF934313588cD53d408e7",exchangeType:"P2Exchange",pathfinderKey:""},PancakeSwapLinea:{chainName:"linea",chainId:59144,twapVersion:4,twapAddress:"0x48423e62acbfEF7779b5b4a5E7d6Fbd39E623d78",lensAddress:"0xe84CaEc86eCF3f0AB4267dC6130D9a5510e73DFb",takers:["0xA05405b6340A7F43dC5835351BFC4f5b1F028359","0xE3Efef1563a5960ACc731F9e4d6f4cBf5bd87dcA"],bidDelaySeconds:60,minChunkSizeUsd:100,name:"PancakeSwap",partner:"Orbs:TWAP:PancakeSwap",exchangeAddress:"0xb37cB9A058c03081Ae6EF934313588cD53d408e7",exchangeType:"P2Exchange",pathfinderKey:""},Lynex:{chainName:"linea",chainId:59144,twapVersion:4,twapAddress:"0x48423e62acbfEF7779b5b4a5E7d6Fbd39E623d78",lensAddress:"0xe84CaEc86eCF3f0AB4267dC6130D9a5510e73DFb",takers:["0xA05405b6340A7F43dC5835351BFC4f5b1F028359","0xE3Efef1563a5960ACc731F9e4d6f4cBf5bd87dcA"],bidDelaySeconds:60,minChunkSizeUsd:100,name:"Lynex",partner:"Orbs:TWAP:Lynex",exchangeAddress:"0x04C06C96d7D19977156016DD408B5992af0570a2",exchangeType:"ExchangeV2",pathfinderKey:"19,18"},SushiArb:{chainName:"arb",chainId:42161,twapVersion:4,twapAddress:"0x0B94dcC0EA2d1ee33Ab064DaC252de980a941eF3",lensAddress:"0x549e1fc9a47FCc0C5C2EbdfF31254cc49fF7164e",takers:["0xA05405b6340A7F43dC5835351BFC4f5b1F028359","0xE3Efef1563a5960ACc731F9e4d6f4cBf5bd87dcA"],bidDelaySeconds:60,minChunkSizeUsd:50,name:"SushiArb",partner:"Orbs:TWAP:Sushi",exchangeAddress:"0x04eB53119079FA779492720D1EfeAEBF0aF2e5ad",exchangeType:"ExchangeV2",pathfinderKey:""},SushiBase:{chainName:"base",chainId:8453,twapVersion:4,twapAddress:"0xc918bdC47264687796Cd54FE362FaC4f8b99Eb55",lensAddress:"0x6313188c1909b161074D62E43105faC9B756A23e",takers:["0xA05405b6340A7F43dC5835351BFC4f5b1F028359","0xE3Efef1563a5960ACc731F9e4d6f4cBf5bd87dcA"],bidDelaySeconds:60,minChunkSizeUsd:50,name:"SushiBase",partner:"Orbs:TWAP:Sushi",exchangeAddress:"0x04eB53119079FA779492720D1EfeAEBF0aF2e5ad",exchangeType:"ExchangeV2",pathfinderKey:""},SushiEth:{chainName:"eth",chainId:1,twapVersion:4,twapAddress:"0xb1ed8BCAD1EaC8a1DF0764700472391800D12946",lensAddress:"0x0967f448c4d4dbd14c355E635AE9CbF68cc44A60",takers:["0xA05405b6340A7F43dC5835351BFC4f5b1F028359","0xE3Efef1563a5960ACc731F9e4d6f4cBf5bd87dcA"],bidDelaySeconds:60,minChunkSizeUsd:200,name:"SushiEth",partner:"Orbs:TWAP:Sushi",exchangeAddress:"0x04eB53119079FA779492720D1EfeAEBF0aF2e5ad",exchangeType:"ExchangeV2",pathfinderKey:""},SushiKatana:{chainName:"katana",chainId:747474,twapVersion:4,twapAddress:"0xf2d96E7BE676153d202e1453804E2749923C7c5b",lensAddress:"0x1579EED0527781B1A748043AA1f59a3858Ace4a7",takers:["0xF74437A3Fc45a518640828E5D6A3E8c9A9BbDC3a","0x07A6C715063e94c0D95e809efefFCbF4EBEdfD55"],bidDelaySeconds:60,minChunkSizeUsd:50,name:"SushiKatana",partner:"Orbs:TWAP:Sushi",exchangeAddress:"0x92209481507e6B2d14C9b5b70Ed287024177220E",exchangeType:"ExchangeV2",pathfinderKey:""},DragonSwap:{chainId:1329,name:"DragonSwap"},SwapX:{chainName:"sonic",chainId:146,twapVersion:4,twapAddress:"0x8963992816b4EafE5a22b7DB2A99513c18be9afA",lensAddress:"0x67e631F71232D63AcA98a2D5E9B2Bce5FCc39d5D",takers:["0xDF406A27C58a8Cd6Fd43e143339bCE131216a913","0x504f6E10173249dD22491829D98862Cf81DeF79E"],bidDelaySeconds:60,minChunkSizeUsd:10,name:"SwapX",partner:"Orbs:TWAP:SwapX",exchangeAddress:"0xDA902994b7F7a1ecDd8De02E4a17dbFF2E6F67b7",exchangeType:"ExchangeV2",pathfinderKey:""},BlackholeAvax:{chainName:"avax",chainId:43114,twapVersion:4,twapAddress:"0xf77Ad005aBF7e31f669ce89a6568B2f39Ca92cDe",lensAddress:"0x48466B82Ce1575c5c9eCa168ac1090048dD47fA3",takers:["0xA05405b6340A7F43dC5835351BFC4f5b1F028359","0xE3Efef1563a5960ACc731F9e4d6f4cBf5bd87dcA"],bidDelaySeconds:60,minChunkSizeUsd:50,name:"BlackholeAvax",partner:"Orbs:TWAP:BlackholeAvax",exchangeAddress:"0xb7A3d74895bFD3Aff6780525e36D79FCf26a895F",exchangeType:"ExchangeV2"}},Ks=JSON.parse('[{"inputs":[{"internalType":"address","name":"_iweth","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint64","name":"id","type":"uint64"},{"indexed":true,"internalType":"address","name":"maker","type":"address"},{"indexed":true,"internalType":"address","name":"exchange","type":"address"},{"indexed":false,"internalType":"uint32","name":"slippagePercent","type":"uint32"},{"components":[{"internalType":"uint32","name":"time","type":"uint32"},{"internalType":"address","name":"taker","type":"address"},{"internalType":"address","name":"exchange","type":"address"},{"internalType":"uint256","name":"dstAmount","type":"uint256"},{"internalType":"uint256","name":"dstFee","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"indexed":false,"internalType":"struct OrderLib.Bid","name":"bid","type":"tuple"}],"name":"OrderBid","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint64","name":"id","type":"uint64"},{"indexed":true,"internalType":"address","name":"maker","type":"address"},{"indexed":false,"internalType":"address","name":"sender","type":"address"}],"name":"OrderCanceled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint64","name":"id","type":"uint64"},{"indexed":true,"internalType":"address","name":"maker","type":"address"},{"indexed":true,"internalType":"address","name":"exchange","type":"address"},{"indexed":false,"internalType":"address","name":"taker","type":"address"}],"name":"OrderCompleted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint64","name":"id","type":"uint64"},{"indexed":true,"internalType":"address","name":"maker","type":"address"},{"indexed":true,"internalType":"address","name":"exchange","type":"address"},{"components":[{"internalType":"address","name":"exchange","type":"address"},{"internalType":"address","name":"srcToken","type":"address"},{"internalType":"address","name":"dstToken","type":"address"},{"internalType":"uint256","name":"srcAmount","type":"uint256"},{"internalType":"uint256","name":"srcBidAmount","type":"uint256"},{"internalType":"uint256","name":"dstMinAmount","type":"uint256"},{"internalType":"uint32","name":"deadline","type":"uint32"},{"internalType":"uint32","name":"bidDelay","type":"uint32"},{"internalType":"uint32","name":"fillDelay","type":"uint32"},{"internalType":"bytes","name":"data","type":"bytes"}],"indexed":false,"internalType":"struct OrderLib.Ask","name":"ask","type":"tuple"}],"name":"OrderCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint64","name":"id","type":"uint64"},{"indexed":true,"internalType":"address","name":"maker","type":"address"},{"indexed":true,"internalType":"address","name":"exchange","type":"address"},{"indexed":false,"internalType":"address","name":"taker","type":"address"},{"indexed":false,"internalType":"uint256","name":"srcAmountIn","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"dstAmountOut","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"dstFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"srcFilledAmount","type":"uint256"}],"name":"OrderFilled","type":"event"},{"inputs":[],"name":"MIN_BID_DELAY_SECONDS","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MIN_OUTBID_PERCENT","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PERCENT_BASE","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"STALE_BID_SECONDS","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"STATUS_CANCELED","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"STATUS_COMPLETED","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"VERSION","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"exchange","type":"address"},{"internalType":"address","name":"srcToken","type":"address"},{"internalType":"address","name":"dstToken","type":"address"},{"internalType":"uint256","name":"srcAmount","type":"uint256"},{"internalType":"uint256","name":"srcBidAmount","type":"uint256"},{"internalType":"uint256","name":"dstMinAmount","type":"uint256"},{"internalType":"uint32","name":"deadline","type":"uint32"},{"internalType":"uint32","name":"bidDelay","type":"uint32"},{"internalType":"uint32","name":"fillDelay","type":"uint32"},{"internalType":"bytes","name":"data","type":"bytes"}],"internalType":"struct OrderLib.Ask","name":"_ask","type":"tuple"}],"name":"ask","outputs":[{"internalType":"uint64","name":"id","type":"uint64"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint64","name":"id","type":"uint64"},{"internalType":"address","name":"exchange","type":"address"},{"internalType":"uint256","name":"dstFee","type":"uint256"},{"internalType":"uint32","name":"slippagePercent","type":"uint32"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"bid","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"book","outputs":[{"internalType":"uint64","name":"id","type":"uint64"},{"internalType":"uint32","name":"status","type":"uint32"},{"internalType":"uint32","name":"time","type":"uint32"},{"internalType":"uint32","name":"filledTime","type":"uint32"},{"internalType":"uint256","name":"srcFilledAmount","type":"uint256"},{"internalType":"address","name":"maker","type":"address"},{"components":[{"internalType":"address","name":"exchange","type":"address"},{"internalType":"address","name":"srcToken","type":"address"},{"internalType":"address","name":"dstToken","type":"address"},{"internalType":"uint256","name":"srcAmount","type":"uint256"},{"internalType":"uint256","name":"srcBidAmount","type":"uint256"},{"internalType":"uint256","name":"dstMinAmount","type":"uint256"},{"internalType":"uint32","name":"deadline","type":"uint32"},{"internalType":"uint32","name":"bidDelay","type":"uint32"},{"internalType":"uint32","name":"fillDelay","type":"uint32"},{"internalType":"bytes","name":"data","type":"bytes"}],"internalType":"struct OrderLib.Ask","name":"ask","type":"tuple"},{"components":[{"internalType":"uint32","name":"time","type":"uint32"},{"internalType":"address","name":"taker","type":"address"},{"internalType":"address","name":"exchange","type":"address"},{"internalType":"uint256","name":"dstAmount","type":"uint256"},{"internalType":"uint256","name":"dstFee","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"internalType":"struct OrderLib.Bid","name":"bid","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64","name":"id","type":"uint64"}],"name":"cancel","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint64","name":"id","type":"uint64"}],"name":"fill","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"iweth","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"length","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"makerOrders","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64","name":"id","type":"uint64"}],"name":"order","outputs":[{"components":[{"internalType":"uint64","name":"id","type":"uint64"},{"internalType":"uint32","name":"status","type":"uint32"},{"internalType":"uint32","name":"time","type":"uint32"},{"internalType":"uint32","name":"filledTime","type":"uint32"},{"internalType":"uint256","name":"srcFilledAmount","type":"uint256"},{"internalType":"address","name":"maker","type":"address"},{"components":[{"internalType":"address","name":"exchange","type":"address"},{"internalType":"address","name":"srcToken","type":"address"},{"internalType":"address","name":"dstToken","type":"address"},{"internalType":"uint256","name":"srcAmount","type":"uint256"},{"internalType":"uint256","name":"srcBidAmount","type":"uint256"},{"internalType":"uint256","name":"dstMinAmount","type":"uint256"},{"internalType":"uint32","name":"deadline","type":"uint32"},{"internalType":"uint32","name":"bidDelay","type":"uint32"},{"internalType":"uint32","name":"fillDelay","type":"uint32"},{"internalType":"bytes","name":"data","type":"bytes"}],"internalType":"struct OrderLib.Ask","name":"ask","type":"tuple"},{"components":[{"internalType":"uint32","name":"time","type":"uint32"},{"internalType":"address","name":"taker","type":"address"},{"internalType":"address","name":"exchange","type":"address"},{"internalType":"uint256","name":"dstAmount","type":"uint256"},{"internalType":"uint256","name":"dstFee","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"internalType":"struct OrderLib.Bid","name":"bid","type":"tuple"}],"internalType":"struct OrderLib.Order","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"maker","type":"address"}],"name":"orderIdsByMaker","outputs":[{"internalType":"uint64[]","name":"","type":"uint64[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64","name":"id","type":"uint64"}],"name":"prune","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"status","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]'),Hs=[{type:"constructor",inputs:[],stateMutability:"nonpayable"},{type:"function",name:"DOMAIN_SEPARATOR",inputs:[],outputs:[{name:"",type:"bytes32",internalType:"bytes32"}],stateMutability:"view"},{type:"function",name:"cancel",inputs:[{name:"digests",type:"bytes32[]",internalType:"bytes32[]"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"eip712Domain",inputs:[],outputs:[{name:"fields",type:"bytes1",internalType:"bytes1"},{name:"name",type:"string",internalType:"string"},{name:"version",type:"string",internalType:"string"},{name:"chainId",type:"uint256",internalType:"uint256"},{name:"verifyingContract",type:"address",internalType:"address"},{name:"salt",type:"bytes32",internalType:"bytes32"},{name:"extensions",type:"uint256[]",internalType:"uint256[]"}],stateMutability:"view"},{type:"function",name:"hashTypedData",inputs:[{name:"structHash",type:"bytes32",internalType:"bytes32"}],outputs:[{name:"digest",type:"bytes32",internalType:"bytes32"}],stateMutability:"view"},{type:"function",name:"repermitWitnessTransferFrom",inputs:[{name:"permit",type:"tuple",internalType:"struct RePermitLib.RePermitTransferFrom",components:[{name:"permitted",type:"tuple",internalType:"struct RePermitLib.TokenPermissions",components:[{name:"token",type:"address",internalType:"address"},{name:"amount",type:"uint256",internalType:"uint256"}]},{name:"nonce",type:"uint256",internalType:"uint256"},{name:"deadline",type:"uint256",internalType:"uint256"}]},{name:"request",type:"tuple",internalType:"struct RePermitLib.TransferRequest",components:[{name:"to",type:"address",internalType:"address"},{name:"amount",type:"uint256",internalType:"uint256"}]},{name:"signer",type:"address",internalType:"address"},{name:"witness",type:"bytes32",internalType:"bytes32"},{name:"witnessTypeString",type:"string",internalType:"string"},{name:"signature",type:"bytes",internalType:"bytes"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"spent",inputs:[{name:"",type:"address",internalType:"address"},{name:"",type:"bytes32",internalType:"bytes32"}],outputs:[{name:"",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"event",name:"Cancel",inputs:[{name:"signer",type:"address",indexed:!0,internalType:"address"},{name:"digest",type:"bytes32",indexed:!1,internalType:"bytes32"}],anonymous:!1},{type:"event",name:"EIP712DomainChanged",inputs:[],anonymous:!1},{type:"event",name:"Spend",inputs:[{name:"signer",type:"address",indexed:!0,internalType:"address"},{name:"permitHash",type:"bytes32",indexed:!0,internalType:"bytes32"},{name:"token",type:"address",indexed:!0,internalType:"address"},{name:"to",type:"address",indexed:!1,internalType:"address"},{name:"amount",type:"uint256",indexed:!1,internalType:"uint256"},{name:"totalSpent",type:"uint256",indexed:!1,internalType:"uint256"}],anonymous:!1},{type:"error",name:"Canceled",inputs:[]},{type:"error",name:"Expired",inputs:[]},{type:"error",name:"InsufficientAllowance",inputs:[]},{type:"error",name:"InvalidShortString",inputs:[]},{type:"error",name:"InvalidSignature",inputs:[]},{type:"error",name:"SafeERC20FailedOperation",inputs:[{name:"token",type:"address",internalType:"address"}]},{type:"error",name:"StringTooLong",inputs:[{name:"str",type:"string",internalType:"string"}]}],Ws=Ks;var $=(e=>(e.TWAP="TWAP",e.LIMIT="LIMIT",e.STOP_LOSS="STOP_LOSS",e.TAKE_PROFIT="TAKE_PROFIT",e))($||{}),he=(e=>(e.Open="OPEN",e.Cancelled="CANCELLED",e.Completed="COMPLETED",e.Expired="EXPIRED",e))(he||{}),vr=(e=>(e.All="ALL",e.Open="OPEN",e.Cancelled="CANCELLED",e.Completed="COMPLETED",e.Expired="EXPIRED",e))(vr||{}),Pe=(e=>(e[e.Minutes=6e4]="Minutes",e[e.Hours=36e5]="Hours",e[e.Weeks=6048e5]="Weeks",e[e.Days=864e5]="Days",e[e.Months=2592e6]="Months",e[e.Years=31536e6]="Years",e))(Pe||{}),V=(e=>(e.LIMIT="limit",e.TWAP_LIMIT="twap-limit",e.TWAP_MARKET="twap-market",e.TAKE_PROFIT_MARKET="take-profit-market",e.TAKE_PROFIT_LIMIT="take-profit-limit",e.STOP_LOSS_LIMIT="stop-loss-limit",e.STOP_LOSS_MARKET="stop-loss-market",e))(V||{}),Ne=(e=>(e.Arbidex="arbidex",e.Blackhole="blackhole",e.Chronos="chronos",e.Dragon="dragon",e.Kodiak="kodiak",e.Lynex="lynex",e.Nami="nami",e.Newera="newera",e.Omni="omni",e.Pancake="pancake",e.Quick="quick",e.Ramses="ramses",e.Shadow="shadow",e.Spark="spark",e.Spooky="spooky",e.Swapx="swapx",e.Teafi="teafi",e.Thena="thena",e.Yowie="yowie",e.Pangolin="pangolin",e.Sushiswap="sushiswap",e.Agent="agent",e))(Ne||{}),me=(e=>(e.EMPTY_LIMIT_PRICE="emptyLimitPrice",e.MAX_CHUNKS="maxChunksError",e.MIN_CHUNKS="minChunksError",e.MIN_TRADE_SIZE="minTradeSizeError",e.MAX_FILL_DELAY="maxFillDelayError",e.MIN_FILL_DELAY="minFillDelayError",e.MAX_ORDER_DURATION="maxDurationError",e.MIN_ORDER_DURATION="minDurationError",e.MISSING_LIMIT_PRICE="missingLimitPrice",e.STOP_LOSS_TRIGGER_PRICE_GREATER_THAN_MARKET_PRICE="StopLossTriggerPriceError",e.TRIGGER_LIMIT_PRICE_GREATER_THAN_TRIGGER_PRICE="triggerLimitPriceError",e.TAKE_PROFIT_TRIGGER_PRICE_LESS_THAN_MARKET_PRICE="TakeProfitTriggerPriceError",e.EMPTY_TRIGGER_PRICE="emptyTriggerPrice",e.INSUFFICIENT_BALANCE="insufficientFunds",e.MAX_ORDER_SIZE="maxOrderSize",e.MIN_TRADE_SIZE_ERROR="minTradeSizeError",e))(me||{});const re="0x0000000000000000000000000000000000000000",ye={eth:{id:1,name:"Ethereum",shortname:"eth",native:{address:re,symbol:"ETH",decimals:18,logoUrl:"https://app.1inch.io/assets/images/network-logos/ethereum.svg"},wToken:{symbol:"WETH",address:"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",decimals:18,logoUrl:"https://tokens-data.1inch.io/images/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2.png"},publicRpcUrl:"https://eth.llamarpc.com",logoUrl:"https://app.1inch.io/assets/images/network-logos/ethereum.svg",explorer:"https://etherscan.io",eip1559:!0},bsc:{id:56,name:"BinanceSmartChain",shortname:"bsc",native:{address:re,symbol:"BNB",decimals:18,logoUrl:"https://s2.coinmarketcap.com/static/img/coins/128x128/1839.png"},wToken:{symbol:"WBNB",address:"0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c",decimals:18,logoUrl:"https://s2.coinmarketcap.com/static/img/coins/128x128/1839.png"},publicRpcUrl:"https://bsc-dataseed.binance.org",logoUrl:"https://app.1inch.io/assets/images/network-logos/bsc_2.svg",explorer:"https://bscscan.com",eip1559:!1},poly:{id:137,name:"Polygon",shortname:"poly",native:{address:re,symbol:"POL",decimals:18,logoUrl:"https://s2.coinmarketcap.com/static/img/coins/64x64/28321.png"},wToken:{symbol:"WPOL",address:"0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270",decimals:18,logoUrl:"https://tokens-data.1inch.io/images/0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270.png"},publicRpcUrl:"https://polygon-rpc.com",logoUrl:"https://app.1inch.io/assets/images/network-logos/polygon.svg",explorer:"https://polygonscan.com",eip1559:!0},arb:{id:42161,name:"Arbitrum",shortname:"arb",native:{address:re,symbol:"ETH",decimals:18,logoUrl:"https://app.1inch.io/assets/images/network-logos/ethereum.svg"},wToken:{symbol:"WETH",address:"0x82af49447d8a07e3bd95bd0d56f35241523fbab1",decimals:18,logoUrl:"https://tokens-data.1inch.io/images/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2.png"},publicRpcUrl:"https://arb1.arbitrum.io/rpc",logoUrl:"https://app.1inch.io/assets/images/network-logos/arbitrum.svg",explorer:"https://arbiscan.io",eip1559:!0},sei:{id:1329,name:"Sei",shortname:"sei",native:{address:re,symbol:"SEI",decimals:18,logoUrl:"https://assets.coingecko.com/coins/images/28205/standard/Sei_Logo_-_Transparent.png"},wToken:{symbol:"WSEI",address:"0xE30feDd158A2e3b13e9badaeABaFc5516e95e8C7",decimals:18,logoUrl:"https://tokens-data.1inch.io/images/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2.png"},publicRpcUrl:"https://evm-rpc.sei-apis.com",logoUrl:"https://assets.coingecko.com/coins/images/28205/standard/Sei_Logo_-_Transparent.png",explorer:"https://seitrace.com",eip1559:!1},avax:{id:43114,name:"Avalanche",shortname:"avax",native:{address:re,symbol:"AVAX",decimals:18,logoUrl:"https://app.1inch.io/assets/images/network-logos/avalanche.svg"},wToken:{symbol:"WAVAX",address:"0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7",decimals:18,logoUrl:"https://tokens-data.1inch.io/images/0xb31f66aa3c1e785363f0875a1b74e27b85fd66c7.png"},publicRpcUrl:"https://api.avax.network/ext/bc/C/rpc",logoUrl:"https://app.1inch.io/assets/images/network-logos/avalanche.svg",explorer:"https://snowtrace.io",eip1559:!0},ftm:{id:250,name:"Fantom",shortname:"ftm",native:{address:re,symbol:"FTM",decimals:18,logoUrl:"https://app.1inch.io/assets/images/network-logos/fantom.svg"},wToken:{symbol:"WFTM",address:"0x21be370D5312f44cB42ce377BC9b8a0cEF1A4C83",decimals:18,logoUrl:"https://tokens-data.1inch.io/images/0x4e15361fd6b4bb609fa63c81a2be19d873717870.png"},publicRpcUrl:"https://rpc.ftm.tools",logoUrl:"https://app.1inch.io/assets/images/network-logos/fantom.svg",explorer:"https://ftmscan.com",eip1559:!0},base:{id:8453,name:"Base",shortname:"base",native:{address:re,symbol:"ETH",decimals:18,logoUrl:"https://s2.coinmarketcap.com/static/img/coins/128x128/1027.png"},wToken:{symbol:"WETH",address:"0x4200000000000000000000000000000000000006",decimals:18,logoUrl:"https://tokens-data.1inch.io/images/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2.png"},publicRpcUrl:"https://mainnet.base.org",logoUrl:"https://app.1inch.io/assets/images/network-logos/base.svg",explorer:"https://basescan.org",eip1559:!1},linea:{id:59144,name:"Linea",shortname:"linea",native:{address:re,symbol:"ETH",decimals:18,logoUrl:"https://app.1inch.io/assets/images/network-logos/ethereum.svg"},wToken:{symbol:"WETH",address:"0xe5D7C2a44FfDDf6b295A15c148167daaAf5Cf34f",decimals:18,logoUrl:"https://tokens-data.1inch.io/images/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2.png"},publicRpcUrl:"https://rpc.linea.build",logoUrl:"https://lineascan.build/images/logo.svg",explorer:"https://lineascan.build",eip1559:!1},zksync:{id:324,name:"zksync",shortname:"zksync",native:{address:re,symbol:"ETH",decimals:18,logoUrl:"https://app.1inch.io/assets/images/network-logos/ethereum.svg"},wToken:{symbol:"WETH",address:"0x5AEa5775959fBC2557Cc8789bC1bf90A239D9a91",decimals:18,logoUrl:"https://tokens-data.1inch.io/images/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2.png"},publicRpcUrl:"https://mainnet.era.zksync.io",logoUrl:"https://raw.githubusercontent.com/matter-labs/zksync/0a4ca2145a0c95b5bafa84c2f095c644907a8825/zkSyncLogo.svg",explorer:"https://explorer.zksync.io/",eip1559:!0},zkevm:{id:1101,name:"zkevm",shortname:"zkevm",native:{address:re,symbol:"ETH",decimals:18,logoUrl:"https://app.1inch.io/assets/images/network-logos/ethereum.svg"},wToken:{symbol:"WETH",address:"0x4F9A0e7FD2Bf6067db6994CF12E4495Df938E6e9",decimals:18,logoUrl:"https://tokens-data.1inch.io/images/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2.png"},publicRpcUrl:"https://zkevm-rpc.com",logoUrl:"https://user-images.githubusercontent.com/18598517/235932702-bc47eae5-d672-4dd9-9da2-8ea8f51a93f3.png",explorer:"https://zkevm.polygonscan.com/",eip1559:!0},manta:{id:169,name:"manta",shortname:"manta",native:{address:re,symbol:"ETH",decimals:18,logoUrl:"https://icons.llamao.fi/icons/chains/rsz_manta.jpg"},wToken:{symbol:"WETH",address:"0x0Dc808adcE2099A9F62AA87D9670745AbA741746",decimals:18,logoUrl:"https://tokens-data.1inch.io/images/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2.png"},publicRpcUrl:"https://pacific-rpc.manta.network/http",logoUrl:"https://icons.llamao.fi/icons/chains/rsz_manta.jpg",explorer:"https://manta.socialscan.io/",eip1559:!0},blast:{id:81457,name:"blast",shortname:"blast",native:{address:re,symbol:"ETH",decimals:18,logoUrl:"https://icons.llamao.fi/icons/chains/rsz_blast"},wToken:{symbol:"WETH",address:"0x4300000000000000000000000000000000000004",decimals:18,logoUrl:"https://tokens-data.1inch.io/images/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2.png"},publicRpcUrl:"https://rpc.ankr.com/blast",logoUrl:"https://icons.llamao.fi/icons/chains/rsz_blast",explorer:"https://blastscan.io/",eip1559:!0},sonic:{id:146,name:"sonic",shortname:"sonic",native:{address:re,symbol:"S",decimals:18,logoUrl:"https://icons.llamao.fi/icons/chains/rsz_sonic"},wToken:{symbol:"WS",address:"0x039e2fB66102314Ce7b64Ce5Ce3E5183bc94aD38",decimals:18,logoUrl:"https://icons.llamao.fi/icons/chains/rsz_sonic"},publicRpcUrl:"https://rpc.soniclabs.com",logoUrl:"https://icons.llamao.fi/icons/chains/rsz_sonic",explorer:"https://www.sonicscan.org/",eip1559:!0},scroll:{id:534352,name:"scroll",shortname:"scroll",native:{address:re,symbol:"ETH",decimals:18,logoUrl:"https://icons.llamao.fi/icons/chains/rsz_scroll"},wToken:{symbol:"WETH",address:"0x5300000000000000000000000000000000000004",decimals:18,logoUrl:"https://tokens-data.1inch.io/images/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2.png"},publicRpcUrl:"https://scroll-rpc.publicnode.com",logoUrl:"https://icons.llamao.fi/icons/chains/rsz_scroll",explorer:"https://scrollscan.com/",eip1559:!0},zircuit:{id:48900,name:"Zircuit",shortname:"zircuit",native:{address:re,symbol:"ETH",decimals:18,logoUrl:"https://app.1inch.io/assets/images/network-logos/ethereum.svg"},wToken:{symbol:"WETH",address:"0x4200000000000000000000000000000000000006",decimals:18,logoUrl:"https://tokens-data.1inch.io/images/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2.png"},publicRpcUrl:"https://zircuit-mainnet.drpc.org",logoUrl:"https://app.1inch.io/assets/images/network-logos/ethereum.svg",explorer:"https://explorer.zircuit.com/",eip1559:!0},flare:{id:14,name:"flare",shortname:"flare",native:{address:re,symbol:"FLR",decimals:18,logoUrl:"https://icons.llamao.fi/icons/chains/rsz_flare?w=48&h=48"},wToken:{symbol:"WFLR",address:"0x1D80c49BbBCd1C0911346656B529DF9E5c2F783d",decimals:18,logoUrl:"https://res.cloudinary.com/sparkdex/image/upload/q_100/v1/website-assets/coins/wflr?_a=DATAg1AAZAA0"},publicRpcUrl:"https://flare.network",logoUrl:"https://icons.llamao.fi/icons/chains/rsz_flare?w=48&h=48",explorer:"https://flarescan.com",eip1559:!0},cronosZkEvm:{id:388,name:"Cronos zkEVM",shortname:"cronosZkEvm",native:{address:"0x000000000000000000000000000000000000800a",symbol:"zkCRO",decimals:18,logoUrl:"https://cryptologos.cc/logos/cronos-cro-logo.png"},wToken:{symbol:"wzkCRO",address:"0xC1bF55EE54E16229d9b369a5502Bfe5fC9F20b6d",decimals:18,logoUrl:"https://cryptologos.cc/logos/cronos-cro-logo.png"},publicRpcUrl:"https://rpc.zkevm.cronos.org",logoUrl:"https://cryptologos.cc/logos/cronos-cro-logo.png",explorer:"https://explorer.zkevm.cronos.org",eip1559:!0},katana:{id:747474,name:"Katana",shortname:"katana",native:{address:re,symbol:"ETH",decimals:18,logoUrl:"https://katana.network/assets/katana-logo.svg"},wToken:{symbol:"WETH",address:"0xee7d8bcfb72bc1880d0cf19822eb0a2e6577ab62",decimals:18,logoUrl:"https://katana.network/assets/weth-logo.svg"},publicRpcUrl:"https://rpc.katanarpc.com",logoUrl:"https://katana.network/assets/katana-logo.svg",explorer:"https://explorer.katana.garden",eip1559:!0},bera:{id:80094,name:"Bera",shortname:"bera",native:{address:re,symbol:"BERA",decimals:18,logoUrl:"https://s2.coinmarketcap.com/static/img/coins/128x128/24647.png"},wToken:{symbol:"WBERA",address:"0x6969696969696969696969696969696969696969",decimals:18,logoUrl:"https://berascan.com/token/images/wrappedbera_ofc_64.png"},publicRpcUrl:"wss://rpc.berachain-apis.com",logoUrl:"https://katana.network/assets/katana-logo.svg",explorer:"https://berascan.com",eip1559:!0},monad:{id:143,name:"Monad",shortname:"monad",native:{address:re,symbol:"MONAD",decimals:18,logoUrl:"https://s2.coinmarketcap.com/static/img/coins/128x128/30495.png"},wToken:{symbol:"WMON",address:"0x3bd359c1119da7da1d913d1c4d2b7c461115433a",decimals:18,logoUrl:"https://assets.coingecko.com/coins/images/70784/standard/wmon.png?1766028904"},publicRpcUrl:"https://monad-mainnet.drpc.org",logoUrl:"https://s2.coinmarketcap.com/static/img/coins/128x128/30495.png",explorer:"https://monad.network",eip1559:!0},optimism:{id:10,name:"Optimism",shortname:"optimism",native:{address:re,symbol:"ETH",decimals:18,logoUrl:"https://s2.coinmarketcap.com/static/img/coins/128x128/11840.png"},wToken:{symbol:"WETH",address:"0x4200000000000000000000000000000000000006",decimals:18,logoUrl:"https://s2.coinmarketcap.com/static/img/coins/128x128/2396.png"},publicRpcUrl:"https://optimism.blockscout.com",logoUrl:"https://s2.coinmarketcap.com/static/img/coins/128x128/11840.png",explorer:"https://optimistic.etherscan.io",eip1559:!0},mantle:{id:5e3,name:"Mantle",shortname:"mantle",native:{address:re,symbol:"MNT",decimals:18,logoUrl:"https://s2.coinmarketcap.com/static/img/coins/128x128/27075.png"},wToken:{symbol:"WMNT",address:"0x78c1b0c915c4faa5fffa6cabf0219da63d7f4cb8",decimals:18,logoUrl:"https://s2.coinmarketcap.com/static/img/coins/128x128/27614.png"},publicRpcUrl:"https://rpc.mantle.xyz",logoUrl:"https://s2.coinmarketcap.com/static/img/coins/128x128/27075.png",explorer:"https://mantlescan.xyz",eip1559:!0}},Dn={version:"2.5.3"},Qs="https://order-sink-dev.orbs.network",js="https://order-sink.orbs.network",zs="https://order-sink-v2.orbs.network",On=Dn.version.split(".")[0],xr=e=>{const t=Number(On)>=2;return e?Qs:t?zs:js},In=300*1e3,ln=1440*60*60*1e3,Sr=300*1e3,$s=new Date(In).getMinutes(),kn=e=>`https://hub.orbs.network/api/private/project_cm7nb67z86nyr01z12gs0fxpf/subgraphs/orbs-twap-${e}/prod/gn`,_e="https://hub.orbs.network/api/apikey/subgraphs/id",Vs={[ye.eth.id]:`${_e}/Bf7bvMYcJbDAvYWJmhMpHZ4cpFjqzkhK6GXXEpnPRq6`,[ye.bsc.id]:`${_e}/4NfXEi8rreQsnAr4aJ45RLCKgnjcWX46Lbt9SadiCcz6`,[ye.poly.id]:`${_e}/3PyRPWSvDnMowGbeBy7aNsvUkD5ZuxdXQw2RdJq4NdXi`,[ye.arb.id]:`${_e}/83bpQexEaqBjHaQbKoFTbtvCXuo5RudRkfLgtRUYqo2c`,[ye.base.id]:`${_e}/DFhaPQb3HATXkpsWNZw3gydYHehLBVEDiSk4iBdZJyps`,[ye.sei.id]:`${_e}/5zjzRnURzoddyFSZBw5E5NAM3oBgPq3NasTYbtMk6EL6`,[ye.linea.id]:`${_e}/6VsNPEYfFLPZCqdMMDadoXQjLHWJdjEwiD768GAtb7j6`,[ye.sonic.id]:`${_e}/DtBr6a5vsoDd2oAXdPszcn4gLgrr1XC68Q3AJQKXnNLV`,[ye.ftm.id]:`${_e}/DdRo1pmJkrJC9fjsjEBWnNE1uqrbh7Diz4tVKd7rfupp`,[ye.katana.id]:`${_e}/CGi9sDFMQcnBwF3C3NoCFqnaE34sssbgwPLTwiskSXmW`,[ye.avax.id]:`${_e}/FxZ1vMwE5Xy1qvKvZENUMz4vhW8Sh4vXJf9Vp7o17pTx`,[ye.bera.id]:kn("berachain"),[ye.flare.id]:kn("flare"),[ye.cronosZkEvm.id]:kn("cronos-zkevm")},Gs=["0x0000000000000000000000000000000000000000","0x0000000000000000000000000000000000001010","0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE","0x000000000000000000000000000000000000dEaD","0x000000000000000000000000000000000000800A","0x000000000000000000000000000000000000800a"],Fr="115792089237316195423570985008687907853269984665640564039457584007913129639935",Ae=e=>`${e.name}_${e.chainId}`,Xs={[Ae(z.SushiArb)]:["0x846F2B29ef314bF3D667981b4ffdADc5B858312a","0x08c41f5D1C844061f6D952E25827eeAA576c6536"],[Ae(z.SushiBase)]:["0x846F2B29ef314bF3D667981b4ffdADc5B858312a","0x08c41f5D1C844061f6D952E25827eeAA576c6536"],[Ae(z.SushiEth)]:["0xc55943Fa6509004B2903ED8F8ab7347BfC47D0bA","0x08c41f5D1C844061f6D952E25827eeAA576c6536"],[Ae(z.PancakeSwap)]:["0xb2BAFe188faD927240038cC4FfF2d771d8A58905","0xE2a0c3b9aD19A18c4bBa7fffBe5bC1b0E58Db1CE"],[Ae(z.PancakeSwapArbitrum)]:["0xE20167871dB616DdfFD0Fd870d9bC068C350DD1F","0x807488ADAD033e95C438F998277bE654152594dc"],[Ae(z.PancakeSwapBase)]:["0x10ed1F36e4eBE76E161c9AADDa20BE841bc0082c","0x3A9df3eE209b802D0337383f5abCe3204d623588"],[Ae(z.PancakeSwapLinea)]:["0x3A9df3eE209b802D0337383f5abCe3204d623588"],[Ae(z.QuickSwap)]:["0x26D0ec4Be402BCE03AAa8aAf0CF67e9428ba54eF"],[Ae(z.Thena)]:["0xc2aBC02acd77Bb2407efA22348dA9afC8B375290"],[Ae(z.Lynex)]:["0x72e3e1fD5D2Ee2F1C2Eb695206D490a1D45C3835"],[Ae(z.DragonSwap)]:["0x101e1B65Bb516FB5f4547C80BAe0b51f1b8D7a22"],[Ae(z.SpookySwapSonic)]:["0xAd97B770ad64aE47fc7d64B3bD820dCDbF9ff7DA"],[Ae(z.SpookySwap)]:["0x3924d62219483015f982b160d48c0fa5Fd436Cba"],[Ae(z.SwapX)]:["0xE5012eBDe5e26EE3Ea41992154731a03023CF274"]},Mn={unit:Pe.Minutes,value:$s},Zs="RePermitWitnessTransferFrom",Ys={RePermitWitnessTransferFrom:[{name:"permitted",type:"TokenPermissions"},{name:"spender",type:"address"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"},{name:"witness",type:"Order"}],Exchange:[{name:"adapter",type:"address"},{name:"ref",type:"address"},{name:"share",type:"uint32"},{name:"data",type:"bytes"}],Input:[{name:"token",type:"address"},{name:"amount",type:"uint256"},{name:"maxAmount",type:"uint256"}],Order:[{name:"reactor",type:"address"},{name:"executor",type:"address"},{name:"exchange",type:"Exchange"},{name:"swapper",type:"address"},{name:"nonce",type:"uint256"},{name:"start",type:"uint256"},{name:"deadline",type:"uint256"},{name:"chainid",type:"uint256"},{name:"exclusivity",type:"uint32"},{name:"epoch",type:"uint32"},{name:"slippage",type:"uint32"},{name:"freshness",type:"uint32"},{name:"input",type:"Input"},{name:"output",type:"Output"}],Output:[{name:"token",type:"address"},{name:"limit",type:"uint256"},{name:"triggerLower",type:"uint256"},{name:"triggerUpper",type:"uint256"},{name:"recipient",type:"address"}],TokenPermissions:[{name:"token",type:"address"},{name:"amount",type:"uint256"}]},Js="https://www.orbs.com/dtwap-and-dlimit-faq/",ea="https://www.orbs.com/dtwap-and-dlimit-faq/#dSLTP",ta="https://raw.githubusercontent.com/orbs-network/twap-ui/master/logo/orbslogo.svg",na="https://www.orbs.com/",ra="https://www.orbs.com/dtwap-dlimit-disclaimer";var Yt=(e=>(e.FRESHNESS="freshness",e.MIN_CHUNK_SIZE_USD="minChunkSizeUsd",e.ENV="env",e.DURATION="duration",e.IGNORE_ERRORS="ignore-errors",e))(Yt||{});const sa="-5",aa="10",ia="-10",oa="5";var ca=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,Bn=Math.ceil,De=Math.floor,ve="[BigNumber Error] ",Pr=ve+"Number primitive has more than 15 significant digits: ",Ue=1e14,W=14,_n=9007199254740991,Un=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],et=1e7,le=1e9;function Dr(e){var t,n,r,s=P.prototype={constructor:P,toString:null,valueOf:null},a=new P(1),o=20,d=4,p=-7,f=21,w=-1e7,C=1e7,v=!1,F=1,O=0,I={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},M="0123456789abcdefghijklmnopqrstuvwxyz",_=!0;function P(i,c){var u,A,m,y,T,h,g,b,E=this;if(!(E instanceof P))return new P(i,c);if(c==null){if(i&&i._isBigNumber===!0){E.s=i.s,!i.c||i.e>C?E.c=E.e=null:i.e<w?E.c=[E.e=0]:(E.e=i.e,E.c=i.c.slice());return}if((h=typeof i=="number")&&i*0==0){if(E.s=1/i<0?(i=-i,-1):1,i===~~i){for(y=0,T=i;T>=10;T/=10,y++);y>C?E.c=E.e=null:(E.e=y,E.c=[i]);return}b=String(i)}else{if(!ca.test(b=String(i)))return r(E,b,h);E.s=b.charCodeAt(0)==45?(b=b.slice(1),-1):1}(y=b.indexOf("."))>-1&&(b=b.replace(".","")),(T=b.search(/e/i))>0?(y<0&&(y=T),y+=+b.slice(T+1),b=b.substring(0,T)):y<0&&(y=b.length)}else{if(ne(c,2,M.length,"Base"),c==10&&_)return E=new P(i),Y(E,o+E.e+1,d);if(b=String(i),h=typeof i=="number"){if(i*0!=0)return r(E,b,h,c);if(E.s=1/i<0?(b=b.slice(1),-1):1,P.DEBUG&&b.replace(/^0\.0*|\./,"").length>15)throw Error(Pr+i)}else E.s=b.charCodeAt(0)===45?(b=b.slice(1),-1):1;for(u=M.slice(0,c),y=T=0,g=b.length;T<g;T++)if(u.indexOf(A=b.charAt(T))<0){if(A=="."){if(T>y){y=g;continue}}else if(!m&&(b==b.toUpperCase()&&(b=b.toLowerCase())||b==b.toLowerCase()&&(b=b.toUpperCase()))){m=!0,T=-1,y=0;continue}return r(E,String(i),h,c)}h=!1,b=n(b,c,10,E.s),(y=b.indexOf("."))>-1?b=b.replace(".",""):y=b.length}for(T=0;b.charCodeAt(T)===48;T++);for(g=b.length;b.charCodeAt(--g)===48;);if(b=b.slice(T,++g)){if(g-=T,h&&P.DEBUG&&g>15&&(i>_n||i!==De(i)))throw Error(Pr+E.s*i);if((y=y-T-1)>C)E.c=E.e=null;else if(y<w)E.c=[E.e=0];else{if(E.e=y,E.c=[],T=(y+1)%W,y<0&&(T+=W),T<g){for(T&&E.c.push(+b.slice(0,T)),g-=W;T<g;)E.c.push(+b.slice(T,T+=W));T=W-(b=b.slice(T)).length}else T-=g;for(;T--;b+="0");E.c.push(+b)}}else E.c=[E.e=0]}P.clone=Dr,P.ROUND_UP=0,P.ROUND_DOWN=1,P.ROUND_CEIL=2,P.ROUND_FLOOR=3,P.ROUND_HALF_UP=4,P.ROUND_HALF_DOWN=5,P.ROUND_HALF_EVEN=6,P.ROUND_HALF_CEIL=7,P.ROUND_HALF_FLOOR=8,P.EUCLID=9,P.config=P.set=function(i){var c,u;if(i!=null)if(typeof i=="object"){if(i.hasOwnProperty(c="DECIMAL_PLACES")&&(u=i[c],ne(u,0,le,c),o=u),i.hasOwnProperty(c="ROUNDING_MODE")&&(u=i[c],ne(u,0,8,c),d=u),i.hasOwnProperty(c="EXPONENTIAL_AT")&&(u=i[c],u&&u.pop?(ne(u[0],-le,0,c),ne(u[1],0,le,c),p=u[0],f=u[1]):(ne(u,-le,le,c),p=-(f=u<0?-u:u))),i.hasOwnProperty(c="RANGE"))if(u=i[c],u&&u.pop)ne(u[0],-le,-1,c),ne(u[1],1,le,c),w=u[0],C=u[1];else if(ne(u,-le,le,c),u)w=-(C=u<0?-u:u);else throw Error(ve+c+" cannot be zero: "+u);if(i.hasOwnProperty(c="CRYPTO"))if(u=i[c],u===!!u)if(u)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))v=u;else throw v=!u,Error(ve+"crypto unavailable");else v=u;else throw Error(ve+c+" not true or false: "+u);if(i.hasOwnProperty(c="MODULO_MODE")&&(u=i[c],ne(u,0,9,c),F=u),i.hasOwnProperty(c="POW_PRECISION")&&(u=i[c],ne(u,0,le,c),O=u),i.hasOwnProperty(c="FORMAT"))if(u=i[c],typeof u=="object")I=u;else throw Error(ve+c+" not an object: "+u);if(i.hasOwnProperty(c="ALPHABET"))if(u=i[c],typeof u=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(u))_=u.slice(0,10)=="0123456789",M=u;else throw Error(ve+c+" invalid: "+u)}else throw Error(ve+"Object expected: "+i);return{DECIMAL_PLACES:o,ROUNDING_MODE:d,EXPONENTIAL_AT:[p,f],RANGE:[w,C],CRYPTO:v,MODULO_MODE:F,POW_PRECISION:O,FORMAT:I,ALPHABET:M}},P.isBigNumber=function(i){if(!i||i._isBigNumber!==!0)return!1;if(!P.DEBUG)return!0;var c,u,A=i.c,m=i.e,y=i.s;e:if({}.toString.call(A)=="[object Array]"){if((y===1||y===-1)&&m>=-le&&m<=le&&m===De(m)){if(A[0]===0){if(m===0&&A.length===1)return!0;break e}if(c=(m+1)%W,c<1&&(c+=W),String(A[0]).length==c){for(c=0;c<A.length;c++)if(u=A[c],u<0||u>=Ue||u!==De(u))break e;if(u!==0)return!0}}}else if(A===null&&m===null&&(y===null||y===1||y===-1))return!0;throw Error(ve+"Invalid BigNumber: "+i)},P.maximum=P.max=function(){return U(arguments,-1)},P.minimum=P.min=function(){return U(arguments,1)},P.random=(function(){var i=9007199254740992,c=Math.random()*i&2097151?function(){return De(Math.random()*i)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(u){var A,m,y,T,h,g=0,b=[],E=new P(a);if(u==null?u=o:ne(u,0,le),T=Bn(u/W),v)if(crypto.getRandomValues){for(A=crypto.getRandomValues(new Uint32Array(T*=2));g<T;)h=A[g]*131072+(A[g+1]>>>11),h>=9e15?(m=crypto.getRandomValues(new Uint32Array(2)),A[g]=m[0],A[g+1]=m[1]):(b.push(h%1e14),g+=2);g=T/2}else if(crypto.randomBytes){for(A=crypto.randomBytes(T*=7);g<T;)h=(A[g]&31)*281474976710656+A[g+1]*1099511627776+A[g+2]*4294967296+A[g+3]*16777216+(A[g+4]<<16)+(A[g+5]<<8)+A[g+6],h>=9e15?crypto.randomBytes(7).copy(A,g):(b.push(h%1e14),g+=7);g=T/7}else throw v=!1,Error(ve+"crypto unavailable");if(!v)for(;g<T;)h=c(),h<9e15&&(b[g++]=h%1e14);for(T=b[--g],u%=W,T&&u&&(h=Un[W-u],b[g]=De(T/h)*h);b[g]===0;b.pop(),g--);if(g<0)b=[y=0];else{for(y=-1;b[0]===0;b.splice(0,1),y-=W);for(g=1,h=b[0];h>=10;h/=10,g++);g<W&&(y-=W-g)}return E.e=y,E.c=b,E}})(),P.sum=function(){for(var i=1,c=arguments,u=new P(c[0]);i<c.length;)u=u.plus(c[i++]);return u},n=(function(){var i="0123456789";function c(u,A,m,y){for(var T,h=[0],g,b=0,E=u.length;b<E;){for(g=h.length;g--;h[g]*=A);for(h[0]+=y.indexOf(u.charAt(b++)),T=0;T<h.length;T++)h[T]>m-1&&(h[T+1]==null&&(h[T+1]=0),h[T+1]+=h[T]/m|0,h[T]%=m)}return h.reverse()}return function(u,A,m,y,T){var h,g,b,E,D,R,L,G,ae=u.indexOf("."),de=o,J=d;for(ae>=0&&(E=O,O=0,u=u.replace(".",""),G=new P(A),R=G.pow(u.length-ae),O=E,G.c=c(ze(Ie(R.c),R.e,"0"),10,m,i),G.e=G.c.length),L=c(u,A,m,T?(h=M,i):(h=i,M)),b=E=L.length;L[--E]==0;L.pop());if(!L[0])return h.charAt(0);if(ae<0?--b:(R.c=L,R.e=b,R.s=y,R=t(R,G,de,J,m),L=R.c,D=R.r,b=R.e),g=b+de+1,ae=L[g],E=m/2,D=D||g<0||L[g+1]!=null,D=J<4?(ae!=null||D)&&(J==0||J==(R.s<0?3:2)):ae>E||ae==E&&(J==4||D||J==6&&L[g-1]&1||J==(R.s<0?8:7)),g<1||!L[0])u=D?ze(h.charAt(1),-de,h.charAt(0)):h.charAt(0);else{if(L.length=g,D)for(--m;++L[--g]>m;)L[g]=0,g||(++b,L=[1].concat(L));for(E=L.length;!L[--E];);for(ae=0,u="";ae<=E;u+=h.charAt(L[ae++]));u=ze(u,b,h.charAt(0))}return u}})(),t=(function(){function i(A,m,y){var T,h,g,b,E=0,D=A.length,R=m%et,L=m/et|0;for(A=A.slice();D--;)g=A[D]%et,b=A[D]/et|0,T=L*g+b*R,h=R*g+T%et*et+E,E=(h/y|0)+(T/et|0)+L*b,A[D]=h%y;return E&&(A=[E].concat(A)),A}function c(A,m,y,T){var h,g;if(y!=T)g=y>T?1:-1;else for(h=g=0;h<y;h++)if(A[h]!=m[h]){g=A[h]>m[h]?1:-1;break}return g}function u(A,m,y,T){for(var h=0;y--;)A[y]-=h,h=A[y]<m[y]?1:0,A[y]=h*T+A[y]-m[y];for(;!A[0]&&A.length>1;A.splice(0,1));}return function(A,m,y,T,h){var g,b,E,D,R,L,G,ae,de,J,te,ge,xn,fr,hr,je,un,Be=A.s==m.s?1:-1,we=A.c,ie=m.c;if(!we||!we[0]||!ie||!ie[0])return new P(!A.s||!m.s||(we?ie&&we[0]==ie[0]:!ie)?NaN:we&&we[0]==0||!ie?Be*0:Be/0);for(ae=new P(Be),de=ae.c=[],b=A.e-m.e,Be=y+b+1,h||(h=Ue,b=Oe(A.e/W)-Oe(m.e/W),Be=Be/W|0),E=0;ie[E]==(we[E]||0);E++);if(ie[E]>(we[E]||0)&&b--,Be<0)de.push(1),D=!0;else{for(fr=we.length,je=ie.length,E=0,Be+=2,R=De(h/(ie[0]+1)),R>1&&(ie=i(ie,R,h),we=i(we,R,h),je=ie.length,fr=we.length),xn=je,J=we.slice(0,je),te=J.length;te<je;J[te++]=0);un=ie.slice(),un=[0].concat(un),hr=ie[0],ie[1]>=h/2&&hr++;do{if(R=0,g=c(ie,J,je,te),g<0){if(ge=J[0],je!=te&&(ge=ge*h+(J[1]||0)),R=De(ge/hr),R>1)for(R>=h&&(R=h-1),L=i(ie,R,h),G=L.length,te=J.length;c(L,J,G,te)==1;)R--,u(L,je<G?un:ie,G,h),G=L.length,g=1;else R==0&&(g=R=1),L=ie.slice(),G=L.length;if(G<te&&(L=[0].concat(L)),u(J,L,te,h),te=J.length,g==-1)for(;c(ie,J,je,te)<1;)R++,u(J,je<te?un:ie,te,h),te=J.length}else g===0&&(R++,J=[0]);de[E++]=R,J[0]?J[te++]=we[xn]||0:(J=[we[xn]],te=1)}while((xn++<fr||J[0]!=null)&&Be--);D=J[0]!=null,de[0]||de.splice(0,1)}if(h==Ue){for(E=1,Be=de[0];Be>=10;Be/=10,E++);Y(ae,y+(ae.e=E+b*W-1)+1,T,D)}else ae.e=b,ae.r=+D;return ae}})();function K(i,c,u,A){var m,y,T,h,g;if(u==null?u=d:ne(u,0,8),!i.c)return i.toString();if(m=i.c[0],T=i.e,c==null)g=Ie(i.c),g=A==1||A==2&&(T<=p||T>=f)?fn(g,T):ze(g,T,"0");else if(i=Y(new P(i),c,u),y=i.e,g=Ie(i.c),h=g.length,A==1||A==2&&(c<=y||y<=p)){for(;h<c;g+="0",h++);g=fn(g,y)}else if(c-=T+(A===2&&y>T),g=ze(g,y,"0"),y+1>h){if(--c>0)for(g+=".";c--;g+="0");}else if(c+=y-h,c>0)for(y+1==h&&(g+=".");c--;g+="0");return i.s<0&&m?"-"+g:g}function U(i,c){for(var u,A,m=1,y=new P(i[0]);m<i.length;m++)A=new P(i[m]),(!A.s||(u=mt(y,A))===c||u===0&&y.s===c)&&(y=A);return y}function Z(i,c,u){for(var A=1,m=c.length;!c[--m];c.pop());for(m=c[0];m>=10;m/=10,A++);return(u=A+u*W-1)>C?i.c=i.e=null:u<w?i.c=[i.e=0]:(i.e=u,i.c=c),i}r=(function(){var i=/^(-?)0([xbo])(?=\w[\w.]*$)/i,c=/^([^.]+)\.$/,u=/^\.([^.]+)$/,A=/^-?(Infinity|NaN)$/,m=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(y,T,h,g){var b,E=h?T:T.replace(m,"");if(A.test(E))y.s=isNaN(E)?null:E<0?-1:1;else{if(!h&&(E=E.replace(i,function(D,R,L){return b=(L=L.toLowerCase())=="x"?16:L=="b"?2:8,!g||g==b?R:D}),g&&(b=g,E=E.replace(c,"$1").replace(u,"0.$1")),T!=E))return new P(E,b);if(P.DEBUG)throw Error(ve+"Not a"+(g?" base "+g:"")+" number: "+T);y.s=null}y.c=y.e=null}})();function Y(i,c,u,A){var m,y,T,h,g,b,E,D=i.c,R=Un;if(D){e:{for(m=1,h=D[0];h>=10;h/=10,m++);if(y=c-m,y<0)y+=W,T=c,g=D[b=0],E=De(g/R[m-T-1]%10);else if(b=Bn((y+1)/W),b>=D.length)if(A){for(;D.length<=b;D.push(0));g=E=0,m=1,y%=W,T=y-W+1}else break e;else{for(g=h=D[b],m=1;h>=10;h/=10,m++);y%=W,T=y-W+m,E=T<0?0:De(g/R[m-T-1]%10)}if(A=A||c<0||D[b+1]!=null||(T<0?g:g%R[m-T-1]),A=u<4?(E||A)&&(u==0||u==(i.s<0?3:2)):E>5||E==5&&(u==4||A||u==6&&(y>0?T>0?g/R[m-T]:0:D[b-1])%10&1||u==(i.s<0?8:7)),c<1||!D[0])return D.length=0,A?(c-=i.e+1,D[0]=R[(W-c%W)%W],i.e=-c||0):D[0]=i.e=0,i;if(y==0?(D.length=b,h=1,b--):(D.length=b+1,h=R[W-y],D[b]=T>0?De(g/R[m-T]%R[T])*h:0),A)for(;;)if(b==0){for(y=1,T=D[0];T>=10;T/=10,y++);for(T=D[0]+=h,h=1;T>=10;T/=10,h++);y!=h&&(i.e++,D[0]==Ue&&(D[0]=1));break}else{if(D[b]+=h,D[b]!=Ue)break;D[b--]=0,h=1}for(y=D.length;D[--y]===0;D.pop());}i.e>C?i.c=i.e=null:i.e<w&&(i.c=[i.e=0])}return i}function oe(i){var c,u=i.e;return u===null?i.toString():(c=Ie(i.c),c=u<=p||u>=f?fn(c,u):ze(c,u,"0"),i.s<0?"-"+c:c)}return s.absoluteValue=s.abs=function(){var i=new P(this);return i.s<0&&(i.s=1),i},s.comparedTo=function(i,c){return mt(this,new P(i,c))},s.decimalPlaces=s.dp=function(i,c){var u,A,m,y=this;if(i!=null)return ne(i,0,le),c==null?c=d:ne(c,0,8),Y(new P(y),i+y.e+1,c);if(!(u=y.c))return null;if(A=((m=u.length-1)-Oe(this.e/W))*W,m=u[m])for(;m%10==0;m/=10,A--);return A<0&&(A=0),A},s.dividedBy=s.div=function(i,c){return t(this,new P(i,c),o,d)},s.dividedToIntegerBy=s.idiv=function(i,c){return t(this,new P(i,c),0,1)},s.exponentiatedBy=s.pow=function(i,c){var u,A,m,y,T,h,g,b,E,D=this;if(i=new P(i),i.c&&!i.isInteger())throw Error(ve+"Exponent not an integer: "+oe(i));if(c!=null&&(c=new P(c)),h=i.e>14,!D.c||!D.c[0]||D.c[0]==1&&!D.e&&D.c.length==1||!i.c||!i.c[0])return E=new P(Math.pow(+oe(D),h?i.s*(2-pn(i)):+oe(i))),c?E.mod(c):E;if(g=i.s<0,c){if(c.c?!c.c[0]:!c.s)return new P(NaN);A=!g&&D.isInteger()&&c.isInteger(),A&&(D=D.mod(c))}else{if(i.e>9&&(D.e>0||D.e<-1||(D.e==0?D.c[0]>1||h&&D.c[1]>=24e7:D.c[0]<8e13||h&&D.c[0]<=9999975e7)))return y=D.s<0&&pn(i)?-0:0,D.e>-1&&(y=1/y),new P(g?1/y:y);O&&(y=Bn(O/W+2))}for(h?(u=new P(.5),g&&(i.s=1),b=pn(i)):(m=Math.abs(+oe(i)),b=m%2),E=new P(a);;){if(b){if(E=E.times(D),!E.c)break;y?E.c.length>y&&(E.c.length=y):A&&(E=E.mod(c))}if(m){if(m=De(m/2),m===0)break;b=m%2}else if(i=i.times(u),Y(i,i.e+1,1),i.e>14)b=pn(i);else{if(m=+oe(i),m===0)break;b=m%2}D=D.times(D),y?D.c&&D.c.length>y&&(D.c.length=y):A&&(D=D.mod(c))}return A?E:(g&&(E=a.div(E)),c?E.mod(c):y?Y(E,O,d,T):E)},s.integerValue=function(i){var c=new P(this);return i==null?i=d:ne(i,0,8),Y(c,c.e+1,i)},s.isEqualTo=s.eq=function(i,c){return mt(this,new P(i,c))===0},s.isFinite=function(){return!!this.c},s.isGreaterThan=s.gt=function(i,c){return mt(this,new P(i,c))>0},s.isGreaterThanOrEqualTo=s.gte=function(i,c){return(c=mt(this,new P(i,c)))===1||c===0},s.isInteger=function(){return!!this.c&&Oe(this.e/W)>this.c.length-2},s.isLessThan=s.lt=function(i,c){return mt(this,new P(i,c))<0},s.isLessThanOrEqualTo=s.lte=function(i,c){return(c=mt(this,new P(i,c)))===-1||c===0},s.isNaN=function(){return!this.s},s.isNegative=function(){return this.s<0},s.isPositive=function(){return this.s>0},s.isZero=function(){return!!this.c&&this.c[0]==0},s.minus=function(i,c){var u,A,m,y,T=this,h=T.s;if(i=new P(i,c),c=i.s,!h||!c)return new P(NaN);if(h!=c)return i.s=-c,T.plus(i);var g=T.e/W,b=i.e/W,E=T.c,D=i.c;if(!g||!b){if(!E||!D)return E?(i.s=-c,i):new P(D?T:NaN);if(!E[0]||!D[0])return D[0]?(i.s=-c,i):new P(E[0]?T:d==3?-0:0)}if(g=Oe(g),b=Oe(b),E=E.slice(),h=g-b){for((y=h<0)?(h=-h,m=E):(b=g,m=D),m.reverse(),c=h;c--;m.push(0));m.reverse()}else for(A=(y=(h=E.length)<(c=D.length))?h:c,h=c=0;c<A;c++)if(E[c]!=D[c]){y=E[c]<D[c];break}if(y&&(m=E,E=D,D=m,i.s=-i.s),c=(A=D.length)-(u=E.length),c>0)for(;c--;E[u++]=0);for(c=Ue-1;A>h;){if(E[--A]<D[A]){for(u=A;u&&!E[--u];E[u]=c);--E[u],E[A]+=Ue}E[A]-=D[A]}for(;E[0]==0;E.splice(0,1),--b);return E[0]?Z(i,E,b):(i.s=d==3?-1:1,i.c=[i.e=0],i)},s.modulo=s.mod=function(i,c){var u,A,m=this;return i=new P(i,c),!m.c||!i.s||i.c&&!i.c[0]?new P(NaN):!i.c||m.c&&!m.c[0]?new P(m):(F==9?(A=i.s,i.s=1,u=t(m,i,0,3),i.s=A,u.s*=A):u=t(m,i,0,F),i=m.minus(u.times(i)),!i.c[0]&&F==1&&(i.s=m.s),i)},s.multipliedBy=s.times=function(i,c){var u,A,m,y,T,h,g,b,E,D,R,L,G,ae,de,J=this,te=J.c,ge=(i=new P(i,c)).c;if(!te||!ge||!te[0]||!ge[0])return!J.s||!i.s||te&&!te[0]&&!ge||ge&&!ge[0]&&!te?i.c=i.e=i.s=null:(i.s*=J.s,!te||!ge?i.c=i.e=null:(i.c=[0],i.e=0)),i;for(A=Oe(J.e/W)+Oe(i.e/W),i.s*=J.s,g=te.length,D=ge.length,g<D&&(G=te,te=ge,ge=G,m=g,g=D,D=m),m=g+D,G=[];m--;G.push(0));for(ae=Ue,de=et,m=D;--m>=0;){for(u=0,R=ge[m]%de,L=ge[m]/de|0,T=g,y=m+T;y>m;)b=te[--T]%de,E=te[T]/de|0,h=L*b+E*R,b=R*b+h%de*de+G[y]+u,u=(b/ae|0)+(h/de|0)+L*E,G[y--]=b%ae;G[y]=u}return u?++A:G.splice(0,1),Z(i,G,A)},s.negated=function(){var i=new P(this);return i.s=-i.s||null,i},s.plus=function(i,c){var u,A=this,m=A.s;if(i=new P(i,c),c=i.s,!m||!c)return new P(NaN);if(m!=c)return i.s=-c,A.minus(i);var y=A.e/W,T=i.e/W,h=A.c,g=i.c;if(!y||!T){if(!h||!g)return new P(m/0);if(!h[0]||!g[0])return g[0]?i:new P(h[0]?A:m*0)}if(y=Oe(y),T=Oe(T),h=h.slice(),m=y-T){for(m>0?(T=y,u=g):(m=-m,u=h),u.reverse();m--;u.push(0));u.reverse()}for(m=h.length,c=g.length,m-c<0&&(u=g,g=h,h=u,c=m),m=0;c;)m=(h[--c]=h[c]+g[c]+m)/Ue|0,h[c]=Ue===h[c]?0:h[c]%Ue;return m&&(h=[m].concat(h),++T),Z(i,h,T)},s.precision=s.sd=function(i,c){var u,A,m,y=this;if(i!=null&&i!==!!i)return ne(i,1,le),c==null?c=d:ne(c,0,8),Y(new P(y),i,c);if(!(u=y.c))return null;if(m=u.length-1,A=m*W+1,m=u[m]){for(;m%10==0;m/=10,A--);for(m=u[0];m>=10;m/=10,A++);}return i&&y.e+1>A&&(A=y.e+1),A},s.shiftedBy=function(i){return ne(i,-_n,_n),this.times("1e"+i)},s.squareRoot=s.sqrt=function(){var i,c,u,A,m,y=this,T=y.c,h=y.s,g=y.e,b=o+4,E=new P("0.5");if(h!==1||!T||!T[0])return new P(!h||h<0&&(!T||T[0])?NaN:T?y:1/0);if(h=Math.sqrt(+oe(y)),h==0||h==1/0?(c=Ie(T),(c.length+g)%2==0&&(c+="0"),h=Math.sqrt(+c),g=Oe((g+1)/2)-(g<0||g%2),h==1/0?c="5e"+g:(c=h.toExponential(),c=c.slice(0,c.indexOf("e")+1)+g),u=new P(c)):u=new P(h+""),u.c[0]){for(g=u.e,h=g+b,h<3&&(h=0);;)if(m=u,u=E.times(m.plus(t(y,m,b,1))),Ie(m.c).slice(0,h)===(c=Ie(u.c)).slice(0,h))if(u.e<g&&--h,c=c.slice(h-3,h+1),c=="9999"||!A&&c=="4999"){if(!A&&(Y(m,m.e+o+2,0),m.times(m).eq(y))){u=m;break}b+=4,h+=4,A=1}else{(!+c||!+c.slice(1)&&c.charAt(0)=="5")&&(Y(u,u.e+o+2,1),i=!u.times(u).eq(y));break}}return Y(u,u.e+o+1,d,i)},s.toExponential=function(i,c){return i!=null&&(ne(i,0,le),i++),K(this,i,c,1)},s.toFixed=function(i,c){return i!=null&&(ne(i,0,le),i=i+this.e+1),K(this,i,c)},s.toFormat=function(i,c,u){var A,m=this;if(u==null)i!=null&&c&&typeof c=="object"?(u=c,c=null):i&&typeof i=="object"?(u=i,i=c=null):u=I;else if(typeof u!="object")throw Error(ve+"Argument not an object: "+u);if(A=m.toFixed(i,c),m.c){var y,T=A.split("."),h=+u.groupSize,g=+u.secondaryGroupSize,b=u.groupSeparator||"",E=T[0],D=T[1],R=m.s<0,L=R?E.slice(1):E,G=L.length;if(g&&(y=h,h=g,g=y,G-=y),h>0&&G>0){for(y=G%h||h,E=L.substr(0,y);y<G;y+=h)E+=b+L.substr(y,h);g>0&&(E+=b+L.slice(y)),R&&(E="-"+E)}A=D?E+(u.decimalSeparator||"")+((g=+u.fractionGroupSize)?D.replace(new RegExp("\\d{"+g+"}\\B","g"),"$&"+(u.fractionGroupSeparator||"")):D):E}return(u.prefix||"")+A+(u.suffix||"")},s.toFraction=function(i){var c,u,A,m,y,T,h,g,b,E,D,R,L=this,G=L.c;if(i!=null&&(h=new P(i),!h.isInteger()&&(h.c||h.s!==1)||h.lt(a)))throw Error(ve+"Argument "+(h.isInteger()?"out of range: ":"not an integer: ")+oe(h));if(!G)return new P(L);for(c=new P(a),b=u=new P(a),A=g=new P(a),R=Ie(G),y=c.e=R.length-L.e-1,c.c[0]=Un[(T=y%W)<0?W+T:T],i=!i||h.comparedTo(c)>0?y>0?c:b:h,T=C,C=1/0,h=new P(R),g.c[0]=0;E=t(h,c,0,1),m=u.plus(E.times(A)),m.comparedTo(i)!=1;)u=A,A=m,b=g.plus(E.times(m=b)),g=m,c=h.minus(E.times(m=c)),h=m;return m=t(i.minus(u),A,0,1),g=g.plus(m.times(b)),u=u.plus(m.times(A)),g.s=b.s=L.s,y=y*2,D=t(b,A,y,d).minus(L).abs().comparedTo(t(g,u,y,d).minus(L).abs())<1?[b,A]:[g,u],C=T,D},s.toNumber=function(){return+oe(this)},s.toPrecision=function(i,c){return i!=null&&ne(i,1,le),K(this,i,c,2)},s.toString=function(i){var c,u=this,A=u.s,m=u.e;return m===null?A?(c="Infinity",A<0&&(c="-"+c)):c="NaN":(i==null?c=m<=p||m>=f?fn(Ie(u.c),m):ze(Ie(u.c),m,"0"):i===10&&_?(u=Y(new P(u),o+m+1,d),c=ze(Ie(u.c),u.e,"0")):(ne(i,2,M.length,"Base"),c=n(ze(Ie(u.c),m,"0"),10,i,A,!0)),A<0&&u.c[0]&&(c="-"+c)),c},s.valueOf=s.toJSON=function(){return oe(this)},s._isBigNumber=!0,s[Symbol.toStringTag]="BigNumber",s[Symbol.for("nodejs.util.inspect.custom")]=s.valueOf,e!=null&&P.set(e),P}function Oe(e){var t=e|0;return e>0||e===t?t:t-1}function Ie(e){for(var t,n,r=1,s=e.length,a=e[0]+"";r<s;){for(t=e[r++]+"",n=W-t.length;n--;t="0"+t);a+=t}for(s=a.length;a.charCodeAt(--s)===48;);return a.slice(0,s+1||1)}function mt(e,t){var n,r,s=e.c,a=t.c,o=e.s,d=t.s,p=e.e,f=t.e;if(!o||!d)return null;if(n=s&&!s[0],r=a&&!a[0],n||r)return n?r?0:-d:o;if(o!=d)return o;if(n=o<0,r=p==f,!s||!a)return r?0:!s^n?1:-1;if(!r)return p>f^n?1:-1;for(d=(p=s.length)<(f=a.length)?p:f,o=0;o<d;o++)if(s[o]!=a[o])return s[o]>a[o]^n?1:-1;return p==f?0:p>f^n?1:-1}function ne(e,t,n,r){if(e<t||e>n||e!==De(e))throw Error(ve+(r||"Argument")+(typeof e=="number"?e<t||e>n?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function pn(e){var t=e.c.length-1;return Oe(e.e/W)==t&&e.c[t]%2!=0}function fn(e,t){return(e.length>1?e.charAt(0)+"."+e.slice(1):e)+(t<0?"e":"e+")+t}function ze(e,t,n){var r,s;if(t<0){for(s=n+".";++t;s+=n);e=s+e}else if(r=e.length,++t>r){for(s=n,t-=r;--t;s+=n);e+=s}else t<r&&(e=e.slice(0,t)+"."+e.slice(t));return e}var x=Dr();function ua(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}const da={1:{adapter:{"odos-v2":"0x1ae80D14C52F82c09a54C423e6f9D5Fb737089C8",sushi:"0x11985E88847aEC23D1C3BCD77Ca0F4A704aB751c"},dex:{sushiswap:{type:"default",solver:"sushi",router:"0xAC4c6e212A361c968F1725b4d055b47E63F80b75",adapter:"0x2e43A28FAf083717CcD9B246d97C61E1Bc9914Df",fee:"0x28F6C9dBE21fFc146Af8d5D15c49Cf48F61140Dc"},agent:{type:"default",solver:"odos-v2",router:"0xCf5540fFFCdC3d510B18bFcA6d2b9987b0772559",adapter:"0xC1bB4d5071Fe7109ae2D67AE05826A3fe9116cfc",fee:"0x03A70aC8126340d3cd6b5828816172693C398661"}}},10:{adapter:{"odos-v2":"0xc7Ec90152fd5A6210570cb04C4Ab099Bdac352af"},dex:{agent:{type:"default",solver:"odos-v2",router:"0xCa423977156BB05b13A2BA3b76Bc5419E2fE9680",adapter:"0xC5Aea83Fdd94A19fB2ce0B7207939C52825D3D3B",fee:"0x03A70aC8126340d3cd6b5828816172693C398661"}}},14:{adapter:{spark:"0x00c7617C471Ef69124464CEc318a3b8CC90aE9A7"},dex:{spark:{type:"default",solver:"spark",router:"0x0f3D8a38D4c74afBebc2c42695642f0e3acb15D3",adapter:"0x00c7617C471Ef69124464CEc318a3b8CC90aE9A7",fee:"0xaeA8C3e1a129A77686E115b1a46D9aD8405F7D2b"}}},56:{adapter:{"odos-v2":"0x6c17cc2984A87BD8b002c6E3C08dBB8c8Eb89E48","pancakeswap-v2":"0xaf3532dca7b4a75cD06671614C093e9e8fb5b1F2"},dex:{thena:{type:"default",solver:"odos-v2",router:"0x89b8AA89FDd0507a99d334CBe3C808fAFC7d850E",adapter:"0x9E61dEabe996236814c28eC69ab2A7405cB6f03E",fee:"0x15eBc8b5b3877512FFF23650188694A9a8891FAc"},pancake:{type:"p2",solver:"pancakeswap-v2",router:"0xd9C500DfF816a1Da21A48A732d3498Bf09dc9AEB",permit2:"0x31c2F6fcFf4F8759b3Bd5Bf0e1084A055615c768",adapter:"0x52Ed96B1AEd25818B6A284b063b055488E012b73",fee:"0x37A957f10F458e0d7fDECBE2917971b57F15c927"},newera:{type:"default",solver:"odos-v2",router:"0x89b8AA89FDd0507a99d334CBe3C808fAFC7d850E",adapter:"0x6236a466CE5c368DC6686d69cAcf5561196B76ef",fee:"0x4E7454909eB6D539111D56b50d68897E933D2d11"},agent:{type:"default",solver:"odos-v2",router:"0x89b8AA89FDd0507a99d334CBe3C808fAFC7d850E",adapter:"0x67Feba015c968c76cCB2EEabf197b4578640BE2C",fee:"0x03A70aC8126340d3cd6b5828816172693C398661"}}},137:{adapter:{"odos-v2":"0x5628D7383b42E14E83DA310de3e7E04E6b025418","paraswap-v5":"0x179C4b8e982b5F1365d36CC8d0c1CEB621B7198D"},dex:{quick:{type:"paraswap",solver:"paraswap-v5",router:"0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57",adapter:"0x727e1CbA41Ff1ff11C32fa43DAb499b4317A1b65",fee:"0xd207DC6a6dA88f27c8DB78201F974161b1d84b1f"},teafi:{type:"paraswap",solver:"paraswap-v5",router:"0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57",adapter:"0xF710D67C783D2C14671EC1c61B0683DCb996F5c3",fee:"0x04Ff96e2c4D62b5771795d307AD679a25b3D2D50"},agent:{type:"default",solver:"odos-v2",router:"0x4E3288c9ca110bCC82bf38F09A7b425c095d92Bf",adapter:"0x75A3d70Fa6d054d31C896b9Cf8AB06b1c1B829B8",fee:"0x03A70aC8126340d3cd6b5828816172693C398661"}}},143:{adapter:{"openocean-v2":"0xc7f07C830e22FCA94bF52F38C6707F9D396c6172","kyber-v2":"0x6f4e5b8d7F6b037c62277992c39E7834D7C04596"},dex:{yowie:{type:"default",solver:"openocean-v2",router:"0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",adapter:"0xCA84Ab5a5A5bf2cff6AC0C835eF049365D13c6cB",fee:"0x6AF3eE77A3A3257777F5649aFa611b4C7Fd975Ef"},pangolin:{type:"default",solver:"kyber-v2",router:"0x6131B5fae19EA4f9D964eAc0408E4408b66337b5",adapter:"0xf42106eBf985bF49b39eba0114F57FA05e7B52eD",fee:"0xde92da99D188Ceb54A11ec711EF52D808A6260B5"}}},146:{adapter:{"odos-v2":"0x0123695379045f9db515E6a77d8154959B94B599","magpie-v3":"0xa5AB087b39dAf175650EFB4F7B8E977C1585a662","openocean-v2":"0xc7f07C830e22FCA94bF52F38C6707F9D396c6172"},dex:{spooky:{type:"default",solver:"magpie-v3",router:"0xc325856e5585823aaC0D1Fd46c35c608D95E65A9",adapter:"0x56083Eb47d4d7d520F4d2b4a0DC98BE56bb98068",fee:"0x840Df4684B35BC68BcdA3F6707A3c82A0D662f8b"},swapx:{type:"default",solver:"openocean-v2",router:"0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",adapter:"0xa7AE3ABf86C81cCEFEd6bE77045F2a32660c1B1c",fee:"0x6E03f7BC0f141894612AA017796096399623895F"},shadow:{type:"default",solver:"magpie-v3",router:"0xc325856e5585823aaC0D1Fd46c35c608D95E65A9",adapter:"0x1adEE94aBa11F19981130F77a1B2620b67e4409A",fee:"0xb9e3751fAF3187E1bC468E56a707a8A91754460e"},agent:{type:"default",solver:"openocean-v2",router:"0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",adapter:"0xD87ee28806bc0060789C4789F123647f4Df25A6C",fee:"0x03A70aC8126340d3cd6b5828816172693C398661"}}},1329:{adapter:{dragon:"0x1e84A9f30607959d2d8b1a04171ef7D9522Ef502","openocean-v2":"0xc7f07C830e22FCA94bF52F38C6707F9D396c6172"},dex:{dragon:{type:"default",solver:"dragon",router:"0x11DA6463D6Cb5a03411Dbf5ab6f6bc3997Ac7428",adapter:"0x1e84A9f30607959d2d8b1a04171ef7D9522Ef502",fee:"0x0dc1E0525202b32e89bA78ed55b1e5cEdB751334"},nami:{type:"default",solver:"openocean-v2",router:"0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",adapter:"0xba56F9A7865d430c8293851D576b5728Ca711ff5",fee:"0xeB58450e23632003f013568703F54446070E2E80"}}},5e3:{adapter:{"odos-v2":"0x3a0fA0f95ea07026c5f84D8d3444Dd6E15AE1874"},dex:{agent:{type:"default",solver:"odos-v2",router:"0xD9F4e85489aDCD0bAF0Cd63b4231c6af58c26745",adapter:"0x9571D46B5A5AAb749E5aCd698D8F20814C7B23D3",fee:"0x03A70aC8126340d3cd6b5828816172693C398661"}}},8453:{adapter:{"odos-v2":"0x1c947387AFC3435135e3da51ccEAB20eD5377DeA","pancakeswap-v2":"0x917b492557957f5dD3e69c04c8E1Ac3d6948c022","kyber-v2":"0x6f4e5b8d7F6b037c62277992c39E7834D7C04596",trebleswap:"0x6f4938535879c668A797F2a6e9B912c54f9D43Cf",sushi:"0x11985E88847aEC23D1C3BCD77Ca0F4A704aB751c"},dex:{pancake:{type:"p2",solver:"pancakeswap-v2",router:"0xFE6508f0015C778Bdcc1fB5465bA5ebE224C9912",permit2:"0x31c2F6fcFf4F8759b3Bd5Bf0e1084A055615c768",adapter:"0xA7CcB11F1D20D1F915FC220F5Cb1646E4523bB75",fee:"0x37A957f10F458e0d7fDECBE2917971b57F15c927"},quick:{type:"default",solver:"kyber-v2",router:"0x6131B5fae19EA4f9D964eAc0408E4408b66337b5",adapter:"0x0438644898F69bfF1018Cb01a81877D14d3e6493",fee:"0xd207DC6a6dA88f27c8DB78201F974161b1d84b1f"},trebleswap:{type:"default",solver:"trebleswap",router:"0x347539D82A14C0A3a89769f1024774A545a151ac",adapter:"0x6f4938535879c668A797F2a6e9B912c54f9D43Cf",fee:"0x15fc883d7DF4e681Ddb9E43e7B1D8c61d4fC162C"},sushiswap:{type:"default",solver:"sushi",router:"0xAC4c6e212A361c968F1725b4d055b47E63F80b75",adapter:"0x2e43A28FAf083717CcD9B246d97C61E1Bc9914Df",fee:"0x28F6C9dBE21fFc146Af8d5D15c49Cf48F61140Dc"},agent:{type:"default",solver:"kyber-v2",router:"0x6131B5fae19EA4f9D964eAc0408E4408b66337b5",adapter:"0xc64d6E64A713EfbbCcB14413479c56461F9c0b77",fee:"0x03A70aC8126340d3cd6b5828816172693C398661"}}},42161:{adapter:{"odos-v2":"0x419faf03F5661e0F0471eF9D7935f09534ffc50F","paraswap-v5":"0x179C4b8e982b5F1365d36CC8d0c1CEB621B7198D","pancakeswap-v2":"0x917b492557957f5dD3e69c04c8E1Ac3d6948c022",sushi:"0x11985E88847aEC23D1C3BCD77Ca0F4A704aB751c"},dex:{arbidex:{type:"default",solver:"odos-v2",router:"0xa669e7A0d4b3e4Fa48af2dE86BD4CD7126Be4e13",adapter:"0xaA66173674F4331e7e672899B3E6aB1190450898",fee:"0xa0c11852f8A44e32F9EC10AD25986A53842f72Ca"},ramses:{type:"paraswap",solver:"paraswap-v5",router:"0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57",adapter:"0xf075352f43cd15bA51B0957A4465223EDf6b4Cd8",fee:"0xB5BaCB60ECDa0bEF809B2A26eC9B4B926835D7af"},omni:{type:"paraswap",solver:"paraswap-v5",router:"0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57",adapter:"0x41c925E8E4fC65136BDf5322824E0D8c20c4824e",fee:"0xba5291526c30B097E9F1Fd1Be301E2ab6E0782aa"},chronos:{type:"default",solver:"odos-v2",router:"0x19cEeAd7105607Cd444F5ad10dd51356436095a1",adapter:"0x6a6b8975d1b131EFd0a9b536766EE7E5d4a16CF2",fee:"0x5729af83240EFecAa18eafaAE82961c2DD045Dbe"},pancake:{type:"p2",solver:"pancakeswap-v2",router:"0xFE6508f0015C778Bdcc1fB5465bA5ebE224C9912",permit2:"0x31c2F6fcFf4F8759b3Bd5Bf0e1084A055615c768",adapter:"0xA7CcB11F1D20D1F915FC220F5Cb1646E4523bB75",fee:"0x37A957f10F458e0d7fDECBE2917971b57F15c927"},sushiswap:{type:"default",solver:"sushi",router:"0xAC4c6e212A361c968F1725b4d055b47E63F80b75",adapter:"0x2e43A28FAf083717CcD9B246d97C61E1Bc9914Df",fee:"0x28F6C9dBE21fFc146Af8d5D15c49Cf48F61140Dc"},agent:{type:"paraswap",solver:"paraswap-v5",router:"0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57",adapter:"0x6F1002141Fcb5d3A3aA8b12A49e6e7DCE5661ae9",fee:"0x03A70aC8126340d3cd6b5828816172693C398661"}}},43114:{adapter:{"odos-v2":"0x533dA659Ef4C2C1d4c98420e1dbe9C68D8538f50","kyber-v2":"0x6f4e5b8d7F6b037c62277992c39E7834D7C04596"},dex:{blackhole:{type:"default",solver:"kyber-v2",router:"0x6131B5fae19EA4f9D964eAc0408E4408b66337b5",adapter:"0xccdF1D6ce95FeC0F842197470CE8969A678B0A04",fee:"0x7f8B62520D9B5DA0ED517cc36e8dcb2a356f1928"},pangolin:{type:"default",solver:"kyber-v2",router:"0x6131B5fae19EA4f9D964eAc0408E4408b66337b5",adapter:"0xf42106eBf985bF49b39eba0114F57FA05e7B52eD",fee:"0xde92da99D188Ceb54A11ec711EF52D808A6260B5"},agent:{type:"default",solver:"kyber-v2",router:"0x6131B5fae19EA4f9D964eAc0408E4408b66337b5",adapter:"0xc64d6E64A713EfbbCcB14413479c56461F9c0b77",fee:"0x03A70aC8126340d3cd6b5828816172693C398661"}}},59144:{adapter:{"odos-v2":"0xA58A55AC39b47504A63993A91B78544158862e61","pancakeswap-v2":"0x917b492557957f5dD3e69c04c8E1Ac3d6948c022",openocean:"0xd2e68b1d1C5DBB2D6cC396c10C55017e01309C37"},dex:{pancake:{type:"p2",solver:"pancakeswap-v2",router:"0xFE6508f0015C778Bdcc1fB5465bA5ebE224C9912",permit2:"0x31c2F6fcFf4F8759b3Bd5Bf0e1084A055615c768",adapter:"0xA7CcB11F1D20D1F915FC220F5Cb1646E4523bB75",fee:"0x37A957f10F458e0d7fDECBE2917971b57F15c927"},lynex:{type:"default",solver:"openocean",router:"0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",adapter:"0xd8bC1FF79a642e8D7Fbd0711374F287202fBb3AA",fee:"0xcb36ed1B1BfAD8F7FC9651f52d21f04A68677423"},agent:{type:"default",solver:"odos-v2",router:"0x2d8879046f1559E53eb052E949e9544bCB72f414",adapter:"0x55E4da2cd634729064bEb294EC682Dc94f5c3f24",fee:"0x03A70aC8126340d3cd6b5828816172693C398661"}}},80094:{adapter:{kodiak:"0xcB16237c88A859d46Ae850B97d7D1bdECF482C06"},dex:{kodiak:{type:"default",solver:"kodiak",router:"0x43Dac637c4383f91B4368041E7A8687da3806Cae",adapter:"0xcB16237c88A859d46Ae850B97d7D1bdECF482C06",fee:"0xBA47Ec15aFbCF6e7e9F52900632049530bB6bAe4"}}},747474:{adapter:{sushi:"0x11985E88847aEC23D1C3BCD77Ca0F4A704aB751c"},dex:{sushiswap:{type:"default",solver:"sushi",router:"0xAC4c6e212A361c968F1725b4d055b47E63F80b75",adapter:"0x2e43A28FAf083717CcD9B246d97C61E1Bc9914Df",fee:"0x28F6C9dBE21fFc146Af8d5D15c49Cf48F61140Dc"}}},"*":{wm:"0x0005d5cE0dB57e5BE3b2b8b6FeB75f0ccd015000",repermit:"0x00002a9C4D9497df5Bd31768eC5d30eEf5405000",cosigner:"0x000ECFa392ecDEfEE6e2a5C095d39B7A32f1E000",reactor:"0x000000b33fE4fB9d999Dd684F79b110731c3d000",executor:"0x000642A0966d9bd49870D9519f76b5cf823f3000",refinery:"0x000E474c0D7084EAA35A501035E73269f4b009A5",salt:{wm:"0xc9b46eae42dfeba3222a0315bf682f33cd5cc9d60c9625642e88406f8415f152",repermit:"0x4871dc9008e605821ea9677b65ea2a60ffb774afb31e0dcaea2e192880096be7",cosigner:"0x1117fe6f4e25c9380d10b2b3314a1e9b33e5f65ba0e55e0c63d0640db0dd60a2",reactor:"0xec73677f3a465a9755d4c9eab9509b59a24613fdb8b78719682930373e9876f5",executor:"0x9abc67d936f79e493f1f14050c2f6adb87ec208ff7aaae2e7ae788a7cb4796d7",refinery:"0x9746de29f1dd31b2c8460d71e92a7aefa34911130e61f274f37776e598c48bec",agentAdapter:"0xf6d54cf6a0619f1fb8e1ded91d4c23e7bb9f498c56735fb0c7669423c766219f",agentFee:"0x151234279af18acc113f70463977058efa2e598b5bfc0c106c75fd638d344c0a"},dex:{agent:{type:"universal",adapter:"0x0002BeFB46587d460AcEA9B2792c4A4c67B9cADa",fee:"0x0006d9557Ac9Af4f31962896299ba4FaBDaB9fEE"}}}};var Rn,Or;function la(){if(Or)return Rn;Or=1;const e=da,t=s=>ua(`./out/${s}.sol/${s}.abi.json`),n=()=>({wm:t("WM"),repermit:t("RePermit"),reactor:t("OrderReactor"),executor:t("Executor"),refinery:t("Refinery"),settler:t("Settler"),adapter:t("DefaultDexAdapter")});function r(s,a){if(!s)return;const{dex:o,salt:d,...p}=e["*"]??{},f=e[s];if(!f)return;const{dex:w,salt:C,...v}=f,F={...p,...v},O=a==null?void 0:a.trim();if(!O)return F;const I=o==null?void 0:o[O],M=w==null?void 0:w[O];if(!(!I&&!M))return{...F,...I,...M}}return Rn={config:r,abis:n,raw:e},Rn}var Ir=la();const _t=(e,t)=>{if(!e||!t)return"";const n=x(10).pow(e||0);return x(t).times(n).idiv(n).div(n).toFixed()};x(0),x(1),x(10),x(1e18);function yt(e,t){return e==t||e.toLowerCase()==t.toLowerCase()}const Ut=e=>!!Gs.find(t=>yt(t,e||""));function pa(e){return[Pe.Years,Pe.Months,Pe.Weeks,Pe.Days,Pe.Hours,Pe.Minutes].find(n=>n<=e)||Pe.Minutes}const gt=e=>e?e.value*e.unit:0,fa=e=>!e||e==="NaN"?"0":x(e).decimalPlaces(0).toFixed(),At=e=>Object.values(ye).find(t=>t.id===e),ha=e=>{if(!e)return;const t=e.map(a=>Ae(a)),n=Object.entries(Xs).filter(([a])=>t.includes(a)).flatMap(([,a])=>a),r=e.map(a=>a.exchangeAddress),s=new Set([...r,...n].map(a=>a.toLowerCase()));return Array.from(s)},Ln=(e,t)=>e.version===1?(e.fillDelay||0)*1e3+Ta(t):(e.fillDelay||0)*1e3,hn=e=>typeof window>"u"?null:new URLSearchParams(window.location.search).get(e),kr=e=>_r().filter(t=>t.name===e).map(t=>t.chainId),Nn=(e="",t="",n=18,r=18)=>{if(!x(e||0).gt(0)||!x(t||0).gt(0))return"";const s=_t(n,e),a=_t(r,t);return x(a).div(s).toFixed()},Mr=(e,t,n)=>{if(e.type===V.TWAP_MARKET)return"";const r=_t(t,e.srcAmountPerTrade),s=_t(n,e.dstMinAmountPerTrade);return x(s).div(r).toFixed()},Br=(e,t,n)=>{if(e.type===V.TWAP_MARKET)return"";const r=_t(t,e.srcAmountPerTrade),s=_t(n,e.triggerPricePerTrade);return x(s).div(r).toFixed()},ma=(e,t,n)=>{if(!e||!t||!n)return;const r=x(e).times(t),s=x(10).pow(n);return r.div(s).toFixed(0)},ya=(e,t,n,r)=>{if(n||!r||!e||!t)return x(0).toString();const s=x(e).times(x(t)),a=x(10).pow(r),o=s.div(a);return x.max(1,o).integerValue(x.ROUND_FLOOR).toFixed(0)},ga=(e,t,n,r)=>{if(e===$.TWAP||e===$.LIMIT)return"0";if(!r||!t||!n)return;const s=x(t).times(x(n)),a=x(10).pow(r),o=s.div(a);return x.max(1,o).integerValue(x.ROUND_FLOOR).toFixed(0)||"0"},Aa=(e,t,n,r)=>{const s=gt(n)*2*t,a=hn(Yt.DURATION),o=pa(a?Number(a):s);return a?{unit:o,value:Number(x(Number(a)/o).toFixed(2))}:r||(e===$.LIMIT?{unit:Pe.Days,value:7}:e===$.STOP_LOSS||e===$.TAKE_PROFIT?{unit:Pe.Days,value:1}:{unit:o,value:Number(x(s/o).toFixed(2))})},Ea=(e,t,n)=>t!==$.TWAP?1:n!==void 0?n:Math.max(1,Math.ceil(e/2)),ba=(e,t,n)=>{if(!e||!t||!n)return 1;const s=x(t).times(e).div(n).integerValue(x.ROUND_FLOOR).toNumber();return Math.max(1,s)},Ca=(e,t)=>e+gt(t)+6e4,Ta=e=>e.bidDelaySeconds*1e3*2,wa=(e="",t=0)=>!e||!t?"0":x(e).div(t).integerValue(x.ROUND_FLOOR).toFixed(0),va=(e,t)=>({isError:!(e.unit===Mn.unit&&e.value===Mn.value)&>(e)*t>ln,value:Math.floor(ln/t)}),xa=(e="",t="",n)=>{if(n===$.STOP_LOSS)return{isError:x(t||0).gte(x(e||0)),value:e}},Sa=(e="",t="",n)=>{if(n===$.TAKE_PROFIT)return{isError:x(t||0).lte(x(e||0)),value:e}},Fa=(e="",t="",n=!1,r)=>{if(!n&&r===$.STOP_LOSS)return{isError:x(t||0).gte(x(e||0)),value:e}},Pa=(e="",t="",n=!1,r)=>{if(!n&&r===$.TAKE_PROFIT)return{isError:x(t||0).gte(x(e||0)),value:e}},Da=(e,t)=>e===$.STOP_LOSS||e===$.TAKE_PROFIT?{isError:gt(t)>5184e6,value:5184e6}:{isError:gt(t)>ln,value:ln},Oa=e=>({isError:gt(e)<Sr,value:Sr}),Ia=e=>({isError:gt(e)<In,value:In}),ka=(e,t,n)=>({isError:x(t||0).multipliedBy(e||0).isLessThan(n),value:n}),Ma=(e,t,n)=>({isError:n===$.TWAP&&x(e).isGreaterThan(t),value:t}),Ba=(e,t)=>{if(e===Ne.Pancake)switch(t){case 56:return z.PancakeSwap;case 42161:return z.PancakeSwapArbitrum;case 8453:return z.PancakeSwapBase;case 59144:return z.PancakeSwapLinea;default:return z.PancakeSwap}if(e===Ne.Sushiswap)switch(t){case 1:return z.SushiEth;case 42161:return z.SushiArb;case 8453:return z.SushiBase;case 747474:return z.SushiKatana;default:return z.SushiEth}if(e===Ne.Quick)switch(t){case 137:return z.QuickSwap;case 8453:return z.QuickSwapBase;default:return z.QuickSwap}if(e===Ne.Thena)switch(t){case 56:return z.Thena;default:return z.Thena}if(e===Ne.Spooky)switch(t){case 250:return z.SpookySwap;case 146:return z.SpookySwapSonic;default:return z.SpookySwap}if(e===Ne.Lynex)switch(t){case 59144:return z.Lynex;default:return z.Lynex}if(e===Ne.Swapx)switch(t){case 146:return z.SwapX;default:return z.SwapX}if(e===Ne.Blackhole)switch(t){case 43114:return z.BlackholeAvax;default:return z.BlackholeAvax}},qn=(e,t=0)=>{const{abi:n,...r}=Ir.config(t,e);if(!r.reactor)throw new Error(`Missing config for partner "${e}" on chain ${t}: reactor address not found`);return{...r,partner:e,twapConfig:Ba(e,t)}},_r=()=>{const e=Ir.raw;return Object.entries(e).filter(([t])=>t!=="*").flatMap(([t,n])=>{const r=n==null?void 0:n.dex;return!r||typeof r!="object"?[]:Object.entries(r).map(([s])=>({chainId:Number(t),name:s,config:qn(s,Number(t))}))}).sort((t,n)=>t.name.localeCompare(n.name))},Ur=e=>{const t=hn(Yt.MIN_CHUNK_SIZE_USD);return t?parseInt(t):e},_a=({marketPrice:e,typedInputAmount:t,srcUsd1Token:n,marketPriceLoading:r,triggerPriceError:s,limitPriceError:a,tradesError:o,fillDelayError:d,durationError:p,balanceError:f,minTradeSizeError:w})=>{if(!hn(Yt.IGNORE_ERRORS)&&!(x(e||0).isZero()||x(t||0).isZero()||x(n||"0").isZero()||r))return w||s||a||o||d||p||f},Ua=(e,t)=>{const n=Date.now().toString(),r=parseInt((e/1e3).toFixed(0)),s=fa(t/1e3),a=hn(Yt.FRESHNESS),o=a?parseInt(a):60;return{nonce:n,epoch:r,deadline:s,freshness:o}},Rr=({chainId:e,srcToken:t,dstToken:n,srcAmount:r,deadlineMillis:s,fillDelayMillis:a,slippage:o,account:d,srcAmountPerTrade:p,dstMinAmountPerTrade:f="0",triggerAmountPerTrade:w="0",config:C,module:v})=>{const{nonce:F,epoch:O,deadline:I,freshness:M}=Ua(a,s),_=Math.floor(Date.now()/1e3).toString(),P=f,K=v===$.STOP_LOSS?w:"0",U=v===$.TAKE_PROFIT?w:"0",Z={permitted:{token:t,amount:r},spender:C.reactor,nonce:F,deadline:I,witness:{reactor:C.reactor,executor:C.executor,exchange:{adapter:C.adapter,ref:C.fee,share:0,data:"0x"},swapper:d,nonce:F,start:_,deadline:I,chainid:e,exclusivity:0,epoch:O,slippage:o,freshness:M,input:{token:t,amount:p,maxAmount:r},output:{token:n,limit:x(P||0).toFixed(),triggerLower:x(K||0).toFixed(),triggerUpper:x(U||0).toFixed(),recipient:d}}};return{domain:{name:"RePermit",version:"1",chainId:e,verifyingContract:C.repermit},order:Z,types:Ys,primaryType:Zs}},Ra=`https://bi.orbs.network/putes/twap-ui-${.7}`;let Kn="unknown";function La(e){Kn=e}function Hn(){const e=Math.random().toString(36).substring(2,16),t=Math.random().toString(36).substring(2,16),n=Date.now().toString(36);return`id_${e+t+n}`}const Na=(e,t,n)=>{var r,s,a,o,d,p,f,w,C;return{spotVersion:Dn.version,partner:e.partner,adapter:e.adapter,cosigner:e.cosigner,executor:e.executor,fee:e.fee,reactor:e.reactor,refinery:e.refinery,repermit:e.repermit,router:e.router,type:e.type,wm:e.wm,chainName:((r=e.twapConfig)==null?void 0:r.chainName)||"",chainId:n||0,twapVersion:((s=e.twapConfig)==null?void 0:s.twapVersion)||0,twapAddress:((a=e.twapConfig)==null?void 0:a.twapAddress)||"",lensAddress:((o=e.twapConfig)==null?void 0:o.lensAddress)||"",bidDelaySeconds:((d=e.twapConfig)==null?void 0:d.bidDelaySeconds)||0,minChunkSizeUsd:t,name:((p=e.twapConfig)==null?void 0:p.name)||"",exchangeAddress:((f=e.twapConfig)==null?void 0:f.exchangeAddress)||"",exchangeType:((w=e.twapConfig)==null?void 0:w.exchangeType)||"",pathfinderKey:((C=e.twapConfig)==null?void 0:C.pathfinderKey)||""}},Lr=async e=>{try{await fetch(Ra,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(e)}).then()}catch(t){console.error("Failed to send BI",t)}};class qa{constructor(){Sn(this,"timeout");Sn(this,"config");Sn(this,"data",{_id:Hn()})}async updateAndSend(t={},n=!1,r){try{this.data={...this.data,...t},n?(await Lr(this.data),r==null||r()):(clearTimeout(this.timeout),this.timeout=setTimeout(()=>{Lr(this.data),r==null||r()},1e3))}catch(s){console.error("Failed to update and send BI",s)}}onCancelOrderRequest(t,n){this.updateAndSend({cancelOrderIdsV1:n===1?t:void 0,cancelOrderIdsV2:n===2?t:void 0,action:"cancel order",cancelOrderSuccess:!1,cancelOrderTxHash:void 0,actionError:void 0})}onCancelOrderSuccess(t){this.updateAndSend({cancelOrderTxHash:t,cancelOrderSuccess:!0})}onCancelOrderError(t){this.onTxError(t)}onWrapSuccess(t){this.updateAndSend({wrapTxHash:t})}onWrapRequest(){this.updateAndSend({action:"wrap"})}onWrapError(t){this.onTxError(t)}onApproveRequest(){this.updateAndSend({action:"approve"})}onApproveSuccess(t){this.updateAndSend({approvalTxHash:t})}onApproveError(t){this.onTxError(t)}onCrash(t){var n;this.updateAndSend({action:"crash",actionError:((n=t==null?void 0:t.message)==null?void 0:n.toLowerCase())||(t==null?void 0:t.toLowerCase())})}onTxError(t){var r;const n=((r=t==null?void 0:t.message)==null?void 0:r.toLowerCase())||(t==null?void 0:t.toLowerCase());this.updateAndSend({actionError:n})}onRequestOrder({account:t,chainId:n,module:r,srcToken:s,dstToken:a,fromTokenAmount:o,srcChunkAmount:d,minDstAmountOutPerTrade:p="",triggerPricePerTrade:f="",deadline:w,fillDelay:C,slippage:v,isMarketOrder:F,chunksAmount:O}){this.updateAndSend({toTokenAddress:a.address,toTokenSymbol:a.symbol,fromTokenAddress:s.address,fromTokenSymbol:s.symbol,fromTokenAmount:o,chunksAmount:O,srcChunkAmount:d,minDstAmountOutPerTrade:p,triggerPricePerTrade:f,deadline:w,fillDelay:C,slippage:v,chainId:n,walletAddress:t,module:r,orderType:F?"market":"limit",actionError:void 0})}onSignOrderRequest(t){this.updateAndSend({action:"sign order",order:t})}onSignOrderError(t){this.onTxError(t)}onSignOrderSuccess(t){this.updateAndSend({action:"sign order",signature:t})}init(t,n,r){var s;this.config=t,r!==((s=this.data)==null?void 0:s.chainId)&&(this.data={_id:Hn(),action:"module-import",uiVersion:Kn,...Na(t,n,r),origin:window.location.origin},this.updateAndSend(this.data))}onCreateOrderError(t){this.onTxError(t)}onCreateOrderRequest(){this.updateAndSend({action:"create order"})}async onCreateOrderSuccess(t){this.updateAndSend({orderHash:t,orderSuccess:!0},void 0,()=>{this.data={_id:Hn(),action:"reset",uiVersion:Kn,origin:this.data.origin,spotVersion:Dn.version,partner:this.data.partner,adapter:this.data.adapter,cosigner:this.data.cosigner,executor:this.data.executor,fee:this.data.fee,reactor:this.data.reactor,refinery:this.data.refinery,repermit:this.data.repermit,router:this.data.router,type:this.data.type,wm:this.data.wm,chainName:this.data.chainName||"",chainId:this.data.chainId||0,twapVersion:this.data.twapVersion||0,twapAddress:this.data.twapAddress||"",lensAddress:this.data.lensAddress||"",bidDelaySeconds:this.data.bidDelaySeconds||0,minChunkSizeUsd:this.data.minChunkSizeUsd||0,name:this.data.name||"",exchangeAddress:this.data.exchangeAddress||"",exchangeType:this.data.exchangeType||"",pathfinderKey:this.data.pathfinderKey||""}})}onLoad(){this.updateAndSend({action:"module-import",origin:window.location.origin})}}const pe=new qa,Ka=e=>{var d;const t=x(e.order.witness.output.limit||0).gt(1),n=e.order.witness.output.stop,r=e.order.witness.output.triggerUpper,s=x(n||0).eq(Fr)||x(r||0).gt(0),a=x(n||0).gt(0),o=((d=e.metadata.chunks)==null?void 0:d.length)||x(e.order.witness.input.maxAmount).div(x(e.order.witness.input.amount)).toNumber();return s?t?V.TAKE_PROFIT_LIMIT:V.TAKE_PROFIT_MARKET:a?t?V.STOP_LOSS_LIMIT:V.STOP_LOSS_MARKET:t?o>1&&t?V.TWAP_LIMIT:t?V.LIMIT:V.TWAP_MARKET:V.TWAP_MARKET},Ha=e=>{var s;const t=((s=e.metadata.chunks)==null?void 0:s.filter(a=>a.status==="success").length)||0,n=e.metadata.expectedChunks||0,r=x(t).dividedBy(n).toNumber();return r>=.99?100:r<=0?0:Number((r*100).toFixed(2))},Wa=(e,t)=>e.metadata.status==="completed"||t>=99?he.Completed:["pending","eligible"].includes(e.metadata.status)?he.Open:e.metadata.description.toLowerCase()==="cancelled by contract"?he.Cancelled:he.Expired,Qa=e=>{var n;return(((n=e.metadata.chunks)==null?void 0:n.filter(r=>r.status==="success"))||[]).map(r=>({inAmount:r.inAmount,outAmount:r.outAmount,timestamp:new Date(r.timestamp).getTime(),txHash:r.txHash}))},ja=(e,t)=>{var r;const n=e.length;return n>=t&&((r=e[n-1])==null?void 0:r.timestamp)||0},za=e=>x(e.metadata.displayOnlyInputTokenPriceUSD).dividedBy(1e18).toFixed(),Wn=e=>Number(e.order.witness.output.limit)===1?"":e.order.witness.output.limit,$a=e=>{const{triggerLower:t="0",triggerUpper:n="0"}=e.order.witness.output,r=Wn(e),s=e.metadata.expectedChunks||1,a=x(n||0).gt(0);return{dstMinAmountPerTrade:r,triggerPricePerTrade:a?n:t,dstMinAmountTotal:x(r).multipliedBy(s).toFixed()}},Va=e=>{const t=Wn(e),n=x(e.order.witness.output.stop||0).eq(Fr),r=e.metadata.expectedChunks||1;return{dstMinAmountPerTrade:n?"":t,triggerPricePerTrade:n?t:x(e.order.witness.output.stop||"").toFixed(),dstMinAmountTotal:n?"":x(t).multipliedBy(r).toFixed()}},Ga=e=>Number(On)>=2?$a(e):Va(e),Nr=e=>{const t=Ha(e),n=Wn(e),r=e.metadata.expectedChunks||1,s=Qa(e),a=Ka(e);return{id:e.hash,hash:e.hash,version:2,type:a,maker:e.order.witness.swapper,progress:t,srcAmountFilled:s.reduce((o,d)=>o.plus(d.inAmount),new x(0)).toFixed()||"",dstAmountFilled:s.reduce((o,d)=>o.plus(d.outAmount),new x(0)).toFixed()||"",fills:s,srcTokenAddress:e.order.witness.input.token,dstTokenAddress:e.order.witness.output.token,orderDollarValueIn:za(e),fillDelay:e.order.witness.epoch*1e3,deadline:Number(e.order.deadline)*1e3,createdAt:new Date(e.timestamp).getTime(),srcAmount:e.order.witness.input.maxAmount,srcAmountPerTrade:e.order.witness.input.amount,totalTradesAmount:r,isMarketPrice:x(n||0).lte(1),chainId:e.order.witness.chainid,filledOrderTimestamp:ja(s,r),status:Wa(e,t),repermitDigest:e.metadata.repermitDigest,isTriggerPrice:a===V.TAKE_PROFIT_MARKET||a===V.TAKE_PROFIT_LIMIT||a===V.STOP_LOSS_LIMIT||a===V.STOP_LOSS_MARKET,rawOrder:e,...Ga(e)}},Xa=async({chainId:e,signal:t,account:n,exchange:r,isDev:s=!1})=>{try{if(!n)return[];const a=r?`&exchange=${r}`:"",d=await(await fetch(`${xr(s)}/orders?swapper=${n}&chainId=${e}${a}`,{signal:t})).json();return!d||!Array.isArray(d.orders)?[]:(console.log(d.orders),d.orders.map(Nr))}catch{return[]}},qr=async(e,t,n=!1)=>{try{const r={signature:t,order:e,status:"pending"};pe.onCreateOrderRequest();const s=await fetch(`${xr(n)}/orders/new`,{method:"POST",body:JSON.stringify(r)}),a=await s.json().catch(()=>({}));if(!s.ok||!(a!=null&&a.success)){const d=(a==null?void 0:a.message)??s.statusText??"Request failed",p=(a==null?void 0:a.code)??s.status;throw new Error(`error:${d}, code:${p}`)}if(!a.signedOrder||typeof a.signedOrder!="object")throw new Error("Invalid API response: missing signedOrder");const o=Nr(a.signedOrder);return pe.onCreateOrderSuccess(o.id),o}catch(r){throw pe.onCreateOrderError(r),console.error(r),r}},$e=(e,t)=>e&&e.length?e.map(t||(n=>`${n}`)):void 0,Za=e=>{if(e)return Vs[e]},Qn=async({chainId:e,buildQuery:t,extractResults:n,signal:r,retries:s=1,limit:a=1e3,page:o})=>{const d=Za(e);if(!d)throw new ri;const p=async C=>{let v=0;for(;v<=s;)try{const F=await fetch(d,{method:"POST",body:JSON.stringify({query:C}),signal:r,headers:{"Content-Type":"application/json"}});if(!F.ok)throw new Error(`HTTP error: ${F.status}`);const O=await F.json();if(O.errors)throw new Error(O.errors[0].message);return n(O)}catch(F){if(v===s)throw F;await new Promise(O=>setTimeout(O,500*2**v)),v++}return[]};let f=0;const w=[];if(o!==void 0){const C=t(o,a);try{return await p(C)}catch{console.warn(`Page ${o} failed, retrying one final time...`);try{return await p(C)}catch{return[]}}}for(;;){const C=t(f,a);let v;try{v=await p(C)}catch{console.warn(`Page ${f} failed, retrying one final time...`);try{v=await p(C)}catch{return w}}if(w.push(...v),v.length<a)break;f++}return w},Kr=e=>e.map(t=>({inAmount:t.srcAmountIn,outAmount:t.dstAmountOut,timestamp:t.timestamp,txHash:t.transactionHash})),Hr=(e,t)=>{const n=x(e||0).gt(1);return!n&&t===1?V.TWAP_MARKET:t>1&&n?V.TWAP_LIMIT:n?V.LIMIT:V.TWAP_MARKET},Ya=(e,t,n,r)=>{var v;const s=Kr(n||[]),a=new x(e.ask_srcAmount||0).div(e.ask_srcBidAmount).integerValue(x.ROUND_FLOOR).toNumber(),d=(n==null?void 0:n.length)===a?(v=n==null?void 0:n[(n==null?void 0:n.length)-1])==null?void 0:v.timestamp:void 0,p=s.reduce((F,O)=>F.plus(O.inAmount),new x(0)).toFixed(),f=s.reduce((F,O)=>F.plus(O.outAmount),new x(0)).toFixed(),w=Wr(e.ask_srcAmount,p),C=Hr(e.ask_dstMinAmount,a);return{repermitDigest:"",version:1,isTriggerPrice:!1,id:e.Contract_id.toString(),hash:"",type:Hr(e.ask_dstMinAmount,a),srcTokenAddress:e.ask_srcToken,dstTokenAddress:e.ask_dstToken,exchangeAddress:e.exchange,twapAddress:e.twapAddress,maker:e.maker,progress:w,dstAmountFilled:f,srcAmountFilled:p,orderDollarValueIn:x(e.dollarValueIn||0).toFixed(6),srcAmount:e.ask_srcAmount,dstMinAmountTotal:x(e.ask_dstMinAmount).multipliedBy(a).toString(),fills:s,fillDelay:e.ask_fillDelay,deadline:e.ask_deadline*1e3,createdAt:new Date(e.timestamp).getTime(),dstMinAmountPerTrade:x(e.ask_dstMinAmount).eq(1)?"":e.ask_dstMinAmount,triggerPricePerTrade:"",srcAmountPerTrade:e.ask_srcBidAmount,txHash:e.transactionHash,totalTradesAmount:a,isMarketPrice:[V.TWAP_MARKET].includes(C),chainId:t,filledOrderTimestamp:d||0,status:r,rawOrder:e}},Ja=e=>{var C;if(!e)return"";const t=$e(e.accounts,v=>`"${v.toLowerCase()}"`),n=$e(ha(e.configs),v=>`"${v.toLowerCase()}"`),r=$e(e.inTokenSymbols,v=>`"${v.toUpperCase()}"`),s=$e(e.outTokenSymbols,v=>`"${v.toUpperCase()}"`),a=$e(e.inTokenAddresses,v=>`"${v.toLowerCase()}"`),o=$e(e.outTokenAddresses,v=>`"${v.toLowerCase()}"`),d=$e(e.transactionHashes,v=>`"${v.toLowerCase()}"`),p=$e(e.orderIds,v=>`"${v}"`),f=n!=null&&n.length?"":$e((C=e.configs)==null?void 0:C.map(v=>v.twapAddress),v=>`"${v.toLowerCase()}"`),w=e.minDollarValueIn;return[n?`exchange_in: [${n.join(", ")}]`:"",f?`twapAddress_in: [${f.join(", ")}]`:"",t?`maker_in: [${t.join(", ")}]`:"",d?`transactionHash_in: [${d.join(", ")}]`:"",p?`Contract_id_in: [${p.join(", ")}]`:"",w?`dollarValueIn_gte: ${w}`:"",r?`srcTokenSymbol_in: [${r.join(", ")}]`:"",s?`dstTokenSymbol_in: [${s.join(", ")}]`:"",a?`srcTokenAddress_in: [${a.join(", ")}]`:"",o?`dstTokenAddress_in: [${o.join(", ")}]`:"",e!=null&&e.startDate?`blockTimestamp_gte: ${e.startDate}`:"",e!=null&&e.endDate?`blockTimestamp_lte: ${e.endDate}`:"",(e==null?void 0:e.orderType)==="limit"?"ask_dstMinAmount_gt: 1":"",(e==null?void 0:e.orderType)==="market"?"ask_dstMinAmount_lte: 1":""].filter(Boolean).join(", ")};async function ei({chainId:e,signal:t,page:n,limit:r,filters:s}){const a=r||1e3,o=Ja(s);return await Qn({chainId:e,signal:t,limit:a,page:n,buildQuery:(p,f)=>`
|
|
2
2
|
{
|
|
3
3
|
orderCreateds(
|
|
4
4
|
${o?`where: { ${o} }`:""},
|
|
5
|
-
first: ${
|
|
6
|
-
skip: ${p*
|
|
5
|
+
first: ${f},
|
|
6
|
+
skip: ${p*f},
|
|
7
7
|
orderBy: timestamp,
|
|
8
8
|
orderDirection: desc,
|
|
9
9
|
) {
|
|
@@ -32,21 +32,21 @@
|
|
|
32
32
|
transactionHash
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
|
-
`,extractResults:p=>{var
|
|
35
|
+
`,extractResults:p=>{var f;return((f=p.data)==null?void 0:f.orderCreateds)||[]}})}const ti=async({chainId:e,orders:t,signal:n})=>{if(t.length===0)return[];const r=jn(t.map(d=>d.Contract_id.toString()));if(!r.length)return[];const a=`where: { twapId_in: [${r.map(d=>`"${d}"`).join(", ")}]}`;return await Qn({chainId:e,signal:n,limit:1e3,buildQuery:(d,p)=>`
|
|
36
36
|
{
|
|
37
37
|
statusNews(
|
|
38
38
|
first: ${p},
|
|
39
39
|
skip: ${d*p},
|
|
40
|
-
${
|
|
40
|
+
${a}
|
|
41
41
|
) {
|
|
42
42
|
twapId
|
|
43
43
|
twapAddress
|
|
44
44
|
status
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
-
`,extractResults:d=>{var p;return((p=d.data)==null?void 0:p.statusNews)||[]}})};function
|
|
47
|
+
`,extractResults:d=>{var p;return((p=d.data)==null?void 0:p.statusNews)||[]}})};function jn(e){return Array.from(new Set(e))}const ni=async({chainId:e,orders:t,signal:n})=>{const r=jn(t.map(C=>C.Contract_id)),s=jn(t.map(C=>C.twapAddress)).filter(Boolean);if(r.length===0)return[];const a=r.join(", "),o=s.map(C=>`"${C}"`).join(", "),d=s.length?`twapAddress_in: [${o}]`:"",f=`where: { ${[`TWAP_id_in: [${a}]`,d].filter(Boolean).join(", ")} }`;return await Qn({chainId:e,signal:n,limit:1e3,buildQuery:(C,v)=>`
|
|
48
48
|
{
|
|
49
|
-
orderFilleds(first: ${
|
|
49
|
+
orderFilleds(first: ${v}, orderBy: timestamp, skip: ${C*v}, ${f}) {
|
|
50
50
|
id
|
|
51
51
|
dstAmountOut
|
|
52
52
|
dstFee
|
|
@@ -61,4 +61,4 @@
|
|
|
61
61
|
dollarValueOut
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
|
-
`,extractResults:E=>{var x;return(((x=E.data)==null?void 0:x.orderFilleds)||[]).map(P=>({...P,timestamp:new Date(P.timestamp).getTime()}))}})};class aa extends Error{constructor(){super("No graph endpoint found"),this.name="NoGraphEndpointError"}}const oa=async({chainId:e,signal:t,page:n,limit:r,filters:s})=>{try{const i=await ra({chainId:e,signal:t,page:n,limit:r,filters:s}),[o,d]=await Promise.all([ia({chainId:e,orders:i,signal:t}),sa({chainId:e,orders:i,signal:t})]),p=i.map(C=>{const E=o==null?void 0:o.filter(x=>x.TWAP_id===Number(C.Contract_id)&&yt(x.exchange,C.exchange)&&yt(x.twapAddress,C.twapAddress));return ta(C,e,E,ua(C,E||[],d))}).sort((C,E)=>E.createdAt-C.createdAt),h=new Set;return p.filter(C=>h.has(C.id)?!1:(h.add(C.id),!0))}catch{return[]}},ua=(e,t,n)=>{var d;const r=(d=n==null?void 0:n.find(p=>p.twapId===e.Contract_id.toString()&&yt(p.twapAddress,e.twapAddress)))==null?void 0:d.status,i=Wr(t).reduce((p,h)=>p.plus(h.inAmount),new S(0)).toFixed(),o=jr(e.ask_srcAmount,i);return ca(o,e.ask_deadline*1e3,r)},jr=(e,t)=>{if(!t||!e)return 0;const n=S(t).dividedBy(e).toNumber();return n>=.99?100:n<=0?0:Number((n*100).toFixed(2))},ca=(e,t,n)=>e===100?fe.Completed:n==="CANCELLED"?fe.Cancelled:n==="COMPLETED"?fe.Completed:t>Date.now()?fe.Open:fe.Expired,da=async({signal:e,page:t,chainId:n,limit:r,config:s,account:i,isDev:o=!1})=>(await Promise.all([s?oa({chainId:n,signal:e,page:t,limit:r,filters:{accounts:[i],configs:s.twapConfig?[s.twapConfig]:[]}}):Promise.resolve([]),Ji({chainId:n,signal:e,account:i,exchange:s==null?void 0:s.adapter,isDev:o})]).then(([h,C])=>[...h,...C])).sort((h,C)=>C.createdAt-h.createdAt),la={version:"1.1.24"},zr=e=>{let t;const n=new Set,r=(h,C)=>{const E=typeof h=="function"?h(t):h;if(!Object.is(E,t)){const x=t;t=C??(typeof E!="object"||E===null)?E:Object.assign({},t,E),n.forEach(P=>P(t,x))}},s=()=>t,d={setState:r,getState:s,getInitialState:()=>p,subscribe:h=>(n.add(h),()=>n.delete(h))},p=t=e(r,s,d);return d},pa=(e=>e?zr(e):zr),ha=e=>e;function fa(e,t=ha){const n=v.useSyncExternalStore(e.subscribe,v.useCallback(()=>t(e.getState()),[e,t]),v.useCallback(()=>t(e.getInitialState()),[e,t]));return v.useDebugValue(n),n}const $r=e=>{const t=pa(e),n=r=>fa(t,r);return Object.assign(n,t),n},ma=(e=>e?$r(e):$r),yn={},Vr={currentTime:Date.now(),cancelOrders:{},swapExecutions:[yn],swapExecutionIndex:0},Q=ma((e,t)=>({state:Vr,updateState:n=>e(r=>({state:{...r.state,...n}})),updateSwapExecutionAtIndex:(n,r)=>e(s=>{const i=[...s.state.swapExecutions];return i[n]={...i[n]??yn,...r},{state:{...s.state,swapExecutions:i}}}),resetSwapExecutionAtIndex:()=>e(n=>{const r=[...n.state.swapExecutions];return r[n.state.swapExecutionIndex]=yn,{state:{...n.state,swapExecutions:r}}}),resetState:()=>{const n=t().state;e({state:{...Vr,currentTime:Date.now(),isMarketOrder:n.isMarketOrder,swapExecutions:[...n.swapExecutions,yn],swapExecutionIndex:n.swapExecutionIndex+1}})}}));var Se=(e=>(e[e.LOADING=1]="LOADING",e[e.SUCCESS=2]="SUCCESS",e[e.FAILED=3]="FAILED",e))(Se||{}),Jt=(e=>(e.TRIGGER_MARKET_PRICE="triggerMarketPriceDisclaimer",e.MARKET_PRICE="marketOrderDisclaimer",e.LIMIT_PRICE="limitOrderDisclaimer",e))(Jt||{}),tt=(e=>(e.WRAP="wrap",e.APPROVE="approve",e.CREATE="create",e))(tt||{});const Et=(e,t)=>!t||!e||S(e).isNaN()?"":S(e).multipliedBy(S(10).pow(t)).toFixed(0),Ee=(e,t)=>{try{return!t||!e||S(e).isNaN()?"":S(e).dividedBy(S(10).pow(t)).toFixed()}catch(n){return console.error(n),""}},ya=e=>{const t="An error occurred.";if(!e||!e.message)return t;try{return e.message.toLowerCase().includes("rejected")?"Transaction Rejected":t}catch{return t}},$n=e=>{var t,n,r,s;if(e!=null&&e.message)return((n=(t=e.message)==null?void 0:t.toLowerCase())==null?void 0:n.includes("rejected"))||((s=(r=e.message)==null?void 0:r.toLowerCase())==null?void 0:s.includes("denied"))},Gr=(e,t)=>{const n=At(t);return n&&Ut(e.address)?n.wToken:e};function Xr(e){return e?e/864e5:0}function Zr(e){return e?e/6e4:0}const ga=(e,t)=>e?V.TWAP_MARKET:t===1?V.LIMIT:V.TWAP_LIMIT,Vn=(e,t,n)=>{const r=At(n);return Ut((e==null?void 0:e.address)||"")&&yt((t==null?void 0:t.address)||"",(r==null?void 0:r.wToken.address)||"")},Gn=(e,t,n)=>{const r=At(n);return yt((e==null?void 0:e.address)||"",(r==null?void 0:r.wToken.address)||"")&&Ut((t==null?void 0:t.address)||"")},Rt=(e,t)=>{if(!t)return"";const n=At(t);return`${n==null?void 0:n.explorer}/tx/${e}`},Xn=(e,t)=>v.useMemo(()=>Et(t,e),[e,t]),en=(e,t)=>v.useMemo(()=>Ee(t,e),[e,t]),gn=()=>{const{chainId:e}=q();return v.useMemo(()=>At(e),[e])},Aa=e=>{const t=gn();return v.useMemo(()=>{if(!(!e||!t))return Rt(e,t.id)},[e,t])},nt=(e,t)=>v.useMemo(()=>!e||!t||S(e||"0").isZero()||S(t||"0").isZero()?"":S(e||"0").times(t).toFixed(),[e,t]),Ea=()=>{const{srcToken:e,dstToken:t,chainId:n}=q();return v.useMemo(()=>Vn(e,t,n),[e,t,n])},ba=()=>{const{srcToken:e,dstToken:t,chainId:n}=q();return v.useMemo(()=>Gn(e,t,n),[e,t,n])},Ta=()=>{const e=Ea(),t=ba();return e||t},rt=()=>{const{srcToken:e,typedInputAmount:t}=q();return{amount:Xn(e==null?void 0:e.decimals,t),amountUI:t,error:S(t||0).isZero()?"enterAmount":void 0}},wa=(e,t)=>{const{module:n,srcUsd1Token:r,marketPrice:s,minChunkSizeUsd:i,typedInputAmount:o}=q();return v.useMemo(()=>{if(S(o||"0").isZero()||!s||S(r||"0").isZero())return;if(!e)return{type:me.MIN_CHUNKS,value:1,args:{minChunks:"1"}};const{isError:d}=Bi(e,t,n);if(d)return{type:me.MAX_CHUNKS,value:t,args:{maxChunks:`${t}`}};const{isError:p,value:h}=_i(o||"",r||"",i||0);if(p)return{type:me.MIN_TRADE_SIZE,value:h,args:{minTradeSize:`${h}`}}},[e,t,n,o,r,i,s])},qe=()=>{const{srcToken:e,srcUsd1Token:t,module:n,minChunkSizeUsd:r}=q(),s=Q(I=>I.state.typedChunks),i=Q(I=>I.updateState),{amount:o,amountUI:d}=rt(),p=v.useMemo(()=>wi(d||"",t||"",r||0),[d,t,r]),h=v.useMemo(()=>Ti(p,n,s),[p,s,n]),C=v.useCallback(I=>i({typedChunks:I}),[i]),E=v.useMemo(()=>Si(o||"",h),[o,h]),x=en(e==null?void 0:e.decimals,E),P=v.useMemo(()=>t?S(x||"0").times(t||0).toString():"0",[x,t]);return{totalTrades:h,maxTrades:p,amountPerTradeUI:x,amountPerTrade:E,amountPerTradeUsd:P,onChange:C,error:wa(h,p)}},Ca=()=>{const{srcToken:e,dstToken:t}=q(),{onChange:n,totalTrades:r,amountPerTradeUsd:s,amountPerTradeUI:i,error:o,maxTrades:d,amountPerTrade:p}=qe();return{error:o,maxTrades:d,totalTrades:r,amountPerTradeUI:i,amountPerTrade:p,onChange:n,amountPerTradeUsd:s,fromToken:e,toToken:t}},xa=e=>{const{totalTrades:t}=qe(),{marketPrice:n,typedInputAmount:r}=q(),s=v.useMemo(()=>{const{isError:o,value:d}=Mi(e);if(!(!o||S(r||"0").isZero()||!n))return{type:me.MIN_FILL_DELAY,value:d}},[e,r,n]),i=v.useMemo(()=>{const{isError:o,value:d}=vi(e,t);if(!(!o||S(r||"0").isZero()||!n))return{type:me.MAX_FILL_DELAY,value:d}},[e,r,n,t]);return s||i},Lt=()=>{const{callbacks:e}=q(),t=Q(i=>i.state.typedFillDelay),n=Q(i=>i.updateState),r=v.useMemo(()=>t||_n,[t]),s=xa(r);return{fillDelay:r,onChange:v.useCallback(i=>{var o;n({typedFillDelay:i}),(o=e==null?void 0:e.onFillDelayChange)==null||o.call(e,i)},[n,e]),error:s,milliseconds:r.unit*r.value}},Sa=()=>{const{onChange:e,fillDelay:t,error:n}=Lt(),r=v.useCallback(i=>e({unit:t.unit,value:Number(i)}),[e,t]),s=v.useCallback(i=>e({unit:i,value:t.value}),[e,t]);return{onInputChange:r,onUnitSelect:s,onChange:e,milliseconds:t.unit*t.value,fillDelay:t,error:n}},va=e=>{const{module:t,marketPrice:n}=q();return v.useMemo(()=>{const r=Ii(t,e),s=ki(e);if(n){if(r.isError)return{type:me.MAX_ORDER_DURATION,value:r.value,args:{duration:`${Math.floor(Xr(r.value)).toFixed(0)} days`}};if(s.isError)return{type:me.MIN_ORDER_DURATION,value:s.value,args:{duration:`${Math.floor(Zr(s.value)).toFixed(0)} minutes`}}}},[e,t,n])},Zn=()=>{const{module:e,callbacks:t}=q(),n=Q(p=>p.state.typedDuration),r=Q(p=>p.updateState),s=qe().totalTrades,i=Lt().fillDelay,o=v.useMemo(()=>bi(e,s,i,n),[s,i,n,e]),d=va(o);return{duration:o,setDuration:v.useCallback(p=>{var h;r({typedDuration:p}),(h=t==null?void 0:t.onDurationChange)==null||h.call(t,p)},[r,t]),error:d}},Pa=()=>{const{duration:e,setDuration:t,error:n}=Zn(),r=v.useCallback(i=>{t({unit:e.unit,value:Number(i)})},[t,e]),s=v.useCallback(i=>{t({unit:i,value:e.value})},[t,e]);return{duration:e,onChange:t,milliseconds:e.unit*e.value,onInputChange:r,onUnitSelect:s,error:n}},Fa=()=>{const{module:e}=q();return v.useMemo(()=>e===j.STOP_LOSS?ai:oi,[e])},Yn=()=>{const{module:e}=q(),t=Q(n=>n.state.isMarketOrder);return v.useMemo(()=>e!==j.STOP_LOSS&&e!==j.TAKE_PROFIT||t?void 0:e===j.STOP_LOSS?ui:ci,[e,t])},An=()=>{const{srcToken:e,dstToken:t,marketPriceLoading:n}=q(),r=Q(h=>h.updateState),s=Q(h=>h.state.isInvertedTrade),i=Q(h=>h.state.typedTriggerPrice),o=Q(h=>h.state.typedLimitPrice),d=Q(h=>h.state.isMarketOrder);return{onInvert:v.useCallback(()=>{i!==void 0&&r({typedTriggerPrice:S(1).div(i).toFixed()}),o!==void 0&&r({typedLimitPrice:S(1).div(o).toFixed()}),r({isInvertedTrade:!s})},[r,s,i,o,n]),isInverted:s,fromToken:s?t:e,toToken:s?e:t,isMarketPrice:d}},Yr=({typedValue:e,tokenDecimals:t=18,initialPrice:n="0",percentage:r,setValue:s,setPercentage:i})=>{const{srcUsd1Token:o,dstUsd1Token:d}=q(),{isInverted:p}=An(),h=v.useMemo(()=>S((()=>{if(e!==void 0){const M=p?S(e).isZero()?S(0):S(1).div(e):S(e);return Et(M.toFixed(),t)}if(r!==void 0&&S(n||"0").gt(0)&&!S(n||"0").isNaN()){const M=S(n||"0"),B=S(r||0).div(100);return M.plus(M.multipliedBy(B)).decimalPlaces(0).toFixed()}return S(n).gt(0)?n:""})()).decimalPlaces(0).toFixed(),[e,r,t,n,p]),C=v.useCallback(O=>{s(O),i(null)},[s,i]),E=v.useCallback(O=>{s(void 0),i(O)},[s,i]),x=v.useMemo(()=>{if(!n||S(n).isZero())return"";if(r!=null)return r;if(h){const O=S(n),B=S(h).minus(O).div(O).multipliedBy(100).decimalPlaces(2).toString();return S(B||"0").isZero()?"":B}return""},[h,n,r]),P=v.useMemo(()=>{let O="";if(e!==void 0)O=e;else{const M=Ee(h,t);if(S(M||"0").isZero())return"";O=p?S(1).div(M).toFixed():M}return O},[e,t,h,p]),I=nt(p?o:d,P||"0");return{amount:S(h).isNaN()?"":h,amountUI:S(P).isNaN()?"":P,selectedPercentage:x,onChange:C,onPercentageChange:E,isInverted:p,usd:S(I).isNaN()?"":I,isTypedValue:e!==void 0}},Da=(e="")=>{const{module:t,marketPrice:n,typedInputAmount:r}=q();return v.useMemo(()=>{if(S(r||"0").isZero()||!n||t!==j.STOP_LOSS&&t!==j.TAKE_PROFIT)return;const s=Pi(n||"",e||"",t);if(s!=null&&s.isError)return{type:me.STOP_LOSS_TRIGGER_PRICE_GREATER_THAN_MARKET_PRICE,value:s.value};const i=Fi(n||"",e||"",t);if(i!=null&&i.isError)return{type:me.TAKE_PROFIT_TRIGGER_PRICE_LESS_THAN_MARKET_PRICE,value:i.value};if(!e||S(e||0).isZero())return{type:me.EMPTY_TRIGGER_PRICE,value:e}},[n,e,t,r])},Oa=e=>{const{srcToken:t,dstToken:n,module:r,dstUsd1Token:s}=q(),i=qe().amountPerTrade,o=Q(h=>h.state.isMarketOrder),d=v.useMemo(()=>Ei(r,i,e,(t==null?void 0:t.decimals)||0),[e,i,o,t==null?void 0:t.decimals,r]),p=en((n==null?void 0:n.decimals)||0,d);return{amount:d,amountUI:p,usd:nt(p,s)}},bt=()=>{const{dstToken:e,marketPrice:t,module:n,callbacks:r}=q(),s=Q(I=>I.updateState),i=Fa(),o=Q(I=>I.state.triggerPricePercent),d=o===void 0?i:o,p=n===j.STOP_LOSS||n===j.TAKE_PROFIT,h=Yr({typedValue:Q(I=>I.state.typedTriggerPrice),percentage:d,tokenDecimals:(e==null?void 0:e.decimals)||18,initialPrice:p?t:void 0,setValue:v.useCallback(I=>{var O;s({typedTriggerPrice:I}),(O=r==null?void 0:r.onTriggerPriceChange)==null||O.call(r,I||"")},[s,r]),setPercentage:v.useCallback(I=>{var O;s({triggerPricePercent:I}),(O=r==null?void 0:r.onTriggerPricePercentChange)==null||O.call(r,I||"")},[s,r])}),C=Da(h.amount),{amount:E,amountUI:x,usd:P}=Oa(h.amount);return v.useMemo(()=>({...h,error:C,pricePerChunk:E,pricePerChunkUI:x,pricePerChunkUsd:P}),[h,C,E,x,P])},Ia=e=>{const{module:t,marketPrice:n,typedInputAmount:r}=q(),{amount:s}=bt(),i=Q(o=>o.state.isMarketOrder);return v.useMemo(()=>{if(S(r||"0").isZero()||!s||!n)return;const o=Di(s,e,i,t),d=Oi(s,e,i,t);if(o!=null&&o.isError)return{type:me.TRIGGER_LIMIT_PRICE_GREATER_THAN_TRIGGER_PRICE,value:o.value};if(d!=null&&d.isError)return{type:me.TRIGGER_LIMIT_PRICE_GREATER_THAN_TRIGGER_PRICE,value:d.value};if(e&&S(e||0).isZero())return{type:me.MISSING_LIMIT_PRICE,value:e||""}},[e,s,t,i,r,n])},En=()=>{const{dstToken:e,marketPrice:t,callbacks:n}=q(),r=Q(h=>h.updateState),s=Yn(),i=Q(h=>h.state.limitPricePercent),o=i===void 0?s:i,d=Yr({typedValue:Q(h=>h.state.typedLimitPrice),percentage:o,tokenDecimals:(e==null?void 0:e.decimals)||18,initialPrice:t,setValue:v.useCallback(h=>{var C;r({typedLimitPrice:h}),(C=n==null?void 0:n.onLimitPriceChange)==null||C.call(n,h||"")},[r,n]),setPercentage:v.useCallback(h=>{var C;r({limitPricePercent:h}),(C=n==null?void 0:n.onLimitPricePercentChange)==null||C.call(n,h||"")},[r,n])}),p=Ia(d.amount);return v.useMemo(()=>({...d,error:p}),[d,p])},ka=()=>{const{module:e}=q(),t=Q(d=>d.updateState),n=Q(d=>d.state.isMarketOrder),r=Yn(),s=Q(d=>d.state.triggerPricePercent)||0,i=e===j.LIMIT,o=v.useCallback(()=>{!n&&e===j.STOP_LOSS&&t({limitPricePercent:r}),t({isMarketOrder:!n})},[t,s,e,n,r]);return{isLimitPrice:!n,toggleLimitPrice:o,hide:i}},Ma=()=>{const{module:e,marketPriceLoading:t,srcToken:n,dstToken:r}=q(),{amount:s,amountUI:i,onChange:o,onPercentageChange:d,usd:p,selectedPercentage:h,error:C,isTypedValue:E}=En(),x=Q(K=>K.updateState),P=Yn(),{isLimitPrice:I,toggleLimitPrice:O}=ka(),{fromToken:M,toToken:B}=An(),F=v.useCallback(()=>{x({typedLimitPrice:void 0}),x({limitPricePercent:P})},[x,e,P]);return{price:s,priceUI:i,error:C,onInputChange:o,onPercentageChange:d,onReset:F,usd:p,srcToken:n,dstToken:r,invertedSrcToken:M,invertedDstToken:B,percentage:h,isLoading:t,isLimitPrice:I,toggleLimitPrice:O,isTypedValue:E}},_a=()=>{const{marketPrice:e,marketPriceLoading:t,srcToken:n,dstToken:r}=q(),{amount:s,amountUI:i,onChange:o,onPercentageChange:d,usd:p,selectedPercentage:h,error:C,pricePerChunk:E,pricePerChunkUI:x,pricePerChunkUsd:P,isTypedValue:I}=bt(),O=Q(K=>K.updateState),{fromToken:M,toToken:B}=An(),F=v.useCallback(()=>{O({triggerPricePercent:void 0,typedTriggerPrice:void 0})},[O]);return{price:s,priceUI:i,amountPerChunk:E,amountPerChunkUI:x,amountPerChunkUsd:P,error:C,onInputChange:o,onPercentageChange:d,percentage:h,onReset:F,usd:p,srcToken:n,dstToken:r,invertedSrcToken:M,invertedDstToken:B,isLoading:t||!e,isTypedValue:I}},Jr=()=>{const{module:e,marketPrice:t}=q(),n=En().amount,r=bt().amount,s=Q(i=>i.state.isMarketOrder);return e===j.LIMIT||!s?n||"":e===j.STOP_LOSS||e===j.TAKE_PROFIT?r||"":t||""},bn=()=>{const{srcToken:e,dstToken:t,dstUsd1Token:n}=q(),r=Jr(),s=rt().amount,i=v.useMemo(()=>gi(s||"",r,(e==null?void 0:e.decimals)||0),[s,r,e==null?void 0:e.decimals]),o=en(t==null?void 0:t.decimals,i);return{amount:i,amountUI:o,usd:nt(o,n)}},Jn=()=>{const{srcToken:e,dstToken:t,dstUsd1Token:n}=q(),r=Jr(),s=qe().amountPerTrade,i=Q(p=>p.state.isMarketOrder),o=v.useMemo(()=>Ai(s,r,!!i,(e==null?void 0:e.decimals)||0),[s,r,i,e==null?void 0:e.decimals]),d=en(t==null?void 0:t.decimals,o);return{amount:o,amountUI:d,usd:nt(d,n)}},Ba=()=>{const{typedInputAmount:e,marketPriceLoading:t,dstToken:n}=q(),{amountUI:r,usd:s}=bn(),o=Ta()?e:r,d=Xn(n==null?void 0:n.decimals,o);return{value:o,valueWei:d,isLoading:t,usd:s}},Ua=()=>{const e=Q(s=>s.state.isMarketOrder),{module:t}=q(),n=v.useMemo(()=>{if(e&&t===j.STOP_LOSS)return Jt.TRIGGER_MARKET_PRICE},[e,t]),r=v.useMemo(()=>{if(!(t!==j.LIMIT&&t!==j.TWAP))return e?Jt.MARKET_PRICE:Jt.LIMIT_PRICE},[e,t]);return n||r},Ra=()=>{const{minChunkSizeUsd:e,typedInputAmount:t,srcUsd1Token:n}=q(),r=nt(t,n);return v.useMemo(()=>S(e).gt(S(r||"0"))?{type:me.MIN_TRADE_SIZE_ERROR,value:e}:void 0,[e,r])};function es(){const{marketPrice:e,marketPriceLoading:t,typedInputAmount:n,srcUsd1Token:r,srcBalance:s,chainId:i}=q(),{error:o}=bt(),{error:d}=En(),{error:p}=qe(),{error:h}=Lt(),{error:C}=Zn(),E=Ra(),x=rt().amount,P=v.useMemo(()=>{if(s&&S(x).gt(s))return{type:me.INSUFFICIENT_BALANCE,value:s||""}},[s,x,i]);return v.useMemo(()=>Ri({marketPrice:e,typedInputAmount:n,srcUsd1Token:r,marketPriceLoading:t,triggerPriceError:o,limitPriceError:d,tradesError:p,fillDelayError:h,durationError:C,balanceError:P,minTradeSizeError:E}),[e,t,n,o,d,p,h,C,P,r,E])}var Nt=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},La={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Na=(Os=class{constructor(){N(this,Ke,La);N(this,xt,!1)}setTimeoutProvider(e){process.env.NODE_ENV!=="production"&&l(this,xt)&&e!==l(this,Ke)&&console.error("[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",{previous:l(this,Ke),provider:e}),_(this,Ke,e),process.env.NODE_ENV!=="production"&&_(this,xt,!1)}setTimeout(e,t){return process.env.NODE_ENV!=="production"&&_(this,xt,!0),l(this,Ke).setTimeout(e,t)}clearTimeout(e){l(this,Ke).clearTimeout(e)}setInterval(e,t){return process.env.NODE_ENV!=="production"&&_(this,xt,!0),l(this,Ke).setInterval(e,t)}clearInterval(e){l(this,Ke).clearInterval(e)}},Ke=new WeakMap,xt=new WeakMap,Os),Tt=new Na;function qa(e){setTimeout(e,0)}var wt=typeof window>"u"||"Deno"in globalThis;function be(){}function Ka(e,t){return typeof e=="function"?e(t):e}function er(e){return typeof e=="number"&&e>=0&&e!==1/0}function ts(e,t){return Math.max(e+(t||0)-Date.now(),0)}function st(e,t){return typeof e=="function"?e(t):e}function ke(e,t){return typeof e=="function"?e(t):e}function ns(e,t){const{type:n="all",exact:r,fetchStatus:s,predicate:i,queryKey:o,stale:d}=e;if(o){if(r){if(t.queryHash!==tr(o,t.options))return!1}else if(!tn(t.queryKey,o))return!1}if(n!=="all"){const p=t.isActive();if(n==="active"&&!p||n==="inactive"&&p)return!1}return!(typeof d=="boolean"&&t.isStale()!==d||s&&s!==t.state.fetchStatus||i&&!i(t))}function rs(e,t){const{exact:n,status:r,predicate:s,mutationKey:i}=e;if(i){if(!t.options.mutationKey)return!1;if(n){if(Ct(t.options.mutationKey)!==Ct(i))return!1}else if(!tn(t.options.mutationKey,i))return!1}return!(r&&t.state.status!==r||s&&!s(t))}function tr(e,t){return((t==null?void 0:t.queryKeyHashFn)||Ct)(e)}function Ct(e){return JSON.stringify(e,(t,n)=>rr(n)?Object.keys(n).sort().reduce((r,s)=>(r[s]=n[s],r),{}):n)}function tn(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>tn(e[n],t[n])):!1}var Ha=Object.prototype.hasOwnProperty;function nr(e,t){if(e===t)return e;const n=ss(e)&&ss(t);if(!n&&!(rr(e)&&rr(t)))return t;const s=(n?e:Object.keys(e)).length,i=n?t:Object.keys(t),o=i.length,d=n?new Array(o):{};let p=0;for(let h=0;h<o;h++){const C=n?h:i[h],E=e[C],x=t[C];if(E===x){d[C]=E,(n?h<s:Ha.call(e,C))&&p++;continue}if(E===null||x===null||typeof E!="object"||typeof x!="object"){d[C]=x;continue}const P=nr(E,x);d[C]=P,P===E&&p++}return s===o&&p===s?e:d}function Tn(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(e[n]!==t[n])return!1;return!0}function ss(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function rr(e){if(!is(e))return!1;const t=e.constructor;if(t===void 0)return!0;const n=t.prototype;return!(!is(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function is(e){return Object.prototype.toString.call(e)==="[object Object]"}function Wa(e){return new Promise(t=>{Tt.setTimeout(t,e)})}function sr(e,t,n){if(typeof n.structuralSharing=="function")return n.structuralSharing(e,t);if(n.structuralSharing!==!1){if(process.env.NODE_ENV!=="production")try{return nr(e,t)}catch(r){throw console.error(`Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${n.queryHash}]: ${r}`),r}return nr(e,t)}return t}function Qa(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function ja(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var wn=Symbol();function as(e,t){return process.env.NODE_ENV!=="production"&&e.queryFn===wn&&console.error(`Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${e.queryHash}'`),!e.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!e.queryFn||e.queryFn===wn?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function os(e,t){return typeof e=="function"?e(...t):!!e}var za=(Is=class extends Nt{constructor(){super();N(this,St);N(this,at);N(this,qt);_(this,qt,t=>{if(!wt&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){l(this,at)||this.setEventListener(l(this,qt))}onUnsubscribe(){var t;this.hasListeners()||((t=l(this,at))==null||t.call(this),_(this,at,void 0))}setEventListener(t){var n;_(this,qt,t),(n=l(this,at))==null||n.call(this),_(this,at,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){l(this,St)!==t&&(_(this,St,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(n=>{n(t)})}isFocused(){var t;return typeof l(this,St)=="boolean"?l(this,St):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},St=new WeakMap,at=new WeakMap,qt=new WeakMap,Is),ir=new za;function ar(){let e,t;const n=new Promise((s,i)=>{e=s,t=i});n.status="pending",n.catch(()=>{});function r(s){Object.assign(n,s),delete n.resolve,delete n.reject}return n.resolve=s=>{r({status:"fulfilled",value:s}),e(s)},n.reject=s=>{r({status:"rejected",reason:s}),t(s)},n}var $a=qa;function Va(){let e=[],t=0,n=d=>{d()},r=d=>{d()},s=$a;const i=d=>{t?e.push(d):s(()=>{n(d)})},o=()=>{const d=e;e=[],d.length&&s(()=>{r(()=>{d.forEach(p=>{n(p)})})})};return{batch:d=>{let p;t++;try{p=d()}finally{t--,t||o()}return p},batchCalls:d=>(...p)=>{i(()=>{d(...p)})},schedule:i,setNotifyFunction:d=>{n=d},setBatchNotifyFunction:d=>{r=d},setScheduler:d=>{s=d}}}var ce=Va(),Ga=(ks=class extends Nt{constructor(){super();N(this,Kt,!0);N(this,ot);N(this,Ht);_(this,Ht,t=>{if(!wt&&window.addEventListener){const n=()=>t(!0),r=()=>t(!1);return window.addEventListener("online",n,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",r)}}})}onSubscribe(){l(this,ot)||this.setEventListener(l(this,Ht))}onUnsubscribe(){var t;this.hasListeners()||((t=l(this,ot))==null||t.call(this),_(this,ot,void 0))}setEventListener(t){var n;_(this,Ht,t),(n=l(this,ot))==null||n.call(this),_(this,ot,t(this.setOnline.bind(this)))}setOnline(t){l(this,Kt)!==t&&(_(this,Kt,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return l(this,Kt)}},Kt=new WeakMap,ot=new WeakMap,Ht=new WeakMap,ks),Cn=new Ga;function Xa(e){return Math.min(1e3*2**e,3e4)}function us(e){return(e??"online")==="online"?Cn.isOnline():!0}var or=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function cs(e){let t=!1,n=0,r;const s=ar(),i=()=>s.status!=="pending",o=O=>{var M;if(!i()){const B=new or(O);x(B),(M=e.onCancel)==null||M.call(e,B)}},d=()=>{t=!0},p=()=>{t=!1},h=()=>ir.isFocused()&&(e.networkMode==="always"||Cn.isOnline())&&e.canRun(),C=()=>us(e.networkMode)&&e.canRun(),E=O=>{i()||(r==null||r(),s.resolve(O))},x=O=>{i()||(r==null||r(),s.reject(O))},P=()=>new Promise(O=>{var M;r=B=>{(i()||h())&&O(B)},(M=e.onPause)==null||M.call(e)}).then(()=>{var O;r=void 0,i()||(O=e.onContinue)==null||O.call(e)}),I=()=>{if(i())return;let O;const M=n===0?e.initialPromise:void 0;try{O=M??e.fn()}catch(B){O=Promise.reject(B)}Promise.resolve(O).then(E).catch(B=>{var Y;if(i())return;const F=e.retry??(wt?0:3),K=e.retryDelay??Xa,U=typeof K=="function"?K(n,B):K,Z=F===!0||typeof F=="number"&&n<F||typeof F=="function"&&F(n,B);if(t||!Z){x(B);return}n++,(Y=e.onFail)==null||Y.call(e,n,B),Wa(U).then(()=>h()?void 0:P()).then(()=>{t?x(B):I()})})};return{promise:s,status:()=>s.status,cancel:o,continue:()=>(r==null||r(),s),cancelRetry:d,continueRetry:p,canStart:C,start:()=>(C()?I():P().then(I),s)}}var ds=(Ms=class{constructor(){N(this,vt)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),er(this.gcTime)&&_(this,vt,Tt.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(wt?1/0:300*1e3))}clearGcTimeout(){l(this,vt)&&(Tt.clearTimeout(l(this,vt)),_(this,vt,void 0))}},vt=new WeakMap,Ms),Za=(_s=class extends ds{constructor(t){super();N(this,Re);N(this,Pt);N(this,Wt);N(this,Me);N(this,Ft);N(this,he);N(this,rn);N(this,Dt);_(this,Dt,!1),_(this,rn,t.defaultOptions),this.setOptions(t.options),this.observers=[],_(this,Ft,t.client),_(this,Me,l(this,Ft).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,_(this,Pt,hs(this.options)),this.state=t.state??l(this,Pt),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=l(this,he))==null?void 0:t.promise}setOptions(t){if(this.options={...l(this,rn),...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const n=hs(this.options);n.data!==void 0&&(this.setState(ps(n.data,n.dataUpdatedAt)),_(this,Pt,n))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&l(this,Me).remove(this)}setData(t,n){const r=sr(this.state.data,t,this.options);return z(this,Re,Je).call(this,{data:r,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),r}setState(t,n){z(this,Re,Je).call(this,{type:"setState",state:t,setStateOptions:n})}cancel(t){var r,s;const n=(r=l(this,he))==null?void 0:r.promise;return(s=l(this,he))==null||s.cancel(t),n?n.then(be).catch(be):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(l(this,Pt))}isActive(){return this.observers.some(t=>ke(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===wn||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>st(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!ts(this.state.dataUpdatedAt,t)}onFocus(){var n;const t=this.observers.find(r=>r.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(n=l(this,he))==null||n.continue()}onOnline(){var n;const t=this.observers.find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=l(this,he))==null||n.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),l(this,Me).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(n=>n!==t),this.observers.length||(l(this,he)&&(l(this,Dt)?l(this,he).cancel({revert:!0}):l(this,he).cancelRetry()),this.scheduleGc()),l(this,Me).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||z(this,Re,Je).call(this,{type:"invalidate"})}async fetch(t,n){var p,h,C,E,x,P,I,O,M,B,F,K;if(this.state.fetchStatus!=="idle"&&((p=l(this,he))==null?void 0:p.status())!=="rejected"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(l(this,he))return l(this,he).continueRetry(),l(this,he).promise}if(t&&this.setOptions(t),!this.options.queryFn){const U=this.observers.find(Z=>Z.options.queryFn);U&&this.setOptions(U.options)}process.env.NODE_ENV!=="production"&&(Array.isArray(this.options.queryKey)||console.error("As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']"));const r=new AbortController,s=U=>{Object.defineProperty(U,"signal",{enumerable:!0,get:()=>(_(this,Dt,!0),r.signal)})},i=()=>{const U=as(this.options,n),Y=(()=>{const oe={client:l(this,Ft),queryKey:this.queryKey,meta:this.meta};return s(oe),oe})();return _(this,Dt,!1),this.options.persister?this.options.persister(U,Y,this):U(Y)},d=(()=>{const U={fetchOptions:n,options:this.options,queryKey:this.queryKey,client:l(this,Ft),state:this.state,fetchFn:i};return s(U),U})();(h=this.options.behavior)==null||h.onFetch(d,this),_(this,Wt,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((C=d.fetchOptions)==null?void 0:C.meta))&&z(this,Re,Je).call(this,{type:"fetch",meta:(E=d.fetchOptions)==null?void 0:E.meta}),_(this,he,cs({initialPromise:n==null?void 0:n.initialPromise,fn:d.fetchFn,onCancel:U=>{U instanceof or&&U.revert&&this.setState({...l(this,Wt),fetchStatus:"idle"}),r.abort()},onFail:(U,Z)=>{z(this,Re,Je).call(this,{type:"failed",failureCount:U,error:Z})},onPause:()=>{z(this,Re,Je).call(this,{type:"pause"})},onContinue:()=>{z(this,Re,Je).call(this,{type:"continue"})},retry:d.options.retry,retryDelay:d.options.retryDelay,networkMode:d.options.networkMode,canRun:()=>!0}));try{const U=await l(this,he).start();if(U===void 0)throw process.env.NODE_ENV!=="production"&&console.error(`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`),new Error(`${this.queryHash} data is undefined`);return this.setData(U),(P=(x=l(this,Me).config).onSuccess)==null||P.call(x,U,this),(O=(I=l(this,Me).config).onSettled)==null||O.call(I,U,this.state.error,this),U}catch(U){if(U instanceof or){if(U.silent)return l(this,he).promise;if(U.revert){if(this.state.data===void 0)throw U;return this.state.data}}throw z(this,Re,Je).call(this,{type:"error",error:U}),(B=(M=l(this,Me).config).onError)==null||B.call(M,U,this),(K=(F=l(this,Me).config).onSettled)==null||K.call(F,this.state.data,U,this),U}finally{this.scheduleGc()}}},Pt=new WeakMap,Wt=new WeakMap,Me=new WeakMap,Ft=new WeakMap,he=new WeakMap,rn=new WeakMap,Dt=new WeakMap,Re=new WeakSet,Je=function(t){const n=r=>{switch(t.type){case"failed":return{...r,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...ls(r.data,this.options),fetchMeta:t.meta??null};case"success":const s={...r,...ps(t.data,t.dataUpdatedAt),dataUpdateCount:r.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return _(this,Wt,t.manual?s:void 0),s;case"error":const i=t.error;return{...r,error:i,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error"};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}};this.state=n(this.state),ce.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),l(this,Me).notify({query:this,type:"updated",action:t})})},_s);function ls(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:us(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function ps(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function hs(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var Ya=(Bs=class extends Nt{constructor(t,n){super();N(this,ee);N(this,ve);N(this,X);N(this,sn);N(this,Te);N(this,Ot);N(this,Qt);N(this,Ve);N(this,ut);N(this,an);N(this,jt);N(this,zt);N(this,It);N(this,kt);N(this,ct);N(this,$t,new Set);this.options=n,_(this,ve,t),_(this,ut,null),_(this,Ve,ar()),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(l(this,X).addObserver(this),fs(l(this,X),this.options)?z(this,ee,dn).call(this):this.updateResult(),z(this,ee,br).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return ur(l(this,X),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return ur(l(this,X),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,z(this,ee,Tr).call(this),z(this,ee,wr).call(this),l(this,X).removeObserver(this)}setOptions(t){const n=this.options,r=l(this,X);if(this.options=l(this,ve).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof ke(this.options.enabled,l(this,X))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");z(this,ee,Cr).call(this),l(this,X).setOptions(this.options),n._defaulted&&!Tn(this.options,n)&&l(this,ve).getQueryCache().notify({type:"observerOptionsUpdated",query:l(this,X),observer:this});const s=this.hasListeners();s&&ms(l(this,X),r,this.options,n)&&z(this,ee,dn).call(this),this.updateResult(),s&&(l(this,X)!==r||ke(this.options.enabled,l(this,X))!==ke(n.enabled,l(this,X))||st(this.options.staleTime,l(this,X))!==st(n.staleTime,l(this,X)))&&z(this,ee,gr).call(this);const i=z(this,ee,Ar).call(this);s&&(l(this,X)!==r||ke(this.options.enabled,l(this,X))!==ke(n.enabled,l(this,X))||i!==l(this,ct))&&z(this,ee,Er).call(this,i)}getOptimisticResult(t){const n=l(this,ve).getQueryCache().build(l(this,ve),t),r=this.createResult(n,t);return eo(this,r)&&(_(this,Te,r),_(this,Qt,this.options),_(this,Ot,l(this,X).state)),r}getCurrentResult(){return l(this,Te)}trackResult(t,n){return new Proxy(t,{get:(r,s)=>(this.trackProp(s),n==null||n(s),s==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&l(this,Ve).status==="pending"&&l(this,Ve).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(r,s))})}trackProp(t){l(this,$t).add(t)}getCurrentQuery(){return l(this,X)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=l(this,ve).defaultQueryOptions(t),r=l(this,ve).getQueryCache().build(l(this,ve),n);return r.fetch().then(()=>this.createResult(r,n))}fetch(t){return z(this,ee,dn).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),l(this,Te)))}createResult(t,n){var u;const r=l(this,X),s=this.options,i=l(this,Te),o=l(this,Ot),d=l(this,Qt),h=t!==r?t.state:l(this,sn),{state:C}=t;let E={...C},x=!1,P;if(n._optimisticResults){const c=this.hasListeners(),A=!c&&fs(t,n),m=c&&ms(t,r,n,s);(A||m)&&(E={...E,...ls(C.data,t.options)}),n._optimisticResults==="isRestoring"&&(E.fetchStatus="idle")}let{error:I,errorUpdatedAt:O,status:M}=E;P=E.data;let B=!1;if(n.placeholderData!==void 0&&P===void 0&&M==="pending"){let c;i!=null&&i.isPlaceholderData&&n.placeholderData===(d==null?void 0:d.placeholderData)?(c=i.data,B=!0):c=typeof n.placeholderData=="function"?n.placeholderData((u=l(this,zt))==null?void 0:u.state.data,l(this,zt)):n.placeholderData,c!==void 0&&(M="success",P=sr(i==null?void 0:i.data,c,n),x=!0)}if(n.select&&P!==void 0&&!B)if(i&&P===(o==null?void 0:o.data)&&n.select===l(this,an))P=l(this,jt);else try{_(this,an,n.select),P=n.select(P),P=sr(i==null?void 0:i.data,P,n),_(this,jt,P),_(this,ut,null)}catch(c){_(this,ut,c)}l(this,ut)&&(I=l(this,ut),P=l(this,jt),O=Date.now(),M="error");const F=E.fetchStatus==="fetching",K=M==="pending",U=M==="error",Z=K&&F,Y=P!==void 0,a={status:M,fetchStatus:E.fetchStatus,isPending:K,isSuccess:M==="success",isError:U,isInitialLoading:Z,isLoading:Z,data:P,dataUpdatedAt:E.dataUpdatedAt,error:I,errorUpdatedAt:O,failureCount:E.fetchFailureCount,failureReason:E.fetchFailureReason,errorUpdateCount:E.errorUpdateCount,isFetched:E.dataUpdateCount>0||E.errorUpdateCount>0,isFetchedAfterMount:E.dataUpdateCount>h.dataUpdateCount||E.errorUpdateCount>h.errorUpdateCount,isFetching:F,isRefetching:F&&!K,isLoadingError:U&&!Y,isPaused:E.fetchStatus==="paused",isPlaceholderData:x,isRefetchError:U&&Y,isStale:cr(t,n),refetch:this.refetch,promise:l(this,Ve),isEnabled:ke(n.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const c=y=>{a.status==="error"?y.reject(a.error):a.data!==void 0&&y.resolve(a.data)},A=()=>{const y=_(this,Ve,a.promise=ar());c(y)},m=l(this,Ve);switch(m.status){case"pending":t.queryHash===r.queryHash&&c(m);break;case"fulfilled":(a.status==="error"||a.data!==m.value)&&A();break;case"rejected":(a.status!=="error"||a.error!==m.reason)&&A();break}}return a}updateResult(){const t=l(this,Te),n=this.createResult(l(this,X),this.options);if(_(this,Ot,l(this,X).state),_(this,Qt,this.options),l(this,Ot).data!==void 0&&_(this,zt,l(this,X)),Tn(n,t))return;_(this,Te,n);const r=()=>{if(!t)return!0;const{notifyOnChangeProps:s}=this.options,i=typeof s=="function"?s():s;if(i==="all"||!i&&!l(this,$t).size)return!0;const o=new Set(i??l(this,$t));return this.options.throwOnError&&o.add("error"),Object.keys(l(this,Te)).some(d=>{const p=d;return l(this,Te)[p]!==t[p]&&o.has(p)})};z(this,ee,Hs).call(this,{listeners:r()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&z(this,ee,br).call(this)}},ve=new WeakMap,X=new WeakMap,sn=new WeakMap,Te=new WeakMap,Ot=new WeakMap,Qt=new WeakMap,Ve=new WeakMap,ut=new WeakMap,an=new WeakMap,jt=new WeakMap,zt=new WeakMap,It=new WeakMap,kt=new WeakMap,ct=new WeakMap,$t=new WeakMap,ee=new WeakSet,dn=function(t){z(this,ee,Cr).call(this);let n=l(this,X).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(be)),n},gr=function(){z(this,ee,Tr).call(this);const t=st(this.options.staleTime,l(this,X));if(wt||l(this,Te).isStale||!er(t))return;const r=ts(l(this,Te).dataUpdatedAt,t)+1;_(this,It,Tt.setTimeout(()=>{l(this,Te).isStale||this.updateResult()},r))},Ar=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(l(this,X)):this.options.refetchInterval)??!1},Er=function(t){z(this,ee,wr).call(this),_(this,ct,t),!(wt||ke(this.options.enabled,l(this,X))===!1||!er(l(this,ct))||l(this,ct)===0)&&_(this,kt,Tt.setInterval(()=>{(this.options.refetchIntervalInBackground||ir.isFocused())&&z(this,ee,dn).call(this)},l(this,ct)))},br=function(){z(this,ee,gr).call(this),z(this,ee,Er).call(this,z(this,ee,Ar).call(this))},Tr=function(){l(this,It)&&(Tt.clearTimeout(l(this,It)),_(this,It,void 0))},wr=function(){l(this,kt)&&(Tt.clearInterval(l(this,kt)),_(this,kt,void 0))},Cr=function(){const t=l(this,ve).getQueryCache().build(l(this,ve),this.options);if(t===l(this,X))return;const n=l(this,X);_(this,X,t),_(this,sn,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},Hs=function(t){ce.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(l(this,Te))}),l(this,ve).getQueryCache().notify({query:l(this,X),type:"observerResultsUpdated"})})},Bs);function Ja(e,t){return ke(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function fs(e,t){return Ja(e,t)||e.state.data!==void 0&&ur(e,t,t.refetchOnMount)}function ur(e,t,n){if(ke(t.enabled,e)!==!1&&st(t.staleTime,e)!=="static"){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&cr(e,t)}return!1}function ms(e,t,n,r){return(e!==t||ke(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&cr(e,n)}function cr(e,t){return ke(t.enabled,e)!==!1&&e.isStaleByTime(st(t.staleTime,e))}function eo(e,t){return!Tn(e.getCurrentResult(),t)}function ys(e){return{onFetch:(t,n)=>{var C,E,x,P,I;const r=t.options,s=(x=(E=(C=t.fetchOptions)==null?void 0:C.meta)==null?void 0:E.fetchMore)==null?void 0:x.direction,i=((P=t.state.data)==null?void 0:P.pages)||[],o=((I=t.state.data)==null?void 0:I.pageParams)||[];let d={pages:[],pageParams:[]},p=0;const h=async()=>{let O=!1;const M=K=>{Object.defineProperty(K,"signal",{enumerable:!0,get:()=>(t.signal.aborted?O=!0:t.signal.addEventListener("abort",()=>{O=!0}),t.signal)})},B=as(t.options,t.fetchOptions),F=async(K,U,Z)=>{if(O)return Promise.reject();if(U==null&&K.pages.length)return Promise.resolve(K);const oe=(()=>{const A={client:t.client,queryKey:t.queryKey,pageParam:U,direction:Z?"backward":"forward",meta:t.options.meta};return M(A),A})(),a=await B(oe),{maxPages:u}=t.options,c=Z?ja:Qa;return{pages:c(K.pages,a,u),pageParams:c(K.pageParams,U,u)}};if(s&&i.length){const K=s==="backward",U=K?to:gs,Z={pages:i,pageParams:o},Y=U(r,Z);d=await F(Z,Y,K)}else{const K=e??i.length;do{const U=p===0?o[0]??r.initialPageParam:gs(r,d);if(p>0&&U==null)break;d=await F(d,U),p++}while(p<K)}return d};t.options.persister?t.fetchFn=()=>{var O,M;return(M=(O=t.options).persister)==null?void 0:M.call(O,h,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=h}}}function gs(e,{pages:t,pageParams:n}){const r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function to(e,{pages:t,pageParams:n}){var r;return t.length>0?(r=e.getPreviousPageParam)==null?void 0:r.call(e,t[0],t,n[0],n):void 0}var no=(Us=class extends ds{constructor(t){super();N(this,We);N(this,on);N(this,He);N(this,we);N(this,Mt);_(this,on,t.client),this.mutationId=t.mutationId,_(this,we,t.mutationCache),_(this,He,[]),this.state=t.state||As(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){l(this,He).includes(t)||(l(this,He).push(t),this.clearGcTimeout(),l(this,we).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){_(this,He,l(this,He).filter(n=>n!==t)),this.scheduleGc(),l(this,we).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){l(this,He).length||(this.state.status==="pending"?this.scheduleGc():l(this,we).remove(this))}continue(){var t;return((t=l(this,Mt))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var o,d,p,h,C,E,x,P,I,O,M,B,F,K,U,Z,Y,oe,a,u;const n=()=>{z(this,We,ft).call(this,{type:"continue"})},r={client:l(this,on),meta:this.options.meta,mutationKey:this.options.mutationKey};_(this,Mt,cs({fn:()=>this.options.mutationFn?this.options.mutationFn(t,r):Promise.reject(new Error("No mutationFn found")),onFail:(c,A)=>{z(this,We,ft).call(this,{type:"failed",failureCount:c,error:A})},onPause:()=>{z(this,We,ft).call(this,{type:"pause"})},onContinue:n,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>l(this,we).canRun(this)}));const s=this.state.status==="pending",i=!l(this,Mt).canStart();try{if(s)n();else{z(this,We,ft).call(this,{type:"pending",variables:t,isPaused:i}),await((d=(o=l(this,we).config).onMutate)==null?void 0:d.call(o,t,this,r));const A=await((h=(p=this.options).onMutate)==null?void 0:h.call(p,t,r));A!==this.state.context&&z(this,We,ft).call(this,{type:"pending",context:A,variables:t,isPaused:i})}const c=await l(this,Mt).start();return await((E=(C=l(this,we).config).onSuccess)==null?void 0:E.call(C,c,t,this.state.context,this,r)),await((P=(x=this.options).onSuccess)==null?void 0:P.call(x,c,t,this.state.context,r)),await((O=(I=l(this,we).config).onSettled)==null?void 0:O.call(I,c,null,this.state.variables,this.state.context,this,r)),await((B=(M=this.options).onSettled)==null?void 0:B.call(M,c,null,t,this.state.context,r)),z(this,We,ft).call(this,{type:"success",data:c}),c}catch(c){try{throw await((K=(F=l(this,we).config).onError)==null?void 0:K.call(F,c,t,this.state.context,this,r)),await((Z=(U=this.options).onError)==null?void 0:Z.call(U,c,t,this.state.context,r)),await((oe=(Y=l(this,we).config).onSettled)==null?void 0:oe.call(Y,void 0,c,this.state.variables,this.state.context,this,r)),await((u=(a=this.options).onSettled)==null?void 0:u.call(a,void 0,c,t,this.state.context,r)),c}finally{z(this,We,ft).call(this,{type:"error",error:c})}}finally{l(this,we).runNext(this)}}},on=new WeakMap,He=new WeakMap,we=new WeakMap,Mt=new WeakMap,We=new WeakSet,ft=function(t){const n=r=>{switch(t.type){case"failed":return{...r,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...r,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:t.error,failureCount:r.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=n(this.state),ce.batch(()=>{l(this,He).forEach(r=>{r.onMutationUpdate(t)}),l(this,we).notify({mutation:this,type:"updated",action:t})})},Us);function As(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var ro=(Rs=class extends Nt{constructor(t={}){super();N(this,Ge);N(this,Le);N(this,un);this.config=t,_(this,Ge,new Set),_(this,Le,new Map),_(this,un,0)}build(t,n,r){const s=new no({client:t,mutationCache:this,mutationId:++Fn(this,un)._,options:t.defaultMutationOptions(n),state:r});return this.add(s),s}add(t){l(this,Ge).add(t);const n=xn(t);if(typeof n=="string"){const r=l(this,Le).get(n);r?r.push(t):l(this,Le).set(n,[t])}this.notify({type:"added",mutation:t})}remove(t){if(l(this,Ge).delete(t)){const n=xn(t);if(typeof n=="string"){const r=l(this,Le).get(n);if(r)if(r.length>1){const s=r.indexOf(t);s!==-1&&r.splice(s,1)}else r[0]===t&&l(this,Le).delete(n)}}this.notify({type:"removed",mutation:t})}canRun(t){const n=xn(t);if(typeof n=="string"){const r=l(this,Le).get(n),s=r==null?void 0:r.find(i=>i.state.status==="pending");return!s||s===t}else return!0}runNext(t){var r;const n=xn(t);if(typeof n=="string"){const s=(r=l(this,Le).get(n))==null?void 0:r.find(i=>i!==t&&i.state.isPaused);return(s==null?void 0:s.continue())??Promise.resolve()}else return Promise.resolve()}clear(){ce.batch(()=>{l(this,Ge).forEach(t=>{this.notify({type:"removed",mutation:t})}),l(this,Ge).clear(),l(this,Le).clear()})}getAll(){return Array.from(l(this,Ge))}find(t){const n={exact:!0,...t};return this.getAll().find(r=>rs(n,r))}findAll(t={}){return this.getAll().filter(n=>rs(t,n))}notify(t){ce.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){const t=this.getAll().filter(n=>n.state.isPaused);return ce.batch(()=>Promise.all(t.map(n=>n.continue().catch(be))))}},Ge=new WeakMap,Le=new WeakMap,un=new WeakMap,Rs);function xn(e){var t;return(t=e.options.scope)==null?void 0:t.id}var so=(Ls=class extends Nt{constructor(t,n){super();N(this,Ye);N(this,Xe);N(this,dt);N(this,Pe);N(this,Ze);_(this,Xe,t),this.setOptions(n),this.bindMethods(),z(this,Ye,Dn).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){var r;const n=this.options;this.options=l(this,Xe).defaultMutationOptions(t),Tn(this.options,n)||l(this,Xe).getMutationCache().notify({type:"observerOptionsUpdated",mutation:l(this,Pe),observer:this}),n!=null&&n.mutationKey&&this.options.mutationKey&&Ct(n.mutationKey)!==Ct(this.options.mutationKey)?this.reset():((r=l(this,Pe))==null?void 0:r.state.status)==="pending"&&l(this,Pe).setOptions(this.options)}onUnsubscribe(){var t;this.hasListeners()||(t=l(this,Pe))==null||t.removeObserver(this)}onMutationUpdate(t){z(this,Ye,Dn).call(this),z(this,Ye,xr).call(this,t)}getCurrentResult(){return l(this,dt)}reset(){var t;(t=l(this,Pe))==null||t.removeObserver(this),_(this,Pe,void 0),z(this,Ye,Dn).call(this),z(this,Ye,xr).call(this)}mutate(t,n){var r;return _(this,Ze,n),(r=l(this,Pe))==null||r.removeObserver(this),_(this,Pe,l(this,Xe).getMutationCache().build(l(this,Xe),this.options)),l(this,Pe).addObserver(this),l(this,Pe).execute(t)}},Xe=new WeakMap,dt=new WeakMap,Pe=new WeakMap,Ze=new WeakMap,Ye=new WeakSet,Dn=function(){var n;const t=((n=l(this,Pe))==null?void 0:n.state)??As();_(this,dt,{...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset})},xr=function(t){ce.batch(()=>{var n,r,s,i,o,d,p,h;if(l(this,Ze)&&this.hasListeners()){const C=l(this,dt).variables,E=l(this,dt).context,x={client:l(this,Xe),meta:this.options.meta,mutationKey:this.options.mutationKey};(t==null?void 0:t.type)==="success"?((r=(n=l(this,Ze)).onSuccess)==null||r.call(n,t.data,C,E,x),(i=(s=l(this,Ze)).onSettled)==null||i.call(s,t.data,null,C,E,x)):(t==null?void 0:t.type)==="error"&&((d=(o=l(this,Ze)).onError)==null||d.call(o,t.error,C,E,x),(h=(p=l(this,Ze)).onSettled)==null||h.call(p,void 0,t.error,C,E,x))}this.listeners.forEach(C=>{C(l(this,dt))})})},Ls),io=(Ns=class extends Nt{constructor(t={}){super();N(this,Qe);this.config=t,_(this,Qe,new Map)}build(t,n,r){const s=n.queryKey,i=n.queryHash??tr(s,n);let o=this.get(i);return o||(o=new Za({client:t,queryKey:s,queryHash:i,options:t.defaultQueryOptions(n),state:r,defaultOptions:t.getQueryDefaults(s)}),this.add(o)),o}add(t){l(this,Qe).has(t.queryHash)||(l(this,Qe).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const n=l(this,Qe).get(t.queryHash);n&&(t.destroy(),n===t&&l(this,Qe).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){ce.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return l(this,Qe).get(t)}getAll(){return[...l(this,Qe).values()]}find(t){const n={exact:!0,...t};return this.getAll().find(r=>ns(n,r))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(r=>ns(t,r)):n}notify(t){ce.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){ce.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){ce.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Qe=new WeakMap,Ns),ao=(qs=class{constructor(e={}){N(this,se);N(this,lt);N(this,pt);N(this,Vt);N(this,Gt);N(this,ht);N(this,Xt);N(this,Zt);_(this,se,e.queryCache||new io),_(this,lt,e.mutationCache||new ro),_(this,pt,e.defaultOptions||{}),_(this,Vt,new Map),_(this,Gt,new Map),_(this,ht,0)}mount(){Fn(this,ht)._++,l(this,ht)===1&&(_(this,Xt,ir.subscribe(async e=>{e&&(await this.resumePausedMutations(),l(this,se).onFocus())})),_(this,Zt,Cn.subscribe(async e=>{e&&(await this.resumePausedMutations(),l(this,se).onOnline())})))}unmount(){var e,t;Fn(this,ht)._--,l(this,ht)===0&&((e=l(this,Xt))==null||e.call(this),_(this,Xt,void 0),(t=l(this,Zt))==null||t.call(this),_(this,Zt,void 0))}isFetching(e){return l(this,se).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return l(this,lt).findAll({...e,status:"pending"}).length}getQueryData(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=l(this,se).get(t.queryHash))==null?void 0:n.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=l(this,se).build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(st(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return l(this,se).findAll(e).map(({queryKey:t,state:n})=>{const r=n.data;return[t,r]})}setQueryData(e,t,n){const r=this.defaultQueryOptions({queryKey:e}),s=l(this,se).get(r.queryHash),i=s==null?void 0:s.state.data,o=Ka(t,i);if(o!==void 0)return l(this,se).build(this,r).setData(o,{...n,manual:!0})}setQueriesData(e,t,n){return ce.batch(()=>l(this,se).findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,n)]))}getQueryState(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=l(this,se).get(t.queryHash))==null?void 0:n.state}removeQueries(e){const t=l(this,se);ce.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=l(this,se);return ce.batch(()=>(n.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},r=ce.batch(()=>l(this,se).findAll(e).map(s=>s.cancel(n)));return Promise.all(r).then(be).catch(be)}invalidateQueries(e,t={}){return ce.batch(()=>(l(this,se).findAll(e).forEach(n=>{n.invalidate()}),(e==null?void 0:e.refetchType)==="none"?Promise.resolve():this.refetchQueries({...e,type:(e==null?void 0:e.refetchType)??(e==null?void 0:e.type)??"active"},t)))}refetchQueries(e,t={}){const n={...t,cancelRefetch:t.cancelRefetch??!0},r=ce.batch(()=>l(this,se).findAll(e).filter(s=>!s.isDisabled()&&!s.isStatic()).map(s=>{let i=s.fetch(void 0,n);return n.throwOnError||(i=i.catch(be)),s.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(r).then(be)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=l(this,se).build(this,t);return n.isStaleByTime(st(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(be).catch(be)}fetchInfiniteQuery(e){return e.behavior=ys(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(be).catch(be)}ensureInfiniteQueryData(e){return e.behavior=ys(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return Cn.isOnline()?l(this,lt).resumePausedMutations():Promise.resolve()}getQueryCache(){return l(this,se)}getMutationCache(){return l(this,lt)}getDefaultOptions(){return l(this,pt)}setDefaultOptions(e){_(this,pt,e)}setQueryDefaults(e,t){l(this,Vt).set(Ct(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...l(this,Vt).values()],n={};return t.forEach(r=>{tn(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){l(this,Gt).set(Ct(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...l(this,Gt).values()],n={};return t.forEach(r=>{tn(e,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...l(this,pt).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=tr(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===wn&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...l(this,pt).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){l(this,se).clear(),l(this,lt).clear()}},se=new WeakMap,lt=new WeakMap,pt=new WeakMap,Vt=new WeakMap,Gt=new WeakMap,ht=new WeakMap,Xt=new WeakMap,Zt=new WeakMap,qs),Es=ue.createContext(void 0),dr=e=>{const t=ue.useContext(Es);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},oo=({client:e,children:t})=>(ue.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),H.jsx(Es.Provider,{value:e,children:t})),bs=ue.createContext(!1),uo=()=>ue.useContext(bs);bs.Provider;function co(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var lo=ue.createContext(co()),po=()=>ue.useContext(lo),ho=(e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))},fo=e=>{ue.useEffect(()=>{e.clearReset()},[e])},mo=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:s})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(s&&e.data===void 0||os(n,[e.error,r])),yo=e=>{if(e.suspense){const n=s=>s==="static"?s:Math.max(s??1e3,1e3),r=e.staleTime;e.staleTime=typeof r=="function"?(...s)=>n(r(...s)):n(r),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},go=(e,t)=>e.isLoading&&e.isFetching&&!t,Ao=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,Ts=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function Eo(e,t,n){var E,x,P,I,O;if(process.env.NODE_ENV!=="production"&&(typeof e!="object"||Array.isArray(e)))throw new Error('Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object');const r=uo(),s=po(),i=dr(),o=i.defaultQueryOptions(e);(x=(E=i.getDefaultOptions().queries)==null?void 0:E._experimental_beforeQuery)==null||x.call(E,o),process.env.NODE_ENV!=="production"&&(o.queryFn||console.error(`[${o.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`)),o._optimisticResults=r?"isRestoring":"optimistic",yo(o),ho(o,s),fo(s);const d=!i.getQueryCache().get(o.queryHash),[p]=ue.useState(()=>new t(i,o)),h=p.getOptimisticResult(o),C=!r&&e.subscribed!==!1;if(ue.useSyncExternalStore(ue.useCallback(M=>{const B=C?p.subscribe(ce.batchCalls(M)):be;return p.updateResult(),B},[p,C]),()=>p.getCurrentResult(),()=>p.getCurrentResult()),ue.useEffect(()=>{p.setOptions(o)},[o,p]),Ao(o,h))throw Ts(o,p,s);if(mo({result:h,errorResetBoundary:s,throwOnError:o.throwOnError,query:i.getQueryCache().get(o.queryHash),suspense:o.suspense}))throw h.error;if((I=(P=i.getDefaultOptions().queries)==null?void 0:P._experimental_afterQuery)==null||I.call(P,o,h),o.experimental_prefetchInRender&&!wt&&go(h,r)){const M=d?Ts(o,p,s):(O=i.getQueryCache().get(o.queryHash))==null?void 0:O.promise;M==null||M.catch(be).finally(()=>{p.updateResult()})}return o.notifyOnChangeProps?h:p.trackResult(h)}function bo(e,t){return Eo(e,Ya)}function it(e,t){const n=dr(),[r]=ue.useState(()=>new so(n,e));ue.useEffect(()=>{r.setOptions(e)},[r,e]);const s=ue.useSyncExternalStore(ue.useCallback(o=>r.subscribe(ce.batchCalls(o)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),i=ue.useCallback((o,d)=>{r.mutate(o,d).catch(be)},[r]);if(s.error&&os(r.options.throwOnError,[s.error]))throw s.error;return{...s,mutate:i,mutateAsync:s.mutate}}const nn=()=>{const e=Q(i=>i.state.swapExecutionIndex),t=Q(i=>i.state.swapExecutions[i.state.swapExecutionIndex]??{}),n=Q(i=>i.updateSwapExecutionAtIndex),r=Q(i=>i.resetSwapExecutionAtIndex),s=v.useCallback(i=>n(e,i),[n,e]);return v.useMemo(()=>({...t,update:s,resetSwap:r}),[t,s,r])},To=2e4,wo=()=>{const{module:e}=q(),t=Q(n=>n.state.isMarketOrder);return v.useMemo(()=>e===j.TWAP?t?V.TWAP_MARKET:V.TWAP_LIMIT:e===j.LIMIT?V.LIMIT:e===j.STOP_LOSS?t?V.STOP_LOSS_MARKET:V.STOP_LOSS_LIMIT:e===j.TAKE_PROFIT?t?V.TAKE_PROFIT_MARKET:V.TAKE_PROFIT_LIMIT:V.TWAP_MARKET,[e,t])},ws=()=>{const{account:e,config:t,chainId:n,isDev:r}=q();return v.useMemo(()=>["useTwapOrderHistoryManager",e,t==null?void 0:t.adapter,n,r],[e,t,n,r])},Co=()=>{const{callbacks:e}=q(),t=dr(),n=ws();return v.useCallback(r=>{var d;const s=t.getQueryData(n);let i=!1;const o=[];s&&s.filter(p=>p.version===2).forEach(p=>{var C;const h=r.find(E=>E.id===p.id);h&&h.progress!==p.progress&&(i=!0,o.push(h),h.status===fe.Completed&&((C=e==null?void 0:e.onOrderFilled)==null||C.call(e,h)))}),i&&((d=e==null?void 0:e.onOrdersProgressUpdate)==null||d.call(e,o))},[t,n,e])},lr=()=>{const{account:e,config:t,chainId:n,isDev:r}=q(),s=ws(),i=Co();return bo({refetchInterval:To,refetchOnWindowFocus:!0,retry:!1,staleTime:1/0,queryKey:s,queryFn:async({signal:d})=>{if(!e||!n||!t)return[];const p=await da({signal:d,chainId:n,config:t,account:e,isDev:r});return i(p),p.map(h=>t!=null&&t.twapConfig?{...h,fillDelayMillis:Nn(h,t.twapConfig)}:h)}})},xo=(e,t,n)=>v.useMemo(()=>{if(!(!e||!t||!n||n!=null&&n.isMarketPrice))return _r(n,e==null?void 0:e.decimals,t==null?void 0:t.decimals)},[n,e,t]),So=(e,t,n)=>v.useMemo(()=>{if(!(!e||!t||!n))return Br(n,e.decimals,t.decimals)},[n,e,t]),vo=(e,t,n)=>v.useMemo(()=>{if(!(!e||!t||!n))return qn(n.srcAmountFilled,n.dstAmountFilled,e.decimals,t.decimals)},[n,e,t]),Sn=(e,t)=>[...e.filter(r=>r.status===t)].sort((r,s)=>s.createdAt-r.createdAt),Po=()=>{const{data:e,isLoading:t,refetch:n,isRefetching:r}=lr(),s=v.useCallback(()=>n().then(i=>i.data),[n]);return v.useMemo(()=>({orders:{all:e??[],open:Sn(e??[],fe.Open),completed:Sn(e??[],fe.Completed),cancelled:Sn(e??[],fe.Cancelled),expired:Sn(e??[],fe.Expired)},isLoading:t,isRefetching:r,refetchOrders:s}),[e,t,r,s])},pr=()=>{const e=Q(n=>n.state.currentTime),t=Zn().duration;return v.useMemo(()=>Ci(e,t),[e,t])},Cs=()=>{const{srcToken:e,dstToken:t,account:n,chainId:r,slippage:s,config:i,module:o,fees:d}=q(),{amount:p}=rt(),{amountPerTrade:h,totalTrades:C}=qe(),E=pr(),{amount:x}=Jn(),{pricePerChunk:P}=bt(),{milliseconds:I}=Lt();return v.useMemo(()=>{var O;return Nr({chainId:r,srcToken:Ut((e==null?void 0:e.address)||"")?((O=At(r))==null?void 0:O.wToken.address)||"":(e==null?void 0:e.address)||"",dstToken:(t==null?void 0:t.address)||"",srcAmount:p,deadlineMillis:E,fillDelayMillis:!C||C===1?0:I,slippage:s*100,account:n,srcAmountPerTrade:h,dstMinAmountPerTrade:x,triggerAmountPerTrade:P,config:i,module:o})},[e,t,n,r,s,i,o,p,h,C,I,x,P,d])};function Fo(e){const t=e.slice(2);if(t.length===128){const i=`0x${t.slice(0,64)}`,o=parseInt(t.charAt(64),16),d=(o>>3)+27,p=`0x${(o&7).toString(16)}${t.slice(65,128)}`;return{r:i,s:p,v:d}}const n=`0x${t.slice(0,64)}`,r=`0x${t.slice(64,128)}`,s=parseInt(t.slice(128,130),16);return{r:n,s:r,v:s}}const Do=()=>{var i;const{account:e,walletInteractions:t,callbacks:n,chainId:r}=q(),s=(i=gn())==null?void 0:i.wToken;return it({mutationFn:async({onHash:o,srcAmountWei:d})=>{var h,C;if(!e)throw new Error("missing account");if(!t)throw new Error("missing walletInteractions");if(!s)throw new Error("tokenAddress is not defined");pe.onWrapRequest();const p=await t.wrapNativeToken(d);return(h=n==null?void 0:n.onWrapRequest)==null||h.call(n),o==null||o(p),pe.onWrapSuccess(p),(C=n==null?void 0:n.onWrapSuccess)==null||C.call(n,{txHash:p,explorerUrl:Rt(p,r),amount:Ee(d,s.decimals)}),p},onError:o=>{throw pe.onWrapError(o),o}})},xs=()=>{const{account:e,walletInteractions:t,chainId:n,callbacks:r}=q(),s=Cs(),{refetch:i}=lr();return it({mutationFn:async()=>{var I,O,M,B;if(!e)throw new Error("missing account");if(!t)throw new Error("missing walletInteractions");if(!n)throw new Error("missing chainId");const{order:o,domain:d,types:p,primaryType:h}=s;pe.onSignOrderRequest(o);let C;try{C=await t.signOrder({domain:d,types:p,primaryType:h,message:o,account:e})}catch(F){throw(I=r==null?void 0:r.onSignOrderError)==null||I.call(r,F),pe.onSignOrderError(F),F}pe.onSignOrderSuccess(C),(O=r==null?void 0:r.onSignOrderSuccess)==null||O.call(r,C);const E=Fo(C),x={v:`0x${E.v.toString(16)}`,r:E.r,s:E.s};(M=r==null?void 0:r.onSignOrderRequest)==null||M.call(r);const P=await Hr(o,x);return(B=r==null?void 0:r.onOrderCreated)==null||B.call(r,P),await i(),P}})},Ss=()=>{const{account:e,walletInteractions:t,config:n}=q();return it({mutationFn:async({tokenAddress:r,srcAmountWei:s})=>{if(!t)throw new Error("missing walletInteractions");if(!e)throw new Error("missing account");if(!n)throw new Error("missing config");const i=await t.getAllowance({tokenAddress:r,spenderAddress:n.repermit}),o=S(i||"0").lt(S(s).toString());return{allowance:i,approvalRequired:o}}})},Oo=()=>{const{account:e,walletInteractions:t,config:n,chainId:r,callbacks:s}=q(),{mutateAsync:i}=Ss();return it({onError:o=>{pe.onApproveError(o)},mutationFn:async({token:o,onHash:d,srcAmountWei:p})=>{var E,x;if(!e)throw new Error("missing account");if(!t)throw new Error("missing walletInteractions");if(!n)throw new Error("missing config");pe.onApproveRequest();const h=await t.approveToken({tokenAddress:o.address,amount:p,spenderAddress:n.repermit});if(!h)throw new Error("failed to approve token");(E=s==null?void 0:s.onApproveRequest)==null||E.call(s),d(h);let C=!1;for(let P=0;P<3;P++){const{approvalRequired:I}=await i({tokenAddress:o.address,srcAmountWei:p});if(!I){C=!0;break}P<2&&await new Promise(O=>setTimeout(O,3e3))}if(!C)throw new Error(`Insufficient ${o.symbol} allowance to perform the swap. Please approve the token first.`);return pe.onApproveSuccess(h),(x=s==null?void 0:s.onApproveSuccess)==null||x.call(s,{txHash:h,explorerUrl:Rt(h,r),token:o,amount:Ee(p,o.decimals)}),h}})},Io=()=>{const{account:e,chainId:t,srcToken:n,dstToken:r,module:s,slippage:i}=q(),o=bt(),d=rt().amount,p=qe().amountPerTrade,h=pr(),C=qe().totalTrades,E=Lt().fillDelay,x=Jn().amount,P=Q(I=>I.state.isMarketOrder);return it({mutationFn:async()=>{pe.onRequestOrder({account:e,chainId:t,module:s,srcToken:n,dstToken:r,fromTokenAmount:d,srcChunkAmount:p,triggerPricePerTrade:o.pricePerChunk,deadline:h,fillDelay:E.unit*E.value,minDstAmountOutPerTrade:x,slippage:i,isMarketOrder:P||!1,chunksAmount:C})}})};function ko(e){const t=e.message,n=t.match(/,\s*code\s*:\s*(\d+)/i);return{message:t.replace(/^error\s*:/i,"").replace(/,\s*code\s*:\s*\d+/i,"").trim()||"",code:n?Number(n[1]):0}}const vs=()=>{const{srcToken:e,dstToken:t,chainId:n,callbacks:r,marketPrice:s}=q(),i=Oo().mutateAsync,o=Do().mutateAsync,d=xs().mutateAsync,{mutateAsync:p}=Ss(),{update:h}=nn(),{amount:C}=rt(),E=Io().mutate;return it({mutationFn:async()=>{var P,I;const x=Ut((e==null?void 0:e.address)||" ");try{if(!e)throw new Error("missing srcToken");if(!t)throw new Error("missing dstToken");if(!n)throw new Error("missing chainId");const O=Gr(e,n);h({allowanceLoading:!0,wrapTxHash:void 0,approveTxHash:void 0,acceptedMarketPrice:s,acceptedSrcAmount:C,srcToken:e,dstToken:t,pendingSteps:[]});const{approvalRequired:M}=await p({tokenAddress:O.address,srcAmountWei:C});let B=0,F=1;x&&F++,M&&F++,h({totalSteps:F,stepIndex:B,allowanceLoading:!1,hasApproval:!M,status:Se.LOADING}),E();let K=[];x&&K.push(tt.WRAP),M&&K.push(tt.APPROVE),K.push(tt.CREATE),h({pendingSteps:K}),x&&(h({step:tt.WRAP}),await o({onHash:Z=>h({wrapTxHash:Z}),srcAmountWei:C}),B++,h({stepIndex:B})),M&&(h({step:tt.APPROVE}),await i({token:O,onHash:Z=>h({approveTxHash:Z}),srcAmountWei:C}),B++,h({stepIndex:B})),h({step:tt.CREATE});const U=await d();return h({status:Se.SUCCESS,orderId:U.id}),U}catch(O){if($n(O))(P=r==null?void 0:r.onSubmitOrderRejected)==null||P.call(r),h({step:void 0,status:void 0,stepIndex:void 0,error:O});else{const M=ko(O);(I=r==null?void 0:r.onSubmitOrderFailed)==null||I.call(r,M),h({status:Se.FAILED,parsedError:M,error:O})}throw O}}})},Mo=()=>{const e=nn(),{srcToken:t,dstToken:n}=q(),r=vs(),s=Q(h=>h.resetState),i=v.useCallback(()=>r.mutateAsync(),[r]),{update:o,resetSwap:d,...p}=e;return v.useMemo(()=>({status:p.status,parsedError:p.parsedError,error:p.error,step:p.step,stepIndex:p.stepIndex,approveTxHash:p.approveTxHash,wrapTxHash:p.wrapTxHash,totalSteps:p.totalSteps,pendingSteps:p.pendingSteps,srcToken:t,dstToken:n,onSubmit:i,resetState:s,resetCurrentSwap:d,isLoading:(e==null?void 0:e.status)===Se.LOADING,isSuccess:(e==null?void 0:e.status)===Se.SUCCESS,isFailed:(e==null?void 0:e.status)===Se.FAILED,confirmButtonLoading:p.allowanceLoading}),[i,p,s,d,t,n])},_o=()=>{const{marketPrice:e,srcToken:t,dstToken:n,marketPriceLoading:r,srcBalance:s,srcUsd1Token:i,noLiquidity:o,typedInputAmount:d}=q(),p=r||S(i||"0").isZero()||s===void 0||S(e||"0").isZero(),h=!!(t&&n&&d&&p),E=!!(es()||o||h||S(d||"0").isZero()||!t||!n);return v.useMemo(()=>({disabled:E,loading:h}),[E,h])},Bo=()=>{const{srcUsd1Token:e,dstUsd1Token:t}=q(),n=rt().amountUI,r=bn().amountUI,s=nt(n,e),i=nt(r,t);return{srcAmountUsd:s,dstAmountUsd:i}},Uo=()=>{const{fees:e,dstToken:t,dstUsd1Token:n}=q(),{amountUI:r}=bn(),s=v.useMemo(()=>!e||!r?"":S(r).multipliedBy(e).dividedBy(100).toFixed(),[r,e]),i=Xn((t==null?void 0:t.decimals)||0,s);return{amountUI:s,amount:i,percent:e,usd:nt(s,n)}},Ro=e=>{const t=v.useMemo(()=>!e.minDestAmountPerTrade||!e.totalTrades?"":S(e.minDestAmountPerTrade).multipliedBy(e.totalTrades).decimalPlaces(0).toFixed(),[e.minDestAmountPerTrade,e.totalTrades]),n=v.useMemo(()=>!e.minDestAmountPerTradeUI||!e.totalTrades?"":S(e.minDestAmountPerTradeUI).multipliedBy(e.totalTrades).toFixed(),[e.minDestAmountPerTradeUI,e.totalTrades]),r=v.useMemo(()=>!e.minDestAmountPerTradeUsd||!e.totalTrades?"":S(e.minDestAmountPerTradeUsd).multipliedBy(e.totalTrades).decimalPlaces(2).toFixed(),[e.minDestAmountPerTradeUsd,e.totalTrades]);return v.useMemo(()=>({srcToken:e.srcToken,dstToken:e.dstToken,orderType:e.orderType,createdAt:e.createdAt||0,deadline:e.deadline||0,totalTrades:e.totalTrades||0,tradeInterval:e.tradeInterval||0,recipient:e.account||"",srcAmount:e.srcAmount||"",srcAmountUI:e.srcAmountUI||"",srcAmountUsd:e.srcAmountUsd||"",dstAmount:e.dstAmount||"",dstAmountUI:e.dstAmountUI||"",dstAmountUsd:e.dstAmountUsd||"",limitPrice:e.limitPrice||"",limitPriceUI:e.limitPriceUI||"",limitPriceUsd:e.limitPriceUsd||"",sizePerTrade:e.srcAmountPerTrade||"",sizePerTradeUI:e.srcAmountPerTradeUI||"",sizePerTradeUsd:e.srcAmountPerTradeUsd,minDestAmountPerTrade:e.minDestAmountPerTrade||"",minDestAmountPerTradeUI:e.minDestAmountPerTradeUI||"",minDestAmountPerTradeUsd:e.minDestAmountPerTradeUsd,dstMinAmount:t,dstMinAmountUI:n,dstMinAmountUsd:r,triggerPrice:e.triggerPrice||"",triggerPriceUI:e.triggerPriceUI||"",triggerPriceUsd:e.triggerPriceUsd}),[e.srcToken,e.dstToken,e.orderType,e.createdAt,e.deadline,e.totalTrades,e.tradeInterval,e.account,e.srcAmount,e.srcAmountUI,e.srcAmountUsd,e.dstAmount,e.dstAmountUI,e.dstAmountUsd,e.limitPrice,e.limitPriceUI,e.limitPriceUsd,e.srcAmountPerTrade,e.srcAmountPerTradeUI,e.srcAmountPerTradeUsd,e.minDestAmountPerTrade,e.minDestAmountPerTradeUI,e.minDestAmountPerTradeUsd,t,n,r,e.triggerPrice,e.triggerPriceUI,e.triggerPriceUsd])},Lo=()=>{const{config:e}=q();return v.useMemo(()=>({spender:e.repermit}),[e])},No=()=>{const{srcToken:e,dstToken:t,account:n,marketPrice:r}=q(),{spender:s}=Lo(),{amount:i}=rt(),{amount:o,amountUI:d,usd:p}=En(),{amountPerTrade:h,amountPerTradeUI:C,amountPerTradeUsd:E,totalTrades:x}=qe(),P=pr(),{amount:I,amountUI:O,usd:M}=Jn(),{amountUI:B,amount:F,usd:K}=bt(),{milliseconds:U}=Lt(),{amount:Z,amountUI:Y}=bn(),{srcAmountUsd:oe,dstAmountUsd:a}=Bo(),{amount:u,amountUI:c,percent:A,usd:m}=Uo(),y=Cs(),w=Q(G=>G.state.isMarketOrder),f=Q(G=>G.state.currentTime),g=nn(),T=wo(),b=g.acceptedSrcAmount||i,D=Ee(r,(t==null?void 0:t.decimals)||0),R=v.useMemo(()=>T===V.TAKE_PROFIT_MARKET||T===V.TAKE_PROFIT_LIMIT||T===V.STOP_LOSS_LIMIT||T===V.STOP_LOSS_MARKET,[T]),L=Ro({srcToken:e,dstToken:t,account:n,orderType:T,createdAt:f,deadline:P,totalTrades:x,tradeInterval:U,srcAmount:b,srcAmountUI:Ee(b,(e==null?void 0:e.decimals)||0),srcAmountUsd:oe,dstAmount:Z,dstAmountUI:Y,dstAmountUsd:a,limitPrice:w?void 0:o,limitPriceUI:w?void 0:d,limitPriceUsd:w?void 0:p,srcAmountPerTrade:h,srcAmountPerTradeUI:C,srcAmountPerTradeUsd:E,minDestAmountPerTrade:I,minDestAmountPerTradeUI:O,minDestAmountPerTradeUsd:M,triggerPrice:F,triggerPriceUI:B,triggerPriceUsd:K});return v.useMemo(()=>({...L,feesAmountUI:c,feesAmount:u,feesUsd:m||"",feesPercentage:A,rePermitData:y,isTriggerPrice:R,isMarketOrder:w,marketPrice:r,marketPriceUi:D,spender:s}),[L,c,u,m,A,y,R,w,r,D,s])},qo=()=>{const{supportedChains:e}=q();return v.useMemo(()=>e,[e])},Ko=60,Ps=()=>{const{refetch:e}=lr();return it({mutationFn:async t=>{var n;for(let r=0;r<Ko;r++){const s=(n=await e())==null?void 0:n.data;if(!s)throw new Error("orders not found");const i=s.find(o=>o.id===t);if((i==null?void 0:i.status)===fe.Cancelled)return;await new Promise(o=>setTimeout(o,1e3))}throw new Error("Timed out waiting for order cancellation to be confirmed")}})},Ho=()=>{const e=Q(n=>n.updateState),t=Q(n=>n.state.cancelOrders);return{cancelOrders:t,setCancelOrder:(n,r)=>{e({cancelOrders:{...t,[n]:r}})},clearCancelOrder:n=>{const{[n]:r,...s}=t;e({cancelOrders:s})}}},Wo=e=>{const{account:t,walletInteractions:n,config:r,callbacks:s,chainId:i}=q(),o=Ps().mutateAsync,{cancelOrders:d,setCancelOrder:p,clearCancelOrder:h}=Ho(),{mutateAsync:C}=it({mutationFn:async()=>{var I,O,M;if(!t||!n||!r)throw new Error("missing required parameters");if(!e)throw new Error("order is required");const P=e.id;try{(I=s==null?void 0:s.onCancelOrderRequest)==null||I.call(s,e),p(P,{status:Se.LOADING}),pe.onCancelOrderRequest([e.version===1?e.id.toString():e.hash],e.version);const B=await n.cancelOrder({order:e,contractAddress:e.version===1?e.twapAddress:r.repermit,args:e.version===1?[e.id]:[[e.hash]],abi:e.version===1?js:Qs});if(!B)throw new Error("failed to cancel order");return pe.onCancelOrderSuccess(B),await o(e.id),(O=s==null?void 0:s.onCancelOrderSuccess)==null||O.call(s,{order:e,txHash:B,explorerUrl:Rt(B,i)}),p(P,{status:Se.SUCCESS,txHash:B}),B}catch(B){console.error("cancel order error",B),(M=s==null?void 0:s.onCancelOrderFailed)==null||M.call(s,B),$n(B)?h(P):(p(P,{status:Se.FAILED,error:B.message}),pe.onCancelOrderError(B))}}}),E=v.useMemo(()=>{const P=d[(e==null?void 0:e.id)||""];return{isLoading:(P==null?void 0:P.status)===Se.LOADING,isSuccess:(P==null?void 0:P.status)===Se.SUCCESS,isError:(P==null?void 0:P.status)===Se.FAILED,error:P==null?void 0:P.error,txHash:P==null?void 0:P.txHash}},[d,e==null?void 0:e.id]),x=v.useCallback(async()=>C(),[C]);return v.useMemo(()=>({cancelOrder:x,...E}),[x,E])},Fs=v.createContext(null),Qo=({children:e})=>{const t=Ca(),n=Pa(),r=Sa(),s=Ma(),i=_a(),o=An(),d=Ba(),p=Ua(),h=es(),C=_o(),E=No(),x=Po(),P=Mo(),I=qo(),O=Ps(),{module:M}=q(),B={tradesAmountPanel:t,durationPanel:n,fillDelayPanel:r,limitPricePanel:s,triggerPricePanel:i,pricePanel:o,dstTokenPanel:d,disclaimerPanel:p,inputError:h,submitOrderButton:C,derivedFormData:E,orderHistoryPanel:x,orderExecutionPanel:P,supportedChains:I,refetchUntilStatusSynced:O,module:M};return H.jsx(Fs.Provider,{value:B,children:e})},jo=()=>{const e=v.useContext(Fs);if(e===null)throw new Error("useSpot must be used within SpotProvider");return e},zo=v.createContext(null),hr={didCatch:!1,error:null};class $o extends v.Component{constructor(t){super(t),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=hr}static getDerivedStateFromError(t){return{didCatch:!0,error:t}}resetErrorBoundary(){const{error:t}=this.state;if(t!==null){for(var n,r,s=arguments.length,i=new Array(s),o=0;o<s;o++)i[o]=arguments[o];(n=(r=this.props).onReset)===null||n===void 0||n.call(r,{args:i,reason:"imperative-api"}),this.setState(hr)}}componentDidCatch(t,n){var r,s;(r=(s=this.props).onError)===null||r===void 0||r.call(s,t,n)}componentDidUpdate(t,n){const{didCatch:r}=this.state,{resetKeys:s}=this.props;if(r&&n.error!==null&&Vo(t.resetKeys,s)){var i,o;(i=(o=this.props).onReset)===null||i===void 0||i.call(o,{next:s,prev:t.resetKeys,reason:"keys"}),this.setState(hr)}}render(){const{children:t,fallbackRender:n,FallbackComponent:r,fallback:s}=this.props,{didCatch:i,error:o}=this.state;let d=t;if(i){const p={error:o,resetErrorBoundary:this.resetErrorBoundary};if(typeof n=="function")d=n(p);else if(r)d=v.createElement(r,p);else if(s!==void 0)d=s;else throw o}return v.createElement(zo.Provider,{value:{didCatch:i,error:o,resetErrorBoundary:this.resetErrorBoundary}},d)}}function Vo(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return e.length!==t.length||e.some((n,r)=>!Object.is(n,t[r]))}const Go=()=>H.jsx("div",{className:"twap-error-fallback",children:H.jsx("p",{style:{fontSize:20,fontWeight:600,textAlign:"center",width:"100%",marginTop:40},children:"Something went wrong"})});function Xo({children:e}){return H.jsx($o,{FallbackComponent:Go,onError:t=>pe.onCrash(t),children:H.jsx(H.Fragment,{children:e})})}const Ds=v.createContext(null),Zo=new ao({defaultOptions:{queries:{refetchOnWindowFocus:!1}}}),Yo=e=>{var r,s,i;const t=Q(o=>o.updateState),n=Q(o=>o.state.isMarketOrder);return v.useEffect(()=>{const o=setInterval(()=>{t({currentTime:Date.now()})},6e4);return()=>clearInterval(o)},[t]),v.useEffect(()=>{var d,p,h,C,E,x,P,I,O,M,B,F,K,U,Z,Y;const o=(p=(d=e.overrides)==null?void 0:d.state)==null?void 0:p.isMarketOrder;o!==void 0&&t({isMarketOrder:o}),t({typedChunks:(C=(h=e.overrides)==null?void 0:h.state)==null?void 0:C.chunks,typedFillDelay:(x=(E=e.overrides)==null?void 0:E.state)==null?void 0:x.fillDelay,typedDuration:(I=(P=e.overrides)==null?void 0:P.state)==null?void 0:I.duration,typedLimitPrice:(M=(O=e.overrides)==null?void 0:O.state)==null?void 0:M.limitPrice,typedTriggerPrice:(F=(B=e.overrides)==null?void 0:B.state)==null?void 0:F.triggerPrice,triggerPricePercent:(U=(K=e.overrides)==null?void 0:K.state)==null?void 0:U.triggerPricePercent,limitPricePercent:(Y=(Z=e.overrides)==null?void 0:Z.state)==null?void 0:Y.limitPricePercent})},[(r=e.overrides)==null?void 0:r.state,e.module]),v.useEffect(()=>{var o,d,p,h;t({typedLimitPrice:(d=(o=e.overrides)==null?void 0:o.state)==null?void 0:d.limitPrice,typedTriggerPrice:(h=(p=e.overrides)==null?void 0:p.state)==null?void 0:h.triggerPrice,triggerPricePercent:void 0,limitPricePercent:void 0})},[(s=e.srcToken)==null?void 0:s.address,(i=e.dstToken)==null?void 0:i.address]),v.useEffect(()=>{e.module===j.LIMIT&&t({isMarketOrder:!1})},[e.module]),v.useEffect(()=>{n&&t({isInvertedTrade:!1})},[n]),v.useEffect(()=>{t({typedChunks:void 0})},[e.typedInputAmount]),null},Jo=({marketReferencePrice:e,srcToken:t,dstToken:n,chainId:r,typedInputAmount:s})=>v.useMemo(()=>{if(Vn(t,n,r)||Gn(t,n,r))return{isLoading:!1,noLiquidity:!1,value:Et(s||"0",t==null?void 0:t.decimals)};if(S(e.value||0).isZero()||S(s||0).isZero())return e;const i=S(e.value||0).dividedBy(s||0).decimalPlaces(0).toFixed();return{...e,value:i}},[e,s,t,n,r]),eu=e=>{const t=nn(),n=v.useMemo(()=>Mr(e.partner),[e.partner]),r=v.useMemo(()=>{const d=n[0];return e.chainId&&n.includes(e.chainId)?e.chainId:d},[e.chainId,n]),s=v.useMemo(()=>Kn(e.partner,r),[e.partner,r]),i=Jo(e),o=v.useMemo(()=>Rr(e.minChunkSizeUsd),[e.minChunkSizeUsd]);return v.useEffect(()=>{pe.init(s,o,r)},[s,r,o]),H.jsxs(Ds.Provider,{value:{typedInputAmount:e.typedInputAmount,minChunkSizeUsd:o,account:e.account,walletInteractions:e.walletInteractions,marketPrice:t.acceptedMarketPrice||i.value,marketPriceLoading:!t.acceptedMarketPrice&&i.isLoading,noLiquidity:!t.acceptedMarketPrice&&i.noLiquidity,config:s,slippage:e.priceProtection,supportedChains:n,chainId:r,partner:e.partner,module:e.module,fees:e.fees||0,overrides:e.overrides,callbacks:e.callbacks,srcUsd1Token:e.srcUsd1Token,dstUsd1Token:e.dstUsd1Token,srcBalance:e.srcBalance,dstBalance:e.dstBalance,srcToken:t.srcToken||e.srcToken,dstToken:t.dstToken||e.dstToken,isDev:e.isDev},children:[H.jsx(Yo,{...e}),H.jsx(Qo,{children:H.jsx(Xo,{children:e.children})})]})},tu=e=>H.jsx(oo,{client:Zo,children:H.jsx(eu,{...e})}),q=()=>{const e=v.useContext(Ds);if(e===null)throw new Error("useSpotContext must be used within SpotProvider");return e},nu=(e,t,n)=>{const r=gn();return v.useMemo(()=>e==null?void 0:e.map(s=>({srcToken:t,dstToken:n,srcAmount:Ee(s.inAmount,t==null?void 0:t.decimals),dstAmount:Ee(s.outAmount,n==null?void 0:n.decimals),timestamp:s.timestamp,txHash:s.txHash,explorerUrl:Rt(s.txHash,r==null?void 0:r.id),executionRate:qn(s.inAmount,s.outAmount,t==null?void 0:t.decimals,n==null?void 0:n.decimals)})).filter(s=>s.srcToken!==void 0&&s.dstToken!==void 0),[e,t,n,r])},ru=(e,t,n)=>{const{config:r}=q(),s=xo(t,n,e),i=So(t,n,e),o=vo(t,n,e),d=v.useMemo(()=>e?e.version===2?e.fillDelay:r.twapConfig?Nn(e,r.twapConfig):0:0,[e,r]),p=nu(e==null?void 0:e.fills,t,n)??[];return v.useMemo(()=>{if(e!=null&&e.id)return{original:e,fills:p,srcToken:t,dstToken:n,orderType:e.type,createdAt:e.createdAt,deadline:e.deadline||0,totalTrades:e.totalTradesAmount||0,tradeInterval:d,recipient:e.maker||"",srcAmount:e.srcAmount||"",srcAmountUI:Ee(e.srcAmount,t==null?void 0:t.decimals),limitPrice:Et(s,n==null?void 0:n.decimals),limitPriceUI:s||"",sizePerTrade:e.srcAmountPerTrade||"",sizePerTradeUI:Ee(e.srcAmountPerTrade,t==null?void 0:t.decimals),minDestAmountPerTrade:e.dstMinAmountPerTrade||"",minDestAmountPerTradeUI:Ee(e.dstMinAmountPerTrade,n==null?void 0:n.decimals),dstMinAmount:e.dstMinAmountTotal,dstMinAmountUI:Ee(e.dstMinAmountTotal,n==null?void 0:n.decimals),triggerPrice:Et(i,n==null?void 0:n.decimals),triggerPriceUI:i||"",id:e.id,amountInFilled:e.srcAmountFilled,amountInFilledUI:Ee(e.srcAmountFilled,t==null?void 0:t.decimals),amountOutFilled:e.dstAmountFilled,amountOutFilledUI:Ee(e.dstAmountFilled,n==null?void 0:n.decimals),progress:e.progress,executionPrice:Et(o,n==null?void 0:n.decimals),executionPriceUI:o,version:e.version}},[e,p,t,n,d,s,i,o])};Ki(la.version),k.DISCLAIMER_URL=ii,k.Disclaimer=Jt,k.InputErrors=me,k.Module=j,k.ORBS_LOGO=ri,k.ORBS_SLTP_FAQ_URL=ni,k.ORBS_TWAP_FAQ_URL=ti,k.ORBS_WEBSITE_URL=si,k.OrderFilter=Sr,k.OrderStatus=fe,k.OrderType=V,k.Partners=Ne,k.SPOT_VERSION=ln,k.SpotProvider=tu,k.Steps=tt,k.SwapStatus=Se,k.TimeUnit=Fe,k.buildRePermitOrderData=Nr,k.ensureWrappedToken=Gr,k.eqIgnoreCase=yt,k.getConfig=Kn,k.getExplorerUrl=Rt,k.getMinChunkSizeUsd=Rr,k.getNetwork=At,k.getOrderExecutionRate=qn,k.getOrderFillDelayMillis=Nn,k.getOrderLimitPriceRate=_r,k.getOrderType=ga,k.getPartnerChains=Mr,k.getPartners=Ur,k.getTriggerPriceRate=Br,k.isNativeAddress=Ut,k.isTxRejected=$n,k.millisToDays=Xr,k.millisToMinutes=Zr,k.networks=ye,k.parseError=ya,k.shouldUnwrapOnly=Gn,k.shouldWrapOnly=Vn,k.submitOrder=Hr,k.toAmountUi=Ee,k.toAmountWei=Et,k.useAmountUi=en,k.useCancelOrder=Wo,k.useDerivedHistoryOrder=ru,k.useExplorerLink=Aa,k.useNetwork=gn,k.useSignOrder=xs,k.useSpot=jo,k.useSubmitOrder=vs,k.useSwapExecution=nn,Object.defineProperty(k,Symbol.toStringTag,{value:"Module"})}));
|
|
64
|
+
`,extractResults:C=>{var v;return(((v=C.data)==null?void 0:v.orderFilleds)||[]).map(F=>({...F,timestamp:new Date(F.timestamp).getTime()}))}})};class ri extends Error{constructor(){super("No graph endpoint found"),this.name="NoGraphEndpointError"}}const si=async({chainId:e,signal:t,page:n,limit:r,filters:s})=>{try{const a=await ei({chainId:e,signal:t,page:n,limit:r,filters:s}),[o,d]=await Promise.all([ni({chainId:e,orders:a,signal:t}),ti({chainId:e,orders:a,signal:t})]),p=a.map(w=>{const C=o==null?void 0:o.filter(v=>v.TWAP_id===Number(w.Contract_id)&&yt(v.exchange,w.exchange)&&yt(v.twapAddress,w.twapAddress));return Ya(w,e,C,ai(w,C||[],d))}).sort((w,C)=>C.createdAt-w.createdAt),f=new Set;return p.filter(w=>f.has(w.id)?!1:(f.add(w.id),!0))}catch{return[]}},ai=(e,t,n)=>{var d;const r=(d=n==null?void 0:n.find(p=>p.twapId===e.Contract_id.toString()&&yt(p.twapAddress,e.twapAddress)))==null?void 0:d.status,a=Kr(t).reduce((p,f)=>p.plus(f.inAmount),new x(0)).toFixed(),o=Wr(e.ask_srcAmount,a);return ii(o,e.ask_deadline*1e3,r)},Wr=(e,t)=>{if(!t||!e)return 0;const n=x(t).dividedBy(e).toNumber();return n>=.99?100:n<=0?0:Number((n*100).toFixed(2))},ii=(e,t,n)=>e===100?he.Completed:n==="CANCELLED"?he.Cancelled:n==="COMPLETED"?he.Completed:t>Date.now()?he.Open:he.Expired,oi=async({signal:e,page:t,chainId:n,limit:r,config:s,account:a,isDev:o=!1})=>(await Promise.all([s?si({chainId:n,signal:e,page:t,limit:r,filters:{accounts:[a],configs:s.twapConfig?[s.twapConfig]:[]}}):Promise.resolve([]),Xa({chainId:n,signal:e,account:a,exchange:s==null?void 0:s.adapter,isDev:o})]).then(([f,w])=>[...f,...w])).sort((f,w)=>w.createdAt-f.createdAt),ci={version:"1.1.25"},Qr=e=>{let t;const n=new Set,r=(f,w)=>{const C=typeof f=="function"?f(t):f;if(!Object.is(C,t)){const v=t;t=w??(typeof C!="object"||C===null)?C:Object.assign({},t,C),n.forEach(F=>F(t,v))}},s=()=>t,d={setState:r,getState:s,getInitialState:()=>p,subscribe:f=>(n.add(f),()=>n.delete(f))},p=t=e(r,s,d);return d},ui=(e=>e?Qr(e):Qr),di=e=>e;function li(e,t=di){const n=S.useSyncExternalStore(e.subscribe,S.useCallback(()=>t(e.getState()),[e,t]),S.useCallback(()=>t(e.getInitialState()),[e,t]));return S.useDebugValue(n),n}const jr=e=>{const t=ui(e),n=r=>li(t,r);return Object.assign(n,t),n},pi=(e=>e?jr(e):jr),mn={},zr={currentTime:Date.now(),cancelOrders:{},swapExecutions:[mn],swapExecutionIndex:0},Q=pi((e,t)=>({state:zr,updateState:n=>e(r=>({state:{...r.state,...n}})),updateSwapExecutionAtIndex:(n,r)=>e(s=>{const a=[...s.state.swapExecutions];return a[n]={...a[n]??mn,...r},{state:{...s.state,swapExecutions:a}}}),resetSwapExecutionAtIndex:()=>e(n=>{const r=[...n.state.swapExecutions];return r[n.state.swapExecutionIndex]=mn,{state:{...n.state,swapExecutions:r}}}),resetState:()=>{const n=t().state;e({state:{...zr,currentTime:Date.now(),isMarketOrder:n.isMarketOrder,swapExecutions:[...n.swapExecutions,mn],swapExecutionIndex:n.swapExecutionIndex+1}})}}));var xe=(e=>(e[e.LOADING=1]="LOADING",e[e.SUCCESS=2]="SUCCESS",e[e.FAILED=3]="FAILED",e))(xe||{}),Jt=(e=>(e.TRIGGER_MARKET_PRICE="triggerMarketPriceDisclaimer",e.MARKET_PRICE="marketOrderDisclaimer",e.LIMIT_PRICE="limitOrderDisclaimer",e))(Jt||{}),tt=(e=>(e.WRAP="wrap",e.APPROVE="approve",e.CREATE="create",e))(tt||{});const Et=(e,t)=>!t||!e||x(e).isNaN()?"":x(e).multipliedBy(x(10).pow(t)).toFixed(0),Ee=(e,t)=>{try{return!t||!e||x(e).isNaN()?"":x(e).dividedBy(x(10).pow(t)).toFixed()}catch(n){return console.error(n),""}},fi=e=>{const t="An error occurred.";if(!e||!e.message)return t;try{return e.message.toLowerCase().includes("rejected")?"Transaction Rejected":t}catch{return t}},zn=e=>{var t,n,r,s;if(e!=null&&e.message)return((n=(t=e.message)==null?void 0:t.toLowerCase())==null?void 0:n.includes("rejected"))||((s=(r=e.message)==null?void 0:r.toLowerCase())==null?void 0:s.includes("denied"))},$r=(e,t)=>{const n=At(t);return n&&Ut(e.address)?n.wToken:e};function Vr(e){return e?e/864e5:0}function Gr(e){return e?e/6e4:0}const hi=(e,t)=>e?V.TWAP_MARKET:t===1?V.LIMIT:V.TWAP_LIMIT,$n=(e,t,n)=>{const r=At(n);return Ut((e==null?void 0:e.address)||"")&&yt((t==null?void 0:t.address)||"",(r==null?void 0:r.wToken.address)||"")},Vn=(e,t,n)=>{const r=At(n);return yt((e==null?void 0:e.address)||"",(r==null?void 0:r.wToken.address)||"")&&Ut((t==null?void 0:t.address)||"")},Rt=(e,t)=>{if(!t)return"";const n=At(t);return`${n==null?void 0:n.explorer}/tx/${e}`},Gn=(e,t)=>S.useMemo(()=>Et(t,e),[e,t]),en=(e,t)=>S.useMemo(()=>Ee(t,e),[e,t]),yn=()=>{const{chainId:e}=q();return S.useMemo(()=>At(e),[e])},mi=e=>{const t=yn();return S.useMemo(()=>{if(!(!e||!t))return Rt(e,t.id)},[e,t])},nt=(e,t)=>S.useMemo(()=>!e||!t||x(e||"0").isZero()||x(t||"0").isZero()?"":x(e||"0").times(t).toFixed(),[e,t]),yi=()=>{const{srcToken:e,dstToken:t,chainId:n}=q();return S.useMemo(()=>$n(e,t,n),[e,t,n])},gi=()=>{const{srcToken:e,dstToken:t,chainId:n}=q();return S.useMemo(()=>Vn(e,t,n),[e,t,n])},Ai=()=>{const e=yi(),t=gi();return e||t},rt=()=>{const{srcToken:e,typedInputAmount:t}=q();return{amount:Gn(e==null?void 0:e.decimals,t),amountUI:t,error:x(t||0).isZero()?"enterAmount":void 0}},Ei=(e,t)=>{const{module:n,srcUsd1Token:r,marketPrice:s,minChunkSizeUsd:a,typedInputAmount:o}=q();return S.useMemo(()=>{if(x(o||"0").isZero()||!s||x(r||"0").isZero())return;if(!e)return{type:me.MIN_CHUNKS,value:1,args:{minChunks:"1"}};const{isError:d}=Ma(e,t,n);if(d)return{type:me.MAX_CHUNKS,value:t,args:{maxChunks:`${t}`}};const{isError:p,value:f}=ka(o||"",r||"",a||0);if(p)return{type:me.MIN_TRADE_SIZE,value:f,args:{minTradeSize:`${f}`}}},[e,t,n,o,r,a,s])},qe=()=>{const{srcToken:e,srcUsd1Token:t,module:n,minChunkSizeUsd:r}=q(),s=Q(O=>O.state.typedChunks),a=Q(O=>O.updateState),{amount:o,amountUI:d}=rt(),p=S.useMemo(()=>ba(d||"",t||"",r||0),[d,t,r]),f=S.useMemo(()=>Ea(p,n,s),[p,s,n]),w=S.useCallback(O=>a({typedChunks:O}),[a]),C=S.useMemo(()=>wa(o||"",f),[o,f]),v=en(e==null?void 0:e.decimals,C),F=S.useMemo(()=>t?x(v||"0").times(t||0).toString():"0",[v,t]);return{totalTrades:f,maxTrades:p,amountPerTradeUI:v,amountPerTrade:C,amountPerTradeUsd:F,onChange:w,error:Ei(f,p)}},bi=()=>{const{srcToken:e,dstToken:t}=q(),{onChange:n,totalTrades:r,amountPerTradeUsd:s,amountPerTradeUI:a,error:o,maxTrades:d,amountPerTrade:p}=qe();return{error:o,maxTrades:d,totalTrades:r,amountPerTradeUI:a,amountPerTrade:p,onChange:n,amountPerTradeUsd:s,fromToken:e,toToken:t}},Ci=e=>{const{totalTrades:t}=qe(),{marketPrice:n,typedInputAmount:r}=q(),s=S.useMemo(()=>{const{isError:o,value:d}=Ia(e);if(!(!o||x(r||"0").isZero()||!n))return{type:me.MIN_FILL_DELAY,value:d}},[e,r,n]),a=S.useMemo(()=>{const{isError:o,value:d}=va(e,t);if(!(!o||x(r||"0").isZero()||!n))return{type:me.MAX_FILL_DELAY,value:d}},[e,r,n,t]);return s||a},Lt=()=>{const{callbacks:e}=q(),t=Q(a=>a.state.typedFillDelay),n=Q(a=>a.updateState),r=S.useMemo(()=>t||Mn,[t]),s=Ci(r);return{fillDelay:r,onChange:S.useCallback(a=>{var o;n({typedFillDelay:a}),(o=e==null?void 0:e.onFillDelayChange)==null||o.call(e,a)},[n,e]),error:s,milliseconds:r.unit*r.value}},Ti=()=>{const{onChange:e,fillDelay:t,error:n}=Lt(),r=S.useCallback(a=>e({unit:t.unit,value:Number(a)}),[e,t]),s=S.useCallback(a=>e({unit:a,value:t.value}),[e,t]);return{onInputChange:r,onUnitSelect:s,onChange:e,milliseconds:t.unit*t.value,fillDelay:t,error:n}},wi=e=>{const{module:t,marketPrice:n}=q();return S.useMemo(()=>{const r=Da(t,e),s=Oa(e);if(n){if(r.isError)return{type:me.MAX_ORDER_DURATION,value:r.value,args:{duration:`${Math.floor(Vr(r.value)).toFixed(0)} days`}};if(s.isError)return{type:me.MIN_ORDER_DURATION,value:s.value,args:{duration:`${Math.floor(Gr(s.value)).toFixed(0)} minutes`}}}},[e,t,n])},Xn=()=>{const{module:e,callbacks:t}=q(),n=Q(p=>p.state.typedDuration),r=Q(p=>p.updateState),s=qe().totalTrades,a=Lt().fillDelay,o=S.useMemo(()=>Aa(e,s,a,n),[s,a,n,e]),d=wi(o);return{duration:o,setDuration:S.useCallback(p=>{var f;r({typedDuration:p}),(f=t==null?void 0:t.onDurationChange)==null||f.call(t,p)},[r,t]),error:d}},vi=()=>{const{duration:e,setDuration:t,error:n}=Xn(),r=S.useCallback(a=>{t({unit:e.unit,value:Number(a)})},[t,e]),s=S.useCallback(a=>{t({unit:a,value:e.value})},[t,e]);return{duration:e,onChange:t,milliseconds:e.unit*e.value,onInputChange:r,onUnitSelect:s,error:n}},xi=()=>{const{module:e}=q();return S.useMemo(()=>e===$.STOP_LOSS?sa:aa,[e])},Zn=()=>{const{module:e}=q(),t=Q(n=>n.state.isMarketOrder);return S.useMemo(()=>e!==$.STOP_LOSS&&e!==$.TAKE_PROFIT||t?void 0:e===$.STOP_LOSS?ia:oa,[e,t])},gn=()=>{const{srcToken:e,dstToken:t,marketPriceLoading:n}=q(),r=Q(f=>f.updateState),s=Q(f=>f.state.isInvertedTrade),a=Q(f=>f.state.typedTriggerPrice),o=Q(f=>f.state.typedLimitPrice),d=Q(f=>f.state.isMarketOrder);return{onInvert:S.useCallback(()=>{a!==void 0&&r({typedTriggerPrice:x(1).div(a).toFixed()}),o!==void 0&&r({typedLimitPrice:x(1).div(o).toFixed()}),r({isInvertedTrade:!s})},[r,s,a,o,n]),isInverted:s,fromToken:s?t:e,toToken:s?e:t,isMarketPrice:d}},Xr=({typedValue:e,tokenDecimals:t=18,initialPrice:n="0",percentage:r,setValue:s,setPercentage:a})=>{const{srcUsd1Token:o,dstUsd1Token:d}=q(),{isInverted:p}=gn(),f=S.useMemo(()=>x((()=>{if(e!==void 0){const M=p?x(e).isZero()?x(0):x(1).div(e):x(e);return Et(M.toFixed(),t)}if(r!==void 0&&x(n||"0").gt(0)&&!x(n||"0").isNaN()){const M=x(n||"0"),_=x(r||0).div(100);return M.plus(M.multipliedBy(_)).decimalPlaces(0).toFixed()}return x(n).gt(0)?n:""})()).decimalPlaces(0).toFixed(),[e,r,t,n,p]),w=S.useCallback(I=>{s(I),a(null)},[s,a]),C=S.useCallback(I=>{s(void 0),a(I)},[s,a]),v=S.useMemo(()=>{if(!n||x(n).isZero())return"";if(r!=null)return r;if(f){const I=x(n),_=x(f).minus(I).div(I).multipliedBy(100).decimalPlaces(2).toString();return x(_||"0").isZero()?"":_}return""},[f,n,r]),F=S.useMemo(()=>{let I="";if(e!==void 0)I=e;else{const M=Ee(f,t);if(x(M||"0").isZero())return"";I=p?x(1).div(M).toFixed():M}return I},[e,t,f,p]),O=nt(p?o:d,F||"0");return{amount:x(f).isNaN()?"":f,amountUI:x(F).isNaN()?"":F,selectedPercentage:v,onChange:w,onPercentageChange:C,isInverted:p,usd:x(O).isNaN()?"":O,isTypedValue:e!==void 0}},Si=(e="")=>{const{module:t,marketPrice:n,typedInputAmount:r}=q();return S.useMemo(()=>{if(x(r||"0").isZero()||!n||t!==$.STOP_LOSS&&t!==$.TAKE_PROFIT)return;const s=xa(n||"",e||"",t);if(s!=null&&s.isError)return{type:me.STOP_LOSS_TRIGGER_PRICE_GREATER_THAN_MARKET_PRICE,value:s.value};const a=Sa(n||"",e||"",t);if(a!=null&&a.isError)return{type:me.TAKE_PROFIT_TRIGGER_PRICE_LESS_THAN_MARKET_PRICE,value:a.value};if(!e||x(e||0).isZero())return{type:me.EMPTY_TRIGGER_PRICE,value:e}},[n,e,t,r])},Fi=e=>{const{srcToken:t,dstToken:n,module:r,dstUsd1Token:s}=q(),a=qe().amountPerTrade,o=Q(f=>f.state.isMarketOrder),d=S.useMemo(()=>ga(r,a,e,(t==null?void 0:t.decimals)||0),[e,a,o,t==null?void 0:t.decimals,r]),p=en((n==null?void 0:n.decimals)||0,d);return{amount:d,amountUI:p,usd:nt(p,s)}},bt=()=>{const{dstToken:e,marketPrice:t,module:n,callbacks:r}=q(),s=Q(O=>O.updateState),a=xi(),o=Q(O=>O.state.triggerPricePercent),d=o===void 0?a:o,p=n===$.STOP_LOSS||n===$.TAKE_PROFIT,f=Xr({typedValue:Q(O=>O.state.typedTriggerPrice),percentage:d,tokenDecimals:(e==null?void 0:e.decimals)||18,initialPrice:p?t:void 0,setValue:S.useCallback(O=>{var I;s({typedTriggerPrice:O}),(I=r==null?void 0:r.onTriggerPriceChange)==null||I.call(r,O||"")},[s,r]),setPercentage:S.useCallback(O=>{var I;s({triggerPricePercent:O}),(I=r==null?void 0:r.onTriggerPricePercentChange)==null||I.call(r,O||"")},[s,r])}),w=Si(f.amount),{amount:C,amountUI:v,usd:F}=Fi(f.amount);return S.useMemo(()=>({...f,error:w,pricePerChunk:C,pricePerChunkUI:v,pricePerChunkUsd:F}),[f,w,C,v,F])},Pi=e=>{const{module:t,marketPrice:n,typedInputAmount:r}=q(),{amount:s}=bt(),a=Q(o=>o.state.isMarketOrder);return S.useMemo(()=>{if(x(r||"0").isZero()||!s||!n)return;const o=Fa(s,e,a,t),d=Pa(s,e,a,t);if(o!=null&&o.isError)return{type:me.TRIGGER_LIMIT_PRICE_GREATER_THAN_TRIGGER_PRICE,value:o.value};if(d!=null&&d.isError)return{type:me.TRIGGER_LIMIT_PRICE_GREATER_THAN_TRIGGER_PRICE,value:d.value};if(e&&x(e||0).isZero())return{type:me.MISSING_LIMIT_PRICE,value:e||""}},[e,s,t,a,r,n])},An=()=>{const{dstToken:e,marketPrice:t,callbacks:n}=q(),r=Q(f=>f.updateState),s=Zn(),a=Q(f=>f.state.limitPricePercent),o=a===void 0?s:a,d=Xr({typedValue:Q(f=>f.state.typedLimitPrice),percentage:o,tokenDecimals:(e==null?void 0:e.decimals)||18,initialPrice:t,setValue:S.useCallback(f=>{var w;r({typedLimitPrice:f}),(w=n==null?void 0:n.onLimitPriceChange)==null||w.call(n,f||"")},[r,n]),setPercentage:S.useCallback(f=>{var w;r({limitPricePercent:f}),(w=n==null?void 0:n.onLimitPricePercentChange)==null||w.call(n,f||"")},[r,n])}),p=Pi(d.amount);return S.useMemo(()=>({...d,error:p}),[d,p])},Di=()=>{const{module:e}=q(),t=Q(d=>d.updateState),n=Q(d=>d.state.isMarketOrder),r=Zn(),s=Q(d=>d.state.triggerPricePercent)||0,a=e===$.LIMIT,o=S.useCallback(()=>{!n&&e===$.STOP_LOSS&&t({limitPricePercent:r}),t({isMarketOrder:!n})},[t,s,e,n,r]);return{isLimitPrice:!n,toggleLimitPrice:o,hide:a}},Oi=()=>{const{module:e,marketPriceLoading:t,srcToken:n,dstToken:r}=q(),{amount:s,amountUI:a,onChange:o,onPercentageChange:d,usd:p,selectedPercentage:f,error:w,isTypedValue:C}=An(),v=Q(K=>K.updateState),F=Zn(),{isLimitPrice:O,toggleLimitPrice:I}=Di(),{fromToken:M,toToken:_}=gn(),P=S.useCallback(()=>{v({typedLimitPrice:void 0}),v({limitPricePercent:F})},[v,e,F]);return{price:s,priceUI:a,error:w,onInputChange:o,onPercentageChange:d,onReset:P,usd:p,srcToken:n,dstToken:r,invertedSrcToken:M,invertedDstToken:_,percentage:f,isLoading:t,isLimitPrice:O,toggleLimitPrice:I,isTypedValue:C}},Ii=()=>{const{marketPrice:e,marketPriceLoading:t,srcToken:n,dstToken:r}=q(),{amount:s,amountUI:a,onChange:o,onPercentageChange:d,usd:p,selectedPercentage:f,error:w,pricePerChunk:C,pricePerChunkUI:v,pricePerChunkUsd:F,isTypedValue:O}=bt(),I=Q(K=>K.updateState),{fromToken:M,toToken:_}=gn(),P=S.useCallback(()=>{I({triggerPricePercent:void 0,typedTriggerPrice:void 0})},[I]);return{price:s,priceUI:a,amountPerChunk:C,amountPerChunkUI:v,amountPerChunkUsd:F,error:w,onInputChange:o,onPercentageChange:d,percentage:f,onReset:P,usd:p,srcToken:n,dstToken:r,invertedSrcToken:M,invertedDstToken:_,isLoading:t||!e,isTypedValue:O}},Zr=()=>{const{module:e,marketPrice:t}=q(),n=An().amount,r=bt().amount,s=Q(a=>a.state.isMarketOrder);return e===$.LIMIT||!s?n||"":e===$.STOP_LOSS||e===$.TAKE_PROFIT?r||"":t||""},En=()=>{const{srcToken:e,dstToken:t,dstUsd1Token:n}=q(),r=Zr(),s=rt().amount,a=S.useMemo(()=>ma(s||"",r,(e==null?void 0:e.decimals)||0),[s,r,e==null?void 0:e.decimals]),o=en(t==null?void 0:t.decimals,a);return{amount:a,amountUI:o,usd:nt(o,n)}},Yn=()=>{const{srcToken:e,dstToken:t,dstUsd1Token:n}=q(),r=Zr(),s=qe().amountPerTrade,a=Q(p=>p.state.isMarketOrder),o=S.useMemo(()=>ya(s,r,!!a,(e==null?void 0:e.decimals)||0),[s,r,a,e==null?void 0:e.decimals]),d=en(t==null?void 0:t.decimals,o);return{amount:o,amountUI:d,usd:nt(d,n)}},ki=()=>{const{typedInputAmount:e,marketPriceLoading:t,dstToken:n}=q(),{amountUI:r,usd:s}=En(),o=Ai()?e:r,d=Gn(n==null?void 0:n.decimals,o);return{value:o,valueWei:d,isLoading:t,usd:s}},Mi=()=>{const e=Q(s=>s.state.isMarketOrder),{module:t}=q(),n=S.useMemo(()=>{if(e&&t===$.STOP_LOSS)return Jt.TRIGGER_MARKET_PRICE},[e,t]),r=S.useMemo(()=>{if(!(t!==$.LIMIT&&t!==$.TWAP))return e?Jt.MARKET_PRICE:Jt.LIMIT_PRICE},[e,t]);return n||r},Bi=()=>{const{minChunkSizeUsd:e,typedInputAmount:t,srcUsd1Token:n}=q(),r=nt(t,n);return S.useMemo(()=>x(e).gt(x(r||"0"))?{type:me.MIN_TRADE_SIZE_ERROR,value:e}:void 0,[e,r])};function Yr(){const{marketPrice:e,marketPriceLoading:t,typedInputAmount:n,srcUsd1Token:r,srcBalance:s,chainId:a}=q(),{error:o}=bt(),{error:d}=An(),{error:p}=qe(),{error:f}=Lt(),{error:w}=Xn(),C=Bi(),v=rt().amount,F=S.useMemo(()=>{if(s&&x(v).gt(s))return{type:me.INSUFFICIENT_BALANCE,value:s||""}},[s,v,a]);return S.useMemo(()=>_a({marketPrice:e,typedInputAmount:n,srcUsd1Token:r,marketPriceLoading:t,triggerPriceError:o,limitPriceError:d,tradesError:p,fillDelayError:f,durationError:w,balanceError:F,minTradeSizeError:C}),[e,t,n,o,d,p,f,w,F,r,C])}var Nt=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},_i={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Ui=(Ps=class{constructor(){N(this,Ke,_i);N(this,vt,!1)}setTimeoutProvider(e){process.env.NODE_ENV!=="production"&&l(this,vt)&&e!==l(this,Ke)&&console.error("[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",{previous:l(this,Ke),provider:e}),B(this,Ke,e),process.env.NODE_ENV!=="production"&&B(this,vt,!1)}setTimeout(e,t){return process.env.NODE_ENV!=="production"&&B(this,vt,!0),l(this,Ke).setTimeout(e,t)}clearTimeout(e){l(this,Ke).clearTimeout(e)}setInterval(e,t){return process.env.NODE_ENV!=="production"&&B(this,vt,!0),l(this,Ke).setInterval(e,t)}clearInterval(e){l(this,Ke).clearInterval(e)}},Ke=new WeakMap,vt=new WeakMap,Ps),Ct=new Ui;function Ri(e){setTimeout(e,0)}var Tt=typeof window>"u"||"Deno"in globalThis;function be(){}function Li(e,t){return typeof e=="function"?e(t):e}function Jn(e){return typeof e=="number"&&e>=0&&e!==1/0}function Jr(e,t){return Math.max(e+(t||0)-Date.now(),0)}function st(e,t){return typeof e=="function"?e(t):e}function ke(e,t){return typeof e=="function"?e(t):e}function es(e,t){const{type:n="all",exact:r,fetchStatus:s,predicate:a,queryKey:o,stale:d}=e;if(o){if(r){if(t.queryHash!==er(o,t.options))return!1}else if(!tn(t.queryKey,o))return!1}if(n!=="all"){const p=t.isActive();if(n==="active"&&!p||n==="inactive"&&p)return!1}return!(typeof d=="boolean"&&t.isStale()!==d||s&&s!==t.state.fetchStatus||a&&!a(t))}function ts(e,t){const{exact:n,status:r,predicate:s,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(wt(t.options.mutationKey)!==wt(a))return!1}else if(!tn(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||s&&!s(t))}function er(e,t){return((t==null?void 0:t.queryKeyHashFn)||wt)(e)}function wt(e){return JSON.stringify(e,(t,n)=>nr(n)?Object.keys(n).sort().reduce((r,s)=>(r[s]=n[s],r),{}):n)}function tn(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>tn(e[n],t[n])):!1}var Ni=Object.prototype.hasOwnProperty;function tr(e,t){if(e===t)return e;const n=ns(e)&&ns(t);if(!n&&!(nr(e)&&nr(t)))return t;const s=(n?e:Object.keys(e)).length,a=n?t:Object.keys(t),o=a.length,d=n?new Array(o):{};let p=0;for(let f=0;f<o;f++){const w=n?f:a[f],C=e[w],v=t[w];if(C===v){d[w]=C,(n?f<s:Ni.call(e,w))&&p++;continue}if(C===null||v===null||typeof C!="object"||typeof v!="object"){d[w]=v;continue}const F=tr(C,v);d[w]=F,F===C&&p++}return s===o&&p===s?e:d}function bn(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(e[n]!==t[n])return!1;return!0}function ns(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function nr(e){if(!rs(e))return!1;const t=e.constructor;if(t===void 0)return!0;const n=t.prototype;return!(!rs(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function rs(e){return Object.prototype.toString.call(e)==="[object Object]"}function qi(e){return new Promise(t=>{Ct.setTimeout(t,e)})}function rr(e,t,n){if(typeof n.structuralSharing=="function")return n.structuralSharing(e,t);if(n.structuralSharing!==!1){if(process.env.NODE_ENV!=="production")try{return tr(e,t)}catch(r){throw console.error(`Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${n.queryHash}]: ${r}`),r}return tr(e,t)}return t}function Ki(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function Hi(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var Cn=Symbol();function ss(e,t){return process.env.NODE_ENV!=="production"&&e.queryFn===Cn&&console.error(`Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${e.queryHash}'`),!e.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!e.queryFn||e.queryFn===Cn?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function as(e,t){return typeof e=="function"?e(...t):!!e}var Wi=(Ds=class extends Nt{constructor(){super();N(this,xt);N(this,it);N(this,qt);B(this,qt,t=>{if(!Tt&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){l(this,it)||this.setEventListener(l(this,qt))}onUnsubscribe(){var t;this.hasListeners()||((t=l(this,it))==null||t.call(this),B(this,it,void 0))}setEventListener(t){var n;B(this,qt,t),(n=l(this,it))==null||n.call(this),B(this,it,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){l(this,xt)!==t&&(B(this,xt,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(n=>{n(t)})}isFocused(){var t;return typeof l(this,xt)=="boolean"?l(this,xt):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},xt=new WeakMap,it=new WeakMap,qt=new WeakMap,Ds),sr=new Wi;function ar(){let e,t;const n=new Promise((s,a)=>{e=s,t=a});n.status="pending",n.catch(()=>{});function r(s){Object.assign(n,s),delete n.resolve,delete n.reject}return n.resolve=s=>{r({status:"fulfilled",value:s}),e(s)},n.reject=s=>{r({status:"rejected",reason:s}),t(s)},n}var Qi=Ri;function ji(){let e=[],t=0,n=d=>{d()},r=d=>{d()},s=Qi;const a=d=>{t?e.push(d):s(()=>{n(d)})},o=()=>{const d=e;e=[],d.length&&s(()=>{r(()=>{d.forEach(p=>{n(p)})})})};return{batch:d=>{let p;t++;try{p=d()}finally{t--,t||o()}return p},batchCalls:d=>(...p)=>{a(()=>{d(...p)})},schedule:a,setNotifyFunction:d=>{n=d},setBatchNotifyFunction:d=>{r=d},setScheduler:d=>{s=d}}}var ue=ji(),zi=(Os=class extends Nt{constructor(){super();N(this,Kt,!0);N(this,ot);N(this,Ht);B(this,Ht,t=>{if(!Tt&&window.addEventListener){const n=()=>t(!0),r=()=>t(!1);return window.addEventListener("online",n,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",r)}}})}onSubscribe(){l(this,ot)||this.setEventListener(l(this,Ht))}onUnsubscribe(){var t;this.hasListeners()||((t=l(this,ot))==null||t.call(this),B(this,ot,void 0))}setEventListener(t){var n;B(this,Ht,t),(n=l(this,ot))==null||n.call(this),B(this,ot,t(this.setOnline.bind(this)))}setOnline(t){l(this,Kt)!==t&&(B(this,Kt,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return l(this,Kt)}},Kt=new WeakMap,ot=new WeakMap,Ht=new WeakMap,Os),Tn=new zi;function $i(e){return Math.min(1e3*2**e,3e4)}function is(e){return(e??"online")==="online"?Tn.isOnline():!0}var ir=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function os(e){let t=!1,n=0,r;const s=ar(),a=()=>s.status!=="pending",o=I=>{var M;if(!a()){const _=new ir(I);v(_),(M=e.onCancel)==null||M.call(e,_)}},d=()=>{t=!0},p=()=>{t=!1},f=()=>sr.isFocused()&&(e.networkMode==="always"||Tn.isOnline())&&e.canRun(),w=()=>is(e.networkMode)&&e.canRun(),C=I=>{a()||(r==null||r(),s.resolve(I))},v=I=>{a()||(r==null||r(),s.reject(I))},F=()=>new Promise(I=>{var M;r=_=>{(a()||f())&&I(_)},(M=e.onPause)==null||M.call(e)}).then(()=>{var I;r=void 0,a()||(I=e.onContinue)==null||I.call(e)}),O=()=>{if(a())return;let I;const M=n===0?e.initialPromise:void 0;try{I=M??e.fn()}catch(_){I=Promise.reject(_)}Promise.resolve(I).then(C).catch(_=>{var Y;if(a())return;const P=e.retry??(Tt?0:3),K=e.retryDelay??$i,U=typeof K=="function"?K(n,_):K,Z=P===!0||typeof P=="number"&&n<P||typeof P=="function"&&P(n,_);if(t||!Z){v(_);return}n++,(Y=e.onFail)==null||Y.call(e,n,_),qi(U).then(()=>f()?void 0:F()).then(()=>{t?v(_):O()})})};return{promise:s,status:()=>s.status,cancel:o,continue:()=>(r==null||r(),s),cancelRetry:d,continueRetry:p,canStart:w,start:()=>(w()?O():F().then(O),s)}}var cs=(Is=class{constructor(){N(this,St)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Jn(this.gcTime)&&B(this,St,Ct.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Tt?1/0:300*1e3))}clearGcTimeout(){l(this,St)&&(Ct.clearTimeout(l(this,St)),B(this,St,void 0))}},St=new WeakMap,Is),Vi=(ks=class extends cs{constructor(t){super();N(this,Re);N(this,Ft);N(this,Wt);N(this,Me);N(this,Pt);N(this,fe);N(this,rn);N(this,Dt);B(this,Dt,!1),B(this,rn,t.defaultOptions),this.setOptions(t.options),this.observers=[],B(this,Pt,t.client),B(this,Me,l(this,Pt).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,B(this,Ft,ls(this.options)),this.state=t.state??l(this,Ft),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=l(this,fe))==null?void 0:t.promise}setOptions(t){if(this.options={...l(this,rn),...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const n=ls(this.options);n.data!==void 0&&(this.setState(ds(n.data,n.dataUpdatedAt)),B(this,Ft,n))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&l(this,Me).remove(this)}setData(t,n){const r=rr(this.state.data,t,this.options);return j(this,Re,Je).call(this,{data:r,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),r}setState(t,n){j(this,Re,Je).call(this,{type:"setState",state:t,setStateOptions:n})}cancel(t){var r,s;const n=(r=l(this,fe))==null?void 0:r.promise;return(s=l(this,fe))==null||s.cancel(t),n?n.then(be).catch(be):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(l(this,Ft))}isActive(){return this.observers.some(t=>ke(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Cn||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>st(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!Jr(this.state.dataUpdatedAt,t)}onFocus(){var n;const t=this.observers.find(r=>r.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(n=l(this,fe))==null||n.continue()}onOnline(){var n;const t=this.observers.find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=l(this,fe))==null||n.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),l(this,Me).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(n=>n!==t),this.observers.length||(l(this,fe)&&(l(this,Dt)?l(this,fe).cancel({revert:!0}):l(this,fe).cancelRetry()),this.scheduleGc()),l(this,Me).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||j(this,Re,Je).call(this,{type:"invalidate"})}async fetch(t,n){var p,f,w,C,v,F,O,I,M,_,P,K;if(this.state.fetchStatus!=="idle"&&((p=l(this,fe))==null?void 0:p.status())!=="rejected"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(l(this,fe))return l(this,fe).continueRetry(),l(this,fe).promise}if(t&&this.setOptions(t),!this.options.queryFn){const U=this.observers.find(Z=>Z.options.queryFn);U&&this.setOptions(U.options)}process.env.NODE_ENV!=="production"&&(Array.isArray(this.options.queryKey)||console.error("As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']"));const r=new AbortController,s=U=>{Object.defineProperty(U,"signal",{enumerable:!0,get:()=>(B(this,Dt,!0),r.signal)})},a=()=>{const U=ss(this.options,n),Y=(()=>{const oe={client:l(this,Pt),queryKey:this.queryKey,meta:this.meta};return s(oe),oe})();return B(this,Dt,!1),this.options.persister?this.options.persister(U,Y,this):U(Y)},d=(()=>{const U={fetchOptions:n,options:this.options,queryKey:this.queryKey,client:l(this,Pt),state:this.state,fetchFn:a};return s(U),U})();(f=this.options.behavior)==null||f.onFetch(d,this),B(this,Wt,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((w=d.fetchOptions)==null?void 0:w.meta))&&j(this,Re,Je).call(this,{type:"fetch",meta:(C=d.fetchOptions)==null?void 0:C.meta}),B(this,fe,os({initialPromise:n==null?void 0:n.initialPromise,fn:d.fetchFn,onCancel:U=>{U instanceof ir&&U.revert&&this.setState({...l(this,Wt),fetchStatus:"idle"}),r.abort()},onFail:(U,Z)=>{j(this,Re,Je).call(this,{type:"failed",failureCount:U,error:Z})},onPause:()=>{j(this,Re,Je).call(this,{type:"pause"})},onContinue:()=>{j(this,Re,Je).call(this,{type:"continue"})},retry:d.options.retry,retryDelay:d.options.retryDelay,networkMode:d.options.networkMode,canRun:()=>!0}));try{const U=await l(this,fe).start();if(U===void 0)throw process.env.NODE_ENV!=="production"&&console.error(`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`),new Error(`${this.queryHash} data is undefined`);return this.setData(U),(F=(v=l(this,Me).config).onSuccess)==null||F.call(v,U,this),(I=(O=l(this,Me).config).onSettled)==null||I.call(O,U,this.state.error,this),U}catch(U){if(U instanceof ir){if(U.silent)return l(this,fe).promise;if(U.revert){if(this.state.data===void 0)throw U;return this.state.data}}throw j(this,Re,Je).call(this,{type:"error",error:U}),(_=(M=l(this,Me).config).onError)==null||_.call(M,U,this),(K=(P=l(this,Me).config).onSettled)==null||K.call(P,this.state.data,U,this),U}finally{this.scheduleGc()}}},Ft=new WeakMap,Wt=new WeakMap,Me=new WeakMap,Pt=new WeakMap,fe=new WeakMap,rn=new WeakMap,Dt=new WeakMap,Re=new WeakSet,Je=function(t){const n=r=>{switch(t.type){case"failed":return{...r,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...us(r.data,this.options),fetchMeta:t.meta??null};case"success":const s={...r,...ds(t.data,t.dataUpdatedAt),dataUpdateCount:r.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return B(this,Wt,t.manual?s:void 0),s;case"error":const a=t.error;return{...r,error:a,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:a,fetchStatus:"idle",status:"error"};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}};this.state=n(this.state),ue.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),l(this,Me).notify({query:this,type:"updated",action:t})})},ks);function us(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:is(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function ds(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function ls(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var Gi=(Ms=class extends Nt{constructor(t,n){super();N(this,ee);N(this,Se);N(this,X);N(this,sn);N(this,Ce);N(this,Ot);N(this,Qt);N(this,Ve);N(this,ct);N(this,an);N(this,jt);N(this,zt);N(this,It);N(this,kt);N(this,ut);N(this,$t,new Set);this.options=n,B(this,Se,t),B(this,ct,null),B(this,Ve,ar()),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(l(this,X).addObserver(this),ps(l(this,X),this.options)?j(this,ee,dn).call(this):this.updateResult(),j(this,ee,Er).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return or(l(this,X),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return or(l(this,X),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,j(this,ee,br).call(this),j(this,ee,Cr).call(this),l(this,X).removeObserver(this)}setOptions(t){const n=this.options,r=l(this,X);if(this.options=l(this,Se).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof ke(this.options.enabled,l(this,X))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");j(this,ee,Tr).call(this),l(this,X).setOptions(this.options),n._defaulted&&!bn(this.options,n)&&l(this,Se).getQueryCache().notify({type:"observerOptionsUpdated",query:l(this,X),observer:this});const s=this.hasListeners();s&&fs(l(this,X),r,this.options,n)&&j(this,ee,dn).call(this),this.updateResult(),s&&(l(this,X)!==r||ke(this.options.enabled,l(this,X))!==ke(n.enabled,l(this,X))||st(this.options.staleTime,l(this,X))!==st(n.staleTime,l(this,X)))&&j(this,ee,yr).call(this);const a=j(this,ee,gr).call(this);s&&(l(this,X)!==r||ke(this.options.enabled,l(this,X))!==ke(n.enabled,l(this,X))||a!==l(this,ut))&&j(this,ee,Ar).call(this,a)}getOptimisticResult(t){const n=l(this,Se).getQueryCache().build(l(this,Se),t),r=this.createResult(n,t);return Zi(this,r)&&(B(this,Ce,r),B(this,Qt,this.options),B(this,Ot,l(this,X).state)),r}getCurrentResult(){return l(this,Ce)}trackResult(t,n){return new Proxy(t,{get:(r,s)=>(this.trackProp(s),n==null||n(s),s==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&l(this,Ve).status==="pending"&&l(this,Ve).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(r,s))})}trackProp(t){l(this,$t).add(t)}getCurrentQuery(){return l(this,X)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=l(this,Se).defaultQueryOptions(t),r=l(this,Se).getQueryCache().build(l(this,Se),n);return r.fetch().then(()=>this.createResult(r,n))}fetch(t){return j(this,ee,dn).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),l(this,Ce)))}createResult(t,n){var c;const r=l(this,X),s=this.options,a=l(this,Ce),o=l(this,Ot),d=l(this,Qt),f=t!==r?t.state:l(this,sn),{state:w}=t;let C={...w},v=!1,F;if(n._optimisticResults){const u=this.hasListeners(),A=!u&&ps(t,n),m=u&&fs(t,r,n,s);(A||m)&&(C={...C,...us(w.data,t.options)}),n._optimisticResults==="isRestoring"&&(C.fetchStatus="idle")}let{error:O,errorUpdatedAt:I,status:M}=C;F=C.data;let _=!1;if(n.placeholderData!==void 0&&F===void 0&&M==="pending"){let u;a!=null&&a.isPlaceholderData&&n.placeholderData===(d==null?void 0:d.placeholderData)?(u=a.data,_=!0):u=typeof n.placeholderData=="function"?n.placeholderData((c=l(this,zt))==null?void 0:c.state.data,l(this,zt)):n.placeholderData,u!==void 0&&(M="success",F=rr(a==null?void 0:a.data,u,n),v=!0)}if(n.select&&F!==void 0&&!_)if(a&&F===(o==null?void 0:o.data)&&n.select===l(this,an))F=l(this,jt);else try{B(this,an,n.select),F=n.select(F),F=rr(a==null?void 0:a.data,F,n),B(this,jt,F),B(this,ct,null)}catch(u){B(this,ct,u)}l(this,ct)&&(O=l(this,ct),F=l(this,jt),I=Date.now(),M="error");const P=C.fetchStatus==="fetching",K=M==="pending",U=M==="error",Z=K&&P,Y=F!==void 0,i={status:M,fetchStatus:C.fetchStatus,isPending:K,isSuccess:M==="success",isError:U,isInitialLoading:Z,isLoading:Z,data:F,dataUpdatedAt:C.dataUpdatedAt,error:O,errorUpdatedAt:I,failureCount:C.fetchFailureCount,failureReason:C.fetchFailureReason,errorUpdateCount:C.errorUpdateCount,isFetched:C.dataUpdateCount>0||C.errorUpdateCount>0,isFetchedAfterMount:C.dataUpdateCount>f.dataUpdateCount||C.errorUpdateCount>f.errorUpdateCount,isFetching:P,isRefetching:P&&!K,isLoadingError:U&&!Y,isPaused:C.fetchStatus==="paused",isPlaceholderData:v,isRefetchError:U&&Y,isStale:cr(t,n),refetch:this.refetch,promise:l(this,Ve),isEnabled:ke(n.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const u=y=>{i.status==="error"?y.reject(i.error):i.data!==void 0&&y.resolve(i.data)},A=()=>{const y=B(this,Ve,i.promise=ar());u(y)},m=l(this,Ve);switch(m.status){case"pending":t.queryHash===r.queryHash&&u(m);break;case"fulfilled":(i.status==="error"||i.data!==m.value)&&A();break;case"rejected":(i.status!=="error"||i.error!==m.reason)&&A();break}}return i}updateResult(){const t=l(this,Ce),n=this.createResult(l(this,X),this.options);if(B(this,Ot,l(this,X).state),B(this,Qt,this.options),l(this,Ot).data!==void 0&&B(this,zt,l(this,X)),bn(n,t))return;B(this,Ce,n);const r=()=>{if(!t)return!0;const{notifyOnChangeProps:s}=this.options,a=typeof s=="function"?s():s;if(a==="all"||!a&&!l(this,$t).size)return!0;const o=new Set(a??l(this,$t));return this.options.throwOnError&&o.add("error"),Object.keys(l(this,Ce)).some(d=>{const p=d;return l(this,Ce)[p]!==t[p]&&o.has(p)})};j(this,ee,qs).call(this,{listeners:r()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&j(this,ee,Er).call(this)}},Se=new WeakMap,X=new WeakMap,sn=new WeakMap,Ce=new WeakMap,Ot=new WeakMap,Qt=new WeakMap,Ve=new WeakMap,ct=new WeakMap,an=new WeakMap,jt=new WeakMap,zt=new WeakMap,It=new WeakMap,kt=new WeakMap,ut=new WeakMap,$t=new WeakMap,ee=new WeakSet,dn=function(t){j(this,ee,Tr).call(this);let n=l(this,X).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(be)),n},yr=function(){j(this,ee,br).call(this);const t=st(this.options.staleTime,l(this,X));if(Tt||l(this,Ce).isStale||!Jn(t))return;const r=Jr(l(this,Ce).dataUpdatedAt,t)+1;B(this,It,Ct.setTimeout(()=>{l(this,Ce).isStale||this.updateResult()},r))},gr=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(l(this,X)):this.options.refetchInterval)??!1},Ar=function(t){j(this,ee,Cr).call(this),B(this,ut,t),!(Tt||ke(this.options.enabled,l(this,X))===!1||!Jn(l(this,ut))||l(this,ut)===0)&&B(this,kt,Ct.setInterval(()=>{(this.options.refetchIntervalInBackground||sr.isFocused())&&j(this,ee,dn).call(this)},l(this,ut)))},Er=function(){j(this,ee,yr).call(this),j(this,ee,Ar).call(this,j(this,ee,gr).call(this))},br=function(){l(this,It)&&(Ct.clearTimeout(l(this,It)),B(this,It,void 0))},Cr=function(){l(this,kt)&&(Ct.clearInterval(l(this,kt)),B(this,kt,void 0))},Tr=function(){const t=l(this,Se).getQueryCache().build(l(this,Se),this.options);if(t===l(this,X))return;const n=l(this,X);B(this,X,t),B(this,sn,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},qs=function(t){ue.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(l(this,Ce))}),l(this,Se).getQueryCache().notify({query:l(this,X),type:"observerResultsUpdated"})})},Ms);function Xi(e,t){return ke(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function ps(e,t){return Xi(e,t)||e.state.data!==void 0&&or(e,t,t.refetchOnMount)}function or(e,t,n){if(ke(t.enabled,e)!==!1&&st(t.staleTime,e)!=="static"){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&cr(e,t)}return!1}function fs(e,t,n,r){return(e!==t||ke(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&cr(e,n)}function cr(e,t){return ke(t.enabled,e)!==!1&&e.isStaleByTime(st(t.staleTime,e))}function Zi(e,t){return!bn(e.getCurrentResult(),t)}function hs(e){return{onFetch:(t,n)=>{var w,C,v,F,O;const r=t.options,s=(v=(C=(w=t.fetchOptions)==null?void 0:w.meta)==null?void 0:C.fetchMore)==null?void 0:v.direction,a=((F=t.state.data)==null?void 0:F.pages)||[],o=((O=t.state.data)==null?void 0:O.pageParams)||[];let d={pages:[],pageParams:[]},p=0;const f=async()=>{let I=!1;const M=K=>{Object.defineProperty(K,"signal",{enumerable:!0,get:()=>(t.signal.aborted?I=!0:t.signal.addEventListener("abort",()=>{I=!0}),t.signal)})},_=ss(t.options,t.fetchOptions),P=async(K,U,Z)=>{if(I)return Promise.reject();if(U==null&&K.pages.length)return Promise.resolve(K);const oe=(()=>{const A={client:t.client,queryKey:t.queryKey,pageParam:U,direction:Z?"backward":"forward",meta:t.options.meta};return M(A),A})(),i=await _(oe),{maxPages:c}=t.options,u=Z?Hi:Ki;return{pages:u(K.pages,i,c),pageParams:u(K.pageParams,U,c)}};if(s&&a.length){const K=s==="backward",U=K?Yi:ms,Z={pages:a,pageParams:o},Y=U(r,Z);d=await P(Z,Y,K)}else{const K=e??a.length;do{const U=p===0?o[0]??r.initialPageParam:ms(r,d);if(p>0&&U==null)break;d=await P(d,U),p++}while(p<K)}return d};t.options.persister?t.fetchFn=()=>{var I,M;return(M=(I=t.options).persister)==null?void 0:M.call(I,f,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=f}}}function ms(e,{pages:t,pageParams:n}){const r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function Yi(e,{pages:t,pageParams:n}){var r;return t.length>0?(r=e.getPreviousPageParam)==null?void 0:r.call(e,t[0],t,n[0],n):void 0}var Ji=(Bs=class extends cs{constructor(t){super();N(this,We);N(this,on);N(this,He);N(this,Te);N(this,Mt);B(this,on,t.client),this.mutationId=t.mutationId,B(this,Te,t.mutationCache),B(this,He,[]),this.state=t.state||ys(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){l(this,He).includes(t)||(l(this,He).push(t),this.clearGcTimeout(),l(this,Te).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){B(this,He,l(this,He).filter(n=>n!==t)),this.scheduleGc(),l(this,Te).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){l(this,He).length||(this.state.status==="pending"?this.scheduleGc():l(this,Te).remove(this))}continue(){var t;return((t=l(this,Mt))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var o,d,p,f,w,C,v,F,O,I,M,_,P,K,U,Z,Y,oe,i,c;const n=()=>{j(this,We,ht).call(this,{type:"continue"})},r={client:l(this,on),meta:this.options.meta,mutationKey:this.options.mutationKey};B(this,Mt,os({fn:()=>this.options.mutationFn?this.options.mutationFn(t,r):Promise.reject(new Error("No mutationFn found")),onFail:(u,A)=>{j(this,We,ht).call(this,{type:"failed",failureCount:u,error:A})},onPause:()=>{j(this,We,ht).call(this,{type:"pause"})},onContinue:n,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>l(this,Te).canRun(this)}));const s=this.state.status==="pending",a=!l(this,Mt).canStart();try{if(s)n();else{j(this,We,ht).call(this,{type:"pending",variables:t,isPaused:a}),await((d=(o=l(this,Te).config).onMutate)==null?void 0:d.call(o,t,this,r));const A=await((f=(p=this.options).onMutate)==null?void 0:f.call(p,t,r));A!==this.state.context&&j(this,We,ht).call(this,{type:"pending",context:A,variables:t,isPaused:a})}const u=await l(this,Mt).start();return await((C=(w=l(this,Te).config).onSuccess)==null?void 0:C.call(w,u,t,this.state.context,this,r)),await((F=(v=this.options).onSuccess)==null?void 0:F.call(v,u,t,this.state.context,r)),await((I=(O=l(this,Te).config).onSettled)==null?void 0:I.call(O,u,null,this.state.variables,this.state.context,this,r)),await((_=(M=this.options).onSettled)==null?void 0:_.call(M,u,null,t,this.state.context,r)),j(this,We,ht).call(this,{type:"success",data:u}),u}catch(u){try{throw await((K=(P=l(this,Te).config).onError)==null?void 0:K.call(P,u,t,this.state.context,this,r)),await((Z=(U=this.options).onError)==null?void 0:Z.call(U,u,t,this.state.context,r)),await((oe=(Y=l(this,Te).config).onSettled)==null?void 0:oe.call(Y,void 0,u,this.state.variables,this.state.context,this,r)),await((c=(i=this.options).onSettled)==null?void 0:c.call(i,void 0,u,t,this.state.context,r)),u}finally{j(this,We,ht).call(this,{type:"error",error:u})}}finally{l(this,Te).runNext(this)}}},on=new WeakMap,He=new WeakMap,Te=new WeakMap,Mt=new WeakMap,We=new WeakSet,ht=function(t){const n=r=>{switch(t.type){case"failed":return{...r,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...r,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:t.error,failureCount:r.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=n(this.state),ue.batch(()=>{l(this,He).forEach(r=>{r.onMutationUpdate(t)}),l(this,Te).notify({mutation:this,type:"updated",action:t})})},Bs);function ys(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var eo=(_s=class extends Nt{constructor(t={}){super();N(this,Ge);N(this,Le);N(this,cn);this.config=t,B(this,Ge,new Set),B(this,Le,new Map),B(this,cn,0)}build(t,n,r){const s=new Ji({client:t,mutationCache:this,mutationId:++Fn(this,cn)._,options:t.defaultMutationOptions(n),state:r});return this.add(s),s}add(t){l(this,Ge).add(t);const n=wn(t);if(typeof n=="string"){const r=l(this,Le).get(n);r?r.push(t):l(this,Le).set(n,[t])}this.notify({type:"added",mutation:t})}remove(t){if(l(this,Ge).delete(t)){const n=wn(t);if(typeof n=="string"){const r=l(this,Le).get(n);if(r)if(r.length>1){const s=r.indexOf(t);s!==-1&&r.splice(s,1)}else r[0]===t&&l(this,Le).delete(n)}}this.notify({type:"removed",mutation:t})}canRun(t){const n=wn(t);if(typeof n=="string"){const r=l(this,Le).get(n),s=r==null?void 0:r.find(a=>a.state.status==="pending");return!s||s===t}else return!0}runNext(t){var r;const n=wn(t);if(typeof n=="string"){const s=(r=l(this,Le).get(n))==null?void 0:r.find(a=>a!==t&&a.state.isPaused);return(s==null?void 0:s.continue())??Promise.resolve()}else return Promise.resolve()}clear(){ue.batch(()=>{l(this,Ge).forEach(t=>{this.notify({type:"removed",mutation:t})}),l(this,Ge).clear(),l(this,Le).clear()})}getAll(){return Array.from(l(this,Ge))}find(t){const n={exact:!0,...t};return this.getAll().find(r=>ts(n,r))}findAll(t={}){return this.getAll().filter(n=>ts(t,n))}notify(t){ue.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){const t=this.getAll().filter(n=>n.state.isPaused);return ue.batch(()=>Promise.all(t.map(n=>n.continue().catch(be))))}},Ge=new WeakMap,Le=new WeakMap,cn=new WeakMap,_s);function wn(e){var t;return(t=e.options.scope)==null?void 0:t.id}var to=(Us=class extends Nt{constructor(t,n){super();N(this,Ye);N(this,Xe);N(this,dt);N(this,Fe);N(this,Ze);B(this,Xe,t),this.setOptions(n),this.bindMethods(),j(this,Ye,Pn).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){var r;const n=this.options;this.options=l(this,Xe).defaultMutationOptions(t),bn(this.options,n)||l(this,Xe).getMutationCache().notify({type:"observerOptionsUpdated",mutation:l(this,Fe),observer:this}),n!=null&&n.mutationKey&&this.options.mutationKey&&wt(n.mutationKey)!==wt(this.options.mutationKey)?this.reset():((r=l(this,Fe))==null?void 0:r.state.status)==="pending"&&l(this,Fe).setOptions(this.options)}onUnsubscribe(){var t;this.hasListeners()||(t=l(this,Fe))==null||t.removeObserver(this)}onMutationUpdate(t){j(this,Ye,Pn).call(this),j(this,Ye,wr).call(this,t)}getCurrentResult(){return l(this,dt)}reset(){var t;(t=l(this,Fe))==null||t.removeObserver(this),B(this,Fe,void 0),j(this,Ye,Pn).call(this),j(this,Ye,wr).call(this)}mutate(t,n){var r;return B(this,Ze,n),(r=l(this,Fe))==null||r.removeObserver(this),B(this,Fe,l(this,Xe).getMutationCache().build(l(this,Xe),this.options)),l(this,Fe).addObserver(this),l(this,Fe).execute(t)}},Xe=new WeakMap,dt=new WeakMap,Fe=new WeakMap,Ze=new WeakMap,Ye=new WeakSet,Pn=function(){var n;const t=((n=l(this,Fe))==null?void 0:n.state)??ys();B(this,dt,{...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset})},wr=function(t){ue.batch(()=>{var n,r,s,a,o,d,p,f;if(l(this,Ze)&&this.hasListeners()){const w=l(this,dt).variables,C=l(this,dt).context,v={client:l(this,Xe),meta:this.options.meta,mutationKey:this.options.mutationKey};(t==null?void 0:t.type)==="success"?((r=(n=l(this,Ze)).onSuccess)==null||r.call(n,t.data,w,C,v),(a=(s=l(this,Ze)).onSettled)==null||a.call(s,t.data,null,w,C,v)):(t==null?void 0:t.type)==="error"&&((d=(o=l(this,Ze)).onError)==null||d.call(o,t.error,w,C,v),(f=(p=l(this,Ze)).onSettled)==null||f.call(p,void 0,t.error,w,C,v))}this.listeners.forEach(w=>{w(l(this,dt))})})},Us),no=(Rs=class extends Nt{constructor(t={}){super();N(this,Qe);this.config=t,B(this,Qe,new Map)}build(t,n,r){const s=n.queryKey,a=n.queryHash??er(s,n);let o=this.get(a);return o||(o=new Vi({client:t,queryKey:s,queryHash:a,options:t.defaultQueryOptions(n),state:r,defaultOptions:t.getQueryDefaults(s)}),this.add(o)),o}add(t){l(this,Qe).has(t.queryHash)||(l(this,Qe).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const n=l(this,Qe).get(t.queryHash);n&&(t.destroy(),n===t&&l(this,Qe).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){ue.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return l(this,Qe).get(t)}getAll(){return[...l(this,Qe).values()]}find(t){const n={exact:!0,...t};return this.getAll().find(r=>es(n,r))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(r=>es(t,r)):n}notify(t){ue.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){ue.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){ue.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Qe=new WeakMap,Rs),ro=(Ls=class{constructor(e={}){N(this,se);N(this,lt);N(this,pt);N(this,Vt);N(this,Gt);N(this,ft);N(this,Xt);N(this,Zt);B(this,se,e.queryCache||new no),B(this,lt,e.mutationCache||new eo),B(this,pt,e.defaultOptions||{}),B(this,Vt,new Map),B(this,Gt,new Map),B(this,ft,0)}mount(){Fn(this,ft)._++,l(this,ft)===1&&(B(this,Xt,sr.subscribe(async e=>{e&&(await this.resumePausedMutations(),l(this,se).onFocus())})),B(this,Zt,Tn.subscribe(async e=>{e&&(await this.resumePausedMutations(),l(this,se).onOnline())})))}unmount(){var e,t;Fn(this,ft)._--,l(this,ft)===0&&((e=l(this,Xt))==null||e.call(this),B(this,Xt,void 0),(t=l(this,Zt))==null||t.call(this),B(this,Zt,void 0))}isFetching(e){return l(this,se).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return l(this,lt).findAll({...e,status:"pending"}).length}getQueryData(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=l(this,se).get(t.queryHash))==null?void 0:n.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=l(this,se).build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(st(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return l(this,se).findAll(e).map(({queryKey:t,state:n})=>{const r=n.data;return[t,r]})}setQueryData(e,t,n){const r=this.defaultQueryOptions({queryKey:e}),s=l(this,se).get(r.queryHash),a=s==null?void 0:s.state.data,o=Li(t,a);if(o!==void 0)return l(this,se).build(this,r).setData(o,{...n,manual:!0})}setQueriesData(e,t,n){return ue.batch(()=>l(this,se).findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,n)]))}getQueryState(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=l(this,se).get(t.queryHash))==null?void 0:n.state}removeQueries(e){const t=l(this,se);ue.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=l(this,se);return ue.batch(()=>(n.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},r=ue.batch(()=>l(this,se).findAll(e).map(s=>s.cancel(n)));return Promise.all(r).then(be).catch(be)}invalidateQueries(e,t={}){return ue.batch(()=>(l(this,se).findAll(e).forEach(n=>{n.invalidate()}),(e==null?void 0:e.refetchType)==="none"?Promise.resolve():this.refetchQueries({...e,type:(e==null?void 0:e.refetchType)??(e==null?void 0:e.type)??"active"},t)))}refetchQueries(e,t={}){const n={...t,cancelRefetch:t.cancelRefetch??!0},r=ue.batch(()=>l(this,se).findAll(e).filter(s=>!s.isDisabled()&&!s.isStatic()).map(s=>{let a=s.fetch(void 0,n);return n.throwOnError||(a=a.catch(be)),s.state.fetchStatus==="paused"?Promise.resolve():a}));return Promise.all(r).then(be)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=l(this,se).build(this,t);return n.isStaleByTime(st(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(be).catch(be)}fetchInfiniteQuery(e){return e.behavior=hs(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(be).catch(be)}ensureInfiniteQueryData(e){return e.behavior=hs(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return Tn.isOnline()?l(this,lt).resumePausedMutations():Promise.resolve()}getQueryCache(){return l(this,se)}getMutationCache(){return l(this,lt)}getDefaultOptions(){return l(this,pt)}setDefaultOptions(e){B(this,pt,e)}setQueryDefaults(e,t){l(this,Vt).set(wt(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...l(this,Vt).values()],n={};return t.forEach(r=>{tn(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){l(this,Gt).set(wt(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...l(this,Gt).values()],n={};return t.forEach(r=>{tn(e,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...l(this,pt).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=er(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===Cn&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...l(this,pt).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){l(this,se).clear(),l(this,lt).clear()}},se=new WeakMap,lt=new WeakMap,pt=new WeakMap,Vt=new WeakMap,Gt=new WeakMap,ft=new WeakMap,Xt=new WeakMap,Zt=new WeakMap,Ls),gs=ce.createContext(void 0),ur=e=>{const t=ce.useContext(gs);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},so=({client:e,children:t})=>(ce.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),H.jsx(gs.Provider,{value:e,children:t})),As=ce.createContext(!1),ao=()=>ce.useContext(As);As.Provider;function io(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var oo=ce.createContext(io()),co=()=>ce.useContext(oo),uo=(e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))},lo=e=>{ce.useEffect(()=>{e.clearReset()},[e])},po=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:s})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(s&&e.data===void 0||as(n,[e.error,r])),fo=e=>{if(e.suspense){const n=s=>s==="static"?s:Math.max(s??1e3,1e3),r=e.staleTime;e.staleTime=typeof r=="function"?(...s)=>n(r(...s)):n(r),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},ho=(e,t)=>e.isLoading&&e.isFetching&&!t,mo=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,Es=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function yo(e,t,n){var C,v,F,O,I;if(process.env.NODE_ENV!=="production"&&(typeof e!="object"||Array.isArray(e)))throw new Error('Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object');const r=ao(),s=co(),a=ur(),o=a.defaultQueryOptions(e);(v=(C=a.getDefaultOptions().queries)==null?void 0:C._experimental_beforeQuery)==null||v.call(C,o),process.env.NODE_ENV!=="production"&&(o.queryFn||console.error(`[${o.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`)),o._optimisticResults=r?"isRestoring":"optimistic",fo(o),uo(o,s),lo(s);const d=!a.getQueryCache().get(o.queryHash),[p]=ce.useState(()=>new t(a,o)),f=p.getOptimisticResult(o),w=!r&&e.subscribed!==!1;if(ce.useSyncExternalStore(ce.useCallback(M=>{const _=w?p.subscribe(ue.batchCalls(M)):be;return p.updateResult(),_},[p,w]),()=>p.getCurrentResult(),()=>p.getCurrentResult()),ce.useEffect(()=>{p.setOptions(o)},[o,p]),mo(o,f))throw Es(o,p,s);if(po({result:f,errorResetBoundary:s,throwOnError:o.throwOnError,query:a.getQueryCache().get(o.queryHash),suspense:o.suspense}))throw f.error;if((O=(F=a.getDefaultOptions().queries)==null?void 0:F._experimental_afterQuery)==null||O.call(F,o,f),o.experimental_prefetchInRender&&!Tt&&ho(f,r)){const M=d?Es(o,p,s):(I=a.getQueryCache().get(o.queryHash))==null?void 0:I.promise;M==null||M.catch(be).finally(()=>{p.updateResult()})}return o.notifyOnChangeProps?f:p.trackResult(f)}function go(e,t){return yo(e,Gi)}function at(e,t){const n=ur(),[r]=ce.useState(()=>new to(n,e));ce.useEffect(()=>{r.setOptions(e)},[r,e]);const s=ce.useSyncExternalStore(ce.useCallback(o=>r.subscribe(ue.batchCalls(o)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=ce.useCallback((o,d)=>{r.mutate(o,d).catch(be)},[r]);if(s.error&&as(r.options.throwOnError,[s.error]))throw s.error;return{...s,mutate:a,mutateAsync:s.mutate}}const nn=()=>{const e=Q(a=>a.state.swapExecutionIndex),t=Q(a=>a.state.swapExecutions[a.state.swapExecutionIndex]??{}),n=Q(a=>a.updateSwapExecutionAtIndex),r=Q(a=>a.resetSwapExecutionAtIndex),s=S.useCallback(a=>n(e,a),[n,e]);return S.useMemo(()=>({...t,update:s,resetSwap:r}),[t,s,r])},Ao=2e4,Eo=()=>{const{module:e}=q(),t=Q(n=>n.state.isMarketOrder);return S.useMemo(()=>e===$.TWAP?t?V.TWAP_MARKET:V.TWAP_LIMIT:e===$.LIMIT?V.LIMIT:e===$.STOP_LOSS?t?V.STOP_LOSS_MARKET:V.STOP_LOSS_LIMIT:e===$.TAKE_PROFIT?t?V.TAKE_PROFIT_MARKET:V.TAKE_PROFIT_LIMIT:V.TWAP_MARKET,[e,t])},bs=()=>{const{account:e,config:t,chainId:n,isDev:r}=q();return S.useMemo(()=>["useTwapOrderHistoryManager",e,t==null?void 0:t.adapter,n,r],[e,t,n,r])},bo=()=>{const{callbacks:e}=q(),t=ur(),n=bs();return S.useCallback(r=>{var d;const s=t.getQueryData(n);let a=!1;const o=[];s&&s.filter(p=>p.version===2).forEach(p=>{var w;const f=r.find(C=>C.id===p.id);f&&f.progress!==p.progress&&(a=!0,o.push(f),f.status===he.Completed&&((w=e==null?void 0:e.onOrderFilled)==null||w.call(e,f)))}),a&&((d=e==null?void 0:e.onOrdersProgressUpdate)==null||d.call(e,o))},[t,n,e])},dr=()=>{const{account:e,config:t,chainId:n,isDev:r}=q(),s=bs(),a=bo();return go({refetchInterval:Ao,refetchOnWindowFocus:!0,retry:!1,staleTime:1/0,queryKey:s,queryFn:async({signal:d})=>{if(!e||!n||!t)return[];const p=await oi({signal:d,chainId:n,config:t,account:e,isDev:r});return a(p),p.map(f=>t!=null&&t.twapConfig?{...f,fillDelayMillis:Ln(f,t.twapConfig)}:f)}})},Co=(e,t,n)=>S.useMemo(()=>{if(!(!e||!t||!n||n!=null&&n.isMarketPrice))return Mr(n,e==null?void 0:e.decimals,t==null?void 0:t.decimals)},[n,e,t]),To=(e,t,n)=>S.useMemo(()=>{if(!(!e||!t||!n))return Br(n,e.decimals,t.decimals)},[n,e,t]),wo=(e,t,n)=>S.useMemo(()=>{if(!(!e||!t||!n))return Nn(n.srcAmountFilled,n.dstAmountFilled,e.decimals,t.decimals)},[n,e,t]),vn=(e,t)=>[...e.filter(r=>r.status===t)].sort((r,s)=>s.createdAt-r.createdAt),vo=()=>{const{data:e,isLoading:t,refetch:n,isRefetching:r}=dr(),s=S.useCallback(()=>n().then(a=>a.data),[n]);return S.useMemo(()=>({orders:{all:e??[],open:vn(e??[],he.Open),completed:vn(e??[],he.Completed),cancelled:vn(e??[],he.Cancelled),expired:vn(e??[],he.Expired)},isLoading:t,isRefetching:r,refetchOrders:s}),[e,t,r,s])},lr=()=>{const e=Q(n=>n.state.currentTime),t=Xn().duration;return S.useMemo(()=>Ca(e,t),[e,t])},Cs=()=>{const{srcToken:e,dstToken:t,account:n,chainId:r,slippage:s,config:a,module:o,fees:d}=q(),{amount:p}=rt(),{amountPerTrade:f,totalTrades:w}=qe(),C=lr(),{amount:v}=Yn(),{pricePerChunk:F}=bt(),{milliseconds:O}=Lt();return S.useMemo(()=>{var I;return Rr({chainId:r,srcToken:Ut((e==null?void 0:e.address)||"")?((I=At(r))==null?void 0:I.wToken.address)||"":(e==null?void 0:e.address)||"",dstToken:(t==null?void 0:t.address)||"",srcAmount:p,deadlineMillis:C,fillDelayMillis:!w||w===1?0:O,slippage:s*100,account:n,srcAmountPerTrade:f,dstMinAmountPerTrade:v,triggerAmountPerTrade:F,config:a,module:o})},[e,t,n,r,s,a,o,p,f,w,O,v,F,d])};function xo(e){const t=e.slice(2);if(t.length===128){const a=`0x${t.slice(0,64)}`,o=parseInt(t.charAt(64),16),d=(o>>3)+27,p=`0x${(o&7).toString(16)}${t.slice(65,128)}`;return{r:a,s:p,v:d}}const n=`0x${t.slice(0,64)}`,r=`0x${t.slice(64,128)}`,s=parseInt(t.slice(128,130),16);return{r:n,s:r,v:s}}const So=()=>{var a;const{account:e,walletInteractions:t,callbacks:n,chainId:r}=q(),s=(a=yn())==null?void 0:a.wToken;return at({mutationFn:async({onHash:o,srcAmountWei:d})=>{var f,w;if(!e)throw new Error("missing account");if(!t)throw new Error("missing walletInteractions");if(!s)throw new Error("tokenAddress is not defined");pe.onWrapRequest();const p=await t.wrapNativeToken(d);return(f=n==null?void 0:n.onWrapRequest)==null||f.call(n),o==null||o(p),pe.onWrapSuccess(p),(w=n==null?void 0:n.onWrapSuccess)==null||w.call(n,{txHash:p,explorerUrl:Rt(p,r),amount:Ee(d,s.decimals)}),p},onError:o=>{throw pe.onWrapError(o),o}})},Ts=()=>{const{account:e,walletInteractions:t,chainId:n,callbacks:r}=q(),s=Cs(),{refetch:a}=dr();return at({mutationFn:async()=>{var O,I,M,_;if(!e)throw new Error("missing account");if(!t)throw new Error("missing walletInteractions");if(!n)throw new Error("missing chainId");const{order:o,domain:d,types:p,primaryType:f}=s;pe.onSignOrderRequest(o);let w;try{w=await t.signOrder({domain:d,types:p,primaryType:f,message:o,account:e})}catch(P){throw(O=r==null?void 0:r.onSignOrderError)==null||O.call(r,P),pe.onSignOrderError(P),P}pe.onSignOrderSuccess(w),(I=r==null?void 0:r.onSignOrderSuccess)==null||I.call(r,w);const C=xo(w),v={v:`0x${C.v.toString(16)}`,r:C.r,s:C.s};(M=r==null?void 0:r.onSignOrderRequest)==null||M.call(r);const F=await qr(o,v);return(_=r==null?void 0:r.onOrderCreated)==null||_.call(r,F),await a(),F}})},ws=()=>{const{account:e,walletInteractions:t,config:n}=q();return at({mutationFn:async({tokenAddress:r,srcAmountWei:s})=>{if(!t)throw new Error("missing walletInteractions");if(!e)throw new Error("missing account");if(!n)throw new Error("missing config");const a=await t.getAllowance({tokenAddress:r,spenderAddress:n.repermit}),o=x(a||"0").lt(x(s).toString());return{allowance:a,approvalRequired:o}}})},Fo=()=>{const{account:e,walletInteractions:t,config:n,chainId:r,callbacks:s}=q(),{mutateAsync:a}=ws();return at({onError:o=>{pe.onApproveError(o)},mutationFn:async({token:o,onHash:d,srcAmountWei:p})=>{var C,v;if(!e)throw new Error("missing account");if(!t)throw new Error("missing walletInteractions");if(!n)throw new Error("missing config");pe.onApproveRequest();const f=await t.approveToken({tokenAddress:o.address,amount:p,spenderAddress:n.repermit});if(!f)throw new Error("failed to approve token");(C=s==null?void 0:s.onApproveRequest)==null||C.call(s),d(f);let w=!1;for(let F=0;F<3;F++){const{approvalRequired:O}=await a({tokenAddress:o.address,srcAmountWei:p});if(!O){w=!0;break}F<2&&await new Promise(I=>setTimeout(I,3e3))}if(!w)throw new Error(`Insufficient ${o.symbol} allowance to perform the swap. Please approve the token first.`);return pe.onApproveSuccess(f),(v=s==null?void 0:s.onApproveSuccess)==null||v.call(s,{txHash:f,explorerUrl:Rt(f,r),token:o,amount:Ee(p,o.decimals)}),f}})},Po=()=>{const{account:e,chainId:t,srcToken:n,dstToken:r,module:s,slippage:a}=q(),o=bt(),d=rt().amount,p=qe().amountPerTrade,f=lr(),w=qe().totalTrades,C=Lt().fillDelay,v=Yn().amount,F=Q(O=>O.state.isMarketOrder);return at({mutationFn:async()=>{pe.onRequestOrder({account:e,chainId:t,module:s,srcToken:n,dstToken:r,fromTokenAmount:d,srcChunkAmount:p,triggerPricePerTrade:o.pricePerChunk,deadline:f,fillDelay:C.unit*C.value,minDstAmountOutPerTrade:v,slippage:a,isMarketOrder:F||!1,chunksAmount:w})}})};function Do(e){const t=e.message,n=t.match(/,\s*code\s*:\s*(\d+)/i);return{message:t.replace(/^error\s*:/i,"").replace(/,\s*code\s*:\s*\d+/i,"").trim()||"",code:n?Number(n[1]):0}}const vs=()=>{const{srcToken:e,dstToken:t,chainId:n,callbacks:r,marketPrice:s}=q(),a=Fo().mutateAsync,o=So().mutateAsync,d=Ts().mutateAsync,{mutateAsync:p}=ws(),{update:f}=nn(),{amount:w}=rt(),C=Po().mutate;return at({mutationFn:async()=>{var F,O;const v=Ut((e==null?void 0:e.address)||" ");try{if(!e)throw new Error("missing srcToken");if(!t)throw new Error("missing dstToken");if(!n)throw new Error("missing chainId");const I=$r(e,n);f({allowanceLoading:!0,wrapTxHash:void 0,approveTxHash:void 0,acceptedMarketPrice:s,acceptedSrcAmount:w,srcToken:e,dstToken:t,pendingSteps:[]});const{approvalRequired:M}=await p({tokenAddress:I.address,srcAmountWei:w});let _=0,P=1;v&&P++,M&&P++,f({totalSteps:P,stepIndex:_,allowanceLoading:!1,hasApproval:!M,status:xe.LOADING}),C();let K=[];v&&K.push(tt.WRAP),M&&K.push(tt.APPROVE),K.push(tt.CREATE),f({pendingSteps:K}),v&&(f({step:tt.WRAP}),await o({onHash:Z=>f({wrapTxHash:Z}),srcAmountWei:w}),_++,f({stepIndex:_})),M&&(f({step:tt.APPROVE}),await a({token:I,onHash:Z=>f({approveTxHash:Z}),srcAmountWei:w}),_++,f({stepIndex:_})),f({step:tt.CREATE});const U=await d();return f({status:xe.SUCCESS,orderId:U.id}),U}catch(I){if(zn(I))(F=r==null?void 0:r.onSubmitOrderRejected)==null||F.call(r),f({step:void 0,status:void 0,stepIndex:void 0,error:I});else{const M=Do(I);(O=r==null?void 0:r.onSubmitOrderFailed)==null||O.call(r,M),f({status:xe.FAILED,parsedError:M,error:I})}throw I}}})},Oo=()=>{const e=nn(),{srcToken:t,dstToken:n}=q(),r=vs(),s=Q(f=>f.resetState),a=S.useCallback(()=>r.mutateAsync(),[r]),{update:o,resetSwap:d,...p}=e;return S.useMemo(()=>({status:p.status,parsedError:p.parsedError,error:p.error,step:p.step,stepIndex:p.stepIndex,approveTxHash:p.approveTxHash,wrapTxHash:p.wrapTxHash,totalSteps:p.totalSteps,pendingSteps:p.pendingSteps,srcToken:t,dstToken:n,onSubmit:a,resetState:s,resetCurrentSwap:d,isLoading:(e==null?void 0:e.status)===xe.LOADING,isSuccess:(e==null?void 0:e.status)===xe.SUCCESS,isFailed:(e==null?void 0:e.status)===xe.FAILED,confirmButtonLoading:p.allowanceLoading}),[a,p,s,d,t,n])},Io=()=>{const{marketPrice:e,srcToken:t,dstToken:n,marketPriceLoading:r,srcBalance:s,srcUsd1Token:a,noLiquidity:o,typedInputAmount:d}=q(),p=r||x(a||"0").isZero()||s===void 0||x(e||"0").isZero(),f=!!(t&&n&&d&&p),C=!!(Yr()||o||f||x(d||"0").isZero()||!t||!n);return S.useMemo(()=>({disabled:C,loading:f}),[C,f])},ko=()=>{const{srcUsd1Token:e,dstUsd1Token:t}=q(),n=rt().amountUI,r=En().amountUI,s=nt(n,e),a=nt(r,t);return{srcAmountUsd:s,dstAmountUsd:a}},Mo=()=>{const{fees:e,dstToken:t,dstUsd1Token:n}=q(),{amountUI:r}=En(),s=S.useMemo(()=>!e||!r?"":x(r).multipliedBy(e).dividedBy(100).toFixed(),[r,e]),a=Gn((t==null?void 0:t.decimals)||0,s);return{amountUI:s,amount:a,percent:e,usd:nt(s,n)}},Bo=e=>{const t=S.useMemo(()=>!e.minDestAmountPerTrade||!e.totalTrades?"":x(e.minDestAmountPerTrade).multipliedBy(e.totalTrades).decimalPlaces(0).toFixed(),[e.minDestAmountPerTrade,e.totalTrades]),n=S.useMemo(()=>!e.minDestAmountPerTradeUI||!e.totalTrades?"":x(e.minDestAmountPerTradeUI).multipliedBy(e.totalTrades).toFixed(),[e.minDestAmountPerTradeUI,e.totalTrades]),r=S.useMemo(()=>!e.minDestAmountPerTradeUsd||!e.totalTrades?"":x(e.minDestAmountPerTradeUsd).multipliedBy(e.totalTrades).decimalPlaces(2).toFixed(),[e.minDestAmountPerTradeUsd,e.totalTrades]);return S.useMemo(()=>({srcToken:e.srcToken,dstToken:e.dstToken,orderType:e.orderType,createdAt:e.createdAt||0,deadline:e.deadline||0,totalTrades:e.totalTrades||0,tradeInterval:e.tradeInterval||0,recipient:e.account||"",srcAmount:e.srcAmount||"",srcAmountUI:e.srcAmountUI||"",srcAmountUsd:e.srcAmountUsd||"",dstAmount:e.dstAmount||"",dstAmountUI:e.dstAmountUI||"",dstAmountUsd:e.dstAmountUsd||"",limitPrice:e.limitPrice||"",limitPriceUI:e.limitPriceUI||"",limitPriceUsd:e.limitPriceUsd||"",sizePerTrade:e.srcAmountPerTrade||"",sizePerTradeUI:e.srcAmountPerTradeUI||"",sizePerTradeUsd:e.srcAmountPerTradeUsd,minDestAmountPerTrade:e.minDestAmountPerTrade||"",minDestAmountPerTradeUI:e.minDestAmountPerTradeUI||"",minDestAmountPerTradeUsd:e.minDestAmountPerTradeUsd,dstMinAmount:t,dstMinAmountUI:n,dstMinAmountUsd:r,triggerPrice:e.triggerPrice||"",triggerPriceUI:e.triggerPriceUI||"",triggerPriceUsd:e.triggerPriceUsd}),[e.srcToken,e.dstToken,e.orderType,e.createdAt,e.deadline,e.totalTrades,e.tradeInterval,e.account,e.srcAmount,e.srcAmountUI,e.srcAmountUsd,e.dstAmount,e.dstAmountUI,e.dstAmountUsd,e.limitPrice,e.limitPriceUI,e.limitPriceUsd,e.srcAmountPerTrade,e.srcAmountPerTradeUI,e.srcAmountPerTradeUsd,e.minDestAmountPerTrade,e.minDestAmountPerTradeUI,e.minDestAmountPerTradeUsd,t,n,r,e.triggerPrice,e.triggerPriceUI,e.triggerPriceUsd])},_o=()=>{const{config:e}=q();return S.useMemo(()=>({spender:e.repermit}),[e])},Uo=()=>{const{srcToken:e,dstToken:t,account:n,marketPrice:r}=q(),{spender:s}=_o(),{amount:a}=rt(),{amount:o,amountUI:d,usd:p}=An(),{amountPerTrade:f,amountPerTradeUI:w,amountPerTradeUsd:C,totalTrades:v}=qe(),F=lr(),{amount:O,amountUI:I,usd:M}=Yn(),{amountUI:_,amount:P,usd:K}=bt(),{milliseconds:U}=Lt(),{amount:Z,amountUI:Y}=En(),{srcAmountUsd:oe,dstAmountUsd:i}=ko(),{amount:c,amountUI:u,percent:A,usd:m}=Mo(),y=Cs(),T=Q(G=>G.state.isMarketOrder),h=Q(G=>G.state.currentTime),g=nn(),b=Eo(),E=g.acceptedSrcAmount||a,D=Ee(r,(t==null?void 0:t.decimals)||0),R=S.useMemo(()=>b===V.TAKE_PROFIT_MARKET||b===V.TAKE_PROFIT_LIMIT||b===V.STOP_LOSS_LIMIT||b===V.STOP_LOSS_MARKET,[b]),L=Bo({srcToken:e,dstToken:t,account:n,orderType:b,createdAt:h,deadline:F,totalTrades:v,tradeInterval:U,srcAmount:E,srcAmountUI:Ee(E,(e==null?void 0:e.decimals)||0),srcAmountUsd:oe,dstAmount:Z,dstAmountUI:Y,dstAmountUsd:i,limitPrice:T?void 0:o,limitPriceUI:T?void 0:d,limitPriceUsd:T?void 0:p,srcAmountPerTrade:f,srcAmountPerTradeUI:w,srcAmountPerTradeUsd:C,minDestAmountPerTrade:O,minDestAmountPerTradeUI:I,minDestAmountPerTradeUsd:M,triggerPrice:P,triggerPriceUI:_,triggerPriceUsd:K});return S.useMemo(()=>({...L,feesAmountUI:u,feesAmount:c,feesUsd:m||"",feesPercentage:A,rePermitData:y,isTriggerPrice:R,isMarketOrder:T,marketPrice:r,marketPriceUi:D,spender:s}),[L,u,c,m,A,y,R,T,r,D,s])},Ro=()=>{const{supportedChains:e}=q();return S.useMemo(()=>e,[e])},Lo=60,xs=()=>{const{refetch:e}=dr();return at({mutationFn:async t=>{var n;for(let r=0;r<Lo;r++){const s=(n=await e())==null?void 0:n.data;if(!s)throw new Error("orders not found");const a=s.find(o=>o.id===t);if((a==null?void 0:a.status)===he.Cancelled)return;await new Promise(o=>setTimeout(o,1e3))}throw new Error("Timed out waiting for order cancellation to be confirmed")}})},No=()=>{const e=Q(n=>n.updateState),t=Q(n=>n.state.cancelOrders);return{cancelOrders:t,setCancelOrder:(n,r)=>{e({cancelOrders:{...t,[n]:r}})},clearCancelOrder:n=>{const{[n]:r,...s}=t;e({cancelOrders:s})}}},qo=e=>{const{account:t,walletInteractions:n,config:r,callbacks:s,chainId:a}=q(),o=xs().mutateAsync,{cancelOrders:d,setCancelOrder:p,clearCancelOrder:f}=No(),{mutateAsync:w}=at({mutationFn:async()=>{var O,I,M;if(!t||!n||!r)throw new Error("missing required parameters");if(!e)throw new Error("order is required");const F=e.id;try{(O=s==null?void 0:s.onCancelOrderRequest)==null||O.call(s,e),p(F,{status:xe.LOADING}),pe.onCancelOrderRequest([e.version===1?e.id.toString():e.hash],e.version);const _=await n.cancelOrder({order:e,contractAddress:e.version===1?e.twapAddress:r.repermit,args:e.version===1?[e.id]:[[e.repermitDigest]],abi:e.version===1?Ws:Hs});if(!_)throw new Error("failed to cancel order");return pe.onCancelOrderSuccess(_),await o(e.id),(I=s==null?void 0:s.onCancelOrderSuccess)==null||I.call(s,{order:e,txHash:_,explorerUrl:Rt(_,a)}),p(F,{status:xe.SUCCESS,txHash:_}),_}catch(_){console.error("cancel order error",_),(M=s==null?void 0:s.onCancelOrderFailed)==null||M.call(s,_),zn(_)?f(F):(p(F,{status:xe.FAILED,error:_.message}),pe.onCancelOrderError(_))}}}),C=S.useMemo(()=>{const F=d[(e==null?void 0:e.id)||""];return{isLoading:(F==null?void 0:F.status)===xe.LOADING,isSuccess:(F==null?void 0:F.status)===xe.SUCCESS,isError:(F==null?void 0:F.status)===xe.FAILED,error:F==null?void 0:F.error,txHash:F==null?void 0:F.txHash}},[d,e==null?void 0:e.id]),v=S.useCallback(async()=>w(),[w]);return S.useMemo(()=>({cancelOrder:v,...C}),[v,C])},Ss=S.createContext(null),Ko=({children:e})=>{const t=bi(),n=vi(),r=Ti(),s=Oi(),a=Ii(),o=gn(),d=ki(),p=Mi(),f=Yr(),w=Io(),C=Uo(),v=vo(),F=Oo(),O=Ro(),I=xs(),{module:M}=q(),_={tradesAmountPanel:t,durationPanel:n,fillDelayPanel:r,limitPricePanel:s,triggerPricePanel:a,pricePanel:o,dstTokenPanel:d,disclaimerPanel:p,inputError:f,submitOrderButton:w,derivedFormData:C,orderHistoryPanel:v,orderExecutionPanel:F,supportedChains:O,refetchUntilStatusSynced:I,module:M};return H.jsx(Ss.Provider,{value:_,children:e})},Ho=()=>{const e=S.useContext(Ss);if(e===null)throw new Error("useSpot must be used within SpotProvider");return e},Wo=S.createContext(null),pr={didCatch:!1,error:null};class Qo extends S.Component{constructor(t){super(t),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=pr}static getDerivedStateFromError(t){return{didCatch:!0,error:t}}resetErrorBoundary(){const{error:t}=this.state;if(t!==null){for(var n,r,s=arguments.length,a=new Array(s),o=0;o<s;o++)a[o]=arguments[o];(n=(r=this.props).onReset)===null||n===void 0||n.call(r,{args:a,reason:"imperative-api"}),this.setState(pr)}}componentDidCatch(t,n){var r,s;(r=(s=this.props).onError)===null||r===void 0||r.call(s,t,n)}componentDidUpdate(t,n){const{didCatch:r}=this.state,{resetKeys:s}=this.props;if(r&&n.error!==null&&jo(t.resetKeys,s)){var a,o;(a=(o=this.props).onReset)===null||a===void 0||a.call(o,{next:s,prev:t.resetKeys,reason:"keys"}),this.setState(pr)}}render(){const{children:t,fallbackRender:n,FallbackComponent:r,fallback:s}=this.props,{didCatch:a,error:o}=this.state;let d=t;if(a){const p={error:o,resetErrorBoundary:this.resetErrorBoundary};if(typeof n=="function")d=n(p);else if(r)d=S.createElement(r,p);else if(s!==void 0)d=s;else throw o}return S.createElement(Wo.Provider,{value:{didCatch:a,error:o,resetErrorBoundary:this.resetErrorBoundary}},d)}}function jo(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return e.length!==t.length||e.some((n,r)=>!Object.is(n,t[r]))}const zo=()=>H.jsx("div",{className:"twap-error-fallback",children:H.jsx("p",{style:{fontSize:20,fontWeight:600,textAlign:"center",width:"100%",marginTop:40},children:"Something went wrong"})});function $o({children:e}){return H.jsx(Qo,{FallbackComponent:zo,onError:t=>pe.onCrash(t),children:H.jsx(H.Fragment,{children:e})})}const Fs=S.createContext(null),Vo=new ro({defaultOptions:{queries:{refetchOnWindowFocus:!1}}}),Go=e=>{var r,s,a;const t=Q(o=>o.updateState),n=Q(o=>o.state.isMarketOrder);return S.useEffect(()=>{const o=setInterval(()=>{t({currentTime:Date.now()})},6e4);return()=>clearInterval(o)},[t]),S.useEffect(()=>{var d,p,f,w,C,v,F,O,I,M,_,P,K,U,Z,Y;const o=(p=(d=e.overrides)==null?void 0:d.state)==null?void 0:p.isMarketOrder;o!==void 0&&t({isMarketOrder:o}),t({typedChunks:(w=(f=e.overrides)==null?void 0:f.state)==null?void 0:w.chunks,typedFillDelay:(v=(C=e.overrides)==null?void 0:C.state)==null?void 0:v.fillDelay,typedDuration:(O=(F=e.overrides)==null?void 0:F.state)==null?void 0:O.duration,typedLimitPrice:(M=(I=e.overrides)==null?void 0:I.state)==null?void 0:M.limitPrice,typedTriggerPrice:(P=(_=e.overrides)==null?void 0:_.state)==null?void 0:P.triggerPrice,triggerPricePercent:(U=(K=e.overrides)==null?void 0:K.state)==null?void 0:U.triggerPricePercent,limitPricePercent:(Y=(Z=e.overrides)==null?void 0:Z.state)==null?void 0:Y.limitPricePercent})},[(r=e.overrides)==null?void 0:r.state,e.module]),S.useEffect(()=>{var o,d,p,f;t({typedLimitPrice:(d=(o=e.overrides)==null?void 0:o.state)==null?void 0:d.limitPrice,typedTriggerPrice:(f=(p=e.overrides)==null?void 0:p.state)==null?void 0:f.triggerPrice,triggerPricePercent:void 0,limitPricePercent:void 0})},[(s=e.srcToken)==null?void 0:s.address,(a=e.dstToken)==null?void 0:a.address]),S.useEffect(()=>{e.module===$.LIMIT&&t({isMarketOrder:!1})},[e.module]),S.useEffect(()=>{n&&t({isInvertedTrade:!1})},[n]),S.useEffect(()=>{t({typedChunks:void 0})},[e.typedInputAmount]),null},Xo=({marketReferencePrice:e,srcToken:t,dstToken:n,chainId:r,typedInputAmount:s})=>S.useMemo(()=>{if($n(t,n,r)||Vn(t,n,r))return{isLoading:!1,noLiquidity:!1,value:Et(s||"0",t==null?void 0:t.decimals)};if(x(e.value||0).isZero()||x(s||0).isZero())return e;const a=x(e.value||0).dividedBy(s||0).decimalPlaces(0).toFixed();return{...e,value:a}},[e,s,t,n,r]),Zo=e=>{const t=nn(),n=S.useMemo(()=>kr(e.partner),[e.partner]),r=S.useMemo(()=>{const d=n[0];return e.chainId&&n.includes(e.chainId)?e.chainId:d},[e.chainId,n]),s=S.useMemo(()=>qn(e.partner,r),[e.partner,r]),a=Xo(e),o=S.useMemo(()=>Ur(e.minChunkSizeUsd),[e.minChunkSizeUsd]);return S.useEffect(()=>{pe.init(s,o,r)},[s,r,o]),H.jsxs(Fs.Provider,{value:{typedInputAmount:e.typedInputAmount,minChunkSizeUsd:o,account:e.account,walletInteractions:e.walletInteractions,marketPrice:t.acceptedMarketPrice||a.value,marketPriceLoading:!t.acceptedMarketPrice&&a.isLoading,noLiquidity:!t.acceptedMarketPrice&&a.noLiquidity,config:s,slippage:e.priceProtection,supportedChains:n,chainId:r,partner:e.partner,module:e.module,fees:e.fees||0,overrides:e.overrides,callbacks:e.callbacks,srcUsd1Token:e.srcUsd1Token,dstUsd1Token:e.dstUsd1Token,srcBalance:e.srcBalance,dstBalance:e.dstBalance,srcToken:t.srcToken||e.srcToken,dstToken:t.dstToken||e.dstToken,isDev:e.isDev},children:[H.jsx(Go,{...e}),H.jsx(Ko,{children:H.jsx($o,{children:e.children})})]})},Yo=e=>H.jsx(so,{client:Vo,children:H.jsx(Zo,{...e})}),q=()=>{const e=S.useContext(Fs);if(e===null)throw new Error("useSpotContext must be used within SpotProvider");return e},Jo=(e,t,n)=>{const r=yn();return S.useMemo(()=>e==null?void 0:e.map(s=>({srcToken:t,dstToken:n,srcAmount:Ee(s.inAmount,t==null?void 0:t.decimals),dstAmount:Ee(s.outAmount,n==null?void 0:n.decimals),timestamp:s.timestamp,txHash:s.txHash,explorerUrl:Rt(s.txHash,r==null?void 0:r.id),executionRate:Nn(s.inAmount,s.outAmount,t==null?void 0:t.decimals,n==null?void 0:n.decimals)})).filter(s=>s.srcToken!==void 0&&s.dstToken!==void 0),[e,t,n,r])},ec=(e,t,n)=>{const{config:r}=q(),s=Co(t,n,e),a=To(t,n,e),o=wo(t,n,e),d=S.useMemo(()=>e?e.version===2?e.fillDelay:r.twapConfig?Ln(e,r.twapConfig):0:0,[e,r]),p=Jo(e==null?void 0:e.fills,t,n)??[];return S.useMemo(()=>{if(e!=null&&e.id)return{original:e,fills:p,srcToken:t,dstToken:n,orderType:e.type,createdAt:e.createdAt,deadline:e.deadline||0,totalTrades:e.totalTradesAmount||0,tradeInterval:d,recipient:e.maker||"",srcAmount:e.srcAmount||"",srcAmountUI:Ee(e.srcAmount,t==null?void 0:t.decimals),limitPrice:Et(s,n==null?void 0:n.decimals),limitPriceUI:s||"",sizePerTrade:e.srcAmountPerTrade||"",sizePerTradeUI:Ee(e.srcAmountPerTrade,t==null?void 0:t.decimals),minDestAmountPerTrade:e.dstMinAmountPerTrade||"",minDestAmountPerTradeUI:Ee(e.dstMinAmountPerTrade,n==null?void 0:n.decimals),dstMinAmount:e.dstMinAmountTotal,dstMinAmountUI:Ee(e.dstMinAmountTotal,n==null?void 0:n.decimals),triggerPrice:Et(a,n==null?void 0:n.decimals),triggerPriceUI:a||"",id:e.id,amountInFilled:e.srcAmountFilled,amountInFilledUI:Ee(e.srcAmountFilled,t==null?void 0:t.decimals),amountOutFilled:e.dstAmountFilled,amountOutFilledUI:Ee(e.dstAmountFilled,n==null?void 0:n.decimals),progress:e.progress,executionPrice:Et(o,n==null?void 0:n.decimals),executionPriceUI:o,version:e.version}},[e,p,t,n,d,s,a,o])};La(ci.version),k.DISCLAIMER_URL=ra,k.Disclaimer=Jt,k.InputErrors=me,k.Module=$,k.ORBS_LOGO=ta,k.ORBS_SLTP_FAQ_URL=ea,k.ORBS_TWAP_FAQ_URL=Js,k.ORBS_WEBSITE_URL=na,k.OrderFilter=vr,k.OrderStatus=he,k.OrderType=V,k.Partners=Ne,k.SPOT_VERSION=On,k.SpotProvider=Yo,k.Steps=tt,k.SwapStatus=xe,k.TimeUnit=Pe,k.buildRePermitOrderData=Rr,k.ensureWrappedToken=$r,k.eqIgnoreCase=yt,k.getConfig=qn,k.getExplorerUrl=Rt,k.getMinChunkSizeUsd=Ur,k.getNetwork=At,k.getOrderExecutionRate=Nn,k.getOrderFillDelayMillis=Ln,k.getOrderLimitPriceRate=Mr,k.getOrderType=hi,k.getPartnerChains=kr,k.getPartners=_r,k.getTriggerPriceRate=Br,k.isNativeAddress=Ut,k.isTxRejected=zn,k.millisToDays=Vr,k.millisToMinutes=Gr,k.networks=ye,k.parseError=fi,k.shouldUnwrapOnly=Vn,k.shouldWrapOnly=$n,k.submitOrder=qr,k.toAmountUi=Ee,k.toAmountWei=Et,k.useAmountUi=en,k.useCancelOrder=qo,k.useDerivedHistoryOrder=ec,k.useExplorerLink=mi,k.useNetwork=yn,k.useSignOrder=Ts,k.useSpot=Ho,k.useSubmitOrder=vs,k.useSwapExecution=nn,Object.defineProperty(k,Symbol.toStringTag,{value:"Module"})}));
|