Loading
function(t){!function(e){"use strict";var r,n={precision:20,rounding:4,toExpNeg:-7,toExpPos:21,LN10:"2.302585092994045684017991454684364207601101488628772976033327900967572609677352480235997205089598298341967784042286"},i=!0,o="[DecimalError] ",s=o+"Invalid argument: ",u=o+"Exponent out of range: ",c=Math.floor,f=Math.pow,h=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,l=c(1286742750677284.5),a={};function d(t,e){var r,n,o,s,u,c,f,h,l=t.constructor,a=l.precision;if(!t.s||!e.s)return e.s||(e=new l(t)),i?x(e,a):e;if(f=t.d,h=e.d,u=t.e,o=e.e,f=f.slice(),s=u-o){for(s<0?(n=f,s=-s,c=h.length):(n=h,o=u,c=f.length),s>(c=(u=Math.ceil(a/7))>c?u+1:c+1)&&(s=c,n.length=1),n.reverse();s--;)n.push(0);n.reverse()}for((c=f.length)-(s=h.length)<0&&(s=c,n=h,h=f,f=n),r=0;s;)r=(f[--s]=f[s]+h[s]+r)/1e7|0,f[s]%=1e7;for(r&&(f.unshift(r),++o),c=f.length;0==f[--c];)f.pop();return e.d=f,e.e=o,i?x(e,a):e}function p(t,e,r){if(t!==~~t||t<e||t>r)throw Error(s+t)}function g(t){var e,r,n,i=t.length-1,o="",s=t[0];if(i>0){for(o+=s,e=1;e<i;e++)(r=7-(n=t[e]+"").length)&&(o+=b(r)),o+=n;(r=7-(n=(s=t[e])+"").length)&&(o+=b(r))}else if(0===s)return"0";for(;s%10==0;)s/=10;return o+s}a.absoluteValue=a.abs=function(){var t=new this.constructor(this);return t.s&&(t.s=1),t},a.comparedTo=a.cmp=function(t){var e,r,n,i;if(t=new this.constructor(t),this.s!==t.s)return this.s||-t.s;if(this.e!==t.e)return this.e>t.e^this.s<0?1:-1;for(e=0,r=(n=this.d.length)<(i=t.d.length)?n:i;e<r;++e)if(this.d[e]!==t.d[e])return this.d[e]>t.d[e]^this.s<0?1:-1;return n===i?0:n>i^this.s<0?1:-1},a.decimalPlaces=a.dp=function(){var t=this.d.length-1,e=(t-this.e)*7;if(t=this.d[t])for(;t%10==0;t/=10)e--;return e<0?0:e},a.dividedBy=a.div=function(t){return v(this,new this.constructor(t))},a.dividedToIntegerBy=a.idiv=function(t){var e=this.constructor;return x(v(this,new e(t),0,1),e.precision)},a.equals=a.eq=function(t){return!this.cmp(t)},a.exponent=function(){return m(this)},a.greaterThan=a.gt=function(t){return this.cmp(t)>0},a.greaterThanOrEqualTo=a.gte=function(t){return this.cmp(t)>=0},a.isInteger=a.isint=function(){return this.e>this.d.length-2},a.isNegative=a.isneg=function(){return this.s<0},a.isPositive=a.ispos=function(){return this.s>0},a.isZero=function(){return 0===this.s},a.lessThan=a.lt=function(t){return 0>this.cmp(t)},a.lessThanOrEqualTo=a.lte=function(t){return 1>this.cmp(t)},a.logarithm=a.log=function(t){var e,n=this.constructor,s=n.precision,u=s+5;if(void 0===t)t=new n(10);else if((t=new n(t)).s<1||t.eq(r))throw Error(o+"NaN");if(this.s<1)throw Error(o+(this.s?"NaN":"-Infinity"));return this.eq(r)?new n(0):(i=!1,e=v(N(this,u),N(t,u),u),i=!0,x(e,s))},a.minus=a.sub=function(t){return t=new this.constructor(t),this.s==t.s?S(this,t):d(this,(t.s=-t.s,t))},a.modulo=a.mod=function(t){var e,r=this.constructor,n=r.precision;if(!(t=new r(t)).s)throw Error(o+"NaN");return this.s?(i=!1,e=v(this,t,0,1).times(t),i=!0,this.minus(e)):x(new r(this),n)},a.naturalExponential=a.exp=function(){return w(this)},a.naturalLogarithm=a.ln=function(){return N(this)},a.negated=a.neg=function(){var t=new this.constructor(this);return t.s=-t.s||0,t},a.plus=a.add=function(t){return t=new this.constructor(t),this.s==t.s?d(this,t):S(this,(t.s=-t.s,t))},a.precision=a.sd=function(t){var e,r,n;if(void 0!==t&&!!t!==t&&1!==t&&0!==t)throw Error(s+t);if(e=m(this)+1,r=7*(n=this.d.length-1)+1,n=this.d[n]){for(;n%10==0;n/=10)r--;for(n=this.d[0];n>=10;n/=10)r++}return t&&e>r?e:r},a.squareRoot=a.sqrt=function(){var t,e,r,n,s,u,f,h=this.constructor;if(this.s<1){if(!this.s)return new h(0);throw Error(o+"NaN")}for(t=m(this),i=!1,0==(s=Math.sqrt(+this))||s==1/0?(((e=g(this.d)).length+t)%2==0&&(e+="0"),s=Math.sqrt(e),t=c((t+1)/2)-(t<0||t%2),n=new h(e=s==1/0?"1e"+t:(e=s.toExponential()).slice(0,e.indexOf("e")+1)+t)):n=new h(s.toString()),s=f=(r=h.precision)+3;;)if(n=(u=n).plus(v(this,u,f+2)).times(.5),g(u.d).slice(0,f)===(e=g(n.d)).slice(0,f)){if(e=e.slice(f-3,f+1),s==f&&"4999"==e){if(x(u,r+1,0),u.times(u).eq(this)){n=u;break}}else if("9999"!=e)break;f+=4}return i=!0,x(n,r)},a.times=a.mul=function(t){var e,r,n,o,s,u,c,f,h,l=this.constructor,a=this.d,d=(t=new l(t)).d;if(!this.s||!t.s)return new l(0);for(t.s*=this.s,r=this.e+t.e,(f=a.length)<(h=d.length)&&(s=a,a=d,d=s,u=f,f=h,h=u),s=[],n=u=f+h;n--;)s.push(0);for(n=h;--n>=0;){for(e=0,o=f+n;o>n;)c=s[o]+d[n]*a[o-n-1]+e,s[o--]=c%1e7|0,e=c/1e7|0;s[o]=(s[o]+e)%1e7|0}for(;!s[--u];)s.pop();return e?++r:s.shift(),t.d=s,t.e=r,i?x(t,l.precision):t},a.toDecimalPlaces=a.todp=function(t,e){var r=this,n=r.constructor;return(r=new n(r),void 0===t)?r:(p(t,0,1e9),void 0===e?e=n.rounding:p(e,0,8),x(r,t+m(r)+1,e))},a.toExponential=function(t,e){var r,n=this,i=n.constructor;return void 0===t?r=O(n,!0):(p(t,0,1e9),void 0===e?e=i.rounding:p(e,0,8),r=O(n=x(new i(n),t+1,e),!0,t+1)),r},a.toFixed=function(t,e){var r,n,i=this.constructor;return void 0===t?O(this):(p(t,0,1e9),void 0===e?e=i.rounding:p(e,0,8),r=O((n=x(new i(this),t+m(this)+1,e)).abs(),!1,t+m(n)+1),this.isneg()&&!this.isZero()?"-"+r:r)},a.toInteger=a.toint=function(){var t=this.constructor;return x(new t(this),m(this)+1,t.rounding)},a.toNumber=function(){return+this},a.toPower=a.pow=function(t){var e,n,s,u,f,h,l=this,a=l.constructor,d=+(t=new a(t));if(!t.s)return new a(r);if(!(l=new a(l)).s){if(t.s<1)throw Error(o+"Infinity");return l}if(l.eq(r))return l;if(s=a.precision,t.eq(r))return x(l,s);if(h=(e=t.e)>=(n=t.d.length-1),f=l.s,h){if((n=d<0?-d:d)<=0x1fffffffffffff){for(u=new a(r),e=Math.ceil(s/7+4),i=!1;n%2&&L((u=u.times(l)).d,e),0!==(n=c(n/2));)L((l=l.times(l)).d,e);return i=!0,t.s<0?new a(r).div(u):x(u,s)}}else if(f<0)throw Error(o+"NaN");return f=f<0&&1&t.d[Math.max(e,n)]?-1:1,l.s=1,i=!1,u=t.times(N(l,s+12)),i=!0,(u=w(u)).s=f,u},a.toPrecision=function(t,e){var r,n,i=this,o=i.constructor;return void 0===t?(r=m(i),n=O(i,r<=o.toExpNeg||r>=o.toExpPos)):(p(t,1,1e9),void 0===e?e=o.rounding:p(e,0,8),r=m(i=x(new o(i),t,e)),n=O(i,t<=r||r<=o.toExpNeg,t)),n},a.toSignificantDigits=a.tosd=function(t,e){var r=this.constructor;return void 0===t?(t=r.precision,e=r.rounding):(p(t,1,1e9),void 0===e?e=r.rounding:p(e,0,8)),x(new r(this),t,e)},a.toString=a.valueOf=a.val=a.toJSON=function(){var t=m(this),e=this.constructor;return O(this,t<=e.toExpNeg||t>=e.toExpPos)};var v=function(){function t(t,e){var r,n=0,i=t.length;for(t=t.slice();i--;)r=t[i]*e+n,t[i]=r%1e7|0,n=r/1e7|0;return n&&t.unshift(n),t}function e(t,e,r,n){var i,o;if(r!=n)o=r>n?1:-1;else for(i=o=0;i<r;i++)if(t[i]!=e[i]){o=t[i]>e[i]?1:-1;break}return o}function r(t,e,r){for(var n=0;r--;)t[r]-=n,n=+(t[r]<e[r]),t[r]=1e7*n+t[r]-e[r];for(;!t[0]&&t.length>1;)t.shift()}return function(n,i,s,u){var c,f,h,l,a,d,p,g,v,w,E,b,N,y,S,O,L,j,_=n.constructor,D=n.s==i.s?1:-1,q=n.d,P=i.d;if(!n.s)return new _(n);if(!i.s)throw Error(o+"Division by zero");for(h=0,f=n.e-i.e,L=P.length,S=q.length,g=(p=new _(D)).d=[];P[h]==(q[h]||0);)++h;if(P[h]>(q[h]||0)&&--f,(b=null==s?s=_.precision:u?s+(m(n)-m(i))+1:s)<0)return new _(0);if(b=b/7+2|0,h=0,1==L)for(l=0,P=P[0],b++;(h<S||l)&&b--;h++)N=1e7*l+(q[h]||0),g[h]=N/P|0,l=N%P|0;else{for((l=1e7/(P[0]+1)|0)>1&&(P=t(P,l),q=t(q,l),L=P.length,S=q.length),y=L,w=(v=q.slice(0,L)).length;w<L;)v[w++]=0;(j=P.slice()).unshift(0),O=P[0],P[1]>=1e7/2&&++O;do l=0,(c=e(P,v,L,w))<0?(E=v[0],L!=w&&(E=1e7*E+(v[1]||0)),(l=E/O|0)>1?(l>=1e7&&(l=1e7-1),d=(a=t(P,l)).length,w=v.length,1==(c=e(a,v,d,w))&&(l--,r(a,L<d?j:P,d))):(0==l&&(c=l=1),a=P.slice()),(d=a.length)<w&&a.unshift(0),r(v,a,w),-1==c&&(w=v.length,(c=e(P,v,L,w))<1&&(l++,r(v,L<w?j:P,w))),w=v.length):0===c&&(l++,v=[0]),g[h++]=l,c&&v[0]?v[w++]=q[y]||0:(v=[q[y]],w=1);while((y++<S||void 0!==v[0])&&b--)}return g[0]||g.shift(),p.e=f,x(p,u?s+m(p)+1:s)}}();function w(t,e){var n,o,s,c,h,l=0,a=0,d=t.constructor,p=d.precision;if(m(t)>16)throw Error(u+m(t));if(!t.s)return new d(r);for(null==e?(i=!1,h=p):h=e,c=new d(.03125);t.abs().gte(.1);)t=t.times(c),a+=5;for(h+=Math.log(f(2,a))/Math.LN10*2+5|0,n=o=s=new d(r),d.precision=h;;){if(o=x(o.times(t),h),n=n.times(++l),g((c=s.plus(v(o,n,h))).d).slice(0,h)===g(s.d).slice(0,h)){for(;a--;)s=x(s.times(s),h);return d.precision=p,null==e?(i=!0,x(s,p)):s}s=c}}function m(t){for(var e=7*t.e,r=t.d[0];r>=10;r/=10)e++;return e}function E(t,e,r){if(e>t.LN10.sd())throw i=!0,r&&(t.precision=r),Error(o+"LN10 precision limit exceeded");return x(new t(t.LN10),e)}function b(t){for(var e="";t--;)e+="0";return e}function N(t,e){var n,s,u,c,f,h,l,a,d,p=1,w=t,b=w.d,y=w.constructor,S=y.precision;if(w.s<1)throw Error(o+(w.s?"NaN":"-Infinity"));if(w.eq(r))return new y(0);if(null==e?(i=!1,a=S):a=e,w.eq(10))return null==e&&(i=!0),E(y,a);if(y.precision=a+=10,s=(n=g(b)).charAt(0),!(15e14>Math.abs(c=m(w))))return l=E(y,a+2,S).times(c+""),w=N(new y(s+"."+n.slice(1)),a-10).plus(l),y.precision=S,null==e?(i=!0,x(w,S)):w;for(;s<7&&1!=s||1==s&&n.charAt(1)>3;)s=(n=g((w=w.times(t)).d)).charAt(0),p++;for(c=m(w),s>1?(w=new y("0."+n),c++):w=new y(s+"."+n.slice(1)),h=f=w=v(w.minus(r),w.plus(r),a),d=x(w.times(w),a),u=3;;){if(f=x(f.times(d),a),g((l=h.plus(v(f,new y(u),a))).d).slice(0,a)===g(h.d).slice(0,a))return h=h.times(2),0!==c&&(h=h.plus(E(y,a+2,S).times(c+""))),h=v(h,new y(p),a),y.precision=S,null==e?(i=!0,x(h,S)):h;h=l,u+=2}}function y(t,e){var r,n,o;for((r=e.indexOf("."))>-1&&(e=e.replace(".","")),(n=e.search(/e/i))>0?(r<0&&(r=n),r+=+e.slice(n+1),e=e.substring(0,n)):r<0&&(r=e.length),n=0;48===e.charCodeAt(n);)++n;for(o=e.length;48===e.charCodeAt(o-1);)--o;if(e=e.slice(n,o)){if(o-=n,t.e=c((r=r-n-1)/7),t.d=[],n=(r+1)%7,r<0&&(n+=7),n<o){for(n&&t.d.push(+e.slice(0,n)),o-=7;n<o;)t.d.push(+e.slice(n,n+=7));n=7-(e=e.slice(n)).length}else n-=o;for(;n--;)e+="0";if(t.d.push(+e),i&&(t.e>l||t.e<-l))throw Error(u+r)}else t.s=0,t.e=0,t.d=[0];return t}function x(t,e,r){var n,o,s,h,a,d,p,g,v=t.d;for(h=1,s=v[0];s>=10;s/=10)h++;if((n=e-h)<0)n+=7,o=e,p=v[g=0];else{if((g=Math.ceil((n+1)/7))>=(s=v.length))return t;for(h=1,p=s=v[g];s>=10;s/=10)h++;n%=7,o=n-7+h}if(void 0!==r&&(a=p/(s=f(10,h-o-1))%10|0,d=e<0||void 0!==v[g+1]||p%s,d=r<4?(a||d)&&(0==r||r==(t.s<0?3:2)):a>5||5==a&&(4==r||d||6==r&&(n>0?o>0?p/f(10,h-o):0:v[g-1])%10&1||r==(t.s<0?8:7))),e<1||!v[0])return d?(s=m(t),v.length=1,e=e-s-1,v[0]=f(10,(7-e%7)%7),t.e=c(-e/7)||0):(v.length=1,v[0]=t.e=t.s=0),t;if(0==n?(v.length=g,s=1,g--):(v.length=g+1,s=f(10,7-n),v[g]=o>0?(p/f(10,h-o)%f(10,o)|0)*s:0),d)for(;;)if(0==g){1e7==(v[0]+=s)&&(v[0]=1,++t.e);break}else{if(v[g]+=s,1e7!=v[g])break;v[g--]=0,s=1}for(n=v.length;0===v[--n];)v.pop();if(i&&(t.e>l||t.e<-l))throw Error(u+m(t));return t}function S(t,e){var r,n,o,s,u,c,f,h,l,a,d=t.constructor,p=d.precision;if(!t.s||!e.s)return e.s?e.s=-e.s:e=new d(t),i?x(e,p):e;if(f=t.d,a=e.d,n=e.e,h=t.e,f=f.slice(),u=h-n){for((l=u<0)?(r=f,u=-u,c=a.length):(r=a,n=h,c=f.length),u>(o=Math.max(Math.ceil(p/7),c)+2)&&(u=o,r.length=1),r.reverse(),o=u;o--;)r.push(0);r.reverse()}else{for((l=(o=f.length)<(c=a.length))&&(c=o),o=0;o<c;o++)if(f[o]!=a[o]){l=f[o]<a[o];break}u=0}for(l&&(r=f,f=a,a=r,e.s=-e.s),c=f.length,o=a.length-c;o>0;--o)f[c++]=0;for(o=a.length;o>u;){if(f[--o]<a[o]){for(s=o;s&&0===f[--s];)f[s]=1e7-1;--f[s],f[o]+=1e7}f[o]-=a[o]}for(;0===f[--c];)f.pop();for(;0===f[0];f.shift())--n;return f[0]?(e.d=f,e.e=n,i?x(e,p):e):new d(0)}function O(t,e,r){var n,i=m(t),o=g(t.d),s=o.length;return e?(r&&(n=r-s)>0?o=o.charAt(0)+"."+o.slice(1)+b(n):s>1&&(o=o.charAt(0)+"."+o.slice(1)),o=o+(i<0?"e":"e+")+i):i<0?(o="0."+b(-i-1)+o,r&&(n=r-s)>0&&(o+=b(n))):i>=s?(o+=b(i+1-s),r&&(n=r-i-1)>0&&(o=o+"."+b(n))):((n=i+1)<s&&(o=o.slice(0,n)+"."+o.slice(n)),r&&(n=r-s)>0&&(i+1===s&&(o+="."),o+=b(n))),t.s<0?"-"+o:o}function L(t,e){if(t.length>e)return t.length=e,!0}function j(t){if(!t||"object"!=typeof t)throw Error(o+"Object expected");var e,r,n,i=["precision",1,1e9,"rounding",0,8,"toExpNeg",-1/0,0,"toExpPos",0,1/0];for(e=0;e<i.length;e+=3)if(void 0!==(n=t[r=i[e]]))if(c(n)===n&&n>=i[e+1]&&n<=i[e+2])this[r]=n;else throw Error(s+r+": "+n);if(void 0!==(n=t[r="LN10"]))if(n==Math.LN10)this[r]=new this(n);else throw Error(s+r+": "+n);return this}(n=function t(e){var r,n,i;function o(t){if(!(this instanceof o))return new o(t);if(this.constructor=o,t instanceof o){this.s=t.s,this.e=t.e,this.d=(t=t.d)?t.slice():t;return}if("number"==typeof t){if(0*t!=0)throw Error(s+t);if(t>0)this.s=1;else if(t<0)t=-t,this.s=-1;else{this.s=0,this.e=0,this.d=[0];return}if(t===~~t&&t<1e7){this.e=0,this.d=[t];return}return y(this,t.toString())}if("string"!=typeof t)throw Error(s+t);if(45===t.charCodeAt(0)?(t=t.slice(1),this.s=-1):this.s=1,h.test(t))y(this,t);else throw Error(s+t)}if(o.prototype=a,o.ROUND_UP=0,o.ROUND_DOWN=1,o.ROUND_CEIL=2,o.ROUND_FLOOR=3,o.ROUND_HALF_UP=4,o.ROUND_HALF_DOWN=5,o.ROUND_HALF_EVEN=6,o.ROUND_HALF_CEIL=7,o.ROUND_HALF_FLOOR=8,o.clone=t,o.config=o.set=j,void 0===e&&(e={}),e)for(r=0,i=["precision","rounding","toExpNeg","toExpPos","LN10"];r<i.length;)e.hasOwnProperty(n=i[r++])||(e[n]=this[n]);return o.config(e),o}(n)).default=n.Decimal=n,r=new n(1),"function"==typeof define&&define.amd?define(function(){return n}):t.exports?t.exports=n:(e||(e="u">typeof self&&self&&self.self==self?self:Function("return this")()),e.Decimal=n)}(this)}