@cbortech/cbor 0.25.9 → 0.25.11

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokenizer-DkLlZ1gc.js","names":[],"sources":["../src/cdn/errors.ts","../src/utils/hex.ts","../src/cdn/tokenizer.ts"],"sourcesContent":["/**\n * Structured syntax error thrown by the CDN tokenizer and parser.\n *\n * Carries the source position of the failure so tooling (editors, linters,\n * playgrounds) can point at the offending range without parsing the message.\n * Position fields are present whenever the failure site knows them.\n */\nexport class CdnSyntaxError extends SyntaxError {\n /** Character offset of the start of the offending range in the source input. */\n readonly offset?: number;\n /** 1-based line number of the offending range. */\n readonly line?: number;\n /** 1-based column number of the offending range. */\n readonly column?: number;\n /** Character offset just past the end of the offending range. */\n readonly endOffset?: number;\n\n constructor(\n message: string,\n position?: {\n offset?: number;\n line?: number;\n column?: number;\n endOffset?: number;\n }\n ) {\n const loc =\n position?.line !== undefined\n ? ` at line ${position.line}, column ${position.column}`\n : '';\n super(`EDN parse error${loc}: ${message}`);\n this.name = 'CdnSyntaxError';\n this.offset = position?.offset;\n this.line = position?.line;\n this.column = position?.column;\n this.endOffset = position?.endOffset;\n }\n}\n","/**\n * Hex codec helpers shared by the CDN serializer, parser, and extensions.\n *\n * Native `Uint8Array.prototype.toHex` is the fastest option at every size, so\n * it is used whenever available. Native `Uint8Array.fromHex` carries a fixed\n * ~300–400 ns argument-validation overhead per call (measured on Node 25/26),\n * which makes a lookup-table loop 5–6× faster for small payloads such as\n * UUIDs; native only wins from ~128 bytes up. `hexToBytes` therefore switches\n * implementations on input length.\n */\n\nconst HEX_DIGITS = Array.from({ length: 256 }, (_, i) =>\n i.toString(16).padStart(2, '0')\n);\n\n// Maps hex char codes (both cases) to their value; -1 marks invalid chars so\n// the decode loop can detect them with a single sign check per byte.\nconst HEX_VALUES = new Int8Array(128).fill(-1);\nfor (let i = 0; i < 16; i++) {\n HEX_VALUES['0123456789abcdef'.charCodeAt(i)] = i;\n HEX_VALUES['0123456789ABCDEF'.charCodeAt(i)] = i;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst _hasNativeToHex =\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n typeof (Uint8Array.prototype as any).toHex === 'function';\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst _hasNativeFromHex =\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n typeof (Uint8Array as any).fromHex === 'function';\n\n// Below this many hex digits the LUT loop beats native fromHex.\nconst NATIVE_FROM_HEX_MIN_DIGITS = 256;\n\n/** Encode bytes as lowercase hex. */\nexport function bytesToHex(bytes: Uint8Array): string {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n if (_hasNativeToHex) return (bytes as any).toHex();\n let out = '';\n for (let i = 0; i < bytes.length; i++) out += HEX_DIGITS[bytes[i]!];\n return out;\n}\n\n// Uppercase table for the annotated hex-dump format (RFC 8949 §3 style).\nconst HEX_DIGITS_UPPER = Array.from({ length: 256 }, (_, i) =>\n i.toString(16).toUpperCase().padStart(2, '0')\n);\n\n/** Encode one byte as two uppercase hex digits (e.g. 10 → \"0A\"). */\nexport function byteToHexUpper(b: number): string {\n return HEX_DIGITS_UPPER[b]!;\n}\n\n/** Encode bytes as space-separated uppercase hex (e.g. \"0A FF\"), the\n * per-line format used by `toHexDump()`. */\nexport function bytesToSpacedHexUpper(bytes: Uint8Array): string {\n let out = '';\n for (let i = 0; i < bytes.length; i++) {\n if (i > 0) out += ' ';\n out += HEX_DIGITS_UPPER[bytes[i]!];\n }\n return out;\n}\n\n/**\n * Decode a hex string to bytes.\n *\n * Throws SyntaxError on odd-length input or non-hex characters (the native\n * fromHex path throws its own SyntaxError with a different message).\n */\nexport function hexToBytes(hex: string): Uint8Array {\n if (hex.length % 2 !== 0)\n throw new SyntaxError(`hex string has odd length: ${hex.length}`);\n if (_hasNativeFromHex && hex.length >= NATIVE_FROM_HEX_MIN_DIGITS)\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return (Uint8Array as any).fromHex(hex) as Uint8Array;\n const out = new Uint8Array(hex.length / 2);\n for (let i = 0, j = 0; i < hex.length; i += 2, j++) {\n const c1 = hex.charCodeAt(i);\n const c2 = hex.charCodeAt(i + 1);\n const hi = c1 < 128 ? HEX_VALUES[c1]! : -1;\n const lo = c2 < 128 ? HEX_VALUES[c2]! : -1;\n if ((hi | lo) < 0) {\n const bad = hi < 0 ? hex[i]! : hex[i + 1]!;\n throw new SyntaxError(\n `invalid character ${JSON.stringify(bad)} in hex string`\n );\n }\n out[j] = (hi << 4) | lo;\n }\n return out;\n}\n","/**\n * CDN lexer (internal).\n *\n * Used by parser.ts for parsing and by CborTextString serialization to collect\n * source offsets after parseCDN() has already validated embedded CDN.\n */\n\nimport { CdnSyntaxError } from './errors';\nimport { bytesToHex } from '../utils/hex';\n\nexport type TokenType =\n | 'INTEGER'\n | 'FLOAT'\n | 'TSTR'\n | 'SQSTR'\n | 'RAWSTRING'\n | 'BYTES_HEX'\n | 'BYTES_HEX_ELIDED'\n | 'BYTES_B64'\n | 'APP_STRING'\n | 'APP_SEQUENCE'\n | 'EMPTY_INDEF_BYTES'\n | 'EMPTY_INDEF_TEXT'\n | 'TRUE'\n | 'FALSE'\n | 'NULL'\n | 'UNDEFINED'\n | 'SIMPLE'\n | 'LBRACKET'\n | 'RBRACKET'\n | 'LBRACE'\n | 'RBRACE'\n | 'LPAREN'\n | 'RPAREN'\n | 'COLON'\n | 'COMMA'\n | 'PLUS'\n | 'UNDERSCORE'\n | 'ENCODING_INDICATOR'\n | 'LT_LT'\n | 'GT_GT'\n | 'ELLIPSIS'\n | 'EOF'\n /** Synthetic token emitted by tokenizeLenient() for the unscannable tail. */\n | 'ERROR';\n\nexport interface Token {\n type: TokenType;\n /** Processed value: decoded string content, raw number text, raw byte content, etc. */\n value: string;\n /** Original source text for this token. */\n raw: string;\n line: number;\n col: number;\n /** Character offset of the first character of this token in the source input. */\n offset: number;\n /** Character offset just past the last character of this token in the source input. */\n endOffset: number;\n /** Only set when type === 'APP_STRING': the extension prefix (e.g. 'dt', 'DT'). */\n appPrefix?: string;\n}\n\n/**\n * @internal\n * SQSTR tokens carry the UTF-8 payload the tokenizer already encoded, so the\n * parser does not decode the hex `value` back into the same bytes. The\n * property is non-enumerable and deliberately absent from the public `Token`\n * type: the tokenize() API shape (keys, JSON.stringify, spread) is unchanged.\n */\nexport interface SqstrToken extends Token {\n readonly _sqstrBytes?: Uint8Array;\n}\n\nexport interface TokenizerOptions {\n /** Character offset at which tokenization starts. */\n offset?: number;\n /** When true, RS (U+001E, RFC 7464 record separator) is treated as whitespace. */\n skipRS?: boolean;\n}\n\nexport interface EdnComment {\n kind: 'line' | 'block';\n marker: '#' | '//' | '/*' | '/';\n text: string;\n start: number;\n end: number;\n line: number;\n col: number;\n}\n\n/** Inverse of positionAt; only used on the cold error path. */\nfunction offsetAt(input: string, line: number, col: number): number {\n let l = 1;\n let c = 1;\n for (let i = 0; i < input.length; i++) {\n if (l === line && c === col) return i;\n if (input[i] === '\\n') {\n l++;\n c = 1;\n } else {\n c++;\n }\n }\n return input.length;\n}\n\nfunction positionAt(\n input: string,\n offset: number\n): { line: number; col: number } {\n let line = 1;\n let col = 1;\n for (let i = 0; i < offset; i++) {\n if (input[i] === '\\n') {\n line++;\n col = 1;\n } else {\n col++;\n }\n }\n return { line, col };\n}\n\n// ─── Scanning helpers (hot path) ─────────────────────────────────────────────\n//\n// Token content is consumed in bulk runs: a charCodeAt loop locates the next\n// character that needs individual handling, and everything before it is\n// appended with a single slice instead of per-character concatenation.\n\nfunction isHexDigitCode(c: number): boolean {\n return (\n (c >= 0x30 && c <= 0x39) || // 0-9\n (c >= 0x61 && c <= 0x66) || // a-f\n (c >= 0x41 && c <= 0x46) // A-F\n );\n}\n\n/** Shared encoder — constructing TextEncoder per token is needlessly slow. */\nconst textEncoder = new TextEncoder();\n\nexport class Tokenizer {\n private pos: number;\n private line: number;\n private col: number;\n private _peeked: Token | null = null;\n private _lastConsumedEndOffset: number;\n private readonly skipRS: boolean;\n /** Comments encountered while scanning, appended in source order. */\n readonly comments: EdnComment[] = [];\n /**\n * When set, non-standard-but-JS-valid escape sequences are accepted instead\n * of throwing. The callback receives a message and the position of the `\\`\n * (offset, line, column) plus the offset just past the escape sequence, so\n * the parser can forward it as a range-carrying ParseWarning.\n */\n onEscapeWarning?: (\n msg: string,\n offset: number,\n line: number,\n col: number,\n endOffset: number\n ) => void;\n constructor(\n private readonly input: string,\n options?: TokenizerOptions\n ) {\n const offset = options?.offset ?? 0;\n this.skipRS = options?.skipRS ?? false;\n if (!Number.isInteger(offset) || offset < 0 || offset > input.length)\n throw new RangeError(\n `EDN parse offset must be an integer between 0 and ${input.length}`\n );\n const position = positionAt(input, offset);\n this.pos = offset;\n this.line = position.line;\n this.col = position.col;\n this._lastConsumedEndOffset = offset;\n }\n\n peek(): Token {\n if (this._peeked === null) this._peeked = this._readNext();\n return this._peeked;\n }\n\n consume(): Token {\n const tok = this._peeked !== null ? this._peeked : this._readNext();\n this._peeked = null;\n this._lastConsumedEndOffset = tok.endOffset;\n return tok;\n }\n\n /** Character offset just past the last character of the most recently consumed token. */\n get lastEndOffset(): number {\n return this._lastConsumedEndOffset;\n }\n\n /** The full source text supplied to this tokenizer. */\n get source(): string {\n return this.input;\n }\n\n // ── Internal helpers ─────────────────────────────────────────────────────\n\n private _ch(): string {\n return this.input[this.pos] ?? '';\n }\n private _eof(): boolean {\n return this.pos >= this.input.length;\n }\n\n private _advance(): string {\n const c = this.input[this.pos++] ?? '';\n if (c === '\\n') {\n this.line++;\n this.col = 1;\n } else {\n this.col++;\n }\n return c;\n }\n\n private _fail(msg: string, line = this.line, col = this.col): never {\n const offset =\n line === this.line && col === this.col\n ? this.pos\n : offsetAt(this.input, line, col);\n // The scan position sits at the end of the offending construct when the\n // failure was reported against an earlier start position; cover at least\n // one character so tooling can underline a range (zero-width only at EOF).\n const endOffset = Math.min(\n Math.max(this.pos, offset + 1),\n this.input.length\n );\n throw new CdnSyntaxError(msg, { offset, line, column: col, endOffset });\n }\n\n private _skipWS(): void {\n for (;;) {\n // Skip whitespace characters. Common ASCII whitespace is matched with\n // direct comparisons; printable ASCII can never match /\\s/, so the\n // regex only runs for the rare remaining characters (e.g. \\f, NBSP).\n for (;;) {\n const ws = this.input[this.pos];\n if (ws === undefined) return;\n if (\n ws === ' ' ||\n ws === '\\n' ||\n ws === '\\t' ||\n ws === '\\r' ||\n (this.skipRS && ws === '\\x1e')\n ) {\n this._advance();\n continue;\n }\n if (ws > ' ' && ws <= '~') break; // printable ASCII — not whitespace\n if (/\\s/.test(ws)) {\n this._advance();\n continue;\n }\n break;\n }\n\n const c = this._ch();\n\n // CDN line comment: # to end of line\n if (c === '#') {\n const start = this.pos;\n const line = this.line;\n const col = this.col;\n while (!this._eof() && this._ch() !== '\\n') this._advance();\n this.comments.push({\n kind: 'line',\n marker: '#',\n text: this.input.slice(start, this.pos),\n start,\n end: this.pos,\n line,\n col,\n });\n continue;\n }\n\n // Comments starting with /\n if (c === '/') {\n const next = this.input[this.pos + 1] ?? '';\n if (next === '/') {\n // EDN end-of-line comment: // to end of line (§2.2)\n const start = this.pos;\n const line = this.line;\n const col = this.col;\n this._advance();\n this._advance();\n while (!this._eof() && this._ch() !== '\\n') this._advance();\n this.comments.push({\n kind: 'line',\n marker: '//',\n text: this.input.slice(start, this.pos),\n start,\n end: this.pos,\n line,\n col,\n });\n continue;\n }\n if (next === '*') {\n // EDN block comment: /* ... */ (§2.2)\n const start = this.pos;\n const line = this.line;\n const col = this.col;\n this._advance();\n this._advance();\n this._skipBlockCommentStar();\n this.comments.push({\n kind: 'block',\n marker: '/*',\n text: this.input.slice(start, this.pos),\n start,\n end: this.pos,\n line,\n col,\n });\n continue;\n }\n // EDN slash-delimited comment: / ... / (§2.2, first char must not be * or /)\n const start = this.pos;\n const line = this.line;\n const col = this.col;\n this._advance(); // consume opening /\n this._skipBlockCommentSlash();\n this.comments.push({\n kind: 'block',\n marker: '/',\n text: this.input.slice(start, this.pos),\n start,\n end: this.pos,\n line,\n col,\n });\n continue;\n }\n\n return;\n }\n }\n\n /**\n * Skip a comment in a quoted byte string literal (h'', b64'').\n * Returns true if a comment was consumed, false if the current char is not a\n * comment start. `quote` is the closing delimiter character.\n *\n * Supports / ... /, /* *\\/, //, and # comment forms (§2.2).\n */\n private _skipByteStringComment(quote: string): boolean {\n const ch = this._ch();\n if (ch === '/') {\n const next = this.input[this.pos + 1] ?? '';\n if (next === '/') {\n this._advance();\n this._advance();\n while (!this._eof() && this._ch() !== '\\n') {\n if (this._ch() === '\\\\') {\n this._advance();\n if (!this._eof() && this._ch() !== '\\n') this._advance();\n continue;\n }\n if (this._ch() === quote) break;\n this._advance();\n }\n return true;\n }\n if (next === '*') {\n this._advance();\n this._advance();\n this._skipBlockCommentStar();\n return true;\n }\n this._advance();\n this._skipBlockCommentSlash();\n return true;\n }\n if (ch === '#') {\n while (!this._eof() && this._ch() !== '\\n') {\n if (this._ch() === '\\\\') {\n this._advance(); // consume '\\'\n if (this._eof() || this._ch() === '\\n') continue;\n const escaped = this._advance();\n if (escaped === 'u') this._validateHexCommentUnicodeEscape();\n continue;\n }\n if (this._ch() === quote) break;\n this._advance();\n }\n return true;\n }\n return false;\n }\n\n /**\n * Validate a `\\uXXXX` or `\\u{N}` escape inside a hex-string comment.\n *\n * Called immediately after the `u` character has been consumed. Rejects\n * lone surrogates and invalid surrogate pairs; tolerates truncated/\n * non-hex sequences (comments are informational, but surrogates are\n * always illegal).\n */\n private _validateHexCommentUnicodeEscape(): void {\n const line = this.line,\n col = this.col;\n\n // Extended form \\u{XXXXXX}\n if (!this._eof() && this._ch() === '{') {\n this._advance(); // {\n let hex = '';\n while (!this._eof() && this._ch() !== '}' && this._ch() !== '\\n')\n hex += this._advance();\n if (!this._eof() && this._ch() === '}') this._advance(); // }\n const cp = parseInt(hex || '0', 16);\n if (cp >= 0xd800 && cp <= 0xdfff)\n this._fail(\n `\\\\u{${hex}} is a surrogate code point, not allowed in hex string comments`,\n line,\n col\n );\n return;\n }\n\n // Standard \\uXXXX — read up to 4 hex digits\n let hex = '';\n for (let i = 0; i < 4; i++) {\n if (this._eof() || this._ch() === '\\n') break;\n if (!/[0-9a-fA-F]/.test(this._ch())) break;\n hex += this._advance();\n }\n if (hex.length < 4) return; // truncated / non-hex — not our problem\n\n const cp = parseInt(hex, 16);\n\n // High surrogate: must be followed immediately by a low-surrogate escape\n if (cp >= 0xd800 && cp <= 0xdbff) {\n if (this._ch() !== '\\\\' || (this.input[this.pos + 1] ?? '') !== 'u')\n this._fail(\n `lone high surrogate \\\\u${hex} in hex string comment`,\n line,\n col\n );\n this._advance(); // \\\n this._advance(); // u\n let hex2 = '';\n for (let i = 0; i < 4; i++) {\n if (this._eof() || this._ch() === '\\n') break;\n if (!/[0-9a-fA-F]/.test(this._ch())) break;\n hex2 += this._advance();\n }\n const cp2 = parseInt(hex2 || '0', 16);\n if (cp2 < 0xdc00 || cp2 > 0xdfff)\n this._fail(\n `\\\\u${hex} (high surrogate) not followed by valid low surrogate in hex string comment`,\n line,\n col\n );\n return;\n }\n\n if (cp >= 0xdc00 && cp <= 0xdfff)\n this._fail(\n `lone low surrogate \\\\u${hex} in hex string comment`,\n line,\n col\n );\n }\n\n /**\n * Skip a comment in a raw byte string (h``, b64``).\n * Called with `i` pointing at the comment-start character.\n * Returns the index after the comment, or -1 if no comment was found.\n *\n * Supports / ... /, /* *\\/, //, and # comment forms (§2.2).\n * `context` is used in unterminated-comment error messages.\n */\n private _skipRawComment(\n raw: string,\n i: number,\n context: string,\n tokenLine: number,\n tokenCol: number\n ): number {\n const ch = raw[i];\n if (ch === '/') {\n i++;\n if (raw[i] === '/') {\n i++;\n while (i < raw.length && raw[i] !== '\\n') i++;\n return i;\n }\n if (raw[i] === '*') {\n i++;\n while (i < raw.length) {\n if (raw[i] === '*' && raw[i + 1] === '/') return i + 2;\n i++;\n }\n return i; // EOF inside comment — fall through; caller will report\n }\n // / … / comment\n while (i < raw.length && raw[i] !== '/') i++;\n if (i >= raw.length)\n this._fail(\n `unterminated block comment in ${context}`,\n tokenLine,\n tokenCol\n );\n return i + 1; // consume closing /\n }\n if (ch === '#') {\n while (i < raw.length && raw[i] !== '\\n') i++;\n return i;\n }\n return -1; // not a comment\n }\n\n /** Skip content until a closing `/` (CDN block comment). */\n private _skipBlockCommentSlash(): void {\n const line = this.line,\n col = this.col;\n while (!this._eof()) {\n if (this._ch() === '\\\\') {\n this._advance();\n if (!this._eof()) this._advance();\n continue;\n }\n if (this._ch() === '/') break;\n this._advance();\n }\n if (this._eof()) this._fail('unterminated block comment', line, col);\n this._advance(); // consume closing /\n }\n\n /** Skip content until a closing `*\\/` (JSONC block comment). */\n private _skipBlockCommentStar(): void {\n const line = this.line,\n col = this.col;\n while (!this._eof()) {\n if (this._ch() === '*' && (this.input[this.pos + 1] ?? '') === '/') {\n this._advance();\n this._advance();\n return;\n }\n this._advance();\n }\n this._fail('unterminated block comment', line, col);\n }\n\n /**\n * Read content between `quote` delimiters, processing escape sequences.\n *\n * Strict spec compliance:\n * - Literal LF (U+000A) is allowed; all other C0 controls and U+007F are rejected.\n * - Literal CR (U+000D) is silently stripped (source-level CRLF normalisation).\n * - Only spec-defined escape sequences are accepted; `\\q` etc. throw SyntaxError.\n * - `\\/` is valid only in double-quoted strings (not in escapable-s, §5.1).\n * - `\\\\` (backslash) is valid in both single- and double-quoted strings.\n * - `\\uXXXX` for a high surrogate must be immediately followed by `\\uXXXX` for\n * the corresponding low surrogate; lone surrogates are rejected.\n * - `\\u{N}` … `\\u{10FFFF}` extended syntax is supported; surrogates are rejected.\n * - In single-quoted strings, `\\u` escapes to printable ASCII (U+0020–U+007E)\n * are forbidden (hexchar-s restriction, draft-25 §5.1).\n */\n private _readStringContent(quote: string): string {\n this._advance(); // opening quote\n const quoteCode = quote.charCodeAt(0);\n const inputLen = this.input.length;\n let out = '';\n while (!this._eof() && this._ch() !== quote) {\n // Fast path: bulk-consume a run of ordinary characters up to the next\n // delimiter, backslash, CR, or control character. LF is ordinary\n // content; it is counted here so line/col stay correct.\n let p = this.pos;\n let newlines = 0;\n let lastNewline = -1;\n while (p < inputLen) {\n const cc = this.input.charCodeAt(p);\n if (cc === quoteCode || cc === 0x5c /* \\ */ || cc === 0x7f /* DEL */)\n break;\n if (cc < 0x20) {\n if (cc !== 0x0a) break; // CR / other C0 controls → slow path\n newlines++;\n lastNewline = p;\n }\n p++;\n }\n if (p > this.pos) {\n out += this.input.slice(this.pos, p);\n if (newlines > 0) {\n this.line += newlines;\n this.col = p - lastNewline;\n } else {\n this.col += p - this.pos;\n }\n this.pos = p;\n continue;\n }\n\n const ch = this._ch();\n\n // Strip literal CR (cross-platform source normalisation — spec §2.5.1)\n if (ch === '\\r') {\n this._advance();\n continue;\n }\n\n // Reject unescaped C0 control characters (except LF) and DEL — spec §5.1 unescaped\n const cp = ch.codePointAt(0)!;\n if ((cp < 0x20 && cp !== 0x0a) || cp === 0x7f)\n this._fail(\n `unescaped control character U+${cp.toString(16).padStart(4, '0')} is not allowed in string literals`\n );\n\n if (ch === '\\\\') {\n // Capture position of the backslash itself before consuming it.\n const eOffset = this.pos,\n eLine = this.line,\n eCol = this.col;\n this._advance();\n const e = this._advance();\n switch (e) {\n case 'n':\n out += '\\n';\n break;\n case 'r':\n out += '\\r';\n break;\n case 't':\n out += '\\t';\n break;\n case 'b':\n out += '\\b';\n break;\n case 'f':\n out += '\\f';\n break;\n case '\\\\':\n out += '\\\\';\n break;\n case 'u':\n out += this._readUnicodeEscape(quote, eOffset, eLine, eCol);\n break;\n default:\n // Escaped delimiter char (e.g. \\' inside '...' or \\\" inside \"...\")\n if (e === quote) {\n out += e;\n break;\n }\n if (e === '/') {\n if (quote === \"'\")\n this._fail(\n `\\\\/ is not a valid escape in single-quoted byte strings (§5.1)`,\n eLine,\n eCol\n );\n out += '/';\n break;\n }\n // Non-standard JS escape sequences — accepted when onEscapeWarning is set.\n if (this.onEscapeWarning) {\n if (e === '0') {\n this.onEscapeWarning(\n '\\\\0 is a non-standard escape sequence; use \\\\u0000 instead',\n eOffset,\n eLine,\n eCol,\n this.pos\n );\n out += '\\0';\n break;\n }\n if (e === 'v') {\n this.onEscapeWarning(\n '\\\\v is a non-standard escape sequence; use \\\\u000b instead',\n eOffset,\n eLine,\n eCol,\n this.pos\n );\n out += '\\v';\n break;\n }\n if (e === 'x') {\n // \\xHH — two hex digits\n const h1 = this._ch();\n const h2 = this.input[this.pos + 1] ?? '';\n if (!/[0-9a-fA-F]/.test(h1) || !/[0-9a-fA-F]/.test(h2)) {\n this._fail(\n '\\\\x escape requires exactly two hex digits',\n eLine,\n eCol\n );\n }\n this._advance();\n this._advance();\n const codePoint = parseInt(h1 + h2, 16);\n this.onEscapeWarning(\n `\\\\x${h1}${h2} is a non-standard escape sequence; use \\\\u00${h1}${h2} instead`,\n eOffset,\n eLine,\n eCol,\n this.pos\n );\n out += String.fromCharCode(codePoint);\n break;\n }\n // Cross-quote delimiter (e.g. \\\" inside '...' or \\' inside \"...\")\n if (e === '\"' || e === \"'\") {\n this.onEscapeWarning(\n `\\\\${e} inside ${quote === '\"' ? 'double' : 'single'}-quoted string is non-standard`,\n eOffset,\n eLine,\n eCol,\n this.pos\n );\n out += e;\n break;\n }\n // JS line continuation: \\ + LF / CR / CRLF → nothing added\n if (e === '\\n' || e === '\\r') {\n if (e === '\\r' && this._ch() === '\\n') this._advance(); // consume CRLF\n this.onEscapeWarning(\n 'line continuation (\\\\<newline>) is non-standard; the newline is ignored',\n eOffset,\n eLine,\n eCol,\n this.pos\n );\n break;\n }\n // Identity escape: \\X → X (JS accepts any \\X as just X)\n this.onEscapeWarning(\n `\\\\${e} is an unknown escape sequence; interpreted as '${e}'`,\n eOffset,\n eLine,\n eCol,\n this.pos\n );\n out += e;\n break;\n }\n this._fail(\n `invalid escape sequence \\\\${e} in ${quote === '\"' ? 'double' : 'single'}-quoted string`,\n eLine,\n eCol\n );\n }\n } else {\n out += this._advance();\n }\n }\n if (this._eof()) this._fail('unterminated string literal');\n this._advance(); // closing quote\n return out;\n }\n\n /**\n * Parse a Unicode escape immediately after `\\u` has been consumed.\n *\n * @param quote - The enclosing string delimiter (`\"` or `'`).\n *\n * Handles two forms:\n * - `\\u{N}` … `\\u{10FFFF}`: direct Unicode scalar value (surrogates rejected)\n * - `\\uXXXX`: exactly four hex digits; a high surrogate must be followed by\n * `\\uXXXX` for the matching low surrogate to form a valid surrogate pair,\n * which is then decoded into the corresponding non-BMP code point.\n *\n * In single-quoted strings (`quote === \"'\"`), `\\u` escapes that resolve to\n * printable ASCII (U+0020–U+007E) are rejected per draft-25 §5.1 hexchar-s.\n * Use `\\\\` for backslash (U+005C) and `\\'` for the single-quote delimiter.\n */\n private _readUnicodeEscape(\n quote: string,\n bsOffset?: number,\n bsLine?: number,\n bsCol?: number\n ): string {\n const line = this.line,\n col = this.col;\n\n /** Warn or throw when this is a single-quoted string and the code point is printable ASCII. */\n const checkSingleQuotedPrintable = (cp: number): void => {\n // Per draft-25 §5.1 hexchar-s, \\u escapes for printable ASCII (U+0020–U+007E)\n // are not valid in single-quoted strings. Use \\\\ for backslash and \\' for\n // the single-quote delimiter. In lenient mode (onEscapeWarning set) we emit\n // a warning and accept the value rather than hard-failing.\n if (quote === \"'\" && cp >= 0x20 && cp <= 0x7e) {\n const msg = `\\\\u escape for printable ASCII U+${cp.toString(16).padStart(4, '0').toUpperCase()} is not allowed in single-quoted strings (§5.1 hexchar-s)`;\n if (this.onEscapeWarning) {\n this.onEscapeWarning(\n msg,\n bsOffset ?? this.pos,\n bsLine ?? line,\n bsCol ?? col,\n this.pos\n );\n return;\n }\n this._fail(msg, line, col);\n }\n };\n\n // Extended form \\u{NNN}\n if (!this._eof() && this._ch() === '{') {\n this._advance(); // {\n let hex = '';\n while (!this._eof() && this._ch() !== '}') {\n const c = this._ch();\n if (!/[0-9a-fA-F]/.test(c))\n this._fail(\n `invalid character in \\\\u{} escape: ${JSON.stringify(c)}`,\n line,\n col\n );\n hex += this._advance();\n }\n if (this._eof()) this._fail('unterminated \\\\u{} escape', line, col);\n this._advance(); // }\n if (hex.length === 0) this._fail('empty \\\\u{} escape', line, col);\n const cp = parseInt(hex, 16);\n if (cp > 0x10_ffff)\n this._fail(\n `\\\\u{${hex}} exceeds maximum Unicode code point U+10FFFF`,\n line,\n col\n );\n if (cp >= 0xd800 && cp <= 0xdfff)\n this._fail(\n `\\\\u{${hex}} is a surrogate code point, which is not a valid Unicode scalar value`,\n line,\n col\n );\n checkSingleQuotedPrintable(cp);\n return String.fromCodePoint(cp);\n }\n\n // Standard form \\uXXXX\n let hex = '';\n for (let i = 0; i < 4; i++) {\n if (this._eof()) this._fail('truncated \\\\uXXXX escape', line, col);\n const c = this._ch();\n if (!/[0-9a-fA-F]/.test(c))\n this._fail(\n `invalid hex digit in \\\\uXXXX escape: ${JSON.stringify(c)}`,\n line,\n col\n );\n hex += this._advance();\n }\n const cp = parseInt(hex, 16);\n\n // High surrogate: must be immediately followed by a low-surrogate escape\n if (cp >= 0xd800 && cp <= 0xdbff) {\n if (this._ch() !== '\\\\' || (this.input[this.pos + 1] ?? '') !== 'u')\n this._fail(\n `lone high surrogate \\\\u${hex} must be followed by \\\\uDC00–\\\\uDFFF`,\n line,\n col\n );\n this._advance(); // \\\n this._advance(); // u\n const line2 = this.line,\n col2 = this.col;\n let hex2 = '';\n for (let i = 0; i < 4; i++) {\n if (this._eof())\n this._fail('truncated low-surrogate escape', line2, col2);\n hex2 += this._advance();\n }\n const cp2 = parseInt(hex2, 16);\n if (cp2 < 0xdc00 || cp2 > 0xdfff)\n this._fail(\n `\\\\u${hex} (high surrogate) not followed by a valid low surrogate (got \\\\u${hex2})`,\n line,\n col\n );\n // Surrogate pairs always resolve to non-BMP (> U+FFFF), never printable ASCII\n return String.fromCodePoint(\n 0x10000 + (cp - 0xd800) * 0x400 + (cp2 - 0xdc00)\n );\n }\n\n // Low surrogate without a preceding high surrogate is invalid\n if (cp >= 0xdc00 && cp <= 0xdfff)\n this._fail(`lone low surrogate \\\\u${hex} is not valid`, line, col);\n\n checkSingleQuotedPrintable(cp);\n return String.fromCharCode(cp);\n }\n\n /**\n * Read raw text-string content between N-backtick delimiters (§2.5.3).\n *\n * - The opening delimiter is the maximal run of consecutive backticks (N ≥ 1).\n * - A single leading newline (LF or CRLF) immediately after the opening is stripped.\n * - No escape sequences are processed — content is taken verbatim.\n * - Literal CR is stripped for source-level CRLF normalisation.\n * - The closing delimiter is the first run of M ≥ N backticks; any excess\n * M-N backticks are appended to the content before closing.\n */\n private _readRawStringContent(): string {\n const openLine = this.line,\n openCol = this.col;\n\n // Count opening backticks (greedy)\n let n = 0;\n while (!this._eof() && this._ch() === '`') {\n this._advance();\n n++;\n }\n\n // Strip a single leading CRLF or LF (§2.5.3)\n if (!this._eof() && this._ch() === '\\r') this._advance(); // CR\n if (!this._eof() && this._ch() === '\\n') this._advance(); // LF\n\n const inputLen = this.input.length;\n let out = '';\n while (!this._eof()) {\n // Fast path: bulk-consume a run of ordinary characters up to the next\n // backtick, CR, or control character. LF is ordinary content; it is\n // counted here so line/col stay correct.\n let p = this.pos;\n let newlines = 0;\n let lastNewline = -1;\n while (p < inputLen) {\n const cc = this.input.charCodeAt(p);\n if (cc === 0x60 /* ` */ || cc === 0x7f /* DEL */) break;\n if (cc < 0x20) {\n if (cc !== 0x0a) break; // CR / other C0 controls → slow path\n newlines++;\n lastNewline = p;\n }\n p++;\n }\n if (p > this.pos) {\n out += this.input.slice(this.pos, p);\n if (newlines > 0) {\n this.line += newlines;\n this.col = p - lastNewline;\n } else {\n this.col += p - this.pos;\n }\n this.pos = p;\n continue;\n }\n\n const ch = this._ch();\n\n // Source-level CRLF normalisation: strip bare CR\n if (ch === '\\r') {\n this._advance();\n continue;\n }\n\n if (ch === '`') {\n // Count this backtick run\n let m = 0;\n while (!this._eof() && this._ch() === '`') {\n this._advance();\n m++;\n }\n if (m >= n) {\n // Closing delimiter found; excess backticks become content\n out += '`'.repeat(m - n);\n // For N≥2, strip one leading and one trailing space (§2.5.3).\n if (n >= 2) {\n if (out.startsWith(' ')) out = out.slice(1);\n if (out.endsWith(' ')) out = out.slice(0, -1);\n }\n if (out === '')\n this._fail(\n 'raw string must not be empty (§2.5.3)',\n openLine,\n openCol\n );\n return out;\n }\n // Not enough backticks — all become content\n out += '`'.repeat(m);\n } else {\n const cp = ch.codePointAt(0)!;\n // rawchars = 1*(%x0a/%x0d / %x20-5f / %x61-7e / NONASCII) — HT and other C0 controls forbidden\n if (cp < 0x20 && cp !== 0x0a && cp !== 0x0d) {\n this._fail(\n `raw string content must not contain control character U+${cp.toString(16).toUpperCase().padStart(4, '0')} (§2.5.3)`,\n this.line,\n this.col\n );\n }\n if (cp === 0x7f) {\n this._fail(\n 'raw string content must not contain DEL (U+007F) (§2.5.3)',\n this.line,\n this.col\n );\n }\n out += this._advance();\n }\n }\n\n this._fail('unterminated raw string literal', openLine, openCol);\n }\n\n /**\n * Post-process raw hex content from a `h``…``\\` raw string (§5.3.3).\n *\n * Skips:\n * - lblank whitespace (LF, SP; also CR for source-level normalisation)\n * - `/ … /` block comments\n * - `# …` line comments (up to but not including LF)\n * Detects `...` ellipsis sequences.\n *\n * A trailing `# comment` immediately before the closing delimiter is allowed\n * per §5.3.3 `r-app-string-h`.\n *\n * Returns { value: hex-string-with-ellipsis-markers, elided: boolean }\n */\n private _processRawHexContent(\n raw: string,\n tokenLine: number,\n tokenCol: number\n ): { value: string; elided: boolean } {\n let hex = '';\n let elided = false;\n let i = 0;\n while (i < raw.length) {\n const ch = raw[i];\n // lblank / CR — skip\n if (ch === '\\n' || ch === ' ' || ch === '\\r') {\n i++;\n continue;\n }\n // HT is still forbidden (rawchars excludes %x09)\n if (ch === '\\t') {\n this._fail(\n 'horizontal tab (HT) is not allowed inside h`` raw byte string literals (§5.3.3)',\n tokenLine,\n tokenCol\n );\n }\n // Comments (§2.2)\n const afterComment = this._skipRawComment(\n raw,\n i,\n 'h`` raw byte string',\n tokenLine,\n tokenCol\n );\n if (afterComment !== -1) {\n i = afterComment;\n continue;\n }\n // Ellipsis: ... (three or more dots)\n if (ch === '.' && raw[i + 1] === '.' && raw[i + 2] === '.') {\n i += 3;\n while (i < raw.length && raw[i] === '.') i++;\n hex += '...';\n elided = true;\n continue;\n }\n // Hex digits — consume the whole run at once\n if (isHexDigitCode(raw.charCodeAt(i))) {\n const runStart = i;\n while (i < raw.length && isHexDigitCode(raw.charCodeAt(i))) i++;\n hex += raw.slice(runStart, i);\n continue;\n }\n this._fail(\n `unexpected character ${JSON.stringify(ch)} in h\\`\\` raw byte string`,\n tokenLine,\n tokenCol\n );\n }\n return { value: hex, elided };\n }\n\n /**\n * Post-process raw base64 content from a `b64``…``\\` raw string (§5.3.4).\n *\n * Skips:\n * - lblank whitespace (LF, SP; also CR for source-level normalisation)\n * - `# …` line comments (up to but not including LF)\n *\n * Returns the stripped base64 string.\n */\n private _processRawB64Content(\n raw: string,\n tokenLine: number,\n tokenCol: number\n ): string {\n let out = '';\n let i = 0;\n while (i < raw.length) {\n const ch = raw[i];\n // lblank / CR — skip\n if (ch === '\\n' || ch === ' ' || ch === '\\r') {\n i++;\n continue;\n }\n // HT forbidden\n if (ch === '\\t') {\n this._fail(\n 'horizontal tab (HT) is not allowed inside b64`` raw byte string literals (§5.3.4)',\n tokenLine,\n tokenCol\n );\n }\n // Line comment: # … (to end of line)\n // Note: // is NOT treated as a comment because / is a valid B64DIGIT\n // (e.g. 0xFF 0xFF encodes to //8= in standard base64).\n if (ch === '#') {\n while (i < raw.length && raw[i] !== '\\n') i++;\n continue;\n }\n // Run of data characters — consume in bulk up to the next terminator\n const runStart = i;\n while (i < raw.length) {\n const d = raw[i];\n if (d === '\\n' || d === ' ' || d === '\\r' || d === '\\t' || d === '#')\n break;\n i++;\n }\n out += raw.slice(runStart, i);\n }\n return out;\n }\n\n /**\n * Read raw byte-string content between `quote` chars (b64 / b64url).\n *\n * Strips whitespace and skips `# ...` line comments per §2.5.5.\n * `/` is NOT treated as a comment delimiter because it is a valid base64 character.\n */\n private _readByteContent(quote: string): string {\n this._advance(); // opening quote\n let raw = '';\n while (!this._eof() && this._ch() !== quote) {\n const ch = this._ch();\n // lblank = %x0A / %x20 — only LF and SP are whitespace (§5.2.2 Fig 4); HT is forbidden\n if (ch === '\\n' || ch === ' ') {\n this._advance();\n continue;\n }\n if (ch === '\\r') {\n // CR is not lblank; skip silently as source-level normalization only\n this._advance();\n continue;\n }\n if (ch === '\\t') {\n this._fail(\n 'horizontal tab (HT) is not allowed inside byte string literals (§5.2.2)',\n this.line,\n this.col\n );\n }\n // # line comment — stop at newline or the closing quote (whichever comes first)\n // Note: // is NOT treated as a comment here because / is a valid B64DIGIT;\n // treating // as a comment would corrupt base64 data that naturally contains\n // consecutive slashes (e.g. 0xFF 0xFF encodes to //8= in standard base64).\n if (ch === '#') {\n while (!this._eof() && this._ch() !== '\\n') {\n if (this._ch() === '\\\\') {\n this._advance();\n if (!this._eof() && this._ch() !== '\\n') this._advance();\n continue;\n }\n if (this._ch() === quote) break;\n this._advance();\n }\n continue;\n }\n // Run of data characters — consume in bulk up to the next terminator.\n // Newlines terminate the run, so a plain column update is safe.\n const runStart = this.pos;\n let p = this.pos;\n const n = this.input.length;\n while (p < n) {\n const d = this.input[p];\n if (\n d === quote ||\n d === '\\n' ||\n d === ' ' ||\n d === '\\r' ||\n d === '\\t' ||\n d === '#'\n )\n break;\n p++;\n }\n this.col += p - runStart;\n this.pos = p;\n raw += this.input.slice(runStart, p);\n }\n if (this._eof()) this._fail('unterminated byte string literal');\n this._advance(); // closing quote\n return raw;\n }\n\n /**\n * Read hex byte-string content, recognising `...` ellipsis sequences (§4.2).\n *\n * Returns the raw hex string (with `...` markers embedded) and a flag\n * indicating whether any ellipsis was found.\n */\n private _readHexByteContentElisionAware(quote: string): {\n value: string;\n elided: boolean;\n } {\n this._advance(); // opening quote\n let hex = '';\n let elided = false;\n while (!this._eof() && this._ch() !== quote) {\n const ch = this._ch();\n // lblank = %x0A / %x20 only; HT is forbidden per §5.2 Figure 3\n if (ch === '\\n' || ch === ' ' || ch === '\\r') {\n this._advance();\n continue;\n }\n if (ch === '\\t') {\n this._fail(\n 'horizontal tab (HT) is not allowed inside hex byte string literals (§5.2.1)',\n this.line,\n this.col\n );\n }\n if (this._skipByteStringComment(quote)) continue;\n // Detect '...' ellipsis inside hex literal\n if (\n ch === '.' &&\n (this.input[this.pos + 1] ?? '') === '.' &&\n (this.input[this.pos + 2] ?? '') === '.'\n ) {\n this._advance();\n this._advance();\n this._advance();\n // consume any additional dots (spec says \"three or more\")\n while (!this._eof() && this._ch() === '.') this._advance();\n // adjacent ... separated only by whitespace collapse into a single ellipsis\n if (!hex.endsWith('...')) hex += '...';\n elided = true;\n continue;\n }\n if (isHexDigitCode(ch.charCodeAt(0))) {\n // Run of hex digits — consume in bulk (digits contain no newlines)\n const runStart = this.pos;\n let p = this.pos;\n const n = this.input.length;\n while (p < n && isHexDigitCode(this.input.charCodeAt(p))) p++;\n this.col += p - runStart;\n this.pos = p;\n hex += this.input.slice(runStart, p);\n continue;\n }\n this._fail(\n `unexpected character ${JSON.stringify(ch)} in hex byte string`\n );\n }\n if (this._eof()) this._fail('unterminated hex byte string literal');\n this._advance(); // closing quote\n return { value: hex, elided };\n }\n\n // ── Token reader ─────────────────────────────────────────────────────────\n\n /** Start offset of the token currently being read (set by _readNext). */\n private _tokStart = 0;\n\n private _readNext(): Token {\n this._skipWS();\n this._tokStart = this.pos;\n return this._readNextCore();\n }\n\n /**\n * Build a complete Token for the source range [_tokStart, pos).\n * Every token is constructed exactly once here — the previous two-step\n * \"partial object, then spread in raw/offsets\" cost an extra object and a\n * property-copy pass per token on the parse hot path.\n *\n * `appPrefix` is added only for app-string/app-sequence tokens so that\n * ordinary tokens keep `'appPrefix' in tok === false`, matching the public\n * tokenize() API shape documented on the Token interface.\n *\n * `raw` stays an eagerly-sliced own data property: Token is public API, and\n * a getter would vanish under the consumer's own `{ ...token }` spread or\n * JSON.stringify. The slice cost is minor next to the removed extra object.\n */\n private _tok(\n type: TokenType,\n value: string,\n line: number,\n col: number,\n appPrefix?: string\n ): Token {\n const offset = this._tokStart;\n const tok: Token = {\n type,\n value,\n raw: this.input.slice(offset, this.pos),\n line,\n col,\n offset,\n endOffset: this.pos,\n };\n if (appPrefix !== undefined) tok.appPrefix = appPrefix;\n return tok;\n }\n\n /**\n * {@link _tok} variant for tokens whose processed `value` IS the raw source\n * text — punctuation, keywords, and numbers without a leading `+`. Reuses\n * `value` as `raw`, skipping a per-token slice on the densest token kinds.\n * Callers must guarantee `value === input.slice(_tokStart, pos)`.\n */\n private _tokV(\n type: TokenType,\n value: string,\n line: number,\n col: number\n ): Token {\n return {\n type,\n value,\n raw: value,\n line,\n col,\n offset: this._tokStart,\n endOffset: this.pos,\n };\n }\n\n private _readNextCore(): Token {\n const line = this.line,\n col = this.col;\n if (this._eof()) return this._tokV('EOF', '', line, col);\n\n const c = this._ch();\n\n switch (c) {\n case '[':\n this._advance();\n return this._tokV('LBRACKET', '[', line, col);\n case ']':\n this._advance();\n return this._tokV('RBRACKET', ']', line, col);\n case '{':\n this._advance();\n return this._tokV('LBRACE', '{', line, col);\n case '}':\n this._advance();\n return this._tokV('RBRACE', '}', line, col);\n case '(':\n this._advance();\n return this._tokV('LPAREN', '(', line, col);\n case ')':\n this._advance();\n return this._tokV('RPAREN', ')', line, col);\n case ':':\n this._advance();\n return this._tokV('COLON', ':', line, col);\n case ',':\n this._advance();\n return this._tokV('COMMA', ',', line, col);\n case '<':\n if ((this.input[this.pos + 1] ?? '') === '<') {\n this._advance();\n this._advance();\n return this._tokV('LT_LT', '<<', line, col);\n }\n this._fail(`unexpected character '<'`, line, col);\n case '>':\n if ((this.input[this.pos + 1] ?? '') === '>') {\n this._advance();\n this._advance();\n return this._tokV('GT_GT', '>>', line, col);\n }\n this._fail(`unexpected character '>'`, line, col);\n case '+': {\n // +Infinity[_N]\n const posInf = this._readSignedInfinity('+', line, col);\n if (posInf !== null) return posInf;\n // Numeric literal with explicit positive sign\n const afterPlus = this.input[this.pos + 1] ?? '';\n if ((afterPlus >= '0' && afterPlus <= '9') || afterPlus === '.') {\n this._advance(); // consume '+'\n return this._readNumber(line, col);\n }\n // String concatenation operator\n this._advance();\n return this._tokV('PLUS', '+', line, col);\n }\n case '`':\n return this._tok('RAWSTRING', this._readRawStringContent(), line, col);\n case '\"': {\n const strVal = this._readStringContent('\"');\n if (\n strVal === '' &&\n this._ch() === '_' &&\n !/[0-7i]/.test(this.input[this.pos + 1] ?? '')\n ) {\n this._advance(); // _\n return this._tok('EMPTY_INDEF_TEXT', '', line, col);\n }\n return this._tok('TSTR', strVal, line, col);\n }\n case \"'\": {\n // ''_ → empty indefinite byte string (but ''_N is sqstr + encoding indicator)\n if (\n (this.input[this.pos + 1] ?? '') === \"'\" &&\n (this.input[this.pos + 2] ?? '') === '_' &&\n !/[0-7i]/.test(this.input[this.pos + 3] ?? '')\n ) {\n this._advance(); // first '\n this._advance(); // second '\n this._advance(); // _\n return this._tok('EMPTY_INDEF_BYTES', '', line, col);\n }\n // 'text' → UTF-8 encoded byte string (major type 2)\n const strVal = this._readStringContent(\"'\");\n const utf8 = textEncoder.encode(strVal);\n const tok = this._tok('SQSTR', bytesToHex(utf8), line, col);\n // Attach the payload for the parser (see SqstrToken). defineProperty\n // keeps it out of keys/JSON/spread; SQSTR is rare enough that the\n // defineProperty cost does not matter.\n Object.defineProperty(tok, '_sqstrBytes', { value: utf8 });\n return tok;\n }\n }\n\n // -Infinity (check before generic '-' handling)\n if (c === '-') {\n const negInf = this._readSignedInfinity('-', line, col);\n if (negInf !== null) return negInf;\n return this._readNumber(line, col);\n }\n\n if (c >= '0' && c <= '9') return this._readNumber(line, col);\n // Leading-dot float: .5, .1e2, etc. (same as +.5 / -.5)\n if (c === '.' && /[0-9]/.test(this.input[this.pos + 1] ?? ''))\n return this._readNumber(line, col);\n if (/[a-zA-Z_]/.test(c)) return this._readIdent(line, col);\n\n // Three or more dots → ellipsis notation (§4.2)\n if (c === '.') {\n if (\n (this.input[this.pos + 1] ?? '') === '.' &&\n (this.input[this.pos + 2] ?? '') === '.'\n ) {\n this._advance();\n this._advance();\n this._advance();\n while (!this._eof() && this._ch() === '.') this._advance();\n return this._tok('ELLIPSIS', '...', line, col);\n }\n this._fail(`unexpected character '.'`, line, col);\n }\n\n this._fail(`unexpected character ${JSON.stringify(c)}`, line, col);\n }\n\n /**\n * Try to read `Infinity[_N]` immediately after a `+`/`-` sign at this.pos.\n *\n * Returns null when the input is not an Infinity literal (e.g. an identifier\n * like `Infinityx` that merely starts with \"Infinity\"); the caller then\n * falls back to its sign handling.\n *\n * All encoding-indicator suffixes _0–_7/_i are tokenized here; the parser\n * validates them and rejects/warns on the invalid ones (_0, _4–_7, _i).\n *\n * Uses startsWith with a position argument instead of slicing the remainder\n * of the input, which would allocate a substring for every sign token.\n */\n private _readSignedInfinity(\n sign: '+' | '-',\n line: number,\n col: number\n ): Token | null {\n if (!this.input.startsWith('Infinity', this.pos + 1)) return null;\n const after = this.input[this.pos + 9] ?? '';\n const hasSuffix =\n after === '_' &&\n /[0-7i]/.test(this.input[this.pos + 10] ?? '') &&\n !/[a-zA-Z0-9_]/.test(this.input[this.pos + 11] ?? '');\n if (/[a-zA-Z0-9_]/.test(after) && !hasSuffix) return null;\n this._advance(); // sign\n for (let i = 0; i < 8; i++) this._advance(); // Infinity\n let value = sign === '-' ? '-Infinity' : 'Infinity';\n if (hasSuffix) value += this._advance() + this._advance(); // _N\n return this._tok('FLOAT', value, line, col);\n }\n\n /** Advance past a run of hex digits. Digits contain no newlines, so a\n * plain column update is safe. */\n private _skipHexDigits(): void {\n let p = this.pos;\n const n = this.input.length;\n while (p < n && isHexDigitCode(this.input.charCodeAt(p))) p++;\n this.col += p - this.pos;\n this.pos = p;\n }\n\n /** Advance past a run of decimal digits (same newline-free guarantee). */\n private _skipDecimalDigits(): void {\n let p = this.pos;\n const n = this.input.length;\n while (p < n) {\n const c = this.input.charCodeAt(p);\n if (c < 0x30 || c > 0x39) break;\n p++;\n }\n this.col += p - this.pos;\n this.pos = p;\n }\n\n /**\n * Consume a trailing _0–_7/_i encoding-indicator suffix when present and\n * not followed by another identifier character.\n */\n private _tryConsumeEncodingSuffix(): void {\n if (this._ch() !== '_') return;\n const d = this.input[this.pos + 1] ?? '';\n const after = this.input[this.pos + 2] ?? '';\n if (((d >= '0' && d <= '7') || d === 'i') && !/[0-9a-zA-Z_]/.test(after)) {\n this._advance();\n this._advance();\n }\n }\n\n private _readNumber(line: number, col: number): Token {\n // The token value is the raw consumed text; it is collected with a single\n // slice at the end instead of per-character string concatenation.\n const start = this.pos;\n const consumed = () => this.input.slice(start, this.pos);\n // consumed() is the exact source range unless a leading '+' was eaten\n // by the caller before _readNumber; only then does raw need its own slice.\n const numTok = (type: TokenType): Token =>\n start === this._tokStart\n ? this._tokV(type, consumed(), line, col)\n : this._tok(type, consumed(), line, col);\n if (this._ch() === '-') this._advance();\n\n // Alternative bases: 0x 0o 0b\n if (this._ch() === '0') {\n const next = this.input[this.pos + 1] ?? '';\n if (next === 'x' || next === 'X') {\n this._advance();\n this._advance(); // '0x'\n const intStart = this.pos;\n this._skipHexDigits();\n const hasIntDigits = this.pos > intStart;\n // Hex float: optional '.[hex]' fractional part followed by 'p'/'P' exponent\n let isHexFloat = false;\n let hasFracDigits = false;\n if (!this._eof() && this._ch() === '.') {\n isHexFloat = true;\n this._advance();\n const fracStart = this.pos;\n this._skipHexDigits();\n hasFracDigits = this.pos > fracStart;\n }\n if (!this._eof() && (this._ch() === 'p' || this._ch() === 'P')) {\n isHexFloat = true;\n // Validate mantissa: need at least one hex digit before or after dot\n if (!hasIntDigits && !hasFracDigits)\n this._fail(\n `hex float has no mantissa digits: ${consumed()}`,\n line,\n col\n );\n this._advance();\n if (!this._eof() && (this._ch() === '+' || this._ch() === '-'))\n this._advance();\n const expStart = this.pos;\n this._skipDecimalDigits();\n // Validate exponent: at least one decimal digit required\n if (this.pos === expStart)\n this._fail(\n `hex float missing exponent digits: ${consumed()}`,\n line,\n col\n );\n } else if (isHexFloat) {\n // Had a dot but no 'p' — missing exponent\n this._fail(\n `hex float missing 'p' exponent: ${consumed()}`,\n line,\n col\n );\n }\n if (isHexFloat) {\n // Encoding-indicator suffix _0/_1/_2/_3/_4/_5/_6/_7/_i for hex floats\n this._tryConsumeEncodingSuffix();\n return numTok('FLOAT');\n }\n return numTok('INTEGER');\n }\n if (next === 'o' || next === 'O') {\n this._advance();\n this._advance();\n while (!this._eof() && this._ch() >= '0' && this._ch() <= '7')\n this._advance();\n return numTok('INTEGER');\n }\n if (next === 'b' || next === 'B') {\n this._advance();\n this._advance();\n while (!this._eof() && (this._ch() === '0' || this._ch() === '1'))\n this._advance();\n return numTok('INTEGER');\n }\n }\n\n // Decimal digits\n this._skipDecimalDigits();\n\n let isFloat = false;\n if (!this._eof() && this._ch() === '.') {\n isFloat = true;\n this._advance();\n this._skipDecimalDigits();\n }\n if (!this._eof() && (this._ch() === 'e' || this._ch() === 'E')) {\n isFloat = true;\n this._advance();\n if (!this._eof() && (this._ch() === '+' || this._ch() === '-'))\n this._advance();\n const expStart = this.pos;\n this._skipDecimalDigits();\n if (this.pos === expStart)\n this._fail(\n `float exponent has no digits: ${JSON.stringify(consumed())}`,\n line,\n col\n );\n }\n\n // Encoding-indicator suffix _0–_7 / _i (no whitespace, not followed by\n // more ident chars). The suffix is included in the token value.\n // isFloat is NOT set here — a float is only a float when it contains\n // '.' or 'e'/'E'. The parser extracts encoding width from the suffix.\n this._tryConsumeEncodingSuffix();\n\n return numTok(isFloat ? 'FLOAT' : 'INTEGER');\n }\n\n private _readIdent(line: number, col: number): Token {\n // Idents contain no newlines, so a plain column update is safe.\n const identStart = this.pos;\n {\n let p = this.pos;\n const n = this.input.length;\n while (p < n) {\n const cc = this.input.charCodeAt(p);\n const isIdentChar =\n (cc >= 0x61 && cc <= 0x7a) || // a-z\n (cc >= 0x41 && cc <= 0x5a) || // A-Z\n (cc >= 0x30 && cc <= 0x39) || // 0-9\n cc === 0x5f; // _\n if (!isIdentChar) break;\n p++;\n }\n this.col += p - this.pos;\n this.pos = p;\n }\n let ident = this.input.slice(identStart, this.pos);\n\n // Known keywords — checked first so they are never shadowed by app-strings.\n switch (ident) {\n case 'true':\n return this._tokV('TRUE', ident, line, col);\n case 'false':\n return this._tokV('FALSE', ident, line, col);\n case 'null':\n return this._tokV('NULL', ident, line, col);\n case 'undefined':\n return this._tokV('UNDEFINED', ident, line, col);\n case 'NaN':\n case 'NaN_0':\n case 'NaN_1':\n case 'NaN_2':\n case 'NaN_3':\n case 'NaN_4':\n case 'NaN_5':\n case 'NaN_6':\n case 'NaN_7':\n case 'NaN_i':\n case 'Infinity':\n case 'Infinity_0':\n case 'Infinity_1':\n case 'Infinity_2':\n case 'Infinity_3':\n case 'Infinity_4':\n case 'Infinity_5':\n case 'Infinity_6':\n case 'Infinity_7':\n case 'Infinity_i':\n return this._tokV('FLOAT', ident, line, col);\n case 'simple':\n return this._tokV('SIMPLE', ident, line, col);\n case '_':\n return this._tokV('UNDERSCORE', '_', line, col);\n // Encoding indicators used in array/map/string/bytes contexts\n case '_0':\n return this._tok('ENCODING_INDICATOR', '0', line, col);\n case '_1':\n return this._tok('ENCODING_INDICATOR', '1', line, col);\n case '_2':\n return this._tok('ENCODING_INDICATOR', '2', line, col);\n case '_3':\n return this._tok('ENCODING_INDICATOR', '3', line, col);\n case '_4':\n return this._tok('ENCODING_INDICATOR', '4', line, col);\n case '_5':\n return this._tok('ENCODING_INDICATOR', '5', line, col);\n case '_6':\n return this._tok('ENCODING_INDICATOR', '6', line, col);\n case '_7':\n // _7 = AI 31 = indefinite-length; kept as ENCODING_INDICATOR so that\n // bare `_` (UNDERSCORE) and explicit `_7` stay distinguishable.\n return this._tok('ENCODING_INDICATOR', '7', line, col);\n case '_i':\n return this._tok('ENCODING_INDICATOR', 'i', line, col);\n }\n\n // Byte-string prefixes or app-string extensions.\n // App-prefix grammar (§3 of draft-ietf-cbor-edn-literals-25):\n // app-prefix = lcalpha *lcldh / ucalpha *ucldh\n // lcldh = lcalpha / DIGIT / \"-\"\n // ucldh = ucalpha / DIGIT / \"-\"\n // Mixed-case or underscore-containing idents are not valid app-prefixes.\n const firstChar = ident[0] ?? '';\n const isLower = firstChar >= 'a' && firstChar <= 'z';\n const isUpper = firstChar >= 'A' && firstChar <= 'Z';\n\n if (isLower || isUpper) {\n // Validate chars already consumed by the main loop (no underscore, correct case).\n const restAlreadyRead = ident.slice(1);\n const restValid = isLower\n ? /^[a-z0-9]*$/.test(restAlreadyRead)\n : /^[A-Z0-9]*$/.test(restAlreadyRead);\n\n if (restValid) {\n // Extend the prefix with any remaining lcldh / ucldh chars.\n // The main loop stops at '-', so we need to consume hyphen-segments here.\n const extStart = this.pos;\n while (!this._eof()) {\n const ch = this._ch();\n const validCh = isLower\n ? (ch >= 'a' && ch <= 'z') || (ch >= '0' && ch <= '9') || ch === '-'\n : (ch >= 'A' && ch <= 'Z') ||\n (ch >= '0' && ch <= '9') ||\n ch === '-';\n if (!validCh) break;\n this.pos++;\n }\n if (this.pos > extStart) {\n this.col += this.pos - extStart;\n ident += this.input.slice(extStart, this.pos);\n }\n\n const q = this._ch();\n // Double quotes are not valid for app-string / byte-string prefixes.\n // app-string = app-prefix sqstr (sqstr uses single quotes only)\n if (q === '\"')\n this._fail(\n `\"${ident}\" prefix requires single quotes or backticks, not double quotes`,\n line,\n col\n );\n if (q === \"'\") {\n switch (ident) {\n case 'h': {\n const { value: hexVal, elided } =\n this._readHexByteContentElisionAware(q);\n return this._tok(\n elided ? 'BYTES_HEX_ELIDED' : 'BYTES_HEX',\n hexVal,\n line,\n col\n );\n }\n case 'b64':\n return this._tok(\n 'BYTES_B64',\n this._readByteContent(q),\n line,\n col\n );\n default:\n return this._tok(\n 'APP_STRING',\n this._readStringContent(q),\n line,\n col,\n ident\n );\n }\n }\n\n // app-rstring: prefix followed by backtick raw string (§2.5.3 / app-rstring)\n if (q === '`') {\n const raw = this._readRawStringContent();\n switch (ident) {\n case 'h': {\n // §5.3.3: lblank + / / block comments + # line comments + ellipsis\n const { value: hexVal, elided } = this._processRawHexContent(\n raw,\n line,\n col\n );\n return this._tok(\n elided ? 'BYTES_HEX_ELIDED' : 'BYTES_HEX',\n hexVal,\n line,\n col\n );\n }\n case 'b64':\n // §5.3.4: lblank + # line comments\n return this._tok(\n 'BYTES_B64',\n this._processRawB64Content(raw, line, col),\n line,\n col\n );\n default:\n return this._tok('APP_STRING', raw, line, col, ident);\n }\n }\n\n // App-sequence extension: prefix<<items...>>\n // The tokenizer consumes only prefix + \"<<\"; the parser reads items until \">>\".\n if (q === '<' && (this.input[this.pos + 1] ?? '') === '<') {\n this._advance();\n this._advance(); // <<\n return this._tok('APP_SEQUENCE', '', line, col, ident);\n }\n }\n }\n\n this._fail(`unknown identifier ${JSON.stringify(ident)}`, line, col);\n }\n}\n"],"mappings":";AAOA,IAAa,IAAb,cAAoC,YAAY;CAE9C;CAEA;CAEA;CAEA;CAEA,YACE,GACA,GAMA;EACA,IAAM,IACJ,GAAU,SAAS,KAAA,IAEf,KADA,YAAY,EAAS,KAAK,WAAW,EAAS;EAOpD,AALA,MAAM,kBAAkB,EAAI,IAAI,GAAS,GACzC,KAAK,OAAO,kBACZ,KAAK,SAAS,GAAU,QACxB,KAAK,OAAO,GAAU,MACtB,KAAK,SAAS,GAAU,QACxB,KAAK,YAAY,GAAU;CAC7B;AACF,GC1BM,IAAa,MAAM,KAAK,EAAE,QAAQ,IAAI,IAAI,GAAG,MACjD,EAAE,SAAS,EAAE,CAAC,CAAC,SAAS,GAAG,GAAG,CAChC,GAIM,qBAAa,IAAI,UAAU,GAAG,EAAA,CAAE,KAAK,EAAE;AAC7C,KAAK,IAAI,IAAI,GAAG,IAAI,IAAI,KAEtB,AADA,EAAW,mBAAmB,WAAW,CAAC,KAAK,GAC/C,EAAW,mBAAmB,WAAW,CAAC,KAAK;AAIjD,IAAM,IAEJ,OAAQ,WAAW,UAAkB,SAAU,YAE3C,IAEJ,OA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A,CACF;KACF;KACA,KAAK,OACH,OAAO,KAAK,KACV,aACA,KAAK,iBAAiB,CAAC,GACvB,GACA,CACF;KACF,SACE,OAAO,KAAK,KACV,cACA,KAAK,mBAAmB,CAAC,GACzB,GACA,GACA,CACF;IACJ;IAIF,IAAI,MAAM,KAAK;KACb,IAAM,IAAM,KAAK,sBAAsB;KACvC,QAAQ,GAAR;MACE,KAAK,KAAK;OAER,IAAM,EAAE,OAAO,GAAQ,cAAW,KAAK,sBACrC,GACA,GACA,CACF;OACA,OAAO,KAAK,KACV,IAAS,qBAAqB,aAC9B,GACA,GACA,CACF;MACF;MACA,KAAK,OAEH,OAAO,KAAK,KACV,aACA,KAAK,sBAAsB,GAAK,GAAM,CAAG,GACzC,GACA,CACF;MACF,SACE,OAAO,KAAK,KAAK,cAAc,GAAK,GAAM,GAAK,CAAK;KACxD;IACF;IAIA,IAAI,MAAM,QAAQ,KAAK,MAAM,KAAK,MAAM,MAAM,QAAQ,KAGpD,OAFA,KAAK,SAAS,GACd,KAAK,SAAS,GACP,KAAK,KAAK,gBAAgB,IAAI,GAAM,GAAK,CAAK;GAEzD;EACF;EAEA,KAAK,MAAM,sBAAsB,KAAK,UAAU,CAAK,KAAK,GAAM,CAAG;CACrE;AACF"}
package/dist/types.d.ts CHANGED
@@ -101,6 +101,19 @@ export interface ParseWarning {
101
101
  line?: number;
102
102
  /** Column number (1-based) where the violation was detected. */
103
103
  column?: number;
104
+ /**
105
+ * Character offset just past the end of the offending range, when the
106
+ * violation is attributable to a specific token. Lets tooling underline
107
+ * the exact range instead of a single position.
108
+ */
109
+ endOffset?: number;
110
+ /**
111
+ * `true` when the violation is a hard syntax error that stopped parsing
112
+ * (emitted by non-strict sequence parsing, which reports the failure as a
113
+ * warning and abandons the rest of the input). Tooling should present
114
+ * fatal warnings as errors.
115
+ */
116
+ fatal?: boolean;
104
117
  }
