@cbortech/cbor 0.27.0 → 0.27.2
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.ja.md +100 -0
- package/README.md +103 -0
- package/dist/ast/CborAppSeqResult.d.ts +37 -4
- package/dist/ast/CborArray.d.ts +2 -2
- package/dist/ast/CborByteString.d.ts +2 -2
- package/dist/ast/CborEmbeddedCBOR.d.ts +1 -1
- package/dist/ast/CborFloat.d.ts +1 -1
- package/dist/ast/CborIndefiniteByteString.d.ts +1 -1
- package/dist/ast/CborIndefiniteTextString.d.ts +1 -1
- package/dist/ast/CborItem.d.ts +314 -9
- package/dist/ast/CborMap.d.ts +2 -2
- package/dist/ast/CborNint.d.ts +1 -1
- package/dist/ast/CborTag.d.ts +26 -4
- package/dist/ast/CborTextString.d.ts +2 -2
- package/dist/ast/CborUint.d.ts +1 -1
- package/dist/ast/CborUnresolvedAppExt.d.ts +9 -0
- package/dist/ast/index.cjs +1 -1
- package/dist/ast/index.js +2 -2
- package/dist/cbor/tagLabels.d.ts +26 -0
- package/dist/cddl/eRefScope.d.ts +241 -0
- package/dist/cddl/eref.d.ts +64 -0
- package/dist/cddl/implicitTags.d.ts +28 -0
- package/dist/cddl/index.cjs +2 -2
- package/dist/cddl/index.cjs.map +1 -1
- package/dist/cddl/index.d.ts +2 -0
- package/dist/cddl/index.js +26 -25
- package/dist/cddl/index.js.map +1 -1
- package/dist/cddl/validator.d.ts +98 -2
- package/dist/cdn/index.cjs +1 -1
- package/dist/cdn/index.js +1 -1
- package/dist/cdn/serialize-utils.d.ts +50 -15
- package/dist/extensions/cri.d.ts +2 -2
- package/dist/extensions/dt.d.ts +4 -4
- package/dist/extensions/eref.d.ts +135 -0
- package/dist/extensions/ip.d.ts +3 -3
- package/dist/extensions/types.d.ts +40 -1
- package/dist/index.cjs +7 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +190 -81
- package/dist/index.js.map +1 -1
- package/dist/js/fromJS.d.ts +23 -1
- package/dist/mapEntries-8zshEr-t.js +7085 -0
- package/dist/mapEntries-8zshEr-t.js.map +1 -0
- package/dist/mapEntries-DwHPAzCN.cjs +68 -0
- package/dist/mapEntries-DwHPAzCN.cjs.map +1 -0
- package/dist/schema-7r2xjpMK.js +345 -0
- package/dist/schema-7r2xjpMK.js.map +1 -0
- package/dist/schema-YiigSWjR.cjs +8 -0
- package/dist/schema-YiigSWjR.cjs.map +1 -0
- package/dist/{serialize-utils-BuIZPaUc.js → serialize-utils-BQtutOo6.js} +70 -52
- package/dist/serialize-utils-BQtutOo6.js.map +1 -0
- package/dist/{serialize-utils-CjTqQivB.cjs → serialize-utils-DQ8T3Mzw.cjs} +9 -9
- package/dist/serialize-utils-DQ8T3Mzw.cjs.map +1 -0
- package/dist/types.d.ts +426 -4
- package/dist/utils/hexfloat.d.ts +10 -2
- package/package.json +13 -14
- package/dist/mapEntries-C1f7G0AM.cjs +0 -13
- package/dist/mapEntries-C1f7G0AM.cjs.map +0 -1
- package/dist/mapEntries-CvLdiN0h.js +0 -3946
- package/dist/mapEntries-CvLdiN0h.js.map +0 -1
- package/dist/schema-CNfrVRYp.js +0 -1977
- package/dist/schema-CNfrVRYp.js.map +0 -1
- package/dist/schema-iXpYtKQl.cjs +0 -63
- package/dist/schema-iXpYtKQl.cjs.map +0 -1
- package/dist/serialize-utils-BuIZPaUc.js.map +0 -1
- package/dist/serialize-utils-CjTqQivB.cjs.map +0 -1
|
@@ -1,3946 +0,0 @@
|
|
|
1
|
-
import { A as e, C as t, D as n, E as r, F as i, I as a, M as o, N as s, O as c, P as l, S as u, T as d, _ as f, a as p, b as m, c as h, d as g, f as _, g as v, h as y, i as b, j as ee, k as x, l as S, m as C, n as w, o as T, p as te, r as E, s as ne, t as D, u as re, v as ie, w as O, x as ae, y as oe } from "./serialize-utils-BuIZPaUc.js";
|
|
2
|
-
//#region src/tag.ts
|
|
3
|
-
var se = Symbol.for("cbor.tag"), ce = class {
|
|
4
|
-
valueOf() {
|
|
5
|
-
return null;
|
|
6
|
-
}
|
|
7
|
-
toJSON() {
|
|
8
|
-
return null;
|
|
9
|
-
}
|
|
10
|
-
}, le = class {
|
|
11
|
-
valueOf() {}
|
|
12
|
-
toJSON() {}
|
|
13
|
-
};
|
|
14
|
-
function ue(e) {
|
|
15
|
-
if (!me(e)) return;
|
|
16
|
-
let t = e[se];
|
|
17
|
-
return typeof t == "bigint" ? t : void 0;
|
|
18
|
-
}
|
|
19
|
-
function de(e, t) {
|
|
20
|
-
let n;
|
|
21
|
-
switch (typeof e) {
|
|
22
|
-
case "number":
|
|
23
|
-
n = new Number(e);
|
|
24
|
-
break;
|
|
25
|
-
case "string":
|
|
26
|
-
n = new String(e);
|
|
27
|
-
break;
|
|
28
|
-
case "boolean":
|
|
29
|
-
n = new Boolean(e);
|
|
30
|
-
break;
|
|
31
|
-
case "bigint":
|
|
32
|
-
n = Object(e);
|
|
33
|
-
break;
|
|
34
|
-
case "undefined":
|
|
35
|
-
n = new le();
|
|
36
|
-
break;
|
|
37
|
-
case "object":
|
|
38
|
-
if (e === null) {
|
|
39
|
-
n = new ce();
|
|
40
|
-
break;
|
|
41
|
-
}
|
|
42
|
-
n = e;
|
|
43
|
-
break;
|
|
44
|
-
default: throw TypeError(`setCborTag: cannot tag value of type ${typeof e}`);
|
|
45
|
-
}
|
|
46
|
-
return n[se] = t, n;
|
|
47
|
-
}
|
|
48
|
-
function fe(e) {
|
|
49
|
-
if (e instanceof Number || e instanceof String || e instanceof Boolean || Object.prototype.toString.call(e) === "[object BigInt]") return e.valueOf();
|
|
50
|
-
if (e instanceof ce) return null;
|
|
51
|
-
if (!(e instanceof le)) return typeof e == "object" && e && delete e[se], e;
|
|
52
|
-
}
|
|
53
|
-
function pe(e) {
|
|
54
|
-
if (e instanceof Number || e instanceof String || e instanceof Boolean || Object.prototype.toString.call(e) === "[object BigInt]") return e.valueOf();
|
|
55
|
-
if (e instanceof ce) return null;
|
|
56
|
-
if (!(e instanceof le)) return e;
|
|
57
|
-
}
|
|
58
|
-
function me(e) {
|
|
59
|
-
return typeof e == "object" && !!e;
|
|
60
|
-
}
|
|
61
|
-
var k = class {
|
|
62
|
-
constructor() {}
|
|
63
|
-
static symbol = se;
|
|
64
|
-
static Null = ce;
|
|
65
|
-
static Undefined = le;
|
|
66
|
-
static get(e) {
|
|
67
|
-
return ue(e);
|
|
68
|
-
}
|
|
69
|
-
static set(e, t) {
|
|
70
|
-
return de(e, t);
|
|
71
|
-
}
|
|
72
|
-
static remove(e) {
|
|
73
|
-
return fe(e);
|
|
74
|
-
}
|
|
75
|
-
static getValue(e) {
|
|
76
|
-
return pe(e);
|
|
77
|
-
}
|
|
78
|
-
}, he = Symbol("cbor.omit"), ge = class e {
|
|
79
|
-
value;
|
|
80
|
-
constructor(e) {
|
|
81
|
-
if (!Number.isInteger(e) || e < 0 || e > 255) throw RangeError("Simple value must be an integer in 0–255");
|
|
82
|
-
this.value = e;
|
|
83
|
-
}
|
|
84
|
-
valueOf() {
|
|
85
|
-
return this.value;
|
|
86
|
-
}
|
|
87
|
-
toJSON() {
|
|
88
|
-
throw TypeError(`simple(${this.value}) cannot be serialized to JSON`);
|
|
89
|
-
}
|
|
90
|
-
static is(t) {
|
|
91
|
-
return t instanceof e;
|
|
92
|
-
}
|
|
93
|
-
static get(t) {
|
|
94
|
-
return t instanceof e ? t.value : void 0;
|
|
95
|
-
}
|
|
96
|
-
}, _e = "getFloat16" in DataView.prototype && "setFloat16" in DataView.prototype, ve = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(8));
|
|
97
|
-
function ye(e) {
|
|
98
|
-
ve.setFloat64(0, e, !1);
|
|
99
|
-
let t = ve.getUint32(0, !1), n = ve.getUint32(4, !1), r = t >>> 31 & 1, i = t >>> 20 & 2047, a = t & 1048575;
|
|
100
|
-
if (i === 2047) {
|
|
101
|
-
if (a === 0 && n === 0) return r << 15 | 31744;
|
|
102
|
-
let e = a >> 10 | (n === 0 ? 0 : 1) || 1;
|
|
103
|
-
return r << 15 | 31744 | e & 1023;
|
|
104
|
-
}
|
|
105
|
-
let o = i - 1023 + 15;
|
|
106
|
-
if (o >= 31) return r << 15 | 31744;
|
|
107
|
-
let s, c, l;
|
|
108
|
-
if (o <= 0) {
|
|
109
|
-
if (o < -10) return r << 15;
|
|
110
|
-
let e = 1 << 20 | a, t = 11 - o;
|
|
111
|
-
t <= 20 ? (s = e >> t & 1023, c = e >> t - 1 & 1, l = !!(e & (1 << t - 1) - 1) || n !== 0) : (s = 0, c = 1, l = a !== 0 || n !== 0);
|
|
112
|
-
} else s = a >> 10, c = a >> 9 & 1, l = !!(a & 511) || n !== 0;
|
|
113
|
-
if (c !== 0 && (l || s & 1) && s++, s >= 1024) {
|
|
114
|
-
let e = o <= 0 ? 1 : o + 1;
|
|
115
|
-
return e >= 31 ? r << 15 | 31744 : r << 15 | e << 10;
|
|
116
|
-
}
|
|
117
|
-
let u = o <= 0 ? 0 : o;
|
|
118
|
-
return r << 15 | u << 10 | s;
|
|
119
|
-
}
|
|
120
|
-
function A(e) {
|
|
121
|
-
let t = e >>> 15 & 1, n = e >>> 10 & 31, r = e & 1023;
|
|
122
|
-
return n === 31 ? r === 0 ? t ? -Infinity : Infinity : NaN : n === 0 ? r === 0 ? t ? -0 : 0 : (t ? -1 : 1) * 2 ** -14 * (r / 1024) : (t ? -1 : 1) * 2 ** (n - 15) * (1 + r / 1024);
|
|
123
|
-
}
|
|
124
|
-
var be = _e ? (e, t, n, r) => {
|
|
125
|
-
e.setFloat16(t, n, r);
|
|
126
|
-
} : (e, t, n, r) => {
|
|
127
|
-
e.setUint16(t, ye(n), r);
|
|
128
|
-
}, xe = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(8)), j = new Uint8Array(xe.buffer), Se = new TextEncoder(), Ce = typeof Se.encodeInto == "function";
|
|
129
|
-
function we(e) {
|
|
130
|
-
return e <= 23 ? 1 : e <= 255 ? 2 : e <= 65535 ? 3 : e <= 4294967295 ? 5 : 9;
|
|
131
|
-
}
|
|
132
|
-
function Te(e) {
|
|
133
|
-
return e === "i" ? 1 : [
|
|
134
|
-
2,
|
|
135
|
-
3,
|
|
136
|
-
5,
|
|
137
|
-
9
|
|
138
|
-
][e];
|
|
139
|
-
}
|
|
140
|
-
var Ee = class {
|
|
141
|
-
buf;
|
|
142
|
-
len = 0;
|
|
143
|
-
constructor(e = 256) {
|
|
144
|
-
this.buf = new Uint8Array(e);
|
|
145
|
-
}
|
|
146
|
-
_ensure(e) {
|
|
147
|
-
let t = this.len + e;
|
|
148
|
-
if (t <= this.buf.length) return;
|
|
149
|
-
let n = this.buf.length * 2;
|
|
150
|
-
for (; n < t;) n *= 2;
|
|
151
|
-
let r = new Uint8Array(n);
|
|
152
|
-
r.set(this.buf), this.buf = r;
|
|
153
|
-
}
|
|
154
|
-
writeByte(e) {
|
|
155
|
-
this._ensure(1), this.buf[this.len++] = e;
|
|
156
|
-
}
|
|
157
|
-
writeBytes(e) {
|
|
158
|
-
this._ensure(e.length), this.buf.set(e, this.len), this.len += e.length;
|
|
159
|
-
}
|
|
160
|
-
writeUint16(e) {
|
|
161
|
-
this._ensure(2);
|
|
162
|
-
let t = this.buf;
|
|
163
|
-
t[this.len++] = e >>> 8 & 255, t[this.len++] = e & 255;
|
|
164
|
-
}
|
|
165
|
-
writeUint32(e) {
|
|
166
|
-
this._ensure(4);
|
|
167
|
-
let t = this.buf;
|
|
168
|
-
t[this.len++] = e >>> 24 & 255, t[this.len++] = e >>> 16 & 255, t[this.len++] = e >>> 8 & 255, t[this.len++] = e & 255;
|
|
169
|
-
}
|
|
170
|
-
writeBigUint64(e) {
|
|
171
|
-
xe.setBigUint64(0, e, !1), this._ensure(8), this.buf.set(j, this.len), this.len += 8;
|
|
172
|
-
}
|
|
173
|
-
writeFloat16(e) {
|
|
174
|
-
be(xe, 0, e, !1), this._ensure(2);
|
|
175
|
-
let t = this.buf;
|
|
176
|
-
t[this.len++] = j[0], t[this.len++] = j[1];
|
|
177
|
-
}
|
|
178
|
-
writeFloat32(e) {
|
|
179
|
-
xe.setFloat32(0, e, !1), this._ensure(4);
|
|
180
|
-
let t = this.buf;
|
|
181
|
-
t[this.len++] = j[0], t[this.len++] = j[1], t[this.len++] = j[2], t[this.len++] = j[3];
|
|
182
|
-
}
|
|
183
|
-
writeFloat64(e) {
|
|
184
|
-
xe.setFloat64(0, e, !1), this._ensure(8), this.buf.set(j, this.len), this.len += 8;
|
|
185
|
-
}
|
|
186
|
-
writeTextString(e, t, n) {
|
|
187
|
-
if (!Ce) {
|
|
188
|
-
let r = Se.encode(t);
|
|
189
|
-
M(this, e, r.length, n), this.writeBytes(r);
|
|
190
|
-
return;
|
|
191
|
-
}
|
|
192
|
-
let r = n === void 0 ? we(t.length) : Te(n);
|
|
193
|
-
this._ensure(9 + 3 * t.length);
|
|
194
|
-
let { written: i } = Se.encodeInto(t, this.buf.subarray(this.len + r)), a = n === void 0 ? we(i) : r;
|
|
195
|
-
a !== r && this.buf.copyWithin(this.len + a, this.len + r, this.len + r + i), M(this, e, i, n), this.len += i;
|
|
196
|
-
}
|
|
197
|
-
finish() {
|
|
198
|
-
return this.buf.slice(0, this.len);
|
|
199
|
-
}
|
|
200
|
-
}, De = [
|
|
201
|
-
255n,
|
|
202
|
-
65535n,
|
|
203
|
-
4294967295n,
|
|
204
|
-
18446744073709551615n
|
|
205
|
-
];
|
|
206
|
-
function Oe(e) {
|
|
207
|
-
return e === "i" ? 23n : De[e];
|
|
208
|
-
}
|
|
209
|
-
function M(e, t, n, r) {
|
|
210
|
-
if (r === void 0 && typeof n == "number" && n < 4294967296) {
|
|
211
|
-
n <= 23 ? e.writeByte(t << 5 | n) : n <= 255 ? (e.writeByte(t << 5 | 24), e.writeByte(n)) : n <= 65535 ? (e.writeByte(t << 5 | 25), e.writeUint16(n)) : (e.writeByte(t << 5 | 26), e.writeUint32(n));
|
|
212
|
-
return;
|
|
213
|
-
}
|
|
214
|
-
let i = typeof n == "number" ? BigInt(n) : n;
|
|
215
|
-
if (r !== void 0) {
|
|
216
|
-
if (r === "i") {
|
|
217
|
-
if (i > 23n) throw RangeError(`value ${i} does not fit in immediate encoding _i (max 23)`);
|
|
218
|
-
e.writeByte(t << 5 | Number(i));
|
|
219
|
-
return;
|
|
220
|
-
}
|
|
221
|
-
if (i > De[r]) throw RangeError(`value ${i} does not fit in encodingWidth _${r} (max ${De[r]})`);
|
|
222
|
-
let n = 24 + r;
|
|
223
|
-
e.writeByte(t << 5 | n), n === 24 ? e.writeByte(Number(i)) : n === 25 ? e.writeUint16(Number(i)) : n === 26 ? e.writeUint32(Number(i)) : e.writeBigUint64(i);
|
|
224
|
-
return;
|
|
225
|
-
}
|
|
226
|
-
i <= 23n ? e.writeByte(t << 5 | Number(i)) : i <= 255n ? (e.writeByte(t << 5 | 24), e.writeByte(Number(i))) : i <= 65535n ? (e.writeByte(t << 5 | 25), e.writeUint16(Number(i))) : i <= 4294967295n ? (e.writeByte(t << 5 | 26), e.writeUint32(Number(i))) : (e.writeByte(t << 5 | 27), e.writeBigUint64(i));
|
|
227
|
-
}
|
|
228
|
-
function ke(e, t, n) {
|
|
229
|
-
let r = new Ee(9);
|
|
230
|
-
return M(r, e, t, n), r.finish();
|
|
231
|
-
}
|
|
232
|
-
var Ae = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(4));
|
|
233
|
-
function je(e) {
|
|
234
|
-
return Object.is(A(ye(e)), e);
|
|
235
|
-
}
|
|
236
|
-
function Me(e) {
|
|
237
|
-
return Ae.setFloat32(0, e, !1), Object.is(Ae.getFloat32(0, !1), e);
|
|
238
|
-
}
|
|
239
|
-
function N(e) {
|
|
240
|
-
return je(e) ? "half" : Me(e) ? "single" : "double";
|
|
241
|
-
}
|
|
242
|
-
//#endregion
|
|
243
|
-
//#region src/ast/CborItem.ts
|
|
244
|
-
function Ne(e) {
|
|
245
|
-
return {
|
|
246
|
-
...e,
|
|
247
|
-
preserveComments: e.comments === void 0 ? e.preserveComments ?? !0 : e.preserveComments,
|
|
248
|
-
preserveByteString: e.preserveByteString ?? !0,
|
|
249
|
-
preserveRawString: e.preserveRawString ?? !0,
|
|
250
|
-
preserveConcatenation: e.preserveConcatenation ?? !0,
|
|
251
|
-
preserveNumberFormat: e.preserveNumberFormat ?? !0,
|
|
252
|
-
preserveAppPrefix: e.preserveAppPrefix ?? !0,
|
|
253
|
-
preserveBlankLines: e.preserveBlankLines ?? !0
|
|
254
|
-
};
|
|
255
|
-
}
|
|
256
|
-
function Pe(e) {
|
|
257
|
-
return e.preserveAppSequence === void 0 && e.appStrings === void 0 ? e : {
|
|
258
|
-
...e,
|
|
259
|
-
preserveAppPrefix: e.preserveAppPrefix ?? e.preserveAppSequence,
|
|
260
|
-
appPrefix: e.appPrefix ?? e.appStrings
|
|
261
|
-
};
|
|
262
|
-
}
|
|
263
|
-
var P = class e {
|
|
264
|
-
start;
|
|
265
|
-
end;
|
|
266
|
-
comments;
|
|
267
|
-
blankLineBefore;
|
|
268
|
-
appSeqSource;
|
|
269
|
-
appSeqComments;
|
|
270
|
-
appSeqEncodingEdits;
|
|
271
|
-
appSeqEncodingEditsComplete;
|
|
272
|
-
appSeqInnerEnd;
|
|
273
|
-
appSeqSourceFeatures;
|
|
274
|
-
warnings;
|
|
275
|
-
_defaults;
|
|
276
|
-
get _containsCdnContainer() {
|
|
277
|
-
return !1;
|
|
278
|
-
}
|
|
279
|
-
_isMultiWordText(e, t = !0) {
|
|
280
|
-
return !1;
|
|
281
|
-
}
|
|
282
|
-
toCBOR(e) {
|
|
283
|
-
let t = this._defaults ? {
|
|
284
|
-
...this._defaults,
|
|
285
|
-
...e
|
|
286
|
-
} : e, n = new Ee();
|
|
287
|
-
return this._encode(n, t), n.finish();
|
|
288
|
-
}
|
|
289
|
-
toCDN(e) {
|
|
290
|
-
let t = this._defaults ? {
|
|
291
|
-
...this._defaults,
|
|
292
|
-
...e
|
|
293
|
-
} : e;
|
|
294
|
-
t &&= Pe(t), t?.preserveAll && (t = Ne(t));
|
|
295
|
-
let r = this._toCDN(t, 0);
|
|
296
|
-
if (!n(t) || O(t) === null) return r;
|
|
297
|
-
let i = u(t), { ownLines: a, inlinePrefix: o } = c(this, "", i), s = this.comments?.trailing ?? [], l = s.length === 0 ? r : `${r} ${s.map((e) => b(e, i).trimEnd()).join(" ")}`;
|
|
298
|
-
return [...a, `${o}${l}`].join("\n");
|
|
299
|
-
}
|
|
300
|
-
toEDN(e) {
|
|
301
|
-
return this.toCDN(e);
|
|
302
|
-
}
|
|
303
|
-
toJS(e) {
|
|
304
|
-
let t = this._defaults ? {
|
|
305
|
-
...this._defaults,
|
|
306
|
-
...e
|
|
307
|
-
} : e, n = this._toJS(t);
|
|
308
|
-
if (!t?.reviver) return n;
|
|
309
|
-
let r = t.reviver.call({ "": n }, "", n);
|
|
310
|
-
return r === he ? void 0 : r;
|
|
311
|
-
}
|
|
312
|
-
toHexDump(e) {
|
|
313
|
-
let t = this._defaults ? {
|
|
314
|
-
...this._defaults,
|
|
315
|
-
...e
|
|
316
|
-
} : e;
|
|
317
|
-
t &&= Pe(t);
|
|
318
|
-
let n = t?.indent ?? 3, r = typeof n == "string" ? n : " ".repeat(n), i = (t?.commentStyle ?? "--") + " ", a = this._toHexDump(0, t), o = 0;
|
|
319
|
-
for (let e of a) {
|
|
320
|
-
let t = e.depth * r.length + e.hex.length;
|
|
321
|
-
t > o && (o = t);
|
|
322
|
-
}
|
|
323
|
-
let s = o + 2;
|
|
324
|
-
return a.map((e) => (r.repeat(e.depth) + e.hex).padEnd(s) + i + e.comment).join("\n");
|
|
325
|
-
}
|
|
326
|
-
_encode(t, n) {
|
|
327
|
-
if (this._toCBOR !== e.prototype._toCBOR) {
|
|
328
|
-
t.writeBytes(this._toCBOR(n));
|
|
329
|
-
return;
|
|
330
|
-
}
|
|
331
|
-
this._encodeTo(t, n);
|
|
332
|
-
}
|
|
333
|
-
_encodeTo(t, n) {
|
|
334
|
-
if (this._toCBOR === e.prototype._toCBOR) throw TypeError("CborItem subclass must implement _encodeTo() or _toCBOR()");
|
|
335
|
-
t.writeBytes(this._toCBOR(n));
|
|
336
|
-
}
|
|
337
|
-
_toCBOR(e) {
|
|
338
|
-
let t = new Ee();
|
|
339
|
-
return this._encodeTo(t, e), t.finish();
|
|
340
|
-
}
|
|
341
|
-
_toHexDump(e, t) {
|
|
342
|
-
return [{
|
|
343
|
-
depth: e,
|
|
344
|
-
hex: l(this._toCBOR()),
|
|
345
|
-
comment: this._toCDN(t, 0)
|
|
346
|
-
}];
|
|
347
|
-
}
|
|
348
|
-
}, F = class extends P {
|
|
349
|
-
value;
|
|
350
|
-
encodingWidth;
|
|
351
|
-
ednSource;
|
|
352
|
-
constructor(e, t) {
|
|
353
|
-
if (super(), this.value = BigInt(e), this.value < 0n) throw RangeError("CborUint value must be non-negative");
|
|
354
|
-
if (this.value > 18446744073709551615n) throw RangeError("CborUint value exceeds maximum uint64");
|
|
355
|
-
this.encodingWidth = t?.encodingWidth, this.ednSource = t?.ednSource;
|
|
356
|
-
}
|
|
357
|
-
_encodeTo(e, t) {
|
|
358
|
-
M(e, 0, this.value, this.encodingWidth);
|
|
359
|
-
}
|
|
360
|
-
_toCDN(e, n) {
|
|
361
|
-
let r = t(e, this.encodingWidth, () => E(this.value));
|
|
362
|
-
if (e?.preserveNumberFormat && this.ednSource !== void 0) return this.ednSource + r;
|
|
363
|
-
let i = this.value;
|
|
364
|
-
switch (e?.intFormat) {
|
|
365
|
-
case "hex": return `0x${i.toString(16)}${r}`;
|
|
366
|
-
case "octal": return `0o${i.toString(8)}${r}`;
|
|
367
|
-
case "binary": return `0b${i.toString(2)}${r}`;
|
|
368
|
-
default: return i.toString() + r;
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
_toJS(e) {
|
|
372
|
-
let t = e?.integerAs ?? "auto";
|
|
373
|
-
return t === "bigint" ? this.value : t === "number" || this.value <= BigInt(2 ** 53 - 1) ? Number(this.value) : this.value;
|
|
374
|
-
}
|
|
375
|
-
}, I = class extends P {
|
|
376
|
-
argument;
|
|
377
|
-
encodingWidth;
|
|
378
|
-
ednSource;
|
|
379
|
-
constructor(e, t) {
|
|
380
|
-
super();
|
|
381
|
-
let n = BigInt(e);
|
|
382
|
-
if (n >= 0n) throw RangeError("CborNint value must be negative");
|
|
383
|
-
if (n < -18446744073709551616n) throw RangeError("CborNint value exceeds minimum int64");
|
|
384
|
-
this.argument = -1n - n, this.encodingWidth = t?.encodingWidth, this.ednSource = t?.ednSource;
|
|
385
|
-
}
|
|
386
|
-
get value() {
|
|
387
|
-
return -1n - this.argument;
|
|
388
|
-
}
|
|
389
|
-
_encodeTo(e, t) {
|
|
390
|
-
M(e, 1, this.argument, this.encodingWidth);
|
|
391
|
-
}
|
|
392
|
-
_toCDN(e, n) {
|
|
393
|
-
let r = t(e, this.encodingWidth, () => E(this.argument));
|
|
394
|
-
if (e?.preserveNumberFormat && this.ednSource !== void 0) return this.ednSource + r;
|
|
395
|
-
let i = this.argument + 1n;
|
|
396
|
-
switch (e?.intFormat) {
|
|
397
|
-
case "hex": return `-0x${i.toString(16)}${r}`;
|
|
398
|
-
case "octal": return `-0o${i.toString(8)}${r}`;
|
|
399
|
-
case "binary": return `-0b${i.toString(2)}${r}`;
|
|
400
|
-
default: return this.value.toString() + r;
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
_toJS(e) {
|
|
404
|
-
let t = this.value, n = e?.integerAs ?? "auto";
|
|
405
|
-
return n === "bigint" ? t : n === "number" || t >= BigInt(-(2 ** 53 - 1)) ? Number(t) : t;
|
|
406
|
-
}
|
|
407
|
-
}, Fe = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(8));
|
|
408
|
-
function Ie(e) {
|
|
409
|
-
let t = e.startsWith("-"), n = e.slice(t ? 3 : 2), r = n.search(/[pP]/);
|
|
410
|
-
if (r === -1) throw SyntaxError(`EDN parse error: hex float missing 'p' exponent: ${e}`);
|
|
411
|
-
let i = n.slice(0, r), a = n.slice(r + 1);
|
|
412
|
-
if (!/^[+-]?\d+$/.test(a)) throw SyntaxError(`EDN parse error: hex float has invalid or missing exponent: ${e}`);
|
|
413
|
-
let o = parseInt(a, 10), s = i.indexOf("."), c;
|
|
414
|
-
if (s === -1) {
|
|
415
|
-
if (!/^[0-9a-fA-F]+$/.test(i)) throw SyntaxError(`EDN parse error: hex float has no mantissa digits: ${e}`);
|
|
416
|
-
c = parseInt(i, 16);
|
|
417
|
-
} else {
|
|
418
|
-
let t = i.slice(0, s), n = i.slice(s + 1);
|
|
419
|
-
if (t === "" && n === "") throw SyntaxError(`EDN parse error: hex float has no mantissa digits: ${e}`);
|
|
420
|
-
if (t !== "" && !/^[0-9a-fA-F]+$/.test(t) || n !== "" && !/^[0-9a-fA-F]+$/.test(n)) throw SyntaxError(`EDN parse error: hex float has invalid mantissa: ${e}`);
|
|
421
|
-
c = (t === "" ? 0 : parseInt(t, 16)) + (n === "" ? 0 : parseInt(n, 16) / 16 ** n.length);
|
|
422
|
-
}
|
|
423
|
-
let l = c * 2 ** o;
|
|
424
|
-
return t ? -l : l;
|
|
425
|
-
}
|
|
426
|
-
function Le(e) {
|
|
427
|
-
if (isNaN(e)) return "NaN";
|
|
428
|
-
if (!isFinite(e)) return e > 0 ? "Infinity" : "-Infinity";
|
|
429
|
-
let t = Object.is(e, -0) || e < 0, n = Math.abs(e);
|
|
430
|
-
if (n === 0) return t ? "-0x0p+0" : "0x0p+0";
|
|
431
|
-
Fe.setFloat64(0, n, !1);
|
|
432
|
-
let r = Fe.getUint32(0, !1), i = Fe.getUint32(4, !1), a = r >>> 20 & 2047, o = r & 1048575, s = i, c = (o.toString(16).padStart(5, "0") + s.toString(16).padStart(8, "0")).replace(/0+$/, ""), l = c === "" ? "" : `.${c}`, u, d;
|
|
433
|
-
a === 0 ? (u = "0", d = -1022) : (u = "1", d = a - 1023);
|
|
434
|
-
let f = d >= 0 ? `+${d}` : `${d}`, p = `0x${u}${l}p${f}`;
|
|
435
|
-
return t ? `-${p}` : p;
|
|
436
|
-
}
|
|
437
|
-
//#endregion
|
|
438
|
-
//#region src/ast/CborFloat.ts
|
|
439
|
-
var L = class extends P {
|
|
440
|
-
value;
|
|
441
|
-
precision;
|
|
442
|
-
ednSource;
|
|
443
|
-
literalSource;
|
|
444
|
-
rawBits;
|
|
445
|
-
constructor(e, t) {
|
|
446
|
-
super(), this.value = e, this.precision = t?.precision, this.rawBits = t?.rawBits, this.literalSource = t?.literalSource;
|
|
447
|
-
}
|
|
448
|
-
_encodeTo(e, t) {
|
|
449
|
-
let n = this.precision ?? N(this.value), r = Number.isNaN(this.value) ? this.rawBits : void 0;
|
|
450
|
-
n === "half" ? (e.writeByte(249), r?.length === 2 ? e.writeBytes(r) : e.writeFloat16(this.value)) : n === "single" ? (e.writeByte(250), r?.length === 4 ? e.writeBytes(r) : e.writeFloat32(this.value)) : (e.writeByte(251), r?.length === 8 ? e.writeBytes(r) : e.writeFloat64(this.value));
|
|
451
|
-
}
|
|
452
|
-
_toCDN(e, t) {
|
|
453
|
-
let n = e?.encodingIndicators ?? "auto";
|
|
454
|
-
if (e?.appPrefix !== !1 && (e?.floatFormat === void 0 || e?.floatFormat === "app-extension") && this.ednSource !== void 0 && (O(e) !== null || !/[\r\n]/.test(this.ednSource))) {
|
|
455
|
-
let e = this.ednSource;
|
|
456
|
-
if (n === "never") return e.replace(/_[0-3i]$/, "");
|
|
457
|
-
if (n === "always") {
|
|
458
|
-
if (/_[0-3i]$/.test(e)) return e;
|
|
459
|
-
let t = this.precision ?? N(this.value);
|
|
460
|
-
return e + (t === "half" ? "_1" : t === "single" ? "_2" : "_3");
|
|
461
|
-
}
|
|
462
|
-
return e;
|
|
463
|
-
}
|
|
464
|
-
if (e?.preserveNumberFormat && this.literalSource !== void 0) {
|
|
465
|
-
let e = this.literalSource;
|
|
466
|
-
if (n === "never") return e.replace(/_[0-7i]$/, "");
|
|
467
|
-
if (n === "always") {
|
|
468
|
-
if (/_[0-7i]$/.test(e)) return e;
|
|
469
|
-
let t = N(this.value);
|
|
470
|
-
return e + S(this.value, this.precision, t, "always");
|
|
471
|
-
}
|
|
472
|
-
return e;
|
|
473
|
-
}
|
|
474
|
-
let r = N(this.value);
|
|
475
|
-
if (e?.floatFormat === "app-extension" && e?.appPrefix !== !1) {
|
|
476
|
-
let e = this.toCBOR();
|
|
477
|
-
return `float'${s(e.subarray(1))}'` + S(this.value, this.precision, r, n);
|
|
478
|
-
}
|
|
479
|
-
return (e?.floatFormat === "hex" ? Le(this.value) : re(this.value)) + S(this.value, this.precision, r, n);
|
|
480
|
-
}
|
|
481
|
-
_toJS(e) {
|
|
482
|
-
return this.value;
|
|
483
|
-
}
|
|
484
|
-
}, R = class extends P {
|
|
485
|
-
tag;
|
|
486
|
-
content;
|
|
487
|
-
encodingWidth;
|
|
488
|
-
ednSource;
|
|
489
|
-
constructor(e, t, n) {
|
|
490
|
-
if (super(), this.tag = BigInt(e), this.tag < 0n) throw RangeError("CborTag tag number must be non-negative");
|
|
491
|
-
this.content = t, this.encodingWidth = n?.encodingWidth, this.ednSource = n?.ednSource;
|
|
492
|
-
}
|
|
493
|
-
get _containsCdnContainer() {
|
|
494
|
-
return this.content._containsCdnContainer;
|
|
495
|
-
}
|
|
496
|
-
_isMultiWordText(e, t = !0) {
|
|
497
|
-
return y(this._toCDN(e, 0), t);
|
|
498
|
-
}
|
|
499
|
-
_encodeTo(e, t) {
|
|
500
|
-
M(e, 6, this.tag, this.encodingWidth), this.content._encode(e, t);
|
|
501
|
-
}
|
|
502
|
-
_toCDN(e, n) {
|
|
503
|
-
let r = t(e, this.encodingWidth, () => E(this.tag));
|
|
504
|
-
return `${e?.preserveNumberFormat && this.ednSource !== void 0 ? this.ednSource : this.tag.toString()}${r}${ae(this.content, this, e, n, (t) => this.content._toCDN(e, t), "(", ")")}`;
|
|
505
|
-
}
|
|
506
|
-
_toHexDump(e, t) {
|
|
507
|
-
let n = [{
|
|
508
|
-
depth: e,
|
|
509
|
-
hex: l(ke(6, this.tag, this.encodingWidth)),
|
|
510
|
-
comment: `Tag ${this.tag}`
|
|
511
|
-
}];
|
|
512
|
-
return m(n, this.content._toHexDump(e + 1, {
|
|
513
|
-
...t,
|
|
514
|
-
appPrefix: !1
|
|
515
|
-
})), n;
|
|
516
|
-
}
|
|
517
|
-
_toJS(e) {
|
|
518
|
-
let t = this.content._toJS(e);
|
|
519
|
-
return e?.stripTags ? t : k.set(t, this.tag);
|
|
520
|
-
}
|
|
521
|
-
};
|
|
522
|
-
//#endregion
|
|
523
|
-
//#region src/ast/CborByteString.ts
|
|
524
|
-
function Re(e, t, r) {
|
|
525
|
-
if (e !== void 0) return n(t) || r === void 0 ? e : x(e, r);
|
|
526
|
-
}
|
|
527
|
-
var z = class extends P {
|
|
528
|
-
indefiniteLength = !1;
|
|
529
|
-
value;
|
|
530
|
-
ednEncoding;
|
|
531
|
-
encodingWidth;
|
|
532
|
-
ednSource;
|
|
533
|
-
ednCommentSyntax;
|
|
534
|
-
ednParts;
|
|
535
|
-
constructor(e, t) {
|
|
536
|
-
super(), this.value = e, this.ednEncoding = t?.ednEncoding ?? "hex", this.encodingWidth = t?.encodingWidth, this.ednSource = t?.ednSource, this.ednCommentSyntax = t?.ednCommentSyntax, this.ednParts = t?.ednParts;
|
|
537
|
-
}
|
|
538
|
-
_isMultiWordText(e, t = !0) {
|
|
539
|
-
return C(this.value, e?.sqstr);
|
|
540
|
-
}
|
|
541
|
-
_encodeTo(e, t) {
|
|
542
|
-
M(e, 2, this.value.length, this.encodingWidth), e.writeBytes(this.value);
|
|
543
|
-
}
|
|
544
|
-
_toCDN(e, r) {
|
|
545
|
-
let i = O(e);
|
|
546
|
-
if (e?.preserveConcatenation && i !== null && this.ednParts !== void 0 && this.ednParts.length > 1) {
|
|
547
|
-
let a = t(e, this.encodingWidth, () => E(BigInt(this.value.length))), o = e?.bstrEncoding ?? this.ednEncoding;
|
|
548
|
-
e?.appPrefix === !1 && o !== "hex" && (o = "hex");
|
|
549
|
-
let s = this.ednParts.map((t) => {
|
|
550
|
-
let n = e?.preserveByteString ? Re(t.source, e, t.commentSyntax) : void 0;
|
|
551
|
-
return n === void 0 ? d(t.bytes, o, e?.sqstr) : n;
|
|
552
|
-
}), c = n(e) ? p(this.comments?.dangling, this.ednParts, u(e)) : void 0;
|
|
553
|
-
return e?.modernConcat && e?.appPrefix !== !1 ? ie("b1", s, a, i, r, c) : (s[s.length - 1] += a, oe(s, i, r, c));
|
|
554
|
-
}
|
|
555
|
-
let a = e?.preserveByteString ? Re(this.ednSource, e, this.ednCommentSyntax) : void 0;
|
|
556
|
-
if (a !== void 0 && (i !== null || !/[\r\n]/.test(a))) return /_[0-3i]$/.test(a) ? (e?.encodingIndicators ?? "auto") === "never" ? a.replace(/_[0-3i]$/, "") : a : a + t(e, this.encodingWidth, () => E(BigInt(this.value.length)));
|
|
557
|
-
let o = t(e, this.encodingWidth, () => E(BigInt(this.value.length))), s = e?.bstrEncoding ?? this.ednEncoding;
|
|
558
|
-
return e?.appPrefix === !1 && s !== "hex" && (s = "hex"), d(this.value, s, e?.sqstr) + o;
|
|
559
|
-
}
|
|
560
|
-
_toJS(e) {
|
|
561
|
-
return this.value;
|
|
562
|
-
}
|
|
563
|
-
}, B = class extends P {
|
|
564
|
-
indefiniteLength = !0;
|
|
565
|
-
chunks;
|
|
566
|
-
constructor(e) {
|
|
567
|
-
super(), this.chunks = e;
|
|
568
|
-
}
|
|
569
|
-
_encodeTo(e, t) {
|
|
570
|
-
e.writeByte(95);
|
|
571
|
-
for (let n of this.chunks) n._encode(e, t);
|
|
572
|
-
e.writeByte(255);
|
|
573
|
-
}
|
|
574
|
-
_isMultiWordText(e, t = !0) {
|
|
575
|
-
return this.chunks.some((t) => t._isMultiWordText(e));
|
|
576
|
-
}
|
|
577
|
-
_toCDN(e, t) {
|
|
578
|
-
if ((e?.encodingIndicators ?? "auto") === "never") {
|
|
579
|
-
let n = this.chunks.reduce((e, t) => e + t.value.length, 0), r = new Uint8Array(n), i = 0;
|
|
580
|
-
for (let e of this.chunks) r.set(e.value, i), i += e.value.length;
|
|
581
|
-
return new z(r)._toCDN(e, t);
|
|
582
|
-
}
|
|
583
|
-
let n = !!e?.modernStreamSyntax && e?.appPrefix !== !1;
|
|
584
|
-
return !n && this.chunks.length === 0 ? "''_" : r({
|
|
585
|
-
node: this,
|
|
586
|
-
options: e,
|
|
587
|
-
depth: t,
|
|
588
|
-
openChar: n ? "ilbs<<" : "(",
|
|
589
|
-
closeChar: n ? ">>" : ")",
|
|
590
|
-
count: this.chunks.length,
|
|
591
|
-
indefiniteLength: !0,
|
|
592
|
-
indefiniteMarker: !n,
|
|
593
|
-
encodingWidth: void 0,
|
|
594
|
-
hasEntryComments: () => this.chunks.some(_),
|
|
595
|
-
renderEntry: (n) => this.chunks[n]._toCDN(e, t + 1),
|
|
596
|
-
entryIsLeaf: n ? void 0 : () => !0,
|
|
597
|
-
alwaysInlineLeaf: n,
|
|
598
|
-
entryIsMultiWordText: (t) => this.chunks[t]._isMultiWordText(e, !n),
|
|
599
|
-
entryLeadingNode: (e) => this.chunks[e],
|
|
600
|
-
entryTrailing: (e, t) => g(this.chunks[e], t)
|
|
601
|
-
});
|
|
602
|
-
}
|
|
603
|
-
_toHexDump(e, t) {
|
|
604
|
-
let n = [{
|
|
605
|
-
depth: e,
|
|
606
|
-
hex: o(95),
|
|
607
|
-
comment: "Start indefinite-length byte string"
|
|
608
|
-
}];
|
|
609
|
-
for (let r of this.chunks) m(n, r._toHexDump(e + 1, t));
|
|
610
|
-
return n.push({
|
|
611
|
-
depth: e,
|
|
612
|
-
hex: o(255),
|
|
613
|
-
comment: "\"break\""
|
|
614
|
-
}), n;
|
|
615
|
-
}
|
|
616
|
-
_toJS(e) {
|
|
617
|
-
let t = this.chunks.reduce((e, t) => e + t.value.length, 0), n = new Uint8Array(t), r = 0;
|
|
618
|
-
for (let e of this.chunks) n.set(e.value, r), r += e.value.length;
|
|
619
|
-
return n;
|
|
620
|
-
}
|
|
621
|
-
}, V = class extends P {
|
|
622
|
-
indefiniteLength = !0;
|
|
623
|
-
chunks;
|
|
624
|
-
constructor(e) {
|
|
625
|
-
super(), this.chunks = e;
|
|
626
|
-
}
|
|
627
|
-
_encodeTo(e, t) {
|
|
628
|
-
e.writeByte(127);
|
|
629
|
-
for (let n of this.chunks) n._encode(e, t);
|
|
630
|
-
e.writeByte(255);
|
|
631
|
-
}
|
|
632
|
-
_isMultiWordText(e, t = !0) {
|
|
633
|
-
return this.chunks.some((t) => t._isMultiWordText(e));
|
|
634
|
-
}
|
|
635
|
-
_toCDN(e, t) {
|
|
636
|
-
if ((e?.encodingIndicators ?? "auto") === "never") return new Y(this.chunks.map((e) => e.value).join(""))._toCDN(e, t);
|
|
637
|
-
let n = !!e?.modernStreamSyntax && e?.appPrefix !== !1;
|
|
638
|
-
return !n && this.chunks.length === 0 ? "\"\"_" : r({
|
|
639
|
-
node: this,
|
|
640
|
-
options: e,
|
|
641
|
-
depth: t,
|
|
642
|
-
openChar: n ? "ilts<<" : "(",
|
|
643
|
-
closeChar: n ? ">>" : ")",
|
|
644
|
-
count: this.chunks.length,
|
|
645
|
-
indefiniteLength: !0,
|
|
646
|
-
indefiniteMarker: !n,
|
|
647
|
-
encodingWidth: void 0,
|
|
648
|
-
hasEntryComments: () => this.chunks.some(_),
|
|
649
|
-
renderEntry: (n) => this.chunks[n]._toCDN(e, t + 1),
|
|
650
|
-
entryIsLeaf: n ? void 0 : () => !0,
|
|
651
|
-
alwaysInlineLeaf: n,
|
|
652
|
-
entryIsMultiWordText: (t) => this.chunks[t]._isMultiWordText(e, !n),
|
|
653
|
-
entryLeadingNode: (e) => this.chunks[e],
|
|
654
|
-
entryTrailing: (e, t) => g(this.chunks[e], t)
|
|
655
|
-
});
|
|
656
|
-
}
|
|
657
|
-
_toHexDump(e, t) {
|
|
658
|
-
let n = [{
|
|
659
|
-
depth: e,
|
|
660
|
-
hex: o(127),
|
|
661
|
-
comment: "Start indefinite-length text string"
|
|
662
|
-
}];
|
|
663
|
-
for (let r of this.chunks) m(n, r._toHexDump(e + 1, t));
|
|
664
|
-
return n.push({
|
|
665
|
-
depth: e,
|
|
666
|
-
hex: o(255),
|
|
667
|
-
comment: "\"break\""
|
|
668
|
-
}), n;
|
|
669
|
-
}
|
|
670
|
-
_toJS(e) {
|
|
671
|
-
return this.chunks.map((e) => e.value).join("");
|
|
672
|
-
}
|
|
673
|
-
}, H = class extends P {
|
|
674
|
-
items;
|
|
675
|
-
indefiniteLength;
|
|
676
|
-
encodingWidth;
|
|
677
|
-
constructor(e, t) {
|
|
678
|
-
super(), this.items = e, this.indefiniteLength = t?.indefiniteLength ?? !1, this.encodingWidth = t?.encodingWidth;
|
|
679
|
-
}
|
|
680
|
-
get _containsCdnContainer() {
|
|
681
|
-
return !0;
|
|
682
|
-
}
|
|
683
|
-
_encodeTo(e, t) {
|
|
684
|
-
if (this.indefiniteLength) {
|
|
685
|
-
e.writeByte(159);
|
|
686
|
-
for (let n of this.items) n._encode(e, t);
|
|
687
|
-
e.writeByte(255);
|
|
688
|
-
return;
|
|
689
|
-
}
|
|
690
|
-
M(e, 4, this.items.length, this.encodingWidth);
|
|
691
|
-
for (let n of this.items) n._encode(e, t);
|
|
692
|
-
}
|
|
693
|
-
_toCDN(e, t) {
|
|
694
|
-
return r({
|
|
695
|
-
node: this,
|
|
696
|
-
options: e,
|
|
697
|
-
depth: t,
|
|
698
|
-
openChar: "[",
|
|
699
|
-
closeChar: "]",
|
|
700
|
-
count: this.items.length,
|
|
701
|
-
indefiniteLength: this.indefiniteLength,
|
|
702
|
-
encodingWidth: this.encodingWidth,
|
|
703
|
-
hasEntryComments: () => this.items.some(_),
|
|
704
|
-
renderEntry: (n) => this.items[n]._toCDN(e, t + 1),
|
|
705
|
-
entryIsLeaf: (e) => !this.items[e]._containsCdnContainer,
|
|
706
|
-
entryIsMultiWordText: (t) => this.items[t]._isMultiWordText(e),
|
|
707
|
-
entryLeadingNode: (e) => this.items[e],
|
|
708
|
-
entryTrailing: (e, t) => g(this.items[e], t)
|
|
709
|
-
});
|
|
710
|
-
}
|
|
711
|
-
_toHexDump(e, t) {
|
|
712
|
-
if (this.indefiniteLength) {
|
|
713
|
-
let n = [{
|
|
714
|
-
depth: e,
|
|
715
|
-
hex: o(159),
|
|
716
|
-
comment: "Start indefinite-length array"
|
|
717
|
-
}];
|
|
718
|
-
for (let r of this.items) m(n, r._toHexDump(e + 1, t));
|
|
719
|
-
return n.push({
|
|
720
|
-
depth: e,
|
|
721
|
-
hex: o(255),
|
|
722
|
-
comment: "\"break\""
|
|
723
|
-
}), n;
|
|
724
|
-
}
|
|
725
|
-
let n = [{
|
|
726
|
-
depth: e,
|
|
727
|
-
hex: l(ke(4, BigInt(this.items.length), this.encodingWidth)),
|
|
728
|
-
comment: `Array of length ${this.items.length}`
|
|
729
|
-
}];
|
|
730
|
-
for (let r of this.items) m(n, r._toHexDump(e + 1, t));
|
|
731
|
-
return n;
|
|
732
|
-
}
|
|
733
|
-
_toJS(e) {
|
|
734
|
-
let t = e?.reviver;
|
|
735
|
-
if (!t) return this.items.map((t) => t._toJS(e));
|
|
736
|
-
let n = e ? {
|
|
737
|
-
...e,
|
|
738
|
-
reviver: void 0
|
|
739
|
-
} : void 0, r = this.items.map((e) => e._toJS(n)), i = 0;
|
|
740
|
-
for (let n = 0; n < this.items.length; n++) {
|
|
741
|
-
let a = n - i, o = this.items[n]._toJS(e), s = t.call(r, String(n), o);
|
|
742
|
-
s === he || e?.undefinedOmits && s === void 0 ? (r.splice(a, 1), i++) : r[a] = s;
|
|
743
|
-
}
|
|
744
|
-
return r;
|
|
745
|
-
}
|
|
746
|
-
}, U = class extends P {
|
|
747
|
-
entries;
|
|
748
|
-
indefiniteLength;
|
|
749
|
-
encodingWidth;
|
|
750
|
-
constructor(e, t) {
|
|
751
|
-
super(), this.entries = e, this.indefiniteLength = t?.indefiniteLength ?? !1, this.encodingWidth = t?.encodingWidth;
|
|
752
|
-
}
|
|
753
|
-
get _containsCdnContainer() {
|
|
754
|
-
return !0;
|
|
755
|
-
}
|
|
756
|
-
_encodeTo(e, t) {
|
|
757
|
-
if (this.indefiniteLength) {
|
|
758
|
-
e.writeByte(191);
|
|
759
|
-
for (let [n, r] of this.entries) n._encode(e, t), r._encode(e, t);
|
|
760
|
-
e.writeByte(255);
|
|
761
|
-
return;
|
|
762
|
-
}
|
|
763
|
-
M(e, 5, this.entries.length, this.encodingWidth);
|
|
764
|
-
for (let [n, r] of this.entries) n._encode(e, t), r._encode(e, t);
|
|
765
|
-
}
|
|
766
|
-
_toCDN(e, t) {
|
|
767
|
-
let n = [], i = (r) => {
|
|
768
|
-
let i = n[r];
|
|
769
|
-
if (!i) {
|
|
770
|
-
let [a, o] = this.entries[r];
|
|
771
|
-
i = [a._toCDN(e, t + 1), o._toCDN(e, t + 1)], n[r] = i;
|
|
772
|
-
}
|
|
773
|
-
return i;
|
|
774
|
-
};
|
|
775
|
-
return r({
|
|
776
|
-
node: this,
|
|
777
|
-
options: e,
|
|
778
|
-
depth: t,
|
|
779
|
-
openChar: "{",
|
|
780
|
-
closeChar: "}",
|
|
781
|
-
count: this.entries.length,
|
|
782
|
-
indefiniteLength: this.indefiniteLength,
|
|
783
|
-
encodingWidth: this.encodingWidth,
|
|
784
|
-
hasEntryComments: () => this.entries.some(([e, t]) => _(e) || _(t)),
|
|
785
|
-
renderEntry: (e, t) => {
|
|
786
|
-
let [n, r] = i(e);
|
|
787
|
-
return `${n}${t}${r}`;
|
|
788
|
-
},
|
|
789
|
-
entryIsLeaf: (e) => {
|
|
790
|
-
let [t, n] = this.entries[e];
|
|
791
|
-
return !t._containsCdnContainer && !n._containsCdnContainer;
|
|
792
|
-
},
|
|
793
|
-
entryIsMultiWordText: (t) => {
|
|
794
|
-
let [n, r] = this.entries[t];
|
|
795
|
-
if (n._isMultiWordText(e) || r._isMultiWordText(e)) return !0;
|
|
796
|
-
let [a, o] = i(t);
|
|
797
|
-
return f(a) || f(o);
|
|
798
|
-
},
|
|
799
|
-
entryLeadingNode: (e) => this.entries[e][0],
|
|
800
|
-
entryTrailing: (e, t) => {
|
|
801
|
-
let [n, r] = this.entries[e];
|
|
802
|
-
return ze([
|
|
803
|
-
...n.comments?.trailing ?? [],
|
|
804
|
-
...r.comments?.leading ?? [],
|
|
805
|
-
...r.comments?.trailing ?? []
|
|
806
|
-
], t);
|
|
807
|
-
}
|
|
808
|
-
});
|
|
809
|
-
}
|
|
810
|
-
_toHexDump(e, t) {
|
|
811
|
-
if (this.indefiniteLength) {
|
|
812
|
-
let n = [{
|
|
813
|
-
depth: e,
|
|
814
|
-
hex: o(191),
|
|
815
|
-
comment: "Start indefinite-length map"
|
|
816
|
-
}];
|
|
817
|
-
for (let [r, i] of this.entries) m(n, r._toHexDump(e + 1, t)), m(n, i._toHexDump(e + 1, t));
|
|
818
|
-
return n.push({
|
|
819
|
-
depth: e,
|
|
820
|
-
hex: o(255),
|
|
821
|
-
comment: "\"break\""
|
|
822
|
-
}), n;
|
|
823
|
-
}
|
|
824
|
-
let n = [{
|
|
825
|
-
depth: e,
|
|
826
|
-
hex: l(ke(5, BigInt(this.entries.length), this.encodingWidth)),
|
|
827
|
-
comment: `Map of length ${this.entries.length}`
|
|
828
|
-
}];
|
|
829
|
-
for (let [r, i] of this.entries) m(n, r._toHexDump(e + 1, t)), m(n, i._toHexDump(e + 1, t));
|
|
830
|
-
return n;
|
|
831
|
-
}
|
|
832
|
-
_toJS(e) {
|
|
833
|
-
let t = e?.reviver, n = () => {
|
|
834
|
-
let n = $.from(this.entries, ([t, n]) => [t._toJS(e), n._toJS(e)]);
|
|
835
|
-
if (!t) return n;
|
|
836
|
-
let r = e?.undefinedOmits;
|
|
837
|
-
for (let e = 0; e < n.length; e++) {
|
|
838
|
-
let [i, a] = n[e], o = t.call(n, i, a);
|
|
839
|
-
o === he || r && o === void 0 ? n.splice(e--, 1) : n[e] = [i, o];
|
|
840
|
-
}
|
|
841
|
-
return n;
|
|
842
|
-
};
|
|
843
|
-
return e?.mapAs === "entries" ? n() : e?.mapAs === "object" || this.entries.every(([e]) => e instanceof Y) ? (() => {
|
|
844
|
-
let n = e ? {
|
|
845
|
-
...e,
|
|
846
|
-
reviver: void 0
|
|
847
|
-
} : void 0, r = {};
|
|
848
|
-
for (let [e, t] of this.entries) {
|
|
849
|
-
let i = e instanceof Y ? e.value : e.toCDN(), a = t._toJS(n);
|
|
850
|
-
i === "__proto__" ? Object.defineProperty(r, i, {
|
|
851
|
-
value: a,
|
|
852
|
-
writable: !0,
|
|
853
|
-
enumerable: !0,
|
|
854
|
-
configurable: !0
|
|
855
|
-
}) : r[i] = a;
|
|
856
|
-
}
|
|
857
|
-
if (!t) return r;
|
|
858
|
-
let i = /* @__PURE__ */ new Map();
|
|
859
|
-
for (let e = 0; e < this.entries.length; e++) {
|
|
860
|
-
let [t] = this.entries[e];
|
|
861
|
-
i.set(t instanceof Y ? t.value : t.toCDN(), e);
|
|
862
|
-
}
|
|
863
|
-
for (let n = 0; n < this.entries.length; n++) {
|
|
864
|
-
let [a, o] = this.entries[n], s = a instanceof Y ? a.value : a.toCDN();
|
|
865
|
-
if (i.get(s) !== n) continue;
|
|
866
|
-
let c = o._toJS(e), l = t.call(r, s, c);
|
|
867
|
-
l === he || e?.undefinedOmits && l === void 0 ? delete r[s] : s === "__proto__" ? Object.defineProperty(r, s, {
|
|
868
|
-
value: l,
|
|
869
|
-
writable: !0,
|
|
870
|
-
enumerable: !0,
|
|
871
|
-
configurable: !0
|
|
872
|
-
}) : r[s] = l;
|
|
873
|
-
}
|
|
874
|
-
return r;
|
|
875
|
-
})() : n();
|
|
876
|
-
}
|
|
877
|
-
};
|
|
878
|
-
function ze(e, t) {
|
|
879
|
-
return e.length === 0 ? "" : " " + e.map((e) => b(e, t).trimEnd()).join(" ");
|
|
880
|
-
}
|
|
881
|
-
//#endregion
|
|
882
|
-
//#region src/ast/CborSimple.ts
|
|
883
|
-
var W = class e extends P {
|
|
884
|
-
value;
|
|
885
|
-
ednSource;
|
|
886
|
-
constructor(e, t) {
|
|
887
|
-
if (super(), !Number.isInteger(e) || e < 0 || e > 255) throw RangeError("CborSimple value must be an integer in 0–255");
|
|
888
|
-
this.value = e, this.ednSource = t?.ednSource;
|
|
889
|
-
}
|
|
890
|
-
static FALSE = new e(20);
|
|
891
|
-
static TRUE = new e(21);
|
|
892
|
-
static NULL = new e(22);
|
|
893
|
-
static UNDEFINED = new e(23);
|
|
894
|
-
_encodeTo(e, t) {
|
|
895
|
-
if (this.value <= 23) {
|
|
896
|
-
e.writeByte(224 | this.value);
|
|
897
|
-
return;
|
|
898
|
-
}
|
|
899
|
-
e.writeByte(248), e.writeByte(this.value);
|
|
900
|
-
}
|
|
901
|
-
_toCDN(e, t) {
|
|
902
|
-
if (e?.preserveNumberFormat && this.ednSource !== void 0) return `simple(${this.ednSource})`;
|
|
903
|
-
switch (this.value) {
|
|
904
|
-
case 20: return "false";
|
|
905
|
-
case 21: return "true";
|
|
906
|
-
case 22: return "null";
|
|
907
|
-
case 23: return "undefined";
|
|
908
|
-
default: return `simple(${this.value})`;
|
|
909
|
-
}
|
|
910
|
-
}
|
|
911
|
-
_toJS(e) {
|
|
912
|
-
switch (this.value) {
|
|
913
|
-
case 20: return !1;
|
|
914
|
-
case 21: return !0;
|
|
915
|
-
case 22: return null;
|
|
916
|
-
case 23: return;
|
|
917
|
-
default: return new ge(this.value);
|
|
918
|
-
}
|
|
919
|
-
}
|
|
920
|
-
}, G = class extends P {
|
|
921
|
-
items;
|
|
922
|
-
encodingWidth;
|
|
923
|
-
constructor(e, t) {
|
|
924
|
-
super(), this.items = e, this.encodingWidth = t?.encodingWidth;
|
|
925
|
-
}
|
|
926
|
-
get _containsCdnContainer() {
|
|
927
|
-
return this.items.some((e) => e._containsCdnContainer);
|
|
928
|
-
}
|
|
929
|
-
_content(e) {
|
|
930
|
-
let t = new Ee();
|
|
931
|
-
for (let n of this.items) n._encode(t, e);
|
|
932
|
-
return t.finish();
|
|
933
|
-
}
|
|
934
|
-
_encodeTo(e, t) {
|
|
935
|
-
let n = this._content(t);
|
|
936
|
-
M(e, 2, n.length, this.encodingWidth), e.writeBytes(n);
|
|
937
|
-
}
|
|
938
|
-
_toCDN(e, t) {
|
|
939
|
-
return r({
|
|
940
|
-
node: this,
|
|
941
|
-
options: e,
|
|
942
|
-
depth: t,
|
|
943
|
-
openChar: "<<",
|
|
944
|
-
closeChar: ">>",
|
|
945
|
-
count: this.items.length,
|
|
946
|
-
indefiniteLength: !1,
|
|
947
|
-
encodingWidth: this.encodingWidth,
|
|
948
|
-
eiPosition: "close",
|
|
949
|
-
canonicalCount: () => BigInt(this._content(e).length),
|
|
950
|
-
hasEntryComments: () => this.items.some(_),
|
|
951
|
-
renderEntry: (n) => this.items[n]._toCDN(e, t + 1),
|
|
952
|
-
alwaysInlineLeaf: !0,
|
|
953
|
-
entryIsMultiWordText: (t) => this.items[t]._isMultiWordText(e, !1),
|
|
954
|
-
entryLeadingNode: (e) => this.items[e],
|
|
955
|
-
entryTrailing: (e, t) => g(this.items[e], t)
|
|
956
|
-
});
|
|
957
|
-
}
|
|
958
|
-
_toHexDump(e, t) {
|
|
959
|
-
let n = this._content().length, r = [{
|
|
960
|
-
depth: e,
|
|
961
|
-
hex: l(ke(2, BigInt(n), this.encodingWidth)),
|
|
962
|
-
comment: `Embedded CBOR sequence, ${n} byte${n === 1 ? "" : "s"}`
|
|
963
|
-
}];
|
|
964
|
-
for (let n of this.items) m(r, n._toHexDump(e + 1, t));
|
|
965
|
-
return r;
|
|
966
|
-
}
|
|
967
|
-
_toJS(e) {
|
|
968
|
-
return this._content();
|
|
969
|
-
}
|
|
970
|
-
};
|
|
971
|
-
//#endregion
|
|
972
|
-
//#region src/utils/strip-comments.ts
|
|
973
|
-
function Be(e) {
|
|
974
|
-
let t = "", n = 0;
|
|
975
|
-
for (; n < e.length;) {
|
|
976
|
-
let r = e[n];
|
|
977
|
-
if (r === " " || r === "\n" || r === "\r") {
|
|
978
|
-
n++;
|
|
979
|
-
continue;
|
|
980
|
-
}
|
|
981
|
-
if (r === "#") {
|
|
982
|
-
for (; n < e.length && e[n] !== "\n";) n++;
|
|
983
|
-
continue;
|
|
984
|
-
}
|
|
985
|
-
if (r === "/") {
|
|
986
|
-
let t = e[n + 1] ?? "";
|
|
987
|
-
if (t === "/") {
|
|
988
|
-
for (; n < e.length && e[n] !== "\n";) n++;
|
|
989
|
-
continue;
|
|
990
|
-
}
|
|
991
|
-
if (t === "*") {
|
|
992
|
-
for (n += 2; n < e.length && (e[n] !== "*" || (e[n + 1] ?? "") !== "/");) n++;
|
|
993
|
-
if (n >= e.length) throw SyntaxError("unterminated block comment");
|
|
994
|
-
n += 2;
|
|
995
|
-
continue;
|
|
996
|
-
}
|
|
997
|
-
for (n++; n < e.length && e[n] !== "/";) n++;
|
|
998
|
-
if (n >= e.length) throw SyntaxError("unterminated block comment");
|
|
999
|
-
n++;
|
|
1000
|
-
continue;
|
|
1001
|
-
}
|
|
1002
|
-
t += r, n++;
|
|
1003
|
-
}
|
|
1004
|
-
return t;
|
|
1005
|
-
}
|
|
1006
|
-
//#endregion
|
|
1007
|
-
//#region src/extensions/b32.ts
|
|
1008
|
-
var Ve = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567", He = "0123456789ABCDEFGHIJKLMNOPQRSTUV";
|
|
1009
|
-
function Ue(e) {
|
|
1010
|
-
let t = e.length;
|
|
1011
|
-
for (; t > 0 && e.charCodeAt(t - 1) === 61;) t--;
|
|
1012
|
-
return e.slice(0, t);
|
|
1013
|
-
}
|
|
1014
|
-
function We(e, t, n) {
|
|
1015
|
-
let r = Ue(e).toUpperCase(), i = r.length % 8;
|
|
1016
|
-
if (i === 1 || i === 3 || i === 6) throw SyntaxError(`invalid base32 length: ${r.length} characters`);
|
|
1017
|
-
let a = (/* @__PURE__ */ new Uint8Array(128)).fill(255);
|
|
1018
|
-
for (let e = 0; e < t.length; e++) a[t.charCodeAt(e)] = e;
|
|
1019
|
-
let o = new Uint8Array(Math.floor(r.length * 5 / 8)), s = 0, c = 0, l = 0;
|
|
1020
|
-
for (let e of r) {
|
|
1021
|
-
let t = e.charCodeAt(0), n = t < 128 ? a[t] : 255;
|
|
1022
|
-
if (n === 255) throw SyntaxError(`invalid character in byte string: ${JSON.stringify(e)}`);
|
|
1023
|
-
s = s << 5 | n, c += 5, c >= 8 && (c -= 8, o[l++] = s >> c & 255);
|
|
1024
|
-
}
|
|
1025
|
-
if (c > 0 && s & (1 << c) - 1) {
|
|
1026
|
-
let e = "non-zero trailing bits in base32 input";
|
|
1027
|
-
if (n) n(e);
|
|
1028
|
-
else throw SyntaxError(e);
|
|
1029
|
-
}
|
|
1030
|
-
return o;
|
|
1031
|
-
}
|
|
1032
|
-
var Ge = {
|
|
1033
|
-
appStringPrefixes: ["b32"],
|
|
1034
|
-
parseAppString(e, t, n) {
|
|
1035
|
-
return new z(We(Be(t), Ve, n), { ednEncoding: "base32" });
|
|
1036
|
-
}
|
|
1037
|
-
}, Ke = {
|
|
1038
|
-
appStringPrefixes: ["h32"],
|
|
1039
|
-
parseAppString(e, t, n) {
|
|
1040
|
-
return new z(We(Be(t), He, n), { ednEncoding: "base32hex" });
|
|
1041
|
-
}
|
|
1042
|
-
}, qe = 999n, Je = class extends R {
|
|
1043
|
-
constructor(e, t) {
|
|
1044
|
-
let n = t.length === 1 && t[0] instanceof Y ? t[0] : new H(t);
|
|
1045
|
-
super(qe, new H([new Y(e), n]));
|
|
1046
|
-
}
|
|
1047
|
-
_toCDN(e, t) {
|
|
1048
|
-
if (e?.appPrefix === !1) return super._toCDN(e, t);
|
|
1049
|
-
let n = this.content, r = n.items[0].value, i = n.items[1];
|
|
1050
|
-
return i instanceof Y ? `${r}${ne(i.value)}` : `${r}<<${i.items.map((n) => n._toCDN(e, t)).join(", ")}>>`;
|
|
1051
|
-
}
|
|
1052
|
-
}, Ye = class extends P {
|
|
1053
|
-
inner;
|
|
1054
|
-
ednSource;
|
|
1055
|
-
constructor(e, t) {
|
|
1056
|
-
super(), this.inner = e, this.ednSource = t;
|
|
1057
|
-
}
|
|
1058
|
-
get _containsCdnContainer() {
|
|
1059
|
-
return this.inner._containsCdnContainer;
|
|
1060
|
-
}
|
|
1061
|
-
_isMultiWordText(e, t = !0) {
|
|
1062
|
-
return y(this._toCDN(e, 0), t);
|
|
1063
|
-
}
|
|
1064
|
-
_encodeTo(e, t) {
|
|
1065
|
-
this.inner._encode(e, t);
|
|
1066
|
-
}
|
|
1067
|
-
_toCDN(e, t) {
|
|
1068
|
-
let n = e?.encodingIndicators ?? "auto";
|
|
1069
|
-
return e?.appPrefix !== !1 && n === "auto" && (O(e) !== null || !/[\r\n]/.test(this.ednSource)) ? this.ednSource : this.inner._toCDN(e, t);
|
|
1070
|
-
}
|
|
1071
|
-
_toJS(e) {
|
|
1072
|
-
return this.inner._toJS(e);
|
|
1073
|
-
}
|
|
1074
|
-
}, Xe = 888n;
|
|
1075
|
-
function Ze(e, t, n, r) {
|
|
1076
|
-
return n ? [...(e.comments?.trailing ?? []).map((e) => b(e, r)), ...(t.comments?.leading ?? []).map((e) => b(e, r))] : [];
|
|
1077
|
-
}
|
|
1078
|
-
function Qe(e, t, n, r) {
|
|
1079
|
-
return n === null || !t.some((e) => e.length > 0) ? e.join(" + ") : oe(e, n, r, t);
|
|
1080
|
-
}
|
|
1081
|
-
function $e(e, t, r, i) {
|
|
1082
|
-
if (e === void 0) return;
|
|
1083
|
-
let a = n(t) || i === void 0 ? e : x(e, i);
|
|
1084
|
-
return tt(a, r) ? a : void 0;
|
|
1085
|
-
}
|
|
1086
|
-
function et(e, t) {
|
|
1087
|
-
return e !== void 0 && tt(e, t);
|
|
1088
|
-
}
|
|
1089
|
-
function tt(e, t) {
|
|
1090
|
-
return t !== null || !/[\r\n]/.test(e);
|
|
1091
|
-
}
|
|
1092
|
-
var K = class e extends R {
|
|
1093
|
-
realBoundary;
|
|
1094
|
-
fromByteLiteral;
|
|
1095
|
-
literalSource;
|
|
1096
|
-
constructor(e, t) {
|
|
1097
|
-
Array.isArray(e) ? (super(Xe, new H(e)), this.fromByteLiteral = !1, this.literalSource = void 0, this.realBoundary = t) : (super(Xe, W.NULL), this.fromByteLiteral = e ?? !1, this.literalSource = t, this.realBoundary = void 0);
|
|
1098
|
-
}
|
|
1099
|
-
_toCDN(t, r) {
|
|
1100
|
-
if (t?.appPrefix === !1) return super._toCDN(t, r);
|
|
1101
|
-
if (this.content instanceof W) return "...";
|
|
1102
|
-
if (this.content instanceof H) {
|
|
1103
|
-
let i = !!t?.preserveConcatenation;
|
|
1104
|
-
if (i || t?.preserveByteString && !this._hasRealConcatenation()) {
|
|
1105
|
-
let e = this._renderPreservedBytesElision(t, r);
|
|
1106
|
-
if (e !== void 0) return e;
|
|
1107
|
-
}
|
|
1108
|
-
if (!i || this.realBoundary === void 0) {
|
|
1109
|
-
let e = this._compactHexElided();
|
|
1110
|
-
if (e !== void 0) return e;
|
|
1111
|
-
}
|
|
1112
|
-
let a = this.content.items, o = a.map((e) => i ? this._renderFragment(e, t, r) : e._toCDN(t, r)), s = n(t), c = u(t), l = a.slice(1).map((e, t) => Ze(a[t], e, s, c));
|
|
1113
|
-
if (t?.modernConcat) {
|
|
1114
|
-
let n = a.every((t) => t instanceof z || t instanceof e && t.content instanceof W);
|
|
1115
|
-
return ie(n ? "b1" : "t1", o, "", O(t), r, l);
|
|
1116
|
-
}
|
|
1117
|
-
return Qe(o, l, O(t), r);
|
|
1118
|
-
}
|
|
1119
|
-
return super._toCDN(t, r);
|
|
1120
|
-
}
|
|
1121
|
-
_hasRealConcatenation() {
|
|
1122
|
-
return this.realBoundary?.some((e, t) => t > 0 && e) ? !0 : this.content.items.some((e) => e instanceof z && e.ednParts !== void 0 && e.ednParts.length > 1);
|
|
1123
|
-
}
|
|
1124
|
-
_renderFragment(e, t, r) {
|
|
1125
|
-
let i = O(t), a = n(t), o = u(t), s = !!t?.modernConcat;
|
|
1126
|
-
if (e instanceof z && e.ednParts !== void 0 && e.ednParts.length > 1) {
|
|
1127
|
-
let n = t?.appPrefix === !1 ? "hex" : t?.bstrEncoding ?? e.ednEncoding, c = e.ednParts.map((e) => {
|
|
1128
|
-
let r = t?.preserveByteString ? $e(e.source, t, i, e.commentSyntax) : void 0;
|
|
1129
|
-
return r === void 0 ? d(e.bytes, n, t?.sqstr) : r;
|
|
1130
|
-
}), l = a ? p(e.comments?.dangling, e.ednParts, o) ?? [] : [];
|
|
1131
|
-
return s ? ie("b1", c, "", i, r, l) : Qe(c, l, i, r);
|
|
1132
|
-
}
|
|
1133
|
-
if (e instanceof Y && e.ednParts !== void 0 && e.ednParts.length > 1) {
|
|
1134
|
-
let n = t?.preserveRawString ? e.ednPartSources : void 0, c = e.ednParts.map((e, t) => {
|
|
1135
|
-
let r = n?.[t];
|
|
1136
|
-
return et(r, i) ? r : h(e);
|
|
1137
|
-
}), l = a ? p(e.comments?.dangling, e.ednPartSpans, o) ?? [] : [];
|
|
1138
|
-
return s ? ie("t1", c, "", i, r, l) : Qe(c, l, i, r);
|
|
1139
|
-
}
|
|
1140
|
-
return e._toCDN(t, r);
|
|
1141
|
-
}
|
|
1142
|
-
_compactHexElided() {
|
|
1143
|
-
let t = this.content.items, n = "", r = !1;
|
|
1144
|
-
for (let i of t) if (i instanceof z) n += s(i.value), r = !0;
|
|
1145
|
-
else if (i instanceof e && i.content instanceof W) n += "...";
|
|
1146
|
-
else return;
|
|
1147
|
-
if (r) return `h'${n}'`;
|
|
1148
|
-
}
|
|
1149
|
-
_renderPreservedBytesElision(t, r) {
|
|
1150
|
-
if (this.realBoundary === void 0) return;
|
|
1151
|
-
let i = this.realBoundary, a = this.content.items, o = [], c = [], l = [], f = (e) => {
|
|
1152
|
-
l.length > 0 && (o.push(l), c.push(e ?? []), l = []);
|
|
1153
|
-
}, m = n(t), h = u(t);
|
|
1154
|
-
for (let t = 0; t < a.length; t++) {
|
|
1155
|
-
let n = a[t];
|
|
1156
|
-
if (t > 0 && i[t] && f(Ze(a[t - 1], n, m, h)), n instanceof e && n.content instanceof W) l.push({
|
|
1157
|
-
ellipsis: !0,
|
|
1158
|
-
fromByteLiteral: n.fromByteLiteral,
|
|
1159
|
-
literalSource: n.literalSource
|
|
1160
|
-
});
|
|
1161
|
-
else if (n instanceof z) {
|
|
1162
|
-
if (n.ednParts !== void 0 && n.ednParts.length > 1) {
|
|
1163
|
-
let [e, ...t] = n.ednParts;
|
|
1164
|
-
l.push({
|
|
1165
|
-
bytes: e.bytes,
|
|
1166
|
-
source: e.source,
|
|
1167
|
-
commentSyntax: e.commentSyntax
|
|
1168
|
-
});
|
|
1169
|
-
let r = m ? p(n.comments?.dangling, n.ednParts, h) : void 0;
|
|
1170
|
-
t.forEach((e, t) => {
|
|
1171
|
-
f(r?.[t]), l.push({
|
|
1172
|
-
bytes: e.bytes,
|
|
1173
|
-
source: e.source,
|
|
1174
|
-
commentSyntax: e.commentSyntax
|
|
1175
|
-
});
|
|
1176
|
-
});
|
|
1177
|
-
} else l.push({
|
|
1178
|
-
bytes: n.value,
|
|
1179
|
-
source: n.ednSource,
|
|
1180
|
-
commentSyntax: n.ednCommentSyntax
|
|
1181
|
-
});
|
|
1182
|
-
} else return;
|
|
1183
|
-
}
|
|
1184
|
-
if (l.length > 0 && o.push(l), o.length === 0) return;
|
|
1185
|
-
let g = t?.appPrefix === !1 ? "hex" : t?.bstrEncoding ?? "hex", _ = O(t), v = o.map((e) => {
|
|
1186
|
-
if (t?.preserveByteString) for (let n of e) {
|
|
1187
|
-
if (!("ellipsis" in n)) continue;
|
|
1188
|
-
let e = $e(n.literalSource, t, _, "full");
|
|
1189
|
-
if (e !== void 0) return e;
|
|
1190
|
-
}
|
|
1191
|
-
let n = e.filter((e) => !("ellipsis" in e));
|
|
1192
|
-
if (n.length === 0) return e.some((e) => "ellipsis" in e && e.fromByteLiteral) ? "h'...'" : "...";
|
|
1193
|
-
if (e.length === 1) {
|
|
1194
|
-
let e = n[0], r = t?.preserveByteString ? $e(e.source, t, _, e.commentSyntax) : void 0;
|
|
1195
|
-
return r === void 0 ? d(e.bytes, g, t?.sqstr) : r;
|
|
1196
|
-
}
|
|
1197
|
-
return `h'${e.map((e) => "ellipsis" in e ? "..." : s(e.bytes)).join("")}'`;
|
|
1198
|
-
});
|
|
1199
|
-
return t?.preserveConcatenation && t?.modernConcat && v.length > 1 ? ie("b1", v, "", _, r, c) : Qe(v, c, _, r);
|
|
1200
|
-
}
|
|
1201
|
-
}, nt = 2n, rt = 3n, it = 18446744073709551615n, at = -18446744073709551616n;
|
|
1202
|
-
function ot(e) {
|
|
1203
|
-
if (e < 0n) throw RangeError("bigintToBytes requires a non-negative value");
|
|
1204
|
-
if (e === 0n) return /* @__PURE__ */ new Uint8Array();
|
|
1205
|
-
let t = e.toString(16);
|
|
1206
|
-
t.length % 2 != 0 && (t = "0" + t);
|
|
1207
|
-
let n = new Uint8Array(t.length / 2);
|
|
1208
|
-
for (let e = 0; e < n.length; e++) n[e] = parseInt(t.slice(e * 2, e * 2 + 2), 16);
|
|
1209
|
-
return n;
|
|
1210
|
-
}
|
|
1211
|
-
function st(e) {
|
|
1212
|
-
let t = 0n;
|
|
1213
|
-
for (let n of e) t = t << 8n | BigInt(n);
|
|
1214
|
-
return t;
|
|
1215
|
-
}
|
|
1216
|
-
var ct = class extends R {
|
|
1217
|
-
bigValue;
|
|
1218
|
-
constructor(e) {
|
|
1219
|
-
if (e <= it) throw RangeError(`CborBigUint value ${e} fits in CborUint; use CborUint instead`);
|
|
1220
|
-
super(nt, new z(ot(e))), this.bigValue = e;
|
|
1221
|
-
}
|
|
1222
|
-
_toCDN(e, t) {
|
|
1223
|
-
return this.bigValue.toString();
|
|
1224
|
-
}
|
|
1225
|
-
_toJS(e) {
|
|
1226
|
-
return this.bigValue;
|
|
1227
|
-
}
|
|
1228
|
-
}, lt = class extends R {
|
|
1229
|
-
bigValue;
|
|
1230
|
-
constructor(e) {
|
|
1231
|
-
if (e >= at) throw RangeError(`CborBigNint value ${e} fits in CborNint; use CborNint instead`);
|
|
1232
|
-
super(rt, new z(ot(-1n - e))), this.bigValue = e;
|
|
1233
|
-
}
|
|
1234
|
-
_toCDN(e, t) {
|
|
1235
|
-
return this.bigValue.toString();
|
|
1236
|
-
}
|
|
1237
|
-
_toJS(e) {
|
|
1238
|
-
return this.bigValue;
|
|
1239
|
-
}
|
|
1240
|
-
}, ut = new TextEncoder(), dt = new TextDecoder("utf-8", { fatal: !0 }), ft = new TextDecoder("utf-8", { fatal: !1 });
|
|
1241
|
-
function pt(t, r) {
|
|
1242
|
-
let i = new e(t, {
|
|
1243
|
-
offset: r?.offset,
|
|
1244
|
-
skipRS: r?._skipRS
|
|
1245
|
-
}), a = new Mt(i, r ?? {}).parse();
|
|
1246
|
-
return (n(r) || r?.preserveAll) && (wt(a, i.comments, t), Dt(a)), a;
|
|
1247
|
-
}
|
|
1248
|
-
function mt(e) {
|
|
1249
|
-
let t = e, n;
|
|
1250
|
-
return /[_][0-7i]$/.test(e) && (n = e[e.length - 1], t = e.slice(0, -2)), {
|
|
1251
|
-
numStr: t,
|
|
1252
|
-
rawSuffix: n
|
|
1253
|
-
};
|
|
1254
|
-
}
|
|
1255
|
-
function ht(e) {
|
|
1256
|
-
return e.startsWith("-") ? -BigInt(e.slice(1)) : BigInt(e);
|
|
1257
|
-
}
|
|
1258
|
-
function q(e) {
|
|
1259
|
-
if (e !== void 0) return _t([e.appSeqSourceFeatures, gt(e)]);
|
|
1260
|
-
}
|
|
1261
|
-
function gt(e) {
|
|
1262
|
-
if (e instanceof z) return {
|
|
1263
|
-
byteString: !0,
|
|
1264
|
-
concatenation: e.ednParts !== void 0 && e.ednParts.length > 1
|
|
1265
|
-
};
|
|
1266
|
-
if (e instanceof Y) {
|
|
1267
|
-
let t = e.ednParts !== void 0, n = e.ednPartSources?.filter((e) => e !== void 0).length ?? 0, r = t ? e.ednParts.reduce((t, n, r) => {
|
|
1268
|
-
let i = e.ednPartSources?.[r] !== void 0, a = e.ednPartIsByteString?.[r] ?? !1;
|
|
1269
|
-
return i || !a ? t : t + 1;
|
|
1270
|
-
}, 0) : 0, i = (t ? e.ednParts.length : 0) - n - r;
|
|
1271
|
-
return {
|
|
1272
|
-
byteString: r > 0,
|
|
1273
|
-
textString: e.quotedEdnSource !== void 0 || i > 0,
|
|
1274
|
-
rawString: e.ednSource !== void 0 || n > 0,
|
|
1275
|
-
concatenation: t && e.ednParts.length > 1
|
|
1276
|
-
};
|
|
1277
|
-
}
|
|
1278
|
-
if (e instanceof H) return _t(e.items.map(q));
|
|
1279
|
-
if (e instanceof U) return _t(e.entries.flatMap(([e, t]) => [q(e), q(t)]));
|
|
1280
|
-
if (e instanceof R) return q(e.content);
|
|
1281
|
-
if (e instanceof B || e instanceof V || e instanceof G) return _t((e instanceof G ? e.items : e.chunks).map(q));
|
|
1282
|
-
}
|
|
1283
|
-
function _t(e) {
|
|
1284
|
-
let t = e.filter((e) => e !== void 0);
|
|
1285
|
-
if (t.length !== 0) return {
|
|
1286
|
-
byteString: t.some((e) => e.byteString),
|
|
1287
|
-
textString: t.some((e) => e.textString),
|
|
1288
|
-
rawString: t.some((e) => e.rawString),
|
|
1289
|
-
concatenation: t.some((e) => e.concatenation)
|
|
1290
|
-
};
|
|
1291
|
-
}
|
|
1292
|
-
function vt(e, t) {
|
|
1293
|
-
if (e.endsWith("_i") || e.endsWith("_0")) {
|
|
1294
|
-
let n = "_0 and _i encoding indicators are not valid for floating-point values";
|
|
1295
|
-
if (t) t(n), e = e.slice(0, -2);
|
|
1296
|
-
else throw SyntaxError(`EDN parse error: ${n}`);
|
|
1297
|
-
} else if (/[_][4567]$/.test(e)) {
|
|
1298
|
-
let n = e[e.length - 1], r = n === "7" ? "indefinite-length encoding (_7) is not valid for floating-point values" : `encoding indicator _${n} (AI ${Number(n) + 24}) is reserved and not valid`;
|
|
1299
|
-
if (t) t(r), e = e.slice(0, -2);
|
|
1300
|
-
else throw SyntaxError(`EDN parse error: ${r}`);
|
|
1301
|
-
}
|
|
1302
|
-
if (e === "NaN") return {
|
|
1303
|
-
value: NaN,
|
|
1304
|
-
precision: void 0
|
|
1305
|
-
};
|
|
1306
|
-
if (e === "Infinity") return {
|
|
1307
|
-
value: Infinity,
|
|
1308
|
-
precision: void 0
|
|
1309
|
-
};
|
|
1310
|
-
if (e === "-Infinity") return {
|
|
1311
|
-
value: -Infinity,
|
|
1312
|
-
precision: void 0
|
|
1313
|
-
};
|
|
1314
|
-
let n = e, r;
|
|
1315
|
-
return e.endsWith("_1") ? (r = "half", n = e.slice(0, -2)) : e.endsWith("_2") ? (r = "single", n = e.slice(0, -2)) : e.endsWith("_3") && (r = "double", n = e.slice(0, -2)), /^-?0[xX]/.test(n) ? {
|
|
1316
|
-
value: Ie(n),
|
|
1317
|
-
precision: r
|
|
1318
|
-
} : {
|
|
1319
|
-
value: parseFloat(n),
|
|
1320
|
-
precision: r
|
|
1321
|
-
};
|
|
1322
|
-
}
|
|
1323
|
-
var yt = /\r?\n[ \t]*\r?\n/;
|
|
1324
|
-
function bt(e, t, n) {
|
|
1325
|
-
return yt.test(e.slice(t, n));
|
|
1326
|
-
}
|
|
1327
|
-
function xt(e, t, n, r) {
|
|
1328
|
-
let i = [];
|
|
1329
|
-
for (let a = t; a < e.length; a++) {
|
|
1330
|
-
let t = e[a];
|
|
1331
|
-
if (t.start >= r) break;
|
|
1332
|
-
t.start >= n && t.end <= r && i.push({
|
|
1333
|
-
...t,
|
|
1334
|
-
start: t.start - n,
|
|
1335
|
-
end: t.end - n
|
|
1336
|
-
});
|
|
1337
|
-
}
|
|
1338
|
-
return i;
|
|
1339
|
-
}
|
|
1340
|
-
function St(e, t, n, r) {
|
|
1341
|
-
if (n.end !== void 0) return {
|
|
1342
|
-
start: (/_[0-7i]$/.test(e.slice(Math.max(0, n.end - 2), n.end)) ? n.end - 2 : n.end) - t,
|
|
1343
|
-
end: n.end - t,
|
|
1344
|
-
always: r,
|
|
1345
|
-
never: ""
|
|
1346
|
-
};
|
|
1347
|
-
}
|
|
1348
|
-
function Ct(t, n, r) {
|
|
1349
|
-
if (r instanceof F) {
|
|
1350
|
-
let e = St(t, n, r, `_${r.encodingWidth ?? E(r.value)}`);
|
|
1351
|
-
return e ? [e] : [];
|
|
1352
|
-
}
|
|
1353
|
-
if (r instanceof I) {
|
|
1354
|
-
let e = St(t, n, r, `_${r.encodingWidth ?? E(r.argument)}`);
|
|
1355
|
-
return e ? [e] : [];
|
|
1356
|
-
}
|
|
1357
|
-
if (r instanceof L) {
|
|
1358
|
-
let e = r.precision ?? N(r.value), i = St(t, n, r, e === "half" ? "_1" : e === "single" ? "_2" : "_3");
|
|
1359
|
-
return i ? [i] : [];
|
|
1360
|
-
}
|
|
1361
|
-
if (r instanceof z) {
|
|
1362
|
-
let e = St(t, n, r, `_${r.encodingWidth ?? E(BigInt(r.value.length))}`);
|
|
1363
|
-
return e ? [e] : [];
|
|
1364
|
-
}
|
|
1365
|
-
if (r instanceof Y) {
|
|
1366
|
-
let e = St(t, n, r, `_${r.encodingWidth ?? E(BigInt(ut.encode(r.value).length))}`);
|
|
1367
|
-
return e ? [e] : [];
|
|
1368
|
-
}
|
|
1369
|
-
if (r instanceof H) {
|
|
1370
|
-
let i = [];
|
|
1371
|
-
if (r.indefiniteLength) return;
|
|
1372
|
-
if (r.start !== void 0) {
|
|
1373
|
-
let a = new e(t, { offset: r.start }), o = a.consume(), s = a.peek(), c = s.type === "ENCODING_INDICATOR", l = `_${r.encodingWidth ?? E(BigInt(r.items.length))}`, u = t[o.endOffset] ?? "", d = !c && /[+\-.0-9A-Z_a-z]/.test(u) ? " " : "";
|
|
1374
|
-
i.push({
|
|
1375
|
-
start: (c ? s.offset : o.endOffset) - n,
|
|
1376
|
-
end: (c ? s.endOffset : o.endOffset) - n,
|
|
1377
|
-
always: l + d,
|
|
1378
|
-
never: ""
|
|
1379
|
-
});
|
|
1380
|
-
}
|
|
1381
|
-
for (let e of r.items) {
|
|
1382
|
-
let r = Ct(t, n, e);
|
|
1383
|
-
if (r === void 0) return;
|
|
1384
|
-
m(i, r);
|
|
1385
|
-
}
|
|
1386
|
-
return i;
|
|
1387
|
-
}
|
|
1388
|
-
}
|
|
1389
|
-
function wt(e, t, n) {
|
|
1390
|
-
if (t.length === 0) return;
|
|
1391
|
-
let r = Tt(e), i = Ot(n), a = [...r].sort((e, t) => e.start - t.start || t.end - e.end), o = [...r].sort((e, t) => e.end - t.end || e.start - t.start), s = [...t].sort((e, t) => e.start - t.start), c = [], l = 0;
|
|
1392
|
-
for (let e of s) {
|
|
1393
|
-
let t = { ...e }, r = 0, s = o.length;
|
|
1394
|
-
for (; r < s;) {
|
|
1395
|
-
let t = r + s >> 1;
|
|
1396
|
-
o[t].end <= e.start ? r = t + 1 : s = t;
|
|
1397
|
-
}
|
|
1398
|
-
let u = r > 0 ? o[r - 1] : void 0, d = u ? n.slice(u.end, e.start) : "";
|
|
1399
|
-
if (u && i(u.end) === e.line && !d.includes(":")) {
|
|
1400
|
-
Et(u.node, "trailing", t);
|
|
1401
|
-
continue;
|
|
1402
|
-
}
|
|
1403
|
-
for (; l < a.length && a[l].start < e.start;) {
|
|
1404
|
-
let e = a[l++];
|
|
1405
|
-
for (; c.length > 0 && c[c.length - 1].end <= e.start;) c.pop();
|
|
1406
|
-
c.push(e);
|
|
1407
|
-
}
|
|
1408
|
-
for (; c.length > 0 && c[c.length - 1].end <= e.start;) c.pop();
|
|
1409
|
-
let f = c.length > 0 ? c[c.length - 1] : void 0;
|
|
1410
|
-
for (r = 0, s = a.length; r < s;) {
|
|
1411
|
-
let t = r + s >> 1;
|
|
1412
|
-
a[t].start < e.end ? r = t + 1 : s = t;
|
|
1413
|
-
}
|
|
1414
|
-
let p = r < a.length ? a[r] : void 0;
|
|
1415
|
-
if ((!f || p && p.end <= f.end) && p) {
|
|
1416
|
-
t.sameLine = i(e.end) === i(p.start), Et(p.node, "leading", t);
|
|
1417
|
-
continue;
|
|
1418
|
-
}
|
|
1419
|
-
f && Et(f.node, "dangling", t);
|
|
1420
|
-
}
|
|
1421
|
-
}
|
|
1422
|
-
function Tt(e) {
|
|
1423
|
-
let t = [], n = (e) => {
|
|
1424
|
-
if (e.start !== void 0 && e.end !== void 0 && t.push({
|
|
1425
|
-
node: e,
|
|
1426
|
-
start: e.start,
|
|
1427
|
-
end: e.end
|
|
1428
|
-
}), e instanceof H || e instanceof G) {
|
|
1429
|
-
for (let t of e.items) n(t);
|
|
1430
|
-
return;
|
|
1431
|
-
}
|
|
1432
|
-
if (e instanceof U) {
|
|
1433
|
-
for (let [t, r] of e.entries) n(t), n(r);
|
|
1434
|
-
return;
|
|
1435
|
-
}
|
|
1436
|
-
if (e instanceof B || e instanceof V) {
|
|
1437
|
-
for (let t of e.chunks) n(t);
|
|
1438
|
-
return;
|
|
1439
|
-
}
|
|
1440
|
-
e instanceof R && n(e.content);
|
|
1441
|
-
};
|
|
1442
|
-
return n(e), t;
|
|
1443
|
-
}
|
|
1444
|
-
function Et(e, t, n) {
|
|
1445
|
-
e.comments ??= {}, e.comments[t] ??= [], e.comments[t].push(n);
|
|
1446
|
-
}
|
|
1447
|
-
function Dt(e) {
|
|
1448
|
-
if (e instanceof K) {
|
|
1449
|
-
if (e.content instanceof H) {
|
|
1450
|
-
let t = e.content.items;
|
|
1451
|
-
for (let e of t) Dt(e);
|
|
1452
|
-
let n = t[t.length - 1], r = n?.comments?.trailing;
|
|
1453
|
-
r !== void 0 && r.length > 0 && !e.comments?.trailing?.length && (e.comments ??= {}, e.comments.trailing = r, n.comments.trailing = void 0);
|
|
1454
|
-
}
|
|
1455
|
-
return;
|
|
1456
|
-
}
|
|
1457
|
-
if (e instanceof H || e instanceof G) {
|
|
1458
|
-
for (let t of e.items) Dt(t);
|
|
1459
|
-
return;
|
|
1460
|
-
}
|
|
1461
|
-
if (e instanceof U) {
|
|
1462
|
-
for (let [t, n] of e.entries) Dt(t), Dt(n);
|
|
1463
|
-
return;
|
|
1464
|
-
}
|
|
1465
|
-
if (e instanceof B || e instanceof V) {
|
|
1466
|
-
for (let t of e.chunks) Dt(t);
|
|
1467
|
-
return;
|
|
1468
|
-
}
|
|
1469
|
-
e instanceof R && Dt(e.content);
|
|
1470
|
-
}
|
|
1471
|
-
function Ot(e) {
|
|
1472
|
-
let t = [0];
|
|
1473
|
-
for (let n = 0; n < e.length; n++) e[n] === "\n" && t.push(n + 1);
|
|
1474
|
-
return (n) => {
|
|
1475
|
-
let r = Math.max(0, Math.min(e.length, n));
|
|
1476
|
-
r > 0 && r === e.length && r--;
|
|
1477
|
-
let i = 0, a = t.length - 1;
|
|
1478
|
-
for (; i <= a;) {
|
|
1479
|
-
let e = i + a >> 1;
|
|
1480
|
-
t[e] <= r ? i = e + 1 : a = e - 1;
|
|
1481
|
-
}
|
|
1482
|
-
return a + 1;
|
|
1483
|
-
};
|
|
1484
|
-
}
|
|
1485
|
-
var kt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'extensions' option (extensions: [${e}])`, At = (e, t) => `install ${t}, import { ${e} } from '${t}', and pass it via the 'extensions' option (extensions: [${e}])`, J = (e) => `'${e}' is a default built-in extension that was excluded via the 'builtinExtensions' option; add it back to that array (or omit 'builtinExtensions' to use the default set)`, jt = /* @__PURE__ */ new Map([
|
|
1486
|
-
["b32", kt("b32")],
|
|
1487
|
-
["h32", kt("h32")],
|
|
1488
|
-
["same", kt("same")],
|
|
1489
|
-
["hash", At("hash", "@cbortech/hash-extension")],
|
|
1490
|
-
["uuid", At("uuid", "@cbortech/uuid-extension")],
|
|
1491
|
-
["UUID", At("uuid", "@cbortech/uuid-extension")],
|
|
1492
|
-
["dt", J("dt")],
|
|
1493
|
-
["DT", J("dt")],
|
|
1494
|
-
["ip", J("ip")],
|
|
1495
|
-
["IP", J("ip")],
|
|
1496
|
-
["cri", J("cri")],
|
|
1497
|
-
["CRI", J("cri")],
|
|
1498
|
-
["t1", J("t1")],
|
|
1499
|
-
["b1", J("b1")],
|
|
1500
|
-
["ilbs", J("ilbs")],
|
|
1501
|
-
["ilts", J("ilts")],
|
|
1502
|
-
["float", J("float")]
|
|
1503
|
-
]), Mt = class {
|
|
1504
|
-
t;
|
|
1505
|
-
_options;
|
|
1506
|
-
extByPrefix;
|
|
1507
|
-
extByTag;
|
|
1508
|
-
unresolvedExtension;
|
|
1509
|
-
_pendingWarnings = [];
|
|
1510
|
-
_hintedPrefixes = /* @__PURE__ */ new Set();
|
|
1511
|
-
constructor(e, t) {
|
|
1512
|
-
this.t = e, this._options = t, this.extByPrefix = /* @__PURE__ */ new Map(), this.extByTag = /* @__PURE__ */ new Map(), this.unresolvedExtension = t.unresolvedExtension ?? "cpa999";
|
|
1513
|
-
let n = di(t.builtinExtensions);
|
|
1514
|
-
for (let e of [...n, ...t.extensions ?? []]) {
|
|
1515
|
-
for (let t of e.appStringPrefixes ?? []) this.extByPrefix.set(t, e);
|
|
1516
|
-
for (let t of e.tagNumbers ?? []) this.extByTag.set(t, e);
|
|
1517
|
-
}
|
|
1518
|
-
this.t.onEscapeWarning = (e, t, n, r, i) => {
|
|
1519
|
-
let o = {
|
|
1520
|
-
message: e,
|
|
1521
|
-
offset: t,
|
|
1522
|
-
line: n,
|
|
1523
|
-
column: r,
|
|
1524
|
-
endOffset: i
|
|
1525
|
-
};
|
|
1526
|
-
if (this._pendingWarnings.push(o), this._options.onWarning ? this._options.onWarning(o) : this._options.silent || console.warn(`CDN strict violation at line ${n}, column ${r}: ${e}`), this._options.strict !== !1) throw new a(e, {
|
|
1527
|
-
offset: t,
|
|
1528
|
-
line: n,
|
|
1529
|
-
column: r,
|
|
1530
|
-
endOffset: i
|
|
1531
|
-
});
|
|
1532
|
-
};
|
|
1533
|
-
}
|
|
1534
|
-
parse() {
|
|
1535
|
-
let e = this.parseValue();
|
|
1536
|
-
if (this._options.allowTrailing) return e;
|
|
1537
|
-
let t = this.t.peek();
|
|
1538
|
-
if (t.type !== "EOF") for (this._warnOrFail(`unexpected token after value: ${JSON.stringify(t.value)}`, t), this._pendingWarnings.length > 0 && (e.warnings ??= [], e.warnings.push(...this._pendingWarnings), this._pendingWarnings = []); this.t.peek().type !== "EOF";) this.t.consume();
|
|
1539
|
-
return e;
|
|
1540
|
-
}
|
|
1541
|
-
parseValue() {
|
|
1542
|
-
let e = this.t.peek().offset, t = this._parseValueNode();
|
|
1543
|
-
if (this.t.peek().type === "UNDERSCORE") {
|
|
1544
|
-
let e = this.t.consume();
|
|
1545
|
-
this._warnOrFail("bare _ is not a valid encoding indicator; use _0, _1, _2, _3, or _i", e);
|
|
1546
|
-
}
|
|
1547
|
-
if (this._pendingWarnings.length > 0) {
|
|
1548
|
-
t.warnings ??= [];
|
|
1549
|
-
for (let e of this._pendingWarnings) t.warnings.push(e);
|
|
1550
|
-
this._pendingWarnings = [];
|
|
1551
|
-
}
|
|
1552
|
-
return t.start = e, t.end = this.t.lastEndOffset, t;
|
|
1553
|
-
}
|
|
1554
|
-
_parseValueNode() {
|
|
1555
|
-
let e = this.t.peek();
|
|
1556
|
-
switch (e.type) {
|
|
1557
|
-
case "INTEGER": return this.parseIntegerOrTag();
|
|
1558
|
-
case "FLOAT": return this.parseFloat();
|
|
1559
|
-
case "TSTR":
|
|
1560
|
-
case "RAWSTRING": return this.parseString();
|
|
1561
|
-
case "BYTES_HEX":
|
|
1562
|
-
case "SQSTR":
|
|
1563
|
-
case "BYTES_B64": return this.t.consume(), this._parseBytesConcat(this._decodeBytesToken(e), e.type, e.raw, e.offset, e.endOffset);
|
|
1564
|
-
case "EMPTY_INDEF_BYTES": return this.t.consume(), new B([]);
|
|
1565
|
-
case "EMPTY_INDEF_TEXT": return this.t.consume(), new V([]);
|
|
1566
|
-
case "TRUE": return this.t.consume(), new W(21);
|
|
1567
|
-
case "FALSE": return this.t.consume(), new W(20);
|
|
1568
|
-
case "NULL": return this.t.consume(), new W(22);
|
|
1569
|
-
case "UNDEFINED": return this.t.consume(), new W(23);
|
|
1570
|
-
case "SIMPLE": return this.parseSimple();
|
|
1571
|
-
case "LBRACKET": return this.parseArray();
|
|
1572
|
-
case "LBRACE": return this.parseMap();
|
|
1573
|
-
case "LPAREN": return this.parseIndefGroup();
|
|
1574
|
-
case "LT_LT": return this.parseEmbeddedCBOR();
|
|
1575
|
-
case "APP_STRING": {
|
|
1576
|
-
this.t.consume();
|
|
1577
|
-
let t, n = "";
|
|
1578
|
-
if (this.t.peek().type === "ENCODING_INDICATOR") {
|
|
1579
|
-
let e = this.t.consume();
|
|
1580
|
-
t = this._resolveEncodingWidth(e.value, e), n = e.raw;
|
|
1581
|
-
}
|
|
1582
|
-
let r = this.extByPrefix.get(e.appPrefix);
|
|
1583
|
-
if (!r?.parseAppString) {
|
|
1584
|
-
if (r || this._hintMissingExtension(e.appPrefix, e), this.unresolvedExtension === "cpa999") return new Je(e.appPrefix, [new Y(e.value)]);
|
|
1585
|
-
this._fail(`unknown app-string extension: ${JSON.stringify(e.appPrefix)}`, e);
|
|
1586
|
-
}
|
|
1587
|
-
{
|
|
1588
|
-
let i = this._pendingWarnings.length;
|
|
1589
|
-
try {
|
|
1590
|
-
let i = r.parseAppString(e.appPrefix, e.value, this._extOnError(e), t === void 0 ? void 0 : { encodingWidth: t });
|
|
1591
|
-
return t !== void 0 && this._applyEiToResult(i, t, e), r.preserveAppSeqSource === "optional" ? (i.appSeqSource = e.raw + n, i) : i instanceof z && Object.getPrototypeOf(i) === z.prototype && i.ednSource === void 0 ? new z(i.value, {
|
|
1592
|
-
ednEncoding: i.ednEncoding,
|
|
1593
|
-
encodingWidth: i.encodingWidth,
|
|
1594
|
-
ednSource: e.raw + n,
|
|
1595
|
-
ednCommentSyntax: r === Ge || r === Ke ? "full" : void 0
|
|
1596
|
-
}) : (i instanceof L && i.ednSource === void 0 && (i.ednSource = e.raw + n), i);
|
|
1597
|
-
} catch (t) {
|
|
1598
|
-
if (this._options.strict !== !1) throw t;
|
|
1599
|
-
return this._pendingWarnings.length === i && this._warn(t instanceof Error ? t.message : String(t), e), new Je(e.appPrefix, [new Y(e.value)]);
|
|
1600
|
-
}
|
|
1601
|
-
}
|
|
1602
|
-
}
|
|
1603
|
-
case "APP_SEQUENCE": {
|
|
1604
|
-
let t = this.t.comments.length;
|
|
1605
|
-
this.t.consume();
|
|
1606
|
-
let n = [];
|
|
1607
|
-
for (; this.t.peek().type !== "GT_GT";) {
|
|
1608
|
-
if (this.t.peek().type === "EOF" && this._fail(`unterminated ${e.appPrefix}<<...>>`, e), n.length > 0) {
|
|
1609
|
-
if (this.t.peek().type === "COMMA") {
|
|
1610
|
-
if (this.t.consume(), this.t.peek().type === "GT_GT") break;
|
|
1611
|
-
} else this.t.peek().offset === this.t.lastEndOffset && this._warnOrFail("<<...>> items must be separated by \",\" or whitespace", this.t.peek());
|
|
1612
|
-
}
|
|
1613
|
-
n.push(this.parseValue());
|
|
1614
|
-
}
|
|
1615
|
-
this.expect("GT_GT");
|
|
1616
|
-
let r, i;
|
|
1617
|
-
this.t.peek().type === "ENCODING_INDICATOR" && (i = this.t.consume(), r = this._resolveEncodingWidth(i.value, i));
|
|
1618
|
-
let a = this.extByPrefix.get(e.appPrefix);
|
|
1619
|
-
if (!a) {
|
|
1620
|
-
if (this._hintMissingExtension(e.appPrefix, e), this.unresolvedExtension === "cpa999") return new Je(e.appPrefix, n);
|
|
1621
|
-
this._fail(`unknown app-string extension: ${JSON.stringify(e.appPrefix)}`, e);
|
|
1622
|
-
}
|
|
1623
|
-
a.parseAppSequence || this._fail(`app-string extension ${JSON.stringify(e.appPrefix)} does not support <<...>> form`, e);
|
|
1624
|
-
{
|
|
1625
|
-
let o = this._pendingWarnings.length;
|
|
1626
|
-
try {
|
|
1627
|
-
let o = a.parseAppSequence(e.appPrefix, n, this._extOnError(e));
|
|
1628
|
-
r !== void 0 && this._applyEiToResult(o, r, i ?? e);
|
|
1629
|
-
let s = this.t.source.slice(e.offset, this.t.lastEndOffset);
|
|
1630
|
-
if (a.preserveAppSeqSource === "optional") o.appSeqSource = s, o.appSeqComments = xt(this.t.comments, t, e.offset, this.t.lastEndOffset), n.length === 1 && (n[0].end !== void 0 && (o.appSeqInnerEnd = n[0].end - e.offset), o.appSeqSourceFeatures = q(n[0]));
|
|
1631
|
-
else if (o instanceof L) o.ednSource === void 0 && (o.ednSource = s);
|
|
1632
|
-
else if (a.preserveAppSeqSource) return new Ye(o, s);
|
|
1633
|
-
return o;
|
|
1634
|
-
} catch (t) {
|
|
1635
|
-
if (this._options.strict !== !1) throw t;
|
|
1636
|
-
return this._pendingWarnings.length === o && this._warn(t instanceof Error ? t.message : String(t), e), new Je(e.appPrefix, n);
|
|
1637
|
-
}
|
|
1638
|
-
}
|
|
1639
|
-
}
|
|
1640
|
-
case "ELLIPSIS": {
|
|
1641
|
-
if (this.t.consume(), this.t.peek().type !== "PLUS") return new K();
|
|
1642
|
-
let e = [new K()];
|
|
1643
|
-
for (; this.t.peek().type === "PLUS";) this.t.consume(), e.push(this.parseValue());
|
|
1644
|
-
return new K(e, e.map(() => !0));
|
|
1645
|
-
}
|
|
1646
|
-
case "BYTES_HEX_ELIDED": return this.t.consume(), this._parseHexElidedConcat(e);
|
|
1647
|
-
default: this._fail(`unexpected token: ${JSON.stringify(e.value)}`, e);
|
|
1648
|
-
}
|
|
1649
|
-
}
|
|
1650
|
-
parseIntegerOrTag() {
|
|
1651
|
-
let e = this.t.comments.length, t = this.t.consume(), { numStr: n, rawSuffix: r } = mt(t.value), i = r === void 0 ? t.endOffset : t.endOffset - 2, a = t.endOffset, o = r === void 0 ? this.consumeEncodingIndicator(void 0, (e) => {
|
|
1652
|
-
i = e.offset, a = e.endOffset;
|
|
1653
|
-
}) : this._resolveEncodingWidth(r, t), s = ht(n), c = r === void 0 ? t.raw : t.raw.slice(0, -2);
|
|
1654
|
-
if (s > 18446744073709551615n) return this.t.peek().type === "LPAREN" && this._fail("tag number exceeds maximum uint64", t), new ct(s);
|
|
1655
|
-
if (s < -18446744073709551616n) return new lt(s);
|
|
1656
|
-
if (o !== void 0) {
|
|
1657
|
-
let e = s >= 0n ? s : -(s + 1n);
|
|
1658
|
-
o = this._validateEncodingFit(e, o, t);
|
|
1659
|
-
}
|
|
1660
|
-
let l = s >= 0n ? new F(s, {
|
|
1661
|
-
encodingWidth: o,
|
|
1662
|
-
ednSource: c
|
|
1663
|
-
}) : new I(s, {
|
|
1664
|
-
encodingWidth: o,
|
|
1665
|
-
ednSource: c
|
|
1666
|
-
});
|
|
1667
|
-
if (this.t.peek().type === "LPAREN") {
|
|
1668
|
-
l instanceof F || this._fail("tag number must be non-negative", t), this.t.consume();
|
|
1669
|
-
let n = this._pendingWarnings.splice(0), r = this.parseValue();
|
|
1670
|
-
this.expect("RPAREN");
|
|
1671
|
-
let s = l.value, u = this.extByTag.get(s);
|
|
1672
|
-
if (u?.parseTag) {
|
|
1673
|
-
let l = u.parseTag(s, r);
|
|
1674
|
-
if (l !== void 0) {
|
|
1675
|
-
if (l instanceof R && (o !== void 0 && l.encodingWidth === void 0 && (l.encodingWidth = o), l.ednSource === void 0 && (l.ednSource = c), u.preserveAppSeqSource === "optional" && l.appSeqSource === void 0)) {
|
|
1676
|
-
l.appSeqSource = this.t.source.slice(t.offset, this.t.lastEndOffset), l.appSeqComments = xt(this.t.comments, e, t.offset, this.t.lastEndOffset);
|
|
1677
|
-
let n = l.encodingWidth ?? E(l.tag), o = Ct(this.t.source, t.offset, l.content);
|
|
1678
|
-
l.appSeqEncodingEdits = [{
|
|
1679
|
-
start: i - t.offset,
|
|
1680
|
-
end: a - t.offset,
|
|
1681
|
-
always: `_${n}`,
|
|
1682
|
-
never: ""
|
|
1683
|
-
}, ...o ?? []], o === void 0 && (l.appSeqEncodingEditsComplete = !1), l.appSeqSourceFeatures = q(r);
|
|
1684
|
-
}
|
|
1685
|
-
return n.length > 0 && (l.warnings ??= [], l.warnings.push(...n)), l;
|
|
1686
|
-
}
|
|
1687
|
-
}
|
|
1688
|
-
let d = new R(s, r, {
|
|
1689
|
-
encodingWidth: o,
|
|
1690
|
-
ednSource: c
|
|
1691
|
-
});
|
|
1692
|
-
return n.length > 0 && (d.warnings ??= [], d.warnings.push(...n)), d;
|
|
1693
|
-
}
|
|
1694
|
-
return l;
|
|
1695
|
-
}
|
|
1696
|
-
parseFloat() {
|
|
1697
|
-
let e = this.t.consume(), t = (t) => this._warnOrFail(t, e), { value: n, precision: r } = vt(e.value, t);
|
|
1698
|
-
if (r === "half" || r === "single") {
|
|
1699
|
-
let e = r === "half" ? A(ye(n)) : Math.fround(n);
|
|
1700
|
-
Object.is(n, e) || isNaN(n) && isNaN(e) || t(`${n} cannot be exactly represented as ${r === "half" ? "f16 (_1)" : "f32 (_2)"}; use _3 or remove the indicator`);
|
|
1701
|
-
}
|
|
1702
|
-
return new L(n, {
|
|
1703
|
-
precision: r,
|
|
1704
|
-
literalSource: e.raw
|
|
1705
|
-
});
|
|
1706
|
-
}
|
|
1707
|
-
parseString() {
|
|
1708
|
-
let e = this.t.consume();
|
|
1709
|
-
if (this.t.peek().type !== "PLUS") {
|
|
1710
|
-
let t = this.consumeEncodingIndicator(() => BigInt(ut.encode(e.value).length));
|
|
1711
|
-
return e.type === "RAWSTRING" ? new Y(e.value, {
|
|
1712
|
-
ednSource: e.raw,
|
|
1713
|
-
...t === void 0 ? {} : { encodingWidth: t }
|
|
1714
|
-
}) : new Y(e.value, {
|
|
1715
|
-
quotedEdnSource: e.raw,
|
|
1716
|
-
...t === void 0 ? {} : { encodingWidth: t }
|
|
1717
|
-
});
|
|
1718
|
-
}
|
|
1719
|
-
let t = !1, n = [e.type === "RAWSTRING" ? {
|
|
1720
|
-
text: e.value,
|
|
1721
|
-
source: e.raw,
|
|
1722
|
-
start: e.offset,
|
|
1723
|
-
end: e.endOffset
|
|
1724
|
-
} : {
|
|
1725
|
-
text: e.value,
|
|
1726
|
-
start: e.offset,
|
|
1727
|
-
end: e.endOffset
|
|
1728
|
-
}];
|
|
1729
|
-
for (; this.t.peek().type === "PLUS";) {
|
|
1730
|
-
this.t.consume();
|
|
1731
|
-
let e = this.t.peek();
|
|
1732
|
-
e.type === "ELLIPSIS" ? (this.t.consume(), n.push({
|
|
1733
|
-
ellipsis: !0,
|
|
1734
|
-
start: e.offset,
|
|
1735
|
-
end: e.endOffset
|
|
1736
|
-
}), t = !0) : e.type === "TSTR" || e.type === "RAWSTRING" ? (this.t.consume(), n.push(e.type === "RAWSTRING" ? {
|
|
1737
|
-
text: e.value,
|
|
1738
|
-
source: e.raw,
|
|
1739
|
-
start: e.offset,
|
|
1740
|
-
end: e.endOffset
|
|
1741
|
-
} : {
|
|
1742
|
-
text: e.value,
|
|
1743
|
-
start: e.offset,
|
|
1744
|
-
end: e.endOffset
|
|
1745
|
-
})) : this._isBytesToken(e.type) ? (this.t.consume(), n.push({
|
|
1746
|
-
text: this._decodeUtf8(this._decodeBytesToken(e), e),
|
|
1747
|
-
isByteString: !0,
|
|
1748
|
-
start: e.offset,
|
|
1749
|
-
end: e.endOffset
|
|
1750
|
-
})) : this._fail(`expected string or byte string after +, got ${JSON.stringify(e.value)}`, e);
|
|
1751
|
-
}
|
|
1752
|
-
if (!t) {
|
|
1753
|
-
let e = n.map((e) => "text" in e ? e.text : ""), t = n.map((e) => "text" in e ? e.source : void 0), r = n.map((e) => "text" in e ? e.isByteString ?? !1 : !1), i = n.map((e) => ({
|
|
1754
|
-
start: e.start,
|
|
1755
|
-
end: e.end
|
|
1756
|
-
})), a = e.join(""), o = this.consumeEncodingIndicator(() => BigInt(ut.encode(a).length));
|
|
1757
|
-
return new Y(a, {
|
|
1758
|
-
ednParts: e,
|
|
1759
|
-
ednPartSpans: i,
|
|
1760
|
-
...t.some((e) => e !== void 0) ? { ednPartSources: t } : {},
|
|
1761
|
-
...r.some((e) => e) ? { ednPartIsByteString: r } : {},
|
|
1762
|
-
...o === void 0 ? {} : { encodingWidth: o }
|
|
1763
|
-
});
|
|
1764
|
-
}
|
|
1765
|
-
let r = [], i = [], a = () => {
|
|
1766
|
-
let e = i.map((e) => e.text), t = e.join("");
|
|
1767
|
-
if (t !== "") {
|
|
1768
|
-
let n = i.map((e) => e.source), a = i.map((e) => e.isByteString ?? !1), o = new Y(t, {
|
|
1769
|
-
ednParts: e,
|
|
1770
|
-
ednPartSpans: i.map((e) => ({
|
|
1771
|
-
start: e.start,
|
|
1772
|
-
end: e.end
|
|
1773
|
-
})),
|
|
1774
|
-
...n.some((e) => e !== void 0) ? { ednPartSources: n } : {},
|
|
1775
|
-
...a.some((e) => e) ? { ednPartIsByteString: a } : {}
|
|
1776
|
-
});
|
|
1777
|
-
o.start = i[0].start, o.end = i[i.length - 1].end, r.push(o);
|
|
1778
|
-
}
|
|
1779
|
-
i.length = 0;
|
|
1780
|
-
};
|
|
1781
|
-
for (let e of n) if ("ellipsis" in e) {
|
|
1782
|
-
a();
|
|
1783
|
-
let t = new K();
|
|
1784
|
-
t.start = e.start, t.end = e.end, r.push(t);
|
|
1785
|
-
} else i.push(e);
|
|
1786
|
-
return a(), new K(r);
|
|
1787
|
-
}
|
|
1788
|
-
_isBytesToken(e) {
|
|
1789
|
-
return e === "BYTES_HEX" || e === "SQSTR" || e === "BYTES_B64";
|
|
1790
|
-
}
|
|
1791
|
-
_hexToBytes(e, t) {
|
|
1792
|
-
try {
|
|
1793
|
-
return i(e);
|
|
1794
|
-
} catch (e) {
|
|
1795
|
-
if (e instanceof a || !(e instanceof SyntaxError)) throw e;
|
|
1796
|
-
this._fail(e.message, t);
|
|
1797
|
-
}
|
|
1798
|
-
}
|
|
1799
|
-
_decodeBytesToken(e) {
|
|
1800
|
-
let t = (t) => this._warnOrFail(t, e);
|
|
1801
|
-
switch (e.type) {
|
|
1802
|
-
case "SQSTR": {
|
|
1803
|
-
let t = e._sqstrBytes;
|
|
1804
|
-
return t === void 0 ? this._hexToBytes(e.value, e) : t;
|
|
1805
|
-
}
|
|
1806
|
-
case "BYTES_HEX": return this._hexToBytes(e.value, e);
|
|
1807
|
-
case "BYTES_B64": try {
|
|
1808
|
-
return ee(e.value, t);
|
|
1809
|
-
} catch (t) {
|
|
1810
|
-
if (t instanceof a || !(t instanceof SyntaxError)) throw t;
|
|
1811
|
-
this._fail(t.message, e);
|
|
1812
|
-
}
|
|
1813
|
-
default: this._fail("expected byte string token", e);
|
|
1814
|
-
}
|
|
1815
|
-
}
|
|
1816
|
-
_decodeUtf8(e, t) {
|
|
1817
|
-
if (this._options.allowInvalidUtf8) return ft.decode(e);
|
|
1818
|
-
try {
|
|
1819
|
-
return dt.decode(e);
|
|
1820
|
-
} catch {
|
|
1821
|
-
return this._warnOrFail("byte string in text concatenation is not valid UTF-8", t), ft.decode(e);
|
|
1822
|
-
}
|
|
1823
|
-
}
|
|
1824
|
-
_tokenTypeToCdnEncoding(e) {
|
|
1825
|
-
return e === "BYTES_B64" ? "base64" : "hex";
|
|
1826
|
-
}
|
|
1827
|
-
_tokenTypeToCommentSyntax(e) {
|
|
1828
|
-
if (e === "BYTES_HEX") return "full";
|
|
1829
|
-
if (e === "BYTES_B64") return "hash-only";
|
|
1830
|
-
}
|
|
1831
|
-
_parseBytesConcat(e, t, n, r, i) {
|
|
1832
|
-
if (this.t.peek().type !== "PLUS") {
|
|
1833
|
-
let r = this.consumeEncodingIndicator(() => BigInt(e.length));
|
|
1834
|
-
return new z(e, {
|
|
1835
|
-
ednEncoding: this._tokenTypeToCdnEncoding(t),
|
|
1836
|
-
ednSource: n,
|
|
1837
|
-
ednCommentSyntax: this._tokenTypeToCommentSyntax(t),
|
|
1838
|
-
...r === void 0 ? {} : { encodingWidth: r }
|
|
1839
|
-
});
|
|
1840
|
-
}
|
|
1841
|
-
let a = [{
|
|
1842
|
-
bytes: e,
|
|
1843
|
-
source: n,
|
|
1844
|
-
commentSyntax: this._tokenTypeToCommentSyntax(t),
|
|
1845
|
-
real: !1,
|
|
1846
|
-
start: r,
|
|
1847
|
-
end: i
|
|
1848
|
-
}], o = this._consumeByteEllipsisChain(a);
|
|
1849
|
-
return this._buildFromByteAtoms(o, this._tokenTypeToCdnEncoding(t));
|
|
1850
|
-
}
|
|
1851
|
-
_parseHexElidedConcat(e) {
|
|
1852
|
-
let t = this._consumeByteEllipsisChain(this._elidedHexAtoms(e.value, e));
|
|
1853
|
-
return this._buildFromByteAtoms(t, "hex");
|
|
1854
|
-
}
|
|
1855
|
-
_consumeByteEllipsisChain(e) {
|
|
1856
|
-
let t = e;
|
|
1857
|
-
for (; this.t.peek().type === "PLUS";) {
|
|
1858
|
-
this.t.consume();
|
|
1859
|
-
let e = this.t.peek();
|
|
1860
|
-
if (e.type === "ELLIPSIS") this.t.consume(), t.push({
|
|
1861
|
-
ellipsis: !0,
|
|
1862
|
-
real: !0,
|
|
1863
|
-
fromByteLiteral: !1,
|
|
1864
|
-
start: e.offset,
|
|
1865
|
-
end: e.endOffset
|
|
1866
|
-
});
|
|
1867
|
-
else if (e.type === "BYTES_HEX_ELIDED") {
|
|
1868
|
-
this.t.consume();
|
|
1869
|
-
let n = this._elidedHexAtoms(e.value, e);
|
|
1870
|
-
n.length > 0 && (n[0].real = !0), m(t, n);
|
|
1871
|
-
} else this._isBytesToken(e.type) ? (this.t.consume(), t.push({
|
|
1872
|
-
bytes: this._decodeBytesToken(e),
|
|
1873
|
-
source: e.raw,
|
|
1874
|
-
commentSyntax: this._tokenTypeToCommentSyntax(e.type),
|
|
1875
|
-
real: !0,
|
|
1876
|
-
start: e.offset,
|
|
1877
|
-
end: e.endOffset
|
|
1878
|
-
})) : e.type === "TSTR" || e.type === "RAWSTRING" ? (this.t.consume(), this._warnOrFail("text string in a byte-string concatenation is not allowed; use a byte string literal (h'...', b64'...', or '...') instead", e), t.push({
|
|
1879
|
-
bytes: ut.encode(e.value),
|
|
1880
|
-
real: !0,
|
|
1881
|
-
start: e.offset,
|
|
1882
|
-
end: e.endOffset
|
|
1883
|
-
})) : this._fail(`expected byte string after +, got ${JSON.stringify(e.value)}`, e);
|
|
1884
|
-
}
|
|
1885
|
-
return t;
|
|
1886
|
-
}
|
|
1887
|
-
_elidedHexAtoms(e, t) {
|
|
1888
|
-
let n = e.split("..."), r = [];
|
|
1889
|
-
for (let e = 0; e < n.length; e++) e > 0 && r.push({
|
|
1890
|
-
ellipsis: !0,
|
|
1891
|
-
real: !1,
|
|
1892
|
-
fromByteLiteral: !0,
|
|
1893
|
-
literalSource: t.raw,
|
|
1894
|
-
start: t.offset,
|
|
1895
|
-
end: t.endOffset
|
|
1896
|
-
}), n[e].length > 0 && r.push({
|
|
1897
|
-
bytes: this._hexToBytes(n[e], t),
|
|
1898
|
-
commentSyntax: "full",
|
|
1899
|
-
real: !1,
|
|
1900
|
-
start: t.offset,
|
|
1901
|
-
end: t.endOffset
|
|
1902
|
-
});
|
|
1903
|
-
return r;
|
|
1904
|
-
}
|
|
1905
|
-
_buildFromByteAtoms(e, t) {
|
|
1906
|
-
if (!e.some((e) => "ellipsis" in e)) {
|
|
1907
|
-
let n = e, r = this._concatBytes(n.map((e) => e.bytes)), i = this.consumeEncodingIndicator(() => BigInt(r.length));
|
|
1908
|
-
return new z(r, {
|
|
1909
|
-
ednEncoding: t,
|
|
1910
|
-
ednParts: n,
|
|
1911
|
-
...i === void 0 ? {} : { encodingWidth: i }
|
|
1912
|
-
});
|
|
1913
|
-
}
|
|
1914
|
-
let n = [], r = [], i = [], a = () => {
|
|
1915
|
-
if (i.length > 0) {
|
|
1916
|
-
let e = new z(this._concatBytes(i.map((e) => e.bytes)), { ...i.length > 1 ? { ednParts: i.map(({ bytes: e, source: t, commentSyntax: n, start: r, end: i }) => ({
|
|
1917
|
-
bytes: e,
|
|
1918
|
-
source: t,
|
|
1919
|
-
commentSyntax: n,
|
|
1920
|
-
start: r,
|
|
1921
|
-
end: i
|
|
1922
|
-
})) } : {
|
|
1923
|
-
ednSource: i[0].source,
|
|
1924
|
-
ednCommentSyntax: i[0].commentSyntax
|
|
1925
|
-
} });
|
|
1926
|
-
e.start = i[0].start, e.end = i[i.length - 1].end, n.push(e), r.push(i[0].real), i.length = 0;
|
|
1927
|
-
}
|
|
1928
|
-
};
|
|
1929
|
-
for (let t of e) if ("ellipsis" in t) {
|
|
1930
|
-
a();
|
|
1931
|
-
let e = new K(t.fromByteLiteral, t.literalSource);
|
|
1932
|
-
e.start = t.start, e.end = t.end, n.push(e), r.push(t.real);
|
|
1933
|
-
} else i.push(t);
|
|
1934
|
-
return a(), new K(n, r);
|
|
1935
|
-
}
|
|
1936
|
-
_concatBytes(e) {
|
|
1937
|
-
let t = e.reduce((e, t) => e + t.byteLength, 0), n = new Uint8Array(t), r = 0;
|
|
1938
|
-
for (let t of e) n.set(t, r), r += t.byteLength;
|
|
1939
|
-
return n;
|
|
1940
|
-
}
|
|
1941
|
-
parseSimple() {
|
|
1942
|
-
this.t.consume(), this.expect("LPAREN");
|
|
1943
|
-
let e = this.t.peek();
|
|
1944
|
-
e.type !== "INTEGER" && this._fail(`expected integer inside simple(), got ${JSON.stringify(e.value)}`, e), this.t.consume();
|
|
1945
|
-
let { numStr: t } = mt(e.value), n = Number(ht(t));
|
|
1946
|
-
return this.expect("RPAREN"), new W(n, { ednSource: e.raw });
|
|
1947
|
-
}
|
|
1948
|
-
parseEmbeddedCBOR() {
|
|
1949
|
-
this.t.consume();
|
|
1950
|
-
let e = [];
|
|
1951
|
-
for (; this.t.peek().type !== "GT_GT";) {
|
|
1952
|
-
if (e.length > 0) {
|
|
1953
|
-
if (this.t.peek().type === "COMMA") {
|
|
1954
|
-
if (this.t.consume(), this.t.peek().type === "GT_GT") break;
|
|
1955
|
-
} else this.t.peek().offset === this.t.lastEndOffset && this._warnOrFail("<<...>> items must be separated by \",\" or whitespace", this.t.peek());
|
|
1956
|
-
}
|
|
1957
|
-
e.push(this.parseValue());
|
|
1958
|
-
}
|
|
1959
|
-
this.expect("GT_GT");
|
|
1960
|
-
let t;
|
|
1961
|
-
if (this.t.peek().type === "ENCODING_INDICATOR") {
|
|
1962
|
-
let e = this.t.consume();
|
|
1963
|
-
t = this._resolveEncodingWidth(e.value, e);
|
|
1964
|
-
}
|
|
1965
|
-
return new G(e, { encodingWidth: t });
|
|
1966
|
-
}
|
|
1967
|
-
parseArray() {
|
|
1968
|
-
this.t.consume();
|
|
1969
|
-
let e = !1, t, n;
|
|
1970
|
-
this.t.peek().type === "UNDERSCORE" ? (this.t.consume(), e = !0) : this.t.peek().type === "ENCODING_INDICATOR" && (n = this.t.consume(), n.value === "7" ? (e = !0, this._warnOrFail("encoding indicator _7 is non-standard; use _ to indicate indefinite length", n), n = void 0) : t = this._resolveEncodingWidth(n.value, n));
|
|
1971
|
-
let r = this._pendingWarnings.splice(0), i = [], a = this.t.lastEndOffset;
|
|
1972
|
-
for (; this.t.peek().type !== "RBRACKET";) {
|
|
1973
|
-
if (i.length > 0) {
|
|
1974
|
-
if (this.t.peek().type === "COMMA") {
|
|
1975
|
-
if (this.t.consume(), this.t.peek().type === "RBRACKET") break;
|
|
1976
|
-
} else this.t.peek().offset === this.t.lastEndOffset && this._warnOrFail("array items must be separated by \",\" or whitespace", this.t.peek());
|
|
1977
|
-
}
|
|
1978
|
-
let e = this.parseValue();
|
|
1979
|
-
bt(this.t.source, a, e.start) && (e.blankLineBefore = !0), a = e.end, i.push(e);
|
|
1980
|
-
}
|
|
1981
|
-
this.expect("RBRACKET"), t !== void 0 && n !== void 0 && (t = this._validateEncodingFit(BigInt(i.length), t, n));
|
|
1982
|
-
let o = new H(i, {
|
|
1983
|
-
indefiniteLength: e,
|
|
1984
|
-
encodingWidth: t
|
|
1985
|
-
});
|
|
1986
|
-
return r.length > 0 && (o.warnings ??= [], o.warnings.push(...r)), o;
|
|
1987
|
-
}
|
|
1988
|
-
parseMap() {
|
|
1989
|
-
this.t.consume();
|
|
1990
|
-
let e = !1, t, n;
|
|
1991
|
-
this.t.peek().type === "UNDERSCORE" ? (this.t.consume(), e = !0) : this.t.peek().type === "ENCODING_INDICATOR" && (n = this.t.consume(), n.value === "7" ? (e = !0, this._warnOrFail("encoding indicator _7 is non-standard; use _ to indicate indefinite length", n), n = void 0) : t = this._resolveEncodingWidth(n.value, n));
|
|
1992
|
-
let r = this._pendingWarnings.splice(0), i = [], a = this.t.lastEndOffset;
|
|
1993
|
-
for (; this.t.peek().type !== "RBRACE";) {
|
|
1994
|
-
if (i.length > 0) {
|
|
1995
|
-
if (this.t.peek().type === "COMMA") {
|
|
1996
|
-
if (this.t.consume(), this.t.peek().type === "RBRACE") break;
|
|
1997
|
-
} else this.t.peek().offset === this.t.lastEndOffset && this._warnOrFail("map entries must be separated by \",\" or whitespace", this.t.peek());
|
|
1998
|
-
}
|
|
1999
|
-
let e = this.parseValue();
|
|
2000
|
-
bt(this.t.source, a, e.start) && (e.blankLineBefore = !0), this.expect("COLON");
|
|
2001
|
-
let t = this.parseValue();
|
|
2002
|
-
a = t.end, i.push([e, t]);
|
|
2003
|
-
}
|
|
2004
|
-
this.expect("RBRACE"), t !== void 0 && n !== void 0 && (t = this._validateEncodingFit(BigInt(i.length), t, n));
|
|
2005
|
-
let o = new U(i, {
|
|
2006
|
-
indefiniteLength: e,
|
|
2007
|
-
encodingWidth: t
|
|
2008
|
-
});
|
|
2009
|
-
return r.length > 0 && (o.warnings ??= [], o.warnings.push(...r)), o;
|
|
2010
|
-
}
|
|
2011
|
-
parseIndefGroup() {
|
|
2012
|
-
this.t.consume();
|
|
2013
|
-
let e = this.t.peek();
|
|
2014
|
-
if (e.type === "UNDERSCORE") this.t.consume();
|
|
2015
|
-
else if (e.type === "ENCODING_INDICATOR" && e.value === "7") this.t.consume(), this._warnOrFail("encoding indicator _7 is non-standard; use _ to indicate indefinite length", e);
|
|
2016
|
-
else if (e.type === "ENCODING_INDICATOR") {
|
|
2017
|
-
let e = this.t.consume(), t = `encoding indicator _${e.value} is not valid in an indefinite string group; use _`;
|
|
2018
|
-
this._warnOrFail(t, e);
|
|
2019
|
-
} else e.type !== "RPAREN" && this._warnOrFail("indefinite string group is missing _ after (; interpreting as (_ ...)", e);
|
|
2020
|
-
let t = this._pendingWarnings.splice(0), n = [], r = this.t.lastEndOffset;
|
|
2021
|
-
for (; this.t.peek().type !== "RPAREN";) {
|
|
2022
|
-
if (n.length > 0) {
|
|
2023
|
-
if (this.t.peek().type === "COMMA") {
|
|
2024
|
-
if (this.t.consume(), this.t.peek().type === "RPAREN") break;
|
|
2025
|
-
} else this.t.peek().offset === this.t.lastEndOffset && this._warnOrFail("indefinite string chunks must be separated by \",\" or whitespace", this.t.peek());
|
|
2026
|
-
}
|
|
2027
|
-
let e = this.parseValue();
|
|
2028
|
-
bt(this.t.source, r, e.start) && (e.blankLineBefore = !0), r = e.end, n.push(e);
|
|
2029
|
-
}
|
|
2030
|
-
this.expect("RPAREN"), n.length === 0 && this._fail("empty indefinite group (_ ) is ambiguous; use ''_ for bytes or \"\"_ for text");
|
|
2031
|
-
let i = n[0];
|
|
2032
|
-
if (i instanceof z) {
|
|
2033
|
-
let e = new B(n.map((e, t) => {
|
|
2034
|
-
if (e instanceof z) return e;
|
|
2035
|
-
this._fail(`indefinite byte string chunk ${t} must be a byte string, not a text string`);
|
|
2036
|
-
}));
|
|
2037
|
-
return t.length > 0 && (e.warnings = t), e;
|
|
2038
|
-
}
|
|
2039
|
-
if (i instanceof Y) {
|
|
2040
|
-
let e = new V(n.map((e, t) => {
|
|
2041
|
-
if (e instanceof Y) return e;
|
|
2042
|
-
this._fail(`indefinite text string chunk ${t} must be a text string, not a byte string`);
|
|
2043
|
-
}));
|
|
2044
|
-
return t.length > 0 && (e.warnings = t), e;
|
|
2045
|
-
}
|
|
2046
|
-
this._fail("indefinite group chunks must be byte strings or text strings");
|
|
2047
|
-
}
|
|
2048
|
-
consumeEncodingIndicator(e, t) {
|
|
2049
|
-
if (this.t.peek().type === "ENCODING_INDICATOR") {
|
|
2050
|
-
let n = this.t.consume();
|
|
2051
|
-
t?.(n);
|
|
2052
|
-
let r = this._resolveEncodingWidth(n.value, n);
|
|
2053
|
-
return r !== void 0 && e !== void 0 && (r = this._validateEncodingFit(e(), r, n)), r;
|
|
2054
|
-
}
|
|
2055
|
-
}
|
|
2056
|
-
expect(e) {
|
|
2057
|
-
let t = this.t.consume();
|
|
2058
|
-
return t.type !== e && this._fail(`expected ${e}, got ${t.type} (${JSON.stringify(t.value)})`, t), t;
|
|
2059
|
-
}
|
|
2060
|
-
_applyEiToResult(e, t, n) {
|
|
2061
|
-
if (e instanceof L) {
|
|
2062
|
-
let r = t === 1 ? "half" : t === 2 ? "single" : t === 3 ? "double" : void 0;
|
|
2063
|
-
if (r === void 0) this._warnOrFail(`encoding indicator _${t} is not valid for a float; use _1, _2, or _3`, n);
|
|
2064
|
-
else if (e.precision !== r) {
|
|
2065
|
-
if (r !== "double") {
|
|
2066
|
-
let t = r === "half" ? A(ye(e.value)) : Math.fround(e.value);
|
|
2067
|
-
!Object.is(t, e.value) && !isNaN(e.value) && this._warnOrFail(`${e.value} cannot be exactly represented as ${r === "half" ? "float16 (_1)" : "float32 (_2)"}`, n);
|
|
2068
|
-
}
|
|
2069
|
-
e.precision = r;
|
|
2070
|
-
}
|
|
2071
|
-
} else if (e instanceof F) {
|
|
2072
|
-
if (e.encodingWidth === void 0) {
|
|
2073
|
-
let r = this._validateEncodingFit(e.value, t, n);
|
|
2074
|
-
r !== void 0 && (e.encodingWidth = r);
|
|
2075
|
-
}
|
|
2076
|
-
} else if (e instanceof I) {
|
|
2077
|
-
if (e.encodingWidth === void 0) {
|
|
2078
|
-
let r = this._validateEncodingFit(e.argument, t, n);
|
|
2079
|
-
r !== void 0 && (e.encodingWidth = r);
|
|
2080
|
-
}
|
|
2081
|
-
} else if (e instanceof z) {
|
|
2082
|
-
if (e.encodingWidth === void 0) {
|
|
2083
|
-
let r = this._validateEncodingFit(BigInt(e.value.length), t, n);
|
|
2084
|
-
r !== void 0 && (e.encodingWidth = r);
|
|
2085
|
-
}
|
|
2086
|
-
} else if (e instanceof Y) {
|
|
2087
|
-
if (e.encodingWidth === void 0) {
|
|
2088
|
-
let r = this._validateEncodingFit(BigInt(ut.encode(e.value).length), t, n);
|
|
2089
|
-
r !== void 0 && (e.encodingWidth = r);
|
|
2090
|
-
}
|
|
2091
|
-
} else if (e instanceof H) {
|
|
2092
|
-
if (e.encodingWidth === void 0) {
|
|
2093
|
-
let r = this._validateEncodingFit(BigInt(e.items.length), t, n);
|
|
2094
|
-
r !== void 0 && (e.encodingWidth = r);
|
|
2095
|
-
}
|
|
2096
|
-
} else if (e instanceof U) {
|
|
2097
|
-
if (e.encodingWidth === void 0) {
|
|
2098
|
-
let r = this._validateEncodingFit(BigInt(e.entries.length), t, n);
|
|
2099
|
-
r !== void 0 && (e.encodingWidth = r);
|
|
2100
|
-
}
|
|
2101
|
-
} else if (e instanceof R) {
|
|
2102
|
-
if (e.encodingWidth === void 0) {
|
|
2103
|
-
let r = this._validateEncodingFit(e.tag, t, n);
|
|
2104
|
-
r !== void 0 && (e.encodingWidth = r);
|
|
2105
|
-
}
|
|
2106
|
-
} else this._warnOrFail(`encoding indicator _${t} is not applicable to this app-string result type`, n);
|
|
2107
|
-
}
|
|
2108
|
-
_validateEncodingFit(e, t, n) {
|
|
2109
|
-
let r = Oe(t);
|
|
2110
|
-
if (e <= r) return t;
|
|
2111
|
-
let i = `value ${e} does not fit in encoding indicator ${t === "i" ? "_i (max 23)" : `_${t} (max ${r})`}`;
|
|
2112
|
-
this._warnOrFail(i, n);
|
|
2113
|
-
}
|
|
2114
|
-
_resolveEncodingWidth(e, t) {
|
|
2115
|
-
if (e === "4" || e === "5" || e === "6") {
|
|
2116
|
-
let n = `encoding indicator _${e} (AI ${Number(e) + 24}) is reserved and not valid`;
|
|
2117
|
-
this._warnOrFail(n, t);
|
|
2118
|
-
return;
|
|
2119
|
-
}
|
|
2120
|
-
if (e === "7") {
|
|
2121
|
-
this._warnOrFail("indefinite-length encoding (_7) is not valid here; use [_ ...] or {_ ...} for indefinite collections", t);
|
|
2122
|
-
return;
|
|
2123
|
-
}
|
|
2124
|
-
return e === "i" ? "i" : Number(e);
|
|
2125
|
-
}
|
|
2126
|
-
_extOnError(e) {
|
|
2127
|
-
return (t) => this._warnOrFail(t, e);
|
|
2128
|
-
}
|
|
2129
|
-
_warnOrFail(e, t) {
|
|
2130
|
-
this._warn(e, t), this._options.strict !== !1 && this._fail(e, t);
|
|
2131
|
-
}
|
|
2132
|
-
_hintMissingExtension(e, t) {
|
|
2133
|
-
let n = jt.get(e);
|
|
2134
|
-
if (n === void 0 || this._hintedPrefixes.has(e)) return;
|
|
2135
|
-
this._hintedPrefixes.add(e);
|
|
2136
|
-
let r = `app-string prefix '${e}' requires an extension that is not enabled; ${n}`;
|
|
2137
|
-
this._options.onWarning ? this._options.onWarning({
|
|
2138
|
-
message: r,
|
|
2139
|
-
...Nt(t),
|
|
2140
|
-
hint: !0
|
|
2141
|
-
}) : this._options.silent || console.warn(`CDN: ${r}`);
|
|
2142
|
-
}
|
|
2143
|
-
_warn(e, t) {
|
|
2144
|
-
let n = { message: e };
|
|
2145
|
-
if (t !== void 0 && Object.assign(n, Nt(t)), this._pendingWarnings.push(n), this._options.onWarning) this._options.onWarning(n);
|
|
2146
|
-
else if (!this._options.silent) {
|
|
2147
|
-
let n = t ? ` at line ${t.line}, column ${t.col}` : "";
|
|
2148
|
-
console.warn(`CDN strict violation${n}: ${e}`);
|
|
2149
|
-
}
|
|
2150
|
-
}
|
|
2151
|
-
_fail(e, t) {
|
|
2152
|
-
throw new a(e, t ? Nt(t) : void 0);
|
|
2153
|
-
}
|
|
2154
|
-
};
|
|
2155
|
-
function Nt(e) {
|
|
2156
|
-
return {
|
|
2157
|
-
offset: e.offset,
|
|
2158
|
-
line: e.line,
|
|
2159
|
-
column: e.col,
|
|
2160
|
-
endOffset: e.endOffset
|
|
2161
|
-
};
|
|
2162
|
-
}
|
|
2163
|
-
//#endregion
|
|
2164
|
-
//#region src/ast/CborTextString.ts
|
|
2165
|
-
var Pt = new TextEncoder(), Ft = new TextDecoder(), It = !1, Y = class extends P {
|
|
2166
|
-
indefiniteLength = !1;
|
|
2167
|
-
value;
|
|
2168
|
-
encodingWidth;
|
|
2169
|
-
ednParts;
|
|
2170
|
-
ednSource;
|
|
2171
|
-
quotedEdnSource;
|
|
2172
|
-
ednPartSources;
|
|
2173
|
-
ednPartIsByteString;
|
|
2174
|
-
ednPartSpans;
|
|
2175
|
-
constructor(e, t) {
|
|
2176
|
-
super(), this.value = e, this.encodingWidth = t?.encodingWidth, this.ednParts = t?.ednParts, this.ednSource = t?.ednSource, this.quotedEdnSource = t?.quotedEdnSource, this.ednPartSources = t?.ednPartSources, this.ednPartIsByteString = t?.ednPartIsByteString, this.ednPartSpans = t?.ednPartSpans;
|
|
2177
|
-
}
|
|
2178
|
-
_isMultiWordText(e, t = !0) {
|
|
2179
|
-
return v(this.value);
|
|
2180
|
-
}
|
|
2181
|
-
_encodeTo(e, t) {
|
|
2182
|
-
e.writeTextString(3, this.value, this.encodingWidth);
|
|
2183
|
-
}
|
|
2184
|
-
_toCDN(e, n) {
|
|
2185
|
-
let r = t(e, this.encodingWidth, () => E(BigInt(Pt.encode(this.value).length)));
|
|
2186
|
-
return Lt(this.value, r, e, n, this.ednParts, this.ednSource, this.quotedEdnSource, this.ednPartSources, this.ednPartSpans, this.comments?.dangling);
|
|
2187
|
-
}
|
|
2188
|
-
_toJS(e) {
|
|
2189
|
-
return this.value;
|
|
2190
|
-
}
|
|
2191
|
-
};
|
|
2192
|
-
function Lt(e, t, r, i, a, o, s, c, l, d) {
|
|
2193
|
-
let f = O(r);
|
|
2194
|
-
if (r?.preserveRawString && o !== void 0 && (f !== null || !/[\r\n]/.test(o))) return o + t;
|
|
2195
|
-
if (r?.preserveTextString && s !== void 0 && (f !== null || !/[\r\n]/.test(s))) return s + t;
|
|
2196
|
-
if (f === null) return h(e) + t;
|
|
2197
|
-
let g = r?.preserveRawString ? c : void 0, _ = g?.some((e) => e !== void 0) ?? !1, { cdn: v, newline: y } = zt(r), b = r?.preserveConcatenation && a !== void 0 && (a.length > 1 || _) ? a : void 0;
|
|
2198
|
-
if (!v && !y && b === void 0) return h(e) + t;
|
|
2199
|
-
let ee = v ? Ht(e, !!r?.inlineLeafContainers, y) : null;
|
|
2200
|
-
if (b !== void 0 && (ee === null || _)) {
|
|
2201
|
-
let e = n(r) ? p(d, l, u(r)) : void 0, a = [];
|
|
2202
|
-
for (let [t, n] of b.entries()) {
|
|
2203
|
-
let r = g?.[t];
|
|
2204
|
-
if (r !== void 0) a.push({
|
|
2205
|
-
text: n,
|
|
2206
|
-
contentDepth: 0,
|
|
2207
|
-
source: r
|
|
2208
|
-
});
|
|
2209
|
-
else if (y) {
|
|
2210
|
-
let e = /* @__PURE__ */ new Map();
|
|
2211
|
-
for (let { point: t, contentDepth: r } of Vt(n, 0)) e.set(t, r);
|
|
2212
|
-
m(a, Zt(n, e));
|
|
2213
|
-
} else a.push({
|
|
2214
|
-
text: n,
|
|
2215
|
-
contentDepth: 0
|
|
2216
|
-
});
|
|
2217
|
-
let i = e?.[t];
|
|
2218
|
-
i && i.length > 0 && (a[a.length - 1].commentsAfter = i);
|
|
2219
|
-
}
|
|
2220
|
-
if (r?.modernConcat && r?.appPrefix !== !1) {
|
|
2221
|
-
let e = a.map(({ text: e, source: t }) => t ?? h(e)), n = a.map((e) => e.commentsAfter ?? []);
|
|
2222
|
-
return ie("t1", e, t, f, i, n);
|
|
2223
|
-
}
|
|
2224
|
-
return Rt(a, t, f, i);
|
|
2225
|
-
}
|
|
2226
|
-
let x = /* @__PURE__ */ new Map();
|
|
2227
|
-
if (ee !== null) for (let { point: e, contentDepth: t } of ee) x.set(e, t);
|
|
2228
|
-
if (y) {
|
|
2229
|
-
let t = ee === null ? Vt(e, 0) : Ut(e);
|
|
2230
|
-
for (let { point: e, contentDepth: n } of t) x.has(e) || x.set(e, n);
|
|
2231
|
-
}
|
|
2232
|
-
let S = Zt(e, x);
|
|
2233
|
-
return S.length <= 1 ? h(e) + t : Rt(S, t, f, i);
|
|
2234
|
-
}
|
|
2235
|
-
function Rt(e, t, n, r) {
|
|
2236
|
-
let i = e.map(({ text: n, source: r }, i) => {
|
|
2237
|
-
let a = r ?? h(n);
|
|
2238
|
-
return i === e.length - 1 ? a + t : a;
|
|
2239
|
-
}), a = i[0];
|
|
2240
|
-
for (let t = 1; t < i.length; t++) {
|
|
2241
|
-
let o = te(n, r + 1 + e[t].contentDepth);
|
|
2242
|
-
a += " +\n";
|
|
2243
|
-
for (let n of e[t - 1].commentsAfter ?? []) a += `${o}${n}\n`;
|
|
2244
|
-
a += `${o}${i[t]}`;
|
|
2245
|
-
}
|
|
2246
|
-
return a;
|
|
2247
|
-
}
|
|
2248
|
-
function zt(e) {
|
|
2249
|
-
let t = e?.splitCdn === void 0 || e?.splitNewline === void 0 ? Bt(e?.textStringFormat ?? []) : [];
|
|
2250
|
-
return {
|
|
2251
|
-
cdn: e?.splitCdn ?? t.includes("cdn"),
|
|
2252
|
-
newline: e?.splitNewline ?? t.includes("newline")
|
|
2253
|
-
};
|
|
2254
|
-
}
|
|
2255
|
-
function Bt(e) {
|
|
2256
|
-
return e.map((e) => e === "cboredn" ? (It || (It = !0, console.warn("`textStringFormat: ['cboredn']` is deprecated; use `textStringFormat: ['cdn']` instead.")), "cdn") : e);
|
|
2257
|
-
}
|
|
2258
|
-
function Vt(e, t) {
|
|
2259
|
-
let n = [];
|
|
2260
|
-
for (let r = 0; r < e.length; r++) {
|
|
2261
|
-
let i = e[r];
|
|
2262
|
-
i === "\r" ? e[r + 1] === "\n" ? (n.push({
|
|
2263
|
-
point: r + 2,
|
|
2264
|
-
contentDepth: t
|
|
2265
|
-
}), r++) : n.push({
|
|
2266
|
-
point: r + 1,
|
|
2267
|
-
contentDepth: t
|
|
2268
|
-
}) : i === "\n" && n.push({
|
|
2269
|
-
point: r + 1,
|
|
2270
|
-
contentDepth: t
|
|
2271
|
-
});
|
|
2272
|
-
}
|
|
2273
|
-
return n;
|
|
2274
|
-
}
|
|
2275
|
-
function Ht(t, n, r) {
|
|
2276
|
-
try {
|
|
2277
|
-
pt(t);
|
|
2278
|
-
} catch {
|
|
2279
|
-
return null;
|
|
2280
|
-
}
|
|
2281
|
-
let a = [], o = new e(t), s = 0, c = null, l = !1, u = 0, d = null, f = [], p = (e, t) => {
|
|
2282
|
-
let n = f[f.length - 1];
|
|
2283
|
-
n ? n.ownCandidates.push({
|
|
2284
|
-
point: e,
|
|
2285
|
-
contentDepth: t
|
|
2286
|
-
}) : a.push({
|
|
2287
|
-
point: e,
|
|
2288
|
-
contentDepth: t
|
|
2289
|
-
});
|
|
2290
|
-
}, m = (e) => e.kind === "LT_LT" || e.kind === "APP_SEQUENCE", h = () => {
|
|
2291
|
-
for (let e = f.length - 1; e >= 0; e--) {
|
|
2292
|
-
let t = f[e];
|
|
2293
|
-
if (!(t.kind === "LPAREN" && t.isTagParen)) return t;
|
|
2294
|
-
}
|
|
2295
|
-
}, g = (e) => {
|
|
2296
|
-
let t = (m(e) || !e.entryHasContainer) && !e.entryForcedBreak;
|
|
2297
|
-
e.allOk = e.allOk && t, e.anyForcedBreak = e.anyForcedBreak || e.entryForcedBreak, e.anyForcedBreakStructural = e.anyForcedBreakStructural || e.entryForcedBreakStructural, e.entryHasContainer = !1, e.entryForcedBreak = !1, e.entryForcedBreakStructural = !1;
|
|
2298
|
-
}, _ = "none", y = [], b = !1, x = !1, S = !1, C = !1, w = [], T = !1, te = (e) => {
|
|
2299
|
-
w.push({
|
|
2300
|
-
depth: e,
|
|
2301
|
-
kind: _,
|
|
2302
|
-
texts: y,
|
|
2303
|
-
broken: b,
|
|
2304
|
-
hasEllipsis: x,
|
|
2305
|
-
sawPlus: S,
|
|
2306
|
-
awaitingTagCheck: C
|
|
2307
|
-
}), _ = "none", y = [], b = !1, x = !1, S = !1, C = !1, T = !0;
|
|
2308
|
-
}, E = () => {
|
|
2309
|
-
let e = w[w.length - 1];
|
|
2310
|
-
e !== void 0 && s === e.depth && (w.pop(), _ = e.kind, y = e.texts, b = e.broken, x = e.hasEllipsis, S = e.sawPlus, C = e.awaitingTagCheck);
|
|
2311
|
-
}, ne = () => {
|
|
2312
|
-
if (x && S) for (let e of f) e.entryHasContainer = !0;
|
|
2313
|
-
if (_ === "text" && !b && y.length > 0 && v(y.join(""))) {
|
|
2314
|
-
let e = f[f.length - 1];
|
|
2315
|
-
e && (e.entryForcedBreak = !0);
|
|
2316
|
-
}
|
|
2317
|
-
_ = "none", y = [], b = !1, x = !1, S = !1, C = !1;
|
|
2318
|
-
};
|
|
2319
|
-
for (;;) {
|
|
2320
|
-
let e = o.consume();
|
|
2321
|
-
if (e.type === "EOF") {
|
|
2322
|
-
ne();
|
|
2323
|
-
break;
|
|
2324
|
-
}
|
|
2325
|
-
let v = !1, w = !1;
|
|
2326
|
-
if (C && (e.type === "ENCODING_INDICATOR" ? w = !0 : e.type === "LPAREN" ? (C = !1, te(s), w = !0) : C = !1), !w) {
|
|
2327
|
-
let t = e.type === "PLUS" || e.type === "ENCODING_INDICATOR" || d === "PLUS" && (Jt.has(e.type) || e.type === "ELLIPSIS");
|
|
2328
|
-
_ !== "none" && !t && (d === "PLUS" && x ? Kt.has(e.type) ? te(s) : e.type === "INTEGER" && (C = !0) : ne()), e.type === "PLUS" && _ !== "none" && (S = !0);
|
|
2329
|
-
}
|
|
2330
|
-
if (l || (l = !0, e.offset > 0 && Yt(o.comments, 0, e.offset) && p(e.offset, s)), c !== null) {
|
|
2331
|
-
if (c.kind === "opener" && Gt.has(e.type)) {
|
|
2332
|
-
c.point = e.endOffset, d = e.type, u = e.endOffset;
|
|
2333
|
-
continue;
|
|
2334
|
-
}
|
|
2335
|
-
c.kind === "opener" && qt.has(e.type) && Xt(t, c.point, e.offset) ? v = !0 : p(e.offset, c.contentDepth), c = null;
|
|
2336
|
-
}
|
|
2337
|
-
if (Kt.has(e.type)) {
|
|
2338
|
-
if (e.type === "LBRACKET" || e.type === "LBRACE") for (let e of f) e.entryHasContainer = !0;
|
|
2339
|
-
s++, c = {
|
|
2340
|
-
point: e.endOffset,
|
|
2341
|
-
contentDepth: s,
|
|
2342
|
-
kind: "opener"
|
|
2343
|
-
}, f.push({
|
|
2344
|
-
kind: e.type,
|
|
2345
|
-
isTagParen: e.type === "LPAREN" && d === "INTEGER",
|
|
2346
|
-
isChainContinuationRoot: T,
|
|
2347
|
-
openOffset: e.offset,
|
|
2348
|
-
ownCandidates: [],
|
|
2349
|
-
childCandidates: [],
|
|
2350
|
-
entryHasContainer: !1,
|
|
2351
|
-
entryForcedBreak: !1,
|
|
2352
|
-
anyForcedBreak: !1,
|
|
2353
|
-
entryForcedBreakStructural: !1,
|
|
2354
|
-
anyForcedBreakStructural: !1,
|
|
2355
|
-
allOk: !0
|
|
2356
|
-
}), T = !1;
|
|
2357
|
-
} else if (qt.has(e.type)) {
|
|
2358
|
-
s = Math.max(0, s - 1), E(), v || p(e.offset, s);
|
|
2359
|
-
let t = f.pop();
|
|
2360
|
-
if (t) {
|
|
2361
|
-
g(t);
|
|
2362
|
-
let r = t.kind === "LPAREN" && t.isTagParen, i = (m(t) || n && (t.kind === "LBRACKET" || t.kind === "LBRACE" || t.kind === "LPAREN")) && t.ownCandidates.length > 0 && (r || t.allOk) && !Yt(o.comments, t.openOffset, e.endOffset) ? t.childCandidates : [...t.ownCandidates, ...t.childCandidates], s = f[f.length - 1];
|
|
2363
|
-
if (s) {
|
|
2364
|
-
for (let e of i) s.childCandidates.push(e);
|
|
2365
|
-
let e = i.length > 0 || t.anyForcedBreakStructural;
|
|
2366
|
-
(t.isChainContinuationRoot && t.isTagParen ? e : i.length > 0 || t.anyForcedBreak) && (s.entryForcedBreak = !0), e && (s.entryForcedBreakStructural = !0);
|
|
2367
|
-
} else for (let e of i) a.push(e);
|
|
2368
|
-
}
|
|
2369
|
-
} else if (e.type === "COMMA") {
|
|
2370
|
-
let t = f[f.length - 1];
|
|
2371
|
-
t && g(t), c = {
|
|
2372
|
-
point: e.endOffset,
|
|
2373
|
-
contentDepth: s,
|
|
2374
|
-
kind: "comma"
|
|
2375
|
-
};
|
|
2376
|
-
} else if (e.type === "TSTR" || e.type === "RAWSTRING") {
|
|
2377
|
-
let n = t.slice(e.offset, e.endOffset);
|
|
2378
|
-
if (r && (e.type === "TSTR" ? Wt(n).length > 0 : Vt(n, 0).length > 0)) {
|
|
2379
|
-
let e = f[f.length - 1];
|
|
2380
|
-
e && (e.entryForcedBreak = !0, e.entryForcedBreakStructural = !0);
|
|
2381
|
-
}
|
|
2382
|
-
d === "PLUS" && _ === "text" ? y.push(e.value) : (_ = "text", y = [e.value], b = !1);
|
|
2383
|
-
} else if (e.type === "SQSTR") {
|
|
2384
|
-
if (d !== "PLUS" || _ !== "byte") {
|
|
2385
|
-
let t = e._sqstrBytes, n = t ? Ft.decode(t) : null;
|
|
2386
|
-
d === "PLUS" && _ === "text" ? n === null ? b = !0 : y.push(n) : (_ = "text", y = n === null ? [] : [n], b = n === null);
|
|
2387
|
-
}
|
|
2388
|
-
} else if (e.type === "BYTES_HEX" || e.type === "BYTES_HEX_ELIDED" || e.type === "BYTES_B64" || e.type === "APP_STRING") {
|
|
2389
|
-
if (d === "PLUS" && _ === "text") {
|
|
2390
|
-
let t = null;
|
|
2391
|
-
try {
|
|
2392
|
-
e.type === "BYTES_HEX" ? t = Ft.decode(i(e.value)) : e.type === "BYTES_B64" && (t = Ft.decode(ee(e.value)));
|
|
2393
|
-
} catch {
|
|
2394
|
-
t = null;
|
|
2395
|
-
}
|
|
2396
|
-
t === null ? b = !0 : y.push(t);
|
|
2397
|
-
} else {
|
|
2398
|
-
let e = f[f.length - 1], t = h();
|
|
2399
|
-
e && (!t || !m(t)) && (e.entryForcedBreak = !0), (d !== "PLUS" || _ === "none") && (_ = "byte");
|
|
2400
|
-
}
|
|
2401
|
-
} else e.type === "ELLIPSIS" && (x = !0, d === "PLUS" && _ === "text" ? b = !0 : (d !== "PLUS" || _ === "none") && (_ = "text", y = [], b = !0));
|
|
2402
|
-
d = e.type, u = e.endOffset;
|
|
2403
|
-
}
|
|
2404
|
-
let D = o.comments.find((e) => e.start >= u);
|
|
2405
|
-
return D !== void 0 && a.push({
|
|
2406
|
-
point: D.start,
|
|
2407
|
-
contentDepth: s
|
|
2408
|
-
}), a;
|
|
2409
|
-
}
|
|
2410
|
-
function Ut(t) {
|
|
2411
|
-
let n = [], r = new e(t), i = 0;
|
|
2412
|
-
for (;;) {
|
|
2413
|
-
let e = r.consume();
|
|
2414
|
-
if (e.type === "EOF") break;
|
|
2415
|
-
if (Kt.has(e.type)) i++;
|
|
2416
|
-
else if (qt.has(e.type)) i = Math.max(0, i - 1);
|
|
2417
|
-
else if (e.type !== "COMMA") {
|
|
2418
|
-
if (e.type === "TSTR") {
|
|
2419
|
-
let r = t.slice(e.offset, e.endOffset);
|
|
2420
|
-
for (let t of Wt(r)) n.push({
|
|
2421
|
-
point: e.offset + t,
|
|
2422
|
-
contentDepth: i + 1
|
|
2423
|
-
});
|
|
2424
|
-
} else if (e.type === "RAWSTRING") {
|
|
2425
|
-
let r = t.slice(e.offset, e.endOffset);
|
|
2426
|
-
for (let { point: t } of Vt(r, 0)) n.push({
|
|
2427
|
-
point: e.offset + t,
|
|
2428
|
-
contentDepth: i + 1
|
|
2429
|
-
});
|
|
2430
|
-
}
|
|
2431
|
-
}
|
|
2432
|
-
}
|
|
2433
|
-
return n;
|
|
2434
|
-
}
|
|
2435
|
-
function Wt(e) {
|
|
2436
|
-
let t = [], n = 1, r = e.length - 1;
|
|
2437
|
-
for (; n < r;) {
|
|
2438
|
-
let r = e[n];
|
|
2439
|
-
if (r === "\\") {
|
|
2440
|
-
let r = e[n + 1];
|
|
2441
|
-
if (r === "n" || r === "r") t.push(n + 2), n += 2;
|
|
2442
|
-
else if (r === "u") {
|
|
2443
|
-
if (e[n + 2] === "{") {
|
|
2444
|
-
let t = e.indexOf("}", n + 3);
|
|
2445
|
-
n = t >= 0 ? t + 1 : n + 2;
|
|
2446
|
-
} else n += 6;
|
|
2447
|
-
} else n += 2;
|
|
2448
|
-
} else r === "\r" ? e[n + 1] === "\n" ? (t.push(n + 2), n += 2) : (t.push(n + 1), n++) : (r === "\n" && t.push(n + 1), n++);
|
|
2449
|
-
}
|
|
2450
|
-
return t;
|
|
2451
|
-
}
|
|
2452
|
-
var Gt = /* @__PURE__ */ new Set(["ENCODING_INDICATOR", "UNDERSCORE"]), Kt = /* @__PURE__ */ new Set([
|
|
2453
|
-
"LBRACKET",
|
|
2454
|
-
"LBRACE",
|
|
2455
|
-
"LPAREN",
|
|
2456
|
-
"LT_LT",
|
|
2457
|
-
"APP_SEQUENCE"
|
|
2458
|
-
]), qt = /* @__PURE__ */ new Set([
|
|
2459
|
-
"RBRACKET",
|
|
2460
|
-
"RBRACE",
|
|
2461
|
-
"RPAREN",
|
|
2462
|
-
"GT_GT"
|
|
2463
|
-
]), Jt = /* @__PURE__ */ new Set([
|
|
2464
|
-
"TSTR",
|
|
2465
|
-
"RAWSTRING",
|
|
2466
|
-
"SQSTR",
|
|
2467
|
-
"BYTES_HEX",
|
|
2468
|
-
"BYTES_HEX_ELIDED",
|
|
2469
|
-
"BYTES_B64"
|
|
2470
|
-
]);
|
|
2471
|
-
function Yt(e, t, n) {
|
|
2472
|
-
return e.some((e) => e.start >= t && e.end <= n);
|
|
2473
|
-
}
|
|
2474
|
-
function Xt(e, t, n) {
|
|
2475
|
-
return /^[\t\n\r ]*$/.test(e.slice(t, n));
|
|
2476
|
-
}
|
|
2477
|
-
function Zt(e, t) {
|
|
2478
|
-
let n = [...t].filter(([t]) => t > 0 && t < e.length).sort(([e], [t]) => e - t);
|
|
2479
|
-
if (n.length === 0) return [{
|
|
2480
|
-
text: e,
|
|
2481
|
-
contentDepth: 0
|
|
2482
|
-
}];
|
|
2483
|
-
let r = [], i = 0, a = 0;
|
|
2484
|
-
for (let [t, o] of n) t !== i && (r.push({
|
|
2485
|
-
text: e.slice(i, t),
|
|
2486
|
-
contentDepth: a
|
|
2487
|
-
}), i = t, a = o);
|
|
2488
|
-
return i < e.length && r.push({
|
|
2489
|
-
text: e.slice(i),
|
|
2490
|
-
contentDepth: a
|
|
2491
|
-
}), r;
|
|
2492
|
-
}
|
|
2493
|
-
//#endregion
|
|
2494
|
-
//#region src/extensions/dt.ts
|
|
2495
|
-
function Qt(e) {
|
|
2496
|
-
if (Number.isInteger(e)) return (/* @__PURE__ */ new Date(e * 1e3)).toISOString().replace(/\.000Z$/, "Z");
|
|
2497
|
-
let t = Math.round(e * 1e3);
|
|
2498
|
-
if (t / 1e3 === e) return new Date(t).toISOString().replace(/\.000Z$/, "Z");
|
|
2499
|
-
let n = Math.floor(e), r = e - n, i = (/* @__PURE__ */ new Date(n * 1e3)).toISOString().replace(/\.\d+Z$/, ""), a = r.toString(), o = a.indexOf("."), s = o >= 0 ? a.slice(o + 1) : "0";
|
|
2500
|
-
for (; s.length < 3;) s += "0";
|
|
2501
|
-
return `${i}.${s}Z`;
|
|
2502
|
-
}
|
|
2503
|
-
var $t = new TextDecoder("utf-8", { fatal: !0 });
|
|
2504
|
-
function en(e) {
|
|
2505
|
-
if (e.length !== 1) throw SyntaxError("dt<<...>>: expected exactly one item");
|
|
2506
|
-
let t = e[0];
|
|
2507
|
-
if (t instanceof Y) return t.value;
|
|
2508
|
-
if (t instanceof z) return $t.decode(t.value);
|
|
2509
|
-
throw SyntaxError("dt<<...>>: expected a text string or byte string");
|
|
2510
|
-
}
|
|
2511
|
-
var tn = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})$/i;
|
|
2512
|
-
function nn(e, t) {
|
|
2513
|
-
if (!tn.test(e)) {
|
|
2514
|
-
let n = `dt: invalid RFC 3339 date-time: ${JSON.stringify(e)}`;
|
|
2515
|
-
if (t) t(n);
|
|
2516
|
-
else throw SyntaxError(n);
|
|
2517
|
-
}
|
|
2518
|
-
let n = e.match(/^(.+T\d{2}:\d{2}:\d{2})(\.\d+)(Z|[+-]\d{2}:\d{2})$/i), r, i;
|
|
2519
|
-
n ? (r = n[1] + n[3], i = parseFloat("0" + n[2])) : (r = e, i = void 0);
|
|
2520
|
-
let a = Date.parse(r);
|
|
2521
|
-
if (isNaN(a)) throw SyntaxError(`dt: invalid RFC 3339 date-time: ${JSON.stringify(e)}`);
|
|
2522
|
-
if (i === void 0) {
|
|
2523
|
-
let e = a / 1e3;
|
|
2524
|
-
return e >= 0 ? new an(BigInt(e)) : new on(BigInt(e));
|
|
2525
|
-
}
|
|
2526
|
-
return new sn(a / 1e3 + i);
|
|
2527
|
-
}
|
|
2528
|
-
var rn = 1n, an = class extends F {
|
|
2529
|
-
constructor(e, t) {
|
|
2530
|
-
super(e, t);
|
|
2531
|
-
}
|
|
2532
|
-
_toCDN(e, n) {
|
|
2533
|
-
if (e?.appPrefix === !1) return super._toCDN(e, n);
|
|
2534
|
-
let r = t(e, this.encodingWidth, () => E(this.value));
|
|
2535
|
-
return T(e, this.appSeqSource, void 0, this.appSeqSourceFeatures) === "adjusted" ? D(this.appSeqSource, r, e, this.appSeqInnerEnd, this.appSeqComments) : `dt'${Qt(Number(this.value))}'${r}`;
|
|
2536
|
-
}
|
|
2537
|
-
}, on = class extends I {
|
|
2538
|
-
constructor(e, t) {
|
|
2539
|
-
super(e, t);
|
|
2540
|
-
}
|
|
2541
|
-
_toCDN(e, n) {
|
|
2542
|
-
if (e?.appPrefix === !1) return super._toCDN(e, n);
|
|
2543
|
-
let r = t(e, this.encodingWidth, () => E(this.argument));
|
|
2544
|
-
return T(e, this.appSeqSource, void 0, this.appSeqSourceFeatures) === "adjusted" ? D(this.appSeqSource, r, e, this.appSeqInnerEnd, this.appSeqComments) : `dt'${Qt(Number(this.value))}'${r}`;
|
|
2545
|
-
}
|
|
2546
|
-
}, sn = class extends L {
|
|
2547
|
-
constructor(e, t) {
|
|
2548
|
-
super(e, t);
|
|
2549
|
-
}
|
|
2550
|
-
_toCDN(e, t) {
|
|
2551
|
-
if (e?.appPrefix === !1) return super._toCDN(e, t);
|
|
2552
|
-
let n = N(this.value), r = S(this.value, this.precision, n, e?.encodingIndicators ?? "auto");
|
|
2553
|
-
return T(e, this.appSeqSource, void 0, this.appSeqSourceFeatures) === "adjusted" ? D(this.appSeqSource, r, e, this.appSeqInnerEnd, this.appSeqComments) : `dt'${Qt(this.value)}'${r}`;
|
|
2554
|
-
}
|
|
2555
|
-
}, cn = class extends R {
|
|
2556
|
-
constructor(e, t) {
|
|
2557
|
-
super(rn, typeof e == "string" ? nn(e) : e, t);
|
|
2558
|
-
}
|
|
2559
|
-
_toCDN(e, n) {
|
|
2560
|
-
if (e?.appPrefix === !1) return super._toCDN(e, n);
|
|
2561
|
-
let r = T(e, this.appSeqSource, this.ednSource, this.appSeqSourceFeatures, this.appSeqEncodingEditsComplete);
|
|
2562
|
-
if (r === "verbatim") return this.appSeqSource;
|
|
2563
|
-
if (r === "source") return w(this.appSeqSource, e, this.appSeqComments, this.appSeqEncodingEdits);
|
|
2564
|
-
if (r === "structural") return super._toCDN({
|
|
2565
|
-
...e,
|
|
2566
|
-
appPrefix: !1
|
|
2567
|
-
}, n);
|
|
2568
|
-
let i = t(e, this.encodingWidth, () => E(rn));
|
|
2569
|
-
if (r === "adjusted") return D(this.appSeqSource, i, e, this.appSeqInnerEnd, this.appSeqComments);
|
|
2570
|
-
let a = this.content;
|
|
2571
|
-
return (a instanceof L ? a.precision !== void 0 && a.precision !== N(a.value) : a.encodingWidth !== void 0) ? super._toCDN({
|
|
2572
|
-
...e,
|
|
2573
|
-
appPrefix: !1
|
|
2574
|
-
}, n) : `DT'${Qt(a instanceof L ? a.value : Number(a.value))}'${i}`;
|
|
2575
|
-
}
|
|
2576
|
-
}, ln = class extends cn {
|
|
2577
|
-
constructor(e, t) {
|
|
2578
|
-
super(e, t);
|
|
2579
|
-
}
|
|
2580
|
-
_toJS(e) {
|
|
2581
|
-
let t = this.content, n = t instanceof L ? t.value * 1e3 : Number(t.value) * 1e3;
|
|
2582
|
-
return new Date(n);
|
|
2583
|
-
}
|
|
2584
|
-
};
|
|
2585
|
-
function un(e) {
|
|
2586
|
-
let t = e?.jsDate ?? !1;
|
|
2587
|
-
function n(e) {
|
|
2588
|
-
return t ? new ln(e) : new cn(e);
|
|
2589
|
-
}
|
|
2590
|
-
let r = {
|
|
2591
|
-
appStringPrefixes: ["dt", "DT"],
|
|
2592
|
-
tagNumbers: [rn],
|
|
2593
|
-
preserveAppSeqSource: "optional",
|
|
2594
|
-
parseAppString(e, t, r) {
|
|
2595
|
-
return e === "DT" ? n(t) : nn(t, r);
|
|
2596
|
-
},
|
|
2597
|
-
parseAppSequence(e, t, r) {
|
|
2598
|
-
let i = en(t);
|
|
2599
|
-
return e === "DT" ? n(i) : nn(i, r);
|
|
2600
|
-
},
|
|
2601
|
-
parseTag(e, n) {
|
|
2602
|
-
if (e !== 1n) return;
|
|
2603
|
-
let r;
|
|
2604
|
-
if (n instanceof F) r = new an(n.value, {
|
|
2605
|
-
encodingWidth: n.encodingWidth,
|
|
2606
|
-
ednSource: n.ednSource
|
|
2607
|
-
});
|
|
2608
|
-
else if (n instanceof I) r = new on(n.value, {
|
|
2609
|
-
encodingWidth: n.encodingWidth,
|
|
2610
|
-
ednSource: n.ednSource
|
|
2611
|
-
});
|
|
2612
|
-
else if (n instanceof L) r = new sn(n.value, {
|
|
2613
|
-
precision: n.precision,
|
|
2614
|
-
literalSource: n.literalSource
|
|
2615
|
-
});
|
|
2616
|
-
else return;
|
|
2617
|
-
return r.start = n.start, r.end = n.end, t ? new ln(r) : new cn(r);
|
|
2618
|
-
}
|
|
2619
|
-
};
|
|
2620
|
-
return t && (r.fromJS = (e, t) => {
|
|
2621
|
-
if (e instanceof Date) return new ln(Qt(e.getTime() / 1e3));
|
|
2622
|
-
}, r.isJSType = (e) => e instanceof Date), r;
|
|
2623
|
-
}
|
|
2624
|
-
var dn = un(), fn = un({ jsDate: !0 });
|
|
2625
|
-
//#endregion
|
|
2626
|
-
//#region src/utils/ip.ts
|
|
2627
|
-
function pn(e) {
|
|
2628
|
-
let t = e.split(".");
|
|
2629
|
-
if (t.length !== 4) throw SyntaxError(`ip: invalid IPv4 address: ${JSON.stringify(e)}`);
|
|
2630
|
-
let n = /* @__PURE__ */ new Uint8Array(4);
|
|
2631
|
-
for (let e = 0; e < 4; e++) {
|
|
2632
|
-
let r = t[e];
|
|
2633
|
-
if (!/^\d+$/.test(r) || r.length > 1 && r[0] === "0") throw SyntaxError(`ip: invalid IPv4 octet: ${JSON.stringify(r)}`);
|
|
2634
|
-
let i = parseInt(r, 10);
|
|
2635
|
-
if (i > 255) throw SyntaxError(`ip: IPv4 octet out of range: ${i}`);
|
|
2636
|
-
n[e] = i;
|
|
2637
|
-
}
|
|
2638
|
-
return n;
|
|
2639
|
-
}
|
|
2640
|
-
function mn(e) {
|
|
2641
|
-
let t = /* @__PURE__ */ new Uint8Array(16);
|
|
2642
|
-
if (e === "::") return t;
|
|
2643
|
-
let n = e, r = null, i = e.match(/^(.*):(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/);
|
|
2644
|
-
i && (n = i[1], n.endsWith(":") && (n += ":"), r = pn(i[2]));
|
|
2645
|
-
let a = n.split("::");
|
|
2646
|
-
if (a.length > 2) throw SyntaxError(`ip: invalid IPv6 address: ${JSON.stringify(e)}`);
|
|
2647
|
-
let o = a.length === 2, s = a[0] ? a[0].split(":") : [], c = o && a[1] ? a[1].split(":") : [], l = r ? 6 : 8;
|
|
2648
|
-
if (!o && s.length !== l || o && s.length + c.length >= l) throw SyntaxError(`ip: invalid IPv6 address: ${JSON.stringify(e)}`);
|
|
2649
|
-
let u = l - s.length - c.length, d = [
|
|
2650
|
-
...s,
|
|
2651
|
-
...Array(u).fill("0"),
|
|
2652
|
-
...c
|
|
2653
|
-
], f = 0;
|
|
2654
|
-
for (let e of d) {
|
|
2655
|
-
if (!/^[0-9a-fA-F]{1,4}$/.test(e)) throw SyntaxError(`ip: invalid IPv6 group: ${JSON.stringify(e)}`);
|
|
2656
|
-
let n = parseInt(e, 16);
|
|
2657
|
-
t[f++] = n >> 8 & 255, t[f++] = n & 255;
|
|
2658
|
-
}
|
|
2659
|
-
return r && t.set(r, 12), t;
|
|
2660
|
-
}
|
|
2661
|
-
function hn(e) {
|
|
2662
|
-
return Array.from(e).join(".");
|
|
2663
|
-
}
|
|
2664
|
-
function gn(e) {
|
|
2665
|
-
let t = e.slice(0, 10).every((e) => e === 0) && e[10] === 255 && e[11] === 255 ? hn(e.slice(12)) : null, n = t ? 6 : 8, r = [];
|
|
2666
|
-
for (let t = 0; t < n * 2; t += 2) r.push(e[t] << 8 | e[t + 1]);
|
|
2667
|
-
let i = -1, a = 0, o = 0;
|
|
2668
|
-
for (; o < n;) if (r[o] === 0) {
|
|
2669
|
-
let e = o + 1;
|
|
2670
|
-
for (; e < n && r[e] === 0;) e++;
|
|
2671
|
-
e - o > a && (i = o, a = e - o), o = e;
|
|
2672
|
-
} else o++;
|
|
2673
|
-
a < 2 && (i = -1);
|
|
2674
|
-
let s = (e) => e.toString(16), c;
|
|
2675
|
-
return c = i === -1 ? r.map(s).join(":") : `${r.slice(0, i).map(s).join(":")}::${r.slice(i + a).map(s).join(":")}`, t ? `${c}:${t}` : c;
|
|
2676
|
-
}
|
|
2677
|
-
//#endregion
|
|
2678
|
-
//#region src/extensions/ip.ts
|
|
2679
|
-
var _n = "ip", vn = "IP", yn = 52n, bn = 54n, xn = new TextDecoder("utf-8", { fatal: !0 });
|
|
2680
|
-
function Sn(e) {
|
|
2681
|
-
if (e.length !== 1) throw SyntaxError("ip<<...>>: expected exactly one item");
|
|
2682
|
-
let t = e[0];
|
|
2683
|
-
if (t instanceof Y) return t.value;
|
|
2684
|
-
if (t instanceof z) return xn.decode(t.value);
|
|
2685
|
-
throw SyntaxError("ip<<...>>: expected a text string or byte string");
|
|
2686
|
-
}
|
|
2687
|
-
function Cn(e) {
|
|
2688
|
-
return /^\d/.test(e) && e.includes(".") && !e.includes(":") ? {
|
|
2689
|
-
bytes: pn(e),
|
|
2690
|
-
isV4: !0
|
|
2691
|
-
} : {
|
|
2692
|
-
bytes: mn(e),
|
|
2693
|
-
isV4: !1
|
|
2694
|
-
};
|
|
2695
|
-
}
|
|
2696
|
-
function wn(e) {
|
|
2697
|
-
if (e.length === 4) return hn(e);
|
|
2698
|
-
if (e.length === 16) return gn(e);
|
|
2699
|
-
throw SyntaxError(`ip: unexpected byte length: ${e.length}`);
|
|
2700
|
-
}
|
|
2701
|
-
function Tn(e, t) {
|
|
2702
|
-
let n = new Uint8Array(e.length);
|
|
2703
|
-
n.set(e);
|
|
2704
|
-
let r = Math.floor(t / 8), i = t % 8;
|
|
2705
|
-
i > 0 && r < e.length && (n[r] &= 255 << 8 - i & 255);
|
|
2706
|
-
for (let t = r + +(i > 0); t < e.length; t++) n[t] = 0;
|
|
2707
|
-
let a = Math.ceil(t / 8);
|
|
2708
|
-
for (; a > 0 && n[a - 1] === 0;) a--;
|
|
2709
|
-
return n.slice(0, a);
|
|
2710
|
-
}
|
|
2711
|
-
function En(e, t) {
|
|
2712
|
-
let n = new Uint8Array(t);
|
|
2713
|
-
return n.set(e), n;
|
|
2714
|
-
}
|
|
2715
|
-
var Dn = class extends z {
|
|
2716
|
-
_toCDN(e, n) {
|
|
2717
|
-
if (e?.appPrefix === !1) return super._toCDN(e, n);
|
|
2718
|
-
let r = t(e, this.encodingWidth, () => E(BigInt(this.value.length)));
|
|
2719
|
-
return T(e, this.appSeqSource, void 0, this.appSeqSourceFeatures) === "adjusted" ? D(this.appSeqSource, r, e, this.appSeqInnerEnd, this.appSeqComments) : `${_n}'${wn(this.value)}'${r}`;
|
|
2720
|
-
}
|
|
2721
|
-
}, On = class extends H {
|
|
2722
|
-
_isV4;
|
|
2723
|
-
constructor(e, t, n) {
|
|
2724
|
-
super([new F(BigInt(e)), new z(t)]), this._isV4 = n;
|
|
2725
|
-
}
|
|
2726
|
-
_toCDN(e, t) {
|
|
2727
|
-
if (e?.appPrefix === !1) return super._toCDN(e, t);
|
|
2728
|
-
if (T(e, this.appSeqSource, void 0, this.appSeqSourceFeatures) === "adjusted") return D(this.appSeqSource, "", e, this.appSeqInnerEnd, this.appSeqComments);
|
|
2729
|
-
let n = Number(this.items[0].value), r = this.items[1].value;
|
|
2730
|
-
return `${_n}'${wn(En(r, this._isV4 ? 4 : 16))}/${n}'`;
|
|
2731
|
-
}
|
|
2732
|
-
}, kn = class extends R {
|
|
2733
|
-
constructor(e, t) {
|
|
2734
|
-
super(e, t);
|
|
2735
|
-
}
|
|
2736
|
-
_toCDN(e, n) {
|
|
2737
|
-
if (e?.appPrefix === !1) return super._toCDN(e, n);
|
|
2738
|
-
let r = T(e, this.appSeqSource, this.ednSource, this.appSeqSourceFeatures, this.appSeqEncodingEditsComplete);
|
|
2739
|
-
if (r === "verbatim") return this.appSeqSource;
|
|
2740
|
-
if (r === "source") return w(this.appSeqSource, e, this.appSeqComments, this.appSeqEncodingEdits);
|
|
2741
|
-
if (r === "structural") return super._toCDN(e, n);
|
|
2742
|
-
if (r === "adjusted") {
|
|
2743
|
-
let n = t(e, this.encodingWidth, () => E(this.tag));
|
|
2744
|
-
return D(this.appSeqSource, n, e, this.appSeqInnerEnd, this.appSeqComments);
|
|
2745
|
-
}
|
|
2746
|
-
let i = this.tag === yn ? 4 : 16, a = this.content;
|
|
2747
|
-
if (a instanceof z) {
|
|
2748
|
-
if (a.encodingWidth !== void 0) return super._toCDN(e, n);
|
|
2749
|
-
let r = t(e, this.encodingWidth, () => E(this.tag));
|
|
2750
|
-
return `${vn}'${wn(a.value)}'${r}`;
|
|
2751
|
-
}
|
|
2752
|
-
if (a instanceof H && a.items.length === 2 && a.items[0] instanceof F && a.items[1] instanceof z) {
|
|
2753
|
-
if (a.encodingWidth !== void 0 || a.items[0].encodingWidth !== void 0 || a.items[1].encodingWidth !== void 0) return super._toCDN(e, n);
|
|
2754
|
-
let r = Number(a.items[0].value), o = En(a.items[1].value, i), s = t(e, this.encodingWidth, () => E(this.tag));
|
|
2755
|
-
return `${vn}'${wn(o)}/${r}'${s}`;
|
|
2756
|
-
}
|
|
2757
|
-
return super._toCDN(e, n);
|
|
2758
|
-
}
|
|
2759
|
-
};
|
|
2760
|
-
function An(e, t) {
|
|
2761
|
-
let n = t.indexOf("/");
|
|
2762
|
-
if (n === -1) {
|
|
2763
|
-
let { bytes: n, isV4: r } = Cn(t);
|
|
2764
|
-
return e === vn ? new kn(r ? yn : bn, new z(n)) : new Dn(n);
|
|
2765
|
-
}
|
|
2766
|
-
let r = t.slice(0, n), i = t.slice(n + 1);
|
|
2767
|
-
if (!/^\d+$/.test(i)) throw SyntaxError(`ip: invalid prefix length: ${JSON.stringify(i)}`);
|
|
2768
|
-
let a = parseInt(i, 10), { bytes: o, isV4: s } = Cn(r), c = s ? 32 : 128;
|
|
2769
|
-
if (a > c) throw SyntaxError(`ip: prefix length ${a} exceeds maximum ${c} for ${s ? "IPv4" : "IPv6"}`);
|
|
2770
|
-
let l = Tn(o, a);
|
|
2771
|
-
return e === vn ? new kn(s ? yn : bn, new H([new F(BigInt(a)), new z(l)])) : new On(a, l, s);
|
|
2772
|
-
}
|
|
2773
|
-
var jn = {
|
|
2774
|
-
appStringPrefixes: [_n, vn],
|
|
2775
|
-
tagNumbers: [yn, bn],
|
|
2776
|
-
preserveAppSeqSource: "optional",
|
|
2777
|
-
parseAppString(e, t) {
|
|
2778
|
-
return An(e, t);
|
|
2779
|
-
},
|
|
2780
|
-
parseAppSequence(e, t) {
|
|
2781
|
-
return An(e, Sn(t));
|
|
2782
|
-
},
|
|
2783
|
-
parseTag(e, t) {
|
|
2784
|
-
if ((e === yn || e === bn) && (t instanceof z || t instanceof H)) return new kn(e, t);
|
|
2785
|
-
}
|
|
2786
|
-
}, Mn = "cri", Nn = "CRI", Pn = 99n, Fn = /* @__PURE__ */ new Map([
|
|
2787
|
-
["coap", -1n],
|
|
2788
|
-
["coaps", -2n],
|
|
2789
|
-
["http", -3n],
|
|
2790
|
-
["https", -4n],
|
|
2791
|
-
["urn", -5n],
|
|
2792
|
-
["did", -6n],
|
|
2793
|
-
["coap+tcp", -7n],
|
|
2794
|
-
["coaps+tcp", -8n],
|
|
2795
|
-
["coap+ws", -25n],
|
|
2796
|
-
["coaps+ws", -26n]
|
|
2797
|
-
]), In = new Map([...Fn.entries()].map(([e, t]) => [t, e]));
|
|
2798
|
-
function X(e) {
|
|
2799
|
-
try {
|
|
2800
|
-
return decodeURIComponent(e);
|
|
2801
|
-
} catch {
|
|
2802
|
-
return e;
|
|
2803
|
-
}
|
|
2804
|
-
}
|
|
2805
|
-
var Ln = new TextEncoder(), Rn = new TextDecoder("utf-8", { fatal: !0 });
|
|
2806
|
-
function zn(e) {
|
|
2807
|
-
return Array.from(Ln.encode(e), (e) => `%${e.toString(16).toUpperCase().padStart(2, "0")}`).join("");
|
|
2808
|
-
}
|
|
2809
|
-
function Bn(e, t) {
|
|
2810
|
-
let n = "";
|
|
2811
|
-
for (let r of e) n += t(r) ? r : zn(r);
|
|
2812
|
-
return n;
|
|
2813
|
-
}
|
|
2814
|
-
function Vn(e) {
|
|
2815
|
-
return /[A-Za-z0-9\-._~]/.test(e);
|
|
2816
|
-
}
|
|
2817
|
-
function Hn(e) {
|
|
2818
|
-
return /[!$&'()*+,;=]/.test(e);
|
|
2819
|
-
}
|
|
2820
|
-
function Un(e) {
|
|
2821
|
-
return Vn(e) || Hn(e) || e === ":" || e === "@";
|
|
2822
|
-
}
|
|
2823
|
-
function Wn(e) {
|
|
2824
|
-
return (Un(e) || e === "/" || e === "?") && e !== "&";
|
|
2825
|
-
}
|
|
2826
|
-
function Gn(e) {
|
|
2827
|
-
return Un(e) || e === "/" || e === "?";
|
|
2828
|
-
}
|
|
2829
|
-
function Kn(e) {
|
|
2830
|
-
return Vn(e) || Hn(e) || e === ":";
|
|
2831
|
-
}
|
|
2832
|
-
function qn(e) {
|
|
2833
|
-
return Vn(e) || Hn(e);
|
|
2834
|
-
}
|
|
2835
|
-
function Jn(e) {
|
|
2836
|
-
let t = [], n = e, r = n.indexOf("@");
|
|
2837
|
-
r >= 0 && (t.push(W.FALSE), t.push(new Y(X(n.slice(0, r)))), n = n.slice(r + 1));
|
|
2838
|
-
let i, a = null;
|
|
2839
|
-
if (n.startsWith("[")) {
|
|
2840
|
-
let e = n.indexOf("]");
|
|
2841
|
-
if (e < 0) throw SyntaxError("cri: unterminated IPv6 bracket in authority");
|
|
2842
|
-
i = n.slice(1, e);
|
|
2843
|
-
let r = n.slice(e + 1);
|
|
2844
|
-
if (r.startsWith(":")) a = r.slice(1);
|
|
2845
|
-
else if (r.length > 0) throw SyntaxError("cri: unexpected characters after ']' in authority");
|
|
2846
|
-
t.push(new z(mn(i)));
|
|
2847
|
-
} else {
|
|
2848
|
-
let e = n.lastIndexOf(":");
|
|
2849
|
-
if (e >= 0 ? (i = n.slice(0, e), a = n.slice(e + 1)) : i = n, i !== "") {
|
|
2850
|
-
if (/^\d{1,3}(\.\d{1,3}){3}$/.test(i)) t.push(new z(pn(i)));
|
|
2851
|
-
else for (let e of i.toLowerCase().split(".")) t.push(new Y(e));
|
|
2852
|
-
}
|
|
2853
|
-
}
|
|
2854
|
-
if (a !== null && a !== "") {
|
|
2855
|
-
if (!/^\d+$/.test(a)) throw SyntaxError(`cri: invalid port: ${JSON.stringify(a)}`);
|
|
2856
|
-
let e = parseInt(a, 10);
|
|
2857
|
-
if (e > 65535) throw SyntaxError(`cri: port ${e} out of range`);
|
|
2858
|
-
t.push(new F(BigInt(e)));
|
|
2859
|
-
}
|
|
2860
|
-
return new H(t);
|
|
2861
|
-
}
|
|
2862
|
-
function Yn(e) {
|
|
2863
|
-
let t = e.items, n = 0, r = "";
|
|
2864
|
-
if (n < t.length && t[n] instanceof W && t[n].value === 20) {
|
|
2865
|
-
n++;
|
|
2866
|
-
let e = t[n++];
|
|
2867
|
-
r += Bn(e.value, Kn) + "@";
|
|
2868
|
-
}
|
|
2869
|
-
if (n >= t.length) return r;
|
|
2870
|
-
let i = t[n];
|
|
2871
|
-
if (i instanceof z) {
|
|
2872
|
-
n++;
|
|
2873
|
-
let { length: e } = i.value;
|
|
2874
|
-
if (e === 4) r += hn(i.value);
|
|
2875
|
-
else if (e === 16) r += "[" + gn(i.value) + "]";
|
|
2876
|
-
else throw Error(`cri: unexpected host-ip byte length: ${e}`);
|
|
2877
|
-
n < t.length && t[n] instanceof Y && (r += `%25${Bn(t[n++].value, qn)}`);
|
|
2878
|
-
} else {
|
|
2879
|
-
let e = [];
|
|
2880
|
-
for (; n < t.length && t[n] instanceof Y;) e.push(Bn(t[n++].value, qn));
|
|
2881
|
-
r += e.join(".");
|
|
2882
|
-
}
|
|
2883
|
-
return n < t.length && t[n] instanceof F && (r += ":" + t[n].value.toString()), r;
|
|
2884
|
-
}
|
|
2885
|
-
function Xn(e) {
|
|
2886
|
-
let t = e.slice(2), n = t.indexOf("/"), r, i;
|
|
2887
|
-
return n >= 0 ? (r = t.slice(0, n), i = t.slice(n + 1).split("/").map((e) => new Y(X(e)))) : (r = t, i = []), {
|
|
2888
|
-
authority: Jn(r),
|
|
2889
|
-
pathSegments: i
|
|
2890
|
-
};
|
|
2891
|
-
}
|
|
2892
|
-
function Zn(e) {
|
|
2893
|
-
let t = e, n = null, r = t.indexOf("#");
|
|
2894
|
-
r >= 0 && (n = X(t.slice(r + 1)), t = t.slice(0, r));
|
|
2895
|
-
let i = null, a = t.indexOf("?");
|
|
2896
|
-
if (a >= 0) {
|
|
2897
|
-
let e = t.slice(a + 1);
|
|
2898
|
-
t = t.slice(0, a), i = e.split("&").map((e) => new Y(X(e)));
|
|
2899
|
-
}
|
|
2900
|
-
let o = [], s = /^([a-zA-Z][a-zA-Z0-9+.\-]*):([\s\S]*)$/.exec(t);
|
|
2901
|
-
if (s) {
|
|
2902
|
-
let e = s[1].toLowerCase(), t = s[2], n = Fn.get(e);
|
|
2903
|
-
if (o.push(n === void 0 ? new Y(e) : new I(n)), t.startsWith("//")) {
|
|
2904
|
-
let { authority: e, pathSegments: n } = Xn(t);
|
|
2905
|
-
o.push(e, new H(n));
|
|
2906
|
-
} else if (t.startsWith("/")) {
|
|
2907
|
-
let e = t.slice(1).split("/").map((e) => new Y(X(e)));
|
|
2908
|
-
o.push(W.NULL, new H(e));
|
|
2909
|
-
} else {
|
|
2910
|
-
let e = t.split("/").map((e) => new Y(X(e)));
|
|
2911
|
-
o.push(W.TRUE, new H(e));
|
|
2912
|
-
}
|
|
2913
|
-
} else if (t.startsWith("//")) {
|
|
2914
|
-
let { authority: e, pathSegments: n } = Xn(t);
|
|
2915
|
-
o.push(W.FALSE, e, new H(n));
|
|
2916
|
-
} else if (t.startsWith("/")) {
|
|
2917
|
-
let e = t.slice(1).split("/").map((e) => new Y(X(e)));
|
|
2918
|
-
o.push(W.TRUE, new H(e));
|
|
2919
|
-
} else if (t === "") o.push(new F(0n));
|
|
2920
|
-
else {
|
|
2921
|
-
let n = 1n, r = t, i = !1;
|
|
2922
|
-
for (r.startsWith("./") && (i = !0, r = r.slice(2)); r.startsWith("../");) n++, r = r.slice(3);
|
|
2923
|
-
if (r === ".." ? (n++, r = "") : r === "." && (r = ""), n === 1n && !i && r !== "" && r.split("/")[0].includes(":")) throw SyntaxError(`cri: invalid relative-path reference — first segment must not contain ':' without a './' prefix (RFC 3986 §3.3): ${JSON.stringify(e)}`);
|
|
2924
|
-
let a = r === "" ? [] : r.split("/").map((e) => new Y(X(e)));
|
|
2925
|
-
o.push(new F(n), new H(a));
|
|
2926
|
-
}
|
|
2927
|
-
if (i !== null && o.push(new H(i)), n !== null && (i === null && o.push(W.NULL), o.push(new Y(n))), n !== null && i === null && o.splice(o.length - 2, 1), i === null && n === null) {
|
|
2928
|
-
let e = o[o.length - 1];
|
|
2929
|
-
e instanceof H && e.items.length === 0 && o.pop();
|
|
2930
|
-
}
|
|
2931
|
-
return o.length === 1 && o[0] instanceof F && o[0].value === 0n ? [] : o;
|
|
2932
|
-
}
|
|
2933
|
-
function Qn(e, t) {
|
|
2934
|
-
let n = t, r = "";
|
|
2935
|
-
if (n < e.length) {
|
|
2936
|
-
let t = e[n];
|
|
2937
|
-
if (t instanceof H) {
|
|
2938
|
-
if (n++, t.items.length > 0) {
|
|
2939
|
-
let e = t.items.map((e) => {
|
|
2940
|
-
if (!(e instanceof Y)) throw Error("cri: query item must be a text string");
|
|
2941
|
-
return Bn(e.value, Wn);
|
|
2942
|
-
});
|
|
2943
|
-
r += "?" + e.join("&");
|
|
2944
|
-
}
|
|
2945
|
-
} else t instanceof W && t.value === 22 && n++;
|
|
2946
|
-
}
|
|
2947
|
-
return n < e.length && e[n] instanceof Y && (r += "#" + Bn(e[n].value, Gn)), r;
|
|
2948
|
-
}
|
|
2949
|
-
function $n(e) {
|
|
2950
|
-
return e.items.map((e) => {
|
|
2951
|
-
if (!(e instanceof Y)) throw Error("cri: path segment must be a text string");
|
|
2952
|
-
return Bn(e.value, Un);
|
|
2953
|
-
});
|
|
2954
|
-
}
|
|
2955
|
-
function er(e) {
|
|
2956
|
-
if (e.length === 0) return "";
|
|
2957
|
-
let t = 0, n = e[t++];
|
|
2958
|
-
if (n instanceof I || n instanceof Y) {
|
|
2959
|
-
let r;
|
|
2960
|
-
if (n instanceof I) {
|
|
2961
|
-
let e = In.get(n.value);
|
|
2962
|
-
if (e === void 0) throw Error(`cri: unrecognised scheme-id ${n.value}`);
|
|
2963
|
-
r = e + ":";
|
|
2964
|
-
} else r = n.value + ":";
|
|
2965
|
-
if (t >= e.length) return r;
|
|
2966
|
-
let i = e[t++], a = "", o = !1;
|
|
2967
|
-
if (i instanceof H) a = "//" + Yn(i), o = !0;
|
|
2968
|
-
else if (i instanceof W) {
|
|
2969
|
-
if (i.value === 22) o = !0;
|
|
2970
|
-
else if (i.value === 21) o = !1;
|
|
2971
|
-
else throw Error(`cri: unexpected no-authority value: simple(${i.value})`);
|
|
2972
|
-
} else throw Error("cri: unexpected type for authority element");
|
|
2973
|
-
let s = "";
|
|
2974
|
-
if (t < e.length && e[t] instanceof H) {
|
|
2975
|
-
let n = e[t++];
|
|
2976
|
-
n.items.length > 0 && (s = (o ? "/" : "") + $n(n).join("/"));
|
|
2977
|
-
}
|
|
2978
|
-
return r + a + s + Qn(e, t);
|
|
2979
|
-
}
|
|
2980
|
-
if (n instanceof W && n.value === 20) {
|
|
2981
|
-
if (t >= e.length || !(e[t] instanceof H)) throw Error("cri: network-path reference requires an authority array");
|
|
2982
|
-
let n = Yn(e[t++]), r = "";
|
|
2983
|
-
if (t < e.length && e[t] instanceof H) {
|
|
2984
|
-
let n = e[t++];
|
|
2985
|
-
n.items.length > 0 && (r = "/" + $n(n).join("/"));
|
|
2986
|
-
}
|
|
2987
|
-
return "//" + n + r + Qn(e, t);
|
|
2988
|
-
}
|
|
2989
|
-
if (n instanceof W && n.value === 21) {
|
|
2990
|
-
let n = "/";
|
|
2991
|
-
if (t < e.length && e[t] instanceof H) {
|
|
2992
|
-
let r = e[t++];
|
|
2993
|
-
n = "/" + $n(r).join("/");
|
|
2994
|
-
}
|
|
2995
|
-
return n + Qn(e, t);
|
|
2996
|
-
}
|
|
2997
|
-
if (n instanceof F) {
|
|
2998
|
-
let r = n.value;
|
|
2999
|
-
if (r === 0n) return Qn(e, t);
|
|
3000
|
-
let i = r === 1n ? "" : "../".repeat(Number(r) - 1), a;
|
|
3001
|
-
if (t < e.length && e[t] instanceof H) {
|
|
3002
|
-
let n = e[t++];
|
|
3003
|
-
if (n.items.length > 0) {
|
|
3004
|
-
let e = $n(n);
|
|
3005
|
-
a = (r === 1n && e[0].includes(":") ? "./" : i) + e.join("/");
|
|
3006
|
-
} else a = i === "" ? "./" : i;
|
|
3007
|
-
} else a = i === "" ? "./" : i;
|
|
3008
|
-
return a + Qn(e, t);
|
|
3009
|
-
}
|
|
3010
|
-
throw Error("cri: unrecognised first element type in CRI array");
|
|
3011
|
-
}
|
|
3012
|
-
var tr = class extends H {
|
|
3013
|
-
_toCDN(e, n) {
|
|
3014
|
-
if (e?.appPrefix === !1) return super._toCDN(e, n);
|
|
3015
|
-
let r = t(e, this.encodingWidth, () => E(BigInt(this.items.length)));
|
|
3016
|
-
if (T(e, this.appSeqSource, void 0, this.appSeqSourceFeatures) === "adjusted") return D(this.appSeqSource, r, e, this.appSeqInnerEnd, this.appSeqComments);
|
|
3017
|
-
try {
|
|
3018
|
-
return `${Mn}'${er(this.items)}'${r}`;
|
|
3019
|
-
} catch {
|
|
3020
|
-
return super._toCDN(e, n);
|
|
3021
|
-
}
|
|
3022
|
-
}
|
|
3023
|
-
}, nr = class extends R {
|
|
3024
|
-
constructor(e) {
|
|
3025
|
-
super(Pn, e);
|
|
3026
|
-
}
|
|
3027
|
-
_toCDN(e, n) {
|
|
3028
|
-
if (e?.appPrefix === !1) return super._toCDN(e, n);
|
|
3029
|
-
let r = T(e, this.appSeqSource, this.ednSource, this.appSeqSourceFeatures, this.appSeqEncodingEditsComplete);
|
|
3030
|
-
if (r === "verbatim") return this.appSeqSource;
|
|
3031
|
-
if (r === "source") return w(this.appSeqSource, e, this.appSeqComments, this.appSeqEncodingEdits);
|
|
3032
|
-
if (r === "structural") return super._toCDN({
|
|
3033
|
-
...e,
|
|
3034
|
-
appPrefix: !1
|
|
3035
|
-
}, n);
|
|
3036
|
-
try {
|
|
3037
|
-
let i = this.content;
|
|
3038
|
-
if (i.encodingWidth !== void 0) return super._toCDN(e, n);
|
|
3039
|
-
let a = t(e, this.encodingWidth, () => E(Pn));
|
|
3040
|
-
return r === "adjusted" ? D(this.appSeqSource, a, e, this.appSeqInnerEnd, this.appSeqComments) : `${Nn}'${er(i.items)}'${a}`;
|
|
3041
|
-
} catch {
|
|
3042
|
-
return super._toCDN(e, n);
|
|
3043
|
-
}
|
|
3044
|
-
}
|
|
3045
|
-
};
|
|
3046
|
-
function rr(e) {
|
|
3047
|
-
if (e.length !== 1) throw SyntaxError("cri<<...>>: expected exactly one item");
|
|
3048
|
-
let t = e[0];
|
|
3049
|
-
if (t instanceof Y) return t.value;
|
|
3050
|
-
if (t instanceof z) return Rn.decode(t.value);
|
|
3051
|
-
throw SyntaxError("cri<<...>>: expected a text string or byte string");
|
|
3052
|
-
}
|
|
3053
|
-
function ir(e, t) {
|
|
3054
|
-
let n = new tr(Zn(t));
|
|
3055
|
-
return e === Nn ? new nr(n) : n;
|
|
3056
|
-
}
|
|
3057
|
-
var ar = {
|
|
3058
|
-
appStringPrefixes: [Mn, Nn],
|
|
3059
|
-
tagNumbers: [Pn],
|
|
3060
|
-
preserveAppSeqSource: "optional",
|
|
3061
|
-
parseAppString(e, t) {
|
|
3062
|
-
return ir(e, t);
|
|
3063
|
-
},
|
|
3064
|
-
parseAppSequence(e, t) {
|
|
3065
|
-
return ir(e, rr(t));
|
|
3066
|
-
},
|
|
3067
|
-
parseTag(e, t) {
|
|
3068
|
-
if (e !== 99n || !(t instanceof H)) return;
|
|
3069
|
-
let n = new tr(t.items, {
|
|
3070
|
-
indefiniteLength: t.indefiniteLength,
|
|
3071
|
-
encodingWidth: t.encodingWidth
|
|
3072
|
-
});
|
|
3073
|
-
return n.start = t.start, n.end = t.end, new nr(n);
|
|
3074
|
-
}
|
|
3075
|
-
}, or = 18446744073709551615n, sr = -18446744073709551616n, cr = {
|
|
3076
|
-
tagNumbers: [nt, rt],
|
|
3077
|
-
parseTag(e, t) {
|
|
3078
|
-
if (t instanceof z) {
|
|
3079
|
-
if (e === 2n) {
|
|
3080
|
-
let e = st(t.value);
|
|
3081
|
-
return e > or ? new ct(e) : void 0;
|
|
3082
|
-
}
|
|
3083
|
-
if (e === 3n) {
|
|
3084
|
-
let e = -1n - st(t.value);
|
|
3085
|
-
return e < sr ? new lt(e) : void 0;
|
|
3086
|
-
}
|
|
3087
|
-
}
|
|
3088
|
-
}
|
|
3089
|
-
};
|
|
3090
|
-
//#endregion
|
|
3091
|
-
//#region src/cbor/decoder.ts
|
|
3092
|
-
function lr(e, t) {
|
|
3093
|
-
if (e === 24 && t <= 23n) return 0;
|
|
3094
|
-
if (e === 25 && t <= 255n) return 1;
|
|
3095
|
-
if (e === 26 && t <= 65535n) return 2;
|
|
3096
|
-
if (e === 27 && t <= 4294967295n) return 3;
|
|
3097
|
-
}
|
|
3098
|
-
function ur(e, t) {
|
|
3099
|
-
if (e === 24 && t <= 23) return 0;
|
|
3100
|
-
if (e === 25 && t <= 255) return 1;
|
|
3101
|
-
if (e === 26 && t <= 65535) return 2;
|
|
3102
|
-
if (e === 27 && t <= 4294967295) return 3;
|
|
3103
|
-
}
|
|
3104
|
-
var dr = new TextDecoder("utf-8", {
|
|
3105
|
-
fatal: !0,
|
|
3106
|
-
ignoreBOM: !0
|
|
3107
|
-
}), fr = new TextDecoder("utf-8", {
|
|
3108
|
-
fatal: !1,
|
|
3109
|
-
ignoreBOM: !0
|
|
3110
|
-
});
|
|
3111
|
-
function Z(e) {
|
|
3112
|
-
throw Error(`CBOR decode error: ${e}`);
|
|
3113
|
-
}
|
|
3114
|
-
function pr(e, t, n) {
|
|
3115
|
-
let r = {
|
|
3116
|
-
message: e,
|
|
3117
|
-
offset: t
|
|
3118
|
-
};
|
|
3119
|
-
if (n?.onWarning ? n.onWarning(r) : n?.silent || console.warn(`CBOR strict violation at offset ${t}: ${e}`), n?.strict !== !1) throw Error(`CBOR decode error: ${e}`);
|
|
3120
|
-
return r;
|
|
3121
|
-
}
|
|
3122
|
-
function mr(e, t) {
|
|
3123
|
-
e.warnings ??= [], e.warnings.push(t);
|
|
3124
|
-
}
|
|
3125
|
-
function hr(e) {
|
|
3126
|
-
if (e instanceof F) return ["u", String(e.value)];
|
|
3127
|
-
if (e instanceof I) return ["n", String(e.value)];
|
|
3128
|
-
if (e instanceof Y) return ["t", e.value];
|
|
3129
|
-
if (e instanceof V) return ["t", e.chunks.map((e) => e.value).join("")];
|
|
3130
|
-
if (e instanceof z) return ["b", s(e.value)];
|
|
3131
|
-
if (e instanceof B) {
|
|
3132
|
-
let t = "";
|
|
3133
|
-
for (let n of e.chunks) t += s(n.value);
|
|
3134
|
-
return ["b", t];
|
|
3135
|
-
}
|
|
3136
|
-
if (e instanceof L) return isNaN(e.value) ? ["f", "NaN"] : Object.is(e.value, -0) ? ["f", "-0"] : ["f", String(e.value)];
|
|
3137
|
-
if (e instanceof W) return ["s", e.value];
|
|
3138
|
-
if (e instanceof H) return ["A", e.items.map(hr)];
|
|
3139
|
-
if (e instanceof U) {
|
|
3140
|
-
let t = e.entries.map(([e, t]) => [hr(e), hr(t)]);
|
|
3141
|
-
if (t.length <= 1) return ["M", t];
|
|
3142
|
-
let n = t.map((e) => [JSON.stringify(e[0]), e]);
|
|
3143
|
-
return n.sort((e, t) => e[0] < t[0] ? -1 : +(e[0] > t[0])), ["M", n.map((e) => e[1])];
|
|
3144
|
-
}
|
|
3145
|
-
return e instanceof R ? [
|
|
3146
|
-
"G",
|
|
3147
|
-
String(e.tag),
|
|
3148
|
-
hr(e.content)
|
|
3149
|
-
] : ["c", s(e.toCBOR())];
|
|
3150
|
-
}
|
|
3151
|
-
function gr(e) {
|
|
3152
|
-
if (e instanceof F) return "u" + e.value;
|
|
3153
|
-
if (e instanceof I) return "n" + e.value;
|
|
3154
|
-
if (e instanceof Y) return "t" + e.value;
|
|
3155
|
-
if (e instanceof V) {
|
|
3156
|
-
let t = "t";
|
|
3157
|
-
for (let n of e.chunks) t += n.value;
|
|
3158
|
-
return t;
|
|
3159
|
-
}
|
|
3160
|
-
if (e instanceof z) return "b" + s(e.value);
|
|
3161
|
-
if (e instanceof B) {
|
|
3162
|
-
let t = "b";
|
|
3163
|
-
for (let n of e.chunks) t += s(n.value);
|
|
3164
|
-
return t;
|
|
3165
|
-
}
|
|
3166
|
-
return e instanceof L ? isNaN(e.value) ? "fNaN" : Object.is(e.value, -0) ? "f-0" : "f" + e.value : e instanceof W ? "s" + e.value : JSON.stringify(hr(e));
|
|
3167
|
-
}
|
|
3168
|
-
var _r = Array.from({ length: 24 }, (e, t) => BigInt(t)), vr;
|
|
3169
|
-
function yr(e) {
|
|
3170
|
-
return e === void 0 ? vr ??= di(void 0).filter((e) => e.parseTag !== void 0) : di(e).filter((e) => e.parseTag !== void 0);
|
|
3171
|
-
}
|
|
3172
|
-
function br(e, t) {
|
|
3173
|
-
for (let n = 0; n < t; n++) if (e[n] >= 128) return;
|
|
3174
|
-
return String.fromCharCode.apply(null, e);
|
|
3175
|
-
}
|
|
3176
|
-
function xr(e, t, n) {
|
|
3177
|
-
if (n <= 23) return {
|
|
3178
|
-
value: _r[n],
|
|
3179
|
-
nextOffset: t
|
|
3180
|
-
};
|
|
3181
|
-
switch (n) {
|
|
3182
|
-
case 24: return t + 1 > e.byteLength && Z("unexpected end of input"), {
|
|
3183
|
-
value: BigInt(e.getUint8(t)),
|
|
3184
|
-
nextOffset: t + 1
|
|
3185
|
-
};
|
|
3186
|
-
case 25: return t + 2 > e.byteLength && Z("unexpected end of input"), {
|
|
3187
|
-
value: BigInt(e.getUint16(t, !1)),
|
|
3188
|
-
nextOffset: t + 2
|
|
3189
|
-
};
|
|
3190
|
-
case 26: return t + 4 > e.byteLength && Z("unexpected end of input"), {
|
|
3191
|
-
value: BigInt(e.getUint32(t, !1)),
|
|
3192
|
-
nextOffset: t + 4
|
|
3193
|
-
};
|
|
3194
|
-
case 27: return t + 8 > e.byteLength && Z("unexpected end of input"), {
|
|
3195
|
-
value: e.getBigUint64(t, !1),
|
|
3196
|
-
nextOffset: t + 8
|
|
3197
|
-
};
|
|
3198
|
-
default: Z(`reserved additional info value: ${n}`);
|
|
3199
|
-
}
|
|
3200
|
-
}
|
|
3201
|
-
function Sr(e, t, n) {
|
|
3202
|
-
if (n <= 23) return {
|
|
3203
|
-
value: n,
|
|
3204
|
-
nextOffset: t
|
|
3205
|
-
};
|
|
3206
|
-
switch (n) {
|
|
3207
|
-
case 24: return t + 1 > e.byteLength && Z("unexpected end of input"), {
|
|
3208
|
-
value: e.getUint8(t),
|
|
3209
|
-
nextOffset: t + 1
|
|
3210
|
-
};
|
|
3211
|
-
case 25: return t + 2 > e.byteLength && Z("unexpected end of input"), {
|
|
3212
|
-
value: e.getUint16(t, !1),
|
|
3213
|
-
nextOffset: t + 2
|
|
3214
|
-
};
|
|
3215
|
-
case 26: return t + 4 > e.byteLength && Z("unexpected end of input"), {
|
|
3216
|
-
value: e.getUint32(t, !1),
|
|
3217
|
-
nextOffset: t + 4
|
|
3218
|
-
};
|
|
3219
|
-
case 27: {
|
|
3220
|
-
t + 8 > e.byteLength && Z("unexpected end of input");
|
|
3221
|
-
let n = e.getUint32(t, !1), r = e.getUint32(t + 4, !1);
|
|
3222
|
-
return {
|
|
3223
|
-
value: n * 4294967296 + r,
|
|
3224
|
-
nextOffset: t + 8
|
|
3225
|
-
};
|
|
3226
|
-
}
|
|
3227
|
-
default: Z(`reserved additional info value: ${n}`);
|
|
3228
|
-
}
|
|
3229
|
-
}
|
|
3230
|
-
function Cr(e, t, n, r, i, a) {
|
|
3231
|
-
let o = [], s = t;
|
|
3232
|
-
for (;;) {
|
|
3233
|
-
if (s >= e.byteLength && Z(`unexpected end of indefinite ${i}`), e.getUint8(s) === 255) {
|
|
3234
|
-
s++;
|
|
3235
|
-
break;
|
|
3236
|
-
}
|
|
3237
|
-
let t = Q(e, s, n, r);
|
|
3238
|
-
a(t.value) || Z(`indefinite-length ${i} chunk must be a definite ${i}`), o.push(t.value), s = t.nextOffset;
|
|
3239
|
-
}
|
|
3240
|
-
return {
|
|
3241
|
-
chunks: o,
|
|
3242
|
-
nextOffset: s
|
|
3243
|
-
};
|
|
3244
|
-
}
|
|
3245
|
-
function wr(e, t, n, r) {
|
|
3246
|
-
let i = gr(e);
|
|
3247
|
-
t.has(i) && n.push(pr(`duplicate map key at offset ${e.start}`, e.start, r)), t.add(i);
|
|
3248
|
-
}
|
|
3249
|
-
function Q(e, t, n, r) {
|
|
3250
|
-
let i = t, a = Er(e, t, n, r);
|
|
3251
|
-
return a.value.start = i, a.value.end = a.nextOffset, a;
|
|
3252
|
-
}
|
|
3253
|
-
function Tr(e, t, n) {
|
|
3254
|
-
return new Uint8Array(e.buffer, e.byteOffset + t, n).slice();
|
|
3255
|
-
}
|
|
3256
|
-
function Er(e, t, n, r) {
|
|
3257
|
-
t >= e.byteLength && Z("unexpected end of input");
|
|
3258
|
-
let i = e.getUint8(t++), a = i >> 5, o = i & 31;
|
|
3259
|
-
switch (a) {
|
|
3260
|
-
case 0: {
|
|
3261
|
-
let { value: n, nextOffset: r } = xr(e, t, o);
|
|
3262
|
-
return {
|
|
3263
|
-
value: new F(n, { encodingWidth: lr(o, n) }),
|
|
3264
|
-
nextOffset: r
|
|
3265
|
-
};
|
|
3266
|
-
}
|
|
3267
|
-
case 1: {
|
|
3268
|
-
let { value: n, nextOffset: r } = xr(e, t, o), i = lr(o, n);
|
|
3269
|
-
return {
|
|
3270
|
-
value: new I(-1n - n, { encodingWidth: i }),
|
|
3271
|
-
nextOffset: r
|
|
3272
|
-
};
|
|
3273
|
-
}
|
|
3274
|
-
case 2: {
|
|
3275
|
-
if (o === 31) {
|
|
3276
|
-
let { chunks: i, nextOffset: a } = Cr(e, t, n, r, "byte string", (e) => e instanceof z);
|
|
3277
|
-
return {
|
|
3278
|
-
value: new B(i),
|
|
3279
|
-
nextOffset: a
|
|
3280
|
-
};
|
|
3281
|
-
}
|
|
3282
|
-
let { value: i, nextOffset: a } = Sr(e, t, o), s = ur(o, i);
|
|
3283
|
-
return a + i > e.byteLength && Z("byte string extends beyond input"), {
|
|
3284
|
-
value: new z(new Uint8Array(e.buffer, e.byteOffset + a, i).slice(), { encodingWidth: s }),
|
|
3285
|
-
nextOffset: a + i
|
|
3286
|
-
};
|
|
3287
|
-
}
|
|
3288
|
-
case 3: {
|
|
3289
|
-
if (o === 31) {
|
|
3290
|
-
let { chunks: i, nextOffset: a } = Cr(e, t, n, r, "text string", (e) => e instanceof Y);
|
|
3291
|
-
return {
|
|
3292
|
-
value: new V(i),
|
|
3293
|
-
nextOffset: a
|
|
3294
|
-
};
|
|
3295
|
-
}
|
|
3296
|
-
let { value: i, nextOffset: a } = Sr(e, t, o), s = ur(o, i);
|
|
3297
|
-
a + i > e.byteLength && Z("text string extends beyond input");
|
|
3298
|
-
let c = new Uint8Array(e.buffer, e.byteOffset + a, i), l, u, d = i < 64 ? br(c, i) : void 0;
|
|
3299
|
-
if (d !== void 0) l = d;
|
|
3300
|
-
else try {
|
|
3301
|
-
l = dr.decode(c);
|
|
3302
|
-
} catch {
|
|
3303
|
-
u = pr("invalid UTF-8 sequence in text string", a, n), l = fr.decode(c);
|
|
3304
|
-
}
|
|
3305
|
-
let f = new Y(l, { encodingWidth: s });
|
|
3306
|
-
return u && mr(f, u), {
|
|
3307
|
-
value: f,
|
|
3308
|
-
nextOffset: a + i
|
|
3309
|
-
};
|
|
3310
|
-
}
|
|
3311
|
-
case 4: {
|
|
3312
|
-
if (o === 31) {
|
|
3313
|
-
let i = [], a = t;
|
|
3314
|
-
for (;;) {
|
|
3315
|
-
if (a >= e.byteLength && Z("unexpected end of indefinite array"), e.getUint8(a) === 255) {
|
|
3316
|
-
a++;
|
|
3317
|
-
break;
|
|
3318
|
-
}
|
|
3319
|
-
let t = Q(e, a, n, r);
|
|
3320
|
-
i.push(t.value), a = t.nextOffset;
|
|
3321
|
-
}
|
|
3322
|
-
return {
|
|
3323
|
-
value: new H(i, { indefiniteLength: !0 }),
|
|
3324
|
-
nextOffset: a
|
|
3325
|
-
};
|
|
3326
|
-
}
|
|
3327
|
-
let { value: i, nextOffset: a } = Sr(e, t, o), s = ur(o, i), c = [], l = a;
|
|
3328
|
-
for (let t = 0; t < i; t++) {
|
|
3329
|
-
let t = Q(e, l, n, r);
|
|
3330
|
-
c.push(t.value), l = t.nextOffset;
|
|
3331
|
-
}
|
|
3332
|
-
return {
|
|
3333
|
-
value: new H(c, { encodingWidth: s }),
|
|
3334
|
-
nextOffset: l
|
|
3335
|
-
};
|
|
3336
|
-
}
|
|
3337
|
-
case 5: {
|
|
3338
|
-
if (o === 31) {
|
|
3339
|
-
let i = [], a = /* @__PURE__ */ new Set(), o = [], s = t;
|
|
3340
|
-
for (;;) {
|
|
3341
|
-
if (s >= e.byteLength && Z("unexpected end of indefinite map"), e.getUint8(s) === 255) {
|
|
3342
|
-
s++;
|
|
3343
|
-
break;
|
|
3344
|
-
}
|
|
3345
|
-
let t = Q(e, s, n, r);
|
|
3346
|
-
wr(t.value, a, o, n), s = t.nextOffset;
|
|
3347
|
-
let c = Q(e, s, n, r);
|
|
3348
|
-
s = c.nextOffset, i.push([t.value, c.value]);
|
|
3349
|
-
}
|
|
3350
|
-
let c = new U(i, { indefiniteLength: !0 });
|
|
3351
|
-
for (let e of o) mr(c, e);
|
|
3352
|
-
return {
|
|
3353
|
-
value: c,
|
|
3354
|
-
nextOffset: s
|
|
3355
|
-
};
|
|
3356
|
-
}
|
|
3357
|
-
let { value: i, nextOffset: a } = Sr(e, t, o), s = ur(o, i), c = [], l = /* @__PURE__ */ new Set(), u = [], d = a;
|
|
3358
|
-
for (let t = 0; t < i; t++) {
|
|
3359
|
-
let t = Q(e, d, n, r);
|
|
3360
|
-
wr(t.value, l, u, n), d = t.nextOffset;
|
|
3361
|
-
let i = Q(e, d, n, r);
|
|
3362
|
-
d = i.nextOffset, c.push([t.value, i.value]);
|
|
3363
|
-
}
|
|
3364
|
-
let f = new U(c, { encodingWidth: s });
|
|
3365
|
-
for (let e of u) mr(f, e);
|
|
3366
|
-
return {
|
|
3367
|
-
value: f,
|
|
3368
|
-
nextOffset: d
|
|
3369
|
-
};
|
|
3370
|
-
}
|
|
3371
|
-
case 6: {
|
|
3372
|
-
o === 31 && Z("tags cannot use indefinite-length encoding");
|
|
3373
|
-
let { value: i, nextOffset: a } = xr(e, t, o), s = lr(o, i), c = Q(e, a, n, r);
|
|
3374
|
-
for (let e of r) {
|
|
3375
|
-
let t = e.parseTag(i, c.value, n);
|
|
3376
|
-
if (t !== void 0) return t instanceof R && s !== void 0 && (t.encodingWidth = s), {
|
|
3377
|
-
value: t,
|
|
3378
|
-
nextOffset: c.nextOffset
|
|
3379
|
-
};
|
|
3380
|
-
}
|
|
3381
|
-
return {
|
|
3382
|
-
value: new R(i, c.value, { encodingWidth: s }),
|
|
3383
|
-
nextOffset: c.nextOffset
|
|
3384
|
-
};
|
|
3385
|
-
}
|
|
3386
|
-
case 7:
|
|
3387
|
-
if (o <= 19) return {
|
|
3388
|
-
value: new W(o),
|
|
3389
|
-
nextOffset: t
|
|
3390
|
-
};
|
|
3391
|
-
if (o === 20) return {
|
|
3392
|
-
value: new W(20),
|
|
3393
|
-
nextOffset: t
|
|
3394
|
-
};
|
|
3395
|
-
if (o === 21) return {
|
|
3396
|
-
value: new W(21),
|
|
3397
|
-
nextOffset: t
|
|
3398
|
-
};
|
|
3399
|
-
if (o === 22) return {
|
|
3400
|
-
value: new W(22),
|
|
3401
|
-
nextOffset: t
|
|
3402
|
-
};
|
|
3403
|
-
if (o === 23) return {
|
|
3404
|
-
value: new W(23),
|
|
3405
|
-
nextOffset: t
|
|
3406
|
-
};
|
|
3407
|
-
if (o === 24) {
|
|
3408
|
-
t + 1 > e.byteLength && Z("unexpected end of input");
|
|
3409
|
-
let r = e.getUint8(t);
|
|
3410
|
-
if (r < 32) {
|
|
3411
|
-
let e = pr(`simple value ${r} must be encoded in initial byte (0–31 reserved for extended encoding)`, t - 1, n), i = new W(r);
|
|
3412
|
-
return mr(i, e), {
|
|
3413
|
-
value: i,
|
|
3414
|
-
nextOffset: t + 1
|
|
3415
|
-
};
|
|
3416
|
-
}
|
|
3417
|
-
return {
|
|
3418
|
-
value: new W(r),
|
|
3419
|
-
nextOffset: t + 1
|
|
3420
|
-
};
|
|
3421
|
-
}
|
|
3422
|
-
if (o === 25) {
|
|
3423
|
-
t + 2 > e.byteLength && Z("unexpected end of input");
|
|
3424
|
-
let n = A(e.getUint16(t, !1));
|
|
3425
|
-
return {
|
|
3426
|
-
value: new L(n, {
|
|
3427
|
-
precision: "half",
|
|
3428
|
-
rawBits: Number.isNaN(n) ? Tr(e, t, 2) : void 0
|
|
3429
|
-
}),
|
|
3430
|
-
nextOffset: t + 2
|
|
3431
|
-
};
|
|
3432
|
-
}
|
|
3433
|
-
if (o === 26) {
|
|
3434
|
-
t + 4 > e.byteLength && Z("unexpected end of input");
|
|
3435
|
-
let n = e.getFloat32(t, !1);
|
|
3436
|
-
return {
|
|
3437
|
-
value: new L(n, {
|
|
3438
|
-
precision: "single",
|
|
3439
|
-
rawBits: Number.isNaN(n) ? Tr(e, t, 4) : void 0
|
|
3440
|
-
}),
|
|
3441
|
-
nextOffset: t + 4
|
|
3442
|
-
};
|
|
3443
|
-
}
|
|
3444
|
-
if (o === 27) {
|
|
3445
|
-
t + 8 > e.byteLength && Z("unexpected end of input");
|
|
3446
|
-
let n = e.getFloat64(t, !1);
|
|
3447
|
-
return {
|
|
3448
|
-
value: new L(n, {
|
|
3449
|
-
precision: "double",
|
|
3450
|
-
rawBits: Number.isNaN(n) ? Tr(e, t, 8) : void 0
|
|
3451
|
-
}),
|
|
3452
|
-
nextOffset: t + 8
|
|
3453
|
-
};
|
|
3454
|
-
}
|
|
3455
|
-
return o < 31 && Z(`reserved additional info value in major type 7: ${o}`), Z("unexpected break code outside indefinite-length item");
|
|
3456
|
-
}
|
|
3457
|
-
return Z(`unknown major type: ${a}`);
|
|
3458
|
-
}
|
|
3459
|
-
function Dr(e) {
|
|
3460
|
-
if (e instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && e instanceof SharedArrayBuffer) return new Uint8Array(e);
|
|
3461
|
-
if (ArrayBuffer.isView(e)) return new Uint8Array(e.buffer, e.byteOffset, e.byteLength);
|
|
3462
|
-
throw TypeError("expected ArrayBufferView or ArrayBufferLike");
|
|
3463
|
-
}
|
|
3464
|
-
function Or(e, t) {
|
|
3465
|
-
let n = Dr(e), r = new DataView(n.buffer, n.byteOffset, n.byteLength), i = t?.offset ?? 0;
|
|
3466
|
-
if (!Number.isInteger(i) || i < 0 || i > r.byteLength) throw RangeError(`CBOR decode offset must be an integer between 0 and ${r.byteLength}`);
|
|
3467
|
-
let a = yr(t?.builtinExtensions), o = t?.extensions?.length ? [...t.extensions.filter((e) => e.parseTag !== void 0), ...a] : a, { value: s, nextOffset: c } = Q(r, i, t, o);
|
|
3468
|
-
if (!t?.allowTrailing && c !== r.byteLength) {
|
|
3469
|
-
mr(s, pr(`${r.byteLength - c} trailing byte(s) after end of CBOR item`, c, t));
|
|
3470
|
-
let e = {
|
|
3471
|
-
strict: !1,
|
|
3472
|
-
silent: !0
|
|
3473
|
-
}, n = c;
|
|
3474
|
-
for (; n < r.byteLength;) ({nextOffset: n} = Q(r, n, e, o));
|
|
3475
|
-
}
|
|
3476
|
-
return s;
|
|
3477
|
-
}
|
|
3478
|
-
//#endregion
|
|
3479
|
-
//#region src/extensions/cbordata.ts
|
|
3480
|
-
var kr = 24n, Ar = {
|
|
3481
|
-
tagNumbers: [kr],
|
|
3482
|
-
parseTag(e, t, n) {
|
|
3483
|
-
if (e !== 24n || !(t instanceof z)) return;
|
|
3484
|
-
let r = (t.end ?? t.value.length) - t.value.length, i = n ? {
|
|
3485
|
-
extensions: n.extensions,
|
|
3486
|
-
builtinExtensions: n.builtinExtensions,
|
|
3487
|
-
strict: n.strict,
|
|
3488
|
-
onWarning: n.onWarning ? (e) => n.onWarning({
|
|
3489
|
-
...e,
|
|
3490
|
-
offset: e.offset + r
|
|
3491
|
-
}) : void 0,
|
|
3492
|
-
silent: n.silent
|
|
3493
|
-
} : void 0;
|
|
3494
|
-
try {
|
|
3495
|
-
return new R(kr, new G([Or(t.value, i)], { encodingWidth: t.encodingWidth }));
|
|
3496
|
-
} catch (e) {
|
|
3497
|
-
if (i?.strict !== !1) throw e;
|
|
3498
|
-
let t = `tag 24 content is not valid CBOR: ${e instanceof Error ? e.message : String(e)}`, a = {
|
|
3499
|
-
message: t,
|
|
3500
|
-
offset: r
|
|
3501
|
-
};
|
|
3502
|
-
n?.onWarning ? n.onWarning(a) : n?.silent || console.warn(`CBOR strict violation at offset ${a.offset}: ${t}`);
|
|
3503
|
-
return;
|
|
3504
|
-
}
|
|
3505
|
-
}
|
|
3506
|
-
};
|
|
3507
|
-
//#endregion
|
|
3508
|
-
//#region src/extensions/ellipsis.ts
|
|
3509
|
-
function jr(e) {
|
|
3510
|
-
return e instanceof K && !(e.content instanceof H);
|
|
3511
|
-
}
|
|
3512
|
-
function Mr(e) {
|
|
3513
|
-
let t = !1, n = !1, r = !1, i;
|
|
3514
|
-
for (let a of e) {
|
|
3515
|
-
let e;
|
|
3516
|
-
if (jr(a)) e = !0, r = !0;
|
|
3517
|
-
else if (a instanceof Y) e = !1, t = !0;
|
|
3518
|
-
else if (a instanceof z) e = !1, n = !0;
|
|
3519
|
-
else return !1;
|
|
3520
|
-
if (e === i) return !1;
|
|
3521
|
-
i = e;
|
|
3522
|
-
}
|
|
3523
|
-
return r && !(t && n);
|
|
3524
|
-
}
|
|
3525
|
-
var Nr = {
|
|
3526
|
-
tagNumbers: [Xe],
|
|
3527
|
-
parseTag(e, t) {
|
|
3528
|
-
if (e === 888n) {
|
|
3529
|
-
if (t instanceof W && t.value === 22) return new K();
|
|
3530
|
-
if (t instanceof H && Mr(t.items)) return new K(t.items);
|
|
3531
|
-
}
|
|
3532
|
-
}
|
|
3533
|
-
}, Pr = new TextEncoder(), Fr = new TextDecoder("utf-8", { fatal: !0 }), Ir = new TextDecoder("utf-8", { fatal: !1 }), Lr = Symbol("ellipsis");
|
|
3534
|
-
function Rr(e) {
|
|
3535
|
-
let t = 0;
|
|
3536
|
-
for (let n of e) t += n.length;
|
|
3537
|
-
let n = new Uint8Array(t), r = 0;
|
|
3538
|
-
for (let t of e) n.set(t, r), r += t.length;
|
|
3539
|
-
return n;
|
|
3540
|
-
}
|
|
3541
|
-
function zr(e, t, n) {
|
|
3542
|
-
if (t instanceof Ye) {
|
|
3543
|
-
zr(e, t.inner, n);
|
|
3544
|
-
return;
|
|
3545
|
-
}
|
|
3546
|
-
if (t instanceof K) {
|
|
3547
|
-
if (t.content instanceof H) for (let r of t.content.items) zr(e, r, n);
|
|
3548
|
-
else n.push(Lr);
|
|
3549
|
-
return;
|
|
3550
|
-
}
|
|
3551
|
-
if (t instanceof Y) {
|
|
3552
|
-
n.push(Pr.encode(t.value));
|
|
3553
|
-
return;
|
|
3554
|
-
}
|
|
3555
|
-
if (t instanceof z) {
|
|
3556
|
-
n.push(t.value);
|
|
3557
|
-
return;
|
|
3558
|
-
}
|
|
3559
|
-
if (t instanceof V) {
|
|
3560
|
-
n.push(Pr.encode(t.chunks.map((e) => e.value).join("")));
|
|
3561
|
-
return;
|
|
3562
|
-
}
|
|
3563
|
-
if (t instanceof B) {
|
|
3564
|
-
n.push(Rr(t.chunks.map((e) => e.value)));
|
|
3565
|
-
return;
|
|
3566
|
-
}
|
|
3567
|
-
throw SyntaxError(`${e}<<...>> arguments must be (text or byte) strings or ellipses`);
|
|
3568
|
-
}
|
|
3569
|
-
function Br(e, t) {
|
|
3570
|
-
try {
|
|
3571
|
-
return Fr.decode(e);
|
|
3572
|
-
} catch {
|
|
3573
|
-
let n = "t1 concatenation result is not valid UTF-8";
|
|
3574
|
-
if (t) t(n);
|
|
3575
|
-
else throw SyntaxError(n);
|
|
3576
|
-
return Ir.decode(e);
|
|
3577
|
-
}
|
|
3578
|
-
}
|
|
3579
|
-
function Vr(e, t, n) {
|
|
3580
|
-
let r = [];
|
|
3581
|
-
for (let n of t) zr(e, n, r);
|
|
3582
|
-
let i = e === "t1", a = [], o = !1, s = [], c = () => {
|
|
3583
|
-
if (s.length === 0) return;
|
|
3584
|
-
let e = Rr(s);
|
|
3585
|
-
s.length = 0, e.length !== 0 && a.push(i ? new Y(Br(e, n)) : new z(e));
|
|
3586
|
-
};
|
|
3587
|
-
for (let e of r) e === Lr ? (c(), a[a.length - 1] instanceof K || (a.push(new K()), o = !0)) : s.push(e);
|
|
3588
|
-
if (!o) {
|
|
3589
|
-
let e = Rr(s);
|
|
3590
|
-
return i ? new Y(Br(e, n)) : new z(e);
|
|
3591
|
-
}
|
|
3592
|
-
return c(), a.length === 1 ? new K() : new K(a);
|
|
3593
|
-
}
|
|
3594
|
-
function Hr(e) {
|
|
3595
|
-
return {
|
|
3596
|
-
appStringPrefixes: [e],
|
|
3597
|
-
preserveAppSeqSource: !0,
|
|
3598
|
-
parseAppString(t, n, r) {
|
|
3599
|
-
return Vr(e, [new Y(n)], r);
|
|
3600
|
-
},
|
|
3601
|
-
parseAppSequence(t, n, r) {
|
|
3602
|
-
return Vr(e, n, r);
|
|
3603
|
-
}
|
|
3604
|
-
};
|
|
3605
|
-
}
|
|
3606
|
-
var Ur = Hr("t1"), Wr = Hr("b1"), Gr = new TextEncoder(), Kr = new TextDecoder("utf-8", { fatal: !0 }), qr = new TextDecoder("utf-8", { fatal: !1 });
|
|
3607
|
-
function Jr(e) {
|
|
3608
|
-
let t = 0;
|
|
3609
|
-
for (let n of e) t += n.length;
|
|
3610
|
-
let n = new Uint8Array(t), r = 0;
|
|
3611
|
-
for (let t of e) n.set(t, r), r += t.length;
|
|
3612
|
-
return n;
|
|
3613
|
-
}
|
|
3614
|
-
function Yr(e, t, n) {
|
|
3615
|
-
let r = e === "ilts", i = [], a = [];
|
|
3616
|
-
for (let o of t) {
|
|
3617
|
-
if (o instanceof Ye && (o = o.inner), o instanceof K) throw SyntaxError(`${e}<<...>> cannot contain ellipses; there is no way to include an elision in an indefinite-length string`);
|
|
3618
|
-
let t, s, c;
|
|
3619
|
-
if (o instanceof Y) t = o.value, c = o.encodingWidth;
|
|
3620
|
-
else if (o instanceof z) s = o.value, c = o.encodingWidth;
|
|
3621
|
-
else if (o instanceof V) t = o.chunks.map((e) => e.value).join("");
|
|
3622
|
-
else if (o instanceof B) s = Jr(o.chunks.map((e) => e.value));
|
|
3623
|
-
else throw SyntaxError(`${e}<<...>> arguments must be (text or byte) strings`);
|
|
3624
|
-
if (r) {
|
|
3625
|
-
let e;
|
|
3626
|
-
if (t !== void 0) e = t;
|
|
3627
|
-
else try {
|
|
3628
|
-
e = Kr.decode(s);
|
|
3629
|
-
} catch {
|
|
3630
|
-
let t = "ilts chunk is not valid UTF-8";
|
|
3631
|
-
if (n) n(t);
|
|
3632
|
-
else throw SyntaxError(t);
|
|
3633
|
-
e = qr.decode(s);
|
|
3634
|
-
}
|
|
3635
|
-
a.push(new Y(e, c === void 0 ? void 0 : { encodingWidth: c }));
|
|
3636
|
-
} else {
|
|
3637
|
-
let e = s ?? Gr.encode(t);
|
|
3638
|
-
i.push(new z(e, c === void 0 ? void 0 : { encodingWidth: c }));
|
|
3639
|
-
}
|
|
3640
|
-
}
|
|
3641
|
-
return r ? new V(a) : new B(i);
|
|
3642
|
-
}
|
|
3643
|
-
function Xr(e) {
|
|
3644
|
-
return {
|
|
3645
|
-
appStringPrefixes: [e],
|
|
3646
|
-
preserveAppSeqSource: !0,
|
|
3647
|
-
parseAppString(t, n, r) {
|
|
3648
|
-
return new Ye(Yr(e, [new Y(n)], r), `${e}${ne(n)}`);
|
|
3649
|
-
},
|
|
3650
|
-
parseAppSequence(t, n, r) {
|
|
3651
|
-
return Yr(e, n, r);
|
|
3652
|
-
}
|
|
3653
|
-
};
|
|
3654
|
-
}
|
|
3655
|
-
var Zr = Xr("ilbs"), Qr = Xr("ilts"), $r = class extends L {
|
|
3656
|
-
_bits;
|
|
3657
|
-
constructor(e) {
|
|
3658
|
-
super(A(e), { precision: "half" }), this._bits = e & 65535;
|
|
3659
|
-
}
|
|
3660
|
-
_toCBOR() {
|
|
3661
|
-
return new Uint8Array([
|
|
3662
|
-
249,
|
|
3663
|
-
this._bits >> 8 & 255,
|
|
3664
|
-
this._bits & 255
|
|
3665
|
-
]);
|
|
3666
|
-
}
|
|
3667
|
-
}, ei = class extends L {
|
|
3668
|
-
_raw;
|
|
3669
|
-
constructor(e) {
|
|
3670
|
-
super(new DataView(e.buffer, e.byteOffset).getFloat32(0, !1), { precision: "single" }), this._raw = e.slice();
|
|
3671
|
-
}
|
|
3672
|
-
_toCBOR() {
|
|
3673
|
-
let e = /* @__PURE__ */ new Uint8Array(5);
|
|
3674
|
-
return e[0] = 250, e.set(this._raw, 1), e;
|
|
3675
|
-
}
|
|
3676
|
-
}, ti = class extends L {
|
|
3677
|
-
_raw;
|
|
3678
|
-
constructor(e) {
|
|
3679
|
-
super(new DataView(e.buffer, e.byteOffset).getFloat64(0, !1), { precision: "double" }), this._raw = e.slice();
|
|
3680
|
-
}
|
|
3681
|
-
_toCBOR() {
|
|
3682
|
-
let e = /* @__PURE__ */ new Uint8Array(9);
|
|
3683
|
-
return e[0] = 251, e.set(this._raw, 1), e;
|
|
3684
|
-
}
|
|
3685
|
-
};
|
|
3686
|
-
function ni(e) {
|
|
3687
|
-
if (e.length === 2) return new $r(e[0] << 8 | e[1]);
|
|
3688
|
-
if (e.length === 4) return new ei(e);
|
|
3689
|
-
if (e.length === 8) return new ti(e);
|
|
3690
|
-
throw SyntaxError(`float'...' requires 4, 8, or 16 hex digits (2, 4, or 8 bytes); got ${e.length} bytes`);
|
|
3691
|
-
}
|
|
3692
|
-
function ri(e) {
|
|
3693
|
-
let t = e >>> 15 & 1, n = e >>> 10 & 31, r = e & 1023, i;
|
|
3694
|
-
if (n === 31) i = t << 31 | 2139095040 | r << 13;
|
|
3695
|
-
else if (n === 0 && r === 0) i = t << 31;
|
|
3696
|
-
else if (n === 0) {
|
|
3697
|
-
let e = r, n = 0;
|
|
3698
|
-
for (; !(e & 512);) e <<= 1, n++;
|
|
3699
|
-
i = t << 31 | 112 - n << 23 | (e & 511) << 14;
|
|
3700
|
-
} else i = t << 31 | n + 112 << 23 | r << 13;
|
|
3701
|
-
let a = /* @__PURE__ */ new Uint8Array(4);
|
|
3702
|
-
return new DataView(a.buffer).setUint32(0, i >>> 0, !1), a;
|
|
3703
|
-
}
|
|
3704
|
-
function ii(e) {
|
|
3705
|
-
let t = e >>> 15 & 1, n = e >>> 10 & 31, r = e & 1023, i = /* @__PURE__ */ new Uint8Array(8), a = new DataView(i.buffer);
|
|
3706
|
-
if (n === 31) a.setUint32(0, (t << 31 | 2146435072 | r << 10) >>> 0, !1), a.setUint32(4, 0, !1);
|
|
3707
|
-
else if (n === 0 && r === 0) a.setUint32(0, t << 31 >>> 0, !1), a.setUint32(4, 0, !1);
|
|
3708
|
-
else if (n === 0) {
|
|
3709
|
-
let e = r, n = 0;
|
|
3710
|
-
for (; !(e & 512);) e <<= 1, n++;
|
|
3711
|
-
a.setUint32(0, (t << 31 | 1008 - n << 20 | (e & 511) << 11) >>> 0, !1), a.setUint32(4, 0, !1);
|
|
3712
|
-
} else a.setUint32(0, (t << 31 | n + 1008 << 20 | r << 10) >>> 0, !1), a.setUint32(4, 0, !1);
|
|
3713
|
-
return i;
|
|
3714
|
-
}
|
|
3715
|
-
function ai(e) {
|
|
3716
|
-
let t = new DataView(e.buffer, e.byteOffset).getUint32(0, !1), n = t >>> 31 & 1, r = t >>> 23 & 255, i = t & 8388607, a = /* @__PURE__ */ new Uint8Array(8), o = new DataView(a.buffer);
|
|
3717
|
-
if (r === 255) o.setUint32(0, (n << 31 | 2146435072 | i >>> 3) >>> 0, !1), o.setUint32(4, (i & 7) << 29, !1);
|
|
3718
|
-
else if (r === 0 && i === 0) o.setUint32(0, n << 31 >>> 0, !1), o.setUint32(4, 0, !1);
|
|
3719
|
-
else {
|
|
3720
|
-
let t = new DataView(e.buffer, e.byteOffset).getFloat32(0, !1);
|
|
3721
|
-
o.setFloat64(0, t, !1);
|
|
3722
|
-
}
|
|
3723
|
-
return a;
|
|
3724
|
-
}
|
|
3725
|
-
function oi(e, t, n) {
|
|
3726
|
-
let r = e.length === 2 ? 1 : e.length === 4 ? 2 : 3;
|
|
3727
|
-
if (r === 1) {
|
|
3728
|
-
let n = e[0] << 8 | e[1];
|
|
3729
|
-
if (t === 2) return new ei(ri(n));
|
|
3730
|
-
if (t === 3) return new ti(ii(n));
|
|
3731
|
-
}
|
|
3732
|
-
if (r === 2) {
|
|
3733
|
-
if (t === 3) return new ti(ai(e));
|
|
3734
|
-
if (t === 1) {
|
|
3735
|
-
let t = new DataView(e.buffer, e.byteOffset).getFloat32(0, !1), r = ye(t);
|
|
3736
|
-
return !Object.is(A(r), t) && !isNaN(t) && n("float'...' value cannot be exactly represented as float16 (_1)"), new $r(r);
|
|
3737
|
-
}
|
|
3738
|
-
}
|
|
3739
|
-
if (r === 3) {
|
|
3740
|
-
let r = new DataView(e.buffer, e.byteOffset).getFloat64(0, !1);
|
|
3741
|
-
if (t === 1) {
|
|
3742
|
-
let e = ye(r);
|
|
3743
|
-
return !Object.is(A(e), r) && !isNaN(r) && n("float'...' value cannot be exactly represented as float16 (_1)"), new $r(e);
|
|
3744
|
-
}
|
|
3745
|
-
if (t === 2) {
|
|
3746
|
-
let e = Math.fround(r);
|
|
3747
|
-
!Object.is(e, r) && !isNaN(r) && n("float'...' value cannot be exactly represented as float32 (_2)");
|
|
3748
|
-
let t = /* @__PURE__ */ new Uint8Array(4);
|
|
3749
|
-
return new DataView(t.buffer).setFloat32(0, e, !1), new ei(t);
|
|
3750
|
-
}
|
|
3751
|
-
}
|
|
3752
|
-
return ni(e);
|
|
3753
|
-
}
|
|
3754
|
-
var si = {
|
|
3755
|
-
appStringPrefixes: ["float"],
|
|
3756
|
-
parseAppString(e, t, n, r) {
|
|
3757
|
-
let a = Be(t);
|
|
3758
|
-
if (!/^[0-9a-fA-F]*$/.test(a)) throw SyntaxError("float'...' contains non-hex characters");
|
|
3759
|
-
if (a.length % 2 != 0) throw SyntaxError(`float'...' hex content has odd length (${a.length} digits)`);
|
|
3760
|
-
let o = i(a), s = r?.encodingWidth;
|
|
3761
|
-
if (s === void 0) return ni(o);
|
|
3762
|
-
if (s !== 1 && s !== 2 && s !== 3) {
|
|
3763
|
-
let e = `float'...' encoding indicator _${s} is not valid; use _1, _2, or _3`;
|
|
3764
|
-
if (n) return n(e), ni(o);
|
|
3765
|
-
throw SyntaxError(e);
|
|
3766
|
-
}
|
|
3767
|
-
return s === (o.length === 2 ? 1 : o.length === 4 ? 2 : 3) ? ni(o) : oi(o, s, n ?? ((e) => {
|
|
3768
|
-
throw SyntaxError(e);
|
|
3769
|
-
}));
|
|
3770
|
-
},
|
|
3771
|
-
parseAppSequence(e, t, n) {
|
|
3772
|
-
if (t.length === 0) throw SyntaxError("float<<...>> requires exactly one byte-string item");
|
|
3773
|
-
if (t.length > 1) {
|
|
3774
|
-
let e = `float<<...>> expects 1 item; got ${t.length} — using first`;
|
|
3775
|
-
if (n) n(e);
|
|
3776
|
-
else throw SyntaxError(e);
|
|
3777
|
-
}
|
|
3778
|
-
if (!(t[0] instanceof z)) throw SyntaxError("float<<...>> item must be a byte string");
|
|
3779
|
-
return ni(t[0].value);
|
|
3780
|
-
}
|
|
3781
|
-
}, ci = [
|
|
3782
|
-
cr,
|
|
3783
|
-
Ar,
|
|
3784
|
-
Nr
|
|
3785
|
-
], li = [
|
|
3786
|
-
dn,
|
|
3787
|
-
jn,
|
|
3788
|
-
ar,
|
|
3789
|
-
Ur,
|
|
3790
|
-
Wr,
|
|
3791
|
-
Zr,
|
|
3792
|
-
Qr,
|
|
3793
|
-
si
|
|
3794
|
-
], ui;
|
|
3795
|
-
function di(e) {
|
|
3796
|
-
return e === void 0 ? ui ??= [...ci, ...li] : e === !1 ? ci : [...ci, ...e];
|
|
3797
|
-
}
|
|
3798
|
-
//#endregion
|
|
3799
|
-
//#region src/js/fromJS.ts
|
|
3800
|
-
var fi;
|
|
3801
|
-
function pi(e) {
|
|
3802
|
-
if (e === void 0) {
|
|
3803
|
-
if (fi) return fi;
|
|
3804
|
-
let e = di(void 0);
|
|
3805
|
-
return fi = {
|
|
3806
|
-
fromJS: e.filter((e) => e.fromJS !== void 0),
|
|
3807
|
-
parseTag: e.filter((e) => e.parseTag !== void 0)
|
|
3808
|
-
};
|
|
3809
|
-
}
|
|
3810
|
-
let t = di(e);
|
|
3811
|
-
return {
|
|
3812
|
-
fromJS: t.filter((e) => e.fromJS !== void 0),
|
|
3813
|
-
parseTag: t.filter((e) => e.parseTag !== void 0)
|
|
3814
|
-
};
|
|
3815
|
-
}
|
|
3816
|
-
function mi(e) {
|
|
3817
|
-
let t = e?.extensions, n = pi(e?.builtinExtensions);
|
|
3818
|
-
return t?.length ? {
|
|
3819
|
-
fromJS: [...t.filter((e) => e.fromJS !== void 0), ...n.fromJS],
|
|
3820
|
-
parseTag: [...t.filter((e) => e.parseTag !== void 0), ...n.parseTag]
|
|
3821
|
-
} : n;
|
|
3822
|
-
}
|
|
3823
|
-
function hi(e, t) {
|
|
3824
|
-
if (t?.replacer) {
|
|
3825
|
-
let { replacer: n, ...r } = t, i = vi(e, n, r.extensions, r.undefinedOmits, r.builtinExtensions);
|
|
3826
|
-
return i === he ? W.UNDEFINED : hi(i, Object.keys(r).length > 0 ? r : void 0);
|
|
3827
|
-
}
|
|
3828
|
-
return gi(e, t, !0, mi(t));
|
|
3829
|
-
}
|
|
3830
|
-
function gi(e, t, n, r) {
|
|
3831
|
-
for (let n of r.fromJS) {
|
|
3832
|
-
let r = n.fromJS(e, t ?? {});
|
|
3833
|
-
if (r !== void 0) return r;
|
|
3834
|
-
}
|
|
3835
|
-
if (n && typeof e == "object" && e && k.symbol in e) {
|
|
3836
|
-
let n = e[k.symbol], i = gi(e, t, !1, r);
|
|
3837
|
-
for (let e of r.parseTag) {
|
|
3838
|
-
let t = e.parseTag(n, i);
|
|
3839
|
-
if (t !== void 0) return t;
|
|
3840
|
-
}
|
|
3841
|
-
return new R(n, i);
|
|
3842
|
-
}
|
|
3843
|
-
if (e instanceof k.Null) return W.NULL;
|
|
3844
|
-
if (e instanceof k.Undefined) return W.UNDEFINED;
|
|
3845
|
-
if (e instanceof ge) return new W(e.value);
|
|
3846
|
-
if (e === null) return W.NULL;
|
|
3847
|
-
if (e === void 0) return W.UNDEFINED;
|
|
3848
|
-
if (e === !0) return W.TRUE;
|
|
3849
|
-
if (e === !1) return W.FALSE;
|
|
3850
|
-
if (typeof e == "bigint") return e > 18446744073709551615n ? new ct(e) : e < -18446744073709551616n ? new lt(e) : e >= 0n ? new F(e) : new I(e);
|
|
3851
|
-
if (typeof e == "number") return (t?.encodeIntegerAs ?? "int") === "int" && Number.isInteger(e) && !Object.is(e, -0) ? e >= 0 ? new F(BigInt(e)) : new I(BigInt(e)) : new L(e);
|
|
3852
|
-
if (typeof e == "string") return new Y(e);
|
|
3853
|
-
if (e instanceof Number || e instanceof Boolean || e instanceof String || Object.prototype.toString.call(e) === "[object BigInt]") return gi(e.valueOf(), t, !1, r);
|
|
3854
|
-
if (e instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && e instanceof SharedArrayBuffer) return new z(new Uint8Array(e));
|
|
3855
|
-
if (ArrayBuffer.isView(e)) return e instanceof Uint8Array && t?.uint8ArrayAs === "array" ? new H(Array.from(e, (e) => new F(BigInt(e)))) : new z(new Uint8Array(e.buffer, e.byteOffset, e.byteLength));
|
|
3856
|
-
if (e instanceof $) return new U([...e].map(([e, n]) => [gi(e, t, !0, r), gi(n, t, !0, r)]));
|
|
3857
|
-
if (Array.isArray(e)) return new H(e.map((e) => gi(e, t, !0, r)));
|
|
3858
|
-
if (typeof e == "object") {
|
|
3859
|
-
let n = [];
|
|
3860
|
-
for (let [i, a] of Object.entries(e)) n.push([new Y(i), gi(a, t, !0, r)]);
|
|
3861
|
-
return new U(n);
|
|
3862
|
-
}
|
|
3863
|
-
throw TypeError(`fromJS: unsupported value type: ${typeof e}`);
|
|
3864
|
-
}
|
|
3865
|
-
function _i(e) {
|
|
3866
|
-
return ArrayBuffer.isView(e) || e instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && e instanceof SharedArrayBuffer || e instanceof Number || e instanceof Boolean || e instanceof String || Object.prototype.toString.call(e) === "[object BigInt]" || e instanceof k.Null || e instanceof k.Undefined || e instanceof ge;
|
|
3867
|
-
}
|
|
3868
|
-
function vi(e, t, n, r, i) {
|
|
3869
|
-
let a = [...n ?? [], ...di(i)].filter((e) => e.isJSType !== void 0);
|
|
3870
|
-
function o(e) {
|
|
3871
|
-
return e === he || r === !0 && e === void 0;
|
|
3872
|
-
}
|
|
3873
|
-
if (Array.isArray(t)) {
|
|
3874
|
-
let n = t.map(String);
|
|
3875
|
-
function r(e) {
|
|
3876
|
-
if (typeof e != "object" || !e) return e;
|
|
3877
|
-
if (e instanceof $) return $.from(e, ([e, t]) => [e, r(t)]);
|
|
3878
|
-
if (Array.isArray(e)) return e.map(r);
|
|
3879
|
-
if (k.symbol in e || _i(e) || a.some((t) => t.isJSType(e))) return e;
|
|
3880
|
-
let t = Object.getPrototypeOf(e);
|
|
3881
|
-
if (t === Object.prototype || t === null) {
|
|
3882
|
-
let t = e.toJSON;
|
|
3883
|
-
if (typeof t == "function") return r(t.call(e));
|
|
3884
|
-
}
|
|
3885
|
-
let i = {};
|
|
3886
|
-
for (let t of n) Object.prototype.hasOwnProperty.call(e, t) && (i[t] = r(e[t]));
|
|
3887
|
-
return i;
|
|
3888
|
-
}
|
|
3889
|
-
return r(e);
|
|
3890
|
-
}
|
|
3891
|
-
let s = t;
|
|
3892
|
-
function c(e, t, n) {
|
|
3893
|
-
if (typeof e == "object" && e && !(e instanceof $)) {
|
|
3894
|
-
let n = Object.getPrototypeOf(e);
|
|
3895
|
-
if (n === Object.prototype || n === null) {
|
|
3896
|
-
let n = e.toJSON;
|
|
3897
|
-
typeof n == "function" && (e = n.call(e, t));
|
|
3898
|
-
}
|
|
3899
|
-
}
|
|
3900
|
-
if (e = s.call(n, t, e), typeof e == "object" && e) {
|
|
3901
|
-
if (k.symbol in e) return e;
|
|
3902
|
-
if (e instanceof $) {
|
|
3903
|
-
let t = new $();
|
|
3904
|
-
for (let [n, r] of e) {
|
|
3905
|
-
let i = c(r, n, e);
|
|
3906
|
-
o(i) || t.push([n, i]);
|
|
3907
|
-
}
|
|
3908
|
-
return t;
|
|
3909
|
-
}
|
|
3910
|
-
if (Array.isArray(e)) return e.map((t, n) => {
|
|
3911
|
-
let r = c(t, String(n), e);
|
|
3912
|
-
return o(r) ? null : r;
|
|
3913
|
-
});
|
|
3914
|
-
if (_i(e) || a.some((t) => t.isJSType(e))) return e;
|
|
3915
|
-
let t = {};
|
|
3916
|
-
for (let n of Object.keys(e)) {
|
|
3917
|
-
let r = c(e[n], n, e);
|
|
3918
|
-
o(r) || (t[n] = r);
|
|
3919
|
-
}
|
|
3920
|
-
return t;
|
|
3921
|
-
}
|
|
3922
|
-
return e;
|
|
3923
|
-
}
|
|
3924
|
-
return c(e, "", { "": e });
|
|
3925
|
-
}
|
|
3926
|
-
//#endregion
|
|
3927
|
-
//#region src/mapEntries.ts
|
|
3928
|
-
var $ = class extends Array {
|
|
3929
|
-
toJSON() {
|
|
3930
|
-
let e = {};
|
|
3931
|
-
for (let [t, n] of this) {
|
|
3932
|
-
let r = typeof t == "string" ? t : hi(t).toCDN();
|
|
3933
|
-
r === "__proto__" ? Object.defineProperty(e, r, {
|
|
3934
|
-
value: n,
|
|
3935
|
-
writable: !0,
|
|
3936
|
-
enumerable: !0,
|
|
3937
|
-
configurable: !0
|
|
3938
|
-
}) : e[r] = n;
|
|
3939
|
-
}
|
|
3940
|
-
return e;
|
|
3941
|
-
}
|
|
3942
|
-
};
|
|
3943
|
-
//#endregion
|
|
3944
|
-
export { R as A, ce as B, G as C, V as D, H as E, P as F, le as H, N as I, ge as L, Ie as M, I as N, B as O, F as P, he as R, Ke as S, U as T, k as V, lt as _, si as a, Ye as b, Wr as c, ar as d, jn as f, pt as g, Y as h, li as i, L as j, z as k, Ur as l, fn as m, vi as n, Zr as o, dn as p, hi as r, Qr as s, $ as t, Or as u, ct as v, W as w, Ge as x, K as y, se as z };
|
|
3945
|
-
|
|
3946
|
-
//# sourceMappingURL=mapEntries-CvLdiN0h.js.map
|