@meshsdk/core-cst 1.9.0-beta.2 → 1.9.0-beta.4

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/dist/index.cjs CHANGED
@@ -892,6 +892,3460 @@ var require_blakejs = __commonJS({
892
892
  }
893
893
  });
894
894
 
895
+ // ../../node_modules/bignumber.js/bignumber.js
896
+ var require_bignumber = __commonJS({
897
+ "../../node_modules/bignumber.js/bignumber.js"(exports2, module2) {
898
+ "use strict";
899
+ (function(globalObject) {
900
+ "use strict";
901
+ var BigNumber, isNumeric = /^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i, mathceil = Math.ceil, mathfloor = Math.floor, bignumberError = "[BigNumber Error] ", tooManyDigits = bignumberError + "Number primitive has more than 15 significant digits: ", BASE = 1e14, LOG_BASE = 14, MAX_SAFE_INTEGER = 9007199254740991, POWS_TEN = [1, 10, 100, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13], SQRT_BASE = 1e7, MAX = 1e9;
902
+ function clone(configObject) {
903
+ var div, convertBase, parseNumeric, P = BigNumber2.prototype = { constructor: BigNumber2, toString: null, valueOf: null }, ONE = new BigNumber2(1), DECIMAL_PLACES = 20, ROUNDING_MODE = 4, TO_EXP_NEG = -7, TO_EXP_POS = 21, MIN_EXP = -1e7, MAX_EXP = 1e7, CRYPTO = false, MODULO_MODE = 1, POW_PRECISION = 0, FORMAT = {
904
+ prefix: "",
905
+ groupSize: 3,
906
+ secondaryGroupSize: 0,
907
+ groupSeparator: ",",
908
+ decimalSeparator: ".",
909
+ fractionGroupSize: 0,
910
+ fractionGroupSeparator: "\xA0",
911
+ // non-breaking space
912
+ suffix: ""
913
+ }, ALPHABET = "0123456789abcdefghijklmnopqrstuvwxyz", alphabetHasNormalDecimalDigits = true;
914
+ function BigNumber2(v, b) {
915
+ var alphabet, c, caseChanged, e, i, isNum, len, str, x = this;
916
+ if (!(x instanceof BigNumber2)) return new BigNumber2(v, b);
917
+ if (b == null) {
918
+ if (v && v._isBigNumber === true) {
919
+ x.s = v.s;
920
+ if (!v.c || v.e > MAX_EXP) {
921
+ x.c = x.e = null;
922
+ } else if (v.e < MIN_EXP) {
923
+ x.c = [x.e = 0];
924
+ } else {
925
+ x.e = v.e;
926
+ x.c = v.c.slice();
927
+ }
928
+ return;
929
+ }
930
+ if ((isNum = typeof v == "number") && v * 0 == 0) {
931
+ x.s = 1 / v < 0 ? (v = -v, -1) : 1;
932
+ if (v === ~~v) {
933
+ for (e = 0, i = v; i >= 10; i /= 10, e++) ;
934
+ if (e > MAX_EXP) {
935
+ x.c = x.e = null;
936
+ } else {
937
+ x.e = e;
938
+ x.c = [v];
939
+ }
940
+ return;
941
+ }
942
+ str = String(v);
943
+ } else {
944
+ if (!isNumeric.test(str = String(v))) return parseNumeric(x, str, isNum);
945
+ x.s = str.charCodeAt(0) == 45 ? (str = str.slice(1), -1) : 1;
946
+ }
947
+ if ((e = str.indexOf(".")) > -1) str = str.replace(".", "");
948
+ if ((i = str.search(/e/i)) > 0) {
949
+ if (e < 0) e = i;
950
+ e += +str.slice(i + 1);
951
+ str = str.substring(0, i);
952
+ } else if (e < 0) {
953
+ e = str.length;
954
+ }
955
+ } else {
956
+ intCheck(b, 2, ALPHABET.length, "Base");
957
+ if (b == 10 && alphabetHasNormalDecimalDigits) {
958
+ x = new BigNumber2(v);
959
+ return round(x, DECIMAL_PLACES + x.e + 1, ROUNDING_MODE);
960
+ }
961
+ str = String(v);
962
+ if (isNum = typeof v == "number") {
963
+ if (v * 0 != 0) return parseNumeric(x, str, isNum, b);
964
+ x.s = 1 / v < 0 ? (str = str.slice(1), -1) : 1;
965
+ if (BigNumber2.DEBUG && str.replace(/^0\.0*|\./, "").length > 15) {
966
+ throw Error(tooManyDigits + v);
967
+ }
968
+ } else {
969
+ x.s = str.charCodeAt(0) === 45 ? (str = str.slice(1), -1) : 1;
970
+ }
971
+ alphabet = ALPHABET.slice(0, b);
972
+ e = i = 0;
973
+ for (len = str.length; i < len; i++) {
974
+ if (alphabet.indexOf(c = str.charAt(i)) < 0) {
975
+ if (c == ".") {
976
+ if (i > e) {
977
+ e = len;
978
+ continue;
979
+ }
980
+ } else if (!caseChanged) {
981
+ if (str == str.toUpperCase() && (str = str.toLowerCase()) || str == str.toLowerCase() && (str = str.toUpperCase())) {
982
+ caseChanged = true;
983
+ i = -1;
984
+ e = 0;
985
+ continue;
986
+ }
987
+ }
988
+ return parseNumeric(x, String(v), isNum, b);
989
+ }
990
+ }
991
+ isNum = false;
992
+ str = convertBase(str, b, 10, x.s);
993
+ if ((e = str.indexOf(".")) > -1) str = str.replace(".", "");
994
+ else e = str.length;
995
+ }
996
+ for (i = 0; str.charCodeAt(i) === 48; i++) ;
997
+ for (len = str.length; str.charCodeAt(--len) === 48; ) ;
998
+ if (str = str.slice(i, ++len)) {
999
+ len -= i;
1000
+ if (isNum && BigNumber2.DEBUG && len > 15 && (v > MAX_SAFE_INTEGER || v !== mathfloor(v))) {
1001
+ throw Error(tooManyDigits + x.s * v);
1002
+ }
1003
+ if ((e = e - i - 1) > MAX_EXP) {
1004
+ x.c = x.e = null;
1005
+ } else if (e < MIN_EXP) {
1006
+ x.c = [x.e = 0];
1007
+ } else {
1008
+ x.e = e;
1009
+ x.c = [];
1010
+ i = (e + 1) % LOG_BASE;
1011
+ if (e < 0) i += LOG_BASE;
1012
+ if (i < len) {
1013
+ if (i) x.c.push(+str.slice(0, i));
1014
+ for (len -= LOG_BASE; i < len; ) {
1015
+ x.c.push(+str.slice(i, i += LOG_BASE));
1016
+ }
1017
+ i = LOG_BASE - (str = str.slice(i)).length;
1018
+ } else {
1019
+ i -= len;
1020
+ }
1021
+ for (; i--; str += "0") ;
1022
+ x.c.push(+str);
1023
+ }
1024
+ } else {
1025
+ x.c = [x.e = 0];
1026
+ }
1027
+ }
1028
+ BigNumber2.clone = clone;
1029
+ BigNumber2.ROUND_UP = 0;
1030
+ BigNumber2.ROUND_DOWN = 1;
1031
+ BigNumber2.ROUND_CEIL = 2;
1032
+ BigNumber2.ROUND_FLOOR = 3;
1033
+ BigNumber2.ROUND_HALF_UP = 4;
1034
+ BigNumber2.ROUND_HALF_DOWN = 5;
1035
+ BigNumber2.ROUND_HALF_EVEN = 6;
1036
+ BigNumber2.ROUND_HALF_CEIL = 7;
1037
+ BigNumber2.ROUND_HALF_FLOOR = 8;
1038
+ BigNumber2.EUCLID = 9;
1039
+ BigNumber2.config = BigNumber2.set = function(obj) {
1040
+ var p, v;
1041
+ if (obj != null) {
1042
+ if (typeof obj == "object") {
1043
+ if (obj.hasOwnProperty(p = "DECIMAL_PLACES")) {
1044
+ v = obj[p];
1045
+ intCheck(v, 0, MAX, p);
1046
+ DECIMAL_PLACES = v;
1047
+ }
1048
+ if (obj.hasOwnProperty(p = "ROUNDING_MODE")) {
1049
+ v = obj[p];
1050
+ intCheck(v, 0, 8, p);
1051
+ ROUNDING_MODE = v;
1052
+ }
1053
+ if (obj.hasOwnProperty(p = "EXPONENTIAL_AT")) {
1054
+ v = obj[p];
1055
+ if (v && v.pop) {
1056
+ intCheck(v[0], -MAX, 0, p);
1057
+ intCheck(v[1], 0, MAX, p);
1058
+ TO_EXP_NEG = v[0];
1059
+ TO_EXP_POS = v[1];
1060
+ } else {
1061
+ intCheck(v, -MAX, MAX, p);
1062
+ TO_EXP_NEG = -(TO_EXP_POS = v < 0 ? -v : v);
1063
+ }
1064
+ }
1065
+ if (obj.hasOwnProperty(p = "RANGE")) {
1066
+ v = obj[p];
1067
+ if (v && v.pop) {
1068
+ intCheck(v[0], -MAX, -1, p);
1069
+ intCheck(v[1], 1, MAX, p);
1070
+ MIN_EXP = v[0];
1071
+ MAX_EXP = v[1];
1072
+ } else {
1073
+ intCheck(v, -MAX, MAX, p);
1074
+ if (v) {
1075
+ MIN_EXP = -(MAX_EXP = v < 0 ? -v : v);
1076
+ } else {
1077
+ throw Error(bignumberError + p + " cannot be zero: " + v);
1078
+ }
1079
+ }
1080
+ }
1081
+ if (obj.hasOwnProperty(p = "CRYPTO")) {
1082
+ v = obj[p];
1083
+ if (v === !!v) {
1084
+ if (v) {
1085
+ if (typeof crypto != "undefined" && crypto && (crypto.getRandomValues || crypto.randomBytes)) {
1086
+ CRYPTO = v;
1087
+ } else {
1088
+ CRYPTO = !v;
1089
+ throw Error(bignumberError + "crypto unavailable");
1090
+ }
1091
+ } else {
1092
+ CRYPTO = v;
1093
+ }
1094
+ } else {
1095
+ throw Error(bignumberError + p + " not true or false: " + v);
1096
+ }
1097
+ }
1098
+ if (obj.hasOwnProperty(p = "MODULO_MODE")) {
1099
+ v = obj[p];
1100
+ intCheck(v, 0, 9, p);
1101
+ MODULO_MODE = v;
1102
+ }
1103
+ if (obj.hasOwnProperty(p = "POW_PRECISION")) {
1104
+ v = obj[p];
1105
+ intCheck(v, 0, MAX, p);
1106
+ POW_PRECISION = v;
1107
+ }
1108
+ if (obj.hasOwnProperty(p = "FORMAT")) {
1109
+ v = obj[p];
1110
+ if (typeof v == "object") FORMAT = v;
1111
+ else throw Error(bignumberError + p + " not an object: " + v);
1112
+ }
1113
+ if (obj.hasOwnProperty(p = "ALPHABET")) {
1114
+ v = obj[p];
1115
+ if (typeof v == "string" && !/^.?$|[+\-.\s]|(.).*\1/.test(v)) {
1116
+ alphabetHasNormalDecimalDigits = v.slice(0, 10) == "0123456789";
1117
+ ALPHABET = v;
1118
+ } else {
1119
+ throw Error(bignumberError + p + " invalid: " + v);
1120
+ }
1121
+ }
1122
+ } else {
1123
+ throw Error(bignumberError + "Object expected: " + obj);
1124
+ }
1125
+ }
1126
+ return {
1127
+ DECIMAL_PLACES,
1128
+ ROUNDING_MODE,
1129
+ EXPONENTIAL_AT: [TO_EXP_NEG, TO_EXP_POS],
1130
+ RANGE: [MIN_EXP, MAX_EXP],
1131
+ CRYPTO,
1132
+ MODULO_MODE,
1133
+ POW_PRECISION,
1134
+ FORMAT,
1135
+ ALPHABET
1136
+ };
1137
+ };
1138
+ BigNumber2.isBigNumber = function(v) {
1139
+ if (!v || v._isBigNumber !== true) return false;
1140
+ if (!BigNumber2.DEBUG) return true;
1141
+ var i, n, c = v.c, e = v.e, s = v.s;
1142
+ out: if ({}.toString.call(c) == "[object Array]") {
1143
+ if ((s === 1 || s === -1) && e >= -MAX && e <= MAX && e === mathfloor(e)) {
1144
+ if (c[0] === 0) {
1145
+ if (e === 0 && c.length === 1) return true;
1146
+ break out;
1147
+ }
1148
+ i = (e + 1) % LOG_BASE;
1149
+ if (i < 1) i += LOG_BASE;
1150
+ if (String(c[0]).length == i) {
1151
+ for (i = 0; i < c.length; i++) {
1152
+ n = c[i];
1153
+ if (n < 0 || n >= BASE || n !== mathfloor(n)) break out;
1154
+ }
1155
+ if (n !== 0) return true;
1156
+ }
1157
+ }
1158
+ } else if (c === null && e === null && (s === null || s === 1 || s === -1)) {
1159
+ return true;
1160
+ }
1161
+ throw Error(bignumberError + "Invalid BigNumber: " + v);
1162
+ };
1163
+ BigNumber2.maximum = BigNumber2.max = function() {
1164
+ return maxOrMin(arguments, -1);
1165
+ };
1166
+ BigNumber2.minimum = BigNumber2.min = function() {
1167
+ return maxOrMin(arguments, 1);
1168
+ };
1169
+ BigNumber2.random = function() {
1170
+ var pow2_53 = 9007199254740992;
1171
+ var random53bitInt = Math.random() * pow2_53 & 2097151 ? function() {
1172
+ return mathfloor(Math.random() * pow2_53);
1173
+ } : function() {
1174
+ return (Math.random() * 1073741824 | 0) * 8388608 + (Math.random() * 8388608 | 0);
1175
+ };
1176
+ return function(dp) {
1177
+ var a, b, e, k, v, i = 0, c = [], rand = new BigNumber2(ONE);
1178
+ if (dp == null) dp = DECIMAL_PLACES;
1179
+ else intCheck(dp, 0, MAX);
1180
+ k = mathceil(dp / LOG_BASE);
1181
+ if (CRYPTO) {
1182
+ if (crypto.getRandomValues) {
1183
+ a = crypto.getRandomValues(new Uint32Array(k *= 2));
1184
+ for (; i < k; ) {
1185
+ v = a[i] * 131072 + (a[i + 1] >>> 11);
1186
+ if (v >= 9e15) {
1187
+ b = crypto.getRandomValues(new Uint32Array(2));
1188
+ a[i] = b[0];
1189
+ a[i + 1] = b[1];
1190
+ } else {
1191
+ c.push(v % 1e14);
1192
+ i += 2;
1193
+ }
1194
+ }
1195
+ i = k / 2;
1196
+ } else if (crypto.randomBytes) {
1197
+ a = crypto.randomBytes(k *= 7);
1198
+ for (; i < k; ) {
1199
+ v = (a[i] & 31) * 281474976710656 + a[i + 1] * 1099511627776 + a[i + 2] * 4294967296 + a[i + 3] * 16777216 + (a[i + 4] << 16) + (a[i + 5] << 8) + a[i + 6];
1200
+ if (v >= 9e15) {
1201
+ crypto.randomBytes(7).copy(a, i);
1202
+ } else {
1203
+ c.push(v % 1e14);
1204
+ i += 7;
1205
+ }
1206
+ }
1207
+ i = k / 7;
1208
+ } else {
1209
+ CRYPTO = false;
1210
+ throw Error(bignumberError + "crypto unavailable");
1211
+ }
1212
+ }
1213
+ if (!CRYPTO) {
1214
+ for (; i < k; ) {
1215
+ v = random53bitInt();
1216
+ if (v < 9e15) c[i++] = v % 1e14;
1217
+ }
1218
+ }
1219
+ k = c[--i];
1220
+ dp %= LOG_BASE;
1221
+ if (k && dp) {
1222
+ v = POWS_TEN[LOG_BASE - dp];
1223
+ c[i] = mathfloor(k / v) * v;
1224
+ }
1225
+ for (; c[i] === 0; c.pop(), i--) ;
1226
+ if (i < 0) {
1227
+ c = [e = 0];
1228
+ } else {
1229
+ for (e = -1; c[0] === 0; c.splice(0, 1), e -= LOG_BASE) ;
1230
+ for (i = 1, v = c[0]; v >= 10; v /= 10, i++) ;
1231
+ if (i < LOG_BASE) e -= LOG_BASE - i;
1232
+ }
1233
+ rand.e = e;
1234
+ rand.c = c;
1235
+ return rand;
1236
+ };
1237
+ }();
1238
+ BigNumber2.sum = function() {
1239
+ var i = 1, args = arguments, sum = new BigNumber2(args[0]);
1240
+ for (; i < args.length; ) sum = sum.plus(args[i++]);
1241
+ return sum;
1242
+ };
1243
+ convertBase = /* @__PURE__ */ function() {
1244
+ var decimal = "0123456789";
1245
+ function toBaseOut(str, baseIn, baseOut, alphabet) {
1246
+ var j, arr = [0], arrL, i = 0, len = str.length;
1247
+ for (; i < len; ) {
1248
+ for (arrL = arr.length; arrL--; arr[arrL] *= baseIn) ;
1249
+ arr[0] += alphabet.indexOf(str.charAt(i++));
1250
+ for (j = 0; j < arr.length; j++) {
1251
+ if (arr[j] > baseOut - 1) {
1252
+ if (arr[j + 1] == null) arr[j + 1] = 0;
1253
+ arr[j + 1] += arr[j] / baseOut | 0;
1254
+ arr[j] %= baseOut;
1255
+ }
1256
+ }
1257
+ }
1258
+ return arr.reverse();
1259
+ }
1260
+ return function(str, baseIn, baseOut, sign, callerIsToString) {
1261
+ var alphabet, d, e, k, r, x, xc, y, i = str.indexOf("."), dp = DECIMAL_PLACES, rm = ROUNDING_MODE;
1262
+ if (i >= 0) {
1263
+ k = POW_PRECISION;
1264
+ POW_PRECISION = 0;
1265
+ str = str.replace(".", "");
1266
+ y = new BigNumber2(baseIn);
1267
+ x = y.pow(str.length - i);
1268
+ POW_PRECISION = k;
1269
+ y.c = toBaseOut(
1270
+ toFixedPoint(coeffToString(x.c), x.e, "0"),
1271
+ 10,
1272
+ baseOut,
1273
+ decimal
1274
+ );
1275
+ y.e = y.c.length;
1276
+ }
1277
+ xc = toBaseOut(str, baseIn, baseOut, callerIsToString ? (alphabet = ALPHABET, decimal) : (alphabet = decimal, ALPHABET));
1278
+ e = k = xc.length;
1279
+ for (; xc[--k] == 0; xc.pop()) ;
1280
+ if (!xc[0]) return alphabet.charAt(0);
1281
+ if (i < 0) {
1282
+ --e;
1283
+ } else {
1284
+ x.c = xc;
1285
+ x.e = e;
1286
+ x.s = sign;
1287
+ x = div(x, y, dp, rm, baseOut);
1288
+ xc = x.c;
1289
+ r = x.r;
1290
+ e = x.e;
1291
+ }
1292
+ d = e + dp + 1;
1293
+ i = xc[d];
1294
+ k = baseOut / 2;
1295
+ r = r || d < 0 || xc[d + 1] != null;
1296
+ r = rm < 4 ? (i != null || r) && (rm == 0 || rm == (x.s < 0 ? 3 : 2)) : i > k || i == k && (rm == 4 || r || rm == 6 && xc[d - 1] & 1 || rm == (x.s < 0 ? 8 : 7));
1297
+ if (d < 1 || !xc[0]) {
1298
+ str = r ? toFixedPoint(alphabet.charAt(1), -dp, alphabet.charAt(0)) : alphabet.charAt(0);
1299
+ } else {
1300
+ xc.length = d;
1301
+ if (r) {
1302
+ for (--baseOut; ++xc[--d] > baseOut; ) {
1303
+ xc[d] = 0;
1304
+ if (!d) {
1305
+ ++e;
1306
+ xc = [1].concat(xc);
1307
+ }
1308
+ }
1309
+ }
1310
+ for (k = xc.length; !xc[--k]; ) ;
1311
+ for (i = 0, str = ""; i <= k; str += alphabet.charAt(xc[i++])) ;
1312
+ str = toFixedPoint(str, e, alphabet.charAt(0));
1313
+ }
1314
+ return str;
1315
+ };
1316
+ }();
1317
+ div = /* @__PURE__ */ function() {
1318
+ function multiply(x, k, base) {
1319
+ var m, temp, xlo, xhi, carry = 0, i = x.length, klo = k % SQRT_BASE, khi = k / SQRT_BASE | 0;
1320
+ for (x = x.slice(); i--; ) {
1321
+ xlo = x[i] % SQRT_BASE;
1322
+ xhi = x[i] / SQRT_BASE | 0;
1323
+ m = khi * xlo + xhi * klo;
1324
+ temp = klo * xlo + m % SQRT_BASE * SQRT_BASE + carry;
1325
+ carry = (temp / base | 0) + (m / SQRT_BASE | 0) + khi * xhi;
1326
+ x[i] = temp % base;
1327
+ }
1328
+ if (carry) x = [carry].concat(x);
1329
+ return x;
1330
+ }
1331
+ function compare2(a, b, aL, bL) {
1332
+ var i, cmp;
1333
+ if (aL != bL) {
1334
+ cmp = aL > bL ? 1 : -1;
1335
+ } else {
1336
+ for (i = cmp = 0; i < aL; i++) {
1337
+ if (a[i] != b[i]) {
1338
+ cmp = a[i] > b[i] ? 1 : -1;
1339
+ break;
1340
+ }
1341
+ }
1342
+ }
1343
+ return cmp;
1344
+ }
1345
+ function subtract(a, b, aL, base) {
1346
+ var i = 0;
1347
+ for (; aL--; ) {
1348
+ a[aL] -= i;
1349
+ i = a[aL] < b[aL] ? 1 : 0;
1350
+ a[aL] = i * base + a[aL] - b[aL];
1351
+ }
1352
+ for (; !a[0] && a.length > 1; a.splice(0, 1)) ;
1353
+ }
1354
+ return function(x, y, dp, rm, base) {
1355
+ var cmp, e, i, more, n, prod, prodL, q, qc, rem, remL, rem0, xi, xL, yc0, yL, yz, s = x.s == y.s ? 1 : -1, xc = x.c, yc = y.c;
1356
+ if (!xc || !xc[0] || !yc || !yc[0]) {
1357
+ return new BigNumber2(
1358
+ // Return NaN if either NaN, or both Infinity or 0.
1359
+ !x.s || !y.s || (xc ? yc && xc[0] == yc[0] : !yc) ? NaN : (
1360
+ // Return ±0 if x is ±0 or y is ±Infinity, or return ±Infinity as y is ±0.
1361
+ xc && xc[0] == 0 || !yc ? s * 0 : s / 0
1362
+ )
1363
+ );
1364
+ }
1365
+ q = new BigNumber2(s);
1366
+ qc = q.c = [];
1367
+ e = x.e - y.e;
1368
+ s = dp + e + 1;
1369
+ if (!base) {
1370
+ base = BASE;
1371
+ e = bitFloor(x.e / LOG_BASE) - bitFloor(y.e / LOG_BASE);
1372
+ s = s / LOG_BASE | 0;
1373
+ }
1374
+ for (i = 0; yc[i] == (xc[i] || 0); i++) ;
1375
+ if (yc[i] > (xc[i] || 0)) e--;
1376
+ if (s < 0) {
1377
+ qc.push(1);
1378
+ more = true;
1379
+ } else {
1380
+ xL = xc.length;
1381
+ yL = yc.length;
1382
+ i = 0;
1383
+ s += 2;
1384
+ n = mathfloor(base / (yc[0] + 1));
1385
+ if (n > 1) {
1386
+ yc = multiply(yc, n, base);
1387
+ xc = multiply(xc, n, base);
1388
+ yL = yc.length;
1389
+ xL = xc.length;
1390
+ }
1391
+ xi = yL;
1392
+ rem = xc.slice(0, yL);
1393
+ remL = rem.length;
1394
+ for (; remL < yL; rem[remL++] = 0) ;
1395
+ yz = yc.slice();
1396
+ yz = [0].concat(yz);
1397
+ yc0 = yc[0];
1398
+ if (yc[1] >= base / 2) yc0++;
1399
+ do {
1400
+ n = 0;
1401
+ cmp = compare2(yc, rem, yL, remL);
1402
+ if (cmp < 0) {
1403
+ rem0 = rem[0];
1404
+ if (yL != remL) rem0 = rem0 * base + (rem[1] || 0);
1405
+ n = mathfloor(rem0 / yc0);
1406
+ if (n > 1) {
1407
+ if (n >= base) n = base - 1;
1408
+ prod = multiply(yc, n, base);
1409
+ prodL = prod.length;
1410
+ remL = rem.length;
1411
+ while (compare2(prod, rem, prodL, remL) == 1) {
1412
+ n--;
1413
+ subtract(prod, yL < prodL ? yz : yc, prodL, base);
1414
+ prodL = prod.length;
1415
+ cmp = 1;
1416
+ }
1417
+ } else {
1418
+ if (n == 0) {
1419
+ cmp = n = 1;
1420
+ }
1421
+ prod = yc.slice();
1422
+ prodL = prod.length;
1423
+ }
1424
+ if (prodL < remL) prod = [0].concat(prod);
1425
+ subtract(rem, prod, remL, base);
1426
+ remL = rem.length;
1427
+ if (cmp == -1) {
1428
+ while (compare2(yc, rem, yL, remL) < 1) {
1429
+ n++;
1430
+ subtract(rem, yL < remL ? yz : yc, remL, base);
1431
+ remL = rem.length;
1432
+ }
1433
+ }
1434
+ } else if (cmp === 0) {
1435
+ n++;
1436
+ rem = [0];
1437
+ }
1438
+ qc[i++] = n;
1439
+ if (rem[0]) {
1440
+ rem[remL++] = xc[xi] || 0;
1441
+ } else {
1442
+ rem = [xc[xi]];
1443
+ remL = 1;
1444
+ }
1445
+ } while ((xi++ < xL || rem[0] != null) && s--);
1446
+ more = rem[0] != null;
1447
+ if (!qc[0]) qc.splice(0, 1);
1448
+ }
1449
+ if (base == BASE) {
1450
+ for (i = 1, s = qc[0]; s >= 10; s /= 10, i++) ;
1451
+ round(q, dp + (q.e = i + e * LOG_BASE - 1) + 1, rm, more);
1452
+ } else {
1453
+ q.e = e;
1454
+ q.r = +more;
1455
+ }
1456
+ return q;
1457
+ };
1458
+ }();
1459
+ function format(n, i, rm, id) {
1460
+ var c0, e, ne, len, str;
1461
+ if (rm == null) rm = ROUNDING_MODE;
1462
+ else intCheck(rm, 0, 8);
1463
+ if (!n.c) return n.toString();
1464
+ c0 = n.c[0];
1465
+ ne = n.e;
1466
+ if (i == null) {
1467
+ str = coeffToString(n.c);
1468
+ str = id == 1 || id == 2 && (ne <= TO_EXP_NEG || ne >= TO_EXP_POS) ? toExponential(str, ne) : toFixedPoint(str, ne, "0");
1469
+ } else {
1470
+ n = round(new BigNumber2(n), i, rm);
1471
+ e = n.e;
1472
+ str = coeffToString(n.c);
1473
+ len = str.length;
1474
+ if (id == 1 || id == 2 && (i <= e || e <= TO_EXP_NEG)) {
1475
+ for (; len < i; str += "0", len++) ;
1476
+ str = toExponential(str, e);
1477
+ } else {
1478
+ i -= ne;
1479
+ str = toFixedPoint(str, e, "0");
1480
+ if (e + 1 > len) {
1481
+ if (--i > 0) for (str += "."; i--; str += "0") ;
1482
+ } else {
1483
+ i += e - len;
1484
+ if (i > 0) {
1485
+ if (e + 1 == len) str += ".";
1486
+ for (; i--; str += "0") ;
1487
+ }
1488
+ }
1489
+ }
1490
+ }
1491
+ return n.s < 0 && c0 ? "-" + str : str;
1492
+ }
1493
+ function maxOrMin(args, n) {
1494
+ var k, y, i = 1, x = new BigNumber2(args[0]);
1495
+ for (; i < args.length; i++) {
1496
+ y = new BigNumber2(args[i]);
1497
+ if (!y.s || (k = compare(x, y)) === n || k === 0 && x.s === n) {
1498
+ x = y;
1499
+ }
1500
+ }
1501
+ return x;
1502
+ }
1503
+ function normalise(n, c, e) {
1504
+ var i = 1, j = c.length;
1505
+ for (; !c[--j]; c.pop()) ;
1506
+ for (j = c[0]; j >= 10; j /= 10, i++) ;
1507
+ if ((e = i + e * LOG_BASE - 1) > MAX_EXP) {
1508
+ n.c = n.e = null;
1509
+ } else if (e < MIN_EXP) {
1510
+ n.c = [n.e = 0];
1511
+ } else {
1512
+ n.e = e;
1513
+ n.c = c;
1514
+ }
1515
+ return n;
1516
+ }
1517
+ parseNumeric = /* @__PURE__ */ function() {
1518
+ var basePrefix = /^(-?)0([xbo])(?=\w[\w.]*$)/i, dotAfter = /^([^.]+)\.$/, dotBefore = /^\.([^.]+)$/, isInfinityOrNaN = /^-?(Infinity|NaN)$/, whitespaceOrPlus = /^\s*\+(?=[\w.])|^\s+|\s+$/g;
1519
+ return function(x, str, isNum, b) {
1520
+ var base, s = isNum ? str : str.replace(whitespaceOrPlus, "");
1521
+ if (isInfinityOrNaN.test(s)) {
1522
+ x.s = isNaN(s) ? null : s < 0 ? -1 : 1;
1523
+ } else {
1524
+ if (!isNum) {
1525
+ s = s.replace(basePrefix, function(m, p1, p2) {
1526
+ base = (p2 = p2.toLowerCase()) == "x" ? 16 : p2 == "b" ? 2 : 8;
1527
+ return !b || b == base ? p1 : m;
1528
+ });
1529
+ if (b) {
1530
+ base = b;
1531
+ s = s.replace(dotAfter, "$1").replace(dotBefore, "0.$1");
1532
+ }
1533
+ if (str != s) return new BigNumber2(s, base);
1534
+ }
1535
+ if (BigNumber2.DEBUG) {
1536
+ throw Error(bignumberError + "Not a" + (b ? " base " + b : "") + " number: " + str);
1537
+ }
1538
+ x.s = null;
1539
+ }
1540
+ x.c = x.e = null;
1541
+ };
1542
+ }();
1543
+ function round(x, sd, rm, r) {
1544
+ var d, i, j, k, n, ni, rd, xc = x.c, pows10 = POWS_TEN;
1545
+ if (xc) {
1546
+ out: {
1547
+ for (d = 1, k = xc[0]; k >= 10; k /= 10, d++) ;
1548
+ i = sd - d;
1549
+ if (i < 0) {
1550
+ i += LOG_BASE;
1551
+ j = sd;
1552
+ n = xc[ni = 0];
1553
+ rd = mathfloor(n / pows10[d - j - 1] % 10);
1554
+ } else {
1555
+ ni = mathceil((i + 1) / LOG_BASE);
1556
+ if (ni >= xc.length) {
1557
+ if (r) {
1558
+ for (; xc.length <= ni; xc.push(0)) ;
1559
+ n = rd = 0;
1560
+ d = 1;
1561
+ i %= LOG_BASE;
1562
+ j = i - LOG_BASE + 1;
1563
+ } else {
1564
+ break out;
1565
+ }
1566
+ } else {
1567
+ n = k = xc[ni];
1568
+ for (d = 1; k >= 10; k /= 10, d++) ;
1569
+ i %= LOG_BASE;
1570
+ j = i - LOG_BASE + d;
1571
+ rd = j < 0 ? 0 : mathfloor(n / pows10[d - j - 1] % 10);
1572
+ }
1573
+ }
1574
+ r = r || sd < 0 || // Are there any non-zero digits after the rounding digit?
1575
+ // The expression n % pows10[d - j - 1] returns all digits of n to the right
1576
+ // of the digit at j, e.g. if n is 908714 and j is 2, the expression gives 714.
1577
+ xc[ni + 1] != null || (j < 0 ? n : n % pows10[d - j - 1]);
1578
+ r = rm < 4 ? (rd || r) && (rm == 0 || rm == (x.s < 0 ? 3 : 2)) : rd > 5 || rd == 5 && (rm == 4 || r || rm == 6 && // Check whether the digit to the left of the rounding digit is odd.
1579
+ (i > 0 ? j > 0 ? n / pows10[d - j] : 0 : xc[ni - 1]) % 10 & 1 || rm == (x.s < 0 ? 8 : 7));
1580
+ if (sd < 1 || !xc[0]) {
1581
+ xc.length = 0;
1582
+ if (r) {
1583
+ sd -= x.e + 1;
1584
+ xc[0] = pows10[(LOG_BASE - sd % LOG_BASE) % LOG_BASE];
1585
+ x.e = -sd || 0;
1586
+ } else {
1587
+ xc[0] = x.e = 0;
1588
+ }
1589
+ return x;
1590
+ }
1591
+ if (i == 0) {
1592
+ xc.length = ni;
1593
+ k = 1;
1594
+ ni--;
1595
+ } else {
1596
+ xc.length = ni + 1;
1597
+ k = pows10[LOG_BASE - i];
1598
+ xc[ni] = j > 0 ? mathfloor(n / pows10[d - j] % pows10[j]) * k : 0;
1599
+ }
1600
+ if (r) {
1601
+ for (; ; ) {
1602
+ if (ni == 0) {
1603
+ for (i = 1, j = xc[0]; j >= 10; j /= 10, i++) ;
1604
+ j = xc[0] += k;
1605
+ for (k = 1; j >= 10; j /= 10, k++) ;
1606
+ if (i != k) {
1607
+ x.e++;
1608
+ if (xc[0] == BASE) xc[0] = 1;
1609
+ }
1610
+ break;
1611
+ } else {
1612
+ xc[ni] += k;
1613
+ if (xc[ni] != BASE) break;
1614
+ xc[ni--] = 0;
1615
+ k = 1;
1616
+ }
1617
+ }
1618
+ }
1619
+ for (i = xc.length; xc[--i] === 0; xc.pop()) ;
1620
+ }
1621
+ if (x.e > MAX_EXP) {
1622
+ x.c = x.e = null;
1623
+ } else if (x.e < MIN_EXP) {
1624
+ x.c = [x.e = 0];
1625
+ }
1626
+ }
1627
+ return x;
1628
+ }
1629
+ function valueOf(n) {
1630
+ var str, e = n.e;
1631
+ if (e === null) return n.toString();
1632
+ str = coeffToString(n.c);
1633
+ str = e <= TO_EXP_NEG || e >= TO_EXP_POS ? toExponential(str, e) : toFixedPoint(str, e, "0");
1634
+ return n.s < 0 ? "-" + str : str;
1635
+ }
1636
+ P.absoluteValue = P.abs = function() {
1637
+ var x = new BigNumber2(this);
1638
+ if (x.s < 0) x.s = 1;
1639
+ return x;
1640
+ };
1641
+ P.comparedTo = function(y, b) {
1642
+ return compare(this, new BigNumber2(y, b));
1643
+ };
1644
+ P.decimalPlaces = P.dp = function(dp, rm) {
1645
+ var c, n, v, x = this;
1646
+ if (dp != null) {
1647
+ intCheck(dp, 0, MAX);
1648
+ if (rm == null) rm = ROUNDING_MODE;
1649
+ else intCheck(rm, 0, 8);
1650
+ return round(new BigNumber2(x), dp + x.e + 1, rm);
1651
+ }
1652
+ if (!(c = x.c)) return null;
1653
+ n = ((v = c.length - 1) - bitFloor(this.e / LOG_BASE)) * LOG_BASE;
1654
+ if (v = c[v]) for (; v % 10 == 0; v /= 10, n--) ;
1655
+ if (n < 0) n = 0;
1656
+ return n;
1657
+ };
1658
+ P.dividedBy = P.div = function(y, b) {
1659
+ return div(this, new BigNumber2(y, b), DECIMAL_PLACES, ROUNDING_MODE);
1660
+ };
1661
+ P.dividedToIntegerBy = P.idiv = function(y, b) {
1662
+ return div(this, new BigNumber2(y, b), 0, 1);
1663
+ };
1664
+ P.exponentiatedBy = P.pow = function(n, m) {
1665
+ var half, isModExp, i, k, more, nIsBig, nIsNeg, nIsOdd, y, x = this;
1666
+ n = new BigNumber2(n);
1667
+ if (n.c && !n.isInteger()) {
1668
+ throw Error(bignumberError + "Exponent not an integer: " + valueOf(n));
1669
+ }
1670
+ if (m != null) m = new BigNumber2(m);
1671
+ nIsBig = n.e > 14;
1672
+ if (!x.c || !x.c[0] || x.c[0] == 1 && !x.e && x.c.length == 1 || !n.c || !n.c[0]) {
1673
+ y = new BigNumber2(Math.pow(+valueOf(x), nIsBig ? n.s * (2 - isOdd(n)) : +valueOf(n)));
1674
+ return m ? y.mod(m) : y;
1675
+ }
1676
+ nIsNeg = n.s < 0;
1677
+ if (m) {
1678
+ if (m.c ? !m.c[0] : !m.s) return new BigNumber2(NaN);
1679
+ isModExp = !nIsNeg && x.isInteger() && m.isInteger();
1680
+ if (isModExp) x = x.mod(m);
1681
+ } else if (n.e > 9 && (x.e > 0 || x.e < -1 || (x.e == 0 ? x.c[0] > 1 || nIsBig && x.c[1] >= 24e7 : x.c[0] < 8e13 || nIsBig && x.c[0] <= 9999975e7))) {
1682
+ k = x.s < 0 && isOdd(n) ? -0 : 0;
1683
+ if (x.e > -1) k = 1 / k;
1684
+ return new BigNumber2(nIsNeg ? 1 / k : k);
1685
+ } else if (POW_PRECISION) {
1686
+ k = mathceil(POW_PRECISION / LOG_BASE + 2);
1687
+ }
1688
+ if (nIsBig) {
1689
+ half = new BigNumber2(0.5);
1690
+ if (nIsNeg) n.s = 1;
1691
+ nIsOdd = isOdd(n);
1692
+ } else {
1693
+ i = Math.abs(+valueOf(n));
1694
+ nIsOdd = i % 2;
1695
+ }
1696
+ y = new BigNumber2(ONE);
1697
+ for (; ; ) {
1698
+ if (nIsOdd) {
1699
+ y = y.times(x);
1700
+ if (!y.c) break;
1701
+ if (k) {
1702
+ if (y.c.length > k) y.c.length = k;
1703
+ } else if (isModExp) {
1704
+ y = y.mod(m);
1705
+ }
1706
+ }
1707
+ if (i) {
1708
+ i = mathfloor(i / 2);
1709
+ if (i === 0) break;
1710
+ nIsOdd = i % 2;
1711
+ } else {
1712
+ n = n.times(half);
1713
+ round(n, n.e + 1, 1);
1714
+ if (n.e > 14) {
1715
+ nIsOdd = isOdd(n);
1716
+ } else {
1717
+ i = +valueOf(n);
1718
+ if (i === 0) break;
1719
+ nIsOdd = i % 2;
1720
+ }
1721
+ }
1722
+ x = x.times(x);
1723
+ if (k) {
1724
+ if (x.c && x.c.length > k) x.c.length = k;
1725
+ } else if (isModExp) {
1726
+ x = x.mod(m);
1727
+ }
1728
+ }
1729
+ if (isModExp) return y;
1730
+ if (nIsNeg) y = ONE.div(y);
1731
+ return m ? y.mod(m) : k ? round(y, POW_PRECISION, ROUNDING_MODE, more) : y;
1732
+ };
1733
+ P.integerValue = function(rm) {
1734
+ var n = new BigNumber2(this);
1735
+ if (rm == null) rm = ROUNDING_MODE;
1736
+ else intCheck(rm, 0, 8);
1737
+ return round(n, n.e + 1, rm);
1738
+ };
1739
+ P.isEqualTo = P.eq = function(y, b) {
1740
+ return compare(this, new BigNumber2(y, b)) === 0;
1741
+ };
1742
+ P.isFinite = function() {
1743
+ return !!this.c;
1744
+ };
1745
+ P.isGreaterThan = P.gt = function(y, b) {
1746
+ return compare(this, new BigNumber2(y, b)) > 0;
1747
+ };
1748
+ P.isGreaterThanOrEqualTo = P.gte = function(y, b) {
1749
+ return (b = compare(this, new BigNumber2(y, b))) === 1 || b === 0;
1750
+ };
1751
+ P.isInteger = function() {
1752
+ return !!this.c && bitFloor(this.e / LOG_BASE) > this.c.length - 2;
1753
+ };
1754
+ P.isLessThan = P.lt = function(y, b) {
1755
+ return compare(this, new BigNumber2(y, b)) < 0;
1756
+ };
1757
+ P.isLessThanOrEqualTo = P.lte = function(y, b) {
1758
+ return (b = compare(this, new BigNumber2(y, b))) === -1 || b === 0;
1759
+ };
1760
+ P.isNaN = function() {
1761
+ return !this.s;
1762
+ };
1763
+ P.isNegative = function() {
1764
+ return this.s < 0;
1765
+ };
1766
+ P.isPositive = function() {
1767
+ return this.s > 0;
1768
+ };
1769
+ P.isZero = function() {
1770
+ return !!this.c && this.c[0] == 0;
1771
+ };
1772
+ P.minus = function(y, b) {
1773
+ var i, j, t, xLTy, x = this, a = x.s;
1774
+ y = new BigNumber2(y, b);
1775
+ b = y.s;
1776
+ if (!a || !b) return new BigNumber2(NaN);
1777
+ if (a != b) {
1778
+ y.s = -b;
1779
+ return x.plus(y);
1780
+ }
1781
+ var xe = x.e / LOG_BASE, ye = y.e / LOG_BASE, xc = x.c, yc = y.c;
1782
+ if (!xe || !ye) {
1783
+ if (!xc || !yc) return xc ? (y.s = -b, y) : new BigNumber2(yc ? x : NaN);
1784
+ if (!xc[0] || !yc[0]) {
1785
+ return yc[0] ? (y.s = -b, y) : new BigNumber2(xc[0] ? x : (
1786
+ // IEEE 754 (2008) 6.3: n - n = -0 when rounding to -Infinity
1787
+ ROUNDING_MODE == 3 ? -0 : 0
1788
+ ));
1789
+ }
1790
+ }
1791
+ xe = bitFloor(xe);
1792
+ ye = bitFloor(ye);
1793
+ xc = xc.slice();
1794
+ if (a = xe - ye) {
1795
+ if (xLTy = a < 0) {
1796
+ a = -a;
1797
+ t = xc;
1798
+ } else {
1799
+ ye = xe;
1800
+ t = yc;
1801
+ }
1802
+ t.reverse();
1803
+ for (b = a; b--; t.push(0)) ;
1804
+ t.reverse();
1805
+ } else {
1806
+ j = (xLTy = (a = xc.length) < (b = yc.length)) ? a : b;
1807
+ for (a = b = 0; b < j; b++) {
1808
+ if (xc[b] != yc[b]) {
1809
+ xLTy = xc[b] < yc[b];
1810
+ break;
1811
+ }
1812
+ }
1813
+ }
1814
+ if (xLTy) {
1815
+ t = xc;
1816
+ xc = yc;
1817
+ yc = t;
1818
+ y.s = -y.s;
1819
+ }
1820
+ b = (j = yc.length) - (i = xc.length);
1821
+ if (b > 0) for (; b--; xc[i++] = 0) ;
1822
+ b = BASE - 1;
1823
+ for (; j > a; ) {
1824
+ if (xc[--j] < yc[j]) {
1825
+ for (i = j; i && !xc[--i]; xc[i] = b) ;
1826
+ --xc[i];
1827
+ xc[j] += BASE;
1828
+ }
1829
+ xc[j] -= yc[j];
1830
+ }
1831
+ for (; xc[0] == 0; xc.splice(0, 1), --ye) ;
1832
+ if (!xc[0]) {
1833
+ y.s = ROUNDING_MODE == 3 ? -1 : 1;
1834
+ y.c = [y.e = 0];
1835
+ return y;
1836
+ }
1837
+ return normalise(y, xc, ye);
1838
+ };
1839
+ P.modulo = P.mod = function(y, b) {
1840
+ var q, s, x = this;
1841
+ y = new BigNumber2(y, b);
1842
+ if (!x.c || !y.s || y.c && !y.c[0]) {
1843
+ return new BigNumber2(NaN);
1844
+ } else if (!y.c || x.c && !x.c[0]) {
1845
+ return new BigNumber2(x);
1846
+ }
1847
+ if (MODULO_MODE == 9) {
1848
+ s = y.s;
1849
+ y.s = 1;
1850
+ q = div(x, y, 0, 3);
1851
+ y.s = s;
1852
+ q.s *= s;
1853
+ } else {
1854
+ q = div(x, y, 0, MODULO_MODE);
1855
+ }
1856
+ y = x.minus(q.times(y));
1857
+ if (!y.c[0] && MODULO_MODE == 1) y.s = x.s;
1858
+ return y;
1859
+ };
1860
+ P.multipliedBy = P.times = function(y, b) {
1861
+ var c, e, i, j, k, m, xcL, xlo, xhi, ycL, ylo, yhi, zc, base, sqrtBase, x = this, xc = x.c, yc = (y = new BigNumber2(y, b)).c;
1862
+ if (!xc || !yc || !xc[0] || !yc[0]) {
1863
+ if (!x.s || !y.s || xc && !xc[0] && !yc || yc && !yc[0] && !xc) {
1864
+ y.c = y.e = y.s = null;
1865
+ } else {
1866
+ y.s *= x.s;
1867
+ if (!xc || !yc) {
1868
+ y.c = y.e = null;
1869
+ } else {
1870
+ y.c = [0];
1871
+ y.e = 0;
1872
+ }
1873
+ }
1874
+ return y;
1875
+ }
1876
+ e = bitFloor(x.e / LOG_BASE) + bitFloor(y.e / LOG_BASE);
1877
+ y.s *= x.s;
1878
+ xcL = xc.length;
1879
+ ycL = yc.length;
1880
+ if (xcL < ycL) {
1881
+ zc = xc;
1882
+ xc = yc;
1883
+ yc = zc;
1884
+ i = xcL;
1885
+ xcL = ycL;
1886
+ ycL = i;
1887
+ }
1888
+ for (i = xcL + ycL, zc = []; i--; zc.push(0)) ;
1889
+ base = BASE;
1890
+ sqrtBase = SQRT_BASE;
1891
+ for (i = ycL; --i >= 0; ) {
1892
+ c = 0;
1893
+ ylo = yc[i] % sqrtBase;
1894
+ yhi = yc[i] / sqrtBase | 0;
1895
+ for (k = xcL, j = i + k; j > i; ) {
1896
+ xlo = xc[--k] % sqrtBase;
1897
+ xhi = xc[k] / sqrtBase | 0;
1898
+ m = yhi * xlo + xhi * ylo;
1899
+ xlo = ylo * xlo + m % sqrtBase * sqrtBase + zc[j] + c;
1900
+ c = (xlo / base | 0) + (m / sqrtBase | 0) + yhi * xhi;
1901
+ zc[j--] = xlo % base;
1902
+ }
1903
+ zc[j] = c;
1904
+ }
1905
+ if (c) {
1906
+ ++e;
1907
+ } else {
1908
+ zc.splice(0, 1);
1909
+ }
1910
+ return normalise(y, zc, e);
1911
+ };
1912
+ P.negated = function() {
1913
+ var x = new BigNumber2(this);
1914
+ x.s = -x.s || null;
1915
+ return x;
1916
+ };
1917
+ P.plus = function(y, b) {
1918
+ var t, x = this, a = x.s;
1919
+ y = new BigNumber2(y, b);
1920
+ b = y.s;
1921
+ if (!a || !b) return new BigNumber2(NaN);
1922
+ if (a != b) {
1923
+ y.s = -b;
1924
+ return x.minus(y);
1925
+ }
1926
+ var xe = x.e / LOG_BASE, ye = y.e / LOG_BASE, xc = x.c, yc = y.c;
1927
+ if (!xe || !ye) {
1928
+ if (!xc || !yc) return new BigNumber2(a / 0);
1929
+ if (!xc[0] || !yc[0]) return yc[0] ? y : new BigNumber2(xc[0] ? x : a * 0);
1930
+ }
1931
+ xe = bitFloor(xe);
1932
+ ye = bitFloor(ye);
1933
+ xc = xc.slice();
1934
+ if (a = xe - ye) {
1935
+ if (a > 0) {
1936
+ ye = xe;
1937
+ t = yc;
1938
+ } else {
1939
+ a = -a;
1940
+ t = xc;
1941
+ }
1942
+ t.reverse();
1943
+ for (; a--; t.push(0)) ;
1944
+ t.reverse();
1945
+ }
1946
+ a = xc.length;
1947
+ b = yc.length;
1948
+ if (a - b < 0) {
1949
+ t = yc;
1950
+ yc = xc;
1951
+ xc = t;
1952
+ b = a;
1953
+ }
1954
+ for (a = 0; b; ) {
1955
+ a = (xc[--b] = xc[b] + yc[b] + a) / BASE | 0;
1956
+ xc[b] = BASE === xc[b] ? 0 : xc[b] % BASE;
1957
+ }
1958
+ if (a) {
1959
+ xc = [a].concat(xc);
1960
+ ++ye;
1961
+ }
1962
+ return normalise(y, xc, ye);
1963
+ };
1964
+ P.precision = P.sd = function(sd, rm) {
1965
+ var c, n, v, x = this;
1966
+ if (sd != null && sd !== !!sd) {
1967
+ intCheck(sd, 1, MAX);
1968
+ if (rm == null) rm = ROUNDING_MODE;
1969
+ else intCheck(rm, 0, 8);
1970
+ return round(new BigNumber2(x), sd, rm);
1971
+ }
1972
+ if (!(c = x.c)) return null;
1973
+ v = c.length - 1;
1974
+ n = v * LOG_BASE + 1;
1975
+ if (v = c[v]) {
1976
+ for (; v % 10 == 0; v /= 10, n--) ;
1977
+ for (v = c[0]; v >= 10; v /= 10, n++) ;
1978
+ }
1979
+ if (sd && x.e + 1 > n) n = x.e + 1;
1980
+ return n;
1981
+ };
1982
+ P.shiftedBy = function(k) {
1983
+ intCheck(k, -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER);
1984
+ return this.times("1e" + k);
1985
+ };
1986
+ P.squareRoot = P.sqrt = function() {
1987
+ var m, n, r, rep, t, x = this, c = x.c, s = x.s, e = x.e, dp = DECIMAL_PLACES + 4, half = new BigNumber2("0.5");
1988
+ if (s !== 1 || !c || !c[0]) {
1989
+ return new BigNumber2(!s || s < 0 && (!c || c[0]) ? NaN : c ? x : 1 / 0);
1990
+ }
1991
+ s = Math.sqrt(+valueOf(x));
1992
+ if (s == 0 || s == 1 / 0) {
1993
+ n = coeffToString(c);
1994
+ if ((n.length + e) % 2 == 0) n += "0";
1995
+ s = Math.sqrt(+n);
1996
+ e = bitFloor((e + 1) / 2) - (e < 0 || e % 2);
1997
+ if (s == 1 / 0) {
1998
+ n = "5e" + e;
1999
+ } else {
2000
+ n = s.toExponential();
2001
+ n = n.slice(0, n.indexOf("e") + 1) + e;
2002
+ }
2003
+ r = new BigNumber2(n);
2004
+ } else {
2005
+ r = new BigNumber2(s + "");
2006
+ }
2007
+ if (r.c[0]) {
2008
+ e = r.e;
2009
+ s = e + dp;
2010
+ if (s < 3) s = 0;
2011
+ for (; ; ) {
2012
+ t = r;
2013
+ r = half.times(t.plus(div(x, t, dp, 1)));
2014
+ if (coeffToString(t.c).slice(0, s) === (n = coeffToString(r.c)).slice(0, s)) {
2015
+ if (r.e < e) --s;
2016
+ n = n.slice(s - 3, s + 1);
2017
+ if (n == "9999" || !rep && n == "4999") {
2018
+ if (!rep) {
2019
+ round(t, t.e + DECIMAL_PLACES + 2, 0);
2020
+ if (t.times(t).eq(x)) {
2021
+ r = t;
2022
+ break;
2023
+ }
2024
+ }
2025
+ dp += 4;
2026
+ s += 4;
2027
+ rep = 1;
2028
+ } else {
2029
+ if (!+n || !+n.slice(1) && n.charAt(0) == "5") {
2030
+ round(r, r.e + DECIMAL_PLACES + 2, 1);
2031
+ m = !r.times(r).eq(x);
2032
+ }
2033
+ break;
2034
+ }
2035
+ }
2036
+ }
2037
+ }
2038
+ return round(r, r.e + DECIMAL_PLACES + 1, ROUNDING_MODE, m);
2039
+ };
2040
+ P.toExponential = function(dp, rm) {
2041
+ if (dp != null) {
2042
+ intCheck(dp, 0, MAX);
2043
+ dp++;
2044
+ }
2045
+ return format(this, dp, rm, 1);
2046
+ };
2047
+ P.toFixed = function(dp, rm) {
2048
+ if (dp != null) {
2049
+ intCheck(dp, 0, MAX);
2050
+ dp = dp + this.e + 1;
2051
+ }
2052
+ return format(this, dp, rm);
2053
+ };
2054
+ P.toFormat = function(dp, rm, format2) {
2055
+ var str, x = this;
2056
+ if (format2 == null) {
2057
+ if (dp != null && rm && typeof rm == "object") {
2058
+ format2 = rm;
2059
+ rm = null;
2060
+ } else if (dp && typeof dp == "object") {
2061
+ format2 = dp;
2062
+ dp = rm = null;
2063
+ } else {
2064
+ format2 = FORMAT;
2065
+ }
2066
+ } else if (typeof format2 != "object") {
2067
+ throw Error(bignumberError + "Argument not an object: " + format2);
2068
+ }
2069
+ str = x.toFixed(dp, rm);
2070
+ if (x.c) {
2071
+ var i, arr = str.split("."), g1 = +format2.groupSize, g2 = +format2.secondaryGroupSize, groupSeparator = format2.groupSeparator || "", intPart = arr[0], fractionPart = arr[1], isNeg = x.s < 0, intDigits = isNeg ? intPart.slice(1) : intPart, len = intDigits.length;
2072
+ if (g2) {
2073
+ i = g1;
2074
+ g1 = g2;
2075
+ g2 = i;
2076
+ len -= i;
2077
+ }
2078
+ if (g1 > 0 && len > 0) {
2079
+ i = len % g1 || g1;
2080
+ intPart = intDigits.substr(0, i);
2081
+ for (; i < len; i += g1) intPart += groupSeparator + intDigits.substr(i, g1);
2082
+ if (g2 > 0) intPart += groupSeparator + intDigits.slice(i);
2083
+ if (isNeg) intPart = "-" + intPart;
2084
+ }
2085
+ str = fractionPart ? intPart + (format2.decimalSeparator || "") + ((g2 = +format2.fractionGroupSize) ? fractionPart.replace(
2086
+ new RegExp("\\d{" + g2 + "}\\B", "g"),
2087
+ "$&" + (format2.fractionGroupSeparator || "")
2088
+ ) : fractionPart) : intPart;
2089
+ }
2090
+ return (format2.prefix || "") + str + (format2.suffix || "");
2091
+ };
2092
+ P.toFraction = function(md) {
2093
+ var d, d0, d1, d2, e, exp, n, n0, n1, q, r, s, x = this, xc = x.c;
2094
+ if (md != null) {
2095
+ n = new BigNumber2(md);
2096
+ if (!n.isInteger() && (n.c || n.s !== 1) || n.lt(ONE)) {
2097
+ throw Error(bignumberError + "Argument " + (n.isInteger() ? "out of range: " : "not an integer: ") + valueOf(n));
2098
+ }
2099
+ }
2100
+ if (!xc) return new BigNumber2(x);
2101
+ d = new BigNumber2(ONE);
2102
+ n1 = d0 = new BigNumber2(ONE);
2103
+ d1 = n0 = new BigNumber2(ONE);
2104
+ s = coeffToString(xc);
2105
+ e = d.e = s.length - x.e - 1;
2106
+ d.c[0] = POWS_TEN[(exp = e % LOG_BASE) < 0 ? LOG_BASE + exp : exp];
2107
+ md = !md || n.comparedTo(d) > 0 ? e > 0 ? d : n1 : n;
2108
+ exp = MAX_EXP;
2109
+ MAX_EXP = 1 / 0;
2110
+ n = new BigNumber2(s);
2111
+ n0.c[0] = 0;
2112
+ for (; ; ) {
2113
+ q = div(n, d, 0, 1);
2114
+ d2 = d0.plus(q.times(d1));
2115
+ if (d2.comparedTo(md) == 1) break;
2116
+ d0 = d1;
2117
+ d1 = d2;
2118
+ n1 = n0.plus(q.times(d2 = n1));
2119
+ n0 = d2;
2120
+ d = n.minus(q.times(d2 = d));
2121
+ n = d2;
2122
+ }
2123
+ d2 = div(md.minus(d0), d1, 0, 1);
2124
+ n0 = n0.plus(d2.times(n1));
2125
+ d0 = d0.plus(d2.times(d1));
2126
+ n0.s = n1.s = x.s;
2127
+ e = e * 2;
2128
+ r = div(n1, d1, e, ROUNDING_MODE).minus(x).abs().comparedTo(
2129
+ div(n0, d0, e, ROUNDING_MODE).minus(x).abs()
2130
+ ) < 1 ? [n1, d1] : [n0, d0];
2131
+ MAX_EXP = exp;
2132
+ return r;
2133
+ };
2134
+ P.toNumber = function() {
2135
+ return +valueOf(this);
2136
+ };
2137
+ P.toPrecision = function(sd, rm) {
2138
+ if (sd != null) intCheck(sd, 1, MAX);
2139
+ return format(this, sd, rm, 2);
2140
+ };
2141
+ P.toString = function(b) {
2142
+ var str, n = this, s = n.s, e = n.e;
2143
+ if (e === null) {
2144
+ if (s) {
2145
+ str = "Infinity";
2146
+ if (s < 0) str = "-" + str;
2147
+ } else {
2148
+ str = "NaN";
2149
+ }
2150
+ } else {
2151
+ if (b == null) {
2152
+ str = e <= TO_EXP_NEG || e >= TO_EXP_POS ? toExponential(coeffToString(n.c), e) : toFixedPoint(coeffToString(n.c), e, "0");
2153
+ } else if (b === 10 && alphabetHasNormalDecimalDigits) {
2154
+ n = round(new BigNumber2(n), DECIMAL_PLACES + e + 1, ROUNDING_MODE);
2155
+ str = toFixedPoint(coeffToString(n.c), n.e, "0");
2156
+ } else {
2157
+ intCheck(b, 2, ALPHABET.length, "Base");
2158
+ str = convertBase(toFixedPoint(coeffToString(n.c), e, "0"), 10, b, s, true);
2159
+ }
2160
+ if (s < 0 && n.c[0]) str = "-" + str;
2161
+ }
2162
+ return str;
2163
+ };
2164
+ P.valueOf = P.toJSON = function() {
2165
+ return valueOf(this);
2166
+ };
2167
+ P._isBigNumber = true;
2168
+ if (configObject != null) BigNumber2.set(configObject);
2169
+ return BigNumber2;
2170
+ }
2171
+ function bitFloor(n) {
2172
+ var i = n | 0;
2173
+ return n > 0 || n === i ? i : i - 1;
2174
+ }
2175
+ function coeffToString(a) {
2176
+ var s, z, i = 1, j = a.length, r = a[0] + "";
2177
+ for (; i < j; ) {
2178
+ s = a[i++] + "";
2179
+ z = LOG_BASE - s.length;
2180
+ for (; z--; s = "0" + s) ;
2181
+ r += s;
2182
+ }
2183
+ for (j = r.length; r.charCodeAt(--j) === 48; ) ;
2184
+ return r.slice(0, j + 1 || 1);
2185
+ }
2186
+ function compare(x, y) {
2187
+ var a, b, xc = x.c, yc = y.c, i = x.s, j = y.s, k = x.e, l = y.e;
2188
+ if (!i || !j) return null;
2189
+ a = xc && !xc[0];
2190
+ b = yc && !yc[0];
2191
+ if (a || b) return a ? b ? 0 : -j : i;
2192
+ if (i != j) return i;
2193
+ a = i < 0;
2194
+ b = k == l;
2195
+ if (!xc || !yc) return b ? 0 : !xc ^ a ? 1 : -1;
2196
+ if (!b) return k > l ^ a ? 1 : -1;
2197
+ j = (k = xc.length) < (l = yc.length) ? k : l;
2198
+ for (i = 0; i < j; i++) if (xc[i] != yc[i]) return xc[i] > yc[i] ^ a ? 1 : -1;
2199
+ return k == l ? 0 : k > l ^ a ? 1 : -1;
2200
+ }
2201
+ function intCheck(n, min, max, name) {
2202
+ if (n < min || n > max || n !== mathfloor(n)) {
2203
+ throw Error(bignumberError + (name || "Argument") + (typeof n == "number" ? n < min || n > max ? " out of range: " : " not an integer: " : " not a primitive number: ") + String(n));
2204
+ }
2205
+ }
2206
+ function isOdd(n) {
2207
+ var k = n.c.length - 1;
2208
+ return bitFloor(n.e / LOG_BASE) == k && n.c[k] % 2 != 0;
2209
+ }
2210
+ function toExponential(str, e) {
2211
+ return (str.length > 1 ? str.charAt(0) + "." + str.slice(1) : str) + (e < 0 ? "e" : "e+") + e;
2212
+ }
2213
+ function toFixedPoint(str, e, z) {
2214
+ var len, zs;
2215
+ if (e < 0) {
2216
+ for (zs = z + "."; ++e; zs += z) ;
2217
+ str = zs + str;
2218
+ } else {
2219
+ len = str.length;
2220
+ if (++e > len) {
2221
+ for (zs = z, e -= len; --e; zs += z) ;
2222
+ str += zs;
2223
+ } else if (e < len) {
2224
+ str = str.slice(0, e) + "." + str.slice(e);
2225
+ }
2226
+ }
2227
+ return str;
2228
+ }
2229
+ BigNumber = clone();
2230
+ BigNumber["default"] = BigNumber.BigNumber = BigNumber;
2231
+ if (typeof define == "function" && define.amd) {
2232
+ define(function() {
2233
+ return BigNumber;
2234
+ });
2235
+ } else if (typeof module2 != "undefined" && module2.exports) {
2236
+ module2.exports = BigNumber;
2237
+ } else {
2238
+ if (!globalObject) {
2239
+ globalObject = typeof self != "undefined" && self ? self : window;
2240
+ }
2241
+ globalObject.BigNumber = BigNumber;
2242
+ }
2243
+ })(exports2);
2244
+ }
2245
+ });
2246
+
2247
+ // ../../node_modules/json-bigint/lib/stringify.js
2248
+ var require_stringify = __commonJS({
2249
+ "../../node_modules/json-bigint/lib/stringify.js"(exports2, module2) {
2250
+ "use strict";
2251
+ var BigNumber = require_bignumber();
2252
+ var JSON2 = module2.exports;
2253
+ (function() {
2254
+ "use strict";
2255
+ function f(n) {
2256
+ return n < 10 ? "0" + n : n;
2257
+ }
2258
+ var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, gap, indent, meta = {
2259
+ // table of character substitutions
2260
+ "\b": "\\b",
2261
+ " ": "\\t",
2262
+ "\n": "\\n",
2263
+ "\f": "\\f",
2264
+ "\r": "\\r",
2265
+ '"': '\\"',
2266
+ "\\": "\\\\"
2267
+ }, rep;
2268
+ function quote(string) {
2269
+ escapable.lastIndex = 0;
2270
+ return escapable.test(string) ? '"' + string.replace(escapable, function(a) {
2271
+ var c = meta[a];
2272
+ return typeof c === "string" ? c : "\\u" + ("0000" + a.charCodeAt(0).toString(16)).slice(-4);
2273
+ }) + '"' : '"' + string + '"';
2274
+ }
2275
+ function str(key, holder) {
2276
+ var i, k, v, length, mind = gap, partial, value = holder[key], isBigNumber = value != null && (value instanceof BigNumber || BigNumber.isBigNumber(value));
2277
+ if (value && typeof value === "object" && typeof value.toJSON === "function") {
2278
+ value = value.toJSON(key);
2279
+ }
2280
+ if (typeof rep === "function") {
2281
+ value = rep.call(holder, key, value);
2282
+ }
2283
+ switch (typeof value) {
2284
+ case "string":
2285
+ if (isBigNumber) {
2286
+ return value;
2287
+ } else {
2288
+ return quote(value);
2289
+ }
2290
+ case "number":
2291
+ return isFinite(value) ? String(value) : "null";
2292
+ case "boolean":
2293
+ case "null":
2294
+ case "bigint":
2295
+ return String(value);
2296
+ // If the type is 'object', we might be dealing with an object or an array or
2297
+ // null.
2298
+ case "object":
2299
+ if (!value) {
2300
+ return "null";
2301
+ }
2302
+ gap += indent;
2303
+ partial = [];
2304
+ if (Object.prototype.toString.apply(value) === "[object Array]") {
2305
+ length = value.length;
2306
+ for (i = 0; i < length; i += 1) {
2307
+ partial[i] = str(i, value) || "null";
2308
+ }
2309
+ v = partial.length === 0 ? "[]" : gap ? "[\n" + gap + partial.join(",\n" + gap) + "\n" + mind + "]" : "[" + partial.join(",") + "]";
2310
+ gap = mind;
2311
+ return v;
2312
+ }
2313
+ if (rep && typeof rep === "object") {
2314
+ length = rep.length;
2315
+ for (i = 0; i < length; i += 1) {
2316
+ if (typeof rep[i] === "string") {
2317
+ k = rep[i];
2318
+ v = str(k, value);
2319
+ if (v) {
2320
+ partial.push(quote(k) + (gap ? ": " : ":") + v);
2321
+ }
2322
+ }
2323
+ }
2324
+ } else {
2325
+ Object.keys(value).forEach(function(k2) {
2326
+ var v2 = str(k2, value);
2327
+ if (v2) {
2328
+ partial.push(quote(k2) + (gap ? ": " : ":") + v2);
2329
+ }
2330
+ });
2331
+ }
2332
+ v = partial.length === 0 ? "{}" : gap ? "{\n" + gap + partial.join(",\n" + gap) + "\n" + mind + "}" : "{" + partial.join(",") + "}";
2333
+ gap = mind;
2334
+ return v;
2335
+ }
2336
+ }
2337
+ if (typeof JSON2.stringify !== "function") {
2338
+ JSON2.stringify = function(value, replacer, space) {
2339
+ var i;
2340
+ gap = "";
2341
+ indent = "";
2342
+ if (typeof space === "number") {
2343
+ for (i = 0; i < space; i += 1) {
2344
+ indent += " ";
2345
+ }
2346
+ } else if (typeof space === "string") {
2347
+ indent = space;
2348
+ }
2349
+ rep = replacer;
2350
+ if (replacer && typeof replacer !== "function" && (typeof replacer !== "object" || typeof replacer.length !== "number")) {
2351
+ throw new Error("JSON.stringify");
2352
+ }
2353
+ return str("", { "": value });
2354
+ };
2355
+ }
2356
+ })();
2357
+ }
2358
+ });
2359
+
2360
+ // ../../node_modules/json-bigint/lib/parse.js
2361
+ var require_parse = __commonJS({
2362
+ "../../node_modules/json-bigint/lib/parse.js"(exports2, module2) {
2363
+ "use strict";
2364
+ var BigNumber = null;
2365
+ var suspectProtoRx = /(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])/;
2366
+ var suspectConstructorRx = /(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)/;
2367
+ var json_parse = function(options) {
2368
+ "use strict";
2369
+ var _options = {
2370
+ strict: false,
2371
+ // not being strict means do not generate syntax errors for "duplicate key"
2372
+ storeAsString: false,
2373
+ // toggles whether the values should be stored as BigNumber (default) or a string
2374
+ alwaysParseAsBig: false,
2375
+ // toggles whether all numbers should be Big
2376
+ useNativeBigInt: false,
2377
+ // toggles whether to use native BigInt instead of bignumber.js
2378
+ protoAction: "error",
2379
+ constructorAction: "error"
2380
+ };
2381
+ if (options !== void 0 && options !== null) {
2382
+ if (options.strict === true) {
2383
+ _options.strict = true;
2384
+ }
2385
+ if (options.storeAsString === true) {
2386
+ _options.storeAsString = true;
2387
+ }
2388
+ _options.alwaysParseAsBig = options.alwaysParseAsBig === true ? options.alwaysParseAsBig : false;
2389
+ _options.useNativeBigInt = options.useNativeBigInt === true ? options.useNativeBigInt : false;
2390
+ if (typeof options.constructorAction !== "undefined") {
2391
+ if (options.constructorAction === "error" || options.constructorAction === "ignore" || options.constructorAction === "preserve") {
2392
+ _options.constructorAction = options.constructorAction;
2393
+ } else {
2394
+ throw new Error(
2395
+ `Incorrect value for constructorAction option, must be "error", "ignore" or undefined but passed ${options.constructorAction}`
2396
+ );
2397
+ }
2398
+ }
2399
+ if (typeof options.protoAction !== "undefined") {
2400
+ if (options.protoAction === "error" || options.protoAction === "ignore" || options.protoAction === "preserve") {
2401
+ _options.protoAction = options.protoAction;
2402
+ } else {
2403
+ throw new Error(
2404
+ `Incorrect value for protoAction option, must be "error", "ignore" or undefined but passed ${options.protoAction}`
2405
+ );
2406
+ }
2407
+ }
2408
+ }
2409
+ var at, ch, escapee = {
2410
+ '"': '"',
2411
+ "\\": "\\",
2412
+ "/": "/",
2413
+ b: "\b",
2414
+ f: "\f",
2415
+ n: "\n",
2416
+ r: "\r",
2417
+ t: " "
2418
+ }, text, error = function(m) {
2419
+ throw {
2420
+ name: "SyntaxError",
2421
+ message: m,
2422
+ at,
2423
+ text
2424
+ };
2425
+ }, next = function(c) {
2426
+ if (c && c !== ch) {
2427
+ error("Expected '" + c + "' instead of '" + ch + "'");
2428
+ }
2429
+ ch = text.charAt(at);
2430
+ at += 1;
2431
+ return ch;
2432
+ }, number = function() {
2433
+ var number2, string2 = "";
2434
+ if (ch === "-") {
2435
+ string2 = "-";
2436
+ next("-");
2437
+ }
2438
+ while (ch >= "0" && ch <= "9") {
2439
+ string2 += ch;
2440
+ next();
2441
+ }
2442
+ if (ch === ".") {
2443
+ string2 += ".";
2444
+ while (next() && ch >= "0" && ch <= "9") {
2445
+ string2 += ch;
2446
+ }
2447
+ }
2448
+ if (ch === "e" || ch === "E") {
2449
+ string2 += ch;
2450
+ next();
2451
+ if (ch === "-" || ch === "+") {
2452
+ string2 += ch;
2453
+ next();
2454
+ }
2455
+ while (ch >= "0" && ch <= "9") {
2456
+ string2 += ch;
2457
+ next();
2458
+ }
2459
+ }
2460
+ number2 = +string2;
2461
+ if (!isFinite(number2)) {
2462
+ error("Bad number");
2463
+ } else {
2464
+ if (BigNumber == null) BigNumber = require_bignumber();
2465
+ if (string2.length > 15)
2466
+ return _options.storeAsString ? string2 : _options.useNativeBigInt ? BigInt(string2) : new BigNumber(string2);
2467
+ else
2468
+ return !_options.alwaysParseAsBig ? number2 : _options.useNativeBigInt ? BigInt(number2) : new BigNumber(number2);
2469
+ }
2470
+ }, string = function() {
2471
+ var hex, i, string2 = "", uffff;
2472
+ if (ch === '"') {
2473
+ var startAt = at;
2474
+ while (next()) {
2475
+ if (ch === '"') {
2476
+ if (at - 1 > startAt) string2 += text.substring(startAt, at - 1);
2477
+ next();
2478
+ return string2;
2479
+ }
2480
+ if (ch === "\\") {
2481
+ if (at - 1 > startAt) string2 += text.substring(startAt, at - 1);
2482
+ next();
2483
+ if (ch === "u") {
2484
+ uffff = 0;
2485
+ for (i = 0; i < 4; i += 1) {
2486
+ hex = parseInt(next(), 16);
2487
+ if (!isFinite(hex)) {
2488
+ break;
2489
+ }
2490
+ uffff = uffff * 16 + hex;
2491
+ }
2492
+ string2 += String.fromCharCode(uffff);
2493
+ } else if (typeof escapee[ch] === "string") {
2494
+ string2 += escapee[ch];
2495
+ } else {
2496
+ break;
2497
+ }
2498
+ startAt = at;
2499
+ }
2500
+ }
2501
+ }
2502
+ error("Bad string");
2503
+ }, white = function() {
2504
+ while (ch && ch <= " ") {
2505
+ next();
2506
+ }
2507
+ }, word = function() {
2508
+ switch (ch) {
2509
+ case "t":
2510
+ next("t");
2511
+ next("r");
2512
+ next("u");
2513
+ next("e");
2514
+ return true;
2515
+ case "f":
2516
+ next("f");
2517
+ next("a");
2518
+ next("l");
2519
+ next("s");
2520
+ next("e");
2521
+ return false;
2522
+ case "n":
2523
+ next("n");
2524
+ next("u");
2525
+ next("l");
2526
+ next("l");
2527
+ return null;
2528
+ }
2529
+ error("Unexpected '" + ch + "'");
2530
+ }, value, array = function() {
2531
+ var array2 = [];
2532
+ if (ch === "[") {
2533
+ next("[");
2534
+ white();
2535
+ if (ch === "]") {
2536
+ next("]");
2537
+ return array2;
2538
+ }
2539
+ while (ch) {
2540
+ array2.push(value());
2541
+ white();
2542
+ if (ch === "]") {
2543
+ next("]");
2544
+ return array2;
2545
+ }
2546
+ next(",");
2547
+ white();
2548
+ }
2549
+ }
2550
+ error("Bad array");
2551
+ }, object = function() {
2552
+ var key, object2 = /* @__PURE__ */ Object.create(null);
2553
+ if (ch === "{") {
2554
+ next("{");
2555
+ white();
2556
+ if (ch === "}") {
2557
+ next("}");
2558
+ return object2;
2559
+ }
2560
+ while (ch) {
2561
+ key = string();
2562
+ white();
2563
+ next(":");
2564
+ if (_options.strict === true && Object.hasOwnProperty.call(object2, key)) {
2565
+ error('Duplicate key "' + key + '"');
2566
+ }
2567
+ if (suspectProtoRx.test(key) === true) {
2568
+ if (_options.protoAction === "error") {
2569
+ error("Object contains forbidden prototype property");
2570
+ } else if (_options.protoAction === "ignore") {
2571
+ value();
2572
+ } else {
2573
+ object2[key] = value();
2574
+ }
2575
+ } else if (suspectConstructorRx.test(key) === true) {
2576
+ if (_options.constructorAction === "error") {
2577
+ error("Object contains forbidden constructor property");
2578
+ } else if (_options.constructorAction === "ignore") {
2579
+ value();
2580
+ } else {
2581
+ object2[key] = value();
2582
+ }
2583
+ } else {
2584
+ object2[key] = value();
2585
+ }
2586
+ white();
2587
+ if (ch === "}") {
2588
+ next("}");
2589
+ return object2;
2590
+ }
2591
+ next(",");
2592
+ white();
2593
+ }
2594
+ }
2595
+ error("Bad object");
2596
+ };
2597
+ value = function() {
2598
+ white();
2599
+ switch (ch) {
2600
+ case "{":
2601
+ return object();
2602
+ case "[":
2603
+ return array();
2604
+ case '"':
2605
+ return string();
2606
+ case "-":
2607
+ return number();
2608
+ default:
2609
+ return ch >= "0" && ch <= "9" ? number() : word();
2610
+ }
2611
+ };
2612
+ return function(source, reviver) {
2613
+ var result;
2614
+ text = source + "";
2615
+ at = 0;
2616
+ ch = " ";
2617
+ result = value();
2618
+ white();
2619
+ if (ch) {
2620
+ error("Syntax error");
2621
+ }
2622
+ return typeof reviver === "function" ? function walk(holder, key) {
2623
+ var k, v, value2 = holder[key];
2624
+ if (value2 && typeof value2 === "object") {
2625
+ Object.keys(value2).forEach(function(k2) {
2626
+ v = walk(value2, k2);
2627
+ if (v !== void 0) {
2628
+ value2[k2] = v;
2629
+ } else {
2630
+ delete value2[k2];
2631
+ }
2632
+ });
2633
+ }
2634
+ return reviver.call(holder, key, value2);
2635
+ }({ "": result }, "") : result;
2636
+ };
2637
+ };
2638
+ module2.exports = json_parse;
2639
+ }
2640
+ });
2641
+
2642
+ // ../../node_modules/json-bigint/index.js
2643
+ var require_json_bigint = __commonJS({
2644
+ "../../node_modules/json-bigint/index.js"(exports2, module2) {
2645
+ "use strict";
2646
+ var json_stringify = require_stringify().stringify;
2647
+ var json_parse = require_parse();
2648
+ module2.exports = function(options) {
2649
+ return {
2650
+ parse: json_parse(options),
2651
+ stringify: json_stringify
2652
+ };
2653
+ };
2654
+ module2.exports.parse = json_parse();
2655
+ module2.exports.stringify = json_stringify;
2656
+ }
2657
+ });
2658
+
2659
+ // ../../node_modules/minimalistic-assert/index.js
2660
+ var require_minimalistic_assert = __commonJS({
2661
+ "../../node_modules/minimalistic-assert/index.js"(exports2, module2) {
2662
+ "use strict";
2663
+ module2.exports = assert;
2664
+ function assert(val, msg) {
2665
+ if (!val)
2666
+ throw new Error(msg || "Assertion failed");
2667
+ }
2668
+ assert.equal = function assertEqual(l, r, msg) {
2669
+ if (l != r)
2670
+ throw new Error(msg || "Assertion failed: " + l + " != " + r);
2671
+ };
2672
+ }
2673
+ });
2674
+
2675
+ // ../../node_modules/inherits/inherits_browser.js
2676
+ var require_inherits_browser = __commonJS({
2677
+ "../../node_modules/inherits/inherits_browser.js"(exports2, module2) {
2678
+ "use strict";
2679
+ if (typeof Object.create === "function") {
2680
+ module2.exports = function inherits(ctor, superCtor) {
2681
+ if (superCtor) {
2682
+ ctor.super_ = superCtor;
2683
+ ctor.prototype = Object.create(superCtor.prototype, {
2684
+ constructor: {
2685
+ value: ctor,
2686
+ enumerable: false,
2687
+ writable: true,
2688
+ configurable: true
2689
+ }
2690
+ });
2691
+ }
2692
+ };
2693
+ } else {
2694
+ module2.exports = function inherits(ctor, superCtor) {
2695
+ if (superCtor) {
2696
+ ctor.super_ = superCtor;
2697
+ var TempCtor = function() {
2698
+ };
2699
+ TempCtor.prototype = superCtor.prototype;
2700
+ ctor.prototype = new TempCtor();
2701
+ ctor.prototype.constructor = ctor;
2702
+ }
2703
+ };
2704
+ }
2705
+ }
2706
+ });
2707
+
2708
+ // ../../node_modules/inherits/inherits.js
2709
+ var require_inherits = __commonJS({
2710
+ "../../node_modules/inherits/inherits.js"(exports2, module2) {
2711
+ "use strict";
2712
+ try {
2713
+ util = require("util");
2714
+ if (typeof util.inherits !== "function") throw "";
2715
+ module2.exports = util.inherits;
2716
+ } catch (e) {
2717
+ module2.exports = require_inherits_browser();
2718
+ }
2719
+ var util;
2720
+ }
2721
+ });
2722
+
2723
+ // ../../node_modules/hash.js/lib/hash/utils.js
2724
+ var require_utils = __commonJS({
2725
+ "../../node_modules/hash.js/lib/hash/utils.js"(exports2) {
2726
+ "use strict";
2727
+ var assert = require_minimalistic_assert();
2728
+ var inherits = require_inherits();
2729
+ exports2.inherits = inherits;
2730
+ function isSurrogatePair(msg, i) {
2731
+ if ((msg.charCodeAt(i) & 64512) !== 55296) {
2732
+ return false;
2733
+ }
2734
+ if (i < 0 || i + 1 >= msg.length) {
2735
+ return false;
2736
+ }
2737
+ return (msg.charCodeAt(i + 1) & 64512) === 56320;
2738
+ }
2739
+ function toArray(msg, enc) {
2740
+ if (Array.isArray(msg))
2741
+ return msg.slice();
2742
+ if (!msg)
2743
+ return [];
2744
+ var res = [];
2745
+ if (typeof msg === "string") {
2746
+ if (!enc) {
2747
+ var p = 0;
2748
+ for (var i = 0; i < msg.length; i++) {
2749
+ var c = msg.charCodeAt(i);
2750
+ if (c < 128) {
2751
+ res[p++] = c;
2752
+ } else if (c < 2048) {
2753
+ res[p++] = c >> 6 | 192;
2754
+ res[p++] = c & 63 | 128;
2755
+ } else if (isSurrogatePair(msg, i)) {
2756
+ c = 65536 + ((c & 1023) << 10) + (msg.charCodeAt(++i) & 1023);
2757
+ res[p++] = c >> 18 | 240;
2758
+ res[p++] = c >> 12 & 63 | 128;
2759
+ res[p++] = c >> 6 & 63 | 128;
2760
+ res[p++] = c & 63 | 128;
2761
+ } else {
2762
+ res[p++] = c >> 12 | 224;
2763
+ res[p++] = c >> 6 & 63 | 128;
2764
+ res[p++] = c & 63 | 128;
2765
+ }
2766
+ }
2767
+ } else if (enc === "hex") {
2768
+ msg = msg.replace(/[^a-z0-9]+/ig, "");
2769
+ if (msg.length % 2 !== 0)
2770
+ msg = "0" + msg;
2771
+ for (i = 0; i < msg.length; i += 2)
2772
+ res.push(parseInt(msg[i] + msg[i + 1], 16));
2773
+ }
2774
+ } else {
2775
+ for (i = 0; i < msg.length; i++)
2776
+ res[i] = msg[i] | 0;
2777
+ }
2778
+ return res;
2779
+ }
2780
+ exports2.toArray = toArray;
2781
+ function toHex(msg) {
2782
+ var res = "";
2783
+ for (var i = 0; i < msg.length; i++)
2784
+ res += zero2(msg[i].toString(16));
2785
+ return res;
2786
+ }
2787
+ exports2.toHex = toHex;
2788
+ function htonl(w) {
2789
+ var res = w >>> 24 | w >>> 8 & 65280 | w << 8 & 16711680 | (w & 255) << 24;
2790
+ return res >>> 0;
2791
+ }
2792
+ exports2.htonl = htonl;
2793
+ function toHex32(msg, endian) {
2794
+ var res = "";
2795
+ for (var i = 0; i < msg.length; i++) {
2796
+ var w = msg[i];
2797
+ if (endian === "little")
2798
+ w = htonl(w);
2799
+ res += zero8(w.toString(16));
2800
+ }
2801
+ return res;
2802
+ }
2803
+ exports2.toHex32 = toHex32;
2804
+ function zero2(word) {
2805
+ if (word.length === 1)
2806
+ return "0" + word;
2807
+ else
2808
+ return word;
2809
+ }
2810
+ exports2.zero2 = zero2;
2811
+ function zero8(word) {
2812
+ if (word.length === 7)
2813
+ return "0" + word;
2814
+ else if (word.length === 6)
2815
+ return "00" + word;
2816
+ else if (word.length === 5)
2817
+ return "000" + word;
2818
+ else if (word.length === 4)
2819
+ return "0000" + word;
2820
+ else if (word.length === 3)
2821
+ return "00000" + word;
2822
+ else if (word.length === 2)
2823
+ return "000000" + word;
2824
+ else if (word.length === 1)
2825
+ return "0000000" + word;
2826
+ else
2827
+ return word;
2828
+ }
2829
+ exports2.zero8 = zero8;
2830
+ function join32(msg, start, end, endian) {
2831
+ var len = end - start;
2832
+ assert(len % 4 === 0);
2833
+ var res = new Array(len / 4);
2834
+ for (var i = 0, k = start; i < res.length; i++, k += 4) {
2835
+ var w;
2836
+ if (endian === "big")
2837
+ w = msg[k] << 24 | msg[k + 1] << 16 | msg[k + 2] << 8 | msg[k + 3];
2838
+ else
2839
+ w = msg[k + 3] << 24 | msg[k + 2] << 16 | msg[k + 1] << 8 | msg[k];
2840
+ res[i] = w >>> 0;
2841
+ }
2842
+ return res;
2843
+ }
2844
+ exports2.join32 = join32;
2845
+ function split32(msg, endian) {
2846
+ var res = new Array(msg.length * 4);
2847
+ for (var i = 0, k = 0; i < msg.length; i++, k += 4) {
2848
+ var m = msg[i];
2849
+ if (endian === "big") {
2850
+ res[k] = m >>> 24;
2851
+ res[k + 1] = m >>> 16 & 255;
2852
+ res[k + 2] = m >>> 8 & 255;
2853
+ res[k + 3] = m & 255;
2854
+ } else {
2855
+ res[k + 3] = m >>> 24;
2856
+ res[k + 2] = m >>> 16 & 255;
2857
+ res[k + 1] = m >>> 8 & 255;
2858
+ res[k] = m & 255;
2859
+ }
2860
+ }
2861
+ return res;
2862
+ }
2863
+ exports2.split32 = split32;
2864
+ function rotr32(w, b) {
2865
+ return w >>> b | w << 32 - b;
2866
+ }
2867
+ exports2.rotr32 = rotr32;
2868
+ function rotl32(w, b) {
2869
+ return w << b | w >>> 32 - b;
2870
+ }
2871
+ exports2.rotl32 = rotl32;
2872
+ function sum32(a, b) {
2873
+ return a + b >>> 0;
2874
+ }
2875
+ exports2.sum32 = sum32;
2876
+ function sum32_3(a, b, c) {
2877
+ return a + b + c >>> 0;
2878
+ }
2879
+ exports2.sum32_3 = sum32_3;
2880
+ function sum32_4(a, b, c, d) {
2881
+ return a + b + c + d >>> 0;
2882
+ }
2883
+ exports2.sum32_4 = sum32_4;
2884
+ function sum32_5(a, b, c, d, e) {
2885
+ return a + b + c + d + e >>> 0;
2886
+ }
2887
+ exports2.sum32_5 = sum32_5;
2888
+ function sum64(buf, pos, ah, al) {
2889
+ var bh = buf[pos];
2890
+ var bl = buf[pos + 1];
2891
+ var lo = al + bl >>> 0;
2892
+ var hi = (lo < al ? 1 : 0) + ah + bh;
2893
+ buf[pos] = hi >>> 0;
2894
+ buf[pos + 1] = lo;
2895
+ }
2896
+ exports2.sum64 = sum64;
2897
+ function sum64_hi(ah, al, bh, bl) {
2898
+ var lo = al + bl >>> 0;
2899
+ var hi = (lo < al ? 1 : 0) + ah + bh;
2900
+ return hi >>> 0;
2901
+ }
2902
+ exports2.sum64_hi = sum64_hi;
2903
+ function sum64_lo(ah, al, bh, bl) {
2904
+ var lo = al + bl;
2905
+ return lo >>> 0;
2906
+ }
2907
+ exports2.sum64_lo = sum64_lo;
2908
+ function sum64_4_hi(ah, al, bh, bl, ch, cl, dh, dl) {
2909
+ var carry = 0;
2910
+ var lo = al;
2911
+ lo = lo + bl >>> 0;
2912
+ carry += lo < al ? 1 : 0;
2913
+ lo = lo + cl >>> 0;
2914
+ carry += lo < cl ? 1 : 0;
2915
+ lo = lo + dl >>> 0;
2916
+ carry += lo < dl ? 1 : 0;
2917
+ var hi = ah + bh + ch + dh + carry;
2918
+ return hi >>> 0;
2919
+ }
2920
+ exports2.sum64_4_hi = sum64_4_hi;
2921
+ function sum64_4_lo(ah, al, bh, bl, ch, cl, dh, dl) {
2922
+ var lo = al + bl + cl + dl;
2923
+ return lo >>> 0;
2924
+ }
2925
+ exports2.sum64_4_lo = sum64_4_lo;
2926
+ function sum64_5_hi(ah, al, bh, bl, ch, cl, dh, dl, eh, el) {
2927
+ var carry = 0;
2928
+ var lo = al;
2929
+ lo = lo + bl >>> 0;
2930
+ carry += lo < al ? 1 : 0;
2931
+ lo = lo + cl >>> 0;
2932
+ carry += lo < cl ? 1 : 0;
2933
+ lo = lo + dl >>> 0;
2934
+ carry += lo < dl ? 1 : 0;
2935
+ lo = lo + el >>> 0;
2936
+ carry += lo < el ? 1 : 0;
2937
+ var hi = ah + bh + ch + dh + eh + carry;
2938
+ return hi >>> 0;
2939
+ }
2940
+ exports2.sum64_5_hi = sum64_5_hi;
2941
+ function sum64_5_lo(ah, al, bh, bl, ch, cl, dh, dl, eh, el) {
2942
+ var lo = al + bl + cl + dl + el;
2943
+ return lo >>> 0;
2944
+ }
2945
+ exports2.sum64_5_lo = sum64_5_lo;
2946
+ function rotr64_hi(ah, al, num) {
2947
+ var r = al << 32 - num | ah >>> num;
2948
+ return r >>> 0;
2949
+ }
2950
+ exports2.rotr64_hi = rotr64_hi;
2951
+ function rotr64_lo(ah, al, num) {
2952
+ var r = ah << 32 - num | al >>> num;
2953
+ return r >>> 0;
2954
+ }
2955
+ exports2.rotr64_lo = rotr64_lo;
2956
+ function shr64_hi(ah, al, num) {
2957
+ return ah >>> num;
2958
+ }
2959
+ exports2.shr64_hi = shr64_hi;
2960
+ function shr64_lo(ah, al, num) {
2961
+ var r = ah << 32 - num | al >>> num;
2962
+ return r >>> 0;
2963
+ }
2964
+ exports2.shr64_lo = shr64_lo;
2965
+ }
2966
+ });
2967
+
2968
+ // ../../node_modules/hash.js/lib/hash/common.js
2969
+ var require_common = __commonJS({
2970
+ "../../node_modules/hash.js/lib/hash/common.js"(exports2) {
2971
+ "use strict";
2972
+ var utils = require_utils();
2973
+ var assert = require_minimalistic_assert();
2974
+ function BlockHash() {
2975
+ this.pending = null;
2976
+ this.pendingTotal = 0;
2977
+ this.blockSize = this.constructor.blockSize;
2978
+ this.outSize = this.constructor.outSize;
2979
+ this.hmacStrength = this.constructor.hmacStrength;
2980
+ this.padLength = this.constructor.padLength / 8;
2981
+ this.endian = "big";
2982
+ this._delta8 = this.blockSize / 8;
2983
+ this._delta32 = this.blockSize / 32;
2984
+ }
2985
+ exports2.BlockHash = BlockHash;
2986
+ BlockHash.prototype.update = function update(msg, enc) {
2987
+ msg = utils.toArray(msg, enc);
2988
+ if (!this.pending)
2989
+ this.pending = msg;
2990
+ else
2991
+ this.pending = this.pending.concat(msg);
2992
+ this.pendingTotal += msg.length;
2993
+ if (this.pending.length >= this._delta8) {
2994
+ msg = this.pending;
2995
+ var r = msg.length % this._delta8;
2996
+ this.pending = msg.slice(msg.length - r, msg.length);
2997
+ if (this.pending.length === 0)
2998
+ this.pending = null;
2999
+ msg = utils.join32(msg, 0, msg.length - r, this.endian);
3000
+ for (var i = 0; i < msg.length; i += this._delta32)
3001
+ this._update(msg, i, i + this._delta32);
3002
+ }
3003
+ return this;
3004
+ };
3005
+ BlockHash.prototype.digest = function digest(enc) {
3006
+ this.update(this._pad());
3007
+ assert(this.pending === null);
3008
+ return this._digest(enc);
3009
+ };
3010
+ BlockHash.prototype._pad = function pad() {
3011
+ var len = this.pendingTotal;
3012
+ var bytes = this._delta8;
3013
+ var k = bytes - (len + this.padLength) % bytes;
3014
+ var res = new Array(k + this.padLength);
3015
+ res[0] = 128;
3016
+ for (var i = 1; i < k; i++)
3017
+ res[i] = 0;
3018
+ len <<= 3;
3019
+ if (this.endian === "big") {
3020
+ for (var t = 8; t < this.padLength; t++)
3021
+ res[i++] = 0;
3022
+ res[i++] = 0;
3023
+ res[i++] = 0;
3024
+ res[i++] = 0;
3025
+ res[i++] = 0;
3026
+ res[i++] = len >>> 24 & 255;
3027
+ res[i++] = len >>> 16 & 255;
3028
+ res[i++] = len >>> 8 & 255;
3029
+ res[i++] = len & 255;
3030
+ } else {
3031
+ res[i++] = len & 255;
3032
+ res[i++] = len >>> 8 & 255;
3033
+ res[i++] = len >>> 16 & 255;
3034
+ res[i++] = len >>> 24 & 255;
3035
+ res[i++] = 0;
3036
+ res[i++] = 0;
3037
+ res[i++] = 0;
3038
+ res[i++] = 0;
3039
+ for (t = 8; t < this.padLength; t++)
3040
+ res[i++] = 0;
3041
+ }
3042
+ return res;
3043
+ };
3044
+ }
3045
+ });
3046
+
3047
+ // ../../node_modules/hash.js/lib/hash/sha/common.js
3048
+ var require_common2 = __commonJS({
3049
+ "../../node_modules/hash.js/lib/hash/sha/common.js"(exports2) {
3050
+ "use strict";
3051
+ var utils = require_utils();
3052
+ var rotr32 = utils.rotr32;
3053
+ function ft_1(s, x, y, z) {
3054
+ if (s === 0)
3055
+ return ch32(x, y, z);
3056
+ if (s === 1 || s === 3)
3057
+ return p32(x, y, z);
3058
+ if (s === 2)
3059
+ return maj32(x, y, z);
3060
+ }
3061
+ exports2.ft_1 = ft_1;
3062
+ function ch32(x, y, z) {
3063
+ return x & y ^ ~x & z;
3064
+ }
3065
+ exports2.ch32 = ch32;
3066
+ function maj32(x, y, z) {
3067
+ return x & y ^ x & z ^ y & z;
3068
+ }
3069
+ exports2.maj32 = maj32;
3070
+ function p32(x, y, z) {
3071
+ return x ^ y ^ z;
3072
+ }
3073
+ exports2.p32 = p32;
3074
+ function s0_256(x) {
3075
+ return rotr32(x, 2) ^ rotr32(x, 13) ^ rotr32(x, 22);
3076
+ }
3077
+ exports2.s0_256 = s0_256;
3078
+ function s1_256(x) {
3079
+ return rotr32(x, 6) ^ rotr32(x, 11) ^ rotr32(x, 25);
3080
+ }
3081
+ exports2.s1_256 = s1_256;
3082
+ function g0_256(x) {
3083
+ return rotr32(x, 7) ^ rotr32(x, 18) ^ x >>> 3;
3084
+ }
3085
+ exports2.g0_256 = g0_256;
3086
+ function g1_256(x) {
3087
+ return rotr32(x, 17) ^ rotr32(x, 19) ^ x >>> 10;
3088
+ }
3089
+ exports2.g1_256 = g1_256;
3090
+ }
3091
+ });
3092
+
3093
+ // ../../node_modules/hash.js/lib/hash/sha/1.js
3094
+ var require__ = __commonJS({
3095
+ "../../node_modules/hash.js/lib/hash/sha/1.js"(exports2, module2) {
3096
+ "use strict";
3097
+ var utils = require_utils();
3098
+ var common = require_common();
3099
+ var shaCommon = require_common2();
3100
+ var rotl32 = utils.rotl32;
3101
+ var sum32 = utils.sum32;
3102
+ var sum32_5 = utils.sum32_5;
3103
+ var ft_1 = shaCommon.ft_1;
3104
+ var BlockHash = common.BlockHash;
3105
+ var sha1_K = [
3106
+ 1518500249,
3107
+ 1859775393,
3108
+ 2400959708,
3109
+ 3395469782
3110
+ ];
3111
+ function SHA1() {
3112
+ if (!(this instanceof SHA1))
3113
+ return new SHA1();
3114
+ BlockHash.call(this);
3115
+ this.h = [
3116
+ 1732584193,
3117
+ 4023233417,
3118
+ 2562383102,
3119
+ 271733878,
3120
+ 3285377520
3121
+ ];
3122
+ this.W = new Array(80);
3123
+ }
3124
+ utils.inherits(SHA1, BlockHash);
3125
+ module2.exports = SHA1;
3126
+ SHA1.blockSize = 512;
3127
+ SHA1.outSize = 160;
3128
+ SHA1.hmacStrength = 80;
3129
+ SHA1.padLength = 64;
3130
+ SHA1.prototype._update = function _update(msg, start) {
3131
+ var W = this.W;
3132
+ for (var i = 0; i < 16; i++)
3133
+ W[i] = msg[start + i];
3134
+ for (; i < W.length; i++)
3135
+ W[i] = rotl32(W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16], 1);
3136
+ var a = this.h[0];
3137
+ var b = this.h[1];
3138
+ var c = this.h[2];
3139
+ var d = this.h[3];
3140
+ var e = this.h[4];
3141
+ for (i = 0; i < W.length; i++) {
3142
+ var s = ~~(i / 20);
3143
+ var t = sum32_5(rotl32(a, 5), ft_1(s, b, c, d), e, W[i], sha1_K[s]);
3144
+ e = d;
3145
+ d = c;
3146
+ c = rotl32(b, 30);
3147
+ b = a;
3148
+ a = t;
3149
+ }
3150
+ this.h[0] = sum32(this.h[0], a);
3151
+ this.h[1] = sum32(this.h[1], b);
3152
+ this.h[2] = sum32(this.h[2], c);
3153
+ this.h[3] = sum32(this.h[3], d);
3154
+ this.h[4] = sum32(this.h[4], e);
3155
+ };
3156
+ SHA1.prototype._digest = function digest(enc) {
3157
+ if (enc === "hex")
3158
+ return utils.toHex32(this.h, "big");
3159
+ else
3160
+ return utils.split32(this.h, "big");
3161
+ };
3162
+ }
3163
+ });
3164
+
3165
+ // ../../node_modules/hash.js/lib/hash/sha/256.js
3166
+ var require__2 = __commonJS({
3167
+ "../../node_modules/hash.js/lib/hash/sha/256.js"(exports2, module2) {
3168
+ "use strict";
3169
+ var utils = require_utils();
3170
+ var common = require_common();
3171
+ var shaCommon = require_common2();
3172
+ var assert = require_minimalistic_assert();
3173
+ var sum32 = utils.sum32;
3174
+ var sum32_4 = utils.sum32_4;
3175
+ var sum32_5 = utils.sum32_5;
3176
+ var ch32 = shaCommon.ch32;
3177
+ var maj32 = shaCommon.maj32;
3178
+ var s0_256 = shaCommon.s0_256;
3179
+ var s1_256 = shaCommon.s1_256;
3180
+ var g0_256 = shaCommon.g0_256;
3181
+ var g1_256 = shaCommon.g1_256;
3182
+ var BlockHash = common.BlockHash;
3183
+ var sha256_K = [
3184
+ 1116352408,
3185
+ 1899447441,
3186
+ 3049323471,
3187
+ 3921009573,
3188
+ 961987163,
3189
+ 1508970993,
3190
+ 2453635748,
3191
+ 2870763221,
3192
+ 3624381080,
3193
+ 310598401,
3194
+ 607225278,
3195
+ 1426881987,
3196
+ 1925078388,
3197
+ 2162078206,
3198
+ 2614888103,
3199
+ 3248222580,
3200
+ 3835390401,
3201
+ 4022224774,
3202
+ 264347078,
3203
+ 604807628,
3204
+ 770255983,
3205
+ 1249150122,
3206
+ 1555081692,
3207
+ 1996064986,
3208
+ 2554220882,
3209
+ 2821834349,
3210
+ 2952996808,
3211
+ 3210313671,
3212
+ 3336571891,
3213
+ 3584528711,
3214
+ 113926993,
3215
+ 338241895,
3216
+ 666307205,
3217
+ 773529912,
3218
+ 1294757372,
3219
+ 1396182291,
3220
+ 1695183700,
3221
+ 1986661051,
3222
+ 2177026350,
3223
+ 2456956037,
3224
+ 2730485921,
3225
+ 2820302411,
3226
+ 3259730800,
3227
+ 3345764771,
3228
+ 3516065817,
3229
+ 3600352804,
3230
+ 4094571909,
3231
+ 275423344,
3232
+ 430227734,
3233
+ 506948616,
3234
+ 659060556,
3235
+ 883997877,
3236
+ 958139571,
3237
+ 1322822218,
3238
+ 1537002063,
3239
+ 1747873779,
3240
+ 1955562222,
3241
+ 2024104815,
3242
+ 2227730452,
3243
+ 2361852424,
3244
+ 2428436474,
3245
+ 2756734187,
3246
+ 3204031479,
3247
+ 3329325298
3248
+ ];
3249
+ function SHA256() {
3250
+ if (!(this instanceof SHA256))
3251
+ return new SHA256();
3252
+ BlockHash.call(this);
3253
+ this.h = [
3254
+ 1779033703,
3255
+ 3144134277,
3256
+ 1013904242,
3257
+ 2773480762,
3258
+ 1359893119,
3259
+ 2600822924,
3260
+ 528734635,
3261
+ 1541459225
3262
+ ];
3263
+ this.k = sha256_K;
3264
+ this.W = new Array(64);
3265
+ }
3266
+ utils.inherits(SHA256, BlockHash);
3267
+ module2.exports = SHA256;
3268
+ SHA256.blockSize = 512;
3269
+ SHA256.outSize = 256;
3270
+ SHA256.hmacStrength = 192;
3271
+ SHA256.padLength = 64;
3272
+ SHA256.prototype._update = function _update(msg, start) {
3273
+ var W = this.W;
3274
+ for (var i = 0; i < 16; i++)
3275
+ W[i] = msg[start + i];
3276
+ for (; i < W.length; i++)
3277
+ W[i] = sum32_4(g1_256(W[i - 2]), W[i - 7], g0_256(W[i - 15]), W[i - 16]);
3278
+ var a = this.h[0];
3279
+ var b = this.h[1];
3280
+ var c = this.h[2];
3281
+ var d = this.h[3];
3282
+ var e = this.h[4];
3283
+ var f = this.h[5];
3284
+ var g = this.h[6];
3285
+ var h = this.h[7];
3286
+ assert(this.k.length === W.length);
3287
+ for (i = 0; i < W.length; i++) {
3288
+ var T1 = sum32_5(h, s1_256(e), ch32(e, f, g), this.k[i], W[i]);
3289
+ var T2 = sum32(s0_256(a), maj32(a, b, c));
3290
+ h = g;
3291
+ g = f;
3292
+ f = e;
3293
+ e = sum32(d, T1);
3294
+ d = c;
3295
+ c = b;
3296
+ b = a;
3297
+ a = sum32(T1, T2);
3298
+ }
3299
+ this.h[0] = sum32(this.h[0], a);
3300
+ this.h[1] = sum32(this.h[1], b);
3301
+ this.h[2] = sum32(this.h[2], c);
3302
+ this.h[3] = sum32(this.h[3], d);
3303
+ this.h[4] = sum32(this.h[4], e);
3304
+ this.h[5] = sum32(this.h[5], f);
3305
+ this.h[6] = sum32(this.h[6], g);
3306
+ this.h[7] = sum32(this.h[7], h);
3307
+ };
3308
+ SHA256.prototype._digest = function digest(enc) {
3309
+ if (enc === "hex")
3310
+ return utils.toHex32(this.h, "big");
3311
+ else
3312
+ return utils.split32(this.h, "big");
3313
+ };
3314
+ }
3315
+ });
3316
+
3317
+ // ../../node_modules/hash.js/lib/hash/sha/224.js
3318
+ var require__3 = __commonJS({
3319
+ "../../node_modules/hash.js/lib/hash/sha/224.js"(exports2, module2) {
3320
+ "use strict";
3321
+ var utils = require_utils();
3322
+ var SHA256 = require__2();
3323
+ function SHA224() {
3324
+ if (!(this instanceof SHA224))
3325
+ return new SHA224();
3326
+ SHA256.call(this);
3327
+ this.h = [
3328
+ 3238371032,
3329
+ 914150663,
3330
+ 812702999,
3331
+ 4144912697,
3332
+ 4290775857,
3333
+ 1750603025,
3334
+ 1694076839,
3335
+ 3204075428
3336
+ ];
3337
+ }
3338
+ utils.inherits(SHA224, SHA256);
3339
+ module2.exports = SHA224;
3340
+ SHA224.blockSize = 512;
3341
+ SHA224.outSize = 224;
3342
+ SHA224.hmacStrength = 192;
3343
+ SHA224.padLength = 64;
3344
+ SHA224.prototype._digest = function digest(enc) {
3345
+ if (enc === "hex")
3346
+ return utils.toHex32(this.h.slice(0, 7), "big");
3347
+ else
3348
+ return utils.split32(this.h.slice(0, 7), "big");
3349
+ };
3350
+ }
3351
+ });
3352
+
3353
+ // ../../node_modules/hash.js/lib/hash/sha/512.js
3354
+ var require__4 = __commonJS({
3355
+ "../../node_modules/hash.js/lib/hash/sha/512.js"(exports2, module2) {
3356
+ "use strict";
3357
+ var utils = require_utils();
3358
+ var common = require_common();
3359
+ var assert = require_minimalistic_assert();
3360
+ var rotr64_hi = utils.rotr64_hi;
3361
+ var rotr64_lo = utils.rotr64_lo;
3362
+ var shr64_hi = utils.shr64_hi;
3363
+ var shr64_lo = utils.shr64_lo;
3364
+ var sum64 = utils.sum64;
3365
+ var sum64_hi = utils.sum64_hi;
3366
+ var sum64_lo = utils.sum64_lo;
3367
+ var sum64_4_hi = utils.sum64_4_hi;
3368
+ var sum64_4_lo = utils.sum64_4_lo;
3369
+ var sum64_5_hi = utils.sum64_5_hi;
3370
+ var sum64_5_lo = utils.sum64_5_lo;
3371
+ var BlockHash = common.BlockHash;
3372
+ var sha512_K = [
3373
+ 1116352408,
3374
+ 3609767458,
3375
+ 1899447441,
3376
+ 602891725,
3377
+ 3049323471,
3378
+ 3964484399,
3379
+ 3921009573,
3380
+ 2173295548,
3381
+ 961987163,
3382
+ 4081628472,
3383
+ 1508970993,
3384
+ 3053834265,
3385
+ 2453635748,
3386
+ 2937671579,
3387
+ 2870763221,
3388
+ 3664609560,
3389
+ 3624381080,
3390
+ 2734883394,
3391
+ 310598401,
3392
+ 1164996542,
3393
+ 607225278,
3394
+ 1323610764,
3395
+ 1426881987,
3396
+ 3590304994,
3397
+ 1925078388,
3398
+ 4068182383,
3399
+ 2162078206,
3400
+ 991336113,
3401
+ 2614888103,
3402
+ 633803317,
3403
+ 3248222580,
3404
+ 3479774868,
3405
+ 3835390401,
3406
+ 2666613458,
3407
+ 4022224774,
3408
+ 944711139,
3409
+ 264347078,
3410
+ 2341262773,
3411
+ 604807628,
3412
+ 2007800933,
3413
+ 770255983,
3414
+ 1495990901,
3415
+ 1249150122,
3416
+ 1856431235,
3417
+ 1555081692,
3418
+ 3175218132,
3419
+ 1996064986,
3420
+ 2198950837,
3421
+ 2554220882,
3422
+ 3999719339,
3423
+ 2821834349,
3424
+ 766784016,
3425
+ 2952996808,
3426
+ 2566594879,
3427
+ 3210313671,
3428
+ 3203337956,
3429
+ 3336571891,
3430
+ 1034457026,
3431
+ 3584528711,
3432
+ 2466948901,
3433
+ 113926993,
3434
+ 3758326383,
3435
+ 338241895,
3436
+ 168717936,
3437
+ 666307205,
3438
+ 1188179964,
3439
+ 773529912,
3440
+ 1546045734,
3441
+ 1294757372,
3442
+ 1522805485,
3443
+ 1396182291,
3444
+ 2643833823,
3445
+ 1695183700,
3446
+ 2343527390,
3447
+ 1986661051,
3448
+ 1014477480,
3449
+ 2177026350,
3450
+ 1206759142,
3451
+ 2456956037,
3452
+ 344077627,
3453
+ 2730485921,
3454
+ 1290863460,
3455
+ 2820302411,
3456
+ 3158454273,
3457
+ 3259730800,
3458
+ 3505952657,
3459
+ 3345764771,
3460
+ 106217008,
3461
+ 3516065817,
3462
+ 3606008344,
3463
+ 3600352804,
3464
+ 1432725776,
3465
+ 4094571909,
3466
+ 1467031594,
3467
+ 275423344,
3468
+ 851169720,
3469
+ 430227734,
3470
+ 3100823752,
3471
+ 506948616,
3472
+ 1363258195,
3473
+ 659060556,
3474
+ 3750685593,
3475
+ 883997877,
3476
+ 3785050280,
3477
+ 958139571,
3478
+ 3318307427,
3479
+ 1322822218,
3480
+ 3812723403,
3481
+ 1537002063,
3482
+ 2003034995,
3483
+ 1747873779,
3484
+ 3602036899,
3485
+ 1955562222,
3486
+ 1575990012,
3487
+ 2024104815,
3488
+ 1125592928,
3489
+ 2227730452,
3490
+ 2716904306,
3491
+ 2361852424,
3492
+ 442776044,
3493
+ 2428436474,
3494
+ 593698344,
3495
+ 2756734187,
3496
+ 3733110249,
3497
+ 3204031479,
3498
+ 2999351573,
3499
+ 3329325298,
3500
+ 3815920427,
3501
+ 3391569614,
3502
+ 3928383900,
3503
+ 3515267271,
3504
+ 566280711,
3505
+ 3940187606,
3506
+ 3454069534,
3507
+ 4118630271,
3508
+ 4000239992,
3509
+ 116418474,
3510
+ 1914138554,
3511
+ 174292421,
3512
+ 2731055270,
3513
+ 289380356,
3514
+ 3203993006,
3515
+ 460393269,
3516
+ 320620315,
3517
+ 685471733,
3518
+ 587496836,
3519
+ 852142971,
3520
+ 1086792851,
3521
+ 1017036298,
3522
+ 365543100,
3523
+ 1126000580,
3524
+ 2618297676,
3525
+ 1288033470,
3526
+ 3409855158,
3527
+ 1501505948,
3528
+ 4234509866,
3529
+ 1607167915,
3530
+ 987167468,
3531
+ 1816402316,
3532
+ 1246189591
3533
+ ];
3534
+ function SHA512() {
3535
+ if (!(this instanceof SHA512))
3536
+ return new SHA512();
3537
+ BlockHash.call(this);
3538
+ this.h = [
3539
+ 1779033703,
3540
+ 4089235720,
3541
+ 3144134277,
3542
+ 2227873595,
3543
+ 1013904242,
3544
+ 4271175723,
3545
+ 2773480762,
3546
+ 1595750129,
3547
+ 1359893119,
3548
+ 2917565137,
3549
+ 2600822924,
3550
+ 725511199,
3551
+ 528734635,
3552
+ 4215389547,
3553
+ 1541459225,
3554
+ 327033209
3555
+ ];
3556
+ this.k = sha512_K;
3557
+ this.W = new Array(160);
3558
+ }
3559
+ utils.inherits(SHA512, BlockHash);
3560
+ module2.exports = SHA512;
3561
+ SHA512.blockSize = 1024;
3562
+ SHA512.outSize = 512;
3563
+ SHA512.hmacStrength = 192;
3564
+ SHA512.padLength = 128;
3565
+ SHA512.prototype._prepareBlock = function _prepareBlock(msg, start) {
3566
+ var W = this.W;
3567
+ for (var i = 0; i < 32; i++)
3568
+ W[i] = msg[start + i];
3569
+ for (; i < W.length; i += 2) {
3570
+ var c0_hi = g1_512_hi(W[i - 4], W[i - 3]);
3571
+ var c0_lo = g1_512_lo(W[i - 4], W[i - 3]);
3572
+ var c1_hi = W[i - 14];
3573
+ var c1_lo = W[i - 13];
3574
+ var c2_hi = g0_512_hi(W[i - 30], W[i - 29]);
3575
+ var c2_lo = g0_512_lo(W[i - 30], W[i - 29]);
3576
+ var c3_hi = W[i - 32];
3577
+ var c3_lo = W[i - 31];
3578
+ W[i] = sum64_4_hi(
3579
+ c0_hi,
3580
+ c0_lo,
3581
+ c1_hi,
3582
+ c1_lo,
3583
+ c2_hi,
3584
+ c2_lo,
3585
+ c3_hi,
3586
+ c3_lo
3587
+ );
3588
+ W[i + 1] = sum64_4_lo(
3589
+ c0_hi,
3590
+ c0_lo,
3591
+ c1_hi,
3592
+ c1_lo,
3593
+ c2_hi,
3594
+ c2_lo,
3595
+ c3_hi,
3596
+ c3_lo
3597
+ );
3598
+ }
3599
+ };
3600
+ SHA512.prototype._update = function _update(msg, start) {
3601
+ this._prepareBlock(msg, start);
3602
+ var W = this.W;
3603
+ var ah = this.h[0];
3604
+ var al = this.h[1];
3605
+ var bh = this.h[2];
3606
+ var bl = this.h[3];
3607
+ var ch = this.h[4];
3608
+ var cl = this.h[5];
3609
+ var dh = this.h[6];
3610
+ var dl = this.h[7];
3611
+ var eh = this.h[8];
3612
+ var el = this.h[9];
3613
+ var fh = this.h[10];
3614
+ var fl = this.h[11];
3615
+ var gh = this.h[12];
3616
+ var gl = this.h[13];
3617
+ var hh = this.h[14];
3618
+ var hl = this.h[15];
3619
+ assert(this.k.length === W.length);
3620
+ for (var i = 0; i < W.length; i += 2) {
3621
+ var c0_hi = hh;
3622
+ var c0_lo = hl;
3623
+ var c1_hi = s1_512_hi(eh, el);
3624
+ var c1_lo = s1_512_lo(eh, el);
3625
+ var c2_hi = ch64_hi(eh, el, fh, fl, gh, gl);
3626
+ var c2_lo = ch64_lo(eh, el, fh, fl, gh, gl);
3627
+ var c3_hi = this.k[i];
3628
+ var c3_lo = this.k[i + 1];
3629
+ var c4_hi = W[i];
3630
+ var c4_lo = W[i + 1];
3631
+ var T1_hi = sum64_5_hi(
3632
+ c0_hi,
3633
+ c0_lo,
3634
+ c1_hi,
3635
+ c1_lo,
3636
+ c2_hi,
3637
+ c2_lo,
3638
+ c3_hi,
3639
+ c3_lo,
3640
+ c4_hi,
3641
+ c4_lo
3642
+ );
3643
+ var T1_lo = sum64_5_lo(
3644
+ c0_hi,
3645
+ c0_lo,
3646
+ c1_hi,
3647
+ c1_lo,
3648
+ c2_hi,
3649
+ c2_lo,
3650
+ c3_hi,
3651
+ c3_lo,
3652
+ c4_hi,
3653
+ c4_lo
3654
+ );
3655
+ c0_hi = s0_512_hi(ah, al);
3656
+ c0_lo = s0_512_lo(ah, al);
3657
+ c1_hi = maj64_hi(ah, al, bh, bl, ch, cl);
3658
+ c1_lo = maj64_lo(ah, al, bh, bl, ch, cl);
3659
+ var T2_hi = sum64_hi(c0_hi, c0_lo, c1_hi, c1_lo);
3660
+ var T2_lo = sum64_lo(c0_hi, c0_lo, c1_hi, c1_lo);
3661
+ hh = gh;
3662
+ hl = gl;
3663
+ gh = fh;
3664
+ gl = fl;
3665
+ fh = eh;
3666
+ fl = el;
3667
+ eh = sum64_hi(dh, dl, T1_hi, T1_lo);
3668
+ el = sum64_lo(dl, dl, T1_hi, T1_lo);
3669
+ dh = ch;
3670
+ dl = cl;
3671
+ ch = bh;
3672
+ cl = bl;
3673
+ bh = ah;
3674
+ bl = al;
3675
+ ah = sum64_hi(T1_hi, T1_lo, T2_hi, T2_lo);
3676
+ al = sum64_lo(T1_hi, T1_lo, T2_hi, T2_lo);
3677
+ }
3678
+ sum64(this.h, 0, ah, al);
3679
+ sum64(this.h, 2, bh, bl);
3680
+ sum64(this.h, 4, ch, cl);
3681
+ sum64(this.h, 6, dh, dl);
3682
+ sum64(this.h, 8, eh, el);
3683
+ sum64(this.h, 10, fh, fl);
3684
+ sum64(this.h, 12, gh, gl);
3685
+ sum64(this.h, 14, hh, hl);
3686
+ };
3687
+ SHA512.prototype._digest = function digest(enc) {
3688
+ if (enc === "hex")
3689
+ return utils.toHex32(this.h, "big");
3690
+ else
3691
+ return utils.split32(this.h, "big");
3692
+ };
3693
+ function ch64_hi(xh, xl, yh, yl, zh) {
3694
+ var r = xh & yh ^ ~xh & zh;
3695
+ if (r < 0)
3696
+ r += 4294967296;
3697
+ return r;
3698
+ }
3699
+ function ch64_lo(xh, xl, yh, yl, zh, zl) {
3700
+ var r = xl & yl ^ ~xl & zl;
3701
+ if (r < 0)
3702
+ r += 4294967296;
3703
+ return r;
3704
+ }
3705
+ function maj64_hi(xh, xl, yh, yl, zh) {
3706
+ var r = xh & yh ^ xh & zh ^ yh & zh;
3707
+ if (r < 0)
3708
+ r += 4294967296;
3709
+ return r;
3710
+ }
3711
+ function maj64_lo(xh, xl, yh, yl, zh, zl) {
3712
+ var r = xl & yl ^ xl & zl ^ yl & zl;
3713
+ if (r < 0)
3714
+ r += 4294967296;
3715
+ return r;
3716
+ }
3717
+ function s0_512_hi(xh, xl) {
3718
+ var c0_hi = rotr64_hi(xh, xl, 28);
3719
+ var c1_hi = rotr64_hi(xl, xh, 2);
3720
+ var c2_hi = rotr64_hi(xl, xh, 7);
3721
+ var r = c0_hi ^ c1_hi ^ c2_hi;
3722
+ if (r < 0)
3723
+ r += 4294967296;
3724
+ return r;
3725
+ }
3726
+ function s0_512_lo(xh, xl) {
3727
+ var c0_lo = rotr64_lo(xh, xl, 28);
3728
+ var c1_lo = rotr64_lo(xl, xh, 2);
3729
+ var c2_lo = rotr64_lo(xl, xh, 7);
3730
+ var r = c0_lo ^ c1_lo ^ c2_lo;
3731
+ if (r < 0)
3732
+ r += 4294967296;
3733
+ return r;
3734
+ }
3735
+ function s1_512_hi(xh, xl) {
3736
+ var c0_hi = rotr64_hi(xh, xl, 14);
3737
+ var c1_hi = rotr64_hi(xh, xl, 18);
3738
+ var c2_hi = rotr64_hi(xl, xh, 9);
3739
+ var r = c0_hi ^ c1_hi ^ c2_hi;
3740
+ if (r < 0)
3741
+ r += 4294967296;
3742
+ return r;
3743
+ }
3744
+ function s1_512_lo(xh, xl) {
3745
+ var c0_lo = rotr64_lo(xh, xl, 14);
3746
+ var c1_lo = rotr64_lo(xh, xl, 18);
3747
+ var c2_lo = rotr64_lo(xl, xh, 9);
3748
+ var r = c0_lo ^ c1_lo ^ c2_lo;
3749
+ if (r < 0)
3750
+ r += 4294967296;
3751
+ return r;
3752
+ }
3753
+ function g0_512_hi(xh, xl) {
3754
+ var c0_hi = rotr64_hi(xh, xl, 1);
3755
+ var c1_hi = rotr64_hi(xh, xl, 8);
3756
+ var c2_hi = shr64_hi(xh, xl, 7);
3757
+ var r = c0_hi ^ c1_hi ^ c2_hi;
3758
+ if (r < 0)
3759
+ r += 4294967296;
3760
+ return r;
3761
+ }
3762
+ function g0_512_lo(xh, xl) {
3763
+ var c0_lo = rotr64_lo(xh, xl, 1);
3764
+ var c1_lo = rotr64_lo(xh, xl, 8);
3765
+ var c2_lo = shr64_lo(xh, xl, 7);
3766
+ var r = c0_lo ^ c1_lo ^ c2_lo;
3767
+ if (r < 0)
3768
+ r += 4294967296;
3769
+ return r;
3770
+ }
3771
+ function g1_512_hi(xh, xl) {
3772
+ var c0_hi = rotr64_hi(xh, xl, 19);
3773
+ var c1_hi = rotr64_hi(xl, xh, 29);
3774
+ var c2_hi = shr64_hi(xh, xl, 6);
3775
+ var r = c0_hi ^ c1_hi ^ c2_hi;
3776
+ if (r < 0)
3777
+ r += 4294967296;
3778
+ return r;
3779
+ }
3780
+ function g1_512_lo(xh, xl) {
3781
+ var c0_lo = rotr64_lo(xh, xl, 19);
3782
+ var c1_lo = rotr64_lo(xl, xh, 29);
3783
+ var c2_lo = shr64_lo(xh, xl, 6);
3784
+ var r = c0_lo ^ c1_lo ^ c2_lo;
3785
+ if (r < 0)
3786
+ r += 4294967296;
3787
+ return r;
3788
+ }
3789
+ }
3790
+ });
3791
+
3792
+ // ../../node_modules/hash.js/lib/hash/sha/384.js
3793
+ var require__5 = __commonJS({
3794
+ "../../node_modules/hash.js/lib/hash/sha/384.js"(exports2, module2) {
3795
+ "use strict";
3796
+ var utils = require_utils();
3797
+ var SHA512 = require__4();
3798
+ function SHA384() {
3799
+ if (!(this instanceof SHA384))
3800
+ return new SHA384();
3801
+ SHA512.call(this);
3802
+ this.h = [
3803
+ 3418070365,
3804
+ 3238371032,
3805
+ 1654270250,
3806
+ 914150663,
3807
+ 2438529370,
3808
+ 812702999,
3809
+ 355462360,
3810
+ 4144912697,
3811
+ 1731405415,
3812
+ 4290775857,
3813
+ 2394180231,
3814
+ 1750603025,
3815
+ 3675008525,
3816
+ 1694076839,
3817
+ 1203062813,
3818
+ 3204075428
3819
+ ];
3820
+ }
3821
+ utils.inherits(SHA384, SHA512);
3822
+ module2.exports = SHA384;
3823
+ SHA384.blockSize = 1024;
3824
+ SHA384.outSize = 384;
3825
+ SHA384.hmacStrength = 192;
3826
+ SHA384.padLength = 128;
3827
+ SHA384.prototype._digest = function digest(enc) {
3828
+ if (enc === "hex")
3829
+ return utils.toHex32(this.h.slice(0, 12), "big");
3830
+ else
3831
+ return utils.split32(this.h.slice(0, 12), "big");
3832
+ };
3833
+ }
3834
+ });
3835
+
3836
+ // ../../node_modules/hash.js/lib/hash/sha.js
3837
+ var require_sha = __commonJS({
3838
+ "../../node_modules/hash.js/lib/hash/sha.js"(exports2) {
3839
+ "use strict";
3840
+ exports2.sha1 = require__();
3841
+ exports2.sha224 = require__3();
3842
+ exports2.sha256 = require__2();
3843
+ exports2.sha384 = require__5();
3844
+ exports2.sha512 = require__4();
3845
+ }
3846
+ });
3847
+
3848
+ // ../../node_modules/hash.js/lib/hash/ripemd.js
3849
+ var require_ripemd = __commonJS({
3850
+ "../../node_modules/hash.js/lib/hash/ripemd.js"(exports2) {
3851
+ "use strict";
3852
+ var utils = require_utils();
3853
+ var common = require_common();
3854
+ var rotl32 = utils.rotl32;
3855
+ var sum32 = utils.sum32;
3856
+ var sum32_3 = utils.sum32_3;
3857
+ var sum32_4 = utils.sum32_4;
3858
+ var BlockHash = common.BlockHash;
3859
+ function RIPEMD160() {
3860
+ if (!(this instanceof RIPEMD160))
3861
+ return new RIPEMD160();
3862
+ BlockHash.call(this);
3863
+ this.h = [1732584193, 4023233417, 2562383102, 271733878, 3285377520];
3864
+ this.endian = "little";
3865
+ }
3866
+ utils.inherits(RIPEMD160, BlockHash);
3867
+ exports2.ripemd160 = RIPEMD160;
3868
+ RIPEMD160.blockSize = 512;
3869
+ RIPEMD160.outSize = 160;
3870
+ RIPEMD160.hmacStrength = 192;
3871
+ RIPEMD160.padLength = 64;
3872
+ RIPEMD160.prototype._update = function update(msg, start) {
3873
+ var A = this.h[0];
3874
+ var B = this.h[1];
3875
+ var C = this.h[2];
3876
+ var D = this.h[3];
3877
+ var E = this.h[4];
3878
+ var Ah = A;
3879
+ var Bh = B;
3880
+ var Ch = C;
3881
+ var Dh = D;
3882
+ var Eh = E;
3883
+ for (var j = 0; j < 80; j++) {
3884
+ var T = sum32(
3885
+ rotl32(
3886
+ sum32_4(A, f(j, B, C, D), msg[r[j] + start], K(j)),
3887
+ s[j]
3888
+ ),
3889
+ E
3890
+ );
3891
+ A = E;
3892
+ E = D;
3893
+ D = rotl32(C, 10);
3894
+ C = B;
3895
+ B = T;
3896
+ T = sum32(
3897
+ rotl32(
3898
+ sum32_4(Ah, f(79 - j, Bh, Ch, Dh), msg[rh[j] + start], Kh(j)),
3899
+ sh[j]
3900
+ ),
3901
+ Eh
3902
+ );
3903
+ Ah = Eh;
3904
+ Eh = Dh;
3905
+ Dh = rotl32(Ch, 10);
3906
+ Ch = Bh;
3907
+ Bh = T;
3908
+ }
3909
+ T = sum32_3(this.h[1], C, Dh);
3910
+ this.h[1] = sum32_3(this.h[2], D, Eh);
3911
+ this.h[2] = sum32_3(this.h[3], E, Ah);
3912
+ this.h[3] = sum32_3(this.h[4], A, Bh);
3913
+ this.h[4] = sum32_3(this.h[0], B, Ch);
3914
+ this.h[0] = T;
3915
+ };
3916
+ RIPEMD160.prototype._digest = function digest(enc) {
3917
+ if (enc === "hex")
3918
+ return utils.toHex32(this.h, "little");
3919
+ else
3920
+ return utils.split32(this.h, "little");
3921
+ };
3922
+ function f(j, x, y, z) {
3923
+ if (j <= 15)
3924
+ return x ^ y ^ z;
3925
+ else if (j <= 31)
3926
+ return x & y | ~x & z;
3927
+ else if (j <= 47)
3928
+ return (x | ~y) ^ z;
3929
+ else if (j <= 63)
3930
+ return x & z | y & ~z;
3931
+ else
3932
+ return x ^ (y | ~z);
3933
+ }
3934
+ function K(j) {
3935
+ if (j <= 15)
3936
+ return 0;
3937
+ else if (j <= 31)
3938
+ return 1518500249;
3939
+ else if (j <= 47)
3940
+ return 1859775393;
3941
+ else if (j <= 63)
3942
+ return 2400959708;
3943
+ else
3944
+ return 2840853838;
3945
+ }
3946
+ function Kh(j) {
3947
+ if (j <= 15)
3948
+ return 1352829926;
3949
+ else if (j <= 31)
3950
+ return 1548603684;
3951
+ else if (j <= 47)
3952
+ return 1836072691;
3953
+ else if (j <= 63)
3954
+ return 2053994217;
3955
+ else
3956
+ return 0;
3957
+ }
3958
+ var r = [
3959
+ 0,
3960
+ 1,
3961
+ 2,
3962
+ 3,
3963
+ 4,
3964
+ 5,
3965
+ 6,
3966
+ 7,
3967
+ 8,
3968
+ 9,
3969
+ 10,
3970
+ 11,
3971
+ 12,
3972
+ 13,
3973
+ 14,
3974
+ 15,
3975
+ 7,
3976
+ 4,
3977
+ 13,
3978
+ 1,
3979
+ 10,
3980
+ 6,
3981
+ 15,
3982
+ 3,
3983
+ 12,
3984
+ 0,
3985
+ 9,
3986
+ 5,
3987
+ 2,
3988
+ 14,
3989
+ 11,
3990
+ 8,
3991
+ 3,
3992
+ 10,
3993
+ 14,
3994
+ 4,
3995
+ 9,
3996
+ 15,
3997
+ 8,
3998
+ 1,
3999
+ 2,
4000
+ 7,
4001
+ 0,
4002
+ 6,
4003
+ 13,
4004
+ 11,
4005
+ 5,
4006
+ 12,
4007
+ 1,
4008
+ 9,
4009
+ 11,
4010
+ 10,
4011
+ 0,
4012
+ 8,
4013
+ 12,
4014
+ 4,
4015
+ 13,
4016
+ 3,
4017
+ 7,
4018
+ 15,
4019
+ 14,
4020
+ 5,
4021
+ 6,
4022
+ 2,
4023
+ 4,
4024
+ 0,
4025
+ 5,
4026
+ 9,
4027
+ 7,
4028
+ 12,
4029
+ 2,
4030
+ 10,
4031
+ 14,
4032
+ 1,
4033
+ 3,
4034
+ 8,
4035
+ 11,
4036
+ 6,
4037
+ 15,
4038
+ 13
4039
+ ];
4040
+ var rh = [
4041
+ 5,
4042
+ 14,
4043
+ 7,
4044
+ 0,
4045
+ 9,
4046
+ 2,
4047
+ 11,
4048
+ 4,
4049
+ 13,
4050
+ 6,
4051
+ 15,
4052
+ 8,
4053
+ 1,
4054
+ 10,
4055
+ 3,
4056
+ 12,
4057
+ 6,
4058
+ 11,
4059
+ 3,
4060
+ 7,
4061
+ 0,
4062
+ 13,
4063
+ 5,
4064
+ 10,
4065
+ 14,
4066
+ 15,
4067
+ 8,
4068
+ 12,
4069
+ 4,
4070
+ 9,
4071
+ 1,
4072
+ 2,
4073
+ 15,
4074
+ 5,
4075
+ 1,
4076
+ 3,
4077
+ 7,
4078
+ 14,
4079
+ 6,
4080
+ 9,
4081
+ 11,
4082
+ 8,
4083
+ 12,
4084
+ 2,
4085
+ 10,
4086
+ 0,
4087
+ 4,
4088
+ 13,
4089
+ 8,
4090
+ 6,
4091
+ 4,
4092
+ 1,
4093
+ 3,
4094
+ 11,
4095
+ 15,
4096
+ 0,
4097
+ 5,
4098
+ 12,
4099
+ 2,
4100
+ 13,
4101
+ 9,
4102
+ 7,
4103
+ 10,
4104
+ 14,
4105
+ 12,
4106
+ 15,
4107
+ 10,
4108
+ 4,
4109
+ 1,
4110
+ 5,
4111
+ 8,
4112
+ 7,
4113
+ 6,
4114
+ 2,
4115
+ 13,
4116
+ 14,
4117
+ 0,
4118
+ 3,
4119
+ 9,
4120
+ 11
4121
+ ];
4122
+ var s = [
4123
+ 11,
4124
+ 14,
4125
+ 15,
4126
+ 12,
4127
+ 5,
4128
+ 8,
4129
+ 7,
4130
+ 9,
4131
+ 11,
4132
+ 13,
4133
+ 14,
4134
+ 15,
4135
+ 6,
4136
+ 7,
4137
+ 9,
4138
+ 8,
4139
+ 7,
4140
+ 6,
4141
+ 8,
4142
+ 13,
4143
+ 11,
4144
+ 9,
4145
+ 7,
4146
+ 15,
4147
+ 7,
4148
+ 12,
4149
+ 15,
4150
+ 9,
4151
+ 11,
4152
+ 7,
4153
+ 13,
4154
+ 12,
4155
+ 11,
4156
+ 13,
4157
+ 6,
4158
+ 7,
4159
+ 14,
4160
+ 9,
4161
+ 13,
4162
+ 15,
4163
+ 14,
4164
+ 8,
4165
+ 13,
4166
+ 6,
4167
+ 5,
4168
+ 12,
4169
+ 7,
4170
+ 5,
4171
+ 11,
4172
+ 12,
4173
+ 14,
4174
+ 15,
4175
+ 14,
4176
+ 15,
4177
+ 9,
4178
+ 8,
4179
+ 9,
4180
+ 14,
4181
+ 5,
4182
+ 6,
4183
+ 8,
4184
+ 6,
4185
+ 5,
4186
+ 12,
4187
+ 9,
4188
+ 15,
4189
+ 5,
4190
+ 11,
4191
+ 6,
4192
+ 8,
4193
+ 13,
4194
+ 12,
4195
+ 5,
4196
+ 12,
4197
+ 13,
4198
+ 14,
4199
+ 11,
4200
+ 8,
4201
+ 5,
4202
+ 6
4203
+ ];
4204
+ var sh = [
4205
+ 8,
4206
+ 9,
4207
+ 9,
4208
+ 11,
4209
+ 13,
4210
+ 15,
4211
+ 15,
4212
+ 5,
4213
+ 7,
4214
+ 7,
4215
+ 8,
4216
+ 11,
4217
+ 14,
4218
+ 14,
4219
+ 12,
4220
+ 6,
4221
+ 9,
4222
+ 13,
4223
+ 15,
4224
+ 7,
4225
+ 12,
4226
+ 8,
4227
+ 9,
4228
+ 11,
4229
+ 7,
4230
+ 7,
4231
+ 12,
4232
+ 7,
4233
+ 6,
4234
+ 15,
4235
+ 13,
4236
+ 11,
4237
+ 9,
4238
+ 7,
4239
+ 15,
4240
+ 11,
4241
+ 8,
4242
+ 6,
4243
+ 6,
4244
+ 14,
4245
+ 12,
4246
+ 13,
4247
+ 5,
4248
+ 14,
4249
+ 13,
4250
+ 13,
4251
+ 7,
4252
+ 5,
4253
+ 15,
4254
+ 5,
4255
+ 8,
4256
+ 11,
4257
+ 14,
4258
+ 14,
4259
+ 6,
4260
+ 14,
4261
+ 6,
4262
+ 9,
4263
+ 12,
4264
+ 9,
4265
+ 12,
4266
+ 5,
4267
+ 15,
4268
+ 8,
4269
+ 8,
4270
+ 5,
4271
+ 12,
4272
+ 9,
4273
+ 12,
4274
+ 5,
4275
+ 14,
4276
+ 6,
4277
+ 8,
4278
+ 13,
4279
+ 6,
4280
+ 5,
4281
+ 15,
4282
+ 13,
4283
+ 11,
4284
+ 11
4285
+ ];
4286
+ }
4287
+ });
4288
+
4289
+ // ../../node_modules/hash.js/lib/hash/hmac.js
4290
+ var require_hmac = __commonJS({
4291
+ "../../node_modules/hash.js/lib/hash/hmac.js"(exports2, module2) {
4292
+ "use strict";
4293
+ var utils = require_utils();
4294
+ var assert = require_minimalistic_assert();
4295
+ function Hmac(hash2, key, enc) {
4296
+ if (!(this instanceof Hmac))
4297
+ return new Hmac(hash2, key, enc);
4298
+ this.Hash = hash2;
4299
+ this.blockSize = hash2.blockSize / 8;
4300
+ this.outSize = hash2.outSize / 8;
4301
+ this.inner = null;
4302
+ this.outer = null;
4303
+ this._init(utils.toArray(key, enc));
4304
+ }
4305
+ module2.exports = Hmac;
4306
+ Hmac.prototype._init = function init(key) {
4307
+ if (key.length > this.blockSize)
4308
+ key = new this.Hash().update(key).digest();
4309
+ assert(key.length <= this.blockSize);
4310
+ for (var i = key.length; i < this.blockSize; i++)
4311
+ key.push(0);
4312
+ for (i = 0; i < key.length; i++)
4313
+ key[i] ^= 54;
4314
+ this.inner = new this.Hash().update(key);
4315
+ for (i = 0; i < key.length; i++)
4316
+ key[i] ^= 106;
4317
+ this.outer = new this.Hash().update(key);
4318
+ };
4319
+ Hmac.prototype.update = function update(msg, enc) {
4320
+ this.inner.update(msg, enc);
4321
+ return this;
4322
+ };
4323
+ Hmac.prototype.digest = function digest(enc) {
4324
+ this.outer.update(this.inner.digest());
4325
+ return this.outer.digest(enc);
4326
+ };
4327
+ }
4328
+ });
4329
+
4330
+ // ../../node_modules/hash.js/lib/hash.js
4331
+ var require_hash = __commonJS({
4332
+ "../../node_modules/hash.js/lib/hash.js"(exports2) {
4333
+ "use strict";
4334
+ var hash2 = exports2;
4335
+ hash2.utils = require_utils();
4336
+ hash2.common = require_common();
4337
+ hash2.sha = require_sha();
4338
+ hash2.ripemd = require_ripemd();
4339
+ hash2.hmac = require_hmac();
4340
+ hash2.sha1 = hash2.sha.sha1;
4341
+ hash2.sha256 = hash2.sha.sha256;
4342
+ hash2.sha224 = hash2.sha.sha224;
4343
+ hash2.sha384 = hash2.sha.sha384;
4344
+ hash2.sha512 = hash2.sha.sha512;
4345
+ hash2.ripemd160 = hash2.ripemd.ripemd160;
4346
+ }
4347
+ });
4348
+
895
4349
  // src/index.ts
