UNPKG

raydium-sdk-v2-custody

Version:

An SDK for building applications on top of Raydium.

1 lines 439 kB
var Ml=Object.defineProperty,Nl=Object.defineProperties;var vl=Object.getOwnPropertyDescriptors;var Oo=Object.getOwnPropertySymbols;var qa=Object.prototype.hasOwnProperty,Ua=Object.prototype.propertyIsEnumerable;var Da=(o,e,t)=>e in o?Ml(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,M=(o,e)=>{for(var t in e||(e={}))qa.call(e,t)&&Da(o,t,e[t]);if(Oo)for(var t of Oo(e))Ua.call(e,t)&&Da(o,t,e[t]);return o},X=(o,e)=>Nl(o,vl(e));var ze=(o,e)=>{var t={};for(var n in o)qa.call(o,n)&&e.indexOf(n)<0&&(t[n]=o[n]);if(o!=null&&Oo)for(var n of Oo(o))e.indexOf(n)<0&&Ua.call(o,n)&&(t[n]=o[n]);return t};import Nu from"axios";import{PublicKey as za}from"@solana/web3.js";import{get as Ur,set as Ga}from"lodash";var Vl=(i=>(i[i.Error=0]="Error",i[i.Warning=1]="Warning",i[i.Info=2]="Info",i[i.Debug=3]="Debug",i))(Vl||{}),Gr=class{constructor(e){this.logLevel=e.logLevel!==void 0?e.logLevel:0,this.name=e.name}set level(e){this.logLevel=e}get time(){return Date.now().toString()}get moduleName(){return this.name}isLogLevel(e){return e<=this.logLevel}error(...e){return this.isLogLevel(0)?(console.error(this.time,this.name,"sdk logger error",...e),this):this}logWithError(...e){let t=e.map(n=>typeof n=="object"?JSON.stringify(n):n).join(", ");throw new Error(t)}warning(...e){return this.isLogLevel(1)?(console.warn(this.time,this.name,"sdk logger warning",...e),this):this}info(...e){return this.isLogLevel(2)?(console.info(this.time,this.name,"sdk logger info",...e),this):this}debug(...e){return this.isLogLevel(3)?(console.debug(this.time,this.name,"sdk logger debug",...e),this):this}},Xr={},Xa={};function ye(o){let e=Ur(Xr,o);if(!e){let t=Ur(Xa,o);e=new Gr({name:o,logLevel:t}),Ga(Xr,o,e)}return e}function Ky(o,e){Ga(Xa,o,e);let t=Ur(Xr,o);t&&(t.level=e)}import{MINT_SIZE as _l,TOKEN_PROGRAM_ID as El,getTransferFeeConfig as Fl,unpackMint as Wl}from"@solana/spl-token";var zr=ye("Raydium_accountInfo_util");async function Ut(o,e,t){let{batchRequest:n,commitment:i="confirmed",chunkCount:r=100}=M({batchRequest:!1},t),s=Qr(e,r),a=new Array(s.length).fill([]);if(n){let c=s.map(m=>{let d=o._buildArgs([m.map(p=>p.toBase58())],i,"base64");return{methodName:"getMultipleAccounts",args:d}}),u=Qr(c,10);a=(await(await Promise.all(u.map(async m=>await o._rpcBatchRequest(m)))).flat()).map(m=>(m.error&&zr.logWithError(`failed to get info for multiple accounts, RPC_ERROR, ${m.error.message}`),m.result.value.map(d=>{if(d){let{data:p,executable:y,lamports:f,owner:b,rentEpoch:g}=d;return p.length!==2&&p[1]!=="base64"&&zr.logWithError("info must be base64 encoded, RPC_ERROR"),{data:Buffer.from(p[0],"base64"),executable:y,lamports:f,owner:new za(b),rentEpoch:g}}return null})))}else try{a=await Promise.all(s.map(c=>o.getMultipleAccountsInfo(c,i)))}catch(c){c instanceof Error&&zr.logWithError(`failed to get info for multiple accounts, RPC_ERROR, ${c.message}`)}return a.flat()}async function $e(o,e,t){let n=await Ut(o,e.map(i=>i.pubkey),t);return e.map((i,r)=>X(M({},i),{accountInfo:n[r]}))}var Dl=(n=>(n[n.Uninitialized=0]="Uninitialized",n[n.Mint=1]="Mint",n[n.Account=2]="Account",n))(Dl||{}),Vy=1;async function si({connection:o,mints:e,config:t}){var r,s,a;if(e.length===0)return{};let n=await $e(o,e.map(c=>({pubkey:yt(c)})),t),i={};for(let c of n){if(!c.accountInfo||c.accountInfo.data.length<_l){console.log("invalid mint account",c.pubkey.toBase58());continue}let u=Wl(c.pubkey,c.accountInfo,(r=c.accountInfo)==null?void 0:r.owner);i[c.pubkey.toString()]=X(M({},u),{programId:((s=c.accountInfo)==null?void 0:s.owner)||El,feeConfig:(a=Fl(u))!=null?a:void 0})}return i[za.default.toBase58()]=i[$.toBase58()],i}import je from"bn.js";var ai=9e15,In=1e9,Yr="0123456789abcdef",No="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",vo="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",Hr={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-ai,maxE:ai,crypto:!1},ja,un,ue=!0,_o="[DecimalError] ",Tn=_o+"Invalid argument: ",Za=_o+"Precision limit exceeded",$a=_o+"crypto unavailable",Ja="[object Decimal]",bt=Math.floor,tt=Math.pow,ql=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,Ul=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,Gl=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,eu=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,Xt=1e7,re=7,Xl=9007199254740991,zl=No.length-1,jr=vo.length-1,U={toStringTag:Ja};U.absoluteValue=U.abs=function(){var o=new this.constructor(this);return o.s<0&&(o.s=1),ie(o)};U.ceil=function(){return ie(new this.constructor(this),this.e+1,2)};U.clampedTo=U.clamp=function(o,e){var t,n=this,i=n.constructor;if(o=new i(o),e=new i(e),!o.s||!e.s)return new i(NaN);if(o.gt(e))throw Error(Tn+e);return t=n.cmp(o),t<0?o:n.cmp(e)>0?e:new i(n)};U.comparedTo=U.cmp=function(o){var e,t,n,i,r=this,s=r.d,a=(o=new r.constructor(o)).d,c=r.s,u=o.s;if(!s||!a)return!c||!u?NaN:c!==u?c:s===a?0:!s^c<0?1:-1;if(!s[0]||!a[0])return s[0]?c:a[0]?-u:0;if(c!==u)return c;if(r.e!==o.e)return r.e>o.e^c<0?1:-1;for(n=s.length,i=a.length,e=0,t=n<i?n:i;e<t;++e)if(s[e]!==a[e])return s[e]>a[e]^c<0?1:-1;return n===i?0:n>i^c<0?1:-1};U.cosine=U.cos=function(){var o,e,t=this,n=t.constructor;return t.d?t.d[0]?(o=n.precision,e=n.rounding,n.precision=o+Math.max(t.e,t.sd())+re,n.rounding=1,t=Ql(n,ru(n,t)),n.precision=o,n.rounding=e,ie(un==2||un==3?t.neg():t,o,e,!0)):new n(1):new n(NaN)};U.cubeRoot=U.cbrt=function(){var o,e,t,n,i,r,s,a,c,u,l=this,m=l.constructor;if(!l.isFinite()||l.isZero())return new m(l);for(ue=!1,r=l.s*tt(l.s*l,1/3),!r||Math.abs(r)==1/0?(t=ct(l.d),o=l.e,(r=(o-t.length+1)%3)&&(t+=r==1||r==-2?"0":"00"),r=tt(t,1/3),o=bt((o+1)/3)-(o%3==(o<0?-1:2)),r==1/0?t="5e"+o:(t=r.toExponential(),t=t.slice(0,t.indexOf("e")+1)+o),n=new m(t),n.s=l.s):n=new m(r.toString()),s=(o=m.precision)+3;;)if(a=n,c=a.times(a).times(a),u=c.plus(l),n=Oe(u.plus(l).times(a),u.plus(c),s+2,1),ct(a.d).slice(0,s)===(t=ct(n.d)).slice(0,s))if(t=t.slice(s-3,s+1),t=="9999"||!i&&t=="4999"){if(!i&&(ie(a,o+1,0),a.times(a).times(a).eq(l))){n=a;break}s+=4,i=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(ie(n,o+1,1),e=!n.times(n).times(n).eq(l));break}return ue=!0,ie(n,o,m.rounding,e)};U.decimalPlaces=U.dp=function(){var o,e=this.d,t=NaN;if(e){if(o=e.length-1,t=(o-bt(this.e/re))*re,o=e[o],o)for(;o%10==0;o/=10)t--;t<0&&(t=0)}return t};U.dividedBy=U.div=function(o){return Oe(this,new this.constructor(o))};U.dividedToIntegerBy=U.divToInt=function(o){var e=this,t=e.constructor;return ie(Oe(e,new t(o),0,1,1),t.precision,t.rounding)};U.equals=U.eq=function(o){return this.cmp(o)===0};U.floor=function(){return ie(new this.constructor(this),this.e+1,3)};U.greaterThan=U.gt=function(o){return this.cmp(o)>0};U.greaterThanOrEqualTo=U.gte=function(o){var e=this.cmp(o);return e==1||e===0};U.hyperbolicCosine=U.cosh=function(){var o,e,t,n,i,r=this,s=r.constructor,a=new s(1);if(!r.isFinite())return new s(r.s?1/0:NaN);if(r.isZero())return a;t=s.precision,n=s.rounding,s.precision=t+Math.max(r.e,r.sd())+4,s.rounding=1,i=r.d.length,i<32?(o=Math.ceil(i/3),e=(1/Fo(4,o)).toString()):(o=16,e="2.3283064365386962890625e-10"),r=ui(s,1,r.times(e),new s(1),!0);for(var c,u=o,l=new s(8);u--;)c=r.times(r),r=a.minus(c.times(l.minus(c.times(l))));return ie(r,s.precision=t,s.rounding=n,!0)};U.hyperbolicSine=U.sinh=function(){var o,e,t,n,i=this,r=i.constructor;if(!i.isFinite()||i.isZero())return new r(i);if(e=r.precision,t=r.rounding,r.precision=e+Math.max(i.e,i.sd())+4,r.rounding=1,n=i.d.length,n<3)i=ui(r,2,i,i,!0);else{o=1.4*Math.sqrt(n),o=o>16?16:o|0,i=i.times(1/Fo(5,o)),i=ui(r,2,i,i,!0);for(var s,a=new r(5),c=new r(16),u=new r(20);o--;)s=i.times(i),i=i.times(a.plus(s.times(c.times(s).plus(u))))}return r.precision=e,r.rounding=t,ie(i,e,t,!0)};U.hyperbolicTangent=U.tanh=function(){var o,e,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(o=n.precision,e=n.rounding,n.precision=o+7,n.rounding=1,Oe(t.sinh(),t.cosh(),n.precision=o,n.rounding=e)):new n(t.s)};U.inverseCosine=U.acos=function(){var o,e=this,t=e.constructor,n=e.abs().cmp(1),i=t.precision,r=t.rounding;return n!==-1?n===0?e.isNeg()?Gt(t,i,r):new t(0):new t(NaN):e.isZero()?Gt(t,i+4,r).times(.5):(t.precision=i+6,t.rounding=1,e=e.asin(),o=Gt(t,i+4,r).times(.5),t.precision=i,t.rounding=r,o.minus(e))};U.inverseHyperbolicCosine=U.acosh=function(){var o,e,t=this,n=t.constructor;return t.lte(1)?new n(t.eq(1)?0:NaN):t.isFinite()?(o=n.precision,e=n.rounding,n.precision=o+Math.max(Math.abs(t.e),t.sd())+4,n.rounding=1,ue=!1,t=t.times(t).minus(1).sqrt().plus(t),ue=!0,n.precision=o,n.rounding=e,t.ln()):new n(t)};U.inverseHyperbolicSine=U.asinh=function(){var o,e,t=this,n=t.constructor;return!t.isFinite()||t.isZero()?new n(t):(o=n.precision,e=n.rounding,n.precision=o+2*Math.max(Math.abs(t.e),t.sd())+6,n.rounding=1,ue=!1,t=t.times(t).plus(1).sqrt().plus(t),ue=!0,n.precision=o,n.rounding=e,t.ln())};U.inverseHyperbolicTangent=U.atanh=function(){var o,e,t,n,i=this,r=i.constructor;return i.isFinite()?i.e>=0?new r(i.abs().eq(1)?i.s/0:i.isZero()?i:NaN):(o=r.precision,e=r.rounding,n=i.sd(),Math.max(n,o)<2*-i.e-1?ie(new r(i),o,e,!0):(r.precision=t=n-i.e,i=Oe(i.plus(1),new r(1).minus(i),t+o,1),r.precision=o+4,r.rounding=1,i=i.ln(),r.precision=o,r.rounding=e,i.times(.5))):new r(NaN)};U.inverseSine=U.asin=function(){var o,e,t,n,i=this,r=i.constructor;return i.isZero()?new r(i):(e=i.abs().cmp(1),t=r.precision,n=r.rounding,e!==-1?e===0?(o=Gt(r,t+4,n).times(.5),o.s=i.s,o):new r(NaN):(r.precision=t+6,r.rounding=1,i=i.div(new r(1).minus(i.times(i)).sqrt().plus(1)).atan(),r.precision=t,r.rounding=n,i.times(2)))};U.inverseTangent=U.atan=function(){var o,e,t,n,i,r,s,a,c,u=this,l=u.constructor,m=l.precision,d=l.rounding;if(u.isFinite()){if(u.isZero())return new l(u);if(u.abs().eq(1)&&m+4<=jr)return s=Gt(l,m+4,d).times(.25),s.s=u.s,s}else{if(!u.s)return new l(NaN);if(m+4<=jr)return s=Gt(l,m+4,d).times(.5),s.s=u.s,s}for(l.precision=a=m+10,l.rounding=1,t=Math.min(28,a/re+2|0),o=t;o;--o)u=u.div(u.times(u).plus(1).sqrt().plus(1));for(ue=!1,e=Math.ceil(a/re),n=1,c=u.times(u),s=new l(u),i=u;o!==-1;)if(i=i.times(c),r=s.minus(i.div(n+=2)),i=i.times(c),s=r.plus(i.div(n+=2)),s.d[e]!==void 0)for(o=e;s.d[o]===r.d[o]&&o--;);return t&&(s=s.times(2<<t-1)),ue=!0,ie(s,l.precision=m,l.rounding=d,!0)};U.isFinite=function(){return!!this.d};U.isInteger=U.isInt=function(){return!!this.d&&bt(this.e/re)>this.d.length-2};U.isNaN=function(){return!this.s};U.isNegative=U.isNeg=function(){return this.s<0};U.isPositive=U.isPos=function(){return this.s>0};U.isZero=function(){return!!this.d&&this.d[0]===0};U.lessThan=U.lt=function(o){return this.cmp(o)<0};U.lessThanOrEqualTo=U.lte=function(o){return this.cmp(o)<1};U.logarithm=U.log=function(o){var e,t,n,i,r,s,a,c,u=this,l=u.constructor,m=l.precision,d=l.rounding,p=5;if(o==null)o=new l(10),e=!0;else{if(o=new l(o),t=o.d,o.s<0||!t||!t[0]||o.eq(1))return new l(NaN);e=o.eq(10)}if(t=u.d,u.s<0||!t||!t[0]||u.eq(1))return new l(t&&!t[0]?-1/0:u.s!=1?NaN:t?0:1/0);if(e)if(t.length>1)r=!0;else{for(i=t[0];i%10===0;)i/=10;r=i!==1}if(ue=!1,a=m+p,s=hn(u,a),n=e?Vo(l,a+10):hn(o,a),c=Oe(s,n,a,1),Si(c.d,i=m,d))do if(a+=10,s=hn(u,a),n=e?Vo(l,a+10):hn(o,a),c=Oe(s,n,a,1),!r){+ct(c.d).slice(i+1,i+15)+1==1e14&&(c=ie(c,m+1,0));break}while(Si(c.d,i+=10,d));return ue=!0,ie(c,m,d)};U.minus=U.sub=function(o){var e,t,n,i,r,s,a,c,u,l,m,d,p=this,y=p.constructor;if(o=new y(o),!p.d||!o.d)return!p.s||!o.s?o=new y(NaN):p.d?o.s=-o.s:o=new y(o.d||p.s!==o.s?p:NaN),o;if(p.s!=o.s)return o.s=-o.s,p.plus(o);if(u=p.d,d=o.d,a=y.precision,c=y.rounding,!u[0]||!d[0]){if(d[0])o.s=-o.s;else if(u[0])o=new y(p);else return new y(c===3?-0:0);return ue?ie(o,a,c):o}if(t=bt(o.e/re),l=bt(p.e/re),u=u.slice(),r=l-t,r){for(m=r<0,m?(e=u,r=-r,s=d.length):(e=d,t=l,s=u.length),n=Math.max(Math.ceil(a/re),s)+2,r>n&&(r=n,e.length=1),e.reverse(),n=r;n--;)e.push(0);e.reverse()}else{for(n=u.length,s=d.length,m=n<s,m&&(s=n),n=0;n<s;n++)if(u[n]!=d[n]){m=u[n]<d[n];break}r=0}for(m&&(e=u,u=d,d=e,o.s=-o.s),s=u.length,n=d.length-s;n>0;--n)u[s++]=0;for(n=d.length;n>r;){if(u[--n]<d[n]){for(i=n;i&&u[--i]===0;)u[i]=Xt-1;--u[i],u[n]+=Xt}u[n]-=d[n]}for(;u[--s]===0;)u.pop();for(;u[0]===0;u.shift())--t;return u[0]?(o.d=u,o.e=Eo(u,t),ue?ie(o,a,c):o):new y(c===3?-0:0)};U.modulo=U.mod=function(o){var e,t=this,n=t.constructor;return o=new n(o),!t.d||!o.s||o.d&&!o.d[0]?new n(NaN):!o.d||t.d&&!t.d[0]?ie(new n(t),n.precision,n.rounding):(ue=!1,n.modulo==9?(e=Oe(t,o.abs(),0,3,1),e.s*=o.s):e=Oe(t,o,0,n.modulo,1),e=e.times(o),ue=!0,t.minus(e))};U.naturalExponential=U.exp=function(){return Zr(this)};U.naturalLogarithm=U.ln=function(){return hn(this)};U.negated=U.neg=function(){var o=new this.constructor(this);return o.s=-o.s,ie(o)};U.plus=U.add=function(o){var e,t,n,i,r,s,a,c,u,l,m=this,d=m.constructor;if(o=new d(o),!m.d||!o.d)return!m.s||!o.s?o=new d(NaN):m.d||(o=new d(o.d||m.s===o.s?m:NaN)),o;if(m.s!=o.s)return o.s=-o.s,m.minus(o);if(u=m.d,l=o.d,a=d.precision,c=d.rounding,!u[0]||!l[0])return l[0]||(o=new d(m)),ue?ie(o,a,c):o;if(r=bt(m.e/re),n=bt(o.e/re),u=u.slice(),i=r-n,i){for(i<0?(t=u,i=-i,s=l.length):(t=l,n=r,s=u.length),r=Math.ceil(a/re),s=r>s?r+1:s+1,i>s&&(i=s,t.length=1),t.reverse();i--;)t.push(0);t.reverse()}for(s=u.length,i=l.length,s-i<0&&(i=s,t=l,l=u,u=t),e=0;i;)e=(u[--i]=u[i]+l[i]+e)/Xt|0,u[i]%=Xt;for(e&&(u.unshift(e),++n),s=u.length;u[--s]==0;)u.pop();return o.d=u,o.e=Eo(u,n),ue?ie(o,a,c):o};U.precision=U.sd=function(o){var e,t=this;if(o!==void 0&&o!==!!o&&o!==1&&o!==0)throw Error(Tn+o);return t.d?(e=tu(t.d),o&&t.e+1>e&&(e=t.e+1)):e=NaN,e};U.round=function(){var o=this,e=o.constructor;return ie(new e(o),o.e+1,e.rounding)};U.sine=U.sin=function(){var o,e,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(o=n.precision,e=n.rounding,n.precision=o+Math.max(t.e,t.sd())+re,n.rounding=1,t=Hl(n,ru(n,t)),n.precision=o,n.rounding=e,ie(un>2?t.neg():t,o,e,!0)):new n(NaN)};U.squareRoot=U.sqrt=function(){var o,e,t,n,i,r,s=this,a=s.d,c=s.e,u=s.s,l=s.constructor;if(u!==1||!a||!a[0])return new l(!u||u<0&&(!a||a[0])?NaN:a?s:1/0);for(ue=!1,u=Math.sqrt(+s),u==0||u==1/0?(e=ct(a),(e.length+c)%2==0&&(e+="0"),u=Math.sqrt(e),c=bt((c+1)/2)-(c<0||c%2),u==1/0?e="5e"+c:(e=u.toExponential(),e=e.slice(0,e.indexOf("e")+1)+c),n=new l(e)):n=new l(u.toString()),t=(c=l.precision)+3;;)if(r=n,n=r.plus(Oe(s,r,t+2,1)).times(.5),ct(r.d).slice(0,t)===(e=ct(n.d)).slice(0,t))if(e=e.slice(t-3,t+1),e=="9999"||!i&&e=="4999"){if(!i&&(ie(r,c+1,0),r.times(r).eq(s))){n=r;break}t+=4,i=1}else{(!+e||!+e.slice(1)&&e.charAt(0)=="5")&&(ie(n,c+1,1),o=!n.times(n).eq(s));break}return ue=!0,ie(n,c,l.rounding,o)};U.tangent=U.tan=function(){var o,e,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(o=n.precision,e=n.rounding,n.precision=o+10,n.rounding=1,t=t.sin(),t.s=1,t=Oe(t,new n(1).minus(t.times(t)).sqrt(),o+10,0),n.precision=o,n.rounding=e,ie(un==2||un==4?t.neg():t,o,e,!0)):new n(NaN)};U.times=U.mul=function(o){var e,t,n,i,r,s,a,c,u,l=this,m=l.constructor,d=l.d,p=(o=new m(o)).d;if(o.s*=l.s,!d||!d[0]||!p||!p[0])return new m(!o.s||d&&!d[0]&&!p||p&&!p[0]&&!d?NaN:!d||!p?o.s/0:o.s*0);for(t=bt(l.e/re)+bt(o.e/re),c=d.length,u=p.length,c<u&&(r=d,d=p,p=r,s=c,c=u,u=s),r=[],s=c+u,n=s;n--;)r.push(0);for(n=u;--n>=0;){for(e=0,i=c+n;i>n;)a=r[i]+p[n]*d[i-n-1]+e,r[i--]=a%Xt|0,e=a/Xt|0;r[i]=(r[i]+e)%Xt|0}for(;!r[--s];)r.pop();return e?++t:r.shift(),o.d=r,o.e=Eo(r,t),ue?ie(o,m.precision,m.rounding):o};U.toBinary=function(o,e){return Jr(this,2,o,e)};U.toDecimalPlaces=U.toDP=function(o,e){var t=this,n=t.constructor;return t=new n(t),o===void 0?t:(St(o,0,In),e===void 0?e=n.rounding:St(e,0,8),ie(t,o+t.e+1,e))};U.toExponential=function(o,e){var t,n=this,i=n.constructor;return o===void 0?t=Jt(n,!0):(St(o,0,In),e===void 0?e=i.rounding:St(e,0,8),n=ie(new i(n),o+1,e),t=Jt(n,!0,o+1)),n.isNeg()&&!n.isZero()?"-"+t:t};U.toFixed=function(o,e){var t,n,i=this,r=i.constructor;return o===void 0?t=Jt(i):(St(o,0,In),e===void 0?e=r.rounding:St(e,0,8),n=ie(new r(i),o+i.e+1,e),t=Jt(n,!1,o+n.e+1)),i.isNeg()&&!i.isZero()?"-"+t:t};U.toFraction=function(o){var e,t,n,i,r,s,a,c,u,l,m,d,p=this,y=p.d,f=p.constructor;if(!y)return new f(p);if(u=t=new f(1),n=c=new f(0),e=new f(n),r=e.e=tu(y)-p.e-1,s=r%re,e.d[0]=tt(10,s<0?re+s:s),o==null)o=r>0?e:u;else{if(a=new f(o),!a.isInt()||a.lt(u))throw Error(Tn+a);o=a.gt(e)?r>0?e:u:a}for(ue=!1,a=new f(ct(y)),l=f.precision,f.precision=r=y.length*re*2;m=Oe(a,e,0,1,1),i=t.plus(m.times(n)),i.cmp(o)!=1;)t=n,n=i,i=u,u=c.plus(m.times(i)),c=i,i=e,e=a.minus(m.times(i)),a=i;return i=Oe(o.minus(t),n,0,1,1),c=c.plus(i.times(u)),t=t.plus(i.times(n)),c.s=u.s=p.s,d=Oe(u,n,r,1).minus(p).abs().cmp(Oe(c,t,r,1).minus(p).abs())<1?[u,n]:[c,t],f.precision=l,ue=!0,d};U.toHexadecimal=U.toHex=function(o,e){return Jr(this,16,o,e)};U.toNearest=function(o,e){var t=this,n=t.constructor;if(t=new n(t),o==null){if(!t.d)return t;o=new n(1),e=n.rounding}else{if(o=new n(o),e===void 0?e=n.rounding:St(e,0,8),!t.d)return o.s?t:o;if(!o.d)return o.s&&(o.s=t.s),o}return o.d[0]?(ue=!1,t=Oe(t,o,0,e,1).times(o),ue=!0,ie(t)):(o.s=t.s,t=o),t};U.toNumber=function(){return+this};U.toOctal=function(o,e){return Jr(this,8,o,e)};U.toPower=U.pow=function(o){var e,t,n,i,r,s,a=this,c=a.constructor,u=+(o=new c(o));if(!a.d||!o.d||!a.d[0]||!o.d[0])return new c(tt(+a,u));if(a=new c(a),a.eq(1))return a;if(n=c.precision,r=c.rounding,o.eq(1))return ie(a,n,r);if(e=bt(o.e/re),e>=o.d.length-1&&(t=u<0?-u:u)<=Xl)return i=nu(c,a,t,n),o.s<0?new c(1).div(i):ie(i,n,r);if(s=a.s,s<0){if(e<o.d.length-1)return new c(NaN);if((o.d[e]&1)==0&&(s=1),a.e==0&&a.d[0]==1&&a.d.length==1)return a.s=s,a}return t=tt(+a,u),e=t==0||!isFinite(t)?bt(u*(Math.log("0."+ct(a.d))/Math.LN10+a.e+1)):new c(t+"").e,e>c.maxE+1||e<c.minE-1?new c(e>0?s/0:0):(ue=!1,c.rounding=a.s=1,t=Math.min(12,(e+"").length),i=Zr(o.times(hn(a,n+t)),n),i.d&&(i=ie(i,n+5,1),Si(i.d,n,r)&&(e=n+10,i=ie(Zr(o.times(hn(a,e+t)),e),e+5,1),+ct(i.d).slice(n+1,n+15)+1==1e14&&(i=ie(i,n+1,0)))),i.s=s,ue=!0,c.rounding=r,ie(i,n,r))};U.toPrecision=function(o,e){var t,n=this,i=n.constructor;return o===void 0?t=Jt(n,n.e<=i.toExpNeg||n.e>=i.toExpPos):(St(o,1,In),e===void 0?e=i.rounding:St(e,0,8),n=ie(new i(n),o,e),t=Jt(n,o<=n.e||n.e<=i.toExpNeg,o)),n.isNeg()&&!n.isZero()?"-"+t:t};U.toSignificantDigits=U.toSD=function(o,e){var t=this,n=t.constructor;return o===void 0?(o=n.precision,e=n.rounding):(St(o,1,In),e===void 0?e=n.rounding:St(e,0,8)),ie(new n(t),o,e)};U.toString=function(){var o=this,e=o.constructor,t=Jt(o,o.e<=e.toExpNeg||o.e>=e.toExpPos);return o.isNeg()&&!o.isZero()?"-"+t:t};U.truncated=U.trunc=function(){return ie(new this.constructor(this),this.e+1,1)};U.valueOf=U.toJSON=function(){var o=this,e=o.constructor,t=Jt(o,o.e<=e.toExpNeg||o.e>=e.toExpPos);return o.isNeg()?"-"+t:t};function ct(o){var e,t,n,i=o.length-1,r="",s=o[0];if(i>0){for(r+=s,e=1;e<i;e++)n=o[e]+"",t=re-n.length,t&&(r+=kn(t)),r+=n;s=o[e],n=s+"",t=re-n.length,t&&(r+=kn(t))}else if(s===0)return"0";for(;s%10===0;)s/=10;return r+s}function St(o,e,t){if(o!==~~o||o<e||o>t)throw Error(Tn+o)}function Si(o,e,t,n){var i,r,s,a;for(r=o[0];r>=10;r/=10)--e;return--e<0?(e+=re,i=0):(i=Math.ceil((e+1)/re),e%=re),r=tt(10,re-e),a=o[i]%r|0,n==null?e<3?(e==0?a=a/100|0:e==1&&(a=a/10|0),s=t<4&&a==99999||t>3&&a==49999||a==5e4||a==0):s=(t<4&&a+1==r||t>3&&a+1==r/2)&&(o[i+1]/r/100|0)==tt(10,e-2)-1||(a==r/2||a==0)&&(o[i+1]/r/100|0)==0:e<4?(e==0?a=a/1e3|0:e==1?a=a/100|0:e==2&&(a=a/10|0),s=(n||t<4)&&a==9999||!n&&t>3&&a==4999):s=((n||t<4)&&a+1==r||!n&&t>3&&a+1==r/2)&&(o[i+1]/r/1e3|0)==tt(10,e-3)-1,s}function Mo(o,e,t){for(var n,i=[0],r,s=0,a=o.length;s<a;){for(r=i.length;r--;)i[r]*=e;for(i[0]+=Yr.indexOf(o.charAt(s++)),n=0;n<i.length;n++)i[n]>t-1&&(i[n+1]===void 0&&(i[n+1]=0),i[n+1]+=i[n]/t|0,i[n]%=t)}return i.reverse()}function Ql(o,e){var t,n,i;if(e.isZero())return e;n=e.d.length,n<32?(t=Math.ceil(n/3),i=(1/Fo(4,t)).toString()):(t=16,i="2.3283064365386962890625e-10"),o.precision+=t,e=ui(o,1,e.times(i),new o(1));for(var r=t;r--;){var s=e.times(e);e=s.times(s).minus(s).times(8).plus(1)}return o.precision-=t,e}var Oe=function(){function o(n,i,r){var s,a=0,c=n.length;for(n=n.slice();c--;)s=n[c]*i+a,n[c]=s%r|0,a=s/r|0;return a&&n.unshift(a),n}function e(n,i,r,s){var a,c;if(r!=s)c=r>s?1:-1;else for(a=c=0;a<r;a++)if(n[a]!=i[a]){c=n[a]>i[a]?1:-1;break}return c}function t(n,i,r,s){for(var a=0;r--;)n[r]-=a,a=n[r]<i[r]?1:0,n[r]=a*s+n[r]-i[r];for(;!n[0]&&n.length>1;)n.shift()}return function(n,i,r,s,a,c){var u,l,m,d,p,y,f,b,g,A,w,k,I,h,x,K,S,B,C,L,O=n.constructor,E=n.s==i.s?1:-1,q=n.d,_=i.d;if(!q||!q[0]||!_||!_[0])return new O(!n.s||!i.s||(q?_&&q[0]==_[0]:!_)?NaN:q&&q[0]==0||!_?E*0:E/0);for(c?(p=1,l=n.e-i.e):(c=Xt,p=re,l=bt(n.e/p)-bt(i.e/p)),C=_.length,S=q.length,g=new O(E),A=g.d=[],m=0;_[m]==(q[m]||0);m++);if(_[m]>(q[m]||0)&&l--,r==null?(h=r=O.precision,s=O.rounding):a?h=r+(n.e-i.e)+1:h=r,h<0)A.push(1),y=!0;else{if(h=h/p+2|0,m=0,C==1){for(d=0,_=_[0],h++;(m<S||d)&&h--;m++)x=d*c+(q[m]||0),A[m]=x/_|0,d=x%_|0;y=d||m<S}else{for(d=c/(_[0]+1)|0,d>1&&(_=o(_,d,c),q=o(q,d,c),C=_.length,S=q.length),K=C,w=q.slice(0,C),k=w.length;k<C;)w[k++]=0;L=_.slice(),L.unshift(0),B=_[0],_[1]>=c/2&&++B;do d=0,u=e(_,w,C,k),u<0?(I=w[0],C!=k&&(I=I*c+(w[1]||0)),d=I/B|0,d>1?(d>=c&&(d=c-1),f=o(_,d,c),b=f.length,k=w.length,u=e(f,w,b,k),u==1&&(d--,t(f,C<b?L:_,b,c))):(d==0&&(u=d=1),f=_.slice()),b=f.length,b<k&&f.unshift(0),t(w,f,k,c),u==-1&&(k=w.length,u=e(_,w,C,k),u<1&&(d++,t(w,C<k?L:_,k,c))),k=w.length):u===0&&(d++,w=[0]),A[m++]=d,u&&w[0]?w[k++]=q[K]||0:(w=[q[K]],k=1);while((K++<S||w[0]!==void 0)&&h--);y=w[0]!==void 0}A[0]||A.shift()}if(p==1)g.e=l,ja=y;else{for(m=1,d=A[0];d>=10;d/=10)m++;g.e=m+l*p-1,ie(g,a?r+g.e+1:r,s,y)}return g}}();function ie(o,e,t,n){var i,r,s,a,c,u,l,m,d,p=o.constructor;e:if(e!=null){if(m=o.d,!m)return o;for(i=1,a=m[0];a>=10;a/=10)i++;if(r=e-i,r<0)r+=re,s=e,l=m[d=0],c=l/tt(10,i-s-1)%10|0;else if(d=Math.ceil((r+1)/re),a=m.length,d>=a)if(n){for(;a++<=d;)m.push(0);l=c=0,i=1,r%=re,s=r-re+1}else break e;else{for(l=a=m[d],i=1;a>=10;a/=10)i++;r%=re,s=r-re+i,c=s<0?0:l/tt(10,i-s-1)%10|0}if(n=n||e<0||m[d+1]!==void 0||(s<0?l:l%tt(10,i-s-1)),u=t<4?(c||n)&&(t==0||t==(o.s<0?3:2)):c>5||c==5&&(t==4||n||t==6&&(r>0?s>0?l/tt(10,i-s):0:m[d-1])%10&1||t==(o.s<0?8:7)),e<1||!m[0])return m.length=0,u?(e-=o.e+1,m[0]=tt(10,(re-e%re)%re),o.e=-e||0):m[0]=o.e=0,o;if(r==0?(m.length=d,a=1,d--):(m.length=d+1,a=tt(10,re-r),m[d]=s>0?(l/tt(10,i-s)%tt(10,s)|0)*a:0),u)for(;;)if(d==0){for(r=1,s=m[0];s>=10;s/=10)r++;for(s=m[0]+=a,a=1;s>=10;s/=10)a++;r!=a&&(o.e++,m[0]==Xt&&(m[0]=1));break}else{if(m[d]+=a,m[d]!=Xt)break;m[d--]=0,a=1}for(r=m.length;m[--r]===0;)m.pop()}return ue&&(o.e>p.maxE?(o.d=null,o.e=NaN):o.e<p.minE&&(o.e=0,o.d=[0])),o}function Jt(o,e,t){if(!o.isFinite())return ou(o);var n,i=o.e,r=ct(o.d),s=r.length;return e?(t&&(n=t-s)>0?r=r.charAt(0)+"."+r.slice(1)+kn(n):s>1&&(r=r.charAt(0)+"."+r.slice(1)),r=r+(o.e<0?"e":"e+")+o.e):i<0?(r="0."+kn(-i-1)+r,t&&(n=t-s)>0&&(r+=kn(n))):i>=s?(r+=kn(i+1-s),t&&(n=t-i-1)>0&&(r=r+"."+kn(n))):((n=i+1)<s&&(r=r.slice(0,n)+"."+r.slice(n)),t&&(n=t-s)>0&&(i+1===s&&(r+="."),r+=kn(n))),r}function Eo(o,e){var t=o[0];for(e*=re;t>=10;t/=10)e++;return e}function Vo(o,e,t){if(e>zl)throw ue=!0,t&&(o.precision=t),Error(Za);return ie(new o(No),e,1,!0)}function Gt(o,e,t){if(e>jr)throw Error(Za);return ie(new o(vo),e,t,!0)}function tu(o){var e=o.length-1,t=e*re+1;if(e=o[e],e){for(;e%10==0;e/=10)t--;for(e=o[0];e>=10;e/=10)t++}return t}function kn(o){for(var e="";o--;)e+="0";return e}function nu(o,e,t,n){var i,r=new o(1),s=Math.ceil(n/re+4);for(ue=!1;;){if(t%2&&(r=r.times(e),Ya(r.d,s)&&(i=!0)),t=bt(t/2),t===0){t=r.d.length-1,i&&r.d[t]===0&&++r.d[t];break}e=e.times(e),Ya(e.d,s)}return ue=!0,r}function Qa(o){return o.d[o.d.length-1]&1}function iu(o,e,t){for(var n,i=new o(e[0]),r=0;++r<e.length;)if(n=new o(e[r]),n.s)i[t](n)&&(i=n);else{i=n;break}return i}function Zr(o,e){var t,n,i,r,s,a,c,u=0,l=0,m=0,d=o.constructor,p=d.rounding,y=d.precision;if(!o.d||!o.d[0]||o.e>17)return new d(o.d?o.d[0]?o.s<0?0:1/0:1:o.s?o.s<0?0:o:0/0);for(e==null?(ue=!1,c=y):c=e,a=new d(.03125);o.e>-2;)o=o.times(a),m+=5;for(n=Math.log(tt(2,m))/Math.LN10*2+5|0,c+=n,t=r=s=new d(1),d.precision=c;;){if(r=ie(r.times(o),c,1),t=t.times(++l),a=s.plus(Oe(r,t,c,1)),ct(a.d).slice(0,c)===ct(s.d).slice(0,c)){for(i=m;i--;)s=ie(s.times(s),c,1);if(e==null)if(u<3&&Si(s.d,c-n,p,u))d.precision=c+=10,t=r=a=new d(1),l=0,u++;else return ie(s,d.precision=y,p,ue=!0);else return d.precision=y,s}s=a}}function hn(o,e){var t,n,i,r,s,a,c,u,l,m,d,p=1,y=10,f=o,b=f.d,g=f.constructor,A=g.rounding,w=g.precision;if(f.s<0||!b||!b[0]||!f.e&&b[0]==1&&b.length==1)return new g(b&&!b[0]?-1/0:f.s!=1?NaN:b?0:f);if(e==null?(ue=!1,l=w):l=e,g.precision=l+=y,t=ct(b),n=t.charAt(0),Math.abs(r=f.e)<15e14){for(;n<7&&n!=1||n==1&&t.charAt(1)>3;)f=f.times(o),t=ct(f.d),n=t.charAt(0),p++;r=f.e,n>1?(f=new g("0."+t),r++):f=new g(n+"."+t.slice(1))}else return u=Vo(g,l+2,w).times(r+""),f=hn(new g(n+"."+t.slice(1)),l-y).plus(u),g.precision=w,e==null?ie(f,w,A,ue=!0):f;for(m=f,c=s=f=Oe(f.minus(1),f.plus(1),l,1),d=ie(f.times(f),l,1),i=3;;){if(s=ie(s.times(d),l,1),u=c.plus(Oe(s,new g(i),l,1)),ct(u.d).slice(0,l)===ct(c.d).slice(0,l))if(c=c.times(2),r!==0&&(c=c.plus(Vo(g,l+2,w).times(r+""))),c=Oe(c,new g(p),l,1),e==null)if(Si(c.d,l-y,A,a))g.precision=l+=y,u=s=f=Oe(m.minus(1),m.plus(1),l,1),d=ie(f.times(f),l,1),i=a=1;else return ie(c,g.precision=w,A,ue=!0);else return g.precision=w,c;c=u,i+=2}}function ou(o){return String(o.s*o.s/0)}function $r(o,e){var t,n,i;for((t=e.indexOf("."))>-1&&(e=e.replace(".","")),(n=e.search(/e/i))>0?(t<0&&(t=n),t+=+e.slice(n+1),e=e.substring(0,n)):t<0&&(t=e.length),n=0;e.charCodeAt(n)===48;n++);for(i=e.length;e.charCodeAt(i-1)===48;--i);if(e=e.slice(n,i),e){if(i-=n,o.e=t=t-n-1,o.d=[],n=(t+1)%re,t<0&&(n+=re),n<i){for(n&&o.d.push(+e.slice(0,n)),i-=re;n<i;)o.d.push(+e.slice(n,n+=re));e=e.slice(n),n=re-e.length}else n-=i;for(;n--;)e+="0";o.d.push(+e),ue&&(o.e>o.constructor.maxE?(o.d=null,o.e=NaN):o.e<o.constructor.minE&&(o.e=0,o.d=[0]))}else o.e=0,o.d=[0];return o}function Yl(o,e){var t,n,i,r,s,a,c,u,l;if(e.indexOf("_")>-1){if(e=e.replace(/(\d)_(?=\d)/g,"$1"),eu.test(e))return $r(o,e)}else if(e==="Infinity"||e==="NaN")return+e||(o.s=NaN),o.e=NaN,o.d=null,o;if(Ul.test(e))t=16,e=e.toLowerCase();else if(ql.test(e))t=2;else if(Gl.test(e))t=8;else throw Error(Tn+e);for(r=e.search(/p/i),r>0?(c=+e.slice(r+1),e=e.substring(2,r)):e=e.slice(2),r=e.indexOf("."),s=r>=0,n=o.constructor,s&&(e=e.replace(".",""),a=e.length,r=a-r,i=nu(n,new n(t),r,r*2)),u=Mo(e,t,Xt),l=u.length-1,r=l;u[r]===0;--r)u.pop();return r<0?new n(o.s*0):(o.e=Eo(u,l),o.d=u,ue=!1,s&&(o=Oe(o,i,a*4)),c&&(o=o.times(Math.abs(c)<54?tt(2,c):Ci.pow(2,c))),ue=!0,o)}function Hl(o,e){var t,n=e.d.length;if(n<3)return e.isZero()?e:ui(o,2,e,e);t=1.4*Math.sqrt(n),t=t>16?16:t|0,e=e.times(1/Fo(5,t)),e=ui(o,2,e,e);for(var i,r=new o(5),s=new o(16),a=new o(20);t--;)i=e.times(e),e=e.times(r.plus(i.times(s.times(i).minus(a))));return e}function ui(o,e,t,n,i){var r,s,a,c,u=1,l=o.precision,m=Math.ceil(l/re);for(ue=!1,c=t.times(t),a=new o(n);;){if(s=Oe(a.times(c),new o(e++*e++),l,1),a=i?n.plus(s):n.minus(s),n=Oe(s.times(c),new o(e++*e++),l,1),s=a.plus(n),s.d[m]!==void 0){for(r=m;s.d[r]===a.d[r]&&r--;);if(r==-1)break}r=a,a=n,n=s,s=r,u++}return ue=!0,s.d.length=m+1,s}function Fo(o,e){for(var t=o;--e;)t*=o;return t}function ru(o,e){var t,n=e.s<0,i=Gt(o,o.precision,1),r=i.times(.5);if(e=e.abs(),e.lte(r))return un=n?4:1,e;if(t=e.divToInt(i),t.isZero())un=n?3:2;else{if(e=e.minus(t.times(i)),e.lte(r))return un=Qa(t)?n?2:3:n?4:1,e;un=Qa(t)?n?1:4:n?3:2}return e.minus(i).abs()}function Jr(o,e,t,n){var i,r,s,a,c,u,l,m,d,p=o.constructor,y=t!==void 0;if(y?(St(t,1,In),n===void 0?n=p.rounding:St(n,0,8)):(t=p.precision,n=p.rounding),!o.isFinite())l=ou(o);else{for(l=Jt(o),s=l.indexOf("."),y?(i=2,e==16?t=t*4-3:e==8&&(t=t*3-2)):i=e,s>=0&&(l=l.replace(".",""),d=new p(1),d.e=l.length-s,d.d=Mo(Jt(d),10,i),d.e=d.d.length),m=Mo(l,10,i),r=c=m.length;m[--c]==0;)m.pop();if(!m[0])l=y?"0p+0":"0";else{if(s<0?r--:(o=new p(o),o.d=m,o.e=r,o=Oe(o,d,t,n,0,i),m=o.d,r=o.e,u=ja),s=m[t],a=i/2,u=u||m[t+1]!==void 0,u=n<4?(s!==void 0||u)&&(n===0||n===(o.s<0?3:2)):s>a||s===a&&(n===4||u||n===6&&m[t-1]&1||n===(o.s<0?8:7)),m.length=t,u)for(;++m[--t]>i-1;)m[t]=0,t||(++r,m.unshift(1));for(c=m.length;!m[c-1];--c);for(s=0,l="";s<c;s++)l+=Yr.charAt(m[s]);if(y){if(c>1)if(e==16||e==8){for(s=e==16?4:3,--c;c%s;c++)l+="0";for(m=Mo(l,i,e),c=m.length;!m[c-1];--c);for(s=1,l="1.";s<c;s++)l+=Yr.charAt(m[s])}else l=l.charAt(0)+"."+l.slice(1);l=l+(r<0?"p":"p+")+r}else if(r<0){for(;++r;)l="0"+l;l="0."+l}else if(++r>c)for(r-=c;r--;)l+="0";else r<c&&(l=l.slice(0,r)+"."+l.slice(r))}l=(e==16?"0x":e==2?"0b":e==8?"0o":"")+l}return o.s<0?"-"+l:l}function Ya(o,e){if(o.length>e)return o.length=e,!0}function jl(o){return new this(o).abs()}function Zl(o){return new this(o).acos()}function $l(o){return new this(o).acosh()}function Jl(o,e){return new this(o).plus(e)}function em(o){return new this(o).asin()}function tm(o){return new this(o).asinh()}function nm(o){return new this(o).atan()}function im(o){return new this(o).atanh()}function om(o,e){o=new this(o),e=new this(e);var t,n=this.precision,i=this.rounding,r=n+4;return!o.s||!e.s?t=new this(NaN):!o.d&&!e.d?(t=Gt(this,r,1).times(e.s>0?.25:.75),t.s=o.s):!e.d||o.isZero()?(t=e.s<0?Gt(this,n,i):new this(0),t.s=o.s):!o.d||e.isZero()?(t=Gt(this,r,1).times(.5),t.s=o.s):e.s<0?(this.precision=r,this.rounding=1,t=this.atan(Oe(o,e,r,1)),e=Gt(this,r,1),this.precision=n,this.rounding=i,t=o.s<0?t.minus(e):t.plus(e)):t=this.atan(Oe(o,e,r,1)),t}function rm(o){return new this(o).cbrt()}function sm(o){return ie(o=new this(o),o.e+1,2)}function am(o,e,t){return new this(o).clamp(e,t)}function um(o){if(!o||typeof o!="object")throw Error(_o+"Object expected");var e,t,n,i=o.defaults===!0,r=["precision",1,In,"rounding",0,8,"toExpNeg",-ai,0,"toExpPos",0,ai,"maxE",0,ai,"minE",-ai,0,"modulo",0,9];for(e=0;e<r.length;e+=3)if(t=r[e],i&&(this[t]=Hr[t]),(n=o[t])!==void 0)if(bt(n)===n&&n>=r[e+1]&&n<=r[e+2])this[t]=n;else throw Error(Tn+t+": "+n);if(t="crypto",i&&(this[t]=Hr[t]),(n=o[t])!==void 0)if(n===!0||n===!1||n===0||n===1)if(n)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[t]=!0;else throw Error($a);else this[t]=!1;else throw Error(Tn+t+": "+n);return this}function cm(o){return new this(o).cos()}function lm(o){return new this(o).cosh()}function su(o){var e,t,n;function i(r){var s,a,c,u=this;if(!(u instanceof i))return new i(r);if(u.constructor=i,Ha(r)){u.s=r.s,ue?!r.d||r.e>i.maxE?(u.e=NaN,u.d=null):r.e<i.minE?(u.e=0,u.d=[0]):(u.e=r.e,u.d=r.d.slice()):(u.e=r.e,u.d=r.d?r.d.slice():r.d);return}if(c=typeof r,c==="number"){if(r===0){u.s=1/r<0?-1:1,u.e=0,u.d=[0];return}if(r<0?(r=-r,u.s=-1):u.s=1,r===~~r&&r<1e7){for(s=0,a=r;a>=10;a/=10)s++;ue?s>i.maxE?(u.e=NaN,u.d=null):s<i.minE?(u.e=0,u.d=[0]):(u.e=s,u.d=[r]):(u.e=s,u.d=[r]);return}else if(r*0!==0){r||(u.s=NaN),u.e=NaN,u.d=null;return}return $r(u,r.toString())}else if(c!=="string")throw Error(Tn+r);return(a=r.charCodeAt(0))===45?(r=r.slice(1),u.s=-1):(a===43&&(r=r.slice(1)),u.s=1),eu.test(r)?$r(u,r):Yl(u,r)}if(i.prototype=U,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=um,i.clone=su,i.isDecimal=Ha,i.abs=jl,i.acos=Zl,i.acosh=$l,i.add=Jl,i.asin=em,i.asinh=tm,i.atan=nm,i.atanh=im,i.atan2=om,i.cbrt=rm,i.ceil=sm,i.clamp=am,i.cos=cm,i.cosh=lm,i.div=mm,i.exp=dm,i.floor=pm,i.hypot=fm,i.ln=ym,i.log=bm,i.log10=Pm,i.log2=gm,i.max=Am,i.min=wm,i.mod=km,i.mul=hm,i.pow=Tm,i.random=Im,i.round=Bm,i.sign=xm,i.sin=Km,i.sinh=Sm,i.sqrt=Cm,i.sub=Lm,i.sum=Rm,i.tan=Om,i.tanh=Mm,i.trunc=Nm,o===void 0&&(o={}),o&&o.defaults!==!0)for(n=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],e=0;e<n.length;)o.hasOwnProperty(t=n[e++])||(o[t]=this[t]);return i.config(o),i}function mm(o,e){return new this(o).div(e)}function dm(o){return new this(o).exp()}function pm(o){return ie(o=new this(o),o.e+1,3)}function fm(){var o,e,t=new this(0);for(ue=!1,o=0;o<arguments.length;)if(e=new this(arguments[o++]),e.d)t.d&&(t=t.plus(e.times(e)));else{if(e.s)return ue=!0,new this(1/0);t=e}return ue=!0,t.sqrt()}function Ha(o){return o instanceof Ci||o&&o.toStringTag===Ja||!1}function ym(o){return new this(o).ln()}function bm(o,e){return new this(o).log(e)}function gm(o){return new this(o).log(2)}function Pm(o){return new this(o).log(10)}function Am(){return iu(this,arguments,"lt")}function wm(){return iu(this,arguments,"gt")}function km(o,e){return new this(o).mod(e)}function hm(o,e){return new this(o).mul(e)}function Tm(o,e){return new this(o).pow(e)}function Im(o){var e,t,n,i,r=0,s=new this(1),a=[];if(o===void 0?o=this.precision:St(o,1,In),n=Math.ceil(o/re),this.crypto)if(crypto.getRandomValues)for(e=crypto.getRandomValues(new Uint32Array(n));r<n;)i=e[r],i>=429e7?e[r]=crypto.getRandomValues(new Uint32Array(1))[0]:a[r++]=i%1e7;else if(crypto.randomBytes){for(e=crypto.randomBytes(n*=4);r<n;)i=e[r]+(e[r+1]<<8)+(e[r+2]<<16)+((e[r+3]&127)<<24),i>=214e7?crypto.randomBytes(4).copy(e,r):(a.push(i%1e7),r+=4);r=n/4}else throw Error($a);else for(;r<n;)a[r++]=Math.random()*1e7|0;for(n=a[--r],o%=re,n&&o&&(i=tt(10,re-o),a[r]=(n/i|0)*i);a[r]===0;r--)a.pop();if(r<0)t=0,a=[0];else{for(t=-1;a[0]===0;t-=re)a.shift();for(n=1,i=a[0];i>=10;i/=10)n++;n<re&&(t-=re-n)}return s.e=t,s.d=a,s}function Bm(o){return ie(o=new this(o),o.e+1,this.rounding)}function xm(o){return o=new this(o),o.d?o.d[0]?o.s:0*o.s:o.s||NaN}function Km(o){return new this(o).sin()}function Sm(o){return new this(o).sinh()}function Cm(o){return new this(o).sqrt()}function Lm(o,e){return new this(o).sub(e)}function Rm(){var o=0,e=arguments,t=new this(e[o]);for(ue=!1;t.s&&++o<e.length;)t=t.plus(e[o]);return ue=!0,ie(t,this.precision,this.rounding)}function Om(o){return new this(o).tan()}function Mm(o){return new this(o).tanh()}function Nm(o){return ie(o=new this(o),o.e+1,1)}U[Symbol.for("nodejs.util.inspect.custom")]=U.toString;U[Symbol.toStringTag]="Decimal";var Ci=U.constructor=su(Hr);No=new Ci(No);vo=new Ci(vo);var V=Ci;import Dm from"big.js";import Bn from"bn.js";import vm from"toformat";var Vm=vm,Li=Vm;import Do from"big.js";import _m from"bn.js";import Em from"decimal.js-light";import Ri from"bn.js";var es=(n=>(n[n.ROUND_DOWN=0]="ROUND_DOWN",n[n.ROUND_HALF_UP=1]="ROUND_HALF_UP",n[n.ROUND_UP=2]="ROUND_UP",n))(es||{}),au=9007199254740991;function ne(o){let e=ye("Raydium_parseBigNumberish");if(o instanceof Ri)return o;if(typeof o=="string"){if(o.match(/^-?[0-9]+$/))return new Ri(o);e.logWithError(`invalid BigNumberish string: ${o}`)}return typeof o=="number"?(o%1&&e.logWithError(`BigNumberish number underflow: ${o}`),(o>=au||o<=-au)&&e.logWithError(`BigNumberish number overflow: ${o}`),new Ri(String(o))):typeof o=="bigint"?new Ri(o.toString()):(e.error(`invalid BigNumberish value: ${o}`),new Ri(0))}var Wo=ye("module/fraction"),ts=Li(Do),Oi=Li(Em),Fm={[0]:Oi.ROUND_DOWN,[1]:Oi.ROUND_HALF_UP,[2]:Oi.ROUND_UP},Wm={[0]:Do.roundDown,[1]:Do.roundHalfUp,[2]:Do.roundUp},le=class{constructor(e,t=new _m(1)){this.numerator=ne(e),this.denominator=ne(t)}get quotient(){return this.numerator.div(this.denominator)}invert(){return new le(this.denominator,this.numerator)}add(e){let t=e instanceof le?e:new le(ne(e));return this.denominator.eq(t.denominator)?new le(this.numerator.add(t.numerator),this.denominator):new le(this.numerator.mul(t.denominator).add(t.numerator.mul(this.denominator)),this.denominator.mul(t.denominator))}sub(e){let t=e instanceof le?e:new le(ne(e));return this.denominator.eq(t.denominator)?new le(this.numerator.sub(t.numerator),this.denominator):new le(this.numerator.mul(t.denominator).sub(t.numerator.mul(this.denominator)),this.denominator.mul(t.denominator))}mul(e){let t=e instanceof le?e:new le(ne(e));return new le(this.numerator.mul(t.numerator),this.denominator.mul(t.denominator))}div(e){let t=e instanceof le?e:new le(ne(e));return new le(this.numerator.mul(t.denominator),this.denominator.mul(t.numerator))}toSignificant(e,t={groupSeparator:""},n=1){Number.isInteger(e)||Wo.logWithError(`${e} is not an integer.`),e<=0&&Wo.logWithError(`${e} is not positive.`),Oi.set({precision:e+1,rounding:Fm[n]});let i=new Oi(this.numerator.toString()).div(this.denominator.toString()).toSignificantDigits(e);return i.toFormat(i.decimalPlaces(),t)}toFixed(e,t={groupSeparator:""},n=1){return Number.isInteger(e)||Wo.logWithError(`${e} is not an integer.`),e<0&&Wo.logWithError(`${e} is negative.`),ts.DP=e,ts.RM=Wm[n]||1,new ts(this.numerator.toString()).div(this.denominator.toString()).toFormat(e,t)}isZero(){return this.numerator.isZero()}};var qm=ye("Raydium_amount"),qo=Li(Dm);function uu(o,e){let t="0",n="0";if(o.includes(".")){let i=o.split(".");i.length===2?([t,n]=i,n=n.padEnd(e,"0")):qm.logWithError(`invalid number string, num: ${o}`)}else t=o;return[t,n.slice(0,e)||n]}var we=class extends le{constructor(t,n,i=!0,r){let s=new Bn(0),a=Dn.pow(new Bn(t.decimals));if(i)s=ne(n);else{let c=new Bn(0),u=new Bn(0);if(typeof n=="string"||typeof n=="number"||typeof n=="bigint"){let[l,m]=uu(n.toString(),t.decimals);c=ne(l),u=ne(m)}c=c.mul(a),s=c.add(u)}super(s,a);this.logger=ye(r||"TokenAmount"),this.token=t}get raw(){return this.numerator}isZero(){return this.raw.isZero()}gt(t){return this.token.equals(t.token)||this.logger.logWithError("gt token not equals"),this.raw.gt(t.raw)}lt(t){return this.token.equals(t.token)||this.logger.logWithError("lt token not equals"),this.raw.lt(t.raw)}add(t){return this.token.equals(t.token)||this.logger.logWithError("add token not equals"),new we(this.token,this.raw.add(t.raw))}subtract(t){return this.token.equals(t.token)||this.logger.logWithError("sub token not equals"),new we(this.token,this.raw.sub(t.raw))}toSignificant(t=this.token.decimals,n,i=0){return super.toSignificant(t,n,i)}toFixed(t=this.token.decimals,n,i=0){return t>this.token.decimals&&this.logger.logWithError("decimals overflow"),super.toFixed(t,n,i)}toExact(t={groupSeparator:""}){return qo.DP=this.token.decimals,new qo(this.numerator.toString()).div(this.denominator.toString()).toFormat(t)}},Wn=class extends le{constructor(t,n,i=!0,r){let s=new Bn(0),a=Dn.pow(new Bn(t.decimals));if(i)s=ne(n);else{let c=new Bn(0),u=new Bn(0);if(typeof n=="string"||typeof n=="number"||typeof n=="bigint"){let[l,m]=uu(n.toString(),t.decimals);c=ne(l),u=ne(m)}c=c.mul(a),s=c.add(u)}super(s,a);this.logger=ye(r||"TokenAmount"),this.currency=t}get raw(){return this.numerator}isZero(){return this.raw.isZero()}gt(t){return this.currency.equals(t.currency)||this.logger.logWithError("gt currency not equals"),this.raw.gt(t.raw)}lt(t){return this.currency.equals(t.currency)||this.logger.logWithError("lt currency not equals"),this.raw.lt(t.raw)}add(t){return this.currency.equals(t.currency)||this.logger.logWithError("add currency not equals"),new Wn(this.currency,this.raw.add(t.raw))}sub(t){return this.currency.equals(t.currency)||this.logger.logWithError("sub currency not equals"),new Wn(this.currency,this.raw.sub(t.raw))}toSignificant(t=this.currency.decimals,n,i=0){return super.toSignificant(t,n,i)}toFixed(t=this.currency.decimals,n,i=0){return t>this.currency.decimals&&this.logger.logWithError("decimals overflow"),super.toFixed(t,n,i)}toExact(t={groupSeparator:""}){return qo.DP=this.currency.decimals,new qo(this.numerator.toString()).div(this.denominator.toString()).toFormat(t)}};import{PublicKey as Um}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as cu}from"@solana/spl-token";var en={chainId:101,address:Um.default.toBase58(),programId:cu.toBase58(),decimals:9,symbol:"SOL",name:"solana",logoURI:"https://img-v1.raydium.io/icon/So11111111111111111111111111111111111111112.png",tags:[],priority:2,type:"raydium",extensions:{coingeckoId:"solana"}},ot={chainId:101,address:"So11111111111111111111111111111111111111112",programId:cu.toBase58(),decimals:9,symbol:"WSOL",name:"Wrapped SOL",logoURI:"https://img-v1.raydium.io/icon/So11111111111111111111111111111111111111112.png",tags:[],priority:2,type:"raydium",extensions:{coingeckoId:"solana"}};import{PublicKey as ss}from"@solana/web3.js";import{PublicKey as ve,SystemProgram as lu,SYSVAR_RENT_PUBKEY as Gm}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as Xm}from"@solana/spl-token";function P({pubkey:o,isSigner:e=!1,isWritable:t=!0}){return{pubkey:o,isWritable:t,isSigner:e}}var ns=[P({pubkey:Xm,isWritable:!1}),P({pubkey:lu.programId,isWritable:!1}),P({pubkey:Gm,isWritable:!1})];function is({publicKey:o,transformSol:e}){let t=os(o.toString());if(t instanceof ve)return e&&t.equals(rt)?$:t;if(e&&t.toString()===rt.toBase58())return $;if(typeof t=="string"){if(t===ve.default.toBase58())return ve.default;try{return new ve(t)}catch{throw new Error("invalid public key")}}throw new Error("invalid public key")}function os(o){try{return new ve(o)}catch{return o}}var qn=new ve("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),tn=new ve("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),Qe=new ve("SysvarRent111111111111111111111111111111111"),rs=new ve("SysvarC1ock11111111111111111111111111111111"),cn=new ve("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"),Uo=new ve("Sysvar1nstructions1111111111111111111111111"),Go=lu.programId,yb=new ve("4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R"),bb=new ve("Ea5SjE2Y6yvCeW5dYTn7PYMuW5ikXkvbGdcmSnXeaLjS"),gb=new ve("SRMuApVNdxXokk5GT7XD5cUUgXMBCoAz2LHeuAoKWRt"),Pb=new ve("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"),Ab=new ve("Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB"),wb=new ve("mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So"),kb=new ve("7dHbWXmci3dT8UFYWYZweBLXgycu7Y3iL6trKn1Y7ARj"),hb=new ve("USDH1SM1ojwWUga67PGrgFWUHibbjqMvuMaDkRJTgkX"),Tb=new ve("NRVwhjBQiUPYtfDT5zRBVJajzFQHaBUNtC7SNVvqRFa"),Ib=new ve("ANAxByE6G2WjFp7A4NqtWYXb3mgruyzZYg3spfxe6Lbo"),Bb=new ve("7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs"),$=new ve("So11111111111111111111111111111111111111112"),rt=ve.default;function yt(o){return is({publicKey:o,transformSol:!0})}var as=class{constructor({mint:e,decimals:t,symbol:n,name:i,skipMint:r=!1,isToken2022:s=!1}){if(e===rt.toBase58()||e instanceof ss&&rt.equals(e)){this.decimals=ot.decimals,this.symbol=ot.symbol,this.name=ot.name,this.mint=new ss(ot.address),this.isToken2022=!1;return}this.decimals=t,this.symbol=n||e.toString().substring(0,6),this.name=i||e.toString().substring(0,6),this.mint=r?ss.default:is({publicKey:e}),this.isToken2022=s}equals(e){return this===e?!0:this.mint.equals(e.mint)}},xe=as;xe.WSOL=new as(X(M({},ot),{mint:ot.address}));var us=class{constructor({decimals:e,symbol:t="UNKNOWN",name:n="UNKNOWN"}){this.decimals=e,this.symbol=t,this.name=n}equals(e){return this===e}},Mi=us;Mi.SOL=new us(en);function Nb(o,e){return o instanceof xe&&e instanceof xe?o.equals(e):o instanceof xe||e instanceof xe?!1:o===e}import zm from"bn.js";var mu=new le(new zm(100)),De=class extends le{toSignificant(e=5,t,n){return this.mul(mu).toSignificant(e,t,n)}toFixed(e=2,t,n){return this.mul(mu).toFixed(e,t,n)}};var Qm=ye("Raydium_price"),st=class extends le{constructor(t){let{baseToken:n,quoteToken:i,numerator:r,denominator:s}=t;super(r,s);this.baseToken=n,this.quoteToken=i,this.scalar=new le(cs(n.decimals),cs(i.decimals))}get raw(){return new le(this.numerator,this.denominator)}get adjusted(){return super.mul(this.scalar)}invert(){return new st({baseToken:this.quoteToken,quoteToken:this.baseToken,denominator:this.numerator,numerator:this.denominator})}mul(t){this.quoteToken!==t.baseToken&&Qm.logWithError("mul token not equals");let n=super.mul(t);return new st({baseToken:this.baseToken,quoteToken:t.quoteToken,denominator:n.denominator,numerator:n.numerator})}toSignificant(t=this.quoteToken.decimals,n,i){return this.adjusted.toSignificant(t,n,i)}toFixed(t=this.quoteToken.decimals,n,i){return this.adjusted.toFixed(t,n,i)}};function Ye(o){if(o instanceof De)return new le(o.numerator,o.denominator);if(o instanceof st)return o.adjusted;if(o instanceof we)try{return Ye(o.toExact())}catch{return new le(He)}if(o instanceof le)return o;let e=String(o),t=Un(e);return new le(t.numerator,t.denominator)}function tg(o){var n;if(o instanceof De)return{fr:new le(o.numerator,o.denominator)};if(o instanceof st)return{fr:o.adjusted};if(o instanceof we)return{fr:Ye(o.toExact()),decimals:o.token.decimals};if(o instanceof le)return{fr:o};let e=String(o),t=Un(e);return{fr:new le(t.numerator,t.denominator),decimals:(n=t.dec)==null?void 0:n.length}}function ng(o,e){if(o==null||e==null)return!1;let t=Ye(o),n=Ye(e);return t.sub(n).numerator,t.sub(n).numerator.lt(He)}function Ym(o,e){if(o==null||e==null)return!1;let t=Ye(o),n=Ye(e);return t.sub(n).numerator.gt(He)}function ig(o,e){if(o==null||e==null)return!1;let t=Ye(o),n=Ye(e);return t.sub(n).numerator.lte(He)}function og(o,e){if(o==null||e==null)return!1;let t=Ye(o),n=Ye(e);return t.sub(n).numerator.gte(He)}function Hm(o,e){if(o==null||e==null)return!1;let t=Ye(o),n=Ye(e);return t.sub(n).numerator.eq(He)}function rg(o,e){if(o==null||e==null)return;let t=Ye(o),n=Ye(e);try{return t.div(n)}catch{return t}}function sg(o,e){if(o==null||e==null)return;let t=Ye(o),n=Ye(e);return t.sub(n)}function ag(o){return o==null?!1:!Hm(o,0)}function ug(o,e){return Ym(e,o)?e:o}function ls(o,e){if(o==null||e==null)return;let t=Ye(o),n=Ye(e);return t.mul(n)}function cg(o,e){if(o==null||e==null)return;let t=Ye(o),n=Ye(e);return t.add(n)}import{PublicKey as jm}from"@solana/web3.js";import Zm from"bn.js";async function du(o){new Promise(e=>setTimeout(e,o))}function yg(){return new Date().getTime()}function ms(o){return typeof o=="object"&&o!==null&&![xe,we,jm,le,Zm,st,De].some(e=>typeof e=="object"&&o instanceof e)}function Me(o){return typeof o=="string"?os(o):Array.isArray(o)?o.map(e=>Me(e)):ms(o)?Object.fromEntries(Object.entries(o).map(([e,t])=>[e,Me(t)])):o}var He=new je(0),yu=new je(1),Sg=new je(2),Cg=new je(3),Lg=new je(5),Dn=new je(10),Rg=new je(100),Og=new je(1e3),Mg=new je(1e4);function cs(o){return Dn.pow(ne(o))}function Un(o){var a;if(o===void 0)return{denominator:"1",numerator:"0"};if(o instanceof je)return{numerator:o.toString(),denominator:"1"};if(o instanceof le)return{denominator:o.denominator.toString(),numerator:o.numerator.toString()};let e=String(o),[,t="",n="",i=""]=(a=e.replace(",","").match(/(-?)(\d*)\.?(\d*)/))!=null?a:[],r="1"+"0".repeat(i.length),s=t+(n==="0"?"":n)+i||"0";return{denominator:r,numerator:s,sign:t,int:n,dec:i}}function Xo(o,e){let t=o.divmod(e);return t.mod.isZero()?t.div:t.div.isNeg()?t.div.isubn(1):t.div.iaddn(1)}function $m(o){var n;let[,e="",t=""]=(n=o.toFixed(2).match(/(-?)(\d*)\.?(\d*)/))!=null?n:[];return`${e}${t}`}function Jm(o,e=0){return o instanceof je?o:new je($m(bu(o).mul(Dn.pow(new je(String(e))))))}function bu(o){if(o instanceof De)return new le(o.numerator,o.denominator);if(o instanceof st)return o.adjusted;if(o instanceof we)try{return bu(o.toExact())}catch{return new le(He)}if(o instanceof le)return o;let e=String(o),t=Un(e);return new le(t.numerator,t.denominator)}function Ng(o,e){let{numerator:t,denominator:n}=Un(o);return new De(new je(t),new je(n).mul(e!=null&&e.alreadyDecimaled?new je(100):new je(1)))}function vg(o){let{token:e,numberPrice:t,decimalDone:n}=o,i=new xe({mint:"",decimals:6,symbol:"usd",name:"usd",skipMint:!0}),{numerator:r,denominator:s}=Un(t),a=n?new je(r).mul(Dn.pow(new je(e.decimals))):r,c=new je(s).mul(Dn.pow(new je(i.decimals)));return new st({baseToken:i,denominator:c.toString(),quoteToken:new xe(X(M({},e),{skipMint:!0,mint:""})),numerator:a.toString()})}function pu(o){let e=new Mi({decimals:6,symbol:"usd",name:"usd"}),t=Jm(ls(o,10**e.decimals));return new Wn(e,t)}function Vg(o,e){return pu(!e||!o?0:ls(o,e))}function ed(o){if(o==null)return;let{numerator:e,denominator:t}=Un(o.toString());return new le(e,t)}function td(o){return o instanceof V}function fu(o){return td(o)?ed(o):Array.isArray(o)?o.map(e=>fu(e)):ms(o)?Object.fromEntries(Object.entries(o).map(([e,t])=>[e,fu(t)])):o}var gu=o=>typeof o=="number",Pu=o=>o?new Date(o):new Date,nd=o=>Pu(o).getTime();function Au(o,e,t){let n=gu(e)?e*((t==null?void 0:t.unit)==="s"?1e3:1):e;return new Date(o).getTime()<=n}function wu(o,e,t){let n=gu(e)?e*((t==null?void 0:t.unit)===