@tonyclaw/agent-inspector 3.0.16 → 3.0.17

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 (85) hide show
  1. package/.output/nitro.json +1 -1
  2. package/.output/public/assets/{CompareDrawer-BJmxAiM0.js → CompareDrawer-Lx-WeJNC.js} +1 -1
  3. package/.output/public/assets/{ProxyViewerContainer-C40Nig73.js → ProxyViewerContainer-BNehwMI0.js} +31 -31
  4. package/.output/public/assets/{ReplayDialog-CkLdOMJr.js → ReplayDialog-CADaXFPE.js} +1 -1
  5. package/.output/public/assets/{RequestAnatomy-DemOFfSc.js → RequestAnatomy-CGoL8ACh.js} +1 -1
  6. package/.output/public/assets/{ResponseView-9LhpuDo7.js → ResponseView-BSwM1dCH.js} +2 -2
  7. package/.output/public/assets/{StreamingChunkSequence-RRWYBOdz.js → StreamingChunkSequence-qhWtSx3D.js} +1 -1
  8. package/.output/public/assets/{_sessionId-CWEh2Jsn.js → _sessionId-2uq_HB8p.js} +1 -1
  9. package/.output/public/assets/index-BHXN1Fsx.css +1 -0
  10. package/.output/public/assets/{index-Lwir70Rs.js → index-DPc2wzgW.js} +1 -1
  11. package/.output/public/assets/{index-hjNWJZGE.js → index-T0u1foYL.js} +1 -1
  12. package/.output/public/assets/{json-viewer-D8gvbDlB.js → json-viewer-uIwLntt-.js} +1 -1
  13. package/.output/public/assets/{main-ovrz0tyD.js → main-DuFBHsus.js} +2 -2
  14. package/.output/server/_libs/@opentelemetry/semantic-conventions+[...].mjs +2658 -0
  15. package/.output/server/_libs/agent-base.mjs +234 -0
  16. package/.output/server/_libs/anthropic-ai__sdk.mjs +6042 -0
  17. package/.output/server/_libs/atomically.mjs +3 -0
  18. package/.output/server/_libs/base64-js.mjs +102 -0
  19. package/.output/server/_libs/bignumber.js.mjs +1353 -0
  20. package/.output/server/_libs/buffer-equal-constant-time.mjs +38 -0
  21. package/.output/server/_libs/data-uri-to-buffer.mjs +39 -0
  22. package/.output/server/_libs/debug.mjs +547 -0
  23. package/.output/server/_libs/ecdsa-sig-formatter.mjs +162 -0
  24. package/.output/server/_libs/extend.mjs +2 -1
  25. package/.output/server/_libs/fetch-blob.mjs +287 -0
  26. package/.output/server/_libs/formdata-polyfill.mjs +88 -0
  27. package/.output/server/_libs/gaxios.mjs +927 -0
  28. package/.output/server/_libs/gcp-metadata.mjs +322 -0
  29. package/.output/server/_libs/google-auth-library.mjs +6339 -0
  30. package/.output/server/_libs/google-logging-utils.mjs +385 -0
  31. package/.output/server/_libs/google__genai.mjs +18034 -0
  32. package/.output/server/_libs/has-flag.mjs +16 -0
  33. package/.output/server/_libs/https-proxy-agent.mjs +280 -0
  34. package/.output/server/_libs/json-bigint.mjs +413 -0
  35. package/.output/server/_libs/jwa.mjs +233 -0
  36. package/.output/server/_libs/jws.mjs +298 -0
  37. package/.output/server/_libs/lucide-react.mjs +261 -226
  38. package/.output/server/_libs/mariozechner__pi-agent-core.mjs +824 -0
  39. package/.output/server/_libs/mariozechner__pi-ai.mjs +22889 -0
  40. package/.output/server/_libs/mistralai__mistralai.mjs +32045 -0
  41. package/.output/server/_libs/ms.mjs +120 -0
  42. package/.output/server/_libs/node-domexception.mjs +17 -0
  43. package/.output/server/_libs/node-fetch.mjs +1578 -0
  44. package/.output/server/_libs/ohash.mjs +1 -1
  45. package/.output/server/_libs/openai.mjs +6766 -0
  46. package/.output/server/_libs/opentelemetry__api.mjs +1678 -0
  47. package/.output/server/_libs/p-retry.mjs +87 -0
  48. package/.output/server/_libs/partial-json.mjs +244 -0
  49. package/.output/server/_libs/react-dom.mjs +5 -5
  50. package/.output/server/_libs/react-markdown.mjs +2 -2
  51. package/.output/server/_libs/react.mjs +30 -0
  52. package/.output/server/_libs/readable-stream.mjs +5 -5
  53. package/.output/server/_libs/retry.mjs +236 -0
  54. package/.output/server/_libs/safe-buffer.mjs +63 -1
  55. package/.output/server/_libs/srvx.mjs +2 -2
  56. package/.output/server/_libs/supports-color.mjs +108 -0
  57. package/.output/server/_libs/tanstack__router-core.mjs +1 -1
  58. package/.output/server/_libs/typebox.mjs +6596 -0
  59. package/.output/server/_libs/util-deprecate.mjs +2 -2
  60. package/.output/server/_libs/vfile.mjs +2 -2
  61. package/.output/server/_libs/web-streams-polyfill.mjs +4282 -0
  62. package/.output/server/_libs/ws.mjs +3715 -0
  63. package/.output/server/_libs/zod-to-json-schema.mjs +1207 -0
  64. package/.output/server/_libs/zod.mjs +597 -9
  65. package/.output/server/{_sessionId-zI_GFX_7.mjs → _sessionId-DL2JQJwR.mjs} +14 -13
  66. package/.output/server/_ssr/{CompareDrawer-Ckcx1RVu.mjs → CompareDrawer-hPTOTmyU.mjs} +14 -13
  67. package/.output/server/_ssr/{ProxyViewerContainer-BgXewlIr.mjs → ProxyViewerContainer-k0mFaufl.mjs} +153 -87
  68. package/.output/server/_ssr/{ReplayDialog-wx3nDtZn.mjs → ReplayDialog-t6QdwnZh.mjs} +15 -14
  69. package/.output/server/_ssr/{RequestAnatomy-DN80zt0G.mjs → RequestAnatomy-BnvWxyac.mjs} +14 -13
  70. package/.output/server/_ssr/{ResponseView-DD7rTu_l.mjs → ResponseView-BhhozRRl.mjs} +14 -13
  71. package/.output/server/_ssr/{StreamingChunkSequence-DAgz6Vvw.mjs → StreamingChunkSequence-Dl_laTbX.mjs} +14 -13
  72. package/.output/server/_ssr/{index-dcTjp8du.mjs → index-D1-t1D8F.mjs} +13 -12
  73. package/.output/server/_ssr/index.mjs +4 -4
  74. package/.output/server/_ssr/{json-viewer-N2cuzGWR.mjs → json-viewer-D5Lh2yBU.mjs} +14 -13
  75. package/.output/server/_ssr/{router-BfQ0QsD5.mjs → router-DaLFEeWW.mjs} +523 -97
  76. package/.output/server/_tanstack-start-manifest_v-DsSiD2gY.mjs +4 -0
  77. package/.output/server/index.mjs +76 -76
  78. package/package.json +4 -1
  79. package/src/components/ProxyViewer.tsx +3 -0
  80. package/src/components/pi-agent/PiAgentPanel.tsx +204 -0
  81. package/src/lib/piAgentContract.ts +21 -0
  82. package/src/routes/api/pi-agent.ts +29 -0
  83. package/src/services/piAgent.ts +390 -0
  84. package/.output/public/assets/index-HRfrFVYw.css +0 -1
  85. package/.output/server/_tanstack-start-manifest_v-BXnYrbcJ.mjs +0 -4