896
4350
  var index_exports = {};
897
4351
  __export(index_exports, {
@@ -904,6 +4358,8 @@ __export(index_exports, {
904
4358
  BaseAddress: () => BaseAddress,
905
4359
  Bip32PrivateKey: () => Bip32PrivateKey2,
906
4360
  Bip32PrivateKeyHex: () => Bip32PrivateKeyHex2,
4361
+ Bip32PublicKey: () => Bip32PublicKey2,
4362
+ Bip32PublicKeyHex: () => Bip32PublicKeyHex2,
907
4363
  Cardano: () => import_core8.Cardano,
908
4364
  CardanoSDK: () => CardanoSDK,
909
4365
  CardanoSDKSerializer: () => CardanoSDKSerializer,
@@ -928,6 +4384,7 @@ __export(index_exports, {
928
4384
  Ed25519KeyHash: () => Ed25519KeyHash2,
929
4385
  Ed25519KeyHashHex: () => Ed25519KeyHashHex2,
930
4386
  Ed25519PrivateExtendedKeyHex: () => Ed25519PrivateExtendedKeyHex,
4387
+ Ed25519PrivateKey: () => Ed25519PrivateKey2,
931
4388
  Ed25519PrivateNormalKeyHex: () => Ed25519PrivateNormalKeyHex,
932
4389
  Ed25519PublicKey: () => Ed25519PublicKey2,
933
4390
  Ed25519PublicKeyHex: () => Ed25519PublicKeyHex2,
@@ -938,6 +4395,7 @@ __export(index_exports, {
938
4395
  Hash: () => Hash,
939
4396
  Hash28ByteBase16: () => Hash28ByteBase162,
940
4397
  Hash32ByteBase16: () => Hash32ByteBase162,
4398
+ HexBlob: () => HexBlob,
941
4399
  MetadatumList: () => MetadatumList,
942
4400
  MetadatumMap: () => MetadatumMap,
943
4401
  NativeScript: () => NativeScript,
@@ -974,16 +4432,6 @@ __export(index_exports, {
974
4432
  StakeCredentialStatus: () => StakeCredentialStatus,
975
4433
  StakeDelegation: () => StakeDelegation,
976
4434
  StakeRegistration: () => StakeRegistration,
977
- StricaBip32PrivateKey: () => StricaBip32PrivateKey,
978
- StricaBip32PrivateKeyType: () => StricaBip32PrivateKey,
979
- StricaBip32PublicKey: () => StricaBip32PublicKey,
980
- StricaBip32PublicKeyType: () => StricaBip32PublicKey,
981
- StricaDecoder: () => StricaDecoder,
982
- StricaEncoder: () => StricaEncoder,
983
- StricaPrivateKey: () => StricaPrivateKey,
984
- StricaPrivateKeyType: () => StricaPrivateKey,
985
- StricaPublicKey: () => StricaPublicKey,
986
- StricaPublicKeyType: () => StricaPublicKey,
987
4435
  Transaction: () => Transaction,
988
4436
  TransactionBody: () => TransactionBody,
989
4437
  TransactionId: () => TransactionId,
@@ -992,10 +4440,12 @@ __export(index_exports, {
992
4440
  TransactionOutput: () => TransactionOutput,
993
4441
  TransactionUnspentOutput: () => TransactionUnspentOutput,
994
4442
  TransactionWitnessSet: () => TransactionWitnessSet,
4443
+ TxCBOR: () => TxCBOR,
995
4444
  TxIndex: () => TxIndex,
996
4445
  Value: () => Value,
997
4446
  VkeyWitness: () => VkeyWitness,
998
4447
  VrfVkBech32: () => VrfVkBech32,
4448
+ addVKeyWitnessSetToTransaction: () => addVKeyWitnessSetToTransaction,
999
4449
  addrBech32ToPlutusDataHex: () => addrBech32ToPlutusDataHex,
1000
4450
  addrBech32ToPlutusDataObj: () => addrBech32ToPlutusDataObj,
1001
4451
  addressToBech32: () => addressToBech32,
@@ -1006,12 +4456,14 @@ __export(index_exports, {
1006
4456
  buildBaseAddress: () => buildBaseAddress,
1007
4457
  buildBip32PrivateKey: () => buildBip32PrivateKey,
1008
4458
  buildDRepID: () => buildDRepID,
4459
+ buildEd25519PrivateKeyFromSecretKey: () => buildEd25519PrivateKeyFromSecretKey,
1009
4460
  buildEnterpriseAddress: () => buildEnterpriseAddress,
1010
4461
  buildKeys: () => buildKeys,
1011
4462
  buildRewardAddress: () => buildRewardAddress,
1012
4463
  buildScriptPubkey: () => buildScriptPubkey,
1013
4464
  bytesToHex: () => bytesToHex,
1014
4465
  checkSignature: () => checkSignature,
4466
+ clampScalar: () => clampScalar,
1015
4467
  computeAuxiliaryDataHash: () => computeAuxiliaryDataHash,
1016
4468
  deserializeAddress: () => deserializeAddress,
1017
4469
  deserializeBech32Address: () => deserializeBech32Address,
@@ -1142,6 +4594,8 @@ var Ed25519PublicKey2 = Crypto.Ed25519PublicKey;
1142
4594
  var Ed25519Signature2 = Crypto.Ed25519Signature;
1143
4595
  var Bip32PrivateKey2 = Crypto.Bip32PrivateKey;
1144
4596
  var Bip32PrivateKeyHex2 = Crypto.Bip32PrivateKeyHex;
4597
+ var Bip32PublicKey2 = Crypto.Bip32PublicKey;
4598
+ var Bip32PublicKeyHex2 = Crypto.Bip32PublicKeyHex;
1145
4599
  var PlutusLanguageVersion = import_core.Cardano.PlutusLanguageVersion;
1146
4600
  var NativeScript = import_core.Serialization.NativeScript;
1147
4601
  var PlutusV1Script = import_core.Serialization.PlutusV1Script;
@@ -1174,28 +4628,20 @@ var ScriptPubkey = import_core.Serialization.ScriptPubkey;
1174
4628
  var DRepID = import_core.Cardano.DRepID;
1175
4629
  var DRep = import_core.Serialization.DRep;
1176
4630
  var StakeCredentialStatus = import_core.Cardano.StakeCredentialStatus;
4631
+ var HexBlob = import_util.HexBlob;
4632
+ var TxCBOR = import_core.Serialization.TxCBOR;
4633
+ var Ed25519PrivateKey2 = Crypto.Ed25519PrivateKey;
1177
4634
  var computeAuxiliaryDataHash = import_core.Cardano.computeAuxiliaryDataHash;
1178
4635
  var blake2b2 = Crypto.blake2b;
1179
4636
 
1180
- // src/stricahq/bip32ed25519/wrapper.ts
1181
- var cjsBip32ed25519 = __toESM(require("@stricahq/bip32ed25519"), 1);
1182
- var bip32ed25519 = cjsBip32ed25519;
1183
- var exportedBip32ed25519 = bip32ed25519?.default || bip32ed25519;
1184
- var StricaPrivateKey = exportedBip32ed25519.PrivateKey;
1185
- var StricaPublicKey = exportedBip32ed25519.PublicKey;
1186
- var StricaBip32PrivateKey = exportedBip32ed25519.Bip32PrivateKey;
1187
- var StricaBip32PublicKey = exportedBip32ed25519.Bip32PublicKey;
1188
-
1189
- // src/stricahq/cbors/wrapper.ts
1190
- var cjsCbors = __toESM(require("@stricahq/cbors"), 1);
1191
- var cbors = cjsCbors;
1192
- var exportedCbors = cbors?.default || cbors;
1193
- var StricaEncoder = exportedCbors.Encoder;
1194
- var StricaDecoder = exportedCbors.Decoder;
4637
+ // src/message-signing/check-signature.ts
4638
+ var import_crypto = require("@cardano-sdk/crypto");
1195
4639
 
1196
4640
  // src/message-signing/cose-sign1.ts
1197
4641
  var import_buffer = require("buffer");
4642
+ var import_cbor = require("@harmoniclabs/cbor");
1198
4643
  var import_blakejs = __toESM(require_blakejs(), 1);
4644
+ var import_json_bigint = __toESM(require_json_bigint(), 1);
1199
4645
  var CoseSign1 = class _CoseSign1 {
1200
4646
  protectedMap;
1201
4647
  unProtectedMap;
@@ -1205,29 +4651,36 @@ var CoseSign1 = class _CoseSign1 {
1205
4651
  this.protectedMap = payload.protectedMap;
1206
4652
  this.unProtectedMap = payload.unProtectedMap;
1207
4653
  this.payload = payload.payload;
1208
- if (this.unProtectedMap.get("hashed") == null) {
1209
- this.unProtectedMap.set("hashed", false);
4654
+ if (!this.unProtectedMap.map.find((value) => {
4655
+ return import_json_bigint.default.stringify(value.k) === import_json_bigint.default.stringify(new import_cbor.CborText("hashed"));
4656
+ })) {
4657
+ this.unProtectedMap.map.push({
4658
+ k: new import_cbor.CborText("hashed"),
4659
+ v: new import_cbor.CborSimple(false)
4660
+ });
1210
4661
  }
1211
4662
  this.signature = payload.signature;
1212
4663
  }
1213
4664
  static fromCbor(cbor) {
1214
- const decoded = StricaDecoder.decode(import_buffer.Buffer.from(cbor, "hex"));
1215
- if (!(decoded.value instanceof Array)) throw Error("Invalid CBOR");
1216
- if (decoded.value.length !== 4) throw Error("Invalid COSE_SIGN1");
4665
+ const decoded = import_cbor.Cbor.parse(cbor);
4666
+ if (!(0, import_cbor.isRawCborArray)(decoded.toRawObj()))
4667
+ throw Error("Invalid CBOR");
4668
+ if (decoded.array.length !== 4) throw Error("Invalid COSE_SIGN1");
1217
4669
  let protectedMap;
1218
- const protectedSerialized = decoded.value[0];
4670
+ const protectedSerialized = decoded.array[0];
1219
4671
  try {
1220
- protectedMap = StricaDecoder.decode(protectedSerialized).value;
1221
- if (!(protectedMap instanceof Map)) {
4672
+ protectedMap = import_cbor.Cbor.parse(protectedSerialized.bytes);
4673
+ if (!(0, import_cbor.isRawCborMap)(protectedMap.toRawObj())) {
1222
4674
  throw Error();
1223
4675
  }
1224
4676
  } catch (error) {
1225
4677
  throw Error("Invalid protected");
1226
4678
  }
1227
- const unProtectedMap = decoded.value[1];
1228
- if (!(unProtectedMap instanceof Map)) throw Error("Invalid unprotected");
1229
- const payload = decoded.value[2];
1230
- const signature = decoded.value[3];
4679
+ let unProtectedMap = decoded.array[1];
4680
+ if (!(0, import_cbor.isRawCborMap)(unProtectedMap.toRawObj()))
4681
+ throw Error("Invalid unprotected");
4682
+ const payload = decoded.array[2];
4683
+ const signature = decoded.array[3];
1231
4684
  return new _CoseSign1({
1232
4685
  protectedMap,
1233
4686
  unProtectedMap,
@@ -1236,31 +4689,37 @@ var CoseSign1 = class _CoseSign1 {
1236
4689
  });
1237
4690
  }
1238
4691
  createSigStructure(externalAad = import_buffer.Buffer.alloc(0)) {
1239
- let protectedSerialized = import_buffer.Buffer.alloc(0);
1240
- if (this.protectedMap.size !== 0) {
1241
- protectedSerialized = StricaEncoder.encode(this.protectedMap);
4692
+ let protectedSerialized = new import_cbor.CborBytes(import_buffer.Buffer.alloc(0));
4693
+ if (this.protectedMap.map.length !== 0) {
4694
+ protectedSerialized = new import_cbor.CborBytes(
4695
+ import_cbor.Cbor.encode(this.protectedMap).toBuffer()
4696
+ );
1242
4697
  }
1243
- const structure = [
1244
- "Signature1",
4698
+ if (!this.payload) throw Error("Invalid payload");
4699
+ const structure = new import_cbor.CborArray([
4700
+ new import_cbor.CborText("Signature1"),
1245
4701
  protectedSerialized,
1246
- externalAad,
4702
+ new import_cbor.CborBytes(externalAad),
1247
4703
  this.payload
1248
- ];
1249
- return StricaEncoder.encode(structure);
4704
+ ]);
4705
+ return import_buffer.Buffer.from(import_cbor.Cbor.encode(structure).toBuffer());
1250
4706
  }
1251
4707
  buildMessage(signature) {
1252
- this.signature = signature;
1253
- let protectedSerialized = import_buffer.Buffer.alloc(0);
1254
- if (this.protectedMap.size !== 0) {
1255
- protectedSerialized = StricaEncoder.encode(this.protectedMap);
4708
+ this.signature = new import_cbor.CborBytes(signature);
4709
+ let protectedSerialized = new import_cbor.CborBytes(import_buffer.Buffer.alloc(0));
4710
+ if (this.protectedMap.map.length !== 0) {
4711
+ protectedSerialized = new import_cbor.CborBytes(
4712
+ import_cbor.Cbor.encode(this.protectedMap).toBuffer()
4713
+ );
1256
4714
  }
1257
- const coseSign1 = [
4715
+ if (!this.payload) throw Error("Invalid payload");
4716
+ const coseSign1 = new import_cbor.CborArray([
1258
4717
  protectedSerialized,
1259
4718
  this.unProtectedMap,
1260
4719
  this.payload,
1261
4720
  this.signature
1262
- ];
1263
- return StricaEncoder.encode(coseSign1);
4721
+ ]);
4722
+ return import_buffer.Buffer.from(import_cbor.Cbor.encode(coseSign1).toBuffer());
1264
4723
  }
1265
4724
  verifySignature({
1266
4725
  externalAad = import_buffer.Buffer.alloc(0),
@@ -1271,66 +4730,84 @@ var CoseSign1 = class _CoseSign1 {
1271
4730
  }
1272
4731
  if (!publicKeyBuffer) throw Error("Public key not found");
1273
4732
  if (!this.signature) throw Error("Signature not found");
1274
- const publicKey = new StricaPublicKey(publicKeyBuffer);
4733
+ const publicKey = new Ed25519PublicKey2(publicKeyBuffer);
1275
4734
  return publicKey.verify(
1276
- this.signature,
1277
- this.createSigStructure(externalAad)
4735
+ new Ed25519Signature2(this.signature.bytes),
4736
+ HexBlob(
4737
+ import_buffer.Buffer.from(this.createSigStructure(externalAad)).toString("hex")
4738
+ )
1278
4739
  );
1279
4740
  }
1280
4741
  hashPayload() {
1281
4742
  if (!this.unProtectedMap) throw Error("Invalid unprotected map");
1282
4743
  if (!this.payload) throw Error("Invalid payload");
1283
- if (this.unProtectedMap.get("hashed"))
4744
+ const hashedIndex = this.unProtectedMap.map.findIndex((value) => {
4745
+ return import_json_bigint.default.stringify(value.k) === import_json_bigint.default.stringify(new import_cbor.CborText("hashed"));
4746
+ });
4747
+ const hashed = this.unProtectedMap.map[hashedIndex];
4748
+ if (hashed && import_json_bigint.default.stringify(hashed.v) === import_json_bigint.default.stringify(new import_cbor.CborSimple(true)))
1284
4749
  throw Error("Payload already hashed");
1285
- if (this.unProtectedMap.get("hashed") != false)
4750
+ if (hashed && import_json_bigint.default.stringify(hashed.v) === import_json_bigint.default.stringify(new import_cbor.CborSimple(true)) != false)
1286
4751
  throw Error("Invalid unprotected map");
1287
- this.unProtectedMap.set("hashed", true);
1288
- const hash = (0, import_blakejs.blake2b)(this.payload, void 0, 24);
1289
- this.payload = import_buffer.Buffer.from(hash);
4752
+ this.unProtectedMap.map.splice(hashedIndex, 1);
4753
+ const hash2 = (0, import_blakejs.blake2b)(this.payload.bytes, void 0, 24);
4754
+ this.payload = new import_cbor.CborBytes(hash2);
1290
4755
  }
1291
4756
  getAddress() {
1292
- return this.protectedMap.get("address");
4757
+ const address = this.protectedMap.map.find((value) => {
4758
+ return import_json_bigint.default.stringify(value.k) === import_json_bigint.default.stringify(new import_cbor.CborText("address"));
4759
+ });
4760
+ if (!address) throw Error("Address not found");
4761
+ return import_buffer.Buffer.from(address.v.bytes);
1293
4762
  }
1294
4763
  getPublicKey() {
1295
- return this.protectedMap.get(4);
4764
+ const publicKey = this.protectedMap.map.find((value) => {
4765
+ return import_json_bigint.default.stringify(value.k) === import_json_bigint.default.stringify(new import_cbor.CborUInt(4));
4766
+ });
4767
+ if (!publicKey) throw Error("Public key not found");
4768
+ return import_buffer.Buffer.from(publicKey.v.bytes);
1296
4769
  }
1297
4770
  getSignature() {
1298
- return this.signature;
4771
+ return this.signature ? import_buffer.Buffer.from(this.signature.bytes) : this.signature;
1299
4772
  }
1300
4773
  getPayload() {
1301
- return this.payload;
4774
+ return this.payload ? import_buffer.Buffer.from(this.payload.bytes) : this.payload;
1302
4775
  }
1303
4776
  };
1304
4777
  var getPublicKeyFromCoseKey = (cbor) => {
1305
- const decodedCoseKey = StricaDecoder.decode(import_buffer.Buffer.from(cbor, "hex"));
1306
- const publicKeyBuffer = decodedCoseKey.value.get(-2);
1307
- if (publicKeyBuffer) {
1308
- return publicKeyBuffer;
4778
+ const decodedCoseKey = import_cbor.Cbor.parse(cbor);
4779
+ const publicKeyEntry = decodedCoseKey.map.find((value) => {
4780
+ return import_json_bigint.default.stringify(value.k) === import_json_bigint.default.stringify(new import_cbor.CborNegInt(BigInt(-2)));
4781
+ });
4782
+ if (publicKeyEntry) {
4783
+ return import_buffer.Buffer.from(publicKeyEntry.v.bytes);
1309
4784
  }
1310
4785
  throw Error("Public key not found");
1311
4786
  };
1312
4787
  var getCoseKeyFromPublicKey = (cbor) => {
1313
- const coseKeyMap = /* @__PURE__ */ new Map();
1314
- coseKeyMap.set(1, 1);
1315
- coseKeyMap.set(3, -8);
1316
- coseKeyMap.set(6, -2);
1317
- coseKeyMap.set(-2, import_buffer.Buffer.from(cbor, "hex"));
1318
- return StricaEncoder.encode(coseKeyMap);
4788
+ const coseKeyMap = [];
4789
+ coseKeyMap.push({ k: new import_cbor.CborUInt(1), v: new import_cbor.CborUInt(1) });
4790
+ coseKeyMap.push({ k: new import_cbor.CborUInt(3), v: new import_cbor.CborNegInt(-8) });
4791
+ coseKeyMap.push({ k: new import_cbor.CborUInt(6), v: new import_cbor.CborNegInt(-2) });
4792
+ coseKeyMap.push({
4793
+ k: new import_cbor.CborNegInt(-2),
4794
+ v: new import_cbor.CborBytes(import_buffer.Buffer.from(cbor, "hex"))
4795
+ });
4796
+ return import_buffer.Buffer.from(import_cbor.Cbor.encode(new import_cbor.CborMap(coseKeyMap)).toBuffer());
1319
4797
  };
1320
4798
 
1321
4799
  // src/message-signing/check-signature.ts
1322
- var checkSignature = (data, { key, signature }, address) => {
4800
+ var checkSignature = async (data, { key, signature }, address) => {
4801
+ await (0, import_crypto.ready)();
1323
4802
  const builder = CoseSign1.fromCbor(signature);
1324
4803
  const publicKeyBuffer = getPublicKeyFromCoseKey(key);
1325
4804
  if (address) {
1326
4805
  let network = NetworkId.Mainnet;
1327
4806
  const paymentAddress = BaseAddress.fromAddress(Address.fromBech32(address));
1328
- const coseSign1PublicKey = new StricaBip32PublicKey(publicKeyBuffer);
4807
+ const coseSign1PublicKey = Ed25519PublicKey2.fromBytes(publicKeyBuffer);
1329
4808
  const credential = {
1330
4809
  hash: Hash28ByteBase162.fromEd25519KeyHashHex(
1331
- Ed25519KeyHashHex2(
1332
- coseSign1PublicKey.toPublicKey().hash().toString("hex")
1333
- )
4810
+ coseSign1PublicKey.hash().hex()
1334
4811
  ),
1335
4812
  type: 0
1336
4813
  };
@@ -1391,17 +4868,17 @@ var checkSignature = (data, { key, signature }, address) => {
1391
4868
  };
1392
4869
 
1393
4870
  // ../../node_modules/nanoid/index.js
1394
- var import_crypto = __toESM(require("crypto"), 1);
4871
+ var import_crypto2 = __toESM(require("crypto"), 1);
1395
4872
  var POOL_SIZE_MULTIPLIER = 128;
1396
4873
  var pool;
1397
4874
  var poolOffset;
1398
4875
  var fillPool = (bytes) => {
1399
4876
  if (!pool || pool.length < bytes) {
1400
4877
  pool = Buffer.allocUnsafe(bytes * POOL_SIZE_MULTIPLIER);
1401
- import_crypto.default.randomFillSync(pool);
4878
+ import_crypto2.default.randomFillSync(pool);
1402
4879
  poolOffset = 0;
1403
4880
  } else if (poolOffset + bytes > pool.length) {
1404
- import_crypto.default.randomFillSync(pool);
4881
+ import_crypto2.default.randomFillSync(pool);
1405
4882
  poolOffset = 0;
1406
4883
  }
1407
4884
  poolOffset += bytes;
@@ -1441,20 +4918,26 @@ var generateNonce = (label = "", length = 32) => {
1441
4918
  };
1442
4919
 
1443
4920
  // src/message-signing/sign-data.ts
4921
+ var import_cbor2 = require("@harmoniclabs/cbor");
1444
4922
  var signData = (data, signer) => {
1445
4923
  const payload = Buffer.from(data, "hex");
1446
- const publicKey = signer.key.toPublicKey().toBytes();
1447
- const protectedMap = /* @__PURE__ */ new Map();
1448
- protectedMap.set(1, -8);
1449
- protectedMap.set(4, publicKey);
1450
- protectedMap.set("address", Buffer.from(signer.address.toBytes(), "hex"));
4924
+ const publicKey = Buffer.from(signer.key.toPublic().bytes());
4925
+ const protectedMap = [];
4926
+ protectedMap.push({ k: new import_cbor2.CborUInt(1), v: new import_cbor2.CborNegInt(-8) });
4927
+ protectedMap.push({ k: new import_cbor2.CborUInt(4), v: new import_cbor2.CborBytes(publicKey) });
4928
+ protectedMap.push({
4929
+ k: new import_cbor2.CborText("address"),
4930
+ v: new import_cbor2.CborBytes(Buffer.from(signer.address.toBytes(), "hex"))
4931
+ });
1451
4932
  const coseSign1Builder = new CoseSign1({
1452
- protectedMap,
1453
- unProtectedMap: /* @__PURE__ */ new Map(),
1454
- payload
4933
+ protectedMap: new import_cbor2.CborMap(protectedMap),
4934
+ unProtectedMap: new import_cbor2.CborMap([]),
4935
+ payload: new import_cbor2.CborBytes(payload)
1455
4936
  });
1456
- const signature = signer.key.sign(coseSign1Builder.createSigStructure());
1457
- const coseSignature = coseSign1Builder.buildMessage(signature).toString("hex");
4937
+ const signature = signer.key.sign(
4938
+ HexBlob(Buffer.from(coseSign1Builder.createSigStructure()).toString("hex"))
4939
+ );
4940
+ const coseSignature = coseSign1Builder.buildMessage(Buffer.from(signature.bytes())).toString("hex");
1458
4941
  return {
1459
4942
  key: getCoseKeyFromPublicKey(publicKey.toString("hex")).toString("hex"),
1460
4943
  signature: coseSignature
@@ -1463,16 +4946,17 @@ var signData = (data, signer) => {
1463
4946
 
1464
4947
  // src/resolvers/index.ts
1465
4948
  var import_core4 = require("@cardano-sdk/core");
1466
- var import_crypto5 = require("@cardano-sdk/crypto");
4949
+ var import_crypto7 = require("@cardano-sdk/crypto");
1467
4950
  var import_util7 = require("@cardano-sdk/util");
1468
4951
  var import_base32_encoding3 = __toESM(require("base32-encoding"), 1);
1469
4952
  var import_bech323 = require("bech32");
1470
4953
  var import_common7 = require("@meshsdk/common");
1471
4954
 
1472
4955
  // src/utils/builder.ts
1473
- var import_crypto2 = require("@cardano-sdk/crypto");
4956
+ var import_crypto3 = require("@cardano-sdk/crypto");
1474
4957
  var import_util2 = require("@cardano-sdk/util");
1475
- var import_pbkdf2 = require("pbkdf2");
4958
+ var import_hash = __toESM(require_hash(), 1);
4959
+ var import_crypto4 = require("crypto");
1476
4960
  var import_common2 = require("@meshsdk/common");
1477
4961
  var buildBaseAddress = (networkId, paymentKeyHash, stakeKeyHash) => {
1478
4962
  return BaseAddress.fromCredentials(
@@ -1493,22 +4977,22 @@ var buildEnterpriseAddress = (networkId, paymentKeyHash) => {
1493
4977
  type: CredentialType.KeyHash
1494
4978
  });
1495
4979
  };
4980
+ var clampScalar = (scalar) => {
4981
+ if (scalar[0] !== void 0) {
4982
+ scalar[0] &= 248;
4983
+ }
4984
+ if (scalar[31] !== void 0) {
4985
+ scalar[31] &= 31;
4986
+ scalar[31] |= 64;
4987
+ }
4988
+ return scalar;
4989
+ };
1496
4990
  var buildBip32PrivateKey = (entropy, password = "") => {
1497
4991
  const PBKDF2_ITERATIONS = 4096;
1498
4992
  const PBKDF2_KEY_SIZE = 96;
1499
4993
  const PBKDF2_DIGEST_ALGORITHM = "sha512";
1500
- const clampScalar = (scalar) => {
1501
- if (scalar[0] !== void 0) {
1502
- scalar[0] &= 248;
1503
- }
1504
- if (scalar[31] !== void 0) {
1505
- scalar[31] &= 31;
1506
- scalar[31] |= 64;
1507
- }
1508
- return scalar;
1509
- };
1510
4994
  const _entropy = Buffer.from(entropy, "hex");
1511
- const xprv = (0, import_pbkdf2.pbkdf2Sync)(
4995
+ const xprv = (0, import_crypto4.pbkdf2Sync)(
1512
4996
  password,
1513
4997
  _entropy,
1514
4998
  PBKDF2_ITERATIONS,
@@ -1524,31 +5008,47 @@ var buildRewardAddress = (networkId, stakeKeyHash) => {
1524
5008
  };
1525
5009
  return RewardAddress.fromCredentials(networkId, cred);
1526
5010
  };
1527
- var buildKeys = (entropy, accountIndex, keyIndex = 0) => {
1528
- if (typeof entropy === "string") {
1529
- const rootKey = new StricaBip32PrivateKey(Buffer.from(entropy, "hex"));
1530
- const accountKey = rootKey.derive(import_common2.HARDENED_KEY_START + 1852).derive(import_common2.HARDENED_KEY_START + 1815).derive(import_common2.HARDENED_KEY_START + accountIndex);
1531
- const paymentKey = accountKey.derive(0).derive(keyIndex).toPrivateKey();
1532
- const stakeKey = accountKey.derive(2).derive(0).toPrivateKey();
1533
- const dRepKey = accountKey.derive(3).derive(keyIndex).toPrivateKey();
5011
+ var buildKeys = (privateKeyHex, accountIndex, keyIndex = 0) => {
5012
+ if (typeof privateKeyHex === "string") {
5013
+ const privateKey = Bip32PrivateKey2.fromHex(
5014
+ Bip32PrivateKeyHex2(privateKeyHex)
5015
+ );
5016
+ const accountKey = privateKey.derive([
5017
+ import_common2.HARDENED_KEY_START + 1852,
5018
+ // purpose
5019
+ import_common2.HARDENED_KEY_START + 1815,
5020
+ // coin type
5021
+ import_common2.HARDENED_KEY_START + accountIndex
5022
+ // account index
5023
+ ]);
5024
+ const paymentKey = accountKey.derive([0, keyIndex]).toRawKey();
5025
+ const stakeKey = accountKey.derive([2, 0]).toRawKey();
5026
+ const dRepKey = accountKey.derive([3, keyIndex]).toRawKey();
1534
5027
  return { paymentKey, stakeKey, dRepKey };
1535
5028
  } else {
1536
- const paymentKey = StricaPrivateKey.fromSecretKey(
1537
- Buffer.from(entropy[0], "hex")
1538
- );
1539
- const stakeKey = StricaPrivateKey.fromSecretKey(
1540
- Buffer.from(entropy[1], "hex")
1541
- );
5029
+ const paymentKey = buildEd25519PrivateKeyFromSecretKey(privateKeyHex[0]);
5030
+ const stakeKey = buildEd25519PrivateKeyFromSecretKey(privateKeyHex[1]);
1542
5031
  return { paymentKey, stakeKey };
1543
5032
  }
1544
5033
  };
5034
+ var buildEd25519PrivateKeyFromSecretKey = (secretKeyHex) => {
5035
+ return Ed25519PrivateKey2.fromExtendedBytes(
5036
+ new Uint8Array(
5037
+ clampScalar(
5038
+ Buffer.from(
5039
+ import_hash.default.sha512().update(Buffer.from(secretKeyHex, "hex")).digest()
5040
+ )
5041
+ )
5042
+ )
5043
+ );
5044
+ };
1545
5045
  var buildScriptPubkey = (keyHash) => {
1546
5046
  const scriptPubkey = new ScriptPubkey(Ed25519KeyHashHex2(keyHash.hex()));
1547
5047
  return NativeScript.newScriptPubkey(scriptPubkey);
1548
5048
  };
1549
5049
  var buildDRepID = (dRepKey, networkId = NetworkId.Testnet, addressType = AddressType.EnterpriseKey) => {
1550
5050
  const dRepKeyBytes = Buffer.from(dRepKey, "hex");
1551
- const dRepIdHex = (0, import_crypto2.blake2b)(28).update(dRepKeyBytes).digest("hex");
5051
+ const dRepIdHex = (0, import_crypto3.blake2b)(28).update(dRepKeyBytes).digest("hex");
1552
5052
  const paymentAddress = EnterpriseAddress.packParts({
1553
5053
  networkId,
1554
5054
  paymentPart: {
@@ -1565,7 +5065,7 @@ var buildDRepID = (dRepKey, networkId = NetworkId.Testnet, addressType = Address
1565
5065
 
1566
5066
  // src/utils/converter.ts
1567
5067
  var import_core3 = require("@cardano-sdk/core");
1568
- var import_crypto4 = require("@cardano-sdk/crypto");
5068
+ var import_crypto6 = require("@cardano-sdk/crypto");
1569
5069
  var import_util5 = require("@cardano-sdk/util");
1570
5070
  var import_base32_encoding = __toESM(require("base32-encoding"), 1);
1571
5071
  var import_bech32 = require("bech32");
@@ -1699,9 +5199,14 @@ var fromPlutusDataToJson = (data) => {
1699
5199
  const plutusData = data.asConstrPlutusData();
1700
5200
  if (plutusData) {
1701
5201
  const fields = plutusData.getData();
5202
+ const list = [];
5203
+ for (let i = 0; i < fields.getLength(); i++) {
5204
+ const element = fields.get(i);
5205
+ list.push(fromPlutusDataToJson(element));
5206
+ }
1702
5207
  return {
1703
5208
  constructor: plutusData.getAlternative(),
1704
- fields: fromPlutusDataToJson(PlutusData.newList(fields))
5209
+ fields: list
1705
5210
  };
1706
5211
  } else {
1707
5212
  throw new Error("Invalid constructor data found");
@@ -1735,7 +5240,7 @@ var fromPlutusDataToJson = (data) => {
1735
5240
  const element = plutusList.get(i);
1736
5241
  list.push(fromPlutusDataToJson(element));
1737
5242
  }
1738
- return list;
5243
+ return { list };
1739
5244
  } else {
1740
5245
  throw new Error("Invalid list data found");
1741
5246
  }
@@ -1777,7 +5282,7 @@ var deserializePlutusData = (plutusData) => PlutusData.fromCbor((0, import_util3
1777
5282
 
1778
5283
  // src/utils/deserializer.ts
1779
5284
  var import_core2 = require("@cardano-sdk/core");
1780
- var import_crypto3 = require("@cardano-sdk/crypto");
5285
+ var import_crypto5 = require("@cardano-sdk/crypto");
1781
5286
  var import_util4 = require("@cardano-sdk/util");
1782
5287
  var import_common4 = require("@meshsdk/common");
1783
5288
  var deserializeEd25519KeyHash = (ed25519KeyHash) => Ed25519KeyHash2.fromBytes((0, import_common4.toBytes)(ed25519KeyHash));
@@ -1794,7 +5299,7 @@ var deserializePlutusScript = (plutusScript, version) => {
1794
5299
  }
1795
5300
  };
1796
5301
  var deserializeNativeScript = (nativeScript) => NativeScript.fromCbor((0, import_util4.HexBlob)(nativeScript));
1797
- var deserializeScriptHash = (scriptHash) => ScriptHash.fromEd25519KeyHashHex((0, import_crypto3.Ed25519KeyHashHex)(scriptHash));
5302
+ var deserializeScriptHash = (scriptHash) => ScriptHash.fromEd25519KeyHashHex((0, import_crypto5.Ed25519KeyHashHex)(scriptHash));
1798
5303
  var deserializeScriptRef = (scriptRef) => Script.fromCbor((0, import_util4.HexBlob)(scriptRef));
1799
5304
  var deserializeTxUnspentOutput = (txUnspentOutput) => TransactionUnspentOutput.fromCbor((0, import_util4.HexBlob)(txUnspentOutput));
1800
5305
  var deserializeValue = (value) => Value.fromCbor((0, import_util4.HexBlob)(value));
@@ -1810,7 +5315,7 @@ var toCardanoAddress = (address) => {
1810
5315
  try {
1811
5316
  return Address.fromBase58(address);
1812
5317
  } catch {
1813
- throw new Error("Invalid address format");
5318
+ throw new Error(`Invalid address format, ${address}`);
1814
5319
  }
1815
5320
  }
1816
5321
  };
@@ -2026,7 +5531,7 @@ var toNativeScript = (script) => {
2026
5531
  case "sig":
2027
5532
  return NativeScript.newScriptPubkey(
2028
5533
  new import_core3.Serialization.ScriptPubkey(
2029
- import_crypto4.Ed25519KeyHash.fromBytes((0, import_common5.toBytes)(script.keyHash)).hex()
5534
+ import_crypto6.Ed25519KeyHash.fromBytes((0, import_common5.toBytes)(script.keyHash)).hex()
2030
5535
  )
2031
5536
  );
2032
5537
  }
@@ -2340,7 +5845,7 @@ var plutusDataToAddrBech32 = (plutusData, networkId = 0) => {
2340
5845
  return EnterpriseAddress.fromCredentials(
2341
5846
  networkId,
2342
5847
  cardanoPaymentCredential
2343
- ).toAddress().toBech32();
5848
+ ).toAddress().toBech32().toString();
2344
5849
  } else if (delegationConstrData.getAlternative() === BigInt(0)) {
2345
5850
  const delegationDataList = delegationConstrData.getData();
2346
5851
  if (delegationDataList.getLength() !== 1) {
@@ -2376,7 +5881,7 @@ var plutusDataToAddrBech32 = (plutusData, networkId = 0) => {
2376
5881
  networkId,
2377
5882
  cardanoPaymentCredential,
2378
5883
  cardanoStakeCredential
2379
- ).toAddress().toBech32();
5884
+ ).toAddress().toBech32().toString();
2380
5885
  } else if (delegationDataInnerConstrData.getAlternative() === BigInt(1)) {
2381
5886
  const delegationDataInnerList = delegationDataInnerConstrData.getData();
2382
5887
  if (delegationDataInnerList.getLength() !== 3) {
@@ -2411,7 +5916,7 @@ var plutusDataToAddrBech32 = (plutusData, networkId = 0) => {
2411
5916
  networkId,
2412
5917
  cardanoPaymentCredential,
2413
5918
  cardanoPointer
2414
- ).toAddress().toBech32();
5919
+ ).toAddress().toBech32().toString();
2415
5920
  } else {
2416
5921
  throw new Error(
2417
5922
  "Error: serializeAddressObj: Delegation inner part must be alternative 0 or 1"
@@ -2429,7 +5934,7 @@ var serializeAddressObj = (plutusDataAddressObject, networkId = 0) => {
2429
5934
  };
2430
5935
  var serializePlutusAddressToBech32 = (plutusHex, networkId = 0) => {
2431
5936
  const cardanoPlutusData = PlutusData.fromCbor((0, import_util6.HexBlob)(plutusHex));
2432
- return plutusDataToAddrBech32(cardanoPlutusData, networkId);
5937
+ return plutusDataToAddrBech32(cardanoPlutusData, networkId).toString();
2433
5938
  };
2434
5939
  var deserializeBech32Address = (bech32Addr) => {
2435
5940
  const deserializedAddress = Address.fromBech32(bech32Addr).getProps();
@@ -2468,15 +5973,15 @@ var v2ScriptToBech32 = (scriptCbor, stakeCredential, networkId = 0, isScriptStak
2468
5973
  networkId,
2469
5974
  isScriptStakeCredential
2470
5975
  );
2471
- var scriptHashToRewardAddress = (hash, networkId = 0) => {
5976
+ var scriptHashToRewardAddress = (hash2, networkId = 0) => {
2472
5977
  return RewardAddress.fromCredentials(networkId, {
2473
- hash: Hash28ByteBase162(hash),
5978
+ hash: Hash28ByteBase162(hash2),
2474
5979
  type: CredentialType.ScriptHash
2475
5980
  }).toAddress().toBech32().toString();
2476
5981
  };
2477
- var keyHashToRewardAddress = (hash, networkId = 0) => {
5982
+ var keyHashToRewardAddress = (hash2, networkId = 0) => {
2478
5983
  return RewardAddress.fromCredentials(networkId, {
2479
- hash: Hash28ByteBase162(hash),
5984
+ hash: Hash28ByteBase162(hash2),
2480
5985
  type: CredentialType.KeyHash
2481
5986
  }).toAddress().toBech32().toString();
2482
5987
  };
@@ -2494,6 +5999,29 @@ var hexToBech32 = (prefix, hex) => {
2494
5999
  return import_bech322.bech32.encode(prefix, base32RawBytes);
2495
6000
  };
2496
6001
 
6002
+ // src/utils/witness-set.ts
6003
+ var addVKeyWitnessSetToTransaction = (txHex, vkeyWitnessSet) => {
6004
+ const tx = Transaction.fromCbor(TxCBOR(txHex));
6005
+ const currentWitnessSet = tx.witnessSet();
6006
+ const newVkeyWitnessSet = TransactionWitnessSet.fromCbor(
6007
+ HexBlob(vkeyWitnessSet)
6008
+ );
6009
+ const currentVkeyWitnesses = currentWitnessSet.vkeys();
6010
+ const newVkeyWitnesses = newVkeyWitnessSet.vkeys();
6011
+ const allVkeyWitnesses = [
6012
+ ...currentVkeyWitnesses?.values() ?? [],
6013
+ ...newVkeyWitnesses?.values() ?? []
6014
+ ];
6015
+ currentWitnessSet.setVkeys(
6016
+ CborSet.fromCore(
6017
+ allVkeyWitnesses.map((vkw) => vkw.toCore()),
6018
+ VkeyWitness.fromCore
6019
+ )
6020
+ );
6021
+ tx.setWitnessSet(currentWitnessSet);
6022
+ return tx.toCbor();
6023
+ };
6024
+
2497
6025
  // src/resolvers/index.ts
2498
6026
  var resolveDataHash = (data) => {
2499
6027
  const plutusData = toPlutusData(data);
@@ -2544,8 +6072,8 @@ var resolvePlutusScriptHash = (bech325) => {
2544
6072
  throw new Error(`An error occurred during resolveScriptHash: ${error}.`);
2545
6073
  }
2546
6074
  };
2547
- var resolvePoolId = (hash) => {
2548
- return PoolId.fromKeyHash(Ed25519KeyHashHex2(hash)).toString();
6075
+ var resolvePoolId = (hash2) => {
6076
+ return PoolId.fromKeyHash(Ed25519KeyHashHex2(hash2)).toString();
2549
6077
  };
2550
6078
  var resolvePrivateKey = (words) => {
2551
6079
  const buildBip32PrivateKey2 = (entropy2, password = "") => {
@@ -2589,8 +6117,8 @@ var resolveStakeKeyHash = (bech325) => {
2589
6117
  };
2590
6118
  var resolveTxHash = (txHex) => {
2591
6119
  const txBody = deserializeTx(txHex).body();
2592
- const hash = (0, import_crypto5.blake2b)(import_crypto5.blake2b.BYTES).update(hexToBytes(txBody.toCbor())).digest();
2593
- return import_core4.Cardano.TransactionId.fromHexBlob(import_util7.HexBlob.fromBytes(hash)).toString();
6120
+ const hash2 = (0, import_crypto7.blake2b)(import_crypto7.blake2b.BYTES).update(hexToBytes(txBody.toCbor())).digest();
6121
+ return import_core4.Cardano.TransactionId.fromHexBlob(import_util7.HexBlob.fromBytes(hash2)).toString();
2594
6122
  };
2595
6123
  var resolveScriptHashDRepId = (scriptHash) => {
2596
6124
  return DRepID.cip129FromCredential({
@@ -2616,7 +6144,7 @@ var resolveEd25519KeyHash = (bech325) => {
2616
6144
  // src/serializer/index.ts
2617
6145
  var import_core7 = require("@cardano-sdk/core");
2618
6146
  var import_util9 = require("@cardano-sdk/util");
2619
- var import_cbor = require("@harmoniclabs/cbor");
6147
+ var import_cbor3 = require("@harmoniclabs/cbor");
2620
6148
  var import_base32_encoding4 = __toESM(require("base32-encoding"), 1);
2621
6149
  var import_bech324 = require("bech32");
2622
6150
  var import_common8 = require("@meshsdk/common");
@@ -3029,8 +6557,14 @@ var calculateFees = (minFeeA, minFeeB, minFeeRefScriptCostPerByte, priceMem, pri
3029
6557
  }
3030
6558
  if (tx.witnessSet().redeemers()) {
3031
6559
  for (const redeemer of tx.witnessSet().redeemers().values()) {
3032
- scriptFee += redeemer.exUnits().mem() * BigInt(priceMemNumerator.toString()) / BigInt(priceMemDenominator.toString()) + BigInt(1);
3033
- scriptFee += redeemer.exUnits().steps() * BigInt(priceStepNumerator.toString()) / BigInt(priceStepDenominator.toString()) + BigInt(1);
6560
+ scriptFee += redeemer.exUnits().mem() * BigInt(priceMemNumerator.toString()) / BigInt(priceMemDenominator.toString());
6561
+ scriptFee += redeemer.exUnits().steps() * BigInt(priceStepNumerator.toString()) / BigInt(priceStepDenominator.toString());
6562
+ if (priceMemNumerator % priceMemDenominator !== 0) {
6563
+ scriptFee += BigInt(1);
6564
+ }
6565
+ if (priceStepNumerator % priceStepDenominator !== 0) {
6566
+ scriptFee += BigInt(1);
6567
+ }
3034
6568
  }
3035
6569
  }
3036
6570
  return BigInt(fee) + scriptFee;
@@ -3073,7 +6607,7 @@ var toCardanoMetadatum = (metadatum) => {
3073
6607
  // src/utils/script-data-hash.ts
3074
6608
  var import_core6 = require("@cardano-sdk/core");
3075
6609
  var Crypto3 = __toESM(require("@cardano-sdk/crypto"), 1);
3076
- var import_crypto6 = require("@cardano-sdk/crypto");
6610
+ var import_crypto8 = require("@cardano-sdk/crypto");
3077
6611
  var import_util8 = require("@cardano-sdk/util");
3078
6612
  var CBOR_EMPTY_LIST = new Uint8Array([128]);
3079
6613
  var CBOR_EMPTY_MAP = new Uint8Array([160]);
@@ -3100,7 +6634,7 @@ var hashScriptData = (costModels, redemeers, datums) => {
3100
6634
  Buffer.from(costModels.languageViewsEncoding(), "hex")
3101
6635
  );
3102
6636
  }
3103
- return import_crypto6.Hash32ByteBase16.fromHexBlob(
6637
+ return import_crypto8.Hash32ByteBase16.fromHexBlob(
3104
6638
  import_util8.HexBlob.fromBytes(
3105
6639
  Crypto3.blake2b(Crypto3.blake2b.BYTES).update(writer.encode()).digest()
3106
6640
  )
@@ -3121,8 +6655,8 @@ var CardanoSDKSerializer = class {
3121
6655
  hash: Hash28ByteBase162(stakeKeyHash)
3122
6656
  }).toAddress().toBech32();
3123
6657
  }
3124
- serializePoolId(hash) {
3125
- return PoolId.fromKeyHash(Ed25519KeyHashHex2(hash)).toString();
6658
+ serializePoolId(hash2) {
6659
+ return PoolId.fromKeyHash(Ed25519KeyHashHex2(hash2)).toString();
3126
6660
  }
3127
6661
  serializeAddress(address, networkId) {
3128
6662
  let paymentCred = void 0;
@@ -3301,40 +6835,40 @@ var CardanoSDKSerializer = class {
3301
6835
  break;
3302
6836
  }
3303
6837
  }
3304
- let taggedScript = new import_cbor.CborTag(
6838
+ let taggedScript = new import_cbor3.CborTag(
3305
6839
  24,
3306
- import_cbor.Cbor.parse(
3307
- import_cbor.CborString.fromCborObj(
3308
- new import_cbor.CborBytes(
3309
- import_cbor.Cbor.encode(
3310
- new import_cbor.CborArray([
3311
- new import_cbor.CborUInt(versionByte),
3312
- new import_cbor.CborString(script.code).toCborObj()
6840
+ import_cbor3.Cbor.parse(
6841
+ import_cbor3.CborString.fromCborObj(
6842
+ new import_cbor3.CborBytes(
6843
+ import_cbor3.Cbor.encode(
6844
+ new import_cbor3.CborArray([
6845
+ new import_cbor3.CborUInt(versionByte),
6846
+ new import_cbor3.CborString(script.code).toCborObj()
3313
6847
  ])
3314
6848
  ).toBuffer()
3315
6849
  )
3316
6850
  )
3317
6851
  )
3318
6852
  );
3319
- return import_cbor.Cbor.encode(taggedScript).toString();
6853
+ return import_cbor3.Cbor.encode(taggedScript).toString();
3320
6854
  } else {
3321
6855
  const nativeScript = toNativeScript(script);
3322
- let taggedScript = new import_cbor.CborTag(
6856
+ let taggedScript = new import_cbor3.CborTag(
3323
6857
  24,
3324
- import_cbor.Cbor.parse(
3325
- import_cbor.CborString.fromCborObj(
3326
- new import_cbor.CborBytes(
3327
- import_cbor.Cbor.encode(
3328
- new import_cbor.CborArray([
3329
- new import_cbor.CborUInt(0),
3330
- new import_cbor.CborString(nativeScript.toCbor()).toCborObj()
6858
+ import_cbor3.Cbor.parse(
6859
+ import_cbor3.CborString.fromCborObj(
6860
+ new import_cbor3.CborBytes(
6861
+ import_cbor3.Cbor.encode(
6862
+ new import_cbor3.CborArray([
6863
+ new import_cbor3.CborUInt(0),
6864
+ new import_cbor3.CborString(nativeScript.toCbor()).toCborObj()
3331
6865
  ])
3332
6866
  ).toBuffer()
3333
6867
  )
3334
6868
  )
3335
6869
  )
3336
6870
  );
3337
- return import_cbor.Cbor.encode(taggedScript).toString();
6871
+ return import_cbor3.Cbor.encode(taggedScript).toString();
3338
6872
  }
3339
6873
  }
3340
6874
  }
@@ -3366,18 +6900,12 @@ var CardanoSDKSerializer = class {
3366
6900
  if (keyHex.length === 68 && keyHex.substring(0, 4) === "5820") {
3367
6901
  keyHex = keyHex.substring(4);
3368
6902
  }
3369
- const cardanoSigner = StricaPrivateKey.fromSecretKey(
3370
- Buffer.from(keyHex, "hex")
3371
- );
3372
- const signature = cardanoSigner.sign(
3373
- Buffer.from(cardanoTx.getId(), "hex")
3374
- );
6903
+ const cardanoSigner = buildEd25519PrivateKeyFromSecretKey(keyHex);
6904
+ const signature = cardanoSigner.sign((0, import_util9.HexBlob)(cardanoTx.getId()));
3375
6905
  currentWitnessSetVkeysValues.push(
3376
6906
  new VkeyWitness(
3377
- Ed25519PublicKeyHex2(
3378
- cardanoSigner.toPublicKey().toBytes().toString("hex")
3379
- ),
3380
- Ed25519SignatureHex2(signature.toString("hex"))
6907
+ Ed25519PublicKeyHex2(cardanoSigner.toPublic().hex()),
6908
+ Ed25519SignatureHex2(signature.hex())
3381
6909
  )
3382
6910
  );
3383
6911
  }
@@ -4215,7 +7743,7 @@ var CardanoSDKSerializerCore = class {
4215
7743
  currentOutputs.push(changeOutput);
4216
7744
  } else if (changeOutput.amount().coin() - fee < 0) {
4217
7745
  throw new Error(
4218
- "There was enough inputs to cover outputs, but not enough to cover fees"
7746
+ `There was enough inputs to cover outputs, but not enough to cover fees - fee: ${fee}`
4219
7747
  );
4220
7748
  }
4221
7749
  this.txBody.setOutputs(currentOutputs);
@@ -4497,7 +8025,7 @@ var CardanoSDKSerializerCore = class {
4497
8025
  };
4498
8026
 
4499
8027
  // src/plutus-tools/index.ts
4500
- var import_cbor2 = require("@harmoniclabs/cbor");
8028
+ var import_cbor4 = require("@harmoniclabs/cbor");
4501
8029
  var import_plutus_data = require("@harmoniclabs/plutus-data");
4502
8030
  var import_uplc = require("@harmoniclabs/uplc");
4503
8031
  var supportedPlutusCoreVersions = [
@@ -4547,8 +8075,8 @@ var getPurePlutusBytes = (plutusScript) => {
4547
8075
  if (hasSupportedPlutusVersion(unwrappedScript)) {
4548
8076
  return unwrappedScript;
4549
8077
  }
4550
- const cbor = import_cbor2.Cbor.parse(unwrappedScript);
4551
- if (cbor instanceof import_cbor2.CborBytes) {
8078
+ const cbor = import_cbor4.Cbor.parse(unwrappedScript);
8079
+ if (cbor instanceof import_cbor4.CborBytes) {
4552
8080
  unwrappedScript = cbor.bytes;
4553
8081
  } else {
4554
8082
  break;
@@ -4563,7 +8091,7 @@ var getPurePlutusBytes = (plutusScript) => {
4563
8091
  throw new Error("Unsupported Plutus version or invalid Plutus script bytes");
4564
8092
  };
4565
8093
  var applyCborEncoding = (plutusScript) => {
4566
- return import_cbor2.Cbor.encode(new import_cbor2.CborBytes(plutusScript)).toBuffer();
8094
+ return import_cbor4.Cbor.encode(new import_cbor4.CborBytes(plutusScript)).toBuffer();
4567
8095
  };
4568
8096
  var applyEncoding = (plutusScript, outputEncoding) => {
4569
8097
  switch (outputEncoding) {
@@ -4639,6 +8167,8 @@ var CardanoSDK = __toESM(require("@cardano-sdk/core"), 1);
4639
8167
  BaseAddress,
4640
8168
  Bip32PrivateKey,
4641
8169
  Bip32PrivateKeyHex,
8170
+ Bip32PublicKey,
8171
+ Bip32PublicKeyHex,
4642
8172
  Cardano,
4643
8173
  CardanoSDK,
4644
8174
  CardanoSDKSerializer,
@@ -4663,6 +8193,7 @@ var CardanoSDK = __toESM(require("@cardano-sdk/core"), 1);
4663
8193
  Ed25519KeyHash,
4664
8194
  Ed25519KeyHashHex,
4665
8195
  Ed25519PrivateExtendedKeyHex,
8196
+ Ed25519PrivateKey,
4666
8197
  Ed25519PrivateNormalKeyHex,
4667
8198
  Ed25519PublicKey,
4668
8199
  Ed25519PublicKeyHex,
@@ -4673,6 +8204,7 @@ var CardanoSDK = __toESM(require("@cardano-sdk/core"), 1);
4673
8204
  Hash,
4674
8205
  Hash28ByteBase16,
4675
8206
  Hash32ByteBase16,
8207
+ HexBlob,
4676
8208
  MetadatumList,
4677
8209
  MetadatumMap,
4678
8210
  NativeScript,
@@ -4709,16 +8241,6 @@ var CardanoSDK = __toESM(require("@cardano-sdk/core"), 1);
4709
8241
  StakeCredentialStatus,
4710
8242
  StakeDelegation,
4711
8243
  StakeRegistration,
4712
- StricaBip32PrivateKey,
4713
- StricaBip32PrivateKeyType,
4714
- StricaBip32PublicKey,
4715
- StricaBip32PublicKeyType,
4716
- StricaDecoder,
4717
- StricaEncoder,
4718
- StricaPrivateKey,
4719
- StricaPrivateKeyType,
4720
- StricaPublicKey,
4721
- StricaPublicKeyType,
4722
8244
  Transaction,
4723
8245
  TransactionBody,
4724
8246
  TransactionId,
@@ -4727,10 +8249,12 @@ var CardanoSDK = __toESM(require("@cardano-sdk/core"), 1);
4727
8249
  TransactionOutput,
4728
8250
  TransactionUnspentOutput,
4729
8251
  TransactionWitnessSet,
8252
+ TxCBOR,
4730
8253
  TxIndex,
4731
8254
  Value,
4732
8255
  VkeyWitness,
4733
8256
  VrfVkBech32,
8257
+ addVKeyWitnessSetToTransaction,
4734
8258
  addrBech32ToPlutusDataHex,
4735
8259
  addrBech32ToPlutusDataObj,
4736
8260
  addressToBech32,
@@ -4741,12 +8265,14 @@ var CardanoSDK = __toESM(require("@cardano-sdk/core"), 1);
4741
8265
  buildBaseAddress,
4742
8266
  buildBip32PrivateKey,
4743
8267
  buildDRepID,
8268
+ buildEd25519PrivateKeyFromSecretKey,
4744
8269
  buildEnterpriseAddress,
4745
8270
  buildKeys,
4746
8271
  buildRewardAddress,
4747
8272
  buildScriptPubkey,
4748
8273
  bytesToHex,
4749
8274
  checkSignature,
8275
+ clampScalar,
4750
8276
  computeAuxiliaryDataHash,
4751
8277
  deserializeAddress,
4752
8278
  deserializeBech32Address,