@unicom-cloud/utils 0.1.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.
Files changed (69) hide show
  1. package/case-name/index.js +23 -0
  2. package/class-name/index.js +9 -0
  3. package/clipboard-copy/index.js +41 -0
  4. package/constant/address.js +5304 -0
  5. package/constant/chineseCharacters.js +4 -0
  6. package/constant/constellations.js +17 -0
  7. package/constant/domain.js +268 -0
  8. package/constant/identity.js +18 -0
  9. package/constant/index.js +6 -0
  10. package/constant/keyboardCode.js +105 -0
  11. package/constant/licensePlate.js +42 -0
  12. package/constant/name.js +666 -0
  13. package/constant/platform.js +20 -0
  14. package/constant/protocol.js +18 -0
  15. package/constant/ui.js +17 -0
  16. package/cookie/index.js +33 -0
  17. package/cookie/src/index.js +116 -0
  18. package/decimal/decimal.js +1070 -0
  19. package/decimal/index.js +5 -0
  20. package/event-emitter/index.js +57 -0
  21. package/file/fileToURL.js +26 -0
  22. package/file/index.js +6 -0
  23. package/file/saveAs.js +35 -0
  24. package/filesize/index.js +8 -0
  25. package/filesize/src/constants.js +71 -0
  26. package/filesize/src/filesize.js +88 -0
  27. package/index.js +47 -0
  28. package/invariant/index.js +21 -0
  29. package/is/index.js +137 -0
  30. package/math/index.js +34 -0
  31. package/md5/index.js +65 -0
  32. package/mock/MockWebSocket.js +117 -0
  33. package/mock/MockXMLHttpRequest.js +94 -0
  34. package/mock/index.js +8 -0
  35. package/normalize-wheel/ExecutionEnvironment.js +11 -0
  36. package/normalize-wheel/UserAgent_DEPRECATED.js +146 -0
  37. package/normalize-wheel/index.js +13 -0
  38. package/normalize-wheel/isEventSupported.js +33 -0
  39. package/nzh/cn.js +7 -0
  40. package/nzh/hk.js +7 -0
  41. package/nzh/index.js +4 -0
  42. package/nzh/nzh.js +22 -0
  43. package/nzh/src/autoGet.js +25 -0
  44. package/nzh/src/index.js +93 -0
  45. package/nzh/src/langs/cn_b.js +12 -0
  46. package/nzh/src/langs/cn_s.js +9 -0
  47. package/nzh/src/langs/hk_b.js +12 -0
  48. package/nzh/src/langs/hk_s.js +9 -0
  49. package/nzh/src/utils.js +71 -0
  50. package/objectKeysSort.js +7 -0
  51. package/package.json +1 -0
  52. package/random/address.js +32 -0
  53. package/random/constellation.js +8 -0
  54. package/random/image.js +20 -0
  55. package/random/index.js +63 -0
  56. package/random/licensePlate.js +12 -0
  57. package/random/name.js +25 -0
  58. package/random/number.js +15 -0
  59. package/random/text.js +117 -0
  60. package/random/time.js +8 -0
  61. package/random/web.js +37 -0
  62. package/screenfull/index.js +119 -0
  63. package/tree/index.js +87 -0
  64. package/turbo-stream/index.js +6 -0
  65. package/turbo-stream/src/decode.js +284 -0
  66. package/turbo-stream/src/encode.js +363 -0
  67. package/turbo-stream/src/shared.js +287 -0
  68. package/url-toolkit/index.js +8 -0
  69. package/url-toolkit/src/url-toolkit.js +74 -0
