Repository navigation
Expand file tree
/
Copy pathBigInteger-D1cEhss9.js
More file actions
3 lines (3 loc) · 20.9 KB
/
Copy pathBigInteger-D1cEhss9.js
File metadata and controls
3 lines (3 loc) · 20.9 KB
1
2
3
//# allFunctionsCalledOnLoad
import{t as e}from"./rolldown-runtime-BJUb_-bc.js";var t=e(((e,t)=>{var n=(function(e){var t=1e7,r=9007199254740992,i=f(r),a=`0123456789abcdefghijklmnopqrstuvwxyz`,o=typeof BigInt==`function`;function s(e,t,n,r){return e===void 0?s[0]:t===void 0||+t==10&&!n?Q(e):re(e,t,n,r)}function c(e,t){this.value=e,this.sign=t,this.isSmall=!1}c.prototype=Object.create(s.prototype);function l(e){this.value=e,this.sign=e<0,this.isSmall=!0}l.prototype=Object.create(s.prototype);function u(e){this.value=e}u.prototype=Object.create(s.prototype);function d(e){return-r<e&&e<r}function f(e){return e<1e7?[e]:e<0x5af3107a4000?[e%1e7,Math.floor(e/1e7)]:[e%1e7,Math.floor(e/1e7)%1e7,Math.floor(e/0x5af3107a4000)]}function p(e){m(e);var n=e.length;if(n<4&&M(e,i)<0)switch(n){case 0:return 0;case 1:return e[0];case 2:return e[0]+e[1]*t;default:return e[0]+(e[1]+e[2]*t)*t}return e}function m(e){for(var t=e.length;e[--t]===0;);e.length=t+1}function h(e){for(var t=Array(e),n=-1;++n<e;)t[n]=0;return t}function g(e){return e>0?Math.floor(e):Math.ceil(e)}function _(e,n){for(var r=e.length,i=n.length,a=Array(r),o=0,s=t,c,l=0;l<i;l++)c=e[l]+n[l]+o,o=+(c>=s),a[l]=c-o*s;for(;l<r;)c=e[l]+o,o=+(c===s),a[l++]=c-o*s;return o>0&&a.push(o),a}function v(e,t){return e.length>=t.length?_(e,t):_(t,e)}function y(e,n){for(var r=e.length,i=Array(r),a=t,o,s=0;s<r;s++)o=e[s]-a+n,n=Math.floor(o/a),i[s]=o-n*a,n+=1;for(;n>0;)i[s++]=n%a,n=Math.floor(n/a);return i}c.prototype.add=function(e){var t=Q(e);if(this.sign!==t.sign)return this.subtract(t.negate());var n=this.value,r=t.value;return t.isSmall?new c(y(n,Math.abs(r)),this.sign):new c(v(n,r),this.sign)},c.prototype.plus=c.prototype.add,l.prototype.add=function(e){var t=Q(e),n=this.value;if(n<0!==t.sign)return this.subtract(t.negate());var r=t.value;if(t.isSmall){if(d(n+r))return new l(n+r);r=f(Math.abs(r))}return new c(y(r,Math.abs(n)),n<0)},l.prototype.plus=l.prototype.add,u.prototype.add=function(e){return new u(this.value+Q(e).value)},u.prototype.plus=u.prototype.add;function b(e,n){for(var r=e.length,i=n.length,a=Array(r),o=0,s=t,c=0,l;c<i;c++)l=e[c]-o-n[c],l<0?(l+=s,o=1):o=0,a[c]=l;for(c=i;c<r;c++){if(l=e[c]-o,l<0)l+=s;else{a[c++]=l;break}a[c]=l}for(;c<r;c++)a[c]=e[c];return m(a),a}function x(e,t,n){var r;return M(e,t)>=0?r=b(e,t):(r=b(t,e),n=!n),r=p(r),typeof r==`number`?(n&&(r=-r),new l(r)):new c(r,n)}function S(e,n,r){for(var i=e.length,a=Array(i),o=-n,s=t,u=0,d;u<i;u++)d=e[u]+o,o=Math.floor(d/s),d%=s,a[u]=d<0?d+s:d;return a=p(a),typeof a==`number`?(r&&(a=-a),new l(a)):new c(a,r)}c.prototype.subtract=function(e){var t=Q(e);if(this.sign!==t.sign)return this.add(t.negate());var n=this.value,r=t.value;return t.isSmall?S(n,Math.abs(r),this.sign):x(n,r,this.sign)},c.prototype.minus=c.prototype.subtract,l.prototype.subtract=function(e){var t=Q(e),n=this.value;if(n<0!==t.sign)return this.add(t.negate());var r=t.value;return t.isSmall?new l(n-r):S(r,Math.abs(n),n>=0)},l.prototype.minus=l.prototype.subtract,u.prototype.subtract=function(e){return new u(this.value-Q(e).value)},u.prototype.minus=u.prototype.subtract,c.prototype.negate=function(){return new c(this.value,!this.sign)},l.prototype.negate=function(){var e=this.sign,t=new l(-this.value);return t.sign=!e,t},u.prototype.negate=function(){return new u(-this.value)},c.prototype.abs=function(){return new c(this.value,!1)},l.prototype.abs=function(){return new l(Math.abs(this.value))},u.prototype.abs=function(){return new u(this.value>=0?this.value:-this.value)};function C(e,n){for(var r=e.length,i=n.length,a=h(r+i),o=t,s,c,l=0,u,d;l<r;++l){u=e[l];for(var f=0;f<i;++f)d=n[f],s=u*d+a[l+f],c=Math.floor(s/o),a[l+f]=s-c*o,a[l+f+1]+=c}return m(a),a}function w(e,n){for(var r=e.length,i=Array(r),a=t,o=0,s,c=0;c<r;c++)s=e[c]*n+o,o=Math.floor(s/a),i[c]=s-o*a;for(;o>0;)i[c++]=o%a,o=Math.floor(o/a);return i}function T(e,t){for(var n=[];t-->0;)n.push(0);return n.concat(e)}function E(e,t){var n=Math.max(e.length,t.length);if(n<=30)return C(e,t);n=Math.ceil(n/2);var r=e.slice(n),i=e.slice(0,n),a=t.slice(n),o=t.slice(0,n),s=E(i,o),c=E(r,a),l=v(v(s,T(b(b(E(v(i,r),v(o,a)),s),c),n)),T(c,2*n));return m(l),l}function D(e,t){return-.012*e-.012*t+15e-6*e*t>0}c.prototype.multiply=function(e){var n=Q(e),r=this.value,i=n.value,a=this.sign!==n.sign,o;if(n.isSmall){if(i===0)return s[0];if(i===1)return this;if(i===-1)return this.negate();if(o=Math.abs(i),o<t)return new c(w(r,o),a);i=f(o)}return D(r.length,i.length)?new c(E(r,i),a):new c(C(r,i),a)},c.prototype.times=c.prototype.multiply;function O(e,n,r){return e<t?new c(w(n,e),r):new c(C(n,f(e)),r)}l.prototype._multiplyBySmall=function(e){return d(e.value*this.value)?new l(e.value*this.value):O(Math.abs(e.value),f(Math.abs(this.value)),this.sign!==e.sign)},c.prototype._multiplyBySmall=function(e){return e.value===0?s[0]:e.value===1?this:e.value===-1?this.negate():O(Math.abs(e.value),this.value,this.sign!==e.sign)},l.prototype.multiply=function(e){return Q(e)._multiplyBySmall(this)},l.prototype.times=l.prototype.multiply,u.prototype.multiply=function(e){return new u(this.value*Q(e).value)},u.prototype.times=u.prototype.multiply;function k(e){for(var n=e.length,r=h(n+n),i=t,a,o,s=0,c,l;s<n;s++){c=e[s],o=0-c*c;for(var u=s;u<n;u++)l=e[u],a=c*l*2+r[s+u]+o,o=Math.floor(a/i),r[s+u]=a-o*i;r[s+n]=o}return m(r),r}c.prototype.square=function(){return new c(k(this.value),!1)},l.prototype.square=function(){var e=this.value*this.value;return d(e)?new l(e):new c(k(f(Math.abs(this.value))),!1)},u.prototype.square=function(e){return new u(this.value*this.value)};function ee(e,n){var r=e.length,i=n.length,a=t,o=h(n.length),s=n[i-1],c=Math.ceil(a/(2*s)),l=w(e,c),u=w(n,c),d,f,m,g,_,v,y;for(l.length<=r&&l.push(0),u.push(0),s=u[i-1],f=r-i;f>=0;f--){for(d=a-1,l[f+i]!==s&&(d=Math.floor((l[f+i]*a+l[f+i-1])/s)),m=0,g=0,v=u.length,_=0;_<v;_++)m+=d*u[_],y=Math.floor(m/a),g+=l[f+_]-(m-y*a),m=y,g<0?(l[f+_]=g+a,g=-1):(l[f+_]=g,g=0);for(;g!==0;){for(--d,m=0,_=0;_<v;_++)m+=l[f+_]-a+u[_],m<0?(l[f+_]=m+a,m=0):(l[f+_]=m,m=1);g+=m}o[f]=d}return l=A(l,c)[0],[p(o),p(l)]}function te(e,n){for(var r=e.length,i=n.length,a=[],o=[],s=t,c,l,u,d,f;r;)if(o.unshift(e[--r]),m(o),M(o,n)<0)a.push(0);else{l=o.length,u=o[l-1]*s+o[l-2],d=n[i-1]*s+n[i-2],l>i&&(u=(u+1)*s),c=Math.ceil(u/d);do{if(f=w(n,c),M(f,o)<=0)break;c--}while(c);a.push(c),o=b(o,f)}return a.reverse(),[p(a),p(o)]}function A(e,n){var r=e.length,i=h(r),a=t,o,s,c=0,l;for(o=r-1;o>=0;--o)l=c*a+e[o],s=g(l/n),c=l-s*n,i[o]=s|0;return[i,c|0]}function j(e,n){var r,i=Q(n);if(o)return[new u(e.value/i.value),new u(e.value%i.value)];var a=e.value,d=i.value,m;if(d===0)throw Error(`Cannot divide by zero`);if(e.isSmall)return i.isSmall?[new l(g(a/d)),new l(a%d)]:[s[0],e];if(i.isSmall){if(d===1)return[e,s[0]];if(d==-1)return[e.negate(),s[0]];var h=Math.abs(d);if(h<t){r=A(a,h),m=p(r[0]);var _=r[1];return e.sign&&(_=-_),typeof m==`number`?(e.sign!==i.sign&&(m=-m),[new l(m),new l(_)]):[new c(m,e.sign!==i.sign),new l(_)]}d=f(h)}var v=M(a,d);if(v===-1)return[s[0],e];if(v===0)return[s[e.sign===i.sign?1:-1],s[0]];r=a.length+d.length<=200?ee(a,d):te(a,d),m=r[0];var y=e.sign!==i.sign,b=r[1],x=e.sign;return typeof m==`number`?(y&&(m=-m),m=new l(m)):m=new c(m,y),typeof b==`number`?(x&&(b=-b),b=new l(b)):b=new c(b,x),[m,b]}c.prototype.divmod=function(e){var t=j(this,e);return{quotient:t[0],remainder:t[1]}},u.prototype.divmod=l.prototype.divmod=c.prototype.divmod,c.prototype.divide=function(e){return j(this,e)[0]},u.prototype.over=u.prototype.divide=function(e){return new u(this.value/Q(e).value)},l.prototype.over=l.prototype.divide=c.prototype.over=c.prototype.divide,c.prototype.mod=function(e){return j(this,e)[1]},u.prototype.mod=u.prototype.remainder=function(e){return new u(this.value%Q(e).value)},l.prototype.remainder=l.prototype.mod=c.prototype.remainder=c.prototype.mod,c.prototype.pow=function(e){var t=Q(e),n=this.value,r=t.value,i,a,o;if(r===0)return s[1];if(n===0)return s[0];if(n===1)return s[1];if(n===-1)return t.isEven()?s[1]:s[-1];if(t.sign)return s[0];if(!t.isSmall)throw Error(`The exponent `+t.toString()+` is too large.`);if(this.isSmall&&d(i=n**+r))return new l(g(i));for(a=this,o=s[1];r&!0&&(o=o.times(a),--r),r!==0;)r/=2,a=a.square();return o},l.prototype.pow=c.prototype.pow,u.prototype.pow=function(e){var t=Q(e),n=this.value,r=t.value,i=BigInt(0),a=BigInt(1),o=BigInt(2);if(r===i)return s[1];if(n===i)return s[0];if(n===a)return s[1];if(n===BigInt(-1))return t.isEven()?s[1]:s[-1];if(t.isNegative())return new u(i);for(var c=this,l=s[1];(r&a)===a&&(l=l.times(c),--r),r!==i;)r/=o,c=c.square();return l},c.prototype.modPow=function(e,t){if(e=Q(e),t=Q(t),t.isZero())throw Error(`Cannot take modPow with modulus 0`);var n=s[1],r=this.mod(t);for(e.isNegative()&&(e=e.multiply(s[-1]),r=r.modInv(t));e.isPositive();){if(r.isZero())return s[0];e.isOdd()&&(n=n.multiply(r).mod(t)),e=e.divide(2),r=r.square().mod(t)}return n},u.prototype.modPow=l.prototype.modPow=c.prototype.modPow;function M(e,t){if(e.length!==t.length)return e.length>t.length?1:-1;for(var n=e.length-1;n>=0;n--)if(e[n]!==t[n])return e[n]>t[n]?1:-1;return 0}c.prototype.compareAbs=function(e){var t=Q(e),n=this.value,r=t.value;return t.isSmall?1:M(n,r)},l.prototype.compareAbs=function(e){var t=Q(e),n=Math.abs(this.value),r=t.value;return t.isSmall?(r=Math.abs(r),n===r?0:n>r?1:-1):-1},u.prototype.compareAbs=function(e){var t=this.value,n=Q(e).value;return t=t>=0?t:-t,n=n>=0?n:-n,t===n?0:t>n?1:-1},c.prototype.compare=function(e){if(e===1/0)return-1;if(e===-1/0)return 1;var t=Q(e),n=this.value,r=t.value;return this.sign===t.sign?t.isSmall?this.sign?-1:1:M(n,r)*(this.sign?-1:1):t.sign?1:-1},c.prototype.compareTo=c.prototype.compare,l.prototype.compare=function(e){if(e===1/0)return-1;if(e===-1/0)return 1;var t=Q(e),n=this.value,r=t.value;return t.isSmall?n==r?0:n>r?1:-1:n<0===t.sign?n<0?1:-1:n<0?-1:1},l.prototype.compareTo=l.prototype.compare,u.prototype.compare=function(e){if(e===1/0)return-1;if(e===-1/0)return 1;var t=this.value,n=Q(e).value;return t===n?0:t>n?1:-1},u.prototype.compareTo=u.prototype.compare,c.prototype.equals=function(e){return this.compare(e)===0},u.prototype.eq=u.prototype.equals=l.prototype.eq=l.prototype.equals=c.prototype.eq=c.prototype.equals,c.prototype.notEquals=function(e){return this.compare(e)!==0},u.prototype.neq=u.prototype.notEquals=l.prototype.neq=l.prototype.notEquals=c.prototype.neq=c.prototype.notEquals,c.prototype.greater=function(e){return this.compare(e)>0},u.prototype.gt=u.prototype.greater=l.prototype.gt=l.prototype.greater=c.prototype.gt=c.prototype.greater,c.prototype.lesser=function(e){return this.compare(e)<0},u.prototype.lt=u.prototype.lesser=l.prototype.lt=l.prototype.lesser=c.prototype.lt=c.prototype.lesser,c.prototype.greaterOrEquals=function(e){return this.compare(e)>=0},u.prototype.geq=u.prototype.greaterOrEquals=l.prototype.geq=l.prototype.greaterOrEquals=c.prototype.geq=c.prototype.greaterOrEquals,c.prototype.lesserOrEquals=function(e){return this.compare(e)<=0},u.prototype.leq=u.prototype.lesserOrEquals=l.prototype.leq=l.prototype.lesserOrEquals=c.prototype.leq=c.prototype.lesserOrEquals,c.prototype.isEven=function(){return!(this.value[0]&1)},l.prototype.isEven=function(){return!(this.value&1)},u.prototype.isEven=function(){return(this.value&BigInt(1))===BigInt(0)},c.prototype.isOdd=function(){return(this.value[0]&1)==1},l.prototype.isOdd=function(){return(this.value&1)==1},u.prototype.isOdd=function(){return(this.value&BigInt(1))===BigInt(1)},c.prototype.isPositive=function(){return!this.sign},l.prototype.isPositive=function(){return this.value>0},u.prototype.isPositive=l.prototype.isPositive,c.prototype.isNegative=function(){return this.sign},l.prototype.isNegative=function(){return this.value<0},u.prototype.isNegative=l.prototype.isNegative,c.prototype.isUnit=function(){return!1},l.prototype.isUnit=function(){return Math.abs(this.value)===1},u.prototype.isUnit=function(){return this.abs().value===BigInt(1)},c.prototype.isZero=function(){return!1},l.prototype.isZero=function(){return this.value===0},u.prototype.isZero=function(){return this.value===BigInt(0)},c.prototype.isDivisibleBy=function(e){var t=Q(e);return t.isZero()?!1:t.isUnit()?!0:t.compareAbs(2)===0?this.isEven():this.mod(t).isZero()},u.prototype.isDivisibleBy=l.prototype.isDivisibleBy=c.prototype.isDivisibleBy;function N(e){var t=e.abs();if(t.isUnit())return!1;if(t.equals(2)||t.equals(3)||t.equals(5))return!0;if(t.isEven()||t.isDivisibleBy(3)||t.isDivisibleBy(5))return!1;if(t.lesser(49))return!0}function P(e,t){for(var r=e.prev(),i=r,a=0,o,s,c;i.isEven();)i=i.divide(2),a++;next:for(s=0;s<t.length;s++)if(!e.lesser(t[s])&&(c=n(t[s]).modPow(i,e),!(c.isUnit()||c.equals(r)))){for(o=a-1;o!=0;o--){if(c=c.square().mod(e),c.isUnit())return!1;if(c.equals(r))continue next}return!1}return!0}c.prototype.isPrime=function(t){var r=N(this);if(r!==e)return r;var i=this.abs(),a=i.bitLength();if(a<=64)return P(i,[2,3,5,7,11,13,17,19,23,29,31,37]);for(var o=Math.log(2)*a.toJSNumber(),s=Math.ceil(t===!0?2*o**2:o),c=[],l=0;l<s;l++)c.push(n(l+2));return P(i,c)},u.prototype.isPrime=l.prototype.isPrime=c.prototype.isPrime,c.prototype.isProbablePrime=function(t,r){var i=N(this);if(i!==e)return i;for(var a=this.abs(),o=t===e?5:t,s=[],c=0;c<o;c++)s.push(n.randBetween(2,a.minus(2),r));return P(a,s)},u.prototype.isProbablePrime=l.prototype.isProbablePrime=c.prototype.isProbablePrime,c.prototype.modInv=function(e){for(var t=n.zero,r=n.one,i=Q(e),a=this.abs(),o,s,c;!a.isZero();)o=i.divide(a),s=t,c=i,t=r,i=a,r=s.subtract(o.multiply(r)),a=c.subtract(o.multiply(a));if(!i.isUnit())throw Error(this.toString()+` and `+e.toString()+` are not co-prime`);return t.compare(0)===-1&&(t=t.add(e)),this.isNegative()?t.negate():t},u.prototype.modInv=l.prototype.modInv=c.prototype.modInv,c.prototype.next=function(){var e=this.value;return this.sign?S(e,1,this.sign):new c(y(e,1),this.sign)},l.prototype.next=function(){var e=this.value;return e+1<r?new l(e+1):new c(i,!1)},u.prototype.next=function(){return new u(this.value+BigInt(1))},c.prototype.prev=function(){var e=this.value;return this.sign?new c(y(e,1),!0):S(e,1,this.sign)},l.prototype.prev=function(){var e=this.value;return e-1>-r?new l(e-1):new c(i,!0)},u.prototype.prev=function(){return new u(this.value-BigInt(1))};for(var F=[1];2*F[F.length-1]<=t;)F.push(2*F[F.length-1]);var I=F.length,L=F[I-1];function R(e){return Math.abs(e)<=t}c.prototype.shiftLeft=function(e){var t=Q(e).toJSNumber();if(!R(t))throw Error(String(t)+` is too large for shifting.`);if(t<0)return this.shiftRight(-t);var n=this;if(n.isZero())return n;for(;t>=I;)n=n.multiply(L),t-=I-1;return n.multiply(F[t])},u.prototype.shiftLeft=l.prototype.shiftLeft=c.prototype.shiftLeft,c.prototype.shiftRight=function(e){var t,n=Q(e).toJSNumber();if(!R(n))throw Error(String(n)+` is too large for shifting.`);if(n<0)return this.shiftLeft(-n);for(var r=this;n>=I;){if(r.isZero()||r.isNegative()&&r.isUnit())return r;t=j(r,L),r=t[1].isNegative()?t[0].prev():t[0],n-=I-1}return t=j(r,F[n]),t[1].isNegative()?t[0].prev():t[0]},u.prototype.shiftRight=l.prototype.shiftRight=c.prototype.shiftRight;function z(e,t,r){t=Q(t);for(var i=e.isNegative(),a=t.isNegative(),o=i?e.not():e,s=a?t.not():t,c=0,l=0,u=null,d=null,f=[];!o.isZero()||!s.isZero();)u=j(o,L),c=u[1].toJSNumber(),i&&(c=L-1-c),d=j(s,L),l=d[1].toJSNumber(),a&&(l=L-1-l),o=u[0],s=d[0],f.push(r(c,l));for(var p=r(+!!i,+!!a)===0?n(0):n(-1),m=f.length-1;m>=0;--m)p=p.multiply(L).add(n(f[m]));return p}c.prototype.not=function(){return this.negate().prev()},u.prototype.not=l.prototype.not=c.prototype.not,c.prototype.and=function(e){return z(this,e,function(e,t){return e&t})},u.prototype.and=l.prototype.and=c.prototype.and,c.prototype.or=function(e){return z(this,e,function(e,t){return e|t})},u.prototype.or=l.prototype.or=c.prototype.or,c.prototype.xor=function(e){return z(this,e,function(e,t){return e^t})},u.prototype.xor=l.prototype.xor=c.prototype.xor;var B=1<<30,V=(t&-t)*(t&-t)|B;function H(e){var n=e.value,r=typeof n==`number`?n|B:typeof n==`bigint`?n|BigInt(B):n[0]+n[1]*t|V;return r&-r}function U(e,t){if(t.compareTo(e)<=0){var r=U(e,t.square(t)),i=r.p,a=r.e,o=i.multiply(t);return o.compareTo(e)<=0?{p:o,e:a*2+1}:{p:i,e:a*2}}return{p:n(1),e:0}}c.prototype.bitLength=function(){var e=this;return e.compareTo(n(0))<0&&(e=e.negate().subtract(n(1))),e.compareTo(n(0))===0?n(0):n(U(e,n(2)).e).add(n(1))},u.prototype.bitLength=l.prototype.bitLength=c.prototype.bitLength;function W(e,t){return e=Q(e),t=Q(t),e.greater(t)?e:t}function G(e,t){return e=Q(e),t=Q(t),e.lesser(t)?e:t}function K(e,t){if(e=Q(e).abs(),t=Q(t).abs(),e.equals(t))return e;if(e.isZero())return t;if(t.isZero())return e;for(var n=s[1],r,i;e.isEven()&&t.isEven();)r=G(H(e),H(t)),e=e.divide(r),t=t.divide(r),n=n.multiply(r);for(;e.isEven();)e=e.divide(H(e));do{for(;t.isEven();)t=t.divide(H(t));e.greater(t)&&(i=t,t=e,e=i),t=t.subtract(e)}while(!t.isZero());return n.isUnit()?e:e.multiply(n)}function q(e,t){return e=Q(e).abs(),t=Q(t).abs(),e.divide(K(e,t)).multiply(t)}function ne(e,n,r){e=Q(e),n=Q(n);var i=r||Math.random,a=G(e,n),o=W(e,n).subtract(a).add(1);if(o.isSmall)return a.add(Math.floor(i()*o));for(var c=Y(o,t).value,l=[],u=!0,d=0;d<c.length;d++){var f=u?c[d]+(d+1<c.length?c[d+1]/t:0):t,p=g(i()*f);l.push(p),p<c[d]&&(u=!1)}return a.add(s.fromArray(l,t,!1))}var re=function(e,t,n,r){n=n||a,e=String(e),r||(e=e.toLowerCase(),n=n.toLowerCase());var i=e.length,o,s=Math.abs(t),c={};for(o=0;o<n.length;o++)c[n[o]]=o;for(o=0;o<i;o++){var l=e[o];if(l!==`-`&&l in c&&c[l]>=s){if(l===`1`&&s===1)continue;throw Error(l+` is not a valid digit in base `+t+`.`)}}t=Q(t);var u=[],d=e[0]===`-`;for(o=+!!d;o<e.length;o++){var l=e[o];if(l in c)u.push(Q(c[l]));else if(l===`<`){var f=o;do o++;while(e[o]!==`>`&&o<e.length);u.push(Q(e.slice(f+1,o)))}else throw Error(l+` is not a valid character`)}return J(u,t,d)};function J(e,t,n){for(var r=s[0],i=s[1],a=e.length-1;a>=0;a--)r=r.add(e[a].times(i)),i=i.times(t);return n?r.negate():r}function ie(e,t){return t=t||a,e<t.length?t[e]:`<`+e+`>`}function Y(e,t){if(t=n(t),t.isZero()){if(e.isZero())return{value:[0],isNegative:!1};throw Error(`Cannot convert nonzero numbers to base 0.`)}if(t.equals(-1)){if(e.isZero())return{value:[0],isNegative:!1};if(e.isNegative())return{value:[].concat.apply([],Array.apply(null,Array(-e.toJSNumber())).map(Array.prototype.valueOf,[1,0])),isNegative:!1};var r=Array.apply(null,Array(e.toJSNumber()-1)).map(Array.prototype.valueOf,[0,1]);return r.unshift([1]),{value:[].concat.apply([],r),isNegative:!1}}var i=!1;if(e.isNegative()&&t.isPositive()&&(i=!0,e=e.abs()),t.isUnit())return e.isZero()?{value:[0],isNegative:!1}:{value:Array.apply(null,Array(e.toJSNumber())).map(Number.prototype.valueOf,1),isNegative:i};for(var a=[],o=e,s;o.isNegative()||o.compareAbs(t)>=0;){s=o.divmod(t),o=s.quotient;var c=s.remainder;c.isNegative()&&(c=t.minus(c).abs(),o=o.next()),a.push(c.toJSNumber())}return a.push(o.toJSNumber()),{value:a.reverse(),isNegative:i}}function X(e,t,n){var r=Y(e,t);return(r.isNegative?`-`:``)+r.value.map(function(e){return ie(e,n)}).join(``)}c.prototype.toArray=function(e){return Y(this,e)},l.prototype.toArray=function(e){return Y(this,e)},u.prototype.toArray=function(e){return Y(this,e)},c.prototype.toString=function(t,n){if(t===e&&(t=10),t!==10||n)return X(this,t,n);for(var r=this.value,i=r.length,a=String(r[--i]),o=`0000000`,s;--i>=0;)s=String(r[i]),a+=o.slice(s.length)+s;return(this.sign?`-`:``)+a},l.prototype.toString=function(t,n){return t===e&&(t=10),t!=10||n?X(this,t,n):String(this.value)},u.prototype.toString=l.prototype.toString,u.prototype.toJSON=c.prototype.toJSON=l.prototype.toJSON=function(){return this.toString()},c.prototype.valueOf=function(){return parseInt(this.toString(),10)},c.prototype.toJSNumber=c.prototype.valueOf,l.prototype.valueOf=function(){return this.value},l.prototype.toJSNumber=l.prototype.valueOf,u.prototype.valueOf=u.prototype.toJSNumber=function(){return parseInt(this.toString(),10)};function Z(e){if(d(+e)){var t=+e;if(t===g(t))return o?new u(BigInt(t)):new l(t);throw Error(`Invalid integer: `+e)}var n=e[0]===`-`;n&&(e=e.slice(1));var r=e.split(/e/i);if(r.length>2)throw Error(`Invalid integer: `+r.join(`e`));if(r.length===2){var i=r[1];if(i[0]===`+`&&(i=i.slice(1)),i=+i,i!==g(i)||!d(i))throw Error(`Invalid integer: `+i+` is not a valid exponent.`);var a=r[0],s=a.indexOf(`.`);if(s>=0&&(i-=a.length-s-1,a=a.slice(0,s)+a.slice(s+1)),i<0)throw Error(`Cannot include negative exponent part for integers`);a+=Array(i+1).join(`0`),e=a}if(!/^([0-9][0-9]*)$/.test(e))throw Error(`Invalid integer: `+e);if(o)return new u(BigInt(n?`-`+e:e));for(var f=[],p=e.length,h=7,_=p-h;p>0;)f.push(+e.slice(_,p)),_-=h,_<0&&(_=0),p-=h;return m(f),new c(f,n)}function ae(e){if(o)return new u(BigInt(e));if(d(e)){if(e!==g(e))throw Error(e+` is not an integer.`);return new l(e)}return Z(e.toString())}function Q(e){return typeof e==`number`?ae(e):typeof e==`string`?Z(e):typeof e==`bigint`?new u(e):e}for(var $=0;$<1e3;$++)s[$]=Q($),$>0&&(s[-$]=Q(-$));return s.one=s[1],s.zero=s[0],s.minusOne=s[-1],s.max=W,s.min=G,s.gcd=K,s.lcm=q,s.isInstance=function(e){return e instanceof c||e instanceof l||e instanceof u},s.randBetween=ne,s.fromArray=function(e,t,n){return J(e.map(Q),Q(t||10),n)},s})();t!==void 0&&t.hasOwnProperty(`exports`)&&(t.exports=n),typeof define==`function`&&define.amd&&define(function(){return n})}));export{t};
//# sourceMappingURL=BigInteger-D1cEhss9.js.map