@rebasepro/server-core 0.6.1 → 0.8.0

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.
Files changed (116) hide show
  1. package/dist/api/graphql/graphql-schema-generator.d.ts +9 -0
  2. package/dist/api/rest/api-generator.d.ts +2 -14
  3. package/dist/api/rest/query-parser.d.ts +2 -5
  4. package/dist/api/types.d.ts +8 -2
  5. package/dist/auth/adapter-middleware.d.ts +7 -1
  6. package/dist/auth/admin-roles-route.d.ts +18 -0
  7. package/dist/auth/admin-users-route.d.ts +28 -0
  8. package/dist/auth/api-keys/api-key-types.d.ts +8 -0
  9. package/dist/auth/auth-hooks.d.ts +17 -0
  10. package/dist/auth/builtin-auth-adapter.d.ts +3 -1
  11. package/dist/auth/index.d.ts +1 -0
  12. package/dist/auth/interfaces.d.ts +32 -2
  13. package/dist/auth/magic-link-routes.d.ts +30 -0
  14. package/dist/auth/mfa-crypto.d.ts +23 -0
  15. package/dist/auth/mfa-routes.d.ts +2 -1
  16. package/dist/auth/middleware.d.ts +9 -2
  17. package/dist/auth/routes.d.ts +3 -1
  18. package/dist/auth/session-routes.d.ts +2 -0
  19. package/dist/backend-CIxN4FVm.js.map +1 -1
  20. package/dist/base64-js-C_frYBkI.js +1687 -0
  21. package/dist/base64-js-C_frYBkI.js.map +1 -0
  22. package/dist/{dist-CZKP-Xz4.js → dist-DMO-zF6D.js} +2 -2
  23. package/dist/{dist-CZKP-Xz4.js.map → dist-DMO-zF6D.js.map} +1 -1
  24. package/dist/email/index.d.ts +2 -2
  25. package/dist/email/templates.d.ts +8 -0
  26. package/dist/email/types.d.ts +18 -0
  27. package/dist/functions/define-function.d.ts +50 -0
  28. package/dist/functions/index.d.ts +2 -0
  29. package/dist/index.d.ts +16 -18
  30. package/dist/index.es.js +1947 -2356
  31. package/dist/index.es.js.map +1 -1
  32. package/dist/index.umd.js +40615 -10203
  33. package/dist/index.umd.js.map +1 -1
  34. package/dist/init.d.ts +68 -12
  35. package/dist/jws-BqRRaK11.js +616 -0
  36. package/dist/jws-BqRRaK11.js.map +1 -0
  37. package/dist/{jwt-DHcQRGC3.js → jwt-BETC8a1J.js} +3 -611
  38. package/dist/jwt-BETC8a1J.js.map +1 -0
  39. package/dist/services/routed-realtime-service.d.ts +43 -0
  40. package/dist/{src-COaj0G3P.js → src-CB2PIpBe.js} +2 -2
  41. package/dist/{src-COaj0G3P.js.map → src-CB2PIpBe.js.map} +1 -1
  42. package/dist/src-DjzOT1kG.js +29746 -0
  43. package/dist/src-DjzOT1kG.js.map +1 -0
  44. package/dist/storage/GCSStorageController.d.ts +43 -0
  45. package/dist/storage/index.d.ts +5 -2
  46. package/dist/storage/routes.d.ts +33 -1
  47. package/dist/storage/tus-handler.d.ts +3 -1
  48. package/dist/storage/types.d.ts +28 -3
  49. package/dist/utils/dev-port.d.ts +2 -0
  50. package/package.json +13 -5
  51. package/src/api/errors.ts +16 -2
  52. package/src/api/graphql/graphql-schema-generator.ts +50 -15
  53. package/src/api/openapi-generator.ts +2 -2
  54. package/src/api/rest/api-generator.ts +44 -123
  55. package/src/api/rest/query-parser.ts +6 -23
  56. package/src/api/server.ts +10 -2
  57. package/src/api/types.ts +8 -2
  58. package/src/auth/adapter-middleware.ts +10 -2
  59. package/src/auth/admin-roles-route.ts +36 -0
  60. package/src/auth/admin-users-route.ts +302 -0
  61. package/src/auth/api-keys/api-key-middleware.ts +4 -3
  62. package/src/auth/api-keys/api-key-routes.ts +12 -2
  63. package/src/auth/api-keys/api-key-store.ts +83 -66
  64. package/src/auth/api-keys/api-key-types.ts +8 -0
  65. package/src/auth/apple-oauth.ts +2 -1
  66. package/src/auth/auth-hooks.ts +21 -0
  67. package/src/auth/bitbucket-oauth.ts +2 -1
  68. package/src/auth/builtin-auth-adapter.ts +29 -6
  69. package/src/auth/custom-auth-adapter.ts +2 -0
  70. package/src/auth/discord-oauth.ts +2 -1
  71. package/src/auth/facebook-oauth.ts +2 -1
  72. package/src/auth/github-oauth.ts +2 -1
  73. package/src/auth/gitlab-oauth.ts +2 -1
  74. package/src/auth/google-oauth.ts +8 -4
  75. package/src/auth/index.ts +2 -0
  76. package/src/auth/interfaces.ts +38 -2
  77. package/src/auth/linkedin-oauth.ts +2 -1
  78. package/src/auth/magic-link-routes.ts +167 -0
  79. package/src/auth/mfa-crypto.ts +91 -0
  80. package/src/auth/mfa-routes.ts +34 -10
  81. package/src/auth/microsoft-oauth.ts +2 -1
  82. package/src/auth/middleware.ts +14 -5
  83. package/src/auth/reset-password-admin.ts +17 -1
  84. package/src/auth/routes.ts +78 -10
  85. package/src/auth/session-routes.ts +15 -3
  86. package/src/auth/slack-oauth.ts +2 -1
  87. package/src/auth/spotify-oauth.ts +2 -1
  88. package/src/auth/twitter-oauth.ts +8 -1
  89. package/src/cron/cron-store.ts +25 -23
  90. package/src/email/index.ts +3 -2
  91. package/src/email/templates.ts +82 -0
  92. package/src/email/types.ts +16 -0
  93. package/src/functions/define-function.ts +59 -0
  94. package/src/functions/function-loader.ts +16 -0
  95. package/src/functions/index.ts +2 -0
  96. package/src/index.ts +70 -37
  97. package/src/init.ts +214 -25
  98. package/src/services/routed-realtime-service.ts +113 -0
  99. package/src/storage/GCSStorageController.ts +334 -0
  100. package/src/storage/index.ts +9 -3
  101. package/src/storage/routes.ts +191 -23
  102. package/src/storage/tus-handler.ts +16 -4
  103. package/src/storage/types.ts +25 -3
  104. package/src/utils/dev-port.ts +13 -7
  105. package/test/api-generator.test.ts +1 -1
  106. package/test/auth-config-types.test.ts +40 -0
  107. package/test/auth-routes.test.ts +54 -4
  108. package/test/custom-auth-adapter.test.ts +20 -1
  109. package/test/define-function.test.ts +45 -0
  110. package/test/env.test.ts +9 -19
  111. package/test/multi-datasource-routing.test.ts +113 -0
  112. package/test/routed-realtime-service.test.ts +86 -0
  113. package/test/storage-routes.test.ts +160 -0
  114. package/test/transform-auth-response.test.ts +305 -0
  115. package/dist/jwt-DHcQRGC3.js.map +0 -1
  116. package/test/backend-hooks-data.test.ts +0 -477
