@orbs-network/spot-react 1.1.37 → 1.1.38
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 +1088 -1089
- package/dist/spot-react.umd.cjs +9 -9
- package/package.json +2 -2
package/dist/spot-react.umd.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
(function(I,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):(I=typeof globalThis<"u"?globalThis:I||self,H(I.SpotReact={},I.jsxRuntime,I.React))})(this,(function(I,H,F){"use strict";var pc=Object.defineProperty;var $s=I=>{throw TypeError(I)};var fc=(I,H,F)=>H in I?pc(I,H,{enumerable:!0,configurable:!0,writable:!0,value:F}):I[H]=F;var In=(I,H,F)=>fc(I,typeof H!="symbol"?H+"":H,F),br=(I,H,F)=>H.has(I)||$s("Cannot "+F);var l=(I,H,F)=>(br(I,H,"read from private field"),F?F.call(I):H.get(I)),N=(I,H,F)=>H.has(I)?$s("Cannot add the same private member more than once"):H instanceof WeakSet?H.add(I):H.set(I,F),M=(I,H,F,_t)=>(br(I,H,"write to private field"),_t?_t.call(I,F):H.set(I,F),F),Q=(I,H,F)=>(br(I,H,"access private method"),F);var Bn=(I,H,F,_t)=>({set _(ce){M(I,H,ce,F)},get _(){return l(I,H,_t)}});var He,St,_s,vt,ot,Kt,Us,Ht,ct,Wt,Rs,Ft,Ls,Dt,zt,ke,Pt,he,sn,Ot,Le,et,Ns,ve,Y,an,Ce,It,Qt,Ge,ut,on,$t,jt,Bt,Mt,dt,Vt,ee,ln,Cr,Tr,wr,xr,Sr,vr,Fr,js,qs,cn,We,Te,kt,ze,mt,Ks,Xe,Ne,un,Hs,Ze,lt,Fe,Ye,Je,Mn,Dr,Ws,Qe,zs,se,pt,ft,Gt,Xt,ht,Zt,Yt,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 ce=_t(F),$={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"}},Vs=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"}]'),Gs=[{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"}]}],Xs=Vs;var j=(e=>(e.TWAP="TWAP",e.LIMIT="LIMIT",e.STOP_LOSS="STOP_LOSS",e.TAKE_PROFIT="TAKE_PROFIT",e))(j||{}),ue=(e=>(e.Open="OPEN",e.Cancelled="CANCELLED",e.Completed="COMPLETED",e.Expired="EXPIRED",e))(ue||{}),Pr=(e=>(e.All="ALL",e.Open="OPEN",e.Cancelled="CANCELLED",e.Completed="COMPLETED",e.Expired="EXPIRED",e))(Pr||{}),De=(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))(De||{}),X=(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))(X||{}),Pe=(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.Utila="utila",e.Ring="ring",e.EfficientFrontier="ef",e.HtDigital="ht",e))(Pe||{}),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 ne="0x0000000000000000000000000000000000000000",ye={eth:{id:1,name:"Ethereum",shortname:"eth",native:{address:ne,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:ne,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},unichain:{id:130,name:"Unichain",shortname:"unichain",native:{address:ne,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/130/0x4200000000000000000000000000000000000006_0x042e6d078c6cf9e13a618396b0aa40181bcb43921ebdb5fabc8fb1124d516156.webp"},publicRpcUrl:"https://mainnet.unichain.org",logoUrl:"https://icons.llamao.fi/icons/chains/rsz_unichain",explorer:"https://uniscan.xyz",eip1559:!0},xlayer:{id:196,name:"X Layer",shortname:"xlayer",native:{address:ne,symbol:"OKB",decimals:18,logoUrl:"https://s2.coinmarketcap.com/static/img/coins/128x128/3897.png"},wToken:{symbol:"WOKB",address:"0xe538905cf8410324e03A5A23C1c177a474D59b2b",decimals:18,logoUrl:"https://s2.coinmarketcap.com/static/img/coins/128x128/3897.png"},publicRpcUrl:"https://rpc.xlayer.tech",logoUrl:"https://s2.coinmarketcap.com/static/img/coins/128x128/3897.png",explorer:"https://www.oklink.com/xlayer",eip1559:!0},hyperevm:{id:999,name:"HyperEVM",shortname:"hyperevm",native:{address:ne,symbol:"HYPE",decimals:18,logoUrl:"https://s2.coinmarketcap.com/static/img/coins/128x128/32196.png"},wToken:{symbol:"WHYPE",address:"0x5555555555555555555555555555555555555555",decimals:18,logoUrl:"https://s2.coinmarketcap.com/static/img/coins/128x128/32196.png"},publicRpcUrl:"https://rpc.hyperliquid.xyz/evm",logoUrl:"https://icons.llamao.fi/icons/chains/rsz_hyperliquid",explorer:"https://hyperevmscan.io",eip1559:!0},megaeth:{id:4326,name:"MegaETH",shortname:"megaeth",native:{address:ne,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://mainnet.megaeth.com/rpc",logoUrl:"https://icons.llamao.fi/icons/chains/rsz_megaeth",explorer:"https://mega.etherscan.io",eip1559:!0},poly:{id:137,name:"Polygon",shortname:"poly",native:{address:ne,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:ne,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:ne,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:ne,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:ne,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:ne,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:ne,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:ne,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:ne,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:ne,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:ne,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:ne,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:ne,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:ne,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:ne,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:ne,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:ne,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:ne,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:ne,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:ne,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}},kn={version:"2.6.5"},Or="https://order-sink-dev.orbs.network",pn="https://order-sink.orbs.network",Ir="https://order-sink-v2.orbs.network",fn=kn.version.split(".")[0],Zs=e=>{const t=Number(fn)>=2;return e?Or:t?Ir:pn},Ys=e=>{const t=Number(fn)>=2;return e?[Or]:t?[Ir,pn]:[pn]},Js={[Pe.Thena]:"0xB75218ba5A99bF57Fd02556B70F05A4A0f1Dbe67"},ea=({endpoint:e,exchange:t,partner:n})=>e===pn&&n&&Js[n]||t,_n=300*1e3,hn=1440*60*60*1e3,Br=300*1e3,ta=new Date(_n).getMinutes(),Un=e=>`https://hub.orbs.network/api/private/project_cm7nb67z86nyr01z12gs0fxpf/subgraphs/orbs-twap-${e}/prod/gn`,Ue="https://hub.orbs.network/api/apikey/subgraphs/id",na={[ye.eth.id]:`${Ue}/Bf7bvMYcJbDAvYWJmhMpHZ4cpFjqzkhK6GXXEpnPRq6`,[ye.bsc.id]:`${Ue}/4NfXEi8rreQsnAr4aJ45RLCKgnjcWX46Lbt9SadiCcz6`,[ye.poly.id]:`${Ue}/3PyRPWSvDnMowGbeBy7aNsvUkD5ZuxdXQw2RdJq4NdXi`,[ye.arb.id]:`${Ue}/83bpQexEaqBjHaQbKoFTbtvCXuo5RudRkfLgtRUYqo2c`,[ye.base.id]:`${Ue}/DFhaPQb3HATXkpsWNZw3gydYHehLBVEDiSk4iBdZJyps`,[ye.sei.id]:`${Ue}/5zjzRnURzoddyFSZBw5E5NAM3oBgPq3NasTYbtMk6EL6`,[ye.linea.id]:`${Ue}/6VsNPEYfFLPZCqdMMDadoXQjLHWJdjEwiD768GAtb7j6`,[ye.sonic.id]:`${Ue}/DtBr6a5vsoDd2oAXdPszcn4gLgrr1XC68Q3AJQKXnNLV`,[ye.ftm.id]:`${Ue}/DdRo1pmJkrJC9fjsjEBWnNE1uqrbh7Diz4tVKd7rfupp`,[ye.katana.id]:`${Ue}/CGi9sDFMQcnBwF3C3NoCFqnaE34sssbgwPLTwiskSXmW`,[ye.avax.id]:`${Ue}/FxZ1vMwE5Xy1qvKvZENUMz4vhW8Sh4vXJf9Vp7o17pTx`,[ye.bera.id]:Un("berachain"),[ye.flare.id]:Un("flare"),[ye.cronosZkEvm.id]:Un("cronos-zkevm")},ra=["0x0000000000000000000000000000000000000000","0x0000000000000000000000000000000000001010","0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE","0x000000000000000000000000000000000000dEaD","0x000000000000000000000000000000000000800A","0x000000000000000000000000000000000000800a"],Mr="115792089237316195423570985008687907853269984665640564039457584007913129639935",Ae=e=>`${e.name}_${e.chainId}`,sa={[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"]},Rn={unit:De.Minutes,value:ta},aa="RePermitWitnessTransferFrom",ia={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"}]},oa="https://www.orbs.com/dtwap-and-dlimit-faq/",ca="https://www.orbs.com/dtwap-and-dlimit-faq/#dSLTP",ua="https://raw.githubusercontent.com/orbs-network/twap-ui/master/logo/orbslogo.svg",da="https://www.orbs.com/",la="https://www.orbs.com/dtwap-dlimit-disclaimer";var Jt=(e=>(e.FRESHNESS="freshness",e.MIN_CHUNK_SIZE_USD="minChunkSizeUsd",e.ENV="env",e.DURATION="duration",e.IGNORE_ERRORS="ignore-errors",e))(Jt||{});const pa="-5",fa="10",ha="-10",ma="5";var ya=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,Ln=Math.ceil,Oe=Math.floor,xe="[BigNumber Error] ",kr=xe+"Number primitive has more than 15 significant digits: ",Re=1e14,W=14,Nn=9007199254740991,qn=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],tt=1e7,pe=1e9;function _r(e){var t,n,r,s=S.prototype={constructor:S,toString:null,valueOf:null},a=new S(1),o=20,u=4,p=-7,f=21,w=-1e7,y=1e7,b=!1,D=1,O=0,B={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},k="0123456789abcdefghijklmnopqrstuvwxyz",_=!0;function S(i,c){var d,E,m,g,x,h,A,T,C=this;if(!(C instanceof S))return new S(i,c);if(c==null){if(i&&i._isBigNumber===!0){C.s=i.s,!i.c||i.e>y?C.c=C.e=null:i.e<w?C.c=[C.e=0]:(C.e=i.e,C.c=i.c.slice());return}if((h=typeof i=="number")&&i*0==0){if(C.s=1/i<0?(i=-i,-1):1,i===~~i){for(g=0,x=i;x>=10;x/=10,g++);g>y?C.c=C.e=null:(C.e=g,C.c=[i]);return}T=String(i)}else{if(!ya.test(T=String(i)))return r(C,T,h);C.s=T.charCodeAt(0)==45?(T=T.slice(1),-1):1}(g=T.indexOf("."))>-1&&(T=T.replace(".","")),(x=T.search(/e/i))>0?(g<0&&(g=x),g+=+T.slice(x+1),T=T.substring(0,x)):g<0&&(g=T.length)}else{if(re(c,2,k.length,"Base"),c==10&&_)return C=new S(i),G(C,o+C.e+1,u);if(T=String(i),h=typeof i=="number"){if(i*0!=0)return r(C,T,h,c);if(C.s=1/i<0?(T=T.slice(1),-1):1,S.DEBUG&&T.replace(/^0\.0*|\./,"").length>15)throw Error(kr+i)}else C.s=T.charCodeAt(0)===45?(T=T.slice(1),-1):1;for(d=k.slice(0,c),g=x=0,A=T.length;x<A;x++)if(d.indexOf(E=T.charAt(x))<0){if(E=="."){if(x>g){g=A;continue}}else if(!m&&(T==T.toUpperCase()&&(T=T.toLowerCase())||T==T.toLowerCase()&&(T=T.toUpperCase()))){m=!0,x=-1,g=0;continue}return r(C,String(i),h,c)}h=!1,T=n(T,c,10,C.s),(g=T.indexOf("."))>-1?T=T.replace(".",""):g=T.length}for(x=0;T.charCodeAt(x)===48;x++);for(A=T.length;T.charCodeAt(--A)===48;);if(T=T.slice(x,++A)){if(A-=x,h&&S.DEBUG&&A>15&&(i>Nn||i!==Oe(i)))throw Error(kr+C.s*i);if((g=g-x-1)>y)C.c=C.e=null;else if(g<w)C.c=[C.e=0];else{if(C.e=g,C.c=[],x=(g+1)%W,g<0&&(x+=W),x<A){for(x&&C.c.push(+T.slice(0,x)),A-=W;x<A;)C.c.push(+T.slice(x,x+=W));x=W-(T=T.slice(x)).length}else x-=A;for(;x--;T+="0");C.c.push(+T)}}else C.c=[C.e=0]}S.clone=_r,S.ROUND_UP=0,S.ROUND_DOWN=1,S.ROUND_CEIL=2,S.ROUND_FLOOR=3,S.ROUND_HALF_UP=4,S.ROUND_HALF_DOWN=5,S.ROUND_HALF_EVEN=6,S.ROUND_HALF_CEIL=7,S.ROUND_HALF_FLOOR=8,S.EUCLID=9,S.config=S.set=function(i){var c,d;if(i!=null)if(typeof i=="object"){if(i.hasOwnProperty(c="DECIMAL_PLACES")&&(d=i[c],re(d,0,pe,c),o=d),i.hasOwnProperty(c="ROUNDING_MODE")&&(d=i[c],re(d,0,8,c),u=d),i.hasOwnProperty(c="EXPONENTIAL_AT")&&(d=i[c],d&&d.pop?(re(d[0],-pe,0,c),re(d[1],0,pe,c),p=d[0],f=d[1]):(re(d,-pe,pe,c),p=-(f=d<0?-d:d))),i.hasOwnProperty(c="RANGE"))if(d=i[c],d&&d.pop)re(d[0],-pe,-1,c),re(d[1],1,pe,c),w=d[0],y=d[1];else if(re(d,-pe,pe,c),d)w=-(y=d<0?-d:d);else throw Error(xe+c+" cannot be zero: "+d);if(i.hasOwnProperty(c="CRYPTO"))if(d=i[c],d===!!d)if(d)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))b=d;else throw b=!d,Error(xe+"crypto unavailable");else b=d;else throw Error(xe+c+" not true or false: "+d);if(i.hasOwnProperty(c="MODULO_MODE")&&(d=i[c],re(d,0,9,c),D=d),i.hasOwnProperty(c="POW_PRECISION")&&(d=i[c],re(d,0,pe,c),O=d),i.hasOwnProperty(c="FORMAT"))if(d=i[c],typeof d=="object")B=d;else throw Error(xe+c+" not an object: "+d);if(i.hasOwnProperty(c="ALPHABET"))if(d=i[c],typeof d=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(d))_=d.slice(0,10)=="0123456789",k=d;else throw Error(xe+c+" invalid: "+d)}else throw Error(xe+"Object expected: "+i);return{DECIMAL_PLACES:o,ROUNDING_MODE:u,EXPONENTIAL_AT:[p,f],RANGE:[w,y],CRYPTO:b,MODULO_MODE:D,POW_PRECISION:O,FORMAT:B,ALPHABET:k}},S.isBigNumber=function(i){if(!i||i._isBigNumber!==!0)return!1;if(!S.DEBUG)return!0;var c,d,E=i.c,m=i.e,g=i.s;e:if({}.toString.call(E)=="[object Array]"){if((g===1||g===-1)&&m>=-pe&&m<=pe&&m===Oe(m)){if(E[0]===0){if(m===0&&E.length===1)return!0;break e}if(c=(m+1)%W,c<1&&(c+=W),String(E[0]).length==c){for(c=0;c<E.length;c++)if(d=E[c],d<0||d>=Re||d!==Oe(d))break e;if(d!==0)return!0}}}else if(E===null&&m===null&&(g===null||g===1||g===-1))return!0;throw Error(xe+"Invalid BigNumber: "+i)},S.maximum=S.max=function(){return U(arguments,-1)},S.minimum=S.min=function(){return U(arguments,1)},S.random=(function(){var i=9007199254740992,c=Math.random()*i&2097151?function(){return Oe(Math.random()*i)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(d){var E,m,g,x,h,A=0,T=[],C=new S(a);if(d==null?d=o:re(d,0,pe),x=Ln(d/W),b)if(crypto.getRandomValues){for(E=crypto.getRandomValues(new Uint32Array(x*=2));A<x;)h=E[A]*131072+(E[A+1]>>>11),h>=9e15?(m=crypto.getRandomValues(new Uint32Array(2)),E[A]=m[0],E[A+1]=m[1]):(T.push(h%1e14),A+=2);A=x/2}else if(crypto.randomBytes){for(E=crypto.randomBytes(x*=7);A<x;)h=(E[A]&31)*281474976710656+E[A+1]*1099511627776+E[A+2]*4294967296+E[A+3]*16777216+(E[A+4]<<16)+(E[A+5]<<8)+E[A+6],h>=9e15?crypto.randomBytes(7).copy(E,A):(T.push(h%1e14),A+=7);A=x/7}else throw b=!1,Error(xe+"crypto unavailable");if(!b)for(;A<x;)h=c(),h<9e15&&(T[A++]=h%1e14);for(x=T[--A],d%=W,x&&d&&(h=qn[W-d],T[A]=Oe(x/h)*h);T[A]===0;T.pop(),A--);if(A<0)T=[g=0];else{for(g=-1;T[0]===0;T.splice(0,1),g-=W);for(A=1,h=T[0];h>=10;h/=10,A++);A<W&&(g-=W-A)}return C.e=g,C.c=T,C}})(),S.sum=function(){for(var i=1,c=arguments,d=new S(c[0]);i<c.length;)d=d.plus(c[i++]);return d},n=(function(){var i="0123456789";function c(d,E,m,g){for(var x,h=[0],A,T=0,C=d.length;T<C;){for(A=h.length;A--;h[A]*=E);for(h[0]+=g.indexOf(d.charAt(T++)),x=0;x<h.length;x++)h[x]>m-1&&(h[x+1]==null&&(h[x+1]=0),h[x+1]+=h[x]/m|0,h[x]%=m)}return h.reverse()}return function(d,E,m,g,x){var h,A,T,C,P,R,L,Z,ae=d.indexOf("."),le=o,J=u;for(ae>=0&&(C=O,O=0,d=d.replace(".",""),Z=new S(E),R=Z.pow(d.length-ae),O=C,Z.c=c(je(Be(R.c),R.e,"0"),10,m,i),Z.e=Z.c.length),L=c(d,E,m,x?(h=k,i):(h=i,k)),T=C=L.length;L[--C]==0;L.pop());if(!L[0])return h.charAt(0);if(ae<0?--T:(R.c=L,R.e=T,R.s=g,R=t(R,Z,le,J,m),L=R.c,P=R.r,T=R.e),A=T+le+1,ae=L[A],C=m/2,P=P||A<0||L[A+1]!=null,P=J<4?(ae!=null||P)&&(J==0||J==(R.s<0?3:2)):ae>C||ae==C&&(J==4||P||J==6&&L[A-1]&1||J==(R.s<0?8:7)),A<1||!L[0])d=P?je(h.charAt(1),-le,h.charAt(0)):h.charAt(0);else{if(L.length=A,P)for(--m;++L[--A]>m;)L[A]=0,A||(++T,L=[1].concat(L));for(C=L.length;!L[--C];);for(ae=0,d="";ae<=C;d+=h.charAt(L[ae++]));d=je(d,T,h.charAt(0))}return d}})(),t=(function(){function i(E,m,g){var x,h,A,T,C=0,P=E.length,R=m%tt,L=m/tt|0;for(E=E.slice();P--;)A=E[P]%tt,T=E[P]/tt|0,x=L*A+T*R,h=R*A+x%tt*tt+C,C=(h/g|0)+(x/tt|0)+L*T,E[P]=h%g;return C&&(E=[C].concat(E)),E}function c(E,m,g,x){var h,A;if(g!=x)A=g>x?1:-1;else for(h=A=0;h<g;h++)if(E[h]!=m[h]){A=E[h]>m[h]?1:-1;break}return A}function d(E,m,g,x){for(var h=0;g--;)E[g]-=h,h=E[g]<m[g]?1:0,E[g]=h*x+E[g]-m[g];for(;!E[0]&&E.length>1;E.splice(0,1));}return function(E,m,g,x,h){var A,T,C,P,R,L,Z,ae,le,J,te,ge,On,Ar,Er,$e,dn,_e=E.s==m.s?1:-1,we=E.c,ie=m.c;if(!we||!we[0]||!ie||!ie[0])return new S(!E.s||!m.s||(we?ie&&we[0]==ie[0]:!ie)?NaN:we&&we[0]==0||!ie?_e*0:_e/0);for(ae=new S(_e),le=ae.c=[],T=E.e-m.e,_e=g+T+1,h||(h=Re,T=Ie(E.e/W)-Ie(m.e/W),_e=_e/W|0),C=0;ie[C]==(we[C]||0);C++);if(ie[C]>(we[C]||0)&&T--,_e<0)le.push(1),P=!0;else{for(Ar=we.length,$e=ie.length,C=0,_e+=2,R=Oe(h/(ie[0]+1)),R>1&&(ie=i(ie,R,h),we=i(we,R,h),$e=ie.length,Ar=we.length),On=$e,J=we.slice(0,$e),te=J.length;te<$e;J[te++]=0);dn=ie.slice(),dn=[0].concat(dn),Er=ie[0],ie[1]>=h/2&&Er++;do{if(R=0,A=c(ie,J,$e,te),A<0){if(ge=J[0],$e!=te&&(ge=ge*h+(J[1]||0)),R=Oe(ge/Er),R>1)for(R>=h&&(R=h-1),L=i(ie,R,h),Z=L.length,te=J.length;c(L,J,Z,te)==1;)R--,d(L,$e<Z?dn:ie,Z,h),Z=L.length,A=1;else R==0&&(A=R=1),L=ie.slice(),Z=L.length;if(Z<te&&(L=[0].concat(L)),d(J,L,te,h),te=J.length,A==-1)for(;c(ie,J,$e,te)<1;)R++,d(J,$e<te?dn:ie,te,h),te=J.length}else A===0&&(R++,J=[0]);le[C++]=R,J[0]?J[te++]=we[On]||0:(J=[we[On]],te=1)}while((On++<Ar||J[0]!=null)&&_e--);P=J[0]!=null,le[0]||le.splice(0,1)}if(h==Re){for(C=1,_e=le[0];_e>=10;_e/=10,C++);G(ae,g+(ae.e=C+T*W-1)+1,x,P)}else ae.e=T,ae.r=+P;return ae}})();function K(i,c,d,E){var m,g,x,h,A;if(d==null?d=u:re(d,0,8),!i.c)return i.toString();if(m=i.c[0],x=i.e,c==null)A=Be(i.c),A=E==1||E==2&&(x<=p||x>=f)?yn(A,x):je(A,x,"0");else if(i=G(new S(i),c,d),g=i.e,A=Be(i.c),h=A.length,E==1||E==2&&(c<=g||g<=p)){for(;h<c;A+="0",h++);A=yn(A,g)}else if(c-=x+(E===2&&g>x),A=je(A,g,"0"),g+1>h){if(--c>0)for(A+=".";c--;A+="0");}else if(c+=g-h,c>0)for(g+1==h&&(A+=".");c--;A+="0");return i.s<0&&m?"-"+A:A}function U(i,c){for(var d,E,m=1,g=new S(i[0]);m<i.length;m++)E=new S(i[m]),(!E.s||(d=yt(g,E))===c||d===0&&g.s===c)&&(g=E);return g}function V(i,c,d){for(var E=1,m=c.length;!c[--m];c.pop());for(m=c[0];m>=10;m/=10,E++);return(d=E+d*W-1)>y?i.c=i.e=null:d<w?i.c=[i.e=0]:(i.e=d,i.c=c),i}r=(function(){var i=/^(-?)0([xbo])(?=\w[\w.]*$)/i,c=/^([^.]+)\.$/,d=/^\.([^.]+)$/,E=/^-?(Infinity|NaN)$/,m=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(g,x,h,A){var T,C=h?x:x.replace(m,"");if(E.test(C))g.s=isNaN(C)?null:C<0?-1:1;else{if(!h&&(C=C.replace(i,function(P,R,L){return T=(L=L.toLowerCase())=="x"?16:L=="b"?2:8,!A||A==T?R:P}),A&&(T=A,C=C.replace(c,"$1").replace(d,"0.$1")),x!=C))return new S(C,T);if(S.DEBUG)throw Error(xe+"Not a"+(A?" base "+A:"")+" number: "+x);g.s=null}g.c=g.e=null}})();function G(i,c,d,E){var m,g,x,h,A,T,C,P=i.c,R=qn;if(P){e:{for(m=1,h=P[0];h>=10;h/=10,m++);if(g=c-m,g<0)g+=W,x=c,A=P[T=0],C=Oe(A/R[m-x-1]%10);else if(T=Ln((g+1)/W),T>=P.length)if(E){for(;P.length<=T;P.push(0));A=C=0,m=1,g%=W,x=g-W+1}else break e;else{for(A=h=P[T],m=1;h>=10;h/=10,m++);g%=W,x=g-W+m,C=x<0?0:Oe(A/R[m-x-1]%10)}if(E=E||c<0||P[T+1]!=null||(x<0?A:A%R[m-x-1]),E=d<4?(C||E)&&(d==0||d==(i.s<0?3:2)):C>5||C==5&&(d==4||E||d==6&&(g>0?x>0?A/R[m-x]:0:P[T-1])%10&1||d==(i.s<0?8:7)),c<1||!P[0])return P.length=0,E?(c-=i.e+1,P[0]=R[(W-c%W)%W],i.e=-c||0):P[0]=i.e=0,i;if(g==0?(P.length=T,h=1,T--):(P.length=T+1,h=R[W-g],P[T]=x>0?Oe(A/R[m-x]%R[x])*h:0),E)for(;;)if(T==0){for(g=1,x=P[0];x>=10;x/=10,g++);for(x=P[0]+=h,h=1;x>=10;x/=10,h++);g!=h&&(i.e++,P[0]==Re&&(P[0]=1));break}else{if(P[T]+=h,P[T]!=Re)break;P[T--]=0,h=1}for(g=P.length;P[--g]===0;P.pop());}i.e>y?i.c=i.e=null:i.e<w&&(i.c=[i.e=0])}return i}function oe(i){var c,d=i.e;return d===null?i.toString():(c=Be(i.c),c=d<=p||d>=f?yn(c,d):je(c,d,"0"),i.s<0?"-"+c:c)}return s.absoluteValue=s.abs=function(){var i=new S(this);return i.s<0&&(i.s=1),i},s.comparedTo=function(i,c){return yt(this,new S(i,c))},s.decimalPlaces=s.dp=function(i,c){var d,E,m,g=this;if(i!=null)return re(i,0,pe),c==null?c=u:re(c,0,8),G(new S(g),i+g.e+1,c);if(!(d=g.c))return null;if(E=((m=d.length-1)-Ie(this.e/W))*W,m=d[m])for(;m%10==0;m/=10,E--);return E<0&&(E=0),E},s.dividedBy=s.div=function(i,c){return t(this,new S(i,c),o,u)},s.dividedToIntegerBy=s.idiv=function(i,c){return t(this,new S(i,c),0,1)},s.exponentiatedBy=s.pow=function(i,c){var d,E,m,g,x,h,A,T,C,P=this;if(i=new S(i),i.c&&!i.isInteger())throw Error(xe+"Exponent not an integer: "+oe(i));if(c!=null&&(c=new S(c)),h=i.e>14,!P.c||!P.c[0]||P.c[0]==1&&!P.e&&P.c.length==1||!i.c||!i.c[0])return C=new S(Math.pow(+oe(P),h?i.s*(2-mn(i)):+oe(i))),c?C.mod(c):C;if(A=i.s<0,c){if(c.c?!c.c[0]:!c.s)return new S(NaN);E=!A&&P.isInteger()&&c.isInteger(),E&&(P=P.mod(c))}else{if(i.e>9&&(P.e>0||P.e<-1||(P.e==0?P.c[0]>1||h&&P.c[1]>=24e7:P.c[0]<8e13||h&&P.c[0]<=9999975e7)))return g=P.s<0&&mn(i)?-0:0,P.e>-1&&(g=1/g),new S(A?1/g:g);O&&(g=Ln(O/W+2))}for(h?(d=new S(.5),A&&(i.s=1),T=mn(i)):(m=Math.abs(+oe(i)),T=m%2),C=new S(a);;){if(T){if(C=C.times(P),!C.c)break;g?C.c.length>g&&(C.c.length=g):E&&(C=C.mod(c))}if(m){if(m=Oe(m/2),m===0)break;T=m%2}else if(i=i.times(d),G(i,i.e+1,1),i.e>14)T=mn(i);else{if(m=+oe(i),m===0)break;T=m%2}P=P.times(P),g?P.c&&P.c.length>g&&(P.c.length=g):E&&(P=P.mod(c))}return E?C:(A&&(C=a.div(C)),c?C.mod(c):g?G(C,O,u,x):C)},s.integerValue=function(i){var c=new S(this);return i==null?i=u:re(i,0,8),G(c,c.e+1,i)},s.isEqualTo=s.eq=function(i,c){return yt(this,new S(i,c))===0},s.isFinite=function(){return!!this.c},s.isGreaterThan=s.gt=function(i,c){return yt(this,new S(i,c))>0},s.isGreaterThanOrEqualTo=s.gte=function(i,c){return(c=yt(this,new S(i,c)))===1||c===0},s.isInteger=function(){return!!this.c&&Ie(this.e/W)>this.c.length-2},s.isLessThan=s.lt=function(i,c){return yt(this,new S(i,c))<0},s.isLessThanOrEqualTo=s.lte=function(i,c){return(c=yt(this,new S(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 d,E,m,g,x=this,h=x.s;if(i=new S(i,c),c=i.s,!h||!c)return new S(NaN);if(h!=c)return i.s=-c,x.plus(i);var A=x.e/W,T=i.e/W,C=x.c,P=i.c;if(!A||!T){if(!C||!P)return C?(i.s=-c,i):new S(P?x:NaN);if(!C[0]||!P[0])return P[0]?(i.s=-c,i):new S(C[0]?x:u==3?-0:0)}if(A=Ie(A),T=Ie(T),C=C.slice(),h=A-T){for((g=h<0)?(h=-h,m=C):(T=A,m=P),m.reverse(),c=h;c--;m.push(0));m.reverse()}else for(E=(g=(h=C.length)<(c=P.length))?h:c,h=c=0;c<E;c++)if(C[c]!=P[c]){g=C[c]<P[c];break}if(g&&(m=C,C=P,P=m,i.s=-i.s),c=(E=P.length)-(d=C.length),c>0)for(;c--;C[d++]=0);for(c=Re-1;E>h;){if(C[--E]<P[E]){for(d=E;d&&!C[--d];C[d]=c);--C[d],C[E]+=Re}C[E]-=P[E]}for(;C[0]==0;C.splice(0,1),--T);return C[0]?V(i,C,T):(i.s=u==3?-1:1,i.c=[i.e=0],i)},s.modulo=s.mod=function(i,c){var d,E,m=this;return i=new S(i,c),!m.c||!i.s||i.c&&!i.c[0]?new S(NaN):!i.c||m.c&&!m.c[0]?new S(m):(D==9?(E=i.s,i.s=1,d=t(m,i,0,3),i.s=E,d.s*=E):d=t(m,i,0,D),i=m.minus(d.times(i)),!i.c[0]&&D==1&&(i.s=m.s),i)},s.multipliedBy=s.times=function(i,c){var d,E,m,g,x,h,A,T,C,P,R,L,Z,ae,le,J=this,te=J.c,ge=(i=new S(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(E=Ie(J.e/W)+Ie(i.e/W),i.s*=J.s,A=te.length,P=ge.length,A<P&&(Z=te,te=ge,ge=Z,m=A,A=P,P=m),m=A+P,Z=[];m--;Z.push(0));for(ae=Re,le=tt,m=P;--m>=0;){for(d=0,R=ge[m]%le,L=ge[m]/le|0,x=A,g=m+x;g>m;)T=te[--x]%le,C=te[x]/le|0,h=L*T+C*R,T=R*T+h%le*le+Z[g]+d,d=(T/ae|0)+(h/le|0)+L*C,Z[g--]=T%ae;Z[g]=d}return d?++E:Z.splice(0,1),V(i,Z,E)},s.negated=function(){var i=new S(this);return i.s=-i.s||null,i},s.plus=function(i,c){var d,E=this,m=E.s;if(i=new S(i,c),c=i.s,!m||!c)return new S(NaN);if(m!=c)return i.s=-c,E.minus(i);var g=E.e/W,x=i.e/W,h=E.c,A=i.c;if(!g||!x){if(!h||!A)return new S(m/0);if(!h[0]||!A[0])return A[0]?i:new S(h[0]?E:m*0)}if(g=Ie(g),x=Ie(x),h=h.slice(),m=g-x){for(m>0?(x=g,d=A):(m=-m,d=h),d.reverse();m--;d.push(0));d.reverse()}for(m=h.length,c=A.length,m-c<0&&(d=A,A=h,h=d,c=m),m=0;c;)m=(h[--c]=h[c]+A[c]+m)/Re|0,h[c]=Re===h[c]?0:h[c]%Re;return m&&(h=[m].concat(h),++x),V(i,h,x)},s.precision=s.sd=function(i,c){var d,E,m,g=this;if(i!=null&&i!==!!i)return re(i,1,pe),c==null?c=u:re(c,0,8),G(new S(g),i,c);if(!(d=g.c))return null;if(m=d.length-1,E=m*W+1,m=d[m]){for(;m%10==0;m/=10,E--);for(m=d[0];m>=10;m/=10,E++);}return i&&g.e+1>E&&(E=g.e+1),E},s.shiftedBy=function(i){return re(i,-Nn,Nn),this.times("1e"+i)},s.squareRoot=s.sqrt=function(){var i,c,d,E,m,g=this,x=g.c,h=g.s,A=g.e,T=o+4,C=new S("0.5");if(h!==1||!x||!x[0])return new S(!h||h<0&&(!x||x[0])?NaN:x?g:1/0);if(h=Math.sqrt(+oe(g)),h==0||h==1/0?(c=Be(x),(c.length+A)%2==0&&(c+="0"),h=Math.sqrt(+c),A=Ie((A+1)/2)-(A<0||A%2),h==1/0?c="5e"+A:(c=h.toExponential(),c=c.slice(0,c.indexOf("e")+1)+A),d=new S(c)):d=new S(h+""),d.c[0]){for(A=d.e,h=A+T,h<3&&(h=0);;)if(m=d,d=C.times(m.plus(t(g,m,T,1))),Be(m.c).slice(0,h)===(c=Be(d.c)).slice(0,h))if(d.e<A&&--h,c=c.slice(h-3,h+1),c=="9999"||!E&&c=="4999"){if(!E&&(G(m,m.e+o+2,0),m.times(m).eq(g))){d=m;break}T+=4,h+=4,E=1}else{(!+c||!+c.slice(1)&&c.charAt(0)=="5")&&(G(d,d.e+o+2,1),i=!d.times(d).eq(g));break}}return G(d,d.e+o+1,u,i)},s.toExponential=function(i,c){return i!=null&&(re(i,0,pe),i++),K(this,i,c,1)},s.toFixed=function(i,c){return i!=null&&(re(i,0,pe),i=i+this.e+1),K(this,i,c)},s.toFormat=function(i,c,d){var E,m=this;if(d==null)i!=null&&c&&typeof c=="object"?(d=c,c=null):i&&typeof i=="object"?(d=i,i=c=null):d=B;else if(typeof d!="object")throw Error(xe+"Argument not an object: "+d);if(E=m.toFixed(i,c),m.c){var g,x=E.split("."),h=+d.groupSize,A=+d.secondaryGroupSize,T=d.groupSeparator||"",C=x[0],P=x[1],R=m.s<0,L=R?C.slice(1):C,Z=L.length;if(A&&(g=h,h=A,A=g,Z-=g),h>0&&Z>0){for(g=Z%h||h,C=L.substr(0,g);g<Z;g+=h)C+=T+L.substr(g,h);A>0&&(C+=T+L.slice(g)),R&&(C="-"+C)}E=P?C+(d.decimalSeparator||"")+((A=+d.fractionGroupSize)?P.replace(new RegExp("\\d{"+A+"}\\B","g"),"$&"+(d.fractionGroupSeparator||"")):P):C}return(d.prefix||"")+E+(d.suffix||"")},s.toFraction=function(i){var c,d,E,m,g,x,h,A,T,C,P,R,L=this,Z=L.c;if(i!=null&&(h=new S(i),!h.isInteger()&&(h.c||h.s!==1)||h.lt(a)))throw Error(xe+"Argument "+(h.isInteger()?"out of range: ":"not an integer: ")+oe(h));if(!Z)return new S(L);for(c=new S(a),T=d=new S(a),E=A=new S(a),R=Be(Z),g=c.e=R.length-L.e-1,c.c[0]=qn[(x=g%W)<0?W+x:x],i=!i||h.comparedTo(c)>0?g>0?c:T:h,x=y,y=1/0,h=new S(R),A.c[0]=0;C=t(h,c,0,1),m=d.plus(C.times(E)),m.comparedTo(i)!=1;)d=E,E=m,T=A.plus(C.times(m=T)),A=m,c=h.minus(C.times(m=c)),h=m;return m=t(i.minus(d),E,0,1),A=A.plus(m.times(T)),d=d.plus(m.times(E)),A.s=T.s=L.s,g=g*2,P=t(T,E,g,u).minus(L).abs().comparedTo(t(A,d,g,u).minus(L).abs())<1?[T,E]:[A,d],y=x,P},s.toNumber=function(){return+oe(this)},s.toPrecision=function(i,c){return i!=null&&re(i,1,pe),K(this,i,c,2)},s.toString=function(i){var c,d=this,E=d.s,m=d.e;return m===null?E?(c="Infinity",E<0&&(c="-"+c)):c="NaN":(i==null?c=m<=p||m>=f?yn(Be(d.c),m):je(Be(d.c),m,"0"):i===10&&_?(d=G(new S(d),o+m+1,u),c=je(Be(d.c),d.e,"0")):(re(i,2,k.length,"Base"),c=n(je(Be(d.c),m,"0"),10,i,E,!0)),E<0&&d.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&&S.set(e),S}function Ie(e){var t=e|0;return e>0||e===t?t:t-1}function Be(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 yt(e,t){var n,r,s=e.c,a=t.c,o=e.s,u=t.s,p=e.e,f=t.e;if(!o||!u)return null;if(n=s&&!s[0],r=a&&!a[0],n||r)return n?r?0:-u:o;if(o!=u)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(u=(p=s.length)<(f=a.length)?p:f,o=0;o<u;o++)if(s[o]!=a[o])return s[o]>a[o]^n?1:-1;return p==f?0:p>f^n?1:-1}function re(e,t,n,r){if(e<t||e>n||e!==Oe(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 mn(e){var t=e.c.length-1;return Ie(e.e/W)==t&&e.c[t]%2!=0}function yn(e,t){return(e.length>1?e.charAt(0)+"."+e.slice(1):e)+(t<0?"e":"e+")+t}function je(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 v=_r();function ga(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 Aa={1:{adapter:{Odos:"0x1ae80D14C52F82c09a54C423e6f9D5Fb737089C8",Sushi:"0x11985E88847aEC23D1C3BCD77Ca0F4A704aB751c",Ring:"0x47e27973dA3e16dB13F8b713877b3A31623E0E5B"},dex:{sushiswap:{type:"default",solver:"Sushi",router:"0xAC4c6e212A361c968F1725b4d055b47E63F80b75",adapter:"0x2e43A28FAf083717CcD9B246d97C61E1Bc9914Df",fee:"0x28F6C9dBE21fFc146Af8d5D15c49Cf48F61140Dc"},ring:{type:"dynamicp2",solver:"Ring",permit2:"0x000000000022D473030F116dDEE9F6B43aC78BA3",adapter:"0x028fa69049aB68EC42064Eb18896D587dD41Af2a",fee:"0xA04329696aAd1417c75Cf6d91342815001999B21"}}},10:{adapter:{Odos:"0xc7Ec90152fd5A6210570cb04C4Ab099Bdac352af",Sushi:"0x11985E88847aEC23D1C3BCD77Ca0F4A704aB751c"},dex:{sushiswap:{type:"default",solver:"Sushi",router:"0xAC4c6e212A361c968F1725b4d055b47E63F80b75",adapter:"0x2e43A28FAf083717CcD9B246d97C61E1Bc9914Df",fee:"0x28F6C9dBE21fFc146Af8d5D15c49Cf48F61140Dc"}}},14:{adapter:{SparkDex:"0x00c7617C471Ef69124464CEc318a3b8CC90aE9A7"},dex:{spark:{type:"default",solver:"SparkDex",router:"0x0f3D8a38D4c74afBebc2c42695642f0e3acb15D3",adapter:"0x00c7617C471Ef69124464CEc318a3b8CC90aE9A7",fee:"0xaeA8C3e1a129A77686E115b1a46D9aD8405F7D2b"}}},56:{adapter:{Odos:"0x6c17cc2984A87BD8b002c6E3C08dBB8c8Eb89E48",Orbs:"0xaf3532dca7b4a75cD06671614C093e9e8fb5b1F2",Ring:"0x47e27973dA3e16dB13F8b713877b3A31623E0E5B",Topaz:"0x2Be5260d030ff9A6040bA4292326B796ff1a055d"},dex:{thena:{type:"default",solver:"Odos",router:"0x89b8AA89FDd0507a99d334CBe3C808fAFC7d850E",adapter:"0x9E61dEabe996236814c28eC69ab2A7405cB6f03E",fee:"0x15eBc8b5b3877512FFF23650188694A9a8891FAc"},pancake:{type:"p2",solver:"Orbs",router:"0xd9C500DfF816a1Da21A48A732d3498Bf09dc9AEB",permit2:"0x31c2F6fcFf4F8759b3Bd5Bf0e1084A055615c768",adapter:"0x52Ed96B1AEd25818B6A284b063b055488E012b73",fee:"0x37A957f10F458e0d7fDECBE2917971b57F15c927"},newera:{type:"default",solver:"Odos",router:"0x89b8AA89FDd0507a99d334CBe3C808fAFC7d850E",adapter:"0x6236a466CE5c368DC6686d69cAcf5561196B76ef",fee:"0x4E7454909eB6D539111D56b50d68897E933D2d11"},ring:{type:"dynamicp2",solver:"Ring",permit2:"0x000000000022D473030F116dDEE9F6B43aC78BA3",adapter:"0x028fa69049aB68EC42064Eb18896D587dD41Af2a",fee:"0xA04329696aAd1417c75Cf6d91342815001999B21"},topaz:{type:"default",solver:"Topaz",router:"0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",adapter:"0x671c59dCbc8ee3a08D15e1D03a88032740869919",fee:"0xDbB17E23d12cd3C0AA856528F7177a68f98fFd5B"}}},130:{adapter:{Ring:"0x47e27973dA3e16dB13F8b713877b3A31623E0E5B"},dex:{ring:{type:"dynamicp2",solver:"Ring",permit2:"0x000000000022D473030F116dDEE9F6B43aC78BA3",adapter:"0x028fa69049aB68EC42064Eb18896D587dD41Af2a",fee:"0xA04329696aAd1417c75Cf6d91342815001999B21"}}},137:{adapter:{Odos:"0x5628D7383b42E14E83DA310de3e7E04E6b025418",Paraswap:"0x179C4b8e982b5F1365d36CC8d0c1CEB621B7198D"},dex:{quick:{type:"paraswap",solver:"Paraswap",router:"0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57",adapter:"0x727e1CbA41Ff1ff11C32fa43DAb499b4317A1b65",fee:"0xd207DC6a6dA88f27c8DB78201F974161b1d84b1f"},teafi:{type:"paraswap",solver:"Paraswap",router:"0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57",adapter:"0xF710D67C783D2C14671EC1c61B0683DCb996F5c3",fee:"0x04Ff96e2c4D62b5771795d307AD679a25b3D2D50"}}},143:{adapter:{OpenOcean:"0xc7f07C830e22FCA94bF52F38C6707F9D396c6172",Kyber:"0x6f4e5b8d7F6b037c62277992c39E7834D7C04596"},dex:{yowie:{type:"default",solver:"OpenOcean",router:"0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",adapter:"0xCA84Ab5a5A5bf2cff6AC0C835eF049365D13c6cB",fee:"0x6AF3eE77A3A3257777F5649aFa611b4C7Fd975Ef"},pangolin:{type:"default",solver:"Kyber",router:"0x6131B5fae19EA4f9D964eAc0408E4408b66337b5",adapter:"0xf42106eBf985bF49b39eba0114F57FA05e7B52eD",fee:"0xde92da99D188Ceb54A11ec711EF52D808A6260B5"}}},146:{adapter:{Odos:"0x0123695379045f9db515E6a77d8154959B94B599",OpenOcean:"0xc7f07C830e22FCA94bF52F38C6707F9D396c6172",Magpie:"0x4914efb617fEa2Fd7529fdb365854Fd8f17bCBDE"},dex:{spooky:{type:"default",solver:"Magpie",router:"0x20f6ee51340adeed01a59b0e65cb3703f3dc860c",adapter:"0x0F6533Fd45D13ad6AAa364023d6c05eCB2d3Ac2E",fee:"0x840Df4684B35BC68BcdA3F6707A3c82A0D662f8b"},swapx:{type:"default",solver:"OpenOcean",router:"0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",adapter:"0xa7AE3ABf86C81cCEFEd6bE77045F2a32660c1B1c",fee:"0x6E03f7BC0f141894612AA017796096399623895F"},shadow:{type:"default",solver:"Magpie",router:"0x20f6ee51340adeed01a59b0e65cb3703f3dc860c",adapter:"0x39b024E187e5f35fea05953fECB9314a97de3d94",fee:"0xb9e3751fAF3187E1bC468E56a707a8A91754460e"}}},196:{adapter:{Ring:"0x47e27973dA3e16dB13F8b713877b3A31623E0E5B"},dex:{ring:{type:"dynamicp2",solver:"Ring",permit2:"0x000000000022D473030F116dDEE9F6B43aC78BA3",adapter:"0x028fa69049aB68EC42064Eb18896D587dD41Af2a",fee:"0xA04329696aAd1417c75Cf6d91342815001999B21"}}},999:{reactor:"0x826dD029Becf04868aae378aE4C0cf1b9DEa354B",executor:"0x71dd93213714132868123798Cbe103d2f65c81A1",adapter:{Ring:"0x47e27973dA3e16dB13F8b713877b3A31623E0E5B"},dex:{ring:{type:"dynamicp2",solver:"Ring",permit2:"0x000000000022D473030F116dDEE9F6B43aC78BA3",adapter:"0x028fa69049aB68EC42064Eb18896D587dD41Af2a",fee:"0xA04329696aAd1417c75Cf6d91342815001999B21"}}},1329:{adapter:{DragonSwap:"0x1e84A9f30607959d2d8b1a04171ef7D9522Ef502",OpenOcean:"0xc7f07C830e22FCA94bF52F38C6707F9D396c6172"},dex:{dragon:{type:"default",solver:"DragonSwap",router:"0x11DA6463D6Cb5a03411Dbf5ab6f6bc3997Ac7428",adapter:"0x1e84A9f30607959d2d8b1a04171ef7D9522Ef502",fee:"0x0dc1E0525202b32e89bA78ed55b1e5cEdB751334"},nami:{type:"default",solver:"OpenOcean",router:"0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",adapter:"0xba56F9A7865d430c8293851D576b5728Ca711ff5",fee:"0xeB58450e23632003f013568703F54446070E2E80"}}},4326:{adapter:{Ring:"0x47e27973dA3e16dB13F8b713877b3A31623E0E5B"},dex:{ring:{type:"dynamicp2",solver:"Ring",permit2:"0x000000000022D473030F116dDEE9F6B43aC78BA3",adapter:"0x028fa69049aB68EC42064Eb18896D587dD41Af2a",fee:"0xA04329696aAd1417c75Cf6d91342815001999B21"}}},5e3:{adapter:{Odos:"0x3a0fA0f95ea07026c5f84D8d3444Dd6E15AE1874",Sushi:"0x11985E88847aEC23D1C3BCD77Ca0F4A704aB751c"},dex:{sushiswap:{type:"default",solver:"Sushi",router:"0xAC4c6e212A361c968F1725b4d055b47E63F80b75",adapter:"0x2e43A28FAf083717CcD9B246d97C61E1Bc9914Df",fee:"0x28F6C9dBE21fFc146Af8d5D15c49Cf48F61140Dc"}}},8453:{adapter:{Odos:"0x1c947387AFC3435135e3da51ccEAB20eD5377DeA",Orbs:"0x917b492557957f5dD3e69c04c8E1Ac3d6948c022",Kyber:"0x6f4e5b8d7F6b037c62277992c39E7834D7C04596",TrebleSwap:"0x6f4938535879c668A797F2a6e9B912c54f9D43Cf",Sushi:"0x11985E88847aEC23D1C3BCD77Ca0F4A704aB751c",Ring:"0x47e27973dA3e16dB13F8b713877b3A31623E0E5B"},dex:{pancake:{type:"p2",solver:"Orbs",router:"0xFE6508f0015C778Bdcc1fB5465bA5ebE224C9912",permit2:"0x31c2F6fcFf4F8759b3Bd5Bf0e1084A055615c768",adapter:"0xA7CcB11F1D20D1F915FC220F5Cb1646E4523bB75",fee:"0x37A957f10F458e0d7fDECBE2917971b57F15c927"},quick:{type:"default",solver:"Kyber",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"},ring:{type:"dynamicp2",solver:"Ring",permit2:"0x000000000022D473030F116dDEE9F6B43aC78BA3",adapter:"0x028fa69049aB68EC42064Eb18896D587dD41Af2a",fee:"0xA04329696aAd1417c75Cf6d91342815001999B21"}}},42161:{adapter:{Odos:"0x419faf03F5661e0F0471eF9D7935f09534ffc50F",Paraswap:"0x179C4b8e982b5F1365d36CC8d0c1CEB621B7198D",Orbs:"0x917b492557957f5dD3e69c04c8E1Ac3d6948c022",Sushi:"0x11985E88847aEC23D1C3BCD77Ca0F4A704aB751c",Ring:"0x47e27973dA3e16dB13F8b713877b3A31623E0E5B"},dex:{arbidex:{type:"default",solver:"Odos",router:"0xa669e7A0d4b3e4Fa48af2dE86BD4CD7126Be4e13",adapter:"0xaA66173674F4331e7e672899B3E6aB1190450898",fee:"0xa0c11852f8A44e32F9EC10AD25986A53842f72Ca"},ramses:{type:"paraswap",solver:"Paraswap",router:"0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57",adapter:"0xf075352f43cd15bA51B0957A4465223EDf6b4Cd8",fee:"0xB5BaCB60ECDa0bEF809B2A26eC9B4B926835D7af"},omni:{type:"paraswap",solver:"Paraswap",router:"0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57",adapter:"0x41c925E8E4fC65136BDf5322824E0D8c20c4824e",fee:"0xba5291526c30B097E9F1Fd1Be301E2ab6E0782aa"},chronos:{type:"default",solver:"Odos",router:"0x19cEeAd7105607Cd444F5ad10dd51356436095a1",adapter:"0x6a6b8975d1b131EFd0a9b536766EE7E5d4a16CF2",fee:"0x5729af83240EFecAa18eafaAE82961c2DD045Dbe"},pancake:{type:"p2",solver:"Orbs",router:"0xFE6508f0015C778Bdcc1fB5465bA5ebE224C9912",permit2:"0x31c2F6fcFf4F8759b3Bd5Bf0e1084A055615c768",adapter:"0xA7CcB11F1D20D1F915FC220F5Cb1646E4523bB75",fee:"0x37A957f10F458e0d7fDECBE2917971b57F15c927"},sushiswap:{type:"default",solver:"Sushi",router:"0xAC4c6e212A361c968F1725b4d055b47E63F80b75",adapter:"0x2e43A28FAf083717CcD9B246d97C61E1Bc9914Df",fee:"0x28F6C9dBE21fFc146Af8d5D15c49Cf48F61140Dc"},ring:{type:"dynamicp2",solver:"Ring",permit2:"0x000000000022D473030F116dDEE9F6B43aC78BA3",adapter:"0x028fa69049aB68EC42064Eb18896D587dD41Af2a",fee:"0xA04329696aAd1417c75Cf6d91342815001999B21"}}},43114:{adapter:{Odos:"0x533dA659Ef4C2C1d4c98420e1dbe9C68D8538f50",Kyber:"0x6f4e5b8d7F6b037c62277992c39E7834D7C04596"},dex:{blackhole:{type:"default",solver:"Kyber",router:"0x6131B5fae19EA4f9D964eAc0408E4408b66337b5",adapter:"0xccdF1D6ce95FeC0F842197470CE8969A678B0A04",fee:"0x7f8B62520D9B5DA0ED517cc36e8dcb2a356f1928"},pangolin:{type:"default",solver:"Kyber",router:"0x6131B5fae19EA4f9D964eAc0408E4408b66337b5",adapter:"0xf42106eBf985bF49b39eba0114F57FA05e7B52eD",fee:"0xde92da99D188Ceb54A11ec711EF52D808A6260B5"}}},59144:{adapter:{Odos:"0xA58A55AC39b47504A63993A91B78544158862e61",Orbs:"0x917b492557957f5dD3e69c04c8E1Ac3d6948c022",OpenOcean:"0xd2e68b1d1C5DBB2D6cC396c10C55017e01309C37"},dex:{pancake:{type:"p2",solver:"Orbs",router:"0xFE6508f0015C778Bdcc1fB5465bA5ebE224C9912",permit2:"0x31c2F6fcFf4F8759b3Bd5Bf0e1084A055615c768",adapter:"0xA7CcB11F1D20D1F915FC220F5Cb1646E4523bB75",fee:"0x37A957f10F458e0d7fDECBE2917971b57F15c927"},lynex:{type:"default",solver:"OpenOcean",router:"0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",adapter:"0xd8bC1FF79a642e8D7Fbd0711374F287202fBb3AA",fee:"0xcb36ed1B1BfAD8F7FC9651f52d21f04A68677423"}}},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",utilaAdapter:"0x7671291910b559d7a05ab73ee31dd714d9c6e7b065c9496338bf427182ae5145",utilaFee:"0x46f797cddb221ecf6279b56f52e2f6360cd721ef95bd5a17dd0ffceffaaf7fd6",efAdapter:"0xa5425e0f84a7cf12c4213f57396810d808d88e43a65210786bd0d9a98a314728",efFee:"0x14387b821c54f18e2a9351887a92cc79164a5ea0b88cfc3f36741eae6d4fd815",htAdapter:"0x2ec50a8a136049da76c16f3dd12a8ed1b23f2bc91aca73c6a20cc8344e34f998",htFee:"0x2f902a86a7f6abeedc073e76cd33d4737f25189e18c8f450f16d2ffe14405242"},dex:{agent:{type:"universal",adapter:"0x0002BeFB46587d460AcEA9B2792c4A4c67B9cADa",fee:"0x0006d9557Ac9Af4f31962896299ba4FaBDaB9fEE"},utila:{type:"universal",adapter:"0x000ADa14B2ECF45Da6Cf1B33dE34e05231E9C76f",fee:"0x000FEee351263c82501a4dF5f699a8b630ac7f36"},ef:{type:"universal",adapter:"0xeF1B796D708BD776F6b377E93eAd8Ca5fA0C3117",fee:"0xeF1D677d7aE1a066beb26cC1C74E31C082B75FEf"},ht:{type:"universal",adapter:"0xA560a960C3b7784f5c335C33028D31596b91650b",fee:"0xE7a926C0cb01aCCE74e5d4FCeB7CA1699e200608"}}}};var Kn,Ur;function Ea(){if(Ur)return Kn;Ur=1;const e=Aa,t=a=>ga(`./out/${a}.sol/${a}.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(a){var u;if(!a)return;const o=e[a];if(o)return{...((u=e["*"])==null?void 0:u.adapter)??{},...o.adapter??{}}}function s(a,o){if(!a)return;const{dex:u,salt:p,...f}=e["*"]??{},w=e[a];if(!w)return;const{dex:y,salt:b,...D}=w,O={...f,...D},B=o==null?void 0:o.trim();if(!B)return O;const k=u==null?void 0:u[B],_=y==null?void 0:y[B];if(!(!k&&!_))return{...O,...k,..._}}return Kn={config:s,adapters:r,abis:n,raw:e},Kn}var Rr=Ea();const Ut=(e,t)=>{if(!e||!t)return"";const n=v(10).pow(e||0);return v(t).times(n).idiv(n).div(n).toFixed()};v(0),v(1),v(10),v(1e18);function gt(e,t){return e==t||e.toLowerCase()==t.toLowerCase()}const Rt=e=>!!ra.find(t=>gt(t,e||""));function ba(e){return[De.Years,De.Months,De.Weeks,De.Days,De.Hours,De.Minutes].find(n=>n<=e)||De.Minutes}const At=e=>e?e.value*e.unit:0,Ca=e=>!e||e==="NaN"?"0":v(e).decimalPlaces(0).toFixed(),Et=e=>Object.values(ye).find(t=>t.id===e),Ta=e=>{if(!e)return;const t=e.map(a=>Ae(a)),n=Object.entries(sa).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)},Hn=(e,t)=>e.version===1?(e.fillDelay||0)*1e3+Ia(t):(e.fillDelay||0)*1e3,gn=e=>typeof window>"u"?null:new URLSearchParams(window.location.search).get(e),Lr=e=>Hr().filter(t=>t.name===e).map(t=>t.chainId),Wn=(e="",t="",n=18,r=18)=>{if(!v(e||0).gt(0)||!v(t||0).gt(0))return"";const s=Ut(n,e),a=Ut(r,t);return v(a).div(s).toFixed()},Nr=(e,t,n)=>{if(e.type===X.TWAP_MARKET)return"";const r=Ut(t,e.srcAmountPerTrade),s=Ut(n,e.dstMinAmountPerTrade);return v(s).div(r).toFixed()},qr=(e,t,n)=>{if(e.type===X.TWAP_MARKET)return"";const r=Ut(t,e.srcAmountPerTrade),s=Ut(n,e.triggerPricePerTrade);return v(s).div(r).toFixed()},wa=new Set([1,56,42161,8453]),Kr=(e,t)=>e===Pe.Ring?wa.has(t):!0,xa=(e,t,n)=>{if(!e||!t||!n)return;const r=v(e).times(t),s=v(10).pow(n);return r.div(s).toFixed(0)},Sa=(e,t,n,r)=>{if(n||!r||!e||!t)return v(0).toString();const s=v(e).times(v(t)),a=v(10).pow(r),o=s.div(a);return v.max(1,o).integerValue(v.ROUND_FLOOR).toFixed(0)},va=(e,t,n,r)=>{if(e===j.TWAP||e===j.LIMIT)return"0";if(!r||!t||!n)return;const s=v(t).times(v(n)),a=v(10).pow(r),o=s.div(a);return v.max(1,o).integerValue(v.ROUND_FLOOR).toFixed(0)||"0"},Fa=(e,t,n,r)=>{const s=At(n)*2*t,a=gn(Jt.DURATION),o=ba(a?Number(a):s);return a?{unit:o,value:Number(v(Number(a)/o).toFixed(2))}:r||(e===j.LIMIT?{unit:De.Days,value:7}:e===j.STOP_LOSS||e===j.TAKE_PROFIT?{unit:De.Days,value:1}:{unit:o,value:Number(v(s/o).toFixed(2))})},Da=(e,t,n)=>t!==j.TWAP?1:n!==void 0?n:Math.max(1,Math.ceil(e/2)),Pa=(e,t,n)=>{if(!e||!t||!n)return 1;const s=v(t).times(e).div(n).integerValue(v.ROUND_FLOOR).toNumber();return Math.max(1,s)},Oa=(e,t)=>e+At(t)+6e4,Ia=e=>e.bidDelaySeconds*1e3*2,Ba=(e="",t=0)=>!e||!t?"0":v(e).div(t).integerValue(v.ROUND_FLOOR).toFixed(0),Ma=(e,t)=>({isError:!(e.unit===Rn.unit&&e.value===Rn.value)&&At(e)*t>hn,value:Math.floor(hn/t)}),ka=(e="",t="",n)=>{if(n===j.STOP_LOSS)return{isError:v(t||0).gte(v(e||0)),value:e}},_a=(e="",t="",n)=>{if(n===j.TAKE_PROFIT)return{isError:v(t||0).lte(v(e||0)),value:e}},Ua=(e="",t="",n=!1,r)=>{if(!n&&r===j.STOP_LOSS)return{isError:v(t||0).gte(v(e||0)),value:e}},Ra=(e="",t="",n=!1,r)=>{if(!n&&r===j.TAKE_PROFIT)return{isError:v(t||0).gte(v(e||0)),value:e}},La=(e,t)=>e===j.STOP_LOSS||e===j.TAKE_PROFIT?{isError:At(t)>5184e6,value:5184e6}:{isError:At(t)>hn,value:hn},Na=e=>({isError:At(e)<Br,value:Br}),qa=e=>({isError:At(e)<_n,value:_n}),Ka=(e,t,n)=>({isError:v(t||0).multipliedBy(e||0).isLessThan(n),value:n}),Ha=(e,t,n)=>({isError:n===j.TWAP&&v(e).isGreaterThan(t),value:t}),Wa=(e,t)=>{if(e===Pe.Pancake)switch(t){case 56:return $.PancakeSwap;case 42161:return $.PancakeSwapArbitrum;case 8453:return $.PancakeSwapBase;case 59144:return $.PancakeSwapLinea;default:return $.PancakeSwap}if(e===Pe.Sushiswap)switch(t){case 1:return $.SushiEth;case 42161:return $.SushiArb;case 8453:return $.SushiBase;case 747474:return $.SushiKatana;default:return $.SushiEth}if(e===Pe.Quick)switch(t){case 137:return $.QuickSwap;case 8453:return $.QuickSwapBase;default:return $.QuickSwap}if(e===Pe.Thena)switch(t){case 56:return $.Thena;default:return $.Thena}if(e===Pe.Spooky)switch(t){case 250:return $.SpookySwap;case 146:return $.SpookySwapSonic;default:return $.SpookySwap}if(e===Pe.Lynex)switch(t){case 59144:return $.Lynex;default:return $.Lynex}if(e===Pe.Swapx)switch(t){case 146:return $.SwapX;default:return $.SwapX}if(e===Pe.Blackhole)switch(t){case 43114:return $.BlackholeAvax;default:return $.BlackholeAvax}},zn=(e,t=0)=>{if(!Kr(e,t))throw new Error(`Partner "${e}" is not supported on chain ${t}`);const{abi:n,...r}=Rr.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:Wa(e,t)}},Hr=()=>{var n;const e=Rr.raw,t=((n=e["*"])==null?void 0:n.dex)??{};return Object.entries(e).filter(([r])=>r!=="*").flatMap(([r,s])=>{const a=Number(r),o={...t,...(s==null?void 0:s.dex)??{}};return!o||typeof o!="object"?[]:Object.entries(o).flatMap(([u])=>{const p=u;return Kr(p,a)?[{chainId:a,name:u,config:zn(p,a)}]:[]})}).sort((r,s)=>r.name.localeCompare(s.name))},Wr=e=>{const t=gn(Jt.MIN_CHUNK_SIZE_USD);return t?parseInt(t):e},za=({marketPrice:e,typedInputAmount:t,srcUsd1Token:n,marketPriceLoading:r,triggerPriceError:s,limitPriceError:a,tradesError:o,fillDelayError:u,durationError:p,balanceError:f,minTradeSizeError:w})=>{if(!gn(Jt.IGNORE_ERRORS)&&!(v(e||0).isZero()||v(t||0).isZero()||v(n||"0").isZero()||r))return w||s||a||o||u||p||f},Qa=(e,t)=>{const n=Date.now().toString(),r=parseInt((e/1e3).toFixed(0)),s=Ca(t/1e3),a=gn(Jt.FRESHNESS),o=a?parseInt(a):60;return{nonce:n,epoch:r,deadline:s,freshness:o}},zr=({chainId:e,srcToken:t,dstToken:n,srcAmount:r,deadlineMillis:s,fillDelayMillis:a,slippage:o,account:u,srcAmountPerTrade:p,dstMinAmountPerTrade:f="0",triggerAmountPerTrade:w="0",config:y,module:b})=>{const{nonce:D,epoch:O,deadline:B,freshness:k}=Qa(a,s),_=Math.floor(Date.now()/1e3).toString(),S=f,K=b===j.STOP_LOSS?w:"0",U=b===j.TAKE_PROFIT?w:"0",V={permitted:{token:t,amount:r},spender:y.reactor,nonce:D,deadline:B,witness:{reactor:y.reactor,executor:y.executor,exchange:{adapter:y.adapter,ref:y.fee,share:0,data:"0x"},swapper:u,nonce:D,start:_,deadline:B,chainid:e,exclusivity:0,epoch:O,slippage:o,freshness:k,input:{token:t,amount:p,maxAmount:r},output:{token:n,limit:v(S||0).toFixed(),triggerLower:v(K||0).toFixed(),triggerUpper:v(U||0).toFixed(),recipient:u}}};return{domain:{name:"RePermit",version:"1",chainId:e,verifyingContract:y.repermit},order:V,types:ia,primaryType:aa}},$a=`https://bi.orbs.network/putes/twap-ui-${.7}`;let Qn="unknown";function ja(e){Qn=e}function $n(){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 Va=(e,t,n)=>{var r,s,a,o,u,p,f,w,y;return{spotVersion:kn.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:((u=e.twapConfig)==null?void 0:u.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:((y=e.twapConfig)==null?void 0:y.pathfinderKey)||""}},Qr=async e=>{try{await fetch($a,{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 Ga{constructor(){In(this,"timeout");In(this,"config");In(this,"data",{_id:$n()})}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:a,fromTokenAmount:o,srcChunkAmount:u,minDstAmountOutPerTrade:p="",triggerPricePerTrade:f="",deadline:w,fillDelay:y,slippage:b,isMarketOrder:D,chunksAmount:O}){this.updateAndSend({toTokenAddress:a.address,toTokenSymbol:a.symbol,fromTokenAddress:s.address,fromTokenSymbol:s.symbol,fromTokenAmount:o,chunksAmount:O,srcChunkAmount:u,minDstAmountOutPerTrade:p,triggerPricePerTrade:f,deadline:w,fillDelay:y,slippage:b,chainId:n,walletAddress:t,module:r,orderType:D?"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,s){var a,o;this.config=t,(r!==((a=this.data)==null?void 0:a.chainId)||s!==((o=this.data)==null?void 0:o.appId))&&(this.data={_id:$n(),action:"module-import",uiVersion:Qn,appId:s,...Va(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:$n(),action:"reset",uiVersion:Qn,appId:this.data.appId,origin:this.data.origin,spotVersion:kn.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 fe=new Ga,Xa=e=>{var f;const t=v(e.order.witness.output.limit||0).gt(1),{stop:n,triggerLower:r,triggerUpper:s}=e.order.witness.output,a=v(n||0).eq(Mr),o=a||v(s||0).gt(0),u=!a&&v(n||0).gt(0)||v(r||0).gt(0),p=((f=e.metadata.chunks)==null?void 0:f.length)||v(e.order.witness.input.maxAmount).div(v(e.order.witness.input.amount)).toNumber();return o?t?X.TAKE_PROFIT_LIMIT:X.TAKE_PROFIT_MARKET:u?t?X.STOP_LOSS_LIMIT:X.STOP_LOSS_MARKET:t?p>1&&t?X.TWAP_LIMIT:t?X.LIMIT:X.TWAP_MARKET:X.TWAP_MARKET},Za=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=v(t).dividedBy(n).toNumber();return r>=.99?100:r<=0?0:Number((r*100).toFixed(2))},Ya=(e,t)=>e.metadata.status==="completed"||t>=99?ue.Completed:["pending","eligible"].includes(e.metadata.status)?ue.Open:e.metadata.description.toLowerCase()==="cancelled by contract"?ue.Cancelled:ue.Expired,Ja=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}))},ei=(e,t)=>{var r;const n=e.length;return n>=t&&((r=e[n-1])==null?void 0:r.timestamp)||0},ti=e=>v(e.metadata.displayOnlyInputTokenPriceUSD).dividedBy(1e18).toFixed(),jn=e=>Number(e.order.witness.output.limit)===1?"":e.order.witness.output.limit,ni=e=>{const{triggerLower:t="0",triggerUpper:n="0"}=e.order.witness.output,r=jn(e),s=e.metadata.expectedChunks||1,a=v(n||0).gt(0);return{dstMinAmountPerTrade:r,triggerPricePerTrade:a?n:t,dstMinAmountTotal:v(r).multipliedBy(s).toFixed()}},ri=e=>{const t=jn(e),n=v(e.order.witness.output.stop||0).eq(Mr),r=e.metadata.expectedChunks||1;return{dstMinAmountPerTrade:n?"":t,triggerPricePerTrade:n?t:v(e.order.witness.output.stop||"").toFixed(),dstMinAmountTotal:n?"":v(t).multipliedBy(r).toFixed()}},si=e=>Number(fn)>=2?ni(e):ri(e),$r=e=>{const t=Za(e),n=jn(e),r=e.metadata.expectedChunks||1,s=Ja(e),a=Xa(e);return{id:e.hash,hash:e.hash,version:2,type:a,maker:e.order.witness.swapper,progress:t,srcAmountFilled:s.reduce((o,u)=>o.plus(u.inAmount),new v(0)).toFixed()||"",dstAmountFilled:s.reduce((o,u)=>o.plus(u.outAmount),new v(0)).toFixed()||"",fills:s,srcTokenAddress:e.order.witness.input.token,dstTokenAddress:e.order.witness.output.token,orderDollarValueIn:ti(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:v(n||0).lte(1),chainId:e.order.witness.chainid,filledOrderTimestamp:ei(s,r),status:Ya(e,t),repermitDigest:e.metadata.repermitDigest,isTriggerPrice:a===X.TAKE_PROFIT_MARKET||a===X.TAKE_PROFIT_LIMIT||a===X.STOP_LOSS_LIMIT||a===X.STOP_LOSS_MARKET,rawOrder:e,...si(e)}},ai=async({chainId:e,signal:t,account:n,exchange:r,partner:s,isDev:a=!1})=>{try{if(!n)return[];const o=Ys(a),u=new Map;return(await Promise.all(o.map(async f=>{try{const w=ea({endpoint:f,exchange:r,partner:s}),y=w?`&exchange=${w}`:"",D=await(await fetch(`${f}/orders?swapper=${n}&chainId=${e}${y}`,{signal:t})).json();if(!D||!Array.isArray(D.orders))return[];const O=[];for(const B of D.orders)try{O.push($r(B))}catch{continue}return O}catch{return[]}}))).flat().forEach(f=>{u.has(f.id)||u.set(f.id,f)}),Array.from(u.values())}catch{return[]}},jr=async(e,t,n=!1)=>{try{const r={signature:t,order:e,status:"pending"};fe.onCreateOrderRequest();const s=await fetch(`${Zs(n)}/orders/new`,{method:"POST",body:JSON.stringify(r)}),a=await s.json().catch(()=>({}));if(!s.ok||!(a!=null&&a.success)){const u=(a==null?void 0:a.message)??s.statusText??"Request failed",p=(a==null?void 0:a.code)??s.status;throw new Error(`error:${u}, code:${p}`)}if(!a.signedOrder||typeof a.signedOrder!="object")throw new Error("Invalid API response: missing signedOrder");const o=$r(a.signedOrder);return fe.onCreateOrderSuccess(o.id),o}catch(r){throw fe.onCreateOrderError(r),console.error(r),r}},Ve=(e,t)=>e&&e.length?e.map(t||(n=>`${n}`)):void 0,ii=e=>{if(e)return na[e]},Vn=async({chainId:e,buildQuery:t,extractResults:n,signal:r,retries:s=1,limit:a=1e3,page:o})=>{const u=ii(e);if(!u)throw new pi;const p=async y=>{let b=0;for(;b<=s;)try{const D=await fetch(u,{method:"POST",body:JSON.stringify({query:y}),signal:r,headers:{"Content-Type":"application/json"}});if(!D.ok)throw new Error(`HTTP error: ${D.status}`);const O=await D.json();if(O.errors)throw new Error(O.errors[0].message);return n(O)}catch(D){if(b===s)throw D;await new Promise(O=>setTimeout(O,500*2**b)),b++}return[]};let f=0;const w=[];if(o!==void 0){const y=t(o,a);try{return await p(y)}catch{console.warn(`Page ${o} failed, retrying one final time...`);try{return await p(y)}catch{return[]}}}for(;;){const y=t(f,a);let b;try{b=await p(y)}catch{console.warn(`Page ${f} failed, retrying one final time...`);try{b=await p(y)}catch{return w}}if(w.push(...b),b.length<a)break;f++}return w},Vr=e=>e.map(t=>({inAmount:t.srcAmountIn,outAmount:t.dstAmountOut,timestamp:t.timestamp,txHash:t.transactionHash})),Gr=(e,t)=>{const n=v(e||0).gt(1);return!n&&t===1?X.TWAP_MARKET:t>1&&n?X.TWAP_LIMIT:n?X.LIMIT:X.TWAP_MARKET},oi=(e,t,n,r)=>{var b;const s=Vr(n||[]),a=new v(e.ask_srcAmount||0).div(e.ask_srcBidAmount).integerValue(v.ROUND_FLOOR).toNumber(),u=(n==null?void 0:n.length)===a?(b=n==null?void 0:n[(n==null?void 0:n.length)-1])==null?void 0:b.timestamp:void 0,p=s.reduce((D,O)=>D.plus(O.inAmount),new v(0)).toFixed(),f=s.reduce((D,O)=>D.plus(O.outAmount),new v(0)).toFixed(),w=Xr(e.ask_srcAmount,p),y=Gr(e.ask_dstMinAmount,a);return{repermitDigest:"",version:1,isTriggerPrice:!1,id:e.Contract_id.toString(),hash:"",type:Gr(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:v(e.dollarValueIn||0).toFixed(6),srcAmount:e.ask_srcAmount,dstMinAmountTotal:v(e.ask_dstMinAmount).multipliedBy(a).toString(),fills:s,fillDelay:e.ask_fillDelay,deadline:e.ask_deadline*1e3,createdAt:new Date(e.timestamp).getTime(),dstMinAmountPerTrade:v(e.ask_dstMinAmount).eq(1)?"":e.ask_dstMinAmount,triggerPricePerTrade:"",srcAmountPerTrade:e.ask_srcBidAmount,txHash:e.transactionHash,totalTradesAmount:a,isMarketPrice:[X.TWAP_MARKET].includes(y),chainId:t,filledOrderTimestamp:u||0,status:r,rawOrder:e}},ci=e=>{var y;if(!e)return"";const t=Ve(e.accounts,b=>`"${b.toLowerCase()}"`),n=Ve(Ta(e.configs),b=>`"${b.toLowerCase()}"`),r=Ve(e.inTokenSymbols,b=>`"${b.toUpperCase()}"`),s=Ve(e.outTokenSymbols,b=>`"${b.toUpperCase()}"`),a=Ve(e.inTokenAddresses,b=>`"${b.toLowerCase()}"`),o=Ve(e.outTokenAddresses,b=>`"${b.toLowerCase()}"`),u=Ve(e.transactionHashes,b=>`"${b.toLowerCase()}"`),p=Ve(e.orderIds,b=>`"${b}"`),f=n!=null&&n.length?"":Ve((y=e.configs)==null?void 0:y.map(b=>b.twapAddress),b=>`"${b.toLowerCase()}"`),w=e.minDollarValueIn;return[n?`exchange_in: [${n.join(", ")}]`:"",f?`twapAddress_in: [${f.join(", ")}]`:"",t?`maker_in: [${t.join(", ")}]`:"",u?`transactionHash_in: [${u.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 ui({chainId:e,signal:t,page:n,limit:r,filters:s}){const a=r||1e3,o=ci(s);return await Vn({chainId:e,signal:t,limit:a,page:n,buildQuery:(p,f)=>`
|
|
1
|
+
(function(B,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):(B=typeof globalThis<"u"?globalThis:B||self,H(B.SpotReact={},B.jsxRuntime,B.React))})(this,(function(B,H,D){"use strict";var fc=Object.defineProperty;var $s=B=>{throw TypeError(B)};var pc=(B,H,D)=>H in B?fc(B,H,{enumerable:!0,configurable:!0,writable:!0,value:D}):B[H]=D;var Bn=(B,H,D)=>pc(B,typeof H!="symbol"?H+"":H,D),Er=(B,H,D)=>H.has(B)||$s("Cannot "+D);var l=(B,H,D)=>(Er(B,H,"read from private field"),D?D.call(B):H.get(B)),N=(B,H,D)=>H.has(B)?$s("Cannot add the same private member more than once"):H instanceof WeakSet?H.add(B):H.set(B,D),M=(B,H,D,_t)=>(Er(B,H,"write to private field"),_t?_t.call(B,D):H.set(B,D),D),Q=(B,H,D)=>(Er(B,H,"access private method"),D);var In=(B,H,D,_t)=>({set _(ce){M(B,H,ce,D)},get _(){return l(B,H,_t)}});var He,Ft,_s,St,ot,Kt,Us,Ht,ct,Wt,Rs,Dt,Ls,vt,zt,ke,Pt,he,sn,Ot,Le,et,Ns,Se,Y,an,Ce,Bt,Qt,Ge,ut,on,$t,jt,It,Mt,dt,Vt,ee,ln,Cr,xr,Tr,wr,Fr,Sr,Dr,js,qs,cn,We,xe,kt,ze,mt,Ks,Xe,Ne,un,Hs,Ze,lt,De,Ye,Je,Mn,vr,Ws,Qe,zs,se,ft,pt,Gt,Xt,ht,Zt,Yt,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 ce=_t(D),$={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"}},Vs=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"}]'),Gs=[{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"}]}],Xs=Vs;var j=(e=>(e.TWAP="TWAP",e.LIMIT="LIMIT",e.STOP_LOSS="STOP_LOSS",e.TAKE_PROFIT="TAKE_PROFIT",e))(j||{}),ue=(e=>(e.Open="OPEN",e.Cancelled="CANCELLED",e.Completed="COMPLETED",e.Expired="EXPIRED",e))(ue||{}),Pr=(e=>(e.All="ALL",e.Open="OPEN",e.Cancelled="CANCELLED",e.Completed="COMPLETED",e.Expired="EXPIRED",e))(Pr||{}),ve=(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))(ve||{}),X=(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))(X||{}),Pe=(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.Utila="utila",e.Ring="ring",e.EfficientFrontier="ef",e.HtDigital="ht",e))(Pe||{}),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 ne="0x0000000000000000000000000000000000000000",ye={eth:{id:1,name:"Ethereum",shortname:"eth",native:{address:ne,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:ne,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},unichain:{id:130,name:"Unichain",shortname:"unichain",native:{address:ne,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/130/0x4200000000000000000000000000000000000006_0x042e6d078c6cf9e13a618396b0aa40181bcb43921ebdb5fabc8fb1124d516156.webp"},publicRpcUrl:"https://mainnet.unichain.org",logoUrl:"https://icons.llamao.fi/icons/chains/rsz_unichain",explorer:"https://uniscan.xyz",eip1559:!0},xlayer:{id:196,name:"X Layer",shortname:"xlayer",native:{address:ne,symbol:"OKB",decimals:18,logoUrl:"https://s2.coinmarketcap.com/static/img/coins/128x128/3897.png"},wToken:{symbol:"WOKB",address:"0xe538905cf8410324e03A5A23C1c177a474D59b2b",decimals:18,logoUrl:"https://s2.coinmarketcap.com/static/img/coins/128x128/3897.png"},publicRpcUrl:"https://rpc.xlayer.tech",logoUrl:"https://s2.coinmarketcap.com/static/img/coins/128x128/3897.png",explorer:"https://www.oklink.com/xlayer",eip1559:!0},hyperevm:{id:999,name:"HyperEVM",shortname:"hyperevm",native:{address:ne,symbol:"HYPE",decimals:18,logoUrl:"https://s2.coinmarketcap.com/static/img/coins/128x128/32196.png"},wToken:{symbol:"WHYPE",address:"0x5555555555555555555555555555555555555555",decimals:18,logoUrl:"https://s2.coinmarketcap.com/static/img/coins/128x128/32196.png"},publicRpcUrl:"https://rpc.hyperliquid.xyz/evm",logoUrl:"https://icons.llamao.fi/icons/chains/rsz_hyperliquid",explorer:"https://hyperevmscan.io",eip1559:!0},megaeth:{id:4326,name:"MegaETH",shortname:"megaeth",native:{address:ne,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://mainnet.megaeth.com/rpc",logoUrl:"https://icons.llamao.fi/icons/chains/rsz_megaeth",explorer:"https://mega.etherscan.io",eip1559:!0},poly:{id:137,name:"Polygon",shortname:"poly",native:{address:ne,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:ne,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:ne,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:ne,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:ne,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:ne,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:ne,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:ne,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:ne,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:ne,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:ne,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:ne,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:ne,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:ne,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:ne,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:ne,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:ne,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:ne,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:ne,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:ne,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}},kn={version:"2.7.0"},Or="https://order-sink-dev.orbs.network",fn="https://order-sink.orbs.network",Br="https://order-sink-v2.orbs.network",pn=kn.version.split(".")[0],Zs=e=>{const t=Number(pn)>=2;return e?Or:t?Br:fn},Ys=e=>{const t=Number(pn)>=2;return e?[Or]:t?[Br,fn]:[fn]},Js={[Pe.Thena]:"0xB75218ba5A99bF57Fd02556B70F05A4A0f1Dbe67"},ea=({endpoint:e,exchange:t,partner:n})=>e===fn&&n&&Js[n]||t,_n=300*1e3,hn=1440*60*60*1e3,Ir=300*1e3,ta=new Date(_n).getMinutes(),Un=e=>`https://hub.orbs.network/api/private/project_cm7nb67z86nyr01z12gs0fxpf/subgraphs/orbs-twap-${e}/prod/gn`,Ue="https://hub.orbs.network/api/apikey/subgraphs/id",na={[ye.eth.id]:`${Ue}/Bf7bvMYcJbDAvYWJmhMpHZ4cpFjqzkhK6GXXEpnPRq6`,[ye.bsc.id]:`${Ue}/4NfXEi8rreQsnAr4aJ45RLCKgnjcWX46Lbt9SadiCcz6`,[ye.poly.id]:`${Ue}/3PyRPWSvDnMowGbeBy7aNsvUkD5ZuxdXQw2RdJq4NdXi`,[ye.arb.id]:`${Ue}/83bpQexEaqBjHaQbKoFTbtvCXuo5RudRkfLgtRUYqo2c`,[ye.base.id]:`${Ue}/DFhaPQb3HATXkpsWNZw3gydYHehLBVEDiSk4iBdZJyps`,[ye.sei.id]:`${Ue}/5zjzRnURzoddyFSZBw5E5NAM3oBgPq3NasTYbtMk6EL6`,[ye.linea.id]:`${Ue}/6VsNPEYfFLPZCqdMMDadoXQjLHWJdjEwiD768GAtb7j6`,[ye.sonic.id]:`${Ue}/DtBr6a5vsoDd2oAXdPszcn4gLgrr1XC68Q3AJQKXnNLV`,[ye.ftm.id]:`${Ue}/DdRo1pmJkrJC9fjsjEBWnNE1uqrbh7Diz4tVKd7rfupp`,[ye.katana.id]:`${Ue}/CGi9sDFMQcnBwF3C3NoCFqnaE34sssbgwPLTwiskSXmW`,[ye.avax.id]:`${Ue}/FxZ1vMwE5Xy1qvKvZENUMz4vhW8Sh4vXJf9Vp7o17pTx`,[ye.bera.id]:Un("berachain"),[ye.flare.id]:Un("flare"),[ye.cronosZkEvm.id]:Un("cronos-zkevm")},ra=["0x0000000000000000000000000000000000000000","0x0000000000000000000000000000000000001010","0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE","0x000000000000000000000000000000000000dEaD","0x000000000000000000000000000000000000800A","0x000000000000000000000000000000000000800a"],Mr="115792089237316195423570985008687907853269984665640564039457584007913129639935",ge=e=>`${e.name}_${e.chainId}`,sa={[ge($.SushiArb)]:["0x846F2B29ef314bF3D667981b4ffdADc5B858312a","0x08c41f5D1C844061f6D952E25827eeAA576c6536"],[ge($.SushiBase)]:["0x846F2B29ef314bF3D667981b4ffdADc5B858312a","0x08c41f5D1C844061f6D952E25827eeAA576c6536"],[ge($.SushiEth)]:["0xc55943Fa6509004B2903ED8F8ab7347BfC47D0bA","0x08c41f5D1C844061f6D952E25827eeAA576c6536"],[ge($.PancakeSwap)]:["0xb2BAFe188faD927240038cC4FfF2d771d8A58905","0xE2a0c3b9aD19A18c4bBa7fffBe5bC1b0E58Db1CE"],[ge($.PancakeSwapArbitrum)]:["0xE20167871dB616DdfFD0Fd870d9bC068C350DD1F","0x807488ADAD033e95C438F998277bE654152594dc"],[ge($.PancakeSwapBase)]:["0x10ed1F36e4eBE76E161c9AADDa20BE841bc0082c","0x3A9df3eE209b802D0337383f5abCe3204d623588"],[ge($.PancakeSwapLinea)]:["0x3A9df3eE209b802D0337383f5abCe3204d623588"],[ge($.QuickSwap)]:["0x26D0ec4Be402BCE03AAa8aAf0CF67e9428ba54eF"],[ge($.Thena)]:["0xc2aBC02acd77Bb2407efA22348dA9afC8B375290"],[ge($.Lynex)]:["0x72e3e1fD5D2Ee2F1C2Eb695206D490a1D45C3835"],[ge($.DragonSwap)]:["0x101e1B65Bb516FB5f4547C80BAe0b51f1b8D7a22"],[ge($.SpookySwapSonic)]:["0xAd97B770ad64aE47fc7d64B3bD820dCDbF9ff7DA"],[ge($.SpookySwap)]:["0x3924d62219483015f982b160d48c0fa5Fd436Cba"],[ge($.SwapX)]:["0xE5012eBDe5e26EE3Ea41992154731a03023CF274"]},Rn={unit:ve.Minutes,value:ta},aa="RePermitWitnessTransferFrom",ia={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"}]},oa="https://www.orbs.com/dtwap-and-dlimit-faq/",ca="https://www.orbs.com/dtwap-and-dlimit-faq/#dSLTP",ua="https://raw.githubusercontent.com/orbs-network/twap-ui/master/logo/orbslogo.svg",da="https://www.orbs.com/",la="https://www.orbs.com/dtwap-dlimit-disclaimer";var Jt=(e=>(e.FRESHNESS="freshness",e.MIN_CHUNK_SIZE_USD="minChunkSizeUsd",e.ENV="env",e.DURATION="duration",e.IGNORE_ERRORS="ignore-errors",e))(Jt||{});const fa="-5",pa="10",ha="-10",ma="5";var ya=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,Ln=Math.ceil,Oe=Math.floor,we="[BigNumber Error] ",kr=we+"Number primitive has more than 15 significant digits: ",Re=1e14,W=14,Nn=9007199254740991,qn=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],tt=1e7,fe=1e9;function _r(e){var t,n,r,s=F.prototype={constructor:F,toString:null,valueOf:null},a=new F(1),o=20,u=4,f=-7,p=21,T=-1e7,y=1e7,E=!1,v=1,O=0,I={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},k="0123456789abcdefghijklmnopqrstuvwxyz",_=!0;function F(i,c){var d,b,m,A,w,h,g,x,C=this;if(!(C instanceof F))return new F(i,c);if(c==null){if(i&&i._isBigNumber===!0){C.s=i.s,!i.c||i.e>y?C.c=C.e=null:i.e<T?C.c=[C.e=0]:(C.e=i.e,C.c=i.c.slice());return}if((h=typeof i=="number")&&i*0==0){if(C.s=1/i<0?(i=-i,-1):1,i===~~i){for(A=0,w=i;w>=10;w/=10,A++);A>y?C.c=C.e=null:(C.e=A,C.c=[i]);return}x=String(i)}else{if(!ya.test(x=String(i)))return r(C,x,h);C.s=x.charCodeAt(0)==45?(x=x.slice(1),-1):1}(A=x.indexOf("."))>-1&&(x=x.replace(".","")),(w=x.search(/e/i))>0?(A<0&&(A=w),A+=+x.slice(w+1),x=x.substring(0,w)):A<0&&(A=x.length)}else{if(re(c,2,k.length,"Base"),c==10&&_)return C=new F(i),G(C,o+C.e+1,u);if(x=String(i),h=typeof i=="number"){if(i*0!=0)return r(C,x,h,c);if(C.s=1/i<0?(x=x.slice(1),-1):1,F.DEBUG&&x.replace(/^0\.0*|\./,"").length>15)throw Error(kr+i)}else C.s=x.charCodeAt(0)===45?(x=x.slice(1),-1):1;for(d=k.slice(0,c),A=w=0,g=x.length;w<g;w++)if(d.indexOf(b=x.charAt(w))<0){if(b=="."){if(w>A){A=g;continue}}else if(!m&&(x==x.toUpperCase()&&(x=x.toLowerCase())||x==x.toLowerCase()&&(x=x.toUpperCase()))){m=!0,w=-1,A=0;continue}return r(C,String(i),h,c)}h=!1,x=n(x,c,10,C.s),(A=x.indexOf("."))>-1?x=x.replace(".",""):A=x.length}for(w=0;x.charCodeAt(w)===48;w++);for(g=x.length;x.charCodeAt(--g)===48;);if(x=x.slice(w,++g)){if(g-=w,h&&F.DEBUG&&g>15&&(i>Nn||i!==Oe(i)))throw Error(kr+C.s*i);if((A=A-w-1)>y)C.c=C.e=null;else if(A<T)C.c=[C.e=0];else{if(C.e=A,C.c=[],w=(A+1)%W,A<0&&(w+=W),w<g){for(w&&C.c.push(+x.slice(0,w)),g-=W;w<g;)C.c.push(+x.slice(w,w+=W));w=W-(x=x.slice(w)).length}else w-=g;for(;w--;x+="0");C.c.push(+x)}}else C.c=[C.e=0]}F.clone=_r,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(i){var c,d;if(i!=null)if(typeof i=="object"){if(i.hasOwnProperty(c="DECIMAL_PLACES")&&(d=i[c],re(d,0,fe,c),o=d),i.hasOwnProperty(c="ROUNDING_MODE")&&(d=i[c],re(d,0,8,c),u=d),i.hasOwnProperty(c="EXPONENTIAL_AT")&&(d=i[c],d&&d.pop?(re(d[0],-fe,0,c),re(d[1],0,fe,c),f=d[0],p=d[1]):(re(d,-fe,fe,c),f=-(p=d<0?-d:d))),i.hasOwnProperty(c="RANGE"))if(d=i[c],d&&d.pop)re(d[0],-fe,-1,c),re(d[1],1,fe,c),T=d[0],y=d[1];else if(re(d,-fe,fe,c),d)T=-(y=d<0?-d:d);else throw Error(we+c+" cannot be zero: "+d);if(i.hasOwnProperty(c="CRYPTO"))if(d=i[c],d===!!d)if(d)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))E=d;else throw E=!d,Error(we+"crypto unavailable");else E=d;else throw Error(we+c+" not true or false: "+d);if(i.hasOwnProperty(c="MODULO_MODE")&&(d=i[c],re(d,0,9,c),v=d),i.hasOwnProperty(c="POW_PRECISION")&&(d=i[c],re(d,0,fe,c),O=d),i.hasOwnProperty(c="FORMAT"))if(d=i[c],typeof d=="object")I=d;else throw Error(we+c+" not an object: "+d);if(i.hasOwnProperty(c="ALPHABET"))if(d=i[c],typeof d=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(d))_=d.slice(0,10)=="0123456789",k=d;else throw Error(we+c+" invalid: "+d)}else throw Error(we+"Object expected: "+i);return{DECIMAL_PLACES:o,ROUNDING_MODE:u,EXPONENTIAL_AT:[f,p],RANGE:[T,y],CRYPTO:E,MODULO_MODE:v,POW_PRECISION:O,FORMAT:I,ALPHABET:k}},F.isBigNumber=function(i){if(!i||i._isBigNumber!==!0)return!1;if(!F.DEBUG)return!0;var c,d,b=i.c,m=i.e,A=i.s;e:if({}.toString.call(b)=="[object Array]"){if((A===1||A===-1)&&m>=-fe&&m<=fe&&m===Oe(m)){if(b[0]===0){if(m===0&&b.length===1)return!0;break e}if(c=(m+1)%W,c<1&&(c+=W),String(b[0]).length==c){for(c=0;c<b.length;c++)if(d=b[c],d<0||d>=Re||d!==Oe(d))break e;if(d!==0)return!0}}}else if(b===null&&m===null&&(A===null||A===1||A===-1))return!0;throw Error(we+"Invalid BigNumber: "+i)},F.maximum=F.max=function(){return U(arguments,-1)},F.minimum=F.min=function(){return U(arguments,1)},F.random=(function(){var i=9007199254740992,c=Math.random()*i&2097151?function(){return Oe(Math.random()*i)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(d){var b,m,A,w,h,g=0,x=[],C=new F(a);if(d==null?d=o:re(d,0,fe),w=Ln(d/W),E)if(crypto.getRandomValues){for(b=crypto.getRandomValues(new Uint32Array(w*=2));g<w;)h=b[g]*131072+(b[g+1]>>>11),h>=9e15?(m=crypto.getRandomValues(new Uint32Array(2)),b[g]=m[0],b[g+1]=m[1]):(x.push(h%1e14),g+=2);g=w/2}else if(crypto.randomBytes){for(b=crypto.randomBytes(w*=7);g<w;)h=(b[g]&31)*281474976710656+b[g+1]*1099511627776+b[g+2]*4294967296+b[g+3]*16777216+(b[g+4]<<16)+(b[g+5]<<8)+b[g+6],h>=9e15?crypto.randomBytes(7).copy(b,g):(x.push(h%1e14),g+=7);g=w/7}else throw E=!1,Error(we+"crypto unavailable");if(!E)for(;g<w;)h=c(),h<9e15&&(x[g++]=h%1e14);for(w=x[--g],d%=W,w&&d&&(h=qn[W-d],x[g]=Oe(w/h)*h);x[g]===0;x.pop(),g--);if(g<0)x=[A=0];else{for(A=-1;x[0]===0;x.splice(0,1),A-=W);for(g=1,h=x[0];h>=10;h/=10,g++);g<W&&(A-=W-g)}return C.e=A,C.c=x,C}})(),F.sum=function(){for(var i=1,c=arguments,d=new F(c[0]);i<c.length;)d=d.plus(c[i++]);return d},n=(function(){var i="0123456789";function c(d,b,m,A){for(var w,h=[0],g,x=0,C=d.length;x<C;){for(g=h.length;g--;h[g]*=b);for(h[0]+=A.indexOf(d.charAt(x++)),w=0;w<h.length;w++)h[w]>m-1&&(h[w+1]==null&&(h[w+1]=0),h[w+1]+=h[w]/m|0,h[w]%=m)}return h.reverse()}return function(d,b,m,A,w){var h,g,x,C,P,R,L,Z,ae=d.indexOf("."),le=o,J=u;for(ae>=0&&(C=O,O=0,d=d.replace(".",""),Z=new F(b),R=Z.pow(d.length-ae),O=C,Z.c=c(je(Ie(R.c),R.e,"0"),10,m,i),Z.e=Z.c.length),L=c(d,b,m,w?(h=k,i):(h=i,k)),x=C=L.length;L[--C]==0;L.pop());if(!L[0])return h.charAt(0);if(ae<0?--x:(R.c=L,R.e=x,R.s=A,R=t(R,Z,le,J,m),L=R.c,P=R.r,x=R.e),g=x+le+1,ae=L[g],C=m/2,P=P||g<0||L[g+1]!=null,P=J<4?(ae!=null||P)&&(J==0||J==(R.s<0?3:2)):ae>C||ae==C&&(J==4||P||J==6&&L[g-1]&1||J==(R.s<0?8:7)),g<1||!L[0])d=P?je(h.charAt(1),-le,h.charAt(0)):h.charAt(0);else{if(L.length=g,P)for(--m;++L[--g]>m;)L[g]=0,g||(++x,L=[1].concat(L));for(C=L.length;!L[--C];);for(ae=0,d="";ae<=C;d+=h.charAt(L[ae++]));d=je(d,x,h.charAt(0))}return d}})(),t=(function(){function i(b,m,A){var w,h,g,x,C=0,P=b.length,R=m%tt,L=m/tt|0;for(b=b.slice();P--;)g=b[P]%tt,x=b[P]/tt|0,w=L*g+x*R,h=R*g+w%tt*tt+C,C=(h/A|0)+(w/tt|0)+L*x,b[P]=h%A;return C&&(b=[C].concat(b)),b}function c(b,m,A,w){var h,g;if(A!=w)g=A>w?1:-1;else for(h=g=0;h<A;h++)if(b[h]!=m[h]){g=b[h]>m[h]?1:-1;break}return g}function d(b,m,A,w){for(var h=0;A--;)b[A]-=h,h=b[A]<m[A]?1:0,b[A]=h*w+b[A]-m[A];for(;!b[0]&&b.length>1;b.splice(0,1));}return function(b,m,A,w,h){var g,x,C,P,R,L,Z,ae,le,J,te,Ae,On,gr,br,$e,dn,_e=b.s==m.s?1:-1,Te=b.c,ie=m.c;if(!Te||!Te[0]||!ie||!ie[0])return new F(!b.s||!m.s||(Te?ie&&Te[0]==ie[0]:!ie)?NaN:Te&&Te[0]==0||!ie?_e*0:_e/0);for(ae=new F(_e),le=ae.c=[],x=b.e-m.e,_e=A+x+1,h||(h=Re,x=Be(b.e/W)-Be(m.e/W),_e=_e/W|0),C=0;ie[C]==(Te[C]||0);C++);if(ie[C]>(Te[C]||0)&&x--,_e<0)le.push(1),P=!0;else{for(gr=Te.length,$e=ie.length,C=0,_e+=2,R=Oe(h/(ie[0]+1)),R>1&&(ie=i(ie,R,h),Te=i(Te,R,h),$e=ie.length,gr=Te.length),On=$e,J=Te.slice(0,$e),te=J.length;te<$e;J[te++]=0);dn=ie.slice(),dn=[0].concat(dn),br=ie[0],ie[1]>=h/2&&br++;do{if(R=0,g=c(ie,J,$e,te),g<0){if(Ae=J[0],$e!=te&&(Ae=Ae*h+(J[1]||0)),R=Oe(Ae/br),R>1)for(R>=h&&(R=h-1),L=i(ie,R,h),Z=L.length,te=J.length;c(L,J,Z,te)==1;)R--,d(L,$e<Z?dn:ie,Z,h),Z=L.length,g=1;else R==0&&(g=R=1),L=ie.slice(),Z=L.length;if(Z<te&&(L=[0].concat(L)),d(J,L,te,h),te=J.length,g==-1)for(;c(ie,J,$e,te)<1;)R++,d(J,$e<te?dn:ie,te,h),te=J.length}else g===0&&(R++,J=[0]);le[C++]=R,J[0]?J[te++]=Te[On]||0:(J=[Te[On]],te=1)}while((On++<gr||J[0]!=null)&&_e--);P=J[0]!=null,le[0]||le.splice(0,1)}if(h==Re){for(C=1,_e=le[0];_e>=10;_e/=10,C++);G(ae,A+(ae.e=C+x*W-1)+1,w,P)}else ae.e=x,ae.r=+P;return ae}})();function K(i,c,d,b){var m,A,w,h,g;if(d==null?d=u:re(d,0,8),!i.c)return i.toString();if(m=i.c[0],w=i.e,c==null)g=Ie(i.c),g=b==1||b==2&&(w<=f||w>=p)?yn(g,w):je(g,w,"0");else if(i=G(new F(i),c,d),A=i.e,g=Ie(i.c),h=g.length,b==1||b==2&&(c<=A||A<=f)){for(;h<c;g+="0",h++);g=yn(g,A)}else if(c-=w+(b===2&&A>w),g=je(g,A,"0"),A+1>h){if(--c>0)for(g+=".";c--;g+="0");}else if(c+=A-h,c>0)for(A+1==h&&(g+=".");c--;g+="0");return i.s<0&&m?"-"+g:g}function U(i,c){for(var d,b,m=1,A=new F(i[0]);m<i.length;m++)b=new F(i[m]),(!b.s||(d=yt(A,b))===c||d===0&&A.s===c)&&(A=b);return A}function V(i,c,d){for(var b=1,m=c.length;!c[--m];c.pop());for(m=c[0];m>=10;m/=10,b++);return(d=b+d*W-1)>y?i.c=i.e=null:d<T?i.c=[i.e=0]:(i.e=d,i.c=c),i}r=(function(){var i=/^(-?)0([xbo])(?=\w[\w.]*$)/i,c=/^([^.]+)\.$/,d=/^\.([^.]+)$/,b=/^-?(Infinity|NaN)$/,m=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(A,w,h,g){var x,C=h?w:w.replace(m,"");if(b.test(C))A.s=isNaN(C)?null:C<0?-1:1;else{if(!h&&(C=C.replace(i,function(P,R,L){return x=(L=L.toLowerCase())=="x"?16:L=="b"?2:8,!g||g==x?R:P}),g&&(x=g,C=C.replace(c,"$1").replace(d,"0.$1")),w!=C))return new F(C,x);if(F.DEBUG)throw Error(we+"Not a"+(g?" base "+g:"")+" number: "+w);A.s=null}A.c=A.e=null}})();function G(i,c,d,b){var m,A,w,h,g,x,C,P=i.c,R=qn;if(P){e:{for(m=1,h=P[0];h>=10;h/=10,m++);if(A=c-m,A<0)A+=W,w=c,g=P[x=0],C=Oe(g/R[m-w-1]%10);else if(x=Ln((A+1)/W),x>=P.length)if(b){for(;P.length<=x;P.push(0));g=C=0,m=1,A%=W,w=A-W+1}else break e;else{for(g=h=P[x],m=1;h>=10;h/=10,m++);A%=W,w=A-W+m,C=w<0?0:Oe(g/R[m-w-1]%10)}if(b=b||c<0||P[x+1]!=null||(w<0?g:g%R[m-w-1]),b=d<4?(C||b)&&(d==0||d==(i.s<0?3:2)):C>5||C==5&&(d==4||b||d==6&&(A>0?w>0?g/R[m-w]:0:P[x-1])%10&1||d==(i.s<0?8:7)),c<1||!P[0])return P.length=0,b?(c-=i.e+1,P[0]=R[(W-c%W)%W],i.e=-c||0):P[0]=i.e=0,i;if(A==0?(P.length=x,h=1,x--):(P.length=x+1,h=R[W-A],P[x]=w>0?Oe(g/R[m-w]%R[w])*h:0),b)for(;;)if(x==0){for(A=1,w=P[0];w>=10;w/=10,A++);for(w=P[0]+=h,h=1;w>=10;w/=10,h++);A!=h&&(i.e++,P[0]==Re&&(P[0]=1));break}else{if(P[x]+=h,P[x]!=Re)break;P[x--]=0,h=1}for(A=P.length;P[--A]===0;P.pop());}i.e>y?i.c=i.e=null:i.e<T&&(i.c=[i.e=0])}return i}function oe(i){var c,d=i.e;return d===null?i.toString():(c=Ie(i.c),c=d<=f||d>=p?yn(c,d):je(c,d,"0"),i.s<0?"-"+c:c)}return s.absoluteValue=s.abs=function(){var i=new F(this);return i.s<0&&(i.s=1),i},s.comparedTo=function(i,c){return yt(this,new F(i,c))},s.decimalPlaces=s.dp=function(i,c){var d,b,m,A=this;if(i!=null)return re(i,0,fe),c==null?c=u:re(c,0,8),G(new F(A),i+A.e+1,c);if(!(d=A.c))return null;if(b=((m=d.length-1)-Be(this.e/W))*W,m=d[m])for(;m%10==0;m/=10,b--);return b<0&&(b=0),b},s.dividedBy=s.div=function(i,c){return t(this,new F(i,c),o,u)},s.dividedToIntegerBy=s.idiv=function(i,c){return t(this,new F(i,c),0,1)},s.exponentiatedBy=s.pow=function(i,c){var d,b,m,A,w,h,g,x,C,P=this;if(i=new F(i),i.c&&!i.isInteger())throw Error(we+"Exponent not an integer: "+oe(i));if(c!=null&&(c=new F(c)),h=i.e>14,!P.c||!P.c[0]||P.c[0]==1&&!P.e&&P.c.length==1||!i.c||!i.c[0])return C=new F(Math.pow(+oe(P),h?i.s*(2-mn(i)):+oe(i))),c?C.mod(c):C;if(g=i.s<0,c){if(c.c?!c.c[0]:!c.s)return new F(NaN);b=!g&&P.isInteger()&&c.isInteger(),b&&(P=P.mod(c))}else{if(i.e>9&&(P.e>0||P.e<-1||(P.e==0?P.c[0]>1||h&&P.c[1]>=24e7:P.c[0]<8e13||h&&P.c[0]<=9999975e7)))return A=P.s<0&&mn(i)?-0:0,P.e>-1&&(A=1/A),new F(g?1/A:A);O&&(A=Ln(O/W+2))}for(h?(d=new F(.5),g&&(i.s=1),x=mn(i)):(m=Math.abs(+oe(i)),x=m%2),C=new F(a);;){if(x){if(C=C.times(P),!C.c)break;A?C.c.length>A&&(C.c.length=A):b&&(C=C.mod(c))}if(m){if(m=Oe(m/2),m===0)break;x=m%2}else if(i=i.times(d),G(i,i.e+1,1),i.e>14)x=mn(i);else{if(m=+oe(i),m===0)break;x=m%2}P=P.times(P),A?P.c&&P.c.length>A&&(P.c.length=A):b&&(P=P.mod(c))}return b?C:(g&&(C=a.div(C)),c?C.mod(c):A?G(C,O,u,w):C)},s.integerValue=function(i){var c=new F(this);return i==null?i=u:re(i,0,8),G(c,c.e+1,i)},s.isEqualTo=s.eq=function(i,c){return yt(this,new F(i,c))===0},s.isFinite=function(){return!!this.c},s.isGreaterThan=s.gt=function(i,c){return yt(this,new F(i,c))>0},s.isGreaterThanOrEqualTo=s.gte=function(i,c){return(c=yt(this,new F(i,c)))===1||c===0},s.isInteger=function(){return!!this.c&&Be(this.e/W)>this.c.length-2},s.isLessThan=s.lt=function(i,c){return yt(this,new F(i,c))<0},s.isLessThanOrEqualTo=s.lte=function(i,c){return(c=yt(this,new F(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 d,b,m,A,w=this,h=w.s;if(i=new F(i,c),c=i.s,!h||!c)return new F(NaN);if(h!=c)return i.s=-c,w.plus(i);var g=w.e/W,x=i.e/W,C=w.c,P=i.c;if(!g||!x){if(!C||!P)return C?(i.s=-c,i):new F(P?w:NaN);if(!C[0]||!P[0])return P[0]?(i.s=-c,i):new F(C[0]?w:u==3?-0:0)}if(g=Be(g),x=Be(x),C=C.slice(),h=g-x){for((A=h<0)?(h=-h,m=C):(x=g,m=P),m.reverse(),c=h;c--;m.push(0));m.reverse()}else for(b=(A=(h=C.length)<(c=P.length))?h:c,h=c=0;c<b;c++)if(C[c]!=P[c]){A=C[c]<P[c];break}if(A&&(m=C,C=P,P=m,i.s=-i.s),c=(b=P.length)-(d=C.length),c>0)for(;c--;C[d++]=0);for(c=Re-1;b>h;){if(C[--b]<P[b]){for(d=b;d&&!C[--d];C[d]=c);--C[d],C[b]+=Re}C[b]-=P[b]}for(;C[0]==0;C.splice(0,1),--x);return C[0]?V(i,C,x):(i.s=u==3?-1:1,i.c=[i.e=0],i)},s.modulo=s.mod=function(i,c){var d,b,m=this;return i=new F(i,c),!m.c||!i.s||i.c&&!i.c[0]?new F(NaN):!i.c||m.c&&!m.c[0]?new F(m):(v==9?(b=i.s,i.s=1,d=t(m,i,0,3),i.s=b,d.s*=b):d=t(m,i,0,v),i=m.minus(d.times(i)),!i.c[0]&&v==1&&(i.s=m.s),i)},s.multipliedBy=s.times=function(i,c){var d,b,m,A,w,h,g,x,C,P,R,L,Z,ae,le,J=this,te=J.c,Ae=(i=new F(i,c)).c;if(!te||!Ae||!te[0]||!Ae[0])return!J.s||!i.s||te&&!te[0]&&!Ae||Ae&&!Ae[0]&&!te?i.c=i.e=i.s=null:(i.s*=J.s,!te||!Ae?i.c=i.e=null:(i.c=[0],i.e=0)),i;for(b=Be(J.e/W)+Be(i.e/W),i.s*=J.s,g=te.length,P=Ae.length,g<P&&(Z=te,te=Ae,Ae=Z,m=g,g=P,P=m),m=g+P,Z=[];m--;Z.push(0));for(ae=Re,le=tt,m=P;--m>=0;){for(d=0,R=Ae[m]%le,L=Ae[m]/le|0,w=g,A=m+w;A>m;)x=te[--w]%le,C=te[w]/le|0,h=L*x+C*R,x=R*x+h%le*le+Z[A]+d,d=(x/ae|0)+(h/le|0)+L*C,Z[A--]=x%ae;Z[A]=d}return d?++b:Z.splice(0,1),V(i,Z,b)},s.negated=function(){var i=new F(this);return i.s=-i.s||null,i},s.plus=function(i,c){var d,b=this,m=b.s;if(i=new F(i,c),c=i.s,!m||!c)return new F(NaN);if(m!=c)return i.s=-c,b.minus(i);var A=b.e/W,w=i.e/W,h=b.c,g=i.c;if(!A||!w){if(!h||!g)return new F(m/0);if(!h[0]||!g[0])return g[0]?i:new F(h[0]?b:m*0)}if(A=Be(A),w=Be(w),h=h.slice(),m=A-w){for(m>0?(w=A,d=g):(m=-m,d=h),d.reverse();m--;d.push(0));d.reverse()}for(m=h.length,c=g.length,m-c<0&&(d=g,g=h,h=d,c=m),m=0;c;)m=(h[--c]=h[c]+g[c]+m)/Re|0,h[c]=Re===h[c]?0:h[c]%Re;return m&&(h=[m].concat(h),++w),V(i,h,w)},s.precision=s.sd=function(i,c){var d,b,m,A=this;if(i!=null&&i!==!!i)return re(i,1,fe),c==null?c=u:re(c,0,8),G(new F(A),i,c);if(!(d=A.c))return null;if(m=d.length-1,b=m*W+1,m=d[m]){for(;m%10==0;m/=10,b--);for(m=d[0];m>=10;m/=10,b++);}return i&&A.e+1>b&&(b=A.e+1),b},s.shiftedBy=function(i){return re(i,-Nn,Nn),this.times("1e"+i)},s.squareRoot=s.sqrt=function(){var i,c,d,b,m,A=this,w=A.c,h=A.s,g=A.e,x=o+4,C=new F("0.5");if(h!==1||!w||!w[0])return new F(!h||h<0&&(!w||w[0])?NaN:w?A:1/0);if(h=Math.sqrt(+oe(A)),h==0||h==1/0?(c=Ie(w),(c.length+g)%2==0&&(c+="0"),h=Math.sqrt(+c),g=Be((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),d=new F(c)):d=new F(h+""),d.c[0]){for(g=d.e,h=g+x,h<3&&(h=0);;)if(m=d,d=C.times(m.plus(t(A,m,x,1))),Ie(m.c).slice(0,h)===(c=Ie(d.c)).slice(0,h))if(d.e<g&&--h,c=c.slice(h-3,h+1),c=="9999"||!b&&c=="4999"){if(!b&&(G(m,m.e+o+2,0),m.times(m).eq(A))){d=m;break}x+=4,h+=4,b=1}else{(!+c||!+c.slice(1)&&c.charAt(0)=="5")&&(G(d,d.e+o+2,1),i=!d.times(d).eq(A));break}}return G(d,d.e+o+1,u,i)},s.toExponential=function(i,c){return i!=null&&(re(i,0,fe),i++),K(this,i,c,1)},s.toFixed=function(i,c){return i!=null&&(re(i,0,fe),i=i+this.e+1),K(this,i,c)},s.toFormat=function(i,c,d){var b,m=this;if(d==null)i!=null&&c&&typeof c=="object"?(d=c,c=null):i&&typeof i=="object"?(d=i,i=c=null):d=I;else if(typeof d!="object")throw Error(we+"Argument not an object: "+d);if(b=m.toFixed(i,c),m.c){var A,w=b.split("."),h=+d.groupSize,g=+d.secondaryGroupSize,x=d.groupSeparator||"",C=w[0],P=w[1],R=m.s<0,L=R?C.slice(1):C,Z=L.length;if(g&&(A=h,h=g,g=A,Z-=A),h>0&&Z>0){for(A=Z%h||h,C=L.substr(0,A);A<Z;A+=h)C+=x+L.substr(A,h);g>0&&(C+=x+L.slice(A)),R&&(C="-"+C)}b=P?C+(d.decimalSeparator||"")+((g=+d.fractionGroupSize)?P.replace(new RegExp("\\d{"+g+"}\\B","g"),"$&"+(d.fractionGroupSeparator||"")):P):C}return(d.prefix||"")+b+(d.suffix||"")},s.toFraction=function(i){var c,d,b,m,A,w,h,g,x,C,P,R,L=this,Z=L.c;if(i!=null&&(h=new F(i),!h.isInteger()&&(h.c||h.s!==1)||h.lt(a)))throw Error(we+"Argument "+(h.isInteger()?"out of range: ":"not an integer: ")+oe(h));if(!Z)return new F(L);for(c=new F(a),x=d=new F(a),b=g=new F(a),R=Ie(Z),A=c.e=R.length-L.e-1,c.c[0]=qn[(w=A%W)<0?W+w:w],i=!i||h.comparedTo(c)>0?A>0?c:x:h,w=y,y=1/0,h=new F(R),g.c[0]=0;C=t(h,c,0,1),m=d.plus(C.times(b)),m.comparedTo(i)!=1;)d=b,b=m,x=g.plus(C.times(m=x)),g=m,c=h.minus(C.times(m=c)),h=m;return m=t(i.minus(d),b,0,1),g=g.plus(m.times(x)),d=d.plus(m.times(b)),g.s=x.s=L.s,A=A*2,P=t(x,b,A,u).minus(L).abs().comparedTo(t(g,d,A,u).minus(L).abs())<1?[x,b]:[g,d],y=w,P},s.toNumber=function(){return+oe(this)},s.toPrecision=function(i,c){return i!=null&&re(i,1,fe),K(this,i,c,2)},s.toString=function(i){var c,d=this,b=d.s,m=d.e;return m===null?b?(c="Infinity",b<0&&(c="-"+c)):c="NaN":(i==null?c=m<=f||m>=p?yn(Ie(d.c),m):je(Ie(d.c),m,"0"):i===10&&_?(d=G(new F(d),o+m+1,u),c=je(Ie(d.c),d.e,"0")):(re(i,2,k.length,"Base"),c=n(je(Ie(d.c),m,"0"),10,i,b,!0)),b<0&&d.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&&F.set(e),F}function Be(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 yt(e,t){var n,r,s=e.c,a=t.c,o=e.s,u=t.s,f=e.e,p=t.e;if(!o||!u)return null;if(n=s&&!s[0],r=a&&!a[0],n||r)return n?r?0:-u:o;if(o!=u)return o;if(n=o<0,r=f==p,!s||!a)return r?0:!s^n?1:-1;if(!r)return f>p^n?1:-1;for(u=(f=s.length)<(p=a.length)?f:p,o=0;o<u;o++)if(s[o]!=a[o])return s[o]>a[o]^n?1:-1;return f==p?0:f>p^n?1:-1}function re(e,t,n,r){if(e<t||e>n||e!==Oe(e))throw Error(we+(r||"Argument")+(typeof e=="number"?e<t||e>n?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function mn(e){var t=e.c.length-1;return Be(e.e/W)==t&&e.c[t]%2!=0}function yn(e,t){return(e.length>1?e.charAt(0)+"."+e.slice(1):e)+(t<0?"e":"e+")+t}function je(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=_r();function Aa(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 ga={1:{adapter:{Nordstern:"0x6603629C8d4b683fdc51c7F810D1799cfEAcEAe3",Sushi:"0x11985E88847aEC23D1C3BCD77Ca0F4A704aB751c",Ring:"0x47e27973dA3e16dB13F8b713877b3A31623E0E5B",Kyber:"0x6bbE14b2205a87FA0EAdE5f0795C7bb16B5347EA",Magpie:"0x8622CBd71D8Aba76Ce1C2235510f2b2C6335C31E",OpenOcean:"0x2Be5260d030ff9A6040bA4292326B796ff1a055d",Paraswap:"0x777A3e65a5473148D5d7abdFD2BB5bFB61b6432f"},dex:{sushiswap:{type:"default",solver:"Sushi",router:"0xAC4c6e212A361c968F1725b4d055b47E63F80b75",adapter:"0x2e43A28FAf083717CcD9B246d97C61E1Bc9914Df",fee:"0x28F6C9dBE21fFc146Af8d5D15c49Cf48F61140Dc"},ring:{type:"dynamicp2",solver:"Ring",permit2:"0x000000000022D473030F116dDEE9F6B43aC78BA3",adapter:"0x028fa69049aB68EC42064Eb18896D587dD41Af2a",fee:"0xA04329696aAd1417c75Cf6d91342815001999B21"}}},10:{adapter:{Nordstern:"0x1D06d98D523F8B51AD693D4A22fb97fCf0838d83",Sushi:"0x11985E88847aEC23D1C3BCD77Ca0F4A704aB751c",Kyber:"0x6bbE14b2205a87FA0EAdE5f0795C7bb16B5347EA",Magpie:"0x8622CBd71D8Aba76Ce1C2235510f2b2C6335C31E",OpenOcean:"0x2Be5260d030ff9A6040bA4292326B796ff1a055d",Paraswap:"0x777A3e65a5473148D5d7abdFD2BB5bFB61b6432f"},dex:{}},14:{adapter:{Nordstern:"0xd16A1849E86431872a87f476fa0DfB30eEb96cb3",SparkDex:"0x00c7617C471Ef69124464CEc318a3b8CC90aE9A7",OpenOcean:"0x2Be5260d030ff9A6040bA4292326B796ff1a055d"},dex:{spark:{type:"default",solver:"SparkDex",router:"0x0f3D8a38D4c74afBebc2c42695642f0e3acb15D3",adapter:"0x00c7617C471Ef69124464CEc318a3b8CC90aE9A7",fee:"0xaeA8C3e1a129A77686E115b1a46D9aD8405F7D2b"}}},56:{adapter:{Nordstern:"0x20253Cd6EEEB89e61ce7DDCf74a25Baba6A05BDF",Orbs:"0xaf3532dca7b4a75cD06671614C093e9e8fb5b1F2",Ring:"0x47e27973dA3e16dB13F8b713877b3A31623E0E5B",Topaz:"0x2Be5260d030ff9A6040bA4292326B796ff1a055d",Kyber:"0x6bbE14b2205a87FA0EAdE5f0795C7bb16B5347EA",Magpie:"0xBB5f16d51cF0eEfcC894268a72a9cF42d9a6F4f0",OpenOcean:"0x2Be5260d030ff9A6040bA4292326B796ff1a055d",Paraswap:"0x777A3e65a5473148D5d7abdFD2BB5bFB61b6432f",Sushi:"0xA985f801ea74321AdcC9Ef88B394858CbA3F71ba"},dex:{thena:{type:"universal",adapter:"0xEC85273E085eD7f7b9879c4A67a3E5D9f3AD242A",fee:"0x15eBc8b5b3877512FFF23650188694A9a8891FAc"},pancake:{type:"p2",solver:"Orbs",router:"0xd9C500DfF816a1Da21A48A732d3498Bf09dc9AEB",permit2:"0x31c2F6fcFf4F8759b3Bd5Bf0e1084A055615c768",adapter:"0x52Ed96B1AEd25818B6A284b063b055488E012b73",fee:"0x37A957f10F458e0d7fDECBE2917971b57F15c927"},ring:{type:"dynamicp2",solver:"Ring",permit2:"0x000000000022D473030F116dDEE9F6B43aC78BA3",adapter:"0x028fa69049aB68EC42064Eb18896D587dD41Af2a",fee:"0xA04329696aAd1417c75Cf6d91342815001999B21"},topaz:{type:"default",solver:"Topaz",router:"0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",adapter:"0x671c59dCbc8ee3a08D15e1D03a88032740869919",fee:"0xDbB17E23d12cd3C0AA856528F7177a68f98fFd5B"}}},130:{adapter:{Nordstern:"0x763Fb927d181bCE8be779794A030BCE45D4869fA",Ring:"0x47e27973dA3e16dB13F8b713877b3A31623E0E5B",Kyber:"0x6bbE14b2205a87FA0EAdE5f0795C7bb16B5347EA",Magpie:"0x6795A03Af6E1332BD931C0891D5C6AFF85550b54",OpenOcean:"0x2Be5260d030ff9A6040bA4292326B796ff1a055d",Paraswap:"0x777A3e65a5473148D5d7abdFD2BB5bFB61b6432f"},dex:{ring:{type:"dynamicp2",solver:"Ring",permit2:"0x000000000022D473030F116dDEE9F6B43aC78BA3",adapter:"0x028fa69049aB68EC42064Eb18896D587dD41Af2a",fee:"0xA04329696aAd1417c75Cf6d91342815001999B21"}}},137:{adapter:{Nordstern:"0xf065b4bFa073b5A0A3eb254D67cbc5118D8B0Ea7",Paraswap:"0x179C4b8e982b5F1365d36CC8d0c1CEB621B7198D",Kyber:"0x6bbE14b2205a87FA0EAdE5f0795C7bb16B5347EA",Magpie:"0x8622CBd71D8Aba76Ce1C2235510f2b2C6335C31E",OpenOcean:"0x2Be5260d030ff9A6040bA4292326B796ff1a055d",Sushi:"0xA985f801ea74321AdcC9Ef88B394858CbA3F71ba"},dex:{quick:{type:"paraswap",solver:"Paraswap",router:"0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57",adapter:"0x727e1CbA41Ff1ff11C32fa43DAb499b4317A1b65",fee:"0xd207DC6a6dA88f27c8DB78201F974161b1d84b1f"},teafi:{type:"paraswap",solver:"Paraswap",router:"0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57",adapter:"0xF710D67C783D2C14671EC1c61B0683DCb996F5c3",fee:"0x04Ff96e2c4D62b5771795d307AD679a25b3D2D50"}}},143:{adapter:{Nordstern:"0xd16A1849E86431872a87f476fa0DfB30eEb96cb3",OpenOcean:"0xc7f07C830e22FCA94bF52F38C6707F9D396c6172",Kyber:"0x6f4e5b8d7F6b037c62277992c39E7834D7C04596",Magpie:"0x6795A03Af6E1332BD931C0891D5C6AFF85550b54",Sushi:"0xA985f801ea74321AdcC9Ef88B394858CbA3F71ba"},dex:{yowie:{type:"default",solver:"OpenOcean",router:"0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",adapter:"0xCA84Ab5a5A5bf2cff6AC0C835eF049365D13c6cB",fee:"0x6AF3eE77A3A3257777F5649aFa611b4C7Fd975Ef"},pangolin:{type:"default",solver:"Kyber",router:"0x6131B5fae19EA4f9D964eAc0408E4408b66337b5",adapter:"0xf42106eBf985bF49b39eba0114F57FA05e7B52eD",fee:"0xde92da99D188Ceb54A11ec711EF52D808A6260B5"}}},146:{adapter:{Nordstern:"0xEAEEdF2b8818970356212d5C2f449E2BE68D6800",OpenOcean:"0xc7f07C830e22FCA94bF52F38C6707F9D396c6172",Magpie:"0x217E9311396C8722b9eC98aFf865F067fe5E59c1",Kyber:"0x6bbE14b2205a87FA0EAdE5f0795C7bb16B5347EA",Sushi:"0xA985f801ea74321AdcC9Ef88B394858CbA3F71ba",Paraswap:"0x777A3e65a5473148D5d7abdFD2BB5bFB61b6432f"},dex:{spooky:{type:"default",solver:"Magpie",router:"0x20f6ee51340adeed01a59b0e65cb3703f3dc860c",adapter:"0x0F6533Fd45D13ad6AAa364023d6c05eCB2d3Ac2E",fee:"0x840Df4684B35BC68BcdA3F6707A3c82A0D662f8b"},swapx:{type:"default",solver:"OpenOcean",router:"0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",adapter:"0xa7AE3ABf86C81cCEFEd6bE77045F2a32660c1B1c",fee:"0x6E03f7BC0f141894612AA017796096399623895F"},shadow:{type:"default",solver:"Magpie",router:"0x20f6ee51340adeed01a59b0e65cb3703f3dc860c",adapter:"0x39b024E187e5f35fea05953fECB9314a97de3d94",fee:"0xb9e3751fAF3187E1bC468E56a707a8A91754460e"}}},196:{adapter:{Ring:"0x47e27973dA3e16dB13F8b713877b3A31623E0E5B",Sushi:"0xA985f801ea74321AdcC9Ef88B394858CbA3F71ba"},dex:{ring:{type:"dynamicp2",solver:"Ring",permit2:"0x000000000022D473030F116dDEE9F6B43aC78BA3",adapter:"0x028fa69049aB68EC42064Eb18896D587dD41Af2a",fee:"0xA04329696aAd1417c75Cf6d91342815001999B21"}}},999:{adapter:{Nordstern:"0xA9c6c1F14c1d0eF2ab6ec79E5dcF0ff3a3680F05",Ring:"0x47e27973dA3e16dB13F8b713877b3A31623E0E5B",Kyber:"0x6bbE14b2205a87FA0EAdE5f0795C7bb16B5347EA",OpenOcean:"0x2Be5260d030ff9A6040bA4292326B796ff1a055d",Magpie:"0x6795A03Af6E1332BD931C0891D5C6AFF85550b54",Sushi:"0xA985f801ea74321AdcC9Ef88B394858CbA3F71ba"},dex:{ring:{type:"dynamicp2",solver:"Ring",permit2:"0x000000000022D473030F116dDEE9F6B43aC78BA3",adapter:"0x028fa69049aB68EC42064Eb18896D587dD41Af2a",fee:"0xA04329696aAd1417c75Cf6d91342815001999B21"}}},1329:{adapter:{Nordstern:"0xd16A1849E86431872a87f476fa0DfB30eEb96cb3",DragonSwap:"0x1e84A9f30607959d2d8b1a04171ef7D9522Ef502",OpenOcean:"0xc7f07C830e22FCA94bF52F38C6707F9D396c6172"},dex:{dragon:{type:"default",solver:"DragonSwap",router:"0x11DA6463D6Cb5a03411Dbf5ab6f6bc3997Ac7428",adapter:"0x1e84A9f30607959d2d8b1a04171ef7D9522Ef502",fee:"0x0dc1E0525202b32e89bA78ed55b1e5cEdB751334"},nami:{type:"default",solver:"OpenOcean",router:"0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",adapter:"0xba56F9A7865d430c8293851D576b5728Ca711ff5",fee:"0xeB58450e23632003f013568703F54446070E2E80"}}},4326:{adapter:{Ring:"0x47e27973dA3e16dB13F8b713877b3A31623E0E5B",Kyber:"0x6bbE14b2205a87FA0EAdE5f0795C7bb16B5347EA",Magpie:"0x6795A03Af6E1332BD931C0891D5C6AFF85550b54",Sushi:"0xA985f801ea74321AdcC9Ef88B394858CbA3F71ba"},dex:{ring:{type:"dynamicp2",solver:"Ring",permit2:"0x000000000022D473030F116dDEE9F6B43aC78BA3",adapter:"0x028fa69049aB68EC42064Eb18896D587dD41Af2a",fee:"0xA04329696aAd1417c75Cf6d91342815001999B21"}}},8453:{adapter:{Nordstern:"0xd16A1849E86431872a87f476fa0DfB30eEb96cb3",Orbs:"0x917b492557957f5dD3e69c04c8E1Ac3d6948c022",Kyber:"0x6f4e5b8d7F6b037c62277992c39E7834D7C04596",TrebleSwap:"0x6f4938535879c668A797F2a6e9B912c54f9D43Cf",Sushi:"0x11985E88847aEC23D1C3BCD77Ca0F4A704aB751c",Ring:"0x47e27973dA3e16dB13F8b713877b3A31623E0E5B",Magpie:"0x448Ab278aE53a518b181C01AEaFD397f049060E7",OpenOcean:"0x2Be5260d030ff9A6040bA4292326B796ff1a055d",Paraswap:"0x777A3e65a5473148D5d7abdFD2BB5bFB61b6432f"},dex:{pancake:{type:"p2",solver:"Orbs",router:"0xFE6508f0015C778Bdcc1fB5465bA5ebE224C9912",permit2:"0x31c2F6fcFf4F8759b3Bd5Bf0e1084A055615c768",adapter:"0xA7CcB11F1D20D1F915FC220F5Cb1646E4523bB75",fee:"0x37A957f10F458e0d7fDECBE2917971b57F15c927"},quick:{type:"default",solver:"Kyber",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"},ring:{type:"dynamicp2",solver:"Ring",permit2:"0x000000000022D473030F116dDEE9F6B43aC78BA3",adapter:"0x028fa69049aB68EC42064Eb18896D587dD41Af2a",fee:"0xA04329696aAd1417c75Cf6d91342815001999B21"}}},42161:{adapter:{Nordstern:"0x52756370A08F63ADE4900A9c3046cf93ac0397e5",Paraswap:"0x179C4b8e982b5F1365d36CC8d0c1CEB621B7198D",Orbs:"0x917b492557957f5dD3e69c04c8E1Ac3d6948c022",Sushi:"0x11985E88847aEC23D1C3BCD77Ca0F4A704aB751c",Ring:"0x47e27973dA3e16dB13F8b713877b3A31623E0E5B",Kyber:"0x6bbE14b2205a87FA0EAdE5f0795C7bb16B5347EA",Magpie:"0xB844Fa943230A0ff3b7a0E9483dF2689D513d77d",OpenOcean:"0x2Be5260d030ff9A6040bA4292326B796ff1a055d"},dex:{ramses:{type:"paraswap",solver:"Paraswap",router:"0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57",adapter:"0xf075352f43cd15bA51B0957A4465223EDf6b4Cd8",fee:"0xB5BaCB60ECDa0bEF809B2A26eC9B4B926835D7af"},omni:{type:"paraswap",solver:"Paraswap",router:"0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57",adapter:"0x41c925E8E4fC65136BDf5322824E0D8c20c4824e",fee:"0xba5291526c30B097E9F1Fd1Be301E2ab6E0782aa"},pancake:{type:"p2",solver:"Orbs",router:"0xFE6508f0015C778Bdcc1fB5465bA5ebE224C9912",permit2:"0x31c2F6fcFf4F8759b3Bd5Bf0e1084A055615c768",adapter:"0xA7CcB11F1D20D1F915FC220F5Cb1646E4523bB75",fee:"0x37A957f10F458e0d7fDECBE2917971b57F15c927"},sushiswap:{type:"default",solver:"Sushi",router:"0xAC4c6e212A361c968F1725b4d055b47E63F80b75",adapter:"0x2e43A28FAf083717CcD9B246d97C61E1Bc9914Df",fee:"0x28F6C9dBE21fFc146Af8d5D15c49Cf48F61140Dc"},ring:{type:"dynamicp2",solver:"Ring",permit2:"0x000000000022D473030F116dDEE9F6B43aC78BA3",adapter:"0x028fa69049aB68EC42064Eb18896D587dD41Af2a",fee:"0xA04329696aAd1417c75Cf6d91342815001999B21"}}},43114:{adapter:{Nordstern:"0x1D06d98D523F8B51AD693D4A22fb97fCf0838d83",Kyber:"0x6f4e5b8d7F6b037c62277992c39E7834D7C04596",Magpie:"0x0Fd65Dc22A3c3aa1501a6Bb509F66ff5C4585a5d",OpenOcean:"0x2Be5260d030ff9A6040bA4292326B796ff1a055d",Paraswap:"0x777A3e65a5473148D5d7abdFD2BB5bFB61b6432f",Sushi:"0xA985f801ea74321AdcC9Ef88B394858CbA3F71ba"},dex:{blackhole:{type:"default",solver:"Kyber",router:"0x6131B5fae19EA4f9D964eAc0408E4408b66337b5",adapter:"0xccdF1D6ce95FeC0F842197470CE8969A678B0A04",fee:"0x7f8B62520D9B5DA0ED517cc36e8dcb2a356f1928"},pangolin:{type:"default",solver:"Kyber",router:"0x6131B5fae19EA4f9D964eAc0408E4408b66337b5",adapter:"0xf42106eBf985bF49b39eba0114F57FA05e7B52eD",fee:"0xde92da99D188Ceb54A11ec711EF52D808A6260B5"}}},59144:{adapter:{Nordstern:"0xA9c6c1F14c1d0eF2ab6ec79E5dcF0ff3a3680F05",Orbs:"0x917b492557957f5dD3e69c04c8E1Ac3d6948c022",OpenOcean:"0xd2e68b1d1C5DBB2D6cC396c10C55017e01309C37",Kyber:"0x6bbE14b2205a87FA0EAdE5f0795C7bb16B5347EA",Sushi:"0xA985f801ea74321AdcC9Ef88B394858CbA3F71ba",Magpie:"0xBcFd0eE2C44136526dcA007e41e4f3DDD32A0Bd2"},dex:{pancake:{type:"p2",solver:"Orbs",router:"0xFE6508f0015C778Bdcc1fB5465bA5ebE224C9912",permit2:"0x31c2F6fcFf4F8759b3Bd5Bf0e1084A055615c768",adapter:"0xA7CcB11F1D20D1F915FC220F5Cb1646E4523bB75",fee:"0x37A957f10F458e0d7fDECBE2917971b57F15c927"},lynex:{type:"default",solver:"OpenOcean",router:"0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",adapter:"0xd8bC1FF79a642e8D7Fbd0711374F287202fBb3AA",fee:"0xcb36ed1B1BfAD8F7FC9651f52d21f04A68677423"}}},80094:{adapter:{Nordstern:"0x763Fb927d181bCE8be779794A030BCE45D4869fA",Kodiak:"0xcB16237c88A859d46Ae850B97d7D1bdECF482C06",Kyber:"0x6bbE14b2205a87FA0EAdE5f0795C7bb16B5347EA",OpenOcean:"0x2Be5260d030ff9A6040bA4292326B796ff1a055d",Magpie:"0xBcFd0eE2C44136526dcA007e41e4f3DDD32A0Bd2",Sushi:"0xA985f801ea74321AdcC9Ef88B394858CbA3F71ba"},dex:{kodiak:{type:"default",solver:"Kodiak",router:"0x43Dac637c4383f91B4368041E7A8687da3806Cae",adapter:"0xcB16237c88A859d46Ae850B97d7D1bdECF482C06",fee:"0xBA47Ec15aFbCF6e7e9F52900632049530bB6bAe4"}}},747474:{adapter:{Nordstern:"0xd16A1849E86431872a87f476fa0DfB30eEb96cb3",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",utilaAdapter:"0x7671291910b559d7a05ab73ee31dd714d9c6e7b065c9496338bf427182ae5145",utilaFee:"0x46f797cddb221ecf6279b56f52e2f6360cd721ef95bd5a17dd0ffceffaaf7fd6",efAdapter:"0xa5425e0f84a7cf12c4213f57396810d808d88e43a65210786bd0d9a98a314728",efFee:"0x14387b821c54f18e2a9351887a92cc79164a5ea0b88cfc3f36741eae6d4fd815",htAdapter:"0x2ec50a8a136049da76c16f3dd12a8ed1b23f2bc91aca73c6a20cc8344e34f998",htFee:"0x2f902a86a7f6abeedc073e76cd33d4737f25189e18c8f450f16d2ffe14405242"},dex:{agent:{type:"universal",adapter:"0x0002BeFB46587d460AcEA9B2792c4A4c67B9cADa",fee:"0x0006d9557Ac9Af4f31962896299ba4FaBDaB9fEE"},utila:{type:"universal",adapter:"0x000ADa14B2ECF45Da6Cf1B33dE34e05231E9C76f",fee:"0x000FEee351263c82501a4dF5f699a8b630ac7f36"},ef:{type:"universal",adapter:"0xeF1B796D708BD776F6b377E93eAd8Ca5fA0C3117",fee:"0xeF1D677d7aE1a066beb26cC1C74E31C082B75FEf"},ht:{type:"universal",adapter:"0xA560a960C3b7784f5c335C33028D31596b91650b",fee:"0xE7a926C0cb01aCCE74e5d4FCeB7CA1699e200608"}}}};var Kn,Ur;function ba(){if(Ur)return Kn;Ur=1;const e=ga,t=a=>Aa(`./out/${a}.sol/${a}.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(a){var u;if(!a)return;const o=e[a];if(o)return{...((u=e["*"])==null?void 0:u.adapter)??{},...o.adapter??{}}}function s(a,o){if(!a)return;const{dex:u,salt:f,...p}=e["*"]??{},T=e[a];if(!T)return;const{dex:y,salt:E,...v}=T,O={...p,...v},I=o==null?void 0:o.trim();if(!I)return O;const k=u==null?void 0:u[I],_=y==null?void 0:y[I];if(!(!k&&!_))return{...O,...k,..._}}return Kn={config:s,adapters:r,abis:n,raw:e},Kn}var Rr=ba();const Ut=(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 At(e,t){return e==t||e.toLowerCase()==t.toLowerCase()}const Rt=e=>!!ra.find(t=>At(t,e||""));function Ea(e){return[ve.Years,ve.Months,ve.Weeks,ve.Days,ve.Hours,ve.Minutes].find(n=>n<=e)||ve.Minutes}const gt=e=>e?e.value*e.unit:0,Ca=e=>!e||e==="NaN"?"0":S(e).decimalPlaces(0).toFixed(),bt=e=>Object.values(ye).find(t=>t.id===e),xa=e=>{if(!e)return;const t=e.map(a=>ge(a)),n=Object.entries(sa).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)},Hn=(e,t)=>e.version===1?(e.fillDelay||0)*1e3+Ba(t):(e.fillDelay||0)*1e3,An=e=>typeof window>"u"?null:new URLSearchParams(window.location.search).get(e),Lr=e=>Hr().filter(t=>t.name===e).map(t=>t.chainId),Wn=(e="",t="",n=18,r=18)=>{if(!S(e||0).gt(0)||!S(t||0).gt(0))return"";const s=Ut(n,e),a=Ut(r,t);return S(a).div(s).toFixed()},Nr=(e,t,n)=>{if(e.type===X.TWAP_MARKET)return"";const r=Ut(t,e.srcAmountPerTrade),s=Ut(n,e.dstMinAmountPerTrade);return S(s).div(r).toFixed()},qr=(e,t,n)=>{if(e.type===X.TWAP_MARKET)return"";const r=Ut(t,e.srcAmountPerTrade),s=Ut(n,e.triggerPricePerTrade);return S(s).div(r).toFixed()},Ta=new Set([1,56,42161,8453]),Kr=(e,t)=>e===Pe.Ring?Ta.has(t):!0,wa=(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)},Fa=(e,t,n,r)=>{if(n||!r||!e||!t)return S(0).toString();const s=S(e).times(S(t)),a=S(10).pow(r),o=s.div(a);return S.max(1,o).integerValue(S.ROUND_FLOOR).toFixed(0)},Sa=(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)),a=S(10).pow(r),o=s.div(a);return S.max(1,o).integerValue(S.ROUND_FLOOR).toFixed(0)||"0"},Da=(e,t,n,r)=>{const s=gt(n)*2*t,a=An(Jt.DURATION),o=Ea(a?Number(a):s);return a?{unit:o,value:Number(S(Number(a)/o).toFixed(2))}:r||(e===j.LIMIT?{unit:ve.Days,value:7}:e===j.STOP_LOSS||e===j.TAKE_PROFIT?{unit:ve.Days,value:1}:{unit:o,value:Number(S(s/o).toFixed(2))})},va=(e,t,n)=>t!==j.TWAP?1:n!==void 0?n:Math.max(1,Math.ceil(e/2)),Pa=(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)},Oa=(e,t)=>e+gt(t)+6e4,Ba=e=>e.bidDelaySeconds*1e3*2,Ia=(e="",t=0)=>!e||!t?"0":S(e).div(t).integerValue(S.ROUND_FLOOR).toFixed(0),Ma=(e,t)=>({isError:!(e.unit===Rn.unit&&e.value===Rn.value)&>(e)*t>hn,value:Math.floor(hn/t)}),ka=(e="",t="",n)=>{if(n===j.STOP_LOSS)return{isError:S(t||0).gte(S(e||0)),value:e}},_a=(e="",t="",n)=>{if(n===j.TAKE_PROFIT)return{isError:S(t||0).lte(S(e||0)),value:e}},Ua=(e="",t="",n=!1,r)=>{if(!n&&r===j.STOP_LOSS)return{isError:S(t||0).gte(S(e||0)),value:e}},Ra=(e="",t="",n=!1,r)=>{if(!n&&r===j.TAKE_PROFIT)return{isError:S(t||0).gte(S(e||0)),value:e}},La=(e,t)=>e===j.STOP_LOSS||e===j.TAKE_PROFIT?{isError:gt(t)>5184e6,value:5184e6}:{isError:gt(t)>hn,value:hn},Na=e=>({isError:gt(e)<Ir,value:Ir}),qa=e=>({isError:gt(e)<_n,value:_n}),Ka=(e,t,n)=>({isError:S(t||0).multipliedBy(e||0).isLessThan(n),value:n}),Ha=(e,t,n)=>({isError:n===j.TWAP&&S(e).isGreaterThan(t),value:t}),Wa=(e,t)=>{if(e===Pe.Pancake)switch(t){case 56:return $.PancakeSwap;case 42161:return $.PancakeSwapArbitrum;case 8453:return $.PancakeSwapBase;case 59144:return $.PancakeSwapLinea;default:return $.PancakeSwap}if(e===Pe.Sushiswap)switch(t){case 1:return $.SushiEth;case 42161:return $.SushiArb;case 8453:return $.SushiBase;case 747474:return $.SushiKatana;default:return $.SushiEth}if(e===Pe.Quick)switch(t){case 137:return $.QuickSwap;case 8453:return $.QuickSwapBase;default:return $.QuickSwap}if(e===Pe.Thena)switch(t){case 56:return $.Thena;default:return $.Thena}if(e===Pe.Spooky)switch(t){case 250:return $.SpookySwap;case 146:return $.SpookySwapSonic;default:return $.SpookySwap}if(e===Pe.Lynex)switch(t){case 59144:return $.Lynex;default:return $.Lynex}if(e===Pe.Swapx)switch(t){case 146:return $.SwapX;default:return $.SwapX}if(e===Pe.Blackhole)switch(t){case 43114:return $.BlackholeAvax;default:return $.BlackholeAvax}},zn=(e,t=0)=>{if(!Kr(e,t))throw new Error(`Partner "${e}" is not supported on chain ${t}`);const{abi:n,...r}=Rr.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:Wa(e,t)}},Hr=()=>{var n;const e=Rr.raw,t=((n=e["*"])==null?void 0:n.dex)??{};return Object.entries(e).filter(([r])=>r!=="*").flatMap(([r,s])=>{const a=Number(r),o={...t,...(s==null?void 0:s.dex)??{}};return!o||typeof o!="object"?[]:Object.entries(o).flatMap(([u])=>{const f=u;return Kr(f,a)?[{chainId:a,name:u,config:zn(f,a)}]:[]})}).sort((r,s)=>r.name.localeCompare(s.name))},Wr=e=>{const t=An(Jt.MIN_CHUNK_SIZE_USD);return t?parseInt(t):e},za=({marketPrice:e,typedInputAmount:t,srcUsd1Token:n,marketPriceLoading:r,triggerPriceError:s,limitPriceError:a,tradesError:o,fillDelayError:u,durationError:f,balanceError:p,minTradeSizeError:T})=>{if(!An(Jt.IGNORE_ERRORS)&&!(S(e||0).isZero()||S(t||0).isZero()||S(n||"0").isZero()||r))return T||s||a||o||u||f||p},Qa=(e,t)=>{const n=Date.now().toString(),r=parseInt((e/1e3).toFixed(0)),s=Ca(t/1e3),a=An(Jt.FRESHNESS),o=a?parseInt(a):60;return{nonce:n,epoch:r,deadline:s,freshness:o}},zr=({chainId:e,srcToken:t,dstToken:n,srcAmount:r,deadlineMillis:s,fillDelayMillis:a,slippage:o,account:u,srcAmountPerTrade:f,dstMinAmountPerTrade:p="0",triggerAmountPerTrade:T="0",config:y,module:E})=>{const{nonce:v,epoch:O,deadline:I,freshness:k}=Qa(a,s),_=Math.floor(Date.now()/1e3).toString(),F=p,K=E===j.STOP_LOSS?T:"0",U=E===j.TAKE_PROFIT?T:"0",V={permitted:{token:t,amount:r},spender:y.reactor,nonce:v,deadline:I,witness:{reactor:y.reactor,executor:y.executor,exchange:{adapter:y.adapter,ref:y.fee,share:0,data:"0x"},swapper:u,nonce:v,start:_,deadline:I,chainid:e,exclusivity:0,epoch:O,slippage:o,freshness:k,input:{token:t,amount:f,maxAmount:r},output:{token:n,limit:S(F||0).toFixed(),triggerLower:S(K||0).toFixed(),triggerUpper:S(U||0).toFixed(),recipient:u}}};return{domain:{name:"RePermit",version:"1",chainId:e,verifyingContract:y.repermit},order:V,types:ia,primaryType:aa}},$a=`https://bi.orbs.network/putes/twap-ui-${.7}`;let Qn="unknown";function ja(e){Qn=e}function $n(){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 Va=(e,t,n)=>{var r,s,a,o,u,f,p,T,y;return{spotVersion:kn.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:((u=e.twapConfig)==null?void 0:u.bidDelaySeconds)||0,minChunkSizeUsd:t,name:((f=e.twapConfig)==null?void 0:f.name)||"",exchangeAddress:((p=e.twapConfig)==null?void 0:p.exchangeAddress)||"",exchangeType:((T=e.twapConfig)==null?void 0:T.exchangeType)||"",pathfinderKey:((y=e.twapConfig)==null?void 0:y.pathfinderKey)||""}},Qr=async e=>{try{await fetch($a,{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 Ga{constructor(){Bn(this,"timeout");Bn(this,"config");Bn(this,"data",{_id:$n()})}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:a,fromTokenAmount:o,srcChunkAmount:u,minDstAmountOutPerTrade:f="",triggerPricePerTrade:p="",deadline:T,fillDelay:y,slippage:E,isMarketOrder:v,chunksAmount:O}){this.updateAndSend({toTokenAddress:a.address,toTokenSymbol:a.symbol,fromTokenAddress:s.address,fromTokenSymbol:s.symbol,fromTokenAmount:o,chunksAmount:O,srcChunkAmount:u,minDstAmountOutPerTrade:f,triggerPricePerTrade:p,deadline:T,fillDelay:y,slippage:E,chainId:n,walletAddress:t,module:r,orderType:v?"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,s){var a,o;this.config=t,(r!==((a=this.data)==null?void 0:a.chainId)||s!==((o=this.data)==null?void 0:o.appId))&&(this.data={_id:$n(),action:"module-import",uiVersion:Qn,appId:s,...Va(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:$n(),action:"reset",uiVersion:Qn,appId:this.data.appId,origin:this.data.origin,spotVersion:kn.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 Ga,Xa=e=>{var p;const t=S(e.order.witness.output.limit||0).gt(1),{stop:n,triggerLower:r,triggerUpper:s}=e.order.witness.output,a=S(n||0).eq(Mr),o=a||S(s||0).gt(0),u=!a&&S(n||0).gt(0)||S(r||0).gt(0),f=((p=e.metadata.chunks)==null?void 0:p.length)||S(e.order.witness.input.maxAmount).div(S(e.order.witness.input.amount)).toNumber();return o?t?X.TAKE_PROFIT_LIMIT:X.TAKE_PROFIT_MARKET:u?t?X.STOP_LOSS_LIMIT:X.STOP_LOSS_MARKET:t?f>1&&t?X.TWAP_LIMIT:t?X.LIMIT:X.TWAP_MARKET:X.TWAP_MARKET},Za=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=S(t).dividedBy(n).toNumber();return r>=.99?100:r<=0?0:Number((r*100).toFixed(2))},Ya=(e,t)=>e.metadata.status==="completed"||t>=99?ue.Completed:["pending","eligible"].includes(e.metadata.status)?ue.Open:e.metadata.description.toLowerCase()==="cancelled by contract"?ue.Cancelled:ue.Expired,Ja=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}))},ei=(e,t)=>{var r;const n=e.length;return n>=t&&((r=e[n-1])==null?void 0:r.timestamp)||0},ti=e=>S(e.metadata.displayOnlyInputTokenPriceUSD).dividedBy(1e18).toFixed(),jn=e=>Number(e.order.witness.output.limit)===1?"":e.order.witness.output.limit,ni=e=>{const{triggerLower:t="0",triggerUpper:n="0"}=e.order.witness.output,r=jn(e),s=e.metadata.expectedChunks||1,a=S(n||0).gt(0);return{dstMinAmountPerTrade:r,triggerPricePerTrade:a?n:t,dstMinAmountTotal:S(r).multipliedBy(s).toFixed()}},ri=e=>{const t=jn(e),n=S(e.order.witness.output.stop||0).eq(Mr),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()}},si=e=>Number(pn)>=2?ni(e):ri(e),$r=e=>{const t=Za(e),n=jn(e),r=e.metadata.expectedChunks||1,s=Ja(e),a=Xa(e);return{id:e.hash,hash:e.hash,version:2,type:a,maker:e.order.witness.swapper,progress:t,srcAmountFilled:s.reduce((o,u)=>o.plus(u.inAmount),new S(0)).toFixed()||"",dstAmountFilled:s.reduce((o,u)=>o.plus(u.outAmount),new S(0)).toFixed()||"",fills:s,srcTokenAddress:e.order.witness.input.token,dstTokenAddress:e.order.witness.output.token,orderDollarValueIn:ti(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:ei(s,r),status:Ya(e,t),repermitDigest:e.metadata.repermitDigest,isTriggerPrice:a===X.TAKE_PROFIT_MARKET||a===X.TAKE_PROFIT_LIMIT||a===X.STOP_LOSS_LIMIT||a===X.STOP_LOSS_MARKET,rawOrder:e,...si(e)}},ai=async({chainId:e,signal:t,account:n,exchange:r,partner:s,isDev:a=!1})=>{try{if(!n)return[];const o=Ys(a),u=new Map;return(await Promise.all(o.map(async p=>{try{const T=ea({endpoint:p,exchange:r,partner:s}),y=T?`&exchange=${T}`:"",v=await(await fetch(`${p}/orders?swapper=${n}&chainId=${e}${y}`,{signal:t})).json();if(!v||!Array.isArray(v.orders))return[];const O=[];for(const I of v.orders)try{O.push($r(I))}catch{continue}return O}catch{return[]}}))).flat().forEach(p=>{u.has(p.id)||u.set(p.id,p)}),Array.from(u.values())}catch{return[]}},jr=async(e,t,n=!1)=>{try{const r={signature:t,order:e,status:"pending"};pe.onCreateOrderRequest();const s=await fetch(`${Zs(n)}/orders/new`,{method:"POST",body:JSON.stringify(r)}),a=await s.json().catch(()=>({}));if(!s.ok||!(a!=null&&a.success)){const u=(a==null?void 0:a.message)??s.statusText??"Request failed",f=(a==null?void 0:a.code)??s.status;throw new Error(`error:${u}, code:${f}`)}if(!a.signedOrder||typeof a.signedOrder!="object")throw new Error("Invalid API response: missing signedOrder");const o=$r(a.signedOrder);return pe.onCreateOrderSuccess(o.id),o}catch(r){throw pe.onCreateOrderError(r),console.error(r),r}},Ve=(e,t)=>e&&e.length?e.map(t||(n=>`${n}`)):void 0,ii=e=>{if(e)return na[e]},Vn=async({chainId:e,buildQuery:t,extractResults:n,signal:r,retries:s=1,limit:a=1e3,page:o})=>{const u=ii(e);if(!u)throw new fi;const f=async y=>{let E=0;for(;E<=s;)try{const v=await fetch(u,{method:"POST",body:JSON.stringify({query:y}),signal:r,headers:{"Content-Type":"application/json"}});if(!v.ok)throw new Error(`HTTP error: ${v.status}`);const O=await v.json();if(O.errors)throw new Error(O.errors[0].message);return n(O)}catch(v){if(E===s)throw v;await new Promise(O=>setTimeout(O,500*2**E)),E++}return[]};let p=0;const T=[];if(o!==void 0){const y=t(o,a);try{return await f(y)}catch{console.warn(`Page ${o} failed, retrying one final time...`);try{return await f(y)}catch{return[]}}}for(;;){const y=t(p,a);let E;try{E=await f(y)}catch{console.warn(`Page ${p} failed, retrying one final time...`);try{E=await f(y)}catch{return T}}if(T.push(...E),E.length<a)break;p++}return T},Vr=e=>e.map(t=>({inAmount:t.srcAmountIn,outAmount:t.dstAmountOut,timestamp:t.timestamp,txHash:t.transactionHash})),Gr=(e,t)=>{const n=S(e||0).gt(1);return!n&&t===1?X.TWAP_MARKET:t>1&&n?X.TWAP_LIMIT:n?X.LIMIT:X.TWAP_MARKET},oi=(e,t,n,r)=>{var E;const s=Vr(n||[]),a=new S(e.ask_srcAmount||0).div(e.ask_srcBidAmount).integerValue(S.ROUND_FLOOR).toNumber(),u=(n==null?void 0:n.length)===a?(E=n==null?void 0:n[(n==null?void 0:n.length)-1])==null?void 0:E.timestamp:void 0,f=s.reduce((v,O)=>v.plus(O.inAmount),new S(0)).toFixed(),p=s.reduce((v,O)=>v.plus(O.outAmount),new S(0)).toFixed(),T=Xr(e.ask_srcAmount,f),y=Gr(e.ask_dstMinAmount,a);return{repermitDigest:"",version:1,isTriggerPrice:!1,id:e.Contract_id.toString(),hash:"",type:Gr(e.ask_dstMinAmount,a),srcTokenAddress:e.ask_srcToken,dstTokenAddress:e.ask_dstToken,exchangeAddress:e.exchange,twapAddress:e.twapAddress,maker:e.maker,progress:T,dstAmountFilled:p,srcAmountFilled:f,orderDollarValueIn:S(e.dollarValueIn||0).toFixed(6),srcAmount:e.ask_srcAmount,dstMinAmountTotal:S(e.ask_dstMinAmount).multipliedBy(a).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:a,isMarketPrice:[X.TWAP_MARKET].includes(y),chainId:t,filledOrderTimestamp:u||0,status:r,rawOrder:e}},ci=e=>{var y;if(!e)return"";const t=Ve(e.accounts,E=>`"${E.toLowerCase()}"`),n=Ve(xa(e.configs),E=>`"${E.toLowerCase()}"`),r=Ve(e.inTokenSymbols,E=>`"${E.toUpperCase()}"`),s=Ve(e.outTokenSymbols,E=>`"${E.toUpperCase()}"`),a=Ve(e.inTokenAddresses,E=>`"${E.toLowerCase()}"`),o=Ve(e.outTokenAddresses,E=>`"${E.toLowerCase()}"`),u=Ve(e.transactionHashes,E=>`"${E.toLowerCase()}"`),f=Ve(e.orderIds,E=>`"${E}"`),p=n!=null&&n.length?"":Ve((y=e.configs)==null?void 0:y.map(E=>E.twapAddress),E=>`"${E.toLowerCase()}"`),T=e.minDollarValueIn;return[n?`exchange_in: [${n.join(", ")}]`:"",p?`twapAddress_in: [${p.join(", ")}]`:"",t?`maker_in: [${t.join(", ")}]`:"",u?`transactionHash_in: [${u.join(", ")}]`:"",f?`Contract_id_in: [${f.join(", ")}]`:"",T?`dollarValueIn_gte: ${T}`:"",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 ui({chainId:e,signal:t,page:n,limit:r,filters:s}){const a=r||1e3,o=ci(s);return await Vn({chainId:e,signal:t,limit:a,page:n,buildQuery:(f,p)=>`
|
|
2
2
|
{
|
|
3
3
|
orderCreateds(
|
|
4
4
|
${o?`where: { ${o} }`:""},
|
|
5
|
-
first: ${
|
|
6
|
-
skip: ${p
|
|
5
|
+
first: ${p},
|
|
6
|
+
skip: ${f*p},
|
|
7
7
|
orderBy: timestamp,
|
|
8
8
|
orderDirection: desc,
|
|
9
9
|
) {
|
|
@@ -32,11 +32,11 @@
|
|
|
32
32
|
transactionHash
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
|
-
`,extractResults:
|
|
35
|
+
`,extractResults:f=>{var p;return((p=f.data)==null?void 0:p.orderCreateds)||[]}})}const di=async({chainId:e,orders:t,signal:n})=>{if(t.length===0)return[];const r=Gn(t.map(u=>u.Contract_id.toString()));if(!r.length)return[];const a=`where: { twapId_in: [${r.map(u=>`"${u}"`).join(", ")}]}`;return await Vn({chainId:e,signal:n,limit:1e3,buildQuery:(u,f)=>`
|
|
36
36
|
{
|
|
37
37
|
statusNews(
|
|
38
|
-
first: ${
|
|
39
|
-
skip: ${u*
|
|
38
|
+
first: ${f},
|
|
39
|
+
skip: ${u*f},
|
|
40
40
|
${a}
|
|
41
41
|
) {
|
|
42
42
|
twapId
|
|
@@ -44,9 +44,9 @@
|
|
|
44
44
|
status
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
-
`,extractResults:u=>{var
|
|
47
|
+
`,extractResults:u=>{var f;return((f=u.data)==null?void 0:f.statusNews)||[]}})};function Gn(e){return Array.from(new Set(e))}const li=async({chainId:e,orders:t,signal:n})=>{const r=Gn(t.map(y=>y.Contract_id)),s=Gn(t.map(y=>y.twapAddress)).filter(Boolean);if(r.length===0)return[];const a=r.join(", "),o=s.map(y=>`"${y}"`).join(", "),u=s.length?`twapAddress_in: [${o}]`:"",p=`where: { ${[`TWAP_id_in: [${a}]`,u].filter(Boolean).join(", ")} }`;return await Vn({chainId:e,signal:n,limit:1e3,buildQuery:(y,E)=>`
|
|
48
48
|
{
|
|
49
|
-
orderFilleds(first: ${
|
|
49
|
+
orderFilleds(first: ${E}, orderBy: timestamp, skip: ${y*E}, ${p}) {
|
|
50
50
|
id
|
|
51
51
|
dstAmountOut
|
|
52
52
|
dstFee
|
|
@@ -61,4 +61,4 @@
|
|
|
61
61
|
dollarValueOut
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
|
-
`,extractResults:y=>{var b;return(((b=y.data)==null?void 0:b.orderFilleds)||[]).map(D=>({...D,timestamp:new Date(D.timestamp).getTime()}))}})};class pi extends Error{constructor(){super("No graph endpoint found"),this.name="NoGraphEndpointError"}}const fi=async({chainId:e,signal:t,page:n,limit:r,filters:s})=>{try{const a=await ui({chainId:e,signal:t,page:n,limit:r,filters:s}),[o,u]=await Promise.all([li({chainId:e,orders:a,signal:t}),di({chainId:e,orders:a,signal:t})]),p=a.map(w=>{const y=o==null?void 0:o.filter(b=>b.TWAP_id===Number(w.Contract_id)&>(b.exchange,w.exchange)&>(b.twapAddress,w.twapAddress));return oi(w,e,y,hi(w,y||[],u))}).sort((w,y)=>y.createdAt-w.createdAt),f=new Set;return p.filter(w=>f.has(w.id)?!1:(f.add(w.id),!0))}catch{return[]}},hi=(e,t,n)=>{var u;const r=(u=n==null?void 0:n.find(p=>p.twapId===e.Contract_id.toString()&>(p.twapAddress,e.twapAddress)))==null?void 0:u.status,a=Vr(t).reduce((p,f)=>p.plus(f.inAmount),new v(0)).toFixed(),o=Xr(e.ask_srcAmount,a);return mi(o,e.ask_deadline*1e3,r)},Xr=(e,t)=>{if(!t||!e)return 0;const n=v(t).dividedBy(e).toNumber();return n>=.99?100:n<=0?0:Number((n*100).toFixed(2))},mi=(e,t,n)=>e===100?ue.Completed:n==="CANCELLED"?ue.Cancelled:n==="COMPLETED"?ue.Completed:t>Date.now()?ue.Open:ue.Expired,yi=async({signal:e,page:t,chainId:n,limit:r,config:s,account:a,isDev:o=!1,includeV1GraphOrders:u=!0})=>(await Promise.all([!s||!u?Promise.resolve([]):fi({chainId:n,signal:e,page:t,limit:r,filters:{accounts:[a],configs:s.twapConfig?[s.twapConfig]:[]}}),ai({chainId:n,signal:e,account:a,exchange:s==null?void 0:s.adapter,partner:s==null?void 0:s.partner,isDev:o})]).then(([w,y])=>[...w,...y])).sort((w,y)=>y.createdAt-w.createdAt),gi={version:"1.1.37"},Zr=e=>{let t;const n=new Set,r=(f,w)=>{const y=typeof f=="function"?f(t):f;if(!Object.is(y,t)){const b=t;t=w??(typeof y!="object"||y===null)?y:Object.assign({},t,y),n.forEach(D=>D(t,b))}},s=()=>t,u={setState:r,getState:s,getInitialState:()=>p,subscribe:f=>(n.add(f),()=>n.delete(f))},p=t=e(r,s,u);return u},Ai=(e=>e?Zr(e):Zr),Ei=e=>e;function bi(e,t=Ei){const n=F.useSyncExternalStore(e.subscribe,F.useCallback(()=>t(e.getState()),[e,t]),F.useCallback(()=>t(e.getInitialState()),[e,t]));return F.useDebugValue(n),n}const Yr=e=>{const t=Ai(e),n=r=>bi(t,r);return Object.assign(n,t),n},Ci=(e=>e?Yr(e):Yr),An={},Jr={currentTime:Date.now(),cancelOrders:{},swapExecutions:[An],swapExecutionIndex:0},z=Ci((e,t)=>({state:Jr,updateState:n=>e(r=>({state:{...r.state,...n}})),updateSwapExecutionAtIndex:(n,r)=>e(s=>{const a=[...s.state.swapExecutions];return a[n]={...a[n]??An,...r},{state:{...s.state,swapExecutions:a}}}),resetSwapExecutionAtIndex:()=>e(n=>{const r=[...n.state.swapExecutions];return r[n.state.swapExecutionIndex]=An,{state:{...n.state,swapExecutions:r}}}),resetState:()=>{const n=t().state;e({state:{...Jr,currentTime:Date.now(),isMarketOrder:n.isMarketOrder,swapExecutions:[...n.swapExecutions,An],swapExecutionIndex:n.swapExecutionIndex+1}})}}));var Se=(e=>(e[e.LOADING=1]="LOADING",e[e.SUCCESS=2]="SUCCESS",e[e.FAILED=3]="FAILED",e))(Se||{}),en=(e=>(e.TRIGGER_MARKET_PRICE="triggerMarketPriceDisclaimer",e.MARKET_PRICE="marketOrderDisclaimer",e.LIMIT_PRICE="limitOrderDisclaimer",e))(en||{}),nt=(e=>(e.WRAP="wrap",e.APPROVE="approve",e.CREATE="create",e))(nt||{});const rt=(e,t)=>!t||!e||v(e).isNaN()?"":v(e).multipliedBy(v(10).pow(t)).toFixed(0),Ee=(e,t)=>{try{return!t||!e||v(e).isNaN()?"":v(e).dividedBy(v(10).pow(t)).toFixed()}catch(n){return console.error(n),""}},Ti=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}},Xn=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"))},es=(e,t)=>{const n=Et(t);return n&&Rt(e.address)?n.wToken:e};function Zn(e){return e?e/864e5:0}function En(e){return e?e/6e4:0}const wi=(e,t)=>e?X.TWAP_MARKET:t===1?X.LIMIT:X.TWAP_LIMIT,Yn=(e,t,n)=>{const r=Et(n);return Rt((e==null?void 0:e.address)||"")&>((t==null?void 0:t.address)||"",(r==null?void 0:r.wToken.address)||"")},Jn=(e,t,n)=>{const r=Et(n);return gt((e==null?void 0:e.address)||"",(r==null?void 0:r.wToken.address)||"")&&Rt((t==null?void 0:t.address)||"")},Lt=(e,t)=>{if(!t)return"";const n=Et(t);return`${n==null?void 0:n.explorer}/tx/${e}`},er=(e,t)=>F.useMemo(()=>rt(t,e),[e,t]),bt=(e,t)=>F.useMemo(()=>Ee(t,e),[e,t]),bn=()=>{const{chainId:e}=q();return F.useMemo(()=>Et(e),[e])},xi=e=>{const t=bn();return F.useMemo(()=>{if(!(!e||!t))return Lt(e,t.id)},[e,t])},qe=(e,t)=>F.useMemo(()=>!e||!t||v(e||"0").isZero()||v(t||"0").isZero()?"":v(e||"0").times(t).toFixed(),[e,t]),Si=()=>{const{srcToken:e,dstToken:t,chainId:n}=q();return F.useMemo(()=>Yn(e,t,n),[e,t,n])},vi=()=>{const{srcToken:e,dstToken:t,chainId:n}=q();return F.useMemo(()=>Jn(e,t,n),[e,t,n])},Fi=()=>{const e=Si(),t=vi();return e||t},st=()=>{const{srcToken:e,typedInputAmount:t}=q();return{amount:er(e==null?void 0:e.decimals,t),amountUI:t,error:v(t||0).isZero()?"enterAmount":void 0}},Di=(e,t)=>{const{module:n,srcUsd1Token:r,marketPrice:s,minChunkSizeUsd:a,typedInputAmount:o}=q();return F.useMemo(()=>{if(v(o||"0").isZero()||!s||v(r||"0").isZero())return;if(!e)return{type:me.MIN_CHUNKS,value:1,args:{minChunks:"1"}};const{isError:u}=Ha(e,t,n);if(u)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])},Ke=()=>{const{srcToken:e,srcUsd1Token:t,module:n,minChunkSizeUsd:r}=q(),s=z(O=>O.state.typedChunks),a=z(O=>O.updateState),{amount:o,amountUI:u}=st(),p=F.useMemo(()=>Pa(u||"",t||"",r||0),[u,t,r]),f=F.useMemo(()=>Da(p,n,s),[p,s,n]),w=F.useCallback(O=>a({typedChunks:O}),[a]),y=F.useMemo(()=>Ba(o||"",f),[o,f]),b=bt(e==null?void 0:e.decimals,y),D=F.useMemo(()=>t?v(b||"0").times(t||0).toString():"0",[b,t]);return{totalTrades:f,maxTrades:p,amountPerTradeUI:b,amountPerTrade:y,amountPerTradeUsd:D,onChange:w,error:Di(f,p)}},Pi=()=>{const{srcToken:e,dstToken:t}=q(),{onChange:n,totalTrades:r,amountPerTradeUsd:s,amountPerTradeUI:a,error:o,maxTrades:u,amountPerTrade:p}=Ke();return{error:o,maxTrades:u,totalTrades:r,amountPerTradeUI:a,amountPerTrade:p,onChange:n,amountPerTradeUsd:s,fromToken:e,toToken:t}},ts=e=>{const t=Zn(e);if(t>=1)return`${t.toFixed(t%1?1:0)} ${t===1?"day":"days"}`;const n=En(e)/60;if(n>=1)return`${n.toFixed(n%1?1:0)} ${n===1?"hour":"hours"}`;const r=En(e);return`${r.toFixed(r%1?1:0)} ${r===1?"minute":"minutes"}`},Oi=e=>{const{totalTrades:t}=Ke(),{marketPrice:n,typedInputAmount:r}=q(),s=F.useMemo(()=>{const{isError:o,value:u}=qa(e);if(!(!o||v(r||"0").isZero()||!n))return{type:me.MIN_FILL_DELAY,value:u,args:{fillDelay:ts(u)}}},[e,r,n]),a=F.useMemo(()=>{const{isError:o,value:u}=Ma(e,t);if(!(!o||v(r||"0").isZero()||!n))return{type:me.MAX_FILL_DELAY,value:u,args:{fillDelay:ts(u)}}},[e,r,n,t]);return s||a},Nt=()=>{const{callbacks:e}=q(),t=z(a=>a.state.typedFillDelay),n=z(a=>a.updateState),r=F.useMemo(()=>t||Rn,[t]),s=Oi(r);return{fillDelay:r,onChange:F.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}},Ii=()=>{const{onChange:e,fillDelay:t,error:n}=Nt(),r=F.useCallback(a=>e({unit:t.unit,value:Number(a)}),[e,t]),s=F.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}},Bi=e=>{const{module:t,marketPrice:n}=q();return F.useMemo(()=>{const r=La(t,e),s=Na(e);if(n){if(r.isError)return{type:me.MAX_ORDER_DURATION,value:r.value,args:{duration:`${Math.floor(Zn(r.value)).toFixed(0)} days`}};if(s.isError)return{type:me.MIN_ORDER_DURATION,value:s.value,args:{duration:`${Math.floor(En(s.value)).toFixed(0)} minutes`}}}},[e,t,n])},tr=()=>{const{module:e,callbacks:t}=q(),n=z(p=>p.state.typedDuration),r=z(p=>p.updateState),s=Ke().totalTrades,a=Nt().fillDelay,o=F.useMemo(()=>Fa(e,s,a,n),[s,a,n,e]),u=Bi(o);return{duration:o,setDuration:F.useCallback(p=>{var f;r({typedDuration:p}),(f=t==null?void 0:t.onDurationChange)==null||f.call(t,p)},[r,t]),error:u}},Mi=()=>{const{duration:e,setDuration:t,error:n}=tr(),r=F.useCallback(a=>{t({unit:e.unit,value:Number(a)})},[t,e]),s=F.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}},ki=()=>{const{module:e}=q();return F.useMemo(()=>e===j.STOP_LOSS?pa:fa,[e])},nr=()=>{const{module:e}=q(),t=z(n=>n.state.isMarketOrder);return F.useMemo(()=>e!==j.STOP_LOSS&&e!==j.TAKE_PROFIT||t?void 0:e===j.STOP_LOSS?ha:ma,[e,t])},ns=e=>{if(e===void 0||e==="")return e;const t=v(e);return t.isNaN()||t.isZero()?"0":v(1).div(t).toFixed()},Cn=()=>{const{srcToken:e,dstToken:t}=q(),n=z(p=>p.updateState),r=z(p=>p.state.isInvertedTrade),s=z(p=>p.state.typedTriggerPrice),a=z(p=>p.state.typedLimitPrice),o=z(p=>p.state.isMarketOrder);return{onInvert:F.useCallback(()=>{n({isInvertedTrade:!r,...s!==void 0?{typedTriggerPrice:ns(s)}:{},...a!==void 0?{typedLimitPrice:ns(a)}:{}})},[n,r,s,a]),isInverted:r,fromToken:r?t:e,toToken:r?e:t,isMarketPrice:o}},Tn=e=>e?v(e).isNaN()?"":e:"",rs=({amount:e,typedValue:t,amountDecimals:n=18,invertedAmountDecimals:r=18,amountUsd:s,invertedAmountUsd:a,isInverted:o})=>{const u=F.useMemo(()=>{if(t!==void 0)return Tn(t);const w=Ee(e,n);return!w||v(w||"0").isZero()?"":o?v(1).div(w).toFixed():w},[e,n,o,t]),p=F.useMemo(()=>u?Tn(o?rt(u,r):e):"",[e,u,r,o]),f=qe(u||"0",o?a:s);return{amount:p,amountUI:u,usd:Tn(f)}},ss=({typedValue:e,tokenDecimals:t=18,initialPrice:n="0",percentage:r,setValue:s,setPercentage:a})=>{const{isInverted:o}=Cn(),u=F.useMemo(()=>v((()=>{if(e!==void 0){const b=o?v(e).isZero()?v(0):v(1).div(e):v(e);return rt(b.toFixed(),t)}if(r!==void 0&&v(n||"0").gt(0)&&!v(n||"0").isNaN()){const b=v(n||"0"),D=v(r||0).div(100);return b.plus(b.multipliedBy(D)).decimalPlaces(0).toFixed()}return v(n).gt(0)?n:""})()).decimalPlaces(0).toFixed(),[e,r,t,n,o]),p=F.useCallback(y=>{s(y),a(null)},[s,a]),f=F.useCallback(y=>{s(void 0),a(y)},[s,a]),w=F.useMemo(()=>{if(!n||v(n).isZero())return"";if(r!=null)return r;if(u){const y=v(n),D=v(u).minus(y).div(y).multipliedBy(100).decimalPlaces(2).toString();return v(D||"0").isZero()?"":D}return""},[u,n,r]);return{amount:v(u).isNaN()?"":u,typedValue:e,selectedPercentage:w,onChange:p,onPercentageChange:f,isTypedValue:e!==void 0}},_i=(e="")=>{const{module:t,marketPrice:n,typedInputAmount:r}=q();return F.useMemo(()=>{if(v(r||"0").isZero()||!n||t!==j.STOP_LOSS&&t!==j.TAKE_PROFIT)return;const s=ka(n||"",e||"",t);if(s!=null&&s.isError)return{type:me.STOP_LOSS_TRIGGER_PRICE_GREATER_THAN_MARKET_PRICE,value:s.value};const a=_a(n||"",e||"",t);if(a!=null&&a.isError)return{type:me.TAKE_PROFIT_TRIGGER_PRICE_LESS_THAN_MARKET_PRICE,value:a.value};if(!e||v(e||0).isZero())return{type:me.EMPTY_TRIGGER_PRICE,value:e}},[n,e,t,r])},Ui=e=>{const{srcToken:t,dstToken:n,module:r,dstUsd1Token:s}=q(),a=Ke().amountPerTrade,o=z(f=>f.state.isMarketOrder),u=F.useMemo(()=>va(r,a,e,(t==null?void 0:t.decimals)||0),[e,a,o,t==null?void 0:t.decimals,r]),p=bt((n==null?void 0:n.decimals)||0,u);return{amount:u,amountUI:p,usd:qe(p,s)}},Ct=()=>{const{dstToken:e,dstUsd1Token:t,marketPrice:n,module:r,callbacks:s}=q(),a=z(_=>_.updateState),o=ki(),u=z(_=>_.state.triggerPricePercent),p=u===void 0?o:u,f=r===j.STOP_LOSS||r===j.TAKE_PROFIT,w=ss({typedValue:z(_=>_.state.typedTriggerPrice),percentage:p,tokenDecimals:(e==null?void 0:e.decimals)||18,initialPrice:f?n:void 0,setValue:F.useCallback(_=>{var S;a({typedTriggerPrice:_}),(S=s==null?void 0:s.onTriggerPriceChange)==null||S.call(s,_||"")},[a,s]),setPercentage:F.useCallback(_=>{var S;a({triggerPricePercent:_}),(S=s==null?void 0:s.onTriggerPricePercentChange)==null||S.call(s,_||"")},[a,s])}),y=_i(w.amount),b=bt((e==null?void 0:e.decimals)||18,w.amount),D=qe(b,t),{amount:O,amountUI:B,usd:k}=Ui(w.amount);return F.useMemo(()=>({...w,amountUI:v(b).isNaN()?"":b,usd:v(D).isNaN()?"":D,error:y,pricePerChunk:O,pricePerChunkUI:B,pricePerChunkUsd:k}),[w,b,D,y,O,B,k])},Ri=e=>{const{module:t,marketPrice:n,typedInputAmount:r}=q(),{amount:s}=Ct(),a=z(o=>o.state.isMarketOrder);return F.useMemo(()=>{if(v(r||"0").isZero()||!s||!n)return;const o=Ua(s,e,a,t),u=Ra(s,e,a,t);if(o!=null&&o.isError)return{type:me.TRIGGER_LIMIT_PRICE_GREATER_THAN_TRIGGER_PRICE,value:o.value};if(u!=null&&u.isError)return{type:me.TRIGGER_LIMIT_PRICE_GREATER_THAN_TRIGGER_PRICE,value:u.value};if(e&&v(e||0).isZero())return{type:me.MISSING_LIMIT_PRICE,value:e||""}},[e,s,t,a,r,n])},wn=()=>{const{dstToken:e,dstUsd1Token:t,marketPrice:n,callbacks:r}=q(),s=z(b=>b.updateState),a=nr(),o=z(b=>b.state.limitPricePercent),u=o===void 0?a:o,p=ss({typedValue:z(b=>b.state.typedLimitPrice),percentage:u,tokenDecimals:(e==null?void 0:e.decimals)||18,initialPrice:n,setValue:F.useCallback(b=>{var D;s({typedLimitPrice:b}),(D=r==null?void 0:r.onLimitPriceChange)==null||D.call(r,b||"")},[s,r]),setPercentage:F.useCallback(b=>{var D;s({limitPricePercent:b}),(D=r==null?void 0:r.onLimitPricePercentChange)==null||D.call(r,b||"")},[s,r])}),f=Ri(p.amount),w=bt((e==null?void 0:e.decimals)||18,p.amount),y=qe(w,t);return F.useMemo(()=>({...p,amountUI:v(w).isNaN()?"":w,usd:v(y).isNaN()?"":y,error:f}),[p,w,y,f])},Li=()=>{const{module:e}=q(),t=z(u=>u.updateState),n=z(u=>u.state.isMarketOrder),r=nr(),s=z(u=>u.state.triggerPricePercent)||0,a=e===j.LIMIT,o=F.useCallback(()=>{!n&&e===j.STOP_LOSS&&t({limitPricePercent:r}),t({isMarketOrder:!n})},[t,s,e,n,r]);return{isLimitPrice:!n,toggleLimitPrice:o,hide:a}},Ni=()=>{const{module:e,marketPriceLoading:t,srcToken:n,dstToken:r,srcUsd1Token:s,dstUsd1Token:a}=q(),{amount:o,typedValue:u,onChange:p,onPercentageChange:f,selectedPercentage:w,error:y,isTypedValue:b}=wn(),D=z(G=>G.updateState),O=nr(),{isLimitPrice:B,toggleLimitPrice:k}=Li(),{fromToken:_,toToken:S,isInverted:K}=Cn(),U=rs({amount:o,typedValue:u,amountDecimals:(r==null?void 0:r.decimals)||18,invertedAmountDecimals:(n==null?void 0:n.decimals)||18,amountUsd:a,invertedAmountUsd:s,isInverted:K}),V=F.useCallback(()=>{D({typedLimitPrice:void 0}),D({limitPricePercent:O})},[D,e,O]);return{price:U.amount,priceUI:U.amountUI,error:y,onInputChange:p,onPercentageChange:f,onReset:V,usd:U.usd,srcToken:n,dstToken:r,invertedSrcToken:_,invertedDstToken:S,percentage:w,isLoading:t,isLimitPrice:B,toggleLimitPrice:k,isTypedValue:b}},qi=()=>{const{marketPrice:e,marketPriceLoading:t,srcToken:n,dstToken:r,srcUsd1Token:s,dstUsd1Token:a}=q(),{amount:o,typedValue:u,onChange:p,onPercentageChange:f,selectedPercentage:w,error:y,pricePerChunk:b,pricePerChunkUI:D,pricePerChunkUsd:O,isTypedValue:B}=Ct(),k=z(G=>G.updateState),{fromToken:_,toToken:S,isInverted:K}=Cn(),U=rs({amount:o,typedValue:u,amountDecimals:(r==null?void 0:r.decimals)||18,invertedAmountDecimals:(n==null?void 0:n.decimals)||18,amountUsd:a,invertedAmountUsd:s,isInverted:K}),V=F.useCallback(()=>{k({triggerPricePercent:void 0,typedTriggerPrice:void 0})},[k]);return{price:U.amount,priceUI:U.amountUI,amountPerChunk:b,amountPerChunkUI:D,amountPerChunkUsd:O,error:y,onInputChange:p,onPercentageChange:f,percentage:w,onReset:V,usd:U.usd,srcToken:n,dstToken:r,invertedSrcToken:_,invertedDstToken:S,isLoading:t||!e,isTypedValue:B}},as=()=>{const{module:e,marketPrice:t}=q(),n=wn().amount,r=Ct().amount,s=z(a=>a.state.isMarketOrder);return e===j.LIMIT||!s?n||"":e===j.STOP_LOSS||e===j.TAKE_PROFIT?r||"":t||""},xn=()=>{const{srcToken:e,dstToken:t,dstUsd1Token:n}=q(),r=as(),s=st().amount,a=F.useMemo(()=>xa(s||"",r,(e==null?void 0:e.decimals)||0),[s,r,e==null?void 0:e.decimals]),o=bt(t==null?void 0:t.decimals,a);return{amount:a,amountUI:o,usd:qe(o,n)}},rr=()=>{const{srcToken:e,dstToken:t,dstUsd1Token:n}=q(),r=as(),s=Ke().amountPerTrade,a=z(p=>p.state.isMarketOrder),o=F.useMemo(()=>Sa(s,r,!!a,(e==null?void 0:e.decimals)||0),[s,r,a,e==null?void 0:e.decimals]),u=bt(t==null?void 0:t.decimals,o);return{amount:o,amountUI:u,usd:qe(u,n)}},Ki=()=>{const{typedInputAmount:e,marketPriceLoading:t,dstToken:n}=q(),{amountUI:r,usd:s}=xn(),o=Fi()?e:r,u=er(n==null?void 0:n.decimals,o);return{value:o,valueWei:u,isLoading:t,usd:s}},Hi=()=>{const e=z(s=>s.state.isMarketOrder),{module:t}=q(),n=F.useMemo(()=>{if(e&&t===j.STOP_LOSS)return en.TRIGGER_MARKET_PRICE},[e,t]),r=F.useMemo(()=>{if(!(t!==j.LIMIT&&t!==j.TWAP))return e?en.MARKET_PRICE:en.LIMIT_PRICE},[e,t]);return n||r},Wi=()=>{const{minChunkSizeUsd:e,typedInputAmount:t,srcUsd1Token:n}=q(),r=qe(t,n);return F.useMemo(()=>v(e).gt(v(r||"0"))?{type:me.MIN_TRADE_SIZE_ERROR,value:e,args:{minTradeSize:`${e}`}}:void 0,[e,r])};function is(){const{marketPrice:e,marketPriceLoading:t,typedInputAmount:n,srcUsd1Token:r,srcBalance:s,chainId:a}=q(),{error:o}=Ct(),{error:u}=wn(),{error:p}=Ke(),{error:f}=Nt(),{error:w}=tr(),y=Wi(),b=st().amount,D=F.useMemo(()=>{if(s&&v(b).gt(s))return{type:me.INSUFFICIENT_BALANCE,value:s||""}},[s,b,a]);return F.useMemo(()=>za({marketPrice:e,typedInputAmount:n,srcUsd1Token:r,marketPriceLoading:t,triggerPriceError:o,limitPriceError:u,tradesError:p,fillDelayError:f,durationError:w,balanceError:D,minTradeSizeError:y}),[e,t,n,o,u,p,f,w,D,r,y])}var qt=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(){}},zi={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Qi=(_s=class{constructor(){N(this,He,zi);N(this,St,!1)}setTimeoutProvider(e){process.env.NODE_ENV!=="production"&&l(this,St)&&e!==l(this,He)&&console.error("[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",{previous:l(this,He),provider:e}),M(this,He,e),process.env.NODE_ENV!=="production"&&M(this,St,!1)}setTimeout(e,t){return process.env.NODE_ENV!=="production"&&M(this,St,!0),l(this,He).setTimeout(e,t)}clearTimeout(e){l(this,He).clearTimeout(e)}setInterval(e,t){return process.env.NODE_ENV!=="production"&&M(this,St,!0),l(this,He).setInterval(e,t)}clearInterval(e){l(this,He).clearInterval(e)}},He=new WeakMap,St=new WeakMap,_s),Tt=new Qi;function $i(e){setTimeout(e,0)}var wt=typeof window>"u"||"Deno"in globalThis;function be(){}function ji(e,t){return typeof e=="function"?e(t):e}function sr(e){return typeof e=="number"&&e>=0&&e!==1/0}function os(e,t){return Math.max(e+(t||0)-Date.now(),0)}function at(e,t){return typeof e=="function"?e(t):e}function Me(e,t){return typeof e=="function"?e(t):e}function cs(e,t){const{type:n="all",exact:r,fetchStatus:s,predicate:a,queryKey:o,stale:u}=e;if(o){if(r){if(t.queryHash!==ar(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 u=="boolean"&&t.isStale()!==u||s&&s!==t.state.fetchStatus||a&&!a(t))}function us(e,t){const{exact:n,status:r,predicate:s,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(xt(t.options.mutationKey)!==xt(a))return!1}else if(!tn(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||s&&!s(t))}function ar(e,t){return((t==null?void 0:t.queryKeyHashFn)||xt)(e)}function xt(e){return JSON.stringify(e,(t,n)=>or(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 Vi=Object.prototype.hasOwnProperty;function ir(e,t){if(e===t)return e;const n=ds(e)&&ds(t);if(!n&&!(or(e)&&or(t)))return t;const s=(n?e:Object.keys(e)).length,a=n?t:Object.keys(t),o=a.length,u=n?new Array(o):{};let p=0;for(let f=0;f<o;f++){const w=n?f:a[f],y=e[w],b=t[w];if(y===b){u[w]=y,(n?f<s:Vi.call(e,w))&&p++;continue}if(y===null||b===null||typeof y!="object"||typeof b!="object"){u[w]=b;continue}const D=ir(y,b);u[w]=D,D===y&&p++}return s===o&&p===s?e:u}function Sn(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 ds(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function or(e){if(!ls(e))return!1;const t=e.constructor;if(t===void 0)return!0;const n=t.prototype;return!(!ls(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function ls(e){return Object.prototype.toString.call(e)==="[object Object]"}function Gi(e){return new Promise(t=>{Tt.setTimeout(t,e)})}function cr(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 ir(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 ir(e,t)}return t}function Xi(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function Zi(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var vn=Symbol();function ps(e,t){return process.env.NODE_ENV!=="production"&&e.queryFn===vn&&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===vn?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function fs(e,t){return typeof e=="function"?e(...t):!!e}var Yi=(Us=class extends qt{constructor(){super();N(this,vt);N(this,ot);N(this,Kt);M(this,Kt,t=>{if(!wt&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){l(this,ot)||this.setEventListener(l(this,Kt))}onUnsubscribe(){var t;this.hasListeners()||((t=l(this,ot))==null||t.call(this),M(this,ot,void 0))}setEventListener(t){var n;M(this,Kt,t),(n=l(this,ot))==null||n.call(this),M(this,ot,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){l(this,vt)!==t&&(M(this,vt,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(n=>{n(t)})}isFocused(){var t;return typeof l(this,vt)=="boolean"?l(this,vt):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},vt=new WeakMap,ot=new WeakMap,Kt=new WeakMap,Us),ur=new Yi;function dr(){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 Ji=$i;function eo(){let e=[],t=0,n=u=>{u()},r=u=>{u()},s=Ji;const a=u=>{t?e.push(u):s(()=>{n(u)})},o=()=>{const u=e;e=[],u.length&&s(()=>{r(()=>{u.forEach(p=>{n(p)})})})};return{batch:u=>{let p;t++;try{p=u()}finally{t--,t||o()}return p},batchCalls:u=>(...p)=>{a(()=>{u(...p)})},schedule:a,setNotifyFunction:u=>{n=u},setBatchNotifyFunction:u=>{r=u},setScheduler:u=>{s=u}}}var de=eo(),to=(Rs=class extends qt{constructor(){super();N(this,Ht,!0);N(this,ct);N(this,Wt);M(this,Wt,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,ct)||this.setEventListener(l(this,Wt))}onUnsubscribe(){var t;this.hasListeners()||((t=l(this,ct))==null||t.call(this),M(this,ct,void 0))}setEventListener(t){var n;M(this,Wt,t),(n=l(this,ct))==null||n.call(this),M(this,ct,t(this.setOnline.bind(this)))}setOnline(t){l(this,Ht)!==t&&(M(this,Ht,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return l(this,Ht)}},Ht=new WeakMap,ct=new WeakMap,Wt=new WeakMap,Rs),Fn=new to;function no(e){return Math.min(1e3*2**e,3e4)}function hs(e){return(e??"online")==="online"?Fn.isOnline():!0}var lr=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function ms(e){let t=!1,n=0,r;const s=dr(),a=()=>s.status!=="pending",o=B=>{var k;if(!a()){const _=new lr(B);b(_),(k=e.onCancel)==null||k.call(e,_)}},u=()=>{t=!0},p=()=>{t=!1},f=()=>ur.isFocused()&&(e.networkMode==="always"||Fn.isOnline())&&e.canRun(),w=()=>hs(e.networkMode)&&e.canRun(),y=B=>{a()||(r==null||r(),s.resolve(B))},b=B=>{a()||(r==null||r(),s.reject(B))},D=()=>new Promise(B=>{var k;r=_=>{(a()||f())&&B(_)},(k=e.onPause)==null||k.call(e)}).then(()=>{var B;r=void 0,a()||(B=e.onContinue)==null||B.call(e)}),O=()=>{if(a())return;let B;const k=n===0?e.initialPromise:void 0;try{B=k??e.fn()}catch(_){B=Promise.reject(_)}Promise.resolve(B).then(y).catch(_=>{var G;if(a())return;const S=e.retry??(wt?0:3),K=e.retryDelay??no,U=typeof K=="function"?K(n,_):K,V=S===!0||typeof S=="number"&&n<S||typeof S=="function"&&S(n,_);if(t||!V){b(_);return}n++,(G=e.onFail)==null||G.call(e,n,_),Gi(U).then(()=>f()?void 0:D()).then(()=>{t?b(_):O()})})};return{promise:s,status:()=>s.status,cancel:o,continue:()=>(r==null||r(),s),cancelRetry:u,continueRetry:p,canStart:w,start:()=>(w()?O():D().then(O),s)}}var ys=(Ls=class{constructor(){N(this,Ft)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),sr(this.gcTime)&&M(this,Ft,Tt.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(wt?1/0:300*1e3))}clearGcTimeout(){l(this,Ft)&&(Tt.clearTimeout(l(this,Ft)),M(this,Ft,void 0))}},Ft=new WeakMap,Ls),ro=(Ns=class extends ys{constructor(t){super();N(this,Le);N(this,Dt);N(this,zt);N(this,ke);N(this,Pt);N(this,he);N(this,sn);N(this,Ot);M(this,Ot,!1),M(this,sn,t.defaultOptions),this.setOptions(t.options),this.observers=[],M(this,Pt,t.client),M(this,ke,l(this,Pt).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,M(this,Dt,Es(this.options)),this.state=t.state??l(this,Dt),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,sn),...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const n=Es(this.options);n.data!==void 0&&(this.setState(As(n.data,n.dataUpdatedAt)),M(this,Dt,n))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&l(this,ke).remove(this)}setData(t,n){const r=cr(this.state.data,t,this.options);return Q(this,Le,et).call(this,{data:r,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),r}setState(t,n){Q(this,Le,et).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,Dt))}isActive(){return this.observers.some(t=>Me(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===vn||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>at(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:!os(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,ke).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,Ot)?l(this,he).cancel({revert:!0}):l(this,he).cancelRetry()),this.scheduleGc()),l(this,ke).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||Q(this,Le,et).call(this,{type:"invalidate"})}async fetch(t,n){var p,f,w,y,b,D,O,B,k,_,S,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(V=>V.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:()=>(M(this,Ot,!0),r.signal)})},a=()=>{const U=ps(this.options,n),G=(()=>{const oe={client:l(this,Pt),queryKey:this.queryKey,meta:this.meta};return s(oe),oe})();return M(this,Ot,!1),this.options.persister?this.options.persister(U,G,this):U(G)},u=(()=>{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(u,this),M(this,zt,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((w=u.fetchOptions)==null?void 0:w.meta))&&Q(this,Le,et).call(this,{type:"fetch",meta:(y=u.fetchOptions)==null?void 0:y.meta}),M(this,he,ms({initialPromise:n==null?void 0:n.initialPromise,fn:u.fetchFn,onCancel:U=>{U instanceof lr&&U.revert&&this.setState({...l(this,zt),fetchStatus:"idle"}),r.abort()},onFail:(U,V)=>{Q(this,Le,et).call(this,{type:"failed",failureCount:U,error:V})},onPause:()=>{Q(this,Le,et).call(this,{type:"pause"})},onContinue:()=>{Q(this,Le,et).call(this,{type:"continue"})},retry:u.options.retry,retryDelay:u.options.retryDelay,networkMode:u.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),(D=(b=l(this,ke).config).onSuccess)==null||D.call(b,U,this),(B=(O=l(this,ke).config).onSettled)==null||B.call(O,U,this.state.error,this),U}catch(U){if(U instanceof lr){if(U.silent)return l(this,he).promise;if(U.revert){if(this.state.data===void 0)throw U;return this.state.data}}throw Q(this,Le,et).call(this,{type:"error",error:U}),(_=(k=l(this,ke).config).onError)==null||_.call(k,U,this),(K=(S=l(this,ke).config).onSettled)==null||K.call(S,this.state.data,U,this),U}finally{this.scheduleGc()}}},Dt=new WeakMap,zt=new WeakMap,ke=new WeakMap,Pt=new WeakMap,he=new WeakMap,sn=new WeakMap,Ot=new WeakMap,Le=new WeakSet,et=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,...gs(r.data,this.options),fetchMeta:t.meta??null};case"success":const s={...r,...As(t.data,t.dataUpdatedAt),dataUpdateCount:r.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return M(this,zt,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),de.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),l(this,ke).notify({query:this,type:"updated",action:t})})},Ns);function gs(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:hs(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function As(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function Es(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 so=(qs=class extends qt{constructor(t,n){super();N(this,ee);N(this,ve);N(this,Y);N(this,an);N(this,Ce);N(this,It);N(this,Qt);N(this,Ge);N(this,ut);N(this,on);N(this,$t);N(this,jt);N(this,Bt);N(this,Mt);N(this,dt);N(this,Vt,new Set);this.options=n,M(this,ve,t),M(this,ut,null),M(this,Ge,dr()),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(l(this,Y).addObserver(this),bs(l(this,Y),this.options)?Q(this,ee,ln).call(this):this.updateResult(),Q(this,ee,xr).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return pr(l(this,Y),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return pr(l(this,Y),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,Q(this,ee,Sr).call(this),Q(this,ee,vr).call(this),l(this,Y).removeObserver(this)}setOptions(t){const n=this.options,r=l(this,Y);if(this.options=l(this,ve).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Me(this.options.enabled,l(this,Y))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");Q(this,ee,Fr).call(this),l(this,Y).setOptions(this.options),n._defaulted&&!Sn(this.options,n)&&l(this,ve).getQueryCache().notify({type:"observerOptionsUpdated",query:l(this,Y),observer:this});const s=this.hasListeners();s&&Cs(l(this,Y),r,this.options,n)&&Q(this,ee,ln).call(this),this.updateResult(),s&&(l(this,Y)!==r||Me(this.options.enabled,l(this,Y))!==Me(n.enabled,l(this,Y))||at(this.options.staleTime,l(this,Y))!==at(n.staleTime,l(this,Y)))&&Q(this,ee,Cr).call(this);const a=Q(this,ee,Tr).call(this);s&&(l(this,Y)!==r||Me(this.options.enabled,l(this,Y))!==Me(n.enabled,l(this,Y))||a!==l(this,dt))&&Q(this,ee,wr).call(this,a)}getOptimisticResult(t){const n=l(this,ve).getQueryCache().build(l(this,ve),t),r=this.createResult(n,t);return io(this,r)&&(M(this,Ce,r),M(this,Qt,this.options),M(this,It,l(this,Y).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,Ge).status==="pending"&&l(this,Ge).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(r,s))})}trackProp(t){l(this,Vt).add(t)}getCurrentQuery(){return l(this,Y)}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 Q(this,ee,ln).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),l(this,Ce)))}createResult(t,n){var c;const r=l(this,Y),s=this.options,a=l(this,Ce),o=l(this,It),u=l(this,Qt),f=t!==r?t.state:l(this,an),{state:w}=t;let y={...w},b=!1,D;if(n._optimisticResults){const d=this.hasListeners(),E=!d&&bs(t,n),m=d&&Cs(t,r,n,s);(E||m)&&(y={...y,...gs(w.data,t.options)}),n._optimisticResults==="isRestoring"&&(y.fetchStatus="idle")}let{error:O,errorUpdatedAt:B,status:k}=y;D=y.data;let _=!1;if(n.placeholderData!==void 0&&D===void 0&&k==="pending"){let d;a!=null&&a.isPlaceholderData&&n.placeholderData===(u==null?void 0:u.placeholderData)?(d=a.data,_=!0):d=typeof n.placeholderData=="function"?n.placeholderData((c=l(this,jt))==null?void 0:c.state.data,l(this,jt)):n.placeholderData,d!==void 0&&(k="success",D=cr(a==null?void 0:a.data,d,n),b=!0)}if(n.select&&D!==void 0&&!_)if(a&&D===(o==null?void 0:o.data)&&n.select===l(this,on))D=l(this,$t);else try{M(this,on,n.select),D=n.select(D),D=cr(a==null?void 0:a.data,D,n),M(this,$t,D),M(this,ut,null)}catch(d){M(this,ut,d)}l(this,ut)&&(O=l(this,ut),D=l(this,$t),B=Date.now(),k="error");const S=y.fetchStatus==="fetching",K=k==="pending",U=k==="error",V=K&&S,G=D!==void 0,i={status:k,fetchStatus:y.fetchStatus,isPending:K,isSuccess:k==="success",isError:U,isInitialLoading:V,isLoading:V,data:D,dataUpdatedAt:y.dataUpdatedAt,error:O,errorUpdatedAt:B,failureCount:y.fetchFailureCount,failureReason:y.fetchFailureReason,errorUpdateCount:y.errorUpdateCount,isFetched:y.dataUpdateCount>0||y.errorUpdateCount>0,isFetchedAfterMount:y.dataUpdateCount>f.dataUpdateCount||y.errorUpdateCount>f.errorUpdateCount,isFetching:S,isRefetching:S&&!K,isLoadingError:U&&!G,isPaused:y.fetchStatus==="paused",isPlaceholderData:b,isRefetchError:U&&G,isStale:fr(t,n),refetch:this.refetch,promise:l(this,Ge),isEnabled:Me(n.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const d=g=>{i.status==="error"?g.reject(i.error):i.data!==void 0&&g.resolve(i.data)},E=()=>{const g=M(this,Ge,i.promise=dr());d(g)},m=l(this,Ge);switch(m.status){case"pending":t.queryHash===r.queryHash&&d(m);break;case"fulfilled":(i.status==="error"||i.data!==m.value)&&E();break;case"rejected":(i.status!=="error"||i.error!==m.reason)&&E();break}}return i}updateResult(){const t=l(this,Ce),n=this.createResult(l(this,Y),this.options);if(M(this,It,l(this,Y).state),M(this,Qt,this.options),l(this,It).data!==void 0&&M(this,jt,l(this,Y)),Sn(n,t))return;M(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,Vt).size)return!0;const o=new Set(a??l(this,Vt));return this.options.throwOnError&&o.add("error"),Object.keys(l(this,Ce)).some(u=>{const p=u;return l(this,Ce)[p]!==t[p]&&o.has(p)})};Q(this,ee,js).call(this,{listeners:r()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&Q(this,ee,xr).call(this)}},ve=new WeakMap,Y=new WeakMap,an=new WeakMap,Ce=new WeakMap,It=new WeakMap,Qt=new WeakMap,Ge=new WeakMap,ut=new WeakMap,on=new WeakMap,$t=new WeakMap,jt=new WeakMap,Bt=new WeakMap,Mt=new WeakMap,dt=new WeakMap,Vt=new WeakMap,ee=new WeakSet,ln=function(t){Q(this,ee,Fr).call(this);let n=l(this,Y).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(be)),n},Cr=function(){Q(this,ee,Sr).call(this);const t=at(this.options.staleTime,l(this,Y));if(wt||l(this,Ce).isStale||!sr(t))return;const r=os(l(this,Ce).dataUpdatedAt,t)+1;M(this,Bt,Tt.setTimeout(()=>{l(this,Ce).isStale||this.updateResult()},r))},Tr=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(l(this,Y)):this.options.refetchInterval)??!1},wr=function(t){Q(this,ee,vr).call(this),M(this,dt,t),!(wt||Me(this.options.enabled,l(this,Y))===!1||!sr(l(this,dt))||l(this,dt)===0)&&M(this,Mt,Tt.setInterval(()=>{(this.options.refetchIntervalInBackground||ur.isFocused())&&Q(this,ee,ln).call(this)},l(this,dt)))},xr=function(){Q(this,ee,Cr).call(this),Q(this,ee,wr).call(this,Q(this,ee,Tr).call(this))},Sr=function(){l(this,Bt)&&(Tt.clearTimeout(l(this,Bt)),M(this,Bt,void 0))},vr=function(){l(this,Mt)&&(Tt.clearInterval(l(this,Mt)),M(this,Mt,void 0))},Fr=function(){const t=l(this,ve).getQueryCache().build(l(this,ve),this.options);if(t===l(this,Y))return;const n=l(this,Y);M(this,Y,t),M(this,an,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},js=function(t){de.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(l(this,Ce))}),l(this,ve).getQueryCache().notify({query:l(this,Y),type:"observerResultsUpdated"})})},qs);function ao(e,t){return Me(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function bs(e,t){return ao(e,t)||e.state.data!==void 0&&pr(e,t,t.refetchOnMount)}function pr(e,t,n){if(Me(t.enabled,e)!==!1&&at(t.staleTime,e)!=="static"){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&fr(e,t)}return!1}function Cs(e,t,n,r){return(e!==t||Me(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&fr(e,n)}function fr(e,t){return Me(t.enabled,e)!==!1&&e.isStaleByTime(at(t.staleTime,e))}function io(e,t){return!Sn(e.getCurrentResult(),t)}function Ts(e){return{onFetch:(t,n)=>{var w,y,b,D,O;const r=t.options,s=(b=(y=(w=t.fetchOptions)==null?void 0:w.meta)==null?void 0:y.fetchMore)==null?void 0:b.direction,a=((D=t.state.data)==null?void 0:D.pages)||[],o=((O=t.state.data)==null?void 0:O.pageParams)||[];let u={pages:[],pageParams:[]},p=0;const f=async()=>{let B=!1;const k=K=>{Object.defineProperty(K,"signal",{enumerable:!0,get:()=>(t.signal.aborted?B=!0:t.signal.addEventListener("abort",()=>{B=!0}),t.signal)})},_=ps(t.options,t.fetchOptions),S=async(K,U,V)=>{if(B)return Promise.reject();if(U==null&&K.pages.length)return Promise.resolve(K);const oe=(()=>{const E={client:t.client,queryKey:t.queryKey,pageParam:U,direction:V?"backward":"forward",meta:t.options.meta};return k(E),E})(),i=await _(oe),{maxPages:c}=t.options,d=V?Zi:Xi;return{pages:d(K.pages,i,c),pageParams:d(K.pageParams,U,c)}};if(s&&a.length){const K=s==="backward",U=K?oo:ws,V={pages:a,pageParams:o},G=U(r,V);u=await S(V,G,K)}else{const K=e??a.length;do{const U=p===0?o[0]??r.initialPageParam:ws(r,u);if(p>0&&U==null)break;u=await S(u,U),p++}while(p<K)}return u};t.options.persister?t.fetchFn=()=>{var B,k;return(k=(B=t.options).persister)==null?void 0:k.call(B,f,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=f}}}function ws(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 oo(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 co=(Ks=class extends ys{constructor(t){super();N(this,ze);N(this,cn);N(this,We);N(this,Te);N(this,kt);M(this,cn,t.client),this.mutationId=t.mutationId,M(this,Te,t.mutationCache),M(this,We,[]),this.state=t.state||xs(),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,We).includes(t)||(l(this,We).push(t),this.clearGcTimeout(),l(this,Te).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){M(this,We,l(this,We).filter(n=>n!==t)),this.scheduleGc(),l(this,Te).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){l(this,We).length||(this.state.status==="pending"?this.scheduleGc():l(this,Te).remove(this))}continue(){var t;return((t=l(this,kt))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var o,u,p,f,w,y,b,D,O,B,k,_,S,K,U,V,G,oe,i,c;const n=()=>{Q(this,ze,mt).call(this,{type:"continue"})},r={client:l(this,cn),meta:this.options.meta,mutationKey:this.options.mutationKey};M(this,kt,ms({fn:()=>this.options.mutationFn?this.options.mutationFn(t,r):Promise.reject(new Error("No mutationFn found")),onFail:(d,E)=>{Q(this,ze,mt).call(this,{type:"failed",failureCount:d,error:E})},onPause:()=>{Q(this,ze,mt).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,kt).canStart();try{if(s)n();else{Q(this,ze,mt).call(this,{type:"pending",variables:t,isPaused:a}),await((u=(o=l(this,Te).config).onMutate)==null?void 0:u.call(o,t,this,r));const E=await((f=(p=this.options).onMutate)==null?void 0:f.call(p,t,r));E!==this.state.context&&Q(this,ze,mt).call(this,{type:"pending",context:E,variables:t,isPaused:a})}const d=await l(this,kt).start();return await((y=(w=l(this,Te).config).onSuccess)==null?void 0:y.call(w,d,t,this.state.context,this,r)),await((D=(b=this.options).onSuccess)==null?void 0:D.call(b,d,t,this.state.context,r)),await((B=(O=l(this,Te).config).onSettled)==null?void 0:B.call(O,d,null,this.state.variables,this.state.context,this,r)),await((_=(k=this.options).onSettled)==null?void 0:_.call(k,d,null,t,this.state.context,r)),Q(this,ze,mt).call(this,{type:"success",data:d}),d}catch(d){try{throw await((K=(S=l(this,Te).config).onError)==null?void 0:K.call(S,d,t,this.state.context,this,r)),await((V=(U=this.options).onError)==null?void 0:V.call(U,d,t,this.state.context,r)),await((oe=(G=l(this,Te).config).onSettled)==null?void 0:oe.call(G,void 0,d,this.state.variables,this.state.context,this,r)),await((c=(i=this.options).onSettled)==null?void 0:c.call(i,void 0,d,t,this.state.context,r)),d}finally{Q(this,ze,mt).call(this,{type:"error",error:d})}}finally{l(this,Te).runNext(this)}}},cn=new WeakMap,We=new WeakMap,Te=new WeakMap,kt=new WeakMap,ze=new WeakSet,mt=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),de.batch(()=>{l(this,We).forEach(r=>{r.onMutationUpdate(t)}),l(this,Te).notify({mutation:this,type:"updated",action:t})})},Ks);function xs(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var uo=(Hs=class extends qt{constructor(t={}){super();N(this,Xe);N(this,Ne);N(this,un);this.config=t,M(this,Xe,new Set),M(this,Ne,new Map),M(this,un,0)}build(t,n,r){const s=new co({client:t,mutationCache:this,mutationId:++Bn(this,un)._,options:t.defaultMutationOptions(n),state:r});return this.add(s),s}add(t){l(this,Xe).add(t);const n=Dn(t);if(typeof n=="string"){const r=l(this,Ne).get(n);r?r.push(t):l(this,Ne).set(n,[t])}this.notify({type:"added",mutation:t})}remove(t){if(l(this,Xe).delete(t)){const n=Dn(t);if(typeof n=="string"){const r=l(this,Ne).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,Ne).delete(n)}}this.notify({type:"removed",mutation:t})}canRun(t){const n=Dn(t);if(typeof n=="string"){const r=l(this,Ne).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=Dn(t);if(typeof n=="string"){const s=(r=l(this,Ne).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(){de.batch(()=>{l(this,Xe).forEach(t=>{this.notify({type:"removed",mutation:t})}),l(this,Xe).clear(),l(this,Ne).clear()})}getAll(){return Array.from(l(this,Xe))}find(t){const n={exact:!0,...t};return this.getAll().find(r=>us(n,r))}findAll(t={}){return this.getAll().filter(n=>us(t,n))}notify(t){de.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){const t=this.getAll().filter(n=>n.state.isPaused);return de.batch(()=>Promise.all(t.map(n=>n.continue().catch(be))))}},Xe=new WeakMap,Ne=new WeakMap,un=new WeakMap,Hs);function Dn(e){var t;return(t=e.options.scope)==null?void 0:t.id}var lo=(Ws=class extends qt{constructor(t,n){super();N(this,Je);N(this,Ze);N(this,lt);N(this,Fe);N(this,Ye);M(this,Ze,t),this.setOptions(n),this.bindMethods(),Q(this,Je,Mn).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,Ze).defaultMutationOptions(t),Sn(this.options,n)||l(this,Ze).getMutationCache().notify({type:"observerOptionsUpdated",mutation:l(this,Fe),observer:this}),n!=null&&n.mutationKey&&this.options.mutationKey&&xt(n.mutationKey)!==xt(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){Q(this,Je,Mn).call(this),Q(this,Je,Dr).call(this,t)}getCurrentResult(){return l(this,lt)}reset(){var t;(t=l(this,Fe))==null||t.removeObserver(this),M(this,Fe,void 0),Q(this,Je,Mn).call(this),Q(this,Je,Dr).call(this)}mutate(t,n){var r;return M(this,Ye,n),(r=l(this,Fe))==null||r.removeObserver(this),M(this,Fe,l(this,Ze).getMutationCache().build(l(this,Ze),this.options)),l(this,Fe).addObserver(this),l(this,Fe).execute(t)}},Ze=new WeakMap,lt=new WeakMap,Fe=new WeakMap,Ye=new WeakMap,Je=new WeakSet,Mn=function(){var n;const t=((n=l(this,Fe))==null?void 0:n.state)??xs();M(this,lt,{...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset})},Dr=function(t){de.batch(()=>{var n,r,s,a,o,u,p,f;if(l(this,Ye)&&this.hasListeners()){const w=l(this,lt).variables,y=l(this,lt).context,b={client:l(this,Ze),meta:this.options.meta,mutationKey:this.options.mutationKey};(t==null?void 0:t.type)==="success"?((r=(n=l(this,Ye)).onSuccess)==null||r.call(n,t.data,w,y,b),(a=(s=l(this,Ye)).onSettled)==null||a.call(s,t.data,null,w,y,b)):(t==null?void 0:t.type)==="error"&&((u=(o=l(this,Ye)).onError)==null||u.call(o,t.error,w,y,b),(f=(p=l(this,Ye)).onSettled)==null||f.call(p,void 0,t.error,w,y,b))}this.listeners.forEach(w=>{w(l(this,lt))})})},Ws),po=(zs=class extends qt{constructor(t={}){super();N(this,Qe);this.config=t,M(this,Qe,new Map)}build(t,n,r){const s=n.queryKey,a=n.queryHash??ar(s,n);let o=this.get(a);return o||(o=new ro({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(){de.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=>cs(n,r))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(r=>cs(t,r)):n}notify(t){de.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){de.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){de.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Qe=new WeakMap,zs),fo=(Qs=class{constructor(e={}){N(this,se);N(this,pt);N(this,ft);N(this,Gt);N(this,Xt);N(this,ht);N(this,Zt);N(this,Yt);M(this,se,e.queryCache||new po),M(this,pt,e.mutationCache||new uo),M(this,ft,e.defaultOptions||{}),M(this,Gt,new Map),M(this,Xt,new Map),M(this,ht,0)}mount(){Bn(this,ht)._++,l(this,ht)===1&&(M(this,Zt,ur.subscribe(async e=>{e&&(await this.resumePausedMutations(),l(this,se).onFocus())})),M(this,Yt,Fn.subscribe(async e=>{e&&(await this.resumePausedMutations(),l(this,se).onOnline())})))}unmount(){var e,t;Bn(this,ht)._--,l(this,ht)===0&&((e=l(this,Zt))==null||e.call(this),M(this,Zt,void 0),(t=l(this,Yt))==null||t.call(this),M(this,Yt,void 0))}isFetching(e){return l(this,se).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return l(this,pt).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(at(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=ji(t,a);if(o!==void 0)return l(this,se).build(this,r).setData(o,{...n,manual:!0})}setQueriesData(e,t,n){return de.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);de.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=l(this,se);return de.batch(()=>(n.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},r=de.batch(()=>l(this,se).findAll(e).map(s=>s.cancel(n)));return Promise.all(r).then(be).catch(be)}invalidateQueries(e,t={}){return de.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=de.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(at(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=Ts(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(be).catch(be)}ensureInfiniteQueryData(e){return e.behavior=Ts(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return Fn.isOnline()?l(this,pt).resumePausedMutations():Promise.resolve()}getQueryCache(){return l(this,se)}getMutationCache(){return l(this,pt)}getDefaultOptions(){return l(this,ft)}setDefaultOptions(e){M(this,ft,e)}setQueryDefaults(e,t){l(this,Gt).set(xt(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...l(this,Gt).values()],n={};return t.forEach(r=>{tn(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){l(this,Xt).set(xt(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...l(this,Xt).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,ft).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=ar(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===vn&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...l(this,ft).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){l(this,se).clear(),l(this,pt).clear()}},se=new WeakMap,pt=new WeakMap,ft=new WeakMap,Gt=new WeakMap,Xt=new WeakMap,ht=new WeakMap,Zt=new WeakMap,Yt=new WeakMap,Qs),Ss=ce.createContext(void 0),nn=e=>{const t=ce.useContext(Ss);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},ho=({client:e,children:t})=>(ce.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),H.jsx(Ss.Provider,{value:e,children:t})),vs=ce.createContext(!1),mo=()=>ce.useContext(vs);vs.Provider;function yo(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var go=ce.createContext(yo()),Ao=()=>ce.useContext(go),Eo=(e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))},bo=e=>{ce.useEffect(()=>{e.clearReset()},[e])},Co=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:s})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(s&&e.data===void 0||fs(n,[e.error,r])),To=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))}},wo=(e,t)=>e.isLoading&&e.isFetching&&!t,xo=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,Fs=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function So(e,t,n){var y,b,D,O,B;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=mo(),s=Ao(),a=nn(),o=a.defaultQueryOptions(e);(b=(y=a.getDefaultOptions().queries)==null?void 0:y._experimental_beforeQuery)==null||b.call(y,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",To(o),Eo(o,s),bo(s);const u=!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(k=>{const _=w?p.subscribe(de.batchCalls(k)):be;return p.updateResult(),_},[p,w]),()=>p.getCurrentResult(),()=>p.getCurrentResult()),ce.useEffect(()=>{p.setOptions(o)},[o,p]),xo(o,f))throw Fs(o,p,s);if(Co({result:f,errorResetBoundary:s,throwOnError:o.throwOnError,query:a.getQueryCache().get(o.queryHash),suspense:o.suspense}))throw f.error;if((O=(D=a.getDefaultOptions().queries)==null?void 0:D._experimental_afterQuery)==null||O.call(D,o,f),o.experimental_prefetchInRender&&!wt&&wo(f,r)){const k=u?Fs(o,p,s):(B=a.getQueryCache().get(o.queryHash))==null?void 0:B.promise;k==null||k.catch(be).finally(()=>{p.updateResult()})}return o.notifyOnChangeProps?f:p.trackResult(f)}function vo(e,t){return So(e,so)}function it(e,t){const n=nn(),[r]=ce.useState(()=>new lo(n,e));ce.useEffect(()=>{r.setOptions(e)},[r,e]);const s=ce.useSyncExternalStore(ce.useCallback(o=>r.subscribe(de.batchCalls(o)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=ce.useCallback((o,u)=>{r.mutate(o,u).catch(be)},[r]);if(s.error&&fs(r.options.throwOnError,[s.error]))throw s.error;return{...s,mutate:a,mutateAsync:s.mutate}}const rn=()=>{const e=z(a=>a.state.swapExecutionIndex),t=z(a=>a.state.swapExecutions[a.state.swapExecutionIndex]??{}),n=z(a=>a.updateSwapExecutionAtIndex),r=z(a=>a.resetSwapExecutionAtIndex),s=F.useCallback(a=>n(e,a),[n,e]);return F.useMemo(()=>({...t,update:s,resetSwap:r}),[t,s,r])},Fo=2e4,Do=()=>{const{module:e}=q(),t=z(n=>n.state.isMarketOrder);return F.useMemo(()=>e===j.TWAP?t?X.TWAP_MARKET:X.TWAP_LIMIT:e===j.LIMIT?X.LIMIT:e===j.STOP_LOSS?t?X.STOP_LOSS_MARKET:X.STOP_LOSS_LIMIT:e===j.TAKE_PROFIT?t?X.TAKE_PROFIT_MARKET:X.TAKE_PROFIT_LIMIT:X.TWAP_MARKET,[e,t])},hr=()=>{const{account:e,config:t,chainId:n,isDev:r}=q();return F.useMemo(()=>["useTwapOrderHistoryManager",e,t==null?void 0:t.adapter,t==null?void 0:t.partner,n,r],[e,t,n,r])},Po=()=>{const e=nn(),t=hr();return F.useCallback((n,r)=>{e.setQueryData(t,s=>s==null?void 0:s.map(a=>a.id===n?{...a,status:r}:a))},[e,t])},Oo=()=>{const{callbacks:e}=q(),t=nn(),n=hr();return F.useCallback(r=>{var u;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(y=>y.id===p.id);f&&f.progress!==p.progress&&(a=!0,o.push(f),f.status===ue.Completed&&((w=e==null?void 0:e.onOrderFilled)==null||w.call(e,f)))}),a&&((u=e==null?void 0:e.onOrdersProgressUpdate)==null||u.call(e,o))},[t,n,e])},Io=(e,t)=>{const n=new Set(e.map(s=>s.id)),r=(t==null?void 0:t.filter(s=>s.version===1&&!n.has(s.id)))??[];return[...e,...r].sort((s,a)=>a.createdAt-s.createdAt)},mr=()=>{const{account:e,config:t,chainId:n,isDev:r}=q(),s=nn(),a=hr(),o=Oo();return vo({refetchInterval:Fo,refetchOnWindowFocus:!0,retry:!1,gcTime:1/0,staleTime:1/0,queryKey:a,queryFn:async({signal:p})=>{if(!e||!n||!t)return[];const f=s.getQueryData(a),w=!f,y=await yi({signal:p,chainId:n,config:t,account:e,isDev:r,includeV1GraphOrders:w});o(y);const b=y.map(D=>t!=null&&t.twapConfig?{...D,fillDelayMillis:Hn(D,t.twapConfig)}:D);return w?b:Io(b,f)}})},Bo=(e,t,n)=>F.useMemo(()=>{if(!(!e||!t||!n||n!=null&&n.isMarketPrice))return Nr(n,e==null?void 0:e.decimals,t==null?void 0:t.decimals)},[n,e,t]),Mo=(e,t,n)=>F.useMemo(()=>{if(!(!e||!t||!n))return qr(n,e.decimals,t.decimals)},[n,e,t]),ko=(e,t,n)=>F.useMemo(()=>{if(!(!e||!t||!n))return Wn(n.srcAmountFilled,n.dstAmountFilled,e.decimals,t.decimals)},[n,e,t]),Pn=(e,t)=>[...e.filter(r=>r.status===t)].sort((r,s)=>s.createdAt-r.createdAt),_o=()=>{const{data:e,isLoading:t,refetch:n,isRefetching:r}=mr(),s=F.useCallback(()=>n().then(a=>a.data),[n]);return F.useMemo(()=>({orders:{all:e??[],open:Pn(e??[],ue.Open),completed:Pn(e??[],ue.Completed),cancelled:Pn(e??[],ue.Cancelled),expired:Pn(e??[],ue.Expired)},isLoading:t,isRefetching:r,refetchOrders:s}),[e,t,r,s])},yr=()=>{const e=z(n=>n.state.currentTime),t=tr().duration;return F.useMemo(()=>Oa(e,t),[e,t])},Ds=()=>{const{srcToken:e,dstToken:t,account:n,chainId:r,slippage:s,config:a,module:o,fees:u}=q(),{amount:p}=st(),{amountPerTrade:f,totalTrades:w}=Ke(),y=yr(),{amount:b}=rr(),{pricePerChunk:D}=Ct(),{milliseconds:O}=Nt();return F.useMemo(()=>{var B;return zr({chainId:r,srcToken:Rt((e==null?void 0:e.address)||"")?((B=Et(r))==null?void 0:B.wToken.address)||"":(e==null?void 0:e.address)||"",dstToken:(t==null?void 0:t.address)||"",srcAmount:p,deadlineMillis:y,fillDelayMillis:!w||w===1?0:O,slippage:s*100,account:n,srcAmountPerTrade:f,dstMinAmountPerTrade:b,triggerAmountPerTrade:D,config:a,module:o})},[e,t,n,r,s,a,o,p,f,w,O,b,D,u])};function Uo(e){const t=e.slice(2);if(t.length===128){const a=`0x${t.slice(0,64)}`,o=parseInt(t.charAt(64),16),u=(o>>3)+27,p=`0x${(o&7).toString(16)}${t.slice(65,128)}`;return{r:a,s:p,v:u}}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 Ro=()=>{var a;const{account:e,walletInteractions:t,callbacks:n,chainId:r}=q(),s=(a=bn())==null?void 0:a.wToken;return it({mutationFn:async({onHash:o,srcAmountWei:u})=>{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");fe.onWrapRequest();const p=await t.wrapNativeToken(u);return(f=n==null?void 0:n.onWrapRequest)==null||f.call(n),o==null||o(p),fe.onWrapSuccess(p),(w=n==null?void 0:n.onWrapSuccess)==null||w.call(n,{txHash:p,explorerUrl:Lt(p,r),amount:Ee(u,s.decimals)}),p},onError:o=>{throw fe.onWrapError(o),o}})},Ps=()=>{const{account:e,walletInteractions:t,chainId:n,callbacks:r,isDev:s}=q(),a=Ds(),{refetch:o}=mr();return it({mutationFn:async()=>{var B,k,_,S;if(!e)throw new Error("missing account");if(!t)throw new Error("missing walletInteractions");if(!n)throw new Error("missing chainId");const{order:u,domain:p,types:f,primaryType:w}=a;fe.onSignOrderRequest(u);let y;try{y=await t.signOrder({domain:p,types:f,primaryType:w,message:u,account:e})}catch(K){throw(B=r==null?void 0:r.onSignOrderError)==null||B.call(r,K),fe.onSignOrderError(K),K}fe.onSignOrderSuccess(y),(k=r==null?void 0:r.onSignOrderSuccess)==null||k.call(r,y);const b=Uo(y),D={v:`0x${b.v.toString(16)}`,r:b.r,s:b.s};(_=r==null?void 0:r.onSignOrderRequest)==null||_.call(r);const O=await jr(u,D,s);return(S=r==null?void 0:r.onOrderCreated)==null||S.call(r,O),await o(),O}})},Os=()=>{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 a=await t.getAllowance({tokenAddress:r,spenderAddress:n.repermit}),o=v(a||"0").lt(v(s).toString());return{allowance:a,approvalRequired:o}}})},Lo=()=>{const{account:e,walletInteractions:t,config:n,chainId:r,callbacks:s}=q(),{mutateAsync:a}=Os();return it({onError:o=>{fe.onApproveError(o)},mutationFn:async({token:o,onHash:u,srcAmountWei:p})=>{var y,b;if(!e)throw new Error("missing account");if(!t)throw new Error("missing walletInteractions");if(!n)throw new Error("missing config");fe.onApproveRequest();const f=await t.approveToken({tokenAddress:o.address,amount:p,spenderAddress:n.repermit});if(!f)throw new Error("failed to approve token");(y=s==null?void 0:s.onApproveRequest)==null||y.call(s),u(f);let w=!1;for(let D=0;D<3;D++){const{approvalRequired:O}=await a({tokenAddress:o.address,srcAmountWei:p});if(!O){w=!0;break}D<2&&await new Promise(B=>setTimeout(B,3e3))}if(!w)throw new Error(`Insufficient ${o.symbol} allowance to perform the swap. Please approve the token first.`);return fe.onApproveSuccess(f),(b=s==null?void 0:s.onApproveSuccess)==null||b.call(s,{txHash:f,explorerUrl:Lt(f,r),token:o,amount:Ee(p,o.decimals)}),f}})},No=()=>{const{account:e,chainId:t,srcToken:n,dstToken:r,module:s,slippage:a}=q(),o=Ct(),u=st().amount,p=Ke().amountPerTrade,f=yr(),w=Ke().totalTrades,y=Nt().fillDelay,b=rr().amount,D=z(O=>O.state.isMarketOrder);return it({mutationFn:async()=>{fe.onRequestOrder({account:e,chainId:t,module:s,srcToken:n,dstToken:r,fromTokenAmount:u,srcChunkAmount:p,triggerPricePerTrade:o.pricePerChunk,deadline:f,fillDelay:y.unit*y.value,minDstAmountOutPerTrade:b,slippage:a,isMarketOrder:D||!1,chunksAmount:w})}})};function qo(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 Is=()=>{const{srcToken:e,dstToken:t,chainId:n,callbacks:r,marketPrice:s}=q(),a=Lo().mutateAsync,o=Ro().mutateAsync,u=Ps().mutateAsync,{mutateAsync:p}=Os(),{update:f}=rn(),{amount:w}=st(),y=No().mutate;return it({mutationFn:async()=>{var D,O;const b=Rt((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 B=es(e,n);f({allowanceLoading:!0,wrapTxHash:void 0,approveTxHash:void 0,acceptedMarketPrice:s,acceptedSrcAmount:w,srcToken:e,dstToken:t,pendingSteps:[]});const{approvalRequired:k}=await p({tokenAddress:B.address,srcAmountWei:w});let _=0,S=1;b&&S++,k&&S++,f({totalSteps:S,stepIndex:_,allowanceLoading:!1,hasApproval:!k,status:Se.LOADING}),y();let K=[];b&&K.push(nt.WRAP),k&&K.push(nt.APPROVE),K.push(nt.CREATE),f({pendingSteps:K}),b&&(f({step:nt.WRAP}),await o({onHash:V=>f({wrapTxHash:V}),srcAmountWei:w}),_++,f({stepIndex:_})),k&&(f({step:nt.APPROVE}),await a({token:B,onHash:V=>f({approveTxHash:V}),srcAmountWei:w}),_++,f({stepIndex:_})),f({step:nt.CREATE});const U=await u();return f({status:Se.SUCCESS,orderId:U.id}),U}catch(B){if(Xn(B))(D=r==null?void 0:r.onSubmitOrderRejected)==null||D.call(r),f({step:void 0,status:void 0,stepIndex:void 0,error:B});else{const k=qo(B);(O=r==null?void 0:r.onSubmitOrderFailed)==null||O.call(r,k),f({status:Se.FAILED,parsedError:k,error:B})}throw B}}})},Ko=()=>{const e=rn(),{srcToken:t,dstToken:n}=q(),r=Is(),s=z(f=>f.resetState),a=F.useCallback(()=>r.mutateAsync(),[r]),{update:o,resetSwap:u,...p}=e;return F.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:u,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}),[a,p,s,u,t,n])},Ho=()=>{const{marketPrice:e,srcToken:t,dstToken:n,marketPriceLoading:r,srcBalance:s,srcUsd1Token:a,noLiquidity:o,typedInputAmount:u}=q(),p=r||v(a||"0").isZero()||s===void 0||v(e||"0").isZero(),f=!!(t&&n&&u&&p),y=!!(is()||o||f||v(u||"0").isZero()||!t||!n);return F.useMemo(()=>({disabled:y,loading:f}),[y,f])},Wo=()=>{const{srcUsd1Token:e,dstUsd1Token:t}=q(),n=st().amountUI,r=xn().amountUI,s=qe(n,e),a=qe(r,t);return{srcAmountUsd:s,dstAmountUsd:a}},zo=()=>{const{fees:e,dstToken:t,dstUsd1Token:n}=q(),{amountUI:r}=xn(),s=F.useMemo(()=>!e||!r?"":v(r).multipliedBy(e).dividedBy(100).toFixed(),[r,e]),a=er((t==null?void 0:t.decimals)||0,s);return{amountUI:s,amount:a,percent:e,usd:qe(s,n)}},Qo=e=>{const t=F.useMemo(()=>!e.minDestAmountPerTrade||!e.totalTrades?"":v(e.minDestAmountPerTrade).multipliedBy(e.totalTrades).decimalPlaces(0).toFixed(),[e.minDestAmountPerTrade,e.totalTrades]),n=F.useMemo(()=>!e.minDestAmountPerTradeUI||!e.totalTrades?"":v(e.minDestAmountPerTradeUI).multipliedBy(e.totalTrades).toFixed(),[e.minDestAmountPerTradeUI,e.totalTrades]),r=F.useMemo(()=>!e.minDestAmountPerTradeUsd||!e.totalTrades?"":v(e.minDestAmountPerTradeUsd).multipliedBy(e.totalTrades).decimalPlaces(2).toFixed(),[e.minDestAmountPerTradeUsd,e.totalTrades]);return F.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 F.useMemo(()=>({spender:e.repermit}),[e])},jo=()=>{const{srcToken:e,dstToken:t,account:n,marketPrice:r}=q(),{spender:s}=$o(),{amount:a}=st(),{amount:o,amountUI:u,usd:p}=wn(),{amountPerTrade:f,amountPerTradeUI:w,amountPerTradeUsd:y,totalTrades:b}=Ke(),D=yr(),{amount:O,amountUI:B,usd:k}=rr(),{amountUI:_,amount:S,usd:K}=Ct(),{milliseconds:U}=Nt(),{amount:V,amountUI:G}=xn(),{srcAmountUsd:oe,dstAmountUsd:i}=Wo(),{amount:c,amountUI:d,percent:E,usd:m}=zo(),g=Ds(),x=z(Z=>Z.state.isMarketOrder),h=z(Z=>Z.state.currentTime),A=rn(),T=Do(),C=A.acceptedSrcAmount||a,P=Ee(r,(t==null?void 0:t.decimals)||0),R=F.useMemo(()=>T===X.TAKE_PROFIT_MARKET||T===X.TAKE_PROFIT_LIMIT||T===X.STOP_LOSS_LIMIT||T===X.STOP_LOSS_MARKET,[T]),L=Qo({srcToken:e,dstToken:t,account:n,orderType:T,createdAt:h,deadline:D,totalTrades:b,tradeInterval:U,srcAmount:C,srcAmountUI:Ee(C,(e==null?void 0:e.decimals)||0),srcAmountUsd:oe,dstAmount:V,dstAmountUI:G,dstAmountUsd:i,limitPrice:x?void 0:o,limitPriceUI:x?void 0:u,limitPriceUsd:x?void 0:p,srcAmountPerTrade:f,srcAmountPerTradeUI:w,srcAmountPerTradeUsd:y,minDestAmountPerTrade:O,minDestAmountPerTradeUI:B,minDestAmountPerTradeUsd:k,triggerPrice:S,triggerPriceUI:_,triggerPriceUsd:K});return F.useMemo(()=>({...L,feesAmountUI:d,feesAmount:c,feesUsd:m||"",feesPercentage:E,rePermitData:g,isTriggerPrice:R,isMarketOrder:x,marketPrice:r,marketPriceUi:P,spender:s}),[L,d,c,m,E,g,R,x,r,P,s])},Vo=()=>{const{supportedChains:e}=q();return F.useMemo(()=>e,[e])},Go=60,Bs=()=>{const{refetch:e}=mr();return it({mutationFn:async t=>{var n;for(let r=0;r<Go;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)===ue.Cancelled)return;await new Promise(o=>setTimeout(o,1e3))}throw new Error("Timed out waiting for order cancellation to be confirmed")}})},Xo=()=>{const e=z(n=>n.updateState),t=z(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})}}},Zo=e=>{const{account:t,walletInteractions:n,config:r,callbacks:s,chainId:a}=q(),o=Bs().mutateAsync,u=Po(),{cancelOrders:p,setCancelOrder:f,clearCancelOrder:w}=Xo(),{mutateAsync:y}=it({mutationFn:async()=>{var B,k,_;if(!t||!n||!r)throw new Error("missing required parameters");if(!e)throw new Error("order is required");const O=e.id;try{(B=s==null?void 0:s.onCancelOrderRequest)==null||B.call(s,e),f(O,{status:Se.LOADING}),fe.onCancelOrderRequest([e.version===1?e.id.toString():e.hash],e.version);const S=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?Xs:Gs});if(!S)throw new Error("failed to cancel order");return fe.onCancelOrderSuccess(S),e.version===1?u(e.id,ue.Cancelled):await o(e.id),(k=s==null?void 0:s.onCancelOrderSuccess)==null||k.call(s,{order:e.version===1?{...e,status:ue.Cancelled}:e,txHash:S,explorerUrl:Lt(S,a)}),f(O,{status:Se.SUCCESS,txHash:S}),S}catch(S){console.error("cancel order error",S),(_=s==null?void 0:s.onCancelOrderFailed)==null||_.call(s,S),Xn(S)?w(O):(f(O,{status:Se.FAILED,error:S.message}),fe.onCancelOrderError(S))}}}),b=F.useMemo(()=>{const O=p[(e==null?void 0:e.id)||""];return{isLoading:(O==null?void 0:O.status)===Se.LOADING,isSuccess:(O==null?void 0:O.status)===Se.SUCCESS,isError:(O==null?void 0:O.status)===Se.FAILED,error:O==null?void 0:O.error,txHash:O==null?void 0:O.txHash}},[p,e==null?void 0:e.id]),D=F.useCallback(async()=>y(),[y]);return F.useMemo(()=>({cancelOrder:D,...b}),[D,b])},Ms=F.createContext(null),Yo=({children:e})=>{const t=Pi(),n=Mi(),r=Ii(),s=Ni(),a=qi(),o=Cn(),u=Ki(),p=Hi(),f=is(),w=Ho(),y=jo(),b=_o(),D=Ko(),O=Vo(),B=Bs(),{module:k}=q(),_={tradesAmountPanel:t,durationPanel:n,fillDelayPanel:r,limitPricePanel:s,triggerPricePanel:a,pricePanel:o,dstTokenPanel:u,disclaimerPanel:p,inputError:f,submitOrderButton:w,derivedFormData:y,orderHistoryPanel:b,orderExecutionPanel:D,supportedChains:O,refetchUntilStatusSynced:B,module:k};return H.jsx(Ms.Provider,{value:_,children:e})},Jo=()=>{const e=F.useContext(Ms);if(e===null)throw new Error("useSpot must be used within SpotProvider");return e},ec=F.createContext(null),gr={didCatch:!1,error:null};class tc extends F.Component{constructor(t){super(t),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=gr}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(gr)}}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&&nc(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(gr)}}render(){const{children:t,fallbackRender:n,FallbackComponent:r,fallback:s}=this.props,{didCatch:a,error:o}=this.state;let u=t;if(a){const p={error:o,resetErrorBoundary:this.resetErrorBoundary};if(typeof n=="function")u=n(p);else if(r)u=F.createElement(r,p);else if(s!==void 0)u=s;else throw o}return F.createElement(ec.Provider,{value:{didCatch:a,error:o,resetErrorBoundary:this.resetErrorBoundary}},u)}}function nc(){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 rc=()=>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 sc({children:e}){return H.jsx(tc,{FallbackComponent:rc,onError:t=>fe.onCrash(t),children:H.jsx(H.Fragment,{children:e})})}const ks=F.createContext(null),ac=new fo({defaultOptions:{queries:{refetchOnWindowFocus:!1}}}),ic=e=>{var r,s,a;const t=z(o=>o.updateState),n=z(o=>o.state.isMarketOrder);return F.useEffect(()=>{const o=setInterval(()=>{t({currentTime:Date.now()})},6e4);return()=>clearInterval(o)},[t]),F.useEffect(()=>{var u,p,f,w,y,b,D,O,B,k,_,S,K,U,V,G;const o=(p=(u=e.overrides)==null?void 0:u.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:(b=(y=e.overrides)==null?void 0:y.state)==null?void 0:b.fillDelay,typedDuration:(O=(D=e.overrides)==null?void 0:D.state)==null?void 0:O.duration,typedLimitPrice:(k=(B=e.overrides)==null?void 0:B.state)==null?void 0:k.limitPrice,typedTriggerPrice:(S=(_=e.overrides)==null?void 0:_.state)==null?void 0:S.triggerPrice,triggerPricePercent:(U=(K=e.overrides)==null?void 0:K.state)==null?void 0:U.triggerPricePercent,limitPricePercent:(G=(V=e.overrides)==null?void 0:V.state)==null?void 0:G.limitPricePercent})},[(r=e.overrides)==null?void 0:r.state,e.module]),F.useEffect(()=>{var o,u,p,f;t({typedLimitPrice:(u=(o=e.overrides)==null?void 0:o.state)==null?void 0:u.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]),F.useEffect(()=>{e.module===j.LIMIT&&t({isMarketOrder:!1})},[e.module]),F.useEffect(()=>{n&&t({isInvertedTrade:!1})},[n]),F.useEffect(()=>{t({typedChunks:void 0})},[e.typedInputAmount]),null},oc=({marketReferencePrice:e,srcToken:t,dstToken:n,chainId:r,typedInputAmount:s})=>F.useMemo(()=>{if(Yn(t,n,r)||Jn(t,n,r))return{isLoading:!1,noLiquidity:!1,value:rt(s||"0",t==null?void 0:t.decimals)};if(v(e.value||0).isZero()||v(s||0).isZero())return e;const a=v(e.value||0).dividedBy(s||0).decimalPlaces(0).toFixed();return{...e,value:a}},[e,s,t,n,r]),cc=e=>{const t=rn(),n=F.useMemo(()=>Lr(e.partner),[e.partner]),r=F.useMemo(()=>{const u=n[0];return e.chainId&&n.includes(e.chainId)?e.chainId:u},[e.chainId,n]),s=F.useMemo(()=>zn(e.partner,r),[e.partner,r]),a=oc(e),o=F.useMemo(()=>Wr(e.minChunkSizeUsd),[e.minChunkSizeUsd]);return F.useEffect(()=>{fe.init(s,o,r,e.appId)},[s,r,o,e.appId]),H.jsxs(ks.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(ic,{...e}),H.jsx(Yo,{children:H.jsx(sc,{children:e.children})})]})},uc=e=>H.jsx(ho,{client:ac,children:H.jsx(cc,{...e})}),q=()=>{const e=F.useContext(ks);if(e===null)throw new Error("useSpotContext must be used within SpotProvider");return e},dc=(e,t,n)=>{const r=bn();return F.useMemo(()=>e==null?void 0:e.map(s=>({rawFill: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:Lt(s.txHash,r==null?void 0:r.id),executionRate:Wn(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])},lc=(e,t,n)=>{const{config:r}=q(),s=Bo(t,n,e),a=Mo(t,n,e),o=ko(t,n,e),u=F.useMemo(()=>e?e.version===2?e.fillDelay:r.twapConfig?Hn(e,r.twapConfig):0:0,[e,r]),p=dc(e==null?void 0:e.fills,t,n)??[];return F.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:u,recipient:e.maker||"",srcAmount:e.srcAmount||"",srcAmountUI:Ee(e.srcAmount,t==null?void 0:t.decimals),limitPrice:rt(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:rt(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:rt(o,n==null?void 0:n.decimals),executionPriceUI:o,version:e.version}},[e,p,t,n,u,s,a,o])};ja(gi.version),I.DISCLAIMER_URL=la,I.Disclaimer=en,I.InputErrors=me,I.Module=j,I.ORBS_LOGO=ua,I.ORBS_SLTP_FAQ_URL=ca,I.ORBS_TWAP_FAQ_URL=oa,I.ORBS_WEBSITE_URL=da,I.OrderFilter=Pr,I.OrderStatus=ue,I.OrderType=X,I.Partners=Pe,I.SPOT_VERSION=fn,I.SpotProvider=uc,I.Steps=nt,I.SwapStatus=Se,I.TimeUnit=De,I.buildRePermitOrderData=zr,I.ensureWrappedToken=es,I.eqIgnoreCase=gt,I.getConfig=zn,I.getExplorerUrl=Lt,I.getMinChunkSizeUsd=Wr,I.getNetwork=Et,I.getOrderExecutionRate=Wn,I.getOrderFillDelayMillis=Hn,I.getOrderLimitPriceRate=Nr,I.getOrderType=wi,I.getPartnerChains=Lr,I.getPartners=Hr,I.getTriggerPriceRate=qr,I.isNativeAddress=Rt,I.isTxRejected=Xn,I.millisToDays=Zn,I.millisToMinutes=En,I.networks=ye,I.parseError=Ti,I.shouldUnwrapOnly=Jn,I.shouldWrapOnly=Yn,I.submitOrder=jr,I.toAmountUi=Ee,I.toAmountWei=rt,I.useAmountUi=bt,I.useCancelOrder=Zo,I.useDerivedHistoryOrder=lc,I.useExplorerLink=xi,I.useNetwork=bn,I.useSignOrder=Ps,I.useSpot=Jo,I.useSubmitOrder=Is,I.useSwapExecution=rn,Object.defineProperty(I,Symbol.toStringTag,{value:"Module"})}));
|
|
64
|
+
`,extractResults:y=>{var E;return(((E=y.data)==null?void 0:E.orderFilleds)||[]).map(v=>({...v,timestamp:new Date(v.timestamp).getTime()}))}})};class fi extends Error{constructor(){super("No graph endpoint found"),this.name="NoGraphEndpointError"}}const pi=async({chainId:e,signal:t,page:n,limit:r,filters:s})=>{try{const a=await ui({chainId:e,signal:t,page:n,limit:r,filters:s}),[o,u]=await Promise.all([li({chainId:e,orders:a,signal:t}),di({chainId:e,orders:a,signal:t})]),f=a.map(T=>{const y=o==null?void 0:o.filter(E=>E.TWAP_id===Number(T.Contract_id)&&At(E.exchange,T.exchange)&&At(E.twapAddress,T.twapAddress));return oi(T,e,y,hi(T,y||[],u))}).sort((T,y)=>y.createdAt-T.createdAt),p=new Set;return f.filter(T=>p.has(T.id)?!1:(p.add(T.id),!0))}catch{return[]}},hi=(e,t,n)=>{var u;const r=(u=n==null?void 0:n.find(f=>f.twapId===e.Contract_id.toString()&&At(f.twapAddress,e.twapAddress)))==null?void 0:u.status,a=Vr(t).reduce((f,p)=>f.plus(p.inAmount),new S(0)).toFixed(),o=Xr(e.ask_srcAmount,a);return mi(o,e.ask_deadline*1e3,r)},Xr=(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))},mi=(e,t,n)=>e===100?ue.Completed:n==="CANCELLED"?ue.Cancelled:n==="COMPLETED"?ue.Completed:t>Date.now()?ue.Open:ue.Expired,yi=async({signal:e,page:t,chainId:n,limit:r,config:s,account:a,isDev:o=!1,includeV1GraphOrders:u=!0})=>(await Promise.all([!s||!u?Promise.resolve([]):pi({chainId:n,signal:e,page:t,limit:r,filters:{accounts:[a],configs:s.twapConfig?[s.twapConfig]:[]}}),ai({chainId:n,signal:e,account:a,exchange:s==null?void 0:s.adapter,partner:s==null?void 0:s.partner,isDev:o})]).then(([T,y])=>[...T,...y])).sort((T,y)=>y.createdAt-T.createdAt),Ai={version:"1.1.38"},Zr=e=>{let t;const n=new Set,r=(p,T)=>{const y=typeof p=="function"?p(t):p;if(!Object.is(y,t)){const E=t;t=T??(typeof y!="object"||y===null)?y:Object.assign({},t,y),n.forEach(v=>v(t,E))}},s=()=>t,u={setState:r,getState:s,getInitialState:()=>f,subscribe:p=>(n.add(p),()=>n.delete(p))},f=t=e(r,s,u);return u},gi=(e=>e?Zr(e):Zr),bi=e=>e;function Ei(e,t=bi){const n=D.useSyncExternalStore(e.subscribe,D.useCallback(()=>t(e.getState()),[e,t]),D.useCallback(()=>t(e.getInitialState()),[e,t]));return D.useDebugValue(n),n}const Yr=e=>{const t=gi(e),n=r=>Ei(t,r);return Object.assign(n,t),n},Ci=(e=>e?Yr(e):Yr),gn={},Jr={currentTime:Date.now(),cancelOrders:{},swapExecutions:[gn],swapExecutionIndex:0},z=Ci((e,t)=>({state:Jr,updateState:n=>e(r=>({state:{...r.state,...n}})),updateSwapExecutionAtIndex:(n,r)=>e(s=>{const a=[...s.state.swapExecutions];return a[n]={...a[n]??gn,...r},{state:{...s.state,swapExecutions:a}}}),resetSwapExecutionAtIndex:()=>e(n=>{const r=[...n.state.swapExecutions];return r[n.state.swapExecutionIndex]=gn,{state:{...n.state,swapExecutions:r}}}),resetState:()=>{const n=t().state;e({state:{...Jr,currentTime:Date.now(),isMarketOrder:n.isMarketOrder,swapExecutions:[...n.swapExecutions,gn],swapExecutionIndex:n.swapExecutionIndex+1}})}}));var Fe=(e=>(e[e.LOADING=1]="LOADING",e[e.SUCCESS=2]="SUCCESS",e[e.FAILED=3]="FAILED",e))(Fe||{}),en=(e=>(e.TRIGGER_MARKET_PRICE="triggerMarketPriceDisclaimer",e.MARKET_PRICE="marketOrderDisclaimer",e.LIMIT_PRICE="limitOrderDisclaimer",e))(en||{}),nt=(e=>(e.WRAP="wrap",e.APPROVE="approve",e.CREATE="create",e))(nt||{});const rt=(e,t)=>!t||!e||S(e).isNaN()?"":S(e).multipliedBy(S(10).pow(t)).toFixed(0),be=(e,t)=>{try{return!t||!e||S(e).isNaN()?"":S(e).dividedBy(S(10).pow(t)).toFixed()}catch(n){return console.error(n),""}},xi=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}},Xn=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"))},es=(e,t)=>{const n=bt(t);return n&&Rt(e.address)?n.wToken:e};function Zn(e){return e?e/864e5:0}function bn(e){return e?e/6e4:0}const Ti=(e,t)=>e?X.TWAP_MARKET:t===1?X.LIMIT:X.TWAP_LIMIT,Yn=(e,t,n)=>{const r=bt(n);return Rt((e==null?void 0:e.address)||"")&&At((t==null?void 0:t.address)||"",(r==null?void 0:r.wToken.address)||"")},Jn=(e,t,n)=>{const r=bt(n);return At((e==null?void 0:e.address)||"",(r==null?void 0:r.wToken.address)||"")&&Rt((t==null?void 0:t.address)||"")},Lt=(e,t)=>{if(!t)return"";const n=bt(t);return`${n==null?void 0:n.explorer}/tx/${e}`},er=(e,t)=>D.useMemo(()=>rt(t,e),[e,t]),Et=(e,t)=>D.useMemo(()=>be(t,e),[e,t]),En=()=>{const{chainId:e}=q();return D.useMemo(()=>bt(e),[e])},wi=e=>{const t=En();return D.useMemo(()=>{if(!(!e||!t))return Lt(e,t.id)},[e,t])},qe=(e,t)=>D.useMemo(()=>!e||!t||S(e||"0").isZero()||S(t||"0").isZero()?"":S(e||"0").times(t).toFixed(),[e,t]),Fi=()=>{const{srcToken:e,dstToken:t,chainId:n}=q();return D.useMemo(()=>Yn(e,t,n),[e,t,n])},Si=()=>{const{srcToken:e,dstToken:t,chainId:n}=q();return D.useMemo(()=>Jn(e,t,n),[e,t,n])},Di=()=>{const e=Fi(),t=Si();return e||t},st=()=>{const{srcToken:e,typedInputAmount:t}=q();return{amount:er(e==null?void 0:e.decimals,t),amountUI:t,error:S(t||0).isZero()?"enterAmount":void 0}},vi=(e,t)=>{const{module:n,srcUsd1Token:r,marketPrice:s,minChunkSizeUsd:a,typedInputAmount:o}=q();return D.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:u}=Ha(e,t,n);if(u)return{type:me.MAX_CHUNKS,value:t,args:{maxChunks:`${t}`}};const{isError:f,value:p}=Ka(o||"",r||"",a||0);if(f)return{type:me.MIN_TRADE_SIZE,value:p,args:{minTradeSize:`${p}`}}},[e,t,n,o,r,a,s])},Ke=()=>{const{srcToken:e,srcUsd1Token:t,module:n,minChunkSizeUsd:r}=q(),s=z(O=>O.state.typedChunks),a=z(O=>O.updateState),{amount:o,amountUI:u}=st(),f=D.useMemo(()=>Pa(u||"",t||"",r||0),[u,t,r]),p=D.useMemo(()=>va(f,n,s),[f,s,n]),T=D.useCallback(O=>a({typedChunks:O}),[a]),y=D.useMemo(()=>Ia(o||"",p),[o,p]),E=Et(e==null?void 0:e.decimals,y),v=D.useMemo(()=>t?S(E||"0").times(t||0).toString():"0",[E,t]);return{totalTrades:p,maxTrades:f,amountPerTradeUI:E,amountPerTrade:y,amountPerTradeUsd:v,onChange:T,error:vi(p,f)}},Pi=()=>{const{srcToken:e,dstToken:t}=q(),{onChange:n,totalTrades:r,amountPerTradeUsd:s,amountPerTradeUI:a,error:o,maxTrades:u,amountPerTrade:f}=Ke();return{error:o,maxTrades:u,totalTrades:r,amountPerTradeUI:a,amountPerTrade:f,onChange:n,amountPerTradeUsd:s,fromToken:e,toToken:t}},ts=e=>{const t=Zn(e);if(t>=1)return`${t.toFixed(t%1?1:0)} ${t===1?"day":"days"}`;const n=bn(e)/60;if(n>=1)return`${n.toFixed(n%1?1:0)} ${n===1?"hour":"hours"}`;const r=bn(e);return`${r.toFixed(r%1?1:0)} ${r===1?"minute":"minutes"}`},Oi=e=>{const{totalTrades:t}=Ke(),{marketPrice:n,typedInputAmount:r}=q(),s=D.useMemo(()=>{const{isError:o,value:u}=qa(e);if(!(!o||S(r||"0").isZero()||!n))return{type:me.MIN_FILL_DELAY,value:u,args:{fillDelay:ts(u)}}},[e,r,n]),a=D.useMemo(()=>{const{isError:o,value:u}=Ma(e,t);if(!(!o||S(r||"0").isZero()||!n))return{type:me.MAX_FILL_DELAY,value:u,args:{fillDelay:ts(u)}}},[e,r,n,t]);return s||a},Nt=()=>{const{callbacks:e}=q(),t=z(a=>a.state.typedFillDelay),n=z(a=>a.updateState),r=D.useMemo(()=>t||Rn,[t]),s=Oi(r);return{fillDelay:r,onChange:D.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}},Bi=()=>{const{onChange:e,fillDelay:t,error:n}=Nt(),r=D.useCallback(a=>e({unit:t.unit,value:Number(a)}),[e,t]),s=D.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}},Ii=e=>{const{module:t,marketPrice:n}=q();return D.useMemo(()=>{const r=La(t,e),s=Na(e);if(n){if(r.isError)return{type:me.MAX_ORDER_DURATION,value:r.value,args:{duration:`${Math.floor(Zn(r.value)).toFixed(0)} days`}};if(s.isError)return{type:me.MIN_ORDER_DURATION,value:s.value,args:{duration:`${Math.floor(bn(s.value)).toFixed(0)} minutes`}}}},[e,t,n])},tr=()=>{const{module:e,callbacks:t}=q(),n=z(f=>f.state.typedDuration),r=z(f=>f.updateState),s=Ke().totalTrades,a=Nt().fillDelay,o=D.useMemo(()=>Da(e,s,a,n),[s,a,n,e]),u=Ii(o);return{duration:o,setDuration:D.useCallback(f=>{var p;r({typedDuration:f}),(p=t==null?void 0:t.onDurationChange)==null||p.call(t,f)},[r,t]),error:u}},Mi=()=>{const{duration:e,setDuration:t,error:n}=tr(),r=D.useCallback(a=>{t({unit:e.unit,value:Number(a)})},[t,e]),s=D.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}},ki=()=>{const{module:e}=q();return D.useMemo(()=>e===j.STOP_LOSS?fa:pa,[e])},nr=()=>{const{module:e}=q(),t=z(n=>n.state.isMarketOrder);return D.useMemo(()=>e!==j.STOP_LOSS&&e!==j.TAKE_PROFIT||t?void 0:e===j.STOP_LOSS?ha:ma,[e,t])},ns=e=>{if(e===void 0||e==="")return e;const t=S(e);return t.isNaN()||t.isZero()?"0":S(1).div(t).toFixed()},Cn=()=>{const{srcToken:e,dstToken:t}=q(),n=z(f=>f.updateState),r=z(f=>f.state.isInvertedTrade),s=z(f=>f.state.typedTriggerPrice),a=z(f=>f.state.typedLimitPrice),o=z(f=>f.state.isMarketOrder);return{onInvert:D.useCallback(()=>{n({isInvertedTrade:!r,...s!==void 0?{typedTriggerPrice:ns(s)}:{},...a!==void 0?{typedLimitPrice:ns(a)}:{}})},[n,r,s,a]),isInverted:r,fromToken:r?t:e,toToken:r?e:t,isMarketPrice:o}},xn=e=>e?S(e).isNaN()?"":e:"",rs=({amount:e,typedValue:t,amountDecimals:n=18,invertedAmountDecimals:r=18,amountUsd:s,invertedAmountUsd:a,isInverted:o})=>{const u=D.useMemo(()=>{if(t!==void 0)return xn(t);const T=be(e,n);return!T||S(T||"0").isZero()?"":o?S(1).div(T).toFixed():T},[e,n,o,t]),f=D.useMemo(()=>u?xn(o?rt(u,r):e):"",[e,u,r,o]),p=qe(u||"0",o?a:s);return{amount:f,amountUI:u,usd:xn(p)}},ss=({typedValue:e,tokenDecimals:t=18,initialPrice:n="0",percentage:r,setValue:s,setPercentage:a})=>{const{isInverted:o}=Cn(),u=D.useMemo(()=>S((()=>{if(e!==void 0){const E=o?S(e).isZero()?S(0):S(1).div(e):S(e);return rt(E.toFixed(),t)}if(r!==void 0&&S(n||"0").gt(0)&&!S(n||"0").isNaN()){const E=S(n||"0"),v=S(r||0).div(100);return E.plus(E.multipliedBy(v)).decimalPlaces(0).toFixed()}return S(n).gt(0)?n:""})()).decimalPlaces(0).toFixed(),[e,r,t,n,o]),f=D.useCallback(y=>{s(y),a(null)},[s,a]),p=D.useCallback(y=>{s(void 0),a(y)},[s,a]),T=D.useMemo(()=>{if(!n||S(n).isZero())return"";if(r!=null)return r;if(u){const y=S(n),v=S(u).minus(y).div(y).multipliedBy(100).decimalPlaces(2).toString();return S(v||"0").isZero()?"":v}return""},[u,n,r]);return{amount:S(u).isNaN()?"":u,typedValue:e,selectedPercentage:T,onChange:f,onPercentageChange:p,isTypedValue:e!==void 0}},_i=(e="")=>{const{module:t,marketPrice:n,typedInputAmount:r}=q();return D.useMemo(()=>{if(S(r||"0").isZero()||!n||t!==j.STOP_LOSS&&t!==j.TAKE_PROFIT)return;const s=ka(n||"",e||"",t);if(s!=null&&s.isError)return{type:me.STOP_LOSS_TRIGGER_PRICE_GREATER_THAN_MARKET_PRICE,value:s.value};const a=_a(n||"",e||"",t);if(a!=null&&a.isError)return{type:me.TAKE_PROFIT_TRIGGER_PRICE_LESS_THAN_MARKET_PRICE,value:a.value};if(!e||S(e||0).isZero())return{type:me.EMPTY_TRIGGER_PRICE,value:e}},[n,e,t,r])},Ui=e=>{const{srcToken:t,dstToken:n,module:r,dstUsd1Token:s}=q(),a=Ke().amountPerTrade,o=z(p=>p.state.isMarketOrder),u=D.useMemo(()=>Sa(r,a,e,(t==null?void 0:t.decimals)||0),[e,a,o,t==null?void 0:t.decimals,r]),f=Et((n==null?void 0:n.decimals)||0,u);return{amount:u,amountUI:f,usd:qe(f,s)}},Ct=()=>{const{dstToken:e,dstUsd1Token:t,marketPrice:n,module:r,callbacks:s}=q(),a=z(_=>_.updateState),o=ki(),u=z(_=>_.state.triggerPricePercent),f=u===void 0?o:u,p=r===j.STOP_LOSS||r===j.TAKE_PROFIT,T=ss({typedValue:z(_=>_.state.typedTriggerPrice),percentage:f,tokenDecimals:(e==null?void 0:e.decimals)||18,initialPrice:p?n:void 0,setValue:D.useCallback(_=>{var F;a({typedTriggerPrice:_}),(F=s==null?void 0:s.onTriggerPriceChange)==null||F.call(s,_||"")},[a,s]),setPercentage:D.useCallback(_=>{var F;a({triggerPricePercent:_}),(F=s==null?void 0:s.onTriggerPricePercentChange)==null||F.call(s,_||"")},[a,s])}),y=_i(T.amount),E=Et((e==null?void 0:e.decimals)||18,T.amount),v=qe(E,t),{amount:O,amountUI:I,usd:k}=Ui(T.amount);return D.useMemo(()=>({...T,amountUI:S(E).isNaN()?"":E,usd:S(v).isNaN()?"":v,error:y,pricePerChunk:O,pricePerChunkUI:I,pricePerChunkUsd:k}),[T,E,v,y,O,I,k])},Ri=e=>{const{module:t,marketPrice:n,typedInputAmount:r}=q(),{amount:s}=Ct(),a=z(o=>o.state.isMarketOrder);return D.useMemo(()=>{if(S(r||"0").isZero()||!s||!n)return;const o=Ua(s,e,a,t),u=Ra(s,e,a,t);if(o!=null&&o.isError)return{type:me.TRIGGER_LIMIT_PRICE_GREATER_THAN_TRIGGER_PRICE,value:o.value};if(u!=null&&u.isError)return{type:me.TRIGGER_LIMIT_PRICE_GREATER_THAN_TRIGGER_PRICE,value:u.value};if(e&&S(e||0).isZero())return{type:me.MISSING_LIMIT_PRICE,value:e||""}},[e,s,t,a,r,n])},Tn=()=>{const{dstToken:e,dstUsd1Token:t,marketPrice:n,callbacks:r}=q(),s=z(E=>E.updateState),a=nr(),o=z(E=>E.state.limitPricePercent),u=o===void 0?a:o,f=ss({typedValue:z(E=>E.state.typedLimitPrice),percentage:u,tokenDecimals:(e==null?void 0:e.decimals)||18,initialPrice:n,setValue:D.useCallback(E=>{var v;s({typedLimitPrice:E}),(v=r==null?void 0:r.onLimitPriceChange)==null||v.call(r,E||"")},[s,r]),setPercentage:D.useCallback(E=>{var v;s({limitPricePercent:E}),(v=r==null?void 0:r.onLimitPricePercentChange)==null||v.call(r,E||"")},[s,r])}),p=Ri(f.amount),T=Et((e==null?void 0:e.decimals)||18,f.amount),y=qe(T,t);return D.useMemo(()=>({...f,amountUI:S(T).isNaN()?"":T,usd:S(y).isNaN()?"":y,error:p}),[f,T,y,p])},Li=()=>{const{module:e}=q(),t=z(u=>u.updateState),n=z(u=>u.state.isMarketOrder),r=nr(),s=z(u=>u.state.triggerPricePercent)||0,a=e===j.LIMIT,o=D.useCallback(()=>{!n&&e===j.STOP_LOSS&&t({limitPricePercent:r}),t({isMarketOrder:!n})},[t,s,e,n,r]);return{isLimitPrice:!n,toggleLimitPrice:o,hide:a}},Ni=()=>{const{module:e,marketPriceLoading:t,srcToken:n,dstToken:r,srcUsd1Token:s,dstUsd1Token:a}=q(),{amount:o,typedValue:u,onChange:f,onPercentageChange:p,selectedPercentage:T,error:y,isTypedValue:E}=Tn(),v=z(G=>G.updateState),O=nr(),{isLimitPrice:I,toggleLimitPrice:k}=Li(),{fromToken:_,toToken:F,isInverted:K}=Cn(),U=rs({amount:o,typedValue:u,amountDecimals:(r==null?void 0:r.decimals)||18,invertedAmountDecimals:(n==null?void 0:n.decimals)||18,amountUsd:a,invertedAmountUsd:s,isInverted:K}),V=D.useCallback(()=>{v({typedLimitPrice:void 0}),v({limitPricePercent:O})},[v,e,O]);return{price:U.amount,priceUI:U.amountUI,error:y,onInputChange:f,onPercentageChange:p,onReset:V,usd:U.usd,srcToken:n,dstToken:r,invertedSrcToken:_,invertedDstToken:F,percentage:T,isLoading:t,isLimitPrice:I,toggleLimitPrice:k,isTypedValue:E}},qi=()=>{const{marketPrice:e,marketPriceLoading:t,srcToken:n,dstToken:r,srcUsd1Token:s,dstUsd1Token:a}=q(),{amount:o,typedValue:u,onChange:f,onPercentageChange:p,selectedPercentage:T,error:y,pricePerChunk:E,pricePerChunkUI:v,pricePerChunkUsd:O,isTypedValue:I}=Ct(),k=z(G=>G.updateState),{fromToken:_,toToken:F,isInverted:K}=Cn(),U=rs({amount:o,typedValue:u,amountDecimals:(r==null?void 0:r.decimals)||18,invertedAmountDecimals:(n==null?void 0:n.decimals)||18,amountUsd:a,invertedAmountUsd:s,isInverted:K}),V=D.useCallback(()=>{k({triggerPricePercent:void 0,typedTriggerPrice:void 0})},[k]);return{price:U.amount,priceUI:U.amountUI,amountPerChunk:E,amountPerChunkUI:v,amountPerChunkUsd:O,error:y,onInputChange:f,onPercentageChange:p,percentage:T,onReset:V,usd:U.usd,srcToken:n,dstToken:r,invertedSrcToken:_,invertedDstToken:F,isLoading:t||!e,isTypedValue:I}},as=()=>{const{module:e,marketPrice:t}=q(),n=Tn().amount,r=Ct().amount,s=z(a=>a.state.isMarketOrder);return e===j.LIMIT||!s?n||"":e===j.STOP_LOSS||e===j.TAKE_PROFIT?r||"":t||""},wn=()=>{const{srcToken:e,dstToken:t,dstUsd1Token:n}=q(),r=as(),s=st().amount,a=D.useMemo(()=>wa(s||"",r,(e==null?void 0:e.decimals)||0),[s,r,e==null?void 0:e.decimals]),o=Et(t==null?void 0:t.decimals,a);return{amount:a,amountUI:o,usd:qe(o,n)}},rr=()=>{const{srcToken:e,dstToken:t,dstUsd1Token:n}=q(),r=as(),s=Ke().amountPerTrade,a=z(f=>f.state.isMarketOrder),o=D.useMemo(()=>Fa(s,r,!!a,(e==null?void 0:e.decimals)||0),[s,r,a,e==null?void 0:e.decimals]),u=Et(t==null?void 0:t.decimals,o);return{amount:o,amountUI:u,usd:qe(u,n)}},Ki=()=>{const{typedInputAmount:e,marketPriceLoading:t,dstToken:n}=q(),{amountUI:r,usd:s}=wn(),o=Di()?e:r,u=er(n==null?void 0:n.decimals,o);return{value:o,valueWei:u,isLoading:t,usd:s}},Hi=()=>{const e=z(s=>s.state.isMarketOrder),{module:t}=q(),n=D.useMemo(()=>{if(e&&t===j.STOP_LOSS)return en.TRIGGER_MARKET_PRICE},[e,t]),r=D.useMemo(()=>{if(!(t!==j.LIMIT&&t!==j.TWAP))return e?en.MARKET_PRICE:en.LIMIT_PRICE},[e,t]);return n||r},Wi=()=>{const{minChunkSizeUsd:e,typedInputAmount:t,srcUsd1Token:n}=q(),r=qe(t,n);return D.useMemo(()=>S(e).gt(S(r||"0"))?{type:me.MIN_TRADE_SIZE_ERROR,value:e,args:{minTradeSize:`${e}`}}:void 0,[e,r])};function is(){const{marketPrice:e,marketPriceLoading:t,typedInputAmount:n,srcUsd1Token:r,srcBalance:s,chainId:a}=q(),{error:o}=Ct(),{error:u}=Tn(),{error:f}=Ke(),{error:p}=Nt(),{error:T}=tr(),y=Wi(),E=st().amount,v=D.useMemo(()=>{if(s&&S(E).gt(s))return{type:me.INSUFFICIENT_BALANCE,value:s||""}},[s,E,a]);return D.useMemo(()=>za({marketPrice:e,typedInputAmount:n,srcUsd1Token:r,marketPriceLoading:t,triggerPriceError:o,limitPriceError:u,tradesError:f,fillDelayError:p,durationError:T,balanceError:v,minTradeSizeError:y}),[e,t,n,o,u,f,p,T,v,r,y])}var qt=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(){}},zi={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Qi=(_s=class{constructor(){N(this,He,zi);N(this,Ft,!1)}setTimeoutProvider(e){process.env.NODE_ENV!=="production"&&l(this,Ft)&&e!==l(this,He)&&console.error("[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",{previous:l(this,He),provider:e}),M(this,He,e),process.env.NODE_ENV!=="production"&&M(this,Ft,!1)}setTimeout(e,t){return process.env.NODE_ENV!=="production"&&M(this,Ft,!0),l(this,He).setTimeout(e,t)}clearTimeout(e){l(this,He).clearTimeout(e)}setInterval(e,t){return process.env.NODE_ENV!=="production"&&M(this,Ft,!0),l(this,He).setInterval(e,t)}clearInterval(e){l(this,He).clearInterval(e)}},He=new WeakMap,Ft=new WeakMap,_s),xt=new Qi;function $i(e){setTimeout(e,0)}var Tt=typeof window>"u"||"Deno"in globalThis;function Ee(){}function ji(e,t){return typeof e=="function"?e(t):e}function sr(e){return typeof e=="number"&&e>=0&&e!==1/0}function os(e,t){return Math.max(e+(t||0)-Date.now(),0)}function at(e,t){return typeof e=="function"?e(t):e}function Me(e,t){return typeof e=="function"?e(t):e}function cs(e,t){const{type:n="all",exact:r,fetchStatus:s,predicate:a,queryKey:o,stale:u}=e;if(o){if(r){if(t.queryHash!==ar(o,t.options))return!1}else if(!tn(t.queryKey,o))return!1}if(n!=="all"){const f=t.isActive();if(n==="active"&&!f||n==="inactive"&&f)return!1}return!(typeof u=="boolean"&&t.isStale()!==u||s&&s!==t.state.fetchStatus||a&&!a(t))}function us(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 ar(e,t){return((t==null?void 0:t.queryKeyHashFn)||wt)(e)}function wt(e){return JSON.stringify(e,(t,n)=>or(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 Vi=Object.prototype.hasOwnProperty;function ir(e,t){if(e===t)return e;const n=ds(e)&&ds(t);if(!n&&!(or(e)&&or(t)))return t;const s=(n?e:Object.keys(e)).length,a=n?t:Object.keys(t),o=a.length,u=n?new Array(o):{};let f=0;for(let p=0;p<o;p++){const T=n?p:a[p],y=e[T],E=t[T];if(y===E){u[T]=y,(n?p<s:Vi.call(e,T))&&f++;continue}if(y===null||E===null||typeof y!="object"||typeof E!="object"){u[T]=E;continue}const v=ir(y,E);u[T]=v,v===y&&f++}return s===o&&f===s?e:u}function Fn(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 ds(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function or(e){if(!ls(e))return!1;const t=e.constructor;if(t===void 0)return!0;const n=t.prototype;return!(!ls(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function ls(e){return Object.prototype.toString.call(e)==="[object Object]"}function Gi(e){return new Promise(t=>{xt.setTimeout(t,e)})}function cr(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 ir(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 ir(e,t)}return t}function Xi(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function Zi(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var Sn=Symbol();function fs(e,t){return process.env.NODE_ENV!=="production"&&e.queryFn===Sn&&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===Sn?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function ps(e,t){return typeof e=="function"?e(...t):!!e}var Yi=(Us=class extends qt{constructor(){super();N(this,St);N(this,ot);N(this,Kt);M(this,Kt,t=>{if(!Tt&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){l(this,ot)||this.setEventListener(l(this,Kt))}onUnsubscribe(){var t;this.hasListeners()||((t=l(this,ot))==null||t.call(this),M(this,ot,void 0))}setEventListener(t){var n;M(this,Kt,t),(n=l(this,ot))==null||n.call(this),M(this,ot,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){l(this,St)!==t&&(M(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,ot=new WeakMap,Kt=new WeakMap,Us),ur=new Yi;function dr(){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 Ji=$i;function eo(){let e=[],t=0,n=u=>{u()},r=u=>{u()},s=Ji;const a=u=>{t?e.push(u):s(()=>{n(u)})},o=()=>{const u=e;e=[],u.length&&s(()=>{r(()=>{u.forEach(f=>{n(f)})})})};return{batch:u=>{let f;t++;try{f=u()}finally{t--,t||o()}return f},batchCalls:u=>(...f)=>{a(()=>{u(...f)})},schedule:a,setNotifyFunction:u=>{n=u},setBatchNotifyFunction:u=>{r=u},setScheduler:u=>{s=u}}}var de=eo(),to=(Rs=class extends qt{constructor(){super();N(this,Ht,!0);N(this,ct);N(this,Wt);M(this,Wt,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,ct)||this.setEventListener(l(this,Wt))}onUnsubscribe(){var t;this.hasListeners()||((t=l(this,ct))==null||t.call(this),M(this,ct,void 0))}setEventListener(t){var n;M(this,Wt,t),(n=l(this,ct))==null||n.call(this),M(this,ct,t(this.setOnline.bind(this)))}setOnline(t){l(this,Ht)!==t&&(M(this,Ht,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return l(this,Ht)}},Ht=new WeakMap,ct=new WeakMap,Wt=new WeakMap,Rs),Dn=new to;function no(e){return Math.min(1e3*2**e,3e4)}function hs(e){return(e??"online")==="online"?Dn.isOnline():!0}var lr=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function ms(e){let t=!1,n=0,r;const s=dr(),a=()=>s.status!=="pending",o=I=>{var k;if(!a()){const _=new lr(I);E(_),(k=e.onCancel)==null||k.call(e,_)}},u=()=>{t=!0},f=()=>{t=!1},p=()=>ur.isFocused()&&(e.networkMode==="always"||Dn.isOnline())&&e.canRun(),T=()=>hs(e.networkMode)&&e.canRun(),y=I=>{a()||(r==null||r(),s.resolve(I))},E=I=>{a()||(r==null||r(),s.reject(I))},v=()=>new Promise(I=>{var k;r=_=>{(a()||p())&&I(_)},(k=e.onPause)==null||k.call(e)}).then(()=>{var I;r=void 0,a()||(I=e.onContinue)==null||I.call(e)}),O=()=>{if(a())return;let I;const k=n===0?e.initialPromise:void 0;try{I=k??e.fn()}catch(_){I=Promise.reject(_)}Promise.resolve(I).then(y).catch(_=>{var G;if(a())return;const F=e.retry??(Tt?0:3),K=e.retryDelay??no,U=typeof K=="function"?K(n,_):K,V=F===!0||typeof F=="number"&&n<F||typeof F=="function"&&F(n,_);if(t||!V){E(_);return}n++,(G=e.onFail)==null||G.call(e,n,_),Gi(U).then(()=>p()?void 0:v()).then(()=>{t?E(_):O()})})};return{promise:s,status:()=>s.status,cancel:o,continue:()=>(r==null||r(),s),cancelRetry:u,continueRetry:f,canStart:T,start:()=>(T()?O():v().then(O),s)}}var ys=(Ls=class{constructor(){N(this,Dt)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),sr(this.gcTime)&&M(this,Dt,xt.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Tt?1/0:300*1e3))}clearGcTimeout(){l(this,Dt)&&(xt.clearTimeout(l(this,Dt)),M(this,Dt,void 0))}},Dt=new WeakMap,Ls),ro=(Ns=class extends ys{constructor(t){super();N(this,Le);N(this,vt);N(this,zt);N(this,ke);N(this,Pt);N(this,he);N(this,sn);N(this,Ot);M(this,Ot,!1),M(this,sn,t.defaultOptions),this.setOptions(t.options),this.observers=[],M(this,Pt,t.client),M(this,ke,l(this,Pt).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,M(this,vt,bs(this.options)),this.state=t.state??l(this,vt),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,sn),...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const n=bs(this.options);n.data!==void 0&&(this.setState(gs(n.data,n.dataUpdatedAt)),M(this,vt,n))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&l(this,ke).remove(this)}setData(t,n){const r=cr(this.state.data,t,this.options);return Q(this,Le,et).call(this,{data:r,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),r}setState(t,n){Q(this,Le,et).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(Ee).catch(Ee):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(l(this,vt))}isActive(){return this.observers.some(t=>Me(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Sn||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>at(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:!os(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,ke).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,Ot)?l(this,he).cancel({revert:!0}):l(this,he).cancelRetry()),this.scheduleGc()),l(this,ke).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||Q(this,Le,et).call(this,{type:"invalidate"})}async fetch(t,n){var f,p,T,y,E,v,O,I,k,_,F,K;if(this.state.fetchStatus!=="idle"&&((f=l(this,he))==null?void 0:f.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(V=>V.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:()=>(M(this,Ot,!0),r.signal)})},a=()=>{const U=fs(this.options,n),G=(()=>{const oe={client:l(this,Pt),queryKey:this.queryKey,meta:this.meta};return s(oe),oe})();return M(this,Ot,!1),this.options.persister?this.options.persister(U,G,this):U(G)},u=(()=>{const U={fetchOptions:n,options:this.options,queryKey:this.queryKey,client:l(this,Pt),state:this.state,fetchFn:a};return s(U),U})();(p=this.options.behavior)==null||p.onFetch(u,this),M(this,zt,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((T=u.fetchOptions)==null?void 0:T.meta))&&Q(this,Le,et).call(this,{type:"fetch",meta:(y=u.fetchOptions)==null?void 0:y.meta}),M(this,he,ms({initialPromise:n==null?void 0:n.initialPromise,fn:u.fetchFn,onCancel:U=>{U instanceof lr&&U.revert&&this.setState({...l(this,zt),fetchStatus:"idle"}),r.abort()},onFail:(U,V)=>{Q(this,Le,et).call(this,{type:"failed",failureCount:U,error:V})},onPause:()=>{Q(this,Le,et).call(this,{type:"pause"})},onContinue:()=>{Q(this,Le,et).call(this,{type:"continue"})},retry:u.options.retry,retryDelay:u.options.retryDelay,networkMode:u.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),(v=(E=l(this,ke).config).onSuccess)==null||v.call(E,U,this),(I=(O=l(this,ke).config).onSettled)==null||I.call(O,U,this.state.error,this),U}catch(U){if(U instanceof lr){if(U.silent)return l(this,he).promise;if(U.revert){if(this.state.data===void 0)throw U;return this.state.data}}throw Q(this,Le,et).call(this,{type:"error",error:U}),(_=(k=l(this,ke).config).onError)==null||_.call(k,U,this),(K=(F=l(this,ke).config).onSettled)==null||K.call(F,this.state.data,U,this),U}finally{this.scheduleGc()}}},vt=new WeakMap,zt=new WeakMap,ke=new WeakMap,Pt=new WeakMap,he=new WeakMap,sn=new WeakMap,Ot=new WeakMap,Le=new WeakSet,et=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,...As(r.data,this.options),fetchMeta:t.meta??null};case"success":const s={...r,...gs(t.data,t.dataUpdatedAt),dataUpdateCount:r.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return M(this,zt,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),de.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),l(this,ke).notify({query:this,type:"updated",action:t})})},Ns);function As(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:hs(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function gs(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function bs(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 so=(qs=class extends qt{constructor(t,n){super();N(this,ee);N(this,Se);N(this,Y);N(this,an);N(this,Ce);N(this,Bt);N(this,Qt);N(this,Ge);N(this,ut);N(this,on);N(this,$t);N(this,jt);N(this,It);N(this,Mt);N(this,dt);N(this,Vt,new Set);this.options=n,M(this,Se,t),M(this,ut,null),M(this,Ge,dr()),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(l(this,Y).addObserver(this),Es(l(this,Y),this.options)?Q(this,ee,ln).call(this):this.updateResult(),Q(this,ee,wr).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return fr(l(this,Y),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return fr(l(this,Y),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,Q(this,ee,Fr).call(this),Q(this,ee,Sr).call(this),l(this,Y).removeObserver(this)}setOptions(t){const n=this.options,r=l(this,Y);if(this.options=l(this,Se).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Me(this.options.enabled,l(this,Y))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");Q(this,ee,Dr).call(this),l(this,Y).setOptions(this.options),n._defaulted&&!Fn(this.options,n)&&l(this,Se).getQueryCache().notify({type:"observerOptionsUpdated",query:l(this,Y),observer:this});const s=this.hasListeners();s&&Cs(l(this,Y),r,this.options,n)&&Q(this,ee,ln).call(this),this.updateResult(),s&&(l(this,Y)!==r||Me(this.options.enabled,l(this,Y))!==Me(n.enabled,l(this,Y))||at(this.options.staleTime,l(this,Y))!==at(n.staleTime,l(this,Y)))&&Q(this,ee,Cr).call(this);const a=Q(this,ee,xr).call(this);s&&(l(this,Y)!==r||Me(this.options.enabled,l(this,Y))!==Me(n.enabled,l(this,Y))||a!==l(this,dt))&&Q(this,ee,Tr).call(this,a)}getOptimisticResult(t){const n=l(this,Se).getQueryCache().build(l(this,Se),t),r=this.createResult(n,t);return io(this,r)&&(M(this,Ce,r),M(this,Qt,this.options),M(this,Bt,l(this,Y).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,Ge).status==="pending"&&l(this,Ge).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(r,s))})}trackProp(t){l(this,Vt).add(t)}getCurrentQuery(){return l(this,Y)}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 Q(this,ee,ln).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),l(this,Ce)))}createResult(t,n){var c;const r=l(this,Y),s=this.options,a=l(this,Ce),o=l(this,Bt),u=l(this,Qt),p=t!==r?t.state:l(this,an),{state:T}=t;let y={...T},E=!1,v;if(n._optimisticResults){const d=this.hasListeners(),b=!d&&Es(t,n),m=d&&Cs(t,r,n,s);(b||m)&&(y={...y,...As(T.data,t.options)}),n._optimisticResults==="isRestoring"&&(y.fetchStatus="idle")}let{error:O,errorUpdatedAt:I,status:k}=y;v=y.data;let _=!1;if(n.placeholderData!==void 0&&v===void 0&&k==="pending"){let d;a!=null&&a.isPlaceholderData&&n.placeholderData===(u==null?void 0:u.placeholderData)?(d=a.data,_=!0):d=typeof n.placeholderData=="function"?n.placeholderData((c=l(this,jt))==null?void 0:c.state.data,l(this,jt)):n.placeholderData,d!==void 0&&(k="success",v=cr(a==null?void 0:a.data,d,n),E=!0)}if(n.select&&v!==void 0&&!_)if(a&&v===(o==null?void 0:o.data)&&n.select===l(this,on))v=l(this,$t);else try{M(this,on,n.select),v=n.select(v),v=cr(a==null?void 0:a.data,v,n),M(this,$t,v),M(this,ut,null)}catch(d){M(this,ut,d)}l(this,ut)&&(O=l(this,ut),v=l(this,$t),I=Date.now(),k="error");const F=y.fetchStatus==="fetching",K=k==="pending",U=k==="error",V=K&&F,G=v!==void 0,i={status:k,fetchStatus:y.fetchStatus,isPending:K,isSuccess:k==="success",isError:U,isInitialLoading:V,isLoading:V,data:v,dataUpdatedAt:y.dataUpdatedAt,error:O,errorUpdatedAt:I,failureCount:y.fetchFailureCount,failureReason:y.fetchFailureReason,errorUpdateCount:y.errorUpdateCount,isFetched:y.dataUpdateCount>0||y.errorUpdateCount>0,isFetchedAfterMount:y.dataUpdateCount>p.dataUpdateCount||y.errorUpdateCount>p.errorUpdateCount,isFetching:F,isRefetching:F&&!K,isLoadingError:U&&!G,isPaused:y.fetchStatus==="paused",isPlaceholderData:E,isRefetchError:U&&G,isStale:pr(t,n),refetch:this.refetch,promise:l(this,Ge),isEnabled:Me(n.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const d=A=>{i.status==="error"?A.reject(i.error):i.data!==void 0&&A.resolve(i.data)},b=()=>{const A=M(this,Ge,i.promise=dr());d(A)},m=l(this,Ge);switch(m.status){case"pending":t.queryHash===r.queryHash&&d(m);break;case"fulfilled":(i.status==="error"||i.data!==m.value)&&b();break;case"rejected":(i.status!=="error"||i.error!==m.reason)&&b();break}}return i}updateResult(){const t=l(this,Ce),n=this.createResult(l(this,Y),this.options);if(M(this,Bt,l(this,Y).state),M(this,Qt,this.options),l(this,Bt).data!==void 0&&M(this,jt,l(this,Y)),Fn(n,t))return;M(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,Vt).size)return!0;const o=new Set(a??l(this,Vt));return this.options.throwOnError&&o.add("error"),Object.keys(l(this,Ce)).some(u=>{const f=u;return l(this,Ce)[f]!==t[f]&&o.has(f)})};Q(this,ee,js).call(this,{listeners:r()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&Q(this,ee,wr).call(this)}},Se=new WeakMap,Y=new WeakMap,an=new WeakMap,Ce=new WeakMap,Bt=new WeakMap,Qt=new WeakMap,Ge=new WeakMap,ut=new WeakMap,on=new WeakMap,$t=new WeakMap,jt=new WeakMap,It=new WeakMap,Mt=new WeakMap,dt=new WeakMap,Vt=new WeakMap,ee=new WeakSet,ln=function(t){Q(this,ee,Dr).call(this);let n=l(this,Y).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(Ee)),n},Cr=function(){Q(this,ee,Fr).call(this);const t=at(this.options.staleTime,l(this,Y));if(Tt||l(this,Ce).isStale||!sr(t))return;const r=os(l(this,Ce).dataUpdatedAt,t)+1;M(this,It,xt.setTimeout(()=>{l(this,Ce).isStale||this.updateResult()},r))},xr=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(l(this,Y)):this.options.refetchInterval)??!1},Tr=function(t){Q(this,ee,Sr).call(this),M(this,dt,t),!(Tt||Me(this.options.enabled,l(this,Y))===!1||!sr(l(this,dt))||l(this,dt)===0)&&M(this,Mt,xt.setInterval(()=>{(this.options.refetchIntervalInBackground||ur.isFocused())&&Q(this,ee,ln).call(this)},l(this,dt)))},wr=function(){Q(this,ee,Cr).call(this),Q(this,ee,Tr).call(this,Q(this,ee,xr).call(this))},Fr=function(){l(this,It)&&(xt.clearTimeout(l(this,It)),M(this,It,void 0))},Sr=function(){l(this,Mt)&&(xt.clearInterval(l(this,Mt)),M(this,Mt,void 0))},Dr=function(){const t=l(this,Se).getQueryCache().build(l(this,Se),this.options);if(t===l(this,Y))return;const n=l(this,Y);M(this,Y,t),M(this,an,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},js=function(t){de.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(l(this,Ce))}),l(this,Se).getQueryCache().notify({query:l(this,Y),type:"observerResultsUpdated"})})},qs);function ao(e,t){return Me(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function Es(e,t){return ao(e,t)||e.state.data!==void 0&&fr(e,t,t.refetchOnMount)}function fr(e,t,n){if(Me(t.enabled,e)!==!1&&at(t.staleTime,e)!=="static"){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&pr(e,t)}return!1}function Cs(e,t,n,r){return(e!==t||Me(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&pr(e,n)}function pr(e,t){return Me(t.enabled,e)!==!1&&e.isStaleByTime(at(t.staleTime,e))}function io(e,t){return!Fn(e.getCurrentResult(),t)}function xs(e){return{onFetch:(t,n)=>{var T,y,E,v,O;const r=t.options,s=(E=(y=(T=t.fetchOptions)==null?void 0:T.meta)==null?void 0:y.fetchMore)==null?void 0:E.direction,a=((v=t.state.data)==null?void 0:v.pages)||[],o=((O=t.state.data)==null?void 0:O.pageParams)||[];let u={pages:[],pageParams:[]},f=0;const p=async()=>{let I=!1;const k=K=>{Object.defineProperty(K,"signal",{enumerable:!0,get:()=>(t.signal.aborted?I=!0:t.signal.addEventListener("abort",()=>{I=!0}),t.signal)})},_=fs(t.options,t.fetchOptions),F=async(K,U,V)=>{if(I)return Promise.reject();if(U==null&&K.pages.length)return Promise.resolve(K);const oe=(()=>{const b={client:t.client,queryKey:t.queryKey,pageParam:U,direction:V?"backward":"forward",meta:t.options.meta};return k(b),b})(),i=await _(oe),{maxPages:c}=t.options,d=V?Zi:Xi;return{pages:d(K.pages,i,c),pageParams:d(K.pageParams,U,c)}};if(s&&a.length){const K=s==="backward",U=K?oo:Ts,V={pages:a,pageParams:o},G=U(r,V);u=await F(V,G,K)}else{const K=e??a.length;do{const U=f===0?o[0]??r.initialPageParam:Ts(r,u);if(f>0&&U==null)break;u=await F(u,U),f++}while(f<K)}return u};t.options.persister?t.fetchFn=()=>{var I,k;return(k=(I=t.options).persister)==null?void 0:k.call(I,p,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=p}}}function Ts(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 oo(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 co=(Ks=class extends ys{constructor(t){super();N(this,ze);N(this,cn);N(this,We);N(this,xe);N(this,kt);M(this,cn,t.client),this.mutationId=t.mutationId,M(this,xe,t.mutationCache),M(this,We,[]),this.state=t.state||ws(),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,We).includes(t)||(l(this,We).push(t),this.clearGcTimeout(),l(this,xe).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){M(this,We,l(this,We).filter(n=>n!==t)),this.scheduleGc(),l(this,xe).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){l(this,We).length||(this.state.status==="pending"?this.scheduleGc():l(this,xe).remove(this))}continue(){var t;return((t=l(this,kt))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var o,u,f,p,T,y,E,v,O,I,k,_,F,K,U,V,G,oe,i,c;const n=()=>{Q(this,ze,mt).call(this,{type:"continue"})},r={client:l(this,cn),meta:this.options.meta,mutationKey:this.options.mutationKey};M(this,kt,ms({fn:()=>this.options.mutationFn?this.options.mutationFn(t,r):Promise.reject(new Error("No mutationFn found")),onFail:(d,b)=>{Q(this,ze,mt).call(this,{type:"failed",failureCount:d,error:b})},onPause:()=>{Q(this,ze,mt).call(this,{type:"pause"})},onContinue:n,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>l(this,xe).canRun(this)}));const s=this.state.status==="pending",a=!l(this,kt).canStart();try{if(s)n();else{Q(this,ze,mt).call(this,{type:"pending",variables:t,isPaused:a}),await((u=(o=l(this,xe).config).onMutate)==null?void 0:u.call(o,t,this,r));const b=await((p=(f=this.options).onMutate)==null?void 0:p.call(f,t,r));b!==this.state.context&&Q(this,ze,mt).call(this,{type:"pending",context:b,variables:t,isPaused:a})}const d=await l(this,kt).start();return await((y=(T=l(this,xe).config).onSuccess)==null?void 0:y.call(T,d,t,this.state.context,this,r)),await((v=(E=this.options).onSuccess)==null?void 0:v.call(E,d,t,this.state.context,r)),await((I=(O=l(this,xe).config).onSettled)==null?void 0:I.call(O,d,null,this.state.variables,this.state.context,this,r)),await((_=(k=this.options).onSettled)==null?void 0:_.call(k,d,null,t,this.state.context,r)),Q(this,ze,mt).call(this,{type:"success",data:d}),d}catch(d){try{throw await((K=(F=l(this,xe).config).onError)==null?void 0:K.call(F,d,t,this.state.context,this,r)),await((V=(U=this.options).onError)==null?void 0:V.call(U,d,t,this.state.context,r)),await((oe=(G=l(this,xe).config).onSettled)==null?void 0:oe.call(G,void 0,d,this.state.variables,this.state.context,this,r)),await((c=(i=this.options).onSettled)==null?void 0:c.call(i,void 0,d,t,this.state.context,r)),d}finally{Q(this,ze,mt).call(this,{type:"error",error:d})}}finally{l(this,xe).runNext(this)}}},cn=new WeakMap,We=new WeakMap,xe=new WeakMap,kt=new WeakMap,ze=new WeakSet,mt=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),de.batch(()=>{l(this,We).forEach(r=>{r.onMutationUpdate(t)}),l(this,xe).notify({mutation:this,type:"updated",action:t})})},Ks);function ws(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var uo=(Hs=class extends qt{constructor(t={}){super();N(this,Xe);N(this,Ne);N(this,un);this.config=t,M(this,Xe,new Set),M(this,Ne,new Map),M(this,un,0)}build(t,n,r){const s=new co({client:t,mutationCache:this,mutationId:++In(this,un)._,options:t.defaultMutationOptions(n),state:r});return this.add(s),s}add(t){l(this,Xe).add(t);const n=vn(t);if(typeof n=="string"){const r=l(this,Ne).get(n);r?r.push(t):l(this,Ne).set(n,[t])}this.notify({type:"added",mutation:t})}remove(t){if(l(this,Xe).delete(t)){const n=vn(t);if(typeof n=="string"){const r=l(this,Ne).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,Ne).delete(n)}}this.notify({type:"removed",mutation:t})}canRun(t){const n=vn(t);if(typeof n=="string"){const r=l(this,Ne).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=vn(t);if(typeof n=="string"){const s=(r=l(this,Ne).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(){de.batch(()=>{l(this,Xe).forEach(t=>{this.notify({type:"removed",mutation:t})}),l(this,Xe).clear(),l(this,Ne).clear()})}getAll(){return Array.from(l(this,Xe))}find(t){const n={exact:!0,...t};return this.getAll().find(r=>us(n,r))}findAll(t={}){return this.getAll().filter(n=>us(t,n))}notify(t){de.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){const t=this.getAll().filter(n=>n.state.isPaused);return de.batch(()=>Promise.all(t.map(n=>n.continue().catch(Ee))))}},Xe=new WeakMap,Ne=new WeakMap,un=new WeakMap,Hs);function vn(e){var t;return(t=e.options.scope)==null?void 0:t.id}var lo=(Ws=class extends qt{constructor(t,n){super();N(this,Je);N(this,Ze);N(this,lt);N(this,De);N(this,Ye);M(this,Ze,t),this.setOptions(n),this.bindMethods(),Q(this,Je,Mn).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,Ze).defaultMutationOptions(t),Fn(this.options,n)||l(this,Ze).getMutationCache().notify({type:"observerOptionsUpdated",mutation:l(this,De),observer:this}),n!=null&&n.mutationKey&&this.options.mutationKey&&wt(n.mutationKey)!==wt(this.options.mutationKey)?this.reset():((r=l(this,De))==null?void 0:r.state.status)==="pending"&&l(this,De).setOptions(this.options)}onUnsubscribe(){var t;this.hasListeners()||(t=l(this,De))==null||t.removeObserver(this)}onMutationUpdate(t){Q(this,Je,Mn).call(this),Q(this,Je,vr).call(this,t)}getCurrentResult(){return l(this,lt)}reset(){var t;(t=l(this,De))==null||t.removeObserver(this),M(this,De,void 0),Q(this,Je,Mn).call(this),Q(this,Je,vr).call(this)}mutate(t,n){var r;return M(this,Ye,n),(r=l(this,De))==null||r.removeObserver(this),M(this,De,l(this,Ze).getMutationCache().build(l(this,Ze),this.options)),l(this,De).addObserver(this),l(this,De).execute(t)}},Ze=new WeakMap,lt=new WeakMap,De=new WeakMap,Ye=new WeakMap,Je=new WeakSet,Mn=function(){var n;const t=((n=l(this,De))==null?void 0:n.state)??ws();M(this,lt,{...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset})},vr=function(t){de.batch(()=>{var n,r,s,a,o,u,f,p;if(l(this,Ye)&&this.hasListeners()){const T=l(this,lt).variables,y=l(this,lt).context,E={client:l(this,Ze),meta:this.options.meta,mutationKey:this.options.mutationKey};(t==null?void 0:t.type)==="success"?((r=(n=l(this,Ye)).onSuccess)==null||r.call(n,t.data,T,y,E),(a=(s=l(this,Ye)).onSettled)==null||a.call(s,t.data,null,T,y,E)):(t==null?void 0:t.type)==="error"&&((u=(o=l(this,Ye)).onError)==null||u.call(o,t.error,T,y,E),(p=(f=l(this,Ye)).onSettled)==null||p.call(f,void 0,t.error,T,y,E))}this.listeners.forEach(T=>{T(l(this,lt))})})},Ws),fo=(zs=class extends qt{constructor(t={}){super();N(this,Qe);this.config=t,M(this,Qe,new Map)}build(t,n,r){const s=n.queryKey,a=n.queryHash??ar(s,n);let o=this.get(a);return o||(o=new ro({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(){de.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=>cs(n,r))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(r=>cs(t,r)):n}notify(t){de.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){de.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){de.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Qe=new WeakMap,zs),po=(Qs=class{constructor(e={}){N(this,se);N(this,ft);N(this,pt);N(this,Gt);N(this,Xt);N(this,ht);N(this,Zt);N(this,Yt);M(this,se,e.queryCache||new fo),M(this,ft,e.mutationCache||new uo),M(this,pt,e.defaultOptions||{}),M(this,Gt,new Map),M(this,Xt,new Map),M(this,ht,0)}mount(){In(this,ht)._++,l(this,ht)===1&&(M(this,Zt,ur.subscribe(async e=>{e&&(await this.resumePausedMutations(),l(this,se).onFocus())})),M(this,Yt,Dn.subscribe(async e=>{e&&(await this.resumePausedMutations(),l(this,se).onOnline())})))}unmount(){var e,t;In(this,ht)._--,l(this,ht)===0&&((e=l(this,Zt))==null||e.call(this),M(this,Zt,void 0),(t=l(this,Yt))==null||t.call(this),M(this,Yt,void 0))}isFetching(e){return l(this,se).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return l(this,ft).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(at(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=ji(t,a);if(o!==void 0)return l(this,se).build(this,r).setData(o,{...n,manual:!0})}setQueriesData(e,t,n){return de.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);de.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=l(this,se);return de.batch(()=>(n.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},r=de.batch(()=>l(this,se).findAll(e).map(s=>s.cancel(n)));return Promise.all(r).then(Ee).catch(Ee)}invalidateQueries(e,t={}){return de.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=de.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(Ee)),s.state.fetchStatus==="paused"?Promise.resolve():a}));return Promise.all(r).then(Ee)}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(at(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Ee).catch(Ee)}fetchInfiniteQuery(e){return e.behavior=xs(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Ee).catch(Ee)}ensureInfiniteQueryData(e){return e.behavior=xs(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return Dn.isOnline()?l(this,ft).resumePausedMutations():Promise.resolve()}getQueryCache(){return l(this,se)}getMutationCache(){return l(this,ft)}getDefaultOptions(){return l(this,pt)}setDefaultOptions(e){M(this,pt,e)}setQueryDefaults(e,t){l(this,Gt).set(wt(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...l(this,Gt).values()],n={};return t.forEach(r=>{tn(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){l(this,Xt).set(wt(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...l(this,Xt).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=ar(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===Sn&&(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,ft).clear()}},se=new WeakMap,ft=new WeakMap,pt=new WeakMap,Gt=new WeakMap,Xt=new WeakMap,ht=new WeakMap,Zt=new WeakMap,Yt=new WeakMap,Qs),Fs=ce.createContext(void 0),nn=e=>{const t=ce.useContext(Fs);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},ho=({client:e,children:t})=>(ce.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),H.jsx(Fs.Provider,{value:e,children:t})),Ss=ce.createContext(!1),mo=()=>ce.useContext(Ss);Ss.Provider;function yo(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var Ao=ce.createContext(yo()),go=()=>ce.useContext(Ao),bo=(e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))},Eo=e=>{ce.useEffect(()=>{e.clearReset()},[e])},Co=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:s})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(s&&e.data===void 0||ps(n,[e.error,r])),xo=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))}},To=(e,t)=>e.isLoading&&e.isFetching&&!t,wo=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,Ds=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function Fo(e,t,n){var y,E,v,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=mo(),s=go(),a=nn(),o=a.defaultQueryOptions(e);(E=(y=a.getDefaultOptions().queries)==null?void 0:y._experimental_beforeQuery)==null||E.call(y,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",xo(o),bo(o,s),Eo(s);const u=!a.getQueryCache().get(o.queryHash),[f]=ce.useState(()=>new t(a,o)),p=f.getOptimisticResult(o),T=!r&&e.subscribed!==!1;if(ce.useSyncExternalStore(ce.useCallback(k=>{const _=T?f.subscribe(de.batchCalls(k)):Ee;return f.updateResult(),_},[f,T]),()=>f.getCurrentResult(),()=>f.getCurrentResult()),ce.useEffect(()=>{f.setOptions(o)},[o,f]),wo(o,p))throw Ds(o,f,s);if(Co({result:p,errorResetBoundary:s,throwOnError:o.throwOnError,query:a.getQueryCache().get(o.queryHash),suspense:o.suspense}))throw p.error;if((O=(v=a.getDefaultOptions().queries)==null?void 0:v._experimental_afterQuery)==null||O.call(v,o,p),o.experimental_prefetchInRender&&!Tt&&To(p,r)){const k=u?Ds(o,f,s):(I=a.getQueryCache().get(o.queryHash))==null?void 0:I.promise;k==null||k.catch(Ee).finally(()=>{f.updateResult()})}return o.notifyOnChangeProps?p:f.trackResult(p)}function So(e,t){return Fo(e,so)}function it(e,t){const n=nn(),[r]=ce.useState(()=>new lo(n,e));ce.useEffect(()=>{r.setOptions(e)},[r,e]);const s=ce.useSyncExternalStore(ce.useCallback(o=>r.subscribe(de.batchCalls(o)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=ce.useCallback((o,u)=>{r.mutate(o,u).catch(Ee)},[r]);if(s.error&&ps(r.options.throwOnError,[s.error]))throw s.error;return{...s,mutate:a,mutateAsync:s.mutate}}const rn=()=>{const e=z(a=>a.state.swapExecutionIndex),t=z(a=>a.state.swapExecutions[a.state.swapExecutionIndex]??{}),n=z(a=>a.updateSwapExecutionAtIndex),r=z(a=>a.resetSwapExecutionAtIndex),s=D.useCallback(a=>n(e,a),[n,e]);return D.useMemo(()=>({...t,update:s,resetSwap:r}),[t,s,r])},Do=2e4,vo=()=>{const{module:e}=q(),t=z(n=>n.state.isMarketOrder);return D.useMemo(()=>e===j.TWAP?t?X.TWAP_MARKET:X.TWAP_LIMIT:e===j.LIMIT?X.LIMIT:e===j.STOP_LOSS?t?X.STOP_LOSS_MARKET:X.STOP_LOSS_LIMIT:e===j.TAKE_PROFIT?t?X.TAKE_PROFIT_MARKET:X.TAKE_PROFIT_LIMIT:X.TWAP_MARKET,[e,t])},hr=()=>{const{account:e,config:t,chainId:n,isDev:r}=q();return D.useMemo(()=>["useTwapOrderHistoryManager",e,t==null?void 0:t.adapter,t==null?void 0:t.partner,n,r],[e,t,n,r])},Po=()=>{const e=nn(),t=hr();return D.useCallback((n,r)=>{e.setQueryData(t,s=>s==null?void 0:s.map(a=>a.id===n?{...a,status:r}:a))},[e,t])},Oo=()=>{const{callbacks:e}=q(),t=nn(),n=hr();return D.useCallback(r=>{var u;const s=t.getQueryData(n);let a=!1;const o=[];s&&s.filter(f=>f.version===2).forEach(f=>{var T;const p=r.find(y=>y.id===f.id);p&&p.progress!==f.progress&&(a=!0,o.push(p),p.status===ue.Completed&&((T=e==null?void 0:e.onOrderFilled)==null||T.call(e,p)))}),a&&((u=e==null?void 0:e.onOrdersProgressUpdate)==null||u.call(e,o))},[t,n,e])},Bo=(e,t)=>{const n=new Set(e.map(s=>s.id)),r=(t==null?void 0:t.filter(s=>s.version===1&&!n.has(s.id)))??[];return[...e,...r].sort((s,a)=>a.createdAt-s.createdAt)},mr=()=>{const{account:e,config:t,chainId:n,isDev:r}=q(),s=nn(),a=hr(),o=Oo();return So({refetchInterval:Do,refetchOnWindowFocus:!0,retry:!1,gcTime:1/0,staleTime:1/0,queryKey:a,queryFn:async({signal:f})=>{if(!e||!n||!t)return[];const p=s.getQueryData(a),T=!p,y=await yi({signal:f,chainId:n,config:t,account:e,isDev:r,includeV1GraphOrders:T});o(y);const E=y.map(v=>t!=null&&t.twapConfig?{...v,fillDelayMillis:Hn(v,t.twapConfig)}:v);return T?E:Bo(E,p)}})},Io=(e,t,n)=>D.useMemo(()=>{if(!(!e||!t||!n||n!=null&&n.isMarketPrice))return Nr(n,e==null?void 0:e.decimals,t==null?void 0:t.decimals)},[n,e,t]),Mo=(e,t,n)=>D.useMemo(()=>{if(!(!e||!t||!n))return qr(n,e.decimals,t.decimals)},[n,e,t]),ko=(e,t,n)=>D.useMemo(()=>{if(!(!e||!t||!n))return Wn(n.srcAmountFilled,n.dstAmountFilled,e.decimals,t.decimals)},[n,e,t]),Pn=(e,t)=>[...e.filter(r=>r.status===t)].sort((r,s)=>s.createdAt-r.createdAt),_o=()=>{const{data:e,isLoading:t,refetch:n,isRefetching:r}=mr(),s=D.useCallback(()=>n().then(a=>a.data),[n]);return D.useMemo(()=>({orders:{all:e??[],open:Pn(e??[],ue.Open),completed:Pn(e??[],ue.Completed),cancelled:Pn(e??[],ue.Cancelled),expired:Pn(e??[],ue.Expired)},isLoading:t,isRefetching:r,refetchOrders:s}),[e,t,r,s])},yr=()=>{const e=z(n=>n.state.currentTime),t=tr().duration;return D.useMemo(()=>Oa(e,t),[e,t])},vs=()=>{const{srcToken:e,dstToken:t,account:n,chainId:r,slippage:s,config:a,module:o,fees:u}=q(),{amount:f}=st(),{amountPerTrade:p,totalTrades:T}=Ke(),y=yr(),{amount:E}=rr(),{pricePerChunk:v}=Ct(),{milliseconds:O}=Nt();return D.useMemo(()=>{var I;return zr({chainId:r,srcToken:Rt((e==null?void 0:e.address)||"")?((I=bt(r))==null?void 0:I.wToken.address)||"":(e==null?void 0:e.address)||"",dstToken:(t==null?void 0:t.address)||"",srcAmount:f,deadlineMillis:y,fillDelayMillis:!T||T===1?0:O,slippage:s*100,account:n,srcAmountPerTrade:p,dstMinAmountPerTrade:E,triggerAmountPerTrade:v,config:a,module:o})},[e,t,n,r,s,a,o,f,p,T,O,E,v,u])};function Uo(e){const t=e.slice(2);if(t.length===128){const a=`0x${t.slice(0,64)}`,o=parseInt(t.charAt(64),16),u=(o>>3)+27,f=`0x${(o&7).toString(16)}${t.slice(65,128)}`;return{r:a,s:f,v:u}}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 Ro=()=>{var a;const{account:e,walletInteractions:t,callbacks:n,chainId:r}=q(),s=(a=En())==null?void 0:a.wToken;return it({mutationFn:async({onHash:o,srcAmountWei:u})=>{var p,T;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 f=await t.wrapNativeToken(u);return(p=n==null?void 0:n.onWrapRequest)==null||p.call(n),o==null||o(f),pe.onWrapSuccess(f),(T=n==null?void 0:n.onWrapSuccess)==null||T.call(n,{txHash:f,explorerUrl:Lt(f,r),amount:be(u,s.decimals)}),f},onError:o=>{throw pe.onWrapError(o),o}})},Ps=()=>{const{account:e,walletInteractions:t,chainId:n,callbacks:r,isDev:s}=q(),a=vs(),{refetch:o}=mr();return it({mutationFn:async()=>{var I,k,_,F;if(!e)throw new Error("missing account");if(!t)throw new Error("missing walletInteractions");if(!n)throw new Error("missing chainId");const{order:u,domain:f,types:p,primaryType:T}=a;pe.onSignOrderRequest(u);let y;try{y=await t.signOrder({domain:f,types:p,primaryType:T,message:u,account:e})}catch(K){throw(I=r==null?void 0:r.onSignOrderError)==null||I.call(r,K),pe.onSignOrderError(K),K}pe.onSignOrderSuccess(y),(k=r==null?void 0:r.onSignOrderSuccess)==null||k.call(r,y);const E=Uo(y),v={v:`0x${E.v.toString(16)}`,r:E.r,s:E.s};(_=r==null?void 0:r.onSignOrderRequest)==null||_.call(r);const O=await jr(u,v,s);return(F=r==null?void 0:r.onOrderCreated)==null||F.call(r,O),await o(),O}})},Os=()=>{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 a=await t.getAllowance({tokenAddress:r,spenderAddress:n.repermit}),o=S(a||"0").lt(S(s).toString());return{allowance:a,approvalRequired:o}}})},Lo=()=>{const{account:e,walletInteractions:t,config:n,chainId:r,callbacks:s}=q(),{mutateAsync:a}=Os();return it({onError:o=>{pe.onApproveError(o)},mutationFn:async({token:o,onHash:u,srcAmountWei:f})=>{var y,E;if(!e)throw new Error("missing account");if(!t)throw new Error("missing walletInteractions");if(!n)throw new Error("missing config");pe.onApproveRequest();const p=await t.approveToken({tokenAddress:o.address,amount:f,spenderAddress:n.repermit});if(!p)throw new Error("failed to approve token");(y=s==null?void 0:s.onApproveRequest)==null||y.call(s),u(p);let T=!1;for(let v=0;v<3;v++){const{approvalRequired:O}=await a({tokenAddress:o.address,srcAmountWei:f});if(!O){T=!0;break}v<2&&await new Promise(I=>setTimeout(I,3e3))}if(!T)throw new Error(`Insufficient ${o.symbol} allowance to perform the swap. Please approve the token first.`);return pe.onApproveSuccess(p),(E=s==null?void 0:s.onApproveSuccess)==null||E.call(s,{txHash:p,explorerUrl:Lt(p,r),token:o,amount:be(f,o.decimals)}),p}})},No=()=>{const{account:e,chainId:t,srcToken:n,dstToken:r,module:s,slippage:a}=q(),o=Ct(),u=st().amount,f=Ke().amountPerTrade,p=yr(),T=Ke().totalTrades,y=Nt().fillDelay,E=rr().amount,v=z(O=>O.state.isMarketOrder);return it({mutationFn:async()=>{pe.onRequestOrder({account:e,chainId:t,module:s,srcToken:n,dstToken:r,fromTokenAmount:u,srcChunkAmount:f,triggerPricePerTrade:o.pricePerChunk,deadline:p,fillDelay:y.unit*y.value,minDstAmountOutPerTrade:E,slippage:a,isMarketOrder:v||!1,chunksAmount:T})}})};function qo(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 Bs=()=>{const{srcToken:e,dstToken:t,chainId:n,callbacks:r,marketPrice:s}=q(),a=Lo().mutateAsync,o=Ro().mutateAsync,u=Ps().mutateAsync,{mutateAsync:f}=Os(),{update:p}=rn(),{amount:T}=st(),y=No().mutate;return it({mutationFn:async()=>{var v,O;const E=Rt((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=es(e,n);p({allowanceLoading:!0,wrapTxHash:void 0,approveTxHash:void 0,acceptedMarketPrice:s,acceptedSrcAmount:T,srcToken:e,dstToken:t,pendingSteps:[]});const{approvalRequired:k}=await f({tokenAddress:I.address,srcAmountWei:T});let _=0,F=1;E&&F++,k&&F++,p({totalSteps:F,stepIndex:_,allowanceLoading:!1,hasApproval:!k,status:Fe.LOADING}),y();let K=[];E&&K.push(nt.WRAP),k&&K.push(nt.APPROVE),K.push(nt.CREATE),p({pendingSteps:K}),E&&(p({step:nt.WRAP}),await o({onHash:V=>p({wrapTxHash:V}),srcAmountWei:T}),_++,p({stepIndex:_})),k&&(p({step:nt.APPROVE}),await a({token:I,onHash:V=>p({approveTxHash:V}),srcAmountWei:T}),_++,p({stepIndex:_})),p({step:nt.CREATE});const U=await u();return p({status:Fe.SUCCESS,orderId:U.id}),U}catch(I){if(Xn(I))(v=r==null?void 0:r.onSubmitOrderRejected)==null||v.call(r),p({step:void 0,status:void 0,stepIndex:void 0,error:I});else{const k=qo(I);(O=r==null?void 0:r.onSubmitOrderFailed)==null||O.call(r,k),p({status:Fe.FAILED,parsedError:k,error:I})}throw I}}})},Ko=()=>{const e=rn(),{srcToken:t,dstToken:n}=q(),r=Bs(),s=z(p=>p.resetState),a=D.useCallback(()=>r.mutateAsync(),[r]),{update:o,resetSwap:u,...f}=e;return D.useMemo(()=>({status:f.status,parsedError:f.parsedError,error:f.error,step:f.step,stepIndex:f.stepIndex,approveTxHash:f.approveTxHash,wrapTxHash:f.wrapTxHash,totalSteps:f.totalSteps,pendingSteps:f.pendingSteps,srcToken:t,dstToken:n,onSubmit:a,resetState:s,resetCurrentSwap:u,isLoading:(e==null?void 0:e.status)===Fe.LOADING,isSuccess:(e==null?void 0:e.status)===Fe.SUCCESS,isFailed:(e==null?void 0:e.status)===Fe.FAILED,confirmButtonLoading:f.allowanceLoading}),[a,f,s,u,t,n])},Ho=()=>{const{marketPrice:e,srcToken:t,dstToken:n,marketPriceLoading:r,srcBalance:s,srcUsd1Token:a,noLiquidity:o,typedInputAmount:u}=q(),f=r||S(a||"0").isZero()||s===void 0||S(e||"0").isZero(),p=!!(t&&n&&u&&f),y=!!(is()||o||p||S(u||"0").isZero()||!t||!n);return D.useMemo(()=>({disabled:y,loading:p}),[y,p])},Wo=()=>{const{srcUsd1Token:e,dstUsd1Token:t}=q(),n=st().amountUI,r=wn().amountUI,s=qe(n,e),a=qe(r,t);return{srcAmountUsd:s,dstAmountUsd:a}},zo=()=>{const{fees:e,dstToken:t,dstUsd1Token:n}=q(),{amountUI:r}=wn(),s=D.useMemo(()=>!e||!r?"":S(r).multipliedBy(e).dividedBy(100).toFixed(),[r,e]),a=er((t==null?void 0:t.decimals)||0,s);return{amountUI:s,amount:a,percent:e,usd:qe(s,n)}},Qo=e=>{const t=D.useMemo(()=>!e.minDestAmountPerTrade||!e.totalTrades?"":S(e.minDestAmountPerTrade).multipliedBy(e.totalTrades).decimalPlaces(0).toFixed(),[e.minDestAmountPerTrade,e.totalTrades]),n=D.useMemo(()=>!e.minDestAmountPerTradeUI||!e.totalTrades?"":S(e.minDestAmountPerTradeUI).multipliedBy(e.totalTrades).toFixed(),[e.minDestAmountPerTradeUI,e.totalTrades]),r=D.useMemo(()=>!e.minDestAmountPerTradeUsd||!e.totalTrades?"":S(e.minDestAmountPerTradeUsd).multipliedBy(e.totalTrades).decimalPlaces(2).toFixed(),[e.minDestAmountPerTradeUsd,e.totalTrades]);return D.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 D.useMemo(()=>({spender:e.repermit}),[e])},jo=()=>{const{srcToken:e,dstToken:t,account:n,marketPrice:r}=q(),{spender:s}=$o(),{amount:a}=st(),{amount:o,amountUI:u,usd:f}=Tn(),{amountPerTrade:p,amountPerTradeUI:T,amountPerTradeUsd:y,totalTrades:E}=Ke(),v=yr(),{amount:O,amountUI:I,usd:k}=rr(),{amountUI:_,amount:F,usd:K}=Ct(),{milliseconds:U}=Nt(),{amount:V,amountUI:G}=wn(),{srcAmountUsd:oe,dstAmountUsd:i}=Wo(),{amount:c,amountUI:d,percent:b,usd:m}=zo(),A=vs(),w=z(Z=>Z.state.isMarketOrder),h=z(Z=>Z.state.currentTime),g=rn(),x=vo(),C=g.acceptedSrcAmount||a,P=be(r,(t==null?void 0:t.decimals)||0),R=D.useMemo(()=>x===X.TAKE_PROFIT_MARKET||x===X.TAKE_PROFIT_LIMIT||x===X.STOP_LOSS_LIMIT||x===X.STOP_LOSS_MARKET,[x]),L=Qo({srcToken:e,dstToken:t,account:n,orderType:x,createdAt:h,deadline:v,totalTrades:E,tradeInterval:U,srcAmount:C,srcAmountUI:be(C,(e==null?void 0:e.decimals)||0),srcAmountUsd:oe,dstAmount:V,dstAmountUI:G,dstAmountUsd:i,limitPrice:w?void 0:o,limitPriceUI:w?void 0:u,limitPriceUsd:w?void 0:f,srcAmountPerTrade:p,srcAmountPerTradeUI:T,srcAmountPerTradeUsd:y,minDestAmountPerTrade:O,minDestAmountPerTradeUI:I,minDestAmountPerTradeUsd:k,triggerPrice:F,triggerPriceUI:_,triggerPriceUsd:K});return D.useMemo(()=>({...L,feesAmountUI:d,feesAmount:c,feesUsd:m||"",feesPercentage:b,rePermitData:A,isTriggerPrice:R,isMarketOrder:w,marketPrice:r,marketPriceUi:P,spender:s}),[L,d,c,m,b,A,R,w,r,P,s])},Vo=()=>{const{supportedChains:e}=q();return D.useMemo(()=>e,[e])},Go=60,Is=()=>{const{refetch:e}=mr();return it({mutationFn:async t=>{var n;for(let r=0;r<Go;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)===ue.Cancelled)return;await new Promise(o=>setTimeout(o,1e3))}throw new Error("Timed out waiting for order cancellation to be confirmed")}})},Xo=()=>{const e=z(n=>n.updateState),t=z(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})}}},Zo=e=>{const{account:t,walletInteractions:n,config:r,callbacks:s,chainId:a}=q(),o=Is().mutateAsync,u=Po(),{cancelOrders:f,setCancelOrder:p,clearCancelOrder:T}=Xo(),{mutateAsync:y}=it({mutationFn:async()=>{var I,k,_;if(!t||!n||!r)throw new Error("missing required parameters");if(!e)throw new Error("order is required");const O=e.id;try{(I=s==null?void 0:s.onCancelOrderRequest)==null||I.call(s,e),p(O,{status:Fe.LOADING}),pe.onCancelOrderRequest([e.version===1?e.id.toString():e.hash],e.version);const F=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?Xs:Gs});if(!F)throw new Error("failed to cancel order");return pe.onCancelOrderSuccess(F),e.version===1?u(e.id,ue.Cancelled):await o(e.id),(k=s==null?void 0:s.onCancelOrderSuccess)==null||k.call(s,{order:e.version===1?{...e,status:ue.Cancelled}:e,txHash:F,explorerUrl:Lt(F,a)}),p(O,{status:Fe.SUCCESS,txHash:F}),F}catch(F){console.error("cancel order error",F),(_=s==null?void 0:s.onCancelOrderFailed)==null||_.call(s,F),Xn(F)?T(O):(p(O,{status:Fe.FAILED,error:F.message}),pe.onCancelOrderError(F))}}}),E=D.useMemo(()=>{const O=f[(e==null?void 0:e.id)||""];return{isLoading:(O==null?void 0:O.status)===Fe.LOADING,isSuccess:(O==null?void 0:O.status)===Fe.SUCCESS,isError:(O==null?void 0:O.status)===Fe.FAILED,error:O==null?void 0:O.error,txHash:O==null?void 0:O.txHash}},[f,e==null?void 0:e.id]),v=D.useCallback(async()=>y(),[y]);return D.useMemo(()=>({cancelOrder:v,...E}),[v,E])},Ms=D.createContext(null),Yo=({children:e})=>{const t=Pi(),n=Mi(),r=Bi(),s=Ni(),a=qi(),o=Cn(),u=Ki(),f=Hi(),p=is(),T=Ho(),y=jo(),E=_o(),v=Ko(),O=Vo(),I=Is(),{module:k}=q(),_={tradesAmountPanel:t,durationPanel:n,fillDelayPanel:r,limitPricePanel:s,triggerPricePanel:a,pricePanel:o,dstTokenPanel:u,disclaimerPanel:f,inputError:p,submitOrderButton:T,derivedFormData:y,orderHistoryPanel:E,orderExecutionPanel:v,supportedChains:O,refetchUntilStatusSynced:I,module:k};return H.jsx(Ms.Provider,{value:_,children:e})},Jo=()=>{const e=D.useContext(Ms);if(e===null)throw new Error("useSpot must be used within SpotProvider");return e},ec=D.createContext(null),Ar={didCatch:!1,error:null};class tc extends D.Component{constructor(t){super(t),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=Ar}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(Ar)}}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&&nc(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(Ar)}}render(){const{children:t,fallbackRender:n,FallbackComponent:r,fallback:s}=this.props,{didCatch:a,error:o}=this.state;let u=t;if(a){const f={error:o,resetErrorBoundary:this.resetErrorBoundary};if(typeof n=="function")u=n(f);else if(r)u=D.createElement(r,f);else if(s!==void 0)u=s;else throw o}return D.createElement(ec.Provider,{value:{didCatch:a,error:o,resetErrorBoundary:this.resetErrorBoundary}},u)}}function nc(){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 rc=()=>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 sc({children:e}){return H.jsx(tc,{FallbackComponent:rc,onError:t=>pe.onCrash(t),children:H.jsx(H.Fragment,{children:e})})}const ks=D.createContext(null),ac=new po({defaultOptions:{queries:{refetchOnWindowFocus:!1}}}),ic=e=>{var r,s,a;const t=z(o=>o.updateState),n=z(o=>o.state.isMarketOrder);return D.useEffect(()=>{const o=setInterval(()=>{t({currentTime:Date.now()})},6e4);return()=>clearInterval(o)},[t]),D.useEffect(()=>{var u,f,p,T,y,E,v,O,I,k,_,F,K,U,V,G;const o=(f=(u=e.overrides)==null?void 0:u.state)==null?void 0:f.isMarketOrder;o!==void 0&&t({isMarketOrder:o}),t({typedChunks:(T=(p=e.overrides)==null?void 0:p.state)==null?void 0:T.chunks,typedFillDelay:(E=(y=e.overrides)==null?void 0:y.state)==null?void 0:E.fillDelay,typedDuration:(O=(v=e.overrides)==null?void 0:v.state)==null?void 0:O.duration,typedLimitPrice:(k=(I=e.overrides)==null?void 0:I.state)==null?void 0:k.limitPrice,typedTriggerPrice:(F=(_=e.overrides)==null?void 0:_.state)==null?void 0:F.triggerPrice,triggerPricePercent:(U=(K=e.overrides)==null?void 0:K.state)==null?void 0:U.triggerPricePercent,limitPricePercent:(G=(V=e.overrides)==null?void 0:V.state)==null?void 0:G.limitPricePercent})},[(r=e.overrides)==null?void 0:r.state,e.module]),D.useEffect(()=>{var o,u,f,p;t({typedLimitPrice:(u=(o=e.overrides)==null?void 0:o.state)==null?void 0:u.limitPrice,typedTriggerPrice:(p=(f=e.overrides)==null?void 0:f.state)==null?void 0:p.triggerPrice,triggerPricePercent:void 0,limitPricePercent:void 0})},[(s=e.srcToken)==null?void 0:s.address,(a=e.dstToken)==null?void 0:a.address]),D.useEffect(()=>{e.module===j.LIMIT&&t({isMarketOrder:!1})},[e.module]),D.useEffect(()=>{n&&t({isInvertedTrade:!1})},[n]),D.useEffect(()=>{t({typedChunks:void 0})},[e.typedInputAmount]),null},oc=({marketReferencePrice:e,srcToken:t,dstToken:n,chainId:r,typedInputAmount:s})=>D.useMemo(()=>{if(Yn(t,n,r)||Jn(t,n,r))return{isLoading:!1,noLiquidity:!1,value:rt(s||"0",t==null?void 0:t.decimals)};if(S(e.value||0).isZero()||S(s||0).isZero())return e;const a=S(e.value||0).dividedBy(s||0).decimalPlaces(0).toFixed();return{...e,value:a}},[e,s,t,n,r]),cc=e=>{const t=rn(),n=D.useMemo(()=>Lr(e.partner),[e.partner]),r=D.useMemo(()=>{const u=n[0];return e.chainId&&n.includes(e.chainId)?e.chainId:u},[e.chainId,n]),s=D.useMemo(()=>zn(e.partner,r),[e.partner,r]),a=oc(e),o=D.useMemo(()=>Wr(e.minChunkSizeUsd),[e.minChunkSizeUsd]);return D.useEffect(()=>{pe.init(s,o,r,e.appId)},[s,r,o,e.appId]),H.jsxs(ks.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(ic,{...e}),H.jsx(Yo,{children:H.jsx(sc,{children:e.children})})]})},uc=e=>H.jsx(ho,{client:ac,children:H.jsx(cc,{...e})}),q=()=>{const e=D.useContext(ks);if(e===null)throw new Error("useSpotContext must be used within SpotProvider");return e},dc=(e,t,n)=>{const r=En();return D.useMemo(()=>e==null?void 0:e.map(s=>({rawFill:s,srcToken:t,dstToken:n,srcAmount:be(s.inAmount,t==null?void 0:t.decimals),dstAmount:be(s.outAmount,n==null?void 0:n.decimals),timestamp:s.timestamp,txHash:s.txHash,explorerUrl:Lt(s.txHash,r==null?void 0:r.id),executionRate:Wn(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])},lc=(e,t,n)=>{const{config:r}=q(),s=Io(t,n,e),a=Mo(t,n,e),o=ko(t,n,e),u=D.useMemo(()=>e?e.version===2?e.fillDelay:r.twapConfig?Hn(e,r.twapConfig):0:0,[e,r]),f=dc(e==null?void 0:e.fills,t,n)??[];return D.useMemo(()=>{if(e!=null&&e.id)return{original:e,fills:f,srcToken:t,dstToken:n,orderType:e.type,createdAt:e.createdAt,deadline:e.deadline||0,totalTrades:e.totalTradesAmount||0,tradeInterval:u,recipient:e.maker||"",srcAmount:e.srcAmount||"",srcAmountUI:be(e.srcAmount,t==null?void 0:t.decimals),limitPrice:rt(s,n==null?void 0:n.decimals),limitPriceUI:s||"",sizePerTrade:e.srcAmountPerTrade||"",sizePerTradeUI:be(e.srcAmountPerTrade,t==null?void 0:t.decimals),minDestAmountPerTrade:e.dstMinAmountPerTrade||"",minDestAmountPerTradeUI:be(e.dstMinAmountPerTrade,n==null?void 0:n.decimals),dstMinAmount:e.dstMinAmountTotal,dstMinAmountUI:be(e.dstMinAmountTotal,n==null?void 0:n.decimals),triggerPrice:rt(a,n==null?void 0:n.decimals),triggerPriceUI:a||"",id:e.id,amountInFilled:e.srcAmountFilled,amountInFilledUI:be(e.srcAmountFilled,t==null?void 0:t.decimals),amountOutFilled:e.dstAmountFilled,amountOutFilledUI:be(e.dstAmountFilled,n==null?void 0:n.decimals),progress:e.progress,executionPrice:rt(o,n==null?void 0:n.decimals),executionPriceUI:o,version:e.version}},[e,f,t,n,u,s,a,o])};ja(Ai.version),B.DISCLAIMER_URL=la,B.Disclaimer=en,B.InputErrors=me,B.Module=j,B.ORBS_LOGO=ua,B.ORBS_SLTP_FAQ_URL=ca,B.ORBS_TWAP_FAQ_URL=oa,B.ORBS_WEBSITE_URL=da,B.OrderFilter=Pr,B.OrderStatus=ue,B.OrderType=X,B.Partners=Pe,B.SPOT_VERSION=pn,B.SpotProvider=uc,B.Steps=nt,B.SwapStatus=Fe,B.TimeUnit=ve,B.buildRePermitOrderData=zr,B.ensureWrappedToken=es,B.eqIgnoreCase=At,B.getConfig=zn,B.getExplorerUrl=Lt,B.getMinChunkSizeUsd=Wr,B.getNetwork=bt,B.getOrderExecutionRate=Wn,B.getOrderFillDelayMillis=Hn,B.getOrderLimitPriceRate=Nr,B.getOrderType=Ti,B.getPartnerChains=Lr,B.getPartners=Hr,B.getTriggerPriceRate=qr,B.isNativeAddress=Rt,B.isTxRejected=Xn,B.millisToDays=Zn,B.millisToMinutes=bn,B.networks=ye,B.parseError=xi,B.shouldUnwrapOnly=Jn,B.shouldWrapOnly=Yn,B.submitOrder=jr,B.toAmountUi=be,B.toAmountWei=rt,B.useAmountUi=Et,B.useCancelOrder=Zo,B.useDerivedHistoryOrder=lc,B.useExplorerLink=wi,B.useNetwork=En,B.useSignOrder=Ps,B.useSpot=Jo,B.useSubmitOrder=Bs,B.useSwapExecution=rn,Object.defineProperty(B,Symbol.toStringTag,{value:"Module"})}));
|