@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.
@@ -44,7 +44,7 @@ ${String(n)}`);Vp(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[z3]=this[z3]={accessors:{}}).accessors,i=this.prototype;function s(o){const a=Du(o);n[a]||(rB(i,o),n[a]=!0)}return Ae.isArray(t)?t.forEach(s):s(t),this}}$f.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),Ae.reduceDescriptors($f.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(n){this[r]=n}}}),Ae.freezeMethods($f);var Si=$f;function Am(e,t){const r=this||Tm,n=t||r,i=Si.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 W3(e){return!!(e&&e.__CANCEL__)}function tc(e,t,r){jt.call(this,e??"canceled",jt.ERR_CANCELED,t,r),this.name="CanceledError"}Ae.inherits(tc,jt,{__CANCEL__:!0});function q3(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 nB(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function iB(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 sB(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 Df=(e,t,r=3)=>{let n=0;const i=iB(50,250);return sB(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)},H3=(e,t)=>{const r=e!=null;return[n=>t[0]({lengthComputable:r,total:e,loaded:n}),t[1]]},G3=e=>(...t)=>Ae.asap(()=>e(...t));var oB=un.hasStandardBrowserEnv?((e,t)=>r=>(r=new URL(r,un.origin),e.protocol===r.protocol&&e.host===r.host&&(t||e.port===r.port)))(new URL(un.origin),un.navigator&&/(msie|trident)/i.test(un.navigator.userAgent)):()=>!0,aB=un.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 cB(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function uB(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function K3(e,t,r){let n=!cB(t);return e&&(n||r==!1)?uB(e,t):t}const Y3=e=>e instanceof Si?{...e}:e;function ma(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(Y3(u),Y3(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 X3=e=>{const t=ma({},e);let{data:r,withXSRFToken:n,xsrfHeaderName:i,xsrfCookieName:s,headers:o,auth:a}=t;t.headers=o=Si.from(o),t.url=B3(K3(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(un.hasStandardBrowserEnv||un.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(un.hasStandardBrowserEnv&&(n&&Ae.isFunction(n)&&(n=n(t)),n||n!==!1&&oB(t.url))){const u=i&&s&&aB.read(s);u&&o.set(i,u)}return t},lB=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(r,n){const i=X3(e);let s=i.data;const o=Si.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=Si.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};q3(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||F3;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]=Df(u,!0),S.addEventListener("progress",h)),c&&S.upload&&([f,v]=Df(c),S.upload.addEventListener("progress",f),S.upload.addEventListener("loadend",v)),(i.cancelToken||i.signal)&&(l=I=>{S&&(n(!I||I.type?new tc(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=nB(i.url);if(O&&un.protocols.indexOf(O)===-1){n(new jt("Unsupported protocol "+O+":",jt.ERR_BAD_REQUEST,e));return}S.send(s||null)})},fB=(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 tc(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}};const dB=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},hB=async function*(e,t){for await(const r of pB(e))yield*dB(r,t)},pB=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()}},J3=(e,t,r,n)=>{const i=hB(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})},Lf=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",Z3=Lf&&typeof ReadableStream=="function",mB=Lf&&(typeof TextEncoder=="function"?(e=>t=>e.encode(t))(new TextEncoder):async e=>new Uint8Array(await new Response(e).arrayBuffer())),Q3=(e,...t)=>{try{return!!e(...t)}catch{return!1}},gB=Z3&&Q3(()=>{let e=!1;const t=new Request(un.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),e_=64*1024,Mm=Z3&&Q3(()=>Ae.isReadableStream(new Response("").body)),Bf={stream:Mm&&(e=>e.body)};Lf&&(e=>{["text","arrayBuffer","blob","formData","stream"].forEach(t=>{!Bf[t]&&(Bf[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 yB=async e=>{if(e==null)return 0;if(Ae.isBlob(e))return e.size;if(Ae.isSpecCompliantForm(e))return(await new Request(un.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 mB(e)).byteLength},vB=async(e,t)=>{const r=Ae.toFiniteNumber(e.getContentLength());return r??yB(t)};var bB=Lf&&(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}=X3(e);u=u?(u+"").toLowerCase():"text";let v=fB([i,s&&s.toAbortSignal()],o),b;const y=v&&v.unsubscribe&&(()=>{v.unsubscribe()});let S;try{if(c&&gB&&r!=="get"&&r!=="head"&&(S=await vB(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]=H3(S,Df(G3(c)));n=J3(D.body,e_,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=Mm&&(u==="stream"||u==="response");if(Mm&&(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&&H3(H,Df(G3(a),!0))||[];O=new Response(J3(O.body,e_,z,()=>{ne&&ne(),y&&y()}),D)}u=u||"text";let U=await Bf[Ae.findKey(Bf,u)||"text"](O,e);return!I&&y&&y(),await new Promise((D,H)=>{q3(D,H,{data:U,headers:Si.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 Om={http:RL,xhr:lB,fetch:bB};Ae.forEach(Om,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const t_=e=>`- ${e}`,wB=e=>Ae.isFunction(e)||e===null||e===!1;var r_={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,!wB(r)&&(n=Om[(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(t_).join(`
46
46
  `):" "+t_(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:Om};function Im(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new tc(null,e)}function n_(e){return Im(e),e.headers=Si.from(e.headers),e.data=Am.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),r_.getAdapter(e.adapter||Tm.adapter)(e).then(function(n){return Im(e),n.data=Am.call(e,e.transformResponse,n),n.headers=Si.from(n.headers),n},function(n){return W3(n)||(Im(e),n&&n.response&&(n.response.data=Am.call(e,e.transformResponse,n.response),n.response.headers=Si.from(n.response.headers))),Promise.reject(n)})}const i_="1.11.0",Uf={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Uf[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}});const s_={};Uf.transitional=function(t,r,n){function i(s,o){return"[Axios v"+i_+"] 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&&!s_[o]&&(s_[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}},Uf.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 Ff={assertOptions:_B,validators:Uf};const Zi=Ff.validators;class Vf{constructor(t){this.defaults=t||{},this.interceptors={request:new U3,response:new U3}}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=ma(this.defaults,r);const{transitional:n,paramsSerializer:i,headers:s}=r;n!==void 0&&Ff.assertOptions(n,{silentJSONParsing:Zi.transitional(Zi.boolean),forcedJSONParsing:Zi.transitional(Zi.boolean),clarifyTimeoutError:Zi.transitional(Zi.boolean)},!1),i!=null&&(Ae.isFunction(i)?r.paramsSerializer={serialize:i}:Ff.assertOptions(i,{encode:Zi.function,serialize:Zi.function},!0)),r.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?r.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:r.allowAbsoluteUrls=!0),Ff.assertOptions(r,{baseUrl:Zi.spelling("baseURL"),withXsrfToken:Zi.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=Si.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=[n_.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=n_.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=ma(this.defaults,t);const r=K3(t.baseURL,t.url,t.allowAbsoluteUrls);return B3(r,t.params,t.paramsSerializer)}}Ae.forEach(["delete","get","head","options"],function(t){Vf.prototype[t]=function(r,n){return this.request(ma(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(ma(a||{},{method:t,headers:n?{"Content-Type":"multipart/form-data"}:{},url:s,data:o}))}}Vf.prototype[t]=r(),Vf.prototype[t+"Form"]=r(!0)});var zf=Vf;class km{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 tc(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 km(function(i){t=i}),cancel:t}}}var xB=km;function SB(e){return function(r){return e.apply(null,r)}}function EB(e){return Ae.isObject(e)&&e.isAxiosError===!0}const jm={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(jm).forEach(([e,t])=>{jm[t]=e});var TB=jm;function o_(e){const t=new zf(e),r=E3(zf.prototype.request,t);return Ae.extend(r,zf.prototype,t,{allOwnKeys:!0}),Ae.extend(r,t,null,{allOwnKeys:!0}),r.create=function(i){return o_(ma(e,i))},r}const Mr=o_(Tm);Mr.Axios=zf,Mr.CanceledError=tc,Mr.CancelToken=xB,Mr.isCancel=W3,Mr.VERSION=i_,Mr.toFormData=Rf,Mr.AxiosError=jt,Mr.Cancel=Mr.CanceledError,Mr.all=function(t){return Promise.all(t)},Mr.spread=SB,Mr.isAxiosError=EB,Mr.mergeConfig=ma,Mr.AxiosHeaders=Si,Mr.formToJSON=e=>V3(Ae.isHTMLForm(e)?new FormData(e):e),Mr.getAdapter=r_.getAdapter,Mr.HttpStatusCode=TB,Mr.default=Mr;var a_=Mr,Pm={exports:{}},Fn={},c_={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})(c_);var CB=c_.exports,Rm={exports:{}},Nm={exports:{}},u_;function l_(){return u_||(u_=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}(Nm)),Nm.exports}var $m={exports:{}},Dm={exports:{}},f_;function d_(){return f_||(f_=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}(Dm)),Dm.exports}var h_;function p_(){return h_||(h_=1,function(e){var t=d_();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}($m)),$m.exports}var Lm={exports:{}},Bm={exports:{}},Um={exports:{}},m_;function g_(){return m_||(m_=1,function(e){var t=l_(),r=d_();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}(Um)),Um.exports}var y_;function v_(){return y_||(y_=1,function(e){var t=p_(),r=g_();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}(Bm)),Bm.exports}var b_;function AB(){return b_||(b_=1,function(e){var t=v_();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}(Lm)),Lm.exports}var Fm={exports:{}},w_;function MB(){return w_||(w_=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}(Fm)),Fm.exports}var Vm={exports:{}},zm={exports:{}},__;function Wf(){return __||(__=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}(zm)),zm.exports}var x_;function OB(){return x_||(x_=1,function(e){var t=Wf().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}(Vm)),Vm.exports}var S_;function IB(){return S_||(S_=1,function(e){var t=l_(),r=p_(),n=AB(),i=v_(),s=g_(),o=MB(),a=OB();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}(Rm)),Rm.exports}var Wm,E_;function kB(){if(E_)return Wm;E_=1;var e=IB()();Wm=e;try{regeneratorRuntime=e}catch{typeof globalThis=="object"?globalThis.regeneratorRuntime=e:Function("r","regeneratorRuntime = r")(e)}return Wm}var qm={exports:{}},T_;function jB(){return T_||(T_=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}(qm)),qm.exports}var Hm={exports:{}},Gm={exports:{}},Km={exports:{}},C_;function PB(){return C_||(C_=1,function(e){var t=Wf().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}(Km)),Km.exports}var A_;function RB(){return A_||(A_=1,function(e){var t=Wf().default,r=PB();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}(Gm)),Gm.exports}var M_;function NB(){return M_||(M_=1,function(e){var t=RB();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}(Hm)),Hm.exports}var Ym,O_;function $B(){if(O_)return Ym;O_=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 Ym=t=>!e.has(t&&t.code),Ym}var Lu=CB;Object.defineProperty(Fn,"__esModule",{value:!0}),Fn.isNetworkError=Zm,Fn.isRetryableError=Hf,Fn.isSafeRequestError=P_,Fn.isIdempotentRequestError=Qm,Fn.isNetworkOrIdempotentRequestError=eg,Fn.exponentialDelay=R_,Fn.default=ga,Fn.DEFAULT_OPTIONS=Fn.namespace=void 0;var qf=Lu(kB()),DB=Lu(Wf()),I_=Lu(jB()),LB=Lu(NB()),BB=Lu($B());function k_(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 Xm(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?k_(Object(r),!0).forEach(function(n){(0,LB.default)(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):k_(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}var Jm="axios-retry";Fn.namespace=Jm;function Zm(e){var t=["ERR_CANCELED","ECONNABORTED"];return!e.response&&!!e.code&&!t.includes(e.code)&&(0,BB.default)(e)}var j_=["get","head","options"],UB=j_.concat(["put","delete"]);function Hf(e){return e.code!=="ECONNABORTED"&&(!e.response||e.response.status>=500&&e.response.status<=599)}function P_(e){return e.config?Hf(e)&&j_.indexOf(e.config.method)!==-1:!1}function Qm(e){return e.config?Hf(e)&&UB.indexOf(e.config.method)!==-1:!1}function eg(e){return Zm(e)||Qm(e)}function FB(){return 0}function R_(){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 N_={retries:3,retryCondition:eg,retryDelay:FB,shouldResetTimeout:!1,onRetry:function(){}};Fn.DEFAULT_OPTIONS=N_;function VB(e,t){return Xm(Xm(Xm({},N_),t),e[Jm])}function $_(e,t){var r=VB(e,t);return r.retryCount=r.retryCount||0,e[Jm]=r,r}function zB(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 WB(e,t){return tg.apply(this,arguments)}function tg(){return tg=(0,I_.default)(qf.default.mark(function e(t,r){var n,i,s,o;return qf.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,DB.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]])})),tg.apply(this,arguments)}function ga(e,t){var r=e.interceptors.request.use(function(i){var s=$_(i,t);return s.lastRequestTime=Date.now(),i}),n=e.interceptors.response.use(null,function(){var i=(0,I_.default)(qf.default.mark(function s(o){var a,c,u,l,f,h,v,b;return qf.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=$_(a,t),S.next=6,WB(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),zB(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}}ga.isNetworkError=Zm,ga.isSafeRequestError=P_,ga.isIdempotentRequestError=Qm,ga.isNetworkOrIdempotentRequestError=eg,ga.exponentialDelay=R_,ga.isRetryableError=Hf;const D_=Fn.default;Pm.exports=D_,Pm.exports.default=D_;var qB=Pm.exports,Gf={},rc=null;typeof WebSocket<"u"?rc=WebSocket:typeof MozWebSocket<"u"?rc=MozWebSocket:typeof qr<"u"?rc=qr.WebSocket||qr.MozWebSocket:typeof window<"u"?rc=window.WebSocket||window.MozWebSocket:typeof self<"u"&&(rc=self.WebSocket||self.MozWebSocket);var HB=rc,GB=qr&&qr.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Gf,"__esModule",{value:!0}),Gf.ResilientWebSocket=void 0;const KB=GB(HB),YB=3e4+3e3;class XB{constructor(t,r){Nt(this,"endpoint");Nt(this,"wsClient");Nt(this,"wsUserClosed");Nt(this,"wsFailedAttempts");Nt(this,"pingTimeout");Nt(this,"logger");Nt(this,"onError");Nt(this,"onMessage");Nt(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 KB.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=JB(this.wsFailedAttempts);(r=this.logger)==null||r.error(`Connection closed unexpectedly or because of timeout. Reconnecting after ${i}ms.`),await L_(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()},YB)}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 L_(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}}Gf.ResilientWebSocket=XB;async function L_(e){return new Promise(t=>setTimeout(t,e))}function JB(e){return 2**e*100}var nc={};Object.defineProperty(nc,"__esModule",{value:!0}),nc.removeLeading0xIfExists=nc.makeWebsocketUrl=void 0;function ZB(e){const t=new URL("ws",e),r=t.protocol==="https:";return t.protocol=r?"wss:":"ws:",t.toString()}nc.makeWebsocketUrl=ZB;function QB(e){return e.startsWith("0x")?e.substring(2):e}nc.removeLeading0xIfExists=QB;var B_=qr&&qr.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Cf,"__esModule",{value:!0}),Cf.PriceServiceConnection=void 0;const rg=lm,eU=B_(a_),U_=B_(qB),tU=Gf,ng=nc;class rU{constructor(t,r){Nt(this,"httpClient");Nt(this,"priceFeedCallbacks");Nt(this,"wsClient");Nt(this,"wsEndpoint");Nt(this,"logger");Nt(this,"priceFeedRequestConfig");Nt(this,"onWsError");var n,i,s;this.httpClient=eU.default.create({baseURL:t,timeout:(r==null?void 0:r.timeout)||5e3}),(0,U_.default)(this.httpClient,{retries:(r==null?void 0:r.httpRetries)||3,retryDelay:U_.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 En<"u"&&typeof En.exit=="function"?(this.logger.error("Halting the process due to the websocket error"),En.exit(1)):this.logger.error("Cannot halt process. Please handle the websocket error.")},this.wsEndpoint=(0,ng.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=>rg.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 rg.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,ng.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,ng.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 tU.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=rg.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()}}Cf.PriceServiceConnection=rU,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.parseAccumulatorUpdateData=e.isAccumulatorUpdateData=e.Price=e.PriceFeed=e.PriceFeedMetadata=e.PriceServiceConnection=void 0;var t=Cf;Object.defineProperty(e,"PriceServiceConnection",{enumerable:!0,get:function(){return t.PriceServiceConnection}});var r=lm;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}})}(um),Object.defineProperty(Tf,"__esModule",{value:!0}),Tf.SuiPriceServiceConnection=void 0;const nU=um,iU=Mf();class sU extends nU.PriceServiceConnection{async getPriceFeedsUpdateData(t){return(await this.getLatestVaas(t)).map(n=>iU.Buffer.from(n,"base64"))}}Tf.SuiPriceServiceConnection=sU;var Kf={};Object.defineProperty(Kf,"__esModule",{value:!0}),Kf.SuiPythClient=void 0;const Yf=T8,ic=li,oU=Mf(),ig=16*1024;class aU{constructor(t,r,n){Nt(this,"provider");Nt(this,"pythStateId");Nt(this,"wormholeStateId");Nt(this,"pythPackageId");Nt(this,"wormholePackageId");Nt(this,"priceTableInfo");Nt(this,"priceFeedObjectIdCache",new Map);Nt(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(ic.bcs.vector(ic.bcs.U8).serialize(Array.from(s),{maxSize:ig}).toBytes()),r.object(Yf.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(ic.bcs.vector(ic.bcs.U8).serialize(Array.from(r[0]),{maxSize:ig}).toBytes()),s[0],t.object(Yf.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(Yf.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(ic.bcs.vector(ic.bcs.U8).serialize(Array.from(r[0]),{maxSize:ig}).toBytes()),s[0],t.object(Yf.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(oU.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)}}Kf.SuiPythClient=aU,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.PriceFeed=e.Price=e.SuiPythClient=e.SuiPriceServiceConnection=void 0;var t=Tf;Object.defineProperty(e,"SuiPriceServiceConnection",{enumerable:!0,get:function(){return t.SuiPriceServiceConnection}});var r=Kf;Object.defineProperty(e,"SuiPythClient",{enumerable:!0,get:function(){return r.SuiPythClient}});var n=um;Object.defineProperty(e,"Price",{enumerable:!0,get:function(){return n.Price}}),Object.defineProperty(e,"PriceFeed",{enumerable:!0,get:function(){return n.PriceFeed}})}(w3);var sg=Yn,cU=vN,ur=T8,F_=RD,V_=w3;function uU(e){return e&&e.__esModule?e:{default:e}}var lU=uU(cU),fU=Object.create,og=Object.defineProperty,dU=Object.defineProperties,hU=Object.getOwnPropertyDescriptor,pU=Object.getOwnPropertyDescriptors,z_=Object.getOwnPropertyNames,W_=Object.getOwnPropertySymbols,mU=Object.getPrototypeOf,q_=Object.prototype.hasOwnProperty,gU=Object.prototype.propertyIsEnumerable,H_=(e,t,r)=>t in e?og(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,yU=(e,t)=>{for(var r in t||(t={}))q_.call(t,r)&&H_(e,r,t[r]);if(W_)for(var r of W_(t))gU.call(t,r)&&H_(e,r,t[r]);return e},vU=(e,t)=>dU(e,pU(t)),bU=(e=>typeof $i<"u"?$i:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof $i<"u"?$i:t)[r]}):e)(function(e){if(typeof $i<"u")return $i.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')}),wU=(e,t)=>function(){return t||(0,e[z_(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 z_(t))!q_.call(e,i)&&i!==r&&og(e,i,{get:()=>t[i],enumerable:!(n=hU(t,i))||n.enumerable});return e},sc=(e,t,r)=>(r=e!=null?fU(mU(e)):{},_U(!e||!e.__esModule?og(r,"default",{value:e,enumerable:!0}):r,e)),yn=(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())}),oc=wU({"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=bU("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,R=x;R<g;R+=E)w=l(d,R,R+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,R,d.length,m),R=0;R<k;R++)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],R=y[d];x="";var ue=this.clone();for(ue.negative=0;!ue.isZero();){var ie=ue.modrn(R).toString(d);ue=ue.idivn(R),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 R=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,R+=j/67108864|0,ue=j&67108863}m.words[w]=ue|0,g=R|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,R,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,pe=Z>>>13,Y=E[4]|0,X=Y&8191,B=Y>>>13,se=E[5]|0,ge=se&8191,de=se>>>13,Se=E[6]|0,Ie=Se&8191,Fe=Se>>>13,Je=E[7]|0,$e=Je&8191,Ge=Je>>>13,nt=E[8]|0,et=nt&8191,Ot=nt>>>13,Dt=E[9]|0,Ke=Dt&8191,pt=Dt>>>13,lt=A[0]|0,tt=lt&8191,ot=lt>>>13,vt=A[1]|0,st=vt&8191,bt=vt>>>13,Lt=A[2]|0,yt=Lt&8191,It=Lt>>>13,Vt=A[3]|0,Xe=Vt&8191,Rt=Vt>>>13,zt=A[4]|0,$=zt&8191,T=zt>>>13,M=A[5]|0,K=M&8191,ae=M>>>13,be=A[6]|0,_e=be&8191,it=be>>>13,St=A[7]|0,rt=St&8191,Q=St>>>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,R=Math.imul(fe,ot);var Mt=(k+g|0)+((w&8191)<<13)|0;k=(R+(w>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,g=Math.imul(Ce,tt),w=Math.imul(Ce,ot),w=w+Math.imul(N,tt)|0,R=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,R=R+Math.imul(fe,bt)|0;var fr=(k+g|0)+((w&8191)<<13)|0;k=(R+(w>>>13)|0)+(fr>>>26)|0,fr&=67108863,g=Math.imul(G,tt),w=Math.imul(G,ot),w=w+Math.imul(ee,tt)|0,R=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,R=R+Math.imul(N,bt)|0,g=g+Math.imul(ie,yt)|0,w=w+Math.imul(ie,It)|0,w=w+Math.imul(fe,yt)|0,R=R+Math.imul(fe,It)|0;var Kt=(k+g|0)+((w&8191)<<13)|0;k=(R+(w>>>13)|0)+(Kt>>>26)|0,Kt&=67108863,g=Math.imul(q,tt),w=Math.imul(q,ot),w=w+Math.imul(pe,tt)|0,R=Math.imul(pe,ot),g=g+Math.imul(G,st)|0,w=w+Math.imul(G,bt)|0,w=w+Math.imul(ee,st)|0,R=R+Math.imul(ee,bt)|0,g=g+Math.imul(Ce,yt)|0,w=w+Math.imul(Ce,It)|0,w=w+Math.imul(N,yt)|0,R=R+Math.imul(N,It)|0,g=g+Math.imul(ie,Xe)|0,w=w+Math.imul(ie,Rt)|0,w=w+Math.imul(fe,Xe)|0,R=R+Math.imul(fe,Rt)|0;var Yt=(k+g|0)+((w&8191)<<13)|0;k=(R+(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,R=Math.imul(B,ot),g=g+Math.imul(q,st)|0,w=w+Math.imul(q,bt)|0,w=w+Math.imul(pe,st)|0,R=R+Math.imul(pe,bt)|0,g=g+Math.imul(G,yt)|0,w=w+Math.imul(G,It)|0,w=w+Math.imul(ee,yt)|0,R=R+Math.imul(ee,It)|0,g=g+Math.imul(Ce,Xe)|0,w=w+Math.imul(Ce,Rt)|0,w=w+Math.imul(N,Xe)|0,R=R+Math.imul(N,Rt)|0,g=g+Math.imul(ie,$)|0,w=w+Math.imul(ie,T)|0,w=w+Math.imul(fe,$)|0,R=R+Math.imul(fe,T)|0;var _r=(k+g|0)+((w&8191)<<13)|0;k=(R+(w>>>13)|0)+(_r>>>26)|0,_r&=67108863,g=Math.imul(ge,tt),w=Math.imul(ge,ot),w=w+Math.imul(de,tt)|0,R=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,R=R+Math.imul(B,bt)|0,g=g+Math.imul(q,yt)|0,w=w+Math.imul(q,It)|0,w=w+Math.imul(pe,yt)|0,R=R+Math.imul(pe,It)|0,g=g+Math.imul(G,Xe)|0,w=w+Math.imul(G,Rt)|0,w=w+Math.imul(ee,Xe)|0,R=R+Math.imul(ee,Rt)|0,g=g+Math.imul(Ce,$)|0,w=w+Math.imul(Ce,T)|0,w=w+Math.imul(N,$)|0,R=R+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,R=R+Math.imul(fe,ae)|0;var rn=(k+g|0)+((w&8191)<<13)|0;k=(R+(w>>>13)|0)+(rn>>>26)|0,rn&=67108863,g=Math.imul(Ie,tt),w=Math.imul(Ie,ot),w=w+Math.imul(Fe,tt)|0,R=Math.imul(Fe,ot),g=g+Math.imul(ge,st)|0,w=w+Math.imul(ge,bt)|0,w=w+Math.imul(de,st)|0,R=R+Math.imul(de,bt)|0,g=g+Math.imul(X,yt)|0,w=w+Math.imul(X,It)|0,w=w+Math.imul(B,yt)|0,R=R+Math.imul(B,It)|0,g=g+Math.imul(q,Xe)|0,w=w+Math.imul(q,Rt)|0,w=w+Math.imul(pe,Xe)|0,R=R+Math.imul(pe,Rt)|0,g=g+Math.imul(G,$)|0,w=w+Math.imul(G,T)|0,w=w+Math.imul(ee,$)|0,R=R+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,R=R+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,R=R+Math.imul(fe,it)|0;var Tr=(k+g|0)+((w&8191)<<13)|0;k=(R+(w>>>13)|0)+(Tr>>>26)|0,Tr&=67108863,g=Math.imul($e,tt),w=Math.imul($e,ot),w=w+Math.imul(Ge,tt)|0,R=Math.imul(Ge,ot),g=g+Math.imul(Ie,st)|0,w=w+Math.imul(Ie,bt)|0,w=w+Math.imul(Fe,st)|0,R=R+Math.imul(Fe,bt)|0,g=g+Math.imul(ge,yt)|0,w=w+Math.imul(ge,It)|0,w=w+Math.imul(de,yt)|0,R=R+Math.imul(de,It)|0,g=g+Math.imul(X,Xe)|0,w=w+Math.imul(X,Rt)|0,w=w+Math.imul(B,Xe)|0,R=R+Math.imul(B,Rt)|0,g=g+Math.imul(q,$)|0,w=w+Math.imul(q,T)|0,w=w+Math.imul(pe,$)|0,R=R+Math.imul(pe,T)|0,g=g+Math.imul(G,K)|0,w=w+Math.imul(G,ae)|0,w=w+Math.imul(ee,K)|0,R=R+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,R=R+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,R=R+Math.imul(fe,Q)|0;var dr=(k+g|0)+((w&8191)<<13)|0;k=(R+(w>>>13)|0)+(dr>>>26)|0,dr&=67108863,g=Math.imul(et,tt),w=Math.imul(et,ot),w=w+Math.imul(Ot,tt)|0,R=Math.imul(Ot,ot),g=g+Math.imul($e,st)|0,w=w+Math.imul($e,bt)|0,w=w+Math.imul(Ge,st)|0,R=R+Math.imul(Ge,bt)|0,g=g+Math.imul(Ie,yt)|0,w=w+Math.imul(Ie,It)|0,w=w+Math.imul(Fe,yt)|0,R=R+Math.imul(Fe,It)|0,g=g+Math.imul(ge,Xe)|0,w=w+Math.imul(ge,Rt)|0,w=w+Math.imul(de,Xe)|0,R=R+Math.imul(de,Rt)|0,g=g+Math.imul(X,$)|0,w=w+Math.imul(X,T)|0,w=w+Math.imul(B,$)|0,R=R+Math.imul(B,T)|0,g=g+Math.imul(q,K)|0,w=w+Math.imul(q,ae)|0,w=w+Math.imul(pe,K)|0,R=R+Math.imul(pe,ae)|0,g=g+Math.imul(G,_e)|0,w=w+Math.imul(G,it)|0,w=w+Math.imul(ee,_e)|0,R=R+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,R=R+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,R=R+Math.imul(fe,Ze)|0;var Gr=(k+g|0)+((w&8191)<<13)|0;k=(R+(w>>>13)|0)+(Gr>>>26)|0,Gr&=67108863,g=Math.imul(Ke,tt),w=Math.imul(Ke,ot),w=w+Math.imul(pt,tt)|0,R=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,R=R+Math.imul(Ot,bt)|0,g=g+Math.imul($e,yt)|0,w=w+Math.imul($e,It)|0,w=w+Math.imul(Ge,yt)|0,R=R+Math.imul(Ge,It)|0,g=g+Math.imul(Ie,Xe)|0,w=w+Math.imul(Ie,Rt)|0,w=w+Math.imul(Fe,Xe)|0,R=R+Math.imul(Fe,Rt)|0,g=g+Math.imul(ge,$)|0,w=w+Math.imul(ge,T)|0,w=w+Math.imul(de,$)|0,R=R+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,R=R+Math.imul(B,ae)|0,g=g+Math.imul(q,_e)|0,w=w+Math.imul(q,it)|0,w=w+Math.imul(pe,_e)|0,R=R+Math.imul(pe,it)|0,g=g+Math.imul(G,rt)|0,w=w+Math.imul(G,Q)|0,w=w+Math.imul(ee,rt)|0,R=R+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,R=R+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,R=R+Math.imul(fe,at)|0;var Ii=(k+g|0)+((w&8191)<<13)|0;k=(R+(w>>>13)|0)+(Ii>>>26)|0,Ii&=67108863,g=Math.imul(Ke,st),w=Math.imul(Ke,bt),w=w+Math.imul(pt,st)|0,R=Math.imul(pt,bt),g=g+Math.imul(et,yt)|0,w=w+Math.imul(et,It)|0,w=w+Math.imul(Ot,yt)|0,R=R+Math.imul(Ot,It)|0,g=g+Math.imul($e,Xe)|0,w=w+Math.imul($e,Rt)|0,w=w+Math.imul(Ge,Xe)|0,R=R+Math.imul(Ge,Rt)|0,g=g+Math.imul(Ie,$)|0,w=w+Math.imul(Ie,T)|0,w=w+Math.imul(Fe,$)|0,R=R+Math.imul(Fe,T)|0,g=g+Math.imul(ge,K)|0,w=w+Math.imul(ge,ae)|0,w=w+Math.imul(de,K)|0,R=R+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,R=R+Math.imul(B,it)|0,g=g+Math.imul(q,rt)|0,w=w+Math.imul(q,Q)|0,w=w+Math.imul(pe,rt)|0,R=R+Math.imul(pe,Q)|0,g=g+Math.imul(G,ke)|0,w=w+Math.imul(G,Ze)|0,w=w+Math.imul(ee,ke)|0,R=R+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,R=R+Math.imul(N,at)|0;var Dn=(k+g|0)+((w&8191)<<13)|0;k=(R+(w>>>13)|0)+(Dn>>>26)|0,Dn&=67108863,g=Math.imul(Ke,yt),w=Math.imul(Ke,It),w=w+Math.imul(pt,yt)|0,R=Math.imul(pt,It),g=g+Math.imul(et,Xe)|0,w=w+Math.imul(et,Rt)|0,w=w+Math.imul(Ot,Xe)|0,R=R+Math.imul(Ot,Rt)|0,g=g+Math.imul($e,$)|0,w=w+Math.imul($e,T)|0,w=w+Math.imul(Ge,$)|0,R=R+Math.imul(Ge,T)|0,g=g+Math.imul(Ie,K)|0,w=w+Math.imul(Ie,ae)|0,w=w+Math.imul(Fe,K)|0,R=R+Math.imul(Fe,ae)|0,g=g+Math.imul(ge,_e)|0,w=w+Math.imul(ge,it)|0,w=w+Math.imul(de,_e)|0,R=R+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,R=R+Math.imul(B,Q)|0,g=g+Math.imul(q,ke)|0,w=w+Math.imul(q,Ze)|0,w=w+Math.imul(pe,ke)|0,R=R+Math.imul(pe,Ze)|0,g=g+Math.imul(G,Qe)|0,w=w+Math.imul(G,at)|0,w=w+Math.imul(ee,Qe)|0,R=R+Math.imul(ee,at)|0;var ki=(k+g|0)+((w&8191)<<13)|0;k=(R+(w>>>13)|0)+(ki>>>26)|0,ki&=67108863,g=Math.imul(Ke,Xe),w=Math.imul(Ke,Rt),w=w+Math.imul(pt,Xe)|0,R=Math.imul(pt,Rt),g=g+Math.imul(et,$)|0,w=w+Math.imul(et,T)|0,w=w+Math.imul(Ot,$)|0,R=R+Math.imul(Ot,T)|0,g=g+Math.imul($e,K)|0,w=w+Math.imul($e,ae)|0,w=w+Math.imul(Ge,K)|0,R=R+Math.imul(Ge,ae)|0,g=g+Math.imul(Ie,_e)|0,w=w+Math.imul(Ie,it)|0,w=w+Math.imul(Fe,_e)|0,R=R+Math.imul(Fe,it)|0,g=g+Math.imul(ge,rt)|0,w=w+Math.imul(ge,Q)|0,w=w+Math.imul(de,rt)|0,R=R+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,R=R+Math.imul(B,Ze)|0,g=g+Math.imul(q,Qe)|0,w=w+Math.imul(q,at)|0,w=w+Math.imul(pe,Qe)|0,R=R+Math.imul(pe,at)|0;var Js=(k+g|0)+((w&8191)<<13)|0;k=(R+(w>>>13)|0)+(Js>>>26)|0,Js&=67108863,g=Math.imul(Ke,$),w=Math.imul(Ke,T),w=w+Math.imul(pt,$)|0,R=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,R=R+Math.imul(Ot,ae)|0,g=g+Math.imul($e,_e)|0,w=w+Math.imul($e,it)|0,w=w+Math.imul(Ge,_e)|0,R=R+Math.imul(Ge,it)|0,g=g+Math.imul(Ie,rt)|0,w=w+Math.imul(Ie,Q)|0,w=w+Math.imul(Fe,rt)|0,R=R+Math.imul(Fe,Q)|0,g=g+Math.imul(ge,ke)|0,w=w+Math.imul(ge,Ze)|0,w=w+Math.imul(de,ke)|0,R=R+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,R=R+Math.imul(B,at)|0;var Zs=(k+g|0)+((w&8191)<<13)|0;k=(R+(w>>>13)|0)+(Zs>>>26)|0,Zs&=67108863,g=Math.imul(Ke,K),w=Math.imul(Ke,ae),w=w+Math.imul(pt,K)|0,R=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,R=R+Math.imul(Ot,it)|0,g=g+Math.imul($e,rt)|0,w=w+Math.imul($e,Q)|0,w=w+Math.imul(Ge,rt)|0,R=R+Math.imul(Ge,Q)|0,g=g+Math.imul(Ie,ke)|0,w=w+Math.imul(Ie,Ze)|0,w=w+Math.imul(Fe,ke)|0,R=R+Math.imul(Fe,Ze)|0,g=g+Math.imul(ge,Qe)|0,w=w+Math.imul(ge,at)|0,w=w+Math.imul(de,Qe)|0,R=R+Math.imul(de,at)|0;var ji=(k+g|0)+((w&8191)<<13)|0;k=(R+(w>>>13)|0)+(ji>>>26)|0,ji&=67108863,g=Math.imul(Ke,_e),w=Math.imul(Ke,it),w=w+Math.imul(pt,_e)|0,R=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,R=R+Math.imul(Ot,Q)|0,g=g+Math.imul($e,ke)|0,w=w+Math.imul($e,Ze)|0,w=w+Math.imul(Ge,ke)|0,R=R+Math.imul(Ge,Ze)|0,g=g+Math.imul(Ie,Qe)|0,w=w+Math.imul(Ie,at)|0,w=w+Math.imul(Fe,Qe)|0,R=R+Math.imul(Fe,at)|0;var Qs=(k+g|0)+((w&8191)<<13)|0;k=(R+(w>>>13)|0)+(Qs>>>26)|0,Qs&=67108863,g=Math.imul(Ke,rt),w=Math.imul(Ke,Q),w=w+Math.imul(pt,rt)|0,R=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,R=R+Math.imul(Ot,Ze)|0,g=g+Math.imul($e,Qe)|0,w=w+Math.imul($e,at)|0,w=w+Math.imul(Ge,Qe)|0,R=R+Math.imul(Ge,at)|0;var eo=(k+g|0)+((w&8191)<<13)|0;k=(R+(w>>>13)|0)+(eo>>>26)|0,eo&=67108863,g=Math.imul(Ke,ke),w=Math.imul(Ke,Ze),w=w+Math.imul(pt,ke)|0,R=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,R=R+Math.imul(Ot,at)|0;var W=(k+g|0)+((w&8191)<<13)|0;k=(R+(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,R=Math.imul(pt,at);var oe=(k+g|0)+((w&8191)<<13)|0;return k=(R+(w>>>13)|0)+(oe>>>26)|0,oe&=67108863,j[0]=Mt,j[1]=fr,j[2]=Kt,j[3]=Yt,j[4]=_r,j[5]=rn,j[6]=Tr,j[7]=dr,j[8]=Gr,j[9]=Ii,j[10]=Dn,j[11]=ki,j[12]=Js,j[13]=Zs,j[14]=ji,j[15]=Qs,j[16]=eo,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 R=A-w,ue=p.words[R]|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 R=0;for(w=this.length-1;w>=0&&(R!==0||w>=E);w--){var ue=this.words[w]|0;this.words[w]=R<<26-A|ue>>>A,R=ue&k}return g&&R!==0&&(g.words[g.length++]=R),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 R=0;R<w.length;R++)w.words[R]=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(),R=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(R)),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(R)),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,R=1;!(x.words[0]&R)&&w<26;++w,R<<=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 R=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(R,new o(1).iushln(fe-Ce-1));ue=ue.redMul(N),R=N.redSqr(),ie=ie.redMul(R),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 R=m.words[A],ue=w-1;ue>=0;ue--){var ie=R>>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)}}),yr=sc(oc()),ac=sc(oc());function ag(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 G_(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 xU(e){return e.split("::")[0]}function cc(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=cc(r),u=vU(yU({},c),{type_arguments:i.map(l=>cc(l).source_address)});return u.type_arguments=u.type_arguments.map(l=>X_.isSuiCoin(l)?l:cc(l).source_address),u.source_address=G_(u.full_address,u.type_arguments),u}const s=r.split("::"),a={full_address:r,address:r===Y_||r===TU?"0x2":ur.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=G_(a.full_address,a.type_arguments),a}catch{return{full_address:e,address:"",module:"",name:"",type_arguments:[],source_address:e}}}function K_(e){return cc(e).source_address}var SU="0x2::coin::Coin",EU=/^0x2::coin::Coin<(.+)>$/,Y_="0x2::sui::SUI",TU="0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI",X_=class Uo{static getCoinTypeArg(t){const r=t.type.match(EU);return r?r[1]:null}static isSUI(t){const r=Uo.getCoinTypeArg(t);return r?Uo.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`${SU}<${t}>`}static getCoinAssets(t,r){const n=[];return r.forEach(i=>{K_(i.coinAddress)===K_(t)&&n.push(i)}),n}static isSuiCoin(t){return cc(t).full_address===Y_}static selectCoinObjectIdGreaterThanOrEqual(t,r,n=[]){const i=Uo.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=Uo.sortByBalance(t.filter(u=>!n.includes(u.coinObjectId))),s=Uo.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:Uo.sortByBalance(a),remainingCoins:Uo.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 _o(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 CU(e,t){e=_o(e),t=_o(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 Bu=sc(oc()),uc=new Bu.default(0);new Bu.default(1);var AU=new Bu.default(2);AU.pow(new Bu.default(128)),new Bu.default("18446744073709551615");var cg="18446744073709551615",MU="0xb1e11ceaf3e7cd3031ef5e24804478ec3441c5aecdace910bdaca317a0c1c535",Xf={AGGREGATOR_V3:"aggregator_v3"},Jf={Mainnet:"0xdeeb7a4662eec9f2f3def03fb937a663dddaa2e215b8078a284d026b7946c270::deep::DEEP",Testnet:"0x36dbef866a1d62bf7328989a10fb2f07d769f4ee587c0de4a0a256e57e0a58a8::deep::DEEP"},Ei={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"}},Gt={FEE_DENOMINATOR:1e6,MAX_FEE_RATE:1e5,MAX_AMOUNT_IN:cg,DEFAULT_PUBLISHED_AT:{Mainnet:"0x33ec64e9bb369bf045ddc198c81adbf2acab424da37465d95296ee02045d2b17",Testnet:"0x0"}},J_=1010106;function OU(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 ac.default(e.amount_in.toString()),amountOut:new ac.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 IU(e,t,r,n,i){return yn(this,null,function*(){let s;if(r.liquidityChanges&&r.liquidityChanges.length>0?s=yield jU(e,r):s=yield kU(e,t,r),!s)return null;if(!s.ok){let c=1e3;return s.status===429&&(c=1001),{quoteID:"",amountIn:uc,amountOut:uc,paths:[],byAmountIn:r.byAmountIn,insufficientLiquidity:!1,deviationRatio:0,error:{code:c,msg:ag(c)}}}const o=lU.default.parse(yield s.text()),a=o.msg==="liquidity is not enough";if(o.msg&&o.msg.indexOf("HoneyPot scam")>-1)return{quoteID:"",amountIn:uc,amountOut:uc,paths:[],byAmountIn:r.byAmountIn,insufficientLiquidity:a,deviationRatio:0,error:{code:1003,msg:ag(1003)}};if(o.data!=null){const c=OU(o.data,r.byAmountIn);if(n>0&&i!=="0x0")if(r.byAmountIn){const u=c.amountOut.mul(new ac.default(n)).div(new ac.default(1e6));c.overlayFee=Number(u.toString()),c.amountOut=c.amountOut.sub(u)}else{const u=c.amountIn.mul(new ac.default(n)).div(new ac.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:uc,amountOut:uc,paths:[],insufficientLiquidity:a,byAmountIn:r.byAmountIn,deviationRatio:0,error:{code:1002,msg:ag(1002)}}})}function kU(e,t,r){return yn(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=_o(n),v=_o(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=${J_}`,yield fetch(b)}catch(n){return console.error(n),null}})}function jU(e,t){return yn(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=_o(r),v=_o(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:J_};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 PU(e){return yn(this,null,function*(){const t=`${e}/deepbookv3_config`;try{return(yield fetch(t)).json()}catch(r){return console.error("Error:",r),null}})}function Z_(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 Q_=(e=>(e[e.Mainnet=0]="Mainnet",e[e.Testnet=1]="Testnet",e))(Q_||{}),RU=sc(oc()),lc=9e15,xo=1e9,ug="0123456789abcdef",Zf="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",Qf="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",lg={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-lc,maxE:lc,crypto:!1},ex,Ls,Ct=!0,ed="[DecimalError] ",So=ed+"Invalid argument: ",tx=ed+"Precision limit exceeded",rx=ed+"crypto unavailable",nx="[object Decimal]",ln=Math.floor,Vr=Math.pow,NU=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,$U=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,DU=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,ix=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,Ti=1e7,wt=7,LU=9007199254740991,BU=Zf.length-1,fg=Qf.length-1,Re={toStringTag:nx};Re.absoluteValue=Re.abs=function(){var e=new this.constructor(this);return e.s<0&&(e.s=1),dt(e)},Re.ceil=function(){return dt(new this.constructor(this),this.e+1,2)},Re.clampedTo=Re.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(So+t);return r=n.cmp(e),r<0?e:n.cmp(t)>0?t:new i(n)},Re.comparedTo=Re.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},Re.cosine=Re.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=UU(n,lx(n,r)),n.precision=e,n.rounding=t,dt(Ls==2||Ls==3?r.neg():r,e,t,!0)):new n(1):new n(NaN)},Re.cubeRoot=Re.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(Ct=!1,s=l.s*Vr(l.s*l,1/3),!s||Math.abs(s)==1/0?(r=Yr(l.d),e=l.e,(s=(e-r.length+1)%3)&&(r+=s==1||s==-2?"0":"00"),s=Vr(r,1/3),e=ln((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=er(u.plus(l).times(a),u.plus(c),o+2,1),Yr(a.d).slice(0,o)===(r=Yr(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 Ct=!0,dt(n,e,f.rounding,t)},Re.decimalPlaces=Re.dp=function(){var e,t=this.d,r=NaN;if(t){if(e=t.length-1,r=(e-ln(this.e/wt))*wt,e=t[e],e)for(;e%10==0;e/=10)r--;r<0&&(r=0)}return r},Re.dividedBy=Re.div=function(e){return er(this,new this.constructor(e))},Re.dividedToIntegerBy=Re.divToInt=function(e){var t=this,r=t.constructor;return dt(er(t,new r(e),0,1,1),r.precision,r.rounding)},Re.equals=Re.eq=function(e){return this.cmp(e)===0},Re.floor=function(){return dt(new this.constructor(this),this.e+1,3)},Re.greaterThan=Re.gt=function(e){return this.cmp(e)>0},Re.greaterThanOrEqualTo=Re.gte=function(e){var t=this.cmp(e);return t==1||t===0},Re.hyperbolicCosine=Re.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/sd(4,e)).toString()):(e=16,t="2.3283064365386962890625e-10"),s=fc(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)},Re.hyperbolicSine=Re.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=fc(s,2,i,i,!0);else{e=1.4*Math.sqrt(n),e=e>16?16:e|0,i=i.times(1/sd(5,e)),i=fc(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)},Re.hyperbolicTangent=Re.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,er(r.sinh(),r.cosh(),n.precision=e,n.rounding=t)):new n(r.s)},Re.inverseCosine=Re.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()?es(t,n,i):new t(0):new t(NaN):e.isZero()?es(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))},Re.inverseHyperbolicCosine=Re.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,Ct=!1,r=r.times(r).minus(1).sqrt().plus(r),Ct=!0,n.precision=e,n.rounding=t,r.ln()):new n(r)},Re.inverseHyperbolicSine=Re.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,Ct=!1,r=r.times(r).plus(1).sqrt().plus(r),Ct=!0,n.precision=e,n.rounding=t,r.ln())},Re.inverseHyperbolicTangent=Re.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=er(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)},Re.inverseSine=Re.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=es(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)))},Re.inverseTangent=Re.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<=fg)return o=es(l,f+4,h).times(.25),o.s=u.s,o}else{if(!u.s)return new l(NaN);if(f+4<=fg)return o=es(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(Ct=!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)),Ct=!0,dt(o,l.precision=f,l.rounding=h,!0)},Re.isFinite=function(){return!!this.d},Re.isInteger=Re.isInt=function(){return!!this.d&&ln(this.e/wt)>this.d.length-2},Re.isNaN=function(){return!this.s},Re.isNegative=Re.isNeg=function(){return this.s<0},Re.isPositive=Re.isPos=function(){return this.s>0},Re.isZero=function(){return!!this.d&&this.d[0]===0},Re.lessThan=Re.lt=function(e){return this.cmp(e)<0},Re.lessThanOrEqualTo=Re.lte=function(e){return this.cmp(e)<1},Re.logarithm=Re.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(Ct=!1,a=f+v,o=To(u,a),n=t?nd(l,a+10):To(e,a),c=er(o,n,a,1),Uu(c.d,i=f,h))do if(a+=10,o=To(u,a),n=t?nd(l,a+10):To(e,a),c=er(o,n,a,1),!s){+Yr(c.d).slice(i+1,i+15)+1==1e14&&(c=dt(c,f+1,0));break}while(Uu(c.d,i+=10,h));return Ct=!0,dt(c,f,h)},Re.minus=Re.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 Ct?dt(e,a,c):e}if(r=ln(e.e/wt),l=ln(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=rd(u,r),Ct?dt(e,a,c):e):new b(c===3?-0:0)},Re.modulo=Re.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):(Ct=!1,n.modulo==9?(t=er(r,e.abs(),0,3,1),t.s*=e.s):t=er(r,e,0,n.modulo,1),t=t.times(e),Ct=!0,r.minus(t))},Re.naturalExponential=Re.exp=function(){return dg(this)},Re.naturalLogarithm=Re.ln=function(){return To(this)},Re.negated=Re.neg=function(){var e=new this.constructor(this);return e.s=-e.s,dt(e)},Re.plus=Re.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)),Ct?dt(e,a,c):e;if(s=ln(f.e/wt),n=ln(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=rd(u,n),Ct?dt(e,a,c):e},Re.precision=Re.sd=function(e){var t,r=this;if(e!==void 0&&e!==!!e&&e!==1&&e!==0)throw Error(So+e);return r.d?(t=sx(r.d),e&&r.e+1>t&&(t=r.e+1)):t=NaN,t},Re.round=function(){var e=this,t=e.constructor;return dt(new t(e),e.e+1,t.rounding)},Re.sine=Re.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=VU(n,lx(n,r)),n.precision=e,n.rounding=t,dt(Ls>2?r.neg():r,e,t,!0)):new n(NaN)},Re.squareRoot=Re.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(Ct=!1,u=Math.sqrt(+o),u==0||u==1/0?(t=Yr(a),(t.length+c)%2==0&&(t+="0"),u=Math.sqrt(t),c=ln((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(er(o,s,r+2,1)).times(.5),Yr(s.d).slice(0,r)===(t=Yr(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 Ct=!0,dt(n,c,l.rounding,e)},Re.tangent=Re.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=er(r,new n(1).minus(r.times(r)).sqrt(),e+10,0),n.precision=e,n.rounding=t,dt(Ls==2||Ls==4?r.neg():r,e,t,!0)):new n(NaN)},Re.times=Re.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=ln(l.e/wt)+ln(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=rd(s,r),Ct?dt(e,f.precision,f.rounding):e},Re.toBinary=function(e,t){return hg(this,2,e,t)},Re.toDecimalPlaces=Re.toDP=function(e,t){var r=this,n=r.constructor;return r=new n(r),e===void 0?r:(jn(e,0,xo),t===void 0?t=n.rounding:jn(t,0,8),dt(r,e+r.e+1,t))},Re.toExponential=function(e,t){var r,n=this,i=n.constructor;return e===void 0?r=Qi(n,!0):(jn(e,0,xo),t===void 0?t=i.rounding:jn(t,0,8),n=dt(new i(n),e+1,t),r=Qi(n,!0,e+1)),n.isNeg()&&!n.isZero()?"-"+r:r},Re.toFixed=function(e,t){var r,n,i=this,s=i.constructor;return e===void 0?r=Qi(i):(jn(e,0,xo),t===void 0?t=s.rounding:jn(t,0,8),n=dt(new s(i),e+i.e+1,t),r=Qi(n,!1,e+n.e+1)),i.isNeg()&&!i.isZero()?"-"+r:r},Re.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=sx(b)-v.e-1,o=s%wt,t.d[0]=Vr(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(So+a);e=a.gt(t)?s>0?t:u:a}for(Ct=!1,a=new y(Yr(b)),l=y.precision,y.precision=s=b.length*wt*2;f=er(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=er(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=er(u,n,s,1).minus(v).abs().cmp(er(c,r,s,1).minus(v).abs())<1?[u,n]:[c,r],y.precision=l,Ct=!0,h},Re.toHexadecimal=Re.toHex=function(e,t){return hg(this,16,e,t)},Re.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:jn(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]?(Ct=!1,r=er(r,e,0,t,1).times(e),Ct=!0,dt(r)):(e.s=r.s,r=e),r},Re.toNumber=function(){return+this},Re.toOctal=function(e,t){return hg(this,8,e,t)},Re.toPower=Re.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(Vr(+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=ln(e.e/wt),t>=e.d.length-1&&(r=u<0?-u:u)<=LU)return i=ox(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=Vr(+a,u),t=r==0||!isFinite(r)?ln(u*(Math.log("0."+Yr(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):(Ct=!1,c.rounding=a.s=1,r=Math.min(12,(t+"").length),i=dg(e.times(To(a,n+r)),n),i.d&&(i=dt(i,n+5,1),Uu(i.d,n,s)&&(t=n+10,i=dt(dg(e.times(To(a,t+r)),t),t+5,1),+Yr(i.d).slice(n+1,n+15)+1==1e14&&(i=dt(i,n+1,0)))),i.s=o,Ct=!0,c.rounding=s,dt(i,n,s))},Re.toPrecision=function(e,t){var r,n=this,i=n.constructor;return e===void 0?r=Qi(n,n.e<=i.toExpNeg||n.e>=i.toExpPos):(jn(e,1,xo),t===void 0?t=i.rounding:jn(t,0,8),n=dt(new i(n),e,t),r=Qi(n,e<=n.e||n.e<=i.toExpNeg,e)),n.isNeg()&&!n.isZero()?"-"+r:r},Re.toSignificantDigits=Re.toSD=function(e,t){var r=this,n=r.constructor;return e===void 0?(e=n.precision,t=n.rounding):(jn(e,1,xo),t===void 0?t=n.rounding:jn(t,0,8)),dt(new n(r),e,t)},Re.toString=function(){var e=this,t=e.constructor,r=Qi(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()&&!e.isZero()?"-"+r:r},Re.truncated=Re.trunc=function(){return dt(new this.constructor(this),this.e+1,1)},Re.valueOf=Re.toJSON=function(){var e=this,t=e.constructor,r=Qi(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()?"-"+r:r};function Yr(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+=Eo(r)),s+=n;o=e[t],n=o+"",r=wt-n.length,r&&(s+=Eo(r))}else if(o===0)return"0";for(;o%10===0;)o/=10;return s+o}function jn(e,t,r){if(e!==~~e||e<t||e>r)throw Error(So+e)}function Uu(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=Vr(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)==Vr(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)==Vr(10,t-3)-1,o}function td(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]+=ug.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 UU(e,t){var r,n,i;if(t.isZero())return t;n=t.d.length,n<32?(r=Math.ceil(n/3),i=(1/sd(4,r)).toString()):(r=16,i="2.3283064365386962890625e-10"),e.precision+=r,t=fc(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 er=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=ln(n.e/v)-ln(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,ex=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/Vr(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/Vr(10,i-o-1)%10|0}if(n=n||t<0||f[h+1]!==void 0||(o<0?l:l%Vr(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/Vr(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]=Vr(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=Vr(10,wt-s),f[h]=o>0?(l/Vr(10,i-o)%Vr(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 Ct&&(e.e>v.maxE?(e.d=null,e.e=NaN):e.e<v.minE&&(e.e=0,e.d=[0])),e}function Qi(e,t,r){if(!e.isFinite())return ux(e);var n,i=e.e,s=Yr(e.d),o=s.length;return t?(r&&(n=r-o)>0?s=s.charAt(0)+"."+s.slice(1)+Eo(n):o>1&&(s=s.charAt(0)+"."+s.slice(1)),s=s+(e.e<0?"e":"e+")+e.e):i<0?(s="0."+Eo(-i-1)+s,r&&(n=r-o)>0&&(s+=Eo(n))):i>=o?(s+=Eo(i+1-o),r&&(n=r-i-1)>0&&(s=s+"."+Eo(n))):((n=i+1)<o&&(s=s.slice(0,n)+"."+s.slice(n)),r&&(n=r-o)>0&&(i+1===o&&(s+="."),s+=Eo(n))),s}function rd(e,t){var r=e[0];for(t*=wt;r>=10;r/=10)t++;return t}function nd(e,t,r){if(t>BU)throw Ct=!0,r&&(e.precision=r),Error(tx);return dt(new e(Zf),t,1,!0)}function es(e,t,r){if(t>fg)throw Error(tx);return dt(new e(Qf),t,r,!0)}function sx(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 Eo(e){for(var t="";e--;)t+="0";return t}function ox(e,t,r,n){var i,s=new e(1),o=Math.ceil(n/wt+4);for(Ct=!1;;){if(r%2&&(s=s.times(t),fx(s.d,o)&&(i=!0)),r=ln(r/2),r===0){r=s.d.length-1,i&&s.d[r]===0&&++s.d[r];break}t=t.times(t),fx(t.d,o)}return Ct=!0,s}function ax(e){return e.d[e.d.length-1]&1}function cx(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 dg(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?(Ct=!1,c=b):c=t,a=new h(.03125);e.e>-2;)e=e.times(a),f+=5;for(n=Math.log(Vr(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(er(s,r,c,1)),Yr(a.d).slice(0,c)===Yr(o.d).slice(0,c)){for(i=f;i--;)o=dt(o.times(o),c,1);if(t==null)if(u<3&&Uu(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,Ct=!0);else return h.precision=b,o}o=a}}function To(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?(Ct=!1,l=I):l=t,C.precision=l+=b,r=Yr(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=Yr(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=nd(C,l+2,I).times(s+""),y=To(new C(n+"."+r.slice(1)),l-b).plus(u),C.precision=I,t==null?dt(y,I,O,Ct=!0):y;for(f=y,c=o=y=er(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(er(o,new C(i),l,1)),Yr(u.d).slice(0,l)===Yr(c.d).slice(0,l))if(c=c.times(2),s!==0&&(c=c.plus(nd(C,l+2,I).times(s+""))),c=er(c,new C(v),l,1),t==null)if(Uu(c.d,l-b,O,a))C.precision=l+=b,u=o=y=er(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,Ct=!0);else return C.precision=I,c;c=u,i+=2}}function ux(e){return String(e.s*e.s/0)}function id(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),Ct&&(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 FU(e,t){var r,n,i,s,o,a,c,u,l;if(t.indexOf("_")>-1){if(t=t.replace(/(\d)_(?=\d)/g,"$1"),ix.test(t))return id(e,t)}else if(t==="Infinity"||t==="NaN")return+t||(e.s=NaN),e.e=NaN,e.d=null,e;if($U.test(t))r=16,t=t.toLowerCase();else if(NU.test(t))r=2;else if(DU.test(t))r=8;else throw Error(So+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=ox(n,new n(r),s,s*2)),u=td(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=rd(u,l),e.d=u,Ct=!1,o&&(e=er(e,i,a*4)),c&&(e=e.times(Math.abs(c)<54?Vr(2,c):Fu.pow(2,c))),Ct=!0,e)}function VU(e,t){var r,n=t.d.length;if(n<3)return t.isZero()?t:fc(e,2,t,t);r=1.4*Math.sqrt(n),r=r>16?16:r|0,t=t.times(1/sd(5,r)),t=fc(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 fc(e,t,r,n,i){var s,o,a,c,u=e.precision,l=Math.ceil(u/wt);for(Ct=!1,c=r.times(r),a=new e(n);;){if(o=er(a.times(c),new e(t++*t++),u,1),a=i?n.plus(o):n.minus(o),n=er(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 Ct=!0,o.d.length=l+1,o}function sd(e,t){for(var r=e;--t;)r*=e;return r}function lx(e,t){var r,n=t.s<0,i=es(e,e.precision,1),s=i.times(.5);if(t=t.abs(),t.lte(s))return Ls=n?4:1,t;if(r=t.divToInt(i),r.isZero())Ls=n?3:2;else{if(t=t.minus(r.times(i)),t.lte(s))return Ls=ax(r)?n?2:3:n?4:1,t;Ls=ax(r)?n?1:4:n?3:2}return t.minus(i).abs()}function hg(e,t,r,n){var i,s,o,a,c,u,l,f,h,v=e.constructor,b=r!==void 0;if(b?(jn(r,1,xo),n===void 0?n=v.rounding:jn(n,0,8)):(r=v.precision,n=v.rounding),!e.isFinite())l=ux(e);else{for(l=Qi(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=td(Qi(h),10,i),h.e=h.d.length),f=td(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=er(e,h,r,n,0,i),f=e.d,s=e.e,u=ex),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+=ug.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=td(l,i,t),c=f.length;!f[c-1];--c);for(o=1,l="1.";o<c;o++)l+=ug.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 fx(e,t){if(e.length>t)return e.length=t,!0}function zU(e){return new this(e).abs()}function WU(e){return new this(e).acos()}function qU(e){return new this(e).acosh()}function HU(e,t){return new this(e).plus(t)}function GU(e){return new this(e).asin()}function KU(e){return new this(e).asinh()}function YU(e){return new this(e).atan()}function XU(e){return new this(e).atanh()}function JU(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=es(this,s,1).times(t.s>0?.25:.75),r.s=e.s):!t.d||e.isZero()?(r=t.s<0?es(this,n,i):new this(0),r.s=e.s):!e.d||t.isZero()?(r=es(this,s,1).times(.5),r.s=e.s):t.s<0?(this.precision=s,this.rounding=1,r=this.atan(er(e,t,s,1)),t=es(this,s,1),this.precision=n,this.rounding=i,r=e.s<0?r.minus(t):r.plus(t)):r=this.atan(er(e,t,s,1)),r}function ZU(e){return new this(e).cbrt()}function QU(e){return dt(e=new this(e),e.e+1,2)}function eF(e,t,r){return new this(e).clamp(t,r)}function tF(e){if(!e||typeof e!="object")throw Error(ed+"Object expected");var t,r,n,i=e.defaults===!0,s=["precision",1,xo,"rounding",0,8,"toExpNeg",-lc,0,"toExpPos",0,lc,"maxE",0,lc,"minE",-lc,0,"modulo",0,9];for(t=0;t<s.length;t+=3)if(r=s[t],i&&(this[r]=lg[r]),(n=e[r])!==void 0)if(ln(n)===n&&n>=s[t+1]&&n<=s[t+2])this[r]=n;else throw Error(So+r+": "+n);if(r="crypto",i&&(this[r]=lg[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(rx);else this[r]=!1;else throw Error(So+r+": "+n);return this}function rF(e){return new this(e).cos()}function nF(e){return new this(e).cosh()}function dx(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,hx(s)){u.s=s.s,Ct?!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++;Ct?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 id(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),ix.test(s)?id(u,s):FU(u,s);if(c==="bigint")return s<0?(s=-s,u.s=-1):u.s=1,id(u,s.toString());throw Error(So+s)}if(i.prototype=Re,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=tF,i.clone=dx,i.isDecimal=hx,i.abs=zU,i.acos=WU,i.acosh=qU,i.add=HU,i.asin=GU,i.asinh=KU,i.atan=YU,i.atanh=XU,i.atan2=JU,i.cbrt=ZU,i.ceil=QU,i.clamp=eF,i.cos=rF,i.cosh=nF,i.div=iF,i.exp=sF,i.floor=oF,i.hypot=aF,i.ln=cF,i.log=uF,i.log10=fF,i.log2=lF,i.max=dF,i.min=hF,i.mod=pF,i.mul=mF,i.pow=gF,i.random=yF,i.round=vF,i.sign=bF,i.sin=wF,i.sinh=_F,i.sqrt=xF,i.sub=SF,i.sum=EF,i.tan=TF,i.tanh=CF,i.trunc=AF,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 iF(e,t){return new this(e).div(t)}function sF(e){return new this(e).exp()}function oF(e){return dt(e=new this(e),e.e+1,3)}function aF(){var e,t,r=new this(0);for(Ct=!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 Ct=!0,new this(1/0);r=t}return Ct=!0,r.sqrt()}function hx(e){return e instanceof Fu||e&&e.toStringTag===nx||!1}function cF(e){return new this(e).ln()}function uF(e,t){return new this(e).log(t)}function lF(e){return new this(e).log(2)}function fF(e){return new this(e).log(10)}function dF(){return cx(this,arguments,-1)}function hF(){return cx(this,arguments,1)}function pF(e,t){return new this(e).mod(t)}function mF(e,t){return new this(e).mul(t)}function gF(e,t){return new this(e).pow(t)}function yF(e){var t,r,n,i,s=0,o=new this(1),a=[];if(e===void 0?e=this.precision:jn(e,1,xo),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(rx);else for(;s<n;)a[s++]=Math.random()*1e7|0;for(n=a[--s],e%=wt,n&&e&&(i=Vr(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 vF(e){return dt(e=new this(e),e.e+1,this.rounding)}function bF(e){return e=new this(e),e.d?e.d[0]?e.s:0*e.s:e.s||NaN}function wF(e){return new this(e).sin()}function _F(e){return new this(e).sinh()}function xF(e){return new this(e).sqrt()}function SF(e,t){return new this(e).sub(t)}function EF(){var e=0,t=arguments,r=new this(t[e]);for(Ct=!1;r.s&&++e<t.length;)r=r.plus(t[e]);return Ct=!0,dt(r,this.precision,this.rounding)}function TF(e){return new this(e).tan()}function CF(e){return new this(e).tanh()}function AF(e){return dt(e=new this(e),e.e+1,1)}Re[Symbol.for("nodejs.util.inspect.custom")]=Re.toString,Re[Symbol.toStringTag]="Decimal";var Fu=Re.constructor=dx(lg);Zf=new Fu(Zf),Qf=new Fu(Qf);var px=Fu;function MF(e,t,r){return Number(gx(new px(e.toString()),t,r).toFixed(0))}function mx(e,t,r){const n=gx(new px(e.toString()),t,r);return new RU.default(n.toFixed(0))}function gx(e,t,r){return t?e.mul(1-r):e.mul(1+r)}var yx=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?Gt.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(ur.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(ur.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})}},OF=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?Gt.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(ur.SUI_CLOCK_OBJECT_ID)];e.moveCall({target:`${t.publishedAt}::kriya_clmm::swap`,typeArguments:[t.coinAType,t.coinBType],arguments:n})}},IF=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?Gt.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(ur.SUI_CLOCK_OBJECT_ID)];e.moveCall({target:`${t.publishedAt}::flowx_clmm::swap`,typeArguments:[t.coinAType,t.coinBType],arguments:n})}},kF=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?Gt.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(ur.SUI_CLOCK_OBJECT_ID)];e.moveCall({target:`${t.publishedAt}::turbos::swap`,typeArguments:[t.coinAType,t.coinBType,t.feeType],arguments:n})}},jF=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?Gt.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(ur.SUI_CLOCK_OBJECT_ID)];e.moveCall({target:`${t.publishedAt}::bluefin::swap`,typeArguments:[t.coinAType,t.coinBType],arguments:n})}},PF=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?Gt.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(ur.SUI_CLOCK_OBJECT_ID)];e.moveCall({target:`${t.publishedAt}::momentum::swap`,typeArguments:[t.coinAType,t.coinBType],arguments:n})}},RF=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?Gt.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(ur.SUI_CLOCK_OBJECT_ID)];e.moveCall({target:`${t.publishedAt}::magma::swap`,typeArguments:[t.coinAType,t.coinBType],arguments:n})}},NF=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?Gt.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})}},$F=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?Gt.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})}},DF=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?Gt.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})}},LF=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?Gt.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(ur.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}},BF=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})}},UF=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?Gt.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(ur.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})}},FF=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?Gt.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(ur.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})}},vx=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?Gt.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})}},VF=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?Gt.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(ur.SUI_CLOCK_OBJECT_ID)];e.moveCall({target:`${t.publishedAt}::haedal_hmm::swap`,typeArguments:[t.coinAType,t.coinBType],arguments:n})}},zF=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?Gt.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(ur.SUI_CLOCK_OBJECT_ID)];e.moveCall({target:`${t.publishedAt}::obric::swap`,typeArguments:[t.coinAType,t.coinBType],arguments:n})}},WF=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?Gt.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(ur.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(ur.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})}},qF=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?Gt.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(ur.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(ur.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(ur.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})}},HF=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?Gt.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(ur.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(ur.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(ur.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})}},GF="0x790f258062909e3a0ffc78b3c53ac2f62d7084c3bab95644bdeb05add7250001::super_sui::SUPER_SUI",KF="0xe44df51c0b21a27ab915fa1fe2ca610cd3eaa6d9666fe5e62b988bf7f0bd8722::musd::MUSD",YF="0xccd628c2334c5ed33e6c47d6c21bb664f8b6307b2ac32c2462a61f69a31ebcee::meth::METH",XF=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?Gt.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 GF:{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 KF:case YF:{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(ur.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})}},JF=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?Gt.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})}},ZF=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?Gt.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})}},QF=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?Gt.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})}},eV=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?Gt.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})}},tV=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?Gt.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})}},rV=Gt.DEFAULT_PUBLISHED_AT.Mainnet;function Vu(e,t){return e&&e.has(Xf.AGGREGATOR_V3)?e.get(Xf.AGGREGATOR_V3):t||rV}function bx(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=Vu(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 wx(e,t){const{swapContext:r,targetCoinType:n,aggregatorPublishedAt:i,packages:s}=e,o=Vu(s,i);return t.moveCall({target:`${o}::router::confirm_swap`,typeArguments:[n],arguments:[r]})}function nV(e,t){const{coinType:r,amount:n,swapCtx:i,aggregatorPublishedAt:s,packages:o}=e,a=Vu(o,s),c=[i,t.pure.u64(n.toString())];return t.moveCall({target:`${a}::router::take_balance`,typeArguments:[r],arguments:c})}function iV(e,t){const{balance:r,coinType:n,recipient:i,aggregatorPublishedAt:s,packages:o}=e,a=Vu(o,s),c=[r,t.pure.address(i)];t.moveCall({target:`${a}::router::transfer_balance`,typeArguments:[n],arguments:c})}function sV(e,t){const{coin:r,coinType:n,aggregatorPublishedAt:i,packages:s}=e,o=Vu(s,i);t.moveCall({target:`${o}::router::transfer_or_destroy_coin`,typeArguments:[n],arguments:[r]})}function oV(e){return e.endsWith("/find_routes")?e.replace("/find_routes",""):e}sc(oc()),sc(oc());var aV=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?Gt.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(ur.SUI_CLOCK_OBJECT_ID)];e.moveCall({target:`${t.publishedAt}::haedal_hmm_v2::swap`,typeArguments:[t.coinAType,t.coinBType],arguments:n})}},cV=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?Gt.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(ur.SUI_CLOCK_OBJECT_ID)];e.moveCall({target:`${t.publishedAt}::fullsail::swap`,typeArguments:[t.coinAType,t.coinBType],arguments:n})}},_x="CETUS",uV="KRIYA",lV="FLOWX",fV="FLOWXV3",dV="KRIYAV3",hV="TURBOS",pV="AFTERMATH",mV="HAEDAL",gV="VOLO",yV="AFSUI",vV="BLUEMOVE",bV="DEEPBOOKV3",wV="SCALLOP",_V="SUILEND",xV="BLUEFIN",xx="HAEDALPMM",SV="ALPHAFI",EV="SPRINGSUI",TV="STEAMM",Sx="METASTABLE",Ex="OBRIC",CV="HAWAL",Tx="STEAMM_OMM",AV="MOMENTUM",Cx="STEAMM_OMM_V2",MV="MAGMA",Ax="SEVENK",Mx="HAEDALHMMV2",OV="FULLSAIL",IV="https://api-sui.cetus.zone/router_v3";function Ox(e){const t=new Set;for(const r of e){if(r.provider===xx&&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===Sx&&(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===Ex&&(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===Tx||r.provider===Cx)&&(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===Ax&&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===Mx&&r.extendedDetails&&r.extendedDetails.haedalhmmv2_base_price_seed&&t.add(r.extendedDetails.haedalhmmv2_base_price_seed)}return Array.from(t)}var Ix=class PT{constructor(t){var r,n;this.endpoint=t.endpoint?oV(t.endpoint):IV,this.client=t.client||new F_.SuiClient({url:F_.getFullnodeUrl("mainnet")}),this.signer=t.signer||"",this.env=t.env||0;const i=PT.CONFIG[this.env];if(this.pythConnections=this.newPythClients((r=t.pythUrls)!=null?r:[]),this.pythClient=new V_.SuiPythClient(this.client,i.pythStateId,i.wormholeStateId),this.apiKey=t.apiKey||"",this.partner=t.partner,t.overlayFeeRate)if(t.overlayFeeRate>0&&t.overlayFeeRate<=Ei.MAX_OVERLAY_FEE_RATE){if(this.overlayFeeRate=t.overlayFeeRate*Gt.FEE_DENOMINATOR,this.overlayFeeRate>Gt.MAX_FEE_RATE)throw new Error(Ei.ERRORS.INVALID_OVERLAY_FEE_RATE)}else throw new Error(Ei.ERRORS.INVALID_OVERLAY_FEE_RATE);else this.overlayFeeRate=0;this.overlayFeeReceiver=(n=t.overlayFeeReceiver)!=null?n:Ei.DEFAULT_OVERLAY_FEE_RECEIVER}newPythClients(t){return t.includes("https://hermes.pyth.network")||t.push("https://hermes.pyth.network"),t.map(n=>new V_.SuiPriceServiceConnection(n,{timeout:3e3}))}deepbookv3DeepFeeType(){return this.env===0?Jf.Mainnet:Jf.Testnet}getDeepbookV3Config(){return yn(this,null,function*(){return yield PU(this.endpoint)})}getOneCoinUsedToMerge(t){return yn(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 yn(this,null,function*(){return IU(this.endpoint,this.apiKey,t,this.overlayFeeRate,this.overlayFeeReceiver)})}executeFlexibleInputSwap(t,r,n,i,s,o,a,c,u){return yn(this,null,function*(){})}newDexRouterV3(t,r,n){switch(t){case _x:return new yx(this.env,n);case dV:return new OF(this.env);case fV:return new IF(this.env);case hV:return new kF(this.env);case xV:return new jF(this.env);case AV:return new PF(this.env);case MV:return new RF(this.env);case uV:return new NF(this.env);case lV:return new $F(this.env);case vV:return new DF(this.env);case bV:return new LF(this.env);case pV:return new BF(this.env);case TV:return new UF(this.env);case wV:return new FF(this.env);case _V:return new vx(this.env);case EV:return new vx(this.env);case xx:return new VF(this.env,r);case Ex:return new zF(this.env,r);case Ax:return new WF(this.env,r);case Tx:return new qF(this.env,r);case Cx:return new HF(this.env,r);case Sx:return new XF(this.env,r);case SV:return new JF(this.env);case gV:return new ZF(this.env);case yV:return new QF(this.env);case mV:return new eV(this.env);case CV:return new tV(this.env);case Mx:return new aV(this.env,r);case OV:return new cV(this.env);default:throw new Error(`${Ei.ERRORS.UNSUPPORTED_DEX} ${t}`)}}expectInputSwapV3(t,r,n,i,s,o,a){if(n.quoteID==null)throw new Error(Ei.ERRORS.QUOTE_ID_REQUIRED);const c=Z_(n),u=bx({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 wx({swapContext:u,targetCoinType:c.targetCoinType,packages:c.packages},t)}expectOutputSwapV3(t,r,n,i,s,o){const a=[],c=new yx(this.env,o),u=Z_(n),l=bx({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=PV(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=nV({coinType:u.fromCoinType,amount:cg,swapCtx:l,packages:u.packages},t);return iV({balance:b,coinType:u.fromCoinType,recipient:this.signer,packages:u.packages},t),wx({swapContext:l,targetCoinType:u.targetCoinType,packages:u.packages},t)}routerSwap(t){return yn(this,null,function*(){const{router:r,inputCoin:n,slippage:i,txb:s,partner:o}=t;if(i>1||i<0)throw new Error(Ei.ERRORS.INVALID_SLIPPAGE);if(!t.router.packages||!t.router.packages.get(Xf.AGGREGATOR_V3))throw new Error(Ei.ERRORS.PACKAGES_REQUIRED);const a=t.router.byAmountIn,c=r.amountIn,u=r.amountOut;pg(this.overlayFeeRate,this.overlayFeeReceiver);let l=new yr.default(0);a?l=u.mul(new yr.default(this.overlayFeeRate)).div(new yr.default(1e6)):l=c.mul(new yr.default(this.overlayFeeRate)).div(new yr.default(1e6));const f=a?u.sub(l):u,h=a?c:c.add(l),v=mx(a?f:h,a,i),b=Ox(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 yn(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;pg(this.overlayFeeRate,this.overlayFeeReceiver);let l=0;u?l=Number(r.amountOut.mul(new yr.default(this.overlayFeeRate)).div(new yr.default(1e6)).toString()):l=Number(r.amountIn.mul(new yr.default(this.overlayFeeRate)).div(new yr.default(1e6)).toString());const f=u?r.amountOut.sub(new yr.default(l)):r.amountOut,h=u?r.amountIn:r.amountIn.add(new yr.default(l)),v=MF(u?f:h,u,n),b=u?h:v;let y=sg.coinWithBalance({balance:BigInt(b.toString()),useGasCoin:!0,type:a}),S;o&&o>0&&(S=sg.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(X_.isSuiCoin(c))i.mergeCoins(i.gas,[O]);else{const I=yield this.getOneCoinUsedToMerge(c);I!=null?i.mergeCoins(i.object(I),[O]):sV({coin:O,coinType:c,packages:r.packages},i)}})}fixableRouterSwapV3(t){return yn(this,null,function*(){const{router:r,inputCoin:n,slippage:i,txb:s,partner:o}=t;pg(this.overlayFeeRate,this.overlayFeeReceiver);let a=0;r.byAmountIn?a=Number(r.amountOut.mul(new yr.default(this.overlayFeeRate)).div(new yr.default(1e6)).toString()):a=Number(r.amountIn.mul(new yr.default(this.overlayFeeRate)).div(new yr.default(1e6)).toString());const c=r.byAmountIn?r.amountOut.sub(new yr.default(a)):r.amountOut,u=r.byAmountIn?r.amountIn:r.amountIn.add(new yr.default(a)),l=mx(r.byAmountIn?c:u,r.byAmountIn,i),f=Ox(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 yn(this,null,function*(){var r,n,i,s;const{from:o,target:a,amount:c,byAmountIn:u,pools:l}=t,f=_o(o),h=_o(a),v=new sg.Transaction,b=CU(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 yr.default(0):new yr.default(cg),H=0;for(let m=0;m<U.length;m+=1)if(!U[m].parsedJson.data.is_exceed)if(t.byAmountIn){const x=new yr.default(U[m].parsedJson.data.amount_out);x.gt(D)&&(H=m,D=x)}else{const x=new yr.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 yr.default((n=z.amount_in)!=null?n:0),V=new yr.default((i=z.fee_amount)!=null?i:0),L=ce.add(V),p={amountIn:L,amountOut:new yr.default((s=z.amount_out)!=null?s:0),deviationRatio:0,paths:[{id:l[H],direction:b,provider:_x,from:f,target:h,feeRate:te,amountIn:L.toString(),amountOut:z.amount_out,publishedAt:MU,extendedDetails:{afterSqrtPrice:z.after_sqrt_price}}],insufficientLiquidity:!1,byAmountIn:t.byAmountIn,quoteID:`degraded-${jV()}`,packages:new Map([[Xf.AGGREGATOR_V3,Gt.DEFAULT_PUBLISHED_AT.Mainnet]])};return{isExceed:z.is_exceed,routeData:p}})}updatePythPriceIDs(t,r){return yn(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 yn(this,null,function*(){return yield this.client.devInspectTransactionBlock({transactionBlock:t,sender:this.signer})})}sendTransaction(t,r){return yn(this,null,function*(){return yield this.client.signAndExecuteTransaction({transaction:t,signer:r})})}};Ix.CONFIG={1:{wormholeStateId:"0x31358d198147da50db32eda2562951d53973a0c0ad5ed738e9b17d88b213d790",pythStateId:"0x243759059f4c3111179da5878c12f68d612c21a8d54d85edc86164bb18be1c7c"},0:{wormholeStateId:"0xaeab97f96cf9877fee2883315d459552b2b921edc16d7ceac6eab944dd88919c",pythStateId:"0x1f9310238ee9298fb703c3419030b35b22bb1cc37113e3bb5007c99aec79e5b8"}};var kV=Ix;function jV(){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 PV(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 pg(e,t){if(e>Ei.MAX_OVERLAY_FEE_RATE_NUMERATOR)throw new Error(Ei.ERRORS.INVALID_OVERLAY_FEE_RATE);if(t==="0x0"&&e>0)throw new Error(Ei.ERRORS.OVERLAY_FEE_RECEIVER_REQUIRED)}var kx=kV,jx=Q_,Px=xU,ya=cc;const Rx="0x2::sui::SUI",RV="0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI";function mg(e){return Or(e).full_address===Rx}function Nx(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=>mg(l)?l:Or(l).source_address),u.source_address=Nx(u.full_address,u.type_arguments),u}const s=r.split("::"),a={full_address:r,address:r===Rx||r===RV?"0x2":Jn(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=Nx(a.full_address,a.type_arguments),a}catch{return{full_address:e,address:"",module:"",name:"",type_arguments:[],source_address:e}}}function NV(e){return e.startsWith("0x")?`${e.slice(2)}`:e}const Bs=(e,t=!0)=>{const r=e.split("::"),n=r.shift();let i=Jn(n);return t&&(i=NV(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=ma(this.defaults,r);const{transitional:n,paramsSerializer:i,headers:s}=r;n!==void 0&&Ff.assertOptions(n,{silentJSONParsing:Zi.transitional(Zi.boolean),forcedJSONParsing:Zi.transitional(Zi.boolean),clarifyTimeoutError:Zi.transitional(Zi.boolean)},!1),i!=null&&(Ae.isFunction(i)?r.paramsSerializer={serialize:i}:Ff.assertOptions(i,{encode:Zi.function,serialize:Zi.function},!0)),r.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?r.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:r.allowAbsoluteUrls=!0),Ff.assertOptions(r,{baseUrl:Zi.spelling("baseURL"),withXsrfToken:Zi.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=Si.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=[n_.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=n_.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=ma(this.defaults,t);const r=K3(t.baseURL,t.url,t.allowAbsoluteUrls);return B3(r,t.params,t.paramsSerializer)}}Ae.forEach(["delete","get","head","options"],function(t){Vf.prototype[t]=function(r,n){return this.request(ma(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(ma(a||{},{method:t,headers:n?{"Content-Type":"multipart/form-data"}:{},url:s,data:o}))}}Vf.prototype[t]=r(),Vf.prototype[t+"Form"]=r(!0)});var zf=Vf;class km{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 tc(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 km(function(i){t=i}),cancel:t}}}var xB=km;function SB(e){return function(r){return e.apply(null,r)}}function EB(e){return Ae.isObject(e)&&e.isAxiosError===!0}const jm={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(jm).forEach(([e,t])=>{jm[t]=e});var TB=jm;function o_(e){const t=new zf(e),r=E3(zf.prototype.request,t);return Ae.extend(r,zf.prototype,t,{allOwnKeys:!0}),Ae.extend(r,t,null,{allOwnKeys:!0}),r.create=function(i){return o_(ma(e,i))},r}const Mr=o_(Tm);Mr.Axios=zf,Mr.CanceledError=tc,Mr.CancelToken=xB,Mr.isCancel=W3,Mr.VERSION=i_,Mr.toFormData=Rf,Mr.AxiosError=jt,Mr.Cancel=Mr.CanceledError,Mr.all=function(t){return Promise.all(t)},Mr.spread=SB,Mr.isAxiosError=EB,Mr.mergeConfig=ma,Mr.AxiosHeaders=Si,Mr.formToJSON=e=>V3(Ae.isHTMLForm(e)?new FormData(e):e),Mr.getAdapter=r_.getAdapter,Mr.HttpStatusCode=TB,Mr.default=Mr;var a_=Mr,Pm={exports:{}},Fn={},c_={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})(c_);var CB=c_.exports,Rm={exports:{}},Nm={exports:{}},u_;function l_(){return u_||(u_=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}(Nm)),Nm.exports}var $m={exports:{}},Dm={exports:{}},f_;function d_(){return f_||(f_=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}(Dm)),Dm.exports}var h_;function p_(){return h_||(h_=1,function(e){var t=d_();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}($m)),$m.exports}var Lm={exports:{}},Bm={exports:{}},Um={exports:{}},m_;function g_(){return m_||(m_=1,function(e){var t=l_(),r=d_();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}(Um)),Um.exports}var y_;function v_(){return y_||(y_=1,function(e){var t=p_(),r=g_();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}(Bm)),Bm.exports}var b_;function AB(){return b_||(b_=1,function(e){var t=v_();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}(Lm)),Lm.exports}var Fm={exports:{}},w_;function MB(){return w_||(w_=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}(Fm)),Fm.exports}var Vm={exports:{}},zm={exports:{}},__;function Wf(){return __||(__=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}(zm)),zm.exports}var x_;function OB(){return x_||(x_=1,function(e){var t=Wf().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}(Vm)),Vm.exports}var S_;function IB(){return S_||(S_=1,function(e){var t=l_(),r=p_(),n=AB(),i=v_(),s=g_(),o=MB(),a=OB();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}(Rm)),Rm.exports}var Wm,E_;function kB(){if(E_)return Wm;E_=1;var e=IB()();Wm=e;try{regeneratorRuntime=e}catch{typeof globalThis=="object"?globalThis.regeneratorRuntime=e:Function("r","regeneratorRuntime = r")(e)}return Wm}var qm={exports:{}},T_;function jB(){return T_||(T_=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}(qm)),qm.exports}var Hm={exports:{}},Gm={exports:{}},Km={exports:{}},C_;function PB(){return C_||(C_=1,function(e){var t=Wf().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}(Km)),Km.exports}var A_;function RB(){return A_||(A_=1,function(e){var t=Wf().default,r=PB();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}(Gm)),Gm.exports}var M_;function NB(){return M_||(M_=1,function(e){var t=RB();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}(Hm)),Hm.exports}var Ym,O_;function $B(){if(O_)return Ym;O_=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 Ym=t=>!e.has(t&&t.code),Ym}var Lu=CB;Object.defineProperty(Fn,"__esModule",{value:!0}),Fn.isNetworkError=Zm,Fn.isRetryableError=Hf,Fn.isSafeRequestError=P_,Fn.isIdempotentRequestError=Qm,Fn.isNetworkOrIdempotentRequestError=eg,Fn.exponentialDelay=R_,Fn.default=ga,Fn.DEFAULT_OPTIONS=Fn.namespace=void 0;var qf=Lu(kB()),DB=Lu(Wf()),I_=Lu(jB()),LB=Lu(NB()),BB=Lu($B());function k_(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 Xm(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?k_(Object(r),!0).forEach(function(n){(0,LB.default)(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):k_(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}var Jm="axios-retry";Fn.namespace=Jm;function Zm(e){var t=["ERR_CANCELED","ECONNABORTED"];return!e.response&&!!e.code&&!t.includes(e.code)&&(0,BB.default)(e)}var j_=["get","head","options"],UB=j_.concat(["put","delete"]);function Hf(e){return e.code!=="ECONNABORTED"&&(!e.response||e.response.status>=500&&e.response.status<=599)}function P_(e){return e.config?Hf(e)&&j_.indexOf(e.config.method)!==-1:!1}function Qm(e){return e.config?Hf(e)&&UB.indexOf(e.config.method)!==-1:!1}function eg(e){return Zm(e)||Qm(e)}function FB(){return 0}function R_(){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 N_={retries:3,retryCondition:eg,retryDelay:FB,shouldResetTimeout:!1,onRetry:function(){}};Fn.DEFAULT_OPTIONS=N_;function VB(e,t){return Xm(Xm(Xm({},N_),t),e[Jm])}function $_(e,t){var r=VB(e,t);return r.retryCount=r.retryCount||0,e[Jm]=r,r}function zB(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 WB(e,t){return tg.apply(this,arguments)}function tg(){return tg=(0,I_.default)(qf.default.mark(function e(t,r){var n,i,s,o;return qf.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,DB.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]])})),tg.apply(this,arguments)}function ga(e,t){var r=e.interceptors.request.use(function(i){var s=$_(i,t);return s.lastRequestTime=Date.now(),i}),n=e.interceptors.response.use(null,function(){var i=(0,I_.default)(qf.default.mark(function s(o){var a,c,u,l,f,h,v,b;return qf.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=$_(a,t),S.next=6,WB(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),zB(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}}ga.isNetworkError=Zm,ga.isSafeRequestError=P_,ga.isIdempotentRequestError=Qm,ga.isNetworkOrIdempotentRequestError=eg,ga.exponentialDelay=R_,ga.isRetryableError=Hf;const D_=Fn.default;Pm.exports=D_,Pm.exports.default=D_;var qB=Pm.exports,Gf={},rc=null;typeof WebSocket<"u"?rc=WebSocket:typeof MozWebSocket<"u"?rc=MozWebSocket:typeof qr<"u"?rc=qr.WebSocket||qr.MozWebSocket:typeof window<"u"?rc=window.WebSocket||window.MozWebSocket:typeof self<"u"&&(rc=self.WebSocket||self.MozWebSocket);var HB=rc,GB=qr&&qr.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Gf,"__esModule",{value:!0}),Gf.ResilientWebSocket=void 0;const KB=GB(HB),YB=3e4+3e3;class XB{constructor(t,r){Nt(this,"endpoint");Nt(this,"wsClient");Nt(this,"wsUserClosed");Nt(this,"wsFailedAttempts");Nt(this,"pingTimeout");Nt(this,"logger");Nt(this,"onError");Nt(this,"onMessage");Nt(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 KB.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=JB(this.wsFailedAttempts);(r=this.logger)==null||r.error(`Connection closed unexpectedly or because of timeout. Reconnecting after ${i}ms.`),await L_(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()},YB)}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 L_(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}}Gf.ResilientWebSocket=XB;async function L_(e){return new Promise(t=>setTimeout(t,e))}function JB(e){return 2**e*100}var nc={};Object.defineProperty(nc,"__esModule",{value:!0}),nc.removeLeading0xIfExists=nc.makeWebsocketUrl=void 0;function ZB(e){const t=new URL("ws",e),r=t.protocol==="https:";return t.protocol=r?"wss:":"ws:",t.toString()}nc.makeWebsocketUrl=ZB;function QB(e){return e.startsWith("0x")?e.substring(2):e}nc.removeLeading0xIfExists=QB;var B_=qr&&qr.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Cf,"__esModule",{value:!0}),Cf.PriceServiceConnection=void 0;const rg=lm,eU=B_(a_),U_=B_(qB),tU=Gf,ng=nc;class rU{constructor(t,r){Nt(this,"httpClient");Nt(this,"priceFeedCallbacks");Nt(this,"wsClient");Nt(this,"wsEndpoint");Nt(this,"logger");Nt(this,"priceFeedRequestConfig");Nt(this,"onWsError");var n,i,s;this.httpClient=eU.default.create({baseURL:t,timeout:(r==null?void 0:r.timeout)||5e3}),(0,U_.default)(this.httpClient,{retries:(r==null?void 0:r.httpRetries)||3,retryDelay:U_.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 En<"u"&&typeof En.exit=="function"?(this.logger.error("Halting the process due to the websocket error"),En.exit(1)):this.logger.error("Cannot halt process. Please handle the websocket error.")},this.wsEndpoint=(0,ng.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=>rg.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 rg.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,ng.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,ng.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 tU.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=rg.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()}}Cf.PriceServiceConnection=rU,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.parseAccumulatorUpdateData=e.isAccumulatorUpdateData=e.Price=e.PriceFeed=e.PriceFeedMetadata=e.PriceServiceConnection=void 0;var t=Cf;Object.defineProperty(e,"PriceServiceConnection",{enumerable:!0,get:function(){return t.PriceServiceConnection}});var r=lm;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}})}(um),Object.defineProperty(Tf,"__esModule",{value:!0}),Tf.SuiPriceServiceConnection=void 0;const nU=um,iU=Mf();class sU extends nU.PriceServiceConnection{async getPriceFeedsUpdateData(t){return(await this.getLatestVaas(t)).map(n=>iU.Buffer.from(n,"base64"))}}Tf.SuiPriceServiceConnection=sU;var Kf={};Object.defineProperty(Kf,"__esModule",{value:!0}),Kf.SuiPythClient=void 0;const Yf=T8,ic=li,oU=Mf(),ig=16*1024;class aU{constructor(t,r,n){Nt(this,"provider");Nt(this,"pythStateId");Nt(this,"wormholeStateId");Nt(this,"pythPackageId");Nt(this,"wormholePackageId");Nt(this,"priceTableInfo");Nt(this,"priceFeedObjectIdCache",new Map);Nt(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(ic.bcs.vector(ic.bcs.U8).serialize(Array.from(s),{maxSize:ig}).toBytes()),r.object(Yf.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(ic.bcs.vector(ic.bcs.U8).serialize(Array.from(r[0]),{maxSize:ig}).toBytes()),s[0],t.object(Yf.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(Yf.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(ic.bcs.vector(ic.bcs.U8).serialize(Array.from(r[0]),{maxSize:ig}).toBytes()),s[0],t.object(Yf.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(oU.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)}}Kf.SuiPythClient=aU,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.PriceFeed=e.Price=e.SuiPythClient=e.SuiPriceServiceConnection=void 0;var t=Tf;Object.defineProperty(e,"SuiPriceServiceConnection",{enumerable:!0,get:function(){return t.SuiPriceServiceConnection}});var r=Kf;Object.defineProperty(e,"SuiPythClient",{enumerable:!0,get:function(){return r.SuiPythClient}});var n=um;Object.defineProperty(e,"Price",{enumerable:!0,get:function(){return n.Price}}),Object.defineProperty(e,"PriceFeed",{enumerable:!0,get:function(){return n.PriceFeed}})}(w3);var sg=Yn,cU=vN,ur=T8,F_=RD,V_=w3;function uU(e){return e&&e.__esModule?e:{default:e}}var lU=uU(cU),fU=Object.create,og=Object.defineProperty,dU=Object.defineProperties,hU=Object.getOwnPropertyDescriptor,pU=Object.getOwnPropertyDescriptors,z_=Object.getOwnPropertyNames,W_=Object.getOwnPropertySymbols,mU=Object.getPrototypeOf,q_=Object.prototype.hasOwnProperty,gU=Object.prototype.propertyIsEnumerable,H_=(e,t,r)=>t in e?og(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,yU=(e,t)=>{for(var r in t||(t={}))q_.call(t,r)&&H_(e,r,t[r]);if(W_)for(var r of W_(t))gU.call(t,r)&&H_(e,r,t[r]);return e},vU=(e,t)=>dU(e,pU(t)),bU=(e=>typeof $i<"u"?$i:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof $i<"u"?$i:t)[r]}):e)(function(e){if(typeof $i<"u")return $i.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')}),wU=(e,t)=>function(){return t||(0,e[z_(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 z_(t))!q_.call(e,i)&&i!==r&&og(e,i,{get:()=>t[i],enumerable:!(n=hU(t,i))||n.enumerable});return e},sc=(e,t,r)=>(r=e!=null?fU(mU(e)):{},_U(!e||!e.__esModule?og(r,"default",{value:e,enumerable:!0}):r,e)),yn=(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())}),oc=wU({"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=bU("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,R=x;R<g;R+=E)w=l(d,R,R+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,R,d.length,m),R=0;R<k;R++)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],R=y[d];x="";var ue=this.clone();for(ue.negative=0;!ue.isZero();){var ie=ue.modrn(R).toString(d);ue=ue.idivn(R),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 R=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,R+=j/67108864|0,ue=j&67108863}m.words[w]=ue|0,g=R|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,R,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,pe=Z>>>13,Y=E[4]|0,X=Y&8191,B=Y>>>13,se=E[5]|0,ge=se&8191,de=se>>>13,Se=E[6]|0,Ie=Se&8191,Fe=Se>>>13,Je=E[7]|0,$e=Je&8191,Ge=Je>>>13,nt=E[8]|0,et=nt&8191,Ot=nt>>>13,Dt=E[9]|0,Ke=Dt&8191,pt=Dt>>>13,lt=A[0]|0,tt=lt&8191,ot=lt>>>13,vt=A[1]|0,st=vt&8191,bt=vt>>>13,Lt=A[2]|0,yt=Lt&8191,It=Lt>>>13,Vt=A[3]|0,Xe=Vt&8191,Rt=Vt>>>13,zt=A[4]|0,$=zt&8191,T=zt>>>13,M=A[5]|0,K=M&8191,ae=M>>>13,be=A[6]|0,_e=be&8191,it=be>>>13,St=A[7]|0,rt=St&8191,Q=St>>>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,R=Math.imul(fe,ot);var Mt=(k+g|0)+((w&8191)<<13)|0;k=(R+(w>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,g=Math.imul(Ce,tt),w=Math.imul(Ce,ot),w=w+Math.imul(N,tt)|0,R=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,R=R+Math.imul(fe,bt)|0;var fr=(k+g|0)+((w&8191)<<13)|0;k=(R+(w>>>13)|0)+(fr>>>26)|0,fr&=67108863,g=Math.imul(G,tt),w=Math.imul(G,ot),w=w+Math.imul(ee,tt)|0,R=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,R=R+Math.imul(N,bt)|0,g=g+Math.imul(ie,yt)|0,w=w+Math.imul(ie,It)|0,w=w+Math.imul(fe,yt)|0,R=R+Math.imul(fe,It)|0;var Kt=(k+g|0)+((w&8191)<<13)|0;k=(R+(w>>>13)|0)+(Kt>>>26)|0,Kt&=67108863,g=Math.imul(q,tt),w=Math.imul(q,ot),w=w+Math.imul(pe,tt)|0,R=Math.imul(pe,ot),g=g+Math.imul(G,st)|0,w=w+Math.imul(G,bt)|0,w=w+Math.imul(ee,st)|0,R=R+Math.imul(ee,bt)|0,g=g+Math.imul(Ce,yt)|0,w=w+Math.imul(Ce,It)|0,w=w+Math.imul(N,yt)|0,R=R+Math.imul(N,It)|0,g=g+Math.imul(ie,Xe)|0,w=w+Math.imul(ie,Rt)|0,w=w+Math.imul(fe,Xe)|0,R=R+Math.imul(fe,Rt)|0;var Yt=(k+g|0)+((w&8191)<<13)|0;k=(R+(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,R=Math.imul(B,ot),g=g+Math.imul(q,st)|0,w=w+Math.imul(q,bt)|0,w=w+Math.imul(pe,st)|0,R=R+Math.imul(pe,bt)|0,g=g+Math.imul(G,yt)|0,w=w+Math.imul(G,It)|0,w=w+Math.imul(ee,yt)|0,R=R+Math.imul(ee,It)|0,g=g+Math.imul(Ce,Xe)|0,w=w+Math.imul(Ce,Rt)|0,w=w+Math.imul(N,Xe)|0,R=R+Math.imul(N,Rt)|0,g=g+Math.imul(ie,$)|0,w=w+Math.imul(ie,T)|0,w=w+Math.imul(fe,$)|0,R=R+Math.imul(fe,T)|0;var _r=(k+g|0)+((w&8191)<<13)|0;k=(R+(w>>>13)|0)+(_r>>>26)|0,_r&=67108863,g=Math.imul(ge,tt),w=Math.imul(ge,ot),w=w+Math.imul(de,tt)|0,R=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,R=R+Math.imul(B,bt)|0,g=g+Math.imul(q,yt)|0,w=w+Math.imul(q,It)|0,w=w+Math.imul(pe,yt)|0,R=R+Math.imul(pe,It)|0,g=g+Math.imul(G,Xe)|0,w=w+Math.imul(G,Rt)|0,w=w+Math.imul(ee,Xe)|0,R=R+Math.imul(ee,Rt)|0,g=g+Math.imul(Ce,$)|0,w=w+Math.imul(Ce,T)|0,w=w+Math.imul(N,$)|0,R=R+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,R=R+Math.imul(fe,ae)|0;var rn=(k+g|0)+((w&8191)<<13)|0;k=(R+(w>>>13)|0)+(rn>>>26)|0,rn&=67108863,g=Math.imul(Ie,tt),w=Math.imul(Ie,ot),w=w+Math.imul(Fe,tt)|0,R=Math.imul(Fe,ot),g=g+Math.imul(ge,st)|0,w=w+Math.imul(ge,bt)|0,w=w+Math.imul(de,st)|0,R=R+Math.imul(de,bt)|0,g=g+Math.imul(X,yt)|0,w=w+Math.imul(X,It)|0,w=w+Math.imul(B,yt)|0,R=R+Math.imul(B,It)|0,g=g+Math.imul(q,Xe)|0,w=w+Math.imul(q,Rt)|0,w=w+Math.imul(pe,Xe)|0,R=R+Math.imul(pe,Rt)|0,g=g+Math.imul(G,$)|0,w=w+Math.imul(G,T)|0,w=w+Math.imul(ee,$)|0,R=R+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,R=R+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,R=R+Math.imul(fe,it)|0;var Tr=(k+g|0)+((w&8191)<<13)|0;k=(R+(w>>>13)|0)+(Tr>>>26)|0,Tr&=67108863,g=Math.imul($e,tt),w=Math.imul($e,ot),w=w+Math.imul(Ge,tt)|0,R=Math.imul(Ge,ot),g=g+Math.imul(Ie,st)|0,w=w+Math.imul(Ie,bt)|0,w=w+Math.imul(Fe,st)|0,R=R+Math.imul(Fe,bt)|0,g=g+Math.imul(ge,yt)|0,w=w+Math.imul(ge,It)|0,w=w+Math.imul(de,yt)|0,R=R+Math.imul(de,It)|0,g=g+Math.imul(X,Xe)|0,w=w+Math.imul(X,Rt)|0,w=w+Math.imul(B,Xe)|0,R=R+Math.imul(B,Rt)|0,g=g+Math.imul(q,$)|0,w=w+Math.imul(q,T)|0,w=w+Math.imul(pe,$)|0,R=R+Math.imul(pe,T)|0,g=g+Math.imul(G,K)|0,w=w+Math.imul(G,ae)|0,w=w+Math.imul(ee,K)|0,R=R+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,R=R+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,R=R+Math.imul(fe,Q)|0;var dr=(k+g|0)+((w&8191)<<13)|0;k=(R+(w>>>13)|0)+(dr>>>26)|0,dr&=67108863,g=Math.imul(et,tt),w=Math.imul(et,ot),w=w+Math.imul(Ot,tt)|0,R=Math.imul(Ot,ot),g=g+Math.imul($e,st)|0,w=w+Math.imul($e,bt)|0,w=w+Math.imul(Ge,st)|0,R=R+Math.imul(Ge,bt)|0,g=g+Math.imul(Ie,yt)|0,w=w+Math.imul(Ie,It)|0,w=w+Math.imul(Fe,yt)|0,R=R+Math.imul(Fe,It)|0,g=g+Math.imul(ge,Xe)|0,w=w+Math.imul(ge,Rt)|0,w=w+Math.imul(de,Xe)|0,R=R+Math.imul(de,Rt)|0,g=g+Math.imul(X,$)|0,w=w+Math.imul(X,T)|0,w=w+Math.imul(B,$)|0,R=R+Math.imul(B,T)|0,g=g+Math.imul(q,K)|0,w=w+Math.imul(q,ae)|0,w=w+Math.imul(pe,K)|0,R=R+Math.imul(pe,ae)|0,g=g+Math.imul(G,_e)|0,w=w+Math.imul(G,it)|0,w=w+Math.imul(ee,_e)|0,R=R+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,R=R+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,R=R+Math.imul(fe,Ze)|0;var Gr=(k+g|0)+((w&8191)<<13)|0;k=(R+(w>>>13)|0)+(Gr>>>26)|0,Gr&=67108863,g=Math.imul(Ke,tt),w=Math.imul(Ke,ot),w=w+Math.imul(pt,tt)|0,R=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,R=R+Math.imul(Ot,bt)|0,g=g+Math.imul($e,yt)|0,w=w+Math.imul($e,It)|0,w=w+Math.imul(Ge,yt)|0,R=R+Math.imul(Ge,It)|0,g=g+Math.imul(Ie,Xe)|0,w=w+Math.imul(Ie,Rt)|0,w=w+Math.imul(Fe,Xe)|0,R=R+Math.imul(Fe,Rt)|0,g=g+Math.imul(ge,$)|0,w=w+Math.imul(ge,T)|0,w=w+Math.imul(de,$)|0,R=R+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,R=R+Math.imul(B,ae)|0,g=g+Math.imul(q,_e)|0,w=w+Math.imul(q,it)|0,w=w+Math.imul(pe,_e)|0,R=R+Math.imul(pe,it)|0,g=g+Math.imul(G,rt)|0,w=w+Math.imul(G,Q)|0,w=w+Math.imul(ee,rt)|0,R=R+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,R=R+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,R=R+Math.imul(fe,at)|0;var Ii=(k+g|0)+((w&8191)<<13)|0;k=(R+(w>>>13)|0)+(Ii>>>26)|0,Ii&=67108863,g=Math.imul(Ke,st),w=Math.imul(Ke,bt),w=w+Math.imul(pt,st)|0,R=Math.imul(pt,bt),g=g+Math.imul(et,yt)|0,w=w+Math.imul(et,It)|0,w=w+Math.imul(Ot,yt)|0,R=R+Math.imul(Ot,It)|0,g=g+Math.imul($e,Xe)|0,w=w+Math.imul($e,Rt)|0,w=w+Math.imul(Ge,Xe)|0,R=R+Math.imul(Ge,Rt)|0,g=g+Math.imul(Ie,$)|0,w=w+Math.imul(Ie,T)|0,w=w+Math.imul(Fe,$)|0,R=R+Math.imul(Fe,T)|0,g=g+Math.imul(ge,K)|0,w=w+Math.imul(ge,ae)|0,w=w+Math.imul(de,K)|0,R=R+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,R=R+Math.imul(B,it)|0,g=g+Math.imul(q,rt)|0,w=w+Math.imul(q,Q)|0,w=w+Math.imul(pe,rt)|0,R=R+Math.imul(pe,Q)|0,g=g+Math.imul(G,ke)|0,w=w+Math.imul(G,Ze)|0,w=w+Math.imul(ee,ke)|0,R=R+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,R=R+Math.imul(N,at)|0;var Dn=(k+g|0)+((w&8191)<<13)|0;k=(R+(w>>>13)|0)+(Dn>>>26)|0,Dn&=67108863,g=Math.imul(Ke,yt),w=Math.imul(Ke,It),w=w+Math.imul(pt,yt)|0,R=Math.imul(pt,It),g=g+Math.imul(et,Xe)|0,w=w+Math.imul(et,Rt)|0,w=w+Math.imul(Ot,Xe)|0,R=R+Math.imul(Ot,Rt)|0,g=g+Math.imul($e,$)|0,w=w+Math.imul($e,T)|0,w=w+Math.imul(Ge,$)|0,R=R+Math.imul(Ge,T)|0,g=g+Math.imul(Ie,K)|0,w=w+Math.imul(Ie,ae)|0,w=w+Math.imul(Fe,K)|0,R=R+Math.imul(Fe,ae)|0,g=g+Math.imul(ge,_e)|0,w=w+Math.imul(ge,it)|0,w=w+Math.imul(de,_e)|0,R=R+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,R=R+Math.imul(B,Q)|0,g=g+Math.imul(q,ke)|0,w=w+Math.imul(q,Ze)|0,w=w+Math.imul(pe,ke)|0,R=R+Math.imul(pe,Ze)|0,g=g+Math.imul(G,Qe)|0,w=w+Math.imul(G,at)|0,w=w+Math.imul(ee,Qe)|0,R=R+Math.imul(ee,at)|0;var ki=(k+g|0)+((w&8191)<<13)|0;k=(R+(w>>>13)|0)+(ki>>>26)|0,ki&=67108863,g=Math.imul(Ke,Xe),w=Math.imul(Ke,Rt),w=w+Math.imul(pt,Xe)|0,R=Math.imul(pt,Rt),g=g+Math.imul(et,$)|0,w=w+Math.imul(et,T)|0,w=w+Math.imul(Ot,$)|0,R=R+Math.imul(Ot,T)|0,g=g+Math.imul($e,K)|0,w=w+Math.imul($e,ae)|0,w=w+Math.imul(Ge,K)|0,R=R+Math.imul(Ge,ae)|0,g=g+Math.imul(Ie,_e)|0,w=w+Math.imul(Ie,it)|0,w=w+Math.imul(Fe,_e)|0,R=R+Math.imul(Fe,it)|0,g=g+Math.imul(ge,rt)|0,w=w+Math.imul(ge,Q)|0,w=w+Math.imul(de,rt)|0,R=R+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,R=R+Math.imul(B,Ze)|0,g=g+Math.imul(q,Qe)|0,w=w+Math.imul(q,at)|0,w=w+Math.imul(pe,Qe)|0,R=R+Math.imul(pe,at)|0;var Js=(k+g|0)+((w&8191)<<13)|0;k=(R+(w>>>13)|0)+(Js>>>26)|0,Js&=67108863,g=Math.imul(Ke,$),w=Math.imul(Ke,T),w=w+Math.imul(pt,$)|0,R=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,R=R+Math.imul(Ot,ae)|0,g=g+Math.imul($e,_e)|0,w=w+Math.imul($e,it)|0,w=w+Math.imul(Ge,_e)|0,R=R+Math.imul(Ge,it)|0,g=g+Math.imul(Ie,rt)|0,w=w+Math.imul(Ie,Q)|0,w=w+Math.imul(Fe,rt)|0,R=R+Math.imul(Fe,Q)|0,g=g+Math.imul(ge,ke)|0,w=w+Math.imul(ge,Ze)|0,w=w+Math.imul(de,ke)|0,R=R+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,R=R+Math.imul(B,at)|0;var Zs=(k+g|0)+((w&8191)<<13)|0;k=(R+(w>>>13)|0)+(Zs>>>26)|0,Zs&=67108863,g=Math.imul(Ke,K),w=Math.imul(Ke,ae),w=w+Math.imul(pt,K)|0,R=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,R=R+Math.imul(Ot,it)|0,g=g+Math.imul($e,rt)|0,w=w+Math.imul($e,Q)|0,w=w+Math.imul(Ge,rt)|0,R=R+Math.imul(Ge,Q)|0,g=g+Math.imul(Ie,ke)|0,w=w+Math.imul(Ie,Ze)|0,w=w+Math.imul(Fe,ke)|0,R=R+Math.imul(Fe,Ze)|0,g=g+Math.imul(ge,Qe)|0,w=w+Math.imul(ge,at)|0,w=w+Math.imul(de,Qe)|0,R=R+Math.imul(de,at)|0;var ji=(k+g|0)+((w&8191)<<13)|0;k=(R+(w>>>13)|0)+(ji>>>26)|0,ji&=67108863,g=Math.imul(Ke,_e),w=Math.imul(Ke,it),w=w+Math.imul(pt,_e)|0,R=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,R=R+Math.imul(Ot,Q)|0,g=g+Math.imul($e,ke)|0,w=w+Math.imul($e,Ze)|0,w=w+Math.imul(Ge,ke)|0,R=R+Math.imul(Ge,Ze)|0,g=g+Math.imul(Ie,Qe)|0,w=w+Math.imul(Ie,at)|0,w=w+Math.imul(Fe,Qe)|0,R=R+Math.imul(Fe,at)|0;var Qs=(k+g|0)+((w&8191)<<13)|0;k=(R+(w>>>13)|0)+(Qs>>>26)|0,Qs&=67108863,g=Math.imul(Ke,rt),w=Math.imul(Ke,Q),w=w+Math.imul(pt,rt)|0,R=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,R=R+Math.imul(Ot,Ze)|0,g=g+Math.imul($e,Qe)|0,w=w+Math.imul($e,at)|0,w=w+Math.imul(Ge,Qe)|0,R=R+Math.imul(Ge,at)|0;var eo=(k+g|0)+((w&8191)<<13)|0;k=(R+(w>>>13)|0)+(eo>>>26)|0,eo&=67108863,g=Math.imul(Ke,ke),w=Math.imul(Ke,Ze),w=w+Math.imul(pt,ke)|0,R=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,R=R+Math.imul(Ot,at)|0;var W=(k+g|0)+((w&8191)<<13)|0;k=(R+(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,R=Math.imul(pt,at);var oe=(k+g|0)+((w&8191)<<13)|0;return k=(R+(w>>>13)|0)+(oe>>>26)|0,oe&=67108863,j[0]=Mt,j[1]=fr,j[2]=Kt,j[3]=Yt,j[4]=_r,j[5]=rn,j[6]=Tr,j[7]=dr,j[8]=Gr,j[9]=Ii,j[10]=Dn,j[11]=ki,j[12]=Js,j[13]=Zs,j[14]=ji,j[15]=Qs,j[16]=eo,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 R=A-w,ue=p.words[R]|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 R=0;for(w=this.length-1;w>=0&&(R!==0||w>=E);w--){var ue=this.words[w]|0;this.words[w]=R<<26-A|ue>>>A,R=ue&k}return g&&R!==0&&(g.words[g.length++]=R),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 R=0;R<w.length;R++)w.words[R]=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(),R=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(R)),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(R)),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,R=1;!(x.words[0]&R)&&w<26;++w,R<<=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 R=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(R,new o(1).iushln(fe-Ce-1));ue=ue.redMul(N),R=N.redSqr(),ie=ie.redMul(R),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 R=m.words[A],ue=w-1;ue>=0;ue--){var ie=R>>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)}}),yr=sc(oc()),ac=sc(oc());function ag(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 G_(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 xU(e){return e.split("::")[0]}function cc(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=cc(r),u=vU(yU({},c),{type_arguments:i.map(l=>cc(l).source_address)});return u.type_arguments=u.type_arguments.map(l=>X_.isSuiCoin(l)?l:cc(l).source_address),u.source_address=G_(u.full_address,u.type_arguments),u}const s=r.split("::"),a={full_address:r,address:r===Y_||r===TU?"0x2":ur.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=G_(a.full_address,a.type_arguments),a}catch{return{full_address:e,address:"",module:"",name:"",type_arguments:[],source_address:e}}}function K_(e){return cc(e).source_address}var SU="0x2::coin::Coin",EU=/^0x2::coin::Coin<(.+)>$/,Y_="0x2::sui::SUI",TU="0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI",X_=class Uo{static getCoinTypeArg(t){const r=t.type.match(EU);return r?r[1]:null}static isSUI(t){const r=Uo.getCoinTypeArg(t);return r?Uo.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`${SU}<${t}>`}static getCoinAssets(t,r){const n=[];return r.forEach(i=>{K_(i.coinAddress)===K_(t)&&n.push(i)}),n}static isSuiCoin(t){return cc(t).full_address===Y_}static selectCoinObjectIdGreaterThanOrEqual(t,r,n=[]){const i=Uo.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=Uo.sortByBalance(t.filter(u=>!n.includes(u.coinObjectId))),s=Uo.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:Uo.sortByBalance(a),remainingCoins:Uo.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 _o(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 CU(e,t){e=_o(e),t=_o(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 Bu=sc(oc()),uc=new Bu.default(0);new Bu.default(1);var AU=new Bu.default(2);AU.pow(new Bu.default(128)),new Bu.default("18446744073709551615");var cg="18446744073709551615",MU="0xd7b0cfc33a3b46c0ae0e2584c44028385da11724d4c94ec5b21a78117c5c1ab9",Xf={AGGREGATOR_V3:"aggregator_v3"},Jf={Mainnet:"0xdeeb7a4662eec9f2f3def03fb937a663dddaa2e215b8078a284d026b7946c270::deep::DEEP",Testnet:"0x36dbef866a1d62bf7328989a10fb2f07d769f4ee587c0de4a0a256e57e0a58a8::deep::DEEP"},Ei={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"}},Gt={FEE_DENOMINATOR:1e6,MAX_FEE_RATE:1e5,MAX_AMOUNT_IN:cg,DEFAULT_PUBLISHED_AT:{Mainnet:"0x33ec64e9bb369bf045ddc198c81adbf2acab424da37465d95296ee02045d2b17",Testnet:"0x0"}},J_=1010200;function OU(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 ac.default(e.amount_in.toString()),amountOut:new ac.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 IU(e,t,r,n,i){return yn(this,null,function*(){let s;if(r.liquidityChanges&&r.liquidityChanges.length>0?s=yield jU(e,r):s=yield kU(e,t,r),!s)return null;if(!s.ok){let c=1e3;return s.status===429&&(c=1001),{quoteID:"",amountIn:uc,amountOut:uc,paths:[],byAmountIn:r.byAmountIn,insufficientLiquidity:!1,deviationRatio:0,error:{code:c,msg:ag(c)}}}const o=lU.default.parse(yield s.text()),a=o.msg==="liquidity is not enough";if(o.msg&&o.msg.indexOf("HoneyPot scam")>-1)return{quoteID:"",amountIn:uc,amountOut:uc,paths:[],byAmountIn:r.byAmountIn,insufficientLiquidity:a,deviationRatio:0,error:{code:1003,msg:ag(1003)}};if(o.data!=null){const c=OU(o.data,r.byAmountIn);if(n>0&&i!=="0x0")if(r.byAmountIn){const u=c.amountOut.mul(new ac.default(n)).div(new ac.default(1e6));c.overlayFee=Number(u.toString()),c.amountOut=c.amountOut.sub(u)}else{const u=c.amountIn.mul(new ac.default(n)).div(new ac.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:uc,amountOut:uc,paths:[],insufficientLiquidity:a,byAmountIn:r.byAmountIn,deviationRatio:0,error:{code:1002,msg:ag(1002)}}})}function kU(e,t,r){return yn(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=_o(n),v=_o(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=${J_}`,yield fetch(b)}catch(n){return console.error(n),null}})}function jU(e,t){return yn(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=_o(r),v=_o(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:J_};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 PU(e){return yn(this,null,function*(){const t=`${e}/deepbookv3_config`;try{return(yield fetch(t)).json()}catch(r){return console.error("Error:",r),null}})}function Z_(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 Q_=(e=>(e[e.Mainnet=0]="Mainnet",e[e.Testnet=1]="Testnet",e))(Q_||{}),RU=sc(oc()),lc=9e15,xo=1e9,ug="0123456789abcdef",Zf="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",Qf="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",lg={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-lc,maxE:lc,crypto:!1},ex,Ls,Ct=!0,ed="[DecimalError] ",So=ed+"Invalid argument: ",tx=ed+"Precision limit exceeded",rx=ed+"crypto unavailable",nx="[object Decimal]",ln=Math.floor,Vr=Math.pow,NU=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,$U=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,DU=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,ix=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,Ti=1e7,wt=7,LU=9007199254740991,BU=Zf.length-1,fg=Qf.length-1,Re={toStringTag:nx};Re.absoluteValue=Re.abs=function(){var e=new this.constructor(this);return e.s<0&&(e.s=1),dt(e)},Re.ceil=function(){return dt(new this.constructor(this),this.e+1,2)},Re.clampedTo=Re.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(So+t);return r=n.cmp(e),r<0?e:n.cmp(t)>0?t:new i(n)},Re.comparedTo=Re.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},Re.cosine=Re.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=UU(n,lx(n,r)),n.precision=e,n.rounding=t,dt(Ls==2||Ls==3?r.neg():r,e,t,!0)):new n(1):new n(NaN)},Re.cubeRoot=Re.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(Ct=!1,s=l.s*Vr(l.s*l,1/3),!s||Math.abs(s)==1/0?(r=Yr(l.d),e=l.e,(s=(e-r.length+1)%3)&&(r+=s==1||s==-2?"0":"00"),s=Vr(r,1/3),e=ln((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=er(u.plus(l).times(a),u.plus(c),o+2,1),Yr(a.d).slice(0,o)===(r=Yr(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 Ct=!0,dt(n,e,f.rounding,t)},Re.decimalPlaces=Re.dp=function(){var e,t=this.d,r=NaN;if(t){if(e=t.length-1,r=(e-ln(this.e/wt))*wt,e=t[e],e)for(;e%10==0;e/=10)r--;r<0&&(r=0)}return r},Re.dividedBy=Re.div=function(e){return er(this,new this.constructor(e))},Re.dividedToIntegerBy=Re.divToInt=function(e){var t=this,r=t.constructor;return dt(er(t,new r(e),0,1,1),r.precision,r.rounding)},Re.equals=Re.eq=function(e){return this.cmp(e)===0},Re.floor=function(){return dt(new this.constructor(this),this.e+1,3)},Re.greaterThan=Re.gt=function(e){return this.cmp(e)>0},Re.greaterThanOrEqualTo=Re.gte=function(e){var t=this.cmp(e);return t==1||t===0},Re.hyperbolicCosine=Re.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/sd(4,e)).toString()):(e=16,t="2.3283064365386962890625e-10"),s=fc(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)},Re.hyperbolicSine=Re.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=fc(s,2,i,i,!0);else{e=1.4*Math.sqrt(n),e=e>16?16:e|0,i=i.times(1/sd(5,e)),i=fc(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)},Re.hyperbolicTangent=Re.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,er(r.sinh(),r.cosh(),n.precision=e,n.rounding=t)):new n(r.s)},Re.inverseCosine=Re.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()?es(t,n,i):new t(0):new t(NaN):e.isZero()?es(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))},Re.inverseHyperbolicCosine=Re.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,Ct=!1,r=r.times(r).minus(1).sqrt().plus(r),Ct=!0,n.precision=e,n.rounding=t,r.ln()):new n(r)},Re.inverseHyperbolicSine=Re.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,Ct=!1,r=r.times(r).plus(1).sqrt().plus(r),Ct=!0,n.precision=e,n.rounding=t,r.ln())},Re.inverseHyperbolicTangent=Re.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=er(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)},Re.inverseSine=Re.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=es(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)))},Re.inverseTangent=Re.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<=fg)return o=es(l,f+4,h).times(.25),o.s=u.s,o}else{if(!u.s)return new l(NaN);if(f+4<=fg)return o=es(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(Ct=!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)),Ct=!0,dt(o,l.precision=f,l.rounding=h,!0)},Re.isFinite=function(){return!!this.d},Re.isInteger=Re.isInt=function(){return!!this.d&&ln(this.e/wt)>this.d.length-2},Re.isNaN=function(){return!this.s},Re.isNegative=Re.isNeg=function(){return this.s<0},Re.isPositive=Re.isPos=function(){return this.s>0},Re.isZero=function(){return!!this.d&&this.d[0]===0},Re.lessThan=Re.lt=function(e){return this.cmp(e)<0},Re.lessThanOrEqualTo=Re.lte=function(e){return this.cmp(e)<1},Re.logarithm=Re.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(Ct=!1,a=f+v,o=To(u,a),n=t?nd(l,a+10):To(e,a),c=er(o,n,a,1),Uu(c.d,i=f,h))do if(a+=10,o=To(u,a),n=t?nd(l,a+10):To(e,a),c=er(o,n,a,1),!s){+Yr(c.d).slice(i+1,i+15)+1==1e14&&(c=dt(c,f+1,0));break}while(Uu(c.d,i+=10,h));return Ct=!0,dt(c,f,h)},Re.minus=Re.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 Ct?dt(e,a,c):e}if(r=ln(e.e/wt),l=ln(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=rd(u,r),Ct?dt(e,a,c):e):new b(c===3?-0:0)},Re.modulo=Re.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):(Ct=!1,n.modulo==9?(t=er(r,e.abs(),0,3,1),t.s*=e.s):t=er(r,e,0,n.modulo,1),t=t.times(e),Ct=!0,r.minus(t))},Re.naturalExponential=Re.exp=function(){return dg(this)},Re.naturalLogarithm=Re.ln=function(){return To(this)},Re.negated=Re.neg=function(){var e=new this.constructor(this);return e.s=-e.s,dt(e)},Re.plus=Re.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)),Ct?dt(e,a,c):e;if(s=ln(f.e/wt),n=ln(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=rd(u,n),Ct?dt(e,a,c):e},Re.precision=Re.sd=function(e){var t,r=this;if(e!==void 0&&e!==!!e&&e!==1&&e!==0)throw Error(So+e);return r.d?(t=sx(r.d),e&&r.e+1>t&&(t=r.e+1)):t=NaN,t},Re.round=function(){var e=this,t=e.constructor;return dt(new t(e),e.e+1,t.rounding)},Re.sine=Re.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=VU(n,lx(n,r)),n.precision=e,n.rounding=t,dt(Ls>2?r.neg():r,e,t,!0)):new n(NaN)},Re.squareRoot=Re.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(Ct=!1,u=Math.sqrt(+o),u==0||u==1/0?(t=Yr(a),(t.length+c)%2==0&&(t+="0"),u=Math.sqrt(t),c=ln((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(er(o,s,r+2,1)).times(.5),Yr(s.d).slice(0,r)===(t=Yr(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 Ct=!0,dt(n,c,l.rounding,e)},Re.tangent=Re.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=er(r,new n(1).minus(r.times(r)).sqrt(),e+10,0),n.precision=e,n.rounding=t,dt(Ls==2||Ls==4?r.neg():r,e,t,!0)):new n(NaN)},Re.times=Re.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=ln(l.e/wt)+ln(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=rd(s,r),Ct?dt(e,f.precision,f.rounding):e},Re.toBinary=function(e,t){return hg(this,2,e,t)},Re.toDecimalPlaces=Re.toDP=function(e,t){var r=this,n=r.constructor;return r=new n(r),e===void 0?r:(jn(e,0,xo),t===void 0?t=n.rounding:jn(t,0,8),dt(r,e+r.e+1,t))},Re.toExponential=function(e,t){var r,n=this,i=n.constructor;return e===void 0?r=Qi(n,!0):(jn(e,0,xo),t===void 0?t=i.rounding:jn(t,0,8),n=dt(new i(n),e+1,t),r=Qi(n,!0,e+1)),n.isNeg()&&!n.isZero()?"-"+r:r},Re.toFixed=function(e,t){var r,n,i=this,s=i.constructor;return e===void 0?r=Qi(i):(jn(e,0,xo),t===void 0?t=s.rounding:jn(t,0,8),n=dt(new s(i),e+i.e+1,t),r=Qi(n,!1,e+n.e+1)),i.isNeg()&&!i.isZero()?"-"+r:r},Re.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=sx(b)-v.e-1,o=s%wt,t.d[0]=Vr(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(So+a);e=a.gt(t)?s>0?t:u:a}for(Ct=!1,a=new y(Yr(b)),l=y.precision,y.precision=s=b.length*wt*2;f=er(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=er(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=er(u,n,s,1).minus(v).abs().cmp(er(c,r,s,1).minus(v).abs())<1?[u,n]:[c,r],y.precision=l,Ct=!0,h},Re.toHexadecimal=Re.toHex=function(e,t){return hg(this,16,e,t)},Re.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:jn(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]?(Ct=!1,r=er(r,e,0,t,1).times(e),Ct=!0,dt(r)):(e.s=r.s,r=e),r},Re.toNumber=function(){return+this},Re.toOctal=function(e,t){return hg(this,8,e,t)},Re.toPower=Re.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(Vr(+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=ln(e.e/wt),t>=e.d.length-1&&(r=u<0?-u:u)<=LU)return i=ox(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=Vr(+a,u),t=r==0||!isFinite(r)?ln(u*(Math.log("0."+Yr(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):(Ct=!1,c.rounding=a.s=1,r=Math.min(12,(t+"").length),i=dg(e.times(To(a,n+r)),n),i.d&&(i=dt(i,n+5,1),Uu(i.d,n,s)&&(t=n+10,i=dt(dg(e.times(To(a,t+r)),t),t+5,1),+Yr(i.d).slice(n+1,n+15)+1==1e14&&(i=dt(i,n+1,0)))),i.s=o,Ct=!0,c.rounding=s,dt(i,n,s))},Re.toPrecision=function(e,t){var r,n=this,i=n.constructor;return e===void 0?r=Qi(n,n.e<=i.toExpNeg||n.e>=i.toExpPos):(jn(e,1,xo),t===void 0?t=i.rounding:jn(t,0,8),n=dt(new i(n),e,t),r=Qi(n,e<=n.e||n.e<=i.toExpNeg,e)),n.isNeg()&&!n.isZero()?"-"+r:r},Re.toSignificantDigits=Re.toSD=function(e,t){var r=this,n=r.constructor;return e===void 0?(e=n.precision,t=n.rounding):(jn(e,1,xo),t===void 0?t=n.rounding:jn(t,0,8)),dt(new n(r),e,t)},Re.toString=function(){var e=this,t=e.constructor,r=Qi(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()&&!e.isZero()?"-"+r:r},Re.truncated=Re.trunc=function(){return dt(new this.constructor(this),this.e+1,1)},Re.valueOf=Re.toJSON=function(){var e=this,t=e.constructor,r=Qi(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()?"-"+r:r};function Yr(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+=Eo(r)),s+=n;o=e[t],n=o+"",r=wt-n.length,r&&(s+=Eo(r))}else if(o===0)return"0";for(;o%10===0;)o/=10;return s+o}function jn(e,t,r){if(e!==~~e||e<t||e>r)throw Error(So+e)}function Uu(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=Vr(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)==Vr(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)==Vr(10,t-3)-1,o}function td(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]+=ug.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 UU(e,t){var r,n,i;if(t.isZero())return t;n=t.d.length,n<32?(r=Math.ceil(n/3),i=(1/sd(4,r)).toString()):(r=16,i="2.3283064365386962890625e-10"),e.precision+=r,t=fc(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 er=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=ln(n.e/v)-ln(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,ex=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/Vr(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/Vr(10,i-o-1)%10|0}if(n=n||t<0||f[h+1]!==void 0||(o<0?l:l%Vr(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/Vr(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]=Vr(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=Vr(10,wt-s),f[h]=o>0?(l/Vr(10,i-o)%Vr(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 Ct&&(e.e>v.maxE?(e.d=null,e.e=NaN):e.e<v.minE&&(e.e=0,e.d=[0])),e}function Qi(e,t,r){if(!e.isFinite())return ux(e);var n,i=e.e,s=Yr(e.d),o=s.length;return t?(r&&(n=r-o)>0?s=s.charAt(0)+"."+s.slice(1)+Eo(n):o>1&&(s=s.charAt(0)+"."+s.slice(1)),s=s+(e.e<0?"e":"e+")+e.e):i<0?(s="0."+Eo(-i-1)+s,r&&(n=r-o)>0&&(s+=Eo(n))):i>=o?(s+=Eo(i+1-o),r&&(n=r-i-1)>0&&(s=s+"."+Eo(n))):((n=i+1)<o&&(s=s.slice(0,n)+"."+s.slice(n)),r&&(n=r-o)>0&&(i+1===o&&(s+="."),s+=Eo(n))),s}function rd(e,t){var r=e[0];for(t*=wt;r>=10;r/=10)t++;return t}function nd(e,t,r){if(t>BU)throw Ct=!0,r&&(e.precision=r),Error(tx);return dt(new e(Zf),t,1,!0)}function es(e,t,r){if(t>fg)throw Error(tx);return dt(new e(Qf),t,r,!0)}function sx(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 Eo(e){for(var t="";e--;)t+="0";return t}function ox(e,t,r,n){var i,s=new e(1),o=Math.ceil(n/wt+4);for(Ct=!1;;){if(r%2&&(s=s.times(t),fx(s.d,o)&&(i=!0)),r=ln(r/2),r===0){r=s.d.length-1,i&&s.d[r]===0&&++s.d[r];break}t=t.times(t),fx(t.d,o)}return Ct=!0,s}function ax(e){return e.d[e.d.length-1]&1}function cx(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 dg(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?(Ct=!1,c=b):c=t,a=new h(.03125);e.e>-2;)e=e.times(a),f+=5;for(n=Math.log(Vr(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(er(s,r,c,1)),Yr(a.d).slice(0,c)===Yr(o.d).slice(0,c)){for(i=f;i--;)o=dt(o.times(o),c,1);if(t==null)if(u<3&&Uu(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,Ct=!0);else return h.precision=b,o}o=a}}function To(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?(Ct=!1,l=I):l=t,C.precision=l+=b,r=Yr(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=Yr(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=nd(C,l+2,I).times(s+""),y=To(new C(n+"."+r.slice(1)),l-b).plus(u),C.precision=I,t==null?dt(y,I,O,Ct=!0):y;for(f=y,c=o=y=er(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(er(o,new C(i),l,1)),Yr(u.d).slice(0,l)===Yr(c.d).slice(0,l))if(c=c.times(2),s!==0&&(c=c.plus(nd(C,l+2,I).times(s+""))),c=er(c,new C(v),l,1),t==null)if(Uu(c.d,l-b,O,a))C.precision=l+=b,u=o=y=er(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,Ct=!0);else return C.precision=I,c;c=u,i+=2}}function ux(e){return String(e.s*e.s/0)}function id(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),Ct&&(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 FU(e,t){var r,n,i,s,o,a,c,u,l;if(t.indexOf("_")>-1){if(t=t.replace(/(\d)_(?=\d)/g,"$1"),ix.test(t))return id(e,t)}else if(t==="Infinity"||t==="NaN")return+t||(e.s=NaN),e.e=NaN,e.d=null,e;if($U.test(t))r=16,t=t.toLowerCase();else if(NU.test(t))r=2;else if(DU.test(t))r=8;else throw Error(So+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=ox(n,new n(r),s,s*2)),u=td(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=rd(u,l),e.d=u,Ct=!1,o&&(e=er(e,i,a*4)),c&&(e=e.times(Math.abs(c)<54?Vr(2,c):Fu.pow(2,c))),Ct=!0,e)}function VU(e,t){var r,n=t.d.length;if(n<3)return t.isZero()?t:fc(e,2,t,t);r=1.4*Math.sqrt(n),r=r>16?16:r|0,t=t.times(1/sd(5,r)),t=fc(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 fc(e,t,r,n,i){var s,o,a,c,u=e.precision,l=Math.ceil(u/wt);for(Ct=!1,c=r.times(r),a=new e(n);;){if(o=er(a.times(c),new e(t++*t++),u,1),a=i?n.plus(o):n.minus(o),n=er(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 Ct=!0,o.d.length=l+1,o}function sd(e,t){for(var r=e;--t;)r*=e;return r}function lx(e,t){var r,n=t.s<0,i=es(e,e.precision,1),s=i.times(.5);if(t=t.abs(),t.lte(s))return Ls=n?4:1,t;if(r=t.divToInt(i),r.isZero())Ls=n?3:2;else{if(t=t.minus(r.times(i)),t.lte(s))return Ls=ax(r)?n?2:3:n?4:1,t;Ls=ax(r)?n?1:4:n?3:2}return t.minus(i).abs()}function hg(e,t,r,n){var i,s,o,a,c,u,l,f,h,v=e.constructor,b=r!==void 0;if(b?(jn(r,1,xo),n===void 0?n=v.rounding:jn(n,0,8)):(r=v.precision,n=v.rounding),!e.isFinite())l=ux(e);else{for(l=Qi(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=td(Qi(h),10,i),h.e=h.d.length),f=td(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=er(e,h,r,n,0,i),f=e.d,s=e.e,u=ex),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+=ug.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=td(l,i,t),c=f.length;!f[c-1];--c);for(o=1,l="1.";o<c;o++)l+=ug.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 fx(e,t){if(e.length>t)return e.length=t,!0}function zU(e){return new this(e).abs()}function WU(e){return new this(e).acos()}function qU(e){return new this(e).acosh()}function HU(e,t){return new this(e).plus(t)}function GU(e){return new this(e).asin()}function KU(e){return new this(e).asinh()}function YU(e){return new this(e).atan()}function XU(e){return new this(e).atanh()}function JU(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=es(this,s,1).times(t.s>0?.25:.75),r.s=e.s):!t.d||e.isZero()?(r=t.s<0?es(this,n,i):new this(0),r.s=e.s):!e.d||t.isZero()?(r=es(this,s,1).times(.5),r.s=e.s):t.s<0?(this.precision=s,this.rounding=1,r=this.atan(er(e,t,s,1)),t=es(this,s,1),this.precision=n,this.rounding=i,r=e.s<0?r.minus(t):r.plus(t)):r=this.atan(er(e,t,s,1)),r}function ZU(e){return new this(e).cbrt()}function QU(e){return dt(e=new this(e),e.e+1,2)}function eF(e,t,r){return new this(e).clamp(t,r)}function tF(e){if(!e||typeof e!="object")throw Error(ed+"Object expected");var t,r,n,i=e.defaults===!0,s=["precision",1,xo,"rounding",0,8,"toExpNeg",-lc,0,"toExpPos",0,lc,"maxE",0,lc,"minE",-lc,0,"modulo",0,9];for(t=0;t<s.length;t+=3)if(r=s[t],i&&(this[r]=lg[r]),(n=e[r])!==void 0)if(ln(n)===n&&n>=s[t+1]&&n<=s[t+2])this[r]=n;else throw Error(So+r+": "+n);if(r="crypto",i&&(this[r]=lg[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(rx);else this[r]=!1;else throw Error(So+r+": "+n);return this}function rF(e){return new this(e).cos()}function nF(e){return new this(e).cosh()}function dx(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,hx(s)){u.s=s.s,Ct?!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++;Ct?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 id(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),ix.test(s)?id(u,s):FU(u,s);if(c==="bigint")return s<0?(s=-s,u.s=-1):u.s=1,id(u,s.toString());throw Error(So+s)}if(i.prototype=Re,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=tF,i.clone=dx,i.isDecimal=hx,i.abs=zU,i.acos=WU,i.acosh=qU,i.add=HU,i.asin=GU,i.asinh=KU,i.atan=YU,i.atanh=XU,i.atan2=JU,i.cbrt=ZU,i.ceil=QU,i.clamp=eF,i.cos=rF,i.cosh=nF,i.div=iF,i.exp=sF,i.floor=oF,i.hypot=aF,i.ln=cF,i.log=uF,i.log10=fF,i.log2=lF,i.max=dF,i.min=hF,i.mod=pF,i.mul=mF,i.pow=gF,i.random=yF,i.round=vF,i.sign=bF,i.sin=wF,i.sinh=_F,i.sqrt=xF,i.sub=SF,i.sum=EF,i.tan=TF,i.tanh=CF,i.trunc=AF,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 iF(e,t){return new this(e).div(t)}function sF(e){return new this(e).exp()}function oF(e){return dt(e=new this(e),e.e+1,3)}function aF(){var e,t,r=new this(0);for(Ct=!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 Ct=!0,new this(1/0);r=t}return Ct=!0,r.sqrt()}function hx(e){return e instanceof Fu||e&&e.toStringTag===nx||!1}function cF(e){return new this(e).ln()}function uF(e,t){return new this(e).log(t)}function lF(e){return new this(e).log(2)}function fF(e){return new this(e).log(10)}function dF(){return cx(this,arguments,-1)}function hF(){return cx(this,arguments,1)}function pF(e,t){return new this(e).mod(t)}function mF(e,t){return new this(e).mul(t)}function gF(e,t){return new this(e).pow(t)}function yF(e){var t,r,n,i,s=0,o=new this(1),a=[];if(e===void 0?e=this.precision:jn(e,1,xo),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(rx);else for(;s<n;)a[s++]=Math.random()*1e7|0;for(n=a[--s],e%=wt,n&&e&&(i=Vr(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 vF(e){return dt(e=new this(e),e.e+1,this.rounding)}function bF(e){return e=new this(e),e.d?e.d[0]?e.s:0*e.s:e.s||NaN}function wF(e){return new this(e).sin()}function _F(e){return new this(e).sinh()}function xF(e){return new this(e).sqrt()}function SF(e,t){return new this(e).sub(t)}function EF(){var e=0,t=arguments,r=new this(t[e]);for(Ct=!1;r.s&&++e<t.length;)r=r.plus(t[e]);return Ct=!0,dt(r,this.precision,this.rounding)}function TF(e){return new this(e).tan()}function CF(e){return new this(e).tanh()}function AF(e){return dt(e=new this(e),e.e+1,1)}Re[Symbol.for("nodejs.util.inspect.custom")]=Re.toString,Re[Symbol.toStringTag]="Decimal";var Fu=Re.constructor=dx(lg);Zf=new Fu(Zf),Qf=new Fu(Qf);var px=Fu;function MF(e,t,r){return Number(gx(new px(e.toString()),t,r).toFixed(0))}function mx(e,t,r){const n=gx(new px(e.toString()),t,r);return new RU.default(n.toFixed(0))}function gx(e,t,r){return t?e.mul(1-r):e.mul(1+r)}var yx=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?Gt.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(ur.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(ur.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})}},OF=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?Gt.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(ur.SUI_CLOCK_OBJECT_ID)];e.moveCall({target:`${t.publishedAt}::kriya_clmm::swap`,typeArguments:[t.coinAType,t.coinBType],arguments:n})}},IF=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?Gt.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(ur.SUI_CLOCK_OBJECT_ID)];e.moveCall({target:`${t.publishedAt}::flowx_clmm::swap`,typeArguments:[t.coinAType,t.coinBType],arguments:n})}},kF=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?Gt.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(ur.SUI_CLOCK_OBJECT_ID)];e.moveCall({target:`${t.publishedAt}::turbos::swap`,typeArguments:[t.coinAType,t.coinBType,t.feeType],arguments:n})}},jF=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?Gt.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(ur.SUI_CLOCK_OBJECT_ID)];e.moveCall({target:`${t.publishedAt}::bluefin::swap`,typeArguments:[t.coinAType,t.coinBType],arguments:n})}},PF=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?Gt.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(ur.SUI_CLOCK_OBJECT_ID)];e.moveCall({target:`${t.publishedAt}::momentum::swap`,typeArguments:[t.coinAType,t.coinBType],arguments:n})}},RF=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?Gt.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(ur.SUI_CLOCK_OBJECT_ID)];e.moveCall({target:`${t.publishedAt}::magma::swap`,typeArguments:[t.coinAType,t.coinBType],arguments:n})}},NF=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?Gt.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})}},$F=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?Gt.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})}},DF=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?Gt.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})}},LF=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?Gt.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(ur.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}},BF=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})}},UF=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?Gt.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(ur.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})}},FF=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?Gt.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(ur.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})}},vx=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?Gt.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})}},VF=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?Gt.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(ur.SUI_CLOCK_OBJECT_ID)];e.moveCall({target:`${t.publishedAt}::haedal_hmm::swap`,typeArguments:[t.coinAType,t.coinBType],arguments:n})}},zF=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?Gt.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(ur.SUI_CLOCK_OBJECT_ID)];e.moveCall({target:`${t.publishedAt}::obric::swap`,typeArguments:[t.coinAType,t.coinBType],arguments:n})}},WF=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?Gt.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(ur.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(ur.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})}},qF=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?Gt.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(ur.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(ur.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(ur.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})}},HF=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?Gt.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(ur.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(ur.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(ur.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})}},GF="0x790f258062909e3a0ffc78b3c53ac2f62d7084c3bab95644bdeb05add7250001::super_sui::SUPER_SUI",KF="0xe44df51c0b21a27ab915fa1fe2ca610cd3eaa6d9666fe5e62b988bf7f0bd8722::musd::MUSD",YF="0xccd628c2334c5ed33e6c47d6c21bb664f8b6307b2ac32c2462a61f69a31ebcee::meth::METH",XF=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?Gt.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 GF:{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 KF:case YF:{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(ur.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})}},JF=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?Gt.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})}},ZF=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?Gt.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})}},QF=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?Gt.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})}},eV=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?Gt.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})}},tV=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?Gt.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})}},rV=Gt.DEFAULT_PUBLISHED_AT.Mainnet;function Vu(e,t){return e&&e.has(Xf.AGGREGATOR_V3)?e.get(Xf.AGGREGATOR_V3):t||rV}function bx(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=Vu(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 wx(e,t){const{swapContext:r,targetCoinType:n,aggregatorPublishedAt:i,packages:s}=e,o=Vu(s,i);return t.moveCall({target:`${o}::router::confirm_swap`,typeArguments:[n],arguments:[r]})}function nV(e,t){const{coinType:r,amount:n,swapCtx:i,aggregatorPublishedAt:s,packages:o}=e,a=Vu(o,s),c=[i,t.pure.u64(n.toString())];return t.moveCall({target:`${a}::router::take_balance`,typeArguments:[r],arguments:c})}function iV(e,t){const{balance:r,coinType:n,recipient:i,aggregatorPublishedAt:s,packages:o}=e,a=Vu(o,s),c=[r,t.pure.address(i)];t.moveCall({target:`${a}::router::transfer_balance`,typeArguments:[n],arguments:c})}function sV(e,t){const{coin:r,coinType:n,aggregatorPublishedAt:i,packages:s}=e,o=Vu(s,i);t.moveCall({target:`${o}::router::transfer_or_destroy_coin`,typeArguments:[n],arguments:[r]})}function oV(e){return e.endsWith("/find_routes")?e.replace("/find_routes",""):e}sc(oc()),sc(oc());var aV=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?Gt.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(ur.SUI_CLOCK_OBJECT_ID)];e.moveCall({target:`${t.publishedAt}::haedal_hmm_v2::swap`,typeArguments:[t.coinAType,t.coinBType],arguments:n})}},cV=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?Gt.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(ur.SUI_CLOCK_OBJECT_ID)];e.moveCall({target:`${t.publishedAt}::fullsail::swap`,typeArguments:[t.coinAType,t.coinBType],arguments:n})}},_x="CETUS",uV="KRIYA",lV="FLOWX",fV="FLOWXV3",dV="KRIYAV3",hV="TURBOS",pV="AFTERMATH",mV="HAEDAL",gV="VOLO",yV="AFSUI",vV="BLUEMOVE",bV="DEEPBOOKV3",wV="SCALLOP",_V="SUILEND",xV="BLUEFIN",xx="HAEDALPMM",SV="ALPHAFI",EV="SPRINGSUI",TV="STEAMM",Sx="METASTABLE",Ex="OBRIC",CV="HAWAL",Tx="STEAMM_OMM",AV="MOMENTUM",Cx="STEAMM_OMM_V2",MV="MAGMA",Ax="SEVENK",Mx="HAEDALHMMV2",OV="FULLSAIL",IV="https://api-sui.cetus.zone/router_v3";function Ox(e){const t=new Set;for(const r of e){if(r.provider===xx&&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===Sx&&(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===Ex&&(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===Tx||r.provider===Cx)&&(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===Ax&&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===Mx&&r.extendedDetails&&r.extendedDetails.haedalhmmv2_base_price_seed&&t.add(r.extendedDetails.haedalhmmv2_base_price_seed)}return Array.from(t)}var Ix=class PT{constructor(t){var r,n;this.endpoint=t.endpoint?oV(t.endpoint):IV,this.client=t.client||new F_.SuiClient({url:F_.getFullnodeUrl("mainnet")}),this.signer=t.signer||"",this.env=t.env||0;const i=PT.CONFIG[this.env];if(this.pythConnections=this.newPythClients((r=t.pythUrls)!=null?r:[]),this.pythClient=new V_.SuiPythClient(this.client,i.pythStateId,i.wormholeStateId),this.apiKey=t.apiKey||"",this.partner=t.partner,t.overlayFeeRate)if(t.overlayFeeRate>0&&t.overlayFeeRate<=Ei.MAX_OVERLAY_FEE_RATE){if(this.overlayFeeRate=t.overlayFeeRate*Gt.FEE_DENOMINATOR,this.overlayFeeRate>Gt.MAX_FEE_RATE)throw new Error(Ei.ERRORS.INVALID_OVERLAY_FEE_RATE)}else throw new Error(Ei.ERRORS.INVALID_OVERLAY_FEE_RATE);else this.overlayFeeRate=0;this.overlayFeeReceiver=(n=t.overlayFeeReceiver)!=null?n:Ei.DEFAULT_OVERLAY_FEE_RECEIVER}newPythClients(t){return t.includes("https://hermes.pyth.network")||t.push("https://hermes.pyth.network"),t.map(n=>new V_.SuiPriceServiceConnection(n,{timeout:3e3}))}deepbookv3DeepFeeType(){return this.env===0?Jf.Mainnet:Jf.Testnet}getDeepbookV3Config(){return yn(this,null,function*(){return yield PU(this.endpoint)})}getOneCoinUsedToMerge(t){return yn(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 yn(this,null,function*(){return IU(this.endpoint,this.apiKey,t,this.overlayFeeRate,this.overlayFeeReceiver)})}executeFlexibleInputSwap(t,r,n,i,s,o,a,c,u){return yn(this,null,function*(){})}newDexRouterV3(t,r,n){switch(t){case _x:return new yx(this.env,n);case dV:return new OF(this.env);case fV:return new IF(this.env);case hV:return new kF(this.env);case xV:return new jF(this.env);case AV:return new PF(this.env);case MV:return new RF(this.env);case uV:return new NF(this.env);case lV:return new $F(this.env);case vV:return new DF(this.env);case bV:return new LF(this.env);case pV:return new BF(this.env);case TV:return new UF(this.env);case wV:return new FF(this.env);case _V:return new vx(this.env);case EV:return new vx(this.env);case xx:return new VF(this.env,r);case Ex:return new zF(this.env,r);case Ax:return new WF(this.env,r);case Tx:return new qF(this.env,r);case Cx:return new HF(this.env,r);case Sx:return new XF(this.env,r);case SV:return new JF(this.env);case gV:return new ZF(this.env);case yV:return new QF(this.env);case mV:return new eV(this.env);case CV:return new tV(this.env);case Mx:return new aV(this.env,r);case OV:return new cV(this.env);default:throw new Error(`${Ei.ERRORS.UNSUPPORTED_DEX} ${t}`)}}expectInputSwapV3(t,r,n,i,s,o,a){if(n.quoteID==null)throw new Error(Ei.ERRORS.QUOTE_ID_REQUIRED);const c=Z_(n),u=bx({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 wx({swapContext:u,targetCoinType:c.targetCoinType,packages:c.packages},t)}expectOutputSwapV3(t,r,n,i,s,o){const a=[],c=new yx(this.env,o),u=Z_(n),l=bx({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=PV(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=nV({coinType:u.fromCoinType,amount:cg,swapCtx:l,packages:u.packages},t);return iV({balance:b,coinType:u.fromCoinType,recipient:this.signer,packages:u.packages},t),wx({swapContext:l,targetCoinType:u.targetCoinType,packages:u.packages},t)}routerSwap(t){return yn(this,null,function*(){const{router:r,inputCoin:n,slippage:i,txb:s,partner:o}=t;if(i>1||i<0)throw new Error(Ei.ERRORS.INVALID_SLIPPAGE);if(!t.router.packages||!t.router.packages.get(Xf.AGGREGATOR_V3))throw new Error(Ei.ERRORS.PACKAGES_REQUIRED);const a=t.router.byAmountIn,c=r.amountIn,u=r.amountOut;pg(this.overlayFeeRate,this.overlayFeeReceiver);let l=new yr.default(0);a?l=u.mul(new yr.default(this.overlayFeeRate)).div(new yr.default(1e6)):l=c.mul(new yr.default(this.overlayFeeRate)).div(new yr.default(1e6));const f=a?u.sub(l):u,h=a?c:c.add(l),v=mx(a?f:h,a,i),b=Ox(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 yn(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;pg(this.overlayFeeRate,this.overlayFeeReceiver);let l=0;u?l=Number(r.amountOut.mul(new yr.default(this.overlayFeeRate)).div(new yr.default(1e6)).toString()):l=Number(r.amountIn.mul(new yr.default(this.overlayFeeRate)).div(new yr.default(1e6)).toString());const f=u?r.amountOut.sub(new yr.default(l)):r.amountOut,h=u?r.amountIn:r.amountIn.add(new yr.default(l)),v=MF(u?f:h,u,n),b=u?h:v;let y=sg.coinWithBalance({balance:BigInt(b.toString()),useGasCoin:!0,type:a}),S;o&&o>0&&(S=sg.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(X_.isSuiCoin(c))i.mergeCoins(i.gas,[O]);else{const I=yield this.getOneCoinUsedToMerge(c);I!=null?i.mergeCoins(i.object(I),[O]):sV({coin:O,coinType:c,packages:r.packages},i)}})}fixableRouterSwapV3(t){return yn(this,null,function*(){const{router:r,inputCoin:n,slippage:i,txb:s,partner:o}=t;pg(this.overlayFeeRate,this.overlayFeeReceiver);let a=0;r.byAmountIn?a=Number(r.amountOut.mul(new yr.default(this.overlayFeeRate)).div(new yr.default(1e6)).toString()):a=Number(r.amountIn.mul(new yr.default(this.overlayFeeRate)).div(new yr.default(1e6)).toString());const c=r.byAmountIn?r.amountOut.sub(new yr.default(a)):r.amountOut,u=r.byAmountIn?r.amountIn:r.amountIn.add(new yr.default(a)),l=mx(r.byAmountIn?c:u,r.byAmountIn,i),f=Ox(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 yn(this,null,function*(){var r,n,i,s;const{from:o,target:a,amount:c,byAmountIn:u,pools:l}=t,f=_o(o),h=_o(a),v=new sg.Transaction,b=CU(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 yr.default(0):new yr.default(cg),H=0;for(let m=0;m<U.length;m+=1)if(!U[m].parsedJson.data.is_exceed)if(t.byAmountIn){const x=new yr.default(U[m].parsedJson.data.amount_out);x.gt(D)&&(H=m,D=x)}else{const x=new yr.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 yr.default((n=z.amount_in)!=null?n:0),V=new yr.default((i=z.fee_amount)!=null?i:0),L=ce.add(V),p={amountIn:L,amountOut:new yr.default((s=z.amount_out)!=null?s:0),deviationRatio:0,paths:[{id:l[H],direction:b,provider:_x,from:f,target:h,feeRate:te,amountIn:L.toString(),amountOut:z.amount_out,publishedAt:MU,extendedDetails:{afterSqrtPrice:z.after_sqrt_price}}],insufficientLiquidity:!1,byAmountIn:t.byAmountIn,quoteID:`degraded-${jV()}`,packages:new Map([[Xf.AGGREGATOR_V3,Gt.DEFAULT_PUBLISHED_AT.Mainnet]])};return{isExceed:z.is_exceed,routeData:p}})}updatePythPriceIDs(t,r){return yn(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 yn(this,null,function*(){return yield this.client.devInspectTransactionBlock({transactionBlock:t,sender:this.signer})})}sendTransaction(t,r){return yn(this,null,function*(){return yield this.client.signAndExecuteTransaction({transaction:t,signer:r})})}};Ix.CONFIG={1:{wormholeStateId:"0x31358d198147da50db32eda2562951d53973a0c0ad5ed738e9b17d88b213d790",pythStateId:"0x243759059f4c3111179da5878c12f68d612c21a8d54d85edc86164bb18be1c7c"},0:{wormholeStateId:"0xaeab97f96cf9877fee2883315d459552b2b921edc16d7ceac6eab944dd88919c",pythStateId:"0x1f9310238ee9298fb703c3419030b35b22bb1cc37113e3bb5007c99aec79e5b8"}};var kV=Ix;function jV(){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 PV(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 pg(e,t){if(e>Ei.MAX_OVERLAY_FEE_RATE_NUMERATOR)throw new Error(Ei.ERRORS.INVALID_OVERLAY_FEE_RATE);if(t==="0x0"&&e>0)throw new Error(Ei.ERRORS.OVERLAY_FEE_RECEIVER_REQUIRED)}var kx=kV,jx=Q_,Px=xU,ya=cc;const Rx="0x2::sui::SUI",RV="0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI";function mg(e){return Or(e).full_address===Rx}function Nx(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=>mg(l)?l:Or(l).source_address),u.source_address=Nx(u.full_address,u.type_arguments),u}const s=r.split("::"),a={full_address:r,address:r===Rx||r===RV?"0x2":Jn(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=Nx(a.full_address,a.type_arguments),a}catch{return{full_address:e,address:"",module:"",name:"",type_arguments:[],source_address:e}}}function NV(e){return e.startsWith("0x")?`${e.slice(2)}`:e}const Bs=(e,t=!0)=>{const r=e.split("::"),n=r.shift();let i=Jn(n);return t&&(i=NV(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