lyb-js 1.4.0 → 1.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Math/LibJsCalculateExpression.js +1 -1
- package/Math/LibJsDecimal.js +1 -1
- package/libJs.d.ts +14 -0
- package/libJs.js +17 -1
- package/lyb.js +3698 -8
- package/package.json +1 -1
package/lyb.js
CHANGED
|
@@ -1,8 +1,3698 @@
|
|
|
1
|
-
(function(
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
*/var fe=9e15,ie=1e9,_e="0123456789abcdef",ve="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",$e="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",Oe={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-fe,maxE:fe,crypto:!1},Ae,te,_=!0,Me="[DecimalError] ",re=Me+"Invalid argument: ",Fe=Me+"Precision limit exceeded",Pe=Me+"crypto unavailable",Je="[object Decimal]",W=Math.floor,Y=Math.pow,vt=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,$t=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,Mt=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,Re=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,K=1e7,k=7,bt=9007199254740991,Nt=ve.length-1,Te=$e.length-1,d={toStringTag:Je};d.absoluteValue=d.abs=function(){var e=new this.constructor(this);return e.s<0&&(e.s=1),S(e)},d.ceil=function(){return S(new this.constructor(this),this.e+1,2)},d.clampedTo=d.clamp=function(e,t){var n,i=this,r=i.constructor;if(e=new r(e),t=new r(t),!e.s||!t.s)return new r(NaN);if(e.gt(t))throw Error(re+t);return n=i.cmp(e),n<0?e:i.cmp(t)>0?t:new r(i)},d.comparedTo=d.cmp=function(e){var t,n,i,r,s=this,o=s.d,u=(e=new s.constructor(e)).d,a=s.s,c=e.s;if(!o||!u)return!a||!c?NaN:a!==c?a:o===u?0:!o^a<0?1:-1;if(!o[0]||!u[0])return o[0]?a:u[0]?-c:0;if(a!==c)return a;if(s.e!==e.e)return s.e>e.e^a<0?1:-1;for(i=o.length,r=u.length,t=0,n=i<r?i:r;t<n;++t)if(o[t]!==u[t])return o[t]>u[t]^a<0?1:-1;return i===r?0:i>r^a<0?1:-1},d.cosine=d.cos=function(){var e,t,n=this,i=n.constructor;return n.d?n.d[0]?(e=i.precision,t=i.rounding,i.precision=e+Math.max(n.e,n.sd())+k,i.rounding=1,n=St(i,Ze(i,n)),i.precision=e,i.rounding=t,S(te==2||te==3?n.neg():n,e,t,!0)):new i(1):new i(NaN)},d.cubeRoot=d.cbrt=function(){var e,t,n,i,r,s,o,u,a,c,f=this,l=f.constructor;if(!f.isFinite()||f.isZero())return new l(f);for(_=!1,s=f.s*Y(f.s*f,1/3),!s||Math.abs(s)==1/0?(n=j(f.d),e=f.e,(s=(e-n.length+1)%3)&&(n+=s==1||s==-2?"0":"00"),s=Y(n,1/3),e=W((e+1)/3)-(e%3==(e<0?-1:2)),s==1/0?n="5e"+e:(n=s.toExponential(),n=n.slice(0,n.indexOf("e")+1)+e),i=new l(n),i.s=f.s):i=new l(s.toString()),o=(e=l.precision)+3;;)if(u=i,a=u.times(u).times(u),c=a.plus(f),i=P(c.plus(f).times(u),c.plus(a),o+2,1),j(u.d).slice(0,o)===(n=j(i.d)).slice(0,o))if(n=n.slice(o-3,o+1),n=="9999"||!r&&n=="4999"){if(!r&&(S(u,e+1,0),u.times(u).times(u).eq(f))){i=u;break}o+=4,r=1}else{(!+n||!+n.slice(1)&&n.charAt(0)=="5")&&(S(i,e+1,1),t=!i.times(i).times(i).eq(f));break}return _=!0,S(i,e,l.rounding,t)},d.decimalPlaces=d.dp=function(){var e,t=this.d,n=NaN;if(t){if(e=t.length-1,n=(e-W(this.e/k))*k,e=t[e],e)for(;e%10==0;e/=10)n--;n<0&&(n=0)}return n},d.dividedBy=d.div=function(e){return P(this,new this.constructor(e))},d.dividedToIntegerBy=d.divToInt=function(e){var t=this,n=t.constructor;return S(P(t,new n(e),0,1,1),n.precision,n.rounding)},d.equals=d.eq=function(e){return this.cmp(e)===0},d.floor=function(){return S(new this.constructor(this),this.e+1,3)},d.greaterThan=d.gt=function(e){return this.cmp(e)>0},d.greaterThanOrEqualTo=d.gte=function(e){var t=this.cmp(e);return t==1||t===0},d.hyperbolicCosine=d.cosh=function(){var e,t,n,i,r,s=this,o=s.constructor,u=new o(1);if(!s.isFinite())return new o(s.s?1/0:NaN);if(s.isZero())return u;n=o.precision,i=o.rounding,o.precision=n+Math.max(s.e,s.sd())+4,o.rounding=1,r=s.d.length,r<32?(e=Math.ceil(r/3),t=(1/De(4,e)).toString()):(e=16,t="2.3283064365386962890625e-10"),s=le(o,1,s.times(t),new o(1),!0);for(var a,c=e,f=new o(8);c--;)a=s.times(s),s=u.minus(a.times(f.minus(a.times(f))));return S(s,o.precision=n,o.rounding=i,!0)},d.hyperbolicSine=d.sinh=function(){var e,t,n,i,r=this,s=r.constructor;if(!r.isFinite()||r.isZero())return new s(r);if(t=s.precision,n=s.rounding,s.precision=t+Math.max(r.e,r.sd())+4,s.rounding=1,i=r.d.length,i<3)r=le(s,2,r,r,!0);else{e=1.4*Math.sqrt(i),e=e>16?16:e|0,r=r.times(1/De(5,e)),r=le(s,2,r,r,!0);for(var o,u=new s(5),a=new s(16),c=new s(20);e--;)o=r.times(r),r=r.times(u.plus(o.times(a.times(o).plus(c))))}return s.precision=t,s.rounding=n,S(r,t,n,!0)},d.hyperbolicTangent=d.tanh=function(){var e,t,n=this,i=n.constructor;return n.isFinite()?n.isZero()?new i(n):(e=i.precision,t=i.rounding,i.precision=e+7,i.rounding=1,P(n.sinh(),n.cosh(),i.precision=e,i.rounding=t)):new i(n.s)},d.inverseCosine=d.acos=function(){var e,t=this,n=t.constructor,i=t.abs().cmp(1),r=n.precision,s=n.rounding;return i!==-1?i===0?t.isNeg()?Q(n,r,s):new n(0):new n(NaN):t.isZero()?Q(n,r+4,s).times(.5):(n.precision=r+6,n.rounding=1,t=t.asin(),e=Q(n,r+4,s).times(.5),n.precision=r,n.rounding=s,e.minus(t))},d.inverseHyperbolicCosine=d.acosh=function(){var e,t,n=this,i=n.constructor;return n.lte(1)?new i(n.eq(1)?0:NaN):n.isFinite()?(e=i.precision,t=i.rounding,i.precision=e+Math.max(Math.abs(n.e),n.sd())+4,i.rounding=1,_=!1,n=n.times(n).minus(1).sqrt().plus(n),_=!0,i.precision=e,i.rounding=t,n.ln()):new i(n)},d.inverseHyperbolicSine=d.asinh=function(){var e,t,n=this,i=n.constructor;return!n.isFinite()||n.isZero()?new i(n):(e=i.precision,t=i.rounding,i.precision=e+2*Math.max(Math.abs(n.e),n.sd())+6,i.rounding=1,_=!1,n=n.times(n).plus(1).sqrt().plus(n),_=!0,i.precision=e,i.rounding=t,n.ln())},d.inverseHyperbolicTangent=d.atanh=function(){var e,t,n,i,r=this,s=r.constructor;return r.isFinite()?r.e>=0?new s(r.abs().eq(1)?r.s/0:r.isZero()?r:NaN):(e=s.precision,t=s.rounding,i=r.sd(),Math.max(i,e)<2*-r.e-1?S(new s(r),e,t,!0):(s.precision=n=i-r.e,r=P(r.plus(1),new s(1).minus(r),n+e,1),s.precision=e+4,s.rounding=1,r=r.ln(),s.precision=e,s.rounding=t,r.times(.5))):new s(NaN)},d.inverseSine=d.asin=function(){var e,t,n,i,r=this,s=r.constructor;return r.isZero()?new s(r):(t=r.abs().cmp(1),n=s.precision,i=s.rounding,t!==-1?t===0?(e=Q(s,n+4,i).times(.5),e.s=r.s,e):new s(NaN):(s.precision=n+6,s.rounding=1,r=r.div(new s(1).minus(r.times(r)).sqrt().plus(1)).atan(),s.precision=n,s.rounding=i,r.times(2)))},d.inverseTangent=d.atan=function(){var e,t,n,i,r,s,o,u,a,c=this,f=c.constructor,l=f.precision,h=f.rounding;if(c.isFinite()){if(c.isZero())return new f(c);if(c.abs().eq(1)&&l+4<=Te)return o=Q(f,l+4,h).times(.25),o.s=c.s,o}else{if(!c.s)return new f(NaN);if(l+4<=Te)return o=Q(f,l+4,h).times(.5),o.s=c.s,o}for(f.precision=u=l+10,f.rounding=1,n=Math.min(28,u/k+2|0),e=n;e;--e)c=c.div(c.times(c).plus(1).sqrt().plus(1));for(_=!1,t=Math.ceil(u/k),i=1,a=c.times(c),o=new f(c),r=c;e!==-1;)if(r=r.times(a),s=o.minus(r.div(i+=2)),r=r.times(a),o=s.plus(r.div(i+=2)),o.d[t]!==void 0)for(e=t;o.d[e]===s.d[e]&&e--;);return n&&(o=o.times(2<<n-1)),_=!0,S(o,f.precision=l,f.rounding=h,!0)},d.isFinite=function(){return!!this.d},d.isInteger=d.isInt=function(){return!!this.d&&W(this.e/k)>this.d.length-2},d.isNaN=function(){return!this.s},d.isNegative=d.isNeg=function(){return this.s<0},d.isPositive=d.isPos=function(){return this.s>0},d.isZero=function(){return!!this.d&&this.d[0]===0},d.lessThan=d.lt=function(e){return this.cmp(e)<0},d.lessThanOrEqualTo=d.lte=function(e){return this.cmp(e)<1},d.logarithm=d.log=function(e){var t,n,i,r,s,o,u,a,c=this,f=c.constructor,l=f.precision,h=f.rounding,p=5;if(e==null)e=new f(10),t=!0;else{if(e=new f(e),n=e.d,e.s<0||!n||!n[0]||e.eq(1))return new f(NaN);t=e.eq(10)}if(n=c.d,c.s<0||!n||!n[0]||c.eq(1))return new f(n&&!n[0]?-1/0:c.s!=1?NaN:n?0:1/0);if(t)if(n.length>1)s=!0;else{for(r=n[0];r%10===0;)r/=10;s=r!==1}if(_=!1,u=l+p,o=oe(c,u),i=t?Se(f,u+10):oe(e,u),a=P(o,i,u,1),de(a.d,r=l,h))do if(u+=10,o=oe(c,u),i=t?Se(f,u+10):oe(e,u),a=P(o,i,u,1),!s){+j(a.d).slice(r+1,r+15)+1==1e14&&(a=S(a,l+1,0));break}while(de(a.d,r+=10,h));return _=!0,S(a,l,h)},d.minus=d.sub=function(e){var t,n,i,r,s,o,u,a,c,f,l,h,p=this,w=p.constructor;if(e=new w(e),!p.d||!e.d)return!p.s||!e.s?e=new w(NaN):p.d?e.s=-e.s:e=new w(e.d||p.s!==e.s?p:NaN),e;if(p.s!=e.s)return e.s=-e.s,p.plus(e);if(c=p.d,h=e.d,u=w.precision,a=w.rounding,!c[0]||!h[0]){if(h[0])e.s=-e.s;else if(c[0])e=new w(p);else return new w(a===3?-0:0);return _?S(e,u,a):e}if(n=W(e.e/k),f=W(p.e/k),c=c.slice(),s=f-n,s){for(l=s<0,l?(t=c,s=-s,o=h.length):(t=h,n=f,o=c.length),i=Math.max(Math.ceil(u/k),o)+2,s>i&&(s=i,t.length=1),t.reverse(),i=s;i--;)t.push(0);t.reverse()}else{for(i=c.length,o=h.length,l=i<o,l&&(o=i),i=0;i<o;i++)if(c[i]!=h[i]){l=c[i]<h[i];break}s=0}for(l&&(t=c,c=h,h=t,e.s=-e.s),o=c.length,i=h.length-o;i>0;--i)c[o++]=0;for(i=h.length;i>s;){if(c[--i]<h[i]){for(r=i;r&&c[--r]===0;)c[r]=K-1;--c[r],c[i]+=K}c[i]-=h[i]}for(;c[--o]===0;)c.pop();for(;c[0]===0;c.shift())--n;return c[0]?(e.d=c,e.e=Ne(c,n),_?S(e,u,a):e):new w(a===3?-0:0)},d.modulo=d.mod=function(e){var t,n=this,i=n.constructor;return e=new i(e),!n.d||!e.s||e.d&&!e.d[0]?new i(NaN):!e.d||n.d&&!n.d[0]?S(new i(n),i.precision,i.rounding):(_=!1,i.modulo==9?(t=P(n,e.abs(),0,3,1),t.s*=e.s):t=P(n,e,0,i.modulo,1),t=t.times(e),_=!0,n.minus(t))},d.naturalExponential=d.exp=function(){return ye(this)},d.naturalLogarithm=d.ln=function(){return oe(this)},d.negated=d.neg=function(){var e=new this.constructor(this);return e.s=-e.s,S(e)},d.plus=d.add=function(e){var t,n,i,r,s,o,u,a,c,f,l=this,h=l.constructor;if(e=new h(e),!l.d||!e.d)return!l.s||!e.s?e=new h(NaN):l.d||(e=new h(e.d||l.s===e.s?l:NaN)),e;if(l.s!=e.s)return e.s=-e.s,l.minus(e);if(c=l.d,f=e.d,u=h.precision,a=h.rounding,!c[0]||!f[0])return f[0]||(e=new h(l)),_?S(e,u,a):e;if(s=W(l.e/k),i=W(e.e/k),c=c.slice(),r=s-i,r){for(r<0?(n=c,r=-r,o=f.length):(n=f,i=s,o=c.length),s=Math.ceil(u/k),o=s>o?s+1:o+1,r>o&&(r=o,n.length=1),n.reverse();r--;)n.push(0);n.reverse()}for(o=c.length,r=f.length,o-r<0&&(r=o,n=f,f=c,c=n),t=0;r;)t=(c[--r]=c[r]+f[r]+t)/K|0,c[r]%=K;for(t&&(c.unshift(t),++i),o=c.length;c[--o]==0;)c.pop();return e.d=c,e.e=Ne(c,i),_?S(e,u,a):e},d.precision=d.sd=function(e){var t,n=this;if(e!==void 0&&e!==!!e&&e!==1&&e!==0)throw Error(re+e);return n.d?(t=qe(n.d),e&&n.e+1>t&&(t=n.e+1)):t=NaN,t},d.round=function(){var e=this,t=e.constructor;return S(new t(e),e.e+1,t.rounding)},d.sine=d.sin=function(){var e,t,n=this,i=n.constructor;return n.isFinite()?n.isZero()?new i(n):(e=i.precision,t=i.rounding,i.precision=e+Math.max(n.e,n.sd())+k,i.rounding=1,n=Et(i,Ze(i,n)),i.precision=e,i.rounding=t,S(te>2?n.neg():n,e,t,!0)):new i(NaN)},d.squareRoot=d.sqrt=function(){var e,t,n,i,r,s,o=this,u=o.d,a=o.e,c=o.s,f=o.constructor;if(c!==1||!u||!u[0])return new f(!c||c<0&&(!u||u[0])?NaN:u?o:1/0);for(_=!1,c=Math.sqrt(+o),c==0||c==1/0?(t=j(u),(t.length+a)%2==0&&(t+="0"),c=Math.sqrt(t),a=W((a+1)/2)-(a<0||a%2),c==1/0?t="5e"+a:(t=c.toExponential(),t=t.slice(0,t.indexOf("e")+1)+a),i=new f(t)):i=new f(c.toString()),n=(a=f.precision)+3;;)if(s=i,i=s.plus(P(o,s,n+2,1)).times(.5),j(s.d).slice(0,n)===(t=j(i.d)).slice(0,n))if(t=t.slice(n-3,n+1),t=="9999"||!r&&t=="4999"){if(!r&&(S(s,a+1,0),s.times(s).eq(o))){i=s;break}n+=4,r=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(S(i,a+1,1),e=!i.times(i).eq(o));break}return _=!0,S(i,a,f.rounding,e)},d.tangent=d.tan=function(){var e,t,n=this,i=n.constructor;return n.isFinite()?n.isZero()?new i(n):(e=i.precision,t=i.rounding,i.precision=e+10,i.rounding=1,n=n.sin(),n.s=1,n=P(n,new i(1).minus(n.times(n)).sqrt(),e+10,0),i.precision=e,i.rounding=t,S(te==2||te==4?n.neg():n,e,t,!0)):new i(NaN)},d.times=d.mul=function(e){var t,n,i,r,s,o,u,a,c,f=this,l=f.constructor,h=f.d,p=(e=new l(e)).d;if(e.s*=f.s,!h||!h[0]||!p||!p[0])return new l(!e.s||h&&!h[0]&&!p||p&&!p[0]&&!h?NaN:!h||!p?e.s/0:e.s*0);for(n=W(f.e/k)+W(e.e/k),a=h.length,c=p.length,a<c&&(s=h,h=p,p=s,o=a,a=c,c=o),s=[],o=a+c,i=o;i--;)s.push(0);for(i=c;--i>=0;){for(t=0,r=a+i;r>i;)u=s[r]+p[i]*h[r-i-1]+t,s[r--]=u%K|0,t=u/K|0;s[r]=(s[r]+t)%K|0}for(;!s[--o];)s.pop();return t?++n:s.shift(),e.d=s,e.e=Ne(s,n),_?S(e,l.precision,l.rounding):e},d.toBinary=function(e,t){return Le(this,2,e,t)},d.toDecimalPlaces=d.toDP=function(e,t){var n=this,i=n.constructor;return n=new i(n),e===void 0?n:(z(e,0,ie),t===void 0?t=i.rounding:z(t,0,8),S(n,e+n.e+1,t))},d.toExponential=function(e,t){var n,i=this,r=i.constructor;return e===void 0?n=ee(i,!0):(z(e,0,ie),t===void 0?t=r.rounding:z(t,0,8),i=S(new r(i),e+1,t),n=ee(i,!0,e+1)),i.isNeg()&&!i.isZero()?"-"+n:n},d.toFixed=function(e,t){var n,i,r=this,s=r.constructor;return e===void 0?n=ee(r):(z(e,0,ie),t===void 0?t=s.rounding:z(t,0,8),i=S(new s(r),e+r.e+1,t),n=ee(i,!1,e+i.e+1)),r.isNeg()&&!r.isZero()?"-"+n:n},d.toFraction=function(e){var t,n,i,r,s,o,u,a,c,f,l,h,p=this,w=p.d,M=p.constructor;if(!w)return new M(p);if(c=n=new M(1),i=a=new M(0),t=new M(i),s=t.e=qe(w)-p.e-1,o=s%k,t.d[0]=Y(10,o<0?k+o:o),e==null)e=s>0?t:c;else{if(u=new M(e),!u.isInt()||u.lt(c))throw Error(re+u);e=u.gt(t)?s>0?t:c:u}for(_=!1,u=new M(j(w)),f=M.precision,M.precision=s=w.length*k*2;l=P(u,t,0,1,1),r=n.plus(l.times(i)),r.cmp(e)!=1;)n=i,i=r,r=c,c=a.plus(l.times(r)),a=r,r=t,t=u.minus(l.times(r)),u=r;return r=P(e.minus(n),i,0,1,1),a=a.plus(r.times(c)),n=n.plus(r.times(i)),a.s=c.s=p.s,h=P(c,i,s,1).minus(p).abs().cmp(P(a,n,s,1).minus(p).abs())<1?[c,i]:[a,n],M.precision=f,_=!0,h},d.toHexadecimal=d.toHex=function(e,t){return Le(this,16,e,t)},d.toNearest=function(e,t){var n=this,i=n.constructor;if(n=new i(n),e==null){if(!n.d)return n;e=new i(1),t=i.rounding}else{if(e=new i(e),t===void 0?t=i.rounding:z(t,0,8),!n.d)return e.s?n:e;if(!e.d)return e.s&&(e.s=n.s),e}return e.d[0]?(_=!1,n=P(n,e,0,t,1).times(e),_=!0,S(n)):(e.s=n.s,n=e),n},d.toNumber=function(){return+this},d.toOctal=function(e,t){return Le(this,8,e,t)},d.toPower=d.pow=function(e){var t,n,i,r,s,o,u=this,a=u.constructor,c=+(e=new a(e));if(!u.d||!e.d||!u.d[0]||!e.d[0])return new a(Y(+u,c));if(u=new a(u),u.eq(1))return u;if(i=a.precision,s=a.rounding,e.eq(1))return S(u,i,s);if(t=W(e.e/k),t>=e.d.length-1&&(n=c<0?-c:c)<=bt)return r=Ue(a,u,n,i),e.s<0?new a(1).div(r):S(r,i,s);if(o=u.s,o<0){if(t<e.d.length-1)return new a(NaN);if(e.d[t]&1||(o=1),u.e==0&&u.d[0]==1&&u.d.length==1)return u.s=o,u}return n=Y(+u,c),t=n==0||!isFinite(n)?W(c*(Math.log("0."+j(u.d))/Math.LN10+u.e+1)):new a(n+"").e,t>a.maxE+1||t<a.minE-1?new a(t>0?o/0:0):(_=!1,a.rounding=u.s=1,n=Math.min(12,(t+"").length),r=ye(e.times(oe(u,i+n)),i),r.d&&(r=S(r,i+5,1),de(r.d,i,s)&&(t=i+10,r=S(ye(e.times(oe(u,t+n)),t),t+5,1),+j(r.d).slice(i+1,i+15)+1==1e14&&(r=S(r,i+1,0)))),r.s=o,_=!0,a.rounding=s,S(r,i,s))},d.toPrecision=function(e,t){var n,i=this,r=i.constructor;return e===void 0?n=ee(i,i.e<=r.toExpNeg||i.e>=r.toExpPos):(z(e,1,ie),t===void 0?t=r.rounding:z(t,0,8),i=S(new r(i),e,t),n=ee(i,e<=i.e||i.e<=r.toExpNeg,e)),i.isNeg()&&!i.isZero()?"-"+n:n},d.toSignificantDigits=d.toSD=function(e,t){var n=this,i=n.constructor;return e===void 0?(e=i.precision,t=i.rounding):(z(e,1,ie),t===void 0?t=i.rounding:z(t,0,8)),S(new i(n),e,t)},d.toString=function(){var e=this,t=e.constructor,n=ee(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()&&!e.isZero()?"-"+n:n},d.truncated=d.trunc=function(){return S(new this.constructor(this),this.e+1,1)},d.valueOf=d.toJSON=function(){var e=this,t=e.constructor,n=ee(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()?"-"+n:n};function j(e){var t,n,i,r=e.length-1,s="",o=e[0];if(r>0){for(s+=o,t=1;t<r;t++)i=e[t]+"",n=k-i.length,n&&(s+=se(n)),s+=i;o=e[t],i=o+"",n=k-i.length,n&&(s+=se(n))}else if(o===0)return"0";for(;o%10===0;)o/=10;return s+o}function z(e,t,n){if(e!==~~e||e<t||e>n)throw Error(re+e)}function de(e,t,n,i){var r,s,o,u;for(s=e[0];s>=10;s/=10)--t;return--t<0?(t+=k,r=0):(r=Math.ceil((t+1)/k),t%=k),s=Y(10,k-t),u=e[r]%s|0,i==null?t<3?(t==0?u=u/100|0:t==1&&(u=u/10|0),o=n<4&&u==99999||n>3&&u==49999||u==5e4||u==0):o=(n<4&&u+1==s||n>3&&u+1==s/2)&&(e[r+1]/s/100|0)==Y(10,t-2)-1||(u==s/2||u==0)&&(e[r+1]/s/100|0)==0:t<4?(t==0?u=u/1e3|0:t==1?u=u/100|0:t==2&&(u=u/10|0),o=(i||n<4)&&u==9999||!i&&n>3&&u==4999):o=((i||n<4)&&u+1==s||!i&&n>3&&u+1==s/2)&&(e[r+1]/s/1e3|0)==Y(10,t-3)-1,o}function be(e,t,n){for(var i,r=[0],s,o=0,u=e.length;o<u;){for(s=r.length;s--;)r[s]*=t;for(r[0]+=_e.indexOf(e.charAt(o++)),i=0;i<r.length;i++)r[i]>n-1&&(r[i+1]===void 0&&(r[i+1]=0),r[i+1]+=r[i]/n|0,r[i]%=n)}return r.reverse()}function St(e,t){var n,i,r;if(t.isZero())return t;i=t.d.length,i<32?(n=Math.ceil(i/3),r=(1/De(4,n)).toString()):(n=16,r="2.3283064365386962890625e-10"),e.precision+=n,t=le(e,1,t.times(r),new e(1));for(var s=n;s--;){var o=t.times(t);t=o.times(o).minus(o).times(8).plus(1)}return e.precision-=n,t}var P=function(){function e(i,r,s){var o,u=0,a=i.length;for(i=i.slice();a--;)o=i[a]*r+u,i[a]=o%s|0,u=o/s|0;return u&&i.unshift(u),i}function t(i,r,s,o){var u,a;if(s!=o)a=s>o?1:-1;else for(u=a=0;u<s;u++)if(i[u]!=r[u]){a=i[u]>r[u]?1:-1;break}return a}function n(i,r,s,o){for(var u=0;s--;)i[s]-=u,u=i[s]<r[s]?1:0,i[s]=u*o+i[s]-r[s];for(;!i[0]&&i.length>1;)i.shift()}return function(i,r,s,o,u,a){var c,f,l,h,p,w,M,F,I,H,O,q,X,T,E,v,A,y,b,R,U=i.constructor,N=i.s==r.s?1:-1,g=i.d,m=r.d;if(!g||!g[0]||!m||!m[0])return new U(!i.s||!r.s||(g?m&&g[0]==m[0]:!m)?NaN:g&&g[0]==0||!m?N*0:N/0);for(a?(p=1,f=i.e-r.e):(a=K,p=k,f=W(i.e/p)-W(r.e/p)),b=m.length,A=g.length,I=new U(N),H=I.d=[],l=0;m[l]==(g[l]||0);l++);if(m[l]>(g[l]||0)&&f--,s==null?(T=s=U.precision,o=U.rounding):u?T=s+(i.e-r.e)+1:T=s,T<0)H.push(1),w=!0;else{if(T=T/p+2|0,l=0,b==1){for(h=0,m=m[0],T++;(l<A||h)&&T--;l++)E=h*a+(g[l]||0),H[l]=E/m|0,h=E%m|0;w=h||l<A}else{for(h=a/(m[0]+1)|0,h>1&&(m=e(m,h,a),g=e(g,h,a),b=m.length,A=g.length),v=b,O=g.slice(0,b),q=O.length;q<b;)O[q++]=0;R=m.slice(),R.unshift(0),y=m[0],m[1]>=a/2&&++y;do h=0,c=t(m,O,b,q),c<0?(X=O[0],b!=q&&(X=X*a+(O[1]||0)),h=X/y|0,h>1?(h>=a&&(h=a-1),M=e(m,h,a),F=M.length,q=O.length,c=t(M,O,F,q),c==1&&(h--,n(M,b<F?R:m,F,a))):(h==0&&(c=h=1),M=m.slice()),F=M.length,F<q&&M.unshift(0),n(O,M,q,a),c==-1&&(q=O.length,c=t(m,O,b,q),c<1&&(h++,n(O,b<q?R:m,q,a))),q=O.length):c===0&&(h++,O=[0]),H[l++]=h,c&&O[0]?O[q++]=g[v]||0:(O=[g[v]],q=1);while((v++<A||O[0]!==void 0)&&T--);w=O[0]!==void 0}H[0]||H.shift()}if(p==1)I.e=f,Ae=w;else{for(l=1,h=H[0];h>=10;h/=10)l++;I.e=l+f*p-1,S(I,u?s+I.e+1:s,o,w)}return I}}();function S(e,t,n,i){var r,s,o,u,a,c,f,l,h,p=e.constructor;e:if(t!=null){if(l=e.d,!l)return e;for(r=1,u=l[0];u>=10;u/=10)r++;if(s=t-r,s<0)s+=k,o=t,f=l[h=0],a=f/Y(10,r-o-1)%10|0;else if(h=Math.ceil((s+1)/k),u=l.length,h>=u)if(i){for(;u++<=h;)l.push(0);f=a=0,r=1,s%=k,o=s-k+1}else break e;else{for(f=u=l[h],r=1;u>=10;u/=10)r++;s%=k,o=s-k+r,a=o<0?0:f/Y(10,r-o-1)%10|0}if(i=i||t<0||l[h+1]!==void 0||(o<0?f:f%Y(10,r-o-1)),c=n<4?(a||i)&&(n==0||n==(e.s<0?3:2)):a>5||a==5&&(n==4||i||n==6&&(s>0?o>0?f/Y(10,r-o):0:l[h-1])%10&1||n==(e.s<0?8:7)),t<1||!l[0])return l.length=0,c?(t-=e.e+1,l[0]=Y(10,(k-t%k)%k),e.e=-t||0):l[0]=e.e=0,e;if(s==0?(l.length=h,u=1,h--):(l.length=h+1,u=Y(10,k-s),l[h]=o>0?(f/Y(10,r-o)%Y(10,o)|0)*u:0),c)for(;;)if(h==0){for(s=1,o=l[0];o>=10;o/=10)s++;for(o=l[0]+=u,u=1;o>=10;o/=10)u++;s!=u&&(e.e++,l[0]==K&&(l[0]=1));break}else{if(l[h]+=u,l[h]!=K)break;l[h--]=0,u=1}for(s=l.length;l[--s]===0;)l.pop()}return _&&(e.e>p.maxE?(e.d=null,e.e=NaN):e.e<p.minE&&(e.e=0,e.d=[0])),e}function ee(e,t,n){if(!e.isFinite())return Ye(e);var i,r=e.e,s=j(e.d),o=s.length;return t?(n&&(i=n-o)>0?s=s.charAt(0)+"."+s.slice(1)+se(i):o>1&&(s=s.charAt(0)+"."+s.slice(1)),s=s+(e.e<0?"e":"e+")+e.e):r<0?(s="0."+se(-r-1)+s,n&&(i=n-o)>0&&(s+=se(i))):r>=o?(s+=se(r+1-o),n&&(i=n-r-1)>0&&(s=s+"."+se(i))):((i=r+1)<o&&(s=s.slice(0,i)+"."+s.slice(i)),n&&(i=n-o)>0&&(r+1===o&&(s+="."),s+=se(i))),s}function Ne(e,t){var n=e[0];for(t*=k;n>=10;n/=10)t++;return t}function Se(e,t,n){if(t>Nt)throw _=!0,n&&(e.precision=n),Error(Fe);return S(new e(ve),t,1,!0)}function Q(e,t,n){if(t>Te)throw Error(Fe);return S(new e($e),t,n,!0)}function qe(e){var t=e.length-1,n=t*k+1;if(t=e[t],t){for(;t%10==0;t/=10)n--;for(t=e[0];t>=10;t/=10)n++}return n}function se(e){for(var t="";e--;)t+="0";return t}function Ue(e,t,n,i){var r,s=new e(1),o=Math.ceil(i/k+4);for(_=!1;;){if(n%2&&(s=s.times(t),je(s.d,o)&&(r=!0)),n=W(n/2),n===0){n=s.d.length-1,r&&s.d[n]===0&&++s.d[n];break}t=t.times(t),je(t.d,o)}return _=!0,s}function Be(e){return e.d[e.d.length-1]&1}function He(e,t,n){for(var i,r=new e(t[0]),s=0;++s<t.length;)if(i=new e(t[s]),i.s)r[n](i)&&(r=i);else{r=i;break}return r}function ye(e,t){var n,i,r,s,o,u,a,c=0,f=0,l=0,h=e.constructor,p=h.rounding,w=h.precision;if(!e.d||!e.d[0]||e.e>17)return new h(e.d?e.d[0]?e.s<0?0:1/0:1:e.s?e.s<0?0:e:0/0);for(t==null?(_=!1,a=w):a=t,u=new h(.03125);e.e>-2;)e=e.times(u),l+=5;for(i=Math.log(Y(2,l))/Math.LN10*2+5|0,a+=i,n=s=o=new h(1),h.precision=a;;){if(s=S(s.times(e),a,1),n=n.times(++f),u=o.plus(P(s,n,a,1)),j(u.d).slice(0,a)===j(o.d).slice(0,a)){for(r=l;r--;)o=S(o.times(o),a,1);if(t==null)if(c<3&&de(o.d,a-i,p,c))h.precision=a+=10,n=s=u=new h(1),f=0,c++;else return S(o,h.precision=w,p,_=!0);else return h.precision=w,o}o=u}}function oe(e,t){var n,i,r,s,o,u,a,c,f,l,h,p=1,w=10,M=e,F=M.d,I=M.constructor,H=I.rounding,O=I.precision;if(M.s<0||!F||!F[0]||!M.e&&F[0]==1&&F.length==1)return new I(F&&!F[0]?-1/0:M.s!=1?NaN:F?0:M);if(t==null?(_=!1,f=O):f=t,I.precision=f+=w,n=j(F),i=n.charAt(0),Math.abs(s=M.e)<15e14){for(;i<7&&i!=1||i==1&&n.charAt(1)>3;)M=M.times(e),n=j(M.d),i=n.charAt(0),p++;s=M.e,i>1?(M=new I("0."+n),s++):M=new I(i+"."+n.slice(1))}else return c=Se(I,f+2,O).times(s+""),M=oe(new I(i+"."+n.slice(1)),f-w).plus(c),I.precision=O,t==null?S(M,O,H,_=!0):M;for(l=M,a=o=M=P(M.minus(1),M.plus(1),f,1),h=S(M.times(M),f,1),r=3;;){if(o=S(o.times(h),f,1),c=a.plus(P(o,new I(r),f,1)),j(c.d).slice(0,f)===j(a.d).slice(0,f))if(a=a.times(2),s!==0&&(a=a.plus(Se(I,f+2,O).times(s+""))),a=P(a,new I(p),f,1),t==null)if(de(a.d,f-w,H,u))I.precision=f+=w,c=o=M=P(l.minus(1),l.plus(1),f,1),h=S(M.times(M),f,1),r=u=1;else return S(a,I.precision=O,H,_=!0);else return I.precision=O,a;a=c,r+=2}}function Ye(e){return String(e.s*e.s/0)}function Ce(e,t){var n,i,r;for((n=t.indexOf("."))>-1&&(t=t.replace(".","")),(i=t.search(/e/i))>0?(n<0&&(n=i),n+=+t.slice(i+1),t=t.substring(0,i)):n<0&&(n=t.length),i=0;t.charCodeAt(i)===48;i++);for(r=t.length;t.charCodeAt(r-1)===48;--r);if(t=t.slice(i,r),t){if(r-=i,e.e=n=n-i-1,e.d=[],i=(n+1)%k,n<0&&(i+=k),i<r){for(i&&e.d.push(+t.slice(0,i)),r-=k;i<r;)e.d.push(+t.slice(i,i+=k));t=t.slice(i),i=k-t.length}else i-=r;for(;i--;)t+="0";e.d.push(+t),_&&(e.e>e.constructor.maxE?(e.d=null,e.e=NaN):e.e<e.constructor.minE&&(e.e=0,e.d=[0]))}else e.e=0,e.d=[0];return e}function Dt(e,t){var n,i,r,s,o,u,a,c,f;if(t.indexOf("_")>-1){if(t=t.replace(/(\d)_(?=\d)/g,"$1"),Re.test(t))return Ce(e,t)}else if(t==="Infinity"||t==="NaN")return+t||(e.s=NaN),e.e=NaN,e.d=null,e;if($t.test(t))n=16,t=t.toLowerCase();else if(vt.test(t))n=2;else if(Mt.test(t))n=8;else throw Error(re+t);for(s=t.search(/p/i),s>0?(a=+t.slice(s+1),t=t.substring(2,s)):t=t.slice(2),s=t.indexOf("."),o=s>=0,i=e.constructor,o&&(t=t.replace(".",""),u=t.length,s=u-s,r=Ue(i,new i(n),s,s*2)),c=be(t,n,K),f=c.length-1,s=f;c[s]===0;--s)c.pop();return s<0?new i(e.s*0):(e.e=Ne(c,f),e.d=c,_=!1,o&&(e=P(e,r,u*4)),a&&(e=e.times(Math.abs(a)<54?Y(2,a):ne.pow(2,a))),_=!0,e)}function Et(e,t){var n,i=t.d.length;if(i<3)return t.isZero()?t:le(e,2,t,t);n=1.4*Math.sqrt(i),n=n>16?16:n|0,t=t.times(1/De(5,n)),t=le(e,2,t,t);for(var r,s=new e(5),o=new e(16),u=new e(20);n--;)r=t.times(t),t=t.times(s.plus(r.times(o.times(r).minus(u))));return t}function le(e,t,n,i,r){var s,o,u,a,c=e.precision,f=Math.ceil(c/k);for(_=!1,a=n.times(n),u=new e(i);;){if(o=P(u.times(a),new e(t++*t++),c,1),u=r?i.plus(o):i.minus(o),i=P(o.times(a),new e(t++*t++),c,1),o=u.plus(i),o.d[f]!==void 0){for(s=f;o.d[s]===u.d[s]&&s--;);if(s==-1)break}s=u,u=i,i=o,o=s}return _=!0,o.d.length=f+1,o}function De(e,t){for(var n=e;--t;)n*=e;return n}function Ze(e,t){var n,i=t.s<0,r=Q(e,e.precision,1),s=r.times(.5);if(t=t.abs(),t.lte(s))return te=i?4:1,t;if(n=t.divToInt(r),n.isZero())te=i?3:2;else{if(t=t.minus(n.times(r)),t.lte(s))return te=Be(n)?i?2:3:i?4:1,t;te=Be(n)?i?1:4:i?3:2}return t.minus(r).abs()}function Le(e,t,n,i){var r,s,o,u,a,c,f,l,h,p=e.constructor,w=n!==void 0;if(w?(z(n,1,ie),i===void 0?i=p.rounding:z(i,0,8)):(n=p.precision,i=p.rounding),!e.isFinite())f=Ye(e);else{for(f=ee(e),o=f.indexOf("."),w?(r=2,t==16?n=n*4-3:t==8&&(n=n*3-2)):r=t,o>=0&&(f=f.replace(".",""),h=new p(1),h.e=f.length-o,h.d=be(ee(h),10,r),h.e=h.d.length),l=be(f,10,r),s=a=l.length;l[--a]==0;)l.pop();if(!l[0])f=w?"0p+0":"0";else{if(o<0?s--:(e=new p(e),e.d=l,e.e=s,e=P(e,h,n,i,0,r),l=e.d,s=e.e,c=Ae),o=l[n],u=r/2,c=c||l[n+1]!==void 0,c=i<4?(o!==void 0||c)&&(i===0||i===(e.s<0?3:2)):o>u||o===u&&(i===4||c||i===6&&l[n-1]&1||i===(e.s<0?8:7)),l.length=n,c)for(;++l[--n]>r-1;)l[n]=0,n||(++s,l.unshift(1));for(a=l.length;!l[a-1];--a);for(o=0,f="";o<a;o++)f+=_e.charAt(l[o]);if(w){if(a>1)if(t==16||t==8){for(o=t==16?4:3,--a;a%o;a++)f+="0";for(l=be(f,r,t),a=l.length;!l[a-1];--a);for(o=1,f="1.";o<a;o++)f+=_e.charAt(l[o])}else f=f.charAt(0)+"."+f.slice(1);f=f+(s<0?"p":"p+")+s}else if(s<0){for(;++s;)f="0"+f;f="0."+f}else if(++s>a)for(s-=a;s--;)f+="0";else s<a&&(f=f.slice(0,s)+"."+f.slice(s))}f=(t==16?"0x":t==2?"0b":t==8?"0o":"")+f}return e.s<0?"-"+f:f}function je(e,t){if(e.length>t)return e.length=t,!0}function kt(e){return new this(e).abs()}function _t(e){return new this(e).acos()}function Ot(e){return new this(e).acosh()}function Tt(e,t){return new this(e).plus(t)}function yt(e){return new this(e).asin()}function Ct(e){return new this(e).asinh()}function Lt(e){return new this(e).atan()}function It(e){return new this(e).atanh()}function At(e,t){e=new this(e),t=new this(t);var n,i=this.precision,r=this.rounding,s=i+4;return!e.s||!t.s?n=new this(NaN):!e.d&&!t.d?(n=Q(this,s,1).times(t.s>0?.25:.75),n.s=e.s):!t.d||e.isZero()?(n=t.s<0?Q(this,i,r):new this(0),n.s=e.s):!e.d||t.isZero()?(n=Q(this,s,1).times(.5),n.s=e.s):t.s<0?(this.precision=s,this.rounding=1,n=this.atan(P(e,t,s,1)),t=Q(this,s,1),this.precision=i,this.rounding=r,n=e.s<0?n.minus(t):n.plus(t)):n=this.atan(P(e,t,s,1)),n}function Ft(e){return new this(e).cbrt()}function Pt(e){return S(e=new this(e),e.e+1,2)}function Jt(e,t,n){return new this(e).clamp(t,n)}function Rt(e){if(!e||typeof e!="object")throw Error(Me+"Object expected");var t,n,i,r=e.defaults===!0,s=["precision",1,ie,"rounding",0,8,"toExpNeg",-fe,0,"toExpPos",0,fe,"maxE",0,fe,"minE",-fe,0,"modulo",0,9];for(t=0;t<s.length;t+=3)if(n=s[t],r&&(this[n]=Oe[n]),(i=e[n])!==void 0)if(W(i)===i&&i>=s[t+1]&&i<=s[t+2])this[n]=i;else throw Error(re+n+": "+i);if(n="crypto",r&&(this[n]=Oe[n]),(i=e[n])!==void 0)if(i===!0||i===!1||i===0||i===1)if(i)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[n]=!0;else throw Error(Pe);else this[n]=!1;else throw Error(re+n+": "+i);return this}function qt(e){return new this(e).cos()}function Ut(e){return new this(e).cosh()}function We(e){var t,n,i;function r(s){var o,u,a,c=this;if(!(c instanceof r))return new r(s);if(c.constructor=r,Ve(s)){c.s=s.s,_?!s.d||s.e>r.maxE?(c.e=NaN,c.d=null):s.e<r.minE?(c.e=0,c.d=[0]):(c.e=s.e,c.d=s.d.slice()):(c.e=s.e,c.d=s.d?s.d.slice():s.d);return}if(a=typeof s,a==="number"){if(s===0){c.s=1/s<0?-1:1,c.e=0,c.d=[0];return}if(s<0?(s=-s,c.s=-1):c.s=1,s===~~s&&s<1e7){for(o=0,u=s;u>=10;u/=10)o++;_?o>r.maxE?(c.e=NaN,c.d=null):o<r.minE?(c.e=0,c.d=[0]):(c.e=o,c.d=[s]):(c.e=o,c.d=[s]);return}else if(s*0!==0){s||(c.s=NaN),c.e=NaN,c.d=null;return}return Ce(c,s.toString())}else if(a!=="string")throw Error(re+s);return(u=s.charCodeAt(0))===45?(s=s.slice(1),c.s=-1):(u===43&&(s=s.slice(1)),c.s=1),Re.test(s)?Ce(c,s):Dt(c,s)}if(r.prototype=d,r.ROUND_UP=0,r.ROUND_DOWN=1,r.ROUND_CEIL=2,r.ROUND_FLOOR=3,r.ROUND_HALF_UP=4,r.ROUND_HALF_DOWN=5,r.ROUND_HALF_EVEN=6,r.ROUND_HALF_CEIL=7,r.ROUND_HALF_FLOOR=8,r.EUCLID=9,r.config=r.set=Rt,r.clone=We,r.isDecimal=Ve,r.abs=kt,r.acos=_t,r.acosh=Ot,r.add=Tt,r.asin=yt,r.asinh=Ct,r.atan=Lt,r.atanh=It,r.atan2=At,r.cbrt=Ft,r.ceil=Pt,r.clamp=Jt,r.cos=qt,r.cosh=Ut,r.div=Bt,r.exp=Ht,r.floor=Yt,r.hypot=Zt,r.ln=jt,r.log=Wt,r.log10=zt,r.log2=Vt,r.max=Gt,r.min=Xt,r.mod=xt,r.mul=Kt,r.pow=Qt,r.random=en,r.round=tn,r.sign=nn,r.sin=rn,r.sinh=sn,r.sqrt=on,r.sub=un,r.sum=cn,r.tan=an,r.tanh=fn,r.trunc=ln,e===void 0&&(e={}),e&&e.defaults!==!0)for(i=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],t=0;t<i.length;)e.hasOwnProperty(n=i[t++])||(e[n]=this[n]);return r.config(e),r}function Bt(e,t){return new this(e).div(t)}function Ht(e){return new this(e).exp()}function Yt(e){return S(e=new this(e),e.e+1,3)}function Zt(){var e,t,n=new this(0);for(_=!1,e=0;e<arguments.length;)if(t=new this(arguments[e++]),t.d)n.d&&(n=n.plus(t.times(t)));else{if(t.s)return _=!0,new this(1/0);n=t}return _=!0,n.sqrt()}function Ve(e){return e instanceof ne||e&&e.toStringTag===Je||!1}function jt(e){return new this(e).ln()}function Wt(e,t){return new this(e).log(t)}function Vt(e){return new this(e).log(2)}function zt(e){return new this(e).log(10)}function Gt(){return He(this,arguments,"lt")}function Xt(){return He(this,arguments,"gt")}function xt(e,t){return new this(e).mod(t)}function Kt(e,t){return new this(e).mul(t)}function Qt(e,t){return new this(e).pow(t)}function en(e){var t,n,i,r,s=0,o=new this(1),u=[];if(e===void 0?e=this.precision:z(e,1,ie),i=Math.ceil(e/k),this.crypto)if(crypto.getRandomValues)for(t=crypto.getRandomValues(new Uint32Array(i));s<i;)r=t[s],r>=429e7?t[s]=crypto.getRandomValues(new Uint32Array(1))[0]:u[s++]=r%1e7;else if(crypto.randomBytes){for(t=crypto.randomBytes(i*=4);s<i;)r=t[s]+(t[s+1]<<8)+(t[s+2]<<16)+((t[s+3]&127)<<24),r>=214e7?crypto.randomBytes(4).copy(t,s):(u.push(r%1e7),s+=4);s=i/4}else throw Error(Pe);else for(;s<i;)u[s++]=Math.random()*1e7|0;for(i=u[--s],e%=k,i&&e&&(r=Y(10,k-e),u[s]=(i/r|0)*r);u[s]===0;s--)u.pop();if(s<0)n=0,u=[0];else{for(n=-1;u[0]===0;n-=k)u.shift();for(i=1,r=u[0];r>=10;r/=10)i++;i<k&&(n-=k-i)}return o.e=n,o.d=u,o}function tn(e){return S(e=new this(e),e.e+1,this.rounding)}function nn(e){return e=new this(e),e.d?e.d[0]?e.s:0*e.s:e.s||NaN}function rn(e){return new this(e).sin()}function sn(e){return new this(e).sinh()}function on(e){return new this(e).sqrt()}function un(e,t){return new this(e).sub(t)}function cn(){var e=0,t=arguments,n=new this(t[e]);for(_=!1;n.s&&++e<t.length;)n=n.plus(t[e]);return _=!0,S(n,this.precision,this.rounding)}function an(e){return new this(e).tan()}function fn(e){return new this(e).tanh()}function ln(e){return S(e=new this(e),e.e+1,1)}d[Symbol.for("nodejs.util.inspect.custom")]=d.toString,d[Symbol.toStringTag]="Decimal";var ne=d.constructor=We(Oe);ve=new ne(ve),$e=new ne($e);const hn=(e,t,n,i=2)=>{const s={"+":(o,u)=>o.add(u),"-":(o,u)=>o.sub(u),"*":(o,u)=>o.mul(u),"/":(o,u)=>{if(u.eq(0))throw new Error("除数不能为0");return o.div(u)}}[n](new ne(e),new ne(t));return Number(s.toFixed(i))},dn=(e,t)=>t.reduce((n,i)=>{const{key:r,verify:s,msg:o,name:u}=i,a=e[r];return a===""||a===void 0||a===null?n.push({key:r,msg:"必填项",name:u}):(typeof s=="function"?!s(a):!s.test(a))&&n.push({key:r,msg:o,name:u}),n},[]),mn=({promiseFn:e,maxRetries:t=3,retryDelay:n=2e3,params:i=void 0})=>new Promise((r,s)=>{let o=0;const u=()=>{e(i).then(a=>{r(a)}).catch(a=>{if(o++,o>=t){s(a);return}setTimeout(u,n)})};u()}),pn=e=>Math.random()*100<e,gn=(e,t,n=0)=>parseFloat((Math.random()*(t-e)+e).toFixed(n)),wn=(e=1)=>{const t=Math.floor(Math.random()*256),n=Math.floor(Math.random()*256),i=Math.floor(Math.random()*256);return`rgba(${t}, ${n}, ${i}, ${e})`},vn=(e,t,n)=>{const i=Array.from({length:t-e+1},(r,s)=>s+e);for(let r=i.length-1;r>0;r--){const s=Math.floor(Math.random()*(r+1));[i[r],i[s]]=[i[s],i[r]]}return i.slice(0,n)};var ze=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ge(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Xe={exports:{}};(function(e,t){(function(n,i){e.exports=i()})(ze,function(){var n=1e3,i=6e4,r=36e5,s="millisecond",o="second",u="minute",a="hour",c="day",f="week",l="month",h="quarter",p="year",w="date",M="Invalid Date",F=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,I=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,H={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(N){var g=["th","st","nd","rd"],m=N%100;return"["+N+(g[(m-20)%10]||g[m]||g[0])+"]"}},O=function(N,g,m){var D=String(N);return!D||D.length>=g?N:""+Array(g+1-D.length).join(m)+N},q={s:O,z:function(N){var g=-N.utcOffset(),m=Math.abs(g),D=Math.floor(m/60),$=m%60;return(g<=0?"+":"-")+O(D,2,"0")+":"+O($,2,"0")},m:function N(g,m){if(g.date()<m.date())return-N(m,g);var D=12*(m.year()-g.year())+(m.month()-g.month()),$=g.clone().add(D,l),C=m-$<0,L=g.clone().add(D+(C?-1:1),l);return+(-(D+(m-$)/(C?$-L:L-$))||0)},a:function(N){return N<0?Math.ceil(N)||0:Math.floor(N)},p:function(N){return{M:l,y:p,w:f,d:c,D:w,h:a,m:u,s:o,ms:s,Q:h}[N]||String(N||"").toLowerCase().replace(/s$/,"")},u:function(N){return N===void 0}},X="en",T={};T[X]=H;var E="$isDayjsObject",v=function(N){return N instanceof R||!(!N||!N[E])},A=function N(g,m,D){var $;if(!g)return X;if(typeof g=="string"){var C=g.toLowerCase();T[C]&&($=C),m&&(T[C]=m,$=C);var L=g.split("-");if(!$&&L.length>1)return N(L[0])}else{var J=g.name;T[J]=g,$=J}return!D&&$&&(X=$),$||!D&&X},y=function(N,g){if(v(N))return N.clone();var m=typeof g=="object"?g:{};return m.date=N,m.args=arguments,new R(m)},b=q;b.l=A,b.i=v,b.w=function(N,g){return y(N,{locale:g.$L,utc:g.$u,x:g.$x,$offset:g.$offset})};var R=function(){function N(m){this.$L=A(m.locale,null,!0),this.parse(m),this.$x=this.$x||m.x||{},this[E]=!0}var g=N.prototype;return g.parse=function(m){this.$d=function(D){var $=D.date,C=D.utc;if($===null)return new Date(NaN);if(b.u($))return new Date;if($ instanceof Date)return new Date($);if(typeof $=="string"&&!/Z$/i.test($)){var L=$.match(F);if(L){var J=L[2]-1||0,B=(L[7]||"0").substring(0,3);return C?new Date(Date.UTC(L[1],J,L[3]||1,L[4]||0,L[5]||0,L[6]||0,B)):new Date(L[1],J,L[3]||1,L[4]||0,L[5]||0,L[6]||0,B)}}return new Date($)}(m),this.init()},g.init=function(){var m=this.$d;this.$y=m.getFullYear(),this.$M=m.getMonth(),this.$D=m.getDate(),this.$W=m.getDay(),this.$H=m.getHours(),this.$m=m.getMinutes(),this.$s=m.getSeconds(),this.$ms=m.getMilliseconds()},g.$utils=function(){return b},g.isValid=function(){return this.$d.toString()!==M},g.isSame=function(m,D){var $=y(m);return this.startOf(D)<=$&&$<=this.endOf(D)},g.isAfter=function(m,D){return y(m)<this.startOf(D)},g.isBefore=function(m,D){return this.endOf(D)<y(m)},g.$g=function(m,D,$){return b.u(m)?this[D]:this.set($,m)},g.unix=function(){return Math.floor(this.valueOf()/1e3)},g.valueOf=function(){return this.$d.getTime()},g.startOf=function(m,D){var $=this,C=!!b.u(D)||D,L=b.p(m),J=function(ae,G){var ue=b.w($.$u?Date.UTC($.$y,G,ae):new Date($.$y,G,ae),$);return C?ue:ue.endOf(c)},B=function(ae,G){return b.w($.toDate()[ae].apply($.toDate("s"),(C?[0,0,0,0]:[23,59,59,999]).slice(G)),$)},Z=this.$W,V=this.$M,x=this.$D,he="set"+(this.$u?"UTC":"");switch(L){case p:return C?J(1,0):J(31,11);case l:return C?J(1,V):J(0,V+1);case f:var ce=this.$locale().weekStart||0,me=(Z<ce?Z+7:Z)-ce;return J(C?x-me:x+(6-me),V);case c:case w:return B(he+"Hours",0);case a:return B(he+"Minutes",1);case u:return B(he+"Seconds",2);case o:return B(he+"Milliseconds",3);default:return this.clone()}},g.endOf=function(m){return this.startOf(m,!1)},g.$set=function(m,D){var $,C=b.p(m),L="set"+(this.$u?"UTC":""),J=($={},$[c]=L+"Date",$[w]=L+"Date",$[l]=L+"Month",$[p]=L+"FullYear",$[a]=L+"Hours",$[u]=L+"Minutes",$[o]=L+"Seconds",$[s]=L+"Milliseconds",$)[C],B=C===c?this.$D+(D-this.$W):D;if(C===l||C===p){var Z=this.clone().set(w,1);Z.$d[J](B),Z.init(),this.$d=Z.set(w,Math.min(this.$D,Z.daysInMonth())).$d}else J&&this.$d[J](B);return this.init(),this},g.set=function(m,D){return this.clone().$set(m,D)},g.get=function(m){return this[b.p(m)]()},g.add=function(m,D){var $,C=this;m=Number(m);var L=b.p(D),J=function(V){var x=y(C);return b.w(x.date(x.date()+Math.round(V*m)),C)};if(L===l)return this.set(l,this.$M+m);if(L===p)return this.set(p,this.$y+m);if(L===c)return J(1);if(L===f)return J(7);var B=($={},$[u]=i,$[a]=r,$[o]=n,$)[L]||1,Z=this.$d.getTime()+m*B;return b.w(Z,this)},g.subtract=function(m,D){return this.add(-1*m,D)},g.format=function(m){var D=this,$=this.$locale();if(!this.isValid())return $.invalidDate||M;var C=m||"YYYY-MM-DDTHH:mm:ssZ",L=b.z(this),J=this.$H,B=this.$m,Z=this.$M,V=$.weekdays,x=$.months,he=$.meridiem,ce=function(G,ue,pe,ke){return G&&(G[ue]||G(D,C))||pe[ue].slice(0,ke)},me=function(G){return b.s(J%12||12,G,"0")},ae=he||function(G,ue,pe){var ke=G<12?"AM":"PM";return pe?ke.toLowerCase():ke};return C.replace(I,function(G,ue){return ue||function(pe){switch(pe){case"YY":return String(D.$y).slice(-2);case"YYYY":return b.s(D.$y,4,"0");case"M":return Z+1;case"MM":return b.s(Z+1,2,"0");case"MMM":return ce($.monthsShort,Z,x,3);case"MMMM":return ce(x,Z);case"D":return D.$D;case"DD":return b.s(D.$D,2,"0");case"d":return String(D.$W);case"dd":return ce($.weekdaysMin,D.$W,V,2);case"ddd":return ce($.weekdaysShort,D.$W,V,3);case"dddd":return V[D.$W];case"H":return String(J);case"HH":return b.s(J,2,"0");case"h":return me(1);case"hh":return me(2);case"a":return ae(J,B,!0);case"A":return ae(J,B,!1);case"m":return String(B);case"mm":return b.s(B,2,"0");case"s":return String(D.$s);case"ss":return b.s(D.$s,2,"0");case"SSS":return b.s(D.$ms,3,"0");case"Z":return L}return null}(G)||L.replace(":","")})},g.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},g.diff=function(m,D,$){var C,L=this,J=b.p(D),B=y(m),Z=(B.utcOffset()-this.utcOffset())*i,V=this-B,x=function(){return b.m(L,B)};switch(J){case p:C=x()/12;break;case l:C=x();break;case h:C=x()/3;break;case f:C=(V-Z)/6048e5;break;case c:C=(V-Z)/864e5;break;case a:C=V/r;break;case u:C=V/i;break;case o:C=V/n;break;default:C=V}return $?C:b.a(C)},g.daysInMonth=function(){return this.endOf(l).$D},g.$locale=function(){return T[this.$L]},g.locale=function(m,D){if(!m)return this.$L;var $=this.clone(),C=A(m,D,!0);return C&&($.$L=C),$},g.clone=function(){return b.w(this.$d,this)},g.toDate=function(){return new Date(this.valueOf())},g.toJSON=function(){return this.isValid()?this.toISOString():null},g.toISOString=function(){return this.$d.toISOString()},g.toString=function(){return this.$d.toUTCString()},N}(),U=R.prototype;return y.prototype=U,[["$ms",s],["$s",o],["$m",u],["$H",a],["$W",c],["$M",l],["$y",p],["$D",w]].forEach(function(N){U[N[1]]=function(g){return this.$g(g,N[0],N[1])}}),y.extend=function(N,g){return N.$i||(N(g,R,y),N.$i=!0),y},y.locale=A,y.isDayjs=v,y.unix=function(N){return y(1e3*N)},y.en=T[X],y.Ls=T,y.p={},y})})(Xe);var $n=Xe.exports;const Ee=Ge($n),Mn=(e,t)=>{const n=Ee(e).startOf(t),i=Ee().startOf(t);return n.isSame(i)?0:n.isBefore(i)?1:-1},bn=e=>{const t=[{unit:"年",milliseconds:31536e6},{unit:"月",milliseconds:2592e6},{unit:"周",milliseconds:6048e5},{unit:"天",milliseconds:864e5},{unit:"小时",milliseconds:36e5},{unit:"分钟",milliseconds:6e4}],i=Date.now()-e;for(const{unit:r,milliseconds:s}of t)if(i>=s)return`${Math.floor(i/s)} ${r}前`;return"刚刚"},Nn=(e={})=>{const{midnight:t="午夜好",morning:n="早上好",forenoon:i="上午好",noon:r="中午好",afternoon:s="下午好",evening:o="晚上好"}=e,u=new Date().getHours();return u<4?t:u<10?n:u<12?i:u<14?r:u<18?s:o};class Sn{constructor(t,n){this._currentIndex=0,this._numsLength=0,this._isDown=!1,this._onChange=n,this._numsLength=t,window.addEventListener("pointerup",()=>{this._isDown&&this._up()})}down(t){this._isDown=!0,this._handleChange(t),this._timerId=setTimeout(()=>{this._isDown&&(this._intervalId=setInterval(()=>{this._handleChange(t)},100))},100)}updateIndex(t){this._currentIndex=t}_up(){this._isDown=!1,clearTimeout(this._timerId),clearInterval(this._intervalId)}_handleChange(t){t==="add"?this._currentIndex<this._numsLength-1&&(this._currentIndex++,this._onChange(this._currentIndex)):t==="sub"&&this._currentIndex>0&&(this._currentIndex--,this._onChange(this._currentIndex))}}const Dn=e=>{if(e<=0)return[0,"B","0 B"];const t=1024,n=["B","KB","MB","GB","TB","PB","EB","ZB","YB"],i=Math.min(Math.floor(Math.log(e)/Math.log(t)),n.length-1),r=(e/t**i).toFixed(2);return[r,n[i],`${r} ${n[i]}`]},En=e=>e.toString().replace(/^(\d{3})\d{4}(\d{4})$/,"$1****$2"),Ie=(e,t=2)=>{const n=e.toFixed(t).toString(),i=n.indexOf(".")>-1?/(\d)(?=(\d{3})+\.)/g:/(\d)(?=(?:\d{3})+$)/g;return n.replace(i,"$1,")},kn=(e,t,n=0)=>{const i=new ne(e),r=Object.entries(t).sort(([,o],[,u])=>u-o);for(const[o,u]of r){const a=new ne(u);if(i.greaterThanOrEqualTo(a)){const c=i.dividedBy(a);return Ie(Number(c),n)+o}}return Ie(Number(i),n)};var xe={exports:{}};(function(e,t){(function(n,i){e.exports=i()})(ze,function(){var n,i,r=1e3,s=6e4,o=36e5,u=864e5,a=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,c=31536e6,f=2628e6,l=/^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/,h={years:c,months:f,days:u,hours:o,minutes:s,seconds:r,milliseconds:1,weeks:6048e5},p=function(T){return T instanceof q},w=function(T,E,v){return new q(T,v,E.$l)},M=function(T){return i.p(T)+"s"},F=function(T){return T<0},I=function(T){return F(T)?Math.ceil(T):Math.floor(T)},H=function(T){return Math.abs(T)},O=function(T,E){return T?F(T)?{negative:!0,format:""+H(T)+E}:{negative:!1,format:""+T+E}:{negative:!1,format:""}},q=function(){function T(v,A,y){var b=this;if(this.$d={},this.$l=y,v===void 0&&(this.$ms=0,this.parseFromMilliseconds()),A)return w(v*h[M(A)],this);if(typeof v=="number")return this.$ms=v,this.parseFromMilliseconds(),this;if(typeof v=="object")return Object.keys(v).forEach(function(N){b.$d[M(N)]=v[N]}),this.calMilliseconds(),this;if(typeof v=="string"){var R=v.match(l);if(R){var U=R.slice(2).map(function(N){return N!=null?Number(N):0});return this.$d.years=U[0],this.$d.months=U[1],this.$d.weeks=U[2],this.$d.days=U[3],this.$d.hours=U[4],this.$d.minutes=U[5],this.$d.seconds=U[6],this.calMilliseconds(),this}}return this}var E=T.prototype;return E.calMilliseconds=function(){var v=this;this.$ms=Object.keys(this.$d).reduce(function(A,y){return A+(v.$d[y]||0)*h[y]},0)},E.parseFromMilliseconds=function(){var v=this.$ms;this.$d.years=I(v/c),v%=c,this.$d.months=I(v/f),v%=f,this.$d.days=I(v/u),v%=u,this.$d.hours=I(v/o),v%=o,this.$d.minutes=I(v/s),v%=s,this.$d.seconds=I(v/r),v%=r,this.$d.milliseconds=v},E.toISOString=function(){var v=O(this.$d.years,"Y"),A=O(this.$d.months,"M"),y=+this.$d.days||0;this.$d.weeks&&(y+=7*this.$d.weeks);var b=O(y,"D"),R=O(this.$d.hours,"H"),U=O(this.$d.minutes,"M"),N=this.$d.seconds||0;this.$d.milliseconds&&(N+=this.$d.milliseconds/1e3,N=Math.round(1e3*N)/1e3);var g=O(N,"S"),m=v.negative||A.negative||b.negative||R.negative||U.negative||g.negative,D=R.format||U.format||g.format?"T":"",$=(m?"-":"")+"P"+v.format+A.format+b.format+D+R.format+U.format+g.format;return $==="P"||$==="-P"?"P0D":$},E.toJSON=function(){return this.toISOString()},E.format=function(v){var A=v||"YYYY-MM-DDTHH:mm:ss",y={Y:this.$d.years,YY:i.s(this.$d.years,2,"0"),YYYY:i.s(this.$d.years,4,"0"),M:this.$d.months,MM:i.s(this.$d.months,2,"0"),D:this.$d.days,DD:i.s(this.$d.days,2,"0"),H:this.$d.hours,HH:i.s(this.$d.hours,2,"0"),m:this.$d.minutes,mm:i.s(this.$d.minutes,2,"0"),s:this.$d.seconds,ss:i.s(this.$d.seconds,2,"0"),SSS:i.s(this.$d.milliseconds,3,"0")};return A.replace(a,function(b,R){return R||String(y[b])})},E.as=function(v){return this.$ms/h[M(v)]},E.get=function(v){var A=this.$ms,y=M(v);return y==="milliseconds"?A%=1e3:A=y==="weeks"?I(A/h[y]):this.$d[y],A||0},E.add=function(v,A,y){var b;return b=A?v*h[M(A)]:p(v)?v.$ms:w(v,this).$ms,w(this.$ms+b*(y?-1:1),this)},E.subtract=function(v,A){return this.add(v,A,!0)},E.locale=function(v){var A=this.clone();return A.$l=v,A},E.clone=function(){return w(this.$ms,this)},E.humanize=function(v){return n().add(this.$ms,"ms").locale(this.$l).fromNow(!v)},E.valueOf=function(){return this.asMilliseconds()},E.milliseconds=function(){return this.get("milliseconds")},E.asMilliseconds=function(){return this.as("milliseconds")},E.seconds=function(){return this.get("seconds")},E.asSeconds=function(){return this.as("seconds")},E.minutes=function(){return this.get("minutes")},E.asMinutes=function(){return this.as("minutes")},E.hours=function(){return this.get("hours")},E.asHours=function(){return this.as("hours")},E.days=function(){return this.get("days")},E.asDays=function(){return this.as("days")},E.weeks=function(){return this.get("weeks")},E.asWeeks=function(){return this.as("weeks")},E.months=function(){return this.get("months")},E.asMonths=function(){return this.as("months")},E.years=function(){return this.get("years")},E.asYears=function(){return this.as("years")},T}(),X=function(T,E,v){return T.add(E.years()*v,"y").add(E.months()*v,"M").add(E.days()*v,"d").add(E.hours()*v,"h").add(E.minutes()*v,"m").add(E.seconds()*v,"s").add(E.milliseconds()*v,"ms")};return function(T,E,v){n=v,i=v().$utils(),v.duration=function(b,R){var U=v.locale();return w(b,{$l:U},R)},v.isDuration=p;var A=E.prototype.add,y=E.prototype.subtract;E.prototype.add=function(b,R){return p(b)?X(this,b,1):A.bind(this)(b,R)},E.prototype.subtract=function(b,R){return p(b)?X(this,b,-1):y.bind(this)(b,R)}}})})(xe);var _n=xe.exports;const On=Ge(_n);Ee.extend(On);const Tn=Object.freeze(Object.defineProperty({__proto__:null,Base:{libJsGetDataType:ge,libJsPromiseTimeout:Ke},Browser:{libJsColorConsole:Qe,libJsIsMobile:et,libJsIsPad:tt,libJsPathParams:nt,libJsSetTitleIcon:it,libJsTagTitleTip:rt,libJsObjToUrlParams:st},Data:{libJsChunkArray:ot,libJsDeepJSONParse:we,libJsGroupArrayByKey:ut,libJsMatchEmail:ct,libJsShuffleArray:at,libJsStepArray:ft,libReverseArrayFromIndex:lt},File:{libJsDownloadImageLink:ht,libJsImageOptimizer:dt,libJsSaveJson:mt},Formatter:{libJsFormatterByte:Dn,libJsMaskPhoneNumber:En,libJsNumComma:Ie,libJsNumberUnit:kn,libJsSecondsFormatterChinese:e=>{const t=Ee.duration(e,"seconds"),n=Math.floor(t.asYears()),i=Math.floor(t.asMonths()%12),r=Math.floor(t.asDays()%30),s=t.hours(),o=t.minutes(),u=t.seconds(),a=[];return n>0&&a.push(`${n}年`),i>0&&a.push(`${i}月`),r>0&&a.push(`${r}天`),s>0&&a.push(`${s}小时`),o>0&&a.push(`${o}分`),(a.length===0||u>0)&&a.push(`${u}秒`),a.join("")}},Math:{libJsCalculateExpression:(e,t=2)=>{e=e.replace(/\s+/g,"");const n={"+":1,"-":1,"*":2,"/":2},i=u=>new ne(u),r=u=>["+","-","*","/"].includes(u),s=u=>/[0-9.]/.test(u),o=u=>{const a=[],c=[];let f=0;for(;f<u.length;){const h=u[f];if(s(h)){let p="";for(;f<u.length&&s(u[f]);)p+=u[f],f++;a.push(i(p))}else if(h==="(")c.push(h),f++;else if(h===")"){for(;c.length>0&&c[c.length-1]!=="(";)a.push(c.pop());c.pop(),f++}else if(r(h)){for(;c.length>0&&n[c[c.length-1]]>=n[h];)a.push(c.pop());c.push(h),f++}else throw new Error(`无效字符: ${h}`)}for(;c.length>0;)a.push(c.pop());const l=[];for(let h of a)if(typeof h=="string"){const p=l.pop(),w=l.pop();switch(h){case"+":l.push(w.add(p));break;case"-":l.push(w.sub(p));break;case"*":l.push(w.mul(p));break;case"/":if(p.eq(0))throw new Error("除数不能为零");l.push(w.div(p));break}}else l.push(h);return l.pop()};try{const u=o(e);return Number(u.toFixed(t))}catch(u){throw new Error("表达式计算失败:"+u.message)}},libJsConvertAngle:pt,libJsCoordsAngle:gt,libJsCoordsDistance:wt,libJsDecimal:hn},Misc:{libJsRegFormValidate:dn,libJsRetryRequest:mn,LibJsNumberStepper:Sn,LibJsEmitter:()=>{const e=new Map;return{on:(r,s)=>{e.has(r)||e.set(r,[]),e.get(r).push(s)},emit:(r,...s)=>{var o;(o=e.get(r))==null||o.forEach(u=>u(...s))},off:(r,s)=>{if(!s)e.delete(r);else{const o=e.get(r);o&&e.set(r,o.filter(u=>u!==s))}}}}},Random:{libJsProbabilityResult:pn,libJsRandom:gn,libJsRandomColor:wn,libJsUniqueRandomNumbers:vn},Time:{libJsSameTimeCheck:Mn,libJsTimeAgo:bn,libJsTimeGreeting:Nn}},Symbol.toStringTag,{value:"Module"}));window.LibJs=Tn});
|
|
1
|
+
(function(factory) {
|
|
2
|
+
typeof define === "function" && define.amd ? define(factory) : factory();
|
|
3
|
+
})(function() {
|
|
4
|
+
"use strict";
|
|
5
|
+
const libJsGetDataType = (v) => {
|
|
6
|
+
return Object.prototype.toString.call(v).substring(8).replace(/]/g, "").toLowerCase();
|
|
7
|
+
};
|
|
8
|
+
const libJsPromiseTimeout = (delay = 1, fn) => {
|
|
9
|
+
let timeoutId;
|
|
10
|
+
let remainingTime = delay;
|
|
11
|
+
let startTime = Date.now();
|
|
12
|
+
let isPaused = false;
|
|
13
|
+
return new Promise((resolve) => {
|
|
14
|
+
const handleVisibilityChange = () => {
|
|
15
|
+
if (document.hidden) {
|
|
16
|
+
isPaused = true;
|
|
17
|
+
clearTimeout(timeoutId);
|
|
18
|
+
remainingTime -= Date.now() - startTime;
|
|
19
|
+
} else {
|
|
20
|
+
if (isPaused) {
|
|
21
|
+
isPaused = false;
|
|
22
|
+
startTime = Date.now();
|
|
23
|
+
startTimeout(resolve);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
const startTimeout = (resolve2) => {
|
|
28
|
+
timeoutId = setTimeout(() => {
|
|
29
|
+
fn == null ? void 0 : fn();
|
|
30
|
+
resolve2();
|
|
31
|
+
document.removeEventListener(
|
|
32
|
+
"visibilitychange",
|
|
33
|
+
handleVisibilityChange
|
|
34
|
+
);
|
|
35
|
+
}, remainingTime);
|
|
36
|
+
};
|
|
37
|
+
document.addEventListener("visibilitychange", handleVisibilityChange);
|
|
38
|
+
startTimeout(resolve);
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
const libJsColorConsole = (title, color, logs = []) => {
|
|
42
|
+
const colors = {
|
|
43
|
+
red: "#c0392b",
|
|
44
|
+
orange: "#d35400",
|
|
45
|
+
yellow: "#f1c40f",
|
|
46
|
+
green: "#27ae60",
|
|
47
|
+
blue: "#2980b9",
|
|
48
|
+
purple: "#be2edd"
|
|
49
|
+
};
|
|
50
|
+
const getTimestamp = () => {
|
|
51
|
+
const now = /* @__PURE__ */ new Date();
|
|
52
|
+
const hour = String(now.getHours()).padStart(2, "0");
|
|
53
|
+
const minutes = String(now.getMinutes()).padStart(2, "0");
|
|
54
|
+
const seconds = String(now.getSeconds()).padStart(2, "0");
|
|
55
|
+
return `[${hour}:${minutes}:${seconds}]`;
|
|
56
|
+
};
|
|
57
|
+
if (Array.isArray(logs)) {
|
|
58
|
+
const v = logs.map((log3) => {
|
|
59
|
+
return [`
|
|
60
|
+
${log3.label}:`, log3.value];
|
|
61
|
+
});
|
|
62
|
+
console.log(
|
|
63
|
+
`%c${getTimestamp()}-${title}`,
|
|
64
|
+
`color: #fff;background: ${colors[color]}; font-size:14px;border-radius:5px;padding:0.25em;margin:0.5em 0`,
|
|
65
|
+
...v.flat(Infinity)
|
|
66
|
+
);
|
|
67
|
+
} else {
|
|
68
|
+
console.log(
|
|
69
|
+
`%c${getTimestamp()}-${title}`,
|
|
70
|
+
`color: #fff;background: ${colors[color]}; font-size:14px;border-radius:5px;padding:0.25em;margin:0.5em 0`,
|
|
71
|
+
logs
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
const libJsIsMobile = () => {
|
|
76
|
+
const ua = navigator.userAgent.toLowerCase();
|
|
77
|
+
return /mobile|android|iphone|ipod/.test(ua);
|
|
78
|
+
};
|
|
79
|
+
const libJsIsPad = () => {
|
|
80
|
+
const ua = navigator.userAgent.toLowerCase();
|
|
81
|
+
const width = Math.max(window.screen.width, window.screen.height);
|
|
82
|
+
const height = Math.min(window.screen.width, window.screen.height);
|
|
83
|
+
const aspectRatio = width / height;
|
|
84
|
+
const isTabletUserAgent = /ipad|tablet|playbook|silk/.test(ua) && !/mobile/.test(ua);
|
|
85
|
+
const isTabletWidth = width >= 768 && width <= 1366;
|
|
86
|
+
const isTabletAspectRatio = aspectRatio >= 1.3 && aspectRatio <= 1.6;
|
|
87
|
+
return isTabletUserAgent || isTabletWidth && isTabletAspectRatio;
|
|
88
|
+
};
|
|
89
|
+
const libJsPathParams = () => {
|
|
90
|
+
const v = location.href;
|
|
91
|
+
const url = v.split("?")[1];
|
|
92
|
+
if (!url)
|
|
93
|
+
return {};
|
|
94
|
+
const params = url.split("&").reduce((pre, cur) => {
|
|
95
|
+
const [k, v2] = cur.split(/=(.+)/);
|
|
96
|
+
return pre[k] = v2, pre;
|
|
97
|
+
}, {}) || {};
|
|
98
|
+
return params;
|
|
99
|
+
};
|
|
100
|
+
const libJsSetTitleIcon = (title, url) => {
|
|
101
|
+
document.title = title;
|
|
102
|
+
const link = document.createElement("link");
|
|
103
|
+
link.setAttribute("rel", "icon");
|
|
104
|
+
link.setAttribute("href", url);
|
|
105
|
+
const head = document.head || document.getElementsByTagName("head")[0];
|
|
106
|
+
head.appendChild(link);
|
|
107
|
+
};
|
|
108
|
+
const libJsTagTitleTip = (backTitle, leaveTitle) => {
|
|
109
|
+
let document_title = "";
|
|
110
|
+
let timer;
|
|
111
|
+
window.addEventListener("visibilitychange", () => {
|
|
112
|
+
clearTimeout(timer);
|
|
113
|
+
if (document.hidden) {
|
|
114
|
+
if (document.title !== backTitle) {
|
|
115
|
+
document_title = document.title;
|
|
116
|
+
}
|
|
117
|
+
document.title = leaveTitle;
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
document.title = backTitle;
|
|
121
|
+
timer = setTimeout(() => {
|
|
122
|
+
document.title = document_title;
|
|
123
|
+
}, 1e3);
|
|
124
|
+
});
|
|
125
|
+
};
|
|
126
|
+
const libJsObjToUrlParams = (params) => {
|
|
127
|
+
return Object.entries(params).map(([key, value]) => `${key}=${value}`).join("&");
|
|
128
|
+
};
|
|
129
|
+
const libJsChunkArray = (arr, chunkSize) => {
|
|
130
|
+
const result = [];
|
|
131
|
+
for (let i = 0; i < arr.length; i += chunkSize) {
|
|
132
|
+
result.push(arr.slice(i, i + chunkSize));
|
|
133
|
+
}
|
|
134
|
+
return result;
|
|
135
|
+
};
|
|
136
|
+
const libJsDeepJSONParse = (data) => {
|
|
137
|
+
if (typeof data === "string") {
|
|
138
|
+
try {
|
|
139
|
+
const parsed = JSON.parse(data);
|
|
140
|
+
return libJsDeepJSONParse(parsed);
|
|
141
|
+
} catch {
|
|
142
|
+
return data;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
if (Array.isArray(data)) {
|
|
146
|
+
return data.map((item) => libJsDeepJSONParse(item));
|
|
147
|
+
}
|
|
148
|
+
if (data !== null && typeof data === "object") {
|
|
149
|
+
return Object.keys(data).reduce((acc, key) => {
|
|
150
|
+
acc[key] = libJsDeepJSONParse(data[key]);
|
|
151
|
+
return acc;
|
|
152
|
+
}, {});
|
|
153
|
+
}
|
|
154
|
+
return data;
|
|
155
|
+
};
|
|
156
|
+
const libJsGroupArrayByKey = (arr = [], key) => {
|
|
157
|
+
return key ? arr.reduce((t, v) => {
|
|
158
|
+
if (!t[v[key]]) {
|
|
159
|
+
t[v[key]] = [];
|
|
160
|
+
}
|
|
161
|
+
t[v[key]].push(v);
|
|
162
|
+
return t;
|
|
163
|
+
}, {}) : {};
|
|
164
|
+
};
|
|
165
|
+
const libJsMatchEmail = (str, emailList) => {
|
|
166
|
+
return str.includes("@") ? emailList.filter((item) => item.includes(str.slice(str.indexOf("@")))).map((item) => (str.includes("@") ? str.split("@")[0] : str) + item) : emailList.map((item) => str + item);
|
|
167
|
+
};
|
|
168
|
+
const libJsShuffleArray = (arr) => {
|
|
169
|
+
const newArr = [...arr];
|
|
170
|
+
for (let i = newArr.length - 1; i > 0; i--) {
|
|
171
|
+
const j = Math.floor(Math.random() * (i + 1));
|
|
172
|
+
[newArr[i], newArr[j]] = [newArr[j], newArr[i]];
|
|
173
|
+
}
|
|
174
|
+
return newArr;
|
|
175
|
+
};
|
|
176
|
+
const libJsStepArray = (arr, step) => {
|
|
177
|
+
const length = arr.length;
|
|
178
|
+
if (length === 0 || step % length === 0)
|
|
179
|
+
return arr;
|
|
180
|
+
const normalizedStep = (step % length + length) % length;
|
|
181
|
+
return arr.slice(-normalizedStep).concat(arr.slice(0, -normalizedStep));
|
|
182
|
+
};
|
|
183
|
+
const libReverseArrayFromIndex = (arr, index) => {
|
|
184
|
+
if (index < 0 || index >= arr.length) {
|
|
185
|
+
throw new Error("Index out of bounds");
|
|
186
|
+
}
|
|
187
|
+
const subArray = arr.slice(index + 1).reverse();
|
|
188
|
+
return [...arr.slice(0, index + 1), ...subArray];
|
|
189
|
+
};
|
|
190
|
+
const libJsDownloadImageLink = (link, name) => {
|
|
191
|
+
fetch(link).then((res) => res.blob()).then((blob) => {
|
|
192
|
+
const a = document.createElement("a");
|
|
193
|
+
const url = window.URL.createObjectURL(blob);
|
|
194
|
+
a.href = url;
|
|
195
|
+
a.download = name;
|
|
196
|
+
a.click();
|
|
197
|
+
});
|
|
198
|
+
};
|
|
199
|
+
const libJsImageOptimizer = (obj) => {
|
|
200
|
+
const canvas = document.createElement("canvas");
|
|
201
|
+
canvas.classList.add("imageOptimizer");
|
|
202
|
+
document.body.appendChild(canvas);
|
|
203
|
+
const files = obj.file;
|
|
204
|
+
if (!files)
|
|
205
|
+
return;
|
|
206
|
+
const name = files.name;
|
|
207
|
+
const extension = name.split(".").pop().toLowerCase();
|
|
208
|
+
const ratio = obj.ratio || 1;
|
|
209
|
+
const maxSize = obj.maxSize || 1024;
|
|
210
|
+
const width = obj.width || 1e4;
|
|
211
|
+
const mimeType = files.type;
|
|
212
|
+
function dataURLtoFile(dataURL, filename) {
|
|
213
|
+
const arr = dataURL.split(",");
|
|
214
|
+
const mime = arr[0].match(/:(.*?);/)[1];
|
|
215
|
+
const bstr = window.atob(arr[1]);
|
|
216
|
+
const n = bstr.length;
|
|
217
|
+
const u8arr = new Uint8Array(n);
|
|
218
|
+
for (let i = 0; i < n; i++) {
|
|
219
|
+
u8arr[i] = bstr.charCodeAt(i);
|
|
220
|
+
}
|
|
221
|
+
return new File([u8arr], filename, { type: mime });
|
|
222
|
+
}
|
|
223
|
+
function formData(file) {
|
|
224
|
+
const data = new FormData();
|
|
225
|
+
data.append("file", file);
|
|
226
|
+
return data;
|
|
227
|
+
}
|
|
228
|
+
const reader = new FileReader();
|
|
229
|
+
reader.readAsDataURL(files);
|
|
230
|
+
reader.onload = (e) => {
|
|
231
|
+
const result = e.target.result;
|
|
232
|
+
if (e.total / 1024 > maxSize) {
|
|
233
|
+
const image = new Image();
|
|
234
|
+
image.src = result;
|
|
235
|
+
image.onload = () => {
|
|
236
|
+
const context = canvas.getContext("2d");
|
|
237
|
+
const scale = width / image.width;
|
|
238
|
+
if (scale < 1) {
|
|
239
|
+
canvas.width = image.width * scale;
|
|
240
|
+
canvas.height = image.height * scale;
|
|
241
|
+
context.drawImage(
|
|
242
|
+
image,
|
|
243
|
+
0,
|
|
244
|
+
0,
|
|
245
|
+
image.width * scale,
|
|
246
|
+
image.height * scale
|
|
247
|
+
);
|
|
248
|
+
} else {
|
|
249
|
+
canvas.width = image.width;
|
|
250
|
+
canvas.height = image.height;
|
|
251
|
+
context.drawImage(image, 0, 0, image.width, image.height);
|
|
252
|
+
}
|
|
253
|
+
const dataUrl = canvas.toDataURL(mimeType, ratio);
|
|
254
|
+
const newName = `${name.split(".")[0]}.${extension}`;
|
|
255
|
+
const file = dataURLtoFile(dataUrl, newName);
|
|
256
|
+
obj.success(formData(file), file, dataUrl);
|
|
257
|
+
canvas.remove();
|
|
258
|
+
};
|
|
259
|
+
image.onerror = obj.fail;
|
|
260
|
+
} else {
|
|
261
|
+
const newName = `${name.split(".")[0]}.${extension}`;
|
|
262
|
+
const file = dataURLtoFile(result, newName);
|
|
263
|
+
obj.success(formData(file), file, result);
|
|
264
|
+
canvas.remove();
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
reader.onerror = obj.fail;
|
|
268
|
+
};
|
|
269
|
+
const libJsSaveJson = (name, data) => {
|
|
270
|
+
const urlObject = window.URL || window.webkitURL;
|
|
271
|
+
const exportBlob = new Blob([data]);
|
|
272
|
+
const saveLink = document.createElement("a");
|
|
273
|
+
saveLink.href = urlObject.createObjectURL(exportBlob);
|
|
274
|
+
saveLink.download = name;
|
|
275
|
+
saveLink.click();
|
|
276
|
+
urlObject.revokeObjectURL(saveLink.href);
|
|
277
|
+
};
|
|
278
|
+
const libJsConvertAngle = (value, type) => {
|
|
279
|
+
if (type === "rad") {
|
|
280
|
+
return value * (Math.PI / 180);
|
|
281
|
+
} else if (type === "deg") {
|
|
282
|
+
return value * (180 / Math.PI);
|
|
283
|
+
} else {
|
|
284
|
+
throw new Error("请使用正确类型");
|
|
285
|
+
}
|
|
286
|
+
};
|
|
287
|
+
const libJsCoordsAngle = (coord1, coord2) => {
|
|
288
|
+
const deltaX = coord2.x - coord1.x;
|
|
289
|
+
const deltaY = coord2.y - coord1.y;
|
|
290
|
+
const angleRad = Math.atan2(deltaY, deltaX);
|
|
291
|
+
let angleDeg = angleRad * (180 / Math.PI);
|
|
292
|
+
angleDeg = -angleDeg + 90;
|
|
293
|
+
if (angleDeg < 0) {
|
|
294
|
+
angleDeg += 360;
|
|
295
|
+
}
|
|
296
|
+
return angleDeg;
|
|
297
|
+
};
|
|
298
|
+
const libJsCoordsDistance = (coord1, coord2) => {
|
|
299
|
+
const deltaX = coord2.x - coord1.x;
|
|
300
|
+
const deltaY = coord2.y - coord1.y;
|
|
301
|
+
const distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
|
|
302
|
+
return distance;
|
|
303
|
+
};
|
|
304
|
+
/*!
|
|
305
|
+
* decimal.js v10.4.3
|
|
306
|
+
* An arbitrary-precision Decimal type for JavaScript.
|
|
307
|
+
* https://github.com/MikeMcl/decimal.js
|
|
308
|
+
* Copyright (c) 2022 Michael Mclaughlin <M8ch88l@gmail.com>
|
|
309
|
+
* MIT Licence
|
|
310
|
+
*/
|
|
311
|
+
var EXP_LIMIT = 9e15, MAX_DIGITS = 1e9, NUMERALS = "0123456789abcdef", LN10 = "2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058", PI = "3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789", DEFAULTS = {
|
|
312
|
+
// These values must be integers within the stated ranges (inclusive).
|
|
313
|
+
// Most of these values can be changed at run-time using the `Decimal.config` method.
|
|
314
|
+
// The maximum number of significant digits of the result of a calculation or base conversion.
|
|
315
|
+
// E.g. `Decimal.config({ precision: 20 });`
|
|
316
|
+
precision: 20,
|
|
317
|
+
// 1 to MAX_DIGITS
|
|
318
|
+
// The rounding mode used when rounding to `precision`.
|
|
319
|
+
//
|
|
320
|
+
// ROUND_UP 0 Away from zero.
|
|
321
|
+
// ROUND_DOWN 1 Towards zero.
|
|
322
|
+
// ROUND_CEIL 2 Towards +Infinity.
|
|
323
|
+
// ROUND_FLOOR 3 Towards -Infinity.
|
|
324
|
+
// ROUND_HALF_UP 4 Towards nearest neighbour. If equidistant, up.
|
|
325
|
+
// ROUND_HALF_DOWN 5 Towards nearest neighbour. If equidistant, down.
|
|
326
|
+
// ROUND_HALF_EVEN 6 Towards nearest neighbour. If equidistant, towards even neighbour.
|
|
327
|
+
// ROUND_HALF_CEIL 7 Towards nearest neighbour. If equidistant, towards +Infinity.
|
|
328
|
+
// ROUND_HALF_FLOOR 8 Towards nearest neighbour. If equidistant, towards -Infinity.
|
|
329
|
+
//
|
|
330
|
+
// E.g.
|
|
331
|
+
// `Decimal.rounding = 4;`
|
|
332
|
+
// `Decimal.rounding = Decimal.ROUND_HALF_UP;`
|
|
333
|
+
rounding: 4,
|
|
334
|
+
// 0 to 8
|
|
335
|
+
// The modulo mode used when calculating the modulus: a mod n.
|
|
336
|
+
// The quotient (q = a / n) is calculated according to the corresponding rounding mode.
|
|
337
|
+
// The remainder (r) is calculated as: r = a - n * q.
|
|
338
|
+
//
|
|
339
|
+
// UP 0 The remainder is positive if the dividend is negative, else is negative.
|
|
340
|
+
// DOWN 1 The remainder has the same sign as the dividend (JavaScript %).
|
|
341
|
+
// FLOOR 3 The remainder has the same sign as the divisor (Python %).
|
|
342
|
+
// HALF_EVEN 6 The IEEE 754 remainder function.
|
|
343
|
+
// EUCLID 9 Euclidian division. q = sign(n) * floor(a / abs(n)). Always positive.
|
|
344
|
+
//
|
|
345
|
+
// Truncated division (1), floored division (3), the IEEE 754 remainder (6), and Euclidian
|
|
346
|
+
// division (9) are commonly used for the modulus operation. The other rounding modes can also
|
|
347
|
+
// be used, but they may not give useful results.
|
|
348
|
+
modulo: 1,
|
|
349
|
+
// 0 to 9
|
|
350
|
+
// The exponent value at and beneath which `toString` returns exponential notation.
|
|
351
|
+
// JavaScript numbers: -7
|
|
352
|
+
toExpNeg: -7,
|
|
353
|
+
// 0 to -EXP_LIMIT
|
|
354
|
+
// The exponent value at and above which `toString` returns exponential notation.
|
|
355
|
+
// JavaScript numbers: 21
|
|
356
|
+
toExpPos: 21,
|
|
357
|
+
// 0 to EXP_LIMIT
|
|
358
|
+
// The minimum exponent value, beneath which underflow to zero occurs.
|
|
359
|
+
// JavaScript numbers: -324 (5e-324)
|
|
360
|
+
minE: -EXP_LIMIT,
|
|
361
|
+
// -1 to -EXP_LIMIT
|
|
362
|
+
// The maximum exponent value, above which overflow to Infinity occurs.
|
|
363
|
+
// JavaScript numbers: 308 (1.7976931348623157e+308)
|
|
364
|
+
maxE: EXP_LIMIT,
|
|
365
|
+
// 1 to EXP_LIMIT
|
|
366
|
+
// Whether to use cryptographically-secure random number generation, if available.
|
|
367
|
+
crypto: false
|
|
368
|
+
// true/false
|
|
369
|
+
}, inexact, quadrant, external = true, decimalError = "[DecimalError] ", invalidArgument = decimalError + "Invalid argument: ", precisionLimitExceeded = decimalError + "Precision limit exceeded", cryptoUnavailable = decimalError + "crypto unavailable", tag = "[object Decimal]", mathfloor = Math.floor, mathpow = Math.pow, isBinary = /^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i, isHex = /^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i, isOctal = /^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i, isDecimal = /^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i, BASE = 1e7, LOG_BASE = 7, MAX_SAFE_INTEGER = 9007199254740991, LN10_PRECISION = LN10.length - 1, PI_PRECISION = PI.length - 1, P = { toStringTag: tag };
|
|
370
|
+
P.absoluteValue = P.abs = function() {
|
|
371
|
+
var x = new this.constructor(this);
|
|
372
|
+
if (x.s < 0)
|
|
373
|
+
x.s = 1;
|
|
374
|
+
return finalise(x);
|
|
375
|
+
};
|
|
376
|
+
P.ceil = function() {
|
|
377
|
+
return finalise(new this.constructor(this), this.e + 1, 2);
|
|
378
|
+
};
|
|
379
|
+
P.clampedTo = P.clamp = function(min2, max2) {
|
|
380
|
+
var k, x = this, Ctor = x.constructor;
|
|
381
|
+
min2 = new Ctor(min2);
|
|
382
|
+
max2 = new Ctor(max2);
|
|
383
|
+
if (!min2.s || !max2.s)
|
|
384
|
+
return new Ctor(NaN);
|
|
385
|
+
if (min2.gt(max2))
|
|
386
|
+
throw Error(invalidArgument + max2);
|
|
387
|
+
k = x.cmp(min2);
|
|
388
|
+
return k < 0 ? min2 : x.cmp(max2) > 0 ? max2 : new Ctor(x);
|
|
389
|
+
};
|
|
390
|
+
P.comparedTo = P.cmp = function(y) {
|
|
391
|
+
var i, j, xdL, ydL, x = this, xd = x.d, yd = (y = new x.constructor(y)).d, xs = x.s, ys = y.s;
|
|
392
|
+
if (!xd || !yd) {
|
|
393
|
+
return !xs || !ys ? NaN : xs !== ys ? xs : xd === yd ? 0 : !xd ^ xs < 0 ? 1 : -1;
|
|
394
|
+
}
|
|
395
|
+
if (!xd[0] || !yd[0])
|
|
396
|
+
return xd[0] ? xs : yd[0] ? -ys : 0;
|
|
397
|
+
if (xs !== ys)
|
|
398
|
+
return xs;
|
|
399
|
+
if (x.e !== y.e)
|
|
400
|
+
return x.e > y.e ^ xs < 0 ? 1 : -1;
|
|
401
|
+
xdL = xd.length;
|
|
402
|
+
ydL = yd.length;
|
|
403
|
+
for (i = 0, j = xdL < ydL ? xdL : ydL; i < j; ++i) {
|
|
404
|
+
if (xd[i] !== yd[i])
|
|
405
|
+
return xd[i] > yd[i] ^ xs < 0 ? 1 : -1;
|
|
406
|
+
}
|
|
407
|
+
return xdL === ydL ? 0 : xdL > ydL ^ xs < 0 ? 1 : -1;
|
|
408
|
+
};
|
|
409
|
+
P.cosine = P.cos = function() {
|
|
410
|
+
var pr, rm, x = this, Ctor = x.constructor;
|
|
411
|
+
if (!x.d)
|
|
412
|
+
return new Ctor(NaN);
|
|
413
|
+
if (!x.d[0])
|
|
414
|
+
return new Ctor(1);
|
|
415
|
+
pr = Ctor.precision;
|
|
416
|
+
rm = Ctor.rounding;
|
|
417
|
+
Ctor.precision = pr + Math.max(x.e, x.sd()) + LOG_BASE;
|
|
418
|
+
Ctor.rounding = 1;
|
|
419
|
+
x = cosine(Ctor, toLessThanHalfPi(Ctor, x));
|
|
420
|
+
Ctor.precision = pr;
|
|
421
|
+
Ctor.rounding = rm;
|
|
422
|
+
return finalise(quadrant == 2 || quadrant == 3 ? x.neg() : x, pr, rm, true);
|
|
423
|
+
};
|
|
424
|
+
P.cubeRoot = P.cbrt = function() {
|
|
425
|
+
var e, m, n, r, rep, s, sd, t, t3, t3plusx, x = this, Ctor = x.constructor;
|
|
426
|
+
if (!x.isFinite() || x.isZero())
|
|
427
|
+
return new Ctor(x);
|
|
428
|
+
external = false;
|
|
429
|
+
s = x.s * mathpow(x.s * x, 1 / 3);
|
|
430
|
+
if (!s || Math.abs(s) == 1 / 0) {
|
|
431
|
+
n = digitsToString(x.d);
|
|
432
|
+
e = x.e;
|
|
433
|
+
if (s = (e - n.length + 1) % 3)
|
|
434
|
+
n += s == 1 || s == -2 ? "0" : "00";
|
|
435
|
+
s = mathpow(n, 1 / 3);
|
|
436
|
+
e = mathfloor((e + 1) / 3) - (e % 3 == (e < 0 ? -1 : 2));
|
|
437
|
+
if (s == 1 / 0) {
|
|
438
|
+
n = "5e" + e;
|
|
439
|
+
} else {
|
|
440
|
+
n = s.toExponential();
|
|
441
|
+
n = n.slice(0, n.indexOf("e") + 1) + e;
|
|
442
|
+
}
|
|
443
|
+
r = new Ctor(n);
|
|
444
|
+
r.s = x.s;
|
|
445
|
+
} else {
|
|
446
|
+
r = new Ctor(s.toString());
|
|
447
|
+
}
|
|
448
|
+
sd = (e = Ctor.precision) + 3;
|
|
449
|
+
for (; ; ) {
|
|
450
|
+
t = r;
|
|
451
|
+
t3 = t.times(t).times(t);
|
|
452
|
+
t3plusx = t3.plus(x);
|
|
453
|
+
r = divide(t3plusx.plus(x).times(t), t3plusx.plus(t3), sd + 2, 1);
|
|
454
|
+
if (digitsToString(t.d).slice(0, sd) === (n = digitsToString(r.d)).slice(0, sd)) {
|
|
455
|
+
n = n.slice(sd - 3, sd + 1);
|
|
456
|
+
if (n == "9999" || !rep && n == "4999") {
|
|
457
|
+
if (!rep) {
|
|
458
|
+
finalise(t, e + 1, 0);
|
|
459
|
+
if (t.times(t).times(t).eq(x)) {
|
|
460
|
+
r = t;
|
|
461
|
+
break;
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
sd += 4;
|
|
465
|
+
rep = 1;
|
|
466
|
+
} else {
|
|
467
|
+
if (!+n || !+n.slice(1) && n.charAt(0) == "5") {
|
|
468
|
+
finalise(r, e + 1, 1);
|
|
469
|
+
m = !r.times(r).times(r).eq(x);
|
|
470
|
+
}
|
|
471
|
+
break;
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
external = true;
|
|
476
|
+
return finalise(r, e, Ctor.rounding, m);
|
|
477
|
+
};
|
|
478
|
+
P.decimalPlaces = P.dp = function() {
|
|
479
|
+
var w, d = this.d, n = NaN;
|
|
480
|
+
if (d) {
|
|
481
|
+
w = d.length - 1;
|
|
482
|
+
n = (w - mathfloor(this.e / LOG_BASE)) * LOG_BASE;
|
|
483
|
+
w = d[w];
|
|
484
|
+
if (w)
|
|
485
|
+
for (; w % 10 == 0; w /= 10)
|
|
486
|
+
n--;
|
|
487
|
+
if (n < 0)
|
|
488
|
+
n = 0;
|
|
489
|
+
}
|
|
490
|
+
return n;
|
|
491
|
+
};
|
|
492
|
+
P.dividedBy = P.div = function(y) {
|
|
493
|
+
return divide(this, new this.constructor(y));
|
|
494
|
+
};
|
|
495
|
+
P.dividedToIntegerBy = P.divToInt = function(y) {
|
|
496
|
+
var x = this, Ctor = x.constructor;
|
|
497
|
+
return finalise(divide(x, new Ctor(y), 0, 1, 1), Ctor.precision, Ctor.rounding);
|
|
498
|
+
};
|
|
499
|
+
P.equals = P.eq = function(y) {
|
|
500
|
+
return this.cmp(y) === 0;
|
|
501
|
+
};
|
|
502
|
+
P.floor = function() {
|
|
503
|
+
return finalise(new this.constructor(this), this.e + 1, 3);
|
|
504
|
+
};
|
|
505
|
+
P.greaterThan = P.gt = function(y) {
|
|
506
|
+
return this.cmp(y) > 0;
|
|
507
|
+
};
|
|
508
|
+
P.greaterThanOrEqualTo = P.gte = function(y) {
|
|
509
|
+
var k = this.cmp(y);
|
|
510
|
+
return k == 1 || k === 0;
|
|
511
|
+
};
|
|
512
|
+
P.hyperbolicCosine = P.cosh = function() {
|
|
513
|
+
var k, n, pr, rm, len, x = this, Ctor = x.constructor, one = new Ctor(1);
|
|
514
|
+
if (!x.isFinite())
|
|
515
|
+
return new Ctor(x.s ? 1 / 0 : NaN);
|
|
516
|
+
if (x.isZero())
|
|
517
|
+
return one;
|
|
518
|
+
pr = Ctor.precision;
|
|
519
|
+
rm = Ctor.rounding;
|
|
520
|
+
Ctor.precision = pr + Math.max(x.e, x.sd()) + 4;
|
|
521
|
+
Ctor.rounding = 1;
|
|
522
|
+
len = x.d.length;
|
|
523
|
+
if (len < 32) {
|
|
524
|
+
k = Math.ceil(len / 3);
|
|
525
|
+
n = (1 / tinyPow(4, k)).toString();
|
|
526
|
+
} else {
|
|
527
|
+
k = 16;
|
|
528
|
+
n = "2.3283064365386962890625e-10";
|
|
529
|
+
}
|
|
530
|
+
x = taylorSeries(Ctor, 1, x.times(n), new Ctor(1), true);
|
|
531
|
+
var cosh2_x, i = k, d8 = new Ctor(8);
|
|
532
|
+
for (; i--; ) {
|
|
533
|
+
cosh2_x = x.times(x);
|
|
534
|
+
x = one.minus(cosh2_x.times(d8.minus(cosh2_x.times(d8))));
|
|
535
|
+
}
|
|
536
|
+
return finalise(x, Ctor.precision = pr, Ctor.rounding = rm, true);
|
|
537
|
+
};
|
|
538
|
+
P.hyperbolicSine = P.sinh = function() {
|
|
539
|
+
var k, pr, rm, len, x = this, Ctor = x.constructor;
|
|
540
|
+
if (!x.isFinite() || x.isZero())
|
|
541
|
+
return new Ctor(x);
|
|
542
|
+
pr = Ctor.precision;
|
|
543
|
+
rm = Ctor.rounding;
|
|
544
|
+
Ctor.precision = pr + Math.max(x.e, x.sd()) + 4;
|
|
545
|
+
Ctor.rounding = 1;
|
|
546
|
+
len = x.d.length;
|
|
547
|
+
if (len < 3) {
|
|
548
|
+
x = taylorSeries(Ctor, 2, x, x, true);
|
|
549
|
+
} else {
|
|
550
|
+
k = 1.4 * Math.sqrt(len);
|
|
551
|
+
k = k > 16 ? 16 : k | 0;
|
|
552
|
+
x = x.times(1 / tinyPow(5, k));
|
|
553
|
+
x = taylorSeries(Ctor, 2, x, x, true);
|
|
554
|
+
var sinh2_x, d5 = new Ctor(5), d16 = new Ctor(16), d20 = new Ctor(20);
|
|
555
|
+
for (; k--; ) {
|
|
556
|
+
sinh2_x = x.times(x);
|
|
557
|
+
x = x.times(d5.plus(sinh2_x.times(d16.times(sinh2_x).plus(d20))));
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
Ctor.precision = pr;
|
|
561
|
+
Ctor.rounding = rm;
|
|
562
|
+
return finalise(x, pr, rm, true);
|
|
563
|
+
};
|
|
564
|
+
P.hyperbolicTangent = P.tanh = function() {
|
|
565
|
+
var pr, rm, x = this, Ctor = x.constructor;
|
|
566
|
+
if (!x.isFinite())
|
|
567
|
+
return new Ctor(x.s);
|
|
568
|
+
if (x.isZero())
|
|
569
|
+
return new Ctor(x);
|
|
570
|
+
pr = Ctor.precision;
|
|
571
|
+
rm = Ctor.rounding;
|
|
572
|
+
Ctor.precision = pr + 7;
|
|
573
|
+
Ctor.rounding = 1;
|
|
574
|
+
return divide(x.sinh(), x.cosh(), Ctor.precision = pr, Ctor.rounding = rm);
|
|
575
|
+
};
|
|
576
|
+
P.inverseCosine = P.acos = function() {
|
|
577
|
+
var halfPi, x = this, Ctor = x.constructor, k = x.abs().cmp(1), pr = Ctor.precision, rm = Ctor.rounding;
|
|
578
|
+
if (k !== -1) {
|
|
579
|
+
return k === 0 ? x.isNeg() ? getPi(Ctor, pr, rm) : new Ctor(0) : new Ctor(NaN);
|
|
580
|
+
}
|
|
581
|
+
if (x.isZero())
|
|
582
|
+
return getPi(Ctor, pr + 4, rm).times(0.5);
|
|
583
|
+
Ctor.precision = pr + 6;
|
|
584
|
+
Ctor.rounding = 1;
|
|
585
|
+
x = x.asin();
|
|
586
|
+
halfPi = getPi(Ctor, pr + 4, rm).times(0.5);
|
|
587
|
+
Ctor.precision = pr;
|
|
588
|
+
Ctor.rounding = rm;
|
|
589
|
+
return halfPi.minus(x);
|
|
590
|
+
};
|
|
591
|
+
P.inverseHyperbolicCosine = P.acosh = function() {
|
|
592
|
+
var pr, rm, x = this, Ctor = x.constructor;
|
|
593
|
+
if (x.lte(1))
|
|
594
|
+
return new Ctor(x.eq(1) ? 0 : NaN);
|
|
595
|
+
if (!x.isFinite())
|
|
596
|
+
return new Ctor(x);
|
|
597
|
+
pr = Ctor.precision;
|
|
598
|
+
rm = Ctor.rounding;
|
|
599
|
+
Ctor.precision = pr + Math.max(Math.abs(x.e), x.sd()) + 4;
|
|
600
|
+
Ctor.rounding = 1;
|
|
601
|
+
external = false;
|
|
602
|
+
x = x.times(x).minus(1).sqrt().plus(x);
|
|
603
|
+
external = true;
|
|
604
|
+
Ctor.precision = pr;
|
|
605
|
+
Ctor.rounding = rm;
|
|
606
|
+
return x.ln();
|
|
607
|
+
};
|
|
608
|
+
P.inverseHyperbolicSine = P.asinh = function() {
|
|
609
|
+
var pr, rm, x = this, Ctor = x.constructor;
|
|
610
|
+
if (!x.isFinite() || x.isZero())
|
|
611
|
+
return new Ctor(x);
|
|
612
|
+
pr = Ctor.precision;
|
|
613
|
+
rm = Ctor.rounding;
|
|
614
|
+
Ctor.precision = pr + 2 * Math.max(Math.abs(x.e), x.sd()) + 6;
|
|
615
|
+
Ctor.rounding = 1;
|
|
616
|
+
external = false;
|
|
617
|
+
x = x.times(x).plus(1).sqrt().plus(x);
|
|
618
|
+
external = true;
|
|
619
|
+
Ctor.precision = pr;
|
|
620
|
+
Ctor.rounding = rm;
|
|
621
|
+
return x.ln();
|
|
622
|
+
};
|
|
623
|
+
P.inverseHyperbolicTangent = P.atanh = function() {
|
|
624
|
+
var pr, rm, wpr, xsd, x = this, Ctor = x.constructor;
|
|
625
|
+
if (!x.isFinite())
|
|
626
|
+
return new Ctor(NaN);
|
|
627
|
+
if (x.e >= 0)
|
|
628
|
+
return new Ctor(x.abs().eq(1) ? x.s / 0 : x.isZero() ? x : NaN);
|
|
629
|
+
pr = Ctor.precision;
|
|
630
|
+
rm = Ctor.rounding;
|
|
631
|
+
xsd = x.sd();
|
|
632
|
+
if (Math.max(xsd, pr) < 2 * -x.e - 1)
|
|
633
|
+
return finalise(new Ctor(x), pr, rm, true);
|
|
634
|
+
Ctor.precision = wpr = xsd - x.e;
|
|
635
|
+
x = divide(x.plus(1), new Ctor(1).minus(x), wpr + pr, 1);
|
|
636
|
+
Ctor.precision = pr + 4;
|
|
637
|
+
Ctor.rounding = 1;
|
|
638
|
+
x = x.ln();
|
|
639
|
+
Ctor.precision = pr;
|
|
640
|
+
Ctor.rounding = rm;
|
|
641
|
+
return x.times(0.5);
|
|
642
|
+
};
|
|
643
|
+
P.inverseSine = P.asin = function() {
|
|
644
|
+
var halfPi, k, pr, rm, x = this, Ctor = x.constructor;
|
|
645
|
+
if (x.isZero())
|
|
646
|
+
return new Ctor(x);
|
|
647
|
+
k = x.abs().cmp(1);
|
|
648
|
+
pr = Ctor.precision;
|
|
649
|
+
rm = Ctor.rounding;
|
|
650
|
+
if (k !== -1) {
|
|
651
|
+
if (k === 0) {
|
|
652
|
+
halfPi = getPi(Ctor, pr + 4, rm).times(0.5);
|
|
653
|
+
halfPi.s = x.s;
|
|
654
|
+
return halfPi;
|
|
655
|
+
}
|
|
656
|
+
return new Ctor(NaN);
|
|
657
|
+
}
|
|
658
|
+
Ctor.precision = pr + 6;
|
|
659
|
+
Ctor.rounding = 1;
|
|
660
|
+
x = x.div(new Ctor(1).minus(x.times(x)).sqrt().plus(1)).atan();
|
|
661
|
+
Ctor.precision = pr;
|
|
662
|
+
Ctor.rounding = rm;
|
|
663
|
+
return x.times(2);
|
|
664
|
+
};
|
|
665
|
+
P.inverseTangent = P.atan = function() {
|
|
666
|
+
var i, j, k, n, px, t, r, wpr, x2, x = this, Ctor = x.constructor, pr = Ctor.precision, rm = Ctor.rounding;
|
|
667
|
+
if (!x.isFinite()) {
|
|
668
|
+
if (!x.s)
|
|
669
|
+
return new Ctor(NaN);
|
|
670
|
+
if (pr + 4 <= PI_PRECISION) {
|
|
671
|
+
r = getPi(Ctor, pr + 4, rm).times(0.5);
|
|
672
|
+
r.s = x.s;
|
|
673
|
+
return r;
|
|
674
|
+
}
|
|
675
|
+
} else if (x.isZero()) {
|
|
676
|
+
return new Ctor(x);
|
|
677
|
+
} else if (x.abs().eq(1) && pr + 4 <= PI_PRECISION) {
|
|
678
|
+
r = getPi(Ctor, pr + 4, rm).times(0.25);
|
|
679
|
+
r.s = x.s;
|
|
680
|
+
return r;
|
|
681
|
+
}
|
|
682
|
+
Ctor.precision = wpr = pr + 10;
|
|
683
|
+
Ctor.rounding = 1;
|
|
684
|
+
k = Math.min(28, wpr / LOG_BASE + 2 | 0);
|
|
685
|
+
for (i = k; i; --i)
|
|
686
|
+
x = x.div(x.times(x).plus(1).sqrt().plus(1));
|
|
687
|
+
external = false;
|
|
688
|
+
j = Math.ceil(wpr / LOG_BASE);
|
|
689
|
+
n = 1;
|
|
690
|
+
x2 = x.times(x);
|
|
691
|
+
r = new Ctor(x);
|
|
692
|
+
px = x;
|
|
693
|
+
for (; i !== -1; ) {
|
|
694
|
+
px = px.times(x2);
|
|
695
|
+
t = r.minus(px.div(n += 2));
|
|
696
|
+
px = px.times(x2);
|
|
697
|
+
r = t.plus(px.div(n += 2));
|
|
698
|
+
if (r.d[j] !== void 0)
|
|
699
|
+
for (i = j; r.d[i] === t.d[i] && i--; )
|
|
700
|
+
;
|
|
701
|
+
}
|
|
702
|
+
if (k)
|
|
703
|
+
r = r.times(2 << k - 1);
|
|
704
|
+
external = true;
|
|
705
|
+
return finalise(r, Ctor.precision = pr, Ctor.rounding = rm, true);
|
|
706
|
+
};
|
|
707
|
+
P.isFinite = function() {
|
|
708
|
+
return !!this.d;
|
|
709
|
+
};
|
|
710
|
+
P.isInteger = P.isInt = function() {
|
|
711
|
+
return !!this.d && mathfloor(this.e / LOG_BASE) > this.d.length - 2;
|
|
712
|
+
};
|
|
713
|
+
P.isNaN = function() {
|
|
714
|
+
return !this.s;
|
|
715
|
+
};
|
|
716
|
+
P.isNegative = P.isNeg = function() {
|
|
717
|
+
return this.s < 0;
|
|
718
|
+
};
|
|
719
|
+
P.isPositive = P.isPos = function() {
|
|
720
|
+
return this.s > 0;
|
|
721
|
+
};
|
|
722
|
+
P.isZero = function() {
|
|
723
|
+
return !!this.d && this.d[0] === 0;
|
|
724
|
+
};
|
|
725
|
+
P.lessThan = P.lt = function(y) {
|
|
726
|
+
return this.cmp(y) < 0;
|
|
727
|
+
};
|
|
728
|
+
P.lessThanOrEqualTo = P.lte = function(y) {
|
|
729
|
+
return this.cmp(y) < 1;
|
|
730
|
+
};
|
|
731
|
+
P.logarithm = P.log = function(base) {
|
|
732
|
+
var isBase10, d, denominator, k, inf, num, sd, r, arg = this, Ctor = arg.constructor, pr = Ctor.precision, rm = Ctor.rounding, guard = 5;
|
|
733
|
+
if (base == null) {
|
|
734
|
+
base = new Ctor(10);
|
|
735
|
+
isBase10 = true;
|
|
736
|
+
} else {
|
|
737
|
+
base = new Ctor(base);
|
|
738
|
+
d = base.d;
|
|
739
|
+
if (base.s < 0 || !d || !d[0] || base.eq(1))
|
|
740
|
+
return new Ctor(NaN);
|
|
741
|
+
isBase10 = base.eq(10);
|
|
742
|
+
}
|
|
743
|
+
d = arg.d;
|
|
744
|
+
if (arg.s < 0 || !d || !d[0] || arg.eq(1)) {
|
|
745
|
+
return new Ctor(d && !d[0] ? -1 / 0 : arg.s != 1 ? NaN : d ? 0 : 1 / 0);
|
|
746
|
+
}
|
|
747
|
+
if (isBase10) {
|
|
748
|
+
if (d.length > 1) {
|
|
749
|
+
inf = true;
|
|
750
|
+
} else {
|
|
751
|
+
for (k = d[0]; k % 10 === 0; )
|
|
752
|
+
k /= 10;
|
|
753
|
+
inf = k !== 1;
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
external = false;
|
|
757
|
+
sd = pr + guard;
|
|
758
|
+
num = naturalLogarithm(arg, sd);
|
|
759
|
+
denominator = isBase10 ? getLn10(Ctor, sd + 10) : naturalLogarithm(base, sd);
|
|
760
|
+
r = divide(num, denominator, sd, 1);
|
|
761
|
+
if (checkRoundingDigits(r.d, k = pr, rm)) {
|
|
762
|
+
do {
|
|
763
|
+
sd += 10;
|
|
764
|
+
num = naturalLogarithm(arg, sd);
|
|
765
|
+
denominator = isBase10 ? getLn10(Ctor, sd + 10) : naturalLogarithm(base, sd);
|
|
766
|
+
r = divide(num, denominator, sd, 1);
|
|
767
|
+
if (!inf) {
|
|
768
|
+
if (+digitsToString(r.d).slice(k + 1, k + 15) + 1 == 1e14) {
|
|
769
|
+
r = finalise(r, pr + 1, 0);
|
|
770
|
+
}
|
|
771
|
+
break;
|
|
772
|
+
}
|
|
773
|
+
} while (checkRoundingDigits(r.d, k += 10, rm));
|
|
774
|
+
}
|
|
775
|
+
external = true;
|
|
776
|
+
return finalise(r, pr, rm);
|
|
777
|
+
};
|
|
778
|
+
P.minus = P.sub = function(y) {
|
|
779
|
+
var d, e, i, j, k, len, pr, rm, xd, xe, xLTy, yd, x = this, Ctor = x.constructor;
|
|
780
|
+
y = new Ctor(y);
|
|
781
|
+
if (!x.d || !y.d) {
|
|
782
|
+
if (!x.s || !y.s)
|
|
783
|
+
y = new Ctor(NaN);
|
|
784
|
+
else if (x.d)
|
|
785
|
+
y.s = -y.s;
|
|
786
|
+
else
|
|
787
|
+
y = new Ctor(y.d || x.s !== y.s ? x : NaN);
|
|
788
|
+
return y;
|
|
789
|
+
}
|
|
790
|
+
if (x.s != y.s) {
|
|
791
|
+
y.s = -y.s;
|
|
792
|
+
return x.plus(y);
|
|
793
|
+
}
|
|
794
|
+
xd = x.d;
|
|
795
|
+
yd = y.d;
|
|
796
|
+
pr = Ctor.precision;
|
|
797
|
+
rm = Ctor.rounding;
|
|
798
|
+
if (!xd[0] || !yd[0]) {
|
|
799
|
+
if (yd[0])
|
|
800
|
+
y.s = -y.s;
|
|
801
|
+
else if (xd[0])
|
|
802
|
+
y = new Ctor(x);
|
|
803
|
+
else
|
|
804
|
+
return new Ctor(rm === 3 ? -0 : 0);
|
|
805
|
+
return external ? finalise(y, pr, rm) : y;
|
|
806
|
+
}
|
|
807
|
+
e = mathfloor(y.e / LOG_BASE);
|
|
808
|
+
xe = mathfloor(x.e / LOG_BASE);
|
|
809
|
+
xd = xd.slice();
|
|
810
|
+
k = xe - e;
|
|
811
|
+
if (k) {
|
|
812
|
+
xLTy = k < 0;
|
|
813
|
+
if (xLTy) {
|
|
814
|
+
d = xd;
|
|
815
|
+
k = -k;
|
|
816
|
+
len = yd.length;
|
|
817
|
+
} else {
|
|
818
|
+
d = yd;
|
|
819
|
+
e = xe;
|
|
820
|
+
len = xd.length;
|
|
821
|
+
}
|
|
822
|
+
i = Math.max(Math.ceil(pr / LOG_BASE), len) + 2;
|
|
823
|
+
if (k > i) {
|
|
824
|
+
k = i;
|
|
825
|
+
d.length = 1;
|
|
826
|
+
}
|
|
827
|
+
d.reverse();
|
|
828
|
+
for (i = k; i--; )
|
|
829
|
+
d.push(0);
|
|
830
|
+
d.reverse();
|
|
831
|
+
} else {
|
|
832
|
+
i = xd.length;
|
|
833
|
+
len = yd.length;
|
|
834
|
+
xLTy = i < len;
|
|
835
|
+
if (xLTy)
|
|
836
|
+
len = i;
|
|
837
|
+
for (i = 0; i < len; i++) {
|
|
838
|
+
if (xd[i] != yd[i]) {
|
|
839
|
+
xLTy = xd[i] < yd[i];
|
|
840
|
+
break;
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
k = 0;
|
|
844
|
+
}
|
|
845
|
+
if (xLTy) {
|
|
846
|
+
d = xd;
|
|
847
|
+
xd = yd;
|
|
848
|
+
yd = d;
|
|
849
|
+
y.s = -y.s;
|
|
850
|
+
}
|
|
851
|
+
len = xd.length;
|
|
852
|
+
for (i = yd.length - len; i > 0; --i)
|
|
853
|
+
xd[len++] = 0;
|
|
854
|
+
for (i = yd.length; i > k; ) {
|
|
855
|
+
if (xd[--i] < yd[i]) {
|
|
856
|
+
for (j = i; j && xd[--j] === 0; )
|
|
857
|
+
xd[j] = BASE - 1;
|
|
858
|
+
--xd[j];
|
|
859
|
+
xd[i] += BASE;
|
|
860
|
+
}
|
|
861
|
+
xd[i] -= yd[i];
|
|
862
|
+
}
|
|
863
|
+
for (; xd[--len] === 0; )
|
|
864
|
+
xd.pop();
|
|
865
|
+
for (; xd[0] === 0; xd.shift())
|
|
866
|
+
--e;
|
|
867
|
+
if (!xd[0])
|
|
868
|
+
return new Ctor(rm === 3 ? -0 : 0);
|
|
869
|
+
y.d = xd;
|
|
870
|
+
y.e = getBase10Exponent(xd, e);
|
|
871
|
+
return external ? finalise(y, pr, rm) : y;
|
|
872
|
+
};
|
|
873
|
+
P.modulo = P.mod = function(y) {
|
|
874
|
+
var q, x = this, Ctor = x.constructor;
|
|
875
|
+
y = new Ctor(y);
|
|
876
|
+
if (!x.d || !y.s || y.d && !y.d[0])
|
|
877
|
+
return new Ctor(NaN);
|
|
878
|
+
if (!y.d || x.d && !x.d[0]) {
|
|
879
|
+
return finalise(new Ctor(x), Ctor.precision, Ctor.rounding);
|
|
880
|
+
}
|
|
881
|
+
external = false;
|
|
882
|
+
if (Ctor.modulo == 9) {
|
|
883
|
+
q = divide(x, y.abs(), 0, 3, 1);
|
|
884
|
+
q.s *= y.s;
|
|
885
|
+
} else {
|
|
886
|
+
q = divide(x, y, 0, Ctor.modulo, 1);
|
|
887
|
+
}
|
|
888
|
+
q = q.times(y);
|
|
889
|
+
external = true;
|
|
890
|
+
return x.minus(q);
|
|
891
|
+
};
|
|
892
|
+
P.naturalExponential = P.exp = function() {
|
|
893
|
+
return naturalExponential(this);
|
|
894
|
+
};
|
|
895
|
+
P.naturalLogarithm = P.ln = function() {
|
|
896
|
+
return naturalLogarithm(this);
|
|
897
|
+
};
|
|
898
|
+
P.negated = P.neg = function() {
|
|
899
|
+
var x = new this.constructor(this);
|
|
900
|
+
x.s = -x.s;
|
|
901
|
+
return finalise(x);
|
|
902
|
+
};
|
|
903
|
+
P.plus = P.add = function(y) {
|
|
904
|
+
var carry, d, e, i, k, len, pr, rm, xd, yd, x = this, Ctor = x.constructor;
|
|
905
|
+
y = new Ctor(y);
|
|
906
|
+
if (!x.d || !y.d) {
|
|
907
|
+
if (!x.s || !y.s)
|
|
908
|
+
y = new Ctor(NaN);
|
|
909
|
+
else if (!x.d)
|
|
910
|
+
y = new Ctor(y.d || x.s === y.s ? x : NaN);
|
|
911
|
+
return y;
|
|
912
|
+
}
|
|
913
|
+
if (x.s != y.s) {
|
|
914
|
+
y.s = -y.s;
|
|
915
|
+
return x.minus(y);
|
|
916
|
+
}
|
|
917
|
+
xd = x.d;
|
|
918
|
+
yd = y.d;
|
|
919
|
+
pr = Ctor.precision;
|
|
920
|
+
rm = Ctor.rounding;
|
|
921
|
+
if (!xd[0] || !yd[0]) {
|
|
922
|
+
if (!yd[0])
|
|
923
|
+
y = new Ctor(x);
|
|
924
|
+
return external ? finalise(y, pr, rm) : y;
|
|
925
|
+
}
|
|
926
|
+
k = mathfloor(x.e / LOG_BASE);
|
|
927
|
+
e = mathfloor(y.e / LOG_BASE);
|
|
928
|
+
xd = xd.slice();
|
|
929
|
+
i = k - e;
|
|
930
|
+
if (i) {
|
|
931
|
+
if (i < 0) {
|
|
932
|
+
d = xd;
|
|
933
|
+
i = -i;
|
|
934
|
+
len = yd.length;
|
|
935
|
+
} else {
|
|
936
|
+
d = yd;
|
|
937
|
+
e = k;
|
|
938
|
+
len = xd.length;
|
|
939
|
+
}
|
|
940
|
+
k = Math.ceil(pr / LOG_BASE);
|
|
941
|
+
len = k > len ? k + 1 : len + 1;
|
|
942
|
+
if (i > len) {
|
|
943
|
+
i = len;
|
|
944
|
+
d.length = 1;
|
|
945
|
+
}
|
|
946
|
+
d.reverse();
|
|
947
|
+
for (; i--; )
|
|
948
|
+
d.push(0);
|
|
949
|
+
d.reverse();
|
|
950
|
+
}
|
|
951
|
+
len = xd.length;
|
|
952
|
+
i = yd.length;
|
|
953
|
+
if (len - i < 0) {
|
|
954
|
+
i = len;
|
|
955
|
+
d = yd;
|
|
956
|
+
yd = xd;
|
|
957
|
+
xd = d;
|
|
958
|
+
}
|
|
959
|
+
for (carry = 0; i; ) {
|
|
960
|
+
carry = (xd[--i] = xd[i] + yd[i] + carry) / BASE | 0;
|
|
961
|
+
xd[i] %= BASE;
|
|
962
|
+
}
|
|
963
|
+
if (carry) {
|
|
964
|
+
xd.unshift(carry);
|
|
965
|
+
++e;
|
|
966
|
+
}
|
|
967
|
+
for (len = xd.length; xd[--len] == 0; )
|
|
968
|
+
xd.pop();
|
|
969
|
+
y.d = xd;
|
|
970
|
+
y.e = getBase10Exponent(xd, e);
|
|
971
|
+
return external ? finalise(y, pr, rm) : y;
|
|
972
|
+
};
|
|
973
|
+
P.precision = P.sd = function(z) {
|
|
974
|
+
var k, x = this;
|
|
975
|
+
if (z !== void 0 && z !== !!z && z !== 1 && z !== 0)
|
|
976
|
+
throw Error(invalidArgument + z);
|
|
977
|
+
if (x.d) {
|
|
978
|
+
k = getPrecision(x.d);
|
|
979
|
+
if (z && x.e + 1 > k)
|
|
980
|
+
k = x.e + 1;
|
|
981
|
+
} else {
|
|
982
|
+
k = NaN;
|
|
983
|
+
}
|
|
984
|
+
return k;
|
|
985
|
+
};
|
|
986
|
+
P.round = function() {
|
|
987
|
+
var x = this, Ctor = x.constructor;
|
|
988
|
+
return finalise(new Ctor(x), x.e + 1, Ctor.rounding);
|
|
989
|
+
};
|
|
990
|
+
P.sine = P.sin = function() {
|
|
991
|
+
var pr, rm, x = this, Ctor = x.constructor;
|
|
992
|
+
if (!x.isFinite())
|
|
993
|
+
return new Ctor(NaN);
|
|
994
|
+
if (x.isZero())
|
|
995
|
+
return new Ctor(x);
|
|
996
|
+
pr = Ctor.precision;
|
|
997
|
+
rm = Ctor.rounding;
|
|
998
|
+
Ctor.precision = pr + Math.max(x.e, x.sd()) + LOG_BASE;
|
|
999
|
+
Ctor.rounding = 1;
|
|
1000
|
+
x = sine(Ctor, toLessThanHalfPi(Ctor, x));
|
|
1001
|
+
Ctor.precision = pr;
|
|
1002
|
+
Ctor.rounding = rm;
|
|
1003
|
+
return finalise(quadrant > 2 ? x.neg() : x, pr, rm, true);
|
|
1004
|
+
};
|
|
1005
|
+
P.squareRoot = P.sqrt = function() {
|
|
1006
|
+
var m, n, sd, r, rep, t, x = this, d = x.d, e = x.e, s = x.s, Ctor = x.constructor;
|
|
1007
|
+
if (s !== 1 || !d || !d[0]) {
|
|
1008
|
+
return new Ctor(!s || s < 0 && (!d || d[0]) ? NaN : d ? x : 1 / 0);
|
|
1009
|
+
}
|
|
1010
|
+
external = false;
|
|
1011
|
+
s = Math.sqrt(+x);
|
|
1012
|
+
if (s == 0 || s == 1 / 0) {
|
|
1013
|
+
n = digitsToString(d);
|
|
1014
|
+
if ((n.length + e) % 2 == 0)
|
|
1015
|
+
n += "0";
|
|
1016
|
+
s = Math.sqrt(n);
|
|
1017
|
+
e = mathfloor((e + 1) / 2) - (e < 0 || e % 2);
|
|
1018
|
+
if (s == 1 / 0) {
|
|
1019
|
+
n = "5e" + e;
|
|
1020
|
+
} else {
|
|
1021
|
+
n = s.toExponential();
|
|
1022
|
+
n = n.slice(0, n.indexOf("e") + 1) + e;
|
|
1023
|
+
}
|
|
1024
|
+
r = new Ctor(n);
|
|
1025
|
+
} else {
|
|
1026
|
+
r = new Ctor(s.toString());
|
|
1027
|
+
}
|
|
1028
|
+
sd = (e = Ctor.precision) + 3;
|
|
1029
|
+
for (; ; ) {
|
|
1030
|
+
t = r;
|
|
1031
|
+
r = t.plus(divide(x, t, sd + 2, 1)).times(0.5);
|
|
1032
|
+
if (digitsToString(t.d).slice(0, sd) === (n = digitsToString(r.d)).slice(0, sd)) {
|
|
1033
|
+
n = n.slice(sd - 3, sd + 1);
|
|
1034
|
+
if (n == "9999" || !rep && n == "4999") {
|
|
1035
|
+
if (!rep) {
|
|
1036
|
+
finalise(t, e + 1, 0);
|
|
1037
|
+
if (t.times(t).eq(x)) {
|
|
1038
|
+
r = t;
|
|
1039
|
+
break;
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
sd += 4;
|
|
1043
|
+
rep = 1;
|
|
1044
|
+
} else {
|
|
1045
|
+
if (!+n || !+n.slice(1) && n.charAt(0) == "5") {
|
|
1046
|
+
finalise(r, e + 1, 1);
|
|
1047
|
+
m = !r.times(r).eq(x);
|
|
1048
|
+
}
|
|
1049
|
+
break;
|
|
1050
|
+
}
|
|
1051
|
+
}
|
|
1052
|
+
}
|
|
1053
|
+
external = true;
|
|
1054
|
+
return finalise(r, e, Ctor.rounding, m);
|
|
1055
|
+
};
|
|
1056
|
+
P.tangent = P.tan = function() {
|
|
1057
|
+
var pr, rm, x = this, Ctor = x.constructor;
|
|
1058
|
+
if (!x.isFinite())
|
|
1059
|
+
return new Ctor(NaN);
|
|
1060
|
+
if (x.isZero())
|
|
1061
|
+
return new Ctor(x);
|
|
1062
|
+
pr = Ctor.precision;
|
|
1063
|
+
rm = Ctor.rounding;
|
|
1064
|
+
Ctor.precision = pr + 10;
|
|
1065
|
+
Ctor.rounding = 1;
|
|
1066
|
+
x = x.sin();
|
|
1067
|
+
x.s = 1;
|
|
1068
|
+
x = divide(x, new Ctor(1).minus(x.times(x)).sqrt(), pr + 10, 0);
|
|
1069
|
+
Ctor.precision = pr;
|
|
1070
|
+
Ctor.rounding = rm;
|
|
1071
|
+
return finalise(quadrant == 2 || quadrant == 4 ? x.neg() : x, pr, rm, true);
|
|
1072
|
+
};
|
|
1073
|
+
P.times = P.mul = function(y) {
|
|
1074
|
+
var carry, e, i, k, r, rL, t, xdL, ydL, x = this, Ctor = x.constructor, xd = x.d, yd = (y = new Ctor(y)).d;
|
|
1075
|
+
y.s *= x.s;
|
|
1076
|
+
if (!xd || !xd[0] || !yd || !yd[0]) {
|
|
1077
|
+
return new Ctor(!y.s || xd && !xd[0] && !yd || yd && !yd[0] && !xd ? NaN : !xd || !yd ? y.s / 0 : y.s * 0);
|
|
1078
|
+
}
|
|
1079
|
+
e = mathfloor(x.e / LOG_BASE) + mathfloor(y.e / LOG_BASE);
|
|
1080
|
+
xdL = xd.length;
|
|
1081
|
+
ydL = yd.length;
|
|
1082
|
+
if (xdL < ydL) {
|
|
1083
|
+
r = xd;
|
|
1084
|
+
xd = yd;
|
|
1085
|
+
yd = r;
|
|
1086
|
+
rL = xdL;
|
|
1087
|
+
xdL = ydL;
|
|
1088
|
+
ydL = rL;
|
|
1089
|
+
}
|
|
1090
|
+
r = [];
|
|
1091
|
+
rL = xdL + ydL;
|
|
1092
|
+
for (i = rL; i--; )
|
|
1093
|
+
r.push(0);
|
|
1094
|
+
for (i = ydL; --i >= 0; ) {
|
|
1095
|
+
carry = 0;
|
|
1096
|
+
for (k = xdL + i; k > i; ) {
|
|
1097
|
+
t = r[k] + yd[i] * xd[k - i - 1] + carry;
|
|
1098
|
+
r[k--] = t % BASE | 0;
|
|
1099
|
+
carry = t / BASE | 0;
|
|
1100
|
+
}
|
|
1101
|
+
r[k] = (r[k] + carry) % BASE | 0;
|
|
1102
|
+
}
|
|
1103
|
+
for (; !r[--rL]; )
|
|
1104
|
+
r.pop();
|
|
1105
|
+
if (carry)
|
|
1106
|
+
++e;
|
|
1107
|
+
else
|
|
1108
|
+
r.shift();
|
|
1109
|
+
y.d = r;
|
|
1110
|
+
y.e = getBase10Exponent(r, e);
|
|
1111
|
+
return external ? finalise(y, Ctor.precision, Ctor.rounding) : y;
|
|
1112
|
+
};
|
|
1113
|
+
P.toBinary = function(sd, rm) {
|
|
1114
|
+
return toStringBinary(this, 2, sd, rm);
|
|
1115
|
+
};
|
|
1116
|
+
P.toDecimalPlaces = P.toDP = function(dp, rm) {
|
|
1117
|
+
var x = this, Ctor = x.constructor;
|
|
1118
|
+
x = new Ctor(x);
|
|
1119
|
+
if (dp === void 0)
|
|
1120
|
+
return x;
|
|
1121
|
+
checkInt32(dp, 0, MAX_DIGITS);
|
|
1122
|
+
if (rm === void 0)
|
|
1123
|
+
rm = Ctor.rounding;
|
|
1124
|
+
else
|
|
1125
|
+
checkInt32(rm, 0, 8);
|
|
1126
|
+
return finalise(x, dp + x.e + 1, rm);
|
|
1127
|
+
};
|
|
1128
|
+
P.toExponential = function(dp, rm) {
|
|
1129
|
+
var str, x = this, Ctor = x.constructor;
|
|
1130
|
+
if (dp === void 0) {
|
|
1131
|
+
str = finiteToString(x, true);
|
|
1132
|
+
} else {
|
|
1133
|
+
checkInt32(dp, 0, MAX_DIGITS);
|
|
1134
|
+
if (rm === void 0)
|
|
1135
|
+
rm = Ctor.rounding;
|
|
1136
|
+
else
|
|
1137
|
+
checkInt32(rm, 0, 8);
|
|
1138
|
+
x = finalise(new Ctor(x), dp + 1, rm);
|
|
1139
|
+
str = finiteToString(x, true, dp + 1);
|
|
1140
|
+
}
|
|
1141
|
+
return x.isNeg() && !x.isZero() ? "-" + str : str;
|
|
1142
|
+
};
|
|
1143
|
+
P.toFixed = function(dp, rm) {
|
|
1144
|
+
var str, y, x = this, Ctor = x.constructor;
|
|
1145
|
+
if (dp === void 0) {
|
|
1146
|
+
str = finiteToString(x);
|
|
1147
|
+
} else {
|
|
1148
|
+
checkInt32(dp, 0, MAX_DIGITS);
|
|
1149
|
+
if (rm === void 0)
|
|
1150
|
+
rm = Ctor.rounding;
|
|
1151
|
+
else
|
|
1152
|
+
checkInt32(rm, 0, 8);
|
|
1153
|
+
y = finalise(new Ctor(x), dp + x.e + 1, rm);
|
|
1154
|
+
str = finiteToString(y, false, dp + y.e + 1);
|
|
1155
|
+
}
|
|
1156
|
+
return x.isNeg() && !x.isZero() ? "-" + str : str;
|
|
1157
|
+
};
|
|
1158
|
+
P.toFraction = function(maxD) {
|
|
1159
|
+
var d, d0, d1, d2, e, k, n, n0, n1, pr, q, r, x = this, xd = x.d, Ctor = x.constructor;
|
|
1160
|
+
if (!xd)
|
|
1161
|
+
return new Ctor(x);
|
|
1162
|
+
n1 = d0 = new Ctor(1);
|
|
1163
|
+
d1 = n0 = new Ctor(0);
|
|
1164
|
+
d = new Ctor(d1);
|
|
1165
|
+
e = d.e = getPrecision(xd) - x.e - 1;
|
|
1166
|
+
k = e % LOG_BASE;
|
|
1167
|
+
d.d[0] = mathpow(10, k < 0 ? LOG_BASE + k : k);
|
|
1168
|
+
if (maxD == null) {
|
|
1169
|
+
maxD = e > 0 ? d : n1;
|
|
1170
|
+
} else {
|
|
1171
|
+
n = new Ctor(maxD);
|
|
1172
|
+
if (!n.isInt() || n.lt(n1))
|
|
1173
|
+
throw Error(invalidArgument + n);
|
|
1174
|
+
maxD = n.gt(d) ? e > 0 ? d : n1 : n;
|
|
1175
|
+
}
|
|
1176
|
+
external = false;
|
|
1177
|
+
n = new Ctor(digitsToString(xd));
|
|
1178
|
+
pr = Ctor.precision;
|
|
1179
|
+
Ctor.precision = e = xd.length * LOG_BASE * 2;
|
|
1180
|
+
for (; ; ) {
|
|
1181
|
+
q = divide(n, d, 0, 1, 1);
|
|
1182
|
+
d2 = d0.plus(q.times(d1));
|
|
1183
|
+
if (d2.cmp(maxD) == 1)
|
|
1184
|
+
break;
|
|
1185
|
+
d0 = d1;
|
|
1186
|
+
d1 = d2;
|
|
1187
|
+
d2 = n1;
|
|
1188
|
+
n1 = n0.plus(q.times(d2));
|
|
1189
|
+
n0 = d2;
|
|
1190
|
+
d2 = d;
|
|
1191
|
+
d = n.minus(q.times(d2));
|
|
1192
|
+
n = d2;
|
|
1193
|
+
}
|
|
1194
|
+
d2 = divide(maxD.minus(d0), d1, 0, 1, 1);
|
|
1195
|
+
n0 = n0.plus(d2.times(n1));
|
|
1196
|
+
d0 = d0.plus(d2.times(d1));
|
|
1197
|
+
n0.s = n1.s = x.s;
|
|
1198
|
+
r = divide(n1, d1, e, 1).minus(x).abs().cmp(divide(n0, d0, e, 1).minus(x).abs()) < 1 ? [n1, d1] : [n0, d0];
|
|
1199
|
+
Ctor.precision = pr;
|
|
1200
|
+
external = true;
|
|
1201
|
+
return r;
|
|
1202
|
+
};
|
|
1203
|
+
P.toHexadecimal = P.toHex = function(sd, rm) {
|
|
1204
|
+
return toStringBinary(this, 16, sd, rm);
|
|
1205
|
+
};
|
|
1206
|
+
P.toNearest = function(y, rm) {
|
|
1207
|
+
var x = this, Ctor = x.constructor;
|
|
1208
|
+
x = new Ctor(x);
|
|
1209
|
+
if (y == null) {
|
|
1210
|
+
if (!x.d)
|
|
1211
|
+
return x;
|
|
1212
|
+
y = new Ctor(1);
|
|
1213
|
+
rm = Ctor.rounding;
|
|
1214
|
+
} else {
|
|
1215
|
+
y = new Ctor(y);
|
|
1216
|
+
if (rm === void 0) {
|
|
1217
|
+
rm = Ctor.rounding;
|
|
1218
|
+
} else {
|
|
1219
|
+
checkInt32(rm, 0, 8);
|
|
1220
|
+
}
|
|
1221
|
+
if (!x.d)
|
|
1222
|
+
return y.s ? x : y;
|
|
1223
|
+
if (!y.d) {
|
|
1224
|
+
if (y.s)
|
|
1225
|
+
y.s = x.s;
|
|
1226
|
+
return y;
|
|
1227
|
+
}
|
|
1228
|
+
}
|
|
1229
|
+
if (y.d[0]) {
|
|
1230
|
+
external = false;
|
|
1231
|
+
x = divide(x, y, 0, rm, 1).times(y);
|
|
1232
|
+
external = true;
|
|
1233
|
+
finalise(x);
|
|
1234
|
+
} else {
|
|
1235
|
+
y.s = x.s;
|
|
1236
|
+
x = y;
|
|
1237
|
+
}
|
|
1238
|
+
return x;
|
|
1239
|
+
};
|
|
1240
|
+
P.toNumber = function() {
|
|
1241
|
+
return +this;
|
|
1242
|
+
};
|
|
1243
|
+
P.toOctal = function(sd, rm) {
|
|
1244
|
+
return toStringBinary(this, 8, sd, rm);
|
|
1245
|
+
};
|
|
1246
|
+
P.toPower = P.pow = function(y) {
|
|
1247
|
+
var e, k, pr, r, rm, s, x = this, Ctor = x.constructor, yn = +(y = new Ctor(y));
|
|
1248
|
+
if (!x.d || !y.d || !x.d[0] || !y.d[0])
|
|
1249
|
+
return new Ctor(mathpow(+x, yn));
|
|
1250
|
+
x = new Ctor(x);
|
|
1251
|
+
if (x.eq(1))
|
|
1252
|
+
return x;
|
|
1253
|
+
pr = Ctor.precision;
|
|
1254
|
+
rm = Ctor.rounding;
|
|
1255
|
+
if (y.eq(1))
|
|
1256
|
+
return finalise(x, pr, rm);
|
|
1257
|
+
e = mathfloor(y.e / LOG_BASE);
|
|
1258
|
+
if (e >= y.d.length - 1 && (k = yn < 0 ? -yn : yn) <= MAX_SAFE_INTEGER) {
|
|
1259
|
+
r = intPow(Ctor, x, k, pr);
|
|
1260
|
+
return y.s < 0 ? new Ctor(1).div(r) : finalise(r, pr, rm);
|
|
1261
|
+
}
|
|
1262
|
+
s = x.s;
|
|
1263
|
+
if (s < 0) {
|
|
1264
|
+
if (e < y.d.length - 1)
|
|
1265
|
+
return new Ctor(NaN);
|
|
1266
|
+
if ((y.d[e] & 1) == 0)
|
|
1267
|
+
s = 1;
|
|
1268
|
+
if (x.e == 0 && x.d[0] == 1 && x.d.length == 1) {
|
|
1269
|
+
x.s = s;
|
|
1270
|
+
return x;
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
1273
|
+
k = mathpow(+x, yn);
|
|
1274
|
+
e = k == 0 || !isFinite(k) ? mathfloor(yn * (Math.log("0." + digitsToString(x.d)) / Math.LN10 + x.e + 1)) : new Ctor(k + "").e;
|
|
1275
|
+
if (e > Ctor.maxE + 1 || e < Ctor.minE - 1)
|
|
1276
|
+
return new Ctor(e > 0 ? s / 0 : 0);
|
|
1277
|
+
external = false;
|
|
1278
|
+
Ctor.rounding = x.s = 1;
|
|
1279
|
+
k = Math.min(12, (e + "").length);
|
|
1280
|
+
r = naturalExponential(y.times(naturalLogarithm(x, pr + k)), pr);
|
|
1281
|
+
if (r.d) {
|
|
1282
|
+
r = finalise(r, pr + 5, 1);
|
|
1283
|
+
if (checkRoundingDigits(r.d, pr, rm)) {
|
|
1284
|
+
e = pr + 10;
|
|
1285
|
+
r = finalise(naturalExponential(y.times(naturalLogarithm(x, e + k)), e), e + 5, 1);
|
|
1286
|
+
if (+digitsToString(r.d).slice(pr + 1, pr + 15) + 1 == 1e14) {
|
|
1287
|
+
r = finalise(r, pr + 1, 0);
|
|
1288
|
+
}
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1291
|
+
r.s = s;
|
|
1292
|
+
external = true;
|
|
1293
|
+
Ctor.rounding = rm;
|
|
1294
|
+
return finalise(r, pr, rm);
|
|
1295
|
+
};
|
|
1296
|
+
P.toPrecision = function(sd, rm) {
|
|
1297
|
+
var str, x = this, Ctor = x.constructor;
|
|
1298
|
+
if (sd === void 0) {
|
|
1299
|
+
str = finiteToString(x, x.e <= Ctor.toExpNeg || x.e >= Ctor.toExpPos);
|
|
1300
|
+
} else {
|
|
1301
|
+
checkInt32(sd, 1, MAX_DIGITS);
|
|
1302
|
+
if (rm === void 0)
|
|
1303
|
+
rm = Ctor.rounding;
|
|
1304
|
+
else
|
|
1305
|
+
checkInt32(rm, 0, 8);
|
|
1306
|
+
x = finalise(new Ctor(x), sd, rm);
|
|
1307
|
+
str = finiteToString(x, sd <= x.e || x.e <= Ctor.toExpNeg, sd);
|
|
1308
|
+
}
|
|
1309
|
+
return x.isNeg() && !x.isZero() ? "-" + str : str;
|
|
1310
|
+
};
|
|
1311
|
+
P.toSignificantDigits = P.toSD = function(sd, rm) {
|
|
1312
|
+
var x = this, Ctor = x.constructor;
|
|
1313
|
+
if (sd === void 0) {
|
|
1314
|
+
sd = Ctor.precision;
|
|
1315
|
+
rm = Ctor.rounding;
|
|
1316
|
+
} else {
|
|
1317
|
+
checkInt32(sd, 1, MAX_DIGITS);
|
|
1318
|
+
if (rm === void 0)
|
|
1319
|
+
rm = Ctor.rounding;
|
|
1320
|
+
else
|
|
1321
|
+
checkInt32(rm, 0, 8);
|
|
1322
|
+
}
|
|
1323
|
+
return finalise(new Ctor(x), sd, rm);
|
|
1324
|
+
};
|
|
1325
|
+
P.toString = function() {
|
|
1326
|
+
var x = this, Ctor = x.constructor, str = finiteToString(x, x.e <= Ctor.toExpNeg || x.e >= Ctor.toExpPos);
|
|
1327
|
+
return x.isNeg() && !x.isZero() ? "-" + str : str;
|
|
1328
|
+
};
|
|
1329
|
+
P.truncated = P.trunc = function() {
|
|
1330
|
+
return finalise(new this.constructor(this), this.e + 1, 1);
|
|
1331
|
+
};
|
|
1332
|
+
P.valueOf = P.toJSON = function() {
|
|
1333
|
+
var x = this, Ctor = x.constructor, str = finiteToString(x, x.e <= Ctor.toExpNeg || x.e >= Ctor.toExpPos);
|
|
1334
|
+
return x.isNeg() ? "-" + str : str;
|
|
1335
|
+
};
|
|
1336
|
+
function digitsToString(d) {
|
|
1337
|
+
var i, k, ws, indexOfLastWord = d.length - 1, str = "", w = d[0];
|
|
1338
|
+
if (indexOfLastWord > 0) {
|
|
1339
|
+
str += w;
|
|
1340
|
+
for (i = 1; i < indexOfLastWord; i++) {
|
|
1341
|
+
ws = d[i] + "";
|
|
1342
|
+
k = LOG_BASE - ws.length;
|
|
1343
|
+
if (k)
|
|
1344
|
+
str += getZeroString(k);
|
|
1345
|
+
str += ws;
|
|
1346
|
+
}
|
|
1347
|
+
w = d[i];
|
|
1348
|
+
ws = w + "";
|
|
1349
|
+
k = LOG_BASE - ws.length;
|
|
1350
|
+
if (k)
|
|
1351
|
+
str += getZeroString(k);
|
|
1352
|
+
} else if (w === 0) {
|
|
1353
|
+
return "0";
|
|
1354
|
+
}
|
|
1355
|
+
for (; w % 10 === 0; )
|
|
1356
|
+
w /= 10;
|
|
1357
|
+
return str + w;
|
|
1358
|
+
}
|
|
1359
|
+
function checkInt32(i, min2, max2) {
|
|
1360
|
+
if (i !== ~~i || i < min2 || i > max2) {
|
|
1361
|
+
throw Error(invalidArgument + i);
|
|
1362
|
+
}
|
|
1363
|
+
}
|
|
1364
|
+
function checkRoundingDigits(d, i, rm, repeating) {
|
|
1365
|
+
var di, k, r, rd;
|
|
1366
|
+
for (k = d[0]; k >= 10; k /= 10)
|
|
1367
|
+
--i;
|
|
1368
|
+
if (--i < 0) {
|
|
1369
|
+
i += LOG_BASE;
|
|
1370
|
+
di = 0;
|
|
1371
|
+
} else {
|
|
1372
|
+
di = Math.ceil((i + 1) / LOG_BASE);
|
|
1373
|
+
i %= LOG_BASE;
|
|
1374
|
+
}
|
|
1375
|
+
k = mathpow(10, LOG_BASE - i);
|
|
1376
|
+
rd = d[di] % k | 0;
|
|
1377
|
+
if (repeating == null) {
|
|
1378
|
+
if (i < 3) {
|
|
1379
|
+
if (i == 0)
|
|
1380
|
+
rd = rd / 100 | 0;
|
|
1381
|
+
else if (i == 1)
|
|
1382
|
+
rd = rd / 10 | 0;
|
|
1383
|
+
r = rm < 4 && rd == 99999 || rm > 3 && rd == 49999 || rd == 5e4 || rd == 0;
|
|
1384
|
+
} else {
|
|
1385
|
+
r = (rm < 4 && rd + 1 == k || rm > 3 && rd + 1 == k / 2) && (d[di + 1] / k / 100 | 0) == mathpow(10, i - 2) - 1 || (rd == k / 2 || rd == 0) && (d[di + 1] / k / 100 | 0) == 0;
|
|
1386
|
+
}
|
|
1387
|
+
} else {
|
|
1388
|
+
if (i < 4) {
|
|
1389
|
+
if (i == 0)
|
|
1390
|
+
rd = rd / 1e3 | 0;
|
|
1391
|
+
else if (i == 1)
|
|
1392
|
+
rd = rd / 100 | 0;
|
|
1393
|
+
else if (i == 2)
|
|
1394
|
+
rd = rd / 10 | 0;
|
|
1395
|
+
r = (repeating || rm < 4) && rd == 9999 || !repeating && rm > 3 && rd == 4999;
|
|
1396
|
+
} else {
|
|
1397
|
+
r = ((repeating || rm < 4) && rd + 1 == k || !repeating && rm > 3 && rd + 1 == k / 2) && (d[di + 1] / k / 1e3 | 0) == mathpow(10, i - 3) - 1;
|
|
1398
|
+
}
|
|
1399
|
+
}
|
|
1400
|
+
return r;
|
|
1401
|
+
}
|
|
1402
|
+
function convertBase(str, baseIn, baseOut) {
|
|
1403
|
+
var j, arr = [0], arrL, i = 0, strL = str.length;
|
|
1404
|
+
for (; i < strL; ) {
|
|
1405
|
+
for (arrL = arr.length; arrL--; )
|
|
1406
|
+
arr[arrL] *= baseIn;
|
|
1407
|
+
arr[0] += NUMERALS.indexOf(str.charAt(i++));
|
|
1408
|
+
for (j = 0; j < arr.length; j++) {
|
|
1409
|
+
if (arr[j] > baseOut - 1) {
|
|
1410
|
+
if (arr[j + 1] === void 0)
|
|
1411
|
+
arr[j + 1] = 0;
|
|
1412
|
+
arr[j + 1] += arr[j] / baseOut | 0;
|
|
1413
|
+
arr[j] %= baseOut;
|
|
1414
|
+
}
|
|
1415
|
+
}
|
|
1416
|
+
}
|
|
1417
|
+
return arr.reverse();
|
|
1418
|
+
}
|
|
1419
|
+
function cosine(Ctor, x) {
|
|
1420
|
+
var k, len, y;
|
|
1421
|
+
if (x.isZero())
|
|
1422
|
+
return x;
|
|
1423
|
+
len = x.d.length;
|
|
1424
|
+
if (len < 32) {
|
|
1425
|
+
k = Math.ceil(len / 3);
|
|
1426
|
+
y = (1 / tinyPow(4, k)).toString();
|
|
1427
|
+
} else {
|
|
1428
|
+
k = 16;
|
|
1429
|
+
y = "2.3283064365386962890625e-10";
|
|
1430
|
+
}
|
|
1431
|
+
Ctor.precision += k;
|
|
1432
|
+
x = taylorSeries(Ctor, 1, x.times(y), new Ctor(1));
|
|
1433
|
+
for (var i = k; i--; ) {
|
|
1434
|
+
var cos2x = x.times(x);
|
|
1435
|
+
x = cos2x.times(cos2x).minus(cos2x).times(8).plus(1);
|
|
1436
|
+
}
|
|
1437
|
+
Ctor.precision -= k;
|
|
1438
|
+
return x;
|
|
1439
|
+
}
|
|
1440
|
+
var divide = function() {
|
|
1441
|
+
function multiplyInteger(x, k, base) {
|
|
1442
|
+
var temp, carry = 0, i = x.length;
|
|
1443
|
+
for (x = x.slice(); i--; ) {
|
|
1444
|
+
temp = x[i] * k + carry;
|
|
1445
|
+
x[i] = temp % base | 0;
|
|
1446
|
+
carry = temp / base | 0;
|
|
1447
|
+
}
|
|
1448
|
+
if (carry)
|
|
1449
|
+
x.unshift(carry);
|
|
1450
|
+
return x;
|
|
1451
|
+
}
|
|
1452
|
+
function compare(a, b, aL, bL) {
|
|
1453
|
+
var i, r;
|
|
1454
|
+
if (aL != bL) {
|
|
1455
|
+
r = aL > bL ? 1 : -1;
|
|
1456
|
+
} else {
|
|
1457
|
+
for (i = r = 0; i < aL; i++) {
|
|
1458
|
+
if (a[i] != b[i]) {
|
|
1459
|
+
r = a[i] > b[i] ? 1 : -1;
|
|
1460
|
+
break;
|
|
1461
|
+
}
|
|
1462
|
+
}
|
|
1463
|
+
}
|
|
1464
|
+
return r;
|
|
1465
|
+
}
|
|
1466
|
+
function subtract(a, b, aL, base) {
|
|
1467
|
+
var i = 0;
|
|
1468
|
+
for (; aL--; ) {
|
|
1469
|
+
a[aL] -= i;
|
|
1470
|
+
i = a[aL] < b[aL] ? 1 : 0;
|
|
1471
|
+
a[aL] = i * base + a[aL] - b[aL];
|
|
1472
|
+
}
|
|
1473
|
+
for (; !a[0] && a.length > 1; )
|
|
1474
|
+
a.shift();
|
|
1475
|
+
}
|
|
1476
|
+
return function(x, y, pr, rm, dp, base) {
|
|
1477
|
+
var cmp, e, i, k, logBase, more, prod, prodL, q, qd, rem, remL, rem0, sd, t, xi, xL, yd0, yL, yz, Ctor = x.constructor, sign2 = x.s == y.s ? 1 : -1, xd = x.d, yd = y.d;
|
|
1478
|
+
if (!xd || !xd[0] || !yd || !yd[0]) {
|
|
1479
|
+
return new Ctor(
|
|
1480
|
+
// Return NaN if either NaN, or both Infinity or 0.
|
|
1481
|
+
!x.s || !y.s || (xd ? yd && xd[0] == yd[0] : !yd) ? NaN : (
|
|
1482
|
+
// Return ±0 if x is 0 or y is ±Infinity, or return ±Infinity as y is 0.
|
|
1483
|
+
xd && xd[0] == 0 || !yd ? sign2 * 0 : sign2 / 0
|
|
1484
|
+
)
|
|
1485
|
+
);
|
|
1486
|
+
}
|
|
1487
|
+
if (base) {
|
|
1488
|
+
logBase = 1;
|
|
1489
|
+
e = x.e - y.e;
|
|
1490
|
+
} else {
|
|
1491
|
+
base = BASE;
|
|
1492
|
+
logBase = LOG_BASE;
|
|
1493
|
+
e = mathfloor(x.e / logBase) - mathfloor(y.e / logBase);
|
|
1494
|
+
}
|
|
1495
|
+
yL = yd.length;
|
|
1496
|
+
xL = xd.length;
|
|
1497
|
+
q = new Ctor(sign2);
|
|
1498
|
+
qd = q.d = [];
|
|
1499
|
+
for (i = 0; yd[i] == (xd[i] || 0); i++)
|
|
1500
|
+
;
|
|
1501
|
+
if (yd[i] > (xd[i] || 0))
|
|
1502
|
+
e--;
|
|
1503
|
+
if (pr == null) {
|
|
1504
|
+
sd = pr = Ctor.precision;
|
|
1505
|
+
rm = Ctor.rounding;
|
|
1506
|
+
} else if (dp) {
|
|
1507
|
+
sd = pr + (x.e - y.e) + 1;
|
|
1508
|
+
} else {
|
|
1509
|
+
sd = pr;
|
|
1510
|
+
}
|
|
1511
|
+
if (sd < 0) {
|
|
1512
|
+
qd.push(1);
|
|
1513
|
+
more = true;
|
|
1514
|
+
} else {
|
|
1515
|
+
sd = sd / logBase + 2 | 0;
|
|
1516
|
+
i = 0;
|
|
1517
|
+
if (yL == 1) {
|
|
1518
|
+
k = 0;
|
|
1519
|
+
yd = yd[0];
|
|
1520
|
+
sd++;
|
|
1521
|
+
for (; (i < xL || k) && sd--; i++) {
|
|
1522
|
+
t = k * base + (xd[i] || 0);
|
|
1523
|
+
qd[i] = t / yd | 0;
|
|
1524
|
+
k = t % yd | 0;
|
|
1525
|
+
}
|
|
1526
|
+
more = k || i < xL;
|
|
1527
|
+
} else {
|
|
1528
|
+
k = base / (yd[0] + 1) | 0;
|
|
1529
|
+
if (k > 1) {
|
|
1530
|
+
yd = multiplyInteger(yd, k, base);
|
|
1531
|
+
xd = multiplyInteger(xd, k, base);
|
|
1532
|
+
yL = yd.length;
|
|
1533
|
+
xL = xd.length;
|
|
1534
|
+
}
|
|
1535
|
+
xi = yL;
|
|
1536
|
+
rem = xd.slice(0, yL);
|
|
1537
|
+
remL = rem.length;
|
|
1538
|
+
for (; remL < yL; )
|
|
1539
|
+
rem[remL++] = 0;
|
|
1540
|
+
yz = yd.slice();
|
|
1541
|
+
yz.unshift(0);
|
|
1542
|
+
yd0 = yd[0];
|
|
1543
|
+
if (yd[1] >= base / 2)
|
|
1544
|
+
++yd0;
|
|
1545
|
+
do {
|
|
1546
|
+
k = 0;
|
|
1547
|
+
cmp = compare(yd, rem, yL, remL);
|
|
1548
|
+
if (cmp < 0) {
|
|
1549
|
+
rem0 = rem[0];
|
|
1550
|
+
if (yL != remL)
|
|
1551
|
+
rem0 = rem0 * base + (rem[1] || 0);
|
|
1552
|
+
k = rem0 / yd0 | 0;
|
|
1553
|
+
if (k > 1) {
|
|
1554
|
+
if (k >= base)
|
|
1555
|
+
k = base - 1;
|
|
1556
|
+
prod = multiplyInteger(yd, k, base);
|
|
1557
|
+
prodL = prod.length;
|
|
1558
|
+
remL = rem.length;
|
|
1559
|
+
cmp = compare(prod, rem, prodL, remL);
|
|
1560
|
+
if (cmp == 1) {
|
|
1561
|
+
k--;
|
|
1562
|
+
subtract(prod, yL < prodL ? yz : yd, prodL, base);
|
|
1563
|
+
}
|
|
1564
|
+
} else {
|
|
1565
|
+
if (k == 0)
|
|
1566
|
+
cmp = k = 1;
|
|
1567
|
+
prod = yd.slice();
|
|
1568
|
+
}
|
|
1569
|
+
prodL = prod.length;
|
|
1570
|
+
if (prodL < remL)
|
|
1571
|
+
prod.unshift(0);
|
|
1572
|
+
subtract(rem, prod, remL, base);
|
|
1573
|
+
if (cmp == -1) {
|
|
1574
|
+
remL = rem.length;
|
|
1575
|
+
cmp = compare(yd, rem, yL, remL);
|
|
1576
|
+
if (cmp < 1) {
|
|
1577
|
+
k++;
|
|
1578
|
+
subtract(rem, yL < remL ? yz : yd, remL, base);
|
|
1579
|
+
}
|
|
1580
|
+
}
|
|
1581
|
+
remL = rem.length;
|
|
1582
|
+
} else if (cmp === 0) {
|
|
1583
|
+
k++;
|
|
1584
|
+
rem = [0];
|
|
1585
|
+
}
|
|
1586
|
+
qd[i++] = k;
|
|
1587
|
+
if (cmp && rem[0]) {
|
|
1588
|
+
rem[remL++] = xd[xi] || 0;
|
|
1589
|
+
} else {
|
|
1590
|
+
rem = [xd[xi]];
|
|
1591
|
+
remL = 1;
|
|
1592
|
+
}
|
|
1593
|
+
} while ((xi++ < xL || rem[0] !== void 0) && sd--);
|
|
1594
|
+
more = rem[0] !== void 0;
|
|
1595
|
+
}
|
|
1596
|
+
if (!qd[0])
|
|
1597
|
+
qd.shift();
|
|
1598
|
+
}
|
|
1599
|
+
if (logBase == 1) {
|
|
1600
|
+
q.e = e;
|
|
1601
|
+
inexact = more;
|
|
1602
|
+
} else {
|
|
1603
|
+
for (i = 1, k = qd[0]; k >= 10; k /= 10)
|
|
1604
|
+
i++;
|
|
1605
|
+
q.e = i + e * logBase - 1;
|
|
1606
|
+
finalise(q, dp ? pr + q.e + 1 : pr, rm, more);
|
|
1607
|
+
}
|
|
1608
|
+
return q;
|
|
1609
|
+
};
|
|
1610
|
+
}();
|
|
1611
|
+
function finalise(x, sd, rm, isTruncated) {
|
|
1612
|
+
var digits, i, j, k, rd, roundUp, w, xd, xdi, Ctor = x.constructor;
|
|
1613
|
+
out:
|
|
1614
|
+
if (sd != null) {
|
|
1615
|
+
xd = x.d;
|
|
1616
|
+
if (!xd)
|
|
1617
|
+
return x;
|
|
1618
|
+
for (digits = 1, k = xd[0]; k >= 10; k /= 10)
|
|
1619
|
+
digits++;
|
|
1620
|
+
i = sd - digits;
|
|
1621
|
+
if (i < 0) {
|
|
1622
|
+
i += LOG_BASE;
|
|
1623
|
+
j = sd;
|
|
1624
|
+
w = xd[xdi = 0];
|
|
1625
|
+
rd = w / mathpow(10, digits - j - 1) % 10 | 0;
|
|
1626
|
+
} else {
|
|
1627
|
+
xdi = Math.ceil((i + 1) / LOG_BASE);
|
|
1628
|
+
k = xd.length;
|
|
1629
|
+
if (xdi >= k) {
|
|
1630
|
+
if (isTruncated) {
|
|
1631
|
+
for (; k++ <= xdi; )
|
|
1632
|
+
xd.push(0);
|
|
1633
|
+
w = rd = 0;
|
|
1634
|
+
digits = 1;
|
|
1635
|
+
i %= LOG_BASE;
|
|
1636
|
+
j = i - LOG_BASE + 1;
|
|
1637
|
+
} else {
|
|
1638
|
+
break out;
|
|
1639
|
+
}
|
|
1640
|
+
} else {
|
|
1641
|
+
w = k = xd[xdi];
|
|
1642
|
+
for (digits = 1; k >= 10; k /= 10)
|
|
1643
|
+
digits++;
|
|
1644
|
+
i %= LOG_BASE;
|
|
1645
|
+
j = i - LOG_BASE + digits;
|
|
1646
|
+
rd = j < 0 ? 0 : w / mathpow(10, digits - j - 1) % 10 | 0;
|
|
1647
|
+
}
|
|
1648
|
+
}
|
|
1649
|
+
isTruncated = isTruncated || sd < 0 || xd[xdi + 1] !== void 0 || (j < 0 ? w : w % mathpow(10, digits - j - 1));
|
|
1650
|
+
roundUp = rm < 4 ? (rd || isTruncated) && (rm == 0 || rm == (x.s < 0 ? 3 : 2)) : rd > 5 || rd == 5 && (rm == 4 || isTruncated || rm == 6 && // Check whether the digit to the left of the rounding digit is odd.
|
|
1651
|
+
(i > 0 ? j > 0 ? w / mathpow(10, digits - j) : 0 : xd[xdi - 1]) % 10 & 1 || rm == (x.s < 0 ? 8 : 7));
|
|
1652
|
+
if (sd < 1 || !xd[0]) {
|
|
1653
|
+
xd.length = 0;
|
|
1654
|
+
if (roundUp) {
|
|
1655
|
+
sd -= x.e + 1;
|
|
1656
|
+
xd[0] = mathpow(10, (LOG_BASE - sd % LOG_BASE) % LOG_BASE);
|
|
1657
|
+
x.e = -sd || 0;
|
|
1658
|
+
} else {
|
|
1659
|
+
xd[0] = x.e = 0;
|
|
1660
|
+
}
|
|
1661
|
+
return x;
|
|
1662
|
+
}
|
|
1663
|
+
if (i == 0) {
|
|
1664
|
+
xd.length = xdi;
|
|
1665
|
+
k = 1;
|
|
1666
|
+
xdi--;
|
|
1667
|
+
} else {
|
|
1668
|
+
xd.length = xdi + 1;
|
|
1669
|
+
k = mathpow(10, LOG_BASE - i);
|
|
1670
|
+
xd[xdi] = j > 0 ? (w / mathpow(10, digits - j) % mathpow(10, j) | 0) * k : 0;
|
|
1671
|
+
}
|
|
1672
|
+
if (roundUp) {
|
|
1673
|
+
for (; ; ) {
|
|
1674
|
+
if (xdi == 0) {
|
|
1675
|
+
for (i = 1, j = xd[0]; j >= 10; j /= 10)
|
|
1676
|
+
i++;
|
|
1677
|
+
j = xd[0] += k;
|
|
1678
|
+
for (k = 1; j >= 10; j /= 10)
|
|
1679
|
+
k++;
|
|
1680
|
+
if (i != k) {
|
|
1681
|
+
x.e++;
|
|
1682
|
+
if (xd[0] == BASE)
|
|
1683
|
+
xd[0] = 1;
|
|
1684
|
+
}
|
|
1685
|
+
break;
|
|
1686
|
+
} else {
|
|
1687
|
+
xd[xdi] += k;
|
|
1688
|
+
if (xd[xdi] != BASE)
|
|
1689
|
+
break;
|
|
1690
|
+
xd[xdi--] = 0;
|
|
1691
|
+
k = 1;
|
|
1692
|
+
}
|
|
1693
|
+
}
|
|
1694
|
+
}
|
|
1695
|
+
for (i = xd.length; xd[--i] === 0; )
|
|
1696
|
+
xd.pop();
|
|
1697
|
+
}
|
|
1698
|
+
if (external) {
|
|
1699
|
+
if (x.e > Ctor.maxE) {
|
|
1700
|
+
x.d = null;
|
|
1701
|
+
x.e = NaN;
|
|
1702
|
+
} else if (x.e < Ctor.minE) {
|
|
1703
|
+
x.e = 0;
|
|
1704
|
+
x.d = [0];
|
|
1705
|
+
}
|
|
1706
|
+
}
|
|
1707
|
+
return x;
|
|
1708
|
+
}
|
|
1709
|
+
function finiteToString(x, isExp, sd) {
|
|
1710
|
+
if (!x.isFinite())
|
|
1711
|
+
return nonFiniteToString(x);
|
|
1712
|
+
var k, e = x.e, str = digitsToString(x.d), len = str.length;
|
|
1713
|
+
if (isExp) {
|
|
1714
|
+
if (sd && (k = sd - len) > 0) {
|
|
1715
|
+
str = str.charAt(0) + "." + str.slice(1) + getZeroString(k);
|
|
1716
|
+
} else if (len > 1) {
|
|
1717
|
+
str = str.charAt(0) + "." + str.slice(1);
|
|
1718
|
+
}
|
|
1719
|
+
str = str + (x.e < 0 ? "e" : "e+") + x.e;
|
|
1720
|
+
} else if (e < 0) {
|
|
1721
|
+
str = "0." + getZeroString(-e - 1) + str;
|
|
1722
|
+
if (sd && (k = sd - len) > 0)
|
|
1723
|
+
str += getZeroString(k);
|
|
1724
|
+
} else if (e >= len) {
|
|
1725
|
+
str += getZeroString(e + 1 - len);
|
|
1726
|
+
if (sd && (k = sd - e - 1) > 0)
|
|
1727
|
+
str = str + "." + getZeroString(k);
|
|
1728
|
+
} else {
|
|
1729
|
+
if ((k = e + 1) < len)
|
|
1730
|
+
str = str.slice(0, k) + "." + str.slice(k);
|
|
1731
|
+
if (sd && (k = sd - len) > 0) {
|
|
1732
|
+
if (e + 1 === len)
|
|
1733
|
+
str += ".";
|
|
1734
|
+
str += getZeroString(k);
|
|
1735
|
+
}
|
|
1736
|
+
}
|
|
1737
|
+
return str;
|
|
1738
|
+
}
|
|
1739
|
+
function getBase10Exponent(digits, e) {
|
|
1740
|
+
var w = digits[0];
|
|
1741
|
+
for (e *= LOG_BASE; w >= 10; w /= 10)
|
|
1742
|
+
e++;
|
|
1743
|
+
return e;
|
|
1744
|
+
}
|
|
1745
|
+
function getLn10(Ctor, sd, pr) {
|
|
1746
|
+
if (sd > LN10_PRECISION) {
|
|
1747
|
+
external = true;
|
|
1748
|
+
if (pr)
|
|
1749
|
+
Ctor.precision = pr;
|
|
1750
|
+
throw Error(precisionLimitExceeded);
|
|
1751
|
+
}
|
|
1752
|
+
return finalise(new Ctor(LN10), sd, 1, true);
|
|
1753
|
+
}
|
|
1754
|
+
function getPi(Ctor, sd, rm) {
|
|
1755
|
+
if (sd > PI_PRECISION)
|
|
1756
|
+
throw Error(precisionLimitExceeded);
|
|
1757
|
+
return finalise(new Ctor(PI), sd, rm, true);
|
|
1758
|
+
}
|
|
1759
|
+
function getPrecision(digits) {
|
|
1760
|
+
var w = digits.length - 1, len = w * LOG_BASE + 1;
|
|
1761
|
+
w = digits[w];
|
|
1762
|
+
if (w) {
|
|
1763
|
+
for (; w % 10 == 0; w /= 10)
|
|
1764
|
+
len--;
|
|
1765
|
+
for (w = digits[0]; w >= 10; w /= 10)
|
|
1766
|
+
len++;
|
|
1767
|
+
}
|
|
1768
|
+
return len;
|
|
1769
|
+
}
|
|
1770
|
+
function getZeroString(k) {
|
|
1771
|
+
var zs = "";
|
|
1772
|
+
for (; k--; )
|
|
1773
|
+
zs += "0";
|
|
1774
|
+
return zs;
|
|
1775
|
+
}
|
|
1776
|
+
function intPow(Ctor, x, n, pr) {
|
|
1777
|
+
var isTruncated, r = new Ctor(1), k = Math.ceil(pr / LOG_BASE + 4);
|
|
1778
|
+
external = false;
|
|
1779
|
+
for (; ; ) {
|
|
1780
|
+
if (n % 2) {
|
|
1781
|
+
r = r.times(x);
|
|
1782
|
+
if (truncate(r.d, k))
|
|
1783
|
+
isTruncated = true;
|
|
1784
|
+
}
|
|
1785
|
+
n = mathfloor(n / 2);
|
|
1786
|
+
if (n === 0) {
|
|
1787
|
+
n = r.d.length - 1;
|
|
1788
|
+
if (isTruncated && r.d[n] === 0)
|
|
1789
|
+
++r.d[n];
|
|
1790
|
+
break;
|
|
1791
|
+
}
|
|
1792
|
+
x = x.times(x);
|
|
1793
|
+
truncate(x.d, k);
|
|
1794
|
+
}
|
|
1795
|
+
external = true;
|
|
1796
|
+
return r;
|
|
1797
|
+
}
|
|
1798
|
+
function isOdd(n) {
|
|
1799
|
+
return n.d[n.d.length - 1] & 1;
|
|
1800
|
+
}
|
|
1801
|
+
function maxOrMin(Ctor, args, ltgt) {
|
|
1802
|
+
var y, x = new Ctor(args[0]), i = 0;
|
|
1803
|
+
for (; ++i < args.length; ) {
|
|
1804
|
+
y = new Ctor(args[i]);
|
|
1805
|
+
if (!y.s) {
|
|
1806
|
+
x = y;
|
|
1807
|
+
break;
|
|
1808
|
+
} else if (x[ltgt](y)) {
|
|
1809
|
+
x = y;
|
|
1810
|
+
}
|
|
1811
|
+
}
|
|
1812
|
+
return x;
|
|
1813
|
+
}
|
|
1814
|
+
function naturalExponential(x, sd) {
|
|
1815
|
+
var denominator, guard, j, pow2, sum2, t, wpr, rep = 0, i = 0, k = 0, Ctor = x.constructor, rm = Ctor.rounding, pr = Ctor.precision;
|
|
1816
|
+
if (!x.d || !x.d[0] || x.e > 17) {
|
|
1817
|
+
return new Ctor(x.d ? !x.d[0] ? 1 : x.s < 0 ? 0 : 1 / 0 : x.s ? x.s < 0 ? 0 : x : 0 / 0);
|
|
1818
|
+
}
|
|
1819
|
+
if (sd == null) {
|
|
1820
|
+
external = false;
|
|
1821
|
+
wpr = pr;
|
|
1822
|
+
} else {
|
|
1823
|
+
wpr = sd;
|
|
1824
|
+
}
|
|
1825
|
+
t = new Ctor(0.03125);
|
|
1826
|
+
while (x.e > -2) {
|
|
1827
|
+
x = x.times(t);
|
|
1828
|
+
k += 5;
|
|
1829
|
+
}
|
|
1830
|
+
guard = Math.log(mathpow(2, k)) / Math.LN10 * 2 + 5 | 0;
|
|
1831
|
+
wpr += guard;
|
|
1832
|
+
denominator = pow2 = sum2 = new Ctor(1);
|
|
1833
|
+
Ctor.precision = wpr;
|
|
1834
|
+
for (; ; ) {
|
|
1835
|
+
pow2 = finalise(pow2.times(x), wpr, 1);
|
|
1836
|
+
denominator = denominator.times(++i);
|
|
1837
|
+
t = sum2.plus(divide(pow2, denominator, wpr, 1));
|
|
1838
|
+
if (digitsToString(t.d).slice(0, wpr) === digitsToString(sum2.d).slice(0, wpr)) {
|
|
1839
|
+
j = k;
|
|
1840
|
+
while (j--)
|
|
1841
|
+
sum2 = finalise(sum2.times(sum2), wpr, 1);
|
|
1842
|
+
if (sd == null) {
|
|
1843
|
+
if (rep < 3 && checkRoundingDigits(sum2.d, wpr - guard, rm, rep)) {
|
|
1844
|
+
Ctor.precision = wpr += 10;
|
|
1845
|
+
denominator = pow2 = t = new Ctor(1);
|
|
1846
|
+
i = 0;
|
|
1847
|
+
rep++;
|
|
1848
|
+
} else {
|
|
1849
|
+
return finalise(sum2, Ctor.precision = pr, rm, external = true);
|
|
1850
|
+
}
|
|
1851
|
+
} else {
|
|
1852
|
+
Ctor.precision = pr;
|
|
1853
|
+
return sum2;
|
|
1854
|
+
}
|
|
1855
|
+
}
|
|
1856
|
+
sum2 = t;
|
|
1857
|
+
}
|
|
1858
|
+
}
|
|
1859
|
+
function naturalLogarithm(y, sd) {
|
|
1860
|
+
var c, c0, denominator, e, numerator, rep, sum2, t, wpr, x1, x2, n = 1, guard = 10, x = y, xd = x.d, Ctor = x.constructor, rm = Ctor.rounding, pr = Ctor.precision;
|
|
1861
|
+
if (x.s < 0 || !xd || !xd[0] || !x.e && xd[0] == 1 && xd.length == 1) {
|
|
1862
|
+
return new Ctor(xd && !xd[0] ? -1 / 0 : x.s != 1 ? NaN : xd ? 0 : x);
|
|
1863
|
+
}
|
|
1864
|
+
if (sd == null) {
|
|
1865
|
+
external = false;
|
|
1866
|
+
wpr = pr;
|
|
1867
|
+
} else {
|
|
1868
|
+
wpr = sd;
|
|
1869
|
+
}
|
|
1870
|
+
Ctor.precision = wpr += guard;
|
|
1871
|
+
c = digitsToString(xd);
|
|
1872
|
+
c0 = c.charAt(0);
|
|
1873
|
+
if (Math.abs(e = x.e) < 15e14) {
|
|
1874
|
+
while (c0 < 7 && c0 != 1 || c0 == 1 && c.charAt(1) > 3) {
|
|
1875
|
+
x = x.times(y);
|
|
1876
|
+
c = digitsToString(x.d);
|
|
1877
|
+
c0 = c.charAt(0);
|
|
1878
|
+
n++;
|
|
1879
|
+
}
|
|
1880
|
+
e = x.e;
|
|
1881
|
+
if (c0 > 1) {
|
|
1882
|
+
x = new Ctor("0." + c);
|
|
1883
|
+
e++;
|
|
1884
|
+
} else {
|
|
1885
|
+
x = new Ctor(c0 + "." + c.slice(1));
|
|
1886
|
+
}
|
|
1887
|
+
} else {
|
|
1888
|
+
t = getLn10(Ctor, wpr + 2, pr).times(e + "");
|
|
1889
|
+
x = naturalLogarithm(new Ctor(c0 + "." + c.slice(1)), wpr - guard).plus(t);
|
|
1890
|
+
Ctor.precision = pr;
|
|
1891
|
+
return sd == null ? finalise(x, pr, rm, external = true) : x;
|
|
1892
|
+
}
|
|
1893
|
+
x1 = x;
|
|
1894
|
+
sum2 = numerator = x = divide(x.minus(1), x.plus(1), wpr, 1);
|
|
1895
|
+
x2 = finalise(x.times(x), wpr, 1);
|
|
1896
|
+
denominator = 3;
|
|
1897
|
+
for (; ; ) {
|
|
1898
|
+
numerator = finalise(numerator.times(x2), wpr, 1);
|
|
1899
|
+
t = sum2.plus(divide(numerator, new Ctor(denominator), wpr, 1));
|
|
1900
|
+
if (digitsToString(t.d).slice(0, wpr) === digitsToString(sum2.d).slice(0, wpr)) {
|
|
1901
|
+
sum2 = sum2.times(2);
|
|
1902
|
+
if (e !== 0)
|
|
1903
|
+
sum2 = sum2.plus(getLn10(Ctor, wpr + 2, pr).times(e + ""));
|
|
1904
|
+
sum2 = divide(sum2, new Ctor(n), wpr, 1);
|
|
1905
|
+
if (sd == null) {
|
|
1906
|
+
if (checkRoundingDigits(sum2.d, wpr - guard, rm, rep)) {
|
|
1907
|
+
Ctor.precision = wpr += guard;
|
|
1908
|
+
t = numerator = x = divide(x1.minus(1), x1.plus(1), wpr, 1);
|
|
1909
|
+
x2 = finalise(x.times(x), wpr, 1);
|
|
1910
|
+
denominator = rep = 1;
|
|
1911
|
+
} else {
|
|
1912
|
+
return finalise(sum2, Ctor.precision = pr, rm, external = true);
|
|
1913
|
+
}
|
|
1914
|
+
} else {
|
|
1915
|
+
Ctor.precision = pr;
|
|
1916
|
+
return sum2;
|
|
1917
|
+
}
|
|
1918
|
+
}
|
|
1919
|
+
sum2 = t;
|
|
1920
|
+
denominator += 2;
|
|
1921
|
+
}
|
|
1922
|
+
}
|
|
1923
|
+
function nonFiniteToString(x) {
|
|
1924
|
+
return String(x.s * x.s / 0);
|
|
1925
|
+
}
|
|
1926
|
+
function parseDecimal(x, str) {
|
|
1927
|
+
var e, i, len;
|
|
1928
|
+
if ((e = str.indexOf(".")) > -1)
|
|
1929
|
+
str = str.replace(".", "");
|
|
1930
|
+
if ((i = str.search(/e/i)) > 0) {
|
|
1931
|
+
if (e < 0)
|
|
1932
|
+
e = i;
|
|
1933
|
+
e += +str.slice(i + 1);
|
|
1934
|
+
str = str.substring(0, i);
|
|
1935
|
+
} else if (e < 0) {
|
|
1936
|
+
e = str.length;
|
|
1937
|
+
}
|
|
1938
|
+
for (i = 0; str.charCodeAt(i) === 48; i++)
|
|
1939
|
+
;
|
|
1940
|
+
for (len = str.length; str.charCodeAt(len - 1) === 48; --len)
|
|
1941
|
+
;
|
|
1942
|
+
str = str.slice(i, len);
|
|
1943
|
+
if (str) {
|
|
1944
|
+
len -= i;
|
|
1945
|
+
x.e = e = e - i - 1;
|
|
1946
|
+
x.d = [];
|
|
1947
|
+
i = (e + 1) % LOG_BASE;
|
|
1948
|
+
if (e < 0)
|
|
1949
|
+
i += LOG_BASE;
|
|
1950
|
+
if (i < len) {
|
|
1951
|
+
if (i)
|
|
1952
|
+
x.d.push(+str.slice(0, i));
|
|
1953
|
+
for (len -= LOG_BASE; i < len; )
|
|
1954
|
+
x.d.push(+str.slice(i, i += LOG_BASE));
|
|
1955
|
+
str = str.slice(i);
|
|
1956
|
+
i = LOG_BASE - str.length;
|
|
1957
|
+
} else {
|
|
1958
|
+
i -= len;
|
|
1959
|
+
}
|
|
1960
|
+
for (; i--; )
|
|
1961
|
+
str += "0";
|
|
1962
|
+
x.d.push(+str);
|
|
1963
|
+
if (external) {
|
|
1964
|
+
if (x.e > x.constructor.maxE) {
|
|
1965
|
+
x.d = null;
|
|
1966
|
+
x.e = NaN;
|
|
1967
|
+
} else if (x.e < x.constructor.minE) {
|
|
1968
|
+
x.e = 0;
|
|
1969
|
+
x.d = [0];
|
|
1970
|
+
}
|
|
1971
|
+
}
|
|
1972
|
+
} else {
|
|
1973
|
+
x.e = 0;
|
|
1974
|
+
x.d = [0];
|
|
1975
|
+
}
|
|
1976
|
+
return x;
|
|
1977
|
+
}
|
|
1978
|
+
function parseOther(x, str) {
|
|
1979
|
+
var base, Ctor, divisor, i, isFloat, len, p, xd, xe;
|
|
1980
|
+
if (str.indexOf("_") > -1) {
|
|
1981
|
+
str = str.replace(/(\d)_(?=\d)/g, "$1");
|
|
1982
|
+
if (isDecimal.test(str))
|
|
1983
|
+
return parseDecimal(x, str);
|
|
1984
|
+
} else if (str === "Infinity" || str === "NaN") {
|
|
1985
|
+
if (!+str)
|
|
1986
|
+
x.s = NaN;
|
|
1987
|
+
x.e = NaN;
|
|
1988
|
+
x.d = null;
|
|
1989
|
+
return x;
|
|
1990
|
+
}
|
|
1991
|
+
if (isHex.test(str)) {
|
|
1992
|
+
base = 16;
|
|
1993
|
+
str = str.toLowerCase();
|
|
1994
|
+
} else if (isBinary.test(str)) {
|
|
1995
|
+
base = 2;
|
|
1996
|
+
} else if (isOctal.test(str)) {
|
|
1997
|
+
base = 8;
|
|
1998
|
+
} else {
|
|
1999
|
+
throw Error(invalidArgument + str);
|
|
2000
|
+
}
|
|
2001
|
+
i = str.search(/p/i);
|
|
2002
|
+
if (i > 0) {
|
|
2003
|
+
p = +str.slice(i + 1);
|
|
2004
|
+
str = str.substring(2, i);
|
|
2005
|
+
} else {
|
|
2006
|
+
str = str.slice(2);
|
|
2007
|
+
}
|
|
2008
|
+
i = str.indexOf(".");
|
|
2009
|
+
isFloat = i >= 0;
|
|
2010
|
+
Ctor = x.constructor;
|
|
2011
|
+
if (isFloat) {
|
|
2012
|
+
str = str.replace(".", "");
|
|
2013
|
+
len = str.length;
|
|
2014
|
+
i = len - i;
|
|
2015
|
+
divisor = intPow(Ctor, new Ctor(base), i, i * 2);
|
|
2016
|
+
}
|
|
2017
|
+
xd = convertBase(str, base, BASE);
|
|
2018
|
+
xe = xd.length - 1;
|
|
2019
|
+
for (i = xe; xd[i] === 0; --i)
|
|
2020
|
+
xd.pop();
|
|
2021
|
+
if (i < 0)
|
|
2022
|
+
return new Ctor(x.s * 0);
|
|
2023
|
+
x.e = getBase10Exponent(xd, xe);
|
|
2024
|
+
x.d = xd;
|
|
2025
|
+
external = false;
|
|
2026
|
+
if (isFloat)
|
|
2027
|
+
x = divide(x, divisor, len * 4);
|
|
2028
|
+
if (p)
|
|
2029
|
+
x = x.times(Math.abs(p) < 54 ? mathpow(2, p) : Decimal.pow(2, p));
|
|
2030
|
+
external = true;
|
|
2031
|
+
return x;
|
|
2032
|
+
}
|
|
2033
|
+
function sine(Ctor, x) {
|
|
2034
|
+
var k, len = x.d.length;
|
|
2035
|
+
if (len < 3) {
|
|
2036
|
+
return x.isZero() ? x : taylorSeries(Ctor, 2, x, x);
|
|
2037
|
+
}
|
|
2038
|
+
k = 1.4 * Math.sqrt(len);
|
|
2039
|
+
k = k > 16 ? 16 : k | 0;
|
|
2040
|
+
x = x.times(1 / tinyPow(5, k));
|
|
2041
|
+
x = taylorSeries(Ctor, 2, x, x);
|
|
2042
|
+
var sin2_x, d5 = new Ctor(5), d16 = new Ctor(16), d20 = new Ctor(20);
|
|
2043
|
+
for (; k--; ) {
|
|
2044
|
+
sin2_x = x.times(x);
|
|
2045
|
+
x = x.times(d5.plus(sin2_x.times(d16.times(sin2_x).minus(d20))));
|
|
2046
|
+
}
|
|
2047
|
+
return x;
|
|
2048
|
+
}
|
|
2049
|
+
function taylorSeries(Ctor, n, x, y, isHyperbolic) {
|
|
2050
|
+
var j, t, u, x2, pr = Ctor.precision, k = Math.ceil(pr / LOG_BASE);
|
|
2051
|
+
external = false;
|
|
2052
|
+
x2 = x.times(x);
|
|
2053
|
+
u = new Ctor(y);
|
|
2054
|
+
for (; ; ) {
|
|
2055
|
+
t = divide(u.times(x2), new Ctor(n++ * n++), pr, 1);
|
|
2056
|
+
u = isHyperbolic ? y.plus(t) : y.minus(t);
|
|
2057
|
+
y = divide(t.times(x2), new Ctor(n++ * n++), pr, 1);
|
|
2058
|
+
t = u.plus(y);
|
|
2059
|
+
if (t.d[k] !== void 0) {
|
|
2060
|
+
for (j = k; t.d[j] === u.d[j] && j--; )
|
|
2061
|
+
;
|
|
2062
|
+
if (j == -1)
|
|
2063
|
+
break;
|
|
2064
|
+
}
|
|
2065
|
+
j = u;
|
|
2066
|
+
u = y;
|
|
2067
|
+
y = t;
|
|
2068
|
+
t = j;
|
|
2069
|
+
}
|
|
2070
|
+
external = true;
|
|
2071
|
+
t.d.length = k + 1;
|
|
2072
|
+
return t;
|
|
2073
|
+
}
|
|
2074
|
+
function tinyPow(b, e) {
|
|
2075
|
+
var n = b;
|
|
2076
|
+
while (--e)
|
|
2077
|
+
n *= b;
|
|
2078
|
+
return n;
|
|
2079
|
+
}
|
|
2080
|
+
function toLessThanHalfPi(Ctor, x) {
|
|
2081
|
+
var t, isNeg = x.s < 0, pi = getPi(Ctor, Ctor.precision, 1), halfPi = pi.times(0.5);
|
|
2082
|
+
x = x.abs();
|
|
2083
|
+
if (x.lte(halfPi)) {
|
|
2084
|
+
quadrant = isNeg ? 4 : 1;
|
|
2085
|
+
return x;
|
|
2086
|
+
}
|
|
2087
|
+
t = x.divToInt(pi);
|
|
2088
|
+
if (t.isZero()) {
|
|
2089
|
+
quadrant = isNeg ? 3 : 2;
|
|
2090
|
+
} else {
|
|
2091
|
+
x = x.minus(t.times(pi));
|
|
2092
|
+
if (x.lte(halfPi)) {
|
|
2093
|
+
quadrant = isOdd(t) ? isNeg ? 2 : 3 : isNeg ? 4 : 1;
|
|
2094
|
+
return x;
|
|
2095
|
+
}
|
|
2096
|
+
quadrant = isOdd(t) ? isNeg ? 1 : 4 : isNeg ? 3 : 2;
|
|
2097
|
+
}
|
|
2098
|
+
return x.minus(pi).abs();
|
|
2099
|
+
}
|
|
2100
|
+
function toStringBinary(x, baseOut, sd, rm) {
|
|
2101
|
+
var base, e, i, k, len, roundUp, str, xd, y, Ctor = x.constructor, isExp = sd !== void 0;
|
|
2102
|
+
if (isExp) {
|
|
2103
|
+
checkInt32(sd, 1, MAX_DIGITS);
|
|
2104
|
+
if (rm === void 0)
|
|
2105
|
+
rm = Ctor.rounding;
|
|
2106
|
+
else
|
|
2107
|
+
checkInt32(rm, 0, 8);
|
|
2108
|
+
} else {
|
|
2109
|
+
sd = Ctor.precision;
|
|
2110
|
+
rm = Ctor.rounding;
|
|
2111
|
+
}
|
|
2112
|
+
if (!x.isFinite()) {
|
|
2113
|
+
str = nonFiniteToString(x);
|
|
2114
|
+
} else {
|
|
2115
|
+
str = finiteToString(x);
|
|
2116
|
+
i = str.indexOf(".");
|
|
2117
|
+
if (isExp) {
|
|
2118
|
+
base = 2;
|
|
2119
|
+
if (baseOut == 16) {
|
|
2120
|
+
sd = sd * 4 - 3;
|
|
2121
|
+
} else if (baseOut == 8) {
|
|
2122
|
+
sd = sd * 3 - 2;
|
|
2123
|
+
}
|
|
2124
|
+
} else {
|
|
2125
|
+
base = baseOut;
|
|
2126
|
+
}
|
|
2127
|
+
if (i >= 0) {
|
|
2128
|
+
str = str.replace(".", "");
|
|
2129
|
+
y = new Ctor(1);
|
|
2130
|
+
y.e = str.length - i;
|
|
2131
|
+
y.d = convertBase(finiteToString(y), 10, base);
|
|
2132
|
+
y.e = y.d.length;
|
|
2133
|
+
}
|
|
2134
|
+
xd = convertBase(str, 10, base);
|
|
2135
|
+
e = len = xd.length;
|
|
2136
|
+
for (; xd[--len] == 0; )
|
|
2137
|
+
xd.pop();
|
|
2138
|
+
if (!xd[0]) {
|
|
2139
|
+
str = isExp ? "0p+0" : "0";
|
|
2140
|
+
} else {
|
|
2141
|
+
if (i < 0) {
|
|
2142
|
+
e--;
|
|
2143
|
+
} else {
|
|
2144
|
+
x = new Ctor(x);
|
|
2145
|
+
x.d = xd;
|
|
2146
|
+
x.e = e;
|
|
2147
|
+
x = divide(x, y, sd, rm, 0, base);
|
|
2148
|
+
xd = x.d;
|
|
2149
|
+
e = x.e;
|
|
2150
|
+
roundUp = inexact;
|
|
2151
|
+
}
|
|
2152
|
+
i = xd[sd];
|
|
2153
|
+
k = base / 2;
|
|
2154
|
+
roundUp = roundUp || xd[sd + 1] !== void 0;
|
|
2155
|
+
roundUp = rm < 4 ? (i !== void 0 || roundUp) && (rm === 0 || rm === (x.s < 0 ? 3 : 2)) : i > k || i === k && (rm === 4 || roundUp || rm === 6 && xd[sd - 1] & 1 || rm === (x.s < 0 ? 8 : 7));
|
|
2156
|
+
xd.length = sd;
|
|
2157
|
+
if (roundUp) {
|
|
2158
|
+
for (; ++xd[--sd] > base - 1; ) {
|
|
2159
|
+
xd[sd] = 0;
|
|
2160
|
+
if (!sd) {
|
|
2161
|
+
++e;
|
|
2162
|
+
xd.unshift(1);
|
|
2163
|
+
}
|
|
2164
|
+
}
|
|
2165
|
+
}
|
|
2166
|
+
for (len = xd.length; !xd[len - 1]; --len)
|
|
2167
|
+
;
|
|
2168
|
+
for (i = 0, str = ""; i < len; i++)
|
|
2169
|
+
str += NUMERALS.charAt(xd[i]);
|
|
2170
|
+
if (isExp) {
|
|
2171
|
+
if (len > 1) {
|
|
2172
|
+
if (baseOut == 16 || baseOut == 8) {
|
|
2173
|
+
i = baseOut == 16 ? 4 : 3;
|
|
2174
|
+
for (--len; len % i; len++)
|
|
2175
|
+
str += "0";
|
|
2176
|
+
xd = convertBase(str, base, baseOut);
|
|
2177
|
+
for (len = xd.length; !xd[len - 1]; --len)
|
|
2178
|
+
;
|
|
2179
|
+
for (i = 1, str = "1."; i < len; i++)
|
|
2180
|
+
str += NUMERALS.charAt(xd[i]);
|
|
2181
|
+
} else {
|
|
2182
|
+
str = str.charAt(0) + "." + str.slice(1);
|
|
2183
|
+
}
|
|
2184
|
+
}
|
|
2185
|
+
str = str + (e < 0 ? "p" : "p+") + e;
|
|
2186
|
+
} else if (e < 0) {
|
|
2187
|
+
for (; ++e; )
|
|
2188
|
+
str = "0" + str;
|
|
2189
|
+
str = "0." + str;
|
|
2190
|
+
} else {
|
|
2191
|
+
if (++e > len)
|
|
2192
|
+
for (e -= len; e--; )
|
|
2193
|
+
str += "0";
|
|
2194
|
+
else if (e < len)
|
|
2195
|
+
str = str.slice(0, e) + "." + str.slice(e);
|
|
2196
|
+
}
|
|
2197
|
+
}
|
|
2198
|
+
str = (baseOut == 16 ? "0x" : baseOut == 2 ? "0b" : baseOut == 8 ? "0o" : "") + str;
|
|
2199
|
+
}
|
|
2200
|
+
return x.s < 0 ? "-" + str : str;
|
|
2201
|
+
}
|
|
2202
|
+
function truncate(arr, len) {
|
|
2203
|
+
if (arr.length > len) {
|
|
2204
|
+
arr.length = len;
|
|
2205
|
+
return true;
|
|
2206
|
+
}
|
|
2207
|
+
}
|
|
2208
|
+
function abs(x) {
|
|
2209
|
+
return new this(x).abs();
|
|
2210
|
+
}
|
|
2211
|
+
function acos(x) {
|
|
2212
|
+
return new this(x).acos();
|
|
2213
|
+
}
|
|
2214
|
+
function acosh(x) {
|
|
2215
|
+
return new this(x).acosh();
|
|
2216
|
+
}
|
|
2217
|
+
function add(x, y) {
|
|
2218
|
+
return new this(x).plus(y);
|
|
2219
|
+
}
|
|
2220
|
+
function asin(x) {
|
|
2221
|
+
return new this(x).asin();
|
|
2222
|
+
}
|
|
2223
|
+
function asinh(x) {
|
|
2224
|
+
return new this(x).asinh();
|
|
2225
|
+
}
|
|
2226
|
+
function atan(x) {
|
|
2227
|
+
return new this(x).atan();
|
|
2228
|
+
}
|
|
2229
|
+
function atanh(x) {
|
|
2230
|
+
return new this(x).atanh();
|
|
2231
|
+
}
|
|
2232
|
+
function atan2(y, x) {
|
|
2233
|
+
y = new this(y);
|
|
2234
|
+
x = new this(x);
|
|
2235
|
+
var r, pr = this.precision, rm = this.rounding, wpr = pr + 4;
|
|
2236
|
+
if (!y.s || !x.s) {
|
|
2237
|
+
r = new this(NaN);
|
|
2238
|
+
} else if (!y.d && !x.d) {
|
|
2239
|
+
r = getPi(this, wpr, 1).times(x.s > 0 ? 0.25 : 0.75);
|
|
2240
|
+
r.s = y.s;
|
|
2241
|
+
} else if (!x.d || y.isZero()) {
|
|
2242
|
+
r = x.s < 0 ? getPi(this, pr, rm) : new this(0);
|
|
2243
|
+
r.s = y.s;
|
|
2244
|
+
} else if (!y.d || x.isZero()) {
|
|
2245
|
+
r = getPi(this, wpr, 1).times(0.5);
|
|
2246
|
+
r.s = y.s;
|
|
2247
|
+
} else if (x.s < 0) {
|
|
2248
|
+
this.precision = wpr;
|
|
2249
|
+
this.rounding = 1;
|
|
2250
|
+
r = this.atan(divide(y, x, wpr, 1));
|
|
2251
|
+
x = getPi(this, wpr, 1);
|
|
2252
|
+
this.precision = pr;
|
|
2253
|
+
this.rounding = rm;
|
|
2254
|
+
r = y.s < 0 ? r.minus(x) : r.plus(x);
|
|
2255
|
+
} else {
|
|
2256
|
+
r = this.atan(divide(y, x, wpr, 1));
|
|
2257
|
+
}
|
|
2258
|
+
return r;
|
|
2259
|
+
}
|
|
2260
|
+
function cbrt(x) {
|
|
2261
|
+
return new this(x).cbrt();
|
|
2262
|
+
}
|
|
2263
|
+
function ceil(x) {
|
|
2264
|
+
return finalise(x = new this(x), x.e + 1, 2);
|
|
2265
|
+
}
|
|
2266
|
+
function clamp(x, min2, max2) {
|
|
2267
|
+
return new this(x).clamp(min2, max2);
|
|
2268
|
+
}
|
|
2269
|
+
function config(obj) {
|
|
2270
|
+
if (!obj || typeof obj !== "object")
|
|
2271
|
+
throw Error(decimalError + "Object expected");
|
|
2272
|
+
var i, p, v, useDefaults = obj.defaults === true, ps = [
|
|
2273
|
+
"precision",
|
|
2274
|
+
1,
|
|
2275
|
+
MAX_DIGITS,
|
|
2276
|
+
"rounding",
|
|
2277
|
+
0,
|
|
2278
|
+
8,
|
|
2279
|
+
"toExpNeg",
|
|
2280
|
+
-EXP_LIMIT,
|
|
2281
|
+
0,
|
|
2282
|
+
"toExpPos",
|
|
2283
|
+
0,
|
|
2284
|
+
EXP_LIMIT,
|
|
2285
|
+
"maxE",
|
|
2286
|
+
0,
|
|
2287
|
+
EXP_LIMIT,
|
|
2288
|
+
"minE",
|
|
2289
|
+
-EXP_LIMIT,
|
|
2290
|
+
0,
|
|
2291
|
+
"modulo",
|
|
2292
|
+
0,
|
|
2293
|
+
9
|
|
2294
|
+
];
|
|
2295
|
+
for (i = 0; i < ps.length; i += 3) {
|
|
2296
|
+
if (p = ps[i], useDefaults)
|
|
2297
|
+
this[p] = DEFAULTS[p];
|
|
2298
|
+
if ((v = obj[p]) !== void 0) {
|
|
2299
|
+
if (mathfloor(v) === v && v >= ps[i + 1] && v <= ps[i + 2])
|
|
2300
|
+
this[p] = v;
|
|
2301
|
+
else
|
|
2302
|
+
throw Error(invalidArgument + p + ": " + v);
|
|
2303
|
+
}
|
|
2304
|
+
}
|
|
2305
|
+
if (p = "crypto", useDefaults)
|
|
2306
|
+
this[p] = DEFAULTS[p];
|
|
2307
|
+
if ((v = obj[p]) !== void 0) {
|
|
2308
|
+
if (v === true || v === false || v === 0 || v === 1) {
|
|
2309
|
+
if (v) {
|
|
2310
|
+
if (typeof crypto != "undefined" && crypto && (crypto.getRandomValues || crypto.randomBytes)) {
|
|
2311
|
+
this[p] = true;
|
|
2312
|
+
} else {
|
|
2313
|
+
throw Error(cryptoUnavailable);
|
|
2314
|
+
}
|
|
2315
|
+
} else {
|
|
2316
|
+
this[p] = false;
|
|
2317
|
+
}
|
|
2318
|
+
} else {
|
|
2319
|
+
throw Error(invalidArgument + p + ": " + v);
|
|
2320
|
+
}
|
|
2321
|
+
}
|
|
2322
|
+
return this;
|
|
2323
|
+
}
|
|
2324
|
+
function cos(x) {
|
|
2325
|
+
return new this(x).cos();
|
|
2326
|
+
}
|
|
2327
|
+
function cosh(x) {
|
|
2328
|
+
return new this(x).cosh();
|
|
2329
|
+
}
|
|
2330
|
+
function clone(obj) {
|
|
2331
|
+
var i, p, ps;
|
|
2332
|
+
function Decimal2(v) {
|
|
2333
|
+
var e, i2, t, x = this;
|
|
2334
|
+
if (!(x instanceof Decimal2))
|
|
2335
|
+
return new Decimal2(v);
|
|
2336
|
+
x.constructor = Decimal2;
|
|
2337
|
+
if (isDecimalInstance(v)) {
|
|
2338
|
+
x.s = v.s;
|
|
2339
|
+
if (external) {
|
|
2340
|
+
if (!v.d || v.e > Decimal2.maxE) {
|
|
2341
|
+
x.e = NaN;
|
|
2342
|
+
x.d = null;
|
|
2343
|
+
} else if (v.e < Decimal2.minE) {
|
|
2344
|
+
x.e = 0;
|
|
2345
|
+
x.d = [0];
|
|
2346
|
+
} else {
|
|
2347
|
+
x.e = v.e;
|
|
2348
|
+
x.d = v.d.slice();
|
|
2349
|
+
}
|
|
2350
|
+
} else {
|
|
2351
|
+
x.e = v.e;
|
|
2352
|
+
x.d = v.d ? v.d.slice() : v.d;
|
|
2353
|
+
}
|
|
2354
|
+
return;
|
|
2355
|
+
}
|
|
2356
|
+
t = typeof v;
|
|
2357
|
+
if (t === "number") {
|
|
2358
|
+
if (v === 0) {
|
|
2359
|
+
x.s = 1 / v < 0 ? -1 : 1;
|
|
2360
|
+
x.e = 0;
|
|
2361
|
+
x.d = [0];
|
|
2362
|
+
return;
|
|
2363
|
+
}
|
|
2364
|
+
if (v < 0) {
|
|
2365
|
+
v = -v;
|
|
2366
|
+
x.s = -1;
|
|
2367
|
+
} else {
|
|
2368
|
+
x.s = 1;
|
|
2369
|
+
}
|
|
2370
|
+
if (v === ~~v && v < 1e7) {
|
|
2371
|
+
for (e = 0, i2 = v; i2 >= 10; i2 /= 10)
|
|
2372
|
+
e++;
|
|
2373
|
+
if (external) {
|
|
2374
|
+
if (e > Decimal2.maxE) {
|
|
2375
|
+
x.e = NaN;
|
|
2376
|
+
x.d = null;
|
|
2377
|
+
} else if (e < Decimal2.minE) {
|
|
2378
|
+
x.e = 0;
|
|
2379
|
+
x.d = [0];
|
|
2380
|
+
} else {
|
|
2381
|
+
x.e = e;
|
|
2382
|
+
x.d = [v];
|
|
2383
|
+
}
|
|
2384
|
+
} else {
|
|
2385
|
+
x.e = e;
|
|
2386
|
+
x.d = [v];
|
|
2387
|
+
}
|
|
2388
|
+
return;
|
|
2389
|
+
} else if (v * 0 !== 0) {
|
|
2390
|
+
if (!v)
|
|
2391
|
+
x.s = NaN;
|
|
2392
|
+
x.e = NaN;
|
|
2393
|
+
x.d = null;
|
|
2394
|
+
return;
|
|
2395
|
+
}
|
|
2396
|
+
return parseDecimal(x, v.toString());
|
|
2397
|
+
} else if (t !== "string") {
|
|
2398
|
+
throw Error(invalidArgument + v);
|
|
2399
|
+
}
|
|
2400
|
+
if ((i2 = v.charCodeAt(0)) === 45) {
|
|
2401
|
+
v = v.slice(1);
|
|
2402
|
+
x.s = -1;
|
|
2403
|
+
} else {
|
|
2404
|
+
if (i2 === 43)
|
|
2405
|
+
v = v.slice(1);
|
|
2406
|
+
x.s = 1;
|
|
2407
|
+
}
|
|
2408
|
+
return isDecimal.test(v) ? parseDecimal(x, v) : parseOther(x, v);
|
|
2409
|
+
}
|
|
2410
|
+
Decimal2.prototype = P;
|
|
2411
|
+
Decimal2.ROUND_UP = 0;
|
|
2412
|
+
Decimal2.ROUND_DOWN = 1;
|
|
2413
|
+
Decimal2.ROUND_CEIL = 2;
|
|
2414
|
+
Decimal2.ROUND_FLOOR = 3;
|
|
2415
|
+
Decimal2.ROUND_HALF_UP = 4;
|
|
2416
|
+
Decimal2.ROUND_HALF_DOWN = 5;
|
|
2417
|
+
Decimal2.ROUND_HALF_EVEN = 6;
|
|
2418
|
+
Decimal2.ROUND_HALF_CEIL = 7;
|
|
2419
|
+
Decimal2.ROUND_HALF_FLOOR = 8;
|
|
2420
|
+
Decimal2.EUCLID = 9;
|
|
2421
|
+
Decimal2.config = Decimal2.set = config;
|
|
2422
|
+
Decimal2.clone = clone;
|
|
2423
|
+
Decimal2.isDecimal = isDecimalInstance;
|
|
2424
|
+
Decimal2.abs = abs;
|
|
2425
|
+
Decimal2.acos = acos;
|
|
2426
|
+
Decimal2.acosh = acosh;
|
|
2427
|
+
Decimal2.add = add;
|
|
2428
|
+
Decimal2.asin = asin;
|
|
2429
|
+
Decimal2.asinh = asinh;
|
|
2430
|
+
Decimal2.atan = atan;
|
|
2431
|
+
Decimal2.atanh = atanh;
|
|
2432
|
+
Decimal2.atan2 = atan2;
|
|
2433
|
+
Decimal2.cbrt = cbrt;
|
|
2434
|
+
Decimal2.ceil = ceil;
|
|
2435
|
+
Decimal2.clamp = clamp;
|
|
2436
|
+
Decimal2.cos = cos;
|
|
2437
|
+
Decimal2.cosh = cosh;
|
|
2438
|
+
Decimal2.div = div;
|
|
2439
|
+
Decimal2.exp = exp;
|
|
2440
|
+
Decimal2.floor = floor;
|
|
2441
|
+
Decimal2.hypot = hypot;
|
|
2442
|
+
Decimal2.ln = ln;
|
|
2443
|
+
Decimal2.log = log;
|
|
2444
|
+
Decimal2.log10 = log10;
|
|
2445
|
+
Decimal2.log2 = log2;
|
|
2446
|
+
Decimal2.max = max;
|
|
2447
|
+
Decimal2.min = min;
|
|
2448
|
+
Decimal2.mod = mod;
|
|
2449
|
+
Decimal2.mul = mul;
|
|
2450
|
+
Decimal2.pow = pow;
|
|
2451
|
+
Decimal2.random = random;
|
|
2452
|
+
Decimal2.round = round;
|
|
2453
|
+
Decimal2.sign = sign;
|
|
2454
|
+
Decimal2.sin = sin;
|
|
2455
|
+
Decimal2.sinh = sinh;
|
|
2456
|
+
Decimal2.sqrt = sqrt;
|
|
2457
|
+
Decimal2.sub = sub;
|
|
2458
|
+
Decimal2.sum = sum;
|
|
2459
|
+
Decimal2.tan = tan;
|
|
2460
|
+
Decimal2.tanh = tanh;
|
|
2461
|
+
Decimal2.trunc = trunc;
|
|
2462
|
+
if (obj === void 0)
|
|
2463
|
+
obj = {};
|
|
2464
|
+
if (obj) {
|
|
2465
|
+
if (obj.defaults !== true) {
|
|
2466
|
+
ps = ["precision", "rounding", "toExpNeg", "toExpPos", "maxE", "minE", "modulo", "crypto"];
|
|
2467
|
+
for (i = 0; i < ps.length; )
|
|
2468
|
+
if (!obj.hasOwnProperty(p = ps[i++]))
|
|
2469
|
+
obj[p] = this[p];
|
|
2470
|
+
}
|
|
2471
|
+
}
|
|
2472
|
+
Decimal2.config(obj);
|
|
2473
|
+
return Decimal2;
|
|
2474
|
+
}
|
|
2475
|
+
function div(x, y) {
|
|
2476
|
+
return new this(x).div(y);
|
|
2477
|
+
}
|
|
2478
|
+
function exp(x) {
|
|
2479
|
+
return new this(x).exp();
|
|
2480
|
+
}
|
|
2481
|
+
function floor(x) {
|
|
2482
|
+
return finalise(x = new this(x), x.e + 1, 3);
|
|
2483
|
+
}
|
|
2484
|
+
function hypot() {
|
|
2485
|
+
var i, n, t = new this(0);
|
|
2486
|
+
external = false;
|
|
2487
|
+
for (i = 0; i < arguments.length; ) {
|
|
2488
|
+
n = new this(arguments[i++]);
|
|
2489
|
+
if (!n.d) {
|
|
2490
|
+
if (n.s) {
|
|
2491
|
+
external = true;
|
|
2492
|
+
return new this(1 / 0);
|
|
2493
|
+
}
|
|
2494
|
+
t = n;
|
|
2495
|
+
} else if (t.d) {
|
|
2496
|
+
t = t.plus(n.times(n));
|
|
2497
|
+
}
|
|
2498
|
+
}
|
|
2499
|
+
external = true;
|
|
2500
|
+
return t.sqrt();
|
|
2501
|
+
}
|
|
2502
|
+
function isDecimalInstance(obj) {
|
|
2503
|
+
return obj instanceof Decimal || obj && obj.toStringTag === tag || false;
|
|
2504
|
+
}
|
|
2505
|
+
function ln(x) {
|
|
2506
|
+
return new this(x).ln();
|
|
2507
|
+
}
|
|
2508
|
+
function log(x, y) {
|
|
2509
|
+
return new this(x).log(y);
|
|
2510
|
+
}
|
|
2511
|
+
function log2(x) {
|
|
2512
|
+
return new this(x).log(2);
|
|
2513
|
+
}
|
|
2514
|
+
function log10(x) {
|
|
2515
|
+
return new this(x).log(10);
|
|
2516
|
+
}
|
|
2517
|
+
function max() {
|
|
2518
|
+
return maxOrMin(this, arguments, "lt");
|
|
2519
|
+
}
|
|
2520
|
+
function min() {
|
|
2521
|
+
return maxOrMin(this, arguments, "gt");
|
|
2522
|
+
}
|
|
2523
|
+
function mod(x, y) {
|
|
2524
|
+
return new this(x).mod(y);
|
|
2525
|
+
}
|
|
2526
|
+
function mul(x, y) {
|
|
2527
|
+
return new this(x).mul(y);
|
|
2528
|
+
}
|
|
2529
|
+
function pow(x, y) {
|
|
2530
|
+
return new this(x).pow(y);
|
|
2531
|
+
}
|
|
2532
|
+
function random(sd) {
|
|
2533
|
+
var d, e, k, n, i = 0, r = new this(1), rd = [];
|
|
2534
|
+
if (sd === void 0)
|
|
2535
|
+
sd = this.precision;
|
|
2536
|
+
else
|
|
2537
|
+
checkInt32(sd, 1, MAX_DIGITS);
|
|
2538
|
+
k = Math.ceil(sd / LOG_BASE);
|
|
2539
|
+
if (!this.crypto) {
|
|
2540
|
+
for (; i < k; )
|
|
2541
|
+
rd[i++] = Math.random() * 1e7 | 0;
|
|
2542
|
+
} else if (crypto.getRandomValues) {
|
|
2543
|
+
d = crypto.getRandomValues(new Uint32Array(k));
|
|
2544
|
+
for (; i < k; ) {
|
|
2545
|
+
n = d[i];
|
|
2546
|
+
if (n >= 429e7) {
|
|
2547
|
+
d[i] = crypto.getRandomValues(new Uint32Array(1))[0];
|
|
2548
|
+
} else {
|
|
2549
|
+
rd[i++] = n % 1e7;
|
|
2550
|
+
}
|
|
2551
|
+
}
|
|
2552
|
+
} else if (crypto.randomBytes) {
|
|
2553
|
+
d = crypto.randomBytes(k *= 4);
|
|
2554
|
+
for (; i < k; ) {
|
|
2555
|
+
n = d[i] + (d[i + 1] << 8) + (d[i + 2] << 16) + ((d[i + 3] & 127) << 24);
|
|
2556
|
+
if (n >= 214e7) {
|
|
2557
|
+
crypto.randomBytes(4).copy(d, i);
|
|
2558
|
+
} else {
|
|
2559
|
+
rd.push(n % 1e7);
|
|
2560
|
+
i += 4;
|
|
2561
|
+
}
|
|
2562
|
+
}
|
|
2563
|
+
i = k / 4;
|
|
2564
|
+
} else {
|
|
2565
|
+
throw Error(cryptoUnavailable);
|
|
2566
|
+
}
|
|
2567
|
+
k = rd[--i];
|
|
2568
|
+
sd %= LOG_BASE;
|
|
2569
|
+
if (k && sd) {
|
|
2570
|
+
n = mathpow(10, LOG_BASE - sd);
|
|
2571
|
+
rd[i] = (k / n | 0) * n;
|
|
2572
|
+
}
|
|
2573
|
+
for (; rd[i] === 0; i--)
|
|
2574
|
+
rd.pop();
|
|
2575
|
+
if (i < 0) {
|
|
2576
|
+
e = 0;
|
|
2577
|
+
rd = [0];
|
|
2578
|
+
} else {
|
|
2579
|
+
e = -1;
|
|
2580
|
+
for (; rd[0] === 0; e -= LOG_BASE)
|
|
2581
|
+
rd.shift();
|
|
2582
|
+
for (k = 1, n = rd[0]; n >= 10; n /= 10)
|
|
2583
|
+
k++;
|
|
2584
|
+
if (k < LOG_BASE)
|
|
2585
|
+
e -= LOG_BASE - k;
|
|
2586
|
+
}
|
|
2587
|
+
r.e = e;
|
|
2588
|
+
r.d = rd;
|
|
2589
|
+
return r;
|
|
2590
|
+
}
|
|
2591
|
+
function round(x) {
|
|
2592
|
+
return finalise(x = new this(x), x.e + 1, this.rounding);
|
|
2593
|
+
}
|
|
2594
|
+
function sign(x) {
|
|
2595
|
+
x = new this(x);
|
|
2596
|
+
return x.d ? x.d[0] ? x.s : 0 * x.s : x.s || NaN;
|
|
2597
|
+
}
|
|
2598
|
+
function sin(x) {
|
|
2599
|
+
return new this(x).sin();
|
|
2600
|
+
}
|
|
2601
|
+
function sinh(x) {
|
|
2602
|
+
return new this(x).sinh();
|
|
2603
|
+
}
|
|
2604
|
+
function sqrt(x) {
|
|
2605
|
+
return new this(x).sqrt();
|
|
2606
|
+
}
|
|
2607
|
+
function sub(x, y) {
|
|
2608
|
+
return new this(x).sub(y);
|
|
2609
|
+
}
|
|
2610
|
+
function sum() {
|
|
2611
|
+
var i = 0, args = arguments, x = new this(args[i]);
|
|
2612
|
+
external = false;
|
|
2613
|
+
for (; x.s && ++i < args.length; )
|
|
2614
|
+
x = x.plus(args[i]);
|
|
2615
|
+
external = true;
|
|
2616
|
+
return finalise(x, this.precision, this.rounding);
|
|
2617
|
+
}
|
|
2618
|
+
function tan(x) {
|
|
2619
|
+
return new this(x).tan();
|
|
2620
|
+
}
|
|
2621
|
+
function tanh(x) {
|
|
2622
|
+
return new this(x).tanh();
|
|
2623
|
+
}
|
|
2624
|
+
function trunc(x) {
|
|
2625
|
+
return finalise(x = new this(x), x.e + 1, 1);
|
|
2626
|
+
}
|
|
2627
|
+
P[Symbol.for("nodejs.util.inspect.custom")] = P.toString;
|
|
2628
|
+
P[Symbol.toStringTag] = "Decimal";
|
|
2629
|
+
var Decimal = P.constructor = clone(DEFAULTS);
|
|
2630
|
+
LN10 = new Decimal(LN10);
|
|
2631
|
+
PI = new Decimal(PI);
|
|
2632
|
+
const libJsDecimal = (num1, num2, operator, point = 2) => {
|
|
2633
|
+
const calc = {
|
|
2634
|
+
"+": (a, b) => a.add(b),
|
|
2635
|
+
"-": (a, b) => a.sub(b),
|
|
2636
|
+
"*": (a, b) => a.mul(b),
|
|
2637
|
+
"/": (a, b) => {
|
|
2638
|
+
if (b.eq(0)) {
|
|
2639
|
+
throw new Error("除数不能为0");
|
|
2640
|
+
}
|
|
2641
|
+
return a.div(b);
|
|
2642
|
+
}
|
|
2643
|
+
};
|
|
2644
|
+
const result = calc[operator](new Decimal(num1), new Decimal(num2));
|
|
2645
|
+
return Number(result.toFixed(point, Decimal.ROUND_DOWN));
|
|
2646
|
+
};
|
|
2647
|
+
const libJsRegFormValidate = (form, rules) => {
|
|
2648
|
+
return rules.reduce((result, rule) => {
|
|
2649
|
+
const { key, verify, msg, name } = rule;
|
|
2650
|
+
const value = form[key];
|
|
2651
|
+
if (value === "" || value === void 0 || value === null) {
|
|
2652
|
+
result.push({ key, msg: "必填项", name });
|
|
2653
|
+
} else if (typeof verify === "function" ? !verify(value) : !verify.test(value)) {
|
|
2654
|
+
result.push({ key, msg, name });
|
|
2655
|
+
}
|
|
2656
|
+
return result;
|
|
2657
|
+
}, []);
|
|
2658
|
+
};
|
|
2659
|
+
const libJsRetryRequest = ({
|
|
2660
|
+
promiseFn,
|
|
2661
|
+
maxRetries = 3,
|
|
2662
|
+
retryDelay = 2e3,
|
|
2663
|
+
params = void 0
|
|
2664
|
+
}) => {
|
|
2665
|
+
return new Promise((resolve, reject) => {
|
|
2666
|
+
let count = 0;
|
|
2667
|
+
const makeRequest = () => {
|
|
2668
|
+
promiseFn(params).then((res) => {
|
|
2669
|
+
resolve(res);
|
|
2670
|
+
}).catch((err) => {
|
|
2671
|
+
count++;
|
|
2672
|
+
if (count >= maxRetries) {
|
|
2673
|
+
reject(err);
|
|
2674
|
+
return;
|
|
2675
|
+
}
|
|
2676
|
+
setTimeout(makeRequest, retryDelay);
|
|
2677
|
+
});
|
|
2678
|
+
};
|
|
2679
|
+
makeRequest();
|
|
2680
|
+
});
|
|
2681
|
+
};
|
|
2682
|
+
const libJsProbabilityResult = (probability) => Math.random() * 100 < probability;
|
|
2683
|
+
const libJsRandom = (min2, max2, num = 0) => {
|
|
2684
|
+
return parseFloat((Math.random() * (max2 - min2) + min2).toFixed(num));
|
|
2685
|
+
};
|
|
2686
|
+
const libJsRandomColor = (alpha = 1) => {
|
|
2687
|
+
const r = Math.floor(Math.random() * 256);
|
|
2688
|
+
const g = Math.floor(Math.random() * 256);
|
|
2689
|
+
const b = Math.floor(Math.random() * 256);
|
|
2690
|
+
return `rgba(${r}, ${g}, ${b}, ${alpha})`;
|
|
2691
|
+
};
|
|
2692
|
+
const libJsUniqueRandomNumbers = (min2, max2, count) => {
|
|
2693
|
+
const numbers = Array.from({ length: max2 - min2 + 1 }, (_, i) => i + min2);
|
|
2694
|
+
for (let i = numbers.length - 1; i > 0; i--) {
|
|
2695
|
+
const j = Math.floor(Math.random() * (i + 1));
|
|
2696
|
+
[numbers[i], numbers[j]] = [numbers[j], numbers[i]];
|
|
2697
|
+
}
|
|
2698
|
+
return numbers.slice(0, count);
|
|
2699
|
+
};
|
|
2700
|
+
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
2701
|
+
function getDefaultExportFromCjs(x) {
|
|
2702
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
2703
|
+
}
|
|
2704
|
+
var dayjs_min = { exports: {} };
|
|
2705
|
+
(function(module, exports) {
|
|
2706
|
+
!function(t, e) {
|
|
2707
|
+
module.exports = e();
|
|
2708
|
+
}(commonjsGlobal, function() {
|
|
2709
|
+
var t = 1e3, e = 6e4, n = 36e5, r = "millisecond", i = "second", s = "minute", u = "hour", a = "day", o = "week", c = "month", f = "quarter", h = "year", d = "date", l = "Invalid Date", $ = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/, y = /\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g, M = { name: "en", weekdays: "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"), months: "January_February_March_April_May_June_July_August_September_October_November_December".split("_"), ordinal: function(t2) {
|
|
2710
|
+
var e2 = ["th", "st", "nd", "rd"], n2 = t2 % 100;
|
|
2711
|
+
return "[" + t2 + (e2[(n2 - 20) % 10] || e2[n2] || e2[0]) + "]";
|
|
2712
|
+
} }, m = function(t2, e2, n2) {
|
|
2713
|
+
var r2 = String(t2);
|
|
2714
|
+
return !r2 || r2.length >= e2 ? t2 : "" + Array(e2 + 1 - r2.length).join(n2) + t2;
|
|
2715
|
+
}, v = { s: m, z: function(t2) {
|
|
2716
|
+
var e2 = -t2.utcOffset(), n2 = Math.abs(e2), r2 = Math.floor(n2 / 60), i2 = n2 % 60;
|
|
2717
|
+
return (e2 <= 0 ? "+" : "-") + m(r2, 2, "0") + ":" + m(i2, 2, "0");
|
|
2718
|
+
}, m: function t2(e2, n2) {
|
|
2719
|
+
if (e2.date() < n2.date())
|
|
2720
|
+
return -t2(n2, e2);
|
|
2721
|
+
var r2 = 12 * (n2.year() - e2.year()) + (n2.month() - e2.month()), i2 = e2.clone().add(r2, c), s2 = n2 - i2 < 0, u2 = e2.clone().add(r2 + (s2 ? -1 : 1), c);
|
|
2722
|
+
return +(-(r2 + (n2 - i2) / (s2 ? i2 - u2 : u2 - i2)) || 0);
|
|
2723
|
+
}, a: function(t2) {
|
|
2724
|
+
return t2 < 0 ? Math.ceil(t2) || 0 : Math.floor(t2);
|
|
2725
|
+
}, p: function(t2) {
|
|
2726
|
+
return { M: c, y: h, w: o, d: a, D: d, h: u, m: s, s: i, ms: r, Q: f }[t2] || String(t2 || "").toLowerCase().replace(/s$/, "");
|
|
2727
|
+
}, u: function(t2) {
|
|
2728
|
+
return void 0 === t2;
|
|
2729
|
+
} }, g = "en", D = {};
|
|
2730
|
+
D[g] = M;
|
|
2731
|
+
var p = "$isDayjsObject", S = function(t2) {
|
|
2732
|
+
return t2 instanceof _ || !(!t2 || !t2[p]);
|
|
2733
|
+
}, w = function t2(e2, n2, r2) {
|
|
2734
|
+
var i2;
|
|
2735
|
+
if (!e2)
|
|
2736
|
+
return g;
|
|
2737
|
+
if ("string" == typeof e2) {
|
|
2738
|
+
var s2 = e2.toLowerCase();
|
|
2739
|
+
D[s2] && (i2 = s2), n2 && (D[s2] = n2, i2 = s2);
|
|
2740
|
+
var u2 = e2.split("-");
|
|
2741
|
+
if (!i2 && u2.length > 1)
|
|
2742
|
+
return t2(u2[0]);
|
|
2743
|
+
} else {
|
|
2744
|
+
var a2 = e2.name;
|
|
2745
|
+
D[a2] = e2, i2 = a2;
|
|
2746
|
+
}
|
|
2747
|
+
return !r2 && i2 && (g = i2), i2 || !r2 && g;
|
|
2748
|
+
}, O = function(t2, e2) {
|
|
2749
|
+
if (S(t2))
|
|
2750
|
+
return t2.clone();
|
|
2751
|
+
var n2 = "object" == typeof e2 ? e2 : {};
|
|
2752
|
+
return n2.date = t2, n2.args = arguments, new _(n2);
|
|
2753
|
+
}, b = v;
|
|
2754
|
+
b.l = w, b.i = S, b.w = function(t2, e2) {
|
|
2755
|
+
return O(t2, { locale: e2.$L, utc: e2.$u, x: e2.$x, $offset: e2.$offset });
|
|
2756
|
+
};
|
|
2757
|
+
var _ = function() {
|
|
2758
|
+
function M2(t2) {
|
|
2759
|
+
this.$L = w(t2.locale, null, true), this.parse(t2), this.$x = this.$x || t2.x || {}, this[p] = true;
|
|
2760
|
+
}
|
|
2761
|
+
var m2 = M2.prototype;
|
|
2762
|
+
return m2.parse = function(t2) {
|
|
2763
|
+
this.$d = function(t3) {
|
|
2764
|
+
var e2 = t3.date, n2 = t3.utc;
|
|
2765
|
+
if (null === e2)
|
|
2766
|
+
return /* @__PURE__ */ new Date(NaN);
|
|
2767
|
+
if (b.u(e2))
|
|
2768
|
+
return /* @__PURE__ */ new Date();
|
|
2769
|
+
if (e2 instanceof Date)
|
|
2770
|
+
return new Date(e2);
|
|
2771
|
+
if ("string" == typeof e2 && !/Z$/i.test(e2)) {
|
|
2772
|
+
var r2 = e2.match($);
|
|
2773
|
+
if (r2) {
|
|
2774
|
+
var i2 = r2[2] - 1 || 0, s2 = (r2[7] || "0").substring(0, 3);
|
|
2775
|
+
return n2 ? new Date(Date.UTC(r2[1], i2, r2[3] || 1, r2[4] || 0, r2[5] || 0, r2[6] || 0, s2)) : new Date(r2[1], i2, r2[3] || 1, r2[4] || 0, r2[5] || 0, r2[6] || 0, s2);
|
|
2776
|
+
}
|
|
2777
|
+
}
|
|
2778
|
+
return new Date(e2);
|
|
2779
|
+
}(t2), this.init();
|
|
2780
|
+
}, m2.init = function() {
|
|
2781
|
+
var t2 = this.$d;
|
|
2782
|
+
this.$y = t2.getFullYear(), this.$M = t2.getMonth(), this.$D = t2.getDate(), this.$W = t2.getDay(), this.$H = t2.getHours(), this.$m = t2.getMinutes(), this.$s = t2.getSeconds(), this.$ms = t2.getMilliseconds();
|
|
2783
|
+
}, m2.$utils = function() {
|
|
2784
|
+
return b;
|
|
2785
|
+
}, m2.isValid = function() {
|
|
2786
|
+
return !(this.$d.toString() === l);
|
|
2787
|
+
}, m2.isSame = function(t2, e2) {
|
|
2788
|
+
var n2 = O(t2);
|
|
2789
|
+
return this.startOf(e2) <= n2 && n2 <= this.endOf(e2);
|
|
2790
|
+
}, m2.isAfter = function(t2, e2) {
|
|
2791
|
+
return O(t2) < this.startOf(e2);
|
|
2792
|
+
}, m2.isBefore = function(t2, e2) {
|
|
2793
|
+
return this.endOf(e2) < O(t2);
|
|
2794
|
+
}, m2.$g = function(t2, e2, n2) {
|
|
2795
|
+
return b.u(t2) ? this[e2] : this.set(n2, t2);
|
|
2796
|
+
}, m2.unix = function() {
|
|
2797
|
+
return Math.floor(this.valueOf() / 1e3);
|
|
2798
|
+
}, m2.valueOf = function() {
|
|
2799
|
+
return this.$d.getTime();
|
|
2800
|
+
}, m2.startOf = function(t2, e2) {
|
|
2801
|
+
var n2 = this, r2 = !!b.u(e2) || e2, f2 = b.p(t2), l2 = function(t3, e3) {
|
|
2802
|
+
var i2 = b.w(n2.$u ? Date.UTC(n2.$y, e3, t3) : new Date(n2.$y, e3, t3), n2);
|
|
2803
|
+
return r2 ? i2 : i2.endOf(a);
|
|
2804
|
+
}, $2 = function(t3, e3) {
|
|
2805
|
+
return b.w(n2.toDate()[t3].apply(n2.toDate("s"), (r2 ? [0, 0, 0, 0] : [23, 59, 59, 999]).slice(e3)), n2);
|
|
2806
|
+
}, y2 = this.$W, M3 = this.$M, m3 = this.$D, v2 = "set" + (this.$u ? "UTC" : "");
|
|
2807
|
+
switch (f2) {
|
|
2808
|
+
case h:
|
|
2809
|
+
return r2 ? l2(1, 0) : l2(31, 11);
|
|
2810
|
+
case c:
|
|
2811
|
+
return r2 ? l2(1, M3) : l2(0, M3 + 1);
|
|
2812
|
+
case o:
|
|
2813
|
+
var g2 = this.$locale().weekStart || 0, D2 = (y2 < g2 ? y2 + 7 : y2) - g2;
|
|
2814
|
+
return l2(r2 ? m3 - D2 : m3 + (6 - D2), M3);
|
|
2815
|
+
case a:
|
|
2816
|
+
case d:
|
|
2817
|
+
return $2(v2 + "Hours", 0);
|
|
2818
|
+
case u:
|
|
2819
|
+
return $2(v2 + "Minutes", 1);
|
|
2820
|
+
case s:
|
|
2821
|
+
return $2(v2 + "Seconds", 2);
|
|
2822
|
+
case i:
|
|
2823
|
+
return $2(v2 + "Milliseconds", 3);
|
|
2824
|
+
default:
|
|
2825
|
+
return this.clone();
|
|
2826
|
+
}
|
|
2827
|
+
}, m2.endOf = function(t2) {
|
|
2828
|
+
return this.startOf(t2, false);
|
|
2829
|
+
}, m2.$set = function(t2, e2) {
|
|
2830
|
+
var n2, o2 = b.p(t2), f2 = "set" + (this.$u ? "UTC" : ""), l2 = (n2 = {}, n2[a] = f2 + "Date", n2[d] = f2 + "Date", n2[c] = f2 + "Month", n2[h] = f2 + "FullYear", n2[u] = f2 + "Hours", n2[s] = f2 + "Minutes", n2[i] = f2 + "Seconds", n2[r] = f2 + "Milliseconds", n2)[o2], $2 = o2 === a ? this.$D + (e2 - this.$W) : e2;
|
|
2831
|
+
if (o2 === c || o2 === h) {
|
|
2832
|
+
var y2 = this.clone().set(d, 1);
|
|
2833
|
+
y2.$d[l2]($2), y2.init(), this.$d = y2.set(d, Math.min(this.$D, y2.daysInMonth())).$d;
|
|
2834
|
+
} else
|
|
2835
|
+
l2 && this.$d[l2]($2);
|
|
2836
|
+
return this.init(), this;
|
|
2837
|
+
}, m2.set = function(t2, e2) {
|
|
2838
|
+
return this.clone().$set(t2, e2);
|
|
2839
|
+
}, m2.get = function(t2) {
|
|
2840
|
+
return this[b.p(t2)]();
|
|
2841
|
+
}, m2.add = function(r2, f2) {
|
|
2842
|
+
var d2, l2 = this;
|
|
2843
|
+
r2 = Number(r2);
|
|
2844
|
+
var $2 = b.p(f2), y2 = function(t2) {
|
|
2845
|
+
var e2 = O(l2);
|
|
2846
|
+
return b.w(e2.date(e2.date() + Math.round(t2 * r2)), l2);
|
|
2847
|
+
};
|
|
2848
|
+
if ($2 === c)
|
|
2849
|
+
return this.set(c, this.$M + r2);
|
|
2850
|
+
if ($2 === h)
|
|
2851
|
+
return this.set(h, this.$y + r2);
|
|
2852
|
+
if ($2 === a)
|
|
2853
|
+
return y2(1);
|
|
2854
|
+
if ($2 === o)
|
|
2855
|
+
return y2(7);
|
|
2856
|
+
var M3 = (d2 = {}, d2[s] = e, d2[u] = n, d2[i] = t, d2)[$2] || 1, m3 = this.$d.getTime() + r2 * M3;
|
|
2857
|
+
return b.w(m3, this);
|
|
2858
|
+
}, m2.subtract = function(t2, e2) {
|
|
2859
|
+
return this.add(-1 * t2, e2);
|
|
2860
|
+
}, m2.format = function(t2) {
|
|
2861
|
+
var e2 = this, n2 = this.$locale();
|
|
2862
|
+
if (!this.isValid())
|
|
2863
|
+
return n2.invalidDate || l;
|
|
2864
|
+
var r2 = t2 || "YYYY-MM-DDTHH:mm:ssZ", i2 = b.z(this), s2 = this.$H, u2 = this.$m, a2 = this.$M, o2 = n2.weekdays, c2 = n2.months, f2 = n2.meridiem, h2 = function(t3, n3, i3, s3) {
|
|
2865
|
+
return t3 && (t3[n3] || t3(e2, r2)) || i3[n3].slice(0, s3);
|
|
2866
|
+
}, d2 = function(t3) {
|
|
2867
|
+
return b.s(s2 % 12 || 12, t3, "0");
|
|
2868
|
+
}, $2 = f2 || function(t3, e3, n3) {
|
|
2869
|
+
var r3 = t3 < 12 ? "AM" : "PM";
|
|
2870
|
+
return n3 ? r3.toLowerCase() : r3;
|
|
2871
|
+
};
|
|
2872
|
+
return r2.replace(y, function(t3, r3) {
|
|
2873
|
+
return r3 || function(t4) {
|
|
2874
|
+
switch (t4) {
|
|
2875
|
+
case "YY":
|
|
2876
|
+
return String(e2.$y).slice(-2);
|
|
2877
|
+
case "YYYY":
|
|
2878
|
+
return b.s(e2.$y, 4, "0");
|
|
2879
|
+
case "M":
|
|
2880
|
+
return a2 + 1;
|
|
2881
|
+
case "MM":
|
|
2882
|
+
return b.s(a2 + 1, 2, "0");
|
|
2883
|
+
case "MMM":
|
|
2884
|
+
return h2(n2.monthsShort, a2, c2, 3);
|
|
2885
|
+
case "MMMM":
|
|
2886
|
+
return h2(c2, a2);
|
|
2887
|
+
case "D":
|
|
2888
|
+
return e2.$D;
|
|
2889
|
+
case "DD":
|
|
2890
|
+
return b.s(e2.$D, 2, "0");
|
|
2891
|
+
case "d":
|
|
2892
|
+
return String(e2.$W);
|
|
2893
|
+
case "dd":
|
|
2894
|
+
return h2(n2.weekdaysMin, e2.$W, o2, 2);
|
|
2895
|
+
case "ddd":
|
|
2896
|
+
return h2(n2.weekdaysShort, e2.$W, o2, 3);
|
|
2897
|
+
case "dddd":
|
|
2898
|
+
return o2[e2.$W];
|
|
2899
|
+
case "H":
|
|
2900
|
+
return String(s2);
|
|
2901
|
+
case "HH":
|
|
2902
|
+
return b.s(s2, 2, "0");
|
|
2903
|
+
case "h":
|
|
2904
|
+
return d2(1);
|
|
2905
|
+
case "hh":
|
|
2906
|
+
return d2(2);
|
|
2907
|
+
case "a":
|
|
2908
|
+
return $2(s2, u2, true);
|
|
2909
|
+
case "A":
|
|
2910
|
+
return $2(s2, u2, false);
|
|
2911
|
+
case "m":
|
|
2912
|
+
return String(u2);
|
|
2913
|
+
case "mm":
|
|
2914
|
+
return b.s(u2, 2, "0");
|
|
2915
|
+
case "s":
|
|
2916
|
+
return String(e2.$s);
|
|
2917
|
+
case "ss":
|
|
2918
|
+
return b.s(e2.$s, 2, "0");
|
|
2919
|
+
case "SSS":
|
|
2920
|
+
return b.s(e2.$ms, 3, "0");
|
|
2921
|
+
case "Z":
|
|
2922
|
+
return i2;
|
|
2923
|
+
}
|
|
2924
|
+
return null;
|
|
2925
|
+
}(t3) || i2.replace(":", "");
|
|
2926
|
+
});
|
|
2927
|
+
}, m2.utcOffset = function() {
|
|
2928
|
+
return 15 * -Math.round(this.$d.getTimezoneOffset() / 15);
|
|
2929
|
+
}, m2.diff = function(r2, d2, l2) {
|
|
2930
|
+
var $2, y2 = this, M3 = b.p(d2), m3 = O(r2), v2 = (m3.utcOffset() - this.utcOffset()) * e, g2 = this - m3, D2 = function() {
|
|
2931
|
+
return b.m(y2, m3);
|
|
2932
|
+
};
|
|
2933
|
+
switch (M3) {
|
|
2934
|
+
case h:
|
|
2935
|
+
$2 = D2() / 12;
|
|
2936
|
+
break;
|
|
2937
|
+
case c:
|
|
2938
|
+
$2 = D2();
|
|
2939
|
+
break;
|
|
2940
|
+
case f:
|
|
2941
|
+
$2 = D2() / 3;
|
|
2942
|
+
break;
|
|
2943
|
+
case o:
|
|
2944
|
+
$2 = (g2 - v2) / 6048e5;
|
|
2945
|
+
break;
|
|
2946
|
+
case a:
|
|
2947
|
+
$2 = (g2 - v2) / 864e5;
|
|
2948
|
+
break;
|
|
2949
|
+
case u:
|
|
2950
|
+
$2 = g2 / n;
|
|
2951
|
+
break;
|
|
2952
|
+
case s:
|
|
2953
|
+
$2 = g2 / e;
|
|
2954
|
+
break;
|
|
2955
|
+
case i:
|
|
2956
|
+
$2 = g2 / t;
|
|
2957
|
+
break;
|
|
2958
|
+
default:
|
|
2959
|
+
$2 = g2;
|
|
2960
|
+
}
|
|
2961
|
+
return l2 ? $2 : b.a($2);
|
|
2962
|
+
}, m2.daysInMonth = function() {
|
|
2963
|
+
return this.endOf(c).$D;
|
|
2964
|
+
}, m2.$locale = function() {
|
|
2965
|
+
return D[this.$L];
|
|
2966
|
+
}, m2.locale = function(t2, e2) {
|
|
2967
|
+
if (!t2)
|
|
2968
|
+
return this.$L;
|
|
2969
|
+
var n2 = this.clone(), r2 = w(t2, e2, true);
|
|
2970
|
+
return r2 && (n2.$L = r2), n2;
|
|
2971
|
+
}, m2.clone = function() {
|
|
2972
|
+
return b.w(this.$d, this);
|
|
2973
|
+
}, m2.toDate = function() {
|
|
2974
|
+
return new Date(this.valueOf());
|
|
2975
|
+
}, m2.toJSON = function() {
|
|
2976
|
+
return this.isValid() ? this.toISOString() : null;
|
|
2977
|
+
}, m2.toISOString = function() {
|
|
2978
|
+
return this.$d.toISOString();
|
|
2979
|
+
}, m2.toString = function() {
|
|
2980
|
+
return this.$d.toUTCString();
|
|
2981
|
+
}, M2;
|
|
2982
|
+
}(), k = _.prototype;
|
|
2983
|
+
return O.prototype = k, [["$ms", r], ["$s", i], ["$m", s], ["$H", u], ["$W", a], ["$M", c], ["$y", h], ["$D", d]].forEach(function(t2) {
|
|
2984
|
+
k[t2[1]] = function(e2) {
|
|
2985
|
+
return this.$g(e2, t2[0], t2[1]);
|
|
2986
|
+
};
|
|
2987
|
+
}), O.extend = function(t2, e2) {
|
|
2988
|
+
return t2.$i || (t2(e2, _, O), t2.$i = true), O;
|
|
2989
|
+
}, O.locale = w, O.isDayjs = S, O.unix = function(t2) {
|
|
2990
|
+
return O(1e3 * t2);
|
|
2991
|
+
}, O.en = D[g], O.Ls = D, O.p = {}, O;
|
|
2992
|
+
});
|
|
2993
|
+
})(dayjs_min);
|
|
2994
|
+
var dayjs_minExports = dayjs_min.exports;
|
|
2995
|
+
const dayjs = /* @__PURE__ */ getDefaultExportFromCjs(dayjs_minExports);
|
|
2996
|
+
const libJsSameTimeCheck = (timestamp, unit) => {
|
|
2997
|
+
const inputTime = dayjs(timestamp).startOf(unit);
|
|
2998
|
+
const currentTime = dayjs().startOf(unit);
|
|
2999
|
+
if (inputTime.isSame(currentTime)) {
|
|
3000
|
+
return 0;
|
|
3001
|
+
} else if (inputTime.isBefore(currentTime)) {
|
|
3002
|
+
return 1;
|
|
3003
|
+
} else {
|
|
3004
|
+
return -1;
|
|
3005
|
+
}
|
|
3006
|
+
};
|
|
3007
|
+
const libJsTimeAgo = (timestamp) => {
|
|
3008
|
+
const timeUnits = [
|
|
3009
|
+
{ unit: "年", milliseconds: 365 * 24 * 60 * 60 * 1e3 },
|
|
3010
|
+
{ unit: "月", milliseconds: 30 * 24 * 60 * 60 * 1e3 },
|
|
3011
|
+
{ unit: "周", milliseconds: 7 * 24 * 60 * 60 * 1e3 },
|
|
3012
|
+
{ unit: "天", milliseconds: 24 * 60 * 60 * 1e3 },
|
|
3013
|
+
{ unit: "小时", milliseconds: 60 * 60 * 1e3 },
|
|
3014
|
+
{ unit: "分钟", milliseconds: 60 * 1e3 }
|
|
3015
|
+
];
|
|
3016
|
+
const currentTime = Date.now();
|
|
3017
|
+
const timeDifference = currentTime - timestamp;
|
|
3018
|
+
for (const { unit, milliseconds } of timeUnits) {
|
|
3019
|
+
if (timeDifference >= milliseconds) {
|
|
3020
|
+
const count = Math.floor(timeDifference / milliseconds);
|
|
3021
|
+
return `${count} ${unit}前`;
|
|
3022
|
+
}
|
|
3023
|
+
}
|
|
3024
|
+
return "刚刚";
|
|
3025
|
+
};
|
|
3026
|
+
const libJsTimeGreeting = (greet = {}) => {
|
|
3027
|
+
const {
|
|
3028
|
+
midnight = "午夜好",
|
|
3029
|
+
morning = "早上好",
|
|
3030
|
+
forenoon = "上午好",
|
|
3031
|
+
noon = "中午好",
|
|
3032
|
+
afternoon = "下午好",
|
|
3033
|
+
evening = "晚上好"
|
|
3034
|
+
} = greet;
|
|
3035
|
+
const now = (/* @__PURE__ */ new Date()).getHours();
|
|
3036
|
+
return now < 4 ? midnight : now < 10 ? morning : now < 12 ? forenoon : now < 14 ? noon : now < 18 ? afternoon : evening;
|
|
3037
|
+
};
|
|
3038
|
+
class LibJsNumberStepper {
|
|
3039
|
+
/**
|
|
3040
|
+
* @param numsLength 数字长度
|
|
3041
|
+
* @param onChange 数字变动时触发
|
|
3042
|
+
*/
|
|
3043
|
+
constructor(numsLength, onChange) {
|
|
3044
|
+
this._currentIndex = 0;
|
|
3045
|
+
this._numsLength = 0;
|
|
3046
|
+
this._isDown = false;
|
|
3047
|
+
this._onChange = onChange;
|
|
3048
|
+
this._numsLength = numsLength;
|
|
3049
|
+
window.addEventListener("pointerup", () => {
|
|
3050
|
+
this._isDown && this._up();
|
|
3051
|
+
});
|
|
3052
|
+
}
|
|
3053
|
+
/** @description 按下
|
|
3054
|
+
* @param type 操作类型 add:加 sub:减
|
|
3055
|
+
*/
|
|
3056
|
+
down(type) {
|
|
3057
|
+
this._isDown = true;
|
|
3058
|
+
this._handleChange(type);
|
|
3059
|
+
this._timerId = setTimeout(() => {
|
|
3060
|
+
if (this._isDown) {
|
|
3061
|
+
this._intervalId = setInterval(() => {
|
|
3062
|
+
this._handleChange(type);
|
|
3063
|
+
}, 100);
|
|
3064
|
+
}
|
|
3065
|
+
}, 100);
|
|
3066
|
+
}
|
|
3067
|
+
/** @description 更新索引 */
|
|
3068
|
+
updateIndex(index) {
|
|
3069
|
+
this._currentIndex = index;
|
|
3070
|
+
}
|
|
3071
|
+
/** @description 抬起 */
|
|
3072
|
+
_up() {
|
|
3073
|
+
this._isDown = false;
|
|
3074
|
+
clearTimeout(this._timerId);
|
|
3075
|
+
clearInterval(this._intervalId);
|
|
3076
|
+
}
|
|
3077
|
+
/** @description 处理数字变化
|
|
3078
|
+
* @param type 操作类型 add:加 sub:减
|
|
3079
|
+
*/
|
|
3080
|
+
_handleChange(type) {
|
|
3081
|
+
if (type === "add") {
|
|
3082
|
+
if (this._currentIndex < this._numsLength - 1) {
|
|
3083
|
+
this._currentIndex++;
|
|
3084
|
+
this._onChange(this._currentIndex);
|
|
3085
|
+
}
|
|
3086
|
+
} else if (type === "sub") {
|
|
3087
|
+
if (this._currentIndex > 0) {
|
|
3088
|
+
this._currentIndex--;
|
|
3089
|
+
this._onChange(this._currentIndex);
|
|
3090
|
+
}
|
|
3091
|
+
}
|
|
3092
|
+
}
|
|
3093
|
+
}
|
|
3094
|
+
const libJsFormatterByte = (bytes) => {
|
|
3095
|
+
if (bytes <= 0)
|
|
3096
|
+
return [0, "B", "0 B"];
|
|
3097
|
+
const k = 1024;
|
|
3098
|
+
const sizes = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
|
|
3099
|
+
const i = Math.min(
|
|
3100
|
+
Math.floor(Math.log(bytes) / Math.log(k)),
|
|
3101
|
+
sizes.length - 1
|
|
3102
|
+
);
|
|
3103
|
+
const size = (bytes / k ** i).toFixed(2);
|
|
3104
|
+
return [size, sizes[i], `${size} ${sizes[i]}`];
|
|
3105
|
+
};
|
|
3106
|
+
const libJsMaskPhoneNumber = (mobile) => {
|
|
3107
|
+
const m = mobile.toString();
|
|
3108
|
+
return m.replace(/^(\d{3})\d{4}(\d{4})$/, "$1****$2");
|
|
3109
|
+
};
|
|
3110
|
+
const libJsNumComma = (num, reserve = 2) => {
|
|
3111
|
+
const str = num.toFixed(reserve).toString();
|
|
3112
|
+
const reg = str.indexOf(".") > -1 ? /(\d)(?=(\d{3})+\.)/g : /(\d)(?=(?:\d{3})+$)/g;
|
|
3113
|
+
return str.replace(reg, "$1,");
|
|
3114
|
+
};
|
|
3115
|
+
const libJsNumberUnit = (num, units, retain = 0) => {
|
|
3116
|
+
const decimalValue = new Decimal(num);
|
|
3117
|
+
const sortedUnits = Object.entries(units).sort(([, a], [, b]) => b - a);
|
|
3118
|
+
for (const [unit, threshold] of sortedUnits) {
|
|
3119
|
+
const decimalThreshold = new Decimal(threshold);
|
|
3120
|
+
if (decimalValue.greaterThanOrEqualTo(decimalThreshold)) {
|
|
3121
|
+
const formattedValue = decimalValue.dividedBy(decimalThreshold);
|
|
3122
|
+
const v2 = libJsNumComma(Number(formattedValue), retain);
|
|
3123
|
+
return v2 + unit;
|
|
3124
|
+
}
|
|
3125
|
+
}
|
|
3126
|
+
const v = libJsNumComma(Number(decimalValue), retain);
|
|
3127
|
+
return v;
|
|
3128
|
+
};
|
|
3129
|
+
var duration$1 = { exports: {} };
|
|
3130
|
+
(function(module, exports) {
|
|
3131
|
+
!function(t, s) {
|
|
3132
|
+
module.exports = s();
|
|
3133
|
+
}(commonjsGlobal, function() {
|
|
3134
|
+
var t, s, n = 1e3, i = 6e4, e = 36e5, r = 864e5, o = /\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g, u = 31536e6, d = 2628e6, a = /^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/, h = { years: u, months: d, days: r, hours: e, minutes: i, seconds: n, milliseconds: 1, weeks: 6048e5 }, c = function(t2) {
|
|
3135
|
+
return t2 instanceof g;
|
|
3136
|
+
}, f = function(t2, s2, n2) {
|
|
3137
|
+
return new g(t2, n2, s2.$l);
|
|
3138
|
+
}, m = function(t2) {
|
|
3139
|
+
return s.p(t2) + "s";
|
|
3140
|
+
}, l = function(t2) {
|
|
3141
|
+
return t2 < 0;
|
|
3142
|
+
}, $ = function(t2) {
|
|
3143
|
+
return l(t2) ? Math.ceil(t2) : Math.floor(t2);
|
|
3144
|
+
}, y = function(t2) {
|
|
3145
|
+
return Math.abs(t2);
|
|
3146
|
+
}, v = function(t2, s2) {
|
|
3147
|
+
return t2 ? l(t2) ? { negative: true, format: "" + y(t2) + s2 } : { negative: false, format: "" + t2 + s2 } : { negative: false, format: "" };
|
|
3148
|
+
}, g = function() {
|
|
3149
|
+
function l2(t2, s2, n2) {
|
|
3150
|
+
var i2 = this;
|
|
3151
|
+
if (this.$d = {}, this.$l = n2, void 0 === t2 && (this.$ms = 0, this.parseFromMilliseconds()), s2)
|
|
3152
|
+
return f(t2 * h[m(s2)], this);
|
|
3153
|
+
if ("number" == typeof t2)
|
|
3154
|
+
return this.$ms = t2, this.parseFromMilliseconds(), this;
|
|
3155
|
+
if ("object" == typeof t2)
|
|
3156
|
+
return Object.keys(t2).forEach(function(s3) {
|
|
3157
|
+
i2.$d[m(s3)] = t2[s3];
|
|
3158
|
+
}), this.calMilliseconds(), this;
|
|
3159
|
+
if ("string" == typeof t2) {
|
|
3160
|
+
var e2 = t2.match(a);
|
|
3161
|
+
if (e2) {
|
|
3162
|
+
var r2 = e2.slice(2).map(function(t3) {
|
|
3163
|
+
return null != t3 ? Number(t3) : 0;
|
|
3164
|
+
});
|
|
3165
|
+
return this.$d.years = r2[0], this.$d.months = r2[1], this.$d.weeks = r2[2], this.$d.days = r2[3], this.$d.hours = r2[4], this.$d.minutes = r2[5], this.$d.seconds = r2[6], this.calMilliseconds(), this;
|
|
3166
|
+
}
|
|
3167
|
+
}
|
|
3168
|
+
return this;
|
|
3169
|
+
}
|
|
3170
|
+
var y2 = l2.prototype;
|
|
3171
|
+
return y2.calMilliseconds = function() {
|
|
3172
|
+
var t2 = this;
|
|
3173
|
+
this.$ms = Object.keys(this.$d).reduce(function(s2, n2) {
|
|
3174
|
+
return s2 + (t2.$d[n2] || 0) * h[n2];
|
|
3175
|
+
}, 0);
|
|
3176
|
+
}, y2.parseFromMilliseconds = function() {
|
|
3177
|
+
var t2 = this.$ms;
|
|
3178
|
+
this.$d.years = $(t2 / u), t2 %= u, this.$d.months = $(t2 / d), t2 %= d, this.$d.days = $(t2 / r), t2 %= r, this.$d.hours = $(t2 / e), t2 %= e, this.$d.minutes = $(t2 / i), t2 %= i, this.$d.seconds = $(t2 / n), t2 %= n, this.$d.milliseconds = t2;
|
|
3179
|
+
}, y2.toISOString = function() {
|
|
3180
|
+
var t2 = v(this.$d.years, "Y"), s2 = v(this.$d.months, "M"), n2 = +this.$d.days || 0;
|
|
3181
|
+
this.$d.weeks && (n2 += 7 * this.$d.weeks);
|
|
3182
|
+
var i2 = v(n2, "D"), e2 = v(this.$d.hours, "H"), r2 = v(this.$d.minutes, "M"), o2 = this.$d.seconds || 0;
|
|
3183
|
+
this.$d.milliseconds && (o2 += this.$d.milliseconds / 1e3, o2 = Math.round(1e3 * o2) / 1e3);
|
|
3184
|
+
var u2 = v(o2, "S"), d2 = t2.negative || s2.negative || i2.negative || e2.negative || r2.negative || u2.negative, a2 = e2.format || r2.format || u2.format ? "T" : "", h2 = (d2 ? "-" : "") + "P" + t2.format + s2.format + i2.format + a2 + e2.format + r2.format + u2.format;
|
|
3185
|
+
return "P" === h2 || "-P" === h2 ? "P0D" : h2;
|
|
3186
|
+
}, y2.toJSON = function() {
|
|
3187
|
+
return this.toISOString();
|
|
3188
|
+
}, y2.format = function(t2) {
|
|
3189
|
+
var n2 = t2 || "YYYY-MM-DDTHH:mm:ss", i2 = { Y: this.$d.years, YY: s.s(this.$d.years, 2, "0"), YYYY: s.s(this.$d.years, 4, "0"), M: this.$d.months, MM: s.s(this.$d.months, 2, "0"), D: this.$d.days, DD: s.s(this.$d.days, 2, "0"), H: this.$d.hours, HH: s.s(this.$d.hours, 2, "0"), m: this.$d.minutes, mm: s.s(this.$d.minutes, 2, "0"), s: this.$d.seconds, ss: s.s(this.$d.seconds, 2, "0"), SSS: s.s(this.$d.milliseconds, 3, "0") };
|
|
3190
|
+
return n2.replace(o, function(t3, s2) {
|
|
3191
|
+
return s2 || String(i2[t3]);
|
|
3192
|
+
});
|
|
3193
|
+
}, y2.as = function(t2) {
|
|
3194
|
+
return this.$ms / h[m(t2)];
|
|
3195
|
+
}, y2.get = function(t2) {
|
|
3196
|
+
var s2 = this.$ms, n2 = m(t2);
|
|
3197
|
+
return "milliseconds" === n2 ? s2 %= 1e3 : s2 = "weeks" === n2 ? $(s2 / h[n2]) : this.$d[n2], s2 || 0;
|
|
3198
|
+
}, y2.add = function(t2, s2, n2) {
|
|
3199
|
+
var i2;
|
|
3200
|
+
return i2 = s2 ? t2 * h[m(s2)] : c(t2) ? t2.$ms : f(t2, this).$ms, f(this.$ms + i2 * (n2 ? -1 : 1), this);
|
|
3201
|
+
}, y2.subtract = function(t2, s2) {
|
|
3202
|
+
return this.add(t2, s2, true);
|
|
3203
|
+
}, y2.locale = function(t2) {
|
|
3204
|
+
var s2 = this.clone();
|
|
3205
|
+
return s2.$l = t2, s2;
|
|
3206
|
+
}, y2.clone = function() {
|
|
3207
|
+
return f(this.$ms, this);
|
|
3208
|
+
}, y2.humanize = function(s2) {
|
|
3209
|
+
return t().add(this.$ms, "ms").locale(this.$l).fromNow(!s2);
|
|
3210
|
+
}, y2.valueOf = function() {
|
|
3211
|
+
return this.asMilliseconds();
|
|
3212
|
+
}, y2.milliseconds = function() {
|
|
3213
|
+
return this.get("milliseconds");
|
|
3214
|
+
}, y2.asMilliseconds = function() {
|
|
3215
|
+
return this.as("milliseconds");
|
|
3216
|
+
}, y2.seconds = function() {
|
|
3217
|
+
return this.get("seconds");
|
|
3218
|
+
}, y2.asSeconds = function() {
|
|
3219
|
+
return this.as("seconds");
|
|
3220
|
+
}, y2.minutes = function() {
|
|
3221
|
+
return this.get("minutes");
|
|
3222
|
+
}, y2.asMinutes = function() {
|
|
3223
|
+
return this.as("minutes");
|
|
3224
|
+
}, y2.hours = function() {
|
|
3225
|
+
return this.get("hours");
|
|
3226
|
+
}, y2.asHours = function() {
|
|
3227
|
+
return this.as("hours");
|
|
3228
|
+
}, y2.days = function() {
|
|
3229
|
+
return this.get("days");
|
|
3230
|
+
}, y2.asDays = function() {
|
|
3231
|
+
return this.as("days");
|
|
3232
|
+
}, y2.weeks = function() {
|
|
3233
|
+
return this.get("weeks");
|
|
3234
|
+
}, y2.asWeeks = function() {
|
|
3235
|
+
return this.as("weeks");
|
|
3236
|
+
}, y2.months = function() {
|
|
3237
|
+
return this.get("months");
|
|
3238
|
+
}, y2.asMonths = function() {
|
|
3239
|
+
return this.as("months");
|
|
3240
|
+
}, y2.years = function() {
|
|
3241
|
+
return this.get("years");
|
|
3242
|
+
}, y2.asYears = function() {
|
|
3243
|
+
return this.as("years");
|
|
3244
|
+
}, l2;
|
|
3245
|
+
}(), p = function(t2, s2, n2) {
|
|
3246
|
+
return t2.add(s2.years() * n2, "y").add(s2.months() * n2, "M").add(s2.days() * n2, "d").add(s2.hours() * n2, "h").add(s2.minutes() * n2, "m").add(s2.seconds() * n2, "s").add(s2.milliseconds() * n2, "ms");
|
|
3247
|
+
};
|
|
3248
|
+
return function(n2, i2, e2) {
|
|
3249
|
+
t = e2, s = e2().$utils(), e2.duration = function(t2, s2) {
|
|
3250
|
+
var n3 = e2.locale();
|
|
3251
|
+
return f(t2, { $l: n3 }, s2);
|
|
3252
|
+
}, e2.isDuration = c;
|
|
3253
|
+
var r2 = i2.prototype.add, o2 = i2.prototype.subtract;
|
|
3254
|
+
i2.prototype.add = function(t2, s2) {
|
|
3255
|
+
return c(t2) ? p(this, t2, 1) : r2.bind(this)(t2, s2);
|
|
3256
|
+
}, i2.prototype.subtract = function(t2, s2) {
|
|
3257
|
+
return c(t2) ? p(this, t2, -1) : o2.bind(this)(t2, s2);
|
|
3258
|
+
};
|
|
3259
|
+
};
|
|
3260
|
+
});
|
|
3261
|
+
})(duration$1);
|
|
3262
|
+
var durationExports = duration$1.exports;
|
|
3263
|
+
const duration = /* @__PURE__ */ getDefaultExportFromCjs(durationExports);
|
|
3264
|
+
dayjs.extend(duration);
|
|
3265
|
+
const libJsSecondsFormatterChinese = (seconds) => {
|
|
3266
|
+
const duration2 = dayjs.duration(seconds, "seconds");
|
|
3267
|
+
const years = Math.floor(duration2.asYears());
|
|
3268
|
+
const months = Math.floor(duration2.asMonths() % 12);
|
|
3269
|
+
const days = Math.floor(duration2.asDays() % 30);
|
|
3270
|
+
const hours = duration2.hours();
|
|
3271
|
+
const minutes = duration2.minutes();
|
|
3272
|
+
const remainingSeconds = duration2.seconds();
|
|
3273
|
+
const timeParts = [];
|
|
3274
|
+
if (years > 0) {
|
|
3275
|
+
timeParts.push(`${years}年`);
|
|
3276
|
+
}
|
|
3277
|
+
if (months > 0) {
|
|
3278
|
+
timeParts.push(`${months}月`);
|
|
3279
|
+
}
|
|
3280
|
+
if (days > 0) {
|
|
3281
|
+
timeParts.push(`${days}天`);
|
|
3282
|
+
}
|
|
3283
|
+
if (hours > 0) {
|
|
3284
|
+
timeParts.push(`${hours}小时`);
|
|
3285
|
+
}
|
|
3286
|
+
if (minutes > 0) {
|
|
3287
|
+
timeParts.push(`${minutes}分`);
|
|
3288
|
+
}
|
|
3289
|
+
if (timeParts.length === 0 || remainingSeconds > 0) {
|
|
3290
|
+
timeParts.push(`${remainingSeconds}秒`);
|
|
3291
|
+
}
|
|
3292
|
+
return timeParts.join("");
|
|
3293
|
+
};
|
|
3294
|
+
const libJsCalculateExpression = (expression, point = 2) => {
|
|
3295
|
+
expression = expression.replace(/\s+/g, "");
|
|
3296
|
+
const operators = {
|
|
3297
|
+
"+": 1,
|
|
3298
|
+
"-": 1,
|
|
3299
|
+
"*": 2,
|
|
3300
|
+
"/": 2
|
|
3301
|
+
};
|
|
3302
|
+
const toDecimal = (value) => new Decimal(value);
|
|
3303
|
+
const isOperator = (char) => ["+", "-", "*", "/"].includes(char);
|
|
3304
|
+
const isNumber = (char) => /[0-9.]/.test(char);
|
|
3305
|
+
const evaluate = (expression2) => {
|
|
3306
|
+
const outputQueue = [];
|
|
3307
|
+
const operatorStack = [];
|
|
3308
|
+
let i = 0;
|
|
3309
|
+
while (i < expression2.length) {
|
|
3310
|
+
const char = expression2[i];
|
|
3311
|
+
if (isNumber(char)) {
|
|
3312
|
+
let numStr = "";
|
|
3313
|
+
while (i < expression2.length && isNumber(expression2[i])) {
|
|
3314
|
+
numStr += expression2[i];
|
|
3315
|
+
i++;
|
|
3316
|
+
}
|
|
3317
|
+
outputQueue.push(toDecimal(numStr));
|
|
3318
|
+
} else if (char === "(") {
|
|
3319
|
+
operatorStack.push(char);
|
|
3320
|
+
i++;
|
|
3321
|
+
} else if (char === ")") {
|
|
3322
|
+
while (operatorStack.length > 0 && operatorStack[operatorStack.length - 1] !== "(") {
|
|
3323
|
+
outputQueue.push(operatorStack.pop());
|
|
3324
|
+
}
|
|
3325
|
+
operatorStack.pop();
|
|
3326
|
+
i++;
|
|
3327
|
+
} else if (isOperator(char)) {
|
|
3328
|
+
while (operatorStack.length > 0 && operators[operatorStack[operatorStack.length - 1]] >= operators[char]) {
|
|
3329
|
+
outputQueue.push(operatorStack.pop());
|
|
3330
|
+
}
|
|
3331
|
+
operatorStack.push(char);
|
|
3332
|
+
i++;
|
|
3333
|
+
} else {
|
|
3334
|
+
throw new Error(`无效字符: ${char}`);
|
|
3335
|
+
}
|
|
3336
|
+
}
|
|
3337
|
+
while (operatorStack.length > 0) {
|
|
3338
|
+
outputQueue.push(operatorStack.pop());
|
|
3339
|
+
}
|
|
3340
|
+
const calcStack = [];
|
|
3341
|
+
for (let token of outputQueue) {
|
|
3342
|
+
if (typeof token === "string") {
|
|
3343
|
+
const b = calcStack.pop();
|
|
3344
|
+
const a = calcStack.pop();
|
|
3345
|
+
switch (token) {
|
|
3346
|
+
case "+":
|
|
3347
|
+
calcStack.push(a.add(b));
|
|
3348
|
+
break;
|
|
3349
|
+
case "-":
|
|
3350
|
+
calcStack.push(a.sub(b));
|
|
3351
|
+
break;
|
|
3352
|
+
case "*":
|
|
3353
|
+
calcStack.push(a.mul(b));
|
|
3354
|
+
break;
|
|
3355
|
+
case "/":
|
|
3356
|
+
if (b.eq(0))
|
|
3357
|
+
throw new Error("除数不能为零");
|
|
3358
|
+
calcStack.push(a.div(b));
|
|
3359
|
+
break;
|
|
3360
|
+
}
|
|
3361
|
+
} else {
|
|
3362
|
+
calcStack.push(token);
|
|
3363
|
+
}
|
|
3364
|
+
}
|
|
3365
|
+
return calcStack.pop();
|
|
3366
|
+
};
|
|
3367
|
+
try {
|
|
3368
|
+
const result = evaluate(expression);
|
|
3369
|
+
return Number(result.toFixed(point, Decimal.ROUND_DOWN));
|
|
3370
|
+
} catch (error) {
|
|
3371
|
+
throw new Error("表达式计算失败:" + error.message);
|
|
3372
|
+
}
|
|
3373
|
+
};
|
|
3374
|
+
const LibJsEmitter = () => {
|
|
3375
|
+
const _eventMap = /* @__PURE__ */ new Map();
|
|
3376
|
+
const on = (event, listener) => {
|
|
3377
|
+
if (!_eventMap.has(event)) {
|
|
3378
|
+
_eventMap.set(event, []);
|
|
3379
|
+
}
|
|
3380
|
+
_eventMap.get(event).push(listener);
|
|
3381
|
+
};
|
|
3382
|
+
const emit = (event, ...args) => {
|
|
3383
|
+
var _a;
|
|
3384
|
+
(_a = _eventMap.get(event)) == null ? void 0 : _a.forEach((listener) => listener(...args));
|
|
3385
|
+
};
|
|
3386
|
+
const off = (event, listener) => {
|
|
3387
|
+
if (!listener) {
|
|
3388
|
+
_eventMap.delete(event);
|
|
3389
|
+
} else {
|
|
3390
|
+
const listeners = _eventMap.get(event);
|
|
3391
|
+
if (listeners) {
|
|
3392
|
+
_eventMap.set(
|
|
3393
|
+
event,
|
|
3394
|
+
listeners.filter((l) => l !== listener)
|
|
3395
|
+
);
|
|
3396
|
+
}
|
|
3397
|
+
}
|
|
3398
|
+
};
|
|
3399
|
+
return { on, emit, off };
|
|
3400
|
+
};
|
|
3401
|
+
const LibJsLerp = (start, end, value) => {
|
|
3402
|
+
const t = Math.min(Math.max(value, 0), 1);
|
|
3403
|
+
return start * (1 - t) + end * t;
|
|
3404
|
+
};
|
|
3405
|
+
const LibJsNormalizeInRange = (start, end, value) => {
|
|
3406
|
+
return Math.max(0, Math.min((start - value) / (start - end), 1));
|
|
3407
|
+
};
|
|
3408
|
+
const Base = {
|
|
3409
|
+
/**
|
|
3410
|
+
* @description 返回数据类型
|
|
3411
|
+
* @param v 需要判断类型的数据
|
|
3412
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsColorConsole-有色打印
|
|
3413
|
+
*/
|
|
3414
|
+
libJsGetDataType,
|
|
3415
|
+
/**
|
|
3416
|
+
* @description 延时执行,切换到其他页面会暂停
|
|
3417
|
+
* @param delay 延时毫秒数
|
|
3418
|
+
* @param fn 延时执行函数
|
|
3419
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsPromiseTimeout-延时执行
|
|
3420
|
+
*/
|
|
3421
|
+
libJsPromiseTimeout
|
|
3422
|
+
};
|
|
3423
|
+
const Browser = {
|
|
3424
|
+
/** @description console颜色打印
|
|
3425
|
+
* @param title 标题
|
|
3426
|
+
* @param color 颜色
|
|
3427
|
+
* @param logs 信息
|
|
3428
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsColorConsole-有色打印
|
|
3429
|
+
*/
|
|
3430
|
+
libJsColorConsole,
|
|
3431
|
+
/** @description 判断是否为移动设备
|
|
3432
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsIsMobile-判断手机
|
|
3433
|
+
*/
|
|
3434
|
+
libJsIsMobile,
|
|
3435
|
+
/** @description 判断是否为平板
|
|
3436
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsIsPad-判断平板
|
|
3437
|
+
*/
|
|
3438
|
+
libJsIsPad,
|
|
3439
|
+
/** @description 获取浏览器地址栏参数
|
|
3440
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsPathParams-地址栏参数
|
|
3441
|
+
*/
|
|
3442
|
+
libJsPathParams,
|
|
3443
|
+
/** @description 动态设置网站标题及图标
|
|
3444
|
+
* @param title 网站标题
|
|
3445
|
+
* @param url 网站图标地址
|
|
3446
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsSetTitleIcon-网站标题图标
|
|
3447
|
+
*/
|
|
3448
|
+
libJsSetTitleIcon,
|
|
3449
|
+
/** @description 网站标题交互,当从当前网页切换到其他网页,网站标题自动切换
|
|
3450
|
+
* @param backTitle 从其他网页返回时显示的标题
|
|
3451
|
+
* @param leaveTitle 从当前网页离开时显示的标题
|
|
3452
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsTagTitleTip-网站标题交互
|
|
3453
|
+
*/
|
|
3454
|
+
libJsTagTitleTip,
|
|
3455
|
+
/** @description 对象转为url参数
|
|
3456
|
+
* @param params 对象参数
|
|
3457
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsObjToUrlParams-对象转Url参数
|
|
3458
|
+
*/
|
|
3459
|
+
libJsObjToUrlParams
|
|
3460
|
+
};
|
|
3461
|
+
const Data = {
|
|
3462
|
+
/**
|
|
3463
|
+
* @description 将数组拆分成指定数组元素数量的多个数组
|
|
3464
|
+
* @param arr 需要拆分的数组
|
|
3465
|
+
* @param chunkSize 每个数组的元素数量
|
|
3466
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsChunkArray-数组拆分
|
|
3467
|
+
*/
|
|
3468
|
+
libJsChunkArray,
|
|
3469
|
+
/** @description 递归将JSON字符串深度解析为对象
|
|
3470
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsDeepJSONParse-深度解析JSON
|
|
3471
|
+
*/
|
|
3472
|
+
libJsDeepJSONParse,
|
|
3473
|
+
/**
|
|
3474
|
+
* @description 分类汇总,将数组对象按照指定键值整理成一个以键值为键名的对象
|
|
3475
|
+
* @param arr 要分组的数组
|
|
3476
|
+
* @param key 分组的键
|
|
3477
|
+
* @returns 分组后的对象
|
|
3478
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsGroupArrayByKey-分类汇总
|
|
3479
|
+
*/
|
|
3480
|
+
libJsGroupArrayByKey,
|
|
3481
|
+
/**
|
|
3482
|
+
* @description 匹配电子邮件,可用于实时输入时,自动补全常用邮箱后缀
|
|
3483
|
+
* @param str 要匹配的字符串
|
|
3484
|
+
* @param emailList 电子邮件后缀列表
|
|
3485
|
+
* @returns 匹配结果数组
|
|
3486
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsMatchEmail-匹配E-Mail
|
|
3487
|
+
*/
|
|
3488
|
+
libJsMatchEmail,
|
|
3489
|
+
/** @description 数组乱序
|
|
3490
|
+
* @param arr 需要乱序的数组
|
|
3491
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsShuffleArray-数组乱序
|
|
3492
|
+
*/
|
|
3493
|
+
libJsShuffleArray,
|
|
3494
|
+
/** @description 数组元素整体步数移动
|
|
3495
|
+
* @param arr 移动的数组
|
|
3496
|
+
* @param step 负数为向后移动,正数为向前移动
|
|
3497
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsStepArray-数组偏移
|
|
3498
|
+
*/
|
|
3499
|
+
libJsStepArray,
|
|
3500
|
+
/** @description 翻转指定索引后面的数组
|
|
3501
|
+
* @param arr 数组
|
|
3502
|
+
* @param index 开始索引
|
|
3503
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-js#LibReverseArrayFromIndex-数组定位翻转
|
|
3504
|
+
*/
|
|
3505
|
+
libReverseArrayFromIndex
|
|
3506
|
+
};
|
|
3507
|
+
const File$1 = {
|
|
3508
|
+
/** @description 下载图片链接
|
|
3509
|
+
* @param link 图片链接
|
|
3510
|
+
* @param name 图片名称
|
|
3511
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsDownloadImageLink-图片下载
|
|
3512
|
+
*/
|
|
3513
|
+
libJsDownloadImageLink,
|
|
3514
|
+
/** @description 图片压缩
|
|
3515
|
+
* @param obj 压缩参数
|
|
3516
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsImageOptimizer-图片压缩
|
|
3517
|
+
*/
|
|
3518
|
+
libJsImageOptimizer,
|
|
3519
|
+
/**
|
|
3520
|
+
* @description 保存文件到本地
|
|
3521
|
+
* @param data 要保存的数据
|
|
3522
|
+
* @param name 文件名
|
|
3523
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsSaveJson-保存文件
|
|
3524
|
+
*/
|
|
3525
|
+
libJsSaveJson
|
|
3526
|
+
};
|
|
3527
|
+
const Formatter = {
|
|
3528
|
+
/**
|
|
3529
|
+
* @description 格式化字节大小
|
|
3530
|
+
* @param bytes 字节数
|
|
3531
|
+
* @returns ['大小', '单位', '大小及单位']
|
|
3532
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsFormatterByte-字节格式化
|
|
3533
|
+
*/
|
|
3534
|
+
libJsFormatterByte,
|
|
3535
|
+
/**
|
|
3536
|
+
* @description 隐藏手机号码中间的四位数字
|
|
3537
|
+
* @param mobile 需要处理的手机号码
|
|
3538
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsMaskPhoneNumber-隐藏手机号码
|
|
3539
|
+
*/
|
|
3540
|
+
libJsMaskPhoneNumber,
|
|
3541
|
+
/**
|
|
3542
|
+
* @description 数字每三位添加逗号
|
|
3543
|
+
* @param num 需要格式化的数字
|
|
3544
|
+
* @param reserve 保留小数位数
|
|
3545
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsNumComma-数字逗号
|
|
3546
|
+
*/
|
|
3547
|
+
libJsNumComma,
|
|
3548
|
+
/** @description 将大于1000的数字使用k为单位
|
|
3549
|
+
* @param num 数字
|
|
3550
|
+
* @param units 单位组,key为单位,value为格式化阈值
|
|
3551
|
+
* @returns [数字, 单位]
|
|
3552
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsNumberUnit-数字单位
|
|
3553
|
+
*/
|
|
3554
|
+
libJsNumberUnit,
|
|
3555
|
+
/**
|
|
3556
|
+
* @description 将秒数格式化为中文时间描述,支持扩展到年和月
|
|
3557
|
+
* @param seconds 秒数
|
|
3558
|
+
* @returns 格式化后的中文时间
|
|
3559
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsSecondsFormatterChinese-中文时间
|
|
3560
|
+
*/
|
|
3561
|
+
libJsSecondsFormatterChinese
|
|
3562
|
+
};
|
|
3563
|
+
const Math$1 = {
|
|
3564
|
+
/** @description 计算表达式字符串
|
|
3565
|
+
* @param expression 表达式字符串
|
|
3566
|
+
* @param point 小数点精度
|
|
3567
|
+
* @returns 计算结果
|
|
3568
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsCalculateExpression-表达式字符串
|
|
3569
|
+
*/
|
|
3570
|
+
libJsCalculateExpression,
|
|
3571
|
+
/**
|
|
3572
|
+
* @description 角度和弧度互相转换
|
|
3573
|
+
* @param value 角度值或弧度值
|
|
3574
|
+
* @param type 角度类型或弧度类型
|
|
3575
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsConvertAngle-角弧度互转
|
|
3576
|
+
*/
|
|
3577
|
+
libJsConvertAngle,
|
|
3578
|
+
/** @description 计算两点角度
|
|
3579
|
+
* @param coord1 起点坐标
|
|
3580
|
+
* @param coord2 终点坐标
|
|
3581
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsCoordsAngle-两点角度
|
|
3582
|
+
*/
|
|
3583
|
+
libJsCoordsAngle,
|
|
3584
|
+
/** @description 计算两点距离
|
|
3585
|
+
* @param coord1 起点坐标
|
|
3586
|
+
* @param coord2 终点坐标
|
|
3587
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsCoordsDistance-两点距离
|
|
3588
|
+
*/
|
|
3589
|
+
libJsCoordsDistance,
|
|
3590
|
+
/** @description 计算两个数的运算结果,并保留指定位数的小数
|
|
3591
|
+
* @param num1 第一个数
|
|
3592
|
+
* @param num2 第二个数
|
|
3593
|
+
* @param operator 运算符,支持加减乘除
|
|
3594
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsDecimal-高精度计算
|
|
3595
|
+
*/
|
|
3596
|
+
libJsDecimal
|
|
3597
|
+
};
|
|
3598
|
+
const Misc = {
|
|
3599
|
+
/**
|
|
3600
|
+
* @description 表单验证函数
|
|
3601
|
+
* @param form 表单数据对象
|
|
3602
|
+
* @param rules 验证规则数组
|
|
3603
|
+
* @returns 验证结果数组,包含未通过验证的项
|
|
3604
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsRegFormValidate-表单验证
|
|
3605
|
+
*/
|
|
3606
|
+
libJsRegFormValidate,
|
|
3607
|
+
/** @description 请求失败重连
|
|
3608
|
+
* @param promiseFn 请求函数
|
|
3609
|
+
* @param maxRetries 最大重试次数
|
|
3610
|
+
* @param retryDelay 重试间隔时间
|
|
3611
|
+
* @param params 请求参数
|
|
3612
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsRetryRequest-请求重连
|
|
3613
|
+
*/
|
|
3614
|
+
libJsRetryRequest,
|
|
3615
|
+
/** @description 数字步进器
|
|
3616
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsNumberStepper-数字步进器
|
|
3617
|
+
*/
|
|
3618
|
+
LibJsNumberStepper,
|
|
3619
|
+
/** @description 事件管理器
|
|
3620
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsEmitter-事件管理器
|
|
3621
|
+
*/
|
|
3622
|
+
LibJsEmitter,
|
|
3623
|
+
/** @description 线性插值
|
|
3624
|
+
* @param start 当 value = 0 时,返回 start
|
|
3625
|
+
* @param end 当 value = 1 时,返回 end
|
|
3626
|
+
* @param value 插值比例,取值范围 0~1
|
|
3627
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsLerp-线性插值
|
|
3628
|
+
*/
|
|
3629
|
+
LibJsLerp,
|
|
3630
|
+
/** @description 值介于起点与终点之间时返回一个介于0与1之间的数
|
|
3631
|
+
* @param start 起点
|
|
3632
|
+
* @param end 终点
|
|
3633
|
+
* @param value 动态值
|
|
3634
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsNormalizeInRange-范围归一化
|
|
3635
|
+
*/
|
|
3636
|
+
LibJsNormalizeInRange
|
|
3637
|
+
};
|
|
3638
|
+
const Random = {
|
|
3639
|
+
/** @description 百分比概率结果
|
|
3640
|
+
* @param probability 触发概率,百分比,0-100
|
|
3641
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsProbabilityResult-概率触发
|
|
3642
|
+
*/
|
|
3643
|
+
libJsProbabilityResult,
|
|
3644
|
+
/** @description 随机数
|
|
3645
|
+
* @param min 最小值
|
|
3646
|
+
* @param max 最大值
|
|
3647
|
+
* @param num 保留小数位数
|
|
3648
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsRandom-随机数
|
|
3649
|
+
*/
|
|
3650
|
+
libJsRandom,
|
|
3651
|
+
/** @description 随机 RGBA 颜色
|
|
3652
|
+
* @param alpha 透明度
|
|
3653
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsRandomColor-随机色
|
|
3654
|
+
*/
|
|
3655
|
+
libJsRandomColor,
|
|
3656
|
+
/** @description 随机生成n个指定范围的随机数数组
|
|
3657
|
+
* @param min 最小值
|
|
3658
|
+
* @param max 最大值
|
|
3659
|
+
* @param count 数组长度
|
|
3660
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsUniqueRandomNumbers-随机数数组
|
|
3661
|
+
*/
|
|
3662
|
+
libJsUniqueRandomNumbers
|
|
3663
|
+
};
|
|
3664
|
+
const Time = {
|
|
3665
|
+
/**
|
|
3666
|
+
* @description 传入时间戳与当前时间判断是否为同一天或同一周
|
|
3667
|
+
* @param timestamp 毫秒时间戳
|
|
3668
|
+
* @param unit 判断单位
|
|
3669
|
+
* @returns 0-同一单位时间 1-新单位时间 -1时间戳大于当前时间
|
|
3670
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsSameTimeCheck-时间比对
|
|
3671
|
+
*/
|
|
3672
|
+
libJsSameTimeCheck,
|
|
3673
|
+
/** @description 时间差计算
|
|
3674
|
+
* @param timestamp 毫秒时间戳
|
|
3675
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsTimeAgo-中文时间差
|
|
3676
|
+
*/
|
|
3677
|
+
libJsTimeAgo,
|
|
3678
|
+
/**
|
|
3679
|
+
* @description 根据当前时间返回问候语
|
|
3680
|
+
* @param greet 自定义问候语对象
|
|
3681
|
+
* @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsTimeGreeting-时间问候
|
|
3682
|
+
*/
|
|
3683
|
+
libJsTimeGreeting
|
|
3684
|
+
};
|
|
3685
|
+
const LibJs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
3686
|
+
__proto__: null,
|
|
3687
|
+
Base,
|
|
3688
|
+
Browser,
|
|
3689
|
+
Data,
|
|
3690
|
+
File: File$1,
|
|
3691
|
+
Formatter,
|
|
3692
|
+
Math: Math$1,
|
|
3693
|
+
Misc,
|
|
3694
|
+
Random,
|
|
3695
|
+
Time
|
|
3696
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
3697
|
+
window.LibJs = LibJs;
|
|
3698
|
+
});
|