@xpadev-net/niconicomments 0.2.73 → 0.2.75

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.
Files changed (3) hide show
  1. package/dist/bundle.d.ts +1930 -1426
  2. package/dist/bundle.js +756 -783
  3. package/package.json +17 -14
package/dist/bundle.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- niconicomments.js v0.2.73
2
+ niconicomments.js v0.2.75
3
3
  (c) 2021 xpadev-net https://xpadev.net
4
4
  Released under the MIT License.
5
5
  */
@@ -213,9 +213,6 @@
213
213
  for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
214
214
  return n;
215
215
  }
216
- function _arrayWithHoles(r) {
217
- if (Array.isArray(r)) return r;
218
- }
219
216
  function _arrayWithoutHoles(r) {
220
217
  if (Array.isArray(r)) return _arrayLikeToArray(r);
221
218
  }
@@ -238,7 +235,7 @@
238
235
  }
239
236
  function _createClass(e, r, t) {
240
237
  return Object.defineProperty(e, "prototype", {
241
- writable: !1
238
+ writable: false
242
239
  }), e;
243
240
  }
244
241
  function _createForOfIteratorHelper(r, e) {
@@ -252,9 +249,9 @@
252
249
  s: F,
253
250
  n: function () {
254
251
  return n >= r.length ? {
255
- done: !0
252
+ done: true
256
253
  } : {
257
- done: !1,
254
+ done: false,
258
255
  value: r[n++]
259
256
  };
260
257
  },
@@ -267,8 +264,8 @@
267
264
  throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
268
265
  }
269
266
  var o,
