Files
discord-decomp/_bundle/Integer.js
T
2026-11-01 12:12:55 +02:00

3112 lines
78 KiB
JavaScript

// Metro module 14 (f15).
function $mk100897($env) {
return function(a0) {
const r2 = $env[0] || $env.$parent[1];
return a0 < r2.length ? r2[a0] : "<" + a0 + ">";
};
}
let BigInteger, SmallInteger, NativeBigInt, arrayToSmall, addAny, subtract, subtractSmall, multiplyLong, multiplyKaratsuba, multiplySmallAndArray, square, divModAny, millerRabinTest, bitwise, integerLogarithm, gcd, toBase, parseStringValue, parseValue, c35_0, c35_1, c35_2, c35_17, length, c35_19, c35_21, parseBase;
let env34;
const r8 = env34 = {};
let env35 = {
$parent: r8
};
const Integer = function Integer(a0, a1, a2, a3) {
"use strict";
let r1, r26, r64;
L39: {
if (a0 === void 0) {
r26 = Integer[0];
} else {
L4: {
if (a1 !== void 0) {
let r15 = a2;
if (+a1 === 10 && !a2) {
break L4;
}
if (!a2) {
r15 = c35_1;
}
const r29 = String(a0);
let r30 = r15;
let r17 = r29;
if (!a3) {
r17 = r29.toLowerCase();
r30 = r15.toLowerCase();
}
const length2 = r17.length;
const r36 = Math.abs(a1);
const r16 = {};
const r7 = 0 < r30.length;
let r39 = 0;
if (r7) {
do {
r16[r30[r39]] = r39;
r39 = r39 + 1;
} while (r39 < r30.length);
}
const r42 = 0 < length2;
let r45 = 0;
if (r42) {
do {
L20: {
const r20 = r17[r45];
r1 = r45;
if (r20 !== "-" && r20 in r16 && r16[r20] >= r36) {
if (r20 === "1" && r36 === 1) {
break L20;
}
throw new Error(r20 + " is not a valid digit in base " + a1 + ".");
}
}
r45 = r1 + 1;
} while (r45 < length2);
}
const r55 = parseValue(a1);
const r57 = r17[0] === "-";
let r58 = r57 ? 1 : 0;
const r59 = [];
while (r58 < r17.length) {
const r63 = r17[r58];
const r8 = r63 in r16;
const r4 = r58;
if (r8) {
r59.push(parseValue(r16[r63]));
r64 = r4;
} else {
let r0 = r4;
if (r63 !== "<") {
throw new Error(r63 + " is not a valid character");
}
while (true) {
r64 = r0 + 1;
if (r17[r64] !== ">") {
const length3 = r17.length;
r0 = r64;
if (r64 < length3) {
continue;
}
}
r59.push(parseValue(r17.slice(r4 + 1, r64)));
break;
}
}
r58 = r64 + 1;
}
const r88 = Integer[0];
let r89 = Integer[1];
let r91 = r59.length - 1;
let r92 = r88;
let r93 = r92;
while (0 <= r91) {
r92 = r92.add(r59[r91].times(r89));
r89 = r89.times(r55);
r91 = r91 - 1;
r93 = r92;
}
r26 = r57 ? r93.negate() : r93;
break L39;
}
}
r26 = parseValue(a0);
}
}
return r26;
};
BigInteger = function BigInteger(a0, a1) {
"use strict";
this.value = a0;
this.sign = a1;
this.isSmall = false;
};
SmallInteger = function SmallInteger(a0) {
"use strict";
this.value = a0;
this.sign = a0 < 0;
this.isSmall = true;
};
NativeBigInt = function NativeBigInt(a0) {
"use strict";
this.value = a0;
};
arrayToSmall = function arrayToSmall(a0) {
"use strict";
let r14, r22;
const r12 = a0.length - 1;
const r9 = a0[r12];
let r10 = r12;
let r13 = r10;
if (r9 === 0) {
do {
const r11 = r10 - 1;
r14 = a0[r11];
r10 = r11;
r13 = r10;
} while (r14 === 0);
}
a0.length = r13 + 1;
const length2 = a0.length;
if (length2 < 4) {
if (a0.length !== c35_0.length) {
r22 = a0.length > c35_0.length ? 1 : -1;
} else {
let r0 = a0.length - 1;
r22 = 0;
while (0 <= r0) {
const r23 = a0[r0];
const r24 = c35_0[r0];
const r1 = r0;
if (r23 !== r24) {
r22 = a0[r1] > c35_0[r1] ? 1 : -1;
break;
}
r0 = r1 - 1;
r22 = 0;
}
}
if (r22 < 0) {
if (length2 === 0) {
return 0;
}
if (length2 === 1) {
return a0[0];
}
if (length2 === 2) {
return a0[0] + a0[1] * 10000000;
}
return a0[0] + (a0[1] + a0[2] * 10000000) * 10000000;
}
}
return a0;
};
addAny = function addAny(a0, a1) {
"use strict";
let r38;
if (a0.length >= a1.length) {
const length4 = a0.length;
const length5 = a1.length;
const array2 = new Array(length4);
const r51 = 0 < length5;
let r54 = 0;
let r55 = 0;
let r56 = 0;
let r57 = 0;
if (r51) {
do {
const r60 = a0[r55] + a1[r55] + r54;
const r61 = r55;
const r62 = r60 >= 10000000 ? 1 : 0;
array2[r61] = r60 - r62 * 10000000;
r55 = r61 + 1;
r54 = r62;
r56 = r54;
r57 = r55;
} while (r57 < length5);
}
let r65 = r56;
let r66 = r65;
while (r57 < length4) {
const r68 = a0[r57] + r65;
const r69 = r57;
const r70 = r68 === 10000000 ? 1 : 0;
r57 = r69 + 1;
array2[r69] = r68 - r70 * 10000000;
r65 = r70;
r66 = r65;
}
r38 = array2;
if (0 < r66) {
array2.push(r66);
r38 = array2;
}
} else {
const length3 = a1.length;
const length2 = a0.length;
const array = new Array(length3);
const r10 = 0 < length2;
let r4 = 0;
let r0 = 0;
let r7 = 0;
let r3 = 0;
if (r10) {
do {
const r28 = a1[r0] + a0[r0] + r4;
const r2 = r0;
const r1 = r28 >= 10000000 ? 1 : 0;
array[r2] = r28 - r1 * 10000000;
r0 = r2 + 1;
r4 = r1;
r7 = r4;
r3 = r0;
} while (r3 < length2);
}
let r30 = r7;
let r31 = r30;
while (r3 < length3) {
const r33 = a1[r3] + r30;
const r34 = r3;
const r35 = r33 === 10000000 ? 1 : 0;
r3 = r34 + 1;
array[r34] = r33 - r35 * 10000000;
r30 = r35;
r31 = r30;
}
r38 = array;
if (0 < r31) {
array.push(r31);
r38 = array;
}
}
return r38;
};
subtract = function subtract(a0, a1) {
"use strict";
let r40;
const length3 = a0.length;
const length2 = a1.length;
const array = new Array(length3);
const r10 = 0 < length2;
let r1 = 0;
let r0 = 0;
let r6 = 0;
if (r10) {
do {
const r5 = a0[r0] - r1 - a1[r0];
const r26 = r0;
let r2 = 0;
let r3 = r5;
if (r3 < 0) {
r3 = r5 + 10000000;
r2 = 1;
}
array[r26] = r3;
r0 = r26 + 1;
r1 = r2;
r6 = r1;
} while (r0 < length2);
}
let r27 = length2;
let r28 = r27;
while (r28 < length3) {
const r30 = a0[r27] - r6;
const r31 = r27;
if (!(r30 < 0)) {
const r18 = +r31;
r28 = r18 + 1;
array[r18] = r30;
break;
}
array[r31] = r30 + 10000000;
r27 = r31 + 1;
r28 = r27;
}
while (r28 < length3) {
array[r28] = a0[r28];
r28 = r28 + 1;
}
const r35 = array.length - 1;
const r36 = array[r35];
let r37 = r35;
let r38 = r37;
if (r36 === 0) {
do {
const r39 = r37 - 1;
r40 = array[r39];
r37 = r39;
r38 = r37;
} while (r40 === 0);
}
array.length = r38 + 1;
return array;
};
subtractSmall = function subtractSmall(a0, a1, a2) {
"use strict";
let r31;
const length2 = a0.length;
const array = new Array(length2);
let r21 = -a1;
const r7 = 0 < length2;
let r0 = 0;
if (r7) {
do {
const r14 = a0[r0] + r21;
const r23 = Math.floor(r14 / 10000000);
const r4 = r14 % 10000000;
const r24 = r0;
let r1 = r4;
if (r1 < 0) {
r1 = r4 + 10000000;
}
array[r24] = r1;
r0 = r24 + 1;
r21 = r23;
} while (r0 < length2);
}
const value = arrayToSmall(array);
if (typeof value === "number") {
const value2 = a2 ? -value : value;
const r36 = {
__proto__: SmallInteger.prototype
};
r36.value = value2;
r36.sign = value2 < 0;
r36.isSmall = true;
r31 = r36;
} else {
r31 = {
__proto__: BigInteger.prototype
};
r31.value = value;
r31.sign = a2;
r31.isSmall = false;
}
return r31;
};
multiplyLong = function multiplyLong(a0, a1) {
"use strict";
let r42;
const length3 = a0.length;
const length2 = a1.length;
const r15 = length3 + length2;
const array = new Array(r15);
let r6 = 0;
while (r6 < r15) {
array[r6] = 0;
r6 = r6 + 1;
}
const r8 = 0 < length3;
let r23 = 0;
if (r8) {
do {
const r24 = a0[r23];
const r25 = 0 < length2;
const r5 = r23;
let r0 = 0;
if (r25) {
do {
const r17 = r24 * a1[r0];
const r2 = r5 + r0;
const r28 = r17 + array[r2];
const r30 = Math.floor(r28 / 10000000);
array[r2] = r28 - r30 * 10000000;
const r33 = r2 + 1;
array[r33] = array[r33] + r30;
r0 = r0 + 1;
} while (r0 < length2);
}
r23 = r5 + 1;
} while (r23 < length3);
}
const r37 = array.length - 1;
const r38 = array[r37];
let r39 = r37;
let r40 = r39;
if (r38 === 0) {
do {
const r41 = r39 - 1;
r42 = array[r41];
r39 = r41;
r40 = r39;
} while (r42 === 0);
}
array.length = r40 + 1;
return array;
};
multiplyKaratsuba = function multiplyKaratsuba(a0, a1) {
"use strict";
let r42, r50, r60;
const r17 = Math.max(a0.length, a1.length);
if (r17 <= 30) {
return multiplyLong(a0, a1);
}
const r21 = Math.ceil(r17 / 2);
const r16 = a0.slice(r21);
const r13 = a0.slice(0, r21);
const r15 = a1.slice(r21);
const r27 = a1.slice(0, r21);
const r28 = multiplyKaratsuba(r13, r27);
const r29 = multiplyKaratsuba(r16, r15);
const r33 = multiplyKaratsuba(addAny(r13, r16), addAny(r27, r15));
const r36 = subtract(subtract(r33, r28), r29);
const r37 = [];
const r38 = +r21;
let r39 = r38 - 1;
if (r38 > 0) {
do {
r37.push(0);
r42 = +r39;
r39 = r42 - 1;
} while (r42 > 0);
}
const r45 = addAny(r28, r37.concat(r36));
const r4 = 2 * r21;
const r46 = [];
let r0 = r4 - 1;
if (0 < r4) {
do {
r46.push(0);
const r2 = r0 - 1;
r50 = r0;
r0 = r2;
} while (0 < r50);
}
const r53 = addAny(r45, r46.concat(r29));
const r55 = r53.length - 1;
const r56 = r53[r55];
let r57 = r55;
let r58 = r57;
if (r56 === 0) {
do {
const r59 = r57 - 1;
r60 = r53[r59];
r57 = r59;
r58 = r57;
} while (r60 === 0);
}
r53.length = r58 + 1;
return r53;
};
multiplySmallAndArray = function multiplySmallAndArray(a0, a1, a2) {
"use strict";
let value;
if (a0 < 10000000) {
const length2 = a1.length;
const array = new Array(length2);
const r6 = 0 < length2;
let r46 = 0;
let r0 = 0;
let r47 = 0;
let r48 = 0;
if (r6) {
do {
const r17 = a1[r0] * a0 + r46;
const r51 = Math.floor(r17 / 10000000);
array[r0] = r17 - r51 * 10000000;
r0 = r0 + 1;
r46 = r51;
r47 = r46;
r48 = r0;
} while (r48 < length2);
}
value = array;
while (r47 > 0) {
const r54 = r48 + 1;
array[r48] = r47 % 10000000;
r47 = Math.floor(r47 / 10000000);
r48 = r54;
value = array;
}
} else {
value = multiplyLong(a1, a0 < 10000000 ? [a0] : a0 < 100000000000000 ? [a0 % 10000000, Math.floor(a0 / 10000000)] : [a0 % 10000000, Math.floor(a0 / 10000000) % 10000000, Math.floor(a0 / 100000000000000)]);
}
const r61 = {
__proto__: BigInteger.prototype
};
r61.value = value;
r61.sign = a2;
r61.isSmall = false;
return r61;
};
square = function square(a0) {
"use strict";
let r43;
const length2 = a0.length;
const r14 = length2 + length2;
const array = new Array(r14);
let r6 = 0;
while (r6 < r14) {
array[r6] = 0;
r6 = r6 + 1;
}
const r9 = 0 < length2;
let r24 = 0;
if (r9) {
do {
const r16 = a0[r24];
let r26 = 0 - r16 * r16;
const r4 = r24;
let r27 = r26;
let r0 = r4;
while (r0 < length2) {
const r1 = r16 * a0[r0] * 2;
const r3 = r4 + r0;
const r18 = r1 + array[r3] + r26;
const r33 = Math.floor(r18 / 10000000);
array[r3] = r18 - r33 * 10000000;
r0 = r0 + 1;
r26 = r33;
r27 = r26;
}
array[r4 + length2] = r27;
r24 = r4 + 1;
} while (r24 < length2);
}
const r38 = array.length - 1;
const r39 = array[r38];
let r40 = r38;
let r41 = r40;
if (r39 === 0) {
do {
const r42 = r40 - 1;
r43 = array[r42];
r40 = r42;
r41 = r40;
} while (r43 === 0);
}
array.length = r41 + 1;
return array;
};
divModAny = function divModAny(a0, a1) {
"use strict";
let r70, r99, r103, r157, r173, r181, r297, r314, r355, r364, r421, r449;
const r47 = parseValue(a1);
if (c35_2) {
const value12 = a0.value / r47.value;
const r480 = {
__proto__: NativeBigInt.prototype
};
r480.value = value12;
const value13 = a0.value % r47.value;
const r485 = {
__proto__: NativeBigInt.prototype
};
r485.value = value13;
return [r480, r485];
}
const value2 = a0.value;
const value = r47.value;
if (value === 0) {
throw new Error("Cannot divide by zero");
}
const isSmall = a0.isSmall;
const isSmall2 = r47.isSmall;
if (isSmall) {
if (isSmall2) {
const r451 = value2 / value;
const value10 = r451 > 0 ? Math.floor(r451) : Math.ceil(r451);
const r460 = {
__proto__: SmallInteger.prototype
};
r460.value = value10;
r460.sign = value10 < 0;
r460.isSmall = true;
const value11 = value2 % value;
const r465 = {
__proto__: SmallInteger.prototype
};
r465.value = value11;
r465.sign = value11 < 0;
r465.isSmall = true;
r449 = [r460, r465];
} else {
r449 = [Integer[0], a0];
}
return r449;
}
let r37 = value;
if (isSmall2) {
if (value === 1) {
return [a0, Integer[0]];
}
if (value == -1) {
return [a0.negate(), Integer[0]];
}
const r51 = Math.abs(value);
if (r51 < 10000000) {
const length13 = value2.length;
const array6 = new Array(length13);
const r390 = 0 < length13;
let r391 = 0;
if (r390) {
do {
array6[r391] = 0;
r391 = r391 + 1;
} while (r391 < length13);
}
let r392 = length13 - 1;
let r393 = 0;
let r394 = 0;
while (0 <= r392) {
const r397 = r393 * 10000000 + value2[r392];
const r398 = r397 / r51;
const r399 = r392;
const r402 = 0 < r398 ? Math.floor(r398) : Math.ceil(r398);
r393 = r397 - r402 * r51;
array6[r399] = r402 | 0;
r392 = r399 - 1;
r394 = r393;
}
const r408 = [array6, r394 | 0];
const value7 = arrayToSmall(r408[0]);
const r411 = r408[1];
const value8 = a0.sign ? -r411 : r411;
if (typeof value7 === "number") {
const value9 = a0.sign !== r47.sign ? -value7 : value7;
const r432 = {
__proto__: SmallInteger.prototype
};
r432.value = value9;
r432.sign = value9 < 0;
r432.isSmall = true;
const r437 = {
__proto__: SmallInteger.prototype
};
r437.value = value8;
r437.sign = value8 < 0;
r437.isSmall = true;
r421 = [r432, r437];
} else {
const sign2 = a0.sign;
const sign3 = r47.sign;
const r418 = {
__proto__: BigInteger.prototype
};
r418.value = value7;
r418.sign = sign2 !== sign3;
r418.isSmall = false;
const r424 = {
__proto__: SmallInteger.prototype
};
r424.value = value8;
r424.sign = value8 < 0;
r424.isSmall = true;
r421 = [r418, r424];
}
return r421;
}
r37 = r51 < 10000000 ? [r51] : r51 < 100000000000000 ? [r51 % 10000000, Math.floor(r51 / 10000000)] : [r51 % 10000000, Math.floor(r51 / 10000000) % 10000000, Math.floor(r51 / 100000000000000)];
}
if (value2.length !== r37.length) {
r70 = value2.length > r37.length ? 1 : -1;
} else {
let r7 = value2.length - 1;
r70 = 0;
while (0 <= r7) {
const r71 = value2[r7];
const r72 = r37[r7];
const r73 = r7;
if (r71 !== r72) {
r70 = value2[r73] > r37[r73] ? 1 : -1;
break;
}
r7 = r73 - 1;
r70 = 0;
}
}
let r82 = -1;
if (r70 === -1) {
return [Integer[0], a0];
}
if (r70 === 0) {
if (a0.sign === r47.sign) {
r82 = 1;
}
return [Integer[r82], Integer[0]];
}
if (value2.length + r37.length <= 200) {
const length6 = value2.length;
const { length: length7, length: length8 } = r37;
const array2 = new Array(length8);
const r192 = 0 < length8;
let r194 = 0;
if (r192) {
do {
array2[r194] = 0;
r194 = r194 + 1;
} while (r194 < length8);
}
const r203 = Math.ceil(10000000 / (2 * r37[length7 - 1]));
const length9 = value2.length;
const array3 = new Array(length9);
const r211 = 0 < length9;
let r212 = 0;
let r213 = 0;
let r214 = 0;
let r215 = 0;
if (r211) {
do {
const r218 = value2[r213] * r203 + r212;
const r222 = Math.floor(r218 / 10000000);
array3[r213] = r218 - r222 * 10000000;
r213 = r213 + 1;
r212 = r222;
r214 = r212;
r215 = r213;
} while (r215 < length9);
}
while (r214 > 0) {
const r225 = r215 + 1;
array3[r215] = r214 % 10000000;
r214 = Math.floor(r214 / 10000000);
r215 = r225;
}
const length10 = r37.length;
const array4 = new Array(length10);
const r237 = 0 < length10;
let r238 = 0;
let r239 = 0;
let r240 = 0;
let r241 = 0;
if (r237) {
do {
const r244 = r37[r239] * r203 + r238;
const r248 = Math.floor(r244 / 10000000);
array4[r239] = r244 - r248 * 10000000;
r239 = r239 + 1;
r238 = r248;
r240 = r238;
r241 = r239;
} while (r241 < length10);
}
while (r240 > 0) {
const r251 = r241 + 1;
array4[r241] = r240 % 10000000;
r240 = Math.floor(r240 / 10000000);
r241 = r251;
}
if (array3.length <= length6) {
array3.push(0);
}
array4.push(0);
const r262 = array4[length7 - 1];
let r263 = length6 - length7;
while (r263 >= 0) {
const r266 = array3[r263 + length7];
const r267 = r263;
const r268 = r266 !== r262 ? Math.floor((array3[r267 + length7] * 10000000 + array3[r267 + length7 - 1]) / r262) : 9999999;
const length11 = array4.length;
const r280 = 0 < length11;
let r281 = 0;
let r282 = 0;
let r283 = 0;
let r284 = 0;
if (r280) {
do {
const r287 = r283 + r268 * array4[r281];
const r290 = Math.floor(r287 / 10000000);
const r4 = r282 + (array3[r267 + r281] - (r287 - r290 * 10000000));
const r296 = r281;
if (r4 < 0) {
array3[r267 + r296] = r4 + 10000000;
r297 = -1;
} else {
array3[r267 + r296] = r4;
r297 = 0;
}
r281 = r296 + 1;
r282 = r297;
r283 = r290;
r284 = r282;
} while (r281 < length11);
}
let r299 = r268;
let r300 = r299;
while (r284 !== 0) {
const r301 = r299 - 1;
const r302 = 0 < length11;
const r303 = r284;
let r304 = 0;
let r305 = 0;
let r306 = 0;
if (r302) {
do {
const r312 = r305 + (array3[r267 + r304] - 10000000 + array4[r304]);
const r313 = r304;
if (r312 < 0) {
array3[r267 + r313] = r312 + 10000000;
r314 = 0;
} else {
array3[r267 + r313] = r312;
r314 = 1;
}
r304 = r313 + 1;
r305 = r314;
r306 = r305;
} while (r304 < length11);
}
r284 = r303 + r306;
r299 = r301;
r300 = r299;
}
array2[r267] = r300;
r263 = r267 - 1;
}
const length12 = array3.length;
const array5 = new Array(length12);
const r323 = 0 < length12;
let r324 = 0;
if (r323) {
do {
array5[r324] = 0;
r324 = r324 + 1;
} while (r324 < length12);
}
let r325 = length12 - 1;
let r326 = 0;
let r327 = 0;
while (0 <= r325) {
const r330 = r326 * 10000000 + array3[r325];
const r331 = r330 / r203;
const r332 = r325;
const r335 = 0 < r331 ? Math.floor(r331) : Math.ceil(r331);
r326 = r330 - r335 * r203;
array5[r332] = r335 | 0;
r325 = r332 - 1;
r327 = r326;
}
const r342 = [array5, r327 | 0][0];
r181 = [arrayToSmall(array2), arrayToSmall(r342)];
} else {
let length3 = value2.length;
const length2 = r37.length;
const r87 = [];
let r88 = [];
let r93 = r88;
while (length3) {
const unshift = r88.unshift;
const r32 = length3 - 1;
unshift.call(r88, value2[r32]);
const r96 = r88.length - 1;
const r35 = r88[r96];
const r97 = r88;
let r36 = r96;
let r98 = r36;
if (r35 === 0) {
do {
const r38 = r36 - 1;
r99 = r97[r38];
r36 = r38;
r98 = r36;
} while (r99 === 0);
}
r97.length = r98 + 1;
if (r97.length !== r37.length) {
r103 = r97.length > r37.length ? 1 : -1;
} else {
let r0 = r97.length - 1;
r103 = 0;
while (0 <= r0) {
const r104 = r97[r0];
const r105 = r37[r0];
const r1 = r0;
if (r104 !== r105) {
r103 = r97[r1] > r37[r1] ? 1 : -1;
break;
}
r0 = r1 - 1;
r103 = 0;
}
}
if (r103 < 0) {
r87.push(0);
r173 = r97;
} else {
const length5 = r97.length;
const r120 = r97[length5 - 1] * 10000000 + r97[length5 - 2];
let r132 = Math.ceil((length5 > length2 ? (r120 + 1) * 10000000 : r120) / (r37[length2 - 1] * 10000000 + r37[length2 - 2]));
while (true) {
const length4 = r37.length;
const array = new Array(length4);
const r137 = 0 < length4;
const r138 = r132;
let r39 = 0;
let r139 = 0;
let r140 = 0;
let r141 = 0;
if (r137) {
do {
const r42 = r37[r139] * r138 + r39;
const r145 = Math.floor(r42 / 10000000);
array[r139] = r42 - r145 * 10000000;
r139 = r139 + 1;
r39 = r145;
r140 = r39;
r141 = r139;
} while (r141 < length4);
}
while (r140 > 0) {
const r148 = r141 + 1;
array[r141] = r140 % 10000000;
r140 = Math.floor(r140 / 10000000);
r141 = r148;
}
if (array.length !== r97.length) {
r157 = array.length > r97.length ? 1 : -1;
} else {
let r156 = array.length - 1;
r157 = 0;
while (0 <= r156) {
const r158 = array[r156];
const r159 = r97[r156];
const r160 = r156;
if (r158 !== r159) {
r157 = array[r160] > r97[r160] ? 1 : -1;
break;
}
r156 = r160 - 1;
r157 = 0;
}
}
let r169 = r138;
if (!(r157 <= 0)) {
r132 = r138 - 1;
r169 = r132;
if (r169) {
continue;
}
}
r87.push(r169);
r173 = subtract(r97, array);
break;
}
}
r88 = r173;
r93 = r88;
length3 = r32;
}
r87.reverse();
r181 = [arrayToSmall(r87), arrayToSmall(r93)];
}
const value3 = r181[0];
const sign4 = a0.sign !== r47.sign;
const value4 = r181[1];
const sign = a0.sign;
if (typeof value3 === "number") {
const value5 = sign4 ? -value3 : value3;
const r359 = {
__proto__: SmallInteger.prototype
};
r359.value = value5;
r359.sign = value5 < 0;
r359.isSmall = true;
r355 = r359;
} else {
r355 = {
__proto__: BigInteger.prototype
};
r355.value = value3;
r355.sign = sign4;
r355.isSmall = false;
}
if (typeof value4 === "number") {
const value6 = sign ? -value4 : value4;
const r369 = {
__proto__: SmallInteger.prototype
};
r369.value = value6;
r369.sign = value6 < 0;
r369.isSmall = true;
r364 = r369;
} else {
r364 = {
__proto__: BigInteger.prototype
};
r364.value = value4;
r364.sign = sign;
r364.isSmall = false;
}
return [r355, r364];
};
millerRabinTest = function millerRabinTest(a0, a1) {
"use strict";
let r29, isEven2;
const r12 = a0.prev();
const isEven = r12.isEven();
let r4 = 0;
let r10 = r12;
let r3 = 0;
let r11 = r10;
if (isEven) {
do {
const r15 = r10.divide(2);
r4 = r4 + 1;
isEven2 = r15.isEven();
r10 = r15;
r3 = r4;
r11 = r10;
} while (isEven2);
}
const r8 = 0 < a1.length;
const r24 = r3 - 1;
let r25 = 0;
if (r8) {
do {
L12: {
const r28 = a0.lesser(a1[r25]);
r29 = r25;
if (!r28) {
let r34 = (0, env34[0])(a1[r29]).modPow(r11, a0);
if (!r34.isUnit() && !r34.equals(r12)) {
let r0 = r24;
while (r0 !== 0) {
const r41 = r34.square().mod(a0);
const isUnit = r41.isUnit();
const r1 = r0;
if (isUnit) {
return false;
}
if (r41.equals(r12)) {
break L12;
}
r0 = r1 - 1;
r34 = r41;
}
return false;
}
}
}
r25 = r29 + 1;
} while (r25 < a1.length);
}
return true;
};
bitwise = function bitwise(a0, a1, a2) {
"use strict";
let r24;
const r8 = parseValue(a1);
const isNegative = a0.isNegative();
const isNegative2 = r8.isNegative();
const r13 = isNegative ? a0.not() : a0;
const r14 = isNegative2 ? r8.not() : r8;
L12: {
r24 = [];
const isZero = r13.isZero();
let r12 = r14;
let r11 = r13;
if (isZero) {
const isZero2 = r14.isZero();
r12 = r14;
r11 = r13;
if (isZero2) {
break L12;
}
}
while (true) {
const r30 = divModAny(r11, c35_19);
const r32 = r30[1].toJSNumber();
const r33 = r12;
const r16 = isNegative ? c35_19 - 1 - r32 : r32;
const r34 = divModAny(r33, c35_19);
const r37 = r34[1].toJSNumber();
const r38 = isNegative2 ? c35_19 - 1 - r37 : r37;
const r40 = r30[0];
const r41 = r34[0];
r24.push(a2(r16, r38));
const isZero3 = r40.isZero();
r12 = r41;
r11 = r40;
if (isZero3) {
const isZero4 = r41.isZero();
r12 = r41;
r11 = r40;
if (isZero4) {
break;
}
}
}
}
const r53 = a2(isNegative ? 1 : 0, isNegative2 ? 1 : 0) !== 0 ? (0, env34[0])(-1) : (0, env34[0])(0);
let r58 = r24.length - 1;
let r60 = r53;
let r61 = r60;
while (0 <= r58) {
r60 = r60.multiply(c35_19).add((0, env34[0])(r24[r58]));
r58 = r58 - 1;
r61 = r60;
}
return r61;
};
integerLogarithm = function integerLogarithm(a0, a1) {
"use strict";
if (a1.compareTo(a0) <= 0) {
const r16 = integerLogarithm(a0, a1.square(a1));
const { p: r17, e: r5 } = r16;
const r19 = r17.multiply(a1);
return r19.compareTo(a0) <= 0 ? {
p: r19,
e: 2 * r5 + 1
} : {
p: r17,
e: 2 * r5
};
}
return {
p: (0, env34[0])(1),
e: 0
};
};
gcd = function gcd(a0, a1) {
"use strict";
let isEven4, isEven6, isEven8;
const r23 = parseValue(a0).abs();
const r27 = parseValue(a1).abs();
if (r23.equals(r27)) {
return r23;
}
if (r23.isZero()) {
return r27;
}
if (r27.isZero()) {
return r23;
}
const r16 = Integer[1];
const isEven = r23.isEven();
let r10 = r16;
let r14 = r27;
let r8 = r23;
if (isEven) {
const isEven2 = r27.isEven();
let r12 = r16;
let r11 = r27;
let r9 = r23;
r10 = r12;
r14 = r11;
r8 = r9;
if (isEven2) {
do {
const value = r9.value;
const r19 = r12;
const r17 = r11;
const r40 = r9;
const r42 = typeof value === "number" ? value | c35_21 : typeof value === "bigint" ? value | BigInt(c35_21) : value[0] + value[1] * 10000000 | 1073758208;
const r47 = r42 & -r42;
const value2 = r17.value;
const r52 = typeof value2 === "number" ? value2 | c35_21 : typeof value2 === "bigint" ? value2 | BigInt(c35_21) : value2[0] + value2[1] * 10000000 | 1073758208;
const r58 = r52 & -r52;
const r60 = parseValue(r47);
let r61 = parseValue(r58);
if (r60.lesser(r61)) {
r61 = r60;
}
const r65 = r40.divide(r61);
const r67 = r17.divide(r61);
const r69 = r19.multiply(r61);
const isEven3 = r65.isEven();
r10 = r69;
r14 = r67;
r8 = r65;
if (!isEven3) {
break;
}
isEven4 = r67.isEven();
r12 = r69;
r11 = r67;
r9 = r65;
r10 = r12;
r14 = r11;
r8 = r9;
} while (isEven4);
}
}
const isEven5 = r8.isEven();
let r79 = r8;
let r80 = r14;
let r81 = r79;
if (isEven5) {
do {
const { divide, value: value3 } = r79;
const r84 = r79;
const r89 = typeof value3 === "number" ? value3 | c35_21 : typeof value3 === "bigint" ? value3 | BigInt(c35_21) : value3[0] + value3[1] * 10000000 | 1073758208;
const r96 = divide.call(r84, r89 & -r89);
isEven6 = r96.isEven();
r79 = r96;
r80 = r14;
r81 = r79;
} while (isEven6);
}
while (true) {
const isEven7 = r80.isEven();
let r101 = r80;
const r102 = r81;
let r103 = r101;
if (isEven7) {
do {
const { divide: divide2, value: value4 } = r101;
const r106 = r101;
const r111 = typeof value4 === "number" ? value4 | c35_21 : typeof value4 === "bigint" ? value4 | BigInt(c35_21) : value4[0] + value4[1] * 10000000 | 1073758208;
const r118 = divide2.call(r106, r111 & -r111);
isEven8 = r118.isEven();
r101 = r118;
r103 = r101;
} while (isEven8);
}
const r122 = r102.greater(r103);
let r123 = r103;
let r124 = r102;
if (r122) {
r123 = r102;
r124 = r103;
}
const r126 = r123.subtract(r124);
const isZero = r126.isZero();
r80 = r126;
r81 = r124;
if (isZero) {
return r10.isUnit() ? r124 : r124.multiply(r10);
}
}
};
toBase = function toBase(a0, a1) {
"use strict";
let r7, r8;
const r9 = (0, env34[0])(a1);
if (r9.isZero()) {
if (a0.isZero()) {
return {
value: [0],
isNegative: false
};
}
throw new Error("Cannot convert nonzero numbers to base 0.");
}
if (r9.equals(-1)) {
if (a0.isZero()) {
return {
value: [0],
isNegative: false
};
}
if (a0.isNegative()) {
return {
value: [].concat.apply([], Array.apply(null, Array(-a0.toJSNumber())).map(Array.prototype.valueOf, [1, 0])),
isNegative: false
};
}
const r98 = Array.apply(null, Array(a0.toJSNumber() - 1)).map(Array.prototype.valueOf, [0, 1]);
r98.unshift([1]);
return {
value: [].concat.apply([], r98),
isNegative: false
};
}
const r24 = a0.isNegative() && r9.isPositive();
let isNegative4 = false;
let r11 = a0;
if (r24) {
r11 = a0.abs();
isNegative4 = true;
}
if (r9.isUnit()) {
return r11.isZero() ? {
value: [0],
isNegative: false
} : {
value: Array.apply(null, Array(r11.toJSNumber())).map(Number.prototype.valueOf, 1),
isNegative: isNegative4
};
}
L13: {
r7 = [];
const isNegative = r11.isNegative();
let r31 = r11;
if (!isNegative) {
const r33 = r11.compareAbs(r9);
r31 = r11;
r8 = r31;
if (!(r33 >= 0)) {
break L13;
}
}
while (true) {
const r36 = r31.divmod(r9);
const { quotient, remainder } = r36;
const isNegative2 = remainder.isNegative();
let r13 = remainder;
let r10 = quotient;
if (isNegative2) {
r13 = r9.minus(remainder).abs();
r10 = quotient.next();
}
r7.push(r13.toJSNumber());
const isNegative3 = r10.isNegative();
r31 = r10;
if (!isNegative3) {
const r50 = r10.compareAbs(r9);
r31 = r10;
r8 = r31;
if (!(r50 >= 0)) {
break;
}
}
}
}
r7.push(r8.toJSNumber());
return {
value: r7.reverse(),
isNegative: isNegative4
};
};
parseStringValue = function parseStringValue(a0) {
"use strict";
let r94, r157;
const r2 = +a0;
let r6 = -9007199254740992 < r2;
if (-9007199254740992 < r2) {
r6 = r2 < 9007199254740992;
}
if (r6) {
const value3 = +a0;
if (value3 === (0 < value3 ? Math.floor(value3) : Math.ceil(value3))) {
if (c35_2) {
const value4 = BigInt(value3);
const r166 = {
__proto__: NativeBigInt.prototype
};
r166.value = value4;
r157 = r166;
} else {
r157 = {
__proto__: SmallInteger.prototype
};
r157.value = value3;
r157.sign = value3 < 0;
r157.isSmall = true;
}
return r157;
}
throw new Error("Invalid integer: " + a0);
}
const sign = a0[0] === "-";
let r12 = sign ? a0.slice(1) : a0;
const r14 = r12.split(/e/i);
if (r14.length > 2) {
throw new Error("Invalid integer: " + r14.join("e"));
}
L20: {
if (r14.length === 2) {
const r15 = r14[1];
const r33 = +(r15[0] === "+" ? r15.slice(1) : r15);
if (r33 === (0 < r33 ? Math.floor(r33) : Math.ceil(r33))) {
let r7 = -9007199254740992 < r33;
if (-9007199254740992 < r33) {
r7 = r33 < 9007199254740992;
}
if (r7) {
const r18 = r14[0];
const r45 = r18.indexOf(".");
let r46 = r18;
let r47 = r33;
if (r45 >= 0) {
r47 = r33 - (r18.length - r45 - 1);
r46 = r18.slice(0, r45) + r18.slice(r45 + 1);
}
if (r47 < 0) {
throw new Error("Cannot include negative exponent part for integers");
}
r12 = r46 + new Array(r47 + 1).join("0");
break L20;
}
}
throw new Error("Invalid integer: " + r33 + " is not a valid exponent.");
}
}
const r66 = /^([0-9][0-9]*)$/.test(r12);
const r67 = r12;
if (r66) {
if (c35_2) {
const value2 = BigInt(sign ? "-" + r67 : r67);
const r108 = {
__proto__: NativeBigInt.prototype
};
r108.value = value2;
return r108;
}
const value = [];
let length2 = r67.length;
let r80 = length2 - 7;
if (length2 > 0) {
do {
value.push(+r67.slice(r80, length2));
let r0 = r80 - 7;
if (r0 < 0) {
r0 = 0;
}
length2 = length2 - 7;
r80 = r0;
} while (0 < length2);
}
const r89 = value.length - 1;
const r90 = value[r89];
let r91 = r89;
let r92 = r91;
if (r90 === 0) {
do {
const r93 = r91 - 1;
r94 = value[r93];
r91 = r93;
r92 = r91;
} while (r94 === 0);
}
value.length = r92 + 1;
const r99 = {
__proto__: BigInteger.prototype
};
r99.value = value;
r99.sign = sign;
r99.isSmall = false;
return r99;
}
throw new Error("Invalid integer: " + r67);
};
parseValue = function parseValue(a0) {
"use strict";
let r3, r21;
if (typeof a0 === "number") {
if (c35_2) {
const value = BigInt(a0);
const r44 = {
__proto__: NativeBigInt.prototype
};
r44.value = value;
r21 = r44;
} else if (-9007199254740992 < a0 && a0 < 9007199254740992) {
if (a0 !== (a0 > 0 ? Math.floor(a0) : Math.ceil(a0))) {
throw new Error(a0 + " is not an integer.");
}
const r29 = {
__proto__: SmallInteger.prototype
};
r29.value = a0;
r29.sign = a0 < 0;
r29.isSmall = true;
r21 = r29;
} else {
r21 = parseStringValue(a0.toString());
}
r3 = r21;
} else if (typeof a0 === "string") {
r3 = parseStringValue(a0);
} else {
r3 = a0;
if (typeof a0 === "bigint") {
const r13 = {
__proto__: NativeBigInt.prototype
};
r13.value = a0;
r3 = r13;
}
}
return r3;
};
c35_0 = [4740992, Math.floor(900719925.4740992) % 10000000, Math.floor(90.07199254740992)];
c35_1 = "0123456789abcdefghijklmnopqrstuvwxyz";
c35_2 = typeof globalThis.BigInt === "function";
BigInteger.prototype = Object.create(Integer.prototype);
SmallInteger.prototype = Object.create(Integer.prototype);
NativeBigInt.prototype = Object.create(Integer.prototype);
BigInteger.prototype.add = function(a0) {
"use strict";
let r30;
const r23 = parseValue(a0);
if (this.sign !== r23.sign) {
return this.subtract(r23.negate());
}
const value2 = this.value;
const { value, isSmall } = r23;
if (isSmall) {
const r34 = Math.abs(value);
const length2 = value2.length;
const array = new Array(length2);
const r39 = 0 < length2;
let r1 = 0;
let r40 = r34;
let r41 = 0;
let r42 = r40;
if (r39) {
do {
const r18 = value2[r1] - 10000000 + r40;
const r45 = Math.floor(r18 / 10000000);
array[r1] = r18 - r45 * 10000000;
r40 = r45 + 1;
r1 = r1 + 1;
r42 = r40;
r41 = r1;
} while (r41 < length2);
}
while (r42 > 0) {
const r48 = r41 + 1;
array[r41] = r42 % 10000000;
r42 = Math.floor(r42 / 10000000);
r41 = r48;
}
const sign2 = this.sign;
const r55 = {
__proto__: BigInteger.prototype
};
r55.value = array;
r55.sign = sign2;
r55.isSmall = false;
r30 = r55;
} else {
const value3 = addAny(value2, value);
const sign = this.sign;
r30 = {
__proto__: BigInteger.prototype
};
r30.value = value3;
r30.sign = sign;
r30.isSmall = false;
}
return r30;
};
BigInteger.prototype.plus = BigInteger.prototype.add;
SmallInteger.prototype.add = function(a0) {
"use strict";
const r11 = parseValue(a0);
const value = this.value;
if (value < 0 !== r11.sign) {
return this.subtract(r11.negate());
}
const { value: value2, isSmall } = r11;
let r19 = value2;
if (isSmall) {
const r29 = value + value2;
if (-9007199254740992 < r29 && r29 < 9007199254740992) {
const value3 = value + value2;
const r82 = {
__proto__: SmallInteger.prototype
};
r82.value = value3;
r82.sign = value3 < 0;
r82.isSmall = true;
return r82;
}
const r15 = Math.abs(value2);
r19 = r15 < 10000000 ? [r15] : r15 < 100000000000000 ? [r15 % 10000000, Math.floor(r15 / 10000000)] : [r15 % 10000000, Math.floor(r15 / 10000000) % 10000000, Math.floor(r15 / 100000000000000)];
}
const r54 = Math.abs(value);
const length2 = r19.length;
const array = new Array(length2);
const r59 = 0 < length2;
let r1 = 0;
let r62 = r54;
let r63 = 0;
let r64 = r62;
if (r59) {
do {
const r21 = r19[r1] - 10000000 + r62;
const r67 = Math.floor(r21 / 10000000);
array[r1] = r21 - r67 * 10000000;
r62 = r67 + 1;
r1 = r1 + 1;
r64 = r62;
r63 = r1;
} while (r63 < length2);
}
while (r64 > 0) {
const r70 = r63 + 1;
array[r63] = r64 % 10000000;
r64 = Math.floor(r64 / 10000000);
r63 = r70;
}
const sign = value < 0;
const r77 = {
__proto__: BigInteger.prototype
};
r77.value = array;
r77.sign = sign;
r77.isSmall = false;
return r77;
};
SmallInteger.prototype.plus = SmallInteger.prototype.add;
NativeBigInt.prototype.add = function(a0) {
"use strict";
const value = this.value + parseValue(a0).value;
const r11 = {
__proto__: NativeBigInt.prototype
};
r11.value = value;
return r11;
};
NativeBigInt.prototype.plus = NativeBigInt.prototype.add;
BigInteger.prototype.subtract = function(a0) {
"use strict";
let r2, r34, r40, sign2;
const r16 = parseValue(a0);
if (this.sign !== r16.sign) {
return this.add(r16.negate());
}
const value = this.value;
const value2 = r16.value;
if (r16.isSmall) {
r40 = subtractSmall(value, Math.abs(value2), this.sign);
} else {
const sign = this.sign;
if (value.length !== value2.length) {
r2 = value.length > value2.length ? 1 : -1;
} else {
let r0 = value.length - 1;
r2 = 0;
while (0 <= r0) {
const r22 = value[r0];
const r23 = value2[r0];
const r1 = r0;
if (r22 !== r23) {
r2 = value[r1] > value2[r1] ? 1 : -1;
break;
}
r0 = r1 - 1;
r2 = 0;
}
}
if (0 <= r2) {
r34 = subtract(value, value2);
sign2 = sign;
} else {
r34 = subtract(value2, value);
sign2 = !sign;
}
const value3 = arrayToSmall(r34);
if (typeof value3 === "number") {
const value4 = sign2 ? -value3 : value3;
const r45 = {
__proto__: SmallInteger.prototype
};
r45.value = value4;
r45.sign = value4 < 0;
r45.isSmall = true;
r40 = r45;
} else {
r40 = {
__proto__: BigInteger.prototype
};
r40.value = value3;
r40.sign = sign2;
r40.isSmall = false;
}
}
return r40;
};
BigInteger.prototype.minus = BigInteger.prototype.subtract;
SmallInteger.prototype.subtract = function(a0) {
"use strict";
let r18;
const r5 = parseValue(a0);
const value = this.value;
if (value < 0 !== r5.sign) {
return this.add(r5.negate());
}
const value2 = r5.value;
if (r5.isSmall) {
const value3 = value - value2;
const r22 = {
__proto__: SmallInteger.prototype
};
r22.value = value3;
r22.sign = value3 < 0;
r22.isSmall = true;
r18 = r22;
} else {
r18 = subtractSmall(value2, Math.abs(value), value >= 0);
}
return r18;
};
SmallInteger.prototype.minus = SmallInteger.prototype.subtract;
NativeBigInt.prototype.subtract = function(a0) {
"use strict";
const value = this.value - parseValue(a0).value;
const r11 = {
__proto__: NativeBigInt.prototype
};
r11.value = value;
return r11;
};
NativeBigInt.prototype.minus = NativeBigInt.prototype.subtract;
BigInteger.prototype.negate = function() {
"use strict";
const value = this.value;
const sign = !this.sign;
const r7 = {
__proto__: BigInteger.prototype
};
r7.value = value;
r7.sign = sign;
r7.isSmall = false;
return r7;
};
SmallInteger.prototype.negate = function() {
"use strict";
const sign = this.sign;
const value = -this.value;
const r9 = {
__proto__: SmallInteger.prototype
};
r9.value = value;
r9.sign = value < 0;
r9.isSmall = true;
r9.sign = !sign;
return r9;
};
NativeBigInt.prototype.negate = function() {
"use strict";
const value = -this.value;
const r6 = {
__proto__: NativeBigInt.prototype
};
r6.value = value;
return r6;
};
BigInteger.prototype.abs = function() {
"use strict";
const value = this.value;
const r6 = {
__proto__: BigInteger.prototype
};
r6.value = value;
r6.sign = false;
r6.isSmall = false;
return r6;
};
SmallInteger.prototype.abs = function() {
"use strict";
const value = Math.abs(this.value);
const r11 = {
__proto__: SmallInteger.prototype
};
r11.value = value;
r11.sign = value < 0;
r11.isSmall = true;
return r11;
};
NativeBigInt.prototype.abs = function() {
"use strict";
const value = this.value >= 0 ? this.value : -this.value;
const r8 = {
__proto__: NativeBigInt.prototype
};
r8.value = value;
return r8;
};
BigInteger.prototype.multiply = function(a0) {
"use strict";
let r63;
const r24 = parseValue(a0);
const value2 = this.value;
const value = r24.value;
const sign = this.sign !== r24.sign;
const isSmall = r24.isSmall;
let r28 = value;
if (isSmall) {
if (value === 0) {
return Integer[0];
}
if (value === 1) {
return this;
}
if (value === -1) {
return this.negate();
}
const r16 = Math.abs(value);
if (r16 < 10000000) {
const length4 = value2.length;
const array = new Array(length4);
const r76 = 0 < length4;
let r77 = 0;
let r78 = 0;
let r79 = 0;
let r80 = 0;
if (r76) {
do {
const r19 = value2[r78] * r16 + r77;
const r84 = Math.floor(r19 / 10000000);
array[r78] = r19 - r84 * 10000000;
r78 = r78 + 1;
r77 = r84;
r79 = r77;
r80 = r78;
} while (r80 < length4);
}
while (r79 > 0) {
const r87 = r80 + 1;
array[r80] = r79 % 10000000;
r79 = Math.floor(r79 / 10000000);
r80 = r87;
}
const r93 = {
__proto__: BigInteger.prototype
};
r93.value = array;
r93.sign = sign;
r93.isSmall = false;
return r93;
}
r28 = r16 < 10000000 ? [r16] : r16 < 100000000000000 ? [r16 % 10000000, Math.floor(r16 / 10000000)] : [r16 % 10000000, Math.floor(r16 / 10000000) % 10000000, Math.floor(r16 / 100000000000000)];
}
const length2 = value2.length;
const length3 = r28.length;
if (0 < -0.012 * length2 - 0.012 * length3 + 0.000015 * length2 * length3) {
const value4 = multiplyKaratsuba(value2, r28);
const r68 = {
__proto__: BigInteger.prototype
};
r68.value = value4;
r68.sign = sign;
r68.isSmall = false;
r63 = r68;
} else {
const value3 = multiplyLong(value2, r28);
r63 = {
__proto__: BigInteger.prototype
};
r63.value = value3;
r63.sign = sign;
r63.isSmall = false;
}
return r63;
};
BigInteger.prototype.times = BigInteger.prototype.multiply;
SmallInteger.prototype._multiplyBySmall = function(a0) {
"use strict";
let r44;
const r15 = a0.value * this.value;
if (-9007199254740992 < r15 && r15 < 9007199254740992) {
const value = a0.value * this.value;
const r50 = {
__proto__: SmallInteger.prototype
};
r50.value = value;
r50.sign = value < 0;
r50.isSmall = true;
r44 = r50;
} else {
const r19 = Math.abs(a0.value);
const r22 = Math.abs(this.value);
r44 = multiplySmallAndArray(r19, r22 < 10000000 ? [r22] : r22 < 100000000000000 ? [r22 % 10000000, Math.floor(r22 / 10000000)] : [r22 % 10000000, Math.floor(r22 / 10000000) % 10000000, Math.floor(r22 / 100000000000000)], this.sign !== a0.sign);
}
return r44;
};
BigInteger.prototype._multiplyBySmall = function(a0) {
"use strict";
return a0.value === 0 ? Integer[0] : a0.value !== 1 ? a0.value === -1 ? this.negate() : multiplySmallAndArray(Math.abs(a0.value), this.value, this.sign !== a0.sign) : this;
};
SmallInteger.prototype.multiply = function(a0) {
"use strict";
return parseValue(a0)._multiplyBySmall(this);
};
SmallInteger.prototype.times = SmallInteger.prototype.multiply;
NativeBigInt.prototype.multiply = function(a0) {
"use strict";
const value = this.value * parseValue(a0).value;
const r11 = {
__proto__: NativeBigInt.prototype
};
r11.value = value;
return r11;
};
NativeBigInt.prototype.times = NativeBigInt.prototype.multiply;
BigInteger.prototype.square = function() {
"use strict";
const value = square(this.value);
const r9 = {
__proto__: BigInteger.prototype
};
r9.value = value;
r9.sign = false;
r9.isSmall = false;
return r9;
};
SmallInteger.prototype.square = function() {
"use strict";
let r39;
const value = this.value * this.value;
if (-9007199254740992 < value && value < 9007199254740992) {
const r43 = {
__proto__: SmallInteger.prototype
};
r43.value = value;
r43.sign = value < 0;
r43.isSmall = true;
r39 = r43;
} else {
const r18 = Math.abs(this.value);
const value2 = square(r18 < 10000000 ? [r18] : r18 < 100000000000000 ? [r18 % 10000000, Math.floor(r18 / 10000000)] : [r18 % 10000000, Math.floor(r18 / 10000000) % 10000000, Math.floor(r18 / 100000000000000)]);
r39 = {
__proto__: BigInteger.prototype
};
r39.value = value2;
r39.sign = false;
r39.isSmall = false;
}
return r39;
};
NativeBigInt.prototype.square = function(a0) {
"use strict";
const value = this.value * this.value;
const r7 = {
__proto__: NativeBigInt.prototype
};
r7.value = value;
return r7;
};
BigInteger.prototype.divmod = function(a0) {
"use strict";
const r5 = divModAny(this, a0);
return {
quotient: r5[0],
remainder: r5[1]
};
};
const prototype4 = NativeBigInt.prototype;
const prototype5 = SmallInteger.prototype;
const divmod = BigInteger.prototype.divmod;
prototype5.divmod = divmod;
prototype4.divmod = divmod;
BigInteger.prototype.divide = function(a0) {
"use strict";
return divModAny(this, a0)[0];
};
const { prototype: prototype6, prototype: prototype7 } = NativeBigInt;
const divide2 = function(a0) {
"use strict";
const value = this.value / parseValue(a0).value;
const r11 = {
__proto__: NativeBigInt.prototype
};
r11.value = value;
return r11;
};
prototype7.divide = divide2;
prototype6.over = divide2;
const { prototype: prototype8, prototype: prototype9 } = SmallInteger;
const prototype = BigInteger.prototype;
const divide = BigInteger.prototype.divide;
prototype.over = divide;
prototype9.divide = divide;
prototype8.over = divide;
BigInteger.prototype.mod = function(a0) {
"use strict";
return divModAny(this, a0)[1];
};
const { prototype: prototype10, prototype: prototype11 } = NativeBigInt;
const remainder = function(a0) {
"use strict";
const value = this.value % parseValue(a0).value;
const r11 = {
__proto__: NativeBigInt.prototype
};
r11.value = value;
return r11;
};
prototype11.remainder = remainder;
prototype10.mod = remainder;
const { prototype: prototype12, prototype: prototype13 } = SmallInteger;
const prototype14 = BigInteger.prototype;
const mod = BigInteger.prototype.mod;
prototype14.remainder = mod;
prototype13.mod = mod;
prototype12.remainder = mod;
BigInteger.prototype.pow = function(a0) {
"use strict";
let r13 = this;
const r24 = parseValue(a0);
const value = this.value;
const value2 = r24.value;
if (value2 === 0) {
return Integer[1];
}
if (value === 0) {
return Integer[0];
}
if (value === 1) {
return Integer[1];
}
if (value === -1) {
const isEven = r24.isEven();
return isEven ? Integer[1] : Integer[-1];
}
if (r24.sign) {
return Integer[0];
}
if (r24.isSmall) {
if (this.isSmall) {
const r38 = Math.pow(value, value2);
if (-9007199254740992 < r38 && r38 < 9007199254740992) {
const value3 = r38 > 0 ? Math.floor(r38) : Math.ceil(r38);
const r60 = {
__proto__: SmallInteger.prototype
};
r60.value = value3;
r60.sign = value3 < 0;
r60.isSmall = true;
return r60;
}
}
const r18 = Integer[1];
const r43 = true & value2;
let r44 = value2;
let r45 = r18;
if (r43) {
r45 = r18.times(this);
r44 = value2 - 1;
}
let r48 = r45;
let r49 = r48;
while (r44 !== 0) {
const r1 = r44 / 2;
const r51 = r13.square();
const r4 = true & r1;
const r20 = r48;
let r0 = r1;
let r52 = r20;
if (r4) {
r52 = r20.times(r51);
r0 = r1 - 1;
}
r44 = r0;
r48 = r52;
r13 = r51;
r49 = r48;
}
return r49;
}
throw new Error("The exponent " + r24.toString() + " is too large.");
};
SmallInteger.prototype.pow = BigInteger.prototype.pow;
NativeBigInt.prototype.pow = function(a0) {
"use strict";
let r6 = this;
const r17 = parseValue(a0);
const value2 = this.value;
const value = r17.value;
const value3 = BigInt(0);
const r10 = BigInt(1);
const r23 = BigInt(2);
if (value === value3) {
return Integer[1];
}
if (value2 === value3) {
return Integer[0];
}
if (value2 === r10) {
return Integer[1];
}
if (value2 === BigInt(-1)) {
const isEven = r17.isEven();
return isEven ? Integer[1] : Integer[-1];
}
if (r17.isNegative()) {
const r41 = {
__proto__: NativeBigInt.prototype
};
r41.value = value3;
return r41;
}
const r12 = Integer[1];
const r11 = value & r10;
let r30 = r12;
let r31 = value;
if (r11 === r10) {
r30 = r12.times(this);
r31 = value - 1;
}
let r33 = r30;
let r34 = r33;
while (r31 !== value3) {
const r14 = r31 / r23;
const r13 = r6.square();
const r15 = r14 & r10;
const r16 = r33;
let r36 = r16;
let r37 = r14;
if (r15 === r10) {
r36 = r16.times(r13);
r37 = r14 - 1;
}
r33 = r36;
r31 = r37;
r6 = r13;
r34 = r33;
}
return r34;
};
BigInteger.prototype.modPow = function(a0, a1) {
"use strict";
let isPositive2;
const r10 = parseValue(a0);
const r8 = parseValue(a1);
if (r8.isZero()) {
throw new Error("Cannot take modPow with modulus 0");
}
const r19 = Integer[1];
const r9 = this.mod(r8);
const isNegative = r10.isNegative();
let r7 = r9;
let r22 = r10;
if (isNegative) {
r22 = r10.multiply(Integer[-1]);
r7 = r9.modInv(r8);
}
const isPositive = r22.isPositive();
let r29 = r22;
let r30 = r19;
let r31 = r30;
if (isPositive) {
do {
const isZero = r7.isZero();
const r11 = r7;
const r12 = r30;
const r34 = r29;
if (isZero) {
return Integer[0];
}
const r37 = r34.isOdd() ? r12.multiply(r11).mod(r8) : r12;
const r42 = r34.divide(2);
r7 = r11.square().mod(r8);
isPositive2 = r42.isPositive();
r30 = r37;
r29 = r42;
r31 = r30;
} while (isPositive2);
}
return r31;
};
const prototype15 = NativeBigInt.prototype;
const prototype16 = SmallInteger.prototype;
const modPow = BigInteger.prototype.modPow;
prototype16.modPow = modPow;
prototype15.modPow = modPow;
BigInteger.prototype.compareAbs = function(a0) {
"use strict";
let r2;
const r10 = parseValue(a0);
const value = this.value;
const { value: value2, isSmall } = r10;
let r5 = 1;
if (!isSmall) {
if (value.length !== value2.length) {
r2 = value.length > value2.length ? 1 : -1;
} else {
let r0 = value.length - 1;
r2 = 0;
while (0 <= r0) {
const r19 = value[r0];
const r20 = value2[r0];
const r1 = r0;
if (r19 !== r20) {
r2 = value[r1] > value2[r1] ? 1 : -1;
break;
}
r0 = r1 - 1;
r2 = 0;
}
}
r5 = r2;
}
return r5;
};
SmallInteger.prototype.compareAbs = function(a0) {
"use strict";
const r7 = parseValue(a0);
const r14 = Math.abs(this.value);
const { value, isSmall } = r7;
let r0 = -1;
let r2 = -1;
if (isSmall) {
const r19 = Math.abs(value);
let r1 = 0;
if (r14 !== r19) {
if (r14 > r19) {
r0 = 1;
}
r1 = r0;
}
r2 = r1;
}
return r2;
};
NativeBigInt.prototype.compareAbs = function(a0) {
"use strict";
const value = this.value;
const value2 = parseValue(a0).value;
let r11 = value;
if (!(r11 >= 0)) {
r11 = -value;
}
let r12 = value2;
if (!(r12 >= 0)) {
r12 = -value2;
}
return r11 !== r12 ? r11 > r12 ? 1 : -1 : 0;
};
BigInteger.prototype.compare = function(a0) {
"use strict";
let r2, r34;
if (a0 === Infinity) {
return -1;
}
if (a0 === -Infinity) {
return 1;
}
const r15 = parseValue(a0);
const value = this.value;
const value2 = r15.value;
if (this.sign !== r15.sign) {
r34 = r15.sign ? 1 : -1;
} else if (r15.isSmall) {
r34 = this.sign ? -1 : 1;
} else {
if (value.length !== value2.length) {
r2 = value.length > value2.length ? 1 : -1;
} else {
let r0 = value.length - 1;
r2 = 0;
while (0 <= r0) {
const r21 = value[r0];
const r22 = value2[r0];
const r23 = r0;
if (r21 !== r22) {
r2 = value[r23] > value2[r23] ? 1 : -1;
break;
}
r0 = r23 - 1;
r2 = 0;
}
}
r34 = r2 * (this.sign ? -1 : 1);
}
return r34;
};
BigInteger.prototype.compareTo = BigInteger.prototype.compare;
SmallInteger.prototype.compare = function(a0) {
"use strict";
if (a0 === Infinity) {
return -1;
}
if (a0 === -Infinity) {
return 1;
}
const r11 = parseValue(a0);
const value = this.value;
const value2 = r11.value;
return r11.isSmall ? value == value2 ? 0 : value > value2 ? 1 : -1 : value < 0 !== r11.sign ? value < 0 ? -1 : 1 : value < 0 ? 1 : -1;
};
SmallInteger.prototype.compareTo = SmallInteger.prototype.compare;
NativeBigInt.prototype.compare = function(a0) {
"use strict";
if (a0 === Infinity) {
return -1;
}
if (a0 === -Infinity) {
return 1;
}
const value = this.value;
const value2 = parseValue(a0).value;
return value !== value2 ? value > value2 ? 1 : -1 : 0;
};
NativeBigInt.prototype.compareTo = NativeBigInt.prototype.compare;
BigInteger.prototype.equals = function(a0) {
"use strict";
return this.compare(a0) === 0;
};
const { prototype: prototype17, prototype: prototype18 } = NativeBigInt;
const { prototype: prototype19, prototype: prototype2 } = SmallInteger;
const prototype3 = BigInteger.prototype;
const equals = BigInteger.prototype.equals;
prototype3.eq = equals;
prototype2.equals = equals;
prototype19.eq = equals;
prototype18.equals = equals;
prototype17.eq = equals;
BigInteger.prototype.notEquals = function(a0) {
"use strict";
return this.compare(a0) !== 0;
};
const { prototype: prototype20, prototype: prototype21 } = NativeBigInt;
const { prototype: prototype22, prototype: prototype23 } = SmallInteger;
const prototype24 = BigInteger.prototype;
const notEquals = BigInteger.prototype.notEquals;
prototype24.neq = notEquals;
prototype23.notEquals = notEquals;
prototype22.neq = notEquals;
prototype21.notEquals = notEquals;
prototype20.neq = notEquals;
BigInteger.prototype.greater = function(a0) {
"use strict";
return this.compare(a0) > 0;
};
const { prototype: prototype25, prototype: prototype26 } = NativeBigInt;
const { prototype: prototype27, prototype: prototype28 } = SmallInteger;
const prototype29 = BigInteger.prototype;
const greater = BigInteger.prototype.greater;
prototype29.gt = greater;
prototype28.greater = greater;
prototype27.gt = greater;
prototype26.greater = greater;
prototype25.gt = greater;
BigInteger.prototype.lesser = function(a0) {
"use strict";
return this.compare(a0) < 0;
};
const { prototype: prototype30, prototype: prototype31 } = NativeBigInt;
const { prototype: prototype32, prototype: prototype33 } = SmallInteger;
const prototype34 = BigInteger.prototype;
const lesser = BigInteger.prototype.lesser;
prototype34.lt = lesser;
prototype33.lesser = lesser;
prototype32.lt = lesser;
prototype31.lesser = lesser;
prototype30.lt = lesser;
BigInteger.prototype.greaterOrEquals = function(a0) {
"use strict";
return this.compare(a0) >= 0;
};
const { prototype: prototype35, prototype: prototype36 } = NativeBigInt;
const { prototype: prototype37, prototype: prototype38 } = SmallInteger;
const prototype39 = BigInteger.prototype;
const greaterOrEquals = BigInteger.prototype.greaterOrEquals;
prototype39.geq = greaterOrEquals;
prototype38.greaterOrEquals = greaterOrEquals;
prototype37.geq = greaterOrEquals;
prototype36.greaterOrEquals = greaterOrEquals;
prototype35.geq = greaterOrEquals;
BigInteger.prototype.lesserOrEquals = function(a0) {
"use strict";
return this.compare(a0) <= 0;
};
const { prototype: prototype40, prototype: prototype41 } = NativeBigInt;
const { prototype: prototype42, prototype: prototype43 } = SmallInteger;
const prototype44 = BigInteger.prototype;
const lesserOrEquals = BigInteger.prototype.lesserOrEquals;
prototype44.leq = lesserOrEquals;
prototype43.lesserOrEquals = lesserOrEquals;
prototype42.leq = lesserOrEquals;
prototype41.lesserOrEquals = lesserOrEquals;
prototype40.leq = lesserOrEquals;
BigInteger.prototype.isEven = function() {
"use strict";
return !(1 & this.value[0]);
};
SmallInteger.prototype.isEven = function() {
"use strict";
return !(1 & this.value);
};
NativeBigInt.prototype.isEven = function() {
"use strict";
return (this.value & BigInt(1)) === BigInt(0);
};
BigInteger.prototype.isOdd = function() {
"use strict";
return !(1 & ~this.value[0]);
};
SmallInteger.prototype.isOdd = function() {
"use strict";
return !(1 & ~this.value);
};
NativeBigInt.prototype.isOdd = function() {
"use strict";
return (this.value & BigInt(1)) === BigInt(1);
};
BigInteger.prototype.isPositive = function() {
"use strict";
return !this.sign;
};
SmallInteger.prototype.isPositive = function() {
"use strict";
return this.value > 0;
};
NativeBigInt.prototype.isPositive = SmallInteger.prototype.isPositive;
BigInteger.prototype.isNegative = function() {
"use strict";
return this.sign;
};
SmallInteger.prototype.isNegative = function() {
"use strict";
return this.value < 0;
};
NativeBigInt.prototype.isNegative = SmallInteger.prototype.isNegative;
BigInteger.prototype.isUnit = function() {
"use strict";
return false;
};
SmallInteger.prototype.isUnit = function() {
"use strict";
return Math.abs(this.value) === 1;
};
NativeBigInt.prototype.isUnit = function() {
"use strict";
return this.abs().value === BigInt(1);
};
BigInteger.prototype.isZero = function() {
"use strict";
return false;
};
SmallInteger.prototype.isZero = function() {
"use strict";
return this.value === 0;
};
NativeBigInt.prototype.isZero = function() {
"use strict";
return this.value === BigInt(0);
};
BigInteger.prototype.isDivisibleBy = function(a0) {
"use strict";
const r5 = parseValue(a0);
const isZero = r5.isZero();
return isZero ? !isZero : !!r5.isUnit() || (r5.compareAbs(2) === 0 ? this.isEven() : this.mod(r5).isZero());
};
const prototype45 = NativeBigInt.prototype;
const prototype46 = SmallInteger.prototype;
const isDivisibleBy = BigInteger.prototype.isDivisibleBy;
prototype46.isDivisibleBy = isDivisibleBy;
prototype45.isDivisibleBy = isDivisibleBy;
BigInteger.prototype.isPrime = function(a0) {
"use strict";
const r11 = this.abs();
const isUnit = r11.isUnit();
let r8 = !isUnit;
if (!isUnit) {
let r25 = !!(r11.equals(2) || r11.equals(3) || r11.equals(5));
if (!r25) {
const r27 = r11.isEven() || r11.isDivisibleBy(3) || r11.isDivisibleBy(5);
r25 = r27 ? !r27 : !!r11.lesser(49) || void 0;
}
r8 = r25;
}
if (r8 !== void 0) {
return r8;
}
const r39 = this.abs();
const r14 = r39.bitLength();
if (r14 <= 64) {
return millerRabinTest(r39, [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37]);
}
const r17 = Math.log(2) * r14.toJSNumber();
const r54 = Math.ceil(a0 === true ? 2 * Math.pow(r17, 2) : r17);
const r55 = [];
const r57 = 0 < r54;
let r0 = 0;
if (r57) {
do {
r55.push((0, env34[0])(r0 + 2));
r0 = r0 + 1;
} while (r0 < r54);
}
return millerRabinTest(r39, r55);
};
const prototype47 = NativeBigInt.prototype;
const prototype48 = SmallInteger.prototype;
const isPrime = BigInteger.prototype.isPrime;
prototype48.isPrime = isPrime;
prototype47.isPrime = isPrime;
BigInteger.prototype.isProbablePrime = function(a0, a1) {
"use strict";
const r11 = this.abs();
const isUnit = r11.isUnit();
let r7 = !isUnit;
if (!isUnit) {
let r26 = !!(r11.equals(2) || r11.equals(3) || r11.equals(5));
if (!r26) {
const r28 = r11.isEven() || r11.isDivisibleBy(3) || r11.isDivisibleBy(5);
r26 = r28 ? !r28 : !!r11.lesser(49) || void 0;
}
r7 = r26;
}
if (r7 !== void 0) {
return r7;
}
const r40 = this.abs();
const r41 = a0 !== void 0 ? a0 : 5;
const r42 = [];
const r44 = 0 < r41;
let r0 = 0;
if (r44) {
do {
r42.push(env34[0].randBetween(2, r40.minus(2), a1));
r0 = r0 + 1;
} while (r0 < r41);
}
return millerRabinTest(r40, r42);
};
const prototype49 = NativeBigInt.prototype;
const prototype50 = SmallInteger.prototype;
const isProbablePrime = BigInteger.prototype.isProbablePrime;
prototype50.isProbablePrime = isProbablePrime;
prototype49.isProbablePrime = isProbablePrime;
BigInteger.prototype.modInv = function(a0) {
"use strict";
let isZero2;
const r17 = env34[0];
const zero = r17.zero;
let one = r17.one;
let r8 = parseValue(a0);
const r7 = this.abs();
const isZero = r7.isZero();
let r9 = r7;
let r23 = zero;
let r4 = r8;
let r24 = r23;
if (!isZero) {
do {
const r12 = r8.divide(r9);
const r13 = r23.subtract(r12.multiply(one));
const r14 = r8.subtract(r12.multiply(r9));
isZero2 = r14.isZero();
r8 = r9;
r23 = one;
r9 = r14;
one = r13;
r4 = r8;
r24 = r23;
} while (!isZero2);
}
if (r4.isUnit()) {
const r51 = r24.compare(0) === -1 ? r24.add(a0) : r24;
return this.isNegative() ? r51.negate() : r51;
}
throw new Error(this.toString() + " and " + a0.toString() + " are not co-prime");
};
const r294 = NativeBigInt.prototype;
const r295 = SmallInteger.prototype;
const modInv = BigInteger.prototype.modInv;
r295.modInv = modInv;
r294.modInv = modInv;
BigInteger.prototype.next = function() {
"use strict";
let r39;
const value = this.value;
if (this.sign) {
r39 = subtractSmall(value, 1, this.sign);
} else {
const length2 = value.length;
const array = new Array(length2);
const r6 = 0 < length2;
let r1 = 0;
let r14 = 1;
let r2 = 0;
let r26 = 1;
if (r6) {
do {
const r17 = value[r1] - 10000000 + r14;
const r29 = Math.floor(r17 / 10000000);
array[r1] = r17 - r29 * 10000000;
r14 = r29 + 1;
r1 = r1 + 1;
r26 = r14;
r2 = r1;
} while (r2 < length2);
}
while (r26 > 0) {
const r32 = r2 + 1;
array[r2] = r26 % 10000000;
r26 = Math.floor(r26 / 10000000);
r2 = r32;
}
const sign = this.sign;
r39 = {
__proto__: BigInteger.prototype
};
r39.value = array;
r39.sign = sign;
r39.isSmall = false;
}
return r39;
};
SmallInteger.prototype.next = function() {
"use strict";
let r10;
const value = this.value;
if (value + 1 < 9007199254740992) {
const value3 = value + 1;
const r14 = {
__proto__: SmallInteger.prototype
};
r14.value = value3;
r14.sign = value3 < 0;
r14.isSmall = true;
r10 = r14;
} else {
const value2 = c35_0;
r10 = {
__proto__: BigInteger.prototype
};
r10.value = value2;
r10.sign = false;
r10.isSmall = false;
}
return r10;
};
NativeBigInt.prototype.next = function() {
"use strict";
const value = this.value + BigInt(1);
const r11 = {
__proto__: NativeBigInt.prototype
};
r11.value = value;
return r11;
};
BigInteger.prototype.prev = function() {
"use strict";
let r24;
const value = this.value;
if (this.sign) {
const length2 = value.length;
const array = new Array(length2);
const r6 = 0 < length2;
let r1 = 0;
let r12 = 1;
let r30 = 0;
let r31 = 1;
if (r6) {
do {
const r16 = value[r1] - 10000000 + r12;
const r34 = Math.floor(r16 / 10000000);
array[r1] = r16 - r34 * 10000000;
r12 = r34 + 1;
r1 = r1 + 1;
r31 = r12;
r30 = r1;
} while (r30 < length2);
}
while (r31 > 0) {
const r37 = r30 + 1;
array[r30] = r31 % 10000000;
r31 = Math.floor(r31 / 10000000);
r30 = r37;
}
const r43 = {
__proto__: BigInteger.prototype
};
r43.value = array;
r43.sign = true;
r43.isSmall = false;
r24 = r43;
} else {
r24 = subtractSmall(value, 1, this.sign);
}
return r24;
};
SmallInteger.prototype.prev = function() {
"use strict";
let r10;
const value = this.value;
if (-9007199254740992 < value - 1) {
const value3 = value - 1;
const r15 = {
__proto__: SmallInteger.prototype
};
r15.value = value3;
r15.sign = value3 < 0;
r15.isSmall = true;
r10 = r15;
} else {
const value2 = c35_0;
r10 = {
__proto__: BigInteger.prototype
};
r10.value = value2;
r10.sign = true;
r10.isSmall = false;
}
return r10;
};
NativeBigInt.prototype.prev = function() {
"use strict";
const value = this.value - BigInt(1);
const r11 = {
__proto__: NativeBigInt.prototype
};
r11.value = value;
return r11;
};
c35_17 = [1];
while (2 * c35_17[c35_17.length - 1] <= 10000000) {
c35_17.push(2 * c35_17[c35_17.length - 1]);
}
const length2 = c35_17.length;
length = length2;
c35_19 = c35_17[length2 - 1];
BigInteger.prototype.shiftLeft = function(a0) {
"use strict";
let r34;
const r16 = parseValue(a0).toJSNumber();
if (Math.abs(r16) <= 10000000) {
if (r16 < 0) {
return this.shiftRight(-r16);
}
if (this.isZero()) {
return this;
}
let r10 = this;
let r9 = r16;
let r32 = this;
let r8 = r9;
if (r8 >= length) {
do {
r10 = r10.multiply(c35_19);
r34 = length;
r9 = r9 - (r34 - 1);
r32 = r10;
r8 = r9;
} while (r8 >= r34);
}
return r32.multiply(c35_17[r8]);
}
throw new Error(String(r16) + " is too large for shifting.");
};
const r330 = NativeBigInt.prototype;
const r331 = SmallInteger.prototype;
const shiftLeft = BigInteger.prototype.shiftLeft;
r331.shiftLeft = shiftLeft;
r330.shiftLeft = shiftLeft;
BigInteger.prototype.shiftRight = function(a0) {
"use strict";
let r36;
const r21 = parseValue(a0).toJSNumber();
if (Math.abs(r21) <= 10000000) {
if (r21 < 0) {
return this.shiftLeft(-r21);
}
let r12 = this;
let r11 = r21;
let r9 = this;
let r10 = r11;
if (r10 >= length) {
while (true) {
L15: {
const isZero = r12.isZero();
r36 = r12;
const r14 = r11;
if (!isZero) {
if (r36.isNegative() && r36.isUnit()) {
break L15;
}
const r42 = divModAny(r36, c35_19);
const isNegative = r42[1].isNegative();
const r45 = r42[0];
const r46 = isNegative ? r45.prev() : r45;
r11 = r14 - (length - 1);
r12 = r46;
r9 = r12;
r10 = r11;
if (r10 >= length) {
continue;
}
break;
}
}
return r36;
}
}
const r52 = divModAny(r9, c35_17[r10]);
const isNegative2 = r52[1].isNegative();
const r56 = r52[0];
return isNegative2 ? r56.prev() : r56;
}
throw new Error(String(r21) + " is too large for shifting.");
};
const r336 = NativeBigInt.prototype;
const r337 = SmallInteger.prototype;
const shiftRight = BigInteger.prototype.shiftRight;
r337.shiftRight = shiftRight;
r336.shiftRight = shiftRight;
BigInteger.prototype.not = function() {
"use strict";
return this.negate().prev();
};
const r342 = NativeBigInt.prototype;
const r343 = SmallInteger.prototype;
const not = BigInteger.prototype.not;
r343.not = not;
r342.not = not;
BigInteger.prototype.and = function(a0) {
"use strict";
return bitwise(this, a0, function(a0, a1) {
return a0 & a1;
});
};
const r348 = NativeBigInt.prototype;
const r349 = SmallInteger.prototype;
const and = BigInteger.prototype.and;
r349.and = and;
r348.and = and;
BigInteger.prototype.or = function(a0) {
"use strict";
return bitwise(this, a0, function(a0, a1) {
return a0 | a1;
});
};
const r354 = NativeBigInt.prototype;
const r355 = SmallInteger.prototype;
const or = BigInteger.prototype.or;
r355.or = or;
r354.or = or;
BigInteger.prototype.xor = function(a0) {
"use strict";
return bitwise(this, a0, function(a0, a1) {
return a0 ^ a1;
});
};
const r360 = NativeBigInt.prototype;
const r361 = SmallInteger.prototype;
const xor = BigInteger.prototype.xor;
r361.xor = xor;
r360.xor = xor;
c35_21 = 1073741824;
BigInteger.prototype.bitLength = function() {
"use strict";
let r27, r33, r66;
const compareTo = this.compareTo;
const r6 = env34[0];
const r16 = compareTo.call(this, r6(0)) < 0 ? this.negate().subtract(r6(1)) : this;
const r22 = r16.compareTo(r6(0));
if (r22 === 0) {
r66 = r6(0);
} else {
const r10 = r6(2);
if (r10.compareTo(r16) <= 0) {
const r13 = r10.square(r10);
if (r13.compareTo(r16) <= 0) {
const r38 = integerLogarithm(r16, r13.square(r13));
const { p: r39, e: r12 } = r38;
const r41 = r39.multiply(r13);
r33 = r41.compareTo(r16) <= 0 ? {
p: r41,
e: 2 * r12 + 1
} : {
p: r39,
e: 2 * r12
};
} else {
r33 = {
p: r6(1),
e: 0
};
}
const { p: r49, e: r50 } = r33;
const r52 = r49.multiply(r10);
r27 = r52.compareTo(r16) <= 0 ? {
p: r52,
e: 2 * r50 + 1
} : {
p: r49,
e: 2 * r50
};
} else {
r27 = {
p: r6(1),
e: 0
};
}
r66 = r6(r27.e).add(r6(1));
}
return r66;
};
const r367 = NativeBigInt.prototype;
const r368 = SmallInteger.prototype;
const bitLength = BigInteger.prototype.bitLength;
r368.bitLength = bitLength;
r367.bitLength = bitLength;
parseBase = function parseBase(a0, a1, a2, a3) {
"use strict";
};
BigInteger.prototype.toArray = function(a0) {
"use strict";
return toBase(this, a0);
};
SmallInteger.prototype.toArray = function(a0) {
"use strict";
return toBase(this, a0);
};
NativeBigInt.prototype.toArray = function(a0) {
"use strict";
return toBase(this, a0);
};
BigInteger.prototype.toString = function(a0, a1) {
"use strict";
const r5 = a0 === void 0 ? 10 : a0;
if (r5 !== 10) {
let env23556;
const r28 = env23556 = {
$parent: env35
};
env23556[0] = a1;
const r31 = toBase(this, r5);
return (r31.isNegative ? "-" : "") + r31.value.map($mk100897(r28)).join("");
}
const value = this.value;
const length2 = value.length;
const r6 = String;
const r13 = length2 - 1;
const r14 = r6(value[r13]);
let r7 = r13 - 1;
let r17 = r14;
let r18 = r17;
while (r7 >= 0) {
const r19 = String(value[r7]);
r17 = r17 + ("0000000".slice(r19.length) + r19);
r7 = r7 - 1;
r18 = r17;
}
return (this.sign ? "-" : "") + r18;
};
SmallInteger.prototype.toString = function(a0, a1) {
"use strict";
let r9;
const r6 = a0 === void 0 ? 10 : a0;
if (r6 != 10) {
let env23557;
const r10 = env23557 = {
$parent: env35
};
env23557[0] = a1;
const r13 = toBase(this, r6);
r9 = (r13.isNegative ? "-" : "") + r13.value.map($mk100897(r10)).join("");
} else {
r9 = String(this.value);
}
return r9;
};
NativeBigInt.prototype.toString = SmallInteger.prototype.toString;
const r385 = NativeBigInt.prototype;
const r386 = BigInteger.prototype;
const r387 = SmallInteger.prototype;
const toJSON = function() {
"use strict";
return this.toString();
};
r387.toJSON = toJSON;
r386.toJSON = toJSON;
r385.toJSON = toJSON;
BigInteger.prototype.valueOf = function() {
"use strict";
return parseInt(this.toString(), 10);
};
BigInteger.prototype.toJSNumber = BigInteger.prototype.valueOf;
SmallInteger.prototype.valueOf = function() {
"use strict";
return this.value;
};
SmallInteger.prototype.toJSNumber = SmallInteger.prototype.valueOf;
const { prototype: r399, prototype: r400 } = NativeBigInt;
const toJSNumber = function() {
"use strict";
return parseInt(this.toString(), 10);
};
r400.toJSNumber = toJSNumber;
r399.valueOf = toJSNumber;
let r404 = 0;
while (true) {
Integer[r404] = parseValue(r404);
const r2 = r404;
if (0 < r2) {
const r4 = -r2;
Integer[r4] = parseValue(r4);
}
r404 = r2 + 1;
if (!(r404 < 1000)) {
const max = function max(a0, a1) {
"use strict";
const r2 = parseValue(a0);
let r6 = parseValue(a1);
if (r2.greater(r6)) {
r6 = r2;
}
return r6;
};
const min = function min(a0, a1) {
"use strict";
const r2 = parseValue(a0);
let r6 = parseValue(a1);
if (r2.lesser(r6)) {
r6 = r2;
}
return r6;
};
Integer.one = Integer[1];
Integer.zero = Integer[0];
Integer.minusOne = Integer[-1];
Integer.max = max;
Integer.min = min;
Integer.gcd = gcd;
Integer.lcm = function lcm(a0, a1) {
"use strict";
const r6 = parseValue(a0).abs();
const r10 = parseValue(a1).abs();
return r6.divide(gcd(r6, r10)).multiply(r10);
};
Integer.isInstance = function(a0) {
"use strict";
return a0 instanceof BigInteger || a0 instanceof SmallInteger || a0 instanceof NativeBigInt;
};
Integer.randBetween = function randBetween(a0, a1, a2) {
"use strict";
let length2;
let r9 = a2;
const r12 = parseValue(a0);
const r13 = parseValue(a1);
if (!a2) {
r9 = Math.random;
}
const r15 = parseValue(r12);
let r24 = parseValue(r13);
if (r15.lesser(r24)) {
r24 = r15;
}
const r26 = parseValue(r12);
let r27 = parseValue(r13);
if (r26.greater(r27)) {
r27 = r26;
}
const r33 = r27.subtract(r24).add(1);
if (r33.isSmall) {
return r24.add(Math.floor(r9() * r33));
}
const value = toBase(r33, 10000000).value;
const r38 = [];
const r5 = 0 < value.length;
let r0 = 0;
let r6 = true;
if (r5) {
do {
const r1 = r0;
let r41 = r6;
const r17 = r41 ? value[r1] : 10000000;
const r20 = r9() * r17;
const r44 = r20 > 0 ? Math.floor(r20) : Math.ceil(r20);
r38.push(r44);
if (r44 < r17) {
r41 = false;
}
r0 = r1 + 1;
length2 = value.length;
r6 = r41;
} while (r0 < length2);
}
return r24.add(Integer.fromArray(r38, 10000000, false));
};
Integer.fromArray = function(a0, a1, a2) {
"use strict";
let r7 = a1;
const map = a0.map;
const r13 = map.call(a0, parseValue);
if (!a1) {
r7 = 10;
}
const r14 = parseValue(r7);
const r16 = Integer[0];
let r17 = Integer[1];
let r0 = r13.length - 1;
let r19 = r16;
let r20 = r19;
while (0 <= r0) {
r19 = r19.add(r13[r0].times(r17));
r17 = r17.times(r14);
r0 = r0 - 1;
r20 = r19;
}
return a2 ? r20.negate() : r20;
};
env34[0] = Integer;
if (module !== void 0 && module.hasOwnProperty("exports")) {
module.exports = Integer;
}
const define2 = globalThis.define;
if (typeof define2 === "function" ? define.amd : typeof define2 === "function") {
define(function() {
return env34[0];
});
}
return void 0;
}
}