@arcblock/did-connect-js 1.29.27 → 1.30.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,736 @@
1
+ //#region ../../node_modules/valibot/dist/index.mjs
2
+ let store$4;
3
+ /**
4
+ * Returns the global configuration.
5
+ *
6
+ * @param config The config to merge.
7
+ *
8
+ * @returns The configuration.
9
+ */
10
+ /* @__NO_SIDE_EFFECTS__ */
11
+ function getGlobalConfig(config$1) {
12
+ return {
13
+ lang: config$1?.lang ?? store$4?.lang,
14
+ message: config$1?.message,
15
+ abortEarly: config$1?.abortEarly ?? store$4?.abortEarly,
16
+ abortPipeEarly: config$1?.abortPipeEarly ?? store$4?.abortPipeEarly
17
+ };
18
+ }
19
+ let store$3;
20
+ /**
21
+ * Returns a global error message.
22
+ *
23
+ * @param lang The language of the message.
24
+ *
25
+ * @returns The error message.
26
+ */
27
+ /* @__NO_SIDE_EFFECTS__ */
28
+ function getGlobalMessage(lang) {
29
+ return store$3?.get(lang);
30
+ }
31
+ let store$2;
32
+ /**
33
+ * Returns a schema error message.
34
+ *
35
+ * @param lang The language of the message.
36
+ *
37
+ * @returns The error message.
38
+ */
39
+ /* @__NO_SIDE_EFFECTS__ */
40
+ function getSchemaMessage(lang) {
41
+ return store$2?.get(lang);
42
+ }
43
+ let store$1;
44
+ /**
45
+ * Returns a specific error message.
46
+ *
47
+ * @param reference The identifier reference.
48
+ * @param lang The language of the message.
49
+ *
50
+ * @returns The error message.
51
+ */
52
+ /* @__NO_SIDE_EFFECTS__ */
53
+ function getSpecificMessage(reference, lang) {
54
+ return store$1?.get(reference)?.get(lang);
55
+ }
56
+ /**
57
+ * Stringifies an unknown input to a literal or type string.
58
+ *
59
+ * @param input The unknown input.
60
+ *
61
+ * @returns A literal or type string.
62
+ *
63
+ * @internal
64
+ */
65
+ /* @__NO_SIDE_EFFECTS__ */
66
+ function _stringify(input) {
67
+ const type = typeof input;
68
+ if (type === "string") return `"${input}"`;
69
+ if (type === "number" || type === "bigint" || type === "boolean") return `${input}`;
70
+ if (type === "object" || type === "function") return (input && Object.getPrototypeOf(input)?.constructor?.name) ?? "null";
71
+ return type;
72
+ }
73
+ /**
74
+ * Adds an issue to the dataset.
75
+ *
76
+ * @param context The issue context.
77
+ * @param label The issue label.
78
+ * @param dataset The input dataset.
79
+ * @param config The configuration.
80
+ * @param other The optional props.
81
+ *
82
+ * @internal
83
+ */
84
+ function _addIssue(context, label, dataset, config$1, other) {
85
+ const input = other && "input" in other ? other.input : dataset.value;
86
+ const expected = other?.expected ?? context.expects ?? null;
87
+ const received = other?.received ?? /* @__PURE__ */ _stringify(input);
88
+ const issue = {
89
+ kind: context.kind,
90
+ type: context.type,
91
+ input,
92
+ expected,
93
+ received,
94
+ message: `Invalid ${label}: ${expected ? `Expected ${expected} but r` : "R"}eceived ${received}`,
95
+ requirement: context.requirement,
96
+ path: other?.path,
97
+ issues: other?.issues,
98
+ lang: config$1.lang,
99
+ abortEarly: config$1.abortEarly,
100
+ abortPipeEarly: config$1.abortPipeEarly
101
+ };
102
+ const isSchema = context.kind === "schema";
103
+ const message$1 = other?.message ?? context.message ?? /* @__PURE__ */ getSpecificMessage(context.reference, issue.lang) ?? (isSchema ? /* @__PURE__ */ getSchemaMessage(issue.lang) : null) ?? config$1.message ?? /* @__PURE__ */ getGlobalMessage(issue.lang);
104
+ if (message$1 !== void 0) issue.message = typeof message$1 === "function" ? message$1(issue) : message$1;
105
+ if (isSchema) dataset.typed = false;
106
+ if (dataset.issues) dataset.issues.push(issue);
107
+ else dataset.issues = [issue];
108
+ }
109
+ /**
110
+ * Returns the Standard Schema properties.
111
+ *
112
+ * @param context The schema context.
113
+ *
114
+ * @returns The Standard Schema properties.
115
+ */
116
+ /* @__NO_SIDE_EFFECTS__ */
117
+ function _getStandardProps(context) {
118
+ return {
119
+ version: 1,
120
+ vendor: "valibot",
121
+ validate(value$1) {
122
+ return context["~run"]({ value: value$1 }, /* @__PURE__ */ getGlobalConfig());
123
+ }
124
+ };
125
+ }
126
+ /**
127
+ * Disallows inherited object properties and prevents object prototype
128
+ * pollution by disallowing certain keys.
129
+ *
130
+ * @param object The object to check.
131
+ * @param key The key to check.
132
+ *
133
+ * @returns Whether the key is allowed.
134
+ *
135
+ * @internal
136
+ */
137
+ /* @__NO_SIDE_EFFECTS__ */
138
+ function _isValidObjectKey(object$1, key) {
139
+ return Object.hasOwn(object$1, key) && key !== "__proto__" && key !== "prototype" && key !== "constructor";
140
+ }
141
+ /**
142
+ * Joins multiple `expects` values with the given separator.
143
+ *
144
+ * @param values The `expects` values.
145
+ * @param separator The separator.
146
+ *
147
+ * @returns The joined `expects` property.
148
+ *
149
+ * @internal
150
+ */
151
+ /* @__NO_SIDE_EFFECTS__ */
152
+ function _joinExpects(values$1, separator) {
153
+ const list = [...new Set(values$1)];
154
+ if (list.length > 1) return `(${list.join(` ${separator} `)})`;
155
+ return list[0] ?? "never";
156
+ }
157
+ /* @__NO_SIDE_EFFECTS__ */
158
+ function check(requirement, message$1) {
159
+ return {
160
+ kind: "validation",
161
+ type: "check",
162
+ reference: check,
163
+ async: false,
164
+ expects: null,
165
+ requirement,
166
+ message: message$1,
167
+ "~run"(dataset, config$1) {
168
+ if (dataset.typed && !this.requirement(dataset.value)) _addIssue(this, "input", dataset, config$1);
169
+ return dataset;
170
+ }
171
+ };
172
+ }
173
+ /* @__NO_SIDE_EFFECTS__ */
174
+ function maxValue(requirement, message$1) {
175
+ return {
176
+ kind: "validation",
177
+ type: "max_value",
178
+ reference: maxValue,
179
+ async: false,
180
+ expects: `<=${requirement instanceof Date ? requirement.toJSON() : /* @__PURE__ */ _stringify(requirement)}`,
181
+ requirement,
182
+ message: message$1,
183
+ "~run"(dataset, config$1) {
184
+ if (dataset.typed && !(dataset.value <= this.requirement)) _addIssue(this, "value", dataset, config$1, { received: dataset.value instanceof Date ? dataset.value.toJSON() : /* @__PURE__ */ _stringify(dataset.value) });
185
+ return dataset;
186
+ }
187
+ };
188
+ }
189
+ /* @__NO_SIDE_EFFECTS__ */
190
+ function minLength(requirement, message$1) {
191
+ return {
192
+ kind: "validation",
193
+ type: "min_length",
194
+ reference: minLength,
195
+ async: false,
196
+ expects: `>=${requirement}`,
197
+ requirement,
198
+ message: message$1,
199
+ "~run"(dataset, config$1) {
200
+ if (dataset.typed && dataset.value.length < this.requirement) _addIssue(this, "length", dataset, config$1, { received: `${dataset.value.length}` });
201
+ return dataset;
202
+ }
203
+ };
204
+ }
205
+ /* @__NO_SIDE_EFFECTS__ */
206
+ function minValue(requirement, message$1) {
207
+ return {
208
+ kind: "validation",
209
+ type: "min_value",
210
+ reference: minValue,
211
+ async: false,
212
+ expects: `>=${requirement instanceof Date ? requirement.toJSON() : /* @__PURE__ */ _stringify(requirement)}`,
213
+ requirement,
214
+ message: message$1,
215
+ "~run"(dataset, config$1) {
216
+ if (dataset.typed && !(dataset.value >= this.requirement)) _addIssue(this, "value", dataset, config$1, { received: dataset.value instanceof Date ? dataset.value.toJSON() : /* @__PURE__ */ _stringify(dataset.value) });
217
+ return dataset;
218
+ }
219
+ };
220
+ }
221
+ /**
222
+ * Creates a raw transformation action.
223
+ *
224
+ * @param action The transformation action.
225
+ *
226
+ * @returns A raw transform action.
227
+ */
228
+ /* @__NO_SIDE_EFFECTS__ */
229
+ function rawTransform(action) {
230
+ return {
231
+ kind: "transformation",
232
+ type: "raw_transform",
233
+ reference: rawTransform,
234
+ async: false,
235
+ "~run"(dataset, config$1) {
236
+ const output = action({
237
+ dataset,
238
+ config: config$1,
239
+ addIssue: (info) => _addIssue(this, info?.label ?? "input", dataset, config$1, info),
240
+ NEVER: null
241
+ });
242
+ if (dataset.issues) dataset.typed = false;
243
+ else dataset.value = output;
244
+ return dataset;
245
+ }
246
+ };
247
+ }
248
+ /* @__NO_SIDE_EFFECTS__ */
249
+ function regex(requirement, message$1) {
250
+ return {
251
+ kind: "validation",
252
+ type: "regex",
253
+ reference: regex,
254
+ async: false,
255
+ expects: `${requirement}`,
256
+ requirement,
257
+ message: message$1,
258
+ "~run"(dataset, config$1) {
259
+ if (dataset.typed && !this.requirement.test(dataset.value)) _addIssue(this, "format", dataset, config$1);
260
+ return dataset;
261
+ }
262
+ };
263
+ }
264
+ /**
265
+ * Creates a custom transformation action.
266
+ *
267
+ * @param operation The transformation operation.
268
+ *
269
+ * @returns A transform action.
270
+ */
271
+ /* @__NO_SIDE_EFFECTS__ */
272
+ function transform(operation) {
273
+ return {
274
+ kind: "transformation",
275
+ type: "transform",
276
+ reference: transform,
277
+ async: false,
278
+ operation,
279
+ "~run"(dataset) {
280
+ dataset.value = this.operation(dataset.value);
281
+ return dataset;
282
+ }
283
+ };
284
+ }
285
+ /**
286
+ * Returns the fallback value of the schema.
287
+ *
288
+ * @param schema The schema to get it from.
289
+ * @param dataset The output dataset if available.
290
+ * @param config The config if available.
291
+ *
292
+ * @returns The fallback value.
293
+ */
294
+ /* @__NO_SIDE_EFFECTS__ */
295
+ function getFallback(schema, dataset, config$1) {
296
+ return typeof schema.fallback === "function" ? schema.fallback(dataset, config$1) : schema.fallback;
297
+ }
298
+ /**
299
+ * Returns the default value of the schema.
300
+ *
301
+ * @param schema The schema to get it from.
302
+ * @param dataset The input dataset if available.
303
+ * @param config The config if available.
304
+ *
305
+ * @returns The default value.
306
+ */
307
+ /* @__NO_SIDE_EFFECTS__ */
308
+ function getDefault(schema, dataset, config$1) {
309
+ return typeof schema.default === "function" ? schema.default(dataset, config$1) : schema.default;
310
+ }
311
+ /**
312
+ * Creates an any schema.
313
+ *
314
+ * Hint: This schema function exists only for completeness and is not
315
+ * recommended in practice. Instead, `unknown` should be used to accept
316
+ * unknown data.
317
+ *
318
+ * @returns An any schema.
319
+ */
320
+ /* @__NO_SIDE_EFFECTS__ */
321
+ function any() {
322
+ return {
323
+ kind: "schema",
324
+ type: "any",
325
+ reference: any,
326
+ expects: "any",
327
+ async: false,
328
+ get "~standard"() {
329
+ return /* @__PURE__ */ _getStandardProps(this);
330
+ },
331
+ "~run"(dataset) {
332
+ dataset.typed = true;
333
+ return dataset;
334
+ }
335
+ };
336
+ }
337
+ /* @__NO_SIDE_EFFECTS__ */
338
+ function array(item, message$1) {
339
+ return {
340
+ kind: "schema",
341
+ type: "array",
342
+ reference: array,
343
+ expects: "Array",
344
+ async: false,
345
+ item,
346
+ message: message$1,
347
+ get "~standard"() {
348
+ return /* @__PURE__ */ _getStandardProps(this);
349
+ },
350
+ "~run"(dataset, config$1) {
351
+ const input = dataset.value;
352
+ if (Array.isArray(input)) {
353
+ dataset.typed = true;
354
+ dataset.value = [];
355
+ for (let key = 0; key < input.length; key++) {
356
+ const value$1 = input[key];
357
+ const itemDataset = this.item["~run"]({ value: value$1 }, config$1);
358
+ if (itemDataset.issues) {
359
+ const pathItem = {
360
+ type: "array",
361
+ origin: "value",
362
+ input,
363
+ key,
364
+ value: value$1
365
+ };
366
+ for (const issue of itemDataset.issues) {
367
+ if (issue.path) issue.path.unshift(pathItem);
368
+ else issue.path = [pathItem];
369
+ dataset.issues?.push(issue);
370
+ }
371
+ if (!dataset.issues) dataset.issues = itemDataset.issues;
372
+ if (config$1.abortEarly) {
373
+ dataset.typed = false;
374
+ break;
375
+ }
376
+ }
377
+ if (!itemDataset.typed) dataset.typed = false;
378
+ dataset.value.push(itemDataset.value);
379
+ }
380
+ } else _addIssue(this, "type", dataset, config$1);
381
+ return dataset;
382
+ }
383
+ };
384
+ }
385
+ /* @__NO_SIDE_EFFECTS__ */
386
+ function boolean(message$1) {
387
+ return {
388
+ kind: "schema",
389
+ type: "boolean",
390
+ reference: boolean,
391
+ expects: "boolean",
392
+ async: false,
393
+ message: message$1,
394
+ get "~standard"() {
395
+ return /* @__PURE__ */ _getStandardProps(this);
396
+ },
397
+ "~run"(dataset, config$1) {
398
+ if (typeof dataset.value === "boolean") dataset.typed = true;
399
+ else _addIssue(this, "type", dataset, config$1);
400
+ return dataset;
401
+ }
402
+ };
403
+ }
404
+ /* @__NO_SIDE_EFFECTS__ */
405
+ function literal(literal_, message$1) {
406
+ return {
407
+ kind: "schema",
408
+ type: "literal",
409
+ reference: literal,
410
+ expects: /* @__PURE__ */ _stringify(literal_),
411
+ async: false,
412
+ literal: literal_,
413
+ message: message$1,
414
+ get "~standard"() {
415
+ return /* @__PURE__ */ _getStandardProps(this);
416
+ },
417
+ "~run"(dataset, config$1) {
418
+ if (dataset.value === this.literal) dataset.typed = true;
419
+ else _addIssue(this, "type", dataset, config$1);
420
+ return dataset;
421
+ }
422
+ };
423
+ }
424
+ /* @__NO_SIDE_EFFECTS__ */
425
+ function looseObject(entries$1, message$1) {
426
+ return {
427
+ kind: "schema",
428
+ type: "loose_object",
429
+ reference: looseObject,
430
+ expects: "Object",
431
+ async: false,
432
+ entries: entries$1,
433
+ message: message$1,
434
+ get "~standard"() {
435
+ return /* @__PURE__ */ _getStandardProps(this);
436
+ },
437
+ "~run"(dataset, config$1) {
438
+ const input = dataset.value;
439
+ if (input && typeof input === "object") {
440
+ dataset.typed = true;
441
+ dataset.value = {};
442
+ for (const key in this.entries) {
443
+ const valueSchema = this.entries[key];
444
+ if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && valueSchema.default !== void 0) {
445
+ const value$1 = key in input ? input[key] : /* @__PURE__ */ getDefault(valueSchema);
446
+ const valueDataset = valueSchema["~run"]({ value: value$1 }, config$1);
447
+ if (valueDataset.issues) {
448
+ const pathItem = {
449
+ type: "object",
450
+ origin: "value",
451
+ input,
452
+ key,
453
+ value: value$1
454
+ };
455
+ for (const issue of valueDataset.issues) {
456
+ if (issue.path) issue.path.unshift(pathItem);
457
+ else issue.path = [pathItem];
458
+ dataset.issues?.push(issue);
459
+ }
460
+ if (!dataset.issues) dataset.issues = valueDataset.issues;
461
+ if (config$1.abortEarly) {
462
+ dataset.typed = false;
463
+ break;
464
+ }
465
+ }
466
+ if (!valueDataset.typed) dataset.typed = false;
467
+ dataset.value[key] = valueDataset.value;
468
+ } else if (valueSchema.fallback !== void 0) dataset.value[key] = /* @__PURE__ */ getFallback(valueSchema);
469
+ else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
470
+ _addIssue(this, "key", dataset, config$1, {
471
+ input: void 0,
472
+ expected: `"${key}"`,
473
+ path: [{
474
+ type: "object",
475
+ origin: "key",
476
+ input,
477
+ key,
478
+ value: input[key]
479
+ }]
480
+ });
481
+ if (config$1.abortEarly) break;
482
+ }
483
+ }
484
+ if (!dataset.issues || !config$1.abortEarly) {
485
+ for (const key in input) if (/* @__PURE__ */ _isValidObjectKey(input, key) && !(key in this.entries)) dataset.value[key] = input[key];
486
+ }
487
+ } else _addIssue(this, "type", dataset, config$1);
488
+ return dataset;
489
+ }
490
+ };
491
+ }
492
+ /* @__NO_SIDE_EFFECTS__ */
493
+ function number(message$1) {
494
+ return {
495
+ kind: "schema",
496
+ type: "number",
497
+ reference: number,
498
+ expects: "number",
499
+ async: false,
500
+ message: message$1,
501
+ get "~standard"() {
502
+ return /* @__PURE__ */ _getStandardProps(this);
503
+ },
504
+ "~run"(dataset, config$1) {
505
+ if (typeof dataset.value === "number" && !isNaN(dataset.value)) dataset.typed = true;
506
+ else _addIssue(this, "type", dataset, config$1);
507
+ return dataset;
508
+ }
509
+ };
510
+ }
511
+ /* @__NO_SIDE_EFFECTS__ */
512
+ function object(entries$1, message$1) {
513
+ return {
514
+ kind: "schema",
515
+ type: "object",
516
+ reference: object,
517
+ expects: "Object",
518
+ async: false,
519
+ entries: entries$1,
520
+ message: message$1,
521
+ get "~standard"() {
522
+ return /* @__PURE__ */ _getStandardProps(this);
523
+ },
524
+ "~run"(dataset, config$1) {
525
+ const input = dataset.value;
526
+ if (input && typeof input === "object") {
527
+ dataset.typed = true;
528
+ dataset.value = {};
529
+ for (const key in this.entries) {
530
+ const valueSchema = this.entries[key];
531
+ if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && valueSchema.default !== void 0) {
532
+ const value$1 = key in input ? input[key] : /* @__PURE__ */ getDefault(valueSchema);
533
+ const valueDataset = valueSchema["~run"]({ value: value$1 }, config$1);
534
+ if (valueDataset.issues) {
535
+ const pathItem = {
536
+ type: "object",
537
+ origin: "value",
538
+ input,
539
+ key,
540
+ value: value$1
541
+ };
542
+ for (const issue of valueDataset.issues) {
543
+ if (issue.path) issue.path.unshift(pathItem);
544
+ else issue.path = [pathItem];
545
+ dataset.issues?.push(issue);
546
+ }
547
+ if (!dataset.issues) dataset.issues = valueDataset.issues;
548
+ if (config$1.abortEarly) {
549
+ dataset.typed = false;
550
+ break;
551
+ }
552
+ }
553
+ if (!valueDataset.typed) dataset.typed = false;
554
+ dataset.value[key] = valueDataset.value;
555
+ } else if (valueSchema.fallback !== void 0) dataset.value[key] = /* @__PURE__ */ getFallback(valueSchema);
556
+ else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
557
+ _addIssue(this, "key", dataset, config$1, {
558
+ input: void 0,
559
+ expected: `"${key}"`,
560
+ path: [{
561
+ type: "object",
562
+ origin: "key",
563
+ input,
564
+ key,
565
+ value: input[key]
566
+ }]
567
+ });
568
+ if (config$1.abortEarly) break;
569
+ }
570
+ }
571
+ } else _addIssue(this, "type", dataset, config$1);
572
+ return dataset;
573
+ }
574
+ };
575
+ }
576
+ /* @__NO_SIDE_EFFECTS__ */
577
+ function optional(wrapped, default_) {
578
+ return {
579
+ kind: "schema",
580
+ type: "optional",
581
+ reference: optional,
582
+ expects: `(${wrapped.expects} | undefined)`,
583
+ async: false,
584
+ wrapped,
585
+ default: default_,
586
+ get "~standard"() {
587
+ return /* @__PURE__ */ _getStandardProps(this);
588
+ },
589
+ "~run"(dataset, config$1) {
590
+ if (dataset.value === void 0) {
591
+ if (this.default !== void 0) dataset.value = /* @__PURE__ */ getDefault(this, dataset, config$1);
592
+ if (dataset.value === void 0) {
593
+ dataset.typed = true;
594
+ return dataset;
595
+ }
596
+ }
597
+ return this.wrapped["~run"](dataset, config$1);
598
+ }
599
+ };
600
+ }
601
+ /* @__NO_SIDE_EFFECTS__ */
602
+ function picklist(options, message$1) {
603
+ return {
604
+ kind: "schema",
605
+ type: "picklist",
606
+ reference: picklist,
607
+ expects: /* @__PURE__ */ _joinExpects(options.map(_stringify), "|"),
608
+ async: false,
609
+ options,
610
+ message: message$1,
611
+ get "~standard"() {
612
+ return /* @__PURE__ */ _getStandardProps(this);
613
+ },
614
+ "~run"(dataset, config$1) {
615
+ if (this.options.includes(dataset.value)) dataset.typed = true;
616
+ else _addIssue(this, "type", dataset, config$1);
617
+ return dataset;
618
+ }
619
+ };
620
+ }
621
+ /* @__NO_SIDE_EFFECTS__ */
622
+ function string(message$1) {
623
+ return {
624
+ kind: "schema",
625
+ type: "string",
626
+ reference: string,
627
+ expects: "string",
628
+ async: false,
629
+ message: message$1,
630
+ get "~standard"() {
631
+ return /* @__PURE__ */ _getStandardProps(this);
632
+ },
633
+ "~run"(dataset, config$1) {
634
+ if (typeof dataset.value === "string") dataset.typed = true;
635
+ else _addIssue(this, "type", dataset, config$1);
636
+ return dataset;
637
+ }
638
+ };
639
+ }
640
+ /**
641
+ * Returns the sub issues of the provided datasets for the union issue.
642
+ *
643
+ * @param datasets The datasets.
644
+ *
645
+ * @returns The sub issues.
646
+ *
647
+ * @internal
648
+ */
649
+ /* @__NO_SIDE_EFFECTS__ */
650
+ function _subIssues(datasets) {
651
+ let issues;
652
+ if (datasets) for (const dataset of datasets) if (issues) issues.push(...dataset.issues);
653
+ else issues = dataset.issues;
654
+ return issues;
655
+ }
656
+ /* @__NO_SIDE_EFFECTS__ */
657
+ function union(options, message$1) {
658
+ return {
659
+ kind: "schema",
660
+ type: "union",
661
+ reference: union,
662
+ expects: /* @__PURE__ */ _joinExpects(options.map((option) => option.expects), "|"),
663
+ async: false,
664
+ options,
665
+ message: message$1,
666
+ get "~standard"() {
667
+ return /* @__PURE__ */ _getStandardProps(this);
668
+ },
669
+ "~run"(dataset, config$1) {
670
+ let validDataset;
671
+ let typedDatasets;
672
+ let untypedDatasets;
673
+ for (const schema of this.options) {
674
+ const optionDataset = schema["~run"]({ value: dataset.value }, config$1);
675
+ if (optionDataset.typed) if (optionDataset.issues) if (typedDatasets) typedDatasets.push(optionDataset);
676
+ else typedDatasets = [optionDataset];
677
+ else {
678
+ validDataset = optionDataset;
679
+ break;
680
+ }
681
+ else if (untypedDatasets) untypedDatasets.push(optionDataset);
682
+ else untypedDatasets = [optionDataset];
683
+ }
684
+ if (validDataset) return validDataset;
685
+ if (typedDatasets) {
686
+ if (typedDatasets.length === 1) return typedDatasets[0];
687
+ _addIssue(this, "type", dataset, config$1, { issues: /* @__PURE__ */ _subIssues(typedDatasets) });
688
+ dataset.typed = true;
689
+ } else if (untypedDatasets?.length === 1) return untypedDatasets[0];
690
+ else _addIssue(this, "type", dataset, config$1, { issues: /* @__PURE__ */ _subIssues(untypedDatasets) });
691
+ return dataset;
692
+ }
693
+ };
694
+ }
695
+ /* @__NO_SIDE_EFFECTS__ */
696
+ function pipe(...pipe$1) {
697
+ return {
698
+ ...pipe$1[0],
699
+ pipe: pipe$1,
700
+ get "~standard"() {
701
+ return /* @__PURE__ */ _getStandardProps(this);
702
+ },
703
+ "~run"(dataset, config$1) {
704
+ for (const item of pipe$1) if (item.kind !== "metadata") {
705
+ if (dataset.issues && (item.kind === "schema" || item.kind === "transformation")) {
706
+ dataset.typed = false;
707
+ break;
708
+ }
709
+ if (!dataset.issues || !config$1.abortEarly && !config$1.abortPipeEarly) dataset = item["~run"](dataset, config$1);
710
+ }
711
+ return dataset;
712
+ }
713
+ };
714
+ }
715
+ /**
716
+ * Parses an unknown input based on a schema.
717
+ *
718
+ * @param schema The schema to be used.
719
+ * @param input The input to be parsed.
720
+ * @param config The parse configuration.
721
+ *
722
+ * @returns The parse result.
723
+ */
724
+ /* @__NO_SIDE_EFFECTS__ */
725
+ function safeParse(schema, input, config$1) {
726
+ const dataset = schema["~run"]({ value: input }, /* @__PURE__ */ getGlobalConfig(config$1));
727
+ return {
728
+ typed: dataset.typed,
729
+ success: !dataset.issues,
730
+ output: dataset.value,
731
+ issues: dataset.issues
732
+ };
733
+ }
734
+
735
+ //#endregion
736
+ export { any, array, boolean, check, literal, looseObject, maxValue, minLength, minValue, number, object, optional, picklist, pipe, rawTransform, regex, safeParse, string, transform, union };