snapper-sdk
Version:
An SDK for building applications on top of Snapper.
1 lines • 108 kB
JavaScript
"use strict";var Hi=Object.create;var yt=Object.defineProperty;var Zi=Object.getOwnPropertyDescriptor;var ji=Object.getOwnPropertyNames;var Yi=Object.getPrototypeOf,Qi=Object.prototype.hasOwnProperty;var Ji=(n,e)=>{for(var t in e)yt(n,t,{get:e[t],enumerable:!0})},Mn=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of ji(e))!Qi.call(n,r)&&r!==t&&yt(n,r,{get:()=>e[r],enumerable:!(i=Zi(e,r))||i.enumerable});return n};var z=(n,e,t)=>(t=n!=null?Hi(Yi(n)):{},Mn(e||!n||!n.__esModule?yt(t,"default",{value:n,enumerable:!0}):t,n)),$i=n=>Mn(yt({},"__esModule",{value:!0}),n);var is={};Ji(is,{default:()=>Yt});module.exports=$i(is);var T=require("@solana/web3.js"),ee=require("@solana/spl-token");var he=z(require("bn.js"));var Ve=9e15,Ke=1e9,Qt="0123456789abcdef",wt="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",At="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",Jt={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-Ve,maxE:Ve,crypto:!1},vn,Te,R=!0,kt="[DecimalError] ",Ce=kt+"Invalid argument: ",Dn=kt+"Precision limit exceeded",_n=kt+"crypto unavailable",Vn="[object Decimal]",re=Math.floor,Q=Math.pow,er=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,tr=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,nr=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,Wn=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,ge=1e7,K=7,ir=9007199254740991,rr=wt.length-1,$t=At.length-1,A={toStringTag:Vn};A.absoluteValue=A.abs=function(){var n=new this.constructor(this);return n.s<0&&(n.s=1),I(n)};A.ceil=function(){return I(new this.constructor(this),this.e+1,2)};A.clampedTo=A.clamp=function(n,e){var t,i=this,r=i.constructor;if(n=new r(n),e=new r(e),!n.s||!e.s)return new r(NaN);if(n.gt(e))throw Error(Ce+e);return t=i.cmp(n),t<0?n:i.cmp(e)>0?e:new r(i)};A.comparedTo=A.cmp=function(n){var e,t,i,r,o=this,s=o.d,a=(n=new o.constructor(n)).d,u=o.s,c=n.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(o.e!==n.e)return o.e>n.e^u<0?1:-1;for(i=s.length,r=a.length,e=0,t=i<r?i:r;e<t;++e)if(s[e]!==a[e])return s[e]>a[e]^u<0?1:-1;return i===r?0:i>r^u<0?1:-1};A.cosine=A.cos=function(){var n,e,t=this,i=t.constructor;return t.d?t.d[0]?(n=i.precision,e=i.rounding,i.precision=n+Math.max(t.e,t.sd())+K,i.rounding=1,t=or(i,zn(i,t)),i.precision=n,i.rounding=e,I(Te==2||Te==3?t.neg():t,n,e,!0)):new i(1):new i(NaN)};A.cubeRoot=A.cbrt=function(){var n,e,t,i,r,o,s,a,u,c,m=this,l=m.constructor;if(!m.isFinite()||m.isZero())return new l(m);for(R=!1,o=m.s*Q(m.s*m,1/3),!o||Math.abs(o)==1/0?(t=ie(m.d),n=m.e,(o=(n-t.length+1)%3)&&(t+=o==1||o==-2?"0":"00"),o=Q(t,1/3),n=re((n+1)/3)-(n%3==(n<0?-1:2)),o==1/0?t="5e"+n:(t=o.toExponential(),t=t.slice(0,t.indexOf("e")+1)+n),i=new l(t),i.s=m.s):i=new l(o.toString()),s=(n=l.precision)+3;;)if(a=i,u=a.times(a).times(a),c=u.plus(m),i=W(c.plus(m).times(a),c.plus(u),s+2,1),ie(a.d).slice(0,s)===(t=ie(i.d)).slice(0,s))if(t=t.slice(s-3,s+1),t=="9999"||!r&&t=="4999"){if(!r&&(I(a,n+1,0),a.times(a).times(a).eq(m))){i=a;break}s+=4,r=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(I(i,n+1,1),e=!i.times(i).times(i).eq(m));break}return R=!0,I(i,n,l.rounding,e)};A.decimalPlaces=A.dp=function(){var n,e=this.d,t=NaN;if(e){if(n=e.length-1,t=(n-re(this.e/K))*K,n=e[n],n)for(;n%10==0;n/=10)t--;t<0&&(t=0)}return t};A.dividedBy=A.div=function(n){return W(this,new this.constructor(n))};A.dividedToIntegerBy=A.divToInt=function(n){var e=this,t=e.constructor;return I(W(e,new t(n),0,1,1),t.precision,t.rounding)};A.equals=A.eq=function(n){return this.cmp(n)===0};A.floor=function(){return I(new this.constructor(this),this.e+1,3)};A.greaterThan=A.gt=function(n){return this.cmp(n)>0};A.greaterThanOrEqualTo=A.gte=function(n){var e=this.cmp(n);return e==1||e===0};A.hyperbolicCosine=A.cosh=function(){var n,e,t,i,r,o=this,s=o.constructor,a=new s(1);if(!o.isFinite())return new s(o.s?1/0:NaN);if(o.isZero())return a;t=s.precision,i=s.rounding,s.precision=t+Math.max(o.e,o.sd())+4,s.rounding=1,r=o.d.length,r<32?(n=Math.ceil(r/3),e=(1/Tt(4,n)).toString()):(n=16,e="2.3283064365386962890625e-10"),o=We(s,1,o.times(e),new s(1),!0);for(var u,c=n,m=new s(8);c--;)u=o.times(o),o=a.minus(u.times(m.minus(u.times(m))));return I(o,s.precision=t,s.rounding=i,!0)};A.hyperbolicSine=A.sinh=function(){var n,e,t,i,r=this,o=r.constructor;if(!r.isFinite()||r.isZero())return new o(r);if(e=o.precision,t=o.rounding,o.precision=e+Math.max(r.e,r.sd())+4,o.rounding=1,i=r.d.length,i<3)r=We(o,2,r,r,!0);else{n=1.4*Math.sqrt(i),n=n>16?16:n|0,r=r.times(1/Tt(5,n)),r=We(o,2,r,r,!0);for(var s,a=new o(5),u=new o(16),c=new o(20);n--;)s=r.times(r),r=r.times(a.plus(s.times(u.times(s).plus(c))))}return o.precision=e,o.rounding=t,I(r,e,t,!0)};A.hyperbolicTangent=A.tanh=function(){var n,e,t=this,i=t.constructor;return t.isFinite()?t.isZero()?new i(t):(n=i.precision,e=i.rounding,i.precision=n+7,i.rounding=1,W(t.sinh(),t.cosh(),i.precision=n,i.rounding=e)):new i(t.s)};A.inverseCosine=A.acos=function(){var n,e=this,t=e.constructor,i=e.abs().cmp(1),r=t.precision,o=t.rounding;return i!==-1?i===0?e.isNeg()?ye(t,r,o):new t(0):new t(NaN):e.isZero()?ye(t,r+4,o).times(.5):(t.precision=r+6,t.rounding=1,e=e.asin(),n=ye(t,r+4,o).times(.5),t.precision=r,t.rounding=o,n.minus(e))};A.inverseHyperbolicCosine=A.acosh=function(){var n,e,t=this,i=t.constructor;return t.lte(1)?new i(t.eq(1)?0:NaN):t.isFinite()?(n=i.precision,e=i.rounding,i.precision=n+Math.max(Math.abs(t.e),t.sd())+4,i.rounding=1,R=!1,t=t.times(t).minus(1).sqrt().plus(t),R=!0,i.precision=n,i.rounding=e,t.ln()):new i(t)};A.inverseHyperbolicSine=A.asinh=function(){var n,e,t=this,i=t.constructor;return!t.isFinite()||t.isZero()?new i(t):(n=i.precision,e=i.rounding,i.precision=n+2*Math.max(Math.abs(t.e),t.sd())+6,i.rounding=1,R=!1,t=t.times(t).plus(1).sqrt().plus(t),R=!0,i.precision=n,i.rounding=e,t.ln())};A.inverseHyperbolicTangent=A.atanh=function(){var n,e,t,i,r=this,o=r.constructor;return r.isFinite()?r.e>=0?new o(r.abs().eq(1)?r.s/0:r.isZero()?r:NaN):(n=o.precision,e=o.rounding,i=r.sd(),Math.max(i,n)<2*-r.e-1?I(new o(r),n,e,!0):(o.precision=t=i-r.e,r=W(r.plus(1),new o(1).minus(r),t+n,1),o.precision=n+4,o.rounding=1,r=r.ln(),o.precision=n,o.rounding=e,r.times(.5))):new o(NaN)};A.inverseSine=A.asin=function(){var n,e,t,i,r=this,o=r.constructor;return r.isZero()?new o(r):(e=r.abs().cmp(1),t=o.precision,i=o.rounding,e!==-1?e===0?(n=ye(o,t+4,i).times(.5),n.s=r.s,n):new o(NaN):(o.precision=t+6,o.rounding=1,r=r.div(new o(1).minus(r.times(r)).sqrt().plus(1)).atan(),o.precision=t,o.rounding=i,r.times(2)))};A.inverseTangent=A.atan=function(){var n,e,t,i,r,o,s,a,u,c=this,m=c.constructor,l=m.precision,d=m.rounding;if(c.isFinite()){if(c.isZero())return new m(c);if(c.abs().eq(1)&&l+4<=$t)return s=ye(m,l+4,d).times(.25),s.s=c.s,s}else{if(!c.s)return new m(NaN);if(l+4<=$t)return s=ye(m,l+4,d).times(.5),s.s=c.s,s}for(m.precision=a=l+10,m.rounding=1,t=Math.min(28,a/K+2|0),n=t;n;--n)c=c.div(c.times(c).plus(1).sqrt().plus(1));for(R=!1,e=Math.ceil(a/K),i=1,u=c.times(c),s=new m(c),r=c;n!==-1;)if(r=r.times(u),o=s.minus(r.div(i+=2)),r=r.times(u),s=o.plus(r.div(i+=2)),s.d[e]!==void 0)for(n=e;s.d[n]===o.d[n]&&n--;);return t&&(s=s.times(2<<t-1)),R=!0,I(s,m.precision=l,m.rounding=d,!0)};A.isFinite=function(){return!!this.d};A.isInteger=A.isInt=function(){return!!this.d&&re(this.e/K)>this.d.length-2};A.isNaN=function(){return!this.s};A.isNegative=A.isNeg=function(){return this.s<0};A.isPositive=A.isPos=function(){return this.s>0};A.isZero=function(){return!!this.d&&this.d[0]===0};A.lessThan=A.lt=function(n){return this.cmp(n)<0};A.lessThanOrEqualTo=A.lte=function(n){return this.cmp(n)<1};A.logarithm=A.log=function(n){var e,t,i,r,o,s,a,u,c=this,m=c.constructor,l=m.precision,d=m.rounding,p=5;if(n==null)n=new m(10),e=!0;else{if(n=new m(n),t=n.d,n.s<0||!t||!t[0]||n.eq(1))return new m(NaN);e=n.eq(10)}if(t=c.d,c.s<0||!t||!t[0]||c.eq(1))return new m(t&&!t[0]?-1/0:c.s!=1?NaN:t?0:1/0);if(e)if(t.length>1)o=!0;else{for(r=t[0];r%10===0;)r/=10;o=r!==1}if(R=!1,a=l+p,s=Se(c,a),i=e?Pt(m,a+10):Se(n,a),u=W(s,i,a,1),et(u.d,r=l,d))do if(a+=10,s=Se(c,a),i=e?Pt(m,a+10):Se(n,a),u=W(s,i,a,1),!o){+ie(u.d).slice(r+1,r+15)+1==1e14&&(u=I(u,l+1,0));break}while(et(u.d,r+=10,d));return R=!0,I(u,l,d)};A.minus=A.sub=function(n){var e,t,i,r,o,s,a,u,c,m,l,d,p=this,g=p.constructor;if(n=new g(n),!p.d||!n.d)return!p.s||!n.s?n=new g(NaN):p.d?n.s=-n.s:n=new g(n.d||p.s!==n.s?p:NaN),n;if(p.s!=n.s)return n.s=-n.s,p.plus(n);if(c=p.d,d=n.d,a=g.precision,u=g.rounding,!c[0]||!d[0]){if(d[0])n.s=-n.s;else if(c[0])n=new g(p);else return new g(u===3?-0:0);return R?I(n,a,u):n}if(t=re(n.e/K),m=re(p.e/K),c=c.slice(),o=m-t,o){for(l=o<0,l?(e=c,o=-o,s=d.length):(e=d,t=m,s=c.length),i=Math.max(Math.ceil(a/K),s)+2,o>i&&(o=i,e.length=1),e.reverse(),i=o;i--;)e.push(0);e.reverse()}else{for(i=c.length,s=d.length,l=i<s,l&&(s=i),i=0;i<s;i++)if(c[i]!=d[i]){l=c[i]<d[i];break}o=0}for(l&&(e=c,c=d,d=e,n.s=-n.s),s=c.length,i=d.length-s;i>0;--i)c[s++]=0;for(i=d.length;i>o;){if(c[--i]<d[i]){for(r=i;r&&c[--r]===0;)c[r]=ge-1;--c[r],c[i]+=ge}c[i]-=d[i]}for(;c[--s]===0;)c.pop();for(;c[0]===0;c.shift())--t;return c[0]?(n.d=c,n.e=ht(c,t),R?I(n,a,u):n):new g(u===3?-0:0)};A.modulo=A.mod=function(n){var e,t=this,i=t.constructor;return n=new i(n),!t.d||!n.s||n.d&&!n.d[0]?new i(NaN):!n.d||t.d&&!t.d[0]?I(new i(t),i.precision,i.rounding):(R=!1,i.modulo==9?(e=W(t,n.abs(),0,3,1),e.s*=n.s):e=W(t,n,0,i.modulo,1),e=e.times(n),R=!0,t.minus(e))};A.naturalExponential=A.exp=function(){return en(this)};A.naturalLogarithm=A.ln=function(){return Se(this)};A.negated=A.neg=function(){var n=new this.constructor(this);return n.s=-n.s,I(n)};A.plus=A.add=function(n){var e,t,i,r,o,s,a,u,c,m,l=this,d=l.constructor;if(n=new d(n),!l.d||!n.d)return!l.s||!n.s?n=new d(NaN):l.d||(n=new d(n.d||l.s===n.s?l:NaN)),n;if(l.s!=n.s)return n.s=-n.s,l.minus(n);if(c=l.d,m=n.d,a=d.precision,u=d.rounding,!c[0]||!m[0])return m[0]||(n=new d(l)),R?I(n,a,u):n;if(o=re(l.e/K),i=re(n.e/K),c=c.slice(),r=o-i,r){for(r<0?(t=c,r=-r,s=m.length):(t=m,i=o,s=c.length),o=Math.ceil(a/K),s=o>s?o+1:s+1,r>s&&(r=s,t.length=1),t.reverse();r--;)t.push(0);t.reverse()}for(s=c.length,r=m.length,s-r<0&&(r=s,t=m,m=c,c=t),e=0;r;)e=(c[--r]=c[r]+m[r]+e)/ge|0,c[r]%=ge;for(e&&(c.unshift(e),++i),s=c.length;c[--s]==0;)c.pop();return n.d=c,n.e=ht(c,i),R?I(n,a,u):n};A.precision=A.sd=function(n){var e,t=this;if(n!==void 0&&n!==!!n&&n!==1&&n!==0)throw Error(Ce+n);return t.d?(e=qn(t.d),n&&t.e+1>e&&(e=t.e+1)):e=NaN,e};A.round=function(){var n=this,e=n.constructor;return I(new e(n),n.e+1,e.rounding)};A.sine=A.sin=function(){var n,e,t=this,i=t.constructor;return t.isFinite()?t.isZero()?new i(t):(n=i.precision,e=i.rounding,i.precision=n+Math.max(t.e,t.sd())+K,i.rounding=1,t=ar(i,zn(i,t)),i.precision=n,i.rounding=e,I(Te>2?t.neg():t,n,e,!0)):new i(NaN)};A.squareRoot=A.sqrt=function(){var n,e,t,i,r,o,s=this,a=s.d,u=s.e,c=s.s,m=s.constructor;if(c!==1||!a||!a[0])return new m(!c||c<0&&(!a||a[0])?NaN:a?s:1/0);for(R=!1,c=Math.sqrt(+s),c==0||c==1/0?(e=ie(a),(e.length+u)%2==0&&(e+="0"),c=Math.sqrt(e),u=re((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),i=new m(e)):i=new m(c.toString()),t=(u=m.precision)+3;;)if(o=i,i=o.plus(W(s,o,t+2,1)).times(.5),ie(o.d).slice(0,t)===(e=ie(i.d)).slice(0,t))if(e=e.slice(t-3,t+1),e=="9999"||!r&&e=="4999"){if(!r&&(I(o,u+1,0),o.times(o).eq(s))){i=o;break}t+=4,r=1}else{(!+e||!+e.slice(1)&&e.charAt(0)=="5")&&(I(i,u+1,1),n=!i.times(i).eq(s));break}return R=!0,I(i,u,m.rounding,n)};A.tangent=A.tan=function(){var n,e,t=this,i=t.constructor;return t.isFinite()?t.isZero()?new i(t):(n=i.precision,e=i.rounding,i.precision=n+10,i.rounding=1,t=t.sin(),t.s=1,t=W(t,new i(1).minus(t.times(t)).sqrt(),n+10,0),i.precision=n,i.rounding=e,I(Te==2||Te==4?t.neg():t,n,e,!0)):new i(NaN)};A.times=A.mul=function(n){var e,t,i,r,o,s,a,u,c,m=this,l=m.constructor,d=m.d,p=(n=new l(n)).d;if(n.s*=m.s,!d||!d[0]||!p||!p[0])return new l(!n.s||d&&!d[0]&&!p||p&&!p[0]&&!d?NaN:!d||!p?n.s/0:n.s*0);for(t=re(m.e/K)+re(n.e/K),u=d.length,c=p.length,u<c&&(o=d,d=p,p=o,s=u,u=c,c=s),o=[],s=u+c,i=s;i--;)o.push(0);for(i=c;--i>=0;){for(e=0,r=u+i;r>i;)a=o[r]+p[i]*d[r-i-1]+e,o[r--]=a%ge|0,e=a/ge|0;o[r]=(o[r]+e)%ge|0}for(;!o[--s];)o.pop();return e?++t:o.shift(),n.d=o,n.e=ht(o,t),R?I(n,l.precision,l.rounding):n};A.toBinary=function(n,e){return nn(this,2,n,e)};A.toDecimalPlaces=A.toDP=function(n,e){var t=this,i=t.constructor;return t=new i(t),n===void 0?t:(ce(n,0,Ke),e===void 0?e=i.rounding:ce(e,0,8),I(t,n+t.e+1,e))};A.toExponential=function(n,e){var t,i=this,r=i.constructor;return n===void 0?t=we(i,!0):(ce(n,0,Ke),e===void 0?e=r.rounding:ce(e,0,8),i=I(new r(i),n+1,e),t=we(i,!0,n+1)),i.isNeg()&&!i.isZero()?"-"+t:t};A.toFixed=function(n,e){var t,i,r=this,o=r.constructor;return n===void 0?t=we(r):(ce(n,0,Ke),e===void 0?e=o.rounding:ce(e,0,8),i=I(new o(r),n+r.e+1,e),t=we(i,!1,n+i.e+1)),r.isNeg()&&!r.isZero()?"-"+t:t};A.toFraction=function(n){var e,t,i,r,o,s,a,u,c,m,l,d,p=this,g=p.d,f=p.constructor;if(!g)return new f(p);if(c=t=new f(1),i=u=new f(0),e=new f(i),o=e.e=qn(g)-p.e-1,s=o%K,e.d[0]=Q(10,s<0?K+s:s),n==null)n=o>0?e:c;else{if(a=new f(n),!a.isInt()||a.lt(c))throw Error(Ce+a);n=a.gt(e)?o>0?e:c:a}for(R=!1,a=new f(ie(g)),m=f.precision,f.precision=o=g.length*K*2;l=W(a,e,0,1,1),r=t.plus(l.times(i)),r.cmp(n)!=1;)t=i,i=r,r=c,c=u.plus(l.times(r)),u=r,r=e,e=a.minus(l.times(r)),a=r;return r=W(n.minus(t),i,0,1,1),u=u.plus(r.times(c)),t=t.plus(r.times(i)),u.s=c.s=p.s,d=W(c,i,o,1).minus(p).abs().cmp(W(u,t,o,1).minus(p).abs())<1?[c,i]:[u,t],f.precision=m,R=!0,d};A.toHexadecimal=A.toHex=function(n,e){return nn(this,16,n,e)};A.toNearest=function(n,e){var t=this,i=t.constructor;if(t=new i(t),n==null){if(!t.d)return t;n=new i(1),e=i.rounding}else{if(n=new i(n),e===void 0?e=i.rounding:ce(e,0,8),!t.d)return n.s?t:n;if(!n.d)return n.s&&(n.s=t.s),n}return n.d[0]?(R=!1,t=W(t,n,0,e,1).times(n),R=!0,I(t)):(n.s=t.s,t=n),t};A.toNumber=function(){return+this};A.toOctal=function(n,e){return nn(this,8,n,e)};A.toPower=A.pow=function(n){var e,t,i,r,o,s,a=this,u=a.constructor,c=+(n=new u(n));if(!a.d||!n.d||!a.d[0]||!n.d[0])return new u(Q(+a,c));if(a=new u(a),a.eq(1))return a;if(i=u.precision,o=u.rounding,n.eq(1))return I(a,i,o);if(e=re(n.e/K),e>=n.d.length-1&&(t=c<0?-c:c)<=ir)return r=Un(u,a,t,i),n.s<0?new u(1).div(r):I(r,i,o);if(s=a.s,s<0){if(e<n.d.length-1)return new u(NaN);if((n.d[e]&1)==0&&(s=1),a.e==0&&a.d[0]==1&&a.d.length==1)return a.s=s,a}return t=Q(+a,c),e=t==0||!isFinite(t)?re(c*(Math.log("0."+ie(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):(R=!1,u.rounding=a.s=1,t=Math.min(12,(e+"").length),r=en(n.times(Se(a,i+t)),i),r.d&&(r=I(r,i+5,1),et(r.d,i,o)&&(e=i+10,r=I(en(n.times(Se(a,e+t)),e),e+5,1),+ie(r.d).slice(i+1,i+15)+1==1e14&&(r=I(r,i+1,0)))),r.s=s,R=!0,u.rounding=o,I(r,i,o))};A.toPrecision=function(n,e){var t,i=this,r=i.constructor;return n===void 0?t=we(i,i.e<=r.toExpNeg||i.e>=r.toExpPos):(ce(n,1,Ke),e===void 0?e=r.rounding:ce(e,0,8),i=I(new r(i),n,e),t=we(i,n<=i.e||i.e<=r.toExpNeg,n)),i.isNeg()&&!i.isZero()?"-"+t:t};A.toSignificantDigits=A.toSD=function(n,e){var t=this,i=t.constructor;return n===void 0?(n=i.precision,e=i.rounding):(ce(n,1,Ke),e===void 0?e=i.rounding:ce(e,0,8)),I(new i(t),n,e)};A.toString=function(){var n=this,e=n.constructor,t=we(n,n.e<=e.toExpNeg||n.e>=e.toExpPos);return n.isNeg()&&!n.isZero()?"-"+t:t};A.truncated=A.trunc=function(){return I(new this.constructor(this),this.e+1,1)};A.valueOf=A.toJSON=function(){var n=this,e=n.constructor,t=we(n,n.e<=e.toExpNeg||n.e>=e.toExpPos);return n.isNeg()?"-"+t:t};function ie(n){var e,t,i,r=n.length-1,o="",s=n[0];if(r>0){for(o+=s,e=1;e<r;e++)i=n[e]+"",t=K-i.length,t&&(o+=Ie(t)),o+=i;s=n[e],i=s+"",t=K-i.length,t&&(o+=Ie(t))}else if(s===0)return"0";for(;s%10===0;)s/=10;return o+s}function ce(n,e,t){if(n!==~~n||n<e||n>t)throw Error(Ce+n)}function et(n,e,t,i){var r,o,s,a;for(o=n[0];o>=10;o/=10)--e;return--e<0?(e+=K,r=0):(r=Math.ceil((e+1)/K),e%=K),o=Q(10,K-e),a=n[r]%o|0,i==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==o||t>3&&a+1==o/2)&&(n[r+1]/o/100|0)==Q(10,e-2)-1||(a==o/2||a==0)&&(n[r+1]/o/100|0)==0:e<4?(e==0?a=a/1e3|0:e==1?a=a/100|0:e==2&&(a=a/10|0),s=(i||t<4)&&a==9999||!i&&t>3&&a==4999):s=((i||t<4)&&a+1==o||!i&&t>3&&a+1==o/2)&&(n[r+1]/o/1e3|0)==Q(10,e-3)-1,s}function gt(n,e,t){for(var i,r=[0],o,s=0,a=n.length;s<a;){for(o=r.length;o--;)r[o]*=e;for(r[0]+=Qt.indexOf(n.charAt(s++)),i=0;i<r.length;i++)r[i]>t-1&&(r[i+1]===void 0&&(r[i+1]=0),r[i+1]+=r[i]/t|0,r[i]%=t)}return r.reverse()}function or(n,e){var t,i,r;if(e.isZero())return e;i=e.d.length,i<32?(t=Math.ceil(i/3),r=(1/Tt(4,t)).toString()):(t=16,r="2.3283064365386962890625e-10"),n.precision+=t,e=We(n,1,e.times(r),new n(1));for(var o=t;o--;){var s=e.times(e);e=s.times(s).minus(s).times(8).plus(1)}return n.precision-=t,e}var W=function(){function n(i,r,o){var s,a=0,u=i.length;for(i=i.slice();u--;)s=i[u]*r+a,i[u]=s%o|0,a=s/o|0;return a&&i.unshift(a),i}function e(i,r,o,s){var a,u;if(o!=s)u=o>s?1:-1;else for(a=u=0;a<o;a++)if(i[a]!=r[a]){u=i[a]>r[a]?1:-1;break}return u}function t(i,r,o,s){for(var a=0;o--;)i[o]-=a,a=i[o]<r[o]?1:0,i[o]=a*s+i[o]-r[o];for(;!i[0]&&i.length>1;)i.shift()}return function(i,r,o,s,a,u){var c,m,l,d,p,g,f,P,b,w,y,k,B,x,N,L,E,G,F,X,Y=i.constructor,le=i.s==r.s?1:-1,te=i.d,_=r.d;if(!te||!te[0]||!_||!_[0])return new Y(!i.s||!r.s||(te?_&&te[0]==_[0]:!_)?NaN:te&&te[0]==0||!_?le*0:le/0);for(u?(p=1,m=i.e-r.e):(u=ge,p=K,m=re(i.e/p)-re(r.e/p)),F=_.length,E=te.length,b=new Y(le),w=b.d=[],l=0;_[l]==(te[l]||0);l++);if(_[l]>(te[l]||0)&&m--,o==null?(x=o=Y.precision,s=Y.rounding):a?x=o+(i.e-r.e)+1:x=o,x<0)w.push(1),g=!0;else{if(x=x/p+2|0,l=0,F==1){for(d=0,_=_[0],x++;(l<E||d)&&x--;l++)N=d*u+(te[l]||0),w[l]=N/_|0,d=N%_|0;g=d||l<E}else{for(d=u/(_[0]+1)|0,d>1&&(_=n(_,d,u),te=n(te,d,u),F=_.length,E=te.length),L=F,y=te.slice(0,F),k=y.length;k<F;)y[k++]=0;X=_.slice(),X.unshift(0),G=_[0],_[1]>=u/2&&++G;do d=0,c=e(_,y,F,k),c<0?(B=y[0],F!=k&&(B=B*u+(y[1]||0)),d=B/G|0,d>1?(d>=u&&(d=u-1),f=n(_,d,u),P=f.length,k=y.length,c=e(f,y,P,k),c==1&&(d--,t(f,F<P?X:_,P,u))):(d==0&&(c=d=1),f=_.slice()),P=f.length,P<k&&f.unshift(0),t(y,f,k,u),c==-1&&(k=y.length,c=e(_,y,F,k),c<1&&(d++,t(y,F<k?X:_,k,u))),k=y.length):c===0&&(d++,y=[0]),w[l++]=d,c&&y[0]?y[k++]=te[L]||0:(y=[te[L]],k=1);while((L++<E||y[0]!==void 0)&&x--);g=y[0]!==void 0}w[0]||w.shift()}if(p==1)b.e=m,vn=g;else{for(l=1,d=w[0];d>=10;d/=10)l++;b.e=l+m*p-1,I(b,a?o+b.e+1:o,s,g)}return b}}();function I(n,e,t,i){var r,o,s,a,u,c,m,l,d,p=n.constructor;e:if(e!=null){if(l=n.d,!l)return n;for(r=1,a=l[0];a>=10;a/=10)r++;if(o=e-r,o<0)o+=K,s=e,m=l[d=0],u=m/Q(10,r-s-1)%10|0;else if(d=Math.ceil((o+1)/K),a=l.length,d>=a)if(i){for(;a++<=d;)l.push(0);m=u=0,r=1,o%=K,s=o-K+1}else break e;else{for(m=a=l[d],r=1;a>=10;a/=10)r++;o%=K,s=o-K+r,u=s<0?0:m/Q(10,r-s-1)%10|0}if(i=i||e<0||l[d+1]!==void 0||(s<0?m:m%Q(10,r-s-1)),c=t<4?(u||i)&&(t==0||t==(n.s<0?3:2)):u>5||u==5&&(t==4||i||t==6&&(o>0?s>0?m/Q(10,r-s):0:l[d-1])%10&1||t==(n.s<0?8:7)),e<1||!l[0])return l.length=0,c?(e-=n.e+1,l[0]=Q(10,(K-e%K)%K),n.e=-e||0):l[0]=n.e=0,n;if(o==0?(l.length=d,a=1,d--):(l.length=d+1,a=Q(10,K-o),l[d]=s>0?(m/Q(10,r-s)%Q(10,s)|0)*a:0),c)for(;;)if(d==0){for(o=1,s=l[0];s>=10;s/=10)o++;for(s=l[0]+=a,a=1;s>=10;s/=10)a++;o!=a&&(n.e++,l[0]==ge&&(l[0]=1));break}else{if(l[d]+=a,l[d]!=ge)break;l[d--]=0,a=1}for(o=l.length;l[--o]===0;)l.pop()}return R&&(n.e>p.maxE?(n.d=null,n.e=NaN):n.e<p.minE&&(n.e=0,n.d=[0])),n}function we(n,e,t){if(!n.isFinite())return Xn(n);var i,r=n.e,o=ie(n.d),s=o.length;return e?(t&&(i=t-s)>0?o=o.charAt(0)+"."+o.slice(1)+Ie(i):s>1&&(o=o.charAt(0)+"."+o.slice(1)),o=o+(n.e<0?"e":"e+")+n.e):r<0?(o="0."+Ie(-r-1)+o,t&&(i=t-s)>0&&(o+=Ie(i))):r>=s?(o+=Ie(r+1-s),t&&(i=t-r-1)>0&&(o=o+"."+Ie(i))):((i=r+1)<s&&(o=o.slice(0,i)+"."+o.slice(i)),t&&(i=t-s)>0&&(r+1===s&&(o+="."),o+=Ie(i))),o}function ht(n,e){var t=n[0];for(e*=K;t>=10;t/=10)e++;return e}function Pt(n,e,t){if(e>rr)throw R=!0,t&&(n.precision=t),Error(Dn);return I(new n(wt),e,1,!0)}function ye(n,e,t){if(e>$t)throw Error(Dn);return I(new n(At),e,t,!0)}function qn(n){var e=n.length-1,t=e*K+1;if(e=n[e],e){for(;e%10==0;e/=10)t--;for(e=n[0];e>=10;e/=10)t++}return t}function Ie(n){for(var e="";n--;)e+="0";return e}function Un(n,e,t,i){var r,o=new n(1),s=Math.ceil(i/K+4);for(R=!1;;){if(t%2&&(o=o.times(e),Fn(o.d,s)&&(r=!0)),t=re(t/2),t===0){t=o.d.length-1,r&&o.d[t]===0&&++o.d[t];break}e=e.times(e),Fn(e.d,s)}return R=!0,o}function On(n){return n.d[n.d.length-1]&1}function Gn(n,e,t){for(var i,r=new n(e[0]),o=0;++o<e.length;)if(i=new n(e[o]),i.s)r[t](i)&&(r=i);else{r=i;break}return r}function en(n,e){var t,i,r,o,s,a,u,c=0,m=0,l=0,d=n.constructor,p=d.rounding,g=d.precision;if(!n.d||!n.d[0]||n.e>17)return new d(n.d?n.d[0]?n.s<0?0:1/0:1:n.s?n.s<0?0:n:0/0);for(e==null?(R=!1,u=g):u=e,a=new d(.03125);n.e>-2;)n=n.times(a),l+=5;for(i=Math.log(Q(2,l))/Math.LN10*2+5|0,u+=i,t=o=s=new d(1),d.precision=u;;){if(o=I(o.times(n),u,1),t=t.times(++m),a=s.plus(W(o,t,u,1)),ie(a.d).slice(0,u)===ie(s.d).slice(0,u)){for(r=l;r--;)s=I(s.times(s),u,1);if(e==null)if(c<3&&et(s.d,u-i,p,c))d.precision=u+=10,t=o=a=new d(1),m=0,c++;else return I(s,d.precision=g,p,R=!0);else return d.precision=g,s}s=a}}function Se(n,e){var t,i,r,o,s,a,u,c,m,l,d,p=1,g=10,f=n,P=f.d,b=f.constructor,w=b.rounding,y=b.precision;if(f.s<0||!P||!P[0]||!f.e&&P[0]==1&&P.length==1)return new b(P&&!P[0]?-1/0:f.s!=1?NaN:P?0:f);if(e==null?(R=!1,m=y):m=e,b.precision=m+=g,t=ie(P),i=t.charAt(0),Math.abs(o=f.e)<15e14){for(;i<7&&i!=1||i==1&&t.charAt(1)>3;)f=f.times(n),t=ie(f.d),i=t.charAt(0),p++;o=f.e,i>1?(f=new b("0."+t),o++):f=new b(i+"."+t.slice(1))}else return c=Pt(b,m+2,y).times(o+""),f=Se(new b(i+"."+t.slice(1)),m-g).plus(c),b.precision=y,e==null?I(f,y,w,R=!0):f;for(l=f,u=s=f=W(f.minus(1),f.plus(1),m,1),d=I(f.times(f),m,1),r=3;;){if(s=I(s.times(d),m,1),c=u.plus(W(s,new b(r),m,1)),ie(c.d).slice(0,m)===ie(u.d).slice(0,m))if(u=u.times(2),o!==0&&(u=u.plus(Pt(b,m+2,y).times(o+""))),u=W(u,new b(p),m,1),e==null)if(et(u.d,m-g,w,a))b.precision=m+=g,c=s=f=W(l.minus(1),l.plus(1),m,1),d=I(f.times(f),m,1),r=a=1;else return I(u,b.precision=y,w,R=!0);else return b.precision=y,u;u=c,r+=2}}function Xn(n){return String(n.s*n.s/0)}function tn(n,e){var t,i,r;for((t=e.indexOf("."))>-1&&(e=e.replace(".","")),(i=e.search(/e/i))>0?(t<0&&(t=i),t+=+e.slice(i+1),e=e.substring(0,i)):t<0&&(t=e.length),i=0;e.charCodeAt(i)===48;i++);for(r=e.length;e.charCodeAt(r-1)===48;--r);if(e=e.slice(i,r),e){if(r-=i,n.e=t=t-i-1,n.d=[],i=(t+1)%K,t<0&&(i+=K),i<r){for(i&&n.d.push(+e.slice(0,i)),r-=K;i<r;)n.d.push(+e.slice(i,i+=K));e=e.slice(i),i=K-e.length}else i-=r;for(;i--;)e+="0";n.d.push(+e),R&&(n.e>n.constructor.maxE?(n.d=null,n.e=NaN):n.e<n.constructor.minE&&(n.e=0,n.d=[0]))}else n.e=0,n.d=[0];return n}function sr(n,e){var t,i,r,o,s,a,u,c,m;if(e.indexOf("_")>-1){if(e=e.replace(/(\d)_(?=\d)/g,"$1"),Wn.test(e))return tn(n,e)}else if(e==="Infinity"||e==="NaN")return+e||(n.s=NaN),n.e=NaN,n.d=null,n;if(tr.test(e))t=16,e=e.toLowerCase();else if(er.test(e))t=2;else if(nr.test(e))t=8;else throw Error(Ce+e);for(o=e.search(/p/i),o>0?(u=+e.slice(o+1),e=e.substring(2,o)):e=e.slice(2),o=e.indexOf("."),s=o>=0,i=n.constructor,s&&(e=e.replace(".",""),a=e.length,o=a-o,r=Un(i,new i(t),o,o*2)),c=gt(e,t,ge),m=c.length-1,o=m;c[o]===0;--o)c.pop();return o<0?new i(n.s*0):(n.e=ht(c,m),n.d=c,R=!1,s&&(n=W(n,r,a*4)),u&&(n=n.times(Math.abs(u)<54?Q(2,u):tt.pow(2,u))),R=!0,n)}function ar(n,e){var t,i=e.d.length;if(i<3)return e.isZero()?e:We(n,2,e,e);t=1.4*Math.sqrt(i),t=t>16?16:t|0,e=e.times(1/Tt(5,t)),e=We(n,2,e,e);for(var r,o=new n(5),s=new n(16),a=new n(20);t--;)r=e.times(e),e=e.times(o.plus(r.times(s.times(r).minus(a))));return e}function We(n,e,t,i,r){var o,s,a,u,c=1,m=n.precision,l=Math.ceil(m/K);for(R=!1,u=t.times(t),a=new n(i);;){if(s=W(a.times(u),new n(e++*e++),m,1),a=r?i.plus(s):i.minus(s),i=W(s.times(u),new n(e++*e++),m,1),s=a.plus(i),s.d[l]!==void 0){for(o=l;s.d[o]===a.d[o]&&o--;);if(o==-1)break}o=a,a=i,i=s,s=o,c++}return R=!0,s.d.length=l+1,s}function Tt(n,e){for(var t=n;--e;)t*=n;return t}function zn(n,e){var t,i=e.s<0,r=ye(n,n.precision,1),o=r.times(.5);if(e=e.abs(),e.lte(o))return Te=i?4:1,e;if(t=e.divToInt(r),t.isZero())Te=i?3:2;else{if(e=e.minus(t.times(r)),e.lte(o))return Te=On(t)?i?2:3:i?4:1,e;Te=On(t)?i?1:4:i?3:2}return e.minus(r).abs()}function nn(n,e,t,i){var r,o,s,a,u,c,m,l,d,p=n.constructor,g=t!==void 0;if(g?(ce(t,1,Ke),i===void 0?i=p.rounding:ce(i,0,8)):(t=p.precision,i=p.rounding),!n.isFinite())m=Xn(n);else{for(m=we(n),s=m.indexOf("."),g?(r=2,e==16?t=t*4-3:e==8&&(t=t*3-2)):r=e,s>=0&&(m=m.replace(".",""),d=new p(1),d.e=m.length-s,d.d=gt(we(d),10,r),d.e=d.d.length),l=gt(m,10,r),o=u=l.length;l[--u]==0;)l.pop();if(!l[0])m=g?"0p+0":"0";else{if(s<0?o--:(n=new p(n),n.d=l,n.e=o,n=W(n,d,t,i,0,r),l=n.d,o=n.e,c=vn),s=l[t],a=r/2,c=c||l[t+1]!==void 0,c=i<4?(s!==void 0||c)&&(i===0||i===(n.s<0?3:2)):s>a||s===a&&(i===4||c||i===6&&l[t-1]&1||i===(n.s<0?8:7)),l.length=t,c)for(;++l[--t]>r-1;)l[t]=0,t||(++o,l.unshift(1));for(u=l.length;!l[u-1];--u);for(s=0,m="";s<u;s++)m+=Qt.charAt(l[s]);if(g){if(u>1)if(e==16||e==8){for(s=e==16?4:3,--u;u%s;u++)m+="0";for(l=gt(m,r,e),u=l.length;!l[u-1];--u);for(s=1,m="1.";s<u;s++)m+=Qt.charAt(l[s])}else m=m.charAt(0)+"."+m.slice(1);m=m+(o<0?"p":"p+")+o}else if(o<0){for(;++o;)m="0"+m;m="0."+m}else if(++o>u)for(o-=u;o--;)m+="0";else o<u&&(m=m.slice(0,o)+"."+m.slice(o))}m=(e==16?"0x":e==2?"0b":e==8?"0o":"")+m}return n.s<0?"-"+m:m}function Fn(n,e){if(n.length>e)return n.length=e,!0}function ur(n){return new this(n).abs()}function cr(n){return new this(n).acos()}function lr(n){return new this(n).acosh()}function mr(n,e){return new this(n).plus(e)}function dr(n){return new this(n).asin()}function pr(n){return new this(n).asinh()}function fr(n){return new this(n).atan()}function br(n){return new this(n).atanh()}function yr(n,e){n=new this(n),e=new this(e);var t,i=this.precision,r=this.rounding,o=i+4;return!n.s||!e.s?t=new this(NaN):!n.d&&!e.d?(t=ye(this,o,1).times(e.s>0?.25:.75),t.s=n.s):!e.d||n.isZero()?(t=e.s<0?ye(this,i,r):new this(0),t.s=n.s):!n.d||e.isZero()?(t=ye(this,o,1).times(.5),t.s=n.s):e.s<0?(this.precision=o,this.rounding=1,t=this.atan(W(n,e,o,1)),e=ye(this,o,1),this.precision=i,this.rounding=r,t=n.s<0?t.minus(e):t.plus(e)):t=this.atan(W(n,e,o,1)),t}function gr(n){return new this(n).cbrt()}function wr(n){return I(n=new this(n),n.e+1,2)}function Ar(n,e,t){return new this(n).clamp(e,t)}function Pr(n){if(!n||typeof n!="object")throw Error(kt+"Object expected");var e,t,i,r=n.defaults===!0,o=["precision",1,Ke,"rounding",0,8,"toExpNeg",-Ve,0,"toExpPos",0,Ve,"maxE",0,Ve,"minE",-Ve,0,"modulo",0,9];for(e=0;e<o.length;e+=3)if(t=o[e],r&&(this[t]=Jt[t]),(i=n[t])!==void 0)if(re(i)===i&&i>=o[e+1]&&i<=o[e+2])this[t]=i;else throw Error(Ce+t+": "+i);if(t="crypto",r&&(this[t]=Jt[t]),(i=n[t])!==void 0)if(i===!0||i===!1||i===0||i===1)if(i)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[t]=!0;else throw Error(_n);else this[t]=!1;else throw Error(Ce+t+": "+i);return this}function kr(n){return new this(n).cos()}function hr(n){return new this(n).cosh()}function Hn(n){var e,t,i;function r(o){var s,a,u,c=this;if(!(c instanceof r))return new r(o);if(c.constructor=r,En(o)){c.s=o.s,R?!o.d||o.e>r.maxE?(c.e=NaN,c.d=null):o.e<r.minE?(c.e=0,c.d=[0]):(c.e=o.e,c.d=o.d.slice()):(c.e=o.e,c.d=o.d?o.d.slice():o.d);return}if(u=typeof o,u==="number"){if(o===0){c.s=1/o<0?-1:1,c.e=0,c.d=[0];return}if(o<0?(o=-o,c.s=-1):c.s=1,o===~~o&&o<1e7){for(s=0,a=o;a>=10;a/=10)s++;R?s>r.maxE?(c.e=NaN,c.d=null):s<r.minE?(c.e=0,c.d=[0]):(c.e=s,c.d=[o]):(c.e=s,c.d=[o]);return}else if(o*0!==0){o||(c.s=NaN),c.e=NaN,c.d=null;return}return tn(c,o.toString())}else if(u!=="string")throw Error(Ce+o);return(a=o.charCodeAt(0))===45?(o=o.slice(1),c.s=-1):(a===43&&(o=o.slice(1)),c.s=1),Wn.test(o)?tn(c,o):sr(c,o)}if(r.prototype=A,r.ROUND_UP=0,r.ROUND_DOWN=1,r.ROUND_CEIL=2,r.ROUND_FLOOR=3,r.ROUND_HALF_UP=4,r.ROUND_HALF_DOWN=5,r.ROUND_HALF_EVEN=6,r.ROUND_HALF_CEIL=7,r.ROUND_HALF_FLOOR=8,r.EUCLID=9,r.config=r.set=Pr,r.clone=Hn,r.isDecimal=En,r.abs=ur,r.acos=cr,r.acosh=lr,r.add=mr,r.asin=dr,r.asinh=pr,r.atan=fr,r.atanh=br,r.atan2=yr,r.cbrt=gr,r.ceil=wr,r.clamp=Ar,r.cos=kr,r.cosh=hr,r.div=Tr,r.exp=Br,r.floor=xr,r.hypot=Ir,r.ln=Sr,r.log=Cr,r.log10=Nr,r.log2=Kr,r.max=Lr,r.min=Rr,r.mod=Mr,r.mul=Or,r.pow=Fr,r.random=Er,r.round=vr,r.sign=Dr,r.sin=_r,r.sinh=Vr,r.sqrt=Wr,r.sub=qr,r.sum=Ur,r.tan=Gr,r.tanh=Xr,r.trunc=zr,n===void 0&&(n={}),n&&n.defaults!==!0)for(i=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],e=0;e<i.length;)n.hasOwnProperty(t=i[e++])||(n[t]=this[t]);return r.config(n),r}function Tr(n,e){return new this(n).div(e)}function Br(n){return new this(n).exp()}function xr(n){return I(n=new this(n),n.e+1,3)}function Ir(){var n,e,t=new this(0);for(R=!1,n=0;n<arguments.length;)if(e=new this(arguments[n++]),e.d)t.d&&(t=t.plus(e.times(e)));else{if(e.s)return R=!0,new this(1/0);t=e}return R=!0,t.sqrt()}function En(n){return n instanceof tt||n&&n.toStringTag===Vn||!1}function Sr(n){return new this(n).ln()}function Cr(n,e){return new this(n).log(e)}function Kr(n){return new this(n).log(2)}function Nr(n){return new this(n).log(10)}function Lr(){return Gn(this,arguments,"lt")}function Rr(){return Gn(this,arguments,"gt")}function Mr(n,e){return new this(n).mod(e)}function Or(n,e){return new this(n).mul(e)}function Fr(n,e){return new this(n).pow(e)}function Er(n){var e,t,i,r,o=0,s=new this(1),a=[];if(n===void 0?n=this.precision:ce(n,1,Ke),i=Math.ceil(n/K),this.crypto)if(crypto.getRandomValues)for(e=crypto.getRandomValues(new Uint32Array(i));o<i;)r=e[o],r>=429e7?e[o]=crypto.getRandomValues(new Uint32Array(1))[0]:a[o++]=r%1e7;else if(crypto.randomBytes){for(e=crypto.randomBytes(i*=4);o<i;)r=e[o]+(e[o+1]<<8)+(e[o+2]<<16)+((e[o+3]&127)<<24),r>=214e7?crypto.randomBytes(4).copy(e,o):(a.push(r%1e7),o+=4);o=i/4}else throw Error(_n);else for(;o<i;)a[o++]=Math.random()*1e7|0;for(i=a[--o],n%=K,i&&n&&(r=Q(10,K-n),a[o]=(i/r|0)*r);a[o]===0;o--)a.pop();if(o<0)t=0,a=[0];else{for(t=-1;a[0]===0;t-=K)a.shift();for(i=1,r=a[0];r>=10;r/=10)i++;i<K&&(t-=K-i)}return s.e=t,s.d=a,s}function vr(n){return I(n=new this(n),n.e+1,this.rounding)}function Dr(n){return n=new this(n),n.d?n.d[0]?n.s:0*n.s:n.s||NaN}function _r(n){return new this(n).sin()}function Vr(n){return new this(n).sinh()}function Wr(n){return new this(n).sqrt()}function qr(n,e){return new this(n).sub(e)}function Ur(){var n=0,e=arguments,t=new this(e[n]);for(R=!1;t.s&&++n<e.length;)t=t.plus(e[n]);return R=!0,I(t,this.precision,this.rounding)}function Gr(n){return new this(n).tan()}function Xr(n){return new this(n).tanh()}function zr(n){return I(n=new this(n),n.e+1,1)}A[Symbol.for("nodejs.util.inspect.custom")]=A.toString;A[Symbol.toStringTag]="Decimal";var tt=A.constructor=Hn(Jt);wt=new tt(wt);At=new tt(At);var J=tt;var di=z(require("big.js")),fo=z(require("bn.js"));var nt=require("lodash");var rn=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(i=>typeof i=="object"?JSON.stringify(i):i).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}},Zn={},Hr={};function ne(n){let e=(0,nt.get)(Zn,n);if(!e){let t=(0,nt.get)(Hr,n);e=new rn({name:n,logLevel:t}),(0,nt.set)(Zn,n,e)}return e}var an=require("@solana/web3.js");var Ne=require("@solana/spl-token"),on=ne("Raydium_accountInfo_util");async function it(n,e,t){let{batchRequest:i,commitment:r="confirmed",chunkCount:o=100}={batchRequest:!1,...t},s=sn(e,o),a=new Array(s.length).fill([]);if(i){let u=s.map(l=>{let d=n._buildArgs([l.map(p=>p.toBase58())],r,"base64");return{methodName:"getMultipleAccounts",args:d}}),c=sn(u,10);a=(await(await Promise.all(c.map(async l=>await n._rpcBatchRequest(l)))).flat()).map(l=>(l.error&&on.logWithError(`failed to get info for multiple accounts, RPC_ERROR, ${l.error.message}`),l.result.value.map(d=>{if(d){let{data:p,executable:g,lamports:f,owner:P,rentEpoch:b}=d;return p.length!==2&&p[1]!=="base64"&&on.logWithError("info must be base64 encoded, RPC_ERROR"),{data:Buffer.from(p[0],"base64"),executable:g,lamports:f,owner:new an.PublicKey(P),rentEpoch:b}}return null})))}else try{a=await Promise.all(s.map(u=>n.getMultipleAccountsInfo(u,r)))}catch(u){u instanceof Error&&on.logWithError(`failed to get info for multiple accounts, RPC_ERROR, ${u.message}`)}return a.flat()}async function Fe(n,e,t){let i=await it(n,e.map(r=>r.pubkey),t);return e.map((r,o)=>({...r,accountInfo:i[o]}))}async function un({connection:n,mints:e,config:t}){var o,s,a;if(e.length===0)return{};let i=await Fe(n,e.map(u=>({pubkey:rt(u)})),t),r={};for(let u of i){if(!u.accountInfo||u.accountInfo.data.length<Ne.MINT_SIZE){console.log("invalid mint account",u.pubkey.toBase58());continue}let c=(0,Ne.unpackMint)(u.pubkey,u.accountInfo,(o=u.accountInfo)==null?void 0:o.owner);r[u.pubkey.toString()]={...c,programId:((s=u.accountInfo)==null?void 0:s.owner)||Ne.TOKEN_PROGRAM_ID,feeConfig:(a=(0,Ne.getTransferFeeConfig)(c))!=null?a:void 0}}return r[an.PublicKey.default.toBase58()]=r[de.toBase58()],r}var qe=z(require("bn.js"));var jn=9007199254740991;function Ae(n){let e=ne("Raydium_parseBigNumberish");if(n instanceof qe.default)return n;if(typeof n=="string"){if(n.match(/^-?[0-9]+$/))return new qe.default(n);e.logWithError(`invalid BigNumberish string: ${n}`)}return typeof n=="number"?(n%1&&e.logWithError(`BigNumberish number underflow: ${n}`),(n>=jn||n<=-jn)&&e.logWithError(`BigNumberish number overflow: ${n}`),new qe.default(String(n))):typeof n=="bigint"?new qe.default(n.toString()):(e.error(`invalid BigNumberish value: ${n}`),new qe.default(0))}var Yn=require("@solana/web3.js"),cn=require("@solana/spl-token"),ln={chainId:101,address:Yn.PublicKey.default.toBase58(),programId:cn.TOKEN_PROGRAM_ID.toBase58(),decimals:9,symbol:"SOL",name:"solana",logoURI:"https://img.raydium.io/icon/So11111111111111111111111111111111111111112.png",tags:[],priority:2,type:"raydium",extensions:{coingeckoId:"solana"}},Le={chainId:101,address:"So11111111111111111111111111111111111111112",programId:cn.TOKEN_PROGRAM_ID.toBase58(),decimals:9,symbol:"WSOL",name:"Wrapped SOL",logoURI:"https://img.raydium.io/icon/So11111111111111111111111111111111111111112.png",tags:[],priority:2,type:"raydium",extensions:{coingeckoId:"solana"}};var St=require("@solana/web3.js");var v=require("@solana/web3.js"),Qn=require("@solana/spl-token");function mn({pubkey:n,isSigner:e=!1,isWritable:t=!0}){return{pubkey:n,isWritable:t,isSigner:e}}var ws=[mn({pubkey:Qn.TOKEN_PROGRAM_ID,isWritable:!1}),mn({pubkey:v.SystemProgram.programId,isWritable:!1}),mn({pubkey:v.SYSVAR_RENT_PUBKEY,isWritable:!1})];function dn({publicKey:n,transformSol:e}){let t=Jn(n.toString());if(t instanceof v.PublicKey)return e&&t.equals(ot)?de:t;if(e&&t.toString()===ot.toBase58())return de;if(typeof t=="string"){if(t===v.PublicKey.default.toBase58())return v.PublicKey.default;try{return new v.PublicKey(t)}catch{throw new Error("invalid public key")}}throw new Error("invalid public key")}function Jn(n){try{return new v.PublicKey(n)}catch{return n}}var Zr=new v.PublicKey("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),Bt=new v.PublicKey("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),xt=new v.PublicKey("SysvarRent111111111111111111111111111111111"),As=new v.PublicKey("SysvarC1ock11111111111111111111111111111111"),Ue=new v.PublicKey("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"),Ps=new v.PublicKey("Sysvar1nstructions1111111111111111111111111"),It=v.SystemProgram.programId,ks=new v.PublicKey("2cpMA1jNS4obgRz8XNg38QuSP83L1AXpUgfxPNcvnAGj"),hs=new v.PublicKey("Ea5SjE2Y6yvCeW5dYTn7PYMuW5ikXkvbGdcmSnXeaLjS"),Ts=new v.PublicKey("SRMuApVNdxXokk5GT7XD5cUUgXMBCoAz2LHeuAoKWRt"),Bs=new v.PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"),xs=new v.PublicKey("Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB"),Is=new v.PublicKey("mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So"),Ss=new v.PublicKey("7dHbWXmci3dT8UFYWYZweBLXgycu7Y3iL6trKn1Y7ARj"),Cs=new v.PublicKey("USDH1SM1ojwWUga67PGrgFWUHibbjqMvuMaDkRJTgkX"),Ks=new v.PublicKey("NRVwhjBQiUPYtfDT5zRBVJajzFQHaBUNtC7SNVvqRFa"),Ns=new v.PublicKey("ANAxByE6G2WjFp7A4NqtWYXb3mgruyzZYg3spfxe6Lbo"),Ls=new v.PublicKey("7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs"),de=new v.PublicKey("So11111111111111111111111111111111111111112"),ot=v.PublicKey.default;function rt(n){return dn({publicKey:n,transformSol:!0})}var pn=class{constructor({mint:e,decimals:t,symbol:i,name:r,skipMint:o=!1,isToken2022:s=!1}){if(e===ot.toBase58()||e instanceof St.PublicKey&&ot.equals(e)){this.decimals=Le.decimals,this.symbol=Le.symbol,this.name=Le.name,this.mint=new St.PublicKey(Le.address),this.isToken2022=!1;return}this.decimals=t,this.symbol=i||e.toString().substring(0,6),this.name=r||e.toString().substring(0,6),this.mint=o?St.PublicKey.default:dn({publicKey:e}),this.isToken2022=s}equals(e){return this===e?!0:this.mint.equals(e.mint)}},Re=pn;Re.WSOL=new pn({...Le,mint:Le.address});var fn=class{constructor({decimals:e,symbol:t="UNKNOWN",name:i="UNKNOWN"}){this.decimals=e,this.symbol=t,this.name=i}equals(e){return this===e}},Ct=fn;Ct.SOL=new fn(ln);var $n=z(require("toformat")),jr=$n.default,st=jr;var at=z(require("big.js")),ei=z(require("bn.js")),ti=z(require("decimal.js-light"));var Kt=ne("module/fraction"),bn=st(at.default),ut=st(ti.default),Qr={[0]:ut.ROUND_DOWN,[1]:ut.ROUND_HALF_UP,[2]:ut.ROUND_UP},Jr={[0]:at.default.roundDown,[1]:at.default.roundHalfUp,[2]:at.default.roundUp},U=class{constructor(e,t=new ei.default(1)){this.numerator=Ae(e),this.denominator=Ae(t)}get quotient(){return this.numerator.div(this.denominator)}invert(){return new U(this.denominator,this.numerator)}add(e){let t=e instanceof U?e:new U(Ae(e));return this.denominator.eq(t.denominator)?new U(this.numerator.add(t.numerator),this.denominator):new U(this.numerator.mul(t.denominator).add(t.numerator.mul(this.denominator)),this.denominator.mul(t.denominator))}sub(e){let t=e instanceof U?e:new U(Ae(e));return this.denominator.eq(t.denominator)?new U(this.numerator.sub(t.numerator),this.denominator):new U(this.numerator.mul(t.denominator).sub(t.numerator.mul(this.denominator)),this.denominator.mul(t.denominator))}mul(e){let t=e instanceof U?e:new U(Ae(e));return new U(this.numerator.mul(t.numerator),this.denominator.mul(t.denominator))}div(e){let t=e instanceof U?e:new U(Ae(e));return new U(this.numerator.mul(t.denominator),this.denominator.mul(t.numerator))}toSignificant(e,t={groupSeparator:""},i=1){Number.isInteger(e)||Kt.logWithError(`${e} is not an integer.`),e<=0&&Kt.logWithError(`${e} is not positive.`),ut.set({precision:e+1,rounding:Qr[i]});let r=new ut(this.numerator.toString()).div(this.denominator.toString()).toSignificantDigits(e);return r.toFormat(r.decimalPlaces(),t)}toFixed(e,t={groupSeparator:""},i=1){return Number.isInteger(e)||Kt.logWithError(`${e} is not an integer.`),e<0&&Kt.logWithError(`${e} is negative.`),bn.DP=e,bn.RM=Jr[i]||1,new bn(this.numerator.toString()).div(this.denominator.toString()).toFormat(e,t)}isZero(){return this.numerator.isZero()}};var ii=z(require("bn.js"));var ni=new U(new ii.default(100)),pe=class extends U{toSignificant(e=5,t,i){return this.mul(ni).toSignificant(e,t,i)}toFixed(e=2,t,i){return this.mul(ni).toFixed(e,t,i)}};var Js=ne("Raydium_price");function sn(n,e=1,t=[]){let i=[...n];if(e<=0)return t;for(;i.length;)t.push(i.splice(0,e));return t}var ai=require("@solana/web3.js"),ui=require("@solana/spl-token");var oe=require("@solana/web3.js");var ue={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",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",FarmV5Deposit:"FarmV5Deposit",FarmV5Withdraw:"FarmV5Withdraw",FarmV5CreateLedger:"FarmV5CreateLedger",FarmV6Deposit:"FarmV6Deposit",FarmV6Withdraw:"FarmV6Withdraw",FarmV6Create:"FarmV6Create",FarmV6Restart:"FarmV6Restart",FarmV6CreatorAddReward:"FarmV6CreatorAddReward",FarmV6CreatorWithdraw:"FarmV6CreatorWithdraw",CpmmCreatePool:"CpmmCreatePool",CpmmCreateConfig:"CpmmCreateConfig",CpmmAddLiquidity:"CpmmAddLiquidity",CpmmWithdrawLiquidity:"CpmmWithdrawLiquidity",CpmmSwapBaseIn:"CpmmSwapBaseIn",CpmmSwapBaseOut:"CpmmSwapBaseOut",CpmmLockLp:"CpmmLockLp",CpmmCollectLockFee:"CpmmCollectLockFee"};var oi=require("@solana/spl-token"),ri=ne("Raydium_txUtil"),si=1644;function Lt(n){let e=[],t=[];return n.microLamports&&(e.push(oe.ComputeBudgetProgram.setComputeUnitPrice({microLamports:n.microLamports})),t.push(ue.SetComputeUnitPrice)),n.units&&(e.push(oe.ComputeBudgetProgram.setComputeUnitLimit({units:n.units})),t.push(ue.SetComputeUnitLimit)),{instructions:e,instructionTypes:t}}async function Ge(n,e){var i,r;let t=e!=null?e:"confirmed";return(r=await((i=n.getLatestBlockhash)==null?void 0:i.call(n,{commitment:t})))==null?void 0:r.blockhash}async function Rt(n,e){return n.getSignatureStatuses([e]),new Promise((t,i)=>{let r=setTimeout(i,6e4);n.onSignature(e,o=>{if(clearTimeout(r),!o.err){t("");return}i(o.err.toString())},"confirmed")})}function $r(n,e){n.length<1&&ri.logWithError(`no instructions provided: ${n.toString()}`),e.length<1&&ri.logWithError(`no signers provided:, ${e.toString()}`);let t=new oe.Transaction;t.recentBlockhash="11111111111111111111111111111111",t.feePayer=e[0],t.add(...n);try{return Buffer.from(t.serialize({verifySignatures:!1})).toString("base64").length<si}catch{return!1}}function fe(n,e){let[t,i]=oe.PublicKey.findProgramAddressSync(n,e);return{publicKey:t,nonce:i}}function ct({instructions:n,payer:e,signers:t}){return $r(n,[e,...t])}function lt({instructions:n,payer:e,lookupTableAddressAccount:t,recentBlockhash:i=oe.Keypair.generate().publicKey.toString()}){let o=new oe.TransactionMessage({payerKey:e,recentBlockhash:i,instructions:n}).compileToV0Message(Object.values(t!=null?t:{}));try{return Buffer.from(new oe.VersionedTransaction(o).serialize()).toString("base64").length<si}catch{return!1}}var eo=n=>Buffer.isBuffer(n)?n:n instanceof Uint8Array?Buffer.from(n.buffer,n.byteOffset,n.byteLength):Buffer.from(n),to=n=>{let e=n.serialize({requireAllSignatures:!1,verifySignatures:!1});n instanceof oe.VersionedTransaction&&(e=eo(e));try{return e instanceof Buffer?e.toString("base64"):Buffer.from(e).toString("base64")}catch{return e.toString("base64")}};function Ee(n){let e=[];return n.forEach(t=>{t instanceof oe.Transaction&&(t.recentBlockhash||(t.recentBlockhash=oi.TOKEN_PROGRAM_ID.toBase58()),t.feePayer||(t.feePayer=oe.Keypair.generate().publicKey)),e.push(to(t))}),console.log("simulate tx string:",e),e}function Pe(n,e,t){return fe([n.toBuffer(),(t!=null?t:ui.TOKEN_PROGRAM_ID).toBuffer(),e.toBuffer()],new ai.PublicKey("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"))}var O=require("@solana/web3.js"),Sa=new O.PublicKey("EhhTKczWMGQt46ynNeRX1WfeagwwJd7ufHvCDjRxjo5Q"),Ca=new O.PublicKey("9KEPoZmtHUrBbhWN1v1KWLMkkvwY6WLtAVUCPRtRjP4z"),Ka=new O.PublicKey("FarmqiPv5eAj3j1GMdMCMUGXqPUvmquZtMy86QH6rzhG"),Na=new O.PublicKey("CLaimxFqjHzgTJtAGHU47NPhg6qrc5sCnpC4tBLyABQS"),La=new O.PublicKey("srmqPvymJeFKQ4zGQed1GFppgkRHL9kaELCbyksJtPX"),Ra=new O.PublicKey("9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin"),Ma=new O.PublicKey("675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8"),Oa=new O.PublicKey("5quBtoiQqxF9Jv6KYKctB59NT3gtJD2Y65kdnB1Uev3h"),Fa=new O.PublicKey("CDSr3ssLcRB6XYPJwAfFt18MZvEZp4LjHcvzBVZ45duo"),no=new O.PublicKey("CAMMCzo5YL8w4VFF8KVHrK22GGUsp5VTaW7grrKgrWqK"),io=new O.PublicKey("LockrWmn6K5twhz3y9w1dQERbmgSaRkfnTeTKbpofwE"),ro=new O.PublicKey("kN1kEznaF5Xbd8LYuqtEFcxzWSBk5Fv6ygX6SqEGJVy"),Ea=new O.PublicKey("routeUGWgWzqBWFcrCfv8tritsqukccJPu3q5GPP3xS"),va=new O.PublicKey("7YttLkHDoNj9wyDur5pM1ejNaAvT9X4eqaYcHQqtj2G5"),Da=new O.PublicKey("6FJon3QE27qgPVggARueB22hLvoh22VzJpXv4rBEoSLF"),_a=new O.PublicKey("CC12se5To1CdEuw7fDS27B7Geo5jJyL7t5UK2B44NgiH"),Va=new O.PublicKey("9HzJyW1qZsEiSfMUf6L2jo3CcTKAyBmSyKdwQeYisHrC"),Wa=new O.PublicKey("DropEU8AvevN3UrXWXTMuz3rqnMczQVNjq3kcSdW2SQi"),ci=new O.PublicKey("SNaPnpKUY656VPwbKmKT8FG4T85g4VWhRH1B4TQUfKs"),li=new O.PublicKey("9pR79Lqe6wDNjag3v8MeVYUostoXjY2ognTydor6AtEZ"),qa=new O.PublicKey("DNXgeM9EiiaAbaWvwjHj9fQQLAX5ZsfHyvmYUNRAdNC8"),oo=new O.PublicKey("4AscABy58S62owbByjUUkQfZsP7fxYH1rDYb69V58HPM"),so=new O.PublicKey("7rQ1QFNosMkUCuh7Z7fPbTHvh73b68sQYdirycEzJVuw"),ao=new O.PublicKey("G11FKBRaAkHAKuLCgLM6K6NUc9rTjPAznRCjZifrTQe2"),Mt=new O.PublicKey("LockrWmn6K5twhz3y9w1dQERbmgSaRkfnTeTKbpofwE"),uo=new O.PublicKey("DLockwT7X7sxtLmGH9g5kmfcjaBtncdbUmi738m5bvQC"),Ot=new O.PublicKey("3f7GcQFG397GAaEnv51zR6tsTVihYRydnydDD1cXekxH"),co=new O.PublicKey("7AFUeLVRjBfzqK3tTGw8hN48KLQWSk6DTE8xprWdPqix");var Ua={SERUM_MARKET:O.PublicKey.default,OPENBOOK_MARKET:new O.PublicKey("EoTcMgcDRTJVZDMZWBoU6rhYHZfkNTVEAfz3uUJRcYGj"),UTIL1216:O.PublicKey.default,FarmV3:new O.PublicKey("85BFyr98MbCUU9MVTEgzx1nbhWACbJqLzho6zd6DZcWL"),FarmV5:new O.PublicKey("EcLzTrNg9V7qhcdyXDe2qjtPkiGzDM2UbdRaeaadU5r2"),FarmV6:new O.PublicKey("Farm2hJLcqPtPg8M4rR6DMrsRNc5TPm5Cs4bVQrMe2T7"),AmmV4:new O.PublicKey("HWy1jotHpo6UqeQxx49dpYYdQB8wj9Qk9MdxwjLvDHB8"),AmmStable:new O.PublicKey("DDg4VmQaJV9ogWce7LpcjBA9bv22wRp5uaTPa5pGjijF"),CLMM:new O.PublicKey("devi51mZmdwUJGU9hjN27vEz64Gps7uUefqxg27EAtH"),CLMM_LOCK_PROGRAM_ID:new O.PublicKey("DLockwT7X7sxtLmGH9g5kmfcjaBtncdbUmi738m5bvQC"),CLMM_LOCK_AUTH_ID:new O.PublicKey("8qmHNvu2Kr2C7U8mJL4Vz1vTDxMhVuXKREwU7TNoaVEo"),Router:new O.PublicKey("BVChZ3XFEwTMUk1o9i3HAf91H6mFxSwa5X2wFAWhYPhU"),CREATE_CPMM_POOL_PROGRAM:oo,CREATE_CPMM_POOL_AUTH:so,CREATE_CPMM_POOL_FEE_ACC:ao,FEE_DESTINATION_ID:new O.PublicKey("3XMrhbv989VxAMi3DErLV9eJht1pHppW5LbKxe9fkEFR"),LOCK_CPMM_PROGRAM:uo,LCOK_CPMM_AUTH:co};var be=z(require("bn.js")),mt=1e4;function ke(n,e,t,i){if(e===void 0)return{amount:n,fee:void 0,expirationTime:void 0};let r={...e,olderTransferFee:{epoch:BigInt(e.olderTransferFee.epoch),maximumFee:BigInt(e.olderTransferFee.maximumFee),transferFeeBasisPoints:e.olderTransferFee.transferFeeBasisPoints},newerTransferFee:{epoch:BigInt(e.newerTransferFee.epoch),maximumFee:BigInt(e.newerTransferFee.maximumFee),transferFeeBasisPoints:e.newerTransferFee.transferFeeBasisPoints}},o=t.epoch<r.newerTransferFee.epoch?r.olderTransferFee:r.newerTransferFee,s=new be.default(o.maximumFee.toString()),a=t.epoch<r.newerTransferFee.epoc