@optique/core 1.2.0-dev.2242 → 1.2.0-dev.2246

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.
@@ -112,8 +112,8 @@ function choice(choices, options = {}) {
112
112
  error: formatNumberChoiceError(input, numberChoices, numberChoices, numberInvalidChoice)
113
113
  };
114
114
  },
115
- format(value) {
116
- return Object.is(value, -0) ? "-0" : String(value);
115
+ format(value$1) {
116
+ return Object.is(value$1, -0) ? "-0" : String(value$1);
117
117
  },
118
118
  suggest(prefix) {
119
119
  return numberStrings.filter((valueStr, i) => !Number.isNaN(numberChoices[i]) && valueStr.startsWith(prefix)).map((valueStr) => ({
@@ -142,9 +142,18 @@ function choice(choices, options = {}) {
142
142
  const stringSuggest = stringOptions.suggest;
143
143
  if (stringSuggest !== void 0) {
144
144
  const isValidString = stringSuggest === "nearest" || stringSuggest === "never";
145
- const isValidObject = typeof stringSuggest === "object" && stringSuggest !== null;
145
+ const isArray = Array.isArray(stringSuggest);
146
+ const isValidObject = typeof stringSuggest === "object" && stringSuggest !== null && !isArray;
146
147
  const isValidFunction = typeof stringSuggest === "function";
147
- if (!isValidString && !isValidObject && !isValidFunction) throw new TypeError(`Expected suggest to be "nearest", "never", an object, or a function, but got ${typeof stringSuggest}: ${String(stringSuggest)}.`);
148
+ if (!isValidString && !isValidObject && !isValidFunction) {
149
+ const actualType = isArray ? "array" : stringSuggest === null ? "null" : typeof stringSuggest;
150
+ throw new TypeError(`Expected suggest to be "nearest", "never", an object, or a function, but got ${actualType}: ${String(stringSuggest)}.`);
151
+ }
152
+ if (isValidObject) {
153
+ const obj = stringSuggest;
154
+ if (obj.maxDistance !== void 0 && (typeof obj.maxDistance !== "number" || !Number.isInteger(obj.maxDistance) || obj.maxDistance < 0)) throw new TypeError(`Expected suggest.maxDistance to be a non-negative integer, but got ${typeof obj.maxDistance}: ${String(obj.maxDistance)}.`);
155
+ if (obj.maxSuggestions !== void 0 && (typeof obj.maxSuggestions !== "number" || !Number.isInteger(obj.maxSuggestions) || obj.maxSuggestions < 1)) throw new TypeError(`Expected suggest.maxSuggestions to be a positive integer, but got ${typeof obj.maxSuggestions}: ${String(obj.maxSuggestions)}.`);
156
+ }
148
157
  }
149
158
  return {
150
159
  mode: "sync",
@@ -163,17 +172,17 @@ function choice(choices, options = {}) {
163
172
  value: stringChoices[index]
164
173
  };
165
174
  },
166
- format(value) {
167
- return String(value);
175
+ format(value$1) {
176
+ return String(value$1);
168
177
  },
169
178
  suggest(prefix) {
170
179
  const normalizedPrefix = caseInsensitive ? prefix.toLowerCase() : prefix;
171
- return stringChoices.filter((value) => {
172
- const normalizedValue = caseInsensitive ? value.toLowerCase() : value;
180
+ return stringChoices.filter((value$1) => {
181
+ const normalizedValue = caseInsensitive ? value$1.toLowerCase() : value$1;
173
182
  return normalizedValue.startsWith(normalizedPrefix);
174
- }).map((value) => ({
183
+ }).map((value$1) => ({
175
184
  kind: "literal",
176
- text: value
185
+ text: value$1
177
186
  }));
178
187
  }
179
188
  };
@@ -189,8 +198,8 @@ function choice(choices, options = {}) {
189
198
  * @since 1.0.0
190
199
  */
191
200
  function checkBooleanOption(options, key) {
192
- const value = options?.[key];
193
- if (value !== void 0 && typeof value !== "boolean") throw new TypeError(`Expected ${String(key)} to be a boolean, but got ${typeof value}: ${String(value)}.`);
201
+ const value$1 = options?.[key];
202
+ if (value$1 !== void 0 && typeof value$1 !== "boolean") throw new TypeError(`Expected ${String(key)} to be a boolean, but got ${typeof value$1}: ${String(value$1)}.`);
194
203
  }
195
204
  /**
196
205
  * Validates that an option value, if present, is one of the allowed values.
@@ -206,10 +215,10 @@ function checkBooleanOption(options, key) {
206
215
  * @since 1.0.0
207
216
  */
208
217
  function checkEnumOption(options, key, allowed) {
209
- const value = options?.[key];
210
- if (value !== void 0 && (typeof value !== "string" || !allowed.includes(value))) {
211
- const rendered = typeof value === "string" ? JSON.stringify(value) : typeof value === "symbol" ? value.toString() : String(value);
212
- throw new TypeError(`Expected ${String(key)} to be one of ${allowed.map((v) => JSON.stringify(v)).join(", ")}, but got ${typeof value}: ${rendered}.`);
218
+ const value$1 = options?.[key];
219
+ if (value$1 !== void 0 && (typeof value$1 !== "string" || !allowed.includes(value$1))) {
220
+ const rendered = typeof value$1 === "string" ? JSON.stringify(value$1) : typeof value$1 === "symbol" ? value$1.toString() : String(value$1);
221
+ throw new TypeError(`Expected ${String(key)} to be one of ${allowed.map((v) => JSON.stringify(v)).join(", ")}, but got ${typeof value$1}: ${rendered}.`);
213
222
  }
214
223
  }
215
224
  /**
@@ -269,14 +278,20 @@ function formatStringChoiceError(input, choices, invalidChoice, suggest) {
269
278
  if (suggest === "nearest") return require_suggestion.appendValueHint(base, input, choices);
270
279
  if (typeof suggest === "function") {
271
280
  const hints = suggest(input, choices);
272
- if (!hints || hints.length === 0) return base;
273
- const suggestionMsg = require_suggestion.createSuggestionMessage(hints);
274
- return suggestionMsg.length > 0 ? [
281
+ if (!Array.isArray(hints) || hints.length === 0) return base;
282
+ let suggestionMsg;
283
+ if (hints.length === 1) suggestionMsg = require_message.message`Did you mean ${require_message.value(hints[0])}?`;
284
+ else {
285
+ const parts = [require_message.text("Did you mean one of these?")];
286
+ for (const hint of hints) parts.push(require_message.text("\n "), require_message.value(hint));
287
+ suggestionMsg = parts;
288
+ }
289
+ return [
275
290
  ...base,
276
291
  require_message.lineBreak(),
277
292
  require_message.lineBreak(),
278
293
  ...suggestionMsg
279
- ] : base;
294
+ ];
280
295
  }
281
296
  return require_suggestion.appendValueHint(base, input, choices, suggest);
282
297
  }
@@ -342,8 +357,8 @@ function string(options = {}) {
342
357
  value: input
343
358
  };
344
359
  },
345
- format(value) {
346
- return value;
360
+ format(value$1) {
361
+ return value$1;
347
362
  }
348
363
  };
349
364
  }
@@ -395,12 +410,12 @@ function keyValue(options = {}) {
395
410
  if (custom != null) return typeof custom === "function" ? custom(error) : custom;
396
411
  return [require_message.text("Invalid value: "), ...require_message.cloneMessage(error)];
397
412
  }
398
- function validateParts(input, key, value) {
413
+ function validateParts(input, key, value$1) {
399
414
  if (!allowEmptyKey && key === "") return {
400
415
  success: false,
401
416
  error: emptyKeyError(input)
402
417
  };
403
- if (!allowEmptyValue && value === "") return {
418
+ if (!allowEmptyValue && value$1 === "") return {
404
419
  success: false,
405
420
  error: emptyValueError(input)
406
421
  };
@@ -409,7 +424,7 @@ function keyValue(options = {}) {
409
424
  success: false,
410
425
  error: invalidKeyError(keyResult.error)
411
426
  };
412
- const valueResult = valueParser.parse(value);
427
+ const valueResult = valueParser.parse(value$1);
413
428
  if (!valueResult.success) return {
414
429
  success: false,
415
430
  error: invalidValueError(valueResult.error)
@@ -431,14 +446,14 @@ function keyValue(options = {}) {
431
446
  if (!allowEmptyKey && key === "") return false;
432
447
  return partsRoundTrip(key, "");
433
448
  }
434
- function fallbackInput(key, value) {
435
- return `${typeof key === "string" ? key : ""}${separator}${typeof value === "string" ? value : ""}`;
449
+ function fallbackInput(key, value$1) {
450
+ return `${typeof key === "string" ? key : ""}${separator}${typeof value$1 === "string" ? value$1 : ""}`;
436
451
  }
437
- function partsRoundTrip(key, value) {
438
- const input = `${key}${separator}${value}`;
452
+ function partsRoundTrip(key, value$1) {
453
+ const input = `${key}${separator}${value$1}`;
439
454
  const index = findSeparator(input);
440
455
  if (index < 0) return false;
441
- return input.slice(0, index) === key && input.slice(index + separator.length) === value;
456
+ return input.slice(0, index) === key && input.slice(index + separator.length) === value$1;
442
457
  }
443
458
  function validateResultParts(input, keyResult, valueResult) {
444
459
  if (!allowEmptyKey && keyResult.value === "") return {
@@ -488,26 +503,26 @@ function keyValue(options = {}) {
488
503
  }
489
504
  return makeKeyValueSuccess(keyResult, valueResult);
490
505
  }
491
- function validateTuple(value) {
492
- if (!allowEmptyKey && value[0] === "") return {
506
+ function validateTuple(value$1) {
507
+ if (!allowEmptyKey && value$1[0] === "") return {
493
508
  success: false,
494
- error: emptyKeyError(fallbackInput(value[0], value[1]))
509
+ error: emptyKeyError(fallbackInput(value$1[0], value$1[1]))
495
510
  };
496
- if (!allowEmptyValue && value[1] === "") return {
511
+ if (!allowEmptyValue && value$1[1] === "") return {
497
512
  success: false,
498
- error: emptyValueError(fallbackInput(value[0], value[1]))
513
+ error: emptyValueError(fallbackInput(value$1[0], value$1[1]))
499
514
  };
500
- const keyResult = validateValueParserValue(keyParser, value[0]);
515
+ const keyResult = validateValueParserValue(keyParser, value$1[0]);
501
516
  if (!keyResult.success) return {
502
517
  success: false,
503
518
  error: invalidKeyError(keyResult.error)
504
519
  };
505
- const valueResult = validateValueParserValue(valueParser, value[1]);
520
+ const valueResult = validateValueParserValue(valueParser, value$1[1]);
506
521
  if (!valueResult.success) return {
507
522
  success: false,
508
523
  error: invalidValueError(valueResult.error)
509
524
  };
510
- return validateResultParts(fallbackInput(value[0], value[1]), keyResult, valueResult);
525
+ return validateResultParts(fallbackInput(value$1[0], value$1[1]), keyResult, valueResult);
511
526
  }
512
527
  return {
513
528
  mode: "sync",
@@ -520,23 +535,23 @@ function keyValue(options = {}) {
520
535
  error: missingSeparatorError(input)
521
536
  };
522
537
  const key = input.slice(0, index);
523
- const value = input.slice(index + separator.length);
524
- return validateParts(input, key, value);
538
+ const value$1 = input.slice(index + separator.length);
539
+ return validateParts(input, key, value$1);
525
540
  },
526
- format(value) {
527
- return `${keyParser.format(value[0])}${separator}${valueParser.format(value[1])}`;
541
+ format(value$1) {
542
+ return `${keyParser.format(value$1[0])}${separator}${valueParser.format(value$1[1])}`;
528
543
  },
529
- validate(value) {
530
- if (!isKeyValueTuple(value)) return {
544
+ validate(value$1) {
545
+ if (!isKeyValueTuple(value$1)) return {
531
546
  success: false,
532
547
  error: require_message.message`Expected a key-value tuple.`
533
548
  };
534
- return validateTuple(value);
549
+ return validateTuple(value$1);
535
550
  },
536
- ...hasNormalize ? { normalize(value) {
537
- if (!isKeyValueTuple(value)) return value;
538
- const normalized = [typeof keyParser.normalize === "function" ? keyParser.normalize(value[0]) : value[0], typeof valueParser.normalize === "function" ? valueParser.normalize(value[1]) : value[1]];
539
- return validateTuple(normalized).success ? normalized : value;
551
+ ...hasNormalize ? { normalize(value$1) {
552
+ if (!isKeyValueTuple(value$1)) return value$1;
553
+ const normalized = [typeof keyParser.normalize === "function" ? keyParser.normalize(value$1[0]) : value$1[0], typeof valueParser.normalize === "function" ? valueParser.normalize(value$1[1]) : value$1[1]];
554
+ return validateTuple(normalized).success ? normalized : value$1;
540
555
  } } : {},
541
556
  ...hasSuggest ? { *suggest(prefix) {
542
557
  const index = findSeparator(prefix);
@@ -560,9 +575,9 @@ function keyValue(options = {}) {
560
575
  }
561
576
  const valuePrefix = prefix.slice(index + separator.length);
562
577
  for (const suggestion of valueParser.suggest(valuePrefix)) {
563
- const value = suggestionTextValue(suggestion);
564
- if (!partsRoundTrip(key, value)) continue;
565
- if (suggestion.kind === "literal" && !validateParts(`${key}${separator}${value}`, key, value).success) continue;
578
+ const value$1 = suggestionTextValue(suggestion);
579
+ if (!partsRoundTrip(key, value$1)) continue;
580
+ if (suggestion.kind === "literal" && !validateParts(`${key}${separator}${value$1}`, key, value$1).success) continue;
566
581
  suggestions.push(prefixKeyValueSuggestion(suggestion, `${key}${separator}`));
567
582
  }
568
583
  }
@@ -575,15 +590,15 @@ function checkKeyValueChildParser(role, parser) {
575
590
  if (parser.mode !== "sync") throw new TypeError(`keyValue() only supports sync ${role} parsers, but an async one was given.`);
576
591
  if (require_internal_dependency.isDerivedValueParser(parser)) throw new TypeError(`keyValue() does not support dependency-derived ${role} parsers (created via deriveFrom() or dependency().derive()); pass the derived parser directly to option() or argument() instead.`);
577
592
  }
578
- function validateValueParserValue(parser, value) {
579
- if (typeof parser.validate === "function") return parser.validate(value);
593
+ function validateValueParserValue(parser, value$1) {
594
+ if (typeof parser.validate === "function") return parser.validate(value$1);
580
595
  let formatted;
581
596
  try {
582
- formatted = parser.format(value);
597
+ formatted = parser.format(value$1);
583
598
  } catch {
584
599
  return {
585
600
  success: true,
586
- value
601
+ value: value$1
587
602
  };
588
603
  }
589
604
  if (typeof formatted !== "string") return {
@@ -592,10 +607,10 @@ function validateValueParserValue(parser, value) {
592
607
  };
593
608
  return parser.parse(formatted);
594
609
  }
595
- function formatValueParserValue(parser, value) {
610
+ function formatValueParserValue(parser, value$1) {
596
611
  let formatted;
597
612
  try {
598
- formatted = parser.format(value);
613
+ formatted = parser.format(value$1);
599
614
  } catch {
600
615
  return {
601
616
  success: true,
@@ -633,8 +648,8 @@ function prefixKeyValueSuggestion(suggestion, prefix, suffix = "") {
633
648
  description: suggestion.description
634
649
  };
635
650
  }
636
- function isKeyValueTuple(value) {
637
- return Array.isArray(value) && value.length === 2 && 0 in value && 1 in value;
651
+ function isKeyValueTuple(value$1) {
652
+ return Array.isArray(value$1) && value$1.length === 2 && 0 in value$1 && 1 in value$1;
638
653
  }
639
654
  function makeKeyValueSuccess(keyResult, valueResult) {
640
655
  const deferredKeys = /* @__PURE__ */ new Map();
@@ -720,22 +735,22 @@ function integer(options) {
720
735
  success: false,
721
736
  error: options.errors?.invalidInteger ? typeof options.errors.invalidInteger === "function" ? options.errors.invalidInteger(input) : options.errors.invalidInteger : require_message.message`Expected a valid integer, but got ${input}.`
722
737
  };
723
- const value = BigInt(input);
724
- if (options.min != null && value < options.min) return {
738
+ const value$1 = BigInt(input);
739
+ if (options.min != null && value$1 < options.min) return {
725
740
  success: false,
726
- error: options.errors?.belowMinimum ? typeof options.errors.belowMinimum === "function" ? options.errors.belowMinimum(value, options.min) : options.errors.belowMinimum : require_message.message`Expected a value greater than or equal to ${require_message.text(options.min.toLocaleString("en"))}, but got ${input}.`
741
+ error: options.errors?.belowMinimum ? typeof options.errors.belowMinimum === "function" ? options.errors.belowMinimum(value$1, options.min) : options.errors.belowMinimum : require_message.message`Expected a value greater than or equal to ${require_message.text(options.min.toLocaleString("en"))}, but got ${input}.`
727
742
  };
728
- else if (options.max != null && value > options.max) return {
743
+ else if (options.max != null && value$1 > options.max) return {
729
744
  success: false,
730
- error: options.errors?.aboveMaximum ? typeof options.errors.aboveMaximum === "function" ? options.errors.aboveMaximum(value, options.max) : options.errors.aboveMaximum : require_message.message`Expected a value less than or equal to ${require_message.text(options.max.toLocaleString("en"))}, but got ${input}.`
745
+ error: options.errors?.aboveMaximum ? typeof options.errors.aboveMaximum === "function" ? options.errors.aboveMaximum(value$1, options.max) : options.errors.aboveMaximum : require_message.message`Expected a value less than or equal to ${require_message.text(options.max.toLocaleString("en"))}, but got ${input}.`
731
746
  };
732
747
  return {
733
748
  success: true,
734
- value
749
+ value: value$1
735
750
  };
736
751
  },
737
- format(value) {
738
- return value.toString();
752
+ format(value$1) {
753
+ return value$1.toString();
739
754
  }
740
755
  };
741
756
  }
@@ -771,22 +786,22 @@ function integer(options) {
771
786
  return makeUnsafeIntegerError(input);
772
787
  }
773
788
  if (n > maxSafe || n < minSafe) return makeUnsafeIntegerError(input);
774
- const value = Number(input);
775
- if (options?.min != null && value < options.min) return {
789
+ const value$1 = Number(input);
790
+ if (options?.min != null && value$1 < options.min) return {
776
791
  success: false,
777
- error: options.errors?.belowMinimum ? typeof options.errors.belowMinimum === "function" ? options.errors.belowMinimum(value, options.min) : options.errors.belowMinimum : require_message.message`Expected a value greater than or equal to ${require_message.text(options.min.toLocaleString("en"))}, but got ${input}.`
792
+ error: options.errors?.belowMinimum ? typeof options.errors.belowMinimum === "function" ? options.errors.belowMinimum(value$1, options.min) : options.errors.belowMinimum : require_message.message`Expected a value greater than or equal to ${require_message.text(options.min.toLocaleString("en"))}, but got ${input}.`
778
793
  };
779
- else if (options?.max != null && value > options.max) return {
794
+ else if (options?.max != null && value$1 > options.max) return {
780
795
  success: false,
781
- error: options.errors?.aboveMaximum ? typeof options.errors.aboveMaximum === "function" ? options.errors.aboveMaximum(value, options.max) : options.errors.aboveMaximum : require_message.message`Expected a value less than or equal to ${require_message.text(options.max.toLocaleString("en"))}, but got ${input}.`
796
+ error: options.errors?.aboveMaximum ? typeof options.errors.aboveMaximum === "function" ? options.errors.aboveMaximum(value$1, options.max) : options.errors.aboveMaximum : require_message.message`Expected a value less than or equal to ${require_message.text(options.max.toLocaleString("en"))}, but got ${input}.`
782
797
  };
783
798
  return {
784
799
  success: true,
785
- value
800
+ value: value$1
786
801
  };
787
802
  },
788
- format(value) {
789
- return value.toString();
803
+ format(value$1) {
804
+ return value$1.toString();
790
805
  }
791
806
  };
792
807
  }
@@ -815,31 +830,31 @@ function float(options = {}) {
815
830
  success: false,
816
831
  error: options.errors?.invalidNumber ? typeof options.errors.invalidNumber === "function" ? options.errors.invalidNumber(i) : options.errors.invalidNumber : require_message.message`Expected a valid number, but got ${i}.`
817
832
  });
818
- let value;
833
+ let value$1;
819
834
  const lowerInput = input.toLowerCase();
820
- if (lowerInput === "nan" && options.allowNaN) value = NaN;
821
- else if ((lowerInput === "infinity" || lowerInput === "+infinity") && options.allowInfinity) value = Infinity;
822
- else if (lowerInput === "-infinity" && options.allowInfinity) value = -Infinity;
835
+ if (lowerInput === "nan" && options.allowNaN) value$1 = NaN;
836
+ else if ((lowerInput === "infinity" || lowerInput === "+infinity") && options.allowInfinity) value$1 = Infinity;
837
+ else if (lowerInput === "-infinity" && options.allowInfinity) value$1 = -Infinity;
823
838
  else if (floatRegex.test(input)) {
824
- value = Number(input);
825
- if (!Number.isFinite(value) && !options.allowInfinity) return invalidNumber(input);
826
- if (Number.isNaN(value)) return invalidNumber(input);
839
+ value$1 = Number(input);
840
+ if (!Number.isFinite(value$1) && !options.allowInfinity) return invalidNumber(input);
841
+ if (Number.isNaN(value$1)) return invalidNumber(input);
827
842
  } else return invalidNumber(input);
828
- if (options.min != null && value < options.min) return {
843
+ if (options.min != null && value$1 < options.min) return {
829
844
  success: false,
830
- error: options.errors?.belowMinimum ? typeof options.errors.belowMinimum === "function" ? options.errors.belowMinimum(value, options.min) : options.errors.belowMinimum : require_message.message`Expected a value greater than or equal to ${require_message.text(options.min.toLocaleString("en"))}, but got ${input}.`
845
+ error: options.errors?.belowMinimum ? typeof options.errors.belowMinimum === "function" ? options.errors.belowMinimum(value$1, options.min) : options.errors.belowMinimum : require_message.message`Expected a value greater than or equal to ${require_message.text(options.min.toLocaleString("en"))}, but got ${input}.`
831
846
  };
832
- else if (options.max != null && value > options.max) return {
847
+ else if (options.max != null && value$1 > options.max) return {
833
848
  success: false,
834
- error: options.errors?.aboveMaximum ? typeof options.errors.aboveMaximum === "function" ? options.errors.aboveMaximum(value, options.max) : options.errors.aboveMaximum : require_message.message`Expected a value less than or equal to ${require_message.text(options.max.toLocaleString("en"))}, but got ${input}.`
849
+ error: options.errors?.aboveMaximum ? typeof options.errors.aboveMaximum === "function" ? options.errors.aboveMaximum(value$1, options.max) : options.errors.aboveMaximum : require_message.message`Expected a value less than or equal to ${require_message.text(options.max.toLocaleString("en"))}, but got ${input}.`
835
850
  };
836
851
  return {
837
852
  success: true,
838
- value
853
+ value: value$1
839
854
  };
840
855
  },
841
- format(value) {
842
- return value.toString();
856
+ format(value$1) {
857
+ return value$1.toString();
843
858
  }
844
859
  };
845
860
  }
@@ -976,17 +991,17 @@ const BIGINT_FORMAT_UNITS_SI_AS_BINARY = [
976
991
  * Formats a bigint byte count using the most readable unit. Falls back to
977
992
  * `"${value}B"`. Tries exact integers, then 1 and 2 decimal places.
978
993
  */
979
- function formatBigIntBytes(value, units) {
980
- if (value === 0n) return "0B";
981
- const absValue = value < 0n ? -value : value;
994
+ function formatBigIntBytes(value$1, units) {
995
+ if (value$1 === 0n) return "0B";
996
+ const absValue = value$1 < 0n ? -value$1 : value$1;
982
997
  for (const [unit, size] of units) {
983
998
  if (absValue < size) continue;
984
- if (value % size === 0n) {
985
- const v = value / size;
999
+ if (value$1 % size === 0n) {
1000
+ const v = value$1 / size;
986
1001
  const absV = v < 0n ? -v : v;
987
1002
  if (absV >= 1n && absV < 1000n) return `${v}${unit}`;
988
1003
  }
989
- const v100 = value * 100n;
1004
+ const v100 = value$1 * 100n;
990
1005
  if (v100 % size === 0n) {
991
1006
  const q = v100 / size;
992
1007
  const absQ = q < 0n ? -q : q;
@@ -998,7 +1013,7 @@ function formatBigIntBytes(value, units) {
998
1013
  }
999
1014
  }
1000
1015
  }
1001
- return `${value}B`;
1016
+ return `${value$1}B`;
1002
1017
  }
1003
1018
  /**
1004
1019
  * Core computation: parses `numStr` as a decimal rational, multiplies by
@@ -1128,10 +1143,10 @@ function fileSize(options = {}) {
1128
1143
  value: bytes
1129
1144
  };
1130
1145
  },
1131
- format(value) {
1146
+ format(value$1) {
1132
1147
  const maxSafe = BigInt(Number.MAX_SAFE_INTEGER);
1133
- if (value >= -maxSafe && value <= maxSafe) return formatWithUnits(Number(value), numberFormatUnits);
1134
- return formatBigIntBytes(value, bigintFormatUnits);
1148
+ if (value$1 >= -maxSafe && value$1 <= maxSafe) return formatWithUnits(Number(value$1), numberFormatUnits);
1149
+ return formatBigIntBytes(value$1, bigintFormatUnits);
1135
1150
  }
1136
1151
  };
1137
1152
  }
@@ -1169,8 +1184,8 @@ function fileSize(options = {}) {
1169
1184
  value: bytes
1170
1185
  };
1171
1186
  },
1172
- format(value) {
1173
- return formatWithUnits(value, formatUnits);
1187
+ format(value$1) {
1188
+ return formatWithUnits(value$1, formatUnits);
1174
1189
  }
1175
1190
  };
1176
1191
  }
@@ -2262,8 +2277,8 @@ function color(options = {}) {
2262
2277
  }
2263
2278
  return invalidFormatError(input);
2264
2279
  },
2265
- format(value) {
2266
- const { r, g, b, a } = value;
2280
+ format(value$1) {
2281
+ const { r, g, b, a } = value$1;
2267
2282
  if (!Number.isInteger(r) || r < 0 || r > 255 || !Number.isInteger(g) || g < 0 || g > 255 || !Number.isInteger(b) || b < 0 || b > 255 || !Number.isFinite(a) || a < 0 || a > 1) throw new RangeError(`Color components out of range: r=${r}, g=${g}, b=${b}, a=${a}.`);
2268
2283
  const aStr = parseFloat(a.toFixed(4));
2269
2284
  if (allowHex) {
@@ -2285,11 +2300,11 @@ function color(options = {}) {
2285
2300
  for (const [name, c] of Object.entries(CSS_NAMED_COLORS)) if (c.r === r && c.g === g && c.b === b && c.a === a) return name;
2286
2301
  throw new RangeError(`No CSS named color matches { r: ${r}, g: ${g}, b: ${b}, a: ${a} }.`);
2287
2302
  },
2288
- normalize(value) {
2289
- if (!Number.isInteger(value.r) || value.r < 0 || value.r > 255 || !Number.isInteger(value.g) || value.g < 0 || value.g > 255 || !Number.isInteger(value.b) || value.b < 0 || value.b > 255 || !Number.isFinite(value.a) || value.a < 0 || value.a > 1) return value;
2290
- const a = Math.round(value.a * 255) / 255;
2291
- return a === value.a ? value : {
2292
- ...value,
2303
+ normalize(value$1) {
2304
+ if (!Number.isInteger(value$1.r) || value$1.r < 0 || value$1.r > 255 || !Number.isInteger(value$1.g) || value$1.g < 0 || value$1.g > 255 || !Number.isInteger(value$1.b) || value$1.b < 0 || value$1.b > 255 || !Number.isFinite(value$1.a) || value$1.a < 0 || value$1.a > 1) return value$1;
2305
+ const a = Math.round(value$1.a * 255) / 255;
2306
+ return a === value$1.a ? value$1 : {
2307
+ ...value$1,
2293
2308
  a
2294
2309
  };
2295
2310
  },
@@ -2394,8 +2409,8 @@ function url(options = {}) {
2394
2409
  value: url$1
2395
2410
  };
2396
2411
  },
2397
- format(value) {
2398
- return value.href;
2412
+ format(value$1) {
2413
+ return value$1.href;
2399
2414
  },
2400
2415
  *suggest(prefix) {
2401
2416
  if (allowedProtocols && prefix.length > 0 && !prefix.includes(":")) for (const protocol of allowedProtocols) {
@@ -2444,8 +2459,8 @@ function locale(options = {}) {
2444
2459
  value: locale$1
2445
2460
  };
2446
2461
  },
2447
- format(value) {
2448
- return value.toString();
2462
+ format(value$1) {
2463
+ return value$1.toString();
2449
2464
  },
2450
2465
  *suggest(prefix) {
2451
2466
  const commonLocales = [
@@ -2774,8 +2789,8 @@ function uuid(options = {}) {
2774
2789
  value: input
2775
2790
  };
2776
2791
  },
2777
- format(value) {
2778
- return value;
2792
+ format(value$1) {
2793
+ return value$1;
2779
2794
  }
2780
2795
  };
2781
2796
  }
@@ -2837,26 +2852,26 @@ function port(options) {
2837
2852
  success: false,
2838
2853
  error: options.errors?.invalidPort ? typeof options.errors.invalidPort === "function" ? options.errors.invalidPort(input) : options.errors.invalidPort : require_message.message`Expected a valid port number, but got ${input}.`
2839
2854
  };
2840
- const value = BigInt(input);
2841
- if (value < min$1) return {
2855
+ const value$1 = BigInt(input);
2856
+ if (value$1 < min$1) return {
2842
2857
  success: false,
2843
- error: options.errors?.belowMinimum ? typeof options.errors.belowMinimum === "function" ? options.errors.belowMinimum(value, min$1) : options.errors.belowMinimum : require_message.message`Expected a port number greater than or equal to ${require_message.text(min$1.toLocaleString("en"))}, but got ${input}.`
2858
+ error: options.errors?.belowMinimum ? typeof options.errors.belowMinimum === "function" ? options.errors.belowMinimum(value$1, min$1) : options.errors.belowMinimum : require_message.message`Expected a port number greater than or equal to ${require_message.text(min$1.toLocaleString("en"))}, but got ${input}.`
2844
2859
  };
2845
- if (value > max$1) return {
2860
+ if (value$1 > max$1) return {
2846
2861
  success: false,
2847
- error: options.errors?.aboveMaximum ? typeof options.errors.aboveMaximum === "function" ? options.errors.aboveMaximum(value, max$1) : options.errors.aboveMaximum : require_message.message`Expected a port number less than or equal to ${require_message.text(max$1.toLocaleString("en"))}, but got ${input}.`
2862
+ error: options.errors?.aboveMaximum ? typeof options.errors.aboveMaximum === "function" ? options.errors.aboveMaximum(value$1, max$1) : options.errors.aboveMaximum : require_message.message`Expected a port number less than or equal to ${require_message.text(max$1.toLocaleString("en"))}, but got ${input}.`
2848
2863
  };
2849
- if (options.disallowWellKnown && value >= 1n && value <= 1023n) return {
2864
+ if (options.disallowWellKnown && value$1 >= 1n && value$1 <= 1023n) return {
2850
2865
  success: false,
2851
- error: options.errors?.wellKnownNotAllowed ? typeof options.errors.wellKnownNotAllowed === "function" ? options.errors.wellKnownNotAllowed(value) : options.errors.wellKnownNotAllowed : require_message.message`Port ${value.toLocaleString("en")} is a well-known port (1-1023) and may require elevated privileges.`
2866
+ error: options.errors?.wellKnownNotAllowed ? typeof options.errors.wellKnownNotAllowed === "function" ? options.errors.wellKnownNotAllowed(value$1) : options.errors.wellKnownNotAllowed : require_message.message`Port ${value$1.toLocaleString("en")} is a well-known port (1-1023) and may require elevated privileges.`
2852
2867
  };
2853
2868
  return {
2854
2869
  success: true,
2855
- value
2870
+ value: value$1
2856
2871
  };
2857
2872
  },
2858
- format(value) {
2859
- return value.toString();
2873
+ format(value$1) {
2874
+ return value$1.toString();
2860
2875
  }
2861
2876
  };
2862
2877
  }
@@ -2877,26 +2892,26 @@ function port(options) {
2877
2892
  success: false,
2878
2893
  error: options?.errors?.invalidPort ? typeof options.errors.invalidPort === "function" ? options.errors.invalidPort(input) : options.errors.invalidPort : require_message.message`Expected a valid port number, but got ${input}.`
2879
2894
  };
2880
- const value = Number.parseInt(input);
2881
- if (value < min) return {
2895
+ const value$1 = Number.parseInt(input);
2896
+ if (value$1 < min) return {
2882
2897
  success: false,
2883
- error: options?.errors?.belowMinimum ? typeof options.errors.belowMinimum === "function" ? options.errors.belowMinimum(value, min) : options.errors.belowMinimum : require_message.message`Expected a port number greater than or equal to ${require_message.text(min.toLocaleString("en"))}, but got ${input}.`
2898
+ error: options?.errors?.belowMinimum ? typeof options.errors.belowMinimum === "function" ? options.errors.belowMinimum(value$1, min) : options.errors.belowMinimum : require_message.message`Expected a port number greater than or equal to ${require_message.text(min.toLocaleString("en"))}, but got ${input}.`
2884
2899
  };
2885
- if (value > max) return {
2900
+ if (value$1 > max) return {
2886
2901
  success: false,
2887
- error: options?.errors?.aboveMaximum ? typeof options.errors.aboveMaximum === "function" ? options.errors.aboveMaximum(value, max) : options.errors.aboveMaximum : require_message.message`Expected a port number less than or equal to ${require_message.text(max.toLocaleString("en"))}, but got ${input}.`
2902
+ error: options?.errors?.aboveMaximum ? typeof options.errors.aboveMaximum === "function" ? options.errors.aboveMaximum(value$1, max) : options.errors.aboveMaximum : require_message.message`Expected a port number less than or equal to ${require_message.text(max.toLocaleString("en"))}, but got ${input}.`
2888
2903
  };
2889
- if (options?.disallowWellKnown && value >= 1 && value <= 1023) return {
2904
+ if (options?.disallowWellKnown && value$1 >= 1 && value$1 <= 1023) return {
2890
2905
  success: false,
2891
- error: options.errors?.wellKnownNotAllowed ? typeof options.errors.wellKnownNotAllowed === "function" ? options.errors.wellKnownNotAllowed(value) : options.errors.wellKnownNotAllowed : require_message.message`Port ${value.toLocaleString("en")} is a well-known port (1-1023) and may require elevated privileges.`
2906
+ error: options.errors?.wellKnownNotAllowed ? typeof options.errors.wellKnownNotAllowed === "function" ? options.errors.wellKnownNotAllowed(value$1) : options.errors.wellKnownNotAllowed : require_message.message`Port ${value$1.toLocaleString("en")} is a well-known port (1-1023) and may require elevated privileges.`
2892
2907
  };
2893
2908
  return {
2894
2909
  success: true,
2895
- value
2910
+ value: value$1
2896
2911
  };
2897
2912
  },
2898
- format(value) {
2899
- return value.toString();
2913
+ format(value$1) {
2914
+ return value$1.toString();
2900
2915
  }
2901
2916
  };
2902
2917
  }
@@ -3030,8 +3045,8 @@ function ipv4(options) {
3030
3045
  value: ipAddress
3031
3046
  };
3032
3047
  },
3033
- format(value) {
3034
- return value;
3048
+ format(value$1) {
3049
+ return value$1;
3035
3050
  }
3036
3051
  };
3037
3052
  }
@@ -3193,8 +3208,8 @@ function hostname(options) {
3193
3208
  value: input
3194
3209
  };
3195
3210
  },
3196
- format(value) {
3197
- return value;
3211
+ format(value$1) {
3212
+ return value$1;
3198
3213
  }
3199
3214
  };
3200
3215
  }
@@ -3415,9 +3430,9 @@ function email(options) {
3415
3430
  };
3416
3431
  }
3417
3432
  },
3418
- format(value) {
3419
- if (Array.isArray(value)) return value.join(", ");
3420
- return value;
3433
+ format(value$1) {
3434
+ if (Array.isArray(value$1)) return value$1.join(", ");
3435
+ return value$1;
3421
3436
  }
3422
3437
  };
3423
3438
  }
@@ -3650,13 +3665,13 @@ function socketAddress(options) {
3650
3665
  };
3651
3666
  return makeInvalidFormatError(input);
3652
3667
  }
3653
- function isSocketAddressValue(value) {
3654
- return typeof value === "object" && value !== null && "host" in value && typeof value.host === "string" && "port" in value && typeof value.port === "number";
3668
+ function isSocketAddressValue(value$1) {
3669
+ return typeof value$1 === "object" && value$1 !== null && "host" in value$1 && typeof value$1.host === "string" && "port" in value$1 && typeof value$1.port === "number";
3655
3670
  }
3656
- function formatSocketAddressValue(value) {
3657
- const ipv6Host = parseAndNormalizeIpv6(value.host);
3658
- if (separator === ":" && ipv6Host !== null) return `[${ipv6Host}]${separator}${value.port}`;
3659
- return `${value.host}${separator}${value.port}`;
3671
+ function formatSocketAddressValue(value$1) {
3672
+ const ipv6Host = parseAndNormalizeIpv6(value$1.host);
3673
+ if (separator === ":" && ipv6Host !== null) return `[${ipv6Host}]${separator}${value$1.port}`;
3674
+ return `${value$1.host}${separator}${value$1.port}`;
3660
3675
  }
3661
3676
  const parser = {
3662
3677
  mode: "sync",
@@ -3889,16 +3904,16 @@ function socketAddress(options) {
3889
3904
  error: require_message.message`Expected a socket address in format ${require_message.text(formatExample)}, but got ${input}.`
3890
3905
  };
3891
3906
  },
3892
- format(value) {
3893
- return formatSocketAddressValue(value);
3907
+ format(value$1) {
3908
+ return formatSocketAddressValue(value$1);
3894
3909
  },
3895
- normalize(value) {
3896
- if (!isSocketAddressValue(value)) return value;
3910
+ normalize(value$1) {
3911
+ if (!isSocketAddressValue(value$1)) return value$1;
3897
3912
  try {
3898
- const result = parser.parse(formatSocketAddressValue(value));
3899
- return result.success ? result.value : value;
3913
+ const result = parser.parse(formatSocketAddressValue(value$1));
3914
+ return result.success ? result.value : value$1;
3900
3915
  } catch {
3901
- return value;
3916
+ return value$1;
3902
3917
  }
3903
3918
  }
3904
3919
  };
@@ -4029,8 +4044,8 @@ function portRange(options) {
4029
4044
  };
4030
4045
  }
4031
4046
  },
4032
- format(value) {
4033
- return `${value.start}${separator}${value.end}`;
4047
+ format(value$1) {
4048
+ return `${value$1.start}${separator}${value$1.end}`;
4034
4049
  }
4035
4050
  };
4036
4051
  }
@@ -4108,11 +4123,11 @@ function macAddress(options) {
4108
4123
  return formatted.join(sep);
4109
4124
  }
4110
4125
  let macParsing = false;
4111
- function normalizeMacValue(value, fallback) {
4112
- if (macParsing) return value;
4126
+ function normalizeMacValue(value$1, fallback) {
4127
+ if (macParsing) return value$1;
4113
4128
  macParsing = true;
4114
4129
  try {
4115
- const result = parserObj.parse(value);
4130
+ const result = parserObj.parse(value$1);
4116
4131
  return result.success ? result.value : fallback;
4117
4132
  } catch {
4118
4133
  return fallback;
@@ -4203,13 +4218,13 @@ function macAddress(options) {
4203
4218
  value: joinOctets(octets, finalSeparator)
4204
4219
  };
4205
4220
  },
4206
- format(value) {
4207
- if (typeof value !== "string") return metavar$1;
4208
- return normalizeMacValue(value, value);
4221
+ format(value$1) {
4222
+ if (typeof value$1 !== "string") return metavar$1;
4223
+ return normalizeMacValue(value$1, value$1);
4209
4224
  },
4210
- normalize(value) {
4211
- if (typeof value !== "string") return value;
4212
- return normalizeMacValue(value, value);
4225
+ normalize(value$1) {
4226
+ if (typeof value$1 !== "string") return value$1;
4227
+ return normalizeMacValue(value$1, value$1);
4213
4228
  }
4214
4229
  };
4215
4230
  return parserObj;
@@ -4491,10 +4506,10 @@ function domain(options) {
4491
4506
  value: result
4492
4507
  };
4493
4508
  },
4494
- format(value) {
4495
- if (typeof value !== "string") return metavar$1;
4496
- if (!lowercase) return value;
4497
- return value.split(".").length >= minLabels ? value.toLowerCase() : value;
4509
+ format(value$1) {
4510
+ if (typeof value$1 !== "string") return metavar$1;
4511
+ if (!lowercase) return value$1;
4512
+ return value$1.split(".").length >= minLabels ? value$1.toLowerCase() : value$1;
4498
4513
  }
4499
4514
  };
4500
4515
  if (lowercase) {
@@ -4721,9 +4736,9 @@ function ipv6(options) {
4721
4736
  value: normalized
4722
4737
  };
4723
4738
  },
4724
- format(value) {
4725
- if (typeof value !== "string") return metavar$1;
4726
- return parseAndNormalizeIpv6(value) ?? value;
4739
+ format(value$1) {
4740
+ if (typeof value$1 !== "string") return metavar$1;
4741
+ return parseAndNormalizeIpv6(value$1) ?? value$1;
4727
4742
  }
4728
4743
  };
4729
4744
  let ipv6Parsing = false;
@@ -5107,9 +5122,9 @@ function ip(options) {
5107
5122
  error: msg
5108
5123
  };
5109
5124
  },
5110
- format(value) {
5111
- if (typeof value !== "string") return metavar$1;
5112
- return parseAndNormalizeIpv6(value) ?? value;
5125
+ format(value$1) {
5126
+ if (typeof value$1 !== "string") return metavar$1;
5127
+ return parseAndNormalizeIpv6(value$1) ?? value$1;
5113
5128
  }
5114
5129
  };
5115
5130
  let ipParsing = false;
@@ -5601,16 +5616,16 @@ function cidr(options) {
5601
5616
  };
5602
5617
  let cidrParsing = false;
5603
5618
  Object.defineProperty(cidrParserObj, "format", {
5604
- value(value) {
5605
- if (typeof value !== "object" || value == null || !("address" in value) || !("prefix" in value) || !("version" in value)) return metavar$1;
5606
- if (cidrParsing) return `${value.address}/${value.prefix}`;
5619
+ value(value$1) {
5620
+ if (typeof value$1 !== "object" || value$1 == null || !("address" in value$1) || !("prefix" in value$1) || !("version" in value$1)) return metavar$1;
5621
+ if (cidrParsing) return `${value$1.address}/${value$1.prefix}`;
5607
5622
  cidrParsing = true;
5608
5623
  try {
5609
- const raw = `${value.address}/${value.prefix}`;
5624
+ const raw = `${value$1.address}/${value$1.prefix}`;
5610
5625
  const result = cidrParserObj.parse(raw);
5611
- return result.success && result.value.version === value.version ? `${result.value.address}/${result.value.prefix}` : raw;
5626
+ return result.success && result.value.version === value$1.version ? `${result.value.address}/${result.value.prefix}` : raw;
5612
5627
  } catch {
5613
- return `${value.address}/${value.prefix}`;
5628
+ return `${value$1.address}/${value$1.prefix}`;
5614
5629
  } finally {
5615
5630
  cidrParsing = false;
5616
5631
  }
@@ -5692,10 +5707,10 @@ function semVer(options = {}) {
5692
5707
  value: result
5693
5708
  };
5694
5709
  },
5695
- format(value) {
5696
- let s = `${value.major}.${value.minor}.${value.patch}`;
5697
- if (value.preRelease != null) s += `-${value.preRelease}`;
5698
- if (value.metadata != null) s += `+${value.metadata}`;
5710
+ format(value$1) {
5711
+ let s = `${value$1.major}.${value$1.minor}.${value$1.patch}`;
5712
+ if (value$1.preRelease != null) s += `-${value$1.preRelease}`;
5713
+ if (value$1.metadata != null) s += `+${value$1.metadata}`;
5699
5714
  return s;
5700
5715
  },
5701
5716
  *suggest(prefix) {
@@ -5719,8 +5734,8 @@ function semVer(options = {}) {
5719
5734
  value: canonical
5720
5735
  };
5721
5736
  },
5722
- format(value) {
5723
- return value;
5737
+ format(value$1) {
5738
+ return value$1;
5724
5739
  },
5725
5740
  *suggest(prefix) {
5726
5741
  for (const s of suggestions) if (s.startsWith(prefix)) yield {
@@ -5788,9 +5803,9 @@ function json(options) {
5788
5803
  metavar: metavar$1,
5789
5804
  placeholder,
5790
5805
  parse(input) {
5791
- let value;
5806
+ let value$1;
5792
5807
  try {
5793
- value = JSON.parse(input);
5808
+ value$1 = JSON.parse(input);
5794
5809
  } catch (e) {
5795
5810
  const err = e instanceof Error ? e : new Error(String(e));
5796
5811
  const error = invalidJsonError instanceof Function ? invalidJsonError(input) : invalidJsonError ?? [require_message.text(`Not a valid JSON: ${err.message}`)];
@@ -5799,7 +5814,7 @@ function json(options) {
5799
5814
  error
5800
5815
  };
5801
5816
  }
5802
- const nonFinite = findNonFiniteNumber(value);
5817
+ const nonFinite = findNonFiniteNumber(value$1);
5803
5818
  if (nonFinite !== void 0) {
5804
5819
  const error = invalidJsonError instanceof Function ? invalidJsonError(input) : invalidJsonError ?? [require_message.text(`Not a valid JSON: number out of range.`)];
5805
5820
  return {
@@ -5808,9 +5823,9 @@ function json(options) {
5808
5823
  };
5809
5824
  }
5810
5825
  if (rootType != null) {
5811
- const actual = jsonTypeOf(value);
5826
+ const actual = jsonTypeOf(value$1);
5812
5827
  if (actual !== rootType) {
5813
- const error = invalidRootTypeError instanceof Function ? invalidRootTypeError(value, rootType) : invalidRootTypeError ?? [require_message.text(`Expected JSON ${rootType}, but got ${actual}.`)];
5828
+ const error = invalidRootTypeError instanceof Function ? invalidRootTypeError(value$1, rootType) : invalidRootTypeError ?? [require_message.text(`Expected JSON ${rootType}, but got ${actual}.`)];
5814
5829
  return {
5815
5830
  success: false,
5816
5831
  error
@@ -5819,20 +5834,20 @@ function json(options) {
5819
5834
  }
5820
5835
  return {
5821
5836
  success: true,
5822
- value
5837
+ value: value$1
5823
5838
  };
5824
5839
  },
5825
- format(value) {
5826
- const nonFinite = findNonFiniteNumber(value);
5840
+ format(value$1) {
5841
+ const nonFinite = findNonFiniteNumber(value$1);
5827
5842
  if (nonFinite !== void 0) throw new TypeError(`Expected a finite JSON number, but got ${String(nonFinite)}.`);
5828
- return JSON.stringify(value);
5843
+ return JSON.stringify(value$1);
5829
5844
  }
5830
5845
  };
5831
5846
  }
5832
- function jsonTypeOf(value) {
5833
- if (value === null) return "null";
5834
- if (Array.isArray(value)) return "array";
5835
- return typeof value;
5847
+ function jsonTypeOf(value$1) {
5848
+ if (value$1 === null) return "null";
5849
+ if (Array.isArray(value$1)) return "array";
5850
+ return typeof value$1;
5836
5851
  }
5837
5852
  /**
5838
5853
  * Finds the first non-finite number (`NaN`, `Infinity`, or `-Infinity`)
@@ -5849,17 +5864,17 @@ function findNonFiniteNumber(root) {
5849
5864
  const stack = [root];
5850
5865
  const seen = /* @__PURE__ */ new Set();
5851
5866
  while (stack.length > 0) {
5852
- const value = stack.pop();
5853
- if (typeof value === "number") {
5854
- if (!Number.isFinite(value)) return value;
5855
- } else if (Array.isArray(value)) {
5856
- if (seen.has(value)) continue;
5857
- seen.add(value);
5858
- for (const item of value) stack.push(item);
5859
- } else if (value !== null && typeof value === "object") {
5860
- if (seen.has(value)) continue;
5861
- seen.add(value);
5862
- for (const item of Object.values(value)) stack.push(item);
5867
+ const value$1 = stack.pop();
5868
+ if (typeof value$1 === "number") {
5869
+ if (!Number.isFinite(value$1)) return value$1;
5870
+ } else if (Array.isArray(value$1)) {
5871
+ if (seen.has(value$1)) continue;
5872
+ seen.add(value$1);
5873
+ for (const item of value$1) stack.push(item);
5874
+ } else if (value$1 !== null && typeof value$1 === "object") {
5875
+ if (seen.has(value$1)) continue;
5876
+ seen.add(value$1);
5877
+ for (const item of Object.values(value$1)) stack.push(item);
5863
5878
  }
5864
5879
  }
5865
5880
  return void 0;
@@ -5992,21 +6007,21 @@ function cron(options = {}) {
5992
6007
  ...years ? { year: "1970" } : {}
5993
6008
  },
5994
6009
  parse: parseCron,
5995
- format(value) {
6010
+ format(value$1) {
5996
6011
  return [
5997
- ...seconds ? [value.second ?? "0"] : [],
5998
- value.minute,
5999
- value.hour,
6000
- value.dayOfMonth,
6001
- value.month,
6002
- value.dayOfWeek,
6003
- ...years ? [value.year ?? "1970"] : []
6012
+ ...seconds ? [value$1.second ?? "0"] : [],
6013
+ value$1.minute,
6014
+ value$1.hour,
6015
+ value$1.dayOfMonth,
6016
+ value$1.month,
6017
+ value$1.dayOfWeek,
6018
+ ...years ? [value$1.year ?? "1970"] : []
6004
6019
  ].join(" ");
6005
6020
  },
6006
- validate(value) {
6007
- if (seconds && value.second == null || years && value.year == null) return makeError(this.format(value));
6008
- if (!seconds && value.second != null || !years && value.year != null) return makeError(this.format(value));
6009
- const result = parseCron(this.format(value));
6021
+ validate(value$1) {
6022
+ if (seconds && value$1.second == null || years && value$1.year == null) return makeError(this.format(value$1));
6023
+ if (!seconds && value$1.second != null || !years && value$1.year != null) return makeError(this.format(value$1));
6024
+ const result = parseCron(this.format(value$1));
6010
6025
  return result.success ? {
6011
6026
  success: true,
6012
6027
  value: result.value
@@ -6038,10 +6053,10 @@ function isQuartzCronField(field, spec, quartz) {
6038
6053
  }
6039
6054
  return false;
6040
6055
  }
6041
- function parseQuartzDayOfWeekSuffixValue(value) {
6042
- if (/^[1-7]$/u.test(value)) return true;
6043
- if (!/^[A-Z]{3}$/u.test(value)) return false;
6044
- return CRON_DAY_NAMES.has(value);
6056
+ function parseQuartzDayOfWeekSuffixValue(value$1) {
6057
+ if (/^[1-7]$/u.test(value$1)) return true;
6058
+ if (!/^[A-Z]{3}$/u.test(value$1)) return false;
6059
+ return CRON_DAY_NAMES.has(value$1);
6045
6060
  }
6046
6061
  function isValidCronFieldPart(part, spec) {
6047
6062
  const stepParts = part.split("/");
@@ -6062,18 +6077,18 @@ function isValidCronFieldPart(part, spec) {
6062
6077
  function isPositiveCronStep(step) {
6063
6078
  return /^\d+$/u.test(step) && Number.parseInt(step, 10) > 0;
6064
6079
  }
6065
- function isCronValueInRange(value, spec) {
6066
- return parseCronValue(value, spec) !== void 0;
6080
+ function isCronValueInRange(value$1, spec) {
6081
+ return parseCronValue(value$1, spec) !== void 0;
6067
6082
  }
6068
6083
  function parseCronRangeEnd(start, end, spec) {
6069
6084
  if (spec.kind === "dayOfWeek" && start.toUpperCase() !== "SUN" && (end.toUpperCase() === "SUN" || end === "0")) return 7;
6070
6085
  return parseCronValue(end, spec);
6071
6086
  }
6072
- function parseCronValue(value, spec) {
6073
- const named = spec.names?.get(value.toUpperCase());
6087
+ function parseCronValue(value$1, spec) {
6088
+ const named = spec.names?.get(value$1.toUpperCase());
6074
6089
  if (named !== void 0) return named;
6075
- if (!/^\d+$/u.test(value)) return void 0;
6076
- const number = Number.parseInt(value, 10);
6090
+ if (!/^\d+$/u.test(value$1)) return void 0;
6091
+ const number = Number.parseInt(value$1, 10);
6077
6092
  return number >= spec.min && number <= spec.max ? number : void 0;
6078
6093
  }
6079
6094
  /**
@@ -6104,14 +6119,14 @@ function firstOf(...rawArgs) {
6104
6119
  }
6105
6120
  const metavar$1 = options.metavar ?? parsers.map((parser) => parser.metavar).join("|");
6106
6121
  require_nonempty.ensureNonEmptyString(metavar$1);
6107
- const mergedChoices = parsers.every((parser) => parser.choices != null) ? Object.freeze(parsers.flatMap((parser) => [...parser.choices]).filter((value, index, all) => all.findIndex((other) => Object.is(other, value)) === index)) : void 0;
6108
- function findOwner(value) {
6122
+ const mergedChoices = parsers.every((parser) => parser.choices != null) ? Object.freeze(parsers.flatMap((parser) => [...parser.choices]).filter((value$1, index, all) => all.findIndex((other) => Object.is(other, value$1)) === index)) : void 0;
6123
+ function findOwner(value$1) {
6109
6124
  let canonicalizing;
6110
6125
  for (const parser of parsers) {
6111
6126
  if (typeof parser.validate === "function") {
6112
6127
  let result$1;
6113
6128
  try {
6114
- result$1 = parser.validate(value);
6129
+ result$1 = parser.validate(value$1);
6115
6130
  } catch {
6116
6131
  continue;
6117
6132
  }
@@ -6123,18 +6138,18 @@ function firstOf(...rawArgs) {
6123
6138
  }
6124
6139
  let formatted;
6125
6140
  try {
6126
- formatted = parser.format(value);
6141
+ formatted = parser.format(value$1);
6127
6142
  } catch {
6128
6143
  continue;
6129
6144
  }
6130
6145
  if (typeof formatted !== "string") continue;
6131
6146
  const result = parser.parse(formatted);
6132
6147
  if (!result.success) continue;
6133
- if (ownsRoundTrippedValue(parser, result.value, value)) return {
6148
+ if (ownsRoundTrippedValue(parser, result.value, value$1)) return {
6134
6149
  parser,
6135
6150
  result
6136
6151
  };
6137
- if (canonicalizing == null && value !== null && typeof value !== "object" && typeof result.value === typeof value) canonicalizing = {
6152
+ if (canonicalizing == null && value$1 !== null && typeof value$1 !== "object" && typeof result.value === typeof value$1) canonicalizing = {
6138
6153
  parser,
6139
6154
  result
6140
6155
  };
@@ -6161,7 +6176,7 @@ function firstOf(...rawArgs) {
6161
6176
  error: noMatch == null ? firstOfNoMatchError(errors) : typeof noMatch === "function" ? noMatch(input, errors) : noMatch
6162
6177
  };
6163
6178
  },
6164
- format(value) {
6179
+ format(value$1) {
6165
6180
  let canonicalizing;
6166
6181
  let fallback;
6167
6182
  let firstError;
@@ -6169,7 +6184,7 @@ function firstOf(...rawArgs) {
6169
6184
  for (const parser of parsers) {
6170
6185
  let formatted;
6171
6186
  try {
6172
- formatted = parser.format(value);
6187
+ formatted = parser.format(value$1);
6173
6188
  } catch (e) {
6174
6189
  if (!hasError) {
6175
6190
  firstError = e;
@@ -6181,14 +6196,14 @@ function firstOf(...rawArgs) {
6181
6196
  if (typeof parser.validate === "function") {
6182
6197
  let owned = false;
6183
6198
  try {
6184
- owned = parser.validate(value).success;
6199
+ owned = parser.validate(value$1).success;
6185
6200
  } catch {}
6186
6201
  if (owned) return formatted;
6187
6202
  } else {
6188
6203
  const result = parser.parse(formatted);
6189
6204
  if (result.success) {
6190
- if (ownsRoundTrippedValue(parser, result.value, value)) return formatted;
6191
- if (canonicalizing == null && value !== null && typeof value !== "object" && typeof result.value === typeof value) canonicalizing = formatted;
6205
+ if (ownsRoundTrippedValue(parser, result.value, value$1)) return formatted;
6206
+ if (canonicalizing == null && value$1 !== null && typeof value$1 !== "object" && typeof result.value === typeof value$1) canonicalizing = formatted;
6192
6207
  }
6193
6208
  }
6194
6209
  fallback ??= formatted;
@@ -6198,18 +6213,18 @@ function firstOf(...rawArgs) {
6198
6213
  if (hasError) throw firstError;
6199
6214
  throw new TypeError("No constituent parser could format the given value.");
6200
6215
  },
6201
- validate(value) {
6202
- const owner = findOwner(value);
6216
+ validate(value$1) {
6217
+ const owner = findOwner(value$1);
6203
6218
  if (owner == null) return {
6204
6219
  success: false,
6205
6220
  error: require_message.message`Expected a value matching ${require_message.metavar(metavar$1)}.`
6206
6221
  };
6207
6222
  return owner.result;
6208
6223
  },
6209
- ...hasNormalize ? { normalize(value) {
6210
- const owner = findOwner(value);
6211
- if (owner == null || typeof owner.parser.normalize !== "function") return value;
6212
- return owner.parser.normalize(value);
6224
+ ...hasNormalize ? { normalize(value$1) {
6225
+ const owner = findOwner(value$1);
6226
+ if (owner == null || typeof owner.parser.normalize !== "function") return value$1;
6227
+ return owner.parser.normalize(value$1);
6213
6228
  } } : {},
6214
6229
  ...hasSuggest ? { *suggest(prefix) {
6215
6230
  const collected = [];
@@ -6252,19 +6267,19 @@ function firstOfNoMatchError(errors) {
6252
6267
  * canonicalization from data loss (e.g. a lossy `color()` `format()`
6253
6268
  * dropping fields that belong to a later, more faithful constituent).
6254
6269
  */
6255
- function ownsRoundTrippedValue(parser, roundTripped, value) {
6256
- if (valuesEqual(roundTripped, value)) return true;
6270
+ function ownsRoundTrippedValue(parser, roundTripped, value$1) {
6271
+ if (valuesEqual(roundTripped, value$1)) return true;
6257
6272
  if (typeof parser.normalize === "function") {
6258
6273
  let normalized;
6259
6274
  try {
6260
- normalized = parser.normalize(value);
6275
+ normalized = parser.normalize(value$1);
6261
6276
  } catch {
6262
6277
  return false;
6263
6278
  }
6264
6279
  if (valuesEqual(roundTripped, normalized)) return true;
6265
6280
  }
6266
- if (typeof value === "string" && typeof roundTripped === "string") return value.toLowerCase() === roundTripped.toLowerCase();
6267
- if (typeof value === "number" && typeof roundTripped === "number") return value === roundTripped;
6281
+ if (typeof value$1 === "string" && typeof roundTripped === "string") return value$1.toLowerCase() === roundTripped.toLowerCase();
6282
+ if (typeof value$1 === "number" && typeof roundTripped === "number") return value$1 === roundTripped;
6268
6283
  return false;
6269
6284
  }
6270
6285
  /**
@@ -6308,9 +6323,9 @@ function valuesEqual(a, b) {
6308
6323
  * Checks whether an object provides a `toString()` implementation other
6309
6324
  * than the generic `Object.prototype.toString`.
6310
6325
  */
6311
- function hasCustomToString(value) {
6326
+ function hasCustomToString(value$1) {
6312
6327
  try {
6313
- const toString = value.toString;
6328
+ const toString = value$1.toString;
6314
6329
  return typeof toString === "function" && toString !== Object.prototype.toString;
6315
6330
  } catch {
6316
6331
  return false;