270
- a = !0,
271
- u = !1;
267
+ a = true,
268
+ u = false;
272
269
  return {
273
270
  s: function () {
274
271
  t = t.call(r);
@@ -278,7 +275,7 @@
278
275
  return a = r.done, r;
279
276
  },
280
277
  e: function (r) {
281
- u = !0, o = r;
278
+ u = true, o = r;
282
279
  },
283
280
  f: function () {
284
281
  try {
@@ -292,9 +289,9 @@
292
289
  function _defineProperty(e, r, t) {
293
290
  return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
294
291
  value: t,
295
- enumerable: !0,
296
- configurable: !0,
297
- writable: !0
292
+ enumerable: true,
293
+ configurable: true,
294
+ writable: true
298
295
  }) : e[r] = t, e;
299
296
  }
300
297
  function _getPrototypeOf(t) {
@@ -307,11 +304,11 @@
307
304
  t.prototype = Object.create(e && e.prototype, {
308
305
  constructor: {
309
306
  value: t,
310
- writable: !0,
311
- configurable: !0
307
+ writable: true,
308
+ configurable: true
312
309
  }
313
310
  }), Object.defineProperty(t, "prototype", {
314
- writable: !1
311
+ writable: false
315
312
  }), e && _setPrototypeOf(t, e);
316
313
  }
317
314
  function _isNativeFunction(t) {
@@ -332,36 +329,6 @@
332
329
  function _iterableToArray(r) {
333
330
  if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
334
331
  }
335
- function _iterableToArrayLimit(r, l) {
336
- var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
337
- if (null != t) {
338
- var e,
339
- n,
340
- i,
341
- u,
342
- a = [],
343
- f = !0,
344
- o = !1;
345
- try {
346
- if (i = (t = t.call(r)).next, 0 === l) {
347
- if (Object(t) !== t) return;
348
- f = !1;
349
- } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
350
- } catch (r) {
351
- o = !0, n = r;
352
- } finally {
353
- try {
354
- if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
355
- } finally {
356
- if (o) throw n;
357
- }
358
- }
359
- return a;
360
- }
361
- }
362
- function _nonIterableRest() {
363
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
364
- }
365
332
  function _nonIterableSpread() {
366
333
  throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
367
334
  }
@@ -378,7 +345,7 @@
378
345
  function _objectSpread2(e) {
379
346
  for (var r = 1; r < arguments.length; r++) {
380
347
  var t = null != arguments[r] ? arguments[r] : {};
381
- r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
348
+ r % 2 ? ownKeys(Object(t), true).forEach(function (r) {
382
349
  _defineProperty(e, r, t[r]);
383
350
  }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
384
351
  Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
@@ -396,9 +363,6 @@
396
363
  return t.__proto__ = e, t;
397
364
  }, _setPrototypeOf(t, e);
398
365
  }
399
- function _slicedToArray(r, e) {
400
- return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
401
- }
402
366
  function _toConsumableArray(r) {
403
367
  return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
404
368
  }
@@ -406,7 +370,7 @@
406
370
  if ("object" != typeof t || !t) return t;
407
371
  var e = t[Symbol.toPrimitive];
408
372
  if (void 0 !== e) {
409
- var i = e.call(t, r || "default");
373
+ var i = e.call(t, r);
410
374
  if ("object" != typeof i) return i;
411
375
  throw new TypeError("@@toPrimitive must return a primitive value.");
412
376
  }
@@ -447,254 +411,272 @@
447
411
  return Wrapper.prototype = Object.create(t.prototype, {
448
412
  constructor: {
449
413
  value: Wrapper,
450
- enumerable: !1,
451
- writable: !0,
452
- configurable: !0
414
+ enumerable: false,
415
+ writable: true,
416
+ configurable: true
453
417
  }
454
418
  }), _setPrototypeOf(Wrapper, t);
455
419
  }, _wrapNativeSuper(t);
456
420
  }
457
421
 
458
- // src/error/ValiError/ValiError.ts
459
- var ValiError = /*#__PURE__*/function (_Error) {
460
- /**
461
- * Creates a Valibot error with useful information.
462
- *
463
- * @param issues The error issues.
464
- */
465
- function ValiError(issues) {
466
- var _this;
467
- _classCallCheck(this, ValiError);
468
- _this = _callSuper(this, ValiError, [issues[0].message]);
469
- _defineProperty(_this, "issues", void 0);
470
- _this.name = "ValiError";
471
- _this.issues = issues;
472
- return _this;
473
- }
474
- _inherits(ValiError, _Error);
475
- return _createClass(ValiError);
476
- }(/*#__PURE__*/_wrapNativeSuper(Error));
477
-
478
- // src/utils/actionIssue/actionIssue.ts
479
- function actionIssue(context, reference, input, label, received) {
480
- return {
481
- issues: [{
482
- context: context,
483
- reference: reference,
484
- input: input,
485
- label: label,
486
- received: received
487
- }]
488
- };
489
- }
490
-
491
- // src/utils/actionOutput/actionOutput.ts
492
- function actionOutput(output) {
493
- return {
494
- output: output
495
- };
496
- }
497
-
498
- // src/utils/defaultArgs/defaultArgs.ts
499
- function defaultArgs(arg1, arg2) {
500
- return Array.isArray(arg1) ? [void 0, arg1] : [arg1, arg2];
501
- }
502
-
503
422
  // src/storages/globalConfig/globalConfig.ts
504
423
  var store;
505
- function getGlobalConfig(config) {
506
- var _config$lang, _store, _config$abortEarly, _store2, _config$abortPipeEarl, _store3, _config$skipPipe, _store4;
424
+ // @__NO_SIDE_EFFECTS__
425
+ function getGlobalConfig(config2) {
426
+ var _config2$lang, _store, _config2$abortEarly, _store2, _config2$abortPipeEar, _store3;
507
427
  return {
508
- lang: (_config$lang = config === null || config === void 0 ? void 0 : config.lang) !== null && _config$lang !== void 0 ? _config$lang : (_store = store) === null || _store === void 0 ? void 0 : _store.lang,
509
- message: config === null || config === void 0 ? void 0 : config.message,
510
- abortEarly: (_config$abortEarly = config === null || config === void 0 ? void 0 : config.abortEarly) !== null && _config$abortEarly !== void 0 ? _config$abortEarly : (_store2 = store) === null || _store2 === void 0 ? void 0 : _store2.abortEarly,
511
- abortPipeEarly: (_config$abortPipeEarl = config === null || config === void 0 ? void 0 : config.abortPipeEarly) !== null && _config$abortPipeEarl !== void 0 ? _config$abortPipeEarl : (_store3 = store) === null || _store3 === void 0 ? void 0 : _store3.abortPipeEarly,
512
- skipPipe: (_config$skipPipe = config === null || config === void 0 ? void 0 : config.skipPipe) !== null && _config$skipPipe !== void 0 ? _config$skipPipe : (_store4 = store) === null || _store4 === void 0 ? void 0 : _store4.skipPipe
428
+ lang: (_config2$lang = void 0 ) !== null && _config2$lang !== void 0 ? _config2$lang : (_store = store) === null || _store === void 0 ? void 0 : _store.lang,
429
+ message: config2 === null || config2 === void 0 ? void 0 : config2.message,
430
+ abortEarly: (_config2$abortEarly = void 0 ) !== null && _config2$abortEarly !== void 0 ? _config2$abortEarly : (_store2 = store) === null || _store2 === void 0 ? void 0 : _store2.abortEarly,
431
+ abortPipeEarly: (_config2$abortPipeEar = void 0 ) !== null && _config2$abortPipeEar !== void 0 ? _config2$abortPipeEar : (_store3 = store) === null || _store3 === void 0 ? void 0 : _store3.abortPipeEarly
513
432
  };
514
433
  }
515
434
 
516
435
  // src/storages/globalMessage/globalMessage.ts
517
436
  var store2;
437
+ // @__NO_SIDE_EFFECTS__
518
438
  function getGlobalMessage(lang) {
519
- var _store5;
520
- return (_store5 = store2) === null || _store5 === void 0 ? void 0 : _store5.get(lang);
439
+ var _store4;
440
+ return (_store4 = store2) === null || _store4 === void 0 ? void 0 : _store4.get(lang);
521
441
  }
522
442
 
523
443
  // src/storages/schemaMessage/schemaMessage.ts
524
444
  var store3;
445
+ // @__NO_SIDE_EFFECTS__
525
446
  function getSchemaMessage(lang) {
526
- var _store7;
527
- return (_store7 = store3) === null || _store7 === void 0 ? void 0 : _store7.get(lang);
447
+ var _store6;
448
+ return (_store6 = store3) === null || _store6 === void 0 ? void 0 : _store6.get(lang);
528
449
  }
529
450
 
530
451
  // src/storages/specificMessage/specificMessage.ts
531
452
  var store4;
453
+ // @__NO_SIDE_EFFECTS__
532
454
  function getSpecificMessage(reference, lang) {
533
- var _store9;
534
- return (_store9 = store4) === null || _store9 === void 0 || (_store9 = _store9.get(reference)) === null || _store9 === void 0 ? void 0 : _store9.get(lang);
455
+ var _store8;
456
+ return (_store8 = store4) === null || _store8 === void 0 || (_store8 = _store8.get(reference)) === null || _store8 === void 0 ? void 0 : _store8.get(lang);
535
457
  }
536
458
 
537
- // src/utils/i18n/i18n.ts
538
- function i18n(schema, context, reference, config, issue) {
539
- var _ref3, _ref4, _ref5, _ref6, _context$message;
540
- var message = (_ref3 = (_ref4 = (_ref5 = (_ref6 = (_context$message = context.message) !== null && _context$message !== void 0 ? _context$message : getSpecificMessage(reference, issue.lang)) !== null && _ref6 !== void 0 ? _ref6 : schema ? getSchemaMessage(issue.lang) : null) !== null && _ref5 !== void 0 ? _ref5 : config === null || config === void 0 ? void 0 : config.message) !== null && _ref4 !== void 0 ? _ref4 : getGlobalMessage(issue.lang)) !== null && _ref3 !== void 0 ? _ref3 : issue.message;
541
- return typeof message === "function" ? message(issue) : message;
459
+ // src/utils/_stringify/_stringify.ts
460
+ // @__NO_SIDE_EFFECTS__
461
+ function _stringify(input) {
462
+ var type = _typeof(input);
463
+ if (type === "string") {
464
+ return "\"".concat(input, "\"");
465
+ }
466
+ if (type === "number" || type === "bigint" || type === "boolean") {
467
+ return "".concat(input);
468
+ }
469
+ if (type === "object" || type === "function") {
470
+ var _ref, _Object$getPrototypeO;
471
+ return (_ref = input && ((_Object$getPrototypeO = Object.getPrototypeOf(input)) === null || _Object$getPrototypeO === void 0 || (_Object$getPrototypeO = _Object$getPrototypeO.constructor) === null || _Object$getPrototypeO === void 0 ? void 0 : _Object$getPrototypeO.name)) !== null && _ref !== void 0 ? _ref : "null";
472
+ }
473
+ return type;
474
+ }
475
+
476
+ // src/utils/_addIssue/_addIssue.ts
477
+ function _addIssue(context, label, dataset, config2, other) {
478
+ var _ref2, _other$expected, _other$received, _ref3, _ref4, _ref5, _ref6, _other$message;
479
+ var input = other && "input" in other ? other.input : dataset.value;
480
+ var expected = (_ref2 = (_other$expected = other === null || other === void 0 ? void 0 : other.expected) !== null && _other$expected !== void 0 ? _other$expected : context.expects) !== null && _ref2 !== void 0 ? _ref2 : null;
481
+ var received = (_other$received = other === null || other === void 0 ? void 0 : other.received) !== null && _other$received !== void 0 ? _other$received : _stringify(input);
482
+ var issue = {
483
+ kind: context.kind,
484
+ type: context.type,
485
+ input: input,
486
+ expected: expected,
487
+ received: received,
488
+ message: "Invalid ".concat(label, ": ").concat(expected ? "Expected ".concat(expected, " but r") : "R", "eceived ").concat(received),
489
+ requirement: context.requirement,
490
+ path: other === null || other === void 0 ? void 0 : other.path,
491
+ issues: other === null || other === void 0 ? void 0 : other.issues,
492
+ lang: config2.lang,
493
+ abortEarly: config2.abortEarly,
494
+ abortPipeEarly: config2.abortPipeEarly
495
+ };
496
+ var isSchema = context.kind === "schema";
497
+ var message2 = (_ref3 = (_ref4 = (_ref5 = (_ref6 = (_other$message = other === null || other === void 0 ? void 0 : other.message) !== null && _other$message !== void 0 ? _other$message : context.message) !== null && _ref6 !== void 0 ? _ref6 : getSpecificMessage(context.reference, issue.lang)) !== null && _ref5 !== void 0 ? _ref5 : isSchema ? getSchemaMessage(issue.lang) : null) !== null && _ref4 !== void 0 ? _ref4 : config2.message) !== null && _ref3 !== void 0 ? _ref3 : getGlobalMessage(issue.lang);
498
+ if (message2 !== void 0) {
499
+ issue.message = typeof message2 === "function" ?
500
+ // @ts-expect-error
501
+ message2(issue) : message2;
502
+ }
503
+ if (isSchema) {
504
+ dataset.typed = false;
505
+ }
506
+ if (dataset.issues) {
507
+ dataset.issues.push(issue);
508
+ } else {
509
+ dataset.issues = [issue];
510
+ }
542
511
  }
543
512
 
544
- // src/utils/schemaResult/schemaResult.ts
545
- function schemaResult(typed, output, issues) {
513
+ // src/utils/_getStandardProps/_getStandardProps.ts
514
+ // @__NO_SIDE_EFFECTS__
515
+ function _getStandardProps(context) {
546
516
  return {
547
- typed: typed,
548
- output: output,
549
- issues: issues
517
+ version: 1,
518
+ vendor: "valibot",
519
+ validate: function validate(value2) {
520
+ return context["~run"]({
521
+ value: value2
522
+ }, getGlobalConfig());
523
+ }
550
524
  };
551
525
  }
552
526
 
553
- // src/utils/stringify/stringify.ts
554
- function stringify(input) {
555
- var type = _typeof(input);
556
- if (type === "object") {
557
- type = input ? Object.getPrototypeOf(input).constructor.name : "null";
527
+ // src/utils/_isValidObjectKey/_isValidObjectKey.ts
528
+ // @__NO_SIDE_EFFECTS__
529
+ function _isValidObjectKey(object2, key) {
530
+ return Object.hasOwn(object2, key) && key !== "__proto__" && key !== "prototype" && key !== "constructor";
531
+ }
532
+
533
+ // src/utils/_joinExpects/_joinExpects.ts
534
+ // @__NO_SIDE_EFFECTS__
535
+ function _joinExpects(values2, separator) {
536
+ var _list$;
537
+ var list = _toConsumableArray(new Set(values2));
538
+ if (list.length > 1) {
539
+ return "(".concat(list.join(" ".concat(separator, " ")), ")");
558
540
  }
559
- return type === "string" ? "\"".concat(input, "\"") : type === "number" || type === "bigint" || type === "boolean" ? "".concat(input) : type;
541
+ return (_list$ = list[0]) !== null && _list$ !== void 0 ? _list$ : "never";
560
542
  }
561
543
 
562
- // src/utils/pipeResult/utils/pipeIssue/pipeIssue.ts
563
- function pipeIssue(context, config, issue) {
564
- var _issue$received;
565
- var received = (_issue$received = issue.received) !== null && _issue$received !== void 0 ? _issue$received : stringify(issue.input);
566
- var schemaIssue2 = {
567
- reason: context.type,
568
- context: issue.context.type,
569
- expected: issue.context.expects,
570
- received: received,
571
- message: "Invalid ".concat(issue.label, ": ").concat(issue.context.expects ? "Expected ".concat(issue.context.expects, " but r") : "R", "eceived ").concat(received),
572
- input: issue.input,
573
- requirement: issue.context.requirement,
574
- path: issue.path,
575
- lang: config === null || config === void 0 ? void 0 : config.lang,
576
- abortEarly: config === null || config === void 0 ? void 0 : config.abortEarly,
577
- abortPipeEarly: config === null || config === void 0 ? void 0 : config.abortPipeEarly,
578
- skipPipe: config === null || config === void 0 ? void 0 : config.skipPipe
544
+ // src/utils/ValiError/ValiError.ts
545
+ var ValiError = /*#__PURE__*/function (_Error) {
546
+ /**
547
+ * Creates a Valibot error with useful information.
548
+ *
549
+ * @param issues The error issues.
550
+ */
551
+ function ValiError(issues) {
552
+ var _this;
553
+ _classCallCheck(this, ValiError);
554
+ _this = _callSuper(this, ValiError, [issues[0].message]);
555
+ _this.name = "ValiError";
556
+ _this.issues = issues;
557
+ return _this;
558
+ }
559
+ _inherits(ValiError, _Error);
560
+ return _createClass(ValiError);
561
+ }(/*#__PURE__*/_wrapNativeSuper(Error));
562
+
563
+ // src/actions/check/check.ts
564
+ // @__NO_SIDE_EFFECTS__
565
+ function check(requirement, message2) {
566
+ return {
567
+ kind: "validation",
568
+ type: "check",
569
+ reference: check,
570
+ async: false,
571
+ expects: null,
572
+ requirement: requirement,
573
+ message: message2,
574
+ "~run": function run(dataset, config2) {
575
+ if (dataset.typed && !this.requirement(dataset.value)) {
576
+ _addIssue(this, "input", dataset, config2);
577
+ }
578
+ return dataset;
579
+ }
579
580
  };
580
- schemaIssue2.message = i18n(false, issue.context, issue.reference, config, schemaIssue2);
581
- return schemaIssue2;
582
581
  }
583
582
 
584
- // src/utils/pipeResult/pipeResult.ts
585
- function pipeResult(context, input, config, issues) {
586
- if (context.pipe && !(config !== null && config !== void 0 && config.skipPipe)) {
587
- var _iterator = _createForOfIteratorHelper(context.pipe),
588
- _step;
589
- try {
590
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
591
- var action = _step.value;
592
- var result = action._parse(input);
593
- if (result.issues) {
594
- var _iterator2 = _createForOfIteratorHelper(result.issues),
595
- _step2;
596
- try {
597
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
598
- var actionIssue2 = _step2.value;
599
- var schemaIssue2 = pipeIssue(context, config, actionIssue2);
600
- issues ? issues.push(schemaIssue2) : issues = [schemaIssue2];
601
- }
602
- } catch (err) {
603
- _iterator2.e(err);
604
- } finally {
605
- _iterator2.f();
606
- }
607
- if (config !== null && config !== void 0 && config.abortEarly || config !== null && config !== void 0 && config.abortPipeEarly) {
608
- break;
609
- }
610
- } else {
611
- input = result.output;
612
- }
583
+ // src/actions/notValue/notValue.ts
584
+ // @__NO_SIDE_EFFECTS__
585
+ function notValue(requirement, message2) {
586
+ return {
587
+ kind: "validation",
588
+ type: "not_value",
589
+ reference: notValue,
590
+ async: false,
591
+ expects: requirement instanceof Date ? "!".concat(requirement.toJSON()) : "!".concat(_stringify(requirement)),
592
+ requirement: requirement,
593
+ message: message2,
594
+ "~run": function run(dataset, config2) {
595
+ if (dataset.typed && this.requirement <= dataset.value && this.requirement >= dataset.value) {
596
+ _addIssue(this, "value", dataset, config2, {
597
+ received: dataset.value instanceof Date ? dataset.value.toJSON() : _stringify(dataset.value)
598
+ });
613
599
  }
614
- } catch (err) {
615
- _iterator.e(err);
616
- } finally {
617
- _iterator.f();
600
+ return dataset;
618
601
  }
619
- }
620
- return schemaResult(true, input, issues);
621
- }
622
- function restAndDefaultArgs(arg1, arg2, arg3) {
623
- if (!arg1 || _typeof(arg1) === "object" && !Array.isArray(arg1)) {
624
- var _defaultArgs = defaultArgs(arg2, arg3),
625
- _defaultArgs2 = _slicedToArray(_defaultArgs, 2),
626
- error2 = _defaultArgs2[0],
627
- pipe2 = _defaultArgs2[1];
628
- return [arg1, error2, pipe2];
629
- }
630
- var _defaultArgs3 = defaultArgs(arg1, arg2),
631
- _defaultArgs4 = _slicedToArray(_defaultArgs3, 2),
632
- error = _defaultArgs4[0],
633
- pipe = _defaultArgs4[1];
634
- return [void 0, error, pipe];
602
+ };
635
603
  }
636
604
 
637
- // src/utils/schemaIssue/schemaIssue.ts
638
- function schemaIssue(context, reference, input, config, other) {
639
- var _other$expected, _other$reason;
640
- var received = stringify(input);
641
- var expected = (_other$expected = other === null || other === void 0 ? void 0 : other.expected) !== null && _other$expected !== void 0 ? _other$expected : context.expects;
642
- var issue = {
643
- reason: (_other$reason = other === null || other === void 0 ? void 0 : other.reason) !== null && _other$reason !== void 0 ? _other$reason : "type",
644
- context: context.type,
645
- expected: expected,
646
- received: received,
647
- message: "Invalid type: Expected ".concat(expected, " but received ").concat(received),
648
- input: input,
649
- path: other === null || other === void 0 ? void 0 : other.path,
650
- issues: other === null || other === void 0 ? void 0 : other.issues,
651
- lang: config === null || config === void 0 ? void 0 : config.lang,
652
- abortEarly: config === null || config === void 0 ? void 0 : config.abortEarly,
653
- abortPipeEarly: config === null || config === void 0 ? void 0 : config.abortPipeEarly,
654
- skipPipe: config === null || config === void 0 ? void 0 : config.skipPipe
655
- };
656
- issue.message = i18n(true, context, reference, config, issue);
605
+ // src/actions/regex/regex.ts
606
+ // @__NO_SIDE_EFFECTS__
607
+ function regex(requirement, message2) {
657
608
  return {
658
- typed: false,
659
- output: input,
660
- issues: [issue]
609
+ kind: "validation",
610
+ type: "regex",
611
+ reference: regex,
612
+ async: false,
613
+ expects: "".concat(requirement),
614
+ requirement: requirement,
615
+ message: message2,
616
+ "~run": function run(dataset, config2) {
617
+ if (dataset.typed && !this.requirement.test(dataset.value)) {
618
+ _addIssue(this, "format", dataset, config2);
619
+ }
620
+ return dataset;
621
+ }
661
622
  };
662
623
  }
663
624
 
625
+ // src/methods/getFallback/getFallback.ts
626
+ // @__NO_SIDE_EFFECTS__
627
+ function getFallback(schema, dataset, config2) {
628
+ return typeof schema.fallback === "function" ?
629
+ // @ts-expect-error
630
+ schema.fallback(dataset, config2) :
631
+ // @ts-expect-error
632
+ schema.fallback;
633
+ }
634
+
664
635
  // src/methods/getDefault/getDefault.ts
665
- function getDefault(schema) {
666
- return typeof schema["default"] === "function" ? schema["default"]() : schema["default"];
636
+ // @__NO_SIDE_EFFECTS__
637
+ function getDefault(schema, dataset, config2) {
638
+ return typeof schema["default"] === "function" ?
639
+ // @ts-expect-error
640
+ schema["default"](dataset, config2) :
641
+ // @ts-expect-error
642
+ schema["default"];
667
643
  }
668
- function is(schema, input, config) {
669
- var _getGlobalConfig;
670
- return !schema._parse(input, {
671
- abortEarly: true,
672
- skipPipe: (_getGlobalConfig = getGlobalConfig(config)) === null || _getGlobalConfig === void 0 ? void 0 : _getGlobalConfig.skipPipe
644
+
645
+ // src/methods/is/is.ts
646
+ // @__NO_SIDE_EFFECTS__
647
+ function is(schema, input) {
648
+ return !schema["~run"]({
649
+ value: input
650
+ }, {
651
+ abortEarly: true
673
652
  }).issues;
674
653
  }
675
654
 
676
655
  // src/schemas/array/array.ts
677
- function array(item, arg2, arg3) {
678
- var _defaultArgs5 = defaultArgs(arg2, arg3),
679
- _defaultArgs6 = _slicedToArray(_defaultArgs5, 2),
680
- message = _defaultArgs6[0],
681
- pipe = _defaultArgs6[1];
656
+ // @__NO_SIDE_EFFECTS__
657
+ function array(item, message2) {
682
658
  return {
659
+ kind: "schema",
683
660
  type: "array",
661
+ reference: array,
684
662
  expects: "Array",
685
663
  async: false,
686
664
  item: item,
687
- message: message,
688
- pipe: pipe,
689
- _parse: function _parse(input, config) {
665
+ message: message2,
666
+ get "~standard"() {
667
+ return _getStandardProps(this);
668
+ },
669
+ "~run": function run(dataset, config2) {
670
+ var input = dataset.value;
690
671
  if (Array.isArray(input)) {
691
- var typed = true;
692
- var issues;
693
- var output = [];
672
+ dataset.typed = true;
673
+ dataset.value = [];
694
674
  for (var key = 0; key < input.length; key++) {
695
675
  var value2 = input[key];
696
- var result = this.item._parse(value2, config);
697
- if (result.issues) {
676
+ var itemDataset = this.item["~run"]({
677
+ value: value2
678
+ }, config2);
679
+ if (itemDataset.issues) {
698
680
  var pathItem = {
699
681
  type: "array",
700
682
  origin: "value",
@@ -702,774 +684,749 @@
702
684
  key: key,
703
685
  value: value2
704
686
  };
705
- var _iterator7 = _createForOfIteratorHelper(result.issues),
706
- _step7;
687
+ var _iterator12 = _createForOfIteratorHelper(itemDataset.issues),
688
+ _step12;
707
689
  try {
708
- for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
709
- var _issues;
710
- var issue = _step7.value;
690
+ for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {
691
+ var _dataset$issues;
692
+ var issue = _step12.value;
711
693
  if (issue.path) {
712
694
  issue.path.unshift(pathItem);
713
695
  } else {
714
696
  issue.path = [pathItem];
715
697
  }
716
- (_issues = issues) === null || _issues === void 0 || _issues.push(issue);
698
+ (_dataset$issues = dataset.issues) === null || _dataset$issues === void 0 || _dataset$issues.push(issue);
717
699
  }
718
700
  } catch (err) {
719
- _iterator7.e(err);
701
+ _iterator12.e(err);
720
702
  } finally {
721
- _iterator7.f();
703
+ _iterator12.f();
722
704
  }
723
- if (!issues) {
724
- issues = result.issues;
705
+ if (!dataset.issues) {
706
+ dataset.issues = itemDataset.issues;
725
707
  }
726
- if (config !== null && config !== void 0 && config.abortEarly) {
727
- typed = false;
708
+ if (config2.abortEarly) {
709
+ dataset.typed = false;
728
710
  break;
729
711
  }
730
712
  }
731
- if (!result.typed) {
732
- typed = false;
713
+ if (!itemDataset.typed) {
714
+ dataset.typed = false;
733
715
  }
734
- output.push(result.output);
735
- }
736
- if (typed) {
737
- return pipeResult(this, output, config, issues);
716
+ dataset.value.push(itemDataset.value);
738
717
  }
739
- return schemaResult(false, output, issues);
718
+ } else {
719
+ _addIssue(this, "type", dataset, config2);
740
720
  }
741
- return schemaIssue(this, array, input, config);
721
+ return dataset;
742
722
  }
743
723
  };
744
724
  }
745
725
 
746
726
  // src/schemas/boolean/boolean.ts
747
- function _boolean(arg1, arg2) {
748
- var _defaultArgs17 = defaultArgs(arg1, arg2),
749
- _defaultArgs18 = _slicedToArray(_defaultArgs17, 2),
750
- message = _defaultArgs18[0],
751
- pipe = _defaultArgs18[1];
727
+ // @__NO_SIDE_EFFECTS__
728
+ function _boolean(message2) {
752
729
  return {
730
+ kind: "schema",
753
731
  type: "boolean",
732
+ reference: _boolean,
754
733
  expects: "boolean",
755
734
  async: false,
756
- message: message,
757
- pipe: pipe,
758
- _parse: function _parse(input, config) {
759
- if (typeof input === "boolean") {
760
- return pipeResult(this, input, config);
735
+ message: message2,
736
+ get "~standard"() {
737
+ return _getStandardProps(this);
738
+ },
739
+ "~run": function run(dataset, config2) {
740
+ if (typeof dataset.value === "boolean") {
741
+ dataset.typed = true;
742
+ } else {
743
+ _addIssue(this, "type", dataset, config2);
761
744
  }
762
- return schemaIssue(this, _boolean, input, config);
745
+ return dataset;
763
746
  }
764
747
  };
765
748
  }
766
749
 
767
750
  // src/schemas/instance/instance.ts
768
- function instance(class_, arg2, arg3) {
769
- var _defaultArgs25 = defaultArgs(arg2, arg3),
770
- _defaultArgs26 = _slicedToArray(_defaultArgs25, 2),
771
- message = _defaultArgs26[0],
772
- pipe = _defaultArgs26[1];
751
+ // @__NO_SIDE_EFFECTS__
752
+ function instance(class_, message2) {
773
753
  return {
754
+ kind: "schema",
774
755
  type: "instance",
756
+ reference: instance,
775
757
  expects: class_.name,
776
758
  async: false,
777
759
  "class": class_,
778
- message: message,
779
- pipe: pipe,
780
- _parse: function _parse(input, config) {
781
- if (input instanceof this["class"]) {
782
- return pipeResult(this, input, config);
760
+ message: message2,
761
+ get "~standard"() {
762
+ return _getStandardProps(this);
763
+ },
764
+ "~run": function run(dataset, config2) {
765
+ if (dataset.value instanceof this["class"]) {
766
+ dataset.typed = true;
767
+ } else {
768
+ _addIssue(this, "type", dataset, config2);
783
769
  }
784
- return schemaIssue(this, instance, input, config);
770
+ return dataset;
785
771
  }
786
772
  };
787
773
  }
788
774
 
789
- // src/schemas/intersect/utils/mergeOutputs/mergeOutputs.ts
790
- function mergeOutputs(output1, output2) {
791
- if (_typeof(output1) === _typeof(output2)) {
792
- if (output1 === output2 || output1 instanceof Date && output2 instanceof Date && +output1 === +output2) {
775
+ // src/schemas/intersect/utils/_merge/_merge.ts
776
+ // @__NO_SIDE_EFFECTS__
777
+ function _merge(value1, value2) {
778
+ if (_typeof(value1) === _typeof(value2)) {
779
+ if (value1 === value2 || value1 instanceof Date && value2 instanceof Date && +value1 === +value2) {
793
780
  return {
794
- output: output1
781
+ value: value1
795
782
  };
796
783
  }
797
- if (Array.isArray(output1) && Array.isArray(output2)) {
798
- if (output1.length === output2.length) {
799
- var array2 = [];
800
- for (var index = 0; index < output1.length; index++) {
801
- var result = mergeOutputs(output1[index], output2[index]);
802
- if (result.invalid) {
803
- return result;
784
+ if (value1 && value2 && value1.constructor === Object && value2.constructor === Object) {
785
+ for (var key in value2) {
786
+ if (key in value1) {
787
+ var dataset = /* @__PURE__ */_merge(value1[key], value2[key]);
788
+ if (dataset.issue) {
789
+ return dataset;
804
790
  }
805
- array2.push(result.output);
791
+ value1[key] = dataset.value;
792
+ } else {
793
+ value1[key] = value2[key];
806
794
  }
807
- return {
808
- output: array2
809
- };
810
795
  }
811
796
  return {
812
- invalid: true
797
+ value: value1
813
798
  };
814
799
  }
815
- if (output1 && output2 && output1.constructor === Object && output2.constructor === Object) {
816
- var object2 = _objectSpread2(_objectSpread2({}, output1), output2);
817
- for (var key in output1) {
818
- if (key in output2) {
819
- var _result = mergeOutputs(output1[key], output2[key]);
820
- if (_result.invalid) {
821
- return _result;
800
+ if (Array.isArray(value1) && Array.isArray(value2)) {
801
+ if (value1.length === value2.length) {
802
+ for (var index = 0; index < value1.length; index++) {
803
+ var _dataset = /* @__PURE__ */_merge(value1[index], value2[index]);
804
+ if (_dataset.issue) {
805
+ return _dataset;
822
806
  }
823
- object2[key] = _result.output;
807
+ value1[index] = _dataset.value;
824
808
  }
809
+ return {
810
+ value: value1
811
+ };
825
812
  }
826
- return {
827
- output: object2
828
- };
829
813
  }
830
814
  }
831
815
  return {
832
- invalid: true
816
+ issue: true
833
817
  };
834
818
  }
835
819
 
836
820
  // src/schemas/intersect/intersect.ts
837
- function intersect(options, arg2, arg3) {
838
- var _defaultArgs29 = defaultArgs(arg2, arg3),
839
- _defaultArgs30 = _slicedToArray(_defaultArgs29, 2),
840
- message = _defaultArgs30[0],
841
- pipe = _defaultArgs30[1];
821
+ // @__NO_SIDE_EFFECTS__
822
+ function intersect(options, message2) {
842
823
  return {
824
+ kind: "schema",
843
825
  type: "intersect",
844
- expects: _toConsumableArray(new Set(options.map(function (option) {
826
+ reference: intersect,
827
+ expects: _joinExpects(options.map(function (option) {
845
828
  return option.expects;
846
- }))).join(" & "),
829
+ }), "&"),
847
830
  async: false,
848
831
  options: options,
849
- message: message,
850
- pipe: pipe,
851
- _parse: function _parse(input, config) {
852
- var typed = true;
853
- var issues;
854
- var output;
855
- var outputs = [];
856
- var _iterator9 = _createForOfIteratorHelper(this.options),
857
- _step9;
858
- try {
859
- for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
860
- var schema = _step9.value;
861
- var _result2 = schema._parse(input, config);
862
- if (_result2.issues) {
863
- if (issues) {
864
- var _iterator10 = _createForOfIteratorHelper(_result2.issues),
865
- _step10;
866
- try {
867
- for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
868
- var issue = _step10.value;
869
- issues.push(issue);
870
- }
871
- } catch (err) {
872
- _iterator10.e(err);
873
- } finally {
874
- _iterator10.f();
832
+ message: message2,
833
+ get "~standard"() {
834
+ return _getStandardProps(this);
835
+ },
836
+ "~run": function run(dataset, config2) {
837
+ if (this.options.length) {
838
+ var input = dataset.value;
839
+ var outputs;
840
+ dataset.typed = true;
841
+ var _iterator14 = _createForOfIteratorHelper(this.options),
842
+ _step14;
843
+ try {
844
+ for (_iterator14.s(); !(_step14 = _iterator14.n()).done;) {
845
+ var schema = _step14.value;
846
+ var optionDataset = schema["~run"]({
847
+ value: input
848
+ }, config2);
849
+ if (optionDataset.issues) {
850
+ if (dataset.issues) {
851
+ var _dataset$issues3;
852
+ (_dataset$issues3 = dataset.issues).push.apply(_dataset$issues3, _toConsumableArray(optionDataset.issues));
853
+ } else {
854
+ dataset.issues = optionDataset.issues;
855
+ }
856
+ if (config2.abortEarly) {
857
+ dataset.typed = false;
858
+ break;
875
859
  }
876
- } else {
877
- issues = _result2.issues;
878
860
  }
879
- if (config !== null && config !== void 0 && config.abortEarly) {
880
- typed = false;
881
- break;
861
+ if (!optionDataset.typed) {
862
+ dataset.typed = false;
863
+ }
864
+ if (dataset.typed) {
865
+ if (outputs) {
866
+ outputs.push(optionDataset.value);
867
+ } else {
868
+ outputs = [optionDataset.value];
869
+ }
882
870
  }
883
871
  }
884
- if (!_result2.typed) {
885
- typed = false;
886
- }
887
- outputs.push(_result2.output);
888
- }
889
- } catch (err) {
890
- _iterator9.e(err);
891
- } finally {
892
- _iterator9.f();
893
- }
894
- if (typed) {
895
- output = outputs[0];
896
- for (var index = 1; index < outputs.length; index++) {
897
- var result = mergeOutputs(output, outputs[index]);
898
- if (result.invalid) {
899
- return schemaIssue(this, intersect, input, config);
872
+ } catch (err) {
873
+ _iterator14.e(err);
874
+ } finally {
875
+ _iterator14.f();
876
+ }
877
+ if (dataset.typed) {
878
+ dataset.value = outputs[0];
879
+ for (var index = 1; index < outputs.length; index++) {
880
+ var mergeDataset = _merge(dataset.value, outputs[index]);
881
+ if (mergeDataset.issue) {
882
+ _addIssue(this, "type", dataset, config2, {
883
+ received: "unknown"
884
+ });
885
+ break;
886
+ }
887
+ dataset.value = mergeDataset.value;
900
888
  }
901
- output = result.output;
902
889
  }
903
- return pipeResult(this, output, config, issues);
890
+ } else {
891
+ _addIssue(this, "type", dataset, config2);
904
892
  }
905
- return schemaResult(false, output, issues);
893
+ return dataset;
906
894
  }
907
895
  };
908
896
  }
909
897
 
910
898
  // src/schemas/literal/literal.ts
911
- function literal(literal_, message) {
899
+ // @__NO_SIDE_EFFECTS__
900
+ function literal(literal_, message2) {
912
901
  return {
902
+ kind: "schema",
913
903
  type: "literal",
914
- expects: stringify(literal_),
904
+ reference: literal,
905
+ expects: _stringify(literal_),
915
906
  async: false,
916
907
  literal: literal_,
917
- message: message,
918
- _parse: function _parse(input, config) {
919
- if (input === this.literal) {
920
- return schemaResult(true, input);
908
+ message: message2,
909
+ get "~standard"() {
910
+ return _getStandardProps(this);
911
+ },
912
+ "~run": function run(dataset, config2) {
913
+ if (dataset.value === this.literal) {
914
+ dataset.typed = true;
915
+ } else {
916
+ _addIssue(this, "type", dataset, config2);
921
917
  }
922
- return schemaIssue(this, literal, input, config);
918
+ return dataset;
923
919
  }
924
920
  };
925
921
  }
926
922
 
927
923
  // src/schemas/nullable/nullable.ts
924
+ // @__NO_SIDE_EFFECTS__
928
925
  function nullable(wrapped, default_) {
929
926
  return {
927
+ kind: "schema",
930
928
  type: "nullable",
931
- expects: "".concat(wrapped.expects, " | null"),
929
+ reference: nullable,
930
+ expects: "(".concat(wrapped.expects, " | null)"),
932
931
  async: false,
933
932
  wrapped: wrapped,
934
933
  "default": default_,
935
- _parse: function _parse(input, config) {
936
- if (input === null) {
937
- var override = getDefault(this);
938
- if (override === void 0) {
939
- return schemaResult(true, input);
934
+ get "~standard"() {
935
+ return _getStandardProps(this);
936
+ },
937
+ "~run": function run(dataset, config2) {
938
+ if (dataset.value === null) {
939
+ if (this["default"] !== void 0) {
940
+ dataset.value = getDefault(this, dataset, config2);
941
+ }
942
+ if (dataset.value === null) {
943
+ dataset.typed = true;
944
+ return dataset;
940
945
  }
941
- input = override;
942
946
  }
943
- return this.wrapped._parse(input, config);
947
+ return this.wrapped["~run"](dataset, config2);
944
948
  }
945
949
  };
946
950
  }
947
951
 
948
952
  // src/schemas/number/number.ts
949
- function number(arg1, arg2) {
950
- var _defaultArgs37 = defaultArgs(arg1, arg2),
951
- _defaultArgs38 = _slicedToArray(_defaultArgs37, 2),
952
- message = _defaultArgs38[0],
953
- pipe = _defaultArgs38[1];
953
+ // @__NO_SIDE_EFFECTS__
954
+ function number(message2) {
954
955
  return {
956
+ kind: "schema",
955
957
  type: "number",
958
+ reference: number,
956
959
  expects: "number",
957
960
  async: false,
958
- message: message,
959
- pipe: pipe,
960
- _parse: function _parse(input, config) {
961
- if (typeof input === "number" && !isNaN(input)) {
962
- return pipeResult(this, input, config);
961
+ message: message2,
962
+ get "~standard"() {
963
+ return _getStandardProps(this);
964
+ },
965
+ "~run": function run(dataset, config2) {
966
+ if (typeof dataset.value === "number" && !isNaN(dataset.value)) {
967
+ dataset.typed = true;
968
+ } else {
969
+ _addIssue(this, "type", dataset, config2);
963
970
  }
964
- return schemaIssue(this, number, input, config);
971
+ return dataset;
965
972
  }
966
973
  };
967
974
  }
968
975
 
969
976
  // src/schemas/object/object.ts
970
- function object(entries, arg2, arg3, arg4) {
971
- var _restAndDefaultArgs = restAndDefaultArgs(arg2, arg3, arg4),
972
- _restAndDefaultArgs2 = _slicedToArray(_restAndDefaultArgs, 3),
973
- rest = _restAndDefaultArgs2[0],
974
- message = _restAndDefaultArgs2[1],
975
- pipe = _restAndDefaultArgs2[2];
976
- var cachedEntries;
977
+ // @__NO_SIDE_EFFECTS__
978
+ function object(entries2, message2) {
977
979
  return {
980
+ kind: "schema",
978
981
  type: "object",
982
+ reference: object,
979
983
  expects: "Object",
980
984
  async: false,
981
- entries: entries,
982
- rest: rest,
983
- message: message,
984
- pipe: pipe,
985
- _parse: function _parse(input, config) {
985
+ entries: entries2,
986
+ message: message2,
987
+ get "~standard"() {
988
+ return _getStandardProps(this);
989
+ },
990
+ "~run": function run(dataset, config2) {
991
+ var input = dataset.value;
986
992
  if (input && _typeof(input) === "object") {
987
- var _cachedEntries;
988
- cachedEntries = (_cachedEntries = cachedEntries) !== null && _cachedEntries !== void 0 ? _cachedEntries : Object.entries(this.entries);
989
- var typed = true;
990
- var issues;
991
- var output = {};
992
- var _iterator16 = _createForOfIteratorHelper(cachedEntries),
993
- _step16;
994
- try {
995
- for (_iterator16.s(); !(_step16 = _iterator16.n()).done;) {
996
- var _step16$value = _slicedToArray(_step16.value, 2),
997
- _key = _step16$value[0],
998
- schema = _step16$value[1];
999
- var _value = input[_key];
1000
- var _result3 = schema._parse(_value, config);
1001
- if (_result3.issues) {
1002
- var _pathItem3 = {
993
+ dataset.typed = true;
994
+ dataset.value = {};
995
+ for (var key in this.entries) {
996
+ var valueSchema = this.entries[key];
997
+ if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") &&
998
+ // @ts-expect-error
999
+ valueSchema["default"] !== void 0) {
1000
+ var value2 = key in input ?
1001
+ // @ts-expect-error
1002
+ input[key] : getDefault(valueSchema);
1003
+ var valueDataset = valueSchema["~run"]({
1004
+ value: value2
1005
+ }, config2);
1006
+ if (valueDataset.issues) {
1007
+ var pathItem = {
1003
1008
  type: "object",
1004
1009
  origin: "value",
1005
1010
  input: input,
1006
- key: _key,
1007
- value: _value
1011
+ key: key,
1012
+ value: value2
1008
1013
  };
1009
- var _iterator18 = _createForOfIteratorHelper(_result3.issues),
1010
- _step18;
1014
+ var _iterator28 = _createForOfIteratorHelper(valueDataset.issues),
1015
+ _step28;
1011
1016
  try {
1012
- for (_iterator18.s(); !(_step18 = _iterator18.n()).done;) {
1013
- var _issues7;
1014
- var _issue2 = _step18.value;
1015
- if (_issue2.path) {
1016
- _issue2.path.unshift(_pathItem3);
1017
+ for (_iterator28.s(); !(_step28 = _iterator28.n()).done;) {
1018
+ var _dataset$issues11;
1019
+ var issue = _step28.value;
1020
+ if (issue.path) {
1021
+ issue.path.unshift(pathItem);
1017
1022
  } else {
1018
- _issue2.path = [_pathItem3];
1023
+ issue.path = [pathItem];
1019
1024
  }
1020
- (_issues7 = issues) === null || _issues7 === void 0 || _issues7.push(_issue2);
1025
+ (_dataset$issues11 = dataset.issues) === null || _dataset$issues11 === void 0 || _dataset$issues11.push(issue);
1021
1026
  }
1022
1027
  } catch (err) {
1023
- _iterator18.e(err);
1028
+ _iterator28.e(err);
1024
1029
  } finally {
1025
- _iterator18.f();
1030
+ _iterator28.f();
1026
1031
  }
1027
- if (!issues) {
1028
- issues = _result3.issues;
1032
+ if (!dataset.issues) {
1033
+ dataset.issues = valueDataset.issues;
1029
1034
  }
1030
- if (config !== null && config !== void 0 && config.abortEarly) {
1031
- typed = false;
1035
+ if (config2.abortEarly) {
1036
+ dataset.typed = false;
1032
1037
  break;
1033
1038
  }
1034
1039
  }
1035
- if (!_result3.typed) {
1036
- typed = false;
1037
- }
1038
- if (_result3.output !== void 0 || _key in input) {
1039
- output[_key] = _result3.output;
1040
+ if (!valueDataset.typed) {
1041
+ dataset.typed = false;
1040
1042
  }
1041
- }
1042
- } catch (err) {
1043
- _iterator16.e(err);
1044
- } finally {
1045
- _iterator16.f();
1046
- }
1047
- if (this.rest && !(config !== null && config !== void 0 && config.abortEarly && issues)) {
1048
- for (var key in input) {
1049
- if (!(key in this.entries)) {
1050
- var value2 = input[key];
1051
- var result = this.rest._parse(value2, config);
1052
- if (result.issues) {
1053
- var pathItem = {
1054
- type: "object",
1055
- origin: "value",
1056
- input: input,
1057
- key: key,
1058
- value: value2
1059
- };
1060
- var _iterator17 = _createForOfIteratorHelper(result.issues),
1061
- _step17;
1062
- try {
1063
- for (_iterator17.s(); !(_step17 = _iterator17.n()).done;) {
1064
- var _issues6;
1065
- var issue = _step17.value;
1066
- if (issue.path) {
1067
- issue.path.unshift(pathItem);
1068
- } else {
1069
- issue.path = [pathItem];
1070
- }
1071
- (_issues6 = issues) === null || _issues6 === void 0 || _issues6.push(issue);
1072
- }
1073
- } catch (err) {
1074
- _iterator17.e(err);
1075
- } finally {
1076
- _iterator17.f();
1077
- }
1078
- if (!issues) {
1079
- issues = result.issues;
1080
- }
1081
- if (config !== null && config !== void 0 && config.abortEarly) {
1082
- typed = false;
1083
- break;
1084
- }
1085
- }
1086
- if (!result.typed) {
1087
- typed = false;
1088
- }
1089
- output[key] = result.output;
1043
+ dataset.value[key] = valueDataset.value;
1044
+ } else if (valueSchema.fallback !== void 0) {
1045
+ dataset.value[key] = getFallback(valueSchema);
1046
+ } else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
1047
+ _addIssue(this, "key", dataset, config2, {
1048
+ input: void 0,
1049
+ expected: "\"".concat(key, "\""),
1050
+ path: [{
1051
+ type: "object",
1052
+ origin: "key",
1053
+ input: input,
1054
+ key: key,
1055
+ // @ts-expect-error
1056
+ value: input[key]
1057
+ }]
1058
+ });
1059
+ if (config2.abortEarly) {
1060
+ break;
1090
1061
  }
1091
1062
  }
1092
1063
  }
1093
- if (typed) {
1094
- return pipeResult(this, output, config, issues);
1095
- }
1096
- return schemaResult(false, output, issues);
1064
+ } else {
1065
+ _addIssue(this, "type", dataset, config2);
1097
1066
  }
1098
- return schemaIssue(this, object, input, config);
1067
+ return dataset;
1099
1068
  }
1100
1069
  };
1101
1070
  }
1102
1071
 
1103
1072
  // src/schemas/optional/optional.ts
1073
+ // @__NO_SIDE_EFFECTS__
1104
1074
  function optional(wrapped, default_) {
1105
1075
  return {
1076
+ kind: "schema",
1106
1077
  type: "optional",
1107
- expects: "".concat(wrapped.expects, " | undefined"),
1078
+ reference: optional,
1079
+ expects: "(".concat(wrapped.expects, " | undefined)"),
1108
1080
  async: false,
1109
1081
  wrapped: wrapped,
1110
1082
  "default": default_,
1111
- _parse: function _parse(input, config) {
1112
- if (input === void 0) {
1113
- var override = getDefault(this);
1114
- if (override === void 0) {
1115
- return schemaResult(true, input);
1083
+ get "~standard"() {
1084
+ return _getStandardProps(this);
1085
+ },
1086
+ "~run": function run(dataset, config2) {
1087
+ if (dataset.value === void 0) {
1088
+ if (this["default"] !== void 0) {
1089
+ dataset.value = getDefault(this, dataset, config2);
1090
+ }
1091
+ if (dataset.value === void 0) {
1092
+ dataset.typed = true;
1093
+ return dataset;
1116
1094
  }
1117
- input = override;
1118
- }
1119
- return this.wrapped._parse(input, config);
1120
- }
1121
- };
1122
- }
1123
-
1124
- // src/schemas/string/string.ts
1125
- function string(arg1, arg2) {
1126
- var _defaultArgs41 = defaultArgs(arg1, arg2),
1127
- _defaultArgs42 = _slicedToArray(_defaultArgs41, 2),
1128
- message = _defaultArgs42[0],
1129
- pipe = _defaultArgs42[1];
1130
- return {
1131
- type: "string",
1132
- expects: "string",
1133
- async: false,
1134
- message: message,
1135
- pipe: pipe,
1136
- _parse: function _parse(input, config) {
1137
- if (typeof input === "string") {
1138
- return pipeResult(this, input, config);
1139
1095
  }
1140
- return schemaIssue(this, string, input, config);
1096
+ return this.wrapped["~run"](dataset, config2);
1141
1097
  }
1142
1098
  };
1143
1099
  }
1144
1100
 
1145
- // src/schemas/record/utils/recordArgs/recordArgs.ts
1146
- function recordArgs(arg1, arg2, arg3, arg4) {
1147
- if (_typeof(arg2) === "object" && !Array.isArray(arg2)) {
1148
- var _defaultArgs45 = defaultArgs(arg3, arg4),
1149
- _defaultArgs46 = _slicedToArray(_defaultArgs45, 2),
1150
- message2 = _defaultArgs46[0],
1151
- pipe2 = _defaultArgs46[1];
1152
- return [arg1, arg2, message2, pipe2];
1153
- }
1154
- var _defaultArgs47 = defaultArgs(arg2, arg3),
1155
- _defaultArgs48 = _slicedToArray(_defaultArgs47, 2),
1156
- message = _defaultArgs48[0],
1157
- pipe = _defaultArgs48[1];
1158
- return [string(), arg1, message, pipe];
1159
- }
1160
-
1161
- // src/schemas/record/values.ts
1162
- var BLOCKED_KEYS = ["__proto__", "prototype", "constructor"];
1163
-
1164
1101
  // src/schemas/record/record.ts
1165
- function record(arg1, arg2, arg3, arg4) {
1166
- var _recordArgs = recordArgs(arg1, arg2, arg3, arg4),
1167
- _recordArgs2 = _slicedToArray(_recordArgs, 4),
1168
- key = _recordArgs2[0],
1169
- value2 = _recordArgs2[1],
1170
- message = _recordArgs2[2],
1171
- pipe = _recordArgs2[3];
1102
+ // @__NO_SIDE_EFFECTS__
1103
+ function record(key, value2, message2) {
1172
1104
  return {
1105
+ kind: "schema",
1173
1106
  type: "record",
1107
+ reference: record,
1174
1108
  expects: "Object",
1175
1109
  async: false,
1176
1110
  key: key,
1177
1111
  value: value2,
1178
- message: message,
1179
- pipe: pipe,
1180
- _parse: function _parse(input, config) {
1112
+ message: message2,
1113
+ get "~standard"() {
1114
+ return _getStandardProps(this);
1115
+ },
1116
+ "~run": function run(dataset, config2) {
1117
+ var input = dataset.value;
1181
1118
  if (input && _typeof(input) === "object") {
1182
- var typed = true;
1183
- var issues;
1184
- var output = {};
1185
- for (var _i = 0, _Object$entries = Object.entries(input); _i < _Object$entries.length; _i++) {
1186
- var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
1187
- inputKey = _Object$entries$_i[0],
1188
- inputValue = _Object$entries$_i[1];
1189
- if (!BLOCKED_KEYS.includes(inputKey)) {
1190
- var pathItem = void 0;
1191
- var keyResult = this.key._parse(inputKey, config);
1192
- if (keyResult.issues) {
1193
- pathItem = {
1194
- type: "record",
1119
+ dataset.typed = true;
1120
+ dataset.value = {};
1121
+ for (var entryKey in input) {
1122
+ if (_isValidObjectKey(input, entryKey)) {
1123
+ var entryValue = input[entryKey];
1124
+ var keyDataset = this.key["~run"]({
1125
+ value: entryKey
1126
+ }, config2);
1127
+ if (keyDataset.issues) {
1128
+ var pathItem = {
1129
+ type: "object",
1195
1130
  origin: "key",
1196
1131
  input: input,
1197
- key: inputKey,
1198
- value: inputValue
1132
+ key: entryKey,
1133
+ value: entryValue
1199
1134
  };
1200
- var _iterator21 = _createForOfIteratorHelper(keyResult.issues),
1201
- _step21;
1135
+ var _iterator37 = _createForOfIteratorHelper(keyDataset.issues),
1136
+ _step37;
1202
1137
  try {
1203
- for (_iterator21.s(); !(_step21 = _iterator21.n()).done;) {
1204
- var _issues10;
1205
- var issue = _step21.value;
1138
+ for (_iterator37.s(); !(_step37 = _iterator37.n()).done;) {
1139
+ var _dataset$issues17;
1140
+ var issue = _step37.value;
1206
1141
  issue.path = [pathItem];
1207
- (_issues10 = issues) === null || _issues10 === void 0 || _issues10.push(issue);
1142
+ (_dataset$issues17 = dataset.issues) === null || _dataset$issues17 === void 0 || _dataset$issues17.push(issue);
1208
1143
  }
1209
1144
  } catch (err) {
1210
- _iterator21.e(err);
1145
+ _iterator37.e(err);
1211
1146
  } finally {
1212
- _iterator21.f();
1147
+ _iterator37.f();
1213
1148
  }
1214
- if (!issues) {
1215
- issues = keyResult.issues;
1149
+ if (!dataset.issues) {
1150
+ dataset.issues = keyDataset.issues;
1216
1151
  }
1217
- if (config !== null && config !== void 0 && config.abortEarly) {
1218
- typed = false;
1152
+ if (config2.abortEarly) {
1153
+ dataset.typed = false;
1219
1154
  break;
1220
1155
  }
1221
1156
  }
1222
- var valueResult = this.value._parse(inputValue, config);
1223
- if (valueResult.issues) {
1224
- var _pathItem4;
1225
- pathItem = (_pathItem4 = pathItem) !== null && _pathItem4 !== void 0 ? _pathItem4 : {
1226
- type: "record",
1157
+ var valueDataset = this.value["~run"]({
1158
+ value: entryValue
1159
+ }, config2);
1160
+ if (valueDataset.issues) {
1161
+ var _pathItem5 = {
1162
+ type: "object",
1227
1163
  origin: "value",
1228
1164
  input: input,
1229
- key: inputKey,
1230
- value: inputValue
1165
+ key: entryKey,
1166
+ value: entryValue
1231
1167
  };
1232
- var _iterator22 = _createForOfIteratorHelper(valueResult.issues),
1233
- _step22;
1168
+ var _iterator38 = _createForOfIteratorHelper(valueDataset.issues),
1169
+ _step38;
1234
1170
  try {
1235
- for (_iterator22.s(); !(_step22 = _iterator22.n()).done;) {
1236
- var _issues11;
1237
- var _issue3 = _step22.value;
1238
- if (_issue3.path) {
1239
- _issue3.path.unshift(pathItem);
1171
+ for (_iterator38.s(); !(_step38 = _iterator38.n()).done;) {
1172
+ var _dataset$issues18;
1173
+ var _issue5 = _step38.value;
1174
+ if (_issue5.path) {
1175
+ _issue5.path.unshift(_pathItem5);
1240
1176
  } else {
1241
- _issue3.path = [pathItem];
1177
+ _issue5.path = [_pathItem5];
1242
1178
  }
1243
- (_issues11 = issues) === null || _issues11 === void 0 || _issues11.push(_issue3);
1179
+ (_dataset$issues18 = dataset.issues) === null || _dataset$issues18 === void 0 || _dataset$issues18.push(_issue5);
1244
1180
  }
1245
1181
  } catch (err) {
1246
- _iterator22.e(err);
1182
+ _iterator38.e(err);
1247
1183
  } finally {
1248
- _iterator22.f();
1184
+ _iterator38.f();
1249
1185
  }
1250
- if (!issues) {
1251
- issues = valueResult.issues;
1186
+ if (!dataset.issues) {
1187
+ dataset.issues = valueDataset.issues;
1252
1188
  }
1253
- if (config !== null && config !== void 0 && config.abortEarly) {
1254
- typed = false;
1189
+ if (config2.abortEarly) {
1190
+ dataset.typed = false;
1255
1191
  break;
1256
1192
  }
1257
1193
  }
1258
- if (!keyResult.typed || !valueResult.typed) {
1259
- typed = false;
1194
+ if (!keyDataset.typed || !valueDataset.typed) {
1195
+ dataset.typed = false;
1260
1196
  }
1261
- if (keyResult.typed) {
1262
- output[keyResult.output] = valueResult.output;
1197
+ if (keyDataset.typed) {
1198
+ dataset.value[keyDataset.value] = valueDataset.value;
1263
1199
  }
1264
1200
  }
1265
1201
  }
1266
- if (typed) {
1267
- return pipeResult(this, output, config, issues);
1268
- }
1269
- return schemaResult(false, output, issues);
1202
+ } else {
1203
+ _addIssue(this, "type", dataset, config2);
1204
+ }
1205
+ return dataset;
1206
+ }
1207
+ };
1208
+ }
1209
+
1210
+ // src/schemas/string/string.ts
1211
+ // @__NO_SIDE_EFFECTS__
1212
+ function string(message2) {
1213
+ return {
1214
+ kind: "schema",
1215
+ type: "string",
1216
+ reference: string,
1217
+ expects: "string",
1218
+ async: false,
1219
+ message: message2,
1220
+ get "~standard"() {
1221
+ return _getStandardProps(this);
1222
+ },
1223
+ "~run": function run(dataset, config2) {
1224
+ if (typeof dataset.value === "string") {
1225
+ dataset.typed = true;
1226
+ } else {
1227
+ _addIssue(this, "type", dataset, config2);
1270
1228
  }
1271
- return schemaIssue(this, record, input, config);
1229
+ return dataset;
1272
1230
  }
1273
1231
  };
1274
1232
  }
1275
1233
 
1276
- // src/schemas/union/utils/subissues/subissues.ts
1277
- function subissues(results) {
1234
+ // src/schemas/union/utils/_subIssues/_subIssues.ts
1235
+ // @__NO_SIDE_EFFECTS__
1236
+ function _subIssues(datasets) {
1278
1237
  var issues;
1279
- if (results) {
1280
- var _iterator31 = _createForOfIteratorHelper(results),
1281
- _step31;
1238
+ if (datasets) {
1239
+ var _iterator61 = _createForOfIteratorHelper(datasets),
1240
+ _step61;
1282
1241
  try {
1283
- for (_iterator31.s(); !(_step31 = _iterator31.n()).done;) {
1284
- var result = _step31.value;
1242
+ for (_iterator61.s(); !(_step61 = _iterator61.n()).done;) {
1243
+ var dataset = _step61.value;
1285
1244
  if (issues) {
1286
- var _iterator32 = _createForOfIteratorHelper(result.issues),
1287
- _step32;
1288
- try {
1289
- for (_iterator32.s(); !(_step32 = _iterator32.n()).done;) {
1290
- var issue = _step32.value;
1291
- issues.push(issue);
1292
- }
1293
- } catch (err) {
1294
- _iterator32.e(err);
1295
- } finally {
1296
- _iterator32.f();
1297
- }
1245
+ var _issues;
1246
+ (_issues = issues).push.apply(_issues, _toConsumableArray(dataset.issues));
1298
1247
  } else {
1299
- issues = result.issues;
1248
+ issues = dataset.issues;
1300
1249
  }
1301
1250
  }
1302
1251
  } catch (err) {
1303
- _iterator31.e(err);
1252
+ _iterator61.e(err);
1304
1253
  } finally {
1305
- _iterator31.f();
1254
+ _iterator61.f();
1306
1255
  }
1307
1256
  }
1308
1257
  return issues;
1309
1258
  }
1310
1259
 
1311
1260
  // src/schemas/union/union.ts
1312
- function union(options, arg2, arg3) {
1313
- var _defaultArgs57 = defaultArgs(arg2, arg3),
1314
- _defaultArgs58 = _slicedToArray(_defaultArgs57, 2),
1315
- message = _defaultArgs58[0],
1316
- pipe = _defaultArgs58[1];
1261
+ // @__NO_SIDE_EFFECTS__
1262
+ function union(options, message2) {
1317
1263
  return {
1264
+ kind: "schema",
1318
1265
  type: "union",
1319
- expects: _toConsumableArray(new Set(options.map(function (option) {
1266
+ reference: union,
1267
+ expects: _joinExpects(options.map(function (option) {
1320
1268
  return option.expects;
1321
- }))).join(" | "),
1269
+ }), "|"),
1322
1270
  async: false,
1323
1271
  options: options,
1324
- message: message,
1325
- pipe: pipe,
1326
- _parse: function _parse(input, config) {
1327
- var _typedResults, _untypedResults;
1328
- var validResult;
1329
- var untypedResults;
1330
- var typedResults;
1331
- var _iterator33 = _createForOfIteratorHelper(this.options),
1332
- _step33;
1272
+ message: message2,
1273
+ get "~standard"() {
1274
+ return _getStandardProps(this);
1275
+ },
1276
+ "~run": function run(dataset, config2) {
1277
+ var _untypedDatasets;
1278
+ var validDataset;
1279
+ var typedDatasets;
1280
+ var untypedDatasets;
1281
+ var _iterator62 = _createForOfIteratorHelper(this.options),
1282
+ _step62;
1333
1283
  try {
1334
- for (_iterator33.s(); !(_step33 = _iterator33.n()).done;) {
1335
- var schema = _step33.value;
1336
- var result = schema._parse(input, config);
1337
- if (result.typed) {
1338
- if (!result.issues) {
1339
- validResult = result;
1340
- break;
1284
+ for (_iterator62.s(); !(_step62 = _iterator62.n()).done;) {
1285
+ var schema = _step62.value;
1286
+ var optionDataset = schema["~run"]({
1287
+ value: dataset.value
1288
+ }, config2);
1289
+ if (optionDataset.typed) {
1290
+ if (optionDataset.issues) {
1291
+ if (typedDatasets) {
1292
+ typedDatasets.push(optionDataset);
1293
+ } else {
1294
+ typedDatasets = [optionDataset];
1295
+ }
1341
1296
  } else {
1342
- typedResults ? typedResults.push(result) : typedResults = [result];
1297
+ validDataset = optionDataset;
1298
+ break;
1343
1299
  }
1344
1300
  } else {
1345
- untypedResults ? untypedResults.push(result) : untypedResults = [result];
1301
+ if (untypedDatasets) {
1302
+ untypedDatasets.push(optionDataset);
1303
+ } else {
1304
+ untypedDatasets = [optionDataset];
1305
+ }
1346
1306
  }
1347
1307
  }
1348
1308
  } catch (err) {
1349
- _iterator33.e(err);
1309
+ _iterator62.e(err);
1350
1310
  } finally {
1351
- _iterator33.f();
1311
+ _iterator62.f();
1352
1312
  }
1353
- if (validResult) {
1354
- return pipeResult(this, validResult.output, config);
1313
+ if (validDataset) {
1314
+ return validDataset;
1355
1315
  }
1356
- if ((_typedResults = typedResults) !== null && _typedResults !== void 0 && _typedResults.length) {
1357
- var firstResult = typedResults[0];
1358
- return pipeResult(this, firstResult.output, config,
1359
- // Hint: If there is more than one typed result, we use a general
1360
- // union issue with subissues because the issues could contradict
1361
- // each other.
1362
- typedResults.length === 1 ? firstResult.issues : schemaIssue(this, union, input, config, {
1363
- reason: "union",
1364
- issues: subissues(typedResults)
1365
- }).issues);
1366
- }
1367
- if (((_untypedResults = untypedResults) === null || _untypedResults === void 0 ? void 0 : _untypedResults.length) === 1) {
1368
- return untypedResults[0];
1316
+ if (typedDatasets) {
1317
+ if (typedDatasets.length === 1) {
1318
+ return typedDatasets[0];
1319
+ }
1320
+ _addIssue(this, "type", dataset, config2, {
1321
+ issues: _subIssues(typedDatasets)
1322
+ });
1323
+ dataset.typed = true;
1324
+ } else if (((_untypedDatasets = untypedDatasets) === null || _untypedDatasets === void 0 ? void 0 : _untypedDatasets.length) === 1) {
1325
+ return untypedDatasets[0];
1326
+ } else {
1327
+ _addIssue(this, "type", dataset, config2, {
1328
+ issues: _subIssues(untypedDatasets)
1329
+ });
1369
1330
  }
1370
- return schemaIssue(this, union, input, config, {
1371
- issues: subissues(untypedResults)
1372
- });
1331
+ return dataset;
1373
1332
  }
1374
1333
  };
1375
1334
  }
1376
1335
 
1377
1336
  // src/schemas/unknown/unknown.ts
1378
- function unknown(pipe) {
1337
+ // @__NO_SIDE_EFFECTS__
1338
+ function unknown() {
1379
1339
  return {
1340
+ kind: "schema",
1380
1341
  type: "unknown",
1342
+ reference: unknown,
1381
1343
  expects: "unknown",
1382
1344
  async: false,
1383
- pipe: pipe,
1384
- _parse: function _parse(input, config) {
1385
- return pipeResult(this, input, config);
1345
+ get "~standard"() {
1346
+ return _getStandardProps(this);
1347
+ },
1348
+ "~run": function run(dataset) {
1349
+ dataset.typed = true;
1350
+ return dataset;
1386
1351
  }
1387
1352
  };
1388
1353
  }
1389
1354
 
1390
1355
  // src/methods/omit/omit.ts
1391
- function omit(schema, keys, arg3, arg4, arg5) {
1392
- var _restAndDefaultArgs13 = restAndDefaultArgs(arg3, arg4, arg5),
1393
- _restAndDefaultArgs14 = _slicedToArray(_restAndDefaultArgs13, 3),
1394
- rest = _restAndDefaultArgs14[0],
1395
- message = _restAndDefaultArgs14[1],
1396
- pipe = _restAndDefaultArgs14[2];
1397
- return object(Object.entries(schema.entries).reduce(function (entries, _ref33) {
1398
- var _ref34 = _slicedToArray(_ref33, 2),
1399
- key = _ref34[0],
1400
- schema2 = _ref34[1];
1401
- return keys.includes(key) ? entries : _objectSpread2(_objectSpread2({}, entries), {}, _defineProperty({}, key, schema2));
1402
- }, {}), rest, message, pipe);
1356
+ // @__NO_SIDE_EFFECTS__
1357
+ function omit(schema, keys) {
1358
+ var entries2 = _objectSpread2({}, schema.entries);
1359
+ var _iterator68 = _createForOfIteratorHelper(keys),
1360
+ _step68;
1361
+ try {
1362
+ for (_iterator68.s(); !(_step68 = _iterator68.n()).done;) {
1363
+ var key = _step68.value;
1364
+ delete entries2[key];
1365
+ }
1366
+ } catch (err) {
1367
+ _iterator68.e(err);
1368
+ } finally {
1369
+ _iterator68.f();
1370
+ }
1371
+ return _objectSpread2(_objectSpread2({}, schema), {}, {
1372
+ entries: entries2,
1373
+ get "~standard"() {
1374
+ return _getStandardProps(this);
1375
+ }
1376
+ });
1403
1377
  }
1404
1378
 
1405
1379
  // src/methods/parse/parse.ts
1406
- function parse(schema, input, config) {
1407
- var result = schema._parse(input, getGlobalConfig(config));
1408
- if (result.issues) {
1409
- throw new ValiError(result.issues);
1380
+ function parse(schema, input, config2) {
1381
+ var dataset = schema["~run"]({
1382
+ value: input
1383
+ }, getGlobalConfig(config2));
1384
+ if (dataset.issues) {
1385
+ throw new ValiError(dataset.issues);
1410
1386
  }
1411
- return result.output;
1387
+ return dataset.value;
1412
1388
  }
1413
1389
 
1414
- // src/methods/safeParse/safeParse.ts
1415
- function safeParse(schema, input, config) {
1416
- var result = schema._parse(input, getGlobalConfig(config));
1417
- return {
1418
- typed: result.typed,
1419
- success: !result.issues,
1420
- output: result.output,
1421
- issues: result.issues
1422
- };
1423
- }
1424
-
1425
- // src/validations/custom/custom.ts
1426
- function custom(requirement, message) {
1427
- return {
1428
- type: "custom",
1429
- expects: null,
1430
- async: false,
1431
- message: message,
1432
- requirement: requirement,
1433
- _parse: function _parse(input) {
1434
- if (this.requirement(input)) {
1435
- return actionOutput(input);
1436
- }
1437
- return actionIssue(this, custom, input, "input");
1438
- }
1439
- };
1440
- }
1441
-
1442
- // src/validations/notValue/notValue.ts
1443
- function notValue(requirement, message) {
1444
- return {
1445
- type: "not_value",
1446
- expects: "!".concat(requirement instanceof Date ? requirement.toJSON() : stringify(requirement)),
1447
- async: false,
1448
- message: message,
1449
- requirement: requirement,
1450
- _parse: function _parse(input) {
1451
- if (input < this.requirement || input > this.requirement) {
1452
- return actionOutput(input);
1390
+ // src/methods/pipe/pipe.ts
1391
+ // @__NO_SIDE_EFFECTS__
1392
+ function pipe() {
1393
+ for (var _len3 = arguments.length, pipe2 = new Array(_len3), _key11 = 0; _key11 < _len3; _key11++) {
1394
+ pipe2[_key11] = arguments[_key11];
1395
+ }
1396
+ return _objectSpread2(_objectSpread2({}, pipe2[0]), {}, {
1397
+ pipe: pipe2,
1398
+ get "~standard"() {
1399
+ return _getStandardProps(this);
1400
+ },
1401
+ "~run": function run(dataset, config2) {
1402
+ for (var _i2 = 0, _pipe = pipe2; _i2 < _pipe.length; _i2++) {
1403
+ var item = _pipe[_i2];
1404
+ if (item.kind !== "metadata") {
1405
+ if (dataset.issues && (item.kind === "schema" || item.kind === "transformation")) {
1406
+ dataset.typed = false;
1407
+ break;
1408
+ }
1409
+ if (!dataset.issues || !config2.abortEarly && !config2.abortPipeEarly) {
1410
+ dataset = item["~run"](dataset, config2);
1411
+ }
1412
+ }
1453
1413
  }
1454
- return actionIssue(this, notValue, input, "value", input instanceof Date ? input.toJSON() : stringify(input));
1414
+ return dataset;
1455
1415
  }
1456
- };
1416
+ });
1457
1417
  }
1458
1418
 
1459
- // src/validations/regex/regex.ts
1460
- function regex(requirement, message) {
1419
+ // src/methods/safeParse/safeParse.ts
1420
+ // @__NO_SIDE_EFFECTS__
1421
+ function safeParse(schema, input, config2) {
1422
+ var dataset = schema["~run"]({
1423
+ value: input
1424
+ }, getGlobalConfig(config2));
1461
1425
  return {
1462
- type: "regex",
1463
- expects: "".concat(requirement),
1464
- async: false,
1465
- message: message,
1466
- requirement: requirement,
1467
- _parse: function _parse(input) {
1468
- if (this.requirement.test(input)) {
1469
- return actionOutput(input);
1470
- }
1471
- return actionIssue(this, regex, input, "format");
1472
- }
1426
+ typed: dataset.typed,
1427
+ success: !dataset.issues,
1428
+ output: dataset.value,
1429
+ issues: dataset.issues
1473
1430
  };
1474
1431
  }
1475
1432
 
@@ -1514,7 +1471,7 @@
1514
1471
  });
1515
1472
  const ZRawApiResponse = union([
1516
1473
  object({ chat: ZApiChat }),
1517
- record(string([notValue("chat")]), unknown()),
1474
+ record(pipe(string(), notValue("chat")), unknown()),
1518
1475
  ]);
1519
1476
  const ZApiPing = object({
1520
1477
  content: string(),
@@ -1603,11 +1560,6 @@
1603
1560
  literal("gulim"),
1604
1561
  literal("simsun"),
1605
1562
  ]);
1606
- union([
1607
- literal("defont"),
1608
- literal("mincho"),
1609
- literal("gothic"),
1610
- ]);
1611
1563
  const ZCommentFlashFont = union([
1612
1564
  literal("defont"),
1613
1565
  literal("gulim"),
@@ -1754,17 +1706,15 @@
1754
1706
  chatItem: (i) => is(ZXml2jsChatItem, i),
1755
1707
  },
1756
1708
  legacyOwner: {
1757
- comments: (i) => is(string([
1758
- custom((i) => {
1759
- const lists = i.split(/\r\n|\r|\n/);
1760
- for (const list of lists) {
1761
- if (list.split(":").length < 3) {
1762
- return false;
1763
- }
1709
+ comments: (i) => is(pipe(string(), check((i) => {
1710
+ const lists = i.split(/\r\n|\r|\n/);
1711
+ for (const list of lists) {
1712
+ if (list.split(":").length < 3) {
1713
+ return false;
1764
1714
  }
1765
- return true;
1766
- }),
1767
- ]), i),
1715
+ }
1716
+ return true;
1717
+ })), i),
1768
1718
  },
1769
1719
  owner: {
1770
1720
  comment: (i) => is(ZOwnerComment, i),
@@ -1798,11 +1748,9 @@
1798
1748
  literal("invisible"),
1799
1749
  ]), i),
1800
1750
  },
1801
- color: (i) => is(string([custom((i) => Object.keys(colors).includes(i))]), i),
1802
- colorCode: (i) => is(string([regex(/^#(?:[0-9a-fA-F]{3,4}|[0-9a-fA-F]{6})$/)]), i),
1803
- colorCodeAllowAlpha: (i) => is(string([
1804
- regex(/^#(?:[0-9a-fA-F]{3,4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/),
1805
- ]), i),
1751
+ color: (i) => is(pipe(string(), check((i) => Object.keys(colors).includes(i))), i),
1752
+ colorCode: (i) => is(pipe(string(), regex(/^#(?:[0-9a-fA-F]{3,4}|[0-9a-fA-F]{6})$/)), i),
1753
+ colorCodeAllowAlpha: (i) => is(pipe(string(), regex(/^#(?:[0-9a-fA-F]{3,4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/)), i),
1806
1754
  },
1807
1755
  config: {
1808
1756
  initOptions: (item) => {
@@ -1957,6 +1905,7 @@
1957
1905
  strokeColor: commands.strokeColor,
1958
1906
  wakuColor: commands.wakuColor,
1959
1907
  fillColor: commands.fillColor,
1908
+ opacity: commands.opacity,
1960
1909
  button: commands.button,
1961
1910
  };
1962
1911
  };
@@ -2080,15 +2029,16 @@
2080
2029
  };
2081
2030
  const processReverseScript = (comment, commands) => {
2082
2031
  const reverse = RegExp(/^[@\uff20]\u9006(?:\s+)?(\u5168|\u30b3\u30e1|\u6295\u30b3\u30e1)?/).exec(comment.content);
2083
- if (!reverse?.[1] || !typeGuard.nicoScript.range.target(reverse[1]))
2084
- return;
2032
+ const target = typeGuard.nicoScript.range.target(reverse?.[1])
2033
+ ? reverse?.[1]
2034
+ : "全";
2085
2035
  if (commands.long === undefined) {
2086
2036
  commands.long = 30;
2087
2037
  }
2088
2038
  nicoScripts.reverse.unshift({
2089
2039
  start: comment.vpos,
2090
2040
  end: comment.vpos + commands.long * 100,
2091
- target: reverse[1],
2041
+ target,
2092
2042
  });
2093
2043
  };
2094
2044
  const processBanScript = (comment, commands) => {
@@ -2113,9 +2063,12 @@
2113
2063
  const options = RegExp(/\s*((?:sm|so|nm|\uff53\uff4d|\uff53\uff4f|\uff4e\uff4d)?[1-9\uff11-\uff19][0-9\uff11-\uff19]*|#[0-9]+:[0-9]+(?:\.[0-9]+)?)\s+(.*)/).exec(input);
2114
2064
  if (!options?.[1])
2115
2065
  return;
2066
+ const end = commands.long === undefined
2067
+ ? undefined
2068
+ : commands.long * 100 + comment.vpos;
2116
2069
  nicoScripts.jump.unshift({
2117
2070
  start: comment.vpos,
2118
- end: commands.long === undefined ? undefined : commands.long * 100,
2071
+ end,
2119
2072
  to: options[1],
2120
2073
  message: options[2],
2121
2074
  });
@@ -2188,6 +2141,11 @@
2188
2141
  result.fillColor ??= fillColor;
2189
2142
  return;
2190
2143
  }
2144
+ const opacity = getOpacity(RegExp(/^nico:opacity:(.+)$/).exec(command));
2145
+ if (typeof opacity === "number") {
2146
+ result.opacity ??= opacity;
2147
+ return;
2148
+ }
2191
2149
  if (is(ZCommentLoc, command)) {
2192
2150
  result.loc ??= command;
2193
2151
  return;
@@ -2226,6 +2184,15 @@
2226
2184
  }
2227
2185
  return;
2228
2186
  };
2187
+ const getOpacity = (match) => {
2188
+ if (!match)
2189
+ return;
2190
+ const value = Number(match[1]);
2191
+ if (!Number.isNaN(value) && value >= 0) {
2192
+ return value;
2193
+ }
2194
+ return;
2195
+ };
2229
2196
  const isFlashComment = (comment) => options.mode === "flash" ||
2230
2197
  (options.mode === "default" &&
2231
2198
  !(comment.mail.includes("gothic") ||
@@ -2428,11 +2395,13 @@
2428
2395
  comment.mail.includes("patissier") ||
2429
2396
  comment.mail.includes("ender") ||
2430
2397
  comment.mail.includes("full")) {
2431
- userScoreList[comment.user_id] += 5;
2398
+ userScoreList[comment.user_id] =
2399
+ (userScoreList[comment.user_id] ?? 0) + 5;
2432
2400
  }
2433
2401
  const lineCount = (comment.content.match(/\r\n|\n|\r/g) ?? []).length;
2434
2402
  if (lineCount > 2) {
2435
- userScoreList[comment.user_id] += lineCount / 2;
2403
+ userScoreList[comment.user_id] =
2404
+ (userScoreList[comment.user_id] ?? 0) + lineCount / 2;
2436
2405
  }
2437
2406
  }
2438
2407
  return userScoreList;
@@ -3039,7 +3008,10 @@
3039
3008
  }
3040
3009
  if (this.image) {
3041
3010
  this.renderer.save();
3042
- if (this.comment._live) {
3011
+ if (typeof this.comment.opacity === "number") {
3012
+ this.renderer.setGlobalAlpha(this.comment.opacity);
3013
+ }
3014
+ else if (this.comment._live) {
3043
3015
  this.renderer.setGlobalAlpha(config.contextFillLiveOpacity);
3044
3016
  }
3045
3017
  else {
@@ -4660,6 +4632,7 @@
4660
4632
  this.context = context;
4661
4633
  this.context.textAlign = "start";
4662
4634
  this.context.textBaseline = "alphabetic";
4635
+ this.context.lineJoin = "round";
4663
4636
  this.video = video;
4664
4637
  }
4665
4638
  drawVideo(enableLegacyPip) {