@eigenpal/cli 0.20.11 → 0.20.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -7674,13 +7674,20 @@ var require_picocolors = __commonJS(function(exports, module) {
7674
7674
  // ../../node_modules/nanoid/index.js
7675
7675
  import { webcrypto as crypto } from "node:crypto";
7676
7676
  function fillPool(bytes) {
7677
- if (!pool || pool.length < bytes) {
7678
- pool = Buffer.allocUnsafe(bytes * POOL_SIZE_MULTIPLIER);
7679
- crypto.getRandomValues(pool);
7680
- poolOffset = 0;
7681
- } else if (poolOffset + bytes > pool.length) {
7682
- crypto.getRandomValues(pool);
7683
- poolOffset = 0;
7677
+ if (bytes < 0)
7678
+ throw new RangeError("Wrong ID size");
7679
+ try {
7680
+ if (!pool || pool.length < bytes) {
7681
+ pool = Buffer.allocUnsafe(bytes * POOL_SIZE_MULTIPLIER);
7682
+ crypto.getRandomValues(pool);
7683
+ poolOffset = 0;
7684
+ } else if (poolOffset + bytes > pool.length) {
7685
+ crypto.getRandomValues(pool);
7686
+ poolOffset = 0;
7687
+ }
7688
+ } catch (e) {
7689
+ pool = undefined;
7690
+ throw e;
7684
7691
  }
7685
7692
  poolOffset += bytes;
7686
7693
  }
@@ -7689,8 +7696,25 @@ function random(bytes) {
7689
7696
  return pool.subarray(poolOffset - bytes, poolOffset);
7690
7697
  }
7691
7698
  function customRandom(alphabet, defaultSize, getRandom) {
7692
- let mask = (2 << 31 - Math.clz32(alphabet.length - 1 | 1)) - 1;
7693
- let step = Math.ceil(1.6 * mask * defaultSize / alphabet.length);
7699
+ let safeByteCutoff = 256 - 256 % alphabet.length;
7700
+ if (safeByteCutoff === 256) {
7701
+ let mask = alphabet.length - 1;
7702
+ return (size = defaultSize) => {
7703
+ if (!size)
7704
+ return "";
7705
+ let id = "";
7706
+ while (true) {
7707
+ let bytes = getRandom(size);
7708
+ let i = size;
7709
+ while (i--) {
7710
+ id += alphabet[bytes[i] & mask];
7711
+ if (id.length >= size)
7712
+ return id;
7713
+ }
7714
+ }
7715
+ };
7716
+ }
7717
+ let step = Math.ceil(1.6 * 256 * defaultSize / safeByteCutoff);
7694
7718
  return (size = defaultSize) => {
7695
7719
  if (!size)
7696
7720
  return "";
@@ -7699,9 +7723,11 @@ function customRandom(alphabet, defaultSize, getRandom) {
7699
7723
  let bytes = getRandom(step);
7700
7724
  let i = step;
7701
7725
  while (i--) {
7702
- id += alphabet[bytes[i] & mask] || "";
7703
- if (id.length >= size)
7704
- return id;
7726
+ if (bytes[i] < safeByteCutoff) {
7727
+ id += alphabet[bytes[i] % alphabet.length];
7728
+ if (id.length >= size)
7729
+ return id;
7730
+ }
7705
7731
  }
7706
7732
  }
7707
7733
  };
@@ -11997,6 +12023,28 @@ var require_data = __commonJS(function(exports, module) {
11997
12023
  var require_utils = __commonJS(function(exports, module) {
11998
12024
  var isUUID = RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu);
11999
12025
  var isIPv4 = RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u);
12026
+ var isPort = RegExp.prototype.test.bind(/^\d*$/u);
12027
+ var isHexPair = RegExp.prototype.test.bind(/^[\da-f]{2}$/iu);
12028
+ var isUnreserved = RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu);
12029
+ var isPathCharacter = RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/]$/u);
12030
+ var isQueryFragmentCharacter = RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/?]$/u);
12031
+ var isUserinfoCharacter = RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:]$/u);
12032
+ var BYTE_HEX = new Array(256);
12033
+ {
12034
+ const HEX_DIGITS = "0123456789ABCDEF";
12035
+ for (let i = 0;i < 256; i++) {
12036
+ BYTE_HEX[i] = "%" + HEX_DIGITS[i >> 4] + HEX_DIGITS[i & 15];
12037
+ }
12038
+ }
12039
+ function percentEncodeNonAscii(cp) {
12040
+ if (cp < 2048) {
12041
+ return BYTE_HEX[192 | cp >> 6] + BYTE_HEX[128 | cp & 63];
12042
+ }
12043
+ if (cp < 65536) {
12044
+ return BYTE_HEX[224 | cp >> 12] + BYTE_HEX[128 | cp >> 6 & 63] + BYTE_HEX[128 | cp & 63];
12045
+ }
12046
+ return BYTE_HEX[240 | cp >> 18] + BYTE_HEX[128 | cp >> 12 & 63] + BYTE_HEX[128 | cp >> 6 & 63] + BYTE_HEX[128 | cp & 63];
12047
+ }
12000
12048
  function stringArrayToHexStripped(input) {
12001
12049
  let acc = "";
12002
12050
  let code = 0;
@@ -12021,91 +12069,122 @@ var require_utils = __commonJS(function(exports, module) {
12021
12069
  }
12022
12070
  return acc;
12023
12071
  }
12072
+ var isHextet = RegExp.prototype.test.bind(/^[\dA-Fa-f]{1,4}$/);
12073
+ var isIPvFuture = RegExp.prototype.test.bind(/^[vV][\dA-Fa-f]+\.[A-Za-z\d\-._~!$&'()*+,;=:]+$/);
12074
+ var isZoneCharacter = RegExp.prototype.test.bind(/^[A-Za-z\d\-._~]$/);
12024
12075
  var nonSimpleDomain = RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);
12025
- function consumeIsZone(buffer) {
12026
- buffer.length = 0;
12027
- return true;
12028
- }
12029
- function consumeHextets(buffer, address, output) {
12030
- if (buffer.length) {
12031
- const hex = stringArrayToHexStripped(buffer);
12032
- if (hex !== "") {
12033
- address.push(hex);
12034
- } else {
12035
- output.error = true;
12036
- return false;
12076
+ function isZoneIdentifier(zone) {
12077
+ if (zone.length === 0)
12078
+ return false;
12079
+ for (let i = 0;i < zone.length; i++) {
12080
+ if (isZoneCharacter(zone[i]))
12081
+ continue;
12082
+ if (zone[i] === "%" && i + 2 < zone.length && isHexPair(zone.slice(i + 1, i + 3))) {
12083
+ i += 2;
12084
+ continue;
12037
12085
  }
12038
- buffer.length = 0;
12086
+ return false;
12039
12087
  }
12040
12088
  return true;
12041
12089
  }
12042
- function getIPV6(input) {
12043
- let tokenCount = 0;
12044
- const output = { error: false, address: "", zone: "" };
12045
- const address = [];
12046
- const buffer = [];
12047
- let endipv6Encountered = false;
12048
- let endIpv6 = false;
12049
- let consume = consumeHextets;
12050
- for (let i = 0;i < input.length; i++) {
12051
- const cursor = input[i];
12052
- if (cursor === "[" || cursor === "]") {
12053
- continue;
12054
- }
12055
- if (cursor === ":") {
12056
- if (endipv6Encountered === true) {
12057
- endIpv6 = true;
12058
- }
12059
- if (!consume(buffer, address, output)) {
12060
- break;
12061
- }
12062
- if (++tokenCount > 7) {
12063
- output.error = true;
12064
- break;
12090
+ function compressIPv6ZeroRun(hextets) {
12091
+ let bestStart = -1;
12092
+ let bestLength = 0;
12093
+ let runStart = -1;
12094
+ let runLength = 0;
12095
+ for (let i = 0;i < hextets.length; i++) {
12096
+ if (hextets[i] === "0") {
12097
+ if (runStart === -1)
12098
+ runStart = i;
12099
+ runLength++;
12100
+ if (runLength > bestLength) {
12101
+ bestLength = runLength;
12102
+ bestStart = runStart;
12065
12103
  }
12066
- if (i > 0 && input[i - 1] === ":") {
12067
- endipv6Encountered = true;
12068
- }
12069
- address.push(":");
12070
- continue;
12071
- } else if (cursor === "%") {
12072
- if (!consume(buffer, address, output)) {
12073
- break;
12074
- }
12075
- consume = consumeIsZone;
12076
12104
  } else {
12077
- buffer.push(cursor);
12078
- continue;
12105
+ runStart = -1;
12106
+ runLength = 0;
12079
12107
  }
12080
12108
  }
12081
- if (buffer.length) {
12082
- if (consume === consumeIsZone) {
12083
- output.zone = buffer.join("");
12084
- } else if (endIpv6) {
12085
- address.push(buffer.join(""));
12086
- } else {
12087
- address.push(stringArrayToHexStripped(buffer));
12109
+ if (bestLength < 2)
12110
+ return hextets.join(":");
12111
+ const head = hextets.slice(0, bestStart).join(":");
12112
+ const tail = hextets.slice(bestStart + bestLength).join(":");
12113
+ return head + "::" + tail;
12114
+ }
12115
+ function normalizeIPv6Address(input) {
12116
+ const compression = input.indexOf("::");
12117
+ if (compression !== -1 && input.indexOf("::", compression + 1) !== -1)
12118
+ return;
12119
+ const left = compression === -1 ? input.split(":") : input.slice(0, compression).split(":");
12120
+ const right = compression === -1 ? [] : input.slice(compression + 2).split(":");
12121
+ if (compression !== -1) {
12122
+ if (left.length === 1 && left[0] === "")
12123
+ left.length = 0;
12124
+ if (right.length === 1 && right[0] === "")
12125
+ right.length = 0;
12126
+ }
12127
+ const parts = left.concat(right);
12128
+ let hextetCount = 0;
12129
+ for (let i = 0;i < parts.length; i++) {
12130
+ const part = parts[i];
12131
+ if (part === "")
12132
+ return;
12133
+ if (part.indexOf(".") !== -1) {
12134
+ if (i !== parts.length - 1 || compression !== -1 && right.length === 0 || !isIPv4(part))
12135
+ return;
12136
+ hextetCount += 2;
12137
+ continue;
12088
12138
  }
12139
+ if (!isHextet(part))
12140
+ return;
12141
+ parts[i] = parseInt(part, 16).toString(16);
12142
+ hextetCount++;
12089
12143
  }
12090
- output.address = address.join("");
12091
- return output;
12144
+ if (compression === -1) {
12145
+ if (hextetCount !== 8)
12146
+ return;
12147
+ return compressIPv6ZeroRun(parts);
12148
+ }
12149
+ if (hextetCount >= 8)
12150
+ return;
12151
+ const expanded = parts.slice(0, left.length);
12152
+ for (let i = hextetCount;i < 8; i++)
12153
+ expanded.push("0");
12154
+ for (let i = left.length;i < parts.length; i++)
12155
+ expanded.push(parts[i]);
12156
+ return compressIPv6ZeroRun(expanded);
12092
12157
  }
12093
12158
  function normalizeIPv6(host) {
12094
- if (findToken(host, ":") < 2) {
12095
- return { host, isIPV6: false };
12096
- }
12097
- const ipv6 = getIPV6(host);
12098
- if (!ipv6.error) {
12099
- let newHost = ipv6.address;
12100
- let escapedHost = ipv6.address;
12101
- if (ipv6.zone) {
12102
- newHost += "%" + ipv6.zone;
12103
- escapedHost += "%25" + ipv6.zone;
12104
- }
12105
- return { host: newHost, isIPV6: true, escapedHost };
12106
- } else {
12107
- return { host, isIPV6: false };
12108
- }
12159
+ const bracketed = host[0] === "[" && host[host.length - 1] === "]";
12160
+ const hasBracket = host[0] === "[" || host[host.length - 1] === "]";
12161
+ if (hasBracket && !bracketed)
12162
+ return { host, isIPV6: false, error: true };
12163
+ let input = bracketed ? host.slice(1, -1) : host;
12164
+ if (bracketed && isIPvFuture(input)) {
12165
+ input = input.toLowerCase();
12166
+ return { host: `[${input}]`, escapedHost: input, isIPV6: false, isIPVFuture: true };
12167
+ }
12168
+ if (findToken(input, ":") < 2) {
12169
+ return { host, isIPV6: false, error: bracketed };
12170
+ }
12171
+ let zoneIdentifier = "";
12172
+ const zoneSeparator = input.indexOf("%");
12173
+ if (zoneSeparator !== -1) {
12174
+ const separatorLength = input.slice(zoneSeparator, zoneSeparator + 3).toLowerCase() === "%25" ? 3 : 1;
12175
+ zoneIdentifier = input.slice(zoneSeparator + separatorLength);
12176
+ if (!isZoneIdentifier(zoneIdentifier))
12177
+ return { host, isIPV6: false, error: true };
12178
+ input = input.slice(0, zoneSeparator);
12179
+ }
12180
+ const address = normalizeIPv6Address(input);
12181
+ if (address === undefined)
12182
+ return { host, isIPV6: false, error: true };
12183
+ return {
12184
+ host: address + (zoneIdentifier ? "%" + zoneIdentifier : ""),
12185
+ escapedHost: address + (zoneIdentifier ? "%25" + zoneIdentifier : ""),
12186
+ isIPV6: true
12187
+ };
12109
12188
  }
12110
12189
  function findToken(str, token) {
12111
12190
  let ind = 0;
@@ -12190,56 +12269,265 @@ var require_utils = __commonJS(function(exports, module) {
12190
12269
  }
12191
12270
  return output.join("");
12192
12271
  }
12193
- function normalizeComponentEncoding(component, esc) {
12194
- const func = esc !== true ? escape : unescape;
12195
- if (component.scheme !== undefined) {
12196
- component.scheme = func(component.scheme);
12272
+ var HOST_DELIMS = { "@": "%40", "/": "%2F", "?": "%3F", "#": "%23", ":": "%3A" };
12273
+ var HOST_DELIM_RE = /[@/?#:]/g;
12274
+ var HOST_DELIM_NO_COLON_RE = /[@/?#]/g;
12275
+ function reescapeHostDelimiters(host, isIP) {
12276
+ const re = isIP ? HOST_DELIM_NO_COLON_RE : HOST_DELIM_RE;
12277
+ re.lastIndex = 0;
12278
+ return host.replace(re, (ch) => HOST_DELIMS[ch]);
12279
+ }
12280
+ function normalizePercentEncoding(input, decodeUnreserved = false) {
12281
+ if (input.indexOf("%") === -1) {
12282
+ return input;
12197
12283
  }
12198
- if (component.userinfo !== undefined) {
12199
- component.userinfo = func(component.userinfo);
12284
+ let output = "";
12285
+ for (let i = 0;i < input.length; i++) {
12286
+ if (input[i] === "%" && i + 2 < input.length) {
12287
+ const hex = input.slice(i + 1, i + 3);
12288
+ if (isHexPair(hex)) {
12289
+ const normalizedHex = hex.toUpperCase();
12290
+ const decoded = String.fromCharCode(parseInt(normalizedHex, 16));
12291
+ if (decodeUnreserved && isUnreserved(decoded)) {
12292
+ output += decoded;
12293
+ } else {
12294
+ output += "%" + normalizedHex;
12295
+ }
12296
+ i += 2;
12297
+ continue;
12298
+ }
12299
+ }
12300
+ output += input[i];
12200
12301
  }
12201
- if (component.host !== undefined) {
12202
- component.host = func(component.host);
12302
+ return output;
12303
+ }
12304
+ function normalizePathEncoding(input) {
12305
+ let output = "";
12306
+ for (let i = 0;i < input.length; i++) {
12307
+ const ch = input[i];
12308
+ if (ch === "%" && i + 2 < input.length) {
12309
+ const hex = input.slice(i + 1, i + 3);
12310
+ if (isHexPair(hex)) {
12311
+ const normalizedHex = hex.toUpperCase();
12312
+ const decoded = String.fromCharCode(parseInt(normalizedHex, 16));
12313
+ if (decoded !== "." && isUnreserved(decoded)) {
12314
+ output += decoded;
12315
+ } else {
12316
+ output += "%" + normalizedHex;
12317
+ }
12318
+ i += 2;
12319
+ continue;
12320
+ }
12321
+ }
12322
+ if (isPathCharacter(ch)) {
12323
+ output += ch;
12324
+ } else {
12325
+ const code = input.charCodeAt(i);
12326
+ if (code < 128) {
12327
+ output += isEscapeSafe(code) ? ch : BYTE_HEX[code];
12328
+ } else if (code < 55296 || code > 57343) {
12329
+ output += percentEncodeNonAscii(code);
12330
+ } else if (code <= 56319 && i + 1 < input.length) {
12331
+ const low = input.charCodeAt(i + 1);
12332
+ if (low >= 56320 && low <= 57343) {
12333
+ output += percentEncodeNonAscii(65536 + (code - 55296 << 10) + (low - 56320));
12334
+ i++;
12335
+ } else {
12336
+ output += percentEncodeNonAscii(65533);
12337
+ }
12338
+ } else {
12339
+ output += percentEncodeNonAscii(65533);
12340
+ }
12341
+ }
12203
12342
  }
12204
- if (component.path !== undefined) {
12205
- component.path = func(component.path);
12343
+ return output;
12344
+ }
12345
+ function serializePathEncoding(input, pathNoScheme = false) {
12346
+ let output = "";
12347
+ let firstSegment = pathNoScheme && input[0] !== "/";
12348
+ for (let i = 0;i < input.length; i++) {
12349
+ const ch = input[i];
12350
+ if (ch === "%" && i + 2 < input.length) {
12351
+ const hex = input.slice(i + 1, i + 3);
12352
+ if (isHexPair(hex)) {
12353
+ output += "%" + hex.toUpperCase();
12354
+ i += 2;
12355
+ continue;
12356
+ }
12357
+ }
12358
+ if (ch === "/") {
12359
+ firstSegment = false;
12360
+ }
12361
+ if (isPathCharacter(ch) && (ch !== ":" || !firstSegment)) {
12362
+ output += ch;
12363
+ } else {
12364
+ const code = input.charCodeAt(i);
12365
+ if (code < 128) {
12366
+ output += BYTE_HEX[code];
12367
+ } else if (code < 55296 || code > 57343) {
12368
+ output += percentEncodeNonAscii(code);
12369
+ } else if (code <= 56319 && i + 1 < input.length) {
12370
+ const low = input.charCodeAt(i + 1);
12371
+ if (low >= 56320 && low <= 57343) {
12372
+ output += percentEncodeNonAscii(65536 + (code - 55296 << 10) + (low - 56320));
12373
+ i++;
12374
+ } else {
12375
+ output += percentEncodeNonAscii(65533);
12376
+ }
12377
+ } else {
12378
+ output += percentEncodeNonAscii(65533);
12379
+ }
12380
+ }
12206
12381
  }
12207
- if (component.query !== undefined) {
12208
- component.query = func(component.query);
12382
+ return output;
12383
+ }
12384
+ function encodeComponent(input, isAllowed) {
12385
+ let output = "";
12386
+ for (let i = 0;i < input.length; i++) {
12387
+ const ch = input[i];
12388
+ if (ch === "%" && i + 2 < input.length) {
12389
+ const hex = input.slice(i + 1, i + 3);
12390
+ if (isHexPair(hex)) {
12391
+ output += "%" + hex.toUpperCase();
12392
+ i += 2;
12393
+ continue;
12394
+ }
12395
+ }
12396
+ if (isAllowed(ch)) {
12397
+ output += ch;
12398
+ } else {
12399
+ const code = input.charCodeAt(i);
12400
+ if (code < 128) {
12401
+ output += BYTE_HEX[code];
12402
+ } else if (code < 55296 || code > 57343) {
12403
+ output += percentEncodeNonAscii(code);
12404
+ } else if (code <= 56319 && i + 1 < input.length) {
12405
+ const low = input.charCodeAt(i + 1);
12406
+ if (low >= 56320 && low <= 57343) {
12407
+ output += percentEncodeNonAscii(65536 + (code - 55296 << 10) + (low - 56320));
12408
+ i++;
12409
+ } else {
12410
+ output += percentEncodeNonAscii(65533);
12411
+ }
12412
+ } else {
12413
+ output += percentEncodeNonAscii(65533);
12414
+ }
12415
+ }
12209
12416
  }
12210
- if (component.fragment !== undefined) {
12211
- component.fragment = func(component.fragment);
12417
+ return output;
12418
+ }
12419
+ function encodeUserinfo(input) {
12420
+ return encodeComponent(input, isUserinfoCharacter);
12421
+ }
12422
+ function encodeQuery(input) {
12423
+ return encodeComponent(input, isQueryFragmentCharacter);
12424
+ }
12425
+ function encodeFragment(input) {
12426
+ return encodeComponent(input, isQueryFragmentCharacter);
12427
+ }
12428
+ function isEscapeSafe(cp) {
12429
+ return cp >= 48 && cp <= 57 || cp >= 65 && cp <= 90 || cp >= 97 && cp <= 122 || cp === 42 || cp === 43 || cp === 45 || cp === 46 || cp === 47 || cp === 64 || cp === 95;
12430
+ }
12431
+ function normalizeQueryFragmentEncoding(input) {
12432
+ let output = "";
12433
+ for (let i = 0;i < input.length; i++) {
12434
+ const ch = input[i];
12435
+ if (ch === "%" && i + 2 < input.length) {
12436
+ const hex = input.slice(i + 1, i + 3);
12437
+ if (isHexPair(hex)) {
12438
+ const normalizedHex = hex.toUpperCase();
12439
+ const decoded = String.fromCharCode(parseInt(normalizedHex, 16));
12440
+ if (isUnreserved(decoded)) {
12441
+ output += decoded;
12442
+ } else {
12443
+ output += "%" + normalizedHex;
12444
+ }
12445
+ i += 2;
12446
+ continue;
12447
+ }
12448
+ }
12449
+ if (isQueryFragmentCharacter(ch)) {
12450
+ output += ch;
12451
+ } else {
12452
+ const code = input.charCodeAt(i);
12453
+ if (code < 128) {
12454
+ output += isEscapeSafe(code) ? ch : BYTE_HEX[code];
12455
+ } else if (code < 55296 || code > 57343) {
12456
+ output += percentEncodeNonAscii(code);
12457
+ } else if (code <= 56319 && i + 1 < input.length) {
12458
+ const low = input.charCodeAt(i + 1);
12459
+ if (low >= 56320 && low <= 57343) {
12460
+ output += percentEncodeNonAscii(65536 + (code - 55296 << 10) + (low - 56320));
12461
+ i++;
12462
+ } else {
12463
+ output += percentEncodeNonAscii(65533);
12464
+ }
12465
+ } else {
12466
+ output += percentEncodeNonAscii(65533);
12467
+ }
12468
+ }
12212
12469
  }
12213
- return component;
12470
+ return output;
12471
+ }
12472
+ function escapePreservingEscapes(input) {
12473
+ let output = "";
12474
+ for (let i = 0;i < input.length; i++) {
12475
+ if (input[i] === "%" && i + 2 < input.length) {
12476
+ const hex = input.slice(i + 1, i + 3);
12477
+ if (isHexPair(hex)) {
12478
+ output += "%" + hex.toUpperCase();
12479
+ i += 2;
12480
+ continue;
12481
+ }
12482
+ }
12483
+ output += escape(input[i]);
12484
+ }
12485
+ return output;
12214
12486
  }
12215
12487
  function recomposeAuthority(component) {
12216
12488
  const uriTokens = [];
12217
12489
  if (component.userinfo !== undefined) {
12218
- uriTokens.push(component.userinfo);
12490
+ uriTokens.push(encodeUserinfo(component.userinfo));
12219
12491
  uriTokens.push("@");
12220
12492
  }
12221
12493
  if (component.host !== undefined) {
12222
- let host = unescape(component.host);
12494
+ let host = component.host;
12223
12495
  if (!isIPv4(host)) {
12224
- const ipV6res = normalizeIPv6(host);
12225
- if (ipV6res.isIPV6 === true) {
12496
+ let ipV6res = normalizeIPv6(host);
12497
+ if (ipV6res.isIPV6 !== true && ipV6res.isIPVFuture !== true) {
12498
+ host = normalizePercentEncoding(host, true);
12499
+ ipV6res = normalizeIPv6(host);
12500
+ }
12501
+ if (ipV6res.isIPV6 === true || ipV6res.isIPVFuture === true) {
12226
12502
  host = `[${ipV6res.escapedHost}]`;
12227
12503
  } else {
12228
- host = component.host;
12504
+ host = reescapeHostDelimiters(host, false);
12229
12505
  }
12230
12506
  }
12231
12507
  uriTokens.push(host);
12232
12508
  }
12233
12509
  if (typeof component.port === "number" || typeof component.port === "string") {
12510
+ const port = String(component.port);
12511
+ if (!isPort(port)) {
12512
+ throw new TypeError("URI port is malformed.");
12513
+ }
12234
12514
  uriTokens.push(":");
12235
- uriTokens.push(String(component.port));
12515
+ uriTokens.push(port);
12236
12516
  }
12237
12517
  return uriTokens.length ? uriTokens.join("") : undefined;
12238
12518
  }
12239
12519
  module.exports = {
12240
12520
  nonSimpleDomain,
12241
12521
  recomposeAuthority,
12242
- normalizeComponentEncoding,
12522
+ reescapeHostDelimiters,
12523
+ normalizePercentEncoding,
12524
+ normalizePathEncoding,
12525
+ serializePathEncoding,
12526
+ normalizeQueryFragmentEncoding,
12527
+ encodeUserinfo,
12528
+ encodeQuery,
12529
+ encodeFragment,
12530
+ escapePreservingEscapes,
12243
12531
  removeDotSegments,
12244
12532
  isIPv4,
12245
12533
  isUUID,
@@ -12251,7 +12539,7 @@ var require_utils = __commonJS(function(exports, module) {
12251
12539
  // ../../node_modules/fast-uri/lib/schemes.js
12252
12540
  var require_schemes = __commonJS(function(exports, module) {
12253
12541
  var { isUUID } = require_utils();
12254
- var URN_REG = /([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu;
12542
+ var URN_REG = /^([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-./:;=@]|%[\da-f]{2})+)$/iu;
12255
12543
  var supportedSchemeNames = [
12256
12544
  "http",
12257
12545
  "https",
@@ -12306,9 +12594,10 @@ var require_schemes = __commonJS(function(exports, module) {
12306
12594
  wsComponent.secure = undefined;
12307
12595
  }
12308
12596
  if (wsComponent.resourceName) {
12309
- const [path, query] = wsComponent.resourceName.split("?");
12597
+ const queryIndex = wsComponent.resourceName.indexOf("?");
12598
+ const path = queryIndex === -1 ? wsComponent.resourceName : wsComponent.resourceName.slice(0, queryIndex);
12310
12599
  wsComponent.path = path && path !== "/" ? path : undefined;
12311
- wsComponent.query = query;
12600
+ wsComponent.query = queryIndex === -1 ? undefined : wsComponent.resourceName.slice(queryIndex + 1);
12312
12601
  wsComponent.resourceName = undefined;
12313
12602
  }
12314
12603
  wsComponent.fragment = undefined;
@@ -12320,7 +12609,7 @@ var require_schemes = __commonJS(function(exports, module) {
12320
12609
  return urnComponent;
12321
12610
  }
12322
12611
  const matches = urnComponent.path.match(URN_REG);
12323
- if (matches) {
12612
+ if (matches && matches[0] === urnComponent.path) {
12324
12613
  const scheme = options.scheme || urnComponent.scheme || "urn";
12325
12614
  urnComponent.nid = matches[1].toLowerCase();
12326
12615
  urnComponent.nss = matches[2];
@@ -12424,11 +12713,20 @@ var require_schemes = __commonJS(function(exports, module) {
12424
12713
 
12425
12714
  // ../../node_modules/fast-uri/index.js
12426
12715
  var require_fast_uri = __commonJS(function(exports, module) {
12427
- var { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizeComponentEncoding, isIPv4, nonSimpleDomain } = require_utils();
12716
+ var { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, serializePathEncoding, normalizeQueryFragmentEncoding, encodeQuery, encodeFragment, reescapeHostDelimiters, isIPv4, nonSimpleDomain } = require_utils();
12428
12717
  var { SCHEMES, getSchemeHandler } = require_schemes();
12718
+ var VALID_SCHEME = /^[A-Za-z][A-Za-z0-9+.-]*$/u;
12719
+ var MALFORMED_SCHEME_ERROR = "URI scheme is malformed.";
12720
+ function decodeValidScheme(scheme) {
12721
+ const decodedScheme = unescape(String(scheme));
12722
+ if (!VALID_SCHEME.test(decodedScheme)) {
12723
+ throw new TypeError(MALFORMED_SCHEME_ERROR);
12724
+ }
12725
+ return decodedScheme;
12726
+ }
12429
12727
  function normalize(uri, options) {
12430
12728
  if (typeof uri === "string") {
12431
- uri = serialize(parse(uri, options), options);
12729
+ uri = normalizeString(uri, options);
12432
12730
  } else if (typeof uri === "object") {
12433
12731
  uri = parse(serialize(uri, options), options);
12434
12732
  }
@@ -12436,7 +12734,34 @@ var require_fast_uri = __commonJS(function(exports, module) {
12436
12734
  }
12437
12735
  function resolve(baseURI, relativeURI, options) {
12438
12736
  const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
12439
- const resolved = resolveComponent(parse(baseURI, schemelessOptions), parse(relativeURI, schemelessOptions), schemelessOptions, true);
12737
+ const {
12738
+ parsed: baseParsed,
12739
+ malformedAuthorityOrPort: baseMalformed,
12740
+ malformedPercentEncoding: baseMalformedPercentEncoding,
12741
+ malformedSchemeSpecific: baseMalformedSchemeSpecific,
12742
+ malformedHost: baseMalformedHost,
12743
+ malformedScheme: baseMalformedScheme
12744
+ } = parseWithStatus(baseURI, schemelessOptions);
12745
+ const {
12746
+ parsed: relativeParsed,
12747
+ malformedAuthorityOrPort: relativeMalformed,
12748
+ malformedPercentEncoding: relativeMalformedPercentEncoding,
12749
+ malformedSchemeSpecific: relativeMalformedSchemeSpecific,
12750
+ malformedHost: relativeMalformedHost,
12751
+ malformedScheme: relativeMalformedScheme
12752
+ } = parseWithStatus(relativeURI, schemelessOptions);
12753
+ if (baseMalformed || relativeMalformed || baseMalformedPercentEncoding || relativeMalformedPercentEncoding || baseMalformedSchemeSpecific || relativeMalformedSchemeSpecific || baseMalformedHost || relativeMalformedHost || baseMalformedScheme || relativeMalformedScheme) {
12754
+ throw new Error(baseParsed.error || relativeParsed.error || "URI is malformed.");
12755
+ }
12756
+ const resolved = resolveComponent(baseParsed, relativeParsed, schemelessOptions, true);
12757
+ const resolvedSchemeHandler = getSchemeHandler(options && options.scheme || resolved.scheme);
12758
+ const resolvedHost = resolved.host;
12759
+ const resolvedHostIsIP = resolvedHost !== undefined && resolvedHost !== "" && (isIPv4(resolvedHost) || normalizeIPv6(resolvedHost).isIPV6);
12760
+ canonicalizeHost(resolved, options || {}, resolvedSchemeHandler, resolvedHostIsIP);
12761
+ const encodedASCIIHost = resolvedHost && resolvedHost.indexOf("%") !== -1 && !/\P{ASCII}/u.test(resolvedHost);
12762
+ if (resolved.error && !encodedASCIIHost) {
12763
+ throw new Error(resolved.error);
12764
+ }
12440
12765
  schemelessOptions.skipEscape = true;
12441
12766
  return serialize(resolved, schemelessOptions);
12442
12767
  }
@@ -12494,19 +12819,9 @@ var require_fast_uri = __commonJS(function(exports, module) {
12494
12819
  return target;
12495
12820
  }
12496
12821
  function equal(uriA, uriB, options) {
12497
- if (typeof uriA === "string") {
12498
- uriA = unescape(uriA);
12499
- uriA = serialize(normalizeComponentEncoding(parse(uriA, options), true), { ...options, skipEscape: true });
12500
- } else if (typeof uriA === "object") {
12501
- uriA = serialize(normalizeComponentEncoding(uriA, true), { ...options, skipEscape: true });
12502
- }
12503
- if (typeof uriB === "string") {
12504
- uriB = unescape(uriB);
12505
- uriB = serialize(normalizeComponentEncoding(parse(uriB, options), true), { ...options, skipEscape: true });
12506
- } else if (typeof uriB === "object") {
12507
- uriB = serialize(normalizeComponentEncoding(uriB, true), { ...options, skipEscape: true });
12508
- }
12509
- return uriA.toLowerCase() === uriB.toLowerCase();
12822
+ const normalizedA = normalizeComparableURI(uriA, options);
12823
+ const normalizedB = normalizeComparableURI(uriB, options);
12824
+ return normalizedA !== undefined && normalizedB !== undefined && normalizedA === normalizedB;
12510
12825
  }
12511
12826
  function serialize(cmpts, opts) {
12512
12827
  const component = {
@@ -12527,20 +12842,23 @@ var require_fast_uri = __commonJS(function(exports, module) {
12527
12842
  };
12528
12843
  const options = Object.assign({}, opts);
12529
12844
  const uriTokens = [];
12845
+ if (component.scheme) {
12846
+ component.scheme = decodeValidScheme(component.scheme);
12847
+ }
12530
12848
  const schemeHandler = getSchemeHandler(options.scheme || component.scheme);
12531
12849
  if (schemeHandler && schemeHandler.serialize)
12532
12850
  schemeHandler.serialize(component, options);
12851
+ const hasAuthority = component.userinfo !== undefined || component.host !== undefined || component.port !== undefined;
12852
+ const pathNoScheme = !options.skipEscape && component.scheme === undefined && !hasAuthority;
12533
12853
  if (component.path !== undefined) {
12534
12854
  if (!options.skipEscape) {
12535
- component.path = escape(component.path);
12536
- if (component.scheme !== undefined) {
12537
- component.path = component.path.split("%3A").join(":");
12538
- }
12855
+ component.path = serializePathEncoding(component.path, pathNoScheme);
12539
12856
  } else {
12540
- component.path = unescape(component.path);
12857
+ component.path = normalizePercentEncoding(component.path);
12541
12858
  }
12542
12859
  }
12543
12860
  if (options.reference !== "suffix" && component.scheme) {
12861
+ component.scheme = decodeValidScheme(component.scheme);
12544
12862
  uriTokens.push(component.scheme, ":");
12545
12863
  }
12546
12864
  const authority = recomposeAuthority(component);
@@ -12558,21 +12876,65 @@ var require_fast_uri = __commonJS(function(exports, module) {
12558
12876
  if (!options.absolutePath && (!schemeHandler || !schemeHandler.absolutePath)) {
12559
12877
  s = removeDotSegments(s);
12560
12878
  }
12879
+ if (pathNoScheme) {
12880
+ s = serializePathEncoding(s, true);
12881
+ }
12561
12882
  if (authority === undefined && s[0] === "/" && s[1] === "/") {
12562
12883
  s = "/%2F" + s.slice(2);
12563
12884
  }
12564
12885
  uriTokens.push(s);
12565
12886
  }
12566
12887
  if (component.query !== undefined) {
12567
- uriTokens.push("?", component.query);
12888
+ uriTokens.push("?", encodeQuery(component.query));
12568
12889
  }
12569
12890
  if (component.fragment !== undefined) {
12570
- uriTokens.push("#", component.fragment);
12891
+ uriTokens.push("#", encodeFragment(component.fragment));
12571
12892
  }
12572
12893
  return uriTokens.join("");
12573
12894
  }
12574
12895
  var URI_PARSE = /^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;
12575
- function parse(uri, opts) {
12896
+ var AUTHORITY_PREFIX = /^(?:[^#/:?]+:)?\/\/([^/?#]*)/;
12897
+ var AUTHORITY_INTRODUCER_REGION = /^(?:[^#/:?]+:)?([/\\\t\n\r]*)/;
12898
+ function getParseError(parsed, matches) {
12899
+ if (matches[2] !== undefined && parsed.path && parsed.path[0] !== "/") {
12900
+ return 'URI path must start with "/" when authority is present.';
12901
+ }
12902
+ if (typeof parsed.port === "number" && (parsed.port < 0 || parsed.port > 65535)) {
12903
+ return "URI port is malformed.";
12904
+ }
12905
+ return;
12906
+ }
12907
+ function hasMalformedPercentEncoding(component) {
12908
+ if (component === undefined)
12909
+ return false;
12910
+ let percent = component.indexOf("%");
12911
+ while (percent !== -1) {
12912
+ if (percent + 2 >= component.length || !/^[\da-f]{2}$/iu.test(component.slice(percent + 1, percent + 3))) {
12913
+ return true;
12914
+ }
12915
+ percent = component.indexOf("%", percent + 3);
12916
+ }
12917
+ return false;
12918
+ }
12919
+ function isIPLiteral(host) {
12920
+ return host[0] === "[" && host[host.length - 1] === "]";
12921
+ }
12922
+ function hasMalformedComponentPercentEncoding(matches) {
12923
+ const host = matches[4];
12924
+ return hasMalformedPercentEncoding(matches[3]) || host !== undefined && !isIPLiteral(host) && hasMalformedPercentEncoding(host) || hasMalformedPercentEncoding(matches[6]) || hasMalformedPercentEncoding(matches[7]) || hasMalformedPercentEncoding(matches[8]);
12925
+ }
12926
+ function canonicalizeHost(parsed, options, schemeHandler, isIP) {
12927
+ if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport) && parsed.host && !isIPLiteral(parsed.host) && (options.domainHost || schemeHandler && schemeHandler.domainHost) && isIP === false && nonSimpleDomain(parsed.host)) {
12928
+ try {
12929
+ parsed.host = new URL("http://" + parsed.host).hostname;
12930
+ } catch (e) {
12931
+ parsed.error = parsed.error || "Host's domain name can not be converted to ASCII: " + e;
12932
+ return true;
12933
+ }
12934
+ }
12935
+ return false;
12936
+ }
12937
+ function parseWithStatus(uri, opts) {
12576
12938
  const options = Object.assign({}, opts);
12577
12939
  const parsed = {
12578
12940
  scheme: undefined,
@@ -12583,6 +12945,12 @@ var require_fast_uri = __commonJS(function(exports, module) {
12583
12945
  query: undefined,
12584
12946
  fragment: undefined
12585
12947
  };
12948
+ let malformedAuthorityOrPort = false;
12949
+ let malformedPercentEncoding = false;
12950
+ let malformedSchemeSpecific = false;
12951
+ let malformedHost = false;
12952
+ let malformedIPLiteral = false;
12953
+ let malformedScheme = false;
12586
12954
  let isIP = false;
12587
12955
  if (options.reference === "suffix") {
12588
12956
  if (options.scheme) {
@@ -12591,6 +12959,25 @@ var require_fast_uri = __commonJS(function(exports, module) {
12591
12959
  uri = "//" + uri;
12592
12960
  }
12593
12961
  }
12962
+ const authorityMatch = uri.match(AUTHORITY_PREFIX);
12963
+ if (authorityMatch !== null && authorityMatch[1].indexOf("\\") !== -1) {
12964
+ parsed.error = "URI authority must not contain a literal backslash.";
12965
+ malformedAuthorityOrPort = true;
12966
+ }
12967
+ const introducerMatch = uri.match(AUTHORITY_INTRODUCER_REGION);
12968
+ if (introducerMatch !== null) {
12969
+ const region = introducerMatch[1];
12970
+ const normalizedRegion = region.replace(/[\t\n\r]/g, "");
12971
+ if (normalizedRegion.length >= 2) {
12972
+ if (normalizedRegion.slice(0, 2) !== "//") {
12973
+ parsed.error = parsed.error || "URI authority must not contain a literal backslash.";
12974
+ malformedAuthorityOrPort = true;
12975
+ } else if (region.length !== normalizedRegion.length) {
12976
+ parsed.error = parsed.error || "URI authority introducer must not contain whitespace.";
12977
+ malformedAuthorityOrPort = true;
12978
+ }
12979
+ }
12980
+ }
12594
12981
  const matches = uri.match(URI_PARSE);
12595
12982
  if (matches) {
12596
12983
  parsed.scheme = matches[1];
@@ -12600,15 +12987,40 @@ var require_fast_uri = __commonJS(function(exports, module) {
12600
12987
  parsed.path = matches[6] || "";
12601
12988
  parsed.query = matches[7];
12602
12989
  parsed.fragment = matches[8];
12990
+ if (parsed.scheme !== undefined) {
12991
+ const decodedScheme = unescape(parsed.scheme);
12992
+ if (VALID_SCHEME.test(decodedScheme)) {
12993
+ parsed.scheme = decodedScheme.toLowerCase();
12994
+ } else {
12995
+ parsed.error = parsed.error || MALFORMED_SCHEME_ERROR;
12996
+ malformedScheme = true;
12997
+ }
12998
+ }
12999
+ malformedPercentEncoding = hasMalformedComponentPercentEncoding(matches);
13000
+ if (malformedPercentEncoding) {
13001
+ parsed.error = parsed.error || "URI contains malformed percent-encoding.";
13002
+ }
12603
13003
  if (isNaN(parsed.port)) {
12604
13004
  parsed.port = matches[5];
12605
13005
  }
13006
+ const parseError = getParseError(parsed, matches);
13007
+ if (parseError !== undefined) {
13008
+ parsed.error = parsed.error || parseError;
13009
+ malformedAuthorityOrPort = true;
13010
+ }
12606
13011
  if (parsed.host) {
12607
13012
  const ipv4result = isIPv4(parsed.host);
12608
13013
  if (ipv4result === false) {
13014
+ const bracketedIPLiteral = isIPLiteral(parsed.host);
13015
+ const hasIPLiteralBracket = parsed.host.indexOf("[") !== -1 || parsed.host.indexOf("]") !== -1;
12609
13016
  const ipv6result = normalizeIPv6(parsed.host);
12610
- parsed.host = ipv6result.host.toLowerCase();
12611
- isIP = ipv6result.isIPV6;
13017
+ isIP = ipv6result.isIPV6 || ipv6result.isIPVFuture === true;
13018
+ malformedIPLiteral = hasIPLiteralBracket && (!bracketedIPLiteral || ipv6result.error === true);
13019
+ parsed.host = isIP ? ipv6result.host : ipv6result.host.toLowerCase();
13020
+ if (malformedIPLiteral) {
13021
+ parsed.error = parsed.error || "URI host is malformed.";
13022
+ malformedAuthorityOrPort = true;
13023
+ }
12612
13024
  } else {
12613
13025
  isIP = true;
12614
13026
  }
@@ -12626,38 +13038,67 @@ var require_fast_uri = __commonJS(function(exports, module) {
12626
13038
  parsed.error = parsed.error || "URI is not a " + options.reference + " reference.";
12627
13039
  }
12628
13040
  const schemeHandler = getSchemeHandler(options.scheme || parsed.scheme);
12629
- if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport)) {
12630
- if (parsed.host && (options.domainHost || schemeHandler && schemeHandler.domainHost) && isIP === false && nonSimpleDomain(parsed.host)) {
12631
- try {
12632
- parsed.host = URL.domainToASCII(parsed.host.toLowerCase());
12633
- } catch (e) {
12634
- parsed.error = parsed.error || "Host's domain name can not be converted to ASCII: " + e;
12635
- }
13041
+ if (!malformedIPLiteral) {
13042
+ malformedHost = canonicalizeHost(parsed, options, schemeHandler, isIP);
13043
+ }
13044
+ if (uri.indexOf("%") !== -1 && parsed.host !== undefined && !malformedIPLiteral) {
13045
+ let host = isIP ? parsed.host : normalizePercentEncoding(parsed.host, true);
13046
+ if (!isIP) {
13047
+ host = normalizePercentEncoding(host.toLowerCase());
12636
13048
  }
13049
+ parsed.host = reescapeHostDelimiters(host, isIP);
12637
13050
  }
12638
13051
  if (!schemeHandler || schemeHandler && !schemeHandler.skipNormalize) {
12639
- if (uri.indexOf("%") !== -1) {
12640
- if (parsed.scheme !== undefined) {
12641
- parsed.scheme = unescape(parsed.scheme);
12642
- }
12643
- if (parsed.host !== undefined) {
12644
- parsed.host = unescape(parsed.host);
12645
- }
12646
- }
12647
13052
  if (parsed.path) {
12648
- parsed.path = escape(unescape(parsed.path));
13053
+ parsed.path = normalizePathEncoding(parsed.path);
13054
+ }
13055
+ if (parsed.query) {
13056
+ parsed.query = normalizeQueryFragmentEncoding(parsed.query);
12649
13057
  }
12650
13058
  if (parsed.fragment) {
12651
- parsed.fragment = encodeURI(decodeURIComponent(parsed.fragment));
13059
+ parsed.fragment = normalizeQueryFragmentEncoding(parsed.fragment);
12652
13060
  }
12653
13061
  }
12654
13062
  if (schemeHandler && schemeHandler.parse) {
12655
13063
  schemeHandler.parse(parsed, options);
13064
+ if (schemeHandler === SCHEMES.urn && parsed.nid === undefined) {
13065
+ malformedSchemeSpecific = true;
13066
+ }
12656
13067
  }
12657
13068
  } else {
12658
13069
  parsed.error = parsed.error || "URI can not be parsed.";
12659
13070
  }
12660
- return parsed;
13071
+ return { parsed, malformedAuthorityOrPort, malformedPercentEncoding, malformedSchemeSpecific, malformedHost, malformedScheme };
13072
+ }
13073
+ function parse(uri, opts) {
13074
+ return parseWithStatus(uri, opts).parsed;
13075
+ }
13076
+ function normalizeString(uri, opts) {
13077
+ return normalizeStringWithStatus(uri, opts).normalized;
13078
+ }
13079
+ function normalizeStringWithStatus(uri, opts) {
13080
+ const { parsed, malformedAuthorityOrPort, malformedPercentEncoding, malformedSchemeSpecific, malformedHost, malformedScheme } = parseWithStatus(uri, opts);
13081
+ return {
13082
+ normalized: malformedAuthorityOrPort || malformedPercentEncoding || malformedSchemeSpecific || malformedHost || malformedScheme ? uri : serialize(parsed, opts),
13083
+ malformedAuthorityOrPort,
13084
+ malformedPercentEncoding,
13085
+ malformedSchemeSpecific,
13086
+ malformedHost,
13087
+ malformedScheme
13088
+ };
13089
+ }
13090
+ function normalizeComparableURI(uri, opts) {
13091
+ if (typeof uri !== "string" && typeof uri !== "object") {
13092
+ return;
13093
+ }
13094
+ let value;
13095
+ try {
13096
+ value = typeof uri === "string" ? uri : serialize(uri, opts);
13097
+ } catch {
13098
+ return;
13099
+ }
13100
+ const { normalized, malformedAuthorityOrPort, malformedPercentEncoding, malformedSchemeSpecific, malformedHost, malformedScheme } = normalizeStringWithStatus(value, opts);
13101
+ return malformedAuthorityOrPort || malformedPercentEncoding || malformedSchemeSpecific || malformedHost || malformedScheme ? undefined : normalized;
12661
13102
  }
12662
13103
  var fastUri = {
12663
13104
  SCHEMES,
@@ -12792,7 +13233,7 @@ var require_core = __commonJS(function(exports) {
12792
13233
  constructor(opts = {}) {
12793
13234
  this.schemas = {};
12794
13235
  this.refs = {};
12795
- this.formats = {};
13236
+ this.formats = Object.create(null);
12796
13237
  this._compilations = new Set;
12797
13238
  this._loading = {};
12798
13239
  this._cache = new Map;
@@ -13533,6 +13974,7 @@ var require_limitLength = __commonJS(function(exports) {
13533
13974
  var require_pattern = __commonJS(function(exports) {
13534
13975
  Object.defineProperty(exports, "__esModule", { value: true });
13535
13976
  var code_1 = require_code2();
13977
+ var util_1 = require_util();
13536
13978
  var codegen_1 = require_codegen();
13537
13979
  var error = {
13538
13980
  message: ({ schemaCode }) => (0, codegen_1.str)`must match pattern "${schemaCode}"`,
@@ -13545,10 +13987,18 @@ var require_pattern = __commonJS(function(exports) {
13545
13987
  $data: true,
13546
13988
  error,
13547
13989
  code(cxt) {
13548
- const { data, $data, schema, schemaCode, it } = cxt;
13990
+ const { gen, data, $data, schema, schemaCode, it } = cxt;
13549
13991
  const u = it.opts.unicodeRegExp ? "u" : "";
13550
- const regExp = $data ? (0, codegen_1._)`(new RegExp(${schemaCode}, ${u}))` : (0, code_1.usePattern)(cxt, schema);
13551
- cxt.fail$data((0, codegen_1._)`!${regExp}.test(${data})`);
13992
+ if ($data) {
13993
+ const { regExp } = it.opts.code;
13994
+ const regExpCode = regExp.code === "new RegExp" ? (0, codegen_1._)`new RegExp` : (0, util_1.useFunc)(gen, regExp);
13995
+ const valid = gen.let("valid");
13996
+ gen.try(() => gen.assign(valid, (0, codegen_1._)`${regExpCode}(${schemaCode}, ${u}).test(${data})`), () => gen.assign(valid, false));
13997
+ cxt.fail$data((0, codegen_1._)`!${valid}`);
13998
+ } else {
13999
+ const regExp = (0, code_1.usePattern)(cxt, schema);
14000
+ cxt.fail$data((0, codegen_1._)`!${regExp}.test(${data})`);
14001
+ }
13552
14002
  }
13553
14003
  };
13554
14004
  exports.default = def;
@@ -57026,36 +57476,38 @@ var require_Alias = __commonJS(function(exports) {
57026
57476
  if (node.anchor === this.source)
57027
57477
  found = node;
57028
57478
  }
57479
+ if (found && ctx) {
57480
+ const { anchors, doc, maxAliasCount } = ctx;
57481
+ let data = anchors.get(found);
57482
+ if (!data) {
57483
+ toJS.toJS(found, null, ctx);
57484
+ data = anchors.get(found);
57485
+ }
57486
+ if (data?.res === undefined) {
57487
+ const msg = "This should not happen: Alias anchor was not resolved?";
57488
+ throw new ReferenceError(msg);
57489
+ }
57490
+ if (maxAliasCount >= 0) {
57491
+ data.count += 1;
57492
+ if (data.aliasCount === 0)
57493
+ data.aliasCount = getAliasCount(doc, found, anchors);
57494
+ if (data.count * data.aliasCount > maxAliasCount) {
57495
+ const msg = "Excessive alias count indicates a resource exhaustion attack";
57496
+ throw new ReferenceError(msg);
57497
+ }
57498
+ }
57499
+ }
57029
57500
  return found;
57030
57501
  }
57031
57502
  toJSON(_arg, ctx) {
57032
57503
  if (!ctx)
57033
57504
  return { source: this.source };
57034
- const { anchors, doc, maxAliasCount } = ctx;
57035
- const source = this.resolve(doc, ctx);
57505
+ const source = this.resolve(ctx.doc, ctx);
57036
57506
  if (!source) {
57037
57507
  const msg = `Unresolved alias (the anchor must be set before the alias): ${this.source}`;
57038
57508
  throw new ReferenceError(msg);
57039
57509
  }
57040
- let data = anchors.get(source);
57041
- if (!data) {
57042
- toJS.toJS(source, null, ctx);
57043
- data = anchors.get(source);
57044
- }
57045
- if (data?.res === undefined) {
57046
- const msg = "This should not happen: Alias anchor was not resolved?";
57047
- throw new ReferenceError(msg);
57048
- }
57049
- if (maxAliasCount >= 0) {
57050
- data.count += 1;
57051
- if (data.aliasCount === 0)
57052
- data.aliasCount = getAliasCount(doc, source, anchors);
57053
- if (data.count * data.aliasCount > maxAliasCount) {
57054
- const msg = "Excessive alias count indicates a resource exhaustion attack";
57055
- throw new ReferenceError(msg);
57056
- }
57057
- }
57058
- return data.res;
57510
+ return ctx.anchors.get(source).res;
57059
57511
  }
57060
57512
  toString(ctx, _onComment, _onChompKeep) {
57061
57513
  const src = `*${this.source}`;
@@ -60817,33 +61269,32 @@ var require_resolve_flow_scalar = __commonJS(function(exports) {
60817
61269
  }
60818
61270
  if (badChar)
60819
61271
  onError(0, "BAD_SCALAR_START", `Plain value cannot start with ${badChar}`);
60820
- return foldLines(source);
61272
+ return unfoldLines(source);
60821
61273
  }
60822
61274
  function singleQuotedValue(source, onError) {
60823
61275
  if (source[source.length - 1] !== "'" || source.length === 1)
60824
61276
  onError(source.length, "MISSING_CHAR", "Missing closing 'quote");
60825
- return foldLines(source.slice(1, -1)).replace(/''/g, "'");
61277
+ return unfoldLines(source.slice(1, -1)).replace(/''/g, "'");
60826
61278
  }
60827
- function foldLines(source) {
60828
- let first, line;
61279
+ function unfoldLines(source) {
61280
+ const line = /(.*?)\r?\n/sy;
61281
+ let match = line.exec(source);
61282
+ if (!match)
61283
+ return source;
61284
+ let trimEnd, trimBoth;
60829
61285
  try {
60830
- first = new RegExp(`(.*?)(?<![ ])[ ]*\r?
60831
- `, "sy");
60832
- line = new RegExp(`[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?
60833
- `, "sy");
61286
+ trimEnd = new RegExp("(?<![ \t])[ \t]+$");
61287
+ trimBoth = new RegExp("^[ \t]+|(?<![ \t])[ \t]+$", "g");
60834
61288
  } catch {
60835
- first = /(.*?)[ \t]*\r?\n/sy;
60836
- line = /[ \t]*(.*?)[ \t]*\r?\n/sy;
61289
+ trimEnd = /[ \t]+$/;
61290
+ trimBoth = /^[ \t]+|[ \t]+$/g;
60837
61291
  }
60838
- let match = first.exec(source);
60839
- if (!match)
60840
- return source;
60841
- let res = match[1];
61292
+ let res = match[1].replace(trimEnd, "");
60842
61293
  let sep = " ";
60843
- let pos = first.lastIndex;
60844
- line.lastIndex = pos;
61294
+ let pos = line.lastIndex;
60845
61295
  while (match = line.exec(source)) {
60846
- if (match[1] === "") {
61296
+ const lm = match[1].replace(trimBoth, "");
61297
+ if (lm === "") {
60847
61298
  if (sep === `
60848
61299
  `)
60849
61300
  res += sep;
@@ -60851,7 +61302,7 @@ var require_resolve_flow_scalar = __commonJS(function(exports) {
60851
61302
  sep = `
60852
61303
  `;
60853
61304
  } else {
60854
- res += sep + match[1];
61305
+ res += sep + lm;
60855
61306
  sep = " ";
60856
61307
  }
60857
61308
  pos = line.lastIndex;
@@ -67863,9 +68314,10 @@ var require_errors3 = __commonJS(function(exports) {
67863
68314
  }
67864
68315
  var key;
67865
68316
  var i;
67866
- function ParseError(message, locator) {
68317
+ function ParseError(message, locator, cause) {
67867
68318
  this.message = message;
67868
68319
  this.locator = locator;
68320
+ this.cause = cause;
67869
68321
  if (Error.captureStackTrace)
67870
68322
  Error.captureStackTrace(this, ParseError);
67871
68323
  }
@@ -67918,7 +68370,7 @@ var require_grammar = __commonJS(function(exports) {
67918
68370
  throw new Error("use regg instead of reg to wrap expressions with `|`!");
67919
68371
  }
67920
68372
  return isStr ? part : part.source;
67921
- }).join(""), UNICODE_SUPPORT ? "mu" : "m");
68373
+ }).join(""), UNICODE_SUPPORT ? "u" : "");
67922
68374
  }
67923
68375
  function regg(args) {
67924
68376
  if (arguments.length === 0) {
@@ -67943,6 +68395,7 @@ var require_grammar = __commonJS(function(exports) {
67943
68395
  var NameStartChar_s = chars(NameStartChar);
67944
68396
  var NameChar = reg("[", NameStartChar_s, chars(/[-.0-9\xB7]/), chars(/[\u0300-\u036F\u203F-\u2040]/), "]");
67945
68397
  var Name = reg(NameStartChar, NameChar, "*");
68398
+ var Name_exact = reg("^", Name, "$");
67946
68399
  var Nmtoken = reg(NameChar, "+");
67947
68400
  var EntityRef = reg("&", Name, ";");
67948
68401
  var CharRef = regg(/&#[0-9]+;|&#x[0-9a-fA-F]+;/);
@@ -67953,11 +68406,12 @@ var require_grammar = __commonJS(function(exports) {
67953
68406
  var NCNameStartChar = chars_without(NameStartChar, ":");
67954
68407
  var NCNameChar = chars_without(NameChar, ":");
67955
68408
  var NCName = reg(NCNameStartChar, NCNameChar, "*");
68409
+ var NCName_exact = reg("^", NCName, "$");
67956
68410
  var QName = reg(NCName, regg(":", NCName), "?");
67957
68411
  var QName_exact = reg("^", QName, "$");
67958
68412
  var QName_group = reg("(", QName, ")");
67959
68413
  var SystemLiteral = regg(/"[^"]*"|'[^']*'/);
67960
- var PI = reg(/^<\?/, "(", Name, ")", regg(S, "(", Char, "*?)"), "?", /\?>/);
68414
+ var PI = reg(/^<\?/, "(", Name, ")", regg(S, "(?!", _SChar, ")(", Char, "*?)"), "?", /\?>/);
67961
68415
  var PubidChar = /[\x20\x0D\x0Aa-zA-Z0-9-'()+,./:=?;!*#@$_%]/;
67962
68416
  var PubidLiteral = regg('"', PubidChar, '*"', "|", "'", chars_without(PubidChar, "'"), "*'");
67963
68417
  var COMMENT_START = "<!--";
@@ -68031,6 +68485,8 @@ var require_grammar = __commonJS(function(exports) {
68031
68485
  exports.ExternalID = ExternalID;
68032
68486
  exports.ExternalID_match = ExternalID_match;
68033
68487
  exports.Name = Name;
68488
+ exports.Name_exact = Name_exact;
68489
+ exports.NCName_exact = NCName_exact;
68034
68490
  exports.NotationDecl = NotationDecl;
68035
68491
  exports.Reference = Reference;
68036
68492
  exports.PEReference = PEReference;
@@ -68266,7 +68722,10 @@ var require_dom = __commonJS(function(exports) {
68266
68722
  return this[i] || null;
68267
68723
  };
68268
68724
  _extends(LiveNodeList, NodeList);
68269
- function NamedNodeMap() {}
68725
+ function NamedNodeMap() {
68726
+ this._nsIndex = Object.create(null);
68727
+ this._noNsIndex = Object.create(null);
68728
+ }
68270
68729
  function _findNodeIndex(list, node) {
68271
68730
  var i = 0;
68272
68731
  while (i < list.length) {
@@ -68276,6 +68735,30 @@ var require_dom = __commonJS(function(exports) {
68276
68735
  i++;
68277
68736
  }
68278
68737
  }
68738
+ function _nnmBucket(map, namespaceURI, create) {
68739
+ if (!namespaceURI) {
68740
+ return map._noNsIndex;
68741
+ }
68742
+ var bucket = map._nsIndex[namespaceURI];
68743
+ if (!bucket && create) {
68744
+ bucket = map._nsIndex[namespaceURI] = Object.create(null);
68745
+ }
68746
+ return bucket;
68747
+ }
68748
+ function _nnmIndexFind(map, namespaceURI, localName) {
68749
+ var bucket = _nnmBucket(map, namespaceURI, false);
68750
+ var found = bucket && bucket[localName];
68751
+ return found ? found : null;
68752
+ }
68753
+ function _nnmIndexAdd(map, attr) {
68754
+ _nnmBucket(map, attr.namespaceURI, true)[attr.localName] = attr;
68755
+ }
68756
+ function _nnmIndexRemove(map, attr) {
68757
+ var bucket = _nnmBucket(map, attr.namespaceURI, false);
68758
+ if (bucket) {
68759
+ delete bucket[attr.localName];
68760
+ }
68761
+ }
68279
68762
  function _addNamedNode(el, list, newAttr, oldAttr) {
68280
68763
  if (oldAttr) {
68281
68764
  list[_findNodeIndex(list, oldAttr)] = newAttr;
@@ -68283,6 +68766,7 @@ var require_dom = __commonJS(function(exports) {
68283
68766
  list[list.length] = newAttr;
68284
68767
  list.length++;
68285
68768
  }
68769
+ _nnmIndexAdd(list, newAttr);
68286
68770
  if (el) {
68287
68771
  newAttr.ownerElement = el;
68288
68772
  var doc = el.ownerDocument;
@@ -68300,6 +68784,7 @@ var require_dom = __commonJS(function(exports) {
68300
68784
  list[i] = list[++i];
68301
68785
  }
68302
68786
  list.length = lastIndex;
68787
+ _nnmIndexRemove(list, attr);
68303
68788
  if (el) {
68304
68789
  var doc = el.ownerDocument;
68305
68790
  if (doc) {
@@ -68331,7 +68816,7 @@ var require_dom = __commonJS(function(exports) {
68331
68816
  if (el && el !== this._ownerElement) {
68332
68817
  throw new DOMException2(DOMException2.INUSE_ATTRIBUTE_ERR);
68333
68818
  }
68334
- var oldAttr = this.getNamedItemNS(attr.namespaceURI, attr.localName);
68819
+ var oldAttr = _nnmIndexFind(this, attr.namespaceURI, attr.localName);
68335
68820
  if (oldAttr === attr) {
68336
68821
  return attr;
68337
68822
  }
@@ -68590,8 +69075,29 @@ var require_dom = __commonJS(function(exports) {
68590
69075
  while (child) {
68591
69076
  var next = child.nextSibling;
68592
69077
  if (next !== null && next.nodeType === TEXT_NODE && child.nodeType === TEXT_NODE) {
68593
- node.removeChild(next);
68594
- child.appendData(next.data);
69078
+ var tail = [];
69079
+ var sibling = next;
69080
+ while (sibling !== null && sibling.nodeType === TEXT_NODE) {
69081
+ tail.push(sibling.data);
69082
+ sibling = sibling.nextSibling;
69083
+ }
69084
+ var removed = child.nextSibling;
69085
+ while (removed !== sibling) {
69086
+ var following = removed.nextSibling;
69087
+ removed.parentNode = null;
69088
+ removed.previousSibling = null;
69089
+ removed.nextSibling = null;
69090
+ removed = following;
69091
+ }
69092
+ child.nextSibling = sibling;
69093
+ if (sibling !== null) {
69094
+ sibling.previousSibling = child;
69095
+ } else {
69096
+ node.lastChild = child;
69097
+ }
69098
+ child.appendData(tail.join(""));
69099
+ _onUpdateChild(node.ownerDocument, node);
69100
+ child = sibling;
68595
69101
  } else {
68596
69102
  child = next;
68597
69103
  }
@@ -69081,7 +69587,7 @@ var require_dom = __commonJS(function(exports) {
69081
69587
  return node;
69082
69588
  },
69083
69589
  createEntityReference: function(name) {
69084
- if (!g.Name.test(name)) {
69590
+ if (!g.Name_exact.test(name)) {
69085
69591
  throw new DOMException2(DOMException2.INVALID_CHARACTER_ERR, 'not a valid xml name "' + name + '"');
69086
69592
  }
69087
69593
  if (this.type === "html") {
@@ -69419,7 +69925,10 @@ var require_dom = __commonJS(function(exports) {
69419
69925
  }
69420
69926
  return true;
69421
69927
  }
69422
- function addSerializedAttribute(buf, qualifiedName, value) {
69928
+ function addSerializedAttribute(buf, qualifiedName, value, requireWellFormed) {
69929
+ if (requireWellFormed && !g.QName_exact.test(qualifiedName)) {
69930
+ throw new DOMException2('The attribute name "' + qualifiedName + '" is not a valid XML QName', DOMExceptionName.InvalidStateError);
69931
+ }
69423
69932
  buf.push(" ", qualifiedName, '="', value.replace(/[<>&"\t\n\r]/g, _xmlEncoder), '"');
69424
69933
  }
69425
69934
  function serializeToString(node, buf, visibleNamespaces, opts) {
@@ -69480,6 +69989,9 @@ var require_dom = __commonJS(function(exports) {
69480
69989
  }
69481
69990
  }
69482
69991
  }
69992
+ if (requireWellFormed && !g.QName_exact.test(prefixedNodeName)) {
69993
+ throw new DOMException2('The element name "' + prefixedNodeName + '" is not a valid XML QName', DOMExceptionName.InvalidStateError);
69994
+ }
69483
69995
  buf.push("<", prefixedNodeName);
69484
69996
  var childNamespaces = namespaces.slice();
69485
69997
  for (var i = 0;i < len; i++) {
@@ -69498,7 +70010,7 @@ var require_dom = __commonJS(function(exports) {
69498
70010
  if (needNamespaceDefine(attr, isHTML, childNamespaces)) {
69499
70011
  var attrPrefix = attr.prefix || "";
69500
70012
  var uri = attr.namespaceURI;
69501
- addSerializedAttribute(buf, attrPrefix ? "xmlns:" + attrPrefix : "xmlns", uri);
70013
+ addSerializedAttribute(buf, attrPrefix ? "xmlns:" + attrPrefix : "xmlns", uri, requireWellFormed);
69502
70014
  childNamespaces.push({ prefix: attrPrefix, namespace: uri });
69503
70015
  }
69504
70016
  var filteredAttr = nodeFilter ? nodeFilter(attr) : attr;
@@ -69506,14 +70018,14 @@ var require_dom = __commonJS(function(exports) {
69506
70018
  if (typeof filteredAttr === "string") {
69507
70019
  buf.push(filteredAttr);
69508
70020
  } else {
69509
- addSerializedAttribute(buf, filteredAttr.name, filteredAttr.value);
70021
+ addSerializedAttribute(buf, filteredAttr.name, filteredAttr.value, requireWellFormed);
69510
70022
  }
69511
70023
  }
69512
70024
  }
69513
70025
  if (nodeName === prefixedNodeName && needNamespaceDefine(n, isHTML, childNamespaces)) {
69514
70026
  var nodePrefix = n.prefix || "";
69515
70027
  var uri = n.namespaceURI;
69516
- addSerializedAttribute(buf, nodePrefix ? "xmlns:" + nodePrefix : "xmlns", uri);
70028
+ addSerializedAttribute(buf, nodePrefix ? "xmlns:" + nodePrefix : "xmlns", uri, requireWellFormed);
69517
70029
  childNamespaces.push({ prefix: nodePrefix, namespace: uri });
69518
70030
  }
69519
70031
  var canCloseTag = !n.firstChild;
@@ -69546,7 +70058,7 @@ var require_dom = __commonJS(function(exports) {
69546
70058
  }
69547
70059
  return { ns: namespaces };
69548
70060
  case ATTRIBUTE_NODE:
69549
- addSerializedAttribute(buf, n.name, n.value);
70061
+ addSerializedAttribute(buf, n.name, n.value, requireWellFormed);
69550
70062
  return null;
69551
70063
  case TEXT_NODE:
69552
70064
  if (requireWellFormed && g.InvalidChar.test(n.data)) {
@@ -69579,6 +70091,9 @@ var require_dom = __commonJS(function(exports) {
69579
70091
  var pubid = n.publicId;
69580
70092
  var sysid = n.systemId;
69581
70093
  if (requireWellFormed) {
70094
+ if (!g.Name_exact.test(n.name)) {
70095
+ throw new DOMException2('The doctype name "' + n.name + '" is not a valid XML Name', DOMExceptionName.InvalidStateError);
70096
+ }
69582
70097
  if (pubid && !g.PubidLiteral_match.test(pubid)) {
69583
70098
  throw new DOMException2("DocumentType publicId is not a valid PubidLiteral", DOMExceptionName.InvalidStateError);
69584
70099
  }
@@ -69605,8 +70120,8 @@ var require_dom = __commonJS(function(exports) {
69605
70120
  return null;
69606
70121
  case PROCESSING_INSTRUCTION_NODE:
69607
70122
  if (requireWellFormed) {
69608
- if (n.target.indexOf(":") !== -1 || n.target.toLowerCase() === "xml") {
69609
- throw new DOMException2("The ProcessingInstruction target is not well-formed", DOMExceptionName.InvalidStateError);
70123
+ if (!g.NCName_exact.test(n.target) || n.target.toLowerCase() === "xml") {
70124
+ throw new DOMException2('The processing instruction target "' + n.target + '" is not a valid XML NCName or is reserved', DOMExceptionName.InvalidStateError);
69610
70125
  }
69611
70126
  if (g.InvalidChar.test(n.data)) {
69612
70127
  throw new DOMException2("The ProcessingInstruction data contains characters outside the XML Char production", DOMExceptionName.InvalidStateError);
@@ -69618,6 +70133,9 @@ var require_dom = __commonJS(function(exports) {
69618
70133
  buf.push("<?", n.target, " ", n.data, "?>");
69619
70134
  return null;
69620
70135
  case ENTITY_REFERENCE_NODE:
70136
+ if (requireWellFormed && !g.Name_exact.test(n.nodeName)) {
70137
+ throw new DOMException2('The entity reference name "' + n.nodeName + '" is not a valid XML Name', DOMExceptionName.InvalidStateError);
70138
+ }
69621
70139
  buf.push("&", n.nodeName, ";");
69622
70140
  return null;
69623
70141
  default:
@@ -69752,6 +70270,25 @@ var require_dom = __commonJS(function(exports) {
69752
70270
  }
69753
70271
  }
69754
70272
  });
70273
+ Object.defineProperty(CharacterData.prototype, "data", {
70274
+ get: function() {
70275
+ return this._data != null ? this._data : "";
70276
+ },
70277
+ set: function(v) {
70278
+ this._data = v;
70279
+ this.length = typeof v === "string" ? v.length : 0;
70280
+ }
70281
+ });
70282
+ Object.defineProperty(CharacterData.prototype, "nodeValue", {
70283
+ get: function() {
70284
+ return this.data;
70285
+ },
70286
+ set: function(v) {
70287
+ this.data = v;
70288
+ },
70289
+ enumerable: true,
70290
+ configurable: true
70291
+ });
69755
70292
  Object.defineProperty(Element.prototype, "children", {
69756
70293
  get: function() {
69757
70294
  return new LiveNodeList(this, childrenRefresh);
@@ -72058,9 +72595,19 @@ var require_sax = __commonJS(function(exports) {
72058
72595
  if (!tagNameRaw) {
72059
72596
  return errorHandler.fatalError("end tag name missing");
72060
72597
  }
72061
- var tagNameMatch = end > 0 && g.reg("^", g.QName_group, g.S_OPT, "$").exec(tagNameRaw);
72598
+ var endTagNameStrict = g.reg("^", g.QName_group, g.S_OPT, "$");
72599
+ var tagNameMatch = end > 0 && endTagNameStrict.exec(tagNameRaw);
72062
72600
  if (!tagNameMatch) {
72063
- return errorHandler.fatalError('end tag name contains invalid characters: "' + tagNameRaw + '"');
72601
+ var leadingTagNameMatch = end > 0 && g.reg("^", g.QName_group).exec(tagNameRaw);
72602
+ if (isHTML && leadingTagNameMatch) {
72603
+ errorHandler.warning('end tag name contains invalid trailing characters: "' + tagNameRaw + '"');
72604
+ tagNameMatch = leadingTagNameMatch;
72605
+ } else if (leadingTagNameMatch && new RegExp(endTagNameStrict.source, endTagNameStrict.flags + "m").test(tagNameRaw)) {
72606
+ errorHandler.error('end tag name is followed by a line break and trailing content: "' + tagNameRaw + '"');
72607
+ tagNameMatch = leadingTagNameMatch;
72608
+ } else {
72609
+ return errorHandler.fatalError('end tag name contains invalid characters: "' + tagNameRaw + '"');
72610
+ }
72064
72611
  }
72065
72612
  if (!domBuilder.currentElement && !domBuilder.doc.documentElement) {
72066
72613
  return;
@@ -72133,7 +72680,7 @@ var require_sax = __commonJS(function(exports) {
72133
72680
  if (e instanceof ParseError) {
72134
72681
  throw e;
72135
72682
  } else if (e instanceof DOMException2) {
72136
- throw new ParseError(e.name + ": " + e.message, domBuilder.locator, e);
72683
+ return errorHandler.fatalError("Error constructing the DOM: " + e.name + ": " + e.message, e);
72137
72684
  }
72138
72685
  errorHandler.error("element parse error: " + e);
72139
72686
  end = -1;
@@ -72166,6 +72713,9 @@ var require_sax = __commonJS(function(exports) {
72166
72713
  var s = S_TAG;
72167
72714
  while (true) {
72168
72715
  var c = source.charAt(p);
72716
+ if (s === S_TAG && c === "<") {
72717
+ throw new Error("unexpected < in tag name: " + source.slice(start, p));
72718
+ }
72169
72719
  switch (c) {
72170
72720
  case "=":
72171
72721
  if (s === S_ATTR) {
@@ -72334,7 +72884,7 @@ var require_sax = __commonJS(function(exports) {
72334
72884
  if (nsPrefix !== false) {
72335
72885
  if (localNSMap == null) {
72336
72886
  localNSMap = Object.create(null);
72337
- _copy(currentNSMap, currentNSMap = Object.create(null));
72887
+ currentNSMap = Object.create(currentNSMap);
72338
72888
  }
72339
72889
  currentNSMap[nsPrefix] = localNSMap[nsPrefix] = value;
72340
72890
  a.uri = NAMESPACE.XMLNS;
@@ -72381,7 +72931,13 @@ var require_sax = __commonJS(function(exports) {
72381
72931
  function parseHtmlSpecialContent(source, elStartEnd, tagName, entityReplacer, domBuilder) {
72382
72932
  var isEscapableRaw = isHTMLEscapableRawTextElement(tagName);
72383
72933
  if (isEscapableRaw || isHTMLRawTextElement(tagName)) {
72384
- var elEndStart = source.indexOf("</" + tagName + ">", elStartEnd);
72934
+ var closeTag = new RegExp("</" + tagName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&") + ">", "ig");
72935
+ closeTag.lastIndex = elStartEnd;
72936
+ var match = closeTag.exec(source);
72937
+ var elEndStart = match ? match.index : -1;
72938
+ if (elEndStart < 0) {
72939
+ return elStartEnd + 1;
72940
+ }
72385
72941
  var text = source.substring(elStartEnd + 1, elEndStart);
72386
72942
  if (isEscapableRaw) {
72387
72943
  text = text.replace(ENTITY_REG, entityReplacer);
@@ -72842,9 +73398,9 @@ var require_dom_parser = __commonJS(function(exports) {
72842
73398
  error: function(message) {
72843
73399
  this.reportError("error", message);
72844
73400
  },
72845
- fatalError: function(message) {
73401
+ fatalError: function(message, cause) {
72846
73402
  this.reportError("fatalError", message);
72847
- throw new ParseError(message, this.locator);
73403
+ throw new ParseError(message, this.locator, cause);
72848
73404
  }
72849
73405
  };
72850
73406
  function _locator(l) {
@@ -199960,36 +200516,38 @@ var require_Alias2 = __commonJS(function(exports) {
199960
200516
  if (node.anchor === this.source)
199961
200517
  found = node;
199962
200518
  }
200519
+ if (found && ctx) {
200520
+ const { anchors, doc, maxAliasCount } = ctx;
200521
+ let data = anchors.get(found);
200522
+ if (!data) {
200523
+ toJS.toJS(found, null, ctx);
200524
+ data = anchors.get(found);
200525
+ }
200526
+ if (data?.res === undefined) {
200527
+ const msg = "This should not happen: Alias anchor was not resolved?";
200528
+ throw new ReferenceError(msg);
200529
+ }
200530
+ if (maxAliasCount >= 0) {
200531
+ data.count += 1;
200532
+ if (data.aliasCount === 0)
200533
+ data.aliasCount = getAliasCount(doc, found, anchors);
200534
+ if (data.count * data.aliasCount > maxAliasCount) {
200535
+ const msg = "Excessive alias count indicates a resource exhaustion attack";
200536
+ throw new ReferenceError(msg);
200537
+ }
200538
+ }
200539
+ }
199963
200540
  return found;
199964
200541
  }
199965
200542
  toJSON(_arg, ctx) {
199966
200543
  if (!ctx)
199967
200544
  return { source: this.source };
199968
- const { anchors, doc, maxAliasCount } = ctx;
199969
- const source = this.resolve(doc, ctx);
200545
+ const source = this.resolve(ctx.doc, ctx);
199970
200546
  if (!source) {
199971
200547
  const msg = `Unresolved alias (the anchor must be set before the alias): ${this.source}`;
199972
200548
  throw new ReferenceError(msg);
199973
200549
  }
199974
- let data = anchors.get(source);
199975
- if (!data) {
199976
- toJS.toJS(source, null, ctx);
199977
- data = anchors.get(source);
199978
- }
199979
- if (data?.res === undefined) {
199980
- const msg = "This should not happen: Alias anchor was not resolved?";
199981
- throw new ReferenceError(msg);
199982
- }
199983
- if (maxAliasCount >= 0) {
199984
- data.count += 1;
199985
- if (data.aliasCount === 0)
199986
- data.aliasCount = getAliasCount(doc, source, anchors);
199987
- if (data.count * data.aliasCount > maxAliasCount) {
199988
- const msg = "Excessive alias count indicates a resource exhaustion attack";
199989
- throw new ReferenceError(msg);
199990
- }
199991
- }
199992
- return data.res;
200550
+ return ctx.anchors.get(source).res;
199993
200551
  }
199994
200552
  toString(ctx, _onComment, _onChompKeep) {
199995
200553
  const src = `*${this.source}`;
@@ -203751,33 +204309,32 @@ var require_resolve_flow_scalar2 = __commonJS(function(exports) {
203751
204309
  }
203752
204310
  if (badChar)
203753
204311
  onError(0, "BAD_SCALAR_START", `Plain value cannot start with ${badChar}`);
203754
- return foldLines(source);
204312
+ return unfoldLines(source);
203755
204313
  }
203756
204314
  function singleQuotedValue(source, onError) {
203757
204315
  if (source[source.length - 1] !== "'" || source.length === 1)
203758
204316
  onError(source.length, "MISSING_CHAR", "Missing closing 'quote");
203759
- return foldLines(source.slice(1, -1)).replace(/''/g, "'");
204317
+ return unfoldLines(source.slice(1, -1)).replace(/''/g, "'");
203760
204318
  }
203761
- function foldLines(source) {
203762
- let first, line;
204319
+ function unfoldLines(source) {
204320
+ const line = /(.*?)\r?\n/sy;
204321
+ let match = line.exec(source);
204322
+ if (!match)
204323
+ return source;
204324
+ let trimEnd, trimBoth;
203763
204325
  try {
203764
- first = new RegExp(`(.*?)(?<![ ])[ ]*\r?
203765
- `, "sy");
203766
- line = new RegExp(`[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?
203767
- `, "sy");
204326
+ trimEnd = new RegExp("(?<![ \t])[ \t]+$");
204327
+ trimBoth = new RegExp("^[ \t]+|(?<![ \t])[ \t]+$", "g");
203768
204328
  } catch {
203769
- first = /(.*?)[ \t]*\r?\n/sy;
203770
- line = /[ \t]*(.*?)[ \t]*\r?\n/sy;
204329
+ trimEnd = /[ \t]+$/;
204330
+ trimBoth = /^[ \t]+|[ \t]+$/g;
203771
204331
  }
203772
- let match = first.exec(source);
203773
- if (!match)
203774
- return source;
203775
- let res = match[1];
204332
+ let res = match[1].replace(trimEnd, "");
203776
204333
  let sep = " ";
203777
- let pos = first.lastIndex;
203778
- line.lastIndex = pos;
204334
+ let pos = line.lastIndex;
203779
204335
  while (match = line.exec(source)) {
203780
- if (match[1] === "") {
204336
+ const lm = match[1].replace(trimBoth, "");
204337
+ if (lm === "") {
203781
204338
  if (sep === `
203782
204339
  `)
203783
204340
  res += sep;
@@ -203785,7 +204342,7 @@ var require_resolve_flow_scalar2 = __commonJS(function(exports) {
203785
204342
  sep = `
203786
204343
  `;
203787
204344
  } else {
203788
- res += sep + match[1];
204345
+ res += sep + lm;
203789
204346
  sep = " ";
203790
204347
  }
203791
204348
  pos = line.lastIndex;
@@ -206391,7 +206948,7 @@ import { fileURLToPath as fileURLToPath8 } from "url";
206391
206948
  // package.json
206392
206949
  var package_default = {
206393
206950
  name: "@eigenpal/cli",
206394
- version: "0.20.11",
206951
+ version: "0.20.13",
206395
206952
  description: "Eigenpal CLI — author and run document workflows from your terminal. Agent-ready.",
206396
206953
  keywords: [
206397
206954
  "eigenpal",
@@ -206446,11 +207003,11 @@ var package_default = {
206446
207003
  },
206447
207004
  dependencies: {
206448
207005
  "@clack/prompts": "^1.3.0",
206449
- ajv: "^8.17.1",
207006
+ ajv: "8.20.0",
206450
207007
  commander: "^14.0.3",
206451
207008
  fflate: "0.8.3",
206452
207009
  picocolors: "^1.1.1",
206453
- yaml: "^2.7.0",
207010
+ yaml: "2.9.1",
206454
207011
  xlsx: "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz",
206455
207012
  zod: "^4.4.3"
206456
207013
  },