raydium-sdk-v2-custody
Version:
An SDK for building applications on top of Raydium.
1 lines • 227 kB
JavaScript
var Fr=Object.create;var Vt=Object.defineProperty,Dr=Object.defineProperties,vr=Object.getOwnPropertyDescriptor,_r=Object.getOwnPropertyDescriptors,qr=Object.getOwnPropertyNames,fn=Object.getOwnPropertySymbols,Vr=Object.getPrototypeOf,Dn=Object.prototype.hasOwnProperty,Ii=Object.prototype.propertyIsEnumerable;var xi=(o,e,t)=>e in o?Vt(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,F=(o,e)=>{for(var t in e||(e={}))Dn.call(e,t)&&xi(o,t,e[t]);if(fn)for(var t of fn(e))Ii.call(e,t)&&xi(o,t,e[t]);return o},Y=(o,e)=>Dr(o,_r(e));var Ot=(o,e)=>{var t={};for(var n in o)Dn.call(o,n)&&e.indexOf(n)<0&&(t[n]=o[n]);if(o!=null&&fn)for(var n of fn(o))e.indexOf(n)<0&&Ii.call(o,n)&&(t[n]=o[n]);return t};var Ur=(o,e)=>{for(var t in e)Vt(o,t,{get:e[t],enumerable:!0})},Si=(o,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of qr(e))!Dn.call(o,i)&&i!==t&&Vt(o,i,{get:()=>e[i],enumerable:!(n=vr(e,i))||n.enumerable});return o};var Te=(o,e,t)=>(t=o!=null?Fr(Vr(o)):{},Si(e||!o||!o.__esModule?Vt(t,"default",{value:o,enumerable:!0}):t,o)),Gr=o=>Si(Vt({},"__esModule",{value:!0}),o);var Ts={};Ur(Ts,{Clmm:()=>Ti});module.exports=Gr(Ts);var M=require("@solana/web3.js"),Be=Te(require("bn.js"));var Et=9e15,Pt=1e9,vn="0123456789abcdef",bn="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",gn="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",_n={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-Et,maxE:Et,crypto:!1},Ni,dt,Z=!0,Pn="[DecimalError] ",wt=Pn+"Invalid argument: ",Mi=Pn+"Precision limit exceeded",Ri=Pn+"crypto unavailable",Oi="[object Decimal]",Fe=Math.floor,Se=Math.pow,Xr=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,zr=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,Hr=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,Ei=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,$e=1e7,G=7,Zr=9007199254740991,jr=bn.length-1,qn=gn.length-1,C={toStringTag:Oi};C.absoluteValue=C.abs=function(){var o=new this.constructor(this);return o.s<0&&(o.s=1),q(o)};C.ceil=function(){return q(new this.constructor(this),this.e+1,2)};C.clampedTo=C.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(wt+e);return t=n.cmp(o),t<0?o:n.cmp(e)>0?e:new i(n)};C.comparedTo=C.cmp=function(o){var e,t,n,i,r=this,s=r.d,a=(o=new r.constructor(o)).d,u=r.s,c=o.s;if(!s||!a)return!u||!c?NaN:u!==c?u:s===a?0:!s^u<0?1:-1;if(!s[0]||!a[0])return s[0]?u:a[0]?-c:0;if(u!==c)return u;if(r.e!==o.e)return r.e>o.e^u<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]^u<0?1:-1;return n===i?0:n>i^u<0?1:-1};C.cosine=C.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())+G,n.rounding=1,t=Yr(n,_i(n,t)),n.precision=o,n.rounding=e,q(dt==2||dt==3?t.neg():t,o,e,!0)):new n(1):new n(NaN)};C.cubeRoot=C.cbrt=function(){var o,e,t,n,i,r,s,a,u,c,l=this,d=l.constructor;if(!l.isFinite()||l.isZero())return new d(l);for(Z=!1,r=l.s*Se(l.s*l,1/3),!r||Math.abs(r)==1/0?(t=Me(l.d),o=l.e,(r=(o-t.length+1)%3)&&(t+=r==1||r==-2?"0":"00"),r=Se(t,1/3),o=Fe((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 d(t),n.s=l.s):n=new d(r.toString()),s=(o=d.precision)+3;;)if(a=n,u=a.times(a).times(a),c=u.plus(l),n=ye(c.plus(l).times(a),c.plus(u),s+2,1),Me(a.d).slice(0,s)===(t=Me(n.d)).slice(0,s))if(t=t.slice(s-3,s+1),t=="9999"||!i&&t=="4999"){if(!i&&(q(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")&&(q(n,o+1,1),e=!n.times(n).times(n).eq(l));break}return Z=!0,q(n,o,d.rounding,e)};C.decimalPlaces=C.dp=function(){var o,e=this.d,t=NaN;if(e){if(o=e.length-1,t=(o-Fe(this.e/G))*G,o=e[o],o)for(;o%10==0;o/=10)t--;t<0&&(t=0)}return t};C.dividedBy=C.div=function(o){return ye(this,new this.constructor(o))};C.dividedToIntegerBy=C.divToInt=function(o){var e=this,t=e.constructor;return q(ye(e,new t(o),0,1,1),t.precision,t.rounding)};C.equals=C.eq=function(o){return this.cmp(o)===0};C.floor=function(){return q(new this.constructor(this),this.e+1,3)};C.greaterThan=C.gt=function(o){return this.cmp(o)>0};C.greaterThanOrEqualTo=C.gte=function(o){var e=this.cmp(o);return e==1||e===0};C.hyperbolicCosine=C.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/An(4,o)).toString()):(o=16,e="2.3283064365386962890625e-10"),r=Wt(s,1,r.times(e),new s(1),!0);for(var u,c=o,l=new s(8);c--;)u=r.times(r),r=a.minus(u.times(l.minus(u.times(l))));return q(r,s.precision=t,s.rounding=n,!0)};C.hyperbolicSine=C.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=Wt(r,2,i,i,!0);else{o=1.4*Math.sqrt(n),o=o>16?16:o|0,i=i.times(1/An(5,o)),i=Wt(r,2,i,i,!0);for(var s,a=new r(5),u=new r(16),c=new r(20);o--;)s=i.times(i),i=i.times(a.plus(s.times(u.times(s).plus(c))))}return r.precision=e,r.rounding=t,q(i,e,t,!0)};C.hyperbolicTangent=C.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,ye(t.sinh(),t.cosh(),n.precision=o,n.rounding=e)):new n(t.s)};C.inverseCosine=C.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()?Je(t,i,r):new t(0):new t(NaN):e.isZero()?Je(t,i+4,r).times(.5):(t.precision=i+6,t.rounding=1,e=e.asin(),o=Je(t,i+4,r).times(.5),t.precision=i,t.rounding=r,o.minus(e))};C.inverseHyperbolicCosine=C.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,Z=!1,t=t.times(t).minus(1).sqrt().plus(t),Z=!0,n.precision=o,n.rounding=e,t.ln()):new n(t)};C.inverseHyperbolicSine=C.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,Z=!1,t=t.times(t).plus(1).sqrt().plus(t),Z=!0,n.precision=o,n.rounding=e,t.ln())};C.inverseHyperbolicTangent=C.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?q(new r(i),o,e,!0):(r.precision=t=n-i.e,i=ye(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)};C.inverseSine=C.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=Je(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)))};C.inverseTangent=C.atan=function(){var o,e,t,n,i,r,s,a,u,c=this,l=c.constructor,d=l.precision,p=l.rounding;if(c.isFinite()){if(c.isZero())return new l(c);if(c.abs().eq(1)&&d+4<=qn)return s=Je(l,d+4,p).times(.25),s.s=c.s,s}else{if(!c.s)return new l(NaN);if(d+4<=qn)return s=Je(l,d+4,p).times(.5),s.s=c.s,s}for(l.precision=a=d+10,l.rounding=1,t=Math.min(28,a/G+2|0),o=t;o;--o)c=c.div(c.times(c).plus(1).sqrt().plus(1));for(Z=!1,e=Math.ceil(a/G),n=1,u=c.times(c),s=new l(c),i=c;o!==-1;)if(i=i.times(u),r=s.minus(i.div(n+=2)),i=i.times(u),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)),Z=!0,q(s,l.precision=d,l.rounding=p,!0)};C.isFinite=function(){return!!this.d};C.isInteger=C.isInt=function(){return!!this.d&&Fe(this.e/G)>this.d.length-2};C.isNaN=function(){return!this.s};C.isNegative=C.isNeg=function(){return this.s<0};C.isPositive=C.isPos=function(){return this.s>0};C.isZero=function(){return!!this.d&&this.d[0]===0};C.lessThan=C.lt=function(o){return this.cmp(o)<0};C.lessThanOrEqualTo=C.lte=function(o){return this.cmp(o)<1};C.logarithm=C.log=function(o){var e,t,n,i,r,s,a,u,c=this,l=c.constructor,d=l.precision,p=l.rounding,m=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=c.d,c.s<0||!t||!t[0]||c.eq(1))return new l(t&&!t[0]?-1/0:c.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(Z=!1,a=d+m,s=gt(c,a),n=e?wn(l,a+10):gt(o,a),u=ye(s,n,a,1),Ut(u.d,i=d,p))do if(a+=10,s=gt(c,a),n=e?wn(l,a+10):gt(o,a),u=ye(s,n,a,1),!r){+Me(u.d).slice(i+1,i+15)+1==1e14&&(u=q(u,d+1,0));break}while(Ut(u.d,i+=10,p));return Z=!0,q(u,d,p)};C.minus=C.sub=function(o){var e,t,n,i,r,s,a,u,c,l,d,p,m=this,y=m.constructor;if(o=new y(o),!m.d||!o.d)return!m.s||!o.s?o=new y(NaN):m.d?o.s=-o.s:o=new y(o.d||m.s!==o.s?m:NaN),o;if(m.s!=o.s)return o.s=-o.s,m.plus(o);if(c=m.d,p=o.d,a=y.precision,u=y.rounding,!c[0]||!p[0]){if(p[0])o.s=-o.s;else if(c[0])o=new y(m);else return new y(u===3?-0:0);return Z?q(o,a,u):o}if(t=Fe(o.e/G),l=Fe(m.e/G),c=c.slice(),r=l-t,r){for(d=r<0,d?(e=c,r=-r,s=p.length):(e=p,t=l,s=c.length),n=Math.max(Math.ceil(a/G),s)+2,r>n&&(r=n,e.length=1),e.reverse(),n=r;n--;)e.push(0);e.reverse()}else{for(n=c.length,s=p.length,d=n<s,d&&(s=n),n=0;n<s;n++)if(c[n]!=p[n]){d=c[n]<p[n];break}r=0}for(d&&(e=c,c=p,p=e,o.s=-o.s),s=c.length,n=p.length-s;n>0;--n)c[s++]=0;for(n=p.length;n>r;){if(c[--n]<p[n]){for(i=n;i&&c[--i]===0;)c[i]=$e-1;--c[i],c[n]+=$e}c[n]-=p[n]}for(;c[--s]===0;)c.pop();for(;c[0]===0;c.shift())--t;return c[0]?(o.d=c,o.e=kn(c,t),Z?q(o,a,u):o):new y(u===3?-0:0)};C.modulo=C.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]?q(new n(t),n.precision,n.rounding):(Z=!1,n.modulo==9?(e=ye(t,o.abs(),0,3,1),e.s*=o.s):e=ye(t,o,0,n.modulo,1),e=e.times(o),Z=!0,t.minus(e))};C.naturalExponential=C.exp=function(){return Vn(this)};C.naturalLogarithm=C.ln=function(){return gt(this)};C.negated=C.neg=function(){var o=new this.constructor(this);return o.s=-o.s,q(o)};C.plus=C.add=function(o){var e,t,n,i,r,s,a,u,c,l,d=this,p=d.constructor;if(o=new p(o),!d.d||!o.d)return!d.s||!o.s?o=new p(NaN):d.d||(o=new p(o.d||d.s===o.s?d:NaN)),o;if(d.s!=o.s)return o.s=-o.s,d.minus(o);if(c=d.d,l=o.d,a=p.precision,u=p.rounding,!c[0]||!l[0])return l[0]||(o=new p(d)),Z?q(o,a,u):o;if(r=Fe(d.e/G),n=Fe(o.e/G),c=c.slice(),i=r-n,i){for(i<0?(t=c,i=-i,s=l.length):(t=l,n=r,s=c.length),r=Math.ceil(a/G),s=r>s?r+1:s+1,i>s&&(i=s,t.length=1),t.reverse();i--;)t.push(0);t.reverse()}for(s=c.length,i=l.length,s-i<0&&(i=s,t=l,l=c,c=t),e=0;i;)e=(c[--i]=c[i]+l[i]+e)/$e|0,c[i]%=$e;for(e&&(c.unshift(e),++n),s=c.length;c[--s]==0;)c.pop();return o.d=c,o.e=kn(c,n),Z?q(o,a,u):o};C.precision=C.sd=function(o){var e,t=this;if(o!==void 0&&o!==!!o&&o!==1&&o!==0)throw Error(wt+o);return t.d?(e=Wi(t.d),o&&t.e+1>e&&(e=t.e+1)):e=NaN,e};C.round=function(){var o=this,e=o.constructor;return q(new e(o),o.e+1,e.rounding)};C.sine=C.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())+G,n.rounding=1,t=Jr(n,_i(n,t)),n.precision=o,n.rounding=e,q(dt>2?t.neg():t,o,e,!0)):new n(NaN)};C.squareRoot=C.sqrt=function(){var o,e,t,n,i,r,s=this,a=s.d,u=s.e,c=s.s,l=s.constructor;if(c!==1||!a||!a[0])return new l(!c||c<0&&(!a||a[0])?NaN:a?s:1/0);for(Z=!1,c=Math.sqrt(+s),c==0||c==1/0?(e=Me(a),(e.length+u)%2==0&&(e+="0"),c=Math.sqrt(e),u=Fe((u+1)/2)-(u<0||u%2),c==1/0?e="5e"+u:(e=c.toExponential(),e=e.slice(0,e.indexOf("e")+1)+u),n=new l(e)):n=new l(c.toString()),t=(u=l.precision)+3;;)if(r=n,n=r.plus(ye(s,r,t+2,1)).times(.5),Me(r.d).slice(0,t)===(e=Me(n.d)).slice(0,t))if(e=e.slice(t-3,t+1),e=="9999"||!i&&e=="4999"){if(!i&&(q(r,u+1,0),r.times(r).eq(s))){n=r;break}t+=4,i=1}else{(!+e||!+e.slice(1)&&e.charAt(0)=="5")&&(q(n,u+1,1),o=!n.times(n).eq(s));break}return Z=!0,q(n,u,l.rounding,o)};C.tangent=C.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=ye(t,new n(1).minus(t.times(t)).sqrt(),o+10,0),n.precision=o,n.rounding=e,q(dt==2||dt==4?t.neg():t,o,e,!0)):new n(NaN)};C.times=C.mul=function(o){var e,t,n,i,r,s,a,u,c,l=this,d=l.constructor,p=l.d,m=(o=new d(o)).d;if(o.s*=l.s,!p||!p[0]||!m||!m[0])return new d(!o.s||p&&!p[0]&&!m||m&&!m[0]&&!p?NaN:!p||!m?o.s/0:o.s*0);for(t=Fe(l.e/G)+Fe(o.e/G),u=p.length,c=m.length,u<c&&(r=p,p=m,m=r,s=u,u=c,c=s),r=[],s=u+c,n=s;n--;)r.push(0);for(n=c;--n>=0;){for(e=0,i=u+n;i>n;)a=r[i]+m[n]*p[i-n-1]+e,r[i--]=a%$e|0,e=a/$e|0;r[i]=(r[i]+e)%$e|0}for(;!r[--s];)r.pop();return e?++t:r.shift(),o.d=r,o.e=kn(r,t),Z?q(o,d.precision,d.rounding):o};C.toBinary=function(o,e){return Gn(this,2,o,e)};C.toDecimalPlaces=C.toDP=function(o,e){var t=this,n=t.constructor;return t=new n(t),o===void 0?t:(Ve(o,0,Pt),e===void 0?e=n.rounding:Ve(e,0,8),q(t,o+t.e+1,e))};C.toExponential=function(o,e){var t,n=this,i=n.constructor;return o===void 0?t=ot(n,!0):(Ve(o,0,Pt),e===void 0?e=i.rounding:Ve(e,0,8),n=q(new i(n),o+1,e),t=ot(n,!0,o+1)),n.isNeg()&&!n.isZero()?"-"+t:t};C.toFixed=function(o,e){var t,n,i=this,r=i.constructor;return o===void 0?t=ot(i):(Ve(o,0,Pt),e===void 0?e=r.rounding:Ve(e,0,8),n=q(new r(i),o+i.e+1,e),t=ot(n,!1,o+n.e+1)),i.isNeg()&&!i.isZero()?"-"+t:t};C.toFraction=function(o){var e,t,n,i,r,s,a,u,c,l,d,p,m=this,y=m.d,f=m.constructor;if(!y)return new f(m);if(c=t=new f(1),n=u=new f(0),e=new f(n),r=e.e=Wi(y)-m.e-1,s=r%G,e.d[0]=Se(10,s<0?G+s:s),o==null)o=r>0?e:c;else{if(a=new f(o),!a.isInt()||a.lt(c))throw Error(wt+a);o=a.gt(e)?r>0?e:c:a}for(Z=!1,a=new f(Me(y)),l=f.precision,f.precision=r=y.length*G*2;d=ye(a,e,0,1,1),i=t.plus(d.times(n)),i.cmp(o)!=1;)t=n,n=i,i=c,c=u.plus(d.times(i)),u=i,i=e,e=a.minus(d.times(i)),a=i;return i=ye(o.minus(t),n,0,1,1),u=u.plus(i.times(c)),t=t.plus(i.times(n)),u.s=c.s=m.s,p=ye(c,n,r,1).minus(m).abs().cmp(ye(u,t,r,1).minus(m).abs())<1?[c,n]:[u,t],f.precision=l,Z=!0,p};C.toHexadecimal=C.toHex=function(o,e){return Gn(this,16,o,e)};C.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:Ve(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]?(Z=!1,t=ye(t,o,0,e,1).times(o),Z=!0,q(t)):(o.s=t.s,t=o),t};C.toNumber=function(){return+this};C.toOctal=function(o,e){return Gn(this,8,o,e)};C.toPower=C.pow=function(o){var e,t,n,i,r,s,a=this,u=a.constructor,c=+(o=new u(o));if(!a.d||!o.d||!a.d[0]||!o.d[0])return new u(Se(+a,c));if(a=new u(a),a.eq(1))return a;if(n=u.precision,r=u.rounding,o.eq(1))return q(a,n,r);if(e=Fe(o.e/G),e>=o.d.length-1&&(t=c<0?-c:c)<=Zr)return i=Fi(u,a,t,n),o.s<0?new u(1).div(i):q(i,n,r);if(s=a.s,s<0){if(e<o.d.length-1)return new u(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=Se(+a,c),e=t==0||!isFinite(t)?Fe(c*(Math.log("0."+Me(a.d))/Math.LN10+a.e+1)):new u(t+"").e,e>u.maxE+1||e<u.minE-1?new u(e>0?s/0:0):(Z=!1,u.rounding=a.s=1,t=Math.min(12,(e+"").length),i=Vn(o.times(gt(a,n+t)),n),i.d&&(i=q(i,n+5,1),Ut(i.d,n,r)&&(e=n+10,i=q(Vn(o.times(gt(a,e+t)),e),e+5,1),+Me(i.d).slice(n+1,n+15)+1==1e14&&(i=q(i,n+1,0)))),i.s=s,Z=!0,u.rounding=r,q(i,n,r))};C.toPrecision=function(o,e){var t,n=this,i=n.constructor;return o===void 0?t=ot(n,n.e<=i.toExpNeg||n.e>=i.toExpPos):(Ve(o,1,Pt),e===void 0?e=i.rounding:Ve(e,0,8),n=q(new i(n),o,e),t=ot(n,o<=n.e||n.e<=i.toExpNeg,o)),n.isNeg()&&!n.isZero()?"-"+t:t};C.toSignificantDigits=C.toSD=function(o,e){var t=this,n=t.constructor;return o===void 0?(o=n.precision,e=n.rounding):(Ve(o,1,Pt),e===void 0?e=n.rounding:Ve(e,0,8)),q(new n(t),o,e)};C.toString=function(){var o=this,e=o.constructor,t=ot(o,o.e<=e.toExpNeg||o.e>=e.toExpPos);return o.isNeg()&&!o.isZero()?"-"+t:t};C.truncated=C.trunc=function(){return q(new this.constructor(this),this.e+1,1)};C.valueOf=C.toJSON=function(){var o=this,e=o.constructor,t=ot(o,o.e<=e.toExpNeg||o.e>=e.toExpPos);return o.isNeg()?"-"+t:t};function Me(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=G-n.length,t&&(r+=bt(t)),r+=n;s=o[e],n=s+"",t=G-n.length,t&&(r+=bt(t))}else if(s===0)return"0";for(;s%10===0;)s/=10;return r+s}function Ve(o,e,t){if(o!==~~o||o<e||o>t)throw Error(wt+o)}function Ut(o,e,t,n){var i,r,s,a;for(r=o[0];r>=10;r/=10)--e;return--e<0?(e+=G,i=0):(i=Math.ceil((e+1)/G),e%=G),r=Se(10,G-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)==Se(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)==Se(10,e-3)-1,s}function yn(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]+=vn.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 Yr(o,e){var t,n,i;if(e.isZero())return e;n=e.d.length,n<32?(t=Math.ceil(n/3),i=(1/An(4,t)).toString()):(t=16,i="2.3283064365386962890625e-10"),o.precision+=t,e=Wt(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 ye=function(){function o(n,i,r){var s,a=0,u=n.length;for(n=n.slice();u--;)s=n[u]*i+a,n[u]=s%r|0,a=s/r|0;return a&&n.unshift(a),n}function e(n,i,r,s){var a,u;if(r!=s)u=r>s?1:-1;else for(a=u=0;a<r;a++)if(n[a]!=i[a]){u=n[a]>i[a]?1:-1;break}return u}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,u){var c,l,d,p,m,y,f,g,b,w,P,A,h,k,T,x,B,N,S,K,R=n.constructor,D=n.s==i.s?1:-1,U=n.d,v=i.d;if(!U||!U[0]||!v||!v[0])return new R(!n.s||!i.s||(U?v&&U[0]==v[0]:!v)?NaN:U&&U[0]==0||!v?D*0:D/0);for(u?(m=1,l=n.e-i.e):(u=$e,m=G,l=Fe(n.e/m)-Fe(i.e/m)),S=v.length,B=U.length,b=new R(D),w=b.d=[],d=0;v[d]==(U[d]||0);d++);if(v[d]>(U[d]||0)&&l--,r==null?(k=r=R.precision,s=R.rounding):a?k=r+(n.e-i.e)+1:k=r,k<0)w.push(1),y=!0;else{if(k=k/m+2|0,d=0,S==1){for(p=0,v=v[0],k++;(d<B||p)&&k--;d++)T=p*u+(U[d]||0),w[d]=T/v|0,p=T%v|0;y=p||d<B}else{for(p=u/(v[0]+1)|0,p>1&&(v=o(v,p,u),U=o(U,p,u),S=v.length,B=U.length),x=S,P=U.slice(0,S),A=P.length;A<S;)P[A++]=0;K=v.slice(),K.unshift(0),N=v[0],v[1]>=u/2&&++N;do p=0,c=e(v,P,S,A),c<0?(h=P[0],S!=A&&(h=h*u+(P[1]||0)),p=h/N|0,p>1?(p>=u&&(p=u-1),f=o(v,p,u),g=f.length,A=P.length,c=e(f,P,g,A),c==1&&(p--,t(f,S<g?K:v,g,u))):(p==0&&(c=p=1),f=v.slice()),g=f.length,g<A&&f.unshift(0),t(P,f,A,u),c==-1&&(A=P.length,c=e(v,P,S,A),c<1&&(p++,t(P,S<A?K:v,A,u))),A=P.length):c===0&&(p++,P=[0]),w[d++]=p,c&&P[0]?P[A++]=U[x]||0:(P=[U[x]],A=1);while((x++<B||P[0]!==void 0)&&k--);y=P[0]!==void 0}w[0]||w.shift()}if(m==1)b.e=l,Ni=y;else{for(d=1,p=w[0];p>=10;p/=10)d++;b.e=d+l*m-1,q(b,a?r+b.e+1:r,s,y)}return b}}();function q(o,e,t,n){var i,r,s,a,u,c,l,d,p,m=o.constructor;e:if(e!=null){if(d=o.d,!d)return o;for(i=1,a=d[0];a>=10;a/=10)i++;if(r=e-i,r<0)r+=G,s=e,l=d[p=0],u=l/Se(10,i-s-1)%10|0;else if(p=Math.ceil((r+1)/G),a=d.length,p>=a)if(n){for(;a++<=p;)d.push(0);l=u=0,i=1,r%=G,s=r-G+1}else break e;else{for(l=a=d[p],i=1;a>=10;a/=10)i++;r%=G,s=r-G+i,u=s<0?0:l/Se(10,i-s-1)%10|0}if(n=n||e<0||d[p+1]!==void 0||(s<0?l:l%Se(10,i-s-1)),c=t<4?(u||n)&&(t==0||t==(o.s<0?3:2)):u>5||u==5&&(t==4||n||t==6&&(r>0?s>0?l/Se(10,i-s):0:d[p-1])%10&1||t==(o.s<0?8:7)),e<1||!d[0])return d.length=0,c?(e-=o.e+1,d[0]=Se(10,(G-e%G)%G),o.e=-e||0):d[0]=o.e=0,o;if(r==0?(d.length=p,a=1,p--):(d.length=p+1,a=Se(10,G-r),d[p]=s>0?(l/Se(10,i-s)%Se(10,s)|0)*a:0),c)for(;;)if(p==0){for(r=1,s=d[0];s>=10;s/=10)r++;for(s=d[0]+=a,a=1;s>=10;s/=10)a++;r!=a&&(o.e++,d[0]==$e&&(d[0]=1));break}else{if(d[p]+=a,d[p]!=$e)break;d[p--]=0,a=1}for(r=d.length;d[--r]===0;)d.pop()}return Z&&(o.e>m.maxE?(o.d=null,o.e=NaN):o.e<m.minE&&(o.e=0,o.d=[0])),o}function ot(o,e,t){if(!o.isFinite())return vi(o);var n,i=o.e,r=Me(o.d),s=r.length;return e?(t&&(n=t-s)>0?r=r.charAt(0)+"."+r.slice(1)+bt(n):s>1&&(r=r.charAt(0)+"."+r.slice(1)),r=r+(o.e<0?"e":"e+")+o.e):i<0?(r="0."+bt(-i-1)+r,t&&(n=t-s)>0&&(r+=bt(n))):i>=s?(r+=bt(i+1-s),t&&(n=t-i-1)>0&&(r=r+"."+bt(n))):((n=i+1)<s&&(r=r.slice(0,n)+"."+r.slice(n)),t&&(n=t-s)>0&&(i+1===s&&(r+="."),r+=bt(n))),r}function kn(o,e){var t=o[0];for(e*=G;t>=10;t/=10)e++;return e}function wn(o,e,t){if(e>jr)throw Z=!0,t&&(o.precision=t),Error(Mi);return q(new o(bn),e,1,!0)}function Je(o,e,t){if(e>qn)throw Error(Mi);return q(new o(gn),e,t,!0)}function Wi(o){var e=o.length-1,t=e*G+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 bt(o){for(var e="";o--;)e+="0";return e}function Fi(o,e,t,n){var i,r=new o(1),s=Math.ceil(n/G+4);for(Z=!1;;){if(t%2&&(r=r.times(e),Ci(r.d,s)&&(i=!0)),t=Fe(t/2),t===0){t=r.d.length-1,i&&r.d[t]===0&&++r.d[t];break}e=e.times(e),Ci(e.d,s)}return Z=!0,r}function Ki(o){return o.d[o.d.length-1]&1}function Di(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 Vn(o,e){var t,n,i,r,s,a,u,c=0,l=0,d=0,p=o.constructor,m=p.rounding,y=p.precision;if(!o.d||!o.d[0]||o.e>17)return new p(o.d?o.d[0]?o.s<0?0:1/0:1:o.s?o.s<0?0:o:0/0);for(e==null?(Z=!1,u=y):u=e,a=new p(.03125);o.e>-2;)o=o.times(a),d+=5;for(n=Math.log(Se(2,d))/Math.LN10*2+5|0,u+=n,t=r=s=new p(1),p.precision=u;;){if(r=q(r.times(o),u,1),t=t.times(++l),a=s.plus(ye(r,t,u,1)),Me(a.d).slice(0,u)===Me(s.d).slice(0,u)){for(i=d;i--;)s=q(s.times(s),u,1);if(e==null)if(c<3&&Ut(s.d,u-n,m,c))p.precision=u+=10,t=r=a=new p(1),l=0,c++;else return q(s,p.precision=y,m,Z=!0);else return p.precision=y,s}s=a}}function gt(o,e){var t,n,i,r,s,a,u,c,l,d,p,m=1,y=10,f=o,g=f.d,b=f.constructor,w=b.rounding,P=b.precision;if(f.s<0||!g||!g[0]||!f.e&&g[0]==1&&g.length==1)return new b(g&&!g[0]?-1/0:f.s!=1?NaN:g?0:f);if(e==null?(Z=!1,l=P):l=e,b.precision=l+=y,t=Me(g),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=Me(f.d),n=t.charAt(0),m++;r=f.e,n>1?(f=new b("0."+t),r++):f=new b(n+"."+t.slice(1))}else return c=wn(b,l+2,P).times(r+""),f=gt(new b(n+"."+t.slice(1)),l-y).plus(c),b.precision=P,e==null?q(f,P,w,Z=!0):f;for(d=f,u=s=f=ye(f.minus(1),f.plus(1),l,1),p=q(f.times(f),l,1),i=3;;){if(s=q(s.times(p),l,1),c=u.plus(ye(s,new b(i),l,1)),Me(c.d).slice(0,l)===Me(u.d).slice(0,l))if(u=u.times(2),r!==0&&(u=u.plus(wn(b,l+2,P).times(r+""))),u=ye(u,new b(m),l,1),e==null)if(Ut(u.d,l-y,w,a))b.precision=l+=y,c=s=f=ye(d.minus(1),d.plus(1),l,1),p=q(f.times(f),l,1),i=a=1;else return q(u,b.precision=P,w,Z=!0);else return b.precision=P,u;u=c,i+=2}}function vi(o){return String(o.s*o.s/0)}function Un(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)%G,t<0&&(n+=G),n<i){for(n&&o.d.push(+e.slice(0,n)),i-=G;n<i;)o.d.push(+e.slice(n,n+=G));e=e.slice(n),n=G-e.length}else n-=i;for(;n--;)e+="0";o.d.push(+e),Z&&(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 Qr(o,e){var t,n,i,r,s,a,u,c,l;if(e.indexOf("_")>-1){if(e=e.replace(/(\d)_(?=\d)/g,"$1"),Ei.test(e))return Un(o,e)}else if(e==="Infinity"||e==="NaN")return+e||(o.s=NaN),o.e=NaN,o.d=null,o;if(zr.test(e))t=16,e=e.toLowerCase();else if(Xr.test(e))t=2;else if(Hr.test(e))t=8;else throw Error(wt+e);for(r=e.search(/p/i),r>0?(u=+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=Fi(n,new n(t),r,r*2)),c=yn(e,t,$e),l=c.length-1,r=l;c[r]===0;--r)c.pop();return r<0?new n(o.s*0):(o.e=kn(c,l),o.d=c,Z=!1,s&&(o=ye(o,i,a*4)),u&&(o=o.times(Math.abs(u)<54?Se(2,u):Gt.pow(2,u))),Z=!0,o)}function Jr(o,e){var t,n=e.d.length;if(n<3)return e.isZero()?e:Wt(o,2,e,e);t=1.4*Math.sqrt(n),t=t>16?16:t|0,e=e.times(1/An(5,t)),e=Wt(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 Wt(o,e,t,n,i){var r,s,a,u,c=1,l=o.precision,d=Math.ceil(l/G);for(Z=!1,u=t.times(t),a=new o(n);;){if(s=ye(a.times(u),new o(e++*e++),l,1),a=i?n.plus(s):n.minus(s),n=ye(s.times(u),new o(e++*e++),l,1),s=a.plus(n),s.d[d]!==void 0){for(r=d;s.d[r]===a.d[r]&&r--;);if(r==-1)break}r=a,a=n,n=s,s=r,c++}return Z=!0,s.d.length=d+1,s}function An(o,e){for(var t=o;--e;)t*=o;return t}function _i(o,e){var t,n=e.s<0,i=Je(o,o.precision,1),r=i.times(.5);if(e=e.abs(),e.lte(r))return dt=n?4:1,e;if(t=e.divToInt(i),t.isZero())dt=n?3:2;else{if(e=e.minus(t.times(i)),e.lte(r))return dt=Ki(t)?n?2:3:n?4:1,e;dt=Ki(t)?n?1:4:n?3:2}return e.minus(i).abs()}function Gn(o,e,t,n){var i,r,s,a,u,c,l,d,p,m=o.constructor,y=t!==void 0;if(y?(Ve(t,1,Pt),n===void 0?n=m.rounding:Ve(n,0,8)):(t=m.precision,n=m.rounding),!o.isFinite())l=vi(o);else{for(l=ot(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(".",""),p=new m(1),p.e=l.length-s,p.d=yn(ot(p),10,i),p.e=p.d.length),d=yn(l,10,i),r=u=d.length;d[--u]==0;)d.pop();if(!d[0])l=y?"0p+0":"0";else{if(s<0?r--:(o=new m(o),o.d=d,o.e=r,o=ye(o,p,t,n,0,i),d=o.d,r=o.e,c=Ni),s=d[t],a=i/2,c=c||d[t+1]!==void 0,c=n<4?(s!==void 0||c)&&(n===0||n===(o.s<0?3:2)):s>a||s===a&&(n===4||c||n===6&&d[t-1]&1||n===(o.s<0?8:7)),d.length=t,c)for(;++d[--t]>i-1;)d[t]=0,t||(++r,d.unshift(1));for(u=d.length;!d[u-1];--u);for(s=0,l="";s<u;s++)l+=vn.charAt(d[s]);if(y){if(u>1)if(e==16||e==8){for(s=e==16?4:3,--u;u%s;u++)l+="0";for(d=yn(l,i,e),u=d.length;!d[u-1];--u);for(s=1,l="1.";s<u;s++)l+=vn.charAt(d[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>u)for(r-=u;r--;)l+="0";else r<u&&(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 Ci(o,e){if(o.length>e)return o.length=e,!0}function $r(o){return new this(o).abs()}function eo(o){return new this(o).acos()}function to(o){return new this(o).acosh()}function no(o,e){return new this(o).plus(e)}function io(o){return new this(o).asin()}function ro(o){return new this(o).asinh()}function oo(o){return new this(o).atan()}function so(o){return new this(o).atanh()}function ao(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=Je(this,r,1).times(e.s>0?.25:.75),t.s=o.s):!e.d||o.isZero()?(t=e.s<0?Je(this,n,i):new this(0),t.s=o.s):!o.d||e.isZero()?(t=Je(this,r,1).times(.5),t.s=o.s):e.s<0?(this.precision=r,this.rounding=1,t=this.atan(ye(o,e,r,1)),e=Je(this,r,1),this.precision=n,this.rounding=i,t=o.s<0?t.minus(e):t.plus(e)):t=this.atan(ye(o,e,r,1)),t}function uo(o){return new this(o).cbrt()}function co(o){return q(o=new this(o),o.e+1,2)}function lo(o,e,t){return new this(o).clamp(e,t)}function mo(o){if(!o||typeof o!="object")throw Error(Pn+"Object expected");var e,t,n,i=o.defaults===!0,r=["precision",1,Pt,"rounding",0,8,"toExpNeg",-Et,0,"toExpPos",0,Et,"maxE",0,Et,"minE",-Et,0,"modulo",0,9];for(e=0;e<r.length;e+=3)if(t=r[e],i&&(this[t]=_n[t]),(n=o[t])!==void 0)if(Fe(n)===n&&n>=r[e+1]&&n<=r[e+2])this[t]=n;else throw Error(wt+t+": "+n);if(t="crypto",i&&(this[t]=_n[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(Ri);else this[t]=!1;else throw Error(wt+t+": "+n);return this}function po(o){return new this(o).cos()}function fo(o){return new this(o).cosh()}function qi(o){var e,t,n;function i(r){var s,a,u,c=this;if(!(c instanceof i))return new i(r);if(c.constructor=i,Li(r)){c.s=r.s,Z?!r.d||r.e>i.maxE?(c.e=NaN,c.d=null):r.e<i.minE?(c.e=0,c.d=[0]):(c.e=r.e,c.d=r.d.slice()):(c.e=r.e,c.d=r.d?r.d.slice():r.d);return}if(u=typeof r,u==="number"){if(r===0){c.s=1/r<0?-1:1,c.e=0,c.d=[0];return}if(r<0?(r=-r,c.s=-1):c.s=1,r===~~r&&r<1e7){for(s=0,a=r;a>=10;a/=10)s++;Z?s>i.maxE?(c.e=NaN,c.d=null):s<i.minE?(c.e=0,c.d=[0]):(c.e=s,c.d=[r]):(c.e=s,c.d=[r]);return}else if(r*0!==0){r||(c.s=NaN),c.e=NaN,c.d=null;return}return Un(c,r.toString())}else if(u!=="string")throw Error(wt+r);return(a=r.charCodeAt(0))===45?(r=r.slice(1),c.s=-1):(a===43&&(r=r.slice(1)),c.s=1),Ei.test(r)?Un(c,r):Qr(c,r)}if(i.prototype=C,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=mo,i.clone=qi,i.isDecimal=Li,i.abs=$r,i.acos=eo,i.acosh=to,i.add=no,i.asin=io,i.asinh=ro,i.atan=oo,i.atanh=so,i.atan2=ao,i.cbrt=uo,i.ceil=co,i.clamp=lo,i.cos=po,i.cosh=fo,i.div=yo,i.exp=bo,i.floor=go,i.hypot=wo,i.ln=Po,i.log=ko,i.log10=ho,i.log2=Ao,i.max=To,i.min=Bo,i.mod=xo,i.mul=Io,i.pow=So,i.random=Ko,i.round=Co,i.sign=Lo,i.sin=No,i.sinh=Mo,i.sqrt=Ro,i.sub=Oo,i.sum=Eo,i.tan=Wo,i.tanh=Fo,i.trunc=Do,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 yo(o,e){return new this(o).div(e)}function bo(o){return new this(o).exp()}function go(o){return q(o=new this(o),o.e+1,3)}function wo(){var o,e,t=new this(0);for(Z=!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 Z=!0,new this(1/0);t=e}return Z=!0,t.sqrt()}function Li(o){return o instanceof Gt||o&&o.toStringTag===Oi||!1}function Po(o){return new this(o).ln()}function ko(o,e){return new this(o).log(e)}function Ao(o){return new this(o).log(2)}function ho(o){return new this(o).log(10)}function To(){return Di(this,arguments,"lt")}function Bo(){return Di(this,arguments,"gt")}function xo(o,e){return new this(o).mod(e)}function Io(o,e){return new this(o).mul(e)}function So(o,e){return new this(o).pow(e)}function Ko(o){var e,t,n,i,r=0,s=new this(1),a=[];if(o===void 0?o=this.precision:Ve(o,1,Pt),n=Math.ceil(o/G),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(Ri);else for(;r<n;)a[r++]=Math.random()*1e7|0;for(n=a[--r],o%=G,n&&o&&(i=Se(10,G-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-=G)a.shift();for(n=1,i=a[0];i>=10;i/=10)n++;n<G&&(t-=G-n)}return s.e=t,s.d=a,s}function Co(o){return q(o=new this(o),o.e+1,this.rounding)}function Lo(o){return o=new this(o),o.d?o.d[0]?o.s:0*o.s:o.s||NaN}function No(o){return new this(o).sin()}function Mo(o){return new this(o).sinh()}function Ro(o){return new this(o).sqrt()}function Oo(o,e){return new this(o).sub(e)}function Eo(){var o=0,e=arguments,t=new this(e[o]);for(Z=!1;t.s&&++o<e.length;)t=t.plus(e[o]);return Z=!0,q(t,this.precision,this.rounding)}function Wo(o){return new this(o).tan()}function Fo(o){return new this(o).tanh()}function Do(o){return q(o=new this(o),o.e+1,1)}C[Symbol.for("nodejs.util.inspect.custom")]=C.toString;C[Symbol.toStringTag]="Decimal";var Gt=C.constructor=qi(_n);bn=new Gt(bn);gn=new Gt(gn);var W=Gt;var Zn=require("@solana/web3.js");var Xt=require("lodash");var Xn=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}},Vi={},vo={};function Re(o){let e=(0,Xt.get)(Vi,o);if(!e){let t=(0,Xt.get)(vo,o);e=new Xn({name:o,logLevel:t}),(0,Xt.set)(Vi,o,e)}return e}var kt=require("@solana/spl-token"),zn=Re("Raydium_accountInfo_util");async function mt(o,e,t){let{batchRequest:n,commitment:i="confirmed",chunkCount:r=100}=F({batchRequest:!1},t),s=Hn(e,r),a=new Array(s.length).fill([]);if(n){let u=s.map(d=>{let p=o._buildArgs([d.map(m=>m.toBase58())],i,"base64");return{methodName:"getMultipleAccounts",args:p}}),c=Hn(u,10);a=(await(await Promise.all(c.map(async d=>await o._rpcBatchRequest(d)))).flat()).map(d=>(d.error&&zn.logWithError(`failed to get info for multiple accounts, RPC_ERROR, ${d.error.message}`),d.result.value.map(p=>{if(p){let{data:m,executable:y,lamports:f,owner:g,rentEpoch:b}=p;return m.length!==2&&m[1]!=="base64"&&zn.logWithError("info must be base64 encoded, RPC_ERROR"),{data:Buffer.from(m[0],"base64"),executable:y,lamports:f,owner:new Zn.PublicKey(g),rentEpoch:b}}return null})))}else try{a=await Promise.all(s.map(u=>o.getMultipleAccountsInfo(u,i)))}catch(u){u instanceof Error&&zn.logWithError(`failed to get info for multiple accounts, RPC_ERROR, ${u.message}`)}return a.flat()}async function pt(o,e,t){let n=await mt(o,e.map(i=>i.pubkey),t);return e.map((i,r)=>Y(F({},i),{accountInfo:n[r]}))}async function Ui({connection:o,mints:e,config:t}){var r,s,a;if(e.length===0)return{};let n=await pt(o,e.map(u=>({pubkey:xt(u)})),t),i={};for(let u of n){if(!u.accountInfo||u.accountInfo.data.length<kt.MINT_SIZE){console.log("invalid mint account",u.pubkey.toBase58());continue}let c=(0,kt.unpackMint)(u.pubkey,u.accountInfo,(r=u.accountInfo)==null?void 0:r.owner);i[u.pubkey.toString()]=Y(F({},c),{programId:((s=u.accountInfo)==null?void 0:s.owner)||kt.TOKEN_PROGRAM_ID,feeConfig:(a=(0,kt.getTransferFeeConfig)(c))!=null?a:void 0})}return i[Zn.PublicKey.default.toBase58()]=i[ne.toBase58()],i}var at=Te(require("bn.js"));var ji=Te(require("big.js")),jt=Te(require("bn.js"));var Gi=Te(require("toformat")),_o=Gi.default,zt=_o;var Ht=Te(require("big.js")),zi=Te(require("bn.js")),Hi=Te(require("decimal.js-light"));var Ft=Te(require("bn.js"));var Xi=9007199254740991;function Ce(o){let e=Re("Raydium_parseBigNumberish");if(o instanceof Ft.default)return o;if(typeof o=="string"){if(o.match(/^-?[0-9]+$/))return new Ft.default(o);e.logWithError(`invalid BigNumberish string: ${o}`)}return typeof o=="number"?(o%1&&e.logWithError(`BigNumberish number underflow: ${o}`),(o>=Xi||o<=-Xi)&&e.logWithError(`BigNumberish number overflow: ${o}`),new Ft.default(String(o))):typeof o=="bigint"?new Ft.default(o.toString()):(e.error(`invalid BigNumberish value: ${o}`),new Ft.default(0))}var hn=Re("module/fraction"),jn=zt(Ht.default),Zt=zt(Hi.default),Vo={[0]:Zt.ROUND_DOWN,[1]:Zt.ROUND_HALF_UP,[2]:Zt.ROUND_UP},Uo={[0]:Ht.default.roundDown,[1]:Ht.default.roundHalfUp,[2]:Ht.default.roundUp},ce=class{constructor(e,t=new zi.default(1)){this.numerator=Ce(e),this.denominator=Ce(t)}get quotient(){return this.numerator.div(this.denominator)}invert(){return new ce(this.denominator,this.numerator)}add(e){let t=e instanceof ce?e:new ce(Ce(e));return this.denominator.eq(t.denominator)?new ce(this.numerator.add(t.numerator),this.denominator):new ce(this.numerator.mul(t.denominator).add(t.numerator.mul(this.denominator)),this.denominator.mul(t.denominator))}sub(e){let t=e instanceof ce?e:new ce(Ce(e));return this.denominator.eq(t.denominator)?new ce(this.numerator.sub(t.numerator),this.denominator):new ce(this.numerator.mul(t.denominator).sub(t.numerator.mul(this.denominator)),this.denominator.mul(t.denominator))}mul(e){let t=e instanceof ce?e:new ce(Ce(e));return new ce(this.numerator.mul(t.numerator),this.denominator.mul(t.denominator))}div(e){let t=e instanceof ce?e:new ce(Ce(e));return new ce(this.numerator.mul(t.denominator),this.denominator.mul(t.numerator))}toSignificant(e,t={groupSeparator:""},n=1){Number.isInteger(e)||hn.logWithError(`${e} is not an integer.`),e<=0&&hn.logWithError(`${e} is not positive.`),Zt.set({precision:e+1,rounding:Vo[n]});let i=new Zt(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)||hn.logWithError(`${e} is not an integer.`),e<0&&hn.logWithError(`${e} is negative.`),jn.DP=e,jn.RM=Uo[n]||1,new jn(this.numerator.toString()).div(this.denominator.toString()).toFormat(e,t)}isZero(){return this.numerator.isZero()}};var Go=Re("Raydium_amount"),Zi=zt(ji.default);function Xo(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")):Go.logWithError(`invalid number string, num: ${o}`)}else t=o;return[t,n.slice(0,e)||n]}var Oe=class extends ce{constructor(t,n,i=!0,r){let s=new jt.default(0),a=Yn.pow(new jt.default(t.decimals));if(i)s=Ce(n);else{let u=new jt.default(0),c=new jt.default(0);if(typeof n=="string"||typeof n=="number"||typeof n=="bigint"){let[l,d]=Xo(n.toString(),t.decimals);u=Ce(l),c=Ce(d)}u=u.mul(a),s=u.add(c)}super(s,a);this.logger=Re(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 Oe(this.token,this.raw.add(t.raw))}subtract(t){return this.token.equals(t.token)||this.logger.logWithError("sub token not equals"),new Oe(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 Zi.DP=this.token.decimals,new Zi(this.numerator.toString()).div(this.denominator.toString()).toFormat(t)}};var Yi=require("@solana/web3.js"),Qn=require("@solana/spl-token"),Jn={chainId:101,address:Yi.PublicKey.default.toBase58(),programId:Qn.TOKEN_PROGRAM_ID.toBase58(),decimals:9,symbol:"SOL",name:"solana",logoURI:"https://img-v1.raydium.io/icon/So11111111111111111111111111111111111111112.png",tags:[],priority:2,type:"raydium",extensions:{coingeckoId:"solana"}},At={chainId:101,address:"So11111111111111111111111111111111111111112",programId:Qn.TOKEN_PROGRAM_ID.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"}};var Tn=require("@solana/web3.js");var le=require("@solana/web3.js"),Qi=require("@solana/spl-token");function $n({pubkey:o,isSigner:e=!1,isWritable:t=!0}){return{pubkey:o,isWritable:t,isSigner:e}}var Js=[$n({pubkey:Qi.TOKEN_PROGRAM_ID,isWritable:!1}),$n({pubkey:le.SystemProgram.programId,isWritable:!1}),$n({pubkey:le.SYSVAR_RENT_PUBKEY,isWritable:!1})];function ei({publicKey:o,transformSol:e}){let t=Ji(o.toString());if(t instanceof le.PublicKey)return e&&t.equals(Yt)?ne:t;if(e&&t.toString()===Yt.toBase58())return ne;if(typeof t=="string"){if(t===le.PublicKey.default.toBase58())return le.PublicKey.default;try{return new le.PublicKey(t)}catch{throw new Error("invalid public key")}}throw new Error("invalid public key")}function Ji(o){try{return new le.PublicKey(o)}catch{return o}}var It=new le.PublicKey("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),ti=new le.PublicKey("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),et=new le.PublicKey("SysvarRent111111111111111111111111111111111"),$s=new le.PublicKey("SysvarC1ock11111111111111111111111111111111"),St=new le.PublicKey("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"),ea=new le.PublicKey("Sysvar1nstructions1111111111111111111111111"),ta=le.SystemProgram.programId,na=new le.PublicKey("4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R"),ia=new le.PublicKey("Ea5SjE2Y6yvCeW5dYTn7PYMuW5ikXkvbGdcmSnXeaLjS"),ra=new le.PublicKey("SRMuApVNdxXokk5GT7XD5cUUgXMBCoAz2LHeuAoKWRt"),oa=new le.PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"),sa=new le.PublicKey("Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB"),aa=new le.PublicKey("mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So"),ua=new le.PublicKey("7dHbWXmci3dT8UFYWYZweBLXgycu7Y3iL6trKn1Y7ARj"),ca=new le.PublicKey("USDH1SM1ojwWUga67PGrgFWUHibbjqMvuMaDkRJTgkX"),la=new le.PublicKey("NRVwhjBQiUPYtfDT5zRBVJajzFQHaBUNtC7SNVvqRFa"),da=new le.PublicKey("ANAxByE6G2WjFp7A4NqtWYXb3mgruyzZYg3spfxe6Lbo"),ma=new le.PublicKey("7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs"),ne=new le.PublicKey("So11111111111111111111111111111111111111112"),Yt=le.PublicKey.default;function xt(o){return ei({publicKey:o,transformSol:!0})}var ni=class{constructor({mint:e,decimals:t,symbol:n,name:i,skipMint:r=!1,isToken2022:s=!1}){if(e===Yt.toBase58()||e instanceof Tn.PublicKey&&Yt.equals(e)){this.decimals=At.decimals,this.symbol=At.symbol,this.name=At.name,this.mint=new Tn.PublicKey(At.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?Tn.PublicKey.default:ei({publicKey:e}),this.isToken2022=s}equals(e){return this===e?!0:this.mint.equals(e.mint)}},st=ni;st.WSOL=new ni(Y(F({},At),{mint:At.address}));var ii=class{constructor({decimals:e,symbol:t="UNKNOWN",name:n="UNKNOWN"}){this.decimals=e,this.symbol=t,this.name=n}equals(e){return this===e}},Bn=ii;Bn.SOL=new ii(Jn);var er=Te(require("bn.js"));var $i=new ce(new er.default(100)),ht=class extends ce{toSignificant(e=5,t,n){return this.mul($i).toSignificant(e,t,n)}toFixed(e=2,t,n){return this.mul($i).toFixed(e,t,n)}};var zo=Re("Raydium_price"),tt=class extends ce{constructor(t){let{baseToken:n,quoteToken:i,numerator:r,denominator:s}=t;super(r,s);this.baseToken=n,this.quoteToken=i,this.scalar=new ce(ri(n.decimals),ri(i.decimals))}get raw(){return new ce(this.numerator,this.denominator)}get adjusted(){return super.mul(this.scalar)}invert(){return new tt({baseToken:this.quoteToken,quoteToken:this.baseToken,denominator:this.numerator,numerator:this.denominator})}mul(t){this.quoteToken!==t.baseToken&&zo.logWithError("mul token not equals");let n=super.mul(t);return new tt({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)}};var Zo=require("@solana/web3.js"),jo=Te(require("bn.js"));var Ho=new at.default(0),iu=new at.default(1),ru=new at.default(2),ou=new at.default(3),su=new at.default(5),Yn=new at.default(10),au=new at.default(100),uu=new at.default(1e3),cu=new at.default(1e4);function ri(o){return Yn.pow(Ce(o))}function Hn(o,e=1,t=[]){let n=[...o];if(e<=0)return t;for(;n.length;)t.push(n.splice(0,e));return t}var rr=require("@solana/web3.js"),or=require("@solana/spl-token");var De=require("@solana/web3.js");var ie={CreateAccount:"CreateAccount",InitAccount:"InitAccount",CreateATA:"CreateATA",CloseAccount:"CloseAccount",TransferAmount:"TransferAmount",InitMint:"InitMint",MintTo:"MintTo",InitMarket:"InitMarket",Util1216OwnerClaim:"Util1216OwnerClaim",SetComputeUnitPrice:"SetComputeUnitPrice",SetComputeUnitLimit:"SetComputeUnitLimit",ClmmCreatePool:"ClmmCreatePool",ClmmOpenPosition:"ClmmOpenPosition",ClmmIncreasePosition:"ClmmIncreasePosition",ClmmDecreasePosition:"ClmmDecreasePosition",ClmmClosePosition:"ClmmClosePosition",ClmmSwapBaseIn:"ClmmSwapBaseIn",ClmmSwapBaseOut:"ClmmSwapBaseOut",ClmmInitReward:"ClmmInitReward",ClmmSetReward:"ClmmSetReward",ClmmCollectReward:"ClmmCollectReward",ClmmLockPosition:"ClmmLockPosition",ClmmHarvestLockPosition:"ClmmHarvestLockPosition",CustodyInitializeUser:"CustodyInitializeUser",CustodyDeposit:"CustodyDeposit",CustodyWithdraw:"CustodyWithdraw",CustodyOpenPosition:"CustodyOpenPosition",CustodyClosePosition:"CustodyClosePosition",CustodyIncreasePosition:"CustodyIncreasePosition",CustodyDecreasePosition:"CustodyDecreasePosition",CustodySwapBaseIn:"CustodySwapBaseIn",CustodySwapBaseOut:"CustodySwapBaseOut",AmmV4Swap:"AmmV4Swap",AmmV4AddLiquidity:"AmmV4AddLiquidity",AmmV4RemoveLiquidity:"AmmV4RemoveLiquidity",AmmV4SimulatePoolInfo:"AmmV4SimulatePoolInfo",AmmV4SwapBaseIn:"AmmV4SwapBaseIn",AmmV4SwapBaseOut:"AmmV4SwapBaseOut",AmmV4CreatePool:"AmmV4CreatePool",AmmV4InitPool:"AmmV4InitPool",AmmV5AddLiquidity:"AmmV5AddLiquidity",AmmV5RemoveLiquidity:"AmmV5RemoveLiquidity",AmmV5SimulatePoolInfo:"AmmV5SimulatePoolInfo",AmmV5SwapBaseIn:"AmmV5SwapBaseIn",AmmV5SwapBaseOut:"AmmV5SwapBaseOut",RouteSwap:"RouteSwap",RouteSwap1:"RouteSwap1",RouteSwap2:"RouteSwap2",FarmV3Deposit:"FarmV3Deposit",FarmV3Withdraw:"FarmV3Withdraw",FarmV3CreateLedger:"FarmV3CreateLedger",FarmV4Withdraw:"FarmV4Withdraw",FarmV5Deposit:"FarmV5Deposit",FarmV5Withdraw:"FarmV5Withdraw",FarmV5CreateLedger:"FarmV5CreateLedger",FarmV6Deposit:"FarmV6Deposit",FarmV6Withdraw:"FarmV6Withdraw",FarmV6Create:"FarmV6Create",FarmV6Restart:"FarmV6Restart",FarmV6CreatorAddReward:"FarmV6CreatorAddReward",FarmV6CreatorWithdraw:"FarmV6CreatorWithdraw",CpmmCreatePool:"CpmmCreatePool",CpmmAddLiquidity:"CpmmAddLiquidity",CpmmWithdrawLiquidity:"CpmmWithdrawLiquidity",CpmmSwapBaseIn:"CpmmSwapBaseIn",CpmmSwapBaseOut:"CpmmSwapBaseOut",CpmmLockLp:"CpmmLockLp",CpmmCollectLockFee:"CpmmCollectLockFee",TransferTip:"TransferTip"};var nr=require("@solana/spl-token"),tr=Re("Raydium_txUtil"),ir=1644;function xn(o){let e=[],t=[];return o.microLamports&&(e.push(De.ComputeBudgetProgram.setComputeUnitPrice({microLamports:o.microLamports})),t.push(ie.SetComputeUnitPrice)),o.units&&(e.push(De.ComputeBudgetProgram.setComputeUnitLimit({units:o.units})),t.push(ie.SetComputeUnitLimit)),{instructions:e,instructionTypes:t}}async function Dt(o,e){var n,i;let t=e!=null?e:"confirmed";return(i=await((n=o.getLatestBlockhash)==null?void 0:n.call(o,{commitment:t})))==null?void 0:i.blockhash}async function In(o,e){return o.getSignatureStatuses([e]),new Promise((t,n)=>{let i=setTimeout(n,6e4);o.onSignature(e,r=>{if(clearTimeout(i),!r.err){t("");return}n(Object.assign(r.err,{txId:e}))},"confirmed")})}function Yo(o,e){o.length<1&&tr.logWithError(`no instructions provided: ${o.toString()}`),e.length<1&&tr.logWithError(`no signers provided:, ${e.toString()}`);let t=new De.Transaction;t.recentBlockhash="11111111111111111111111111111111",t.feePayer=e[0],t.add(...o);try{return Buffer.from(t.serialize({verifySignatures:!1})).toString("base64").length<ir}catch{return!1}}function Ee(o,e){let[t,n]=De.PublicKey.findProgramAddressSync(o,e);return{publicKey:t,nonce:n}}function Qt({instructions:o,payer:e,signers:t}){return Yo(o,[e,...t])}function Jt({instructions:o,payer:e,lookupTableAddressAccount:t,recentBlockhash:n=De.Keypair.generate().publicKey.toString()}){let r=new De.TransactionMessage({payerKey:e,recentBlockhash:n,instructions:o}).compileToV0Message(Object.values(t!=null?t:{}));try{return Buffer.from(new De.VersionedTransaction(r).serialize()).toString("base64").length<ir}catch{return!1}}var Qo=o=>Buffer.isBuffer(o)?o:o instanceof Uint8Array?Buffer.from(o.buffer,o.byteOffset,o.byteLength):Buffer.from(o),Jo=o=>{let e=o.serialize({requireAllSignatures:!1,verifySignatures:!1});o instanceof De.VersionedTransaction&&(e=Qo(e));try{return e instanceof Buffer?e.toString("base64"):Buffer.from(e).toString("base64")}catch{return e.toString("base64")}};function Kt(o){let e=[];return o.forEach(t=>{t instanceof De.Transaction&&(t.recentBlockhash||(t.recentBlockhash=nr.TOKEN_PROGRAM_ID.toBase58()),t.feePayer||(t.feePayer=De.Keypair.generate().publicKey)),e.push(Jo(t))}),console.log("simulate tx string:",e),e}function z(o,e,t){return Ee([o.toBuffer(),(t!=null?t:or.TOKEN_PROGRAM_ID).toBuffer(),