@waves/bignumber
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -6,4 +6,5 @@ import { default as BigNum } from 'bignumber.js'; | ||
readonly bn: BigNum; | ||
static MIN_VALUE: BigNumber; | ||
static MAX_VALUE: BigNumber; | ||
static MIN_VALUE: BigNumber; | ||
static MIN_UNSIGNED_VALUE: BigNumber; | ||
static MAX_UNSIGNED_VALUE: BigNumber; | ||
@@ -35,3 +36,4 @@ static config: Config; | ||
isOdd(): boolean; | ||
toBytes(): Uint8Array; | ||
isInSignedRange(): boolean; | ||
isInUnsignedRange(): boolean; | ||
toFormat(decimals?: number, roundMode?: BigNumber.ROUND_MODE, format?: IFormat): string; | ||
@@ -43,3 +45,10 @@ toFixed(decimals?: number, roundMode?: BigNumber.ROUND_MODE): string; | ||
valueOf(): string; | ||
static fromBytes(bytes: Uint8Array | Array<number>): BigNumber; | ||
toBytes({ isSigned, isLong }?: { | ||
isSigned?: boolean | undefined; | ||
isLong?: boolean | undefined; | ||
}): Uint8Array; | ||
static fromBytes(bytes: Uint8Array | Array<number>, { isSigned, isLong }?: { | ||
isSigned?: boolean | undefined; | ||
isLong?: boolean | undefined; | ||
}): BigNumber; | ||
static max(...items: Array<TLong>): BigNumber; | ||
@@ -46,0 +55,0 @@ static min(...items: Array<TLong>): BigNumber; |
@@ -88,16 +88,8 @@ "use strict"; | ||
}; | ||
BigNumber.prototype.toBytes = function () { | ||
if (!this.isInt()) { | ||
throw new Error('Cant create bytes from number with decimals!'); | ||
} | ||
var isNegative = this.isNegative(); | ||
var toAdd = isNegative ? '1' : '0'; | ||
var baseStr = BigNumber._toLength(64, this.bn.plus(toAdd).abs().toString(2).replace('-', '')); | ||
var baseStrArr = baseStr.split(''); | ||
var bytes = []; | ||
do { | ||
bytes.push(parseInt(baseStrArr.splice(0, 8).join(''), 2)); | ||
} while (baseStrArr.length); | ||
return isNegative ? Uint8Array.from(bytes.map(function (byte) { return 255 - byte; })) : Uint8Array.from(bytes); | ||
BigNumber.prototype.isInSignedRange = function () { | ||
return (this.gte(BigNumber.MIN_VALUE) && this.lte(BigNumber.MAX_VALUE)); | ||
}; | ||
BigNumber.prototype.isInUnsignedRange = function () { | ||
return (this.gte(BigNumber.MIN_UNSIGNED_VALUE) && this.lte(BigNumber.MAX_UNSIGNED_VALUE)); | ||
}; | ||
BigNumber.prototype.toFormat = function (decimals, roundMode, format) { | ||
@@ -126,7 +118,41 @@ return this.bn.toFormat(decimals, roundMode, format); | ||
}; | ||
BigNumber.fromBytes = function (bytes) { | ||
if (bytes.length !== 8) { | ||
throw new Error('Wrong bytes length! Need 8 bytes!'); | ||
BigNumber.prototype.toBytes = function (_a) { | ||
var _b = _a === void 0 ? {} : _a, _c = _b.isSigned, isSigned = _c === void 0 ? true : _c, _d = _b.isLong, isLong = _d === void 0 ? true : _d; | ||
if (!this.isInt()) { | ||
throw new Error('Cant create bytes from number with decimals!'); | ||
} | ||
var isNegative = bytes[0] > 127; | ||
if (!isSigned && this.isNegative()) { | ||
throw new Error('Cant create bytes from negative number in signed mode!'); | ||
} | ||
if (isLong && isSigned && !this.isInSignedRange()) { | ||
throw new Error('Number is not from signed numbers range'); | ||
} | ||
if (isLong && !isSigned && !this.isInUnsignedRange()) { | ||
throw new Error('Number is not from unsigned numbers range'); | ||
} | ||
var isNegative = isSigned && this.isNegative(); | ||
var toAdd = isNegative ? '1' : '0'; | ||
var byteString = this.bn.plus(toAdd).toString(2).replace('-', ''); | ||
var stringLength = isLong | ||
? 64 | ||
: Math.ceil(byteString.length / 8) * 8; | ||
var baseStr = BigNumber._toLength(stringLength, byteString); | ||
var baseStrArr = baseStr.split(''); | ||
var bytes = []; | ||
do { | ||
bytes.push(parseInt(baseStrArr.splice(0, 8).join(''), 2)); | ||
} while (baseStrArr.length); | ||
return isNegative | ||
? Uint8Array.from(bytes.map(function (byte) { return 255 - byte; })) | ||
: Uint8Array.from(bytes); | ||
}; | ||
BigNumber.fromBytes = function (bytes, _a) { | ||
var _b = _a === void 0 ? {} : _a, _c = _b.isSigned, isSigned = _c === void 0 ? true : _c, _d = _b.isLong, isLong = _d === void 0 ? true : _d; | ||
if (isLong && bytes.length !== 8) { | ||
throw new Error('Wrong bytes length! Minimal length is 8 byte!'); | ||
} | ||
bytes = ((!isLong && bytes.length > 0) || isLong) | ||
? bytes | ||
: [0]; | ||
var isNegative = isSigned ? bytes[0] > 127 : false; | ||
var byteString = Array.from(bytes) | ||
@@ -137,8 +163,5 @@ .map(function (byte) { return isNegative ? 255 - byte : byte; }) | ||
var result = new BigNumber(new bignumber_js_1.default(byteString, 2)); | ||
if (isNegative) { | ||
return result.mul(-1).sub(1); | ||
} | ||
else { | ||
return result; | ||
} | ||
return isNegative | ||
? result.mul(-1).sub(1) | ||
: result; | ||
}; | ||
@@ -206,4 +229,5 @@ BigNumber.max = function () { | ||
}; | ||
BigNumber.MIN_VALUE = new BigNumber('-9223372036854775808'); | ||
BigNumber.MAX_VALUE = new BigNumber('9223372036854775807'); | ||
BigNumber.MIN_VALUE = new BigNumber('-9223372036854775808'); | ||
BigNumber.MIN_UNSIGNED_VALUE = new BigNumber('0'); | ||
BigNumber.MAX_UNSIGNED_VALUE = new BigNumber('18446744073709551615'); | ||
@@ -210,0 +234,0 @@ BigNumber.config = new Config_1.Config(); |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).BigNumber={})}(this,function(e){"use strict";var t=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,r=Math.ceil,n=Math.floor,i="[BigNumber Error] ",o=i+"Number primitive has more than 15 significant digits: ",u=1e14,s=14,f=9007199254740991,c=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],l=1e7,a=1e9;function h(e){var t=0|e;return e>0||e===t?t:t-1}function p(e){for(var t,r,n=1,i=e.length,o=e[0]+"";n<i;){for(t=e[n++]+"",r=s-t.length;r--;t="0"+t);o+=t}for(i=o.length;48===o.charCodeAt(--i););return o.slice(0,i+1||1)}function g(e,t){var r,n,i=e.c,o=t.c,u=e.s,s=t.s,f=e.e,c=t.e;if(!u||!s)return null;if(r=i&&!i[0],n=o&&!o[0],r||n)return r?n?0:-s:u;if(u!=s)return u;if(r=u<0,n=f==c,!i||!o)return n?0:!i^r?1:-1;if(!n)return f>c^r?1:-1;for(s=(f=i.length)<(c=o.length)?f:c,u=0;u<s;u++)if(i[u]!=o[u])return i[u]>o[u]^r?1:-1;return f==c?0:f>c^r?1:-1}function m(e,t,r,o){if(e<t||e>r||e!==n(e))throw Error(i+(o||"Argument")+("number"==typeof e?e<t||e>r?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function b(e){var t=e.c.length-1;return h(e.e/s)==t&&e.c[t]%2!=0}function N(e,t){return(e.length>1?e.charAt(0)+"."+e.slice(1):e)+(t<0?"e":"e+")+t}function w(e,t,r){var n,i;if(t<0){for(i=r+".";++t;i+=r);e=i+e}else if(++t>(n=e.length)){for(i=r,t-=n;--t;i+=r);e+=i}else t<n&&(e=e.slice(0,t)+"."+e.slice(t));return e}var d=function e(d){var y,O,v,A,E,_,R,D,U,B=q.prototype={constructor:q,toString:null,valueOf:null},L=new q(1),F=20,S=4,x=-7,I=21,P=-1e7,M=1e7,T=!1,C=1,j=0,G={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},H="0123456789abcdefghijklmnopqrstuvwxyz";function q(e,r){var i,u,c,l,a,h,p,g,b=this;if(!(b instanceof q))return new q(e,r);if(null==r){if(e&&!0===e._isBigNumber)return b.s=e.s,void(!e.c||e.e>M?b.c=b.e=null:e.e<P?b.c=[b.e=0]:(b.e=e.e,b.c=e.c.slice()));if((h="number"==typeof e)&&0*e==0){if(b.s=1/e<0?(e=-e,-1):1,e===~~e){for(l=0,a=e;a>=10;a/=10,l++);return void(l>M?b.c=b.e=null:(b.e=l,b.c=[e]))}g=String(e)}else{if(!t.test(g=String(e)))return v(b,g,h);b.s=45==g.charCodeAt(0)?(g=g.slice(1),-1):1}(l=g.indexOf("."))>-1&&(g=g.replace(".","")),(a=g.search(/e/i))>0?(l<0&&(l=a),l+=+g.slice(a+1),g=g.substring(0,a)):l<0&&(l=g.length)}else{if(m(r,2,H.length,"Base"),10==r)return z(b=new q(e),F+b.e+1,S);if(g=String(e),h="number"==typeof e){if(0*e!=0)return v(b,g,h,r);if(b.s=1/e<0?(g=g.slice(1),-1):1,q.DEBUG&&g.replace(/^0\.0*|\./,"").length>15)throw Error(o+e)}else b.s=45===g.charCodeAt(0)?(g=g.slice(1),-1):1;for(i=H.slice(0,r),l=a=0,p=g.length;a<p;a++)if(i.indexOf(u=g.charAt(a))<0){if("."==u){if(a>l){l=p;continue}}else if(!c&&(g==g.toUpperCase()&&(g=g.toLowerCase())||g==g.toLowerCase()&&(g=g.toUpperCase()))){c=!0,a=-1,l=0;continue}return v(b,String(e),h,r)}h=!1,(l=(g=O(g,r,10,b.s)).indexOf("."))>-1?g=g.replace(".",""):l=g.length}for(a=0;48===g.charCodeAt(a);a++);for(p=g.length;48===g.charCodeAt(--p););if(g=g.slice(a,++p)){if(p-=a,h&&q.DEBUG&&p>15&&(e>f||e!==n(e)))throw Error(o+b.s*e);if((l=l-a-1)>M)b.c=b.e=null;else if(l<P)b.c=[b.e=0];else{if(b.e=l,b.c=[],a=(l+1)%s,l<0&&(a+=s),a<p){for(a&&b.c.push(+g.slice(0,a)),p-=s;a<p;)b.c.push(+g.slice(a,a+=s));a=s-(g=g.slice(a)).length}else a-=p;for(;a--;g+="0");b.c.push(+g)}}else b.c=[b.e=0]}function J(e,t,r,n){var i,o,u,s,f;if(null==r?r=S:m(r,0,8),!e.c)return e.toString();if(i=e.c[0],u=e.e,null==t)f=p(e.c),f=1==n||2==n&&(u<=x||u>=I)?N(f,u):w(f,u,"0");else if(o=(e=z(new q(e),t,r)).e,s=(f=p(e.c)).length,1==n||2==n&&(t<=o||o<=x)){for(;s<t;f+="0",s++);f=N(f,o)}else if(t-=u,f=w(f,o,"0"),o+1>s){if(--t>0)for(f+=".";t--;f+="0");}else if((t+=o-s)>0)for(o+1==s&&(f+=".");t--;f+="0");return e.s<0&&i?"-"+f:f}function k(e,t){for(var r,n=1,i=new q(e[0]);n<e.length;n++){if(!(r=new q(e[n])).s){i=r;break}t.call(i,r)&&(i=r)}return i}function V(e,t,r){for(var n=1,i=t.length;!t[--i];t.pop());for(i=t[0];i>=10;i/=10,n++);return(r=n+r*s-1)>M?e.c=e.e=null:r<P?e.c=[e.e=0]:(e.e=r,e.c=t),e}function z(e,t,i,o){var f,l,a,h,p,g,m,b=e.c,N=c;if(b){e:{for(f=1,h=b[0];h>=10;h/=10,f++);if((l=t-f)<0)l+=s,a=t,m=(p=b[g=0])/N[f-a-1]%10|0;else if((g=r((l+1)/s))>=b.length){if(!o)break e;for(;b.length<=g;b.push(0));p=m=0,f=1,a=(l%=s)-s+1}else{for(p=h=b[g],f=1;h>=10;h/=10,f++);m=(a=(l%=s)-s+f)<0?0:p/N[f-a-1]%10|0}if(o=o||t<0||null!=b[g+1]||(a<0?p:p%N[f-a-1]),o=i<4?(m||o)&&(0==i||i==(e.s<0?3:2)):m>5||5==m&&(4==i||o||6==i&&(l>0?a>0?p/N[f-a]:0:b[g-1])%10&1||i==(e.s<0?8:7)),t<1||!b[0])return b.length=0,o?(t-=e.e+1,b[0]=N[(s-t%s)%s],e.e=-t||0):b[0]=e.e=0,e;if(0==l?(b.length=g,h=1,g--):(b.length=g+1,h=N[s-l],b[g]=a>0?n(p/N[f-a]%N[a])*h:0),o)for(;;){if(0==g){for(l=1,a=b[0];a>=10;a/=10,l++);for(a=b[0]+=h,h=1;a>=10;a/=10,h++);l!=h&&(e.e++,b[0]==u&&(b[0]=1));break}if(b[g]+=h,b[g]!=u)break;b[g--]=0,h=1}for(l=b.length;0===b[--l];b.pop());}e.e>M?e.c=e.e=null:e.e<P&&(e.c=[e.e=0])}return e}function $(e){var t,r=e.e;return null===r?e.toString():(t=p(e.c),t=r<=x||r>=I?N(t,r):w(t,r,"0"),e.s<0?"-"+t:t)}return q.clone=e,q.ROUND_UP=0,q.ROUND_DOWN=1,q.ROUND_CEIL=2,q.ROUND_FLOOR=3,q.ROUND_HALF_UP=4,q.ROUND_HALF_DOWN=5,q.ROUND_HALF_EVEN=6,q.ROUND_HALF_CEIL=7,q.ROUND_HALF_FLOOR=8,q.EUCLID=9,q.config=q.set=function(e){var t,r;if(null!=e){if("object"!=typeof e)throw Error(i+"Object expected: "+e);if(e.hasOwnProperty(t="DECIMAL_PLACES")&&(m(r=e[t],0,a,t),F=r),e.hasOwnProperty(t="ROUNDING_MODE")&&(m(r=e[t],0,8,t),S=r),e.hasOwnProperty(t="EXPONENTIAL_AT")&&((r=e[t])&&r.pop?(m(r[0],-a,0,t),m(r[1],0,a,t),x=r[0],I=r[1]):(m(r,-a,a,t),x=-(I=r<0?-r:r))),e.hasOwnProperty(t="RANGE"))if((r=e[t])&&r.pop)m(r[0],-a,-1,t),m(r[1],1,a,t),P=r[0],M=r[1];else{if(m(r,-a,a,t),!r)throw Error(i+t+" cannot be zero: "+r);P=-(M=r<0?-r:r)}if(e.hasOwnProperty(t="CRYPTO")){if((r=e[t])!==!!r)throw Error(i+t+" not true or false: "+r);if(r){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw T=!r,Error(i+"crypto unavailable");T=r}else T=r}if(e.hasOwnProperty(t="MODULO_MODE")&&(m(r=e[t],0,9,t),C=r),e.hasOwnProperty(t="POW_PRECISION")&&(m(r=e[t],0,a,t),j=r),e.hasOwnProperty(t="FORMAT")){if("object"!=typeof(r=e[t]))throw Error(i+t+" not an object: "+r);G=r}if(e.hasOwnProperty(t="ALPHABET")){if("string"!=typeof(r=e[t])||/^.$|[+-.\s]|(.).*\1/.test(r))throw Error(i+t+" invalid: "+r);H=r}}return{DECIMAL_PLACES:F,ROUNDING_MODE:S,EXPONENTIAL_AT:[x,I],RANGE:[P,M],CRYPTO:T,MODULO_MODE:C,POW_PRECISION:j,FORMAT:G,ALPHABET:H}},q.isBigNumber=function(e){if(!e||!0!==e._isBigNumber)return!1;if(!q.DEBUG)return!0;var t,r,o=e.c,f=e.e,c=e.s;e:if("[object Array]"=={}.toString.call(o)){if((1===c||-1===c)&&f>=-a&&f<=a&&f===n(f)){if(0===o[0]){if(0===f&&1===o.length)return!0;break e}if((t=(f+1)%s)<1&&(t+=s),String(o[0]).length==t){for(t=0;t<o.length;t++)if((r=o[t])<0||r>=u||r!==n(r))break e;if(0!==r)return!0}}}else if(null===o&&null===f&&(null===c||1===c||-1===c))return!0;throw Error(i+"Invalid BigNumber: "+e)},q.maximum=q.max=function(){return k(arguments,B.lt)},q.minimum=q.min=function(){return k(arguments,B.gt)},q.random=(A=9007199254740992*Math.random()&2097151?function(){return n(9007199254740992*Math.random())}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(e){var t,o,u,f,l,h=0,p=[],g=new q(L);if(null==e?e=F:m(e,0,a),f=r(e/s),T)if(crypto.getRandomValues){for(t=crypto.getRandomValues(new Uint32Array(f*=2));h<f;)(l=131072*t[h]+(t[h+1]>>>11))>=9e15?(o=crypto.getRandomValues(new Uint32Array(2)),t[h]=o[0],t[h+1]=o[1]):(p.push(l%1e14),h+=2);h=f/2}else{if(!crypto.randomBytes)throw T=!1,Error(i+"crypto unavailable");for(t=crypto.randomBytes(f*=7);h<f;)(l=281474976710656*(31&t[h])+1099511627776*t[h+1]+4294967296*t[h+2]+16777216*t[h+3]+(t[h+4]<<16)+(t[h+5]<<8)+t[h+6])>=9e15?crypto.randomBytes(7).copy(t,h):(p.push(l%1e14),h+=7);h=f/7}if(!T)for(;h<f;)(l=A())<9e15&&(p[h++]=l%1e14);for(f=p[--h],e%=s,f&&e&&(l=c[s-e],p[h]=n(f/l)*l);0===p[h];p.pop(),h--);if(h<0)p=[u=0];else{for(u=-1;0===p[0];p.splice(0,1),u-=s);for(h=1,l=p[0];l>=10;l/=10,h++);h<s&&(u-=s-h)}return g.e=u,g.c=p,g}),q.sum=function(){for(var e=1,t=arguments,r=new q(t[0]);e<t.length;)r=r.plus(t[e++]);return r},O=function(){function e(e,t,r,n){for(var i,o,u=[0],s=0,f=e.length;s<f;){for(o=u.length;o--;u[o]*=t);for(u[0]+=n.indexOf(e.charAt(s++)),i=0;i<u.length;i++)u[i]>r-1&&(null==u[i+1]&&(u[i+1]=0),u[i+1]+=u[i]/r|0,u[i]%=r)}return u.reverse()}return function(t,r,n,i,o){var u,s,f,c,l,a,h,g,m=t.indexOf("."),b=F,N=S;for(m>=0&&(c=j,j=0,t=t.replace(".",""),a=(g=new q(r)).pow(t.length-m),j=c,g.c=e(w(p(a.c),a.e,"0"),10,n,"0123456789"),g.e=g.c.length),f=c=(h=e(t,r,n,o?(u=H,"0123456789"):(u="0123456789",H))).length;0==h[--c];h.pop());if(!h[0])return u.charAt(0);if(m<0?--f:(a.c=h,a.e=f,a.s=i,h=(a=y(a,g,b,N,n)).c,l=a.r,f=a.e),m=h[s=f+b+1],c=n/2,l=l||s<0||null!=h[s+1],l=N<4?(null!=m||l)&&(0==N||N==(a.s<0?3:2)):m>c||m==c&&(4==N||l||6==N&&1&h[s-1]||N==(a.s<0?8:7)),s<1||!h[0])t=l?w(u.charAt(1),-b,u.charAt(0)):u.charAt(0);else{if(h.length=s,l)for(--n;++h[--s]>n;)h[s]=0,s||(++f,h=[1].concat(h));for(c=h.length;!h[--c];);for(m=0,t="";m<=c;t+=u.charAt(h[m++]));t=w(t,f,u.charAt(0))}return t}}(),y=function(){function e(e,t,r){var n,i,o,u,s=0,f=e.length,c=t%l,a=t/l|0;for(e=e.slice();f--;)s=((i=c*(o=e[f]%l)+(n=a*o+(u=e[f]/l|0)*c)%l*l+s)/r|0)+(n/l|0)+a*u,e[f]=i%r;return s&&(e=[s].concat(e)),e}function t(e,t,r,n){var i,o;if(r!=n)o=r>n?1:-1;else for(i=o=0;i<r;i++)if(e[i]!=t[i]){o=e[i]>t[i]?1:-1;break}return o}function r(e,t,r,n){for(var i=0;r--;)e[r]-=i,i=e[r]<t[r]?1:0,e[r]=i*n+e[r]-t[r];for(;!e[0]&&e.length>1;e.splice(0,1));}return function(i,o,f,c,l){var a,p,g,m,b,N,w,d,y,O,v,A,E,_,R,D,U,B=i.s==o.s?1:-1,L=i.c,F=o.c;if(!(L&&L[0]&&F&&F[0]))return new q(i.s&&o.s&&(L?!F||L[0]!=F[0]:F)?L&&0==L[0]||!F?0*B:B/0:NaN);for(y=(d=new q(B)).c=[],B=f+(p=i.e-o.e)+1,l||(l=u,p=h(i.e/s)-h(o.e/s),B=B/s|0),g=0;F[g]==(L[g]||0);g++);if(F[g]>(L[g]||0)&&p--,B<0)y.push(1),m=!0;else{for(_=L.length,D=F.length,g=0,B+=2,(b=n(l/(F[0]+1)))>1&&(F=e(F,b,l),L=e(L,b,l),D=F.length,_=L.length),E=D,v=(O=L.slice(0,D)).length;v<D;O[v++]=0);U=F.slice(),U=[0].concat(U),R=F[0],F[1]>=l/2&&R++;do{if(b=0,(a=t(F,O,D,v))<0){if(A=O[0],D!=v&&(A=A*l+(O[1]||0)),(b=n(A/R))>1)for(b>=l&&(b=l-1),w=(N=e(F,b,l)).length,v=O.length;1==t(N,O,w,v);)b--,r(N,D<w?U:F,w,l),w=N.length,a=1;else 0==b&&(a=b=1),w=(N=F.slice()).length;if(w<v&&(N=[0].concat(N)),r(O,N,v,l),v=O.length,-1==a)for(;t(F,O,D,v)<1;)b++,r(O,D<v?U:F,v,l),v=O.length}else 0===a&&(b++,O=[0]);y[g++]=b,O[0]?O[v++]=L[E]||0:(O=[L[E]],v=1)}while((E++<_||null!=O[0])&&B--);m=null!=O[0],y[0]||y.splice(0,1)}if(l==u){for(g=1,B=y[0];B>=10;B/=10,g++);z(d,f+(d.e=g+p*s-1)+1,c,m)}else d.e=p,d.r=+m;return d}}(),E=/^(-?)0([xbo])(?=\w[\w.]*$)/i,_=/^([^.]+)\.$/,R=/^\.([^.]+)$/,D=/^-?(Infinity|NaN)$/,U=/^\s*\+(?=[\w.])|^\s+|\s+$/g,v=function(e,t,r,n){var o,u=r?t:t.replace(U,"");if(D.test(u))e.s=isNaN(u)?null:u<0?-1:1;else{if(!r&&(u=u.replace(E,function(e,t,r){return o="x"==(r=r.toLowerCase())?16:"b"==r?2:8,n&&n!=o?e:t}),n&&(o=n,u=u.replace(_,"$1").replace(R,"0.$1")),t!=u))return new q(u,o);if(q.DEBUG)throw Error(i+"Not a"+(n?" base "+n:"")+" number: "+t);e.s=null}e.c=e.e=null},B.absoluteValue=B.abs=function(){var e=new q(this);return e.s<0&&(e.s=1),e},B.comparedTo=function(e,t){return g(this,new q(e,t))},B.decimalPlaces=B.dp=function(e,t){var r,n,i,o=this;if(null!=e)return m(e,0,a),null==t?t=S:m(t,0,8),z(new q(o),e+o.e+1,t);if(!(r=o.c))return null;if(n=((i=r.length-1)-h(this.e/s))*s,i=r[i])for(;i%10==0;i/=10,n--);return n<0&&(n=0),n},B.dividedBy=B.div=function(e,t){return y(this,new q(e,t),F,S)},B.dividedToIntegerBy=B.idiv=function(e,t){return y(this,new q(e,t),0,1)},B.exponentiatedBy=B.pow=function(e,t){var o,u,f,c,l,a,h,p,g=this;if((e=new q(e)).c&&!e.isInteger())throw Error(i+"Exponent not an integer: "+$(e));if(null!=t&&(t=new q(t)),l=e.e>14,!g.c||!g.c[0]||1==g.c[0]&&!g.e&&1==g.c.length||!e.c||!e.c[0])return p=new q(Math.pow(+$(g),l?2-b(e):+$(e))),t?p.mod(t):p;if(a=e.s<0,t){if(t.c?!t.c[0]:!t.s)return new q(NaN);(u=!a&&g.isInteger()&&t.isInteger())&&(g=g.mod(t))}else{if(e.e>9&&(g.e>0||g.e<-1||(0==g.e?g.c[0]>1||l&&g.c[1]>=24e7:g.c[0]<8e13||l&&g.c[0]<=9999975e7)))return c=g.s<0&&b(e)?-0:0,g.e>-1&&(c=1/c),new q(a?1/c:c);j&&(c=r(j/s+2))}for(l?(o=new q(.5),a&&(e.s=1),h=b(e)):h=(f=Math.abs(+$(e)))%2,p=new q(L);;){if(h){if(!(p=p.times(g)).c)break;c?p.c.length>c&&(p.c.length=c):u&&(p=p.mod(t))}if(f){if(0===(f=n(f/2)))break;h=f%2}else if(z(e=e.times(o),e.e+1,1),e.e>14)h=b(e);else{if(0==(f=+$(e)))break;h=f%2}g=g.times(g),c?g.c&&g.c.length>c&&(g.c.length=c):u&&(g=g.mod(t))}return u?p:(a&&(p=L.div(p)),t?p.mod(t):c?z(p,j,S,void 0):p)},B.integerValue=function(e){var t=new q(this);return null==e?e=S:m(e,0,8),z(t,t.e+1,e)},B.isEqualTo=B.eq=function(e,t){return 0===g(this,new q(e,t))},B.isFinite=function(){return!!this.c},B.isGreaterThan=B.gt=function(e,t){return g(this,new q(e,t))>0},B.isGreaterThanOrEqualTo=B.gte=function(e,t){return 1===(t=g(this,new q(e,t)))||0===t},B.isInteger=function(){return!!this.c&&h(this.e/s)>this.c.length-2},B.isLessThan=B.lt=function(e,t){return g(this,new q(e,t))<0},B.isLessThanOrEqualTo=B.lte=function(e,t){return-1===(t=g(this,new q(e,t)))||0===t},B.isNaN=function(){return!this.s},B.isNegative=function(){return this.s<0},B.isPositive=function(){return this.s>0},B.isZero=function(){return!!this.c&&0==this.c[0]},B.minus=function(e,t){var r,n,i,o,f=this,c=f.s;if(t=(e=new q(e,t)).s,!c||!t)return new q(NaN);if(c!=t)return e.s=-t,f.plus(e);var l=f.e/s,a=e.e/s,p=f.c,g=e.c;if(!l||!a){if(!p||!g)return p?(e.s=-t,e):new q(g?f:NaN);if(!p[0]||!g[0])return g[0]?(e.s=-t,e):new q(p[0]?f:3==S?-0:0)}if(l=h(l),a=h(a),p=p.slice(),c=l-a){for((o=c<0)?(c=-c,i=p):(a=l,i=g),i.reverse(),t=c;t--;i.push(0));i.reverse()}else for(n=(o=(c=p.length)<(t=g.length))?c:t,c=t=0;t<n;t++)if(p[t]!=g[t]){o=p[t]<g[t];break}if(o&&(i=p,p=g,g=i,e.s=-e.s),(t=(n=g.length)-(r=p.length))>0)for(;t--;p[r++]=0);for(t=u-1;n>c;){if(p[--n]<g[n]){for(r=n;r&&!p[--r];p[r]=t);--p[r],p[n]+=u}p[n]-=g[n]}for(;0==p[0];p.splice(0,1),--a);return p[0]?V(e,p,a):(e.s=3==S?-1:1,e.c=[e.e=0],e)},B.modulo=B.mod=function(e,t){var r,n,i=this;return e=new q(e,t),!i.c||!e.s||e.c&&!e.c[0]?new q(NaN):!e.c||i.c&&!i.c[0]?new q(i):(9==C?(n=e.s,e.s=1,r=y(i,e,0,3),e.s=n,r.s*=n):r=y(i,e,0,C),(e=i.minus(r.times(e))).c[0]||1!=C||(e.s=i.s),e)},B.multipliedBy=B.times=function(e,t){var r,n,i,o,f,c,a,p,g,m,b,N,w,d,y,O=this,v=O.c,A=(e=new q(e,t)).c;if(!(v&&A&&v[0]&&A[0]))return!O.s||!e.s||v&&!v[0]&&!A||A&&!A[0]&&!v?e.c=e.e=e.s=null:(e.s*=O.s,v&&A?(e.c=[0],e.e=0):e.c=e.e=null),e;for(n=h(O.e/s)+h(e.e/s),e.s*=O.s,(a=v.length)<(m=A.length)&&(w=v,v=A,A=w,i=a,a=m,m=i),i=a+m,w=[];i--;w.push(0));for(d=u,y=l,i=m;--i>=0;){for(r=0,b=A[i]%y,N=A[i]/y|0,o=i+(f=a);o>i;)r=((p=b*(p=v[--f]%y)+(c=N*p+(g=v[f]/y|0)*b)%y*y+w[o]+r)/d|0)+(c/y|0)+N*g,w[o--]=p%d;w[o]=r}return r?++n:w.splice(0,1),V(e,w,n)},B.negated=function(){var e=new q(this);return e.s=-e.s||null,e},B.plus=function(e,t){var r,n=this,i=n.s;if(t=(e=new q(e,t)).s,!i||!t)return new q(NaN);if(i!=t)return e.s=-t,n.minus(e);var o=n.e/s,f=e.e/s,c=n.c,l=e.c;if(!o||!f){if(!c||!l)return new q(i/0);if(!c[0]||!l[0])return l[0]?e:new q(c[0]?n:0*i)}if(o=h(o),f=h(f),c=c.slice(),i=o-f){for(i>0?(f=o,r=l):(i=-i,r=c),r.reverse();i--;r.push(0));r.reverse()}for((i=c.length)-(t=l.length)<0&&(r=l,l=c,c=r,t=i),i=0;t;)i=(c[--t]=c[t]+l[t]+i)/u|0,c[t]=u===c[t]?0:c[t]%u;return i&&(c=[i].concat(c),++f),V(e,c,f)},B.precision=B.sd=function(e,t){var r,n,i,o=this;if(null!=e&&e!==!!e)return m(e,1,a),null==t?t=S:m(t,0,8),z(new q(o),e,t);if(!(r=o.c))return null;if(n=(i=r.length-1)*s+1,i=r[i]){for(;i%10==0;i/=10,n--);for(i=r[0];i>=10;i/=10,n++);}return e&&o.e+1>n&&(n=o.e+1),n},B.shiftedBy=function(e){return m(e,-f,f),this.times("1e"+e)},B.squareRoot=B.sqrt=function(){var e,t,r,n,i,o=this,u=o.c,s=o.s,f=o.e,c=F+4,l=new q("0.5");if(1!==s||!u||!u[0])return new q(!s||s<0&&(!u||u[0])?NaN:u?o:1/0);if(0==(s=Math.sqrt(+$(o)))||s==1/0?(((t=p(u)).length+f)%2==0&&(t+="0"),s=Math.sqrt(+t),f=h((f+1)/2)-(f<0||f%2),r=new q(t=s==1/0?"1e"+f:(t=s.toExponential()).slice(0,t.indexOf("e")+1)+f)):r=new q(s+""),r.c[0])for((s=(f=r.e)+c)<3&&(s=0);;)if(i=r,r=l.times(i.plus(y(o,i,c,1))),p(i.c).slice(0,s)===(t=p(r.c)).slice(0,s)){if(r.e<f&&--s,"9999"!=(t=t.slice(s-3,s+1))&&(n||"4999"!=t)){+t&&(+t.slice(1)||"5"!=t.charAt(0))||(z(r,r.e+F+2,1),e=!r.times(r).eq(o));break}if(!n&&(z(i,i.e+F+2,0),i.times(i).eq(o))){r=i;break}c+=4,s+=4,n=1}return z(r,r.e+F+1,S,e)},B.toExponential=function(e,t){return null!=e&&(m(e,0,a),e++),J(this,e,t,1)},B.toFixed=function(e,t){return null!=e&&(m(e,0,a),e=e+this.e+1),J(this,e,t)},B.toFormat=function(e,t,r){var n,o=this;if(null==r)null!=e&&t&&"object"==typeof t?(r=t,t=null):e&&"object"==typeof e?(r=e,e=t=null):r=G;else if("object"!=typeof r)throw Error(i+"Argument not an object: "+r);if(n=o.toFixed(e,t),o.c){var u,s=n.split("."),f=+r.groupSize,c=+r.secondaryGroupSize,l=r.groupSeparator||"",a=s[0],h=s[1],p=o.s<0,g=p?a.slice(1):a,m=g.length;if(c&&(u=f,f=c,c=u,m-=u),f>0&&m>0){for(u=m%f||f,a=g.substr(0,u);u<m;u+=f)a+=l+g.substr(u,f);c>0&&(a+=l+g.slice(u)),p&&(a="-"+a)}n=h?a+(r.decimalSeparator||"")+((c=+r.fractionGroupSize)?h.replace(new RegExp("\\d{"+c+"}\\B","g"),"$&"+(r.fractionGroupSeparator||"")):h):a}return(r.prefix||"")+n+(r.suffix||"")},B.toFraction=function(e){var t,r,n,o,u,f,l,a,h,g,m,b,N=this,w=N.c;if(null!=e&&(!(l=new q(e)).isInteger()&&(l.c||1!==l.s)||l.lt(L)))throw Error(i+"Argument "+(l.isInteger()?"out of range: ":"not an integer: ")+$(l));if(!w)return new q(N);for(t=new q(L),h=r=new q(L),n=a=new q(L),b=p(w),u=t.e=b.length-N.e-1,t.c[0]=c[(f=u%s)<0?s+f:f],e=!e||l.comparedTo(t)>0?u>0?t:h:l,f=M,M=1/0,l=new q(b),a.c[0]=0;g=y(l,t,0,1),1!=(o=r.plus(g.times(n))).comparedTo(e);)r=n,n=o,h=a.plus(g.times(o=h)),a=o,t=l.minus(g.times(o=t)),l=o;return o=y(e.minus(r),n,0,1),a=a.plus(o.times(h)),r=r.plus(o.times(n)),a.s=h.s=N.s,m=y(h,n,u*=2,S).minus(N).abs().comparedTo(y(a,r,u,S).minus(N).abs())<1?[h,n]:[a,r],M=f,m},B.toNumber=function(){return+$(this)},B.toPrecision=function(e,t){return null!=e&&m(e,1,a),J(this,e,t,2)},B.toString=function(e){var t,r=this,n=r.s,i=r.e;return null===i?n?(t="Infinity",n<0&&(t="-"+t)):t="NaN":(null==e?t=i<=x||i>=I?N(p(r.c),i):w(p(r.c),i,"0"):10===e?t=w(p((r=z(new q(r),F+i+1,S)).c),r.e,"0"):(m(e,2,H.length,"Base"),t=O(w(p(r.c),i,"0"),10,e,n,!0)),n<0&&r.c[0]&&(t="-"+t)),t},B.valueOf=B.toJSON=function(){return $(this)},B._isBigNumber=!0,B[Symbol.toStringTag]="BigNumber",B[Symbol.for("nodejs.util.inspect.custom")]=B.valueOf,null!=d&&q.set(d),q}(),y=function(){return(y=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)},O=function(){function e(){this.format=e.DEFAULT_FORMAT,d.config({FORMAT:this.format})}return e.prototype.set=function(e){"FORMAT"in e&&(this.format=y({},this.format,e.FORMAT),e.FORMAT=this.format),d.config(e)},e.DEFAULT_FORMAT={prefix:"",decimalSeparator:".",groupSeparator:",",groupSize:3,secondaryGroupSize:0,fractionGroupSeparator:" ",fractionGroupSize:0,suffix:""},e}();e.BigNumber=function(){function e(t){"object"==typeof t&&e.isBigNumber(t)?this.bn=t.bn.plus(0):this.bn=e.toBigNumberJs(t)}return e.prototype.clone=function(){return new e(this)},e.prototype.add=function(t){return new e(this.bn.plus(e.toBigNumberJs(t)))},e.prototype.sub=function(t){return new e(this.bn.minus(e.toBigNumberJs(t)))},e.prototype.mul=function(t){return new e(this.bn.times(e.toBigNumberJs(t)))},e.prototype.div=function(t){return new e(this.bn.div(e.toBigNumberJs(t)))},e.prototype.pow=function(t){return new e(this.bn.pow(e.toBigNumberJs(t)))},e.prototype.abs=function(){return new e(this.bn.abs())},e.prototype.mod=function(t){return new e(this.bn.mod(e.toBigNumberJs(t)))},e.prototype.roundTo=function(t,r){return void 0===t&&(t=0),void 0===r&&(r=4),new e(this.bn.dp(t||0,r))},e.prototype.eq=function(t){return this.bn.eq(e.toBigNumberJs(t))},e.prototype.lt=function(t){return this.bn.lt(e.toBigNumberJs(t))},e.prototype.gt=function(t){return this.bn.gt(e.toBigNumberJs(t))},e.prototype.lte=function(t){return this.bn.lte(e.toBigNumberJs(t))},e.prototype.gte=function(t){return this.bn.gte(e.toBigNumberJs(t))},e.prototype.isNaN=function(){return this.bn.isNaN()},e.prototype.isFinite=function(){return this.bn.isFinite()},e.prototype.isZero=function(){return this.eq(0)},e.prototype.isPositive=function(){return this.gt(0)},e.prototype.isNegative=function(){return this.lt(0)},e.prototype.isInt=function(){return this.bn.isInteger()},e.prototype.getDecimalsCount=function(){return this.bn.dp()},e.prototype.isEven=function(){return this.mod(2).eq(0)},e.prototype.isOdd=function(){return!this.isEven()},e.prototype.toBytes=function(){if(!this.isInt())throw new Error("Cant create bytes from number with decimals!");var t=this.isNegative(),r=t?"1":"0",n=e._toLength(64,this.bn.plus(r).abs().toString(2).replace("-","")).split(""),i=[];do{i.push(parseInt(n.splice(0,8).join(""),2))}while(n.length);return t?Uint8Array.from(i.map(function(e){return 255-e})):Uint8Array.from(i)},e.prototype.toFormat=function(e,t,r){return this.bn.toFormat(e,t,r)},e.prototype.toFixed=function(e,t){return null==e?this.bn.toFixed():this.bn.toFixed(e,t)},e.prototype.toString=function(){return this.toFixed()},e.prototype.toNumber=function(){return this.bn.toNumber()},e.prototype.toJSON=function(){return this.bn.toFixed()},e.prototype.valueOf=function(){return this.bn.valueOf()},e.fromBytes=function(t){if(8!==t.length)throw new Error("Wrong bytes length! Need 8 bytes!");var r=t[0]>127,n=Array.from(t).map(function(e){return r?255-e:e}).map(function(t){return e._toLength(8,t.toString(2))}).join(""),i=new e(new d(n,2));return r?i.mul(-1).sub(1):i},e.max=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return e.toBigNumber(t).reduce(function(e,t){return e.gte(t)?e:t})},e.min=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return e.toBigNumber(t).reduce(function(e,t){return e.lte(t)?e:t})},e.sum=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return e.toBigNumber(t).reduce(function(e,t){return e.add(t)})},e.isBigNumber=function(t){return t&&"object"==typeof t&&(t instanceof e||Object.entries(e.prototype).filter(function(e){return"_"!==e[0].charAt(0)}).every(function(e){var r=e[0],n=e[1];return r in t&&typeof n==typeof t[r]}))},e.toBigNumber=function(t){return Array.isArray(t)?t.map(function(t){return new e(t)}):new e(t)},e.toBigNumberJs=function(t){return d.isBigNumber(t)?t:t instanceof e?t.bn:new d(t)},e._toLength=function(e,t){return new Array(e).fill("0",0,e).concat(t.split("")).slice(-e).join("")},e.MAX_VALUE=new e("9223372036854775807"),e.MIN_VALUE=new e("-9223372036854775808"),e.MAX_UNSIGNED_VALUE=new e("18446744073709551615"),e.config=new O,e}(),function(e){!function(e){e[e.ROUND_UP=0]="ROUND_UP",e[e.ROUND_DOWN=1]="ROUND_DOWN",e[e.ROUND_CEIL=2]="ROUND_CEIL",e[e.ROUND_FLOOR=3]="ROUND_FLOOR",e[e.ROUND_HALF_UP=4]="ROUND_HALF_UP",e[e.ROUND_HALF_DOWN=5]="ROUND_HALF_DOWN",e[e.ROUND_HALF_EVEN=6]="ROUND_HALF_EVEN",e[e.ROUND_HALF_CEIL=7]="ROUND_HALF_CEIL",e[e.ROUND_HALF_FLOOR=8]="ROUND_HALF_FLOOR"}(e.ROUND_MODE||(e.ROUND_MODE={}))}(e.BigNumber||(e.BigNumber={}));var v=e.BigNumber;e.default=v,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).BigNumber={})}(this,function(e){"use strict";var t=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,n=Math.ceil,r=Math.floor,i="[BigNumber Error] ",o=i+"Number primitive has more than 15 significant digits: ",u=1e14,s=14,f=9007199254740991,c=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],l=1e7,a=1e9;function h(e){var t=0|e;return e>0||e===t?t:t-1}function p(e){for(var t,n,r=1,i=e.length,o=e[0]+"";r<i;){for(t=e[r++]+"",n=s-t.length;n--;t="0"+t);o+=t}for(i=o.length;48===o.charCodeAt(--i););return o.slice(0,i+1||1)}function g(e,t){var n,r,i=e.c,o=t.c,u=e.s,s=t.s,f=e.e,c=t.e;if(!u||!s)return null;if(n=i&&!i[0],r=o&&!o[0],n||r)return n?r?0:-s:u;if(u!=s)return u;if(n=u<0,r=f==c,!i||!o)return r?0:!i^n?1:-1;if(!r)return f>c^n?1:-1;for(s=(f=i.length)<(c=o.length)?f:c,u=0;u<s;u++)if(i[u]!=o[u])return i[u]>o[u]^n?1:-1;return f==c?0:f>c^n?1:-1}function m(e,t,n,o){if(e<t||e>n||e!==r(e))throw Error(i+(o||"Argument")+("number"==typeof e?e<t||e>n?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function N(e){var t=e.c.length-1;return h(e.e/s)==t&&e.c[t]%2!=0}function b(e,t){return(e.length>1?e.charAt(0)+"."+e.slice(1):e)+(t<0?"e":"e+")+t}function d(e,t,n){var r,i;if(t<0){for(i=n+".";++t;i+=n);e=i+e}else if(++t>(r=e.length)){for(i=n,t-=r;--t;i+=n);e+=i}else t<r&&(e=e.slice(0,t)+"."+e.slice(t));return e}var w=function e(w){var y,O,v,E,A,_,U,R,D,L=V.prototype={constructor:V,toString:null,valueOf:null},B=new V(1),S=20,F=4,I=-7,M=21,x=-1e7,P=1e7,T=!1,C=1,G=0,j={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},H="0123456789abcdefghijklmnopqrstuvwxyz";function V(e,n){var i,u,c,l,a,h,p,g,N=this;if(!(N instanceof V))return new V(e,n);if(null==n){if(e&&!0===e._isBigNumber)return N.s=e.s,void(!e.c||e.e>P?N.c=N.e=null:e.e<x?N.c=[N.e=0]:(N.e=e.e,N.c=e.c.slice()));if((h="number"==typeof e)&&0*e==0){if(N.s=1/e<0?(e=-e,-1):1,e===~~e){for(l=0,a=e;a>=10;a/=10,l++);return void(l>P?N.c=N.e=null:(N.e=l,N.c=[e]))}g=String(e)}else{if(!t.test(g=String(e)))return v(N,g,h);N.s=45==g.charCodeAt(0)?(g=g.slice(1),-1):1}(l=g.indexOf("."))>-1&&(g=g.replace(".","")),(a=g.search(/e/i))>0?(l<0&&(l=a),l+=+g.slice(a+1),g=g.substring(0,a)):l<0&&(l=g.length)}else{if(m(n,2,H.length,"Base"),10==n)return z(N=new V(e),S+N.e+1,F);if(g=String(e),h="number"==typeof e){if(0*e!=0)return v(N,g,h,n);if(N.s=1/e<0?(g=g.slice(1),-1):1,V.DEBUG&&g.replace(/^0\.0*|\./,"").length>15)throw Error(o+e)}else N.s=45===g.charCodeAt(0)?(g=g.slice(1),-1):1;for(i=H.slice(0,n),l=a=0,p=g.length;a<p;a++)if(i.indexOf(u=g.charAt(a))<0){if("."==u){if(a>l){l=p;continue}}else if(!c&&(g==g.toUpperCase()&&(g=g.toLowerCase())||g==g.toLowerCase()&&(g=g.toUpperCase()))){c=!0,a=-1,l=0;continue}return v(N,String(e),h,n)}h=!1,(l=(g=O(g,n,10,N.s)).indexOf("."))>-1?g=g.replace(".",""):l=g.length}for(a=0;48===g.charCodeAt(a);a++);for(p=g.length;48===g.charCodeAt(--p););if(g=g.slice(a,++p)){if(p-=a,h&&V.DEBUG&&p>15&&(e>f||e!==r(e)))throw Error(o+N.s*e);if((l=l-a-1)>P)N.c=N.e=null;else if(l<x)N.c=[N.e=0];else{if(N.e=l,N.c=[],a=(l+1)%s,l<0&&(a+=s),a<p){for(a&&N.c.push(+g.slice(0,a)),p-=s;a<p;)N.c.push(+g.slice(a,a+=s));a=s-(g=g.slice(a)).length}else a-=p;for(;a--;g+="0");N.c.push(+g)}}else N.c=[N.e=0]}function q(e,t,n,r){var i,o,u,s,f;if(null==n?n=F:m(n,0,8),!e.c)return e.toString();if(i=e.c[0],u=e.e,null==t)f=p(e.c),f=1==r||2==r&&(u<=I||u>=M)?b(f,u):d(f,u,"0");else if(o=(e=z(new V(e),t,n)).e,s=(f=p(e.c)).length,1==r||2==r&&(t<=o||o<=I)){for(;s<t;f+="0",s++);f=b(f,o)}else if(t-=u,f=d(f,o,"0"),o+1>s){if(--t>0)for(f+=".";t--;f+="0");}else if((t+=o-s)>0)for(o+1==s&&(f+=".");t--;f+="0");return e.s<0&&i?"-"+f:f}function J(e,t){for(var n,r=1,i=new V(e[0]);r<e.length;r++){if(!(n=new V(e[r])).s){i=n;break}t.call(i,n)&&(i=n)}return i}function k(e,t,n){for(var r=1,i=t.length;!t[--i];t.pop());for(i=t[0];i>=10;i/=10,r++);return(n=r+n*s-1)>P?e.c=e.e=null:n<x?e.c=[e.e=0]:(e.e=n,e.c=t),e}function z(e,t,i,o){var f,l,a,h,p,g,m,N=e.c,b=c;if(N){e:{for(f=1,h=N[0];h>=10;h/=10,f++);if((l=t-f)<0)l+=s,a=t,m=(p=N[g=0])/b[f-a-1]%10|0;else if((g=n((l+1)/s))>=N.length){if(!o)break e;for(;N.length<=g;N.push(0));p=m=0,f=1,a=(l%=s)-s+1}else{for(p=h=N[g],f=1;h>=10;h/=10,f++);m=(a=(l%=s)-s+f)<0?0:p/b[f-a-1]%10|0}if(o=o||t<0||null!=N[g+1]||(a<0?p:p%b[f-a-1]),o=i<4?(m||o)&&(0==i||i==(e.s<0?3:2)):m>5||5==m&&(4==i||o||6==i&&(l>0?a>0?p/b[f-a]:0:N[g-1])%10&1||i==(e.s<0?8:7)),t<1||!N[0])return N.length=0,o?(t-=e.e+1,N[0]=b[(s-t%s)%s],e.e=-t||0):N[0]=e.e=0,e;if(0==l?(N.length=g,h=1,g--):(N.length=g+1,h=b[s-l],N[g]=a>0?r(p/b[f-a]%b[a])*h:0),o)for(;;){if(0==g){for(l=1,a=N[0];a>=10;a/=10,l++);for(a=N[0]+=h,h=1;a>=10;a/=10,h++);l!=h&&(e.e++,N[0]==u&&(N[0]=1));break}if(N[g]+=h,N[g]!=u)break;N[g--]=0,h=1}for(l=N.length;0===N[--l];N.pop());}e.e>P?e.c=e.e=null:e.e<x&&(e.c=[e.e=0])}return e}function $(e){var t,n=e.e;return null===n?e.toString():(t=p(e.c),t=n<=I||n>=M?b(t,n):d(t,n,"0"),e.s<0?"-"+t:t)}return V.clone=e,V.ROUND_UP=0,V.ROUND_DOWN=1,V.ROUND_CEIL=2,V.ROUND_FLOOR=3,V.ROUND_HALF_UP=4,V.ROUND_HALF_DOWN=5,V.ROUND_HALF_EVEN=6,V.ROUND_HALF_CEIL=7,V.ROUND_HALF_FLOOR=8,V.EUCLID=9,V.config=V.set=function(e){var t,n;if(null!=e){if("object"!=typeof e)throw Error(i+"Object expected: "+e);if(e.hasOwnProperty(t="DECIMAL_PLACES")&&(m(n=e[t],0,a,t),S=n),e.hasOwnProperty(t="ROUNDING_MODE")&&(m(n=e[t],0,8,t),F=n),e.hasOwnProperty(t="EXPONENTIAL_AT")&&((n=e[t])&&n.pop?(m(n[0],-a,0,t),m(n[1],0,a,t),I=n[0],M=n[1]):(m(n,-a,a,t),I=-(M=n<0?-n:n))),e.hasOwnProperty(t="RANGE"))if((n=e[t])&&n.pop)m(n[0],-a,-1,t),m(n[1],1,a,t),x=n[0],P=n[1];else{if(m(n,-a,a,t),!n)throw Error(i+t+" cannot be zero: "+n);x=-(P=n<0?-n:n)}if(e.hasOwnProperty(t="CRYPTO")){if((n=e[t])!==!!n)throw Error(i+t+" not true or false: "+n);if(n){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw T=!n,Error(i+"crypto unavailable");T=n}else T=n}if(e.hasOwnProperty(t="MODULO_MODE")&&(m(n=e[t],0,9,t),C=n),e.hasOwnProperty(t="POW_PRECISION")&&(m(n=e[t],0,a,t),G=n),e.hasOwnProperty(t="FORMAT")){if("object"!=typeof(n=e[t]))throw Error(i+t+" not an object: "+n);j=n}if(e.hasOwnProperty(t="ALPHABET")){if("string"!=typeof(n=e[t])||/^.$|[+-.\s]|(.).*\1/.test(n))throw Error(i+t+" invalid: "+n);H=n}}return{DECIMAL_PLACES:S,ROUNDING_MODE:F,EXPONENTIAL_AT:[I,M],RANGE:[x,P],CRYPTO:T,MODULO_MODE:C,POW_PRECISION:G,FORMAT:j,ALPHABET:H}},V.isBigNumber=function(e){if(!e||!0!==e._isBigNumber)return!1;if(!V.DEBUG)return!0;var t,n,o=e.c,f=e.e,c=e.s;e:if("[object Array]"=={}.toString.call(o)){if((1===c||-1===c)&&f>=-a&&f<=a&&f===r(f)){if(0===o[0]){if(0===f&&1===o.length)return!0;break e}if((t=(f+1)%s)<1&&(t+=s),String(o[0]).length==t){for(t=0;t<o.length;t++)if((n=o[t])<0||n>=u||n!==r(n))break e;if(0!==n)return!0}}}else if(null===o&&null===f&&(null===c||1===c||-1===c))return!0;throw Error(i+"Invalid BigNumber: "+e)},V.maximum=V.max=function(){return J(arguments,L.lt)},V.minimum=V.min=function(){return J(arguments,L.gt)},V.random=(E=9007199254740992*Math.random()&2097151?function(){return r(9007199254740992*Math.random())}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(e){var t,o,u,f,l,h=0,p=[],g=new V(B);if(null==e?e=S:m(e,0,a),f=n(e/s),T)if(crypto.getRandomValues){for(t=crypto.getRandomValues(new Uint32Array(f*=2));h<f;)(l=131072*t[h]+(t[h+1]>>>11))>=9e15?(o=crypto.getRandomValues(new Uint32Array(2)),t[h]=o[0],t[h+1]=o[1]):(p.push(l%1e14),h+=2);h=f/2}else{if(!crypto.randomBytes)throw T=!1,Error(i+"crypto unavailable");for(t=crypto.randomBytes(f*=7);h<f;)(l=281474976710656*(31&t[h])+1099511627776*t[h+1]+4294967296*t[h+2]+16777216*t[h+3]+(t[h+4]<<16)+(t[h+5]<<8)+t[h+6])>=9e15?crypto.randomBytes(7).copy(t,h):(p.push(l%1e14),h+=7);h=f/7}if(!T)for(;h<f;)(l=E())<9e15&&(p[h++]=l%1e14);for(f=p[--h],e%=s,f&&e&&(l=c[s-e],p[h]=r(f/l)*l);0===p[h];p.pop(),h--);if(h<0)p=[u=0];else{for(u=-1;0===p[0];p.splice(0,1),u-=s);for(h=1,l=p[0];l>=10;l/=10,h++);h<s&&(u-=s-h)}return g.e=u,g.c=p,g}),V.sum=function(){for(var e=1,t=arguments,n=new V(t[0]);e<t.length;)n=n.plus(t[e++]);return n},O=function(){function e(e,t,n,r){for(var i,o,u=[0],s=0,f=e.length;s<f;){for(o=u.length;o--;u[o]*=t);for(u[0]+=r.indexOf(e.charAt(s++)),i=0;i<u.length;i++)u[i]>n-1&&(null==u[i+1]&&(u[i+1]=0),u[i+1]+=u[i]/n|0,u[i]%=n)}return u.reverse()}return function(t,n,r,i,o){var u,s,f,c,l,a,h,g,m=t.indexOf("."),N=S,b=F;for(m>=0&&(c=G,G=0,t=t.replace(".",""),a=(g=new V(n)).pow(t.length-m),G=c,g.c=e(d(p(a.c),a.e,"0"),10,r,"0123456789"),g.e=g.c.length),f=c=(h=e(t,n,r,o?(u=H,"0123456789"):(u="0123456789",H))).length;0==h[--c];h.pop());if(!h[0])return u.charAt(0);if(m<0?--f:(a.c=h,a.e=f,a.s=i,h=(a=y(a,g,N,b,r)).c,l=a.r,f=a.e),m=h[s=f+N+1],c=r/2,l=l||s<0||null!=h[s+1],l=b<4?(null!=m||l)&&(0==b||b==(a.s<0?3:2)):m>c||m==c&&(4==b||l||6==b&&1&h[s-1]||b==(a.s<0?8:7)),s<1||!h[0])t=l?d(u.charAt(1),-N,u.charAt(0)):u.charAt(0);else{if(h.length=s,l)for(--r;++h[--s]>r;)h[s]=0,s||(++f,h=[1].concat(h));for(c=h.length;!h[--c];);for(m=0,t="";m<=c;t+=u.charAt(h[m++]));t=d(t,f,u.charAt(0))}return t}}(),y=function(){function e(e,t,n){var r,i,o,u,s=0,f=e.length,c=t%l,a=t/l|0;for(e=e.slice();f--;)s=((i=c*(o=e[f]%l)+(r=a*o+(u=e[f]/l|0)*c)%l*l+s)/n|0)+(r/l|0)+a*u,e[f]=i%n;return s&&(e=[s].concat(e)),e}function t(e,t,n,r){var i,o;if(n!=r)o=n>r?1:-1;else for(i=o=0;i<n;i++)if(e[i]!=t[i]){o=e[i]>t[i]?1:-1;break}return o}function n(e,t,n,r){for(var i=0;n--;)e[n]-=i,i=e[n]<t[n]?1:0,e[n]=i*r+e[n]-t[n];for(;!e[0]&&e.length>1;e.splice(0,1));}return function(i,o,f,c,l){var a,p,g,m,N,b,d,w,y,O,v,E,A,_,U,R,D,L=i.s==o.s?1:-1,B=i.c,S=o.c;if(!(B&&B[0]&&S&&S[0]))return new V(i.s&&o.s&&(B?!S||B[0]!=S[0]:S)?B&&0==B[0]||!S?0*L:L/0:NaN);for(y=(w=new V(L)).c=[],L=f+(p=i.e-o.e)+1,l||(l=u,p=h(i.e/s)-h(o.e/s),L=L/s|0),g=0;S[g]==(B[g]||0);g++);if(S[g]>(B[g]||0)&&p--,L<0)y.push(1),m=!0;else{for(_=B.length,R=S.length,g=0,L+=2,(N=r(l/(S[0]+1)))>1&&(S=e(S,N,l),B=e(B,N,l),R=S.length,_=B.length),A=R,v=(O=B.slice(0,R)).length;v<R;O[v++]=0);D=S.slice(),D=[0].concat(D),U=S[0],S[1]>=l/2&&U++;do{if(N=0,(a=t(S,O,R,v))<0){if(E=O[0],R!=v&&(E=E*l+(O[1]||0)),(N=r(E/U))>1)for(N>=l&&(N=l-1),d=(b=e(S,N,l)).length,v=O.length;1==t(b,O,d,v);)N--,n(b,R<d?D:S,d,l),d=b.length,a=1;else 0==N&&(a=N=1),d=(b=S.slice()).length;if(d<v&&(b=[0].concat(b)),n(O,b,v,l),v=O.length,-1==a)for(;t(S,O,R,v)<1;)N++,n(O,R<v?D:S,v,l),v=O.length}else 0===a&&(N++,O=[0]);y[g++]=N,O[0]?O[v++]=B[A]||0:(O=[B[A]],v=1)}while((A++<_||null!=O[0])&&L--);m=null!=O[0],y[0]||y.splice(0,1)}if(l==u){for(g=1,L=y[0];L>=10;L/=10,g++);z(w,f+(w.e=g+p*s-1)+1,c,m)}else w.e=p,w.r=+m;return w}}(),A=/^(-?)0([xbo])(?=\w[\w.]*$)/i,_=/^([^.]+)\.$/,U=/^\.([^.]+)$/,R=/^-?(Infinity|NaN)$/,D=/^\s*\+(?=[\w.])|^\s+|\s+$/g,v=function(e,t,n,r){var o,u=n?t:t.replace(D,"");if(R.test(u))e.s=isNaN(u)?null:u<0?-1:1;else{if(!n&&(u=u.replace(A,function(e,t,n){return o="x"==(n=n.toLowerCase())?16:"b"==n?2:8,r&&r!=o?e:t}),r&&(o=r,u=u.replace(_,"$1").replace(U,"0.$1")),t!=u))return new V(u,o);if(V.DEBUG)throw Error(i+"Not a"+(r?" base "+r:"")+" number: "+t);e.s=null}e.c=e.e=null},L.absoluteValue=L.abs=function(){var e=new V(this);return e.s<0&&(e.s=1),e},L.comparedTo=function(e,t){return g(this,new V(e,t))},L.decimalPlaces=L.dp=function(e,t){var n,r,i,o=this;if(null!=e)return m(e,0,a),null==t?t=F:m(t,0,8),z(new V(o),e+o.e+1,t);if(!(n=o.c))return null;if(r=((i=n.length-1)-h(this.e/s))*s,i=n[i])for(;i%10==0;i/=10,r--);return r<0&&(r=0),r},L.dividedBy=L.div=function(e,t){return y(this,new V(e,t),S,F)},L.dividedToIntegerBy=L.idiv=function(e,t){return y(this,new V(e,t),0,1)},L.exponentiatedBy=L.pow=function(e,t){var o,u,f,c,l,a,h,p,g=this;if((e=new V(e)).c&&!e.isInteger())throw Error(i+"Exponent not an integer: "+$(e));if(null!=t&&(t=new V(t)),l=e.e>14,!g.c||!g.c[0]||1==g.c[0]&&!g.e&&1==g.c.length||!e.c||!e.c[0])return p=new V(Math.pow(+$(g),l?2-N(e):+$(e))),t?p.mod(t):p;if(a=e.s<0,t){if(t.c?!t.c[0]:!t.s)return new V(NaN);(u=!a&&g.isInteger()&&t.isInteger())&&(g=g.mod(t))}else{if(e.e>9&&(g.e>0||g.e<-1||(0==g.e?g.c[0]>1||l&&g.c[1]>=24e7:g.c[0]<8e13||l&&g.c[0]<=9999975e7)))return c=g.s<0&&N(e)?-0:0,g.e>-1&&(c=1/c),new V(a?1/c:c);G&&(c=n(G/s+2))}for(l?(o=new V(.5),a&&(e.s=1),h=N(e)):h=(f=Math.abs(+$(e)))%2,p=new V(B);;){if(h){if(!(p=p.times(g)).c)break;c?p.c.length>c&&(p.c.length=c):u&&(p=p.mod(t))}if(f){if(0===(f=r(f/2)))break;h=f%2}else if(z(e=e.times(o),e.e+1,1),e.e>14)h=N(e);else{if(0==(f=+$(e)))break;h=f%2}g=g.times(g),c?g.c&&g.c.length>c&&(g.c.length=c):u&&(g=g.mod(t))}return u?p:(a&&(p=B.div(p)),t?p.mod(t):c?z(p,G,F,void 0):p)},L.integerValue=function(e){var t=new V(this);return null==e?e=F:m(e,0,8),z(t,t.e+1,e)},L.isEqualTo=L.eq=function(e,t){return 0===g(this,new V(e,t))},L.isFinite=function(){return!!this.c},L.isGreaterThan=L.gt=function(e,t){return g(this,new V(e,t))>0},L.isGreaterThanOrEqualTo=L.gte=function(e,t){return 1===(t=g(this,new V(e,t)))||0===t},L.isInteger=function(){return!!this.c&&h(this.e/s)>this.c.length-2},L.isLessThan=L.lt=function(e,t){return g(this,new V(e,t))<0},L.isLessThanOrEqualTo=L.lte=function(e,t){return-1===(t=g(this,new V(e,t)))||0===t},L.isNaN=function(){return!this.s},L.isNegative=function(){return this.s<0},L.isPositive=function(){return this.s>0},L.isZero=function(){return!!this.c&&0==this.c[0]},L.minus=function(e,t){var n,r,i,o,f=this,c=f.s;if(t=(e=new V(e,t)).s,!c||!t)return new V(NaN);if(c!=t)return e.s=-t,f.plus(e);var l=f.e/s,a=e.e/s,p=f.c,g=e.c;if(!l||!a){if(!p||!g)return p?(e.s=-t,e):new V(g?f:NaN);if(!p[0]||!g[0])return g[0]?(e.s=-t,e):new V(p[0]?f:3==F?-0:0)}if(l=h(l),a=h(a),p=p.slice(),c=l-a){for((o=c<0)?(c=-c,i=p):(a=l,i=g),i.reverse(),t=c;t--;i.push(0));i.reverse()}else for(r=(o=(c=p.length)<(t=g.length))?c:t,c=t=0;t<r;t++)if(p[t]!=g[t]){o=p[t]<g[t];break}if(o&&(i=p,p=g,g=i,e.s=-e.s),(t=(r=g.length)-(n=p.length))>0)for(;t--;p[n++]=0);for(t=u-1;r>c;){if(p[--r]<g[r]){for(n=r;n&&!p[--n];p[n]=t);--p[n],p[r]+=u}p[r]-=g[r]}for(;0==p[0];p.splice(0,1),--a);return p[0]?k(e,p,a):(e.s=3==F?-1:1,e.c=[e.e=0],e)},L.modulo=L.mod=function(e,t){var n,r,i=this;return e=new V(e,t),!i.c||!e.s||e.c&&!e.c[0]?new V(NaN):!e.c||i.c&&!i.c[0]?new V(i):(9==C?(r=e.s,e.s=1,n=y(i,e,0,3),e.s=r,n.s*=r):n=y(i,e,0,C),(e=i.minus(n.times(e))).c[0]||1!=C||(e.s=i.s),e)},L.multipliedBy=L.times=function(e,t){var n,r,i,o,f,c,a,p,g,m,N,b,d,w,y,O=this,v=O.c,E=(e=new V(e,t)).c;if(!(v&&E&&v[0]&&E[0]))return!O.s||!e.s||v&&!v[0]&&!E||E&&!E[0]&&!v?e.c=e.e=e.s=null:(e.s*=O.s,v&&E?(e.c=[0],e.e=0):e.c=e.e=null),e;for(r=h(O.e/s)+h(e.e/s),e.s*=O.s,(a=v.length)<(m=E.length)&&(d=v,v=E,E=d,i=a,a=m,m=i),i=a+m,d=[];i--;d.push(0));for(w=u,y=l,i=m;--i>=0;){for(n=0,N=E[i]%y,b=E[i]/y|0,o=i+(f=a);o>i;)n=((p=N*(p=v[--f]%y)+(c=b*p+(g=v[f]/y|0)*N)%y*y+d[o]+n)/w|0)+(c/y|0)+b*g,d[o--]=p%w;d[o]=n}return n?++r:d.splice(0,1),k(e,d,r)},L.negated=function(){var e=new V(this);return e.s=-e.s||null,e},L.plus=function(e,t){var n,r=this,i=r.s;if(t=(e=new V(e,t)).s,!i||!t)return new V(NaN);if(i!=t)return e.s=-t,r.minus(e);var o=r.e/s,f=e.e/s,c=r.c,l=e.c;if(!o||!f){if(!c||!l)return new V(i/0);if(!c[0]||!l[0])return l[0]?e:new V(c[0]?r:0*i)}if(o=h(o),f=h(f),c=c.slice(),i=o-f){for(i>0?(f=o,n=l):(i=-i,n=c),n.reverse();i--;n.push(0));n.reverse()}for((i=c.length)-(t=l.length)<0&&(n=l,l=c,c=n,t=i),i=0;t;)i=(c[--t]=c[t]+l[t]+i)/u|0,c[t]=u===c[t]?0:c[t]%u;return i&&(c=[i].concat(c),++f),k(e,c,f)},L.precision=L.sd=function(e,t){var n,r,i,o=this;if(null!=e&&e!==!!e)return m(e,1,a),null==t?t=F:m(t,0,8),z(new V(o),e,t);if(!(n=o.c))return null;if(r=(i=n.length-1)*s+1,i=n[i]){for(;i%10==0;i/=10,r--);for(i=n[0];i>=10;i/=10,r++);}return e&&o.e+1>r&&(r=o.e+1),r},L.shiftedBy=function(e){return m(e,-f,f),this.times("1e"+e)},L.squareRoot=L.sqrt=function(){var e,t,n,r,i,o=this,u=o.c,s=o.s,f=o.e,c=S+4,l=new V("0.5");if(1!==s||!u||!u[0])return new V(!s||s<0&&(!u||u[0])?NaN:u?o:1/0);if(0==(s=Math.sqrt(+$(o)))||s==1/0?(((t=p(u)).length+f)%2==0&&(t+="0"),s=Math.sqrt(+t),f=h((f+1)/2)-(f<0||f%2),n=new V(t=s==1/0?"1e"+f:(t=s.toExponential()).slice(0,t.indexOf("e")+1)+f)):n=new V(s+""),n.c[0])for((s=(f=n.e)+c)<3&&(s=0);;)if(i=n,n=l.times(i.plus(y(o,i,c,1))),p(i.c).slice(0,s)===(t=p(n.c)).slice(0,s)){if(n.e<f&&--s,"9999"!=(t=t.slice(s-3,s+1))&&(r||"4999"!=t)){+t&&(+t.slice(1)||"5"!=t.charAt(0))||(z(n,n.e+S+2,1),e=!n.times(n).eq(o));break}if(!r&&(z(i,i.e+S+2,0),i.times(i).eq(o))){n=i;break}c+=4,s+=4,r=1}return z(n,n.e+S+1,F,e)},L.toExponential=function(e,t){return null!=e&&(m(e,0,a),e++),q(this,e,t,1)},L.toFixed=function(e,t){return null!=e&&(m(e,0,a),e=e+this.e+1),q(this,e,t)},L.toFormat=function(e,t,n){var r,o=this;if(null==n)null!=e&&t&&"object"==typeof t?(n=t,t=null):e&&"object"==typeof e?(n=e,e=t=null):n=j;else if("object"!=typeof n)throw Error(i+"Argument not an object: "+n);if(r=o.toFixed(e,t),o.c){var u,s=r.split("."),f=+n.groupSize,c=+n.secondaryGroupSize,l=n.groupSeparator||"",a=s[0],h=s[1],p=o.s<0,g=p?a.slice(1):a,m=g.length;if(c&&(u=f,f=c,c=u,m-=u),f>0&&m>0){for(u=m%f||f,a=g.substr(0,u);u<m;u+=f)a+=l+g.substr(u,f);c>0&&(a+=l+g.slice(u)),p&&(a="-"+a)}r=h?a+(n.decimalSeparator||"")+((c=+n.fractionGroupSize)?h.replace(new RegExp("\\d{"+c+"}\\B","g"),"$&"+(n.fractionGroupSeparator||"")):h):a}return(n.prefix||"")+r+(n.suffix||"")},L.toFraction=function(e){var t,n,r,o,u,f,l,a,h,g,m,N,b=this,d=b.c;if(null!=e&&(!(l=new V(e)).isInteger()&&(l.c||1!==l.s)||l.lt(B)))throw Error(i+"Argument "+(l.isInteger()?"out of range: ":"not an integer: ")+$(l));if(!d)return new V(b);for(t=new V(B),h=n=new V(B),r=a=new V(B),N=p(d),u=t.e=N.length-b.e-1,t.c[0]=c[(f=u%s)<0?s+f:f],e=!e||l.comparedTo(t)>0?u>0?t:h:l,f=P,P=1/0,l=new V(N),a.c[0]=0;g=y(l,t,0,1),1!=(o=n.plus(g.times(r))).comparedTo(e);)n=r,r=o,h=a.plus(g.times(o=h)),a=o,t=l.minus(g.times(o=t)),l=o;return o=y(e.minus(n),r,0,1),a=a.plus(o.times(h)),n=n.plus(o.times(r)),a.s=h.s=b.s,m=y(h,r,u*=2,F).minus(b).abs().comparedTo(y(a,n,u,F).minus(b).abs())<1?[h,r]:[a,n],P=f,m},L.toNumber=function(){return+$(this)},L.toPrecision=function(e,t){return null!=e&&m(e,1,a),q(this,e,t,2)},L.toString=function(e){var t,n=this,r=n.s,i=n.e;return null===i?r?(t="Infinity",r<0&&(t="-"+t)):t="NaN":(null==e?t=i<=I||i>=M?b(p(n.c),i):d(p(n.c),i,"0"):10===e?t=d(p((n=z(new V(n),S+i+1,F)).c),n.e,"0"):(m(e,2,H.length,"Base"),t=O(d(p(n.c),i,"0"),10,e,r,!0)),r<0&&n.c[0]&&(t="-"+t)),t},L.valueOf=L.toJSON=function(){return $(this)},L._isBigNumber=!0,L[Symbol.toStringTag]="BigNumber",L[Symbol.for("nodejs.util.inspect.custom")]=L.valueOf,null!=w&&V.set(w),V}(),y=function(){return(y=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)},O=function(){function e(){this.format=e.DEFAULT_FORMAT,w.config({FORMAT:this.format})}return e.prototype.set=function(e){"FORMAT"in e&&(this.format=y({},this.format,e.FORMAT),e.FORMAT=this.format),w.config(e)},e.DEFAULT_FORMAT={prefix:"",decimalSeparator:".",groupSeparator:",",groupSize:3,secondaryGroupSize:0,fractionGroupSeparator:" ",fractionGroupSize:0,suffix:""},e}();e.BigNumber=function(){function e(t){"object"==typeof t&&e.isBigNumber(t)?this.bn=t.bn.plus(0):this.bn=e.toBigNumberJs(t)}return e.prototype.clone=function(){return new e(this)},e.prototype.add=function(t){return new e(this.bn.plus(e.toBigNumberJs(t)))},e.prototype.sub=function(t){return new e(this.bn.minus(e.toBigNumberJs(t)))},e.prototype.mul=function(t){return new e(this.bn.times(e.toBigNumberJs(t)))},e.prototype.div=function(t){return new e(this.bn.div(e.toBigNumberJs(t)))},e.prototype.pow=function(t){return new e(this.bn.pow(e.toBigNumberJs(t)))},e.prototype.abs=function(){return new e(this.bn.abs())},e.prototype.mod=function(t){return new e(this.bn.mod(e.toBigNumberJs(t)))},e.prototype.roundTo=function(t,n){return void 0===t&&(t=0),void 0===n&&(n=4),new e(this.bn.dp(t||0,n))},e.prototype.eq=function(t){return this.bn.eq(e.toBigNumberJs(t))},e.prototype.lt=function(t){return this.bn.lt(e.toBigNumberJs(t))},e.prototype.gt=function(t){return this.bn.gt(e.toBigNumberJs(t))},e.prototype.lte=function(t){return this.bn.lte(e.toBigNumberJs(t))},e.prototype.gte=function(t){return this.bn.gte(e.toBigNumberJs(t))},e.prototype.isNaN=function(){return this.bn.isNaN()},e.prototype.isFinite=function(){return this.bn.isFinite()},e.prototype.isZero=function(){return this.eq(0)},e.prototype.isPositive=function(){return this.gt(0)},e.prototype.isNegative=function(){return this.lt(0)},e.prototype.isInt=function(){return this.bn.isInteger()},e.prototype.getDecimalsCount=function(){return this.bn.dp()},e.prototype.isEven=function(){return this.mod(2).eq(0)},e.prototype.isOdd=function(){return!this.isEven()},e.prototype.isInSignedRange=function(){return this.gte(e.MIN_VALUE)&&this.lte(e.MAX_VALUE)},e.prototype.isInUnsignedRange=function(){return this.gte(e.MIN_UNSIGNED_VALUE)&&this.lte(e.MAX_UNSIGNED_VALUE)},e.prototype.toFormat=function(e,t,n){return this.bn.toFormat(e,t,n)},e.prototype.toFixed=function(e,t){return null==e?this.bn.toFixed():this.bn.toFixed(e,t)},e.prototype.toString=function(){return this.toFixed()},e.prototype.toNumber=function(){return this.bn.toNumber()},e.prototype.toJSON=function(){return this.bn.toFixed()},e.prototype.valueOf=function(){return this.bn.valueOf()},e.prototype.toBytes=function(t){var n=void 0===t?{}:t,r=n.isSigned,i=void 0===r||r,o=n.isLong,u=void 0===o||o;if(!this.isInt())throw new Error("Cant create bytes from number with decimals!");if(!i&&this.isNegative())throw new Error("Cant create bytes from negative number in signed mode!");if(u&&i&&!this.isInSignedRange())throw new Error("Number is not from signed numbers range");if(u&&!i&&!this.isInUnsignedRange())throw new Error("Number is not from unsigned numbers range");var s=i&&this.isNegative(),f=s?"1":"0",c=this.bn.plus(f).toString(2).replace("-",""),l=u?64:8*Math.ceil(c.length/8),a=e._toLength(l,c).split(""),h=[];do{h.push(parseInt(a.splice(0,8).join(""),2))}while(a.length);return s?Uint8Array.from(h.map(function(e){return 255-e})):Uint8Array.from(h)},e.fromBytes=function(t,n){var r=void 0===n?{}:n,i=r.isSigned,o=void 0===i||i,u=r.isLong,s=void 0===u||u;if(s&&8!==t.length)throw new Error("Wrong bytes length! Minimal length is 8 byte!");t=!s&&t.length>0||s?t:[0];var f=!!o&&t[0]>127,c=Array.from(t).map(function(e){return f?255-e:e}).map(function(t){return e._toLength(8,t.toString(2))}).join(""),l=new e(new w(c,2));return f?l.mul(-1).sub(1):l},e.max=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return e.toBigNumber(t).reduce(function(e,t){return e.gte(t)?e:t})},e.min=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return e.toBigNumber(t).reduce(function(e,t){return e.lte(t)?e:t})},e.sum=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return e.toBigNumber(t).reduce(function(e,t){return e.add(t)})},e.isBigNumber=function(t){return t&&"object"==typeof t&&(t instanceof e||Object.entries(e.prototype).filter(function(e){return"_"!==e[0].charAt(0)}).every(function(e){var n=e[0],r=e[1];return n in t&&typeof r==typeof t[n]}))},e.toBigNumber=function(t){return Array.isArray(t)?t.map(function(t){return new e(t)}):new e(t)},e.toBigNumberJs=function(t){return w.isBigNumber(t)?t:t instanceof e?t.bn:new w(t)},e._toLength=function(e,t){return new Array(e).fill("0",0,e).concat(t.split("")).slice(-e).join("")},e.MIN_VALUE=new e("-9223372036854775808"),e.MAX_VALUE=new e("9223372036854775807"),e.MIN_UNSIGNED_VALUE=new e("0"),e.MAX_UNSIGNED_VALUE=new e("18446744073709551615"),e.config=new O,e}(),function(e){!function(e){e[e.ROUND_UP=0]="ROUND_UP",e[e.ROUND_DOWN=1]="ROUND_DOWN",e[e.ROUND_CEIL=2]="ROUND_CEIL",e[e.ROUND_FLOOR=3]="ROUND_FLOOR",e[e.ROUND_HALF_UP=4]="ROUND_HALF_UP",e[e.ROUND_HALF_DOWN=5]="ROUND_HALF_DOWN",e[e.ROUND_HALF_EVEN=6]="ROUND_HALF_EVEN",e[e.ROUND_HALF_CEIL=7]="ROUND_HALF_CEIL",e[e.ROUND_HALF_FLOOR=8]="ROUND_HALF_FLOOR"}(e.ROUND_MODE||(e.ROUND_MODE={}))}(e.BigNumber||(e.BigNumber={}));var v=e.BigNumber;e.default=v,Object.defineProperty(e,"__esModule",{value:!0})}); |
{ | ||
"name": "@waves/bignumber", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Waves Library for work with Bignumber in javascript", | ||
@@ -30,3 +30,2 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"@types/bignumber.js": "^5.0.0", | ||
"bignumber.js": "^8.1.1" | ||
@@ -33,0 +32,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
158700
1
3085
1
- Removed@types/bignumber.js@^5.0.0
- Removed@types/bignumber.js@5.0.4(transitive)