@usync/drive 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1112 -1231
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,1250 +1,1131 @@
|
|
|
1
|
-
import { ensureAccessToken as
|
|
2
|
-
import { XMLParser as
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
var f, s = this;
|
|
539
|
-
if (n == null)
|
|
540
|
-
e != null && t && typeof t == "object" ? (n = t, t = null) : e && typeof e == "object" ? (n = e, e = t = null) : n = oe;
|
|
541
|
-
else if (typeof n != "object")
|
|
542
|
-
throw Error(j + "Argument not an object: " + n);
|
|
543
|
-
if (f = s.toFixed(e, t), s.c) {
|
|
544
|
-
var a, h = f.split("."), i = +n.groupSize, o = +n.secondaryGroupSize, u = n.groupSeparator || "", l = h[0], w = h[1], E = s.s < 0, O = E ? l.slice(1) : l, D = O.length;
|
|
545
|
-
if (o && (a = i, i = o, o = a, D -= a), i > 0 && D > 0) {
|
|
546
|
-
for (a = D % i || i, l = O.substr(0, a); a < D; a += i) l += u + O.substr(a, i);
|
|
547
|
-
o > 0 && (l += u + O.slice(a)), E && (l = "-" + l);
|
|
548
|
-
}
|
|
549
|
-
f = w ? l + (n.decimalSeparator || "") + ((o = +n.fractionGroupSize) ? w.replace(
|
|
550
|
-
new RegExp("\\d{" + o + "}\\B", "g"),
|
|
551
|
-
"$&" + (n.fractionGroupSeparator || "")
|
|
552
|
-
) : w) : l;
|
|
553
|
-
}
|
|
554
|
-
return (n.prefix || "") + f + (n.suffix || "");
|
|
555
|
-
}, c.toFraction = function(e) {
|
|
556
|
-
var t, n, f, s, a, h, i, o, u, l, w, E, O = this, D = O.c;
|
|
557
|
-
if (e != null && (i = new g(e), !i.isInteger() && (i.c || i.s !== 1) || i.lt(y)))
|
|
558
|
-
throw Error(j + "Argument " + (i.isInteger() ? "out of range: " : "not an integer: ") + V(i));
|
|
559
|
-
if (!D) return new g(O);
|
|
560
|
-
for (t = new g(y), u = n = new g(y), f = o = new g(y), E = $(D), a = t.e = E.length - O.e - 1, t.c[0] = de[(h = a % P) < 0 ? P + h : h], e = !e || i.comparedTo(t) > 0 ? a > 0 ? t : u : i, h = I, I = 1 / 0, i = new g(E), o.c[0] = 0; l = r(i, t, 0, 1), s = n.plus(l.times(f)), s.comparedTo(e) != 1; )
|
|
561
|
-
n = f, f = s, u = o.plus(l.times(s = u)), o = s, t = i.minus(l.times(s = t)), i = s;
|
|
562
|
-
return s = r(e.minus(n), f, 0, 1), o = o.plus(s.times(u)), n = n.plus(s.times(f)), o.s = u.s = O.s, a = a * 2, w = r(u, f, a, T).minus(O).abs().comparedTo(
|
|
563
|
-
r(o, n, a, T).minus(O).abs()
|
|
564
|
-
) < 1 ? [u, f] : [o, n], I = h, w;
|
|
565
|
-
}, c.toNumber = function() {
|
|
566
|
-
return +V(this);
|
|
567
|
-
}, c.toPrecision = function(e, t) {
|
|
568
|
-
return e != null && _(e, 1, B), le(this, e, t, 2);
|
|
569
|
-
}, c.toString = function(e) {
|
|
570
|
-
var t, n = this, f = n.s, s = n.e;
|
|
571
|
-
return s === null ? f ? (t = "Infinity", f < 0 && (t = "-" + t)) : t = "NaN" : (e == null ? t = s <= x || s >= S ? ne($(n.c), s) : J($(n.c), s, "0") : e === 10 && ae ? (n = F(new g(n), v + s + 1, T), t = J($(n.c), n.e, "0")) : (_(e, 2, Q.length, "Base"), t = p(J($(n.c), s, "0"), 10, e, f, !0)), f < 0 && n.c[0] && (t = "-" + t)), t;
|
|
572
|
-
}, c.valueOf = c.toJSON = function() {
|
|
573
|
-
return V(this);
|
|
574
|
-
}, c._isBigNumber = !0, c[Symbol.toStringTag] = "BigNumber", c[/* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom")] = c.valueOf, m != null && g.set(m), g;
|
|
1
|
+
import { ensureAccessToken as e, getAuthorizer as t } from "@usync/oauth2";
|
|
2
|
+
import { XMLParser as n } from "fast-xml-parser";
|
|
3
|
+
p();
|
|
4
|
+
//#region ../../node_modules/.pnpm/bignumber.js@11.1.1/node_modules/bignumber.js/dist/bignumber.mjs
|
|
5
|
+
var r = /^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i, i = Math.ceil, a = Math.floor, o = "[BigNumber Error] ", s = 0x5af3107a4000, c = 14, l = 9007199254740991, u = [
|
|
6
|
+
1,
|
|
7
|
+
10,
|
|
8
|
+
100,
|
|
9
|
+
1e3,
|
|
10
|
+
1e4,
|
|
11
|
+
1e5,
|
|
12
|
+
1e6,
|
|
13
|
+
1e7,
|
|
14
|
+
1e8,
|
|
15
|
+
1e9,
|
|
16
|
+
1e10,
|
|
17
|
+
1e11,
|
|
18
|
+
0xe8d4a51000,
|
|
19
|
+
0x9184e72a000
|
|
20
|
+
], d = 1e7, f = 1e9;
|
|
21
|
+
function p(e) {
|
|
22
|
+
var t, n, S = /^(-?)0([xbo])(?=[^.])/i, C = /^-?(Infinity|NaN)$/, w = /^\s*\+(?!-)|^\s+|\s+$/g, T = z.prototype = {
|
|
23
|
+
constructor: z,
|
|
24
|
+
toString: null,
|
|
25
|
+
valueOf: null
|
|
26
|
+
}, E = new z(1), D = 20, O = 4, k = -7, A = 21, j = -1e7, M = 1e7, N = !1, P = !0, F = 1, I = 0, L = {
|
|
27
|
+
prefix: "",
|
|
28
|
+
negativeSign: "-",
|
|
29
|
+
positiveSign: "",
|
|
30
|
+
groupSeparator: ",",
|
|
31
|
+
groupSize: 3,
|
|
32
|
+
secondaryGroupSize: 0,
|
|
33
|
+
decimalSeparator: ".",
|
|
34
|
+
fractionGroupSeparator: "",
|
|
35
|
+
fractionGroupSize: 0,
|
|
36
|
+
suffix: ""
|
|
37
|
+
}, R = "0123456789abcdefghijklmnopqrstuvwxyz";
|
|
38
|
+
function z(e, t) {
|
|
39
|
+
var n, i, a, s, c = this;
|
|
40
|
+
if (!(c instanceof z)) return new z(e, t);
|
|
41
|
+
if (s = typeof e, t == null) {
|
|
42
|
+
if (U(e)) {
|
|
43
|
+
c.s = e.s, !e.c || e.e > M ? c.c = c.e = null : e.e < j ? c.c = [c.e = 0] : (c.e = e.e, c.c = e.c.slice());
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (s == "number") {
|
|
47
|
+
if (e * 0 != 0) {
|
|
48
|
+
c.s = isNaN(e) ? null : e < 0 ? -1 : 1, c.c = c.e = null;
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
if (c.s = 1 / e < 0 ? (e = -e, -1) : 1, e === ~~e) {
|
|
52
|
+
for (n = 0, i = e; i >= 10; i /= 10, n++);
|
|
53
|
+
n > M ? c.c = c.e = null : (c.e = n, c.c = [e]);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
return B(c, String(e));
|
|
57
|
+
}
|
|
58
|
+
if (s == "bigint") return c.s = e < 0 ? (e = -e, -1) : 1, B(c, String(e));
|
|
59
|
+
if (s == "string") a = e;
|
|
60
|
+
else {
|
|
61
|
+
if (P) throw Error(o + "BigNumber, string, number, or BigInt expected: " + e);
|
|
62
|
+
a = String(e);
|
|
63
|
+
}
|
|
64
|
+
if (r.test(a)) return c.s = a.charCodeAt(0) == 45 ? (a = a.slice(1), -1) : 1, B(c, a);
|
|
65
|
+
if (a = a.replace(w, ""), C.test(a)) {
|
|
66
|
+
c.s = isNaN(a) ? null : a < 0 ? -1 : 1, c.c = c.e = null;
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
if (a = a.replace(S, function(e, n, r) {
|
|
70
|
+
return t = (r = r.toLowerCase()) == "x" ? 16 : r == "b" ? 2 : 8, n;
|
|
71
|
+
}), t) return V(c, a, t, e);
|
|
72
|
+
if (a = a.replace(/(\d)_(?=\d)/g, "$1"), r.test(a)) return c.s = a.charCodeAt(0) == 45 ? (a = a.slice(1), -1) : 1, B(c, a);
|
|
73
|
+
if (P) throw Error(o + "Not a number: " + e);
|
|
74
|
+
c.s = c.c = c.e = null;
|
|
75
|
+
} else {
|
|
76
|
+
if (s != "string") {
|
|
77
|
+
if (P) throw Error(o + "String expected: " + e);
|
|
78
|
+
e = String(e);
|
|
79
|
+
}
|
|
80
|
+
_(t, 2, R.length, "Base"), V(c, e.replace(w, ""), t, e);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
z.clone = p, z.ROUND_UP = 0, z.ROUND_DOWN = 1, z.ROUND_CEIL = 2, z.ROUND_FLOOR = 3, z.ROUND_HALF_UP = 4, z.ROUND_HALF_DOWN = 5, z.ROUND_HALF_EVEN = 6, z.ROUND_HALF_CEIL = 7, z.ROUND_HALF_FLOOR = 8, z.EUCLID = 9, z.config = z.set = function(e) {
|
|
84
|
+
var t, n;
|
|
85
|
+
if (e != null) if (typeof e == "object") {
|
|
86
|
+
if (e.hasOwnProperty(t = "DECIMAL_PLACES") && (D = _(e[t], 0, f, t)), e.hasOwnProperty(t = "ROUNDING_MODE") && (O = _(e[t], 0, 8, t)), e.hasOwnProperty(t = "EXPONENTIAL_AT") && (n = e[t], v(n) ? (_(n[0], -f, 0, t), _(n[1], 0, f, t), k = n[0], A = n[1]) : k = -(A = _(n, -f, f, t) < 0 ? -n : n)), e.hasOwnProperty(t = "RANGE")) if (n = e[t], n) v(n) ? (_(n[0], -f, -1, t), _(n[1], 1, f, t), j = n[0], M = n[1]) : j = -(M = _(n, -f, f, t) < 0 ? -n : n);
|
|
87
|
+
else throw Error(o + t + " cannot be zero: " + n);
|
|
88
|
+
if (e.hasOwnProperty(t = "CRYPTO")) if (n = e[t], n === !!n) if (n) if (typeof crypto < "u" && crypto && (crypto.getRandomValues || crypto.randomBytes)) N = n;
|
|
89
|
+
else throw N = !n, Error(o + "crypto unavailable");
|
|
90
|
+
else N = n;
|
|
91
|
+
else throw Error(o + t + " not true or false: " + n);
|
|
92
|
+
if (e.hasOwnProperty(t = "STRICT")) if (n = e[t], n === !!n) P = n;
|
|
93
|
+
else throw Error(o + t + " not true or false: " + n);
|
|
94
|
+
if (e.hasOwnProperty(t = "MODULO_MODE") && (F = _(e[t], 0, 9, t)), e.hasOwnProperty(t = "POW_PRECISION") && (I = _(e[t], 0, f, t)), e.hasOwnProperty(t = "FORMAT")) if (n = e[t], typeof n == "object") for (t in n) n.hasOwnProperty(t) && L.hasOwnProperty(t) && (L[t] = n[t]);
|
|
95
|
+
else throw Error(o + t + " not an object: " + n);
|
|
96
|
+
if (e.hasOwnProperty(t = "ALPHABET")) if (n = e[t], typeof n == "string" && !/^.?$|[+\-.\s]|(.).*\1/.test(n)) R = n;
|
|
97
|
+
else throw Error(o + t + " invalid: " + n);
|
|
98
|
+
} else throw Error(o + "Object expected: " + e);
|
|
99
|
+
return {
|
|
100
|
+
DECIMAL_PLACES: D,
|
|
101
|
+
ROUNDING_MODE: O,
|
|
102
|
+
EXPONENTIAL_AT: [k, A],
|
|
103
|
+
RANGE: [j, M],
|
|
104
|
+
CRYPTO: N,
|
|
105
|
+
STRICT: P,
|
|
106
|
+
MODULO_MODE: F,
|
|
107
|
+
POW_PRECISION: I,
|
|
108
|
+
FORMAT: L,
|
|
109
|
+
ALPHABET: R
|
|
110
|
+
};
|
|
111
|
+
}, z.fromFormat = function(e, t) {
|
|
112
|
+
if (typeof e != "string") throw Error(o + "Not a string: " + e);
|
|
113
|
+
if (t == null) t = L;
|
|
114
|
+
else if (typeof t != "object") throw Error(o + "Argument not an object: " + t);
|
|
115
|
+
else t = K(t);
|
|
116
|
+
var n, r, i, a, s = t.negativeSign || "-", c = t.positiveSign || "", l = t.prefix || "", u = t.suffix || "", d = t.groupSeparator || "", f = t.decimalSeparator || ".", p = t.fractionGroupSeparator || "";
|
|
117
|
+
if (l && e.indexOf(l) === 0 && (e = e.slice(l.length)), u && e.lastIndexOf(u) === e.length - u.length && (e = e.slice(0, -u.length)), s && e.indexOf(s) === 0 ? (e = e.slice(s.length), r = !0) : c && e.indexOf(c) === 0 && (e = e.slice(c.length)), n = e.indexOf(f), n < 0) {
|
|
118
|
+
if (d) for (; e.indexOf(d) > -1;) e = e.replace(d, "");
|
|
119
|
+
} else {
|
|
120
|
+
if (i = e.slice(0, n), a = e.slice(n + f.length), d) for (; i.indexOf(d) > -1;) i = i.replace(d, "");
|
|
121
|
+
if (p) for (; a.indexOf(p) > -1;) a = a.replace(p, "");
|
|
122
|
+
e = i + "." + a;
|
|
123
|
+
}
|
|
124
|
+
return new z(r ? "-" + e : e);
|
|
125
|
+
}, z.isBigNumber = function(e) {
|
|
126
|
+
if (!U(e)) return !1;
|
|
127
|
+
var t, n, r = e.c, i = e.e, o = e.s;
|
|
128
|
+
if (!v(r)) return r === null && i === null && (o === null || o === 1 || o === -1);
|
|
129
|
+
if (o !== 1 && o !== -1 || i < -f || i > f || i !== a(i)) return !1;
|
|
130
|
+
if (r[0] === 0) return i === 0 && r.length === 1;
|
|
131
|
+
if (t = (i + 1) % c, t < 1 && (t += c), String(r[0]).length !== t) return !1;
|
|
132
|
+
for (t = 0; t < r.length; t++) if (n = r[t], n < 0 || n >= s || n !== a(n)) return !1;
|
|
133
|
+
return n !== 0;
|
|
134
|
+
}, z.maximum = z.max = function() {
|
|
135
|
+
return W(arguments, -1);
|
|
136
|
+
}, z.minimum = z.min = function() {
|
|
137
|
+
return W(arguments, 1);
|
|
138
|
+
}, z.random = (function() {
|
|
139
|
+
var e = 9007199254740992, t = Math.random() * e & 2097151 ? function() {
|
|
140
|
+
return a(Math.random() * e);
|
|
141
|
+
} : function() {
|
|
142
|
+
return (Math.random() * 1073741824 | 0) * 8388608 + (Math.random() * 8388608 | 0);
|
|
143
|
+
};
|
|
144
|
+
return function(e) {
|
|
145
|
+
var n, r, s, l, d, p = 0, m = [], h = new z(E);
|
|
146
|
+
if (e = e == null ? D : _(e, 0, f), l = i(e / c), N) if (crypto.getRandomValues) {
|
|
147
|
+
for (n = crypto.getRandomValues(new Uint32Array(l *= 2)); p < l;) d = n[p] * 131072 + (n[p + 1] >>> 11), d >= 9e15 ? (r = crypto.getRandomValues(new Uint32Array(2)), n[p] = r[0], n[p + 1] = r[1]) : (m.push(d % 0x5af3107a4000), p += 2);
|
|
148
|
+
p = l / 2;
|
|
149
|
+
} else if (crypto.randomBytes) {
|
|
150
|
+
for (n = crypto.randomBytes(l *= 7); p < l;) d = (n[p] & 31) * 281474976710656 + n[p + 1] * 1099511627776 + n[p + 2] * 4294967296 + n[p + 3] * 16777216 + (n[p + 4] << 16) + (n[p + 5] << 8) + n[p + 6], d >= 9e15 ? crypto.randomBytes(7).copy(n, p) : (m.push(d % 0x5af3107a4000), p += 7);
|
|
151
|
+
p = l / 7;
|
|
152
|
+
} else throw N = !1, Error(o + "crypto unavailable");
|
|
153
|
+
if (!N) for (; p < l;) d = t(), d < 9e15 && (m[p++] = d % 0x5af3107a4000);
|
|
154
|
+
for (l = m[--p], e %= c, l && e && (d = u[c - e], m[p] = a(l / d) * d); m[p] === 0; m.pop(), p--);
|
|
155
|
+
if (p < 0) m = [s = 0];
|
|
156
|
+
else {
|
|
157
|
+
for (s = -1; m[0] === 0; m.splice(0, 1), s -= c);
|
|
158
|
+
for (p = 1, d = m[0]; d >= 10; d /= 10, p++);
|
|
159
|
+
p < c && (s -= c - p);
|
|
160
|
+
}
|
|
161
|
+
return h.e = s, h.c = m, h;
|
|
162
|
+
};
|
|
163
|
+
})(), z.sum = function() {
|
|
164
|
+
for (var e = 0, t = new z(0); e < arguments.length;) t = t.plus(arguments[e++]);
|
|
165
|
+
return t;
|
|
166
|
+
};
|
|
167
|
+
function B(e, t) {
|
|
168
|
+
var n, r, i;
|
|
169
|
+
for ((n = t.indexOf(".")) > -1 && (t = t.replace(".", "")), (r = t.search(/e/i)) > 0 ? (n < 0 && (n = r), n += +t.slice(r + 1), t = t.substring(0, r)) : n < 0 && (n = t.length), r = 0; t.charCodeAt(r) === 48; r++);
|
|
170
|
+
for (i = t.length; t.charCodeAt(--i) === 48;);
|
|
171
|
+
if (t = t.slice(r, ++i)) if (i -= r, n = n - r - 1, n > M) e.c = e.e = null;
|
|
172
|
+
else if (n < j) e.c = [e.e = 0];
|
|
173
|
+
else {
|
|
174
|
+
if (e.e = n, e.c = [], r = (n + 1) % c, n < 0 && (r += c), r < i) {
|
|
175
|
+
for (r && e.c.push(+t.slice(0, r)), i -= c; r < i;) e.c.push(+t.slice(r, r += c));
|
|
176
|
+
r = c - (t = t.slice(r)).length;
|
|
177
|
+
} else r -= i;
|
|
178
|
+
for (; r--; t += "0");
|
|
179
|
+
e.c.push(+t);
|
|
180
|
+
}
|
|
181
|
+
else e.c = [e.e = 0];
|
|
182
|
+
}
|
|
183
|
+
function V(e, t, r, i) {
|
|
184
|
+
var a, s, c = R.slice(0, r), l = 0, u = "", d = !1, f = !1, p = !1;
|
|
185
|
+
for (e.s = t.charCodeAt(0) === 45 ? (t = t.slice(1), -1) : 1, s = t.length; l < s; l++) {
|
|
186
|
+
if (a = t.charAt(l), c.indexOf(a) >= 0) {
|
|
187
|
+
u += a, f = !0;
|
|
188
|
+
continue;
|
|
189
|
+
}
|
|
190
|
+
if (a == "_") {
|
|
191
|
+
if (f && l + 1 < s) {
|
|
192
|
+
f = !1;
|
|
193
|
+
continue;
|
|
194
|
+
}
|
|
195
|
+
} else if (a == ".") {
|
|
196
|
+
if (l == 0 || !d && f) {
|
|
197
|
+
if (l + 1 == s) break;
|
|
198
|
+
l == 0 && (u = "0"), u += a, d = !0, f = !1;
|
|
199
|
+
continue;
|
|
200
|
+
}
|
|
201
|
+
} else if (!p && (t == t.toUpperCase() && c == c.toLowerCase() && (t = t.toLowerCase()) || t == t.toLowerCase() && c == c.toUpperCase() && (t = t.toUpperCase()))) {
|
|
202
|
+
l = -1, u = "", p = !0, d = f = !1;
|
|
203
|
+
continue;
|
|
204
|
+
}
|
|
205
|
+
if (P) throw Error(o + "Not a base " + r + " number: " + i);
|
|
206
|
+
e.s = e.c = e.e = null;
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
B(e, n(u, r, 10, e.s));
|
|
210
|
+
}
|
|
211
|
+
n = (function() {
|
|
212
|
+
var e = "0123456789";
|
|
213
|
+
function n(e, t, n, r) {
|
|
214
|
+
for (var i, a = [0], o, s = 0, c = e.length; s < c;) {
|
|
215
|
+
for (o = a.length; o--; a[o] *= t);
|
|
216
|
+
for (a[0] += r.indexOf(e.charAt(s++)), i = 0; i < a.length; i++) a[i] > n - 1 && (a[i + 1] ?? (a[i + 1] = 0), a[i + 1] += a[i] / n | 0, a[i] %= n);
|
|
217
|
+
}
|
|
218
|
+
return a.reverse();
|
|
219
|
+
}
|
|
220
|
+
return function(r, i, a, o, s) {
|
|
221
|
+
var c, l, u, d, f, p, m, g, _ = r.indexOf("."), v = D, y = O;
|
|
222
|
+
for (_ >= 0 && (d = I, I = 0, r = r.replace(".", ""), g = new z(i), p = g.pow(r.length - _), I = d, g.c = n(x(h(p.c), p.e, "0"), 10, a, e), g.e = g.c.length), m = n(r, i, a, s ? (c = R, e) : (c = e, R)), u = d = m.length; m[--d] == 0; m.pop());
|
|
223
|
+
if (!m[0]) return c.charAt(0);
|
|
224
|
+
if (_ < 0 ? --u : (p.c = m, p.e = u, p.s = o, p = t(p, g, v, y, a), m = p.c, f = p.r, u = p.e), l = u + v + 1, _ = m[l], d = a / 2, f = f || l < 0 || m[l + 1] != null, f = y < 4 ? (_ != null || f) && (y == 0 || y == (p.s < 0 ? 3 : 2)) : _ > d || _ == d && (y == 4 || f || y == 6 && m[l - 1] & 1 || y == (p.s < 0 ? 8 : 7)), l < 1 || !m[0]) r = f ? x(c.charAt(1), -v, c.charAt(0)) : c.charAt(0);
|
|
225
|
+
else {
|
|
226
|
+
if (l < m.length && (m.length = l), f) for (--a; ++m[--l] > a;) m[l] = 0, l || (++u, m = [1].concat(m));
|
|
227
|
+
for (d = m.length; !m[--d];);
|
|
228
|
+
for (_ = 0, r = ""; _ <= d; r += c.charAt(m[_++]));
|
|
229
|
+
r = x(r, u, c.charAt(0));
|
|
230
|
+
}
|
|
231
|
+
return r;
|
|
232
|
+
};
|
|
233
|
+
})(), t = (function() {
|
|
234
|
+
function e(e, t, n) {
|
|
235
|
+
var r, i, a, o, s = 0, c = e.length, l = t % d, u = t / d | 0;
|
|
236
|
+
for (e = e.slice(); c--;) a = e[c] % d, o = e[c] / d | 0, r = u * a + o * l, i = l * a + r % d * d + s, s = (i / n | 0) + (r / d | 0) + u * o, e[c] = i % n;
|
|
237
|
+
return s && (e = [s].concat(e)), e;
|
|
238
|
+
}
|
|
239
|
+
function t(e, t, n, r) {
|
|
240
|
+
var i, a;
|
|
241
|
+
if (n != r) a = n > r ? 1 : -1;
|
|
242
|
+
else for (i = a = 0; i < n; i++) if (e[i] != t[i]) {
|
|
243
|
+
a = e[i] > t[i] ? 1 : -1;
|
|
244
|
+
break;
|
|
245
|
+
}
|
|
246
|
+
return a;
|
|
247
|
+
}
|
|
248
|
+
function n(e, t, n, r) {
|
|
249
|
+
for (var i = 0; n--;) e[n] -= i, i = +(e[n] < t[n]), e[n] = i * r + e[n] - t[n];
|
|
250
|
+
for (; !e[0] && e.length > 1; e.splice(0, 1));
|
|
251
|
+
}
|
|
252
|
+
return function(r, i, o, l, u) {
|
|
253
|
+
var d, f, p, h, g, _, v, y, b, x, S, C, w, T, E, D, O, k = r.s == i.s ? 1 : -1, A = r.c, j = i.c;
|
|
254
|
+
if (!A || !A[0] || !j || !j[0]) return new z(!r.s || !i.s || (A ? j && A[0] == j[0] : !j) ? NaN : A && A[0] == 0 || !j ? k * 0 : k / 0);
|
|
255
|
+
for (y = new z(k), b = y.c = [], f = r.e - i.e, k = o + f + 1, u || (u = s, f = m(r.e / c) - m(i.e / c), k = k / c | 0), p = 0; j[p] == (A[p] || 0); p++);
|
|
256
|
+
if (j[p] > (A[p] || 0) && f--, k < 0) b.push(1), h = !0;
|
|
257
|
+
else {
|
|
258
|
+
for (T = A.length, D = j.length, p = 0, k += 2, g = a(u / (j[0] + 1)), g > 1 && (j = e(j, g, u), A = e(A, g, u), D = j.length, T = A.length), w = D, x = A.slice(0, D), S = x.length; S < D; x[S++] = 0);
|
|
259
|
+
O = j.slice(), O = [0].concat(O), E = j[0], j[1] >= u / 2 && E++;
|
|
260
|
+
do {
|
|
261
|
+
if (g = 0, d = t(j, x, D, S), d < 0) {
|
|
262
|
+
if (C = x[0], D != S && (C = C * u + (x[1] || 0)), g = a(C / E), g > 1) for (g >= u && (g = u - 1), _ = e(j, g, u), v = _.length, S = x.length; t(_, x, v, S) == 1;) g--, n(_, D < v ? O : j, v, u), v = _.length, d = 1;
|
|
263
|
+
else g == 0 && (d = g = 1), _ = j.slice(), v = _.length;
|
|
264
|
+
if (v < S && (_ = [0].concat(_)), n(x, _, S, u), S = x.length, d == -1) for (; t(j, x, D, S) < 1;) g++, n(x, D < S ? O : j, S, u), S = x.length;
|
|
265
|
+
} else d === 0 && (g++, x = [0]);
|
|
266
|
+
b[p++] = g, x[0] ? x[S++] = A[w] || 0 : (x = [A[w]], S = 1);
|
|
267
|
+
} while ((w++ < T || x[0] != null) && k--);
|
|
268
|
+
h = x[0] != null, b[0] || b.splice(0, 1);
|
|
269
|
+
}
|
|
270
|
+
if (u == s) {
|
|
271
|
+
for (p = 1, k = b[0]; k >= 10; k /= 10, p++);
|
|
272
|
+
q(y, o + (y.e = p + f * c - 1) + 1, l, h);
|
|
273
|
+
} else y.e = f, y.r = +h;
|
|
274
|
+
return y;
|
|
275
|
+
};
|
|
276
|
+
})();
|
|
277
|
+
function H(e, t, n, r) {
|
|
278
|
+
var i, a, o, s, c;
|
|
279
|
+
if (n = n == null ? O : _(n, 0, 8), !e.c) return e.toString();
|
|
280
|
+
if (i = e.c[0], o = e.e, t == null) c = h(e.c), c = r == 1 || r == 2 && (o <= k || o >= A) ? b(c, o) : x(c, o, "0");
|
|
281
|
+
else if (e = q(new z(e), t, n), a = e.e, c = h(e.c), s = c.length, r == 1 || r == 2 && (t <= a || a <= k)) {
|
|
282
|
+
for (; s < t; c += "0", s++);
|
|
283
|
+
c = b(c, a);
|
|
284
|
+
} else if (t -= o + (r === 2 && a > o), c = x(c, a, "0"), a + 1 > s) {
|
|
285
|
+
if (--t > 0) for (c += "."; t--; c += "0");
|
|
286
|
+
} else if (t += a - s, t > 0) for (a + 1 == s && (c += "."); t--; c += "0");
|
|
287
|
+
return e.s < 0 && i ? "-" + c : c;
|
|
288
|
+
}
|
|
289
|
+
function U(e) {
|
|
290
|
+
return e instanceof z || !!e && e._isBigNumber === !0;
|
|
291
|
+
}
|
|
292
|
+
function W(e, t) {
|
|
293
|
+
for (var n, r, i = 1, a = new z(e[0]); i < e.length; i++) r = new z(e[i]), (!r.s || (n = g(a, r)) === t || n === 0 && a.s === t) && (a = r);
|
|
294
|
+
return a;
|
|
295
|
+
}
|
|
296
|
+
function G(e, t, n) {
|
|
297
|
+
for (var r = 1, i = t.length; !t[--i]; t.pop());
|
|
298
|
+
for (i = t[0]; i >= 10; i /= 10, r++);
|
|
299
|
+
return (n = r + n * c - 1) > M ? e.c = e.e = null : n < j ? e.c = [e.e = 0] : (e.e = n, e.c = t), e;
|
|
300
|
+
}
|
|
301
|
+
function K(e) {
|
|
302
|
+
var t, n = {};
|
|
303
|
+
for (t in L) L.hasOwnProperty(t) && (n[t] = e.hasOwnProperty(t) ? e[t] : L[t]);
|
|
304
|
+
return n;
|
|
305
|
+
}
|
|
306
|
+
function q(e, t, n, r) {
|
|
307
|
+
var o, l, d, f, p, m, h, g = e.c, _ = u;
|
|
308
|
+
if (g) {
|
|
309
|
+
out: {
|
|
310
|
+
for (o = 1, f = g[0]; f >= 10; f /= 10, o++);
|
|
311
|
+
if (l = t - o, l < 0) l += c, d = t, p = g[m = 0], h = a(p / _[o - d - 1] % 10);
|
|
312
|
+
else if (m = i((l + 1) / c), m >= g.length) if (r) {
|
|
313
|
+
for (; g.length <= m; g.push(0));
|
|
314
|
+
p = h = 0, o = 1, l %= c, d = l - c + 1;
|
|
315
|
+
} else break out;
|
|
316
|
+
else {
|
|
317
|
+
for (p = f = g[m], o = 1; f >= 10; f /= 10, o++);
|
|
318
|
+
l %= c, d = l - c + o, h = d < 0 ? 0 : a(p / _[o - d - 1] % 10);
|
|
319
|
+
}
|
|
320
|
+
if (r = r || t < 0 || g[m + 1] != null || (d < 0 ? p : p % _[o - d - 1]), r = n < 4 ? (h || r) && (n == 0 || n == (e.s < 0 ? 3 : 2)) : h > 5 || h == 5 && (n == 4 || r || n == 6 && (l > 0 ? d > 0 ? p / _[o - d] : 0 : g[m - 1]) % 10 & 1 || n == (e.s < 0 ? 8 : 7)), t < 1 || !g[0]) return g.length = 0, r ? (t -= e.e + 1, g[0] = _[(c - t % c) % c], e.e = -t || 0) : g[0] = e.e = 0, e;
|
|
321
|
+
if (l == 0 ? (g.length = m, f = 1, m--) : (g.length = m + 1, f = _[c - l], g[m] = d > 0 ? a(p / _[o - d] % _[d]) * f : 0), r) for (;;) if (m == 0) {
|
|
322
|
+
for (l = 1, d = g[0]; d >= 10; d /= 10, l++);
|
|
323
|
+
for (d = g[0] += f, f = 1; d >= 10; d /= 10, f++);
|
|
324
|
+
l != f && (e.e++, g[0] == s && (g[0] = 1));
|
|
325
|
+
break;
|
|
326
|
+
} else {
|
|
327
|
+
if (g[m] += f, g[m] != s) break;
|
|
328
|
+
g[m--] = 0, f = 1;
|
|
329
|
+
}
|
|
330
|
+
for (l = g.length; g[--l] === 0; g.pop());
|
|
331
|
+
}
|
|
332
|
+
e.e > M ? e.c = e.e = null : e.e < j && (e.c = [e.e = 0]);
|
|
333
|
+
}
|
|
334
|
+
return e;
|
|
335
|
+
}
|
|
336
|
+
function J(e) {
|
|
337
|
+
var t, n = e.e;
|
|
338
|
+
return n === null ? e.toString() : (t = h(e.c), t = n <= k || n >= A ? b(t, n) : x(t, n, "0"), e.s < 0 ? "-" + t : t);
|
|
339
|
+
}
|
|
340
|
+
return T.absoluteValue = T.abs = function() {
|
|
341
|
+
var e = new z(this);
|
|
342
|
+
return e.s < 0 && (e.s = 1), e;
|
|
343
|
+
}, T.comparedTo = function(e, t) {
|
|
344
|
+
return g(this, new z(e, t));
|
|
345
|
+
}, T.decimalPlaces = T.dp = function(e, t) {
|
|
346
|
+
var n, r, i, a = this;
|
|
347
|
+
if (e != null) return q(new z(a), _(e, -f, f) + a.e + 1, t == null ? O : _(t, 0, 8));
|
|
348
|
+
if (!(n = a.c)) return null;
|
|
349
|
+
if (r = ((i = n.length - 1) - m(this.e / c)) * c, i = n[i]) for (; i % 10 == 0; i /= 10, r--);
|
|
350
|
+
return r < 0 && (r = 0), r;
|
|
351
|
+
}, T.dividedBy = T.div = function(e, n) {
|
|
352
|
+
return t(this, new z(e, n), D, O);
|
|
353
|
+
}, T.dividedToIntegerBy = T.idiv = function(e, n) {
|
|
354
|
+
return t(this, new z(e, n), 0, 1);
|
|
355
|
+
}, T.exponentiatedBy = T.pow = function(e, t) {
|
|
356
|
+
var n, r, s, l, u, d, f, p, m, h = this;
|
|
357
|
+
if (e = new z(e), e.c && !e.isInteger()) throw Error(o + "Exponent not an integer: " + J(e));
|
|
358
|
+
if (t != null && (t = new z(t)), d = e.e > 14, !h.c || !h.c[0] || h.c[0] == 1 && !h.e && h.c.length == 1 || !e.c || !e.c[0]) return m = new z(J(h) ** (d ? e.s * (2 - y(e)) : +J(e))), t ? m.mod(t) : m;
|
|
359
|
+
if (f = e.s < 0, t) {
|
|
360
|
+
if (t.c ? !t.c[0] : !t.s) return new z(NaN);
|
|
361
|
+
r = !f && h.isInteger() && t.isInteger(), r && (h = h.mod(t));
|
|
362
|
+
} else if (e.e > 9 && (h.e > 0 || h.e < -1 || (h.e == 0 ? h.c[0] > 1 || d && h.c[1] >= 24e7 : h.c[0] < 8e13 || d && h.c[0] <= 9999975e7))) return l = h.s < 0 && y(e) ? -0 : 0, h.e > -1 && (l = 1 / l), new z(f ? 1 / l : l);
|
|
363
|
+
else I && (l = i(I / c + 2));
|
|
364
|
+
for (d ? (n = new z(.5), f && (e.s = 1), p = y(e)) : (s = Math.abs(+J(e)), p = s % 2), m = new z(E);;) {
|
|
365
|
+
if (p) {
|
|
366
|
+
if (m = m.times(h), !m.c) break;
|
|
367
|
+
l ? m.c.length > l && (m.c.length = l) : r && (m = m.mod(t));
|
|
368
|
+
}
|
|
369
|
+
if (s) {
|
|
370
|
+
if (s = a(s / 2), s === 0) break;
|
|
371
|
+
p = s % 2;
|
|
372
|
+
} else if (e = e.times(n), q(e, e.e + 1, 1), e.e > 14) p = y(e);
|
|
373
|
+
else {
|
|
374
|
+
if (s = +J(e), s === 0) break;
|
|
375
|
+
p = s % 2;
|
|
376
|
+
}
|
|
377
|
+
h = h.times(h), l ? h.c && h.c.length > l && (h.c.length = l) : r && (h = h.mod(t));
|
|
378
|
+
}
|
|
379
|
+
return r ? m : (f && (m = E.div(m)), t ? m.mod(t) : l ? q(m, I, O, u) : m);
|
|
380
|
+
}, T.integerValue = function(e) {
|
|
381
|
+
var t = new z(this);
|
|
382
|
+
return q(t, t.e + 1, e == null ? O : _(e, 0, 8));
|
|
383
|
+
}, T.isEqualTo = T.eq = function(e, t) {
|
|
384
|
+
return g(this, new z(e, t)) === 0;
|
|
385
|
+
}, T.isFinite = function() {
|
|
386
|
+
return !!this.c;
|
|
387
|
+
}, T.isGreaterThan = T.gt = function(e, t) {
|
|
388
|
+
return g(this, new z(e, t)) > 0;
|
|
389
|
+
}, T.isGreaterThanOrEqualTo = T.gte = function(e, t) {
|
|
390
|
+
return (t = g(this, new z(e, t))) === 1 || t === 0;
|
|
391
|
+
}, T.isInteger = function() {
|
|
392
|
+
return !!this.c && m(this.e / c) > this.c.length - 2;
|
|
393
|
+
}, T.isLessThan = T.lt = function(e, t) {
|
|
394
|
+
return g(this, new z(e, t)) < 0;
|
|
395
|
+
}, T.isLessThanOrEqualTo = T.lte = function(e, t) {
|
|
396
|
+
return (t = g(this, new z(e, t))) === -1 || t === 0;
|
|
397
|
+
}, T.isNaN = function() {
|
|
398
|
+
return !this.s;
|
|
399
|
+
}, T.isNegative = function() {
|
|
400
|
+
return this.s < 0;
|
|
401
|
+
}, T.isPositive = function() {
|
|
402
|
+
return this.s > 0;
|
|
403
|
+
}, T.isZero = function() {
|
|
404
|
+
return !!this.c && this.c[0] == 0;
|
|
405
|
+
}, T.minus = function(e, t) {
|
|
406
|
+
var n, r, i, a, o = this, l = o.s;
|
|
407
|
+
if (e = new z(e, t), t = e.s, !l || !t) return new z(NaN);
|
|
408
|
+
if (l != t) return e.s = -t, o.plus(e);
|
|
409
|
+
var u = o.e / c, d = e.e / c, f = o.c, p = e.c;
|
|
410
|
+
if (!u || !d) {
|
|
411
|
+
if (!f || !p) return f ? (e.s = -t, e) : new z(p ? o : NaN);
|
|
412
|
+
if (!f[0] || !p[0]) return p[0] ? (e.s = -t, e) : new z(f[0] ? o : O == 3 ? -0 : 0);
|
|
413
|
+
}
|
|
414
|
+
if (u = m(u), d = m(d), f = f.slice(), l = u - d) {
|
|
415
|
+
for ((a = l < 0) ? (l = -l, i = f) : (d = u, i = p), i.reverse(), t = l; t--; i.push(0));
|
|
416
|
+
i.reverse();
|
|
417
|
+
} else for (r = (a = (l = f.length) < (t = p.length)) ? l : t, l = t = 0; t < r; t++) if (f[t] != p[t]) {
|
|
418
|
+
a = f[t] < p[t];
|
|
419
|
+
break;
|
|
420
|
+
}
|
|
421
|
+
if (a && (i = f, f = p, p = i, e.s = -e.s), t = (r = p.length) - (n = f.length), t > 0) for (; t--; f[n++] = 0);
|
|
422
|
+
for (t = s - 1; r > l;) {
|
|
423
|
+
if (f[--r] < p[r]) {
|
|
424
|
+
for (n = r; n && !f[--n]; f[n] = t);
|
|
425
|
+
--f[n], f[r] += s;
|
|
426
|
+
}
|
|
427
|
+
f[r] -= p[r];
|
|
428
|
+
}
|
|
429
|
+
for (; f[0] == 0; f.splice(0, 1), --d);
|
|
430
|
+
return f[0] ? G(e, f, d) : (e.s = O == 3 ? -1 : 1, e.c = [e.e = 0], e);
|
|
431
|
+
}, T.modulo = T.mod = function(e, n) {
|
|
432
|
+
var r, i, a = this;
|
|
433
|
+
return e = new z(e, n), !a.c || !e.s || e.c && !e.c[0] ? new z(NaN) : !e.c || a.c && !a.c[0] ? new z(a) : (F == 9 ? (i = e.s, e.s = 1, r = t(a, e, 0, 3), e.s = i, r.s *= i) : r = t(a, e, 0, F), e = a.minus(r.times(e)), !e.c[0] && F == 1 && (e.s = a.s), e);
|
|
434
|
+
}, T.multipliedBy = T.times = function(e, t) {
|
|
435
|
+
var n, r, i, a, o, l, u, f, p, h, g, _, v, y, b, x = this, S = x.c, C = (e = new z(e, t)).c;
|
|
436
|
+
if (!S || !C || !S[0] || !C[0]) return !x.s || !e.s || S && !S[0] && !C || C && !C[0] && !S ? e.c = e.e = e.s = null : (e.s *= x.s, !S || !C ? e.c = e.e = null : (e.c = [0], e.e = 0)), e;
|
|
437
|
+
for (r = m(x.e / c) + m(e.e / c), e.s *= x.s, u = S.length, h = C.length, u < h && (v = S, S = C, C = v, i = u, u = h, h = i), i = u + h, v = []; i--; v.push(0));
|
|
438
|
+
for (y = s, b = d, i = h; --i >= 0;) {
|
|
439
|
+
for (n = 0, g = C[i] % b, _ = C[i] / b | 0, o = u, a = i + o; a > i;) f = S[--o] % b, p = S[o] / b | 0, l = _ * f + p * g, f = g * f + l % b * b + v[a] + n, n = (f / y | 0) + (l / b | 0) + _ * p, v[a--] = f % y;
|
|
440
|
+
v[a] = n;
|
|
441
|
+
}
|
|
442
|
+
return n ? ++r : v.splice(0, 1), G(e, v, r);
|
|
443
|
+
}, T.negated = function() {
|
|
444
|
+
var e = new z(this);
|
|
445
|
+
return e.s = -e.s || null, e;
|
|
446
|
+
}, T.plus = function(e, t) {
|
|
447
|
+
var n, r = this, i = r.s;
|
|
448
|
+
if (e = new z(e, t), t = e.s, !i || !t) return new z(NaN);
|
|
449
|
+
if (i != t) return e.s = -t, r.minus(e);
|
|
450
|
+
var a = r.e / c, o = e.e / c, l = r.c, u = e.c;
|
|
451
|
+
if (!a || !o) {
|
|
452
|
+
if (!l || !u) return new z(i / 0);
|
|
453
|
+
if (!l[0] || !u[0]) return u[0] ? e : new z(l[0] ? r : i * 0);
|
|
454
|
+
}
|
|
455
|
+
if (a = m(a), o = m(o), l = l.slice(), i = a - o) {
|
|
456
|
+
for (i > 0 ? (o = a, n = u) : (i = -i, n = l), n.reverse(); i--; n.push(0));
|
|
457
|
+
n.reverse();
|
|
458
|
+
}
|
|
459
|
+
for (i = l.length, t = u.length, i - t < 0 && (n = u, u = l, l = n, t = i), i = 0; t;) i = (l[--t] = l[t] + u[t] + i) / s | 0, l[t] = s === l[t] ? 0 : l[t] % s;
|
|
460
|
+
return i && (l = [i].concat(l), ++o), G(e, l, o);
|
|
461
|
+
}, T.precision = T.sd = function(e, t) {
|
|
462
|
+
var n, r, i, a = this;
|
|
463
|
+
if (e != null && e !== !!e) return q(new z(a), _(e, 1, f), t == null ? O : _(t, 0, 8));
|
|
464
|
+
if (!(n = a.c)) return null;
|
|
465
|
+
if (i = n.length - 1, r = i * c + 1, i = n[i]) {
|
|
466
|
+
for (; i % 10 == 0; i /= 10, r--);
|
|
467
|
+
for (i = n[0]; i >= 10; i /= 10, r++);
|
|
468
|
+
}
|
|
469
|
+
return e && a.e + 1 > r && (r = a.e + 1), r;
|
|
470
|
+
}, T.shiftedBy = function(e) {
|
|
471
|
+
return this.times("1e" + _(e, -l, l));
|
|
472
|
+
}, T.squareRoot = T.sqrt = function() {
|
|
473
|
+
var e, n, r, i, a, o = this, s = o.c, c = o.s, l = o.e, u = D + 4, d = new z("0.5");
|
|
474
|
+
if (c !== 1 || !s || !s[0]) return new z(!c || c < 0 && (!s || s[0]) ? NaN : s ? o : Infinity);
|
|
475
|
+
if (c = Math.sqrt(+J(o)), c == 0 || c == Infinity ? (n = h(s), (n.length + l) % 2 == 0 && (n += "0"), c = Math.sqrt(+n), l = m((l + 1) / 2) - (l < 0 || l % 2), c == Infinity ? n = "5e" + l : (n = c.toExponential(), n = n.slice(0, n.indexOf("e") + 1) + l), r = new z(n)) : r = new z(c + ""), r.c[0]) {
|
|
476
|
+
for (l = r.e, c = l + u, c < 3 && (c = 0);;) if (a = r, r = d.times(a.plus(t(o, a, u, 1))), h(a.c).slice(0, c) === (n = h(r.c)).slice(0, c)) if (r.e < l && --c, n = n.slice(c - 3, c + 1), n == "9999" || !i && n == "4999") {
|
|
477
|
+
if (!i && (q(a, a.e + D + 2, 0), a.times(a).eq(o))) {
|
|
478
|
+
r = a;
|
|
479
|
+
break;
|
|
480
|
+
}
|
|
481
|
+
u += 4, c += 4, i = 1;
|
|
482
|
+
} else {
|
|
483
|
+
(!+n || !+n.slice(1) && n.charAt(0) == "5") && (q(r, r.e + D + 2, 1), e = !r.times(r).eq(o));
|
|
484
|
+
break;
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
return q(r, r.e + D + 1, O, e);
|
|
488
|
+
}, typeof BigInt == "function" && (T.toBigInt = function(e) {
|
|
489
|
+
var t = this;
|
|
490
|
+
return t.c ? BigInt(H(t, t.e + 1, e)) : null;
|
|
491
|
+
}), T.toExponential = function(e, t) {
|
|
492
|
+
return H(this, e == null ? e : _(e, 0, f) + 1, t, 1);
|
|
493
|
+
}, T.toFixed = function(e, t) {
|
|
494
|
+
return H(this, e == null ? e : _(e, -f, f) + this.e + 1, t);
|
|
495
|
+
}, T.toFormat = function(e, t, n) {
|
|
496
|
+
var r, i, a, s = this;
|
|
497
|
+
if (n == null) n = L, e != null && (t == null ? typeof e == "object" && !v(e) && (n = K(e), e = t = null) : typeof t == "object" && (n = K(t), t = null));
|
|
498
|
+
else if (typeof n != "object") throw Error(o + "Argument not an object: " + n);
|
|
499
|
+
else n = K(n);
|
|
500
|
+
if (e != null) if (v(e) && e.length <= 2) {
|
|
501
|
+
if (r = e[0], i = e[1], e = s.dp(), i != null && e > _(i, 0, f) && (e = i), r != null && _(r, 0, f) !== 0) {
|
|
502
|
+
if (i != null && r > i) throw Error(o + "Minimum must not exceed maximum");
|
|
503
|
+
e < r && (e = r);
|
|
504
|
+
}
|
|
505
|
+
} else _(e, -f, f);
|
|
506
|
+
if (a = s.toFixed(e, t), s.s < 0 && (a = a.slice(1)), s.c) {
|
|
507
|
+
var c, l = a.split("."), u = +n.groupSize, d = +n.secondaryGroupSize, p = n.groupSeparator || "", m = l[0], h = l[1], g = m.length;
|
|
508
|
+
if (d && (c = u, u = d, d = c, g -= c), u > 0 && g > 0) {
|
|
509
|
+
for (c = g % u || u, a = m.substr(0, c); c < g; c += u) a += p + m.substr(c, u);
|
|
510
|
+
d > 0 && (a += p + m.slice(c));
|
|
511
|
+
}
|
|
512
|
+
h && (c = +n.fractionGroupSize, c && (h = h.replace(RegExp("\\d{" + c + "}\\B", "g"), "$&" + (n.fractionGroupSeparator || ""))), a += (n.decimalSeparator || "") + h);
|
|
513
|
+
}
|
|
514
|
+
return (n.prefix || "") + (s.s < 0 ? n.negativeSign || "" : s.s > 0 && n.positiveSign || "") + a + (n.suffix || "");
|
|
515
|
+
}, T.toFraction = function(e) {
|
|
516
|
+
var n, r, i, a, s, l, d, f, p, m, g, _, v = this, y = v.c;
|
|
517
|
+
if (e != null && (d = new z(e), !d.isInteger() && (d.c || d.s !== 1) || d.lt(E))) throw Error(o + "Argument " + (d.isInteger() ? "out of range: " : "not an integer: ") + J(d));
|
|
518
|
+
if (!y) return [new z(v.s || 0), new z(0)];
|
|
519
|
+
for (n = new z(E), p = r = new z(E), i = f = new z(E), _ = h(y), s = n.e = _.length - v.e - 1, n.c[0] = u[(l = s % c) < 0 ? c + l : l], e = !e || d.comparedTo(n) > 0 ? s > 0 ? n : p : d, l = M, M = Infinity, d = new z(_), f.c[0] = 0; m = t(d, n, 0, 1), a = r.plus(m.times(i)), a.comparedTo(e) != 1;) r = i, i = a, p = f.plus(m.times(a = p)), f = a, n = d.minus(m.times(a = n)), d = a;
|
|
520
|
+
return a = t(e.minus(r), i, 0, 1), f = f.plus(a.times(p)), r = r.plus(a.times(i)), f.s = p.s = v.s, s *= 2, g = t(p, i, s, O).minus(v).abs().comparedTo(t(f, r, s, O).minus(v).abs()) < 1 ? [p, i] : [f, r], M = l, g;
|
|
521
|
+
}, T.toNumber = function() {
|
|
522
|
+
return +J(this);
|
|
523
|
+
}, T.toObject = function() {
|
|
524
|
+
var e = this;
|
|
525
|
+
return {
|
|
526
|
+
c: e.c ? e.c.slice() : null,
|
|
527
|
+
e: e.e,
|
|
528
|
+
s: e.s
|
|
529
|
+
};
|
|
530
|
+
}, T.toPrecision = function(e, t) {
|
|
531
|
+
return H(this, e == null ? e : _(e, 1, f), t, 2);
|
|
532
|
+
}, T.toString = function(e) {
|
|
533
|
+
var t, r = this, i = r.s, a = r.e;
|
|
534
|
+
return a === null ? i ? (t = "Infinity", i < 0 && (t = "-" + t)) : t = "NaN" : (e == null ? t = a <= k || a >= A ? b(h(r.c), a) : x(h(r.c), a, "0") : (_(e, 2, R.length, "Base"), t = n(x(h(r.c), a, "0"), 10, e, i, !0)), i < 0 && r.c[0] && (t = "-" + t)), t;
|
|
535
|
+
}, T.valueOf = T.toJSON = function() {
|
|
536
|
+
return J(this);
|
|
537
|
+
}, T._isBigNumber = !0, e != null && z.set(e), z;
|
|
575
538
|
}
|
|
576
|
-
function
|
|
577
|
-
|
|
578
|
-
|
|
539
|
+
function m(e) {
|
|
540
|
+
var t = e | 0;
|
|
541
|
+
return e > 0 || e === t ? t : t - 1;
|
|
579
542
|
}
|
|
580
|
-
function
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
543
|
+
function h(e) {
|
|
544
|
+
for (var t, n, r = 1, i = e.length, a = e[0] + ""; r < i;) {
|
|
545
|
+
for (t = e[r++] + "", n = c - t.length; n--; t = "0" + t);
|
|
546
|
+
a += t;
|
|
547
|
+
}
|
|
548
|
+
for (i = a.length; a.charCodeAt(--i) === 48;);
|
|
549
|
+
return a.slice(0, i + 1 || 1);
|
|
587
550
|
}
|
|
588
|
-
function
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
551
|
+
function g(e, t) {
|
|
552
|
+
var n, r, i = e.c, a = t.c, o = e.s, s = t.s, c = e.e, l = t.e;
|
|
553
|
+
if (!o || !s) return null;
|
|
554
|
+
if (n = i && !i[0], r = a && !a[0], n || r) return n ? r ? 0 : -s : o;
|
|
555
|
+
if (o != s) return o;
|
|
556
|
+
if (n = o < 0, r = c == l, !i || !a) return r ? 0 : !i ^ n ? 1 : -1;
|
|
557
|
+
if (!r) return c > l ^ n ? 1 : -1;
|
|
558
|
+
for (s = (c = i.length) < (l = a.length) ? c : l, o = 0; o < s; o++) if (i[o] != a[o]) return i[o] > a[o] ^ n ? 1 : -1;
|
|
559
|
+
return c == l ? 0 : c > l ^ n ? 1 : -1;
|
|
597
560
|
}
|
|
598
|
-
function _(
|
|
599
|
-
|
|
600
|
-
|
|
561
|
+
function _(e, t, n, r) {
|
|
562
|
+
if (e < t || e > n || e !== a(e)) throw Error(o + (r || "Argument") + (typeof e == "number" ? e < t || e > n ? " out of range: " : " not an integer: " : " not a primitive number: ") + String(e));
|
|
563
|
+
return e;
|
|
601
564
|
}
|
|
602
|
-
function
|
|
603
|
-
|
|
604
|
-
return W(m.e / P) == r && m.c[r] % 2 != 0;
|
|
565
|
+
function v(e) {
|
|
566
|
+
return {}.toString.call(e) == "[object Array]";
|
|
605
567
|
}
|
|
606
|
-
function
|
|
607
|
-
|
|
568
|
+
function y(e) {
|
|
569
|
+
var t = e.c.length - 1;
|
|
570
|
+
return m(e.e / c) == t && e.c[t] % 2 != 0;
|
|
608
571
|
}
|
|
609
|
-
function
|
|
610
|
-
|
|
611
|
-
if (r < 0) {
|
|
612
|
-
for (c = p + "."; ++r; c += p) ;
|
|
613
|
-
m = c + m;
|
|
614
|
-
} else if (d = m.length, ++r > d) {
|
|
615
|
-
for (c = p, r -= d; --r; c += p) ;
|
|
616
|
-
m += c;
|
|
617
|
-
} else r < d && (m = m.slice(0, r) + "." + m.slice(r));
|
|
618
|
-
return m;
|
|
572
|
+
function b(e, t) {
|
|
573
|
+
return (e.length > 1 ? e.charAt(0) + "." + e.slice(1) : e) + (t < 0 ? "e" : "e+") + t;
|
|
619
574
|
}
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
d += r[T & 63];
|
|
631
|
-
}
|
|
632
|
-
return d;
|
|
575
|
+
function x(e, t, n) {
|
|
576
|
+
var r, i;
|
|
577
|
+
if (t < 0) {
|
|
578
|
+
for (i = n + "."; ++t; i += n);
|
|
579
|
+
e = i + e;
|
|
580
|
+
} else if (r = e.length, ++t > r) {
|
|
581
|
+
for (i = n, t -= r; --t; i += n);
|
|
582
|
+
e += i;
|
|
583
|
+
} else t < r && (e = e.slice(0, t) + "." + e.slice(t));
|
|
584
|
+
return e;
|
|
633
585
|
}
|
|
634
|
-
|
|
635
|
-
|
|
586
|
+
//#endregion
|
|
587
|
+
//#region ../../node_modules/.pnpm/@gera2ld+common@0.0.5/node_modules/@gera2ld/common/dist/index.js
|
|
588
|
+
var S = "=", C = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
589
|
+
function w(e, t, n) {
|
|
590
|
+
let r = "", i = 0;
|
|
591
|
+
for (; i < e.length;) {
|
|
592
|
+
let a = e[i++], o = e[i++], s = e[i++];
|
|
593
|
+
if (r += t[a >> 2], r += t[(a & 3) << 4 | (o || 0) >> 4], o == null ? n && (r += S) : r += t[(o & 15) << 2 | (s || 0) >> 6], s == null) {
|
|
594
|
+
n && (r += S);
|
|
595
|
+
break;
|
|
596
|
+
}
|
|
597
|
+
r += t[s & 63];
|
|
598
|
+
}
|
|
599
|
+
return r;
|
|
636
600
|
}
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
super(r, { cause: c }), this.request = p, this.response = d;
|
|
640
|
-
}
|
|
601
|
+
function T(e) {
|
|
602
|
+
return w(e, C, !0);
|
|
641
603
|
}
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
b.statusText,
|
|
661
|
-
{
|
|
662
|
-
url: S.toString(),
|
|
663
|
-
method: y.method || "GET",
|
|
664
|
-
options: r,
|
|
665
|
-
data: M
|
|
666
|
-
},
|
|
667
|
-
b
|
|
668
|
-
);
|
|
669
|
-
return M;
|
|
670
|
-
} catch (M) {
|
|
671
|
-
throw M instanceof ie ? M : new ie(
|
|
672
|
-
M?.message || `${M}`,
|
|
673
|
-
{
|
|
674
|
-
url: S.toString(),
|
|
675
|
-
method: y.method || "GET",
|
|
676
|
-
options: r
|
|
677
|
-
},
|
|
678
|
-
b,
|
|
679
|
-
M
|
|
680
|
-
);
|
|
681
|
-
} finally {
|
|
682
|
-
T && clearTimeout(T);
|
|
683
|
-
}
|
|
684
|
-
}
|
|
685
|
-
return {
|
|
686
|
-
async arrayBuffer() {
|
|
687
|
-
return L((I) => I.arrayBuffer());
|
|
688
|
-
},
|
|
689
|
-
async blob() {
|
|
690
|
-
return L((I) => I.blob());
|
|
691
|
-
},
|
|
692
|
-
async json() {
|
|
693
|
-
return x.has("accept") || x.set("accept", "application/json"), L((I) => I.json());
|
|
694
|
-
},
|
|
695
|
-
async text() {
|
|
696
|
-
return L((I) => I.text());
|
|
697
|
-
},
|
|
698
|
-
abort() {
|
|
699
|
-
v.abort();
|
|
700
|
-
}
|
|
701
|
-
};
|
|
702
|
-
}
|
|
703
|
-
function Se(m) {
|
|
704
|
-
return new Promise((r) => setTimeout(r, m));
|
|
705
|
-
}
|
|
706
|
-
function Ee(m) {
|
|
707
|
-
let r = 0;
|
|
708
|
-
return async (p, d) => {
|
|
709
|
-
let c = r, y;
|
|
710
|
-
for (let v = 5; v > 0; v -= 1) {
|
|
711
|
-
await Se(c);
|
|
712
|
-
try {
|
|
713
|
-
const T = await m(p, d);
|
|
714
|
-
return r >>= 1, T;
|
|
715
|
-
} catch (T) {
|
|
716
|
-
if (y = T, T instanceof ie && T.response?.status === 429) {
|
|
717
|
-
const x = T.response.headers.get("retry-after"), S = x && (isNaN(+x) ? new Date(x).getTime() - Date.now() : +x * 1e3);
|
|
718
|
-
S ? c = S : (c = Math.max(1e3, c * 2), r = c);
|
|
719
|
-
} else
|
|
720
|
-
break;
|
|
721
|
-
}
|
|
722
|
-
}
|
|
723
|
-
throw y;
|
|
724
|
-
};
|
|
725
|
-
}
|
|
726
|
-
function Ie(m, r) {
|
|
727
|
-
if (!m) throw new Error("Invalid authorizer");
|
|
728
|
-
return (p) => async (d, c) => {
|
|
729
|
-
const { headers: y, ...v } = c, T = new Headers(y), x = await Te(m, r);
|
|
730
|
-
return T.set("authorization", `Bearer ${x}`), await p(d, {
|
|
731
|
-
...v,
|
|
732
|
-
headers: T
|
|
733
|
-
});
|
|
734
|
-
};
|
|
735
|
-
}
|
|
736
|
-
class _e {
|
|
737
|
-
}
|
|
738
|
-
class se extends _e {
|
|
739
|
-
constructor(r, p) {
|
|
740
|
-
super(), this.authConfig = r, this.context = p, this.request = this.initRequest();
|
|
741
|
-
}
|
|
742
|
-
initRequest() {
|
|
743
|
-
let r = async (c, y) => {
|
|
744
|
-
const { responseType: v, ...T } = y;
|
|
745
|
-
return await ve(new URL(c, this.baseUrl), T)[v]();
|
|
746
|
-
};
|
|
747
|
-
const { authorizer: p, handleOAuth2: d } = this.context;
|
|
748
|
-
return r = Ie(
|
|
749
|
-
p,
|
|
750
|
-
d
|
|
751
|
-
)(r), r = Ee(r), r;
|
|
752
|
-
}
|
|
753
|
-
async getAccount() {
|
|
754
|
-
throw new Error("Not implemented");
|
|
755
|
-
}
|
|
756
|
-
}
|
|
757
|
-
function qe(m, r) {
|
|
758
|
-
return typeof r == "string" ? r.replace(/[^\x00-\x7F]/g, function(p) {
|
|
759
|
-
return "\\u" + p.codePointAt(0).toString(16).padStart(4, "0");
|
|
760
|
-
}) : r;
|
|
604
|
+
new Uint8Array([13, 10]);
|
|
605
|
+
var E = class extends Error {
|
|
606
|
+
constructor(e, t, n, r) {
|
|
607
|
+
super(e, { cause: r }), this.request = t, this.response = n;
|
|
608
|
+
}
|
|
609
|
+
};
|
|
610
|
+
function D(e) {
|
|
611
|
+
let t = new URLSearchParams();
|
|
612
|
+
return Array.isArray(e) || e instanceof URLSearchParams ? new URLSearchParams(e).forEach((e, n) => {
|
|
613
|
+
t.append(n, e);
|
|
614
|
+
}) : e && Object.entries(e).forEach(([e, n]) => {
|
|
615
|
+
if (Array.isArray(n)) {
|
|
616
|
+
let r = e.endsWith("[]") ? e : `${e}[]`;
|
|
617
|
+
n.forEach((e) => {
|
|
618
|
+
t.append(r, e);
|
|
619
|
+
});
|
|
620
|
+
} else t.append(e, n);
|
|
621
|
+
}), t;
|
|
761
622
|
}
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
const p = this.getDropboxPath(r, !1), d = await this.request(
|
|
810
|
-
"https://api.dropboxapi.com/2/files/get_metadata",
|
|
811
|
-
{
|
|
812
|
-
method: "POST",
|
|
813
|
-
json: {
|
|
814
|
-
path: p
|
|
815
|
-
},
|
|
816
|
-
responseType: "json"
|
|
817
|
-
}
|
|
818
|
-
);
|
|
819
|
-
return this.normalizeEntry(d);
|
|
820
|
-
}
|
|
821
|
-
async *list(r) {
|
|
822
|
-
const p = r ? this.getDropboxPath(r, !0) : "";
|
|
823
|
-
let d = await this.request("https://api.dropboxapi.com/2/files/list_folder", {
|
|
824
|
-
method: "POST",
|
|
825
|
-
json: {
|
|
826
|
-
path: p
|
|
827
|
-
},
|
|
828
|
-
responseType: "json"
|
|
829
|
-
});
|
|
830
|
-
for (yield d.entries.map((c) => this.normalizeEntry(c)); d.has_more; )
|
|
831
|
-
d = await this.request(
|
|
832
|
-
"https://api.dropboxapi.com/2/files/list_folder/continue",
|
|
833
|
-
{
|
|
834
|
-
method: "POST",
|
|
835
|
-
json: {
|
|
836
|
-
cursor: d.cursor
|
|
837
|
-
},
|
|
838
|
-
responseType: "json"
|
|
839
|
-
}
|
|
840
|
-
), yield d.entries.map((c) => this.normalizeEntry(c));
|
|
841
|
-
}
|
|
842
|
-
get(r) {
|
|
843
|
-
const p = this.getDropboxPath(r, !1);
|
|
844
|
-
return this.request(
|
|
845
|
-
"https://content.dropboxapi.com/2/files/download",
|
|
846
|
-
{
|
|
847
|
-
method: "POST",
|
|
848
|
-
headers: {
|
|
849
|
-
"Dropbox-API-Arg": JSON.stringify({
|
|
850
|
-
path: p
|
|
851
|
-
})
|
|
852
|
-
},
|
|
853
|
-
responseType: "blob"
|
|
854
|
-
}
|
|
855
|
-
);
|
|
856
|
-
}
|
|
857
|
-
async remove(r) {
|
|
858
|
-
const p = this.getDropboxPath(r, !1);
|
|
859
|
-
await this.request("https://api.dropboxapi.com/2/files/delete", {
|
|
860
|
-
method: "POST",
|
|
861
|
-
json: {
|
|
862
|
-
path: p
|
|
863
|
-
},
|
|
864
|
-
responseType: "json"
|
|
865
|
-
});
|
|
866
|
-
}
|
|
867
|
-
async put(r, p) {
|
|
868
|
-
const d = r.name && !r.id ? [this.getDropboxPath(r.parent, !0), r.name].filter(Boolean).join("/") : this.getDropboxPath(r, !0);
|
|
869
|
-
if (!d) throw new Error("Invalid path");
|
|
870
|
-
const c = await this.request(
|
|
871
|
-
"https://content.dropboxapi.com/2/files/upload",
|
|
872
|
-
{
|
|
873
|
-
method: "POST",
|
|
874
|
-
headers: {
|
|
875
|
-
"Dropbox-API-Arg": JSON.stringify(
|
|
876
|
-
{
|
|
877
|
-
path: d,
|
|
878
|
-
mode: "overwrite"
|
|
879
|
-
},
|
|
880
|
-
qe
|
|
881
|
-
),
|
|
882
|
-
"Content-Type": "application/octet-stream"
|
|
883
|
-
},
|
|
884
|
-
body: p,
|
|
885
|
-
responseType: "json"
|
|
886
|
-
}
|
|
887
|
-
);
|
|
888
|
-
return this.normalizeEntry({
|
|
889
|
-
...c,
|
|
890
|
-
".tag": "file"
|
|
891
|
-
});
|
|
892
|
-
}
|
|
623
|
+
function O(e, t) {
|
|
624
|
+
let { json: n, timeout: r = 1e4, searchParams: i, ...a } = t || {}, o = new AbortController(), s = r ? setTimeout(() => o.abort(), r) : null, c = new Headers(a.headers);
|
|
625
|
+
n != null && (a.body = JSON.stringify(n), c.set("content-type", "application/json"));
|
|
626
|
+
let l = new URL(e);
|
|
627
|
+
i && (l.search = D(i).toString());
|
|
628
|
+
async function u(e) {
|
|
629
|
+
let n;
|
|
630
|
+
try {
|
|
631
|
+
n = await fetch(l, {
|
|
632
|
+
...a,
|
|
633
|
+
headers: c,
|
|
634
|
+
signal: o.signal
|
|
635
|
+
});
|
|
636
|
+
let r = await e(n);
|
|
637
|
+
if (!n.ok) throw new E(n.statusText, {
|
|
638
|
+
url: l.toString(),
|
|
639
|
+
method: a.method || "GET",
|
|
640
|
+
options: t
|
|
641
|
+
}, n, r);
|
|
642
|
+
return r;
|
|
643
|
+
} catch (e) {
|
|
644
|
+
throw e instanceof E ? e : new E(e?.message || `${e}`, {
|
|
645
|
+
url: l.toString(),
|
|
646
|
+
method: a.method || "GET",
|
|
647
|
+
options: t
|
|
648
|
+
}, n, e);
|
|
649
|
+
} finally {
|
|
650
|
+
s && clearTimeout(s);
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
return {
|
|
654
|
+
async arrayBuffer() {
|
|
655
|
+
return u((e) => e.arrayBuffer());
|
|
656
|
+
},
|
|
657
|
+
async blob() {
|
|
658
|
+
return u((e) => e.blob());
|
|
659
|
+
},
|
|
660
|
+
async json() {
|
|
661
|
+
return c.has("accept") || c.set("accept", "application/json"), u((e) => e.json());
|
|
662
|
+
},
|
|
663
|
+
async text() {
|
|
664
|
+
return u((e) => e.text());
|
|
665
|
+
},
|
|
666
|
+
abort() {
|
|
667
|
+
o.abort();
|
|
668
|
+
}
|
|
669
|
+
};
|
|
893
670
|
}
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
async getAccount() {
|
|
899
|
-
const r = await this.request("https://www.googleapis.com/oauth2/v1/userinfo?alt=json", {
|
|
900
|
-
responseType: "json"
|
|
901
|
-
});
|
|
902
|
-
return {
|
|
903
|
-
id: r.id,
|
|
904
|
-
name: r.name,
|
|
905
|
-
avatar: r.picture
|
|
906
|
-
};
|
|
907
|
-
}
|
|
908
|
-
normalizeEntry(r) {
|
|
909
|
-
return {
|
|
910
|
-
kind: r.kind.endsWith("#file") ? "file" : "folder",
|
|
911
|
-
id: r.id,
|
|
912
|
-
name: r.name,
|
|
913
|
-
size: Number(r.size),
|
|
914
|
-
modifiedTime: r.modifiedTime
|
|
915
|
-
};
|
|
916
|
-
}
|
|
917
|
-
async stat(r) {
|
|
918
|
-
const p = await this.request(`files/${r}`, {
|
|
919
|
-
responseType: "json"
|
|
920
|
-
});
|
|
921
|
-
return this.normalizeEntry(p);
|
|
922
|
-
}
|
|
923
|
-
async resolveId(r) {
|
|
924
|
-
return r.id ? r.id : (await this.find(r)).id;
|
|
925
|
-
}
|
|
926
|
-
async find(r) {
|
|
927
|
-
if (r.id) return this.stat(r.id);
|
|
928
|
-
let p;
|
|
929
|
-
if (!r.path) throw new Error("Invalid path");
|
|
930
|
-
const d = r.path.split("/").filter(Boolean);
|
|
931
|
-
for (const c of d) {
|
|
932
|
-
const y = p;
|
|
933
|
-
p = void 0;
|
|
934
|
-
for await (const v of this.list(y)) {
|
|
935
|
-
const T = v.find((x) => x.name === c);
|
|
936
|
-
if (T) {
|
|
937
|
-
p = T;
|
|
938
|
-
break;
|
|
939
|
-
}
|
|
940
|
-
}
|
|
941
|
-
}
|
|
942
|
-
if (!p) throw new Error("Item not found");
|
|
943
|
-
return p;
|
|
944
|
-
}
|
|
945
|
-
async mkdir(r) {
|
|
946
|
-
const p = r.parent && await this.resolveId(r.parent), d = await this.request("files", {
|
|
947
|
-
method: "POST",
|
|
948
|
-
json: {
|
|
949
|
-
name: r.name,
|
|
950
|
-
parents: [p || this.rootId],
|
|
951
|
-
mimeType: "application/vnd.google-apps.folder"
|
|
952
|
-
},
|
|
953
|
-
responseType: "json"
|
|
954
|
-
});
|
|
955
|
-
return this.normalizeEntry(d);
|
|
956
|
-
}
|
|
957
|
-
async *list(r) {
|
|
958
|
-
const p = r && await this.resolveId(r);
|
|
959
|
-
let d = "";
|
|
960
|
-
for (; ; ) {
|
|
961
|
-
const c = new URLSearchParams({
|
|
962
|
-
spaces: this.rootId,
|
|
963
|
-
fields: "files(id,name,size,kind,mimeType,createdTime,modifiedTime),nextPageToken",
|
|
964
|
-
pageToken: d,
|
|
965
|
-
...p && {
|
|
966
|
-
q: `'${p}' in parents`
|
|
967
|
-
}
|
|
968
|
-
}), y = await this.request(`files?${c}`, { responseType: "json" });
|
|
969
|
-
if (yield y.files.map((v) => this.normalizeEntry(v)), !y.nextPageToken) break;
|
|
970
|
-
d = y.nextPageToken;
|
|
971
|
-
}
|
|
972
|
-
}
|
|
973
|
-
async get(r) {
|
|
974
|
-
const p = await this.resolveId(r);
|
|
975
|
-
return await this.request(`files/${p}?alt=media`, {
|
|
976
|
-
responseType: "blob"
|
|
977
|
-
});
|
|
978
|
-
}
|
|
979
|
-
async remove(r) {
|
|
980
|
-
const p = await this.resolveId(r);
|
|
981
|
-
await this.request(`files/${p}`, {
|
|
982
|
-
method: "DELETE",
|
|
983
|
-
responseType: "json"
|
|
984
|
-
});
|
|
985
|
-
}
|
|
986
|
-
async put(r, p) {
|
|
987
|
-
let d = r.parent ? await this.resolveId(r.parent) : "", c = r.id;
|
|
988
|
-
if (!c && !d && r.path)
|
|
989
|
-
try {
|
|
990
|
-
c = await this.resolveId(r);
|
|
991
|
-
} catch {
|
|
992
|
-
const x = r.path.lastIndexOf("/"), S = x < 0 ? "" : r.path.slice(0, x);
|
|
993
|
-
d = await this.resolveId({ path: S });
|
|
994
|
-
}
|
|
995
|
-
if (!c && !r.name) throw new Error("Invalid file name");
|
|
996
|
-
const y = new FormData();
|
|
997
|
-
y.append(
|
|
998
|
-
"metadata",
|
|
999
|
-
new Blob(
|
|
1000
|
-
[
|
|
1001
|
-
JSON.stringify({
|
|
1002
|
-
name: r.name || "",
|
|
1003
|
-
...!c && { parents: [d || this.rootId] }
|
|
1004
|
-
})
|
|
1005
|
-
],
|
|
1006
|
-
{ type: "application/json" }
|
|
1007
|
-
)
|
|
1008
|
-
), y.append("file", p);
|
|
1009
|
-
const v = c ? `https://www.googleapis.com/upload/drive/v3/files/${c}?uploadType=multipart` : "https://www.googleapis.com/upload/drive/v3/files?uploadType=multipart", T = await this.request(v, {
|
|
1010
|
-
body: y,
|
|
1011
|
-
method: c ? "PATCH" : "POST",
|
|
1012
|
-
responseType: "json"
|
|
1013
|
-
});
|
|
1014
|
-
return this.normalizeEntry(T);
|
|
1015
|
-
}
|
|
671
|
+
//#endregion
|
|
672
|
+
//#region src/util.ts
|
|
673
|
+
function k(e) {
|
|
674
|
+
return new Promise((t) => setTimeout(t, e));
|
|
1016
675
|
}
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
};
|
|
1038
|
-
}
|
|
1039
|
-
getOneDrivePath(r, p, d) {
|
|
1040
|
-
let c;
|
|
1041
|
-
if (r?.id)
|
|
1042
|
-
c = `me/drive/items/${r.id}`;
|
|
1043
|
-
else if (r?.parent?.id ? c = `me/drive/items/${r.parent.id}` : c = this.root, r?.name)
|
|
1044
|
-
c += ":", r.parent?.path && !r.parent.id && (c += `${r.parent.path}`), c += `/${r.name}`, d && (c += ":");
|
|
1045
|
-
else if (!p)
|
|
1046
|
-
throw new Error("Invalid path");
|
|
1047
|
-
return d && (c += d), c;
|
|
1048
|
-
}
|
|
1049
|
-
async mkdir(r) {
|
|
1050
|
-
const p = this.getOneDrivePath(r.parent, !0, "/children"), d = await this.request(p, {
|
|
1051
|
-
method: "POST",
|
|
1052
|
-
json: {
|
|
1053
|
-
name: r.name,
|
|
1054
|
-
folder: {},
|
|
1055
|
-
"@microsoft.graph.conflictBehavior": "fail"
|
|
1056
|
-
},
|
|
1057
|
-
responseType: "json"
|
|
1058
|
-
});
|
|
1059
|
-
return this.normalizeEntry(d);
|
|
1060
|
-
}
|
|
1061
|
-
async find(r) {
|
|
1062
|
-
const p = this.getOneDrivePath(r, !1), d = await this.request(p, {
|
|
1063
|
-
responseType: "json"
|
|
1064
|
-
});
|
|
1065
|
-
return this.normalizeEntry(d);
|
|
1066
|
-
}
|
|
1067
|
-
async *list(r) {
|
|
1068
|
-
let p = this.getOneDrivePath(r, !0, "/children");
|
|
1069
|
-
for (; p; ) {
|
|
1070
|
-
const d = await this.request(p, { responseType: "json" });
|
|
1071
|
-
p = d["@odata.nextLink"] || "", yield d.value.map((c) => this.normalizeEntry(c));
|
|
1072
|
-
}
|
|
1073
|
-
}
|
|
1074
|
-
get(r) {
|
|
1075
|
-
const p = this.getOneDrivePath(r, !1, "/content");
|
|
1076
|
-
return this.request(p, { responseType: "blob" });
|
|
1077
|
-
}
|
|
1078
|
-
async remove(r) {
|
|
1079
|
-
const p = this.getOneDrivePath(r, !1);
|
|
1080
|
-
await this.request(p, {
|
|
1081
|
-
method: "DELETE",
|
|
1082
|
-
responseType: "blob"
|
|
1083
|
-
});
|
|
1084
|
-
}
|
|
1085
|
-
async put(r, p) {
|
|
1086
|
-
const d = this.getOneDrivePath(r, !1, "/content"), c = await this.request(d, {
|
|
1087
|
-
method: "PUT",
|
|
1088
|
-
headers: {
|
|
1089
|
-
"Content-Type": "application/octet-stream"
|
|
1090
|
-
},
|
|
1091
|
-
body: p,
|
|
1092
|
-
responseType: "json"
|
|
1093
|
-
});
|
|
1094
|
-
return this.normalizeEntry(c);
|
|
1095
|
-
}
|
|
676
|
+
//#endregion
|
|
677
|
+
//#region src/providers/base.ts
|
|
678
|
+
function A(e) {
|
|
679
|
+
let t = 0;
|
|
680
|
+
return async (n, r) => {
|
|
681
|
+
let i = t, a;
|
|
682
|
+
for (let o = 5; o > 0; --o) {
|
|
683
|
+
await k(i);
|
|
684
|
+
try {
|
|
685
|
+
let i = await e(n, r);
|
|
686
|
+
return t >>= 1, i;
|
|
687
|
+
} catch (e) {
|
|
688
|
+
if (a = e, e instanceof E && e.response?.status === 429) {
|
|
689
|
+
let n = e.response.headers.get("retry-after"), r = n && (isNaN(+n) ? new Date(n).getTime() - Date.now() : n * 1e3);
|
|
690
|
+
r ? i = r : (i = Math.max(1e3, i * 2), t = i);
|
|
691
|
+
} else break;
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
throw a;
|
|
695
|
+
};
|
|
1096
696
|
}
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
});
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
d.endsWith("/") || (d += "/"), this.baseUrl = d;
|
|
1107
|
-
}
|
|
1108
|
-
initRequest() {
|
|
1109
|
-
let r = (p, d) => {
|
|
1110
|
-
const { responseType: c, headers: y, ...v } = d, T = new Headers(y), { serverOptions: x = {}, user: S, password: L } = this.authConfig;
|
|
1111
|
-
if (x && !x.anonymous) {
|
|
1112
|
-
const I = Ae(new TextEncoder().encode(`${S}:${L}`));
|
|
1113
|
-
T.set("authorization", `Basic ${I}`);
|
|
1114
|
-
}
|
|
1115
|
-
return p.startsWith("/") && (p = `.${p}`), ve(new URL(p, this.baseUrl), {
|
|
1116
|
-
// Bypass login CSRF protection in NextCloud by not sending cookies
|
|
1117
|
-
credentials: "omit",
|
|
1118
|
-
...v,
|
|
1119
|
-
headers: T
|
|
1120
|
-
})[c]();
|
|
1121
|
-
};
|
|
1122
|
-
return r = Ee(r), r;
|
|
1123
|
-
}
|
|
1124
|
-
async getAccount() {
|
|
1125
|
-
const { serverOptions: r = {} } = this.authConfig;
|
|
1126
|
-
return {
|
|
1127
|
-
id: `${r.id || "webdav"}`,
|
|
1128
|
-
name: `${r.name || "WebDav"}`,
|
|
1129
|
-
avatar: `${r.avatar || ""}`
|
|
1130
|
-
};
|
|
1131
|
-
}
|
|
1132
|
-
getWebDavPath(r, p) {
|
|
1133
|
-
let d = r?.path || r?.id || "";
|
|
1134
|
-
if (d[0] === "/" && (d = d.slice(1)), !p) throw new Error("Invalid path");
|
|
1135
|
-
return "";
|
|
1136
|
-
}
|
|
1137
|
-
getFullUrl(r) {
|
|
1138
|
-
return new URL(r, this.baseUrl).href;
|
|
1139
|
-
}
|
|
1140
|
-
async mkdir(r) {
|
|
1141
|
-
const p = [this.getWebDavPath(r.parent, !0), r.name].filter(Boolean).join("/");
|
|
1142
|
-
return await this.request(p, {
|
|
1143
|
-
method: "MKCOL",
|
|
1144
|
-
responseType: "blob"
|
|
1145
|
-
}), {
|
|
1146
|
-
id: this.getFullUrl(p),
|
|
1147
|
-
name: r.name,
|
|
1148
|
-
size: 0,
|
|
1149
|
-
kind: "folder",
|
|
1150
|
-
modifiedTime: (/* @__PURE__ */ new Date()).toISOString()
|
|
1151
|
-
};
|
|
1152
|
-
}
|
|
1153
|
-
async propFind(r) {
|
|
1154
|
-
const p = await this.request(r, {
|
|
1155
|
-
method: "PROPFIND",
|
|
1156
|
-
headers: {
|
|
1157
|
-
depth: "1"
|
|
1158
|
-
},
|
|
1159
|
-
responseType: "text"
|
|
1160
|
-
});
|
|
1161
|
-
let c = be.parse(p).multistatus.response;
|
|
1162
|
-
return Array.isArray(c) || (c = c ? [c] : []), c.map((y) => {
|
|
1163
|
-
const v = y.propstat.prop, T = v.resourcetype?.collection;
|
|
1164
|
-
return {
|
|
1165
|
-
id: this.getFullUrl(y.href),
|
|
1166
|
-
name: v.displayname,
|
|
1167
|
-
kind: T ? "folder" : "file",
|
|
1168
|
-
size: T ? 0 : v.getcontentlength,
|
|
1169
|
-
modifiedTime: new Date(v.getlastmodified).toISOString()
|
|
1170
|
-
};
|
|
1171
|
-
});
|
|
1172
|
-
}
|
|
1173
|
-
async find(r) {
|
|
1174
|
-
const p = this.getWebDavPath(r, !1), d = this.getFullUrl(p), y = (await this.propFind(p)).find((v) => v.id === d);
|
|
1175
|
-
if (!y) throw new Error("Item not found");
|
|
1176
|
-
return y;
|
|
1177
|
-
}
|
|
1178
|
-
async *list(r) {
|
|
1179
|
-
const p = this.getWebDavPath(r, !0), d = this.getFullUrl(p);
|
|
1180
|
-
let c = await this.propFind(p);
|
|
1181
|
-
c = c.filter((y) => y.id !== d), yield c;
|
|
1182
|
-
}
|
|
1183
|
-
async get(r) {
|
|
1184
|
-
const p = this.getWebDavPath(r, !1);
|
|
1185
|
-
return this.request(p, { responseType: "blob" });
|
|
1186
|
-
}
|
|
1187
|
-
async remove(r) {
|
|
1188
|
-
const p = this.getWebDavPath(r, !1);
|
|
1189
|
-
await this.request(p, {
|
|
1190
|
-
method: "DELETE",
|
|
1191
|
-
responseType: "blob"
|
|
1192
|
-
});
|
|
1193
|
-
}
|
|
1194
|
-
async put(r, p) {
|
|
1195
|
-
const d = this.getWebDavPath(r, !0) || [this.getWebDavPath(r.parent, !0), r.name || ""].filter(Boolean).join("/");
|
|
1196
|
-
if (!d) throw new Error("Invalid path");
|
|
1197
|
-
return await this.request(d, {
|
|
1198
|
-
method: "PUT",
|
|
1199
|
-
headers: {
|
|
1200
|
-
"Content-Type": "application/octet-stream"
|
|
1201
|
-
},
|
|
1202
|
-
body: p,
|
|
1203
|
-
responseType: "blob"
|
|
1204
|
-
}), {
|
|
1205
|
-
id: this.getFullUrl(d),
|
|
1206
|
-
name: d.slice(d.lastIndexOf("/") + 1),
|
|
1207
|
-
size: p.size,
|
|
1208
|
-
kind: "file",
|
|
1209
|
-
modifiedTime: (/* @__PURE__ */ new Date()).toISOString()
|
|
1210
|
-
};
|
|
1211
|
-
}
|
|
697
|
+
function j(t, n) {
|
|
698
|
+
if (!t) throw Error("Invalid authorizer");
|
|
699
|
+
return (r) => async (i, a) => {
|
|
700
|
+
let { headers: o, ...s } = a, c = new Headers(o), l = await e(t, n);
|
|
701
|
+
return c.set("authorization", `Bearer ${l}`), await r(i, {
|
|
702
|
+
...s,
|
|
703
|
+
headers: c
|
|
704
|
+
});
|
|
705
|
+
};
|
|
1212
706
|
}
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
707
|
+
var M = class {}, N = class extends M {
|
|
708
|
+
constructor(e, t) {
|
|
709
|
+
super(), this.authConfig = e, this.context = t, this.request = this.initRequest();
|
|
710
|
+
}
|
|
711
|
+
initRequest() {
|
|
712
|
+
let e = async (e, t) => {
|
|
713
|
+
let { responseType: n, ...r } = t;
|
|
714
|
+
return await O(new URL(e, this.baseUrl), r)[n]();
|
|
715
|
+
}, { authorizer: t, handleOAuth2: n } = this.context;
|
|
716
|
+
return e = j(t, n)(e), e = A(e), e;
|
|
717
|
+
}
|
|
718
|
+
async getAccount() {
|
|
719
|
+
throw Error("Not implemented");
|
|
720
|
+
}
|
|
1218
721
|
};
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
throw new Error(
|
|
1224
|
-
"storage and handleOAuth2 are required for OAuth2 authorization"
|
|
1225
|
-
);
|
|
1226
|
-
const T = Oe(
|
|
1227
|
-
{
|
|
1228
|
-
redirectUrl: m.redirectUrl,
|
|
1229
|
-
...m.authProviders[r.auth.authProvider],
|
|
1230
|
-
storage: p
|
|
1231
|
-
},
|
|
1232
|
-
{
|
|
1233
|
-
provider: r.auth.authProvider,
|
|
1234
|
-
user: r.auth.user
|
|
1235
|
-
}
|
|
1236
|
-
);
|
|
1237
|
-
c.authorizer = T, c.handleOAuth2 = d;
|
|
1238
|
-
}
|
|
1239
|
-
const y = ze[r.driveProvider];
|
|
1240
|
-
return new y(r.auth, c);
|
|
722
|
+
function P(e, t) {
|
|
723
|
+
return typeof t == "string" ? t.replace(/[^\x00-\x7F]/g, function(e) {
|
|
724
|
+
return "\\u" + e.codePointAt(0).toString(16).padStart(4, "0");
|
|
725
|
+
}) : t;
|
|
1241
726
|
}
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
727
|
+
//#endregion
|
|
728
|
+
//#region src/providers/dropbox.ts
|
|
729
|
+
var F = class extends N {
|
|
730
|
+
normalizeEntry(e) {
|
|
731
|
+
return {
|
|
732
|
+
kind: e[".tag"] === "file" ? "file" : "folder",
|
|
733
|
+
id: e.id,
|
|
734
|
+
name: e.name,
|
|
735
|
+
size: e.size || 0,
|
|
736
|
+
modifiedTime: e.server_modified || ""
|
|
737
|
+
};
|
|
738
|
+
}
|
|
739
|
+
getDropboxPath(e, t) {
|
|
740
|
+
if (e?.id) return `id:${e.id}`;
|
|
741
|
+
let n = e?.path;
|
|
742
|
+
if (n?.[0] === "/") return n;
|
|
743
|
+
if (n || !t) throw Error("Invalid path");
|
|
744
|
+
return "";
|
|
745
|
+
}
|
|
746
|
+
async getAccount() {
|
|
747
|
+
let e = await this.request("https://api.dropboxapi.com/2/users/get_current_account", {
|
|
748
|
+
method: "POST",
|
|
749
|
+
responseType: "json"
|
|
750
|
+
});
|
|
751
|
+
return {
|
|
752
|
+
id: e.account_id,
|
|
753
|
+
name: e.name.display_name,
|
|
754
|
+
avatar: e.profile_photo_url
|
|
755
|
+
};
|
|
756
|
+
}
|
|
757
|
+
async mkdir(e) {
|
|
758
|
+
let t = [this.getDropboxPath(e.parent, !0), e.name].filter(Boolean).join("/"), n = await this.request("https://api.dropboxapi.com/2/files/create_folder_v2", {
|
|
759
|
+
method: "POST",
|
|
760
|
+
json: { path: t },
|
|
761
|
+
responseType: "json"
|
|
762
|
+
});
|
|
763
|
+
return this.normalizeEntry({
|
|
764
|
+
...n.metadata,
|
|
765
|
+
".tag": "folder"
|
|
766
|
+
});
|
|
767
|
+
}
|
|
768
|
+
async find(e) {
|
|
769
|
+
let t = this.getDropboxPath(e, !1), n = await this.request("https://api.dropboxapi.com/2/files/get_metadata", {
|
|
770
|
+
method: "POST",
|
|
771
|
+
json: { path: t },
|
|
772
|
+
responseType: "json"
|
|
773
|
+
});
|
|
774
|
+
return this.normalizeEntry(n);
|
|
775
|
+
}
|
|
776
|
+
async *list(e) {
|
|
777
|
+
let t = e ? this.getDropboxPath(e, !0) : "", n = await this.request("https://api.dropboxapi.com/2/files/list_folder", {
|
|
778
|
+
method: "POST",
|
|
779
|
+
json: { path: t },
|
|
780
|
+
responseType: "json"
|
|
781
|
+
});
|
|
782
|
+
for (yield n.entries.map((e) => this.normalizeEntry(e)); n.has_more;) n = await this.request("https://api.dropboxapi.com/2/files/list_folder/continue", {
|
|
783
|
+
method: "POST",
|
|
784
|
+
json: { cursor: n.cursor },
|
|
785
|
+
responseType: "json"
|
|
786
|
+
}), yield n.entries.map((e) => this.normalizeEntry(e));
|
|
787
|
+
}
|
|
788
|
+
get(e) {
|
|
789
|
+
let t = this.getDropboxPath(e, !1);
|
|
790
|
+
return this.request("https://content.dropboxapi.com/2/files/download", {
|
|
791
|
+
method: "POST",
|
|
792
|
+
headers: { "Dropbox-API-Arg": JSON.stringify({ path: t }) },
|
|
793
|
+
responseType: "blob"
|
|
794
|
+
});
|
|
795
|
+
}
|
|
796
|
+
async remove(e) {
|
|
797
|
+
let t = this.getDropboxPath(e, !1);
|
|
798
|
+
await this.request("https://api.dropboxapi.com/2/files/delete", {
|
|
799
|
+
method: "POST",
|
|
800
|
+
json: { path: t },
|
|
801
|
+
responseType: "json"
|
|
802
|
+
});
|
|
803
|
+
}
|
|
804
|
+
async put(e, t) {
|
|
805
|
+
let n = e.name && !e.id ? [this.getDropboxPath(e.parent, !0), e.name].filter(Boolean).join("/") : this.getDropboxPath(e, !0);
|
|
806
|
+
if (!n) throw Error("Invalid path");
|
|
807
|
+
let r = await this.request("https://content.dropboxapi.com/2/files/upload", {
|
|
808
|
+
method: "POST",
|
|
809
|
+
headers: {
|
|
810
|
+
"Dropbox-API-Arg": JSON.stringify({
|
|
811
|
+
path: n,
|
|
812
|
+
mode: "overwrite"
|
|
813
|
+
}, P),
|
|
814
|
+
"Content-Type": "application/octet-stream"
|
|
815
|
+
},
|
|
816
|
+
body: t,
|
|
817
|
+
responseType: "json"
|
|
818
|
+
});
|
|
819
|
+
return this.normalizeEntry({
|
|
820
|
+
...r,
|
|
821
|
+
".tag": "file"
|
|
822
|
+
});
|
|
823
|
+
}
|
|
824
|
+
}, I = class extends N {
|
|
825
|
+
constructor(...e) {
|
|
826
|
+
super(...e), this.baseUrl = "https://www.googleapis.com/drive/v3/", this.rootId = "appDataFolder";
|
|
827
|
+
}
|
|
828
|
+
async getAccount() {
|
|
829
|
+
let e = await this.request("https://www.googleapis.com/oauth2/v1/userinfo?alt=json", { responseType: "json" });
|
|
830
|
+
return {
|
|
831
|
+
id: e.id,
|
|
832
|
+
name: e.name,
|
|
833
|
+
avatar: e.picture
|
|
834
|
+
};
|
|
835
|
+
}
|
|
836
|
+
normalizeEntry(e) {
|
|
837
|
+
return {
|
|
838
|
+
kind: e.kind.endsWith("#file") ? "file" : "folder",
|
|
839
|
+
id: e.id,
|
|
840
|
+
name: e.name,
|
|
841
|
+
size: Number(e.size),
|
|
842
|
+
modifiedTime: e.modifiedTime
|
|
843
|
+
};
|
|
844
|
+
}
|
|
845
|
+
async stat(e) {
|
|
846
|
+
let t = await this.request(`files/${e}`, { responseType: "json" });
|
|
847
|
+
return this.normalizeEntry(t);
|
|
848
|
+
}
|
|
849
|
+
async resolveId(e) {
|
|
850
|
+
return e.id ? e.id : (await this.find(e)).id;
|
|
851
|
+
}
|
|
852
|
+
async find(e) {
|
|
853
|
+
if (e.id) return this.stat(e.id);
|
|
854
|
+
let t;
|
|
855
|
+
if (!e.path) throw Error("Invalid path");
|
|
856
|
+
let n = e.path.split("/").filter(Boolean);
|
|
857
|
+
for (let e of n) {
|
|
858
|
+
let n = t;
|
|
859
|
+
t = void 0;
|
|
860
|
+
for await (let r of this.list(n)) {
|
|
861
|
+
let n = r.find((t) => t.name === e);
|
|
862
|
+
if (n) {
|
|
863
|
+
t = n;
|
|
864
|
+
break;
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
if (!t) throw Error("Item not found");
|
|
869
|
+
return t;
|
|
870
|
+
}
|
|
871
|
+
async mkdir(e) {
|
|
872
|
+
let t = e.parent && await this.resolveId(e.parent), n = await this.request("files", {
|
|
873
|
+
method: "POST",
|
|
874
|
+
json: {
|
|
875
|
+
name: e.name,
|
|
876
|
+
parents: [t || this.rootId],
|
|
877
|
+
mimeType: "application/vnd.google-apps.folder"
|
|
878
|
+
},
|
|
879
|
+
responseType: "json"
|
|
880
|
+
});
|
|
881
|
+
return this.normalizeEntry(n);
|
|
882
|
+
}
|
|
883
|
+
async *list(e) {
|
|
884
|
+
let t = e && await this.resolveId(e), n = "";
|
|
885
|
+
for (;;) {
|
|
886
|
+
let e = new URLSearchParams({
|
|
887
|
+
spaces: this.rootId,
|
|
888
|
+
fields: "files(id,name,size,kind,mimeType,createdTime,modifiedTime),nextPageToken",
|
|
889
|
+
pageToken: n,
|
|
890
|
+
...t && { q: `'${t}' in parents` }
|
|
891
|
+
}), r = await this.request(`files?${e}`, { responseType: "json" });
|
|
892
|
+
if (yield r.files.map((e) => this.normalizeEntry(e)), !r.nextPageToken) break;
|
|
893
|
+
n = r.nextPageToken;
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
async get(e) {
|
|
897
|
+
let t = await this.resolveId(e);
|
|
898
|
+
return await this.request(`files/${t}?alt=media`, { responseType: "blob" });
|
|
899
|
+
}
|
|
900
|
+
async remove(e) {
|
|
901
|
+
let t = await this.resolveId(e);
|
|
902
|
+
await this.request(`files/${t}`, {
|
|
903
|
+
method: "DELETE",
|
|
904
|
+
responseType: "json"
|
|
905
|
+
});
|
|
906
|
+
}
|
|
907
|
+
async put(e, t) {
|
|
908
|
+
let n = e.parent ? await this.resolveId(e.parent) : "", r = e.id;
|
|
909
|
+
if (!r && !n && e.path) try {
|
|
910
|
+
r = await this.resolveId(e);
|
|
911
|
+
} catch {
|
|
912
|
+
let t = e.path.lastIndexOf("/"), r = t < 0 ? "" : e.path.slice(0, t);
|
|
913
|
+
n = await this.resolveId({ path: r });
|
|
914
|
+
}
|
|
915
|
+
if (!r && !e.name) throw Error("Invalid file name");
|
|
916
|
+
let i = new FormData();
|
|
917
|
+
i.append("metadata", new Blob([JSON.stringify({
|
|
918
|
+
name: e.name || "",
|
|
919
|
+
...!r && { parents: [n || this.rootId] }
|
|
920
|
+
})], { type: "application/json" })), i.append("file", t);
|
|
921
|
+
let a = r ? `https://www.googleapis.com/upload/drive/v3/files/${r}?uploadType=multipart` : "https://www.googleapis.com/upload/drive/v3/files?uploadType=multipart", o = await this.request(a, {
|
|
922
|
+
body: i,
|
|
923
|
+
method: r ? "PATCH" : "POST",
|
|
924
|
+
responseType: "json"
|
|
925
|
+
});
|
|
926
|
+
return this.normalizeEntry(o);
|
|
927
|
+
}
|
|
928
|
+
}, L = class extends N {
|
|
929
|
+
constructor(...e) {
|
|
930
|
+
super(...e), this.baseUrl = "https://graph.microsoft.com/v1.0/", this.root = "me/drive/special/approot";
|
|
931
|
+
}
|
|
932
|
+
async getAccount() {
|
|
933
|
+
let e = await this.request("/oidc/userinfo", { responseType: "json" });
|
|
934
|
+
return {
|
|
935
|
+
id: e.sub,
|
|
936
|
+
name: e.givenname + " " + e.familyname,
|
|
937
|
+
avatar: e.picture
|
|
938
|
+
};
|
|
939
|
+
}
|
|
940
|
+
normalizeEntry(e) {
|
|
941
|
+
return {
|
|
942
|
+
id: e.id,
|
|
943
|
+
name: e.name,
|
|
944
|
+
size: e.size,
|
|
945
|
+
kind: "file",
|
|
946
|
+
modifiedTime: e.lastModifiedDateTime
|
|
947
|
+
};
|
|
948
|
+
}
|
|
949
|
+
getOneDrivePath(e, t, n) {
|
|
950
|
+
let r;
|
|
951
|
+
if (e?.id) r = `me/drive/items/${e.id}`;
|
|
952
|
+
else if (r = e?.parent?.id ? `me/drive/items/${e.parent.id}` : this.root, e?.name) r += ":", e.parent?.path && !e.parent.id && (r += `${e.parent.path}`), r += `/${e.name}`, n && (r += ":");
|
|
953
|
+
else if (!t) throw Error("Invalid path");
|
|
954
|
+
return n && (r += n), r;
|
|
955
|
+
}
|
|
956
|
+
async mkdir(e) {
|
|
957
|
+
let t = this.getOneDrivePath(e.parent, !0, "/children"), n = await this.request(t, {
|
|
958
|
+
method: "POST",
|
|
959
|
+
json: {
|
|
960
|
+
name: e.name,
|
|
961
|
+
folder: {},
|
|
962
|
+
"@microsoft.graph.conflictBehavior": "fail"
|
|
963
|
+
},
|
|
964
|
+
responseType: "json"
|
|
965
|
+
});
|
|
966
|
+
return this.normalizeEntry(n);
|
|
967
|
+
}
|
|
968
|
+
async find(e) {
|
|
969
|
+
let t = this.getOneDrivePath(e, !1), n = await this.request(t, { responseType: "json" });
|
|
970
|
+
return this.normalizeEntry(n);
|
|
971
|
+
}
|
|
972
|
+
async *list(e) {
|
|
973
|
+
let t = this.getOneDrivePath(e, !0, "/children");
|
|
974
|
+
for (; t;) {
|
|
975
|
+
let e = await this.request(t, { responseType: "json" });
|
|
976
|
+
t = e["@odata.nextLink"] || "", yield e.value.map((e) => this.normalizeEntry(e));
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
get(e) {
|
|
980
|
+
let t = this.getOneDrivePath(e, !1, "/content");
|
|
981
|
+
return this.request(t, { responseType: "blob" });
|
|
982
|
+
}
|
|
983
|
+
async remove(e) {
|
|
984
|
+
let t = this.getOneDrivePath(e, !1);
|
|
985
|
+
await this.request(t, {
|
|
986
|
+
method: "DELETE",
|
|
987
|
+
responseType: "blob"
|
|
988
|
+
});
|
|
989
|
+
}
|
|
990
|
+
async put(e, t) {
|
|
991
|
+
let n = this.getOneDrivePath(e, !1, "/content"), r = await this.request(n, {
|
|
992
|
+
method: "PUT",
|
|
993
|
+
headers: { "Content-Type": "application/octet-stream" },
|
|
994
|
+
body: t,
|
|
995
|
+
responseType: "json"
|
|
996
|
+
});
|
|
997
|
+
return this.normalizeEntry(r);
|
|
998
|
+
}
|
|
999
|
+
}, R = new n({
|
|
1000
|
+
ignoreAttributes: !1,
|
|
1001
|
+
removeNSPrefix: !0
|
|
1002
|
+
}), z = {
|
|
1003
|
+
dropbox: F,
|
|
1004
|
+
googledrive: I,
|
|
1005
|
+
onedrive: L,
|
|
1006
|
+
webdav: class extends N {
|
|
1007
|
+
constructor(e, t) {
|
|
1008
|
+
super(e, t);
|
|
1009
|
+
let n = e.serverOptions?.baseUrl;
|
|
1010
|
+
if (!n) throw Error("baseUrl is required");
|
|
1011
|
+
n.endsWith("/") || (n += "/"), this.baseUrl = n;
|
|
1012
|
+
}
|
|
1013
|
+
initRequest() {
|
|
1014
|
+
let e = (e, t) => {
|
|
1015
|
+
let { responseType: n, headers: r, ...i } = t, a = new Headers(r), { serverOptions: o = {}, user: s, password: c } = this.authConfig;
|
|
1016
|
+
if (o && !o.anonymous) {
|
|
1017
|
+
let e = T(new TextEncoder().encode(`${s}:${c}`));
|
|
1018
|
+
a.set("authorization", `Basic ${e}`);
|
|
1019
|
+
}
|
|
1020
|
+
return e.startsWith("/") && (e = `.${e}`), O(new URL(e, this.baseUrl), {
|
|
1021
|
+
credentials: "omit",
|
|
1022
|
+
...i,
|
|
1023
|
+
headers: a
|
|
1024
|
+
})[n]();
|
|
1025
|
+
};
|
|
1026
|
+
return e = A(e), e;
|
|
1027
|
+
}
|
|
1028
|
+
async getAccount() {
|
|
1029
|
+
let { serverOptions: e = {} } = this.authConfig;
|
|
1030
|
+
return {
|
|
1031
|
+
id: `${e.id || "webdav"}`,
|
|
1032
|
+
name: `${e.name || "WebDav"}`,
|
|
1033
|
+
avatar: `${e.avatar || ""}`
|
|
1034
|
+
};
|
|
1035
|
+
}
|
|
1036
|
+
getWebDavPath(e, t) {
|
|
1037
|
+
let n = e?.path || e?.id || "";
|
|
1038
|
+
if (n[0] === "/" && (n = n.slice(1)), !t) throw Error("Invalid path");
|
|
1039
|
+
return "";
|
|
1040
|
+
}
|
|
1041
|
+
getFullUrl(e) {
|
|
1042
|
+
return new URL(e, this.baseUrl).href;
|
|
1043
|
+
}
|
|
1044
|
+
async mkdir(e) {
|
|
1045
|
+
let t = [this.getWebDavPath(e.parent, !0), e.name].filter(Boolean).join("/");
|
|
1046
|
+
return await this.request(t, {
|
|
1047
|
+
method: "MKCOL",
|
|
1048
|
+
responseType: "blob"
|
|
1049
|
+
}), {
|
|
1050
|
+
id: this.getFullUrl(t),
|
|
1051
|
+
name: e.name,
|
|
1052
|
+
size: 0,
|
|
1053
|
+
kind: "folder",
|
|
1054
|
+
modifiedTime: (/* @__PURE__ */ new Date()).toISOString()
|
|
1055
|
+
};
|
|
1056
|
+
}
|
|
1057
|
+
async propFind(e) {
|
|
1058
|
+
let t = await this.request(e, {
|
|
1059
|
+
method: "PROPFIND",
|
|
1060
|
+
headers: { depth: "1" },
|
|
1061
|
+
responseType: "text"
|
|
1062
|
+
}), n = R.parse(t).multistatus.response;
|
|
1063
|
+
return Array.isArray(n) || (n = n ? [n] : []), n.map((e) => {
|
|
1064
|
+
let t = e.propstat.prop, n = t.resourcetype?.collection;
|
|
1065
|
+
return {
|
|
1066
|
+
id: this.getFullUrl(e.href),
|
|
1067
|
+
name: t.displayname,
|
|
1068
|
+
kind: n ? "folder" : "file",
|
|
1069
|
+
size: n ? 0 : t.getcontentlength,
|
|
1070
|
+
modifiedTime: new Date(t.getlastmodified).toISOString()
|
|
1071
|
+
};
|
|
1072
|
+
});
|
|
1073
|
+
}
|
|
1074
|
+
async find(e) {
|
|
1075
|
+
let t = this.getWebDavPath(e, !1), n = this.getFullUrl(t), r = (await this.propFind(t)).find((e) => e.id === n);
|
|
1076
|
+
if (!r) throw Error("Item not found");
|
|
1077
|
+
return r;
|
|
1078
|
+
}
|
|
1079
|
+
async *list(e) {
|
|
1080
|
+
let t = this.getWebDavPath(e, !0), n = this.getFullUrl(t), r = await this.propFind(t);
|
|
1081
|
+
r = r.filter((e) => e.id !== n), yield r;
|
|
1082
|
+
}
|
|
1083
|
+
async get(e) {
|
|
1084
|
+
let t = this.getWebDavPath(e, !1);
|
|
1085
|
+
return this.request(t, { responseType: "blob" });
|
|
1086
|
+
}
|
|
1087
|
+
async remove(e) {
|
|
1088
|
+
let t = this.getWebDavPath(e, !1);
|
|
1089
|
+
await this.request(t, {
|
|
1090
|
+
method: "DELETE",
|
|
1091
|
+
responseType: "blob"
|
|
1092
|
+
});
|
|
1093
|
+
}
|
|
1094
|
+
async put(e, t) {
|
|
1095
|
+
let n = this.getWebDavPath(e, !0) || [this.getWebDavPath(e.parent, !0), e.name || ""].filter(Boolean).join("/");
|
|
1096
|
+
if (!n) throw Error("Invalid path");
|
|
1097
|
+
return await this.request(n, {
|
|
1098
|
+
method: "PUT",
|
|
1099
|
+
headers: { "Content-Type": "application/octet-stream" },
|
|
1100
|
+
body: t,
|
|
1101
|
+
responseType: "blob"
|
|
1102
|
+
}), {
|
|
1103
|
+
id: this.getFullUrl(n),
|
|
1104
|
+
name: n.slice(n.lastIndexOf("/") + 1),
|
|
1105
|
+
size: t.size,
|
|
1106
|
+
kind: "file",
|
|
1107
|
+
modifiedTime: (/* @__PURE__ */ new Date()).toISOString()
|
|
1108
|
+
};
|
|
1109
|
+
}
|
|
1110
|
+
}
|
|
1250
1111
|
};
|
|
1112
|
+
//#endregion
|
|
1113
|
+
//#region src/index.ts
|
|
1114
|
+
async function B(e, n, r, i) {
|
|
1115
|
+
let a = {};
|
|
1116
|
+
if (n.driveProvider !== "webdav") {
|
|
1117
|
+
if (!r || !i) throw Error("storage and handleOAuth2 are required for OAuth2 authorization");
|
|
1118
|
+
a.authorizer = t({
|
|
1119
|
+
redirectUrl: e.redirectUrl,
|
|
1120
|
+
...e.authProviders[n.auth.authProvider],
|
|
1121
|
+
storage: r
|
|
1122
|
+
}, {
|
|
1123
|
+
provider: n.auth.authProvider,
|
|
1124
|
+
user: n.auth.user
|
|
1125
|
+
}), a.handleOAuth2 = i;
|
|
1126
|
+
}
|
|
1127
|
+
let o = z[n.driveProvider];
|
|
1128
|
+
return new o(n.auth, a);
|
|
1129
|
+
}
|
|
1130
|
+
//#endregion
|
|
1131
|
+
export { N as AuthenticatedDriveBase, M as DriveBase, z as DriveProviders, B as connectDrive, P as unicodeReplacer, A as withDelay, j as withToken };
|