node-appwrite 21.1.0 → 22.0.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 (119) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +2 -2
  3. package/dist/client.js +37 -5
  4. package/dist/client.js.map +1 -1
  5. package/dist/client.mjs +1505 -5
  6. package/dist/client.mjs.map +1 -1
  7. package/dist/enums/browser-permission.d.mts +24 -0
  8. package/dist/enums/browser-permission.d.ts +24 -0
  9. package/dist/enums/browser-permission.js +29 -0
  10. package/dist/enums/browser-permission.js.map +1 -0
  11. package/dist/enums/browser-permission.mjs +28 -0
  12. package/dist/enums/browser-permission.mjs.map +1 -0
  13. package/dist/enums/deployment-status.d.mts +1 -0
  14. package/dist/enums/deployment-status.d.ts +1 -0
  15. package/dist/enums/deployment-status.js +1 -0
  16. package/dist/enums/deployment-status.js.map +1 -1
  17. package/dist/enums/deployment-status.mjs +1 -0
  18. package/dist/enums/deployment-status.mjs.map +1 -1
  19. package/dist/enums/name.d.mts +1 -0
  20. package/dist/enums/name.d.ts +1 -0
  21. package/dist/enums/name.js +1 -0
  22. package/dist/enums/name.js.map +1 -1
  23. package/dist/enums/name.mjs +1 -0
  24. package/dist/enums/name.mjs.map +1 -1
  25. package/dist/enums/o-auth-provider.d.mts +1 -2
  26. package/dist/enums/o-auth-provider.d.ts +1 -2
  27. package/dist/enums/o-auth-provider.js +0 -1
  28. package/dist/enums/o-auth-provider.js.map +1 -1
  29. package/dist/enums/o-auth-provider.mjs +0 -1
  30. package/dist/enums/o-auth-provider.mjs.map +1 -1
  31. package/dist/enums/order-by.d.mts +6 -0
  32. package/dist/enums/order-by.d.ts +6 -0
  33. package/dist/enums/order-by.js +11 -0
  34. package/dist/enums/order-by.js.map +1 -0
  35. package/dist/enums/order-by.mjs +10 -0
  36. package/dist/enums/order-by.mjs.map +1 -0
  37. package/dist/enums/roles.d.mts +7 -0
  38. package/dist/enums/roles.d.ts +7 -0
  39. package/dist/enums/roles.js +12 -0
  40. package/dist/enums/roles.js.map +1 -0
  41. package/dist/enums/roles.mjs +11 -0
  42. package/dist/enums/roles.mjs.map +1 -0
  43. package/dist/enums/scopes.d.mts +59 -0
  44. package/dist/enums/scopes.d.ts +59 -0
  45. package/dist/enums/scopes.js +64 -0
  46. package/dist/enums/scopes.js.map +1 -0
  47. package/dist/enums/scopes.mjs +63 -0
  48. package/dist/enums/scopes.mjs.map +1 -0
  49. package/dist/index.d.mts +5 -2
  50. package/dist/index.d.ts +5 -2
  51. package/dist/index.js +21 -6
  52. package/dist/index.js.map +1 -1
  53. package/dist/index.mjs +5 -2
  54. package/dist/index.mjs.map +1 -1
  55. package/dist/models.d.mts +367 -6
  56. package/dist/models.d.ts +367 -6
  57. package/dist/query.d.mts +38 -8
  58. package/dist/query.d.ts +38 -8
  59. package/dist/query.js +48 -7
  60. package/dist/query.js.map +1 -1
  61. package/dist/query.mjs +44 -7
  62. package/dist/query.mjs.map +1 -1
  63. package/dist/services/account.d.mts +13 -1
  64. package/dist/services/account.d.ts +13 -1
  65. package/dist/services/account.js +13 -7
  66. package/dist/services/account.js.map +1 -1
  67. package/dist/services/account.mjs +13 -7
  68. package/dist/services/account.mjs.map +1 -1
  69. package/dist/services/avatars.d.mts +9 -8
  70. package/dist/services/avatars.d.ts +9 -8
  71. package/dist/services/avatars.js.map +1 -1
  72. package/dist/services/avatars.mjs.map +1 -1
  73. package/dist/services/databases.d.mts +329 -34
  74. package/dist/services/databases.d.ts +329 -34
  75. package/dist/services/databases.js +469 -9
  76. package/dist/services/databases.js.map +1 -1
  77. package/dist/services/databases.mjs +469 -9
  78. package/dist/services/databases.mjs.map +1 -1
  79. package/dist/services/functions.d.mts +9 -8
  80. package/dist/services/functions.d.ts +9 -8
  81. package/dist/services/functions.js.map +1 -1
  82. package/dist/services/functions.mjs.map +1 -1
  83. package/dist/services/graphql.js.map +1 -1
  84. package/dist/services/graphql.mjs.map +1 -1
  85. package/dist/services/health.d.mts +25 -6
  86. package/dist/services/health.d.ts +25 -6
  87. package/dist/services/health.js +27 -3
  88. package/dist/services/health.js.map +1 -1
  89. package/dist/services/health.mjs +27 -3
  90. package/dist/services/health.mjs.map +1 -1
  91. package/dist/services/messaging.js.map +1 -1
  92. package/dist/services/messaging.mjs.map +1 -1
  93. package/dist/services/sites.js.map +1 -1
  94. package/dist/services/sites.mjs.map +1 -1
  95. package/dist/services/storage.d.mts +12 -12
  96. package/dist/services/storage.d.ts +12 -12
  97. package/dist/services/storage.js.map +1 -1
  98. package/dist/services/storage.mjs.map +1 -1
  99. package/dist/services/tables-db.d.mts +329 -32
  100. package/dist/services/tables-db.d.ts +329 -32
  101. package/dist/services/tables-db.js +469 -6
  102. package/dist/services/tables-db.js.map +1 -1
  103. package/dist/services/tables-db.mjs +469 -6
  104. package/dist/services/tables-db.mjs.map +1 -1
  105. package/dist/services/teams.d.mts +9 -8
  106. package/dist/services/teams.d.ts +9 -8
  107. package/dist/services/teams.js.map +1 -1
  108. package/dist/services/teams.mjs.map +1 -1
  109. package/dist/services/tokens.js.map +1 -1
  110. package/dist/services/tokens.mjs.map +1 -1
  111. package/dist/services/users.js.map +1 -1
  112. package/dist/services/users.mjs.map +1 -1
  113. package/package.json +4 -2
  114. package/dist/enums/output.d.mts +0 -11
  115. package/dist/enums/output.d.ts +0 -11
  116. package/dist/enums/output.js +0 -16
  117. package/dist/enums/output.js.map +0 -1
  118. package/dist/enums/output.mjs +0 -15
  119. package/dist/enums/output.mjs.map +0 -1
package/dist/client.mjs CHANGED
@@ -1,8 +1,1505 @@
1
1
  import { FormData, File, fetch } from 'node-fetch-native-with-agent';
2
2
  import { createAgent } from 'node-fetch-native-with-agent/agent';
3
+ import JSONbigModule from 'json-bigint';
3
4
  export { Query } from './query.mjs';
4
5
 
5
6
  // src/client.ts
