@cobaltx/sdk-v2
Version:
An SDK for building applications on top of CobaltX.
1 lines • 60.7 kB
JavaScript
import se from"bn.js";var xe=9e15,pe=1e9,nt="0123456789abcdef",Ge="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",Ve="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",rt={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-xe,maxE:xe,crypto:!1},Mt,ue,w=!0,Xe="[DecimalError] ",fe=Xe+"Invalid argument: ",Ft=Xe+"Precision limit exceeded",Ot=Xe+"crypto unavailable",Dt="[object Decimal]",U=Math.floor,O=Math.pow,bn=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,wn=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,yn=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,vt=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,ne=1e7,h=7,Tn=9007199254740991,xn=Ge.length-1,it=Ve.length-1,f={toStringTag:Dt};f.absoluteValue=f.abs=function(){var t=new this.constructor(this);return t.s<0&&(t.s=1),g(t)};f.ceil=function(){return g(new this.constructor(this),this.e+1,2)};f.clampedTo=f.clamp=function(t,e){var n,r=this,i=r.constructor;if(t=new i(t),e=new i(e),!t.s||!e.s)return new i(NaN);if(t.gt(e))throw Error(fe+e);return n=r.cmp(t),n<0?t:r.cmp(e)>0?e:new i(r)};f.comparedTo=f.cmp=function(t){var e,n,r,i,o=this,s=o.d,a=(t=new o.constructor(t)).d,c=o.s,u=t.s;if(!s||!a)return!c||!u?NaN:c!==u?c:s===a?0:!s^c<0?1:-1;if(!s[0]||!a[0])return s[0]?c:a[0]?-u:0;if(c!==u)return c;if(o.e!==t.e)return o.e>t.e^c<0?1:-1;for(r=s.length,i=a.length,e=0,n=r<i?r:i;e<n;++e)if(s[e]!==a[e])return s[e]>a[e]^c<0?1:-1;return r===i?0:r>i^c<0?1:-1};f.cosine=f.cos=function(){var t,e,n=this,r=n.constructor;return n.d?n.d[0]?(t=r.precision,e=r.rounding,r.precision=t+Math.max(n.e,n.sd())+h,r.rounding=1,n=An(r,Ut(r,n)),r.precision=t,r.rounding=e,g(ue==2||ue==3?n.neg():n,t,e,!0)):new r(1):new r(NaN)};f.cubeRoot=f.cbrt=function(){var t,e,n,r,i,o,s,a,c,u,m=this,l=m.constructor;if(!m.isFinite()||m.isZero())return new l(m);for(w=!1,o=m.s*O(m.s*m,1/3),!o||Math.abs(o)==1/0?(n=q(m.d),t=m.e,(o=(t-n.length+1)%3)&&(n+=o==1||o==-2?"0":"00"),o=O(n,1/3),t=U((t+1)/3)-(t%3==(t<0?-1:2)),o==1/0?n="5e"+t:(n=o.toExponential(),n=n.slice(0,n.indexOf("e")+1)+t),r=new l(n),r.s=m.s):r=new l(o.toString()),s=(t=l.precision)+3;;)if(a=r,c=a.times(a).times(a),u=c.plus(m),r=S(u.plus(m).times(a),u.plus(c),s+2,1),q(a.d).slice(0,s)===(n=q(r.d)).slice(0,s))if(n=n.slice(s-3,s+1),n=="9999"||!i&&n=="4999"){if(!i&&(g(a,t+1,0),a.times(a).times(a).eq(m))){r=a;break}s+=4,i=1}else{(!+n||!+n.slice(1)&&n.charAt(0)=="5")&&(g(r,t+1,1),e=!r.times(r).times(r).eq(m));break}return w=!0,g(r,t,l.rounding,e)};f.decimalPlaces=f.dp=function(){var t,e=this.d,n=NaN;if(e){if(t=e.length-1,n=(t-U(this.e/h))*h,t=e[t],t)for(;t%10==0;t/=10)n--;n<0&&(n=0)}return n};f.dividedBy=f.div=function(t){return S(this,new this.constructor(t))};f.dividedToIntegerBy=f.divToInt=function(t){var e=this,n=e.constructor;return g(S(e,new n(t),0,1,1),n.precision,n.rounding)};f.equals=f.eq=function(t){return this.cmp(t)===0};f.floor=function(){return g(new this.constructor(this),this.e+1,3)};f.greaterThan=f.gt=function(t){return this.cmp(t)>0};f.greaterThanOrEqualTo=f.gte=function(t){var e=this.cmp(t);return e==1||e===0};f.hyperbolicCosine=f.cosh=function(){var t,e,n,r,i,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;n=s.precision,r=s.rounding,s.precision=n+Math.max(o.e,o.sd())+4,s.rounding=1,i=o.d.length,i<32?(t=Math.ceil(i/3),e=(1/ze(4,t)).toString()):(t=16,e="2.3283064365386962890625e-10"),o=Ae(s,1,o.times(e),new s(1),!0);for(var c,u=t,m=new s(8);u--;)c=o.times(o),o=a.minus(c.times(m.minus(c.times(m))));return g(o,s.precision=n,s.rounding=r,!0)};f.hyperbolicSine=f.sinh=function(){var t,e,n,r,i=this,o=i.constructor;if(!i.isFinite()||i.isZero())return new o(i);if(e=o.precision,n=o.rounding,o.precision=e+Math.max(i.e,i.sd())+4,o.rounding=1,r=i.d.length,r<3)i=Ae(o,2,i,i,!0);else{t=1.4*Math.sqrt(r),t=t>16?16:t|0,i=i.times(1/ze(5,t)),i=Ae(o,2,i,i,!0);for(var s,a=new o(5),c=new o(16),u=new o(20);t--;)s=i.times(i),i=i.times(a.plus(s.times(c.times(s).plus(u))))}return o.precision=e,o.rounding=n,g(i,e,n,!0)};f.hyperbolicTangent=f.tanh=function(){var t,e,n=this,r=n.constructor;return n.isFinite()?n.isZero()?new r(n):(t=r.precision,e=r.rounding,r.precision=t+7,r.rounding=1,S(n.sinh(),n.cosh(),r.precision=t,r.rounding=e)):new r(n.s)};f.inverseCosine=f.acos=function(){var t,e=this,n=e.constructor,r=e.abs().cmp(1),i=n.precision,o=n.rounding;return r!==-1?r===0?e.isNeg()?te(n,i,o):new n(0):new n(NaN):e.isZero()?te(n,i+4,o).times(.5):(n.precision=i+6,n.rounding=1,e=e.asin(),t=te(n,i+4,o).times(.5),n.precision=i,n.rounding=o,t.minus(e))};f.inverseHyperbolicCosine=f.acosh=function(){var t,e,n=this,r=n.constructor;return n.lte(1)?new r(n.eq(1)?0:NaN):n.isFinite()?(t=r.precision,e=r.rounding,r.precision=t+Math.max(Math.abs(n.e),n.sd())+4,r.rounding=1,w=!1,n=n.times(n).minus(1).sqrt().plus(n),w=!0,r.precision=t,r.rounding=e,n.ln()):new r(n)};f.inverseHyperbolicSine=f.asinh=function(){var t,e,n=this,r=n.constructor;return!n.isFinite()||n.isZero()?new r(n):(t=r.precision,e=r.rounding,r.precision=t+2*Math.max(Math.abs(n.e),n.sd())+6,r.rounding=1,w=!1,n=n.times(n).plus(1).sqrt().plus(n),w=!0,r.precision=t,r.rounding=e,n.ln())};f.inverseHyperbolicTangent=f.atanh=function(){var t,e,n,r,i=this,o=i.constructor;return i.isFinite()?i.e>=0?new o(i.abs().eq(1)?i.s/0:i.isZero()?i:NaN):(t=o.precision,e=o.rounding,r=i.sd(),Math.max(r,t)<2*-i.e-1?g(new o(i),t,e,!0):(o.precision=n=r-i.e,i=S(i.plus(1),new o(1).minus(i),n+t,1),o.precision=t+4,o.rounding=1,i=i.ln(),o.precision=t,o.rounding=e,i.times(.5))):new o(NaN)};f.inverseSine=f.asin=function(){var t,e,n,r,i=this,o=i.constructor;return i.isZero()?new o(i):(e=i.abs().cmp(1),n=o.precision,r=o.rounding,e!==-1?e===0?(t=te(o,n+4,r).times(.5),t.s=i.s,t):new o(NaN):(o.precision=n+6,o.rounding=1,i=i.div(new o(1).minus(i.times(i)).sqrt().plus(1)).atan(),o.precision=n,o.rounding=r,i.times(2)))};f.inverseTangent=f.atan=function(){var t,e,n,r,i,o,s,a,c,u=this,m=u.constructor,l=m.precision,d=m.rounding;if(u.isFinite()){if(u.isZero())return new m(u);if(u.abs().eq(1)&&l+4<=it)return s=te(m,l+4,d).times(.25),s.s=u.s,s}else{if(!u.s)return new m(NaN);if(l+4<=it)return s=te(m,l+4,d).times(.5),s.s=u.s,s}for(m.precision=a=l+10,m.rounding=1,n=Math.min(28,a/h+2|0),t=n;t;--t)u=u.div(u.times(u).plus(1).sqrt().plus(1));for(w=!1,e=Math.ceil(a/h),r=1,c=u.times(u),s=new m(u),i=u;t!==-1;)if(i=i.times(c),o=s.minus(i.div(r+=2)),i=i.times(c),s=o.plus(i.div(r+=2)),s.d[e]!==void 0)for(t=e;s.d[t]===o.d[t]&&t--;);return n&&(s=s.times(2<<n-1)),w=!0,g(s,m.precision=l,m.rounding=d,!0)};f.isFinite=function(){return!!this.d};f.isInteger=f.isInt=function(){return!!this.d&&U(this.e/h)>this.d.length-2};f.isNaN=function(){return!this.s};f.isNegative=f.isNeg=function(){return this.s<0};f.isPositive=f.isPos=function(){return this.s>0};f.isZero=function(){return!!this.d&&this.d[0]===0};f.lessThan=f.lt=function(t){return this.cmp(t)<0};f.lessThanOrEqualTo=f.lte=function(t){return this.cmp(t)<1};f.logarithm=f.log=function(t){var e,n,r,i,o,s,a,c,u=this,m=u.constructor,l=m.precision,d=m.rounding,p=5;if(t==null)t=new m(10),e=!0;else{if(t=new m(t),n=t.d,t.s<0||!n||!n[0]||t.eq(1))return new m(NaN);e=t.eq(10)}if(n=u.d,u.s<0||!n||!n[0]||u.eq(1))return new m(n&&!n[0]?-1/0:u.s!=1?NaN:n?0:1/0);if(e)if(n.length>1)o=!0;else{for(i=n[0];i%10===0;)i/=10;o=i!==1}if(w=!1,a=l+p,s=de(u,a),r=e?Ue(m,a+10):de(t,a),c=S(s,r,a,1),Ne(c.d,i=l,d))do if(a+=10,s=de(u,a),r=e?Ue(m,a+10):de(t,a),c=S(s,r,a,1),!o){+q(c.d).slice(i+1,i+15)+1==1e14&&(c=g(c,l+1,0));break}while(Ne(c.d,i+=10,d));return w=!0,g(c,l,d)};f.minus=f.sub=function(t){var e,n,r,i,o,s,a,c,u,m,l,d,p=this,y=p.constructor;if(t=new y(t),!p.d||!t.d)return!p.s||!t.s?t=new y(NaN):p.d?t.s=-t.s:t=new y(t.d||p.s!==t.s?p:NaN),t;if(p.s!=t.s)return t.s=-t.s,p.plus(t);if(u=p.d,d=t.d,a=y.precision,c=y.rounding,!u[0]||!d[0]){if(d[0])t.s=-t.s;else if(u[0])t=new y(p);else return new y(c===3?-0:0);return w?g(t,a,c):t}if(n=U(t.e/h),m=U(p.e/h),u=u.slice(),o=m-n,o){for(l=o<0,l?(e=u,o=-o,s=d.length):(e=d,n=m,s=u.length),r=Math.max(Math.ceil(a/h),s)+2,o>r&&(o=r,e.length=1),e.reverse(),r=o;r--;)e.push(0);e.reverse()}else{for(r=u.length,s=d.length,l=r<s,l&&(s=r),r=0;r<s;r++)if(u[r]!=d[r]){l=u[r]<d[r];break}o=0}for(l&&(e=u,u=d,d=e,t.s=-t.s),s=u.length,r=d.length-s;r>0;--r)u[s++]=0;for(r=d.length;r>o;){if(u[--r]<d[r]){for(i=r;i&&u[--i]===0;)u[i]=ne-1;--u[i],u[r]+=ne}u[r]-=d[r]}for(;u[--s]===0;)u.pop();for(;u[0]===0;u.shift())--n;return u[0]?(t.d=u,t.e=We(u,n),w?g(t,a,c):t):new y(c===3?-0:0)};f.modulo=f.mod=function(t){var e,n=this,r=n.constructor;return t=new r(t),!n.d||!t.s||t.d&&!t.d[0]?new r(NaN):!t.d||n.d&&!n.d[0]?g(new r(n),r.precision,r.rounding):(w=!1,r.modulo==9?(e=S(n,t.abs(),0,3,1),e.s*=t.s):e=S(n,t,0,r.modulo,1),e=e.times(t),w=!0,n.minus(e))};f.naturalExponential=f.exp=function(){return ot(this)};f.naturalLogarithm=f.ln=function(){return de(this)};f.negated=f.neg=function(){var t=new this.constructor(this);return t.s=-t.s,g(t)};f.plus=f.add=function(t){var e,n,r,i,o,s,a,c,u,m,l=this,d=l.constructor;if(t=new d(t),!l.d||!t.d)return!l.s||!t.s?t=new d(NaN):l.d||(t=new d(t.d||l.s===t.s?l:NaN)),t;if(l.s!=t.s)return t.s=-t.s,l.minus(t);if(u=l.d,m=t.d,a=d.precision,c=d.rounding,!u[0]||!m[0])return m[0]||(t=new d(l)),w?g(t,a,c):t;if(o=U(l.e/h),r=U(t.e/h),u=u.slice(),i=o-r,i){for(i<0?(n=u,i=-i,s=m.length):(n=m,r=o,s=u.length),o=Math.ceil(a/h),s=o>s?o+1:s+1,i>s&&(i=s,n.length=1),n.reverse();i--;)n.push(0);n.reverse()}for(s=u.length,i=m.length,s-i<0&&(i=s,n=m,m=u,u=n),e=0;i;)e=(u[--i]=u[i]+m[i]+e)/ne|0,u[i]%=ne;for(e&&(u.unshift(e),++r),s=u.length;u[--s]==0;)u.pop();return t.d=u,t.e=We(u,r),w?g(t,a,c):t};f.precision=f.sd=function(t){var e,n=this;if(t!==void 0&&t!==!!t&&t!==1&&t!==0)throw Error(fe+t);return n.d?(e=Kt(n.d),t&&n.e+1>e&&(e=n.e+1)):e=NaN,e};f.round=function(){var t=this,e=t.constructor;return g(new e(t),t.e+1,e.rounding)};f.sine=f.sin=function(){var t,e,n=this,r=n.constructor;return n.isFinite()?n.isZero()?new r(n):(t=r.precision,e=r.rounding,r.precision=t+Math.max(n.e,n.sd())+h,r.rounding=1,n=kn(r,Ut(r,n)),r.precision=t,r.rounding=e,g(ue>2?n.neg():n,t,e,!0)):new r(NaN)};f.squareRoot=f.sqrt=function(){var t,e,n,r,i,o,s=this,a=s.d,c=s.e,u=s.s,m=s.constructor;if(u!==1||!a||!a[0])return new m(!u||u<0&&(!a||a[0])?NaN:a?s:1/0);for(w=!1,u=Math.sqrt(+s),u==0||u==1/0?(e=q(a),(e.length+c)%2==0&&(e+="0"),u=Math.sqrt(e),c=U((c+1)/2)-(c<0||c%2),u==1/0?e="5e"+c:(e=u.toExponential(),e=e.slice(0,e.indexOf("e")+1)+c),r=new m(e)):r=new m(u.toString()),n=(c=m.precision)+3;;)if(o=r,r=o.plus(S(s,o,n+2,1)).times(.5),q(o.d).slice(0,n)===(e=q(r.d)).slice(0,n))if(e=e.slice(n-3,n+1),e=="9999"||!i&&e=="4999"){if(!i&&(g(o,c+1,0),o.times(o).eq(s))){r=o;break}n+=4,i=1}else{(!+e||!+e.slice(1)&&e.charAt(0)=="5")&&(g(r,c+1,1),t=!r.times(r).eq(s));break}return w=!0,g(r,c,m.rounding,t)};f.tangent=f.tan=function(){var t,e,n=this,r=n.constructor;return n.isFinite()?n.isZero()?new r(n):(t=r.precision,e=r.rounding,r.precision=t+10,r.rounding=1,n=n.sin(),n.s=1,n=S(n,new r(1).minus(n.times(n)).sqrt(),t+10,0),r.precision=t,r.rounding=e,g(ue==2||ue==4?n.neg():n,t,e,!0)):new r(NaN)};f.times=f.mul=function(t){var e,n,r,i,o,s,a,c,u,m=this,l=m.constructor,d=m.d,p=(t=new l(t)).d;if(t.s*=m.s,!d||!d[0]||!p||!p[0])return new l(!t.s||d&&!d[0]&&!p||p&&!p[0]&&!d?NaN:!d||!p?t.s/0:t.s*0);for(n=U(m.e/h)+U(t.e/h),c=d.length,u=p.length,c<u&&(o=d,d=p,p=o,s=c,c=u,u=s),o=[],s=c+u,r=s;r--;)o.push(0);for(r=u;--r>=0;){for(e=0,i=c+r;i>r;)a=o[i]+p[r]*d[i-r-1]+e,o[i--]=a%ne|0,e=a/ne|0;o[i]=(o[i]+e)%ne|0}for(;!o[--s];)o.pop();return e?++n:o.shift(),t.d=o,t.e=We(o,n),w?g(t,l.precision,l.rounding):t};f.toBinary=function(t,e){return at(this,2,t,e)};f.toDecimalPlaces=f.toDP=function(t,e){var n=this,r=n.constructor;return n=new r(n),t===void 0?n:(H(t,0,pe),e===void 0?e=r.rounding:H(e,0,8),g(n,t+n.e+1,e))};f.toExponential=function(t,e){var n,r=this,i=r.constructor;return t===void 0?n=oe(r,!0):(H(t,0,pe),e===void 0?e=i.rounding:H(e,0,8),r=g(new i(r),t+1,e),n=oe(r,!0,t+1)),r.isNeg()&&!r.isZero()?"-"+n:n};f.toFixed=function(t,e){var n,r,i=this,o=i.constructor;return t===void 0?n=oe(i):(H(t,0,pe),e===void 0?e=o.rounding:H(e,0,8),r=g(new o(i),t+i.e+1,e),n=oe(r,!1,t+r.e+1)),i.isNeg()&&!i.isZero()?"-"+n:n};f.toFraction=function(t){var e,n,r,i,o,s,a,c,u,m,l,d,p=this,y=p.d,b=p.constructor;if(!y)return new b(p);if(u=n=new b(1),r=c=new b(0),e=new b(r),o=e.e=Kt(y)-p.e-1,s=o%h,e.d[0]=O(10,s<0?h+s:s),t==null)t=o>0?e:u;else{if(a=new b(t),!a.isInt()||a.lt(u))throw Error(fe+a);t=a.gt(e)?o>0?e:u:a}for(w=!1,a=new b(q(y)),m=b.precision,b.precision=o=y.length*h*2;l=S(a,e,0,1,1),i=n.plus(l.times(r)),i.cmp(t)!=1;)n=r,r=i,i=u,u=c.plus(l.times(i)),c=i,i=e,e=a.minus(l.times(i)),a=i;return i=S(t.minus(n),r,0,1,1),c=c.plus(i.times(u)),n=n.plus(i.times(r)),c.s=u.s=p.s,d=S(u,r,o,1).minus(p).abs().cmp(S(c,n,o,1).minus(p).abs())<1?[u,r]:[c,n],b.precision=m,w=!0,d};f.toHexadecimal=f.toHex=function(t,e){return at(this,16,t,e)};f.toNearest=function(t,e){var n=this,r=n.constructor;if(n=new r(n),t==null){if(!n.d)return n;t=new r(1),e=r.rounding}else{if(t=new r(t),e===void 0?e=r.rounding:H(e,0,8),!n.d)return t.s?n:t;if(!t.d)return t.s&&(t.s=n.s),t}return t.d[0]?(w=!1,n=S(n,t,0,e,1).times(t),w=!0,g(n)):(t.s=n.s,n=t),n};f.toNumber=function(){return+this};f.toOctal=function(t,e){return at(this,8,t,e)};f.toPower=f.pow=function(t){var e,n,r,i,o,s,a=this,c=a.constructor,u=+(t=new c(t));if(!a.d||!t.d||!a.d[0]||!t.d[0])return new c(O(+a,u));if(a=new c(a),a.eq(1))return a;if(r=c.precision,o=c.rounding,t.eq(1))return g(a,r,o);if(e=U(t.e/h),e>=t.d.length-1&&(n=u<0?-u:u)<=Tn)return i=qt(c,a,n,r),t.s<0?new c(1).div(i):g(i,r,o);if(s=a.s,s<0){if(e<t.d.length-1)return new c(NaN);if((t.d[e]&1)==0&&(s=1),a.e==0&&a.d[0]==1&&a.d.length==1)return a.s=s,a}return n=O(+a,u),e=n==0||!isFinite(n)?U(u*(Math.log("0."+q(a.d))/Math.LN10+a.e+1)):new c(n+"").e,e>c.maxE+1||e<c.minE-1?new c(e>0?s/0:0):(w=!1,c.rounding=a.s=1,n=Math.min(12,(e+"").length),i=ot(t.times(de(a,r+n)),r),i.d&&(i=g(i,r+5,1),Ne(i.d,r,o)&&(e=r+10,i=g(ot(t.times(de(a,e+n)),e),e+5,1),+q(i.d).slice(r+1,r+15)+1==1e14&&(i=g(i,r+1,0)))),i.s=s,w=!0,c.rounding=o,g(i,r,o))};f.toPrecision=function(t,e){var n,r=this,i=r.constructor;return t===void 0?n=oe(r,r.e<=i.toExpNeg||r.e>=i.toExpPos):(H(t,1,pe),e===void 0?e=i.rounding:H(e,0,8),r=g(new i(r),t,e),n=oe(r,t<=r.e||r.e<=i.toExpNeg,t)),r.isNeg()&&!r.isZero()?"-"+n:n};f.toSignificantDigits=f.toSD=function(t,e){var n=this,r=n.constructor;return t===void 0?(t=r.precision,e=r.rounding):(H(t,1,pe),e===void 0?e=r.rounding:H(e,0,8)),g(new r(n),t,e)};f.toString=function(){var t=this,e=t.constructor,n=oe(t,t.e<=e.toExpNeg||t.e>=e.toExpPos);return t.isNeg()&&!t.isZero()?"-"+n:n};f.truncated=f.trunc=function(){return g(new this.constructor(this),this.e+1,1)};f.valueOf=f.toJSON=function(){var t=this,e=t.constructor,n=oe(t,t.e<=e.toExpNeg||t.e>=e.toExpPos);return t.isNeg()?"-"+n:n};function q(t){var e,n,r,i=t.length-1,o="",s=t[0];if(i>0){for(o+=s,e=1;e<i;e++)r=t[e]+"",n=h-r.length,n&&(o+=le(n)),o+=r;s=t[e],r=s+"",n=h-r.length,n&&(o+=le(n))}else if(s===0)return"0";for(;s%10===0;)s/=10;return o+s}function H(t,e,n){if(t!==~~t||t<e||t>n)throw Error(fe+t)}function Ne(t,e,n,r){var i,o,s,a;for(o=t[0];o>=10;o/=10)--e;return--e<0?(e+=h,i=0):(i=Math.ceil((e+1)/h),e%=h),o=O(10,h-e),a=t[i]%o|0,r==null?e<3?(e==0?a=a/100|0:e==1&&(a=a/10|0),s=n<4&&a==99999||n>3&&a==49999||a==5e4||a==0):s=(n<4&&a+1==o||n>3&&a+1==o/2)&&(t[i+1]/o/100|0)==O(10,e-2)-1||(a==o/2||a==0)&&(t[i+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=(r||n<4)&&a==9999||!r&&n>3&&a==4999):s=((r||n<4)&&a+1==o||!r&&n>3&&a+1==o/2)&&(t[i+1]/o/1e3|0)==O(10,e-3)-1,s}function qe(t,e,n){for(var r,i=[0],o,s=0,a=t.length;s<a;){for(o=i.length;o--;)i[o]*=e;for(i[0]+=nt.indexOf(t.charAt(s++)),r=0;r<i.length;r++)i[r]>n-1&&(i[r+1]===void 0&&(i[r+1]=0),i[r+1]+=i[r]/n|0,i[r]%=n)}return i.reverse()}function An(t,e){var n,r,i;if(e.isZero())return e;r=e.d.length,r<32?(n=Math.ceil(r/3),i=(1/ze(4,n)).toString()):(n=16,i="2.3283064365386962890625e-10"),t.precision+=n,e=Ae(t,1,e.times(i),new t(1));for(var o=n;o--;){var s=e.times(e);e=s.times(s).minus(s).times(8).plus(1)}return t.precision-=n,e}var S=function(){function t(r,i,o){var s,a=0,c=r.length;for(r=r.slice();c--;)s=r[c]*i+a,r[c]=s%o|0,a=s/o|0;return a&&r.unshift(a),r}function e(r,i,o,s){var a,c;if(o!=s)c=o>s?1:-1;else for(a=c=0;a<o;a++)if(r[a]!=i[a]){c=r[a]>i[a]?1:-1;break}return c}function n(r,i,o,s){for(var a=0;o--;)r[o]-=a,a=r[o]<i[o]?1:0,r[o]=a*s+r[o]-i[o];for(;!r[0]&&r.length>1;)r.shift()}return function(r,i,o,s,a,c){var u,m,l,d,p,y,b,M,N,K,I,F,be,ae,$e,De,Ie,et,ee,ve,Ke=r.constructor,tt=r.s==i.s?1:-1,V=r.d,L=i.d;if(!V||!V[0]||!L||!L[0])return new Ke(!r.s||!i.s||(V?L&&V[0]==L[0]:!L)?NaN:V&&V[0]==0||!L?tt*0:tt/0);for(c?(p=1,m=r.e-i.e):(c=ne,p=h,m=U(r.e/p)-U(i.e/p)),ee=L.length,Ie=V.length,N=new Ke(tt),K=N.d=[],l=0;L[l]==(V[l]||0);l++);if(L[l]>(V[l]||0)&&m--,o==null?(ae=o=Ke.precision,s=Ke.rounding):a?ae=o+(r.e-i.e)+1:ae=o,ae<0)K.push(1),y=!0;else{if(ae=ae/p+2|0,l=0,ee==1){for(d=0,L=L[0],ae++;(l<Ie||d)&&ae--;l++)$e=d*c+(V[l]||0),K[l]=$e/L|0,d=$e%L|0;y=d||l<Ie}else{for(d=c/(L[0]+1)|0,d>1&&(L=t(L,d,c),V=t(V,d,c),ee=L.length,Ie=V.length),De=ee,I=V.slice(0,ee),F=I.length;F<ee;)I[F++]=0;ve=L.slice(),ve.unshift(0),et=L[0],L[1]>=c/2&&++et;do d=0,u=e(L,I,ee,F),u<0?(be=I[0],ee!=F&&(be=be*c+(I[1]||0)),d=be/et|0,d>1?(d>=c&&(d=c-1),b=t(L,d,c),M=b.length,F=I.length,u=e(b,I,M,F),u==1&&(d--,n(b,ee<M?ve:L,M,c))):(d==0&&(u=d=1),b=L.slice()),M=b.length,M<F&&b.unshift(0),n(I,b,F,c),u==-1&&(F=I.length,u=e(L,I,ee,F),u<1&&(d++,n(I,ee<F?ve:L,F,c))),F=I.length):u===0&&(d++,I=[0]),K[l++]=d,u&&I[0]?I[F++]=V[De]||0:(I=[V[De]],F=1);while((De++<Ie||I[0]!==void 0)&&ae--);y=I[0]!==void 0}K[0]||K.shift()}if(p==1)N.e=m,Mt=y;else{for(l=1,d=K[0];d>=10;d/=10)l++;N.e=l+m*p-1,g(N,a?o+N.e+1:o,s,y)}return N}}();function g(t,e,n,r){var i,o,s,a,c,u,m,l,d,p=t.constructor;e:if(e!=null){if(l=t.d,!l)return t;for(i=1,a=l[0];a>=10;a/=10)i++;if(o=e-i,o<0)o+=h,s=e,m=l[d=0],c=m/O(10,i-s-1)%10|0;else if(d=Math.ceil((o+1)/h),a=l.length,d>=a)if(r){for(;a++<=d;)l.push(0);m=c=0,i=1,o%=h,s=o-h+1}else break e;else{for(m=a=l[d],i=1;a>=10;a/=10)i++;o%=h,s=o-h+i,c=s<0?0:m/O(10,i-s-1)%10|0}if(r=r||e<0||l[d+1]!==void 0||(s<0?m:m%O(10,i-s-1)),u=n<4?(c||r)&&(n==0||n==(t.s<0?3:2)):c>5||c==5&&(n==4||r||n==6&&(o>0?s>0?m/O(10,i-s):0:l[d-1])%10&1||n==(t.s<0?8:7)),e<1||!l[0])return l.length=0,u?(e-=t.e+1,l[0]=O(10,(h-e%h)%h),t.e=-e||0):l[0]=t.e=0,t;if(o==0?(l.length=d,a=1,d--):(l.length=d+1,a=O(10,h-o),l[d]=s>0?(m/O(10,i-s)%O(10,s)|0)*a:0),u)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&&(t.e++,l[0]==ne&&(l[0]=1));break}else{if(l[d]+=a,l[d]!=ne)break;l[d--]=0,a=1}for(o=l.length;l[--o]===0;)l.pop()}return w&&(t.e>p.maxE?(t.d=null,t.e=NaN):t.e<p.minE&&(t.e=0,t.d=[0])),t}function oe(t,e,n){if(!t.isFinite())return Vt(t);var r,i=t.e,o=q(t.d),s=o.length;return e?(n&&(r=n-s)>0?o=o.charAt(0)+"."+o.slice(1)+le(r):s>1&&(o=o.charAt(0)+"."+o.slice(1)),o=o+(t.e<0?"e":"e+")+t.e):i<0?(o="0."+le(-i-1)+o,n&&(r=n-s)>0&&(o+=le(r))):i>=s?(o+=le(i+1-s),n&&(r=n-i-1)>0&&(o=o+"."+le(r))):((r=i+1)<s&&(o=o.slice(0,r)+"."+o.slice(r)),n&&(r=n-s)>0&&(i+1===s&&(o+="."),o+=le(r))),o}function We(t,e){var n=t[0];for(e*=h;n>=10;n/=10)e++;return e}function Ue(t,e,n){if(e>xn)throw w=!0,n&&(t.precision=n),Error(Ft);return g(new t(Ge),e,1,!0)}function te(t,e,n){if(e>it)throw Error(Ft);return g(new t(Ve),e,n,!0)}function Kt(t){var e=t.length-1,n=e*h+1;if(e=t[e],e){for(;e%10==0;e/=10)n--;for(e=t[0];e>=10;e/=10)n++}return n}function le(t){for(var e="";t--;)e+="0";return e}function qt(t,e,n,r){var i,o=new t(1),s=Math.ceil(r/h+4);for(w=!1;;){if(n%2&&(o=o.times(e),Rt(o.d,s)&&(i=!0)),n=U(n/2),n===0){n=o.d.length-1,i&&o.d[n]===0&&++o.d[n];break}e=e.times(e),Rt(e.d,s)}return w=!0,o}function Et(t){return t.d[t.d.length-1]&1}function Gt(t,e,n){for(var r,i=new t(e[0]),o=0;++o<e.length;)if(r=new t(e[o]),r.s)i[n](r)&&(i=r);else{i=r;break}return i}function ot(t,e){var n,r,i,o,s,a,c,u=0,m=0,l=0,d=t.constructor,p=d.rounding,y=d.precision;if(!t.d||!t.d[0]||t.e>17)return new d(t.d?t.d[0]?t.s<0?0:1/0:1:t.s?t.s<0?0:t:0/0);for(e==null?(w=!1,c=y):c=e,a=new d(.03125);t.e>-2;)t=t.times(a),l+=5;for(r=Math.log(O(2,l))/Math.LN10*2+5|0,c+=r,n=o=s=new d(1),d.precision=c;;){if(o=g(o.times(t),c,1),n=n.times(++m),a=s.plus(S(o,n,c,1)),q(a.d).slice(0,c)===q(s.d).slice(0,c)){for(i=l;i--;)s=g(s.times(s),c,1);if(e==null)if(u<3&&Ne(s.d,c-r,p,u))d.precision=c+=10,n=o=a=new d(1),m=0,u++;else return g(s,d.precision=y,p,w=!0);else return d.precision=y,s}s=a}}function de(t,e){var n,r,i,o,s,a,c,u,m,l,d,p=1,y=10,b=t,M=b.d,N=b.constructor,K=N.rounding,I=N.precision;if(b.s<0||!M||!M[0]||!b.e&&M[0]==1&&M.length==1)return new N(M&&!M[0]?-1/0:b.s!=1?NaN:M?0:b);if(e==null?(w=!1,m=I):m=e,N.precision=m+=y,n=q(M),r=n.charAt(0),Math.abs(o=b.e)<15e14){for(;r<7&&r!=1||r==1&&n.charAt(1)>3;)b=b.times(t),n=q(b.d),r=n.charAt(0),p++;o=b.e,r>1?(b=new N("0."+n),o++):b=new N(r+"."+n.slice(1))}else return u=Ue(N,m+2,I).times(o+""),b=de(new N(r+"."+n.slice(1)),m-y).plus(u),N.precision=I,e==null?g(b,I,K,w=!0):b;for(l=b,c=s=b=S(b.minus(1),b.plus(1),m,1),d=g(b.times(b),m,1),i=3;;){if(s=g(s.times(d),m,1),u=c.plus(S(s,new N(i),m,1)),q(u.d).slice(0,m)===q(c.d).slice(0,m))if(c=c.times(2),o!==0&&(c=c.plus(Ue(N,m+2,I).times(o+""))),c=S(c,new N(p),m,1),e==null)if(Ne(c.d,m-y,K,a))N.precision=m+=y,u=s=b=S(l.minus(1),l.plus(1),m,1),d=g(b.times(b),m,1),i=a=1;else return g(c,N.precision=I,K,w=!0);else return N.precision=I,c;c=u,i+=2}}function Vt(t){return String(t.s*t.s/0)}function st(t,e){var n,r,i;for((n=e.indexOf("."))>-1&&(e=e.replace(".","")),(r=e.search(/e/i))>0?(n<0&&(n=r),n+=+e.slice(r+1),e=e.substring(0,r)):n<0&&(n=e.length),r=0;e.charCodeAt(r)===48;r++);for(i=e.length;e.charCodeAt(i-1)===48;--i);if(e=e.slice(r,i),e){if(i-=r,t.e=n=n-r-1,t.d=[],r=(n+1)%h,n<0&&(r+=h),r<i){for(r&&t.d.push(+e.slice(0,r)),i-=h;r<i;)t.d.push(+e.slice(r,r+=h));e=e.slice(r),r=h-e.length}else r-=i;for(;r--;)e+="0";t.d.push(+e),w&&(t.e>t.constructor.maxE?(t.d=null,t.e=NaN):t.e<t.constructor.minE&&(t.e=0,t.d=[0]))}else t.e=0,t.d=[0];return t}function Pn(t,e){var n,r,i,o,s,a,c,u,m;if(e.indexOf("_")>-1){if(e=e.replace(/(\d)_(?=\d)/g,"$1"),vt.test(e))return st(t,e)}else if(e==="Infinity"||e==="NaN")return+e||(t.s=NaN),t.e=NaN,t.d=null,t;if(wn.test(e))n=16,e=e.toLowerCase();else if(bn.test(e))n=2;else if(yn.test(e))n=8;else throw Error(fe+e);for(o=e.search(/p/i),o>0?(c=+e.slice(o+1),e=e.substring(2,o)):e=e.slice(2),o=e.indexOf("."),s=o>=0,r=t.constructor,s&&(e=e.replace(".",""),a=e.length,o=a-o,i=qt(r,new r(n),o,o*2)),u=qe(e,n,ne),m=u.length-1,o=m;u[o]===0;--o)u.pop();return o<0?new r(t.s*0):(t.e=We(u,m),t.d=u,w=!1,s&&(t=S(t,i,a*4)),c&&(t=t.times(Math.abs(c)<54?O(2,c):Ce.pow(2,c))),w=!0,t)}function kn(t,e){var n,r=e.d.length;if(r<3)return e.isZero()?e:Ae(t,2,e,e);n=1.4*Math.sqrt(r),n=n>16?16:n|0,e=e.times(1/ze(5,n)),e=Ae(t,2,e,e);for(var i,o=new t(5),s=new t(16),a=new t(20);n--;)i=e.times(e),e=e.times(o.plus(i.times(s.times(i).minus(a))));return e}function Ae(t,e,n,r,i){var o,s,a,c,u=1,m=t.precision,l=Math.ceil(m/h);for(w=!1,c=n.times(n),a=new t(r);;){if(s=S(a.times(c),new t(e++*e++),m,1),a=i?r.plus(s):r.minus(s),r=S(s.times(c),new t(e++*e++),m,1),s=a.plus(r),s.d[l]!==void 0){for(o=l;s.d[o]===a.d[o]&&o--;);if(o==-1)break}o=a,a=r,r=s,s=o,u++}return w=!0,s.d.length=l+1,s}function ze(t,e){for(var n=t;--e;)n*=t;return n}function Ut(t,e){var n,r=e.s<0,i=te(t,t.precision,1),o=i.times(.5);if(e=e.abs(),e.lte(o))return ue=r?4:1,e;if(n=e.divToInt(i),n.isZero())ue=r?3:2;else{if(e=e.minus(n.times(i)),e.lte(o))return ue=Et(n)?r?2:3:r?4:1,e;ue=Et(n)?r?1:4:r?3:2}return e.minus(i).abs()}function at(t,e,n,r){var i,o,s,a,c,u,m,l,d,p=t.constructor,y=n!==void 0;if(y?(H(n,1,pe),r===void 0?r=p.rounding:H(r,0,8)):(n=p.precision,r=p.rounding),!t.isFinite())m=Vt(t);else{for(m=oe(t),s=m.indexOf("."),y?(i=2,e==16?n=n*4-3:e==8&&(n=n*3-2)):i=e,s>=0&&(m=m.replace(".",""),d=new p(1),d.e=m.length-s,d.d=qe(oe(d),10,i),d.e=d.d.length),l=qe(m,10,i),o=c=l.length;l[--c]==0;)l.pop();if(!l[0])m=y?"0p+0":"0";else{if(s<0?o--:(t=new p(t),t.d=l,t.e=o,t=S(t,d,n,r,0,i),l=t.d,o=t.e,u=Mt),s=l[n],a=i/2,u=u||l[n+1]!==void 0,u=r<4?(s!==void 0||u)&&(r===0||r===(t.s<0?3:2)):s>a||s===a&&(r===4||u||r===6&&l[n-1]&1||r===(t.s<0?8:7)),l.length=n,u)for(;++l[--n]>i-1;)l[n]=0,n||(++o,l.unshift(1));for(c=l.length;!l[c-1];--c);for(s=0,m="";s<c;s++)m+=nt.charAt(l[s]);if(y){if(c>1)if(e==16||e==8){for(s=e==16?4:3,--c;c%s;c++)m+="0";for(l=qe(m,i,e),c=l.length;!l[c-1];--c);for(s=1,m="1.";s<c;s++)m+=nt.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>c)for(o-=c;o--;)m+="0";else o<c&&(m=m.slice(0,o)+"."+m.slice(o))}m=(e==16?"0x":e==2?"0b":e==8?"0o":"")+m}return t.s<0?"-"+m:m}function Rt(t,e){if(t.length>e)return t.length=e,!0}function Bn(t){return new this(t).abs()}function In(t){return new this(t).acos()}function Nn(t){return new this(t).acosh()}function Cn(t,e){return new this(t).plus(e)}function Sn(t){return new this(t).asin()}function Ln(t){return new this(t).asinh()}function En(t){return new this(t).atan()}function Rn(t){return new this(t).atanh()}function _n(t,e){t=new this(t),e=new this(e);var n,r=this.precision,i=this.rounding,o=r+4;return!t.s||!e.s?n=new this(NaN):!t.d&&!e.d?(n=te(this,o,1).times(e.s>0?.25:.75),n.s=t.s):!e.d||t.isZero()?(n=e.s<0?te(this,r,i):new this(0),n.s=t.s):!t.d||e.isZero()?(n=te(this,o,1).times(.5),n.s=t.s):e.s<0?(this.precision=o,this.rounding=1,n=this.atan(S(t,e,o,1)),e=te(this,o,1),this.precision=r,this.rounding=i,n=t.s<0?n.minus(e):n.plus(e)):n=this.atan(S(t,e,o,1)),n}function Mn(t){return new this(t).cbrt()}function Fn(t){return g(t=new this(t),t.e+1,2)}function On(t,e,n){return new this(t).clamp(e,n)}function Dn(t){if(!t||typeof t!="object")throw Error(Xe+"Object expected");var e,n,r,i=t.defaults===!0,o=["precision",1,pe,"rounding",0,8,"toExpNeg",-xe,0,"toExpPos",0,xe,"maxE",0,xe,"minE",-xe,0,"modulo",0,9];for(e=0;e<o.length;e+=3)if(n=o[e],i&&(this[n]=rt[n]),(r=t[n])!==void 0)if(U(r)===r&&r>=o[e+1]&&r<=o[e+2])this[n]=r;else throw Error(fe+n+": "+r);if(n="crypto",i&&(this[n]=rt[n]),(r=t[n])!==void 0)if(r===!0||r===!1||r===0||r===1)if(r)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[n]=!0;else throw Error(Ot);else this[n]=!1;else throw Error(fe+n+": "+r);return this}function vn(t){return new this(t).cos()}function Kn(t){return new this(t).cosh()}function Xt(t){var e,n,r;function i(o){var s,a,c,u=this;if(!(u instanceof i))return new i(o);if(u.constructor=i,_t(o)){u.s=o.s,w?!o.d||o.e>i.maxE?(u.e=NaN,u.d=null):o.e<i.minE?(u.e=0,u.d=[0]):(u.e=o.e,u.d=o.d.slice()):(u.e=o.e,u.d=o.d?o.d.slice():o.d);return}if(c=typeof o,c==="number"){if(o===0){u.s=1/o<0?-1:1,u.e=0,u.d=[0];return}if(o<0?(o=-o,u.s=-1):u.s=1,o===~~o&&o<1e7){for(s=0,a=o;a>=10;a/=10)s++;w?s>i.maxE?(u.e=NaN,u.d=null):s<i.minE?(u.e=0,u.d=[0]):(u.e=s,u.d=[o]):(u.e=s,u.d=[o]);return}else if(o*0!==0){o||(u.s=NaN),u.e=NaN,u.d=null;return}return st(u,o.toString())}else if(c!=="string")throw Error(fe+o);return(a=o.charCodeAt(0))===45?(o=o.slice(1),u.s=-1):(a===43&&(o=o.slice(1)),u.s=1),vt.test(o)?st(u,o):Pn(u,o)}if(i.prototype=f,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=Dn,i.clone=Xt,i.isDecimal=_t,i.abs=Bn,i.acos=In,i.acosh=Nn,i.add=Cn,i.asin=Sn,i.asinh=Ln,i.atan=En,i.atanh=Rn,i.atan2=_n,i.cbrt=Mn,i.ceil=Fn,i.clamp=On,i.cos=vn,i.cosh=Kn,i.div=qn,i.exp=Gn,i.floor=Vn,i.hypot=Un,i.ln=Xn,i.log=Wn,i.log10=Hn,i.log2=zn,i.max=Zn,i.min=jn,i.mod=Qn,i.mul=Yn,i.pow=Jn,i.random=$n,i.round=er,i.sign=tr,i.sin=nr,i.sinh=rr,i.sqrt=ir,i.sub=or,i.sum=sr,i.tan=ar,i.tanh=ur,i.trunc=cr,t===void 0&&(t={}),t&&t.defaults!==!0)for(r=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],e=0;e<r.length;)t.hasOwnProperty(n=r[e++])||(t[n]=this[n]);return i.config(t),i}function qn(t,e){return new this(t).div(e)}function Gn(t){return new this(t).exp()}function Vn(t){return g(t=new this(t),t.e+1,3)}function Un(){var t,e,n=new this(0);for(w=!1,t=0;t<arguments.length;)if(e=new this(arguments[t++]),e.d)n.d&&(n=n.plus(e.times(e)));else{if(e.s)return w=!0,new this(1/0);n=e}return w=!0,n.sqrt()}function _t(t){return t instanceof Ce||t&&t.toStringTag===Dt||!1}function Xn(t){return new this(t).ln()}function Wn(t,e){return new this(t).log(e)}function zn(t){return new this(t).log(2)}function Hn(t){return new this(t).log(10)}function Zn(){return Gt(this,arguments,"lt")}function jn(){return Gt(this,arguments,"gt")}function Qn(t,e){return new this(t).mod(e)}function Yn(t,e){return new this(t).mul(e)}function Jn(t,e){return new this(t).pow(e)}function $n(t){var e,n,r,i,o=0,s=new this(1),a=[];if(t===void 0?t=this.precision:H(t,1,pe),r=Math.ceil(t/h),this.crypto)if(crypto.getRandomValues)for(e=crypto.getRandomValues(new Uint32Array(r));o<r;)i=e[o],i>=429e7?e[o]=crypto.getRandomValues(new Uint32Array(1))[0]:a[o++]=i%1e7;else if(crypto.randomBytes){for(e=crypto.randomBytes(r*=4);o<r;)i=e[o]+(e[o+1]<<8)+(e[o+2]<<16)+((e[o+3]&127)<<24),i>=214e7?crypto.randomBytes(4).copy(e,o):(a.push(i%1e7),o+=4);o=r/4}else throw Error(Ot);else for(;o<r;)a[o++]=Math.random()*1e7|0;for(r=a[--o],t%=h,r&&t&&(i=O(10,h-t),a[o]=(r/i|0)*i);a[o]===0;o--)a.pop();if(o<0)n=0,a=[0];else{for(n=-1;a[0]===0;n-=h)a.shift();for(r=1,i=a[0];i>=10;i/=10)r++;r<h&&(n-=h-r)}return s.e=n,s.d=a,s}function er(t){return g(t=new this(t),t.e+1,this.rounding)}function tr(t){return t=new this(t),t.d?t.d[0]?t.s:0*t.s:t.s||NaN}function nr(t){return new this(t).sin()}function rr(t){return new this(t).sinh()}function ir(t){return new this(t).sqrt()}function or(t,e){return new this(t).sub(e)}function sr(){var t=0,e=arguments,n=new this(e[t]);for(w=!1;n.s&&++t<e.length;)n=n.plus(e[t]);return w=!0,g(n,this.precision,this.rounding)}function ar(t){return new this(t).tan()}function ur(t){return new this(t).tanh()}function cr(t){return g(t=new this(t),t.e+1,1)}f[Symbol.for("nodejs.util.inspect.custom")]=f.toString;f[Symbol.toStringTag]="Decimal";var Ce=f.constructor=Xt(rt);Ge=new Ce(Ge);Ve=new Ce(Ve);var D=Ce;import{MINT_SIZE as ai,TOKEN_PROGRAM_ID as ui,getTransferFeeConfig as ci,unpackMint as mi}from"@solana/spl-token";import{PublicKey as gi}from"@solana/web3.js";import{get as Wt,set as mr}from"lodash";var ut=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 n=e.map(r=>typeof r=="object"?JSON.stringify(r):r).join(", ");throw new Error(n)}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}},zt={},lr={};function Q(t){let e=Wt(zt,t);if(!e){let n=Wt(lr,t);e=new ut({name:t,logLevel:n}),mr(zt,t,e)}return e}var wi=Q("CobaltX_accountInfo_util");import me from"bn.js";import Tr from"big.js";import Oi from"bn.js";import fr from"toformat";var pr=fr,Se=pr;import Ze from"big.js";import hr from"bn.js";import br from"decimal.js-light";import Le from"bn.js";var Ht=9007199254740991;function ce(t){let e=Q("CobaltX_parseBigNumberish");if(t instanceof Le)return t;if(typeof t=="string"){if(t.match(/^-?[0-9]+$/))return new Le(t);e.logWithError(`invalid BigNumberish string: ${t}`)}return typeof t=="number"?(t%1&&e.logWithError(`BigNumberish number underflow: ${t}`),(t>=Ht||t<=-Ht)&&e.logWithError(`BigNumberish number overflow: ${t}`),new Le(String(t))):typeof t=="bigint"?new Le(t.toString()):(e.error(`invalid BigNumberish value: ${t}`),new Le(0))}var He=Q("module/fraction"),mt=Se(Ze),Ee=Se(br),wr={[0]:Ee.ROUND_DOWN,[1]:Ee.ROUND_HALF_UP,[2]:Ee.ROUND_UP},yr={[0]:Ze.roundDown,[1]:Ze.roundHalfUp,[2]:Ze.roundUp},E=class{constructor(e,n=new hr(1)){this.numerator=ce(e),this.denominator=ce(n)}get quotient(){return this.numerator.div(this.denominator)}invert(){return new E(this.denominator,this.numerator)}add(e){let n=e instanceof E?e:new E(ce(e));return this.denominator.eq(n.denominator)?new E(this.numerator.add(n.numerator),this.denominator):new E(this.numerator.mul(n.denominator).add(n.numerator.mul(this.denominator)),this.denominator.mul(n.denominator))}sub(e){let n=e instanceof E?e:new E(ce(e));return this.denominator.eq(n.denominator)?new E(this.numerator.sub(n.numerator),this.denominator):new E(this.numerator.mul(n.denominator).sub(n.numerator.mul(this.denominator)),this.denominator.mul(n.denominator))}mul(e){let n=e instanceof E?e:new E(ce(e));return new E(this.numerator.mul(n.numerator),this.denominator.mul(n.denominator))}div(e){let n=e instanceof E?e:new E(ce(e));return new E(this.numerator.mul(n.denominator),this.denominator.mul(n.numerator))}toSignificant(e,n={groupSeparator:""},r=1){Number.isInteger(e)||He.logWithError(`${e} is not an integer.`),e<=0&&He.logWithError(`${e} is not positive.`),Ee.set({precision:e+1,rounding:wr[r]});let i=new Ee(this.numerator.toString()).div(this.denominator.toString()).toSignificantDigits(e);return i.toFormat(i.decimalPlaces(),n)}toFixed(e,n={groupSeparator:""},r=1){return Number.isInteger(e)||He.logWithError(`${e} is not an integer.`),e<0&&He.logWithError(`${e} is negative.`),mt.DP=e,mt.RM=yr[r]||1,new mt(this.numerator.toString()).div(this.denominator.toString()).toFormat(e,n)}isZero(){return this.numerator.isZero()}};var Wi=Q("CobaltX_amount"),zi=Se(Tr);import{TOKEN_PROGRAM_ID as Zt}from"@solana/spl-token";import{PublicKey as Ar}from"@solana/web3.js";var jt={chainId:101,address:Ar.default.toBase58(),programId:Zt.toBase58(),decimals:9,symbol:"ETH",name:"Ethereum",logoURI:"https://raw.githubusercontent.com/cobaltx-io/tokens/main/logo/So11111111111111111111111111111111111111112.png",tags:[],priority:2,type:"cobaltx",extensions:{coingeckoId:"solana"}},we={chainId:101,address:"So11111111111111111111111111111111111111112",programId:Zt.toBase58(),decimals:9,symbol:"WETH",name:"Wrapped ETH",logoURI:"https://raw.githubusercontent.com/cobaltx-io/tokens/main/logo/So11111111111111111111111111111111111111112.png",tags:[],priority:2,type:"cobaltx",extensions:{coingeckoId:"solana"}};import{PublicKey as dt}from"@solana/web3.js";import{PublicKey as G,SystemProgram as Qt,SYSVAR_RENT_PUBKEY as Pr}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as kr}from"@solana/spl-token";function lt({pubkey:t,isSigner:e=!1,isWritable:n=!0}){return{pubkey:t,isWritable:n,isSigner:e}}var eo=[lt({pubkey:kr,isWritable:!1}),lt({pubkey:Qt.programId,isWritable:!1}),lt({pubkey:Pr,isWritable:!1})];function Yt({publicKey:t,transformSol:e}){let n=Jt(t.toString());if(n instanceof G)return e&&n.equals(Re)?ct:n;if(e&&n.toString()===Re.toBase58())return ct;if(typeof n=="string"){if(n===G.default.toBase58())return G.default;try{return new G(n)}catch{throw new Error("invalid public key")}}throw new Error("invalid public key")}function Jt(t){try{return new G(t)}catch{return t}}var to=new G("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),no=new G("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),ro=new G("SysvarRent111111111111111111111111111111111"),io=new G("SysvarC1ock11111111111111111111111111111111"),Br=new G("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"),oo=new G("Sysvar1nstructions1111111111111111111111111"),so=Qt.programId,ao=new G("a2Gt18uJC8puJT9JRYQLU6rPi6okxQb4WqCjwtYshZB"),uo=new G("bXSKiFqYrALF9gJy1KqHm8tv4QXk8nCgbLN8WRsGEbh"),ct=new G("So11111111111111111111111111111111111111112"),Re=G.default,co=new G("71kRXzJMvSeArtXYNEWa8KAjpRJosdMQ7Dpgy5Jt5zfd"),mo=new G("ERFzpDteGNo8LTDKW1WwVGrkRMmA2y9WZHXNHxMA6BSV");var ft=class{constructor({mint:e,decimals:n,symbol:r,name:i,skipMint:o=!1,isToken2022:s=!1}){if(e===Re.toBase58()||e instanceof dt&&Re.equals(e)){this.decimals=we.decimals,this.symbol=we.symbol,this.name=we.name,this.mint=new dt(we.address),this.isToken2022=!1;return}this.decimals=n,this.symbol=r||e.toString().substring(0,6),this.name=i||e.toString().substring(0,6),this.mint=o?dt.default:Yt({publicKey:e}),this.isToken2022=s}equals(e){return this===e?!0:this.mint.equals(e.mint)}},ye=ft;ye.WSOL=new ft({...we,mint:we.address});var pt=class{constructor({decimals:e,symbol:n="UNKNOWN",name:r="UNKNOWN"}){this.decimals=e,this.symbol=n,this.name=r}equals(e){return this===e}},je=pt;je.SOL=new pt(jt);import Ir from"bn.js";var Po=new E(new Ir(100));var So=Q("CobaltX_price");import{PublicKey as zo}from"@solana/web3.js";import Zo from"bn.js";var Nr=new me(0),ds=new me(1),fs=new me(2),ps=new me(3),gs=new me(5),xr=new me(10),hs=new me(100),bs=new me(1e3),ws=new me(1e4);import{PublicKey as Xs}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as zs}from"@solana/spl-token";import{ComputeBudgetProgram as Ns,Keypair as Ls,PublicKey as Es,Transaction as _s,TransactionMessage as Fs,VersionedTransaction as Os}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as qs}from"@solana/spl-token";var Gs=Q("CobaltX_txUtil");import{PublicKey as T}from"@solana/web3.js";var Qs=new T("EhhTKczWMGQt46ynNeRX1WfeagwwJd7ufHvCDjRxjo5Q"),Ys=new T("CBuCnLe26faBpcBP2fktp4rp8abpcAnTWft6ZrP5Q4T"),Js=new T("9KEPoZmtHUrBbhWN1v1KWLMkkvwY6WLtAVUCPRtRjP4z"),$s=new T("FarmqiPv5eAj3j1GMdMCMUGXqPUvmquZtMy86QH6rzhG"),ea=new T("CLaimxFqjHzgTJtAGHU47NPhg6qrc5sCnpC4tBLyABQS"),ta=new T("srmqPvymJeFKQ4zGQed1GFppgkRHL9kaELCbyksJtPX"),na=new T("9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin"),ra=new T("675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8"),ia=new T("5quBtoiQqxF9Jv6KYKctB59NT3gtJD2Y65kdnB1Uev3h"),oa=new T("CDSr3ssLcRB6XYPJwAfFt18MZvEZp4LjHcvzBVZ45duo"),sa=new T("2TnjBuwqyBB9to5jURagDT7jLmBPefGRiKL2yh1zPZ4V"),aa=new T("LockrWmn6K5twhz3y9w1dQERbmgSaRkfnTeTKbpofwE"),ua=new T("kN1kEznaF5Xbd8LYuqtEFcxzWSBk5Fv6ygX6SqEGJVy"),ca=new T("routeUGWgWzqBWFcrCfv8tritsqukccJPu3q5GPP3xS"),ma=new T("7YttLkHDoNj9wyDur5pM1ejNaAvT9X4eqaYcHQqtj2G5"),la=new T("6FJon3QE27qgPVggARueB22hLvoh22VzJpXv4rBEoSLF"),da=new T("CC12se5To1CdEuw7fDS27B7Geo5jJyL7t5UK2B44NgiH"),fa=new T("9HzJyW1qZsEiSfMUf6L2jo3CcTKAyBmSyKdwQeYisHrC"),pa=new T("DropEU8AvevN3UrXWXTMuz3rqnMczQVNjq3kcSdW2SQi"),ga=new T("CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C"),ha=new T("GpMZbSM2GgvTKHJirzeGfMFoaZ8UR2X7F4v8vHTvxFbL"),ba=new T("DNXgeM9EiiaAbaWvwjHj9fQQLAX5ZsfHyvmYUNRAdNC8"),Sr=new T("CPMDWBwJDtYax9qW7AyRuVC19Cc4L4Vcy4n2BHAbHkCW"),Lr=new T("7rQ1QFNosMkUCuh7Z7fPbTHvh73b68sQYdirycEzJVuw"),Er=new T("G11FKBRaAkHAKuLCgLM6K6NUc9rTjPAznRCjZifrTQe2"),wa=new T("LockrWmn6K5twhz3y9w1dQERbmgSaRkfnTeTKbpofwE"),Rr=new T("DLockwT7X7sxtLmGH9g5kmfcjaBtncdbUmi738m5bvQC"),ya=new T("3f7GcQFG397GAaEnv51zR6tsTVihYRydnydDD1cXekxH"),_r=new T("7AFUeLVRjBfzqK3tTGw8hN48KLQWSk6DTE8xprWdPqix");var Ta={SERUM_MARKET:T.default,OPENBOOK_MARKET:new T("EoTcMgcDRTJVZDMZWBoU6rhYHZfkNTVEAfz3uUJRcYGj"),UTIL1216:T.default,FarmV3:new T("85BFyr98MbCUU9MVTEgzx1nbhWACbJqLzho6zd6DZcWL"),FarmV5:new T("EcLzTrNg9V7qhcdyXDe2qjtPkiGzDM2UbdRaeaadU5r2"),FarmV6:new T("Farm2hJLcqPtPg8M4rR6DMrsRNc5TPm5Cs4bVQrMe2T7"),AmmV4:new T("HWy1jotHpo6UqeQxx49dpYYdQB8wj9Qk9MdxwjLvDHB8"),AmmStable:new T("DDg4VmQaJV9ogWce7LpcjBA9bv22wRp5uaTPa5pGjijF"),CLMM:new T("devi51mZmdwUJGU9hjN27vEz64Gps7uUefqxg27EAtH"),CLMM_LOCK_PROGRAM_ID:new T("DLockwT7X7sxtLmGH9g5kmfcjaBtncdbUmi738m5bvQC"),CLMM_LOCK_AUTH_ID:new T("8qmHNvu2Kr2C7U8mJL4Vz1vTDxMhVuXKREwU7TNoaVEo"),Router:new T("BVChZ3XFEwTMUk1o9i3HAf91H6mFxSwa5X2wFAWhYPhU"),CREATE_CPMM_POOL_PROGRAM:Sr,CREATE_CPMM_POOL_AUTH:Lr,CREATE_CPMM_POOL_FEE_ACC:Er,FEE_DESTINATION_ID:new T("3XMrhbv989VxAMi3DErLV9eJht1pHppW5LbKxe9fkEFR"),LOCK_CPMM_PROGRAM:Rr,LCOK_CPMM_AUTH:_r};import re from"bn.js";var _e=1e4;function ie(t,e,n,r){if(e===void 0)return{amount:t,fee:void 0,expirationTime:void 0};let i={...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=n.epoch<i.newerTransferFee.epoch?i.olderTransferFee:i.newerTransferFee,s=new re(o.maximumFee.toString()),a=n.epoch<i.newerTransferFee.epoch?(Number(i.newerTransferFee.epoch)*n.slotsInEpoch-n.absoluteSlot)*400/1e3:void 0;if(r)if(o.transferFeeBasisPoints===_e){let c=new re(o.maximumFee.toString());return{amount:t.add(c),fee:c,expirationTime:a}}else{let c=wt(t.mul(new re(_e)),new re(_e-o.transferFeeBasisPoints)),u=new re(o.maximumFee.toString()),m=c.sub(t).gt(u)?t.add(u):c,l=wt(m.mul(new re(o.transferFeeBasisPoints)),new re(_e)),d=l.gt(s)?s:l;return{amount:m,fee:d,expirationTime:a}}else{let c=wt(t.mul(new re(o.transferFeeBasisPoints)),new re(_e)),u=c.gt(s)?s:c;return{amount:t,fee:u,expirationTime:a}}}function Me(t,e){return t===void 0?e:e===void 0?t:Math.min(t,e)}function wt(t,e){let{div:n,mod:r}=t.divmod(e);return r.gt(new re(0))?n.add(new re(1)):n}import{PublicKey as Mr,AddressLookupTableAccount as $t}from"@solana/web3.js";var Fr={AiAibtFJts8e4W1FjWYRH34aBJkJqghdmXiJozK7MvTM:new $t({key:new Mr("AiAibtFJts8e4W1FjWYRH34aBJkJqghdmXiJozK7MvTM"),state:$t.deserialize(Buffer.from("AQAAAP//////////d49+DAAAAAAAAQZMWvw7GUNJdaccNBVnb57OKakxL2BHLYvhRwVILRsgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMGRm/lIRcy/+ytunLDm+e8jOW7xfcSayxDmzpAAAAABt324ddloZPZy+FGzut5rBy0he1fWzeROoz1hX7/AKkG3fbh7nWP3hhCXbzkbM3athr8TYO5DSf+vfko2KGL/AVKU1D4XciC1hSlVnJ4iilt3x6rq9CmBniISTL07vagBqfVFxksXFEhjMlMPUrxf1ja7gibof1E49vZigAAAAAGp9UXGMd0yShWY5hpHV62i164o5tLbVxzVVshAAAAAIyXJY9OJInxuz0QKRSODYMLWhOZ2v8QhASOe9jb6fhZC3BlsePRfEU4nVJ/awTDzVi4bHMaoP21SbbRvAP4KUbIScv+6Yw2LHF/6K0ZjUPibbSWXCirYPGuuVl7zT789IUPLW4CpHr4JNCatp3ELXDLKMv6JJ+37le50lbBJ2LvDQdRqCgtphMF/imcN7mY5YRx2xE1A3MQ+L4QRaYK9u4GRfZP3LsAd00a+IkCpA22UNQMKdq5BFbJuwuOLqc8zxCTDlqxBG8J0HcxtfogQHDK06ukzfaXiNDKAob1MqBHS9lJxDYCwz8gd5DtFqNSTKG5l1zxIaKpDP/sffi2is1H9aKveyXSu5StXElYRl9SD5As0DHE4N0GLnf84/siiKXVyp4Ez121kLcUui/jLLFZEz/BwZK3Ilf9B9OcsEAeDMKAy2vjGSxQODgBz0QwGA+eP4ZjIjrIAQaXENv31QfLlOdXSRCkaybRniDHF4C8YcwhcvsqrOVuTP4B2Na+9wLdtrB31uz2rtlFI5kahdsnp/d1SrASDInYCtTYtdoke4kX+hoKWcEWM4Tle8pTUkUVv4BxS6fje/EzKBE4Qu9N9LMnrw/JNO0hqMVB4rk/2ou4AB1loQ7FZoPwut2o4KZB+0p9xnbrQKw038qjpHar+PyDwvxBRcu5hpHw3dguezeWv+IwvgW5icu8EGkhGa9AkFPPJT7VMSFb8xowveU=","base64"))})};import{PublicKey as Ka,sendAndConfirmTransaction as qa,Transaction as Va,TransactionMessage as Xa,VersionedTransaction as Wa}from"@solana/web3.js";import Ha from"axios";import Y from"bn.js";var J=new Y(0),ge=new Y(1),tn=new Y(-1),$=new Y(1).shln(64),Qe=new Y(1).shln(128),yt=$.sub(ge),Fe=64,nn=Qe.subn(1),Te=-443636,Pe=-Te,Tt=new Y("4295048016"),xt=new Y("79226673521066979257578248091"),wu=new Y("4295048017"),yu=new Y("79226673521066979257578248090"),rn=16,on="59543866431248",sn="184467440737095516",an="15793534762490258745",Or=new Y(10).pow(new Y(6));var Tu=new Y("18446744073700000000");import B from"bn.js";var Nu=Buffer.from("amm_config","utf8"),Cu=Buffer.from("pool","utf8"),Su=Buffer.from("pool_vault","utf8"),Lu=Buffer.from("pool_reward_vault","utf8"),Eu=Buffer.from("position","utf8"),Ru=Buffer.from("tick_array","utf8"),_u=Buffer.from("operation","utf8"),Mu=Buffer.from("pool_tick_array_bitmap_extension","utf8"),Fu=Buffer.from("observation","utf8");var Ou=Buffer.from("locked_position","utf8");import{TOKEN_2022_PROGRAM_ID as km}from"@solana/spl-token";import{PublicKey as Cm}from"@solana/web3.js";import Lm from"bn.js";import{PublicKey as Wr}from"@solana/web3.js";import ln,{isBN as dn}from"bn.js";import{bits as Ku,BitStructure as qu,blob as Dr,Blob as Gu,cstr as Vu,f32 as Uu,f32be as Xu,f64 as Wu,f64be as zu,greedy as Hu,Layout as vr,ns64 as Zu,ns64be as ju,nu64 as Qu,nu64be as Yu,offset as Ju,s16 as $u,s16be as ec,s24 as tc,s24be as nc,s32 as Kr,s32be as rc,s40 as ic,s40be as oc,s48 as sc,s48be as ac,s8 as uc,seq as qr,struct as cc,Structure as Gr,u16 as Vr,u16be as mc,u24 as lc,u24be as dc,u32 as fc,u32be as pc,u40 as gc,u40be as hc,u48 as bc,u48be as wc,u8 as Ur,UInt as Xr,union as yc,Union as Tc,unionLayoutDiscriminator as xc,utf8 as Ac}from"@solana/buffer-layout";var At=vr,un=Gr;var Pt=Xr;var cn=Ur,Oe=Vr;var he=Kr;var mn=qr;var j=Dr;var ke=class extends At{constructor(n,r,i){super(n,i);this.blob=j(n),this.signed=r}decode(n,r=0){let i=new ln(this.blob.decode(n,r),10,"le");return this.signed?i.fromTwos(this.span*8).clone():i}encode(n,r,i=0){return typeof n=="number"&&(n=new ln(n)),this.signed&&(n=n.toTwos(this.span*8)),this.blob.encode(n.toArrayLike(Buffer,"le",this.span),r,i)}};function Z(t){return new Pt(1,t)}function Be(t){return new Pt(4,t)}function k(t){return new ke(8,!1,t)}function _(t){return new ke(16,!1,t)}function fn(t){return new ke(8,!0,t)}function pn(t){return new ke(16,!0,t)}var Ye=class extends At{constructor(n,r,i,o){super(n.span,o);this.layout=n,this.decoder=r,this.encoder=i}decode(n,r){return this.decoder(this.layout.decode(n,r))}encode(n,r,i){return this.layout.encode(this.encoder(n),r,i)}getSpan(n,r){return this.layout.getSpan(n,r)}};function C(t){return new Ye(j(32),e=>new Wr(e),e=>e.toBuffer(),t)}function gn(t){return new Ye(cn(),zr,Hr,t)}function zr(t){if(t===0)return!1;if(t===1)return!0;throw new Error("Invalid bool: "+t)}function Hr(t){return t?1:0}var kt=class extends un{decode(e,n){return super.decode(e,n)}};function W(t,e,n){return new kt(t,e,n)}function R(t,e,n){let r,i=typeof e=="number"?e:dn(e)?e.toNumber():new Proxy(e,{get(o,s){if(!r){let a=Reflect.get(o,"count");r=dn(a)?a.toNumber():a,Reflect.set(o,"count",r)}return Reflect.get(o,s)},set(o,s,a){return s==="count"&&(r=a),Reflect.set(o,s,a)}});return mn(t,i,n)}import Xc from"bn.js";var Je=60;var Ct=14;var lm=W([j(8),Z("bump"),Oe("index"),C(""),Be("protocolFeeRate"),Be("tradeFeeRate"),Oe("tickSpacing"),R(k(),8,"")]),jr=W([Be("blockTimestamp"),fn("tickCumulative"),R(k(),4)]),dm=W([j(8),gn("initialized"),k("recentEpoch"),Oe("observationIndex"),C("poolId"),R(jr,100,"observations"),R(k(),4)]),Qr=W([Z("rewardState"),k("openTime"),k("endTime"),k("lastUpdateTime"),_("emissionsPerSecondX64"),k("rewardTotalEmissioned"),k("rewardClaimed"),C("tokenMint"),C("tokenVault"),C("creator"),_("rewardGrowthGlobalX64")]),Yr=W([j(8),Z("bump"),C("ammConfig"),C("creator"),C("mintA"),C("mintB"),C("vaultA"),C("vaultB"),C("observationId"),Z("mintDecimalsA"),Z("mintDecimalsB"),Oe("tickSpacing"),_("liquidity"),_("sqrtPriceX64"),he("tickCurrent"),Be(),_("feeGrowthGlobalX64A"),_("feeGrowthGlobalX64B"),k("protocolFeesTokenA"),k("protocolFeesTokenB"),_("swapInAmountTokenA"),_("swapOutAmountTokenB"),_("swapInAmountTokenB"),_("swapOutAmountTokenA"),Z("status"),R(Z(),7,""),R(Qr,3,"rewardInfos"),R(k(),16,"tickArrayBitmap"),k("totalFeesTokenA"),k("totalFeesClaimedTokenA"),k("totalFeesTokenB"),k("totalFeesClaimedTokenB"),k("fundFeesTokenA"),k("fundFeesTokenB"),k("startTime"),R(k(),15*4-3,"padding")]),Jr=W([_("growthInsideLastX64"),k("rewardAmountOwed")]),$r=W([j(8),Z("bump"),C("nftMint"),C("poolId"),he("tickLower"),he("tickUpper"),_("liquidity"),_("feeGrowthInsideLastX64A"),_("feeGrowthInsideLastX64B"),k("tokenFeesOwedA"),k("tokenFeesOwedB"),R(Jr,3,"rewardInfos"),R(k(),8,"")]),fm=W([j(8),Z("bump"),C("poolId"),he("tickLowerIndex"),he("tickUpperIndex"),_("liquidity"),_("feeGrowthInsideLastX64A"),_("feeGrowthInsideLastX64B"),k("tokenFeesOwedA"),k("tokenFeesOwedB"),R(_(),3,"rewardGrowthInside"),R(k(),8,"")]),ei=W([he("tick"),pn("liquidityNet"),_("liquidityGross"),_("feeGrowthOutsideX64A"),_("feeGrowthOutsideX64B"),R(_(),3,"rewardGrowthsOutsideX64"),R(Be(),13,"")]),hn=W([j(8),C("poolId"),he("startTickIndex"),R(ei,Je,"ticks"),Z("initializedTickCount"),R(Z(),115,"")]),pm=W([j(329),R(C(),100,"whitelistMints")]),ti=W([j(8),C("poolId"),R(R(k(),8),Ct,"positiveTickArrayBitmap"),R(R(k(),8),Ct,"negativeTickArrayBitmap")]),gm=W([k(),Z("bump"),C("owner"),C("poolId"),C("positionId"),C("nftAccount"),R(k(),8)]),hm=W([j(8),Z("bump"),C("lock