105
118
  export interface FromCBOROptions {
106
119
  /**
@@ -396,7 +409,9 @@ export interface ToCDNOptions {
396
409
  * This preserves the spelling and interior layout of non-concatenated
397
410
  * `h'...'`, `b64'...'`, `b32'...'`, `h32'...'`, raw-backtick byte strings,
398
411
  * and single-quoted byte strings, including comments inside those literals.
399
- * Byte strings produced by `+` concatenation are normalised as usual.
412
+ * Byte strings produced by `+` concatenation are normalised as usual;
413
+ * combine with `preserveConcatenation` to keep both the part boundaries
414
+ * and each part's spelling.
400
415
  *
401
416
  * When enabled, this takes precedence over `bstrEncoding` and `sqstr` for
402
417
  * byte strings that carry original EDN source text.
@@ -465,8 +480,58 @@ export interface ToCDNOptions {
465
480
  *
466
481
  * When both are specified, CDN structure split points are combined with
467
482
  * newline split points.
483
+ *
484
+ * @deprecated Use `splitCdn` / `splitNewline` instead. When one of those
485
+ * is specified, it takes precedence over the corresponding array entry.
468
486
  */
469
487
  textStringFormat?: TextStringFormat[];
488
+ /**
489
+ * Format text strings whose content is parseable as CDN (a JSON superset)
490
+ * by splitting them with CDN string concatenation (`"{" + "1:2" + "}"`)
491
+ * and structure-aware indentation, the same way the surrounding CDN is
492
+ * formatted. Only effective when `indent` is specified.
493
+ *
494
+ * When the string content parses as CDN, this takes precedence over
495
+ * `preserveConcatenation`; when it does not, the original concatenation
496
+ * is preserved as usual.
497
+ *
498
+ * Replaces the deprecated `textStringFormat: ['cdn']`.
499
+ *
500
+ * @default false
501
+ */
502
+ splitCdn?: boolean;
503
+ /**
504
+ * Split text strings at newline characters using CDN string concatenation
505
+ * (`"line1\n" + "line2"`). Only effective when `indent` is specified.
506
+ *
507
+ * Combines with `preserveConcatenation`: preserved concatenation parts
508
+ * are further split at the newline characters they contain.
509
+ *
510
+ * Replaces the deprecated `textStringFormat: ['newline']`.
511
+ *
512
+ * @default false
513
+ */
514
+ splitNewline?: boolean;
515
+ /**
516
+ * Preserve `+` string concatenation from the parsed CDN source.
517
+ *
518
+ * When a text string or byte string was parsed from a CDN concatenation
519
+ * chain (e.g. `"a" + "b"` or `h'01' + h'02'`), re-emit it as a
520
+ * concatenation with the original part boundaries instead of joining the
521
+ * parts into a single literal. Each part is re-serialized with the normal
522
+ * rules (`bstrEncoding` / `sqstr` for byte strings); combine with
523
+ * `preserveByteString` to also keep the original spelling of byte string
524
+ * parts.
525
+ *
526
+ * Interaction with the split options: `splitCdn` takes precedence for
527
+ * text strings whose content parses as CDN, while `splitNewline` combines
528
+ * with this option by further splitting the preserved parts at newline
529
+ * characters. Has no effect on values that did not originate from a CDN
530
+ * concatenation.
531
+ *
532
+ * @default false
533
+ */
534
+ preserveConcatenation?: boolean;
470
535
  /**
471
536
  * Control whether CBOR encoding-width indicators (`_N`) are appended to CDN output.
472
537
  *
@@ -10,6 +10,11 @@
10
10
  */
11
11
  /** Encode bytes as lowercase hex. */
12
12
  export declare function bytesToHex(bytes: Uint8Array): string;
13
+ /** Encode one byte as two uppercase hex digits (e.g. 10 → "0A"). */
14
+ export declare function byteToHexUpper(b: number): string;
15
+ /** Encode bytes as space-separated uppercase hex (e.g. "0A FF"), the
16
+ * per-line format used by `toHexDump()`. */
17
+ export declare function bytesToSpacedHexUpper(bytes: Uint8Array): string;
13
18
  /**
14
19
  * Decode a hex string to bytes.
15
20
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cbortech/cbor",
3
- "version": "0.25.9",
3
+ "version": "0.25.11",
4
4
  "description": "Convert between CBOR, CDN (CBOR-EDN), and JavaScript values",
5
5
  "keywords": [
6
6
  "cbor",
@@ -109,9 +109,9 @@
109
109
  "@vitest/ui": "^4.1.9",
110
110
  "cross-env": "^10.1.0",
111
111
  "playwright": "^1.61.1",
112
- "prettier": "^3.8.4",
112
+ "prettier": "^3.9.4",
113
113
  "typescript": "^5.9.3",
114
- "vite": "^8.1.0",
114
+ "vite": "^8.1.2",
115
115
  "vite-plugin-dts": "^4.5.4",
116
116
  "vitest": "^4.1.9"
117
117
  }
@@ -1,12 +0,0 @@
1
- const e=require("./tokenizer-CMK8MtYl.cjs");var t=Symbol.for(`cbor.tag`),n=class{valueOf(){return null}toJSON(){return null}},r=class{valueOf(){}toJSON(){}};function i(e){if(!c(e))return;let n=e[t];return typeof n==`bigint`?n:void 0}function a(e,i){let a;switch(typeof e){case`number`:a=new Number(e);break;case`string`:a=new String(e);break;case`boolean`:a=new Boolean(e);break;case`bigint`:a=Object(e);break;case`undefined`:a=new r;break;case`object`:if(e===null){a=new n;break}a=e;break;default:throw TypeError(`setCborTag: cannot tag value of type ${typeof e}`)}return a[t]=i,a}function o(e){if(e instanceof Number||e instanceof String||e instanceof Boolean||Object.prototype.toString.call(e)===`[object BigInt]`)return e.valueOf();if(e instanceof n)return null;if(!(e instanceof r))return typeof e==`object`&&e&&delete e[t],e}function s(e){if(e instanceof Number||e instanceof String||e instanceof Boolean||Object.prototype.toString.call(e)===`[object BigInt]`)return e.valueOf();if(e instanceof n)return null;if(!(e instanceof r))return e}function c(e){return typeof e==`object`&&!!e}var l=class{constructor(){}static symbol=t;static Null=n;static Undefined=r;static get(e){return i(e)}static set(e,t){return a(e,t)}static remove(e){return o(e)}static getValue(e){return s(e)}},u=Symbol(`cbor.omit`),d=class e{value;constructor(e){if(!Number.isInteger(e)||e<0||e>255)throw RangeError(`Simple value must be an integer in 0–255`);this.value=e}valueOf(){return this.value}toJSON(){throw TypeError(`simple(${this.value}) cannot be serialized to JSON`)}static is(t){return t instanceof e}static get(t){return t instanceof e?t.value:void 0}},f=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`)),p=new Int8Array(128).fill(-1);for(let e=0;e<16;e++)p[`0123456789abcdef`.charCodeAt(e)]=e,p[`0123456789ABCDEF`.charCodeAt(e)]=e;var m=typeof Uint8Array.prototype.toHex==`function`,h=typeof Uint8Array.fromHex==`function`,g=256;function ee(e){if(m)return e.toHex();let t=``;for(let n=0;n<e.length;n++)t+=f[e[n]];return t}function te(e){if(e.length%2!=0)throw SyntaxError(`hex string has odd length: ${e.length}`);if(h&&e.length>=g)return Uint8Array.fromHex(e);let t=new Uint8Array(e.length/2);for(let n=0,r=0;n<e.length;n+=2,r++){let i=e.charCodeAt(n),a=e.charCodeAt(n+1),o=i<128?p[i]:-1,s=a<128?p[a]:-1;if((o|s)<0){let t=o<0?e[n]:e[n+1];throw SyntaxError(`invalid character ${JSON.stringify(t)} in hex string`)}t[r]=o<<4|s}return t}function ne(e){let t=e?.indent;return t===void 0?null:typeof t==`number`?` `.repeat(t):t}function _(e,t){return e.repeat(t)}function re(e){return!!(e.comments?.leading?.length||e.comments?.trailing?.length||e.comments?.dangling?.length)}function ie(e){return!!(e.comments?.trailing?.length||e.comments?.dangling?.length)}function v(e,t){if(!t)return e.text;let{marker:n,text:r}=e;if(t===`c-style`)return n===`#`?`//`+r.slice(1):n===`/`?`/*`+r.slice(1,-1)+`*/`:r;if(n===`//`)return`#`+r.slice(2);if(n===`/*`){let e=r.slice(2,-2);return e.includes(`/`)?r:`/`+(e.startsWith(`*`)||e.startsWith(`/`)?` `+e:e)+`/`}return r}function ae(e,t,n){return(e.comments?.leading??[]).map(e=>t+v(e,n))}function oe(e,t){let n=e.comments?.trailing??[];return n.length===0?``:` `+n.map(e=>v(e,t)).join(` `)}function se(e,t,n){return(e.comments?.dangling??[]).map(e=>t+v(e,n))}function ce(e,t=!1){let n=e?.commas??`comma`,r=n!==`none`;return{inlineSep:r?t?`,`:`, `:` `,multilineSep:r?`,`:``,trailSep:n===`trailing`?`,`:``,colSep:t?`:`:`: `}}var le=typeof new Uint8Array().toBase64==`function`;function ue(e){if(le)return e.toBase64({omitPadding:!0});let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t).replace(/=/g,``)}function de(e){if(le)return e.toBase64({alphabet:`base64url`,omitPadding:!0});let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=/g,``)}var fe=`ABCDEFGHIJKLMNOPQRSTUVWXYZ234567`,pe=`0123456789ABCDEFGHIJKLMNOPQRSTUV`;function me(e,t){let n=``,r=0,i=0;for(let a of e)for(r=r<<8|a,i+=8;i>=5;)i-=5,n+=t[r>>i&31];return i>0&&(n+=t[r<<5-i&31]),n}function he(e){for(let t of e){let e=t.codePointAt(0);if(e<32||e===127)return!0}return!1}function ge(e,t,n){if(n===`string`){let t=ve(e);if(t!=null)return xe(t)}if(n===`printable-string`||n===void 0){let t=ve(e);if(t!=null&&!he(t))return xe(t)}switch(t){case`base64`:return`b64'${ue(e)}'`;case`base64url`:return`b64'${de(e)}'`;case`base32`:return`b32'${me(e,fe)}'`;case`base32hex`:return`h32'${me(e,pe)}'`;default:return`h'${ee(e)}'`}}var _e=new TextDecoder(`utf-8`,{fatal:!0});function ve(e){try{return _e.decode(e)}catch{return null}}function ye(e,t){for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);if(r===t||r===92||r<32||r===127||r>=8192&&(r===8232||r===8233||r>=8203&&r<=8205||r===65279))return!0}return!1}function be(e,t){let n=t.codePointAt(0);if(!ye(e,n))return t+e+t;let r=t;for(let i of e){let e=i.codePointAt(0);switch(e){case n:r+=`\\${t}`;break;case 92:r+=`\\\\`;break;case 10:r+=`\\n`;break;case 13:r+=`\\r`;break;case 9:r+=`\\t`;break;default:e<32||e===127||e===8232||e===8233||e===8203||e===8204||e===8205||e===65279?r+=`\\u${e.toString(16).padStart(4,`0`)}`:r+=i}}return r+t}function xe(e){return be(e,`'`)}function Se(e){return be(e,`'`)}function Ce(e){return be(e,`"`)}function we(e){if(isNaN(e))return`NaN`;if(!isFinite(e))return e>0?`Infinity`:`-Infinity`;if(Object.is(e,-0))return`-0.0`;let t=e.toString();return t.includes(`.`)||t.includes(`e`)?t:t+`.0`}function Te(e,t,n,r){if(r===`never`)return``;let i=t??n;return r===`always`?i===`half`?`_1`:i===`single`?`_2`:`_3`:t===void 0||t===n?``:t===`half`?`_1`:t===`single`?`_2`:`_3`}function y(e){return e<=23n?`i`:e<=255n?0:e<=65535n?1:e<=4294967295n?2:3}function b(e,t,n){let r=e?.encodingIndicators??`auto`;return r===`never`?``:r===`always`?`_${t??n()}`:t===void 0?``:`_${t}`}var Ee=`getFloat16`in DataView.prototype&&`setFloat16`in DataView.prototype,De=new DataView(new ArrayBuffer(8));function x(e){De.setFloat64(0,e,!1);let t=De.getUint32(0,!1),n=De.getUint32(4,!1),r=t>>>31&1,i=t>>>20&2047,a=t&1048575;if(i===2047){if(a===0&&n===0)return r<<15|31744;let e=a>>10|(n===0?0:1)||1;return r<<15|31744|e&1023}let o=i-1023+15;if(o>=31)return r<<15|31744;let s,c,l;if(o<=0){if(o<-10)return r<<15;let e=1<<20|a,t=11-o;t<=20?(s=e>>t&1023,c=e>>t-1&1,l=(e&(1<<t-1)-1)!=0||n!==0):(s=0,c=1,l=a!==0||n!==0)}else s=a>>10,c=a>>9&1,l=(a&511)!=0||n!==0;if(c!==0&&(l||s&1)&&s++,s>=1024){let e=o<=0?1:o+1;return e>=31?r<<15|31744:r<<15|e<<10}let u=o<=0?0:o;return r<<15|u<<10|s}function S(e){let t=e>>>15&1,n=e>>>10&31,r=e&1023;return n===31?r===0?t?-1/0:1/0:NaN:n===0?r===0?t?-0:0:(t?-1:1)*2**-14*(r/1024):(t?-1:1)*2**(n-15)*(1+r/1024)}var Oe=Ee?(e,t,n,r)=>{e.setFloat16(t,n,r)}:(e,t,n,r)=>{e.setUint16(t,x(n),r)},C=new DataView(new ArrayBuffer(8)),w=new Uint8Array(C.buffer),ke=class{buf;len=0;constructor(e=256){this.buf=new Uint8Array(e)}_ensure(e){let t=this.len+e;if(t<=this.buf.length)return;let n=this.buf.length*2;for(;n<t;)n*=2;let r=new Uint8Array(n);r.set(this.buf),this.buf=r}writeByte(e){this._ensure(1),this.buf[this.len++]=e}writeBytes(e){this._ensure(e.length),this.buf.set(e,this.len),this.len+=e.length}writeUint16(e){this._ensure(2);let t=this.buf;t[this.len++]=e>>>8&255,t[this.len++]=e&255}writeUint32(e){this._ensure(4);let t=this.buf;t[this.len++]=e>>>24&255,t[this.len++]=e>>>16&255,t[this.len++]=e>>>8&255,t[this.len++]=e&255}writeBigUint64(e){C.setBigUint64(0,e,!1),this._ensure(8),this.buf.set(w,this.len),this.len+=8}writeFloat16(e){Oe(C,0,e,!1),this._ensure(2);let t=this.buf;t[this.len++]=w[0],t[this.len++]=w[1]}writeFloat32(e){C.setFloat32(0,e,!1),this._ensure(4);let t=this.buf;t[this.len++]=w[0],t[this.len++]=w[1],t[this.len++]=w[2],t[this.len++]=w[3]}writeFloat64(e){C.setFloat64(0,e,!1),this._ensure(8),this.buf.set(w,this.len),this.len+=8}finish(){return this.buf.slice(0,this.len)}},Ae=[255n,65535n,4294967295n,18446744073709551615n];function je(e){return e===`i`?23n:Ae[e]}function T(e,t,n,r){if(r===void 0&&typeof n==`number`&&n<4294967296){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));return}let i=typeof n==`number`?BigInt(n):n;if(r!==void 0){if(r===`i`){if(i>23n)throw RangeError(`value ${i} does not fit in immediate encoding _i (max 23)`);e.writeByte(t<<5|Number(i));return}if(i>Ae[r])throw RangeError(`value ${i} does not fit in encodingWidth _${r} (max ${Ae[r]})`);let n=24+r;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);return}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))}function Me(e,t,n){let r=new ke(9);return T(r,e,t,n),r.finish()}var Ne=new DataView(new ArrayBuffer(4));function Pe(e){return Object.is(S(x(e)),e)}function Fe(e){return Ne.setFloat32(0,e,!1),Object.is(Ne.getFloat32(0,!1),e)}function E(e){return Pe(e)?`half`:Fe(e)?`single`:`double`}var D=class e{start;end;comments;warnings;_defaults;toCBOR(e){let t=this._defaults?{...this._defaults,...e}:e,n=new ke;return this._encode(n,t),n.finish()}toCDN(e){let t=this._defaults?{...this._defaults,...e}:e,n=this._toCDN(t,0),r=t?.preserveComments;if(!r)return n;let i=typeof r==`string`?r:void 0,a=this.comments?.leading?.map(e=>v(e,i))??[],o=this.comments?.trailing??[],s=o.length===0?n:`${n} ${o.map(e=>v(e,i).trimEnd()).join(` `)}`;return[...a,s].join(`
2
- `)}toEDN(e){return this.toCDN(e)}toJS(e){let t=this._defaults?{...this._defaults,...e}:e,n=this._toJS(t);if(!t?.reviver)return n;let r=t.reviver.call({"":n},``,n);return r===u?void 0:r}toHexDump(e){let t=this._defaults?{...this._defaults,...e}:e,n=t?.indent??3,r=typeof n==`string`?n:` `.repeat(n),i=(t?.commentStyle??`--`)+` `,a=this._toHexDump(0,t),o=Math.max(...a.map(e=>e.depth*r.length+e.hex.length))+2;return a.map(e=>(r.repeat(e.depth)+e.hex).padEnd(o)+i+e.comment).join(`
3
- `)}_encode(t,n){if(this._toCBOR!==e.prototype._toCBOR){t.writeBytes(this._toCBOR(n));return}this._encodeTo(t,n)}_encodeTo(t,n){if(this._toCBOR===e.prototype._toCBOR)throw TypeError(`CborItem subclass must implement _encodeTo() or _toCBOR()`);t.writeBytes(this._toCBOR(n))}_toCBOR(e){let t=new ke;return this._encodeTo(t,e),t.finish()}_toHexDump(e,t){return[{depth:e,hex:Array.from(this._toCBOR(),e=>e.toString(16).toUpperCase().padStart(2,`0`)).join(` `),comment:this._toCDN(t,0)}]}},O=class extends D{value;encodingWidth;constructor(e,t){if(super(),this.value=BigInt(e),this.value<0n)throw RangeError(`CborUint value must be non-negative`);if(this.value>18446744073709551615n)throw RangeError(`CborUint value exceeds maximum uint64`);this.encodingWidth=t?.encodingWidth}_encodeTo(e,t){T(e,0,this.value,this.encodingWidth)}_toCDN(e,t){let n=b(e,this.encodingWidth,()=>y(this.value)),r=this.value;switch(e?.intFormat){case`hex`:return`0x${r.toString(16)}${n}`;case`octal`:return`0o${r.toString(8)}${n}`;case`binary`:return`0b${r.toString(2)}${n}`;default:return r.toString()+n}}_toJS(e){let t=e?.integerAs??`auto`;return t===`bigint`?this.value:t===`number`||this.value<=BigInt(2**53-1)?Number(this.value):this.value}},k=class extends D{argument;encodingWidth;constructor(e,t){super();let n=BigInt(e);if(n>=0n)throw RangeError(`CborNint value must be negative`);if(n<-18446744073709551616n)throw RangeError(`CborNint value exceeds minimum int64`);this.argument=-1n-n,this.encodingWidth=t?.encodingWidth}get value(){return-1n-this.argument}_encodeTo(e,t){T(e,1,this.argument,this.encodingWidth)}_toCDN(e,t){let n=b(e,this.encodingWidth,()=>y(this.argument)),r=this.argument+1n;switch(e?.intFormat){case`hex`:return`-0x${r.toString(16)}${n}`;case`octal`:return`-0o${r.toString(8)}${n}`;case`binary`:return`-0b${r.toString(2)}${n}`;default:return this.value.toString()+n}}_toJS(e){let t=this.value,n=e?.integerAs??`auto`;return n===`bigint`?t:n===`number`||t>=BigInt(-(2**53-1))?Number(t):t}},Ie=new DataView(new ArrayBuffer(8));function Le(e){let t=e.startsWith(`-`),n=e.slice(t?3:2),r=n.search(/[pP]/);if(r===-1)throw SyntaxError(`EDN parse error: hex float missing 'p' exponent: ${e}`);let i=n.slice(0,r),a=n.slice(r+1);if(!/^[+-]?\d+$/.test(a))throw SyntaxError(`EDN parse error: hex float has invalid or missing exponent: ${e}`);let o=parseInt(a,10),s=i.indexOf(`.`),c;if(s===-1){if(!/^[0-9a-fA-F]+$/.test(i))throw SyntaxError(`EDN parse error: hex float has no mantissa digits: ${e}`);c=parseInt(i,16)}else{let t=i.slice(0,s),n=i.slice(s+1);if(t===``&&n===``)throw SyntaxError(`EDN parse error: hex float has no mantissa digits: ${e}`);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}`);c=(t===``?0:parseInt(t,16))+(n===``?0:parseInt(n,16)/16**n.length)}let l=c*2**o;return t?-l:l}function Re(e){if(isNaN(e))return`NaN`;if(!isFinite(e))return e>0?`Infinity`:`-Infinity`;let t=Object.is(e,-0)||e<0,n=Math.abs(e);if(n===0)return t?`-0x0p+0`:`0x0p+0`;Ie.setFloat64(0,n,!1);let r=Ie.getUint32(0,!1),i=Ie.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;a===0?(u=`0`,d=-1022):(u=`1`,d=a-1023);let f=d>=0?`+${d}`:`${d}`,p=`0x${u}${l}p${f}`;return t?`-${p}`:p}var A=class extends D{value;precision;ednSource;constructor(e,t){super(),this.value=e,this.precision=t?.precision}_encodeTo(e,t){let n=this.precision??E(this.value);n===`half`?(e.writeByte(249),e.writeFloat16(this.value)):n===`single`?(e.writeByte(250),e.writeFloat32(this.value)):(e.writeByte(251),e.writeFloat64(this.value))}_toCDN(e,t){let n=e?.encodingIndicators??`auto`;if(e?.appStrings!==!1&&this.ednSource!==void 0){if(n===`never`)return this.ednSource.replace(/_[0-3i]$/,``);if(n===`always`){if(/_[0-3i]$/.test(this.ednSource))return this.ednSource;let e=this.precision??E(this.value),t=e===`half`?`_1`:e===`single`?`_2`:`_3`;return this.ednSource+t}return this.ednSource}let r=E(this.value);return(e?.floatFormat===`hex`?Re(this.value):we(this.value))+Te(this.value,this.precision,r,n)}_toJS(e){return this.value}},j=class extends D{tag;content;encodingWidth;constructor(e,t,n){if(super(),this.tag=BigInt(e),this.tag<0n)throw RangeError(`CborTag tag number must be non-negative`);this.content=t,this.encodingWidth=n?.encodingWidth}_encodeTo(e,t){T(e,6,this.tag,this.encodingWidth),this.content._encode(e,t)}_toCDN(e,t){let n=b(e,this.encodingWidth,()=>y(this.tag));return`${this.tag}${n}(${this.content._toCDN(e,t)})`}_toHexDump(e,t){let n=[{depth:e,hex:(e=>Array.from(e,e=>e.toString(16).toUpperCase().padStart(2,`0`)).join(` `))(Me(6,this.tag,this.encodingWidth)),comment:`Tag ${this.tag}`}];return n.push(...this.content._toHexDump(e+1,{...t,appStrings:!1})),n}_toJS(e){let t=this.content._toJS(e);return e?.stripTags?t:l.set(t,this.tag)}},M=class extends D{indefiniteLength=!1;value;ednEncoding;encodingWidth;ednSource;constructor(e,t){super(),this.value=e,this.ednEncoding=t?.ednEncoding??`hex`,this.encodingWidth=t?.encodingWidth,this.ednSource=t?.ednSource}_encodeTo(e,t){T(e,2,this.value.length,this.encodingWidth),e.writeBytes(this.value)}_toCDN(e,t){if(e?.preserveByteString&&this.ednSource!==void 0){if(/_[0-3i]$/.test(this.ednSource))return(e?.encodingIndicators??`auto`)===`never`?this.ednSource.replace(/_[0-3i]$/,``):this.ednSource;let t=b(e,this.encodingWidth,()=>y(BigInt(this.value.length)));return this.ednSource+t}let n=b(e,this.encodingWidth,()=>y(BigInt(this.value.length))),r=e?.bstrEncoding??this.ednEncoding;return e?.appStrings===!1&&r!==`hex`&&(r=`hex`),ge(this.value,r,e?.sqstr)+n}_toJS(e){return this.value}},N=class extends D{indefiniteLength=!0;chunks;constructor(e){super(),this.chunks=e}_encodeTo(e,t){e.writeByte(95);for(let n of this.chunks)n._encode(e,t);e.writeByte(255)}_toCDN(e,t){if((e?.encodingIndicators??`auto`)===`never`){let t=this.chunks.reduce((e,t)=>e+t.value.length,0),n=new Uint8Array(t),r=0;for(let e of this.chunks)n.set(e.value,r),r+=e.value.length;return new M(n)._toCDN(e,0)}return this.chunks.length===0?`''_`:`(_ ${this.chunks.map(t=>t._toCDN(e,0)).join(`, `)})`}_toHexDump(e,t){let n=e=>e.toString(16).toUpperCase().padStart(2,`0`),r=[{depth:e,hex:n(95),comment:`Start indefinite-length byte string`}];for(let n of this.chunks)r.push(...n._toHexDump(e+1,t));return r.push({depth:e,hex:n(255),comment:`"break"`}),r}_toJS(e){let t=this.chunks.reduce((e,t)=>e+t.value.length,0),n=new Uint8Array(t),r=0;for(let e of this.chunks)n.set(e.value,r),r+=e.value.length;return n}},P=class extends D{indefiniteLength=!0;chunks;constructor(e){super(),this.chunks=e}_encodeTo(e,t){e.writeByte(127);for(let n of this.chunks)n._encode(e,t);e.writeByte(255)}_toCDN(e,t){return(e?.encodingIndicators??`auto`)===`never`?new z(this.chunks.map(e=>e.value).join(``))._toCDN(e,t):this.chunks.length===0?`""_`:`(_ ${this.chunks.map(t=>t._toCDN(e,0)).join(`, `)})`}_toHexDump(e,t){let n=e=>e.toString(16).toUpperCase().padStart(2,`0`),r=[{depth:e,hex:n(127),comment:`Start indefinite-length text string`}];for(let n of this.chunks)r.push(...n._toHexDump(e+1,t));return r.push({depth:e,hex:n(255),comment:`"break"`}),r}_toJS(e){return this.chunks.map(e=>e.value).join(``)}},F=class extends D{items;indefiniteLength;encodingWidth;constructor(e,t){super(),this.items=e,this.indefiniteLength=t?.indefiniteLength??!1,this.encodingWidth=t?.encodingWidth}_encodeTo(e,t){if(this.indefiniteLength){e.writeByte(159);for(let n of this.items)n._encode(e,t);e.writeByte(255);return}T(e,4,this.items.length,this.encodingWidth);for(let n of this.items)n._encode(e,t)}_toCDN(e,t){let n=ne(e),r=e?.preserveComments,i=typeof r==`string`?r:void 0,a=r&&(ie(this)||this.items.some(re));n===null&&a&&(n=` `);let{inlineSep:o,multilineSep:s,trailSep:c}=ce(e,n===null),l=this.indefiniteLength?``:b(e,this.encodingWidth,()=>y(BigInt(this.items.length))),u=l?l+` `:``,d=this.indefiniteLength&&(e?.encodingIndicators??`auto`)!==`never`;if(n===null||this.items.length===0&&!a){let n=this.items.map(n=>n._toCDN(e,t+1)).join(o);return this.indefiniteLength?d?this.items.length===0?`[_ ]`:`[_ ${n}]`:`[${n}]`:`[${u}${n}]`}let f=_(n,t+1),p=_(n,t),m=this.indefiniteLength?d?`[_ `:`[`:`[${u}`,h=[];for(let n=0;n<this.items.length;n++){let a=this.items[n];r&&h.push(...ae(a,f,i));let o=n<this.items.length-1?s:c;h.push(`${f}${a._toCDN(e,t+1)}${o}${r?oe(a,i):``}`)}return r&&h.push(...se(this,f,i)),`${m}\n${h.join(`
4
- `)}\n${p}]`}_toHexDump(e,t){let n=e=>e.toString(16).toUpperCase().padStart(2,`0`),r=e=>Array.from(e,e=>e.toString(16).toUpperCase().padStart(2,`0`)).join(` `);if(this.indefiniteLength){let r=[{depth:e,hex:n(159),comment:`Start indefinite-length array`}];for(let n of this.items)r.push(...n._toHexDump(e+1,t));return r.push({depth:e,hex:n(255),comment:`"break"`}),r}let i=[{depth:e,hex:r(Me(4,BigInt(this.items.length),this.encodingWidth)),comment:`Array of length ${this.items.length}`}];for(let n of this.items)i.push(...n._toHexDump(e+1,t));return i}_toJS(e){let t=e?.reviver;if(!t)return this.items.map(t=>t._toJS(e));let n=e?{...e,reviver:void 0}:void 0,r=this.items.map(e=>e._toJS(n)),i=0;for(let n=0;n<this.items.length;n++){let a=n-i,o=this.items[n]._toJS(e),s=t.call(r,String(n),o);s===u||e?.undefinedOmits&&s===void 0?(r.splice(a,1),i++):r[a]=s}return r}},I=class extends D{entries;indefiniteLength;encodingWidth;constructor(e,t){super(),this.entries=e,this.indefiniteLength=t?.indefiniteLength??!1,this.encodingWidth=t?.encodingWidth}_encodeTo(e,t){if(this.indefiniteLength){e.writeByte(191);for(let[n,r]of this.entries)n._encode(e,t),r._encode(e,t);e.writeByte(255);return}T(e,5,this.entries.length,this.encodingWidth);for(let[n,r]of this.entries)n._encode(e,t),r._encode(e,t)}_toCDN(e,t){let n=ne(e),r=e?.preserveComments,i=typeof r==`string`?r:void 0,a=r&&(ie(this)||this.entries.some(([e,t])=>re(e)||re(t)));n===null&&a&&(n=` `);let{inlineSep:o,multilineSep:s,trailSep:c,colSep:l}=ce(e,n===null),u=this.indefiniteLength?``:b(e,this.encodingWidth,()=>y(BigInt(this.entries.length))),d=u?u+` `:``,f=this.indefiniteLength&&(e?.encodingIndicators??`auto`)!==`never`,p=this.indefiniteLength?f?`{_ `:`{`:`{${d}`;if(n===null||this.entries.length===0&&!a){let n=this.entries.map(([n,r])=>`${n._toCDN(e,t+1)}${l}${r._toCDN(e,t+1)}`).join(o);return this.indefiniteLength?f?this.entries.length===0?`{_ }`:`{_ ${n}}`:`{${n}}`:`{${d}${n}}`}let m=_(n,t+1),h=_(n,t),g=[];for(let n=0;n<this.entries.length;n++){let[a,o]=this.entries[n];r&&g.push(...ae(a,m,i));let u=n<this.entries.length-1?s:c,d=r?ze([...a.comments?.trailing??[],...o.comments?.leading??[],...o.comments?.trailing??[]],i):``;g.push(`${m}${a._toCDN(e,t+1)}${l}${o._toCDN(e,t+1)}${u}${d}`)}return r&&g.push(...se(this,m,i)),`${p}\n${g.join(`
5
- `)}\n${h}}`}_toHexDump(e,t){let n=e=>e.toString(16).toUpperCase().padStart(2,`0`),r=e=>Array.from(e,e=>e.toString(16).toUpperCase().padStart(2,`0`)).join(` `);if(this.indefiniteLength){let r=[{depth:e,hex:n(191),comment:`Start indefinite-length map`}];for(let[n,i]of this.entries)r.push(...n._toHexDump(e+1,t)),r.push(...i._toHexDump(e+1,t));return r.push({depth:e,hex:n(255),comment:`"break"`}),r}let i=[{depth:e,hex:r(Me(5,BigInt(this.entries.length),this.encodingWidth)),comment:`Map of length ${this.entries.length}`}];for(let[n,r]of this.entries)i.push(...n._toHexDump(e+1,t)),i.push(...r._toHexDump(e+1,t));return i}_toJS(e){let t=e?.reviver,n=()=>{let n=$.from(this.entries,([t,n])=>[t._toJS(e),n._toJS(e)]);if(!t)return n;let r=e?.undefinedOmits;for(let e=0;e<n.length;e++){let[i,a]=n[e],o=t.call(n,i,a);o===u||r&&o===void 0?n.splice(e--,1):n[e]=[i,o]}return n};return e?.mapAs===`entries`?n():e?.mapAs===`object`||this.entries.every(([e])=>e instanceof z)?(()=>{let n=e?{...e,reviver:void 0}:void 0,r={};for(let[e,t]of this.entries){let i=e instanceof z?e.value:e.toCDN(),a=t._toJS(n);i===`__proto__`?Object.defineProperty(r,i,{value:a,writable:!0,enumerable:!0,configurable:!0}):r[i]=a}if(!t)return r;let i=new Map;for(let e=0;e<this.entries.length;e++){let[t]=this.entries[e];i.set(t instanceof z?t.value:t.toCDN(),e)}for(let n=0;n<this.entries.length;n++){let[a,o]=this.entries[n],s=a instanceof z?a.value:a.toCDN();if(i.get(s)!==n)continue;let c=o._toJS(e),l=t.call(r,s,c);l===u||e?.undefinedOmits&&l===void 0?delete r[s]:s===`__proto__`?Object.defineProperty(r,s,{value:l,writable:!0,enumerable:!0,configurable:!0}):r[s]=l}return r})():n()}};function ze(e,t){return e.length===0?``:` `+e.map(e=>v(e,t).trimEnd()).join(` `)}var L=class e extends D{value;constructor(e){if(super(),!Number.isInteger(e)||e<0||e>255)throw RangeError(`CborSimple value must be an integer in 0–255`);this.value=e}static FALSE=new e(20);static TRUE=new e(21);static NULL=new e(22);static UNDEFINED=new e(23);_encodeTo(e,t){if(this.value<=23){e.writeByte(224|this.value);return}e.writeByte(248),e.writeByte(this.value)}_toCDN(e,t){switch(this.value){case 20:return`false`;case 21:return`true`;case 22:return`null`;case 23:return`undefined`;default:return`simple(${this.value})`}}_toJS(e){switch(this.value){case 20:return!1;case 21:return!0;case 22:return null;case 23:return;default:return new d(this.value)}}},Be=class extends D{items;encodingWidth;constructor(e,t){super(),this.items=e,this.encodingWidth=t?.encodingWidth}_content(e){let t=new ke;for(let n of this.items)n._encode(t,e);return t.finish()}_encodeTo(e,t){let n=this._content(t);T(e,2,n.length,this.encodingWidth),e.writeBytes(n)}_toCDN(e,t){let n=b(e,this.encodingWidth,()=>y(BigInt(this._content(e).length)));if(this.items.length===0)return`<<>>${n}`;let r=ne(e),{inlineSep:i,multilineSep:a,trailSep:o}=ce(e,r===null);if(r===null)return`<<${this.items.map(n=>n._toCDN(e,t+1)).join(i)}>>${n}`;let s=_(r,t+1),c=_(r,t),l=this.items.map(n=>`${s}${n._toCDN(e,t+1)}`),u=l.length-1;return`<<\n${l.map((e,t)=>t<u?`${e}${a}`:`${e}${o}`).join(`
6
- `)}\n${c}>>${n}`}_toHexDump(e,t){let n=e=>Array.from(e,e=>e.toString(16).toUpperCase().padStart(2,`0`)).join(` `),r=this._content().length,i=[{depth:e,hex:n(Me(2,BigInt(r),this.encodingWidth)),comment:`Embedded CBOR sequence, ${r} byte${r===1?``:`s`}`}];for(let n of this.items)i.push(...n._toHexDump(e+1,t));return i}_toJS(e){return this._content()}},Ve=999n,He=class extends j{constructor(e,t){let n=t.length===1&&t[0]instanceof z?t[0]:new F(t);super(Ve,new F([new z(e),n]))}_toCDN(e,t){if(e?.appStrings===!1)return super._toCDN(e,t);let n=this.content,r=n.items[0].value,i=n.items[1];return i instanceof z?`${r}${Se(i.value)}`:`${r}<<${i.items.map(n=>n._toCDN(e,t)).join(`, `)}>>`}},Ue=class extends D{inner;ednSource;constructor(e,t){super(),this.inner=e,this.ednSource=t}_encodeTo(e,t){this.inner._encode(e,t)}_toCDN(e,t){let n=e?.encodingIndicators??`auto`;return e?.appStrings!==!1&&n===`auto`?this.ednSource:this.inner._toCDN(e,t)}_toJS(e){return this.inner._toJS(e)}},We=888n,R=class extends j{constructor(e){e===void 0?super(We,L.NULL):super(We,new F(e))}_toCDN(e,t){return this.content instanceof L?`...`:this.content instanceof F?this.content.items.map(n=>n._toCDN(e,t)).join(` + `):super._toCDN(e,t)}},Ge=2n,Ke=3n,qe=18446744073709551615n,Je=-18446744073709551616n;function Ye(e){if(e<0n)throw RangeError(`bigintToBytes requires a non-negative value`);if(e===0n)return new Uint8Array;let t=e.toString(16);t.length%2!=0&&(t=`0`+t);let n=new Uint8Array(t.length/2);for(let e=0;e<n.length;e++)n[e]=parseInt(t.slice(e*2,e*2+2),16);return n}function Xe(e){let t=0n;for(let n of e)t=t<<8n|BigInt(n);return t}var Ze=class extends j{bigValue;constructor(e){if(e<=qe)throw RangeError(`CborBigUint value ${e} fits in CborUint; use CborUint instead`);super(Ge,new M(Ye(e))),this.bigValue=e}_toCDN(e,t){return this.bigValue.toString()}_toJS(e){return this.bigValue}},Qe=class extends j{bigValue;constructor(e){if(e>=Je)throw RangeError(`CborBigNint value ${e} fits in CborNint; use CborNint instead`);super(Ke,new M(Ye(-1n-e))),this.bigValue=e}_toCDN(e,t){return this.bigValue.toString()}_toJS(e){return this.bigValue}},$e=new TextEncoder,et=new TextDecoder(`utf-8`,{fatal:!0}),tt=new TextDecoder(`utf-8`,{fatal:!1});function nt(t,n){let r=new e.t(t,{offset:n?.offset,skipRS:n?._skipRS}),i=new mt(r,n??{}).parse();return n?.preserveComments&&st(i,r.comments,t),i}function rt(e){let t=e,n;return/[_][0-7i]$/.test(e)&&(n=e[e.length-1],t=e.slice(0,-2)),{numStr:t,rawSuffix:n}}function it(e){return e.startsWith(`-`)?-BigInt(e.slice(1)):BigInt(e)}function at(e,t){if(e.endsWith(`_i`)||e.endsWith(`_0`)){let n=`_0 and _i encoding indicators are not valid for floating-point values`;if(t)t(n),e=e.slice(0,-2);else throw SyntaxError(`EDN parse error: ${n}`)}else if(/[_][4567]$/.test(e)){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`;if(t)t(r),e=e.slice(0,-2);else throw SyntaxError(`EDN parse error: ${r}`)}if(e===`NaN`)return{value:NaN,precision:void 0};if(e===`Infinity`)return{value:1/0,precision:void 0};if(e===`-Infinity`)return{value:-1/0,precision:void 0};let n=e,r;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)?{value:Le(n),precision:r}:{value:parseFloat(n),precision:r}}function ot(e,t){let n=e.indexOf(`=`),r=n>=0?e.slice(0,n):e,i=n>=0?e.slice(n):``;if(/[^A-Za-z0-9+/\-_]/.test(r)){let e=[...r].find(e=>!/[A-Za-z0-9+/\-_]/.test(e))??``;throw SyntaxError(`invalid character ${JSON.stringify(e)} in base64 data`)}if(i&&!/^=+$/.test(i))throw SyntaxError(`invalid character after base64 '=' padding`);let a=r.length%4;if(a===1)throw SyntaxError(`invalid base64 length: ${r.length} data characters (length mod 4 = 1 is never valid)`);let o=a===0?0:4-a;if(i.length>o){let e=`base64 has ${i.length} '=' character${i.length>1?`s`:``} but the data length (${r.length}) requires at most ${o}`;if(t)t(e);else throw SyntaxError(e)}if(i.length>0&&i.length<o){let e=`base64 has ${i.length} '=' character${i.length>1?`s`:``} but needs exactly ${o} — use full padding or no padding at all`;if(t)t(e);else throw SyntaxError(e)}if(a!==0&&r.length>0){let e=r[r.length-1].replace(`-`,`+`).replace(`_`,`/`),n=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`.indexOf(e);if(n>=0&&n&(a===2?15:3)){let e=`base64 has non-zero trailing bits in the final quantum (RFC 4648 §3.5)`;if(t)t(e);else throw SyntaxError(e)}}let s=r.replace(/-/g,`+`).replace(/_/g,`/`)+`=`.repeat(o);if(typeof Uint8Array.fromBase64==`function`)return Uint8Array.fromBase64(s,{alphabet:`base64`,lastChunkHandling:`loose`});let c=atob(s),l=new Uint8Array(c.length);for(let e=0;e<c.length;e++)l[e]=c.charCodeAt(e);return l}function st(e,t,n){if(t.length===0)return;let r=ct(e),i=ut(n);for(let a of t){let t={...a},o=[...r].filter(e=>e.end<=a.start).sort((e,t)=>t.end-e.end||t.start-e.start)[0],s=o?n.slice(o.end,a.start):``;if(o&&i(o.end)===a.line&&!s.includes(`:`)){lt(o.node,`trailing`,t);continue}let c=[...r].filter(e=>e.start<a.start&&a.end<e.end).sort((e,t)=>t.start-e.start||e.end-t.end)[0],l=[...r].filter(e=>e.start>=a.end).sort((e,t)=>e.start-t.start||t.end-e.end)[0];if((!c||l&&l.end<=c.end)&&l){lt(l.node,`leading`,t);continue}lt(c?.node??e,`dangling`,t)}}function ct(e){let t=[],n=e=>{if(e.start!==void 0&&e.end!==void 0&&t.push({node:e,start:e.start,end:e.end}),e instanceof F||e instanceof Be){for(let t of e.items)n(t);return}if(e instanceof I){for(let[t,r]of e.entries)n(t),n(r);return}if(e instanceof N||e instanceof P){for(let t of e.chunks)n(t);return}e instanceof j&&n(e.content)};return n(e),t}function lt(e,t,n){e.comments??={},e.comments[t]??=[],e.comments[t].push(n)}function ut(e){let t=[0];for(let n=0;n<e.length;n++)e[n]===`
7
- `&&t.push(n+1);return n=>{let r=Math.max(0,Math.min(e.length,n));r>0&&r===e.length&&r--;let i=0,a=t.length-1;for(;i<=a;){let e=i+a>>1;t[e]<=r?i=e+1:a=e-1}return a+1}}var dt=e=>`import { ${e} } from '@cbortech/cbor' and pass it via the 'extensions' option (extensions: [${e}])`,ft=(e,t)=>`install ${t}, import { ${e} } from '${t}', and pass it via the 'extensions' option (extensions: [${e}])`,pt=new Map([[`b32`,dt(`b32`)],[`h32`,dt(`h32`)],[`float`,dt(`float`)],[`same`,dt(`same`)],[`hash`,ft(`hash`,`@cbortech/hash-extension`)],[`uuid`,ft(`uuid`,`@cbortech/uuid-extension`)],[`UUID`,ft(`uuid`,`@cbortech/uuid-extension`)]]),mt=class{t;_options;extByPrefix;extByTag;unresolvedExtension;_pendingWarnings=[];_hintedPrefixes=new Set;constructor(t,n){this.t=t,this._options=n,this.extByPrefix=new Map,this.extByTag=new Map,this.unresolvedExtension=n.unresolvedExtension??`cpa999`;for(let e of[...Xn,...n.extensions??[]]){for(let t of e.appStringPrefixes??[])this.extByPrefix.set(t,e);for(let t of e.tagNumbers??[])this.extByTag.set(t,e)}this.t.onEscapeWarning=(t,n,r,i)=>{let a={message:t,offset:n,line:r,column:i};if(this._pendingWarnings.push(a),this._options.onWarning?this._options.onWarning(a):this._options.silent||console.warn(`CDN strict violation at line ${r}, column ${i}: ${t}`),this._options.strict!==!1)throw new e.n(t,{offset:n,line:r,column:i})}}parse(){let e=this.parseValue();if(this._options.allowTrailing)return e;let t=this.t.peek();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();return e}parseValue(){let e=this.t.peek().offset,t=this._parseValueNode();if(this.t.peek().type===`UNDERSCORE`){let e=this.t.consume();this._warnOrFail(`bare _ is not a valid encoding indicator; use _0, _1, _2, _3, or _i`,e)}if(this._pendingWarnings.length>0){t.warnings??=[];for(let e of this._pendingWarnings)t.warnings.push(e);this._pendingWarnings=[]}return t.start=e,t.end=this.t.lastEndOffset,t}_parseValueNode(){let e=this.t.peek();switch(e.type){case`INTEGER`:return this.parseIntegerOrTag();case`FLOAT`:return this.parseFloat();case`TSTR`:case`RAWSTRING`:return this.parseString();case`BYTES_HEX`:case`SQSTR`:case`BYTES_B64`:return this.t.consume(),this._parseBytesConcat(this._decodeBytesToken(e),e.type,e.raw);case`EMPTY_INDEF_BYTES`:return this.t.consume(),new N([]);case`EMPTY_INDEF_TEXT`:return this.t.consume(),new P([]);case`TRUE`:return this.t.consume(),new L(21);case`FALSE`:return this.t.consume(),new L(20);case`NULL`:return this.t.consume(),new L(22);case`UNDEFINED`:return this.t.consume(),new L(23);case`SIMPLE`:return this.parseSimple();case`LBRACKET`:return this.parseArray();case`LBRACE`:return this.parseMap();case`LPAREN`:return this.parseIndefGroup();case`LT_LT`:return this.parseEmbeddedCBOR();case`APP_STRING`:{this.t.consume();let t,n=``;if(this.t.peek().type===`ENCODING_INDICATOR`){let e=this.t.consume();t=this._resolveEncodingWidth(e.value,e),n=e.raw}let r=this.extByPrefix.get(e.appPrefix);if(!r?.parseAppString){if(r||this._hintMissingExtension(e.appPrefix,e),this.unresolvedExtension===`cpa999`)return new He(e.appPrefix,[new z(e.value)]);this._fail(`unknown app-string extension: ${JSON.stringify(e.appPrefix)}`,e)}{let i=this._pendingWarnings.length;try{let i=r.parseAppString(e.appPrefix,e.value,this._extOnError(e),t===void 0?void 0:{encodingWidth:t});return t!==void 0&&this._applyEiToResult(i,t,e),i instanceof M&&Object.getPrototypeOf(i)===M.prototype&&i.ednSource===void 0?new M(i.value,{ednEncoding:i.ednEncoding,encodingWidth:i.encodingWidth,ednSource:e.raw+n}):(i instanceof A&&i.ednSource===void 0&&(i.ednSource=e.raw+n),i)}catch(t){if(this._options.strict!==!1)throw t;return this._pendingWarnings.length===i&&this._warn(t instanceof Error?t.message:String(t),e),new He(e.appPrefix,[new z(e.value)])}}}case`APP_SEQUENCE`:{this.t.consume();let t=[];for(;this.t.peek().type!==`GT_GT`;){if(this.t.peek().type===`EOF`&&this._fail(`unterminated ${e.appPrefix}<<...>>`,e),t.length>0)if(this.t.peek().type===`COMMA`){if(this.t.consume(),this.t.peek().type===`GT_GT`)break}else this.t.peek().offset===this.t.lastEndOffset&&this._warnOrFail(`<<...>> items must be separated by "," or whitespace`,this.t.peek());t.push(this.parseValue())}this.expect(`GT_GT`);let n,r;this.t.peek().type===`ENCODING_INDICATOR`&&(r=this.t.consume(),n=this._resolveEncodingWidth(r.value,r));let i=this.extByPrefix.get(e.appPrefix);if(!i){if(this._hintMissingExtension(e.appPrefix,e),this.unresolvedExtension===`cpa999`)return new He(e.appPrefix,t);this._fail(`unknown app-string extension: ${JSON.stringify(e.appPrefix)}`,e)}i.parseAppSequence||this._fail(`app-string extension ${JSON.stringify(e.appPrefix)} does not support <<...>> form`,e);{let a=this._pendingWarnings.length;try{let a=i.parseAppSequence(e.appPrefix,t,this._extOnError(e));n!==void 0&&this._applyEiToResult(a,n,r??e);let o=this.t.source.slice(e.offset,this.t.lastEndOffset);if(a instanceof A)a.ednSource===void 0&&(a.ednSource=o);else if(i.preserveAppSeqSource)return new Ue(a,o);return a}catch(n){if(this._options.strict!==!1)throw n;return this._pendingWarnings.length===a&&this._warn(n instanceof Error?n.message:String(n),e),new He(e.appPrefix,t)}}}case`ELLIPSIS`:{if(this.t.consume(),this.t.peek().type!==`PLUS`)return new R;let e=[new R];for(;this.t.peek().type===`PLUS`;)this.t.consume(),e.push(this.parseValue());return new R(e)}case`BYTES_HEX_ELIDED`:return this.t.consume(),this._parseHexElidedConcat(e);default:this._fail(`unexpected token: ${JSON.stringify(e.value)}`,e)}}parseIntegerOrTag(){let e=this.t.consume(),{numStr:t,rawSuffix:n}=rt(e.value),r=n===void 0?this.consumeEncodingIndicator():this._resolveEncodingWidth(n,e),i=it(t);if(i>18446744073709551615n)return this.t.peek().type===`LPAREN`&&this._fail(`tag number exceeds maximum uint64`,e),new Ze(i);if(i<-18446744073709551616n)return new Qe(i);if(r!==void 0){let t=i>=0n?i:-(i+1n);r=this._validateEncodingFit(t,r,e)}let a=i>=0n?new O(i,r===void 0?void 0:{encodingWidth:r}):new k(i,r===void 0?void 0:{encodingWidth:r});if(this.t.peek().type===`LPAREN`){a instanceof O||this._fail(`tag number must be non-negative`,e),this.t.consume();let t=this._pendingWarnings.splice(0),n=this.parseValue();this.expect(`RPAREN`);let i=a.value,o=this.extByTag.get(i);if(o?.parseTag){let e=o.parseTag(i,n);if(e!==void 0)return e instanceof j&&r!==void 0&&e.encodingWidth===void 0&&(e.encodingWidth=r),t.length>0&&(e.warnings??=[],e.warnings.push(...t)),e}let s=new j(i,n,r===void 0?void 0:{encodingWidth:r});return t.length>0&&(s.warnings??=[],s.warnings.push(...t)),s}return a}parseFloat(){let e=this.t.consume(),t=t=>this._warnOrFail(t,e),{value:n,precision:r}=at(e.value,t);if(r===`half`||r===`single`){let e=r===`half`?S(x(n)):Math.fround(n);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`)}return new A(n,r===void 0?void 0:{precision:r})}parseString(){let e=this.t.consume();if(this.t.peek().type!==`PLUS`){let t=this.consumeEncodingIndicator(()=>BigInt($e.encode(e.value).length));return new z(e.value,t===void 0?void 0:{encodingWidth:t})}let t=!1,n=[{text:e.value}];for(;this.t.peek().type===`PLUS`;){this.t.consume();let e=this.t.peek();e.type===`ELLIPSIS`?(this.t.consume(),n.push({ellipsis:!0}),t=!0):e.type===`TSTR`||e.type===`RAWSTRING`?(this.t.consume(),n.push({text:e.value})):this._isBytesToken(e.type)?(this.t.consume(),n.push({text:this._decodeUtf8(this._decodeBytesToken(e),e)})):this._fail(`expected string or byte string after +, got ${JSON.stringify(e.value)}`,e)}if(!t){let e=n.map(e=>`text`in e?e.text:``).join(``),t=this.consumeEncodingIndicator(()=>BigInt($e.encode(e).length));return new z(e,t===void 0?void 0:{encodingWidth:t})}let r=[],i=``;for(let e of n)`ellipsis`in e?(i!==``&&(r.push(new z(i)),i=``),r.push(new R)):i+=e.text;return i!==``&&r.push(new z(i)),new R(r)}_isBytesToken(e){return e===`BYTES_HEX`||e===`SQSTR`||e===`BYTES_B64`}_decodeBytesToken(t){let n=e=>this._warnOrFail(e,t);switch(t.type){case`BYTES_HEX`:case`SQSTR`:return te(t.value);case`BYTES_B64`:try{return ot(t.value,n)}catch(n){if(n instanceof e.n||!(n instanceof SyntaxError))throw n;this._fail(n.message,t)}default:this._fail(`expected byte string token`,t)}}_decodeUtf8(e,t){if(this._options.allowInvalidUtf8)return tt.decode(e);try{return et.decode(e)}catch{return this._warnOrFail(`byte string in text concatenation is not valid UTF-8`,t),tt.decode(e)}}_tokenTypeToCdnEncoding(e){return e===`BYTES_B64`?`base64`:`hex`}_parseBytesConcat(e,t,n){if(this.t.peek().type!==`PLUS`){let r=this.consumeEncodingIndicator(()=>BigInt(e.length));return new M(e,{ednEncoding:this._tokenTypeToCdnEncoding(t),ednSource:n,...r===void 0?{}:{encodingWidth:r}})}let r=!1,i=[{bytes:e}];for(;this.t.peek().type===`PLUS`;){this.t.consume();let e=this.t.peek();if(e.type===`ELLIPSIS`)this.t.consume(),i.push({ellipsis:!0}),r=!0;else if(e.type===`BYTES_HEX_ELIDED`){this.t.consume();let t=this._buildBytesElidedItems(e.value);for(let e of t)e instanceof R?(i.push({ellipsis:!0}),r=!0):e instanceof M&&i.push({bytes:e.value})}else this._isBytesToken(e.type)?(this.t.consume(),i.push({bytes:this._decodeBytesToken(e)})):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),i.push({bytes:$e.encode(e.value)})):this._fail(`expected byte string after +, got ${JSON.stringify(e.value)}`,e)}if(!r){let e=i.map(e=>`bytes`in e?e.bytes:new Uint8Array),t=this._concatBytes(e),n=this.consumeEncodingIndicator(()=>BigInt(t.length));return new M(t,n===void 0?void 0:{encodingWidth:n})}let a=[],o=[],s=()=>{o.length>0&&(a.push(new M(this._concatBytes([...o]))),o.length=0)};for(let e of i)`ellipsis`in e?(s(),a.push(new R)):o.push(e.bytes);return s(),new R(a)}_parseHexElidedConcat(e){let t=this._buildBytesElidedItems(e.value);for(;this.t.peek().type===`PLUS`;){this.t.consume();let e=this.t.peek();if(e.type===`ELLIPSIS`)this.t.consume(),t.push(new R);else if(e.type===`BYTES_HEX_ELIDED`){this.t.consume();let n=this._buildBytesElidedItems(e.value);this._mergeFirstBytesItem(t,n)}else if(this._isBytesToken(e.type)){this.t.consume();let n=this._decodeBytesToken(e),r=t[t.length-1];r instanceof M?t[t.length-1]=new M(this._concatBytes([r.value,n])):t.push(new M(n))}else this._fail(`expected byte string after +, got ${JSON.stringify(e.value)}`,e)}return new R(t)}_buildBytesElidedItems(e){let t=e.split(`...`),n=[];for(let e=0;e<t.length;e++)e>0&&n.push(new R),t[e].length>0&&n.push(new M(te(t[e])));return n}_mergeFirstBytesItem(e,t){if(t.length===0)return;let n=e[e.length-1],r=t[0];n instanceof M&&r instanceof M?(e[e.length-1]=new M(this._concatBytes([n.value,r.value])),e.push(...t.slice(1))):e.push(...t)}_concatBytes(e){let t=e.reduce((e,t)=>e+t.byteLength,0),n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.byteLength;return n}parseSimple(){this.t.consume(),this.expect(`LPAREN`);let e=this.t.peek();e.type!==`INTEGER`&&this._fail(`expected integer inside simple(), got ${JSON.stringify(e.value)}`,e),this.t.consume();let{numStr:t}=rt(e.value),n=Number(it(t));return this.expect(`RPAREN`),new L(n)}parseEmbeddedCBOR(){this.t.consume();let e=[];for(;this.t.peek().type!==`GT_GT`;){if(e.length>0)if(this.t.peek().type===`COMMA`){if(this.t.consume(),this.t.peek().type===`GT_GT`)break}else this.t.peek().offset===this.t.lastEndOffset&&this._warnOrFail(`<<...>> items must be separated by "," or whitespace`,this.t.peek());e.push(this.parseValue())}this.expect(`GT_GT`);let t;if(this.t.peek().type===`ENCODING_INDICATOR`){let e=this.t.consume();t=this._resolveEncodingWidth(e.value,e)}return new Be(e,{encodingWidth:t})}parseArray(){this.t.consume();let e=!1,t,n;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));let r=this._pendingWarnings.splice(0),i=[];for(;this.t.peek().type!==`RBRACKET`;){if(i.length>0)if(this.t.peek().type===`COMMA`){if(this.t.consume(),this.t.peek().type===`RBRACKET`)break}else this.t.peek().offset===this.t.lastEndOffset&&this._warnOrFail(`array items must be separated by "," or whitespace`,this.t.peek());i.push(this.parseValue())}this.expect(`RBRACKET`),t!==void 0&&n!==void 0&&(t=this._validateEncodingFit(BigInt(i.length),t,n));let a=new F(i,{indefiniteLength:e,encodingWidth:t});return r.length>0&&(a.warnings??=[],a.warnings.push(...r)),a}parseMap(){this.t.consume();let e=!1,t,n;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));let r=this._pendingWarnings.splice(0),i=[];for(;this.t.peek().type!==`RBRACE`;){if(i.length>0)if(this.t.peek().type===`COMMA`){if(this.t.consume(),this.t.peek().type===`RBRACE`)break}else this.t.peek().offset===this.t.lastEndOffset&&this._warnOrFail(`map entries must be separated by "," or whitespace`,this.t.peek());let e=this.parseValue();this.expect(`COLON`);let t=this.parseValue();i.push([e,t])}this.expect(`RBRACE`),t!==void 0&&n!==void 0&&(t=this._validateEncodingFit(BigInt(i.length),t,n));let a=new I(i,{indefiniteLength:e,encodingWidth:t});return r.length>0&&(a.warnings??=[],a.warnings.push(...r)),a}parseIndefGroup(){this.t.consume();let e=this.t.peek();if(e.type===`UNDERSCORE`)this.t.consume();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);else if(e.type===`ENCODING_INDICATOR`){let e=this.t.consume(),t=`encoding indicator _${e.value} is not valid in an indefinite string group; use _`;this._warnOrFail(t,e)}else e.type!==`RPAREN`&&this._warnOrFail(`indefinite string group is missing _ after (; interpreting as (_ ...)`,e);let t=this._pendingWarnings.splice(0),n=[];for(;this.t.peek().type!==`RPAREN`;){if(n.length>0)if(this.t.peek().type===`COMMA`){if(this.t.consume(),this.t.peek().type===`RPAREN`)break}else this.t.peek().offset===this.t.lastEndOffset&&this._warnOrFail(`indefinite string chunks must be separated by "," or whitespace`,this.t.peek());n.push(this.parseValue())}this.expect(`RPAREN`),n.length===0&&this._fail(`empty indefinite group (_ ) is ambiguous; use ''_ for bytes or ""_ for text`);let r=n[0];if(r instanceof M){let e=new N(n.map((e,t)=>{if(e instanceof M)return e;this._fail(`indefinite byte string chunk ${t} must be a byte string, not a text string`)}));return t.length>0&&(e.warnings=t),e}if(r instanceof z){let e=new P(n.map((e,t)=>{if(e instanceof z)return e;this._fail(`indefinite text string chunk ${t} must be a text string, not a byte string`)}));return t.length>0&&(e.warnings=t),e}this._fail(`indefinite group chunks must be byte strings or text strings`)}consumeEncodingIndicator(e){if(this.t.peek().type===`ENCODING_INDICATOR`){let t=this.t.consume(),n=this._resolveEncodingWidth(t.value,t);return n!==void 0&&e!==void 0&&(n=this._validateEncodingFit(e(),n,t)),n}}expect(e){let t=this.t.consume();return t.type!==e&&this._fail(`expected ${e}, got ${t.type} (${JSON.stringify(t.value)})`,t),t}_applyEiToResult(e,t,n){if(e instanceof A){let r=t===1?`half`:t===2?`single`:t===3?`double`:void 0;if(r===void 0)this._warnOrFail(`encoding indicator _${t} is not valid for a float; use _1, _2, or _3`,n);else if(e.precision!==r){if(r!==`double`){let t=r===`half`?S(x(e.value)):Math.fround(e.value);!Object.is(t,e.value)&&!isNaN(e.value)&&this._warnOrFail(`${e.value} cannot be exactly represented as ${r===`half`?`float16 (_1)`:`float32 (_2)`}`,n)}e.precision=r}}else if(e instanceof O){if(e.encodingWidth===void 0){let r=this._validateEncodingFit(e.value,t,n);r!==void 0&&(e.encodingWidth=r)}}else if(e instanceof k){if(e.encodingWidth===void 0){let r=this._validateEncodingFit(e.argument,t,n);r!==void 0&&(e.encodingWidth=r)}}else if(e instanceof M){if(e.encodingWidth===void 0){let r=this._validateEncodingFit(BigInt(e.value.length),t,n);r!==void 0&&(e.encodingWidth=r)}}else if(e instanceof z){if(e.encodingWidth===void 0){let r=this._validateEncodingFit(BigInt($e.encode(e.value).length),t,n);r!==void 0&&(e.encodingWidth=r)}}else if(e instanceof F){if(e.encodingWidth===void 0){let r=this._validateEncodingFit(BigInt(e.items.length),t,n);r!==void 0&&(e.encodingWidth=r)}}else if(e instanceof I){if(e.encodingWidth===void 0){let r=this._validateEncodingFit(BigInt(e.entries.length),t,n);r!==void 0&&(e.encodingWidth=r)}}else if(e instanceof j){if(e.encodingWidth===void 0){let r=this._validateEncodingFit(e.tag,t,n);r!==void 0&&(e.encodingWidth=r)}}else this._warnOrFail(`encoding indicator _${t} is not applicable to this app-string result type`,n)}_validateEncodingFit(e,t,n){let r=je(t);if(e<=r)return t;let i=`value ${e} does not fit in encoding indicator ${t===`i`?`_i (max 23)`:`_${t} (max ${r})`}`;this._warnOrFail(i,n)}_resolveEncodingWidth(e,t){if(e===`4`||e===`5`||e===`6`){let n=`encoding indicator _${e} (AI ${Number(e)+24}) is reserved and not valid`;this._warnOrFail(n,t);return}if(e===`7`){this._warnOrFail(`indefinite-length encoding (_7) is not valid here; use [_ ...] or {_ ...} for indefinite collections`,t);return}return e===`i`?`i`:Number(e)}_extOnError(e){return t=>this._warnOrFail(t,e)}_warnOrFail(e,t){this._warn(e,t),this._options.strict!==!1&&this._fail(e,t)}_hintMissingExtension(e,t){let n=pt.get(e);if(n===void 0||this._hintedPrefixes.has(e))return;this._hintedPrefixes.add(e);let r=`app-string prefix '${e}' requires an extension that is not enabled; ${n}`;this._options.onWarning?this._options.onWarning({message:r,offset:t.offset,line:t.line,column:t.col}):this._options.silent||console.warn(`CDN: ${r}`)}_warn(e,t){let n={message:e};if(t!==void 0&&(n.offset=t.offset,n.line=t.line,n.column=t.col),this._pendingWarnings.push(n),this._options.onWarning)this._options.onWarning(n);else if(!this._options.silent){let n=t?` at line ${t.line}, column ${t.col}`:``;console.warn(`CDN strict violation${n}: ${e}`)}}_fail(t,n){throw new e.n(t,n?{offset:n.offset,line:n.line,column:n.col,endOffset:n.endOffset}:void 0)}},ht=new TextEncoder,gt=!1,z=class extends D{indefiniteLength=!1;value;encodingWidth;constructor(e,t){super(),this.value=e,this.encodingWidth=t?.encodingWidth}_encodeTo(e,t){let n=ht.encode(this.value);T(e,3,n.length,this.encodingWidth),e.writeBytes(n)}_toCDN(e,t){let n=b(e,this.encodingWidth,()=>y(BigInt(ht.encode(this.value).length)));return _t(this.value,n,e,t)}_toJS(e){return this.value}};function _t(e,t,n,r){let i=vt(n?.textStringFormat??[]),a=ne(n);if(i.length===0||a===null)return Ce(e)+t;let o=new Map,s=null;if(i.includes(`cdn`)&&(s=bt(e),s!==null))for(let{point:e,contentDepth:t}of s)o.set(e,t);if(i.includes(`newline`)){let t=s===null?yt(e,0):xt(e);for(let{point:e,contentDepth:n}of t)o.has(e)||o.set(e,n)}let c=Ot(e,o);if(c.length<=1)return Ce(e)+t;let l=c.map(({text:e},n)=>{let r=Ce(e);return n===c.length-1?r+t:r}),u=l[0];for(let e=1;e<l.length;e++){let t=_(a,r+1+c[e].contentDepth);u+=` +\n${t}${l[e]}`}return u}function vt(e){return e.map(e=>e===`cboredn`?(gt||(gt=!0,console.warn("`textStringFormat: ['cboredn']` is deprecated; use `textStringFormat: ['cdn']` instead.")),`cdn`):e)}function yt(e,t){let n=[];for(let r=0;r<e.length;r++){let i=e[r];i===`\r`?e[r+1]===`
8
- `?(n.push({point:r+2,contentDepth:t}),r++):n.push({point:r+1,contentDepth:t}):i===`
9
- `&&n.push({point:r+1,contentDepth:t})}return n}function bt(t){try{nt(t)}catch{return null}let n=[],r=new e.t(t),i=0,a=null,o=!1,s=0;for(;;){let e=r.consume();if(e.type===`EOF`)break;let c=!1;if(o||(o=!0,e.offset>0&&Et(r.comments,0,e.offset)&&n.push({point:e.offset,contentDepth:i})),a!==null){if(a.kind===`opener`&&Ct.has(e.type)){a.point=e.endOffset,s=e.endOffset;continue}else a.kind===`opener`&&Tt.has(e.type)&&Dt(t,a.point,e.offset)?c=!0:n.push({point:e.offset,contentDepth:a.contentDepth});a=null}wt.has(e.type)?(i++,a={point:e.endOffset,contentDepth:i,kind:`opener`}):Tt.has(e.type)?(i=Math.max(0,i-1),c||n.push({point:e.offset,contentDepth:i})):e.type===`COMMA`&&(a={point:e.endOffset,contentDepth:i,kind:`comma`}),s=e.endOffset}let c=r.comments.find(e=>e.start>=s);return c!==void 0&&n.push({point:c.start,contentDepth:i}),n}function xt(t){let n=[],r=new e.t(t),i=0;for(;;){let e=r.consume();if(e.type===`EOF`)break;if(wt.has(e.type))i++;else if(Tt.has(e.type))i=Math.max(0,i-1);else if(e.type!==`COMMA`){if(e.type===`TSTR`){let r=t.slice(e.offset,e.endOffset);for(let t of St(r))n.push({point:e.offset+t,contentDepth:i+1})}else if(e.type===`RAWSTRING`){let r=t.slice(e.offset,e.endOffset);for(let{point:t}of yt(r,0))n.push({point:e.offset+t,contentDepth:i+1})}}}return n}function St(e){let t=[],n=1,r=e.length-1;for(;n<r;){let r=e[n];if(r===`\\`){let r=e[n+1];if(r===`n`||r===`r`)t.push(n+2),n+=2;else if(r===`u`)if(e[n+2]===`{`){let t=e.indexOf(`}`,n+3);n=t>=0?t+1:n+2}else n+=6;else n+=2}else r===`\r`?e[n+1]===`
10
- `?(t.push(n+2),n+=2):(t.push(n+1),n++):(r===`
11
- `&&t.push(n+1),n++)}return t}var Ct=new Set([`ENCODING_INDICATOR`,`UNDERSCORE`]),wt=new Set([`LBRACKET`,`LBRACE`,`LPAREN`,`LT_LT`]),Tt=new Set([`RBRACKET`,`RBRACE`,`RPAREN`,`GT_GT`]);function Et(e,t,n){return e.some(e=>e.start>=t&&e.end<=n)}function Dt(e,t,n){return/^[\t\n\r ]*$/.test(e.slice(t,n))}function Ot(e,t){let n=[...t].filter(([t])=>t>0&&t<e.length).sort(([e],[t])=>e-t);if(n.length===0)return[{text:e,contentDepth:0}];let r=[],i=0,a=0;for(let[t,o]of n)t!==i&&(r.push({text:e.slice(i,t),contentDepth:a}),i=t,a=o);return i<e.length&&r.push({text:e.slice(i),contentDepth:a}),r}function B(e){if(Number.isInteger(e))return new Date(e*1e3).toISOString().replace(/\.000Z$/,`Z`);let t=Math.round(e*1e3);if(t/1e3===e)return new Date(t).toISOString().replace(/\.000Z$/,`Z`);let n=Math.floor(e),r=e-n,i=new Date(n*1e3).toISOString().replace(/\.\d+Z$/,``),a=r.toString(),o=a.indexOf(`.`),s=o>=0?a.slice(o+1):`0`;for(;s.length<3;)s+=`0`;return`${i}.${s}Z`}var kt=new TextDecoder(`utf-8`,{fatal:!0});function At(e){if(e.length!==1)throw SyntaxError(`dt<<...>>: expected exactly one item`);let t=e[0];if(t instanceof z)return t.value;if(t instanceof M)return kt.decode(t.value);throw SyntaxError(`dt<<...>>: expected a text string or byte string`)}var jt=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})$/i;function Mt(e,t){if(!jt.test(e)){let n=`dt: invalid RFC 3339 date-time: ${JSON.stringify(e)}`;if(t)t(n);else throw SyntaxError(n)}let n=e.match(/^(.+T\d{2}:\d{2}:\d{2})(\.\d+)(Z|[+-]\d{2}:\d{2})$/i),r,i;n?(r=n[1]+n[3],i=parseFloat(`0`+n[2])):(r=e,i=void 0);let a=Date.parse(r);if(isNaN(a))throw SyntaxError(`dt: invalid RFC 3339 date-time: ${JSON.stringify(e)}`);if(i===void 0){let e=a/1e3;return e>=0?new Pt(BigInt(e)):new Ft(BigInt(e))}return new It(a/1e3+i)}var Nt=1n,Pt=class extends O{constructor(e,t){super(e,t)}_toCDN(e,t){if(e?.appStrings===!1)return super._toCDN(e,t);let n=b(e,this.encodingWidth,()=>y(this.value));return`dt'${B(Number(this.value))}'${n}`}},Ft=class extends k{constructor(e,t){super(e,t)}_toCDN(e,t){if(e?.appStrings===!1)return super._toCDN(e,t);let n=b(e,this.encodingWidth,()=>y(this.argument));return`dt'${B(Number(this.value))}'${n}`}},It=class extends A{constructor(e,t){super(e,t)}_toCDN(e,t){if(e?.appStrings===!1)return super._toCDN(e,t);let n=E(this.value),r=Te(this.value,this.precision,n,e?.encodingIndicators??`auto`);return`dt'${B(this.value)}'${r}`}},Lt=class extends j{constructor(e,t){super(Nt,typeof e==`string`?Mt(e):e,t)}_toCDN(e,t){if(e?.appStrings===!1)return super._toCDN(e,t);let n=this.content;if(n instanceof A?n.precision!==void 0&&n.precision!==E(n.value):n.encodingWidth!==void 0)return super._toCDN({...e,appStrings:!1},t);let r=n instanceof A?n.value:Number(n.value),i=b(e,this.encodingWidth,()=>y(Nt));return`DT'${B(r)}'${i}`}},Rt=class extends Lt{constructor(e,t){super(e,t)}_toJS(e){let t=this.content,n=t instanceof A?t.value*1e3:Number(t.value)*1e3;return new Date(n)}};function zt(e){let t=e?.jsDate??!1;function n(e){return t?new Rt(e):new Lt(e)}let r={appStringPrefixes:[`dt`,`DT`],tagNumbers:[Nt],parseAppString(e,t,r){return e===`DT`?n(t):Mt(t,r)},parseAppSequence(e,t,r){let i=At(t);return e===`DT`?n(i):Mt(i,r)},parseTag(e,n){if(e!==1n)return;let r;if(n instanceof O)r=new Pt(n.value,{encodingWidth:n.encodingWidth});else if(n instanceof k)r=new Ft(n.value,{encodingWidth:n.encodingWidth});else if(n instanceof A)r=new It(n.value),n.precision!==void 0&&(r.precision=n.precision);else return;return r.start=n.start,r.end=n.end,t?new Rt(r):new Lt(r)}};return t&&(r.fromJS=(e,t)=>{if(e instanceof Date)return new Rt(B(e.getTime()/1e3))},r.isJSType=e=>e instanceof Date),r}var Bt=zt(),Vt=zt({jsDate:!0});function Ht(e){let t=e.split(`.`);if(t.length!==4)throw SyntaxError(`ip: invalid IPv4 address: ${JSON.stringify(e)}`);let n=new Uint8Array(4);for(let e=0;e<4;e++){let r=t[e];if(!/^\d+$/.test(r)||r.length>1&&r[0]===`0`)throw SyntaxError(`ip: invalid IPv4 octet: ${JSON.stringify(r)}`);let i=parseInt(r,10);if(i>255)throw SyntaxError(`ip: IPv4 octet out of range: ${i}`);n[e]=i}return n}function Ut(e){let t=new Uint8Array(16);if(e===`::`)return t;let n=e,r=null,i=e.match(/^(.*):(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/);i&&(n=i[1],n.endsWith(`:`)&&(n+=`:`),r=Ht(i[2]));let a=n.split(`::`);if(a.length>2)throw SyntaxError(`ip: invalid IPv6 address: ${JSON.stringify(e)}`);let o=a.length===2,s=a[0]?a[0].split(`:`):[],c=o&&a[1]?a[1].split(`:`):[],l=r?6:8;if(!o&&s.length!==l||o&&s.length+c.length>=l)throw SyntaxError(`ip: invalid IPv6 address: ${JSON.stringify(e)}`);let u=l-s.length-c.length,d=[...s,...Array(u).fill(`0`),...c],f=0;for(let e of d){if(!/^[0-9a-fA-F]{1,4}$/.test(e))throw SyntaxError(`ip: invalid IPv6 group: ${JSON.stringify(e)}`);let n=parseInt(e,16);t[f++]=n>>8&255,t[f++]=n&255}return r&&t.set(r,12),t}function Wt(e){return Array.from(e).join(`.`)}function Gt(e){let t=e.slice(0,10).every(e=>e===0)&&e[10]===255&&e[11]===255?Wt(e.slice(12)):null,n=t?6:8,r=[];for(let t=0;t<n*2;t+=2)r.push(e[t]<<8|e[t+1]);let i=-1,a=0,o=0;for(;o<n;)if(r[o]===0){let e=o+1;for(;e<n&&r[e]===0;)e++;e-o>a&&(i=o,a=e-o),o=e}else o++;a<2&&(i=-1);let s=e=>e.toString(16),c;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}var Kt=`ip`,V=`IP`,H=52n,qt=54n,Jt=new TextDecoder(`utf-8`,{fatal:!0});function Yt(e){if(e.length!==1)throw SyntaxError(`ip<<...>>: expected exactly one item`);let t=e[0];if(t instanceof z)return t.value;if(t instanceof M)return Jt.decode(t.value);throw SyntaxError(`ip<<...>>: expected a text string or byte string`)}function Xt(e){return/^\d/.test(e)&&e.includes(`.`)&&!e.includes(`:`)?{bytes:Ht(e),isV4:!0}:{bytes:Ut(e),isV4:!1}}function Zt(e){if(e.length===4)return Wt(e);if(e.length===16)return Gt(e);throw SyntaxError(`ip: unexpected byte length: ${e.length}`)}function Qt(e,t){let n=new Uint8Array(e.length);n.set(e);let r=Math.floor(t/8),i=t%8;i>0&&r<e.length&&(n[r]&=255<<8-i&255);for(let t=r+ +(i>0);t<e.length;t++)n[t]=0;let a=Math.ceil(t/8);for(;a>0&&n[a-1]===0;)a--;return n.slice(0,a)}function $t(e,t){let n=new Uint8Array(t);return n.set(e),n}var en=class extends M{_toCDN(e,t){if(e?.appStrings===!1)return super._toCDN(e,t);let n=b(e,this.encodingWidth,()=>y(BigInt(this.value.length)));return`${Kt}'${Zt(this.value)}'${n}`}},tn=class extends F{_isV4;constructor(e,t,n){super([new O(BigInt(e)),new M(t)]),this._isV4=n}_toCDN(e,t){if(e?.appStrings===!1)return super._toCDN(e,t);let n=Number(this.items[0].value),r=this.items[1].value;return`${Kt}'${Zt($t(r,this._isV4?4:16))}/${n}'`}},nn=class extends j{constructor(e,t){super(e,t)}_toCDN(e,t){if(e?.appStrings===!1)return super._toCDN(e,t);let n=this.tag===H?4:16,r=this.content;if(r instanceof M){if(r.encodingWidth!==void 0)return super._toCDN(e,t);let n=b(e,this.encodingWidth,()=>y(this.tag));return`${V}'${Zt(r.value)}'${n}`}if(r instanceof F&&r.items.length===2&&r.items[0]instanceof O&&r.items[1]instanceof M){if(r.encodingWidth!==void 0||r.items[0].encodingWidth!==void 0||r.items[1].encodingWidth!==void 0)return super._toCDN(e,t);let i=Number(r.items[0].value),a=$t(r.items[1].value,n),o=b(e,this.encodingWidth,()=>y(this.tag));return`${V}'${Zt(a)}/${i}'${o}`}return super._toCDN(e,t)}};function rn(e,t){let n=t.indexOf(`/`);if(n===-1){let{bytes:n,isV4:r}=Xt(t);return e===V?new nn(r?H:qt,new M(n)):new en(n)}let r=t.slice(0,n),i=t.slice(n+1);if(!/^\d+$/.test(i))throw SyntaxError(`ip: invalid prefix length: ${JSON.stringify(i)}`);let a=parseInt(i,10),{bytes:o,isV4:s}=Xt(r),c=s?32:128;if(a>c)throw SyntaxError(`ip: prefix length ${a} exceeds maximum ${c} for ${s?`IPv4`:`IPv6`}`);let l=Qt(o,a);return e===V?new nn(s?H:qt,new F([new O(BigInt(a)),new M(l)])):new tn(a,l,s)}var an={appStringPrefixes:[Kt,V],tagNumbers:[H,qt],parseAppString(e,t){return rn(e,t)},parseAppSequence(e,t){return rn(e,Yt(t))},parseTag(e,t){if(!(e!==H&&e!==qt)&&(t instanceof M||t instanceof F))return new nn(e,t)}},on=18446744073709551615n,sn=-18446744073709551616n,cn={tagNumbers:[Ge,Ke],parseTag(e,t){if(t instanceof M){if(e===2n){let e=Xe(t.value);return e>on?new Ze(e):void 0}if(e===3n){let e=-1n-Xe(t.value);return e<sn?new Qe(e):void 0}}}},ln=`cri`,un=`CRI`,dn=99n,fn=new Map([[`coap`,-1n],[`coaps`,-2n],[`http`,-3n],[`https`,-4n],[`urn`,-5n],[`did`,-6n],[`coap+tcp`,-7n],[`coaps+tcp`,-8n],[`coap+ws`,-25n],[`coaps+ws`,-26n]]),pn=new Map([...fn.entries()].map(([e,t])=>[t,e]));function U(e){try{return decodeURIComponent(e)}catch{return e}}var mn=new TextEncoder,hn=new TextDecoder(`utf-8`,{fatal:!0});function gn(e){return Array.from(mn.encode(e),e=>`%${e.toString(16).toUpperCase().padStart(2,`0`)}`).join(``)}function W(e,t){let n=``;for(let r of e)n+=t(r)?r:gn(r);return n}function _n(e){return/[A-Za-z0-9\-._~]/.test(e)}function vn(e){return/[!$&'()*+,;=]/.test(e)}function yn(e){return _n(e)||vn(e)||e===`:`||e===`@`}function bn(e){return(yn(e)||e===`/`||e===`?`)&&e!==`&`}function xn(e){return yn(e)||e===`/`||e===`?`}function Sn(e){return _n(e)||vn(e)||e===`:`}function Cn(e){return _n(e)||vn(e)}function wn(e){let t=[],n=e,r=n.indexOf(`@`);r>=0&&(t.push(L.FALSE),t.push(new z(U(n.slice(0,r)))),n=n.slice(r+1));let i,a=null;if(n.startsWith(`[`)){let e=n.indexOf(`]`);if(e<0)throw SyntaxError(`cri: unterminated IPv6 bracket in authority`);i=n.slice(1,e);let r=n.slice(e+1);if(r.startsWith(`:`))a=r.slice(1);else if(r.length>0)throw SyntaxError(`cri: unexpected characters after ']' in authority`);t.push(new M(Ut(i)))}else{let e=n.lastIndexOf(`:`);if(e>=0?(i=n.slice(0,e),a=n.slice(e+1)):i=n,i!==``)if(/^\d{1,3}(\.\d{1,3}){3}$/.test(i))t.push(new M(Ht(i)));else for(let e of i.toLowerCase().split(`.`))t.push(new z(e))}if(a!==null&&a!==``){if(!/^\d+$/.test(a))throw SyntaxError(`cri: invalid port: ${JSON.stringify(a)}`);let e=parseInt(a,10);if(e>65535)throw SyntaxError(`cri: port ${e} out of range`);t.push(new O(BigInt(e)))}return new F(t)}function Tn(e){let t=e.items,n=0,r=``;if(n<t.length&&t[n]instanceof L&&t[n].value===20){n++;let e=t[n++];r+=W(e.value,Sn)+`@`}if(n>=t.length)return r;let i=t[n];if(i instanceof M){n++;let{length:e}=i.value;if(e===4)r+=Wt(i.value);else if(e===16)r+=`[`+Gt(i.value)+`]`;else throw Error(`cri: unexpected host-ip byte length: ${e}`);n<t.length&&t[n]instanceof z&&(r+=`%25${W(t[n++].value,Cn)}`)}else{let e=[];for(;n<t.length&&t[n]instanceof z;)e.push(W(t[n++].value,Cn));r+=e.join(`.`)}return n<t.length&&t[n]instanceof O&&(r+=`:`+t[n].value.toString()),r}function En(e){let t=e.slice(2),n=t.indexOf(`/`),r,i;return n>=0?(r=t.slice(0,n),i=t.slice(n+1).split(`/`).map(e=>new z(U(e)))):(r=t,i=[]),{authority:wn(r),pathSegments:i}}function Dn(e){let t=e,n=null,r=t.indexOf(`#`);r>=0&&(n=U(t.slice(r+1)),t=t.slice(0,r));let i=null,a=t.indexOf(`?`);if(a>=0){let e=t.slice(a+1);t=t.slice(0,a),i=e.split(`&`).map(e=>new z(U(e)))}let o=[],s=/^([a-zA-Z][a-zA-Z0-9+.\-]*):([\s\S]*)$/.exec(t);if(s){let e=s[1].toLowerCase(),t=s[2],n=fn.get(e);if(o.push(n===void 0?new z(e):new k(n)),t.startsWith(`//`)){let{authority:e,pathSegments:n}=En(t);o.push(e,new F(n))}else if(t.startsWith(`/`)){let e=t.slice(1).split(`/`).map(e=>new z(U(e)));o.push(L.NULL,new F(e))}else{let e=t.split(`/`).map(e=>new z(U(e)));o.push(L.TRUE,new F(e))}}else if(t.startsWith(`//`)){let{authority:e,pathSegments:n}=En(t);o.push(L.FALSE,e,new F(n))}else if(t.startsWith(`/`)){let e=t.slice(1).split(`/`).map(e=>new z(U(e)));o.push(L.TRUE,new F(e))}else if(t===``)o.push(new O(0n));else{let n=1n,r=t,i=!1;for(r.startsWith(`./`)&&(i=!0,r=r.slice(2));r.startsWith(`../`);)n++,r=r.slice(3);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)}`);let a=r===``?[]:r.split(`/`).map(e=>new z(U(e)));o.push(new O(n),new F(a))}if(i!==null&&o.push(new F(i)),n!==null&&(i===null&&o.push(L.NULL),o.push(new z(n))),n!==null&&i===null&&o.splice(o.length-2,1),i===null&&n===null){let e=o[o.length-1];e instanceof F&&e.items.length===0&&o.pop()}return o.length===1&&o[0]instanceof O&&o[0].value===0n?[]:o}function G(e,t){let n=t,r=``;if(n<e.length){let t=e[n];if(t instanceof F){if(n++,t.items.length>0){let e=t.items.map(e=>{if(!(e instanceof z))throw Error(`cri: query item must be a text string`);return W(e.value,bn)});r+=`?`+e.join(`&`)}}else t instanceof L&&t.value===22&&n++}return n<e.length&&e[n]instanceof z&&(r+=`#`+W(e[n].value,xn)),r}function On(e){return e.items.map(e=>{if(!(e instanceof z))throw Error(`cri: path segment must be a text string`);return W(e.value,yn)})}function kn(e){if(e.length===0)return``;let t=0,n=e[t++];if(n instanceof k||n instanceof z){let r;if(n instanceof k){let e=pn.get(n.value);if(e===void 0)throw Error(`cri: unrecognised scheme-id ${n.value}`);r=e+`:`}else r=n.value+`:`;if(t>=e.length)return r;let i=e[t++],a=``,o=!1;if(i instanceof F)a=`//`+Tn(i),o=!0;else if(i instanceof L)if(i.value===22)o=!0;else if(i.value===21)o=!1;else throw Error(`cri: unexpected no-authority value: simple(${i.value})`);else throw Error(`cri: unexpected type for authority element`);let s=``;if(t<e.length&&e[t]instanceof F){let n=e[t++];n.items.length>0&&(s=(o?`/`:``)+On(n).join(`/`))}return r+a+s+G(e,t)}if(n instanceof L&&n.value===20){if(t>=e.length||!(e[t]instanceof F))throw Error(`cri: network-path reference requires an authority array`);let n=Tn(e[t++]),r=``;if(t<e.length&&e[t]instanceof F){let n=e[t++];n.items.length>0&&(r=`/`+On(n).join(`/`))}return`//`+n+r+G(e,t)}if(n instanceof L&&n.value===21){let n=`/`;if(t<e.length&&e[t]instanceof F){let r=e[t++];n=`/`+On(r).join(`/`)}return n+G(e,t)}if(n instanceof O){let r=n.value;if(r===0n)return G(e,t);let i=r===1n?``:`../`.repeat(Number(r)-1),a;if(t<e.length&&e[t]instanceof F){let n=e[t++];if(n.items.length>0){let e=On(n);a=(r===1n&&e[0].includes(`:`)?`./`:i)+e.join(`/`)}else a=i===``?`./`:i}else a=i===``?`./`:i;return a+G(e,t)}throw Error(`cri: unrecognised first element type in CRI array`)}var An=class extends F{_toCDN(e,t){if(e?.appStrings===!1)return super._toCDN(e,t);try{let t=b(e,this.encodingWidth,()=>y(BigInt(this.items.length)));return`${ln}'${kn(this.items)}'${t}`}catch{return super._toCDN(e,t)}}},jn=class extends j{constructor(e){super(dn,e)}_toCDN(e,t){if(e?.appStrings===!1)return super._toCDN(e,t);try{let n=this.content;if(n.encodingWidth!==void 0)return super._toCDN(e,t);let r=b(e,this.encodingWidth,()=>y(dn));return`${un}'${kn(n.items)}'${r}`}catch{return super._toCDN(e,t)}}};function Mn(e){if(e.length!==1)throw SyntaxError(`cri<<...>>: expected exactly one item`);let t=e[0];if(t instanceof z)return t.value;if(t instanceof M)return hn.decode(t.value);throw SyntaxError(`cri<<...>>: expected a text string or byte string`)}function Nn(e,t){let n=new An(Dn(t));return e===un?new jn(n):n}var Pn={appStringPrefixes:[ln,un],tagNumbers:[dn],parseAppString(e,t){return Nn(e,t)},parseAppSequence(e,t){return Nn(e,Mn(t))},parseTag(e,t){if(e!==99n||!(t instanceof F))return;let n=new An(t.items,{indefiniteLength:t.indefiniteLength,encodingWidth:t.encodingWidth});return n.start=t.start,n.end=t.end,new jn(n)}};function K(e,t){if(e===24&&t<=23n)return 0;if(e===25&&t<=255n)return 1;if(e===26&&t<=65535n)return 2;if(e===27&&t<=4294967295n)return 3}var Fn=new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0}),In=new TextDecoder(`utf-8`,{fatal:!1,ignoreBOM:!0});function q(e){throw Error(`CBOR decode error: ${e}`)}function Ln(e,t,n){let r={message:e,offset:t};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}`);return r}function J(e,t){e.warnings??=[],e.warnings.push(t)}function Rn(e){let t=``;for(let n of e)t+=n.toString(16).padStart(2,`0`);return t}function Y(e){if(e instanceof O)return[`u`,String(e.value)];if(e instanceof k)return[`n`,String(e.value)];if(e instanceof z)return[`t`,e.value];if(e instanceof P)return[`t`,e.chunks.map(e=>e.value).join(``)];if(e instanceof M)return[`b`,Rn(e.value)];if(e instanceof N){let t=``;for(let n of e.chunks)t+=Rn(n.value);return[`b`,t]}if(e instanceof A)return isNaN(e.value)?[`f`,`NaN`]:Object.is(e.value,-0)?[`f`,`-0`]:[`f`,String(e.value)];if(e instanceof L)return[`s`,e.value];if(e instanceof F)return[`A`,e.items.map(Y)];if(e instanceof I){let t=e.entries.map(([e,t])=>[Y(e),Y(t)]);if(t.length<=1)return[`M`,t];let n=t.map(e=>[JSON.stringify(e[0]),e]);return n.sort((e,t)=>e[0]<t[0]?-1:+(e[0]>t[0])),[`M`,n.map(e=>e[1])]}if(e instanceof j)return[`G`,String(e.tag),Y(e.content)];let t=e.toCBOR(),n=``;for(let e of t)n+=e.toString(16).padStart(2,`0`);return[`c`,n]}function zn(e){if(e instanceof O)return`u`+e.value;if(e instanceof k)return`n`+e.value;if(e instanceof z)return`t`+e.value;if(e instanceof P){let t=`t`;for(let n of e.chunks)t+=n.value;return t}if(e instanceof M)return`b`+Rn(e.value);if(e instanceof N){let t=`b`;for(let n of e.chunks)t+=Rn(n.value);return t}return e instanceof A?isNaN(e.value)?`fNaN`:Object.is(e.value,-0)?`f-0`:`f`+e.value:e instanceof L?`s`+e.value:JSON.stringify(Y(e))}var Bn=Array.from({length:24},(e,t)=>BigInt(t)),Vn;function Hn(){return Vn??=Xn.filter(e=>e.parseTag!==void 0)}function Un(e,t){for(let n=0;n<t;n++)if(e[n]>=128)return;return String.fromCharCode.apply(null,e)}function X(e,t,n){if(n<=23)return{value:Bn[n],nextOffset:t};switch(n){case 24:return t+1>e.byteLength&&q(`unexpected end of input`),{value:BigInt(e.getUint8(t)),nextOffset:t+1};case 25:return t+2>e.byteLength&&q(`unexpected end of input`),{value:BigInt(e.getUint16(t,!1)),nextOffset:t+2};case 26:return t+4>e.byteLength&&q(`unexpected end of input`),{value:BigInt(e.getUint32(t,!1)),nextOffset:t+4};case 27:return t+8>e.byteLength&&q(`unexpected end of input`),{value:e.getBigUint64(t,!1),nextOffset:t+8};default:q(`reserved additional info value: ${n}`)}}function Wn(e,t,n,r,i,a){let o=[],s=t;for(;;){if(s>=e.byteLength&&q(`unexpected end of indefinite ${i}`),e.getUint8(s)===255){s++;break}let t=Z(e,s,n,r);a(t.value)||q(`indefinite-length ${i} chunk must be a definite ${i}`),o.push(t.value),s=t.nextOffset}return{chunks:o,nextOffset:s}}function Gn(e,t,n,r){let i=zn(e);t.has(i)&&n.push(Ln(`duplicate map key at offset ${e.start}`,e.start,r)),t.add(i)}function Z(e,t,n,r){let i=t,a=Kn(e,t,n,r);return a.value.start=i,a.value.end=a.nextOffset,a}function Kn(e,t,n,r){t>=e.byteLength&&q(`unexpected end of input`);let i=e.getUint8(t++),a=i>>5,o=i&31;switch(a){case 0:{let{value:n,nextOffset:r}=X(e,t,o);return{value:new O(n,{encodingWidth:K(o,n)}),nextOffset:r}}case 1:{let{value:n,nextOffset:r}=X(e,t,o),i=K(o,n);return{value:new k(-1n-n,{encodingWidth:i}),nextOffset:r}}case 2:{if(o===31){let{chunks:i,nextOffset:a}=Wn(e,t,n,r,`byte string`,e=>e instanceof M);return{value:new N(i),nextOffset:a}}let{value:i,nextOffset:a}=X(e,t,o),s=Number(i),c=K(o,i);return a+s>e.byteLength&&q(`byte string extends beyond input`),{value:new M(new Uint8Array(e.buffer,e.byteOffset+a,s).slice(),{encodingWidth:c}),nextOffset:a+s}}case 3:{if(o===31){let{chunks:i,nextOffset:a}=Wn(e,t,n,r,`text string`,e=>e instanceof z);return{value:new P(i),nextOffset:a}}let{value:i,nextOffset:a}=X(e,t,o),s=Number(i),c=K(o,i);a+s>e.byteLength&&q(`text string extends beyond input`);let l=new Uint8Array(e.buffer,e.byteOffset+a,s),u,d,f=s<64?Un(l,s):void 0;if(f!==void 0)u=f;else try{u=Fn.decode(l)}catch{d=Ln(`invalid UTF-8 sequence in text string`,a,n),u=In.decode(l)}let p=new z(u,{encodingWidth:c});return d&&J(p,d),{value:p,nextOffset:a+s}}case 4:{if(o===31){let i=[],a=t;for(;;){if(a>=e.byteLength&&q(`unexpected end of indefinite array`),e.getUint8(a)===255){a++;break}let t=Z(e,a,n,r);i.push(t.value),a=t.nextOffset}return{value:new F(i,{indefiniteLength:!0}),nextOffset:a}}let{value:i,nextOffset:a}=X(e,t,o),s=Number(i),c=K(o,i),l=[],u=a;for(let t=0;t<s;t++){let t=Z(e,u,n,r);l.push(t.value),u=t.nextOffset}return{value:new F(l,{encodingWidth:c}),nextOffset:u}}case 5:{if(o===31){let i=[],a=new Set,o=[],s=t;for(;;){if(s>=e.byteLength&&q(`unexpected end of indefinite map`),e.getUint8(s)===255){s++;break}let t=Z(e,s,n,r);Gn(t.value,a,o,n),s=t.nextOffset;let c=Z(e,s,n,r);s=c.nextOffset,i.push([t.value,c.value])}let c=new I(i,{indefiniteLength:!0});for(let e of o)J(c,e);return{value:c,nextOffset:s}}let{value:i,nextOffset:a}=X(e,t,o),s=Number(i),c=K(o,i),l=[],u=new Set,d=[],f=a;for(let t=0;t<s;t++){let t=Z(e,f,n,r);Gn(t.value,u,d,n),f=t.nextOffset;let i=Z(e,f,n,r);f=i.nextOffset,l.push([t.value,i.value])}let p=new I(l,{encodingWidth:c});for(let e of d)J(p,e);return{value:p,nextOffset:f}}case 6:{o===31&&q(`tags cannot use indefinite-length encoding`);let{value:i,nextOffset:a}=X(e,t,o),s=K(o,i),c=Z(e,a,n,r);for(let e of r){let t=e.parseTag(i,c.value,n);if(t!==void 0)return t instanceof j&&s!==void 0&&(t.encodingWidth=s),{value:t,nextOffset:c.nextOffset}}return{value:new j(i,c.value,{encodingWidth:s}),nextOffset:c.nextOffset}}case 7:if(o<=19)return{value:new L(o),nextOffset:t};if(o===20)return{value:new L(20),nextOffset:t};if(o===21)return{value:new L(21),nextOffset:t};if(o===22)return{value:new L(22),nextOffset:t};if(o===23)return{value:new L(23),nextOffset:t};if(o===24){t+1>e.byteLength&&q(`unexpected end of input`);let r=e.getUint8(t);if(r<32){let e=Ln(`simple value ${r} must be encoded in initial byte (0–31 reserved for extended encoding)`,t-1,n),i=new L(r);return J(i,e),{value:i,nextOffset:t+1}}return{value:new L(r),nextOffset:t+1}}return o===25?(t+2>e.byteLength&&q(`unexpected end of input`),{value:new A(S(e.getUint16(t,!1)),{precision:`half`}),nextOffset:t+2}):o===26?(t+4>e.byteLength&&q(`unexpected end of input`),{value:new A(e.getFloat32(t,!1),{precision:`single`}),nextOffset:t+4}):o===27?(t+8>e.byteLength&&q(`unexpected end of input`),{value:new A(e.getFloat64(t,!1),{precision:`double`}),nextOffset:t+8}):(o<31&&q(`reserved additional info value in major type 7: ${o}`),q(`unexpected break code outside indefinite-length item`))}return q(`unknown major type: ${a}`)}function qn(e){if(e instanceof ArrayBuffer||typeof SharedArrayBuffer<`u`&&e instanceof SharedArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw TypeError(`expected ArrayBufferView or ArrayBufferLike`)}function Jn(e,t){let n=qn(e),r=new DataView(n.buffer,n.byteOffset,n.byteLength),i=t?.offset??0;if(!Number.isInteger(i)||i<0||i>r.byteLength)throw RangeError(`CBOR decode offset must be an integer between 0 and ${r.byteLength}`);let a=t?.extensions?.length?[...t.extensions.filter(e=>e.parseTag!==void 0),...Hn()]:Hn(),{value:o,nextOffset:s}=Z(r,i,t,a);if(!t?.allowTrailing&&s!==r.byteLength){J(o,Ln(`${r.byteLength-s} trailing byte(s) after end of CBOR item`,s,t));let e={strict:!1,silent:!0},n=s;for(;n<r.byteLength;)({nextOffset:n}=Z(r,n,e,a))}return o}var Yn=24n,Xn=[Bt,an,cn,Pn,{tagNumbers:[Yn],parseTag(e,t,n){if(e!==24n||!(t instanceof M))return;let r=n?{extensions:n.extensions,strict:n.strict,onWarning:n.onWarning,silent:n.silent}:void 0;try{return new j(Yn,new Be([Jn(t.value,r)],{encodingWidth:t.encodingWidth}))}catch(e){if(r?.strict!==!1)throw e;return}}}];function Q(e,t){if(t?.replacer){let{replacer:n,...r}=t,i=$n(e,n,r.extensions,r.undefinedOmits);return i===u?L.UNDEFINED:Q(i,Object.keys(r).length>0?r:void 0)}return Zn(e,t,!0)}function Zn(e,t,n){for(let n of[...t?.extensions??[],...Xn])if(n.fromJS){let r=n.fromJS(e,t??{});if(r!==void 0)return r}if(n&&typeof e==`object`&&e&&l.symbol in e){let n=e[l.symbol],r=Zn(e,t,!1);for(let e of[...t?.extensions??[],...Xn])if(e.parseTag){let t=e.parseTag(n,r);if(t!==void 0)return t}return new j(n,r)}if(e instanceof l.Null)return L.NULL;if(e instanceof l.Undefined)return L.UNDEFINED;if(e instanceof d)return new L(e.value);if(e===null)return L.NULL;if(e===void 0)return L.UNDEFINED;if(e===!0)return L.TRUE;if(e===!1)return L.FALSE;if(typeof e==`bigint`)return e>18446744073709551615n?new Ze(e):e<-18446744073709551616n?new Qe(e):e>=0n?new O(e):new k(e);if(typeof e==`number`)return(t?.encodeIntegerAs??`int`)===`int`&&Number.isInteger(e)&&!Object.is(e,-0)?e>=0?new O(BigInt(e)):new k(BigInt(e)):new A(e);if(typeof e==`string`)return new z(e);if(e instanceof Number||e instanceof Boolean||e instanceof String||Object.prototype.toString.call(e)===`[object BigInt]`)return Zn(e.valueOf(),t,!1);if(e instanceof ArrayBuffer||typeof SharedArrayBuffer<`u`&&e instanceof SharedArrayBuffer)return new M(new Uint8Array(e));if(ArrayBuffer.isView(e))return e instanceof Uint8Array&&t?.uint8ArrayAs===`array`?new F(Array.from(e,e=>new O(BigInt(e)))):new M(new Uint8Array(e.buffer,e.byteOffset,e.byteLength));if(e instanceof $)return new I([...e].map(([e,n])=>[Q(e,t),Q(n,t)]));if(Array.isArray(e))return new F(e.map(e=>Q(e,t)));if(typeof e==`object`){let n=[];for(let[r,i]of Object.entries(e))n.push([new z(r),Q(i,t)]);return new I(n)}throw TypeError(`fromJS: unsupported value type: ${typeof e}`)}function Qn(e){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 l.Null||e instanceof l.Undefined||e instanceof d}function $n(e,t,n,r){let i=[...n??[],...Xn];function a(e){return e===u||r===!0&&e===void 0}if(Array.isArray(t)){let n=t.map(String);function o(e){if(typeof e!=`object`||!e)return e;if(e instanceof $)return $.from(e,([e,t])=>[e,o(t)]);if(Array.isArray(e))return e.map(o);if(l.symbol in e||Qn(e)||i.some(t=>t.isJSType?.(e)))return e;let t=Object.getPrototypeOf(e);if(t===Object.prototype||t===null){let t=e.toJSON;if(typeof t==`function`)return o(t.call(e))}let r={};for(let t of n)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=o(e[t]));return r}return o(e)}let s=t;function c(e,t,n){if(typeof e==`object`&&e&&!(e instanceof $)){let n=Object.getPrototypeOf(e);if(n===Object.prototype||n===null){let n=e.toJSON;typeof n==`function`&&(e=n.call(e,t))}}if(e=s.call(n,t,e),typeof e==`object`&&e){if(l.symbol in e)return e;if(e instanceof $){let t=new $;for(let[n,r]of e){let i=c(r,n,e);a(i)||t.push([n,i])}return t}if(Array.isArray(e))return e.map((t,n)=>{let r=c(t,String(n),e);return a(r)?null:r});if(Qn(e)||i.some(t=>t.isJSType?.(e)))return e;let t={};for(let n of Object.keys(e)){let r=c(e[n],n,e);a(r)||(t[n]=r)}return t}return e}return c(e,``,{"":e})}var $=class extends Array{toJSON(){let e={};for(let[t,n]of this){let r=typeof t==`string`?t:Q(t).toCDN();r===`__proto__`?Object.defineProperty(e,r,{value:n,writable:!0,enumerable:!0,configurable:!0}):e[r]=n}return e}};Object.defineProperty(exports,"A",{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,"C",{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,"D",{enumerable:!0,get:function(){return t}}),Object.defineProperty(exports,"E",{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,"O",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"S",{enumerable:!0,get:function(){return S}}),Object.defineProperty(exports,"T",{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,"_",{enumerable:!0,get:function(){return j}}),Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return Vt}}),Object.defineProperty(exports,"b",{enumerable:!0,get:function(){return O}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return Qe}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return L}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return I}}),Object.defineProperty(exports,"g",{enumerable:!0,get:function(){return M}}),Object.defineProperty(exports,"h",{enumerable:!0,get:function(){return N}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return Jn}}),Object.defineProperty(exports,"k",{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return Ze}}),Object.defineProperty(exports,"m",{enumerable:!0,get:function(){return P}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return $n}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return z}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return F}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return nt}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return $}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return Be}}),Object.defineProperty(exports,"v",{enumerable:!0,get:function(){return A}}),Object.defineProperty(exports,"w",{enumerable:!0,get:function(){return te}}),Object.defineProperty(exports,"x",{enumerable:!0,get:function(){return D}}),Object.defineProperty(exports,"y",{enumerable:!0,get:function(){return k}});
12
- //# sourceMappingURL=mapEntries-BkcJsv3C.cjs.map