7
+
8
+ // node_modules/bignumber.js/bignumber.mjs
9
+ var isNumeric = /^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i;
10
+ var mathceil = Math.ceil;
11
+ var mathfloor = Math.floor;
12
+ var bignumberError = "[BigNumber Error] ";
13
+ var tooManyDigits = bignumberError + "Number primitive has more than 15 significant digits: ";
14
+ var BASE = 1e14;
15
+ var LOG_BASE = 14;
16
+ var MAX_SAFE_INTEGER = 9007199254740991;
17
+ var POWS_TEN = [1, 10, 100, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13];
18
+ var SQRT_BASE = 1e7;
19
+ var MAX = 1e9;
20
+ function clone(configObject) {
21
+ 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 = {
22
+ prefix: "",
23
+ groupSize: 3,
24
+ secondaryGroupSize: 0,
25
+ groupSeparator: ",",
26
+ decimalSeparator: ".",
27
+ fractionGroupSize: 0,
28
+ fractionGroupSeparator: "\xA0",
29
+ // non-breaking space
30
+ suffix: ""
31
+ }, ALPHABET = "0123456789abcdefghijklmnopqrstuvwxyz", alphabetHasNormalDecimalDigits = true;
32
+ function BigNumber2(v, b) {
33
+ var alphabet, c, caseChanged, e, i, isNum, len, str, x = this;
34
+ if (!(x instanceof BigNumber2))
35
+ return new BigNumber2(v, b);
36
+ if (b == null) {
37
+ if (v && v._isBigNumber === true) {
38
+ x.s = v.s;
39
+ if (!v.c || v.e > MAX_EXP) {
40
+ x.c = x.e = null;
41
+ } else if (v.e < MIN_EXP) {
42
+ x.c = [x.e = 0];
43
+ } else {
44
+ x.e = v.e;
45
+ x.c = v.c.slice();
46
+ }
47
+ return;
48
+ }
49
+ if ((isNum = typeof v == "number") && v * 0 == 0) {
50
+ x.s = 1 / v < 0 ? (v = -v, -1) : 1;
51
+ if (v === ~~v) {
52
+ for (e = 0, i = v; i >= 10; i /= 10, e++)
53
+ ;
54
+ if (e > MAX_EXP) {
55
+ x.c = x.e = null;
56
+ } else {
57
+ x.e = e;
58
+ x.c = [v];
59
+ }
60
+ return;
61
+ }
62
+ str = String(v);
63
+ } else {
64
+ if (!isNumeric.test(str = String(v)))
65
+ return parseNumeric(x, str, isNum);
66
+ x.s = str.charCodeAt(0) == 45 ? (str = str.slice(1), -1) : 1;
67
+ }
68
+ if ((e = str.indexOf(".")) > -1)
69
+ str = str.replace(".", "");
70
+ if ((i = str.search(/e/i)) > 0) {
71
+ if (e < 0)
72
+ e = i;
73
+ e += +str.slice(i + 1);
74
+ str = str.substring(0, i);
75
+ } else if (e < 0) {
76
+ e = str.length;
77
+ }
78
+ } else {
79
+ intCheck(b, 2, ALPHABET.length, "Base");
80
+ if (b == 10 && alphabetHasNormalDecimalDigits) {
81
+ x = new BigNumber2(v);
82
+ return round(x, DECIMAL_PLACES + x.e + 1, ROUNDING_MODE);
83
+ }
84
+ str = String(v);
85
+ if (isNum = typeof v == "number") {
86
+ if (v * 0 != 0)
87
+ return parseNumeric(x, str, isNum, b);
88
+ x.s = 1 / v < 0 ? (str = str.slice(1), -1) : 1;
89
+ if (BigNumber2.DEBUG && str.replace(/^0\.0*|\./, "").length > 15) {
90
+ throw Error(tooManyDigits + v);
91
+ }
92
+ } else {
93
+ x.s = str.charCodeAt(0) === 45 ? (str = str.slice(1), -1) : 1;
94
+ }
95
+ alphabet = ALPHABET.slice(0, b);
96
+ e = i = 0;
97
+ for (len = str.length; i < len; i++) {
98
+ if (alphabet.indexOf(c = str.charAt(i)) < 0) {
99
+ if (c == ".") {
100
+ if (i > e) {
101
+ e = len;
102
+ continue;
103
+ }
104
+ } else if (!caseChanged) {
105
+ if (str == str.toUpperCase() && (str = str.toLowerCase()) || str == str.toLowerCase() && (str = str.toUpperCase())) {
106
+ caseChanged = true;
107
+ i = -1;
108
+ e = 0;
109
+ continue;
110
+ }
111
+ }
112
+ return parseNumeric(x, String(v), isNum, b);
113
+ }
114
+ }
115
+ isNum = false;
116
+ str = convertBase(str, b, 10, x.s);
117
+ if ((e = str.indexOf(".")) > -1)
118
+ str = str.replace(".", "");
119
+ else
120
+ e = str.length;
121
+ }
122
+ for (i = 0; str.charCodeAt(i) === 48; i++)
123
+ ;
124
+ for (len = str.length; str.charCodeAt(--len) === 48; )
125
+ ;
126
+ if (str = str.slice(i, ++len)) {
127
+ len -= i;
128
+ if (isNum && BigNumber2.DEBUG && len > 15 && (v > MAX_SAFE_INTEGER || v !== mathfloor(v))) {
129
+ throw Error(tooManyDigits + x.s * v);
130
+ }
131
+ if ((e = e - i - 1) > MAX_EXP) {
132
+ x.c = x.e = null;
133
+ } else if (e < MIN_EXP) {
134
+ x.c = [x.e = 0];
135
+ } else {
136
+ x.e = e;
137
+ x.c = [];
138
+ i = (e + 1) % LOG_BASE;
139
+ if (e < 0)
140
+ i += LOG_BASE;
141
+ if (i < len) {
142
+ if (i)
143
+ x.c.push(+str.slice(0, i));
144
+ for (len -= LOG_BASE; i < len; ) {
145
+ x.c.push(+str.slice(i, i += LOG_BASE));
146
+ }
147
+ i = LOG_BASE - (str = str.slice(i)).length;
148
+ } else {
149
+ i -= len;
150
+ }
151
+ for (; i--; str += "0")
152
+ ;
153
+ x.c.push(+str);
154
+ }
155
+ } else {
156
+ x.c = [x.e = 0];
157
+ }
158
+ }
159
+ BigNumber2.clone = clone;
160
+ BigNumber2.ROUND_UP = 0;
161
+ BigNumber2.ROUND_DOWN = 1;
162
+ BigNumber2.ROUND_CEIL = 2;
163
+ BigNumber2.ROUND_FLOOR = 3;
164
+ BigNumber2.ROUND_HALF_UP = 4;
165
+ BigNumber2.ROUND_HALF_DOWN = 5;
166
+ BigNumber2.ROUND_HALF_EVEN = 6;
167
+ BigNumber2.ROUND_HALF_CEIL = 7;
168
+ BigNumber2.ROUND_HALF_FLOOR = 8;
169
+ BigNumber2.EUCLID = 9;
170
+ BigNumber2.config = BigNumber2.set = function(obj) {
171
+ var p, v;
172
+ if (obj != null) {
173
+ if (typeof obj == "object") {
174
+ if (obj.hasOwnProperty(p = "DECIMAL_PLACES")) {
175
+ v = obj[p];
176
+ intCheck(v, 0, MAX, p);
177
+ DECIMAL_PLACES = v;
178
+ }
179
+ if (obj.hasOwnProperty(p = "ROUNDING_MODE")) {
180
+ v = obj[p];
181
+ intCheck(v, 0, 8, p);
182
+ ROUNDING_MODE = v;
183
+ }
184
+ if (obj.hasOwnProperty(p = "EXPONENTIAL_AT")) {
185
+ v = obj[p];
186
+ if (v && v.pop) {
187
+ intCheck(v[0], -MAX, 0, p);
188
+ intCheck(v[1], 0, MAX, p);
189
+ TO_EXP_NEG = v[0];
190
+ TO_EXP_POS = v[1];
191
+ } else {
192
+ intCheck(v, -MAX, MAX, p);
193
+ TO_EXP_NEG = -(TO_EXP_POS = v < 0 ? -v : v);
194
+ }
195
+ }
196
+ if (obj.hasOwnProperty(p = "RANGE")) {
197
+ v = obj[p];
198
+ if (v && v.pop) {
199
+ intCheck(v[0], -MAX, -1, p);
200
+ intCheck(v[1], 1, MAX, p);
201
+ MIN_EXP = v[0];
202
+ MAX_EXP = v[1];
203
+ } else {
204
+ intCheck(v, -MAX, MAX, p);
205
+ if (v) {
206
+ MIN_EXP = -(MAX_EXP = v < 0 ? -v : v);
207
+ } else {
208
+ throw Error(bignumberError + p + " cannot be zero: " + v);
209
+ }
210
+ }
211
+ }
212
+ if (obj.hasOwnProperty(p = "CRYPTO")) {
213
+ v = obj[p];
214
+ if (v === !!v) {
215
+ if (v) {
216
+ if (typeof crypto != "undefined" && crypto && (crypto.getRandomValues || crypto.randomBytes)) {
217
+ CRYPTO = v;
218
+ } else {
219
+ CRYPTO = !v;
220
+ throw Error(bignumberError + "crypto unavailable");
221
+ }
222
+ } else {
223
+ CRYPTO = v;
224
+ }
225
+ } else {
226
+ throw Error(bignumberError + p + " not true or false: " + v);
227
+ }
228
+ }
229
+ if (obj.hasOwnProperty(p = "MODULO_MODE")) {
230
+ v = obj[p];
231
+ intCheck(v, 0, 9, p);
232
+ MODULO_MODE = v;
233
+ }
234
+ if (obj.hasOwnProperty(p = "POW_PRECISION")) {
235
+ v = obj[p];
236
+ intCheck(v, 0, MAX, p);
237
+ POW_PRECISION = v;
238
+ }
239
+ if (obj.hasOwnProperty(p = "FORMAT")) {
240
+ v = obj[p];
241
+ if (typeof v == "object")
242
+ FORMAT = v;
243
+ else
244
+ throw Error(bignumberError + p + " not an object: " + v);
245
+ }
246
+ if (obj.hasOwnProperty(p = "ALPHABET")) {
247
+ v = obj[p];
248
+ if (typeof v == "string" && !/^.?$|[+\-.\s]|(.).*\1/.test(v)) {
249
+ alphabetHasNormalDecimalDigits = v.slice(0, 10) == "0123456789";
250
+ ALPHABET = v;
251
+ } else {
252
+ throw Error(bignumberError + p + " invalid: " + v);
253
+ }
254
+ }
255
+ } else {
256
+ throw Error(bignumberError + "Object expected: " + obj);
257
+ }
258
+ }
259
+ return {
260
+ DECIMAL_PLACES,
261
+ ROUNDING_MODE,
262
+ EXPONENTIAL_AT: [TO_EXP_NEG, TO_EXP_POS],
263
+ RANGE: [MIN_EXP, MAX_EXP],
264
+ CRYPTO,
265
+ MODULO_MODE,
266
+ POW_PRECISION,
267
+ FORMAT,
268
+ ALPHABET
269
+ };
270
+ };
271
+ BigNumber2.isBigNumber = function(v) {
272
+ if (!v || v._isBigNumber !== true)
273
+ return false;
274
+ if (!BigNumber2.DEBUG)
275
+ return true;
276
+ var i, n, c = v.c, e = v.e, s = v.s;
277
+ out:
278
+ if ({}.toString.call(c) == "[object Array]") {
279
+ if ((s === 1 || s === -1) && e >= -MAX && e <= MAX && e === mathfloor(e)) {
280
+ if (c[0] === 0) {
281
+ if (e === 0 && c.length === 1)
282
+ return true;
283
+ break out;
284
+ }
285
+ i = (e + 1) % LOG_BASE;
286
+ if (i < 1)
287
+ i += LOG_BASE;
288
+ if (String(c[0]).length == i) {
289
+ for (i = 0; i < c.length; i++) {
290
+ n = c[i];
291
+ if (n < 0 || n >= BASE || n !== mathfloor(n))
292
+ break out;
293
+ }
294
+ if (n !== 0)
295
+ return true;
296
+ }
297
+ }
298
+ } else if (c === null && e === null && (s === null || s === 1 || s === -1)) {
299
+ return true;
300
+ }
301
+ throw Error(bignumberError + "Invalid BigNumber: " + v);
302
+ };
303
+ BigNumber2.maximum = BigNumber2.max = function() {
304
+ return maxOrMin(arguments, -1);
305
+ };
306
+ BigNumber2.minimum = BigNumber2.min = function() {
307
+ return maxOrMin(arguments, 1);
308
+ };
309
+ BigNumber2.random = function() {
310
+ var pow2_53 = 9007199254740992;
311
+ var random53bitInt = Math.random() * pow2_53 & 2097151 ? function() {
312
+ return mathfloor(Math.random() * pow2_53);
313
+ } : function() {
314
+ return (Math.random() * 1073741824 | 0) * 8388608 + (Math.random() * 8388608 | 0);
315
+ };
316
+ return function(dp) {
317
+ var a, b, e, k, v, i = 0, c = [], rand = new BigNumber2(ONE);
318
+ if (dp == null)
319
+ dp = DECIMAL_PLACES;
320
+ else
321
+ intCheck(dp, 0, MAX);
322
+ k = mathceil(dp / LOG_BASE);
323
+ if (CRYPTO) {
324
+ if (crypto.getRandomValues) {
325
+ a = crypto.getRandomValues(new Uint32Array(k *= 2));
326
+ for (; i < k; ) {
327
+ v = a[i] * 131072 + (a[i + 1] >>> 11);
328
+ if (v >= 9e15) {
329
+ b = crypto.getRandomValues(new Uint32Array(2));
330
+ a[i] = b[0];
331
+ a[i + 1] = b[1];
332
+ } else {
333
+ c.push(v % 1e14);
334
+ i += 2;
335
+ }
336
+ }
337
+ i = k / 2;
338
+ } else if (crypto.randomBytes) {
339
+ a = crypto.randomBytes(k *= 7);
340
+ for (; i < k; ) {
341
+ 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];
342
+ if (v >= 9e15) {
343
+ crypto.randomBytes(7).copy(a, i);
344
+ } else {
345
+ c.push(v % 1e14);
346
+ i += 7;
347
+ }
348
+ }
349
+ i = k / 7;
350
+ } else {
351
+ CRYPTO = false;
352
+ throw Error(bignumberError + "crypto unavailable");
353
+ }
354
+ }
355
+ if (!CRYPTO) {
356
+ for (; i < k; ) {
357
+ v = random53bitInt();
358
+ if (v < 9e15)
359
+ c[i++] = v % 1e14;
360
+ }
361
+ }
362
+ k = c[--i];
363
+ dp %= LOG_BASE;
364
+ if (k && dp) {
365
+ v = POWS_TEN[LOG_BASE - dp];
366
+ c[i] = mathfloor(k / v) * v;
367
+ }
368
+ for (; c[i] === 0; c.pop(), i--)
369
+ ;
370
+ if (i < 0) {
371
+ c = [e = 0];
372
+ } else {
373
+ for (e = -1; c[0] === 0; c.splice(0, 1), e -= LOG_BASE)
374
+ ;
375
+ for (i = 1, v = c[0]; v >= 10; v /= 10, i++)
376
+ ;
377
+ if (i < LOG_BASE)
378
+ e -= LOG_BASE - i;
379
+ }
380
+ rand.e = e;
381
+ rand.c = c;
382
+ return rand;
383
+ };
384
+ }();
385
+ BigNumber2.sum = function() {
386
+ var i = 1, args = arguments, sum = new BigNumber2(args[0]);
387
+ for (; i < args.length; )
388
+ sum = sum.plus(args[i++]);
389
+ return sum;
390
+ };
391
+ convertBase = function() {
392
+ var decimal = "0123456789";
393
+ function toBaseOut(str, baseIn, baseOut, alphabet) {
394
+ var j, arr = [0], arrL, i = 0, len = str.length;
395
+ for (; i < len; ) {
396
+ for (arrL = arr.length; arrL--; arr[arrL] *= baseIn)
397
+ ;
398
+ arr[0] += alphabet.indexOf(str.charAt(i++));
399
+ for (j = 0; j < arr.length; j++) {
400
+ if (arr[j] > baseOut - 1) {
401
+ if (arr[j + 1] == null)
402
+ arr[j + 1] = 0;
403
+ arr[j + 1] += arr[j] / baseOut | 0;
404
+ arr[j] %= baseOut;
405
+ }
406
+ }
407
+ }
408
+ return arr.reverse();
409
+ }
410
+ return function(str, baseIn, baseOut, sign, callerIsToString) {
411
+ var alphabet, d, e, k, r, x, xc, y, i = str.indexOf("."), dp = DECIMAL_PLACES, rm = ROUNDING_MODE;
412
+ if (i >= 0) {
413
+ k = POW_PRECISION;
414
+ POW_PRECISION = 0;
415
+ str = str.replace(".", "");
416
+ y = new BigNumber2(baseIn);
417
+ x = y.pow(str.length - i);
418
+ POW_PRECISION = k;
419
+ y.c = toBaseOut(
420
+ toFixedPoint(coeffToString(x.c), x.e, "0"),
421
+ 10,
422
+ baseOut,
423
+ decimal
424
+ );
425
+ y.e = y.c.length;
426
+ }
427
+ xc = toBaseOut(str, baseIn, baseOut, callerIsToString ? (alphabet = ALPHABET, decimal) : (alphabet = decimal, ALPHABET));
428
+ e = k = xc.length;
429
+ for (; xc[--k] == 0; xc.pop())
430
+ ;
431
+ if (!xc[0])
432
+ return alphabet.charAt(0);
433
+ if (i < 0) {
434
+ --e;
435
+ } else {
436
+ x.c = xc;
437
+ x.e = e;
438
+ x.s = sign;
439
+ x = div(x, y, dp, rm, baseOut);
440
+ xc = x.c;
441
+ r = x.r;
442
+ e = x.e;
443
+ }
444
+ d = e + dp + 1;
445
+ i = xc[d];
446
+ k = baseOut / 2;
447
+ r = r || d < 0 || xc[d + 1] != null;
448
+ 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));
449
+ if (d < 1 || !xc[0]) {
450
+ str = r ? toFixedPoint(alphabet.charAt(1), -dp, alphabet.charAt(0)) : alphabet.charAt(0);
451
+ } else {
452
+ xc.length = d;
453
+ if (r) {
454
+ for (--baseOut; ++xc[--d] > baseOut; ) {
455
+ xc[d] = 0;
456
+ if (!d) {
457
+ ++e;
458
+ xc = [1].concat(xc);
459
+ }
460
+ }
461
+ }
462
+ for (k = xc.length; !xc[--k]; )
463
+ ;
464
+ for (i = 0, str = ""; i <= k; str += alphabet.charAt(xc[i++]))
465
+ ;
466
+ str = toFixedPoint(str, e, alphabet.charAt(0));
467
+ }
468
+ return str;
469
+ };
470
+ }();
471
+ div = function() {
472
+ function multiply(x, k, base) {
473
+ var m, temp, xlo, xhi, carry = 0, i = x.length, klo = k % SQRT_BASE, khi = k / SQRT_BASE | 0;
474
+ for (x = x.slice(); i--; ) {
475
+ xlo = x[i] % SQRT_BASE;
476
+ xhi = x[i] / SQRT_BASE | 0;
477
+ m = khi * xlo + xhi * klo;
478
+ temp = klo * xlo + m % SQRT_BASE * SQRT_BASE + carry;
479
+ carry = (temp / base | 0) + (m / SQRT_BASE | 0) + khi * xhi;
480
+ x[i] = temp % base;
481
+ }
482
+ if (carry)
483
+ x = [carry].concat(x);
484
+ return x;
485
+ }
486
+ function compare2(a, b, aL, bL) {
487
+ var i, cmp;
488
+ if (aL != bL) {
489
+ cmp = aL > bL ? 1 : -1;
490
+ } else {
491
+ for (i = cmp = 0; i < aL; i++) {
492
+ if (a[i] != b[i]) {
493
+ cmp = a[i] > b[i] ? 1 : -1;
494
+ break;
495
+ }
496
+ }
497
+ }
498
+ return cmp;
499
+ }
500
+ function subtract(a, b, aL, base) {
501
+ var i = 0;
502
+ for (; aL--; ) {
503
+ a[aL] -= i;
504
+ i = a[aL] < b[aL] ? 1 : 0;
505
+ a[aL] = i * base + a[aL] - b[aL];
506
+ }
507
+ for (; !a[0] && a.length > 1; a.splice(0, 1))
508
+ ;
509
+ }
510
+ return function(x, y, dp, rm, base) {
511
+ 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;
512
+ if (!xc || !xc[0] || !yc || !yc[0]) {
513
+ return new BigNumber2(
514
+ // Return NaN if either NaN, or both Infinity or 0.
515
+ !x.s || !y.s || (xc ? yc && xc[0] == yc[0] : !yc) ? NaN : (
516
+ // Return ±0 if x is ±0 or y is ±Infinity, or return ±Infinity as y is ±0.
517
+ xc && xc[0] == 0 || !yc ? s * 0 : s / 0
518
+ )
519
+ );
520
+ }
521
+ q = new BigNumber2(s);
522
+ qc = q.c = [];
523
+ e = x.e - y.e;
524
+ s = dp + e + 1;
525
+ if (!base) {
526
+ base = BASE;
527
+ e = bitFloor(x.e / LOG_BASE) - bitFloor(y.e / LOG_BASE);
528
+ s = s / LOG_BASE | 0;
529
+ }
530
+ for (i = 0; yc[i] == (xc[i] || 0); i++)
531
+ ;
532
+ if (yc[i] > (xc[i] || 0))
533
+ e--;
534
+ if (s < 0) {
535
+ qc.push(1);
536
+ more = true;
537
+ } else {
538
+ xL = xc.length;
539
+ yL = yc.length;
540
+ i = 0;
541
+ s += 2;
542
+ n = mathfloor(base / (yc[0] + 1));
543
+ if (n > 1) {
544
+ yc = multiply(yc, n, base);
545
+ xc = multiply(xc, n, base);
546
+ yL = yc.length;
547
+ xL = xc.length;
548
+ }
549
+ xi = yL;
550
+ rem = xc.slice(0, yL);
551
+ remL = rem.length;
552
+ for (; remL < yL; rem[remL++] = 0)
553
+ ;
554
+ yz = yc.slice();
555
+ yz = [0].concat(yz);
556
+ yc0 = yc[0];
557
+ if (yc[1] >= base / 2)
558
+ yc0++;
559
+ do {
560
+ n = 0;
561
+ cmp = compare2(yc, rem, yL, remL);
562
+ if (cmp < 0) {
563
+ rem0 = rem[0];
564
+ if (yL != remL)
565
+ rem0 = rem0 * base + (rem[1] || 0);
566
+ n = mathfloor(rem0 / yc0);
567
+ if (n > 1) {
568
+ if (n >= base)
569
+ n = base - 1;
570
+ prod = multiply(yc, n, base);
571
+ prodL = prod.length;
572
+ remL = rem.length;
573
+ while (compare2(prod, rem, prodL, remL) == 1) {
574
+ n--;
575
+ subtract(prod, yL < prodL ? yz : yc, prodL, base);
576
+ prodL = prod.length;
577
+ cmp = 1;
578
+ }
579
+ } else {
580
+ if (n == 0) {
581
+ cmp = n = 1;
582
+ }
583
+ prod = yc.slice();
584
+ prodL = prod.length;
585
+ }
586
+ if (prodL < remL)
587
+ prod = [0].concat(prod);
588
+ subtract(rem, prod, remL, base);
589
+ remL = rem.length;
590
+ if (cmp == -1) {
591
+ while (compare2(yc, rem, yL, remL) < 1) {
592
+ n++;
593
+ subtract(rem, yL < remL ? yz : yc, remL, base);
594
+ remL = rem.length;
595
+ }
596
+ }
597
+ } else if (cmp === 0) {
598
+ n++;
599
+ rem = [0];
600
+ }
601
+ qc[i++] = n;
602
+ if (rem[0]) {
603
+ rem[remL++] = xc[xi] || 0;
604
+ } else {
605
+ rem = [xc[xi]];
606
+ remL = 1;
607
+ }
608
+ } while ((xi++ < xL || rem[0] != null) && s--);
609
+ more = rem[0] != null;
610
+ if (!qc[0])
611
+ qc.splice(0, 1);
612
+ }
613
+ if (base == BASE) {
614
+ for (i = 1, s = qc[0]; s >= 10; s /= 10, i++)
615
+ ;
616
+ round(q, dp + (q.e = i + e * LOG_BASE - 1) + 1, rm, more);
617
+ } else {
618
+ q.e = e;
619
+ q.r = +more;
620
+ }
621
+ return q;
622
+ };
623
+ }();
624
+ function format(n, i, rm, id) {
625
+ var c0, e, ne, len, str;
626
+ if (rm == null)
627
+ rm = ROUNDING_MODE;
628
+ else
629
+ intCheck(rm, 0, 8);
630
+ if (!n.c)
631
+ return n.toString();
632
+ c0 = n.c[0];
633
+ ne = n.e;
634
+ if (i == null) {
635
+ str = coeffToString(n.c);
636
+ str = id == 1 || id == 2 && (ne <= TO_EXP_NEG || ne >= TO_EXP_POS) ? toExponential(str, ne) : toFixedPoint(str, ne, "0");
637
+ } else {
638
+ n = round(new BigNumber2(n), i, rm);
639
+ e = n.e;
640
+ str = coeffToString(n.c);
641
+ len = str.length;
642
+ if (id == 1 || id == 2 && (i <= e || e <= TO_EXP_NEG)) {
643
+ for (; len < i; str += "0", len++)
644
+ ;
645
+ str = toExponential(str, e);
646
+ } else {
647
+ i -= ne + (id === 2 && e > ne);
648
+ str = toFixedPoint(str, e, "0");
649
+ if (e + 1 > len) {
650
+ if (--i > 0)
651
+ for (str += "."; i--; str += "0")
652
+ ;
653
+ } else {
654
+ i += e - len;
655
+ if (i > 0) {
656
+ if (e + 1 == len)
657
+ str += ".";
658
+ for (; i--; str += "0")
659
+ ;
660
+ }
661
+ }
662
+ }
663
+ }
664
+ return n.s < 0 && c0 ? "-" + str : str;
665
+ }
666
+ function maxOrMin(args, n) {
667
+ var k, y, i = 1, x = new BigNumber2(args[0]);
668
+ for (; i < args.length; i++) {
669
+ y = new BigNumber2(args[i]);
670
+ if (!y.s || (k = compare(x, y)) === n || k === 0 && x.s === n) {
671
+ x = y;
672
+ }
673
+ }
674
+ return x;
675
+ }
676
+ function normalise(n, c, e) {
677
+ var i = 1, j = c.length;
678
+ for (; !c[--j]; c.pop())
679
+ ;
680
+ for (j = c[0]; j >= 10; j /= 10, i++)
681
+ ;
682
+ if ((e = i + e * LOG_BASE - 1) > MAX_EXP) {
683
+ n.c = n.e = null;
684
+ } else if (e < MIN_EXP) {
685
+ n.c = [n.e = 0];
686
+ } else {
687
+ n.e = e;
688
+ n.c = c;
689
+ }
690
+ return n;
691
+ }
692
+ parseNumeric = function() {
693
+ var basePrefix = /^(-?)0([xbo])(?=\w[\w.]*$)/i, dotAfter = /^([^.]+)\.$/, dotBefore = /^\.([^.]+)$/, isInfinityOrNaN = /^-?(Infinity|NaN)$/, whitespaceOrPlus = /^\s*\+(?=[\w.])|^\s+|\s+$/g;
694
+ return function(x, str, isNum, b) {
695
+ var base, s = isNum ? str : str.replace(whitespaceOrPlus, "");
696
+ if (isInfinityOrNaN.test(s)) {
697
+ x.s = isNaN(s) ? null : s < 0 ? -1 : 1;
698
+ } else {
699
+ if (!isNum) {
700
+ s = s.replace(basePrefix, function(m, p1, p2) {
701
+ base = (p2 = p2.toLowerCase()) == "x" ? 16 : p2 == "b" ? 2 : 8;
702
+ return !b || b == base ? p1 : m;
703
+ });
704
+ if (b) {
705
+ base = b;
706
+ s = s.replace(dotAfter, "$1").replace(dotBefore, "0.$1");
707
+ }
708
+ if (str != s)
709
+ return new BigNumber2(s, base);
710
+ }
711
+ if (BigNumber2.DEBUG) {
712
+ throw Error(bignumberError + "Not a" + (b ? " base " + b : "") + " number: " + str);
713
+ }
714
+ x.s = null;
715
+ }
716
+ x.c = x.e = null;
717
+ };
718
+ }();
719
+ function round(x, sd, rm, r) {
720
+ var d, i, j, k, n, ni, rd, xc = x.c, pows10 = POWS_TEN;
721
+ if (xc) {
722
+ out: {
723
+ for (d = 1, k = xc[0]; k >= 10; k /= 10, d++)
724
+ ;
725
+ i = sd - d;
726
+ if (i < 0) {
727
+ i += LOG_BASE;
728
+ j = sd;
729
+ n = xc[ni = 0];
730
+ rd = mathfloor(n / pows10[d - j - 1] % 10);
731
+ } else {
732
+ ni = mathceil((i + 1) / LOG_BASE);
733
+ if (ni >= xc.length) {
734
+ if (r) {
735
+ for (; xc.length <= ni; xc.push(0))
736
+ ;
737
+ n = rd = 0;
738
+ d = 1;
739
+ i %= LOG_BASE;
740
+ j = i - LOG_BASE + 1;
741
+ } else {
742
+ break out;
743
+ }
744
+ } else {
745
+ n = k = xc[ni];
746
+ for (d = 1; k >= 10; k /= 10, d++)
747
+ ;
748
+ i %= LOG_BASE;
749
+ j = i - LOG_BASE + d;
750
+ rd = j < 0 ? 0 : mathfloor(n / pows10[d - j - 1] % 10);
751
+ }
752
+ }
753
+ r = r || sd < 0 || // Are there any non-zero digits after the rounding digit?
754
+ // The expression n % pows10[d - j - 1] returns all digits of n to the right
755
+ // of the digit at j, e.g. if n is 908714 and j is 2, the expression gives 714.
756
+ xc[ni + 1] != null || (j < 0 ? n : n % pows10[d - j - 1]);
757
+ 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.
758
+ (i > 0 ? j > 0 ? n / pows10[d - j] : 0 : xc[ni - 1]) % 10 & 1 || rm == (x.s < 0 ? 8 : 7));
759
+ if (sd < 1 || !xc[0]) {
760
+ xc.length = 0;
761
+ if (r) {
762
+ sd -= x.e + 1;
763
+ xc[0] = pows10[(LOG_BASE - sd % LOG_BASE) % LOG_BASE];
764
+ x.e = -sd || 0;
765
+ } else {
766
+ xc[0] = x.e = 0;
767
+ }
768
+ return x;
769
+ }
770
+ if (i == 0) {
771
+ xc.length = ni;
772
+ k = 1;
773
+ ni--;
774
+ } else {
775
+ xc.length = ni + 1;
776
+ k = pows10[LOG_BASE - i];
777
+ xc[ni] = j > 0 ? mathfloor(n / pows10[d - j] % pows10[j]) * k : 0;
778
+ }
779
+ if (r) {
780
+ for (; ; ) {
781
+ if (ni == 0) {
782
+ for (i = 1, j = xc[0]; j >= 10; j /= 10, i++)
783
+ ;
784
+ j = xc[0] += k;
785
+ for (k = 1; j >= 10; j /= 10, k++)
786
+ ;
787
+ if (i != k) {
788
+ x.e++;
789
+ if (xc[0] == BASE)
790
+ xc[0] = 1;
791
+ }
792
+ break;
793
+ } else {
794
+ xc[ni] += k;
795
+ if (xc[ni] != BASE)
796
+ break;
797
+ xc[ni--] = 0;
798
+ k = 1;
799
+ }
800
+ }
801
+ }
802
+ for (i = xc.length; xc[--i] === 0; xc.pop())
803
+ ;
804
+ }
805
+ if (x.e > MAX_EXP) {
806
+ x.c = x.e = null;
807
+ } else if (x.e < MIN_EXP) {
808
+ x.c = [x.e = 0];
809
+ }
810
+ }
811
+ return x;
812
+ }
813
+ function valueOf(n) {
814
+ var str, e = n.e;
815
+ if (e === null)
816
+ return n.toString();
817
+ str = coeffToString(n.c);
818
+ str = e <= TO_EXP_NEG || e >= TO_EXP_POS ? toExponential(str, e) : toFixedPoint(str, e, "0");
819
+ return n.s < 0 ? "-" + str : str;
820
+ }
821
+ P.absoluteValue = P.abs = function() {
822
+ var x = new BigNumber2(this);
823
+ if (x.s < 0)
824
+ x.s = 1;
825
+ return x;
826
+ };
827
+ P.comparedTo = function(y, b) {
828
+ return compare(this, new BigNumber2(y, b));
829
+ };
830
+ P.decimalPlaces = P.dp = function(dp, rm) {
831
+ var c, n, v, x = this;
832
+ if (dp != null) {
833
+ intCheck(dp, 0, MAX);
834
+ if (rm == null)
835
+ rm = ROUNDING_MODE;
836
+ else
837
+ intCheck(rm, 0, 8);
838
+ return round(new BigNumber2(x), dp + x.e + 1, rm);
839
+ }
840
+ if (!(c = x.c))
841
+ return null;
842
+ n = ((v = c.length - 1) - bitFloor(this.e / LOG_BASE)) * LOG_BASE;
843
+ if (v = c[v])
844
+ for (; v % 10 == 0; v /= 10, n--)
845
+ ;
846
+ if (n < 0)
847
+ n = 0;
848
+ return n;
849
+ };
850
+ P.dividedBy = P.div = function(y, b) {
851
+ return div(this, new BigNumber2(y, b), DECIMAL_PLACES, ROUNDING_MODE);
852
+ };
853
+ P.dividedToIntegerBy = P.idiv = function(y, b) {
854
+ return div(this, new BigNumber2(y, b), 0, 1);
855
+ };
856
+ P.exponentiatedBy = P.pow = function(n, m) {
857
+ var half, isModExp, i, k, more, nIsBig, nIsNeg, nIsOdd, y, x = this;
858
+ n = new BigNumber2(n);
859
+ if (n.c && !n.isInteger()) {
860
+ throw Error(bignumberError + "Exponent not an integer: " + valueOf(n));
861
+ }
862
+ if (m != null)
863
+ m = new BigNumber2(m);
864
+ nIsBig = n.e > 14;
865
+ if (!x.c || !x.c[0] || x.c[0] == 1 && !x.e && x.c.length == 1 || !n.c || !n.c[0]) {
866
+ y = new BigNumber2(Math.pow(+valueOf(x), nIsBig ? n.s * (2 - isOdd(n)) : +valueOf(n)));
867
+ return m ? y.mod(m) : y;
868
+ }
869
+ nIsNeg = n.s < 0;
870
+ if (m) {
871
+ if (m.c ? !m.c[0] : !m.s)
872
+ return new BigNumber2(NaN);
873
+ isModExp = !nIsNeg && x.isInteger() && m.isInteger();
874
+ if (isModExp)
875
+ x = x.mod(m);
876
+ } 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))) {
877
+ k = x.s < 0 && isOdd(n) ? -0 : 0;
878
+ if (x.e > -1)
879
+ k = 1 / k;
880
+ return new BigNumber2(nIsNeg ? 1 / k : k);
881
+ } else if (POW_PRECISION) {
882
+ k = mathceil(POW_PRECISION / LOG_BASE + 2);
883
+ }
884
+ if (nIsBig) {
885
+ half = new BigNumber2(0.5);
886
+ if (nIsNeg)
887
+ n.s = 1;
888
+ nIsOdd = isOdd(n);
889
+ } else {
890
+ i = Math.abs(+valueOf(n));
891
+ nIsOdd = i % 2;
892
+ }
893
+ y = new BigNumber2(ONE);
894
+ for (; ; ) {
895
+ if (nIsOdd) {
896
+ y = y.times(x);
897
+ if (!y.c)
898
+ break;
899
+ if (k) {
900
+ if (y.c.length > k)
901
+ y.c.length = k;
902
+ } else if (isModExp) {
903
+ y = y.mod(m);
904
+ }
905
+ }
906
+ if (i) {
907
+ i = mathfloor(i / 2);
908
+ if (i === 0)
909
+ break;
910
+ nIsOdd = i % 2;
911
+ } else {
912
+ n = n.times(half);
913
+ round(n, n.e + 1, 1);
914
+ if (n.e > 14) {
915
+ nIsOdd = isOdd(n);
916
+ } else {
917
+ i = +valueOf(n);
918
+ if (i === 0)
919
+ break;
920
+ nIsOdd = i % 2;
921
+ }
922
+ }
923
+ x = x.times(x);
924
+ if (k) {
925
+ if (x.c && x.c.length > k)
926
+ x.c.length = k;
927
+ } else if (isModExp) {
928
+ x = x.mod(m);
929
+ }
930
+ }
931
+ if (isModExp)
932
+ return y;
933
+ if (nIsNeg)
934
+ y = ONE.div(y);
935
+ return m ? y.mod(m) : k ? round(y, POW_PRECISION, ROUNDING_MODE, more) : y;
936
+ };
937
+ P.integerValue = function(rm) {
938
+ var n = new BigNumber2(this);
939
+ if (rm == null)
940
+ rm = ROUNDING_MODE;
941
+ else
942
+ intCheck(rm, 0, 8);
943
+ return round(n, n.e + 1, rm);
944
+ };
945
+ P.isEqualTo = P.eq = function(y, b) {
946
+ return compare(this, new BigNumber2(y, b)) === 0;
947
+ };
948
+ P.isFinite = function() {
949
+ return !!this.c;
950
+ };
951
+ P.isGreaterThan = P.gt = function(y, b) {
952
+ return compare(this, new BigNumber2(y, b)) > 0;
953
+ };
954
+ P.isGreaterThanOrEqualTo = P.gte = function(y, b) {
955
+ return (b = compare(this, new BigNumber2(y, b))) === 1 || b === 0;
956
+ };
957
+ P.isInteger = function() {
958
+ return !!this.c && bitFloor(this.e / LOG_BASE) > this.c.length - 2;
959
+ };
960
+ P.isLessThan = P.lt = function(y, b) {
961
+ return compare(this, new BigNumber2(y, b)) < 0;
962
+ };
963
+ P.isLessThanOrEqualTo = P.lte = function(y, b) {
964
+ return (b = compare(this, new BigNumber2(y, b))) === -1 || b === 0;
965
+ };
966
+ P.isNaN = function() {
967
+ return !this.s;
968
+ };
969
+ P.isNegative = function() {
970
+ return this.s < 0;
971
+ };
972
+ P.isPositive = function() {
973
+ return this.s > 0;
974
+ };
975
+ P.isZero = function() {
976
+ return !!this.c && this.c[0] == 0;
977
+ };
978
+ P.minus = function(y, b) {
979
+ var i, j, t, xLTy, x = this, a = x.s;
980
+ y = new BigNumber2(y, b);
981
+ b = y.s;
982
+ if (!a || !b)
983
+ return new BigNumber2(NaN);
984
+ if (a != b) {
985
+ y.s = -b;
986
+ return x.plus(y);
987
+ }
988
+ var xe = x.e / LOG_BASE, ye = y.e / LOG_BASE, xc = x.c, yc = y.c;
989
+ if (!xe || !ye) {
990
+ if (!xc || !yc)
991
+ return xc ? (y.s = -b, y) : new BigNumber2(yc ? x : NaN);
992
+ if (!xc[0] || !yc[0]) {
993
+ return yc[0] ? (y.s = -b, y) : new BigNumber2(xc[0] ? x : (
994
+ // IEEE 754 (2008) 6.3: n - n = -0 when rounding to -Infinity
995
+ ROUNDING_MODE == 3 ? -0 : 0
996
+ ));
997
+ }
998
+ }
999
+ xe = bitFloor(xe);
1000
+ ye = bitFloor(ye);
1001
+ xc = xc.slice();
1002
+ if (a = xe - ye) {
1003
+ if (xLTy = a < 0) {
1004
+ a = -a;
1005
+ t = xc;
1006
+ } else {
1007
+ ye = xe;
1008
+ t = yc;
1009
+ }
1010
+ t.reverse();
1011
+ for (b = a; b--; t.push(0))
1012
+ ;
1013
+ t.reverse();
1014
+ } else {
1015
+ j = (xLTy = (a = xc.length) < (b = yc.length)) ? a : b;
1016
+ for (a = b = 0; b < j; b++) {
1017
+ if (xc[b] != yc[b]) {
1018
+ xLTy = xc[b] < yc[b];
1019
+ break;
1020
+ }
1021
+ }
1022
+ }
1023
+ if (xLTy) {
1024
+ t = xc;
1025
+ xc = yc;
1026
+ yc = t;
1027
+ y.s = -y.s;
1028
+ }
1029
+ b = (j = yc.length) - (i = xc.length);
1030
+ if (b > 0)
1031
+ for (; b--; xc[i++] = 0)
1032
+ ;
1033
+ b = BASE - 1;
1034
+ for (; j > a; ) {
1035
+ if (xc[--j] < yc[j]) {
1036
+ for (i = j; i && !xc[--i]; xc[i] = b)
1037
+ ;
1038
+ --xc[i];
1039
+ xc[j] += BASE;
1040
+ }
1041
+ xc[j] -= yc[j];
1042
+ }
1043
+ for (; xc[0] == 0; xc.splice(0, 1), --ye)
1044
+ ;
1045
+ if (!xc[0]) {
1046
+ y.s = ROUNDING_MODE == 3 ? -1 : 1;
1047
+ y.c = [y.e = 0];
1048
+ return y;
1049
+ }
1050
+ return normalise(y, xc, ye);
1051
+ };
1052
+ P.modulo = P.mod = function(y, b) {
1053
+ var q, s, x = this;
1054
+ y = new BigNumber2(y, b);
1055
+ if (!x.c || !y.s || y.c && !y.c[0]) {
1056
+ return new BigNumber2(NaN);
1057
+ } else if (!y.c || x.c && !x.c[0]) {
1058
+ return new BigNumber2(x);
1059
+ }
1060
+ if (MODULO_MODE == 9) {
1061
+ s = y.s;
1062
+ y.s = 1;
1063
+ q = div(x, y, 0, 3);
1064
+ y.s = s;
1065
+ q.s *= s;
1066
+ } else {
1067
+ q = div(x, y, 0, MODULO_MODE);
1068
+ }
1069
+ y = x.minus(q.times(y));
1070
+ if (!y.c[0] && MODULO_MODE == 1)
1071
+ y.s = x.s;
1072
+ return y;
1073
+ };
1074
+ P.multipliedBy = P.times = function(y, b) {
1075
+ 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;
1076
+ if (!xc || !yc || !xc[0] || !yc[0]) {
1077
+ if (!x.s || !y.s || xc && !xc[0] && !yc || yc && !yc[0] && !xc) {
1078
+ y.c = y.e = y.s = null;
1079
+ } else {
1080
+ y.s *= x.s;
1081
+ if (!xc || !yc) {
1082
+ y.c = y.e = null;
1083
+ } else {
1084
+ y.c = [0];
1085
+ y.e = 0;
1086
+ }
1087
+ }
1088
+ return y;
1089
+ }
1090
+ e = bitFloor(x.e / LOG_BASE) + bitFloor(y.e / LOG_BASE);
1091
+ y.s *= x.s;
1092
+ xcL = xc.length;
1093
+ ycL = yc.length;
1094
+ if (xcL < ycL) {
1095
+ zc = xc;
1096
+ xc = yc;
1097
+ yc = zc;
1098
+ i = xcL;
1099
+ xcL = ycL;
1100
+ ycL = i;
1101
+ }
1102
+ for (i = xcL + ycL, zc = []; i--; zc.push(0))
1103
+ ;
1104
+ base = BASE;
1105
+ sqrtBase = SQRT_BASE;
1106
+ for (i = ycL; --i >= 0; ) {
1107
+ c = 0;
1108
+ ylo = yc[i] % sqrtBase;
1109
+ yhi = yc[i] / sqrtBase | 0;
1110
+ for (k = xcL, j = i + k; j > i; ) {
1111
+ xlo = xc[--k] % sqrtBase;
1112
+ xhi = xc[k] / sqrtBase | 0;
1113
+ m = yhi * xlo + xhi * ylo;
1114
+ xlo = ylo * xlo + m % sqrtBase * sqrtBase + zc[j] + c;
1115
+ c = (xlo / base | 0) + (m / sqrtBase | 0) + yhi * xhi;
1116
+ zc[j--] = xlo % base;
1117
+ }
1118
+ zc[j] = c;
1119
+ }
1120
+ if (c) {
1121
+ ++e;
1122
+ } else {
1123
+ zc.splice(0, 1);
1124
+ }
1125
+ return normalise(y, zc, e);
1126
+ };
1127
+ P.negated = function() {
1128
+ var x = new BigNumber2(this);
1129
+ x.s = -x.s || null;
1130
+ return x;
1131
+ };
1132
+ P.plus = function(y, b) {
1133
+ var t, x = this, a = x.s;
1134
+ y = new BigNumber2(y, b);
1135
+ b = y.s;
1136
+ if (!a || !b)
1137
+ return new BigNumber2(NaN);
1138
+ if (a != b) {
1139
+ y.s = -b;
1140
+ return x.minus(y);
1141
+ }
1142
+ var xe = x.e / LOG_BASE, ye = y.e / LOG_BASE, xc = x.c, yc = y.c;
1143
+ if (!xe || !ye) {
1144
+ if (!xc || !yc)
1145
+ return new BigNumber2(a / 0);
1146
+ if (!xc[0] || !yc[0])
1147
+ return yc[0] ? y : new BigNumber2(xc[0] ? x : a * 0);
1148
+ }
1149
+ xe = bitFloor(xe);
1150
+ ye = bitFloor(ye);
1151
+ xc = xc.slice();
1152
+ if (a = xe - ye) {
1153
+ if (a > 0) {
1154
+ ye = xe;
1155
+ t = yc;
1156
+ } else {
1157
+ a = -a;
1158
+ t = xc;
1159
+ }
1160
+ t.reverse();
1161
+ for (; a--; t.push(0))
1162
+ ;
1163
+ t.reverse();
1164
+ }
1165
+ a = xc.length;
1166
+ b = yc.length;
1167
+ if (a - b < 0) {
1168
+ t = yc;
1169
+ yc = xc;
1170
+ xc = t;
1171
+ b = a;
1172
+ }
1173
+ for (a = 0; b; ) {
1174
+ a = (xc[--b] = xc[b] + yc[b] + a) / BASE | 0;
1175
+ xc[b] = BASE === xc[b] ? 0 : xc[b] % BASE;
1176
+ }
1177
+ if (a) {
1178
+ xc = [a].concat(xc);
1179
+ ++ye;
1180
+ }
1181
+ return normalise(y, xc, ye);
1182
+ };
1183
+ P.precision = P.sd = function(sd, rm) {
1184
+ var c, n, v, x = this;
1185
+ if (sd != null && sd !== !!sd) {
1186
+ intCheck(sd, 1, MAX);
1187
+ if (rm == null)
1188
+ rm = ROUNDING_MODE;
1189
+ else
1190
+ intCheck(rm, 0, 8);
1191
+ return round(new BigNumber2(x), sd, rm);
1192
+ }
1193
+ if (!(c = x.c))
1194
+ return null;
1195
+ v = c.length - 1;
1196
+ n = v * LOG_BASE + 1;
1197
+ if (v = c[v]) {
1198
+ for (; v % 10 == 0; v /= 10, n--)
1199
+ ;
1200
+ for (v = c[0]; v >= 10; v /= 10, n++)
1201
+ ;
1202
+ }
1203
+ if (sd && x.e + 1 > n)
1204
+ n = x.e + 1;
1205
+ return n;
1206
+ };
1207
+ P.shiftedBy = function(k) {
1208
+ intCheck(k, -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER);
1209
+ return this.times("1e" + k);
1210
+ };
1211
+ P.squareRoot = P.sqrt = function() {
1212
+ 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");
1213
+ if (s !== 1 || !c || !c[0]) {
1214
+ return new BigNumber2(!s || s < 0 && (!c || c[0]) ? NaN : c ? x : 1 / 0);
1215
+ }
1216
+ s = Math.sqrt(+valueOf(x));
1217
+ if (s == 0 || s == 1 / 0) {
1218
+ n = coeffToString(c);
1219
+ if ((n.length + e) % 2 == 0)
1220
+ n += "0";
1221
+ s = Math.sqrt(+n);
1222
+ e = bitFloor((e + 1) / 2) - (e < 0 || e % 2);
1223
+ if (s == 1 / 0) {
1224
+ n = "5e" + e;
1225
+ } else {
1226
+ n = s.toExponential();
1227
+ n = n.slice(0, n.indexOf("e") + 1) + e;
1228
+ }
1229
+ r = new BigNumber2(n);
1230
+ } else {
1231
+ r = new BigNumber2(s + "");
1232
+ }
1233
+ if (r.c[0]) {
1234
+ e = r.e;
1235
+ s = e + dp;
1236
+ if (s < 3)
1237
+ s = 0;
1238
+ for (; ; ) {
1239
+ t = r;
1240
+ r = half.times(t.plus(div(x, t, dp, 1)));
1241
+ if (coeffToString(t.c).slice(0, s) === (n = coeffToString(r.c)).slice(0, s)) {
1242
+ if (r.e < e)
1243
+ --s;
1244
+ n = n.slice(s - 3, s + 1);
1245
+ if (n == "9999" || !rep && n == "4999") {
1246
+ if (!rep) {
1247
+ round(t, t.e + DECIMAL_PLACES + 2, 0);
1248
+ if (t.times(t).eq(x)) {
1249
+ r = t;
1250
+ break;
1251
+ }
1252
+ }
1253
+ dp += 4;
1254
+ s += 4;
1255
+ rep = 1;
1256
+ } else {
1257
+ if (!+n || !+n.slice(1) && n.charAt(0) == "5") {
1258
+ round(r, r.e + DECIMAL_PLACES + 2, 1);
1259
+ m = !r.times(r).eq(x);
1260
+ }
1261
+ break;
1262
+ }
1263
+ }
1264
+ }
1265
+ }
1266
+ return round(r, r.e + DECIMAL_PLACES + 1, ROUNDING_MODE, m);
1267
+ };
1268
+ P.toExponential = function(dp, rm) {
1269
+ if (dp != null) {
1270
+ intCheck(dp, 0, MAX);
1271
+ dp++;
1272
+ }
1273
+ return format(this, dp, rm, 1);
1274
+ };
1275
+ P.toFixed = function(dp, rm) {
1276
+ if (dp != null) {
1277
+ intCheck(dp, 0, MAX);
1278
+ dp = dp + this.e + 1;
1279
+ }
1280
+ return format(this, dp, rm);
1281
+ };
1282
+ P.toFormat = function(dp, rm, format2) {
1283
+ var str, x = this;
1284
+ if (format2 == null) {
1285
+ if (dp != null && rm && typeof rm == "object") {
1286
+ format2 = rm;
1287
+ rm = null;
1288
+ } else if (dp && typeof dp == "object") {
1289
+ format2 = dp;
1290
+ dp = rm = null;
1291
+ } else {
1292
+ format2 = FORMAT;
1293
+ }
1294
+ } else if (typeof format2 != "object") {
1295
+ throw Error(bignumberError + "Argument not an object: " + format2);
1296
+ }
1297
+ str = x.toFixed(dp, rm);
1298
+ if (x.c) {
1299
+ 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;
1300
+ if (g2) {
1301
+ i = g1;
1302
+ g1 = g2;
1303
+ g2 = i;
1304
+ len -= i;
1305
+ }
1306
+ if (g1 > 0 && len > 0) {
1307
+ i = len % g1 || g1;
1308
+ intPart = intDigits.substr(0, i);
1309
+ for (; i < len; i += g1)
1310
+ intPart += groupSeparator + intDigits.substr(i, g1);
1311
+ if (g2 > 0)
1312
+ intPart += groupSeparator + intDigits.slice(i);
1313
+ if (isNeg)
1314
+ intPart = "-" + intPart;
1315
+ }
1316
+ str = fractionPart ? intPart + (format2.decimalSeparator || "") + ((g2 = +format2.fractionGroupSize) ? fractionPart.replace(
1317
+ new RegExp("\\d{" + g2 + "}\\B", "g"),
1318
+ "$&" + (format2.fractionGroupSeparator || "")
1319
+ ) : fractionPart) : intPart;
1320
+ }
1321
+ return (format2.prefix || "") + str + (format2.suffix || "");
1322
+ };
1323
+ P.toFraction = function(md) {
1324
+ var d, d0, d1, d2, e, exp, n, n0, n1, q, r, s, x = this, xc = x.c;
1325
+ if (md != null) {
1326
+ n = new BigNumber2(md);
1327
+ if (!n.isInteger() && (n.c || n.s !== 1) || n.lt(ONE)) {
1328
+ throw Error(bignumberError + "Argument " + (n.isInteger() ? "out of range: " : "not an integer: ") + valueOf(n));
1329
+ }
1330
+ }
1331
+ if (!xc)
1332
+ return new BigNumber2(x);
1333
+ d = new BigNumber2(ONE);
1334
+ n1 = d0 = new BigNumber2(ONE);
1335
+ d1 = n0 = new BigNumber2(ONE);
1336
+ s = coeffToString(xc);
1337
+ e = d.e = s.length - x.e - 1;
1338
+ d.c[0] = POWS_TEN[(exp = e % LOG_BASE) < 0 ? LOG_BASE + exp : exp];
1339
+ md = !md || n.comparedTo(d) > 0 ? e > 0 ? d : n1 : n;
1340
+ exp = MAX_EXP;
1341
+ MAX_EXP = 1 / 0;
1342
+ n = new BigNumber2(s);
1343
+ n0.c[0] = 0;
1344
+ for (; ; ) {
1345
+ q = div(n, d, 0, 1);
1346
+ d2 = d0.plus(q.times(d1));
1347
+ if (d2.comparedTo(md) == 1)
1348
+ break;
1349
+ d0 = d1;
1350
+ d1 = d2;
1351
+ n1 = n0.plus(q.times(d2 = n1));
1352
+ n0 = d2;
1353
+ d = n.minus(q.times(d2 = d));
1354
+ n = d2;
1355
+ }
1356
+ d2 = div(md.minus(d0), d1, 0, 1);
1357
+ n0 = n0.plus(d2.times(n1));
1358
+ d0 = d0.plus(d2.times(d1));
1359
+ n0.s = n1.s = x.s;
1360
+ e = e * 2;
1361
+ r = div(n1, d1, e, ROUNDING_MODE).minus(x).abs().comparedTo(
1362
+ div(n0, d0, e, ROUNDING_MODE).minus(x).abs()
1363
+ ) < 1 ? [n1, d1] : [n0, d0];
1364
+ MAX_EXP = exp;
1365
+ return r;
1366
+ };
1367
+ P.toNumber = function() {
1368
+ return +valueOf(this);
1369
+ };
1370
+ P.toPrecision = function(sd, rm) {
1371
+ if (sd != null)
1372
+ intCheck(sd, 1, MAX);
1373
+ return format(this, sd, rm, 2);
1374
+ };
1375
+ P.toString = function(b) {
1376
+ var str, n = this, s = n.s, e = n.e;
1377
+ if (e === null) {
1378
+ if (s) {
1379
+ str = "Infinity";
1380
+ if (s < 0)
1381
+ str = "-" + str;
1382
+ } else {
1383
+ str = "NaN";
1384
+ }
1385
+ } else {
1386
+ if (b == null) {
1387
+ str = e <= TO_EXP_NEG || e >= TO_EXP_POS ? toExponential(coeffToString(n.c), e) : toFixedPoint(coeffToString(n.c), e, "0");
1388
+ } else if (b === 10 && alphabetHasNormalDecimalDigits) {
1389
+ n = round(new BigNumber2(n), DECIMAL_PLACES + e + 1, ROUNDING_MODE);
1390
+ str = toFixedPoint(coeffToString(n.c), n.e, "0");
1391
+ } else {
1392
+ intCheck(b, 2, ALPHABET.length, "Base");
1393
+ str = convertBase(toFixedPoint(coeffToString(n.c), e, "0"), 10, b, s, true);
1394
+ }
1395
+ if (s < 0 && n.c[0])
1396
+ str = "-" + str;
1397
+ }
1398
+ return str;
1399
+ };
1400
+ P.valueOf = P.toJSON = function() {
1401
+ return valueOf(this);
1402
+ };
1403
+ P._isBigNumber = true;
1404
+ P[Symbol.toStringTag] = "BigNumber";
1405
+ P[Symbol.for("nodejs.util.inspect.custom")] = P.valueOf;
1406
+ if (configObject != null)
1407
+ BigNumber2.set(configObject);
1408
+ return BigNumber2;
1409
+ }
1410
+ function bitFloor(n) {
1411
+ var i = n | 0;
1412
+ return n > 0 || n === i ? i : i - 1;
1413
+ }
1414
+ function coeffToString(a) {
1415
+ var s, z, i = 1, j = a.length, r = a[0] + "";
1416
+ for (; i < j; ) {
1417
+ s = a[i++] + "";
1418
+ z = LOG_BASE - s.length;
1419
+ for (; z--; s = "0" + s)
1420
+ ;
1421
+ r += s;
1422
+ }
1423
+ for (j = r.length; r.charCodeAt(--j) === 48; )
1424
+ ;
1425
+ return r.slice(0, j + 1 || 1);
1426
+ }
1427
+ function compare(x, y) {
1428
+ var a, b, xc = x.c, yc = y.c, i = x.s, j = y.s, k = x.e, l = y.e;
1429
+ if (!i || !j)
1430
+ return null;
1431
+ a = xc && !xc[0];
1432
+ b = yc && !yc[0];
1433
+ if (a || b)
1434
+ return a ? b ? 0 : -j : i;
1435
+ if (i != j)
1436
+ return i;
1437
+ a = i < 0;
1438
+ b = k == l;
1439
+ if (!xc || !yc)
1440
+ return b ? 0 : !xc ^ a ? 1 : -1;
1441
+ if (!b)
1442
+ return k > l ^ a ? 1 : -1;
1443
+ j = (k = xc.length) < (l = yc.length) ? k : l;
1444
+ for (i = 0; i < j; i++)
1445
+ if (xc[i] != yc[i])
1446
+ return xc[i] > yc[i] ^ a ? 1 : -1;
1447
+ return k == l ? 0 : k > l ^ a ? 1 : -1;
1448
+ }
1449
+ function intCheck(n, min, max, name) {
1450
+ if (n < min || n > max || n !== mathfloor(n)) {
1451
+ throw Error(bignumberError + (name || "Argument") + (typeof n == "number" ? n < min || n > max ? " out of range: " : " not an integer: " : " not a primitive number: ") + String(n));
1452
+ }
1453
+ }
1454
+ function isOdd(n) {
1455
+ var k = n.c.length - 1;
1456
+ return bitFloor(n.e / LOG_BASE) == k && n.c[k] % 2 != 0;
1457
+ }
1458
+ function toExponential(str, e) {
1459
+ return (str.length > 1 ? str.charAt(0) + "." + str.slice(1) : str) + (e < 0 ? "e" : "e+") + e;
1460
+ }
1461
+ function toFixedPoint(str, e, z) {
1462
+ var len, zs;
1463
+ if (e < 0) {
1464
+ for (zs = z + "."; ++e; zs += z)
1465
+ ;
1466
+ str = zs + str;
1467
+ } else {
1468
+ len = str.length;
1469
+ if (++e > len) {
1470
+ for (zs = z, e -= len; --e; zs += z)
1471
+ ;
1472
+ str += zs;
1473
+ } else if (e < len) {
1474
+ str = str.slice(0, e) + "." + str.slice(e);
1475
+ }
1476
+ }
1477
+ return str;
1478
+ }
1479
+ var BigNumber = clone();
1480
+ var bignumber_default = BigNumber;
1481
+ var JSONbigParser = JSONbigModule({ storeAsString: false });
1482
+ var JSONbigSerializer = JSONbigModule({ useNativeBigInt: true });
1483
+ var MAX_SAFE = BigInt(Number.MAX_SAFE_INTEGER);
1484
+ var MIN_SAFE = BigInt(Number.MIN_SAFE_INTEGER);
1485
+ function reviver(_key, value) {
1486
+ if (bignumber_default.isBigNumber(value)) {
1487
+ if (value.isInteger()) {
1488
+ const str = value.toFixed();
1489
+ const bi = BigInt(str);
1490
+ if (bi >= MIN_SAFE && bi <= MAX_SAFE) {
1491
+ return Number(str);
1492
+ }
1493
+ return bi;
1494
+ }
1495
+ return value.toNumber();
1496
+ }
1497
+ return value;
1498
+ }
1499
+ var JSONbig = {
1500
+ parse: (text) => JSONbigParser.parse(text, reviver),
1501
+ stringify: JSONbigSerializer.stringify
1502
+ };
6
1503
  var AppwriteException = class extends Error {
7
1504
  constructor(message, code = 0, type = "", response = "") {
8
1505
  super(message);
@@ -14,7 +1511,7 @@ var AppwriteException = class extends Error {
14
1511
  }
15
1512
  };
16
1513
  function getUserAgent() {
17
- let ua = "AppwriteNodeJSSDK/21.1.0";
1514
+ let ua = "AppwriteNodeJSSDK/22.0.0";
18
1515
  const platform = [];
19
1516
  if (typeof process !== "undefined") {
20
1517
  if (typeof process.platform === "string")
@@ -50,7 +1547,7 @@ var _Client = class _Client {
50
1547
  "x-sdk-name": "Node.js",
51
1548
  "x-sdk-platform": "server",
52
1549
  "x-sdk-language": "nodejs",
53
- "x-sdk-version": "21.1.0",
1550
+ "x-sdk-version": "22.0.0",
54
1551
  "user-agent": getUserAgent(),
55
1552
  "X-Appwrite-Response-Format": "1.8.0"
56
1553
  };
@@ -65,6 +1562,9 @@ var _Client = class _Client {
65
1562
  * @returns {this}
66
1563
  */
67
1564
  setEndpoint(endpoint) {
1565
+ if (!endpoint || typeof endpoint !== "string") {
1566
+ throw new AppwriteException("Endpoint must be a valid string");
1567
+ }
68
1568
  if (!endpoint.startsWith("http://") && !endpoint.startsWith("https://")) {
69
1569
  throw new AppwriteException("Invalid endpoint URL: " + endpoint);
70
1570
  }
@@ -194,7 +1694,7 @@ var _Client = class _Client {
194
1694
  } else {
195
1695
  switch (headers["content-type"]) {
196
1696
  case "application/json":
197
- options.body = JSON.stringify(params);
1697
+ options.body = JSONbig.stringify(params);
198
1698
  break;
199
1699
  case "multipart/form-data":
200
1700
  const formData = new FormData();
@@ -276,7 +1776,7 @@ var _Client = class _Client {
276
1776
  warnings.split(";").forEach((warning) => console.warn("Warning: " + warning));
277
1777
  }
278
1778
  if ((_a = response.headers.get("content-type")) == null ? void 0 : _a.includes("application/json")) {
279
- data = await response.json();
1779
+ data = JSONbig.parse(await response.text());
280
1780
  } else if (responseType === "arrayBuffer") {
281
1781
  data = await response.arrayBuffer();
282
1782
  } else {
@@ -287,7 +1787,7 @@ var _Client = class _Client {
287
1787
  if (400 <= response.status) {
288
1788
  let responseText = "";
289
1789
  if (((_b = response.headers.get("content-type")) == null ? void 0 : _b.includes("application/json")) || responseType === "arrayBuffer") {
290
- responseText = JSON.stringify(data);
1790
+ responseText = JSONbig.stringify(data);
291
1791
  } else {
292
1792
  responseText = data == null ? void 0 : data.message;
293
1793
  }