@@ -0,0 +1,284 @@
1
+ import { Deferred as M, TurboBlob as ie, TurboFile as fe, DeferredAsyncIterable as oe, DeferredReadableStream as _e } from "./shared.js";
2
+ const R = 0, T = 1, Y = 2, B = 3, E = 0, g = 1, m = 2, z = 3, x = 4, L = 5, y = 6, j = 7, C = 8, P = 9, O = 10, F = 11, k = 12, G = 13, V = 14, J = 15, K = 16, W = 17, $ = 18, H = 19, X = 20, q = 21, Q = 22, Z = 23, v = 0, ee = 1, se = 2, te = 3, re = 4, le = 1, ce = 2;
3
+ async function Ae(D, { plugins: S = [] } = {}) {
4
+ let a = new M();
5
+ const n = /* @__PURE__ */ new Map(), p = /* @__PURE__ */ new Map(), o = [];
6
+ let d = R, r = E, c = "", N = 0, U, h = 0, I = !1;
7
+ const _ = (i, w) => {
8
+ if (w === le) {
9
+ if (typeof i != "object" || i === null)
10
+ throw new Error("Expected object");
11
+ } else if (w === ce && !Array.isArray(i))
12
+ throw new Error("Expected array");
13
+ if (Array.isArray(i) && typeof i.__type == "number")
14
+ switch (i.__type) {
15
+ case ee:
16
+ for (const [l, f] of i)
17
+ i.__ref.set(l, f);
18
+ i = i.__ref;
19
+ break;
20
+ case v:
21
+ for (const l of i)
22
+ i.__ref.add(l);
23
+ i = i.__ref;
24
+ break;
25
+ case se:
26
+ i = new RegExp(i[0], i[1]), n.set(i.__id, i);
27
+ break;
28
+ case te: {
29
+ const l = new FormData();
30
+ for (const [f, t] of i)
31
+ l.append(f, t);
32
+ i = l, n.set(i.__id, i);
33
+ break;
34
+ }
35
+ case re: {
36
+ let l = !1;
37
+ const f = S.length;
38
+ for (let t = 0; t < f; t++) {
39
+ const e = S[t](...i);
40
+ if (typeof e == "object" && e !== null) {
41
+ i = e.value, l = !0;
42
+ break;
43
+ }
44
+ }
45
+ l || (i = void 0);
46
+ break;
47
+ }
48
+ }
49
+ if (o.length === 0) {
50
+ if (a === null)
51
+ throw new Error("Unexpected root value");
52
+ if (a !== null) {
53
+ a.resolve(i), a = null;
54
+ return;
55
+ }
56
+ }
57
+ const s = o[o.length - 1];
58
+ if (Array.isArray(s))
59
+ s.push(i);
60
+ else if (typeof s == "string")
61
+ o.pop(), o[o.length - 1][s] = i;
62
+ else if (typeof s == "boolean") {
63
+ o.pop();
64
+ const l = p.get(o.pop());
65
+ if (!l)
66
+ throw new Error("Invalid stack state");
67
+ l instanceof M ? s ? l.resolve(i) : l.reject(i) : s ? l.yield(i) : l.reject(i);
68
+ } else
69
+ throw new Error("Invalid stack state");
70
+ }, ne = (i) => {
71
+ const w = i.length;
72
+ let s;
73
+ const l = N;
74
+ N = 0;
75
+ let f = l;
76
+ for (; f < w; f++)
77
+ if (s = i.charCodeAt(f), d === R)
78
+ if (s === 44)
79
+ d = R, r = Array.isArray(o[o.length - 1]) ? E : y;
80
+ else if (s === 10) {
81
+ if (r === O) {
82
+ const t = o.pop();
83
+ if (typeof t != "number")
84
+ throw new Error("Invalid stack state");
85
+ p.get(t).resolve(), p.delete(t);
86
+ }
87
+ d = B, r = R, c = "";
88
+ } else if (s === 123) {
89
+ const t = {};
90
+ o.push(t), n.set(n.size, t), r = y;
91
+ } else if (s === 125)
92
+ _(o.pop(), 1);
93
+ else if (s === 91) {
94
+ const t = [];
95
+ o.push(t), n.set(n.size, t);
96
+ } else if (s === 83) {
97
+ const t = [];
98
+ t.__type = v, t.__ref = /* @__PURE__ */ new Set(), o.push(t), n.set(n.size, t.__ref), f++;
99
+ } else if (s === 77) {
100
+ const t = [];
101
+ t.__type = ee, t.__ref = /* @__PURE__ */ new Map(), o.push(t), n.set(n.size, t.__ref), f++;
102
+ } else if (s === 114) {
103
+ const t = [];
104
+ t.__type = se, t.__id = n.size, o.push(t), n.set(t.__id, t), f++;
105
+ } else if (s === 80) {
106
+ const t = [];
107
+ t.__type = re, t.__id = n.size, o.push(t), n.set(t.__id, t), f++;
108
+ } else if (s === 93)
109
+ _(o.pop(), 2);
110
+ else if (s === 64)
111
+ r = L;
112
+ else if (s === 68)
113
+ r = m;
114
+ else if (s === 85)
115
+ r = z;
116
+ else if (s === 115)
117
+ r = x;
118
+ else if (s === 34)
119
+ d = Y, c = "", U = void 0, h = 0, I = !1;
120
+ else if (s === 36)
121
+ r = j;
122
+ else if (s === 42)
123
+ r = C;
124
+ else if (s === 82)
125
+ r = P;
126
+ else if (s === 58) {
127
+ if (r !== O)
128
+ throw new SyntaxError("Unexpected character: ':'");
129
+ o.push(!0);
130
+ } else if (s === 33) {
131
+ if (r !== O)
132
+ throw new SyntaxError("Unexpected character: '!'");
133
+ o.push(!1);
134
+ } else if (s === 117)
135
+ _(void 0, 0), r = E;
136
+ else if (s === 110)
137
+ f += 3, _(null, 0), r = E;
138
+ else if (s === 116)
139
+ f += 3, _(!0, 0), r = E;
140
+ else if (s === 102)
141
+ f += 4, _(!1, 0), r = E;
142
+ else if (s === 78)
143
+ f += 2, _(Number.NaN, 0), r = E;
144
+ else if (s === 73)
145
+ _(Number.POSITIVE_INFINITY, 0), r = E;
146
+ else if (s === 105)
147
+ _(Number.NEGATIVE_INFINITY, 0), r = E;
148
+ else if (s === 122)
149
+ _(-0, 0), r = E;
150
+ else if (s === 98)
151
+ r = g;
152
+ else if (s === 45 || // -
153
+ s === 46 || // .
154
+ s >= 48 && s <= 57)
155
+ d = T, c = i[f];
156
+ else if (s === 69) {
157
+ const t = new Error();
158
+ o.push(t), n.set(n.size, t), r = y, f++;
159
+ } else if (s === 70) {
160
+ const t = [];
161
+ t.__type = te, t.__id = n.size, o.push(t), n.set(t.__id, t), f++;
162
+ } else if (s === 75) {
163
+ const t = new ie();
164
+ o.push(t), n.set(n.size, t), r = y, f++;
165
+ } else if (s === 107) {
166
+ const t = new fe();
167
+ o.push(t), n.set(n.size, t), r = y, f++;
168
+ } else if (s === 65)
169
+ r = F;
170
+ else if (s === 79)
171
+ r = k;
172
+ else if (s === 111)
173
+ r = G;
174
+ else if (s === 67)
175
+ r = V;
176
+ else if (s === 76)
177
+ r = J;
178
+ else if (s === 108)
179
+ r = K;
180
+ else if (s === 71)
181
+ r = W;
182
+ else if (s === 103)
183
+ r = $;
184
+ else if (s === 72)
185
+ r = H;
186
+ else if (s === 104)
187
+ r = X;
188
+ else if (s === 74)
189
+ r = q;
190
+ else if (s === 106)
191
+ r = Q;
192
+ else if (s === 86)
193
+ r = Z;
194
+ else
195
+ throw new SyntaxError(`Unexpected character: '${i[f]}'`);
196
+ else if (d === T || d === B)
197
+ if (s === 45 || // -
198
+ s === 46 || // .
199
+ s >= 48 && s <= 57)
200
+ c += i[f];
201
+ else {
202
+ if (d === B) {
203
+ o.push(Number(c)), d = R, r = O, f--;
204
+ continue;
205
+ }
206
+ if (r === j) {
207
+ const t = Number(c), e = p.get(t);
208
+ if (e)
209
+ _(e.promise, 0);
210
+ else {
211
+ const b = new M();
212
+ p.set(t, b), _(b.promise, 0);
213
+ }
214
+ } else if (r === C) {
215
+ const t = Number(c), e = p.get(
216
+ t
217
+ );
218
+ if (e)
219
+ _(e.iterable, 0);
220
+ else {
221
+ const b = new oe();
222
+ p.set(t, b), _(b.iterable, 0);
223
+ }
224
+ } else if (r === P) {
225
+ const t = Number(c), e = p.get(
226
+ t
227
+ );
228
+ if (e)
229
+ _(e.readable, 0);
230
+ else {
231
+ const b = new _e();
232
+ p.set(t, b), _(b.readable, 0);
233
+ }
234
+ } else
235
+ _(
236
+ r === g ? BigInt(c) : r === L ? n.get(Number(c)) : Number(c),
237
+ 0
238
+ );
239
+ c = "", d = R, r = E, f--;
240
+ }
241
+ else if (d === Y) {
242
+ let t = !1;
243
+ for (; f < w; f++)
244
+ if (s = i.charCodeAt(f), s !== 34 || U === 92 && h % 2 === 1)
245
+ c += i[f], U = s, U === 92 ? (h++, I = !0) : h = 0;
246
+ else {
247
+ t = !0;
248
+ break;
249
+ }
250
+ if (t) {
251
+ let e = I ? JSON.parse(`"${c}"`) : c;
252
+ r === y ? (o.push(e), f++) : (r === m ? (e = new Date(e), n.set(n.size, e)) : r === x ? e = Symbol.for(e) : r === z ? (e = new URL(e), n.set(n.size, e)) : r === F ? (e = A(e).buffer, n.set(n.size, e)) : r === k ? (e = new Int8Array(A(e).buffer), n.set(n.size, e)) : r === G ? (e = A(e), n.set(n.size, e)) : r === V ? (e = new Uint8ClampedArray(A(e).buffer), n.set(n.size, e)) : r === J ? (e = new Int16Array(A(e).buffer), n.set(n.size, e)) : r === K ? (e = new Uint16Array(A(e).buffer), n.set(n.size, e)) : r === W ? (e = new Int32Array(A(e).buffer), n.set(n.size, e)) : r === $ ? (e = new Uint32Array(A(e).buffer), n.set(n.size, e)) : r === H ? (e = new Float32Array(A(e).buffer), n.set(n.size, e)) : r === X ? (e = new Float64Array(A(e).buffer), n.set(n.size, e)) : r === q ? (e = new BigInt64Array(A(e).buffer), n.set(n.size, e)) : r === Q ? (e = new BigUint64Array(A(e).buffer), n.set(n.size, e)) : r === Z && (e = A(e), e = new DataView(
253
+ e.buffer,
254
+ e.byteOffset,
255
+ e.byteLength
256
+ ), n.set(n.size, e)), _(e, 0)), d = R, r = E;
257
+ } else
258
+ f--;
259
+ }
260
+ f > w && (N = f - w);
261
+ }, u = D.getReader();
262
+ return (async () => {
263
+ let i;
264
+ for (; !(i = await u.read()).done; )
265
+ ne(i.value);
266
+ })().catch((i) => {
267
+ a && (a.reject(i), a = null);
268
+ for (const w of p.values())
269
+ w.reject(i);
270
+ }).finally(() => {
271
+ u.releaseLock(), a && (a.reject(new Error("Stream ended before root value was parsed")), a = null);
272
+ for (const i of p.values())
273
+ i.reject(new Error("Stream ended before promise was resolved"));
274
+ }), a.promise;
275
+ }
276
+ function A(D) {
277
+ const S = atob(D), a = new Uint8Array(S.length);
278
+ for (let n = 0; n < S.length; n++)
279
+ a[n] = S.charCodeAt(n);
280
+ return a;
281
+ }
282
+ export {
283
+ Ae as decode
284
+ };
@@ -0,0 +1,363 @@
1
+ var M = Object.defineProperty;
2
+ var B = (s, t, r) => t in s ? M(s, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : s[t] = r;
3
+ var h = (s, t, r) => B(s, typeof t != "symbol" ? t + "" : t, r);
4
+ import { WaitGroup as C, STR_UNDEFINED as m, STR_NULL as $, STR_TRUE as x, STR_FALSE as G, STR_PROMISE as O, STR_READABLE_STREAM as F, STR_ASYNC_ITERABLE as Y, STR_REFERENCE_SYMBOL as J, STR_DATE as V, STR_REGEXP as j, STR_URL as q, STR_ARRAY_BUFFER as z, STR_INT_8_ARRAY as W, STR_UINT_8_ARRAY as K, STR_UINT_8_ARRAY_CLAMPED as X, STR_INT_16_ARRAY as Z, STR_UINT_16_ARRAY as H, STR_INT_32_ARRAY as Q, STR_UINT_32_ARRAY as k, STR_FLOAT_32_ARRAY as ee, STR_FLOAT_64_ARRAY as te, STR_BIG_INT_64_ARRAY as ie, STR_BIG_UINT_64_ARRAY as ne, STR_DATA_VIEW as oe, STR_FORM_DATA as se, SUPPORTS_FILE as re, STR_FILE as fe, STR_BLOB as ae, STR_ERROR as pe, STR_SET as Re, STR_MAP as _e, STR_PLUGIN as L, STR_NaN as ue, STR_INFINITY as Se, STR_NEGATIVE_INFINITY as le, STR_NEGATIVE_ZERO as Ae, STR_BIGINT as ye, STR_SYMBOL as ce, STR_REDACTED as Te, STR_SUCCESS as U, STR_FAILURE as D } from "./shared.js";
5
+ const { NEGATIVE_INFINITY: de, POSITIVE_INFINITY: Ie, isNaN: Ee } = Number, P = 1, v = 2;
6
+ function we(s, { plugins: t = [], redactErrors: r = !0, signal: f } = {}) {
7
+ const y = () => (f == null ? void 0 : f.aborted) ?? !1, c = new Promise((R, E) => {
8
+ f == null || f.addEventListener("abort", (p) => {
9
+ E(new DOMException("Aborted", "AbortError"));
10
+ });
11
+ });
12
+ return new ReadableStream({
13
+ async start(R) {
14
+ const E = /* @__PURE__ */ new WeakMap(), p = /* @__PURE__ */ new WeakMap(), I = { refId: 0, promiseId: 0 }, T = new C(), e = [], S = (o) => {
15
+ Ne(
16
+ o,
17
+ e,
18
+ E,
19
+ p,
20
+ a,
21
+ I,
22
+ t,
23
+ r
24
+ ), R.enqueue(e.join("") + `
25
+ `), e.length = 0;
26
+ }, i = (o, l) => {
27
+ T.done(), !y() && (R.enqueue(`${o}${U}`), S(l));
28
+ }, n = (o, l) => {
29
+ T.done(), !y() && (R.enqueue(`${o}${D}`), S(l));
30
+ }, a = {
31
+ push: (...o) => {
32
+ for (const [l, d, b] of o)
33
+ T.add(), l === P ? Promise.race([b, c]).then(
34
+ i.bind(null, d),
35
+ n.bind(null, d)
36
+ ) : (async () => {
37
+ const g = b[Symbol.asyncIterator]();
38
+ let N;
39
+ do {
40
+ if (N = await g.next(), y()) return;
41
+ N.done || (R.enqueue(`${d}${U}`), S(N.value));
42
+ } while (!N.done);
43
+ })().then(
44
+ () => {
45
+ y() || R.enqueue(`${d}
46
+ `);
47
+ },
48
+ (g) => {
49
+ y() || (R.enqueue(`${d}${D}`), S(g));
50
+ }
51
+ ).finally(() => {
52
+ T.done();
53
+ });
54
+ }
55
+ };
56
+ try {
57
+ S(s);
58
+ do
59
+ await Promise.race([T.wait(), c]);
60
+ while (T.p > 0);
61
+ R.close();
62
+ } catch (o) {
63
+ R.error(o);
64
+ }
65
+ }
66
+ });
67
+ }
68
+ const A = 1, w = 2;
69
+ class u {
70
+ constructor(t, r, f) {
71
+ h(this, "type");
72
+ h(this, "prefix");
73
+ h(this, "value");
74
+ this.type = t, this.prefix = r, this.value = f;
75
+ }
76
+ }
77
+ function Ne(s, t, r, f, y, c, R, E) {
78
+ const p = [
79
+ new u(
80
+ A,
81
+ "",
82
+ s
83
+ )
84
+ ];
85
+ let I;
86
+ e: for (; (I = p.pop()) !== void 0; ) {
87
+ if (I.type === w) {
88
+ t.push(I.prefix);
89
+ continue;
90
+ }
91
+ const { prefix: T, value: e } = I;
92
+ if (t.push(T), e === void 0) {
93
+ t.push(m);
94
+ continue;
95
+ }
96
+ if (e === null) {
97
+ t.push($);
98
+ continue;
99
+ }
100
+ if (e === !0) {
101
+ t.push(x);
102
+ continue;
103
+ }
104
+ if (e === !1) {
105
+ t.push(G);
106
+ continue;
107
+ }
108
+ const S = typeof e;
109
+ if (S === "object") {
110
+ if (e instanceof Promise || typeof e.then == "function") {
111
+ const i = f.get(e);
112
+ if (i !== void 0) {
113
+ t.push(O, i.toString());
114
+ continue;
115
+ }
116
+ const n = c.promiseId++;
117
+ f.set(e, n), t.push(O, n.toString()), y.push([
118
+ P,
119
+ n,
120
+ e
121
+ ]);
122
+ continue;
123
+ }
124
+ if (e instanceof ReadableStream) {
125
+ const i = f.get(e);
126
+ if (i !== void 0) {
127
+ t.push(F, i.toString());
128
+ continue;
129
+ }
130
+ const n = c.promiseId++;
131
+ f.set(e, n), t.push(F, n.toString()), y.push([
132
+ v,
133
+ n,
134
+ {
135
+ [Symbol.asyncIterator]: async function* () {
136
+ const a = e.getReader();
137
+ try {
138
+ for (; ; ) {
139
+ const { done: o, value: l } = await a.read();
140
+ if (o)
141
+ return;
142
+ yield l;
143
+ }
144
+ } finally {
145
+ a.releaseLock();
146
+ }
147
+ }
148
+ }
149
+ ]);
150
+ continue;
151
+ }
152
+ if (typeof e[Symbol.asyncIterator] == "function") {
153
+ const i = f.get(e);
154
+ if (i !== void 0) {
155
+ t.push(Y, i.toString());
156
+ continue;
157
+ }
158
+ const n = c.promiseId++;
159
+ f.set(e, n), t.push(Y, n.toString()), y.push([
160
+ v,
161
+ n,
162
+ e
163
+ ]);
164
+ continue;
165
+ }
166
+ {
167
+ const i = r.get(e);
168
+ if (i !== void 0) {
169
+ t.push(J, i.toString());
170
+ continue;
171
+ }
172
+ r.set(e, c.refId++);
173
+ }
174
+ if (e instanceof Date)
175
+ t.push(V, '"', e.toJSON(), '"');
176
+ else if (e instanceof RegExp)
177
+ t.push(j, JSON.stringify([e.source, e.flags]));
178
+ else if (e instanceof URL)
179
+ t.push(q, JSON.stringify(e));
180
+ else if (e instanceof ArrayBuffer)
181
+ t.push(
182
+ z,
183
+ _(new Uint8Array(e))
184
+ );
185
+ else if (e instanceof Int8Array)
186
+ t.push(W, _(e));
187
+ else if (e instanceof Uint8Array)
188
+ t.push(K, _(e));
189
+ else if (e instanceof Uint8ClampedArray)
190
+ t.push(X, _(e));
191
+ else if (e instanceof Int16Array)
192
+ t.push(Z, _(e));
193
+ else if (e instanceof Uint16Array)
194
+ t.push(H, _(e));
195
+ else if (e instanceof Int32Array)
196
+ t.push(Q, _(e));
197
+ else if (e instanceof Uint32Array)
198
+ t.push(k, _(e));
199
+ else if (e instanceof Float32Array)
200
+ t.push(ee, _(e));
201
+ else if (e instanceof Float64Array)
202
+ t.push(te, _(e));
203
+ else if (e instanceof BigInt64Array)
204
+ t.push(ie, _(e));
205
+ else if (e instanceof BigUint64Array)
206
+ t.push(ne, _(e));
207
+ else if (e instanceof DataView)
208
+ t.push(oe, _(e));
209
+ else if (e instanceof FormData)
210
+ p.push(
211
+ new u(
212
+ A,
213
+ se,
214
+ Array.from(e.entries())
215
+ )
216
+ );
217
+ else if (re && e instanceof File)
218
+ p.push(
219
+ new u(A, fe, {
220
+ promise: e.arrayBuffer(),
221
+ size: e.size,
222
+ type: e.type,
223
+ name: e.name,
224
+ lastModified: e.lastModified
225
+ })
226
+ );
227
+ else if (e instanceof Blob)
228
+ p.push(
229
+ new u(A, ae, {
230
+ promise: e.arrayBuffer(),
231
+ size: e.size,
232
+ type: e.type
233
+ })
234
+ );
235
+ else if (e instanceof Error)
236
+ p.push(
237
+ new u(
238
+ A,
239
+ pe,
240
+ he(e, E)
241
+ )
242
+ );
243
+ else if (typeof e.toJSON == "function") {
244
+ const i = e.toJSON();
245
+ p.push(
246
+ new u(
247
+ A,
248
+ "",
249
+ i
250
+ )
251
+ ), typeof i == "object" ? c.refId-- : r.delete(e);
252
+ } else {
253
+ if (typeof e[Symbol.iterator] == "function") {
254
+ const n = Array.isArray(e), a = n ? e : Array.from(e);
255
+ p.push(
256
+ new u(
257
+ w,
258
+ "]",
259
+ void 0
260
+ )
261
+ );
262
+ for (let o = a.length - 1; o >= 0; o--)
263
+ p.push(
264
+ new u(
265
+ A,
266
+ o === 0 ? "" : ",",
267
+ a[o]
268
+ )
269
+ );
270
+ t.push(
271
+ n ? "[" : e instanceof Set ? `${Re}[` : e instanceof Map ? `${_e}[` : "["
272
+ );
273
+ continue;
274
+ }
275
+ {
276
+ const i = R.length;
277
+ for (let n = 0; n < i; n++) {
278
+ const a = R[n](e);
279
+ if (Array.isArray(a)) {
280
+ p.push(
281
+ new u(
282
+ A,
283
+ L,
284
+ a
285
+ )
286
+ ), c.refId--, r.delete(e);
287
+ continue e;
288
+ }
289
+ }
290
+ }
291
+ p.push(
292
+ new u(
293
+ w,
294
+ "}",
295
+ void 0
296
+ )
297
+ );
298
+ {
299
+ const i = Object.keys(e);
300
+ let n = i.length;
301
+ const a = new Array(n);
302
+ n -= 1;
303
+ for (let o = i.length - 1; o >= 0; o--) {
304
+ const l = i[o], d = o > 0 ? "," : "";
305
+ a[n - o] = new u(
306
+ A,
307
+ `${d}${JSON.stringify(l)}:`,
308
+ e[l]
309
+ );
310
+ }
311
+ p.push(...a);
312
+ }
313
+ t.push("{");
314
+ }
315
+ } else if (S === "string")
316
+ t.push(JSON.stringify(e));
317
+ else if (S === "number")
318
+ Ee(e) ? t.push(ue) : e === Ie ? t.push(Se) : e === de ? t.push(le) : Object.is(e, -0) ? t.push(Ae) : t.push(e.toString());
319
+ else if (S === "bigint")
320
+ t.push(ye, e.toString());
321
+ else if (S === "symbol") {
322
+ const i = Symbol.keyFor(e);
323
+ typeof i == "string" ? t.push(ce, JSON.stringify(i)) : t.push(m);
324
+ } else {
325
+ const i = R.length;
326
+ for (let n = 0; n < i; n++) {
327
+ const a = R[n](e);
328
+ if (Array.isArray(a)) {
329
+ p.push(
330
+ new u(
331
+ A,
332
+ L,
333
+ a
334
+ )
335
+ );
336
+ continue e;
337
+ }
338
+ }
339
+ t.push(m);
340
+ }
341
+ }
342
+ }
343
+ function he(s, t) {
344
+ const r = t === !0 || typeof t == "string" || typeof t > "u", f = typeof t == "string" ? t : Te;
345
+ return {
346
+ name: r ? "Error" : s.name,
347
+ message: r ? f : s.message,
348
+ stack: r ? void 0 : s.stack,
349
+ cause: s.cause
350
+ };
351
+ }
352
+ function _(s) {
353
+ const t = new Uint8Array(
354
+ s.buffer,
355
+ s.byteOffset,
356
+ s.byteLength
357
+ );
358
+ return `"${btoa(String.fromCharCode.apply(String, t))}"`;
359
+ }
360
+ export {
361
+ we as encode,
362
+ Ne as encodeSync
363
+ };