@cetusprotocol/terminal 1.4.0 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cetus-swap.cjs.js
CHANGED
|
@@ -44,7 +44,7 @@ ${String(n)}`);h0(t);for(let i=0;i<t.callbacks.length;i++){const s=n[i];s instan
|
|
|
44
44
|
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...r){const n=new this(t);return r.forEach(i=>n.set(i)),n}static accessor(t){const n=(this[cv]=this[cv]={accessors:{}}).accessors,i=this.prototype;function s(o){const a=Xc(o);n[a]||(mB(i,o),n[a]=!0)}return Ae.isArray(t)?t.forEach(s):s(t),this}}$d.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);Ae.reduceDescriptors($d.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(n){this[r]=n}}});Ae.freezeMethods($d);var Ei=$d;function np(e,t){const r=this||e1,n=t||r,i=Ei.from(n.headers);let s=n.data;return Ae.forEach(e,function(a){s=a.call(r,s,i.normalize(),t?t.status:void 0)}),i.normalize(),s}function xS(e){return!!(e&&e.__CANCEL__)}function Cc(e,t,r){jt.call(this,e??"canceled",jt.ERR_CANCELED,t,r),this.name="CanceledError"}Ae.inherits(Cc,jt,{__CANCEL__:!0});function SS(e,t,r){const n=r.config.validateStatus;!r.status||!n||n(r.status)?e(r):t(new jt("Request failed with status code "+r.status,[jt.ERR_BAD_REQUEST,jt.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function gB(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function yB(e,t){e=e||10;const r=new Array(e),n=new Array(e);let i=0,s=0,o;return t=t!==void 0?t:1e3,function(c){const u=Date.now(),l=n[s];o||(o=u),r[i]=c,n[i]=u;let f=s,h=0;for(;f!==i;)h+=r[f++],f=f%e;if(i=(i+1)%e,i===s&&(s=(s+1)%e),u-o<t)return;const v=l&&u-l;return v?Math.round(h*1e3/v):void 0}}function vB(e,t){let r=0,n=1e3/t,i,s;const o=(u,l=Date.now())=>{r=l,i=null,s&&(clearTimeout(s),s=null),e(...u)};return[(...u)=>{const l=Date.now(),f=l-r;f>=n?o(u,l):(i=u,s||(s=setTimeout(()=>{s=null,o(i)},n-f)))},()=>i&&o(i)]}const Hf=(e,t,r=3)=>{let n=0;const i=yB(50,250);return vB(s=>{const o=s.loaded,a=s.lengthComputable?s.total:void 0,c=o-n,u=i(c),l=o<=a;n=o;const f={loaded:o,total:a,progress:a?o/a:void 0,bytes:c,rate:u||void 0,estimated:u&&a&&l?(a-o)/u:void 0,event:s,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(f)},r)},uv=(e,t)=>{const r=e!=null;return[n=>t[0]({lengthComputable:r,total:e,loaded:n}),t[1]]},lv=e=>(...t)=>Ae.asap(()=>e(...t));var bB=cn.hasStandardBrowserEnv?((e,t)=>r=>(r=new URL(r,cn.origin),e.protocol===r.protocol&&e.host===r.host&&(t||e.port===r.port)))(new URL(cn.origin),cn.navigator&&/(msie|trident)/i.test(cn.navigator.userAgent)):()=>!0,wB=cn.hasStandardBrowserEnv?{write(e,t,r,n,i,s){const o=[e+"="+encodeURIComponent(t)];Ae.isNumber(r)&&o.push("expires="+new Date(r).toGMTString()),Ae.isString(n)&&o.push("path="+n),Ae.isString(i)&&o.push("domain="+i),s===!0&&o.push("secure"),document.cookie=o.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function _B(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function xB(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function ES(e,t,r){let n=!_B(t);return e&&(n||r==!1)?xB(e,t):t}const fv=e=>e instanceof Ei?{...e}:e;function ya(e,t){t=t||{};const r={};function n(u,l,f,h){return Ae.isPlainObject(u)&&Ae.isPlainObject(l)?Ae.merge.call({caseless:h},u,l):Ae.isPlainObject(l)?Ae.merge({},l):Ae.isArray(l)?l.slice():l}function i(u,l,f,h){if(Ae.isUndefined(l)){if(!Ae.isUndefined(u))return n(void 0,u,f,h)}else return n(u,l,f,h)}function s(u,l){if(!Ae.isUndefined(l))return n(void 0,l)}function o(u,l){if(Ae.isUndefined(l)){if(!Ae.isUndefined(u))return n(void 0,u)}else return n(void 0,l)}function a(u,l,f){if(f in t)return n(u,l);if(f in e)return n(void 0,u)}const c={url:s,method:s,data:s,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:a,headers:(u,l,f)=>i(fv(u),fv(l),f,!0)};return Ae.forEach(Object.keys({...e,...t}),function(l){const f=c[l]||i,h=f(e[l],t[l],l);Ae.isUndefined(h)&&f!==a||(r[l]=h)}),r}var TS=e=>{const t=ya({},e);let{data:r,withXSRFToken:n,xsrfHeaderName:i,xsrfCookieName:s,headers:o,auth:a}=t;t.headers=o=Ei.from(o),t.url=bS(ES(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&o.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):"")));let c;if(Ae.isFormData(r)){if(cn.hasStandardBrowserEnv||cn.hasStandardBrowserWebWorkerEnv)o.setContentType(void 0);else if((c=o.getContentType())!==!1){const[u,...l]=c?c.split(";").map(f=>f.trim()).filter(Boolean):[];o.setContentType([u||"multipart/form-data",...l].join("; "))}}if(cn.hasStandardBrowserEnv&&(n&&Ae.isFunction(n)&&(n=n(t)),n||n!==!1&&bB(t.url))){const u=i&&s&&wB.read(s);u&&o.set(i,u)}return t};const SB=typeof XMLHttpRequest<"u";var EB=SB&&function(e){return new Promise(function(r,n){const i=TS(e);let s=i.data;const o=Ei.from(i.headers).normalize();let{responseType:a,onUploadProgress:c,onDownloadProgress:u}=i,l,f,h,v,b;function y(){v&&v(),b&&b(),i.cancelToken&&i.cancelToken.unsubscribe(l),i.signal&&i.signal.removeEventListener("abort",l)}let S=new XMLHttpRequest;S.open(i.method.toUpperCase(),i.url,!0),S.timeout=i.timeout;function C(){if(!S)return;const I=Ei.from("getAllResponseHeaders"in S&&S.getAllResponseHeaders()),D={data:!a||a==="text"||a==="json"?S.responseText:S.response,status:S.status,statusText:S.statusText,headers:I,config:e,request:S};SS(function(z){r(z),y()},function(z){n(z),y()},D),S=null}"onloadend"in S?S.onloadend=C:S.onreadystatechange=function(){!S||S.readyState!==4||S.status===0&&!(S.responseURL&&S.responseURL.indexOf("file:")===0)||setTimeout(C)},S.onabort=function(){S&&(n(new jt("Request aborted",jt.ECONNABORTED,e,S)),S=null)},S.onerror=function(){n(new jt("Network Error",jt.ERR_NETWORK,e,S)),S=null},S.ontimeout=function(){let U=i.timeout?"timeout of "+i.timeout+"ms exceeded":"timeout exceeded";const D=i.transitional||wS;i.timeoutErrorMessage&&(U=i.timeoutErrorMessage),n(new jt(U,D.clarifyTimeoutError?jt.ETIMEDOUT:jt.ECONNABORTED,e,S)),S=null},s===void 0&&o.setContentType(null),"setRequestHeader"in S&&Ae.forEach(o.toJSON(),function(U,D){S.setRequestHeader(D,U)}),Ae.isUndefined(i.withCredentials)||(S.withCredentials=!!i.withCredentials),a&&a!=="json"&&(S.responseType=i.responseType),u&&([h,b]=Hf(u,!0),S.addEventListener("progress",h)),c&&S.upload&&([f,v]=Hf(c),S.upload.addEventListener("progress",f),S.upload.addEventListener("loadend",v)),(i.cancelToken||i.signal)&&(l=I=>{S&&(n(!I||I.type?new Cc(null,e,S):I),S.abort(),S=null)},i.cancelToken&&i.cancelToken.subscribe(l),i.signal&&(i.signal.aborted?l():i.signal.addEventListener("abort",l)));const O=gB(i.url);if(O&&cn.protocols.indexOf(O)===-1){n(new jt("Unsupported protocol "+O+":",jt.ERR_BAD_REQUEST,e));return}S.send(s||null)})};const TB=(e,t)=>{const{length:r}=e=e?e.filter(Boolean):[];if(t||r){let n=new AbortController,i;const s=function(u){if(!i){i=!0,a();const l=u instanceof Error?u:this.reason;n.abort(l instanceof jt?l:new Cc(l instanceof Error?l.message:l))}};let o=t&&setTimeout(()=>{o=null,s(new jt(`timeout ${t} of ms exceeded`,jt.ETIMEDOUT))},t);const a=()=>{e&&(o&&clearTimeout(o),o=null,e.forEach(u=>{u.unsubscribe?u.unsubscribe(s):u.removeEventListener("abort",s)}),e=null)};e.forEach(u=>u.addEventListener("abort",s));const{signal:c}=n;return c.unsubscribe=()=>Ae.asap(a),c}};var CB=TB;const AB=function*(e,t){let r=e.byteLength;if(!t||r<t){yield e;return}let n=0,i;for(;n<r;)i=n+t,yield e.slice(n,i),n=i},MB=async function*(e,t){for await(const r of OB(e))yield*AB(r,t)},OB=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:r,value:n}=await t.read();if(r)break;yield n}}finally{await t.cancel()}},dv=(e,t,r,n)=>{const i=MB(e,t);let s=0,o,a=c=>{o||(o=!0,n&&n(c))};return new ReadableStream({async pull(c){try{const{done:u,value:l}=await i.next();if(u){a(),c.close();return}let f=l.byteLength;if(r){let h=s+=f;r(h)}c.enqueue(new Uint8Array(l))}catch(u){throw a(u),u}},cancel(c){return a(c),i.return()}},{highWaterMark:2})},Dd=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",CS=Dd&&typeof ReadableStream=="function",IB=Dd&&(typeof TextEncoder=="function"?(e=>t=>e.encode(t))(new TextEncoder):async e=>new Uint8Array(await new Response(e).arrayBuffer())),AS=(e,...t)=>{try{return!!e(...t)}catch{return!1}},kB=CS&&AS(()=>{let e=!1;const t=new Request(cn.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),hv=64*1024,B0=CS&&AS(()=>Ae.isReadableStream(new Response("").body)),Gf={stream:B0&&(e=>e.body)};Dd&&(e=>{["text","arrayBuffer","blob","formData","stream"].forEach(t=>{!Gf[t]&&(Gf[t]=Ae.isFunction(e[t])?r=>r[t]():(r,n)=>{throw new jt(`Response type '${t}' is not supported`,jt.ERR_NOT_SUPPORT,n)})})})(new Response);const jB=async e=>{if(e==null)return 0;if(Ae.isBlob(e))return e.size;if(Ae.isSpecCompliantForm(e))return(await new Request(cn.origin,{method:"POST",body:e}).arrayBuffer()).byteLength;if(Ae.isArrayBufferView(e)||Ae.isArrayBuffer(e))return e.byteLength;if(Ae.isURLSearchParams(e)&&(e=e+""),Ae.isString(e))return(await IB(e)).byteLength},RB=async(e,t)=>{const r=Ae.toFiniteNumber(e.getContentLength());return r??jB(t)};var PB=Dd&&(async e=>{let{url:t,method:r,data:n,signal:i,cancelToken:s,timeout:o,onDownloadProgress:a,onUploadProgress:c,responseType:u,headers:l,withCredentials:f="same-origin",fetchOptions:h}=TS(e);u=u?(u+"").toLowerCase():"text";let v=CB([i,s&&s.toAbortSignal()],o),b;const y=v&&v.unsubscribe&&(()=>{v.unsubscribe()});let S;try{if(c&&kB&&r!=="get"&&r!=="head"&&(S=await RB(l,n))!==0){let D=new Request(t,{method:"POST",body:n,duplex:"half"}),H;if(Ae.isFormData(n)&&(H=D.headers.get("content-type"))&&l.setContentType(H),D.body){const[z,ne]=uv(S,Hf(lv(c)));n=dv(D.body,hv,z,ne)}}Ae.isString(f)||(f=f?"include":"omit");const C="credentials"in Request.prototype;b=new Request(t,{...h,signal:v,method:r.toUpperCase(),headers:l.normalize().toJSON(),body:n,duplex:"half",credentials:C?f:void 0});let O=await fetch(b,h);const I=B0&&(u==="stream"||u==="response");if(B0&&(a||I&&y)){const D={};["status","statusText","headers"].forEach(le=>{D[le]=O[le]});const H=Ae.toFiniteNumber(O.headers.get("content-length")),[z,ne]=a&&uv(H,Hf(lv(a),!0))||[];O=new Response(dv(O.body,hv,z,()=>{ne&&ne(),y&&y()}),D)}u=u||"text";let U=await Gf[Ae.findKey(Gf,u)||"text"](O,e);return!I&&y&&y(),await new Promise((D,H)=>{SS(D,H,{data:U,headers:Ei.from(O.headers),status:O.status,statusText:O.statusText,config:e,request:b})})}catch(C){throw y&&y(),C&&C.name==="TypeError"&&/Load failed|fetch/i.test(C.message)?Object.assign(new jt("Network Error",jt.ERR_NETWORK,e,b),{cause:C.cause||C}):jt.from(C,C&&C.code,e,b)}});const U0={http:GL,xhr:EB,fetch:PB};Ae.forEach(U0,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const pv=e=>`- ${e}`,NB=e=>Ae.isFunction(e)||e===null||e===!1;var MS={getAdapter:e=>{e=Ae.isArray(e)?e:[e];const{length:t}=e;let r,n;const i={};for(let s=0;s<t;s++){r=e[s];let o;if(n=r,!NB(r)&&(n=U0[(o=String(r)).toLowerCase()],n===void 0))throw new jt(`Unknown adapter '${o}'`);if(n)break;i[o||"#"+s]=n}if(!n){const s=Object.entries(i).map(([a,c])=>`adapter ${a} `+(c===!1?"is not supported by the environment":"is not available in the build"));let o=t?s.length>1?`since :
|
|
45
45
|
`+s.map(pv).join(`
|
|
46
46
|
`):" "+pv(s[0]):"as no adapter specified";throw new jt("There is no suitable adapter to dispatch the request "+o,"ERR_NOT_SUPPORT")}return n},adapters:U0};function ip(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Cc(null,e)}function mv(e){return ip(e),e.headers=Ei.from(e.headers),e.data=np.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),MS.getAdapter(e.adapter||e1.adapter)(e).then(function(n){return ip(e),n.data=np.call(e,e.transformResponse,n),n.headers=Ei.from(n.headers),n},function(n){return xS(n)||(ip(e),n&&n.response&&(n.response.data=np.call(e,e.transformResponse,n.response),n.response.headers=Ei.from(n.response.headers))),Promise.reject(n)})}const OS="1.11.0",Ld={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Ld[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}});const gv={};Ld.transitional=function(t,r,n){function i(s,o){return"[Axios v"+OS+"] Transitional option '"+s+"'"+o+(n?". "+n:"")}return(s,o,a)=>{if(t===!1)throw new jt(i(o," has been removed"+(r?" in "+r:"")),jt.ERR_DEPRECATED);return r&&!gv[o]&&(gv[o]=!0,console.warn(i(o," has been deprecated since v"+r+" and will be removed in the near future"))),t?t(s,o,a):!0}};Ld.spelling=function(t){return(r,n)=>(console.warn(`${n} is likely a misspelling of ${t}`),!0)};function $B(e,t,r){if(typeof e!="object")throw new jt("options must be an object",jt.ERR_BAD_OPTION_VALUE);const n=Object.keys(e);let i=n.length;for(;i-- >0;){const s=n[i],o=t[s];if(o){const a=e[s],c=a===void 0||o(a,s,e);if(c!==!0)throw new jt("option "+s+" must be "+c,jt.ERR_BAD_OPTION_VALUE);continue}if(r!==!0)throw new jt("Unknown option "+s,jt.ERR_BAD_OPTION)}}var lf={assertOptions:$B,validators:Ld};const Bi=lf.validators;class Kf{constructor(t){this.defaults=t||{},this.interceptors={request:new av,response:new av}}async request(t,r){try{return await this._request(t,r)}catch(n){if(n instanceof Error){let i={};Error.captureStackTrace?Error.captureStackTrace(i):i=new Error;const s=i.stack?i.stack.replace(/^.+\n/,""):"";try{n.stack?s&&!String(n.stack).endsWith(s.replace(/^.+\n.+\n/,""))&&(n.stack+=`
|
|
47
|
-
`+s):n.stack=s}catch{}}throw n}}_request(t,r){typeof t=="string"?(r=r||{},r.url=t):r=t||{},r=ya(this.defaults,r);const{transitional:n,paramsSerializer:i,headers:s}=r;n!==void 0&&lf.assertOptions(n,{silentJSONParsing:Bi.transitional(Bi.boolean),forcedJSONParsing:Bi.transitional(Bi.boolean),clarifyTimeoutError:Bi.transitional(Bi.boolean)},!1),i!=null&&(Ae.isFunction(i)?r.paramsSerializer={serialize:i}:lf.assertOptions(i,{encode:Bi.function,serialize:Bi.function},!0)),r.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?r.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:r.allowAbsoluteUrls=!0),lf.assertOptions(r,{baseUrl:Bi.spelling("baseURL"),withXsrfToken:Bi.spelling("withXSRFToken")},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let o=s&&Ae.merge(s.common,s[r.method]);s&&Ae.forEach(["delete","get","head","post","put","patch","common"],b=>{delete s[b]}),r.headers=Ei.concat(o,s);const a=[];let c=!0;this.interceptors.request.forEach(function(y){typeof y.runWhen=="function"&&y.runWhen(r)===!1||(c=c&&y.synchronous,a.unshift(y.fulfilled,y.rejected))});const u=[];this.interceptors.response.forEach(function(y){u.push(y.fulfilled,y.rejected)});let l,f=0,h;if(!c){const b=[mv.bind(this),void 0];for(b.unshift(...a),b.push(...u),h=b.length,l=Promise.resolve(r);f<h;)l=l.then(b[f++],b[f++]);return l}h=a.length;let v=r;for(f=0;f<h;){const b=a[f++],y=a[f++];try{v=b(v)}catch(S){y.call(this,S);break}}try{l=mv.call(this,v)}catch(b){return Promise.reject(b)}for(f=0,h=u.length;f<h;)l=l.then(u[f++],u[f++]);return l}getUri(t){t=ya(this.defaults,t);const r=ES(t.baseURL,t.url,t.allowAbsoluteUrls);return bS(r,t.params,t.paramsSerializer)}}Ae.forEach(["delete","get","head","options"],function(t){Kf.prototype[t]=function(r,n){return this.request(ya(n||{},{method:t,url:r,data:(n||{}).data}))}});Ae.forEach(["post","put","patch"],function(t){function r(n){return function(s,o,a){return this.request(ya(a||{},{method:t,headers:n?{"Content-Type":"multipart/form-data"}:{},url:s,data:o}))}}Kf.prototype[t]=r(),Kf.prototype[t+"Form"]=r(!0)});var ff=Kf;class t1{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(s){r=s});const n=this;this.promise.then(i=>{if(!n._listeners)return;let s=n._listeners.length;for(;s-- >0;)n._listeners[s](i);n._listeners=null}),this.promise.then=i=>{let s;const o=new Promise(a=>{n.subscribe(a),s=a}).then(i);return o.cancel=function(){n.unsubscribe(s)},o},t(function(s,o,a){n.reason||(n.reason=new Cc(s,o,a),r(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const r=this._listeners.indexOf(t);r!==-1&&this._listeners.splice(r,1)}toAbortSignal(){const t=new AbortController,r=n=>{t.abort(n)};return this.subscribe(r),t.signal.unsubscribe=()=>this.unsubscribe(r),t.signal}static source(){let t;return{token:new t1(function(i){t=i}),cancel:t}}}var DB=t1;function LB(e){return function(r){return e.apply(null,r)}}function BB(e){return Ae.isObject(e)&&e.isAxiosError===!0}const F0={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(F0).forEach(([e,t])=>{F0[t]=e});var UB=F0;function IS(e){const t=new ff(e),r=aS(ff.prototype.request,t);return Ae.extend(r,ff.prototype,t,{allOwnKeys:!0}),Ae.extend(r,t,null,{allOwnKeys:!0}),r.create=function(i){return IS(ya(e,i))},r}const Ir=IS(e1);Ir.Axios=ff;Ir.CanceledError=Cc;Ir.CancelToken=DB;Ir.isCancel=xS;Ir.VERSION=OS;Ir.toFormData=Nd;Ir.AxiosError=jt;Ir.Cancel=Ir.CanceledError;Ir.all=function(t){return Promise.all(t)};Ir.spread=LB;Ir.isAxiosError=BB;Ir.mergeConfig=ya;Ir.AxiosHeaders=Ei;Ir.formToJSON=e=>_S(Ae.isHTMLForm(e)?new FormData(e):e);Ir.getAdapter=MS.getAdapter;Ir.HttpStatusCode=UB;Ir.default=Ir;var kS=Ir,r1={exports:{}},Vn={},jS={exports:{}};(function(e){function t(r){return r&&r.__esModule?r:{default:r}}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports})(jS);var FB=jS.exports,sp={exports:{}},op={exports:{}},yv;function RS(){return yv||(yv=1,function(e){function t(r,n){this.v=r,this.k=n}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}(op)),op.exports}var ap={exports:{}},cp={exports:{}},vv;function PS(){return vv||(vv=1,function(e){function t(r,n,i,s){var o=Object.defineProperty;try{o({},"",{})}catch{o=0}e.exports=t=function(c,u,l,f){function h(v,b){t(c,v,function(y){return this._invoke(v,b,y)})}u?o?o(c,u,{value:l,enumerable:!f,configurable:!f,writable:!f}):c[u]=l:(h("next",0),h("throw",1),h("return",2))},e.exports.__esModule=!0,e.exports.default=e.exports,t(r,n,i,s)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}(cp)),cp.exports}var bv;function NS(){return bv||(bv=1,function(e){var t=PS();function r(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var n,i,s=typeof Symbol=="function"?Symbol:{},o=s.iterator||"@@iterator",a=s.toStringTag||"@@toStringTag";function c(S,C,O,I){var U=C&&C.prototype instanceof l?C:l,D=Object.create(U.prototype);return t(D,"_invoke",function(H,z,ne){var le,te,ce,V=0,L=ne||[],p=!1,d={p:0,n:0,v:n,a:m,f:m.bind(n,4),d:function(E,A){return le=E,te=0,ce=n,d.n=A,u}};function m(x,E){for(te=x,ce=E,i=0;!p&&V&&!A&&i<L.length;i++){var A,j=L[i],k=d.p,g=j[2];x>3?(A=g===E)&&(ce=j[(te=j[4])?5:(te=3,3)],j[4]=j[5]=n):j[0]<=k&&((A=x<2&&k<j[1])?(te=0,d.v=E,d.n=j[1]):k<g&&(A=x<3||j[0]>E||E>g)&&(j[4]=x,j[5]=E,d.n=g,te=0))}if(A||x>1)return u;throw p=!0,E}return function(x,E,A){if(V>1)throw TypeError("Generator is already running");for(p&&E===1&&m(E,A),te=E,ce=A;(i=te<2?n:ce)||!p;){le||(te?te<3?(te>1&&(d.n=-1),m(te,ce)):d.n=ce:d.v=ce);try{if(V=2,le){if(te||(x="next"),i=le[x]){if(!(i=i.call(le,ce)))throw TypeError("iterator result is not an object");if(!i.done)return i;ce=i.value,te<2&&(te=0)}else te===1&&(i=le.return)&&i.call(le),te<2&&(ce=TypeError("The iterator does not provide a '"+x+"' method"),te=1);le=n}else if((i=(p=d.n<0)?ce:H.call(z,d))!==u)break}catch(j){le=n,te=1,ce=j}finally{V=1}}return{value:i,done:p}}}(S,O,I),!0),D}var u={};function l(){}function f(){}function h(){}i=Object.getPrototypeOf;var v=[][o]?i(i([][o]())):(t(i={},o,function(){return this}),i),b=h.prototype=l.prototype=Object.create(v);function y(S){return Object.setPrototypeOf?Object.setPrototypeOf(S,h):(S.__proto__=h,t(S,a,"GeneratorFunction")),S.prototype=Object.create(b),S}return f.prototype=h,t(b,"constructor",h),t(h,"constructor",f),f.displayName="GeneratorFunction",t(h,a,"GeneratorFunction"),t(b),t(b,a,"Generator"),t(b,o,function(){return this}),t(b,"toString",function(){return"[object Generator]"}),(e.exports=r=function(){return{w:c,m:y}},e.exports.__esModule=!0,e.exports.default=e.exports)()}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports}(ap)),ap.exports}var up={exports:{}},lp={exports:{}},fp={exports:{}},wv;function $S(){return wv||(wv=1,function(e){var t=RS(),r=PS();function n(i,s){function o(c,u,l,f){try{var h=i[c](u),v=h.value;return v instanceof t?s.resolve(v.v).then(function(b){o("next",b,l,f)},function(b){o("throw",b,l,f)}):s.resolve(v).then(function(b){h.value=b,l(h)},function(b){return o("throw",b,l,f)})}catch(b){f(b)}}var a;this.next||(r(n.prototype),r(n.prototype,typeof Symbol=="function"&&Symbol.asyncIterator||"@asyncIterator",function(){return this})),r(this,"_invoke",function(c,u,l){function f(){return new s(function(h,v){o(c,l,h,v)})}return a=a?a.then(f,f):f()},!0)}e.exports=n,e.exports.__esModule=!0,e.exports.default=e.exports}(fp)),fp.exports}var _v;function DS(){return _v||(_v=1,function(e){var t=NS(),r=$S();function n(i,s,o,a,c){return new r(t().w(i,s,o,a),c||Promise)}e.exports=n,e.exports.__esModule=!0,e.exports.default=e.exports}(lp)),lp.exports}var xv;function VB(){return xv||(xv=1,function(e){var t=DS();function r(n,i,s,o,a){var c=t(n,i,s,o,a);return c.next().then(function(u){return u.done?u.value:c.next()})}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports}(up)),up.exports}var dp={exports:{}},Sv;function zB(){return Sv||(Sv=1,function(e){function t(r){var n=Object(r),i=[];for(var s in n)i.unshift(s);return function o(){for(;i.length;)if((s=i.pop())in n)return o.value=s,o.done=!1,o;return o.done=!0,o}}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}(dp)),dp.exports}var hp={exports:{}},pp={exports:{}},Ev;function Bd(){return Ev||(Ev=1,function(e){function t(r){"@babel/helpers - typeof";return e.exports=t=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(n){return typeof n}:function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},e.exports.__esModule=!0,e.exports.default=e.exports,t(r)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}(pp)),pp.exports}var Tv;function WB(){return Tv||(Tv=1,function(e){var t=Bd().default;function r(n){if(n!=null){var i=n[typeof Symbol=="function"&&Symbol.iterator||"@@iterator"],s=0;if(i)return i.call(n);if(typeof n.next=="function")return n;if(!isNaN(n.length))return{next:function(){return n&&s>=n.length&&(n=void 0),{value:n&&n[s++],done:!n}}}}throw new TypeError(t(n)+" is not iterable")}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports}(hp)),hp.exports}var Cv;function qB(){return Cv||(Cv=1,function(e){var t=RS(),r=NS(),n=VB(),i=DS(),s=$S(),o=zB(),a=WB();function c(){var u=r(),l=u.m(c),f=(Object.getPrototypeOf?Object.getPrototypeOf(l):l.__proto__).constructor;function h(y){var S=typeof y=="function"&&y.constructor;return!!S&&(S===f||(S.displayName||S.name)==="GeneratorFunction")}var v={throw:1,return:2,break:3,continue:3};function b(y){var S,C;return function(O){S||(S={stop:function(){return C(O.a,2)},catch:function(){return O.v},abrupt:function(U,D){return C(O.a,v[U],D)},delegateYield:function(U,D,H){return S.resultName=D,C(O.d,a(U),H)},finish:function(U){return C(O.f,U)}},C=function(U,D,H){O.p=S.prev,O.n=S.next;try{return U(D,H)}finally{S.next=O.n}}),S.resultName&&(S[S.resultName]=O.v,S.resultName=void 0),S.sent=O.v,S.next=O.n;try{return y.call(this,S)}finally{O.p=S.prev,O.n=S.next}}}return(e.exports=c=function(){return{wrap:function(C,O,I,U){return u.w(b(C),O,I,U&&U.reverse())},isGeneratorFunction:h,mark:u.m,awrap:function(C,O){return new t(C,O)},AsyncIterator:s,async:function(C,O,I,U,D){return(h(O)?i:n)(b(C),O,I,U,D)},keys:o,values:a}},e.exports.__esModule=!0,e.exports.default=e.exports)()}e.exports=c,e.exports.__esModule=!0,e.exports.default=e.exports}(sp)),sp.exports}var mp,Av;function HB(){if(Av)return mp;Av=1;var e=qB()();mp=e;try{regeneratorRuntime=e}catch{typeof globalThis=="object"?globalThis.regeneratorRuntime=e:Function("r","regeneratorRuntime = r")(e)}return mp}var gp={exports:{}},Mv;function GB(){return Mv||(Mv=1,function(e){function t(n,i,s,o,a,c,u){try{var l=n[c](u),f=l.value}catch(h){return void s(h)}l.done?i(f):Promise.resolve(f).then(o,a)}function r(n){return function(){var i=this,s=arguments;return new Promise(function(o,a){var c=n.apply(i,s);function u(f){t(c,o,a,u,l,"next",f)}function l(f){t(c,o,a,u,l,"throw",f)}u(void 0)})}}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports}(gp)),gp.exports}var yp={exports:{}},vp={exports:{}},bp={exports:{}},Ov;function KB(){return Ov||(Ov=1,function(e){var t=Bd().default;function r(n,i){if(t(n)!="object"||!n)return n;var s=n[Symbol.toPrimitive];if(s!==void 0){var o=s.call(n,i||"default");if(t(o)!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(i==="string"?String:Number)(n)}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports}(bp)),bp.exports}var Iv;function YB(){return Iv||(Iv=1,function(e){var t=Bd().default,r=KB();function n(i){var s=r(i,"string");return t(s)=="symbol"?s:s+""}e.exports=n,e.exports.__esModule=!0,e.exports.default=e.exports}(vp)),vp.exports}var kv;function XB(){return kv||(kv=1,function(e){var t=YB();function r(n,i,s){return(i=t(i))in n?Object.defineProperty(n,i,{value:s,enumerable:!0,configurable:!0,writable:!0}):n[i]=s,n}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports}(yp)),yp.exports}var wp,jv;function JB(){if(jv)return wp;jv=1;const e=new Set(["ENOTFOUND","ENETUNREACH","UNABLE_TO_GET_ISSUER_CERT","UNABLE_TO_GET_CRL","UNABLE_TO_DECRYPT_CERT_SIGNATURE","UNABLE_TO_DECRYPT_CRL_SIGNATURE","UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY","CERT_SIGNATURE_FAILURE","CRL_SIGNATURE_FAILURE","CERT_NOT_YET_VALID","CERT_HAS_EXPIRED","CRL_NOT_YET_VALID","CRL_HAS_EXPIRED","ERROR_IN_CERT_NOT_BEFORE_FIELD","ERROR_IN_CERT_NOT_AFTER_FIELD","ERROR_IN_CRL_LAST_UPDATE_FIELD","ERROR_IN_CRL_NEXT_UPDATE_FIELD","OUT_OF_MEM","DEPTH_ZERO_SELF_SIGNED_CERT","SELF_SIGNED_CERT_IN_CHAIN","UNABLE_TO_GET_ISSUER_CERT_LOCALLY","UNABLE_TO_VERIFY_LEAF_SIGNATURE","CERT_CHAIN_TOO_LONG","CERT_REVOKED","INVALID_CA","PATH_LENGTH_EXCEEDED","INVALID_PURPOSE","CERT_UNTRUSTED","CERT_REJECTED","HOSTNAME_MISMATCH"]);return wp=t=>!e.has(t&&t.code),wp}var ol=FB;Object.defineProperty(Vn,"__esModule",{value:!0});Vn.isNetworkError=i1;Vn.isRetryableError=Ud;Vn.isSafeRequestError=US;Vn.isIdempotentRequestError=s1;Vn.isNetworkOrIdempotentRequestError=o1;Vn.exponentialDelay=FS;Vn.default=Ca;Vn.DEFAULT_OPTIONS=Vn.namespace=void 0;var Yf=ol(HB()),ZB=ol(Bd()),LS=ol(GB()),QB=ol(XB()),eU=ol(JB());function Rv(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function _p(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Rv(Object(r),!0).forEach(function(n){(0,QB.default)(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Rv(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}var n1="axios-retry";Vn.namespace=n1;function i1(e){var t=["ERR_CANCELED","ECONNABORTED"];return!e.response&&!!e.code&&!t.includes(e.code)&&(0,eU.default)(e)}var BS=["get","head","options"],tU=BS.concat(["put","delete"]);function Ud(e){return e.code!=="ECONNABORTED"&&(!e.response||e.response.status>=500&&e.response.status<=599)}function US(e){return e.config?Ud(e)&&BS.indexOf(e.config.method)!==-1:!1}function s1(e){return e.config?Ud(e)&&tU.indexOf(e.config.method)!==-1:!1}function o1(e){return i1(e)||s1(e)}function rU(){return 0}function FS(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:100,r=Math.pow(2,e)*t,n=r*.2*Math.random();return r+n}var VS={retries:3,retryCondition:o1,retryDelay:rU,shouldResetTimeout:!1,onRetry:function(){}};Vn.DEFAULT_OPTIONS=VS;function nU(e,t){return _p(_p(_p({},VS),t),e[n1])}function Pv(e,t){var r=nU(e,t);return r.retryCount=r.retryCount||0,e[n1]=r,r}function iU(e,t){e.defaults.agent===t.agent&&delete t.agent,e.defaults.httpAgent===t.httpAgent&&delete t.httpAgent,e.defaults.httpsAgent===t.httpsAgent&&delete t.httpsAgent}function sU(e,t){return V0.apply(this,arguments)}function V0(){return V0=(0,LS.default)(Yf.default.mark(function e(t,r){var n,i,s,o;return Yf.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:if(n=t.retries,i=t.retryCondition,s=t.retryCount<n&&i(r),(0,ZB.default)(s)!=="object"){c.next=13;break}return c.prev=3,c.next=6,s;case 6:return o=c.sent,c.abrupt("return",o!==!1);case 10:return c.prev=10,c.t0=c.catch(3),c.abrupt("return",!1);case 13:return c.abrupt("return",s);case 14:case"end":return c.stop()}},e,null,[[3,10]])})),V0.apply(this,arguments)}function Ca(e,t){var r=e.interceptors.request.use(function(i){var s=Pv(i,t);return s.lastRequestTime=Date.now(),i}),n=e.interceptors.response.use(null,function(){var i=(0,LS.default)(Yf.default.mark(function s(o){var a,c,u,l,f,h,v,b;return Yf.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:if(a=o.config,a){S.next=3;break}return S.abrupt("return",Promise.reject(o));case 3:return c=Pv(a,t),S.next=6,sU(c,o);case 6:if(!S.sent){S.next=21;break}if(c.retryCount+=1,u=c.retryDelay,l=c.shouldResetTimeout,f=c.onRetry,h=u(c.retryCount,o),iU(e,a),!(!l&&a.timeout&&c.lastRequestTime)){S.next=17;break}if(v=Date.now()-c.lastRequestTime,b=a.timeout-v-h,!(b<=0)){S.next=16;break}return S.abrupt("return",Promise.reject(o));case 16:a.timeout=b;case 17:return a.transformRequest=[function(C){return C}],S.next=20,f(c.retryCount,o,a);case 20:return S.abrupt("return",new Promise(function(C){return setTimeout(function(){return C(e(a))},h)}));case 21:return S.abrupt("return",Promise.reject(o));case 22:case"end":return S.stop()}},s)}));return function(s){return i.apply(this,arguments)}}());return{requestInterceptorId:r,responseInterceptorId:n}}Ca.isNetworkError=i1;Ca.isSafeRequestError=US;Ca.isIdempotentRequestError=s1;Ca.isNetworkOrIdempotentRequestError=o1;Ca.exponentialDelay=FS;Ca.isRetryableError=Ud;const zS=Vn.default;r1.exports=zS;r1.exports.default=zS;var oU=r1.exports,Fd={},Ya=null;typeof WebSocket<"u"?Ya=WebSocket:typeof MozWebSocket<"u"?Ya=MozWebSocket:typeof qr<"u"?Ya=qr.WebSocket||qr.MozWebSocket:typeof window<"u"?Ya=window.WebSocket||window.MozWebSocket:typeof self<"u"&&(Ya=self.WebSocket||self.MozWebSocket);var aU=Ya,cU=qr&&qr.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Fd,"__esModule",{value:!0});Fd.ResilientWebSocket=void 0;const uU=cU(aU),lU=3e4+3e3;class fU{constructor(t,r){Pt(this,"endpoint");Pt(this,"wsClient");Pt(this,"wsUserClosed");Pt(this,"wsFailedAttempts");Pt(this,"pingTimeout");Pt(this,"logger");Pt(this,"onError");Pt(this,"onMessage");Pt(this,"onReconnect");this.endpoint=t,this.logger=r,this.wsFailedAttempts=0,this.onError=n=>{var i;(i=this.logger)==null||i.error(n)},this.wsUserClosed=!0,this.onMessage=()=>{},this.onReconnect=()=>{}}async send(t){var r,n,i;(r=this.logger)==null||r.info(`Sending ${t}`),await this.waitForMaybeReadyWebSocket(),this.wsClient===void 0?(n=this.logger)==null||n.error("Couldn't connect to the websocket server. Error callback is called."):(i=this.wsClient)==null||i.send(t)}async startWebSocket(){var t;this.wsClient===void 0&&((t=this.logger)==null||t.info("Creating Web Socket client"),this.wsClient=new uU.default(this.endpoint),this.wsUserClosed=!1,this.wsClient.onopen=()=>{this.wsFailedAttempts=0,this.wsClient.on!==void 0&&this.heartbeat()},this.wsClient.onerror=r=>{this.onError(r.error)},this.wsClient.onmessage=r=>{this.onMessage(r.data)},this.wsClient.onclose=async()=>{var r,n;if(this.pingTimeout!==void 0&&clearInterval(this.pingTimeout),this.wsUserClosed===!1){this.wsFailedAttempts+=1,this.wsClient=void 0;const i=dU(this.wsFailedAttempts);(r=this.logger)==null||r.error(`Connection closed unexpectedly or because of timeout. Reconnecting after ${i}ms.`),await Nv(i),this.restartUnexpectedClosedWebsocket()}else(n=this.logger)==null||n.info("The connection has been closed successfully.")},this.wsClient.on!==void 0&&this.wsClient.on("ping",this.heartbeat.bind(this)))}heartbeat(){var t;(t=this.logger)==null||t.info("Heartbeat"),this.pingTimeout!==void 0&&clearTimeout(this.pingTimeout),this.pingTimeout=setTimeout(()=>{var r,n;(r=this.logger)==null||r.warn("Connection timed out. Reconnecting..."),(n=this.wsClient)==null||n.terminate(),this.restartUnexpectedClosedWebsocket()},lU)}async waitForMaybeReadyWebSocket(){let t=0;for(;this.wsClient!==void 0&&this.wsClient.readyState!==this.wsClient.OPEN;)if(t>5e3){this.wsClient.close();return}else t+=10,await Nv(10)}async restartUnexpectedClosedWebsocket(){var t;if(this.wsUserClosed!==!0){if(await this.startWebSocket(),await this.waitForMaybeReadyWebSocket(),this.wsClient===void 0){(t=this.logger)==null||t.error("Couldn't reconnect to websocket. Error callback is called.");return}this.onReconnect()}}closeWebSocket(){if(this.wsClient!==void 0){const t=this.wsClient;this.wsClient=void 0,t.close()}this.wsUserClosed=!0}}Fd.ResilientWebSocket=fU;async function Nv(e){return new Promise(t=>setTimeout(t,e))}function dU(e){return 2**e*100}var hc={};Object.defineProperty(hc,"__esModule",{value:!0});hc.removeLeading0xIfExists=hc.makeWebsocketUrl=void 0;function hU(e){const t=new URL("ws",e),r=t.protocol==="https:";return t.protocol=r?"wss:":"ws:",t.toString()}hc.makeWebsocketUrl=hU;function pU(e){return e.startsWith("0x")?e.substring(2):e}hc.removeLeading0xIfExists=pU;var WS=qr&&qr.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Od,"__esModule",{value:!0});Od.PriceServiceConnection=void 0;const xp=Gg,mU=WS(kS),$v=WS(oU),gU=Fd,Sp=hc;class yU{constructor(t,r){Pt(this,"httpClient");Pt(this,"priceFeedCallbacks");Pt(this,"wsClient");Pt(this,"wsEndpoint");Pt(this,"logger");Pt(this,"priceFeedRequestConfig");Pt(this,"onWsError");var n,i,s;this.httpClient=mU.default.create({baseURL:t,timeout:(r==null?void 0:r.timeout)||5e3}),(0,$v.default)(this.httpClient,{retries:(r==null?void 0:r.httpRetries)||3,retryDelay:$v.default.exponentialDelay}),this.priceFeedRequestConfig={binary:(n=r==null?void 0:r.priceFeedRequestConfig)==null?void 0:n.binary,verbose:((i=r==null?void 0:r.priceFeedRequestConfig)==null?void 0:i.verbose)??(r==null?void 0:r.verbose),allowOutOfOrder:(s=r==null?void 0:r.priceFeedRequestConfig)==null?void 0:s.allowOutOfOrder},this.priceFeedCallbacks=new Map,this.logger=(r==null?void 0:r.logger)||{trace:()=>{},debug:()=>{},info:()=>{},warn:console.warn,error:console.error},this.onWsError=o=>{this.logger.error(o),typeof In<"u"&&typeof In.exit=="function"?(this.logger.error("Halting the process due to the websocket error"),In.exit(1)):this.logger.error("Cannot halt process. Please handle the websocket error.")},this.wsEndpoint=(0,Sp.makeWebsocketUrl)(t)}async getLatestPriceFeeds(t){return t.length===0?[]:(await this.httpClient.get("/api/latest_price_feeds",{params:{ids:t,verbose:this.priceFeedRequestConfig.verbose,binary:this.priceFeedRequestConfig.binary}})).data.map(i=>xp.PriceFeed.fromJson(i))}async getLatestVaas(t){return(await this.httpClient.get("/api/latest_vaas",{params:{ids:t}})).data}async getVaa(t,r){const n=await this.httpClient.get("/api/get_vaa",{params:{id:t,publish_time:r}});return[n.data.vaa,n.data.publishTime]}async getPriceFeed(t,r){const n=await this.httpClient.get("/api/get_price_feed",{params:{id:t,publish_time:r,verbose:this.priceFeedRequestConfig.verbose,binary:this.priceFeedRequestConfig.binary}});return xp.PriceFeed.fromJson(n.data)}async getPriceFeedIds(){return(await this.httpClient.get("/api/price_feed_ids")).data}async subscribePriceFeedUpdates(t,r){var s;this.wsClient===void 0&&await this.startWebSocket(),t=t.map(o=>(0,Sp.removeLeading0xIfExists)(o));const n=[];for(const o of t)this.priceFeedCallbacks.has(o)||(this.priceFeedCallbacks.set(o,new Set),n.push(o)),this.priceFeedCallbacks.get(o).add(r);const i={ids:n,type:"subscribe",verbose:this.priceFeedRequestConfig.verbose,binary:this.priceFeedRequestConfig.binary,allow_out_of_order:this.priceFeedRequestConfig.allowOutOfOrder};await((s=this.wsClient)==null?void 0:s.send(JSON.stringify(i)))}async unsubscribePriceFeedUpdates(t,r){var s;this.wsClient===void 0&&await this.startWebSocket(),t=t.map(o=>(0,Sp.removeLeading0xIfExists)(o));const n=[];for(const o of t)if(this.priceFeedCallbacks.has(o)){let a=!1;r===void 0?(this.priceFeedCallbacks.delete(o),a=!0):(this.priceFeedCallbacks.get(o).delete(r),this.priceFeedCallbacks.get(o).size===0&&(this.priceFeedCallbacks.delete(o),a=!0)),a&&n.push(o)}const i={ids:n,type:"unsubscribe"};await((s=this.wsClient)==null?void 0:s.send(JSON.stringify(i))),this.priceFeedCallbacks.size===0&&this.closeWebSocket()}async startWebSocket(){if(this.wsEndpoint===void 0)throw new Error("Websocket endpoint is undefined.");this.wsClient=new gU.ResilientWebSocket(this.wsEndpoint,this.logger),this.wsClient.onError=this.onWsError,this.wsClient.onReconnect=()=>{var t;if(this.priceFeedCallbacks.size>0){const r={ids:Array.from(this.priceFeedCallbacks.keys()),type:"subscribe",verbose:this.priceFeedRequestConfig.verbose,binary:this.priceFeedRequestConfig.binary,allow_out_of_order:this.priceFeedRequestConfig.allowOutOfOrder};this.logger.info("Resubscribing to existing price feeds."),(t=this.wsClient)==null||t.send(JSON.stringify(r))}},this.wsClient.onMessage=t=>{this.logger.info(`Received message ${t.toString()}`);let r;try{r=JSON.parse(t.toString())}catch(n){this.logger.error(`Error parsing message ${t.toString()} as JSON.`),this.logger.error(n),this.onWsError(n);return}if(r.type==="response")r.status==="error"&&(this.logger.error(`Error response from the websocket server ${r.error}.`),this.onWsError(new Error(r.error)));else if(r.type==="price_update"){let n;try{n=xp.PriceFeed.fromJson(r.price_feed)}catch(i){this.logger.error(`Error parsing price feeds from message ${t.toString()}.`),this.logger.error(i),this.onWsError(i);return}if(this.priceFeedCallbacks.has(n.id))for(const i of this.priceFeedCallbacks.get(n.id))i(n)}else this.logger.warn(`Ignoring unsupported server response ${t.toString()}.`)},await this.wsClient.startWebSocket()}closeWebSocket(){var t;(t=this.wsClient)==null||t.closeWebSocket(),this.wsClient=void 0,this.priceFeedCallbacks.clear()}}Od.PriceServiceConnection=yU;(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.parseAccumulatorUpdateData=e.isAccumulatorUpdateData=e.Price=e.PriceFeed=e.PriceFeedMetadata=e.PriceServiceConnection=void 0;var t=Od;Object.defineProperty(e,"PriceServiceConnection",{enumerable:!0,get:function(){return t.PriceServiceConnection}});var r=Gg;Object.defineProperty(e,"PriceFeedMetadata",{enumerable:!0,get:function(){return r.PriceFeedMetadata}}),Object.defineProperty(e,"PriceFeed",{enumerable:!0,get:function(){return r.PriceFeed}}),Object.defineProperty(e,"Price",{enumerable:!0,get:function(){return r.Price}}),Object.defineProperty(e,"isAccumulatorUpdateData",{enumerable:!0,get:function(){return r.isAccumulatorUpdateData}}),Object.defineProperty(e,"parseAccumulatorUpdateData",{enumerable:!0,get:function(){return r.parseAccumulatorUpdateData}})})(Hg);Object.defineProperty(Md,"__esModule",{value:!0});Md.SuiPriceServiceConnection=void 0;const vU=Hg,bU=kd();class wU extends vU.PriceServiceConnection{async getPriceFeedsUpdateData(t){return(await this.getLatestVaas(t)).map(n=>bU.Buffer.from(n,"base64"))}}Md.SuiPriceServiceConnection=wU;var Vd={};Object.defineProperty(Vd,"__esModule",{value:!0});Vd.SuiPythClient=void 0;const Ml=xx,Pa=Oi,_U=kd(),Ep=16*1024;class xU{constructor(t,r,n){Pt(this,"provider");Pt(this,"pythStateId");Pt(this,"wormholeStateId");Pt(this,"pythPackageId");Pt(this,"wormholePackageId");Pt(this,"priceTableInfo");Pt(this,"priceFeedObjectIdCache",new Map);Pt(this,"baseUpdateFee");this.provider=t,this.pythStateId=r,this.wormholeStateId=n,this.pythPackageId=void 0,this.wormholePackageId=void 0}async getBaseUpdateFee(){if(this.baseUpdateFee===void 0){const t=await this.provider.getObject({id:this.pythStateId,options:{showContent:!0}});if(!t.data||!t.data.content||t.data.content.dataType!=="moveObject")throw new Error("Unable to fetch pyth state object");this.baseUpdateFee=t.data.content.fields.base_update_fee}return this.baseUpdateFee}async getPackageId(t){const r=await this.provider.getObject({id:t,options:{showContent:!0}}).then(n=>{var i,s;if(((s=(i=n.data)==null?void 0:i.content)==null?void 0:s.dataType)=="moveObject")return n.data.content.fields;throw new Error(`Cannot fetch package id for object ${t}`)});if("upgrade_cap"in r)return r.upgrade_cap.fields.package;throw new Error("upgrade_cap not found")}async verifyVaas(t,r){const n=await this.getWormholePackageId(),i=[];for(const s of t){const[o]=r.moveCall({target:`${n}::vaa::parse_and_verify`,arguments:[r.object(this.wormholeStateId),r.pure(Pa.bcs.vector(Pa.bcs.U8).serialize(Array.from(s),{maxSize:Ep}).toBytes()),r.object(Ml.SUI_CLOCK_OBJECT_ID)]});i.push(o)}return i}async verifyVaasAndGetHotPotato(t,r,n){if(r.length>1)throw new Error("SDK does not support sending multiple accumulator messages in a single transaction");const i=this.extractVaaBytesFromAccumulatorMessage(r[0]),s=await this.verifyVaas([i],t),[o]=t.moveCall({target:`${n}::pyth::create_authenticated_price_infos_using_accumulator`,arguments:[t.object(this.pythStateId),t.pure(Pa.bcs.vector(Pa.bcs.U8).serialize(Array.from(r[0]),{maxSize:Ep}).toBytes()),s[0],t.object(Ml.SUI_CLOCK_OBJECT_ID)]});return o}async executePriceFeedUpdates(t,r,n,i,s){const o=[];let a=0;for(const c of n){const u=await this.getPriceFeedObjectId(c);if(!u)throw new Error(`Price feed ${c} not found, please create it first`);o.push(u),[i]=t.moveCall({target:`${r}::pyth::update_single_price_feed`,arguments:[t.object(this.pythStateId),i,t.object(u),s[a],t.object(Ml.SUI_CLOCK_OBJECT_ID)]}),a++}return t.moveCall({target:`${r}::hot_potato_vector::destroy`,arguments:[i],typeArguments:[`${r}::price_info::PriceInfo`]}),o}async updatePriceFeeds(t,r,n){const i=await this.getPythPackageId(),s=await this.verifyVaasAndGetHotPotato(t,r,i),o=await this.getBaseUpdateFee(),a=t.splitCoins(t.gas,n.map(()=>t.pure.u64(o)));return await this.executePriceFeedUpdates(t,i,n,s,a)}async updatePriceFeedsWithCoins(t,r,n,i){const s=await this.getPythPackageId(),o=await this.verifyVaasAndGetHotPotato(t,r,s);return await this.executePriceFeedUpdates(t,s,n,o,i)}async createPriceFeed(t,r){const n=await this.getPythPackageId();if(r.length>1)throw new Error("SDK does not support sending multiple accumulator messages in a single transaction");const i=this.extractVaaBytesFromAccumulatorMessage(r[0]),s=await this.verifyVaas([i],t);t.moveCall({target:`${n}::pyth::create_price_feeds_using_accumulator`,arguments:[t.object(this.pythStateId),t.pure(Pa.bcs.vector(Pa.bcs.U8).serialize(Array.from(r[0]),{maxSize:Ep}).toBytes()),s[0],t.object(Ml.SUI_CLOCK_OBJECT_ID)]})}async getWormholePackageId(){return this.wormholePackageId||(this.wormholePackageId=await this.getPackageId(this.wormholeStateId)),this.wormholePackageId}async getPythPackageId(){return this.pythPackageId||(this.pythPackageId=await this.getPackageId(this.pythStateId)),this.pythPackageId}async getPriceFeedObjectId(t){const r=t.replace("0x","");if(!this.priceFeedObjectIdCache.has(r)){const{id:n,fieldType:i}=await this.getPriceTableInfo(),s=await this.provider.getDynamicFieldObject({parentId:n,name:{type:`${i}::price_identifier::PriceIdentifier`,value:{bytes:Array.from(_U.Buffer.from(r,"hex"))}}});if(!s.data||!s.data.content)return;if(s.data.content.dataType!=="moveObject")throw new Error("Price feed type mismatch");this.priceFeedObjectIdCache.set(r,s.data.content.fields.value)}return this.priceFeedObjectIdCache.get(r)}async getPriceTableInfo(){if(this.priceTableInfo===void 0){const t=await this.provider.getDynamicFieldObject({parentId:this.pythStateId,name:{type:"vector<u8>",value:"price_info"}});if(!t.data||!t.data.type)throw new Error("Price Table not found, contract may not be initialized");let r=t.data.type.replace("0x2::table::Table<","");r=r.replace("::price_identifier::PriceIdentifier, 0x2::object::ID>",""),this.priceTableInfo={id:t.data.objectId,fieldType:r}}return this.priceTableInfo}extractVaaBytesFromAccumulatorMessage(t){const n=7+t.readUint8(6)+1,i=t.readUint16BE(n),s=n+2;return t.subarray(s,s+i)}}Vd.SuiPythClient=xU;(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.PriceFeed=e.Price=e.SuiPythClient=e.SuiPriceServiceConnection=void 0;var t=Md;Object.defineProperty(e,"SuiPriceServiceConnection",{enumerable:!0,get:function(){return t.SuiPriceServiceConnection}});var r=Vd;Object.defineProperty(e,"SuiPythClient",{enumerable:!0,get:function(){return r.SuiPythClient}});var n=Hg;Object.defineProperty(e,"Price",{enumerable:!0,get:function(){return n.Price}}),Object.defineProperty(e,"PriceFeed",{enumerable:!0,get:function(){return n.PriceFeed}})})(iS);var Tp=ei,SU=AN,fr=xx,Dv=HD,Lv=iS;function EU(e){return e&&e.__esModule?e:{default:e}}var TU=EU(SU),CU=Object.create,a1=Object.defineProperty,AU=Object.defineProperties,MU=Object.getOwnPropertyDescriptor,OU=Object.getOwnPropertyDescriptors,qS=Object.getOwnPropertyNames,Bv=Object.getOwnPropertySymbols,IU=Object.getPrototypeOf,HS=Object.prototype.hasOwnProperty,kU=Object.prototype.propertyIsEnumerable,Uv=(e,t,r)=>t in e?a1(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,jU=(e,t)=>{for(var r in t||(t={}))HS.call(t,r)&&Uv(e,r,t[r]);if(Bv)for(var r of Bv(t))kU.call(t,r)&&Uv(e,r,t[r]);return e},RU=(e,t)=>AU(e,OU(t)),PU=(e=>typeof qi<"u"?qi:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof qi<"u"?qi:t)[r]}):e)(function(e){if(typeof qi<"u")return qi.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')}),NU=(e,t)=>function(){return t||(0,e[qS(e)[0]])((t={exports:{}}).exports,t),t.exports},$U=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of qS(t))!HS.call(e,i)&&i!==r&&a1(e,i,{get:()=>t[i],enumerable:!(n=MU(t,i))||n.enumerable});return e},Ac=(e,t,r)=>(r=e!=null?CU(IU(e)):{},$U(!e||!e.__esModule?a1(r,"default",{value:e,enumerable:!0}):r,e)),mn=(e,t,r)=>new Promise((n,i)=>{var s=c=>{try{a(r.next(c))}catch(u){i(u)}},o=c=>{try{a(r.throw(c))}catch(u){i(u)}},a=c=>c.done?n(c.value):Promise.resolve(c.value).then(s,o);a((r=r.apply(e,t)).next())}),Mc=NU({"node_modules/bn.js/lib/bn.js"(e,t){(function(r,n){function i(p,d){if(!p)throw new Error(d||"Assertion failed")}function s(p,d){p.super_=d;var m=function(){};m.prototype=d.prototype,p.prototype=new m,p.prototype.constructor=p}function o(p,d,m){if(o.isBN(p))return p;this.negative=0,this.words=null,this.length=0,this.red=null,p!==null&&((d==="le"||d==="be")&&(m=d,d=10),this._init(p||0,d||10,m||"be"))}typeof r=="object"?r.exports=o:n.BN=o,o.BN=o,o.wordSize=26;var a;try{typeof window<"u"&&typeof window.Buffer<"u"?a=window.Buffer:a=PU("buffer").Buffer}catch{}o.isBN=function(d){return d instanceof o?!0:d!==null&&typeof d=="object"&&d.constructor.wordSize===o.wordSize&&Array.isArray(d.words)},o.max=function(d,m){return d.cmp(m)>0?d:m},o.min=function(d,m){return d.cmp(m)<0?d:m},o.prototype._init=function(d,m,x){if(typeof d=="number")return this._initNumber(d,m,x);if(typeof d=="object")return this._initArray(d,m,x);m==="hex"&&(m=16),i(m===(m|0)&&m>=2&&m<=36),d=d.toString().replace(/\s+/g,"");var E=0;d[0]==="-"&&(E++,this.negative=1),E<d.length&&(m===16?this._parseHex(d,E,x):(this._parseBase(d,m,E),x==="le"&&this._initArray(this.toArray(),m,x)))},o.prototype._initNumber=function(d,m,x){d<0&&(this.negative=1,d=-d),d<67108864?(this.words=[d&67108863],this.length=1):d<4503599627370496?(this.words=[d&67108863,d/67108864&67108863],this.length=2):(i(d<9007199254740992),this.words=[d&67108863,d/67108864&67108863,1],this.length=3),x==="le"&&this._initArray(this.toArray(),m,x)},o.prototype._initArray=function(d,m,x){if(i(typeof d.length=="number"),d.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(d.length/3),this.words=new Array(this.length);for(var E=0;E<this.length;E++)this.words[E]=0;var A,j,k=0;if(x==="be")for(E=d.length-1,A=0;E>=0;E-=3)j=d[E]|d[E-1]<<8|d[E-2]<<16,this.words[A]|=j<<k&67108863,this.words[A+1]=j>>>26-k&67108863,k+=24,k>=26&&(k-=26,A++);else if(x==="le")for(E=0,A=0;E<d.length;E+=3)j=d[E]|d[E+1]<<8|d[E+2]<<16,this.words[A]|=j<<k&67108863,this.words[A+1]=j>>>26-k&67108863,k+=24,k>=26&&(k-=26,A++);return this._strip()};function c(p,d){var m=p.charCodeAt(d);if(m>=48&&m<=57)return m-48;if(m>=65&&m<=70)return m-55;if(m>=97&&m<=102)return m-87;i(!1,"Invalid character in "+p)}function u(p,d,m){var x=c(p,m);return m-1>=d&&(x|=c(p,m-1)<<4),x}o.prototype._parseHex=function(d,m,x){this.length=Math.ceil((d.length-m)/6),this.words=new Array(this.length);for(var E=0;E<this.length;E++)this.words[E]=0;var A=0,j=0,k;if(x==="be")for(E=d.length-1;E>=m;E-=2)k=u(d,m,E)<<A,this.words[j]|=k&67108863,A>=18?(A-=18,j+=1,this.words[j]|=k>>>26):A+=8;else{var g=d.length-m;for(E=g%2===0?m+1:m;E<d.length;E+=2)k=u(d,m,E)<<A,this.words[j]|=k&67108863,A>=18?(A-=18,j+=1,this.words[j]|=k>>>26):A+=8}this._strip()};function l(p,d,m,x){for(var E=0,A=0,j=Math.min(p.length,m),k=d;k<j;k++){var g=p.charCodeAt(k)-48;E*=x,g>=49?A=g-49+10:g>=17?A=g-17+10:A=g,i(g>=0&&A<x,"Invalid character"),E+=A}return E}o.prototype._parseBase=function(d,m,x){this.words=[0],this.length=1;for(var E=0,A=1;A<=67108863;A*=m)E++;E--,A=A/m|0;for(var j=d.length-x,k=j%E,g=Math.min(j,j-k)+x,w=0,P=x;P<g;P+=E)w=l(d,P,P+E,m),this.imuln(A),this.words[0]+w<67108864?this.words[0]+=w:this._iaddn(w);if(k!==0){var ue=1;for(w=l(d,P,d.length,m),P=0;P<k;P++)ue*=m;this.imuln(ue),this.words[0]+w<67108864?this.words[0]+=w:this._iaddn(w)}this._strip()},o.prototype.copy=function(d){d.words=new Array(this.length);for(var m=0;m<this.length;m++)d.words[m]=this.words[m];d.length=this.length,d.negative=this.negative,d.red=this.red};function f(p,d){p.words=d.words,p.length=d.length,p.negative=d.negative,p.red=d.red}if(o.prototype._move=function(d){f(d,this)},o.prototype.clone=function(){var d=new o(null);return this.copy(d),d},o.prototype._expand=function(d){for(;this.length<d;)this.words[this.length++]=0;return this},o.prototype._strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},o.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{o.prototype[Symbol.for("nodejs.util.inspect.custom")]=h}catch{o.prototype.inspect=h}else o.prototype.inspect=h;function h(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var v=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],b=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],y=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];o.prototype.toString=function(d,m){d=d||10,m=m|0||1;var x;if(d===16||d==="hex"){x="";for(var E=0,A=0,j=0;j<this.length;j++){var k=this.words[j],g=((k<<E|A)&16777215).toString(16);A=k>>>24-E&16777215,E+=2,E>=26&&(E-=26,j--),A!==0||j!==this.length-1?x=v[6-g.length]+g+x:x=g+x}for(A!==0&&(x=A.toString(16)+x);x.length%m!==0;)x="0"+x;return this.negative!==0&&(x="-"+x),x}if(d===(d|0)&&d>=2&&d<=36){var w=b[d],P=y[d];x="";var ue=this.clone();for(ue.negative=0;!ue.isZero();){var ie=ue.modrn(P).toString(d);ue=ue.idivn(P),ue.isZero()?x=ie+x:x=v[w-ie.length]+ie+x}for(this.isZero()&&(x="0"+x);x.length%m!==0;)x="0"+x;return this.negative!==0&&(x="-"+x),x}i(!1,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var d=this.words[0];return this.length===2?d+=this.words[1]*67108864:this.length===3&&this.words[2]===1?d+=4503599627370496+this.words[1]*67108864:this.length>2&&i(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-d:d},o.prototype.toJSON=function(){return this.toString(16,2)},a&&(o.prototype.toBuffer=function(d,m){return this.toArrayLike(a,d,m)}),o.prototype.toArray=function(d,m){return this.toArrayLike(Array,d,m)};var S=function(d,m){return d.allocUnsafe?d.allocUnsafe(m):new d(m)};o.prototype.toArrayLike=function(d,m,x){this._strip();var E=this.byteLength(),A=x||Math.max(1,E);i(E<=A,"byte array longer than desired length"),i(A>0,"Requested array length <= 0");var j=S(d,A),k=m==="le"?"LE":"BE";return this["_toArrayLike"+k](j,E),j},o.prototype._toArrayLikeLE=function(d,m){for(var x=0,E=0,A=0,j=0;A<this.length;A++){var k=this.words[A]<<j|E;d[x++]=k&255,x<d.length&&(d[x++]=k>>8&255),x<d.length&&(d[x++]=k>>16&255),j===6?(x<d.length&&(d[x++]=k>>24&255),E=0,j=0):(E=k>>>24,j+=2)}if(x<d.length)for(d[x++]=E;x<d.length;)d[x++]=0},o.prototype._toArrayLikeBE=function(d,m){for(var x=d.length-1,E=0,A=0,j=0;A<this.length;A++){var k=this.words[A]<<j|E;d[x--]=k&255,x>=0&&(d[x--]=k>>8&255),x>=0&&(d[x--]=k>>16&255),j===6?(x>=0&&(d[x--]=k>>24&255),E=0,j=0):(E=k>>>24,j+=2)}if(x>=0)for(d[x--]=E;x>=0;)d[x--]=0},Math.clz32?o.prototype._countBits=function(d){return 32-Math.clz32(d)}:o.prototype._countBits=function(d){var m=d,x=0;return m>=4096&&(x+=13,m>>>=13),m>=64&&(x+=7,m>>>=7),m>=8&&(x+=4,m>>>=4),m>=2&&(x+=2,m>>>=2),x+m},o.prototype._zeroBits=function(d){if(d===0)return 26;var m=d,x=0;return m&8191||(x+=13,m>>>=13),m&127||(x+=7,m>>>=7),m&15||(x+=4,m>>>=4),m&3||(x+=2,m>>>=2),m&1||x++,x},o.prototype.bitLength=function(){var d=this.words[this.length-1],m=this._countBits(d);return(this.length-1)*26+m};function C(p){for(var d=new Array(p.bitLength()),m=0;m<d.length;m++){var x=m/26|0,E=m%26;d[m]=p.words[x]>>>E&1}return d}o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var d=0,m=0;m<this.length;m++){var x=this._zeroBits(this.words[m]);if(d+=x,x!==26)break}return d},o.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},o.prototype.toTwos=function(d){return this.negative!==0?this.abs().inotn(d).iaddn(1):this.clone()},o.prototype.fromTwos=function(d){return this.testn(d-1)?this.notn(d).iaddn(1).ineg():this.clone()},o.prototype.isNeg=function(){return this.negative!==0},o.prototype.neg=function(){return this.clone().ineg()},o.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},o.prototype.iuor=function(d){for(;this.length<d.length;)this.words[this.length++]=0;for(var m=0;m<d.length;m++)this.words[m]=this.words[m]|d.words[m];return this._strip()},o.prototype.ior=function(d){return i((this.negative|d.negative)===0),this.iuor(d)},o.prototype.or=function(d){return this.length>d.length?this.clone().ior(d):d.clone().ior(this)},o.prototype.uor=function(d){return this.length>d.length?this.clone().iuor(d):d.clone().iuor(this)},o.prototype.iuand=function(d){var m;this.length>d.length?m=d:m=this;for(var x=0;x<m.length;x++)this.words[x]=this.words[x]&d.words[x];return this.length=m.length,this._strip()},o.prototype.iand=function(d){return i((this.negative|d.negative)===0),this.iuand(d)},o.prototype.and=function(d){return this.length>d.length?this.clone().iand(d):d.clone().iand(this)},o.prototype.uand=function(d){return this.length>d.length?this.clone().iuand(d):d.clone().iuand(this)},o.prototype.iuxor=function(d){var m,x;this.length>d.length?(m=this,x=d):(m=d,x=this);for(var E=0;E<x.length;E++)this.words[E]=m.words[E]^x.words[E];if(this!==m)for(;E<m.length;E++)this.words[E]=m.words[E];return this.length=m.length,this._strip()},o.prototype.ixor=function(d){return i((this.negative|d.negative)===0),this.iuxor(d)},o.prototype.xor=function(d){return this.length>d.length?this.clone().ixor(d):d.clone().ixor(this)},o.prototype.uxor=function(d){return this.length>d.length?this.clone().iuxor(d):d.clone().iuxor(this)},o.prototype.inotn=function(d){i(typeof d=="number"&&d>=0);var m=Math.ceil(d/26)|0,x=d%26;this._expand(m),x>0&&m--;for(var E=0;E<m;E++)this.words[E]=~this.words[E]&67108863;return x>0&&(this.words[E]=~this.words[E]&67108863>>26-x),this._strip()},o.prototype.notn=function(d){return this.clone().inotn(d)},o.prototype.setn=function(d,m){i(typeof d=="number"&&d>=0);var x=d/26|0,E=d%26;return this._expand(x+1),m?this.words[x]=this.words[x]|1<<E:this.words[x]=this.words[x]&~(1<<E),this._strip()},o.prototype.iadd=function(d){var m;if(this.negative!==0&&d.negative===0)return this.negative=0,m=this.isub(d),this.negative^=1,this._normSign();if(this.negative===0&&d.negative!==0)return d.negative=0,m=this.isub(d),d.negative=1,m._normSign();var x,E;this.length>d.length?(x=this,E=d):(x=d,E=this);for(var A=0,j=0;j<E.length;j++)m=(x.words[j]|0)+(E.words[j]|0)+A,this.words[j]=m&67108863,A=m>>>26;for(;A!==0&&j<x.length;j++)m=(x.words[j]|0)+A,this.words[j]=m&67108863,A=m>>>26;if(this.length=x.length,A!==0)this.words[this.length]=A,this.length++;else if(x!==this)for(;j<x.length;j++)this.words[j]=x.words[j];return this},o.prototype.add=function(d){var m;return d.negative!==0&&this.negative===0?(d.negative=0,m=this.sub(d),d.negative^=1,m):d.negative===0&&this.negative!==0?(this.negative=0,m=d.sub(this),this.negative=1,m):this.length>d.length?this.clone().iadd(d):d.clone().iadd(this)},o.prototype.isub=function(d){if(d.negative!==0){d.negative=0;var m=this.iadd(d);return d.negative=1,m._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(d),this.negative=1,this._normSign();var x=this.cmp(d);if(x===0)return this.negative=0,this.length=1,this.words[0]=0,this;var E,A;x>0?(E=this,A=d):(E=d,A=this);for(var j=0,k=0;k<A.length;k++)m=(E.words[k]|0)-(A.words[k]|0)+j,j=m>>26,this.words[k]=m&67108863;for(;j!==0&&k<E.length;k++)m=(E.words[k]|0)+j,j=m>>26,this.words[k]=m&67108863;if(j===0&&k<E.length&&E!==this)for(;k<E.length;k++)this.words[k]=E.words[k];return this.length=Math.max(this.length,k),E!==this&&(this.negative=1),this._strip()},o.prototype.sub=function(d){return this.clone().isub(d)};function O(p,d,m){m.negative=d.negative^p.negative;var x=p.length+d.length|0;m.length=x,x=x-1|0;var E=p.words[0]|0,A=d.words[0]|0,j=E*A,k=j&67108863,g=j/67108864|0;m.words[0]=k;for(var w=1;w<x;w++){for(var P=g>>>26,ue=g&67108863,ie=Math.min(w,d.length-1),fe=Math.max(0,w-p.length+1);fe<=ie;fe++){var ve=w-fe|0;E=p.words[ve]|0,A=d.words[fe]|0,j=E*A+ue,P+=j/67108864|0,ue=j&67108863}m.words[w]=ue|0,g=P|0}return g!==0?m.words[w]=g|0:m.length--,m._strip()}var I=function(d,m,x){var E=d.words,A=m.words,j=x.words,k=0,g,w,P,ue=E[0]|0,ie=ue&8191,fe=ue>>>13,ve=E[1]|0,Ce=ve&8191,N=ve>>>13,F=E[2]|0,G=F&8191,ee=F>>>13,Z=E[3]|0,q=Z&8191,he=Z>>>13,Y=E[4]|0,X=Y&8191,B=Y>>>13,se=E[5]|0,me=se&8191,de=se>>>13,Se=E[6]|0,Ie=Se&8191,Ue=Se>>>13,Je=E[7]|0,Pe=Je&8191,Ge=Je>>>13,nt=E[8]|0,et=nt&8191,Ot=nt>>>13,$t=E[9]|0,Ke=$t&8191,pt=$t>>>13,ut=A[0]|0,tt=ut&8191,ot=ut>>>13,vt=A[1]|0,st=vt&8191,bt=vt>>>13,Dt=A[2]|0,mt=Dt&8191,It=Dt>>>13,Ut=A[3]|0,Ye=Ut&8191,Rt=Ut>>>13,Ft=A[4]|0,$=Ft&8191,T=Ft>>>13,M=A[5]|0,K=M&8191,ae=M>>>13,be=A[6]|0,_e=be&8191,it=be>>>13,xt=A[7]|0,rt=xt&8191,Q=xt>>>13,Ee=A[8]|0,ke=Ee&8191,Ze=Ee>>>13,ft=A[9]|0,Qe=ft&8191,at=ft>>>13;x.negative=d.negative^m.negative,x.length=19,g=Math.imul(ie,tt),w=Math.imul(ie,ot),w=w+Math.imul(fe,tt)|0,P=Math.imul(fe,ot);var Tt=(k+g|0)+((w&8191)<<13)|0;k=(P+(w>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,g=Math.imul(Ce,tt),w=Math.imul(Ce,ot),w=w+Math.imul(N,tt)|0,P=Math.imul(N,ot),g=g+Math.imul(ie,st)|0,w=w+Math.imul(ie,bt)|0,w=w+Math.imul(fe,st)|0,P=P+Math.imul(fe,bt)|0;var or=(k+g|0)+((w&8191)<<13)|0;k=(P+(w>>>13)|0)+(or>>>26)|0,or&=67108863,g=Math.imul(G,tt),w=Math.imul(G,ot),w=w+Math.imul(ee,tt)|0,P=Math.imul(ee,ot),g=g+Math.imul(Ce,st)|0,w=w+Math.imul(Ce,bt)|0,w=w+Math.imul(N,st)|0,P=P+Math.imul(N,bt)|0,g=g+Math.imul(ie,mt)|0,w=w+Math.imul(ie,It)|0,w=w+Math.imul(fe,mt)|0,P=P+Math.imul(fe,It)|0;var Ht=(k+g|0)+((w&8191)<<13)|0;k=(P+(w>>>13)|0)+(Ht>>>26)|0,Ht&=67108863,g=Math.imul(q,tt),w=Math.imul(q,ot),w=w+Math.imul(he,tt)|0,P=Math.imul(he,ot),g=g+Math.imul(G,st)|0,w=w+Math.imul(G,bt)|0,w=w+Math.imul(ee,st)|0,P=P+Math.imul(ee,bt)|0,g=g+Math.imul(Ce,mt)|0,w=w+Math.imul(Ce,It)|0,w=w+Math.imul(N,mt)|0,P=P+Math.imul(N,It)|0,g=g+Math.imul(ie,Ye)|0,w=w+Math.imul(ie,Rt)|0,w=w+Math.imul(fe,Ye)|0,P=P+Math.imul(fe,Rt)|0;var Yt=(k+g|0)+((w&8191)<<13)|0;k=(P+(w>>>13)|0)+(Yt>>>26)|0,Yt&=67108863,g=Math.imul(X,tt),w=Math.imul(X,ot),w=w+Math.imul(B,tt)|0,P=Math.imul(B,ot),g=g+Math.imul(q,st)|0,w=w+Math.imul(q,bt)|0,w=w+Math.imul(he,st)|0,P=P+Math.imul(he,bt)|0,g=g+Math.imul(G,mt)|0,w=w+Math.imul(G,It)|0,w=w+Math.imul(ee,mt)|0,P=P+Math.imul(ee,It)|0,g=g+Math.imul(Ce,Ye)|0,w=w+Math.imul(Ce,Rt)|0,w=w+Math.imul(N,Ye)|0,P=P+Math.imul(N,Rt)|0,g=g+Math.imul(ie,$)|0,w=w+Math.imul(ie,T)|0,w=w+Math.imul(fe,$)|0,P=P+Math.imul(fe,T)|0;var br=(k+g|0)+((w&8191)<<13)|0;k=(P+(w>>>13)|0)+(br>>>26)|0,br&=67108863,g=Math.imul(me,tt),w=Math.imul(me,ot),w=w+Math.imul(de,tt)|0,P=Math.imul(de,ot),g=g+Math.imul(X,st)|0,w=w+Math.imul(X,bt)|0,w=w+Math.imul(B,st)|0,P=P+Math.imul(B,bt)|0,g=g+Math.imul(q,mt)|0,w=w+Math.imul(q,It)|0,w=w+Math.imul(he,mt)|0,P=P+Math.imul(he,It)|0,g=g+Math.imul(G,Ye)|0,w=w+Math.imul(G,Rt)|0,w=w+Math.imul(ee,Ye)|0,P=P+Math.imul(ee,Rt)|0,g=g+Math.imul(Ce,$)|0,w=w+Math.imul(Ce,T)|0,w=w+Math.imul(N,$)|0,P=P+Math.imul(N,T)|0,g=g+Math.imul(ie,K)|0,w=w+Math.imul(ie,ae)|0,w=w+Math.imul(fe,K)|0,P=P+Math.imul(fe,ae)|0;var Gr=(k+g|0)+((w&8191)<<13)|0;k=(P+(w>>>13)|0)+(Gr>>>26)|0,Gr&=67108863,g=Math.imul(Ie,tt),w=Math.imul(Ie,ot),w=w+Math.imul(Ue,tt)|0,P=Math.imul(Ue,ot),g=g+Math.imul(me,st)|0,w=w+Math.imul(me,bt)|0,w=w+Math.imul(de,st)|0,P=P+Math.imul(de,bt)|0,g=g+Math.imul(X,mt)|0,w=w+Math.imul(X,It)|0,w=w+Math.imul(B,mt)|0,P=P+Math.imul(B,It)|0,g=g+Math.imul(q,Ye)|0,w=w+Math.imul(q,Rt)|0,w=w+Math.imul(he,Ye)|0,P=P+Math.imul(he,Rt)|0,g=g+Math.imul(G,$)|0,w=w+Math.imul(G,T)|0,w=w+Math.imul(ee,$)|0,P=P+Math.imul(ee,T)|0,g=g+Math.imul(Ce,K)|0,w=w+Math.imul(Ce,ae)|0,w=w+Math.imul(N,K)|0,P=P+Math.imul(N,ae)|0,g=g+Math.imul(ie,_e)|0,w=w+Math.imul(ie,it)|0,w=w+Math.imul(fe,_e)|0,P=P+Math.imul(fe,it)|0;var _r=(k+g|0)+((w&8191)<<13)|0;k=(P+(w>>>13)|0)+(_r>>>26)|0,_r&=67108863,g=Math.imul(Pe,tt),w=Math.imul(Pe,ot),w=w+Math.imul(Ge,tt)|0,P=Math.imul(Ge,ot),g=g+Math.imul(Ie,st)|0,w=w+Math.imul(Ie,bt)|0,w=w+Math.imul(Ue,st)|0,P=P+Math.imul(Ue,bt)|0,g=g+Math.imul(me,mt)|0,w=w+Math.imul(me,It)|0,w=w+Math.imul(de,mt)|0,P=P+Math.imul(de,It)|0,g=g+Math.imul(X,Ye)|0,w=w+Math.imul(X,Rt)|0,w=w+Math.imul(B,Ye)|0,P=P+Math.imul(B,Rt)|0,g=g+Math.imul(q,$)|0,w=w+Math.imul(q,T)|0,w=w+Math.imul(he,$)|0,P=P+Math.imul(he,T)|0,g=g+Math.imul(G,K)|0,w=w+Math.imul(G,ae)|0,w=w+Math.imul(ee,K)|0,P=P+Math.imul(ee,ae)|0,g=g+Math.imul(Ce,_e)|0,w=w+Math.imul(Ce,it)|0,w=w+Math.imul(N,_e)|0,P=P+Math.imul(N,it)|0,g=g+Math.imul(ie,rt)|0,w=w+Math.imul(ie,Q)|0,w=w+Math.imul(fe,rt)|0,P=P+Math.imul(fe,Q)|0;var ar=(k+g|0)+((w&8191)<<13)|0;k=(P+(w>>>13)|0)+(ar>>>26)|0,ar&=67108863,g=Math.imul(et,tt),w=Math.imul(et,ot),w=w+Math.imul(Ot,tt)|0,P=Math.imul(Ot,ot),g=g+Math.imul(Pe,st)|0,w=w+Math.imul(Pe,bt)|0,w=w+Math.imul(Ge,st)|0,P=P+Math.imul(Ge,bt)|0,g=g+Math.imul(Ie,mt)|0,w=w+Math.imul(Ie,It)|0,w=w+Math.imul(Ue,mt)|0,P=P+Math.imul(Ue,It)|0,g=g+Math.imul(me,Ye)|0,w=w+Math.imul(me,Rt)|0,w=w+Math.imul(de,Ye)|0,P=P+Math.imul(de,Rt)|0,g=g+Math.imul(X,$)|0,w=w+Math.imul(X,T)|0,w=w+Math.imul(B,$)|0,P=P+Math.imul(B,T)|0,g=g+Math.imul(q,K)|0,w=w+Math.imul(q,ae)|0,w=w+Math.imul(he,K)|0,P=P+Math.imul(he,ae)|0,g=g+Math.imul(G,_e)|0,w=w+Math.imul(G,it)|0,w=w+Math.imul(ee,_e)|0,P=P+Math.imul(ee,it)|0,g=g+Math.imul(Ce,rt)|0,w=w+Math.imul(Ce,Q)|0,w=w+Math.imul(N,rt)|0,P=P+Math.imul(N,Q)|0,g=g+Math.imul(ie,ke)|0,w=w+Math.imul(ie,Ze)|0,w=w+Math.imul(fe,ke)|0,P=P+Math.imul(fe,Ze)|0;var Wr=(k+g|0)+((w&8191)<<13)|0;k=(P+(w>>>13)|0)+(Wr>>>26)|0,Wr&=67108863,g=Math.imul(Ke,tt),w=Math.imul(Ke,ot),w=w+Math.imul(pt,tt)|0,P=Math.imul(pt,ot),g=g+Math.imul(et,st)|0,w=w+Math.imul(et,bt)|0,w=w+Math.imul(Ot,st)|0,P=P+Math.imul(Ot,bt)|0,g=g+Math.imul(Pe,mt)|0,w=w+Math.imul(Pe,It)|0,w=w+Math.imul(Ge,mt)|0,P=P+Math.imul(Ge,It)|0,g=g+Math.imul(Ie,Ye)|0,w=w+Math.imul(Ie,Rt)|0,w=w+Math.imul(Ue,Ye)|0,P=P+Math.imul(Ue,Rt)|0,g=g+Math.imul(me,$)|0,w=w+Math.imul(me,T)|0,w=w+Math.imul(de,$)|0,P=P+Math.imul(de,T)|0,g=g+Math.imul(X,K)|0,w=w+Math.imul(X,ae)|0,w=w+Math.imul(B,K)|0,P=P+Math.imul(B,ae)|0,g=g+Math.imul(q,_e)|0,w=w+Math.imul(q,it)|0,w=w+Math.imul(he,_e)|0,P=P+Math.imul(he,it)|0,g=g+Math.imul(G,rt)|0,w=w+Math.imul(G,Q)|0,w=w+Math.imul(ee,rt)|0,P=P+Math.imul(ee,Q)|0,g=g+Math.imul(Ce,ke)|0,w=w+Math.imul(Ce,Ze)|0,w=w+Math.imul(N,ke)|0,P=P+Math.imul(N,Ze)|0,g=g+Math.imul(ie,Qe)|0,w=w+Math.imul(ie,at)|0,w=w+Math.imul(fe,Qe)|0,P=P+Math.imul(fe,at)|0;var ai=(k+g|0)+((w&8191)<<13)|0;k=(P+(w>>>13)|0)+(ai>>>26)|0,ai&=67108863,g=Math.imul(Ke,st),w=Math.imul(Ke,bt),w=w+Math.imul(pt,st)|0,P=Math.imul(pt,bt),g=g+Math.imul(et,mt)|0,w=w+Math.imul(et,It)|0,w=w+Math.imul(Ot,mt)|0,P=P+Math.imul(Ot,It)|0,g=g+Math.imul(Pe,Ye)|0,w=w+Math.imul(Pe,Rt)|0,w=w+Math.imul(Ge,Ye)|0,P=P+Math.imul(Ge,Rt)|0,g=g+Math.imul(Ie,$)|0,w=w+Math.imul(Ie,T)|0,w=w+Math.imul(Ue,$)|0,P=P+Math.imul(Ue,T)|0,g=g+Math.imul(me,K)|0,w=w+Math.imul(me,ae)|0,w=w+Math.imul(de,K)|0,P=P+Math.imul(de,ae)|0,g=g+Math.imul(X,_e)|0,w=w+Math.imul(X,it)|0,w=w+Math.imul(B,_e)|0,P=P+Math.imul(B,it)|0,g=g+Math.imul(q,rt)|0,w=w+Math.imul(q,Q)|0,w=w+Math.imul(he,rt)|0,P=P+Math.imul(he,Q)|0,g=g+Math.imul(G,ke)|0,w=w+Math.imul(G,Ze)|0,w=w+Math.imul(ee,ke)|0,P=P+Math.imul(ee,Ze)|0,g=g+Math.imul(Ce,Qe)|0,w=w+Math.imul(Ce,at)|0,w=w+Math.imul(N,Qe)|0,P=P+Math.imul(N,at)|0;var xn=(k+g|0)+((w&8191)<<13)|0;k=(P+(w>>>13)|0)+(xn>>>26)|0,xn&=67108863,g=Math.imul(Ke,mt),w=Math.imul(Ke,It),w=w+Math.imul(pt,mt)|0,P=Math.imul(pt,It),g=g+Math.imul(et,Ye)|0,w=w+Math.imul(et,Rt)|0,w=w+Math.imul(Ot,Ye)|0,P=P+Math.imul(Ot,Rt)|0,g=g+Math.imul(Pe,$)|0,w=w+Math.imul(Pe,T)|0,w=w+Math.imul(Ge,$)|0,P=P+Math.imul(Ge,T)|0,g=g+Math.imul(Ie,K)|0,w=w+Math.imul(Ie,ae)|0,w=w+Math.imul(Ue,K)|0,P=P+Math.imul(Ue,ae)|0,g=g+Math.imul(me,_e)|0,w=w+Math.imul(me,it)|0,w=w+Math.imul(de,_e)|0,P=P+Math.imul(de,it)|0,g=g+Math.imul(X,rt)|0,w=w+Math.imul(X,Q)|0,w=w+Math.imul(B,rt)|0,P=P+Math.imul(B,Q)|0,g=g+Math.imul(q,ke)|0,w=w+Math.imul(q,Ze)|0,w=w+Math.imul(he,ke)|0,P=P+Math.imul(he,Ze)|0,g=g+Math.imul(G,Qe)|0,w=w+Math.imul(G,at)|0,w=w+Math.imul(ee,Qe)|0,P=P+Math.imul(ee,at)|0;var ci=(k+g|0)+((w&8191)<<13)|0;k=(P+(w>>>13)|0)+(ci>>>26)|0,ci&=67108863,g=Math.imul(Ke,Ye),w=Math.imul(Ke,Rt),w=w+Math.imul(pt,Ye)|0,P=Math.imul(pt,Rt),g=g+Math.imul(et,$)|0,w=w+Math.imul(et,T)|0,w=w+Math.imul(Ot,$)|0,P=P+Math.imul(Ot,T)|0,g=g+Math.imul(Pe,K)|0,w=w+Math.imul(Pe,ae)|0,w=w+Math.imul(Ge,K)|0,P=P+Math.imul(Ge,ae)|0,g=g+Math.imul(Ie,_e)|0,w=w+Math.imul(Ie,it)|0,w=w+Math.imul(Ue,_e)|0,P=P+Math.imul(Ue,it)|0,g=g+Math.imul(me,rt)|0,w=w+Math.imul(me,Q)|0,w=w+Math.imul(de,rt)|0,P=P+Math.imul(de,Q)|0,g=g+Math.imul(X,ke)|0,w=w+Math.imul(X,Ze)|0,w=w+Math.imul(B,ke)|0,P=P+Math.imul(B,Ze)|0,g=g+Math.imul(q,Qe)|0,w=w+Math.imul(q,at)|0,w=w+Math.imul(he,Qe)|0,P=P+Math.imul(he,at)|0;var fs=(k+g|0)+((w&8191)<<13)|0;k=(P+(w>>>13)|0)+(fs>>>26)|0,fs&=67108863,g=Math.imul(Ke,$),w=Math.imul(Ke,T),w=w+Math.imul(pt,$)|0,P=Math.imul(pt,T),g=g+Math.imul(et,K)|0,w=w+Math.imul(et,ae)|0,w=w+Math.imul(Ot,K)|0,P=P+Math.imul(Ot,ae)|0,g=g+Math.imul(Pe,_e)|0,w=w+Math.imul(Pe,it)|0,w=w+Math.imul(Ge,_e)|0,P=P+Math.imul(Ge,it)|0,g=g+Math.imul(Ie,rt)|0,w=w+Math.imul(Ie,Q)|0,w=w+Math.imul(Ue,rt)|0,P=P+Math.imul(Ue,Q)|0,g=g+Math.imul(me,ke)|0,w=w+Math.imul(me,Ze)|0,w=w+Math.imul(de,ke)|0,P=P+Math.imul(de,Ze)|0,g=g+Math.imul(X,Qe)|0,w=w+Math.imul(X,at)|0,w=w+Math.imul(B,Qe)|0,P=P+Math.imul(B,at)|0;var ds=(k+g|0)+((w&8191)<<13)|0;k=(P+(w>>>13)|0)+(ds>>>26)|0,ds&=67108863,g=Math.imul(Ke,K),w=Math.imul(Ke,ae),w=w+Math.imul(pt,K)|0,P=Math.imul(pt,ae),g=g+Math.imul(et,_e)|0,w=w+Math.imul(et,it)|0,w=w+Math.imul(Ot,_e)|0,P=P+Math.imul(Ot,it)|0,g=g+Math.imul(Pe,rt)|0,w=w+Math.imul(Pe,Q)|0,w=w+Math.imul(Ge,rt)|0,P=P+Math.imul(Ge,Q)|0,g=g+Math.imul(Ie,ke)|0,w=w+Math.imul(Ie,Ze)|0,w=w+Math.imul(Ue,ke)|0,P=P+Math.imul(Ue,Ze)|0,g=g+Math.imul(me,Qe)|0,w=w+Math.imul(me,at)|0,w=w+Math.imul(de,Qe)|0,P=P+Math.imul(de,at)|0;var ui=(k+g|0)+((w&8191)<<13)|0;k=(P+(w>>>13)|0)+(ui>>>26)|0,ui&=67108863,g=Math.imul(Ke,_e),w=Math.imul(Ke,it),w=w+Math.imul(pt,_e)|0,P=Math.imul(pt,it),g=g+Math.imul(et,rt)|0,w=w+Math.imul(et,Q)|0,w=w+Math.imul(Ot,rt)|0,P=P+Math.imul(Ot,Q)|0,g=g+Math.imul(Pe,ke)|0,w=w+Math.imul(Pe,Ze)|0,w=w+Math.imul(Ge,ke)|0,P=P+Math.imul(Ge,Ze)|0,g=g+Math.imul(Ie,Qe)|0,w=w+Math.imul(Ie,at)|0,w=w+Math.imul(Ue,Qe)|0,P=P+Math.imul(Ue,at)|0;var hs=(k+g|0)+((w&8191)<<13)|0;k=(P+(w>>>13)|0)+(hs>>>26)|0,hs&=67108863,g=Math.imul(Ke,rt),w=Math.imul(Ke,Q),w=w+Math.imul(pt,rt)|0,P=Math.imul(pt,Q),g=g+Math.imul(et,ke)|0,w=w+Math.imul(et,Ze)|0,w=w+Math.imul(Ot,ke)|0,P=P+Math.imul(Ot,Ze)|0,g=g+Math.imul(Pe,Qe)|0,w=w+Math.imul(Pe,at)|0,w=w+Math.imul(Ge,Qe)|0,P=P+Math.imul(Ge,at)|0;var ps=(k+g|0)+((w&8191)<<13)|0;k=(P+(w>>>13)|0)+(ps>>>26)|0,ps&=67108863,g=Math.imul(Ke,ke),w=Math.imul(Ke,Ze),w=w+Math.imul(pt,ke)|0,P=Math.imul(pt,Ze),g=g+Math.imul(et,Qe)|0,w=w+Math.imul(et,at)|0,w=w+Math.imul(Ot,Qe)|0,P=P+Math.imul(Ot,at)|0;var W=(k+g|0)+((w&8191)<<13)|0;k=(P+(w>>>13)|0)+(W>>>26)|0,W&=67108863,g=Math.imul(Ke,Qe),w=Math.imul(Ke,at),w=w+Math.imul(pt,Qe)|0,P=Math.imul(pt,at);var oe=(k+g|0)+((w&8191)<<13)|0;return k=(P+(w>>>13)|0)+(oe>>>26)|0,oe&=67108863,j[0]=Tt,j[1]=or,j[2]=Ht,j[3]=Yt,j[4]=br,j[5]=Gr,j[6]=_r,j[7]=ar,j[8]=Wr,j[9]=ai,j[10]=xn,j[11]=ci,j[12]=fs,j[13]=ds,j[14]=ui,j[15]=hs,j[16]=ps,j[17]=W,j[18]=oe,k!==0&&(j[19]=k,x.length++),x};Math.imul||(I=O);function U(p,d,m){m.negative=d.negative^p.negative,m.length=p.length+d.length;for(var x=0,E=0,A=0;A<m.length-1;A++){var j=E;E=0;for(var k=x&67108863,g=Math.min(A,d.length-1),w=Math.max(0,A-p.length+1);w<=g;w++){var P=A-w,ue=p.words[P]|0,ie=d.words[w]|0,fe=ue*ie,ve=fe&67108863;j=j+(fe/67108864|0)|0,ve=ve+k|0,k=ve&67108863,j=j+(ve>>>26)|0,E+=j>>>26,j&=67108863}m.words[A]=k,x=j,j=E}return x!==0?m.words[A]=x:m.length--,m._strip()}function D(p,d,m){return U(p,d,m)}o.prototype.mulTo=function(d,m){var x,E=this.length+d.length;return this.length===10&&d.length===10?x=I(this,d,m):E<63?x=O(this,d,m):E<1024?x=U(this,d,m):x=D(this,d,m),x},o.prototype.mul=function(d){var m=new o(null);return m.words=new Array(this.length+d.length),this.mulTo(d,m)},o.prototype.mulf=function(d){var m=new o(null);return m.words=new Array(this.length+d.length),D(this,d,m)},o.prototype.imul=function(d){return this.clone().mulTo(d,this)},o.prototype.imuln=function(d){var m=d<0;m&&(d=-d),i(typeof d=="number"),i(d<67108864);for(var x=0,E=0;E<this.length;E++){var A=(this.words[E]|0)*d,j=(A&67108863)+(x&67108863);x>>=26,x+=A/67108864|0,x+=j>>>26,this.words[E]=j&67108863}return x!==0&&(this.words[E]=x,this.length++),this.length=d===0?1:this.length,m?this.ineg():this},o.prototype.muln=function(d){return this.clone().imuln(d)},o.prototype.sqr=function(){return this.mul(this)},o.prototype.isqr=function(){return this.imul(this.clone())},o.prototype.pow=function(d){var m=C(d);if(m.length===0)return new o(1);for(var x=this,E=0;E<m.length&&m[E]===0;E++,x=x.sqr());if(++E<m.length)for(var A=x.sqr();E<m.length;E++,A=A.sqr())m[E]!==0&&(x=x.mul(A));return x},o.prototype.iushln=function(d){i(typeof d=="number"&&d>=0);var m=d%26,x=(d-m)/26,E=67108863>>>26-m<<26-m,A;if(m!==0){var j=0;for(A=0;A<this.length;A++){var k=this.words[A]&E,g=(this.words[A]|0)-k<<m;this.words[A]=g|j,j=k>>>26-m}j&&(this.words[A]=j,this.length++)}if(x!==0){for(A=this.length-1;A>=0;A--)this.words[A+x]=this.words[A];for(A=0;A<x;A++)this.words[A]=0;this.length+=x}return this._strip()},o.prototype.ishln=function(d){return i(this.negative===0),this.iushln(d)},o.prototype.iushrn=function(d,m,x){i(typeof d=="number"&&d>=0);var E;m?E=(m-m%26)/26:E=0;var A=d%26,j=Math.min((d-A)/26,this.length),k=67108863^67108863>>>A<<A,g=x;if(E-=j,E=Math.max(0,E),g){for(var w=0;w<j;w++)g.words[w]=this.words[w];g.length=j}if(j!==0)if(this.length>j)for(this.length-=j,w=0;w<this.length;w++)this.words[w]=this.words[w+j];else this.words[0]=0,this.length=1;var P=0;for(w=this.length-1;w>=0&&(P!==0||w>=E);w--){var ue=this.words[w]|0;this.words[w]=P<<26-A|ue>>>A,P=ue&k}return g&&P!==0&&(g.words[g.length++]=P),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},o.prototype.ishrn=function(d,m,x){return i(this.negative===0),this.iushrn(d,m,x)},o.prototype.shln=function(d){return this.clone().ishln(d)},o.prototype.ushln=function(d){return this.clone().iushln(d)},o.prototype.shrn=function(d){return this.clone().ishrn(d)},o.prototype.ushrn=function(d){return this.clone().iushrn(d)},o.prototype.testn=function(d){i(typeof d=="number"&&d>=0);var m=d%26,x=(d-m)/26,E=1<<m;if(this.length<=x)return!1;var A=this.words[x];return!!(A&E)},o.prototype.imaskn=function(d){i(typeof d=="number"&&d>=0);var m=d%26,x=(d-m)/26;if(i(this.negative===0,"imaskn works only with positive numbers"),this.length<=x)return this;if(m!==0&&x++,this.length=Math.min(x,this.length),m!==0){var E=67108863^67108863>>>m<<m;this.words[this.length-1]&=E}return this._strip()},o.prototype.maskn=function(d){return this.clone().imaskn(d)},o.prototype.iaddn=function(d){return i(typeof d=="number"),i(d<67108864),d<0?this.isubn(-d):this.negative!==0?this.length===1&&(this.words[0]|0)<=d?(this.words[0]=d-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(d),this.negative=1,this):this._iaddn(d)},o.prototype._iaddn=function(d){this.words[0]+=d;for(var m=0;m<this.length&&this.words[m]>=67108864;m++)this.words[m]-=67108864,m===this.length-1?this.words[m+1]=1:this.words[m+1]++;return this.length=Math.max(this.length,m+1),this},o.prototype.isubn=function(d){if(i(typeof d=="number"),i(d<67108864),d<0)return this.iaddn(-d);if(this.negative!==0)return this.negative=0,this.iaddn(d),this.negative=1,this;if(this.words[0]-=d,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var m=0;m<this.length&&this.words[m]<0;m++)this.words[m]+=67108864,this.words[m+1]-=1;return this._strip()},o.prototype.addn=function(d){return this.clone().iaddn(d)},o.prototype.subn=function(d){return this.clone().isubn(d)},o.prototype.iabs=function(){return this.negative=0,this},o.prototype.abs=function(){return this.clone().iabs()},o.prototype._ishlnsubmul=function(d,m,x){var E=d.length+x,A;this._expand(E);var j,k=0;for(A=0;A<d.length;A++){j=(this.words[A+x]|0)+k;var g=(d.words[A]|0)*m;j-=g&67108863,k=(j>>26)-(g/67108864|0),this.words[A+x]=j&67108863}for(;A<this.length-x;A++)j=(this.words[A+x]|0)+k,k=j>>26,this.words[A+x]=j&67108863;if(k===0)return this._strip();for(i(k===-1),k=0,A=0;A<this.length;A++)j=-(this.words[A]|0)+k,k=j>>26,this.words[A]=j&67108863;return this.negative=1,this._strip()},o.prototype._wordDiv=function(d,m){var x=this.length-d.length,E=this.clone(),A=d,j=A.words[A.length-1]|0,k=this._countBits(j);x=26-k,x!==0&&(A=A.ushln(x),E.iushln(x),j=A.words[A.length-1]|0);var g=E.length-A.length,w;if(m!=="mod"){w=new o(null),w.length=g+1,w.words=new Array(w.length);for(var P=0;P<w.length;P++)w.words[P]=0}var ue=E.clone()._ishlnsubmul(A,1,g);ue.negative===0&&(E=ue,w&&(w.words[g]=1));for(var ie=g-1;ie>=0;ie--){var fe=(E.words[A.length+ie]|0)*67108864+(E.words[A.length+ie-1]|0);for(fe=Math.min(fe/j|0,67108863),E._ishlnsubmul(A,fe,ie);E.negative!==0;)fe--,E.negative=0,E._ishlnsubmul(A,1,ie),E.isZero()||(E.negative^=1);w&&(w.words[ie]=fe)}return w&&w._strip(),E._strip(),m!=="div"&&x!==0&&E.iushrn(x),{div:w||null,mod:E}},o.prototype.divmod=function(d,m,x){if(i(!d.isZero()),this.isZero())return{div:new o(0),mod:new o(0)};var E,A,j;return this.negative!==0&&d.negative===0?(j=this.neg().divmod(d,m),m!=="mod"&&(E=j.div.neg()),m!=="div"&&(A=j.mod.neg(),x&&A.negative!==0&&A.iadd(d)),{div:E,mod:A}):this.negative===0&&d.negative!==0?(j=this.divmod(d.neg(),m),m!=="mod"&&(E=j.div.neg()),{div:E,mod:j.mod}):this.negative&d.negative?(j=this.neg().divmod(d.neg(),m),m!=="div"&&(A=j.mod.neg(),x&&A.negative!==0&&A.isub(d)),{div:j.div,mod:A}):d.length>this.length||this.cmp(d)<0?{div:new o(0),mod:this}:d.length===1?m==="div"?{div:this.divn(d.words[0]),mod:null}:m==="mod"?{div:null,mod:new o(this.modrn(d.words[0]))}:{div:this.divn(d.words[0]),mod:new o(this.modrn(d.words[0]))}:this._wordDiv(d,m)},o.prototype.div=function(d){return this.divmod(d,"div",!1).div},o.prototype.mod=function(d){return this.divmod(d,"mod",!1).mod},o.prototype.umod=function(d){return this.divmod(d,"mod",!0).mod},o.prototype.divRound=function(d){var m=this.divmod(d);if(m.mod.isZero())return m.div;var x=m.div.negative!==0?m.mod.isub(d):m.mod,E=d.ushrn(1),A=d.andln(1),j=x.cmp(E);return j<0||A===1&&j===0?m.div:m.div.negative!==0?m.div.isubn(1):m.div.iaddn(1)},o.prototype.modrn=function(d){var m=d<0;m&&(d=-d),i(d<=67108863);for(var x=(1<<26)%d,E=0,A=this.length-1;A>=0;A--)E=(x*E+(this.words[A]|0))%d;return m?-E:E},o.prototype.modn=function(d){return this.modrn(d)},o.prototype.idivn=function(d){var m=d<0;m&&(d=-d),i(d<=67108863);for(var x=0,E=this.length-1;E>=0;E--){var A=(this.words[E]|0)+x*67108864;this.words[E]=A/d|0,x=A%d}return this._strip(),m?this.ineg():this},o.prototype.divn=function(d){return this.clone().idivn(d)},o.prototype.egcd=function(d){i(d.negative===0),i(!d.isZero());var m=this,x=d.clone();m.negative!==0?m=m.umod(d):m=m.clone();for(var E=new o(1),A=new o(0),j=new o(0),k=new o(1),g=0;m.isEven()&&x.isEven();)m.iushrn(1),x.iushrn(1),++g;for(var w=x.clone(),P=m.clone();!m.isZero();){for(var ue=0,ie=1;!(m.words[0]&ie)&&ue<26;++ue,ie<<=1);if(ue>0)for(m.iushrn(ue);ue-- >0;)(E.isOdd()||A.isOdd())&&(E.iadd(w),A.isub(P)),E.iushrn(1),A.iushrn(1);for(var fe=0,ve=1;!(x.words[0]&ve)&&fe<26;++fe,ve<<=1);if(fe>0)for(x.iushrn(fe);fe-- >0;)(j.isOdd()||k.isOdd())&&(j.iadd(w),k.isub(P)),j.iushrn(1),k.iushrn(1);m.cmp(x)>=0?(m.isub(x),E.isub(j),A.isub(k)):(x.isub(m),j.isub(E),k.isub(A))}return{a:j,b:k,gcd:x.iushln(g)}},o.prototype._invmp=function(d){i(d.negative===0),i(!d.isZero());var m=this,x=d.clone();m.negative!==0?m=m.umod(d):m=m.clone();for(var E=new o(1),A=new o(0),j=x.clone();m.cmpn(1)>0&&x.cmpn(1)>0;){for(var k=0,g=1;!(m.words[0]&g)&&k<26;++k,g<<=1);if(k>0)for(m.iushrn(k);k-- >0;)E.isOdd()&&E.iadd(j),E.iushrn(1);for(var w=0,P=1;!(x.words[0]&P)&&w<26;++w,P<<=1);if(w>0)for(x.iushrn(w);w-- >0;)A.isOdd()&&A.iadd(j),A.iushrn(1);m.cmp(x)>=0?(m.isub(x),E.isub(A)):(x.isub(m),A.isub(E))}var ue;return m.cmpn(1)===0?ue=E:ue=A,ue.cmpn(0)<0&&ue.iadd(d),ue},o.prototype.gcd=function(d){if(this.isZero())return d.abs();if(d.isZero())return this.abs();var m=this.clone(),x=d.clone();m.negative=0,x.negative=0;for(var E=0;m.isEven()&&x.isEven();E++)m.iushrn(1),x.iushrn(1);do{for(;m.isEven();)m.iushrn(1);for(;x.isEven();)x.iushrn(1);var A=m.cmp(x);if(A<0){var j=m;m=x,x=j}else if(A===0||x.cmpn(1)===0)break;m.isub(x)}while(!0);return x.iushln(E)},o.prototype.invm=function(d){return this.egcd(d).a.umod(d)},o.prototype.isEven=function(){return(this.words[0]&1)===0},o.prototype.isOdd=function(){return(this.words[0]&1)===1},o.prototype.andln=function(d){return this.words[0]&d},o.prototype.bincn=function(d){i(typeof d=="number");var m=d%26,x=(d-m)/26,E=1<<m;if(this.length<=x)return this._expand(x+1),this.words[x]|=E,this;for(var A=E,j=x;A!==0&&j<this.length;j++){var k=this.words[j]|0;k+=A,A=k>>>26,k&=67108863,this.words[j]=k}return A!==0&&(this.words[j]=A,this.length++),this},o.prototype.isZero=function(){return this.length===1&&this.words[0]===0},o.prototype.cmpn=function(d){var m=d<0;if(this.negative!==0&&!m)return-1;if(this.negative===0&&m)return 1;this._strip();var x;if(this.length>1)x=1;else{m&&(d=-d),i(d<=67108863,"Number is too big");var E=this.words[0]|0;x=E===d?0:E<d?-1:1}return this.negative!==0?-x|0:x},o.prototype.cmp=function(d){if(this.negative!==0&&d.negative===0)return-1;if(this.negative===0&&d.negative!==0)return 1;var m=this.ucmp(d);return this.negative!==0?-m|0:m},o.prototype.ucmp=function(d){if(this.length>d.length)return 1;if(this.length<d.length)return-1;for(var m=0,x=this.length-1;x>=0;x--){var E=this.words[x]|0,A=d.words[x]|0;if(E!==A){E<A?m=-1:E>A&&(m=1);break}}return m},o.prototype.gtn=function(d){return this.cmpn(d)===1},o.prototype.gt=function(d){return this.cmp(d)===1},o.prototype.gten=function(d){return this.cmpn(d)>=0},o.prototype.gte=function(d){return this.cmp(d)>=0},o.prototype.ltn=function(d){return this.cmpn(d)===-1},o.prototype.lt=function(d){return this.cmp(d)===-1},o.prototype.lten=function(d){return this.cmpn(d)<=0},o.prototype.lte=function(d){return this.cmp(d)<=0},o.prototype.eqn=function(d){return this.cmpn(d)===0},o.prototype.eq=function(d){return this.cmp(d)===0},o.red=function(d){return new V(d)},o.prototype.toRed=function(d){return i(!this.red,"Already a number in reduction context"),i(this.negative===0,"red works only with positives"),d.convertTo(this)._forceRed(d)},o.prototype.fromRed=function(){return i(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},o.prototype._forceRed=function(d){return this.red=d,this},o.prototype.forceRed=function(d){return i(!this.red,"Already a number in reduction context"),this._forceRed(d)},o.prototype.redAdd=function(d){return i(this.red,"redAdd works only with red numbers"),this.red.add(this,d)},o.prototype.redIAdd=function(d){return i(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,d)},o.prototype.redSub=function(d){return i(this.red,"redSub works only with red numbers"),this.red.sub(this,d)},o.prototype.redISub=function(d){return i(this.red,"redISub works only with red numbers"),this.red.isub(this,d)},o.prototype.redShl=function(d){return i(this.red,"redShl works only with red numbers"),this.red.shl(this,d)},o.prototype.redMul=function(d){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,d),this.red.mul(this,d)},o.prototype.redIMul=function(d){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,d),this.red.imul(this,d)},o.prototype.redSqr=function(){return i(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return i(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return i(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return i(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return i(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(d){return i(this.red&&!d.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,d)};var H={k256:null,p224:null,p192:null,p25519:null};function z(p,d){this.name=p,this.p=new o(d,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}z.prototype._tmp=function(){var d=new o(null);return d.words=new Array(Math.ceil(this.n/13)),d},z.prototype.ireduce=function(d){var m=d,x;do this.split(m,this.tmp),m=this.imulK(m),m=m.iadd(this.tmp),x=m.bitLength();while(x>this.n);var E=x<this.n?-1:m.ucmp(this.p);return E===0?(m.words[0]=0,m.length=1):E>0?m.isub(this.p):m.strip!==void 0?m.strip():m._strip(),m},z.prototype.split=function(d,m){d.iushrn(this.n,0,m)},z.prototype.imulK=function(d){return d.imul(this.k)};function ne(){z.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}s(ne,z),ne.prototype.split=function(d,m){for(var x=4194303,E=Math.min(d.length,9),A=0;A<E;A++)m.words[A]=d.words[A];if(m.length=E,d.length<=9){d.words[0]=0,d.length=1;return}var j=d.words[9];for(m.words[m.length++]=j&x,A=10;A<d.length;A++){var k=d.words[A]|0;d.words[A-10]=(k&x)<<4|j>>>22,j=k}j>>>=22,d.words[A-10]=j,j===0&&d.length>10?d.length-=10:d.length-=9},ne.prototype.imulK=function(d){d.words[d.length]=0,d.words[d.length+1]=0,d.length+=2;for(var m=0,x=0;x<d.length;x++){var E=d.words[x]|0;m+=E*977,d.words[x]=m&67108863,m=E*64+(m/67108864|0)}return d.words[d.length-1]===0&&(d.length--,d.words[d.length-1]===0&&d.length--),d};function le(){z.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}s(le,z);function te(){z.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}s(te,z);function ce(){z.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}s(ce,z),ce.prototype.imulK=function(d){for(var m=0,x=0;x<d.length;x++){var E=(d.words[x]|0)*19+m,A=E&67108863;E>>>=26,d.words[x]=A,m=E}return m!==0&&(d.words[d.length++]=m),d},o._prime=function(d){if(H[d])return H[d];var m;if(d==="k256")m=new ne;else if(d==="p224")m=new le;else if(d==="p192")m=new te;else if(d==="p25519")m=new ce;else throw new Error("Unknown prime "+d);return H[d]=m,m};function V(p){if(typeof p=="string"){var d=o._prime(p);this.m=d.p,this.prime=d}else i(p.gtn(1),"modulus must be greater than 1"),this.m=p,this.prime=null}V.prototype._verify1=function(d){i(d.negative===0,"red works only with positives"),i(d.red,"red works only with red numbers")},V.prototype._verify2=function(d,m){i((d.negative|m.negative)===0,"red works only with positives"),i(d.red&&d.red===m.red,"red works only with red numbers")},V.prototype.imod=function(d){return this.prime?this.prime.ireduce(d)._forceRed(this):(f(d,d.umod(this.m)._forceRed(this)),d)},V.prototype.neg=function(d){return d.isZero()?d.clone():this.m.sub(d)._forceRed(this)},V.prototype.add=function(d,m){this._verify2(d,m);var x=d.add(m);return x.cmp(this.m)>=0&&x.isub(this.m),x._forceRed(this)},V.prototype.iadd=function(d,m){this._verify2(d,m);var x=d.iadd(m);return x.cmp(this.m)>=0&&x.isub(this.m),x},V.prototype.sub=function(d,m){this._verify2(d,m);var x=d.sub(m);return x.cmpn(0)<0&&x.iadd(this.m),x._forceRed(this)},V.prototype.isub=function(d,m){this._verify2(d,m);var x=d.isub(m);return x.cmpn(0)<0&&x.iadd(this.m),x},V.prototype.shl=function(d,m){return this._verify1(d),this.imod(d.ushln(m))},V.prototype.imul=function(d,m){return this._verify2(d,m),this.imod(d.imul(m))},V.prototype.mul=function(d,m){return this._verify2(d,m),this.imod(d.mul(m))},V.prototype.isqr=function(d){return this.imul(d,d.clone())},V.prototype.sqr=function(d){return this.mul(d,d)},V.prototype.sqrt=function(d){if(d.isZero())return d.clone();var m=this.m.andln(3);if(i(m%2===1),m===3){var x=this.m.add(new o(1)).iushrn(2);return this.pow(d,x)}for(var E=this.m.subn(1),A=0;!E.isZero()&&E.andln(1)===0;)A++,E.iushrn(1);i(!E.isZero());var j=new o(1).toRed(this),k=j.redNeg(),g=this.m.subn(1).iushrn(1),w=this.m.bitLength();for(w=new o(2*w*w).toRed(this);this.pow(w,g).cmp(k)!==0;)w.redIAdd(k);for(var P=this.pow(w,E),ue=this.pow(d,E.addn(1).iushrn(1)),ie=this.pow(d,E),fe=A;ie.cmp(j)!==0;){for(var ve=ie,Ce=0;ve.cmp(j)!==0;Ce++)ve=ve.redSqr();i(Ce<fe);var N=this.pow(P,new o(1).iushln(fe-Ce-1));ue=ue.redMul(N),P=N.redSqr(),ie=ie.redMul(P),fe=Ce}return ue},V.prototype.invm=function(d){var m=d._invmp(this.m);return m.negative!==0?(m.negative=0,this.imod(m).redNeg()):this.imod(m)},V.prototype.pow=function(d,m){if(m.isZero())return new o(1).toRed(this);if(m.cmpn(1)===0)return d.clone();var x=4,E=new Array(1<<x);E[0]=new o(1).toRed(this),E[1]=d;for(var A=2;A<E.length;A++)E[A]=this.mul(E[A-1],d);var j=E[0],k=0,g=0,w=m.bitLength()%26;for(w===0&&(w=26),A=m.length-1;A>=0;A--){for(var P=m.words[A],ue=w-1;ue>=0;ue--){var ie=P>>ue&1;if(j!==E[0]&&(j=this.sqr(j)),ie===0&&k===0){g=0;continue}k<<=1,k|=ie,g++,!(g!==x&&(A!==0||ue!==0))&&(j=this.mul(j,E[k]),g=0,k=0)}w=26}return j},V.prototype.convertTo=function(d){var m=d.umod(this.m);return m===d?m.clone():m},V.prototype.convertFrom=function(d){var m=d.clone();return m.red=null,m},o.mont=function(d){return new L(d)};function L(p){V.call(this,p),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}s(L,V),L.prototype.convertTo=function(d){return this.imod(d.ushln(this.shift))},L.prototype.convertFrom=function(d){var m=this.imod(d.mul(this.rinv));return m.red=null,m},L.prototype.imul=function(d,m){if(d.isZero()||m.isZero())return d.words[0]=0,d.length=1,d;var x=d.imul(m),E=x.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),A=x.isub(E).iushrn(this.shift),j=A;return A.cmp(this.m)>=0?j=A.isub(this.m):A.cmpn(0)<0&&(j=A.iadd(this.m)),j._forceRed(this)},L.prototype.mul=function(d,m){if(d.isZero()||m.isZero())return new o(0)._forceRed(this);var x=d.mul(m),E=x.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),A=x.isub(E).iushrn(this.shift),j=A;return A.cmp(this.m)>=0?j=A.isub(this.m):A.cmpn(0)<0&&(j=A.iadd(this.m)),j._forceRed(this)},L.prototype.invm=function(d){var m=this.imod(d._invmp(this.m).mul(this.r2));return m._forceRed(this)}})(typeof t>"u"||t,e)}}),dr=Ac(Mc()),Za=Ac(Mc());function Cp(e){switch(e){case 1e3:return"Number too large";case 1001:return"Rate limit exceeded";case 1002:return"Insufficient liquidity";case 1003:return"HoneyPot scam detected";default:return"Unknown error"}}function Fv(e,...t){const r=Array.isArray(t[t.length-1])?t.pop():[];let i=[e,...t].filter(Boolean).join("::");return r&&r.length&&(i+=`<${r.join(", ")}>`),i}function DU(e){return e.split("::")[0]}function sc(e){var t;try{let r=e.replace(/\s/g,"");const n=r.match(/(<.+>)$/),i=(t=n==null?void 0:n[0])==null?void 0:t.match(/(\w+::\w+::\w+)(?:<.*?>(?!>))?/g);if(i){r=r.slice(0,r.indexOf("<"));const c=sc(r),u=RU(jU({},c),{type_arguments:i.map(l=>sc(l).source_address)});return u.type_arguments=u.type_arguments.map(l=>KS.isSuiCoin(l)?l:sc(l).source_address),u.source_address=Fv(u.full_address,u.type_arguments),u}const s=r.split("::"),a={full_address:r,address:r===GS||r===UU?"0x2":fr.normalizeSuiObjectId(s[0]),module:s[1],name:s[2],type_arguments:[],source_address:""};return a.full_address=`${a.address}::${a.module}::${a.name}`,a.source_address=Fv(a.full_address,a.type_arguments),a}catch{return{full_address:e,address:"",module:"",name:"",type_arguments:[],source_address:e}}}function Vv(e){return sc(e).source_address}var LU="0x2::coin::Coin",BU=/^0x2::coin::Coin<(.+)>$/,GS="0x2::sui::SUI",UU="0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI",KS=class so{static getCoinTypeArg(t){const r=t.type.match(BU);return r?r[1]:null}static isSUI(t){const r=so.getCoinTypeArg(t);return r?so.getCoinSymbol(r)==="SUI":!1}static getCoinSymbol(t){return t.substring(t.lastIndexOf(":")+1)}static getBalance(t){return BigInt(t.fields.balance)}static totalBalance(t,r){let n=BigInt(0);return t.forEach(i=>{r===i.coinAddress&&(n+=BigInt(i.balance))}),n}static getID(t){return t.fields.id.id}static getCoinTypeFromArg(t){return`${LU}<${t}>`}static getCoinAssets(t,r){const n=[];return r.forEach(i=>{Vv(i.coinAddress)===Vv(t)&&n.push(i)}),n}static isSuiCoin(t){return sc(t).full_address===GS}static selectCoinObjectIdGreaterThanOrEqual(t,r,n=[]){const i=so.selectCoinAssetGreaterThanOrEqual(t,r,n),s=i.selectedCoins.map(c=>c.coinObjectId),o=i.remainingCoins,a=i.selectedCoins.map(c=>c.balance.toString());return{objectArray:s,remainCoins:o,amountArray:a}}static selectCoinAssetGreaterThanOrEqual(t,r,n=[]){const i=so.sortByBalance(t.filter(u=>!n.includes(u.coinObjectId))),s=so.calculateTotalBalance(i);if(s<r)return{selectedCoins:[],remainingCoins:i};if(s===r)return{selectedCoins:i,remainingCoins:[]};let o=BigInt(0);const a=[],c=[...i];for(;o<s;){const u=r-o,l=c.findIndex(h=>h.balance>=u);if(l!==-1){a.push(c[l]),c.splice(l,1);break}const f=c.pop();f.balance>0&&(a.push(f),o+=f.balance)}return{selectedCoins:so.sortByBalance(a),remainingCoins:so.sortByBalance(c)}}static sortByBalance(t){return t.sort((r,n)=>r.balance<n.balance?-1:r.balance>n.balance?1:0)}static sortByBalanceDes(t){return t.sort((r,n)=>r.balance>n.balance?-1:r.balance<n.balance?0:1)}static calculateTotalBalance(t){return t.reduce((r,n)=>r+n.balance,BigInt(0))}};function Mo(e){const t=e.indexOf("::");if(t===-1)return e;const r=e.substring(0,t),n=e.substring(t);if(!r.startsWith("0x"))return e;const i=r.substring(2);return i.length>64?e:`0x${i.padStart(64,"0")}${n}`}function FU(e,t){e=Mo(e),t=Mo(t);const r=Math.min(e.length,t.length);for(let n=0;n<r;n++){if(e[n]>t[n])return!0;if(e[n]<t[n])return!1}return!0}var al=Ac(Mc()),Na=new al.default(0);new al.default(1);var VU=new al.default(2);VU.pow(new al.default(128));new al.default("18446744073709551615");var z0="18446744073709551615",zU="0xb1e11ceaf3e7cd3031ef5e24804478ec3441c5aecdace910bdaca317a0c1c535",Xf={AGGREGATOR_V3:"aggregator_v3"},Jf={Mainnet:"0xdeeb7a4662eec9f2f3def03fb937a663dddaa2e215b8078a284d026b7946c270::deep::DEEP",Testnet:"0x36dbef866a1d62bf7328989a10fb2f07d769f4ee587c0de4a0a256e57e0a58a8::deep::DEEP"},pi={DEFAULT_PYTH_URL:"https://hermes.pyth.network",PYTH_TIMEOUT:3e3,MAX_OVERLAY_FEE_RATE:.1,MAX_OVERLAY_FEE_RATE_NUMERATOR:1e5,FEE_RATE_MULTIPLIER:1e6,DEFAULT_OVERLAY_FEE_RECEIVER:"0x0",ERRORS:{SIGNER_REQUIRED:"Signer is required, but not provided.",INVALID_OVERLAY_FEE_RATE:"Overlay fee rate must be between 0 and 0.1",INVALID_SLIPPAGE:"Invalid slippage value. Must be between 0 and 1 (e.g., 0.01 represents 1% slippage)",NO_ROUTER_FOUND:"No router found",EMPTY_PATH:"Empty path",UNSUPPORTED_DEX:"Unsupported dex",PYTH_UNAVAILABLE:"All Pyth price nodes are unavailable. Cannot fetch price data. Please switch to or add new available Pyth nodes",QUOTE_ID_REQUIRED:"Quote ID is required",AGGREGATOR_V3_PACKAGE_REQUIRED:"Aggregator V3 package is required",PACKAGES_REQUIRED:"Packages are required",OVERLAY_FEE_RECEIVER_REQUIRED:"Overlay fee rate is set, but overlay fee receiver is not set"}},Kt={FEE_DENOMINATOR:1e6,MAX_FEE_RATE:1e5,MAX_AMOUNT_IN:z0,DEFAULT_PUBLISHED_AT:{Mainnet:"0x33ec64e9bb369bf045ddc198c81adbf2acab424da37465d95296ee02045d2b17",Testnet:"0x0"}},YS=1010106;function WU(e,t){let r=new Map;return e.packages&&(e.packages instanceof Map?r=e.packages:typeof e.packages=="object"&&Object.entries(e.packages).forEach(([n,i])=>{r.set(n,i)})),{quoteID:e.request_id||"",amountIn:new Za.default(e.amount_in.toString()),amountOut:new Za.default(e.amount_out.toString()),byAmountIn:t,insufficientLiquidity:!1,deviationRatio:e.deviation_ratio,packages:r,paths:e.paths.map(n=>({id:n.id,direction:n.direction,provider:n.provider,from:n.from,target:n.target,feeRate:n.fee_rate,amountIn:n.amount_in.toString(),amountOut:n.amount_out.toString(),version:n.version,publishedAt:n.published_at,extendedDetails:n.extended_details}))}}function qU(e,t,r,n,i){return mn(this,null,function*(){let s;if(r.liquidityChanges&&r.liquidityChanges.length>0?s=yield GU(e,r):s=yield HU(e,t,r),!s)return null;if(!s.ok){let c=1e3;return s.status===429&&(c=1001),{quoteID:"",amountIn:Na,amountOut:Na,paths:[],byAmountIn:r.byAmountIn,insufficientLiquidity:!1,deviationRatio:0,error:{code:c,msg:Cp(c)}}}const o=TU.default.parse(yield s.text()),a=o.msg==="liquidity is not enough";if(o.msg&&o.msg.indexOf("HoneyPot scam")>-1)return{quoteID:"",amountIn:Na,amountOut:Na,paths:[],byAmountIn:r.byAmountIn,insufficientLiquidity:a,deviationRatio:0,error:{code:1003,msg:Cp(1003)}};if(o.data!=null){const c=WU(o.data,r.byAmountIn);if(n>0&&i!=="0x0")if(r.byAmountIn){const u=c.amountOut.mul(new Za.default(n)).div(new Za.default(1e6));c.overlayFee=Number(u.toString()),c.amountOut=c.amountOut.sub(u)}else{const u=c.amountIn.mul(new Za.default(n)).div(new Za.default(1e6));c.overlayFee=Number(u.toString()),c.amountIn=c.amountIn.add(u)}return c.packages||(c.packages=new Map),c.packages.has("aggregator_v3")||c.packages.set("aggregator_v3","0x3864c7c59a4889fec05d1aae4bc9dba5a0e0940594b424fbed44cb3f6ac4c032"),c}return{quoteID:"",amountIn:Na,amountOut:Na,paths:[],insufficientLiquidity:a,byAmountIn:r.byAmountIn,deviationRatio:0,error:{code:1002,msg:Cp(1002)}}})}function HU(e,t,r){return mn(this,null,function*(){try{const{from:n,target:i,amount:s,byAmountIn:o,depth:a,splitAlgorithm:c,splitFactor:u,splitCount:l,providers:f}=r,h=Mo(n),v=Mo(i);let b=`${e}/find_routes?from=${h}&target=${v}&amount=${s.toString()}&by_amount_in=${o}`;return a&&(b+=`&depth=${a}`),c&&(b+=`&split_algorithm=${c}`),u&&(b+=`&split_factor=${u}`),l&&(b+=`&split_count=${l}`),f&&f.length>0&&(b+=`&providers=${f.join(",")}`),t.length>0&&(b+=`&apiKey=${t}`),b+=`&v=${YS}`,yield fetch(b)}catch(n){return console.error(n),null}})}function GU(e,t){return mn(this,null,function*(){const{from:r,target:n,amount:i,byAmountIn:s,depth:o,splitAlgorithm:a,splitFactor:c,splitCount:u,providers:l,liquidityChanges:f}=t,h=Mo(r),v=Mo(n),b=`${e}/find_routes`,y=l==null?void 0:l.join(","),S={from:h,target:v,amount:Number(i.toString()),by_amount_in:s,depth:o,split_algorithm:a,split_factor:c,split_count:u,providers:y,liquidity_changes:f.map(C=>({pool:C.poolID,tick_lower:C.ticklower,tick_upper:C.tickUpper,delta_liquidity:C.deltaLiquidity})),v:YS};try{return yield fetch(b,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(S)})}catch(C){return console.error("Error:",C),null}})}function KU(e){return mn(this,null,function*(){const t=`${e}/deepbookv3_config`;try{return(yield fetch(t)).json()}catch(r){return console.error("Error:",r),null}})}function zv(e){const t=e.paths,r=t[0].from,n=t[t.length-1].target,i=[];for(const o of t)i.push({path:o,isLastUseOfIntermediateToken:!1});const s=new Map;for(let o=i.length-1;o>=0;o--){const{from:a}=i[o].path;s.has(a)||(s.set(a,!0),i[o].isLastUseOfIntermediateToken=!0)}return{quoteID:e.quoteID||"",amountIn:e.amountIn,amountOut:e.amountOut,byAmountIn:e.byAmountIn,flattenedPaths:i,fromCoinType:r,targetCoinType:n,packages:e.packages,totalDeepFee:e.totalDeepFee,error:e.error,overlayFee:e.overlayFee}}var XS=(e=>(e[e.Mainnet=0]="Mainnet",e[e.Testnet=1]="Testnet",e))(XS||{}),YU=Ac(Mc()),Qa=9e15,No=1e9,W0="0123456789abcdef",Zf="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",Qf="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",q0={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-Qa,maxE:Qa,crypto:!1},JS,ks,At=!0,zd="[DecimalError] ",Oo=zd+"Invalid argument: ",ZS=zd+"Precision limit exceeded",QS=zd+"crypto unavailable",e5="[object Decimal]",un=Math.floor,$r=Math.pow,XU=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,JU=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,ZU=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,t5=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,Ti=1e7,wt=7,QU=9007199254740991,eF=Zf.length-1,H0=Qf.length-1,Ne={toStringTag:e5};Ne.absoluteValue=Ne.abs=function(){var e=new this.constructor(this);return e.s<0&&(e.s=1),dt(e)};Ne.ceil=function(){return dt(new this.constructor(this),this.e+1,2)};Ne.clampedTo=Ne.clamp=function(e,t){var r,n=this,i=n.constructor;if(e=new i(e),t=new i(t),!e.s||!t.s)return new i(NaN);if(e.gt(t))throw Error(Oo+t);return r=n.cmp(e),r<0?e:n.cmp(t)>0?t:new i(n)};Ne.comparedTo=Ne.cmp=function(e){var t,r,n,i,s=this,o=s.d,a=(e=new s.constructor(e)).d,c=s.s,u=e.s;if(!o||!a)return!c||!u?NaN:c!==u?c:o===a?0:!o^c<0?1:-1;if(!o[0]||!a[0])return o[0]?c:a[0]?-u:0;if(c!==u)return c;if(s.e!==e.e)return s.e>e.e^c<0?1:-1;for(n=o.length,i=a.length,t=0,r=n<i?n:i;t<r;++t)if(o[t]!==a[t])return o[t]>a[t]^c<0?1:-1;return n===i?0:n>i^c<0?1:-1};Ne.cosine=Ne.cos=function(){var e,t,r=this,n=r.constructor;return r.d?r.d[0]?(e=n.precision,t=n.rounding,n.precision=e+Math.max(r.e,r.sd())+wt,n.rounding=1,r=tF(n,o5(n,r)),n.precision=e,n.rounding=t,dt(ks==2||ks==3?r.neg():r,e,t,!0)):new n(1):new n(NaN)};Ne.cubeRoot=Ne.cbrt=function(){var e,t,r,n,i,s,o,a,c,u,l=this,f=l.constructor;if(!l.isFinite()||l.isZero())return new f(l);for(At=!1,s=l.s*$r(l.s*l,1/3),!s||Math.abs(s)==1/0?(r=Jr(l.d),e=l.e,(s=(e-r.length+1)%3)&&(r+=s==1||s==-2?"0":"00"),s=$r(r,1/3),e=un((e+1)/3)-(e%3==(e<0?-1:2)),s==1/0?r="5e"+e:(r=s.toExponential(),r=r.slice(0,r.indexOf("e")+1)+e),n=new f(r),n.s=l.s):n=new f(s.toString()),o=(e=f.precision)+3;;)if(a=n,c=a.times(a).times(a),u=c.plus(l),n=Qt(u.plus(l).times(a),u.plus(c),o+2,1),Jr(a.d).slice(0,o)===(r=Jr(n.d)).slice(0,o))if(r=r.slice(o-3,o+1),r=="9999"||!i&&r=="4999"){if(!i&&(dt(a,e+1,0),a.times(a).times(a).eq(l))){n=a;break}o+=4,i=1}else{(!+r||!+r.slice(1)&&r.charAt(0)=="5")&&(dt(n,e+1,1),t=!n.times(n).times(n).eq(l));break}return At=!0,dt(n,e,f.rounding,t)};Ne.decimalPlaces=Ne.dp=function(){var e,t=this.d,r=NaN;if(t){if(e=t.length-1,r=(e-un(this.e/wt))*wt,e=t[e],e)for(;e%10==0;e/=10)r--;r<0&&(r=0)}return r};Ne.dividedBy=Ne.div=function(e){return Qt(this,new this.constructor(e))};Ne.dividedToIntegerBy=Ne.divToInt=function(e){var t=this,r=t.constructor;return dt(Qt(t,new r(e),0,1,1),r.precision,r.rounding)};Ne.equals=Ne.eq=function(e){return this.cmp(e)===0};Ne.floor=function(){return dt(new this.constructor(this),this.e+1,3)};Ne.greaterThan=Ne.gt=function(e){return this.cmp(e)>0};Ne.greaterThanOrEqualTo=Ne.gte=function(e){var t=this.cmp(e);return t==1||t===0};Ne.hyperbolicCosine=Ne.cosh=function(){var e,t,r,n,i,s=this,o=s.constructor,a=new o(1);if(!s.isFinite())return new o(s.s?1/0:NaN);if(s.isZero())return a;r=o.precision,n=o.rounding,o.precision=r+Math.max(s.e,s.sd())+4,o.rounding=1,i=s.d.length,i<32?(e=Math.ceil(i/3),t=(1/qd(4,e)).toString()):(e=16,t="2.3283064365386962890625e-10"),s=pc(o,1,s.times(t),new o(1),!0);for(var c,u=e,l=new o(8);u--;)c=s.times(s),s=a.minus(c.times(l.minus(c.times(l))));return dt(s,o.precision=r,o.rounding=n,!0)};Ne.hyperbolicSine=Ne.sinh=function(){var e,t,r,n,i=this,s=i.constructor;if(!i.isFinite()||i.isZero())return new s(i);if(t=s.precision,r=s.rounding,s.precision=t+Math.max(i.e,i.sd())+4,s.rounding=1,n=i.d.length,n<3)i=pc(s,2,i,i,!0);else{e=1.4*Math.sqrt(n),e=e>16?16:e|0,i=i.times(1/qd(5,e)),i=pc(s,2,i,i,!0);for(var o,a=new s(5),c=new s(16),u=new s(20);e--;)o=i.times(i),i=i.times(a.plus(o.times(c.times(o).plus(u))))}return s.precision=t,s.rounding=r,dt(i,t,r,!0)};Ne.hyperbolicTangent=Ne.tanh=function(){var e,t,r=this,n=r.constructor;return r.isFinite()?r.isZero()?new n(r):(e=n.precision,t=n.rounding,n.precision=e+7,n.rounding=1,Qt(r.sinh(),r.cosh(),n.precision=e,n.rounding=t)):new n(r.s)};Ne.inverseCosine=Ne.acos=function(){var e=this,t=e.constructor,r=e.abs().cmp(1),n=t.precision,i=t.rounding;return r!==-1?r===0?e.isNeg()?Yi(t,n,i):new t(0):new t(NaN):e.isZero()?Yi(t,n+4,i).times(.5):(t.precision=n+6,t.rounding=1,e=new t(1).minus(e).div(e.plus(1)).sqrt().atan(),t.precision=n,t.rounding=i,e.times(2))};Ne.inverseHyperbolicCosine=Ne.acosh=function(){var e,t,r=this,n=r.constructor;return r.lte(1)?new n(r.eq(1)?0:NaN):r.isFinite()?(e=n.precision,t=n.rounding,n.precision=e+Math.max(Math.abs(r.e),r.sd())+4,n.rounding=1,At=!1,r=r.times(r).minus(1).sqrt().plus(r),At=!0,n.precision=e,n.rounding=t,r.ln()):new n(r)};Ne.inverseHyperbolicSine=Ne.asinh=function(){var e,t,r=this,n=r.constructor;return!r.isFinite()||r.isZero()?new n(r):(e=n.precision,t=n.rounding,n.precision=e+2*Math.max(Math.abs(r.e),r.sd())+6,n.rounding=1,At=!1,r=r.times(r).plus(1).sqrt().plus(r),At=!0,n.precision=e,n.rounding=t,r.ln())};Ne.inverseHyperbolicTangent=Ne.atanh=function(){var e,t,r,n,i=this,s=i.constructor;return i.isFinite()?i.e>=0?new s(i.abs().eq(1)?i.s/0:i.isZero()?i:NaN):(e=s.precision,t=s.rounding,n=i.sd(),Math.max(n,e)<2*-i.e-1?dt(new s(i),e,t,!0):(s.precision=r=n-i.e,i=Qt(i.plus(1),new s(1).minus(i),r+e,1),s.precision=e+4,s.rounding=1,i=i.ln(),s.precision=e,s.rounding=t,i.times(.5))):new s(NaN)};Ne.inverseSine=Ne.asin=function(){var e,t,r,n,i=this,s=i.constructor;return i.isZero()?new s(i):(t=i.abs().cmp(1),r=s.precision,n=s.rounding,t!==-1?t===0?(e=Yi(s,r+4,n).times(.5),e.s=i.s,e):new s(NaN):(s.precision=r+6,s.rounding=1,i=i.div(new s(1).minus(i.times(i)).sqrt().plus(1)).atan(),s.precision=r,s.rounding=n,i.times(2)))};Ne.inverseTangent=Ne.atan=function(){var e,t,r,n,i,s,o,a,c,u=this,l=u.constructor,f=l.precision,h=l.rounding;if(u.isFinite()){if(u.isZero())return new l(u);if(u.abs().eq(1)&&f+4<=H0)return o=Yi(l,f+4,h).times(.25),o.s=u.s,o}else{if(!u.s)return new l(NaN);if(f+4<=H0)return o=Yi(l,f+4,h).times(.5),o.s=u.s,o}for(l.precision=a=f+10,l.rounding=1,r=Math.min(28,a/wt+2|0),e=r;e;--e)u=u.div(u.times(u).plus(1).sqrt().plus(1));for(At=!1,t=Math.ceil(a/wt),n=1,c=u.times(u),o=new l(u),i=u;e!==-1;)if(i=i.times(c),s=o.minus(i.div(n+=2)),i=i.times(c),o=s.plus(i.div(n+=2)),o.d[t]!==void 0)for(e=t;o.d[e]===s.d[e]&&e--;);return r&&(o=o.times(2<<r-1)),At=!0,dt(o,l.precision=f,l.rounding=h,!0)};Ne.isFinite=function(){return!!this.d};Ne.isInteger=Ne.isInt=function(){return!!this.d&&un(this.e/wt)>this.d.length-2};Ne.isNaN=function(){return!this.s};Ne.isNegative=Ne.isNeg=function(){return this.s<0};Ne.isPositive=Ne.isPos=function(){return this.s>0};Ne.isZero=function(){return!!this.d&&this.d[0]===0};Ne.lessThan=Ne.lt=function(e){return this.cmp(e)<0};Ne.lessThanOrEqualTo=Ne.lte=function(e){return this.cmp(e)<1};Ne.logarithm=Ne.log=function(e){var t,r,n,i,s,o,a,c,u=this,l=u.constructor,f=l.precision,h=l.rounding,v=5;if(e==null)e=new l(10),t=!0;else{if(e=new l(e),r=e.d,e.s<0||!r||!r[0]||e.eq(1))return new l(NaN);t=e.eq(10)}if(r=u.d,u.s<0||!r||!r[0]||u.eq(1))return new l(r&&!r[0]?-1/0:u.s!=1?NaN:r?0:1/0);if(t)if(r.length>1)s=!0;else{for(i=r[0];i%10===0;)i/=10;s=i!==1}if(At=!1,a=f+v,o=bo(u,a),n=t?ed(l,a+10):bo(e,a),c=Qt(o,n,a,1),Iu(c.d,i=f,h))do if(a+=10,o=bo(u,a),n=t?ed(l,a+10):bo(e,a),c=Qt(o,n,a,1),!s){+Jr(c.d).slice(i+1,i+15)+1==1e14&&(c=dt(c,f+1,0));break}while(Iu(c.d,i+=10,h));return At=!0,dt(c,f,h)};Ne.minus=Ne.sub=function(e){var t,r,n,i,s,o,a,c,u,l,f,h,v=this,b=v.constructor;if(e=new b(e),!v.d||!e.d)return!v.s||!e.s?e=new b(NaN):v.d?e.s=-e.s:e=new b(e.d||v.s!==e.s?v:NaN),e;if(v.s!=e.s)return e.s=-e.s,v.plus(e);if(u=v.d,h=e.d,a=b.precision,c=b.rounding,!u[0]||!h[0]){if(h[0])e.s=-e.s;else if(u[0])e=new b(v);else return new b(c===3?-0:0);return At?dt(e,a,c):e}if(r=un(e.e/wt),l=un(v.e/wt),u=u.slice(),s=l-r,s){for(f=s<0,f?(t=u,s=-s,o=h.length):(t=h,r=l,o=u.length),n=Math.max(Math.ceil(a/wt),o)+2,s>n&&(s=n,t.length=1),t.reverse(),n=s;n--;)t.push(0);t.reverse()}else{for(n=u.length,o=h.length,f=n<o,f&&(o=n),n=0;n<o;n++)if(u[n]!=h[n]){f=u[n]<h[n];break}s=0}for(f&&(t=u,u=h,h=t,e.s=-e.s),o=u.length,n=h.length-o;n>0;--n)u[o++]=0;for(n=h.length;n>s;){if(u[--n]<h[n]){for(i=n;i&&u[--i]===0;)u[i]=Ti-1;--u[i],u[n]+=Ti}u[n]-=h[n]}for(;u[--o]===0;)u.pop();for(;u[0]===0;u.shift())--r;return u[0]?(e.d=u,e.e=Wd(u,r),At?dt(e,a,c):e):new b(c===3?-0:0)};Ne.modulo=Ne.mod=function(e){var t,r=this,n=r.constructor;return e=new n(e),!r.d||!e.s||e.d&&!e.d[0]?new n(NaN):!e.d||r.d&&!r.d[0]?dt(new n(r),n.precision,n.rounding):(At=!1,n.modulo==9?(t=Qt(r,e.abs(),0,3,1),t.s*=e.s):t=Qt(r,e,0,n.modulo,1),t=t.times(e),At=!0,r.minus(t))};Ne.naturalExponential=Ne.exp=function(){return G0(this)};Ne.naturalLogarithm=Ne.ln=function(){return bo(this)};Ne.negated=Ne.neg=function(){var e=new this.constructor(this);return e.s=-e.s,dt(e)};Ne.plus=Ne.add=function(e){var t,r,n,i,s,o,a,c,u,l,f=this,h=f.constructor;if(e=new h(e),!f.d||!e.d)return!f.s||!e.s?e=new h(NaN):f.d||(e=new h(e.d||f.s===e.s?f:NaN)),e;if(f.s!=e.s)return e.s=-e.s,f.minus(e);if(u=f.d,l=e.d,a=h.precision,c=h.rounding,!u[0]||!l[0])return l[0]||(e=new h(f)),At?dt(e,a,c):e;if(s=un(f.e/wt),n=un(e.e/wt),u=u.slice(),i=s-n,i){for(i<0?(r=u,i=-i,o=l.length):(r=l,n=s,o=u.length),s=Math.ceil(a/wt),o=s>o?s+1:o+1,i>o&&(i=o,r.length=1),r.reverse();i--;)r.push(0);r.reverse()}for(o=u.length,i=l.length,o-i<0&&(i=o,r=l,l=u,u=r),t=0;i;)t=(u[--i]=u[i]+l[i]+t)/Ti|0,u[i]%=Ti;for(t&&(u.unshift(t),++n),o=u.length;u[--o]==0;)u.pop();return e.d=u,e.e=Wd(u,n),At?dt(e,a,c):e};Ne.precision=Ne.sd=function(e){var t,r=this;if(e!==void 0&&e!==!!e&&e!==1&&e!==0)throw Error(Oo+e);return r.d?(t=r5(r.d),e&&r.e+1>t&&(t=r.e+1)):t=NaN,t};Ne.round=function(){var e=this,t=e.constructor;return dt(new t(e),e.e+1,t.rounding)};Ne.sine=Ne.sin=function(){var e,t,r=this,n=r.constructor;return r.isFinite()?r.isZero()?new n(r):(e=n.precision,t=n.rounding,n.precision=e+Math.max(r.e,r.sd())+wt,n.rounding=1,r=nF(n,o5(n,r)),n.precision=e,n.rounding=t,dt(ks>2?r.neg():r,e,t,!0)):new n(NaN)};Ne.squareRoot=Ne.sqrt=function(){var e,t,r,n,i,s,o=this,a=o.d,c=o.e,u=o.s,l=o.constructor;if(u!==1||!a||!a[0])return new l(!u||u<0&&(!a||a[0])?NaN:a?o:1/0);for(At=!1,u=Math.sqrt(+o),u==0||u==1/0?(t=Jr(a),(t.length+c)%2==0&&(t+="0"),u=Math.sqrt(t),c=un((c+1)/2)-(c<0||c%2),u==1/0?t="5e"+c:(t=u.toExponential(),t=t.slice(0,t.indexOf("e")+1)+c),n=new l(t)):n=new l(u.toString()),r=(c=l.precision)+3;;)if(s=n,n=s.plus(Qt(o,s,r+2,1)).times(.5),Jr(s.d).slice(0,r)===(t=Jr(n.d)).slice(0,r))if(t=t.slice(r-3,r+1),t=="9999"||!i&&t=="4999"){if(!i&&(dt(s,c+1,0),s.times(s).eq(o))){n=s;break}r+=4,i=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(dt(n,c+1,1),e=!n.times(n).eq(o));break}return At=!0,dt(n,c,l.rounding,e)};Ne.tangent=Ne.tan=function(){var e,t,r=this,n=r.constructor;return r.isFinite()?r.isZero()?new n(r):(e=n.precision,t=n.rounding,n.precision=e+10,n.rounding=1,r=r.sin(),r.s=1,r=Qt(r,new n(1).minus(r.times(r)).sqrt(),e+10,0),n.precision=e,n.rounding=t,dt(ks==2||ks==4?r.neg():r,e,t,!0)):new n(NaN)};Ne.times=Ne.mul=function(e){var t,r,n,i,s,o,a,c,u,l=this,f=l.constructor,h=l.d,v=(e=new f(e)).d;if(e.s*=l.s,!h||!h[0]||!v||!v[0])return new f(!e.s||h&&!h[0]&&!v||v&&!v[0]&&!h?NaN:!h||!v?e.s/0:e.s*0);for(r=un(l.e/wt)+un(e.e/wt),c=h.length,u=v.length,c<u&&(s=h,h=v,v=s,o=c,c=u,u=o),s=[],o=c+u,n=o;n--;)s.push(0);for(n=u;--n>=0;){for(t=0,i=c+n;i>n;)a=s[i]+v[n]*h[i-n-1]+t,s[i--]=a%Ti|0,t=a/Ti|0;s[i]=(s[i]+t)%Ti|0}for(;!s[--o];)s.pop();return t?++r:s.shift(),e.d=s,e.e=Wd(s,r),At?dt(e,f.precision,f.rounding):e};Ne.toBinary=function(e,t){return c1(this,2,e,t)};Ne.toDecimalPlaces=Ne.toDP=function(e,t){var r=this,n=r.constructor;return r=new n(r),e===void 0?r:(Rn(e,0,No),t===void 0?t=n.rounding:Rn(t,0,8),dt(r,e+r.e+1,t))};Ne.toExponential=function(e,t){var r,n=this,i=n.constructor;return e===void 0?r=is(n,!0):(Rn(e,0,No),t===void 0?t=i.rounding:Rn(t,0,8),n=dt(new i(n),e+1,t),r=is(n,!0,e+1)),n.isNeg()&&!n.isZero()?"-"+r:r};Ne.toFixed=function(e,t){var r,n,i=this,s=i.constructor;return e===void 0?r=is(i):(Rn(e,0,No),t===void 0?t=s.rounding:Rn(t,0,8),n=dt(new s(i),e+i.e+1,t),r=is(n,!1,e+n.e+1)),i.isNeg()&&!i.isZero()?"-"+r:r};Ne.toFraction=function(e){var t,r,n,i,s,o,a,c,u,l,f,h,v=this,b=v.d,y=v.constructor;if(!b)return new y(v);if(u=r=new y(1),n=c=new y(0),t=new y(n),s=t.e=r5(b)-v.e-1,o=s%wt,t.d[0]=$r(10,o<0?wt+o:o),e==null)e=s>0?t:u;else{if(a=new y(e),!a.isInt()||a.lt(u))throw Error(Oo+a);e=a.gt(t)?s>0?t:u:a}for(At=!1,a=new y(Jr(b)),l=y.precision,y.precision=s=b.length*wt*2;f=Qt(a,t,0,1,1),i=r.plus(f.times(n)),i.cmp(e)!=1;)r=n,n=i,i=u,u=c.plus(f.times(i)),c=i,i=t,t=a.minus(f.times(i)),a=i;return i=Qt(e.minus(r),n,0,1,1),c=c.plus(i.times(u)),r=r.plus(i.times(n)),c.s=u.s=v.s,h=Qt(u,n,s,1).minus(v).abs().cmp(Qt(c,r,s,1).minus(v).abs())<1?[u,n]:[c,r],y.precision=l,At=!0,h};Ne.toHexadecimal=Ne.toHex=function(e,t){return c1(this,16,e,t)};Ne.toNearest=function(e,t){var r=this,n=r.constructor;if(r=new n(r),e==null){if(!r.d)return r;e=new n(1),t=n.rounding}else{if(e=new n(e),t===void 0?t=n.rounding:Rn(t,0,8),!r.d)return e.s?r:e;if(!e.d)return e.s&&(e.s=r.s),e}return e.d[0]?(At=!1,r=Qt(r,e,0,t,1).times(e),At=!0,dt(r)):(e.s=r.s,r=e),r};Ne.toNumber=function(){return+this};Ne.toOctal=function(e,t){return c1(this,8,e,t)};Ne.toPower=Ne.pow=function(e){var t,r,n,i,s,o,a=this,c=a.constructor,u=+(e=new c(e));if(!a.d||!e.d||!a.d[0]||!e.d[0])return new c($r(+a,u));if(a=new c(a),a.eq(1))return a;if(n=c.precision,s=c.rounding,e.eq(1))return dt(a,n,s);if(t=un(e.e/wt),t>=e.d.length-1&&(r=u<0?-u:u)<=QU)return i=n5(c,a,r,n),e.s<0?new c(1).div(i):dt(i,n,s);if(o=a.s,o<0){if(t<e.d.length-1)return new c(NaN);if(e.d[t]&1||(o=1),a.e==0&&a.d[0]==1&&a.d.length==1)return a.s=o,a}return r=$r(+a,u),t=r==0||!isFinite(r)?un(u*(Math.log("0."+Jr(a.d))/Math.LN10+a.e+1)):new c(r+"").e,t>c.maxE+1||t<c.minE-1?new c(t>0?o/0:0):(At=!1,c.rounding=a.s=1,r=Math.min(12,(t+"").length),i=G0(e.times(bo(a,n+r)),n),i.d&&(i=dt(i,n+5,1),Iu(i.d,n,s)&&(t=n+10,i=dt(G0(e.times(bo(a,t+r)),t),t+5,1),+Jr(i.d).slice(n+1,n+15)+1==1e14&&(i=dt(i,n+1,0)))),i.s=o,At=!0,c.rounding=s,dt(i,n,s))};Ne.toPrecision=function(e,t){var r,n=this,i=n.constructor;return e===void 0?r=is(n,n.e<=i.toExpNeg||n.e>=i.toExpPos):(Rn(e,1,No),t===void 0?t=i.rounding:Rn(t,0,8),n=dt(new i(n),e,t),r=is(n,e<=n.e||n.e<=i.toExpNeg,e)),n.isNeg()&&!n.isZero()?"-"+r:r};Ne.toSignificantDigits=Ne.toSD=function(e,t){var r=this,n=r.constructor;return e===void 0?(e=n.precision,t=n.rounding):(Rn(e,1,No),t===void 0?t=n.rounding:Rn(t,0,8)),dt(new n(r),e,t)};Ne.toString=function(){var e=this,t=e.constructor,r=is(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()&&!e.isZero()?"-"+r:r};Ne.truncated=Ne.trunc=function(){return dt(new this.constructor(this),this.e+1,1)};Ne.valueOf=Ne.toJSON=function(){var e=this,t=e.constructor,r=is(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()?"-"+r:r};function Jr(e){var t,r,n,i=e.length-1,s="",o=e[0];if(i>0){for(s+=o,t=1;t<i;t++)n=e[t]+"",r=wt-n.length,r&&(s+=uo(r)),s+=n;o=e[t],n=o+"",r=wt-n.length,r&&(s+=uo(r))}else if(o===0)return"0";for(;o%10===0;)o/=10;return s+o}function Rn(e,t,r){if(e!==~~e||e<t||e>r)throw Error(Oo+e)}function Iu(e,t,r,n){var i,s,o,a;for(s=e[0];s>=10;s/=10)--t;return--t<0?(t+=wt,i=0):(i=Math.ceil((t+1)/wt),t%=wt),s=$r(10,wt-t),a=e[i]%s|0,n==null?t<3?(t==0?a=a/100|0:t==1&&(a=a/10|0),o=r<4&&a==99999||r>3&&a==49999||a==5e4||a==0):o=(r<4&&a+1==s||r>3&&a+1==s/2)&&(e[i+1]/s/100|0)==$r(10,t-2)-1||(a==s/2||a==0)&&(e[i+1]/s/100|0)==0:t<4?(t==0?a=a/1e3|0:t==1?a=a/100|0:t==2&&(a=a/10|0),o=(n||r<4)&&a==9999||!n&&r>3&&a==4999):o=((n||r<4)&&a+1==s||!n&&r>3&&a+1==s/2)&&(e[i+1]/s/1e3|0)==$r(10,t-3)-1,o}function df(e,t,r){for(var n,i=[0],s,o=0,a=e.length;o<a;){for(s=i.length;s--;)i[s]*=t;for(i[0]+=W0.indexOf(e.charAt(o++)),n=0;n<i.length;n++)i[n]>r-1&&(i[n+1]===void 0&&(i[n+1]=0),i[n+1]+=i[n]/r|0,i[n]%=r)}return i.reverse()}function tF(e,t){var r,n,i;if(t.isZero())return t;n=t.d.length,n<32?(r=Math.ceil(n/3),i=(1/qd(4,r)).toString()):(r=16,i="2.3283064365386962890625e-10"),e.precision+=r,t=pc(e,1,t.times(i),new e(1));for(var s=r;s--;){var o=t.times(t);t=o.times(o).minus(o).times(8).plus(1)}return e.precision-=r,t}var Qt=function(){function e(n,i,s){var o,a=0,c=n.length;for(n=n.slice();c--;)o=n[c]*i+a,n[c]=o%s|0,a=o/s|0;return a&&n.unshift(a),n}function t(n,i,s,o){var a,c;if(s!=o)c=s>o?1:-1;else for(a=c=0;a<s;a++)if(n[a]!=i[a]){c=n[a]>i[a]?1:-1;break}return c}function r(n,i,s,o){for(var a=0;s--;)n[s]-=a,a=n[s]<i[s]?1:0,n[s]=a*o+n[s]-i[s];for(;!n[0]&&n.length>1;)n.shift()}return function(n,i,s,o,a,c){var u,l,f,h,v,b,y,S,C,O,I,U,D,H,z,ne,le,te,ce,V,L=n.constructor,p=n.s==i.s?1:-1,d=n.d,m=i.d;if(!d||!d[0]||!m||!m[0])return new L(!n.s||!i.s||(d?m&&d[0]==m[0]:!m)?NaN:d&&d[0]==0||!m?p*0:p/0);for(c?(v=1,l=n.e-i.e):(c=Ti,v=wt,l=un(n.e/v)-un(i.e/v)),ce=m.length,le=d.length,C=new L(p),O=C.d=[],f=0;m[f]==(d[f]||0);f++);if(m[f]>(d[f]||0)&&l--,s==null?(H=s=L.precision,o=L.rounding):a?H=s+(n.e-i.e)+1:H=s,H<0)O.push(1),b=!0;else{if(H=H/v+2|0,f=0,ce==1){for(h=0,m=m[0],H++;(f<le||h)&&H--;f++)z=h*c+(d[f]||0),O[f]=z/m|0,h=z%m|0;b=h||f<le}else{for(h=c/(m[0]+1)|0,h>1&&(m=e(m,h,c),d=e(d,h,c),ce=m.length,le=d.length),ne=ce,I=d.slice(0,ce),U=I.length;U<ce;)I[U++]=0;V=m.slice(),V.unshift(0),te=m[0],m[1]>=c/2&&++te;do h=0,u=t(m,I,ce,U),u<0?(D=I[0],ce!=U&&(D=D*c+(I[1]||0)),h=D/te|0,h>1?(h>=c&&(h=c-1),y=e(m,h,c),S=y.length,U=I.length,u=t(y,I,S,U),u==1&&(h--,r(y,ce<S?V:m,S,c))):(h==0&&(u=h=1),y=m.slice()),S=y.length,S<U&&y.unshift(0),r(I,y,U,c),u==-1&&(U=I.length,u=t(m,I,ce,U),u<1&&(h++,r(I,ce<U?V:m,U,c))),U=I.length):u===0&&(h++,I=[0]),O[f++]=h,u&&I[0]?I[U++]=d[ne]||0:(I=[d[ne]],U=1);while((ne++<le||I[0]!==void 0)&&H--);b=I[0]!==void 0}O[0]||O.shift()}if(v==1)C.e=l,JS=b;else{for(f=1,h=O[0];h>=10;h/=10)f++;C.e=f+l*v-1,dt(C,a?s+C.e+1:s,o,b)}return C}}();function dt(e,t,r,n){var i,s,o,a,c,u,l,f,h,v=e.constructor;e:if(t!=null){if(f=e.d,!f)return e;for(i=1,a=f[0];a>=10;a/=10)i++;if(s=t-i,s<0)s+=wt,o=t,l=f[h=0],c=l/$r(10,i-o-1)%10|0;else if(h=Math.ceil((s+1)/wt),a=f.length,h>=a)if(n){for(;a++<=h;)f.push(0);l=c=0,i=1,s%=wt,o=s-wt+1}else break e;else{for(l=a=f[h],i=1;a>=10;a/=10)i++;s%=wt,o=s-wt+i,c=o<0?0:l/$r(10,i-o-1)%10|0}if(n=n||t<0||f[h+1]!==void 0||(o<0?l:l%$r(10,i-o-1)),u=r<4?(c||n)&&(r==0||r==(e.s<0?3:2)):c>5||c==5&&(r==4||n||r==6&&(s>0?o>0?l/$r(10,i-o):0:f[h-1])%10&1||r==(e.s<0?8:7)),t<1||!f[0])return f.length=0,u?(t-=e.e+1,f[0]=$r(10,(wt-t%wt)%wt),e.e=-t||0):f[0]=e.e=0,e;if(s==0?(f.length=h,a=1,h--):(f.length=h+1,a=$r(10,wt-s),f[h]=o>0?(l/$r(10,i-o)%$r(10,o)|0)*a:0),u)for(;;)if(h==0){for(s=1,o=f[0];o>=10;o/=10)s++;for(o=f[0]+=a,a=1;o>=10;o/=10)a++;s!=a&&(e.e++,f[0]==Ti&&(f[0]=1));break}else{if(f[h]+=a,f[h]!=Ti)break;f[h--]=0,a=1}for(s=f.length;f[--s]===0;)f.pop()}return At&&(e.e>v.maxE?(e.d=null,e.e=NaN):e.e<v.minE&&(e.e=0,e.d=[0])),e}function is(e,t,r){if(!e.isFinite())return s5(e);var n,i=e.e,s=Jr(e.d),o=s.length;return t?(r&&(n=r-o)>0?s=s.charAt(0)+"."+s.slice(1)+uo(n):o>1&&(s=s.charAt(0)+"."+s.slice(1)),s=s+(e.e<0?"e":"e+")+e.e):i<0?(s="0."+uo(-i-1)+s,r&&(n=r-o)>0&&(s+=uo(n))):i>=o?(s+=uo(i+1-o),r&&(n=r-i-1)>0&&(s=s+"."+uo(n))):((n=i+1)<o&&(s=s.slice(0,n)+"."+s.slice(n)),r&&(n=r-o)>0&&(i+1===o&&(s+="."),s+=uo(n))),s}function Wd(e,t){var r=e[0];for(t*=wt;r>=10;r/=10)t++;return t}function ed(e,t,r){if(t>eF)throw At=!0,r&&(e.precision=r),Error(ZS);return dt(new e(Zf),t,1,!0)}function Yi(e,t,r){if(t>H0)throw Error(ZS);return dt(new e(Qf),t,r,!0)}function r5(e){var t=e.length-1,r=t*wt+1;if(t=e[t],t){for(;t%10==0;t/=10)r--;for(t=e[0];t>=10;t/=10)r++}return r}function uo(e){for(var t="";e--;)t+="0";return t}function n5(e,t,r,n){var i,s=new e(1),o=Math.ceil(n/wt+4);for(At=!1;;){if(r%2&&(s=s.times(t),qv(s.d,o)&&(i=!0)),r=un(r/2),r===0){r=s.d.length-1,i&&s.d[r]===0&&++s.d[r];break}t=t.times(t),qv(t.d,o)}return At=!0,s}function Wv(e){return e.d[e.d.length-1]&1}function i5(e,t,r){for(var n,i,s=new e(t[0]),o=0;++o<t.length;){if(i=new e(t[o]),!i.s){s=i;break}n=s.cmp(i),(n===r||n===0&&s.s===r)&&(s=i)}return s}function G0(e,t){var r,n,i,s,o,a,c,u=0,l=0,f=0,h=e.constructor,v=h.rounding,b=h.precision;if(!e.d||!e.d[0]||e.e>17)return new h(e.d?e.d[0]?e.s<0?0:1/0:1:e.s?e.s<0?0:e:0/0);for(t==null?(At=!1,c=b):c=t,a=new h(.03125);e.e>-2;)e=e.times(a),f+=5;for(n=Math.log($r(2,f))/Math.LN10*2+5|0,c+=n,r=s=o=new h(1),h.precision=c;;){if(s=dt(s.times(e),c,1),r=r.times(++l),a=o.plus(Qt(s,r,c,1)),Jr(a.d).slice(0,c)===Jr(o.d).slice(0,c)){for(i=f;i--;)o=dt(o.times(o),c,1);if(t==null)if(u<3&&Iu(o.d,c-n,v,u))h.precision=c+=10,r=s=a=new h(1),l=0,u++;else return dt(o,h.precision=b,v,At=!0);else return h.precision=b,o}o=a}}function bo(e,t){var r,n,i,s,o,a,c,u,l,f,h,v=1,b=10,y=e,S=y.d,C=y.constructor,O=C.rounding,I=C.precision;if(y.s<0||!S||!S[0]||!y.e&&S[0]==1&&S.length==1)return new C(S&&!S[0]?-1/0:y.s!=1?NaN:S?0:y);if(t==null?(At=!1,l=I):l=t,C.precision=l+=b,r=Jr(S),n=r.charAt(0),Math.abs(s=y.e)<15e14){for(;n<7&&n!=1||n==1&&r.charAt(1)>3;)y=y.times(e),r=Jr(y.d),n=r.charAt(0),v++;s=y.e,n>1?(y=new C("0."+r),s++):y=new C(n+"."+r.slice(1))}else return u=ed(C,l+2,I).times(s+""),y=bo(new C(n+"."+r.slice(1)),l-b).plus(u),C.precision=I,t==null?dt(y,I,O,At=!0):y;for(f=y,c=o=y=Qt(y.minus(1),y.plus(1),l,1),h=dt(y.times(y),l,1),i=3;;){if(o=dt(o.times(h),l,1),u=c.plus(Qt(o,new C(i),l,1)),Jr(u.d).slice(0,l)===Jr(c.d).slice(0,l))if(c=c.times(2),s!==0&&(c=c.plus(ed(C,l+2,I).times(s+""))),c=Qt(c,new C(v),l,1),t==null)if(Iu(c.d,l-b,O,a))C.precision=l+=b,u=o=y=Qt(f.minus(1),f.plus(1),l,1),h=dt(y.times(y),l,1),i=a=1;else return dt(c,C.precision=I,O,At=!0);else return C.precision=I,c;c=u,i+=2}}function s5(e){return String(e.s*e.s/0)}function hf(e,t){var r,n,i;for((r=t.indexOf("."))>-1&&(t=t.replace(".","")),(n=t.search(/e/i))>0?(r<0&&(r=n),r+=+t.slice(n+1),t=t.substring(0,n)):r<0&&(r=t.length),n=0;t.charCodeAt(n)===48;n++);for(i=t.length;t.charCodeAt(i-1)===48;--i);if(t=t.slice(n,i),t){if(i-=n,e.e=r=r-n-1,e.d=[],n=(r+1)%wt,r<0&&(n+=wt),n<i){for(n&&e.d.push(+t.slice(0,n)),i-=wt;n<i;)e.d.push(+t.slice(n,n+=wt));t=t.slice(n),n=wt-t.length}else n-=i;for(;n--;)t+="0";e.d.push(+t),At&&(e.e>e.constructor.maxE?(e.d=null,e.e=NaN):e.e<e.constructor.minE&&(e.e=0,e.d=[0]))}else e.e=0,e.d=[0];return e}function rF(e,t){var r,n,i,s,o,a,c,u,l;if(t.indexOf("_")>-1){if(t=t.replace(/(\d)_(?=\d)/g,"$1"),t5.test(t))return hf(e,t)}else if(t==="Infinity"||t==="NaN")return+t||(e.s=NaN),e.e=NaN,e.d=null,e;if(JU.test(t))r=16,t=t.toLowerCase();else if(XU.test(t))r=2;else if(ZU.test(t))r=8;else throw Error(Oo+t);for(s=t.search(/p/i),s>0?(c=+t.slice(s+1),t=t.substring(2,s)):t=t.slice(2),s=t.indexOf("."),o=s>=0,n=e.constructor,o&&(t=t.replace(".",""),a=t.length,s=a-s,i=n5(n,new n(r),s,s*2)),u=df(t,r,Ti),l=u.length-1,s=l;u[s]===0;--s)u.pop();return s<0?new n(e.s*0):(e.e=Wd(u,l),e.d=u,At=!1,o&&(e=Qt(e,i,a*4)),c&&(e=e.times(Math.abs(c)<54?$r(2,c):cl.pow(2,c))),At=!0,e)}function nF(e,t){var r,n=t.d.length;if(n<3)return t.isZero()?t:pc(e,2,t,t);r=1.4*Math.sqrt(n),r=r>16?16:r|0,t=t.times(1/qd(5,r)),t=pc(e,2,t,t);for(var i,s=new e(5),o=new e(16),a=new e(20);r--;)i=t.times(t),t=t.times(s.plus(i.times(o.times(i).minus(a))));return t}function pc(e,t,r,n,i){var s,o,a,c,u=e.precision,l=Math.ceil(u/wt);for(At=!1,c=r.times(r),a=new e(n);;){if(o=Qt(a.times(c),new e(t++*t++),u,1),a=i?n.plus(o):n.minus(o),n=Qt(o.times(c),new e(t++*t++),u,1),o=a.plus(n),o.d[l]!==void 0){for(s=l;o.d[s]===a.d[s]&&s--;);if(s==-1)break}s=a,a=n,n=o,o=s}return At=!0,o.d.length=l+1,o}function qd(e,t){for(var r=e;--t;)r*=e;return r}function o5(e,t){var r,n=t.s<0,i=Yi(e,e.precision,1),s=i.times(.5);if(t=t.abs(),t.lte(s))return ks=n?4:1,t;if(r=t.divToInt(i),r.isZero())ks=n?3:2;else{if(t=t.minus(r.times(i)),t.lte(s))return ks=Wv(r)?n?2:3:n?4:1,t;ks=Wv(r)?n?1:4:n?3:2}return t.minus(i).abs()}function c1(e,t,r,n){var i,s,o,a,c,u,l,f,h,v=e.constructor,b=r!==void 0;if(b?(Rn(r,1,No),n===void 0?n=v.rounding:Rn(n,0,8)):(r=v.precision,n=v.rounding),!e.isFinite())l=s5(e);else{for(l=is(e),o=l.indexOf("."),b?(i=2,t==16?r=r*4-3:t==8&&(r=r*3-2)):i=t,o>=0&&(l=l.replace(".",""),h=new v(1),h.e=l.length-o,h.d=df(is(h),10,i),h.e=h.d.length),f=df(l,10,i),s=c=f.length;f[--c]==0;)f.pop();if(!f[0])l=b?"0p+0":"0";else{if(o<0?s--:(e=new v(e),e.d=f,e.e=s,e=Qt(e,h,r,n,0,i),f=e.d,s=e.e,u=JS),o=f[r],a=i/2,u=u||f[r+1]!==void 0,u=n<4?(o!==void 0||u)&&(n===0||n===(e.s<0?3:2)):o>a||o===a&&(n===4||u||n===6&&f[r-1]&1||n===(e.s<0?8:7)),f.length=r,u)for(;++f[--r]>i-1;)f[r]=0,r||(++s,f.unshift(1));for(c=f.length;!f[c-1];--c);for(o=0,l="";o<c;o++)l+=W0.charAt(f[o]);if(b){if(c>1)if(t==16||t==8){for(o=t==16?4:3,--c;c%o;c++)l+="0";for(f=df(l,i,t),c=f.length;!f[c-1];--c);for(o=1,l="1.";o<c;o++)l+=W0.charAt(f[o])}else l=l.charAt(0)+"."+l.slice(1);l=l+(s<0?"p":"p+")+s}else if(s<0){for(;++s;)l="0"+l;l="0."+l}else if(++s>c)for(s-=c;s--;)l+="0";else s<c&&(l=l.slice(0,s)+"."+l.slice(s))}l=(t==16?"0x":t==2?"0b":t==8?"0o":"")+l}return e.s<0?"-"+l:l}function qv(e,t){if(e.length>t)return e.length=t,!0}function iF(e){return new this(e).abs()}function sF(e){return new this(e).acos()}function oF(e){return new this(e).acosh()}function aF(e,t){return new this(e).plus(t)}function cF(e){return new this(e).asin()}function uF(e){return new this(e).asinh()}function lF(e){return new this(e).atan()}function fF(e){return new this(e).atanh()}function dF(e,t){e=new this(e),t=new this(t);var r,n=this.precision,i=this.rounding,s=n+4;return!e.s||!t.s?r=new this(NaN):!e.d&&!t.d?(r=Yi(this,s,1).times(t.s>0?.25:.75),r.s=e.s):!t.d||e.isZero()?(r=t.s<0?Yi(this,n,i):new this(0),r.s=e.s):!e.d||t.isZero()?(r=Yi(this,s,1).times(.5),r.s=e.s):t.s<0?(this.precision=s,this.rounding=1,r=this.atan(Qt(e,t,s,1)),t=Yi(this,s,1),this.precision=n,this.rounding=i,r=e.s<0?r.minus(t):r.plus(t)):r=this.atan(Qt(e,t,s,1)),r}function hF(e){return new this(e).cbrt()}function pF(e){return dt(e=new this(e),e.e+1,2)}function mF(e,t,r){return new this(e).clamp(t,r)}function gF(e){if(!e||typeof e!="object")throw Error(zd+"Object expected");var t,r,n,i=e.defaults===!0,s=["precision",1,No,"rounding",0,8,"toExpNeg",-Qa,0,"toExpPos",0,Qa,"maxE",0,Qa,"minE",-Qa,0,"modulo",0,9];for(t=0;t<s.length;t+=3)if(r=s[t],i&&(this[r]=q0[r]),(n=e[r])!==void 0)if(un(n)===n&&n>=s[t+1]&&n<=s[t+2])this[r]=n;else throw Error(Oo+r+": "+n);if(r="crypto",i&&(this[r]=q0[r]),(n=e[r])!==void 0)if(n===!0||n===!1||n===0||n===1)if(n)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[r]=!0;else throw Error(QS);else this[r]=!1;else throw Error(Oo+r+": "+n);return this}function yF(e){return new this(e).cos()}function vF(e){return new this(e).cosh()}function a5(e){var t,r,n;function i(s){var o,a,c,u=this;if(!(u instanceof i))return new i(s);if(u.constructor=i,Hv(s)){u.s=s.s,At?!s.d||s.e>i.maxE?(u.e=NaN,u.d=null):s.e<i.minE?(u.e=0,u.d=[0]):(u.e=s.e,u.d=s.d.slice()):(u.e=s.e,u.d=s.d?s.d.slice():s.d);return}if(c=typeof s,c==="number"){if(s===0){u.s=1/s<0?-1:1,u.e=0,u.d=[0];return}if(s<0?(s=-s,u.s=-1):u.s=1,s===~~s&&s<1e7){for(o=0,a=s;a>=10;a/=10)o++;At?o>i.maxE?(u.e=NaN,u.d=null):o<i.minE?(u.e=0,u.d=[0]):(u.e=o,u.d=[s]):(u.e=o,u.d=[s]);return}if(s*0!==0){s||(u.s=NaN),u.e=NaN,u.d=null;return}return hf(u,s.toString())}if(c==="string")return(a=s.charCodeAt(0))===45?(s=s.slice(1),u.s=-1):(a===43&&(s=s.slice(1)),u.s=1),t5.test(s)?hf(u,s):rF(u,s);if(c==="bigint")return s<0?(s=-s,u.s=-1):u.s=1,hf(u,s.toString());throw Error(Oo+s)}if(i.prototype=Ne,i.ROUND_UP=0,i.ROUND_DOWN=1,i.ROUND_CEIL=2,i.ROUND_FLOOR=3,i.ROUND_HALF_UP=4,i.ROUND_HALF_DOWN=5,i.ROUND_HALF_EVEN=6,i.ROUND_HALF_CEIL=7,i.ROUND_HALF_FLOOR=8,i.EUCLID=9,i.config=i.set=gF,i.clone=a5,i.isDecimal=Hv,i.abs=iF,i.acos=sF,i.acosh=oF,i.add=aF,i.asin=cF,i.asinh=uF,i.atan=lF,i.atanh=fF,i.atan2=dF,i.cbrt=hF,i.ceil=pF,i.clamp=mF,i.cos=yF,i.cosh=vF,i.div=bF,i.exp=wF,i.floor=_F,i.hypot=xF,i.ln=SF,i.log=EF,i.log10=CF,i.log2=TF,i.max=AF,i.min=MF,i.mod=OF,i.mul=IF,i.pow=kF,i.random=jF,i.round=RF,i.sign=PF,i.sin=NF,i.sinh=$F,i.sqrt=DF,i.sub=LF,i.sum=BF,i.tan=UF,i.tanh=FF,i.trunc=VF,e===void 0&&(e={}),e&&e.defaults!==!0)for(n=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],t=0;t<n.length;)e.hasOwnProperty(r=n[t++])||(e[r]=this[r]);return i.config(e),i}function bF(e,t){return new this(e).div(t)}function wF(e){return new this(e).exp()}function _F(e){return dt(e=new this(e),e.e+1,3)}function xF(){var e,t,r=new this(0);for(At=!1,e=0;e<arguments.length;)if(t=new this(arguments[e++]),t.d)r.d&&(r=r.plus(t.times(t)));else{if(t.s)return At=!0,new this(1/0);r=t}return At=!0,r.sqrt()}function Hv(e){return e instanceof cl||e&&e.toStringTag===e5||!1}function SF(e){return new this(e).ln()}function EF(e,t){return new this(e).log(t)}function TF(e){return new this(e).log(2)}function CF(e){return new this(e).log(10)}function AF(){return i5(this,arguments,-1)}function MF(){return i5(this,arguments,1)}function OF(e,t){return new this(e).mod(t)}function IF(e,t){return new this(e).mul(t)}function kF(e,t){return new this(e).pow(t)}function jF(e){var t,r,n,i,s=0,o=new this(1),a=[];if(e===void 0?e=this.precision:Rn(e,1,No),n=Math.ceil(e/wt),this.crypto)if(crypto.getRandomValues)for(t=crypto.getRandomValues(new Uint32Array(n));s<n;)i=t[s],i>=429e7?t[s]=crypto.getRandomValues(new Uint32Array(1))[0]:a[s++]=i%1e7;else if(crypto.randomBytes){for(t=crypto.randomBytes(n*=4);s<n;)i=t[s]+(t[s+1]<<8)+(t[s+2]<<16)+((t[s+3]&127)<<24),i>=214e7?crypto.randomBytes(4).copy(t,s):(a.push(i%1e7),s+=4);s=n/4}else throw Error(QS);else for(;s<n;)a[s++]=Math.random()*1e7|0;for(n=a[--s],e%=wt,n&&e&&(i=$r(10,wt-e),a[s]=(n/i|0)*i);a[s]===0;s--)a.pop();if(s<0)r=0,a=[0];else{for(r=-1;a[0]===0;r-=wt)a.shift();for(n=1,i=a[0];i>=10;i/=10)n++;n<wt&&(r-=wt-n)}return o.e=r,o.d=a,o}function RF(e){return dt(e=new this(e),e.e+1,this.rounding)}function PF(e){return e=new this(e),e.d?e.d[0]?e.s:0*e.s:e.s||NaN}function NF(e){return new this(e).sin()}function $F(e){return new this(e).sinh()}function DF(e){return new this(e).sqrt()}function LF(e,t){return new this(e).sub(t)}function BF(){var e=0,t=arguments,r=new this(t[e]);for(At=!1;r.s&&++e<t.length;)r=r.plus(t[e]);return At=!0,dt(r,this.precision,this.rounding)}function UF(e){return new this(e).tan()}function FF(e){return new this(e).tanh()}function VF(e){return dt(e=new this(e),e.e+1,1)}Ne[Symbol.for("nodejs.util.inspect.custom")]=Ne.toString;Ne[Symbol.toStringTag]="Decimal";var cl=Ne.constructor=a5(q0);Zf=new cl(Zf);Qf=new cl(Qf);var c5=cl;function zF(e,t,r){return Number(u5(new c5(e.toString()),t,r).toFixed(0))}function Gv(e,t,r){const n=u5(new c5(e.toString()),t,r);return new YU.default(n.toFixed(0))}function u5(e,t,r){return t?e.mul(1-r):e.mul(1+r)}var Kv=class{constructor(e,t){if(e!==0)throw new Error("CetusRouter only supported on mainnet");this.globalConfig=e===0?"0xdaa46292632c3c4d8f31f23ea0f9b36a28ff3677e9684980e4438403a67a3d8f":"0x9774e359588ead122af1c7e7f64e14ade261cfeecdb5d0eb4a5b3b4c8ab8bd3e",this.partner=t??(e===0?"0x639b5e433da31739e800cd085f356e64cae222966d0f1b11bd9dc76b322ff58b":"0x1f5fa5c820f40d43fc47815ad06d95e40a1942ff72a732a92e8ef4aa8cde70a5")}swap(e,t,r,n){const i=this.prepareSwapData(t);this.executeSwapContract(e,i,r)}prepareSwapData(e){if(e.path.publishedAt==null)throw new Error("Cetus not set publishedAt");const t=e.path,[r,n]=t.direction?[t.from,t.target]:[t.target,t.from],i=e.isLastUseOfIntermediateToken?Kt.MAX_AMOUNT_IN:t.amountIn;return{coinAType:r,coinBType:n,direction:t.direction,amountIn:i,publishedAt:t.publishedAt,poolId:t.id}}executeSwapContract(e,t,r){const n=[r,e.object(this.globalConfig),e.object(t.poolId),e.object(this.partner),e.pure.bool(t.direction),e.pure.u64(t.amountIn),e.object(fr.SUI_CLOCK_OBJECT_ID)];e.moveCall({target:`${t.publishedAt}::cetus::swap`,typeArguments:[t.coinAType,t.coinBType],arguments:n})}flashSwapFixedOutput(e,t,r,n){const i=[n,e.object(this.globalConfig),e.object(t.id),e.object(this.partner),r,e.pure.bool(t.direction),e.pure.bool(!1),e.object(fr.SUI_CLOCK_OBJECT_ID)],[s,o]=t.direction?[t.from,t.target]:[t.target,t.from],[a,c]=e.moveCall({target:`${t.publishedAt}::cetus::flash_swap_fixed_output`,typeArguments:[s,o],arguments:i});return{flashReceipt:a,repayAmount:c}}repayFlashSwapFixedOutput(e,t,r,n){const i=[r,e.object(this.globalConfig),e.object(t.id),e.object(this.partner),e.pure.bool(t.direction),n],[s,o]=t.direction?[t.from,t.target]:[t.target,t.from];e.moveCall({target:`${t.publishedAt}::cetus::repay_flash_swap_fixed_output`,typeArguments:[s,o],arguments:i})}add(e,t,r,n){const i=[t,r];return e.moveCall({target:`${n}::cetus::add`,typeArguments:[],arguments:i})}sub(e,t,r,n){const i=[t,r];return e.moveCall({target:`${n}::cetus::sub`,typeArguments:[],arguments:i})}},WF=class{constructor(e){if(e!==0)throw new Error("Kriya V3 only supported on mainnet");this.version="0xf5145a7ac345ca8736cf8c76047d00d6d378f30e81be6f6eb557184d9de93c78"}swap(e,t,r,n){const i=this.prepareSwapData(t);this.executeSwapContract(e,i,r)}prepareSwapData(e){if(e.path.publishedAt==null)throw new Error("Kriya V3 not set publishedAt");const t=e.path,[r,n]=t.direction?[t.from,t.target]:[t.target,t.from],i=e.isLastUseOfIntermediateToken?Kt.MAX_AMOUNT_IN:t.amountIn;return{coinAType:r,coinBType:n,direction:t.direction,amountIn:i,publishedAt:t.publishedAt,poolId:t.id}}executeSwapContract(e,t,r){const n=[r,e.object(t.poolId),e.object(this.version),e.pure.bool(t.direction),e.pure.u64(t.amountIn),e.object(fr.SUI_CLOCK_OBJECT_ID)];e.moveCall({target:`${t.publishedAt}::kriya_clmm::swap`,typeArguments:[t.coinAType,t.coinBType],arguments:n})}},qF=class{constructor(e){if(e!==0)throw new Error("FlowX V3 only supported on mainnet");this.poolRegistry="0x27565d24a4cd51127ac90e4074a841bbe356cca7bf5759ddc14a975be1632abc",this.versioned="0x67624a1533b5aff5d0dfcf5e598684350efd38134d2d245f475524c03a64e656"}swap(e,t,r,n){const i=this.prepareSwapData(t);this.executeSwapContract(e,i,r)}prepareSwapData(e){if(e.path.publishedAt==null)throw new Error("FlowX V3 not set publishedAt");const t=e.path,[r,n]=t.direction?[t.from,t.target]:[t.target,t.from],i=e.isLastUseOfIntermediateToken?Kt.MAX_AMOUNT_IN:t.amountIn,s=t.feeRate*1e6;return{coinAType:r,coinBType:n,direction:t.direction,amountIn:i,publishedAt:t.publishedAt,poolId:t.id,feeRate:s}}executeSwapContract(e,t,r){const n=[r,e.object(this.poolRegistry),e.object(this.versioned),e.pure.u64(t.feeRate),e.pure.u64(t.amountIn),e.pure.bool(t.direction),e.object(fr.SUI_CLOCK_OBJECT_ID)];e.moveCall({target:`${t.publishedAt}::flowx_clmm::swap`,typeArguments:[t.coinAType,t.coinBType],arguments:n})}},HF=class{constructor(e){if(e!==0)throw new Error("Turbos only supported on mainnet");this.versioned="0xf1cf0e81048df168ebeb1b8030fad24b3e0b53ae827c25053fff0779c1445b6f"}swap(e,t,r,n){const i=this.prepareSwapData(t);this.executeSwapContract(e,i,r)}prepareSwapData(e){if(e.path.publishedAt==null)throw new Error("Turbos not set publishedAt");const t=e.path,[r,n]=t.direction?[t.from,t.target]:[t.target,t.from],i=e.isLastUseOfIntermediateToken?Kt.MAX_AMOUNT_IN:t.amountIn;if(t.extendedDetails==null)throw new Error("Extended details not supported");if(t.extendedDetails.turbos_fee_type==null)throw new Error("Turbos fee type not supported");const s=t.extendedDetails.turbos_fee_type;return{coinAType:r,coinBType:n,feeType:s,direction:t.direction,amountIn:i,publishedAt:t.publishedAt,poolId:t.id}}executeSwapContract(e,t,r){const n=[r,e.object(t.poolId),e.object(this.versioned),e.pure.bool(t.direction),e.pure.u64(t.amountIn),e.object(fr.SUI_CLOCK_OBJECT_ID)];e.moveCall({target:`${t.publishedAt}::turbos::swap`,typeArguments:[t.coinAType,t.coinBType,t.feeType],arguments:n})}},GF=class{constructor(e){if(e!==0)throw new Error("Bluefin only supported on mainnet");this.globalConfig="0x03db251ba509a8d5d8777b6338836082335d93eecbdd09a11e190a1cff51c352"}swap(e,t,r,n){const i=this.prepareSwapData(t);this.executeSwapContract(e,i,r)}prepareSwapData(e){if(e.path.publishedAt==null)throw new Error("Bluefin not set publishedAt");const t=e.path,[r,n]=t.direction?[t.from,t.target]:[t.target,t.from],i=e.isLastUseOfIntermediateToken?Kt.MAX_AMOUNT_IN:t.amountIn;return{coinAType:r,coinBType:n,direction:t.direction,amountIn:i,publishedAt:t.publishedAt,poolId:t.id}}executeSwapContract(e,t,r){const n=[r,e.object(this.globalConfig),e.object(t.poolId),e.pure.bool(t.direction),e.pure.u64(t.amountIn),e.object(fr.SUI_CLOCK_OBJECT_ID)];e.moveCall({target:`${t.publishedAt}::bluefin::swap`,typeArguments:[t.coinAType,t.coinBType],arguments:n})}},KF=class{constructor(e){if(e!==0)throw new Error("Momentum only supported on mainnet");this.version="0x2375a0b1ec12010aaea3b2545acfa2ad34cfbba03ce4b59f4c39e1e25eed1b2a"}swap(e,t,r,n){const i=this.prepareSwapData(t);this.executeSwapContract(e,i,r)}prepareSwapData(e){const t=e.path;if(e.path.publishedAt==null)throw new Error("Momentum not set publishedAt");const[r,n]=t.direction?[t.from,t.target]:[t.target,t.from],i=e.isLastUseOfIntermediateToken?Kt.MAX_AMOUNT_IN:t.amountIn;return{coinAType:r,coinBType:n,direction:t.direction,amountIn:i,publishedAt:t.publishedAt,poolId:t.id}}executeSwapContract(e,t,r){const n=[r,e.object(t.poolId),e.pure.bool(t.direction),e.pure.u64(t.amountIn),e.object(this.version),e.object(fr.SUI_CLOCK_OBJECT_ID)];e.moveCall({target:`${t.publishedAt}::momentum::swap`,typeArguments:[t.coinAType,t.coinBType],arguments:n})}},YF=class{constructor(e){if(e!==0)throw new Error("Magma only supported on mainnet");this.globalConfig="0x4c4e1402401f72c7d8533d0ed8d5f8949da363c7a3319ccef261ffe153d32f8a"}swap(e,t,r,n){const i=this.prepareSwapData(t);this.executeSwapContract(e,i,r)}prepareSwapData(e){const t=e.path;if(e.path.publishedAt==null)throw new Error("Magma not set publishedAt");const[r,n]=t.direction?[t.from,t.target]:[t.target,t.from],i=e.isLastUseOfIntermediateToken?Kt.MAX_AMOUNT_IN:t.amountIn;return{coinAType:r,coinBType:n,direction:t.direction,amountIn:i,publishedAt:t.publishedAt,poolId:t.id}}executeSwapContract(e,t,r){const n=[r,e.object(this.globalConfig),e.object(t.poolId),e.pure.bool(t.direction),e.pure.u64(t.amountIn),e.object(fr.SUI_CLOCK_OBJECT_ID)];e.moveCall({target:`${t.publishedAt}::magma::swap`,typeArguments:[t.coinAType,t.coinBType],arguments:n})}},XF=class{constructor(e){if(e!==0)throw new Error("Kriya V2 only supported on mainnet")}swap(e,t,r,n){const i=this.prepareSwapData(t);this.executeSwapContract(e,i,r)}prepareSwapData(e){const t=e.path;if(e.path.publishedAt==null)throw new Error("Kriya V2 not set publishedAt");const[r,n]=t.direction?[t.from,t.target]:[t.target,t.from],i=e.isLastUseOfIntermediateToken?Kt.MAX_AMOUNT_IN:t.amountIn;return{coinAType:r,coinBType:n,direction:t.direction,amountIn:i,publishedAt:t.publishedAt,poolId:t.id}}executeSwapContract(e,t,r){const n=[r,e.object(t.poolId),e.pure.bool(t.direction),e.pure.u64(t.amountIn)];e.moveCall({target:`${t.publishedAt}::kriya_amm::swap`,typeArguments:[t.coinAType,t.coinBType],arguments:n})}},JF=class{constructor(e){if(e!==0)throw new Error("FlowX V2 only supported on mainnet");this.container="0xb65dcbf63fd3ad5d0ebfbf334780dc9f785eff38a4459e37ab08fa79576ee511"}swap(e,t,r,n){const i=this.prepareSwapData(t);this.executeSwapContract(e,i,r)}prepareSwapData(e){const t=e.path;if(e.path.publishedAt==null)throw new Error("FlowX V2 not set publishedAt");const[r,n]=t.direction?[t.from,t.target]:[t.target,t.from],i=e.isLastUseOfIntermediateToken?Kt.MAX_AMOUNT_IN:t.amountIn;return{coinAType:r,coinBType:n,direction:t.direction,amountIn:i,publishedAt:t.publishedAt,poolId:t.id}}executeSwapContract(e,t,r){const n=[r,e.object(this.container),e.pure.bool(t.direction),e.pure.u64(t.amountIn)];e.moveCall({target:`${t.publishedAt}::flowx_amm::swap`,typeArguments:[t.coinAType,t.coinBType],arguments:n})}},ZF=class{constructor(e){if(e!==0)throw new Error("BlueMove only supported on mainnet");this.dexInfo="0x3f2d9f724f4a1ce5e71676448dc452be9a6243dac9c5b975a588c8c867066e92"}swap(e,t,r,n){const i=this.prepareSwapData(t);this.executeSwapContract(e,i,r)}prepareSwapData(e){const t=e.path;if(e.path.publishedAt==null)throw new Error("BlueMove not set publishedAt");const[r,n]=t.direction?[t.from,t.target]:[t.target,t.from],i=e.isLastUseOfIntermediateToken?Kt.MAX_AMOUNT_IN:t.amountIn;return{coinAType:r,coinBType:n,direction:t.direction,amountIn:i,publishedAt:t.publishedAt,poolId:t.id}}executeSwapContract(e,t,r){const n=[r,e.object(this.dexInfo),e.pure.bool(t.direction),e.pure.u64(t.amountIn)];e.moveCall({target:`${t.publishedAt}::bluemove::swap`,typeArguments:[t.coinAType,t.coinBType],arguments:n})}},QF=class{constructor(e){if(e!==0)throw new Error("DeepBook V3 only supported on mainnet");this.env=e,this.globalConfig="0x699d455ab8c5e02075b4345ea1f91be55bf46064ae6026cc2528e701ce3ac135"}swap(e,t,r,n){const i=this.prepareSwapData(t);this.executeSwapContract(e,i,r,n)}prepareSwapData(e){if(e.path.publishedAt==null)throw new Error("DeepBook V3 not set publishedAt");const t=e.path,[r,n]=t.direction?[t.from,t.target]:[t.target,t.from],i=e.isLastUseOfIntermediateToken?Kt.MAX_AMOUNT_IN:t.amountIn;return{coinAType:r,coinBType:n,direction:t.direction,amountIn:i,publishedAt:t.publishedAt,poolId:t.id}}executeSwapContract(e,t,r,n){const i=(n==null?void 0:n.deepbookv3DeepFee)||e.moveCall({target:"0x2::coin::zero",typeArguments:[this.getDeepFeeType()]}),s=[r,e.object(this.globalConfig),e.object(t.poolId),e.pure.u64(t.amountIn),e.pure.bool(t.direction),i,e.object(fr.SUI_CLOCK_OBJECT_ID)];e.moveCall({target:`${t.publishedAt}::deepbookv3::swap`,typeArguments:[t.coinAType,t.coinBType],arguments:s})}getDeepFeeType(){return this.env===0?Jf.Mainnet:Jf.Testnet}},eV=class{constructor(e){if(e!==0)throw new Error("Aftermath only supported on mainnet");this.poolRegistry="0xfcc774493db2c45c79f688f88d28023a3e7d98e4ee9f48bbf5c7990f651577ae",this.protocolFeeVault="0xf194d9b1bcad972e45a7dd67dd49b3ee1e3357a00a50850c52cd51bb450e13b4",this.treasury="0x28e499dff5e864a2eafe476269a4f5035f1c16f338da7be18b103499abf271ce",this.insuranceFund="0xf0c40d67b078000e18032334c3325c47b9ec9f3d9ae4128be820d54663d14e3b",this.referralVault="0x35d35b0e5b177593d8c3a801462485572fc30861e6ce96a55af6dc4730709278"}swap(e,t,r,n){const i=this.prepareSwapData(t);this.executeSwapContract(e,i,r)}prepareSwapData(e){var t,r;if(e.path.publishedAt==null)throw new Error("Aftermath not set publishedAt");const n=e.path,[i,s]=n.direction?[n.from,n.target]:[n.target,n.from],o=e.isLastUseOfIntermediateToken?"18446744073709551615":n.amountIn;return{coinAType:i,coinBType:s,feeType:((t=n.extendedDetails)==null?void 0:t.aftermath_lp_supply_type)||((r=n.extendedDetails)==null?void 0:r.aftermath_lp_supply_type)||"0x2::sui::SUI",direction:n.direction,amountIn:o,expectAmountOut:n.amountOut,publishedAt:n.publishedAt,poolId:n.id}}executeSwapContract(e,t,r){const n=[r,e.object(t.poolId),e.object(this.poolRegistry),e.object(this.protocolFeeVault),e.object(this.treasury),e.object(this.insuranceFund),e.object(this.referralVault),e.pure.bool(t.direction),e.pure.u64(t.amountIn),e.pure.u64(t.expectAmountOut)];e.moveCall({target:`${t.publishedAt}::aftermath::swap`,typeArguments:[t.coinAType,t.coinBType,t.feeType],arguments:n})}},tV=class{constructor(e){if(e!==0)throw new Error("Steamm CPMM only supported on mainnet")}swap(e,t,r,n){const i=this.prepareSwapData(t);this.executeSwapContract(e,i,r)}validateExtendedDetails(e){const t=["steamm_bank_a","steamm_bank_b","steamm_lending_market","steamm_lending_market_type","steamm_btoken_a_type","steamm_btoken_b_type","steamm_lp_token_type"];for(const r of t)if(e[r]==null)throw new Error(`Steamm CPMM ${r} not supported`)}prepareSwapData(e){const t=e.path;if(e.path.publishedAt==null)throw new Error("Steamm CPMM not set publishedAt");if(!t.extendedDetails)throw new Error("Extended details not found for Steamm CPMM");this.validateExtendedDetails(t.extendedDetails);const{direction:r,from:n,target:i}=t,[s,o]=r?[n,i]:[i,n],a=e.isLastUseOfIntermediateToken?Kt.MAX_AMOUNT_IN:t.amountIn;return{coinAType:s,coinBType:o,direction:r,amountIn:a,publishedAt:t.publishedAt,poolId:t.id,extendedDetails:t.extendedDetails}}executeSwapContract(e,t,r){const n=[r,e.object(t.poolId),e.object(t.extendedDetails.steamm_bank_a),e.object(t.extendedDetails.steamm_bank_b),e.object(t.extendedDetails.steamm_lending_market),e.pure.bool(t.direction),e.pure.u64(t.amountIn),e.object(fr.SUI_CLOCK_OBJECT_ID)];e.moveCall({target:`${t.publishedAt}::steamm_cpmm::swap`,typeArguments:[t.extendedDetails.steamm_lending_market_type,t.coinAType,t.coinBType,t.extendedDetails.steamm_btoken_a_type,t.extendedDetails.steamm_btoken_b_type,t.extendedDetails.steamm_lp_token_type],arguments:n})}},rV=class{constructor(e){if(e!==0)throw new Error("Scallop only supported on mainnet");this.version="0x07871c4b3c847a0f674510d4978d5cf6f960452795e8ff6f189fd2088a3f6ac7",this.marketData="0xa757975255146dc9686aa823b7838b507f315d704f428cbadad2f4ea061939d9"}swap(e,t,r,n){const i=this.prepareSwapData(t);this.executeSwapContract(e,i,r)}prepareSwapData(e){const t=e.path;if(e.path.publishedAt==null)throw new Error("Scallop not set publishedAt");const[r,n]=t.direction?[t.from,t.target]:[t.from,t.target],i=e.isLastUseOfIntermediateToken?Kt.MAX_AMOUNT_IN:t.amountIn;if(t.extendedDetails==null)throw new Error("Extended details not supported");const s=t.extendedDetails.scallopScoinTreasury||t.extendedDetails.scallop_scoin_treasury;if(s==null)throw new Error("Scallop scoin treasury not supported");return{coinAType:r,coinBType:n,direction:t.direction,amountIn:i,publishedAt:t.publishedAt,poolId:t.id,scallopScoinTreasury:s}}executeSwapContract(e,t,r){const n=[r,e.object(this.version),e.object(this.marketData),e.object(t.scallopScoinTreasury),e.pure.u64(t.amountIn),e.object(fr.SUI_CLOCK_OBJECT_ID)],i=t.direction?"swap_a2b":"swap_b2a";e.moveCall({target:`${t.publishedAt}::scallop::${i}`,typeArguments:[t.coinAType,t.coinBType],arguments:n})}},Yv=class{constructor(e){if(e!==0)throw new Error("Springsui only supported on mainnet")}swap(e,t,r,n){const i=this.prepareSwapData(t);this.executeSwapContract(e,i,r)}prepareSwapData(e){const t=e.path;if(e.path.publishedAt==null)throw new Error("Springsui not set publishedAt");const r=t.direction?t.target:t.from,n=e.isLastUseOfIntermediateToken?Kt.MAX_AMOUNT_IN:t.amountIn;return{springSUICoinType:r,direction:t.direction,amountIn:n,publishedAt:t.publishedAt,poolId:t.id}}executeSwapContract(e,t,r){const n=[r,e.object(t.poolId),e.object("0x5"),e.pure.u64(t.amountIn),e.pure.bool(t.direction)];e.moveCall({target:`${t.publishedAt}::springsui::swap`,typeArguments:[t.springSUICoinType],arguments:n})}},nV=class{constructor(e,t){if(e!==0)throw new Error("Haedal PMM only supported on mainnet");this.pythPriceIDs=t}swap(e,t,r,n){const i=t.path;if(!i.extendedDetails)throw new Error("Extended details not found for Haedal PMM");this.validateExtendedDetails(i.extendedDetails);const s=this.prepareSwapData(t);this.executeSwapContract(e,s,r)}validateExtendedDetails(e){if(!e.haedal_pmm_base_price_seed)throw new Error("Haedal PMM base price seed not supported");if(!e.haedal_pmm_quote_price_seed)throw new Error("Haedal PMM quote price seed not supported")}prepareSwapData(e){const t=e.path;if(e.path.publishedAt==null)throw new Error("Haedal PMM not set publishedAt");const r=t.extendedDetails,[n,i]=t.direction?[t.from,t.target]:[t.target,t.from],s=e.isLastUseOfIntermediateToken?Kt.MAX_AMOUNT_IN:t.amountIn,o=r.haedal_pmm_base_price_seed,a=r.haedal_pmm_quote_price_seed,c=this.pythPriceIDs.get(o),u=this.pythPriceIDs.get(a);if(!c||!u)throw new Error("Haedal HMM requires oracle price IDs for both coins");return{coinAType:n,coinBType:i,basePriceId:c,quotePriceId:u,a2b:t.direction,amountIn:s,publishedAt:t.publishedAt,poolId:t.id}}executeSwapContract(e,t,r){const n=[r,e.object(t.poolId),e.object(t.basePriceId),e.object(t.quotePriceId),e.pure.u64(t.amountIn),e.pure.bool(t.a2b),e.object(fr.SUI_CLOCK_OBJECT_ID)];e.moveCall({target:`${t.publishedAt}::haedal_hmm::swap`,typeArguments:[t.coinAType,t.coinBType],arguments:n})}},iV=class{constructor(e,t){if(e===1)throw new Error("Obric is not supported on testnet");this.pythStateObjectId="0x1f9310238ee9298fb703c3419030b35b22bb1cc37113e3bb5007c99aec79e5b8",this.pythPriceIDs=t}swap(e,t,r,n){const i=this.prepareSwapData(t);this.executeSwapContract(e,i,r)}prepareSwapData(e){const t=e.path;if(e.path.publishedAt==null)throw new Error("Obric not set publishedAt");if(!t.extendedDetails)throw new Error("Extended details not supported in obric");const{direction:r,from:n,target:i}=t,[s,o]=r?[n,i]:[i,n],a=e.isLastUseOfIntermediateToken?Kt.MAX_AMOUNT_IN:t.amountIn;let c,u;if(t.extendedDetails.obric_coin_a_price_seed&&t.extendedDetails.obric_coin_b_price_seed)c=this.pythPriceIDs.get(t.extendedDetails.obric_coin_a_price_seed),u=this.pythPriceIDs.get(t.extendedDetails.obric_coin_b_price_seed);else if(t.extendedDetails.obric_coin_a_price_id&&t.extendedDetails.obric_coin_b_price_id)c=t.extendedDetails.obric_coin_a_price_id,u=t.extendedDetails.obric_coin_b_price_id;else throw new Error("Base price id or quote price id not supported");return{coinAType:s,coinBType:o,coinAPriceInfoObjectId:c,coinBPriceInfoObjectId:u,direction:r,amountIn:a,publishedAt:t.publishedAt,poolId:t.id,extendedDetails:t.extendedDetails}}executeSwapContract(e,t,r){if(!t.coinAPriceInfoObjectId||!t.coinBPriceInfoObjectId)throw new Error("Base price info object id or quote price info object id not found");const n=[r,e.object(t.poolId),e.pure.u64(t.amountIn),e.pure.bool(t.direction),e.object(this.pythStateObjectId),e.object(t.coinAPriceInfoObjectId),e.object(t.coinBPriceInfoObjectId),e.object(fr.SUI_CLOCK_OBJECT_ID)];e.moveCall({target:`${t.publishedAt}::obric::swap`,typeArguments:[t.coinAType,t.coinBType],arguments:n})}},sV=class{constructor(e,t){if(e!==0)throw new Error("Sevenk only supported on mainnet");this.oraclePublishedAt="0x8c36ea167c5e6da8c3d60b4fc897416105dcb986471bd81cfbfd38720a4487c0",this.pythPriceIDs=t}swap(e,t,r,n){const i=this.prepareSwapData(t);this.executeSwapContract(e,i,r,n)}prepareSwapData(e){const t=e.path;if(e.path.publishedAt==null)throw new Error("Sevenk not set publishedAt");if(!t.extendedDetails)throw new Error("Extended details not found for Sevenk");const{direction:r,from:n,target:i}=t,[s,o,a]=r?["swap_a2b",n,i]:["swap_b2a",i,n],c=e.isLastUseOfIntermediateToken?Kt.MAX_AMOUNT_IN:t.amountIn,u=t.extendedDetails;if(!u.sevenk_coin_a_price_seed||!u.sevenk_coin_b_price_seed||!u.sevenk_oracle_config_a||!u.sevenk_oracle_config_b||!u.sevenk_lp_cap_type)throw new Error("Required Sevenk extended details not found");const l=u.sevenk_coin_a_price_seed,f=u.sevenk_coin_b_price_seed,h=u.sevenk_oracle_config_a,v=u.sevenk_oracle_config_b,b=u.sevenk_lp_cap_type,y=this.pythPriceIDs.get(l),S=this.pythPriceIDs.get(f);if(!y||!S)throw new Error("Sevenk price info object IDs not found");return{func:s,coinAType:o,coinBType:a,coinAPriceId:y,coinBPriceId:S,coinAOracleId:h,coinBOracleId:v,lpCapType:b,direction:r,amountIn:c,publishedAt:t.publishedAt,poolId:t.id,extendedDetails:t.extendedDetails}}executeSwapContract(e,t,r,n){const i=e.moveCall({target:`${this.oraclePublishedAt}::oracle::new_holder`,typeArguments:[],arguments:[]});e.moveCall({target:`${this.oraclePublishedAt}::pyth::get_price`,typeArguments:[],arguments:[e.object(t.coinAOracleId),i,e.object(t.coinAPriceId),e.object(fr.SUI_CLOCK_OBJECT_ID)]}),e.moveCall({target:`${this.oraclePublishedAt}::pyth::get_price`,typeArguments:[],arguments:[e.object(t.coinBOracleId),i,e.object(t.coinBPriceId),e.object(fr.SUI_CLOCK_OBJECT_ID)]});const s=[r,e.object(t.poolId),i,e.pure.u64(t.amountIn)];e.moveCall({target:`${t.publishedAt}::sevenk::${t.func}`,typeArguments:[t.coinAType,t.coinBType,t.lpCapType],arguments:s})}},oV=class{constructor(e,t){if(e!==0)throw new Error("Steamm OMM only supported on mainnet");this.pythPriceIDs=t,this.oraclePackageId="0xe84b649199654d18c38e727212f5d8dacfc3cf78d60d0a7fc85fd589f280eb2b"}swap(e,t,r,n){const i=t.path;if(!i.extendedDetails)throw new Error("Extended details not found for Steamm OMM");this.validateExtendedDetails(i.extendedDetails);const s=this.prepareSwapData(t);this.executeSwapContract(e,s,r)}validateExtendedDetails(e){const t=["steamm_bank_a","steamm_bank_b","steamm_lending_market","steamm_lending_market_type","steamm_btoken_a_type","steamm_btoken_b_type","steamm_lp_token_type","steammOracleRegistryId","steammOracleIndexA","steammOracleIndexB","steammOraclePythPriceSeedA","steammOraclePythPriceSeedB"];for(const r of t)if(e[r]==null)throw new Error(`Steamm ${r} not supported`)}prepareSwapData(e){const t=e.path;if(e.path.publishedAt==null)throw new Error("Steamm OMM not set publishedAt");const r=t.extendedDetails,{direction:n,from:i,target:s}=t,[o,a,c]=n?["swap_a2b_v2",i,s]:["swap_b2a_v2",s,i],u=e.isLastUseOfIntermediateToken?Kt.MAX_AMOUNT_IN:t.amountIn,l=r.steamm_oracle_pyth_price_seed_a,f=r.steamm_oracle_pyth_price_seed_b;if(!l||!f)throw new Error("Steamm oracle price seeds not found");const h=this.pythPriceIDs.get(l),v=this.pythPriceIDs.get(f);if(!h||!v)throw new Error("Base price info object id or quote price info object id not found");return{func:o,coinAType:a,coinBType:c,direction:n,amountIn:u,publishedAt:t.publishedAt,poolId:t.id,extendedDetails:r,priceInfoObjectIdA:h,priceInfoObjectIdB:v}}executeSwapContract(e,t,r){const n=t.extendedDetails,i=e.moveCall({target:`${this.oraclePackageId}::oracles::get_pyth_price`,typeArguments:[],arguments:[e.object(n.steammOracleRegistryId),e.object(t.priceInfoObjectIdA),e.pure.u64(n.steammOracleIndexA),e.object(fr.SUI_CLOCK_OBJECT_ID)]}),s=e.moveCall({target:`${this.oraclePackageId}::oracles::get_pyth_price`,typeArguments:[],arguments:[e.object(n.steammOracleRegistryId),e.object(t.priceInfoObjectIdB),e.pure.u64(n.steammOracleIndexB),e.object(fr.SUI_CLOCK_OBJECT_ID)]}),o=[r,e.object(t.poolId),e.object(n.steamm_bank_a),e.object(n.steamm_bank_b),e.object(n.steamm_lending_market),i,s,e.pure.u64(t.amountIn),e.object(fr.SUI_CLOCK_OBJECT_ID)];e.moveCall({target:`${t.publishedAt}::steamm_omm::${t.func}`,typeArguments:[n.steamm_lending_market_type,t.coinAType,t.coinBType,n.steamm_btoken_a_type,n.steamm_btoken_b_type,n.steamm_lp_token_type],arguments:o})}},aV=class{constructor(e,t){if(e!==0)throw new Error("Steamm OMM V2 only supported on mainnet");this.pythPriceIDs=t,this.oraclePackageId="0xe84b649199654d18c38e727212f5d8dacfc3cf78d60d0a7fc85fd589f280eb2b"}swap(e,t,r,n){const i=t.path;if(!i.extendedDetails)throw new Error("Extended details not found for Steamm OMM V2");this.validateExtendedDetails(i.extendedDetails);const s=this.prepareSwapData(t);this.executeSwapContract(e,s,r)}validateExtendedDetails(e){const t=["steamm_bank_a","steamm_bank_b","steamm_lending_market","steamm_lending_market_type","steamm_btoken_a_type","steamm_btoken_b_type","steamm_lp_token_type","steamm_oracle_registry_id","steamm_oracle_index_a","steamm_oracle_index_b","steamm_oracle_pyth_price_seed_a","steamm_oracle_pyth_price_seed_b"];for(const r of t)if(e[r]==null)throw new Error(`Steamm OMM V2 ${r} not supported`)}prepareSwapData(e){const t=e.path;if(e.path.publishedAt==null)throw new Error("Steamm OMM V2 not set publishedAt");const r=t.extendedDetails,{direction:n,from:i,target:s}=t,[o,a]=n?[i,s]:[s,i],c=e.isLastUseOfIntermediateToken?Kt.MAX_AMOUNT_IN:t.amountIn,u=r.steamm_oracle_pyth_price_seed_a,l=r.steamm_oracle_pyth_price_seed_b;if(!u||!l)throw new Error("Steamm OMM V2 oracle price seeds not found");const f=this.pythPriceIDs.get(u),h=this.pythPriceIDs.get(l);if(!f||!h)throw new Error("Base price info object id or quote price info object id not found");return{coinAType:o,coinBType:a,direction:n,amountIn:c,publishedAt:t.publishedAt,poolId:t.id,extendedDetails:r,priceInfoObjectIdA:f,priceInfoObjectIdB:h}}executeSwapContract(e,t,r){const n=t.extendedDetails,i=e.moveCall({target:`${this.oraclePackageId}::oracles::get_pyth_price`,typeArguments:[],arguments:[e.object(n.steamm_oracle_registry_id),e.object(t.priceInfoObjectIdA),e.pure.u64(n.steamm_oracle_index_a),e.object(fr.SUI_CLOCK_OBJECT_ID)]}),s=e.moveCall({target:`${this.oraclePackageId}::oracles::get_pyth_price`,typeArguments:[],arguments:[e.object(n.steamm_oracle_registry_id),e.object(t.priceInfoObjectIdB),e.pure.u64(n.steamm_oracle_index_b),e.object(fr.SUI_CLOCK_OBJECT_ID)]}),o=[r,e.object(t.poolId),e.object(n.steamm_bank_a),e.object(n.steamm_bank_b),e.object(n.steamm_lending_market),i,s,e.pure.bool(t.direction),e.pure.u64(t.amountIn),e.object(fr.SUI_CLOCK_OBJECT_ID)];e.moveCall({target:`${t.publishedAt}::steamm_omm_v2::swap`,typeArguments:[n.steamm_lending_market_type,t.coinAType,t.coinBType,n.steamm_btoken_a_type,n.steamm_btoken_b_type,n.steamm_lp_token_type],arguments:o})}},cV="0x790f258062909e3a0ffc78b3c53ac2f62d7084c3bab95644bdeb05add7250001::super_sui::SUPER_SUI",uV="0xe44df51c0b21a27ab915fa1fe2ca610cd3eaa6d9666fe5e62b988bf7f0bd8722::musd::MUSD",lV="0xccd628c2334c5ed33e6c47d6c21bb664f8b6307b2ac32c2462a61f69a31ebcee::meth::METH",fV=class{constructor(e,t){if(e!==0)throw new Error("Metastable only supported on mainnet");this.versionID="0x4696559327b35ff2ab26904e7426a1646312e9c836d5c6cff6709a5ccc30915c",this.pythPriceIDs=t}swap(e,t,r,n){const i=this.prepareSwapData(t),s=this.createDepositCap(e,i);this.executeSwapContract(e,i,r,s)}prepareSwapData(e){const t=e.path;if(e.path.publishedAt==null)throw new Error("Metastable not set publishedAt");if(!t.extendedDetails)throw new Error("Extended details not found for Metastable");const{direction:r,from:n,target:i}=t,[s,o]=r?[n,i]:[i,n],[a,c]=r?["swap_a2b","create_deposit_cap"]:["swap_b2a","create_withdraw_cap"];if(!t.extendedDetails.metastable_create_cap_pkg_id||!t.extendedDetails.metastable_create_cap_module||!t.extendedDetails.metastable_whitelisted_app_id)throw new Error("CreateCapPkgId or CreateCapModule or WhitelistedAppId not found in extended details");const u=e.isLastUseOfIntermediateToken?Kt.MAX_AMOUNT_IN:t.amountIn;return{coinType:s,metaCoinType:o,func:a,createCapFunc:c,direction:r,amountIn:u,publishedAt:t.publishedAt,poolId:t.id,extendedDetails:t.extendedDetails}}createDepositCap(e,t){const r=[t.metaCoinType];t.extendedDetails.metastable_create_cap_all_type_params&&r.push(t.coinType);const n=[e.object(t.extendedDetails.metastable_whitelisted_app_id),e.object(t.poolId)];switch(t.metaCoinType){case cV:{if(!t.extendedDetails.metastable_registry_id)throw new Error("Not found registry id for super sui");n.push(e.object(t.extendedDetails.metastable_registry_id));break}case uV:case lV:{if(t.extendedDetails.metastable_price_seed!=null){const i=this.pythPriceIDs.get(t.extendedDetails.metastable_price_seed);if(i==null)throw new Error("Invalid Pyth price feed: "+t.extendedDetails.metastable_price_seed);n.push(e.object(i))}if(t.extendedDetails.metastable_eth_price_seed!=null){const i=this.pythPriceIDs.get(t.extendedDetails.metastable_eth_price_seed);if(i==null)throw new Error("Invalid Pyth price feed: "+t.extendedDetails.metastable_eth_price_seed);n.push(e.object(i))}n.push(e.object(fr.SUI_CLOCK_OBJECT_ID));break}default:throw new Error("Invalid Metacoin: "+t.metaCoinType)}return e.moveCall({target:`${t.extendedDetails.metastable_create_cap_pkg_id}::${t.extendedDetails.metastable_create_cap_module}::${t.createCapFunc}`,typeArguments:r,arguments:n})}executeSwapContract(e,t,r,n){const i=[r,e.object(t.poolId),e.object(this.versionID),n,e.pure.u64(t.amountIn)];e.moveCall({target:`${t.publishedAt}::metastable::${t.func}`,typeArguments:[t.coinType,t.metaCoinType],arguments:i})}},dV=class{constructor(e){if(e!==0)throw new Error("Alphafi only supported on mainnet");this.suiSystemState="0x0000000000000000000000000000000000000000000000000000000000000005"}swap(e,t,r,n){const i=this.prepareSwapData(t);this.executeSwapContract(e,i,r)}prepareSwapData(e){if(e.path.publishedAt==null)throw new Error("Alphafi not set publishedAt");const t=e.path,[r,n]=t.direction?[t.from,t.target]:[t.target,t.from],i=e.isLastUseOfIntermediateToken?Kt.MAX_AMOUNT_IN:t.amountIn;return{coinAType:r,coinBType:n,direction:t.direction,amountIn:i,publishedAt:t.publishedAt,poolId:t.id}}executeSwapContract(e,t,r){const n=[r,e.object(t.poolId),e.object(this.suiSystemState),e.pure.bool(t.direction),e.pure.u64(t.amountIn)];e.moveCall({target:`${t.publishedAt}::alphafi::swap`,typeArguments:[t.coinBType],arguments:n})}},hV=class{constructor(e){if(e!==0)throw new Error("Volo only supported on mainnet");this.stakePool="0x2d914e23d82fedef1b5f56a32d5c64bdcc3087ccfea2b4d6ea51a71f587840e5",this.metadata="0x680cd26af32b2bde8d3361e804c53ec1d1cfe24c7f039eb7f549e8dfde389a60"}swap(e,t,r,n){const i=this.prepareSwapData(t);this.executeSwapContract(e,i,r)}prepareSwapData(e){const t=e.path;if(e.path.publishedAt==null)throw new Error("Volo not set publishedAt");const[r,n]=t.direction?[t.from,t.target]:[t.target,t.from],i=e.isLastUseOfIntermediateToken?Kt.MAX_AMOUNT_IN:t.amountIn;return{coinAType:r,coinBType:n,direction:t.direction,amountIn:i,publishedAt:t.publishedAt,poolId:t.id}}executeSwapContract(e,t,r){const n=[r,e.object(this.stakePool),e.object(this.metadata),e.object("0x5"),e.pure.bool(t.direction),e.pure.u64(t.amountIn)];e.moveCall({target:`${t.publishedAt}::volo::swap`,typeArguments:[],arguments:n})}},pV=class{constructor(e){if(e!==0)throw new Error("afSUI only supported on mainnet");this.stakedSuiVault="0x2f8f6d5da7f13ea37daa397724280483ed062769813b6f31e9788e59cc88994d",this.safe="0xeb685899830dd5837b47007809c76d91a098d52aabbf61e8ac467c59e5cc4610",this.referVault="0x4ce9a19b594599536c53edb25d22532f82f18038dc8ef618afd00fbbfb9845ef",this.validator="0xd30018ec3f5ff1a3c75656abf927a87d7f0529e6dc89c7ddd1bd27ecb05e3db2"}swap(e,t,r,n){const i=this.prepareSwapData(t);this.executeSwapContract(e,i,r)}prepareSwapData(e){if(e.path.publishedAt==null)throw new Error("AFSUI not set publishedAt");const t=e.path,[r,n]=t.direction?[t.from,t.target]:[t.target,t.from],i=e.isLastUseOfIntermediateToken?Kt.MAX_AMOUNT_IN:t.amountIn;return{coinAType:r,coinBType:n,direction:t.direction,amountIn:i,publishedAt:t.publishedAt,poolId:t.id}}executeSwapContract(e,t,r){if(!t.direction)throw new Error("AFSUI not support b2a swap");const n=[r,e.object(this.stakedSuiVault),e.object(this.safe),e.object("0x5"),e.object(this.referVault),e.object(this.validator),e.pure.bool(t.direction),e.pure.u64(t.amountIn)];e.moveCall({target:`${t.publishedAt}::afsui::swap`,typeArguments:[],arguments:n})}},mV=class{constructor(e){if(e!==0)throw new Error("Haedal only supported on mainnet")}swap(e,t,r,n){const i=this.prepareSwapData(t);this.executeSwapContract(e,i,r)}prepareSwapData(e){const t=e.path;if(e.path.publishedAt==null)throw new Error("Haedal not set publishedAt");const[r,n]=t.direction?[t.from,t.target]:[t.target,t.from],i=e.isLastUseOfIntermediateToken?Kt.MAX_AMOUNT_IN:t.amountIn;return{coinAType:r,coinBType:n,direction:t.direction,amountIn:i,publishedAt:t.publishedAt,poolId:t.id}}executeSwapContract(e,t,r){const n=[r,e.object(t.poolId),e.object("0x5"),e.pure.bool(t.direction),e.pure.u64(t.amountIn)];e.moveCall({target:`${t.publishedAt}::hasui::swap`,typeArguments:[],arguments:n})}},gV=class{constructor(e){if(e!==0)throw new Error("Hawal only supported on mainnet");this.staking="0x10b9d30c28448939ce6c4d6c6e0ffce4a7f8a4ada8248bdad09ef8b70e4a3904",this.validator="0x7b3ba6de2ae58283f60d5b8dc04bb9e90e4796b3b2e0dea75569f491275242e7"}swap(e,t,r,n){const i=this.prepareSwapData(t);this.executeSwapContract(e,i,r)}prepareSwapData(e){const t=e.path;if(e.path.publishedAt==null)throw new Error("Hawal not set publishedAt");const[r,n]=t.direction?[t.from,t.target]:[t.target,t.from],i=e.isLastUseOfIntermediateToken?Kt.MAX_AMOUNT_IN:t.amountIn;return{coinAType:r,coinBType:n,direction:t.direction,amountIn:i,publishedAt:t.publishedAt,poolId:t.id}}executeSwapContract(e,t,r){const n=[r,e.object(this.staking),e.object(t.poolId),e.object(this.validator),e.pure.bool(t.direction),e.pure.u64(t.amountIn)];e.moveCall({target:`${t.publishedAt}::hawal::swap`,typeArguments:[],arguments:n})}},yV=Kt.DEFAULT_PUBLISHED_AT.Mainnet;function ul(e,t){return e&&e.has(Xf.AGGREGATOR_V3)?e.get(Xf.AGGREGATOR_V3):t||yV}function Xv(e,t){const{quoteID:r,fromCoinType:n,targetCoinType:i,expectAmountOut:s,amountOutLimit:o,inputCoin:a,feeRate:c,feeRecipient:u,aggregatorPublishedAt:l,packages:f}=e,h=ul(f,l),v=[t.pure.string(r),t.pure.u64(s.toString()),t.pure.u64(o.toString()),a,t.pure.u32(Number(c.toString())),t.pure.address(u)];return t.moveCall({target:`${h}::router::new_swap_context`,typeArguments:[n,i],arguments:v})}function Jv(e,t){const{swapContext:r,targetCoinType:n,aggregatorPublishedAt:i,packages:s}=e,o=ul(s,i);return t.moveCall({target:`${o}::router::confirm_swap`,typeArguments:[n],arguments:[r]})}function vV(e,t){const{coinType:r,amount:n,swapCtx:i,aggregatorPublishedAt:s,packages:o}=e,a=ul(o,s),c=[i,t.pure.u64(n.toString())];return t.moveCall({target:`${a}::router::take_balance`,typeArguments:[r],arguments:c})}function bV(e,t){const{balance:r,coinType:n,recipient:i,aggregatorPublishedAt:s,packages:o}=e,a=ul(o,s),c=[r,t.pure.address(i)];t.moveCall({target:`${a}::router::transfer_balance`,typeArguments:[n],arguments:c})}function wV(e,t){const{coin:r,coinType:n,aggregatorPublishedAt:i,packages:s}=e,o=ul(s,i);t.moveCall({target:`${o}::router::transfer_or_destroy_coin`,typeArguments:[n],arguments:[r]})}function _V(e){return e.endsWith("/find_routes")?e.replace("/find_routes",""):e}Ac(Mc());Ac(Mc());var xV=class{constructor(e,t){if(e!==0)throw new Error("Haedal HMM V2 only supported on mainnet");this.pythPriceIDs=t}swap(e,t,r,n){const i=t.path;if(!i.extendedDetails)throw new Error("Extended details not found for Haedal HMM V2");this.validateExtendedDetails(i.extendedDetails);const s=this.prepareSwapData(t);this.executeSwapContract(e,s,r)}validateExtendedDetails(e){if(!e.haedalhmmv2_base_price_seed)throw new Error("Haedal HMM V2 base price seed not supported")}prepareSwapData(e){const t=e.path;if(e.path.publishedAt==null)throw new Error("Haedal HMM V2 not set publishedAt");const r=t.extendedDetails,[n,i]=t.direction?[t.from,t.target]:[t.target,t.from],s=e.isLastUseOfIntermediateToken?Kt.MAX_AMOUNT_IN:t.amountIn,o=r.haedalhmmv2_base_price_seed,a=this.pythPriceIDs.get(o);if(!a)throw new Error("Haedal HMM V2 requires oracle price IDs for base coin");return{coinAType:n,coinBType:i,basePriceId:a,a2b:t.direction,amountIn:s,publishedAt:t.publishedAt,poolId:t.id}}executeSwapContract(e,t,r){const n=[r,e.object(t.poolId),e.object(t.basePriceId),e.pure.u64(t.amountIn),e.pure.bool(t.a2b),e.object(fr.SUI_CLOCK_OBJECT_ID)];e.moveCall({target:`${t.publishedAt}::haedal_hmm_v2::swap`,typeArguments:[t.coinAType,t.coinBType],arguments:n})}},SV=class{constructor(e){if(e!==0)throw new Error("Fullsail only supported on mainnet");this.globalConfig="0xe93baa80cb570b3a494cbf0621b2ba96bc993926d34dc92508c9446f9a05d615",this.vault="0xfb971d3a2fb98bde74e1c30ba15a3d8bef60a02789e59ae0b91660aeed3e64e1",this.stats="0x6822a33d1d971e040c32f7cc74507010d1fe786f7d06ab89135083ddb07d2dc2",this.price_provider="0x854b2d2c0381bb656ec962f8b443eb082654384cf97885359d1956c7d76e33c9"}swap(e,t,r,n){const i=this.prepareSwapData(t);this.executeSwapContract(e,i,r)}prepareSwapData(e){const t=e.path;if(e.path.publishedAt==null)throw new Error("Fullsail not set publishedAt");const[r,n]=t.direction?[t.from,t.target]:[t.target,t.from],i=e.isLastUseOfIntermediateToken?Kt.MAX_AMOUNT_IN:t.amountIn;return{coinAType:r,coinBType:n,direction:t.direction,amountIn:i,publishedAt:t.publishedAt,poolId:t.id}}executeSwapContract(e,t,r){const n=[r,e.object(this.globalConfig),e.object(this.vault),e.object(this.stats),e.object(this.price_provider),e.object(t.poolId),e.pure.bool(t.direction),e.pure.u64(t.amountIn),e.object(fr.SUI_CLOCK_OBJECT_ID)];e.moveCall({target:`${t.publishedAt}::fullsail::swap`,typeArguments:[t.coinAType,t.coinBType],arguments:n})}},Zv="CETUS",EV="KRIYA",TV="FLOWX",CV="FLOWXV3",AV="KRIYAV3",MV="TURBOS",OV="AFTERMATH",IV="HAEDAL",kV="VOLO",jV="AFSUI",RV="BLUEMOVE",PV="DEEPBOOKV3",NV="SCALLOP",$V="SUILEND",DV="BLUEFIN",l5="HAEDALPMM",LV="ALPHAFI",BV="SPRINGSUI",UV="STEAMM",f5="METASTABLE",d5="OBRIC",FV="HAWAL",h5="STEAMM_OMM",VV="MOMENTUM",p5="STEAMM_OMM_V2",zV="MAGMA",m5="SEVENK",g5="HAEDALHMMV2",WV="FULLSAIL",qV="https://api-sui.cetus.zone/router_v3";function Qv(e){const t=new Set;for(const r of e){if(r.provider===l5&&r.extendedDetails&&r.extendedDetails.haedal_pmm_base_price_seed&&r.extendedDetails.haedal_pmm_quote_price_seed&&(t.add(r.extendedDetails.haedal_pmm_base_price_seed),t.add(r.extendedDetails.haedal_pmm_quote_price_seed)),r.provider===f5&&(r.extendedDetails&&r.extendedDetails.metastable_price_seed&&t.add(r.extendedDetails.metastable_price_seed),r.extendedDetails&&r.extendedDetails.metastable_eth_price_seed&&t.add(r.extendedDetails.metastable_eth_price_seed)),r.provider===d5&&(r.extendedDetails&&r.extendedDetails.obric_coin_a_price_seed&&t.add(r.extendedDetails.obric_coin_a_price_seed),r.extendedDetails&&r.extendedDetails.obric_coin_b_price_seed&&t.add(r.extendedDetails.obric_coin_b_price_seed)),(r.provider===h5||r.provider===p5)&&(r.extendedDetails&&r.extendedDetails.steamm_oracle_pyth_price_seed_a&&t.add(r.extendedDetails.steamm_oracle_pyth_price_seed_a),r.extendedDetails&&r.extendedDetails.steamm_oracle_pyth_price_seed_b&&t.add(r.extendedDetails.steamm_oracle_pyth_price_seed_b)),r.provider===m5&&r.extendedDetails){const n=r.extendedDetails;n.sevenk_coin_a_price_seed&&t.add(n.sevenk_coin_a_price_seed),n.sevenk_coin_b_price_seed&&t.add(n.sevenk_coin_b_price_seed)}r.provider===g5&&r.extendedDetails&&r.extendedDetails.haedalhmmv2_base_price_seed&&t.add(r.extendedDetails.haedalhmmv2_base_price_seed)}return Array.from(t)}var y5=class v5{constructor(t){var r,n;this.endpoint=t.endpoint?_V(t.endpoint):qV,this.client=t.client||new Dv.SuiClient({url:Dv.getFullnodeUrl("mainnet")}),this.signer=t.signer||"",this.env=t.env||0;const i=v5.CONFIG[this.env];if(this.pythConnections=this.newPythClients((r=t.pythUrls)!=null?r:[]),this.pythClient=new Lv.SuiPythClient(this.client,i.pythStateId,i.wormholeStateId),this.apiKey=t.apiKey||"",this.partner=t.partner,t.overlayFeeRate)if(t.overlayFeeRate>0&&t.overlayFeeRate<=pi.MAX_OVERLAY_FEE_RATE){if(this.overlayFeeRate=t.overlayFeeRate*Kt.FEE_DENOMINATOR,this.overlayFeeRate>Kt.MAX_FEE_RATE)throw new Error(pi.ERRORS.INVALID_OVERLAY_FEE_RATE)}else throw new Error(pi.ERRORS.INVALID_OVERLAY_FEE_RATE);else this.overlayFeeRate=0;this.overlayFeeReceiver=(n=t.overlayFeeReceiver)!=null?n:pi.DEFAULT_OVERLAY_FEE_RECEIVER}newPythClients(t){return t.includes("https://hermes.pyth.network")||t.push("https://hermes.pyth.network"),t.map(n=>new Lv.SuiPriceServiceConnection(n,{timeout:3e3}))}deepbookv3DeepFeeType(){return this.env===0?Jf.Mainnet:Jf.Testnet}getDeepbookV3Config(){return mn(this,null,function*(){return yield KU(this.endpoint)})}getOneCoinUsedToMerge(t){return mn(this,null,function*(){try{const r=yield this.client.getCoins({owner:this.signer,coinType:t,limit:1});return r.data.length===1?r.data[0].coinObjectId:null}catch{return null}})}findRouters(t){return mn(this,null,function*(){return qU(this.endpoint,this.apiKey,t,this.overlayFeeRate,this.overlayFeeReceiver)})}executeFlexibleInputSwap(t,r,n,i,s,o,a,c,u){return mn(this,null,function*(){})}newDexRouterV3(t,r,n){switch(t){case Zv:return new Kv(this.env,n);case AV:return new WF(this.env);case CV:return new qF(this.env);case MV:return new HF(this.env);case DV:return new GF(this.env);case VV:return new KF(this.env);case zV:return new YF(this.env);case EV:return new XF(this.env);case TV:return new JF(this.env);case RV:return new ZF(this.env);case PV:return new QF(this.env);case OV:return new eV(this.env);case UV:return new tV(this.env);case NV:return new rV(this.env);case $V:return new Yv(this.env);case BV:return new Yv(this.env);case l5:return new nV(this.env,r);case d5:return new iV(this.env,r);case m5:return new sV(this.env,r);case h5:return new oV(this.env,r);case p5:return new aV(this.env,r);case f5:return new fV(this.env,r);case LV:return new dV(this.env);case kV:return new hV(this.env);case jV:return new pV(this.env);case IV:return new mV(this.env);case FV:return new gV(this.env);case g5:return new xV(this.env,r);case WV:return new SV(this.env);default:throw new Error(`${pi.ERRORS.UNSUPPORTED_DEX} ${t}`)}}expectInputSwapV3(t,r,n,i,s,o,a){if(n.quoteID==null)throw new Error(pi.ERRORS.QUOTE_ID_REQUIRED);const c=zv(n),u=Xv({quoteID:c.quoteID,fromCoinType:c.fromCoinType,targetCoinType:c.targetCoinType,expectAmountOut:i,amountOutLimit:s,inputCoin:r,feeRate:this.overlayFeeRate,feeRecipient:this.overlayFeeReceiver,packages:c.packages},t);let l=new Map;for(const h of c.flattenedPaths){const v=h.path;l.has(v.provider)||l.set(v.provider,this.newDexRouterV3(v.provider,o,a)),l.get(v.provider).swap(t,h,u,{pythPriceIDs:o})}return Jv({swapContext:u,targetCoinType:c.targetCoinType,packages:c.packages},t)}expectOutputSwapV3(t,r,n,i,s,o){const a=[],c=new Kv(this.env,o),u=zv(n),l=Xv({quoteID:u.quoteID,fromCoinType:u.fromCoinType,targetCoinType:u.targetCoinType,expectAmountOut:i,amountOutLimit:i,inputCoin:r,feeRate:this.overlayFeeRate,feeRecipient:this.overlayFeeReceiver,packages:u.packages},t),f=KV(n.paths);let h=new Map,v=new Map;for(let S=n.paths.length-1;S>=0;S--){const C=n.paths[S],O=f.get(C.from);let I;if(S!==O||C.target===u.targetCoinType){if(C.target!==u.targetCoinType){let D=BigInt(C.amountOut);v.has(C.target)&&(D=v.get(C.target)+D),v.set(C.target,D)}I=t.pure.u64(C.amountOut.toString())}else{if(!h.has(C.target))throw Error("no need repay record");if(v.has(C.target)){const D=v.get(C.target),H=h.get(C.target);I=c.sub(t,H,t.pure.u64(D),C.publishedAt)}else I=h.get(C.target)}const U=c.flashSwapFixedOutput(t,C,I,l);if(a.unshift(U.flashReceipt),h.has(C.from)){const D=h.get(C.from);h.set(C.from,c.add(t,D,U.repayAmount,C.publishedAt))}else h.set(C.from,U.repayAmount)}for(let S=0;S<n.paths.length;S++){const C=n.paths[S];c.repayFlashSwapFixedOutput(t,C,l,a[S])}const b=vV({coinType:u.fromCoinType,amount:z0,swapCtx:l,packages:u.packages},t);return bV({balance:b,coinType:u.fromCoinType,recipient:this.signer,packages:u.packages},t),Jv({swapContext:l,targetCoinType:u.targetCoinType,packages:u.packages},t)}routerSwap(t){return mn(this,null,function*(){const{router:r,inputCoin:n,slippage:i,txb:s,partner:o}=t;if(i>1||i<0)throw new Error(pi.ERRORS.INVALID_SLIPPAGE);if(!t.router.packages||!t.router.packages.get(Xf.AGGREGATOR_V3))throw new Error(pi.ERRORS.PACKAGES_REQUIRED);const a=t.router.byAmountIn,c=r.amountIn,u=r.amountOut;Ap(this.overlayFeeRate,this.overlayFeeReceiver);let l=new dr.default(0);a?l=u.mul(new dr.default(this.overlayFeeRate)).div(new dr.default(1e6)):l=c.mul(new dr.default(this.overlayFeeRate)).div(new dr.default(1e6));const f=a?u.sub(l):u,h=a?c:c.add(l),v=Gv(a?f:h,a,i),b=Qv(r.paths),y=b.length>0?yield this.updatePythPriceIDs(b,s):new Map;return a?this.expectInputSwapV3(s,n,r,u.toString(),v.toString(),y,o??this.partner):this.expectOutputSwapV3(s,n,r,u.toString(),v.toString(),o??this.partner)})}fastRouterSwap(t){return mn(this,null,function*(){const{router:r,slippage:n,txb:i,partner:s,payDeepFeeAmount:o}=t,a=r.paths[0].from,c=r.paths[r.paths.length-1].target,u=r.byAmountIn;Ap(this.overlayFeeRate,this.overlayFeeReceiver);let l=0;u?l=Number(r.amountOut.mul(new dr.default(this.overlayFeeRate)).div(new dr.default(1e6)).toString()):l=Number(r.amountIn.mul(new dr.default(this.overlayFeeRate)).div(new dr.default(1e6)).toString());const f=u?r.amountOut.sub(new dr.default(l)):r.amountOut,h=u?r.amountIn:r.amountIn.add(new dr.default(l)),v=zF(u?f:h,u,n),b=u?h:v;let y=Tp.coinWithBalance({balance:BigInt(b.toString()),useGasCoin:!0,type:a}),S;o&&o>0&&(S=Tp.coinWithBalance({balance:BigInt(o),type:this.deepbookv3DeepFeeType()}));const C={router:r,inputCoin:y,slippage:n,txb:i,partner:s??this.partner,deepbookv3DeepFee:S},O=yield this.routerSwap(C);if(KS.isSuiCoin(c))i.mergeCoins(i.gas,[O]);else{const I=yield this.getOneCoinUsedToMerge(c);I!=null?i.mergeCoins(i.object(I),[O]):wV({coin:O,coinType:c,packages:r.packages},i)}})}fixableRouterSwapV3(t){return mn(this,null,function*(){const{router:r,inputCoin:n,slippage:i,txb:s,partner:o}=t;Ap(this.overlayFeeRate,this.overlayFeeReceiver);let a=0;r.byAmountIn?a=Number(r.amountOut.mul(new dr.default(this.overlayFeeRate)).div(new dr.default(1e6)).toString()):a=Number(r.amountIn.mul(new dr.default(this.overlayFeeRate)).div(new dr.default(1e6)).toString());const c=r.byAmountIn?r.amountOut.sub(new dr.default(a)):r.amountOut,u=r.byAmountIn?r.amountIn:r.amountIn.add(new dr.default(a)),l=Gv(r.byAmountIn?c:u,r.byAmountIn,i),f=Qv(r.paths),h=f.length>0?yield this.updatePythPriceIDs(f,s):new Map;return r.byAmountIn?this.expectInputSwapV3(s,n,r,c.toString(),l.toString(),h,o??this.partner):this.expectOutputSwapV3(s,n,r,c.toString(),l.toString(),o??this.partner)})}swapInPools(t){return mn(this,null,function*(){var r,n,i,s;const{from:o,target:a,amount:c,byAmountIn:u,pools:l}=t,f=Mo(o),h=Mo(a),v=new Tp.Transaction,b=FU(f,h),y=b?f:h,S=b?h:f,C=[y,S],O=this.env===0?"0xb2db7142fa83210a7d78d9c12ac49c043b3cbbd482224fea6e3da00aa5a5ae2d":"0x4f920e1ef6318cfba77e20a0538a419a5a504c14230169438b99aba485db40a6";for(let m=0;m<l.length;m++){const x=[v.object(l[m]),v.pure.bool(b),v.pure.bool(u),v.pure.u64(c.toString())];v.moveCall({target:`${O}::fetcher_script::calculate_swap_result`,arguments:x,typeArguments:C})}this.signer||(this.signer="0x0");const I=yield this.client.devInspectTransactionBlock({transactionBlock:v,sender:this.signer});if(I.error!=null)throw new Error("Simulation error: "+I.error);const U=(r=I.events)==null?void 0:r.filter(m=>m.type.includes("CalculatedSwapResultEvent"));if(U.length===0||U.length!==l.length)throw new Error("Simulate event result error");let D=u?new dr.default(0):new dr.default(z0),H=0;for(let m=0;m<U.length;m+=1)if(!U[m].parsedJson.data.is_exceed)if(t.byAmountIn){const x=new dr.default(U[m].parsedJson.data.amount_out);x.gt(D)&&(H=m,D=x)}else{const x=new dr.default(U[m].parsedJson.data.amount_out);x.lt(D)&&(H=m,D=x)}const z=U[H].parsedJson.data,[ne,le]=yield Promise.all([this.client.getCoinMetadata({coinType:y}).then(m=>m==null?void 0:m.decimals),this.client.getCoinMetadata({coinType:S}).then(m=>m==null?void 0:m.decimals)]);if(ne==null||le==null)throw new Error("Cannot get coin decimals");const te=Number(z.fee_rate)/1e6,ce=new dr.default((n=z.amount_in)!=null?n:0),V=new dr.default((i=z.fee_amount)!=null?i:0),L=ce.add(V),p={amountIn:L,amountOut:new dr.default((s=z.amount_out)!=null?s:0),deviationRatio:0,paths:[{id:l[H],direction:b,provider:Zv,from:f,target:h,feeRate:te,amountIn:L.toString(),amountOut:z.amount_out,publishedAt:zU,extendedDetails:{afterSqrtPrice:z.after_sqrt_price}}],insufficientLiquidity:!1,byAmountIn:t.byAmountIn,quoteID:`degraded-${GV()}`,packages:new Map([[Xf.AGGREGATOR_V3,Kt.DEFAULT_PUBLISHED_AT.Mainnet]])};return{isExceed:z.is_exceed,routeData:p}})}updatePythPriceIDs(t,r){return mn(this,null,function*(){let n=null,i=null;for(const a of this.pythConnections)try{n=yield a.getPriceFeedsUpdateData(t);break}catch(c){i=c;continue}if(n==null)throw new Error(`All Pyth price nodes are unavailable. Cannot fetch price data. Please switch to or add new available Pyth nodes. Detailed error: ${i==null?void 0:i.message}`);let s=[];try{s=yield this.pythClient.updatePriceFeeds(r,n,t)}catch(a){throw new Error(`All Pyth price nodes are unavailable. Cannot fetch price data. Please switch to or add new available Pyth nodes in the pythUrls parameter when initializing AggregatorClient, for example: new AggregatorClient({ pythUrls: ["https://your-pyth-node-url"] }). Detailed error: ${a}`)}let o=new Map;for(let a=0;a<t.length;a++)o.set(t[a],s[a]);return o})}devInspectTransactionBlock(t){return mn(this,null,function*(){return yield this.client.devInspectTransactionBlock({transactionBlock:t,sender:this.signer})})}sendTransaction(t,r){return mn(this,null,function*(){return yield this.client.signAndExecuteTransaction({transaction:t,signer:r})})}};y5.CONFIG={1:{wormholeStateId:"0x31358d198147da50db32eda2562951d53973a0c0ad5ed738e9b17d88b213d790",pythStateId:"0x243759059f4c3111179da5878c12f68d612c21a8d54d85edc86164bb18be1c7c"},0:{wormholeStateId:"0xaeab97f96cf9877fee2883315d459552b2b921edc16d7ceac6eab944dd88919c",pythStateId:"0x1f9310238ee9298fb703c3419030b35b22bb1cc37113e3bb5007c99aec79e5b8"}};var HV=y5;function GV(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){const t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}function KV(e){let t=new Map;for(let r=0;r<e.length;r++)t.has(e[r].from)||t.set(e[r].from,r);return t}function Ap(e,t){if(e>pi.MAX_OVERLAY_FEE_RATE_NUMERATOR)throw new Error(pi.ERRORS.INVALID_OVERLAY_FEE_RATE);if(t==="0x0"&&e>0)throw new Error(pi.ERRORS.OVERLAY_FEE_RECEIVER_REQUIRED)}var b5=HV,w5=XS,eb=DU,da=sc;const _5="0x2::sui::SUI",YV="0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI";function K0(e){return Or(e).full_address===_5}function tb(e,...t){const r=Array.isArray(t[t.length-1])?t.pop():[];let i=[e,...t].filter(Boolean).join("::");return r&&r.length&&(i+=`<${r.join(", ")}>`),i}function Or(e){var t;try{let r=e.replace(/\s/g,"");const n=r.match(/(<.+>)$/),i=(t=n==null?void 0:n[0])==null?void 0:t.match(/(\w+::\w+::\w+)(?:<.*?>(?!>))?/g);if(i){r=r.slice(0,r.indexOf("<"));const u={...Or(r),type_arguments:i.map(l=>Or(l).source_address)};return u.type_arguments=u.type_arguments.map(l=>K0(l)?l:Or(l).source_address),u.source_address=tb(u.full_address,u.type_arguments),u}const s=r.split("::"),a={full_address:r,address:r===_5||r===YV?"0x2":ii(s[0]),module:s[1],name:s[2],type_arguments:[],source_address:""};return a.full_address=`${a.address}::${a.module}::${a.name}`,a.source_address=tb(a.full_address,a.type_arguments),a}catch{return{full_address:e,address:"",module:"",name:"",type_arguments:[],source_address:e}}}function XV(e){return e.startsWith("0x")?`${e.slice(2)}`:e}const Vs=(e,t=!0)=>{const r=e.split("::"),n=r.shift();let i=ii(n);return t&&(i=XV(i)),`${i}::${r.join("::")}`};/*!
|
|
47
|
+
`+s):n.stack=s}catch{}}throw n}}_request(t,r){typeof t=="string"?(r=r||{},r.url=t):r=t||{},r=ya(this.defaults,r);const{transitional:n,paramsSerializer:i,headers:s}=r;n!==void 0&&lf.assertOptions(n,{silentJSONParsing:Bi.transitional(Bi.boolean),forcedJSONParsing:Bi.transitional(Bi.boolean),clarifyTimeoutError:Bi.transitional(Bi.boolean)},!1),i!=null&&(Ae.isFunction(i)?r.paramsSerializer={serialize:i}:lf.assertOptions(i,{encode:Bi.function,serialize:Bi.function},!0)),r.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?r.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:r.allowAbsoluteUrls=!0),lf.assertOptions(r,{baseUrl:Bi.spelling("baseURL"),withXsrfToken:Bi.spelling("withXSRFToken")},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let o=s&&Ae.merge(s.common,s[r.method]);s&&Ae.forEach(["delete","get","head","post","put","patch","common"],b=>{delete s[b]}),r.headers=Ei.concat(o,s);const a=[];let c=!0;this.interceptors.request.forEach(function(y){typeof y.runWhen=="function"&&y.runWhen(r)===!1||(c=c&&y.synchronous,a.unshift(y.fulfilled,y.rejected))});const u=[];this.interceptors.response.forEach(function(y){u.push(y.fulfilled,y.rejected)});let l,f=0,h;if(!c){const b=[mv.bind(this),void 0];for(b.unshift(...a),b.push(...u),h=b.length,l=Promise.resolve(r);f<h;)l=l.then(b[f++],b[f++]);return l}h=a.length;let v=r;for(f=0;f<h;){const b=a[f++],y=a[f++];try{v=b(v)}catch(S){y.call(this,S);break}}try{l=mv.call(this,v)}catch(b){return Promise.reject(b)}for(f=0,h=u.length;f<h;)l=l.then(u[f++],u[f++]);return l}getUri(t){t=ya(this.defaults,t);const r=ES(t.baseURL,t.url,t.allowAbsoluteUrls);return bS(r,t.params,t.paramsSerializer)}}Ae.forEach(["delete","get","head","options"],function(t){Kf.prototype[t]=function(r,n){return this.request(ya(n||{},{method:t,url:r,data:(n||{}).data}))}});Ae.forEach(["post","put","patch"],function(t){function r(n){return function(s,o,a){return this.request(ya(a||{},{method:t,headers:n?{"Content-Type":"multipart/form-data"}:{},url:s,data:o}))}}Kf.prototype[t]=r(),Kf.prototype[t+"Form"]=r(!0)});var ff=Kf;class t1{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(s){r=s});const n=this;this.promise.then(i=>{if(!n._listeners)return;let s=n._listeners.length;for(;s-- >0;)n._listeners[s](i);n._listeners=null}),this.promise.then=i=>{let s;const o=new Promise(a=>{n.subscribe(a),s=a}).then(i);return o.cancel=function(){n.unsubscribe(s)},o},t(function(s,o,a){n.reason||(n.reason=new Cc(s,o,a),r(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const r=this._listeners.indexOf(t);r!==-1&&this._listeners.splice(r,1)}toAbortSignal(){const t=new AbortController,r=n=>{t.abort(n)};return this.subscribe(r),t.signal.unsubscribe=()=>this.unsubscribe(r),t.signal}static source(){let t;return{token:new t1(function(i){t=i}),cancel:t}}}var DB=t1;function LB(e){return function(r){return e.apply(null,r)}}function BB(e){return Ae.isObject(e)&&e.isAxiosError===!0}const F0={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(F0).forEach(([e,t])=>{F0[t]=e});var UB=F0;function IS(e){const t=new ff(e),r=aS(ff.prototype.request,t);return Ae.extend(r,ff.prototype,t,{allOwnKeys:!0}),Ae.extend(r,t,null,{allOwnKeys:!0}),r.create=function(i){return IS(ya(e,i))},r}const Ir=IS(e1);Ir.Axios=ff;Ir.CanceledError=Cc;Ir.CancelToken=DB;Ir.isCancel=xS;Ir.VERSION=OS;Ir.toFormData=Nd;Ir.AxiosError=jt;Ir.Cancel=Ir.CanceledError;Ir.all=function(t){return Promise.all(t)};Ir.spread=LB;Ir.isAxiosError=BB;Ir.mergeConfig=ya;Ir.AxiosHeaders=Ei;Ir.formToJSON=e=>_S(Ae.isHTMLForm(e)?new FormData(e):e);Ir.getAdapter=MS.getAdapter;Ir.HttpStatusCode=UB;Ir.default=Ir;var kS=Ir,r1={exports:{}},Vn={},jS={exports:{}};(function(e){function t(r){return r&&r.__esModule?r:{default:r}}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports})(jS);var FB=jS.exports,sp={exports:{}},op={exports:{}},yv;function RS(){return yv||(yv=1,function(e){function t(r,n){this.v=r,this.k=n}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}(op)),op.exports}var ap={exports:{}},cp={exports:{}},vv;function PS(){return vv||(vv=1,function(e){function t(r,n,i,s){var o=Object.defineProperty;try{o({},"",{})}catch{o=0}e.exports=t=function(c,u,l,f){function h(v,b){t(c,v,function(y){return this._invoke(v,b,y)})}u?o?o(c,u,{value:l,enumerable:!f,configurable:!f,writable:!f}):c[u]=l:(h("next",0),h("throw",1),h("return",2))},e.exports.__esModule=!0,e.exports.default=e.exports,t(r,n,i,s)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}(cp)),cp.exports}var bv;function NS(){return bv||(bv=1,function(e){var t=PS();function r(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var n,i,s=typeof Symbol=="function"?Symbol:{},o=s.iterator||"@@iterator",a=s.toStringTag||"@@toStringTag";function c(S,C,O,I){var U=C&&C.prototype instanceof l?C:l,D=Object.create(U.prototype);return t(D,"_invoke",function(H,z,ne){var le,te,ce,V=0,L=ne||[],p=!1,d={p:0,n:0,v:n,a:m,f:m.bind(n,4),d:function(E,A){return le=E,te=0,ce=n,d.n=A,u}};function m(x,E){for(te=x,ce=E,i=0;!p&&V&&!A&&i<L.length;i++){var A,j=L[i],k=d.p,g=j[2];x>3?(A=g===E)&&(ce=j[(te=j[4])?5:(te=3,3)],j[4]=j[5]=n):j[0]<=k&&((A=x<2&&k<j[1])?(te=0,d.v=E,d.n=j[1]):k<g&&(A=x<3||j[0]>E||E>g)&&(j[4]=x,j[5]=E,d.n=g,te=0))}if(A||x>1)return u;throw p=!0,E}return function(x,E,A){if(V>1)throw TypeError("Generator is already running");for(p&&E===1&&m(E,A),te=E,ce=A;(i=te<2?n:ce)||!p;){le||(te?te<3?(te>1&&(d.n=-1),m(te,ce)):d.n=ce:d.v=ce);try{if(V=2,le){if(te||(x="next"),i=le[x]){if(!(i=i.call(le,ce)))throw TypeError("iterator result is not an object");if(!i.done)return i;ce=i.value,te<2&&(te=0)}else te===1&&(i=le.return)&&i.call(le),te<2&&(ce=TypeError("The iterator does not provide a '"+x+"' method"),te=1);le=n}else if((i=(p=d.n<0)?ce:H.call(z,d))!==u)break}catch(j){le=n,te=1,ce=j}finally{V=1}}return{value:i,done:p}}}(S,O,I),!0),D}var u={};function l(){}function f(){}function h(){}i=Object.getPrototypeOf;var v=[][o]?i(i([][o]())):(t(i={},o,function(){return this}),i),b=h.prototype=l.prototype=Object.create(v);function y(S){return Object.setPrototypeOf?Object.setPrototypeOf(S,h):(S.__proto__=h,t(S,a,"GeneratorFunction")),S.prototype=Object.create(b),S}return f.prototype=h,t(b,"constructor",h),t(h,"constructor",f),f.displayName="GeneratorFunction",t(h,a,"GeneratorFunction"),t(b),t(b,a,"Generator"),t(b,o,function(){return this}),t(b,"toString",function(){return"[object Generator]"}),(e.exports=r=function(){return{w:c,m:y}},e.exports.__esModule=!0,e.exports.default=e.exports)()}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports}(ap)),ap.exports}var up={exports:{}},lp={exports:{}},fp={exports:{}},wv;function $S(){return wv||(wv=1,function(e){var t=RS(),r=PS();function n(i,s){function o(c,u,l,f){try{var h=i[c](u),v=h.value;return v instanceof t?s.resolve(v.v).then(function(b){o("next",b,l,f)},function(b){o("throw",b,l,f)}):s.resolve(v).then(function(b){h.value=b,l(h)},function(b){return o("throw",b,l,f)})}catch(b){f(b)}}var a;this.next||(r(n.prototype),r(n.prototype,typeof Symbol=="function"&&Symbol.asyncIterator||"@asyncIterator",function(){return this})),r(this,"_invoke",function(c,u,l){function f(){return new s(function(h,v){o(c,l,h,v)})}return a=a?a.then(f,f):f()},!0)}e.exports=n,e.exports.__esModule=!0,e.exports.default=e.exports}(fp)),fp.exports}var _v;function DS(){return _v||(_v=1,function(e){var t=NS(),r=$S();function n(i,s,o,a,c){return new r(t().w(i,s,o,a),c||Promise)}e.exports=n,e.exports.__esModule=!0,e.exports.default=e.exports}(lp)),lp.exports}var xv;function VB(){return xv||(xv=1,function(e){var t=DS();function r(n,i,s,o,a){var c=t(n,i,s,o,a);return c.next().then(function(u){return u.done?u.value:c.next()})}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports}(up)),up.exports}var dp={exports:{}},Sv;function zB(){return Sv||(Sv=1,function(e){function t(r){var n=Object(r),i=[];for(var s in n)i.unshift(s);return function o(){for(;i.length;)if((s=i.pop())in n)return o.value=s,o.done=!1,o;return o.done=!0,o}}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}(dp)),dp.exports}var hp={exports:{}},pp={exports:{}},Ev;function Bd(){return Ev||(Ev=1,function(e){function t(r){"@babel/helpers - typeof";return e.exports=t=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(n){return typeof n}:function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},e.exports.__esModule=!0,e.exports.default=e.exports,t(r)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}(pp)),pp.exports}var Tv;function WB(){return Tv||(Tv=1,function(e){var t=Bd().default;function r(n){if(n!=null){var i=n[typeof Symbol=="function"&&Symbol.iterator||"@@iterator"],s=0;if(i)return i.call(n);if(typeof n.next=="function")return n;if(!isNaN(n.length))return{next:function(){return n&&s>=n.length&&(n=void 0),{value:n&&n[s++],done:!n}}}}throw new TypeError(t(n)+" is not iterable")}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports}(hp)),hp.exports}var Cv;function qB(){return Cv||(Cv=1,function(e){var t=RS(),r=NS(),n=VB(),i=DS(),s=$S(),o=zB(),a=WB();function c(){var u=r(),l=u.m(c),f=(Object.getPrototypeOf?Object.getPrototypeOf(l):l.__proto__).constructor;function h(y){var S=typeof y=="function"&&y.constructor;return!!S&&(S===f||(S.displayName||S.name)==="GeneratorFunction")}var v={throw:1,return:2,break:3,continue:3};function b(y){var S,C;return function(O){S||(S={stop:function(){return C(O.a,2)},catch:function(){return O.v},abrupt:function(U,D){return C(O.a,v[U],D)},delegateYield:function(U,D,H){return S.resultName=D,C(O.d,a(U),H)},finish:function(U){return C(O.f,U)}},C=function(U,D,H){O.p=S.prev,O.n=S.next;try{return U(D,H)}finally{S.next=O.n}}),S.resultName&&(S[S.resultName]=O.v,S.resultName=void 0),S.sent=O.v,S.next=O.n;try{return y.call(this,S)}finally{O.p=S.prev,O.n=S.next}}}return(e.exports=c=function(){return{wrap:function(C,O,I,U){return u.w(b(C),O,I,U&&U.reverse())},isGeneratorFunction:h,mark:u.m,awrap:function(C,O){return new t(C,O)},AsyncIterator:s,async:function(C,O,I,U,D){return(h(O)?i:n)(b(C),O,I,U,D)},keys:o,values:a}},e.exports.__esModule=!0,e.exports.default=e.exports)()}e.exports=c,e.exports.__esModule=!0,e.exports.default=e.exports}(sp)),sp.exports}var mp,Av;function HB(){if(Av)return mp;Av=1;var e=qB()();mp=e;try{regeneratorRuntime=e}catch{typeof globalThis=="object"?globalThis.regeneratorRuntime=e:Function("r","regeneratorRuntime = r")(e)}return mp}var gp={exports:{}},Mv;function GB(){return Mv||(Mv=1,function(e){function t(n,i,s,o,a,c,u){try{var l=n[c](u),f=l.value}catch(h){return void s(h)}l.done?i(f):Promise.resolve(f).then(o,a)}function r(n){return function(){var i=this,s=arguments;return new Promise(function(o,a){var c=n.apply(i,s);function u(f){t(c,o,a,u,l,"next",f)}function l(f){t(c,o,a,u,l,"throw",f)}u(void 0)})}}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports}(gp)),gp.exports}var yp={exports:{}},vp={exports:{}},bp={exports:{}},Ov;function KB(){return Ov||(Ov=1,function(e){var t=Bd().default;function r(n,i){if(t(n)!="object"||!n)return n;var s=n[Symbol.toPrimitive];if(s!==void 0){var o=s.call(n,i||"default");if(t(o)!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(i==="string"?String:Number)(n)}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports}(bp)),bp.exports}var Iv;function YB(){return Iv||(Iv=1,function(e){var t=Bd().default,r=KB();function n(i){var s=r(i,"string");return t(s)=="symbol"?s:s+""}e.exports=n,e.exports.__esModule=!0,e.exports.default=e.exports}(vp)),vp.exports}var kv;function XB(){return kv||(kv=1,function(e){var t=YB();function r(n,i,s){return(i=t(i))in n?Object.defineProperty(n,i,{value:s,enumerable:!0,configurable:!0,writable:!0}):n[i]=s,n}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports}(yp)),yp.exports}var wp,jv;function JB(){if(jv)return wp;jv=1;const e=new Set(["ENOTFOUND","ENETUNREACH","UNABLE_TO_GET_ISSUER_CERT","UNABLE_TO_GET_CRL","UNABLE_TO_DECRYPT_CERT_SIGNATURE","UNABLE_TO_DECRYPT_CRL_SIGNATURE","UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY","CERT_SIGNATURE_FAILURE","CRL_SIGNATURE_FAILURE","CERT_NOT_YET_VALID","CERT_HAS_EXPIRED","CRL_NOT_YET_VALID","CRL_HAS_EXPIRED","ERROR_IN_CERT_NOT_BEFORE_FIELD","ERROR_IN_CERT_NOT_AFTER_FIELD","ERROR_IN_CRL_LAST_UPDATE_FIELD","ERROR_IN_CRL_NEXT_UPDATE_FIELD","OUT_OF_MEM","DEPTH_ZERO_SELF_SIGNED_CERT","SELF_SIGNED_CERT_IN_CHAIN","UNABLE_TO_GET_ISSUER_CERT_LOCALLY","UNABLE_TO_VERIFY_LEAF_SIGNATURE","CERT_CHAIN_TOO_LONG","CERT_REVOKED","INVALID_CA","PATH_LENGTH_EXCEEDED","INVALID_PURPOSE","CERT_UNTRUSTED","CERT_REJECTED","HOSTNAME_MISMATCH"]);return wp=t=>!e.has(t&&t.code),wp}var ol=FB;Object.defineProperty(Vn,"__esModule",{value:!0});Vn.isNetworkError=i1;Vn.isRetryableError=Ud;Vn.isSafeRequestError=US;Vn.isIdempotentRequestError=s1;Vn.isNetworkOrIdempotentRequestError=o1;Vn.exponentialDelay=FS;Vn.default=Ca;Vn.DEFAULT_OPTIONS=Vn.namespace=void 0;var Yf=ol(HB()),ZB=ol(Bd()),LS=ol(GB()),QB=ol(XB()),eU=ol(JB());function Rv(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function _p(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Rv(Object(r),!0).forEach(function(n){(0,QB.default)(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Rv(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}var n1="axios-retry";Vn.namespace=n1;function i1(e){var t=["ERR_CANCELED","ECONNABORTED"];return!e.response&&!!e.code&&!t.includes(e.code)&&(0,eU.default)(e)}var BS=["get","head","options"],tU=BS.concat(["put","delete"]);function Ud(e){return e.code!=="ECONNABORTED"&&(!e.response||e.response.status>=500&&e.response.status<=599)}function US(e){return e.config?Ud(e)&&BS.indexOf(e.config.method)!==-1:!1}function s1(e){return e.config?Ud(e)&&tU.indexOf(e.config.method)!==-1:!1}function o1(e){return i1(e)||s1(e)}function rU(){return 0}function FS(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:100,r=Math.pow(2,e)*t,n=r*.2*Math.random();return r+n}var VS={retries:3,retryCondition:o1,retryDelay:rU,shouldResetTimeout:!1,onRetry:function(){}};Vn.DEFAULT_OPTIONS=VS;function nU(e,t){return _p(_p(_p({},VS),t),e[n1])}function Pv(e,t){var r=nU(e,t);return r.retryCount=r.retryCount||0,e[n1]=r,r}function iU(e,t){e.defaults.agent===t.agent&&delete t.agent,e.defaults.httpAgent===t.httpAgent&&delete t.httpAgent,e.defaults.httpsAgent===t.httpsAgent&&delete t.httpsAgent}function sU(e,t){return V0.apply(this,arguments)}function V0(){return V0=(0,LS.default)(Yf.default.mark(function e(t,r){var n,i,s,o;return Yf.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:if(n=t.retries,i=t.retryCondition,s=t.retryCount<n&&i(r),(0,ZB.default)(s)!=="object"){c.next=13;break}return c.prev=3,c.next=6,s;case 6:return o=c.sent,c.abrupt("return",o!==!1);case 10:return c.prev=10,c.t0=c.catch(3),c.abrupt("return",!1);case 13:return c.abrupt("return",s);case 14:case"end":return c.stop()}},e,null,[[3,10]])})),V0.apply(this,arguments)}function Ca(e,t){var r=e.interceptors.request.use(function(i){var s=Pv(i,t);return s.lastRequestTime=Date.now(),i}),n=e.interceptors.response.use(null,function(){var i=(0,LS.default)(Yf.default.mark(function s(o){var a,c,u,l,f,h,v,b;return Yf.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:if(a=o.config,a){S.next=3;break}return S.abrupt("return",Promise.reject(o));case 3:return c=Pv(a,t),S.next=6,sU(c,o);case 6:if(!S.sent){S.next=21;break}if(c.retryCount+=1,u=c.retryDelay,l=c.shouldResetTimeout,f=c.onRetry,h=u(c.retryCount,o),iU(e,a),!(!l&&a.timeout&&c.lastRequestTime)){S.next=17;break}if(v=Date.now()-c.lastRequestTime,b=a.timeout-v-h,!(b<=0)){S.next=16;break}return S.abrupt("return",Promise.reject(o));case 16:a.timeout=b;case 17:return a.transformRequest=[function(C){return C}],S.next=20,f(c.retryCount,o,a);case 20:return S.abrupt("return",new Promise(function(C){return setTimeout(function(){return C(e(a))},h)}));case 21:return S.abrupt("return",Promise.reject(o));case 22:case"end":return S.stop()}},s)}));return function(s){return i.apply(this,arguments)}}());return{requestInterceptorId:r,responseInterceptorId:n}}Ca.isNetworkError=i1;Ca.isSafeRequestError=US;Ca.isIdempotentRequestError=s1;Ca.isNetworkOrIdempotentRequestError=o1;Ca.exponentialDelay=FS;Ca.isRetryableError=Ud;const zS=Vn.default;r1.exports=zS;r1.exports.default=zS;var oU=r1.exports,Fd={},Ya=null;typeof WebSocket<"u"?Ya=WebSocket:typeof MozWebSocket<"u"?Ya=MozWebSocket:typeof qr<"u"?Ya=qr.WebSocket||qr.MozWebSocket:typeof window<"u"?Ya=window.WebSocket||window.MozWebSocket:typeof self<"u"&&(Ya=self.WebSocket||self.MozWebSocket);var aU=Ya,cU=qr&&qr.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Fd,"__esModule",{value:!0});Fd.ResilientWebSocket=void 0;const uU=cU(aU),lU=3e4+3e3;class fU{constructor(t,r){Pt(this,"endpoint");Pt(this,"wsClient");Pt(this,"wsUserClosed");Pt(this,"wsFailedAttempts");Pt(this,"pingTimeout");Pt(this,"logger");Pt(this,"onError");Pt(this,"onMessage");Pt(this,"onReconnect");this.endpoint=t,this.logger=r,this.wsFailedAttempts=0,this.onError=n=>{var i;(i=this.logger)==null||i.error(n)},this.wsUserClosed=!0,this.onMessage=()=>{},this.onReconnect=()=>{}}async send(t){var r,n,i;(r=this.logger)==null||r.info(`Sending ${t}`),await this.waitForMaybeReadyWebSocket(),this.wsClient===void 0?(n=this.logger)==null||n.error("Couldn't connect to the websocket server. Error callback is called."):(i=this.wsClient)==null||i.send(t)}async startWebSocket(){var t;this.wsClient===void 0&&((t=this.logger)==null||t.info("Creating Web Socket client"),this.wsClient=new uU.default(this.endpoint),this.wsUserClosed=!1,this.wsClient.onopen=()=>{this.wsFailedAttempts=0,this.wsClient.on!==void 0&&this.heartbeat()},this.wsClient.onerror=r=>{this.onError(r.error)},this.wsClient.onmessage=r=>{this.onMessage(r.data)},this.wsClient.onclose=async()=>{var r,n;if(this.pingTimeout!==void 0&&clearInterval(this.pingTimeout),this.wsUserClosed===!1){this.wsFailedAttempts+=1,this.wsClient=void 0;const i=dU(this.wsFailedAttempts);(r=this.logger)==null||r.error(`Connection closed unexpectedly or because of timeout. Reconnecting after ${i}ms.`),await Nv(i),this.restartUnexpectedClosedWebsocket()}else(n=this.logger)==null||n.info("The connection has been closed successfully.")},this.wsClient.on!==void 0&&this.wsClient.on("ping",this.heartbeat.bind(this)))}heartbeat(){var t;(t=this.logger)==null||t.info("Heartbeat"),this.pingTimeout!==void 0&&clearTimeout(this.pingTimeout),this.pingTimeout=setTimeout(()=>{var r,n;(r=this.logger)==null||r.warn("Connection timed out. Reconnecting..."),(n=this.wsClient)==null||n.terminate(),this.restartUnexpectedClosedWebsocket()},lU)}async waitForMaybeReadyWebSocket(){let t=0;for(;this.wsClient!==void 0&&this.wsClient.readyState!==this.wsClient.OPEN;)if(t>5e3){this.wsClient.close();return}else t+=10,await Nv(10)}async restartUnexpectedClosedWebsocket(){var t;if(this.wsUserClosed!==!0){if(await this.startWebSocket(),await this.waitForMaybeReadyWebSocket(),this.wsClient===void 0){(t=this.logger)==null||t.error("Couldn't reconnect to websocket. Error callback is called.");return}this.onReconnect()}}closeWebSocket(){if(this.wsClient!==void 0){const t=this.wsClient;this.wsClient=void 0,t.close()}this.wsUserClosed=!0}}Fd.ResilientWebSocket=fU;async function Nv(e){return new Promise(t=>setTimeout(t,e))}function dU(e){return 2**e*100}var hc={};Object.defineProperty(hc,"__esModule",{value:!0});hc.removeLeading0xIfExists=hc.makeWebsocketUrl=void 0;function hU(e){const t=new URL("ws",e),r=t.protocol==="https:";return t.protocol=r?"wss:":"ws:",t.toString()}hc.makeWebsocketUrl=hU;function pU(e){return e.startsWith("0x")?e.substring(2):e}hc.removeLeading0xIfExists=pU;var WS=qr&&qr.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Od,"__esModule",{value:!0});Od.PriceServiceConnection=void 0;const xp=Gg,mU=WS(kS),$v=WS(oU),gU=Fd,Sp=hc;class yU{constructor(t,r){Pt(this,"httpClient");Pt(this,"priceFeedCallbacks");Pt(this,"wsClient");Pt(this,"wsEndpoint");Pt(this,"logger");Pt(this,"priceFeedRequestConfig");Pt(this,"onWsError");var n,i,s;this.httpClient=mU.default.create({baseURL:t,timeout:(r==null?void 0:r.timeout)||5e3}),(0,$v.default)(this.httpClient,{retries:(r==null?void 0:r.httpRetries)||3,retryDelay:$v.default.exponentialDelay}),this.priceFeedRequestConfig={binary:(n=r==null?void 0:r.priceFeedRequestConfig)==null?void 0:n.binary,verbose:((i=r==null?void 0:r.priceFeedRequestConfig)==null?void 0:i.verbose)??(r==null?void 0:r.verbose),allowOutOfOrder:(s=r==null?void 0:r.priceFeedRequestConfig)==null?void 0:s.allowOutOfOrder},this.priceFeedCallbacks=new Map,this.logger=(r==null?void 0:r.logger)||{trace:()=>{},debug:()=>{},info:()=>{},warn:console.warn,error:console.error},this.onWsError=o=>{this.logger.error(o),typeof In<"u"&&typeof In.exit=="function"?(this.logger.error("Halting the process due to the websocket error"),In.exit(1)):this.logger.error("Cannot halt process. Please handle the websocket error.")},this.wsEndpoint=(0,Sp.makeWebsocketUrl)(t)}async getLatestPriceFeeds(t){return t.length===0?[]:(await this.httpClient.get("/api/latest_price_feeds",{params:{ids:t,verbose:this.priceFeedRequestConfig.verbose,binary:this.priceFeedRequestConfig.binary}})).data.map(i=>xp.PriceFeed.fromJson(i))}async getLatestVaas(t){return(await this.httpClient.get("/api/latest_vaas",{params:{ids:t}})).data}async getVaa(t,r){const n=await this.httpClient.get("/api/get_vaa",{params:{id:t,publish_time:r}});return[n.data.vaa,n.data.publishTime]}async getPriceFeed(t,r){const n=await this.httpClient.get("/api/get_price_feed",{params:{id:t,publish_time:r,verbose:this.priceFeedRequestConfig.verbose,binary:this.priceFeedRequestConfig.binary}});return xp.PriceFeed.fromJson(n.data)}async getPriceFeedIds(){return(await this.httpClient.get("/api/price_feed_ids")).data}async subscribePriceFeedUpdates(t,r){var s;this.wsClient===void 0&&await this.startWebSocket(),t=t.map(o=>(0,Sp.removeLeading0xIfExists)(o));const n=[];for(const o of t)this.priceFeedCallbacks.has(o)||(this.priceFeedCallbacks.set(o,new Set),n.push(o)),this.priceFeedCallbacks.get(o).add(r);const i={ids:n,type:"subscribe",verbose:this.priceFeedRequestConfig.verbose,binary:this.priceFeedRequestConfig.binary,allow_out_of_order:this.priceFeedRequestConfig.allowOutOfOrder};await((s=this.wsClient)==null?void 0:s.send(JSON.stringify(i)))}async unsubscribePriceFeedUpdates(t,r){var s;this.wsClient===void 0&&await this.startWebSocket(),t=t.map(o=>(0,Sp.removeLeading0xIfExists)(o));const n=[];for(const o of t)if(this.priceFeedCallbacks.has(o)){let a=!1;r===void 0?(this.priceFeedCallbacks.delete(o),a=!0):(this.priceFeedCallbacks.get(o).delete(r),this.priceFeedCallbacks.get(o).size===0&&(this.priceFeedCallbacks.delete(o),a=!0)),a&&n.push(o)}const i={ids:n,type:"unsubscribe"};await((s=this.wsClient)==null?void 0:s.send(JSON.stringify(i))),this.priceFeedCallbacks.size===0&&this.closeWebSocket()}async startWebSocket(){if(this.wsEndpoint===void 0)throw new Error("Websocket endpoint is undefined.");this.wsClient=new gU.ResilientWebSocket(this.wsEndpoint,this.logger),this.wsClient.onError=this.onWsError,this.wsClient.onReconnect=()=>{var t;if(this.priceFeedCallbacks.size>0){const r={ids:Array.from(this.priceFeedCallbacks.keys()),type:"subscribe",verbose:this.priceFeedRequestConfig.verbose,binary:this.priceFeedRequestConfig.binary,allow_out_of_order:this.priceFeedRequestConfig.allowOutOfOrder};this.logger.info("Resubscribing to existing price feeds."),(t=this.wsClient)==null||t.send(JSON.stringify(r))}},this.wsClient.onMessage=t=>{this.logger.info(`Received message ${t.toString()}`);let r;try{r=JSON.parse(t.toString())}catch(n){this.logger.error(`Error parsing message ${t.toString()} as JSON.`),this.logger.error(n),this.onWsError(n);return}if(r.type==="response")r.status==="error"&&(this.logger.error(`Error response from the websocket server ${r.error}.`),this.onWsError(new Error(r.error)));else if(r.type==="price_update"){let n;try{n=xp.PriceFeed.fromJson(r.price_feed)}catch(i){this.logger.error(`Error parsing price feeds from message ${t.toString()}.`),this.logger.error(i),this.onWsError(i);return}if(this.priceFeedCallbacks.has(n.id))for(const i of this.priceFeedCallbacks.get(n.id))i(n)}else this.logger.warn(`Ignoring unsupported server response ${t.toString()}.`)},await this.wsClient.startWebSocket()}closeWebSocket(){var t;(t=this.wsClient)==null||t.closeWebSocket(),this.wsClient=void 0,this.priceFeedCallbacks.clear()}}Od.PriceServiceConnection=yU;(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.parseAccumulatorUpdateData=e.isAccumulatorUpdateData=e.Price=e.PriceFeed=e.PriceFeedMetadata=e.PriceServiceConnection=void 0;var t=Od;Object.defineProperty(e,"PriceServiceConnection",{enumerable:!0,get:function(){return t.PriceServiceConnection}});var r=Gg;Object.defineProperty(e,"PriceFeedMetadata",{enumerable:!0,get:function(){return r.PriceFeedMetadata}}),Object.defineProperty(e,"PriceFeed",{enumerable:!0,get:function(){return r.PriceFeed}}),Object.defineProperty(e,"Price",{enumerable:!0,get:function(){return r.Price}}),Object.defineProperty(e,"isAccumulatorUpdateData",{enumerable:!0,get:function(){return r.isAccumulatorUpdateData}}),Object.defineProperty(e,"parseAccumulatorUpdateData",{enumerable:!0,get:function(){return r.parseAccumulatorUpdateData}})})(Hg);Object.defineProperty(Md,"__esModule",{value:!0});Md.SuiPriceServiceConnection=void 0;const vU=Hg,bU=kd();class wU extends vU.PriceServiceConnection{async getPriceFeedsUpdateData(t){return(await this.getLatestVaas(t)).map(n=>bU.Buffer.from(n,"base64"))}}Md.SuiPriceServiceConnection=wU;var Vd={};Object.defineProperty(Vd,"__esModule",{value:!0});Vd.SuiPythClient=void 0;const Ml=xx,Pa=Oi,_U=kd(),Ep=16*1024;class xU{constructor(t,r,n){Pt(this,"provider");Pt(this,"pythStateId");Pt(this,"wormholeStateId");Pt(this,"pythPackageId");Pt(this,"wormholePackageId");Pt(this,"priceTableInfo");Pt(this,"priceFeedObjectIdCache",new Map);Pt(this,"baseUpdateFee");this.provider=t,this.pythStateId=r,this.wormholeStateId=n,this.pythPackageId=void 0,this.wormholePackageId=void 0}async getBaseUpdateFee(){if(this.baseUpdateFee===void 0){const t=await this.provider.getObject({id:this.pythStateId,options:{showContent:!0}});if(!t.data||!t.data.content||t.data.content.dataType!=="moveObject")throw new Error("Unable to fetch pyth state object");this.baseUpdateFee=t.data.content.fields.base_update_fee}return this.baseUpdateFee}async getPackageId(t){const r=await this.provider.getObject({id:t,options:{showContent:!0}}).then(n=>{var i,s;if(((s=(i=n.data)==null?void 0:i.content)==null?void 0:s.dataType)=="moveObject")return n.data.content.fields;throw new Error(`Cannot fetch package id for object ${t}`)});if("upgrade_cap"in r)return r.upgrade_cap.fields.package;throw new Error("upgrade_cap not found")}async verifyVaas(t,r){const n=await this.getWormholePackageId(),i=[];for(const s of t){const[o]=r.moveCall({target:`${n}::vaa::parse_and_verify`,arguments:[r.object(this.wormholeStateId),r.pure(Pa.bcs.vector(Pa.bcs.U8).serialize(Array.from(s),{maxSize:Ep}).toBytes()),r.object(Ml.SUI_CLOCK_OBJECT_ID)]});i.push(o)}return i}async verifyVaasAndGetHotPotato(t,r,n){if(r.length>1)throw new Error("SDK does not support sending multiple accumulator messages in a single transaction");const i=this.extractVaaBytesFromAccumulatorMessage(r[0]),s=await this.verifyVaas([i],t),[o]=t.moveCall({target:`${n}::pyth::create_authenticated_price_infos_using_accumulator`,arguments:[t.object(this.pythStateId),t.pure(Pa.bcs.vector(Pa.bcs.U8).serialize(Array.from(r[0]),{maxSize:Ep}).toBytes()),s[0],t.object(Ml.SUI_CLOCK_OBJECT_ID)]});return o}async executePriceFeedUpdates(t,r,n,i,s){const o=[];let a=0;for(const c of n){const u=await this.getPriceFeedObjectId(c);if(!u)throw new Error(`Price feed ${c} not found, please create it first`);o.push(u),[i]=t.moveCall({target:`${r}::pyth::update_single_price_feed`,arguments:[t.object(this.pythStateId),i,t.object(u),s[a],t.object(Ml.SUI_CLOCK_OBJECT_ID)]}),a++}return t.moveCall({target:`${r}::hot_potato_vector::destroy`,arguments:[i],typeArguments:[`${r}::price_info::PriceInfo`]}),o}async updatePriceFeeds(t,r,n){const i=await this.getPythPackageId(),s=await this.verifyVaasAndGetHotPotato(t,r,i),o=await this.getBaseUpdateFee(),a=t.splitCoins(t.gas,n.map(()=>t.pure.u64(o)));return await this.executePriceFeedUpdates(t,i,n,s,a)}async updatePriceFeedsWithCoins(t,r,n,i){const s=await this.getPythPackageId(),o=await this.verifyVaasAndGetHotPotato(t,r,s);return await this.executePriceFeedUpdates(t,s,n,o,i)}async createPriceFeed(t,r){const n=await this.getPythPackageId();if(r.length>1)throw new Error("SDK does not support sending multiple accumulator messages in a single transaction");const i=this.extractVaaBytesFromAccumulatorMessage(r[0]),s=await this.verifyVaas([i],t);t.moveCall({target:`${n}::pyth::create_price_feeds_using_accumulator`,arguments:[t.object(this.pythStateId),t.pure(Pa.bcs.vector(Pa.bcs.U8).serialize(Array.from(r[0]),{maxSize:Ep}).toBytes()),s[0],t.object(Ml.SUI_CLOCK_OBJECT_ID)]})}async getWormholePackageId(){return this.wormholePackageId||(this.wormholePackageId=await this.getPackageId(this.wormholeStateId)),this.wormholePackageId}async getPythPackageId(){return this.pythPackageId||(this.pythPackageId=await this.getPackageId(this.pythStateId)),this.pythPackageId}async getPriceFeedObjectId(t){const r=t.replace("0x","");if(!this.priceFeedObjectIdCache.has(r)){const{id:n,fieldType:i}=await this.getPriceTableInfo(),s=await this.provider.getDynamicFieldObject({parentId:n,name:{type:`${i}::price_identifier::PriceIdentifier`,value:{bytes:Array.from(_U.Buffer.from(r,"hex"))}}});if(!s.data||!s.data.content)return;if(s.data.content.dataType!=="moveObject")throw new Error("Price feed type mismatch");this.priceFeedObjectIdCache.set(r,s.data.content.fields.value)}return this.priceFeedObjectIdCache.get(r)}async getPriceTableInfo(){if(this.priceTableInfo===void 0){const t=await this.provider.getDynamicFieldObject({parentId:this.pythStateId,name:{type:"vector<u8>",value:"price_info"}});if(!t.data||!t.data.type)throw new Error("Price Table not found, contract may not be initialized");let r=t.data.type.replace("0x2::table::Table<","");r=r.replace("::price_identifier::PriceIdentifier, 0x2::object::ID>",""),this.priceTableInfo={id:t.data.objectId,fieldType:r}}return this.priceTableInfo}extractVaaBytesFromAccumulatorMessage(t){const n=7+t.readUint8(6)+1,i=t.readUint16BE(n),s=n+2;return t.subarray(s,s+i)}}Vd.SuiPythClient=xU;(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.PriceFeed=e.Price=e.SuiPythClient=e.SuiPriceServiceConnection=void 0;var t=Md;Object.defineProperty(e,"SuiPriceServiceConnection",{enumerable:!0,get:function(){return t.SuiPriceServiceConnection}});var r=Vd;Object.defineProperty(e,"SuiPythClient",{enumerable:!0,get:function(){return r.SuiPythClient}});var n=Hg;Object.defineProperty(e,"Price",{enumerable:!0,get:function(){return n.Price}}),Object.defineProperty(e,"PriceFeed",{enumerable:!0,get:function(){return n.PriceFeed}})})(iS);var Tp=ei,SU=AN,fr=xx,Dv=HD,Lv=iS;function EU(e){return e&&e.__esModule?e:{default:e}}var TU=EU(SU),CU=Object.create,a1=Object.defineProperty,AU=Object.defineProperties,MU=Object.getOwnPropertyDescriptor,OU=Object.getOwnPropertyDescriptors,qS=Object.getOwnPropertyNames,Bv=Object.getOwnPropertySymbols,IU=Object.getPrototypeOf,HS=Object.prototype.hasOwnProperty,kU=Object.prototype.propertyIsEnumerable,Uv=(e,t,r)=>t in e?a1(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,jU=(e,t)=>{for(var r in t||(t={}))HS.call(t,r)&&Uv(e,r,t[r]);if(Bv)for(var r of Bv(t))kU.call(t,r)&&Uv(e,r,t[r]);return e},RU=(e,t)=>AU(e,OU(t)),PU=(e=>typeof qi<"u"?qi:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof qi<"u"?qi:t)[r]}):e)(function(e){if(typeof qi<"u")return qi.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')}),NU=(e,t)=>function(){return t||(0,e[qS(e)[0]])((t={exports:{}}).exports,t),t.exports},$U=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of qS(t))!HS.call(e,i)&&i!==r&&a1(e,i,{get:()=>t[i],enumerable:!(n=MU(t,i))||n.enumerable});return e},Ac=(e,t,r)=>(r=e!=null?CU(IU(e)):{},$U(!e||!e.__esModule?a1(r,"default",{value:e,enumerable:!0}):r,e)),mn=(e,t,r)=>new Promise((n,i)=>{var s=c=>{try{a(r.next(c))}catch(u){i(u)}},o=c=>{try{a(r.throw(c))}catch(u){i(u)}},a=c=>c.done?n(c.value):Promise.resolve(c.value).then(s,o);a((r=r.apply(e,t)).next())}),Mc=NU({"node_modules/bn.js/lib/bn.js"(e,t){(function(r,n){function i(p,d){if(!p)throw new Error(d||"Assertion failed")}function s(p,d){p.super_=d;var m=function(){};m.prototype=d.prototype,p.prototype=new m,p.prototype.constructor=p}function o(p,d,m){if(o.isBN(p))return p;this.negative=0,this.words=null,this.length=0,this.red=null,p!==null&&((d==="le"||d==="be")&&(m=d,d=10),this._init(p||0,d||10,m||"be"))}typeof r=="object"?r.exports=o:n.BN=o,o.BN=o,o.wordSize=26;var a;try{typeof window<"u"&&typeof window.Buffer<"u"?a=window.Buffer:a=PU("buffer").Buffer}catch{}o.isBN=function(d){return d instanceof o?!0:d!==null&&typeof d=="object"&&d.constructor.wordSize===o.wordSize&&Array.isArray(d.words)},o.max=function(d,m){return d.cmp(m)>0?d:m},o.min=function(d,m){return d.cmp(m)<0?d:m},o.prototype._init=function(d,m,x){if(typeof d=="number")return this._initNumber(d,m,x);if(typeof d=="object")return this._initArray(d,m,x);m==="hex"&&(m=16),i(m===(m|0)&&m>=2&&m<=36),d=d.toString().replace(/\s+/g,"");var E=0;d[0]==="-"&&(E++,this.negative=1),E<d.length&&(m===16?this._parseHex(d,E,x):(this._parseBase(d,m,E),x==="le"&&this._initArray(this.toArray(),m,x)))},o.prototype._initNumber=function(d,m,x){d<0&&(this.negative=1,d=-d),d<67108864?(this.words=[d&67108863],this.length=1):d<4503599627370496?(this.words=[d&67108863,d/67108864&67108863],this.length=2):(i(d<9007199254740992),this.words=[d&67108863,d/67108864&67108863,1],this.length=3),x==="le"&&this._initArray(this.toArray(),m,x)},o.prototype._initArray=function(d,m,x){if(i(typeof d.length=="number"),d.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(d.length/3),this.words=new Array(this.length);for(var E=0;E<this.length;E++)this.words[E]=0;var A,j,k=0;if(x==="be")for(E=d.length-1,A=0;E>=0;E-=3)j=d[E]|d[E-1]<<8|d[E-2]<<16,this.words[A]|=j<<k&67108863,this.words[A+1]=j>>>26-k&67108863,k+=24,k>=26&&(k-=26,A++);else if(x==="le")for(E=0,A=0;E<d.length;E+=3)j=d[E]|d[E+1]<<8|d[E+2]<<16,this.words[A]|=j<<k&67108863,this.words[A+1]=j>>>26-k&67108863,k+=24,k>=26&&(k-=26,A++);return this._strip()};function c(p,d){var m=p.charCodeAt(d);if(m>=48&&m<=57)return m-48;if(m>=65&&m<=70)return m-55;if(m>=97&&m<=102)return m-87;i(!1,"Invalid character in "+p)}function u(p,d,m){var x=c(p,m);return m-1>=d&&(x|=c(p,m-1)<<4),x}o.prototype._parseHex=function(d,m,x){this.length=Math.ceil((d.length-m)/6),this.words=new Array(this.length);for(var E=0;E<this.length;E++)this.words[E]=0;var A=0,j=0,k;if(x==="be")for(E=d.length-1;E>=m;E-=2)k=u(d,m,E)<<A,this.words[j]|=k&67108863,A>=18?(A-=18,j+=1,this.words[j]|=k>>>26):A+=8;else{var g=d.length-m;for(E=g%2===0?m+1:m;E<d.length;E+=2)k=u(d,m,E)<<A,this.words[j]|=k&67108863,A>=18?(A-=18,j+=1,this.words[j]|=k>>>26):A+=8}this._strip()};function l(p,d,m,x){for(var E=0,A=0,j=Math.min(p.length,m),k=d;k<j;k++){var g=p.charCodeAt(k)-48;E*=x,g>=49?A=g-49+10:g>=17?A=g-17+10:A=g,i(g>=0&&A<x,"Invalid character"),E+=A}return E}o.prototype._parseBase=function(d,m,x){this.words=[0],this.length=1;for(var E=0,A=1;A<=67108863;A*=m)E++;E--,A=A/m|0;for(var j=d.length-x,k=j%E,g=Math.min(j,j-k)+x,w=0,P=x;P<g;P+=E)w=l(d,P,P+E,m),this.imuln(A),this.words[0]+w<67108864?this.words[0]+=w:this._iaddn(w);if(k!==0){var ue=1;for(w=l(d,P,d.length,m),P=0;P<k;P++)ue*=m;this.imuln(ue),this.words[0]+w<67108864?this.words[0]+=w:this._iaddn(w)}this._strip()},o.prototype.copy=function(d){d.words=new Array(this.length);for(var m=0;m<this.length;m++)d.words[m]=this.words[m];d.length=this.length,d.negative=this.negative,d.red=this.red};function f(p,d){p.words=d.words,p.length=d.length,p.negative=d.negative,p.red=d.red}if(o.prototype._move=function(d){f(d,this)},o.prototype.clone=function(){var d=new o(null);return this.copy(d),d},o.prototype._expand=function(d){for(;this.length<d;)this.words[this.length++]=0;return this},o.prototype._strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},o.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{o.prototype[Symbol.for("nodejs.util.inspect.custom")]=h}catch{o.prototype.inspect=h}else o.prototype.inspect=h;function h(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var v=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],b=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],y=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];o.prototype.toString=function(d,m){d=d||10,m=m|0||1;var x;if(d===16||d==="hex"){x="";for(var E=0,A=0,j=0;j<this.length;j++){var k=this.words[j],g=((k<<E|A)&16777215).toString(16);A=k>>>24-E&16777215,E+=2,E>=26&&(E-=26,j--),A!==0||j!==this.length-1?x=v[6-g.length]+g+x:x=g+x}for(A!==0&&(x=A.toString(16)+x);x.length%m!==0;)x="0"+x;return this.negative!==0&&(x="-"+x),x}if(d===(d|0)&&d>=2&&d<=36){var w=b[d],P=y[d];x="";var ue=this.clone();for(ue.negative=0;!ue.isZero();){var ie=ue.modrn(P).toString(d);ue=ue.idivn(P),ue.isZero()?x=ie+x:x=v[w-ie.length]+ie+x}for(this.isZero()&&(x="0"+x);x.length%m!==0;)x="0"+x;return this.negative!==0&&(x="-"+x),x}i(!1,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var d=this.words[0];return this.length===2?d+=this.words[1]*67108864:this.length===3&&this.words[2]===1?d+=4503599627370496+this.words[1]*67108864:this.length>2&&i(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-d:d},o.prototype.toJSON=function(){return this.toString(16,2)},a&&(o.prototype.toBuffer=function(d,m){return this.toArrayLike(a,d,m)}),o.prototype.toArray=function(d,m){return this.toArrayLike(Array,d,m)};var S=function(d,m){return d.allocUnsafe?d.allocUnsafe(m):new d(m)};o.prototype.toArrayLike=function(d,m,x){this._strip();var E=this.byteLength(),A=x||Math.max(1,E);i(E<=A,"byte array longer than desired length"),i(A>0,"Requested array length <= 0");var j=S(d,A),k=m==="le"?"LE":"BE";return this["_toArrayLike"+k](j,E),j},o.prototype._toArrayLikeLE=function(d,m){for(var x=0,E=0,A=0,j=0;A<this.length;A++){var k=this.words[A]<<j|E;d[x++]=k&255,x<d.length&&(d[x++]=k>>8&255),x<d.length&&(d[x++]=k>>16&255),j===6?(x<d.length&&(d[x++]=k>>24&255),E=0,j=0):(E=k>>>24,j+=2)}if(x<d.length)for(d[x++]=E;x<d.length;)d[x++]=0},o.prototype._toArrayLikeBE=function(d,m){for(var x=d.length-1,E=0,A=0,j=0;A<this.length;A++){var k=this.words[A]<<j|E;d[x--]=k&255,x>=0&&(d[x--]=k>>8&255),x>=0&&(d[x--]=k>>16&255),j===6?(x>=0&&(d[x--]=k>>24&255),E=0,j=0):(E=k>>>24,j+=2)}if(x>=0)for(d[x--]=E;x>=0;)d[x--]=0},Math.clz32?o.prototype._countBits=function(d){return 32-Math.clz32(d)}:o.prototype._countBits=function(d){var m=d,x=0;return m>=4096&&(x+=13,m>>>=13),m>=64&&(x+=7,m>>>=7),m>=8&&(x+=4,m>>>=4),m>=2&&(x+=2,m>>>=2),x+m},o.prototype._zeroBits=function(d){if(d===0)return 26;var m=d,x=0;return m&8191||(x+=13,m>>>=13),m&127||(x+=7,m>>>=7),m&15||(x+=4,m>>>=4),m&3||(x+=2,m>>>=2),m&1||x++,x},o.prototype.bitLength=function(){var d=this.words[this.length-1],m=this._countBits(d);return(this.length-1)*26+m};function C(p){for(var d=new Array(p.bitLength()),m=0;m<d.length;m++){var x=m/26|0,E=m%26;d[m]=p.words[x]>>>E&1}return d}o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var d=0,m=0;m<this.length;m++){var x=this._zeroBits(this.words[m]);if(d+=x,x!==26)break}return d},o.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},o.prototype.toTwos=function(d){return this.negative!==0?this.abs().inotn(d).iaddn(1):this.clone()},o.prototype.fromTwos=function(d){return this.testn(d-1)?this.notn(d).iaddn(1).ineg():this.clone()},o.prototype.isNeg=function(){return this.negative!==0},o.prototype.neg=function(){return this.clone().ineg()},o.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},o.prototype.iuor=function(d){for(;this.length<d.length;)this.words[this.length++]=0;for(var m=0;m<d.length;m++)this.words[m]=this.words[m]|d.words[m];return this._strip()},o.prototype.ior=function(d){return i((this.negative|d.negative)===0),this.iuor(d)},o.prototype.or=function(d){return this.length>d.length?this.clone().ior(d):d.clone().ior(this)},o.prototype.uor=function(d){return this.length>d.length?this.clone().iuor(d):d.clone().iuor(this)},o.prototype.iuand=function(d){var m;this.length>d.length?m=d:m=this;for(var x=0;x<m.length;x++)this.words[x]=this.words[x]&d.words[x];return this.length=m.length,this._strip()},o.prototype.iand=function(d){return i((this.negative|d.negative)===0),this.iuand(d)},o.prototype.and=function(d){return this.length>d.length?this.clone().iand(d):d.clone().iand(this)},o.prototype.uand=function(d){return this.length>d.length?this.clone().iuand(d):d.clone().iuand(this)},o.prototype.iuxor=function(d){var m,x;this.length>d.length?(m=this,x=d):(m=d,x=this);for(var E=0;E<x.length;E++)this.words[E]=m.words[E]^x.words[E];if(this!==m)for(;E<m.length;E++)this.words[E]=m.words[E];return this.length=m.length,this._strip()},o.prototype.ixor=function(d){return i((this.negative|d.negative)===0),this.iuxor(d)},o.prototype.xor=function(d){return this.length>d.length?this.clone().ixor(d):d.clone().ixor(this)},o.prototype.uxor=function(d){return this.length>d.length?this.clone().iuxor(d):d.clone().iuxor(this)},o.prototype.inotn=function(d){i(typeof d=="number"&&d>=0);var m=Math.ceil(d/26)|0,x=d%26;this._expand(m),x>0&&m--;for(var E=0;E<m;E++)this.words[E]=~this.words[E]&67108863;return x>0&&(this.words[E]=~this.words[E]&67108863>>26-x),this._strip()},o.prototype.notn=function(d){return this.clone().inotn(d)},o.prototype.setn=function(d,m){i(typeof d=="number"&&d>=0);var x=d/26|0,E=d%26;return this._expand(x+1),m?this.words[x]=this.words[x]|1<<E:this.words[x]=this.words[x]&~(1<<E),this._strip()},o.prototype.iadd=function(d){var m;if(this.negative!==0&&d.negative===0)return this.negative=0,m=this.isub(d),this.negative^=1,this._normSign();if(this.negative===0&&d.negative!==0)return d.negative=0,m=this.isub(d),d.negative=1,m._normSign();var x,E;this.length>d.length?(x=this,E=d):(x=d,E=this);for(var A=0,j=0;j<E.length;j++)m=(x.words[j]|0)+(E.words[j]|0)+A,this.words[j]=m&67108863,A=m>>>26;for(;A!==0&&j<x.length;j++)m=(x.words[j]|0)+A,this.words[j]=m&67108863,A=m>>>26;if(this.length=x.length,A!==0)this.words[this.length]=A,this.length++;else if(x!==this)for(;j<x.length;j++)this.words[j]=x.words[j];return this},o.prototype.add=function(d){var m;return d.negative!==0&&this.negative===0?(d.negative=0,m=this.sub(d),d.negative^=1,m):d.negative===0&&this.negative!==0?(this.negative=0,m=d.sub(this),this.negative=1,m):this.length>d.length?this.clone().iadd(d):d.clone().iadd(this)},o.prototype.isub=function(d){if(d.negative!==0){d.negative=0;var m=this.iadd(d);return d.negative=1,m._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(d),this.negative=1,this._normSign();var x=this.cmp(d);if(x===0)return this.negative=0,this.length=1,this.words[0]=0,this;var E,A;x>0?(E=this,A=d):(E=d,A=this);for(var j=0,k=0;k<A.length;k++)m=(E.words[k]|0)-(A.words[k]|0)+j,j=m>>26,this.words[k]=m&67108863;for(;j!==0&&k<E.length;k++)m=(E.words[k]|0)+j,j=m>>26,this.words[k]=m&67108863;if(j===0&&k<E.length&&E!==this)for(;k<E.length;k++)this.words[k]=E.words[k];return this.length=Math.max(this.length,k),E!==this&&(this.negative=1),this._strip()},o.prototype.sub=function(d){return this.clone().isub(d)};function O(p,d,m){m.negative=d.negative^p.negative;var x=p.length+d.length|0;m.length=x,x=x-1|0;var E=p.words[0]|0,A=d.words[0]|0,j=E*A,k=j&67108863,g=j/67108864|0;m.words[0]=k;for(var w=1;w<x;w++){for(var P=g>>>26,ue=g&67108863,ie=Math.min(w,d.length-1),fe=Math.max(0,w-p.length+1);fe<=ie;fe++){var ve=w-fe|0;E=p.words[ve]|0,A=d.words[fe]|0,j=E*A+ue,P+=j/67108864|0,ue=j&67108863}m.words[w]=ue|0,g=P|0}return g!==0?m.words[w]=g|0:m.length--,m._strip()}var I=function(d,m,x){var E=d.words,A=m.words,j=x.words,k=0,g,w,P,ue=E[0]|0,ie=ue&8191,fe=ue>>>13,ve=E[1]|0,Ce=ve&8191,N=ve>>>13,F=E[2]|0,G=F&8191,ee=F>>>13,Z=E[3]|0,q=Z&8191,he=Z>>>13,Y=E[4]|0,X=Y&8191,B=Y>>>13,se=E[5]|0,me=se&8191,de=se>>>13,Se=E[6]|0,Ie=Se&8191,Ue=Se>>>13,Je=E[7]|0,Pe=Je&8191,Ge=Je>>>13,nt=E[8]|0,et=nt&8191,Ot=nt>>>13,$t=E[9]|0,Ke=$t&8191,pt=$t>>>13,ut=A[0]|0,tt=ut&8191,ot=ut>>>13,vt=A[1]|0,st=vt&8191,bt=vt>>>13,Dt=A[2]|0,mt=Dt&8191,It=Dt>>>13,Ut=A[3]|0,Ye=Ut&8191,Rt=Ut>>>13,Ft=A[4]|0,$=Ft&8191,T=Ft>>>13,M=A[5]|0,K=M&8191,ae=M>>>13,be=A[6]|0,_e=be&8191,it=be>>>13,xt=A[7]|0,rt=xt&8191,Q=xt>>>13,Ee=A[8]|0,ke=Ee&8191,Ze=Ee>>>13,ft=A[9]|0,Qe=ft&8191,at=ft>>>13;x.negative=d.negative^m.negative,x.length=19,g=Math.imul(ie,tt),w=Math.imul(ie,ot),w=w+Math.imul(fe,tt)|0,P=Math.imul(fe,ot);var Tt=(k+g|0)+((w&8191)<<13)|0;k=(P+(w>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,g=Math.imul(Ce,tt),w=Math.imul(Ce,ot),w=w+Math.imul(N,tt)|0,P=Math.imul(N,ot),g=g+Math.imul(ie,st)|0,w=w+Math.imul(ie,bt)|0,w=w+Math.imul(fe,st)|0,P=P+Math.imul(fe,bt)|0;var or=(k+g|0)+((w&8191)<<13)|0;k=(P+(w>>>13)|0)+(or>>>26)|0,or&=67108863,g=Math.imul(G,tt),w=Math.imul(G,ot),w=w+Math.imul(ee,tt)|0,P=Math.imul(ee,ot),g=g+Math.imul(Ce,st)|0,w=w+Math.imul(Ce,bt)|0,w=w+Math.imul(N,st)|0,P=P+Math.imul(N,bt)|0,g=g+Math.imul(ie,mt)|0,w=w+Math.imul(ie,It)|0,w=w+Math.imul(fe,mt)|0,P=P+Math.imul(fe,It)|0;var Ht=(k+g|0)+((w&8191)<<13)|0;k=(P+(w>>>13)|0)+(Ht>>>26)|0,Ht&=67108863,g=Math.imul(q,tt),w=Math.imul(q,ot),w=w+Math.imul(he,tt)|0,P=Math.imul(he,ot),g=g+Math.imul(G,st)|0,w=w+Math.imul(G,bt)|0,w=w+Math.imul(ee,st)|0,P=P+Math.imul(ee,bt)|0,g=g+Math.imul(Ce,mt)|0,w=w+Math.imul(Ce,It)|0,w=w+Math.imul(N,mt)|0,P=P+Math.imul(N,It)|0,g=g+Math.imul(ie,Ye)|0,w=w+Math.imul(ie,Rt)|0,w=w+Math.imul(fe,Ye)|0,P=P+Math.imul(fe,Rt)|0;var Yt=(k+g|0)+((w&8191)<<13)|0;k=(P+(w>>>13)|0)+(Yt>>>26)|0,Yt&=67108863,g=Math.imul(X,tt),w=Math.imul(X,ot),w=w+Math.imul(B,tt)|0,P=Math.imul(B,ot),g=g+Math.imul(q,st)|0,w=w+Math.imul(q,bt)|0,w=w+Math.imul(he,st)|0,P=P+Math.imul(he,bt)|0,g=g+Math.imul(G,mt)|0,w=w+Math.imul(G,It)|0,w=w+Math.imul(ee,mt)|0,P=P+Math.imul(ee,It)|0,g=g+Math.imul(Ce,Ye)|0,w=w+Math.imul(Ce,Rt)|0,w=w+Math.imul(N,Ye)|0,P=P+Math.imul(N,Rt)|0,g=g+Math.imul(ie,$)|0,w=w+Math.imul(ie,T)|0,w=w+Math.imul(fe,$)|0,P=P+Math.imul(fe,T)|0;var br=(k+g|0)+((w&8191)<<13)|0;k=(P+(w>>>13)|0)+(br>>>26)|0,br&=67108863,g=Math.imul(me,tt),w=Math.imul(me,ot),w=w+Math.imul(de,tt)|0,P=Math.imul(de,ot),g=g+Math.imul(X,st)|0,w=w+Math.imul(X,bt)|0,w=w+Math.imul(B,st)|0,P=P+Math.imul(B,bt)|0,g=g+Math.imul(q,mt)|0,w=w+Math.imul(q,It)|0,w=w+Math.imul(he,mt)|0,P=P+Math.imul(he,It)|0,g=g+Math.imul(G,Ye)|0,w=w+Math.imul(G,Rt)|0,w=w+Math.imul(ee,Ye)|0,P=P+Math.imul(ee,Rt)|0,g=g+Math.imul(Ce,$)|0,w=w+Math.imul(Ce,T)|0,w=w+Math.imul(N,$)|0,P=P+Math.imul(N,T)|0,g=g+Math.imul(ie,K)|0,w=w+Math.imul(ie,ae)|0,w=w+Math.imul(fe,K)|0,P=P+Math.imul(fe,ae)|0;var Gr=(k+g|0)+((w&8191)<<13)|0;k=(P+(w>>>13)|0)+(Gr>>>26)|0,Gr&=67108863,g=Math.imul(Ie,tt),w=Math.imul(Ie,ot),w=w+Math.imul(Ue,tt)|0,P=Math.imul(Ue,ot),g=g+Math.imul(me,st)|0,w=w+Math.imul(me,bt)|0,w=w+Math.imul(de,st)|0,P=P+Math.imul(de,bt)|0,g=g+Math.imul(X,mt)|0,w=w+Math.imul(X,It)|0,w=w+Math.imul(B,mt)|0,P=P+Math.imul(B,It)|0,g=g+Math.imul(q,Ye)|0,w=w+Math.imul(q,Rt)|0,w=w+Math.imul(he,Ye)|0,P=P+Math.imul(he,Rt)|0,g=g+Math.imul(G,$)|0,w=w+Math.imul(G,T)|0,w=w+Math.imul(ee,$)|0,P=P+Math.imul(ee,T)|0,g=g+Math.imul(Ce,K)|0,w=w+Math.imul(Ce,ae)|0,w=w+Math.imul(N,K)|0,P=P+Math.imul(N,ae)|0,g=g+Math.imul(ie,_e)|0,w=w+Math.imul(ie,it)|0,w=w+Math.imul(fe,_e)|0,P=P+Math.imul(fe,it)|0;var _r=(k+g|0)+((w&8191)<<13)|0;k=(P+(w>>>13)|0)+(_r>>>26)|0,_r&=67108863,g=Math.imul(Pe,tt),w=Math.imul(Pe,ot),w=w+Math.imul(Ge,tt)|0,P=Math.imul(Ge,ot),g=g+Math.imul(Ie,st)|0,w=w+Math.imul(Ie,bt)|0,w=w+Math.imul(Ue,st)|0,P=P+Math.imul(Ue,bt)|0,g=g+Math.imul(me,mt)|0,w=w+Math.imul(me,It)|0,w=w+Math.imul(de,mt)|0,P=P+Math.imul(de,It)|0,g=g+Math.imul(X,Ye)|0,w=w+Math.imul(X,Rt)|0,w=w+Math.imul(B,Ye)|0,P=P+Math.imul(B,Rt)|0,g=g+Math.imul(q,$)|0,w=w+Math.imul(q,T)|0,w=w+Math.imul(he,$)|0,P=P+Math.imul(he,T)|0,g=g+Math.imul(G,K)|0,w=w+Math.imul(G,ae)|0,w=w+Math.imul(ee,K)|0,P=P+Math.imul(ee,ae)|0,g=g+Math.imul(Ce,_e)|0,w=w+Math.imul(Ce,it)|0,w=w+Math.imul(N,_e)|0,P=P+Math.imul(N,it)|0,g=g+Math.imul(ie,rt)|0,w=w+Math.imul(ie,Q)|0,w=w+Math.imul(fe,rt)|0,P=P+Math.imul(fe,Q)|0;var ar=(k+g|0)+((w&8191)<<13)|0;k=(P+(w>>>13)|0)+(ar>>>26)|0,ar&=67108863,g=Math.imul(et,tt),w=Math.imul(et,ot),w=w+Math.imul(Ot,tt)|0,P=Math.imul(Ot,ot),g=g+Math.imul(Pe,st)|0,w=w+Math.imul(Pe,bt)|0,w=w+Math.imul(Ge,st)|0,P=P+Math.imul(Ge,bt)|0,g=g+Math.imul(Ie,mt)|0,w=w+Math.imul(Ie,It)|0,w=w+Math.imul(Ue,mt)|0,P=P+Math.imul(Ue,It)|0,g=g+Math.imul(me,Ye)|0,w=w+Math.imul(me,Rt)|0,w=w+Math.imul(de,Ye)|0,P=P+Math.imul(de,Rt)|0,g=g+Math.imul(X,$)|0,w=w+Math.imul(X,T)|0,w=w+Math.imul(B,$)|0,P=P+Math.imul(B,T)|0,g=g+Math.imul(q,K)|0,w=w+Math.imul(q,ae)|0,w=w+Math.imul(he,K)|0,P=P+Math.imul(he,ae)|0,g=g+Math.imul(G,_e)|0,w=w+Math.imul(G,it)|0,w=w+Math.imul(ee,_e)|0,P=P+Math.imul(ee,it)|0,g=g+Math.imul(Ce,rt)|0,w=w+Math.imul(Ce,Q)|0,w=w+Math.imul(N,rt)|0,P=P+Math.imul(N,Q)|0,g=g+Math.imul(ie,ke)|0,w=w+Math.imul(ie,Ze)|0,w=w+Math.imul(fe,ke)|0,P=P+Math.imul(fe,Ze)|0;var Wr=(k+g|0)+((w&8191)<<13)|0;k=(P+(w>>>13)|0)+(Wr>>>26)|0,Wr&=67108863,g=Math.imul(Ke,tt),w=Math.imul(Ke,ot),w=w+Math.imul(pt,tt)|0,P=Math.imul(pt,ot),g=g+Math.imul(et,st)|0,w=w+Math.imul(et,bt)|0,w=w+Math.imul(Ot,st)|0,P=P+Math.imul(Ot,bt)|0,g=g+Math.imul(Pe,mt)|0,w=w+Math.imul(Pe,It)|0,w=w+Math.imul(Ge,mt)|0,P=P+Math.imul(Ge,It)|0,g=g+Math.imul(Ie,Ye)|0,w=w+Math.imul(Ie,Rt)|0,w=w+Math.imul(Ue,Ye)|0,P=P+Math.imul(Ue,Rt)|0,g=g+Math.imul(me,$)|0,w=w+Math.imul(me,T)|0,w=w+Math.imul(de,$)|0,P=P+Math.imul(de,T)|0,g=g+Math.imul(X,K)|0,w=w+Math.imul(X,ae)|0,w=w+Math.imul(B,K)|0,P=P+Math.imul(B,ae)|0,g=g+Math.imul(q,_e)|0,w=w+Math.imul(q,it)|0,w=w+Math.imul(he,_e)|0,P=P+Math.imul(he,it)|0,g=g+Math.imul(G,rt)|0,w=w+Math.imul(G,Q)|0,w=w+Math.imul(ee,rt)|0,P=P+Math.imul(ee,Q)|0,g=g+Math.imul(Ce,ke)|0,w=w+Math.imul(Ce,Ze)|0,w=w+Math.imul(N,ke)|0,P=P+Math.imul(N,Ze)|0,g=g+Math.imul(ie,Qe)|0,w=w+Math.imul(ie,at)|0,w=w+Math.imul(fe,Qe)|0,P=P+Math.imul(fe,at)|0;var ai=(k+g|0)+((w&8191)<<13)|0;k=(P+(w>>>13)|0)+(ai>>>26)|0,ai&=67108863,g=Math.imul(Ke,st),w=Math.imul(Ke,bt),w=w+Math.imul(pt,st)|0,P=Math.imul(pt,bt),g=g+Math.imul(et,mt)|0,w=w+Math.imul(et,It)|0,w=w+Math.imul(Ot,mt)|0,P=P+Math.imul(Ot,It)|0,g=g+Math.imul(Pe,Ye)|0,w=w+Math.imul(Pe,Rt)|0,w=w+Math.imul(Ge,Ye)|0,P=P+Math.imul(Ge,Rt)|0,g=g+Math.imul(Ie,$)|0,w=w+Math.imul(Ie,T)|0,w=w+Math.imul(Ue,$)|0,P=P+Math.imul(Ue,T)|0,g=g+Math.imul(me,K)|0,w=w+Math.imul(me,ae)|0,w=w+Math.imul(de,K)|0,P=P+Math.imul(de,ae)|0,g=g+Math.imul(X,_e)|0,w=w+Math.imul(X,it)|0,w=w+Math.imul(B,_e)|0,P=P+Math.imul(B,it)|0,g=g+Math.imul(q,rt)|0,w=w+Math.imul(q,Q)|0,w=w+Math.imul(he,rt)|0,P=P+Math.imul(he,Q)|0,g=g+Math.imul(G,ke)|0,w=w+Math.imul(G,Ze)|0,w=w+Math.imul(ee,ke)|0,P=P+Math.imul(ee,Ze)|0,g=g+Math.imul(Ce,Qe)|0,w=w+Math.imul(Ce,at)|0,w=w+Math.imul(N,Qe)|0,P=P+Math.imul(N,at)|0;var xn=(k+g|0)+((w&8191)<<13)|0;k=(P+(w>>>13)|0)+(xn>>>26)|0,xn&=67108863,g=Math.imul(Ke,mt),w=Math.imul(Ke,It),w=w+Math.imul(pt,mt)|0,P=Math.imul(pt,It),g=g+Math.imul(et,Ye)|0,w=w+Math.imul(et,Rt)|0,w=w+Math.imul(Ot,Ye)|0,P=P+Math.imul(Ot,Rt)|0,g=g+Math.imul(Pe,$)|0,w=w+Math.imul(Pe,T)|0,w=w+Math.imul(Ge,$)|0,P=P+Math.imul(Ge,T)|0,g=g+Math.imul(Ie,K)|0,w=w+Math.imul(Ie,ae)|0,w=w+Math.imul(Ue,K)|0,P=P+Math.imul(Ue,ae)|0,g=g+Math.imul(me,_e)|0,w=w+Math.imul(me,it)|0,w=w+Math.imul(de,_e)|0,P=P+Math.imul(de,it)|0,g=g+Math.imul(X,rt)|0,w=w+Math.imul(X,Q)|0,w=w+Math.imul(B,rt)|0,P=P+Math.imul(B,Q)|0,g=g+Math.imul(q,ke)|0,w=w+Math.imul(q,Ze)|0,w=w+Math.imul(he,ke)|0,P=P+Math.imul(he,Ze)|0,g=g+Math.imul(G,Qe)|0,w=w+Math.imul(G,at)|0,w=w+Math.imul(ee,Qe)|0,P=P+Math.imul(ee,at)|0;var ci=(k+g|0)+((w&8191)<<13)|0;k=(P+(w>>>13)|0)+(ci>>>26)|0,ci&=67108863,g=Math.imul(Ke,Ye),w=Math.imul(Ke,Rt),w=w+Math.imul(pt,Ye)|0,P=Math.imul(pt,Rt),g=g+Math.imul(et,$)|0,w=w+Math.imul(et,T)|0,w=w+Math.imul(Ot,$)|0,P=P+Math.imul(Ot,T)|0,g=g+Math.imul(Pe,K)|0,w=w+Math.imul(Pe,ae)|0,w=w+Math.imul(Ge,K)|0,P=P+Math.imul(Ge,ae)|0,g=g+Math.imul(Ie,_e)|0,w=w+Math.imul(Ie,it)|0,w=w+Math.imul(Ue,_e)|0,P=P+Math.imul(Ue,it)|0,g=g+Math.imul(me,rt)|0,w=w+Math.imul(me,Q)|0,w=w+Math.imul(de,rt)|0,P=P+Math.imul(de,Q)|0,g=g+Math.imul(X,ke)|0,w=w+Math.imul(X,Ze)|0,w=w+Math.imul(B,ke)|0,P=P+Math.imul(B,Ze)|0,g=g+Math.imul(q,Qe)|0,w=w+Math.imul(q,at)|0,w=w+Math.imul(he,Qe)|0,P=P+Math.imul(he,at)|0;var fs=(k+g|0)+((w&8191)<<13)|0;k=(P+(w>>>13)|0)+(fs>>>26)|0,fs&=67108863,g=Math.imul(Ke,$),w=Math.imul(Ke,T),w=w+Math.imul(pt,$)|0,P=Math.imul(pt,T),g=g+Math.imul(et,K)|0,w=w+Math.imul(et,ae)|0,w=w+Math.imul(Ot,K)|0,P=P+Math.imul(Ot,ae)|0,g=g+Math.imul(Pe,_e)|0,w=w+Math.imul(Pe,it)|0,w=w+Math.imul(Ge,_e)|0,P=P+Math.imul(Ge,it)|0,g=g+Math.imul(Ie,rt)|0,w=w+Math.imul(Ie,Q)|0,w=w+Math.imul(Ue,rt)|0,P=P+Math.imul(Ue,Q)|0,g=g+Math.imul(me,ke)|0,w=w+Math.imul(me,Ze)|0,w=w+Math.imul(de,ke)|0,P=P+Math.imul(de,Ze)|0,g=g+Math.imul(X,Qe)|0,w=w+Math.imul(X,at)|0,w=w+Math.imul(B,Qe)|0,P=P+Math.imul(B,at)|0;var ds=(k+g|0)+((w&8191)<<13)|0;k=(P+(w>>>13)|0)+(ds>>>26)|0,ds&=67108863,g=Math.imul(Ke,K),w=Math.imul(Ke,ae),w=w+Math.imul(pt,K)|0,P=Math.imul(pt,ae),g=g+Math.imul(et,_e)|0,w=w+Math.imul(et,it)|0,w=w+Math.imul(Ot,_e)|0,P=P+Math.imul(Ot,it)|0,g=g+Math.imul(Pe,rt)|0,w=w+Math.imul(Pe,Q)|0,w=w+Math.imul(Ge,rt)|0,P=P+Math.imul(Ge,Q)|0,g=g+Math.imul(Ie,ke)|0,w=w+Math.imul(Ie,Ze)|0,w=w+Math.imul(Ue,ke)|0,P=P+Math.imul(Ue,Ze)|0,g=g+Math.imul(me,Qe)|0,w=w+Math.imul(me,at)|0,w=w+Math.imul(de,Qe)|0,P=P+Math.imul(de,at)|0;var ui=(k+g|0)+((w&8191)<<13)|0;k=(P+(w>>>13)|0)+(ui>>>26)|0,ui&=67108863,g=Math.imul(Ke,_e),w=Math.imul(Ke,it),w=w+Math.imul(pt,_e)|0,P=Math.imul(pt,it),g=g+Math.imul(et,rt)|0,w=w+Math.imul(et,Q)|0,w=w+Math.imul(Ot,rt)|0,P=P+Math.imul(Ot,Q)|0,g=g+Math.imul(Pe,ke)|0,w=w+Math.imul(Pe,Ze)|0,w=w+Math.imul(Ge,ke)|0,P=P+Math.imul(Ge,Ze)|0,g=g+Math.imul(Ie,Qe)|0,w=w+Math.imul(Ie,at)|0,w=w+Math.imul(Ue,Qe)|0,P=P+Math.imul(Ue,at)|0;var hs=(k+g|0)+((w&8191)<<13)|0;k=(P+(w>>>13)|0)+(hs>>>26)|0,hs&=67108863,g=Math.imul(Ke,rt),w=Math.imul(Ke,Q),w=w+Math.imul(pt,rt)|0,P=Math.imul(pt,Q),g=g+Math.imul(et,ke)|0,w=w+Math.imul(et,Ze)|0,w=w+Math.imul(Ot,ke)|0,P=P+Math.imul(Ot,Ze)|0,g=g+Math.imul(Pe,Qe)|0,w=w+Math.imul(Pe,at)|0,w=w+Math.imul(Ge,Qe)|0,P=P+Math.imul(Ge,at)|0;var ps=(k+g|0)+((w&8191)<<13)|0;k=(P+(w>>>13)|0)+(ps>>>26)|0,ps&=67108863,g=Math.imul(Ke,ke),w=Math.imul(Ke,Ze),w=w+Math.imul(pt,ke)|0,P=Math.imul(pt,Ze),g=g+Math.imul(et,Qe)|0,w=w+Math.imul(et,at)|0,w=w+Math.imul(Ot,Qe)|0,P=P+Math.imul(Ot,at)|0;var W=(k+g|0)+((w&8191)<<13)|0;k=(P+(w>>>13)|0)+(W>>>26)|0,W&=67108863,g=Math.imul(Ke,Qe),w=Math.imul(Ke,at),w=w+Math.imul(pt,Qe)|0,P=Math.imul(pt,at);var oe=(k+g|0)+((w&8191)<<13)|0;return k=(P+(w>>>13)|0)+(oe>>>26)|0,oe&=67108863,j[0]=Tt,j[1]=or,j[2]=Ht,j[3]=Yt,j[4]=br,j[5]=Gr,j[6]=_r,j[7]=ar,j[8]=Wr,j[9]=ai,j[10]=xn,j[11]=ci,j[12]=fs,j[13]=ds,j[14]=ui,j[15]=hs,j[16]=ps,j[17]=W,j[18]=oe,k!==0&&(j[19]=k,x.length++),x};Math.imul||(I=O);function U(p,d,m){m.negative=d.negative^p.negative,m.length=p.length+d.length;for(var x=0,E=0,A=0;A<m.length-1;A++){var j=E;E=0;for(var k=x&67108863,g=Math.min(A,d.length-1),w=Math.max(0,A-p.length+1);w<=g;w++){var P=A-w,ue=p.words[P]|0,ie=d.words[w]|0,fe=ue*ie,ve=fe&67108863;j=j+(fe/67108864|0)|0,ve=ve+k|0,k=ve&67108863,j=j+(ve>>>26)|0,E+=j>>>26,j&=67108863}m.words[A]=k,x=j,j=E}return x!==0?m.words[A]=x:m.length--,m._strip()}function D(p,d,m){return U(p,d,m)}o.prototype.mulTo=function(d,m){var x,E=this.length+d.length;return this.length===10&&d.length===10?x=I(this,d,m):E<63?x=O(this,d,m):E<1024?x=U(this,d,m):x=D(this,d,m),x},o.prototype.mul=function(d){var m=new o(null);return m.words=new Array(this.length+d.length),this.mulTo(d,m)},o.prototype.mulf=function(d){var m=new o(null);return m.words=new Array(this.length+d.length),D(this,d,m)},o.prototype.imul=function(d){return this.clone().mulTo(d,this)},o.prototype.imuln=function(d){var m=d<0;m&&(d=-d),i(typeof d=="number"),i(d<67108864);for(var x=0,E=0;E<this.length;E++){var A=(this.words[E]|0)*d,j=(A&67108863)+(x&67108863);x>>=26,x+=A/67108864|0,x+=j>>>26,this.words[E]=j&67108863}return x!==0&&(this.words[E]=x,this.length++),this.length=d===0?1:this.length,m?this.ineg():this},o.prototype.muln=function(d){return this.clone().imuln(d)},o.prototype.sqr=function(){return this.mul(this)},o.prototype.isqr=function(){return this.imul(this.clone())},o.prototype.pow=function(d){var m=C(d);if(m.length===0)return new o(1);for(var x=this,E=0;E<m.length&&m[E]===0;E++,x=x.sqr());if(++E<m.length)for(var A=x.sqr();E<m.length;E++,A=A.sqr())m[E]!==0&&(x=x.mul(A));return x},o.prototype.iushln=function(d){i(typeof d=="number"&&d>=0);var m=d%26,x=(d-m)/26,E=67108863>>>26-m<<26-m,A;if(m!==0){var j=0;for(A=0;A<this.length;A++){var k=this.words[A]&E,g=(this.words[A]|0)-k<<m;this.words[A]=g|j,j=k>>>26-m}j&&(this.words[A]=j,this.length++)}if(x!==0){for(A=this.length-1;A>=0;A--)this.words[A+x]=this.words[A];for(A=0;A<x;A++)this.words[A]=0;this.length+=x}return this._strip()},o.prototype.ishln=function(d){return i(this.negative===0),this.iushln(d)},o.prototype.iushrn=function(d,m,x){i(typeof d=="number"&&d>=0);var E;m?E=(m-m%26)/26:E=0;var A=d%26,j=Math.min((d-A)/26,this.length),k=67108863^67108863>>>A<<A,g=x;if(E-=j,E=Math.max(0,E),g){for(var w=0;w<j;w++)g.words[w]=this.words[w];g.length=j}if(j!==0)if(this.length>j)for(this.length-=j,w=0;w<this.length;w++)this.words[w]=this.words[w+j];else this.words[0]=0,this.length=1;var P=0;for(w=this.length-1;w>=0&&(P!==0||w>=E);w--){var ue=this.words[w]|0;this.words[w]=P<<26-A|ue>>>A,P=ue&k}return g&&P!==0&&(g.words[g.length++]=P),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},o.prototype.ishrn=function(d,m,x){return i(this.negative===0),this.iushrn(d,m,x)},o.prototype.shln=function(d){return this.clone().ishln(d)},o.prototype.ushln=function(d){return this.clone().iushln(d)},o.prototype.shrn=function(d){return this.clone().ishrn(d)},o.prototype.ushrn=function(d){return this.clone().iushrn(d)},o.prototype.testn=function(d){i(typeof d=="number"&&d>=0);var m=d%26,x=(d-m)/26,E=1<<m;if(this.length<=x)return!1;var A=this.words[x];return!!(A&E)},o.prototype.imaskn=function(d){i(typeof d=="number"&&d>=0);var m=d%26,x=(d-m)/26;if(i(this.negative===0,"imaskn works only with positive numbers"),this.length<=x)return this;if(m!==0&&x++,this.length=Math.min(x,this.length),m!==0){var E=67108863^67108863>>>m<<m;this.words[this.length-1]&=E}return this._strip()},o.prototype.maskn=function(d){return this.clone().imaskn(d)},o.prototype.iaddn=function(d){return i(typeof d=="number"),i(d<67108864),d<0?this.isubn(-d):this.negative!==0?this.length===1&&(this.words[0]|0)<=d?(this.words[0]=d-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(d),this.negative=1,this):this._iaddn(d)},o.prototype._iaddn=function(d){this.words[0]+=d;for(var m=0;m<this.length&&this.words[m]>=67108864;m++)this.words[m]-=67108864,m===this.length-1?this.words[m+1]=1:this.words[m+1]++;return this.length=Math.max(this.length,m+1),this},o.prototype.isubn=function(d){if(i(typeof d=="number"),i(d<67108864),d<0)return this.iaddn(-d);if(this.negative!==0)return this.negative=0,this.iaddn(d),this.negative=1,this;if(this.words[0]-=d,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var m=0;m<this.length&&this.words[m]<0;m++)this.words[m]+=67108864,this.words[m+1]-=1;return this._strip()},o.prototype.addn=function(d){return this.clone().iaddn(d)},o.prototype.subn=function(d){return this.clone().isubn(d)},o.prototype.iabs=function(){return this.negative=0,this},o.prototype.abs=function(){return this.clone().iabs()},o.prototype._ishlnsubmul=function(d,m,x){var E=d.length+x,A;this._expand(E);var j,k=0;for(A=0;A<d.length;A++){j=(this.words[A+x]|0)+k;var g=(d.words[A]|0)*m;j-=g&67108863,k=(j>>26)-(g/67108864|0),this.words[A+x]=j&67108863}for(;A<this.length-x;A++)j=(this.words[A+x]|0)+k,k=j>>26,this.words[A+x]=j&67108863;if(k===0)return this._strip();for(i(k===-1),k=0,A=0;A<this.length;A++)j=-(this.words[A]|0)+k,k=j>>26,this.words[A]=j&67108863;return this.negative=1,this._strip()},o.prototype._wordDiv=function(d,m){var x=this.length-d.length,E=this.clone(),A=d,j=A.words[A.length-1]|0,k=this._countBits(j);x=26-k,x!==0&&(A=A.ushln(x),E.iushln(x),j=A.words[A.length-1]|0);var g=E.length-A.length,w;if(m!=="mod"){w=new o(null),w.length=g+1,w.words=new Array(w.length);for(var P=0;P<w.length;P++)w.words[P]=0}var ue=E.clone()._ishlnsubmul(A,1,g);ue.negative===0&&(E=ue,w&&(w.words[g]=1));for(var ie=g-1;ie>=0;ie--){var fe=(E.words[A.length+ie]|0)*67108864+(E.words[A.length+ie-1]|0);for(fe=Math.min(fe/j|0,67108863),E._ishlnsubmul(A,fe,ie);E.negative!==0;)fe--,E.negative=0,E._ishlnsubmul(A,1,ie),E.isZero()||(E.negative^=1);w&&(w.words[ie]=fe)}return w&&w._strip(),E._strip(),m!=="div"&&x!==0&&E.iushrn(x),{div:w||null,mod:E}},o.prototype.divmod=function(d,m,x){if(i(!d.isZero()),this.isZero())return{div:new o(0),mod:new o(0)};var E,A,j;return this.negative!==0&&d.negative===0?(j=this.neg().divmod(d,m),m!=="mod"&&(E=j.div.neg()),m!=="div"&&(A=j.mod.neg(),x&&A.negative!==0&&A.iadd(d)),{div:E,mod:A}):this.negative===0&&d.negative!==0?(j=this.divmod(d.neg(),m),m!=="mod"&&(E=j.div.neg()),{div:E,mod:j.mod}):this.negative&d.negative?(j=this.neg().divmod(d.neg(),m),m!=="div"&&(A=j.mod.neg(),x&&A.negative!==0&&A.isub(d)),{div:j.div,mod:A}):d.length>this.length||this.cmp(d)<0?{div:new o(0),mod:this}:d.length===1?m==="div"?{div:this.divn(d.words[0]),mod:null}:m==="mod"?{div:null,mod:new o(this.modrn(d.words[0]))}:{div:this.divn(d.words[0]),mod:new o(this.modrn(d.words[0]))}:this._wordDiv(d,m)},o.prototype.div=function(d){return this.divmod(d,"div",!1).div},o.prototype.mod=function(d){return this.divmod(d,"mod",!1).mod},o.prototype.umod=function(d){return this.divmod(d,"mod",!0).mod},o.prototype.divRound=function(d){var m=this.divmod(d);if(m.mod.isZero())return m.div;var x=m.div.negative!==0?m.mod.isub(d):m.mod,E=d.ushrn(1),A=d.andln(1),j=x.cmp(E);return j<0||A===1&&j===0?m.div:m.div.negative!==0?m.div.isubn(1):m.div.iaddn(1)},o.prototype.modrn=function(d){var m=d<0;m&&(d=-d),i(d<=67108863);for(var x=(1<<26)%d,E=0,A=this.length-1;A>=0;A--)E=(x*E+(this.words[A]|0))%d;return m?-E:E},o.prototype.modn=function(d){return this.modrn(d)},o.prototype.idivn=function(d){var m=d<0;m&&(d=-d),i(d<=67108863);for(var x=0,E=this.length-1;E>=0;E--){var A=(this.words[E]|0)+x*67108864;this.words[E]=A/d|0,x=A%d}return this._strip(),m?this.ineg():this},o.prototype.divn=function(d){return this.clone().idivn(d)},o.prototype.egcd=function(d){i(d.negative===0),i(!d.isZero());var m=this,x=d.clone();m.negative!==0?m=m.umod(d):m=m.clone();for(var E=new o(1),A=new o(0),j=new o(0),k=new o(1),g=0;m.isEven()&&x.isEven();)m.iushrn(1),x.iushrn(1),++g;for(var w=x.clone(),P=m.clone();!m.isZero();){for(var ue=0,ie=1;!(m.words[0]&ie)&&ue<26;++ue,ie<<=1);if(ue>0)for(m.iushrn(ue);ue-- >0;)(E.isOdd()||A.isOdd())&&(E.iadd(w),A.isub(P)),E.iushrn(1),A.iushrn(1);for(var fe=0,ve=1;!(x.words[0]&ve)&&fe<26;++fe,ve<<=1);if(fe>0)for(x.iushrn(fe);fe-- >0;)(j.isOdd()||k.isOdd())&&(j.iadd(w),k.isub(P)),j.iushrn(1),k.iushrn(1);m.cmp(x)>=0?(m.isub(x),E.isub(j),A.isub(k)):(x.isub(m),j.isub(E),k.isub(A))}return{a:j,b:k,gcd:x.iushln(g)}},o.prototype._invmp=function(d){i(d.negative===0),i(!d.isZero());var m=this,x=d.clone();m.negative!==0?m=m.umod(d):m=m.clone();for(var E=new o(1),A=new o(0),j=x.clone();m.cmpn(1)>0&&x.cmpn(1)>0;){for(var k=0,g=1;!(m.words[0]&g)&&k<26;++k,g<<=1);if(k>0)for(m.iushrn(k);k-- >0;)E.isOdd()&&E.iadd(j),E.iushrn(1);for(var w=0,P=1;!(x.words[0]&P)&&w<26;++w,P<<=1);if(w>0)for(x.iushrn(w);w-- >0;)A.isOdd()&&A.iadd(j),A.iushrn(1);m.cmp(x)>=0?(m.isub(x),E.isub(A)):(x.isub(m),A.isub(E))}var ue;return m.cmpn(1)===0?ue=E:ue=A,ue.cmpn(0)<0&&ue.iadd(d),ue},o.prototype.gcd=function(d){if(this.isZero())return d.abs();if(d.isZero())return this.abs();var m=this.clone(),x=d.clone();m.negative=0,x.negative=0;for(var E=0;m.isEven()&&x.isEven();E++)m.iushrn(1),x.iushrn(1);do{for(;m.isEven();)m.iushrn(1);for(;x.isEven();)x.iushrn(1);var A=m.cmp(x);if(A<0){var j=m;m=x,x=j}else if(A===0||x.cmpn(1)===0)break;m.isub(x)}while(!0);return x.iushln(E)},o.prototype.invm=function(d){return this.egcd(d).a.umod(d)},o.prototype.isEven=function(){return(this.words[0]&1)===0},o.prototype.isOdd=function(){return(this.words[0]&1)===1},o.prototype.andln=function(d){return this.words[0]&d},o.prototype.bincn=function(d){i(typeof d=="number");var m=d%26,x=(d-m)/26,E=1<<m;if(this.length<=x)return this._expand(x+1),this.words[x]|=E,this;for(var A=E,j=x;A!==0&&j<this.length;j++){var k=this.words[j]|0;k+=A,A=k>>>26,k&=67108863,this.words[j]=k}return A!==0&&(this.words[j]=A,this.length++),this},o.prototype.isZero=function(){return this.length===1&&this.words[0]===0},o.prototype.cmpn=function(d){var m=d<0;if(this.negative!==0&&!m)return-1;if(this.negative===0&&m)return 1;this._strip();var x;if(this.length>1)x=1;else{m&&(d=-d),i(d<=67108863,"Number is too big");var E=this.words[0]|0;x=E===d?0:E<d?-1:1}return this.negative!==0?-x|0:x},o.prototype.cmp=function(d){if(this.negative!==0&&d.negative===0)return-1;if(this.negative===0&&d.negative!==0)return 1;var m=this.ucmp(d);return this.negative!==0?-m|0:m},o.prototype.ucmp=function(d){if(this.length>d.length)return 1;if(this.length<d.length)return-1;for(var m=0,x=this.length-1;x>=0;x--){var E=this.words[x]|0,A=d.words[x]|0;if(E!==A){E<A?m=-1:E>A&&(m=1);break}}return m},o.prototype.gtn=function(d){return this.cmpn(d)===1},o.prototype.gt=function(d){return this.cmp(d)===1},o.prototype.gten=function(d){return this.cmpn(d)>=0},o.prototype.gte=function(d){return this.cmp(d)>=0},o.prototype.ltn=function(d){return this.cmpn(d)===-1},o.prototype.lt=function(d){return this.cmp(d)===-1},o.prototype.lten=function(d){return this.cmpn(d)<=0},o.prototype.lte=function(d){return this.cmp(d)<=0},o.prototype.eqn=function(d){return this.cmpn(d)===0},o.prototype.eq=function(d){return this.cmp(d)===0},o.red=function(d){return new V(d)},o.prototype.toRed=function(d){return i(!this.red,"Already a number in reduction context"),i(this.negative===0,"red works only with positives"),d.convertTo(this)._forceRed(d)},o.prototype.fromRed=function(){return i(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},o.prototype._forceRed=function(d){return this.red=d,this},o.prototype.forceRed=function(d){return i(!this.red,"Already a number in reduction context"),this._forceRed(d)},o.prototype.redAdd=function(d){return i(this.red,"redAdd works only with red numbers"),this.red.add(this,d)},o.prototype.redIAdd=function(d){return i(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,d)},o.prototype.redSub=function(d){return i(this.red,"redSub works only with red numbers"),this.red.sub(this,d)},o.prototype.redISub=function(d){return i(this.red,"redISub works only with red numbers"),this.red.isub(this,d)},o.prototype.redShl=function(d){return i(this.red,"redShl works only with red numbers"),this.red.shl(this,d)},o.prototype.redMul=function(d){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,d),this.red.mul(this,d)},o.prototype.redIMul=function(d){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,d),this.red.imul(this,d)},o.prototype.redSqr=function(){return i(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return i(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return i(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return i(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return i(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(d){return i(this.red&&!d.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,d)};var H={k256:null,p224:null,p192:null,p25519:null};function z(p,d){this.name=p,this.p=new o(d,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}z.prototype._tmp=function(){var d=new o(null);return d.words=new Array(Math.ceil(this.n/13)),d},z.prototype.ireduce=function(d){var m=d,x;do this.split(m,this.tmp),m=this.imulK(m),m=m.iadd(this.tmp),x=m.bitLength();while(x>this.n);var E=x<this.n?-1:m.ucmp(this.p);return E===0?(m.words[0]=0,m.length=1):E>0?m.isub(this.p):m.strip!==void 0?m.strip():m._strip(),m},z.prototype.split=function(d,m){d.iushrn(this.n,0,m)},z.prototype.imulK=function(d){return d.imul(this.k)};function ne(){z.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}s(ne,z),ne.prototype.split=function(d,m){for(var x=4194303,E=Math.min(d.length,9),A=0;A<E;A++)m.words[A]=d.words[A];if(m.length=E,d.length<=9){d.words[0]=0,d.length=1;return}var j=d.words[9];for(m.words[m.length++]=j&x,A=10;A<d.length;A++){var k=d.words[A]|0;d.words[A-10]=(k&x)<<4|j>>>22,j=k}j>>>=22,d.words[A-10]=j,j===0&&d.length>10?d.length-=10:d.length-=9},ne.prototype.imulK=function(d){d.words[d.length]=0,d.words[d.length+1]=0,d.length+=2;for(var m=0,x=0;x<d.length;x++){var E=d.words[x]|0;m+=E*977,d.words[x]=m&67108863,m=E*64+(m/67108864|0)}return d.words[d.length-1]===0&&(d.length--,d.words[d.length-1]===0&&d.length--),d};function le(){z.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}s(le,z);function te(){z.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}s(te,z);function ce(){z.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}s(ce,z),ce.prototype.imulK=function(d){for(var m=0,x=0;x<d.length;x++){var E=(d.words[x]|0)*19+m,A=E&67108863;E>>>=26,d.words[x]=A,m=E}return m!==0&&(d.words[d.length++]=m),d},o._prime=function(d){if(H[d])return H[d];var m;if(d==="k256")m=new ne;else if(d==="p224")m=new le;else if(d==="p192")m=new te;else if(d==="p25519")m=new ce;else throw new Error("Unknown prime "+d);return H[d]=m,m};function V(p){if(typeof p=="string"){var d=o._prime(p);this.m=d.p,this.prime=d}else i(p.gtn(1),"modulus must be greater than 1"),this.m=p,this.prime=null}V.prototype._verify1=function(d){i(d.negative===0,"red works only with positives"),i(d.red,"red works only with red numbers")},V.prototype._verify2=function(d,m){i((d.negative|m.negative)===0,"red works only with positives"),i(d.red&&d.red===m.red,"red works only with red numbers")},V.prototype.imod=function(d){return this.prime?this.prime.ireduce(d)._forceRed(this):(f(d,d.umod(this.m)._forceRed(this)),d)},V.prototype.neg=function(d){return d.isZero()?d.clone():this.m.sub(d)._forceRed(this)},V.prototype.add=function(d,m){this._verify2(d,m);var x=d.add(m);return x.cmp(this.m)>=0&&x.isub(this.m),x._forceRed(this)},V.prototype.iadd=function(d,m){this._verify2(d,m);var x=d.iadd(m);return x.cmp(this.m)>=0&&x.isub(this.m),x},V.prototype.sub=function(d,m){this._verify2(d,m);var x=d.sub(m);return x.cmpn(0)<0&&x.iadd(this.m),x._forceRed(this)},V.prototype.isub=function(d,m){this._verify2(d,m);var x=d.isub(m);return x.cmpn(0)<0&&x.iadd(this.m),x},V.prototype.shl=function(d,m){return this._verify1(d),this.imod(d.ushln(m))},V.prototype.imul=function(d,m){return this._verify2(d,m),this.imod(d.imul(m))},V.prototype.mul=function(d,m){return this._verify2(d,m),this.imod(d.mul(m))},V.prototype.isqr=function(d){return this.imul(d,d.clone())},V.prototype.sqr=function(d){return this.mul(d,d)},V.prototype.sqrt=function(d){if(d.isZero())return d.clone();var m=this.m.andln(3);if(i(m%2===1),m===3){var x=this.m.add(new o(1)).iushrn(2);return this.pow(d,x)}for(var E=this.m.subn(1),A=0;!E.isZero()&&E.andln(1)===0;)A++,E.iushrn(1);i(!E.isZero());var j=new o(1).toRed(this),k=j.redNeg(),g=this.m.subn(1).iushrn(1),w=this.m.bitLength();for(w=new o(2*w*w).toRed(this);this.pow(w,g).cmp(k)!==0;)w.redIAdd(k);for(var P=this.pow(w,E),ue=this.pow(d,E.addn(1).iushrn(1)),ie=this.pow(d,E),fe=A;ie.cmp(j)!==0;){for(var ve=ie,Ce=0;ve.cmp(j)!==0;Ce++)ve=ve.redSqr();i(Ce<fe);var N=this.pow(P,new o(1).iushln(fe-Ce-1));ue=ue.redMul(N),P=N.redSqr(),ie=ie.redMul(P),fe=Ce}return ue},V.prototype.invm=function(d){var m=d._invmp(this.m);return m.negative!==0?(m.negative=0,this.imod(m).redNeg()):this.imod(m)},V.prototype.pow=function(d,m){if(m.isZero())return new o(1).toRed(this);if(m.cmpn(1)===0)return d.clone();var x=4,E=new Array(1<<x);E[0]=new o(1).toRed(this),E[1]=d;for(var A=2;A<E.length;A++)E[A]=this.mul(E[A-1],d);var j=E[0],k=0,g=0,w=m.bitLength()%26;for(w===0&&(w=26),A=m.length-1;A>=0;A--){for(var P=m.words[A],ue=w-1;ue>=0;ue--){var ie=P>>ue&1;if(j!==E[0]&&(j=this.sqr(j)),ie===0&&k===0){g=0;continue}k<<=1,k|=ie,g++,!(g!==x&&(A!==0||ue!==0))&&(j=this.mul(j,E[k]),g=0,k=0)}w=26}return j},V.prototype.convertTo=function(d){var m=d.umod(this.m);return m===d?m.clone():m},V.prototype.convertFrom=function(d){var m=d.clone();return m.red=null,m},o.mont=function(d){return new L(d)};function L(p){V.call(this,p),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}s(L,V),L.prototype.convertTo=function(d){return this.imod(d.ushln(this.shift))},L.prototype.convertFrom=function(d){var m=this.imod(d.mul(this.rinv));return m.red=null,m},L.prototype.imul=function(d,m){if(d.isZero()||m.isZero())return d.words[0]=0,d.length=1,d;var x=d.imul(m),E=x.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),A=x.isub(E).iushrn(this.shift),j=A;return A.cmp(this.m)>=0?j=A.isub(this.m):A.cmpn(0)<0&&(j=A.iadd(this.m)),j._forceRed(this)},L.prototype.mul=function(d,m){if(d.isZero()||m.isZero())return new o(0)._forceRed(this);var x=d.mul(m),E=x.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),A=x.isub(E).iushrn(this.shift),j=A;return A.cmp(this.m)>=0?j=A.isub(this.m):A.cmpn(0)<0&&(j=A.iadd(this.m)),j._forceRed(this)},L.prototype.invm=function(d){var m=this.imod(d._invmp(this.m).mul(this.r2));return m._forceRed(this)}})(typeof t>"u"||t,e)}}),dr=Ac(Mc()),Za=Ac(Mc());function Cp(e){switch(e){case 1e3:return"Number too large";case 1001:return"Rate limit exceeded";case 1002:return"Insufficient liquidity";case 1003:return"HoneyPot scam detected";default:return"Unknown error"}}function Fv(e,...t){const r=Array.isArray(t[t.length-1])?t.pop():[];let i=[e,...t].filter(Boolean).join("::");return r&&r.length&&(i+=`<${r.join(", ")}>`),i}function DU(e){return e.split("::")[0]}function sc(e){var t;try{let r=e.replace(/\s/g,"");const n=r.match(/(<.+>)$/),i=(t=n==null?void 0:n[0])==null?void 0:t.match(/(\w+::\w+::\w+)(?:<.*?>(?!>))?/g);if(i){r=r.slice(0,r.indexOf("<"));const c=sc(r),u=RU(jU({},c),{type_arguments:i.map(l=>sc(l).source_address)});return u.type_arguments=u.type_arguments.map(l=>KS.isSuiCoin(l)?l:sc(l).source_address),u.source_address=Fv(u.full_address,u.type_arguments),u}const s=r.split("::"),a={full_address:r,address:r===GS||r===UU?"0x2":fr.normalizeSuiObjectId(s[0]),module:s[1],name:s[2],type_arguments:[],source_address:""};return a.full_address=`${a.address}::${a.module}::${a.name}`,a.source_address=Fv(a.full_address,a.type_arguments),a}catch{return{full_address:e,address:"",module:"",name:"",type_arguments:[],source_address:e}}}function Vv(e){return sc(e).source_address}var LU="0x2::coin::Coin",BU=/^0x2::coin::Coin<(.+)>$/,GS="0x2::sui::SUI",UU="0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI",KS=class so{static getCoinTypeArg(t){const r=t.type.match(BU);return r?r[1]:null}static isSUI(t){const r=so.getCoinTypeArg(t);return r?so.getCoinSymbol(r)==="SUI":!1}static getCoinSymbol(t){return t.substring(t.lastIndexOf(":")+1)}static getBalance(t){return BigInt(t.fields.balance)}static totalBalance(t,r){let n=BigInt(0);return t.forEach(i=>{r===i.coinAddress&&(n+=BigInt(i.balance))}),n}static getID(t){return t.fields.id.id}static getCoinTypeFromArg(t){return`${LU}<${t}>`}static getCoinAssets(t,r){const n=[];return r.forEach(i=>{Vv(i.coinAddress)===Vv(t)&&n.push(i)}),n}static isSuiCoin(t){return sc(t).full_address===GS}static selectCoinObjectIdGreaterThanOrEqual(t,r,n=[]){const i=so.selectCoinAssetGreaterThanOrEqual(t,r,n),s=i.selectedCoins.map(c=>c.coinObjectId),o=i.remainingCoins,a=i.selectedCoins.map(c=>c.balance.toString());return{objectArray:s,remainCoins:o,amountArray:a}}static selectCoinAssetGreaterThanOrEqual(t,r,n=[]){const i=so.sortByBalance(t.filter(u=>!n.includes(u.coinObjectId))),s=so.calculateTotalBalance(i);if(s<r)return{selectedCoins:[],remainingCoins:i};if(s===r)return{selectedCoins:i,remainingCoins:[]};let o=BigInt(0);const a=[],c=[...i];for(;o<s;){const u=r-o,l=c.findIndex(h=>h.balance>=u);if(l!==-1){a.push(c[l]),c.splice(l,1);break}const f=c.pop();f.balance>0&&(a.push(f),o+=f.balance)}return{selectedCoins:so.sortByBalance(a),remainingCoins:so.sortByBalance(c)}}static sortByBalance(t){return t.sort((r,n)=>r.balance<n.balance?-1:r.balance>n.balance?1:0)}static sortByBalanceDes(t){return t.sort((r,n)=>r.balance>n.balance?-1:r.balance<n.balance?0:1)}static calculateTotalBalance(t){return t.reduce((r,n)=>r+n.balance,BigInt(0))}};function Mo(e){const t=e.indexOf("::");if(t===-1)return e;const r=e.substring(0,t),n=e.substring(t);if(!r.startsWith("0x"))return e;const i=r.substring(2);return i.length>64?e:`0x${i.padStart(64,"0")}${n}`}function FU(e,t){e=Mo(e),t=Mo(t);const r=Math.min(e.length,t.length);for(let n=0;n<r;n++){if(e[n]>t[n])return!0;if(e[n]<t[n])return!1}return!0}var al=Ac(Mc()),Na=new al.default(0);new al.default(1);var VU=new al.default(2);VU.pow(new al.default(128));new al.default("18446744073709551615");var z0="18446744073709551615",zU="0xd7b0cfc33a3b46c0ae0e2584c44028385da11724d4c94ec5b21a78117c5c1ab9",Xf={AGGREGATOR_V3:"aggregator_v3"},Jf={Mainnet:"0xdeeb7a4662eec9f2f3def03fb937a663dddaa2e215b8078a284d026b7946c270::deep::DEEP",Testnet:"0x36dbef866a1d62bf7328989a10fb2f07d769f4ee587c0de4a0a256e57e0a58a8::deep::DEEP"},pi={DEFAULT_PYTH_URL:"https://hermes.pyth.network",PYTH_TIMEOUT:3e3,MAX_OVERLAY_FEE_RATE:.1,MAX_OVERLAY_FEE_RATE_NUMERATOR:1e5,FEE_RATE_MULTIPLIER:1e6,DEFAULT_OVERLAY_FEE_RECEIVER:"0x0",ERRORS:{SIGNER_REQUIRED:"Signer is required, but not provided.",INVALID_OVERLAY_FEE_RATE:"Overlay fee rate must be between 0 and 0.1",INVALID_SLIPPAGE:"Invalid slippage value. Must be between 0 and 1 (e.g., 0.01 represents 1% slippage)",NO_ROUTER_FOUND:"No router found",EMPTY_PATH:"Empty path",UNSUPPORTED_DEX:"Unsupported dex",PYTH_UNAVAILABLE:"All Pyth price nodes are unavailable. Cannot fetch price data. Please switch to or add new available Pyth nodes",QUOTE_ID_REQUIRED:"Quote ID is required",AGGREGATOR_V3_PACKAGE_REQUIRED:"Aggregator V3 package is required",PACKAGES_REQUIRED:"Packages are required",OVERLAY_FEE_RECEIVER_REQUIRED:"Overlay fee rate is set, but overlay fee receiver is not set"}},Kt={FEE_DENOMINATOR:1e6,MAX_FEE_RATE:1e5,MAX_AMOUNT_IN:z0,DEFAULT_PUBLISHED_AT:{Mainnet:"0x33ec64e9bb369bf045ddc198c81adbf2acab424da37465d95296ee02045d2b17",Testnet:"0x0"}},YS=1010200;function WU(e,t){let r=new Map;return e.packages&&(e.packages instanceof Map?r=e.packages:typeof e.packages=="object"&&Object.entries(e.packages).forEach(([n,i])=>{r.set(n,i)})),{quoteID:e.request_id||"",amountIn:new Za.default(e.amount_in.toString()),amountOut:new Za.default(e.amount_out.toString()),byAmountIn:t,insufficientLiquidity:!1,deviationRatio:e.deviation_ratio,packages:r,paths:e.paths.map(n=>({id:n.id,direction:n.direction,provider:n.provider,from:n.from,target:n.target,feeRate:n.fee_rate,amountIn:n.amount_in.toString(),amountOut:n.amount_out.toString(),version:n.version,publishedAt:n.published_at,extendedDetails:n.extended_details}))}}function qU(e,t,r,n,i){return mn(this,null,function*(){let s;if(r.liquidityChanges&&r.liquidityChanges.length>0?s=yield GU(e,r):s=yield HU(e,t,r),!s)return null;if(!s.ok){let c=1e3;return s.status===429&&(c=1001),{quoteID:"",amountIn:Na,amountOut:Na,paths:[],byAmountIn:r.byAmountIn,insufficientLiquidity:!1,deviationRatio:0,error:{code:c,msg:Cp(c)}}}const o=TU.default.parse(yield s.text()),a=o.msg==="liquidity is not enough";if(o.msg&&o.msg.indexOf("HoneyPot scam")>-1)return{quoteID:"",amountIn:Na,amountOut:Na,paths:[],byAmountIn:r.byAmountIn,insufficientLiquidity:a,deviationRatio:0,error:{code:1003,msg:Cp(1003)}};if(o.data!=null){const c=WU(o.data,r.byAmountIn);if(n>0&&i!=="0x0")if(r.byAmountIn){const u=c.amountOut.mul(new Za.default(n)).div(new Za.default(1e6));c.overlayFee=Number(u.toString()),c.amountOut=c.amountOut.sub(u)}else{const u=c.amountIn.mul(new Za.default(n)).div(new Za.default(1e6));c.overlayFee=Number(u.toString()),c.amountIn=c.amountIn.add(u)}return c.packages||(c.packages=new Map),c.packages.has("aggregator_v3")||c.packages.set("aggregator_v3","0x3864c7c59a4889fec05d1aae4bc9dba5a0e0940594b424fbed44cb3f6ac4c032"),c}return{quoteID:"",amountIn:Na,amountOut:Na,paths:[],insufficientLiquidity:a,byAmountIn:r.byAmountIn,deviationRatio:0,error:{code:1002,msg:Cp(1002)}}})}function HU(e,t,r){return mn(this,null,function*(){try{const{from:n,target:i,amount:s,byAmountIn:o,depth:a,splitAlgorithm:c,splitFactor:u,splitCount:l,providers:f}=r,h=Mo(n),v=Mo(i);let b=`${e}/find_routes?from=${h}&target=${v}&amount=${s.toString()}&by_amount_in=${o}`;return a&&(b+=`&depth=${a}`),c&&(b+=`&split_algorithm=${c}`),u&&(b+=`&split_factor=${u}`),l&&(b+=`&split_count=${l}`),f&&f.length>0&&(b+=`&providers=${f.join(",")}`),t.length>0&&(b+=`&apiKey=${t}`),b+=`&v=${YS}`,yield fetch(b)}catch(n){return console.error(n),null}})}function GU(e,t){return mn(this,null,function*(){const{from:r,target:n,amount:i,byAmountIn:s,depth:o,splitAlgorithm:a,splitFactor:c,splitCount:u,providers:l,liquidityChanges:f}=t,h=Mo(r),v=Mo(n),b=`${e}/find_routes`,y=l==null?void 0:l.join(","),S={from:h,target:v,amount:Number(i.toString()),by_amount_in:s,depth:o,split_algorithm:a,split_factor:c,split_count:u,providers:y,liquidity_changes:f.map(C=>({pool:C.poolID,tick_lower:C.ticklower,tick_upper:C.tickUpper,delta_liquidity:C.deltaLiquidity})),v:YS};try{return yield fetch(b,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(S)})}catch(C){return console.error("Error:",C),null}})}function KU(e){return mn(this,null,function*(){const t=`${e}/deepbookv3_config`;try{return(yield fetch(t)).json()}catch(r){return console.error("Error:",r),null}})}function zv(e){const t=e.paths,r=t[0].from,n=t[t.length-1].target,i=[];for(const o of t)i.push({path:o,isLastUseOfIntermediateToken:!1});const s=new Map;for(let o=i.length-1;o>=0;o--){const{from:a}=i[o].path;s.has(a)||(s.set(a,!0),i[o].isLastUseOfIntermediateToken=!0)}return{quoteID:e.quoteID||"",amountIn:e.amountIn,amountOut:e.amountOut,byAmountIn:e.byAmountIn,flattenedPaths:i,fromCoinType:r,targetCoinType:n,packages:e.packages,totalDeepFee:e.totalDeepFee,error:e.error,overlayFee:e.overlayFee}}var XS=(e=>(e[e.Mainnet=0]="Mainnet",e[e.Testnet=1]="Testnet",e))(XS||{}),YU=Ac(Mc()),Qa=9e15,No=1e9,W0="0123456789abcdef",Zf="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",Qf="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",q0={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-Qa,maxE:Qa,crypto:!1},JS,ks,At=!0,zd="[DecimalError] ",Oo=zd+"Invalid argument: ",ZS=zd+"Precision limit exceeded",QS=zd+"crypto unavailable",e5="[object Decimal]",un=Math.floor,$r=Math.pow,XU=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,JU=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,ZU=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,t5=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,Ti=1e7,wt=7,QU=9007199254740991,eF=Zf.length-1,H0=Qf.length-1,Ne={toStringTag:e5};Ne.absoluteValue=Ne.abs=function(){var e=new this.constructor(this);return e.s<0&&(e.s=1),dt(e)};Ne.ceil=function(){return dt(new this.constructor(this),this.e+1,2)};Ne.clampedTo=Ne.clamp=function(e,t){var r,n=this,i=n.constructor;if(e=new i(e),t=new i(t),!e.s||!t.s)return new i(NaN);if(e.gt(t))throw Error(Oo+t);return r=n.cmp(e),r<0?e:n.cmp(t)>0?t:new i(n)};Ne.comparedTo=Ne.cmp=function(e){var t,r,n,i,s=this,o=s.d,a=(e=new s.constructor(e)).d,c=s.s,u=e.s;if(!o||!a)return!c||!u?NaN:c!==u?c:o===a?0:!o^c<0?1:-1;if(!o[0]||!a[0])return o[0]?c:a[0]?-u:0;if(c!==u)return c;if(s.e!==e.e)return s.e>e.e^c<0?1:-1;for(n=o.length,i=a.length,t=0,r=n<i?n:i;t<r;++t)if(o[t]!==a[t])return o[t]>a[t]^c<0?1:-1;return n===i?0:n>i^c<0?1:-1};Ne.cosine=Ne.cos=function(){var e,t,r=this,n=r.constructor;return r.d?r.d[0]?(e=n.precision,t=n.rounding,n.precision=e+Math.max(r.e,r.sd())+wt,n.rounding=1,r=tF(n,o5(n,r)),n.precision=e,n.rounding=t,dt(ks==2||ks==3?r.neg():r,e,t,!0)):new n(1):new n(NaN)};Ne.cubeRoot=Ne.cbrt=function(){var e,t,r,n,i,s,o,a,c,u,l=this,f=l.constructor;if(!l.isFinite()||l.isZero())return new f(l);for(At=!1,s=l.s*$r(l.s*l,1/3),!s||Math.abs(s)==1/0?(r=Jr(l.d),e=l.e,(s=(e-r.length+1)%3)&&(r+=s==1||s==-2?"0":"00"),s=$r(r,1/3),e=un((e+1)/3)-(e%3==(e<0?-1:2)),s==1/0?r="5e"+e:(r=s.toExponential(),r=r.slice(0,r.indexOf("e")+1)+e),n=new f(r),n.s=l.s):n=new f(s.toString()),o=(e=f.precision)+3;;)if(a=n,c=a.times(a).times(a),u=c.plus(l),n=Qt(u.plus(l).times(a),u.plus(c),o+2,1),Jr(a.d).slice(0,o)===(r=Jr(n.d)).slice(0,o))if(r=r.slice(o-3,o+1),r=="9999"||!i&&r=="4999"){if(!i&&(dt(a,e+1,0),a.times(a).times(a).eq(l))){n=a;break}o+=4,i=1}else{(!+r||!+r.slice(1)&&r.charAt(0)=="5")&&(dt(n,e+1,1),t=!n.times(n).times(n).eq(l));break}return At=!0,dt(n,e,f.rounding,t)};Ne.decimalPlaces=Ne.dp=function(){var e,t=this.d,r=NaN;if(t){if(e=t.length-1,r=(e-un(this.e/wt))*wt,e=t[e],e)for(;e%10==0;e/=10)r--;r<0&&(r=0)}return r};Ne.dividedBy=Ne.div=function(e){return Qt(this,new this.constructor(e))};Ne.dividedToIntegerBy=Ne.divToInt=function(e){var t=this,r=t.constructor;return dt(Qt(t,new r(e),0,1,1),r.precision,r.rounding)};Ne.equals=Ne.eq=function(e){return this.cmp(e)===0};Ne.floor=function(){return dt(new this.constructor(this),this.e+1,3)};Ne.greaterThan=Ne.gt=function(e){return this.cmp(e)>0};Ne.greaterThanOrEqualTo=Ne.gte=function(e){var t=this.cmp(e);return t==1||t===0};Ne.hyperbolicCosine=Ne.cosh=function(){var e,t,r,n,i,s=this,o=s.constructor,a=new o(1);if(!s.isFinite())return new o(s.s?1/0:NaN);if(s.isZero())return a;r=o.precision,n=o.rounding,o.precision=r+Math.max(s.e,s.sd())+4,o.rounding=1,i=s.d.length,i<32?(e=Math.ceil(i/3),t=(1/qd(4,e)).toString()):(e=16,t="2.3283064365386962890625e-10"),s=pc(o,1,s.times(t),new o(1),!0);for(var c,u=e,l=new o(8);u--;)c=s.times(s),s=a.minus(c.times(l.minus(c.times(l))));return dt(s,o.precision=r,o.rounding=n,!0)};Ne.hyperbolicSine=Ne.sinh=function(){var e,t,r,n,i=this,s=i.constructor;if(!i.isFinite()||i.isZero())return new s(i);if(t=s.precision,r=s.rounding,s.precision=t+Math.max(i.e,i.sd())+4,s.rounding=1,n=i.d.length,n<3)i=pc(s,2,i,i,!0);else{e=1.4*Math.sqrt(n),e=e>16?16:e|0,i=i.times(1/qd(5,e)),i=pc(s,2,i,i,!0);for(var o,a=new s(5),c=new s(16),u=new s(20);e--;)o=i.times(i),i=i.times(a.plus(o.times(c.times(o).plus(u))))}return s.precision=t,s.rounding=r,dt(i,t,r,!0)};Ne.hyperbolicTangent=Ne.tanh=function(){var e,t,r=this,n=r.constructor;return r.isFinite()?r.isZero()?new n(r):(e=n.precision,t=n.rounding,n.precision=e+7,n.rounding=1,Qt(r.sinh(),r.cosh(),n.precision=e,n.rounding=t)):new n(r.s)};Ne.inverseCosine=Ne.acos=function(){var e=this,t=e.constructor,r=e.abs().cmp(1),n=t.precision,i=t.rounding;return r!==-1?r===0?e.isNeg()?Yi(t,n,i):new t(0):new t(NaN):e.isZero()?Yi(t,n+4,i).times(.5):(t.precision=n+6,t.rounding=1,e=new t(1).minus(e).div(e.plus(1)).sqrt().atan(),t.precision=n,t.rounding=i,e.times(2))};Ne.inverseHyperbolicCosine=Ne.acosh=function(){var e,t,r=this,n=r.constructor;return r.lte(1)?new n(r.eq(1)?0:NaN):r.isFinite()?(e=n.precision,t=n.rounding,n.precision=e+Math.max(Math.abs(r.e),r.sd())+4,n.rounding=1,At=!1,r=r.times(r).minus(1).sqrt().plus(r),At=!0,n.precision=e,n.rounding=t,r.ln()):new n(r)};Ne.inverseHyperbolicSine=Ne.asinh=function(){var e,t,r=this,n=r.constructor;return!r.isFinite()||r.isZero()?new n(r):(e=n.precision,t=n.rounding,n.precision=e+2*Math.max(Math.abs(r.e),r.sd())+6,n.rounding=1,At=!1,r=r.times(r).plus(1).sqrt().plus(r),At=!0,n.precision=e,n.rounding=t,r.ln())};Ne.inverseHyperbolicTangent=Ne.atanh=function(){var e,t,r,n,i=this,s=i.constructor;return i.isFinite()?i.e>=0?new s(i.abs().eq(1)?i.s/0:i.isZero()?i:NaN):(e=s.precision,t=s.rounding,n=i.sd(),Math.max(n,e)<2*-i.e-1?dt(new s(i),e,t,!0):(s.precision=r=n-i.e,i=Qt(i.plus(1),new s(1).minus(i),r+e,1),s.precision=e+4,s.rounding=1,i=i.ln(),s.precision=e,s.rounding=t,i.times(.5))):new s(NaN)};Ne.inverseSine=Ne.asin=function(){var e,t,r,n,i=this,s=i.constructor;return i.isZero()?new s(i):(t=i.abs().cmp(1),r=s.precision,n=s.rounding,t!==-1?t===0?(e=Yi(s,r+4,n).times(.5),e.s=i.s,e):new s(NaN):(s.precision=r+6,s.rounding=1,i=i.div(new s(1).minus(i.times(i)).sqrt().plus(1)).atan(),s.precision=r,s.rounding=n,i.times(2)))};Ne.inverseTangent=Ne.atan=function(){var e,t,r,n,i,s,o,a,c,u=this,l=u.constructor,f=l.precision,h=l.rounding;if(u.isFinite()){if(u.isZero())return new l(u);if(u.abs().eq(1)&&f+4<=H0)return o=Yi(l,f+4,h).times(.25),o.s=u.s,o}else{if(!u.s)return new l(NaN);if(f+4<=H0)return o=Yi(l,f+4,h).times(.5),o.s=u.s,o}for(l.precision=a=f+10,l.rounding=1,r=Math.min(28,a/wt+2|0),e=r;e;--e)u=u.div(u.times(u).plus(1).sqrt().plus(1));for(At=!1,t=Math.ceil(a/wt),n=1,c=u.times(u),o=new l(u),i=u;e!==-1;)if(i=i.times(c),s=o.minus(i.div(n+=2)),i=i.times(c),o=s.plus(i.div(n+=2)),o.d[t]!==void 0)for(e=t;o.d[e]===s.d[e]&&e--;);return r&&(o=o.times(2<<r-1)),At=!0,dt(o,l.precision=f,l.rounding=h,!0)};Ne.isFinite=function(){return!!this.d};Ne.isInteger=Ne.isInt=function(){return!!this.d&&un(this.e/wt)>this.d.length-2};Ne.isNaN=function(){return!this.s};Ne.isNegative=Ne.isNeg=function(){return this.s<0};Ne.isPositive=Ne.isPos=function(){return this.s>0};Ne.isZero=function(){return!!this.d&&this.d[0]===0};Ne.lessThan=Ne.lt=function(e){return this.cmp(e)<0};Ne.lessThanOrEqualTo=Ne.lte=function(e){return this.cmp(e)<1};Ne.logarithm=Ne.log=function(e){var t,r,n,i,s,o,a,c,u=this,l=u.constructor,f=l.precision,h=l.rounding,v=5;if(e==null)e=new l(10),t=!0;else{if(e=new l(e),r=e.d,e.s<0||!r||!r[0]||e.eq(1))return new l(NaN);t=e.eq(10)}if(r=u.d,u.s<0||!r||!r[0]||u.eq(1))return new l(r&&!r[0]?-1/0:u.s!=1?NaN:r?0:1/0);if(t)if(r.length>1)s=!0;else{for(i=r[0];i%10===0;)i/=10;s=i!==1}if(At=!1,a=f+v,o=bo(u,a),n=t?ed(l,a+10):bo(e,a),c=Qt(o,n,a,1),Iu(c.d,i=f,h))do if(a+=10,o=bo(u,a),n=t?ed(l,a+10):bo(e,a),c=Qt(o,n,a,1),!s){+Jr(c.d).slice(i+1,i+15)+1==1e14&&(c=dt(c,f+1,0));break}while(Iu(c.d,i+=10,h));return At=!0,dt(c,f,h)};Ne.minus=Ne.sub=function(e){var t,r,n,i,s,o,a,c,u,l,f,h,v=this,b=v.constructor;if(e=new b(e),!v.d||!e.d)return!v.s||!e.s?e=new b(NaN):v.d?e.s=-e.s:e=new b(e.d||v.s!==e.s?v:NaN),e;if(v.s!=e.s)return e.s=-e.s,v.plus(e);if(u=v.d,h=e.d,a=b.precision,c=b.rounding,!u[0]||!h[0]){if(h[0])e.s=-e.s;else if(u[0])e=new b(v);else return new b(c===3?-0:0);return At?dt(e,a,c):e}if(r=un(e.e/wt),l=un(v.e/wt),u=u.slice(),s=l-r,s){for(f=s<0,f?(t=u,s=-s,o=h.length):(t=h,r=l,o=u.length),n=Math.max(Math.ceil(a/wt),o)+2,s>n&&(s=n,t.length=1),t.reverse(),n=s;n--;)t.push(0);t.reverse()}else{for(n=u.length,o=h.length,f=n<o,f&&(o=n),n=0;n<o;n++)if(u[n]!=h[n]){f=u[n]<h[n];break}s=0}for(f&&(t=u,u=h,h=t,e.s=-e.s),o=u.length,n=h.length-o;n>0;--n)u[o++]=0;for(n=h.length;n>s;){if(u[--n]<h[n]){for(i=n;i&&u[--i]===0;)u[i]=Ti-1;--u[i],u[n]+=Ti}u[n]-=h[n]}for(;u[--o]===0;)u.pop();for(;u[0]===0;u.shift())--r;return u[0]?(e.d=u,e.e=Wd(u,r),At?dt(e,a,c):e):new b(c===3?-0:0)};Ne.modulo=Ne.mod=function(e){var t,r=this,n=r.constructor;return e=new n(e),!r.d||!e.s||e.d&&!e.d[0]?new n(NaN):!e.d||r.d&&!r.d[0]?dt(new n(r),n.precision,n.rounding):(At=!1,n.modulo==9?(t=Qt(r,e.abs(),0,3,1),t.s*=e.s):t=Qt(r,e,0,n.modulo,1),t=t.times(e),At=!0,r.minus(t))};Ne.naturalExponential=Ne.exp=function(){return G0(this)};Ne.naturalLogarithm=Ne.ln=function(){return bo(this)};Ne.negated=Ne.neg=function(){var e=new this.constructor(this);return e.s=-e.s,dt(e)};Ne.plus=Ne.add=function(e){var t,r,n,i,s,o,a,c,u,l,f=this,h=f.constructor;if(e=new h(e),!f.d||!e.d)return!f.s||!e.s?e=new h(NaN):f.d||(e=new h(e.d||f.s===e.s?f:NaN)),e;if(f.s!=e.s)return e.s=-e.s,f.minus(e);if(u=f.d,l=e.d,a=h.precision,c=h.rounding,!u[0]||!l[0])return l[0]||(e=new h(f)),At?dt(e,a,c):e;if(s=un(f.e/wt),n=un(e.e/wt),u=u.slice(),i=s-n,i){for(i<0?(r=u,i=-i,o=l.length):(r=l,n=s,o=u.length),s=Math.ceil(a/wt),o=s>o?s+1:o+1,i>o&&(i=o,r.length=1),r.reverse();i--;)r.push(0);r.reverse()}for(o=u.length,i=l.length,o-i<0&&(i=o,r=l,l=u,u=r),t=0;i;)t=(u[--i]=u[i]+l[i]+t)/Ti|0,u[i]%=Ti;for(t&&(u.unshift(t),++n),o=u.length;u[--o]==0;)u.pop();return e.d=u,e.e=Wd(u,n),At?dt(e,a,c):e};Ne.precision=Ne.sd=function(e){var t,r=this;if(e!==void 0&&e!==!!e&&e!==1&&e!==0)throw Error(Oo+e);return r.d?(t=r5(r.d),e&&r.e+1>t&&(t=r.e+1)):t=NaN,t};Ne.round=function(){var e=this,t=e.constructor;return dt(new t(e),e.e+1,t.rounding)};Ne.sine=Ne.sin=function(){var e,t,r=this,n=r.constructor;return r.isFinite()?r.isZero()?new n(r):(e=n.precision,t=n.rounding,n.precision=e+Math.max(r.e,r.sd())+wt,n.rounding=1,r=nF(n,o5(n,r)),n.precision=e,n.rounding=t,dt(ks>2?r.neg():r,e,t,!0)):new n(NaN)};Ne.squareRoot=Ne.sqrt=function(){var e,t,r,n,i,s,o=this,a=o.d,c=o.e,u=o.s,l=o.constructor;if(u!==1||!a||!a[0])return new l(!u||u<0&&(!a||a[0])?NaN:a?o:1/0);for(At=!1,u=Math.sqrt(+o),u==0||u==1/0?(t=Jr(a),(t.length+c)%2==0&&(t+="0"),u=Math.sqrt(t),c=un((c+1)/2)-(c<0||c%2),u==1/0?t="5e"+c:(t=u.toExponential(),t=t.slice(0,t.indexOf("e")+1)+c),n=new l(t)):n=new l(u.toString()),r=(c=l.precision)+3;;)if(s=n,n=s.plus(Qt(o,s,r+2,1)).times(.5),Jr(s.d).slice(0,r)===(t=Jr(n.d)).slice(0,r))if(t=t.slice(r-3,r+1),t=="9999"||!i&&t=="4999"){if(!i&&(dt(s,c+1,0),s.times(s).eq(o))){n=s;break}r+=4,i=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(dt(n,c+1,1),e=!n.times(n).eq(o));break}return At=!0,dt(n,c,l.rounding,e)};Ne.tangent=Ne.tan=function(){var e,t,r=this,n=r.constructor;return r.isFinite()?r.isZero()?new n(r):(e=n.precision,t=n.rounding,n.precision=e+10,n.rounding=1,r=r.sin(),r.s=1,r=Qt(r,new n(1).minus(r.times(r)).sqrt(),e+10,0),n.precision=e,n.rounding=t,dt(ks==2||ks==4?r.neg():r,e,t,!0)):new n(NaN)};Ne.times=Ne.mul=function(e){var t,r,n,i,s,o,a,c,u,l=this,f=l.constructor,h=l.d,v=(e=new f(e)).d;if(e.s*=l.s,!h||!h[0]||!v||!v[0])return new f(!e.s||h&&!h[0]&&!v||v&&!v[0]&&!h?NaN:!h||!v?e.s/0:e.s*0);for(r=un(l.e/wt)+un(e.e/wt),c=h.length,u=v.length,c<u&&(s=h,h=v,v=s,o=c,c=u,u=o),s=[],o=c+u,n=o;n--;)s.push(0);for(n=u;--n>=0;){for(t=0,i=c+n;i>n;)a=s[i]+v[n]*h[i-n-1]+t,s[i--]=a%Ti|0,t=a/Ti|0;s[i]=(s[i]+t)%Ti|0}for(;!s[--o];)s.pop();return t?++r:s.shift(),e.d=s,e.e=Wd(s,r),At?dt(e,f.precision,f.rounding):e};Ne.toBinary=function(e,t){return c1(this,2,e,t)};Ne.toDecimalPlaces=Ne.toDP=function(e,t){var r=this,n=r.constructor;return r=new n(r),e===void 0?r:(Rn(e,0,No),t===void 0?t=n.rounding:Rn(t,0,8),dt(r,e+r.e+1,t))};Ne.toExponential=function(e,t){var r,n=this,i=n.constructor;return e===void 0?r=is(n,!0):(Rn(e,0,No),t===void 0?t=i.rounding:Rn(t,0,8),n=dt(new i(n),e+1,t),r=is(n,!0,e+1)),n.isNeg()&&!n.isZero()?"-"+r:r};Ne.toFixed=function(e,t){var r,n,i=this,s=i.constructor;return e===void 0?r=is(i):(Rn(e,0,No),t===void 0?t=s.rounding:Rn(t,0,8),n=dt(new s(i),e+i.e+1,t),r=is(n,!1,e+n.e+1)),i.isNeg()&&!i.isZero()?"-"+r:r};Ne.toFraction=function(e){var t,r,n,i,s,o,a,c,u,l,f,h,v=this,b=v.d,y=v.constructor;if(!b)return new y(v);if(u=r=new y(1),n=c=new y(0),t=new y(n),s=t.e=r5(b)-v.e-1,o=s%wt,t.d[0]=$r(10,o<0?wt+o:o),e==null)e=s>0?t:u;else{if(a=new y(e),!a.isInt()||a.lt(u))throw Error(Oo+a);e=a.gt(t)?s>0?t:u:a}for(At=!1,a=new y(Jr(b)),l=y.precision,y.precision=s=b.length*wt*2;f=Qt(a,t,0,1,1),i=r.plus(f.times(n)),i.cmp(e)!=1;)r=n,n=i,i=u,u=c.plus(f.times(i)),c=i,i=t,t=a.minus(f.times(i)),a=i;return i=Qt(e.minus(r),n,0,1,1),c=c.plus(i.times(u)),r=r.plus(i.times(n)),c.s=u.s=v.s,h=Qt(u,n,s,1).minus(v).abs().cmp(Qt(c,r,s,1).minus(v).abs())<1?[u,n]:[c,r],y.precision=l,At=!0,h};Ne.toHexadecimal=Ne.toHex=function(e,t){return c1(this,16,e,t)};Ne.toNearest=function(e,t){var r=this,n=r.constructor;if(r=new n(r),e==null){if(!r.d)return r;e=new n(1),t=n.rounding}else{if(e=new n(e),t===void 0?t=n.rounding:Rn(t,0,8),!r.d)return e.s?r:e;if(!e.d)return e.s&&(e.s=r.s),e}return e.d[0]?(At=!1,r=Qt(r,e,0,t,1).times(e),At=!0,dt(r)):(e.s=r.s,r=e),r};Ne.toNumber=function(){return+this};Ne.toOctal=function(e,t){return c1(this,8,e,t)};Ne.toPower=Ne.pow=function(e){var t,r,n,i,s,o,a=this,c=a.constructor,u=+(e=new c(e));if(!a.d||!e.d||!a.d[0]||!e.d[0])return new c($r(+a,u));if(a=new c(a),a.eq(1))return a;if(n=c.precision,s=c.rounding,e.eq(1))return dt(a,n,s);if(t=un(e.e/wt),t>=e.d.length-1&&(r=u<0?-u:u)<=QU)return i=n5(c,a,r,n),e.s<0?new c(1).div(i):dt(i,n,s);if(o=a.s,o<0){if(t<e.d.length-1)return new c(NaN);if(e.d[t]&1||(o=1),a.e==0&&a.d[0]==1&&a.d.length==1)return a.s=o,a}return r=$r(+a,u),t=r==0||!isFinite(r)?un(u*(Math.log("0."+Jr(a.d))/Math.LN10+a.e+1)):new c(r+"").e,t>c.maxE+1||t<c.minE-1?new c(t>0?o/0:0):(At=!1,c.rounding=a.s=1,r=Math.min(12,(t+"").length),i=G0(e.times(bo(a,n+r)),n),i.d&&(i=dt(i,n+5,1),Iu(i.d,n,s)&&(t=n+10,i=dt(G0(e.times(bo(a,t+r)),t),t+5,1),+Jr(i.d).slice(n+1,n+15)+1==1e14&&(i=dt(i,n+1,0)))),i.s=o,At=!0,c.rounding=s,dt(i,n,s))};Ne.toPrecision=function(e,t){var r,n=this,i=n.constructor;return e===void 0?r=is(n,n.e<=i.toExpNeg||n.e>=i.toExpPos):(Rn(e,1,No),t===void 0?t=i.rounding:Rn(t,0,8),n=dt(new i(n),e,t),r=is(n,e<=n.e||n.e<=i.toExpNeg,e)),n.isNeg()&&!n.isZero()?"-"+r:r};Ne.toSignificantDigits=Ne.toSD=function(e,t){var r=this,n=r.constructor;return e===void 0?(e=n.precision,t=n.rounding):(Rn(e,1,No),t===void 0?t=n.rounding:Rn(t,0,8)),dt(new n(r),e,t)};Ne.toString=function(){var e=this,t=e.constructor,r=is(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()&&!e.isZero()?"-"+r:r};Ne.truncated=Ne.trunc=function(){return dt(new this.constructor(this),this.e+1,1)};Ne.valueOf=Ne.toJSON=function(){var e=this,t=e.constructor,r=is(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()?"-"+r:r};function Jr(e){var t,r,n,i=e.length-1,s="",o=e[0];if(i>0){for(s+=o,t=1;t<i;t++)n=e[t]+"",r=wt-n.length,r&&(s+=uo(r)),s+=n;o=e[t],n=o+"",r=wt-n.length,r&&(s+=uo(r))}else if(o===0)return"0";for(;o%10===0;)o/=10;return s+o}function Rn(e,t,r){if(e!==~~e||e<t||e>r)throw Error(Oo+e)}function Iu(e,t,r,n){var i,s,o,a;for(s=e[0];s>=10;s/=10)--t;return--t<0?(t+=wt,i=0):(i=Math.ceil((t+1)/wt),t%=wt),s=$r(10,wt-t),a=e[i]%s|0,n==null?t<3?(t==0?a=a/100|0:t==1&&(a=a/10|0),o=r<4&&a==99999||r>3&&a==49999||a==5e4||a==0):o=(r<4&&a+1==s||r>3&&a+1==s/2)&&(e[i+1]/s/100|0)==$r(10,t-2)-1||(a==s/2||a==0)&&(e[i+1]/s/100|0)==0:t<4?(t==0?a=a/1e3|0:t==1?a=a/100|0:t==2&&(a=a/10|0),o=(n||r<4)&&a==9999||!n&&r>3&&a==4999):o=((n||r<4)&&a+1==s||!n&&r>3&&a+1==s/2)&&(e[i+1]/s/1e3|0)==$r(10,t-3)-1,o}function df(e,t,r){for(var n,i=[0],s,o=0,a=e.length;o<a;){for(s=i.length;s--;)i[s]*=t;for(i[0]+=W0.indexOf(e.charAt(o++)),n=0;n<i.length;n++)i[n]>r-1&&(i[n+1]===void 0&&(i[n+1]=0),i[n+1]+=i[n]/r|0,i[n]%=r)}return i.reverse()}function tF(e,t){var r,n,i;if(t.isZero())return t;n=t.d.length,n<32?(r=Math.ceil(n/3),i=(1/qd(4,r)).toString()):(r=16,i="2.3283064365386962890625e-10"),e.precision+=r,t=pc(e,1,t.times(i),new e(1));for(var s=r;s--;){var o=t.times(t);t=o.times(o).minus(o).times(8).plus(1)}return e.precision-=r,t}var Qt=function(){function e(n,i,s){var o,a=0,c=n.length;for(n=n.slice();c--;)o=n[c]*i+a,n[c]=o%s|0,a=o/s|0;return a&&n.unshift(a),n}function t(n,i,s,o){var a,c;if(s!=o)c=s>o?1:-1;else for(a=c=0;a<s;a++)if(n[a]!=i[a]){c=n[a]>i[a]?1:-1;break}return c}function r(n,i,s,o){for(var a=0;s--;)n[s]-=a,a=n[s]<i[s]?1:0,n[s]=a*o+n[s]-i[s];for(;!n[0]&&n.length>1;)n.shift()}return function(n,i,s,o,a,c){var u,l,f,h,v,b,y,S,C,O,I,U,D,H,z,ne,le,te,ce,V,L=n.constructor,p=n.s==i.s?1:-1,d=n.d,m=i.d;if(!d||!d[0]||!m||!m[0])return new L(!n.s||!i.s||(d?m&&d[0]==m[0]:!m)?NaN:d&&d[0]==0||!m?p*0:p/0);for(c?(v=1,l=n.e-i.e):(c=Ti,v=wt,l=un(n.e/v)-un(i.e/v)),ce=m.length,le=d.length,C=new L(p),O=C.d=[],f=0;m[f]==(d[f]||0);f++);if(m[f]>(d[f]||0)&&l--,s==null?(H=s=L.precision,o=L.rounding):a?H=s+(n.e-i.e)+1:H=s,H<0)O.push(1),b=!0;else{if(H=H/v+2|0,f=0,ce==1){for(h=0,m=m[0],H++;(f<le||h)&&H--;f++)z=h*c+(d[f]||0),O[f]=z/m|0,h=z%m|0;b=h||f<le}else{for(h=c/(m[0]+1)|0,h>1&&(m=e(m,h,c),d=e(d,h,c),ce=m.length,le=d.length),ne=ce,I=d.slice(0,ce),U=I.length;U<ce;)I[U++]=0;V=m.slice(),V.unshift(0),te=m[0],m[1]>=c/2&&++te;do h=0,u=t(m,I,ce,U),u<0?(D=I[0],ce!=U&&(D=D*c+(I[1]||0)),h=D/te|0,h>1?(h>=c&&(h=c-1),y=e(m,h,c),S=y.length,U=I.length,u=t(y,I,S,U),u==1&&(h--,r(y,ce<S?V:m,S,c))):(h==0&&(u=h=1),y=m.slice()),S=y.length,S<U&&y.unshift(0),r(I,y,U,c),u==-1&&(U=I.length,u=t(m,I,ce,U),u<1&&(h++,r(I,ce<U?V:m,U,c))),U=I.length):u===0&&(h++,I=[0]),O[f++]=h,u&&I[0]?I[U++]=d[ne]||0:(I=[d[ne]],U=1);while((ne++<le||I[0]!==void 0)&&H--);b=I[0]!==void 0}O[0]||O.shift()}if(v==1)C.e=l,JS=b;else{for(f=1,h=O[0];h>=10;h/=10)f++;C.e=f+l*v-1,dt(C,a?s+C.e+1:s,o,b)}return C}}();function dt(e,t,r,n){var i,s,o,a,c,u,l,f,h,v=e.constructor;e:if(t!=null){if(f=e.d,!f)return e;for(i=1,a=f[0];a>=10;a/=10)i++;if(s=t-i,s<0)s+=wt,o=t,l=f[h=0],c=l/$r(10,i-o-1)%10|0;else if(h=Math.ceil((s+1)/wt),a=f.length,h>=a)if(n){for(;a++<=h;)f.push(0);l=c=0,i=1,s%=wt,o=s-wt+1}else break e;else{for(l=a=f[h],i=1;a>=10;a/=10)i++;s%=wt,o=s-wt+i,c=o<0?0:l/$r(10,i-o-1)%10|0}if(n=n||t<0||f[h+1]!==void 0||(o<0?l:l%$r(10,i-o-1)),u=r<4?(c||n)&&(r==0||r==(e.s<0?3:2)):c>5||c==5&&(r==4||n||r==6&&(s>0?o>0?l/$r(10,i-o):0:f[h-1])%10&1||r==(e.s<0?8:7)),t<1||!f[0])return f.length=0,u?(t-=e.e+1,f[0]=$r(10,(wt-t%wt)%wt),e.e=-t||0):f[0]=e.e=0,e;if(s==0?(f.length=h,a=1,h--):(f.length=h+1,a=$r(10,wt-s),f[h]=o>0?(l/$r(10,i-o)%$r(10,o)|0)*a:0),u)for(;;)if(h==0){for(s=1,o=f[0];o>=10;o/=10)s++;for(o=f[0]+=a,a=1;o>=10;o/=10)a++;s!=a&&(e.e++,f[0]==Ti&&(f[0]=1));break}else{if(f[h]+=a,f[h]!=Ti)break;f[h--]=0,a=1}for(s=f.length;f[--s]===0;)f.pop()}return At&&(e.e>v.maxE?(e.d=null,e.e=NaN):e.e<v.minE&&(e.e=0,e.d=[0])),e}function is(e,t,r){if(!e.isFinite())return s5(e);var n,i=e.e,s=Jr(e.d),o=s.length;return t?(r&&(n=r-o)>0?s=s.charAt(0)+"."+s.slice(1)+uo(n):o>1&&(s=s.charAt(0)+"."+s.slice(1)),s=s+(e.e<0?"e":"e+")+e.e):i<0?(s="0."+uo(-i-1)+s,r&&(n=r-o)>0&&(s+=uo(n))):i>=o?(s+=uo(i+1-o),r&&(n=r-i-1)>0&&(s=s+"."+uo(n))):((n=i+1)<o&&(s=s.slice(0,n)+"."+s.slice(n)),r&&(n=r-o)>0&&(i+1===o&&(s+="."),s+=uo(n))),s}function Wd(e,t){var r=e[0];for(t*=wt;r>=10;r/=10)t++;return t}function ed(e,t,r){if(t>eF)throw At=!0,r&&(e.precision=r),Error(ZS);return dt(new e(Zf),t,1,!0)}function Yi(e,t,r){if(t>H0)throw Error(ZS);return dt(new e(Qf),t,r,!0)}function r5(e){var t=e.length-1,r=t*wt+1;if(t=e[t],t){for(;t%10==0;t/=10)r--;for(t=e[0];t>=10;t/=10)r++}return r}function uo(e){for(var t="";e--;)t+="0";return t}function n5(e,t,r,n){var i,s=new e(1),o=Math.ceil(n/wt+4);for(At=!1;;){if(r%2&&(s=s.times(t),qv(s.d,o)&&(i=!0)),r=un(r/2),r===0){r=s.d.length-1,i&&s.d[r]===0&&++s.d[r];break}t=t.times(t),qv(t.d,o)}return At=!0,s}function Wv(e){return e.d[e.d.length-1]&1}function i5(e,t,r){for(var n,i,s=new e(t[0]),o=0;++o<t.length;){if(i=new e(t[o]),!i.s){s=i;break}n=s.cmp(i),(n===r||n===0&&s.s===r)&&(s=i)}return s}function G0(e,t){var r,n,i,s,o,a,c,u=0,l=0,f=0,h=e.constructor,v=h.rounding,b=h.precision;if(!e.d||!e.d[0]||e.e>17)return new h(e.d?e.d[0]?e.s<0?0:1/0:1:e.s?e.s<0?0:e:0/0);for(t==null?(At=!1,c=b):c=t,a=new h(.03125);e.e>-2;)e=e.times(a),f+=5;for(n=Math.log($r(2,f))/Math.LN10*2+5|0,c+=n,r=s=o=new h(1),h.precision=c;;){if(s=dt(s.times(e),c,1),r=r.times(++l),a=o.plus(Qt(s,r,c,1)),Jr(a.d).slice(0,c)===Jr(o.d).slice(0,c)){for(i=f;i--;)o=dt(o.times(o),c,1);if(t==null)if(u<3&&Iu(o.d,c-n,v,u))h.precision=c+=10,r=s=a=new h(1),l=0,u++;else return dt(o,h.precision=b,v,At=!0);else return h.precision=b,o}o=a}}function bo(e,t){var r,n,i,s,o,a,c,u,l,f,h,v=1,b=10,y=e,S=y.d,C=y.constructor,O=C.rounding,I=C.precision;if(y.s<0||!S||!S[0]||!y.e&&S[0]==1&&S.length==1)return new C(S&&!S[0]?-1/0:y.s!=1?NaN:S?0:y);if(t==null?(At=!1,l=I):l=t,C.precision=l+=b,r=Jr(S),n=r.charAt(0),Math.abs(s=y.e)<15e14){for(;n<7&&n!=1||n==1&&r.charAt(1)>3;)y=y.times(e),r=Jr(y.d),n=r.charAt(0),v++;s=y.e,n>1?(y=new C("0."+r),s++):y=new C(n+"."+r.slice(1))}else return u=ed(C,l+2,I).times(s+""),y=bo(new C(n+"."+r.slice(1)),l-b).plus(u),C.precision=I,t==null?dt(y,I,O,At=!0):y;for(f=y,c=o=y=Qt(y.minus(1),y.plus(1),l,1),h=dt(y.times(y),l,1),i=3;;){if(o=dt(o.times(h),l,1),u=c.plus(Qt(o,new C(i),l,1)),Jr(u.d).slice(0,l)===Jr(c.d).slice(0,l))if(c=c.times(2),s!==0&&(c=c.plus(ed(C,l+2,I).times(s+""))),c=Qt(c,new C(v),l,1),t==null)if(Iu(c.d,l-b,O,a))C.precision=l+=b,u=o=y=Qt(f.minus(1),f.plus(1),l,1),h=dt(y.times(y),l,1),i=a=1;else return dt(c,C.precision=I,O,At=!0);else return C.precision=I,c;c=u,i+=2}}function s5(e){return String(e.s*e.s/0)}function hf(e,t){var r,n,i;for((r=t.indexOf("."))>-1&&(t=t.replace(".","")),(n=t.search(/e/i))>0?(r<0&&(r=n),r+=+t.slice(n+1),t=t.substring(0,n)):r<0&&(r=t.length),n=0;t.charCodeAt(n)===48;n++);for(i=t.length;t.charCodeAt(i-1)===48;--i);if(t=t.slice(n,i),t){if(i-=n,e.e=r=r-n-1,e.d=[],n=(r+1)%wt,r<0&&(n+=wt),n<i){for(n&&e.d.push(+t.slice(0,n)),i-=wt;n<i;)e.d.push(+t.slice(n,n+=wt));t=t.slice(n),n=wt-t.length}else n-=i;for(;n--;)t+="0";e.d.push(+t),At&&(e.e>e.constructor.maxE?(e.d=null,e.e=NaN):e.e<e.constructor.minE&&(e.e=0,e.d=[0]))}else e.e=0,e.d=[0];return e}function rF(e,t){var r,n,i,s,o,a,c,u,l;if(t.indexOf("_")>-1){if(t=t.replace(/(\d)_(?=\d)/g,"$1"),t5.test(t))return hf(e,t)}else if(t==="Infinity"||t==="NaN")return+t||(e.s=NaN),e.e=NaN,e.d=null,e;if(JU.test(t))r=16,t=t.toLowerCase();else if(XU.test(t))r=2;else if(ZU.test(t))r=8;else throw Error(Oo+t);for(s=t.search(/p/i),s>0?(c=+t.slice(s+1),t=t.substring(2,s)):t=t.slice(2),s=t.indexOf("."),o=s>=0,n=e.constructor,o&&(t=t.replace(".",""),a=t.length,s=a-s,i=n5(n,new n(r),s,s*2)),u=df(t,r,Ti),l=u.length-1,s=l;u[s]===0;--s)u.pop();return s<0?new n(e.s*0):(e.e=Wd(u,l),e.d=u,At=!1,o&&(e=Qt(e,i,a*4)),c&&(e=e.times(Math.abs(c)<54?$r(2,c):cl.pow(2,c))),At=!0,e)}function nF(e,t){var r,n=t.d.length;if(n<3)return t.isZero()?t:pc(e,2,t,t);r=1.4*Math.sqrt(n),r=r>16?16:r|0,t=t.times(1/qd(5,r)),t=pc(e,2,t,t);for(var i,s=new e(5),o=new e(16),a=new e(20);r--;)i=t.times(t),t=t.times(s.plus(i.times(o.times(i).minus(a))));return t}function pc(e,t,r,n,i){var s,o,a,c,u=e.precision,l=Math.ceil(u/wt);for(At=!1,c=r.times(r),a=new e(n);;){if(o=Qt(a.times(c),new e(t++*t++),u,1),a=i?n.plus(o):n.minus(o),n=Qt(o.times(c),new e(t++*t++),u,1),o=a.plus(n),o.d[l]!==void 0){for(s=l;o.d[s]===a.d[s]&&s--;);if(s==-1)break}s=a,a=n,n=o,o=s}return At=!0,o.d.length=l+1,o}function qd(e,t){for(var r=e;--t;)r*=e;return r}function o5(e,t){var r,n=t.s<0,i=Yi(e,e.precision,1),s=i.times(.5);if(t=t.abs(),t.lte(s))return ks=n?4:1,t;if(r=t.divToInt(i),r.isZero())ks=n?3:2;else{if(t=t.minus(r.times(i)),t.lte(s))return ks=Wv(r)?n?2:3:n?4:1,t;ks=Wv(r)?n?1:4:n?3:2}return t.minus(i).abs()}function c1(e,t,r,n){var i,s,o,a,c,u,l,f,h,v=e.constructor,b=r!==void 0;if(b?(Rn(r,1,No),n===void 0?n=v.rounding:Rn(n,0,8)):(r=v.precision,n=v.rounding),!e.isFinite())l=s5(e);else{for(l=is(e),o=l.indexOf("."),b?(i=2,t==16?r=r*4-3:t==8&&(r=r*3-2)):i=t,o>=0&&(l=l.replace(".",""),h=new v(1),h.e=l.length-o,h.d=df(is(h),10,i),h.e=h.d.length),f=df(l,10,i),s=c=f.length;f[--c]==0;)f.pop();if(!f[0])l=b?"0p+0":"0";else{if(o<0?s--:(e=new v(e),e.d=f,e.e=s,e=Qt(e,h,r,n,0,i),f=e.d,s=e.e,u=JS),o=f[r],a=i/2,u=u||f[r+1]!==void 0,u=n<4?(o!==void 0||u)&&(n===0||n===(e.s<0?3:2)):o>a||o===a&&(n===4||u||n===6&&f[r-1]&1||n===(e.s<0?8:7)),f.length=r,u)for(;++f[--r]>i-1;)f[r]=0,r||(++s,f.unshift(1));for(c=f.length;!f[c-1];--c);for(o=0,l="";o<c;o++)l+=W0.charAt(f[o]);if(b){if(c>1)if(t==16||t==8){for(o=t==16?4:3,--c;c%o;c++)l+="0";for(f=df(l,i,t),c=f.length;!f[c-1];--c);for(o=1,l="1.";o<c;o++)l+=W0.charAt(f[o])}else l=l.charAt(0)+"."+l.slice(1);l=l+(s<0?"p":"p+")+s}else if(s<0){for(;++s;)l="0"+l;l="0."+l}else if(++s>c)for(s-=c;s--;)l+="0";else s<c&&(l=l.slice(0,s)+"."+l.slice(s))}l=(t==16?"0x":t==2?"0b":t==8?"0o":"")+l}return e.s<0?"-"+l:l}function qv(e,t){if(e.length>t)return e.length=t,!0}function iF(e){return new this(e).abs()}function sF(e){return new this(e).acos()}function oF(e){return new this(e).acosh()}function aF(e,t){return new this(e).plus(t)}function cF(e){return new this(e).asin()}function uF(e){return new this(e).asinh()}function lF(e){return new this(e).atan()}function fF(e){return new this(e).atanh()}function dF(e,t){e=new this(e),t=new this(t);var r,n=this.precision,i=this.rounding,s=n+4;return!e.s||!t.s?r=new this(NaN):!e.d&&!t.d?(r=Yi(this,s,1).times(t.s>0?.25:.75),r.s=e.s):!t.d||e.isZero()?(r=t.s<0?Yi(this,n,i):new this(0),r.s=e.s):!e.d||t.isZero()?(r=Yi(this,s,1).times(.5),r.s=e.s):t.s<0?(this.precision=s,this.rounding=1,r=this.atan(Qt(e,t,s,1)),t=Yi(this,s,1),this.precision=n,this.rounding=i,r=e.s<0?r.minus(t):r.plus(t)):r=this.atan(Qt(e,t,s,1)),r}function hF(e){return new this(e).cbrt()}function pF(e){return dt(e=new this(e),e.e+1,2)}function mF(e,t,r){return new this(e).clamp(t,r)}function gF(e){if(!e||typeof e!="object")throw Error(zd+"Object expected");var t,r,n,i=e.defaults===!0,s=["precision",1,No,"rounding",0,8,"toExpNeg",-Qa,0,"toExpPos",0,Qa,"maxE",0,Qa,"minE",-Qa,0,"modulo",0,9];for(t=0;t<s.length;t+=3)if(r=s[t],i&&(this[r]=q0[r]),(n=e[r])!==void 0)if(un(n)===n&&n>=s[t+1]&&n<=s[t+2])this[r]=n;else throw Error(Oo+r+": "+n);if(r="crypto",i&&(this[r]=q0[r]),(n=e[r])!==void 0)if(n===!0||n===!1||n===0||n===1)if(n)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[r]=!0;else throw Error(QS);else this[r]=!1;else throw Error(Oo+r+": "+n);return this}function yF(e){return new this(e).cos()}function vF(e){return new this(e).cosh()}function a5(e){var t,r,n;function i(s){var o,a,c,u=this;if(!(u instanceof i))return new i(s);if(u.constructor=i,Hv(s)){u.s=s.s,At?!s.d||s.e>i.maxE?(u.e=NaN,u.d=null):s.e<i.minE?(u.e=0,u.d=[0]):(u.e=s.e,u.d=s.d.slice()):(u.e=s.e,u.d=s.d?s.d.slice():s.d);return}if(c=typeof s,c==="number"){if(s===0){u.s=1/s<0?-1:1,u.e=0,u.d=[0];return}if(s<0?(s=-s,u.s=-1):u.s=1,s===~~s&&s<1e7){for(o=0,a=s;a>=10;a/=10)o++;At?o>i.maxE?(u.e=NaN,u.d=null):o<i.minE?(u.e=0,u.d=[0]):(u.e=o,u.d=[s]):(u.e=o,u.d=[s]);return}if(s*0!==0){s||(u.s=NaN),u.e=NaN,u.d=null;return}return hf(u,s.toString())}if(c==="string")return(a=s.charCodeAt(0))===45?(s=s.slice(1),u.s=-1):(a===43&&(s=s.slice(1)),u.s=1),t5.test(s)?hf(u,s):rF(u,s);if(c==="bigint")return s<0?(s=-s,u.s=-1):u.s=1,hf(u,s.toString());throw Error(Oo+s)}if(i.prototype=Ne,i.ROUND_UP=0,i.ROUND_DOWN=1,i.ROUND_CEIL=2,i.ROUND_FLOOR=3,i.ROUND_HALF_UP=4,i.ROUND_HALF_DOWN=5,i.ROUND_HALF_EVEN=6,i.ROUND_HALF_CEIL=7,i.ROUND_HALF_FLOOR=8,i.EUCLID=9,i.config=i.set=gF,i.clone=a5,i.isDecimal=Hv,i.abs=iF,i.acos=sF,i.acosh=oF,i.add=aF,i.asin=cF,i.asinh=uF,i.atan=lF,i.atanh=fF,i.atan2=dF,i.cbrt=hF,i.ceil=pF,i.clamp=mF,i.cos=yF,i.cosh=vF,i.div=bF,i.exp=wF,i.floor=_F,i.hypot=xF,i.ln=SF,i.log=EF,i.log10=CF,i.log2=TF,i.max=AF,i.min=MF,i.mod=OF,i.mul=IF,i.pow=kF,i.random=jF,i.round=RF,i.sign=PF,i.sin=NF,i.sinh=$F,i.sqrt=DF,i.sub=LF,i.sum=BF,i.tan=UF,i.tanh=FF,i.trunc=VF,e===void 0&&(e={}),e&&e.defaults!==!0)for(n=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],t=0;t<n.length;)e.hasOwnProperty(r=n[t++])||(e[r]=this[r]);return i.config(e),i}function bF(e,t){return new this(e).div(t)}function wF(e){return new this(e).exp()}function _F(e){return dt(e=new this(e),e.e+1,3)}function xF(){var e,t,r=new this(0);for(At=!1,e=0;e<arguments.length;)if(t=new this(arguments[e++]),t.d)r.d&&(r=r.plus(t.times(t)));else{if(t.s)return At=!0,new this(1/0);r=t}return At=!0,r.sqrt()}function Hv(e){return e instanceof cl||e&&e.toStringTag===e5||!1}function SF(e){return new this(e).ln()}function EF(e,t){return new this(e).log(t)}function TF(e){return new this(e).log(2)}function CF(e){return new this(e).log(10)}function AF(){return i5(this,arguments,-1)}function MF(){return i5(this,arguments,1)}function OF(e,t){return new this(e).mod(t)}function IF(e,t){return new this(e).mul(t)}function kF(e,t){return new this(e).pow(t)}function jF(e){var t,r,n,i,s=0,o=new this(1),a=[];if(e===void 0?e=this.precision:Rn(e,1,No),n=Math.ceil(e/wt),this.crypto)if(crypto.getRandomValues)for(t=crypto.getRandomValues(new Uint32Array(n));s<n;)i=t[s],i>=429e7?t[s]=crypto.getRandomValues(new Uint32Array(1))[0]:a[s++]=i%1e7;else if(crypto.randomBytes){for(t=crypto.randomBytes(n*=4);s<n;)i=t[s]+(t[s+1]<<8)+(t[s+2]<<16)+((t[s+3]&127)<<24),i>=214e7?crypto.randomBytes(4).copy(t,s):(a.push(i%1e7),s+=4);s=n/4}else throw Error(QS);else for(;s<n;)a[s++]=Math.random()*1e7|0;for(n=a[--s],e%=wt,n&&e&&(i=$r(10,wt-e),a[s]=(n/i|0)*i);a[s]===0;s--)a.pop();if(s<0)r=0,a=[0];else{for(r=-1;a[0]===0;r-=wt)a.shift();for(n=1,i=a[0];i>=10;i/=10)n++;n<wt&&(r-=wt-n)}return o.e=r,o.d=a,o}function RF(e){return dt(e=new this(e),e.e+1,this.rounding)}function PF(e){return e=new this(e),e.d?e.d[0]?e.s:0*e.s:e.s||NaN}function NF(e){return new this(e).sin()}function $F(e){return new this(e).sinh()}function DF(e){return new this(e).sqrt()}function LF(e,t){return new this(e).sub(t)}function BF(){var e=0,t=arguments,r=new this(t[e]);for(At=!1;r.s&&++e<t.length;)r=r.plus(t[e]);return At=!0,dt(r,this.precision,this.rounding)}function UF(e){return new this(e).tan()}function FF(e){return new this(e).tanh()}function VF(e){return dt(e=new this(e),e.e+1,1)}Ne[Symbol.for("nodejs.util.inspect.custom")]=Ne.toString;Ne[Symbol.toStringTag]="Decimal";var cl=Ne.constructor=a5(q0);Zf=new cl(Zf);Qf=new cl(Qf);var c5=cl;function zF(e,t,r){return Number(u5(new c5(e.toString()),t,r).toFixed(0))}function Gv(e,t,r){const n=u5(new c5(e.toString()),t,r);return new YU.default(n.toFixed(0))}function u5(e,t,r){return t?e.mul(1-r):e.mul(1+r)}var Kv=class{constructor(e,t){if(e!==0)throw new Error("CetusRouter only supported on mainnet");this.globalConfig=e===0?"0xdaa46292632c3c4d8f31f23ea0f9b36a28ff3677e9684980e4438403a67a3d8f":"0x9774e359588ead122af1c7e7f64e14ade261cfeecdb5d0eb4a5b3b4c8ab8bd3e",this.partner=t??(e===0?"0x639b5e433da31739e800cd085f356e64cae222966d0f1b11bd9dc76b322ff58b":"0x1f5fa5c820f40d43fc47815ad06d95e40a1942ff72a732a92e8ef4aa8cde70a5")}swap(e,t,r,n){const i=this.prepareSwapData(t);this.executeSwapContract(e,i,r)}prepareSwapData(e){if(e.path.publishedAt==null)throw new Error("Cetus not set publishedAt");const t=e.path,[r,n]=t.direction?[t.from,t.target]:[t.target,t.from],i=e.isLastUseOfIntermediateToken?Kt.MAX_AMOUNT_IN:t.amountIn;return{coinAType:r,coinBType:n,direction:t.direction,amountIn:i,publishedAt:t.publishedAt,poolId:t.id}}executeSwapContract(e,t,r){const n=[r,e.object(this.globalConfig),e.object(t.poolId),e.object(this.partner),e.pure.bool(t.direction),e.pure.u64(t.amountIn),e.object(fr.SUI_CLOCK_OBJECT_ID)];e.moveCall({target:`${t.publishedAt}::cetus::swap`,typeArguments:[t.coinAType,t.coinBType],arguments:n})}flashSwapFixedOutput(e,t,r,n){const i=[n,e.object(this.globalConfig),e.object(t.id),e.object(this.partner),r,e.pure.bool(t.direction),e.pure.bool(!1),e.object(fr.SUI_CLOCK_OBJECT_ID)],[s,o]=t.direction?[t.from,t.target]:[t.target,t.from],[a,c]=e.moveCall({target:`${t.publishedAt}::cetus::flash_swap_fixed_output`,typeArguments:[s,o],arguments:i});return{flashReceipt:a,repayAmount:c}}repayFlashSwapFixedOutput(e,t,r,n){const i=[r,e.object(this.globalConfig),e.object(t.id),e.object(this.partner),e.pure.bool(t.direction),n],[s,o]=t.direction?[t.from,t.target]:[t.target,t.from];e.moveCall({target:`${t.publishedAt}::cetus::repay_flash_swap_fixed_output`,typeArguments:[s,o],arguments:i})}add(e,t,r,n){const i=[t,r];return e.moveCall({target:`${n}::cetus::add`,typeArguments:[],arguments:i})}sub(e,t,r,n){const i=[t,r];return e.moveCall({target:`${n}::cetus::sub`,typeArguments:[],arguments:i})}},WF=class{constructor(e){if(e!==0)throw new Error("Kriya V3 only supported on mainnet");this.version="0xf5145a7ac345ca8736cf8c76047d00d6d378f30e81be6f6eb557184d9de93c78"}swap(e,t,r,n){const i=this.prepareSwapData(t);this.executeSwapContract(e,i,r)}prepareSwapData(e){if(e.path.publishedAt==null)throw new Error("Kriya V3 not set publishedAt");const t=e.path,[r,n]=t.direction?[t.from,t.target]:[t.target,t.from],i=e.isLastUseOfIntermediateToken?Kt.MAX_AMOUNT_IN:t.amountIn;return{coinAType:r,coinBType:n,direction:t.direction,amountIn:i,publishedAt:t.publishedAt,poolId:t.id}}executeSwapContract(e,t,r){const n=[r,e.object(t.poolId),e.object(this.version),e.pure.bool(t.direction),e.pure.u64(t.amountIn),e.object(fr.SUI_CLOCK_OBJECT_ID)];e.moveCall({target:`${t.publishedAt}::kriya_clmm::swap`,typeArguments:[t.coinAType,t.coinBType],arguments:n})}},qF=class{constructor(e){if(e!==0)throw new Error("FlowX V3 only supported on mainnet");this.poolRegistry="0x27565d24a4cd51127ac90e4074a841bbe356cca7bf5759ddc14a975be1632abc",this.versioned="0x67624a1533b5aff5d0dfcf5e598684350efd38134d2d245f475524c03a64e656"}swap(e,t,r,n){const i=this.prepareSwapData(t);this.executeSwapContract(e,i,r)}prepareSwapData(e){if(e.path.publishedAt==null)throw new Error("FlowX V3 not set publishedAt");const t=e.path,[r,n]=t.direction?[t.from,t.target]:[t.target,t.from],i=e.isLastUseOfIntermediateToken?Kt.MAX_AMOUNT_IN:t.amountIn,s=t.feeRate*1e6;return{coinAType:r,coinBType:n,direction:t.direction,amountIn:i,publishedAt:t.publishedAt,poolId:t.id,feeRate:s}}executeSwapContract(e,t,r){const n=[r,e.object(this.poolRegistry),e.object(this.versioned),e.pure.u64(t.feeRate),e.pure.u64(t.amountIn),e.pure.bool(t.direction),e.object(fr.SUI_CLOCK_OBJECT_ID)];e.moveCall({target:`${t.publishedAt}::flowx_clmm::swap`,typeArguments:[t.coinAType,t.coinBType],arguments:n})}},HF=class{constructor(e){if(e!==0)throw new Error("Turbos only supported on mainnet");this.versioned="0xf1cf0e81048df168ebeb1b8030fad24b3e0b53ae827c25053fff0779c1445b6f"}swap(e,t,r,n){const i=this.prepareSwapData(t);this.executeSwapContract(e,i,r)}prepareSwapData(e){if(e.path.publishedAt==null)throw new Error("Turbos not set publishedAt");const t=e.path,[r,n]=t.direction?[t.from,t.target]:[t.target,t.from],i=e.isLastUseOfIntermediateToken?Kt.MAX_AMOUNT_IN:t.amountIn;if(t.extendedDetails==null)throw new Error("Extended details not supported");if(t.extendedDetails.turbos_fee_type==null)throw new Error("Turbos fee type not supported");const s=t.extendedDetails.turbos_fee_type;return{coinAType:r,coinBType:n,feeType:s,direction:t.direction,amountIn:i,publishedAt:t.publishedAt,poolId:t.id}}executeSwapContract(e,t,r){const n=[r,e.object(t.poolId),e.object(this.versioned),e.pure.bool(t.direction),e.pure.u64(t.amountIn),e.object(fr.SUI_CLOCK_OBJECT_ID)];e.moveCall({target:`${t.publishedAt}::turbos::swap`,typeArguments:[t.coinAType,t.coinBType,t.feeType],arguments:n})}},GF=class{constructor(e){if(e!==0)throw new Error("Bluefin only supported on mainnet");this.globalConfig="0x03db251ba509a8d5d8777b6338836082335d93eecbdd09a11e190a1cff51c352"}swap(e,t,r,n){const i=this.prepareSwapData(t);this.executeSwapContract(e,i,r)}prepareSwapData(e){if(e.path.publishedAt==null)throw new Error("Bluefin not set publishedAt");const t=e.path,[r,n]=t.direction?[t.from,t.target]:[t.target,t.from],i=e.isLastUseOfIntermediateToken?Kt.MAX_AMOUNT_IN:t.amountIn;return{coinAType:r,coinBType:n,direction:t.direction,amountIn:i,publishedAt:t.publishedAt,poolId:t.id}}executeSwapContract(e,t,r){const n=[r,e.object(this.globalConfig),e.object(t.poolId),e.pure.bool(t.direction),e.pure.u64(t.amountIn),e.object(fr.SUI_CLOCK_OBJECT_ID)];e.moveCall({target:`${t.publishedAt}::bluefin::swap`,typeArguments:[t.coinAType,t.coinBType],arguments:n})}},KF=class{constructor(e){if(e!==0)throw new Error("Momentum only supported on mainnet");this.version="0x2375a0b1ec12010aaea3b2545acfa2ad34cfbba03ce4b59f4c39e1e25eed1b2a"}swap(e,t,r,n){const i=this.prepareSwapData(t);this.executeSwapContract(e,i,r)}prepareSwapData(e){const t=e.path;if(e.path.publishedAt==null)throw new Error("Momentum not set publishedAt");const[r,n]=t.direction?[t.from,t.target]:[t.target,t.from],i=e.isLastUseOfIntermediateToken?Kt.MAX_AMOUNT_IN:t.amountIn;return{coinAType:r,coinBType:n,direction:t.direction,amountIn:i,publishedAt:t.publishedAt,poolId:t.id}}executeSwapContract(e,t,r){const n=[r,e.object(t.poolId),e.pure.bool(t.direction),e.pure.u64(t.amountIn),e.object(this.version),e.object(fr.SUI_CLOCK_OBJECT_ID)];e.moveCall({target:`${t.publishedAt}::momentum::swap`,typeArguments:[t.coinAType,t.coinBType],arguments:n})}},YF=class{constructor(e){if(e!==0)throw new Error("Magma only supported on mainnet");this.globalConfig="0x4c4e1402401f72c7d8533d0ed8d5f8949da363c7a3319ccef261ffe153d32f8a"}swap(e,t,r,n){const i=this.prepareSwapData(t);this.executeSwapContract(e,i,r)}prepareSwapData(e){const t=e.path;if(e.path.publishedAt==null)throw new Error("Magma not set publishedAt");const[r,n]=t.direction?[t.from,t.target]:[t.target,t.from],i=e.isLastUseOfIntermediateToken?Kt.MAX_AMOUNT_IN:t.amountIn;return{coinAType:r,coinBType:n,direction:t.direction,amountIn:i,publishedAt:t.publishedAt,poolId:t.id}}executeSwapContract(e,t,r){const n=[r,e.object(this.globalConfig),e.object(t.poolId),e.pure.bool(t.direction),e.pure.u64(t.amountIn),e.object(fr.SUI_CLOCK_OBJECT_ID)];e.moveCall({target:`${t.publishedAt}::magma::swap`,typeArguments:[t.coinAType,t.coinBType],arguments:n})}},XF=class{constructor(e){if(e!==0)throw new Error("Kriya V2 only supported on mainnet")}swap(e,t,r,n){const i=this.prepareSwapData(t);this.executeSwapContract(e,i,r)}prepareSwapData(e){const t=e.path;if(e.path.publishedAt==null)throw new Error("Kriya V2 not set publishedAt");const[r,n]=t.direction?[t.from,t.target]:[t.target,t.from],i=e.isLastUseOfIntermediateToken?Kt.MAX_AMOUNT_IN:t.amountIn;return{coinAType:r,coinBType:n,direction:t.direction,amountIn:i,publishedAt:t.publishedAt,poolId:t.id}}executeSwapContract(e,t,r){const n=[r,e.object(t.poolId),e.pure.bool(t.direction),e.pure.u64(t.amountIn)];e.moveCall({target:`${t.publishedAt}::kriya_amm::swap`,typeArguments:[t.coinAType,t.coinBType],arguments:n})}},JF=class{constructor(e){if(e!==0)throw new Error("FlowX V2 only supported on mainnet");this.container="0xb65dcbf63fd3ad5d0ebfbf334780dc9f785eff38a4459e37ab08fa79576ee511"}swap(e,t,r,n){const i=this.prepareSwapData(t);this.executeSwapContract(e,i,r)}prepareSwapData(e){const t=e.path;if(e.path.publishedAt==null)throw new Error("FlowX V2 not set publishedAt");const[r,n]=t.direction?[t.from,t.target]:[t.target,t.from],i=e.isLastUseOfIntermediateToken?Kt.MAX_AMOUNT_IN:t.amountIn;return{coinAType:r,coinBType:n,direction:t.direction,amountIn:i,publishedAt:t.publishedAt,poolId:t.id}}executeSwapContract(e,t,r){const n=[r,e.object(this.container),e.pure.bool(t.direction),e.pure.u64(t.amountIn)];e.moveCall({target:`${t.publishedAt}::flowx_amm::swap`,typeArguments:[t.coinAType,t.coinBType],arguments:n})}},ZF=class{constructor(e){if(e!==0)throw new Error("BlueMove only supported on mainnet");this.dexInfo="0x3f2d9f724f4a1ce5e71676448dc452be9a6243dac9c5b975a588c8c867066e92"}swap(e,t,r,n){const i=this.prepareSwapData(t);this.executeSwapContract(e,i,r)}prepareSwapData(e){const t=e.path;if(e.path.publishedAt==null)throw new Error("BlueMove not set publishedAt");const[r,n]=t.direction?[t.from,t.target]:[t.target,t.from],i=e.isLastUseOfIntermediateToken?Kt.MAX_AMOUNT_IN:t.amountIn;return{coinAType:r,coinBType:n,direction:t.direction,amountIn:i,publishedAt:t.publishedAt,poolId:t.id}}executeSwapContract(e,t,r){const n=[r,e.object(this.dexInfo),e.pure.bool(t.direction),e.pure.u64(t.amountIn)];e.moveCall({target:`${t.publishedAt}::bluemove::swap`,typeArguments:[t.coinAType,t.coinBType],arguments:n})}},QF=class{constructor(e){if(e!==0)throw new Error("DeepBook V3 only supported on mainnet");this.env=e,this.globalConfig="0x699d455ab8c5e02075b4345ea1f91be55bf46064ae6026cc2528e701ce3ac135"}swap(e,t,r,n){const i=this.prepareSwapData(t);this.executeSwapContract(e,i,r,n)}prepareSwapData(e){if(e.path.publishedAt==null)throw new Error("DeepBook V3 not set publishedAt");const t=e.path,[r,n]=t.direction?[t.from,t.target]:[t.target,t.from],i=e.isLastUseOfIntermediateToken?Kt.MAX_AMOUNT_IN:t.amountIn;return{coinAType:r,coinBType:n,direction:t.direction,amountIn:i,publishedAt:t.publishedAt,poolId:t.id}}executeSwapContract(e,t,r,n){const i=(n==null?void 0:n.deepbookv3DeepFee)||e.moveCall({target:"0x2::coin::zero",typeArguments:[this.getDeepFeeType()]}),s=[r,e.object(this.globalConfig),e.object(t.poolId),e.pure.u64(t.amountIn),e.pure.bool(t.direction),i,e.object(fr.SUI_CLOCK_OBJECT_ID)];e.moveCall({target:`${t.publishedAt}::deepbookv3::swap`,typeArguments:[t.coinAType,t.coinBType],arguments:s})}getDeepFeeType(){return this.env===0?Jf.Mainnet:Jf.Testnet}},eV=class{constructor(e){if(e!==0)throw new Error("Aftermath only supported on mainnet");this.poolRegistry="0xfcc774493db2c45c79f688f88d28023a3e7d98e4ee9f48bbf5c7990f651577ae",this.protocolFeeVault="0xf194d9b1bcad972e45a7dd67dd49b3ee1e3357a00a50850c52cd51bb450e13b4",this.treasury="0x28e499dff5e864a2eafe476269a4f5035f1c16f338da7be18b103499abf271ce",this.insuranceFund="0xf0c40d67b078000e18032334c3325c47b9ec9f3d9ae4128be820d54663d14e3b",this.referralVault="0x35d35b0e5b177593d8c3a801462485572fc30861e6ce96a55af6dc4730709278"}swap(e,t,r,n){const i=this.prepareSwapData(t);this.executeSwapContract(e,i,r)}prepareSwapData(e){var t,r;if(e.path.publishedAt==null)throw new Error("Aftermath not set publishedAt");const n=e.path,[i,s]=n.direction?[n.from,n.target]:[n.target,n.from],o=e.isLastUseOfIntermediateToken?"18446744073709551615":n.amountIn;return{coinAType:i,coinBType:s,feeType:((t=n.extendedDetails)==null?void 0:t.aftermath_lp_supply_type)||((r=n.extendedDetails)==null?void 0:r.aftermath_lp_supply_type)||"0x2::sui::SUI",direction:n.direction,amountIn:o,expectAmountOut:n.amountOut,publishedAt:n.publishedAt,poolId:n.id}}executeSwapContract(e,t,r){const n=[r,e.object(t.poolId),e.object(this.poolRegistry),e.object(this.protocolFeeVault),e.object(this.treasury),e.object(this.insuranceFund),e.object(this.referralVault),e.pure.bool(t.direction),e.pure.u64(t.amountIn),e.pure.u64(t.expectAmountOut)];e.moveCall({target:`${t.publishedAt}::aftermath::swap`,typeArguments:[t.coinAType,t.coinBType,t.feeType],arguments:n})}},tV=class{constructor(e){if(e!==0)throw new Error("Steamm CPMM only supported on mainnet")}swap(e,t,r,n){const i=this.prepareSwapData(t);this.executeSwapContract(e,i,r)}validateExtendedDetails(e){const t=["steamm_bank_a","steamm_bank_b","steamm_lending_market","steamm_lending_market_type","steamm_btoken_a_type","steamm_btoken_b_type","steamm_lp_token_type"];for(const r of t)if(e[r]==null)throw new Error(`Steamm CPMM ${r} not supported`)}prepareSwapData(e){const t=e.path;if(e.path.publishedAt==null)throw new Error("Steamm CPMM not set publishedAt");if(!t.extendedDetails)throw new Error("Extended details not found for Steamm CPMM");this.validateExtendedDetails(t.extendedDetails);const{direction:r,from:n,target:i}=t,[s,o]=r?[n,i]:[i,n],a=e.isLastUseOfIntermediateToken?Kt.MAX_AMOUNT_IN:t.amountIn;return{coinAType:s,coinBType:o,direction:r,amountIn:a,publishedAt:t.publishedAt,poolId:t.id,extendedDetails:t.extendedDetails}}executeSwapContract(e,t,r){const n=[r,e.object(t.poolId),e.object(t.extendedDetails.steamm_bank_a),e.object(t.extendedDetails.steamm_bank_b),e.object(t.extendedDetails.steamm_lending_market),e.pure.bool(t.direction),e.pure.u64(t.amountIn),e.object(fr.SUI_CLOCK_OBJECT_ID)];e.moveCall({target:`${t.publishedAt}::steamm_cpmm::swap`,typeArguments:[t.extendedDetails.steamm_lending_market_type,t.coinAType,t.coinBType,t.extendedDetails.steamm_btoken_a_type,t.extendedDetails.steamm_btoken_b_type,t.extendedDetails.steamm_lp_token_type],arguments:n})}},rV=class{constructor(e){if(e!==0)throw new Error("Scallop only supported on mainnet");this.version="0x07871c4b3c847a0f674510d4978d5cf6f960452795e8ff6f189fd2088a3f6ac7",this.marketData="0xa757975255146dc9686aa823b7838b507f315d704f428cbadad2f4ea061939d9"}swap(e,t,r,n){const i=this.prepareSwapData(t);this.executeSwapContract(e,i,r)}prepareSwapData(e){const t=e.path;if(e.path.publishedAt==null)throw new Error("Scallop not set publishedAt");const[r,n]=t.direction?[t.from,t.target]:[t.from,t.target],i=e.isLastUseOfIntermediateToken?Kt.MAX_AMOUNT_IN:t.amountIn;if(t.extendedDetails==null)throw new Error("Extended details not supported");const s=t.extendedDetails.scallopScoinTreasury||t.extendedDetails.scallop_scoin_treasury;if(s==null)throw new Error("Scallop scoin treasury not supported");return{coinAType:r,coinBType:n,direction:t.direction,amountIn:i,publishedAt:t.publishedAt,poolId:t.id,scallopScoinTreasury:s}}executeSwapContract(e,t,r){const n=[r,e.object(this.version),e.object(this.marketData),e.object(t.scallopScoinTreasury),e.pure.u64(t.amountIn),e.object(fr.SUI_CLOCK_OBJECT_ID)],i=t.direction?"swap_a2b":"swap_b2a";e.moveCall({target:`${t.publishedAt}::scallop::${i}`,typeArguments:[t.coinAType,t.coinBType],arguments:n})}},Yv=class{constructor(e){if(e!==0)throw new Error("Springsui only supported on mainnet")}swap(e,t,r,n){const i=this.prepareSwapData(t);this.executeSwapContract(e,i,r)}prepareSwapData(e){const t=e.path;if(e.path.publishedAt==null)throw new Error("Springsui not set publishedAt");const r=t.direction?t.target:t.from,n=e.isLastUseOfIntermediateToken?Kt.MAX_AMOUNT_IN:t.amountIn;return{springSUICoinType:r,direction:t.direction,amountIn:n,publishedAt:t.publishedAt,poolId:t.id}}executeSwapContract(e,t,r){const n=[r,e.object(t.poolId),e.object("0x5"),e.pure.u64(t.amountIn),e.pure.bool(t.direction)];e.moveCall({target:`${t.publishedAt}::springsui::swap`,typeArguments:[t.springSUICoinType],arguments:n})}},nV=class{constructor(e,t){if(e!==0)throw new Error("Haedal PMM only supported on mainnet");this.pythPriceIDs=t}swap(e,t,r,n){const i=t.path;if(!i.extendedDetails)throw new Error("Extended details not found for Haedal PMM");this.validateExtendedDetails(i.extendedDetails);const s=this.prepareSwapData(t);this.executeSwapContract(e,s,r)}validateExtendedDetails(e){if(!e.haedal_pmm_base_price_seed)throw new Error("Haedal PMM base price seed not supported");if(!e.haedal_pmm_quote_price_seed)throw new Error("Haedal PMM quote price seed not supported")}prepareSwapData(e){const t=e.path;if(e.path.publishedAt==null)throw new Error("Haedal PMM not set publishedAt");const r=t.extendedDetails,[n,i]=t.direction?[t.from,t.target]:[t.target,t.from],s=e.isLastUseOfIntermediateToken?Kt.MAX_AMOUNT_IN:t.amountIn,o=r.haedal_pmm_base_price_seed,a=r.haedal_pmm_quote_price_seed,c=this.pythPriceIDs.get(o),u=this.pythPriceIDs.get(a);if(!c||!u)throw new Error("Haedal HMM requires oracle price IDs for both coins");return{coinAType:n,coinBType:i,basePriceId:c,quotePriceId:u,a2b:t.direction,amountIn:s,publishedAt:t.publishedAt,poolId:t.id}}executeSwapContract(e,t,r){const n=[r,e.object(t.poolId),e.object(t.basePriceId),e.object(t.quotePriceId),e.pure.u64(t.amountIn),e.pure.bool(t.a2b),e.object(fr.SUI_CLOCK_OBJECT_ID)];e.moveCall({target:`${t.publishedAt}::haedal_hmm::swap`,typeArguments:[t.coinAType,t.coinBType],arguments:n})}},iV=class{constructor(e,t){if(e===1)throw new Error("Obric is not supported on testnet");this.pythStateObjectId="0x1f9310238ee9298fb703c3419030b35b22bb1cc37113e3bb5007c99aec79e5b8",this.pythPriceIDs=t}swap(e,t,r,n){const i=this.prepareSwapData(t);this.executeSwapContract(e,i,r)}prepareSwapData(e){const t=e.path;if(e.path.publishedAt==null)throw new Error("Obric not set publishedAt");if(!t.extendedDetails)throw new Error("Extended details not supported in obric");const{direction:r,from:n,target:i}=t,[s,o]=r?[n,i]:[i,n],a=e.isLastUseOfIntermediateToken?Kt.MAX_AMOUNT_IN:t.amountIn;let c,u;if(t.extendedDetails.obric_coin_a_price_seed&&t.extendedDetails.obric_coin_b_price_seed)c=this.pythPriceIDs.get(t.extendedDetails.obric_coin_a_price_seed),u=this.pythPriceIDs.get(t.extendedDetails.obric_coin_b_price_seed);else if(t.extendedDetails.obric_coin_a_price_id&&t.extendedDetails.obric_coin_b_price_id)c=t.extendedDetails.obric_coin_a_price_id,u=t.extendedDetails.obric_coin_b_price_id;else throw new Error("Base price id or quote price id not supported");return{coinAType:s,coinBType:o,coinAPriceInfoObjectId:c,coinBPriceInfoObjectId:u,direction:r,amountIn:a,publishedAt:t.publishedAt,poolId:t.id,extendedDetails:t.extendedDetails}}executeSwapContract(e,t,r){if(!t.coinAPriceInfoObjectId||!t.coinBPriceInfoObjectId)throw new Error("Base price info object id or quote price info object id not found");const n=[r,e.object(t.poolId),e.pure.u64(t.amountIn),e.pure.bool(t.direction),e.object(this.pythStateObjectId),e.object(t.coinAPriceInfoObjectId),e.object(t.coinBPriceInfoObjectId),e.object(fr.SUI_CLOCK_OBJECT_ID)];e.moveCall({target:`${t.publishedAt}::obric::swap`,typeArguments:[t.coinAType,t.coinBType],arguments:n})}},sV=class{constructor(e,t){if(e!==0)throw new Error("Sevenk only supported on mainnet");this.oraclePublishedAt="0x8c36ea167c5e6da8c3d60b4fc897416105dcb986471bd81cfbfd38720a4487c0",this.pythPriceIDs=t}swap(e,t,r,n){const i=this.prepareSwapData(t);this.executeSwapContract(e,i,r,n)}prepareSwapData(e){const t=e.path;if(e.path.publishedAt==null)throw new Error("Sevenk not set publishedAt");if(!t.extendedDetails)throw new Error("Extended details not found for Sevenk");const{direction:r,from:n,target:i}=t,[s,o,a]=r?["swap_a2b",n,i]:["swap_b2a",i,n],c=e.isLastUseOfIntermediateToken?Kt.MAX_AMOUNT_IN:t.amountIn,u=t.extendedDetails;if(!u.sevenk_coin_a_price_seed||!u.sevenk_coin_b_price_seed||!u.sevenk_oracle_config_a||!u.sevenk_oracle_config_b||!u.sevenk_lp_cap_type)throw new Error("Required Sevenk extended details not found");const l=u.sevenk_coin_a_price_seed,f=u.sevenk_coin_b_price_seed,h=u.sevenk_oracle_config_a,v=u.sevenk_oracle_config_b,b=u.sevenk_lp_cap_type,y=this.pythPriceIDs.get(l),S=this.pythPriceIDs.get(f);if(!y||!S)throw new Error("Sevenk price info object IDs not found");return{func:s,coinAType:o,coinBType:a,coinAPriceId:y,coinBPriceId:S,coinAOracleId:h,coinBOracleId:v,lpCapType:b,direction:r,amountIn:c,publishedAt:t.publishedAt,poolId:t.id,extendedDetails:t.extendedDetails}}executeSwapContract(e,t,r,n){const i=e.moveCall({target:`${this.oraclePublishedAt}::oracle::new_holder`,typeArguments:[],arguments:[]});e.moveCall({target:`${this.oraclePublishedAt}::pyth::get_price`,typeArguments:[],arguments:[e.object(t.coinAOracleId),i,e.object(t.coinAPriceId),e.object(fr.SUI_CLOCK_OBJECT_ID)]}),e.moveCall({target:`${this.oraclePublishedAt}::pyth::get_price`,typeArguments:[],arguments:[e.object(t.coinBOracleId),i,e.object(t.coinBPriceId),e.object(fr.SUI_CLOCK_OBJECT_ID)]});const s=[r,e.object(t.poolId),i,e.pure.u64(t.amountIn)];e.moveCall({target:`${t.publishedAt}::sevenk::${t.func}`,typeArguments:[t.coinAType,t.coinBType,t.lpCapType],arguments:s})}},oV=class{constructor(e,t){if(e!==0)throw new Error("Steamm OMM only supported on mainnet");this.pythPriceIDs=t,this.oraclePackageId="0xe84b649199654d18c38e727212f5d8dacfc3cf78d60d0a7fc85fd589f280eb2b"}swap(e,t,r,n){const i=t.path;if(!i.extendedDetails)throw new Error("Extended details not found for Steamm OMM");this.validateExtendedDetails(i.extendedDetails);const s=this.prepareSwapData(t);this.executeSwapContract(e,s,r)}validateExtendedDetails(e){const t=["steamm_bank_a","steamm_bank_b","steamm_lending_market","steamm_lending_market_type","steamm_btoken_a_type","steamm_btoken_b_type","steamm_lp_token_type","steammOracleRegistryId","steammOracleIndexA","steammOracleIndexB","steammOraclePythPriceSeedA","steammOraclePythPriceSeedB"];for(const r of t)if(e[r]==null)throw new Error(`Steamm ${r} not supported`)}prepareSwapData(e){const t=e.path;if(e.path.publishedAt==null)throw new Error("Steamm OMM not set publishedAt");const r=t.extendedDetails,{direction:n,from:i,target:s}=t,[o,a,c]=n?["swap_a2b_v2",i,s]:["swap_b2a_v2",s,i],u=e.isLastUseOfIntermediateToken?Kt.MAX_AMOUNT_IN:t.amountIn,l=r.steamm_oracle_pyth_price_seed_a,f=r.steamm_oracle_pyth_price_seed_b;if(!l||!f)throw new Error("Steamm oracle price seeds not found");const h=this.pythPriceIDs.get(l),v=this.pythPriceIDs.get(f);if(!h||!v)throw new Error("Base price info object id or quote price info object id not found");return{func:o,coinAType:a,coinBType:c,direction:n,amountIn:u,publishedAt:t.publishedAt,poolId:t.id,extendedDetails:r,priceInfoObjectIdA:h,priceInfoObjectIdB:v}}executeSwapContract(e,t,r){const n=t.extendedDetails,i=e.moveCall({target:`${this.oraclePackageId}::oracles::get_pyth_price`,typeArguments:[],arguments:[e.object(n.steammOracleRegistryId),e.object(t.priceInfoObjectIdA),e.pure.u64(n.steammOracleIndexA),e.object(fr.SUI_CLOCK_OBJECT_ID)]}),s=e.moveCall({target:`${this.oraclePackageId}::oracles::get_pyth_price`,typeArguments:[],arguments:[e.object(n.steammOracleRegistryId),e.object(t.priceInfoObjectIdB),e.pure.u64(n.steammOracleIndexB),e.object(fr.SUI_CLOCK_OBJECT_ID)]}),o=[r,e.object(t.poolId),e.object(n.steamm_bank_a),e.object(n.steamm_bank_b),e.object(n.steamm_lending_market),i,s,e.pure.u64(t.amountIn),e.object(fr.SUI_CLOCK_OBJECT_ID)];e.moveCall({target:`${t.publishedAt}::steamm_omm::${t.func}`,typeArguments:[n.steamm_lending_market_type,t.coinAType,t.coinBType,n.steamm_btoken_a_type,n.steamm_btoken_b_type,n.steamm_lp_token_type],arguments:o})}},aV=class{constructor(e,t){if(e!==0)throw new Error("Steamm OMM V2 only supported on mainnet");this.pythPriceIDs=t,this.oraclePackageId="0xe84b649199654d18c38e727212f5d8dacfc3cf78d60d0a7fc85fd589f280eb2b"}swap(e,t,r,n){const i=t.path;if(!i.extendedDetails)throw new Error("Extended details not found for Steamm OMM V2");this.validateExtendedDetails(i.extendedDetails);const s=this.prepareSwapData(t);this.executeSwapContract(e,s,r)}validateExtendedDetails(e){const t=["steamm_bank_a","steamm_bank_b","steamm_lending_market","steamm_lending_market_type","steamm_btoken_a_type","steamm_btoken_b_type","steamm_lp_token_type","steamm_oracle_registry_id","steamm_oracle_index_a","steamm_oracle_index_b","steamm_oracle_pyth_price_seed_a","steamm_oracle_pyth_price_seed_b"];for(const r of t)if(e[r]==null)throw new Error(`Steamm OMM V2 ${r} not supported`)}prepareSwapData(e){const t=e.path;if(e.path.publishedAt==null)throw new Error("Steamm OMM V2 not set publishedAt");const r=t.extendedDetails,{direction:n,from:i,target:s}=t,[o,a]=n?[i,s]:[s,i],c=e.isLastUseOfIntermediateToken?Kt.MAX_AMOUNT_IN:t.amountIn,u=r.steamm_oracle_pyth_price_seed_a,l=r.steamm_oracle_pyth_price_seed_b;if(!u||!l)throw new Error("Steamm OMM V2 oracle price seeds not found");const f=this.pythPriceIDs.get(u),h=this.pythPriceIDs.get(l);if(!f||!h)throw new Error("Base price info object id or quote price info object id not found");return{coinAType:o,coinBType:a,direction:n,amountIn:c,publishedAt:t.publishedAt,poolId:t.id,extendedDetails:r,priceInfoObjectIdA:f,priceInfoObjectIdB:h}}executeSwapContract(e,t,r){const n=t.extendedDetails,i=e.moveCall({target:`${this.oraclePackageId}::oracles::get_pyth_price`,typeArguments:[],arguments:[e.object(n.steamm_oracle_registry_id),e.object(t.priceInfoObjectIdA),e.pure.u64(n.steamm_oracle_index_a),e.object(fr.SUI_CLOCK_OBJECT_ID)]}),s=e.moveCall({target:`${this.oraclePackageId}::oracles::get_pyth_price`,typeArguments:[],arguments:[e.object(n.steamm_oracle_registry_id),e.object(t.priceInfoObjectIdB),e.pure.u64(n.steamm_oracle_index_b),e.object(fr.SUI_CLOCK_OBJECT_ID)]}),o=[r,e.object(t.poolId),e.object(n.steamm_bank_a),e.object(n.steamm_bank_b),e.object(n.steamm_lending_market),i,s,e.pure.bool(t.direction),e.pure.u64(t.amountIn),e.object(fr.SUI_CLOCK_OBJECT_ID)];e.moveCall({target:`${t.publishedAt}::steamm_omm_v2::swap`,typeArguments:[n.steamm_lending_market_type,t.coinAType,t.coinBType,n.steamm_btoken_a_type,n.steamm_btoken_b_type,n.steamm_lp_token_type],arguments:o})}},cV="0x790f258062909e3a0ffc78b3c53ac2f62d7084c3bab95644bdeb05add7250001::super_sui::SUPER_SUI",uV="0xe44df51c0b21a27ab915fa1fe2ca610cd3eaa6d9666fe5e62b988bf7f0bd8722::musd::MUSD",lV="0xccd628c2334c5ed33e6c47d6c21bb664f8b6307b2ac32c2462a61f69a31ebcee::meth::METH",fV=class{constructor(e,t){if(e!==0)throw new Error("Metastable only supported on mainnet");this.versionID="0x4696559327b35ff2ab26904e7426a1646312e9c836d5c6cff6709a5ccc30915c",this.pythPriceIDs=t}swap(e,t,r,n){const i=this.prepareSwapData(t),s=this.createDepositCap(e,i);this.executeSwapContract(e,i,r,s)}prepareSwapData(e){const t=e.path;if(e.path.publishedAt==null)throw new Error("Metastable not set publishedAt");if(!t.extendedDetails)throw new Error("Extended details not found for Metastable");const{direction:r,from:n,target:i}=t,[s,o]=r?[n,i]:[i,n],[a,c]=r?["swap_a2b","create_deposit_cap"]:["swap_b2a","create_withdraw_cap"];if(!t.extendedDetails.metastable_create_cap_pkg_id||!t.extendedDetails.metastable_create_cap_module||!t.extendedDetails.metastable_whitelisted_app_id)throw new Error("CreateCapPkgId or CreateCapModule or WhitelistedAppId not found in extended details");const u=e.isLastUseOfIntermediateToken?Kt.MAX_AMOUNT_IN:t.amountIn;return{coinType:s,metaCoinType:o,func:a,createCapFunc:c,direction:r,amountIn:u,publishedAt:t.publishedAt,poolId:t.id,extendedDetails:t.extendedDetails}}createDepositCap(e,t){const r=[t.metaCoinType];t.extendedDetails.metastable_create_cap_all_type_params&&r.push(t.coinType);const n=[e.object(t.extendedDetails.metastable_whitelisted_app_id),e.object(t.poolId)];switch(t.metaCoinType){case cV:{if(!t.extendedDetails.metastable_registry_id)throw new Error("Not found registry id for super sui");n.push(e.object(t.extendedDetails.metastable_registry_id));break}case uV:case lV:{if(t.extendedDetails.metastable_price_seed!=null){const i=this.pythPriceIDs.get(t.extendedDetails.metastable_price_seed);if(i==null)throw new Error("Invalid Pyth price feed: "+t.extendedDetails.metastable_price_seed);n.push(e.object(i))}if(t.extendedDetails.metastable_eth_price_seed!=null){const i=this.pythPriceIDs.get(t.extendedDetails.metastable_eth_price_seed);if(i==null)throw new Error("Invalid Pyth price feed: "+t.extendedDetails.metastable_eth_price_seed);n.push(e.object(i))}n.push(e.object(fr.SUI_CLOCK_OBJECT_ID));break}default:throw new Error("Invalid Metacoin: "+t.metaCoinType)}return e.moveCall({target:`${t.extendedDetails.metastable_create_cap_pkg_id}::${t.extendedDetails.metastable_create_cap_module}::${t.createCapFunc}`,typeArguments:r,arguments:n})}executeSwapContract(e,t,r,n){const i=[r,e.object(t.poolId),e.object(this.versionID),n,e.pure.u64(t.amountIn)];e.moveCall({target:`${t.publishedAt}::metastable::${t.func}`,typeArguments:[t.coinType,t.metaCoinType],arguments:i})}},dV=class{constructor(e){if(e!==0)throw new Error("Alphafi only supported on mainnet");this.suiSystemState="0x0000000000000000000000000000000000000000000000000000000000000005"}swap(e,t,r,n){const i=this.prepareSwapData(t);this.executeSwapContract(e,i,r)}prepareSwapData(e){if(e.path.publishedAt==null)throw new Error("Alphafi not set publishedAt");const t=e.path,[r,n]=t.direction?[t.from,t.target]:[t.target,t.from],i=e.isLastUseOfIntermediateToken?Kt.MAX_AMOUNT_IN:t.amountIn;return{coinAType:r,coinBType:n,direction:t.direction,amountIn:i,publishedAt:t.publishedAt,poolId:t.id}}executeSwapContract(e,t,r){const n=[r,e.object(t.poolId),e.object(this.suiSystemState),e.pure.bool(t.direction),e.pure.u64(t.amountIn)];e.moveCall({target:`${t.publishedAt}::alphafi::swap`,typeArguments:[t.coinBType],arguments:n})}},hV=class{constructor(e){if(e!==0)throw new Error("Volo only supported on mainnet");this.stakePool="0x2d914e23d82fedef1b5f56a32d5c64bdcc3087ccfea2b4d6ea51a71f587840e5",this.metadata="0x680cd26af32b2bde8d3361e804c53ec1d1cfe24c7f039eb7f549e8dfde389a60"}swap(e,t,r,n){const i=this.prepareSwapData(t);this.executeSwapContract(e,i,r)}prepareSwapData(e){const t=e.path;if(e.path.publishedAt==null)throw new Error("Volo not set publishedAt");const[r,n]=t.direction?[t.from,t.target]:[t.target,t.from],i=e.isLastUseOfIntermediateToken?Kt.MAX_AMOUNT_IN:t.amountIn;return{coinAType:r,coinBType:n,direction:t.direction,amountIn:i,publishedAt:t.publishedAt,poolId:t.id}}executeSwapContract(e,t,r){const n=[r,e.object(this.stakePool),e.object(this.metadata),e.object("0x5"),e.pure.bool(t.direction),e.pure.u64(t.amountIn)];e.moveCall({target:`${t.publishedAt}::volo::swap`,typeArguments:[],arguments:n})}},pV=class{constructor(e){if(e!==0)throw new Error("afSUI only supported on mainnet");this.stakedSuiVault="0x2f8f6d5da7f13ea37daa397724280483ed062769813b6f31e9788e59cc88994d",this.safe="0xeb685899830dd5837b47007809c76d91a098d52aabbf61e8ac467c59e5cc4610",this.referVault="0x4ce9a19b594599536c53edb25d22532f82f18038dc8ef618afd00fbbfb9845ef",this.validator="0xd30018ec3f5ff1a3c75656abf927a87d7f0529e6dc89c7ddd1bd27ecb05e3db2"}swap(e,t,r,n){const i=this.prepareSwapData(t);this.executeSwapContract(e,i,r)}prepareSwapData(e){if(e.path.publishedAt==null)throw new Error("AFSUI not set publishedAt");const t=e.path,[r,n]=t.direction?[t.from,t.target]:[t.target,t.from],i=e.isLastUseOfIntermediateToken?Kt.MAX_AMOUNT_IN:t.amountIn;return{coinAType:r,coinBType:n,direction:t.direction,amountIn:i,publishedAt:t.publishedAt,poolId:t.id}}executeSwapContract(e,t,r){if(!t.direction)throw new Error("AFSUI not support b2a swap");const n=[r,e.object(this.stakedSuiVault),e.object(this.safe),e.object("0x5"),e.object(this.referVault),e.object(this.validator),e.pure.bool(t.direction),e.pure.u64(t.amountIn)];e.moveCall({target:`${t.publishedAt}::afsui::swap`,typeArguments:[],arguments:n})}},mV=class{constructor(e){if(e!==0)throw new Error("Haedal only supported on mainnet")}swap(e,t,r,n){const i=this.prepareSwapData(t);this.executeSwapContract(e,i,r)}prepareSwapData(e){const t=e.path;if(e.path.publishedAt==null)throw new Error("Haedal not set publishedAt");const[r,n]=t.direction?[t.from,t.target]:[t.target,t.from],i=e.isLastUseOfIntermediateToken?Kt.MAX_AMOUNT_IN:t.amountIn;return{coinAType:r,coinBType:n,direction:t.direction,amountIn:i,publishedAt:t.publishedAt,poolId:t.id}}executeSwapContract(e,t,r){const n=[r,e.object(t.poolId),e.object("0x5"),e.pure.bool(t.direction),e.pure.u64(t.amountIn)];e.moveCall({target:`${t.publishedAt}::hasui::swap`,typeArguments:[],arguments:n})}},gV=class{constructor(e){if(e!==0)throw new Error("Hawal only supported on mainnet");this.staking="0x10b9d30c28448939ce6c4d6c6e0ffce4a7f8a4ada8248bdad09ef8b70e4a3904",this.validator="0x7b3ba6de2ae58283f60d5b8dc04bb9e90e4796b3b2e0dea75569f491275242e7"}swap(e,t,r,n){const i=this.prepareSwapData(t);this.executeSwapContract(e,i,r)}prepareSwapData(e){const t=e.path;if(e.path.publishedAt==null)throw new Error("Hawal not set publishedAt");const[r,n]=t.direction?[t.from,t.target]:[t.target,t.from],i=e.isLastUseOfIntermediateToken?Kt.MAX_AMOUNT_IN:t.amountIn;return{coinAType:r,coinBType:n,direction:t.direction,amountIn:i,publishedAt:t.publishedAt,poolId:t.id}}executeSwapContract(e,t,r){const n=[r,e.object(this.staking),e.object(t.poolId),e.object(this.validator),e.pure.bool(t.direction),e.pure.u64(t.amountIn)];e.moveCall({target:`${t.publishedAt}::hawal::swap`,typeArguments:[],arguments:n})}},yV=Kt.DEFAULT_PUBLISHED_AT.Mainnet;function ul(e,t){return e&&e.has(Xf.AGGREGATOR_V3)?e.get(Xf.AGGREGATOR_V3):t||yV}function Xv(e,t){const{quoteID:r,fromCoinType:n,targetCoinType:i,expectAmountOut:s,amountOutLimit:o,inputCoin:a,feeRate:c,feeRecipient:u,aggregatorPublishedAt:l,packages:f}=e,h=ul(f,l),v=[t.pure.string(r),t.pure.u64(s.toString()),t.pure.u64(o.toString()),a,t.pure.u32(Number(c.toString())),t.pure.address(u)];return t.moveCall({target:`${h}::router::new_swap_context`,typeArguments:[n,i],arguments:v})}function Jv(e,t){const{swapContext:r,targetCoinType:n,aggregatorPublishedAt:i,packages:s}=e,o=ul(s,i);return t.moveCall({target:`${o}::router::confirm_swap`,typeArguments:[n],arguments:[r]})}function vV(e,t){const{coinType:r,amount:n,swapCtx:i,aggregatorPublishedAt:s,packages:o}=e,a=ul(o,s),c=[i,t.pure.u64(n.toString())];return t.moveCall({target:`${a}::router::take_balance`,typeArguments:[r],arguments:c})}function bV(e,t){const{balance:r,coinType:n,recipient:i,aggregatorPublishedAt:s,packages:o}=e,a=ul(o,s),c=[r,t.pure.address(i)];t.moveCall({target:`${a}::router::transfer_balance`,typeArguments:[n],arguments:c})}function wV(e,t){const{coin:r,coinType:n,aggregatorPublishedAt:i,packages:s}=e,o=ul(s,i);t.moveCall({target:`${o}::router::transfer_or_destroy_coin`,typeArguments:[n],arguments:[r]})}function _V(e){return e.endsWith("/find_routes")?e.replace("/find_routes",""):e}Ac(Mc());Ac(Mc());var xV=class{constructor(e,t){if(e!==0)throw new Error("Haedal HMM V2 only supported on mainnet");this.pythPriceIDs=t}swap(e,t,r,n){const i=t.path;if(!i.extendedDetails)throw new Error("Extended details not found for Haedal HMM V2");this.validateExtendedDetails(i.extendedDetails);const s=this.prepareSwapData(t);this.executeSwapContract(e,s,r)}validateExtendedDetails(e){if(!e.haedalhmmv2_base_price_seed)throw new Error("Haedal HMM V2 base price seed not supported")}prepareSwapData(e){const t=e.path;if(e.path.publishedAt==null)throw new Error("Haedal HMM V2 not set publishedAt");const r=t.extendedDetails,[n,i]=t.direction?[t.from,t.target]:[t.target,t.from],s=e.isLastUseOfIntermediateToken?Kt.MAX_AMOUNT_IN:t.amountIn,o=r.haedalhmmv2_base_price_seed,a=this.pythPriceIDs.get(o);if(!a)throw new Error("Haedal HMM V2 requires oracle price IDs for base coin");return{coinAType:n,coinBType:i,basePriceId:a,a2b:t.direction,amountIn:s,publishedAt:t.publishedAt,poolId:t.id}}executeSwapContract(e,t,r){const n=[r,e.object(t.poolId),e.object(t.basePriceId),e.pure.u64(t.amountIn),e.pure.bool(t.a2b),e.object(fr.SUI_CLOCK_OBJECT_ID)];e.moveCall({target:`${t.publishedAt}::haedal_hmm_v2::swap`,typeArguments:[t.coinAType,t.coinBType],arguments:n})}},SV=class{constructor(e){if(e!==0)throw new Error("Fullsail only supported on mainnet");this.globalConfig="0xe93baa80cb570b3a494cbf0621b2ba96bc993926d34dc92508c9446f9a05d615",this.vault="0xfb971d3a2fb98bde74e1c30ba15a3d8bef60a02789e59ae0b91660aeed3e64e1",this.stats="0x6822a33d1d971e040c32f7cc74507010d1fe786f7d06ab89135083ddb07d2dc2",this.price_provider="0x854b2d2c0381bb656ec962f8b443eb082654384cf97885359d1956c7d76e33c9"}swap(e,t,r,n){const i=this.prepareSwapData(t);this.executeSwapContract(e,i,r)}prepareSwapData(e){const t=e.path;if(e.path.publishedAt==null)throw new Error("Fullsail not set publishedAt");const[r,n]=t.direction?[t.from,t.target]:[t.target,t.from],i=e.isLastUseOfIntermediateToken?Kt.MAX_AMOUNT_IN:t.amountIn;return{coinAType:r,coinBType:n,direction:t.direction,amountIn:i,publishedAt:t.publishedAt,poolId:t.id}}executeSwapContract(e,t,r){const n=[r,e.object(this.globalConfig),e.object(this.vault),e.object(this.stats),e.object(this.price_provider),e.object(t.poolId),e.pure.bool(t.direction),e.pure.u64(t.amountIn),e.object(fr.SUI_CLOCK_OBJECT_ID)];e.moveCall({target:`${t.publishedAt}::fullsail::swap`,typeArguments:[t.coinAType,t.coinBType],arguments:n})}},Zv="CETUS",EV="KRIYA",TV="FLOWX",CV="FLOWXV3",AV="KRIYAV3",MV="TURBOS",OV="AFTERMATH",IV="HAEDAL",kV="VOLO",jV="AFSUI",RV="BLUEMOVE",PV="DEEPBOOKV3",NV="SCALLOP",$V="SUILEND",DV="BLUEFIN",l5="HAEDALPMM",LV="ALPHAFI",BV="SPRINGSUI",UV="STEAMM",f5="METASTABLE",d5="OBRIC",FV="HAWAL",h5="STEAMM_OMM",VV="MOMENTUM",p5="STEAMM_OMM_V2",zV="MAGMA",m5="SEVENK",g5="HAEDALHMMV2",WV="FULLSAIL",qV="https://api-sui.cetus.zone/router_v3";function Qv(e){const t=new Set;for(const r of e){if(r.provider===l5&&r.extendedDetails&&r.extendedDetails.haedal_pmm_base_price_seed&&r.extendedDetails.haedal_pmm_quote_price_seed&&(t.add(r.extendedDetails.haedal_pmm_base_price_seed),t.add(r.extendedDetails.haedal_pmm_quote_price_seed)),r.provider===f5&&(r.extendedDetails&&r.extendedDetails.metastable_price_seed&&t.add(r.extendedDetails.metastable_price_seed),r.extendedDetails&&r.extendedDetails.metastable_eth_price_seed&&t.add(r.extendedDetails.metastable_eth_price_seed)),r.provider===d5&&(r.extendedDetails&&r.extendedDetails.obric_coin_a_price_seed&&t.add(r.extendedDetails.obric_coin_a_price_seed),r.extendedDetails&&r.extendedDetails.obric_coin_b_price_seed&&t.add(r.extendedDetails.obric_coin_b_price_seed)),(r.provider===h5||r.provider===p5)&&(r.extendedDetails&&r.extendedDetails.steamm_oracle_pyth_price_seed_a&&t.add(r.extendedDetails.steamm_oracle_pyth_price_seed_a),r.extendedDetails&&r.extendedDetails.steamm_oracle_pyth_price_seed_b&&t.add(r.extendedDetails.steamm_oracle_pyth_price_seed_b)),r.provider===m5&&r.extendedDetails){const n=r.extendedDetails;n.sevenk_coin_a_price_seed&&t.add(n.sevenk_coin_a_price_seed),n.sevenk_coin_b_price_seed&&t.add(n.sevenk_coin_b_price_seed)}r.provider===g5&&r.extendedDetails&&r.extendedDetails.haedalhmmv2_base_price_seed&&t.add(r.extendedDetails.haedalhmmv2_base_price_seed)}return Array.from(t)}var y5=class v5{constructor(t){var r,n;this.endpoint=t.endpoint?_V(t.endpoint):qV,this.client=t.client||new Dv.SuiClient({url:Dv.getFullnodeUrl("mainnet")}),this.signer=t.signer||"",this.env=t.env||0;const i=v5.CONFIG[this.env];if(this.pythConnections=this.newPythClients((r=t.pythUrls)!=null?r:[]),this.pythClient=new Lv.SuiPythClient(this.client,i.pythStateId,i.wormholeStateId),this.apiKey=t.apiKey||"",this.partner=t.partner,t.overlayFeeRate)if(t.overlayFeeRate>0&&t.overlayFeeRate<=pi.MAX_OVERLAY_FEE_RATE){if(this.overlayFeeRate=t.overlayFeeRate*Kt.FEE_DENOMINATOR,this.overlayFeeRate>Kt.MAX_FEE_RATE)throw new Error(pi.ERRORS.INVALID_OVERLAY_FEE_RATE)}else throw new Error(pi.ERRORS.INVALID_OVERLAY_FEE_RATE);else this.overlayFeeRate=0;this.overlayFeeReceiver=(n=t.overlayFeeReceiver)!=null?n:pi.DEFAULT_OVERLAY_FEE_RECEIVER}newPythClients(t){return t.includes("https://hermes.pyth.network")||t.push("https://hermes.pyth.network"),t.map(n=>new Lv.SuiPriceServiceConnection(n,{timeout:3e3}))}deepbookv3DeepFeeType(){return this.env===0?Jf.Mainnet:Jf.Testnet}getDeepbookV3Config(){return mn(this,null,function*(){return yield KU(this.endpoint)})}getOneCoinUsedToMerge(t){return mn(this,null,function*(){try{const r=yield this.client.getCoins({owner:this.signer,coinType:t,limit:1});return r.data.length===1?r.data[0].coinObjectId:null}catch{return null}})}findRouters(t){return mn(this,null,function*(){return qU(this.endpoint,this.apiKey,t,this.overlayFeeRate,this.overlayFeeReceiver)})}executeFlexibleInputSwap(t,r,n,i,s,o,a,c,u){return mn(this,null,function*(){})}newDexRouterV3(t,r,n){switch(t){case Zv:return new Kv(this.env,n);case AV:return new WF(this.env);case CV:return new qF(this.env);case MV:return new HF(this.env);case DV:return new GF(this.env);case VV:return new KF(this.env);case zV:return new YF(this.env);case EV:return new XF(this.env);case TV:return new JF(this.env);case RV:return new ZF(this.env);case PV:return new QF(this.env);case OV:return new eV(this.env);case UV:return new tV(this.env);case NV:return new rV(this.env);case $V:return new Yv(this.env);case BV:return new Yv(this.env);case l5:return new nV(this.env,r);case d5:return new iV(this.env,r);case m5:return new sV(this.env,r);case h5:return new oV(this.env,r);case p5:return new aV(this.env,r);case f5:return new fV(this.env,r);case LV:return new dV(this.env);case kV:return new hV(this.env);case jV:return new pV(this.env);case IV:return new mV(this.env);case FV:return new gV(this.env);case g5:return new xV(this.env,r);case WV:return new SV(this.env);default:throw new Error(`${pi.ERRORS.UNSUPPORTED_DEX} ${t}`)}}expectInputSwapV3(t,r,n,i,s,o,a){if(n.quoteID==null)throw new Error(pi.ERRORS.QUOTE_ID_REQUIRED);const c=zv(n),u=Xv({quoteID:c.quoteID,fromCoinType:c.fromCoinType,targetCoinType:c.targetCoinType,expectAmountOut:i,amountOutLimit:s,inputCoin:r,feeRate:this.overlayFeeRate,feeRecipient:this.overlayFeeReceiver,packages:c.packages},t);let l=new Map;for(const h of c.flattenedPaths){const v=h.path;l.has(v.provider)||l.set(v.provider,this.newDexRouterV3(v.provider,o,a)),l.get(v.provider).swap(t,h,u,{pythPriceIDs:o})}return Jv({swapContext:u,targetCoinType:c.targetCoinType,packages:c.packages},t)}expectOutputSwapV3(t,r,n,i,s,o){const a=[],c=new Kv(this.env,o),u=zv(n),l=Xv({quoteID:u.quoteID,fromCoinType:u.fromCoinType,targetCoinType:u.targetCoinType,expectAmountOut:i,amountOutLimit:i,inputCoin:r,feeRate:this.overlayFeeRate,feeRecipient:this.overlayFeeReceiver,packages:u.packages},t),f=KV(n.paths);let h=new Map,v=new Map;for(let S=n.paths.length-1;S>=0;S--){const C=n.paths[S],O=f.get(C.from);let I;if(S!==O||C.target===u.targetCoinType){if(C.target!==u.targetCoinType){let D=BigInt(C.amountOut);v.has(C.target)&&(D=v.get(C.target)+D),v.set(C.target,D)}I=t.pure.u64(C.amountOut.toString())}else{if(!h.has(C.target))throw Error("no need repay record");if(v.has(C.target)){const D=v.get(C.target),H=h.get(C.target);I=c.sub(t,H,t.pure.u64(D),C.publishedAt)}else I=h.get(C.target)}const U=c.flashSwapFixedOutput(t,C,I,l);if(a.unshift(U.flashReceipt),h.has(C.from)){const D=h.get(C.from);h.set(C.from,c.add(t,D,U.repayAmount,C.publishedAt))}else h.set(C.from,U.repayAmount)}for(let S=0;S<n.paths.length;S++){const C=n.paths[S];c.repayFlashSwapFixedOutput(t,C,l,a[S])}const b=vV({coinType:u.fromCoinType,amount:z0,swapCtx:l,packages:u.packages},t);return bV({balance:b,coinType:u.fromCoinType,recipient:this.signer,packages:u.packages},t),Jv({swapContext:l,targetCoinType:u.targetCoinType,packages:u.packages},t)}routerSwap(t){return mn(this,null,function*(){const{router:r,inputCoin:n,slippage:i,txb:s,partner:o}=t;if(i>1||i<0)throw new Error(pi.ERRORS.INVALID_SLIPPAGE);if(!t.router.packages||!t.router.packages.get(Xf.AGGREGATOR_V3))throw new Error(pi.ERRORS.PACKAGES_REQUIRED);const a=t.router.byAmountIn,c=r.amountIn,u=r.amountOut;Ap(this.overlayFeeRate,this.overlayFeeReceiver);let l=new dr.default(0);a?l=u.mul(new dr.default(this.overlayFeeRate)).div(new dr.default(1e6)):l=c.mul(new dr.default(this.overlayFeeRate)).div(new dr.default(1e6));const f=a?u.sub(l):u,h=a?c:c.add(l),v=Gv(a?f:h,a,i),b=Qv(r.paths),y=b.length>0?yield this.updatePythPriceIDs(b,s):new Map;return a?this.expectInputSwapV3(s,n,r,u.toString(),v.toString(),y,o??this.partner):this.expectOutputSwapV3(s,n,r,u.toString(),v.toString(),o??this.partner)})}fastRouterSwap(t){return mn(this,null,function*(){const{router:r,slippage:n,txb:i,partner:s,payDeepFeeAmount:o}=t,a=r.paths[0].from,c=r.paths[r.paths.length-1].target,u=r.byAmountIn;Ap(this.overlayFeeRate,this.overlayFeeReceiver);let l=0;u?l=Number(r.amountOut.mul(new dr.default(this.overlayFeeRate)).div(new dr.default(1e6)).toString()):l=Number(r.amountIn.mul(new dr.default(this.overlayFeeRate)).div(new dr.default(1e6)).toString());const f=u?r.amountOut.sub(new dr.default(l)):r.amountOut,h=u?r.amountIn:r.amountIn.add(new dr.default(l)),v=zF(u?f:h,u,n),b=u?h:v;let y=Tp.coinWithBalance({balance:BigInt(b.toString()),useGasCoin:!0,type:a}),S;o&&o>0&&(S=Tp.coinWithBalance({balance:BigInt(o),type:this.deepbookv3DeepFeeType()}));const C={router:r,inputCoin:y,slippage:n,txb:i,partner:s??this.partner,deepbookv3DeepFee:S},O=yield this.routerSwap(C);if(KS.isSuiCoin(c))i.mergeCoins(i.gas,[O]);else{const I=yield this.getOneCoinUsedToMerge(c);I!=null?i.mergeCoins(i.object(I),[O]):wV({coin:O,coinType:c,packages:r.packages},i)}})}fixableRouterSwapV3(t){return mn(this,null,function*(){const{router:r,inputCoin:n,slippage:i,txb:s,partner:o}=t;Ap(this.overlayFeeRate,this.overlayFeeReceiver);let a=0;r.byAmountIn?a=Number(r.amountOut.mul(new dr.default(this.overlayFeeRate)).div(new dr.default(1e6)).toString()):a=Number(r.amountIn.mul(new dr.default(this.overlayFeeRate)).div(new dr.default(1e6)).toString());const c=r.byAmountIn?r.amountOut.sub(new dr.default(a)):r.amountOut,u=r.byAmountIn?r.amountIn:r.amountIn.add(new dr.default(a)),l=Gv(r.byAmountIn?c:u,r.byAmountIn,i),f=Qv(r.paths),h=f.length>0?yield this.updatePythPriceIDs(f,s):new Map;return r.byAmountIn?this.expectInputSwapV3(s,n,r,c.toString(),l.toString(),h,o??this.partner):this.expectOutputSwapV3(s,n,r,c.toString(),l.toString(),o??this.partner)})}swapInPools(t){return mn(this,null,function*(){var r,n,i,s;const{from:o,target:a,amount:c,byAmountIn:u,pools:l}=t,f=Mo(o),h=Mo(a),v=new Tp.Transaction,b=FU(f,h),y=b?f:h,S=b?h:f,C=[y,S],O=this.env===0?"0x5bcd02f33d65c7ce98cd1ffb88174629210e59230b41c4b4572de1541f94946e":"0x4f920e1ef6318cfba77e20a0538a419a5a504c14230169438b99aba485db40a6";for(let m=0;m<l.length;m++){const x=[v.object(l[m]),v.pure.bool(b),v.pure.bool(u),v.pure.u64(c.toString())];v.moveCall({target:`${O}::fetcher_script::calculate_swap_result`,arguments:x,typeArguments:C})}this.signer||(this.signer="0x0");const I=yield this.client.devInspectTransactionBlock({transactionBlock:v,sender:this.signer});if(I.error!=null)throw new Error("Simulation error: "+I.error);const U=(r=I.events)==null?void 0:r.filter(m=>m.type.includes("CalculatedSwapResultEvent"));if(U.length===0||U.length!==l.length)throw new Error("Simulate event result error");let D=u?new dr.default(0):new dr.default(z0),H=0;for(let m=0;m<U.length;m+=1)if(!U[m].parsedJson.data.is_exceed)if(t.byAmountIn){const x=new dr.default(U[m].parsedJson.data.amount_out);x.gt(D)&&(H=m,D=x)}else{const x=new dr.default(U[m].parsedJson.data.amount_out);x.lt(D)&&(H=m,D=x)}const z=U[H].parsedJson.data,[ne,le]=yield Promise.all([this.client.getCoinMetadata({coinType:y}).then(m=>m==null?void 0:m.decimals),this.client.getCoinMetadata({coinType:S}).then(m=>m==null?void 0:m.decimals)]);if(ne==null||le==null)throw new Error("Cannot get coin decimals");const te=Number(z.fee_rate)/1e6,ce=new dr.default((n=z.amount_in)!=null?n:0),V=new dr.default((i=z.fee_amount)!=null?i:0),L=ce.add(V),p={amountIn:L,amountOut:new dr.default((s=z.amount_out)!=null?s:0),deviationRatio:0,paths:[{id:l[H],direction:b,provider:Zv,from:f,target:h,feeRate:te,amountIn:L.toString(),amountOut:z.amount_out,publishedAt:zU,extendedDetails:{afterSqrtPrice:z.after_sqrt_price}}],insufficientLiquidity:!1,byAmountIn:t.byAmountIn,quoteID:`degraded-${GV()}`,packages:new Map([[Xf.AGGREGATOR_V3,Kt.DEFAULT_PUBLISHED_AT.Mainnet]])};return{isExceed:z.is_exceed,routeData:p}})}updatePythPriceIDs(t,r){return mn(this,null,function*(){let n=null,i=null;for(const a of this.pythConnections)try{n=yield a.getPriceFeedsUpdateData(t);break}catch(c){i=c;continue}if(n==null)throw new Error(`All Pyth price nodes are unavailable. Cannot fetch price data. Please switch to or add new available Pyth nodes. Detailed error: ${i==null?void 0:i.message}`);let s=[];try{s=yield this.pythClient.updatePriceFeeds(r,n,t)}catch(a){throw new Error(`All Pyth price nodes are unavailable. Cannot fetch price data. Please switch to or add new available Pyth nodes in the pythUrls parameter when initializing AggregatorClient, for example: new AggregatorClient({ pythUrls: ["https://your-pyth-node-url"] }). Detailed error: ${a}`)}let o=new Map;for(let a=0;a<t.length;a++)o.set(t[a],s[a]);return o})}devInspectTransactionBlock(t){return mn(this,null,function*(){return yield this.client.devInspectTransactionBlock({transactionBlock:t,sender:this.signer})})}sendTransaction(t,r){return mn(this,null,function*(){return yield this.client.signAndExecuteTransaction({transaction:t,signer:r})})}};y5.CONFIG={1:{wormholeStateId:"0x31358d198147da50db32eda2562951d53973a0c0ad5ed738e9b17d88b213d790",pythStateId:"0x243759059f4c3111179da5878c12f68d612c21a8d54d85edc86164bb18be1c7c"},0:{wormholeStateId:"0xaeab97f96cf9877fee2883315d459552b2b921edc16d7ceac6eab944dd88919c",pythStateId:"0x1f9310238ee9298fb703c3419030b35b22bb1cc37113e3bb5007c99aec79e5b8"}};var HV=y5;function GV(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){const t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}function KV(e){let t=new Map;for(let r=0;r<e.length;r++)t.has(e[r].from)||t.set(e[r].from,r);return t}function Ap(e,t){if(e>pi.MAX_OVERLAY_FEE_RATE_NUMERATOR)throw new Error(pi.ERRORS.INVALID_OVERLAY_FEE_RATE);if(t==="0x0"&&e>0)throw new Error(pi.ERRORS.OVERLAY_FEE_RECEIVER_REQUIRED)}var b5=HV,w5=XS,eb=DU,da=sc;const _5="0x2::sui::SUI",YV="0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI";function K0(e){return Or(e).full_address===_5}function tb(e,...t){const r=Array.isArray(t[t.length-1])?t.pop():[];let i=[e,...t].filter(Boolean).join("::");return r&&r.length&&(i+=`<${r.join(", ")}>`),i}function Or(e){var t;try{let r=e.replace(/\s/g,"");const n=r.match(/(<.+>)$/),i=(t=n==null?void 0:n[0])==null?void 0:t.match(/(\w+::\w+::\w+)(?:<.*?>(?!>))?/g);if(i){r=r.slice(0,r.indexOf("<"));const u={...Or(r),type_arguments:i.map(l=>Or(l).source_address)};return u.type_arguments=u.type_arguments.map(l=>K0(l)?l:Or(l).source_address),u.source_address=tb(u.full_address,u.type_arguments),u}const s=r.split("::"),a={full_address:r,address:r===_5||r===YV?"0x2":ii(s[0]),module:s[1],name:s[2],type_arguments:[],source_address:""};return a.full_address=`${a.address}::${a.module}::${a.name}`,a.source_address=tb(a.full_address,a.type_arguments),a}catch{return{full_address:e,address:"",module:"",name:"",type_arguments:[],source_address:e}}}function XV(e){return e.startsWith("0x")?`${e.slice(2)}`:e}const Vs=(e,t=!0)=>{const r=e.split("::"),n=r.shift();let i=ii(n);return t&&(i=XV(i)),`${i}::${r.join("::")}`};/*!
|
|
48
48
|
* decimal.js v10.6.0
|
|
49
49
|
* An arbitrary-precision Decimal type for JavaScript.
|
|
50
50
|
* https://github.com/MikeMcl/decimal.js
|