@orbs-network/spot-react 0.0.36 → 0.0.37

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.
@@ -61,7 +61,7 @@
61
61
  dollarValueOut
62
62
  }
63
63
  }
64
- `,extractResults:d=>{var f;return(((f=d.data)==null?void 0:f.orderFilleds)||[]).map(m=>({...m,timestamp:new Date(m.timestamp).getTime()}))}})};class kw extends Error{constructor(){super("No graph endpoint found"),this.name="NoGraphEndpointError"}}const Cw=async({chainId:e,signal:t,page:r,limit:n,filters:s})=>{const a=await ww({chainId:e,signal:t,page:r,limit:n,filters:s}),[o,i]=await Promise.all([Ew({chainId:e,orders:a,signal:t}),vw({chainId:e,orders:a,signal:t})]);return a.map(l=>{const u=o==null?void 0:o.filter(d=>d.TWAP_id===Number(l.Contract_id)&&Ps(d.exchange,l.exchange)&&Ps(d.twapAddress,l.twapAddress));return gw(l,e,u,Tw(l,u||[],i))}).sort((l,u)=>u.createdAt-l.createdAt)},Tw=(e,t,r)=>{var i;const n=(i=r==null?void 0:r.find(c=>c.twapId===e.Contract_id.toString()&&Ps(c.twapAddress,e.twapAddress)))==null?void 0:i.status,a=Th(t).reduce((c,l)=>c.plus(l.inAmount),new j(0)).toFixed(),o=Ah(e.ask_srcAmount,a);return Sw(o,e.ask_deadline*1e3,n)},Ah=(e,t)=>{if(!t||!e)return 0;const r=j(t).dividedBy(e).toNumber();return r>=.99?100:r<=0?0:Number((r*100).toFixed(2))},Sw=(e,t,r)=>e===100?lt.Completed:r==="CANCELED"?lt.Canceled:r==="COMPLETED"?lt.Completed:t>Date.now()?lt.Open:lt.Expired,Ph=async({signal:e,page:t,chainId:r,limit:n,config:s,account:a})=>(await Promise.all([s?Cw({chainId:r,signal:e,page:t,limit:n,filters:{accounts:[a],configs:[s]}}):Promise.resolve([]),bw({chainId:r,signal:e,account:a})]).then(([c,l])=>[...c,...l])).sort((c,l)=>l.createdAt-c.createdAt),Aw={version:"0.0.36"};var Ta=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(){}},Pw={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Iw=(f5=class{constructor(){le(this,dn,Pw);le(this,pa,!1)}setTimeoutProvider(e){process.env.NODE_ENV!=="production"&&N(this,pa)&&e!==N(this,dn)&&console.error("[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",{previous:N(this,dn),provider:e}),ee(this,dn,e),process.env.NODE_ENV!=="production"&&ee(this,pa,!1)}setTimeout(e,t){return process.env.NODE_ENV!=="production"&&ee(this,pa,!0),N(this,dn).setTimeout(e,t)}clearTimeout(e){N(this,dn).clearTimeout(e)}setInterval(e,t){return process.env.NODE_ENV!=="production"&&ee(this,pa,!0),N(this,dn).setInterval(e,t)}clearInterval(e){N(this,dn).clearInterval(e)}},dn=new WeakMap,pa=new WeakMap,f5),Fs=new Iw;function Bw(e){setTimeout(e,0)}var Us=typeof window>"u"||"Deno"in globalThis;function jt(){}function Fw(e,t){return typeof e=="function"?e(t):e}function fd(e){return typeof e=="number"&&e>=0&&e!==1/0}function Ih(e,t){return Math.max(e+(t||0)-Date.now(),0)}function Xn(e,t){return typeof e=="function"?e(t):e}function Er(e,t){return typeof e=="function"?e(t):e}function Bh(e,t){const{type:r="all",exact:n,fetchStatus:s,predicate:a,queryKey:o,stale:i}=e;if(o){if(n){if(t.queryHash!==md(o,t.options))return!1}else if(!Uo(t.queryKey,o))return!1}if(r!=="all"){const c=t.isActive();if(r==="active"&&!c||r==="inactive"&&c)return!1}return!(typeof i=="boolean"&&t.isStale()!==i||s&&s!==t.state.fetchStatus||a&&!a(t))}function Fh(e,t){const{exact:r,status:n,predicate:s,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(r){if(Os(t.options.mutationKey)!==Os(a))return!1}else if(!Uo(t.options.mutationKey,a))return!1}return!(n&&t.state.status!==n||s&&!s(t))}function md(e,t){return((t==null?void 0:t.queryKeyHashFn)||Os)(e)}function Os(e){return JSON.stringify(e,(t,r)=>bd(r)?Object.keys(r).sort().reduce((n,s)=>(n[s]=r[s],n),{}):r)}function Uo(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(r=>Uo(e[r],t[r])):!1}var Uw=Object.prototype.hasOwnProperty;function hd(e,t){if(e===t)return e;const r=Uh(e)&&Uh(t);if(!r&&!(bd(e)&&bd(t)))return t;const s=(r?e:Object.keys(e)).length,a=r?t:Object.keys(t),o=a.length,i=r?new Array(o):{};let c=0;for(let l=0;l<o;l++){const u=r?l:a[l],d=e[u],f=t[u];if(d===f){i[u]=d,(r?l<s:Uw.call(e,u))&&c++;continue}if(d===null||f===null||typeof d!="object"||typeof f!="object"){i[u]=f;continue}const m=hd(d,f);i[u]=m,m===d&&c++}return s===o&&c===s?e:i}function Oc(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const r in e)if(e[r]!==t[r])return!1;return!0}function Uh(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function bd(e){if(!Oh(e))return!1;const t=e.constructor;if(t===void 0)return!0;const r=t.prototype;return!(!Oh(r)||!r.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function Oh(e){return Object.prototype.toString.call(e)==="[object Object]"}function Ow(e){return new Promise(t=>{Fs.setTimeout(t,e)})}function yd(e,t,r){if(typeof r.structuralSharing=="function")return r.structuralSharing(e,t);if(r.structuralSharing!==!1){if(process.env.NODE_ENV!=="production")try{return hd(e,t)}catch(n){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. [${r.queryHash}]: ${n}`),n}return hd(e,t)}return t}function Dw(e,t,r=0){const n=[...e,t];return r&&n.length>r?n.slice(1):n}function _w(e,t,r=0){const n=[t,...e];return r&&n.length>r?n.slice(0,-1):n}var Dc=Symbol();function Dh(e,t){return process.env.NODE_ENV!=="production"&&e.queryFn===Dc&&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===Dc?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function _h(e,t){return typeof e=="function"?e(...t):!!e}var Mw=(m5=class extends Ta{constructor(){super();le(this,fa);le(this,gs);le(this,go);ee(this,go,t=>{if(!Us&&window.addEventListener){const r=()=>t();return window.addEventListener("visibilitychange",r,!1),()=>{window.removeEventListener("visibilitychange",r)}}})}onSubscribe(){N(this,gs)||this.setEventListener(N(this,go))}onUnsubscribe(){var t;this.hasListeners()||((t=N(this,gs))==null||t.call(this),ee(this,gs,void 0))}setEventListener(t){var r;ee(this,go,t),(r=N(this,gs))==null||r.call(this),ee(this,gs,t(n=>{typeof n=="boolean"?this.setFocused(n):this.onFocus()}))}setFocused(t){N(this,fa)!==t&&(ee(this,fa,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(r=>{r(t)})}isFocused(){var t;return typeof N(this,fa)=="boolean"?N(this,fa):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},fa=new WeakMap,gs=new WeakMap,go=new WeakMap,m5),gd=new Mw;function xd(){let e,t;const r=new Promise((s,a)=>{e=s,t=a});r.status="pending",r.catch(()=>{});function n(s){Object.assign(r,s),delete r.resolve,delete r.reject}return r.resolve=s=>{n({status:"fulfilled",value:s}),e(s)},r.reject=s=>{n({status:"rejected",reason:s}),t(s)},r}var Nw=Bw;function Lw(){let e=[],t=0,r=i=>{i()},n=i=>{i()},s=Nw;const a=i=>{t?e.push(i):s(()=>{r(i)})},o=()=>{const i=e;e=[],i.length&&s(()=>{n(()=>{i.forEach(c=>{r(c)})})})};return{batch:i=>{let c;t++;try{c=i()}finally{t--,t||o()}return c},batchCalls:i=>(...c)=>{a(()=>{i(...c)})},schedule:a,setNotifyFunction:i=>{r=i},setBatchNotifyFunction:i=>{n=i},setScheduler:i=>{s=i}}}var kt=Lw(),zw=(h5=class extends Ta{constructor(){super();le(this,xo,!0);le(this,xs);le(this,wo);ee(this,wo,t=>{if(!Us&&window.addEventListener){const r=()=>t(!0),n=()=>t(!1);return window.addEventListener("online",r,!1),window.addEventListener("offline",n,!1),()=>{window.removeEventListener("online",r),window.removeEventListener("offline",n)}}})}onSubscribe(){N(this,xs)||this.setEventListener(N(this,wo))}onUnsubscribe(){var t;this.hasListeners()||((t=N(this,xs))==null||t.call(this),ee(this,xs,void 0))}setEventListener(t){var r;ee(this,wo,t),(r=N(this,xs))==null||r.call(this),ee(this,xs,t(this.setOnline.bind(this)))}setOnline(t){N(this,xo)!==t&&(ee(this,xo,t),this.listeners.forEach(n=>{n(t)}))}isOnline(){return N(this,xo)}},xo=new WeakMap,xs=new WeakMap,wo=new WeakMap,h5),_c=new zw;function Rw(e){return Math.min(1e3*2**e,3e4)}function Mh(e){return(e??"online")==="online"?_c.isOnline():!0}var wd=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function Nh(e){let t=!1,r=0,n;const s=xd(),a=()=>s.status!=="pending",o=g=>{var E;if(!a()){const v=new wd(g);f(v),(E=e.onCancel)==null||E.call(e,v)}},i=()=>{t=!0},c=()=>{t=!1},l=()=>gd.isFocused()&&(e.networkMode==="always"||_c.isOnline())&&e.canRun(),u=()=>Mh(e.networkMode)&&e.canRun(),d=g=>{a()||(n==null||n(),s.resolve(g))},f=g=>{a()||(n==null||n(),s.reject(g))},m=()=>new Promise(g=>{var E;n=v=>{(a()||l())&&g(v)},(E=e.onPause)==null||E.call(e)}).then(()=>{var g;n=void 0,a()||(g=e.onContinue)==null||g.call(e)}),y=()=>{if(a())return;let g;const E=r===0?e.initialPromise:void 0;try{g=E??e.fn()}catch(v){g=Promise.reject(v)}Promise.resolve(g).then(d).catch(v=>{var L;if(a())return;const w=e.retry??(Us?0:3),A=e.retryDelay??Rw,C=typeof A=="function"?A(r,v):A,D=w===!0||typeof w=="number"&&r<w||typeof w=="function"&&w(r,v);if(t||!D){f(v);return}r++,(L=e.onFail)==null||L.call(e,r,v),Ow(C).then(()=>l()?void 0:m()).then(()=>{t?f(v):y()})})};return{promise:s,status:()=>s.status,cancel:o,continue:()=>(n==null||n(),s),cancelRetry:i,continueRetry:c,canStart:u,start:()=>(u()?y():m().then(y),s)}}var Lh=(b5=class{constructor(){le(this,ma)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),fd(this.gcTime)&&ee(this,ma,Fs.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Us?1/0:300*1e3))}clearGcTimeout(){N(this,ma)&&(Fs.clearTimeout(N(this,ma)),ee(this,ma,void 0))}},ma=new WeakMap,b5),Hw=(y5=class extends Lh{constructor(t){super();le(this,Yr);le(this,ha);le(this,vo);le(this,Br);le(this,ba);le(this,Bt);le(this,wc);le(this,ya);ee(this,ya,!1),ee(this,wc,t.defaultOptions),this.setOptions(t.options),this.observers=[],ee(this,ba,t.client),ee(this,Br,N(this,ba).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,ee(this,ha,Hh(this.options)),this.state=t.state??N(this,ha),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=N(this,Bt))==null?void 0:t.promise}setOptions(t){if(this.options={...N(this,wc),...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const r=Hh(this.options);r.data!==void 0&&(this.setState(Rh(r.data,r.dataUpdatedAt)),ee(this,ha,r))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&N(this,Br).remove(this)}setData(t,r){const n=yd(this.state.data,t,this.options);return Ae(this,Yr,Yn).call(this,{data:n,type:"success",dataUpdatedAt:r==null?void 0:r.updatedAt,manual:r==null?void 0:r.manual}),n}setState(t,r){Ae(this,Yr,Yn).call(this,{type:"setState",state:t,setStateOptions:r})}cancel(t){var n,s;const r=(n=N(this,Bt))==null?void 0:n.promise;return(s=N(this,Bt))==null||s.cancel(t),r?r.then(jt).catch(jt):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(N(this,ha))}isActive(){return this.observers.some(t=>Er(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Dc||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>Xn(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:!Ih(this.state.dataUpdatedAt,t)}onFocus(){var r;const t=this.observers.find(n=>n.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(r=N(this,Bt))==null||r.continue()}onOnline(){var r;const t=this.observers.find(n=>n.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(r=N(this,Bt))==null||r.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),N(this,Br).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(r=>r!==t),this.observers.length||(N(this,Bt)&&(N(this,ya)?N(this,Bt).cancel({revert:!0}):N(this,Bt).cancelRetry()),this.scheduleGc()),N(this,Br).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||Ae(this,Yr,Yn).call(this,{type:"invalidate"})}async fetch(t,r){var c,l,u,d,f,m,y,g,E,v,w,A;if(this.state.fetchStatus!=="idle"&&((c=N(this,Bt))==null?void 0:c.status())!=="rejected"){if(this.state.data!==void 0&&(r!=null&&r.cancelRefetch))this.cancel({silent:!0});else if(N(this,Bt))return N(this,Bt).continueRetry(),N(this,Bt).promise}if(t&&this.setOptions(t),!this.options.queryFn){const C=this.observers.find(D=>D.options.queryFn);C&&this.setOptions(C.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 n=new AbortController,s=C=>{Object.defineProperty(C,"signal",{enumerable:!0,get:()=>(ee(this,ya,!0),n.signal)})},a=()=>{const C=Dh(this.options,r),L=(()=>{const T={client:N(this,ba),queryKey:this.queryKey,meta:this.meta};return s(T),T})();return ee(this,ya,!1),this.options.persister?this.options.persister(C,L,this):C(L)},i=(()=>{const C={fetchOptions:r,options:this.options,queryKey:this.queryKey,client:N(this,ba),state:this.state,fetchFn:a};return s(C),C})();(l=this.options.behavior)==null||l.onFetch(i,this),ee(this,vo,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((u=i.fetchOptions)==null?void 0:u.meta))&&Ae(this,Yr,Yn).call(this,{type:"fetch",meta:(d=i.fetchOptions)==null?void 0:d.meta}),ee(this,Bt,Nh({initialPromise:r==null?void 0:r.initialPromise,fn:i.fetchFn,onCancel:C=>{C instanceof wd&&C.revert&&this.setState({...N(this,vo),fetchStatus:"idle"}),n.abort()},onFail:(C,D)=>{Ae(this,Yr,Yn).call(this,{type:"failed",failureCount:C,error:D})},onPause:()=>{Ae(this,Yr,Yn).call(this,{type:"pause"})},onContinue:()=>{Ae(this,Yr,Yn).call(this,{type:"continue"})},retry:i.options.retry,retryDelay:i.options.retryDelay,networkMode:i.options.networkMode,canRun:()=>!0}));try{const C=await N(this,Bt).start();if(C===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(C),(m=(f=N(this,Br).config).onSuccess)==null||m.call(f,C,this),(g=(y=N(this,Br).config).onSettled)==null||g.call(y,C,this.state.error,this),C}catch(C){if(C instanceof wd){if(C.silent)return N(this,Bt).promise;if(C.revert){if(this.state.data===void 0)throw C;return this.state.data}}throw Ae(this,Yr,Yn).call(this,{type:"error",error:C}),(v=(E=N(this,Br).config).onError)==null||v.call(E,C,this),(A=(w=N(this,Br).config).onSettled)==null||A.call(w,this.state.data,C,this),C}finally{this.scheduleGc()}}},ha=new WeakMap,vo=new WeakMap,Br=new WeakMap,ba=new WeakMap,Bt=new WeakMap,wc=new WeakMap,ya=new WeakMap,Yr=new WeakSet,Yn=function(t){const r=n=>{switch(t.type){case"failed":return{...n,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...n,fetchStatus:"paused"};case"continue":return{...n,fetchStatus:"fetching"};case"fetch":return{...n,...zh(n.data,this.options),fetchMeta:t.meta??null};case"success":const s={...n,...Rh(t.data,t.dataUpdatedAt),dataUpdateCount:n.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return ee(this,vo,t.manual?s:void 0),s;case"error":const a=t.error;return{...n,error:a,errorUpdateCount:n.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:n.fetchFailureCount+1,fetchFailureReason:a,fetchStatus:"idle",status:"error"};case"invalidate":return{...n,isInvalidated:!0};case"setState":return{...n,...t.state}}};this.state=r(this.state),kt.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),N(this,Br).notify({query:this,type:"updated",action:t})})},y5);function zh(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Mh(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function Rh(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function Hh(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,r=t!==void 0,n=r?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:r?n??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}var $w=(g5=class extends Ta{constructor(t,r){super();le(this,Ve);le(this,sr);le(this,De);le(this,vc);le(this,qt);le(this,ga);le(this,Eo);le(this,Gn);le(this,ws);le(this,Ec);le(this,ko);le(this,Co);le(this,xa);le(this,wa);le(this,vs);le(this,To,new Set);this.options=r,ee(this,sr,t),ee(this,ws,null),ee(this,Gn,xd()),this.bindMethods(),this.setOptions(r)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(N(this,De).addObserver(this),$h(N(this,De),this.options)?Ae(this,Ve,Tc).call(this):this.updateResult(),Ae(this,Ve,Tm).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return vd(N(this,De),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return vd(N(this,De),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,Ae(this,Ve,Sm).call(this),Ae(this,Ve,Am).call(this),N(this,De).removeObserver(this)}setOptions(t){const r=this.options,n=N(this,De);if(this.options=N(this,sr).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Er(this.options.enabled,N(this,De))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");Ae(this,Ve,Pm).call(this),N(this,De).setOptions(this.options),r._defaulted&&!Oc(this.options,r)&&N(this,sr).getQueryCache().notify({type:"observerOptionsUpdated",query:N(this,De),observer:this});const s=this.hasListeners();s&&Gh(N(this,De),n,this.options,r)&&Ae(this,Ve,Tc).call(this),this.updateResult(),s&&(N(this,De)!==n||Er(this.options.enabled,N(this,De))!==Er(r.enabled,N(this,De))||Xn(this.options.staleTime,N(this,De))!==Xn(r.staleTime,N(this,De)))&&Ae(this,Ve,Em).call(this);const a=Ae(this,Ve,km).call(this);s&&(N(this,De)!==n||Er(this.options.enabled,N(this,De))!==Er(r.enabled,N(this,De))||a!==N(this,vs))&&Ae(this,Ve,Cm).call(this,a)}getOptimisticResult(t){const r=N(this,sr).getQueryCache().build(N(this,sr),t),n=this.createResult(r,t);return jw(this,n)&&(ee(this,qt,n),ee(this,Eo,this.options),ee(this,ga,N(this,De).state)),n}getCurrentResult(){return N(this,qt)}trackResult(t,r){return new Proxy(t,{get:(n,s)=>(this.trackProp(s),r==null||r(s),s==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&N(this,Gn).status==="pending"&&N(this,Gn).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(n,s))})}trackProp(t){N(this,To).add(t)}getCurrentQuery(){return N(this,De)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const r=N(this,sr).defaultQueryOptions(t),n=N(this,sr).getQueryCache().build(N(this,sr),r);return n.fetch().then(()=>this.createResult(n,r))}fetch(t){return Ae(this,Ve,Tc).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),N(this,qt)))}createResult(t,r){var b;const n=N(this,De),s=this.options,a=N(this,qt),o=N(this,ga),i=N(this,Eo),l=t!==n?t.state:N(this,vc),{state:u}=t;let d={...u},f=!1,m;if(r._optimisticResults){const x=this.hasListeners(),S=!x&&$h(t,r),I=x&&Gh(t,n,r,s);(S||I)&&(d={...d,...zh(u.data,t.options)}),r._optimisticResults==="isRestoring"&&(d.fetchStatus="idle")}let{error:y,errorUpdatedAt:g,status:E}=d;m=d.data;let v=!1;if(r.placeholderData!==void 0&&m===void 0&&E==="pending"){let x;a!=null&&a.isPlaceholderData&&r.placeholderData===(i==null?void 0:i.placeholderData)?(x=a.data,v=!0):x=typeof r.placeholderData=="function"?r.placeholderData((b=N(this,Co))==null?void 0:b.state.data,N(this,Co)):r.placeholderData,x!==void 0&&(E="success",m=yd(a==null?void 0:a.data,x,r),f=!0)}if(r.select&&m!==void 0&&!v)if(a&&m===(o==null?void 0:o.data)&&r.select===N(this,Ec))m=N(this,ko);else try{ee(this,Ec,r.select),m=r.select(m),m=yd(a==null?void 0:a.data,m,r),ee(this,ko,m),ee(this,ws,null)}catch(x){ee(this,ws,x)}N(this,ws)&&(y=N(this,ws),m=N(this,ko),g=Date.now(),E="error");const w=d.fetchStatus==="fetching",A=E==="pending",C=E==="error",D=A&&w,L=m!==void 0,h={status:E,fetchStatus:d.fetchStatus,isPending:A,isSuccess:E==="success",isError:C,isInitialLoading:D,isLoading:D,data:m,dataUpdatedAt:d.dataUpdatedAt,error:y,errorUpdatedAt:g,failureCount:d.fetchFailureCount,failureReason:d.fetchFailureReason,errorUpdateCount:d.errorUpdateCount,isFetched:d.dataUpdateCount>0||d.errorUpdateCount>0,isFetchedAfterMount:d.dataUpdateCount>l.dataUpdateCount||d.errorUpdateCount>l.errorUpdateCount,isFetching:w,isRefetching:w&&!A,isLoadingError:C&&!L,isPaused:d.fetchStatus==="paused",isPlaceholderData:f,isRefetchError:C&&L,isStale:Ed(t,r),refetch:this.refetch,promise:N(this,Gn),isEnabled:Er(r.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const x=F=>{h.status==="error"?F.reject(h.error):h.data!==void 0&&F.resolve(h.data)},S=()=>{const F=ee(this,Gn,h.promise=xd());x(F)},I=N(this,Gn);switch(I.status){case"pending":t.queryHash===n.queryHash&&x(I);break;case"fulfilled":(h.status==="error"||h.data!==I.value)&&S();break;case"rejected":(h.status!=="error"||h.error!==I.reason)&&S();break}}return h}updateResult(){const t=N(this,qt),r=this.createResult(N(this,De),this.options);if(ee(this,ga,N(this,De).state),ee(this,Eo,this.options),N(this,ga).data!==void 0&&ee(this,Co,N(this,De)),Oc(r,t))return;ee(this,qt,r);const n=()=>{if(!t)return!0;const{notifyOnChangeProps:s}=this.options,a=typeof s=="function"?s():s;if(a==="all"||!a&&!N(this,To).size)return!0;const o=new Set(a??N(this,To));return this.options.throwOnError&&o.add("error"),Object.keys(N(this,qt)).some(i=>{const c=i;return N(this,qt)[c]!==t[c]&&o.has(c)})};Ae(this,Ve,F5).call(this,{listeners:n()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&Ae(this,Ve,Tm).call(this)}},sr=new WeakMap,De=new WeakMap,vc=new WeakMap,qt=new WeakMap,ga=new WeakMap,Eo=new WeakMap,Gn=new WeakMap,ws=new WeakMap,Ec=new WeakMap,ko=new WeakMap,Co=new WeakMap,xa=new WeakMap,wa=new WeakMap,vs=new WeakMap,To=new WeakMap,Ve=new WeakSet,Tc=function(t){Ae(this,Ve,Pm).call(this);let r=N(this,De).fetch(this.options,t);return t!=null&&t.throwOnError||(r=r.catch(jt)),r},Em=function(){Ae(this,Ve,Sm).call(this);const t=Xn(this.options.staleTime,N(this,De));if(Us||N(this,qt).isStale||!fd(t))return;const n=Ih(N(this,qt).dataUpdatedAt,t)+1;ee(this,xa,Fs.setTimeout(()=>{N(this,qt).isStale||this.updateResult()},n))},km=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(N(this,De)):this.options.refetchInterval)??!1},Cm=function(t){Ae(this,Ve,Am).call(this),ee(this,vs,t),!(Us||Er(this.options.enabled,N(this,De))===!1||!fd(N(this,vs))||N(this,vs)===0)&&ee(this,wa,Fs.setInterval(()=>{(this.options.refetchIntervalInBackground||gd.isFocused())&&Ae(this,Ve,Tc).call(this)},N(this,vs)))},Tm=function(){Ae(this,Ve,Em).call(this),Ae(this,Ve,Cm).call(this,Ae(this,Ve,km).call(this))},Sm=function(){N(this,xa)&&(Fs.clearTimeout(N(this,xa)),ee(this,xa,void 0))},Am=function(){N(this,wa)&&(Fs.clearInterval(N(this,wa)),ee(this,wa,void 0))},Pm=function(){const t=N(this,sr).getQueryCache().build(N(this,sr),this.options);if(t===N(this,De))return;const r=N(this,De);ee(this,De,t),ee(this,vc,t.state),this.hasListeners()&&(r==null||r.removeObserver(this),t.addObserver(this))},F5=function(t){kt.batch(()=>{t.listeners&&this.listeners.forEach(r=>{r(N(this,qt))}),N(this,sr).getQueryCache().notify({query:N(this,De),type:"observerResultsUpdated"})})},g5);function Gw(e,t){return Er(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function $h(e,t){return Gw(e,t)||e.state.data!==void 0&&vd(e,t,t.refetchOnMount)}function vd(e,t,r){if(Er(t.enabled,e)!==!1&&Xn(t.staleTime,e)!=="static"){const n=typeof r=="function"?r(e):r;return n==="always"||n!==!1&&Ed(e,t)}return!1}function Gh(e,t,r,n){return(e!==t||Er(n.enabled,e)===!1)&&(!r.suspense||e.state.status!=="error")&&Ed(e,r)}function Ed(e,t){return Er(t.enabled,e)!==!1&&e.isStaleByTime(Xn(t.staleTime,e))}function jw(e,t){return!Oc(e.getCurrentResult(),t)}function jh(e){return{onFetch:(t,r)=>{var u,d,f,m,y;const n=t.options,s=(f=(d=(u=t.fetchOptions)==null?void 0:u.meta)==null?void 0:d.fetchMore)==null?void 0:f.direction,a=((m=t.state.data)==null?void 0:m.pages)||[],o=((y=t.state.data)==null?void 0:y.pageParams)||[];let i={pages:[],pageParams:[]},c=0;const l=async()=>{let g=!1;const E=A=>{Object.defineProperty(A,"signal",{enumerable:!0,get:()=>(t.signal.aborted?g=!0:t.signal.addEventListener("abort",()=>{g=!0}),t.signal)})},v=Dh(t.options,t.fetchOptions),w=async(A,C,D)=>{if(g)return Promise.reject();if(C==null&&A.pages.length)return Promise.resolve(A);const T=(()=>{const S={client:t.client,queryKey:t.queryKey,pageParam:C,direction:D?"backward":"forward",meta:t.options.meta};return E(S),S})(),h=await v(T),{maxPages:b}=t.options,x=D?_w:Dw;return{pages:x(A.pages,h,b),pageParams:x(A.pageParams,C,b)}};if(s&&a.length){const A=s==="backward",C=A?Vw:Vh,D={pages:a,pageParams:o},L=C(n,D);i=await w(D,L,A)}else{const A=e??a.length;do{const C=c===0?o[0]??n.initialPageParam:Vh(n,i);if(c>0&&C==null)break;i=await w(i,C),c++}while(c<A)}return i};t.options.persister?t.fetchFn=()=>{var g,E;return(E=(g=t.options).persister)==null?void 0:E.call(g,l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},r)}:t.fetchFn=l}}}function Vh(e,{pages:t,pageParams:r}){const n=t.length-1;return t.length>0?e.getNextPageParam(t[n],t,r[n],r):void 0}function Vw(e,{pages:t,pageParams:r}){var n;return t.length>0?(n=e.getPreviousPageParam)==null?void 0:n.call(e,t[0],t,r[0],r):void 0}var Ww=(x5=class extends Lh{constructor(t){super();le(this,fn);le(this,kc);le(this,pn);le(this,Yt);le(this,va);ee(this,kc,t.client),this.mutationId=t.mutationId,ee(this,Yt,t.mutationCache),ee(this,pn,[]),this.state=t.state||Wh(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){N(this,pn).includes(t)||(N(this,pn).push(t),this.clearGcTimeout(),N(this,Yt).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){ee(this,pn,N(this,pn).filter(r=>r!==t)),this.scheduleGc(),N(this,Yt).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){N(this,pn).length||(this.state.status==="pending"?this.scheduleGc():N(this,Yt).remove(this))}continue(){var t;return((t=N(this,va))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var o,i,c,l,u,d,f,m,y,g,E,v,w,A,C,D,L,T,h,b;const r=()=>{Ae(this,fn,Ss).call(this,{type:"continue"})},n={client:N(this,kc),meta:this.options.meta,mutationKey:this.options.mutationKey};ee(this,va,Nh({fn:()=>this.options.mutationFn?this.options.mutationFn(t,n):Promise.reject(new Error("No mutationFn found")),onFail:(x,S)=>{Ae(this,fn,Ss).call(this,{type:"failed",failureCount:x,error:S})},onPause:()=>{Ae(this,fn,Ss).call(this,{type:"pause"})},onContinue:r,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>N(this,Yt).canRun(this)}));const s=this.state.status==="pending",a=!N(this,va).canStart();try{if(s)r();else{Ae(this,fn,Ss).call(this,{type:"pending",variables:t,isPaused:a}),await((i=(o=N(this,Yt).config).onMutate)==null?void 0:i.call(o,t,this,n));const S=await((l=(c=this.options).onMutate)==null?void 0:l.call(c,t,n));S!==this.state.context&&Ae(this,fn,Ss).call(this,{type:"pending",context:S,variables:t,isPaused:a})}const x=await N(this,va).start();return await((d=(u=N(this,Yt).config).onSuccess)==null?void 0:d.call(u,x,t,this.state.context,this,n)),await((m=(f=this.options).onSuccess)==null?void 0:m.call(f,x,t,this.state.context,n)),await((g=(y=N(this,Yt).config).onSettled)==null?void 0:g.call(y,x,null,this.state.variables,this.state.context,this,n)),await((v=(E=this.options).onSettled)==null?void 0:v.call(E,x,null,t,this.state.context,n)),Ae(this,fn,Ss).call(this,{type:"success",data:x}),x}catch(x){try{throw await((A=(w=N(this,Yt).config).onError)==null?void 0:A.call(w,x,t,this.state.context,this,n)),await((D=(C=this.options).onError)==null?void 0:D.call(C,x,t,this.state.context,n)),await((T=(L=N(this,Yt).config).onSettled)==null?void 0:T.call(L,void 0,x,this.state.variables,this.state.context,this,n)),await((b=(h=this.options).onSettled)==null?void 0:b.call(h,void 0,x,t,this.state.context,n)),x}finally{Ae(this,fn,Ss).call(this,{type:"error",error:x})}}finally{N(this,Yt).runNext(this)}}},kc=new WeakMap,pn=new WeakMap,Yt=new WeakMap,va=new WeakMap,fn=new WeakSet,Ss=function(t){const r=n=>{switch(t.type){case"failed":return{...n,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...n,isPaused:!0};case"continue":return{...n,isPaused:!1};case"pending":return{...n,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{...n,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...n,data:void 0,error:t.error,failureCount:n.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=r(this.state),kt.batch(()=>{N(this,pn).forEach(n=>{n.onMutationUpdate(t)}),N(this,Yt).notify({mutation:this,type:"updated",action:t})})},x5);function Wh(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var qw=(w5=class extends Ta{constructor(t={}){super();le(this,jn);le(this,Kr);le(this,Cc);this.config=t,ee(this,jn,new Set),ee(this,Kr,new Map),ee(this,Cc,0)}build(t,r,n){const s=new Ww({client:t,mutationCache:this,mutationId:++Ku(this,Cc)._,options:t.defaultMutationOptions(r),state:n});return this.add(s),s}add(t){N(this,jn).add(t);const r=Mc(t);if(typeof r=="string"){const n=N(this,Kr).get(r);n?n.push(t):N(this,Kr).set(r,[t])}this.notify({type:"added",mutation:t})}remove(t){if(N(this,jn).delete(t)){const r=Mc(t);if(typeof r=="string"){const n=N(this,Kr).get(r);if(n)if(n.length>1){const s=n.indexOf(t);s!==-1&&n.splice(s,1)}else n[0]===t&&N(this,Kr).delete(r)}}this.notify({type:"removed",mutation:t})}canRun(t){const r=Mc(t);if(typeof r=="string"){const n=N(this,Kr).get(r),s=n==null?void 0:n.find(a=>a.state.status==="pending");return!s||s===t}else return!0}runNext(t){var n;const r=Mc(t);if(typeof r=="string"){const s=(n=N(this,Kr).get(r))==null?void 0:n.find(a=>a!==t&&a.state.isPaused);return(s==null?void 0:s.continue())??Promise.resolve()}else return Promise.resolve()}clear(){kt.batch(()=>{N(this,jn).forEach(t=>{this.notify({type:"removed",mutation:t})}),N(this,jn).clear(),N(this,Kr).clear()})}getAll(){return Array.from(N(this,jn))}find(t){const r={exact:!0,...t};return this.getAll().find(n=>Fh(r,n))}findAll(t={}){return this.getAll().filter(r=>Fh(t,r))}notify(t){kt.batch(()=>{this.listeners.forEach(r=>{r(t)})})}resumePausedMutations(){const t=this.getAll().filter(r=>r.state.isPaused);return kt.batch(()=>Promise.all(t.map(r=>r.continue().catch(jt))))}},jn=new WeakMap,Kr=new WeakMap,Cc=new WeakMap,w5);function Mc(e){var t;return(t=e.options.scope)==null?void 0:t.id}var Yw=(v5=class extends Ta{constructor(t,r){super();le(this,qn);le(this,Vn);le(this,Es);le(this,ar);le(this,Wn);ee(this,Vn,t),this.setOptions(r),this.bindMethods(),Ae(this,qn,Zu).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){var n;const r=this.options;this.options=N(this,Vn).defaultMutationOptions(t),Oc(this.options,r)||N(this,Vn).getMutationCache().notify({type:"observerOptionsUpdated",mutation:N(this,ar),observer:this}),r!=null&&r.mutationKey&&this.options.mutationKey&&Os(r.mutationKey)!==Os(this.options.mutationKey)?this.reset():((n=N(this,ar))==null?void 0:n.state.status)==="pending"&&N(this,ar).setOptions(this.options)}onUnsubscribe(){var t;this.hasListeners()||(t=N(this,ar))==null||t.removeObserver(this)}onMutationUpdate(t){Ae(this,qn,Zu).call(this),Ae(this,qn,Im).call(this,t)}getCurrentResult(){return N(this,Es)}reset(){var t;(t=N(this,ar))==null||t.removeObserver(this),ee(this,ar,void 0),Ae(this,qn,Zu).call(this),Ae(this,qn,Im).call(this)}mutate(t,r){var n;return ee(this,Wn,r),(n=N(this,ar))==null||n.removeObserver(this),ee(this,ar,N(this,Vn).getMutationCache().build(N(this,Vn),this.options)),N(this,ar).addObserver(this),N(this,ar).execute(t)}},Vn=new WeakMap,Es=new WeakMap,ar=new WeakMap,Wn=new WeakMap,qn=new WeakSet,Zu=function(){var r;const t=((r=N(this,ar))==null?void 0:r.state)??Wh();ee(this,Es,{...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset})},Im=function(t){kt.batch(()=>{var r,n,s,a,o,i,c,l;if(N(this,Wn)&&this.hasListeners()){const u=N(this,Es).variables,d=N(this,Es).context,f={client:N(this,Vn),meta:this.options.meta,mutationKey:this.options.mutationKey};(t==null?void 0:t.type)==="success"?((n=(r=N(this,Wn)).onSuccess)==null||n.call(r,t.data,u,d,f),(a=(s=N(this,Wn)).onSettled)==null||a.call(s,t.data,null,u,d,f)):(t==null?void 0:t.type)==="error"&&((i=(o=N(this,Wn)).onError)==null||i.call(o,t.error,u,d,f),(l=(c=N(this,Wn)).onSettled)==null||l.call(c,void 0,t.error,u,d,f))}this.listeners.forEach(u=>{u(N(this,Es))})})},v5),Kw=(E5=class extends Ta{constructor(t={}){super();le(this,mn);this.config=t,ee(this,mn,new Map)}build(t,r,n){const s=r.queryKey,a=r.queryHash??md(s,r);let o=this.get(a);return o||(o=new Hw({client:t,queryKey:s,queryHash:a,options:t.defaultQueryOptions(r),state:n,defaultOptions:t.getQueryDefaults(s)}),this.add(o)),o}add(t){N(this,mn).has(t.queryHash)||(N(this,mn).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const r=N(this,mn).get(t.queryHash);r&&(t.destroy(),r===t&&N(this,mn).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){kt.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return N(this,mn).get(t)}getAll(){return[...N(this,mn).values()]}find(t){const r={exact:!0,...t};return this.getAll().find(n=>Bh(r,n))}findAll(t={}){const r=this.getAll();return Object.keys(t).length>0?r.filter(n=>Bh(t,n)):r}notify(t){kt.batch(()=>{this.listeners.forEach(r=>{r(t)})})}onFocus(){kt.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){kt.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},mn=new WeakMap,E5),Zw=(k5=class{constructor(e={}){le(this,ft);le(this,ks);le(this,Cs);le(this,So);le(this,Ao);le(this,Ts);le(this,Po);le(this,Io);ee(this,ft,e.queryCache||new Kw),ee(this,ks,e.mutationCache||new qw),ee(this,Cs,e.defaultOptions||{}),ee(this,So,new Map),ee(this,Ao,new Map),ee(this,Ts,0)}mount(){Ku(this,Ts)._++,N(this,Ts)===1&&(ee(this,Po,gd.subscribe(async e=>{e&&(await this.resumePausedMutations(),N(this,ft).onFocus())})),ee(this,Io,_c.subscribe(async e=>{e&&(await this.resumePausedMutations(),N(this,ft).onOnline())})))}unmount(){var e,t;Ku(this,Ts)._--,N(this,Ts)===0&&((e=N(this,Po))==null||e.call(this),ee(this,Po,void 0),(t=N(this,Io))==null||t.call(this),ee(this,Io,void 0))}isFetching(e){return N(this,ft).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return N(this,ks).findAll({...e,status:"pending"}).length}getQueryData(e){var r;const t=this.defaultQueryOptions({queryKey:e});return(r=N(this,ft).get(t.queryHash))==null?void 0:r.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),r=N(this,ft).build(this,t),n=r.state.data;return n===void 0?this.fetchQuery(e):(e.revalidateIfStale&&r.isStaleByTime(Xn(t.staleTime,r))&&this.prefetchQuery(t),Promise.resolve(n))}getQueriesData(e){return N(this,ft).findAll(e).map(({queryKey:t,state:r})=>{const n=r.data;return[t,n]})}setQueryData(e,t,r){const n=this.defaultQueryOptions({queryKey:e}),s=N(this,ft).get(n.queryHash),a=s==null?void 0:s.state.data,o=Fw(t,a);if(o!==void 0)return N(this,ft).build(this,n).setData(o,{...r,manual:!0})}setQueriesData(e,t,r){return kt.batch(()=>N(this,ft).findAll(e).map(({queryKey:n})=>[n,this.setQueryData(n,t,r)]))}getQueryState(e){var r;const t=this.defaultQueryOptions({queryKey:e});return(r=N(this,ft).get(t.queryHash))==null?void 0:r.state}removeQueries(e){const t=N(this,ft);kt.batch(()=>{t.findAll(e).forEach(r=>{t.remove(r)})})}resetQueries(e,t){const r=N(this,ft);return kt.batch(()=>(r.findAll(e).forEach(n=>{n.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const r={revert:!0,...t},n=kt.batch(()=>N(this,ft).findAll(e).map(s=>s.cancel(r)));return Promise.all(n).then(jt).catch(jt)}invalidateQueries(e,t={}){return kt.batch(()=>(N(this,ft).findAll(e).forEach(r=>{r.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 r={...t,cancelRefetch:t.cancelRefetch??!0},n=kt.batch(()=>N(this,ft).findAll(e).filter(s=>!s.isDisabled()&&!s.isStatic()).map(s=>{let a=s.fetch(void 0,r);return r.throwOnError||(a=a.catch(jt)),s.state.fetchStatus==="paused"?Promise.resolve():a}));return Promise.all(n).then(jt)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const r=N(this,ft).build(this,t);return r.isStaleByTime(Xn(t.staleTime,r))?r.fetch(t):Promise.resolve(r.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(jt).catch(jt)}fetchInfiniteQuery(e){return e.behavior=jh(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(jt).catch(jt)}ensureInfiniteQueryData(e){return e.behavior=jh(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return _c.isOnline()?N(this,ks).resumePausedMutations():Promise.resolve()}getQueryCache(){return N(this,ft)}getMutationCache(){return N(this,ks)}getDefaultOptions(){return N(this,Cs)}setDefaultOptions(e){ee(this,Cs,e)}setQueryDefaults(e,t){N(this,So).set(Os(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...N(this,So).values()],r={};return t.forEach(n=>{Uo(e,n.queryKey)&&Object.assign(r,n.defaultOptions)}),r}setMutationDefaults(e,t){N(this,Ao).set(Os(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...N(this,Ao).values()],r={};return t.forEach(n=>{Uo(e,n.mutationKey)&&Object.assign(r,n.defaultOptions)}),r}defaultQueryOptions(e){if(e._defaulted)return e;const t={...N(this,Cs).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=md(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===Dc&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...N(this,Cs).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){N(this,ft).clear(),N(this,ks).clear()}},ft=new WeakMap,ks=new WeakMap,Cs=new WeakMap,So=new WeakMap,Ao=new WeakMap,Ts=new WeakMap,Po=new WeakMap,Io=new WeakMap,k5),qh=xt.createContext(void 0),Nc=e=>{const t=xt.useContext(qh);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},Xw=({client:e,children:t})=>(xt.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),B.jsx(qh.Provider,{value:e,children:t})),Yh=xt.createContext(!1),Qw=()=>xt.useContext(Yh);Yh.Provider;function Jw(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var e3=xt.createContext(Jw()),t3=()=>xt.useContext(e3),r3=(e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))},n3=e=>{xt.useEffect(()=>{e.clearReset()},[e])},s3=({result:e,errorResetBoundary:t,throwOnError:r,query:n,suspense:s})=>e.isError&&!t.isReset()&&!e.isFetching&&n&&(s&&e.data===void 0||_h(r,[e.error,n])),a3=e=>{if(e.suspense){const r=s=>s==="static"?s:Math.max(s??1e3,1e3),n=e.staleTime;e.staleTime=typeof n=="function"?(...s)=>r(n(...s)):r(n),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},o3=(e,t)=>e.isLoading&&e.isFetching&&!t,i3=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,Kh=(e,t,r)=>t.fetchOptimistic(e).catch(()=>{r.clearReset()});function c3(e,t,r){var d,f,m,y,g;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 n=Qw(),s=t3(),a=Nc(),o=a.defaultQueryOptions(e);(f=(d=a.getDefaultOptions().queries)==null?void 0:d._experimental_beforeQuery)==null||f.call(d,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=n?"isRestoring":"optimistic",a3(o),r3(o,s),n3(s);const i=!a.getQueryCache().get(o.queryHash),[c]=xt.useState(()=>new t(a,o)),l=c.getOptimisticResult(o),u=!n&&e.subscribed!==!1;if(xt.useSyncExternalStore(xt.useCallback(E=>{const v=u?c.subscribe(kt.batchCalls(E)):jt;return c.updateResult(),v},[c,u]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),xt.useEffect(()=>{c.setOptions(o)},[o,c]),i3(o,l))throw Kh(o,c,s);if(s3({result:l,errorResetBoundary:s,throwOnError:o.throwOnError,query:a.getQueryCache().get(o.queryHash),suspense:o.suspense}))throw l.error;if((y=(m=a.getDefaultOptions().queries)==null?void 0:m._experimental_afterQuery)==null||y.call(m,o,l),o.experimental_prefetchInRender&&!Us&&o3(l,n)){const E=i?Kh(o,c,s):(g=a.getQueryCache().get(o.queryHash))==null?void 0:g.promise;E==null||E.catch(jt).finally(()=>{c.updateResult()})}return o.notifyOnChangeProps?l:c.trackResult(l)}function l3(e,t){return c3(e,$w)}function gn(e,t){const r=Nc(),[n]=xt.useState(()=>new Yw(r,e));xt.useEffect(()=>{n.setOptions(e)},[n,e]);const s=xt.useSyncExternalStore(xt.useCallback(o=>n.subscribe(kt.batchCalls(o)),[n]),()=>n.getCurrentResult(),()=>n.getCurrentResult()),a=xt.useCallback((o,i)=>{n.mutate(o,i).catch(jt)},[n]);if(s.error&&_h(n.options.throwOnError,[s.error]))throw s.error;return{...s,mutate:a,mutateAsync:s.mutate}}const u3=M.createContext(null),kd={didCatch:!1,error:null};class d3 extends M.Component{constructor(t){super(t),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=kd}static getDerivedStateFromError(t){return{didCatch:!0,error:t}}resetErrorBoundary(){const{error:t}=this.state;if(t!==null){for(var r,n,s=arguments.length,a=new Array(s),o=0;o<s;o++)a[o]=arguments[o];(r=(n=this.props).onReset)===null||r===void 0||r.call(n,{args:a,reason:"imperative-api"}),this.setState(kd)}}componentDidCatch(t,r){var n,s;(n=(s=this.props).onError)===null||n===void 0||n.call(s,t,r)}componentDidUpdate(t,r){const{didCatch:n}=this.state,{resetKeys:s}=this.props;if(n&&r.error!==null&&p3(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(kd)}}render(){const{children:t,fallbackRender:r,FallbackComponent:n,fallback:s}=this.props,{didCatch:a,error:o}=this.state;let i=t;if(a){const c={error:o,resetErrorBoundary:this.resetErrorBoundary};if(typeof r=="function")i=r(c);else if(n)i=M.createElement(n,c);else if(s!==void 0)i=s;else throw o}return M.createElement(u3.Provider,{value:{didCatch:a,error:o,resetErrorBoundary:this.resetErrorBoundary}},i)}}function p3(){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((r,n)=>!Object.is(r,t[n]))}const Zh=e=>{let t;const r=new Set,n=(l,u)=>{const d=typeof l=="function"?l(t):l;if(!Object.is(d,t)){const f=t;t=u??(typeof d!="object"||d===null)?d:Object.assign({},t,d),r.forEach(m=>m(t,f))}},s=()=>t,i={setState:n,getState:s,getInitialState:()=>c,subscribe:l=>(r.add(l),()=>r.delete(l))},c=t=e(n,s,i);return i},f3=(e=>e?Zh(e):Zh),m3=e=>e;function h3(e,t=m3){const r=M.useSyncExternalStore(e.subscribe,M.useCallback(()=>t(e.getState()),[e,t]),M.useCallback(()=>t(e.getInitialState()),[e,t]));return M.useDebugValue(r),r}const Xh=e=>{const t=f3(e),r=n=>h3(t,n);return Object.assign(r,t),r},b3=(e=>e?Xh(e):Xh),Qh={disclaimerAccepted:!0,currentTime:Date.now(),swapExecution:{}},Z=b3((e,t)=>({state:Qh,updateState:r=>e(n=>({state:{...n.state,...r}})),updateSwapExecution:r=>e(n=>({state:{...n.state,swapExecution:{...n.state.swapExecution,...r}}})),resetState:()=>{e({state:{...Qh,currentTime:Date.now(),swapExecution:{...t().state.swapExecution,status:void 0},isMarketOrder:t().state.isMarketOrder}})}}));(function(){try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".orbs_OrbsLogo{object-fit:contain;display:inline}.orbs_PoweredBy{border-radius:8px;margin-left:auto;margin-right:auto}.orbs_PoweredBy a{display:flex;align-items:center;justify-content:center;text-decoration:none;color:inherit}.orbs_PoweredBy span{font-size:14px}.orbs_PoweredBy .orbs_OrbsLogo{margin-left:6px;margin-right:6px;width:18px;height:18px}.orbs_Text{margin:0;padding:0}.orbs_Spinner{width:var(--size, 38px);height:var(--size, 38px);border:var(--border-width, 3px) solid var(--border-color, white);border-bottom-color:var(--bottom-border-color, rgba(255, 255, 255, .2));border-radius:50%;display:inline-block;box-sizing:border-box;animation:orbs_rotation 1s linear infinite}@keyframes orbs_rotation{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.orbs_TradeStepLayout{--layout-min-height: 220px;--layout-width: 100%;--layout-display: flex;--layout-direction: column;--layout-align: center;--layout-overflow: visible;display:var(--layout-display);flex-direction:var(--layout-direction);align-items:var(--layout-align);width:var(--layout-width);min-height:var(--layout-min-height);overflow:var(--layout-overflow)}.orbs_TradeStepLayoutBody{--body-gap: 20px;--body-margin-top: 30px;--body-width: 100%;--body-display: flex;--body-direction: column;--body-align: center;--body-overflow: visible;gap:var(--body-gap);align-items:var(--body-align);display:var(--body-display);flex-direction:var(--body-direction);width:var(--body-width);margin-top:var(--body-margin-top);overflow:var(--body-overflow)}.orbs_TradeStepLayoutHeader{--header-gap: 30px;--header-display: flex;--header-direction: column;--header-align: center;--header-justify: center;--header-overflow: visible;display:var(--header-display);flex-direction:var(--header-direction);align-items:var(--header-align);justify-content:var(--header-justify);gap:var(--header-gap);overflow:var(--header-overflow)}.orbs_TradeStepLayoutTitle{--title-font-size: 18px;--title-font-weight: 500;--title-line-height: normal;--title-color: inherit;--title-text-align: center;--title-margin: 0;--title-padding: 0;font-size:var(--title-font-size);font-weight:var(--title-font-weight);line-height:var(--title-line-height);color:var(--title-color);text-align:var(--title-text-align);margin:var(--title-margin);padding:var(--title-padding)}.orbs_StepIndicator{--indicator-display: flex;--indicator-align: center;--indicator-justify: flex-start;--indicator-height: 7px;--indicator-width: 120px;--indicator-border-radius: 999px;--indicator-bg-color: white;--indicator-margin-bottom: 20px;--indicator-position: relative;--indicator-overflow: hidden;--indicator-border: none;--indicator-box-shadow: none;display:var(--indicator-display);align-items:var(--indicator-align);justify-content:var(--indicator-justify);height:var(--indicator-height);width:var(--indicator-width);border-radius:var(--indicator-border-radius);overflow:var(--indicator-overflow);background-color:var(--indicator-bg-color);margin-bottom:var(--indicator-margin-bottom);position:var(--indicator-position);border:var(--indicator-border);box-shadow:var(--indicator-box-shadow)}.orbs_StepIndicatorLine{--line-height: 100%;--line-bg-color: black;--line-position: absolute;--line-top: 0;--line-left: 0;--line-right: 0;--line-bottom: 0;--line-transition: all .3s ease;--line-border-radius: inherit;--line-box-shadow: none;height:var(--line-height);background-color:var(--line-bg-color);position:var(--line-position);top:var(--line-top);left:var(--line-left);right:var(--line-right);bottom:var(--line-bottom);transition:var(--line-transition);border-radius:var(--line-border-radius);box-shadow:var(--line-box-shadow)}.orbs_TradeStepLayoutFooter{--footer-display: flex;--footer-align: center;--footer-justify: center;--footer-direction: column;--footer-margin-top: auto;--footer-padding-top: 30px;--footer-width: 100%;--footer-overflow: visible;--footer-border-top: none;display:var(--footer-display);align-items:var(--footer-align);justify-content:var(--footer-justify);flex-direction:var(--footer-direction);margin-top:var(--footer-margin-top);padding-top:var(--footer-padding-top);width:var(--footer-width);overflow:var(--footer-overflow);border-top:var(--footer-border-top)}.orbs_TradeStepLayoutFooter p{--footer-text-font-size: 15px;--footer-text-line-height: normal;--footer-text-color: inherit;--footer-text-margin: 0;--footer-text-padding: 0;font-size:var(--footer-text-font-size);line-height:var(--footer-text-line-height);color:var(--footer-text-color);margin:var(--footer-text-margin);padding:var(--footer-text-padding)}.orbs_TradeStepLayoutFooterLink{--link-color: inherit;--link-text-decoration: none;--link-font-size: 15px;--link-text-align: center;--link-margin: auto;--link-outline: none;--link-line-height: normal;--link-padding: 0;--link-transition: color .2s ease;--link-hover-color: inherit;--link-hover-text-decoration: underline;color:var(--link-color);text-decoration:var(--link-text-decoration);font-size:var(--link-font-size);text-align:var(--link-text-align);margin-left:var(--link-margin);margin-right:var(--link-margin);outline:var(--link-outline);line-height:var(--link-line-height);padding:var(--link-padding);transition:var(--link-transition)}.orbs_TradeStepLayoutFooterLink:hover{color:var(--link-hover-color);text-decoration:var(--link-hover-text-decoration)}.orbs_TradeStepLayoutSuccessIcon{--success-icon-display: flex;--success-icon-justify: center;--success-icon-align: center;--success-icon-width: 60px;--success-icon-height: 60px;--success-icon-border-radius: 50%;--success-icon-overflow: visible;--success-icon-bg-color: transparent;--success-icon-border: none;--success-icon-box-shadow: none;display:var(--success-icon-display);justify-content:var(--success-icon-justify);align-items:var(--success-icon-align);width:var(--success-icon-width);height:var(--success-icon-height);border-radius:var(--success-icon-border-radius);overflow:var(--success-icon-overflow);background-color:var(--success-icon-bg-color);border:var(--success-icon-border);box-shadow:var(--success-icon-box-shadow)}.orbs_TradeStepLayoutErrorIcon{--error-icon-width: 80px;--error-icon-height: 80px;--error-icon-display: flex;--error-icon-justify: center;--error-icon-align: center;--error-icon-overflow: visible;--error-icon-bg-color: transparent;--error-icon-border: none;--error-icon-box-shadow: none;width:var(--error-icon-width);height:var(--error-icon-height);display:var(--error-icon-display);justify-content:var(--error-icon-justify);align-items:var(--error-icon-align);overflow:var(--error-icon-overflow);background-color:var(--error-icon-bg-color);border:var(--error-icon-border);box-shadow:var(--error-icon-box-shadow)}.orbs_FailedContentMsg{font-size:22px;font-weight:500}.orbs_TradePreview{display:flex;align-items:center;justify-content:center;gap:8px;width:100%}.orbs_TradePreviewToken{display:flex;align-items:center;gap:6px;max-width:calc(50% - 30px)}.orbs_TradePreviewToken p{--token-font-size: 15px;--token-white-space: nowrap;--token-overflow: hidden;--token-text-overflow: ellipsis;--token-flex: 1;--token-margin: 0;--token-padding: 0;font-size:var(--token-font-size);white-space:var(--token-white-space);overflow:var(--token-overflow);text-overflow:var(--token-text-overflow);flex:var(--token-flex);margin:var(--token-margin)}.orbs_TradepPreviewIcon{width:22px;height:22px}.orbs_TradepPreviewLogo{width:24px;height:24px;border-radius:50%;overflow:hidden}.orbs_FlexRow{display:flex;flex-direction:row}.orbs_FlexColumn{display:flex;flex-direction:column}@keyframes orbs_skeletonAnimation{0%{opacity:.2}to{opacity:.4}}.orbs_SkeletonLoader{animation:orbs_skeletonAnimation 1s linear infinite alternate;background-color:#fff}.orbs_Main-wrapper{width:100%}.orbs_Main{width:100%;display:flex;flex-direction:column;gap:28px}.orbs_MainToken{display:flex;flex-direction:row;align-items:center;justify-content:space-between;width:100%;gap:8px}.orbs_MainTokenLeft{display:flex;flex-direction:column;align-items:flex-start;gap:8px}.orbs_MainTokenUsd{display:flex;align-items:center;gap:5px}.orbs_MainTokenUsd small{font-size:12px;opacity:.6}.orbs_MainContentLoader{width:100%;display:flex;gap:15px;align-items:center;margin-top:20px}.orbs_MainContentRectengularLoader{flex:1;height:20px;max-width:250px;border-radius:20px}.orbs_MainContentCircleLoader{width:30px;height:30px;border-radius:50%}.orbs_MainTokenLogo{--width: 40px;--height: 40px;width:var(--width);height:var(--height)}.orbs_MainTokenLogo img{width:100%;height:100%;object-fit:cover}.orbs_SwapFlow{display:flex;flex-direction:column;justify-content:center;align-items:center;width:100%}.orbs_SwapFlow *{box-sizing:border-box}")),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();const Ne=e=>`orbs_${e}`;function Oo({children:e,className:t=""}){return B.jsx("p",{className:`${t} ${Ne("Text")}`,children:e})}const Jh=M.createContext({});function y3({children:e,...t}){return B.jsx(Jh.Provider,{value:t,children:e})}const Zr=()=>M.useContext(Jh);var mt=(e=>(e[e.LOADING=1]="LOADING",e[e.SUCCESS=2]="SUCCESS",e[e.FAILED=3]="FAILED",e))(mt||{});const g3=({className:e="",size:t=38,borderWidth:r=3,borderColor:n="white",bottomBorderColor:s="rgba(255, 255, 255, 0.2)"})=>{const a={"--size":`${t}px`,"--border-width":`${r}px`,"--border-color":n,"--bottom-border-color":s};return B.jsx("div",{className:`${Ne("Spinner")} ${e}`,style:a})};function Lc({className:e="",body:t,footerLink:r,footerText:n,title:s,children:a}){return B.jsxs("div",{className:`${Ne("TradeStepLayout")} ${e}`,children:[B.jsxs("div",{className:Ne("TradeStepLayoutHeader"),children:[B.jsx(k3,{}),s&&B.jsx(Oo,{className:Ne("TradeStepLayoutTitle"),children:s})]}),t&&B.jsx("div",{className:Ne("TradeStepLayoutBody"),children:t}),B.jsx(x3,{link:r,text:n}),a]})}const x3=({link:e,text:t})=>{const{swapStatus:r}=Zr();return!e&&!t?null:B.jsxs("div",{className:Ne("TradeStepLayoutFooter"),children:[B.jsx(T3,{}),e?B.jsx(w3,{link:e,text:t}):r===mt.FAILED?void 0:B.jsx(Oo,{children:t})]})},w3=({link:e,text:t})=>B.jsx("a",{target:"_blank",className:Ne("TradeStepLayoutFooterLink"),href:e,children:t});function v3(){const{components:e}=Zr();return e.SuccessIcon?e.SuccessIcon:B.jsxs("svg",{fill:"none",viewBox:"0 0 16 16",className:Ne("TradeStepLayoutSuccessIcon"),children:[B.jsx("circle",{cx:"8",cy:"8",r:"7",strokeWidth:"1.5",stroke:"#00C853"}),B.jsx("path",{strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",stroke:"#00C853",d:"M5 8l2 2 4-4"})]})}function E3(){const{components:e}=Zr();return e.FailedIcon?e.FailedIcon:B.jsxs("svg",{className:Ne("TradeStepLayoutErrorIcon"),viewBox:"0 0 16 16",fill:"none",children:[B.jsx("circle",{cx:"8",cy:"8",r:"7",strokeWidth:"1.5",stroke:"#FF3D00"}),B.jsx("path",{strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",stroke:"#FF3D00",d:"M8 4v5M8 11h.01"})]})}const k3=()=>{const{swapStatus:e}=Zr();return e===mt.SUCCESS?B.jsx(v3,{}):e===mt.FAILED?B.jsx(E3,{}):B.jsx(C3,{})},C3=()=>{const{components:e}=Zr();return e.Loader?e.Loader:B.jsx(g3,{size:60,borderWidth:5,className:Ne("TradeStepLayoutSpinner")})},T3=()=>{const{totalSteps:e,currentStepIndex:t=0,swapStatus:r}=Zr();return r!==mt.LOADING||e===1?null:B.jsx("div",{className:Ne("StepIndicator"),children:B.jsx("div",{style:{width:`${100/(e||0)}%`,left:`${t*100/(e||0)}%`},className:Ne("StepIndicatorLine")})})},S3=({error:e,footerLink:t,footerText:r})=>B.jsx(Lc,{footerLink:t,footerText:r,body:e||B.jsx("p",{className:Ne("FailedContentMsg"),children:"Something went wrong"}),className:Ne("FailedContent")});function A3(){return B.jsx("svg",{fill:"currentColor",viewBox:"0 0 16 16",className:Ne("TradepPreviewIcon"),children:B.jsx("path",{fillRule:"evenodd",d:"M4 8a.5.5 0 01.5-.5h5.793L8.146 5.354a.5.5 0 11.708-.708l3 3a.5.5 0 010 .708l-3 3a.5.5 0 01-.708-.708L10.293 8.5H4.5A.5.5 0 014 8z"})})}const e1=({inTokenOnly:e})=>{const{inToken:t,outToken:r,inAmount:n,outAmount:s,components:a}=Zr();return B.jsxs("div",{className:Ne("TradePreview"),children:[B.jsx(t1,{token:t,amount:n,Logo:a==null?void 0:a.SrcTokenLogo}),!e&&B.jsxs(B.Fragment,{children:[B.jsx(A3,{}),B.jsx(t1,{token:r,amount:s,Logo:a==null?void 0:a.DstTokenLogo})]})]})},t1=({token:e,amount:t,Logo:r})=>B.jsxs("div",{className:Ne("TradePreviewToken"),children:[r||B.jsx("img",{src:e==null?void 0:e.logoUrl,className:Ne("TradepPreviewLogo"),alt:`${e==null?void 0:e.symbol} logo`}),B.jsxs(Oo,{children:[t," ",e==null?void 0:e.symbol]})]});function P3({title:e,footerLink:t,footerText:r,hideTokens:n}){return B.jsx(Lc,{title:e,className:Ne("Success"),body:!n&&B.jsx(e1,{}),footerLink:t,footerText:r})}const r1=({$gap:e=10,$alignItems:t="flex-start",children:r,className:n="",customStyles:s={}})=>{const a={gap:`${e}px`,alignItems:t,width:"100%",...s};return B.jsx("div",{className:`${Ne("FlexColumn")} ${n}`,style:a,children:r})};function n1({styles:e={},className:t=""}){return B.jsx("div",{style:e,className:`${Ne("SkeletonLoader")} ${t}`})}const I3=()=>B.jsxs("div",{className:`${Ne("MainContentLoader")}`,children:[B.jsx(n1,{className:`${Ne("MainContentCircleLoader")}`}),B.jsx(n1,{className:`${Ne("MainContentRectengularLoader")}`})]}),B3=({fromTitle:e,toTitle:t,inUsd:r,outUsd:n})=>{const{swapStatus:s,outAmount:a,inAmount:o,inToken:i,outToken:c,components:l,totalSteps:u}=Zr(),d=B.jsx(a1,{fromTitle:e,inUsd:r,inToken:i,toTitle:t,outUsd:n,outToken:c,inAmount:o,outAmount:a,SrcTokenLogo:l.SrcTokenLogo,DstTokenLogo:l.DstTokenLogo});return s?u?B.jsx(F3,{}):B.jsxs(r1,{children:[d,B.jsx(I3,{})]}):B.jsx(r1,{children:d})},s1=({amount:e,token:t,usd:r,title:n,Logo:s})=>B.jsxs("div",{className:`${Ne("MainToken")}`,children:[B.jsxs("div",{className:`${Ne("MainTokenLeft")}`,children:[B.jsx(Oo,{className:`${Ne("MainTokenTitle")}`,children:n}),B.jsx(Oo,{className:` ${Ne("MainTokenAmount")}`,children:`${e&&Number(e)>0?e:""} ${(t==null?void 0:t.symbol)||""}`}),r&&B.jsx("div",{className:` ${Ne("MainTokenUsd")}`,children:r})]}),s||B.jsx("div",{className:` ${Ne("MainTokenLogo")}`,children:t!=null&&t.logoUrl?B.jsx("img",{src:t==null?void 0:t.logoUrl,alt:"Token logo"}):null})]});function F3(){const{currentStep:e}=Zr();return e?B.jsx(Lc,{footerLink:e.footerLink,footerText:e.footerText,title:e.title,body:e.hideTokens?void 0:B.jsx(e1,{inTokenOnly:e==null?void 0:e.inTokenOnly})}):null}const a1=({fromTitle:e,inUsd:t,inToken:r,toTitle:n,outUsd:s,outToken:a,inAmount:o,outAmount:i,SrcTokenLogo:c,DstTokenLogo:l})=>B.jsxs("div",{className:`${Ne("Main")}`,children:[B.jsx(s1,{title:e||"Swap from",usd:t,token:r,amount:o,Logo:c}),B.jsx(s1,{title:n||"Swap to",usd:s,token:a,amount:i,Logo:l})]}),Qn=e=>B.jsx(y3,{...e,children:B.jsx(U3,{})}),U3=()=>{const{swapStatus:e,components:t,className:r}=Zr();return B.jsx("div",{className:`${Ne("SwapFlow")} ${r}`,children:e===mt.SUCCESS?t==null?void 0:t.Success:e===mt.FAILED?t==null?void 0:t.Failed:t==null?void 0:t.Main})};Qn.Success=P3,Qn.Failed=S3,Qn.Main=B3,Qn.StepLayout=Lc;var Mt=(e=>(e[e.EMPTY_LIMIT_PRICE=0]="EMPTY_LIMIT_PRICE",e[e.MAX_CHUNKS=1]="MAX_CHUNKS",e[e.MIN_CHUNKS=2]="MIN_CHUNKS",e[e.MIN_TRADE_SIZE=3]="MIN_TRADE_SIZE",e[e.MAX_FILL_DELAY=4]="MAX_FILL_DELAY",e[e.MIN_FILL_DELAY=5]="MIN_FILL_DELAY",e[e.MAX_ORDER_DURATION=6]="MAX_ORDER_DURATION",e[e.MIN_ORDER_DURATION=7]="MIN_ORDER_DURATION",e[e.MISSING_LIMIT_PRICE=8]="MISSING_LIMIT_PRICE",e[e.STOP_LOSS_TRIGGER_PRICE_GREATER_THAN_MARKET_PRICE=9]="STOP_LOSS_TRIGGER_PRICE_GREATER_THAN_MARKET_PRICE",e[e.TRIGGER_LIMIT_PRICE_GREATER_THAN_TRIGGER_PRICE=10]="TRIGGER_LIMIT_PRICE_GREATER_THAN_TRIGGER_PRICE",e[e.TAKE_PROFIT_TRIGGER_PRICE_LESS_THAN_MARKET_PRICE=11]="TAKE_PROFIT_TRIGGER_PRICE_LESS_THAN_MARKET_PRICE",e[e.EMPTY_TRIGGER_PRICE=12]="EMPTY_TRIGGER_PRICE",e[e.INSUFFICIENT_BALANCE=13]="INSUFFICIENT_BALANCE",e[e.MAX_ORDER_SIZE=14]="MAX_ORDER_SIZE",e))(Mt||{}),Ds=(e=>(e.WRAP="wrap",e.APPROVE="approve",e.CREATE="create",e))(Ds||{});const O3=e=>e.replace(/,/g,""),D3=async e=>{if(!(navigator!=null&&navigator.clipboard))return console.warn("Clipboard not supported"),!1;try{return await navigator.clipboard.writeText(e),!0}catch(t){return console.warn("Copy failed",t),!1}},o1=e=>{if(!e)return"";const t=Math.floor(e/1e3),r=Math.floor(t/(1440*60)),n=Math.floor(t%(1440*60)/3600),s=Math.floor(t%3600/60),a=t%60,o=[];return r&&o.push(`${r} days `),n&&o.push(`${n} hours `),s&&o.push(`${s} minutes`),a&&o.push(`${a} seconds`),o.join(" ")},Cd=(e,t)=>e?`${e.substring(0,(t==null?void 0:t.start)||6)}...${e.substring(e.length-((t==null?void 0:t.end)||5))}`:"",_3=e=>{const t="An error occurred.";if(!e||!e.message)return t;try{return e.message.toLowerCase().indexOf("rejected")?"Transaction Rejected":t}catch{return t}};function Do(e,t=6,r=8){if(!e)return"";const n=e.startsWith("-")?"-":"",s=n?e.slice(1):e,[a,o=""]=s.split(".");if(!o||Number(o)===0)return n+a;if(a!=="0"){const f=o.slice(0,t).replace(/0+$/,""),m=f?"."+f:"";return n+a+m}const i=o.search(/[^0]/);if(i===-1||i+1>r)return"0";const c=o.slice(0,i),u=o.slice(i).slice(0,t).replace(/0+$/,"");return u?n+"0."+c+u:"0"}const Td=e=>{var t,r,n,s;if(e!=null&&e.message)return((r=(t=e.message)==null?void 0:t.toLowerCase())==null?void 0:r.includes("rejected"))||((s=(n=e.message)==null?void 0:n.toLowerCase())==null?void 0:s.includes("denied"))},M3=e=>{switch(e){case Ft.base.id:return 1e-4;default:return .01}},i1=(e,t,r)=>{if(!j(e.srcAmountFilled||0).gt(0)||!j(e.dstAmountFilled||0).gt(0))return"";const n=bn(t,e.srcAmountFilled),s=bn(r,e.dstAmountFilled);return j(s).div(n).toFixed()},c1=(e,t,r)=>{if(e.type===ut.TWAP_MARKET)return"";const n=bn(t,e.srcAmountPerTrade),s=bn(r,e.dstMinAmountPerTrade);return j(s).div(n).toFixed()},l1=(e,t)=>{const r=Bs(t);return r&&Is(e.address)?r.wToken:e};function u1(e){return e?e/864e5:0}function Sd(e){return e?e/6e4:0}const N3=(e,t)=>e?ut.TWAP_MARKET:t===1?ut.LIMIT:ut.TWAP_LIMIT,Ad=(e,t,r)=>{const n=Bs(r);return Is((e==null?void 0:e.address)||"")&&Ps((t==null?void 0:t.address)||"",(n==null?void 0:n.wToken.address)||"")},Pd=(e,t,r)=>{const n=Bs(r);return Ps((e==null?void 0:e.address)||"",(n==null?void 0:n.wToken.address)||"")&&Is((t==null?void 0:t.address)||"")},_o=(e,t)=>{if(!t)return"";const r=Bs(t);return`${r==null?void 0:r.explorer}/tx/${e}`};function p(e){const t={formatters:void 0,fees:void 0,serializers:void 0,...e};function r(n){return s=>{const a=typeof s=="function"?s(n):s,o={...n,...a};return Object.assign(o,{extend:r(o)})}}return Object.assign(t,{extend:r(t)})}function L3(){return{}}const z3=p({id:16600,name:"0G Newton Testnet",nativeCurrency:{name:"A0GI",symbol:"A0GI",decimals:18},rpcUrls:{default:{http:["https://evmrpc-testnet.0g.ai"]}},blockExplorers:{default:{name:"0G BlockChain Explorer",url:"https://chainscan-newton.0g.ai"}},testnet:!0}),R3=p({id:16601,name:"0G Galileo Testnet",nativeCurrency:{name:"A0GI",symbol:"A0GI",decimals:18},rpcUrls:{default:{http:["https://evmrpc-testnet.0g.ai"]}},blockExplorers:{default:{name:"0G BlockChain Explorer",url:"https://chainscan-galileo.0g.ai"}},testnet:!0}),H3=p({id:16661,name:"0G Mainnet",nativeCurrency:{name:"0G",symbol:"0G",decimals:18},rpcUrls:{default:{http:["https://evmrpc.0g.ai"]}},blockExplorers:{default:{name:"0G BlockChain Explorer",url:"https://chainscan.0g.ai"}},testnet:!1}),$3=p({id:16602,name:"0G Galileo Testnet",nativeCurrency:{name:"A0GI",symbol:"A0GI",decimals:18},rpcUrls:{default:{http:["https://evmrpc-testnet.0g.ai"]}},blockExplorers:{default:{name:"0G BlockChain Explorer",url:"https://chainscan-galileo.0g.ai"}},testnet:!0}),G3=p({id:995,name:"5ireChain",nativeCurrency:{name:"5ire Token",symbol:"5IRE",decimals:18},rpcUrls:{default:{http:["https://rpc.5ire.network"]}},blockExplorers:{default:{name:"5ireChain Mainnet Explorer",url:"https://5irescan.io/"}},testnet:!1}),j3=p({id:179,name:"ABEY Mainnet",nativeCurrency:{name:"ABEY",symbol:"ABEY",decimals:18},rpcUrls:{default:{http:["https://rpc.abeychain.com"]}},blockExplorers:{default:{name:"Abey Scan",url:"https://abeyscan.com"}},testnet:!1}),d1="2.43.3";let Mo={getDocsUrl:({docsBaseUrl:e,docsPath:t="",docsSlug:r})=>t?`${e??"https://viem.sh"}${t}${r?`#${r}`:""}`:void 0,version:`viem@${d1}`},$=class Bm extends Error{constructor(t,r={}){var i;const n=(()=>{var c;return r.cause instanceof Bm?r.cause.details:(c=r.cause)!=null&&c.message?r.cause.message:r.details})(),s=r.cause instanceof Bm&&r.cause.docsPath||r.docsPath,a=(i=Mo.getDocsUrl)==null?void 0:i.call(Mo,{...r,docsPath:s}),o=[t||"An error occurred.","",...r.metaMessages?[...r.metaMessages,""]:[],...a?[`Docs: ${a}`]:[],...n?[`Details: ${n}`]:[],...Mo.version?[`Version: ${Mo.version}`]:[]].join(`
64
+ `,extractResults:d=>{var f;return(((f=d.data)==null?void 0:f.orderFilleds)||[]).map(m=>({...m,timestamp:new Date(m.timestamp).getTime()}))}})};class kw extends Error{constructor(){super("No graph endpoint found"),this.name="NoGraphEndpointError"}}const Cw=async({chainId:e,signal:t,page:r,limit:n,filters:s})=>{const a=await ww({chainId:e,signal:t,page:r,limit:n,filters:s}),[o,i]=await Promise.all([Ew({chainId:e,orders:a,signal:t}),vw({chainId:e,orders:a,signal:t})]);return a.map(l=>{const u=o==null?void 0:o.filter(d=>d.TWAP_id===Number(l.Contract_id)&&Ps(d.exchange,l.exchange)&&Ps(d.twapAddress,l.twapAddress));return gw(l,e,u,Tw(l,u||[],i))}).sort((l,u)=>u.createdAt-l.createdAt)},Tw=(e,t,r)=>{var i;const n=(i=r==null?void 0:r.find(c=>c.twapId===e.Contract_id.toString()&&Ps(c.twapAddress,e.twapAddress)))==null?void 0:i.status,a=Th(t).reduce((c,l)=>c.plus(l.inAmount),new j(0)).toFixed(),o=Ah(e.ask_srcAmount,a);return Sw(o,e.ask_deadline*1e3,n)},Ah=(e,t)=>{if(!t||!e)return 0;const r=j(t).dividedBy(e).toNumber();return r>=.99?100:r<=0?0:Number((r*100).toFixed(2))},Sw=(e,t,r)=>e===100?lt.Completed:r==="CANCELED"?lt.Canceled:r==="COMPLETED"?lt.Completed:t>Date.now()?lt.Open:lt.Expired,Ph=async({signal:e,page:t,chainId:r,limit:n,config:s,account:a})=>(await Promise.all([s?Cw({chainId:r,signal:e,page:t,limit:n,filters:{accounts:[a],configs:[s]}}):Promise.resolve([]),bw({chainId:r,signal:e,account:a})]).then(([c,l])=>[...c,...l])).sort((c,l)=>l.createdAt-c.createdAt),Aw={version:"0.0.37"};var Ta=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(){}},Pw={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Iw=(f5=class{constructor(){le(this,dn,Pw);le(this,pa,!1)}setTimeoutProvider(e){process.env.NODE_ENV!=="production"&&N(this,pa)&&e!==N(this,dn)&&console.error("[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",{previous:N(this,dn),provider:e}),ee(this,dn,e),process.env.NODE_ENV!=="production"&&ee(this,pa,!1)}setTimeout(e,t){return process.env.NODE_ENV!=="production"&&ee(this,pa,!0),N(this,dn).setTimeout(e,t)}clearTimeout(e){N(this,dn).clearTimeout(e)}setInterval(e,t){return process.env.NODE_ENV!=="production"&&ee(this,pa,!0),N(this,dn).setInterval(e,t)}clearInterval(e){N(this,dn).clearInterval(e)}},dn=new WeakMap,pa=new WeakMap,f5),Fs=new Iw;function Bw(e){setTimeout(e,0)}var Us=typeof window>"u"||"Deno"in globalThis;function jt(){}function Fw(e,t){return typeof e=="function"?e(t):e}function fd(e){return typeof e=="number"&&e>=0&&e!==1/0}function Ih(e,t){return Math.max(e+(t||0)-Date.now(),0)}function Xn(e,t){return typeof e=="function"?e(t):e}function Er(e,t){return typeof e=="function"?e(t):e}function Bh(e,t){const{type:r="all",exact:n,fetchStatus:s,predicate:a,queryKey:o,stale:i}=e;if(o){if(n){if(t.queryHash!==md(o,t.options))return!1}else if(!Uo(t.queryKey,o))return!1}if(r!=="all"){const c=t.isActive();if(r==="active"&&!c||r==="inactive"&&c)return!1}return!(typeof i=="boolean"&&t.isStale()!==i||s&&s!==t.state.fetchStatus||a&&!a(t))}function Fh(e,t){const{exact:r,status:n,predicate:s,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(r){if(Os(t.options.mutationKey)!==Os(a))return!1}else if(!Uo(t.options.mutationKey,a))return!1}return!(n&&t.state.status!==n||s&&!s(t))}function md(e,t){return((t==null?void 0:t.queryKeyHashFn)||Os)(e)}function Os(e){return JSON.stringify(e,(t,r)=>bd(r)?Object.keys(r).sort().reduce((n,s)=>(n[s]=r[s],n),{}):r)}function Uo(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(r=>Uo(e[r],t[r])):!1}var Uw=Object.prototype.hasOwnProperty;function hd(e,t){if(e===t)return e;const r=Uh(e)&&Uh(t);if(!r&&!(bd(e)&&bd(t)))return t;const s=(r?e:Object.keys(e)).length,a=r?t:Object.keys(t),o=a.length,i=r?new Array(o):{};let c=0;for(let l=0;l<o;l++){const u=r?l:a[l],d=e[u],f=t[u];if(d===f){i[u]=d,(r?l<s:Uw.call(e,u))&&c++;continue}if(d===null||f===null||typeof d!="object"||typeof f!="object"){i[u]=f;continue}const m=hd(d,f);i[u]=m,m===d&&c++}return s===o&&c===s?e:i}function Oc(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const r in e)if(e[r]!==t[r])return!1;return!0}function Uh(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function bd(e){if(!Oh(e))return!1;const t=e.constructor;if(t===void 0)return!0;const r=t.prototype;return!(!Oh(r)||!r.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function Oh(e){return Object.prototype.toString.call(e)==="[object Object]"}function Ow(e){return new Promise(t=>{Fs.setTimeout(t,e)})}function yd(e,t,r){if(typeof r.structuralSharing=="function")return r.structuralSharing(e,t);if(r.structuralSharing!==!1){if(process.env.NODE_ENV!=="production")try{return hd(e,t)}catch(n){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. [${r.queryHash}]: ${n}`),n}return hd(e,t)}return t}function Dw(e,t,r=0){const n=[...e,t];return r&&n.length>r?n.slice(1):n}function _w(e,t,r=0){const n=[t,...e];return r&&n.length>r?n.slice(0,-1):n}var Dc=Symbol();function Dh(e,t){return process.env.NODE_ENV!=="production"&&e.queryFn===Dc&&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===Dc?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function _h(e,t){return typeof e=="function"?e(...t):!!e}var Mw=(m5=class extends Ta{constructor(){super();le(this,fa);le(this,gs);le(this,go);ee(this,go,t=>{if(!Us&&window.addEventListener){const r=()=>t();return window.addEventListener("visibilitychange",r,!1),()=>{window.removeEventListener("visibilitychange",r)}}})}onSubscribe(){N(this,gs)||this.setEventListener(N(this,go))}onUnsubscribe(){var t;this.hasListeners()||((t=N(this,gs))==null||t.call(this),ee(this,gs,void 0))}setEventListener(t){var r;ee(this,go,t),(r=N(this,gs))==null||r.call(this),ee(this,gs,t(n=>{typeof n=="boolean"?this.setFocused(n):this.onFocus()}))}setFocused(t){N(this,fa)!==t&&(ee(this,fa,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(r=>{r(t)})}isFocused(){var t;return typeof N(this,fa)=="boolean"?N(this,fa):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},fa=new WeakMap,gs=new WeakMap,go=new WeakMap,m5),gd=new Mw;function xd(){let e,t;const r=new Promise((s,a)=>{e=s,t=a});r.status="pending",r.catch(()=>{});function n(s){Object.assign(r,s),delete r.resolve,delete r.reject}return r.resolve=s=>{n({status:"fulfilled",value:s}),e(s)},r.reject=s=>{n({status:"rejected",reason:s}),t(s)},r}var Nw=Bw;function Lw(){let e=[],t=0,r=i=>{i()},n=i=>{i()},s=Nw;const a=i=>{t?e.push(i):s(()=>{r(i)})},o=()=>{const i=e;e=[],i.length&&s(()=>{n(()=>{i.forEach(c=>{r(c)})})})};return{batch:i=>{let c;t++;try{c=i()}finally{t--,t||o()}return c},batchCalls:i=>(...c)=>{a(()=>{i(...c)})},schedule:a,setNotifyFunction:i=>{r=i},setBatchNotifyFunction:i=>{n=i},setScheduler:i=>{s=i}}}var kt=Lw(),zw=(h5=class extends Ta{constructor(){super();le(this,xo,!0);le(this,xs);le(this,wo);ee(this,wo,t=>{if(!Us&&window.addEventListener){const r=()=>t(!0),n=()=>t(!1);return window.addEventListener("online",r,!1),window.addEventListener("offline",n,!1),()=>{window.removeEventListener("online",r),window.removeEventListener("offline",n)}}})}onSubscribe(){N(this,xs)||this.setEventListener(N(this,wo))}onUnsubscribe(){var t;this.hasListeners()||((t=N(this,xs))==null||t.call(this),ee(this,xs,void 0))}setEventListener(t){var r;ee(this,wo,t),(r=N(this,xs))==null||r.call(this),ee(this,xs,t(this.setOnline.bind(this)))}setOnline(t){N(this,xo)!==t&&(ee(this,xo,t),this.listeners.forEach(n=>{n(t)}))}isOnline(){return N(this,xo)}},xo=new WeakMap,xs=new WeakMap,wo=new WeakMap,h5),_c=new zw;function Rw(e){return Math.min(1e3*2**e,3e4)}function Mh(e){return(e??"online")==="online"?_c.isOnline():!0}var wd=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function Nh(e){let t=!1,r=0,n;const s=xd(),a=()=>s.status!=="pending",o=g=>{var E;if(!a()){const v=new wd(g);f(v),(E=e.onCancel)==null||E.call(e,v)}},i=()=>{t=!0},c=()=>{t=!1},l=()=>gd.isFocused()&&(e.networkMode==="always"||_c.isOnline())&&e.canRun(),u=()=>Mh(e.networkMode)&&e.canRun(),d=g=>{a()||(n==null||n(),s.resolve(g))},f=g=>{a()||(n==null||n(),s.reject(g))},m=()=>new Promise(g=>{var E;n=v=>{(a()||l())&&g(v)},(E=e.onPause)==null||E.call(e)}).then(()=>{var g;n=void 0,a()||(g=e.onContinue)==null||g.call(e)}),y=()=>{if(a())return;let g;const E=r===0?e.initialPromise:void 0;try{g=E??e.fn()}catch(v){g=Promise.reject(v)}Promise.resolve(g).then(d).catch(v=>{var L;if(a())return;const w=e.retry??(Us?0:3),A=e.retryDelay??Rw,C=typeof A=="function"?A(r,v):A,D=w===!0||typeof w=="number"&&r<w||typeof w=="function"&&w(r,v);if(t||!D){f(v);return}r++,(L=e.onFail)==null||L.call(e,r,v),Ow(C).then(()=>l()?void 0:m()).then(()=>{t?f(v):y()})})};return{promise:s,status:()=>s.status,cancel:o,continue:()=>(n==null||n(),s),cancelRetry:i,continueRetry:c,canStart:u,start:()=>(u()?y():m().then(y),s)}}var Lh=(b5=class{constructor(){le(this,ma)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),fd(this.gcTime)&&ee(this,ma,Fs.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Us?1/0:300*1e3))}clearGcTimeout(){N(this,ma)&&(Fs.clearTimeout(N(this,ma)),ee(this,ma,void 0))}},ma=new WeakMap,b5),Hw=(y5=class extends Lh{constructor(t){super();le(this,Yr);le(this,ha);le(this,vo);le(this,Br);le(this,ba);le(this,Bt);le(this,wc);le(this,ya);ee(this,ya,!1),ee(this,wc,t.defaultOptions),this.setOptions(t.options),this.observers=[],ee(this,ba,t.client),ee(this,Br,N(this,ba).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,ee(this,ha,Hh(this.options)),this.state=t.state??N(this,ha),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=N(this,Bt))==null?void 0:t.promise}setOptions(t){if(this.options={...N(this,wc),...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const r=Hh(this.options);r.data!==void 0&&(this.setState(Rh(r.data,r.dataUpdatedAt)),ee(this,ha,r))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&N(this,Br).remove(this)}setData(t,r){const n=yd(this.state.data,t,this.options);return Ae(this,Yr,Yn).call(this,{data:n,type:"success",dataUpdatedAt:r==null?void 0:r.updatedAt,manual:r==null?void 0:r.manual}),n}setState(t,r){Ae(this,Yr,Yn).call(this,{type:"setState",state:t,setStateOptions:r})}cancel(t){var n,s;const r=(n=N(this,Bt))==null?void 0:n.promise;return(s=N(this,Bt))==null||s.cancel(t),r?r.then(jt).catch(jt):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(N(this,ha))}isActive(){return this.observers.some(t=>Er(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Dc||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>Xn(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:!Ih(this.state.dataUpdatedAt,t)}onFocus(){var r;const t=this.observers.find(n=>n.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(r=N(this,Bt))==null||r.continue()}onOnline(){var r;const t=this.observers.find(n=>n.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(r=N(this,Bt))==null||r.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),N(this,Br).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(r=>r!==t),this.observers.length||(N(this,Bt)&&(N(this,ya)?N(this,Bt).cancel({revert:!0}):N(this,Bt).cancelRetry()),this.scheduleGc()),N(this,Br).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||Ae(this,Yr,Yn).call(this,{type:"invalidate"})}async fetch(t,r){var c,l,u,d,f,m,y,g,E,v,w,A;if(this.state.fetchStatus!=="idle"&&((c=N(this,Bt))==null?void 0:c.status())!=="rejected"){if(this.state.data!==void 0&&(r!=null&&r.cancelRefetch))this.cancel({silent:!0});else if(N(this,Bt))return N(this,Bt).continueRetry(),N(this,Bt).promise}if(t&&this.setOptions(t),!this.options.queryFn){const C=this.observers.find(D=>D.options.queryFn);C&&this.setOptions(C.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 n=new AbortController,s=C=>{Object.defineProperty(C,"signal",{enumerable:!0,get:()=>(ee(this,ya,!0),n.signal)})},a=()=>{const C=Dh(this.options,r),L=(()=>{const T={client:N(this,ba),queryKey:this.queryKey,meta:this.meta};return s(T),T})();return ee(this,ya,!1),this.options.persister?this.options.persister(C,L,this):C(L)},i=(()=>{const C={fetchOptions:r,options:this.options,queryKey:this.queryKey,client:N(this,ba),state:this.state,fetchFn:a};return s(C),C})();(l=this.options.behavior)==null||l.onFetch(i,this),ee(this,vo,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((u=i.fetchOptions)==null?void 0:u.meta))&&Ae(this,Yr,Yn).call(this,{type:"fetch",meta:(d=i.fetchOptions)==null?void 0:d.meta}),ee(this,Bt,Nh({initialPromise:r==null?void 0:r.initialPromise,fn:i.fetchFn,onCancel:C=>{C instanceof wd&&C.revert&&this.setState({...N(this,vo),fetchStatus:"idle"}),n.abort()},onFail:(C,D)=>{Ae(this,Yr,Yn).call(this,{type:"failed",failureCount:C,error:D})},onPause:()=>{Ae(this,Yr,Yn).call(this,{type:"pause"})},onContinue:()=>{Ae(this,Yr,Yn).call(this,{type:"continue"})},retry:i.options.retry,retryDelay:i.options.retryDelay,networkMode:i.options.networkMode,canRun:()=>!0}));try{const C=await N(this,Bt).start();if(C===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(C),(m=(f=N(this,Br).config).onSuccess)==null||m.call(f,C,this),(g=(y=N(this,Br).config).onSettled)==null||g.call(y,C,this.state.error,this),C}catch(C){if(C instanceof wd){if(C.silent)return N(this,Bt).promise;if(C.revert){if(this.state.data===void 0)throw C;return this.state.data}}throw Ae(this,Yr,Yn).call(this,{type:"error",error:C}),(v=(E=N(this,Br).config).onError)==null||v.call(E,C,this),(A=(w=N(this,Br).config).onSettled)==null||A.call(w,this.state.data,C,this),C}finally{this.scheduleGc()}}},ha=new WeakMap,vo=new WeakMap,Br=new WeakMap,ba=new WeakMap,Bt=new WeakMap,wc=new WeakMap,ya=new WeakMap,Yr=new WeakSet,Yn=function(t){const r=n=>{switch(t.type){case"failed":return{...n,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...n,fetchStatus:"paused"};case"continue":return{...n,fetchStatus:"fetching"};case"fetch":return{...n,...zh(n.data,this.options),fetchMeta:t.meta??null};case"success":const s={...n,...Rh(t.data,t.dataUpdatedAt),dataUpdateCount:n.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return ee(this,vo,t.manual?s:void 0),s;case"error":const a=t.error;return{...n,error:a,errorUpdateCount:n.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:n.fetchFailureCount+1,fetchFailureReason:a,fetchStatus:"idle",status:"error"};case"invalidate":return{...n,isInvalidated:!0};case"setState":return{...n,...t.state}}};this.state=r(this.state),kt.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),N(this,Br).notify({query:this,type:"updated",action:t})})},y5);function zh(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Mh(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function Rh(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function Hh(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,r=t!==void 0,n=r?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:r?n??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}var $w=(g5=class extends Ta{constructor(t,r){super();le(this,Ve);le(this,sr);le(this,De);le(this,vc);le(this,qt);le(this,ga);le(this,Eo);le(this,Gn);le(this,ws);le(this,Ec);le(this,ko);le(this,Co);le(this,xa);le(this,wa);le(this,vs);le(this,To,new Set);this.options=r,ee(this,sr,t),ee(this,ws,null),ee(this,Gn,xd()),this.bindMethods(),this.setOptions(r)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(N(this,De).addObserver(this),$h(N(this,De),this.options)?Ae(this,Ve,Tc).call(this):this.updateResult(),Ae(this,Ve,Tm).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return vd(N(this,De),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return vd(N(this,De),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,Ae(this,Ve,Sm).call(this),Ae(this,Ve,Am).call(this),N(this,De).removeObserver(this)}setOptions(t){const r=this.options,n=N(this,De);if(this.options=N(this,sr).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Er(this.options.enabled,N(this,De))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");Ae(this,Ve,Pm).call(this),N(this,De).setOptions(this.options),r._defaulted&&!Oc(this.options,r)&&N(this,sr).getQueryCache().notify({type:"observerOptionsUpdated",query:N(this,De),observer:this});const s=this.hasListeners();s&&Gh(N(this,De),n,this.options,r)&&Ae(this,Ve,Tc).call(this),this.updateResult(),s&&(N(this,De)!==n||Er(this.options.enabled,N(this,De))!==Er(r.enabled,N(this,De))||Xn(this.options.staleTime,N(this,De))!==Xn(r.staleTime,N(this,De)))&&Ae(this,Ve,Em).call(this);const a=Ae(this,Ve,km).call(this);s&&(N(this,De)!==n||Er(this.options.enabled,N(this,De))!==Er(r.enabled,N(this,De))||a!==N(this,vs))&&Ae(this,Ve,Cm).call(this,a)}getOptimisticResult(t){const r=N(this,sr).getQueryCache().build(N(this,sr),t),n=this.createResult(r,t);return jw(this,n)&&(ee(this,qt,n),ee(this,Eo,this.options),ee(this,ga,N(this,De).state)),n}getCurrentResult(){return N(this,qt)}trackResult(t,r){return new Proxy(t,{get:(n,s)=>(this.trackProp(s),r==null||r(s),s==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&N(this,Gn).status==="pending"&&N(this,Gn).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(n,s))})}trackProp(t){N(this,To).add(t)}getCurrentQuery(){return N(this,De)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const r=N(this,sr).defaultQueryOptions(t),n=N(this,sr).getQueryCache().build(N(this,sr),r);return n.fetch().then(()=>this.createResult(n,r))}fetch(t){return Ae(this,Ve,Tc).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),N(this,qt)))}createResult(t,r){var b;const n=N(this,De),s=this.options,a=N(this,qt),o=N(this,ga),i=N(this,Eo),l=t!==n?t.state:N(this,vc),{state:u}=t;let d={...u},f=!1,m;if(r._optimisticResults){const x=this.hasListeners(),S=!x&&$h(t,r),I=x&&Gh(t,n,r,s);(S||I)&&(d={...d,...zh(u.data,t.options)}),r._optimisticResults==="isRestoring"&&(d.fetchStatus="idle")}let{error:y,errorUpdatedAt:g,status:E}=d;m=d.data;let v=!1;if(r.placeholderData!==void 0&&m===void 0&&E==="pending"){let x;a!=null&&a.isPlaceholderData&&r.placeholderData===(i==null?void 0:i.placeholderData)?(x=a.data,v=!0):x=typeof r.placeholderData=="function"?r.placeholderData((b=N(this,Co))==null?void 0:b.state.data,N(this,Co)):r.placeholderData,x!==void 0&&(E="success",m=yd(a==null?void 0:a.data,x,r),f=!0)}if(r.select&&m!==void 0&&!v)if(a&&m===(o==null?void 0:o.data)&&r.select===N(this,Ec))m=N(this,ko);else try{ee(this,Ec,r.select),m=r.select(m),m=yd(a==null?void 0:a.data,m,r),ee(this,ko,m),ee(this,ws,null)}catch(x){ee(this,ws,x)}N(this,ws)&&(y=N(this,ws),m=N(this,ko),g=Date.now(),E="error");const w=d.fetchStatus==="fetching",A=E==="pending",C=E==="error",D=A&&w,L=m!==void 0,h={status:E,fetchStatus:d.fetchStatus,isPending:A,isSuccess:E==="success",isError:C,isInitialLoading:D,isLoading:D,data:m,dataUpdatedAt:d.dataUpdatedAt,error:y,errorUpdatedAt:g,failureCount:d.fetchFailureCount,failureReason:d.fetchFailureReason,errorUpdateCount:d.errorUpdateCount,isFetched:d.dataUpdateCount>0||d.errorUpdateCount>0,isFetchedAfterMount:d.dataUpdateCount>l.dataUpdateCount||d.errorUpdateCount>l.errorUpdateCount,isFetching:w,isRefetching:w&&!A,isLoadingError:C&&!L,isPaused:d.fetchStatus==="paused",isPlaceholderData:f,isRefetchError:C&&L,isStale:Ed(t,r),refetch:this.refetch,promise:N(this,Gn),isEnabled:Er(r.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const x=F=>{h.status==="error"?F.reject(h.error):h.data!==void 0&&F.resolve(h.data)},S=()=>{const F=ee(this,Gn,h.promise=xd());x(F)},I=N(this,Gn);switch(I.status){case"pending":t.queryHash===n.queryHash&&x(I);break;case"fulfilled":(h.status==="error"||h.data!==I.value)&&S();break;case"rejected":(h.status!=="error"||h.error!==I.reason)&&S();break}}return h}updateResult(){const t=N(this,qt),r=this.createResult(N(this,De),this.options);if(ee(this,ga,N(this,De).state),ee(this,Eo,this.options),N(this,ga).data!==void 0&&ee(this,Co,N(this,De)),Oc(r,t))return;ee(this,qt,r);const n=()=>{if(!t)return!0;const{notifyOnChangeProps:s}=this.options,a=typeof s=="function"?s():s;if(a==="all"||!a&&!N(this,To).size)return!0;const o=new Set(a??N(this,To));return this.options.throwOnError&&o.add("error"),Object.keys(N(this,qt)).some(i=>{const c=i;return N(this,qt)[c]!==t[c]&&o.has(c)})};Ae(this,Ve,F5).call(this,{listeners:n()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&Ae(this,Ve,Tm).call(this)}},sr=new WeakMap,De=new WeakMap,vc=new WeakMap,qt=new WeakMap,ga=new WeakMap,Eo=new WeakMap,Gn=new WeakMap,ws=new WeakMap,Ec=new WeakMap,ko=new WeakMap,Co=new WeakMap,xa=new WeakMap,wa=new WeakMap,vs=new WeakMap,To=new WeakMap,Ve=new WeakSet,Tc=function(t){Ae(this,Ve,Pm).call(this);let r=N(this,De).fetch(this.options,t);return t!=null&&t.throwOnError||(r=r.catch(jt)),r},Em=function(){Ae(this,Ve,Sm).call(this);const t=Xn(this.options.staleTime,N(this,De));if(Us||N(this,qt).isStale||!fd(t))return;const n=Ih(N(this,qt).dataUpdatedAt,t)+1;ee(this,xa,Fs.setTimeout(()=>{N(this,qt).isStale||this.updateResult()},n))},km=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(N(this,De)):this.options.refetchInterval)??!1},Cm=function(t){Ae(this,Ve,Am).call(this),ee(this,vs,t),!(Us||Er(this.options.enabled,N(this,De))===!1||!fd(N(this,vs))||N(this,vs)===0)&&ee(this,wa,Fs.setInterval(()=>{(this.options.refetchIntervalInBackground||gd.isFocused())&&Ae(this,Ve,Tc).call(this)},N(this,vs)))},Tm=function(){Ae(this,Ve,Em).call(this),Ae(this,Ve,Cm).call(this,Ae(this,Ve,km).call(this))},Sm=function(){N(this,xa)&&(Fs.clearTimeout(N(this,xa)),ee(this,xa,void 0))},Am=function(){N(this,wa)&&(Fs.clearInterval(N(this,wa)),ee(this,wa,void 0))},Pm=function(){const t=N(this,sr).getQueryCache().build(N(this,sr),this.options);if(t===N(this,De))return;const r=N(this,De);ee(this,De,t),ee(this,vc,t.state),this.hasListeners()&&(r==null||r.removeObserver(this),t.addObserver(this))},F5=function(t){kt.batch(()=>{t.listeners&&this.listeners.forEach(r=>{r(N(this,qt))}),N(this,sr).getQueryCache().notify({query:N(this,De),type:"observerResultsUpdated"})})},g5);function Gw(e,t){return Er(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function $h(e,t){return Gw(e,t)||e.state.data!==void 0&&vd(e,t,t.refetchOnMount)}function vd(e,t,r){if(Er(t.enabled,e)!==!1&&Xn(t.staleTime,e)!=="static"){const n=typeof r=="function"?r(e):r;return n==="always"||n!==!1&&Ed(e,t)}return!1}function Gh(e,t,r,n){return(e!==t||Er(n.enabled,e)===!1)&&(!r.suspense||e.state.status!=="error")&&Ed(e,r)}function Ed(e,t){return Er(t.enabled,e)!==!1&&e.isStaleByTime(Xn(t.staleTime,e))}function jw(e,t){return!Oc(e.getCurrentResult(),t)}function jh(e){return{onFetch:(t,r)=>{var u,d,f,m,y;const n=t.options,s=(f=(d=(u=t.fetchOptions)==null?void 0:u.meta)==null?void 0:d.fetchMore)==null?void 0:f.direction,a=((m=t.state.data)==null?void 0:m.pages)||[],o=((y=t.state.data)==null?void 0:y.pageParams)||[];let i={pages:[],pageParams:[]},c=0;const l=async()=>{let g=!1;const E=A=>{Object.defineProperty(A,"signal",{enumerable:!0,get:()=>(t.signal.aborted?g=!0:t.signal.addEventListener("abort",()=>{g=!0}),t.signal)})},v=Dh(t.options,t.fetchOptions),w=async(A,C,D)=>{if(g)return Promise.reject();if(C==null&&A.pages.length)return Promise.resolve(A);const T=(()=>{const S={client:t.client,queryKey:t.queryKey,pageParam:C,direction:D?"backward":"forward",meta:t.options.meta};return E(S),S})(),h=await v(T),{maxPages:b}=t.options,x=D?_w:Dw;return{pages:x(A.pages,h,b),pageParams:x(A.pageParams,C,b)}};if(s&&a.length){const A=s==="backward",C=A?Vw:Vh,D={pages:a,pageParams:o},L=C(n,D);i=await w(D,L,A)}else{const A=e??a.length;do{const C=c===0?o[0]??n.initialPageParam:Vh(n,i);if(c>0&&C==null)break;i=await w(i,C),c++}while(c<A)}return i};t.options.persister?t.fetchFn=()=>{var g,E;return(E=(g=t.options).persister)==null?void 0:E.call(g,l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},r)}:t.fetchFn=l}}}function Vh(e,{pages:t,pageParams:r}){const n=t.length-1;return t.length>0?e.getNextPageParam(t[n],t,r[n],r):void 0}function Vw(e,{pages:t,pageParams:r}){var n;return t.length>0?(n=e.getPreviousPageParam)==null?void 0:n.call(e,t[0],t,r[0],r):void 0}var Ww=(x5=class extends Lh{constructor(t){super();le(this,fn);le(this,kc);le(this,pn);le(this,Yt);le(this,va);ee(this,kc,t.client),this.mutationId=t.mutationId,ee(this,Yt,t.mutationCache),ee(this,pn,[]),this.state=t.state||Wh(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){N(this,pn).includes(t)||(N(this,pn).push(t),this.clearGcTimeout(),N(this,Yt).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){ee(this,pn,N(this,pn).filter(r=>r!==t)),this.scheduleGc(),N(this,Yt).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){N(this,pn).length||(this.state.status==="pending"?this.scheduleGc():N(this,Yt).remove(this))}continue(){var t;return((t=N(this,va))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var o,i,c,l,u,d,f,m,y,g,E,v,w,A,C,D,L,T,h,b;const r=()=>{Ae(this,fn,Ss).call(this,{type:"continue"})},n={client:N(this,kc),meta:this.options.meta,mutationKey:this.options.mutationKey};ee(this,va,Nh({fn:()=>this.options.mutationFn?this.options.mutationFn(t,n):Promise.reject(new Error("No mutationFn found")),onFail:(x,S)=>{Ae(this,fn,Ss).call(this,{type:"failed",failureCount:x,error:S})},onPause:()=>{Ae(this,fn,Ss).call(this,{type:"pause"})},onContinue:r,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>N(this,Yt).canRun(this)}));const s=this.state.status==="pending",a=!N(this,va).canStart();try{if(s)r();else{Ae(this,fn,Ss).call(this,{type:"pending",variables:t,isPaused:a}),await((i=(o=N(this,Yt).config).onMutate)==null?void 0:i.call(o,t,this,n));const S=await((l=(c=this.options).onMutate)==null?void 0:l.call(c,t,n));S!==this.state.context&&Ae(this,fn,Ss).call(this,{type:"pending",context:S,variables:t,isPaused:a})}const x=await N(this,va).start();return await((d=(u=N(this,Yt).config).onSuccess)==null?void 0:d.call(u,x,t,this.state.context,this,n)),await((m=(f=this.options).onSuccess)==null?void 0:m.call(f,x,t,this.state.context,n)),await((g=(y=N(this,Yt).config).onSettled)==null?void 0:g.call(y,x,null,this.state.variables,this.state.context,this,n)),await((v=(E=this.options).onSettled)==null?void 0:v.call(E,x,null,t,this.state.context,n)),Ae(this,fn,Ss).call(this,{type:"success",data:x}),x}catch(x){try{throw await((A=(w=N(this,Yt).config).onError)==null?void 0:A.call(w,x,t,this.state.context,this,n)),await((D=(C=this.options).onError)==null?void 0:D.call(C,x,t,this.state.context,n)),await((T=(L=N(this,Yt).config).onSettled)==null?void 0:T.call(L,void 0,x,this.state.variables,this.state.context,this,n)),await((b=(h=this.options).onSettled)==null?void 0:b.call(h,void 0,x,t,this.state.context,n)),x}finally{Ae(this,fn,Ss).call(this,{type:"error",error:x})}}finally{N(this,Yt).runNext(this)}}},kc=new WeakMap,pn=new WeakMap,Yt=new WeakMap,va=new WeakMap,fn=new WeakSet,Ss=function(t){const r=n=>{switch(t.type){case"failed":return{...n,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...n,isPaused:!0};case"continue":return{...n,isPaused:!1};case"pending":return{...n,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{...n,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...n,data:void 0,error:t.error,failureCount:n.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=r(this.state),kt.batch(()=>{N(this,pn).forEach(n=>{n.onMutationUpdate(t)}),N(this,Yt).notify({mutation:this,type:"updated",action:t})})},x5);function Wh(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var qw=(w5=class extends Ta{constructor(t={}){super();le(this,jn);le(this,Kr);le(this,Cc);this.config=t,ee(this,jn,new Set),ee(this,Kr,new Map),ee(this,Cc,0)}build(t,r,n){const s=new Ww({client:t,mutationCache:this,mutationId:++Ku(this,Cc)._,options:t.defaultMutationOptions(r),state:n});return this.add(s),s}add(t){N(this,jn).add(t);const r=Mc(t);if(typeof r=="string"){const n=N(this,Kr).get(r);n?n.push(t):N(this,Kr).set(r,[t])}this.notify({type:"added",mutation:t})}remove(t){if(N(this,jn).delete(t)){const r=Mc(t);if(typeof r=="string"){const n=N(this,Kr).get(r);if(n)if(n.length>1){const s=n.indexOf(t);s!==-1&&n.splice(s,1)}else n[0]===t&&N(this,Kr).delete(r)}}this.notify({type:"removed",mutation:t})}canRun(t){const r=Mc(t);if(typeof r=="string"){const n=N(this,Kr).get(r),s=n==null?void 0:n.find(a=>a.state.status==="pending");return!s||s===t}else return!0}runNext(t){var n;const r=Mc(t);if(typeof r=="string"){const s=(n=N(this,Kr).get(r))==null?void 0:n.find(a=>a!==t&&a.state.isPaused);return(s==null?void 0:s.continue())??Promise.resolve()}else return Promise.resolve()}clear(){kt.batch(()=>{N(this,jn).forEach(t=>{this.notify({type:"removed",mutation:t})}),N(this,jn).clear(),N(this,Kr).clear()})}getAll(){return Array.from(N(this,jn))}find(t){const r={exact:!0,...t};return this.getAll().find(n=>Fh(r,n))}findAll(t={}){return this.getAll().filter(r=>Fh(t,r))}notify(t){kt.batch(()=>{this.listeners.forEach(r=>{r(t)})})}resumePausedMutations(){const t=this.getAll().filter(r=>r.state.isPaused);return kt.batch(()=>Promise.all(t.map(r=>r.continue().catch(jt))))}},jn=new WeakMap,Kr=new WeakMap,Cc=new WeakMap,w5);function Mc(e){var t;return(t=e.options.scope)==null?void 0:t.id}var Yw=(v5=class extends Ta{constructor(t,r){super();le(this,qn);le(this,Vn);le(this,Es);le(this,ar);le(this,Wn);ee(this,Vn,t),this.setOptions(r),this.bindMethods(),Ae(this,qn,Zu).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){var n;const r=this.options;this.options=N(this,Vn).defaultMutationOptions(t),Oc(this.options,r)||N(this,Vn).getMutationCache().notify({type:"observerOptionsUpdated",mutation:N(this,ar),observer:this}),r!=null&&r.mutationKey&&this.options.mutationKey&&Os(r.mutationKey)!==Os(this.options.mutationKey)?this.reset():((n=N(this,ar))==null?void 0:n.state.status)==="pending"&&N(this,ar).setOptions(this.options)}onUnsubscribe(){var t;this.hasListeners()||(t=N(this,ar))==null||t.removeObserver(this)}onMutationUpdate(t){Ae(this,qn,Zu).call(this),Ae(this,qn,Im).call(this,t)}getCurrentResult(){return N(this,Es)}reset(){var t;(t=N(this,ar))==null||t.removeObserver(this),ee(this,ar,void 0),Ae(this,qn,Zu).call(this),Ae(this,qn,Im).call(this)}mutate(t,r){var n;return ee(this,Wn,r),(n=N(this,ar))==null||n.removeObserver(this),ee(this,ar,N(this,Vn).getMutationCache().build(N(this,Vn),this.options)),N(this,ar).addObserver(this),N(this,ar).execute(t)}},Vn=new WeakMap,Es=new WeakMap,ar=new WeakMap,Wn=new WeakMap,qn=new WeakSet,Zu=function(){var r;const t=((r=N(this,ar))==null?void 0:r.state)??Wh();ee(this,Es,{...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset})},Im=function(t){kt.batch(()=>{var r,n,s,a,o,i,c,l;if(N(this,Wn)&&this.hasListeners()){const u=N(this,Es).variables,d=N(this,Es).context,f={client:N(this,Vn),meta:this.options.meta,mutationKey:this.options.mutationKey};(t==null?void 0:t.type)==="success"?((n=(r=N(this,Wn)).onSuccess)==null||n.call(r,t.data,u,d,f),(a=(s=N(this,Wn)).onSettled)==null||a.call(s,t.data,null,u,d,f)):(t==null?void 0:t.type)==="error"&&((i=(o=N(this,Wn)).onError)==null||i.call(o,t.error,u,d,f),(l=(c=N(this,Wn)).onSettled)==null||l.call(c,void 0,t.error,u,d,f))}this.listeners.forEach(u=>{u(N(this,Es))})})},v5),Kw=(E5=class extends Ta{constructor(t={}){super();le(this,mn);this.config=t,ee(this,mn,new Map)}build(t,r,n){const s=r.queryKey,a=r.queryHash??md(s,r);let o=this.get(a);return o||(o=new Hw({client:t,queryKey:s,queryHash:a,options:t.defaultQueryOptions(r),state:n,defaultOptions:t.getQueryDefaults(s)}),this.add(o)),o}add(t){N(this,mn).has(t.queryHash)||(N(this,mn).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const r=N(this,mn).get(t.queryHash);r&&(t.destroy(),r===t&&N(this,mn).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){kt.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return N(this,mn).get(t)}getAll(){return[...N(this,mn).values()]}find(t){const r={exact:!0,...t};return this.getAll().find(n=>Bh(r,n))}findAll(t={}){const r=this.getAll();return Object.keys(t).length>0?r.filter(n=>Bh(t,n)):r}notify(t){kt.batch(()=>{this.listeners.forEach(r=>{r(t)})})}onFocus(){kt.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){kt.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},mn=new WeakMap,E5),Zw=(k5=class{constructor(e={}){le(this,ft);le(this,ks);le(this,Cs);le(this,So);le(this,Ao);le(this,Ts);le(this,Po);le(this,Io);ee(this,ft,e.queryCache||new Kw),ee(this,ks,e.mutationCache||new qw),ee(this,Cs,e.defaultOptions||{}),ee(this,So,new Map),ee(this,Ao,new Map),ee(this,Ts,0)}mount(){Ku(this,Ts)._++,N(this,Ts)===1&&(ee(this,Po,gd.subscribe(async e=>{e&&(await this.resumePausedMutations(),N(this,ft).onFocus())})),ee(this,Io,_c.subscribe(async e=>{e&&(await this.resumePausedMutations(),N(this,ft).onOnline())})))}unmount(){var e,t;Ku(this,Ts)._--,N(this,Ts)===0&&((e=N(this,Po))==null||e.call(this),ee(this,Po,void 0),(t=N(this,Io))==null||t.call(this),ee(this,Io,void 0))}isFetching(e){return N(this,ft).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return N(this,ks).findAll({...e,status:"pending"}).length}getQueryData(e){var r;const t=this.defaultQueryOptions({queryKey:e});return(r=N(this,ft).get(t.queryHash))==null?void 0:r.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),r=N(this,ft).build(this,t),n=r.state.data;return n===void 0?this.fetchQuery(e):(e.revalidateIfStale&&r.isStaleByTime(Xn(t.staleTime,r))&&this.prefetchQuery(t),Promise.resolve(n))}getQueriesData(e){return N(this,ft).findAll(e).map(({queryKey:t,state:r})=>{const n=r.data;return[t,n]})}setQueryData(e,t,r){const n=this.defaultQueryOptions({queryKey:e}),s=N(this,ft).get(n.queryHash),a=s==null?void 0:s.state.data,o=Fw(t,a);if(o!==void 0)return N(this,ft).build(this,n).setData(o,{...r,manual:!0})}setQueriesData(e,t,r){return kt.batch(()=>N(this,ft).findAll(e).map(({queryKey:n})=>[n,this.setQueryData(n,t,r)]))}getQueryState(e){var r;const t=this.defaultQueryOptions({queryKey:e});return(r=N(this,ft).get(t.queryHash))==null?void 0:r.state}removeQueries(e){const t=N(this,ft);kt.batch(()=>{t.findAll(e).forEach(r=>{t.remove(r)})})}resetQueries(e,t){const r=N(this,ft);return kt.batch(()=>(r.findAll(e).forEach(n=>{n.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const r={revert:!0,...t},n=kt.batch(()=>N(this,ft).findAll(e).map(s=>s.cancel(r)));return Promise.all(n).then(jt).catch(jt)}invalidateQueries(e,t={}){return kt.batch(()=>(N(this,ft).findAll(e).forEach(r=>{r.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 r={...t,cancelRefetch:t.cancelRefetch??!0},n=kt.batch(()=>N(this,ft).findAll(e).filter(s=>!s.isDisabled()&&!s.isStatic()).map(s=>{let a=s.fetch(void 0,r);return r.throwOnError||(a=a.catch(jt)),s.state.fetchStatus==="paused"?Promise.resolve():a}));return Promise.all(n).then(jt)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const r=N(this,ft).build(this,t);return r.isStaleByTime(Xn(t.staleTime,r))?r.fetch(t):Promise.resolve(r.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(jt).catch(jt)}fetchInfiniteQuery(e){return e.behavior=jh(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(jt).catch(jt)}ensureInfiniteQueryData(e){return e.behavior=jh(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return _c.isOnline()?N(this,ks).resumePausedMutations():Promise.resolve()}getQueryCache(){return N(this,ft)}getMutationCache(){return N(this,ks)}getDefaultOptions(){return N(this,Cs)}setDefaultOptions(e){ee(this,Cs,e)}setQueryDefaults(e,t){N(this,So).set(Os(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...N(this,So).values()],r={};return t.forEach(n=>{Uo(e,n.queryKey)&&Object.assign(r,n.defaultOptions)}),r}setMutationDefaults(e,t){N(this,Ao).set(Os(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...N(this,Ao).values()],r={};return t.forEach(n=>{Uo(e,n.mutationKey)&&Object.assign(r,n.defaultOptions)}),r}defaultQueryOptions(e){if(e._defaulted)return e;const t={...N(this,Cs).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=md(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===Dc&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...N(this,Cs).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){N(this,ft).clear(),N(this,ks).clear()}},ft=new WeakMap,ks=new WeakMap,Cs=new WeakMap,So=new WeakMap,Ao=new WeakMap,Ts=new WeakMap,Po=new WeakMap,Io=new WeakMap,k5),qh=xt.createContext(void 0),Nc=e=>{const t=xt.useContext(qh);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},Xw=({client:e,children:t})=>(xt.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),B.jsx(qh.Provider,{value:e,children:t})),Yh=xt.createContext(!1),Qw=()=>xt.useContext(Yh);Yh.Provider;function Jw(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var e3=xt.createContext(Jw()),t3=()=>xt.useContext(e3),r3=(e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))},n3=e=>{xt.useEffect(()=>{e.clearReset()},[e])},s3=({result:e,errorResetBoundary:t,throwOnError:r,query:n,suspense:s})=>e.isError&&!t.isReset()&&!e.isFetching&&n&&(s&&e.data===void 0||_h(r,[e.error,n])),a3=e=>{if(e.suspense){const r=s=>s==="static"?s:Math.max(s??1e3,1e3),n=e.staleTime;e.staleTime=typeof n=="function"?(...s)=>r(n(...s)):r(n),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},o3=(e,t)=>e.isLoading&&e.isFetching&&!t,i3=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,Kh=(e,t,r)=>t.fetchOptimistic(e).catch(()=>{r.clearReset()});function c3(e,t,r){var d,f,m,y,g;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 n=Qw(),s=t3(),a=Nc(),o=a.defaultQueryOptions(e);(f=(d=a.getDefaultOptions().queries)==null?void 0:d._experimental_beforeQuery)==null||f.call(d,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=n?"isRestoring":"optimistic",a3(o),r3(o,s),n3(s);const i=!a.getQueryCache().get(o.queryHash),[c]=xt.useState(()=>new t(a,o)),l=c.getOptimisticResult(o),u=!n&&e.subscribed!==!1;if(xt.useSyncExternalStore(xt.useCallback(E=>{const v=u?c.subscribe(kt.batchCalls(E)):jt;return c.updateResult(),v},[c,u]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),xt.useEffect(()=>{c.setOptions(o)},[o,c]),i3(o,l))throw Kh(o,c,s);if(s3({result:l,errorResetBoundary:s,throwOnError:o.throwOnError,query:a.getQueryCache().get(o.queryHash),suspense:o.suspense}))throw l.error;if((y=(m=a.getDefaultOptions().queries)==null?void 0:m._experimental_afterQuery)==null||y.call(m,o,l),o.experimental_prefetchInRender&&!Us&&o3(l,n)){const E=i?Kh(o,c,s):(g=a.getQueryCache().get(o.queryHash))==null?void 0:g.promise;E==null||E.catch(jt).finally(()=>{c.updateResult()})}return o.notifyOnChangeProps?l:c.trackResult(l)}function l3(e,t){return c3(e,$w)}function gn(e,t){const r=Nc(),[n]=xt.useState(()=>new Yw(r,e));xt.useEffect(()=>{n.setOptions(e)},[n,e]);const s=xt.useSyncExternalStore(xt.useCallback(o=>n.subscribe(kt.batchCalls(o)),[n]),()=>n.getCurrentResult(),()=>n.getCurrentResult()),a=xt.useCallback((o,i)=>{n.mutate(o,i).catch(jt)},[n]);if(s.error&&_h(n.options.throwOnError,[s.error]))throw s.error;return{...s,mutate:a,mutateAsync:s.mutate}}const u3=M.createContext(null),kd={didCatch:!1,error:null};class d3 extends M.Component{constructor(t){super(t),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=kd}static getDerivedStateFromError(t){return{didCatch:!0,error:t}}resetErrorBoundary(){const{error:t}=this.state;if(t!==null){for(var r,n,s=arguments.length,a=new Array(s),o=0;o<s;o++)a[o]=arguments[o];(r=(n=this.props).onReset)===null||r===void 0||r.call(n,{args:a,reason:"imperative-api"}),this.setState(kd)}}componentDidCatch(t,r){var n,s;(n=(s=this.props).onError)===null||n===void 0||n.call(s,t,r)}componentDidUpdate(t,r){const{didCatch:n}=this.state,{resetKeys:s}=this.props;if(n&&r.error!==null&&p3(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(kd)}}render(){const{children:t,fallbackRender:r,FallbackComponent:n,fallback:s}=this.props,{didCatch:a,error:o}=this.state;let i=t;if(a){const c={error:o,resetErrorBoundary:this.resetErrorBoundary};if(typeof r=="function")i=r(c);else if(n)i=M.createElement(n,c);else if(s!==void 0)i=s;else throw o}return M.createElement(u3.Provider,{value:{didCatch:a,error:o,resetErrorBoundary:this.resetErrorBoundary}},i)}}function p3(){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((r,n)=>!Object.is(r,t[n]))}const Zh=e=>{let t;const r=new Set,n=(l,u)=>{const d=typeof l=="function"?l(t):l;if(!Object.is(d,t)){const f=t;t=u??(typeof d!="object"||d===null)?d:Object.assign({},t,d),r.forEach(m=>m(t,f))}},s=()=>t,i={setState:n,getState:s,getInitialState:()=>c,subscribe:l=>(r.add(l),()=>r.delete(l))},c=t=e(n,s,i);return i},f3=(e=>e?Zh(e):Zh),m3=e=>e;function h3(e,t=m3){const r=M.useSyncExternalStore(e.subscribe,M.useCallback(()=>t(e.getState()),[e,t]),M.useCallback(()=>t(e.getInitialState()),[e,t]));return M.useDebugValue(r),r}const Xh=e=>{const t=f3(e),r=n=>h3(t,n);return Object.assign(r,t),r},b3=(e=>e?Xh(e):Xh),Qh={disclaimerAccepted:!0,currentTime:Date.now(),swapExecution:{}},Z=b3((e,t)=>({state:Qh,updateState:r=>e(n=>({state:{...n.state,...r}})),updateSwapExecution:r=>e(n=>({state:{...n.state,swapExecution:{...n.state.swapExecution,...r}}})),resetState:()=>{e({state:{...Qh,currentTime:Date.now(),swapExecution:{...t().state.swapExecution,error:void 0,parsedError:void 0,status:void 0},isMarketOrder:t().state.isMarketOrder}})}}));(function(){try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".orbs_OrbsLogo{object-fit:contain;display:inline}.orbs_PoweredBy{border-radius:8px;margin-left:auto;margin-right:auto}.orbs_PoweredBy a{display:flex;align-items:center;justify-content:center;text-decoration:none;color:inherit}.orbs_PoweredBy span{font-size:14px}.orbs_PoweredBy .orbs_OrbsLogo{margin-left:6px;margin-right:6px;width:18px;height:18px}.orbs_Text{margin:0;padding:0}.orbs_Spinner{width:var(--size, 38px);height:var(--size, 38px);border:var(--border-width, 3px) solid var(--border-color, white);border-bottom-color:var(--bottom-border-color, rgba(255, 255, 255, .2));border-radius:50%;display:inline-block;box-sizing:border-box;animation:orbs_rotation 1s linear infinite}@keyframes orbs_rotation{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.orbs_TradeStepLayout{--layout-min-height: 220px;--layout-width: 100%;--layout-display: flex;--layout-direction: column;--layout-align: center;--layout-overflow: visible;display:var(--layout-display);flex-direction:var(--layout-direction);align-items:var(--layout-align);width:var(--layout-width);min-height:var(--layout-min-height);overflow:var(--layout-overflow)}.orbs_TradeStepLayoutBody{--body-gap: 20px;--body-margin-top: 30px;--body-width: 100%;--body-display: flex;--body-direction: column;--body-align: center;--body-overflow: visible;gap:var(--body-gap);align-items:var(--body-align);display:var(--body-display);flex-direction:var(--body-direction);width:var(--body-width);margin-top:var(--body-margin-top);overflow:var(--body-overflow)}.orbs_TradeStepLayoutHeader{--header-gap: 30px;--header-display: flex;--header-direction: column;--header-align: center;--header-justify: center;--header-overflow: visible;display:var(--header-display);flex-direction:var(--header-direction);align-items:var(--header-align);justify-content:var(--header-justify);gap:var(--header-gap);overflow:var(--header-overflow)}.orbs_TradeStepLayoutTitle{--title-font-size: 18px;--title-font-weight: 500;--title-line-height: normal;--title-color: inherit;--title-text-align: center;--title-margin: 0;--title-padding: 0;font-size:var(--title-font-size);font-weight:var(--title-font-weight);line-height:var(--title-line-height);color:var(--title-color);text-align:var(--title-text-align);margin:var(--title-margin);padding:var(--title-padding)}.orbs_StepIndicator{--indicator-display: flex;--indicator-align: center;--indicator-justify: flex-start;--indicator-height: 7px;--indicator-width: 120px;--indicator-border-radius: 999px;--indicator-bg-color: white;--indicator-margin-bottom: 20px;--indicator-position: relative;--indicator-overflow: hidden;--indicator-border: none;--indicator-box-shadow: none;display:var(--indicator-display);align-items:var(--indicator-align);justify-content:var(--indicator-justify);height:var(--indicator-height);width:var(--indicator-width);border-radius:var(--indicator-border-radius);overflow:var(--indicator-overflow);background-color:var(--indicator-bg-color);margin-bottom:var(--indicator-margin-bottom);position:var(--indicator-position);border:var(--indicator-border);box-shadow:var(--indicator-box-shadow)}.orbs_StepIndicatorLine{--line-height: 100%;--line-bg-color: black;--line-position: absolute;--line-top: 0;--line-left: 0;--line-right: 0;--line-bottom: 0;--line-transition: all .3s ease;--line-border-radius: inherit;--line-box-shadow: none;height:var(--line-height);background-color:var(--line-bg-color);position:var(--line-position);top:var(--line-top);left:var(--line-left);right:var(--line-right);bottom:var(--line-bottom);transition:var(--line-transition);border-radius:var(--line-border-radius);box-shadow:var(--line-box-shadow)}.orbs_TradeStepLayoutFooter{--footer-display: flex;--footer-align: center;--footer-justify: center;--footer-direction: column;--footer-margin-top: auto;--footer-padding-top: 30px;--footer-width: 100%;--footer-overflow: visible;--footer-border-top: none;display:var(--footer-display);align-items:var(--footer-align);justify-content:var(--footer-justify);flex-direction:var(--footer-direction);margin-top:var(--footer-margin-top);padding-top:var(--footer-padding-top);width:var(--footer-width);overflow:var(--footer-overflow);border-top:var(--footer-border-top)}.orbs_TradeStepLayoutFooter p{--footer-text-font-size: 15px;--footer-text-line-height: normal;--footer-text-color: inherit;--footer-text-margin: 0;--footer-text-padding: 0;font-size:var(--footer-text-font-size);line-height:var(--footer-text-line-height);color:var(--footer-text-color);margin:var(--footer-text-margin);padding:var(--footer-text-padding)}.orbs_TradeStepLayoutFooterLink{--link-color: inherit;--link-text-decoration: none;--link-font-size: 15px;--link-text-align: center;--link-margin: auto;--link-outline: none;--link-line-height: normal;--link-padding: 0;--link-transition: color .2s ease;--link-hover-color: inherit;--link-hover-text-decoration: underline;color:var(--link-color);text-decoration:var(--link-text-decoration);font-size:var(--link-font-size);text-align:var(--link-text-align);margin-left:var(--link-margin);margin-right:var(--link-margin);outline:var(--link-outline);line-height:var(--link-line-height);padding:var(--link-padding);transition:var(--link-transition)}.orbs_TradeStepLayoutFooterLink:hover{color:var(--link-hover-color);text-decoration:var(--link-hover-text-decoration)}.orbs_TradeStepLayoutSuccessIcon{--success-icon-display: flex;--success-icon-justify: center;--success-icon-align: center;--success-icon-width: 60px;--success-icon-height: 60px;--success-icon-border-radius: 50%;--success-icon-overflow: visible;--success-icon-bg-color: transparent;--success-icon-border: none;--success-icon-box-shadow: none;display:var(--success-icon-display);justify-content:var(--success-icon-justify);align-items:var(--success-icon-align);width:var(--success-icon-width);height:var(--success-icon-height);border-radius:var(--success-icon-border-radius);overflow:var(--success-icon-overflow);background-color:var(--success-icon-bg-color);border:var(--success-icon-border);box-shadow:var(--success-icon-box-shadow)}.orbs_TradeStepLayoutErrorIcon{--error-icon-width: 80px;--error-icon-height: 80px;--error-icon-display: flex;--error-icon-justify: center;--error-icon-align: center;--error-icon-overflow: visible;--error-icon-bg-color: transparent;--error-icon-border: none;--error-icon-box-shadow: none;width:var(--error-icon-width);height:var(--error-icon-height);display:var(--error-icon-display);justify-content:var(--error-icon-justify);align-items:var(--error-icon-align);overflow:var(--error-icon-overflow);background-color:var(--error-icon-bg-color);border:var(--error-icon-border);box-shadow:var(--error-icon-box-shadow)}.orbs_FailedContentMsg{font-size:22px;font-weight:500}.orbs_TradePreview{display:flex;align-items:center;justify-content:center;gap:8px;width:100%}.orbs_TradePreviewToken{display:flex;align-items:center;gap:6px;max-width:calc(50% - 30px)}.orbs_TradePreviewToken p{--token-font-size: 15px;--token-white-space: nowrap;--token-overflow: hidden;--token-text-overflow: ellipsis;--token-flex: 1;--token-margin: 0;--token-padding: 0;font-size:var(--token-font-size);white-space:var(--token-white-space);overflow:var(--token-overflow);text-overflow:var(--token-text-overflow);flex:var(--token-flex);margin:var(--token-margin)}.orbs_TradepPreviewIcon{width:22px;height:22px}.orbs_TradepPreviewLogo{width:24px;height:24px;border-radius:50%;overflow:hidden}.orbs_FlexRow{display:flex;flex-direction:row}.orbs_FlexColumn{display:flex;flex-direction:column}@keyframes orbs_skeletonAnimation{0%{opacity:.2}to{opacity:.4}}.orbs_SkeletonLoader{animation:orbs_skeletonAnimation 1s linear infinite alternate;background-color:#fff}.orbs_Main-wrapper{width:100%}.orbs_Main{width:100%;display:flex;flex-direction:column;gap:28px}.orbs_MainToken{display:flex;flex-direction:row;align-items:center;justify-content:space-between;width:100%;gap:8px}.orbs_MainTokenLeft{display:flex;flex-direction:column;align-items:flex-start;gap:8px}.orbs_MainTokenUsd{display:flex;align-items:center;gap:5px}.orbs_MainTokenUsd small{font-size:12px;opacity:.6}.orbs_MainContentLoader{width:100%;display:flex;gap:15px;align-items:center;margin-top:20px}.orbs_MainContentRectengularLoader{flex:1;height:20px;max-width:250px;border-radius:20px}.orbs_MainContentCircleLoader{width:30px;height:30px;border-radius:50%}.orbs_MainTokenLogo{--width: 40px;--height: 40px;width:var(--width);height:var(--height)}.orbs_MainTokenLogo img{width:100%;height:100%;object-fit:cover}.orbs_SwapFlow{display:flex;flex-direction:column;justify-content:center;align-items:center;width:100%}.orbs_SwapFlow *{box-sizing:border-box}")),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();const Ne=e=>`orbs_${e}`;function Oo({children:e,className:t=""}){return B.jsx("p",{className:`${t} ${Ne("Text")}`,children:e})}const Jh=M.createContext({});function y3({children:e,...t}){return B.jsx(Jh.Provider,{value:t,children:e})}const Zr=()=>M.useContext(Jh);var mt=(e=>(e[e.LOADING=1]="LOADING",e[e.SUCCESS=2]="SUCCESS",e[e.FAILED=3]="FAILED",e))(mt||{});const g3=({className:e="",size:t=38,borderWidth:r=3,borderColor:n="white",bottomBorderColor:s="rgba(255, 255, 255, 0.2)"})=>{const a={"--size":`${t}px`,"--border-width":`${r}px`,"--border-color":n,"--bottom-border-color":s};return B.jsx("div",{className:`${Ne("Spinner")} ${e}`,style:a})};function Lc({className:e="",body:t,footerLink:r,footerText:n,title:s,children:a}){return B.jsxs("div",{className:`${Ne("TradeStepLayout")} ${e}`,children:[B.jsxs("div",{className:Ne("TradeStepLayoutHeader"),children:[B.jsx(k3,{}),s&&B.jsx(Oo,{className:Ne("TradeStepLayoutTitle"),children:s})]}),t&&B.jsx("div",{className:Ne("TradeStepLayoutBody"),children:t}),B.jsx(x3,{link:r,text:n}),a]})}const x3=({link:e,text:t})=>{const{swapStatus:r}=Zr();return!e&&!t?null:B.jsxs("div",{className:Ne("TradeStepLayoutFooter"),children:[B.jsx(T3,{}),e?B.jsx(w3,{link:e,text:t}):r===mt.FAILED?void 0:B.jsx(Oo,{children:t})]})},w3=({link:e,text:t})=>B.jsx("a",{target:"_blank",className:Ne("TradeStepLayoutFooterLink"),href:e,children:t});function v3(){const{components:e}=Zr();return e.SuccessIcon?e.SuccessIcon:B.jsxs("svg",{fill:"none",viewBox:"0 0 16 16",className:Ne("TradeStepLayoutSuccessIcon"),children:[B.jsx("circle",{cx:"8",cy:"8",r:"7",strokeWidth:"1.5",stroke:"#00C853"}),B.jsx("path",{strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",stroke:"#00C853",d:"M5 8l2 2 4-4"})]})}function E3(){const{components:e}=Zr();return e.FailedIcon?e.FailedIcon:B.jsxs("svg",{className:Ne("TradeStepLayoutErrorIcon"),viewBox:"0 0 16 16",fill:"none",children:[B.jsx("circle",{cx:"8",cy:"8",r:"7",strokeWidth:"1.5",stroke:"#FF3D00"}),B.jsx("path",{strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",stroke:"#FF3D00",d:"M8 4v5M8 11h.01"})]})}const k3=()=>{const{swapStatus:e}=Zr();return e===mt.SUCCESS?B.jsx(v3,{}):e===mt.FAILED?B.jsx(E3,{}):B.jsx(C3,{})},C3=()=>{const{components:e}=Zr();return e.Loader?e.Loader:B.jsx(g3,{size:60,borderWidth:5,className:Ne("TradeStepLayoutSpinner")})},T3=()=>{const{totalSteps:e,currentStepIndex:t=0,swapStatus:r}=Zr();return r!==mt.LOADING||e===1?null:B.jsx("div",{className:Ne("StepIndicator"),children:B.jsx("div",{style:{width:`${100/(e||0)}%`,left:`${t*100/(e||0)}%`},className:Ne("StepIndicatorLine")})})},S3=({error:e,footerLink:t,footerText:r})=>B.jsx(Lc,{footerLink:t,footerText:r,body:e||B.jsx("p",{className:Ne("FailedContentMsg"),children:"Something went wrong"}),className:Ne("FailedContent")});function A3(){return B.jsx("svg",{fill:"currentColor",viewBox:"0 0 16 16",className:Ne("TradepPreviewIcon"),children:B.jsx("path",{fillRule:"evenodd",d:"M4 8a.5.5 0 01.5-.5h5.793L8.146 5.354a.5.5 0 11.708-.708l3 3a.5.5 0 010 .708l-3 3a.5.5 0 01-.708-.708L10.293 8.5H4.5A.5.5 0 014 8z"})})}const e1=({inTokenOnly:e})=>{const{inToken:t,outToken:r,inAmount:n,outAmount:s,components:a}=Zr();return B.jsxs("div",{className:Ne("TradePreview"),children:[B.jsx(t1,{token:t,amount:n,Logo:a==null?void 0:a.SrcTokenLogo}),!e&&B.jsxs(B.Fragment,{children:[B.jsx(A3,{}),B.jsx(t1,{token:r,amount:s,Logo:a==null?void 0:a.DstTokenLogo})]})]})},t1=({token:e,amount:t,Logo:r})=>B.jsxs("div",{className:Ne("TradePreviewToken"),children:[r||B.jsx("img",{src:e==null?void 0:e.logoUrl,className:Ne("TradepPreviewLogo"),alt:`${e==null?void 0:e.symbol} logo`}),B.jsxs(Oo,{children:[t," ",e==null?void 0:e.symbol]})]});function P3({title:e,footerLink:t,footerText:r,hideTokens:n}){return B.jsx(Lc,{title:e,className:Ne("Success"),body:!n&&B.jsx(e1,{}),footerLink:t,footerText:r})}const r1=({$gap:e=10,$alignItems:t="flex-start",children:r,className:n="",customStyles:s={}})=>{const a={gap:`${e}px`,alignItems:t,width:"100%",...s};return B.jsx("div",{className:`${Ne("FlexColumn")} ${n}`,style:a,children:r})};function n1({styles:e={},className:t=""}){return B.jsx("div",{style:e,className:`${Ne("SkeletonLoader")} ${t}`})}const I3=()=>B.jsxs("div",{className:`${Ne("MainContentLoader")}`,children:[B.jsx(n1,{className:`${Ne("MainContentCircleLoader")}`}),B.jsx(n1,{className:`${Ne("MainContentRectengularLoader")}`})]}),B3=({fromTitle:e,toTitle:t,inUsd:r,outUsd:n})=>{const{swapStatus:s,outAmount:a,inAmount:o,inToken:i,outToken:c,components:l,totalSteps:u}=Zr(),d=B.jsx(a1,{fromTitle:e,inUsd:r,inToken:i,toTitle:t,outUsd:n,outToken:c,inAmount:o,outAmount:a,SrcTokenLogo:l.SrcTokenLogo,DstTokenLogo:l.DstTokenLogo});return s?u?B.jsx(F3,{}):B.jsxs(r1,{children:[d,B.jsx(I3,{})]}):B.jsx(r1,{children:d})},s1=({amount:e,token:t,usd:r,title:n,Logo:s})=>B.jsxs("div",{className:`${Ne("MainToken")}`,children:[B.jsxs("div",{className:`${Ne("MainTokenLeft")}`,children:[B.jsx(Oo,{className:`${Ne("MainTokenTitle")}`,children:n}),B.jsx(Oo,{className:` ${Ne("MainTokenAmount")}`,children:`${e&&Number(e)>0?e:""} ${(t==null?void 0:t.symbol)||""}`}),r&&B.jsx("div",{className:` ${Ne("MainTokenUsd")}`,children:r})]}),s||B.jsx("div",{className:` ${Ne("MainTokenLogo")}`,children:t!=null&&t.logoUrl?B.jsx("img",{src:t==null?void 0:t.logoUrl,alt:"Token logo"}):null})]});function F3(){const{currentStep:e}=Zr();return e?B.jsx(Lc,{footerLink:e.footerLink,footerText:e.footerText,title:e.title,body:e.hideTokens?void 0:B.jsx(e1,{inTokenOnly:e==null?void 0:e.inTokenOnly})}):null}const a1=({fromTitle:e,inUsd:t,inToken:r,toTitle:n,outUsd:s,outToken:a,inAmount:o,outAmount:i,SrcTokenLogo:c,DstTokenLogo:l})=>B.jsxs("div",{className:`${Ne("Main")}`,children:[B.jsx(s1,{title:e||"Swap from",usd:t,token:r,amount:o,Logo:c}),B.jsx(s1,{title:n||"Swap to",usd:s,token:a,amount:i,Logo:l})]}),Qn=e=>B.jsx(y3,{...e,children:B.jsx(U3,{})}),U3=()=>{const{swapStatus:e,components:t,className:r}=Zr();return B.jsx("div",{className:`${Ne("SwapFlow")} ${r}`,children:e===mt.SUCCESS?t==null?void 0:t.Success:e===mt.FAILED?t==null?void 0:t.Failed:t==null?void 0:t.Main})};Qn.Success=P3,Qn.Failed=S3,Qn.Main=B3,Qn.StepLayout=Lc;var Mt=(e=>(e[e.EMPTY_LIMIT_PRICE=0]="EMPTY_LIMIT_PRICE",e[e.MAX_CHUNKS=1]="MAX_CHUNKS",e[e.MIN_CHUNKS=2]="MIN_CHUNKS",e[e.MIN_TRADE_SIZE=3]="MIN_TRADE_SIZE",e[e.MAX_FILL_DELAY=4]="MAX_FILL_DELAY",e[e.MIN_FILL_DELAY=5]="MIN_FILL_DELAY",e[e.MAX_ORDER_DURATION=6]="MAX_ORDER_DURATION",e[e.MIN_ORDER_DURATION=7]="MIN_ORDER_DURATION",e[e.MISSING_LIMIT_PRICE=8]="MISSING_LIMIT_PRICE",e[e.STOP_LOSS_TRIGGER_PRICE_GREATER_THAN_MARKET_PRICE=9]="STOP_LOSS_TRIGGER_PRICE_GREATER_THAN_MARKET_PRICE",e[e.TRIGGER_LIMIT_PRICE_GREATER_THAN_TRIGGER_PRICE=10]="TRIGGER_LIMIT_PRICE_GREATER_THAN_TRIGGER_PRICE",e[e.TAKE_PROFIT_TRIGGER_PRICE_LESS_THAN_MARKET_PRICE=11]="TAKE_PROFIT_TRIGGER_PRICE_LESS_THAN_MARKET_PRICE",e[e.EMPTY_TRIGGER_PRICE=12]="EMPTY_TRIGGER_PRICE",e[e.INSUFFICIENT_BALANCE=13]="INSUFFICIENT_BALANCE",e[e.MAX_ORDER_SIZE=14]="MAX_ORDER_SIZE",e))(Mt||{}),Ds=(e=>(e.WRAP="wrap",e.APPROVE="approve",e.CREATE="create",e))(Ds||{});const O3=e=>e.replace(/,/g,""),D3=async e=>{if(!(navigator!=null&&navigator.clipboard))return console.warn("Clipboard not supported"),!1;try{return await navigator.clipboard.writeText(e),!0}catch(t){return console.warn("Copy failed",t),!1}},o1=e=>{if(!e)return"";const t=Math.floor(e/1e3),r=Math.floor(t/(1440*60)),n=Math.floor(t%(1440*60)/3600),s=Math.floor(t%3600/60),a=t%60,o=[];return r&&o.push(`${r} days `),n&&o.push(`${n} hours `),s&&o.push(`${s} minutes`),a&&o.push(`${a} seconds`),o.join(" ")},Cd=(e,t)=>e?`${e.substring(0,(t==null?void 0:t.start)||6)}...${e.substring(e.length-((t==null?void 0:t.end)||5))}`:"",_3=e=>{const t="An error occurred.";if(!e||!e.message)return t;try{return e.message.toLowerCase().indexOf("rejected")?"Transaction Rejected":t}catch{return t}};function Do(e,t=6,r=8){if(!e)return"";const n=e.startsWith("-")?"-":"",s=n?e.slice(1):e,[a,o=""]=s.split(".");if(!o||Number(o)===0)return n+a;if(a!=="0"){const f=o.slice(0,t).replace(/0+$/,""),m=f?"."+f:"";return n+a+m}const i=o.search(/[^0]/);if(i===-1||i+1>r)return"0";const c=o.slice(0,i),u=o.slice(i).slice(0,t).replace(/0+$/,"");return u?n+"0."+c+u:"0"}const Td=e=>{var t,r,n,s;if(e!=null&&e.message)return((r=(t=e.message)==null?void 0:t.toLowerCase())==null?void 0:r.includes("rejected"))||((s=(n=e.message)==null?void 0:n.toLowerCase())==null?void 0:s.includes("denied"))},M3=e=>{switch(e){case Ft.base.id:return 1e-4;default:return .01}},i1=(e,t,r)=>{if(!j(e.srcAmountFilled||0).gt(0)||!j(e.dstAmountFilled||0).gt(0))return"";const n=bn(t,e.srcAmountFilled),s=bn(r,e.dstAmountFilled);return j(s).div(n).toFixed()},c1=(e,t,r)=>{if(e.type===ut.TWAP_MARKET)return"";const n=bn(t,e.srcAmountPerTrade),s=bn(r,e.dstMinAmountPerTrade);return j(s).div(n).toFixed()},l1=(e,t)=>{const r=Bs(t);return r&&Is(e.address)?r.wToken:e};function u1(e){return e?e/864e5:0}function Sd(e){return e?e/6e4:0}const N3=(e,t)=>e?ut.TWAP_MARKET:t===1?ut.LIMIT:ut.TWAP_LIMIT,Ad=(e,t,r)=>{const n=Bs(r);return Is((e==null?void 0:e.address)||"")&&Ps((t==null?void 0:t.address)||"",(n==null?void 0:n.wToken.address)||"")},Pd=(e,t,r)=>{const n=Bs(r);return Ps((e==null?void 0:e.address)||"",(n==null?void 0:n.wToken.address)||"")&&Is((t==null?void 0:t.address)||"")},_o=(e,t)=>{if(!t)return"";const r=Bs(t);return`${r==null?void 0:r.explorer}/tx/${e}`};function p(e){const t={formatters:void 0,fees:void 0,serializers:void 0,...e};function r(n){return s=>{const a=typeof s=="function"?s(n):s,o={...n,...a};return Object.assign(o,{extend:r(o)})}}return Object.assign(t,{extend:r(t)})}function L3(){return{}}const z3=p({id:16600,name:"0G Newton Testnet",nativeCurrency:{name:"A0GI",symbol:"A0GI",decimals:18},rpcUrls:{default:{http:["https://evmrpc-testnet.0g.ai"]}},blockExplorers:{default:{name:"0G BlockChain Explorer",url:"https://chainscan-newton.0g.ai"}},testnet:!0}),R3=p({id:16601,name:"0G Galileo Testnet",nativeCurrency:{name:"A0GI",symbol:"A0GI",decimals:18},rpcUrls:{default:{http:["https://evmrpc-testnet.0g.ai"]}},blockExplorers:{default:{name:"0G BlockChain Explorer",url:"https://chainscan-galileo.0g.ai"}},testnet:!0}),H3=p({id:16661,name:"0G Mainnet",nativeCurrency:{name:"0G",symbol:"0G",decimals:18},rpcUrls:{default:{http:["https://evmrpc.0g.ai"]}},blockExplorers:{default:{name:"0G BlockChain Explorer",url:"https://chainscan.0g.ai"}},testnet:!1}),$3=p({id:16602,name:"0G Galileo Testnet",nativeCurrency:{name:"A0GI",symbol:"A0GI",decimals:18},rpcUrls:{default:{http:["https://evmrpc-testnet.0g.ai"]}},blockExplorers:{default:{name:"0G BlockChain Explorer",url:"https://chainscan-galileo.0g.ai"}},testnet:!0}),G3=p({id:995,name:"5ireChain",nativeCurrency:{name:"5ire Token",symbol:"5IRE",decimals:18},rpcUrls:{default:{http:["https://rpc.5ire.network"]}},blockExplorers:{default:{name:"5ireChain Mainnet Explorer",url:"https://5irescan.io/"}},testnet:!1}),j3=p({id:179,name:"ABEY Mainnet",nativeCurrency:{name:"ABEY",symbol:"ABEY",decimals:18},rpcUrls:{default:{http:["https://rpc.abeychain.com"]}},blockExplorers:{default:{name:"Abey Scan",url:"https://abeyscan.com"}},testnet:!1}),d1="2.43.3";let Mo={getDocsUrl:({docsBaseUrl:e,docsPath:t="",docsSlug:r})=>t?`${e??"https://viem.sh"}${t}${r?`#${r}`:""}`:void 0,version:`viem@${d1}`},$=class Bm extends Error{constructor(t,r={}){var i;const n=(()=>{var c;return r.cause instanceof Bm?r.cause.details:(c=r.cause)!=null&&c.message?r.cause.message:r.details})(),s=r.cause instanceof Bm&&r.cause.docsPath||r.docsPath,a=(i=Mo.getDocsUrl)==null?void 0:i.call(Mo,{...r,docsPath:s}),o=[t||"An error occurred.","",...r.metaMessages?[...r.metaMessages,""]:[],...a?[`Docs: ${a}`]:[],...n?[`Details: ${n}`]:[],...Mo.version?[`Version: ${Mo.version}`]:[]].join(`
65
65
  `);super(o,r.cause?{cause:r.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=n,this.docsPath=s,this.metaMessages=r.metaMessages,this.name=r.name??this.name,this.shortMessage=t,this.version=d1}walk(t){return p1(this,t)}};function p1(e,t){return t!=null&&t(e)?e:e&&typeof e=="object"&&"cause"in e&&e.cause!==void 0?p1(e.cause,t):t?null:e}let f1=class extends ${constructor({max:t,min:r,signed:n,size:s,value:a}){super(`Number "${a}" is not in safe ${s?`${s*8}-bit ${n?"signed":"unsigned"} `:""}integer range ${t?`(${r} to ${t})`:`(above ${r})`}`,{name:"IntegerOutOfRangeError"})}},V3=class extends ${constructor(t){super(`Bytes value "${t}" is not a valid boolean. The bytes array must contain a single byte of either a 0 or 1 value.`,{name:"InvalidBytesBooleanError"})}};class W3 extends ${constructor(t){super(`Hex value "${t}" is not a valid boolean. The hex value must be "0x0" (false) or "0x1" (true).`,{name:"InvalidHexBooleanError"})}}let q3=class extends ${constructor({givenSize:t,maxSize:r}){super(`Size cannot exceed ${r} bytes. Given size: ${t} bytes.`,{name:"SizeOverflowError"})}};function Or(e,{strict:t=!0}={}){return!e||typeof e!="string"?!1:t?/^0x[0-9a-fA-F]*$/.test(e):e.startsWith("0x")}function ct(e){return Or(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}function Zt(e,{dir:t="left"}={}){let r=typeof e=="string"?e.replace("0x",""):e,n=0;for(let s=0;s<r.length-1&&r[t==="left"?s:r.length-s-1].toString()==="0";s++)n++;return r=t==="left"?r.slice(n):r.slice(0,r.length-n),typeof e=="string"?(r.length===1&&t==="right"&&(r=`${r}0`),`0x${r.length%2===1?`0${r}`:r}`):r}let m1=class extends ${constructor({offset:t,position:r,size:n}){super(`Slice ${r==="start"?"starting":"ending"} at offset "${t}" is out-of-bounds (size: ${n}).`,{name:"SliceOffsetOutOfBoundsError"})}},h1=class extends ${constructor({size:t,targetSize:r,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (${t}) exceeds padding size (${r}).`,{name:"SizeExceedsPaddingSizeError"})}};class b1 extends ${constructor({size:t,targetSize:r,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} is expected to be ${r} ${n} long, but is ${t} ${n} long.`,{name:"InvalidBytesLengthError"})}}function _s(e,{dir:t,size:r=32}={}){return typeof e=="string"?Jn(e,{dir:t,size:r}):Y3(e,{dir:t,size:r})}function Jn(e,{dir:t,size:r=32}={}){if(r===null)return e;const n=e.replace("0x","");if(n.length>r*2)throw new h1({size:Math.ceil(n.length/2),targetSize:r,type:"hex"});return`0x${n[t==="right"?"padEnd":"padStart"](r*2,"0")}`}function Y3(e,{dir:t,size:r=32}={}){if(r===null)return e;if(e.length>r)throw new h1({size:e.length,targetSize:r,type:"bytes"});const n=new Uint8Array(r);for(let s=0;s<r;s++){const a=t==="right";n[a?s:r-s-1]=e[a?s:e.length-s-1]}return n}const K3=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Fe(e,t={}){return typeof e=="number"||typeof e=="bigint"?q(e,t):typeof e=="string"?Sa(e,t):typeof e=="boolean"?y1(e,t):vt(e,t)}function y1(e,t={}){const r=`0x${Number(e)}`;return typeof t.size=="number"?(Dr(r,{size:t.size}),_s(r,{size:t.size})):r}function vt(e,t={}){let r="";for(let s=0;s<e.length;s++)r+=K3[e[s]];const n=`0x${r}`;return typeof t.size=="number"?(Dr(n,{size:t.size}),_s(n,{dir:"right",size:t.size})):n}function q(e,t={}){const{signed:r,size:n}=t,s=BigInt(e);let a;n?r?a=(1n<<BigInt(n)*8n-1n)-1n:a=2n**(BigInt(n)*8n)-1n:typeof e=="number"&&(a=BigInt(Number.MAX_SAFE_INTEGER));const o=typeof a=="bigint"&&r?-a-1n:0;if(a&&s>a||s<o){const c=typeof e=="bigint"?"n":"";throw new f1({max:a?`${a}${c}`:void 0,min:`${o}${c}`,signed:r,size:n,value:`${e}${c}`})}const i=`0x${(r&&s<0?(1n<<BigInt(n*8))+BigInt(s):s).toString(16)}`;return n?_s(i,{size:n}):i}const Z3=new TextEncoder;function Sa(e,t={}){const r=Z3.encode(e);return vt(r,t)}const X3=new TextEncoder;function xn(e,t={}){return typeof e=="number"||typeof e=="bigint"?J3(e,t):typeof e=="boolean"?Q3(e,t):Or(e)?or(e,t):Ms(e,t)}function Q3(e,t={}){const r=new Uint8Array(1);return r[0]=Number(e),typeof t.size=="number"?(Dr(r,{size:t.size}),_s(r,{size:t.size})):r}const wn={zero:48,nine:57,A:65,F:70,a:97,f:102};function g1(e){if(e>=wn.zero&&e<=wn.nine)return e-wn.zero;if(e>=wn.A&&e<=wn.F)return e-(wn.A-10);if(e>=wn.a&&e<=wn.f)return e-(wn.a-10)}function or(e,t={}){let r=e;t.size&&(Dr(r,{size:t.size}),r=_s(r,{dir:"right",size:t.size}));let n=r.slice(2);n.length%2&&(n=`0${n}`);const s=n.length/2,a=new Uint8Array(s);for(let o=0,i=0;o<s;o++){const c=g1(n.charCodeAt(i++)),l=g1(n.charCodeAt(i++));if(c===void 0||l===void 0)throw new $(`Invalid byte sequence ("${n[i-2]}${n[i-1]}" in "${n}").`);a[o]=c*16+l}return a}function J3(e,t){const r=q(e,t);return or(r)}function Ms(e,t={}){const r=X3.encode(e);return typeof t.size=="number"?(Dr(r,{size:t.size}),_s(r,{dir:"right",size:t.size})):r}function Dr(e,{size:t}){if(ct(e)>t)throw new q3({givenSize:ct(e),maxSize:t})}function Le(e,t={}){const{signed:r}=t;t.size&&Dr(e,{size:t.size});const n=BigInt(e);if(!r)return n;const s=(e.length-2)/2,a=(1n<<BigInt(s)*8n-1n)-1n;return n<=a?n:n-BigInt(`0x${"f".padStart(s*2,"f")}`)-1n}function e8(e,t={}){let r=e;if(t.size&&(Dr(r,{size:t.size}),r=Zt(r)),Zt(r)==="0x00")return!1;if(Zt(r)==="0x01")return!0;throw new W3(r)}function ir(e,t={}){return Number(Le(e,t))}function zc(e,t){return({exclude:r,format:n})=>({exclude:r,format:(s,a)=>{const o=t(s,a);if(r)for(const i of r)delete o[i];return{...o,...n(s,a)}},type:e})}const x1={"0x0":"legacy","0x1":"eip2930","0x2":"eip1559","0x3":"eip4844","0x4":"eip7702"};function Ns(e,t){const r={...e,blockHash:e.blockHash?e.blockHash:null,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,chainId:e.chainId?ir(e.chainId):void 0,gas:e.gas?BigInt(e.gas):void 0,gasPrice:e.gasPrice?BigInt(e.gasPrice):void 0,maxFeePerBlobGas:e.maxFeePerBlobGas?BigInt(e.maxFeePerBlobGas):void 0,maxFeePerGas:e.maxFeePerGas?BigInt(e.maxFeePerGas):void 0,maxPriorityFeePerGas:e.maxPriorityFeePerGas?BigInt(e.maxPriorityFeePerGas):void 0,nonce:e.nonce?ir(e.nonce):void 0,to:e.to?e.to:null,transactionIndex:e.transactionIndex?Number(e.transactionIndex):null,type:e.type?x1[e.type]:void 0,typeHex:e.type?e.type:void 0,value:e.value?BigInt(e.value):void 0,v:e.v?BigInt(e.v):void 0};return e.authorizationList&&(r.authorizationList=t8(e.authorizationList)),r.yParity=(()=>{if(e.yParity)return Number(e.yParity);if(typeof r.v=="bigint"){if(r.v===0n||r.v===27n)return 0;if(r.v===1n||r.v===28n)return 1;if(r.v>=35n)return r.v%2n===0n?1:0}})(),r.type==="legacy"&&(delete r.accessList,delete r.maxFeePerBlobGas,delete r.maxFeePerGas,delete r.maxPriorityFeePerGas,delete r.yParity),r.type==="eip2930"&&(delete r.maxFeePerBlobGas,delete r.maxFeePerGas,delete r.maxPriorityFeePerGas),r.type==="eip1559"&&delete r.maxFeePerBlobGas,r}const Rc=zc("transaction",Ns);function t8(e){return e.map(t=>({address:t.address,chainId:Number(t.chainId),nonce:Number(t.nonce),r:t.r,s:t.s,yParity:Number(t.yParity)}))}function Id(e,t){const r=(e.transactions??[]).map(n=>typeof n=="string"?n:Ns(n));return{...e,baseFeePerGas:e.baseFeePerGas?BigInt(e.baseFeePerGas):null,blobGasUsed:e.blobGasUsed?BigInt(e.blobGasUsed):void 0,difficulty:e.difficulty?BigInt(e.difficulty):void 0,excessBlobGas:e.excessBlobGas?BigInt(e.excessBlobGas):void 0,gasLimit:e.gasLimit?BigInt(e.gasLimit):void 0,gasUsed:e.gasUsed?BigInt(e.gasUsed):void 0,hash:e.hash?e.hash:null,logsBloom:e.logsBloom?e.logsBloom:null,nonce:e.nonce?e.nonce:null,number:e.number?BigInt(e.number):null,size:e.size?BigInt(e.size):void 0,timestamp:e.timestamp?BigInt(e.timestamp):void 0,transactions:r,totalDifficulty:e.totalDifficulty?BigInt(e.totalDifficulty):null}}const Bd=zc("block",Id);function Xr(e,{args:t,eventName:r}={}){return{...e,blockHash:e.blockHash?e.blockHash:null,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,blockTimestamp:e.blockTimestamp?BigInt(e.blockTimestamp):e.blockTimestamp===null?null:void 0,logIndex:e.logIndex?Number(e.logIndex):null,transactionHash:e.transactionHash?e.transactionHash:null,transactionIndex:e.transactionIndex?Number(e.transactionIndex):null,...r?{args:t,eventName:r}:{}}}const w1={"0x0":"reverted","0x1":"success"};function Hc(e,t){const r={...e,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,contractAddress:e.contractAddress?e.contractAddress:null,cumulativeGasUsed:e.cumulativeGasUsed?BigInt(e.cumulativeGasUsed):null,effectiveGasPrice:e.effectiveGasPrice?BigInt(e.effectiveGasPrice):null,gasUsed:e.gasUsed?BigInt(e.gasUsed):null,logs:e.logs?e.logs.map(n=>Xr(n)):null,to:e.to?e.to:null,transactionIndex:e.transactionIndex?ir(e.transactionIndex):null,status:e.status?w1[e.status]:null,type:e.type?x1[e.type]||e.type:null};return e.blobGasPrice&&(r.blobGasPrice=BigInt(e.blobGasPrice)),e.blobGasUsed&&(r.blobGasUsed=BigInt(e.blobGasUsed)),r}const Fd=zc("transactionReceipt",Hc),r8={legacy:"0x0",eip2930:"0x1",eip1559:"0x2",eip4844:"0x3",eip7702:"0x4"};function _r(e,t){const r={};return typeof e.authorizationList<"u"&&(r.authorizationList=n8(e.authorizationList)),typeof e.accessList<"u"&&(r.accessList=e.accessList),typeof e.blobVersionedHashes<"u"&&(r.blobVersionedHashes=e.blobVersionedHashes),typeof e.blobs<"u"&&(typeof e.blobs[0]!="string"?r.blobs=e.blobs.map(n=>vt(n)):r.blobs=e.blobs),typeof e.data<"u"&&(r.data=e.data),e.account&&(r.from=e.account.address),typeof e.from<"u"&&(r.from=e.from),typeof e.gas<"u"&&(r.gas=q(e.gas)),typeof e.gasPrice<"u"&&(r.gasPrice=q(e.gasPrice)),typeof e.maxFeePerBlobGas<"u"&&(r.maxFeePerBlobGas=q(e.maxFeePerBlobGas)),typeof e.maxFeePerGas<"u"&&(r.maxFeePerGas=q(e.maxFeePerGas)),typeof e.maxPriorityFeePerGas<"u"&&(r.maxPriorityFeePerGas=q(e.maxPriorityFeePerGas)),typeof e.nonce<"u"&&(r.nonce=q(e.nonce)),typeof e.to<"u"&&(r.to=e.to),typeof e.type<"u"&&(r.type=r8[e.type]),typeof e.value<"u"&&(r.value=q(e.value)),r}const Ud=zc("transactionRequest",_r);function n8(e){return e.map(t=>({address:t.address,r:t.r?q(BigInt(t.r)):t.r,s:t.s?q(BigInt(t.s)):t.s,chainId:q(t.chainId),nonce:q(t.nonce),...typeof t.yParity<"u"?{yParity:q(t.yParity)}:{},...typeof t.v<"u"&&typeof t.yParity>"u"?{v:q(t.v)}:{}}))}const s8=2n**16n-1n,Ls=2n**256n-1n,Od=50000n,v1=s8*32n,E1={block:Bd({format(e){var r;const t=(r=e.transactions)==null?void 0:r.map(n=>{var a;if(typeof n=="string")return n;const s=(a=E1.transaction)==null?void 0:a.format(n);return s.typeHex==="0x71"?s.type="eip712":s.typeHex==="0xff"&&(s.type="priority"),s});return{l1BatchNumber:e.l1BatchNumber?Le(e.l1BatchNumber):null,l1BatchTimestamp:e.l1BatchTimestamp?Le(e.l1BatchTimestamp):null,transactions:t}}}),transaction:Rc({format(e){const t={};return e.type==="0x71"?t.type="eip712":e.type==="0xff"&&(t.type="priority"),{...t,l1BatchNumber:e.l1BatchNumber?Le(e.l1BatchNumber):null,l1BatchTxIndex:e.l1BatchTxIndex?Le(e.l1BatchTxIndex):null}}}),transactionReceipt:Fd({format(e){return{l1BatchNumber:e.l1BatchNumber?Le(e.l1BatchNumber):null,l1BatchTxIndex:e.l1BatchTxIndex?Le(e.l1BatchTxIndex):null,logs:e.logs.map(t=>({...Xr(t),l1BatchNumber:t.l1BatchNumber?Le(t.l1BatchNumber):null,transactionLogIndex:ir(t.transactionLogIndex),logType:t.logType})),l2ToL1Logs:e.l2ToL1Logs.map(t=>({blockNumber:Le(t.blockHash),blockHash:t.blockHash,l1BatchNumber:t.l1BatchNumber?Le(t.l1BatchNumber):null,transactionIndex:Le(t.transactionIndex),shardId:Le(t.shardId),isService:t.isService,sender:t.sender,key:t.key,value:t.value,transactionHash:t.transactionHash,logIndex:Le(t.logIndex)}))}}}),transactionRequest:Ud({exclude:["customSignature","factoryDeps","gasPerPubdata","paymaster","paymasterInput"],format(e){return e.gasPerPubdata||e.paymaster&&e.paymasterInput||e.factoryDeps||e.customSignature?{eip712Meta:{...e.gasPerPubdata?{gasPerPubdata:Fe(e.gasPerPubdata)}:{gasPerPubdata:Fe(Od)},...e.paymaster&&e.paymasterInput?{paymasterParams:{paymaster:e.paymaster,paymasterInput:Array.from(or(e.paymasterInput))}}:{},...e.factoryDeps?{factoryDeps:e.factoryDeps.map(t=>Array.from(or(t)))}:{},...e.customSignature?{customSignature:Array.from(or(e.customSignature))}:{}},type:"0x71"}:{}}})};function cr(e){return typeof e[0]=="string"?lr(e):a8(e)}function a8(e){let t=0;for(const s of e)t+=s.length;const r=new Uint8Array(t);let n=0;for(const s of e)r.set(s,n),n+=s.length;return r}function lr(e){return`0x${e.reduce((t,r)=>t+r.replace("0x",""),"")}`}let k1=class extends ${constructor({offset:t}){super(`Offset \`${t}\` cannot be negative.`,{name:"NegativeOffsetError"})}},C1=class extends ${constructor({length:t,position:r}){super(`Position \`${r}\` is out of bounds (\`0 < position < ${t}\`).`,{name:"PositionOutOfBoundsError"})}},o8=class extends ${constructor({count:t,limit:r}){super(`Recursive read limit of \`${r}\` exceeded (recursive read count: \`${t}\`).`,{name:"RecursiveReadLimitExceededError"})}};const i8={bytes:new Uint8Array,dataView:new DataView(new ArrayBuffer(0)),position:0,positionReadCount:new Map,recursiveReadCount:0,recursiveReadLimit:Number.POSITIVE_INFINITY,assertReadLimit(){if(this.recursiveReadCount>=this.recursiveReadLimit)throw new o8({count:this.recursiveReadCount+1,limit:this.recursiveReadLimit})},assertPosition(e){if(e<0||e>this.bytes.length-1)throw new C1({length:this.bytes.length,position:e})},decrementPosition(e){if(e<0)throw new k1({offset:e});const t=this.position-e;this.assertPosition(t),this.position=t},getReadCount(e){return this.positionReadCount.get(e||this.position)||0},incrementPosition(e){if(e<0)throw new k1({offset:e});const t=this.position+e;this.assertPosition(t),this.position=t},inspectByte(e){const t=e??this.position;return this.assertPosition(t),this.bytes[t]},inspectBytes(e,t){const r=t??this.position;return this.assertPosition(r+e-1),this.bytes.subarray(r,r+e)},inspectUint8(e){const t=e??this.position;return this.assertPosition(t),this.bytes[t]},inspectUint16(e){const t=e??this.position;return this.assertPosition(t+1),this.dataView.getUint16(t)},inspectUint24(e){const t=e??this.position;return this.assertPosition(t+2),(this.dataView.getUint16(t)<<8)+this.dataView.getUint8(t+2)},inspectUint32(e){const t=e??this.position;return this.assertPosition(t+3),this.dataView.getUint32(t)},pushByte(e){this.assertPosition(this.position),this.bytes[this.position]=e,this.position++},pushBytes(e){this.assertPosition(this.position+e.length-1),this.bytes.set(e,this.position),this.position+=e.length},pushUint8(e){this.assertPosition(this.position),this.bytes[this.position]=e,this.position++},pushUint16(e){this.assertPosition(this.position+1),this.dataView.setUint16(this.position,e),this.position+=2},pushUint24(e){this.assertPosition(this.position+2),this.dataView.setUint16(this.position,e>>8),this.dataView.setUint8(this.position+2,e&255),this.position+=3},pushUint32(e){this.assertPosition(this.position+3),this.dataView.setUint32(this.position,e),this.position+=4},readByte(){this.assertReadLimit(),this._touch();const e=this.inspectByte();return this.position++,e},readBytes(e,t){this.assertReadLimit(),this._touch();const r=this.inspectBytes(e);return this.position+=t??e,r},readUint8(){this.assertReadLimit(),this._touch();const e=this.inspectUint8();return this.position+=1,e},readUint16(){this.assertReadLimit(),this._touch();const e=this.inspectUint16();return this.position+=2,e},readUint24(){this.assertReadLimit(),this._touch();const e=this.inspectUint24();return this.position+=3,e},readUint32(){this.assertReadLimit(),this._touch();const e=this.inspectUint32();return this.position+=4,e},get remaining(){return this.bytes.length-this.position},setPosition(e){const t=this.position;return this.assertPosition(e),this.position=e,()=>this.position=t},_touch(){if(this.recursiveReadLimit===Number.POSITIVE_INFINITY)return;const e=this.getReadCount();this.positionReadCount.set(this.position,e+1),e>0&&this.recursiveReadCount++}};function Dd(e,{recursiveReadLimit:t=8192}={}){const r=Object.create(i8);return r.bytes=e,r.dataView=new DataView(e.buffer??e,e.byteOffset,e.byteLength),r.positionReadCount=new Map,r.recursiveReadLimit=t,r}function Qr(e,t="hex"){const r=T1(e),n=Dd(new Uint8Array(r.length));return r.encode(n),t==="hex"?vt(n.bytes):n.bytes}function T1(e){return Array.isArray(e)?c8(e.map(t=>T1(t))):l8(e)}function c8(e){const t=e.reduce((s,a)=>s+a.length,0),r=S1(t);return{length:t<=55?1+t:1+r+t,encode(s){t<=55?s.pushByte(192+t):(s.pushByte(247+r),r===1?s.pushUint8(t):r===2?s.pushUint16(t):r===3?s.pushUint24(t):s.pushUint32(t));for(const{encode:a}of e)a(s)}}}function l8(e){const t=typeof e=="string"?or(e):e,r=S1(t.length);return{length:t.length===1&&t[0]<128?1:t.length<=55?1+t.length:1+r+t.length,encode(s){t.length===1&&t[0]<128?s.pushBytes(t):t.length<=55?(s.pushByte(128+t.length),s.pushBytes(t)):(s.pushByte(183+r),r===1?s.pushUint8(t.length):r===2?s.pushUint16(t.length):r===3?s.pushUint24(t.length):s.pushUint32(t.length),s.pushBytes(t))}}}function S1(e){if(e<2**8)return 1;if(e<2**16)return 2;if(e<2**24)return 3;if(e<2**32)return 4;throw new $("Length is too large.")}const u8={gwei:9,wei:18},d8={ether:-9,wei:9};function A1(e,t){let r=e.toString();const n=r.startsWith("-");n&&(r=r.slice(1)),r=r.padStart(t,"0");let[s,a]=[r.slice(0,r.length-t),r.slice(r.length-t)];return a=a.replace(/(0+)$/,""),`${n?"-":""}${s||"0"}${a?`.${a}`:""}`}function _d(e,t="wei"){return A1(e,u8[t])}function Xt(e,t="wei"){return A1(e,d8[t])}function No(e){const t=Object.entries(e).map(([n,s])=>s===void 0||s===!1?null:[n,s]).filter(Boolean),r=t.reduce((n,[s])=>Math.max(n,s.length),0);return t.map(([n,s])=>` ${`${n}:`.padEnd(r+1)} ${s}`).join(`
66
66
  `)}class p8 extends ${constructor({v:t}){super(`Invalid \`v\` value "${t}". Expected 27 or 28.`,{name:"InvalidLegacyVError"})}}class f8 extends ${constructor({transaction:t}){super("Cannot infer a transaction type from provided transaction.",{metaMessages:["Provided Transaction:","{",No(t),"}","","To infer the type, either provide:","- a `type` to the Transaction, or","- an EIP-1559 Transaction with `maxFeePerGas`, or","- an EIP-2930 Transaction with `gasPrice` & `accessList`, or","- an EIP-4844 Transaction with `blobs`, `blobVersionedHashes`, `sidecars`, or","- an EIP-7702 Transaction with `authorizationList`, or","- a Legacy Transaction with `gasPrice`"],name:"InvalidSerializableTransactionError"})}}let m8=class extends ${constructor({storageKey:t}){super(`Size for storage key "${t}" is invalid. Expected 32 bytes. Got ${Math.floor((t.length-2)/2)} bytes.`,{name:"InvalidStorageKeySizeError"})}};class h8 extends ${constructor(t,{account:r,docsPath:n,chain:s,data:a,gas:o,gasPrice:i,maxFeePerGas:c,maxPriorityFeePerGas:l,nonce:u,to:d,value:f}){var y;const m=No({chain:s&&`${s==null?void 0:s.name} (id: ${s==null?void 0:s.id})`,from:r==null?void 0:r.address,to:d,value:typeof f<"u"&&`${_d(f)} ${((y=s==null?void 0:s.nativeCurrency)==null?void 0:y.symbol)||"ETH"}`,data:a,gas:o,gasPrice:typeof i<"u"&&`${Xt(i)} gwei`,maxFeePerGas:typeof c<"u"&&`${Xt(c)} gwei`,maxPriorityFeePerGas:typeof l<"u"&&`${Xt(l)} gwei`,nonce:u});super(t.shortMessage,{cause:t,docsPath:n,metaMessages:[...t.metaMessages?[...t.metaMessages," "]:[],"Request Arguments:",m].filter(Boolean),name:"TransactionExecutionError"}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.cause=t}}class P1 extends ${constructor({blockHash:t,blockNumber:r,blockTag:n,hash:s,index:a}){let o="Transaction";n&&a!==void 0&&(o=`Transaction at block time "${n}" at index "${a}"`),t&&a!==void 0&&(o=`Transaction at block hash "${t}" at index "${a}"`),r&&a!==void 0&&(o=`Transaction at block number "${r}" at index "${a}"`),s&&(o=`Transaction with hash "${s}"`),super(`${o} could not be found.`,{name:"TransactionNotFoundError"})}}class I1 extends ${constructor({hash:t}){super(`Transaction receipt with hash "${t}" could not be found. The Transaction may not be processed on a block yet.`,{name:"TransactionReceiptNotFoundError"})}}class B1 extends ${constructor({receipt:t}){super(`Transaction with hash "${t.transactionHash}" reverted.`,{metaMessages:['The receipt marked the transaction as "reverted". This could mean that the function on the contract you are trying to call threw an error.'," ","You can attempt to extract the revert reason by:","- calling the `simulateContract` or `simulateCalls` Action with the `abi` and `functionName` of the contract","- using the `call` Action with raw `data`"],name:"TransactionReceiptRevertedError"}),Object.defineProperty(this,"receipt",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.receipt=t}}class b8 extends ${constructor({hash:t}){super(`Timed out while waiting for transaction with hash "${t}" to be confirmed.`,{name:"WaitForTransactionReceiptTimeoutError"})}}function y8(e){if(!e||e.length===0)return[];const t=[];for(const r of e){const{chainId:n,nonce:s,...a}=r,o=r.address;t.push([n?Fe(n):"0x",o,s?Fe(s):"0x",..._a({},a)])}return t}function Md(e){const{kzg:t}=e,r=e.to??(typeof e.blobs[0]=="string"?"hex":"bytes"),n=typeof e.blobs[0]=="string"?e.blobs.map(a=>or(a)):e.blobs,s=[];for(const a of n)s.push(Uint8Array.from(t.blobToKzgCommitment(a)));return r==="bytes"?s:s.map(a=>vt(a))}function Nd(e){const{kzg:t}=e,r=e.to??(typeof e.blobs[0]=="string"?"hex":"bytes"),n=typeof e.blobs[0]=="string"?e.blobs.map(o=>or(o)):e.blobs,s=typeof e.commitments[0]=="string"?e.commitments.map(o=>or(o)):e.commitments,a=[];for(let o=0;o<n.length;o++){const i=n[o],c=s[o];a.push(Uint8Array.from(t.computeBlobKzgProof(i,c)))}return r==="bytes"?a:a.map(o=>vt(o))}const Aa=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function g8(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Lo(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function zs(e,...t){if(!g8(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function x8(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");Lo(e.outputLen),Lo(e.blockLen)}function Pa(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function F1(e,t){zs(e);const r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function w8(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function es(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Ld(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Jr(e,t){return e<<32-t|e>>>t}const v8=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function E8(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function k8(e){for(let t=0;t<e.length;t++)e[t]=E8(e[t]);return e}const U1=v8?e=>e:k8;function C8(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function $c(e){return typeof e=="string"&&(e=C8(e)),zs(e),e}function T8(...e){let t=0;for(let n=0;n<e.length;n++){const s=e[n];zs(s),t+=s.length}const r=new Uint8Array(t);for(let n=0,s=0;n<e.length;n++){const a=e[n];r.set(a,s),s+=a.length}return r}class zd{}function Gc(e){const t=n=>e().update($c(n)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function S8(e=32){if(Aa&&typeof Aa.getRandomValues=="function")return Aa.getRandomValues(new Uint8Array(e));if(Aa&&typeof Aa.randomBytes=="function")return Uint8Array.from(Aa.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}function A8(e,t,r,n){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,r,n);const s=BigInt(32),a=BigInt(4294967295),o=Number(r>>s&a),i=Number(r&a),c=n?4:0,l=n?0:4;e.setUint32(t+c,o,n),e.setUint32(t+l,i,n)}function P8(e,t,r){return e&t^~e&r}function I8(e,t,r){return e&t^e&r^t&r}class O1 extends zd{constructor(t,r,n,s){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=s,this.buffer=new Uint8Array(t),this.view=Ld(this.buffer)}update(t){Pa(this),t=$c(t),zs(t);const{view:r,buffer:n,blockLen:s}=this,a=t.length;for(let o=0;o<a;){const i=Math.min(s-this.pos,a-o);if(i===s){const c=Ld(t);for(;s<=a-o;o+=s)this.process(c,o);continue}n.set(t.subarray(o,o+i),this.pos),this.pos+=i,o+=i,this.pos===s&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){Pa(this),F1(t,this),this.finished=!0;const{buffer:r,view:n,blockLen:s,isLE:a}=this;let{pos:o}=this;r[o++]=128,es(this.buffer.subarray(o)),this.padOffset>s-o&&(this.process(n,0),o=0);for(let d=o;d<s;d++)r[d]=0;A8(n,s-8,BigInt(this.length*8),a),this.process(n,0);const i=Ld(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=c/4,u=this.get();if(l>u.length)throw new Error("_sha2: outputLen bigger than state");for(let d=0;d<l;d++)i.setUint32(4*d,u[d],a)}digest(){const{buffer:t,outputLen:r}=this;this.digestInto(t);const n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:r,buffer:n,length:s,finished:a,destroyed:o,pos:i}=this;return t.destroyed=o,t.finished=a,t.length=s,t.pos=i,s%r&&t.buffer.set(n),t}clone(){return this._cloneInto()}}const ts=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Nt=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]),Lt=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),jc=BigInt(2**32-1),D1=BigInt(32);function B8(e,t=!1){return t?{h:Number(e&jc),l:Number(e>>D1&jc)}:{h:Number(e>>D1&jc)|0,l:Number(e&jc)|0}}function _1(e,t=!1){const r=e.length;let n=new Uint32Array(r),s=new Uint32Array(r);for(let a=0;a<r;a++){const{h:o,l:i}=B8(e[a],t);[n[a],s[a]]=[o,i]}return[n,s]}const M1=(e,t,r)=>e>>>r,N1=(e,t,r)=>e<<32-r|t>>>r,Ia=(e,t,r)=>e>>>r|t<<32-r,Ba=(e,t,r)=>e<<32-r|t>>>r,Vc=(e,t,r)=>e<<64-r|t>>>r-32,Wc=(e,t,r)=>e>>>r-32|t<<64-r,F8=(e,t,r)=>e<<r|t>>>32-r,U8=(e,t,r)=>t<<r|e>>>32-r,O8=(e,t,r)=>t<<r-32|e>>>64-r,D8=(e,t,r)=>e<<r-32|t>>>64-r;function vn(e,t,r,n){const s=(t>>>0)+(n>>>0);return{h:e+r+(s/2**32|0)|0,l:s|0}}const _8=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),M8=(e,t,r,n)=>t+r+n+(e/2**32|0)|0,N8=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0),L8=(e,t,r,n,s)=>t+r+n+s+(e/2**32|0)|0,z8=(e,t,r,n,s)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(s>>>0),R8=(e,t,r,n,s,a)=>t+r+n+s+a+(e/2**32|0)|0,H8=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),rs=new Uint32Array(64);class $8 extends O1{constructor(t=32){super(64,t,8,!1),this.A=ts[0]|0,this.B=ts[1]|0,this.C=ts[2]|0,this.D=ts[3]|0,this.E=ts[4]|0,this.F=ts[5]|0,this.G=ts[6]|0,this.H=ts[7]|0}get(){const{A:t,B:r,C:n,D:s,E:a,F:o,G:i,H:c}=this;return[t,r,n,s,a,o,i,c]}set(t,r,n,s,a,o,i,c){this.A=t|0,this.B=r|0,this.C=n|0,this.D=s|0,this.E=a|0,this.F=o|0,this.G=i|0,this.H=c|0}process(t,r){for(let d=0;d<16;d++,r+=4)rs[d]=t.getUint32(r,!1);for(let d=16;d<64;d++){const f=rs[d-15],m=rs[d-2],y=Jr(f,7)^Jr(f,18)^f>>>3,g=Jr(m,17)^Jr(m,19)^m>>>10;rs[d]=g+rs[d-7]+y+rs[d-16]|0}let{A:n,B:s,C:a,D:o,E:i,F:c,G:l,H:u}=this;for(let d=0;d<64;d++){const f=Jr(i,6)^Jr(i,11)^Jr(i,25),m=u+f+P8(i,c,l)+H8[d]+rs[d]|0,g=(Jr(n,2)^Jr(n,13)^Jr(n,22))+I8(n,s,a)|0;u=l,l=c,c=i,i=o+m|0,o=a,a=s,s=n,n=m+g|0}n=n+this.A|0,s=s+this.B|0,a=a+this.C|0,o=o+this.D|0,i=i+this.E|0,c=c+this.F|0,l=l+this.G|0,u=u+this.H|0,this.set(n,s,a,o,i,c,l,u)}roundClean(){es(rs)}destroy(){this.set(0,0,0,0,0,0,0,0),es(this.buffer)}}const L1=_1(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))),G8=L1[0],j8=L1[1],ns=new Uint32Array(80),ss=new Uint32Array(80);class z1 extends O1{constructor(t=64){super(128,t,16,!1),this.Ah=Lt[0]|0,this.Al=Lt[1]|0,this.Bh=Lt[2]|0,this.Bl=Lt[3]|0,this.Ch=Lt[4]|0,this.Cl=Lt[5]|0,this.Dh=Lt[6]|0,this.Dl=Lt[7]|0,this.Eh=Lt[8]|0,this.El=Lt[9]|0,this.Fh=Lt[10]|0,this.Fl=Lt[11]|0,this.Gh=Lt[12]|0,this.Gl=Lt[13]|0,this.Hh=Lt[14]|0,this.Hl=Lt[15]|0}get(){const{Ah:t,Al:r,Bh:n,Bl:s,Ch:a,Cl:o,Dh:i,Dl:c,Eh:l,El:u,Fh:d,Fl:f,Gh:m,Gl:y,Hh:g,Hl:E}=this;return[t,r,n,s,a,o,i,c,l,u,d,f,m,y,g,E]}set(t,r,n,s,a,o,i,c,l,u,d,f,m,y,g,E){this.Ah=t|0,this.Al=r|0,this.Bh=n|0,this.Bl=s|0,this.Ch=a|0,this.Cl=o|0,this.Dh=i|0,this.Dl=c|0,this.Eh=l|0,this.El=u|0,this.Fh=d|0,this.Fl=f|0,this.Gh=m|0,this.Gl=y|0,this.Hh=g|0,this.Hl=E|0}process(t,r){for(let A=0;A<16;A++,r+=4)ns[A]=t.getUint32(r),ss[A]=t.getUint32(r+=4);for(let A=16;A<80;A++){const C=ns[A-15]|0,D=ss[A-15]|0,L=Ia(C,D,1)^Ia(C,D,8)^M1(C,D,7),T=Ba(C,D,1)^Ba(C,D,8)^N1(C,D,7),h=ns[A-2]|0,b=ss[A-2]|0,x=Ia(h,b,19)^Vc(h,b,61)^M1(h,b,6),S=Ba(h,b,19)^Wc(h,b,61)^N1(h,b,6),I=N8(T,S,ss[A-7],ss[A-16]),F=L8(I,L,x,ns[A-7],ns[A-16]);ns[A]=F|0,ss[A]=I|0}let{Ah:n,Al:s,Bh:a,Bl:o,Ch:i,Cl:c,Dh:l,Dl:u,Eh:d,El:f,Fh:m,Fl:y,Gh:g,Gl:E,Hh:v,Hl:w}=this;for(let A=0;A<80;A++){const C=Ia(d,f,14)^Ia(d,f,18)^Vc(d,f,41),D=Ba(d,f,14)^Ba(d,f,18)^Wc(d,f,41),L=d&m^~d&g,T=f&y^~f&E,h=z8(w,D,T,j8[A],ss[A]),b=R8(h,v,C,L,G8[A],ns[A]),x=h|0,S=Ia(n,s,28)^Vc(n,s,34)^Vc(n,s,39),I=Ba(n,s,28)^Wc(n,s,34)^Wc(n,s,39),F=n&a^n&i^a&i,_=s&o^s&c^o&c;v=g|0,w=E|0,g=m|0,E=y|0,m=d|0,y=f|0,{h:d,l:f}=vn(l|0,u|0,b|0,x|0),l=i|0,u=c|0,i=a|0,c=o|0,a=n|0,o=s|0;const k=_8(x,I,_);n=M8(k,b,S,F),s=k|0}({h:n,l:s}=vn(this.Ah|0,this.Al|0,n|0,s|0)),{h:a,l:o}=vn(this.Bh|0,this.Bl|0,a|0,o|0),{h:i,l:c}=vn(this.Ch|0,this.Cl|0,i|0,c|0),{h:l,l:u}=vn(this.Dh|0,this.Dl|0,l|0,u|0),{h:d,l:f}=vn(this.Eh|0,this.El|0,d|0,f|0),{h:m,l:y}=vn(this.Fh|0,this.Fl|0,m|0,y|0),{h:g,l:E}=vn(this.Gh|0,this.Gl|0,g|0,E|0),{h:v,l:w}=vn(this.Hh|0,this.Hl|0,v|0,w|0),this.set(n,s,a,o,i,c,l,u,d,f,m,y,g,E,v,w)}roundClean(){es(ns,ss)}destroy(){es(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class V8 extends z1{constructor(){super(48),this.Ah=Nt[0]|0,this.Al=Nt[1]|0,this.Bh=Nt[2]|0,this.Bl=Nt[3]|0,this.Ch=Nt[4]|0,this.Cl=Nt[5]|0,this.Dh=Nt[6]|0,this.Dl=Nt[7]|0,this.Eh=Nt[8]|0,this.El=Nt[9]|0,this.Fh=Nt[10]|0,this.Fl=Nt[11]|0,this.Gh=Nt[12]|0,this.Gl=Nt[13]|0,this.Hh=Nt[14]|0,this.Hl=Nt[15]|0}}const Rd=Gc(()=>new $8),W8=Gc(()=>new z1),q8=Gc(()=>new V8),R1=Rd;function H1(e,t){const r=t||"hex",n=R1(Or(e,{strict:!1})?xn(e):e);return r==="bytes"?n:Fe(n)}function Y8(e){const{commitment:t,version:r=1}=e,n=e.to??(typeof t=="string"?"hex":"bytes"),s=H1(t,"bytes");return s.set([r],0),n==="bytes"?s:vt(s)}function $1(e){const{commitments:t,version:r}=e,n=e.to??(typeof t[0]=="string"?"hex":"bytes"),s=[];for(const a of t)s.push(Y8({commitment:a,to:n,version:r}));return s}const G1=6,j1=32,Hd=4096,V1=j1*Hd,W1=V1*G1-1-1*Hd*G1,q1=1;class K8 extends ${constructor({maxSize:t,size:r}){super("Blob size is too large.",{metaMessages:[`Max: ${t} bytes`,`Given: ${r} bytes`],name:"BlobSizeTooLargeError"})}}class Y1 extends ${constructor(){super("Blob data must not be empty.",{name:"EmptyBlobError"})}}class Z8 extends ${constructor({hash:t,size:r}){super(`Versioned hash "${t}" size is invalid.`,{metaMessages:["Expected: 32",`Received: ${r}`],name:"InvalidVersionedHashSizeError"})}}class X8 extends ${constructor({hash:t,version:r}){super(`Versioned hash "${t}" version is invalid.`,{metaMessages:[`Expected: ${q1}`,`Received: ${r}`],name:"InvalidVersionedHashVersionError"})}}function Q8(e){const t=e.to??(typeof e.data=="string"?"hex":"bytes"),r=typeof e.data=="string"?or(e.data):e.data,n=ct(r);if(!n)throw new Y1;if(n>W1)throw new K8({maxSize:W1,size:n});const s=[];let a=!0,o=0;for(;a;){const i=Dd(new Uint8Array(V1));let c=0;for(;c<Hd;){const l=r.slice(o,o+(j1-1));if(i.pushByte(0),i.pushBytes(l),l.length<31){i.pushByte(128),a=!1;break}c++,o+=31}s.push(i)}return t==="bytes"?s.map(i=>i.bytes):s.map(i=>vt(i.bytes))}function K1(e){const{data:t,kzg:r,to:n}=e,s=e.blobs??Q8({data:t,to:n}),a=e.commitments??Md({blobs:s,kzg:r,to:n}),o=e.proofs??Nd({blobs:s,commitments:a,kzg:r,to:n}),i=[];for(let c=0;c<s.length;c++)i.push({blob:s[c],commitment:a[c],proof:o[c]});return i}let Ct=class extends ${constructor({address:t}){super(`Address "${t}" is invalid.`,{metaMessages:["- Address must be a hex value of 20 bytes (40 hex characters).","- Address must match its checksum counterpart."],name:"InvalidAddressError"})}};class $d extends ${constructor({blockNumber:t,chain:r,contract:n}){super(`Chain "${r.name}" does not support contract "${n.name}".`,{metaMessages:["This could be due to any of the following:",...t&&n.blockCreated&&n.blockCreated>t?[`- The contract "${n.name}" was not deployed until block ${n.blockCreated} (current block ${t}).`]:[`- The chain does not have the contract "${n.name}" configured.`]],name:"ChainDoesNotSupportContract"})}}class J8 extends ${constructor({chain:t,currentChainId:r}){super(`The current chain of the wallet (id: ${r}) does not match the target chain for the transaction (id: ${t.id} – ${t.name}).`,{metaMessages:[`Current Chain ID: ${r}`,`Expected Chain ID: ${t.id} – ${t.name}`],name:"ChainMismatchError"})}}class ev extends ${constructor(){super(["No chain was provided to the request.","Please provide a chain with the `chain` argument on the Action, or by supplying a `chain` to WalletClient."].join(`
67
67
  `),{name:"ChainNotFoundError"})}}class Z1 extends ${constructor(){super("No chain was provided to the Client.",{name:"ClientChainNotConfiguredError"})}}let Fa=class extends ${constructor({chainId:t}){super(typeof t=="number"?`Chain ID "${t}" is invalid.`:"Chain ID is invalid.",{name:"InvalidChainIdError"})}};class Ua extends ${constructor({cause:t,message:r}={}){var s;const n=(s=r==null?void 0:r.replace("execution reverted: ",""))==null?void 0:s.replace("execution reverted","");super(`Execution reverted ${n?`with reason: ${n}`:"for an unknown reason"}.`,{cause:t,name:"ExecutionRevertedError"})}}Object.defineProperty(Ua,"code",{enumerable:!0,configurable:!0,writable:!0,value:3}),Object.defineProperty(Ua,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/execution reverted|gas required exceeds allowance/});let as=class extends ${constructor({cause:t,maxFeePerGas:r}={}){super(`The fee cap (\`maxFeePerGas\`${r?` = ${Xt(r)} gwei`:""}) cannot be higher than the maximum allowed value (2^256-1).`,{cause:t,name:"FeeCapTooHighError"})}};Object.defineProperty(as,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max fee per gas higher than 2\^256-1|fee cap higher than 2\^256-1/});class Gd extends ${constructor({cause:t,maxFeePerGas:r}={}){super(`The fee cap (\`maxFeePerGas\`${r?` = ${Xt(r)}`:""} gwei) cannot be lower than the block base fee.`,{cause:t,name:"FeeCapTooLowError"})}}Object.defineProperty(Gd,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max fee per gas less than block base fee|fee cap less than block base fee|transaction is outdated/});class jd extends ${constructor({cause:t,nonce:r}={}){super(`Nonce provided for the transaction ${r?`(${r}) `:""}is higher than the next one expected.`,{cause:t,name:"NonceTooHighError"})}}Object.defineProperty(jd,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too high/});class Vd extends ${constructor({cause:t,nonce:r}={}){super([`Nonce provided for the transaction ${r?`(${r}) `:""}is lower than the current nonce of the account.`,"Try increasing the nonce or find the latest nonce with `getTransactionCount`."].join(`
@@ -123,4 +123,4 @@ te.version="2.30.1",az(Je),te.fn=Y,te.min=qR,te.max=YR,te.now=KR,te.utc=rn,te.un
123
123
  Prefix can't start with '-' when allowNegative is true.
124
124
  prefix: `+s+`
125
125
  allowNegative: `+a+`
126
- `),a=!1),Object.assign(Object.assign({},e),{allowNegative:a})}function vG(e){e=wG(e),e.decimalSeparator,e.allowedDecimalSeparators,e.thousandsGroupStyle;var t=e.suffix,r=e.allowNegative,n=e.allowLeadingZeros,s=e.onKeyDown;s===void 0&&(s=L0);var a=e.onBlur;a===void 0&&(a=L0);var o=e.thousandSeparator,i=e.decimalScale,c=e.fixedDecimalScale,l=e.prefix;l===void 0&&(l="");var u=e.defaultValue,d=e.value,f=e.valueIsNumericString,m=e.onValueChange,y=aG(e,["decimalSeparator","allowedDecimalSeparators","thousandsGroupStyle","suffix","allowNegative","allowLeadingZeros","onKeyDown","onBlur","thousandSeparator","decimalScale","fixedDecimalScale","prefix","defaultValue","value","valueIsNumericString","onValueChange"]),g=Uu(e),E=g.decimalSeparator,v=g.allowedDecimalSeparators,w=function(P){return j2(P,e)},A=function(P,O){return gG(P,O,e)},C=fo(d)?u:d,D=f??yG(C,l,t);fo(d)?fo(u)||(D=D||typeof u=="number"):D=D||typeof d=="number";var L=function(P){return L2(P)?P:(typeof P=="number"&&(P=$2(P)),D&&typeof i=="number"?G2(P,i,!!c):P)},T=mG(L(d),L(u),!!D,w,A,m),h=T[0],b=h.numAsString,x=h.formattedValue,S=T[1],I=function(P){var O=P.target,U=P.key,z=O.selectionStart,H=O.selectionEnd,G=O.value;if(G===void 0&&(G=""),(U==="Backspace"||U==="Delete")&&H<l.length){P.preventDefault();return}if(z!==H){s(P);return}U==="Backspace"&&G[0]==="-"&&z===l.length+1&&r&&sc(O,1),i&&c&&(U==="Backspace"&&G[z-1]===E?(sc(O,z-1),P.preventDefault()):U==="Delete"&&G[z]===E&&P.preventDefault()),v!=null&&v.includes(U)&&G[z]===E&&sc(O,z+1);var J=o===!0?",":o;U==="Backspace"&&G[z-1]===J&&sc(O,z-1),U==="Delete"&&G[z]===J&&sc(O,z+1),s(P)},F=function(P){var O=b;if(O.match(/\d/g)||(O=""),n||(O=dG(O)),c&&i&&(O=G2(O,i,c)),O!==b){var U=j2(O,e);S({formattedValue:U,value:O,floatValue:parseFloat(O)},{event:P,source:N0.event})}a(P)},_=function(P){return P===E?!0:N2(P)},k=function(P){var O=P.currentValue,U=P.lastValue,z=P.formattedValue,H=P.currentValueIndex,G=P.formattedValueIndex,J=O[H],pe=z[G],he=pG(U,O),ie=he.to,de=function(Be){return A(Be).indexOf(".")+l.length};return d===0&&c&&i&&O[ie.start]===E&&de(O)<H&&de(z)>G?!1:H>=ie.start&&H<ie.end&&v&&v.includes(J)&&pe===E?!0:J===pe};return Object.assign(Object.assign({},y),{value:x,valueIsNumericString:!1,isValidInputCharacter:_,isCharacterSame:k,onValueChange:S,format:w,removeFormatting:A,getCaretBoundary:function(P){return xG(P,e)},onKeyDown:I,onBlur:F})}const V2=(e,t)=>M.useMemo(()=>Pc(e,t),[e,t]),Vr=(e,t)=>M.useMemo(()=>bn(e,t),[e,t]),ac=()=>{const{chainId:e}=ne();return M.useMemo(()=>Bs(e),[e])},R0=e=>{const t=ac();return M.useMemo(()=>{if(!(!e||!t))return _o(e,t.id)},[e,t])},aa=(e,t)=>M.useMemo(()=>!e||!t||j(e||"0").isZero()||j(t||"0").isZero()?"":j(e||"0").times(t).toFixed(),[e,t]),EG=()=>{const{srcToken:e,dstToken:t,chainId:r}=ne();return M.useMemo(()=>Ad(e,t,r),[e,t,r])},kG=()=>{const{srcToken:e,dstToken:t,chainId:r}=ne();return M.useMemo(()=>Pd(e,t,r),[e,t,r])},CG=()=>{const e=EG(),t=kG();return e||t},H0=e=>{const{overrides:t}=ne();return M.useMemo(()=>t!=null&&t.dateFormat?t.dateFormat(e||0):te(e).format("DD/MM/YYYY HH:mm"),[e,t==null?void 0:t.dateFormat])};function TG(){const{callbacks:e}=ne();return M.useCallback(async t=>{var r;try{await navigator.clipboard.writeText(t),(r=e==null?void 0:e.onCopy)==null||r.call(e)}catch(n){console.error("Copy failed:",n)}},[e==null?void 0:e.onCopy])}const SG=(e,t)=>M.useMemo(()=>Do(e==null?void 0:e.toString(),t),[e,t]),ze=({value:e,decimalScale:t=3,prefix:r,suffix:n})=>{var c;const s=SG(e,t),{overrides:a}=ne(),o=a==null?void 0:a.numberFormat,i=vG({allowLeadingZeros:!0,thousandSeparator:",",displayType:"text",value:s||"",decimalScale:18,prefix:r,suffix:n});return o?o(e||""):(c=i.value)==null?void 0:c.toString()},AG={expirationTooltip:"This is the date and time marking the end of the period which you have selected for your order to be executed.",tradeSizeTooltip:"The number of input tokens that will be removed from your balance and swapped for the output token in each individual trade.",totalTradesTooltip:"The total number of individual trades that will be scheduled as part of your order. Note that in limit orders, not all trades that are scheduled will be executed.",minDstAmountTooltip:" This is the minimum number of tokens that may be received. NOTE: This minimum only refers to executed trades. Some trades may not be executed if the limit price is higher than the available market prices and your order may only be partially filled.",limitPriceTooltip:"Trades will only execute if the available market price is better than the limit price, potentially resulting in partial fills or orders remaining unfilled upon expiration.",maxDurationTooltip:"This is the time period during which the order will be active. Please note that orders may be completed earlier than this time, partially filled, or remain unfilled based on the specified parameters.",tradeIntervalTootlip:"The estimated time that will elapse between each trade in your order. Note that as this time includes an allowance of two minutes for bidder auction and block settlement, which cannot be predicted exactly, actual time may vary.",triggerPriceTooltip:"The price at which the order will be executed. If the market price is higher than the trigger price, the order will be executed at the market price.",placeOrder:"Place order",enterAmount:"Enter an amount",emptyLimitPrice:"Limit price is required",insufficientFunds:"Insufficient Balance",tradeIntervalLabel:"Trade interval",expirationLabel:"Expiration",limitPrice:"Limit Price",finalExcecutionPrice:"Final execution price",marketPrice:"Market price",from:"From",to:"To (estimated)",Open:"Open",Completed:"Completed",Expired:"Expired",Canceled:"Canceled",minReceivedPerTrade:"Min. received per trade",triggerPricePerChunk:"Trigger Price per trade",maxChunksError:"Max. trades amount is {maxChunks}",minChunksError:"Min. trades amount is {minChunks}",minTradeSizeError:"Min. trade size is ${minTradeSize}",allOrders:"All",minFillDelayError:"Min. trade interval is {fillDelay}",maxFillDelayError:"Max. trade interval is {fillDelay}",recipient:"Recipient",marketOrderWarning:"Each individual trade in this order will be filled at the current market price at the time of execution.",limitPriceMessage:"Limit orders may not execute when the token's price is equal or close to the limit price, due to gas and standard swap fees.",limit:"Limit",maxDurationError:"Max. expiry is {duration}",minDurationError:"Min. expiry is {duration}",expiry:"Expiry",individualTradeSize:"Individual trade size",numberOfTrades:"No. of trades",averageExecutionPrice:"Avg. execution price",twapMarket:"TWAP-market",twapLimit:"TWAP-limit",stopLoss:"Stop-loss",triggerPriceMarket:"Trigger Market Price ",triggerPriceLimit:"Trigger Limit Price ",takeProfit:"Take-profit",minReceived:"Min. received",noOrders:"No {status} Orders",noLiquidity:"No liquidity for this pair",excecutionSummary:"Execution summary",orderInfo:"Order info",wrapAction:"Wrap {symbol}",approveAction:"Approve {symbol}",createOrderAction:"Create {name} order",amountReceived:"Amount received",createdAt:"Created at",amountOut:"Amount out",status:"Status",progress:"Progress",minutes:"minutes",days:"days",tradeIntervalTitle:"Every",tradesAmountTitle:"Over",stopLossTooltip:"The trigger price at which your stop-loss order will be activated.",takeProfitTooltip:"The trigger price at which your take-profit order will be activated.",stopLossLabel:"Trigger Price",StopLossTriggerPriceError:"Trigger price must be less than market price",TakeProfitTriggerPriceError:"Trigger price must be greater than market price",triggerLimitPriceError:"Limit price must be less than trigger price",triggerPrice:"Trigger Price",tradePrice:"Trade Price",triggerMarketPriceDisclaimer:" In extreme market movements, slippage may occur and the executed price of the market order may be worse than the specified trigger price.",stopLossLimitPriceTooltip:"The stop loss order will execute at the specified limit price or better, once the stop price is triggered.",stopLossDurationTooltip:"This is the time period during which the order will be active. Please note that orders may be completed earlier than this time, or remain unfilled based on the specified parameters.",emptyTriggerPrice:"Trigger price is required",id:"ID",fees:"Fees {value}",version:"Version",maxOrderSizeError:"Max. trade size is {maxOrderSize} USD",viewOnExplorer:"View on explorer",proceedInWallet:"Proceed in wallet",wrapMsg:"Note: {symbol} was wrapped to {wSymbol}",createOrderActionSuccess:"{name} order placed"};function PG(e){let t=e;const r=/\{[^{}]*\}/g;for(;r.test(t);)t=t.replace(r,"");return t}const Ue=()=>{const e=ne();return M.useCallback((r,n)=>{var o,i;const s=(o=e.getTranslation)==null?void 0:o.call(e,r,n);if(s&&s!==r)return s;const a=((i=e.translations)==null?void 0:i[r])||AG[r];return PG(a.replace(/{(\w+)}/g,(c,l)=>(n==null?void 0:n[l])||c))},[e.getTranslation,e.translations])},Ou=({value:e})=>{const t=ze({value:e,decimalScale:2});return t?B.jsx("small",{className:"twap-order-details__detail-row-value-usd",children:` ($${t})`}):null},IG=({deadline:e,label:t,tooltip:r})=>{const n=H0(e);return B.jsx(hr,{title:t,tooltip:r,children:n})},BG=({price:e,dstToken:t,label:r,tooltip:n,usd:s})=>{const a=ze({value:e});return j(e||0).isZero()?null:B.jsx(hr,{title:r,tooltip:n,children:B.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[`${a||"-"} ${t==null?void 0:t.symbol}`,B.jsx(Ou,{value:s})]})})},FG=({price:e,dstToken:t,percentage:r,isMarketOrder:n})=>{const s=ze({value:e}),a=Ue();return n?null:B.jsx(hr,{title:a("limitPrice")||"",tooltip:a("limitPriceTooltip")||"",children:B.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[`${s||"-"} ${t==null?void 0:t.symbol}`,r&&B.jsx("small",{children:`(${r}%)`})]})})},UG=({tradeSize:e,srcToken:t,trades:r,label:n,tooltip:s})=>r===1?null:B.jsx(hr,{title:n,tooltip:s,children:`${e||"-"} ${(t==null?void 0:t.symbol)||""}`}),OG=({dstToken:e,dstMinAmountOut:t,label:r,tooltip:n,usd:s})=>{const a=ze({value:t});return j(t||0).isZero()?null:B.jsxs(hr,{title:r,tooltip:n,children:[`${t?a:"-"} ${e==null?void 0:e.symbol}`,B.jsx(Ou,{value:s})]})},DG=({trades:e,label:t,tooltip:r})=>e===1?null:B.jsx(hr,{title:t,tooltip:r,children:e}),_G=()=>{var s;const e=Ue(),{account:t}=ne(),r=(s=ac())==null?void 0:s.explorer,n=Cd(t);return B.jsx(hr,{title:e("recipient")||"",children:r?B.jsx("a",{href:`${r}/address/${t}`,target:"_blank",children:n}):n})},MG=({fillDelayMillis:e,chunks:t=0,label:r,tooltip:n})=>{const s=M.useMemo(()=>o1(e),[e]);return t===1?null:B.jsx(hr,{title:r,tooltip:n,children:s})},hr=({title:e,tooltip:t,children:r,className:n="",onClick:s,style:a})=>{const{components:o}=ne(),i=o.Tooltip;return B.jsxs("div",{className:`${n} twap-order-details__detail-row`,onClick:s,style:a,children:[B.jsxs("div",{className:"twap-order-details__detail-row-label",children:[B.jsx("p",{className:"twap-order-details__detail-row-label-value",children:e}),t&&i&&B.jsx(i,{tooltipText:t})]}),B.jsx("div",{className:"twap-order-details__detail-row-value",children:r})]})},NG=({id:e})=>{const{components:t}=ne(),r=t==null?void 0:t.Tooltip,n=TG();return e.startsWith("0x")?B.jsx(hr,{title:"ID",onClick:()=>n(e),style:{cursor:"pointer"},children:r&&B.jsx(r,{tooltipText:e,children:B.jsxs("div",{className:"twap-order-details__detail-row-value-id",children:[B.jsx("p",{children:Cd(e)}),B.jsx(sz.AiOutlineCopy,{})]})})}):B.jsx(hr,{title:"ID",children:e})},LG=({version:e})=>B.jsx(hr,{title:"Version",children:e});function we({children:e,className:t=""}){return B.jsx("div",{className:`${t} twap-order-details`,children:e})}const zG=({children:e})=>e,RG=({fees:e,label:t,usd:r,dstTokenSymbol:n})=>{const s=ze({value:e});return B.jsxs(hr,{title:t,children:[`${e?s:"-"} ${n}`,B.jsx(Ou,{value:r})]})};we.Deadline=IG,we.Fees=RG,we.TradeSize=UG,we.MinDestAmount=OG,we.TradesAmount=DG,we.Recipient=_G,we.TradeInterval=MG,we.DetailRow=hr,we.TriggerPrice=BG,we.LimitPrice=FG,we.OrderID=NG,we.Container=zG,we.OrderVersion=LG,we.USD=Ou;const $0=()=>{const{publicClient:e}=ne();return gn({mutationFn:async t=>{if(!e)throw new Error("publicClient is not defined");const r=10;let n=0,s=1e3;for(;n<r;)try{return await e.waitForTransactionReceipt({hash:t,confirmations:2,retryDelay:s})}catch(a){if(n++,n>=r)throw new Error(`Failed after ${r} attempts: ${a}`);await new Promise(o=>setTimeout(o,s)),s*=2}}}).mutateAsync},G0=()=>{const{account:e,walletClient:t,publicClient:r,config:n,callbacks:s,chainId:a}=ne(),o=$0(),i=Z(u=>u.updateState),c=async u=>{dt.onCancelOrderRequest(u.map(d=>d.id.toString()),1);try{return(await Promise.all(u.map(f=>t.writeContract({account:e,address:f.twapAddress,abi:Dm,functionName:"cancel",args:[f.id],chain:t.chain}))))[0]}catch(d){throw dt.onCancelOrderError(d),d}},l=async u=>{var d;try{dt.onCancelOrderRequest(u.map(y=>y.hash),2);const f=await t.writeContract({account:e,address:n.repermit,abi:Om,functionName:"cancel",args:[u.map(y=>y.hash)],chain:t.chain}),m=await o(f);if(!m)throw new Error("failed to get transaction receipt");if(m.status==="reverted")throw new Error("failed to cancel order");return dt.onCancelOrderSuccess(f),(d=s==null?void 0:s.onCancelOrderSuccess)==null||d.call(s,{orders:u,txHash:f,explorerUrl:_o(f,a)}),m.transactionHash}catch(f){throw dt.onCancelOrderError(f),f}};return gn({mutationFn:async({orders:u})=>{var d,f;if(!e||!t||!r||!n)throw new Error("missing required parameters");try{(d=s==null?void 0:s.onCancelOrderRequest)==null||d.call(s,u),i({cancelOrderStatus:mt.LOADING,cancelOrderTxHash:void 0,cancelOrderError:void 0});const m=u.filter(v=>v.version===1),y=u.filter(v=>v.version===2),[g,E]=await Promise.all([m.length?c(m):Promise.resolve(""),y.length?l(y):Promise.resolve("")]);return i({cancelOrderStatus:mt.SUCCESS,orderIdsToCancel:[]}),[...g||[],E]}catch(m){console.error("cancel order error",m),(f=s==null?void 0:s.onCancelOrderFailed)==null||f.call(s,m),Td(m)?i({cancelOrderStatus:void 0}):(i({cancelOrderStatus:mt.FAILED}),dt.onCancelOrderError(m))}}})},W2=e=>{const t=Ue();return M.useMemo(()=>e?e.type===ut.TRIGGER_PRICE_MARKET?t("triggerPriceMarket"):e.type===ut.TRIGGER_PRICE_LIMIT?t("triggerPriceLimit"):e.type===ut.TWAP_MARKET?t("twapMarket"):e.type===ut.TWAP_LIMIT?t("twapLimit"):t("twapMarket"):t("twapMarket"),[t,e==null?void 0:e.type])},j0=()=>{const{account:e,config:t,chainId:r}=ne();return M.useMemo(()=>["useTwapOrderHistoryManager",e,t==null?void 0:t.partner,r],[e,t,r])},HG=()=>{const e=Nc(),{account:t}=ne(),r=j0();return M.useCallback(n=>{e.setQueryData(r,s=>s?s!=null&&s.some(a=>a.id===n.id)?s:[n,...s]:[n])},[e,r,t])},$G=()=>{const{callbacks:e,refetchBalances:t}=ne(),r=Nc(),n=j0();return M.useCallback(s=>{var c;const a=r.getQueryData(n);let o=!1;const i=[];a&&a.forEach(l=>{var d;const u=s.find(f=>f.id===l.id);u&&u.progress!==l.progress&&(o=!0,i.push(u),u.status===lt.Completed&&((d=e==null?void 0:e.onOrderFilled)==null||d.call(e,u)))}),o&&((c=e==null?void 0:e.onOrdersProgressUpdate)==null||c.call(e,i),t==null||t())},[r,n,e,t])},GG=()=>{const{account:e,config:t,chainId:r}=ne(),n=j0(),s=$G();return l3({refetchInterval:KL,refetchOnWindowFocus:!0,retry:!1,staleTime:1/0,queryKey:n,queryFn:async({signal:a})=>{if(!e||!r||!t)return[];const o=await Ph({signal:a,chainId:r,config:t.twapConfig,account:e});return s(o),o.map(i=>t!=null&&t.twapConfig?{...i,fillDelayMillis:td(i,t.twapConfig)}:i)}})},Du=()=>{const{data:e,isLoading:t,error:r,refetch:n,isRefetching:s}=GG(),{mutateAsync:a}=G0();return M.useMemo(()=>({orders:{all:e??[],open:_u(e??[],lt.Open),completed:_u(e??[],lt.Completed),expired:_u(e??[],lt.Expired),canceled:_u(e??[],lt.Canceled)},isLoading:t,error:r,refetch:()=>n().then(o=>o.data),cancelOrder:a,isRefetching:s}),[e,t,r,n,a,s])},q2=()=>{const e=Z(r=>r.state.orderHistoryStatusFilter),{orders:t}=Du();return M.useMemo(()=>e?t.all.filter(r=>r.status.toLowerCase()===e.toLowerCase())||[]:t.all,[e,t])},_u=(e,t)=>e.filter(r=>r.status===t).sort((r,n)=>n.createdAt-r.createdAt),jG=(e,t,r)=>M.useMemo(()=>{if(!(!e||!t||!r||r!=null&&r.isMarketPrice))return c1(r,e==null?void 0:e.decimals,t==null?void 0:t.decimals)},[r,e,t]),VG=(e,t,r)=>M.useMemo(()=>{if(!(!e||!t||!r))return i1(r,e.decimals,t.decimals)},[r,e,t]),Y2=()=>{const e=Z(r=>r.updateState),t=Z(r=>r.state.orderIdsToCancel);return M.useCallback(r=>{t!=null&&t.includes(r)?e({orderIdsToCancel:t==null?void 0:t.filter(n=>n!==r)}):e({orderIdsToCancel:[...t||[],r]})},[e,t])},WG=()=>{var T,h;const e=Ue(),{orders:t,isLoading:r,refetch:n,isRefetching:s}=Du(),{mutateAsync:a,isPending:o}=G0(),i=q2(),c=Z(b=>b.updateState),l=Z(b=>b.state.orderHistoryStatusFilter),u=Z(b=>b.state.cancelOrdersMode),d=Z(b=>b.state.orderIdsToCancel),f=M.useCallback(b=>c({cancelOrdersMode:b,orderIdsToCancel:[]}),[c]),m=M.useCallback(()=>c({selectedOrderID:void 0}),[c]),y=M.useCallback(b=>a({orders:b}),[a]),g=M.useCallback(b=>c({orderHistoryStatusFilter:b}),[]),E=M.useMemo(()=>{const b=Object.keys(lt).map(x=>({text:x,value:x}));return[{text:e("allOrders"),value:""},...b]},[e]),v=Y2(),w=Z(b=>b.state.selectedOrderID),A=Z2(w),C=M.useMemo(()=>t.all.filter(b=>d==null?void 0:d.includes(b.id)),[t,d]),D=M.useCallback(()=>c({orderIdsToCancel:t.open.map(b=>b.id)}),[c,t]),L=M.useCallback(b=>a({orders:[b]}).then(x=>(x==null?void 0:x[0])||""),[a]);return{refetch:n,onHideSelectedOrder:m,onCancelOrders:y,onCancelOrder:L,onSelectStatus:g,onToggleCancelOrdersMode:f,onSelectOrder:v,isRefetching:s,orders:t,ordersToDisplay:i,isLoading:r,selectedOrder:w?A:void 0,openOrdersCount:((T=t==null?void 0:t.open)==null?void 0:T.length)||0,isCancelOrdersLoading:o,selectedStatus:l||((h=E[0])==null?void 0:h.value)||"",statuses:E,cancelOrdersMode:u,ordersToCancel:C,onSelectAllOrdersToCancel:D}},K2=e=>{const t=Ue(),r=ze({value:e.srcAmount}),n=ze({value:e.limitPrice}),s=ze({value:e.limitPriceUsd}),a=ze({value:e.srcAmountPerTrade}),o=ze({value:e.srcAmountPerTradeUsd,decimalScale:2}),i=ze({value:e.minDestAmountPerTrade}),c=ze({value:e.minDestAmountPerTradeUsd,decimalScale:2}),l=ze({value:e.triggerPricePerTrade}),u=ze({value:e.triggerPricePerTradeUsd,decimalScale:2}),d=ze({value:e.srcUsd,decimalScale:2}),f=ze({value:e.dstUsd,decimalScale:2}),m=ze({value:e.dstAmount});return M.useMemo(()=>({srcToken:e.srcToken,dstToken:e.dstToken,srcUsd:d||"",dstUsd:f||"",limitPrice:{label:t("limitPrice"),value:n||"",usd:s||""},deadline:{tooltip:t("expirationTooltip"),label:t("expirationLabel"),value:e.deadline||0},srcAmount:{label:t("amountOut"),value:r||"",usd:d||""},dstAmount:{value:m||"",usd:f||""},sizePerTrade:{tooltip:t("tradeSizeTooltip"),label:t("individualTradeSize"),value:a||"",usd:o},totalTrades:{tooltip:t("totalTradesTooltip"),label:t("numberOfTrades"),value:e.totalTrades||0},minDestAmountPerTrade:{tooltip:t("minDstAmountTooltip"),label:t(e.totalTrades&&e.totalTrades>1?"minReceivedPerTrade":"minReceived"),value:i||"",usd:c},tradeInterval:{tooltip:t("tradeIntervalTootlip"),label:t("tradeIntervalLabel"),value:e.tradeInterval||0},triggerPricePerTrade:{tooltip:t("triggerPriceTooltip"),label:t(e.totalTrades&&e.totalTrades>1?"triggerPricePerChunk":"triggerPrice"),value:l||"",usd:u},recipient:{label:t("recipient"),value:e.account||""}}),[d,f,n,r,a,o,i,l,u,n,s,m,f,c])},Z2=e=>{const{orders:t}=Du(),{useToken:r,config:n}=ne(),s=Ue(),a=M.useMemo(()=>t==null?void 0:t.all.find(C=>C.id===e),[t,e])||{},o=W2(a),i=r==null?void 0:r(a==null?void 0:a.srcTokenAddress),c=r==null?void 0:r(a==null?void 0:a.dstTokenAddress),l=Vr(i==null?void 0:i.decimals,a==null?void 0:a.srcAmount),u=jG(i,c,a),d=ze({value:VG(i,c,a)}),f=ze({value:Vr(i==null?void 0:i.decimals,a==null?void 0:a.srcAmountFilled)}),m=ze({value:Vr(c==null?void 0:c.decimals,a==null?void 0:a.dstAmountFilled)}),y=ze({value:a==null?void 0:a.progress,decimalScale:2}),g=Vr(i==null?void 0:i.decimals,a==null?void 0:a.srcAmountPerTrade),E=Vr(c==null?void 0:c.decimals,a==null?void 0:a.dstMinAmountPerTrade),v=Vr(c==null?void 0:c.decimals,a==null?void 0:a.triggerPricePerTrade),w=M.useMemo(()=>a?a.version===2?a.fillDelay:n.twapConfig?td(a,n.twapConfig):0:0,[a,n]),A=K2({srcToken:i,dstToken:c,account:a==null?void 0:a.maker,limitPrice:u,deadline:a==null?void 0:a.deadline,tradeInterval:w,srcAmount:l,totalTrades:a==null?void 0:a.totalTradesAmount,srcAmountPerTrade:g,minDestAmountPerTrade:E,triggerPricePerTrade:v});return M.useMemo(()=>({original:a,title:o,...A,createdAt:{label:s("createdAt"),value:a==null?void 0:a.createdAt},id:{label:s("id"),value:a==null?void 0:a.id},amountInFilled:{label:s("amountOut"),value:f},amountOutFilled:{label:s("amountReceived"),value:m,token:c},progress:{label:s("progress"),value:y},excecutionPrice:{label:s((a==null?void 0:a.totalTradesAmount)===1?"finalExcecutionPrice":"averageExecutionPrice"),value:d},version:{label:s("version"),value:a==null?void 0:a.version}}),[a,s,d,f,m,y,o,i,c,A])},X2=M.createContext({}),Rt=()=>M.useContext(X2),qG=()=>{const e=Z(c=>c.state.selectedOrderID),t=Z2(e),r=Ue(),[n,s]=M.useState("panel1"),{components:a}=ne(),o=a.TokenLogo;M.useEffect(()=>{s("panel1")},[t.id.value]);const i=c=>{s(n===c?!1:c)};return t?B.jsx(X2.Provider,{value:{order:t},children:B.jsxs("div",{className:"twap-orders__selected-order",children:[B.jsx(a1,{SrcTokenLogo:o&&B.jsx(o,{token:t.srcToken}),DstTokenLogo:o&&B.jsx(o,{token:t.dstToken}),fromTitle:r("from"),inToken:t.srcToken,toTitle:r("to"),outToken:t.dstToken}),B.jsx(we.Container,{children:B.jsxs("div",{className:"twap-orders__selected-order-bottom",children:[B.jsxs("div",{className:"twap-orders__selected-order-accordions",children:[B.jsx(Q2,{title:r("excecutionSummary"),onClick:()=>i("panel1"),expanded:n==="panel1",children:B.jsx(rj,{})}),B.jsx(Q2,{title:r("orderInfo"),expanded:n==="panel2",onClick:()=>i("panel2"),children:B.jsx(YG,{})})]}),B.jsx(sj,{})]})})]})}):null},Q2=({expanded:e,onClick:t,children:r,title:n})=>B.jsxs("div",{className:"twap-orders__selected-order-accordion",children:[B.jsxs("div",{onClick:t,className:"twap-orders__selected-order-accordion-trigger",children:[B.jsx("p",{children:n}),B.jsx(rz.IoIosArrowDown,{style:{transform:e?"rotate(180deg)":"rotate(0deg)"}})]}),e&&B.jsx("div",{className:"twap-orders__selected-order-accordion-details",children:r})]}),YG=()=>B.jsxs(we,{children:[B.jsx(tj,{}),B.jsx(aj,{}),B.jsx(QG,{}),B.jsx(oj,{}),B.jsx(KG,{}),B.jsx(ZG,{}),B.jsx(XG,{}),B.jsx(JG,{}),B.jsx(ej,{}),B.jsx(dj,{}),B.jsx(we.Recipient,{})]}),KG=()=>{const{order:e}=Rt();return B.jsx(we.TradeSize,{tradeSize:e.sizePerTrade.value,srcToken:e.srcToken,label:e.sizePerTrade.label,tooltip:e.sizePerTrade.tooltip,trades:e.totalTrades.value})},ZG=()=>{const{order:e}=Rt();return B.jsx(we.TradesAmount,{trades:e.totalTrades.value,label:e.totalTrades.label,tooltip:e.totalTrades.tooltip})},XG=()=>{const{order:e}=Rt();return B.jsx(we.MinDestAmount,{dstToken:e.dstToken,dstMinAmountOut:e.minDestAmountPerTrade.value,label:e.minDestAmountPerTrade.label,tooltip:e.minDestAmountPerTrade.tooltip})},QG=()=>{const{order:e}=Rt();return B.jsx(we.Deadline,{deadline:e.deadline.value,label:e.deadline.label,tooltip:e.deadline.tooltip})},JG=()=>{const{order:e}=Rt();return B.jsx(we.TradeInterval,{fillDelayMillis:e.tradeInterval.value,chunks:e.totalTrades.value,label:e.tradeInterval.label,tooltip:e.tradeInterval.tooltip})},ej=()=>{const{order:e}=Rt();return B.jsx(we.TriggerPrice,{dstToken:e.dstToken,price:e.triggerPricePerTrade.value,label:e.triggerPricePerTrade.label,tooltip:e.triggerPricePerTrade.tooltip})},tj=()=>{const{order:e}=Rt();return B.jsx(we.OrderID,{id:e.id.value||""})},rj=()=>B.jsxs(we,{children:[B.jsx(lj,{}),B.jsx(ij,{}),B.jsx(nj,{}),B.jsx(uj,{}),B.jsx(pj,{})]}),nj=()=>{var r;const{order:e}=Rt(),t=ze({value:e.amountOutFilled.value,decimalScale:3});return e.amountOutFilled.value?B.jsx(we.DetailRow,{title:e.amountOutFilled.label,children:B.jsxs("p",{children:[t||"-"," ",(r=e.dstToken)==null?void 0:r.symbol]})}):null},sj=()=>{const{order:e}=Rt(),{mutateAsync:t,isPending:r}=G0(),{components:n}=ne(),s=n.Button,a=M.useCallback(async()=>t({orders:[e.original]}),[t,e]);return!e||e.original.status!==lt.Open||!s?null:B.jsx(s,{loading:r,onClick:a,disabled:r,className:"twap-cancel-order",children:"Cancel"})},aj=()=>{const{order:e}=Rt(),t=Ue(),r=H0(e.createdAt.value);return B.jsx(we.DetailRow,{title:t("createdAt")||"",children:B.jsx("p",{children:r})})},oj=()=>{var n;const{order:e}=Rt(),t=Ue(),r=ze({value:e.srcAmount.value,decimalScale:3});return B.jsx(we.DetailRow,{title:t("amountOut")||"",children:B.jsxs("p",{children:[r||0," ",(n=e.srcToken)==null?void 0:n.symbol]})})},ij=()=>{var r;const{order:e}=Rt(),t=ze({value:e.amountInFilled.value,decimalScale:3});return B.jsx(we.DetailRow,{title:e.amountInFilled.label,children:B.jsxs("p",{children:[t||"-"," ",(r=e.srcToken)==null?void 0:r.symbol]})})},cj=()=>{const{order:e}=Rt(),t=Ue();return M.useMemo(()=>{switch(e.original.status){case lt.Open:return t("Open")||"";case lt.Completed:return t("Completed")||"";case lt.Expired:return t("Expired")||"";case lt.Canceled:return t("Canceled")||""}},[e.original.status,t])},lj=()=>{const e=Ue(),t=cj();return B.jsx(we.DetailRow,{title:e("status")||"",children:B.jsx("p",{children:t})})},uj=()=>{const{order:e}=Rt(),t=ze({value:e.progress.value,decimalScale:2});return B.jsx(we.DetailRow,{title:e.progress.label,children:B.jsxs("p",{children:[t||0,"%"]})})},dj=()=>{const{order:e}=Rt(),t=Ue();return e.limitPrice.value?B.jsx(J2,{title:t("limitPrice")||"",price:e.limitPrice.value,srcToken:e.srcToken,dstToken:e.dstToken}):null},pj=()=>{const{order:e}=Rt();return e.excecutionPrice.value?B.jsx(J2,{title:e.excecutionPrice.label,price:e.excecutionPrice.value,srcToken:e.srcToken,dstToken:e.dstToken}):null},J2=({price:e,srcToken:t,dstToken:r,title:n})=>{const s=ze({value:e,decimalScale:3});return B.jsx(we.DetailRow,{title:n,children:j(e||0).isZero()?B.jsx("p",{children:"-"}):B.jsxs("p",{children:["1 ",t==null?void 0:t.symbol," = ",s," ",r==null?void 0:r.symbol]})})};var V0={},ex;function fj(){if(ex)return V0;ex=1;var e=uu.GenIcon;return V0.HiArrowRight=function(r){return e({tag:"svg",attr:{viewBox:"0 0 20 20",fill:"currentColor"},child:[{tag:"path",attr:{fillRule:"evenodd",d:"M10.293 3.293a1 1 0 011.414 0l6 6a1 1 0 010 1.414l-6 6a1 1 0 01-1.414-1.414L14.586 11H3a1 1 0 110-2h11.586l-4.293-4.293a1 1 0 010-1.414z",clipRule:"evenodd"}}]})(r)},V0}var mj=fj();const Mu=0,ms=1,mo=2,tx=4;function rx(e){return()=>e}function hj(e){e()}function nx(e,t){return r=>e(t(r))}function sx(e,t){return()=>e(t)}function bj(e,t){return r=>e(t,r)}function W0(e){return e!==void 0}function yj(...e){return()=>{e.map(hj)}}function ho(){}function Nu(e,t){return t(e),e}function gj(e,t){return t(e)}function et(...e){return e}function je(e,t){return e(ms,t)}function Ce(e,t){e(Mu,t)}function q0(e){e(mo)}function st(e){return e(tx)}function ce(e,t){return je(e,bj(t,Mu))}function Wr(e,t){const r=e(ms,n=>{r(),t(n)});return r}function ax(e){let t,r;return n=>s=>{t=s,r&&clearTimeout(r),r=setTimeout(()=>{n(t)},e)}}function ox(e,t){return e===t}function tt(e=ox){let t;return r=>n=>{e(t,n)||(t=n,r(n))}}function fe(e){return t=>r=>{e(r)&&t(r)}}function re(e){return t=>nx(t,e)}function on(e){return t=>()=>{t(e)}}function W(e,...t){const r=xj(...t);return(n,s)=>{switch(n){case mo:q0(e);return;case ms:return je(e,r(s))}}}function cn(e,t){return r=>n=>{r(t=e(t,n))}}function oa(e){return t=>r=>{e>0?e--:t(r)}}function Hn(e){let t=null,r;return n=>s=>{t=s,!r&&(r=setTimeout(()=>{r=void 0,n(t)},e))}}function Te(...e){const t=new Array(e.length);let r=0,n=null;const s=Math.pow(2,e.length)-1;return e.forEach((a,o)=>{const i=Math.pow(2,o);je(a,c=>{const l=r;r=r|i,t[o]=c,l!==s&&r===s&&n&&(n(),n=null)})}),a=>o=>{const i=()=>{a([o].concat(t))};r===s?i():n=i}}function xj(...e){return t=>e.reduceRight(gj,t)}function wj(e){let t,r;const n=()=>t==null?void 0:t();return function(s,a){switch(s){case ms:return a?r===a?void 0:(n(),r=a,t=je(e,a),t):(n(),ho);case mo:n(),r=null;return}}}function K(e){let t=e;const r=Oe();return(n,s)=>{switch(n){case Mu:t=s;break;case ms:{s(t);break}case tx:return t}return r(n,s)}}function Ht(e,t){return Nu(K(t),r=>ce(e,r))}function Oe(){const e=[];return(t,r)=>{switch(t){case Mu:e.slice().forEach(n=>{n(r)});return;case mo:e.splice(0,e.length);return;case ms:return e.push(r),()=>{const n=e.indexOf(r);n>-1&&e.splice(n,1)}}}}function br(e){return Nu(Oe(),t=>ce(e,t))}function $e(e,t=[],{singleton:r}={singleton:!0}){return{constructor:e,dependencies:t,id:vj(),singleton:r}}const vj=()=>Symbol();function Ej(e){const t=new Map,r=({constructor:n,dependencies:s,id:a,singleton:o})=>{if(o&&t.has(a))return t.get(a);const i=n(s.map(c=>r(c)));return o&&t.set(a,i),i};return r(e)}function Et(...e){const t=Oe(),r=new Array(e.length);let n=0;const s=Math.pow(2,e.length)-1;return e.forEach((a,o)=>{const i=Math.pow(2,o);je(a,c=>{r[o]=c,n=n|i,n===s&&Ce(t,r)})}),function(a,o){switch(a){case mo:{q0(t);return}case ms:return n===s&&o(r),je(t,o)}}}function me(e,t=ox){return W(e,tt(t))}function Y0(...e){return function(t,r){switch(t){case mo:return;case ms:return yj(...e.map(n=>je(n,r)))}}}var nr=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(nr||{});const kj={0:"debug",3:"error",1:"log",2:"warn"},Cj=()=>typeof globalThis>"u"?window:globalThis,hs=$e(()=>{const e=K(3);return{log:K((t,r,n=1)=>{var s;const a=(s=Cj().VIRTUOSO_LOG_LEVEL)!=null?s:st(e);n>=a&&console[kj[n]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,r)}),logLevel:e}},[],{singleton:!0});function ia(e,t,r){return K0(e,t,r).callbackRef}function K0(e,t,r){const n=M.useRef(null);let s=o=>{};const a=M.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(o=>{const i=()=>{const c=o[0].target;c.offsetParent!==null&&e(c)};r?i():requestAnimationFrame(i)}):null,[e,r]);return s=o=>{o&&t?(a==null||a.observe(o),n.current=o):(n.current&&(a==null||a.unobserve(n.current)),n.current=null)},{callbackRef:s,ref:n}}function Tj(e,t,r,n,s,a,o,i,c){const l=M.useCallback(u=>{const d=Sj(u.children,t,i?"offsetWidth":"offsetHeight",s);let f=u.parentElement;for(;!f.dataset.virtuosoScroller;)f=f.parentElement;const m=f.lastElementChild.dataset.viewportType==="window";let y;m&&(y=f.ownerDocument.defaultView);const g=o?i?o.scrollLeft:o.scrollTop:m?i?y.scrollX||y.document.documentElement.scrollLeft:y.scrollY||y.document.documentElement.scrollTop:i?f.scrollLeft:f.scrollTop,E=o?i?o.scrollWidth:o.scrollHeight:m?i?y.document.documentElement.scrollWidth:y.document.documentElement.scrollHeight:i?f.scrollWidth:f.scrollHeight,v=o?i?o.offsetWidth:o.offsetHeight:m?i?y.innerWidth:y.innerHeight:i?f.offsetWidth:f.offsetHeight;n({scrollHeight:E,scrollTop:Math.max(g,0),viewportHeight:v}),a==null||a(i?ix("column-gap",getComputedStyle(u).columnGap,s):ix("row-gap",getComputedStyle(u).rowGap,s)),d!==null&&e(d)},[e,t,s,a,o,n,i]);return K0(l,r,c)}function Sj(e,t,r,n){const s=e.length;if(s===0)return null;const a=[];for(let o=0;o<s;o++){const i=e.item(o);if(i.dataset.index===void 0)continue;const c=parseInt(i.dataset.index),l=parseFloat(i.dataset.knownSize),u=t(i,r);if(u===0&&n("Zero-sized element, this should not happen",{child:i},nr.ERROR),u===l)continue;const d=a[a.length-1];a.length===0||d.size!==u||d.endIndex!==c-1?a.push({endIndex:c,size:u,startIndex:c}):a[a.length-1].endIndex++}return a}function ix(e,t,r){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&r(`${e} was not resolved to pixel value correctly`,t,nr.WARN),t==="normal"?0:parseInt(t??"0",10)}function cx(e,t,r){const n=M.useRef(null),s=M.useCallback(c=>{if(!(c!=null&&c.offsetParent))return;const l=c.getBoundingClientRect(),u=l.width;let d,f;if(t){const m=t.getBoundingClientRect(),y=l.top-m.top;f=m.height-Math.max(0,y),d=y+t.scrollTop}else{const m=o.current.ownerDocument.defaultView;f=m.innerHeight-Math.max(0,l.top),d=l.top+m.scrollY}n.current={offsetTop:d,visibleHeight:f,visibleWidth:u},e(n.current)},[e,t]),{callbackRef:a,ref:o}=K0(s,!0,r),i=M.useCallback(()=>{s(o.current)},[s,o]);return M.useEffect(()=>{var c;if(t){t.addEventListener("scroll",i);const l=new ResizeObserver(()=>{requestAnimationFrame(i)});return l.observe(t),()=>{t.removeEventListener("scroll",i),l.unobserve(t)}}else{const l=(c=o.current)==null?void 0:c.ownerDocument.defaultView;return l==null||l.addEventListener("scroll",i),l==null||l.addEventListener("resize",i),()=>{l==null||l.removeEventListener("scroll",i),l==null||l.removeEventListener("resize",i)}}},[i,t,o]),a}const Wt=$e(()=>{const e=Oe(),t=Oe(),r=K(0),n=Oe(),s=K(0),a=Oe(),o=Oe(),i=K(0),c=K(0),l=K(0),u=K(0),d=Oe(),f=Oe(),m=K(!1),y=K(!1),g=K(!1);return ce(W(e,re(({scrollTop:E})=>E)),t),ce(W(e,re(({scrollHeight:E})=>E)),o),ce(t,s),{deviation:r,fixedFooterHeight:l,fixedHeaderHeight:c,footerHeight:u,headerHeight:i,horizontalDirection:y,scrollBy:f,scrollContainerState:e,scrollHeight:o,scrollingInProgress:m,scrollTo:d,scrollTop:t,skipAnimationFrameInResizeObserver:g,smoothScrollTargetReached:n,statefulScrollTop:s,viewportHeight:a}},[],{singleton:!0}),oc={lvl:0};function lx(e,t){const r=e.length;if(r===0)return[];let{index:n,value:s}=t(e[0]);const a=[];for(let o=1;o<r;o++){const{index:i,value:c}=t(e[o]);a.push({end:i-1,start:n,value:s}),n=i,s=c}return a.push({end:1/0,start:n,value:s}),a}function qe(e){return e===oc}function ic(e,t){if(!qe(e))return t===e.k?e.v:t<e.k?ic(e.l,t):ic(e.r,t)}function qr(e,t,r="k"){if(qe(e))return[-1/0,void 0];if(Number(e[r])===t)return[e.k,e.v];if(Number(e[r])<t){const n=qr(e.r,t,r);return n[0]===-1/0?[e.k,e.v]:n}return qr(e.l,t,r)}function yr(e,t,r){return qe(e)?px(t,r,1):t===e.k?St(e,{k:t,v:r}):t<e.k?fx(St(e,{l:yr(e.l,t,r)})):fx(St(e,{r:yr(e.r,t,r)}))}function bo(){return oc}function yo(e,t,r){if(qe(e))return[];const n=qr(e,t)[0];return Aj(X0(e,n,r))}function Z0(e,t){if(qe(e))return oc;const{k:r,l:n,r:s}=e;if(t===r){if(qe(n))return s;if(qe(s))return n;{const[a,o]=dx(n);return Lu(St(e,{k:a,l:ux(n),v:o}))}}else return t<r?Lu(St(e,{l:Z0(n,t)})):Lu(St(e,{r:Z0(s,t)}))}function ca(e){return qe(e)?[]:[...ca(e.l),{k:e.k,v:e.v},...ca(e.r)]}function X0(e,t,r){if(qe(e))return[];const{k:n,l:s,r:a,v:o}=e;let i=[];return n>t&&(i=i.concat(X0(s,t,r))),n>=t&&n<=r&&i.push({k:n,v:o}),n<=r&&(i=i.concat(X0(a,t,r))),i}function Lu(e){const{l:t,lvl:r,r:n}=e;if(n.lvl>=r-1&&t.lvl>=r-1)return e;if(r>n.lvl+1){if(Q0(t))return mx(St(e,{lvl:r-1}));if(!qe(t)&&!qe(t.r))return St(t.r,{l:St(t,{r:t.r.l}),lvl:r,r:St(e,{l:t.r.r,lvl:r-1})});throw new Error("Unexpected empty nodes")}else{if(Q0(e))return J0(St(e,{lvl:r-1}));if(!qe(n)&&!qe(n.l)){const s=n.l,a=Q0(s)?n.lvl-1:n.lvl;return St(s,{l:St(e,{lvl:r-1,r:s.l}),lvl:s.lvl+1,r:J0(St(n,{l:s.r,lvl:a}))})}else throw new Error("Unexpected empty nodes")}}function St(e,t){return px(t.k!==void 0?t.k:e.k,t.v!==void 0?t.v:e.v,t.lvl!==void 0?t.lvl:e.lvl,t.l!==void 0?t.l:e.l,t.r!==void 0?t.r:e.r)}function ux(e){return qe(e.r)?e.l:Lu(St(e,{r:ux(e.r)}))}function Q0(e){return qe(e)||e.lvl>e.r.lvl}function dx(e){return qe(e.r)?[e.k,e.v]:dx(e.r)}function px(e,t,r,n=oc,s=oc){return{k:e,l:n,lvl:r,r:s,v:t}}function fx(e){return J0(mx(e))}function mx(e){const{l:t}=e;return!qe(t)&&t.lvl===e.lvl?St(t,{r:St(e,{l:t.r})}):e}function J0(e){const{lvl:t,r}=e;return!qe(r)&&!qe(r.r)&&r.lvl===t&&r.r.lvl===t?St(r,{l:St(e,{r:r.l}),lvl:t+1}):e}function Aj(e){return lx(e,({k:t,v:r})=>({index:t,value:r}))}function hx(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function cc(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const em=$e(()=>({recalcInProgress:K(!1)}),[],{singleton:!0});function bx(e,t,r){return e[zu(e,t,r)]}function zu(e,t,r,n=0){let s=e.length-1;for(;n<=s;){const a=Math.floor((n+s)/2),o=e[a],i=r(o,t);if(i===0)return a;if(i===-1){if(s-n<2)return a-1;s=a-1}else{if(s===n)return a;n=a+1}}throw new Error(`Failed binary finding record in array - ${e.join(",")}, searched for ${t}`)}function Pj(e,t,r,n){const s=zu(e,t,n),a=zu(e,r,n,s);return e.slice(s,a+1)}function bs(e,t){return Math.round(e.getBoundingClientRect()[t])}function Ru(e){return!qe(e.groupOffsetTree)}function tm({index:e},t){return t===e?0:t<e?-1:1}function Ij(){return{groupIndices:[],groupOffsetTree:bo(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:bo()}}function Bj(e,t){let r=qe(e)?0:1/0;for(const n of t){const{endIndex:s,size:a,startIndex:o}=n;if(r=Math.min(r,o),qe(e)){e=yr(e,0,a);continue}const i=yo(e,o-1,s+1);if(i.some(Nj(n)))continue;let c=!1,l=!1;for(const{end:u,start:d,value:f}of i)c?(s>=d||a===f)&&(e=Z0(e,d)):(l=f!==a,c=!0),u>s&&s>=d&&f!==a&&(e=yr(e,s+1,f));l&&(e=yr(e,o,a))}return[e,r]}function Fj(e){return typeof e.groupIndex<"u"}function Uj({offset:e},t){return t===e?0:t<e?-1:1}function lc(e,t,r){if(t.length===0)return 0;const{index:n,offset:s,size:a}=bx(t,e,tm),o=e-n,i=a*o+(o-1)*r+s;return i>0?i+r:i}function yx(e,t){if(!Ru(t))return e;let r=0;for(;t.groupIndices[r]<=e+r;)r++;return e+r}function gx(e,t,r){if(Fj(e))return t.groupIndices[e.groupIndex]+1;{const n=e.index==="LAST"?r:e.index;let s=yx(n,t);return s=Math.max(0,s,Math.min(r,s)),s}}function Oj(e,t,r,n=0){return n>0&&(t=Math.max(t,bx(e,n,tm).offset)),lx(Pj(e,t,r,Uj),Mj)}function Dj(e,[t,r,n,s]){t.length>0&&n("received item sizes",t,nr.DEBUG);const a=e.sizeTree;let o=a,i=0;if(r.length>0&&qe(a)&&t.length===2){const f=t[0].size,m=t[1].size;o=r.reduce((y,g)=>yr(yr(y,g,f),g+1,m),o)}else[o,i]=Bj(o,t);if(o===a)return e;const{lastIndex:c,lastOffset:l,lastSize:u,offsetTree:d}=rm(e.offsetTree,i,o,s);return{groupIndices:r,groupOffsetTree:r.reduce((f,m)=>yr(f,m,lc(m,d,s)),bo()),lastIndex:c,lastOffset:l,lastSize:u,offsetTree:d,sizeTree:o}}function _j(e){return ca(e).map(({k:t,v:r},n,s)=>{const a=s[n+1];return{endIndex:a?a.k-1:1/0,size:r,startIndex:t}})}function xx(e,t){let r=0,n=0;for(;r<e;)r+=t[n+1]-t[n]-1,n++;return n-(r===e?0:1)}function rm(e,t,r,n){let s=e,a=0,o=0,i=0,c=0;if(t!==0){c=zu(s,t-1,tm),i=s[c].offset;const l=qr(r,t-1);a=l[0],o=l[1],s.length&&s[c].size===qr(r,t)[1]&&(c-=1),s=s.slice(0,c+1)}else s=[];for(const{start:l,value:u}of yo(r,t,1/0)){const d=l-a,f=d*o+i+d*n;s.push({index:l,offset:f,size:u}),a=l,i=f,o=u}return{lastIndex:a,lastOffset:i,lastSize:o,offsetTree:s}}function Mj(e){return{index:e.index,value:e}}function Nj(e){const{endIndex:t,size:r,startIndex:n}=e;return s=>s.start===n&&(s.end===t||s.end===1/0)&&s.value===r}const Lj={offsetHeight:"height",offsetWidth:"width"},ln=$e(([{log:e},{recalcInProgress:t}])=>{const r=Oe(),n=Oe(),s=Ht(n,0),a=Oe(),o=Oe(),i=K(0),c=K([]),l=K(void 0),u=K(void 0),d=K(void 0),f=K(void 0),m=K((T,h)=>bs(T,Lj[h])),y=K(void 0),g=K(0),E=Ij(),v=Ht(W(r,Te(c,e,g),cn(Dj,E),tt()),E),w=Ht(W(c,tt(),cn((T,h)=>({current:h,prev:T.current}),{current:[],prev:[]}),re(({prev:T})=>T)),[]);ce(W(c,fe(T=>T.length>0),Te(v,g),re(([T,h,b])=>{const x=T.reduce((S,I,F)=>yr(S,I,lc(I,h.offsetTree,b)||F),bo());return{...h,groupIndices:T,groupOffsetTree:x}})),v),ce(W(n,Te(v),fe(([T,{lastIndex:h}])=>T<h),re(([T,{lastIndex:h,lastSize:b}])=>[{endIndex:h,size:b,startIndex:T}])),r),ce(l,u);const A=Ht(W(l,re(T=>T===void 0)),!0);ce(W(u,fe(T=>T!==void 0&&qe(st(v).sizeTree)),re(T=>{const h=st(d),b=st(c).length>0;return h?b?[{endIndex:0,size:h,startIndex:0},{endIndex:1,size:T,startIndex:1}]:[]:[{endIndex:0,size:T,startIndex:0}]})),r),ce(W(f,fe(T=>T!==void 0&&T.length>0&&qe(st(v).sizeTree)),re(T=>{const h=[];let b=T[0],x=0;for(let S=1;S<T.length;S++){const I=T[S];I!==b&&(h.push({endIndex:S-1,size:b,startIndex:x}),b=I,x=S)}return h.push({endIndex:T.length-1,size:b,startIndex:x}),h})),r),ce(W(c,Te(d,u),fe(([,T,h])=>T!==void 0&&h!==void 0),re(([T,h,b])=>{const x=[];for(let S=0;S<T.length;S++){const I=T[S],F=T[S+1];x.push({startIndex:I,endIndex:I,size:h}),F!==void 0&&x.push({startIndex:I+1,endIndex:F-1,size:b})}return x})),r);const C=br(W(r,Te(v),cn(({sizes:T},[h,b])=>({changed:b!==T,sizes:b}),{changed:!1,sizes:E}),re(T=>T.changed)));je(W(i,cn((T,h)=>({diff:T.prev-h,prev:h}),{diff:0,prev:0}),re(T=>T.diff)),T=>{const{groupIndices:h}=st(v);if(T>0)Ce(t,!0),Ce(a,T+xx(T,h));else if(T<0){const b=st(w);b.length>0&&(T-=xx(-T,b)),Ce(o,T)}}),je(W(i,Te(e)),([T,h])=>{T<0&&h("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:i},nr.ERROR)});const D=br(a);ce(W(a,Te(v),re(([T,h])=>{const b=h.groupIndices.length>0,x=[],S=h.lastSize;if(b){const I=ic(h.sizeTree,0);let F=0,_=0;for(;F<T;){const P=h.groupIndices[_],O=h.groupIndices.length===_+1?1/0:h.groupIndices[_+1]-P-1;x.push({endIndex:P,size:I,startIndex:P}),x.push({endIndex:P+1+O-1,size:S,startIndex:P+1}),_++,F+=O+1}const k=ca(h.sizeTree);return F!==T&&k.shift(),k.reduce((P,{k:O,v:U})=>{let z=P.ranges;return P.prevSize!==0&&(z=[...P.ranges,{endIndex:O+T-1,size:P.prevSize,startIndex:P.prevIndex}]),{prevIndex:O+T,prevSize:U,ranges:z}},{prevIndex:T,prevSize:0,ranges:x}).ranges}return ca(h.sizeTree).reduce((I,{k:F,v:_})=>({prevIndex:F+T,prevSize:_,ranges:[...I.ranges,{endIndex:F+T-1,size:I.prevSize,startIndex:I.prevIndex}]}),{prevIndex:0,prevSize:S,ranges:[]}).ranges})),r);const L=br(W(o,Te(v,g),re(([T,{offsetTree:h},b])=>{const x=-T;return lc(x,h,b)})));return ce(W(o,Te(v,g),re(([T,h,b])=>{if(h.groupIndices.length>0){if(qe(h.sizeTree))return h;let x=bo();const S=st(w);let I=0,F=0,_=0;for(;I<-T;){_=S[F];const k=S[F+1]-_-1;F++,I+=k+1}if(x=ca(h.sizeTree).reduce((k,{k:P,v:O})=>yr(k,Math.max(0,P+T),O),x),I!==-T){const k=ic(h.sizeTree,_);x=yr(x,0,k);const P=qr(h.sizeTree,-T+1)[1];x=yr(x,1,P)}return{...h,sizeTree:x,...rm(h.offsetTree,0,x,b)}}else{const x=ca(h.sizeTree).reduce((S,{k:I,v:F})=>yr(S,Math.max(0,I+T),F),bo());return{...h,sizeTree:x,...rm(h.offsetTree,0,x,b)}}})),v),{beforeUnshiftWith:D,data:y,defaultItemSize:u,firstItemIndex:i,fixedItemSize:l,fixedGroupSize:d,gap:g,groupIndices:c,heightEstimates:f,itemSize:m,listRefresh:C,shiftWith:o,shiftWithOffset:L,sizeRanges:r,sizes:v,statefulTotalCount:s,totalCount:n,trackItemSizes:A,unshiftWith:a}},et(hs,em),{singleton:!0});function zj(e){return e.reduce((t,r)=>(t.groupIndices.push(t.totalCount),t.totalCount+=r+1,t),{groupIndices:[],totalCount:0})}const wx=$e(([{groupIndices:e,sizes:t,totalCount:r},{headerHeight:n,scrollTop:s}])=>{const a=Oe(),o=Oe(),i=br(W(a,re(zj)));return ce(W(i,re(c=>c.totalCount)),r),ce(W(i,re(c=>c.groupIndices)),e),ce(W(Et(s,t,n),fe(([c,l])=>Ru(l)),re(([c,l,u])=>qr(l.groupOffsetTree,Math.max(c-u,0),"v")[0]),tt(),re(c=>[c])),o),{groupCounts:a,topItemsIndexes:o}},et(ln,Wt)),ys=$e(([{log:e}])=>{const t=K(!1),r=br(W(t,fe(n=>n),tt()));return je(t,n=>{n&&st(e)("props updated",{},nr.DEBUG)}),{didMount:r,propsReady:t}},et(hs),{singleton:!0}),Rj=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function vx(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!Rj)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const uc=$e(([{gap:e,listRefresh:t,sizes:r,totalCount:n},{fixedFooterHeight:s,fixedHeaderHeight:a,footerHeight:o,headerHeight:i,scrollingInProgress:c,scrollTo:l,smoothScrollTargetReached:u,viewportHeight:d},{log:f}])=>{const m=Oe(),y=Oe(),g=K(0);let E=null,v=null,w=null;function A(){E&&(E(),E=null),w&&(w(),w=null),v&&(clearTimeout(v),v=null),Ce(c,!1)}return ce(W(m,Te(r,d,n,g,i,o,f),Te(e,a,s),re(([[C,D,L,T,h,b,x,S],I,F,_])=>{const k=vx(C),{align:P,behavior:O,offset:U}=k,z=T-1,H=gx(k,D,z);let G=lc(H,D.offsetTree,I)+b;P==="end"?(G+=F+qr(D.sizeTree,H)[1]-L+_,H===z&&(G+=x)):P==="center"?G+=(F+qr(D.sizeTree,H)[1]-L+_)/2:G-=h,U&&(G+=U);const J=pe=>{A(),pe?(S("retrying to scroll to",{location:C},nr.DEBUG),Ce(m,C)):(Ce(y,!0),S("list did not change, scroll successful",{},nr.DEBUG))};if(A(),O==="smooth"){let pe=!1;w=je(t,he=>{pe=pe||he}),E=Wr(u,()=>{J(pe)})}else E=Wr(W(t,Hj(150)),J);return v=setTimeout(()=>{A()},1200),Ce(c,!0),S("scrolling from index to",{behavior:O,index:H,top:G},nr.DEBUG),{behavior:O,top:G}})),l),{scrollTargetReached:y,scrollToIndex:m,topListHeight:g}},et(ln,Wt,hs),{singleton:!0});function Hj(e){return t=>{const r=setTimeout(()=>{t(!1)},e);return n=>{n&&(t(!0),clearTimeout(r))}}}function nm(e,t){e==0?t():requestAnimationFrame(()=>{nm(e-1,t)})}function sm(e,t){const r=t-1;return typeof e=="number"?e:e.index==="LAST"?r:e.index}const dc=$e(([{defaultItemSize:e,listRefresh:t,sizes:r},{scrollTop:n},{scrollTargetReached:s,scrollToIndex:a},{didMount:o}])=>{const i=K(!0),c=K(0),l=K(!0);return ce(W(o,Te(c),fe(([u,d])=>!!d),on(!1)),i),ce(W(o,Te(c),fe(([u,d])=>!!d),on(!1)),l),je(W(Et(t,o),Te(i,r,e,l),fe(([[,u],d,{sizeTree:f},m,y])=>u&&(!qe(f)||W0(m))&&!d&&!y),Te(c)),([,u])=>{Wr(s,()=>{Ce(l,!0)}),nm(4,()=>{Wr(n,()=>{Ce(i,!0)}),Ce(a,u)})}),{initialItemFinalLocationReached:l,initialTopMostItemIndex:c,scrolledToInitialItem:i}},et(ln,Wt,uc,ys),{singleton:!0});function Ex(e,t){return Math.abs(e-t)<1.01}const pc="up",fc="down",$j="none",Gj={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},jj=0,mc=$e(([{footerHeight:e,headerHeight:t,scrollBy:r,scrollContainerState:n,scrollTop:s,viewportHeight:a}])=>{const o=K(!1),i=K(!0),c=Oe(),l=Oe(),u=K(4),d=K(jj),f=Ht(W(Y0(W(me(s),oa(1),on(!0)),W(me(s),oa(1),on(!1),ax(100))),tt()),!1),m=Ht(W(Y0(W(r,on(!0)),W(r,on(!1),ax(200))),tt()),!1);ce(W(Et(me(s),me(d)),re(([w,A])=>w<=A),tt()),i),ce(W(i,Hn(50)),l);const y=br(W(Et(n,me(a),me(t),me(e),me(u)),cn((w,[{scrollHeight:A,scrollTop:C},D,L,T,h])=>{const b=C+D-A>-h,x={scrollHeight:A,scrollTop:C,viewportHeight:D};if(b){let I,F;return C>w.state.scrollTop?(I="SCROLLED_DOWN",F=w.state.scrollTop-C):(I="SIZE_DECREASED",F=w.state.scrollTop-C||w.scrollTopDelta),{atBottom:!0,atBottomBecause:I,scrollTopDelta:F,state:x}}let S;return x.scrollHeight>w.state.scrollHeight?S="SIZE_INCREASED":D<w.state.viewportHeight?S="VIEWPORT_HEIGHT_DECREASING":C<w.state.scrollTop?S="SCROLLING_UPWARDS":S="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:S,state:x}},Gj),tt((w,A)=>w&&w.atBottom===A.atBottom))),g=Ht(W(n,cn((w,{scrollHeight:A,scrollTop:C,viewportHeight:D})=>{if(Ex(w.scrollHeight,A))return{changed:!1,jump:0,scrollHeight:A,scrollTop:C};{const L=A-(C+D)<1;return w.scrollTop!==C&&L?{changed:!0,jump:w.scrollTop-C,scrollHeight:A,scrollTop:C}:{changed:!0,jump:0,scrollHeight:A,scrollTop:C}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),fe(w=>w.changed),re(w=>w.jump)),0);ce(W(y,re(w=>w.atBottom)),o),ce(W(o,Hn(50)),c);const E=K(fc);ce(W(n,re(({scrollTop:w})=>w),tt(),cn((w,A)=>st(m)?{direction:w.direction,prevScrollTop:A}:{direction:A<w.prevScrollTop?pc:fc,prevScrollTop:A},{direction:fc,prevScrollTop:0}),re(w=>w.direction)),E),ce(W(n,Hn(50),on($j)),E);const v=K(0);return ce(W(f,fe(w=>!w),on(0)),v),ce(W(s,Hn(100),Te(f),fe(([w,A])=>!!A),cn(([w,A],[C])=>[A,C],[0,0]),re(([w,A])=>A-w)),v),{atBottomState:y,atBottomStateChange:c,atBottomThreshold:u,atTopStateChange:l,atTopThreshold:d,isAtBottom:o,isAtTop:i,isScrolling:f,lastJumpDueToItemResize:g,scrollDirection:E,scrollVelocity:v}},et(Wt)),hc="top",bc="bottom",kx="none";function Cx(e,t,r){return typeof e=="number"?r===pc&&t===hc||r===fc&&t===bc?e:0:r===pc?t===hc?e.main:e.reverse:t===bc?e.main:e.reverse}function Tx(e,t){var r;return typeof e=="number"?e:(r=e[t])!=null?r:0}const am=$e(([{deviation:e,fixedHeaderHeight:t,headerHeight:r,scrollTop:n,viewportHeight:s}])=>{const a=Oe(),o=K(0),i=K(0),c=K(0),l=Ht(W(Et(me(n),me(s),me(r),me(a,cc),me(c),me(o),me(t),me(e),me(i)),re(([u,d,f,[m,y],g,E,v,w,A])=>{const C=u-w,D=E+v,L=Math.max(f-C,0);let T=kx;const h=Tx(A,hc),b=Tx(A,bc);return m-=w,m+=f+v,y+=f+v,y-=w,m>u+D-h&&(T=pc),y<u-L+d+b&&(T=fc),T!==kx?[Math.max(C-f-Cx(g,hc,T)-h,0),C-L-v+d+Cx(g,bc,T)+b]:null}),fe(u=>u!=null),tt(cc)),[0,0]);return{increaseViewportBy:i,listBoundary:a,overscan:c,topListHeight:o,visibleRange:l}},et(Wt),{singleton:!0});function Vj(e,t,r){if(Ru(t)){const n=yx(e,t);return[{index:qr(t.groupOffsetTree,n)[0],offset:0,size:0},{data:r==null?void 0:r[0],index:n,offset:0,size:0}]}return[{data:r==null?void 0:r[0],index:e,offset:0,size:0}]}const om={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Hu(e,t,r,n,s,a){const{lastIndex:o,lastOffset:i,lastSize:c}=s;let l=0,u=0;if(e.length>0){l=e[0].offset;const g=e[e.length-1];u=g.offset+g.size}const d=r-o,f=i+d*c+(d-1)*n,m=l,y=f-u;return{bottom:u,firstItemIndex:a,items:Ax(e,s,a),offsetBottom:y,offsetTop:l,top:m,topItems:Ax(t,s,a),topListHeight:t.reduce((g,E)=>E.size+g,0),totalCount:r}}function Sx(e,t,r,n,s,a){let o=0;if(r.groupIndices.length>0)for(const u of r.groupIndices){if(u-o>=e)break;o++}const i=e+o,c=sm(t,i),l=Array.from({length:i}).map((u,d)=>({data:a[d+c],index:d+c,offset:0,size:0}));return Hu(l,[],i,s,r,n)}function Ax(e,t,r){if(e.length===0)return[];if(!Ru(t))return e.map(l=>({...l,index:l.index+r,originalIndex:l.index}));const n=e[0].index,s=e[e.length-1].index,a=[],o=yo(t.groupOffsetTree,n,s);let i,c=0;for(const l of e){(!i||i.end<l.index)&&(i=o.shift(),c=t.groupIndices.indexOf(i.start));let u;l.index===i.start?u={index:c,type:"group"}:u={groupIndex:c,index:l.index-(c+1)+r},a.push({...u,data:l.data,offset:l.offset,originalIndex:l.index,size:l.size})}return a}function Px(e,t){var r;return e===void 0?0:typeof e=="number"?e:(r=e[t])!=null?r:0}const la=$e(([{data:e,firstItemIndex:t,gap:r,sizes:n,totalCount:s},a,{listBoundary:o,topListHeight:i,visibleRange:c},{initialTopMostItemIndex:l,scrolledToInitialItem:u},{topListHeight:d},f,{didMount:m},{recalcInProgress:y}])=>{const g=K([]),E=K(0),v=Oe(),w=K(0);ce(a.topItemsIndexes,g);const A=Ht(W(Et(m,y,me(c,cc),me(s),me(n),me(l),u,me(g),me(t),me(r),me(w),e),fe(([T,h,,b,,,,,,,,x])=>{const S=x&&x.length!==b;return T&&!h&&!S}),re(([,,[T,h],b,x,S,I,F,_,k,P,O])=>{var U,z,H,G;const J=x,{offsetTree:pe,sizeTree:he}=J,ie=st(E);if(b===0)return{...om,totalCount:b};if(T===0&&h===0)return ie===0?{...om,totalCount:b}:Sx(ie,S,x,_,k,O||[]);if(qe(he))return ie>0?null:Hu(Vj(sm(S,b),J,O),[],b,k,J,_);const de=[];if(F.length>0){const Se=F[0],Ee=F[F.length-1];let be=0;for(const Ze of yo(he,Se,Ee)){const Ye=Ze.value,Xe=Math.max(Ze.start,Se),Fr=Math.min(Ze.end,Ee);for(let Ot=Xe;Ot<=Fr;Ot++)de.push({data:O==null?void 0:O[Ot],index:Ot,offset:be,size:Ye}),be+=Ye}}if(!I)return Hu([],de,b,k,J,_);const Be=F.length>0?F[F.length-1]+1:0,Q=Oj(pe,T,h,Be);if(Q.length===0)return null;const ve=b-1,_e=Nu([],Se=>{for(const Ee of Q){const be=Ee.value;let Ze=be.offset,Ye=Ee.start;const Xe=be.size;if(be.offset<T){Ye+=Math.floor((T-be.offset+k)/(Xe+k));const Ot=Ye-Ee.start;Ze+=Ot*Xe+Ot*k}Ye<Be&&(Ze+=(Be-Ye)*Xe,Ye=Be);const Fr=Math.min(Ee.end,ve);for(let Ot=Ye;Ot<=Fr&&!(Ze>=h);Ot++)Se.push({data:O==null?void 0:O[Ot],index:Ot,offset:Ze,size:Xe}),Ze+=Xe+k}}),Ge=Px(P,hc),ot=Px(P,bc);if(_e.length>0&&(Ge>0||ot>0)){const Se=_e[0],Ee=_e[_e.length-1];if(Ge>0&&Se.index>Be){const be=Math.min(Ge,Se.index-Be),Ze=[];let Ye=Se.offset;for(let Xe=Se.index-1;Xe>=Se.index-be;Xe--){const Fr=(z=(U=yo(he,Xe,Xe)[0])==null?void 0:U.value)!=null?z:Se.size;Ye-=Fr+k,Ze.unshift({data:O==null?void 0:O[Xe],index:Xe,offset:Ye,size:Fr})}_e.unshift(...Ze)}if(ot>0&&Ee.index<ve){const be=Math.min(ot,ve-Ee.index);let Ze=Ee.offset+Ee.size+k;for(let Ye=Ee.index+1;Ye<=Ee.index+be;Ye++){const Xe=(G=(H=yo(he,Ye,Ye)[0])==null?void 0:H.value)!=null?G:Ee.size;_e.push({data:O==null?void 0:O[Ye],index:Ye,offset:Ze,size:Xe}),Ze+=Xe+k}}}return Hu(_e,de,b,k,J,_)}),fe(T=>T!==null),tt()),om);ce(W(e,fe(W0),re(T=>T==null?void 0:T.length)),s),ce(W(A,re(T=>T.topListHeight)),d),ce(d,i),ce(W(A,re(T=>[T.top,T.bottom])),o),ce(W(A,re(T=>T.items)),v);const C=br(W(A,fe(({items:T})=>T.length>0),Te(s,e),fe(([{items:T},h])=>T[T.length-1].originalIndex===h-1),re(([,T,h])=>[T-1,h]),tt(cc),re(([T])=>T))),D=br(W(A,Hn(200),fe(({items:T,topItems:h})=>T.length>0&&T[0].originalIndex===h.length),re(({items:T})=>T[0].index),tt())),L=br(W(A,fe(({items:T})=>T.length>0),re(({items:T})=>{let h=0,b=T.length-1;for(;T[h].type==="group"&&h<b;)h++;for(;T[b].type==="group"&&b>h;)b--;return{endIndex:T[b].index,startIndex:T[h].index}}),tt(hx)));return{endReached:C,initialItemCount:E,itemsRendered:v,listState:A,minOverscanItemCount:w,rangeChanged:L,startReached:D,topItemsIndexes:g,...f}},et(ln,wx,am,dc,uc,mc,ys,em),{singleton:!0}),Ix=$e(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:r,headerHeight:n},{listState:s}])=>{const a=Oe(),o=Ht(W(Et(r,e,n,t,s),re(([i,c,l,u,d])=>i+c+l+u+d.offsetBottom+d.bottom)),0);return ce(me(o),a),{totalListHeight:o,totalListHeightChanged:a}},et(Wt,la),{singleton:!0}),Wj=$e(([{viewportHeight:e},{totalListHeight:t}])=>{const r=K(!1),n=Ht(W(Et(r,e,t),fe(([s])=>s),re(([,s,a])=>Math.max(0,s-a)),Hn(0),tt()),0);return{alignToBottom:r,paddingTopAddition:n}},et(Wt,Ix),{singleton:!0}),Bx=$e(()=>({context:K(null)})),qj=({itemBottom:e,itemTop:t,locationParams:{align:r,behavior:n,...s},viewportBottom:a,viewportTop:o})=>t<o?{...s,align:r??"start",behavior:n}:e>a?{...s,align:r??"end",behavior:n}:null,Fx=$e(([{gap:e,sizes:t,totalCount:r},{fixedFooterHeight:n,fixedHeaderHeight:s,headerHeight:a,scrollingInProgress:o,scrollTop:i,viewportHeight:c},{scrollToIndex:l}])=>{const u=Oe();return ce(W(u,Te(t,c,r,a,s,n,i),Te(e),re(([[d,f,m,y,g,E,v,w],A])=>{const{align:C,behavior:D,calculateViewLocation:L=qj,done:T,...h}=d,b=gx(d,f,y-1),x=lc(b,f.offsetTree,A)+g+E,S=x+qr(f.sizeTree,b)[1],I=w+E,F=w+m-v,_=L({itemBottom:S,itemTop:x,locationParams:{align:C,behavior:D,...h},viewportBottom:F,viewportTop:I});return _?T&&Wr(W(o,fe(k=>!k),oa(st(o)?1:2)),T):T&&T(),_}),fe(d=>d!==null)),l),{scrollIntoView:u}},et(ln,Wt,uc,la,hs),{singleton:!0});function Ux(e){return e?e==="smooth"?"smooth":"auto":!1}const Yj=(e,t)=>typeof e=="function"?Ux(e(t)):t&&Ux(e),Kj=$e(([{listRefresh:e,totalCount:t,fixedItemSize:r,data:n},{atBottomState:s,isAtBottom:a},{scrollToIndex:o},{scrolledToInitialItem:i},{didMount:c,propsReady:l},{log:u},{scrollingInProgress:d},{context:f},{scrollIntoView:m}])=>{const y=K(!1),g=Oe();let E=null;function v(D){Ce(o,{align:"end",behavior:D,index:"LAST"})}je(W(Et(W(me(t),oa(1)),c),Te(me(y),a,i,d),re(([[D,L],T,h,b,x])=>{let S=L&&b,I="auto";return S&&(I=Yj(T,h||x),S=S&&!!I),{followOutputBehavior:I,shouldFollow:S,totalCount:D}}),fe(({shouldFollow:D})=>D)),({followOutputBehavior:D,totalCount:L})=>{E&&(E(),E=null),st(r)?requestAnimationFrame(()=>{st(u)("following output to ",{totalCount:L},nr.DEBUG),v(D)}):E=Wr(e,()=>{st(u)("following output to ",{totalCount:L},nr.DEBUG),v(D),E=null})});function w(D){const L=Wr(s,T=>{D&&!T.atBottom&&T.notAtBottomBecause==="SIZE_INCREASED"&&!E&&(st(u)("scrolling to bottom due to increased size",{},nr.DEBUG),v("auto"))});setTimeout(L,100)}je(W(Et(me(y),t,l),fe(([D,,L])=>D&&L),cn(({value:D},[,L])=>({refreshed:D===L,value:L}),{refreshed:!1,value:0}),fe(({refreshed:D})=>D),Te(y,t)),([,D])=>{st(i)&&w(D!==!1)}),je(g,()=>{w(st(y)!==!1)}),je(Et(me(y),s),([D,L])=>{D&&!L.atBottom&&L.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&v("auto")});const A=K(null),C=Oe();return ce(Y0(W(me(n),re(D=>{var L;return(L=D==null?void 0:D.length)!=null?L:0})),W(me(t))),C),je(W(Et(W(C,oa(1)),c),Te(me(A),i,d,f),re(([[D,L],T,h,b,x])=>L&&h&&(T==null?void 0:T({context:x,totalCount:D,scrollingInProgress:b}))),fe(D=>!!D),Hn(0)),D=>{E&&(E(),E=null),st(r)?requestAnimationFrame(()=>{st(u)("scrolling into view",{}),Ce(m,D)}):E=Wr(e,()=>{st(u)("scrolling into view",{}),Ce(m,D),E=null})}),{autoscrollToBottom:g,followOutput:y,scrollIntoViewOnChange:A}},et(ln,mc,uc,dc,ys,hs,Wt,Bx,Fx)),Zj=$e(([{data:e,firstItemIndex:t,gap:r,sizes:n},{initialTopMostItemIndex:s},{initialItemCount:a,listState:o},{didMount:i}])=>(ce(W(i,Te(a),fe(([,c])=>c!==0),Te(s,n,t,r,e),re(([[,c],l,u,d,f,m=[]])=>Sx(c,l,u,d,f,m))),o),{}),et(ln,dc,la,ys),{singleton:!0}),Xj=$e(([{didMount:e},{scrollTo:t},{listState:r}])=>{const n=K(0);return je(W(e,Te(n),fe(([,s])=>s!==0),re(([,s])=>({top:s}))),s=>{Wr(W(r,oa(1),fe(a=>a.items.length>1)),()=>{requestAnimationFrame(()=>{Ce(t,s)})})}),{initialScrollTop:n}},et(ys,Wt,la),{singleton:!0}),Ox=$e(([{scrollVelocity:e}])=>{const t=K(!1),r=Oe(),n=K(!1);return ce(W(e,Te(n,t,r),fe(([s,a])=>!!a),re(([s,a,o,i])=>{const{enter:c,exit:l}=a;if(o){if(l(s,i))return!1}else if(c(s,i))return!0;return o}),tt()),t),je(W(Et(t,e,r),Te(n)),([[s,a,o],i])=>{s&&i&&i.change&&i.change(a,o)}),{isSeeking:t,scrollSeekConfiguration:n,scrollSeekRangeChanged:r,scrollVelocity:e}},et(mc),{singleton:!0}),im=$e(([{scrollContainerState:e,scrollTo:t}])=>{const r=Oe(),n=Oe(),s=Oe(),a=K(!1),o=K(void 0);return ce(W(Et(r,n),re(([{scrollHeight:i,scrollTop:c,viewportHeight:l},{offsetTop:u}])=>({scrollHeight:i,scrollTop:Math.max(0,c-u),viewportHeight:l}))),e),ce(W(t,Te(n),re(([i,{offsetTop:c}])=>({...i,top:i.top+c}))),s),{customScrollParent:o,useWindowScroll:a,windowScrollContainerState:r,windowScrollTo:s,windowViewportRect:n}},et(Wt)),Qj=$e(([{sizeRanges:e,sizes:t},{headerHeight:r,scrollTop:n},{initialTopMostItemIndex:s},{didMount:a},{useWindowScroll:o,windowScrollContainerState:i,windowViewportRect:c}])=>{const l=Oe(),u=K(void 0),d=K(null),f=K(null);return ce(i,d),ce(c,f),je(W(l,Te(t,n,o,d,f,r)),([m,y,g,E,v,w,A])=>{const C=_j(y.sizeTree);E&&v!==null&&w!==null&&(g=v.scrollTop-w.offsetTop),g-=A,m({ranges:C,scrollTop:g})}),ce(W(u,fe(W0),re(Jj)),s),ce(W(a,Te(u),fe(([,m])=>m!==void 0),tt(),re(([,m])=>m.ranges)),e),{getState:l,restoreStateFrom:u}},et(ln,Wt,dc,ys,im));function Jj(e){return{align:"start",index:0,offset:e.scrollTop}}const eV=$e(([{topItemsIndexes:e}])=>{const t=K(0);return ce(W(t,fe(r=>r>=0),re(r=>Array.from({length:r}).map((n,s)=>s))),e),{topItemCount:t}},et(la));function Dx(e){let t=!1,r;return()=>(t||(t=!0,r=e()),r)}const tV=Dx(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),rV=$e(([{deviation:e,scrollBy:t,scrollingInProgress:r,scrollTop:n},{isAtBottom:s,isScrolling:a,lastJumpDueToItemResize:o,scrollDirection:i},{listState:c},{beforeUnshiftWith:l,gap:u,shiftWithOffset:d,sizes:f},{log:m},{recalcInProgress:y}])=>{const g=br(W(c,Te(o),cn(([,v,w,A],[{bottom:C,items:D,offsetBottom:L,totalCount:T},h])=>{const b=C+L;let x=0;return w===T&&v.length>0&&D.length>0&&(D[0].originalIndex===0&&v[0].originalIndex===0||(x=b-A,x!==0&&(x+=h))),[x,D,T,b]},[0,[],0,0]),fe(([v])=>v!==0),Te(n,i,r,s,m,y),fe(([,v,w,A,,,C])=>!C&&!A&&v!==0&&w===pc),re(([[v],,,,,w])=>(w("Upward scrolling compensation",{amount:v},nr.DEBUG),v))));function E(v){v>0?(Ce(t,{behavior:"auto",top:-v}),Ce(e,0)):(Ce(e,0),Ce(t,{behavior:"auto",top:-v}))}return je(W(g,Te(e,a)),([v,w,A])=>{A&&tV()?Ce(e,w-v):E(-v)}),je(W(Et(Ht(a,!1),e,y),fe(([v,w,A])=>!v&&!A&&w!==0),re(([v,w])=>w),Hn(1)),E),ce(W(d,re(v=>({top:-v}))),t),je(W(l,Te(f,u),re(([v,{groupIndices:w,lastSize:A,sizeTree:C},D])=>{function L(T){return T*(A+D)}if(w.length===0)return L(v);{let T=0;const h=ic(C,0);let b=0,x=0;for(;b<v;){b++,T+=h;let S=w.length===x+1?1/0:w[x+1]-w[x]-1;b+S>v&&(T-=h,S=v-b+1),b+=S,T+=L(S),x++}return T}})),v=>{Ce(e,v),requestAnimationFrame(()=>{Ce(t,{top:v}),requestAnimationFrame(()=>{Ce(e,0),Ce(y,!1)})})}),{deviation:e}},et(Wt,mc,la,ln,hs,em)),nV=$e(([e,t,r,n,s,a,o,i,c,l,u])=>({...e,...t,...r,...n,...s,...a,...o,...i,...c,...l,...u}),et(am,Zj,ys,Ox,Ix,Xj,Wj,im,Fx,hs,Bx)),_x=$e(([{data:e,defaultItemSize:t,firstItemIndex:r,fixedItemSize:n,fixedGroupSize:s,gap:a,groupIndices:o,heightEstimates:i,itemSize:c,sizeRanges:l,sizes:u,statefulTotalCount:d,totalCount:f,trackItemSizes:m},{initialItemFinalLocationReached:y,initialTopMostItemIndex:g,scrolledToInitialItem:E},v,w,A,C,{scrollToIndex:D},L,{topItemCount:T},{groupCounts:h},b])=>{const{listState:x,minOverscanItemCount:S,topItemsIndexes:I,rangeChanged:F,..._}=C;return ce(F,b.scrollSeekRangeChanged),ce(W(b.windowViewportRect,re(k=>k.visibleHeight)),v.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:r,fixedItemHeight:n,fixedGroupHeight:s,gap:a,groupCounts:h,heightEstimates:i,initialItemFinalLocationReached:y,initialTopMostItemIndex:g,scrolledToInitialItem:E,sizeRanges:l,topItemCount:T,topItemsIndexes:I,totalCount:f,...A,groupIndices:o,itemSize:c,listState:x,minOverscanItemCount:S,scrollToIndex:D,statefulTotalCount:d,trackItemSizes:m,rangeChanged:F,..._,...b,...v,sizes:u,...w}},et(ln,dc,Wt,Qj,Kj,la,uc,rV,eV,wx,nV));function sV(e,t){const r={},n={};let s=0;const a=e.length;for(;s<a;)n[e[s]]=1,s+=1;for(const o in t)Object.hasOwn(n,o)||(r[o]=t[o]);return r}const $u=typeof document<"u"?M.useLayoutEffect:M.useEffect;function Mx(e,t,r){const n=Object.keys(t.required||{}),s=Object.keys(t.optional||{}),a=Object.keys(t.methods||{}),o=Object.keys(t.events||{}),i=M.createContext({});function c(E,v){E.propsReady&&Ce(E.propsReady,!1);for(const w of n){const A=E[t.required[w]];Ce(A,v[w])}for(const w of s)if(w in v){const A=E[t.optional[w]];Ce(A,v[w])}E.propsReady&&Ce(E.propsReady,!0)}function l(E){return a.reduce((v,w)=>(v[w]=A=>{const C=E[t.methods[w]];Ce(C,A)},v),{})}function u(E){return o.reduce((v,w)=>(v[w]=wj(E[t.events[w]]),v),{})}const d=M.forwardRef((E,v)=>{const{children:w,...A}=E,[C]=M.useState(()=>Nu(Ej(e),T=>{c(T,A)})),[D]=M.useState(sx(u,C));$u(()=>{for(const T of o)T in A&&je(D[T],A[T]);return()=>{Object.values(D).map(q0)}},[A,D,C]),$u(()=>{c(C,A)}),M.useImperativeHandle(v,rx(l(C)));const L=r;return B.jsx(i.Provider,{value:C,children:r?B.jsx(L,{...sV([...n,...s,...o],A),children:w}):w})}),f=E=>{const v=M.useContext(i);return M.useCallback(w=>{Ce(v[E],w)},[v,E])},m=E=>{const v=M.useContext(i)[E],w=M.useCallback(A=>je(v,A),[v]);return M.useSyncExternalStore(w,()=>st(v),()=>st(v))},y=E=>{const v=M.useContext(i)[E],[w,A]=M.useState(sx(st,v));return $u(()=>je(v,C=>{C!==w&&A(rx(C))}),[v,w]),w},g=M.version.startsWith("18")?m:y;return{Component:d,useEmitter:(E,v)=>{const w=M.useContext(i)[E];$u(()=>je(w,v),[v,w])},useEmitterValue:g,usePublisher:f}}const Nx=M.createContext(void 0),Lx=M.createContext(void 0),zx=typeof document<"u"?M.useLayoutEffect:M.useEffect;function cm(e){return"self"in e}function aV(e){return"body"in e}function Rx(e,t,r,n=ho,s,a){const o=M.useRef(null),i=M.useRef(null),c=M.useRef(null),l=M.useCallback(f=>{let m,y,g;const E=f.target;if(aV(E)||cm(E)){const w=cm(E)?E:E.defaultView;g=a?w.scrollX:w.scrollY,m=a?w.document.documentElement.scrollWidth:w.document.documentElement.scrollHeight,y=a?w.innerWidth:w.innerHeight}else g=a?E.scrollLeft:E.scrollTop,m=a?E.scrollWidth:E.scrollHeight,y=a?E.offsetWidth:E.offsetHeight;const v=()=>{e({scrollHeight:m,scrollTop:Math.max(g,0),viewportHeight:y})};f.suppressFlushSync?v():ka.flushSync(v),i.current!==null&&(g===i.current||g<=0||g===m-y)&&(i.current=null,t(!0),c.current&&(clearTimeout(c.current),c.current=null))},[e,t,a]);M.useEffect(()=>{const f=s||o.current;return n(s||o.current),l({suppressFlushSync:!0,target:f}),f.addEventListener("scroll",l,{passive:!0}),()=>{n(null),f.removeEventListener("scroll",l)}},[o,l,r,n,s]);function u(f){const m=o.current;if(!m||(a?"offsetWidth"in m&&m.offsetWidth===0:"offsetHeight"in m&&m.offsetHeight===0))return;const y=f.behavior==="smooth";let g,E,v;cm(m)?(E=Math.max(bs(m.document.documentElement,a?"width":"height"),a?m.document.documentElement.scrollWidth:m.document.documentElement.scrollHeight),g=a?m.innerWidth:m.innerHeight,v=a?window.scrollX:window.scrollY):(E=m[a?"scrollWidth":"scrollHeight"],g=bs(m,a?"width":"height"),v=m[a?"scrollLeft":"scrollTop"]);const w=E-g;if(f.top=Math.ceil(Math.max(Math.min(w,f.top),0)),Ex(g,E)||f.top===v){e({scrollHeight:E,scrollTop:v,viewportHeight:g}),y&&t(!0);return}y?(i.current=f.top,c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{c.current=null,i.current=null,t(!0)},1e3)):i.current=null,a&&(f={behavior:f.behavior,left:f.top}),m.scrollTo(f)}function d(f){a&&(f={behavior:f.behavior,left:f.top}),o.current.scrollBy(f)}return{scrollByCallback:d,scrollerRef:o,scrollToCallback:u}}const lm="-webkit-sticky",Hx="sticky",um=Dx(()=>{if(typeof document>"u")return Hx;const e=document.createElement("div");return e.style.position=lm,e.style.position===lm?lm:Hx});function dm(e){return e}const oV=$e(()=>{const e=K(i=>`Item ${i}`),t=K(i=>`Group ${i}`),r=K({}),n=K(dm),s=K("div"),a=K(ho),o=(i,c=null)=>Ht(W(r,re(l=>l[i]),tt()),c);return{components:r,computeItemKey:n,EmptyPlaceholder:o("EmptyPlaceholder"),FooterComponent:o("Footer"),GroupComponent:o("Group","div"),groupContent:t,HeaderComponent:o("Header"),HeaderFooterTag:s,ItemComponent:o("Item","div"),itemContent:e,ListComponent:o("List","div"),ScrollerComponent:o("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:o("ScrollSeekPlaceholder"),TopItemListComponent:o("TopItemList")}}),iV=$e(([e,t])=>({...e,...t}),et(_x,oV)),cV=({height:e})=>B.jsx("div",{style:{height:e}}),lV={overflowAnchor:"none",position:um(),zIndex:1},$x={overflowAnchor:"none"},uV={...$x,display:"inline-block",height:"100%"},Gx=M.memo(function({showTopList:e=!1}){const t=ye("listState"),r=Pr("sizeRanges"),n=ye("useWindowScroll"),s=ye("customScrollParent"),a=Pr("windowScrollContainerState"),o=Pr("scrollContainerState"),i=s||n?a:o,c=ye("itemContent"),l=ye("context"),u=ye("groupContent"),d=ye("trackItemSizes"),f=ye("itemSize"),m=ye("log"),y=Pr("gap"),g=ye("horizontalDirection"),{callbackRef:E}=Tj(r,f,d,e?ho:i,m,y,s,g,ye("skipAnimationFrameInResizeObserver")),[v,w]=M.useState(0);pm("deviation",_=>{v!==_&&w(_)});const A=ye("EmptyPlaceholder"),C=ye("ScrollSeekPlaceholder")||cV,D=ye("ListComponent"),L=ye("ItemComponent"),T=ye("GroupComponent"),h=ye("computeItemKey"),b=ye("isSeeking"),x=ye("groupIndices").length>0,S=ye("alignToBottom"),I=ye("initialItemFinalLocationReached"),F=e?{}:{boxSizing:"border-box",...g?{display:"inline-block",height:"100%",marginLeft:v!==0?v:S?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:v!==0?v:S?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...I?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&A?B.jsx(A,{...$t(A,l)}):B.jsx(D,{...$t(D,l),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:E,style:F,children:(e?t.topItems:t.items).map(_=>{const k=_.originalIndex,P=h(k+t.firstItemIndex,_.data,l);return b?M.createElement(C,{...$t(C,l),height:_.size,index:_.index,key:P,type:_.type||"item",..._.type==="group"?{}:{groupIndex:_.groupIndex}}):_.type==="group"?M.createElement(T,{...$t(T,l),"data-index":k,"data-item-index":_.index,"data-known-size":_.size,key:P,style:lV},u(_.index,l)):M.createElement(L,{...$t(L,l),...mV(L,_.data),"data-index":k,"data-item-group-index":_.groupIndex,"data-item-index":_.index,"data-known-size":_.size,key:P,style:g?uV:$x},x?c(_.index,_.groupIndex,_.data,l):c(_.index,_.data,l))})})}),dV={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},pV={outline:"none",overflowX:"auto",position:"relative"},Gu=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),fV={position:um(),top:0,width:"100%",zIndex:1};function $t(e,t){if(typeof e!="string")return{context:t}}function mV(e,t){return{item:typeof e=="string"?void 0:t}}const hV=M.memo(function(){const e=ye("HeaderComponent"),t=Pr("headerHeight"),r=ye("HeaderFooterTag"),n=ia(M.useMemo(()=>a=>{t(bs(a,"height"))},[t]),!0,ye("skipAnimationFrameInResizeObserver")),s=ye("context");return e?B.jsx(r,{ref:n,children:B.jsx(e,{...$t(e,s)})}):null}),bV=M.memo(function(){const e=ye("FooterComponent"),t=Pr("footerHeight"),r=ye("HeaderFooterTag"),n=ia(M.useMemo(()=>a=>{t(bs(a,"height"))},[t]),!0,ye("skipAnimationFrameInResizeObserver")),s=ye("context");return e?B.jsx(r,{ref:n,children:B.jsx(e,{...$t(e,s)})}):null});function jx({useEmitter:e,useEmitterValue:t,usePublisher:r}){return M.memo(function({children:n,style:s,context:a,...o}){const i=r("scrollContainerState"),c=t("ScrollerComponent"),l=r("smoothScrollTargetReached"),u=t("scrollerRef"),d=t("horizontalDirection")||!1,{scrollByCallback:f,scrollerRef:m,scrollToCallback:y}=Rx(i,l,c,u,void 0,d);return e("scrollTo",y),e("scrollBy",f),B.jsx(c,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:m,style:{...d?pV:dV,...s},tabIndex:0,...o,...$t(c,a),children:n})})}function Vx({useEmitter:e,useEmitterValue:t,usePublisher:r}){return M.memo(function({children:n,style:s,context:a,...o}){const i=r("windowScrollContainerState"),c=t("ScrollerComponent"),l=r("smoothScrollTargetReached"),u=t("totalListHeight"),d=t("deviation"),f=t("customScrollParent"),m=M.useRef(null),y=t("scrollerRef"),{scrollByCallback:g,scrollerRef:E,scrollToCallback:v}=Rx(i,l,c,y,f);return zx(()=>{var w;return E.current=f||((w=m.current)==null?void 0:w.ownerDocument.defaultView),()=>{E.current=null}},[E,f]),e("windowScrollTo",v),e("scrollBy",g),B.jsx(c,{ref:m,"data-virtuoso-scroller":!0,style:{position:"relative",...s,...u!==0?{height:u+d}:{}},...o,...$t(c,a),children:n})})}const yV=({children:e})=>{const t=M.useContext(Nx),r=Pr("viewportHeight"),n=Pr("fixedItemHeight"),s=ye("alignToBottom"),a=ye("horizontalDirection"),o=M.useMemo(()=>nx(r,c=>bs(c,a?"width":"height")),[r,a]),i=ia(o,!0,ye("skipAnimationFrameInResizeObserver"));return M.useEffect(()=>{t&&(r(t.viewportHeight),n(t.itemHeight))},[t,r,n]),B.jsx("div",{"data-viewport-type":"element",ref:i,style:Gu(s),children:e})},gV=({children:e})=>{const t=M.useContext(Nx),r=Pr("windowViewportRect"),n=Pr("fixedItemHeight"),s=ye("customScrollParent"),a=cx(r,s,ye("skipAnimationFrameInResizeObserver")),o=ye("alignToBottom");return M.useEffect(()=>{t&&(n(t.itemHeight),r({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,r,n]),B.jsx("div",{"data-viewport-type":"window",ref:a,style:Gu(o),children:e})},xV=({children:e})=>{const t=ye("TopItemListComponent")||"div",r=ye("headerHeight"),n={...fV,marginTop:`${r}px`},s=ye("context");return B.jsx(t,{style:n,...$t(t,s),children:e})},wV=M.memo(function(e){const t=ye("useWindowScroll"),r=ye("topItemsIndexes").length>0,n=ye("customScrollParent"),s=ye("context");return B.jsxs(n||t?kV:EV,{...e,context:s,children:[r&&B.jsx(xV,{children:B.jsx(Gx,{showTopList:!0})}),B.jsxs(n||t?gV:yV,{children:[B.jsx(hV,{}),B.jsx(Gx,{}),B.jsx(bV,{})]})]})}),{Component:vV,useEmitter:pm,useEmitterValue:ye,usePublisher:Pr}=Mx(iV,{required:{},optional:{restoreStateFrom:"restoreStateFrom",context:"context",followOutput:"followOutput",scrollIntoViewOnChange:"scrollIntoViewOnChange",itemContent:"itemContent",groupContent:"groupContent",overscan:"overscan",increaseViewportBy:"increaseViewportBy",minOverscanItemCount:"minOverscanItemCount",totalCount:"totalCount",groupCounts:"groupCounts",topItemCount:"topItemCount",firstItemIndex:"firstItemIndex",initialTopMostItemIndex:"initialTopMostItemIndex",components:"components",atBottomThreshold:"atBottomThreshold",atTopThreshold:"atTopThreshold",computeItemKey:"computeItemKey",defaultItemHeight:"defaultItemHeight",fixedGroupHeight:"fixedGroupHeight",fixedItemHeight:"fixedItemHeight",heightEstimates:"heightEstimates",itemSize:"itemSize",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"HeaderFooterTag",data:"data",initialItemCount:"initialItemCount",initialScrollTop:"initialScrollTop",alignToBottom:"alignToBottom",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",horizontalDirection:"horizontalDirection",skipAnimationFrameInResizeObserver:"skipAnimationFrameInResizeObserver"},methods:{scrollToIndex:"scrollToIndex",scrollIntoView:"scrollIntoView",scrollTo:"scrollTo",scrollBy:"scrollBy",autoscrollToBottom:"autoscrollToBottom",getState:"getState"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",totalListHeightChanged:"totalListHeightChanged",itemsRendered:"itemsRendered",groupIndices:"groupIndices"}},wV),EV=jx({useEmitter:pm,useEmitterValue:ye,usePublisher:Pr}),kV=Vx({useEmitter:pm,useEmitterValue:ye,usePublisher:Pr}),CV=vV;et(_x,$e(()=>{const e=K(l=>B.jsxs("td",{children:["Item $",l]})),t=K(null),r=K(l=>B.jsxs("td",{colSpan:1e3,children:["Group ",l]})),n=K(null),s=K(null),a=K({}),o=K(dm),i=K(ho),c=(l,u=null)=>Ht(W(a,re(d=>d[l]),tt()),u);return{components:a,computeItemKey:o,context:t,EmptyPlaceholder:c("EmptyPlaceholder"),FillerRow:c("FillerRow"),fixedFooterContent:s,fixedHeaderContent:n,itemContent:e,groupContent:r,ScrollerComponent:c("Scroller","div"),scrollerRef:i,ScrollSeekPlaceholder:c("ScrollSeekPlaceholder"),TableBodyComponent:c("TableBody","tbody"),TableComponent:c("Table","table"),TableFooterComponent:c("TableFoot","tfoot"),TableHeadComponent:c("TableHead","thead"),TableRowComponent:c("TableRow","tr"),GroupComponent:c("Group","tr")}})),um();const Wx={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},TV={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:qx,floor:ju,max:yc,min:fm,round:Yx}=Math;function Kx(e,t,r){return Array.from({length:t-e+1}).map((n,s)=>({data:r===null?null:r[s+e],index:s+e}))}function SV(e){return{...TV,items:e}}function Vu(e,t){return e&&e.width===t.width&&e.height===t.height}function AV(e,t){return e&&e.column===t.column&&e.row===t.row}const PV=$e(([{increaseViewportBy:e,listBoundary:t,overscan:r,visibleRange:n},{footerHeight:s,headerHeight:a,scrollBy:o,scrollContainerState:i,scrollTo:c,scrollTop:l,smoothScrollTargetReached:u,viewportHeight:d},f,m,{didMount:y,propsReady:g},{customScrollParent:E,useWindowScroll:v,windowScrollContainerState:w,windowScrollTo:A,windowViewportRect:C},D])=>{const L=K(0),T=K(0),h=K(Wx),b=K({height:0,width:0}),x=K({height:0,width:0}),S=Oe(),I=Oe(),F=K(0),_=K(null),k=K({column:0,row:0}),P=Oe(),O=Oe(),U=K(!1),z=K(0),H=K(!0),G=K(!1),J=K(!1);je(W(y,Te(z),fe(([Q,ve])=>!!ve)),()=>{Ce(H,!1)}),je(W(Et(y,H,x,b,z,G),fe(([Q,ve,_e,Ge,,ot])=>Q&&!ve&&_e.height!==0&&Ge.height!==0&&!ot)),([,,,,Q])=>{Ce(G,!0),nm(1,()=>{Ce(S,Q)}),Wr(W(l),()=>{Ce(t,[0,0]),Ce(H,!0)})}),ce(W(O,fe(Q=>Q!=null&&Q.scrollTop>0),on(0)),T),je(W(y,Te(O),fe(([,Q])=>Q!=null)),([,Q])=>{Q&&(Ce(b,Q.viewport),Ce(x,Q.item),Ce(k,Q.gap),Q.scrollTop>0&&(Ce(U,!0),Wr(W(l,oa(1)),ve=>{Ce(U,!1)}),Ce(c,{top:Q.scrollTop})))}),ce(W(b,re(({height:Q})=>Q)),d),ce(W(Et(me(b,Vu),me(x,Vu),me(k,(Q,ve)=>Q&&Q.column===ve.column&&Q.row===ve.row),me(l)),re(([Q,ve,_e,Ge])=>({gap:_e,item:ve,scrollTop:Ge,viewport:Q}))),P),ce(W(Et(me(L),n,me(k,AV),me(x,Vu),me(b,Vu),me(_),me(T),me(U),me(H),me(z)),fe(([,,,,,,,Q])=>!Q),re(([Q,[ve,_e],Ge,ot,Se,Ee,be,,Ze,Ye])=>{const{column:Xe,row:Fr}=Ge,{height:Ot,width:wm}=ot,{width:C5}=Se;if(be===0&&(Q===0||C5===0))return Wx;if(wm===0){const I5=sm(Ye,Q),NW=I5+Math.max(be-1,0);return SV(Kx(I5,NW,Ee))}const qu=Zx(C5,wm,Xe);let Bo,Ea;Ze?ve===0&&_e===0&&be>0?(Bo=0,Ea=be-1):(Bo=qu*ju((ve+Fr)/(Ot+Fr)),Ea=qu*qx((_e+Fr)/(Ot+Fr))-1,Ea=fm(Q-1,yc(Ea,qu-1)),Bo=fm(Ea,yc(0,Bo))):(Bo=0,Ea=-1);const T5=Kx(Bo,Ea,Ee),{bottom:S5,top:A5}=Xx(Se,Ge,ot,T5),P5=qx(Q/qu),MW=P5*Ot+(P5-1)*Fr-S5;return{bottom:S5,itemHeight:Ot,items:T5,itemWidth:wm,offsetBottom:MW,offsetTop:A5,top:A5}})),h),ce(W(_,fe(Q=>Q!==null),re(Q=>Q.length)),L),ce(W(Et(b,x,h,k),fe(([Q,ve,{items:_e}])=>_e.length>0&&ve.height!==0&&Q.height!==0),re(([Q,ve,{items:_e},Ge])=>{const{bottom:ot,top:Se}=Xx(Q,Ge,ve,_e);return[Se,ot]}),tt(cc)),t);const pe=K(!1);ce(W(l,Te(pe),re(([Q,ve])=>ve||Q!==0)),pe);const he=br(W(Et(h,L),fe(([{items:Q}])=>Q.length>0),Te(pe),fe(([[Q,ve],_e])=>{const Ge=Q.items[Q.items.length-1].index===ve-1;return(_e||Q.bottom>0&&Q.itemHeight>0&&Q.offsetBottom===0&&Q.items.length===ve)&&Ge}),re(([[,Q]])=>Q-1),tt())),ie=br(W(me(h),fe(({items:Q})=>Q.length>0&&Q[0].index===0),on(0),tt())),de=br(W(me(h),Te(U),fe(([{items:Q},ve])=>Q.length>0&&!ve),re(([{items:Q}])=>({endIndex:Q[Q.length-1].index,startIndex:Q[0].index})),tt(hx),Hn(0)));ce(de,m.scrollSeekRangeChanged),ce(W(S,Te(b,x,L,k),re(([Q,ve,_e,Ge,ot])=>{const Se=vx(Q),{align:Ee,behavior:be,offset:Ze}=Se;let Ye=Se.index;Ye==="LAST"&&(Ye=Ge-1),Ye=yc(0,Ye,fm(Ge-1,Ye));let Xe=mm(ve,ot,_e,Ye);return Ee==="end"?Xe=Yx(Xe-ve.height+_e.height):Ee==="center"&&(Xe=Yx(Xe-ve.height/2+_e.height/2)),Ze&&(Xe+=Ze),{behavior:be,top:Xe}})),c);const Be=Ht(W(h,re(Q=>Q.offsetBottom+Q.bottom)),0);return ce(W(C,re(Q=>({height:Q.visibleHeight,width:Q.visibleWidth}))),b),{customScrollParent:E,data:_,deviation:F,footerHeight:s,gap:k,headerHeight:a,increaseViewportBy:e,initialItemCount:T,itemDimensions:x,overscan:r,restoreStateFrom:O,scrollBy:o,scrollContainerState:i,scrollHeight:I,scrollTo:c,scrollToIndex:S,scrollTop:l,smoothScrollTargetReached:u,totalCount:L,useWindowScroll:v,viewportDimensions:b,windowScrollContainerState:w,windowScrollTo:A,windowViewportRect:C,...m,gridState:h,horizontalDirection:J,initialTopMostItemIndex:z,totalListHeight:Be,...f,endReached:he,propsReady:g,rangeChanged:de,startReached:ie,stateChanged:P,stateRestoreInProgress:U,...D}},et(am,Wt,mc,Ox,ys,im,hs));function Zx(e,t,r){return yc(1,ju((e+r)/(ju(t)+r)))}function Xx(e,t,r,n){const{height:s}=r;if(s===void 0||n.length===0)return{bottom:0,top:0};const a=mm(e,t,r,n[0].index);return{bottom:mm(e,t,r,n[n.length-1].index)+s,top:a}}function mm(e,t,r,n){const s=Zx(e.width,r.width,t.column),a=ju(n/s),o=a*r.height+yc(0,a-1)*t.row;return o>0?o+t.row:o}const IV=$e(()=>{const e=K(d=>`Item ${d}`),t=K({}),r=K(null),n=K("virtuoso-grid-item"),s=K("virtuoso-grid-list"),a=K(dm),o=K("div"),i=K(ho),c=(d,f=null)=>Ht(W(t,re(m=>m[d]),tt()),f),l=K(!1),u=K(!1);return ce(me(u),l),{components:t,computeItemKey:a,context:r,FooterComponent:c("Footer"),HeaderComponent:c("Header"),headerFooterTag:o,itemClassName:n,ItemComponent:c("Item","div"),itemContent:e,listClassName:s,ListComponent:c("List","div"),readyStateChanged:l,reportReadyState:u,ScrollerComponent:c("Scroller","div"),scrollerRef:i,ScrollSeekPlaceholder:c("ScrollSeekPlaceholder","div")}}),BV=$e(([e,t])=>({...e,...t}),et(PV,IV)),FV=M.memo(function(){const e=at("gridState"),t=at("listClassName"),r=at("itemClassName"),n=at("itemContent"),s=at("computeItemKey"),a=at("isSeeking"),o=Ir("scrollHeight"),i=at("ItemComponent"),c=at("ListComponent"),l=at("ScrollSeekPlaceholder"),u=at("context"),d=Ir("itemDimensions"),f=Ir("gap"),m=at("log"),y=at("stateRestoreInProgress"),g=Ir("reportReadyState"),E=ia(M.useMemo(()=>v=>{const w=v.parentElement.parentElement.scrollHeight;o(w);const A=v.firstChild;if(A){const{height:C,width:D}=A.getBoundingClientRect();d({height:C,width:D})}f({column:Jx("column-gap",getComputedStyle(v).columnGap,m),row:Jx("row-gap",getComputedStyle(v).rowGap,m)})},[o,d,f,m]),!0,!1);return zx(()=>{e.itemHeight>0&&e.itemWidth>0&&g(!0)},[e]),y?null:B.jsx(c,{className:t,ref:E,...$t(c,u),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(v=>{const w=s(v.index,v.data,u);return a?B.jsx(l,{...$t(l,u),height:e.itemHeight,index:v.index,width:e.itemWidth},w):M.createElement(i,{...$t(i,u),className:r,"data-index":v.index,key:w},n(v.index,v.data,u))})})}),UV=M.memo(function(){const e=at("HeaderComponent"),t=Ir("headerHeight"),r=at("headerFooterTag"),n=ia(M.useMemo(()=>a=>{t(bs(a,"height"))},[t]),!0,!1),s=at("context");return e?B.jsx(r,{ref:n,children:B.jsx(e,{...$t(e,s)})}):null}),OV=M.memo(function(){const e=at("FooterComponent"),t=Ir("footerHeight"),r=at("headerFooterTag"),n=ia(M.useMemo(()=>a=>{t(bs(a,"height"))},[t]),!0,!1),s=at("context");return e?B.jsx(r,{ref:n,children:B.jsx(e,{...$t(e,s)})}):null}),DV=({children:e})=>{const t=M.useContext(Lx),r=Ir("itemDimensions"),n=Ir("viewportDimensions"),s=ia(M.useMemo(()=>a=>{n(a.getBoundingClientRect())},[n]),!0,!1);return M.useEffect(()=>{t&&(n({height:t.viewportHeight,width:t.viewportWidth}),r({height:t.itemHeight,width:t.itemWidth}))},[t,n,r]),B.jsx("div",{ref:s,style:Gu(!1),children:e})},_V=({children:e})=>{const t=M.useContext(Lx),r=Ir("windowViewportRect"),n=Ir("itemDimensions"),s=at("customScrollParent"),a=cx(r,s,!1);return M.useEffect(()=>{t&&(n({height:t.itemHeight,width:t.itemWidth}),r({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,r,n]),B.jsx("div",{ref:a,style:Gu(!1),children:e})},MV=M.memo(function({...e}){const t=at("useWindowScroll"),r=at("customScrollParent"),n=r||t?LV:NV,s=r||t?_V:DV,a=at("context");return B.jsx(n,{...e,...$t(n,a),children:B.jsxs(s,{children:[B.jsx(UV,{}),B.jsx(FV,{}),B.jsx(OV,{})]})})}),{useEmitter:Qx,useEmitterValue:at,usePublisher:Ir}=Mx(BV,{optional:{context:"context",totalCount:"totalCount",overscan:"overscan",itemContent:"itemContent",components:"components",computeItemKey:"computeItemKey",data:"data",initialItemCount:"initialItemCount",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"headerFooterTag",listClassName:"listClassName",itemClassName:"itemClassName",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",restoreStateFrom:"restoreStateFrom",initialTopMostItemIndex:"initialTopMostItemIndex",increaseViewportBy:"increaseViewportBy"},methods:{scrollTo:"scrollTo",scrollBy:"scrollBy",scrollToIndex:"scrollToIndex"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",stateChanged:"stateChanged",readyStateChanged:"readyStateChanged"}},MV),NV=jx({useEmitter:Qx,useEmitterValue:at,usePublisher:Ir}),LV=Vx({useEmitter:Qx,useEmitterValue:at,usePublisher:Ir});function Jx(e,t,r){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&r(`${e} was not resolved to pixel value correctly`,t,nr.WARN),t==="normal"?0:parseInt(t??"0",10)}var hm={},e5;function zV(){if(e5)return hm;e5=1;var e=uu.GenIcon;return hm.AiFillQuestionCircle=function(r){return e({tag:"svg",attr:{viewBox:"0 0 1024 1024"},child:[{tag:"path",attr:{d:"M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 708c-22.1 0-40-17.9-40-40s17.9-40 40-40 40 17.9 40 40-17.9 40-40 40zm62.9-219.5a48.3 48.3 0 0 0-30.9 44.8V620c0 4.4-3.6 8-8 8h-48c-4.4 0-8-3.6-8-8v-21.5c0-23.1 6.7-45.9 19.9-64.9 12.9-18.6 30.9-32.8 52.1-40.9 34-13.1 56-41.6 56-72.7 0-44.1-43.1-80-96-80s-96 35.9-96 80v7.6c0 4.4-3.6 8-8 8h-48c-4.4 0-8-3.6-8-8V420c0-39.3 17.2-76 48.4-103.3C430.4 290.4 470 276 512 276s81.6 14.5 111.6 40.7C654.8 344 672 380.7 672 420c0 57.8-38.1 109.8-97.1 132.5z"}}]})(r)},hm}var RV=zV();function HV({logo:e,className:t="",style:r={},alt:n="Token logo"}){const[s,a]=M.useState(!1);return M.useEffect(()=>{a(!1)},[e]),e&&!s?B.jsx("img",{alt:n,style:r,onError:()=>a(!0),className:`twap-token-logo ${t}`,src:e}):B.jsx(RV.AiFillQuestionCircle,{style:{width:20,height:20},className:"twap-token-svg"})}const $V=()=>B.jsx("div",{className:"twap-orders__loader",children:B.jsx("p",{children:"Loading..."})}),GV=()=>{const{isLoading:e}=Du(),t=q2(),r=Z(a=>a.state.orderIdsToCancel),n=Z(a=>a.state.cancelOrdersMode),s=Y2();return B.jsx(B.Fragment,{children:e?B.jsx($V,{}):t!=null&&t.length?B.jsx("div",{className:`twap-orders__list ${n?"twap-orders__list-select-mode":""}`,children:B.jsx(CV,{style:{height:"100%"},data:t,itemContent:(a,o)=>B.jsx(jV,{cancelOrdersMode:!!n,selected:(r==null?void 0:r.includes(o.id))||!1,selectOrder:s,order:o},a)})}):B.jsx(VV,{})})},jV=({order:e,selectOrder:t,selected:r,cancelOrdersMode:n})=>{const s=Z(i=>i.updateState),a=xt.useCallback(()=>{s({selectedOrderID:e==null?void 0:e.id})},[s,e==null?void 0:e.id]),o=xt.useCallback(()=>{n?t(e==null?void 0:e.id):a()},[n,t,a,e==null?void 0:e.id]);return B.jsx("div",{className:`twap-orders__list-item twap-orders__list-item-${e.status} ${n?"twap-orders__list-item-select-mode":""} ${r?"twap-orders__list-item-selected":""}`,onClick:o,children:B.jsxs("div",{className:"twap-orders__list-item-content",children:[B.jsx(WV,{order:e}),B.jsx(qV,{value:e.progress||0}),B.jsxs("div",{className:"twap-orders__list-item-tokens",children:[B.jsx(t5,{address:e.srcTokenAddress}),B.jsx(mj.HiArrowRight,{className:"twap-orders__list-item-tokens-arrow"}),B.jsx(t5,{address:e.dstTokenAddress})]})]})})},VV=()=>{const e=Z(n=>n.state.orderHistoryStatusFilter),t=Ue(),r=xt.useMemo(()=>e||"",[e]);return B.jsx("div",{className:"twap-orders__list-empty",children:B.jsx("p",{children:t("noOrders",{status:r})})})},WV=({order:e})=>{const t=e&&e.status,r=W2(e),n=H0(e.createdAt);return B.jsxs("div",{className:"twap-orders__list-item-header",children:[B.jsxs("p",{className:"twap-orders__list-item-header-title",children:[r," ",B.jsx("span",{children:`(${n})`})]}),B.jsx("p",{className:"twap-orders__list-item-header-status",children:t})]})},t5=e=>{const{useToken:t,components:r}=ne(),n=t==null?void 0:t(e.address);return B.jsx("div",{className:"twap-orders__list-item-token",children:n?B.jsxs(B.Fragment,{children:[B.jsx("div",{className:"twap-orders__list-item-token-logo",children:r.TokenLogo?B.jsx(r.TokenLogo,{token:n}):B.jsx(HV,{logo:n==null?void 0:n.logoUrl})}),B.jsx("p",{className:"twap-orders__list-item-token-symbol",children:n==null?void 0:n.symbol})]}):B.jsx("div",{})})};function qV(e){return B.jsxs("div",{className:"twap-orders__list-item-progress",children:[B.jsx("div",{className:"twap-orders__list-item-progress-bar",children:B.jsx("div",{className:"twap-orders__list-item-progress-bar-filled",style:{width:`${e.value}%`}})}),B.jsx("div",{className:"twap-orders__list-item-token-progress-label",children:B.jsx("p",{children:`${Math.round(e.value)}%`})})]})}const YV=()=>{const e=Z(r=>r.state.selectedOrderID),t=e!==void 0;return B.jsx("div",{className:`twap-orders ${e!==void 0?"twap-orders__show-selected":""}`,children:t?B.jsx(qG,{}):B.jsx(GV,{})})},KV=e=>{const t=Ue(),{marketPrice:r}=ne(),n=Z(a=>a.state.typedSrcAmount);return M.useMemo(()=>{const{isError:a,value:o}=hh(e);if(!(!a||j(n||"0").isZero()||!r))return{type:Mt.MIN_FILL_DELAY,value:o,message:t("minFillDelayError",{fillDelay:`${Sd(o)} ${t("minutes")}`})}},[e,t,n,r])},ua=()=>{const e=Z(s=>s.state.typedFillDelay),t=Z(s=>s.updateState),r=M.useMemo(()=>e||Bc,[e]),n=KV(r);return{fillDelay:r,onChange:M.useCallback(s=>t({typedFillDelay:s}),[t]),error:n,milliseconds:r.unit*r.value}},ZV=()=>{const{onChange:e,fillDelay:t,error:r}=ua(),n=Ue(),s=M.useCallback(o=>e({unit:t.unit,value:Number(o)}),[e,t]),a=M.useCallback(o=>e({unit:o,value:t.value}),[e,t]);return{onInputChange:s,onUnitSelect:a,onChange:e,milliseconds:t.unit*t.value,fillDelay:t,error:r,label:n("tradeIntervalTitle"),tooltip:n("tradeIntervalTootlip")}},un=()=>{const{srcToken:e}=ne(),t=Ue(),r=Z(a=>a.state.typedSrcAmount),s=Z(a=>a.state.acceptedSrcAmount)||r;return{amountWei:V2(e==null?void 0:e.decimals,s),amountUI:s,error:j(s||0).isZero()?t("enterAmount"):void 0}},XV=(e,t)=>{const{module:r,srcUsd1Token:n,marketPrice:s,minChunkSizeUsd:a}=ne(),o=Ue(),i=Z(c=>c.state.typedSrcAmount);return M.useMemo(()=>{if(j(i||"0").isZero()||!s)return;if(!e)return{type:Mt.MIN_CHUNKS,value:1,message:o("minChunksError",{minChunks:"1"})};const{isError:c}=yh(e,t,r);if(c)return{type:Mt.MAX_CHUNKS,value:t,message:o("maxChunksError",{maxChunks:`${t}`})};const{isError:l,value:u}=bh(i||"",n||"",a||0);if(l)return{type:Mt.MIN_TRADE_SIZE,value:u,message:o("minTradeSizeError",{minTradeSize:`${u}`})}},[e,t,r,i,n,a,o,s])},$n=()=>{const{srcToken:e,srcUsd1Token:t,module:r,minChunkSizeUsd:n}=ne(),s=Z(g=>g.state.typedChunks),a=ua().fillDelay,o=Z(g=>g.updateState),{amountWei:i,amountUI:c}=un(),l=M.useMemo(()=>oh(a,c||"",t||"",n||0),[c,t,n,a]),u=M.useMemo(()=>ah(l,r,s),[l,s,r]),d=M.useCallback(g=>o({typedChunks:g}),[o]),f=M.useMemo(()=>ch(i||"",u),[i,u]),m=Vr(e==null?void 0:e.decimals,f),y=M.useMemo(()=>t?j(m||"0").times(t||0).toString():"0",[m,t]);return{totalTrades:u,maxTrades:l,amountPerTradeUI:m,amountPerTradeWei:f,amountPerTradeUsd:y,onChange:d,error:XV(u,l)}},QV=()=>{const{srcToken:e,dstToken:t}=ne(),r=Ue(),{onChange:n,totalTrades:s,amountPerTradeUsd:a,amountPerTradeUI:o,error:i,maxTrades:c,amountPerTradeWei:l}=$n(),u=ze({value:o}),d=ze({value:a});return{error:i,maxTrades:c,totalTrades:s,amountPerTrade:u,amountPerTradeWei:l,onChange:n,label:r("tradesAmountTitle"),tooltip:r("totalTradesTooltip"),amountPerTradeUsd:d,fromToken:e,toToken:t}},JV=e=>{const{module:t,marketPrice:r}=ne(),n=Ue();return M.useMemo(()=>{const s=fh(t,e),a=mh(e);if(r){if(s.isError)return{type:Mt.MAX_ORDER_DURATION,value:s.value,message:n("maxDurationError",{duration:`${Math.floor(u1(s.value)).toFixed(0)} ${n("days")}`})};if(a.isError)return{type:Mt.MIN_ORDER_DURATION,value:a.value,message:n("minDurationError",{duration:`${Math.floor(Sd(a.value)).toFixed(0)} ${n("minutes")}`})}}},[e,n,t,r])},bm=()=>{const{module:e}=ne(),t=Z(i=>i.state.typedDuration),r=Z(i=>i.updateState),n=$n().totalTrades,s=ua().fillDelay,a=M.useMemo(()=>sh(e,n,s,t),[n,s,t,e]),o=JV(a);return{duration:a,setDuration:M.useCallback(i=>r({typedDuration:i}),[r]),error:o}},eW=()=>{const{module:e}=ne(),t=Ue(),{duration:r,setDuration:n,error:s}=bm(),a=M.useCallback(c=>{n({unit:r.unit,value:Number(c)})},[n,r]),o=M.useCallback(c=>{n({unit:c,value:r.value})},[n,r]),i=M.useMemo(()=>e===ge.STOP_LOSS?t("stopLossDurationTooltip"):t("maxDurationTooltip"),[t,e]);return{duration:r,onChange:n,milliseconds:r.unit*r.value,onInputChange:a,onUnitSelect:o,label:t("expiry"),tooltip:i,error:s}},tW=()=>{const e=Z(a=>a.state.isMarketOrder),{module:t}=ne(),r=Ue(),n=M.useMemo(()=>{if(e&&!(t!==ge.STOP_LOSS&&t!==ge.TAKE_PROFIT))return{text:r("triggerMarketPriceDisclaimer"),url:Fc}},[e,r,t]),s=M.useMemo(()=>{if(!(t!==ge.LIMIT&&t!==ge.TWAP))return{text:r(e?"marketOrderWarning":"limitPriceMessage"),url:"https://www.orbs.com/dtwap-and-dlimit-faq/"}},[e,r,t]);return n||s},Wu=()=>{const{srcToken:e,dstToken:t,marketPriceLoading:r}=ne(),n=Z(l=>l.updateState),s=Z(l=>l.state.isInvertedTrade),a=Z(l=>l.state.typedTriggerPrice),o=Z(l=>l.state.typedLimitPrice),i=Z(l=>l.state.isMarketOrder);return{onInvert:M.useCallback(()=>{a!==void 0&&n({typedTriggerPrice:j(1).div(a).toFixed()}),o!==void 0&&n({typedLimitPrice:j(1).div(o).toFixed()}),n({isInvertedTrade:!s})},[n,s,a,o,r]),isInverted:s,fromToken:s?t:e,toToken:s?e:t,isMarketPrice:i}},r5=({typedValue:e,tokenDecimals:t=18,initialPrice:r="0",percentage:n,setValue:s,setPercentage:a})=>{const{srcUsd1Token:o,dstUsd1Token:i}=ne(),{isInverted:c}=Wu(),l=M.useMemo(()=>{if(e!==void 0){const g=c?j(e).isZero()?j(0):j(1).div(e):j(e);return Pc(t,g.toFixed())}if(n!==void 0&&j(r||"0").gt(0)&&!j(r||"0").isNaN()){const g=j(r||"0"),E=j(n||0).div(100);return g.plus(g.multipliedBy(E)).decimalPlaces(0).toFixed()}return j(r).gt(0)?r:""},[e,n,t,r,c]),u=M.useCallback(g=>{s(g),a(null)},[s,a]),d=M.useCallback(g=>{s(void 0),a(g)},[s,a]),f=M.useMemo(()=>{if(!r||j(r).isZero())return"";if(n!=null)return n;if(l){const g=j(r),v=j(l).minus(g).div(g).multipliedBy(100).decimalPlaces(2).toString();return j(v||"0").isZero()?"":v}return""},[l,r,n]),m=M.useMemo(()=>{let g="";if(e!==void 0)g=e;else{const E=bn(t,l);if(j(E||"0").isZero())return"";g=c?j(1).div(E).toFixed():E}return Do(g,6,t)},[e,t,l,c]),y=aa(c?o:i,m||"0");return{amountWei:j(l).isNaN()?"":l,amountUI:j(m).isNaN()?"":m,selectedPercentage:f,onChange:u,onPercentageChange:d,isInverted:c,usd:j(y).isNaN()?"":y}},rW=()=>{const{module:e}=ne();return M.useMemo(()=>e===ge.STOP_LOSS?Km:Zm,[e])},ym=()=>{const{module:e}=ne(),t=Z(r=>r.state.isMarketOrder);return M.useMemo(()=>e!==ge.STOP_LOSS&&e!==ge.TAKE_PROFIT||t?void 0:e===ge.STOP_LOSS?Xm:Qm,[e,t])},nW=(e="")=>{const{module:t,marketPrice:r}=ne(),n=Ue(),s=Z(a=>a.state.typedSrcAmount);return M.useMemo(()=>{if(j(s||"0").isZero()||!r||t!==ge.STOP_LOSS&&t!==ge.TAKE_PROFIT)return;const a=lh(r||"",e||"",t);if(a!=null&&a.isError)return{type:Mt.STOP_LOSS_TRIGGER_PRICE_GREATER_THAN_MARKET_PRICE,value:a.value,message:n("StopLossTriggerPriceError")||""};const o=uh(r||"",e||"",t);if(o!=null&&o.isError)return{type:Mt.TAKE_PROFIT_TRIGGER_PRICE_LESS_THAN_MARKET_PRICE,value:o.value,message:n("TakeProfitTriggerPriceError")||""};if(!e||j(e||0).isZero())return{type:Mt.EMPTY_TRIGGER_PRICE,value:e,message:n("emptyTriggerPrice")||""}},[r,e,t,n,s])},sW=e=>{const{srcToken:t,dstToken:r,module:n}=ne(),s=$n().amountPerTradeWei,a=Z(i=>i.state.isMarketOrder),o=M.useMemo(()=>nh(n,s,e,(t==null?void 0:t.decimals)||0),[e,s,a,t==null?void 0:t.decimals,n]);return{amountWei:o,amountUI:Vr((r==null?void 0:r.decimals)||0,o)}},da=()=>{const{dstToken:e,marketPrice:t,module:r}=ne(),n=Z(m=>m.updateState),s=rW(),a=Z(m=>m.state.triggerPricePercent),o=M.useCallback(m=>{n({triggerPricePercent:m})},[n]),i=a===void 0?s:a,c=r===ge.STOP_LOSS||r===ge.TAKE_PROFIT,l=r5({typedValue:Z(m=>m.state.typedTriggerPrice),percentage:i,tokenDecimals:e==null?void 0:e.decimals,initialPrice:c?t:void 0,setValue:M.useCallback(m=>n({typedTriggerPrice:m}),[n]),setPercentage:o}),u=nW(l.amountWei),{amountWei:d,amountUI:f}=sW(l.amountWei);return M.useMemo(()=>({...l,error:u,pricePerChunkWei:d,pricePerChunkUI:f}),[l,u,d,f])},aW=()=>{const{module:e,marketPrice:t,marketPriceLoading:r}=ne(),n=Ue(),{amountUI:s,onChange:a,onPercentageChange:o,usd:i,selectedPercentage:c,error:l}=da(),u=Z(w=>w.state.isMarketOrder),d=Z(w=>w.updateState),{isInverted:f,onInvert:m,fromToken:y,toToken:g}=Wu(),E=M.useCallback(()=>{d({triggerPricePercent:void 0,typedTriggerPrice:void 0})},[d]),v=e!==ge.STOP_LOSS&&e!==ge.TAKE_PROFIT;return{price:s,error:l,label:n("stopLossLabel"),tooltip:e===ge.STOP_LOSS?n("stopLossTooltip"):n("takeProfitTooltip"),onChange:a,onPercentageChange:o,percentage:c,isActive:!u,onReset:E,usd:i,fromToken:y,toToken:g,prefix:"",isLoading:r||!t,isInverted:f,hide:v,onInvert:m}},oW=e=>{const{module:t,marketPrice:r}=ne(),n=Ue(),{amountWei:s}=da(),a=Z(i=>i.state.isMarketOrder),o=Z(i=>i.state.typedSrcAmount);return M.useMemo(()=>{if(j(o||"0").isZero()||!s||!r)return;const i=dh(s,e,a,t),c=ph(s,e,a,t);if(i!=null&&i.isError)return{type:Mt.TRIGGER_LIMIT_PRICE_GREATER_THAN_TRIGGER_PRICE,message:n("triggerLimitPriceError")||"",value:i.value};if(c!=null&&c.isError)return{type:Mt.TRIGGER_LIMIT_PRICE_GREATER_THAN_TRIGGER_PRICE,message:n("triggerLimitPriceError")||"",value:c.value};if(e&&j(e||0).isZero())return{type:Mt.MISSING_LIMIT_PRICE,message:n("emptyLimitPrice")||"",value:e||""}},[e,n,s,t,a,o,r])},gc=()=>{const{dstToken:e,marketPrice:t,module:r}=ne(),n=Z(l=>l.updateState),s=ym(),a=Z(l=>l.state.limitPricePercent),o=a===void 0?s:a,i=r5({typedValue:Z(l=>l.state.typedLimitPrice),percentage:o,tokenDecimals:e==null?void 0:e.decimals,initialPrice:t,setValue:M.useCallback(l=>n({typedLimitPrice:l}),[n]),setPercentage:M.useCallback(l=>{n({limitPricePercent:l})},[n,r])}),c=oW(i.amountWei);return M.useMemo(()=>({...i,error:c}),[i,c])},iW=()=>{const{module:e}=ne(),t=Z(i=>i.updateState),r=Z(i=>i.state.isMarketOrder),n=ym(),s=Z(i=>i.state.triggerPricePercent)||0,a=e===ge.LIMIT,o=M.useCallback(()=>{!r&&e===ge.STOP_LOSS&&t({limitPricePercent:n}),t({isMarketOrder:!r})},[t,s,e,r,n]);return{isLimitPrice:!r,toggleLimitPrice:o,hide:a}},cW=()=>{const{module:e,marketPriceLoading:t}=ne(),r=Ue(),{amountUI:n,onChange:s,onPercentageChange:a,usd:o,selectedPercentage:i,error:c}=gc(),l=Z(L=>L.state.isMarketOrder),u=Z(L=>L.updateState),d=ym(),{isLimitPrice:f,toggleLimitPrice:m}=iW(),{triggerPricePercent:y}=Z(L=>L.state),{isInverted:g,onInvert:E,fromToken:v,toToken:w}=Wu(),A=M.useMemo(()=>{if(!(e!==ge.STOP_LOSS&&e!==ge.TAKE_PROFIT||!l))return{text:r("triggerMarketPriceDisclaimer"),url:Fc}},[y,r,e,l]),C=M.useCallback(()=>{u({typedLimitPrice:void 0}),u({limitPricePercent:d})},[u,e,d]),D=M.useMemo(()=>e===ge.STOP_LOSS?r("stopLossLimitPriceTooltip"):r("limitPriceTooltip"),[r,e]);return{price:n,error:c,warning:A,label:r("limitPrice"),tooltip:D,onChange:s,onPercentageChange:a,onReset:C,usd:o,fromToken:v,toToken:w,percentage:i,isInverted:g,isLoading:t,isLimitPrice:f,toggleLimitPrice:m,onInvert:E}},n5=()=>{const{module:e,marketPrice:t}=ne(),r=gc().amountWei,n=da().amountWei,s=Z(a=>a.state.isMarketOrder);return e===ge.LIMIT||!s?r||"":e===ge.STOP_LOSS||e===ge.TAKE_PROFIT?n||"":t||""},xc=()=>{const{srcToken:e,dstToken:t}=ne(),r=n5(),n=un().amountWei,s=M.useMemo(()=>th(n||"",r,(e==null?void 0:e.decimals)||0),[n,r,e==null?void 0:e.decimals]);return{amountWei:s,amountUI:Vr(t==null?void 0:t.decimals,s)}},gm=()=>{const{srcToken:e,dstToken:t,dstUsd1Token:r}=ne(),n=n5(),s=$n().amountPerTradeWei,a=Z(c=>c.state.isMarketOrder),o=M.useMemo(()=>rh(s,n,!!a,(e==null?void 0:e.decimals)||0),[s,n,a,e==null?void 0:e.decimals]),i=Vr(t==null?void 0:t.decimals,o);return{amountWei:o,amountUI:i,usd:aa(i,r)}},s5=()=>{const{srcBalance:e,chainId:t}=ne(),r=Ue(),n=un().amountWei;return M.useMemo(()=>{if(e&&j(n).gt(e))return{type:Mt.INSUFFICIENT_BALANCE,message:r("insufficientFunds"),value:e||""}},[e,n,r,t])};function a5(){const{marketPrice:e,marketPriceLoading:t}=ne(),r=Z(l=>l.state.typedSrcAmount),n=s5(),{error:s}=da(),{error:a}=gc(),{error:o}=$n(),{error:i}=ua(),{error:c}=bm();return M.useMemo(()=>{const l=Fo("ignore-errors");if(!(j(e||0).isZero()||j(r||0).isZero()||t||l))return s||a||o||i||c||n},[e,t,r,s,a,o,i,c,n])}const o5=(e,t)=>{const{marketPriceLoading:r,srcToken:n,dstToken:s,srcBalance:a,dstBalance:o}=ne(),i=Z(C=>C.state.typedSrcAmount),c=Z(C=>C.updateState),{srcUsd1Token:l,dstUsd1Token:u}=ne(),d=aa(i,l),f=aa(t,u),m=CG(),y=e?n:s,g=Vr(y==null?void 0:y.decimals,e?a:o),E=s5(),v=M.useCallback(C=>{e&&c({typedSrcAmount:C})},[c,e]),w=M.useCallback(()=>{e&&c({typedSrcAmount:Do(g,8)})},[c,e,g]),A=m||e?i:Do(t||"",8);return{balance:g,usd:e||m?d:f,value:A||"",valueWei:V2(y==null?void 0:y.decimals,A),onChange:v,onMax:w,isLoading:i?e?!1:r:!1,token:y,isInsufficientBalance:e?E:void 0}},lW=()=>o5(!0),uW=()=>{const e=xc().amountUI,t=Z(r=>r.state.typedSrcAmount);return o5(!1,t?e:"")},dW=()=>{const e=Z(t=>t.updateState);return{amount:Z(t=>t.state.typedSrcAmount)||"",reset:M.useCallback(()=>e({typedSrcAmount:""}),[e])}},pW=()=>{const e=Z(n=>n.state.isMarketOrder),t=Z(n=>n.updateState),r=M.useCallback(()=>{t({isMarketOrder:!e})},[t,e]);return{isMarketPrice:!e,togglePrice:r}},xm=()=>{const e=Z(r=>r.state.currentTime),t=bm().duration;return M.useMemo(()=>ih(e,t),[e,t])},fW=()=>{const{srcUsd1Token:e,dstUsd1Token:t}=ne(),r=un().amountUI,n=xc().amountUI,s=aa(r,e),a=aa(n,t);return{srcAmountUsd:s,dstAmountUsd:a}},mW=()=>{const{fees:e,dstUsd1Token:t}=ne(),{amountUI:r}=xc(),n=M.useMemo(()=>!e||!r?"":j(r).multipliedBy(e).dividedBy(100).toFixed(),[r,e]);return{amount:n,percent:e,usd:aa(n,t)}},i5=()=>{const{srcToken:e,dstToken:t,account:r,chainId:n,slippage:s,config:a}=ne(),{amountWei:o}=un(),{amountWei:i}=gc(),{amountPerTradeWei:c,totalTrades:l}=$n(),u=xm(),{amountWei:d}=gm(),{amountWei:f}=da(),{milliseconds:m}=ua();return M.useMemo(()=>{var y;return{srcToken:e,dstToken:t,limitPrice:i,deadline:u,srcAmount:o,srcAmountPerTrade:c,totalTrades:l,minDestAmountPerTrade:d,tradeInterval:m,triggerPricePerTrade:f,maker:r,rePermitData:xh({chainId:n,srcToken:Is((e==null?void 0:e.address)||"")?((y=Bs(n))==null?void 0:y.wToken.address)||"":(e==null?void 0:e.address)||"",dstToken:(t==null?void 0:t.address)||"",srcAmount:o,deadlineMillis:u,fillDelayMillis:!l||l===1?0:m,slippage:s*100,account:r,srcAmountPerTrade:c,dstMinAmountPerTrade:d,triggerAmountPerTrade:f,config:a})}},[e,t,i,u,o,c,l,d,f,r,m,s,n,a])},c5=()=>{const{srcToken:e,dstToken:t,account:r}=ne(),n=Ue(),{amountUI:s,usd:a}=gm(),{amountPerTradeUI:o,amountPerTradeUsd:i,totalTrades:c}=$n(),{amountUI:l,usd:u}=da(),d=xm(),{amountUI:f,usd:m}=gc(),{amount:y,percent:g,usd:E}=mW(),{milliseconds:v}=ua(),{amountUI:w}=xc(),{srcAmountUsd:A,dstAmountUsd:C}=fW(),D=un().amountUI,L=Z(x=>x.state.isMarketOrder),T=K2({srcToken:e,dstToken:t,account:r,limitPrice:L?void 0:f,limitPriceUsd:L?void 0:m,deadline:d,tradeInterval:v,srcAmount:D,totalTrades:c,srcAmountPerTrade:o,srcAmountPerTradeUsd:i,minDestAmountPerTrade:s,minDestAmountPerTradeUsd:a,triggerPricePerTrade:l,triggerPricePerTradeUsd:u,srcUsd:A,dstUsd:C,dstAmount:w}),h=ze({value:y}),b=ze({value:E});return M.useMemo(()=>({...T,fees:{label:n("fees",{value:`${g}%`}),amount:h,usd:b||"",percentage:g}}),[T,h,b,g])},l5=M.createContext({}),hW=({children:e,...t})=>B.jsx(l5.Provider,{value:t,children:e}),bW=()=>M.useContext(l5),u5=()=>{var s,a;const e=Ue(),{wrapTxHash:t,srcToken:r}=Z(o=>o.state.swapExecution),n=(a=(s=ac())==null?void 0:s.wToken)==null?void 0:a.symbol;return t?B.jsx("p",{className:"twap-error-wrap-msg",children:e("wrapMsg",{symbol:(r==null?void 0:r.symbol)||"",wSymbol:n||""})}):null},yW=(e=!1,t=1)=>{const{module:r}=ne(),n=Ue();return M.useMemo(()=>r===ge.STOP_LOSS?n("stopLoss"):r===ge.TAKE_PROFIT?n("takeProfit"):n(e?"twapMarket":t===1?"limit":"twapLimit"),[n,r,e,t])},gW=({price:e,dstTokenSymbol:t,label:r,usd:n})=>B.jsxs(we.DetailRow,{title:r,children:[`${e||"-"} ${t||""}`,B.jsx(we.USD,{value:n})]}),d5=()=>{const e=Ue(),t=Z(a=>a.state.isMarketOrder),r=Z(a=>a.state.swapExecution.status),{totalTrades:n}=$n(),s=yW(t,n);return r===mt.SUCCESS?e("createOrderActionSuccess",{name:s}):e("createOrderAction",{name:s})},xW=()=>{const e=Z(y=>y.state.swapExecution.srcToken),t=Ue(),{step:r,wrapTxHash:n,approveTxHash:s}=Z(y=>y.state.swapExecution),a=ac(),o=R0(n),i=R0(n),c=R0(s),l=Z(y=>y.state.swapExecution.status),d=Is((e==null?void 0:e.address)||"")?(a==null?void 0:a.native.symbol)||"":(e==null?void 0:e.symbol)||"",f=a==null?void 0:a.wToken.symbol,m=d5();return M.useMemo(()=>r===Ds.WRAP?{title:t("wrapAction",{symbol:d}),footerLink:o,footerText:t(o?"viewOnExplorer":"proceedInWallet")}:r===Ds.APPROVE?{title:t("approveAction",{symbol:d}),footerLink:c,footerText:t(c?"viewOnExplorer":"proceedInWallet")}:{title:m,footerText:l===mt.LOADING?t("proceedInWallet"):void 0},[r,c,d,m,t,o,i,f,l])},wW=({error:e})=>B.jsxs("div",{className:"twap-error",children:[B.jsx("h2",{className:"twap-error-title",children:"Transaction failed"}),(e==null?void 0:e.code)&&B.jsxs("p",{className:"twap-error-code",children:["Error code: ",e==null?void 0:e.code]}),B.jsx(u5,{})]});function vW({error:e}){const{components:t}=ne(),r=Ue(),n=Z(o=>{var i;return(i=o.state.swapExecution)==null?void 0:i.wrapTxHash}),s=t.SubmitOrderErrorView,a=B.jsx(Qn.Failed,{error:B.jsx(wW,{error:e}),footerLink:Fc,footerText:r("viewOnExplorer")});return s?B.jsx(s,{wrapTxHash:n,error:e,children:a}):a}const EW=()=>{const{components:e}=ne(),t=Z(u=>u.state.swapExecution.srcToken),r=Z(u=>u.state.swapExecution.dstToken),{reviewDetails:n}=bW(),s=Ue(),a=Z(u=>{var d;return!!((d=u.state.swapExecution)!=null&&d.status)}),o=c5(),i=e.USD,c=e.SubmitOrderMainView,l=B.jsxs(B.Fragment,{children:[B.jsx(Qn.Main,{fromTitle:s("from"),toTitle:s("to"),inUsd:i?B.jsx(i,{value:o.srcUsd,isLoading:!1}):`$${o.srcUsd}`,outUsd:i?B.jsx(i,{value:o.dstUsd,isLoading:!1}):`$${o.dstUsd}`}),!a&&B.jsxs("div",{className:"twap-create-order-bottom",children:[B.jsx(we.Container,{children:B.jsxs("div",{className:"twap-create-order-details",children:[B.jsx(we.Deadline,{deadline:o.deadline.value,label:o.deadline.label,tooltip:o.deadline.tooltip||""}),B.jsx(we.TriggerPrice,{price:o.triggerPricePerTrade.value,dstToken:r,label:o.triggerPricePerTrade.label,tooltip:o.triggerPricePerTrade.tooltip||"",usd:o.triggerPricePerTrade.usd}),B.jsx(gW,{price:o.limitPrice.value,dstTokenSymbol:r==null?void 0:r.symbol,label:o.limitPrice.label,usd:o.limitPrice.usd}),B.jsx(we.MinDestAmount,{dstToken:r,dstMinAmountOut:o.minDestAmountPerTrade.value,label:o.minDestAmountPerTrade.label,tooltip:o.minDestAmountPerTrade.tooltip||"",usd:o.minDestAmountPerTrade.usd}),B.jsx(we.TradeSize,{tradeSize:o.sizePerTrade.value,trades:o.totalTrades.value,srcToken:t,label:o.sizePerTrade.label,tooltip:o.sizePerTrade.tooltip}),B.jsx(we.TradesAmount,{trades:o.totalTrades.value,label:o.totalTrades.label,tooltip:o.totalTrades.tooltip}),B.jsx(we.TradeInterval,{chunks:o.totalTrades.value,fillDelayMillis:o.tradeInterval.value,label:o.tradeInterval.label,tooltip:o.tradeInterval.tooltip}),B.jsx(we.Recipient,{}),o.fees.amount&&B.jsx(we.Fees,{fees:o.fees.amount,label:o.fees.label,usd:o.fees.usd,dstTokenSymbol:r==null?void 0:r.symbol})]})}),n]})]});return c?B.jsx(c,{children:l}):l},kW=e=>{const{status:t,stepIndex:r,totalSteps:n,error:s}=Z(w=>w.state.swapExecution),{components:a}=ne(),o=a.Spinner,i=a.SuccessIcon,c=a.ErrorIcon,l=a.TokenLogo,{srcToken:u,dstToken:d}=ne(),f=un().amountUI,m=xc().amountUI,y=ze({value:f,decimalScale:2}),g=ze({value:m,decimalScale:2}),E=M.useMemo(()=>({symbol:u==null?void 0:u.symbol,logoUrl:u==null?void 0:u.logoUrl}),[u]),v=M.useMemo(()=>({symbol:d==null?void 0:d.symbol,logoUrl:d==null?void 0:d.logoUrl}),[d]);return B.jsx(hW,{...e,children:B.jsx(Qn,{inAmount:y,outAmount:g,swapStatus:t,totalSteps:n,currentStep:xW(),currentStepIndex:r,inToken:E,outToken:v,components:{SrcTokenLogo:l&&B.jsx(l,{token:u}),DstTokenLogo:l&&B.jsx(l,{token:d}),Failed:B.jsx(vW,{error:s}),Success:B.jsx(CW,{}),Main:B.jsx(EW,{}),Loader:o,SuccessIcon:i,FailedIcon:c}})})},CW=()=>{const e=d5(),{components:t}=ne(),r=Z(a=>a.state.swapExecution.orderId),n=t.SubmitOrderSuccessView,s=B.jsxs(B.Fragment,{children:[B.jsx(Qn.Success,{title:e}),B.jsx(u5,{})]});return n?B.jsx(n,{newOrderId:r,children:s}):s},TW=()=>{const{supportedChains:e}=ne();return M.useMemo(()=>e,[e])},SW=()=>{const{config:e}=ne();return M.useMemo(()=>({spender:e.repermit}),[e])},AW=()=>{var c;const{account:e,walletClient:t,overrides:r,refetchBalances:n,callbacks:s,chainId:a}=ne(),o=(c=ac())==null?void 0:c.wToken,i=$0();return gn({mutationFn:async({onHash:l,srcAmountWei:u})=>{var m,y;if(!e)throw new Error("missing account");if(!t)throw new Error("missing walletClient");if(!o)throw new Error("tokenAddress is not defined");let d;dt.onWrapRequest(),(m=s==null?void 0:s.onWrapRequest)==null||m.call(s),r!=null&&r.wrap?d=await r.wrap(BigInt(u)):d=await t.writeContract({abi:Um,functionName:"deposit",account:e,address:o.address,value:BigInt(u),chain:t.chain}),l==null||l(d);const f=await i(d);if(!f)throw new Error("failed to get transaction receipt");if(f.status==="reverted")throw new Error("failed to wrap token");return dt.onWrapSuccess(d),(y=s==null?void 0:s.onWrapSuccess)==null||y.call(s,{txHash:f.transactionHash,explorerUrl:_o(f.transactionHash,a),amount:bn(o.decimals,u)}),n==null||n(),f},onError:l=>{throw dt.onWrapError(l),l}})},PW=()=>{const{account:e,walletClient:t,chainId:r,callbacks:n}=ne(),s=i5().rePermitData,a=HG();return gn({mutationFn:async()=>{var y,g,E,v;if(!e)throw new Error("missing account");if(!t)throw new Error("missing walletClient");if(!r)throw new Error("missing chainId");const{order:o,domain:i,types:c,primaryType:l}=s;dt.onSignOrderRequest(o),(y=n==null?void 0:n.onSignOrderRequest)==null||y.call(n),console.log({domain:i,types:c,primaryType:l,message:o,account:e}),console.log("Using domain:",i),console.log("Using types:",c),console.log("Order data to sign:",JSON.stringify(o,null,2)),console.log(`Account address: ${e}`);let u;try{u=await(t==null?void 0:t.signTypedData({domain:i,types:c,primaryType:l,message:o,account:e}))}catch(w){throw(g=n==null?void 0:n.onSignOrderError)==null||g.call(n,w),dt.onSignOrderError(w),w}dt.onSignOrderSuccess(u),(E=n==null?void 0:n.onSignOrderSuccess)==null||E.call(n,u);const d=zL(u),f={v:q(d.v||0),r:d.r,s:d.s},m=await Ch(o,f);return(v=n==null?void 0:n.onOrderCreated)==null||v.call(n,m),a(m),m}})},p5=()=>{const{account:e,publicClient:t,config:r}=ne();return gn({mutationFn:async({tokenAddress:n,srcAmountWei:s})=>{if(!t)throw new Error("missing publicClient");if(!e)throw new Error("missing account");if(!r)throw new Error("missing config");console.log(r.repermit,"repermit");const a=await t.readContract({address:n,abi:xg,functionName:"allowance",args:[e,r.repermit]}).then(i=>i.toString()),o=j(a||"0").lt(j(s).toString());return{allowance:a,approvalRequired:o}}})},IW=()=>{const{account:e,walletClient:t,overrides:r,config:n,chainId:s,callbacks:a}=ne(),o=$0(),{mutateAsync:i}=p5();return gn({onError:c=>{dt.onApproveError(c)},mutationFn:async({token:c,onHash:l,srcAmountWei:u})=>{var y,g;if(!e)throw new Error("missing account");if(!t)throw new Error("missing walletClient");if(!n)throw new Error("missing config");(y=a==null?void 0:a.onApproveRequest)==null||y.call(a),dt.onApproveRequest();let d;if(r!=null&&r.approveOrder?d=await r.approveOrder({tokenAddress:c.address,spenderAddress:n.repermit,amount:Ls}):d=await t.writeContract({abi:xg,functionName:"approve",account:e,address:c.address,args:[n.repermit,Ls],chain:t.chain}),!d)throw new Error("failed to approve token");l(d);const f=await o(d);if(!f)throw new Error("failed to get transaction receipt");if(f.status==="reverted")throw new Error("failed to approve token");let m=!1;for(let E=0;E<3;E++){const{approvalRequired:v}=await i({tokenAddress:c.address,srcAmountWei:u});if(!v){m=!0;break}E<2&&await new Promise(w=>setTimeout(w,3e3))}if(!m)throw new Error(`Insufficient ${c.symbol} allowance to perform the swap. Please approve the token first.`);return dt.onApproveSuccess(f.transactionHash),(g=a==null?void 0:a.onApproveSuccess)==null||g.call(a,{txHash:f.transactionHash,explorerUrl:_o(f.transactionHash,s),token:c,amount:bn(c.decimals,u)}),f}})},BW=()=>{const{account:e,chainId:t,srcToken:r,dstToken:n,module:s,slippage:a}=ne(),o=da(),i=un().amountWei,c=$n().amountPerTradeWei,l=xm(),u=ua().fillDelay,d=gm().amountWei,f=Z(m=>m.state.isMarketOrder);return gn({mutationFn:async()=>{dt.onRequestOrder({account:e,chainId:t,module:s,srcToken:r,dstToken:n,fromTokenAmount:i,srcChunkAmount:c,triggerPricePerTrade:o.pricePerChunkWei,deadline:l,fillDelay:u.unit*u.value,minDstAmountOutPerTrade:d,slippage:a,isMarketOrder:f||!1})}})};function FW(e){const t=e.message,r=t.match(/,\s*code\s*:\s*(\d+)/i);return{message:t.replace(/^error\s*:/i,"").replace(/,\s*code\s*:\s*\d+/i,"").trim()||"",code:r?Number(r[1]):0,error:e}}const UW=()=>{const{srcToken:e,dstToken:t,chainId:r,callbacks:n}=ne(),s=IW().mutateAsync,a=AW().mutateAsync,o=PW().mutateAsync,{mutateAsync:i}=p5(),c=Z(d=>d.updateSwapExecution),{amountWei:l}=un(),u=BW().mutate;return gn({mutationFn:async()=>{var f,m;const d=Is((e==null?void 0:e.address)||" ");try{if(!e)throw new Error("missing srcToken");if(!t)throw new Error("missing dstToken");if(!r)throw new Error("missing chainId");const y=l1(e,r);c({allowanceLoading:!0});const{approvalRequired:g}=await i({tokenAddress:y.address,srcAmountWei:l});let E=0,v=1;d&&v++,g&&v++,c({totalSteps:v,stepIndex:E,allowanceLoading:!1,status:mt.LOADING}),u(),d&&(c({step:Ds.WRAP}),await a({onHash:A=>c({wrapTxHash:A}),srcAmountWei:l}),E++,c({stepIndex:E})),g&&(c({step:Ds.APPROVE}),await s({token:y,onHash:A=>c({approveTxHash:A}),srcAmountWei:l}),E++,c({stepIndex:E})),c({step:Ds.CREATE});const w=await o();return c({status:mt.SUCCESS,orderId:w.id}),w}catch(y){if(Td(y))(f=n==null?void 0:n.onSubmitOrderRejected)==null||f.call(n),c({step:void 0,status:void 0,stepIndex:void 0});else{const g=FW(y);(m=n==null?void 0:n.onSubmitOrderFailed)==null||m.call(n,g),c({status:mt.FAILED,error:g})}}}})},OW=()=>{const{marketPrice:e,srcToken:t,dstToken:r}=ne(),n=UW(),s=Z(f=>f.updateState),{amountUI:a}=un(),o=Z(f=>f.resetState),i=Z(f=>f.state.swapExecution),c=M.useCallback(()=>{(i==null?void 0:i.status)===mt.SUCCESS&&(s({typedSrcAmount:""}),setTimeout(()=>{o()},1e3))},[i==null?void 0:i.status,o,s]),l=M.useCallback(()=>{(i==null?void 0:i.status)!==mt.LOADING&&s({acceptedSrcAmount:void 0,acceptedMarketPrice:void 0,swapExecution:{srcToken:t,dstToken:r}})},[s,t,r]),u=gn({mutationFn:async()=>(s({acceptedSrcAmount:a,acceptedMarketPrice:e}),await n.mutateAsync())}),d=M.useCallback(()=>u.mutateAsync(),[u]);return M.useMemo(()=>({reset:o,onCloseModal:c,onOpenModal:l,onSubmit:d,...i,isLoading:!!((i==null?void 0:i.status)===mt.LOADING||i!=null&&i.allowanceLoading),isSuccess:(i==null?void 0:i.status)===mt.SUCCESS,isFailed:(i==null?void 0:i.status)===mt.FAILED}),[o,c,d,i])},DW=()=>{const e=Ue(),{marketPrice:t,srcToken:r,dstToken:n,marketPriceLoading:s,srcBalance:a,srcUsd1Token:o,noLiquidity:i}=ne(),c=s||j(o||"0").isZero()||a===void 0||j(t||"0").isZero(),l=Z(y=>y.state.typedSrcAmount),u=!!(r&&n&&l&&c),d=a5(),f=M.useMemo(()=>i?e("noLiquidity"):j(l||"0").isZero()?e("enterAmount"):(d==null?void 0:d.type)===Mt.INSUFFICIENT_BALANCE?e("insufficientFunds"):e("placeOrder"),[d,e,l,i]),m=!!(d||i||u||j(l||"0").isZero()||!r||!n);return M.useMemo(()=>({disabled:m,text:f,loading:u}),[m,f,u])};vh(Aw.version);const _W={SubmitOrderPanel:kW,Orders:YV};R.CRASH_ERROR_MESSAGE=ew,R.Components=_W,R.Configs=Dt,R.DEFAULT_DURATION_OPTIONS=ZL,R.DEFAULT_FILL_DELAY=Bc,R.DEFAULT_STOP_LOSS_LIMIT_PERCENTAGE=Xm,R.DEFAULT_STOP_LOSS_PERCENTAGE=Km,R.DEFAULT_TAKE_PROFIT_LIMIT_PERCENTAGE=Qm,R.DEFAULT_TAKE_PROFIT_PERCENTAGE=Zm,R.DISCLAIMER_URL=J5,R.EIP712_TYPES=Ym,R.ERC20_ABI=M5,R.EXCLUSIVITY_OVERRIDE_BPS=Y5,R.FEES=q5,R.IWETH_ABI=Um,R.InputErrors=Mt,R.LEGACY_EXCHANGES_MAP=Wm,R.MAX_ORDER_DURATION_MILLIS=Ca,R.MIN_CHUNKS=V5,R.MIN_FILL_DELAY_MILLIS=Ic,R.MIN_FILL_DELAY_MINUTES=Hm,R.MIN_ORDER_DURATION_MILLIS=ad,R.Module=ge,R.ORBS_LOGO=Z5,R.ORBS_LOGO_FALLBACK=X5,R.ORBS_SLTP_FAQ_URL=K5,R.ORBS_TWAP_FAQ_URL=Fc,R.ORBS_WEBSITE_URL=Q5,R.OrderStatus=lt,R.OrderType=ut,R.PRICE_PROTECTION_SETTINGS=XL,R.Partners=_m,R.QUERY_PARAMS=Uc,R.REPERMIT_ABI=Om,R.REPERMIT_PRIMARY_TYPE=qm,R.SUGGEST_CHUNK_VALUE=j5,R.SpotProvider=YL,R.Steps=Ds,R.SwapStatus=mt,R.THE_GRAPH_ORDERS_API=Gm,R.TWAP_ABI=Dm,R.TimeUnit=Gt,R.amountBN=Pc,R.amountUi=bn,R.analytics=dt,R.buildRePermitOrderData=xh,R.copy=D3,R.ensureWrappedToken=l1,R.eqIgnoreCase=Ps,R.fillDelayText=o1,R.formatDecimals=Do,R.getAccountOrders=Ph,R.getApiEndpoint=sd,R.getChunks=ah,R.getConfig=cd,R.getDeadline=ih,R.getDestTokenAmount=th,R.getDestTokenMinAmountPerChunk=rh,R.getDuration=sh,R.getEstimatedDelayBetweenChunksMillis=id,R.getExplorerUrl=_o,R.getMaxChunksError=yh,R.getMaxFillDelayError=ow,R.getMaxOrderDurationError=fh,R.getMaxPossibleChunks=oh,R.getMinFillDelayError=hh,R.getMinNativeBalance=M3,R.getMinOrderDurationError=mh,R.getMinTradeSizeError=bh,R.getMinimumDelayMinutes=aw,R.getNetwork=Bs,R.getOrderExcecutionRate=i1,R.getOrderFillDelayMillis=td,R.getOrderLimitPriceRate=c1,R.getOrderType=N3,R.getPartnerChains=zm,R.getPartnerIdentifier=_t,R.getPartners=gh,R.getQueryParam=Fo,R.getSrcTokenChunkAmount=ch,R.getStopLossLimitPriceError=dh,R.getStopLossPriceError=lh,R.getTakeProfitLimitPriceError=ph,R.getTakeProfitPriceError=uh,R.getTriggerPricePerChunk=nh,R.isNativeAddress=Is,R.isTxRejected=Td,R.makeElipsisAddress=Cd,R.maxUint256=W5,R.millisToDays=u1,R.millisToMinutes=Sd,R.nativeTokenAddresses=Vm,R.networks=Ft,R.parseError=_3,R.removeCommas=O3,R.setApiMode=G5,R.setUIVersion=vh,R.shouldUnwrapOnly=Pd,R.shouldWrapOnly=Ad,R.submitOrder=Ch,R.useAddresses=SW,R.useDisclaimerPanel=tW,R.useDstTokenPanel=uW,R.useDurationPanel=eW,R.useFillDelayPanel=ZV,R.useFormatNumber=ze,R.useInputErrors=a5,R.useInvertTradePanel=Wu,R.useLimitPricePanel=cW,R.useOrder=i5,R.useOrderHistoryPanel=WG,R.useOrderInfo=c5,R.usePartnerChains=TW,R.useSrcTokenPanel=lW,R.useSubmitOrderButton=DW,R.useSubmitOrderPanel=OW,R.useTogglePricePanel=pW,R.useTradesPanel=QV,R.useTranslations=Ue,R.useTriggerPricePanel=aW,R.useTypedSrcAmount=dW,R.zeroAddress=jm,Object.defineProperty(R,Symbol.toStringTag,{value:"Module"})}));
126
+ `),a=!1),Object.assign(Object.assign({},e),{allowNegative:a})}function vG(e){e=wG(e),e.decimalSeparator,e.allowedDecimalSeparators,e.thousandsGroupStyle;var t=e.suffix,r=e.allowNegative,n=e.allowLeadingZeros,s=e.onKeyDown;s===void 0&&(s=L0);var a=e.onBlur;a===void 0&&(a=L0);var o=e.thousandSeparator,i=e.decimalScale,c=e.fixedDecimalScale,l=e.prefix;l===void 0&&(l="");var u=e.defaultValue,d=e.value,f=e.valueIsNumericString,m=e.onValueChange,y=aG(e,["decimalSeparator","allowedDecimalSeparators","thousandsGroupStyle","suffix","allowNegative","allowLeadingZeros","onKeyDown","onBlur","thousandSeparator","decimalScale","fixedDecimalScale","prefix","defaultValue","value","valueIsNumericString","onValueChange"]),g=Uu(e),E=g.decimalSeparator,v=g.allowedDecimalSeparators,w=function(P){return j2(P,e)},A=function(P,O){return gG(P,O,e)},C=fo(d)?u:d,D=f??yG(C,l,t);fo(d)?fo(u)||(D=D||typeof u=="number"):D=D||typeof d=="number";var L=function(P){return L2(P)?P:(typeof P=="number"&&(P=$2(P)),D&&typeof i=="number"?G2(P,i,!!c):P)},T=mG(L(d),L(u),!!D,w,A,m),h=T[0],b=h.numAsString,x=h.formattedValue,S=T[1],I=function(P){var O=P.target,U=P.key,z=O.selectionStart,H=O.selectionEnd,G=O.value;if(G===void 0&&(G=""),(U==="Backspace"||U==="Delete")&&H<l.length){P.preventDefault();return}if(z!==H){s(P);return}U==="Backspace"&&G[0]==="-"&&z===l.length+1&&r&&sc(O,1),i&&c&&(U==="Backspace"&&G[z-1]===E?(sc(O,z-1),P.preventDefault()):U==="Delete"&&G[z]===E&&P.preventDefault()),v!=null&&v.includes(U)&&G[z]===E&&sc(O,z+1);var J=o===!0?",":o;U==="Backspace"&&G[z-1]===J&&sc(O,z-1),U==="Delete"&&G[z]===J&&sc(O,z+1),s(P)},F=function(P){var O=b;if(O.match(/\d/g)||(O=""),n||(O=dG(O)),c&&i&&(O=G2(O,i,c)),O!==b){var U=j2(O,e);S({formattedValue:U,value:O,floatValue:parseFloat(O)},{event:P,source:N0.event})}a(P)},_=function(P){return P===E?!0:N2(P)},k=function(P){var O=P.currentValue,U=P.lastValue,z=P.formattedValue,H=P.currentValueIndex,G=P.formattedValueIndex,J=O[H],pe=z[G],he=pG(U,O),ie=he.to,de=function(Be){return A(Be).indexOf(".")+l.length};return d===0&&c&&i&&O[ie.start]===E&&de(O)<H&&de(z)>G?!1:H>=ie.start&&H<ie.end&&v&&v.includes(J)&&pe===E?!0:J===pe};return Object.assign(Object.assign({},y),{value:x,valueIsNumericString:!1,isValidInputCharacter:_,isCharacterSame:k,onValueChange:S,format:w,removeFormatting:A,getCaretBoundary:function(P){return xG(P,e)},onKeyDown:I,onBlur:F})}const V2=(e,t)=>M.useMemo(()=>Pc(e,t),[e,t]),Vr=(e,t)=>M.useMemo(()=>bn(e,t),[e,t]),ac=()=>{const{chainId:e}=ne();return M.useMemo(()=>Bs(e),[e])},R0=e=>{const t=ac();return M.useMemo(()=>{if(!(!e||!t))return _o(e,t.id)},[e,t])},aa=(e,t)=>M.useMemo(()=>!e||!t||j(e||"0").isZero()||j(t||"0").isZero()?"":j(e||"0").times(t).toFixed(),[e,t]),EG=()=>{const{srcToken:e,dstToken:t,chainId:r}=ne();return M.useMemo(()=>Ad(e,t,r),[e,t,r])},kG=()=>{const{srcToken:e,dstToken:t,chainId:r}=ne();return M.useMemo(()=>Pd(e,t,r),[e,t,r])},CG=()=>{const e=EG(),t=kG();return e||t},H0=e=>{const{overrides:t}=ne();return M.useMemo(()=>t!=null&&t.dateFormat?t.dateFormat(e||0):te(e).format("DD/MM/YYYY HH:mm"),[e,t==null?void 0:t.dateFormat])};function TG(){const{callbacks:e}=ne();return M.useCallback(async t=>{var r;try{await navigator.clipboard.writeText(t),(r=e==null?void 0:e.onCopy)==null||r.call(e)}catch(n){console.error("Copy failed:",n)}},[e==null?void 0:e.onCopy])}const SG=(e,t)=>M.useMemo(()=>Do(e==null?void 0:e.toString(),t),[e,t]),ze=({value:e,decimalScale:t=3,prefix:r,suffix:n})=>{var c;const s=SG(e,t),{overrides:a}=ne(),o=a==null?void 0:a.numberFormat,i=vG({allowLeadingZeros:!0,thousandSeparator:",",displayType:"text",value:s||"",decimalScale:18,prefix:r,suffix:n});return o?o(e||""):(c=i.value)==null?void 0:c.toString()},AG={expirationTooltip:"This is the date and time marking the end of the period which you have selected for your order to be executed.",tradeSizeTooltip:"The number of input tokens that will be removed from your balance and swapped for the output token in each individual trade.",totalTradesTooltip:"The total number of individual trades that will be scheduled as part of your order. Note that in limit orders, not all trades that are scheduled will be executed.",minDstAmountTooltip:" This is the minimum number of tokens that may be received. NOTE: This minimum only refers to executed trades. Some trades may not be executed if the limit price is higher than the available market prices and your order may only be partially filled.",limitPriceTooltip:"Trades will only execute if the available market price is better than the limit price, potentially resulting in partial fills or orders remaining unfilled upon expiration.",maxDurationTooltip:"This is the time period during which the order will be active. Please note that orders may be completed earlier than this time, partially filled, or remain unfilled based on the specified parameters.",tradeIntervalTootlip:"The estimated time that will elapse between each trade in your order. Note that as this time includes an allowance of two minutes for bidder auction and block settlement, which cannot be predicted exactly, actual time may vary.",triggerPriceTooltip:"The price at which the order will be executed. If the market price is higher than the trigger price, the order will be executed at the market price.",placeOrder:"Place order",enterAmount:"Enter an amount",emptyLimitPrice:"Limit price is required",insufficientFunds:"Insufficient Balance",tradeIntervalLabel:"Trade interval",expirationLabel:"Expiration",limitPrice:"Limit Price",finalExcecutionPrice:"Final execution price",marketPrice:"Market price",from:"From",to:"To (estimated)",Open:"Open",Completed:"Completed",Expired:"Expired",Canceled:"Canceled",minReceivedPerTrade:"Min. received per trade",triggerPricePerChunk:"Trigger Price per trade",maxChunksError:"Max. trades amount is {maxChunks}",minChunksError:"Min. trades amount is {minChunks}",minTradeSizeError:"Min. trade size is ${minTradeSize}",allOrders:"All",minFillDelayError:"Min. trade interval is {fillDelay}",maxFillDelayError:"Max. trade interval is {fillDelay}",recipient:"Recipient",marketOrderWarning:"Each individual trade in this order will be filled at the current market price at the time of execution.",limitPriceMessage:"Limit orders may not execute when the token's price is equal or close to the limit price, due to gas and standard swap fees.",limit:"Limit",maxDurationError:"Max. expiry is {duration}",minDurationError:"Min. expiry is {duration}",expiry:"Expiry",individualTradeSize:"Individual trade size",numberOfTrades:"No. of trades",averageExecutionPrice:"Avg. execution price",twapMarket:"TWAP-market",twapLimit:"TWAP-limit",stopLoss:"Stop-loss",triggerPriceMarket:"Trigger Market Price ",triggerPriceLimit:"Trigger Limit Price ",takeProfit:"Take-profit",minReceived:"Min. received",noOrders:"No {status} Orders",noLiquidity:"No liquidity for this pair",excecutionSummary:"Execution summary",orderInfo:"Order info",wrapAction:"Wrap {symbol}",approveAction:"Approve {symbol}",createOrderAction:"Create {name} order",amountReceived:"Amount received",createdAt:"Created at",amountOut:"Amount out",status:"Status",progress:"Progress",minutes:"minutes",days:"days",tradeIntervalTitle:"Every",tradesAmountTitle:"Over",stopLossTooltip:"The trigger price at which your stop-loss order will be activated.",takeProfitTooltip:"The trigger price at which your take-profit order will be activated.",stopLossLabel:"Trigger Price",StopLossTriggerPriceError:"Trigger price must be less than market price",TakeProfitTriggerPriceError:"Trigger price must be greater than market price",triggerLimitPriceError:"Limit price must be less than trigger price",triggerPrice:"Trigger Price",tradePrice:"Trade Price",triggerMarketPriceDisclaimer:" In extreme market movements, slippage may occur and the executed price of the market order may be worse than the specified trigger price.",stopLossLimitPriceTooltip:"The stop loss order will execute at the specified limit price or better, once the stop price is triggered.",stopLossDurationTooltip:"This is the time period during which the order will be active. Please note that orders may be completed earlier than this time, or remain unfilled based on the specified parameters.",emptyTriggerPrice:"Trigger price is required",id:"ID",fees:"Fees {value}",version:"Version",maxOrderSizeError:"Max. trade size is {maxOrderSize} USD",viewOnExplorer:"View on explorer",proceedInWallet:"Proceed in wallet",wrapMsg:"Note: {symbol} was wrapped to {wSymbol}",createOrderActionSuccess:"{name} order placed"};function PG(e){let t=e;const r=/\{[^{}]*\}/g;for(;r.test(t);)t=t.replace(r,"");return t}const Ue=()=>{const e=ne();return M.useCallback((r,n)=>{var o,i;const s=(o=e.getTranslation)==null?void 0:o.call(e,r,n);if(s&&s!==r)return s;const a=((i=e.translations)==null?void 0:i[r])||AG[r];return PG(a.replace(/{(\w+)}/g,(c,l)=>(n==null?void 0:n[l])||c))},[e.getTranslation,e.translations])},Ou=({value:e})=>{const t=ze({value:e,decimalScale:2});return t?B.jsx("small",{className:"twap-order-details__detail-row-value-usd",children:` ($${t})`}):null},IG=({deadline:e,label:t,tooltip:r})=>{const n=H0(e);return B.jsx(hr,{title:t,tooltip:r,children:n})},BG=({price:e,dstToken:t,label:r,tooltip:n,usd:s})=>{const a=ze({value:e});return j(e||0).isZero()?null:B.jsx(hr,{title:r,tooltip:n,children:B.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[`${a||"-"} ${t==null?void 0:t.symbol}`,B.jsx(Ou,{value:s})]})})},FG=({price:e,dstToken:t,percentage:r,isMarketOrder:n})=>{const s=ze({value:e}),a=Ue();return n?null:B.jsx(hr,{title:a("limitPrice")||"",tooltip:a("limitPriceTooltip")||"",children:B.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[`${s||"-"} ${t==null?void 0:t.symbol}`,r&&B.jsx("small",{children:`(${r}%)`})]})})},UG=({tradeSize:e,srcToken:t,trades:r,label:n,tooltip:s})=>r===1?null:B.jsx(hr,{title:n,tooltip:s,children:`${e||"-"} ${(t==null?void 0:t.symbol)||""}`}),OG=({dstToken:e,dstMinAmountOut:t,label:r,tooltip:n,usd:s})=>{const a=ze({value:t});return j(t||0).isZero()?null:B.jsxs(hr,{title:r,tooltip:n,children:[`${t?a:"-"} ${e==null?void 0:e.symbol}`,B.jsx(Ou,{value:s})]})},DG=({trades:e,label:t,tooltip:r})=>e===1?null:B.jsx(hr,{title:t,tooltip:r,children:e}),_G=()=>{var s;const e=Ue(),{account:t}=ne(),r=(s=ac())==null?void 0:s.explorer,n=Cd(t);return B.jsx(hr,{title:e("recipient")||"",children:r?B.jsx("a",{href:`${r}/address/${t}`,target:"_blank",children:n}):n})},MG=({fillDelayMillis:e,chunks:t=0,label:r,tooltip:n})=>{const s=M.useMemo(()=>o1(e),[e]);return t===1?null:B.jsx(hr,{title:r,tooltip:n,children:s})},hr=({title:e,tooltip:t,children:r,className:n="",onClick:s,style:a})=>{const{components:o}=ne(),i=o.Tooltip;return B.jsxs("div",{className:`${n} twap-order-details__detail-row`,onClick:s,style:a,children:[B.jsxs("div",{className:"twap-order-details__detail-row-label",children:[B.jsx("p",{className:"twap-order-details__detail-row-label-value",children:e}),t&&i&&B.jsx(i,{tooltipText:t})]}),B.jsx("div",{className:"twap-order-details__detail-row-value",children:r})]})},NG=({id:e})=>{const{components:t}=ne(),r=t==null?void 0:t.Tooltip,n=TG();return e.startsWith("0x")?B.jsx(hr,{title:"ID",onClick:()=>n(e),style:{cursor:"pointer"},children:r&&B.jsx(r,{tooltipText:e,children:B.jsxs("div",{className:"twap-order-details__detail-row-value-id",children:[B.jsx("p",{children:Cd(e)}),B.jsx(sz.AiOutlineCopy,{})]})})}):B.jsx(hr,{title:"ID",children:e})},LG=({version:e})=>B.jsx(hr,{title:"Version",children:e});function we({children:e,className:t=""}){return B.jsx("div",{className:`${t} twap-order-details`,children:e})}const zG=({children:e})=>e,RG=({fees:e,label:t,usd:r,dstTokenSymbol:n})=>{const s=ze({value:e});return B.jsxs(hr,{title:t,children:[`${e?s:"-"} ${n}`,B.jsx(Ou,{value:r})]})};we.Deadline=IG,we.Fees=RG,we.TradeSize=UG,we.MinDestAmount=OG,we.TradesAmount=DG,we.Recipient=_G,we.TradeInterval=MG,we.DetailRow=hr,we.TriggerPrice=BG,we.LimitPrice=FG,we.OrderID=NG,we.Container=zG,we.OrderVersion=LG,we.USD=Ou;const $0=()=>{const{publicClient:e}=ne();return gn({mutationFn:async t=>{if(!e)throw new Error("publicClient is not defined");const r=10;let n=0,s=1e3;for(;n<r;)try{return await e.waitForTransactionReceipt({hash:t,confirmations:2,retryDelay:s})}catch(a){if(n++,n>=r)throw new Error(`Failed after ${r} attempts: ${a}`);await new Promise(o=>setTimeout(o,s)),s*=2}}}).mutateAsync},G0=()=>{const{account:e,walletClient:t,publicClient:r,config:n,callbacks:s,chainId:a}=ne(),o=$0(),i=Z(u=>u.updateState),c=async u=>{dt.onCancelOrderRequest(u.map(d=>d.id.toString()),1);try{return(await Promise.all(u.map(f=>t.writeContract({account:e,address:f.twapAddress,abi:Dm,functionName:"cancel",args:[f.id],chain:t.chain}))))[0]}catch(d){throw dt.onCancelOrderError(d),d}},l=async u=>{var d;try{dt.onCancelOrderRequest(u.map(y=>y.hash),2);const f=await t.writeContract({account:e,address:n.repermit,abi:Om,functionName:"cancel",args:[u.map(y=>y.hash)],chain:t.chain}),m=await o(f);if(!m)throw new Error("failed to get transaction receipt");if(m.status==="reverted")throw new Error("failed to cancel order");return dt.onCancelOrderSuccess(f),(d=s==null?void 0:s.onCancelOrderSuccess)==null||d.call(s,{orders:u,txHash:f,explorerUrl:_o(f,a)}),m.transactionHash}catch(f){throw dt.onCancelOrderError(f),f}};return gn({mutationFn:async({orders:u})=>{var d,f;if(!e||!t||!r||!n)throw new Error("missing required parameters");try{(d=s==null?void 0:s.onCancelOrderRequest)==null||d.call(s,u),i({cancelOrderStatus:mt.LOADING,cancelOrderTxHash:void 0,cancelOrderError:void 0});const m=u.filter(v=>v.version===1),y=u.filter(v=>v.version===2),[g,E]=await Promise.all([m.length?c(m):Promise.resolve(""),y.length?l(y):Promise.resolve("")]);return i({cancelOrderStatus:mt.SUCCESS,orderIdsToCancel:[]}),[...g||[],E]}catch(m){console.error("cancel order error",m),(f=s==null?void 0:s.onCancelOrderFailed)==null||f.call(s,m),Td(m)?i({cancelOrderStatus:void 0}):(i({cancelOrderStatus:mt.FAILED}),dt.onCancelOrderError(m))}}})},W2=e=>{const t=Ue();return M.useMemo(()=>e?e.type===ut.TRIGGER_PRICE_MARKET?t("triggerPriceMarket"):e.type===ut.TRIGGER_PRICE_LIMIT?t("triggerPriceLimit"):e.type===ut.TWAP_MARKET?t("twapMarket"):e.type===ut.TWAP_LIMIT?t("twapLimit"):t("twapMarket"):t("twapMarket"),[t,e==null?void 0:e.type])},j0=()=>{const{account:e,config:t,chainId:r}=ne();return M.useMemo(()=>["useTwapOrderHistoryManager",e,t==null?void 0:t.partner,r],[e,t,r])},HG=()=>{const e=Nc(),{account:t}=ne(),r=j0();return M.useCallback(n=>{e.setQueryData(r,s=>s?s!=null&&s.some(a=>a.id===n.id)?s:[n,...s]:[n])},[e,r,t])},$G=()=>{const{callbacks:e,refetchBalances:t}=ne(),r=Nc(),n=j0();return M.useCallback(s=>{var c;const a=r.getQueryData(n);let o=!1;const i=[];a&&a.forEach(l=>{var d;const u=s.find(f=>f.id===l.id);u&&u.progress!==l.progress&&(o=!0,i.push(u),u.status===lt.Completed&&((d=e==null?void 0:e.onOrderFilled)==null||d.call(e,u)))}),o&&((c=e==null?void 0:e.onOrdersProgressUpdate)==null||c.call(e,i),t==null||t())},[r,n,e,t])},GG=()=>{const{account:e,config:t,chainId:r}=ne(),n=j0(),s=$G();return l3({refetchInterval:KL,refetchOnWindowFocus:!0,retry:!1,staleTime:1/0,queryKey:n,queryFn:async({signal:a})=>{if(!e||!r||!t)return[];const o=await Ph({signal:a,chainId:r,config:t.twapConfig,account:e});return s(o),o.map(i=>t!=null&&t.twapConfig?{...i,fillDelayMillis:td(i,t.twapConfig)}:i)}})},Du=()=>{const{data:e,isLoading:t,error:r,refetch:n,isRefetching:s}=GG(),{mutateAsync:a}=G0();return M.useMemo(()=>({orders:{all:e??[],open:_u(e??[],lt.Open),completed:_u(e??[],lt.Completed),expired:_u(e??[],lt.Expired),canceled:_u(e??[],lt.Canceled)},isLoading:t,error:r,refetch:()=>n().then(o=>o.data),cancelOrder:a,isRefetching:s}),[e,t,r,n,a,s])},q2=()=>{const e=Z(r=>r.state.orderHistoryStatusFilter),{orders:t}=Du();return M.useMemo(()=>e?t.all.filter(r=>r.status.toLowerCase()===e.toLowerCase())||[]:t.all,[e,t])},_u=(e,t)=>e.filter(r=>r.status===t).sort((r,n)=>n.createdAt-r.createdAt),jG=(e,t,r)=>M.useMemo(()=>{if(!(!e||!t||!r||r!=null&&r.isMarketPrice))return c1(r,e==null?void 0:e.decimals,t==null?void 0:t.decimals)},[r,e,t]),VG=(e,t,r)=>M.useMemo(()=>{if(!(!e||!t||!r))return i1(r,e.decimals,t.decimals)},[r,e,t]),Y2=()=>{const e=Z(r=>r.updateState),t=Z(r=>r.state.orderIdsToCancel);return M.useCallback(r=>{t!=null&&t.includes(r)?e({orderIdsToCancel:t==null?void 0:t.filter(n=>n!==r)}):e({orderIdsToCancel:[...t||[],r]})},[e,t])},WG=()=>{var T,h;const e=Ue(),{orders:t,isLoading:r,refetch:n,isRefetching:s}=Du(),{mutateAsync:a,isPending:o}=G0(),i=q2(),c=Z(b=>b.updateState),l=Z(b=>b.state.orderHistoryStatusFilter),u=Z(b=>b.state.cancelOrdersMode),d=Z(b=>b.state.orderIdsToCancel),f=M.useCallback(b=>c({cancelOrdersMode:b,orderIdsToCancel:[]}),[c]),m=M.useCallback(()=>c({selectedOrderID:void 0}),[c]),y=M.useCallback(b=>a({orders:b}),[a]),g=M.useCallback(b=>c({orderHistoryStatusFilter:b}),[]),E=M.useMemo(()=>{const b=Object.keys(lt).map(x=>({text:x,value:x}));return[{text:e("allOrders"),value:""},...b]},[e]),v=Y2(),w=Z(b=>b.state.selectedOrderID),A=Z2(w),C=M.useMemo(()=>t.all.filter(b=>d==null?void 0:d.includes(b.id)),[t,d]),D=M.useCallback(()=>c({orderIdsToCancel:t.open.map(b=>b.id)}),[c,t]),L=M.useCallback(b=>a({orders:[b]}).then(x=>(x==null?void 0:x[0])||""),[a]);return{refetch:n,onHideSelectedOrder:m,onCancelOrders:y,onCancelOrder:L,onSelectStatus:g,onToggleCancelOrdersMode:f,onSelectOrder:v,isRefetching:s,orders:t,ordersToDisplay:i,isLoading:r,selectedOrder:w?A:void 0,openOrdersCount:((T=t==null?void 0:t.open)==null?void 0:T.length)||0,isCancelOrdersLoading:o,selectedStatus:l||((h=E[0])==null?void 0:h.value)||"",statuses:E,cancelOrdersMode:u,ordersToCancel:C,onSelectAllOrdersToCancel:D}},K2=e=>{const t=Ue(),r=ze({value:e.srcAmount}),n=ze({value:e.limitPrice}),s=ze({value:e.limitPriceUsd}),a=ze({value:e.srcAmountPerTrade}),o=ze({value:e.srcAmountPerTradeUsd,decimalScale:2}),i=ze({value:e.minDestAmountPerTrade}),c=ze({value:e.minDestAmountPerTradeUsd,decimalScale:2}),l=ze({value:e.triggerPricePerTrade}),u=ze({value:e.triggerPricePerTradeUsd,decimalScale:2}),d=ze({value:e.srcUsd,decimalScale:2}),f=ze({value:e.dstUsd,decimalScale:2}),m=ze({value:e.dstAmount});return M.useMemo(()=>({srcToken:e.srcToken,dstToken:e.dstToken,srcUsd:d||"",dstUsd:f||"",limitPrice:{label:t("limitPrice"),value:n||"",usd:s||""},deadline:{tooltip:t("expirationTooltip"),label:t("expirationLabel"),value:e.deadline||0},srcAmount:{label:t("amountOut"),value:r||"",usd:d||""},dstAmount:{value:m||"",usd:f||""},sizePerTrade:{tooltip:t("tradeSizeTooltip"),label:t("individualTradeSize"),value:a||"",usd:o},totalTrades:{tooltip:t("totalTradesTooltip"),label:t("numberOfTrades"),value:e.totalTrades||0},minDestAmountPerTrade:{tooltip:t("minDstAmountTooltip"),label:t(e.totalTrades&&e.totalTrades>1?"minReceivedPerTrade":"minReceived"),value:i||"",usd:c},tradeInterval:{tooltip:t("tradeIntervalTootlip"),label:t("tradeIntervalLabel"),value:e.tradeInterval||0},triggerPricePerTrade:{tooltip:t("triggerPriceTooltip"),label:t(e.totalTrades&&e.totalTrades>1?"triggerPricePerChunk":"triggerPrice"),value:l||"",usd:u},recipient:{label:t("recipient"),value:e.account||""}}),[d,f,n,r,a,o,i,l,u,n,s,m,f,c])},Z2=e=>{const{orders:t}=Du(),{useToken:r,config:n}=ne(),s=Ue(),a=M.useMemo(()=>t==null?void 0:t.all.find(C=>C.id===e),[t,e])||{},o=W2(a),i=r==null?void 0:r(a==null?void 0:a.srcTokenAddress),c=r==null?void 0:r(a==null?void 0:a.dstTokenAddress),l=Vr(i==null?void 0:i.decimals,a==null?void 0:a.srcAmount),u=jG(i,c,a),d=ze({value:VG(i,c,a)}),f=ze({value:Vr(i==null?void 0:i.decimals,a==null?void 0:a.srcAmountFilled)}),m=ze({value:Vr(c==null?void 0:c.decimals,a==null?void 0:a.dstAmountFilled)}),y=ze({value:a==null?void 0:a.progress,decimalScale:2}),g=Vr(i==null?void 0:i.decimals,a==null?void 0:a.srcAmountPerTrade),E=Vr(c==null?void 0:c.decimals,a==null?void 0:a.dstMinAmountPerTrade),v=Vr(c==null?void 0:c.decimals,a==null?void 0:a.triggerPricePerTrade),w=M.useMemo(()=>a?a.version===2?a.fillDelay:n.twapConfig?td(a,n.twapConfig):0:0,[a,n]),A=K2({srcToken:i,dstToken:c,account:a==null?void 0:a.maker,limitPrice:u,deadline:a==null?void 0:a.deadline,tradeInterval:w,srcAmount:l,totalTrades:a==null?void 0:a.totalTradesAmount,srcAmountPerTrade:g,minDestAmountPerTrade:E,triggerPricePerTrade:v});return M.useMemo(()=>({original:a,title:o,...A,createdAt:{label:s("createdAt"),value:a==null?void 0:a.createdAt},id:{label:s("id"),value:a==null?void 0:a.id},amountInFilled:{label:s("amountOut"),value:f},amountOutFilled:{label:s("amountReceived"),value:m,token:c},progress:{label:s("progress"),value:y},excecutionPrice:{label:s((a==null?void 0:a.totalTradesAmount)===1?"finalExcecutionPrice":"averageExecutionPrice"),value:d},version:{label:s("version"),value:a==null?void 0:a.version}}),[a,s,d,f,m,y,o,i,c,A])},X2=M.createContext({}),Rt=()=>M.useContext(X2),qG=()=>{const e=Z(c=>c.state.selectedOrderID),t=Z2(e),r=Ue(),[n,s]=M.useState("panel1"),{components:a}=ne(),o=a.TokenLogo;M.useEffect(()=>{s("panel1")},[t.id.value]);const i=c=>{s(n===c?!1:c)};return t?B.jsx(X2.Provider,{value:{order:t},children:B.jsxs("div",{className:"twap-orders__selected-order",children:[B.jsx(a1,{SrcTokenLogo:o&&B.jsx(o,{token:t.srcToken}),DstTokenLogo:o&&B.jsx(o,{token:t.dstToken}),fromTitle:r("from"),inToken:t.srcToken,toTitle:r("to"),outToken:t.dstToken}),B.jsx(we.Container,{children:B.jsxs("div",{className:"twap-orders__selected-order-bottom",children:[B.jsxs("div",{className:"twap-orders__selected-order-accordions",children:[B.jsx(Q2,{title:r("excecutionSummary"),onClick:()=>i("panel1"),expanded:n==="panel1",children:B.jsx(rj,{})}),B.jsx(Q2,{title:r("orderInfo"),expanded:n==="panel2",onClick:()=>i("panel2"),children:B.jsx(YG,{})})]}),B.jsx(sj,{})]})})]})}):null},Q2=({expanded:e,onClick:t,children:r,title:n})=>B.jsxs("div",{className:"twap-orders__selected-order-accordion",children:[B.jsxs("div",{onClick:t,className:"twap-orders__selected-order-accordion-trigger",children:[B.jsx("p",{children:n}),B.jsx(rz.IoIosArrowDown,{style:{transform:e?"rotate(180deg)":"rotate(0deg)"}})]}),e&&B.jsx("div",{className:"twap-orders__selected-order-accordion-details",children:r})]}),YG=()=>B.jsxs(we,{children:[B.jsx(tj,{}),B.jsx(aj,{}),B.jsx(QG,{}),B.jsx(oj,{}),B.jsx(KG,{}),B.jsx(ZG,{}),B.jsx(XG,{}),B.jsx(JG,{}),B.jsx(ej,{}),B.jsx(dj,{}),B.jsx(we.Recipient,{})]}),KG=()=>{const{order:e}=Rt();return B.jsx(we.TradeSize,{tradeSize:e.sizePerTrade.value,srcToken:e.srcToken,label:e.sizePerTrade.label,tooltip:e.sizePerTrade.tooltip,trades:e.totalTrades.value})},ZG=()=>{const{order:e}=Rt();return B.jsx(we.TradesAmount,{trades:e.totalTrades.value,label:e.totalTrades.label,tooltip:e.totalTrades.tooltip})},XG=()=>{const{order:e}=Rt();return B.jsx(we.MinDestAmount,{dstToken:e.dstToken,dstMinAmountOut:e.minDestAmountPerTrade.value,label:e.minDestAmountPerTrade.label,tooltip:e.minDestAmountPerTrade.tooltip})},QG=()=>{const{order:e}=Rt();return B.jsx(we.Deadline,{deadline:e.deadline.value,label:e.deadline.label,tooltip:e.deadline.tooltip})},JG=()=>{const{order:e}=Rt();return B.jsx(we.TradeInterval,{fillDelayMillis:e.tradeInterval.value,chunks:e.totalTrades.value,label:e.tradeInterval.label,tooltip:e.tradeInterval.tooltip})},ej=()=>{const{order:e}=Rt();return B.jsx(we.TriggerPrice,{dstToken:e.dstToken,price:e.triggerPricePerTrade.value,label:e.triggerPricePerTrade.label,tooltip:e.triggerPricePerTrade.tooltip})},tj=()=>{const{order:e}=Rt();return B.jsx(we.OrderID,{id:e.id.value||""})},rj=()=>B.jsxs(we,{children:[B.jsx(lj,{}),B.jsx(ij,{}),B.jsx(nj,{}),B.jsx(uj,{}),B.jsx(pj,{})]}),nj=()=>{var r;const{order:e}=Rt(),t=ze({value:e.amountOutFilled.value,decimalScale:3});return e.amountOutFilled.value?B.jsx(we.DetailRow,{title:e.amountOutFilled.label,children:B.jsxs("p",{children:[t||"-"," ",(r=e.dstToken)==null?void 0:r.symbol]})}):null},sj=()=>{const{order:e}=Rt(),{mutateAsync:t,isPending:r}=G0(),{components:n}=ne(),s=n.Button,a=M.useCallback(async()=>t({orders:[e.original]}),[t,e]);return!e||e.original.status!==lt.Open||!s?null:B.jsx(s,{loading:r,onClick:a,disabled:r,className:"twap-cancel-order",children:"Cancel"})},aj=()=>{const{order:e}=Rt(),t=Ue(),r=H0(e.createdAt.value);return B.jsx(we.DetailRow,{title:t("createdAt")||"",children:B.jsx("p",{children:r})})},oj=()=>{var n;const{order:e}=Rt(),t=Ue(),r=ze({value:e.srcAmount.value,decimalScale:3});return B.jsx(we.DetailRow,{title:t("amountOut")||"",children:B.jsxs("p",{children:[r||0," ",(n=e.srcToken)==null?void 0:n.symbol]})})},ij=()=>{var r;const{order:e}=Rt(),t=ze({value:e.amountInFilled.value,decimalScale:3});return B.jsx(we.DetailRow,{title:e.amountInFilled.label,children:B.jsxs("p",{children:[t||"-"," ",(r=e.srcToken)==null?void 0:r.symbol]})})},cj=()=>{const{order:e}=Rt(),t=Ue();return M.useMemo(()=>{switch(e.original.status){case lt.Open:return t("Open")||"";case lt.Completed:return t("Completed")||"";case lt.Expired:return t("Expired")||"";case lt.Canceled:return t("Canceled")||""}},[e.original.status,t])},lj=()=>{const e=Ue(),t=cj();return B.jsx(we.DetailRow,{title:e("status")||"",children:B.jsx("p",{children:t})})},uj=()=>{const{order:e}=Rt(),t=ze({value:e.progress.value,decimalScale:2});return B.jsx(we.DetailRow,{title:e.progress.label,children:B.jsxs("p",{children:[t||0,"%"]})})},dj=()=>{const{order:e}=Rt(),t=Ue();return e.limitPrice.value?B.jsx(J2,{title:t("limitPrice")||"",price:e.limitPrice.value,srcToken:e.srcToken,dstToken:e.dstToken}):null},pj=()=>{const{order:e}=Rt();return e.excecutionPrice.value?B.jsx(J2,{title:e.excecutionPrice.label,price:e.excecutionPrice.value,srcToken:e.srcToken,dstToken:e.dstToken}):null},J2=({price:e,srcToken:t,dstToken:r,title:n})=>{const s=ze({value:e,decimalScale:3});return B.jsx(we.DetailRow,{title:n,children:j(e||0).isZero()?B.jsx("p",{children:"-"}):B.jsxs("p",{children:["1 ",t==null?void 0:t.symbol," = ",s," ",r==null?void 0:r.symbol]})})};var V0={},ex;function fj(){if(ex)return V0;ex=1;var e=uu.GenIcon;return V0.HiArrowRight=function(r){return e({tag:"svg",attr:{viewBox:"0 0 20 20",fill:"currentColor"},child:[{tag:"path",attr:{fillRule:"evenodd",d:"M10.293 3.293a1 1 0 011.414 0l6 6a1 1 0 010 1.414l-6 6a1 1 0 01-1.414-1.414L14.586 11H3a1 1 0 110-2h11.586l-4.293-4.293a1 1 0 010-1.414z",clipRule:"evenodd"}}]})(r)},V0}var mj=fj();const Mu=0,ms=1,mo=2,tx=4;function rx(e){return()=>e}function hj(e){e()}function nx(e,t){return r=>e(t(r))}function sx(e,t){return()=>e(t)}function bj(e,t){return r=>e(t,r)}function W0(e){return e!==void 0}function yj(...e){return()=>{e.map(hj)}}function ho(){}function Nu(e,t){return t(e),e}function gj(e,t){return t(e)}function et(...e){return e}function je(e,t){return e(ms,t)}function Ce(e,t){e(Mu,t)}function q0(e){e(mo)}function st(e){return e(tx)}function ce(e,t){return je(e,bj(t,Mu))}function Wr(e,t){const r=e(ms,n=>{r(),t(n)});return r}function ax(e){let t,r;return n=>s=>{t=s,r&&clearTimeout(r),r=setTimeout(()=>{n(t)},e)}}function ox(e,t){return e===t}function tt(e=ox){let t;return r=>n=>{e(t,n)||(t=n,r(n))}}function fe(e){return t=>r=>{e(r)&&t(r)}}function re(e){return t=>nx(t,e)}function on(e){return t=>()=>{t(e)}}function W(e,...t){const r=xj(...t);return(n,s)=>{switch(n){case mo:q0(e);return;case ms:return je(e,r(s))}}}function cn(e,t){return r=>n=>{r(t=e(t,n))}}function oa(e){return t=>r=>{e>0?e--:t(r)}}function Hn(e){let t=null,r;return n=>s=>{t=s,!r&&(r=setTimeout(()=>{r=void 0,n(t)},e))}}function Te(...e){const t=new Array(e.length);let r=0,n=null;const s=Math.pow(2,e.length)-1;return e.forEach((a,o)=>{const i=Math.pow(2,o);je(a,c=>{const l=r;r=r|i,t[o]=c,l!==s&&r===s&&n&&(n(),n=null)})}),a=>o=>{const i=()=>{a([o].concat(t))};r===s?i():n=i}}function xj(...e){return t=>e.reduceRight(gj,t)}function wj(e){let t,r;const n=()=>t==null?void 0:t();return function(s,a){switch(s){case ms:return a?r===a?void 0:(n(),r=a,t=je(e,a),t):(n(),ho);case mo:n(),r=null;return}}}function K(e){let t=e;const r=Oe();return(n,s)=>{switch(n){case Mu:t=s;break;case ms:{s(t);break}case tx:return t}return r(n,s)}}function Ht(e,t){return Nu(K(t),r=>ce(e,r))}function Oe(){const e=[];return(t,r)=>{switch(t){case Mu:e.slice().forEach(n=>{n(r)});return;case mo:e.splice(0,e.length);return;case ms:return e.push(r),()=>{const n=e.indexOf(r);n>-1&&e.splice(n,1)}}}}function br(e){return Nu(Oe(),t=>ce(e,t))}function $e(e,t=[],{singleton:r}={singleton:!0}){return{constructor:e,dependencies:t,id:vj(),singleton:r}}const vj=()=>Symbol();function Ej(e){const t=new Map,r=({constructor:n,dependencies:s,id:a,singleton:o})=>{if(o&&t.has(a))return t.get(a);const i=n(s.map(c=>r(c)));return o&&t.set(a,i),i};return r(e)}function Et(...e){const t=Oe(),r=new Array(e.length);let n=0;const s=Math.pow(2,e.length)-1;return e.forEach((a,o)=>{const i=Math.pow(2,o);je(a,c=>{r[o]=c,n=n|i,n===s&&Ce(t,r)})}),function(a,o){switch(a){case mo:{q0(t);return}case ms:return n===s&&o(r),je(t,o)}}}function me(e,t=ox){return W(e,tt(t))}function Y0(...e){return function(t,r){switch(t){case mo:return;case ms:return yj(...e.map(n=>je(n,r)))}}}var nr=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(nr||{});const kj={0:"debug",3:"error",1:"log",2:"warn"},Cj=()=>typeof globalThis>"u"?window:globalThis,hs=$e(()=>{const e=K(3);return{log:K((t,r,n=1)=>{var s;const a=(s=Cj().VIRTUOSO_LOG_LEVEL)!=null?s:st(e);n>=a&&console[kj[n]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,r)}),logLevel:e}},[],{singleton:!0});function ia(e,t,r){return K0(e,t,r).callbackRef}function K0(e,t,r){const n=M.useRef(null);let s=o=>{};const a=M.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(o=>{const i=()=>{const c=o[0].target;c.offsetParent!==null&&e(c)};r?i():requestAnimationFrame(i)}):null,[e,r]);return s=o=>{o&&t?(a==null||a.observe(o),n.current=o):(n.current&&(a==null||a.unobserve(n.current)),n.current=null)},{callbackRef:s,ref:n}}function Tj(e,t,r,n,s,a,o,i,c){const l=M.useCallback(u=>{const d=Sj(u.children,t,i?"offsetWidth":"offsetHeight",s);let f=u.parentElement;for(;!f.dataset.virtuosoScroller;)f=f.parentElement;const m=f.lastElementChild.dataset.viewportType==="window";let y;m&&(y=f.ownerDocument.defaultView);const g=o?i?o.scrollLeft:o.scrollTop:m?i?y.scrollX||y.document.documentElement.scrollLeft:y.scrollY||y.document.documentElement.scrollTop:i?f.scrollLeft:f.scrollTop,E=o?i?o.scrollWidth:o.scrollHeight:m?i?y.document.documentElement.scrollWidth:y.document.documentElement.scrollHeight:i?f.scrollWidth:f.scrollHeight,v=o?i?o.offsetWidth:o.offsetHeight:m?i?y.innerWidth:y.innerHeight:i?f.offsetWidth:f.offsetHeight;n({scrollHeight:E,scrollTop:Math.max(g,0),viewportHeight:v}),a==null||a(i?ix("column-gap",getComputedStyle(u).columnGap,s):ix("row-gap",getComputedStyle(u).rowGap,s)),d!==null&&e(d)},[e,t,s,a,o,n,i]);return K0(l,r,c)}function Sj(e,t,r,n){const s=e.length;if(s===0)return null;const a=[];for(let o=0;o<s;o++){const i=e.item(o);if(i.dataset.index===void 0)continue;const c=parseInt(i.dataset.index),l=parseFloat(i.dataset.knownSize),u=t(i,r);if(u===0&&n("Zero-sized element, this should not happen",{child:i},nr.ERROR),u===l)continue;const d=a[a.length-1];a.length===0||d.size!==u||d.endIndex!==c-1?a.push({endIndex:c,size:u,startIndex:c}):a[a.length-1].endIndex++}return a}function ix(e,t,r){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&r(`${e} was not resolved to pixel value correctly`,t,nr.WARN),t==="normal"?0:parseInt(t??"0",10)}function cx(e,t,r){const n=M.useRef(null),s=M.useCallback(c=>{if(!(c!=null&&c.offsetParent))return;const l=c.getBoundingClientRect(),u=l.width;let d,f;if(t){const m=t.getBoundingClientRect(),y=l.top-m.top;f=m.height-Math.max(0,y),d=y+t.scrollTop}else{const m=o.current.ownerDocument.defaultView;f=m.innerHeight-Math.max(0,l.top),d=l.top+m.scrollY}n.current={offsetTop:d,visibleHeight:f,visibleWidth:u},e(n.current)},[e,t]),{callbackRef:a,ref:o}=K0(s,!0,r),i=M.useCallback(()=>{s(o.current)},[s,o]);return M.useEffect(()=>{var c;if(t){t.addEventListener("scroll",i);const l=new ResizeObserver(()=>{requestAnimationFrame(i)});return l.observe(t),()=>{t.removeEventListener("scroll",i),l.unobserve(t)}}else{const l=(c=o.current)==null?void 0:c.ownerDocument.defaultView;return l==null||l.addEventListener("scroll",i),l==null||l.addEventListener("resize",i),()=>{l==null||l.removeEventListener("scroll",i),l==null||l.removeEventListener("resize",i)}}},[i,t,o]),a}const Wt=$e(()=>{const e=Oe(),t=Oe(),r=K(0),n=Oe(),s=K(0),a=Oe(),o=Oe(),i=K(0),c=K(0),l=K(0),u=K(0),d=Oe(),f=Oe(),m=K(!1),y=K(!1),g=K(!1);return ce(W(e,re(({scrollTop:E})=>E)),t),ce(W(e,re(({scrollHeight:E})=>E)),o),ce(t,s),{deviation:r,fixedFooterHeight:l,fixedHeaderHeight:c,footerHeight:u,headerHeight:i,horizontalDirection:y,scrollBy:f,scrollContainerState:e,scrollHeight:o,scrollingInProgress:m,scrollTo:d,scrollTop:t,skipAnimationFrameInResizeObserver:g,smoothScrollTargetReached:n,statefulScrollTop:s,viewportHeight:a}},[],{singleton:!0}),oc={lvl:0};function lx(e,t){const r=e.length;if(r===0)return[];let{index:n,value:s}=t(e[0]);const a=[];for(let o=1;o<r;o++){const{index:i,value:c}=t(e[o]);a.push({end:i-1,start:n,value:s}),n=i,s=c}return a.push({end:1/0,start:n,value:s}),a}function qe(e){return e===oc}function ic(e,t){if(!qe(e))return t===e.k?e.v:t<e.k?ic(e.l,t):ic(e.r,t)}function qr(e,t,r="k"){if(qe(e))return[-1/0,void 0];if(Number(e[r])===t)return[e.k,e.v];if(Number(e[r])<t){const n=qr(e.r,t,r);return n[0]===-1/0?[e.k,e.v]:n}return qr(e.l,t,r)}function yr(e,t,r){return qe(e)?px(t,r,1):t===e.k?St(e,{k:t,v:r}):t<e.k?fx(St(e,{l:yr(e.l,t,r)})):fx(St(e,{r:yr(e.r,t,r)}))}function bo(){return oc}function yo(e,t,r){if(qe(e))return[];const n=qr(e,t)[0];return Aj(X0(e,n,r))}function Z0(e,t){if(qe(e))return oc;const{k:r,l:n,r:s}=e;if(t===r){if(qe(n))return s;if(qe(s))return n;{const[a,o]=dx(n);return Lu(St(e,{k:a,l:ux(n),v:o}))}}else return t<r?Lu(St(e,{l:Z0(n,t)})):Lu(St(e,{r:Z0(s,t)}))}function ca(e){return qe(e)?[]:[...ca(e.l),{k:e.k,v:e.v},...ca(e.r)]}function X0(e,t,r){if(qe(e))return[];const{k:n,l:s,r:a,v:o}=e;let i=[];return n>t&&(i=i.concat(X0(s,t,r))),n>=t&&n<=r&&i.push({k:n,v:o}),n<=r&&(i=i.concat(X0(a,t,r))),i}function Lu(e){const{l:t,lvl:r,r:n}=e;if(n.lvl>=r-1&&t.lvl>=r-1)return e;if(r>n.lvl+1){if(Q0(t))return mx(St(e,{lvl:r-1}));if(!qe(t)&&!qe(t.r))return St(t.r,{l:St(t,{r:t.r.l}),lvl:r,r:St(e,{l:t.r.r,lvl:r-1})});throw new Error("Unexpected empty nodes")}else{if(Q0(e))return J0(St(e,{lvl:r-1}));if(!qe(n)&&!qe(n.l)){const s=n.l,a=Q0(s)?n.lvl-1:n.lvl;return St(s,{l:St(e,{lvl:r-1,r:s.l}),lvl:s.lvl+1,r:J0(St(n,{l:s.r,lvl:a}))})}else throw new Error("Unexpected empty nodes")}}function St(e,t){return px(t.k!==void 0?t.k:e.k,t.v!==void 0?t.v:e.v,t.lvl!==void 0?t.lvl:e.lvl,t.l!==void 0?t.l:e.l,t.r!==void 0?t.r:e.r)}function ux(e){return qe(e.r)?e.l:Lu(St(e,{r:ux(e.r)}))}function Q0(e){return qe(e)||e.lvl>e.r.lvl}function dx(e){return qe(e.r)?[e.k,e.v]:dx(e.r)}function px(e,t,r,n=oc,s=oc){return{k:e,l:n,lvl:r,r:s,v:t}}function fx(e){return J0(mx(e))}function mx(e){const{l:t}=e;return!qe(t)&&t.lvl===e.lvl?St(t,{r:St(e,{l:t.r})}):e}function J0(e){const{lvl:t,r}=e;return!qe(r)&&!qe(r.r)&&r.lvl===t&&r.r.lvl===t?St(r,{l:St(e,{r:r.l}),lvl:t+1}):e}function Aj(e){return lx(e,({k:t,v:r})=>({index:t,value:r}))}function hx(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function cc(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const em=$e(()=>({recalcInProgress:K(!1)}),[],{singleton:!0});function bx(e,t,r){return e[zu(e,t,r)]}function zu(e,t,r,n=0){let s=e.length-1;for(;n<=s;){const a=Math.floor((n+s)/2),o=e[a],i=r(o,t);if(i===0)return a;if(i===-1){if(s-n<2)return a-1;s=a-1}else{if(s===n)return a;n=a+1}}throw new Error(`Failed binary finding record in array - ${e.join(",")}, searched for ${t}`)}function Pj(e,t,r,n){const s=zu(e,t,n),a=zu(e,r,n,s);return e.slice(s,a+1)}function bs(e,t){return Math.round(e.getBoundingClientRect()[t])}function Ru(e){return!qe(e.groupOffsetTree)}function tm({index:e},t){return t===e?0:t<e?-1:1}function Ij(){return{groupIndices:[],groupOffsetTree:bo(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:bo()}}function Bj(e,t){let r=qe(e)?0:1/0;for(const n of t){const{endIndex:s,size:a,startIndex:o}=n;if(r=Math.min(r,o),qe(e)){e=yr(e,0,a);continue}const i=yo(e,o-1,s+1);if(i.some(Nj(n)))continue;let c=!1,l=!1;for(const{end:u,start:d,value:f}of i)c?(s>=d||a===f)&&(e=Z0(e,d)):(l=f!==a,c=!0),u>s&&s>=d&&f!==a&&(e=yr(e,s+1,f));l&&(e=yr(e,o,a))}return[e,r]}function Fj(e){return typeof e.groupIndex<"u"}function Uj({offset:e},t){return t===e?0:t<e?-1:1}function lc(e,t,r){if(t.length===0)return 0;const{index:n,offset:s,size:a}=bx(t,e,tm),o=e-n,i=a*o+(o-1)*r+s;return i>0?i+r:i}function yx(e,t){if(!Ru(t))return e;let r=0;for(;t.groupIndices[r]<=e+r;)r++;return e+r}function gx(e,t,r){if(Fj(e))return t.groupIndices[e.groupIndex]+1;{const n=e.index==="LAST"?r:e.index;let s=yx(n,t);return s=Math.max(0,s,Math.min(r,s)),s}}function Oj(e,t,r,n=0){return n>0&&(t=Math.max(t,bx(e,n,tm).offset)),lx(Pj(e,t,r,Uj),Mj)}function Dj(e,[t,r,n,s]){t.length>0&&n("received item sizes",t,nr.DEBUG);const a=e.sizeTree;let o=a,i=0;if(r.length>0&&qe(a)&&t.length===2){const f=t[0].size,m=t[1].size;o=r.reduce((y,g)=>yr(yr(y,g,f),g+1,m),o)}else[o,i]=Bj(o,t);if(o===a)return e;const{lastIndex:c,lastOffset:l,lastSize:u,offsetTree:d}=rm(e.offsetTree,i,o,s);return{groupIndices:r,groupOffsetTree:r.reduce((f,m)=>yr(f,m,lc(m,d,s)),bo()),lastIndex:c,lastOffset:l,lastSize:u,offsetTree:d,sizeTree:o}}function _j(e){return ca(e).map(({k:t,v:r},n,s)=>{const a=s[n+1];return{endIndex:a?a.k-1:1/0,size:r,startIndex:t}})}function xx(e,t){let r=0,n=0;for(;r<e;)r+=t[n+1]-t[n]-1,n++;return n-(r===e?0:1)}function rm(e,t,r,n){let s=e,a=0,o=0,i=0,c=0;if(t!==0){c=zu(s,t-1,tm),i=s[c].offset;const l=qr(r,t-1);a=l[0],o=l[1],s.length&&s[c].size===qr(r,t)[1]&&(c-=1),s=s.slice(0,c+1)}else s=[];for(const{start:l,value:u}of yo(r,t,1/0)){const d=l-a,f=d*o+i+d*n;s.push({index:l,offset:f,size:u}),a=l,i=f,o=u}return{lastIndex:a,lastOffset:i,lastSize:o,offsetTree:s}}function Mj(e){return{index:e.index,value:e}}function Nj(e){const{endIndex:t,size:r,startIndex:n}=e;return s=>s.start===n&&(s.end===t||s.end===1/0)&&s.value===r}const Lj={offsetHeight:"height",offsetWidth:"width"},ln=$e(([{log:e},{recalcInProgress:t}])=>{const r=Oe(),n=Oe(),s=Ht(n,0),a=Oe(),o=Oe(),i=K(0),c=K([]),l=K(void 0),u=K(void 0),d=K(void 0),f=K(void 0),m=K((T,h)=>bs(T,Lj[h])),y=K(void 0),g=K(0),E=Ij(),v=Ht(W(r,Te(c,e,g),cn(Dj,E),tt()),E),w=Ht(W(c,tt(),cn((T,h)=>({current:h,prev:T.current}),{current:[],prev:[]}),re(({prev:T})=>T)),[]);ce(W(c,fe(T=>T.length>0),Te(v,g),re(([T,h,b])=>{const x=T.reduce((S,I,F)=>yr(S,I,lc(I,h.offsetTree,b)||F),bo());return{...h,groupIndices:T,groupOffsetTree:x}})),v),ce(W(n,Te(v),fe(([T,{lastIndex:h}])=>T<h),re(([T,{lastIndex:h,lastSize:b}])=>[{endIndex:h,size:b,startIndex:T}])),r),ce(l,u);const A=Ht(W(l,re(T=>T===void 0)),!0);ce(W(u,fe(T=>T!==void 0&&qe(st(v).sizeTree)),re(T=>{const h=st(d),b=st(c).length>0;return h?b?[{endIndex:0,size:h,startIndex:0},{endIndex:1,size:T,startIndex:1}]:[]:[{endIndex:0,size:T,startIndex:0}]})),r),ce(W(f,fe(T=>T!==void 0&&T.length>0&&qe(st(v).sizeTree)),re(T=>{const h=[];let b=T[0],x=0;for(let S=1;S<T.length;S++){const I=T[S];I!==b&&(h.push({endIndex:S-1,size:b,startIndex:x}),b=I,x=S)}return h.push({endIndex:T.length-1,size:b,startIndex:x}),h})),r),ce(W(c,Te(d,u),fe(([,T,h])=>T!==void 0&&h!==void 0),re(([T,h,b])=>{const x=[];for(let S=0;S<T.length;S++){const I=T[S],F=T[S+1];x.push({startIndex:I,endIndex:I,size:h}),F!==void 0&&x.push({startIndex:I+1,endIndex:F-1,size:b})}return x})),r);const C=br(W(r,Te(v),cn(({sizes:T},[h,b])=>({changed:b!==T,sizes:b}),{changed:!1,sizes:E}),re(T=>T.changed)));je(W(i,cn((T,h)=>({diff:T.prev-h,prev:h}),{diff:0,prev:0}),re(T=>T.diff)),T=>{const{groupIndices:h}=st(v);if(T>0)Ce(t,!0),Ce(a,T+xx(T,h));else if(T<0){const b=st(w);b.length>0&&(T-=xx(-T,b)),Ce(o,T)}}),je(W(i,Te(e)),([T,h])=>{T<0&&h("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:i},nr.ERROR)});const D=br(a);ce(W(a,Te(v),re(([T,h])=>{const b=h.groupIndices.length>0,x=[],S=h.lastSize;if(b){const I=ic(h.sizeTree,0);let F=0,_=0;for(;F<T;){const P=h.groupIndices[_],O=h.groupIndices.length===_+1?1/0:h.groupIndices[_+1]-P-1;x.push({endIndex:P,size:I,startIndex:P}),x.push({endIndex:P+1+O-1,size:S,startIndex:P+1}),_++,F+=O+1}const k=ca(h.sizeTree);return F!==T&&k.shift(),k.reduce((P,{k:O,v:U})=>{let z=P.ranges;return P.prevSize!==0&&(z=[...P.ranges,{endIndex:O+T-1,size:P.prevSize,startIndex:P.prevIndex}]),{prevIndex:O+T,prevSize:U,ranges:z}},{prevIndex:T,prevSize:0,ranges:x}).ranges}return ca(h.sizeTree).reduce((I,{k:F,v:_})=>({prevIndex:F+T,prevSize:_,ranges:[...I.ranges,{endIndex:F+T-1,size:I.prevSize,startIndex:I.prevIndex}]}),{prevIndex:0,prevSize:S,ranges:[]}).ranges})),r);const L=br(W(o,Te(v,g),re(([T,{offsetTree:h},b])=>{const x=-T;return lc(x,h,b)})));return ce(W(o,Te(v,g),re(([T,h,b])=>{if(h.groupIndices.length>0){if(qe(h.sizeTree))return h;let x=bo();const S=st(w);let I=0,F=0,_=0;for(;I<-T;){_=S[F];const k=S[F+1]-_-1;F++,I+=k+1}if(x=ca(h.sizeTree).reduce((k,{k:P,v:O})=>yr(k,Math.max(0,P+T),O),x),I!==-T){const k=ic(h.sizeTree,_);x=yr(x,0,k);const P=qr(h.sizeTree,-T+1)[1];x=yr(x,1,P)}return{...h,sizeTree:x,...rm(h.offsetTree,0,x,b)}}else{const x=ca(h.sizeTree).reduce((S,{k:I,v:F})=>yr(S,Math.max(0,I+T),F),bo());return{...h,sizeTree:x,...rm(h.offsetTree,0,x,b)}}})),v),{beforeUnshiftWith:D,data:y,defaultItemSize:u,firstItemIndex:i,fixedItemSize:l,fixedGroupSize:d,gap:g,groupIndices:c,heightEstimates:f,itemSize:m,listRefresh:C,shiftWith:o,shiftWithOffset:L,sizeRanges:r,sizes:v,statefulTotalCount:s,totalCount:n,trackItemSizes:A,unshiftWith:a}},et(hs,em),{singleton:!0});function zj(e){return e.reduce((t,r)=>(t.groupIndices.push(t.totalCount),t.totalCount+=r+1,t),{groupIndices:[],totalCount:0})}const wx=$e(([{groupIndices:e,sizes:t,totalCount:r},{headerHeight:n,scrollTop:s}])=>{const a=Oe(),o=Oe(),i=br(W(a,re(zj)));return ce(W(i,re(c=>c.totalCount)),r),ce(W(i,re(c=>c.groupIndices)),e),ce(W(Et(s,t,n),fe(([c,l])=>Ru(l)),re(([c,l,u])=>qr(l.groupOffsetTree,Math.max(c-u,0),"v")[0]),tt(),re(c=>[c])),o),{groupCounts:a,topItemsIndexes:o}},et(ln,Wt)),ys=$e(([{log:e}])=>{const t=K(!1),r=br(W(t,fe(n=>n),tt()));return je(t,n=>{n&&st(e)("props updated",{},nr.DEBUG)}),{didMount:r,propsReady:t}},et(hs),{singleton:!0}),Rj=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function vx(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!Rj)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const uc=$e(([{gap:e,listRefresh:t,sizes:r,totalCount:n},{fixedFooterHeight:s,fixedHeaderHeight:a,footerHeight:o,headerHeight:i,scrollingInProgress:c,scrollTo:l,smoothScrollTargetReached:u,viewportHeight:d},{log:f}])=>{const m=Oe(),y=Oe(),g=K(0);let E=null,v=null,w=null;function A(){E&&(E(),E=null),w&&(w(),w=null),v&&(clearTimeout(v),v=null),Ce(c,!1)}return ce(W(m,Te(r,d,n,g,i,o,f),Te(e,a,s),re(([[C,D,L,T,h,b,x,S],I,F,_])=>{const k=vx(C),{align:P,behavior:O,offset:U}=k,z=T-1,H=gx(k,D,z);let G=lc(H,D.offsetTree,I)+b;P==="end"?(G+=F+qr(D.sizeTree,H)[1]-L+_,H===z&&(G+=x)):P==="center"?G+=(F+qr(D.sizeTree,H)[1]-L+_)/2:G-=h,U&&(G+=U);const J=pe=>{A(),pe?(S("retrying to scroll to",{location:C},nr.DEBUG),Ce(m,C)):(Ce(y,!0),S("list did not change, scroll successful",{},nr.DEBUG))};if(A(),O==="smooth"){let pe=!1;w=je(t,he=>{pe=pe||he}),E=Wr(u,()=>{J(pe)})}else E=Wr(W(t,Hj(150)),J);return v=setTimeout(()=>{A()},1200),Ce(c,!0),S("scrolling from index to",{behavior:O,index:H,top:G},nr.DEBUG),{behavior:O,top:G}})),l),{scrollTargetReached:y,scrollToIndex:m,topListHeight:g}},et(ln,Wt,hs),{singleton:!0});function Hj(e){return t=>{const r=setTimeout(()=>{t(!1)},e);return n=>{n&&(t(!0),clearTimeout(r))}}}function nm(e,t){e==0?t():requestAnimationFrame(()=>{nm(e-1,t)})}function sm(e,t){const r=t-1;return typeof e=="number"?e:e.index==="LAST"?r:e.index}const dc=$e(([{defaultItemSize:e,listRefresh:t,sizes:r},{scrollTop:n},{scrollTargetReached:s,scrollToIndex:a},{didMount:o}])=>{const i=K(!0),c=K(0),l=K(!0);return ce(W(o,Te(c),fe(([u,d])=>!!d),on(!1)),i),ce(W(o,Te(c),fe(([u,d])=>!!d),on(!1)),l),je(W(Et(t,o),Te(i,r,e,l),fe(([[,u],d,{sizeTree:f},m,y])=>u&&(!qe(f)||W0(m))&&!d&&!y),Te(c)),([,u])=>{Wr(s,()=>{Ce(l,!0)}),nm(4,()=>{Wr(n,()=>{Ce(i,!0)}),Ce(a,u)})}),{initialItemFinalLocationReached:l,initialTopMostItemIndex:c,scrolledToInitialItem:i}},et(ln,Wt,uc,ys),{singleton:!0});function Ex(e,t){return Math.abs(e-t)<1.01}const pc="up",fc="down",$j="none",Gj={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},jj=0,mc=$e(([{footerHeight:e,headerHeight:t,scrollBy:r,scrollContainerState:n,scrollTop:s,viewportHeight:a}])=>{const o=K(!1),i=K(!0),c=Oe(),l=Oe(),u=K(4),d=K(jj),f=Ht(W(Y0(W(me(s),oa(1),on(!0)),W(me(s),oa(1),on(!1),ax(100))),tt()),!1),m=Ht(W(Y0(W(r,on(!0)),W(r,on(!1),ax(200))),tt()),!1);ce(W(Et(me(s),me(d)),re(([w,A])=>w<=A),tt()),i),ce(W(i,Hn(50)),l);const y=br(W(Et(n,me(a),me(t),me(e),me(u)),cn((w,[{scrollHeight:A,scrollTop:C},D,L,T,h])=>{const b=C+D-A>-h,x={scrollHeight:A,scrollTop:C,viewportHeight:D};if(b){let I,F;return C>w.state.scrollTop?(I="SCROLLED_DOWN",F=w.state.scrollTop-C):(I="SIZE_DECREASED",F=w.state.scrollTop-C||w.scrollTopDelta),{atBottom:!0,atBottomBecause:I,scrollTopDelta:F,state:x}}let S;return x.scrollHeight>w.state.scrollHeight?S="SIZE_INCREASED":D<w.state.viewportHeight?S="VIEWPORT_HEIGHT_DECREASING":C<w.state.scrollTop?S="SCROLLING_UPWARDS":S="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:S,state:x}},Gj),tt((w,A)=>w&&w.atBottom===A.atBottom))),g=Ht(W(n,cn((w,{scrollHeight:A,scrollTop:C,viewportHeight:D})=>{if(Ex(w.scrollHeight,A))return{changed:!1,jump:0,scrollHeight:A,scrollTop:C};{const L=A-(C+D)<1;return w.scrollTop!==C&&L?{changed:!0,jump:w.scrollTop-C,scrollHeight:A,scrollTop:C}:{changed:!0,jump:0,scrollHeight:A,scrollTop:C}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),fe(w=>w.changed),re(w=>w.jump)),0);ce(W(y,re(w=>w.atBottom)),o),ce(W(o,Hn(50)),c);const E=K(fc);ce(W(n,re(({scrollTop:w})=>w),tt(),cn((w,A)=>st(m)?{direction:w.direction,prevScrollTop:A}:{direction:A<w.prevScrollTop?pc:fc,prevScrollTop:A},{direction:fc,prevScrollTop:0}),re(w=>w.direction)),E),ce(W(n,Hn(50),on($j)),E);const v=K(0);return ce(W(f,fe(w=>!w),on(0)),v),ce(W(s,Hn(100),Te(f),fe(([w,A])=>!!A),cn(([w,A],[C])=>[A,C],[0,0]),re(([w,A])=>A-w)),v),{atBottomState:y,atBottomStateChange:c,atBottomThreshold:u,atTopStateChange:l,atTopThreshold:d,isAtBottom:o,isAtTop:i,isScrolling:f,lastJumpDueToItemResize:g,scrollDirection:E,scrollVelocity:v}},et(Wt)),hc="top",bc="bottom",kx="none";function Cx(e,t,r){return typeof e=="number"?r===pc&&t===hc||r===fc&&t===bc?e:0:r===pc?t===hc?e.main:e.reverse:t===bc?e.main:e.reverse}function Tx(e,t){var r;return typeof e=="number"?e:(r=e[t])!=null?r:0}const am=$e(([{deviation:e,fixedHeaderHeight:t,headerHeight:r,scrollTop:n,viewportHeight:s}])=>{const a=Oe(),o=K(0),i=K(0),c=K(0),l=Ht(W(Et(me(n),me(s),me(r),me(a,cc),me(c),me(o),me(t),me(e),me(i)),re(([u,d,f,[m,y],g,E,v,w,A])=>{const C=u-w,D=E+v,L=Math.max(f-C,0);let T=kx;const h=Tx(A,hc),b=Tx(A,bc);return m-=w,m+=f+v,y+=f+v,y-=w,m>u+D-h&&(T=pc),y<u-L+d+b&&(T=fc),T!==kx?[Math.max(C-f-Cx(g,hc,T)-h,0),C-L-v+d+Cx(g,bc,T)+b]:null}),fe(u=>u!=null),tt(cc)),[0,0]);return{increaseViewportBy:i,listBoundary:a,overscan:c,topListHeight:o,visibleRange:l}},et(Wt),{singleton:!0});function Vj(e,t,r){if(Ru(t)){const n=yx(e,t);return[{index:qr(t.groupOffsetTree,n)[0],offset:0,size:0},{data:r==null?void 0:r[0],index:n,offset:0,size:0}]}return[{data:r==null?void 0:r[0],index:e,offset:0,size:0}]}const om={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Hu(e,t,r,n,s,a){const{lastIndex:o,lastOffset:i,lastSize:c}=s;let l=0,u=0;if(e.length>0){l=e[0].offset;const g=e[e.length-1];u=g.offset+g.size}const d=r-o,f=i+d*c+(d-1)*n,m=l,y=f-u;return{bottom:u,firstItemIndex:a,items:Ax(e,s,a),offsetBottom:y,offsetTop:l,top:m,topItems:Ax(t,s,a),topListHeight:t.reduce((g,E)=>E.size+g,0),totalCount:r}}function Sx(e,t,r,n,s,a){let o=0;if(r.groupIndices.length>0)for(const u of r.groupIndices){if(u-o>=e)break;o++}const i=e+o,c=sm(t,i),l=Array.from({length:i}).map((u,d)=>({data:a[d+c],index:d+c,offset:0,size:0}));return Hu(l,[],i,s,r,n)}function Ax(e,t,r){if(e.length===0)return[];if(!Ru(t))return e.map(l=>({...l,index:l.index+r,originalIndex:l.index}));const n=e[0].index,s=e[e.length-1].index,a=[],o=yo(t.groupOffsetTree,n,s);let i,c=0;for(const l of e){(!i||i.end<l.index)&&(i=o.shift(),c=t.groupIndices.indexOf(i.start));let u;l.index===i.start?u={index:c,type:"group"}:u={groupIndex:c,index:l.index-(c+1)+r},a.push({...u,data:l.data,offset:l.offset,originalIndex:l.index,size:l.size})}return a}function Px(e,t){var r;return e===void 0?0:typeof e=="number"?e:(r=e[t])!=null?r:0}const la=$e(([{data:e,firstItemIndex:t,gap:r,sizes:n,totalCount:s},a,{listBoundary:o,topListHeight:i,visibleRange:c},{initialTopMostItemIndex:l,scrolledToInitialItem:u},{topListHeight:d},f,{didMount:m},{recalcInProgress:y}])=>{const g=K([]),E=K(0),v=Oe(),w=K(0);ce(a.topItemsIndexes,g);const A=Ht(W(Et(m,y,me(c,cc),me(s),me(n),me(l),u,me(g),me(t),me(r),me(w),e),fe(([T,h,,b,,,,,,,,x])=>{const S=x&&x.length!==b;return T&&!h&&!S}),re(([,,[T,h],b,x,S,I,F,_,k,P,O])=>{var U,z,H,G;const J=x,{offsetTree:pe,sizeTree:he}=J,ie=st(E);if(b===0)return{...om,totalCount:b};if(T===0&&h===0)return ie===0?{...om,totalCount:b}:Sx(ie,S,x,_,k,O||[]);if(qe(he))return ie>0?null:Hu(Vj(sm(S,b),J,O),[],b,k,J,_);const de=[];if(F.length>0){const Se=F[0],Ee=F[F.length-1];let be=0;for(const Ze of yo(he,Se,Ee)){const Ye=Ze.value,Xe=Math.max(Ze.start,Se),Fr=Math.min(Ze.end,Ee);for(let Ot=Xe;Ot<=Fr;Ot++)de.push({data:O==null?void 0:O[Ot],index:Ot,offset:be,size:Ye}),be+=Ye}}if(!I)return Hu([],de,b,k,J,_);const Be=F.length>0?F[F.length-1]+1:0,Q=Oj(pe,T,h,Be);if(Q.length===0)return null;const ve=b-1,_e=Nu([],Se=>{for(const Ee of Q){const be=Ee.value;let Ze=be.offset,Ye=Ee.start;const Xe=be.size;if(be.offset<T){Ye+=Math.floor((T-be.offset+k)/(Xe+k));const Ot=Ye-Ee.start;Ze+=Ot*Xe+Ot*k}Ye<Be&&(Ze+=(Be-Ye)*Xe,Ye=Be);const Fr=Math.min(Ee.end,ve);for(let Ot=Ye;Ot<=Fr&&!(Ze>=h);Ot++)Se.push({data:O==null?void 0:O[Ot],index:Ot,offset:Ze,size:Xe}),Ze+=Xe+k}}),Ge=Px(P,hc),ot=Px(P,bc);if(_e.length>0&&(Ge>0||ot>0)){const Se=_e[0],Ee=_e[_e.length-1];if(Ge>0&&Se.index>Be){const be=Math.min(Ge,Se.index-Be),Ze=[];let Ye=Se.offset;for(let Xe=Se.index-1;Xe>=Se.index-be;Xe--){const Fr=(z=(U=yo(he,Xe,Xe)[0])==null?void 0:U.value)!=null?z:Se.size;Ye-=Fr+k,Ze.unshift({data:O==null?void 0:O[Xe],index:Xe,offset:Ye,size:Fr})}_e.unshift(...Ze)}if(ot>0&&Ee.index<ve){const be=Math.min(ot,ve-Ee.index);let Ze=Ee.offset+Ee.size+k;for(let Ye=Ee.index+1;Ye<=Ee.index+be;Ye++){const Xe=(G=(H=yo(he,Ye,Ye)[0])==null?void 0:H.value)!=null?G:Ee.size;_e.push({data:O==null?void 0:O[Ye],index:Ye,offset:Ze,size:Xe}),Ze+=Xe+k}}}return Hu(_e,de,b,k,J,_)}),fe(T=>T!==null),tt()),om);ce(W(e,fe(W0),re(T=>T==null?void 0:T.length)),s),ce(W(A,re(T=>T.topListHeight)),d),ce(d,i),ce(W(A,re(T=>[T.top,T.bottom])),o),ce(W(A,re(T=>T.items)),v);const C=br(W(A,fe(({items:T})=>T.length>0),Te(s,e),fe(([{items:T},h])=>T[T.length-1].originalIndex===h-1),re(([,T,h])=>[T-1,h]),tt(cc),re(([T])=>T))),D=br(W(A,Hn(200),fe(({items:T,topItems:h})=>T.length>0&&T[0].originalIndex===h.length),re(({items:T})=>T[0].index),tt())),L=br(W(A,fe(({items:T})=>T.length>0),re(({items:T})=>{let h=0,b=T.length-1;for(;T[h].type==="group"&&h<b;)h++;for(;T[b].type==="group"&&b>h;)b--;return{endIndex:T[b].index,startIndex:T[h].index}}),tt(hx)));return{endReached:C,initialItemCount:E,itemsRendered:v,listState:A,minOverscanItemCount:w,rangeChanged:L,startReached:D,topItemsIndexes:g,...f}},et(ln,wx,am,dc,uc,mc,ys,em),{singleton:!0}),Ix=$e(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:r,headerHeight:n},{listState:s}])=>{const a=Oe(),o=Ht(W(Et(r,e,n,t,s),re(([i,c,l,u,d])=>i+c+l+u+d.offsetBottom+d.bottom)),0);return ce(me(o),a),{totalListHeight:o,totalListHeightChanged:a}},et(Wt,la),{singleton:!0}),Wj=$e(([{viewportHeight:e},{totalListHeight:t}])=>{const r=K(!1),n=Ht(W(Et(r,e,t),fe(([s])=>s),re(([,s,a])=>Math.max(0,s-a)),Hn(0),tt()),0);return{alignToBottom:r,paddingTopAddition:n}},et(Wt,Ix),{singleton:!0}),Bx=$e(()=>({context:K(null)})),qj=({itemBottom:e,itemTop:t,locationParams:{align:r,behavior:n,...s},viewportBottom:a,viewportTop:o})=>t<o?{...s,align:r??"start",behavior:n}:e>a?{...s,align:r??"end",behavior:n}:null,Fx=$e(([{gap:e,sizes:t,totalCount:r},{fixedFooterHeight:n,fixedHeaderHeight:s,headerHeight:a,scrollingInProgress:o,scrollTop:i,viewportHeight:c},{scrollToIndex:l}])=>{const u=Oe();return ce(W(u,Te(t,c,r,a,s,n,i),Te(e),re(([[d,f,m,y,g,E,v,w],A])=>{const{align:C,behavior:D,calculateViewLocation:L=qj,done:T,...h}=d,b=gx(d,f,y-1),x=lc(b,f.offsetTree,A)+g+E,S=x+qr(f.sizeTree,b)[1],I=w+E,F=w+m-v,_=L({itemBottom:S,itemTop:x,locationParams:{align:C,behavior:D,...h},viewportBottom:F,viewportTop:I});return _?T&&Wr(W(o,fe(k=>!k),oa(st(o)?1:2)),T):T&&T(),_}),fe(d=>d!==null)),l),{scrollIntoView:u}},et(ln,Wt,uc,la,hs),{singleton:!0});function Ux(e){return e?e==="smooth"?"smooth":"auto":!1}const Yj=(e,t)=>typeof e=="function"?Ux(e(t)):t&&Ux(e),Kj=$e(([{listRefresh:e,totalCount:t,fixedItemSize:r,data:n},{atBottomState:s,isAtBottom:a},{scrollToIndex:o},{scrolledToInitialItem:i},{didMount:c,propsReady:l},{log:u},{scrollingInProgress:d},{context:f},{scrollIntoView:m}])=>{const y=K(!1),g=Oe();let E=null;function v(D){Ce(o,{align:"end",behavior:D,index:"LAST"})}je(W(Et(W(me(t),oa(1)),c),Te(me(y),a,i,d),re(([[D,L],T,h,b,x])=>{let S=L&&b,I="auto";return S&&(I=Yj(T,h||x),S=S&&!!I),{followOutputBehavior:I,shouldFollow:S,totalCount:D}}),fe(({shouldFollow:D})=>D)),({followOutputBehavior:D,totalCount:L})=>{E&&(E(),E=null),st(r)?requestAnimationFrame(()=>{st(u)("following output to ",{totalCount:L},nr.DEBUG),v(D)}):E=Wr(e,()=>{st(u)("following output to ",{totalCount:L},nr.DEBUG),v(D),E=null})});function w(D){const L=Wr(s,T=>{D&&!T.atBottom&&T.notAtBottomBecause==="SIZE_INCREASED"&&!E&&(st(u)("scrolling to bottom due to increased size",{},nr.DEBUG),v("auto"))});setTimeout(L,100)}je(W(Et(me(y),t,l),fe(([D,,L])=>D&&L),cn(({value:D},[,L])=>({refreshed:D===L,value:L}),{refreshed:!1,value:0}),fe(({refreshed:D})=>D),Te(y,t)),([,D])=>{st(i)&&w(D!==!1)}),je(g,()=>{w(st(y)!==!1)}),je(Et(me(y),s),([D,L])=>{D&&!L.atBottom&&L.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&v("auto")});const A=K(null),C=Oe();return ce(Y0(W(me(n),re(D=>{var L;return(L=D==null?void 0:D.length)!=null?L:0})),W(me(t))),C),je(W(Et(W(C,oa(1)),c),Te(me(A),i,d,f),re(([[D,L],T,h,b,x])=>L&&h&&(T==null?void 0:T({context:x,totalCount:D,scrollingInProgress:b}))),fe(D=>!!D),Hn(0)),D=>{E&&(E(),E=null),st(r)?requestAnimationFrame(()=>{st(u)("scrolling into view",{}),Ce(m,D)}):E=Wr(e,()=>{st(u)("scrolling into view",{}),Ce(m,D),E=null})}),{autoscrollToBottom:g,followOutput:y,scrollIntoViewOnChange:A}},et(ln,mc,uc,dc,ys,hs,Wt,Bx,Fx)),Zj=$e(([{data:e,firstItemIndex:t,gap:r,sizes:n},{initialTopMostItemIndex:s},{initialItemCount:a,listState:o},{didMount:i}])=>(ce(W(i,Te(a),fe(([,c])=>c!==0),Te(s,n,t,r,e),re(([[,c],l,u,d,f,m=[]])=>Sx(c,l,u,d,f,m))),o),{}),et(ln,dc,la,ys),{singleton:!0}),Xj=$e(([{didMount:e},{scrollTo:t},{listState:r}])=>{const n=K(0);return je(W(e,Te(n),fe(([,s])=>s!==0),re(([,s])=>({top:s}))),s=>{Wr(W(r,oa(1),fe(a=>a.items.length>1)),()=>{requestAnimationFrame(()=>{Ce(t,s)})})}),{initialScrollTop:n}},et(ys,Wt,la),{singleton:!0}),Ox=$e(([{scrollVelocity:e}])=>{const t=K(!1),r=Oe(),n=K(!1);return ce(W(e,Te(n,t,r),fe(([s,a])=>!!a),re(([s,a,o,i])=>{const{enter:c,exit:l}=a;if(o){if(l(s,i))return!1}else if(c(s,i))return!0;return o}),tt()),t),je(W(Et(t,e,r),Te(n)),([[s,a,o],i])=>{s&&i&&i.change&&i.change(a,o)}),{isSeeking:t,scrollSeekConfiguration:n,scrollSeekRangeChanged:r,scrollVelocity:e}},et(mc),{singleton:!0}),im=$e(([{scrollContainerState:e,scrollTo:t}])=>{const r=Oe(),n=Oe(),s=Oe(),a=K(!1),o=K(void 0);return ce(W(Et(r,n),re(([{scrollHeight:i,scrollTop:c,viewportHeight:l},{offsetTop:u}])=>({scrollHeight:i,scrollTop:Math.max(0,c-u),viewportHeight:l}))),e),ce(W(t,Te(n),re(([i,{offsetTop:c}])=>({...i,top:i.top+c}))),s),{customScrollParent:o,useWindowScroll:a,windowScrollContainerState:r,windowScrollTo:s,windowViewportRect:n}},et(Wt)),Qj=$e(([{sizeRanges:e,sizes:t},{headerHeight:r,scrollTop:n},{initialTopMostItemIndex:s},{didMount:a},{useWindowScroll:o,windowScrollContainerState:i,windowViewportRect:c}])=>{const l=Oe(),u=K(void 0),d=K(null),f=K(null);return ce(i,d),ce(c,f),je(W(l,Te(t,n,o,d,f,r)),([m,y,g,E,v,w,A])=>{const C=_j(y.sizeTree);E&&v!==null&&w!==null&&(g=v.scrollTop-w.offsetTop),g-=A,m({ranges:C,scrollTop:g})}),ce(W(u,fe(W0),re(Jj)),s),ce(W(a,Te(u),fe(([,m])=>m!==void 0),tt(),re(([,m])=>m.ranges)),e),{getState:l,restoreStateFrom:u}},et(ln,Wt,dc,ys,im));function Jj(e){return{align:"start",index:0,offset:e.scrollTop}}const eV=$e(([{topItemsIndexes:e}])=>{const t=K(0);return ce(W(t,fe(r=>r>=0),re(r=>Array.from({length:r}).map((n,s)=>s))),e),{topItemCount:t}},et(la));function Dx(e){let t=!1,r;return()=>(t||(t=!0,r=e()),r)}const tV=Dx(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),rV=$e(([{deviation:e,scrollBy:t,scrollingInProgress:r,scrollTop:n},{isAtBottom:s,isScrolling:a,lastJumpDueToItemResize:o,scrollDirection:i},{listState:c},{beforeUnshiftWith:l,gap:u,shiftWithOffset:d,sizes:f},{log:m},{recalcInProgress:y}])=>{const g=br(W(c,Te(o),cn(([,v,w,A],[{bottom:C,items:D,offsetBottom:L,totalCount:T},h])=>{const b=C+L;let x=0;return w===T&&v.length>0&&D.length>0&&(D[0].originalIndex===0&&v[0].originalIndex===0||(x=b-A,x!==0&&(x+=h))),[x,D,T,b]},[0,[],0,0]),fe(([v])=>v!==0),Te(n,i,r,s,m,y),fe(([,v,w,A,,,C])=>!C&&!A&&v!==0&&w===pc),re(([[v],,,,,w])=>(w("Upward scrolling compensation",{amount:v},nr.DEBUG),v))));function E(v){v>0?(Ce(t,{behavior:"auto",top:-v}),Ce(e,0)):(Ce(e,0),Ce(t,{behavior:"auto",top:-v}))}return je(W(g,Te(e,a)),([v,w,A])=>{A&&tV()?Ce(e,w-v):E(-v)}),je(W(Et(Ht(a,!1),e,y),fe(([v,w,A])=>!v&&!A&&w!==0),re(([v,w])=>w),Hn(1)),E),ce(W(d,re(v=>({top:-v}))),t),je(W(l,Te(f,u),re(([v,{groupIndices:w,lastSize:A,sizeTree:C},D])=>{function L(T){return T*(A+D)}if(w.length===0)return L(v);{let T=0;const h=ic(C,0);let b=0,x=0;for(;b<v;){b++,T+=h;let S=w.length===x+1?1/0:w[x+1]-w[x]-1;b+S>v&&(T-=h,S=v-b+1),b+=S,T+=L(S),x++}return T}})),v=>{Ce(e,v),requestAnimationFrame(()=>{Ce(t,{top:v}),requestAnimationFrame(()=>{Ce(e,0),Ce(y,!1)})})}),{deviation:e}},et(Wt,mc,la,ln,hs,em)),nV=$e(([e,t,r,n,s,a,o,i,c,l,u])=>({...e,...t,...r,...n,...s,...a,...o,...i,...c,...l,...u}),et(am,Zj,ys,Ox,Ix,Xj,Wj,im,Fx,hs,Bx)),_x=$e(([{data:e,defaultItemSize:t,firstItemIndex:r,fixedItemSize:n,fixedGroupSize:s,gap:a,groupIndices:o,heightEstimates:i,itemSize:c,sizeRanges:l,sizes:u,statefulTotalCount:d,totalCount:f,trackItemSizes:m},{initialItemFinalLocationReached:y,initialTopMostItemIndex:g,scrolledToInitialItem:E},v,w,A,C,{scrollToIndex:D},L,{topItemCount:T},{groupCounts:h},b])=>{const{listState:x,minOverscanItemCount:S,topItemsIndexes:I,rangeChanged:F,..._}=C;return ce(F,b.scrollSeekRangeChanged),ce(W(b.windowViewportRect,re(k=>k.visibleHeight)),v.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:r,fixedItemHeight:n,fixedGroupHeight:s,gap:a,groupCounts:h,heightEstimates:i,initialItemFinalLocationReached:y,initialTopMostItemIndex:g,scrolledToInitialItem:E,sizeRanges:l,topItemCount:T,topItemsIndexes:I,totalCount:f,...A,groupIndices:o,itemSize:c,listState:x,minOverscanItemCount:S,scrollToIndex:D,statefulTotalCount:d,trackItemSizes:m,rangeChanged:F,..._,...b,...v,sizes:u,...w}},et(ln,dc,Wt,Qj,Kj,la,uc,rV,eV,wx,nV));function sV(e,t){const r={},n={};let s=0;const a=e.length;for(;s<a;)n[e[s]]=1,s+=1;for(const o in t)Object.hasOwn(n,o)||(r[o]=t[o]);return r}const $u=typeof document<"u"?M.useLayoutEffect:M.useEffect;function Mx(e,t,r){const n=Object.keys(t.required||{}),s=Object.keys(t.optional||{}),a=Object.keys(t.methods||{}),o=Object.keys(t.events||{}),i=M.createContext({});function c(E,v){E.propsReady&&Ce(E.propsReady,!1);for(const w of n){const A=E[t.required[w]];Ce(A,v[w])}for(const w of s)if(w in v){const A=E[t.optional[w]];Ce(A,v[w])}E.propsReady&&Ce(E.propsReady,!0)}function l(E){return a.reduce((v,w)=>(v[w]=A=>{const C=E[t.methods[w]];Ce(C,A)},v),{})}function u(E){return o.reduce((v,w)=>(v[w]=wj(E[t.events[w]]),v),{})}const d=M.forwardRef((E,v)=>{const{children:w,...A}=E,[C]=M.useState(()=>Nu(Ej(e),T=>{c(T,A)})),[D]=M.useState(sx(u,C));$u(()=>{for(const T of o)T in A&&je(D[T],A[T]);return()=>{Object.values(D).map(q0)}},[A,D,C]),$u(()=>{c(C,A)}),M.useImperativeHandle(v,rx(l(C)));const L=r;return B.jsx(i.Provider,{value:C,children:r?B.jsx(L,{...sV([...n,...s,...o],A),children:w}):w})}),f=E=>{const v=M.useContext(i);return M.useCallback(w=>{Ce(v[E],w)},[v,E])},m=E=>{const v=M.useContext(i)[E],w=M.useCallback(A=>je(v,A),[v]);return M.useSyncExternalStore(w,()=>st(v),()=>st(v))},y=E=>{const v=M.useContext(i)[E],[w,A]=M.useState(sx(st,v));return $u(()=>je(v,C=>{C!==w&&A(rx(C))}),[v,w]),w},g=M.version.startsWith("18")?m:y;return{Component:d,useEmitter:(E,v)=>{const w=M.useContext(i)[E];$u(()=>je(w,v),[v,w])},useEmitterValue:g,usePublisher:f}}const Nx=M.createContext(void 0),Lx=M.createContext(void 0),zx=typeof document<"u"?M.useLayoutEffect:M.useEffect;function cm(e){return"self"in e}function aV(e){return"body"in e}function Rx(e,t,r,n=ho,s,a){const o=M.useRef(null),i=M.useRef(null),c=M.useRef(null),l=M.useCallback(f=>{let m,y,g;const E=f.target;if(aV(E)||cm(E)){const w=cm(E)?E:E.defaultView;g=a?w.scrollX:w.scrollY,m=a?w.document.documentElement.scrollWidth:w.document.documentElement.scrollHeight,y=a?w.innerWidth:w.innerHeight}else g=a?E.scrollLeft:E.scrollTop,m=a?E.scrollWidth:E.scrollHeight,y=a?E.offsetWidth:E.offsetHeight;const v=()=>{e({scrollHeight:m,scrollTop:Math.max(g,0),viewportHeight:y})};f.suppressFlushSync?v():ka.flushSync(v),i.current!==null&&(g===i.current||g<=0||g===m-y)&&(i.current=null,t(!0),c.current&&(clearTimeout(c.current),c.current=null))},[e,t,a]);M.useEffect(()=>{const f=s||o.current;return n(s||o.current),l({suppressFlushSync:!0,target:f}),f.addEventListener("scroll",l,{passive:!0}),()=>{n(null),f.removeEventListener("scroll",l)}},[o,l,r,n,s]);function u(f){const m=o.current;if(!m||(a?"offsetWidth"in m&&m.offsetWidth===0:"offsetHeight"in m&&m.offsetHeight===0))return;const y=f.behavior==="smooth";let g,E,v;cm(m)?(E=Math.max(bs(m.document.documentElement,a?"width":"height"),a?m.document.documentElement.scrollWidth:m.document.documentElement.scrollHeight),g=a?m.innerWidth:m.innerHeight,v=a?window.scrollX:window.scrollY):(E=m[a?"scrollWidth":"scrollHeight"],g=bs(m,a?"width":"height"),v=m[a?"scrollLeft":"scrollTop"]);const w=E-g;if(f.top=Math.ceil(Math.max(Math.min(w,f.top),0)),Ex(g,E)||f.top===v){e({scrollHeight:E,scrollTop:v,viewportHeight:g}),y&&t(!0);return}y?(i.current=f.top,c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{c.current=null,i.current=null,t(!0)},1e3)):i.current=null,a&&(f={behavior:f.behavior,left:f.top}),m.scrollTo(f)}function d(f){a&&(f={behavior:f.behavior,left:f.top}),o.current.scrollBy(f)}return{scrollByCallback:d,scrollerRef:o,scrollToCallback:u}}const lm="-webkit-sticky",Hx="sticky",um=Dx(()=>{if(typeof document>"u")return Hx;const e=document.createElement("div");return e.style.position=lm,e.style.position===lm?lm:Hx});function dm(e){return e}const oV=$e(()=>{const e=K(i=>`Item ${i}`),t=K(i=>`Group ${i}`),r=K({}),n=K(dm),s=K("div"),a=K(ho),o=(i,c=null)=>Ht(W(r,re(l=>l[i]),tt()),c);return{components:r,computeItemKey:n,EmptyPlaceholder:o("EmptyPlaceholder"),FooterComponent:o("Footer"),GroupComponent:o("Group","div"),groupContent:t,HeaderComponent:o("Header"),HeaderFooterTag:s,ItemComponent:o("Item","div"),itemContent:e,ListComponent:o("List","div"),ScrollerComponent:o("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:o("ScrollSeekPlaceholder"),TopItemListComponent:o("TopItemList")}}),iV=$e(([e,t])=>({...e,...t}),et(_x,oV)),cV=({height:e})=>B.jsx("div",{style:{height:e}}),lV={overflowAnchor:"none",position:um(),zIndex:1},$x={overflowAnchor:"none"},uV={...$x,display:"inline-block",height:"100%"},Gx=M.memo(function({showTopList:e=!1}){const t=ye("listState"),r=Pr("sizeRanges"),n=ye("useWindowScroll"),s=ye("customScrollParent"),a=Pr("windowScrollContainerState"),o=Pr("scrollContainerState"),i=s||n?a:o,c=ye("itemContent"),l=ye("context"),u=ye("groupContent"),d=ye("trackItemSizes"),f=ye("itemSize"),m=ye("log"),y=Pr("gap"),g=ye("horizontalDirection"),{callbackRef:E}=Tj(r,f,d,e?ho:i,m,y,s,g,ye("skipAnimationFrameInResizeObserver")),[v,w]=M.useState(0);pm("deviation",_=>{v!==_&&w(_)});const A=ye("EmptyPlaceholder"),C=ye("ScrollSeekPlaceholder")||cV,D=ye("ListComponent"),L=ye("ItemComponent"),T=ye("GroupComponent"),h=ye("computeItemKey"),b=ye("isSeeking"),x=ye("groupIndices").length>0,S=ye("alignToBottom"),I=ye("initialItemFinalLocationReached"),F=e?{}:{boxSizing:"border-box",...g?{display:"inline-block",height:"100%",marginLeft:v!==0?v:S?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:v!==0?v:S?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...I?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&A?B.jsx(A,{...$t(A,l)}):B.jsx(D,{...$t(D,l),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:E,style:F,children:(e?t.topItems:t.items).map(_=>{const k=_.originalIndex,P=h(k+t.firstItemIndex,_.data,l);return b?M.createElement(C,{...$t(C,l),height:_.size,index:_.index,key:P,type:_.type||"item",..._.type==="group"?{}:{groupIndex:_.groupIndex}}):_.type==="group"?M.createElement(T,{...$t(T,l),"data-index":k,"data-item-index":_.index,"data-known-size":_.size,key:P,style:lV},u(_.index,l)):M.createElement(L,{...$t(L,l),...mV(L,_.data),"data-index":k,"data-item-group-index":_.groupIndex,"data-item-index":_.index,"data-known-size":_.size,key:P,style:g?uV:$x},x?c(_.index,_.groupIndex,_.data,l):c(_.index,_.data,l))})})}),dV={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},pV={outline:"none",overflowX:"auto",position:"relative"},Gu=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),fV={position:um(),top:0,width:"100%",zIndex:1};function $t(e,t){if(typeof e!="string")return{context:t}}function mV(e,t){return{item:typeof e=="string"?void 0:t}}const hV=M.memo(function(){const e=ye("HeaderComponent"),t=Pr("headerHeight"),r=ye("HeaderFooterTag"),n=ia(M.useMemo(()=>a=>{t(bs(a,"height"))},[t]),!0,ye("skipAnimationFrameInResizeObserver")),s=ye("context");return e?B.jsx(r,{ref:n,children:B.jsx(e,{...$t(e,s)})}):null}),bV=M.memo(function(){const e=ye("FooterComponent"),t=Pr("footerHeight"),r=ye("HeaderFooterTag"),n=ia(M.useMemo(()=>a=>{t(bs(a,"height"))},[t]),!0,ye("skipAnimationFrameInResizeObserver")),s=ye("context");return e?B.jsx(r,{ref:n,children:B.jsx(e,{...$t(e,s)})}):null});function jx({useEmitter:e,useEmitterValue:t,usePublisher:r}){return M.memo(function({children:n,style:s,context:a,...o}){const i=r("scrollContainerState"),c=t("ScrollerComponent"),l=r("smoothScrollTargetReached"),u=t("scrollerRef"),d=t("horizontalDirection")||!1,{scrollByCallback:f,scrollerRef:m,scrollToCallback:y}=Rx(i,l,c,u,void 0,d);return e("scrollTo",y),e("scrollBy",f),B.jsx(c,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:m,style:{...d?pV:dV,...s},tabIndex:0,...o,...$t(c,a),children:n})})}function Vx({useEmitter:e,useEmitterValue:t,usePublisher:r}){return M.memo(function({children:n,style:s,context:a,...o}){const i=r("windowScrollContainerState"),c=t("ScrollerComponent"),l=r("smoothScrollTargetReached"),u=t("totalListHeight"),d=t("deviation"),f=t("customScrollParent"),m=M.useRef(null),y=t("scrollerRef"),{scrollByCallback:g,scrollerRef:E,scrollToCallback:v}=Rx(i,l,c,y,f);return zx(()=>{var w;return E.current=f||((w=m.current)==null?void 0:w.ownerDocument.defaultView),()=>{E.current=null}},[E,f]),e("windowScrollTo",v),e("scrollBy",g),B.jsx(c,{ref:m,"data-virtuoso-scroller":!0,style:{position:"relative",...s,...u!==0?{height:u+d}:{}},...o,...$t(c,a),children:n})})}const yV=({children:e})=>{const t=M.useContext(Nx),r=Pr("viewportHeight"),n=Pr("fixedItemHeight"),s=ye("alignToBottom"),a=ye("horizontalDirection"),o=M.useMemo(()=>nx(r,c=>bs(c,a?"width":"height")),[r,a]),i=ia(o,!0,ye("skipAnimationFrameInResizeObserver"));return M.useEffect(()=>{t&&(r(t.viewportHeight),n(t.itemHeight))},[t,r,n]),B.jsx("div",{"data-viewport-type":"element",ref:i,style:Gu(s),children:e})},gV=({children:e})=>{const t=M.useContext(Nx),r=Pr("windowViewportRect"),n=Pr("fixedItemHeight"),s=ye("customScrollParent"),a=cx(r,s,ye("skipAnimationFrameInResizeObserver")),o=ye("alignToBottom");return M.useEffect(()=>{t&&(n(t.itemHeight),r({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,r,n]),B.jsx("div",{"data-viewport-type":"window",ref:a,style:Gu(o),children:e})},xV=({children:e})=>{const t=ye("TopItemListComponent")||"div",r=ye("headerHeight"),n={...fV,marginTop:`${r}px`},s=ye("context");return B.jsx(t,{style:n,...$t(t,s),children:e})},wV=M.memo(function(e){const t=ye("useWindowScroll"),r=ye("topItemsIndexes").length>0,n=ye("customScrollParent"),s=ye("context");return B.jsxs(n||t?kV:EV,{...e,context:s,children:[r&&B.jsx(xV,{children:B.jsx(Gx,{showTopList:!0})}),B.jsxs(n||t?gV:yV,{children:[B.jsx(hV,{}),B.jsx(Gx,{}),B.jsx(bV,{})]})]})}),{Component:vV,useEmitter:pm,useEmitterValue:ye,usePublisher:Pr}=Mx(iV,{required:{},optional:{restoreStateFrom:"restoreStateFrom",context:"context",followOutput:"followOutput",scrollIntoViewOnChange:"scrollIntoViewOnChange",itemContent:"itemContent",groupContent:"groupContent",overscan:"overscan",increaseViewportBy:"increaseViewportBy",minOverscanItemCount:"minOverscanItemCount",totalCount:"totalCount",groupCounts:"groupCounts",topItemCount:"topItemCount",firstItemIndex:"firstItemIndex",initialTopMostItemIndex:"initialTopMostItemIndex",components:"components",atBottomThreshold:"atBottomThreshold",atTopThreshold:"atTopThreshold",computeItemKey:"computeItemKey",defaultItemHeight:"defaultItemHeight",fixedGroupHeight:"fixedGroupHeight",fixedItemHeight:"fixedItemHeight",heightEstimates:"heightEstimates",itemSize:"itemSize",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"HeaderFooterTag",data:"data",initialItemCount:"initialItemCount",initialScrollTop:"initialScrollTop",alignToBottom:"alignToBottom",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",horizontalDirection:"horizontalDirection",skipAnimationFrameInResizeObserver:"skipAnimationFrameInResizeObserver"},methods:{scrollToIndex:"scrollToIndex",scrollIntoView:"scrollIntoView",scrollTo:"scrollTo",scrollBy:"scrollBy",autoscrollToBottom:"autoscrollToBottom",getState:"getState"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",totalListHeightChanged:"totalListHeightChanged",itemsRendered:"itemsRendered",groupIndices:"groupIndices"}},wV),EV=jx({useEmitter:pm,useEmitterValue:ye,usePublisher:Pr}),kV=Vx({useEmitter:pm,useEmitterValue:ye,usePublisher:Pr}),CV=vV;et(_x,$e(()=>{const e=K(l=>B.jsxs("td",{children:["Item $",l]})),t=K(null),r=K(l=>B.jsxs("td",{colSpan:1e3,children:["Group ",l]})),n=K(null),s=K(null),a=K({}),o=K(dm),i=K(ho),c=(l,u=null)=>Ht(W(a,re(d=>d[l]),tt()),u);return{components:a,computeItemKey:o,context:t,EmptyPlaceholder:c("EmptyPlaceholder"),FillerRow:c("FillerRow"),fixedFooterContent:s,fixedHeaderContent:n,itemContent:e,groupContent:r,ScrollerComponent:c("Scroller","div"),scrollerRef:i,ScrollSeekPlaceholder:c("ScrollSeekPlaceholder"),TableBodyComponent:c("TableBody","tbody"),TableComponent:c("Table","table"),TableFooterComponent:c("TableFoot","tfoot"),TableHeadComponent:c("TableHead","thead"),TableRowComponent:c("TableRow","tr"),GroupComponent:c("Group","tr")}})),um();const Wx={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},TV={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:qx,floor:ju,max:yc,min:fm,round:Yx}=Math;function Kx(e,t,r){return Array.from({length:t-e+1}).map((n,s)=>({data:r===null?null:r[s+e],index:s+e}))}function SV(e){return{...TV,items:e}}function Vu(e,t){return e&&e.width===t.width&&e.height===t.height}function AV(e,t){return e&&e.column===t.column&&e.row===t.row}const PV=$e(([{increaseViewportBy:e,listBoundary:t,overscan:r,visibleRange:n},{footerHeight:s,headerHeight:a,scrollBy:o,scrollContainerState:i,scrollTo:c,scrollTop:l,smoothScrollTargetReached:u,viewportHeight:d},f,m,{didMount:y,propsReady:g},{customScrollParent:E,useWindowScroll:v,windowScrollContainerState:w,windowScrollTo:A,windowViewportRect:C},D])=>{const L=K(0),T=K(0),h=K(Wx),b=K({height:0,width:0}),x=K({height:0,width:0}),S=Oe(),I=Oe(),F=K(0),_=K(null),k=K({column:0,row:0}),P=Oe(),O=Oe(),U=K(!1),z=K(0),H=K(!0),G=K(!1),J=K(!1);je(W(y,Te(z),fe(([Q,ve])=>!!ve)),()=>{Ce(H,!1)}),je(W(Et(y,H,x,b,z,G),fe(([Q,ve,_e,Ge,,ot])=>Q&&!ve&&_e.height!==0&&Ge.height!==0&&!ot)),([,,,,Q])=>{Ce(G,!0),nm(1,()=>{Ce(S,Q)}),Wr(W(l),()=>{Ce(t,[0,0]),Ce(H,!0)})}),ce(W(O,fe(Q=>Q!=null&&Q.scrollTop>0),on(0)),T),je(W(y,Te(O),fe(([,Q])=>Q!=null)),([,Q])=>{Q&&(Ce(b,Q.viewport),Ce(x,Q.item),Ce(k,Q.gap),Q.scrollTop>0&&(Ce(U,!0),Wr(W(l,oa(1)),ve=>{Ce(U,!1)}),Ce(c,{top:Q.scrollTop})))}),ce(W(b,re(({height:Q})=>Q)),d),ce(W(Et(me(b,Vu),me(x,Vu),me(k,(Q,ve)=>Q&&Q.column===ve.column&&Q.row===ve.row),me(l)),re(([Q,ve,_e,Ge])=>({gap:_e,item:ve,scrollTop:Ge,viewport:Q}))),P),ce(W(Et(me(L),n,me(k,AV),me(x,Vu),me(b,Vu),me(_),me(T),me(U),me(H),me(z)),fe(([,,,,,,,Q])=>!Q),re(([Q,[ve,_e],Ge,ot,Se,Ee,be,,Ze,Ye])=>{const{column:Xe,row:Fr}=Ge,{height:Ot,width:wm}=ot,{width:C5}=Se;if(be===0&&(Q===0||C5===0))return Wx;if(wm===0){const I5=sm(Ye,Q),NW=I5+Math.max(be-1,0);return SV(Kx(I5,NW,Ee))}const qu=Zx(C5,wm,Xe);let Bo,Ea;Ze?ve===0&&_e===0&&be>0?(Bo=0,Ea=be-1):(Bo=qu*ju((ve+Fr)/(Ot+Fr)),Ea=qu*qx((_e+Fr)/(Ot+Fr))-1,Ea=fm(Q-1,yc(Ea,qu-1)),Bo=fm(Ea,yc(0,Bo))):(Bo=0,Ea=-1);const T5=Kx(Bo,Ea,Ee),{bottom:S5,top:A5}=Xx(Se,Ge,ot,T5),P5=qx(Q/qu),MW=P5*Ot+(P5-1)*Fr-S5;return{bottom:S5,itemHeight:Ot,items:T5,itemWidth:wm,offsetBottom:MW,offsetTop:A5,top:A5}})),h),ce(W(_,fe(Q=>Q!==null),re(Q=>Q.length)),L),ce(W(Et(b,x,h,k),fe(([Q,ve,{items:_e}])=>_e.length>0&&ve.height!==0&&Q.height!==0),re(([Q,ve,{items:_e},Ge])=>{const{bottom:ot,top:Se}=Xx(Q,Ge,ve,_e);return[Se,ot]}),tt(cc)),t);const pe=K(!1);ce(W(l,Te(pe),re(([Q,ve])=>ve||Q!==0)),pe);const he=br(W(Et(h,L),fe(([{items:Q}])=>Q.length>0),Te(pe),fe(([[Q,ve],_e])=>{const Ge=Q.items[Q.items.length-1].index===ve-1;return(_e||Q.bottom>0&&Q.itemHeight>0&&Q.offsetBottom===0&&Q.items.length===ve)&&Ge}),re(([[,Q]])=>Q-1),tt())),ie=br(W(me(h),fe(({items:Q})=>Q.length>0&&Q[0].index===0),on(0),tt())),de=br(W(me(h),Te(U),fe(([{items:Q},ve])=>Q.length>0&&!ve),re(([{items:Q}])=>({endIndex:Q[Q.length-1].index,startIndex:Q[0].index})),tt(hx),Hn(0)));ce(de,m.scrollSeekRangeChanged),ce(W(S,Te(b,x,L,k),re(([Q,ve,_e,Ge,ot])=>{const Se=vx(Q),{align:Ee,behavior:be,offset:Ze}=Se;let Ye=Se.index;Ye==="LAST"&&(Ye=Ge-1),Ye=yc(0,Ye,fm(Ge-1,Ye));let Xe=mm(ve,ot,_e,Ye);return Ee==="end"?Xe=Yx(Xe-ve.height+_e.height):Ee==="center"&&(Xe=Yx(Xe-ve.height/2+_e.height/2)),Ze&&(Xe+=Ze),{behavior:be,top:Xe}})),c);const Be=Ht(W(h,re(Q=>Q.offsetBottom+Q.bottom)),0);return ce(W(C,re(Q=>({height:Q.visibleHeight,width:Q.visibleWidth}))),b),{customScrollParent:E,data:_,deviation:F,footerHeight:s,gap:k,headerHeight:a,increaseViewportBy:e,initialItemCount:T,itemDimensions:x,overscan:r,restoreStateFrom:O,scrollBy:o,scrollContainerState:i,scrollHeight:I,scrollTo:c,scrollToIndex:S,scrollTop:l,smoothScrollTargetReached:u,totalCount:L,useWindowScroll:v,viewportDimensions:b,windowScrollContainerState:w,windowScrollTo:A,windowViewportRect:C,...m,gridState:h,horizontalDirection:J,initialTopMostItemIndex:z,totalListHeight:Be,...f,endReached:he,propsReady:g,rangeChanged:de,startReached:ie,stateChanged:P,stateRestoreInProgress:U,...D}},et(am,Wt,mc,Ox,ys,im,hs));function Zx(e,t,r){return yc(1,ju((e+r)/(ju(t)+r)))}function Xx(e,t,r,n){const{height:s}=r;if(s===void 0||n.length===0)return{bottom:0,top:0};const a=mm(e,t,r,n[0].index);return{bottom:mm(e,t,r,n[n.length-1].index)+s,top:a}}function mm(e,t,r,n){const s=Zx(e.width,r.width,t.column),a=ju(n/s),o=a*r.height+yc(0,a-1)*t.row;return o>0?o+t.row:o}const IV=$e(()=>{const e=K(d=>`Item ${d}`),t=K({}),r=K(null),n=K("virtuoso-grid-item"),s=K("virtuoso-grid-list"),a=K(dm),o=K("div"),i=K(ho),c=(d,f=null)=>Ht(W(t,re(m=>m[d]),tt()),f),l=K(!1),u=K(!1);return ce(me(u),l),{components:t,computeItemKey:a,context:r,FooterComponent:c("Footer"),HeaderComponent:c("Header"),headerFooterTag:o,itemClassName:n,ItemComponent:c("Item","div"),itemContent:e,listClassName:s,ListComponent:c("List","div"),readyStateChanged:l,reportReadyState:u,ScrollerComponent:c("Scroller","div"),scrollerRef:i,ScrollSeekPlaceholder:c("ScrollSeekPlaceholder","div")}}),BV=$e(([e,t])=>({...e,...t}),et(PV,IV)),FV=M.memo(function(){const e=at("gridState"),t=at("listClassName"),r=at("itemClassName"),n=at("itemContent"),s=at("computeItemKey"),a=at("isSeeking"),o=Ir("scrollHeight"),i=at("ItemComponent"),c=at("ListComponent"),l=at("ScrollSeekPlaceholder"),u=at("context"),d=Ir("itemDimensions"),f=Ir("gap"),m=at("log"),y=at("stateRestoreInProgress"),g=Ir("reportReadyState"),E=ia(M.useMemo(()=>v=>{const w=v.parentElement.parentElement.scrollHeight;o(w);const A=v.firstChild;if(A){const{height:C,width:D}=A.getBoundingClientRect();d({height:C,width:D})}f({column:Jx("column-gap",getComputedStyle(v).columnGap,m),row:Jx("row-gap",getComputedStyle(v).rowGap,m)})},[o,d,f,m]),!0,!1);return zx(()=>{e.itemHeight>0&&e.itemWidth>0&&g(!0)},[e]),y?null:B.jsx(c,{className:t,ref:E,...$t(c,u),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(v=>{const w=s(v.index,v.data,u);return a?B.jsx(l,{...$t(l,u),height:e.itemHeight,index:v.index,width:e.itemWidth},w):M.createElement(i,{...$t(i,u),className:r,"data-index":v.index,key:w},n(v.index,v.data,u))})})}),UV=M.memo(function(){const e=at("HeaderComponent"),t=Ir("headerHeight"),r=at("headerFooterTag"),n=ia(M.useMemo(()=>a=>{t(bs(a,"height"))},[t]),!0,!1),s=at("context");return e?B.jsx(r,{ref:n,children:B.jsx(e,{...$t(e,s)})}):null}),OV=M.memo(function(){const e=at("FooterComponent"),t=Ir("footerHeight"),r=at("headerFooterTag"),n=ia(M.useMemo(()=>a=>{t(bs(a,"height"))},[t]),!0,!1),s=at("context");return e?B.jsx(r,{ref:n,children:B.jsx(e,{...$t(e,s)})}):null}),DV=({children:e})=>{const t=M.useContext(Lx),r=Ir("itemDimensions"),n=Ir("viewportDimensions"),s=ia(M.useMemo(()=>a=>{n(a.getBoundingClientRect())},[n]),!0,!1);return M.useEffect(()=>{t&&(n({height:t.viewportHeight,width:t.viewportWidth}),r({height:t.itemHeight,width:t.itemWidth}))},[t,n,r]),B.jsx("div",{ref:s,style:Gu(!1),children:e})},_V=({children:e})=>{const t=M.useContext(Lx),r=Ir("windowViewportRect"),n=Ir("itemDimensions"),s=at("customScrollParent"),a=cx(r,s,!1);return M.useEffect(()=>{t&&(n({height:t.itemHeight,width:t.itemWidth}),r({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,r,n]),B.jsx("div",{ref:a,style:Gu(!1),children:e})},MV=M.memo(function({...e}){const t=at("useWindowScroll"),r=at("customScrollParent"),n=r||t?LV:NV,s=r||t?_V:DV,a=at("context");return B.jsx(n,{...e,...$t(n,a),children:B.jsxs(s,{children:[B.jsx(UV,{}),B.jsx(FV,{}),B.jsx(OV,{})]})})}),{useEmitter:Qx,useEmitterValue:at,usePublisher:Ir}=Mx(BV,{optional:{context:"context",totalCount:"totalCount",overscan:"overscan",itemContent:"itemContent",components:"components",computeItemKey:"computeItemKey",data:"data",initialItemCount:"initialItemCount",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"headerFooterTag",listClassName:"listClassName",itemClassName:"itemClassName",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",restoreStateFrom:"restoreStateFrom",initialTopMostItemIndex:"initialTopMostItemIndex",increaseViewportBy:"increaseViewportBy"},methods:{scrollTo:"scrollTo",scrollBy:"scrollBy",scrollToIndex:"scrollToIndex"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",stateChanged:"stateChanged",readyStateChanged:"readyStateChanged"}},MV),NV=jx({useEmitter:Qx,useEmitterValue:at,usePublisher:Ir}),LV=Vx({useEmitter:Qx,useEmitterValue:at,usePublisher:Ir});function Jx(e,t,r){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&r(`${e} was not resolved to pixel value correctly`,t,nr.WARN),t==="normal"?0:parseInt(t??"0",10)}var hm={},e5;function zV(){if(e5)return hm;e5=1;var e=uu.GenIcon;return hm.AiFillQuestionCircle=function(r){return e({tag:"svg",attr:{viewBox:"0 0 1024 1024"},child:[{tag:"path",attr:{d:"M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 708c-22.1 0-40-17.9-40-40s17.9-40 40-40 40 17.9 40 40-17.9 40-40 40zm62.9-219.5a48.3 48.3 0 0 0-30.9 44.8V620c0 4.4-3.6 8-8 8h-48c-4.4 0-8-3.6-8-8v-21.5c0-23.1 6.7-45.9 19.9-64.9 12.9-18.6 30.9-32.8 52.1-40.9 34-13.1 56-41.6 56-72.7 0-44.1-43.1-80-96-80s-96 35.9-96 80v7.6c0 4.4-3.6 8-8 8h-48c-4.4 0-8-3.6-8-8V420c0-39.3 17.2-76 48.4-103.3C430.4 290.4 470 276 512 276s81.6 14.5 111.6 40.7C654.8 344 672 380.7 672 420c0 57.8-38.1 109.8-97.1 132.5z"}}]})(r)},hm}var RV=zV();function HV({logo:e,className:t="",style:r={},alt:n="Token logo"}){const[s,a]=M.useState(!1);return M.useEffect(()=>{a(!1)},[e]),e&&!s?B.jsx("img",{alt:n,style:r,onError:()=>a(!0),className:`twap-token-logo ${t}`,src:e}):B.jsx(RV.AiFillQuestionCircle,{style:{width:20,height:20},className:"twap-token-svg"})}const $V=()=>B.jsx("div",{className:"twap-orders__loader",children:B.jsx("p",{children:"Loading..."})}),GV=()=>{const{isLoading:e}=Du(),t=q2(),r=Z(a=>a.state.orderIdsToCancel),n=Z(a=>a.state.cancelOrdersMode),s=Y2();return B.jsx(B.Fragment,{children:e?B.jsx($V,{}):t!=null&&t.length?B.jsx("div",{className:`twap-orders__list ${n?"twap-orders__list-select-mode":""}`,children:B.jsx(CV,{style:{height:"100%"},data:t,itemContent:(a,o)=>B.jsx(jV,{cancelOrdersMode:!!n,selected:(r==null?void 0:r.includes(o.id))||!1,selectOrder:s,order:o},a)})}):B.jsx(VV,{})})},jV=({order:e,selectOrder:t,selected:r,cancelOrdersMode:n})=>{const s=Z(i=>i.updateState),a=xt.useCallback(()=>{s({selectedOrderID:e==null?void 0:e.id})},[s,e==null?void 0:e.id]),o=xt.useCallback(()=>{n?t(e==null?void 0:e.id):a()},[n,t,a,e==null?void 0:e.id]);return B.jsx("div",{className:`twap-orders__list-item twap-orders__list-item-${e.status} ${n?"twap-orders__list-item-select-mode":""} ${r?"twap-orders__list-item-selected":""}`,onClick:o,children:B.jsxs("div",{className:"twap-orders__list-item-content",children:[B.jsx(WV,{order:e}),B.jsx(qV,{value:e.progress||0}),B.jsxs("div",{className:"twap-orders__list-item-tokens",children:[B.jsx(t5,{address:e.srcTokenAddress}),B.jsx(mj.HiArrowRight,{className:"twap-orders__list-item-tokens-arrow"}),B.jsx(t5,{address:e.dstTokenAddress})]})]})})},VV=()=>{const e=Z(n=>n.state.orderHistoryStatusFilter),t=Ue(),r=xt.useMemo(()=>e||"",[e]);return B.jsx("div",{className:"twap-orders__list-empty",children:B.jsx("p",{children:t("noOrders",{status:r})})})},WV=({order:e})=>{const t=e&&e.status,r=W2(e),n=H0(e.createdAt);return B.jsxs("div",{className:"twap-orders__list-item-header",children:[B.jsxs("p",{className:"twap-orders__list-item-header-title",children:[r," ",B.jsx("span",{children:`(${n})`})]}),B.jsx("p",{className:"twap-orders__list-item-header-status",children:t})]})},t5=e=>{const{useToken:t,components:r}=ne(),n=t==null?void 0:t(e.address);return B.jsx("div",{className:"twap-orders__list-item-token",children:n?B.jsxs(B.Fragment,{children:[B.jsx("div",{className:"twap-orders__list-item-token-logo",children:r.TokenLogo?B.jsx(r.TokenLogo,{token:n}):B.jsx(HV,{logo:n==null?void 0:n.logoUrl})}),B.jsx("p",{className:"twap-orders__list-item-token-symbol",children:n==null?void 0:n.symbol})]}):B.jsx("div",{})})};function qV(e){return B.jsxs("div",{className:"twap-orders__list-item-progress",children:[B.jsx("div",{className:"twap-orders__list-item-progress-bar",children:B.jsx("div",{className:"twap-orders__list-item-progress-bar-filled",style:{width:`${e.value}%`}})}),B.jsx("div",{className:"twap-orders__list-item-token-progress-label",children:B.jsx("p",{children:`${Math.round(e.value)}%`})})]})}const YV=()=>{const e=Z(r=>r.state.selectedOrderID),t=e!==void 0;return B.jsx("div",{className:`twap-orders ${e!==void 0?"twap-orders__show-selected":""}`,children:t?B.jsx(qG,{}):B.jsx(GV,{})})},KV=e=>{const t=Ue(),{marketPrice:r}=ne(),n=Z(a=>a.state.typedSrcAmount);return M.useMemo(()=>{const{isError:a,value:o}=hh(e);if(!(!a||j(n||"0").isZero()||!r))return{type:Mt.MIN_FILL_DELAY,value:o,message:t("minFillDelayError",{fillDelay:`${Sd(o)} ${t("minutes")}`})}},[e,t,n,r])},ua=()=>{const e=Z(s=>s.state.typedFillDelay),t=Z(s=>s.updateState),r=M.useMemo(()=>e||Bc,[e]),n=KV(r);return{fillDelay:r,onChange:M.useCallback(s=>t({typedFillDelay:s}),[t]),error:n,milliseconds:r.unit*r.value}},ZV=()=>{const{onChange:e,fillDelay:t,error:r}=ua(),n=Ue(),s=M.useCallback(o=>e({unit:t.unit,value:Number(o)}),[e,t]),a=M.useCallback(o=>e({unit:o,value:t.value}),[e,t]);return{onInputChange:s,onUnitSelect:a,onChange:e,milliseconds:t.unit*t.value,fillDelay:t,error:r,label:n("tradeIntervalTitle"),tooltip:n("tradeIntervalTootlip")}},un=()=>{const{srcToken:e}=ne(),t=Ue(),r=Z(a=>a.state.typedSrcAmount),s=Z(a=>a.state.acceptedSrcAmount)||r;return{amountWei:V2(e==null?void 0:e.decimals,s),amountUI:s,error:j(s||0).isZero()?t("enterAmount"):void 0}},XV=(e,t)=>{const{module:r,srcUsd1Token:n,marketPrice:s,minChunkSizeUsd:a}=ne(),o=Ue(),i=Z(c=>c.state.typedSrcAmount);return M.useMemo(()=>{if(j(i||"0").isZero()||!s)return;if(!e)return{type:Mt.MIN_CHUNKS,value:1,message:o("minChunksError",{minChunks:"1"})};const{isError:c}=yh(e,t,r);if(c)return{type:Mt.MAX_CHUNKS,value:t,message:o("maxChunksError",{maxChunks:`${t}`})};const{isError:l,value:u}=bh(i||"",n||"",a||0);if(l)return{type:Mt.MIN_TRADE_SIZE,value:u,message:o("minTradeSizeError",{minTradeSize:`${u}`})}},[e,t,r,i,n,a,o,s])},$n=()=>{const{srcToken:e,srcUsd1Token:t,module:r,minChunkSizeUsd:n}=ne(),s=Z(g=>g.state.typedChunks),a=ua().fillDelay,o=Z(g=>g.updateState),{amountWei:i,amountUI:c}=un(),l=M.useMemo(()=>oh(a,c||"",t||"",n||0),[c,t,n,a]),u=M.useMemo(()=>ah(l,r,s),[l,s,r]),d=M.useCallback(g=>o({typedChunks:g}),[o]),f=M.useMemo(()=>ch(i||"",u),[i,u]),m=Vr(e==null?void 0:e.decimals,f),y=M.useMemo(()=>t?j(m||"0").times(t||0).toString():"0",[m,t]);return{totalTrades:u,maxTrades:l,amountPerTradeUI:m,amountPerTradeWei:f,amountPerTradeUsd:y,onChange:d,error:XV(u,l)}},QV=()=>{const{srcToken:e,dstToken:t}=ne(),r=Ue(),{onChange:n,totalTrades:s,amountPerTradeUsd:a,amountPerTradeUI:o,error:i,maxTrades:c,amountPerTradeWei:l}=$n(),u=ze({value:o}),d=ze({value:a});return{error:i,maxTrades:c,totalTrades:s,amountPerTrade:u,amountPerTradeWei:l,onChange:n,label:r("tradesAmountTitle"),tooltip:r("totalTradesTooltip"),amountPerTradeUsd:d,fromToken:e,toToken:t}},JV=e=>{const{module:t,marketPrice:r}=ne(),n=Ue();return M.useMemo(()=>{const s=fh(t,e),a=mh(e);if(r){if(s.isError)return{type:Mt.MAX_ORDER_DURATION,value:s.value,message:n("maxDurationError",{duration:`${Math.floor(u1(s.value)).toFixed(0)} ${n("days")}`})};if(a.isError)return{type:Mt.MIN_ORDER_DURATION,value:a.value,message:n("minDurationError",{duration:`${Math.floor(Sd(a.value)).toFixed(0)} ${n("minutes")}`})}}},[e,n,t,r])},bm=()=>{const{module:e}=ne(),t=Z(i=>i.state.typedDuration),r=Z(i=>i.updateState),n=$n().totalTrades,s=ua().fillDelay,a=M.useMemo(()=>sh(e,n,s,t),[n,s,t,e]),o=JV(a);return{duration:a,setDuration:M.useCallback(i=>r({typedDuration:i}),[r]),error:o}},eW=()=>{const{module:e}=ne(),t=Ue(),{duration:r,setDuration:n,error:s}=bm(),a=M.useCallback(c=>{n({unit:r.unit,value:Number(c)})},[n,r]),o=M.useCallback(c=>{n({unit:c,value:r.value})},[n,r]),i=M.useMemo(()=>e===ge.STOP_LOSS?t("stopLossDurationTooltip"):t("maxDurationTooltip"),[t,e]);return{duration:r,onChange:n,milliseconds:r.unit*r.value,onInputChange:a,onUnitSelect:o,label:t("expiry"),tooltip:i,error:s}},tW=()=>{const e=Z(a=>a.state.isMarketOrder),{module:t}=ne(),r=Ue(),n=M.useMemo(()=>{if(e&&!(t!==ge.STOP_LOSS&&t!==ge.TAKE_PROFIT))return{text:r("triggerMarketPriceDisclaimer"),url:Fc}},[e,r,t]),s=M.useMemo(()=>{if(!(t!==ge.LIMIT&&t!==ge.TWAP))return{text:r(e?"marketOrderWarning":"limitPriceMessage"),url:"https://www.orbs.com/dtwap-and-dlimit-faq/"}},[e,r,t]);return n||s},Wu=()=>{const{srcToken:e,dstToken:t,marketPriceLoading:r}=ne(),n=Z(l=>l.updateState),s=Z(l=>l.state.isInvertedTrade),a=Z(l=>l.state.typedTriggerPrice),o=Z(l=>l.state.typedLimitPrice),i=Z(l=>l.state.isMarketOrder);return{onInvert:M.useCallback(()=>{a!==void 0&&n({typedTriggerPrice:j(1).div(a).toFixed()}),o!==void 0&&n({typedLimitPrice:j(1).div(o).toFixed()}),n({isInvertedTrade:!s})},[n,s,a,o,r]),isInverted:s,fromToken:s?t:e,toToken:s?e:t,isMarketPrice:i}},r5=({typedValue:e,tokenDecimals:t=18,initialPrice:r="0",percentage:n,setValue:s,setPercentage:a})=>{const{srcUsd1Token:o,dstUsd1Token:i}=ne(),{isInverted:c}=Wu(),l=M.useMemo(()=>{if(e!==void 0){const g=c?j(e).isZero()?j(0):j(1).div(e):j(e);return Pc(t,g.toFixed())}if(n!==void 0&&j(r||"0").gt(0)&&!j(r||"0").isNaN()){const g=j(r||"0"),E=j(n||0).div(100);return g.plus(g.multipliedBy(E)).decimalPlaces(0).toFixed()}return j(r).gt(0)?r:""},[e,n,t,r,c]),u=M.useCallback(g=>{s(g),a(null)},[s,a]),d=M.useCallback(g=>{s(void 0),a(g)},[s,a]),f=M.useMemo(()=>{if(!r||j(r).isZero())return"";if(n!=null)return n;if(l){const g=j(r),v=j(l).minus(g).div(g).multipliedBy(100).decimalPlaces(2).toString();return j(v||"0").isZero()?"":v}return""},[l,r,n]),m=M.useMemo(()=>{let g="";if(e!==void 0)g=e;else{const E=bn(t,l);if(j(E||"0").isZero())return"";g=c?j(1).div(E).toFixed():E}return Do(g,6,t)},[e,t,l,c]),y=aa(c?o:i,m||"0");return{amountWei:j(l).isNaN()?"":l,amountUI:j(m).isNaN()?"":m,selectedPercentage:f,onChange:u,onPercentageChange:d,isInverted:c,usd:j(y).isNaN()?"":y}},rW=()=>{const{module:e}=ne();return M.useMemo(()=>e===ge.STOP_LOSS?Km:Zm,[e])},ym=()=>{const{module:e}=ne(),t=Z(r=>r.state.isMarketOrder);return M.useMemo(()=>e!==ge.STOP_LOSS&&e!==ge.TAKE_PROFIT||t?void 0:e===ge.STOP_LOSS?Xm:Qm,[e,t])},nW=(e="")=>{const{module:t,marketPrice:r}=ne(),n=Ue(),s=Z(a=>a.state.typedSrcAmount);return M.useMemo(()=>{if(j(s||"0").isZero()||!r||t!==ge.STOP_LOSS&&t!==ge.TAKE_PROFIT)return;const a=lh(r||"",e||"",t);if(a!=null&&a.isError)return{type:Mt.STOP_LOSS_TRIGGER_PRICE_GREATER_THAN_MARKET_PRICE,value:a.value,message:n("StopLossTriggerPriceError")||""};const o=uh(r||"",e||"",t);if(o!=null&&o.isError)return{type:Mt.TAKE_PROFIT_TRIGGER_PRICE_LESS_THAN_MARKET_PRICE,value:o.value,message:n("TakeProfitTriggerPriceError")||""};if(!e||j(e||0).isZero())return{type:Mt.EMPTY_TRIGGER_PRICE,value:e,message:n("emptyTriggerPrice")||""}},[r,e,t,n,s])},sW=e=>{const{srcToken:t,dstToken:r,module:n}=ne(),s=$n().amountPerTradeWei,a=Z(i=>i.state.isMarketOrder),o=M.useMemo(()=>nh(n,s,e,(t==null?void 0:t.decimals)||0),[e,s,a,t==null?void 0:t.decimals,n]);return{amountWei:o,amountUI:Vr((r==null?void 0:r.decimals)||0,o)}},da=()=>{const{dstToken:e,marketPrice:t,module:r}=ne(),n=Z(m=>m.updateState),s=rW(),a=Z(m=>m.state.triggerPricePercent),o=M.useCallback(m=>{n({triggerPricePercent:m})},[n]),i=a===void 0?s:a,c=r===ge.STOP_LOSS||r===ge.TAKE_PROFIT,l=r5({typedValue:Z(m=>m.state.typedTriggerPrice),percentage:i,tokenDecimals:e==null?void 0:e.decimals,initialPrice:c?t:void 0,setValue:M.useCallback(m=>n({typedTriggerPrice:m}),[n]),setPercentage:o}),u=nW(l.amountWei),{amountWei:d,amountUI:f}=sW(l.amountWei);return M.useMemo(()=>({...l,error:u,pricePerChunkWei:d,pricePerChunkUI:f}),[l,u,d,f])},aW=()=>{const{module:e,marketPrice:t,marketPriceLoading:r}=ne(),n=Ue(),{amountUI:s,onChange:a,onPercentageChange:o,usd:i,selectedPercentage:c,error:l}=da(),u=Z(w=>w.state.isMarketOrder),d=Z(w=>w.updateState),{isInverted:f,onInvert:m,fromToken:y,toToken:g}=Wu(),E=M.useCallback(()=>{d({triggerPricePercent:void 0,typedTriggerPrice:void 0})},[d]),v=e!==ge.STOP_LOSS&&e!==ge.TAKE_PROFIT;return{price:s,error:l,label:n("stopLossLabel"),tooltip:e===ge.STOP_LOSS?n("stopLossTooltip"):n("takeProfitTooltip"),onChange:a,onPercentageChange:o,percentage:c,isActive:!u,onReset:E,usd:i,fromToken:y,toToken:g,prefix:"",isLoading:r||!t,isInverted:f,hide:v,onInvert:m}},oW=e=>{const{module:t,marketPrice:r}=ne(),n=Ue(),{amountWei:s}=da(),a=Z(i=>i.state.isMarketOrder),o=Z(i=>i.state.typedSrcAmount);return M.useMemo(()=>{if(j(o||"0").isZero()||!s||!r)return;const i=dh(s,e,a,t),c=ph(s,e,a,t);if(i!=null&&i.isError)return{type:Mt.TRIGGER_LIMIT_PRICE_GREATER_THAN_TRIGGER_PRICE,message:n("triggerLimitPriceError")||"",value:i.value};if(c!=null&&c.isError)return{type:Mt.TRIGGER_LIMIT_PRICE_GREATER_THAN_TRIGGER_PRICE,message:n("triggerLimitPriceError")||"",value:c.value};if(e&&j(e||0).isZero())return{type:Mt.MISSING_LIMIT_PRICE,message:n("emptyLimitPrice")||"",value:e||""}},[e,n,s,t,a,o,r])},gc=()=>{const{dstToken:e,marketPrice:t,module:r}=ne(),n=Z(l=>l.updateState),s=ym(),a=Z(l=>l.state.limitPricePercent),o=a===void 0?s:a,i=r5({typedValue:Z(l=>l.state.typedLimitPrice),percentage:o,tokenDecimals:e==null?void 0:e.decimals,initialPrice:t,setValue:M.useCallback(l=>n({typedLimitPrice:l}),[n]),setPercentage:M.useCallback(l=>{n({limitPricePercent:l})},[n,r])}),c=oW(i.amountWei);return M.useMemo(()=>({...i,error:c}),[i,c])},iW=()=>{const{module:e}=ne(),t=Z(i=>i.updateState),r=Z(i=>i.state.isMarketOrder),n=ym(),s=Z(i=>i.state.triggerPricePercent)||0,a=e===ge.LIMIT,o=M.useCallback(()=>{!r&&e===ge.STOP_LOSS&&t({limitPricePercent:n}),t({isMarketOrder:!r})},[t,s,e,r,n]);return{isLimitPrice:!r,toggleLimitPrice:o,hide:a}},cW=()=>{const{module:e,marketPriceLoading:t}=ne(),r=Ue(),{amountUI:n,onChange:s,onPercentageChange:a,usd:o,selectedPercentage:i,error:c}=gc(),l=Z(L=>L.state.isMarketOrder),u=Z(L=>L.updateState),d=ym(),{isLimitPrice:f,toggleLimitPrice:m}=iW(),{triggerPricePercent:y}=Z(L=>L.state),{isInverted:g,onInvert:E,fromToken:v,toToken:w}=Wu(),A=M.useMemo(()=>{if(!(e!==ge.STOP_LOSS&&e!==ge.TAKE_PROFIT||!l))return{text:r("triggerMarketPriceDisclaimer"),url:Fc}},[y,r,e,l]),C=M.useCallback(()=>{u({typedLimitPrice:void 0}),u({limitPricePercent:d})},[u,e,d]),D=M.useMemo(()=>e===ge.STOP_LOSS?r("stopLossLimitPriceTooltip"):r("limitPriceTooltip"),[r,e]);return{price:n,error:c,warning:A,label:r("limitPrice"),tooltip:D,onChange:s,onPercentageChange:a,onReset:C,usd:o,fromToken:v,toToken:w,percentage:i,isInverted:g,isLoading:t,isLimitPrice:f,toggleLimitPrice:m,onInvert:E}},n5=()=>{const{module:e,marketPrice:t}=ne(),r=gc().amountWei,n=da().amountWei,s=Z(a=>a.state.isMarketOrder);return e===ge.LIMIT||!s?r||"":e===ge.STOP_LOSS||e===ge.TAKE_PROFIT?n||"":t||""},xc=()=>{const{srcToken:e,dstToken:t}=ne(),r=n5(),n=un().amountWei,s=M.useMemo(()=>th(n||"",r,(e==null?void 0:e.decimals)||0),[n,r,e==null?void 0:e.decimals]);return{amountWei:s,amountUI:Vr(t==null?void 0:t.decimals,s)}},gm=()=>{const{srcToken:e,dstToken:t,dstUsd1Token:r}=ne(),n=n5(),s=$n().amountPerTradeWei,a=Z(c=>c.state.isMarketOrder),o=M.useMemo(()=>rh(s,n,!!a,(e==null?void 0:e.decimals)||0),[s,n,a,e==null?void 0:e.decimals]),i=Vr(t==null?void 0:t.decimals,o);return{amountWei:o,amountUI:i,usd:aa(i,r)}},s5=()=>{const{srcBalance:e,chainId:t}=ne(),r=Ue(),n=un().amountWei;return M.useMemo(()=>{if(e&&j(n).gt(e))return{type:Mt.INSUFFICIENT_BALANCE,message:r("insufficientFunds"),value:e||""}},[e,n,r,t])};function a5(){const{marketPrice:e,marketPriceLoading:t}=ne(),r=Z(l=>l.state.typedSrcAmount),n=s5(),{error:s}=da(),{error:a}=gc(),{error:o}=$n(),{error:i}=ua(),{error:c}=bm();return M.useMemo(()=>{const l=Fo("ignore-errors");if(!(j(e||0).isZero()||j(r||0).isZero()||t||l))return s||a||o||i||c||n},[e,t,r,s,a,o,i,c,n])}const o5=(e,t)=>{const{marketPriceLoading:r,srcToken:n,dstToken:s,srcBalance:a,dstBalance:o}=ne(),i=Z(C=>C.state.typedSrcAmount),c=Z(C=>C.updateState),{srcUsd1Token:l,dstUsd1Token:u}=ne(),d=aa(i,l),f=aa(t,u),m=CG(),y=e?n:s,g=Vr(y==null?void 0:y.decimals,e?a:o),E=s5(),v=M.useCallback(C=>{e&&c({typedSrcAmount:C})},[c,e]),w=M.useCallback(()=>{e&&c({typedSrcAmount:Do(g,8)})},[c,e,g]),A=m||e?i:Do(t||"",8);return{balance:g,usd:e||m?d:f,value:A||"",valueWei:V2(y==null?void 0:y.decimals,A),onChange:v,onMax:w,isLoading:i?e?!1:r:!1,token:y,isInsufficientBalance:e?E:void 0}},lW=()=>o5(!0),uW=()=>{const e=xc().amountUI,t=Z(r=>r.state.typedSrcAmount);return o5(!1,t?e:"")},dW=()=>{const e=Z(t=>t.updateState);return{amount:Z(t=>t.state.typedSrcAmount)||"",reset:M.useCallback(()=>e({typedSrcAmount:""}),[e])}},pW=()=>{const e=Z(n=>n.state.isMarketOrder),t=Z(n=>n.updateState),r=M.useCallback(()=>{t({isMarketOrder:!e})},[t,e]);return{isMarketPrice:!e,togglePrice:r}},xm=()=>{const e=Z(r=>r.state.currentTime),t=bm().duration;return M.useMemo(()=>ih(e,t),[e,t])},fW=()=>{const{srcUsd1Token:e,dstUsd1Token:t}=ne(),r=un().amountUI,n=xc().amountUI,s=aa(r,e),a=aa(n,t);return{srcAmountUsd:s,dstAmountUsd:a}},mW=()=>{const{fees:e,dstUsd1Token:t}=ne(),{amountUI:r}=xc(),n=M.useMemo(()=>!e||!r?"":j(r).multipliedBy(e).dividedBy(100).toFixed(),[r,e]);return{amount:n,percent:e,usd:aa(n,t)}},i5=()=>{const{srcToken:e,dstToken:t,account:r,chainId:n,slippage:s,config:a}=ne(),{amountWei:o}=un(),{amountWei:i}=gc(),{amountPerTradeWei:c,totalTrades:l}=$n(),u=xm(),{amountWei:d}=gm(),{amountWei:f}=da(),{milliseconds:m}=ua();return M.useMemo(()=>{var y;return{srcToken:e,dstToken:t,limitPrice:i,deadline:u,srcAmount:o,srcAmountPerTrade:c,totalTrades:l,minDestAmountPerTrade:d,tradeInterval:m,triggerPricePerTrade:f,maker:r,rePermitData:xh({chainId:n,srcToken:Is((e==null?void 0:e.address)||"")?((y=Bs(n))==null?void 0:y.wToken.address)||"":(e==null?void 0:e.address)||"",dstToken:(t==null?void 0:t.address)||"",srcAmount:o,deadlineMillis:u,fillDelayMillis:!l||l===1?0:m,slippage:s*100,account:r,srcAmountPerTrade:c,dstMinAmountPerTrade:d,triggerAmountPerTrade:f,config:a})}},[e,t,i,u,o,c,l,d,f,r,m,s,n,a])},c5=()=>{const{srcToken:e,dstToken:t,account:r}=ne(),n=Ue(),{amountUI:s,usd:a}=gm(),{amountPerTradeUI:o,amountPerTradeUsd:i,totalTrades:c}=$n(),{amountUI:l,usd:u}=da(),d=xm(),{amountUI:f,usd:m}=gc(),{amount:y,percent:g,usd:E}=mW(),{milliseconds:v}=ua(),{amountUI:w}=xc(),{srcAmountUsd:A,dstAmountUsd:C}=fW(),D=un().amountUI,L=Z(x=>x.state.isMarketOrder),T=K2({srcToken:e,dstToken:t,account:r,limitPrice:L?void 0:f,limitPriceUsd:L?void 0:m,deadline:d,tradeInterval:v,srcAmount:D,totalTrades:c,srcAmountPerTrade:o,srcAmountPerTradeUsd:i,minDestAmountPerTrade:s,minDestAmountPerTradeUsd:a,triggerPricePerTrade:l,triggerPricePerTradeUsd:u,srcUsd:A,dstUsd:C,dstAmount:w}),h=ze({value:y}),b=ze({value:E});return M.useMemo(()=>({...T,fees:{label:n("fees",{value:`${g}%`}),amount:h,usd:b||"",percentage:g}}),[T,h,b,g])},l5=M.createContext({}),hW=({children:e,...t})=>B.jsx(l5.Provider,{value:t,children:e}),bW=()=>M.useContext(l5),u5=()=>{var s,a;const e=Ue(),{wrapTxHash:t,srcToken:r}=Z(o=>o.state.swapExecution),n=(a=(s=ac())==null?void 0:s.wToken)==null?void 0:a.symbol;return t?B.jsx("p",{className:"twap-error-wrap-msg",children:e("wrapMsg",{symbol:(r==null?void 0:r.symbol)||"",wSymbol:n||""})}):null},yW=(e=!1,t=1)=>{const{module:r}=ne(),n=Ue();return M.useMemo(()=>r===ge.STOP_LOSS?n("stopLoss"):r===ge.TAKE_PROFIT?n("takeProfit"):n(e?"twapMarket":t===1?"limit":"twapLimit"),[n,r,e,t])},gW=({price:e,dstTokenSymbol:t,label:r,usd:n})=>B.jsxs(we.DetailRow,{title:r,children:[`${e||"-"} ${t||""}`,B.jsx(we.USD,{value:n})]}),d5=()=>{const e=Ue(),t=Z(a=>a.state.isMarketOrder),r=Z(a=>a.state.swapExecution.status),{totalTrades:n}=$n(),s=yW(t,n);return r===mt.SUCCESS?e("createOrderActionSuccess",{name:s}):e("createOrderAction",{name:s})},xW=()=>{const e=Z(y=>y.state.swapExecution.srcToken),t=Ue(),{step:r,wrapTxHash:n,approveTxHash:s}=Z(y=>y.state.swapExecution),a=ac(),o=R0(n),i=R0(n),c=R0(s),l=Z(y=>y.state.swapExecution.status),d=Is((e==null?void 0:e.address)||"")?(a==null?void 0:a.native.symbol)||"":(e==null?void 0:e.symbol)||"",f=a==null?void 0:a.wToken.symbol,m=d5();return M.useMemo(()=>r===Ds.WRAP?{title:t("wrapAction",{symbol:d}),footerLink:o,footerText:t(o?"viewOnExplorer":"proceedInWallet")}:r===Ds.APPROVE?{title:t("approveAction",{symbol:d}),footerLink:c,footerText:t(c?"viewOnExplorer":"proceedInWallet")}:{title:m,footerText:l===mt.LOADING?t("proceedInWallet"):void 0},[r,c,d,m,t,o,i,f,l])},wW=({error:e})=>B.jsxs("div",{className:"twap-error",children:[B.jsx("h2",{className:"twap-error-title",children:"Transaction failed"}),(e==null?void 0:e.code)&&B.jsxs("p",{className:"twap-error-code",children:["Error code: ",e==null?void 0:e.code]}),B.jsx(u5,{})]});function vW({error:e}){const{components:t}=ne(),r=Ue(),n=Z(o=>{var i;return(i=o.state.swapExecution)==null?void 0:i.wrapTxHash}),s=t.SubmitOrderErrorView,a=B.jsx(Qn.Failed,{error:B.jsx(wW,{error:e}),footerLink:Fc,footerText:r("viewOnExplorer")});return s?B.jsx(s,{wrapTxHash:n,error:e,children:a}):a}const EW=()=>{const{components:e}=ne(),t=Z(u=>u.state.swapExecution.srcToken),r=Z(u=>u.state.swapExecution.dstToken),{reviewDetails:n}=bW(),s=Ue(),a=Z(u=>{var d;return!!((d=u.state.swapExecution)!=null&&d.status)}),o=c5(),i=e.USD,c=e.SubmitOrderMainView,l=B.jsxs(B.Fragment,{children:[B.jsx(Qn.Main,{fromTitle:s("from"),toTitle:s("to"),inUsd:i?B.jsx(i,{value:o.srcUsd,isLoading:!1}):`$${o.srcUsd}`,outUsd:i?B.jsx(i,{value:o.dstUsd,isLoading:!1}):`$${o.dstUsd}`}),!a&&B.jsxs("div",{className:"twap-create-order-bottom",children:[B.jsx(we.Container,{children:B.jsxs("div",{className:"twap-create-order-details",children:[B.jsx(we.Deadline,{deadline:o.deadline.value,label:o.deadline.label,tooltip:o.deadline.tooltip||""}),B.jsx(we.TriggerPrice,{price:o.triggerPricePerTrade.value,dstToken:r,label:o.triggerPricePerTrade.label,tooltip:o.triggerPricePerTrade.tooltip||"",usd:o.triggerPricePerTrade.usd}),B.jsx(gW,{price:o.limitPrice.value,dstTokenSymbol:r==null?void 0:r.symbol,label:o.limitPrice.label,usd:o.limitPrice.usd}),B.jsx(we.MinDestAmount,{dstToken:r,dstMinAmountOut:o.minDestAmountPerTrade.value,label:o.minDestAmountPerTrade.label,tooltip:o.minDestAmountPerTrade.tooltip||"",usd:o.minDestAmountPerTrade.usd}),B.jsx(we.TradeSize,{tradeSize:o.sizePerTrade.value,trades:o.totalTrades.value,srcToken:t,label:o.sizePerTrade.label,tooltip:o.sizePerTrade.tooltip}),B.jsx(we.TradesAmount,{trades:o.totalTrades.value,label:o.totalTrades.label,tooltip:o.totalTrades.tooltip}),B.jsx(we.TradeInterval,{chunks:o.totalTrades.value,fillDelayMillis:o.tradeInterval.value,label:o.tradeInterval.label,tooltip:o.tradeInterval.tooltip}),B.jsx(we.Recipient,{}),o.fees.amount&&B.jsx(we.Fees,{fees:o.fees.amount,label:o.fees.label,usd:o.fees.usd,dstTokenSymbol:r==null?void 0:r.symbol})]})}),n]})]});return c?B.jsx(c,{children:l}):l},kW=e=>{const{status:t,stepIndex:r,totalSteps:n,parsedError:s}=Z(w=>w.state.swapExecution),{components:a}=ne(),o=a.Spinner,i=a.SuccessIcon,c=a.ErrorIcon,l=a.TokenLogo,{srcToken:u,dstToken:d}=ne(),f=un().amountUI,m=xc().amountUI,y=ze({value:f,decimalScale:2}),g=ze({value:m,decimalScale:2}),E=M.useMemo(()=>({symbol:u==null?void 0:u.symbol,logoUrl:u==null?void 0:u.logoUrl}),[u]),v=M.useMemo(()=>({symbol:d==null?void 0:d.symbol,logoUrl:d==null?void 0:d.logoUrl}),[d]);return B.jsx(hW,{...e,children:B.jsx(Qn,{inAmount:y,outAmount:g,swapStatus:t,totalSteps:n,currentStep:xW(),currentStepIndex:r,inToken:E,outToken:v,components:{SrcTokenLogo:l&&B.jsx(l,{token:u}),DstTokenLogo:l&&B.jsx(l,{token:d}),Failed:B.jsx(vW,{error:s}),Success:B.jsx(CW,{}),Main:B.jsx(EW,{}),Loader:o,SuccessIcon:i,FailedIcon:c}})})},CW=()=>{const e=d5(),{components:t}=ne(),r=Z(a=>a.state.swapExecution.orderId),n=t.SubmitOrderSuccessView,s=B.jsxs(B.Fragment,{children:[B.jsx(Qn.Success,{title:e}),B.jsx(u5,{})]});return n?B.jsx(n,{newOrderId:r,children:s}):s},TW=()=>{const{supportedChains:e}=ne();return M.useMemo(()=>e,[e])},SW=()=>{const{config:e}=ne();return M.useMemo(()=>({spender:e.repermit}),[e])},AW=()=>{var c;const{account:e,walletClient:t,overrides:r,refetchBalances:n,callbacks:s,chainId:a}=ne(),o=(c=ac())==null?void 0:c.wToken,i=$0();return gn({mutationFn:async({onHash:l,srcAmountWei:u})=>{var m,y;if(!e)throw new Error("missing account");if(!t)throw new Error("missing walletClient");if(!o)throw new Error("tokenAddress is not defined");let d;dt.onWrapRequest(),(m=s==null?void 0:s.onWrapRequest)==null||m.call(s),r!=null&&r.wrap?d=await r.wrap(BigInt(u)):d=await t.writeContract({abi:Um,functionName:"deposit",account:e,address:o.address,value:BigInt(u),chain:t.chain}),l==null||l(d);const f=await i(d);if(!f)throw new Error("failed to get transaction receipt");if(f.status==="reverted")throw new Error("failed to wrap token");return dt.onWrapSuccess(d),(y=s==null?void 0:s.onWrapSuccess)==null||y.call(s,{txHash:f.transactionHash,explorerUrl:_o(f.transactionHash,a),amount:bn(o.decimals,u)}),n==null||n(),f},onError:l=>{throw dt.onWrapError(l),l}})},PW=()=>{const{account:e,walletClient:t,chainId:r,callbacks:n}=ne(),s=i5().rePermitData,a=HG();return gn({mutationFn:async()=>{var y,g,E,v;if(!e)throw new Error("missing account");if(!t)throw new Error("missing walletClient");if(!r)throw new Error("missing chainId");const{order:o,domain:i,types:c,primaryType:l}=s;dt.onSignOrderRequest(o),(y=n==null?void 0:n.onSignOrderRequest)==null||y.call(n),console.log({domain:i,types:c,primaryType:l,message:o,account:e}),console.log("Using domain:",i),console.log("Using types:",c),console.log("Order data to sign:",JSON.stringify(o,null,2)),console.log(`Account address: ${e}`);let u;try{u=await(t==null?void 0:t.signTypedData({domain:i,types:c,primaryType:l,message:o,account:e}))}catch(w){throw(g=n==null?void 0:n.onSignOrderError)==null||g.call(n,w),dt.onSignOrderError(w),w}dt.onSignOrderSuccess(u),(E=n==null?void 0:n.onSignOrderSuccess)==null||E.call(n,u);const d=zL(u),f={v:q(d.v||0),r:d.r,s:d.s},m=await Ch(o,f);return(v=n==null?void 0:n.onOrderCreated)==null||v.call(n,m),a(m),m}})},p5=()=>{const{account:e,publicClient:t,config:r}=ne();return gn({mutationFn:async({tokenAddress:n,srcAmountWei:s})=>{if(!t)throw new Error("missing publicClient");if(!e)throw new Error("missing account");if(!r)throw new Error("missing config");console.log(r.repermit,"repermit");const a=await t.readContract({address:n,abi:xg,functionName:"allowance",args:[e,r.repermit]}).then(i=>i.toString()),o=j(a||"0").lt(j(s).toString());return{allowance:a,approvalRequired:o}}})},IW=()=>{const{account:e,walletClient:t,overrides:r,config:n,chainId:s,callbacks:a}=ne(),o=$0(),{mutateAsync:i}=p5();return gn({onError:c=>{dt.onApproveError(c)},mutationFn:async({token:c,onHash:l,srcAmountWei:u})=>{var y,g;if(!e)throw new Error("missing account");if(!t)throw new Error("missing walletClient");if(!n)throw new Error("missing config");(y=a==null?void 0:a.onApproveRequest)==null||y.call(a),dt.onApproveRequest();let d;if(r!=null&&r.approveOrder?d=await r.approveOrder({tokenAddress:c.address,spenderAddress:n.repermit,amount:Ls}):d=await t.writeContract({abi:xg,functionName:"approve",account:e,address:c.address,args:[n.repermit,Ls],chain:t.chain}),!d)throw new Error("failed to approve token");l(d);const f=await o(d);if(!f)throw new Error("failed to get transaction receipt");if(f.status==="reverted")throw new Error("failed to approve token");let m=!1;for(let E=0;E<3;E++){const{approvalRequired:v}=await i({tokenAddress:c.address,srcAmountWei:u});if(!v){m=!0;break}E<2&&await new Promise(w=>setTimeout(w,3e3))}if(!m)throw new Error(`Insufficient ${c.symbol} allowance to perform the swap. Please approve the token first.`);return dt.onApproveSuccess(f.transactionHash),(g=a==null?void 0:a.onApproveSuccess)==null||g.call(a,{txHash:f.transactionHash,explorerUrl:_o(f.transactionHash,s),token:c,amount:bn(c.decimals,u)}),f}})},BW=()=>{const{account:e,chainId:t,srcToken:r,dstToken:n,module:s,slippage:a}=ne(),o=da(),i=un().amountWei,c=$n().amountPerTradeWei,l=xm(),u=ua().fillDelay,d=gm().amountWei,f=Z(m=>m.state.isMarketOrder);return gn({mutationFn:async()=>{dt.onRequestOrder({account:e,chainId:t,module:s,srcToken:r,dstToken:n,fromTokenAmount:i,srcChunkAmount:c,triggerPricePerTrade:o.pricePerChunkWei,deadline:l,fillDelay:u.unit*u.value,minDstAmountOutPerTrade:d,slippage:a,isMarketOrder:f||!1})}})};function FW(e){const t=e.message,r=t.match(/,\s*code\s*:\s*(\d+)/i);return{message:t.replace(/^error\s*:/i,"").replace(/,\s*code\s*:\s*\d+/i,"").trim()||"",code:r?Number(r[1]):0}}const UW=()=>{const{srcToken:e,dstToken:t,chainId:r,callbacks:n}=ne(),s=IW().mutateAsync,a=AW().mutateAsync,o=PW().mutateAsync,{mutateAsync:i}=p5(),c=Z(d=>d.updateSwapExecution),{amountWei:l}=un(),u=BW().mutate;return gn({mutationFn:async()=>{var f,m;const d=Is((e==null?void 0:e.address)||" ");try{if(!e)throw new Error("missing srcToken");if(!t)throw new Error("missing dstToken");if(!r)throw new Error("missing chainId");const y=l1(e,r);c({allowanceLoading:!0});const{approvalRequired:g}=await i({tokenAddress:y.address,srcAmountWei:l});let E=0,v=1;d&&v++,g&&v++,c({totalSteps:v,stepIndex:E,allowanceLoading:!1,status:mt.LOADING}),u(),d&&(c({step:Ds.WRAP}),await a({onHash:A=>c({wrapTxHash:A}),srcAmountWei:l}),E++,c({stepIndex:E})),g&&(c({step:Ds.APPROVE}),await s({token:y,onHash:A=>c({approveTxHash:A}),srcAmountWei:l}),E++,c({stepIndex:E})),c({step:Ds.CREATE});const w=await o();return c({status:mt.SUCCESS,orderId:w.id}),w}catch(y){if(Td(y))(f=n==null?void 0:n.onSubmitOrderRejected)==null||f.call(n),c({step:void 0,status:void 0,stepIndex:void 0,error:y});else{const g=FW(y);(m=n==null?void 0:n.onSubmitOrderFailed)==null||m.call(n,g),c({status:mt.FAILED,parsedError:g,error:y})}}}})},OW=()=>{const{marketPrice:e,srcToken:t,dstToken:r}=ne(),n=UW(),s=Z(f=>f.updateState),{amountUI:a}=un(),o=Z(f=>f.resetState),i=Z(f=>f.state.swapExecution),c=M.useCallback(()=>{(i==null?void 0:i.status)===mt.SUCCESS&&(s({typedSrcAmount:""}),setTimeout(()=>{o()},1e3))},[i==null?void 0:i.status,o,s]),l=M.useCallback(()=>{(i==null?void 0:i.status)!==mt.LOADING&&s({acceptedSrcAmount:void 0,acceptedMarketPrice:void 0,swapExecution:{srcToken:t,dstToken:r}})},[s,t,r]),u=gn({mutationFn:async()=>(s({acceptedSrcAmount:a,acceptedMarketPrice:e}),await n.mutateAsync())}),d=M.useCallback(()=>u.mutateAsync(),[u]);return M.useMemo(()=>({reset:o,onCloseModal:c,onOpenModal:l,onSubmit:d,...i,isLoading:!!((i==null?void 0:i.status)===mt.LOADING||i!=null&&i.allowanceLoading),isSuccess:(i==null?void 0:i.status)===mt.SUCCESS,isFailed:(i==null?void 0:i.status)===mt.FAILED}),[o,c,d,i])},DW=()=>{const e=Ue(),{marketPrice:t,srcToken:r,dstToken:n,marketPriceLoading:s,srcBalance:a,srcUsd1Token:o,noLiquidity:i}=ne(),c=s||j(o||"0").isZero()||a===void 0||j(t||"0").isZero(),l=Z(y=>y.state.typedSrcAmount),u=!!(r&&n&&l&&c),d=a5(),f=M.useMemo(()=>i?e("noLiquidity"):j(l||"0").isZero()?e("enterAmount"):(d==null?void 0:d.type)===Mt.INSUFFICIENT_BALANCE?e("insufficientFunds"):e("placeOrder"),[d,e,l,i]),m=!!(d||i||u||j(l||"0").isZero()||!r||!n);return M.useMemo(()=>({disabled:m,text:f,loading:u}),[m,f,u])};vh(Aw.version);const _W={SubmitOrderPanel:kW,Orders:YV};R.CRASH_ERROR_MESSAGE=ew,R.Components=_W,R.Configs=Dt,R.DEFAULT_DURATION_OPTIONS=ZL,R.DEFAULT_FILL_DELAY=Bc,R.DEFAULT_STOP_LOSS_LIMIT_PERCENTAGE=Xm,R.DEFAULT_STOP_LOSS_PERCENTAGE=Km,R.DEFAULT_TAKE_PROFIT_LIMIT_PERCENTAGE=Qm,R.DEFAULT_TAKE_PROFIT_PERCENTAGE=Zm,R.DISCLAIMER_URL=J5,R.EIP712_TYPES=Ym,R.ERC20_ABI=M5,R.EXCLUSIVITY_OVERRIDE_BPS=Y5,R.FEES=q5,R.IWETH_ABI=Um,R.InputErrors=Mt,R.LEGACY_EXCHANGES_MAP=Wm,R.MAX_ORDER_DURATION_MILLIS=Ca,R.MIN_CHUNKS=V5,R.MIN_FILL_DELAY_MILLIS=Ic,R.MIN_FILL_DELAY_MINUTES=Hm,R.MIN_ORDER_DURATION_MILLIS=ad,R.Module=ge,R.ORBS_LOGO=Z5,R.ORBS_LOGO_FALLBACK=X5,R.ORBS_SLTP_FAQ_URL=K5,R.ORBS_TWAP_FAQ_URL=Fc,R.ORBS_WEBSITE_URL=Q5,R.OrderStatus=lt,R.OrderType=ut,R.PRICE_PROTECTION_SETTINGS=XL,R.Partners=_m,R.QUERY_PARAMS=Uc,R.REPERMIT_ABI=Om,R.REPERMIT_PRIMARY_TYPE=qm,R.SUGGEST_CHUNK_VALUE=j5,R.SpotProvider=YL,R.Steps=Ds,R.SwapStatus=mt,R.THE_GRAPH_ORDERS_API=Gm,R.TWAP_ABI=Dm,R.TimeUnit=Gt,R.amountBN=Pc,R.amountUi=bn,R.analytics=dt,R.buildRePermitOrderData=xh,R.copy=D3,R.ensureWrappedToken=l1,R.eqIgnoreCase=Ps,R.fillDelayText=o1,R.formatDecimals=Do,R.getAccountOrders=Ph,R.getApiEndpoint=sd,R.getChunks=ah,R.getConfig=cd,R.getDeadline=ih,R.getDestTokenAmount=th,R.getDestTokenMinAmountPerChunk=rh,R.getDuration=sh,R.getEstimatedDelayBetweenChunksMillis=id,R.getExplorerUrl=_o,R.getMaxChunksError=yh,R.getMaxFillDelayError=ow,R.getMaxOrderDurationError=fh,R.getMaxPossibleChunks=oh,R.getMinFillDelayError=hh,R.getMinNativeBalance=M3,R.getMinOrderDurationError=mh,R.getMinTradeSizeError=bh,R.getMinimumDelayMinutes=aw,R.getNetwork=Bs,R.getOrderExcecutionRate=i1,R.getOrderFillDelayMillis=td,R.getOrderLimitPriceRate=c1,R.getOrderType=N3,R.getPartnerChains=zm,R.getPartnerIdentifier=_t,R.getPartners=gh,R.getQueryParam=Fo,R.getSrcTokenChunkAmount=ch,R.getStopLossLimitPriceError=dh,R.getStopLossPriceError=lh,R.getTakeProfitLimitPriceError=ph,R.getTakeProfitPriceError=uh,R.getTriggerPricePerChunk=nh,R.isNativeAddress=Is,R.isTxRejected=Td,R.makeElipsisAddress=Cd,R.maxUint256=W5,R.millisToDays=u1,R.millisToMinutes=Sd,R.nativeTokenAddresses=Vm,R.networks=Ft,R.parseError=_3,R.removeCommas=O3,R.setApiMode=G5,R.setUIVersion=vh,R.shouldUnwrapOnly=Pd,R.shouldWrapOnly=Ad,R.submitOrder=Ch,R.useAddresses=SW,R.useDisclaimerPanel=tW,R.useDstTokenPanel=uW,R.useDurationPanel=eW,R.useFillDelayPanel=ZV,R.useFormatNumber=ze,R.useInputErrors=a5,R.useInvertTradePanel=Wu,R.useLimitPricePanel=cW,R.useOrder=i5,R.useOrderHistoryPanel=WG,R.useOrderInfo=c5,R.usePartnerChains=TW,R.useSrcTokenPanel=lW,R.useSubmitOrderButton=DW,R.useSubmitOrderPanel=OW,R.useTogglePricePanel=pW,R.useTradesPanel=QV,R.useTranslations=Ue,R.useTriggerPricePanel=aW,R.useTypedSrcAmount=dW,R.zeroAddress=jm,Object.defineProperty(R,Symbol.toStringTag,{value:"Module"})}));