@@ -0,0 +1,1687 @@
1
+ import { createRequire as __createRequire } from "module";
2
+ import "process";
3
+ __createRequire(import.meta.url);
4
+ import { t as __commonJSMin } from "./chunk-Dze3rakg.js";
5
+ //#region ../../node_modules/.pnpm/extend@3.0.2/node_modules/extend/index.js
6
+ var require_extend = /* @__PURE__ */ __commonJSMin(((exports, module) => {
7
+ var hasOwn = Object.prototype.hasOwnProperty;
8
+ var toStr = Object.prototype.toString;
9
+ var defineProperty = Object.defineProperty;
10
+ var gOPD = Object.getOwnPropertyDescriptor;
11
+ var isArray = function isArray(arr) {
12
+ if (typeof Array.isArray === "function") return Array.isArray(arr);
13
+ return toStr.call(arr) === "[object Array]";
14
+ };
15
+ var isPlainObject = function isPlainObject(obj) {
16
+ if (!obj || toStr.call(obj) !== "[object Object]") return false;
17
+ var hasOwnConstructor = hasOwn.call(obj, "constructor");
18
+ var hasIsPrototypeOf = obj.constructor && obj.constructor.prototype && hasOwn.call(obj.constructor.prototype, "isPrototypeOf");
19
+ if (obj.constructor && !hasOwnConstructor && !hasIsPrototypeOf) return false;
20
+ var key;
21
+ for (key in obj);
22
+ return typeof key === "undefined" || hasOwn.call(obj, key);
23
+ };
24
+ var setProperty = function setProperty(target, options) {
25
+ if (defineProperty && options.name === "__proto__") defineProperty(target, options.name, {
26
+ enumerable: true,
27
+ configurable: true,
28
+ value: options.newValue,
29
+ writable: true
30
+ });
31
+ else target[options.name] = options.newValue;
32
+ };
33
+ var getProperty = function getProperty(obj, name) {
34
+ if (name === "__proto__") {
35
+ if (!hasOwn.call(obj, name)) return;
36
+ else if (gOPD) return gOPD(obj, name).value;
37
+ }
38
+ return obj[name];
39
+ };
40
+ module.exports = function extend() {
41
+ var options, name, src, copy, copyIsArray, clone;
42
+ var target = arguments[0];
43
+ var i = 1;
44
+ var length = arguments.length;
45
+ var deep = false;
46
+ if (typeof target === "boolean") {
47
+ deep = target;
48
+ target = arguments[1] || {};
49
+ i = 2;
50
+ }
51
+ if (target == null || typeof target !== "object" && typeof target !== "function") target = {};
52
+ for (; i < length; ++i) {
53
+ options = arguments[i];
54
+ if (options != null) for (name in options) {
55
+ src = getProperty(target, name);
56
+ copy = getProperty(options, name);
57
+ if (target !== copy) {
58
+ if (deep && copy && (isPlainObject(copy) || (copyIsArray = isArray(copy)))) {
59
+ if (copyIsArray) {
60
+ copyIsArray = false;
61
+ clone = src && isArray(src) ? src : [];
62
+ } else clone = src && isPlainObject(src) ? src : {};
63
+ setProperty(target, {
64
+ name,
65
+ newValue: extend(deep, clone, copy)
66
+ });
67
+ } else if (typeof copy !== "undefined") setProperty(target, {
68
+ name,
69
+ newValue: copy
70
+ });
71
+ }
72
+ }
73
+ }
74
+ return target;
75
+ };
76
+ }));
77
+ //#endregion
78
+ //#region ../../node_modules/.pnpm/bignumber.js@9.3.1/node_modules/bignumber.js/bignumber.js
79
+ var require_bignumber = /* @__PURE__ */ __commonJSMin(((exports, module) => {
80
+ (function(globalObject) {
81
+ "use strict";
82
+ 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 = 0x5af3107a4000, LOG_BASE = 14, MAX_SAFE_INTEGER = 9007199254740991, POWS_TEN = [
83
+ 1,
84
+ 10,
85
+ 100,
86
+ 1e3,
87
+ 1e4,
88
+ 1e5,
89
+ 1e6,
90
+ 1e7,
91
+ 1e8,
92
+ 1e9,
93
+ 1e10,
94
+ 1e11,
95
+ 0xe8d4a51000,
96
+ 0x9184e72a000
97
+ ], SQRT_BASE = 1e7, MAX = 1e9;
98
+ function clone(configObject) {
99
+ var div, convertBase, parseNumeric, P = BigNumber.prototype = {
100
+ constructor: BigNumber,
101
+ toString: null,
102
+ valueOf: null
103
+ }, ONE = new BigNumber(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 = {
104
+ prefix: "",
105
+ groupSize: 3,
106
+ secondaryGroupSize: 0,
107
+ groupSeparator: ",",
108
+ decimalSeparator: ".",
109
+ fractionGroupSize: 0,
110
+ fractionGroupSeparator: "\xA0",
111
+ suffix: ""
112
+ }, ALPHABET = "0123456789abcdefghijklmnopqrstuvwxyz", alphabetHasNormalDecimalDigits = true;
113
+ function BigNumber(v, b) {
114
+ var alphabet, c, caseChanged, e, i, isNum, len, str, x = this;
115
+ if (!(x instanceof BigNumber)) return new BigNumber(v, b);
116
+ if (b == null) {
117
+ if (v && v._isBigNumber === true) {
118
+ x.s = v.s;
119
+ if (!v.c || v.e > MAX_EXP) x.c = x.e = null;
120
+ else if (v.e < MIN_EXP) x.c = [x.e = 0];
121
+ else {
122
+ x.e = v.e;
123
+ x.c = v.c.slice();
124
+ }
125
+ return;
126
+ }
127
+ if ((isNum = typeof v == "number") && v * 0 == 0) {
128
+ x.s = 1 / v < 0 ? (v = -v, -1) : 1;
129
+ if (v === ~~v) {
130
+ for (e = 0, i = v; i >= 10; i /= 10, e++);
131
+ if (e > MAX_EXP) x.c = x.e = null;
132
+ else {
133
+ x.e = e;
134
+ x.c = [v];
135
+ }
136
+ return;
137
+ }
138
+ str = String(v);
139
+ } else {
140
+ if (!isNumeric.test(str = String(v))) return parseNumeric(x, str, isNum);
141
+ x.s = str.charCodeAt(0) == 45 ? (str = str.slice(1), -1) : 1;
142
+ }
143
+ if ((e = str.indexOf(".")) > -1) str = str.replace(".", "");
144
+ if ((i = str.search(/e/i)) > 0) {
145
+ if (e < 0) e = i;
146
+ e += +str.slice(i + 1);
147
+ str = str.substring(0, i);
148
+ } else if (e < 0) e = str.length;
149
+ } else {
150
+ intCheck(b, 2, ALPHABET.length, "Base");
151
+ if (b == 10 && alphabetHasNormalDecimalDigits) {
152
+ x = new BigNumber(v);
153
+ return round(x, DECIMAL_PLACES + x.e + 1, ROUNDING_MODE);
154
+ }
155
+ str = String(v);
156
+ if (isNum = typeof v == "number") {
157
+ if (v * 0 != 0) return parseNumeric(x, str, isNum, b);
158
+ x.s = 1 / v < 0 ? (str = str.slice(1), -1) : 1;
159
+ if (BigNumber.DEBUG && str.replace(/^0\.0*|\./, "").length > 15) throw Error(tooManyDigits + v);
160
+ } else x.s = str.charCodeAt(0) === 45 ? (str = str.slice(1), -1) : 1;
161
+ alphabet = ALPHABET.slice(0, b);
162
+ e = i = 0;
163
+ for (len = str.length; i < len; i++) if (alphabet.indexOf(c = str.charAt(i)) < 0) {
164
+ if (c == ".") {
165
+ if (i > e) {
166
+ e = len;
167
+ continue;
168
+ }
169
+ } else if (!caseChanged) {
170
+ if (str == str.toUpperCase() && (str = str.toLowerCase()) || str == str.toLowerCase() && (str = str.toUpperCase())) {
171
+ caseChanged = true;
172
+ i = -1;
173
+ e = 0;
174
+ continue;
175
+ }
176
+ }
177
+ return parseNumeric(x, String(v), isNum, b);
178
+ }
179
+ isNum = false;
180
+ str = convertBase(str, b, 10, x.s);
181
+ if ((e = str.indexOf(".")) > -1) str = str.replace(".", "");
182
+ else e = str.length;
183
+ }
184
+ for (i = 0; str.charCodeAt(i) === 48; i++);
185
+ for (len = str.length; str.charCodeAt(--len) === 48;);
186
+ if (str = str.slice(i, ++len)) {
187
+ len -= i;
188
+ if (isNum && BigNumber.DEBUG && len > 15 && (v > MAX_SAFE_INTEGER || v !== mathfloor(v))) throw Error(tooManyDigits + x.s * v);
189
+ if ((e = e - i - 1) > MAX_EXP) x.c = x.e = null;
190
+ else if (e < MIN_EXP) x.c = [x.e = 0];
191
+ else {
192
+ x.e = e;
193
+ x.c = [];
194
+ i = (e + 1) % LOG_BASE;
195
+ if (e < 0) i += LOG_BASE;
196
+ if (i < len) {
197
+ if (i) x.c.push(+str.slice(0, i));
198
+ for (len -= LOG_BASE; i < len;) x.c.push(+str.slice(i, i += LOG_BASE));
199
+ i = LOG_BASE - (str = str.slice(i)).length;
200
+ } else i -= len;
201
+ for (; i--; str += "0");
202
+ x.c.push(+str);
203
+ }
204
+ } else x.c = [x.e = 0];
205
+ }
206
+ BigNumber.clone = clone;
207
+ BigNumber.ROUND_UP = 0;
208
+ BigNumber.ROUND_DOWN = 1;
209
+ BigNumber.ROUND_CEIL = 2;
210
+ BigNumber.ROUND_FLOOR = 3;
211
+ BigNumber.ROUND_HALF_UP = 4;
212
+ BigNumber.ROUND_HALF_DOWN = 5;
213
+ BigNumber.ROUND_HALF_EVEN = 6;
214
+ BigNumber.ROUND_HALF_CEIL = 7;
215
+ BigNumber.ROUND_HALF_FLOOR = 8;
216
+ BigNumber.EUCLID = 9;
217
+ BigNumber.config = BigNumber.set = function(obj) {
218
+ var p, v;
219
+ if (obj != null) if (typeof obj == "object") {
220
+ if (obj.hasOwnProperty(p = "DECIMAL_PLACES")) {
221
+ v = obj[p];
222
+ intCheck(v, 0, MAX, p);
223
+ DECIMAL_PLACES = v;
224
+ }
225
+ if (obj.hasOwnProperty(p = "ROUNDING_MODE")) {
226
+ v = obj[p];
227
+ intCheck(v, 0, 8, p);
228
+ ROUNDING_MODE = v;
229
+ }
230
+ if (obj.hasOwnProperty(p = "EXPONENTIAL_AT")) {
231
+ v = obj[p];
232
+ if (v && v.pop) {
233
+ intCheck(v[0], -MAX, 0, p);
234
+ intCheck(v[1], 0, MAX, p);
235
+ TO_EXP_NEG = v[0];
236
+ TO_EXP_POS = v[1];
237
+ } else {
238
+ intCheck(v, -MAX, MAX, p);
239
+ TO_EXP_NEG = -(TO_EXP_POS = v < 0 ? -v : v);
240
+ }
241
+ }
242
+ if (obj.hasOwnProperty(p = "RANGE")) {
243
+ v = obj[p];
244
+ if (v && v.pop) {
245
+ intCheck(v[0], -MAX, -1, p);
246
+ intCheck(v[1], 1, MAX, p);
247
+ MIN_EXP = v[0];
248
+ MAX_EXP = v[1];
249
+ } else {
250
+ intCheck(v, -MAX, MAX, p);
251
+ if (v) MIN_EXP = -(MAX_EXP = v < 0 ? -v : v);
252
+ else throw Error(bignumberError + p + " cannot be zero: " + v);
253
+ }
254
+ }
255
+ if (obj.hasOwnProperty(p = "CRYPTO")) {
256
+ v = obj[p];
257
+ if (v === !!v) if (v) if (typeof crypto != "undefined" && crypto && (crypto.getRandomValues || crypto.randomBytes)) CRYPTO = v;
258
+ else {
259
+ CRYPTO = !v;
260
+ throw Error(bignumberError + "crypto unavailable");
261
+ }
262
+ else CRYPTO = v;
263
+ else throw Error(bignumberError + p + " not true or false: " + v);
264
+ }
265
+ if (obj.hasOwnProperty(p = "MODULO_MODE")) {
266
+ v = obj[p];
267
+ intCheck(v, 0, 9, p);
268
+ MODULO_MODE = v;
269
+ }
270
+ if (obj.hasOwnProperty(p = "POW_PRECISION")) {
271
+ v = obj[p];
272
+ intCheck(v, 0, MAX, p);
273
+ POW_PRECISION = v;
274
+ }
275
+ if (obj.hasOwnProperty(p = "FORMAT")) {
276
+ v = obj[p];
277
+ if (typeof v == "object") FORMAT = v;
278
+ else throw Error(bignumberError + p + " not an object: " + v);
279
+ }
280
+ if (obj.hasOwnProperty(p = "ALPHABET")) {
281
+ v = obj[p];
282
+ if (typeof v == "string" && !/^.?$|[+\-.\s]|(.).*\1/.test(v)) {
283
+ alphabetHasNormalDecimalDigits = v.slice(0, 10) == "0123456789";
284
+ ALPHABET = v;
285
+ } else throw Error(bignumberError + p + " invalid: " + v);
286
+ }
287
+ } else throw Error(bignumberError + "Object expected: " + obj);
288
+ return {
289
+ DECIMAL_PLACES,
290
+ ROUNDING_MODE,
291
+ EXPONENTIAL_AT: [TO_EXP_NEG, TO_EXP_POS],
292
+ RANGE: [MIN_EXP, MAX_EXP],
293
+ CRYPTO,
294
+ MODULO_MODE,
295
+ POW_PRECISION,
296
+ FORMAT,
297
+ ALPHABET
298
+ };
299
+ };
300
+ BigNumber.isBigNumber = function(v) {
301
+ if (!v || v._isBigNumber !== true) return false;
302
+ if (!BigNumber.DEBUG) return true;
303
+ var i, n, c = v.c, e = v.e, s = v.s;
304
+ out: if ({}.toString.call(c) == "[object Array]") {
305
+ if ((s === 1 || s === -1) && e >= -MAX && e <= MAX && e === mathfloor(e)) {
306
+ if (c[0] === 0) {
307
+ if (e === 0 && c.length === 1) return true;
308
+ break out;
309
+ }
310
+ i = (e + 1) % LOG_BASE;
311
+ if (i < 1) i += LOG_BASE;
312
+ if (String(c[0]).length == i) {
313
+ for (i = 0; i < c.length; i++) {
314
+ n = c[i];
315
+ if (n < 0 || n >= BASE || n !== mathfloor(n)) break out;
316
+ }
317
+ if (n !== 0) return true;
318
+ }
319
+ }
320
+ } else if (c === null && e === null && (s === null || s === 1 || s === -1)) return true;
321
+ throw Error(bignumberError + "Invalid BigNumber: " + v);
322
+ };
323
+ BigNumber.maximum = BigNumber.max = function() {
324
+ return maxOrMin(arguments, -1);
325
+ };
326
+ BigNumber.minimum = BigNumber.min = function() {
327
+ return maxOrMin(arguments, 1);
328
+ };
329
+ BigNumber.random = (function() {
330
+ var pow2_53 = 9007199254740992;
331
+ var random53bitInt = Math.random() * pow2_53 & 2097151 ? function() {
332
+ return mathfloor(Math.random() * pow2_53);
333
+ } : function() {
334
+ return (Math.random() * 1073741824 | 0) * 8388608 + (Math.random() * 8388608 | 0);
335
+ };
336
+ return function(dp) {
337
+ var a, b, e, k, v, i = 0, c = [], rand = new BigNumber(ONE);
338
+ if (dp == null) dp = DECIMAL_PLACES;
339
+ else intCheck(dp, 0, MAX);
340
+ k = mathceil(dp / LOG_BASE);
341
+ if (CRYPTO) if (crypto.getRandomValues) {
342
+ a = crypto.getRandomValues(new Uint32Array(k *= 2));
343
+ for (; i < k;) {
344
+ v = a[i] * 131072 + (a[i + 1] >>> 11);
345
+ if (v >= 9e15) {
346
+ b = crypto.getRandomValues(new Uint32Array(2));
347
+ a[i] = b[0];
348
+ a[i + 1] = b[1];
349
+ } else {
350
+ c.push(v % 0x5af3107a4000);
351
+ i += 2;
352
+ }
353
+ }
354
+ i = k / 2;
355
+ } else if (crypto.randomBytes) {
356
+ a = crypto.randomBytes(k *= 7);
357
+ for (; i < k;) {
358
+ 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];
359
+ if (v >= 9e15) crypto.randomBytes(7).copy(a, i);
360
+ else {
361
+ c.push(v % 0x5af3107a4000);
362
+ i += 7;
363
+ }
364
+ }
365
+ i = k / 7;
366
+ } else {
367
+ CRYPTO = false;
368
+ throw Error(bignumberError + "crypto unavailable");
369
+ }
370
+ if (!CRYPTO) for (; i < k;) {
371
+ v = random53bitInt();
372
+ if (v < 9e15) c[i++] = v % 0x5af3107a4000;
373
+ }
374
+ k = c[--i];
375
+ dp %= LOG_BASE;
376
+ if (k && dp) {
377
+ v = POWS_TEN[LOG_BASE - dp];
378
+ c[i] = mathfloor(k / v) * v;
379
+ }
380
+ for (; c[i] === 0; c.pop(), i--);
381
+ if (i < 0) c = [e = 0];
382
+ else {
383
+ for (e = -1; c[0] === 0; c.splice(0, 1), e -= LOG_BASE);
384
+ for (i = 1, v = c[0]; v >= 10; v /= 10, i++);
385
+ if (i < LOG_BASE) e -= LOG_BASE - i;
386
+ }
387
+ rand.e = e;
388
+ rand.c = c;
389
+ return rand;
390
+ };
391
+ })();
392
+ BigNumber.sum = function() {
393
+ var i = 1, args = arguments, sum = new BigNumber(args[0]);
394
+ for (; i < args.length;) sum = sum.plus(args[i++]);
395
+ return sum;
396
+ };
397
+ convertBase = (function() {
398
+ var decimal = "0123456789";
399
+ function toBaseOut(str, baseIn, baseOut, alphabet) {
400
+ var j, arr = [0], arrL, i = 0, len = str.length;
401
+ for (; i < len;) {
402
+ for (arrL = arr.length; arrL--; arr[arrL] *= baseIn);
403
+ arr[0] += alphabet.indexOf(str.charAt(i++));
404
+ for (j = 0; j < arr.length; j++) if (arr[j] > baseOut - 1) {
405
+ if (arr[j + 1] == null) arr[j + 1] = 0;
406
+ arr[j + 1] += arr[j] / baseOut | 0;
407
+ arr[j] %= baseOut;
408
+ }
409
+ }
410
+ return arr.reverse();
411
+ }
412
+ return function(str, baseIn, baseOut, sign, callerIsToString) {
413
+ var alphabet, d, e, k, r, x, xc, y, i = str.indexOf("."), dp = DECIMAL_PLACES, rm = ROUNDING_MODE;
414
+ if (i >= 0) {
415
+ k = POW_PRECISION;
416
+ POW_PRECISION = 0;
417
+ str = str.replace(".", "");
418
+ y = new BigNumber(baseIn);
419
+ x = y.pow(str.length - i);
420
+ POW_PRECISION = k;
421
+ y.c = toBaseOut(toFixedPoint(coeffToString(x.c), x.e, "0"), 10, baseOut, decimal);
422
+ y.e = y.c.length;
423
+ }
424
+ xc = toBaseOut(str, baseIn, baseOut, callerIsToString ? (alphabet = ALPHABET, decimal) : (alphabet = decimal, ALPHABET));
425
+ e = k = xc.length;
426
+ for (; xc[--k] == 0; xc.pop());
427
+ if (!xc[0]) return alphabet.charAt(0);
428
+ if (i < 0) --e;
429
+ else {
430
+ x.c = xc;
431
+ x.e = e;
432
+ x.s = sign;
433
+ x = div(x, y, dp, rm, baseOut);
434
+ xc = x.c;
435
+ r = x.r;
436
+ e = x.e;
437
+ }
438
+ d = e + dp + 1;
439
+ i = xc[d];
440
+ k = baseOut / 2;
441
+ r = r || d < 0 || xc[d + 1] != null;
442
+ 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));
443
+ if (d < 1 || !xc[0]) str = r ? toFixedPoint(alphabet.charAt(1), -dp, alphabet.charAt(0)) : alphabet.charAt(0);
444
+ else {
445
+ xc.length = d;
446
+ if (r) for (--baseOut; ++xc[--d] > baseOut;) {
447
+ xc[d] = 0;
448
+ if (!d) {
449
+ ++e;
450
+ xc = [1].concat(xc);
451
+ }
452
+ }
453
+ for (k = xc.length; !xc[--k];);
454
+ for (i = 0, str = ""; i <= k; str += alphabet.charAt(xc[i++]));
455
+ str = toFixedPoint(str, e, alphabet.charAt(0));
456
+ }
457
+ return str;
458
+ };
459
+ })();
460
+ div = (function() {
461
+ function multiply(x, k, base) {
462
+ var m, temp, xlo, xhi, carry = 0, i = x.length, klo = k % SQRT_BASE, khi = k / SQRT_BASE | 0;
463
+ for (x = x.slice(); i--;) {
464
+ xlo = x[i] % SQRT_BASE;
465
+ xhi = x[i] / SQRT_BASE | 0;
466
+ m = khi * xlo + xhi * klo;
467
+ temp = klo * xlo + m % SQRT_BASE * SQRT_BASE + carry;
468
+ carry = (temp / base | 0) + (m / SQRT_BASE | 0) + khi * xhi;
469
+ x[i] = temp % base;
470
+ }
471
+ if (carry) x = [carry].concat(x);
472
+ return x;
473
+ }
474
+ function compare(a, b, aL, bL) {
475
+ var i, cmp;
476
+ if (aL != bL) cmp = aL > bL ? 1 : -1;
477
+ else for (i = cmp = 0; i < aL; i++) if (a[i] != b[i]) {
478
+ cmp = a[i] > b[i] ? 1 : -1;
479
+ break;
480
+ }
481
+ return cmp;
482
+ }
483
+ function subtract(a, b, aL, base) {
484
+ var i = 0;
485
+ for (; aL--;) {
486
+ a[aL] -= i;
487
+ i = a[aL] < b[aL] ? 1 : 0;
488
+ a[aL] = i * base + a[aL] - b[aL];
489
+ }
490
+ for (; !a[0] && a.length > 1; a.splice(0, 1));
491
+ }
492
+ return function(x, y, dp, rm, base) {
493
+ 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;
494
+ if (!xc || !xc[0] || !yc || !yc[0]) return new BigNumber(!x.s || !y.s || (xc ? yc && xc[0] == yc[0] : !yc) ? NaN : xc && xc[0] == 0 || !yc ? s * 0 : s / 0);
495
+ q = new BigNumber(s);
496
+ qc = q.c = [];
497
+ e = x.e - y.e;
498
+ s = dp + e + 1;
499
+ if (!base) {
500
+ base = BASE;
501
+ e = bitFloor(x.e / LOG_BASE) - bitFloor(y.e / LOG_BASE);
502
+ s = s / LOG_BASE | 0;
503
+ }
504
+ for (i = 0; yc[i] == (xc[i] || 0); i++);
505
+ if (yc[i] > (xc[i] || 0)) e--;
506
+ if (s < 0) {
507
+ qc.push(1);
508
+ more = true;
509
+ } else {
510
+ xL = xc.length;
511
+ yL = yc.length;
512
+ i = 0;
513
+ s += 2;
514
+ n = mathfloor(base / (yc[0] + 1));
515
+ if (n > 1) {
516
+ yc = multiply(yc, n, base);
517
+ xc = multiply(xc, n, base);
518
+ yL = yc.length;
519
+ xL = xc.length;
520
+ }
521
+ xi = yL;
522
+ rem = xc.slice(0, yL);
523
+ remL = rem.length;
524
+ for (; remL < yL; rem[remL++] = 0);
525
+ yz = yc.slice();
526
+ yz = [0].concat(yz);
527
+ yc0 = yc[0];
528
+ if (yc[1] >= base / 2) yc0++;
529
+ do {
530
+ n = 0;
531
+ cmp = compare(yc, rem, yL, remL);
532
+ if (cmp < 0) {
533
+ rem0 = rem[0];
534
+ if (yL != remL) rem0 = rem0 * base + (rem[1] || 0);
535
+ n = mathfloor(rem0 / yc0);
536
+ if (n > 1) {
537
+ if (n >= base) n = base - 1;
538
+ prod = multiply(yc, n, base);
539
+ prodL = prod.length;
540
+ remL = rem.length;
541
+ while (compare(prod, rem, prodL, remL) == 1) {
542
+ n--;
543
+ subtract(prod, yL < prodL ? yz : yc, prodL, base);
544
+ prodL = prod.length;
545
+ cmp = 1;
546
+ }
547
+ } else {
548
+ if (n == 0) cmp = n = 1;
549
+ prod = yc.slice();
550
+ prodL = prod.length;
551
+ }
552
+ if (prodL < remL) prod = [0].concat(prod);
553
+ subtract(rem, prod, remL, base);
554
+ remL = rem.length;
555
+ if (cmp == -1) while (compare(yc, rem, yL, remL) < 1) {
556
+ n++;
557
+ subtract(rem, yL < remL ? yz : yc, remL, base);
558
+ remL = rem.length;
559
+ }
560
+ } else if (cmp === 0) {
561
+ n++;
562
+ rem = [0];
563
+ }
564
+ qc[i++] = n;
565
+ if (rem[0]) rem[remL++] = xc[xi] || 0;
566
+ else {
567
+ rem = [xc[xi]];
568
+ remL = 1;
569
+ }
570
+ } while ((xi++ < xL || rem[0] != null) && s--);
571
+ more = rem[0] != null;
572
+ if (!qc[0]) qc.splice(0, 1);
573
+ }
574
+ if (base == BASE) {
575
+ for (i = 1, s = qc[0]; s >= 10; s /= 10, i++);
576
+ round(q, dp + (q.e = i + e * LOG_BASE - 1) + 1, rm, more);
577
+ } else {
578
+ q.e = e;
579
+ q.r = +more;
580
+ }
581
+ return q;
582
+ };
583
+ })();
584
+ function format(n, i, rm, id) {
585
+ var c0, e, ne, len, str;
586
+ if (rm == null) rm = ROUNDING_MODE;
587
+ else intCheck(rm, 0, 8);
588
+ if (!n.c) return n.toString();
589
+ c0 = n.c[0];
590
+ ne = n.e;
591
+ if (i == null) {
592
+ str = coeffToString(n.c);
593
+ str = id == 1 || id == 2 && (ne <= TO_EXP_NEG || ne >= TO_EXP_POS) ? toExponential(str, ne) : toFixedPoint(str, ne, "0");
594
+ } else {
595
+ n = round(new BigNumber(n), i, rm);
596
+ e = n.e;
597
+ str = coeffToString(n.c);
598
+ len = str.length;
599
+ if (id == 1 || id == 2 && (i <= e || e <= TO_EXP_NEG)) {
600
+ for (; len < i; str += "0", len++);
601
+ str = toExponential(str, e);
602
+ } else {
603
+ i -= ne + (id === 2 && e > ne);
604
+ str = toFixedPoint(str, e, "0");
605
+ if (e + 1 > len) {
606
+ if (--i > 0) for (str += "."; i--; str += "0");
607
+ } else {
608
+ i += e - len;
609
+ if (i > 0) {
610
+ if (e + 1 == len) str += ".";
611
+ for (; i--; str += "0");
612
+ }
613
+ }
614
+ }
615
+ }
616
+ return n.s < 0 && c0 ? "-" + str : str;
617
+ }
618
+ function maxOrMin(args, n) {
619
+ var k, y, i = 1, x = new BigNumber(args[0]);
620
+ for (; i < args.length; i++) {
621
+ y = new BigNumber(args[i]);
622
+ if (!y.s || (k = compare(x, y)) === n || k === 0 && x.s === n) x = y;
623
+ }
624
+ return x;
625
+ }
626
+ function normalise(n, c, e) {
627
+ var i = 1, j = c.length;
628
+ for (; !c[--j]; c.pop());
629
+ for (j = c[0]; j >= 10; j /= 10, i++);
630
+ if ((e = i + e * LOG_BASE - 1) > MAX_EXP) n.c = n.e = null;
631
+ else if (e < MIN_EXP) n.c = [n.e = 0];
632
+ else {
633
+ n.e = e;
634
+ n.c = c;
635
+ }
636
+ return n;
637
+ }
638
+ parseNumeric = (function() {
639
+ var basePrefix = /^(-?)0([xbo])(?=\w[\w.]*$)/i, dotAfter = /^([^.]+)\.$/, dotBefore = /^\.([^.]+)$/, isInfinityOrNaN = /^-?(Infinity|NaN)$/, whitespaceOrPlus = /^\s*\+(?=[\w.])|^\s+|\s+$/g;
640
+ return function(x, str, isNum, b) {
641
+ var base, s = isNum ? str : str.replace(whitespaceOrPlus, "");
642
+ if (isInfinityOrNaN.test(s)) x.s = isNaN(s) ? null : s < 0 ? -1 : 1;
643
+ else {
644
+ if (!isNum) {
645
+ s = s.replace(basePrefix, function(m, p1, p2) {
646
+ base = (p2 = p2.toLowerCase()) == "x" ? 16 : p2 == "b" ? 2 : 8;
647
+ return !b || b == base ? p1 : m;
648
+ });
649
+ if (b) {
650
+ base = b;
651
+ s = s.replace(dotAfter, "$1").replace(dotBefore, "0.$1");
652
+ }
653
+ if (str != s) return new BigNumber(s, base);
654
+ }
655
+ if (BigNumber.DEBUG) throw Error(bignumberError + "Not a" + (b ? " base " + b : "") + " number: " + str);
656
+ x.s = null;
657
+ }
658
+ x.c = x.e = null;
659
+ };
660
+ })();
661
+ function round(x, sd, rm, r) {
662
+ var d, i, j, k, n, ni, rd, xc = x.c, pows10 = POWS_TEN;
663
+ if (xc) {
664
+ out: {
665
+ for (d = 1, k = xc[0]; k >= 10; k /= 10, d++);
666
+ i = sd - d;
667
+ if (i < 0) {
668
+ i += LOG_BASE;
669
+ j = sd;
670
+ n = xc[ni = 0];
671
+ rd = mathfloor(n / pows10[d - j - 1] % 10);
672
+ } else {
673
+ ni = mathceil((i + 1) / LOG_BASE);
674
+ if (ni >= xc.length) if (r) {
675
+ for (; xc.length <= ni; xc.push(0));
676
+ n = rd = 0;
677
+ d = 1;
678
+ i %= LOG_BASE;
679
+ j = i - LOG_BASE + 1;
680
+ } else break out;
681
+ else {
682
+ n = k = xc[ni];
683
+ for (d = 1; k >= 10; k /= 10, d++);
684
+ i %= LOG_BASE;
685
+ j = i - LOG_BASE + d;
686
+ rd = j < 0 ? 0 : mathfloor(n / pows10[d - j - 1] % 10);
687
+ }
688
+ }
689
+ r = r || sd < 0 || xc[ni + 1] != null || (j < 0 ? n : n % pows10[d - j - 1]);
690
+ r = rm < 4 ? (rd || r) && (rm == 0 || rm == (x.s < 0 ? 3 : 2)) : rd > 5 || rd == 5 && (rm == 4 || r || rm == 6 && (i > 0 ? j > 0 ? n / pows10[d - j] : 0 : xc[ni - 1]) % 10 & 1 || rm == (x.s < 0 ? 8 : 7));
691
+ if (sd < 1 || !xc[0]) {
692
+ xc.length = 0;
693
+ if (r) {
694
+ sd -= x.e + 1;
695
+ xc[0] = pows10[(LOG_BASE - sd % LOG_BASE) % LOG_BASE];
696
+ x.e = -sd || 0;
697
+ } else xc[0] = x.e = 0;
698
+ return x;
699
+ }
700
+ if (i == 0) {
701
+ xc.length = ni;
702
+ k = 1;
703
+ ni--;
704
+ } else {
705
+ xc.length = ni + 1;
706
+ k = pows10[LOG_BASE - i];
707
+ xc[ni] = j > 0 ? mathfloor(n / pows10[d - j] % pows10[j]) * k : 0;
708
+ }
709
+ if (r) for (;;) if (ni == 0) {
710
+ for (i = 1, j = xc[0]; j >= 10; j /= 10, i++);
711
+ j = xc[0] += k;
712
+ for (k = 1; j >= 10; j /= 10, k++);
713
+ if (i != k) {
714
+ x.e++;
715
+ if (xc[0] == BASE) xc[0] = 1;
716
+ }
717
+ break;
718
+ } else {
719
+ xc[ni] += k;
720
+ if (xc[ni] != BASE) break;
721
+ xc[ni--] = 0;
722
+ k = 1;
723
+ }
724
+ for (i = xc.length; xc[--i] === 0; xc.pop());
725
+ }
726
+ if (x.e > MAX_EXP) x.c = x.e = null;
727
+ else if (x.e < MIN_EXP) x.c = [x.e = 0];
728
+ }
729
+ return x;
730
+ }
731
+ function valueOf(n) {
732
+ var str, e = n.e;
733
+ if (e === null) return n.toString();
734
+ str = coeffToString(n.c);
735
+ str = e <= TO_EXP_NEG || e >= TO_EXP_POS ? toExponential(str, e) : toFixedPoint(str, e, "0");
736
+ return n.s < 0 ? "-" + str : str;
737
+ }
738
+ P.absoluteValue = P.abs = function() {
739
+ var x = new BigNumber(this);
740
+ if (x.s < 0) x.s = 1;
741
+ return x;
742
+ };
743
+ P.comparedTo = function(y, b) {
744
+ return compare(this, new BigNumber(y, b));
745
+ };
746
+ P.decimalPlaces = P.dp = function(dp, rm) {
747
+ var c, n, v, x = this;
748
+ if (dp != null) {
749
+ intCheck(dp, 0, MAX);
750
+ if (rm == null) rm = ROUNDING_MODE;
751
+ else intCheck(rm, 0, 8);
752
+ return round(new BigNumber(x), dp + x.e + 1, rm);
753
+ }
754
+ if (!(c = x.c)) return null;
755
+ n = ((v = c.length - 1) - bitFloor(this.e / LOG_BASE)) * LOG_BASE;
756
+ if (v = c[v]) for (; v % 10 == 0; v /= 10, n--);
757
+ if (n < 0) n = 0;
758
+ return n;
759
+ };
760
+ P.dividedBy = P.div = function(y, b) {
761
+ return div(this, new BigNumber(y, b), DECIMAL_PLACES, ROUNDING_MODE);
762
+ };
763
+ P.dividedToIntegerBy = P.idiv = function(y, b) {
764
+ return div(this, new BigNumber(y, b), 0, 1);
765
+ };
766
+ P.exponentiatedBy = P.pow = function(n, m) {
767
+ var half, isModExp, i, k, more, nIsBig, nIsNeg, nIsOdd, y, x = this;
768
+ n = new BigNumber(n);
769
+ if (n.c && !n.isInteger()) throw Error(bignumberError + "Exponent not an integer: " + valueOf(n));
770
+ if (m != null) m = new BigNumber(m);
771
+ nIsBig = n.e > 14;
772
+ if (!x.c || !x.c[0] || x.c[0] == 1 && !x.e && x.c.length == 1 || !n.c || !n.c[0]) {
773
+ y = new BigNumber(Math.pow(+valueOf(x), nIsBig ? n.s * (2 - isOdd(n)) : +valueOf(n)));
774
+ return m ? y.mod(m) : y;
775
+ }
776
+ nIsNeg = n.s < 0;
777
+ if (m) {
778
+ if (m.c ? !m.c[0] : !m.s) return new BigNumber(NaN);
779
+ isModExp = !nIsNeg && x.isInteger() && m.isInteger();
780
+ if (isModExp) x = x.mod(m);
781
+ } 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))) {
782
+ k = x.s < 0 && isOdd(n) ? -0 : 0;
783
+ if (x.e > -1) k = 1 / k;
784
+ return new BigNumber(nIsNeg ? 1 / k : k);
785
+ } else if (POW_PRECISION) k = mathceil(POW_PRECISION / LOG_BASE + 2);
786
+ if (nIsBig) {
787
+ half = new BigNumber(.5);
788
+ if (nIsNeg) n.s = 1;
789
+ nIsOdd = isOdd(n);
790
+ } else {
791
+ i = Math.abs(+valueOf(n));
792
+ nIsOdd = i % 2;
793
+ }
794
+ y = new BigNumber(ONE);
795
+ for (;;) {
796
+ if (nIsOdd) {
797
+ y = y.times(x);
798
+ if (!y.c) break;
799
+ if (k) {
800
+ if (y.c.length > k) y.c.length = k;
801
+ } else if (isModExp) y = y.mod(m);
802
+ }
803
+ if (i) {
804
+ i = mathfloor(i / 2);
805
+ if (i === 0) break;
806
+ nIsOdd = i % 2;
807
+ } else {
808
+ n = n.times(half);
809
+ round(n, n.e + 1, 1);
810
+ if (n.e > 14) nIsOdd = isOdd(n);
811
+ else {
812
+ i = +valueOf(n);
813
+ if (i === 0) break;
814
+ nIsOdd = i % 2;
815
+ }
816
+ }
817
+ x = x.times(x);
818
+ if (k) {
819
+ if (x.c && x.c.length > k) x.c.length = k;
820
+ } else if (isModExp) x = x.mod(m);
821
+ }
822
+ if (isModExp) return y;
823
+ if (nIsNeg) y = ONE.div(y);
824
+ return m ? y.mod(m) : k ? round(y, POW_PRECISION, ROUNDING_MODE, more) : y;
825
+ };
826
+ P.integerValue = function(rm) {
827
+ var n = new BigNumber(this);
828
+ if (rm == null) rm = ROUNDING_MODE;
829
+ else intCheck(rm, 0, 8);
830
+ return round(n, n.e + 1, rm);
831
+ };
832
+ P.isEqualTo = P.eq = function(y, b) {
833
+ return compare(this, new BigNumber(y, b)) === 0;
834
+ };
835
+ P.isFinite = function() {
836
+ return !!this.c;
837
+ };
838
+ P.isGreaterThan = P.gt = function(y, b) {
839
+ return compare(this, new BigNumber(y, b)) > 0;
840
+ };
841
+ P.isGreaterThanOrEqualTo = P.gte = function(y, b) {
842
+ return (b = compare(this, new BigNumber(y, b))) === 1 || b === 0;
843
+ };
844
+ P.isInteger = function() {
845
+ return !!this.c && bitFloor(this.e / LOG_BASE) > this.c.length - 2;
846
+ };
847
+ P.isLessThan = P.lt = function(y, b) {
848
+ return compare(this, new BigNumber(y, b)) < 0;
849
+ };
850
+ P.isLessThanOrEqualTo = P.lte = function(y, b) {
851
+ return (b = compare(this, new BigNumber(y, b))) === -1 || b === 0;
852
+ };
853
+ P.isNaN = function() {
854
+ return !this.s;
855
+ };
856
+ P.isNegative = function() {
857
+ return this.s < 0;
858
+ };
859
+ P.isPositive = function() {
860
+ return this.s > 0;
861
+ };
862
+ P.isZero = function() {
863
+ return !!this.c && this.c[0] == 0;
864
+ };
865
+ P.minus = function(y, b) {
866
+ var i, j, t, xLTy, x = this, a = x.s;
867
+ y = new BigNumber(y, b);
868
+ b = y.s;
869
+ if (!a || !b) return new BigNumber(NaN);
870
+ if (a != b) {
871
+ y.s = -b;
872
+ return x.plus(y);
873
+ }
874
+ var xe = x.e / LOG_BASE, ye = y.e / LOG_BASE, xc = x.c, yc = y.c;
875
+ if (!xe || !ye) {
876
+ if (!xc || !yc) return xc ? (y.s = -b, y) : new BigNumber(yc ? x : NaN);
877
+ if (!xc[0] || !yc[0]) return yc[0] ? (y.s = -b, y) : new BigNumber(xc[0] ? x : ROUNDING_MODE == 3 ? -0 : 0);
878
+ }
879
+ xe = bitFloor(xe);
880
+ ye = bitFloor(ye);
881
+ xc = xc.slice();
882
+ if (a = xe - ye) {
883
+ if (xLTy = a < 0) {
884
+ a = -a;
885
+ t = xc;
886
+ } else {
887
+ ye = xe;
888
+ t = yc;
889
+ }
890
+ t.reverse();
891
+ for (b = a; b--; t.push(0));
892
+ t.reverse();
893
+ } else {
894
+ j = (xLTy = (a = xc.length) < (b = yc.length)) ? a : b;
895
+ for (a = b = 0; b < j; b++) if (xc[b] != yc[b]) {
896
+ xLTy = xc[b] < yc[b];
897
+ break;
898
+ }
899
+ }
900
+ if (xLTy) {
901
+ t = xc;
902
+ xc = yc;
903
+ yc = t;
904
+ y.s = -y.s;
905
+ }
906
+ b = (j = yc.length) - (i = xc.length);
907
+ if (b > 0) for (; b--; xc[i++] = 0);
908
+ b = BASE - 1;
909
+ for (; j > a;) {
910
+ if (xc[--j] < yc[j]) {
911
+ for (i = j; i && !xc[--i]; xc[i] = b);
912
+ --xc[i];
913
+ xc[j] += BASE;
914
+ }
915
+ xc[j] -= yc[j];
916
+ }
917
+ for (; xc[0] == 0; xc.splice(0, 1), --ye);
918
+ if (!xc[0]) {
919
+ y.s = ROUNDING_MODE == 3 ? -1 : 1;
920
+ y.c = [y.e = 0];
921
+ return y;
922
+ }
923
+ return normalise(y, xc, ye);
924
+ };
925
+ P.modulo = P.mod = function(y, b) {
926
+ var q, s, x = this;
927
+ y = new BigNumber(y, b);
928
+ if (!x.c || !y.s || y.c && !y.c[0]) return new BigNumber(NaN);
929
+ else if (!y.c || x.c && !x.c[0]) return new BigNumber(x);
930
+ if (MODULO_MODE == 9) {
931
+ s = y.s;
932
+ y.s = 1;
933
+ q = div(x, y, 0, 3);
934
+ y.s = s;
935
+ q.s *= s;
936
+ } else q = div(x, y, 0, MODULO_MODE);
937
+ y = x.minus(q.times(y));
938
+ if (!y.c[0] && MODULO_MODE == 1) y.s = x.s;
939
+ return y;
940
+ };
941
+ P.multipliedBy = P.times = function(y, b) {
942
+ var c, e, i, j, k, m, xcL, xlo, xhi, ycL, ylo, yhi, zc, base, sqrtBase, x = this, xc = x.c, yc = (y = new BigNumber(y, b)).c;
943
+ if (!xc || !yc || !xc[0] || !yc[0]) {
944
+ if (!x.s || !y.s || xc && !xc[0] && !yc || yc && !yc[0] && !xc) y.c = y.e = y.s = null;
945
+ else {
946
+ y.s *= x.s;
947
+ if (!xc || !yc) y.c = y.e = null;
948
+ else {
949
+ y.c = [0];
950
+ y.e = 0;
951
+ }
952
+ }
953
+ return y;
954
+ }
955
+ e = bitFloor(x.e / LOG_BASE) + bitFloor(y.e / LOG_BASE);
956
+ y.s *= x.s;
957
+ xcL = xc.length;
958
+ ycL = yc.length;
959
+ if (xcL < ycL) {
960
+ zc = xc;
961
+ xc = yc;
962
+ yc = zc;
963
+ i = xcL;
964
+ xcL = ycL;
965
+ ycL = i;
966
+ }
967
+ for (i = xcL + ycL, zc = []; i--; zc.push(0));
968
+ base = BASE;
969
+ sqrtBase = SQRT_BASE;
970
+ for (i = ycL; --i >= 0;) {
971
+ c = 0;
972
+ ylo = yc[i] % sqrtBase;
973
+ yhi = yc[i] / sqrtBase | 0;
974
+ for (k = xcL, j = i + k; j > i;) {
975
+ xlo = xc[--k] % sqrtBase;
976
+ xhi = xc[k] / sqrtBase | 0;
977
+ m = yhi * xlo + xhi * ylo;
978
+ xlo = ylo * xlo + m % sqrtBase * sqrtBase + zc[j] + c;
979
+ c = (xlo / base | 0) + (m / sqrtBase | 0) + yhi * xhi;
980
+ zc[j--] = xlo % base;
981
+ }
982
+ zc[j] = c;
983
+ }
984
+ if (c) ++e;
985
+ else zc.splice(0, 1);
986
+ return normalise(y, zc, e);
987
+ };
988
+ P.negated = function() {
989
+ var x = new BigNumber(this);
990
+ x.s = -x.s || null;
991
+ return x;
992
+ };
993
+ P.plus = function(y, b) {
994
+ var t, x = this, a = x.s;
995
+ y = new BigNumber(y, b);
996
+ b = y.s;
997
+ if (!a || !b) return new BigNumber(NaN);
998
+ if (a != b) {
999
+ y.s = -b;
1000
+ return x.minus(y);
1001
+ }
1002
+ var xe = x.e / LOG_BASE, ye = y.e / LOG_BASE, xc = x.c, yc = y.c;
1003
+ if (!xe || !ye) {
1004
+ if (!xc || !yc) return new BigNumber(a / 0);
1005
+ if (!xc[0] || !yc[0]) return yc[0] ? y : new BigNumber(xc[0] ? x : a * 0);
1006
+ }
1007
+ xe = bitFloor(xe);
1008
+ ye = bitFloor(ye);
1009
+ xc = xc.slice();
1010
+ if (a = xe - ye) {
1011
+ if (a > 0) {
1012
+ ye = xe;
1013
+ t = yc;
1014
+ } else {
1015
+ a = -a;
1016
+ t = xc;
1017
+ }
1018
+ t.reverse();
1019
+ for (; a--; t.push(0));
1020
+ t.reverse();
1021
+ }
1022
+ a = xc.length;
1023
+ b = yc.length;
1024
+ if (a - b < 0) {
1025
+ t = yc;
1026
+ yc = xc;
1027
+ xc = t;
1028
+ b = a;
1029
+ }
1030
+ for (a = 0; b;) {
1031
+ a = (xc[--b] = xc[b] + yc[b] + a) / BASE | 0;
1032
+ xc[b] = BASE === xc[b] ? 0 : xc[b] % BASE;
1033
+ }
1034
+ if (a) {
1035
+ xc = [a].concat(xc);
1036
+ ++ye;
1037
+ }
1038
+ return normalise(y, xc, ye);
1039
+ };
1040
+ P.precision = P.sd = function(sd, rm) {
1041
+ var c, n, v, x = this;
1042
+ if (sd != null && sd !== !!sd) {
1043
+ intCheck(sd, 1, MAX);
1044
+ if (rm == null) rm = ROUNDING_MODE;
1045
+ else intCheck(rm, 0, 8);
1046
+ return round(new BigNumber(x), sd, rm);
1047
+ }
1048
+ if (!(c = x.c)) return null;
1049
+ v = c.length - 1;
1050
+ n = v * LOG_BASE + 1;
1051
+ if (v = c[v]) {
1052
+ for (; v % 10 == 0; v /= 10, n--);
1053
+ for (v = c[0]; v >= 10; v /= 10, n++);
1054
+ }
1055
+ if (sd && x.e + 1 > n) n = x.e + 1;
1056
+ return n;
1057
+ };
1058
+ P.shiftedBy = function(k) {
1059
+ intCheck(k, -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER);
1060
+ return this.times("1e" + k);
1061
+ };
1062
+ P.squareRoot = P.sqrt = function() {
1063
+ var m, n, r, rep, t, x = this, c = x.c, s = x.s, e = x.e, dp = DECIMAL_PLACES + 4, half = new BigNumber("0.5");
1064
+ if (s !== 1 || !c || !c[0]) return new BigNumber(!s || s < 0 && (!c || c[0]) ? NaN : c ? x : Infinity);
1065
+ s = Math.sqrt(+valueOf(x));
1066
+ if (s == 0 || s == Infinity) {
1067
+ n = coeffToString(c);
1068
+ if ((n.length + e) % 2 == 0) n += "0";
1069
+ s = Math.sqrt(+n);
1070
+ e = bitFloor((e + 1) / 2) - (e < 0 || e % 2);
1071
+ if (s == Infinity) n = "5e" + e;
1072
+ else {
1073
+ n = s.toExponential();
1074
+ n = n.slice(0, n.indexOf("e") + 1) + e;
1075
+ }
1076
+ r = new BigNumber(n);
1077
+ } else r = new BigNumber(s + "");
1078
+ if (r.c[0]) {
1079
+ e = r.e;
1080
+ s = e + dp;
1081
+ if (s < 3) s = 0;
1082
+ for (;;) {
1083
+ t = r;
1084
+ r = half.times(t.plus(div(x, t, dp, 1)));
1085
+ if (coeffToString(t.c).slice(0, s) === (n = coeffToString(r.c)).slice(0, s)) {
1086
+ if (r.e < e) --s;
1087
+ n = n.slice(s - 3, s + 1);
1088
+ if (n == "9999" || !rep && n == "4999") {
1089
+ if (!rep) {
1090
+ round(t, t.e + DECIMAL_PLACES + 2, 0);
1091
+ if (t.times(t).eq(x)) {
1092
+ r = t;
1093
+ break;
1094
+ }
1095
+ }
1096
+ dp += 4;
1097
+ s += 4;
1098
+ rep = 1;
1099
+ } else {
1100
+ if (!+n || !+n.slice(1) && n.charAt(0) == "5") {
1101
+ round(r, r.e + DECIMAL_PLACES + 2, 1);
1102
+ m = !r.times(r).eq(x);
1103
+ }
1104
+ break;
1105
+ }
1106
+ }
1107
+ }
1108
+ }
1109
+ return round(r, r.e + DECIMAL_PLACES + 1, ROUNDING_MODE, m);
1110
+ };
1111
+ P.toExponential = function(dp, rm) {
1112
+ if (dp != null) {
1113
+ intCheck(dp, 0, MAX);
1114
+ dp++;
1115
+ }
1116
+ return format(this, dp, rm, 1);
1117
+ };
1118
+ P.toFixed = function(dp, rm) {
1119
+ if (dp != null) {
1120
+ intCheck(dp, 0, MAX);
1121
+ dp = dp + this.e + 1;
1122
+ }
1123
+ return format(this, dp, rm);
1124
+ };
1125
+ P.toFormat = function(dp, rm, format) {
1126
+ var str, x = this;
1127
+ if (format == null) if (dp != null && rm && typeof rm == "object") {
1128
+ format = rm;
1129
+ rm = null;
1130
+ } else if (dp && typeof dp == "object") {
1131
+ format = dp;
1132
+ dp = rm = null;
1133
+ } else format = FORMAT;
1134
+ else if (typeof format != "object") throw Error(bignumberError + "Argument not an object: " + format);
1135
+ str = x.toFixed(dp, rm);
1136
+ if (x.c) {
1137
+ var i, arr = str.split("."), g1 = +format.groupSize, g2 = +format.secondaryGroupSize, groupSeparator = format.groupSeparator || "", intPart = arr[0], fractionPart = arr[1], isNeg = x.s < 0, intDigits = isNeg ? intPart.slice(1) : intPart, len = intDigits.length;
1138
+ if (g2) {
1139
+ i = g1;
1140
+ g1 = g2;
1141
+ g2 = i;
1142
+ len -= i;
1143
+ }
1144
+ if (g1 > 0 && len > 0) {
1145
+ i = len % g1 || g1;
1146
+ intPart = intDigits.substr(0, i);
1147
+ for (; i < len; i += g1) intPart += groupSeparator + intDigits.substr(i, g1);
1148
+ if (g2 > 0) intPart += groupSeparator + intDigits.slice(i);
1149
+ if (isNeg) intPart = "-" + intPart;
1150
+ }
1151
+ str = fractionPart ? intPart + (format.decimalSeparator || "") + ((g2 = +format.fractionGroupSize) ? fractionPart.replace(new RegExp("\\d{" + g2 + "}\\B", "g"), "$&" + (format.fractionGroupSeparator || "")) : fractionPart) : intPart;
1152
+ }
1153
+ return (format.prefix || "") + str + (format.suffix || "");
1154
+ };
1155
+ P.toFraction = function(md) {
1156
+ var d, d0, d1, d2, e, exp, n, n0, n1, q, r, s, x = this, xc = x.c;
1157
+ if (md != null) {
1158
+ n = new BigNumber(md);
1159
+ if (!n.isInteger() && (n.c || n.s !== 1) || n.lt(ONE)) throw Error(bignumberError + "Argument " + (n.isInteger() ? "out of range: " : "not an integer: ") + valueOf(n));
1160
+ }
1161
+ if (!xc) return new BigNumber(x);
1162
+ d = new BigNumber(ONE);
1163
+ n1 = d0 = new BigNumber(ONE);
1164
+ d1 = n0 = new BigNumber(ONE);
1165
+ s = coeffToString(xc);
1166
+ e = d.e = s.length - x.e - 1;
1167
+ d.c[0] = POWS_TEN[(exp = e % LOG_BASE) < 0 ? LOG_BASE + exp : exp];
1168
+ md = !md || n.comparedTo(d) > 0 ? e > 0 ? d : n1 : n;
1169
+ exp = MAX_EXP;
1170
+ MAX_EXP = Infinity;
1171
+ n = new BigNumber(s);
1172
+ n0.c[0] = 0;
1173
+ for (;;) {
1174
+ q = div(n, d, 0, 1);
1175
+ d2 = d0.plus(q.times(d1));
1176
+ if (d2.comparedTo(md) == 1) break;
1177
+ d0 = d1;
1178
+ d1 = d2;
1179
+ n1 = n0.plus(q.times(d2 = n1));
1180
+ n0 = d2;
1181
+ d = n.minus(q.times(d2 = d));
1182
+ n = d2;
1183
+ }
1184
+ d2 = div(md.minus(d0), d1, 0, 1);
1185
+ n0 = n0.plus(d2.times(n1));
1186
+ d0 = d0.plus(d2.times(d1));
1187
+ n0.s = n1.s = x.s;
1188
+ e = e * 2;
1189
+ r = div(n1, d1, e, ROUNDING_MODE).minus(x).abs().comparedTo(div(n0, d0, e, ROUNDING_MODE).minus(x).abs()) < 1 ? [n1, d1] : [n0, d0];
1190
+ MAX_EXP = exp;
1191
+ return r;
1192
+ };
1193
+ P.toNumber = function() {
1194
+ return +valueOf(this);
1195
+ };
1196
+ P.toPrecision = function(sd, rm) {
1197
+ if (sd != null) intCheck(sd, 1, MAX);
1198
+ return format(this, sd, rm, 2);
1199
+ };
1200
+ P.toString = function(b) {
1201
+ var str, n = this, s = n.s, e = n.e;
1202
+ if (e === null) if (s) {
1203
+ str = "Infinity";
1204
+ if (s < 0) str = "-" + str;
1205
+ } else str = "NaN";
1206
+ else {
1207
+ if (b == null) str = e <= TO_EXP_NEG || e >= TO_EXP_POS ? toExponential(coeffToString(n.c), e) : toFixedPoint(coeffToString(n.c), e, "0");
1208
+ else if (b === 10 && alphabetHasNormalDecimalDigits) {
1209
+ n = round(new BigNumber(n), DECIMAL_PLACES + e + 1, ROUNDING_MODE);
1210
+ str = toFixedPoint(coeffToString(n.c), n.e, "0");
1211
+ } else {
1212
+ intCheck(b, 2, ALPHABET.length, "Base");
1213
+ str = convertBase(toFixedPoint(coeffToString(n.c), e, "0"), 10, b, s, true);
1214
+ }
1215
+ if (s < 0 && n.c[0]) str = "-" + str;
1216
+ }
1217
+ return str;
1218
+ };
1219
+ P.valueOf = P.toJSON = function() {
1220
+ return valueOf(this);
1221
+ };
1222
+ P._isBigNumber = true;
1223
+ if (configObject != null) BigNumber.set(configObject);
1224
+ return BigNumber;
1225
+ }
1226
+ function bitFloor(n) {
1227
+ var i = n | 0;
1228
+ return n > 0 || n === i ? i : i - 1;
1229
+ }
1230
+ function coeffToString(a) {
1231
+ var s, z, i = 1, j = a.length, r = a[0] + "";
1232
+ for (; i < j;) {
1233
+ s = a[i++] + "";
1234
+ z = LOG_BASE - s.length;
1235
+ for (; z--; s = "0" + s);
1236
+ r += s;
1237
+ }
1238
+ for (j = r.length; r.charCodeAt(--j) === 48;);
1239
+ return r.slice(0, j + 1 || 1);
1240
+ }
1241
+ function compare(x, y) {
1242
+ var a, b, xc = x.c, yc = y.c, i = x.s, j = y.s, k = x.e, l = y.e;
1243
+ if (!i || !j) return null;
1244
+ a = xc && !xc[0];
1245
+ b = yc && !yc[0];
1246
+ if (a || b) return a ? b ? 0 : -j : i;
1247
+ if (i != j) return i;
1248
+ a = i < 0;
1249
+ b = k == l;
1250
+ if (!xc || !yc) return b ? 0 : !xc ^ a ? 1 : -1;
1251
+ if (!b) return k > l ^ a ? 1 : -1;
1252
+ j = (k = xc.length) < (l = yc.length) ? k : l;
1253
+ for (i = 0; i < j; i++) if (xc[i] != yc[i]) return xc[i] > yc[i] ^ a ? 1 : -1;
1254
+ return k == l ? 0 : k > l ^ a ? 1 : -1;
1255
+ }
1256
+ function intCheck(n, min, max, name) {
1257
+ if (n < min || n > max || n !== mathfloor(n)) throw Error(bignumberError + (name || "Argument") + (typeof n == "number" ? n < min || n > max ? " out of range: " : " not an integer: " : " not a primitive number: ") + String(n));
1258
+ }
1259
+ function isOdd(n) {
1260
+ var k = n.c.length - 1;
1261
+ return bitFloor(n.e / LOG_BASE) == k && n.c[k] % 2 != 0;
1262
+ }
1263
+ function toExponential(str, e) {
1264
+ return (str.length > 1 ? str.charAt(0) + "." + str.slice(1) : str) + (e < 0 ? "e" : "e+") + e;
1265
+ }
1266
+ function toFixedPoint(str, e, z) {
1267
+ var len, zs;
1268
+ if (e < 0) {
1269
+ for (zs = z + "."; ++e; zs += z);
1270
+ str = zs + str;
1271
+ } else {
1272
+ len = str.length;
1273
+ if (++e > len) {
1274
+ for (zs = z, e -= len; --e; zs += z);
1275
+ str += zs;
1276
+ } else if (e < len) str = str.slice(0, e) + "." + str.slice(e);
1277
+ }
1278
+ return str;
1279
+ }
1280
+ BigNumber = clone();
1281
+ BigNumber["default"] = BigNumber.BigNumber = BigNumber;
1282
+ if (typeof define == "function" && define.amd) define(function() {
1283
+ return BigNumber;
1284
+ });
1285
+ else if (typeof module != "undefined" && module.exports) module.exports = BigNumber;
1286
+ else {
1287
+ if (!globalObject) globalObject = typeof self != "undefined" && self ? self : window;
1288
+ globalObject.BigNumber = BigNumber;
1289
+ }
1290
+ })(exports);
1291
+ }));
1292
+ //#endregion
1293
+ //#region ../../node_modules/.pnpm/json-bigint@1.0.0/node_modules/json-bigint/lib/stringify.js
1294
+ var require_stringify = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1295
+ var BigNumber = require_bignumber();
1296
+ var JSON = module.exports;
1297
+ (function() {
1298
+ "use strict";
1299
+ var escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, gap, indent, meta = {
1300
+ "\b": "\\b",
1301
+ " ": "\\t",
1302
+ "\n": "\\n",
1303
+ "\f": "\\f",
1304
+ "\r": "\\r",
1305
+ "\"": "\\\"",
1306
+ "\\": "\\\\"
1307
+ }, rep;
1308
+ function quote(string) {
1309
+ escapable.lastIndex = 0;
1310
+ return escapable.test(string) ? "\"" + string.replace(escapable, function(a) {
1311
+ var c = meta[a];
1312
+ return typeof c === "string" ? c : "\\u" + ("0000" + a.charCodeAt(0).toString(16)).slice(-4);
1313
+ }) + "\"" : "\"" + string + "\"";
1314
+ }
1315
+ function str(key, holder) {
1316
+ var i, k, v, length, mind = gap, partial, value = holder[key], isBigNumber = value != null && (value instanceof BigNumber || BigNumber.isBigNumber(value));
1317
+ if (value && typeof value === "object" && typeof value.toJSON === "function") value = value.toJSON(key);
1318
+ if (typeof rep === "function") value = rep.call(holder, key, value);
1319
+ switch (typeof value) {
1320
+ case "string": if (isBigNumber) return value;
1321
+ else return quote(value);
1322
+ case "number": return isFinite(value) ? String(value) : "null";
1323
+ case "boolean":
1324
+ case "null":
1325
+ case "bigint": return String(value);
1326
+ case "object":
1327
+ if (!value) return "null";
1328
+ gap += indent;
1329
+ partial = [];
1330
+ if (Object.prototype.toString.apply(value) === "[object Array]") {
1331
+ length = value.length;
1332
+ for (i = 0; i < length; i += 1) partial[i] = str(i, value) || "null";
1333
+ v = partial.length === 0 ? "[]" : gap ? "[\n" + gap + partial.join(",\n" + gap) + "\n" + mind + "]" : "[" + partial.join(",") + "]";
1334
+ gap = mind;
1335
+ return v;
1336
+ }
1337
+ if (rep && typeof rep === "object") {
1338
+ length = rep.length;
1339
+ for (i = 0; i < length; i += 1) if (typeof rep[i] === "string") {
1340
+ k = rep[i];
1341
+ v = str(k, value);
1342
+ if (v) partial.push(quote(k) + (gap ? ": " : ":") + v);
1343
+ }
1344
+ } else Object.keys(value).forEach(function(k) {
1345
+ var v = str(k, value);
1346
+ if (v) partial.push(quote(k) + (gap ? ": " : ":") + v);
1347
+ });
1348
+ v = partial.length === 0 ? "{}" : gap ? "{\n" + gap + partial.join(",\n" + gap) + "\n" + mind + "}" : "{" + partial.join(",") + "}";
1349
+ gap = mind;
1350
+ return v;
1351
+ }
1352
+ }
1353
+ if (typeof JSON.stringify !== "function") JSON.stringify = function(value, replacer, space) {
1354
+ var i;
1355
+ gap = "";
1356
+ indent = "";
1357
+ if (typeof space === "number") for (i = 0; i < space; i += 1) indent += " ";
1358
+ else if (typeof space === "string") indent = space;
1359
+ rep = replacer;
1360
+ if (replacer && typeof replacer !== "function" && (typeof replacer !== "object" || typeof replacer.length !== "number")) throw new Error("JSON.stringify");
1361
+ return str("", { "": value });
1362
+ };
1363
+ })();
1364
+ }));
1365
+ //#endregion
1366
+ //#region ../../node_modules/.pnpm/json-bigint@1.0.0/node_modules/json-bigint/lib/parse.js
1367
+ var require_parse = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1368
+ var BigNumber = null;
1369
+ var suspectProtoRx = /(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])/;
1370
+ 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)/;
1371
+ var json_parse = function(options) {
1372
+ "use strict";
1373
+ var _options = {
1374
+ strict: false,
1375
+ storeAsString: false,
1376
+ alwaysParseAsBig: false,
1377
+ useNativeBigInt: false,
1378
+ protoAction: "error",
1379
+ constructorAction: "error"
1380
+ };
1381
+ if (options !== void 0 && options !== null) {
1382
+ if (options.strict === true) _options.strict = true;
1383
+ if (options.storeAsString === true) _options.storeAsString = true;
1384
+ _options.alwaysParseAsBig = options.alwaysParseAsBig === true ? options.alwaysParseAsBig : false;
1385
+ _options.useNativeBigInt = options.useNativeBigInt === true ? options.useNativeBigInt : false;
1386
+ if (typeof options.constructorAction !== "undefined") if (options.constructorAction === "error" || options.constructorAction === "ignore" || options.constructorAction === "preserve") _options.constructorAction = options.constructorAction;
1387
+ else throw new Error(`Incorrect value for constructorAction option, must be "error", "ignore" or undefined but passed ${options.constructorAction}`);
1388
+ if (typeof options.protoAction !== "undefined") if (options.protoAction === "error" || options.protoAction === "ignore" || options.protoAction === "preserve") _options.protoAction = options.protoAction;
1389
+ else throw new Error(`Incorrect value for protoAction option, must be "error", "ignore" or undefined but passed ${options.protoAction}`);
1390
+ }
1391
+ var at, ch, escapee = {
1392
+ "\"": "\"",
1393
+ "\\": "\\",
1394
+ "/": "/",
1395
+ b: "\b",
1396
+ f: "\f",
1397
+ n: "\n",
1398
+ r: "\r",
1399
+ t: " "
1400
+ }, text, error = function(m) {
1401
+ throw {
1402
+ name: "SyntaxError",
1403
+ message: m,
1404
+ at,
1405
+ text
1406
+ };
1407
+ }, next = function(c) {
1408
+ if (c && c !== ch) error("Expected '" + c + "' instead of '" + ch + "'");
1409
+ ch = text.charAt(at);
1410
+ at += 1;
1411
+ return ch;
1412
+ }, number = function() {
1413
+ var number, string = "";
1414
+ if (ch === "-") {
1415
+ string = "-";
1416
+ next("-");
1417
+ }
1418
+ while (ch >= "0" && ch <= "9") {
1419
+ string += ch;
1420
+ next();
1421
+ }
1422
+ if (ch === ".") {
1423
+ string += ".";
1424
+ while (next() && ch >= "0" && ch <= "9") string += ch;
1425
+ }
1426
+ if (ch === "e" || ch === "E") {
1427
+ string += ch;
1428
+ next();
1429
+ if (ch === "-" || ch === "+") {
1430
+ string += ch;
1431
+ next();
1432
+ }
1433
+ while (ch >= "0" && ch <= "9") {
1434
+ string += ch;
1435
+ next();
1436
+ }
1437
+ }
1438
+ number = +string;
1439
+ if (!isFinite(number)) error("Bad number");
1440
+ else {
1441
+ if (BigNumber == null) BigNumber = require_bignumber();
1442
+ if (string.length > 15) return _options.storeAsString ? string : _options.useNativeBigInt ? BigInt(string) : new BigNumber(string);
1443
+ else return !_options.alwaysParseAsBig ? number : _options.useNativeBigInt ? BigInt(number) : new BigNumber(number);
1444
+ }
1445
+ }, string = function() {
1446
+ var hex, i, string = "", uffff;
1447
+ if (ch === "\"") {
1448
+ var startAt = at;
1449
+ while (next()) {
1450
+ if (ch === "\"") {
1451
+ if (at - 1 > startAt) string += text.substring(startAt, at - 1);
1452
+ next();
1453
+ return string;
1454
+ }
1455
+ if (ch === "\\") {
1456
+ if (at - 1 > startAt) string += text.substring(startAt, at - 1);
1457
+ next();
1458
+ if (ch === "u") {
1459
+ uffff = 0;
1460
+ for (i = 0; i < 4; i += 1) {
1461
+ hex = parseInt(next(), 16);
1462
+ if (!isFinite(hex)) break;
1463
+ uffff = uffff * 16 + hex;
1464
+ }
1465
+ string += String.fromCharCode(uffff);
1466
+ } else if (typeof escapee[ch] === "string") string += escapee[ch];
1467
+ else break;
1468
+ startAt = at;
1469
+ }
1470
+ }
1471
+ }
1472
+ error("Bad string");
1473
+ }, white = function() {
1474
+ while (ch && ch <= " ") next();
1475
+ }, word = function() {
1476
+ switch (ch) {
1477
+ case "t":
1478
+ next("t");
1479
+ next("r");
1480
+ next("u");
1481
+ next("e");
1482
+ return true;
1483
+ case "f":
1484
+ next("f");
1485
+ next("a");
1486
+ next("l");
1487
+ next("s");
1488
+ next("e");
1489
+ return false;
1490
+ case "n":
1491
+ next("n");
1492
+ next("u");
1493
+ next("l");
1494
+ next("l");
1495
+ return null;
1496
+ }
1497
+ error("Unexpected '" + ch + "'");
1498
+ }, value, array = function() {
1499
+ var array = [];
1500
+ if (ch === "[") {
1501
+ next("[");
1502
+ white();
1503
+ if (ch === "]") {
1504
+ next("]");
1505
+ return array;
1506
+ }
1507
+ while (ch) {
1508
+ array.push(value());
1509
+ white();
1510
+ if (ch === "]") {
1511
+ next("]");
1512
+ return array;
1513
+ }
1514
+ next(",");
1515
+ white();
1516
+ }
1517
+ }
1518
+ error("Bad array");
1519
+ }, object = function() {
1520
+ var key, object = Object.create(null);
1521
+ if (ch === "{") {
1522
+ next("{");
1523
+ white();
1524
+ if (ch === "}") {
1525
+ next("}");
1526
+ return object;
1527
+ }
1528
+ while (ch) {
1529
+ key = string();
1530
+ white();
1531
+ next(":");
1532
+ if (_options.strict === true && Object.hasOwnProperty.call(object, key)) error("Duplicate key \"" + key + "\"");
1533
+ if (suspectProtoRx.test(key) === true) if (_options.protoAction === "error") error("Object contains forbidden prototype property");
1534
+ else if (_options.protoAction === "ignore") value();
1535
+ else object[key] = value();
1536
+ else if (suspectConstructorRx.test(key) === true) if (_options.constructorAction === "error") error("Object contains forbidden constructor property");
1537
+ else if (_options.constructorAction === "ignore") value();
1538
+ else object[key] = value();
1539
+ else object[key] = value();
1540
+ white();
1541
+ if (ch === "}") {
1542
+ next("}");
1543
+ return object;
1544
+ }
1545
+ next(",");
1546
+ white();
1547
+ }
1548
+ }
1549
+ error("Bad object");
1550
+ };
1551
+ value = function() {
1552
+ white();
1553
+ switch (ch) {
1554
+ case "{": return object();
1555
+ case "[": return array();
1556
+ case "\"": return string();
1557
+ case "-": return number();
1558
+ default: return ch >= "0" && ch <= "9" ? number() : word();
1559
+ }
1560
+ };
1561
+ return function(source, reviver) {
1562
+ var result;
1563
+ text = source + "";
1564
+ at = 0;
1565
+ ch = " ";
1566
+ result = value();
1567
+ white();
1568
+ if (ch) error("Syntax error");
1569
+ return typeof reviver === "function" ? (function walk(holder, key) {
1570
+ var v, value = holder[key];
1571
+ if (value && typeof value === "object") Object.keys(value).forEach(function(k) {
1572
+ v = walk(value, k);
1573
+ if (v !== void 0) value[k] = v;
1574
+ else delete value[k];
1575
+ });
1576
+ return reviver.call(holder, key, value);
1577
+ })({ "": result }, "") : result;
1578
+ };
1579
+ };
1580
+ module.exports = json_parse;
1581
+ }));
1582
+ //#endregion
1583
+ //#region ../../node_modules/.pnpm/json-bigint@1.0.0/node_modules/json-bigint/index.js
1584
+ var require_json_bigint = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1585
+ var json_stringify = require_stringify().stringify;
1586
+ var json_parse = require_parse();
1587
+ module.exports = function(options) {
1588
+ return {
1589
+ parse: json_parse(options),
1590
+ stringify: json_stringify
1591
+ };
1592
+ };
1593
+ module.exports.parse = json_parse();
1594
+ module.exports.stringify = json_stringify;
1595
+ }));
1596
+ //#endregion
1597
+ //#region ../../node_modules/.pnpm/base64-js@1.5.1/node_modules/base64-js/index.js
1598
+ var require_base64_js = /* @__PURE__ */ __commonJSMin(((exports) => {
1599
+ exports.byteLength = byteLength;
1600
+ exports.toByteArray = toByteArray;
1601
+ exports.fromByteArray = fromByteArray;
1602
+ var lookup = [];
1603
+ var revLookup = [];
1604
+ var Arr = typeof Uint8Array !== "undefined" ? Uint8Array : Array;
1605
+ var code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
1606
+ for (var i = 0, len = code.length; i < len; ++i) {
1607
+ lookup[i] = code[i];
1608
+ revLookup[code.charCodeAt(i)] = i;
1609
+ }
1610
+ revLookup["-".charCodeAt(0)] = 62;
1611
+ revLookup["_".charCodeAt(0)] = 63;
1612
+ function getLens(b64) {
1613
+ var len = b64.length;
1614
+ if (len % 4 > 0) throw new Error("Invalid string. Length must be a multiple of 4");
1615
+ var validLen = b64.indexOf("=");
1616
+ if (validLen === -1) validLen = len;
1617
+ var placeHoldersLen = validLen === len ? 0 : 4 - validLen % 4;
1618
+ return [validLen, placeHoldersLen];
1619
+ }
1620
+ function byteLength(b64) {
1621
+ var lens = getLens(b64);
1622
+ var validLen = lens[0];
1623
+ var placeHoldersLen = lens[1];
1624
+ return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen;
1625
+ }
1626
+ function _byteLength(b64, validLen, placeHoldersLen) {
1627
+ return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen;
1628
+ }
1629
+ function toByteArray(b64) {
1630
+ var tmp;
1631
+ var lens = getLens(b64);
1632
+ var validLen = lens[0];
1633
+ var placeHoldersLen = lens[1];
1634
+ var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen));
1635
+ var curByte = 0;
1636
+ var len = placeHoldersLen > 0 ? validLen - 4 : validLen;
1637
+ var i;
1638
+ for (i = 0; i < len; i += 4) {
1639
+ tmp = revLookup[b64.charCodeAt(i)] << 18 | revLookup[b64.charCodeAt(i + 1)] << 12 | revLookup[b64.charCodeAt(i + 2)] << 6 | revLookup[b64.charCodeAt(i + 3)];
1640
+ arr[curByte++] = tmp >> 16 & 255;
1641
+ arr[curByte++] = tmp >> 8 & 255;
1642
+ arr[curByte++] = tmp & 255;
1643
+ }
1644
+ if (placeHoldersLen === 2) {
1645
+ tmp = revLookup[b64.charCodeAt(i)] << 2 | revLookup[b64.charCodeAt(i + 1)] >> 4;
1646
+ arr[curByte++] = tmp & 255;
1647
+ }
1648
+ if (placeHoldersLen === 1) {
1649
+ tmp = revLookup[b64.charCodeAt(i)] << 10 | revLookup[b64.charCodeAt(i + 1)] << 4 | revLookup[b64.charCodeAt(i + 2)] >> 2;
1650
+ arr[curByte++] = tmp >> 8 & 255;
1651
+ arr[curByte++] = tmp & 255;
1652
+ }
1653
+ return arr;
1654
+ }
1655
+ function tripletToBase64(num) {
1656
+ return lookup[num >> 18 & 63] + lookup[num >> 12 & 63] + lookup[num >> 6 & 63] + lookup[num & 63];
1657
+ }
1658
+ function encodeChunk(uint8, start, end) {
1659
+ var tmp;
1660
+ var output = [];
1661
+ for (var i = start; i < end; i += 3) {
1662
+ tmp = (uint8[i] << 16 & 16711680) + (uint8[i + 1] << 8 & 65280) + (uint8[i + 2] & 255);
1663
+ output.push(tripletToBase64(tmp));
1664
+ }
1665
+ return output.join("");
1666
+ }
1667
+ function fromByteArray(uint8) {
1668
+ var tmp;
1669
+ var len = uint8.length;
1670
+ var extraBytes = len % 3;
1671
+ var parts = [];
1672
+ var maxChunkLength = 16383;
1673
+ for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) parts.push(encodeChunk(uint8, i, i + maxChunkLength > len2 ? len2 : i + maxChunkLength));
1674
+ if (extraBytes === 1) {
1675
+ tmp = uint8[len - 1];
1676
+ parts.push(lookup[tmp >> 2] + lookup[tmp << 4 & 63] + "==");
1677
+ } else if (extraBytes === 2) {
1678
+ tmp = (uint8[len - 2] << 8) + uint8[len - 1];
1679
+ parts.push(lookup[tmp >> 10] + lookup[tmp >> 4 & 63] + lookup[tmp << 2 & 63] + "=");
1680
+ }
1681
+ return parts.join("");
1682
+ }
1683
+ }));
1684
+ //#endregion
1685
+ export { require_json_bigint as n, require_extend as r, require_base64_js as t };
1686
+
1687
+ //# sourceMappingURL=base64-js-C_frYBkI.js.map