mystmd 1.3.13__py3-none-any.whl → 1.3.14__py3-none-any.whl

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.
mystmd_py/myst.cjs CHANGED
@@ -51243,7 +51243,7 @@ and ensure you are accounting for this risk.
51243
51243
  if (!tagAllowed(name3) || options.disallowedTagsMode === "recursiveEscape" && !isEmptyObject(skipMap) || options.nestingLimit != null && depth >= options.nestingLimit) {
51244
51244
  skip = true;
51245
51245
  skipMap[depth] = true;
51246
- if (options.disallowedTagsMode === "discard") {
51246
+ if (options.disallowedTagsMode === "discard" || options.disallowedTagsMode === "completelyDiscard") {
51247
51247
  if (nonTextTagsArray.indexOf(name3) !== -1) {
51248
51248
  skipText = true;
51249
51249
  skipTextDepth = 1;
@@ -51253,7 +51253,7 @@ and ensure you are accounting for this risk.
51253
51253
  }
51254
51254
  depth++;
51255
51255
  if (skip) {
51256
- if (options.disallowedTagsMode === "discard") {
51256
+ if (options.disallowedTagsMode === "discard" || options.disallowedTagsMode === "completelyDiscard") {
51257
51257
  return;
51258
51258
  }
51259
51259
  tempResult = result;
@@ -51271,7 +51271,7 @@ and ensure you are accounting for this risk.
51271
51271
  delete frame.attribs[a2];
51272
51272
  return;
51273
51273
  }
51274
- if (value === "" && (options.nonBooleanAttributes.includes(a2) || options.nonBooleanAttributes.includes("*"))) {
51274
+ if (value === "" && !options.allowedEmptyAttributes.includes(a2) && (options.nonBooleanAttributes.includes(a2) || options.nonBooleanAttributes.includes("*"))) {
51275
51275
  delete frame.attribs[a2];
51276
51276
  return;
51277
51277
  }
@@ -51382,11 +51382,12 @@ and ensure you are accounting for this risk.
51382
51382
  const allowedWildcardClasses = allowedClassesMap["*"];
51383
51383
  const allowedSpecificClassesGlob = allowedClassesGlobMap[name3];
51384
51384
  const allowedSpecificClassesRegex = allowedClassesRegexMap[name3];
51385
+ const allowedWildcardClassesRegex = allowedClassesRegexMap["*"];
51385
51386
  const allowedWildcardClassesGlob = allowedClassesGlobMap["*"];
51386
51387
  const allowedClassesGlobs = [
51387
51388
  allowedSpecificClassesGlob,
51388
51389
  allowedWildcardClassesGlob
51389
- ].concat(allowedSpecificClassesRegex).filter(function(t2) {
51390
+ ].concat(allowedSpecificClassesRegex, allowedWildcardClassesRegex).filter(function(t2) {
51390
51391
  return t2;
51391
51392
  });
51392
51393
  if (allowedSpecificClasses && allowedWildcardClasses) {
@@ -51402,7 +51403,7 @@ and ensure you are accounting for this risk.
51402
51403
  if (a2 === "style") {
51403
51404
  if (options.parseStyleAttributes) {
51404
51405
  try {
51405
- const abstractSyntaxTree = postcssParse(name3 + " {" + value + "}");
51406
+ const abstractSyntaxTree = postcssParse(name3 + " {" + value + "}", { map: false });
51406
51407
  const filteredAST = filterCss(abstractSyntaxTree, options.allowedStyles);
51407
51408
  value = stringifyStyleAttributes(filteredAST);
51408
51409
  if (value.length === 0) {
@@ -51423,6 +51424,8 @@ and ensure you are accounting for this risk.
51423
51424
  result += " " + a2;
51424
51425
  if (value && value.length) {
51425
51426
  result += '="' + escapeHtml4(value, true) + '"';
51427
+ } else if (options.allowedEmptyAttributes.includes(a2)) {
51428
+ result += '=""';
51426
51429
  }
51427
51430
  } else {
51428
51431
  delete frame.attribs[a2];
@@ -51453,7 +51456,9 @@ and ensure you are accounting for this risk.
51453
51456
  tag = lastFrame.tag;
51454
51457
  text7 = lastFrame.innerText !== void 0 ? lastFrame.innerText : text7;
51455
51458
  }
51456
- if (options.disallowedTagsMode === "discard" && (tag === "script" || tag === "style")) {
51459
+ if (options.disallowedTagsMode === "completelyDiscard" && !tagAllowed(tag)) {
51460
+ text7 = "";
51461
+ } else if ((options.disallowedTagsMode === "discard" || options.disallowedTagsMode === "completelyDiscard") && (tag === "script" || tag === "style")) {
51457
51462
  result += text7;
51458
51463
  } else {
51459
51464
  const escaped = escapeHtml4(text7, false);
@@ -51490,7 +51495,7 @@ and ensure you are accounting for this risk.
51490
51495
  const skip = skipMap[depth];
51491
51496
  if (skip) {
51492
51497
  delete skipMap[depth];
51493
- if (options.disallowedTagsMode === "discard") {
51498
+ if (options.disallowedTagsMode === "discard" || options.disallowedTagsMode === "completelyDiscard") {
51494
51499
  frame.updateParentNodeText();
51495
51500
  return;
51496
51501
  }
@@ -51932,6 +51937,9 @@ and ensure you are accounting for this risk.
51932
51937
  // these attributes would make sense if we did.
51933
51938
  img: ["src", "srcset", "alt", "title", "width", "height", "loading"]
51934
51939
  },
51940
+ allowedEmptyAttributes: [
51941
+ "alt"
51942
+ ],
51935
51943
  // Lots of these won't come up by default because we don't allow them
51936
51944
  selfClosing: ["img", "br", "hr", "area", "base", "basefont", "input", "link", "meta"],
51937
51945
  // URL schemes we permit
@@ -101455,7 +101463,7 @@ var require_utils10 = __commonJS({
101455
101463
  return (Number(max) - Number(min)) / Number(step) >= limit;
101456
101464
  };
101457
101465
  exports2.escapeNode = (block5, n = 0, type2) => {
101458
- let node3 = block5.nodes[n];
101466
+ const node3 = block5.nodes[n];
101459
101467
  if (!node3)
101460
101468
  return;
101461
101469
  if (type2 && node3.type === type2 || node3.type === "open" || node3.type === "close") {
@@ -101506,8 +101514,14 @@ var require_utils10 = __commonJS({
101506
101514
  const result = [];
101507
101515
  const flat = (arr) => {
101508
101516
  for (let i2 = 0; i2 < arr.length; i2++) {
101509
- let ele = arr[i2];
101510
- Array.isArray(ele) ? flat(ele, result) : ele !== void 0 && result.push(ele);
101517
+ const ele = arr[i2];
101518
+ if (Array.isArray(ele)) {
101519
+ flat(ele);
101520
+ continue;
101521
+ }
101522
+ if (ele !== void 0) {
101523
+ result.push(ele);
101524
+ }
101511
101525
  }
101512
101526
  return result;
101513
101527
  };
@@ -101523,9 +101537,9 @@ var require_stringify3 = __commonJS({
101523
101537
  "use strict";
101524
101538
  var utils2 = require_utils10();
101525
101539
  module2.exports = (ast, options = {}) => {
101526
- let stringify4 = (node3, parent2 = {}) => {
101527
- let invalidBlock = options.escapeInvalid && utils2.isInvalidBrace(parent2);
101528
- let invalidNode = node3.invalid === true && options.escapeInvalid === true;
101540
+ const stringify4 = (node3, parent2 = {}) => {
101541
+ const invalidBlock = options.escapeInvalid && utils2.isInvalidBrace(parent2);
101542
+ const invalidNode = node3.invalid === true && options.escapeInvalid === true;
101529
101543
  let output2 = "";
101530
101544
  if (node3.value) {
101531
101545
  if ((invalidBlock || invalidNode) && utils2.isOpenOrClose(node3)) {
@@ -101537,7 +101551,7 @@ var require_stringify3 = __commonJS({
101537
101551
  return node3.value;
101538
101552
  }
101539
101553
  if (node3.nodes) {
101540
- for (let child of node3.nodes) {
101554
+ for (const child of node3.nodes) {
101541
101555
  output2 += stringify4(child);
101542
101556
  }
101543
101557
  }
@@ -101829,7 +101843,7 @@ var require_fill_range = __commonJS({
101829
101843
  input3 = "0" + input3;
101830
101844
  return negative ? "-" + input3 : input3;
101831
101845
  };
101832
- var toSequence = (parts, options) => {
101846
+ var toSequence = (parts, options, maxLen) => {
101833
101847
  parts.negatives.sort((a2, b) => a2 < b ? -1 : a2 > b ? 1 : 0);
101834
101848
  parts.positives.sort((a2, b) => a2 < b ? -1 : a2 > b ? 1 : 0);
101835
101849
  let prefix2 = options.capture ? "" : "?:";
@@ -101837,10 +101851,10 @@ var require_fill_range = __commonJS({
101837
101851
  let negatives = "";
101838
101852
  let result;
101839
101853
  if (parts.positives.length) {
101840
- positives = parts.positives.join("|");
101854
+ positives = parts.positives.map((v) => toMaxLen(String(v), maxLen)).join("|");
101841
101855
  }
101842
101856
  if (parts.negatives.length) {
101843
- negatives = `-(${prefix2}${parts.negatives.join("|")})`;
101857
+ negatives = `-(${prefix2}${parts.negatives.map((v) => toMaxLen(String(v), maxLen)).join("|")})`;
101844
101858
  }
101845
101859
  if (positives && negatives) {
101846
101860
  result = `${positives}|${negatives}`;
@@ -101922,7 +101936,7 @@ var require_fill_range = __commonJS({
101922
101936
  index4++;
101923
101937
  }
101924
101938
  if (options.toRegex === true) {
101925
- return step > 1 ? toSequence(parts, options) : toRegex(range, null, { wrap: false, ...options });
101939
+ return step > 1 ? toSequence(parts, options, maxLen) : toRegex(range, null, { wrap: false, ...options });
101926
101940
  }
101927
101941
  return range;
101928
101942
  };
@@ -101989,16 +102003,17 @@ var require_compile = __commonJS({
101989
102003
  var fill3 = require_fill_range();
101990
102004
  var utils2 = require_utils10();
101991
102005
  var compile2 = (ast, options = {}) => {
101992
- let walk2 = (node3, parent2 = {}) => {
101993
- let invalidBlock = utils2.isInvalidBrace(parent2);
101994
- let invalidNode = node3.invalid === true && options.escapeInvalid === true;
101995
- let invalid3 = invalidBlock === true || invalidNode === true;
101996
- let prefix2 = options.escapeInvalid === true ? "\\" : "";
102006
+ const walk2 = (node3, parent2 = {}) => {
102007
+ const invalidBlock = utils2.isInvalidBrace(parent2);
102008
+ const invalidNode = node3.invalid === true && options.escapeInvalid === true;
102009
+ const invalid3 = invalidBlock === true || invalidNode === true;
102010
+ const prefix2 = options.escapeInvalid === true ? "\\" : "";
101997
102011
  let output2 = "";
101998
102012
  if (node3.isOpen === true) {
101999
102013
  return prefix2 + node3.value;
102000
102014
  }
102001
102015
  if (node3.isClose === true) {
102016
+ console.log("node.isClose", prefix2, node3.value);
102002
102017
  return prefix2 + node3.value;
102003
102018
  }
102004
102019
  if (node3.type === "open") {
@@ -102014,14 +102029,14 @@ var require_compile = __commonJS({
102014
102029
  return node3.value;
102015
102030
  }
102016
102031
  if (node3.nodes && node3.ranges > 0) {
102017
- let args = utils2.reduce(node3.nodes);
102018
- let range = fill3(...args, { ...options, wrap: false, toRegex: true });
102032
+ const args = utils2.reduce(node3.nodes);
102033
+ const range = fill3(...args, { ...options, wrap: false, toRegex: true, strictZeros: true });
102019
102034
  if (range.length !== 0) {
102020
102035
  return args.length > 1 && range.length > 1 ? `(${range})` : range;
102021
102036
  }
102022
102037
  }
102023
102038
  if (node3.nodes) {
102024
- for (let child of node3.nodes) {
102039
+ for (const child of node3.nodes) {
102025
102040
  output2 += walk2(child, node3);
102026
102041
  }
102027
102042
  }
@@ -102041,7 +102056,7 @@ var require_expand = __commonJS({
102041
102056
  var stringify4 = require_stringify3();
102042
102057
  var utils2 = require_utils10();
102043
102058
  var append = (queue = "", stash = "", enclose = false) => {
102044
- let result = [];
102059
+ const result = [];
102045
102060
  queue = [].concat(queue);
102046
102061
  stash = [].concat(stash);
102047
102062
  if (!stash.length)
@@ -102049,9 +102064,9 @@ var require_expand = __commonJS({
102049
102064
  if (!queue.length) {
102050
102065
  return enclose ? utils2.flatten(stash).map((ele) => `{${ele}}`) : stash;
102051
102066
  }
102052
- for (let item of queue) {
102067
+ for (const item of queue) {
102053
102068
  if (Array.isArray(item)) {
102054
- for (let value of item) {
102069
+ for (const value of item) {
102055
102070
  result.push(append(value, stash, enclose));
102056
102071
  }
102057
102072
  } else {
@@ -102065,8 +102080,8 @@ var require_expand = __commonJS({
102065
102080
  return utils2.flatten(result);
102066
102081
  };
102067
102082
  var expand2 = (ast, options = {}) => {
102068
- let rangeLimit = options.rangeLimit === void 0 ? 1e3 : options.rangeLimit;
102069
- let walk2 = (node3, parent2 = {}) => {
102083
+ const rangeLimit = options.rangeLimit === void 0 ? 1e3 : options.rangeLimit;
102084
+ const walk2 = (node3, parent2 = {}) => {
102070
102085
  node3.queue = [];
102071
102086
  let p5 = parent2;
102072
102087
  let q2 = parent2.queue;
@@ -102083,7 +102098,7 @@ var require_expand = __commonJS({
102083
102098
  return;
102084
102099
  }
102085
102100
  if (node3.nodes && node3.ranges > 0) {
102086
- let args = utils2.reduce(node3.nodes);
102101
+ const args = utils2.reduce(node3.nodes);
102087
102102
  if (utils2.exceedsLimit(...args, options.step, rangeLimit)) {
102088
102103
  throw new RangeError("expanded array length exceeds range limit. Use options.rangeLimit to increase or disable the limit.");
102089
102104
  }
@@ -102095,7 +102110,7 @@ var require_expand = __commonJS({
102095
102110
  node3.nodes = [];
102096
102111
  return;
102097
102112
  }
102098
- let enclose = utils2.encloseBrace(node3);
102113
+ const enclose = utils2.encloseBrace(node3);
102099
102114
  let queue = node3.queue;
102100
102115
  let block5 = node3;
102101
102116
  while (block5.type !== "brace" && block5.type !== "root" && block5.parent) {
@@ -102103,7 +102118,7 @@ var require_expand = __commonJS({
102103
102118
  queue = block5.queue;
102104
102119
  }
102105
102120
  for (let i2 = 0; i2 < node3.nodes.length; i2++) {
102106
- let child = node3.nodes[i2];
102121
+ const child = node3.nodes[i2];
102107
102122
  if (child.type === "comma" && node3.type === "brace") {
102108
102123
  if (i2 === 1)
102109
102124
  queue.push("");
@@ -102135,7 +102150,7 @@ var require_constants4 = __commonJS({
102135
102150
  "../../node_modules/braces/lib/constants.js"(exports2, module2) {
102136
102151
  "use strict";
102137
102152
  module2.exports = {
102138
- MAX_LENGTH: 1024 * 64,
102153
+ MAX_LENGTH: 1e4,
102139
102154
  // Digits
102140
102155
  CHAR_0: "0",
102141
102156
  /* 0 */
@@ -102269,21 +102284,20 @@ var require_parse5 = __commonJS({
102269
102284
  if (typeof input3 !== "string") {
102270
102285
  throw new TypeError("Expected a string");
102271
102286
  }
102272
- let opts = options || {};
102273
- let max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
102287
+ const opts = options || {};
102288
+ const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
102274
102289
  if (input3.length > max) {
102275
102290
  throw new SyntaxError(`Input length (${input3.length}), exceeds max characters (${max})`);
102276
102291
  }
102277
- let ast = { type: "root", input: input3, nodes: [] };
102278
- let stack = [ast];
102292
+ const ast = { type: "root", input: input3, nodes: [] };
102293
+ const stack = [ast];
102279
102294
  let block5 = ast;
102280
102295
  let prev = ast;
102281
102296
  let brackets = 0;
102282
- let length = input3.length;
102297
+ const length = input3.length;
102283
102298
  let index4 = 0;
102284
102299
  let depth = 0;
102285
102300
  let value;
102286
- let memo = {};
102287
102301
  const advance = () => input3[index4++];
102288
102302
  const push = (node3) => {
102289
102303
  if (node3.type === "text" && prev.type === "dot") {
@@ -102316,7 +102330,6 @@ var require_parse5 = __commonJS({
102316
102330
  }
102317
102331
  if (value === CHAR_LEFT_SQUARE_BRACKET2) {
102318
102332
  brackets++;
102319
- let closed = true;
102320
102333
  let next;
102321
102334
  while (index4 < length && (next = advance())) {
102322
102335
  value += next;
@@ -102355,7 +102368,7 @@ var require_parse5 = __commonJS({
102355
102368
  continue;
102356
102369
  }
102357
102370
  if (value === CHAR_DOUBLE_QUOTE2 || value === CHAR_SINGLE_QUOTE2 || value === CHAR_BACKTICK) {
102358
- let open2 = value;
102371
+ const open2 = value;
102359
102372
  let next;
102360
102373
  if (options.keepQuotes !== true) {
102361
102374
  value = "";
@@ -102377,8 +102390,8 @@ var require_parse5 = __commonJS({
102377
102390
  }
102378
102391
  if (value === CHAR_LEFT_CURLY_BRACE) {
102379
102392
  depth++;
102380
- let dollar = prev.value && prev.value.slice(-1) === "$" || block5.dollar === true;
102381
- let brace = {
102393
+ const dollar = prev.value && prev.value.slice(-1) === "$" || block5.dollar === true;
102394
+ const brace = {
102382
102395
  type: "brace",
102383
102396
  open: true,
102384
102397
  close: false,
@@ -102398,7 +102411,7 @@ var require_parse5 = __commonJS({
102398
102411
  push({ type: "text", value });
102399
102412
  continue;
102400
102413
  }
102401
- let type2 = "close";
102414
+ const type2 = "close";
102402
102415
  block5 = stack.pop();
102403
102416
  block5.close = true;
102404
102417
  push({ type: type2, value });
@@ -102409,7 +102422,7 @@ var require_parse5 = __commonJS({
102409
102422
  if (value === CHAR_COMMA2 && depth > 0) {
102410
102423
  if (block5.ranges > 0) {
102411
102424
  block5.ranges = 0;
102412
- let open2 = block5.nodes.shift();
102425
+ const open2 = block5.nodes.shift();
102413
102426
  block5.nodes = [open2, { type: "text", value: stringify4(block5) }];
102414
102427
  }
102415
102428
  push({ type: "comma", value });
@@ -102417,7 +102430,7 @@ var require_parse5 = __commonJS({
102417
102430
  continue;
102418
102431
  }
102419
102432
  if (value === CHAR_DOT && depth > 0 && block5.commas === 0) {
102420
- let siblings2 = block5.nodes;
102433
+ const siblings2 = block5.nodes;
102421
102434
  if (depth === 0 || siblings2.length === 0) {
102422
102435
  push({ type: "text", value });
102423
102436
  continue;
@@ -102438,7 +102451,7 @@ var require_parse5 = __commonJS({
102438
102451
  }
102439
102452
  if (prev.type === "range") {
102440
102453
  siblings2.pop();
102441
- let before = siblings2[siblings2.length - 1];
102454
+ const before = siblings2[siblings2.length - 1];
102442
102455
  before.value += prev.value + value;
102443
102456
  prev = before;
102444
102457
  block5.ranges--;
@@ -102463,8 +102476,8 @@ var require_parse5 = __commonJS({
102463
102476
  node3.invalid = true;
102464
102477
  }
102465
102478
  });
102466
- let parent2 = stack[stack.length - 1];
102467
- let index5 = parent2.nodes.indexOf(block5);
102479
+ const parent2 = stack[stack.length - 1];
102480
+ const index5 = parent2.nodes.indexOf(block5);
102468
102481
  parent2.nodes.splice(index5, 1, ...block5.nodes);
102469
102482
  }
102470
102483
  } while (stack.length > 0);
@@ -102486,8 +102499,8 @@ var require_braces = __commonJS({
102486
102499
  var braces = (input3, options = {}) => {
102487
102500
  let output2 = [];
102488
102501
  if (Array.isArray(input3)) {
102489
- for (let pattern of input3) {
102490
- let result = braces.create(pattern, options);
102502
+ for (const pattern of input3) {
102503
+ const result = braces.create(pattern, options);
102491
102504
  if (Array.isArray(result)) {
102492
102505
  output2.push(...result);
102493
102506
  } else {
@@ -129421,6 +129434,11 @@ var require_raw_body = __commonJS({
129421
129434
  function getRawBody(stream3, options, callback) {
129422
129435
  var done = callback;
129423
129436
  var opts = options || {};
129437
+ if (stream3 === void 0) {
129438
+ throw new TypeError("argument stream is required");
129439
+ } else if (typeof stream3 !== "object" || stream3 === null || typeof stream3.on !== "function") {
129440
+ throw new TypeError("argument stream must be a stream");
129441
+ }
129424
129442
  if (options === true || typeof options === "string") {
129425
129443
  opts = {
129426
129444
  encoding: options
@@ -130117,6 +130135,8 @@ var require_json4 = __commonJS({
130117
130135
  var typeis = require_type_is();
130118
130136
  module2.exports = json2;
130119
130137
  var FIRST_CHAR_REGEXP = /^[\x20\x09\x0a\x0d]*([^\x20\x09\x0a\x0d])/;
130138
+ var JSON_SYNTAX_CHAR = "#";
130139
+ var JSON_SYNTAX_REGEXP = /#+/g;
130120
130140
  function json2(options) {
130121
130141
  var opts = options || {};
130122
130142
  var limit = typeof opts.limit !== "number" ? bytes.parse(opts.limit || "100kb") : opts.limit;
@@ -130187,13 +130207,21 @@ var require_json4 = __commonJS({
130187
130207
  }
130188
130208
  function createStrictSyntaxError(str2, char) {
130189
130209
  var index4 = str2.indexOf(char);
130190
- var partial = index4 !== -1 ? str2.substring(0, index4) + "#" : "";
130210
+ var partial = "";
130211
+ if (index4 !== -1) {
130212
+ partial = str2.substring(0, index4) + JSON_SYNTAX_CHAR;
130213
+ for (var i2 = index4 + 1; i2 < str2.length; i2++) {
130214
+ partial += JSON_SYNTAX_CHAR;
130215
+ }
130216
+ }
130191
130217
  try {
130192
130218
  JSON.parse(partial);
130193
130219
  throw new SyntaxError("strict violation");
130194
130220
  } catch (e2) {
130195
130221
  return normalizeJsonSyntaxError(e2, {
130196
- message: e2.message.replace("#", char),
130222
+ message: e2.message.replace(JSON_SYNTAX_REGEXP, function(placeholder) {
130223
+ return str2.substring(index4, index4 + placeholder.length);
130224
+ }),
130197
130225
  stack: e2.stack
130198
130226
  });
130199
130227
  }
@@ -131339,6 +131367,12 @@ var require_object_inspect = __commonJS({
131339
131367
  if (isString(obj)) {
131340
131368
  return markBoxed(inspect4(String(obj)));
131341
131369
  }
131370
+ if (typeof window !== "undefined" && obj === window) {
131371
+ return "{ [object Window] }";
131372
+ }
131373
+ if (typeof globalThis !== "undefined" && obj === globalThis || typeof global !== "undefined" && obj === global) {
131374
+ return "{ [object globalThis] }";
131375
+ }
131342
131376
  if (!isDate2(obj) && !isRegExp(obj)) {
131343
131377
  var ys = arrObjKeys(obj, inspect4);
131344
131378
  var isPlainObject6 = gPO ? gPO(obj) === Object.prototype : obj instanceof Object || obj.constructor === Object;
@@ -131639,7 +131673,7 @@ var require_side_channel = __commonJS({
131639
131673
  var GetIntrinsic = require_get_intrinsic();
131640
131674
  var callBound = require_callBound();
131641
131675
  var inspect4 = require_object_inspect();
131642
- var $TypeError = GetIntrinsic("%TypeError%");
131676
+ var $TypeError = require_type2();
131643
131677
  var $WeakMap = GetIntrinsic("%WeakMap%", true);
131644
131678
  var $Map = GetIntrinsic("%Map%", true);
131645
131679
  var $weakMapGet = callBound("WeakMap.prototype.get", true);
@@ -131649,10 +131683,13 @@ var require_side_channel = __commonJS({
131649
131683
  var $mapSet = callBound("Map.prototype.set", true);
131650
131684
  var $mapHas = callBound("Map.prototype.has", true);
131651
131685
  var listGetNode = function(list6, key2) {
131652
- for (var prev = list6, curr; (curr = prev.next) !== null; prev = curr) {
131686
+ var prev = list6;
131687
+ var curr;
131688
+ for (; (curr = prev.next) !== null; prev = curr) {
131653
131689
  if (curr.key === key2) {
131654
131690
  prev.next = curr.next;
131655
- curr.next = list6.next;
131691
+ curr.next = /** @type {NonNullable<typeof list.next>} */
131692
+ list6.next;
131656
131693
  list6.next = curr;
131657
131694
  return curr;
131658
131695
  }
@@ -131667,8 +131704,9 @@ var require_side_channel = __commonJS({
131667
131704
  if (node3) {
131668
131705
  node3.value = value;
131669
131706
  } else {
131670
- objects.next = {
131671
- // eslint-disable-line no-param-reassign
131707
+ objects.next = /** @type {import('.').ListNode<typeof value>} */
131708
+ {
131709
+ // eslint-disable-line no-param-reassign, no-extra-parens
131672
131710
  key: key2,
131673
131711
  next: objects.next,
131674
131712
  value
@@ -131872,6 +131910,7 @@ var require_utils13 = __commonJS({
131872
131910
  return strWithoutPlus;
131873
131911
  }
131874
131912
  };
131913
+ var limit = 1024;
131875
131914
  var encode = function encode2(str2, defaultEncoder, charset, kind, format) {
131876
131915
  if (str2.length === 0) {
131877
131916
  return str2;
@@ -131888,27 +131927,32 @@ var require_utils13 = __commonJS({
131888
131927
  });
131889
131928
  }
131890
131929
  var out = "";
131891
- for (var i2 = 0; i2 < string2.length; ++i2) {
131892
- var c = string2.charCodeAt(i2);
131893
- if (c === 45 || c === 46 || c === 95 || c === 126 || c >= 48 && c <= 57 || c >= 65 && c <= 90 || c >= 97 && c <= 122 || format === formats.RFC1738 && (c === 40 || c === 41)) {
131894
- out += string2.charAt(i2);
131895
- continue;
131896
- }
131897
- if (c < 128) {
131898
- out = out + hexTable[c];
131899
- continue;
131900
- }
131901
- if (c < 2048) {
131902
- out = out + (hexTable[192 | c >> 6] + hexTable[128 | c & 63]);
131903
- continue;
131904
- }
131905
- if (c < 55296 || c >= 57344) {
131906
- out = out + (hexTable[224 | c >> 12] + hexTable[128 | c >> 6 & 63] + hexTable[128 | c & 63]);
131907
- continue;
131930
+ for (var j = 0; j < string2.length; j += limit) {
131931
+ var segment = string2.length >= limit ? string2.slice(j, j + limit) : string2;
131932
+ var arr = [];
131933
+ for (var i2 = 0; i2 < segment.length; ++i2) {
131934
+ var c = segment.charCodeAt(i2);
131935
+ if (c === 45 || c === 46 || c === 95 || c === 126 || c >= 48 && c <= 57 || c >= 65 && c <= 90 || c >= 97 && c <= 122 || format === formats.RFC1738 && (c === 40 || c === 41)) {
131936
+ arr[arr.length] = segment.charAt(i2);
131937
+ continue;
131938
+ }
131939
+ if (c < 128) {
131940
+ arr[arr.length] = hexTable[c];
131941
+ continue;
131942
+ }
131943
+ if (c < 2048) {
131944
+ arr[arr.length] = hexTable[192 | c >> 6] + hexTable[128 | c & 63];
131945
+ continue;
131946
+ }
131947
+ if (c < 55296 || c >= 57344) {
131948
+ arr[arr.length] = hexTable[224 | c >> 12] + hexTable[128 | c >> 6 & 63] + hexTable[128 | c & 63];
131949
+ continue;
131950
+ }
131951
+ i2 += 1;
131952
+ c = 65536 + ((c & 1023) << 10 | segment.charCodeAt(i2) & 1023);
131953
+ arr[arr.length] = hexTable[240 | c >> 18] + hexTable[128 | c >> 12 & 63] + hexTable[128 | c >> 6 & 63] + hexTable[128 | c & 63];
131908
131954
  }
131909
- i2 += 1;
131910
- c = 65536 + ((c & 1023) << 10 | string2.charCodeAt(i2) & 1023);
131911
- out += hexTable[240 | c >> 18] + hexTable[128 | c >> 12 & 63] + hexTable[128 | c >> 6 & 63] + hexTable[128 | c & 63];
131955
+ out += arr.join("");
131912
131956
  }
131913
131957
  return out;
131914
131958
  };
@@ -131989,7 +132033,6 @@ var require_stringify4 = __commonJS({
131989
132033
  }
131990
132034
  };
131991
132035
  var isArray2 = Array.isArray;
131992
- var split2 = String.prototype.split;
131993
132036
  var push = Array.prototype.push;
131994
132037
  var pushToArray = function(arr, valueOrArray) {
131995
132038
  push.apply(arr, isArray2(valueOrArray) ? valueOrArray : [valueOrArray]);
@@ -131999,10 +132042,13 @@ var require_stringify4 = __commonJS({
131999
132042
  var defaults4 = {
132000
132043
  addQueryPrefix: false,
132001
132044
  allowDots: false,
132045
+ allowEmptyArrays: false,
132046
+ arrayFormat: "indices",
132002
132047
  charset: "utf-8",
132003
132048
  charsetSentinel: false,
132004
132049
  delimiter: "&",
132005
132050
  encode: true,
132051
+ encodeDotInKeys: false,
132006
132052
  encoder: utils2.encode,
132007
132053
  encodeValuesOnly: false,
132008
132054
  format: defaultFormat,
@@ -132019,7 +132065,7 @@ var require_stringify4 = __commonJS({
132019
132065
  return typeof v === "string" || typeof v === "number" || typeof v === "boolean" || typeof v === "symbol" || typeof v === "bigint";
132020
132066
  };
132021
132067
  var sentinel = {};
132022
- var stringify4 = function stringify5(object, prefix2, generateArrayPrefix, commaRoundTrip, strictNullHandling, skipNulls, encoder, filter7, sort, allowDots, serializeDate, format, formatter, encodeValuesOnly, charset, sideChannel) {
132068
+ var stringify4 = function stringify5(object, prefix2, generateArrayPrefix, commaRoundTrip, allowEmptyArrays, strictNullHandling, skipNulls, encodeDotInKeys, encoder, filter7, sort, allowDots, serializeDate, format, formatter, encodeValuesOnly, charset, sideChannel) {
132023
132069
  var obj = object;
132024
132070
  var tmpSc = sideChannel;
132025
132071
  var step = 0;
@@ -132059,14 +132105,6 @@ var require_stringify4 = __commonJS({
132059
132105
  if (isNonNullishPrimitive(obj) || utils2.isBuffer(obj)) {
132060
132106
  if (encoder) {
132061
132107
  var keyValue = encodeValuesOnly ? prefix2 : encoder(prefix2, defaults4.encoder, charset, "key", format);
132062
- if (generateArrayPrefix === "comma" && encodeValuesOnly) {
132063
- var valuesArray = split2.call(String(obj), ",");
132064
- var valuesJoined = "";
132065
- for (var i2 = 0; i2 < valuesArray.length; ++i2) {
132066
- valuesJoined += (i2 === 0 ? "" : ",") + formatter(encoder(valuesArray[i2], defaults4.encoder, charset, "value", format));
132067
- }
132068
- return [formatter(keyValue) + (commaRoundTrip && isArray2(obj) && valuesArray.length === 1 ? "[]" : "") + "=" + valuesJoined];
132069
- }
132070
132108
  return [formatter(keyValue) + "=" + formatter(encoder(obj, defaults4.encoder, charset, "value", format))];
132071
132109
  }
132072
132110
  return [formatter(prefix2) + "=" + formatter(String(obj))];
@@ -132077,6 +132115,9 @@ var require_stringify4 = __commonJS({
132077
132115
  }
132078
132116
  var objKeys;
132079
132117
  if (generateArrayPrefix === "comma" && isArray2(obj)) {
132118
+ if (encodeValuesOnly && encoder) {
132119
+ obj = utils2.maybeMap(obj, encoder);
132120
+ }
132080
132121
  objKeys = [{ value: obj.length > 0 ? obj.join(",") || null : void 0 }];
132081
132122
  } else if (isArray2(filter7)) {
132082
132123
  objKeys = filter7;
@@ -132084,14 +132125,19 @@ var require_stringify4 = __commonJS({
132084
132125
  var keys2 = Object.keys(obj);
132085
132126
  objKeys = sort ? keys2.sort(sort) : keys2;
132086
132127
  }
132087
- var adjustedPrefix = commaRoundTrip && isArray2(obj) && obj.length === 1 ? prefix2 + "[]" : prefix2;
132128
+ var encodedPrefix = encodeDotInKeys ? prefix2.replace(/\./g, "%2E") : prefix2;
132129
+ var adjustedPrefix = commaRoundTrip && isArray2(obj) && obj.length === 1 ? encodedPrefix + "[]" : encodedPrefix;
132130
+ if (allowEmptyArrays && isArray2(obj) && obj.length === 0) {
132131
+ return adjustedPrefix + "[]";
132132
+ }
132088
132133
  for (var j = 0; j < objKeys.length; ++j) {
132089
132134
  var key2 = objKeys[j];
132090
132135
  var value = typeof key2 === "object" && typeof key2.value !== "undefined" ? key2.value : obj[key2];
132091
132136
  if (skipNulls && value === null) {
132092
132137
  continue;
132093
132138
  }
132094
- var keyPrefix = isArray2(obj) ? typeof generateArrayPrefix === "function" ? generateArrayPrefix(adjustedPrefix, key2) : adjustedPrefix : adjustedPrefix + (allowDots ? "." + key2 : "[" + key2 + "]");
132139
+ var encodedKey = allowDots && encodeDotInKeys ? key2.replace(/\./g, "%2E") : key2;
132140
+ var keyPrefix = isArray2(obj) ? typeof generateArrayPrefix === "function" ? generateArrayPrefix(adjustedPrefix, encodedKey) : adjustedPrefix : adjustedPrefix + (allowDots ? "." + encodedKey : "[" + encodedKey + "]");
132095
132141
  sideChannel.set(object, step);
132096
132142
  var valueSideChannel = getSideChannel();
132097
132143
  valueSideChannel.set(sentinel, sideChannel);
@@ -132100,9 +132146,11 @@ var require_stringify4 = __commonJS({
132100
132146
  keyPrefix,
132101
132147
  generateArrayPrefix,
132102
132148
  commaRoundTrip,
132149
+ allowEmptyArrays,
132103
132150
  strictNullHandling,
132104
132151
  skipNulls,
132105
- encoder,
132152
+ encodeDotInKeys,
132153
+ generateArrayPrefix === "comma" && encodeValuesOnly && isArray2(obj) ? null : encoder,
132106
132154
  filter7,
132107
132155
  sort,
132108
132156
  allowDots,
@@ -132120,6 +132168,12 @@ var require_stringify4 = __commonJS({
132120
132168
  if (!opts) {
132121
132169
  return defaults4;
132122
132170
  }
132171
+ if (typeof opts.allowEmptyArrays !== "undefined" && typeof opts.allowEmptyArrays !== "boolean") {
132172
+ throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");
132173
+ }
132174
+ if (typeof opts.encodeDotInKeys !== "undefined" && typeof opts.encodeDotInKeys !== "boolean") {
132175
+ throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");
132176
+ }
132123
132177
  if (opts.encoder !== null && typeof opts.encoder !== "undefined" && typeof opts.encoder !== "function") {
132124
132178
  throw new TypeError("Encoder has to be a function.");
132125
132179
  }
@@ -132139,13 +132193,29 @@ var require_stringify4 = __commonJS({
132139
132193
  if (typeof opts.filter === "function" || isArray2(opts.filter)) {
132140
132194
  filter7 = opts.filter;
132141
132195
  }
132196
+ var arrayFormat;
132197
+ if (opts.arrayFormat in arrayPrefixGenerators) {
132198
+ arrayFormat = opts.arrayFormat;
132199
+ } else if ("indices" in opts) {
132200
+ arrayFormat = opts.indices ? "indices" : "repeat";
132201
+ } else {
132202
+ arrayFormat = defaults4.arrayFormat;
132203
+ }
132204
+ if ("commaRoundTrip" in opts && typeof opts.commaRoundTrip !== "boolean") {
132205
+ throw new TypeError("`commaRoundTrip` must be a boolean, or absent");
132206
+ }
132207
+ var allowDots = typeof opts.allowDots === "undefined" ? opts.encodeDotInKeys === true ? true : defaults4.allowDots : !!opts.allowDots;
132142
132208
  return {
132143
132209
  addQueryPrefix: typeof opts.addQueryPrefix === "boolean" ? opts.addQueryPrefix : defaults4.addQueryPrefix,
132144
- allowDots: typeof opts.allowDots === "undefined" ? defaults4.allowDots : !!opts.allowDots,
132210
+ allowDots,
132211
+ allowEmptyArrays: typeof opts.allowEmptyArrays === "boolean" ? !!opts.allowEmptyArrays : defaults4.allowEmptyArrays,
132212
+ arrayFormat,
132145
132213
  charset,
132146
132214
  charsetSentinel: typeof opts.charsetSentinel === "boolean" ? opts.charsetSentinel : defaults4.charsetSentinel,
132215
+ commaRoundTrip: opts.commaRoundTrip,
132147
132216
  delimiter: typeof opts.delimiter === "undefined" ? defaults4.delimiter : opts.delimiter,
132148
132217
  encode: typeof opts.encode === "boolean" ? opts.encode : defaults4.encode,
132218
+ encodeDotInKeys: typeof opts.encodeDotInKeys === "boolean" ? opts.encodeDotInKeys : defaults4.encodeDotInKeys,
132149
132219
  encoder: typeof opts.encoder === "function" ? opts.encoder : defaults4.encoder,
132150
132220
  encodeValuesOnly: typeof opts.encodeValuesOnly === "boolean" ? opts.encodeValuesOnly : defaults4.encodeValuesOnly,
132151
132221
  filter: filter7,
@@ -132173,19 +132243,8 @@ var require_stringify4 = __commonJS({
132173
132243
  if (typeof obj !== "object" || obj === null) {
132174
132244
  return "";
132175
132245
  }
132176
- var arrayFormat;
132177
- if (opts && opts.arrayFormat in arrayPrefixGenerators) {
132178
- arrayFormat = opts.arrayFormat;
132179
- } else if (opts && "indices" in opts) {
132180
- arrayFormat = opts.indices ? "indices" : "repeat";
132181
- } else {
132182
- arrayFormat = "indices";
132183
- }
132184
- var generateArrayPrefix = arrayPrefixGenerators[arrayFormat];
132185
- if (opts && "commaRoundTrip" in opts && typeof opts.commaRoundTrip !== "boolean") {
132186
- throw new TypeError("`commaRoundTrip` must be a boolean, or absent");
132187
- }
132188
- var commaRoundTrip = generateArrayPrefix === "comma" && opts && opts.commaRoundTrip;
132246
+ var generateArrayPrefix = arrayPrefixGenerators[options.arrayFormat];
132247
+ var commaRoundTrip = generateArrayPrefix === "comma" && options.commaRoundTrip;
132189
132248
  if (!objKeys) {
132190
132249
  objKeys = Object.keys(obj);
132191
132250
  }
@@ -132203,8 +132262,10 @@ var require_stringify4 = __commonJS({
132203
132262
  key2,
132204
132263
  generateArrayPrefix,
132205
132264
  commaRoundTrip,
132265
+ options.allowEmptyArrays,
132206
132266
  options.strictNullHandling,
132207
132267
  options.skipNulls,
132268
+ options.encodeDotInKeys,
132208
132269
  options.encode ? options.encoder : null,
132209
132270
  options.filter,
132210
132271
  options.sort,
@@ -132240,20 +132301,24 @@ var require_parse6 = __commonJS({
132240
132301
  var isArray2 = Array.isArray;
132241
132302
  var defaults4 = {
132242
132303
  allowDots: false,
132304
+ allowEmptyArrays: false,
132243
132305
  allowPrototypes: false,
132244
132306
  allowSparse: false,
132245
132307
  arrayLimit: 20,
132246
132308
  charset: "utf-8",
132247
132309
  charsetSentinel: false,
132248
132310
  comma: false,
132311
+ decodeDotInKeys: false,
132249
132312
  decoder: utils2.decode,
132250
132313
  delimiter: "&",
132251
132314
  depth: 5,
132315
+ duplicates: "combine",
132252
132316
  ignoreQueryPrefix: false,
132253
132317
  interpretNumericEntities: false,
132254
132318
  parameterLimit: 1e3,
132255
132319
  parseArrays: true,
132256
132320
  plainObjects: false,
132321
+ strictDepth: false,
132257
132322
  strictNullHandling: false
132258
132323
  };
132259
132324
  var interpretNumericEntities = function(str2) {
@@ -132270,8 +132335,9 @@ var require_parse6 = __commonJS({
132270
132335
  var isoSentinel = "utf8=%26%2310003%3B";
132271
132336
  var charsetSentinel = "utf8=%E2%9C%93";
132272
132337
  var parseValues = function parseQueryStringValues(str2, options) {
132273
- var obj = {};
132338
+ var obj = { __proto__: null };
132274
132339
  var cleanStr = options.ignoreQueryPrefix ? str2.replace(/^\?/, "") : str2;
132340
+ cleanStr = cleanStr.replace(/%5B/gi, "[").replace(/%5D/gi, "]");
132275
132341
  var limit = options.parameterLimit === Infinity ? void 0 : options.parameterLimit;
132276
132342
  var parts = cleanStr.split(options.delimiter, limit);
132277
132343
  var skipIndex = -1;
@@ -132316,9 +132382,10 @@ var require_parse6 = __commonJS({
132316
132382
  if (part.indexOf("[]=") > -1) {
132317
132383
  val = isArray2(val) ? [val] : val;
132318
132384
  }
132319
- if (has3.call(obj, key2)) {
132385
+ var existing = has3.call(obj, key2);
132386
+ if (existing && options.duplicates === "combine") {
132320
132387
  obj[key2] = utils2.combine(obj[key2], val);
132321
- } else {
132388
+ } else if (!existing || options.duplicates === "last") {
132322
132389
  obj[key2] = val;
132323
132390
  }
132324
132391
  }
@@ -132330,18 +132397,19 @@ var require_parse6 = __commonJS({
132330
132397
  var obj;
132331
132398
  var root6 = chain[i2];
132332
132399
  if (root6 === "[]" && options.parseArrays) {
132333
- obj = [].concat(leaf);
132400
+ obj = options.allowEmptyArrays && (leaf === "" || options.strictNullHandling && leaf === null) ? [] : [].concat(leaf);
132334
132401
  } else {
132335
132402
  obj = options.plainObjects ? /* @__PURE__ */ Object.create(null) : {};
132336
132403
  var cleanRoot = root6.charAt(0) === "[" && root6.charAt(root6.length - 1) === "]" ? root6.slice(1, -1) : root6;
132337
- var index4 = parseInt(cleanRoot, 10);
132338
- if (!options.parseArrays && cleanRoot === "") {
132404
+ var decodedRoot = options.decodeDotInKeys ? cleanRoot.replace(/%2E/g, ".") : cleanRoot;
132405
+ var index4 = parseInt(decodedRoot, 10);
132406
+ if (!options.parseArrays && decodedRoot === "") {
132339
132407
  obj = { 0: leaf };
132340
- } else if (!isNaN(index4) && root6 !== cleanRoot && String(index4) === cleanRoot && index4 >= 0 && (options.parseArrays && index4 <= options.arrayLimit)) {
132408
+ } else if (!isNaN(index4) && root6 !== decodedRoot && String(index4) === decodedRoot && index4 >= 0 && (options.parseArrays && index4 <= options.arrayLimit)) {
132341
132409
  obj = [];
132342
132410
  obj[index4] = leaf;
132343
- } else if (cleanRoot !== "__proto__") {
132344
- obj[cleanRoot] = leaf;
132411
+ } else if (decodedRoot !== "__proto__") {
132412
+ obj[decodedRoot] = leaf;
132345
132413
  }
132346
132414
  }
132347
132415
  leaf = obj;
@@ -132377,6 +132445,9 @@ var require_parse6 = __commonJS({
132377
132445
  keys2.push(segment[1]);
132378
132446
  }
132379
132447
  if (segment) {
132448
+ if (options.strictDepth === true) {
132449
+ throw new RangeError("Input depth exceeded depth option of " + options.depth + " and strictDepth is true");
132450
+ }
132380
132451
  keys2.push("[" + key2.slice(segment.index) + "]");
132381
132452
  }
132382
132453
  return parseObject(keys2, val, options, valuesParsed);
@@ -132385,30 +132456,45 @@ var require_parse6 = __commonJS({
132385
132456
  if (!opts) {
132386
132457
  return defaults4;
132387
132458
  }
132388
- if (opts.decoder !== null && opts.decoder !== void 0 && typeof opts.decoder !== "function") {
132459
+ if (typeof opts.allowEmptyArrays !== "undefined" && typeof opts.allowEmptyArrays !== "boolean") {
132460
+ throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");
132461
+ }
132462
+ if (typeof opts.decodeDotInKeys !== "undefined" && typeof opts.decodeDotInKeys !== "boolean") {
132463
+ throw new TypeError("`decodeDotInKeys` option can only be `true` or `false`, when provided");
132464
+ }
132465
+ if (opts.decoder !== null && typeof opts.decoder !== "undefined" && typeof opts.decoder !== "function") {
132389
132466
  throw new TypeError("Decoder has to be a function.");
132390
132467
  }
132391
132468
  if (typeof opts.charset !== "undefined" && opts.charset !== "utf-8" && opts.charset !== "iso-8859-1") {
132392
132469
  throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");
132393
132470
  }
132394
132471
  var charset = typeof opts.charset === "undefined" ? defaults4.charset : opts.charset;
132472
+ var duplicates = typeof opts.duplicates === "undefined" ? defaults4.duplicates : opts.duplicates;
132473
+ if (duplicates !== "combine" && duplicates !== "first" && duplicates !== "last") {
132474
+ throw new TypeError("The duplicates option must be either combine, first, or last");
132475
+ }
132476
+ var allowDots = typeof opts.allowDots === "undefined" ? opts.decodeDotInKeys === true ? true : defaults4.allowDots : !!opts.allowDots;
132395
132477
  return {
132396
- allowDots: typeof opts.allowDots === "undefined" ? defaults4.allowDots : !!opts.allowDots,
132478
+ allowDots,
132479
+ allowEmptyArrays: typeof opts.allowEmptyArrays === "boolean" ? !!opts.allowEmptyArrays : defaults4.allowEmptyArrays,
132397
132480
  allowPrototypes: typeof opts.allowPrototypes === "boolean" ? opts.allowPrototypes : defaults4.allowPrototypes,
132398
132481
  allowSparse: typeof opts.allowSparse === "boolean" ? opts.allowSparse : defaults4.allowSparse,
132399
132482
  arrayLimit: typeof opts.arrayLimit === "number" ? opts.arrayLimit : defaults4.arrayLimit,
132400
132483
  charset,
132401
132484
  charsetSentinel: typeof opts.charsetSentinel === "boolean" ? opts.charsetSentinel : defaults4.charsetSentinel,
132402
132485
  comma: typeof opts.comma === "boolean" ? opts.comma : defaults4.comma,
132486
+ decodeDotInKeys: typeof opts.decodeDotInKeys === "boolean" ? opts.decodeDotInKeys : defaults4.decodeDotInKeys,
132403
132487
  decoder: typeof opts.decoder === "function" ? opts.decoder : defaults4.decoder,
132404
132488
  delimiter: typeof opts.delimiter === "string" || utils2.isRegExp(opts.delimiter) ? opts.delimiter : defaults4.delimiter,
132405
132489
  // eslint-disable-next-line no-implicit-coercion, no-extra-parens
132406
132490
  depth: typeof opts.depth === "number" || opts.depth === false ? +opts.depth : defaults4.depth,
132491
+ duplicates,
132407
132492
  ignoreQueryPrefix: opts.ignoreQueryPrefix === true,
132408
132493
  interpretNumericEntities: typeof opts.interpretNumericEntities === "boolean" ? opts.interpretNumericEntities : defaults4.interpretNumericEntities,
132409
132494
  parameterLimit: typeof opts.parameterLimit === "number" ? opts.parameterLimit : defaults4.parameterLimit,
132410
132495
  parseArrays: opts.parseArrays !== false,
132411
132496
  plainObjects: typeof opts.plainObjects === "boolean" ? opts.plainObjects : defaults4.plainObjects,
132497
+ strictDepth: typeof opts.strictDepth === "boolean" ? !!opts.strictDepth : defaults4.strictDepth,
132412
132498
  strictNullHandling: typeof opts.strictNullHandling === "boolean" ? opts.strictNullHandling : defaults4.strictNullHandling
132413
132499
  };
132414
132500
  };
@@ -132471,6 +132557,7 @@ var require_urlencoded = __commonJS({
132471
132557
  var limit = typeof opts.limit !== "number" ? bytes.parse(opts.limit || "100kb") : opts.limit;
132472
132558
  var type2 = opts.type || "application/x-www-form-urlencoded";
132473
132559
  var verify = opts.verify || false;
132560
+ var depth = typeof opts.depth !== "number" ? Number(opts.depth || 32) : opts.depth;
132474
132561
  if (verify !== false && typeof verify !== "function") {
132475
132562
  throw new TypeError("option verify must be function");
132476
132563
  }
@@ -132511,16 +132598,21 @@ var require_urlencoded = __commonJS({
132511
132598
  encoding: charset,
132512
132599
  inflate,
132513
132600
  limit,
132514
- verify
132601
+ verify,
132602
+ depth
132515
132603
  });
132516
132604
  };
132517
132605
  }
132518
132606
  function extendedparser(options) {
132519
132607
  var parameterLimit = options.parameterLimit !== void 0 ? options.parameterLimit : 1e3;
132608
+ var depth = typeof options.depth !== "number" ? Number(options.depth || 32) : options.depth;
132520
132609
  var parse16 = parser3("qs");
132521
132610
  if (isNaN(parameterLimit) || parameterLimit < 1) {
132522
132611
  throw new TypeError("option parameterLimit must be a positive number");
132523
132612
  }
132613
+ if (isNaN(depth) || depth < 0) {
132614
+ throw new TypeError("option depth must be a zero or a positive number");
132615
+ }
132524
132616
  if (isFinite(parameterLimit)) {
132525
132617
  parameterLimit = parameterLimit | 0;
132526
132618
  }
@@ -132534,12 +132626,23 @@ var require_urlencoded = __commonJS({
132534
132626
  }
132535
132627
  var arrayLimit = Math.max(100, paramCount);
132536
132628
  debug("parse extended urlencoding");
132537
- return parse16(body3, {
132538
- allowPrototypes: true,
132539
- arrayLimit,
132540
- depth: Infinity,
132541
- parameterLimit
132542
- });
132629
+ try {
132630
+ return parse16(body3, {
132631
+ allowPrototypes: true,
132632
+ arrayLimit,
132633
+ depth,
132634
+ strictDepth: true,
132635
+ parameterLimit
132636
+ });
132637
+ } catch (err) {
132638
+ if (err instanceof RangeError) {
132639
+ throw createError(400, "The input exceeded the depth", {
132640
+ type: "querystring.parse.rangeError"
132641
+ });
132642
+ } else {
132643
+ throw err;
132644
+ }
132645
+ }
132543
132646
  };
132544
132647
  }
132545
132648
  function getCharset(req) {
@@ -133151,7 +133254,7 @@ var require_encodeurl = __commonJS({
133151
133254
  "../../node_modules/encodeurl/index.js"(exports2, module2) {
133152
133255
  "use strict";
133153
133256
  module2.exports = encodeUrl;
133154
- var ENCODE_CHARS_REGEXP = /(?:[^\x21\x25\x26-\x3B\x3D\x3F-\x5B\x5D\x5F\x61-\x7A\x7E]|%(?:[^0-9A-Fa-f]|[0-9A-Fa-f][^0-9A-Fa-f]|$))+/g;
133257
+ var ENCODE_CHARS_REGEXP = /(?:[^\x21\x23-\x3B\x3D\x3F-\x5F\x61-\x7A\x7C\x7E]|%(?:[^0-9A-Fa-f]|[0-9A-Fa-f][^0-9A-Fa-f]|$))+/g;
133155
133258
  var UNMATCHED_SURROGATE_PAIR_REGEXP = /(^|[^\uD800-\uDBFF])[\uDC00-\uDFFF]|[\uD800-\uDBFF]([^\uDC00-\uDFFF]|$)/g;
133156
133259
  var UNMATCHED_SURROGATE_PAIR_REPLACE = "$1\uFFFD$2";
133157
133260
  function encodeUrl(url) {
@@ -133337,7 +133440,9 @@ var require_finalhandler = __commonJS({
133337
133440
  }
133338
133441
  if (headersSent(res)) {
133339
133442
  debug("cannot %d after headers sent", status);
133340
- req.socket.destroy();
133443
+ if (req.socket) {
133444
+ req.socket.destroy();
133445
+ }
133341
133446
  return;
133342
133447
  }
133343
133448
  send(req, res, status, headers, msg);
@@ -133395,7 +133500,9 @@ var require_finalhandler = __commonJS({
133395
133500
  function write3() {
133396
133501
  var body3 = createHtmlDocument(message);
133397
133502
  res.statusCode = status;
133398
- res.statusMessage = statuses.message[status];
133503
+ if (req.httpVersionMajor < 2) {
133504
+ res.statusMessage = statuses.message[status];
133505
+ }
133399
133506
  res.removeHeader("Content-Encoding");
133400
133507
  res.removeHeader("Content-Language");
133401
133508
  res.removeHeader("Content-Range");
@@ -133904,23 +134011,28 @@ var require_array_flatten = __commonJS({
133904
134011
  // ../../node_modules/path-to-regexp/index.js
133905
134012
  var require_path_to_regexp = __commonJS({
133906
134013
  "../../node_modules/path-to-regexp/index.js"(exports2, module2) {
133907
- module2.exports = pathtoRegexp;
133908
- var MATCHING_GROUP_REGEXP = /\((?!\?)/g;
133909
- function pathtoRegexp(path42, keys2, options) {
134014
+ module2.exports = pathToRegexp;
134015
+ var MATCHING_GROUP_REGEXP = /\\.|\((?:\?<(.*?)>)?(?!\?)/g;
134016
+ function pathToRegexp(path42, keys2, options) {
133910
134017
  options = options || {};
133911
134018
  keys2 = keys2 || [];
133912
134019
  var strict = options.strict;
133913
134020
  var end = options.end !== false;
133914
134021
  var flags = options.sensitive ? "" : "i";
134022
+ var lookahead = options.lookahead !== false;
133915
134023
  var extraOffset = 0;
133916
134024
  var keysOffset = keys2.length;
133917
134025
  var i2 = 0;
133918
134026
  var name3 = 0;
134027
+ var pos = 0;
134028
+ var backtrack = "";
133919
134029
  var m2;
133920
134030
  if (path42 instanceof RegExp) {
133921
134031
  while (m2 = MATCHING_GROUP_REGEXP.exec(path42.source)) {
134032
+ if (m2[0][0] === "\\")
134033
+ continue;
133922
134034
  keys2.push({
133923
- name: name3++,
134035
+ name: m2[1] || name3++,
133924
134036
  optional: false,
133925
134037
  offset: m2.index
133926
134038
  });
@@ -133929,39 +134041,52 @@ var require_path_to_regexp = __commonJS({
133929
134041
  }
133930
134042
  if (Array.isArray(path42)) {
133931
134043
  path42 = path42.map(function(value) {
133932
- return pathtoRegexp(value, keys2, options).source;
134044
+ return pathToRegexp(value, keys2, options).source;
133933
134045
  });
133934
- return new RegExp("(?:" + path42.join("|") + ")", flags);
133935
- }
133936
- path42 = ("^" + path42 + (strict ? "" : path42[path42.length - 1] === "/" ? "?" : "/?")).replace(/\/\(/g, "/(?:").replace(/([\/\.])/g, "\\$1").replace(/(\\\/)?(\\\.)?:(\w+)(\(.*?\))?(\*)?(\?)?/g, function(match3, slash, format, key2, capture, star3, optional, offset) {
133937
- slash = slash || "";
133938
- format = format || "";
133939
- capture = capture || "([^\\/" + format + "]+?)";
133940
- optional = optional || "";
133941
- keys2.push({
133942
- name: key2,
133943
- optional: !!optional,
133944
- offset: offset + extraOffset
133945
- });
133946
- var result = "" + (optional ? "" : slash) + "(?:" + format + (optional ? slash : "") + capture + (star3 ? "((?:[\\/" + format + "].+?)?)" : "") + ")" + optional;
133947
- extraOffset += result.length - match3.length;
133948
- return result;
133949
- }).replace(/\*/g, function(star3, index5) {
133950
- var len = keys2.length;
133951
- while (len-- > keysOffset && keys2[len].offset > index5) {
133952
- keys2[len].offset += 3;
134046
+ return new RegExp(path42.join("|"), flags);
134047
+ }
134048
+ path42 = path42.replace(
134049
+ /\\.|(\/)?(\.)?:(\w+)(\(.*?\))?(\*)?(\?)?|[.*]|\/\(/g,
134050
+ function(match3, slash, format, key2, capture, star3, optional, offset) {
134051
+ pos = offset + match3.length;
134052
+ if (match3[0] === "\\") {
134053
+ backtrack += match3;
134054
+ return match3;
134055
+ }
134056
+ if (match3 === ".") {
134057
+ backtrack += "\\.";
134058
+ extraOffset += 1;
134059
+ return "\\.";
134060
+ }
134061
+ backtrack = slash || format ? "" : path42.slice(pos, offset);
134062
+ if (match3 === "*") {
134063
+ extraOffset += 3;
134064
+ return "(.*)";
134065
+ }
134066
+ if (match3 === "/(") {
134067
+ backtrack += "/";
134068
+ extraOffset += 2;
134069
+ return "/(?:";
134070
+ }
134071
+ slash = slash || "";
134072
+ format = format ? "\\." : "";
134073
+ optional = optional || "";
134074
+ capture = capture ? capture.replace(/\\.|\*/, function(m3) {
134075
+ return m3 === "*" ? "(.*)" : m3;
134076
+ }) : backtrack ? "((?:(?!/|" + backtrack + ").)+?)" : "([^/" + format + "]+?)";
134077
+ keys2.push({
134078
+ name: key2,
134079
+ optional: !!optional,
134080
+ offset: offset + extraOffset
134081
+ });
134082
+ var result = "(?:" + format + slash + capture + (star3 ? "((?:[/" + format + "].+?)?)" : "") + ")" + optional;
134083
+ extraOffset += result.length - match3.length;
134084
+ return result;
133953
134085
  }
133954
- return "(.*)";
133955
- });
134086
+ );
133956
134087
  while (m2 = MATCHING_GROUP_REGEXP.exec(path42)) {
133957
- var escapeCount = 0;
133958
- var index4 = m2.index;
133959
- while (path42.charAt(--index4) === "\\") {
133960
- escapeCount++;
133961
- }
133962
- if (escapeCount % 2 === 1) {
134088
+ if (m2[0][0] === "\\")
133963
134089
  continue;
133964
- }
133965
134090
  if (keysOffset + i2 === keys2.length || keys2[keysOffset + i2].offset > m2.index) {
133966
134091
  keys2.splice(keysOffset + i2, 0, {
133967
134092
  name: name3++,
@@ -133972,8 +134097,13 @@ var require_path_to_regexp = __commonJS({
133972
134097
  }
133973
134098
  i2++;
133974
134099
  }
133975
- path42 += end ? "$" : path42[path42.length - 1] === "/" ? "" : "(?=\\/|$)";
133976
- return new RegExp(path42, flags);
134100
+ path42 += strict ? "" : path42[path42.length - 1] === "/" ? "?" : "/?";
134101
+ if (end) {
134102
+ path42 += "$";
134103
+ } else if (path42[path42.length - 1] !== "/") {
134104
+ path42 += lookahead ? "(?=/|$)" : "(?:/|$)";
134105
+ }
134106
+ return new RegExp("^" + path42, flags);
133977
134107
  }
133978
134108
  }
133979
134109
  });
@@ -134138,7 +134268,7 @@ var require_route2 = __commonJS({
134138
134268
  if (this.methods._all) {
134139
134269
  return true;
134140
134270
  }
134141
- var name3 = method.toLowerCase();
134271
+ var name3 = typeof method === "string" ? method.toLowerCase() : method;
134142
134272
  if (name3 === "head" && !this.methods["head"]) {
134143
134273
  name3 = "get";
134144
134274
  }
@@ -134161,7 +134291,7 @@ var require_route2 = __commonJS({
134161
134291
  if (stack.length === 0) {
134162
134292
  return done();
134163
134293
  }
134164
- var method = req.method.toLowerCase();
134294
+ var method = typeof req.method === "string" ? req.method.toLowerCase() : req.method;
134165
134295
  if (method === "head" && !this.methods["head"]) {
134166
134296
  method = "get";
134167
134297
  }
@@ -135413,6 +135543,20 @@ var require_src4 = __commonJS({
135413
135543
  }
135414
135544
  });
135415
135545
 
135546
+ // ../../node_modules/send/node_modules/encodeurl/index.js
135547
+ var require_encodeurl2 = __commonJS({
135548
+ "../../node_modules/send/node_modules/encodeurl/index.js"(exports2, module2) {
135549
+ "use strict";
135550
+ module2.exports = encodeUrl;
135551
+ var ENCODE_CHARS_REGEXP = /(?:[^\x21\x25\x26-\x3B\x3D\x3F-\x5B\x5D\x5F\x61-\x7A\x7E]|%(?:[^0-9A-Fa-f]|[0-9A-Fa-f][^0-9A-Fa-f]|$))+/g;
135552
+ var UNMATCHED_SURROGATE_PAIR_REGEXP = /(^|[^\uD800-\uDBFF])[\uDC00-\uDFFF]|[\uD800-\uDBFF]([^\uDC00-\uDFFF]|$)/g;
135553
+ var UNMATCHED_SURROGATE_PAIR_REPLACE = "$1\uFFFD$2";
135554
+ function encodeUrl(url) {
135555
+ return String(url).replace(UNMATCHED_SURROGATE_PAIR_REGEXP, UNMATCHED_SURROGATE_PAIR_REPLACE).replace(ENCODE_CHARS_REGEXP, encodeURI);
135556
+ }
135557
+ }
135558
+ });
135559
+
135416
135560
  // ../../node_modules/etag/index.js
135417
135561
  var require_etag = __commonJS({
135418
135562
  "../../node_modules/etag/index.js"(exports2, module2) {
@@ -135794,7 +135938,7 @@ var require_send = __commonJS({
135794
135938
  var debug = require_src4()("send");
135795
135939
  var deprecate3 = require_depd()("send");
135796
135940
  var destroy = require_destroy();
135797
- var encodeUrl = require_encodeurl();
135941
+ var encodeUrl = require_encodeurl2();
135798
135942
  var escapeHtml4 = require_escape_html();
135799
135943
  var etag = require_etag();
135800
135944
  var fresh = require_fresh();
@@ -135995,7 +136139,7 @@ var require_send = __commonJS({
135995
136139
  return;
135996
136140
  }
135997
136141
  var loc = encodeUrl(collapseLeadingSlashes(this.path + "/"));
135998
- var doc = createHtmlDocument("Redirecting", 'Redirecting to <a href="' + escapeHtml4(loc) + '">' + escapeHtml4(loc) + "</a>");
136142
+ var doc = createHtmlDocument("Redirecting", "Redirecting to " + escapeHtml4(loc));
135999
136143
  res.statusCode = 301;
136000
136144
  res.setHeader("Content-Type", "text/html; charset=UTF-8");
136001
136145
  res.setHeader("Content-Length", Buffer.byteLength(doc));
@@ -137213,9 +137357,9 @@ var require_utils14 = __commonJS({
137213
137357
  contentDisposition,
137214
137358
  "utils.contentDisposition: use content-disposition npm module instead"
137215
137359
  );
137216
- function acceptParams(str2, index4) {
137360
+ function acceptParams(str2) {
137217
137361
  var parts = str2.split(/ *; */);
137218
- var ret = { value: parts[0], quality: 1, params: {}, originalIndex: index4 };
137362
+ var ret = { value: parts[0], quality: 1, params: {} };
137219
137363
  for (var i2 = 1; i2 < parts.length; ++i2) {
137220
137364
  var pms = parts[i2].split(/ *= */);
137221
137365
  if ("q" === pms[0]) {
@@ -138377,68 +138521,96 @@ var require_cookie = __commonJS({
138377
138521
  exports2.parse = parse16;
138378
138522
  exports2.serialize = serialize3;
138379
138523
  var __toString = Object.prototype.toString;
138380
- var fieldContentRegExp = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;
138381
- function parse16(str2, options) {
138524
+ var cookieNameRegExp = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;
138525
+ var cookieValueRegExp = /^("?)[\u0021\u0023-\u002B\u002D-\u003A\u003C-\u005B\u005D-\u007E]*\1$/;
138526
+ var domainValueRegExp = /^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i;
138527
+ var pathValueRegExp = /^[\u0020-\u003A\u003D-\u007E]*$/;
138528
+ function parse16(str2, opt) {
138382
138529
  if (typeof str2 !== "string") {
138383
138530
  throw new TypeError("argument str must be a string");
138384
138531
  }
138385
138532
  var obj = {};
138386
- var opt = options || {};
138387
- var dec = opt.decode || decode2;
138533
+ var len = str2.length;
138534
+ if (len < 2)
138535
+ return obj;
138536
+ var dec = opt && opt.decode || decode2;
138388
138537
  var index4 = 0;
138389
- while (index4 < str2.length) {
138390
- var eqIdx = str2.indexOf("=", index4);
138391
- if (eqIdx === -1) {
138538
+ var eqIdx = 0;
138539
+ var endIdx = 0;
138540
+ do {
138541
+ eqIdx = str2.indexOf("=", index4);
138542
+ if (eqIdx === -1)
138392
138543
  break;
138393
- }
138394
- var endIdx = str2.indexOf(";", index4);
138544
+ endIdx = str2.indexOf(";", index4);
138395
138545
  if (endIdx === -1) {
138396
- endIdx = str2.length;
138397
- } else if (endIdx < eqIdx) {
138546
+ endIdx = len;
138547
+ } else if (eqIdx > endIdx) {
138398
138548
  index4 = str2.lastIndexOf(";", eqIdx - 1) + 1;
138399
138549
  continue;
138400
138550
  }
138401
- var key2 = str2.slice(index4, eqIdx).trim();
138402
- if (void 0 === obj[key2]) {
138403
- var val = str2.slice(eqIdx + 1, endIdx).trim();
138404
- if (val.charCodeAt(0) === 34) {
138405
- val = val.slice(1, -1);
138406
- }
138551
+ var keyStartIdx = startIndex(str2, index4, eqIdx);
138552
+ var keyEndIdx = endIndex(str2, eqIdx, keyStartIdx);
138553
+ var key2 = str2.slice(keyStartIdx, keyEndIdx);
138554
+ if (!obj.hasOwnProperty(key2)) {
138555
+ var valStartIdx = startIndex(str2, eqIdx + 1, endIdx);
138556
+ var valEndIdx = endIndex(str2, endIdx, valStartIdx);
138557
+ if (str2.charCodeAt(valStartIdx) === 34 && str2.charCodeAt(valEndIdx - 1) === 34) {
138558
+ valStartIdx++;
138559
+ valEndIdx--;
138560
+ }
138561
+ var val = str2.slice(valStartIdx, valEndIdx);
138407
138562
  obj[key2] = tryDecode(val, dec);
138408
138563
  }
138409
138564
  index4 = endIdx + 1;
138410
- }
138565
+ } while (index4 < len);
138411
138566
  return obj;
138412
138567
  }
138413
- function serialize3(name3, val, options) {
138414
- var opt = options || {};
138415
- var enc = opt.encode || encode;
138568
+ function startIndex(str2, index4, max) {
138569
+ do {
138570
+ var code7 = str2.charCodeAt(index4);
138571
+ if (code7 !== 32 && code7 !== 9)
138572
+ return index4;
138573
+ } while (++index4 < max);
138574
+ return max;
138575
+ }
138576
+ function endIndex(str2, index4, min) {
138577
+ while (index4 > min) {
138578
+ var code7 = str2.charCodeAt(--index4);
138579
+ if (code7 !== 32 && code7 !== 9)
138580
+ return index4 + 1;
138581
+ }
138582
+ return min;
138583
+ }
138584
+ function serialize3(name3, val, opt) {
138585
+ var enc = opt && opt.encode || encodeURIComponent;
138416
138586
  if (typeof enc !== "function") {
138417
138587
  throw new TypeError("option encode is invalid");
138418
138588
  }
138419
- if (!fieldContentRegExp.test(name3)) {
138589
+ if (!cookieNameRegExp.test(name3)) {
138420
138590
  throw new TypeError("argument name is invalid");
138421
138591
  }
138422
138592
  var value = enc(val);
138423
- if (value && !fieldContentRegExp.test(value)) {
138593
+ if (!cookieValueRegExp.test(value)) {
138424
138594
  throw new TypeError("argument val is invalid");
138425
138595
  }
138426
138596
  var str2 = name3 + "=" + value;
138597
+ if (!opt)
138598
+ return str2;
138427
138599
  if (null != opt.maxAge) {
138428
- var maxAge = opt.maxAge - 0;
138429
- if (isNaN(maxAge) || !isFinite(maxAge)) {
138600
+ var maxAge = Math.floor(opt.maxAge);
138601
+ if (!isFinite(maxAge)) {
138430
138602
  throw new TypeError("option maxAge is invalid");
138431
138603
  }
138432
- str2 += "; Max-Age=" + Math.floor(maxAge);
138604
+ str2 += "; Max-Age=" + maxAge;
138433
138605
  }
138434
138606
  if (opt.domain) {
138435
- if (!fieldContentRegExp.test(opt.domain)) {
138607
+ if (!domainValueRegExp.test(opt.domain)) {
138436
138608
  throw new TypeError("option domain is invalid");
138437
138609
  }
138438
138610
  str2 += "; Domain=" + opt.domain;
138439
138611
  }
138440
138612
  if (opt.path) {
138441
- if (!fieldContentRegExp.test(opt.path)) {
138613
+ if (!pathValueRegExp.test(opt.path)) {
138442
138614
  throw new TypeError("option path is invalid");
138443
138615
  }
138444
138616
  str2 += "; Path=" + opt.path;
@@ -138456,6 +138628,9 @@ var require_cookie = __commonJS({
138456
138628
  if (opt.secure) {
138457
138629
  str2 += "; Secure";
138458
138630
  }
138631
+ if (opt.partitioned) {
138632
+ str2 += "; Partitioned";
138633
+ }
138459
138634
  if (opt.priority) {
138460
138635
  var priority = typeof opt.priority === "string" ? opt.priority.toLowerCase() : opt.priority;
138461
138636
  switch (priority) {
@@ -138496,11 +138671,8 @@ var require_cookie = __commonJS({
138496
138671
  function decode2(str2) {
138497
138672
  return str2.indexOf("%") !== -1 ? decodeURIComponent(str2) : str2;
138498
138673
  }
138499
- function encode(val) {
138500
- return encodeURIComponent(val);
138501
- }
138502
138674
  function isDate2(val) {
138503
- return __toString.call(val) === "[object Date]" || val instanceof Date;
138675
+ return __toString.call(val) === "[object Date]";
138504
138676
  }
138505
138677
  function tryDecode(str2, decode3) {
138506
138678
  try {
@@ -138869,6 +139041,14 @@ var require_response = __commonJS({
138869
139041
  return this.getHeader(field);
138870
139042
  };
138871
139043
  res.clearCookie = function clearCookie(name3, options) {
139044
+ if (options) {
139045
+ if (options.maxAge) {
139046
+ deprecate3('res.clearCookie: Passing "options.maxAge" is deprecated. In v5.0.0 of Express, this option will be ignored, as res.clearCookie will automatically set cookies to expire immediately. Please update your code to omit this option.');
139047
+ }
139048
+ if (options.expires) {
139049
+ deprecate3('res.clearCookie: Passing "options.expires" is deprecated. In v5.0.0 of Express, this option will be ignored, as res.clearCookie will automatically set cookies to expire immediately. Please update your code to omit this option.');
139050
+ }
139051
+ }
138872
139052
  var opts = merge3({ expires: /* @__PURE__ */ new Date(1), path: "/" }, options);
138873
139053
  return this.cookie(name3, "", opts);
138874
139054
  };
@@ -138897,9 +139077,12 @@ var require_response = __commonJS({
138897
139077
  return this;
138898
139078
  };
138899
139079
  res.location = function location4(url) {
138900
- var loc = url;
139080
+ var loc;
138901
139081
  if (url === "back") {
139082
+ deprecate3('res.location("back"): use res.location(req.get("Referrer") || "/") and refer to https://dub.sh/security-redirect for best practices');
138902
139083
  loc = this.req.get("Referrer") || "/";
139084
+ } else {
139085
+ loc = String(url);
138903
139086
  }
138904
139087
  return this.set("Location", encodeUrl(loc));
138905
139088
  };
@@ -138923,7 +139106,7 @@ var require_response = __commonJS({
138923
139106
  },
138924
139107
  html: function() {
138925
139108
  var u3 = escapeHtml4(address);
138926
- body3 = "<p>" + statuses.message[status] + '. Redirecting to <a href="' + u3 + '">' + u3 + "</a></p>";
139109
+ body3 = "<p>" + statuses.message[status] + ". Redirecting to " + u3 + "</p>";
138927
139110
  },
138928
139111
  default: function() {
138929
139112
  body3 = "";
@@ -139149,7 +139332,7 @@ var require_serve_static = __commonJS({
139149
139332
  originalUrl.path = null;
139150
139333
  originalUrl.pathname = collapseLeadingSlashes(originalUrl.pathname + "/");
139151
139334
  var loc = encodeUrl(url.format(originalUrl));
139152
- var doc = createHtmlDocument("Redirecting", 'Redirecting to <a href="' + escapeHtml4(loc) + '">' + escapeHtml4(loc) + "</a>");
139335
+ var doc = createHtmlDocument("Redirecting", "Redirecting to " + escapeHtml4(loc));
139153
139336
  res.statusCode = 301;
139154
139337
  res.setHeader("Content-Type", "text/html; charset=UTF-8");
139155
139338
  res.setHeader("Content-Length", Buffer.byteLength(doc));
@@ -139348,10 +139531,15 @@ var require_stream = __commonJS({
139348
139531
  var require_constants6 = __commonJS({
139349
139532
  "../../node_modules/ws/lib/constants.js"(exports2, module2) {
139350
139533
  "use strict";
139534
+ var BINARY_TYPES = ["nodebuffer", "arraybuffer", "fragments"];
139535
+ var hasBlob = typeof Blob !== "undefined";
139536
+ if (hasBlob)
139537
+ BINARY_TYPES.push("blob");
139351
139538
  module2.exports = {
139352
- BINARY_TYPES: ["nodebuffer", "arraybuffer", "fragments"],
139539
+ BINARY_TYPES,
139353
139540
  EMPTY_BUFFER: Buffer.alloc(0),
139354
139541
  GUID: "258EAFA5-E914-47DA-95CA-C5AB0DC85B11",
139542
+ hasBlob,
139355
139543
  kForOnEventAttribute: Symbol("kIsForOnEventAttribute"),
139356
139544
  kListener: Symbol("kListener"),
139357
139545
  kStatusCode: Symbol("status-code"),
@@ -139880,6 +140068,7 @@ var require_validation = __commonJS({
139880
140068
  "../../node_modules/ws/lib/validation.js"(exports2, module2) {
139881
140069
  "use strict";
139882
140070
  var { isUtf8 } = require("buffer");
140071
+ var { hasBlob } = require_constants6();
139883
140072
  var tokenChars = [
139884
140073
  0,
139885
140074
  0,
@@ -140050,7 +140239,11 @@ var require_validation = __commonJS({
140050
140239
  }
140051
140240
  return true;
140052
140241
  }
140242
+ function isBlob2(value) {
140243
+ return hasBlob && typeof value === "object" && typeof value.arrayBuffer === "function" && typeof value.type === "string" && typeof value.stream === "function" && (value[Symbol.toStringTag] === "Blob" || value[Symbol.toStringTag] === "File");
140244
+ }
140053
140245
  module2.exports = {
140246
+ isBlob: isBlob2,
140054
140247
  isValidStatusCode,
140055
140248
  isValidUTF8: _isValidUTF8,
140056
140249
  tokenChars
@@ -140092,11 +140285,15 @@ var require_receiver = __commonJS({
140092
140285
  var GET_MASK = 3;
140093
140286
  var GET_DATA = 4;
140094
140287
  var INFLATING = 5;
140288
+ var DEFER_EVENT = 6;
140095
140289
  var Receiver2 = class extends Writable {
140096
140290
  /**
140097
140291
  * Creates a Receiver instance.
140098
140292
  *
140099
140293
  * @param {Object} [options] Options object
140294
+ * @param {Boolean} [options.allowSynchronousEvents=true] Specifies whether
140295
+ * any of the `'message'`, `'ping'`, and `'pong'` events can be emitted
140296
+ * multiple times in the same tick
140100
140297
  * @param {String} [options.binaryType=nodebuffer] The type for binary data
140101
140298
  * @param {Object} [options.extensions] An object containing the negotiated
140102
140299
  * extensions
@@ -140108,6 +140305,7 @@ var require_receiver = __commonJS({
140108
140305
  */
140109
140306
  constructor(options = {}) {
140110
140307
  super();
140308
+ this._allowSynchronousEvents = options.allowSynchronousEvents !== void 0 ? options.allowSynchronousEvents : true;
140111
140309
  this._binaryType = options.binaryType || BINARY_TYPES[0];
140112
140310
  this._extensions = options.extensions || {};
140113
140311
  this._isServer = !!options.isServer;
@@ -140126,8 +140324,9 @@ var require_receiver = __commonJS({
140126
140324
  this._totalPayloadLength = 0;
140127
140325
  this._messageLength = 0;
140128
140326
  this._fragments = [];
140129
- this._state = GET_INFO;
140327
+ this._errored = false;
140130
140328
  this._loop = false;
140329
+ this._state = GET_INFO;
140131
140330
  }
140132
140331
  /**
140133
140332
  * Implements `Writable.prototype._write()`.
@@ -140189,195 +140388,207 @@ var require_receiver = __commonJS({
140189
140388
  * @private
140190
140389
  */
140191
140390
  startLoop(cb) {
140192
- let err;
140193
140391
  this._loop = true;
140194
140392
  do {
140195
140393
  switch (this._state) {
140196
140394
  case GET_INFO:
140197
- err = this.getInfo();
140395
+ this.getInfo(cb);
140198
140396
  break;
140199
140397
  case GET_PAYLOAD_LENGTH_16:
140200
- err = this.getPayloadLength16();
140398
+ this.getPayloadLength16(cb);
140201
140399
  break;
140202
140400
  case GET_PAYLOAD_LENGTH_64:
140203
- err = this.getPayloadLength64();
140401
+ this.getPayloadLength64(cb);
140204
140402
  break;
140205
140403
  case GET_MASK:
140206
140404
  this.getMask();
140207
140405
  break;
140208
140406
  case GET_DATA:
140209
- err = this.getData(cb);
140407
+ this.getData(cb);
140210
140408
  break;
140211
- default:
140409
+ case INFLATING:
140410
+ case DEFER_EVENT:
140212
140411
  this._loop = false;
140213
140412
  return;
140214
140413
  }
140215
140414
  } while (this._loop);
140216
- cb(err);
140415
+ if (!this._errored)
140416
+ cb();
140217
140417
  }
140218
140418
  /**
140219
140419
  * Reads the first two bytes of a frame.
140220
140420
  *
140221
- * @return {(RangeError|undefined)} A possible error
140421
+ * @param {Function} cb Callback
140222
140422
  * @private
140223
140423
  */
140224
- getInfo() {
140424
+ getInfo(cb) {
140225
140425
  if (this._bufferedBytes < 2) {
140226
140426
  this._loop = false;
140227
140427
  return;
140228
140428
  }
140229
140429
  const buf = this.consume(2);
140230
140430
  if ((buf[0] & 48) !== 0) {
140231
- this._loop = false;
140232
- return error(
140431
+ const error = this.createError(
140233
140432
  RangeError,
140234
140433
  "RSV2 and RSV3 must be clear",
140235
140434
  true,
140236
140435
  1002,
140237
140436
  "WS_ERR_UNEXPECTED_RSV_2_3"
140238
140437
  );
140438
+ cb(error);
140439
+ return;
140239
140440
  }
140240
140441
  const compressed = (buf[0] & 64) === 64;
140241
140442
  if (compressed && !this._extensions[PerMessageDeflate.extensionName]) {
140242
- this._loop = false;
140243
- return error(
140443
+ const error = this.createError(
140244
140444
  RangeError,
140245
140445
  "RSV1 must be clear",
140246
140446
  true,
140247
140447
  1002,
140248
140448
  "WS_ERR_UNEXPECTED_RSV_1"
140249
140449
  );
140450
+ cb(error);
140451
+ return;
140250
140452
  }
140251
140453
  this._fin = (buf[0] & 128) === 128;
140252
140454
  this._opcode = buf[0] & 15;
140253
140455
  this._payloadLength = buf[1] & 127;
140254
140456
  if (this._opcode === 0) {
140255
140457
  if (compressed) {
140256
- this._loop = false;
140257
- return error(
140458
+ const error = this.createError(
140258
140459
  RangeError,
140259
140460
  "RSV1 must be clear",
140260
140461
  true,
140261
140462
  1002,
140262
140463
  "WS_ERR_UNEXPECTED_RSV_1"
140263
140464
  );
140465
+ cb(error);
140466
+ return;
140264
140467
  }
140265
140468
  if (!this._fragmented) {
140266
- this._loop = false;
140267
- return error(
140469
+ const error = this.createError(
140268
140470
  RangeError,
140269
140471
  "invalid opcode 0",
140270
140472
  true,
140271
140473
  1002,
140272
140474
  "WS_ERR_INVALID_OPCODE"
140273
140475
  );
140476
+ cb(error);
140477
+ return;
140274
140478
  }
140275
140479
  this._opcode = this._fragmented;
140276
140480
  } else if (this._opcode === 1 || this._opcode === 2) {
140277
140481
  if (this._fragmented) {
140278
- this._loop = false;
140279
- return error(
140482
+ const error = this.createError(
140280
140483
  RangeError,
140281
140484
  `invalid opcode ${this._opcode}`,
140282
140485
  true,
140283
140486
  1002,
140284
140487
  "WS_ERR_INVALID_OPCODE"
140285
140488
  );
140489
+ cb(error);
140490
+ return;
140286
140491
  }
140287
140492
  this._compressed = compressed;
140288
140493
  } else if (this._opcode > 7 && this._opcode < 11) {
140289
140494
  if (!this._fin) {
140290
- this._loop = false;
140291
- return error(
140495
+ const error = this.createError(
140292
140496
  RangeError,
140293
140497
  "FIN must be set",
140294
140498
  true,
140295
140499
  1002,
140296
140500
  "WS_ERR_EXPECTED_FIN"
140297
140501
  );
140502
+ cb(error);
140503
+ return;
140298
140504
  }
140299
140505
  if (compressed) {
140300
- this._loop = false;
140301
- return error(
140506
+ const error = this.createError(
140302
140507
  RangeError,
140303
140508
  "RSV1 must be clear",
140304
140509
  true,
140305
140510
  1002,
140306
140511
  "WS_ERR_UNEXPECTED_RSV_1"
140307
140512
  );
140513
+ cb(error);
140514
+ return;
140308
140515
  }
140309
140516
  if (this._payloadLength > 125 || this._opcode === 8 && this._payloadLength === 1) {
140310
- this._loop = false;
140311
- return error(
140517
+ const error = this.createError(
140312
140518
  RangeError,
140313
140519
  `invalid payload length ${this._payloadLength}`,
140314
140520
  true,
140315
140521
  1002,
140316
140522
  "WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH"
140317
140523
  );
140524
+ cb(error);
140525
+ return;
140318
140526
  }
140319
140527
  } else {
140320
- this._loop = false;
140321
- return error(
140528
+ const error = this.createError(
140322
140529
  RangeError,
140323
140530
  `invalid opcode ${this._opcode}`,
140324
140531
  true,
140325
140532
  1002,
140326
140533
  "WS_ERR_INVALID_OPCODE"
140327
140534
  );
140535
+ cb(error);
140536
+ return;
140328
140537
  }
140329
140538
  if (!this._fin && !this._fragmented)
140330
140539
  this._fragmented = this._opcode;
140331
140540
  this._masked = (buf[1] & 128) === 128;
140332
140541
  if (this._isServer) {
140333
140542
  if (!this._masked) {
140334
- this._loop = false;
140335
- return error(
140543
+ const error = this.createError(
140336
140544
  RangeError,
140337
140545
  "MASK must be set",
140338
140546
  true,
140339
140547
  1002,
140340
140548
  "WS_ERR_EXPECTED_MASK"
140341
140549
  );
140550
+ cb(error);
140551
+ return;
140342
140552
  }
140343
140553
  } else if (this._masked) {
140344
- this._loop = false;
140345
- return error(
140554
+ const error = this.createError(
140346
140555
  RangeError,
140347
140556
  "MASK must be clear",
140348
140557
  true,
140349
140558
  1002,
140350
140559
  "WS_ERR_UNEXPECTED_MASK"
140351
140560
  );
140561
+ cb(error);
140562
+ return;
140352
140563
  }
140353
140564
  if (this._payloadLength === 126)
140354
140565
  this._state = GET_PAYLOAD_LENGTH_16;
140355
140566
  else if (this._payloadLength === 127)
140356
140567
  this._state = GET_PAYLOAD_LENGTH_64;
140357
140568
  else
140358
- return this.haveLength();
140569
+ this.haveLength(cb);
140359
140570
  }
140360
140571
  /**
140361
140572
  * Gets extended payload length (7+16).
140362
140573
  *
140363
- * @return {(RangeError|undefined)} A possible error
140574
+ * @param {Function} cb Callback
140364
140575
  * @private
140365
140576
  */
140366
- getPayloadLength16() {
140577
+ getPayloadLength16(cb) {
140367
140578
  if (this._bufferedBytes < 2) {
140368
140579
  this._loop = false;
140369
140580
  return;
140370
140581
  }
140371
140582
  this._payloadLength = this.consume(2).readUInt16BE(0);
140372
- return this.haveLength();
140583
+ this.haveLength(cb);
140373
140584
  }
140374
140585
  /**
140375
140586
  * Gets extended payload length (7+64).
140376
140587
  *
140377
- * @return {(RangeError|undefined)} A possible error
140588
+ * @param {Function} cb Callback
140378
140589
  * @private
140379
140590
  */
140380
- getPayloadLength64() {
140591
+ getPayloadLength64(cb) {
140381
140592
  if (this._bufferedBytes < 8) {
140382
140593
  this._loop = false;
140383
140594
  return;
@@ -140385,36 +140596,38 @@ var require_receiver = __commonJS({
140385
140596
  const buf = this.consume(8);
140386
140597
  const num = buf.readUInt32BE(0);
140387
140598
  if (num > Math.pow(2, 53 - 32) - 1) {
140388
- this._loop = false;
140389
- return error(
140599
+ const error = this.createError(
140390
140600
  RangeError,
140391
140601
  "Unsupported WebSocket frame: payload length > 2^53 - 1",
140392
140602
  false,
140393
140603
  1009,
140394
140604
  "WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH"
140395
140605
  );
140606
+ cb(error);
140607
+ return;
140396
140608
  }
140397
140609
  this._payloadLength = num * Math.pow(2, 32) + buf.readUInt32BE(4);
140398
- return this.haveLength();
140610
+ this.haveLength(cb);
140399
140611
  }
140400
140612
  /**
140401
140613
  * Payload length has been read.
140402
140614
  *
140403
- * @return {(RangeError|undefined)} A possible error
140615
+ * @param {Function} cb Callback
140404
140616
  * @private
140405
140617
  */
140406
- haveLength() {
140618
+ haveLength(cb) {
140407
140619
  if (this._payloadLength && this._opcode < 8) {
140408
140620
  this._totalPayloadLength += this._payloadLength;
140409
140621
  if (this._totalPayloadLength > this._maxPayload && this._maxPayload > 0) {
140410
- this._loop = false;
140411
- return error(
140622
+ const error = this.createError(
140412
140623
  RangeError,
140413
140624
  "Max payload size exceeded",
140414
140625
  false,
140415
140626
  1009,
140416
140627
  "WS_ERR_UNSUPPORTED_MESSAGE_LENGTH"
140417
140628
  );
140629
+ cb(error);
140630
+ return;
140418
140631
  }
140419
140632
  }
140420
140633
  if (this._masked)
@@ -140439,7 +140652,6 @@ var require_receiver = __commonJS({
140439
140652
  * Reads data bytes.
140440
140653
  *
140441
140654
  * @param {Function} cb Callback
140442
- * @return {(Error|RangeError|undefined)} A possible error
140443
140655
  * @private
140444
140656
  */
140445
140657
  getData(cb) {
@@ -140454,8 +140666,10 @@ var require_receiver = __commonJS({
140454
140666
  unmask(data, this._mask);
140455
140667
  }
140456
140668
  }
140457
- if (this._opcode > 7)
140458
- return this.controlMessage(data);
140669
+ if (this._opcode > 7) {
140670
+ this.controlMessage(data, cb);
140671
+ return;
140672
+ }
140459
140673
  if (this._compressed) {
140460
140674
  this._state = INFLATING;
140461
140675
  this.decompress(data, cb);
@@ -140465,7 +140679,7 @@ var require_receiver = __commonJS({
140465
140679
  this._messageLength = this._totalPayloadLength;
140466
140680
  this._fragments.push(data);
140467
140681
  }
140468
- return this.dataMessage();
140682
+ this.dataMessage(cb);
140469
140683
  }
140470
140684
  /**
140471
140685
  * Decompresses data.
@@ -140482,64 +140696,87 @@ var require_receiver = __commonJS({
140482
140696
  if (buf.length) {
140483
140697
  this._messageLength += buf.length;
140484
140698
  if (this._messageLength > this._maxPayload && this._maxPayload > 0) {
140485
- return cb(
140486
- error(
140487
- RangeError,
140488
- "Max payload size exceeded",
140489
- false,
140490
- 1009,
140491
- "WS_ERR_UNSUPPORTED_MESSAGE_LENGTH"
140492
- )
140699
+ const error = this.createError(
140700
+ RangeError,
140701
+ "Max payload size exceeded",
140702
+ false,
140703
+ 1009,
140704
+ "WS_ERR_UNSUPPORTED_MESSAGE_LENGTH"
140493
140705
  );
140706
+ cb(error);
140707
+ return;
140494
140708
  }
140495
140709
  this._fragments.push(buf);
140496
140710
  }
140497
- const er = this.dataMessage();
140498
- if (er)
140499
- return cb(er);
140500
- this.startLoop(cb);
140711
+ this.dataMessage(cb);
140712
+ if (this._state === GET_INFO)
140713
+ this.startLoop(cb);
140501
140714
  });
140502
140715
  }
140503
140716
  /**
140504
140717
  * Handles a data message.
140505
140718
  *
140506
- * @return {(Error|undefined)} A possible error
140719
+ * @param {Function} cb Callback
140507
140720
  * @private
140508
140721
  */
140509
- dataMessage() {
140510
- if (this._fin) {
140511
- const messageLength = this._messageLength;
140512
- const fragments = this._fragments;
140513
- this._totalPayloadLength = 0;
140514
- this._messageLength = 0;
140515
- this._fragmented = 0;
140516
- this._fragments = [];
140517
- if (this._opcode === 2) {
140518
- let data;
140519
- if (this._binaryType === "nodebuffer") {
140520
- data = concat2(fragments, messageLength);
140521
- } else if (this._binaryType === "arraybuffer") {
140522
- data = toArrayBuffer(concat2(fragments, messageLength));
140523
- } else {
140524
- data = fragments;
140525
- }
140722
+ dataMessage(cb) {
140723
+ if (!this._fin) {
140724
+ this._state = GET_INFO;
140725
+ return;
140726
+ }
140727
+ const messageLength = this._messageLength;
140728
+ const fragments = this._fragments;
140729
+ this._totalPayloadLength = 0;
140730
+ this._messageLength = 0;
140731
+ this._fragmented = 0;
140732
+ this._fragments = [];
140733
+ if (this._opcode === 2) {
140734
+ let data;
140735
+ if (this._binaryType === "nodebuffer") {
140736
+ data = concat2(fragments, messageLength);
140737
+ } else if (this._binaryType === "arraybuffer") {
140738
+ data = toArrayBuffer(concat2(fragments, messageLength));
140739
+ } else if (this._binaryType === "blob") {
140740
+ data = new Blob(fragments);
140741
+ } else {
140742
+ data = fragments;
140743
+ }
140744
+ if (this._allowSynchronousEvents) {
140526
140745
  this.emit("message", data, true);
140746
+ this._state = GET_INFO;
140527
140747
  } else {
140528
- const buf = concat2(fragments, messageLength);
140529
- if (!this._skipUTF8Validation && !isValidUTF8(buf)) {
140530
- this._loop = false;
140531
- return error(
140532
- Error,
140533
- "invalid UTF-8 sequence",
140534
- true,
140535
- 1007,
140536
- "WS_ERR_INVALID_UTF8"
140537
- );
140538
- }
140748
+ this._state = DEFER_EVENT;
140749
+ setImmediate(() => {
140750
+ this.emit("message", data, true);
140751
+ this._state = GET_INFO;
140752
+ this.startLoop(cb);
140753
+ });
140754
+ }
140755
+ } else {
140756
+ const buf = concat2(fragments, messageLength);
140757
+ if (!this._skipUTF8Validation && !isValidUTF8(buf)) {
140758
+ const error = this.createError(
140759
+ Error,
140760
+ "invalid UTF-8 sequence",
140761
+ true,
140762
+ 1007,
140763
+ "WS_ERR_INVALID_UTF8"
140764
+ );
140765
+ cb(error);
140766
+ return;
140767
+ }
140768
+ if (this._state === INFLATING || this._allowSynchronousEvents) {
140539
140769
  this.emit("message", buf, false);
140770
+ this._state = GET_INFO;
140771
+ } else {
140772
+ this._state = DEFER_EVENT;
140773
+ setImmediate(() => {
140774
+ this.emit("message", buf, false);
140775
+ this._state = GET_INFO;
140776
+ this.startLoop(cb);
140777
+ });
140540
140778
  }
140541
140779
  }
140542
- this._state = GET_INFO;
140543
140780
  }
140544
140781
  /**
140545
140782
  * Handles a control message.
@@ -140548,22 +140785,24 @@ var require_receiver = __commonJS({
140548
140785
  * @return {(Error|RangeError|undefined)} A possible error
140549
140786
  * @private
140550
140787
  */
140551
- controlMessage(data) {
140788
+ controlMessage(data, cb) {
140552
140789
  if (this._opcode === 8) {
140553
- this._loop = false;
140554
140790
  if (data.length === 0) {
140791
+ this._loop = false;
140555
140792
  this.emit("conclude", 1005, EMPTY_BUFFER);
140556
140793
  this.end();
140557
140794
  } else {
140558
140795
  const code7 = data.readUInt16BE(0);
140559
140796
  if (!isValidStatusCode(code7)) {
140560
- return error(
140797
+ const error = this.createError(
140561
140798
  RangeError,
140562
140799
  `invalid status code ${code7}`,
140563
140800
  true,
140564
140801
  1002,
140565
140802
  "WS_ERR_INVALID_CLOSE_CODE"
140566
140803
  );
140804
+ cb(error);
140805
+ return;
140567
140806
  }
140568
140807
  const buf = new FastBuffer(
140569
140808
  data.buffer,
@@ -140571,35 +140810,60 @@ var require_receiver = __commonJS({
140571
140810
  data.length - 2
140572
140811
  );
140573
140812
  if (!this._skipUTF8Validation && !isValidUTF8(buf)) {
140574
- return error(
140813
+ const error = this.createError(
140575
140814
  Error,
140576
140815
  "invalid UTF-8 sequence",
140577
140816
  true,
140578
140817
  1007,
140579
140818
  "WS_ERR_INVALID_UTF8"
140580
140819
  );
140820
+ cb(error);
140821
+ return;
140581
140822
  }
140823
+ this._loop = false;
140582
140824
  this.emit("conclude", code7, buf);
140583
140825
  this.end();
140584
140826
  }
140585
- } else if (this._opcode === 9) {
140586
- this.emit("ping", data);
140827
+ this._state = GET_INFO;
140828
+ return;
140829
+ }
140830
+ if (this._allowSynchronousEvents) {
140831
+ this.emit(this._opcode === 9 ? "ping" : "pong", data);
140832
+ this._state = GET_INFO;
140587
140833
  } else {
140588
- this.emit("pong", data);
140834
+ this._state = DEFER_EVENT;
140835
+ setImmediate(() => {
140836
+ this.emit(this._opcode === 9 ? "ping" : "pong", data);
140837
+ this._state = GET_INFO;
140838
+ this.startLoop(cb);
140839
+ });
140589
140840
  }
140590
- this._state = GET_INFO;
140841
+ }
140842
+ /**
140843
+ * Builds an error object.
140844
+ *
140845
+ * @param {function(new:Error|RangeError)} ErrorCtor The error constructor
140846
+ * @param {String} message The error message
140847
+ * @param {Boolean} prefix Specifies whether or not to add a default prefix to
140848
+ * `message`
140849
+ * @param {Number} statusCode The status code
140850
+ * @param {String} errorCode The exposed error code
140851
+ * @return {(Error|RangeError)} The error
140852
+ * @private
140853
+ */
140854
+ createError(ErrorCtor, message, prefix2, statusCode, errorCode) {
140855
+ this._loop = false;
140856
+ this._errored = true;
140857
+ const err = new ErrorCtor(
140858
+ prefix2 ? `Invalid WebSocket frame: ${message}` : message
140859
+ );
140860
+ Error.captureStackTrace(err, this.createError);
140861
+ err.code = errorCode;
140862
+ err[kStatusCode] = statusCode;
140863
+ return err;
140591
140864
  }
140592
140865
  };
140593
140866
  module2.exports = Receiver2;
140594
- function error(ErrorCtor, message, prefix2, statusCode, errorCode) {
140595
- const err = new ErrorCtor(
140596
- prefix2 ? `Invalid WebSocket frame: ${message}` : message
140597
- );
140598
- Error.captureStackTrace(err, error);
140599
- err.code = errorCode;
140600
- err[kStatusCode] = statusCode;
140601
- return err;
140602
- }
140603
140867
  }
140604
140868
  });
140605
140869
 
@@ -140607,20 +140871,25 @@ var require_receiver = __commonJS({
140607
140871
  var require_sender = __commonJS({
140608
140872
  "../../node_modules/ws/lib/sender.js"(exports2, module2) {
140609
140873
  "use strict";
140610
- var net3 = require("net");
140611
- var tls = require("tls");
140874
+ var { Duplex: Duplex2 } = require("stream");
140612
140875
  var { randomFillSync: randomFillSync2 } = require("crypto");
140613
140876
  var PerMessageDeflate = require_permessage_deflate();
140614
- var { EMPTY_BUFFER } = require_constants6();
140615
- var { isValidStatusCode } = require_validation();
140877
+ var { EMPTY_BUFFER, kWebSocket, NOOP } = require_constants6();
140878
+ var { isBlob: isBlob2, isValidStatusCode } = require_validation();
140616
140879
  var { mask: applyMask, toBuffer } = require_buffer_util();
140617
140880
  var kByteLength = Symbol("kByteLength");
140618
140881
  var maskBuffer = Buffer.alloc(4);
140882
+ var RANDOM_POOL_SIZE = 8 * 1024;
140883
+ var randomPool;
140884
+ var randomPoolPointer = RANDOM_POOL_SIZE;
140885
+ var DEFAULT = 0;
140886
+ var DEFLATING = 1;
140887
+ var GET_BLOB_DATA = 2;
140619
140888
  var Sender2 = class {
140620
140889
  /**
140621
140890
  * Creates a Sender instance.
140622
140891
  *
140623
- * @param {(net.Socket|tls.Socket)} socket The connection socket
140892
+ * @param {Duplex} socket The connection socket
140624
140893
  * @param {Object} [extensions] An object containing the negotiated extensions
140625
140894
  * @param {Function} [generateMask] The function used to generate the masking
140626
140895
  * key
@@ -140635,8 +140904,10 @@ var require_sender = __commonJS({
140635
140904
  this._firstFragment = true;
140636
140905
  this._compress = false;
140637
140906
  this._bufferedBytes = 0;
140638
- this._deflating = false;
140639
140907
  this._queue = [];
140908
+ this._state = DEFAULT;
140909
+ this.onerror = NOOP;
140910
+ this[kWebSocket] = void 0;
140640
140911
  }
140641
140912
  /**
140642
140913
  * Frames a piece of data according to the HyBi WebSocket protocol.
@@ -140669,7 +140940,17 @@ var require_sender = __commonJS({
140669
140940
  if (options.generateMask) {
140670
140941
  options.generateMask(mask2);
140671
140942
  } else {
140672
- randomFillSync2(mask2, 0, 4);
140943
+ if (randomPoolPointer === RANDOM_POOL_SIZE) {
140944
+ if (randomPool === void 0) {
140945
+ randomPool = Buffer.alloc(RANDOM_POOL_SIZE);
140946
+ }
140947
+ randomFillSync2(randomPool, 0, RANDOM_POOL_SIZE);
140948
+ randomPoolPointer = 0;
140949
+ }
140950
+ mask2[0] = randomPool[randomPoolPointer++];
140951
+ mask2[1] = randomPool[randomPoolPointer++];
140952
+ mask2[2] = randomPool[randomPoolPointer++];
140953
+ mask2[3] = randomPool[randomPoolPointer++];
140673
140954
  }
140674
140955
  skipMasking = (mask2[0] | mask2[1] | mask2[2] | mask2[3]) === 0;
140675
140956
  offset = 6;
@@ -140762,7 +141043,7 @@ var require_sender = __commonJS({
140762
141043
  readOnly: false,
140763
141044
  rsv1: false
140764
141045
  };
140765
- if (this._deflating) {
141046
+ if (this._state !== DEFAULT) {
140766
141047
  this.enqueue([this.dispatch, buf, false, options, cb]);
140767
141048
  } else {
140768
141049
  this.sendFrame(Sender2.frame(buf, options), cb);
@@ -140782,6 +141063,9 @@ var require_sender = __commonJS({
140782
141063
  if (typeof data === "string") {
140783
141064
  byteLength2 = Buffer.byteLength(data);
140784
141065
  readOnly = false;
141066
+ } else if (isBlob2(data)) {
141067
+ byteLength2 = data.size;
141068
+ readOnly = false;
140785
141069
  } else {
140786
141070
  data = toBuffer(data);
140787
141071
  byteLength2 = data.length;
@@ -140800,7 +141084,13 @@ var require_sender = __commonJS({
140800
141084
  readOnly,
140801
141085
  rsv1: false
140802
141086
  };
140803
- if (this._deflating) {
141087
+ if (isBlob2(data)) {
141088
+ if (this._state !== DEFAULT) {
141089
+ this.enqueue([this.getBlobData, data, false, options, cb]);
141090
+ } else {
141091
+ this.getBlobData(data, false, options, cb);
141092
+ }
141093
+ } else if (this._state !== DEFAULT) {
140804
141094
  this.enqueue([this.dispatch, data, false, options, cb]);
140805
141095
  } else {
140806
141096
  this.sendFrame(Sender2.frame(data, options), cb);
@@ -140820,6 +141110,9 @@ var require_sender = __commonJS({
140820
141110
  if (typeof data === "string") {
140821
141111
  byteLength2 = Buffer.byteLength(data);
140822
141112
  readOnly = false;
141113
+ } else if (isBlob2(data)) {
141114
+ byteLength2 = data.size;
141115
+ readOnly = false;
140823
141116
  } else {
140824
141117
  data = toBuffer(data);
140825
141118
  byteLength2 = data.length;
@@ -140838,7 +141131,13 @@ var require_sender = __commonJS({
140838
141131
  readOnly,
140839
141132
  rsv1: false
140840
141133
  };
140841
- if (this._deflating) {
141134
+ if (isBlob2(data)) {
141135
+ if (this._state !== DEFAULT) {
141136
+ this.enqueue([this.getBlobData, data, false, options, cb]);
141137
+ } else {
141138
+ this.getBlobData(data, false, options, cb);
141139
+ }
141140
+ } else if (this._state !== DEFAULT) {
140842
141141
  this.enqueue([this.dispatch, data, false, options, cb]);
140843
141142
  } else {
140844
141143
  this.sendFrame(Sender2.frame(data, options), cb);
@@ -140869,6 +141168,9 @@ var require_sender = __commonJS({
140869
141168
  if (typeof data === "string") {
140870
141169
  byteLength2 = Buffer.byteLength(data);
140871
141170
  readOnly = false;
141171
+ } else if (isBlob2(data)) {
141172
+ byteLength2 = data.size;
141173
+ readOnly = false;
140872
141174
  } else {
140873
141175
  data = toBuffer(data);
140874
141176
  byteLength2 = data.length;
@@ -140886,38 +141188,75 @@ var require_sender = __commonJS({
140886
141188
  }
140887
141189
  if (options.fin)
140888
141190
  this._firstFragment = true;
140889
- if (perMessageDeflate) {
140890
- const opts = {
140891
- [kByteLength]: byteLength2,
140892
- fin: options.fin,
140893
- generateMask: this._generateMask,
140894
- mask: options.mask,
140895
- maskBuffer: this._maskBuffer,
140896
- opcode,
140897
- readOnly,
140898
- rsv1
140899
- };
140900
- if (this._deflating) {
140901
- this.enqueue([this.dispatch, data, this._compress, opts, cb]);
141191
+ const opts = {
141192
+ [kByteLength]: byteLength2,
141193
+ fin: options.fin,
141194
+ generateMask: this._generateMask,
141195
+ mask: options.mask,
141196
+ maskBuffer: this._maskBuffer,
141197
+ opcode,
141198
+ readOnly,
141199
+ rsv1
141200
+ };
141201
+ if (isBlob2(data)) {
141202
+ if (this._state !== DEFAULT) {
141203
+ this.enqueue([this.getBlobData, data, this._compress, opts, cb]);
140902
141204
  } else {
140903
- this.dispatch(data, this._compress, opts, cb);
140904
- }
140905
- } else {
140906
- this.sendFrame(
140907
- Sender2.frame(data, {
140908
- [kByteLength]: byteLength2,
140909
- fin: options.fin,
140910
- generateMask: this._generateMask,
140911
- mask: options.mask,
140912
- maskBuffer: this._maskBuffer,
140913
- opcode,
140914
- readOnly,
140915
- rsv1: false
140916
- }),
140917
- cb
140918
- );
141205
+ this.getBlobData(data, this._compress, opts, cb);
141206
+ }
141207
+ } else if (this._state !== DEFAULT) {
141208
+ this.enqueue([this.dispatch, data, this._compress, opts, cb]);
141209
+ } else {
141210
+ this.dispatch(data, this._compress, opts, cb);
140919
141211
  }
140920
141212
  }
141213
+ /**
141214
+ * Gets the contents of a blob as binary data.
141215
+ *
141216
+ * @param {Blob} blob The blob
141217
+ * @param {Boolean} [compress=false] Specifies whether or not to compress
141218
+ * the data
141219
+ * @param {Object} options Options object
141220
+ * @param {Boolean} [options.fin=false] Specifies whether or not to set the
141221
+ * FIN bit
141222
+ * @param {Function} [options.generateMask] The function used to generate the
141223
+ * masking key
141224
+ * @param {Boolean} [options.mask=false] Specifies whether or not to mask
141225
+ * `data`
141226
+ * @param {Buffer} [options.maskBuffer] The buffer used to store the masking
141227
+ * key
141228
+ * @param {Number} options.opcode The opcode
141229
+ * @param {Boolean} [options.readOnly=false] Specifies whether `data` can be
141230
+ * modified
141231
+ * @param {Boolean} [options.rsv1=false] Specifies whether or not to set the
141232
+ * RSV1 bit
141233
+ * @param {Function} [cb] Callback
141234
+ * @private
141235
+ */
141236
+ getBlobData(blob, compress, options, cb) {
141237
+ this._bufferedBytes += options[kByteLength];
141238
+ this._state = GET_BLOB_DATA;
141239
+ blob.arrayBuffer().then((arrayBuffer) => {
141240
+ if (this._socket.destroyed) {
141241
+ const err = new Error(
141242
+ "The socket was closed while the blob was being read"
141243
+ );
141244
+ process.nextTick(callCallbacks, this, err, cb);
141245
+ return;
141246
+ }
141247
+ this._bufferedBytes -= options[kByteLength];
141248
+ const data = toBuffer(arrayBuffer);
141249
+ if (!compress) {
141250
+ this._state = DEFAULT;
141251
+ this.sendFrame(Sender2.frame(data, options), cb);
141252
+ this.dequeue();
141253
+ } else {
141254
+ this.dispatch(data, compress, options, cb);
141255
+ }
141256
+ }).catch((err) => {
141257
+ process.nextTick(onError, this, err, cb);
141258
+ });
141259
+ }
140921
141260
  /**
140922
141261
  * Dispatches a message.
140923
141262
  *
@@ -140948,24 +141287,17 @@ var require_sender = __commonJS({
140948
141287
  }
140949
141288
  const perMessageDeflate = this._extensions[PerMessageDeflate.extensionName];
140950
141289
  this._bufferedBytes += options[kByteLength];
140951
- this._deflating = true;
141290
+ this._state = DEFLATING;
140952
141291
  perMessageDeflate.compress(data, options.fin, (_3, buf) => {
140953
141292
  if (this._socket.destroyed) {
140954
141293
  const err = new Error(
140955
141294
  "The socket was closed while data was being compressed"
140956
141295
  );
140957
- if (typeof cb === "function")
140958
- cb(err);
140959
- for (let i2 = 0; i2 < this._queue.length; i2++) {
140960
- const params = this._queue[i2];
140961
- const callback = params[params.length - 1];
140962
- if (typeof callback === "function")
140963
- callback(err);
140964
- }
141296
+ callCallbacks(this, err, cb);
140965
141297
  return;
140966
141298
  }
140967
141299
  this._bufferedBytes -= options[kByteLength];
140968
- this._deflating = false;
141300
+ this._state = DEFAULT;
140969
141301
  options.readOnly = false;
140970
141302
  this.sendFrame(Sender2.frame(buf, options), cb);
140971
141303
  this.dequeue();
@@ -140977,7 +141309,7 @@ var require_sender = __commonJS({
140977
141309
  * @private
140978
141310
  */
140979
141311
  dequeue() {
140980
- while (!this._deflating && this._queue.length) {
141312
+ while (this._state === DEFAULT && this._queue.length) {
140981
141313
  const params = this._queue.shift();
140982
141314
  this._bufferedBytes -= params[3][kByteLength];
140983
141315
  Reflect.apply(params[0], this, params.slice(1));
@@ -141012,6 +141344,20 @@ var require_sender = __commonJS({
141012
141344
  }
141013
141345
  };
141014
141346
  module2.exports = Sender2;
141347
+ function callCallbacks(sender, err, cb) {
141348
+ if (typeof cb === "function")
141349
+ cb(err);
141350
+ for (let i2 = 0; i2 < sender._queue.length; i2++) {
141351
+ const params = sender._queue[i2];
141352
+ const callback = params[params.length - 1];
141353
+ if (typeof callback === "function")
141354
+ callback(err);
141355
+ }
141356
+ }
141357
+ function onError(sender, err, cb) {
141358
+ callCallbacks(sender, err, cb);
141359
+ sender.onerror(err);
141360
+ }
141015
141361
  }
141016
141362
  });
141017
141363
 
@@ -141424,11 +141770,12 @@ var require_websocket = __commonJS({
141424
141770
  var net3 = require("net");
141425
141771
  var tls = require("tls");
141426
141772
  var { randomBytes, createHash: createHash5 } = require("crypto");
141427
- var { Readable } = require("stream");
141773
+ var { Duplex: Duplex2, Readable } = require("stream");
141428
141774
  var { URL: URL4 } = require("url");
141429
141775
  var PerMessageDeflate = require_permessage_deflate();
141430
141776
  var Receiver2 = require_receiver();
141431
141777
  var Sender2 = require_sender();
141778
+ var { isBlob: isBlob2 } = require_validation();
141432
141779
  var {
141433
141780
  BINARY_TYPES,
141434
141781
  EMPTY_BUFFER,
@@ -141465,6 +141812,7 @@ var require_websocket = __commonJS({
141465
141812
  this._closeFrameSent = false;
141466
141813
  this._closeMessage = EMPTY_BUFFER;
141467
141814
  this._closeTimer = null;
141815
+ this._errorEmitted = false;
141468
141816
  this._extensions = {};
141469
141817
  this._paused = false;
141470
141818
  this._protocol = "";
@@ -141488,13 +141836,13 @@ var require_websocket = __commonJS({
141488
141836
  }
141489
141837
  initAsClient(this, address, protocols, options);
141490
141838
  } else {
141839
+ this._autoPong = options.autoPong;
141491
141840
  this._isServer = true;
141492
141841
  }
141493
141842
  }
141494
141843
  /**
141495
- * This deviates from the WHATWG interface since ws doesn't support the
141496
- * required default "blob" type (instead we define a custom "nodebuffer"
141497
- * type).
141844
+ * For historical reasons, the custom "nodebuffer" type is used by the default
141845
+ * instead of "blob".
141498
141846
  *
141499
141847
  * @type {String}
141500
141848
  */
@@ -141577,10 +141925,12 @@ var require_websocket = __commonJS({
141577
141925
  /**
141578
141926
  * Set up the socket and the internal resources.
141579
141927
  *
141580
- * @param {(net.Socket|tls.Socket)} socket The network socket between the
141581
- * server and client
141928
+ * @param {Duplex} socket The network socket between the server and client
141582
141929
  * @param {Buffer} head The first packet of the upgraded stream
141583
141930
  * @param {Object} options Options object
141931
+ * @param {Boolean} [options.allowSynchronousEvents=false] Specifies whether
141932
+ * any of the `'message'`, `'ping'`, and `'pong'` events can be emitted
141933
+ * multiple times in the same tick
141584
141934
  * @param {Function} [options.generateMask] The function used to generate the
141585
141935
  * masking key
141586
141936
  * @param {Number} [options.maxPayload=0] The maximum allowed message size
@@ -141590,16 +141940,19 @@ var require_websocket = __commonJS({
141590
141940
  */
141591
141941
  setSocket(socket, head2, options) {
141592
141942
  const receiver = new Receiver2({
141943
+ allowSynchronousEvents: options.allowSynchronousEvents,
141593
141944
  binaryType: this.binaryType,
141594
141945
  extensions: this._extensions,
141595
141946
  isServer: this._isServer,
141596
141947
  maxPayload: options.maxPayload,
141597
141948
  skipUTF8Validation: options.skipUTF8Validation
141598
141949
  });
141599
- this._sender = new Sender2(socket, this._extensions, options.generateMask);
141950
+ const sender = new Sender2(socket, this._extensions, options.generateMask);
141600
141951
  this._receiver = receiver;
141952
+ this._sender = sender;
141601
141953
  this._socket = socket;
141602
141954
  receiver[kWebSocket] = this;
141955
+ sender[kWebSocket] = this;
141603
141956
  socket[kWebSocket] = this;
141604
141957
  receiver.on("conclude", receiverOnConclude);
141605
141958
  receiver.on("drain", receiverOnDrain);
@@ -141607,8 +141960,11 @@ var require_websocket = __commonJS({
141607
141960
  receiver.on("message", receiverOnMessage);
141608
141961
  receiver.on("ping", receiverOnPing);
141609
141962
  receiver.on("pong", receiverOnPong);
141610
- socket.setTimeout(0);
141611
- socket.setNoDelay();
141963
+ sender.onerror = senderOnError;
141964
+ if (socket.setTimeout)
141965
+ socket.setTimeout(0);
141966
+ if (socket.setNoDelay)
141967
+ socket.setNoDelay();
141612
141968
  if (head2.length > 0)
141613
141969
  socket.unshift(head2);
141614
141970
  socket.on("close", socketOnClose);
@@ -141679,10 +142035,7 @@ var require_websocket = __commonJS({
141679
142035
  this._socket.end();
141680
142036
  }
141681
142037
  });
141682
- this._closeTimer = setTimeout(
141683
- this._socket.destroy.bind(this._socket),
141684
- closeTimeout
141685
- );
142038
+ setCloseTimer(this);
141686
142039
  }
141687
142040
  /**
141688
142041
  * Pause the socket.
@@ -141900,6 +142253,8 @@ var require_websocket = __commonJS({
141900
142253
  module2.exports = WebSocket3;
141901
142254
  function initAsClient(websocket, address, protocols, options) {
141902
142255
  const opts = {
142256
+ allowSynchronousEvents: true,
142257
+ autoPong: true,
141903
142258
  protocolVersion: protocolVersions[1],
141904
142259
  maxPayload: 100 * 1024 * 1024,
141905
142260
  skipUTF8Validation: false,
@@ -141907,7 +142262,6 @@ var require_websocket = __commonJS({
141907
142262
  followRedirects: false,
141908
142263
  maxRedirects: 10,
141909
142264
  ...options,
141910
- createConnection: void 0,
141911
142265
  socketPath: void 0,
141912
142266
  hostname: void 0,
141913
142267
  protocol: void 0,
@@ -141917,6 +142271,7 @@ var require_websocket = __commonJS({
141917
142271
  path: void 0,
141918
142272
  port: void 0
141919
142273
  };
142274
+ websocket._autoPong = opts.autoPong;
141920
142275
  if (!protocolVersions.includes(opts.protocolVersion)) {
141921
142276
  throw new RangeError(
141922
142277
  `Unsupported protocol version: ${opts.protocolVersion} (supported versions: ${protocolVersions.join(", ")})`
@@ -141925,20 +142280,24 @@ var require_websocket = __commonJS({
141925
142280
  let parsedUrl;
141926
142281
  if (address instanceof URL4) {
141927
142282
  parsedUrl = address;
141928
- websocket._url = address.href;
141929
142283
  } else {
141930
142284
  try {
141931
142285
  parsedUrl = new URL4(address);
141932
142286
  } catch (e2) {
141933
142287
  throw new SyntaxError(`Invalid URL: ${address}`);
141934
142288
  }
141935
- websocket._url = address;
141936
142289
  }
142290
+ if (parsedUrl.protocol === "http:") {
142291
+ parsedUrl.protocol = "ws:";
142292
+ } else if (parsedUrl.protocol === "https:") {
142293
+ parsedUrl.protocol = "wss:";
142294
+ }
142295
+ websocket._url = parsedUrl.href;
141937
142296
  const isSecure = parsedUrl.protocol === "wss:";
141938
142297
  const isIpcUrl = parsedUrl.protocol === "ws+unix:";
141939
142298
  let invalidUrlMessage;
141940
142299
  if (parsedUrl.protocol !== "ws:" && !isSecure && !isIpcUrl) {
141941
- invalidUrlMessage = `The URL's protocol must be one of "ws:", "wss:", or "ws+unix:"`;
142300
+ invalidUrlMessage = `The URL's protocol must be one of "ws:", "wss:", "http:", "https", or "ws+unix:"`;
141942
142301
  } else if (isIpcUrl && !parsedUrl.pathname) {
141943
142302
  invalidUrlMessage = "The URL's pathname is empty";
141944
142303
  } else if (parsedUrl.hash) {
@@ -141958,7 +142317,7 @@ var require_websocket = __commonJS({
141958
142317
  const request = isSecure ? https3.request : http5.request;
141959
142318
  const protocolSet = /* @__PURE__ */ new Set();
141960
142319
  let perMessageDeflate;
141961
- opts.createConnection = isSecure ? tlsConnect : netConnect;
142320
+ opts.createConnection = opts.createConnection || (isSecure ? tlsConnect : netConnect);
141962
142321
  opts.defaultPort = opts.defaultPort || defaultPort;
141963
142322
  opts.port = parsedUrl.port || defaultPort;
141964
142323
  opts.host = parsedUrl.hostname.startsWith("[") ? parsedUrl.hostname.slice(1, -1) : parsedUrl.hostname;
@@ -142082,7 +142441,8 @@ var require_websocket = __commonJS({
142082
142441
  if (websocket.readyState !== WebSocket3.CONNECTING)
142083
142442
  return;
142084
142443
  req = websocket._req = null;
142085
- if (res.headers.upgrade.toLowerCase() !== "websocket") {
142444
+ const upgrade = res.headers.upgrade;
142445
+ if (upgrade === void 0 || upgrade.toLowerCase() !== "websocket") {
142086
142446
  abortHandshake(websocket, socket, "Invalid Upgrade header");
142087
142447
  return;
142088
142448
  }
@@ -142139,6 +142499,7 @@ var require_websocket = __commonJS({
142139
142499
  websocket._extensions[PerMessageDeflate.extensionName] = perMessageDeflate;
142140
142500
  }
142141
142501
  websocket.setSocket(socket, head2, {
142502
+ allowSynchronousEvents: opts.allowSynchronousEvents,
142142
142503
  generateMask: opts.generateMask,
142143
142504
  maxPayload: opts.maxPayload,
142144
142505
  skipUTF8Validation: opts.skipUTF8Validation
@@ -142152,6 +142513,7 @@ var require_websocket = __commonJS({
142152
142513
  }
142153
142514
  function emitErrorAndClose(websocket, err) {
142154
142515
  websocket._readyState = WebSocket3.CLOSING;
142516
+ websocket._errorEmitted = true;
142155
142517
  websocket.emit("error", err);
142156
142518
  websocket.emitClose();
142157
142519
  }
@@ -142185,7 +142547,7 @@ var require_websocket = __commonJS({
142185
142547
  }
142186
142548
  function sendAfterClose(websocket, data, cb) {
142187
142549
  if (data) {
142188
- const length = toBuffer(data).length;
142550
+ const length = isBlob2(data) ? data.size : toBuffer(data).length;
142189
142551
  if (websocket._socket)
142190
142552
  websocket._sender._bufferedBytes += length;
142191
142553
  else
@@ -142224,7 +142586,10 @@ var require_websocket = __commonJS({
142224
142586
  process.nextTick(resume, websocket._socket);
142225
142587
  websocket.close(err[kStatusCode]);
142226
142588
  }
142227
- websocket.emit("error", err);
142589
+ if (!websocket._errorEmitted) {
142590
+ websocket._errorEmitted = true;
142591
+ websocket.emit("error", err);
142592
+ }
142228
142593
  }
142229
142594
  function receiverOnFinish() {
142230
142595
  this[kWebSocket].emitClose();
@@ -142234,7 +142599,8 @@ var require_websocket = __commonJS({
142234
142599
  }
142235
142600
  function receiverOnPing(data) {
142236
142601
  const websocket = this[kWebSocket];
142237
- websocket.pong(data, !websocket._isServer, NOOP);
142602
+ if (websocket._autoPong)
142603
+ websocket.pong(data, !this._isServer, NOOP);
142238
142604
  websocket.emit("ping", data);
142239
142605
  }
142240
142606
  function receiverOnPong(data) {
@@ -142243,6 +142609,26 @@ var require_websocket = __commonJS({
142243
142609
  function resume(stream3) {
142244
142610
  stream3.resume();
142245
142611
  }
142612
+ function senderOnError(err) {
142613
+ const websocket = this[kWebSocket];
142614
+ if (websocket.readyState === WebSocket3.CLOSED)
142615
+ return;
142616
+ if (websocket.readyState === WebSocket3.OPEN) {
142617
+ websocket._readyState = WebSocket3.CLOSING;
142618
+ setCloseTimer(websocket);
142619
+ }
142620
+ this._socket.end();
142621
+ if (!websocket._errorEmitted) {
142622
+ websocket._errorEmitted = true;
142623
+ websocket.emit("error", err);
142624
+ }
142625
+ }
142626
+ function setCloseTimer(websocket) {
142627
+ websocket._closeTimer = setTimeout(
142628
+ websocket._socket.destroy.bind(websocket._socket),
142629
+ closeTimeout
142630
+ );
142631
+ }
142246
142632
  function socketOnClose() {
142247
142633
  const websocket = this[kWebSocket];
142248
142634
  this.removeListener("close", socketOnClose);
@@ -142340,9 +142726,7 @@ var require_websocket_server = __commonJS({
142340
142726
  "use strict";
142341
142727
  var EventEmitter4 = require("events");
142342
142728
  var http5 = require("http");
142343
- var https3 = require("https");
142344
- var net3 = require("net");
142345
- var tls = require("tls");
142729
+ var { Duplex: Duplex2 } = require("stream");
142346
142730
  var { createHash: createHash5 } = require("crypto");
142347
142731
  var extension = require_extension();
142348
142732
  var PerMessageDeflate = require_permessage_deflate();
@@ -142358,6 +142742,11 @@ var require_websocket_server = __commonJS({
142358
142742
  * Create a `WebSocketServer` instance.
142359
142743
  *
142360
142744
  * @param {Object} options Configuration options
142745
+ * @param {Boolean} [options.allowSynchronousEvents=true] Specifies whether
142746
+ * any of the `'message'`, `'ping'`, and `'pong'` events can be emitted
142747
+ * multiple times in the same tick
142748
+ * @param {Boolean} [options.autoPong=true] Specifies whether or not to
142749
+ * automatically send a pong in response to a ping
142361
142750
  * @param {Number} [options.backlog=511] The maximum length of the queue of
142362
142751
  * pending connections
142363
142752
  * @param {Boolean} [options.clientTracking=true] Specifies whether or not to
@@ -142383,6 +142772,8 @@ var require_websocket_server = __commonJS({
142383
142772
  constructor(options, callback) {
142384
142773
  super();
142385
142774
  options = {
142775
+ allowSynchronousEvents: true,
142776
+ autoPong: true,
142386
142777
  maxPayload: 100 * 1024 * 1024,
142387
142778
  skipUTF8Validation: false,
142388
142779
  perMessageDeflate: false,
@@ -142523,8 +142914,7 @@ var require_websocket_server = __commonJS({
142523
142914
  * Handle a HTTP Upgrade request.
142524
142915
  *
142525
142916
  * @param {http.IncomingMessage} req The request object
142526
- * @param {(net.Socket|tls.Socket)} socket The network socket between the
142527
- * server and client
142917
+ * @param {Duplex} socket The network socket between the server and client
142528
142918
  * @param {Buffer} head The first packet of the upgraded stream
142529
142919
  * @param {Function} cb Callback
142530
142920
  * @public
@@ -142532,18 +142922,19 @@ var require_websocket_server = __commonJS({
142532
142922
  handleUpgrade(req, socket, head2, cb) {
142533
142923
  socket.on("error", socketOnError);
142534
142924
  const key2 = req.headers["sec-websocket-key"];
142925
+ const upgrade = req.headers.upgrade;
142535
142926
  const version4 = +req.headers["sec-websocket-version"];
142536
142927
  if (req.method !== "GET") {
142537
142928
  const message = "Invalid HTTP method";
142538
142929
  abortHandshakeOrEmitwsClientError(this, req, socket, 405, message);
142539
142930
  return;
142540
142931
  }
142541
- if (req.headers.upgrade.toLowerCase() !== "websocket") {
142932
+ if (upgrade === void 0 || upgrade.toLowerCase() !== "websocket") {
142542
142933
  const message = "Invalid Upgrade header";
142543
142934
  abortHandshakeOrEmitwsClientError(this, req, socket, 400, message);
142544
142935
  return;
142545
142936
  }
142546
- if (!key2 || !keyRegex.test(key2)) {
142937
+ if (key2 === void 0 || !keyRegex.test(key2)) {
142547
142938
  const message = "Missing or invalid Sec-WebSocket-Key header";
142548
142939
  abortHandshakeOrEmitwsClientError(this, req, socket, 400, message);
142549
142940
  return;
@@ -142623,8 +143014,7 @@ var require_websocket_server = __commonJS({
142623
143014
  * @param {String} key The value of the `Sec-WebSocket-Key` header
142624
143015
  * @param {Set} protocols The subprotocols
142625
143016
  * @param {http.IncomingMessage} req The request object
142626
- * @param {(net.Socket|tls.Socket)} socket The network socket between the
142627
- * server and client
143017
+ * @param {Duplex} socket The network socket between the server and client
142628
143018
  * @param {Buffer} head The first packet of the upgraded stream
142629
143019
  * @param {Function} cb Callback
142630
143020
  * @throws {Error} If called more than once with the same socket
@@ -142647,7 +143037,7 @@ var require_websocket_server = __commonJS({
142647
143037
  "Connection: Upgrade",
142648
143038
  `Sec-WebSocket-Accept: ${digest}`
142649
143039
  ];
142650
- const ws = new this.options.WebSocket(null);
143040
+ const ws = new this.options.WebSocket(null, void 0, this.options);
142651
143041
  if (protocols.size) {
142652
143042
  const protocol = this.options.handleProtocols ? this.options.handleProtocols(protocols, req) : protocols.values().next().value;
142653
143043
  if (protocol) {
@@ -142667,6 +143057,7 @@ var require_websocket_server = __commonJS({
142667
143057
  socket.write(headers.concat("\r\n").join("\r\n"));
142668
143058
  socket.removeListener("error", socketOnError);
142669
143059
  ws.setSocket(socket, head2, {
143060
+ allowSynchronousEvents: this.options.allowSynchronousEvents,
142670
143061
  maxPayload: this.options.maxPayload,
142671
143062
  skipUTF8Validation: this.options.skipUTF8Validation
142672
143063
  });
@@ -193500,7 +193891,7 @@ var {
193500
193891
  } = import_index.default;
193501
193892
 
193502
193893
  // src/version.ts
193503
- var version = "1.3.13";
193894
+ var version = "1.3.14";
193504
193895
  var version_default = version;
193505
193896
 
193506
193897
  // ../myst-cli/dist/build/build.js
@@ -288984,7 +289375,7 @@ var import_node_path14 = __toESM(require("path"), 1);
288984
289375
  var import_nbtx = __toESM(require_cjs2(), 1);
288985
289376
 
288986
289377
  // ../myst-cli/dist/version.js
288987
- var version2 = "1.3.13";
289378
+ var version2 = "1.3.14";
288988
289379
  var version_default2 = version2;
288989
289380
 
288990
289381
  // ../myst-cli/dist/utils/headers.js
@@ -304400,7 +304791,7 @@ function renderImports(kind, output2, imports, packages, preamble) {
304400
304791
  }
304401
304792
 
304402
304793
  // ../jtex/dist/version.js
304403
- var version3 = "1.0.18";
304794
+ var version3 = "1.0.19";
304404
304795
  var version_default3 = version3;
304405
304796
 
304406
304797
  // ../jtex/dist/jtex.js
@@ -332811,6 +333202,13 @@ content-disposition/index.js:
332811
333202
  * MIT Licensed
332812
333203
  *)
332813
333204
 
333205
+ encodeurl/index.js:
333206
+ (*!
333207
+ * encodeurl
333208
+ * Copyright(c) 2016 Douglas Christopher Wilson
333209
+ * MIT Licensed
333210
+ *)
333211
+
332814
333212
  etag/index.js:
332815
333213
  (*!
332816
333214
  * etag