@@ -0,0 +1,1353 @@
1
+ var bignumber$1 = { exports: {} };
2
+ var bignumber = bignumber$1.exports;
3
+ var hasRequiredBignumber;
4
+ function requireBignumber() {
5
+ if (hasRequiredBignumber) return bignumber$1.exports;
6
+ hasRequiredBignumber = 1;
7
+ (function(module) {
8
+ (function(globalObject) {
9
+ 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;
10
+ function clone(configObject) {
11
+ 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 = {
12
+ prefix: "",
13
+ groupSize: 3,
14
+ secondaryGroupSize: 0,
15
+ groupSeparator: ",",
16
+ decimalSeparator: ".",
17
+ fractionGroupSize: 0,
18
+ fractionGroupSeparator: " ",
19
+ // non-breaking space
20
+ suffix: ""
21
+ }, ALPHABET = "0123456789abcdefghijklmnopqrstuvwxyz", alphabetHasNormalDecimalDigits = true;
22
+ function BigNumber2(v, b) {
23
+ var alphabet, c, caseChanged, e, i, isNum, len, str, x = this;
24
+ if (!(x instanceof BigNumber2)) return new BigNumber2(v, b);
25
+ if (b == null) {
26
+ if (v && v._isBigNumber === true) {
27
+ x.s = v.s;
28
+ if (!v.c || v.e > MAX_EXP) {
29
+ x.c = x.e = null;
30
+ } else if (v.e < MIN_EXP) {
31
+ x.c = [x.e = 0];
32
+ } else {
33
+ x.e = v.e;
34
+ x.c = v.c.slice();
35
+ }
36
+ return;
37
+ }
38
+ if ((isNum = typeof v == "number") && v * 0 == 0) {
39
+ x.s = 1 / v < 0 ? (v = -v, -1) : 1;
40
+ if (v === ~~v) {
41
+ for (e = 0, i = v; i >= 10; i /= 10, e++) ;
42
+ if (e > MAX_EXP) {
43
+ x.c = x.e = null;
44
+ } else {
45
+ x.e = e;
46
+ x.c = [v];
47
+ }
48
+ return;
49
+ }
50
+ str = String(v);
51
+ } else {
52
+ if (!isNumeric.test(str = String(v))) return parseNumeric(x, str, isNum);
53
+ x.s = str.charCodeAt(0) == 45 ? (str = str.slice(1), -1) : 1;
54
+ }
55
+ if ((e = str.indexOf(".")) > -1) str = str.replace(".", "");
56
+ if ((i = str.search(/e/i)) > 0) {
57
+ if (e < 0) e = i;
58
+ e += +str.slice(i + 1);
59
+ str = str.substring(0, i);
60
+ } else if (e < 0) {
61
+ e = str.length;
62
+ }
63
+ } else {
64
+ intCheck(b, 2, ALPHABET.length, "Base");
65
+ if (b == 10 && alphabetHasNormalDecimalDigits) {
66
+ x = new BigNumber2(v);
67
+ return round(x, DECIMAL_PLACES + x.e + 1, ROUNDING_MODE);
68
+ }
69
+ str = String(v);
70
+ if (isNum = typeof v == "number") {
71
+ if (v * 0 != 0) return parseNumeric(x, str, isNum, b);
72
+ x.s = 1 / v < 0 ? (str = str.slice(1), -1) : 1;
73
+ if (BigNumber2.DEBUG && str.replace(/^0\.0*|\./, "").length > 15) {
74
+ throw Error(tooManyDigits + v);
75
+ }
76
+ } else {
77
+ x.s = str.charCodeAt(0) === 45 ? (str = str.slice(1), -1) : 1;
78
+ }
79
+ alphabet = ALPHABET.slice(0, b);
80
+ e = i = 0;
81
+ for (len = str.length; i < len; i++) {
82
+ if (alphabet.indexOf(c = str.charAt(i)) < 0) {
83
+ if (c == ".") {
84
+ if (i > e) {
85
+ e = len;
86
+ continue;
87
+ }
88
+ } else if (!caseChanged) {
89
+ if (str == str.toUpperCase() && (str = str.toLowerCase()) || str == str.toLowerCase() && (str = str.toUpperCase())) {
90
+ caseChanged = true;
91
+ i = -1;
92
+ e = 0;
93
+ continue;
94
+ }
95
+ }
96
+ return parseNumeric(x, String(v), isNum, b);
97
+ }
98
+ }
99
+ isNum = false;
100
+ str = convertBase(str, b, 10, x.s);
101
+ if ((e = str.indexOf(".")) > -1) str = str.replace(".", "");
102
+ else e = str.length;
103
+ }
104
+ for (i = 0; str.charCodeAt(i) === 48; i++) ;
105
+ for (len = str.length; str.charCodeAt(--len) === 48; ) ;
106
+ if (str = str.slice(i, ++len)) {
107
+ len -= i;
108
+ if (isNum && BigNumber2.DEBUG && len > 15 && (v > MAX_SAFE_INTEGER || v !== mathfloor(v))) {
109
+ throw Error(tooManyDigits + x.s * v);
110
+ }
111
+ if ((e = e - i - 1) > MAX_EXP) {
112
+ x.c = x.e = null;
113
+ } else if (e < MIN_EXP) {
114
+ x.c = [x.e = 0];
115
+ } else {
116
+ x.e = e;
117
+ x.c = [];
118
+ i = (e + 1) % LOG_BASE;
119
+ if (e < 0) i += LOG_BASE;
120
+ if (i < len) {
121
+ if (i) x.c.push(+str.slice(0, i));
122
+ for (len -= LOG_BASE; i < len; ) {
123
+ x.c.push(+str.slice(i, i += LOG_BASE));
124
+ }
125
+ i = LOG_BASE - (str = str.slice(i)).length;
126
+ } else {
127
+ i -= len;
128
+ }
129
+ for (; i--; str += "0") ;
130
+ x.c.push(+str);
131
+ }
132
+ } else {
133
+ x.c = [x.e = 0];
134
+ }
135
+ }
136
+ BigNumber2.clone = clone;
137
+ BigNumber2.ROUND_UP = 0;
138
+ BigNumber2.ROUND_DOWN = 1;
139
+ BigNumber2.ROUND_CEIL = 2;
140
+ BigNumber2.ROUND_FLOOR = 3;
141
+ BigNumber2.ROUND_HALF_UP = 4;
142
+ BigNumber2.ROUND_HALF_DOWN = 5;
143
+ BigNumber2.ROUND_HALF_EVEN = 6;
144
+ BigNumber2.ROUND_HALF_CEIL = 7;
145
+ BigNumber2.ROUND_HALF_FLOOR = 8;
146
+ BigNumber2.EUCLID = 9;
147
+ BigNumber2.config = BigNumber2.set = function(obj) {
148
+ var p, v;
149
+ if (obj != null) {
150
+ if (typeof obj == "object") {
151
+ if (obj.hasOwnProperty(p = "DECIMAL_PLACES")) {
152
+ v = obj[p];
153
+ intCheck(v, 0, MAX, p);
154
+ DECIMAL_PLACES = v;
155
+ }
156
+ if (obj.hasOwnProperty(p = "ROUNDING_MODE")) {
157
+ v = obj[p];
158
+ intCheck(v, 0, 8, p);
159
+ ROUNDING_MODE = v;
160
+ }
161
+ if (obj.hasOwnProperty(p = "EXPONENTIAL_AT")) {
162
+ v = obj[p];
163
+ if (v && v.pop) {
164
+ intCheck(v[0], -MAX, 0, p);
165
+ intCheck(v[1], 0, MAX, p);
166
+ TO_EXP_NEG = v[0];
167
+ TO_EXP_POS = v[1];
168
+ } else {
169
+ intCheck(v, -MAX, MAX, p);
170
+ TO_EXP_NEG = -(TO_EXP_POS = v < 0 ? -v : v);
171
+ }
172
+ }
173
+ if (obj.hasOwnProperty(p = "RANGE")) {
174
+ v = obj[p];
175
+ if (v && v.pop) {
176
+ intCheck(v[0], -MAX, -1, p);
177
+ intCheck(v[1], 1, MAX, p);
178
+ MIN_EXP = v[0];
179
+ MAX_EXP = v[1];
180
+ } else {
181
+ intCheck(v, -MAX, MAX, p);
182
+ if (v) {
183
+ MIN_EXP = -(MAX_EXP = v < 0 ? -v : v);
184
+ } else {
185
+ throw Error(bignumberError + p + " cannot be zero: " + v);
186
+ }
187
+ }
188
+ }
189
+ if (obj.hasOwnProperty(p = "CRYPTO")) {
190
+ v = obj[p];
191
+ if (v === !!v) {
192
+ if (v) {
193
+ if (typeof crypto != "undefined" && crypto && (crypto.getRandomValues || crypto.randomBytes)) {
194
+ CRYPTO = v;
195
+ } else {
196
+ CRYPTO = !v;
197
+ throw Error(bignumberError + "crypto unavailable");
198
+ }
199
+ } else {
200
+ CRYPTO = v;
201
+ }
202
+ } else {
203
+ throw Error(bignumberError + p + " not true or false: " + v);
204
+ }
205
+ }
206
+ if (obj.hasOwnProperty(p = "MODULO_MODE")) {
207
+ v = obj[p];
208
+ intCheck(v, 0, 9, p);
209
+ MODULO_MODE = v;
210
+ }
211
+ if (obj.hasOwnProperty(p = "POW_PRECISION")) {
212
+ v = obj[p];
213
+ intCheck(v, 0, MAX, p);
214
+ POW_PRECISION = v;
215
+ }
216
+ if (obj.hasOwnProperty(p = "FORMAT")) {
217
+ v = obj[p];
218
+ if (typeof v == "object") FORMAT = v;
219
+ else throw Error(bignumberError + p + " not an object: " + v);
220
+ }
221
+ if (obj.hasOwnProperty(p = "ALPHABET")) {
222
+ v = obj[p];
223
+ if (typeof v == "string" && !/^.?$|[+\-.\s]|(.).*\1/.test(v)) {
224
+ alphabetHasNormalDecimalDigits = v.slice(0, 10) == "0123456789";
225
+ ALPHABET = v;
226
+ } else {
227
+ throw Error(bignumberError + p + " invalid: " + v);
228
+ }
229
+ }
230
+ } else {
231
+ throw Error(bignumberError + "Object expected: " + obj);
232
+ }
233
+ }
234
+ return {
235
+ DECIMAL_PLACES,
236
+ ROUNDING_MODE,
237
+ EXPONENTIAL_AT: [TO_EXP_NEG, TO_EXP_POS],
238
+ RANGE: [MIN_EXP, MAX_EXP],
239
+ CRYPTO,
240
+ MODULO_MODE,
241
+ POW_PRECISION,
242
+ FORMAT,
243
+ ALPHABET
244
+ };
245
+ };
246
+ BigNumber2.isBigNumber = function(v) {
247
+ if (!v || v._isBigNumber !== true) return false;
248
+ if (!BigNumber2.DEBUG) return true;
249
+ var i, n, c = v.c, e = v.e, s = v.s;
250
+ out: if ({}.toString.call(c) == "[object Array]") {
251
+ if ((s === 1 || s === -1) && e >= -MAX && e <= MAX && e === mathfloor(e)) {
252
+ if (c[0] === 0) {
253
+ if (e === 0 && c.length === 1) return true;
254
+ break out;
255
+ }
256
+ i = (e + 1) % LOG_BASE;
257
+ if (i < 1) i += LOG_BASE;
258
+ if (String(c[0]).length == i) {
259
+ for (i = 0; i < c.length; i++) {
260
+ n = c[i];
261
+ if (n < 0 || n >= BASE || n !== mathfloor(n)) break out;
262
+ }
263
+ if (n !== 0) return true;
264
+ }
265
+ }
266
+ } else if (c === null && e === null && (s === null || s === 1 || s === -1)) {
267
+ return true;
268
+ }
269
+ throw Error(bignumberError + "Invalid BigNumber: " + v);
270
+ };
271
+ BigNumber2.maximum = BigNumber2.max = function() {
272
+ return maxOrMin(arguments, -1);
273
+ };
274
+ BigNumber2.minimum = BigNumber2.min = function() {
275
+ return maxOrMin(arguments, 1);
276
+ };
277
+ BigNumber2.random = (function() {
278
+ var pow2_53 = 9007199254740992;
279
+ var random53bitInt = Math.random() * pow2_53 & 2097151 ? function() {
280
+ return mathfloor(Math.random() * pow2_53);
281
+ } : function() {
282
+ return (Math.random() * 1073741824 | 0) * 8388608 + (Math.random() * 8388608 | 0);
283
+ };
284
+ return function(dp) {
285
+ var a, b, e, k, v, i = 0, c = [], rand = new BigNumber2(ONE);
286
+ if (dp == null) dp = DECIMAL_PLACES;
287
+ else intCheck(dp, 0, MAX);
288
+ k = mathceil(dp / LOG_BASE);
289
+ if (CRYPTO) {
290
+ if (crypto.getRandomValues) {
291
+ a = crypto.getRandomValues(new Uint32Array(k *= 2));
292
+ for (; i < k; ) {
293
+ v = a[i] * 131072 + (a[i + 1] >>> 11);
294
+ if (v >= 9e15) {
295
+ b = crypto.getRandomValues(new Uint32Array(2));
296
+ a[i] = b[0];
297
+ a[i + 1] = b[1];
298
+ } else {
299
+ c.push(v % 1e14);
300
+ i += 2;
301
+ }
302
+ }
303
+ i = k / 2;
304
+ } else if (crypto.randomBytes) {
305
+ a = crypto.randomBytes(k *= 7);
306
+ for (; i < k; ) {
307
+ 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];
308
+ if (v >= 9e15) {
309
+ crypto.randomBytes(7).copy(a, i);
310
+ } else {
311
+ c.push(v % 1e14);
312
+ i += 7;
313
+ }
314
+ }
315
+ i = k / 7;
316
+ } else {
317
+ CRYPTO = false;
318
+ throw Error(bignumberError + "crypto unavailable");
319
+ }
320
+ }
321
+ if (!CRYPTO) {
322
+ for (; i < k; ) {
323
+ v = random53bitInt();
324
+ if (v < 9e15) c[i++] = v % 1e14;
325
+ }
326
+ }
327
+ k = c[--i];
328
+ dp %= LOG_BASE;
329
+ if (k && dp) {
330
+ v = POWS_TEN[LOG_BASE - dp];
331
+ c[i] = mathfloor(k / v) * v;
332
+ }
333
+ for (; c[i] === 0; c.pop(), i--) ;
334
+ if (i < 0) {
335
+ c = [e = 0];
336
+ } else {
337
+ for (e = -1; c[0] === 0; c.splice(0, 1), e -= LOG_BASE) ;
338
+ for (i = 1, v = c[0]; v >= 10; v /= 10, i++) ;
339
+ if (i < LOG_BASE) e -= LOG_BASE - i;
340
+ }
341
+ rand.e = e;
342
+ rand.c = c;
343
+ return rand;
344
+ };
345
+ })();
346
+ BigNumber2.sum = function() {
347
+ var i = 1, args = arguments, sum = new BigNumber2(args[0]);
348
+ for (; i < args.length; ) sum = sum.plus(args[i++]);
349
+ return sum;
350
+ };
351
+ convertBase = /* @__PURE__ */ (function() {
352
+ var decimal = "0123456789";
353
+ function toBaseOut(str, baseIn, baseOut, alphabet) {
354
+ var j, arr = [0], arrL, i = 0, len = str.length;
355
+ for (; i < len; ) {
356
+ for (arrL = arr.length; arrL--; arr[arrL] *= baseIn) ;
357
+ arr[0] += alphabet.indexOf(str.charAt(i++));
358
+ for (j = 0; j < arr.length; j++) {
359
+ if (arr[j] > baseOut - 1) {
360
+ if (arr[j + 1] == null) arr[j + 1] = 0;
361
+ arr[j + 1] += arr[j] / baseOut | 0;
362
+ arr[j] %= baseOut;
363
+ }
364
+ }
365
+ }
366
+ return arr.reverse();
367
+ }
368
+ return function(str, baseIn, baseOut, sign, callerIsToString) {
369
+ var alphabet, d, e, k, r, x, xc, y, i = str.indexOf("."), dp = DECIMAL_PLACES, rm = ROUNDING_MODE;
370
+ if (i >= 0) {
371
+ k = POW_PRECISION;
372
+ POW_PRECISION = 0;
373
+ str = str.replace(".", "");
374
+ y = new BigNumber2(baseIn);
375
+ x = y.pow(str.length - i);
376
+ POW_PRECISION = k;
377
+ y.c = toBaseOut(
378
+ toFixedPoint(coeffToString(x.c), x.e, "0"),
379
+ 10,
380
+ baseOut,
381
+ decimal
382
+ );
383
+ y.e = y.c.length;
384
+ }
385
+ xc = toBaseOut(str, baseIn, baseOut, callerIsToString ? (alphabet = ALPHABET, decimal) : (alphabet = decimal, ALPHABET));
386
+ e = k = xc.length;
387
+ for (; xc[--k] == 0; xc.pop()) ;
388
+ if (!xc[0]) return alphabet.charAt(0);
389
+ if (i < 0) {
390
+ --e;
391
+ } else {
392
+ x.c = xc;
393
+ x.e = e;
394
+ x.s = sign;
395
+ x = div(x, y, dp, rm, baseOut);
396
+ xc = x.c;
397
+ r = x.r;
398
+ e = x.e;
399
+ }
400
+ d = e + dp + 1;
401
+ i = xc[d];
402
+ k = baseOut / 2;
403
+ r = r || d < 0 || xc[d + 1] != null;
404
+ 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));
405
+ if (d < 1 || !xc[0]) {
406
+ str = r ? toFixedPoint(alphabet.charAt(1), -dp, alphabet.charAt(0)) : alphabet.charAt(0);
407
+ } else {
408
+ xc.length = d;
409
+ if (r) {
410
+ for (--baseOut; ++xc[--d] > baseOut; ) {
411
+ xc[d] = 0;
412
+ if (!d) {
413
+ ++e;
414
+ xc = [1].concat(xc);
415
+ }
416
+ }
417
+ }
418
+ for (k = xc.length; !xc[--k]; ) ;
419
+ for (i = 0, str = ""; i <= k; str += alphabet.charAt(xc[i++])) ;
420
+ str = toFixedPoint(str, e, alphabet.charAt(0));
421
+ }
422
+ return str;
423
+ };
424
+ })();
425
+ div = /* @__PURE__ */ (function() {
426
+ function multiply(x, k, base) {
427
+ var m, temp, xlo, xhi, carry = 0, i = x.length, klo = k % SQRT_BASE, khi = k / SQRT_BASE | 0;
428
+ for (x = x.slice(); i--; ) {
429
+ xlo = x[i] % SQRT_BASE;
430
+ xhi = x[i] / SQRT_BASE | 0;
431
+ m = khi * xlo + xhi * klo;
432
+ temp = klo * xlo + m % SQRT_BASE * SQRT_BASE + carry;
433
+ carry = (temp / base | 0) + (m / SQRT_BASE | 0) + khi * xhi;
434
+ x[i] = temp % base;
435
+ }
436
+ if (carry) x = [carry].concat(x);
437
+ return x;
438
+ }
439
+ function compare2(a, b, aL, bL) {
440
+ var i, cmp;
441
+ if (aL != bL) {
442
+ cmp = aL > bL ? 1 : -1;
443
+ } else {
444
+ for (i = cmp = 0; i < aL; i++) {
445
+ if (a[i] != b[i]) {
446
+ cmp = a[i] > b[i] ? 1 : -1;
447
+ break;
448
+ }
449
+ }
450
+ }
451
+ return cmp;
452
+ }
453
+ function subtract(a, b, aL, base) {
454
+ var i = 0;
455
+ for (; aL--; ) {
456
+ a[aL] -= i;
457
+ i = a[aL] < b[aL] ? 1 : 0;
458
+ a[aL] = i * base + a[aL] - b[aL];
459
+ }
460
+ for (; !a[0] && a.length > 1; a.splice(0, 1)) ;
461
+ }
462
+ return function(x, y, dp, rm, base) {
463
+ 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;
464
+ if (!xc || !xc[0] || !yc || !yc[0]) {
465
+ return new BigNumber2(
466
+ // Return NaN if either NaN, or both Infinity or 0.
467
+ !x.s || !y.s || (xc ? yc && xc[0] == yc[0] : !yc) ? NaN : (
468
+ // Return ±0 if x is ±0 or y is ±Infinity, or return ±Infinity as y is ±0.
469
+ xc && xc[0] == 0 || !yc ? s * 0 : s / 0
470
+ )
471
+ );
472
+ }
473
+ q = new BigNumber2(s);
474
+ qc = q.c = [];
475
+ e = x.e - y.e;
476
+ s = dp + e + 1;
477
+ if (!base) {
478
+ base = BASE;
479
+ e = bitFloor(x.e / LOG_BASE) - bitFloor(y.e / LOG_BASE);
480
+ s = s / LOG_BASE | 0;
481
+ }
482
+ for (i = 0; yc[i] == (xc[i] || 0); i++) ;
483
+ if (yc[i] > (xc[i] || 0)) e--;
484
+ if (s < 0) {
485
+ qc.push(1);
486
+ more = true;
487
+ } else {
488
+ xL = xc.length;
489
+ yL = yc.length;
490
+ i = 0;
491
+ s += 2;
492
+ n = mathfloor(base / (yc[0] + 1));
493
+ if (n > 1) {
494
+ yc = multiply(yc, n, base);
495
+ xc = multiply(xc, n, base);
496
+ yL = yc.length;
497
+ xL = xc.length;
498
+ }
499
+ xi = yL;
500
+ rem = xc.slice(0, yL);
501
+ remL = rem.length;
502
+ for (; remL < yL; rem[remL++] = 0) ;
503
+ yz = yc.slice();
504
+ yz = [0].concat(yz);
505
+ yc0 = yc[0];
506
+ if (yc[1] >= base / 2) yc0++;
507
+ do {
508
+ n = 0;
509
+ cmp = compare2(yc, rem, yL, remL);
510
+ if (cmp < 0) {
511
+ rem0 = rem[0];
512
+ if (yL != remL) rem0 = rem0 * base + (rem[1] || 0);
513
+ n = mathfloor(rem0 / yc0);
514
+ if (n > 1) {
515
+ if (n >= base) n = base - 1;
516
+ prod = multiply(yc, n, base);
517
+ prodL = prod.length;
518
+ remL = rem.length;
519
+ while (compare2(prod, rem, prodL, remL) == 1) {
520
+ n--;
521
+ subtract(prod, yL < prodL ? yz : yc, prodL, base);
522
+ prodL = prod.length;
523
+ cmp = 1;
524
+ }
525
+ } else {
526
+ if (n == 0) {
527
+ cmp = n = 1;
528
+ }
529
+ prod = yc.slice();
530
+ prodL = prod.length;
531
+ }
532
+ if (prodL < remL) prod = [0].concat(prod);
533
+ subtract(rem, prod, remL, base);
534
+ remL = rem.length;
535
+ if (cmp == -1) {
536
+ while (compare2(yc, rem, yL, remL) < 1) {
537
+ n++;
538
+ subtract(rem, yL < remL ? yz : yc, remL, base);
539
+ remL = rem.length;
540
+ }
541
+ }
542
+ } else if (cmp === 0) {
543
+ n++;
544
+ rem = [0];
545
+ }
546
+ qc[i++] = n;
547
+ if (rem[0]) {
548
+ rem[remL++] = xc[xi] || 0;
549
+ } else {
550
+ rem = [xc[xi]];
551
+ remL = 1;
552
+ }
553
+ } while ((xi++ < xL || rem[0] != null) && s--);
554
+ more = rem[0] != null;
555
+ if (!qc[0]) qc.splice(0, 1);
556
+ }
557
+ if (base == BASE) {
558
+ for (i = 1, s = qc[0]; s >= 10; s /= 10, i++) ;
559
+ round(q, dp + (q.e = i + e * LOG_BASE - 1) + 1, rm, more);
560
+ } else {
561
+ q.e = e;
562
+ q.r = +more;
563
+ }
564
+ return q;
565
+ };
566
+ })();
567
+ function format(n, i, rm, id) {
568
+ var c0, e, ne, len, str;
569
+ if (rm == null) rm = ROUNDING_MODE;
570
+ else intCheck(rm, 0, 8);
571
+ if (!n.c) return n.toString();
572
+ c0 = n.c[0];
573
+ ne = n.e;
574
+ if (i == null) {
575
+ str = coeffToString(n.c);
576
+ str = id == 1 || id == 2 && (ne <= TO_EXP_NEG || ne >= TO_EXP_POS) ? toExponential(str, ne) : toFixedPoint(str, ne, "0");
577
+ } else {
578
+ n = round(new BigNumber2(n), i, rm);
579
+ e = n.e;
580
+ str = coeffToString(n.c);
581
+ len = str.length;
582
+ if (id == 1 || id == 2 && (i <= e || e <= TO_EXP_NEG)) {
583
+ for (; len < i; str += "0", len++) ;
584
+ str = toExponential(str, e);
585
+ } else {
586
+ i -= ne + (id === 2 && e > ne);
587
+ str = toFixedPoint(str, e, "0");
588
+ if (e + 1 > len) {
589
+ if (--i > 0) for (str += "."; i--; str += "0") ;
590
+ } else {
591
+ i += e - len;
592
+ if (i > 0) {
593
+ if (e + 1 == len) str += ".";
594
+ for (; i--; str += "0") ;
595
+ }
596
+ }
597
+ }
598
+ }
599
+ return n.s < 0 && c0 ? "-" + str : str;
600
+ }
601
+ function maxOrMin(args, n) {
602
+ var k, y, i = 1, x = new BigNumber2(args[0]);
603
+ for (; i < args.length; i++) {
604
+ y = new BigNumber2(args[i]);
605
+ if (!y.s || (k = compare(x, y)) === n || k === 0 && x.s === n) {
606
+ x = y;
607
+ }
608
+ }
609
+ return x;
610
+ }
611
+ function normalise(n, c, e) {
612
+ var i = 1, j = c.length;
613
+ for (; !c[--j]; c.pop()) ;
614
+ for (j = c[0]; j >= 10; j /= 10, i++) ;
615
+ if ((e = i + e * LOG_BASE - 1) > MAX_EXP) {
616
+ n.c = n.e = null;
617
+ } else if (e < MIN_EXP) {
618
+ n.c = [n.e = 0];
619
+ } else {
620
+ n.e = e;
621
+ n.c = c;
622
+ }
623
+ return n;
624
+ }
625
+ parseNumeric = /* @__PURE__ */ (function() {
626
+ var basePrefix = /^(-?)0([xbo])(?=\w[\w.]*$)/i, dotAfter = /^([^.]+)\.$/, dotBefore = /^\.([^.]+)$/, isInfinityOrNaN = /^-?(Infinity|NaN)$/, whitespaceOrPlus = /^\s*\+(?=[\w.])|^\s+|\s+$/g;
627
+ return function(x, str, isNum, b) {
628
+ var base, s = isNum ? str : str.replace(whitespaceOrPlus, "");
629
+ if (isInfinityOrNaN.test(s)) {
630
+ x.s = isNaN(s) ? null : s < 0 ? -1 : 1;
631
+ } else {
632
+ if (!isNum) {
633
+ s = s.replace(basePrefix, function(m, p1, p2) {
634
+ base = (p2 = p2.toLowerCase()) == "x" ? 16 : p2 == "b" ? 2 : 8;
635
+ return !b || b == base ? p1 : m;
636
+ });
637
+ if (b) {
638
+ base = b;
639
+ s = s.replace(dotAfter, "$1").replace(dotBefore, "0.$1");
640
+ }
641
+ if (str != s) return new BigNumber2(s, base);
642
+ }
643
+ if (BigNumber2.DEBUG) {
644
+ throw Error(bignumberError + "Not a" + (b ? " base " + b : "") + " number: " + str);
645
+ }
646
+ x.s = null;
647
+ }
648
+ x.c = x.e = null;
649
+ };
650
+ })();
651
+ function round(x, sd, rm, r) {
652
+ var d, i, j, k, n, ni, rd, xc = x.c, pows10 = POWS_TEN;
653
+ if (xc) {
654
+ out: {
655
+ for (d = 1, k = xc[0]; k >= 10; k /= 10, d++) ;
656
+ i = sd - d;
657
+ if (i < 0) {
658
+ i += LOG_BASE;
659
+ j = sd;
660
+ n = xc[ni = 0];
661
+ rd = mathfloor(n / pows10[d - j - 1] % 10);
662
+ } else {
663
+ ni = mathceil((i + 1) / LOG_BASE);
664
+ if (ni >= xc.length) {
665
+ if (r) {
666
+ for (; xc.length <= ni; xc.push(0)) ;
667
+ n = rd = 0;
668
+ d = 1;
669
+ i %= LOG_BASE;
670
+ j = i - LOG_BASE + 1;
671
+ } else {
672
+ break out;
673
+ }
674
+ } else {
675
+ n = k = xc[ni];
676
+ for (d = 1; k >= 10; k /= 10, d++) ;
677
+ i %= LOG_BASE;
678
+ j = i - LOG_BASE + d;
679
+ rd = j < 0 ? 0 : mathfloor(n / pows10[d - j - 1] % 10);
680
+ }
681
+ }
682
+ r = r || sd < 0 || // Are there any non-zero digits after the rounding digit?
683
+ // The expression n % pows10[d - j - 1] returns all digits of n to the right
684
+ // of the digit at j, e.g. if n is 908714 and j is 2, the expression gives 714.
685
+ xc[ni + 1] != null || (j < 0 ? n : n % pows10[d - j - 1]);
686
+ 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.
687
+ (i > 0 ? j > 0 ? n / pows10[d - j] : 0 : xc[ni - 1]) % 10 & 1 || rm == (x.s < 0 ? 8 : 7));
688
+ if (sd < 1 || !xc[0]) {
689
+ xc.length = 0;
690
+ if (r) {
691
+ sd -= x.e + 1;
692
+ xc[0] = pows10[(LOG_BASE - sd % LOG_BASE) % LOG_BASE];
693
+ x.e = -sd || 0;
694
+ } else {
695
+ xc[0] = x.e = 0;
696
+ }
697
+ return x;
698
+ }
699
+ if (i == 0) {
700
+ xc.length = ni;
701
+ k = 1;
702
+ ni--;
703
+ } else {
704
+ xc.length = ni + 1;
705
+ k = pows10[LOG_BASE - i];
706
+ xc[ni] = j > 0 ? mathfloor(n / pows10[d - j] % pows10[j]) * k : 0;
707
+ }
708
+ if (r) {
709
+ for (; ; ) {
710
+ if (ni == 0) {
711
+ for (i = 1, j = xc[0]; j >= 10; j /= 10, i++) ;
712
+ j = xc[0] += k;
713
+ for (k = 1; j >= 10; j /= 10, k++) ;
714
+ if (i != k) {
715
+ x.e++;
716
+ if (xc[0] == BASE) xc[0] = 1;
717
+ }
718
+ break;
719
+ } else {
720
+ xc[ni] += k;
721
+ if (xc[ni] != BASE) break;
722
+ xc[ni--] = 0;
723
+ k = 1;
724
+ }
725
+ }
726
+ }
727
+ for (i = xc.length; xc[--i] === 0; xc.pop()) ;
728
+ }
729
+ if (x.e > MAX_EXP) {
730
+ x.c = x.e = null;
731
+ } else if (x.e < MIN_EXP) {
732
+ x.c = [x.e = 0];
733
+ }
734
+ }
735
+ return x;
736
+ }
737
+ function valueOf(n) {
738
+ var str, e = n.e;
739
+ if (e === null) return n.toString();
740
+ str = coeffToString(n.c);
741
+ str = e <= TO_EXP_NEG || e >= TO_EXP_POS ? toExponential(str, e) : toFixedPoint(str, e, "0");
742
+ return n.s < 0 ? "-" + str : str;
743
+ }
744
+ P.absoluteValue = P.abs = function() {
745
+ var x = new BigNumber2(this);
746
+ if (x.s < 0) x.s = 1;
747
+ return x;
748
+ };
749
+ P.comparedTo = function(y, b) {
750
+ return compare(this, new BigNumber2(y, b));
751
+ };
752
+ P.decimalPlaces = P.dp = function(dp, rm) {
753
+ var c, n, v, x = this;
754
+ if (dp != null) {
755
+ intCheck(dp, 0, MAX);
756
+ if (rm == null) rm = ROUNDING_MODE;
757
+ else intCheck(rm, 0, 8);
758
+ return round(new BigNumber2(x), dp + x.e + 1, rm);
759
+ }
760
+ if (!(c = x.c)) return null;
761
+ n = ((v = c.length - 1) - bitFloor(this.e / LOG_BASE)) * LOG_BASE;
762
+ if (v = c[v]) for (; v % 10 == 0; v /= 10, n--) ;
763
+ if (n < 0) n = 0;
764
+ return n;
765
+ };
766
+ P.dividedBy = P.div = function(y, b) {
767
+ return div(this, new BigNumber2(y, b), DECIMAL_PLACES, ROUNDING_MODE);
768
+ };
769
+ P.dividedToIntegerBy = P.idiv = function(y, b) {
770
+ return div(this, new BigNumber2(y, b), 0, 1);
771
+ };
772
+ P.exponentiatedBy = P.pow = function(n, m) {
773
+ var half, isModExp, i, k, more, nIsBig, nIsNeg, nIsOdd, y, x = this;
774
+ n = new BigNumber2(n);
775
+ if (n.c && !n.isInteger()) {
776
+ throw Error(bignumberError + "Exponent not an integer: " + valueOf(n));
777
+ }
778
+ if (m != null) m = new BigNumber2(m);
779
+ nIsBig = n.e > 14;
780
+ if (!x.c || !x.c[0] || x.c[0] == 1 && !x.e && x.c.length == 1 || !n.c || !n.c[0]) {
781
+ y = new BigNumber2(Math.pow(+valueOf(x), nIsBig ? n.s * (2 - isOdd(n)) : +valueOf(n)));
782
+ return m ? y.mod(m) : y;
783
+ }
784
+ nIsNeg = n.s < 0;
785
+ if (m) {
786
+ if (m.c ? !m.c[0] : !m.s) return new BigNumber2(NaN);
787
+ isModExp = !nIsNeg && x.isInteger() && m.isInteger();
788
+ if (isModExp) x = x.mod(m);
789
+ } 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))) {
790
+ k = x.s < 0 && isOdd(n) ? -0 : 0;
791
+ if (x.e > -1) k = 1 / k;
792
+ return new BigNumber2(nIsNeg ? 1 / k : k);
793
+ } else if (POW_PRECISION) {
794
+ k = mathceil(POW_PRECISION / LOG_BASE + 2);
795
+ }
796
+ if (nIsBig) {
797
+ half = new BigNumber2(0.5);
798
+ if (nIsNeg) n.s = 1;
799
+ nIsOdd = isOdd(n);
800
+ } else {
801
+ i = Math.abs(+valueOf(n));
802
+ nIsOdd = i % 2;
803
+ }
804
+ y = new BigNumber2(ONE);
805
+ for (; ; ) {
806
+ if (nIsOdd) {
807
+ y = y.times(x);
808
+ if (!y.c) break;
809
+ if (k) {
810
+ if (y.c.length > k) y.c.length = k;
811
+ } else if (isModExp) {
812
+ y = y.mod(m);
813
+ }
814
+ }
815
+ if (i) {
816
+ i = mathfloor(i / 2);
817
+ if (i === 0) break;
818
+ nIsOdd = i % 2;
819
+ } else {
820
+ n = n.times(half);
821
+ round(n, n.e + 1, 1);
822
+ if (n.e > 14) {
823
+ nIsOdd = isOdd(n);
824
+ } else {
825
+ i = +valueOf(n);
826
+ if (i === 0) break;
827
+ nIsOdd = i % 2;
828
+ }
829
+ }
830
+ x = x.times(x);
831
+ if (k) {
832
+ if (x.c && x.c.length > k) x.c.length = k;
833
+ } else if (isModExp) {
834
+ x = x.mod(m);
835
+ }
836
+ }
837
+ if (isModExp) return y;
838
+ if (nIsNeg) y = ONE.div(y);
839
+ return m ? y.mod(m) : k ? round(y, POW_PRECISION, ROUNDING_MODE, more) : y;
840
+ };
841
+ P.integerValue = function(rm) {
842
+ var n = new BigNumber2(this);
843
+ if (rm == null) rm = ROUNDING_MODE;
844
+ else intCheck(rm, 0, 8);
845
+ return round(n, n.e + 1, rm);
846
+ };
847
+ P.isEqualTo = P.eq = function(y, b) {
848
+ return compare(this, new BigNumber2(y, b)) === 0;
849
+ };
850
+ P.isFinite = function() {
851
+ return !!this.c;
852
+ };
853
+ P.isGreaterThan = P.gt = function(y, b) {
854
+ return compare(this, new BigNumber2(y, b)) > 0;
855
+ };
856
+ P.isGreaterThanOrEqualTo = P.gte = function(y, b) {
857
+ return (b = compare(this, new BigNumber2(y, b))) === 1 || b === 0;
858
+ };
859
+ P.isInteger = function() {
860
+ return !!this.c && bitFloor(this.e / LOG_BASE) > this.c.length - 2;
861
+ };
862
+ P.isLessThan = P.lt = function(y, b) {
863
+ return compare(this, new BigNumber2(y, b)) < 0;
864
+ };
865
+ P.isLessThanOrEqualTo = P.lte = function(y, b) {
866
+ return (b = compare(this, new BigNumber2(y, b))) === -1 || b === 0;
867
+ };
868
+ P.isNaN = function() {
869
+ return !this.s;
870
+ };
871
+ P.isNegative = function() {
872
+ return this.s < 0;
873
+ };
874
+ P.isPositive = function() {
875
+ return this.s > 0;
876
+ };
877
+ P.isZero = function() {
878
+ return !!this.c && this.c[0] == 0;
879
+ };
880
+ P.minus = function(y, b) {
881
+ var i, j, t, xLTy, x = this, a = x.s;
882
+ y = new BigNumber2(y, b);
883
+ b = y.s;
884
+ if (!a || !b) return new BigNumber2(NaN);
885
+ if (a != b) {
886
+ y.s = -b;
887
+ return x.plus(y);
888
+ }
889
+ var xe = x.e / LOG_BASE, ye = y.e / LOG_BASE, xc = x.c, yc = y.c;
890
+ if (!xe || !ye) {
891
+ if (!xc || !yc) return xc ? (y.s = -b, y) : new BigNumber2(yc ? x : NaN);
892
+ if (!xc[0] || !yc[0]) {
893
+ return yc[0] ? (y.s = -b, y) : new BigNumber2(xc[0] ? x : (
894
+ // IEEE 754 (2008) 6.3: n - n = -0 when rounding to -Infinity
895
+ ROUNDING_MODE == 3 ? -0 : 0
896
+ ));
897
+ }
898
+ }
899
+ xe = bitFloor(xe);
900
+ ye = bitFloor(ye);
901
+ xc = xc.slice();
902
+ if (a = xe - ye) {
903
+ if (xLTy = a < 0) {
904
+ a = -a;
905
+ t = xc;
906
+ } else {
907
+ ye = xe;
908
+ t = yc;
909
+ }
910
+ t.reverse();
911
+ for (b = a; b--; t.push(0)) ;
912
+ t.reverse();
913
+ } else {
914
+ j = (xLTy = (a = xc.length) < (b = yc.length)) ? a : b;
915
+ for (a = b = 0; b < j; b++) {
916
+ if (xc[b] != yc[b]) {
917
+ xLTy = xc[b] < yc[b];
918
+ break;
919
+ }
920
+ }
921
+ }
922
+ if (xLTy) {
923
+ t = xc;
924
+ xc = yc;
925
+ yc = t;
926
+ y.s = -y.s;
927
+ }
928
+ b = (j = yc.length) - (i = xc.length);
929
+ if (b > 0) for (; b--; xc[i++] = 0) ;
930
+ b = BASE - 1;
931
+ for (; j > a; ) {
932
+ if (xc[--j] < yc[j]) {
933
+ for (i = j; i && !xc[--i]; xc[i] = b) ;
934
+ --xc[i];
935
+ xc[j] += BASE;
936
+ }
937
+ xc[j] -= yc[j];
938
+ }
939
+ for (; xc[0] == 0; xc.splice(0, 1), --ye) ;
940
+ if (!xc[0]) {
941
+ y.s = ROUNDING_MODE == 3 ? -1 : 1;
942
+ y.c = [y.e = 0];
943
+ return y;
944
+ }
945
+ return normalise(y, xc, ye);
946
+ };
947
+ P.modulo = P.mod = function(y, b) {
948
+ var q, s, x = this;
949
+ y = new BigNumber2(y, b);
950
+ if (!x.c || !y.s || y.c && !y.c[0]) {
951
+ return new BigNumber2(NaN);
952
+ } else if (!y.c || x.c && !x.c[0]) {
953
+ return new BigNumber2(x);
954
+ }
955
+ if (MODULO_MODE == 9) {
956
+ s = y.s;
957
+ y.s = 1;
958
+ q = div(x, y, 0, 3);
959
+ y.s = s;
960
+ q.s *= s;
961
+ } else {
962
+ q = div(x, y, 0, MODULO_MODE);
963
+ }
964
+ y = x.minus(q.times(y));
965
+ if (!y.c[0] && MODULO_MODE == 1) y.s = x.s;
966
+ return y;
967
+ };
968
+ P.multipliedBy = P.times = function(y, b) {
969
+ 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;
970
+ if (!xc || !yc || !xc[0] || !yc[0]) {
971
+ if (!x.s || !y.s || xc && !xc[0] && !yc || yc && !yc[0] && !xc) {
972
+ y.c = y.e = y.s = null;
973
+ } else {
974
+ y.s *= x.s;
975
+ if (!xc || !yc) {
976
+ y.c = y.e = null;
977
+ } else {
978
+ y.c = [0];
979
+ y.e = 0;
980
+ }
981
+ }
982
+ return y;
983
+ }
984
+ e = bitFloor(x.e / LOG_BASE) + bitFloor(y.e / LOG_BASE);
985
+ y.s *= x.s;
986
+ xcL = xc.length;
987
+ ycL = yc.length;
988
+ if (xcL < ycL) {
989
+ zc = xc;
990
+ xc = yc;
991
+ yc = zc;
992
+ i = xcL;
993
+ xcL = ycL;
994
+ ycL = i;
995
+ }
996
+ for (i = xcL + ycL, zc = []; i--; zc.push(0)) ;
997
+ base = BASE;
998
+ sqrtBase = SQRT_BASE;
999
+ for (i = ycL; --i >= 0; ) {
1000
+ c = 0;
1001
+ ylo = yc[i] % sqrtBase;
1002
+ yhi = yc[i] / sqrtBase | 0;
1003
+ for (k = xcL, j = i + k; j > i; ) {
1004
+ xlo = xc[--k] % sqrtBase;
1005
+ xhi = xc[k] / sqrtBase | 0;
1006
+ m = yhi * xlo + xhi * ylo;
1007
+ xlo = ylo * xlo + m % sqrtBase * sqrtBase + zc[j] + c;
1008
+ c = (xlo / base | 0) + (m / sqrtBase | 0) + yhi * xhi;
1009
+ zc[j--] = xlo % base;
1010
+ }
1011
+ zc[j] = c;
1012
+ }
1013
+ if (c) {
1014
+ ++e;
1015
+ } else {
1016
+ zc.splice(0, 1);
1017
+ }
1018
+ return normalise(y, zc, e);
1019
+ };
1020
+ P.negated = function() {
1021
+ var x = new BigNumber2(this);
1022
+ x.s = -x.s || null;
1023
+ return x;
1024
+ };
1025
+ P.plus = function(y, b) {
1026
+ var t, x = this, a = x.s;
1027
+ y = new BigNumber2(y, b);
1028
+ b = y.s;
1029
+ if (!a || !b) return new BigNumber2(NaN);
1030
+ if (a != b) {
1031
+ y.s = -b;
1032
+ return x.minus(y);
1033
+ }
1034
+ var xe = x.e / LOG_BASE, ye = y.e / LOG_BASE, xc = x.c, yc = y.c;
1035
+ if (!xe || !ye) {
1036
+ if (!xc || !yc) return new BigNumber2(a / 0);
1037
+ if (!xc[0] || !yc[0]) return yc[0] ? y : new BigNumber2(xc[0] ? x : a * 0);
1038
+ }
1039
+ xe = bitFloor(xe);
1040
+ ye = bitFloor(ye);
1041
+ xc = xc.slice();
1042
+ if (a = xe - ye) {
1043
+ if (a > 0) {
1044
+ ye = xe;
1045
+ t = yc;
1046
+ } else {
1047
+ a = -a;
1048
+ t = xc;
1049
+ }
1050
+ t.reverse();
1051
+ for (; a--; t.push(0)) ;
1052
+ t.reverse();
1053
+ }
1054
+ a = xc.length;
1055
+ b = yc.length;
1056
+ if (a - b < 0) {
1057
+ t = yc;
1058
+ yc = xc;
1059
+ xc = t;
1060
+ b = a;
1061
+ }
1062
+ for (a = 0; b; ) {
1063
+ a = (xc[--b] = xc[b] + yc[b] + a) / BASE | 0;
1064
+ xc[b] = BASE === xc[b] ? 0 : xc[b] % BASE;
1065
+ }
1066
+ if (a) {
1067
+ xc = [a].concat(xc);
1068
+ ++ye;
1069
+ }
1070
+ return normalise(y, xc, ye);
1071
+ };
1072
+ P.precision = P.sd = function(sd, rm) {
1073
+ var c, n, v, x = this;
1074
+ if (sd != null && sd !== !!sd) {
1075
+ intCheck(sd, 1, MAX);
1076
+ if (rm == null) rm = ROUNDING_MODE;
1077
+ else intCheck(rm, 0, 8);
1078
+ return round(new BigNumber2(x), sd, rm);
1079
+ }
1080
+ if (!(c = x.c)) return null;
1081
+ v = c.length - 1;
1082
+ n = v * LOG_BASE + 1;
1083
+ if (v = c[v]) {
1084
+ for (; v % 10 == 0; v /= 10, n--) ;
1085
+ for (v = c[0]; v >= 10; v /= 10, n++) ;
1086
+ }
1087
+ if (sd && x.e + 1 > n) n = x.e + 1;
1088
+ return n;
1089
+ };
1090
+ P.shiftedBy = function(k) {
1091
+ intCheck(k, -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER);
1092
+ return this.times("1e" + k);
1093
+ };
1094
+ P.squareRoot = P.sqrt = function() {
1095
+ 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");
1096
+ if (s !== 1 || !c || !c[0]) {
1097
+ return new BigNumber2(!s || s < 0 && (!c || c[0]) ? NaN : c ? x : 1 / 0);
1098
+ }
1099
+ s = Math.sqrt(+valueOf(x));
1100
+ if (s == 0 || s == 1 / 0) {
1101
+ n = coeffToString(c);
1102
+ if ((n.length + e) % 2 == 0) n += "0";
1103
+ s = Math.sqrt(+n);
1104
+ e = bitFloor((e + 1) / 2) - (e < 0 || e % 2);
1105
+ if (s == 1 / 0) {
1106
+ n = "5e" + e;
1107
+ } else {
1108
+ n = s.toExponential();
1109
+ n = n.slice(0, n.indexOf("e") + 1) + e;
1110
+ }
1111
+ r = new BigNumber2(n);
1112
+ } else {
1113
+ r = new BigNumber2(s + "");
1114
+ }
1115
+ if (r.c[0]) {
1116
+ e = r.e;
1117
+ s = e + dp;
1118
+ if (s < 3) s = 0;
1119
+ for (; ; ) {
1120
+ t = r;
1121
+ r = half.times(t.plus(div(x, t, dp, 1)));
1122
+ if (coeffToString(t.c).slice(0, s) === (n = coeffToString(r.c)).slice(0, s)) {
1123
+ if (r.e < e) --s;
1124
+ n = n.slice(s - 3, s + 1);
1125
+ if (n == "9999" || !rep && n == "4999") {
1126
+ if (!rep) {
1127
+ round(t, t.e + DECIMAL_PLACES + 2, 0);
1128
+ if (t.times(t).eq(x)) {
1129
+ r = t;
1130
+ break;
1131
+ }
1132
+ }
1133
+ dp += 4;
1134
+ s += 4;
1135
+ rep = 1;
1136
+ } else {
1137
+ if (!+n || !+n.slice(1) && n.charAt(0) == "5") {
1138
+ round(r, r.e + DECIMAL_PLACES + 2, 1);
1139
+ m = !r.times(r).eq(x);
1140
+ }
1141
+ break;
1142
+ }
1143
+ }
1144
+ }
1145
+ }
1146
+ return round(r, r.e + DECIMAL_PLACES + 1, ROUNDING_MODE, m);
1147
+ };
1148
+ P.toExponential = function(dp, rm) {
1149
+ if (dp != null) {
1150
+ intCheck(dp, 0, MAX);
1151
+ dp++;
1152
+ }
1153
+ return format(this, dp, rm, 1);
1154
+ };
1155
+ P.toFixed = function(dp, rm) {
1156
+ if (dp != null) {
1157
+ intCheck(dp, 0, MAX);
1158
+ dp = dp + this.e + 1;
1159
+ }
1160
+ return format(this, dp, rm);
1161
+ };
1162
+ P.toFormat = function(dp, rm, format2) {
1163
+ var str, x = this;
1164
+ if (format2 == null) {
1165
+ if (dp != null && rm && typeof rm == "object") {
1166
+ format2 = rm;
1167
+ rm = null;
1168
+ } else if (dp && typeof dp == "object") {
1169
+ format2 = dp;
1170
+ dp = rm = null;
1171
+ } else {
1172
+ format2 = FORMAT;
1173
+ }
1174
+ } else if (typeof format2 != "object") {
1175
+ throw Error(bignumberError + "Argument not an object: " + format2);
1176
+ }
1177
+ str = x.toFixed(dp, rm);
1178
+ if (x.c) {
1179
+ 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;
1180
+ if (g2) {
1181
+ i = g1;
1182
+ g1 = g2;
1183
+ g2 = i;
1184
+ len -= i;
1185
+ }
1186
+ if (g1 > 0 && len > 0) {
1187
+ i = len % g1 || g1;
1188
+ intPart = intDigits.substr(0, i);
1189
+ for (; i < len; i += g1) intPart += groupSeparator + intDigits.substr(i, g1);
1190
+ if (g2 > 0) intPart += groupSeparator + intDigits.slice(i);
1191
+ if (isNeg) intPart = "-" + intPart;
1192
+ }
1193
+ str = fractionPart ? intPart + (format2.decimalSeparator || "") + ((g2 = +format2.fractionGroupSize) ? fractionPart.replace(
1194
+ new RegExp("\\d{" + g2 + "}\\B", "g"),
1195
+ "$&" + (format2.fractionGroupSeparator || "")
1196
+ ) : fractionPart) : intPart;
1197
+ }
1198
+ return (format2.prefix || "") + str + (format2.suffix || "");
1199
+ };
1200
+ P.toFraction = function(md) {
1201
+ var d, d0, d1, d2, e, exp, n, n0, n1, q, r, s, x = this, xc = x.c;
1202
+ if (md != null) {
1203
+ n = new BigNumber2(md);
1204
+ if (!n.isInteger() && (n.c || n.s !== 1) || n.lt(ONE)) {
1205
+ throw Error(bignumberError + "Argument " + (n.isInteger() ? "out of range: " : "not an integer: ") + valueOf(n));
1206
+ }
1207
+ }
1208
+ if (!xc) return new BigNumber2(x);
1209
+ d = new BigNumber2(ONE);
1210
+ n1 = d0 = new BigNumber2(ONE);
1211
+ d1 = n0 = new BigNumber2(ONE);
1212
+ s = coeffToString(xc);
1213
+ e = d.e = s.length - x.e - 1;
1214
+ d.c[0] = POWS_TEN[(exp = e % LOG_BASE) < 0 ? LOG_BASE + exp : exp];
1215
+ md = !md || n.comparedTo(d) > 0 ? e > 0 ? d : n1 : n;
1216
+ exp = MAX_EXP;
1217
+ MAX_EXP = 1 / 0;
1218
+ n = new BigNumber2(s);
1219
+ n0.c[0] = 0;
1220
+ for (; ; ) {
1221
+ q = div(n, d, 0, 1);
1222
+ d2 = d0.plus(q.times(d1));
1223
+ if (d2.comparedTo(md) == 1) break;
1224
+ d0 = d1;
1225
+ d1 = d2;
1226
+ n1 = n0.plus(q.times(d2 = n1));
1227
+ n0 = d2;
1228
+ d = n.minus(q.times(d2 = d));
1229
+ n = d2;
1230
+ }
1231
+ d2 = div(md.minus(d0), d1, 0, 1);
1232
+ n0 = n0.plus(d2.times(n1));
1233
+ d0 = d0.plus(d2.times(d1));
1234
+ n0.s = n1.s = x.s;
1235
+ e = e * 2;
1236
+ r = div(n1, d1, e, ROUNDING_MODE).minus(x).abs().comparedTo(
1237
+ div(n0, d0, e, ROUNDING_MODE).minus(x).abs()
1238
+ ) < 1 ? [n1, d1] : [n0, d0];
1239
+ MAX_EXP = exp;
1240
+ return r;
1241
+ };
1242
+ P.toNumber = function() {
1243
+ return +valueOf(this);
1244
+ };
1245
+ P.toPrecision = function(sd, rm) {
1246
+ if (sd != null) intCheck(sd, 1, MAX);
1247
+ return format(this, sd, rm, 2);
1248
+ };
1249
+ P.toString = function(b) {
1250
+ var str, n = this, s = n.s, e = n.e;
1251
+ if (e === null) {
1252
+ if (s) {
1253
+ str = "Infinity";
1254
+ if (s < 0) str = "-" + str;
1255
+ } else {
1256
+ str = "NaN";
1257
+ }
1258
+ } else {
1259
+ if (b == null) {
1260
+ str = e <= TO_EXP_NEG || e >= TO_EXP_POS ? toExponential(coeffToString(n.c), e) : toFixedPoint(coeffToString(n.c), e, "0");
1261
+ } else if (b === 10 && alphabetHasNormalDecimalDigits) {
1262
+ n = round(new BigNumber2(n), DECIMAL_PLACES + e + 1, ROUNDING_MODE);
1263
+ str = toFixedPoint(coeffToString(n.c), n.e, "0");
1264
+ } else {
1265
+ intCheck(b, 2, ALPHABET.length, "Base");
1266
+ str = convertBase(toFixedPoint(coeffToString(n.c), e, "0"), 10, b, s, true);
1267
+ }
1268
+ if (s < 0 && n.c[0]) str = "-" + str;
1269
+ }
1270
+ return str;
1271
+ };
1272
+ P.valueOf = P.toJSON = function() {
1273
+ return valueOf(this);
1274
+ };
1275
+ P._isBigNumber = true;
1276
+ if (configObject != null) BigNumber2.set(configObject);
1277
+ return BigNumber2;
1278
+ }
1279
+ function bitFloor(n) {
1280
+ var i = n | 0;
1281
+ return n > 0 || n === i ? i : i - 1;
1282
+ }
1283
+ function coeffToString(a) {
1284
+ var s, z, i = 1, j = a.length, r = a[0] + "";
1285
+ for (; i < j; ) {
1286
+ s = a[i++] + "";
1287
+ z = LOG_BASE - s.length;
1288
+ for (; z--; s = "0" + s) ;
1289
+ r += s;
1290
+ }
1291
+ for (j = r.length; r.charCodeAt(--j) === 48; ) ;
1292
+ return r.slice(0, j + 1 || 1);
1293
+ }
1294
+ function compare(x, y) {
1295
+ var a, b, xc = x.c, yc = y.c, i = x.s, j = y.s, k = x.e, l = y.e;
1296
+ if (!i || !j) return null;
1297
+ a = xc && !xc[0];
1298
+ b = yc && !yc[0];
1299
+ if (a || b) return a ? b ? 0 : -j : i;
1300
+ if (i != j) return i;
1301
+ a = i < 0;
1302
+ b = k == l;
1303
+ if (!xc || !yc) return b ? 0 : !xc ^ a ? 1 : -1;
1304
+ if (!b) return k > l ^ a ? 1 : -1;
1305
+ j = (k = xc.length) < (l = yc.length) ? k : l;
1306
+ for (i = 0; i < j; i++) if (xc[i] != yc[i]) return xc[i] > yc[i] ^ a ? 1 : -1;
1307
+ return k == l ? 0 : k > l ^ a ? 1 : -1;
1308
+ }
1309
+ function intCheck(n, min, max, name) {
1310
+ if (n < min || n > max || n !== mathfloor(n)) {
1311
+ throw Error(bignumberError + (name || "Argument") + (typeof n == "number" ? n < min || n > max ? " out of range: " : " not an integer: " : " not a primitive number: ") + String(n));
1312
+ }
1313
+ }
1314
+ function isOdd(n) {
1315
+ var k = n.c.length - 1;
1316
+ return bitFloor(n.e / LOG_BASE) == k && n.c[k] % 2 != 0;
1317
+ }
1318
+ function toExponential(str, e) {
1319
+ return (str.length > 1 ? str.charAt(0) + "." + str.slice(1) : str) + (e < 0 ? "e" : "e+") + e;
1320
+ }
1321
+ function toFixedPoint(str, e, z) {
1322
+ var len, zs;
1323
+ if (e < 0) {
1324
+ for (zs = z + "."; ++e; zs += z) ;
1325
+ str = zs + str;
1326
+ } else {
1327
+ len = str.length;
1328
+ if (++e > len) {
1329
+ for (zs = z, e -= len; --e; zs += z) ;
1330
+ str += zs;
1331
+ } else if (e < len) {
1332
+ str = str.slice(0, e) + "." + str.slice(e);
1333
+ }
1334
+ }
1335
+ return str;
1336
+ }
1337
+ BigNumber = clone();
1338
+ BigNumber["default"] = BigNumber.BigNumber = BigNumber;
1339
+ if (module.exports) {
1340
+ module.exports = BigNumber;
1341
+ } else {
1342
+ if (!globalObject) {
1343
+ globalObject = typeof self != "undefined" && self ? self : window;
1344
+ }
1345
+ globalObject.BigNumber = BigNumber;
1346
+ }
1347
+ })(bignumber);
1348
+ })(bignumber$1);
1349
+ return bignumber$1.exports;
1350
+ }
1351
+ export {
1352
+ requireBignumber as r
1353
+ };