@usync/drive 0.0.1
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/README.md +7 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +1250 -0
- package/dist/providers/base.d.ts +33 -0
- package/dist/providers/dropbox.d.ts +23 -0
- package/dist/providers/googledrive.d.ts +26 -0
- package/dist/providers/index.d.ts +11 -0
- package/dist/providers/onedrive.d.ts +28 -0
- package/dist/providers/webdav.d.ts +37 -0
- package/dist/types.d.ts +34 -0
- package/dist/util.d.ts +1 -0
- package/package.json +28 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,1250 @@
|
|
|
1
|
+
import { ensureAccessToken as Te, getAuthorizer as Oe } from "@usync/oauth2";
|
|
2
|
+
import { XMLParser as Pe } from "fast-xml-parser";
|
|
3
|
+
var xe = /^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i, he = Math.ceil, G = Math.floor, j = "[BigNumber Error] ", ge = j + "Number primitive has more than 15 significant digits: ", H = 1e14, P = 14, pe = 9007199254740991, de = [1, 10, 100, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13], K = 1e7, B = 1e9;
|
|
4
|
+
function ye(m) {
|
|
5
|
+
var r, p, d, c = g.prototype = { constructor: g, toString: null, valueOf: null }, y = new g(1), v = 20, T = 4, x = -7, S = 21, L = -1e7, I = 1e7, b = !1, M = 1, Y = 0, oe = {
|
|
6
|
+
prefix: "",
|
|
7
|
+
groupSize: 3,
|
|
8
|
+
secondaryGroupSize: 0,
|
|
9
|
+
groupSeparator: ",",
|
|
10
|
+
decimalSeparator: ".",
|
|
11
|
+
fractionGroupSize: 0,
|
|
12
|
+
fractionGroupSeparator: " ",
|
|
13
|
+
// non-breaking space
|
|
14
|
+
suffix: ""
|
|
15
|
+
}, Q = "0123456789abcdefghijklmnopqrstuvwxyz", ae = !0;
|
|
16
|
+
function g(e, t) {
|
|
17
|
+
var n, f, s, a, h, i, o, u, l = this;
|
|
18
|
+
if (!(l instanceof g)) return new g(e, t);
|
|
19
|
+
if (t == null) {
|
|
20
|
+
if (e && e._isBigNumber === !0) {
|
|
21
|
+
l.s = e.s, !e.c || e.e > I ? l.c = l.e = null : e.e < L ? l.c = [l.e = 0] : (l.e = e.e, l.c = e.c.slice());
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
if ((i = typeof e == "number") && e * 0 == 0) {
|
|
25
|
+
if (l.s = 1 / e < 0 ? (e = -e, -1) : 1, e === ~~e) {
|
|
26
|
+
for (a = 0, h = e; h >= 10; h /= 10, a++) ;
|
|
27
|
+
a > I ? l.c = l.e = null : (l.e = a, l.c = [e]);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
u = String(e);
|
|
31
|
+
} else {
|
|
32
|
+
if (!xe.test(u = String(e))) return d(l, u, i);
|
|
33
|
+
l.s = u.charCodeAt(0) == 45 ? (u = u.slice(1), -1) : 1;
|
|
34
|
+
}
|
|
35
|
+
(a = u.indexOf(".")) > -1 && (u = u.replace(".", "")), (h = u.search(/e/i)) > 0 ? (a < 0 && (a = h), a += +u.slice(h + 1), u = u.substring(0, h)) : a < 0 && (a = u.length);
|
|
36
|
+
} else {
|
|
37
|
+
if (_(t, 2, Q.length, "Base"), t == 10 && ae)
|
|
38
|
+
return l = new g(e), F(l, v + l.e + 1, T);
|
|
39
|
+
if (u = String(e), i = typeof e == "number") {
|
|
40
|
+
if (e * 0 != 0) return d(l, u, i, t);
|
|
41
|
+
if (l.s = 1 / e < 0 ? (u = u.slice(1), -1) : 1, g.DEBUG && u.replace(/^0\.0*|\./, "").length > 15)
|
|
42
|
+
throw Error(ge + e);
|
|
43
|
+
} else
|
|
44
|
+
l.s = u.charCodeAt(0) === 45 ? (u = u.slice(1), -1) : 1;
|
|
45
|
+
for (n = Q.slice(0, t), a = h = 0, o = u.length; h < o; h++)
|
|
46
|
+
if (n.indexOf(f = u.charAt(h)) < 0) {
|
|
47
|
+
if (f == ".") {
|
|
48
|
+
if (h > a) {
|
|
49
|
+
a = o;
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
} else if (!s && (u == u.toUpperCase() && (u = u.toLowerCase()) || u == u.toLowerCase() && (u = u.toUpperCase()))) {
|
|
53
|
+
s = !0, h = -1, a = 0;
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
return d(l, String(e), i, t);
|
|
57
|
+
}
|
|
58
|
+
i = !1, u = p(u, t, 10, l.s), (a = u.indexOf(".")) > -1 ? u = u.replace(".", "") : a = u.length;
|
|
59
|
+
}
|
|
60
|
+
for (h = 0; u.charCodeAt(h) === 48; h++) ;
|
|
61
|
+
for (o = u.length; u.charCodeAt(--o) === 48; ) ;
|
|
62
|
+
if (u = u.slice(h, ++o)) {
|
|
63
|
+
if (o -= h, i && g.DEBUG && o > 15 && (e > pe || e !== G(e)))
|
|
64
|
+
throw Error(ge + l.s * e);
|
|
65
|
+
if ((a = a - h - 1) > I)
|
|
66
|
+
l.c = l.e = null;
|
|
67
|
+
else if (a < L)
|
|
68
|
+
l.c = [l.e = 0];
|
|
69
|
+
else {
|
|
70
|
+
if (l.e = a, l.c = [], h = (a + 1) % P, a < 0 && (h += P), h < o) {
|
|
71
|
+
for (h && l.c.push(+u.slice(0, h)), o -= P; h < o; )
|
|
72
|
+
l.c.push(+u.slice(h, h += P));
|
|
73
|
+
h = P - (u = u.slice(h)).length;
|
|
74
|
+
} else
|
|
75
|
+
h -= o;
|
|
76
|
+
for (; h--; u += "0") ;
|
|
77
|
+
l.c.push(+u);
|
|
78
|
+
}
|
|
79
|
+
} else
|
|
80
|
+
l.c = [l.e = 0];
|
|
81
|
+
}
|
|
82
|
+
g.clone = ye, g.ROUND_UP = 0, g.ROUND_DOWN = 1, g.ROUND_CEIL = 2, g.ROUND_FLOOR = 3, g.ROUND_HALF_UP = 4, g.ROUND_HALF_DOWN = 5, g.ROUND_HALF_EVEN = 6, g.ROUND_HALF_CEIL = 7, g.ROUND_HALF_FLOOR = 8, g.EUCLID = 9, g.config = g.set = function(e) {
|
|
83
|
+
var t, n;
|
|
84
|
+
if (e != null)
|
|
85
|
+
if (typeof e == "object") {
|
|
86
|
+
if (e.hasOwnProperty(t = "DECIMAL_PLACES") && (n = e[t], _(n, 0, B, t), v = n), e.hasOwnProperty(t = "ROUNDING_MODE") && (n = e[t], _(n, 0, 8, t), T = n), e.hasOwnProperty(t = "EXPONENTIAL_AT") && (n = e[t], n && n.pop ? (_(n[0], -B, 0, t), _(n[1], 0, B, t), x = n[0], S = n[1]) : (_(n, -B, B, t), x = -(S = n < 0 ? -n : n))), e.hasOwnProperty(t = "RANGE"))
|
|
87
|
+
if (n = e[t], n && n.pop)
|
|
88
|
+
_(n[0], -B, -1, t), _(n[1], 1, B, t), L = n[0], I = n[1];
|
|
89
|
+
else if (_(n, -B, B, t), n)
|
|
90
|
+
L = -(I = n < 0 ? -n : n);
|
|
91
|
+
else
|
|
92
|
+
throw Error(j + t + " cannot be zero: " + n);
|
|
93
|
+
if (e.hasOwnProperty(t = "CRYPTO"))
|
|
94
|
+
if (n = e[t], n === !!n)
|
|
95
|
+
if (n)
|
|
96
|
+
if (typeof crypto < "u" && crypto && (crypto.getRandomValues || crypto.randomBytes))
|
|
97
|
+
b = n;
|
|
98
|
+
else
|
|
99
|
+
throw b = !n, Error(j + "crypto unavailable");
|
|
100
|
+
else
|
|
101
|
+
b = n;
|
|
102
|
+
else
|
|
103
|
+
throw Error(j + t + " not true or false: " + n);
|
|
104
|
+
if (e.hasOwnProperty(t = "MODULO_MODE") && (n = e[t], _(n, 0, 9, t), M = n), e.hasOwnProperty(t = "POW_PRECISION") && (n = e[t], _(n, 0, B, t), Y = n), e.hasOwnProperty(t = "FORMAT"))
|
|
105
|
+
if (n = e[t], typeof n == "object") oe = n;
|
|
106
|
+
else throw Error(j + t + " not an object: " + n);
|
|
107
|
+
if (e.hasOwnProperty(t = "ALPHABET"))
|
|
108
|
+
if (n = e[t], typeof n == "string" && !/^.?$|[+\-.\s]|(.).*\1/.test(n))
|
|
109
|
+
ae = n.slice(0, 10) == "0123456789", Q = n;
|
|
110
|
+
else
|
|
111
|
+
throw Error(j + t + " invalid: " + n);
|
|
112
|
+
} else
|
|
113
|
+
throw Error(j + "Object expected: " + e);
|
|
114
|
+
return {
|
|
115
|
+
DECIMAL_PLACES: v,
|
|
116
|
+
ROUNDING_MODE: T,
|
|
117
|
+
EXPONENTIAL_AT: [x, S],
|
|
118
|
+
RANGE: [L, I],
|
|
119
|
+
CRYPTO: b,
|
|
120
|
+
MODULO_MODE: M,
|
|
121
|
+
POW_PRECISION: Y,
|
|
122
|
+
FORMAT: oe,
|
|
123
|
+
ALPHABET: Q
|
|
124
|
+
};
|
|
125
|
+
}, g.isBigNumber = function(e) {
|
|
126
|
+
if (!e || e._isBigNumber !== !0) return !1;
|
|
127
|
+
if (!g.DEBUG) return !0;
|
|
128
|
+
var t, n, f = e.c, s = e.e, a = e.s;
|
|
129
|
+
e: if ({}.toString.call(f) == "[object Array]") {
|
|
130
|
+
if ((a === 1 || a === -1) && s >= -B && s <= B && s === G(s)) {
|
|
131
|
+
if (f[0] === 0) {
|
|
132
|
+
if (s === 0 && f.length === 1) return !0;
|
|
133
|
+
break e;
|
|
134
|
+
}
|
|
135
|
+
if (t = (s + 1) % P, t < 1 && (t += P), String(f[0]).length == t) {
|
|
136
|
+
for (t = 0; t < f.length; t++)
|
|
137
|
+
if (n = f[t], n < 0 || n >= H || n !== G(n)) break e;
|
|
138
|
+
if (n !== 0) return !0;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
} else if (f === null && s === null && (a === null || a === 1 || a === -1))
|
|
142
|
+
return !0;
|
|
143
|
+
throw Error(j + "Invalid BigNumber: " + e);
|
|
144
|
+
}, g.maximum = g.max = function() {
|
|
145
|
+
return we(arguments, -1);
|
|
146
|
+
}, g.minimum = g.min = function() {
|
|
147
|
+
return we(arguments, 1);
|
|
148
|
+
}, g.random = (function() {
|
|
149
|
+
var e = 9007199254740992, t = Math.random() * e & 2097151 ? function() {
|
|
150
|
+
return G(Math.random() * e);
|
|
151
|
+
} : function() {
|
|
152
|
+
return (Math.random() * 1073741824 | 0) * 8388608 + (Math.random() * 8388608 | 0);
|
|
153
|
+
};
|
|
154
|
+
return function(n) {
|
|
155
|
+
var f, s, a, h, i, o = 0, u = [], l = new g(y);
|
|
156
|
+
if (n == null ? n = v : _(n, 0, B), h = he(n / P), b)
|
|
157
|
+
if (crypto.getRandomValues) {
|
|
158
|
+
for (f = crypto.getRandomValues(new Uint32Array(h *= 2)); o < h; )
|
|
159
|
+
i = f[o] * 131072 + (f[o + 1] >>> 11), i >= 9e15 ? (s = crypto.getRandomValues(new Uint32Array(2)), f[o] = s[0], f[o + 1] = s[1]) : (u.push(i % 1e14), o += 2);
|
|
160
|
+
o = h / 2;
|
|
161
|
+
} else if (crypto.randomBytes) {
|
|
162
|
+
for (f = crypto.randomBytes(h *= 7); o < h; )
|
|
163
|
+
i = (f[o] & 31) * 281474976710656 + f[o + 1] * 1099511627776 + f[o + 2] * 4294967296 + f[o + 3] * 16777216 + (f[o + 4] << 16) + (f[o + 5] << 8) + f[o + 6], i >= 9e15 ? crypto.randomBytes(7).copy(f, o) : (u.push(i % 1e14), o += 7);
|
|
164
|
+
o = h / 7;
|
|
165
|
+
} else
|
|
166
|
+
throw b = !1, Error(j + "crypto unavailable");
|
|
167
|
+
if (!b)
|
|
168
|
+
for (; o < h; )
|
|
169
|
+
i = t(), i < 9e15 && (u[o++] = i % 1e14);
|
|
170
|
+
for (h = u[--o], n %= P, h && n && (i = de[P - n], u[o] = G(h / i) * i); u[o] === 0; u.pop(), o--) ;
|
|
171
|
+
if (o < 0)
|
|
172
|
+
u = [a = 0];
|
|
173
|
+
else {
|
|
174
|
+
for (a = -1; u[0] === 0; u.splice(0, 1), a -= P) ;
|
|
175
|
+
for (o = 1, i = u[0]; i >= 10; i /= 10, o++) ;
|
|
176
|
+
o < P && (a -= P - o);
|
|
177
|
+
}
|
|
178
|
+
return l.e = a, l.c = u, l;
|
|
179
|
+
};
|
|
180
|
+
})(), g.sum = function() {
|
|
181
|
+
for (var e = 1, t = arguments, n = new g(t[0]); e < t.length; ) n = n.plus(t[e++]);
|
|
182
|
+
return n;
|
|
183
|
+
}, p = /* @__PURE__ */ (function() {
|
|
184
|
+
var e = "0123456789";
|
|
185
|
+
function t(n, f, s, a) {
|
|
186
|
+
for (var h, i = [0], o, u = 0, l = n.length; u < l; ) {
|
|
187
|
+
for (o = i.length; o--; i[o] *= f) ;
|
|
188
|
+
for (i[0] += a.indexOf(n.charAt(u++)), h = 0; h < i.length; h++)
|
|
189
|
+
i[h] > s - 1 && (i[h + 1] == null && (i[h + 1] = 0), i[h + 1] += i[h] / s | 0, i[h] %= s);
|
|
190
|
+
}
|
|
191
|
+
return i.reverse();
|
|
192
|
+
}
|
|
193
|
+
return function(n, f, s, a, h) {
|
|
194
|
+
var i, o, u, l, w, E, O, D, q = n.indexOf("."), k = v, N = T;
|
|
195
|
+
for (q >= 0 && (l = Y, Y = 0, n = n.replace(".", ""), D = new g(f), E = D.pow(n.length - q), Y = l, D.c = t(
|
|
196
|
+
J($(E.c), E.e, "0"),
|
|
197
|
+
10,
|
|
198
|
+
s,
|
|
199
|
+
e
|
|
200
|
+
), D.e = D.c.length), O = t(n, f, s, h ? (i = Q, e) : (i = e, Q)), u = l = O.length; O[--l] == 0; O.pop()) ;
|
|
201
|
+
if (!O[0]) return i.charAt(0);
|
|
202
|
+
if (q < 0 ? --u : (E.c = O, E.e = u, E.s = a, E = r(E, D, k, N, s), O = E.c, w = E.r, u = E.e), o = u + k + 1, q = O[o], l = s / 2, w = w || o < 0 || O[o + 1] != null, w = N < 4 ? (q != null || w) && (N == 0 || N == (E.s < 0 ? 3 : 2)) : q > l || q == l && (N == 4 || w || N == 6 && O[o - 1] & 1 || N == (E.s < 0 ? 8 : 7)), o < 1 || !O[0])
|
|
203
|
+
n = w ? J(i.charAt(1), -k, i.charAt(0)) : i.charAt(0);
|
|
204
|
+
else {
|
|
205
|
+
if (O.length = o, w)
|
|
206
|
+
for (--s; ++O[--o] > s; )
|
|
207
|
+
O[o] = 0, o || (++u, O = [1].concat(O));
|
|
208
|
+
for (l = O.length; !O[--l]; ) ;
|
|
209
|
+
for (q = 0, n = ""; q <= l; n += i.charAt(O[q++])) ;
|
|
210
|
+
n = J(n, u, i.charAt(0));
|
|
211
|
+
}
|
|
212
|
+
return n;
|
|
213
|
+
};
|
|
214
|
+
})(), r = /* @__PURE__ */ (function() {
|
|
215
|
+
function e(f, s, a) {
|
|
216
|
+
var h, i, o, u, l = 0, w = f.length, E = s % K, O = s / K | 0;
|
|
217
|
+
for (f = f.slice(); w--; )
|
|
218
|
+
o = f[w] % K, u = f[w] / K | 0, h = O * o + u * E, i = E * o + h % K * K + l, l = (i / a | 0) + (h / K | 0) + O * u, f[w] = i % a;
|
|
219
|
+
return l && (f = [l].concat(f)), f;
|
|
220
|
+
}
|
|
221
|
+
function t(f, s, a, h) {
|
|
222
|
+
var i, o;
|
|
223
|
+
if (a != h)
|
|
224
|
+
o = a > h ? 1 : -1;
|
|
225
|
+
else
|
|
226
|
+
for (i = o = 0; i < a; i++)
|
|
227
|
+
if (f[i] != s[i]) {
|
|
228
|
+
o = f[i] > s[i] ? 1 : -1;
|
|
229
|
+
break;
|
|
230
|
+
}
|
|
231
|
+
return o;
|
|
232
|
+
}
|
|
233
|
+
function n(f, s, a, h) {
|
|
234
|
+
for (var i = 0; a--; )
|
|
235
|
+
f[a] -= i, i = f[a] < s[a] ? 1 : 0, f[a] = i * h + f[a] - s[a];
|
|
236
|
+
for (; !f[0] && f.length > 1; f.splice(0, 1)) ;
|
|
237
|
+
}
|
|
238
|
+
return function(f, s, a, h, i) {
|
|
239
|
+
var o, u, l, w, E, O, D, q, k, N, A, R, te, ce, ue, X, ee, C = f.s == s.s ? 1 : -1, z = f.c, U = s.c;
|
|
240
|
+
if (!z || !z[0] || !U || !U[0])
|
|
241
|
+
return new g(
|
|
242
|
+
// Return NaN if either NaN, or both Infinity or 0.
|
|
243
|
+
!f.s || !s.s || (z ? U && z[0] == U[0] : !U) ? NaN : (
|
|
244
|
+
// Return ±0 if x is ±0 or y is ±Infinity, or return ±Infinity as y is ±0.
|
|
245
|
+
z && z[0] == 0 || !U ? C * 0 : C / 0
|
|
246
|
+
)
|
|
247
|
+
);
|
|
248
|
+
for (q = new g(C), k = q.c = [], u = f.e - s.e, C = a + u + 1, i || (i = H, u = W(f.e / P) - W(s.e / P), C = C / P | 0), l = 0; U[l] == (z[l] || 0); l++) ;
|
|
249
|
+
if (U[l] > (z[l] || 0) && u--, C < 0)
|
|
250
|
+
k.push(1), w = !0;
|
|
251
|
+
else {
|
|
252
|
+
for (ce = z.length, X = U.length, l = 0, C += 2, E = G(i / (U[0] + 1)), E > 1 && (U = e(U, E, i), z = e(z, E, i), X = U.length, ce = z.length), te = X, N = z.slice(0, X), A = N.length; A < X; N[A++] = 0) ;
|
|
253
|
+
ee = U.slice(), ee = [0].concat(ee), ue = U[0], U[1] >= i / 2 && ue++;
|
|
254
|
+
do {
|
|
255
|
+
if (E = 0, o = t(U, N, X, A), o < 0) {
|
|
256
|
+
if (R = N[0], X != A && (R = R * i + (N[1] || 0)), E = G(R / ue), E > 1)
|
|
257
|
+
for (E >= i && (E = i - 1), O = e(U, E, i), D = O.length, A = N.length; t(O, N, D, A) == 1; )
|
|
258
|
+
E--, n(O, X < D ? ee : U, D, i), D = O.length, o = 1;
|
|
259
|
+
else
|
|
260
|
+
E == 0 && (o = E = 1), O = U.slice(), D = O.length;
|
|
261
|
+
if (D < A && (O = [0].concat(O)), n(N, O, A, i), A = N.length, o == -1)
|
|
262
|
+
for (; t(U, N, X, A) < 1; )
|
|
263
|
+
E++, n(N, X < A ? ee : U, A, i), A = N.length;
|
|
264
|
+
} else o === 0 && (E++, N = [0]);
|
|
265
|
+
k[l++] = E, N[0] ? N[A++] = z[te] || 0 : (N = [z[te]], A = 1);
|
|
266
|
+
} while ((te++ < ce || N[0] != null) && C--);
|
|
267
|
+
w = N[0] != null, k[0] || k.splice(0, 1);
|
|
268
|
+
}
|
|
269
|
+
if (i == H) {
|
|
270
|
+
for (l = 1, C = k[0]; C >= 10; C /= 10, l++) ;
|
|
271
|
+
F(q, a + (q.e = l + u * P - 1) + 1, h, w);
|
|
272
|
+
} else
|
|
273
|
+
q.e = u, q.r = +w;
|
|
274
|
+
return q;
|
|
275
|
+
};
|
|
276
|
+
})();
|
|
277
|
+
function le(e, t, n, f) {
|
|
278
|
+
var s, a, h, i, o;
|
|
279
|
+
if (n == null ? n = T : _(n, 0, 8), !e.c) return e.toString();
|
|
280
|
+
if (s = e.c[0], h = e.e, t == null)
|
|
281
|
+
o = $(e.c), o = f == 1 || f == 2 && (h <= x || h >= S) ? ne(o, h) : J(o, h, "0");
|
|
282
|
+
else if (e = F(new g(e), t, n), a = e.e, o = $(e.c), i = o.length, f == 1 || f == 2 && (t <= a || a <= x)) {
|
|
283
|
+
for (; i < t; o += "0", i++) ;
|
|
284
|
+
o = ne(o, a);
|
|
285
|
+
} else if (t -= h + (f === 2 && a > h), o = J(o, a, "0"), a + 1 > i) {
|
|
286
|
+
if (--t > 0) for (o += "."; t--; o += "0") ;
|
|
287
|
+
} else if (t += a - i, t > 0)
|
|
288
|
+
for (a + 1 == i && (o += "."); t--; o += "0") ;
|
|
289
|
+
return e.s < 0 && s ? "-" + o : o;
|
|
290
|
+
}
|
|
291
|
+
function we(e, t) {
|
|
292
|
+
for (var n, f, s = 1, a = new g(e[0]); s < e.length; s++)
|
|
293
|
+
f = new g(e[s]), (!f.s || (n = Z(a, f)) === t || n === 0 && a.s === t) && (a = f);
|
|
294
|
+
return a;
|
|
295
|
+
}
|
|
296
|
+
function fe(e, t, n) {
|
|
297
|
+
for (var f = 1, s = t.length; !t[--s]; t.pop()) ;
|
|
298
|
+
for (s = t[0]; s >= 10; s /= 10, f++) ;
|
|
299
|
+
return (n = f + n * P - 1) > I ? e.c = e.e = null : n < L ? e.c = [e.e = 0] : (e.e = n, e.c = t), e;
|
|
300
|
+
}
|
|
301
|
+
d = /* @__PURE__ */ (function() {
|
|
302
|
+
var e = /^(-?)0([xbo])(?=\w[\w.]*$)/i, t = /^([^.]+)\.$/, n = /^\.([^.]+)$/, f = /^-?(Infinity|NaN)$/, s = /^\s*\+(?=[\w.])|^\s+|\s+$/g;
|
|
303
|
+
return function(a, h, i, o) {
|
|
304
|
+
var u, l = i ? h : h.replace(s, "");
|
|
305
|
+
if (f.test(l))
|
|
306
|
+
a.s = isNaN(l) ? null : l < 0 ? -1 : 1;
|
|
307
|
+
else {
|
|
308
|
+
if (!i && (l = l.replace(e, function(w, E, O) {
|
|
309
|
+
return u = (O = O.toLowerCase()) == "x" ? 16 : O == "b" ? 2 : 8, !o || o == u ? E : w;
|
|
310
|
+
}), o && (u = o, l = l.replace(t, "$1").replace(n, "0.$1")), h != l))
|
|
311
|
+
return new g(l, u);
|
|
312
|
+
if (g.DEBUG)
|
|
313
|
+
throw Error(j + "Not a" + (o ? " base " + o : "") + " number: " + h);
|
|
314
|
+
a.s = null;
|
|
315
|
+
}
|
|
316
|
+
a.c = a.e = null;
|
|
317
|
+
};
|
|
318
|
+
})();
|
|
319
|
+
function F(e, t, n, f) {
|
|
320
|
+
var s, a, h, i, o, u, l, w = e.c, E = de;
|
|
321
|
+
if (w) {
|
|
322
|
+
e: {
|
|
323
|
+
for (s = 1, i = w[0]; i >= 10; i /= 10, s++) ;
|
|
324
|
+
if (a = t - s, a < 0)
|
|
325
|
+
a += P, h = t, o = w[u = 0], l = G(o / E[s - h - 1] % 10);
|
|
326
|
+
else if (u = he((a + 1) / P), u >= w.length)
|
|
327
|
+
if (f) {
|
|
328
|
+
for (; w.length <= u; w.push(0)) ;
|
|
329
|
+
o = l = 0, s = 1, a %= P, h = a - P + 1;
|
|
330
|
+
} else
|
|
331
|
+
break e;
|
|
332
|
+
else {
|
|
333
|
+
for (o = i = w[u], s = 1; i >= 10; i /= 10, s++) ;
|
|
334
|
+
a %= P, h = a - P + s, l = h < 0 ? 0 : G(o / E[s - h - 1] % 10);
|
|
335
|
+
}
|
|
336
|
+
if (f = f || t < 0 || // Are there any non-zero digits after the rounding digit?
|
|
337
|
+
// The expression n % pows10[d - j - 1] returns all digits of n to the right
|
|
338
|
+
// of the digit at j, e.g. if n is 908714 and j is 2, the expression gives 714.
|
|
339
|
+
w[u + 1] != null || (h < 0 ? o : o % E[s - h - 1]), f = n < 4 ? (l || f) && (n == 0 || n == (e.s < 0 ? 3 : 2)) : l > 5 || l == 5 && (n == 4 || f || n == 6 && // Check whether the digit to the left of the rounding digit is odd.
|
|
340
|
+
(a > 0 ? h > 0 ? o / E[s - h] : 0 : w[u - 1]) % 10 & 1 || n == (e.s < 0 ? 8 : 7)), t < 1 || !w[0])
|
|
341
|
+
return w.length = 0, f ? (t -= e.e + 1, w[0] = E[(P - t % P) % P], e.e = -t || 0) : w[0] = e.e = 0, e;
|
|
342
|
+
if (a == 0 ? (w.length = u, i = 1, u--) : (w.length = u + 1, i = E[P - a], w[u] = h > 0 ? G(o / E[s - h] % E[h]) * i : 0), f)
|
|
343
|
+
for (; ; )
|
|
344
|
+
if (u == 0) {
|
|
345
|
+
for (a = 1, h = w[0]; h >= 10; h /= 10, a++) ;
|
|
346
|
+
for (h = w[0] += i, i = 1; h >= 10; h /= 10, i++) ;
|
|
347
|
+
a != i && (e.e++, w[0] == H && (w[0] = 1));
|
|
348
|
+
break;
|
|
349
|
+
} else {
|
|
350
|
+
if (w[u] += i, w[u] != H) break;
|
|
351
|
+
w[u--] = 0, i = 1;
|
|
352
|
+
}
|
|
353
|
+
for (a = w.length; w[--a] === 0; w.pop()) ;
|
|
354
|
+
}
|
|
355
|
+
e.e > I ? e.c = e.e = null : e.e < L && (e.c = [e.e = 0]);
|
|
356
|
+
}
|
|
357
|
+
return e;
|
|
358
|
+
}
|
|
359
|
+
function V(e) {
|
|
360
|
+
var t, n = e.e;
|
|
361
|
+
return n === null ? e.toString() : (t = $(e.c), t = n <= x || n >= S ? ne(t, n) : J(t, n, "0"), e.s < 0 ? "-" + t : t);
|
|
362
|
+
}
|
|
363
|
+
return c.absoluteValue = c.abs = function() {
|
|
364
|
+
var e = new g(this);
|
|
365
|
+
return e.s < 0 && (e.s = 1), e;
|
|
366
|
+
}, c.comparedTo = function(e, t) {
|
|
367
|
+
return Z(this, new g(e, t));
|
|
368
|
+
}, c.decimalPlaces = c.dp = function(e, t) {
|
|
369
|
+
var n, f, s, a = this;
|
|
370
|
+
if (e != null)
|
|
371
|
+
return _(e, 0, B), t == null ? t = T : _(t, 0, 8), F(new g(a), e + a.e + 1, t);
|
|
372
|
+
if (!(n = a.c)) return null;
|
|
373
|
+
if (f = ((s = n.length - 1) - W(this.e / P)) * P, s = n[s]) for (; s % 10 == 0; s /= 10, f--) ;
|
|
374
|
+
return f < 0 && (f = 0), f;
|
|
375
|
+
}, c.dividedBy = c.div = function(e, t) {
|
|
376
|
+
return r(this, new g(e, t), v, T);
|
|
377
|
+
}, c.dividedToIntegerBy = c.idiv = function(e, t) {
|
|
378
|
+
return r(this, new g(e, t), 0, 1);
|
|
379
|
+
}, c.exponentiatedBy = c.pow = function(e, t) {
|
|
380
|
+
var n, f, s, a, h, i, o, u, l, w = this;
|
|
381
|
+
if (e = new g(e), e.c && !e.isInteger())
|
|
382
|
+
throw Error(j + "Exponent not an integer: " + V(e));
|
|
383
|
+
if (t != null && (t = new g(t)), i = e.e > 14, !w.c || !w.c[0] || w.c[0] == 1 && !w.e && w.c.length == 1 || !e.c || !e.c[0])
|
|
384
|
+
return l = new g(Math.pow(+V(w), i ? e.s * (2 - re(e)) : +V(e))), t ? l.mod(t) : l;
|
|
385
|
+
if (o = e.s < 0, t) {
|
|
386
|
+
if (t.c ? !t.c[0] : !t.s) return new g(NaN);
|
|
387
|
+
f = !o && w.isInteger() && t.isInteger(), f && (w = w.mod(t));
|
|
388
|
+
} else {
|
|
389
|
+
if (e.e > 9 && (w.e > 0 || w.e < -1 || (w.e == 0 ? w.c[0] > 1 || i && w.c[1] >= 24e7 : w.c[0] < 8e13 || i && w.c[0] <= 9999975e7)))
|
|
390
|
+
return a = w.s < 0 && re(e) ? -0 : 0, w.e > -1 && (a = 1 / a), new g(o ? 1 / a : a);
|
|
391
|
+
Y && (a = he(Y / P + 2));
|
|
392
|
+
}
|
|
393
|
+
for (i ? (n = new g(0.5), o && (e.s = 1), u = re(e)) : (s = Math.abs(+V(e)), u = s % 2), l = new g(y); ; ) {
|
|
394
|
+
if (u) {
|
|
395
|
+
if (l = l.times(w), !l.c) break;
|
|
396
|
+
a ? l.c.length > a && (l.c.length = a) : f && (l = l.mod(t));
|
|
397
|
+
}
|
|
398
|
+
if (s) {
|
|
399
|
+
if (s = G(s / 2), s === 0) break;
|
|
400
|
+
u = s % 2;
|
|
401
|
+
} else if (e = e.times(n), F(e, e.e + 1, 1), e.e > 14)
|
|
402
|
+
u = re(e);
|
|
403
|
+
else {
|
|
404
|
+
if (s = +V(e), s === 0) break;
|
|
405
|
+
u = s % 2;
|
|
406
|
+
}
|
|
407
|
+
w = w.times(w), a ? w.c && w.c.length > a && (w.c.length = a) : f && (w = w.mod(t));
|
|
408
|
+
}
|
|
409
|
+
return f ? l : (o && (l = y.div(l)), t ? l.mod(t) : a ? F(l, Y, T, h) : l);
|
|
410
|
+
}, c.integerValue = function(e) {
|
|
411
|
+
var t = new g(this);
|
|
412
|
+
return e == null ? e = T : _(e, 0, 8), F(t, t.e + 1, e);
|
|
413
|
+
}, c.isEqualTo = c.eq = function(e, t) {
|
|
414
|
+
return Z(this, new g(e, t)) === 0;
|
|
415
|
+
}, c.isFinite = function() {
|
|
416
|
+
return !!this.c;
|
|
417
|
+
}, c.isGreaterThan = c.gt = function(e, t) {
|
|
418
|
+
return Z(this, new g(e, t)) > 0;
|
|
419
|
+
}, c.isGreaterThanOrEqualTo = c.gte = function(e, t) {
|
|
420
|
+
return (t = Z(this, new g(e, t))) === 1 || t === 0;
|
|
421
|
+
}, c.isInteger = function() {
|
|
422
|
+
return !!this.c && W(this.e / P) > this.c.length - 2;
|
|
423
|
+
}, c.isLessThan = c.lt = function(e, t) {
|
|
424
|
+
return Z(this, new g(e, t)) < 0;
|
|
425
|
+
}, c.isLessThanOrEqualTo = c.lte = function(e, t) {
|
|
426
|
+
return (t = Z(this, new g(e, t))) === -1 || t === 0;
|
|
427
|
+
}, c.isNaN = function() {
|
|
428
|
+
return !this.s;
|
|
429
|
+
}, c.isNegative = function() {
|
|
430
|
+
return this.s < 0;
|
|
431
|
+
}, c.isPositive = function() {
|
|
432
|
+
return this.s > 0;
|
|
433
|
+
}, c.isZero = function() {
|
|
434
|
+
return !!this.c && this.c[0] == 0;
|
|
435
|
+
}, c.minus = function(e, t) {
|
|
436
|
+
var n, f, s, a, h = this, i = h.s;
|
|
437
|
+
if (e = new g(e, t), t = e.s, !i || !t) return new g(NaN);
|
|
438
|
+
if (i != t)
|
|
439
|
+
return e.s = -t, h.plus(e);
|
|
440
|
+
var o = h.e / P, u = e.e / P, l = h.c, w = e.c;
|
|
441
|
+
if (!o || !u) {
|
|
442
|
+
if (!l || !w) return l ? (e.s = -t, e) : new g(w ? h : NaN);
|
|
443
|
+
if (!l[0] || !w[0])
|
|
444
|
+
return w[0] ? (e.s = -t, e) : new g(l[0] ? h : (
|
|
445
|
+
// IEEE 754 (2008) 6.3: n - n = -0 when rounding to -Infinity
|
|
446
|
+
T == 3 ? -0 : 0
|
|
447
|
+
));
|
|
448
|
+
}
|
|
449
|
+
if (o = W(o), u = W(u), l = l.slice(), i = o - u) {
|
|
450
|
+
for ((a = i < 0) ? (i = -i, s = l) : (u = o, s = w), s.reverse(), t = i; t--; s.push(0)) ;
|
|
451
|
+
s.reverse();
|
|
452
|
+
} else
|
|
453
|
+
for (f = (a = (i = l.length) < (t = w.length)) ? i : t, i = t = 0; t < f; t++)
|
|
454
|
+
if (l[t] != w[t]) {
|
|
455
|
+
a = l[t] < w[t];
|
|
456
|
+
break;
|
|
457
|
+
}
|
|
458
|
+
if (a && (s = l, l = w, w = s, e.s = -e.s), t = (f = w.length) - (n = l.length), t > 0) for (; t--; l[n++] = 0) ;
|
|
459
|
+
for (t = H - 1; f > i; ) {
|
|
460
|
+
if (l[--f] < w[f]) {
|
|
461
|
+
for (n = f; n && !l[--n]; l[n] = t) ;
|
|
462
|
+
--l[n], l[f] += H;
|
|
463
|
+
}
|
|
464
|
+
l[f] -= w[f];
|
|
465
|
+
}
|
|
466
|
+
for (; l[0] == 0; l.splice(0, 1), --u) ;
|
|
467
|
+
return l[0] ? fe(e, l, u) : (e.s = T == 3 ? -1 : 1, e.c = [e.e = 0], e);
|
|
468
|
+
}, c.modulo = c.mod = function(e, t) {
|
|
469
|
+
var n, f, s = this;
|
|
470
|
+
return e = new g(e, t), !s.c || !e.s || e.c && !e.c[0] ? new g(NaN) : !e.c || s.c && !s.c[0] ? new g(s) : (M == 9 ? (f = e.s, e.s = 1, n = r(s, e, 0, 3), e.s = f, n.s *= f) : n = r(s, e, 0, M), e = s.minus(n.times(e)), !e.c[0] && M == 1 && (e.s = s.s), e);
|
|
471
|
+
}, c.multipliedBy = c.times = function(e, t) {
|
|
472
|
+
var n, f, s, a, h, i, o, u, l, w, E, O, D, q, k, N = this, A = N.c, R = (e = new g(e, t)).c;
|
|
473
|
+
if (!A || !R || !A[0] || !R[0])
|
|
474
|
+
return !N.s || !e.s || A && !A[0] && !R || R && !R[0] && !A ? e.c = e.e = e.s = null : (e.s *= N.s, !A || !R ? e.c = e.e = null : (e.c = [0], e.e = 0)), e;
|
|
475
|
+
for (f = W(N.e / P) + W(e.e / P), e.s *= N.s, o = A.length, w = R.length, o < w && (D = A, A = R, R = D, s = o, o = w, w = s), s = o + w, D = []; s--; D.push(0)) ;
|
|
476
|
+
for (q = H, k = K, s = w; --s >= 0; ) {
|
|
477
|
+
for (n = 0, E = R[s] % k, O = R[s] / k | 0, h = o, a = s + h; a > s; )
|
|
478
|
+
u = A[--h] % k, l = A[h] / k | 0, i = O * u + l * E, u = E * u + i % k * k + D[a] + n, n = (u / q | 0) + (i / k | 0) + O * l, D[a--] = u % q;
|
|
479
|
+
D[a] = n;
|
|
480
|
+
}
|
|
481
|
+
return n ? ++f : D.splice(0, 1), fe(e, D, f);
|
|
482
|
+
}, c.negated = function() {
|
|
483
|
+
var e = new g(this);
|
|
484
|
+
return e.s = -e.s || null, e;
|
|
485
|
+
}, c.plus = function(e, t) {
|
|
486
|
+
var n, f = this, s = f.s;
|
|
487
|
+
if (e = new g(e, t), t = e.s, !s || !t) return new g(NaN);
|
|
488
|
+
if (s != t)
|
|
489
|
+
return e.s = -t, f.minus(e);
|
|
490
|
+
var a = f.e / P, h = e.e / P, i = f.c, o = e.c;
|
|
491
|
+
if (!a || !h) {
|
|
492
|
+
if (!i || !o) return new g(s / 0);
|
|
493
|
+
if (!i[0] || !o[0]) return o[0] ? e : new g(i[0] ? f : s * 0);
|
|
494
|
+
}
|
|
495
|
+
if (a = W(a), h = W(h), i = i.slice(), s = a - h) {
|
|
496
|
+
for (s > 0 ? (h = a, n = o) : (s = -s, n = i), n.reverse(); s--; n.push(0)) ;
|
|
497
|
+
n.reverse();
|
|
498
|
+
}
|
|
499
|
+
for (s = i.length, t = o.length, s - t < 0 && (n = o, o = i, i = n, t = s), s = 0; t; )
|
|
500
|
+
s = (i[--t] = i[t] + o[t] + s) / H | 0, i[t] = H === i[t] ? 0 : i[t] % H;
|
|
501
|
+
return s && (i = [s].concat(i), ++h), fe(e, i, h);
|
|
502
|
+
}, c.precision = c.sd = function(e, t) {
|
|
503
|
+
var n, f, s, a = this;
|
|
504
|
+
if (e != null && e !== !!e)
|
|
505
|
+
return _(e, 1, B), t == null ? t = T : _(t, 0, 8), F(new g(a), e, t);
|
|
506
|
+
if (!(n = a.c)) return null;
|
|
507
|
+
if (s = n.length - 1, f = s * P + 1, s = n[s]) {
|
|
508
|
+
for (; s % 10 == 0; s /= 10, f--) ;
|
|
509
|
+
for (s = n[0]; s >= 10; s /= 10, f++) ;
|
|
510
|
+
}
|
|
511
|
+
return e && a.e + 1 > f && (f = a.e + 1), f;
|
|
512
|
+
}, c.shiftedBy = function(e) {
|
|
513
|
+
return _(e, -pe, pe), this.times("1e" + e);
|
|
514
|
+
}, c.squareRoot = c.sqrt = function() {
|
|
515
|
+
var e, t, n, f, s, a = this, h = a.c, i = a.s, o = a.e, u = v + 4, l = new g("0.5");
|
|
516
|
+
if (i !== 1 || !h || !h[0])
|
|
517
|
+
return new g(!i || i < 0 && (!h || h[0]) ? NaN : h ? a : 1 / 0);
|
|
518
|
+
if (i = Math.sqrt(+V(a)), i == 0 || i == 1 / 0 ? (t = $(h), (t.length + o) % 2 == 0 && (t += "0"), i = Math.sqrt(+t), o = W((o + 1) / 2) - (o < 0 || o % 2), i == 1 / 0 ? t = "5e" + o : (t = i.toExponential(), t = t.slice(0, t.indexOf("e") + 1) + o), n = new g(t)) : n = new g(i + ""), n.c[0]) {
|
|
519
|
+
for (o = n.e, i = o + u, i < 3 && (i = 0); ; )
|
|
520
|
+
if (s = n, n = l.times(s.plus(r(a, s, u, 1))), $(s.c).slice(0, i) === (t = $(n.c)).slice(0, i))
|
|
521
|
+
if (n.e < o && --i, t = t.slice(i - 3, i + 1), t == "9999" || !f && t == "4999") {
|
|
522
|
+
if (!f && (F(s, s.e + v + 2, 0), s.times(s).eq(a))) {
|
|
523
|
+
n = s;
|
|
524
|
+
break;
|
|
525
|
+
}
|
|
526
|
+
u += 4, i += 4, f = 1;
|
|
527
|
+
} else {
|
|
528
|
+
(!+t || !+t.slice(1) && t.charAt(0) == "5") && (F(n, n.e + v + 2, 1), e = !n.times(n).eq(a));
|
|
529
|
+
break;
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
return F(n, n.e + v + 1, T, e);
|
|
533
|
+
}, c.toExponential = function(e, t) {
|
|
534
|
+
return e != null && (_(e, 0, B), e++), le(this, e, t, 1);
|
|
535
|
+
}, c.toFixed = function(e, t) {
|
|
536
|
+
return e != null && (_(e, 0, B), e = e + this.e + 1), le(this, e, t);
|
|
537
|
+
}, c.toFormat = function(e, t, n) {
|
|
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;
|
|
575
|
+
}
|
|
576
|
+
function W(m) {
|
|
577
|
+
var r = m | 0;
|
|
578
|
+
return m > 0 || m === r ? r : r - 1;
|
|
579
|
+
}
|
|
580
|
+
function $(m) {
|
|
581
|
+
for (var r, p, d = 1, c = m.length, y = m[0] + ""; d < c; ) {
|
|
582
|
+
for (r = m[d++] + "", p = P - r.length; p--; r = "0" + r) ;
|
|
583
|
+
y += r;
|
|
584
|
+
}
|
|
585
|
+
for (c = y.length; y.charCodeAt(--c) === 48; ) ;
|
|
586
|
+
return y.slice(0, c + 1 || 1);
|
|
587
|
+
}
|
|
588
|
+
function Z(m, r) {
|
|
589
|
+
var p, d, c = m.c, y = r.c, v = m.s, T = r.s, x = m.e, S = r.e;
|
|
590
|
+
if (!v || !T) return null;
|
|
591
|
+
if (p = c && !c[0], d = y && !y[0], p || d) return p ? d ? 0 : -T : v;
|
|
592
|
+
if (v != T) return v;
|
|
593
|
+
if (p = v < 0, d = x == S, !c || !y) return d ? 0 : !c ^ p ? 1 : -1;
|
|
594
|
+
if (!d) return x > S ^ p ? 1 : -1;
|
|
595
|
+
for (T = (x = c.length) < (S = y.length) ? x : S, v = 0; v < T; v++) if (c[v] != y[v]) return c[v] > y[v] ^ p ? 1 : -1;
|
|
596
|
+
return x == S ? 0 : x > S ^ p ? 1 : -1;
|
|
597
|
+
}
|
|
598
|
+
function _(m, r, p, d) {
|
|
599
|
+
if (m < r || m > p || m !== G(m))
|
|
600
|
+
throw Error(j + (d || "Argument") + (typeof m == "number" ? m < r || m > p ? " out of range: " : " not an integer: " : " not a primitive number: ") + String(m));
|
|
601
|
+
}
|
|
602
|
+
function re(m) {
|
|
603
|
+
var r = m.c.length - 1;
|
|
604
|
+
return W(m.e / P) == r && m.c[r] % 2 != 0;
|
|
605
|
+
}
|
|
606
|
+
function ne(m, r) {
|
|
607
|
+
return (m.length > 1 ? m.charAt(0) + "." + m.slice(1) : m) + (r < 0 ? "e" : "e+") + r;
|
|
608
|
+
}
|
|
609
|
+
function J(m, r, p) {
|
|
610
|
+
var d, c;
|
|
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;
|
|
619
|
+
}
|
|
620
|
+
ye();
|
|
621
|
+
const me = "=", Ne = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
622
|
+
function De(m, r, p) {
|
|
623
|
+
let d = "", c = 0;
|
|
624
|
+
for (; c < m.length; ) {
|
|
625
|
+
const y = m[c++], v = m[c++], T = m[c++];
|
|
626
|
+
if (d += r[y >> 2], d += r[(y & 3) << 4 | (v || 0) >> 4], v == null ? d += me : d += r[(v & 15) << 2 | (T || 0) >> 6], T == null) {
|
|
627
|
+
d += me;
|
|
628
|
+
break;
|
|
629
|
+
}
|
|
630
|
+
d += r[T & 63];
|
|
631
|
+
}
|
|
632
|
+
return d;
|
|
633
|
+
}
|
|
634
|
+
function Ae(m) {
|
|
635
|
+
return De(m, Ne);
|
|
636
|
+
}
|
|
637
|
+
class ie extends Error {
|
|
638
|
+
constructor(r, p, d, c) {
|
|
639
|
+
super(r, { cause: c }), this.request = p, this.response = d;
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
function ve(m, r) {
|
|
643
|
+
const { json: p, timeout: d = 1e4, searchParams: c, ...y } = r || {}, v = new AbortController(), T = d ? setTimeout(() => v.abort(), d) : null, x = new Headers(y.headers);
|
|
644
|
+
p != null && (y.body = JSON.stringify(p), x.set("content-type", "application/json"));
|
|
645
|
+
const S = new URL(m);
|
|
646
|
+
c && new URLSearchParams(c).forEach((I, b) => {
|
|
647
|
+
S.searchParams.set(b, I);
|
|
648
|
+
});
|
|
649
|
+
async function L(I) {
|
|
650
|
+
let b;
|
|
651
|
+
try {
|
|
652
|
+
b = await fetch(S, {
|
|
653
|
+
...y,
|
|
654
|
+
headers: x,
|
|
655
|
+
signal: v.signal
|
|
656
|
+
});
|
|
657
|
+
const M = await I(b);
|
|
658
|
+
if (!b.ok)
|
|
659
|
+
throw new ie(
|
|
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;
|
|
761
|
+
}
|
|
762
|
+
class Ue extends se {
|
|
763
|
+
normalizeEntry(r) {
|
|
764
|
+
return {
|
|
765
|
+
kind: r[".tag"] === "file" ? "file" : "folder",
|
|
766
|
+
id: r.id,
|
|
767
|
+
name: r.name,
|
|
768
|
+
size: r.size || 0,
|
|
769
|
+
modifiedTime: r.server_modified || ""
|
|
770
|
+
};
|
|
771
|
+
}
|
|
772
|
+
getDropboxPath(r, p) {
|
|
773
|
+
if (r?.id) return `id:${r.id}`;
|
|
774
|
+
const d = r?.path;
|
|
775
|
+
if (d?.[0] === "/") return d;
|
|
776
|
+
if (
|
|
777
|
+
// Invalid path
|
|
778
|
+
d || // Empty path
|
|
779
|
+
!p
|
|
780
|
+
)
|
|
781
|
+
throw new Error("Invalid path");
|
|
782
|
+
return "";
|
|
783
|
+
}
|
|
784
|
+
async getAccount() {
|
|
785
|
+
const r = await this.request("https://api.dropboxapi.com/2/users/get_current_account", {
|
|
786
|
+
method: "POST",
|
|
787
|
+
responseType: "json"
|
|
788
|
+
});
|
|
789
|
+
return {
|
|
790
|
+
id: r.account_id,
|
|
791
|
+
name: r.name.display_name,
|
|
792
|
+
avatar: r.profile_photo_url
|
|
793
|
+
};
|
|
794
|
+
}
|
|
795
|
+
async mkdir(r) {
|
|
796
|
+
const p = [this.getDropboxPath(r.parent, !0), r.name].filter(Boolean).join("/"), d = await this.request("https://api.dropboxapi.com/2/files/create_folder_v2", {
|
|
797
|
+
method: "POST",
|
|
798
|
+
json: {
|
|
799
|
+
path: p
|
|
800
|
+
},
|
|
801
|
+
responseType: "json"
|
|
802
|
+
});
|
|
803
|
+
return this.normalizeEntry({
|
|
804
|
+
...d.metadata,
|
|
805
|
+
".tag": "folder"
|
|
806
|
+
});
|
|
807
|
+
}
|
|
808
|
+
async find(r) {
|
|
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
|
+
}
|
|
893
|
+
}
|
|
894
|
+
class ke extends se {
|
|
895
|
+
constructor() {
|
|
896
|
+
super(...arguments), this.baseUrl = "https://www.googleapis.com/drive/v3/", this.rootId = "appDataFolder";
|
|
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
|
+
}
|
|
1016
|
+
}
|
|
1017
|
+
class Be extends se {
|
|
1018
|
+
constructor() {
|
|
1019
|
+
super(...arguments), this.baseUrl = "https://graph.microsoft.com/v1.0/", this.root = "me/drive/special/approot";
|
|
1020
|
+
}
|
|
1021
|
+
// or 'me/drive/root' for a personal drive
|
|
1022
|
+
async getAccount() {
|
|
1023
|
+
const r = await this.request("/oidc/userinfo", { responseType: "json" });
|
|
1024
|
+
return {
|
|
1025
|
+
id: r.sub,
|
|
1026
|
+
name: r.givenname + " " + r.familyname,
|
|
1027
|
+
avatar: r.picture
|
|
1028
|
+
};
|
|
1029
|
+
}
|
|
1030
|
+
normalizeEntry(r) {
|
|
1031
|
+
return {
|
|
1032
|
+
id: r.id,
|
|
1033
|
+
name: r.name,
|
|
1034
|
+
size: r.size,
|
|
1035
|
+
kind: "file",
|
|
1036
|
+
modifiedTime: r.lastModifiedDateTime
|
|
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
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
const be = new Pe({
|
|
1098
|
+
ignoreAttributes: !1,
|
|
1099
|
+
removeNSPrefix: !0
|
|
1100
|
+
});
|
|
1101
|
+
class Re extends se {
|
|
1102
|
+
constructor(r, p) {
|
|
1103
|
+
super(r, p);
|
|
1104
|
+
let d = r.serverOptions?.baseUrl;
|
|
1105
|
+
if (!d) throw new Error("baseUrl is required");
|
|
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
|
+
}
|
|
1212
|
+
}
|
|
1213
|
+
const ze = {
|
|
1214
|
+
dropbox: Ue,
|
|
1215
|
+
googledrive: ke,
|
|
1216
|
+
onedrive: Be,
|
|
1217
|
+
webdav: Re
|
|
1218
|
+
};
|
|
1219
|
+
async function je(m, r, p, d) {
|
|
1220
|
+
let c = {};
|
|
1221
|
+
if (r.driveProvider !== "webdav") {
|
|
1222
|
+
if (!p || !d)
|
|
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);
|
|
1241
|
+
}
|
|
1242
|
+
export {
|
|
1243
|
+
se as AuthenticatedDriveBase,
|
|
1244
|
+
_e as DriveBase,
|
|
1245
|
+
ze as DriveProviders,
|
|
1246
|
+
je as connectDrive,
|
|
1247
|
+
qe as unicodeReplacer,
|
|
1248
|
+
Ee as withDelay,
|
|
1249
|
+
Ie as withToken
|
|
1250
|
+
};
|