@paean-ai/harness-model-pricing 0.1.1-rc.21 → 0.1.1-rc.23

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 (2) hide show
  1. package/lib/client.js +7 -3951
  2. package/package.json +30 -32
package/lib/client.js CHANGED
@@ -8,6 +8,7 @@ window.__ModuleLoader__.load({
8
8
  let react = require("react");
9
9
  let react_dom = require("react-dom");
10
10
  let _deepseek_ai_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
11
+ let zod = require("zod");
11
12
  //#region lib/types/calculate.js
12
13
  /**
13
14
  * Resolve an alias without querying account identity or changing its route.
@@ -619,3956 +620,11 @@ window.__ModuleLoader__.load({
619
620
  return new Intl.NumberFormat("en-US").format(value);
620
621
  }
621
622
  //#endregion
622
- //#region ../../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/core.js
623
- var _a$1;
624
- function $constructor(name, initializer, params) {
625
- function init(inst, def) {
626
- if (!inst._zod) Object.defineProperty(inst, "_zod", {
627
- value: {
628
- def,
629
- constr: _,
630
- traits: /* @__PURE__ */ new Set()
631
- },
632
- enumerable: false
633
- });
634
- if (inst._zod.traits.has(name)) return;
635
- inst._zod.traits.add(name);
636
- initializer(inst, def);
637
- const proto = _.prototype;
638
- const keys = Object.keys(proto);
639
- for (let i = 0; i < keys.length; i++) {
640
- const k = keys[i];
641
- if (!(k in inst)) inst[k] = proto[k].bind(inst);
642
- }
643
- }
644
- const Parent = params?.Parent ?? Object;
645
- class Definition extends Parent {}
646
- Object.defineProperty(Definition, "name", { value: name });
647
- function _(def) {
648
- var _a;
649
- const inst = params?.Parent ? new Definition() : this;
650
- init(inst, def);
651
- (_a = inst._zod).deferred ?? (_a.deferred = []);
652
- for (const fn of inst._zod.deferred) fn();
653
- return inst;
654
- }
655
- Object.defineProperty(_, "init", { value: init });
656
- Object.defineProperty(_, Symbol.hasInstance, { value: (inst) => {
657
- if (params?.Parent && inst instanceof params.Parent) return true;
658
- return inst?._zod?.traits?.has(name);
659
- } });
660
- Object.defineProperty(_, "name", { value: name });
661
- return _;
662
- }
663
- var $ZodAsyncError = class extends Error {
664
- constructor() {
665
- super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
666
- }
667
- };
668
- var $ZodEncodeError = class extends Error {
669
- constructor(name) {
670
- super(`Encountered unidirectional transform during encode: ${name}`);
671
- this.name = "ZodEncodeError";
672
- }
673
- };
674
- (_a$1 = globalThis).__zod_globalConfig ?? (_a$1.__zod_globalConfig = {});
675
- const globalConfig = globalThis.__zod_globalConfig;
676
- function config(newConfig) {
677
- if (newConfig) Object.assign(globalConfig, newConfig);
678
- return globalConfig;
679
- }
680
- //#endregion
681
- //#region ../../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/util.js
682
- function getEnumValues(entries) {
683
- const numericValues = Object.values(entries).filter((v) => typeof v === "number");
684
- return Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
685
- }
686
- function jsonStringifyReplacer(_, value) {
687
- if (typeof value === "bigint") return value.toString();
688
- return value;
689
- }
690
- function cached(getter) {
691
- return { get value() {
692
- {
693
- const value = getter();
694
- Object.defineProperty(this, "value", { value });
695
- return value;
696
- }
697
- throw new Error("cached value already set");
698
- } };
699
- }
700
- function nullish(input) {
701
- return input === null || input === void 0;
702
- }
703
- function cleanRegex(source) {
704
- const start = source.startsWith("^") ? 1 : 0;
705
- const end = source.endsWith("$") ? source.length - 1 : source.length;
706
- return source.slice(start, end);
707
- }
708
- function floatSafeRemainder(val, step) {
709
- const ratio = val / step;
710
- const roundedRatio = Math.round(ratio);
711
- const tolerance = Number.EPSILON * Math.max(Math.abs(ratio), 1);
712
- if (Math.abs(ratio - roundedRatio) < tolerance) return 0;
713
- return ratio - roundedRatio;
714
- }
715
- const EVALUATING = /* @__PURE__*/ Symbol("evaluating");
716
- function defineLazy(object, key, getter) {
717
- let value = void 0;
718
- Object.defineProperty(object, key, {
719
- get() {
720
- if (value === EVALUATING) return;
721
- if (value === void 0) {
722
- value = EVALUATING;
723
- value = getter();
724
- }
725
- return value;
726
- },
727
- set(v) {
728
- Object.defineProperty(object, key, { value: v });
729
- },
730
- configurable: true
731
- });
732
- }
733
- function assignProp(target, prop, value) {
734
- Object.defineProperty(target, prop, {
735
- value,
736
- writable: true,
737
- enumerable: true,
738
- configurable: true
739
- });
740
- }
741
- function mergeDefs(...defs) {
742
- const mergedDescriptors = {};
743
- for (const def of defs) Object.assign(mergedDescriptors, Object.getOwnPropertyDescriptors(def));
744
- return Object.defineProperties({}, mergedDescriptors);
745
- }
746
- function esc(str) {
747
- return JSON.stringify(str);
748
- }
749
- function slugify(input) {
750
- return input.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
751
- }
752
- const captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => {};
753
- function isObject(data) {
754
- return typeof data === "object" && data !== null && !Array.isArray(data);
755
- }
756
- const allowsEval = /* @__PURE__*/ cached(() => {
757
- if (globalConfig.jitless) return false;
758
- if (typeof navigator !== "undefined" && navigator?.userAgent?.includes("Cloudflare")) return false;
759
- try {
760
- new Function("");
761
- return true;
762
- } catch (_) {
763
- return false;
764
- }
765
- });
766
- function isPlainObject(o) {
767
- if (isObject(o) === false) return false;
768
- const ctor = o.constructor;
769
- if (ctor === void 0) return true;
770
- if (typeof ctor !== "function") return true;
771
- const prot = ctor.prototype;
772
- if (isObject(prot) === false) return false;
773
- if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) return false;
774
- return true;
775
- }
776
- function shallowClone(o) {
777
- if (isPlainObject(o)) return { ...o };
778
- if (Array.isArray(o)) return [...o];
779
- if (o instanceof Map) return new Map(o);
780
- if (o instanceof Set) return new Set(o);
781
- return o;
782
- }
783
- const propertyKeyTypes = /* @__PURE__*/ new Set([
784
- "string",
785
- "number",
786
- "symbol"
787
- ]);
788
- function escapeRegex(str) {
789
- return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
790
- }
791
- function clone(inst, def, params) {
792
- const cl = new inst._zod.constr(def ?? inst._zod.def);
793
- if (!def || params?.parent) cl._zod.parent = inst;
794
- return cl;
795
- }
796
- function normalizeParams(_params) {
797
- const params = _params;
798
- if (!params) return {};
799
- if (typeof params === "string") return { error: () => params };
800
- if (params?.message !== void 0) {
801
- if (params?.error !== void 0) throw new Error("Cannot specify both `message` and `error` params");
802
- params.error = params.message;
803
- }
804
- delete params.message;
805
- if (typeof params.error === "string") return {
806
- ...params,
807
- error: () => params.error
808
- };
809
- return params;
810
- }
811
- function optionalKeys(shape) {
812
- return Object.keys(shape).filter((k) => {
813
- return shape[k]._zod.optin === "optional" && shape[k]._zod.optout === "optional";
814
- });
815
- }
816
- const NUMBER_FORMAT_RANGES = {
817
- safeint: [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER],
818
- int32: [-2147483648, 2147483647],
819
- uint32: [0, 4294967295],
820
- float32: [-34028234663852886e22, 34028234663852886e22],
821
- float64: [-Number.MAX_VALUE, Number.MAX_VALUE]
822
- };
823
- function pick(schema, mask) {
824
- const currDef = schema._zod.def;
825
- const checks = currDef.checks;
826
- if (checks && checks.length > 0) throw new Error(".pick() cannot be used on object schemas containing refinements");
827
- return clone(schema, mergeDefs(schema._zod.def, {
828
- get shape() {
829
- const newShape = {};
830
- for (const key in mask) {
831
- if (!(key in currDef.shape)) throw new Error(`Unrecognized key: "${key}"`);
832
- if (!mask[key]) continue;
833
- newShape[key] = currDef.shape[key];
834
- }
835
- assignProp(this, "shape", newShape);
836
- return newShape;
837
- },
838
- checks: []
839
- }));
840
- }
841
- function omit(schema, mask) {
842
- const currDef = schema._zod.def;
843
- const checks = currDef.checks;
844
- if (checks && checks.length > 0) throw new Error(".omit() cannot be used on object schemas containing refinements");
845
- return clone(schema, mergeDefs(schema._zod.def, {
846
- get shape() {
847
- const newShape = { ...schema._zod.def.shape };
848
- for (const key in mask) {
849
- if (!(key in currDef.shape)) throw new Error(`Unrecognized key: "${key}"`);
850
- if (!mask[key]) continue;
851
- delete newShape[key];
852
- }
853
- assignProp(this, "shape", newShape);
854
- return newShape;
855
- },
856
- checks: []
857
- }));
858
- }
859
- function extend(schema, shape) {
860
- if (!isPlainObject(shape)) throw new Error("Invalid input to extend: expected a plain object");
861
- const checks = schema._zod.def.checks;
862
- if (checks && checks.length > 0) {
863
- const existingShape = schema._zod.def.shape;
864
- for (const key in shape) if (Object.getOwnPropertyDescriptor(existingShape, key) !== void 0) throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.");
865
- }
866
- return clone(schema, mergeDefs(schema._zod.def, { get shape() {
867
- const _shape = {
868
- ...schema._zod.def.shape,
869
- ...shape
870
- };
871
- assignProp(this, "shape", _shape);
872
- return _shape;
873
- } }));
874
- }
875
- function safeExtend(schema, shape) {
876
- if (!isPlainObject(shape)) throw new Error("Invalid input to safeExtend: expected a plain object");
877
- return clone(schema, mergeDefs(schema._zod.def, { get shape() {
878
- const _shape = {
879
- ...schema._zod.def.shape,
880
- ...shape
881
- };
882
- assignProp(this, "shape", _shape);
883
- return _shape;
884
- } }));
885
- }
886
- function merge(a, b) {
887
- if (a._zod.def.checks?.length) throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");
888
- return clone(a, mergeDefs(a._zod.def, {
889
- get shape() {
890
- const _shape = {
891
- ...a._zod.def.shape,
892
- ...b._zod.def.shape
893
- };
894
- assignProp(this, "shape", _shape);
895
- return _shape;
896
- },
897
- get catchall() {
898
- return b._zod.def.catchall;
899
- },
900
- checks: b._zod.def.checks ?? []
901
- }));
902
- }
903
- function partial(Class, schema, mask) {
904
- const checks = schema._zod.def.checks;
905
- if (checks && checks.length > 0) throw new Error(".partial() cannot be used on object schemas containing refinements");
906
- return clone(schema, mergeDefs(schema._zod.def, {
907
- get shape() {
908
- const oldShape = schema._zod.def.shape;
909
- const shape = { ...oldShape };
910
- if (mask) for (const key in mask) {
911
- if (!(key in oldShape)) throw new Error(`Unrecognized key: "${key}"`);
912
- if (!mask[key]) continue;
913
- shape[key] = Class ? new Class({
914
- type: "optional",
915
- innerType: oldShape[key]
916
- }) : oldShape[key];
917
- }
918
- else for (const key in oldShape) shape[key] = Class ? new Class({
919
- type: "optional",
920
- innerType: oldShape[key]
921
- }) : oldShape[key];
922
- assignProp(this, "shape", shape);
923
- return shape;
924
- },
925
- checks: []
926
- }));
927
- }
928
- function required(Class, schema, mask) {
929
- return clone(schema, mergeDefs(schema._zod.def, { get shape() {
930
- const oldShape = schema._zod.def.shape;
931
- const shape = { ...oldShape };
932
- if (mask) for (const key in mask) {
933
- if (!(key in shape)) throw new Error(`Unrecognized key: "${key}"`);
934
- if (!mask[key]) continue;
935
- shape[key] = new Class({
936
- type: "nonoptional",
937
- innerType: oldShape[key]
938
- });
939
- }
940
- else for (const key in oldShape) shape[key] = new Class({
941
- type: "nonoptional",
942
- innerType: oldShape[key]
943
- });
944
- assignProp(this, "shape", shape);
945
- return shape;
946
- } }));
947
- }
948
- function aborted(x, startIndex = 0) {
949
- if (x.aborted === true) return true;
950
- for (let i = startIndex; i < x.issues.length; i++) if (x.issues[i]?.continue !== true) return true;
951
- return false;
952
- }
953
- function explicitlyAborted(x, startIndex = 0) {
954
- if (x.aborted === true) return true;
955
- for (let i = startIndex; i < x.issues.length; i++) if (x.issues[i]?.continue === false) return true;
956
- return false;
957
- }
958
- function prefixIssues(path, issues) {
959
- return issues.map((iss) => {
960
- var _a;
961
- (_a = iss).path ?? (_a.path = []);
962
- iss.path.unshift(path);
963
- return iss;
964
- });
965
- }
966
- function unwrapMessage(message) {
967
- return typeof message === "string" ? message : message?.message;
968
- }
969
- function finalizeIssue(iss, ctx, config) {
970
- const message = iss.message ? iss.message : unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ?? unwrapMessage(ctx?.error?.(iss)) ?? unwrapMessage(config.customError?.(iss)) ?? unwrapMessage(config.localeError?.(iss)) ?? "Invalid input";
971
- const { inst: _inst, continue: _continue, input: _input, ...rest } = iss;
972
- rest.path ?? (rest.path = []);
973
- rest.message = message;
974
- if (ctx?.reportInput) rest.input = _input;
975
- return rest;
976
- }
977
- function getLengthableOrigin(input) {
978
- if (Array.isArray(input)) return "array";
979
- if (typeof input === "string") return "string";
980
- return "unknown";
981
- }
982
- function issue(...args) {
983
- const [iss, input, inst] = args;
984
- if (typeof iss === "string") return {
985
- message: iss,
986
- code: "custom",
987
- input,
988
- inst
989
- };
990
- return { ...iss };
991
- }
992
- //#endregion
993
- //#region ../../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/errors.js
994
- const initializer$1 = (inst, def) => {
995
- inst.name = "$ZodError";
996
- Object.defineProperty(inst, "_zod", {
997
- value: inst._zod,
998
- enumerable: false
999
- });
1000
- Object.defineProperty(inst, "issues", {
1001
- value: def,
1002
- enumerable: false
1003
- });
1004
- inst.message = JSON.stringify(def, jsonStringifyReplacer, 2);
1005
- Object.defineProperty(inst, "toString", {
1006
- value: () => inst.message,
1007
- enumerable: false
1008
- });
1009
- };
1010
- const $ZodError = $constructor("$ZodError", initializer$1);
1011
- const $ZodRealError = $constructor("$ZodError", initializer$1, { Parent: Error });
1012
- function flattenError(error, mapper = (issue) => issue.message) {
1013
- const fieldErrors = {};
1014
- const formErrors = [];
1015
- for (const sub of error.issues) if (sub.path.length > 0) {
1016
- fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
1017
- fieldErrors[sub.path[0]].push(mapper(sub));
1018
- } else formErrors.push(mapper(sub));
1019
- return {
1020
- formErrors,
1021
- fieldErrors
1022
- };
1023
- }
1024
- function formatError(error, mapper = (issue) => issue.message) {
1025
- const fieldErrors = { _errors: [] };
1026
- const processError = (error, path = []) => {
1027
- for (const issue of error.issues) if (issue.code === "invalid_union" && issue.errors.length) issue.errors.map((issues) => processError({ issues }, [...path, ...issue.path]));
1028
- else if (issue.code === "invalid_key") processError({ issues: issue.issues }, [...path, ...issue.path]);
1029
- else if (issue.code === "invalid_element") processError({ issues: issue.issues }, [...path, ...issue.path]);
1030
- else {
1031
- const fullpath = [...path, ...issue.path];
1032
- if (fullpath.length === 0) fieldErrors._errors.push(mapper(issue));
1033
- else {
1034
- let curr = fieldErrors;
1035
- let i = 0;
1036
- while (i < fullpath.length) {
1037
- const el = fullpath[i];
1038
- if (!(i === fullpath.length - 1)) curr[el] = curr[el] || { _errors: [] };
1039
- else {
1040
- curr[el] = curr[el] || { _errors: [] };
1041
- curr[el]._errors.push(mapper(issue));
1042
- }
1043
- curr = curr[el];
1044
- i++;
1045
- }
1046
- }
1047
- }
1048
- };
1049
- processError(error);
1050
- return fieldErrors;
1051
- }
1052
- //#endregion
1053
- //#region ../../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/parse.js
1054
- const _parse = (_Err) => (schema, value, _ctx, _params) => {
1055
- const ctx = _ctx ? {
1056
- ..._ctx,
1057
- async: false
1058
- } : { async: false };
1059
- const result = schema._zod.run({
1060
- value,
1061
- issues: []
1062
- }, ctx);
1063
- if (result instanceof Promise) throw new $ZodAsyncError();
1064
- if (result.issues.length) {
1065
- const e = new ((_params?.Err) ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
1066
- captureStackTrace(e, _params?.callee);
1067
- throw e;
1068
- }
1069
- return result.value;
1070
- };
1071
- const _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
1072
- const ctx = _ctx ? {
1073
- ..._ctx,
1074
- async: true
1075
- } : { async: true };
1076
- let result = schema._zod.run({
1077
- value,
1078
- issues: []
1079
- }, ctx);
1080
- if (result instanceof Promise) result = await result;
1081
- if (result.issues.length) {
1082
- const e = new ((params?.Err) ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
1083
- captureStackTrace(e, params?.callee);
1084
- throw e;
1085
- }
1086
- return result.value;
1087
- };
1088
- const _safeParse = (_Err) => (schema, value, _ctx) => {
1089
- const ctx = _ctx ? {
1090
- ..._ctx,
1091
- async: false
1092
- } : { async: false };
1093
- const result = schema._zod.run({
1094
- value,
1095
- issues: []
1096
- }, ctx);
1097
- if (result instanceof Promise) throw new $ZodAsyncError();
1098
- return result.issues.length ? {
1099
- success: false,
1100
- error: new (_Err ?? $ZodError)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
1101
- } : {
1102
- success: true,
1103
- data: result.value
1104
- };
1105
- };
1106
- const safeParse$1 = /* @__PURE__*/ _safeParse($ZodRealError);
1107
- const _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
1108
- const ctx = _ctx ? {
1109
- ..._ctx,
1110
- async: true
1111
- } : { async: true };
1112
- let result = schema._zod.run({
1113
- value,
1114
- issues: []
1115
- }, ctx);
1116
- if (result instanceof Promise) result = await result;
1117
- return result.issues.length ? {
1118
- success: false,
1119
- error: new _Err(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
1120
- } : {
1121
- success: true,
1122
- data: result.value
1123
- };
1124
- };
1125
- const safeParseAsync$1 = /* @__PURE__*/ _safeParseAsync($ZodRealError);
1126
- const _encode = (_Err) => (schema, value, _ctx) => {
1127
- const ctx = _ctx ? {
1128
- ..._ctx,
1129
- direction: "backward"
1130
- } : { direction: "backward" };
1131
- return _parse(_Err)(schema, value, ctx);
1132
- };
1133
- const _decode = (_Err) => (schema, value, _ctx) => {
1134
- return _parse(_Err)(schema, value, _ctx);
1135
- };
1136
- const _encodeAsync = (_Err) => async (schema, value, _ctx) => {
1137
- const ctx = _ctx ? {
1138
- ..._ctx,
1139
- direction: "backward"
1140
- } : { direction: "backward" };
1141
- return _parseAsync(_Err)(schema, value, ctx);
1142
- };
1143
- const _decodeAsync = (_Err) => async (schema, value, _ctx) => {
1144
- return _parseAsync(_Err)(schema, value, _ctx);
1145
- };
1146
- const _safeEncode = (_Err) => (schema, value, _ctx) => {
1147
- const ctx = _ctx ? {
1148
- ..._ctx,
1149
- direction: "backward"
1150
- } : { direction: "backward" };
1151
- return _safeParse(_Err)(schema, value, ctx);
1152
- };
1153
- const _safeDecode = (_Err) => (schema, value, _ctx) => {
1154
- return _safeParse(_Err)(schema, value, _ctx);
1155
- };
1156
- const _safeEncodeAsync = (_Err) => async (schema, value, _ctx) => {
1157
- const ctx = _ctx ? {
1158
- ..._ctx,
1159
- direction: "backward"
1160
- } : { direction: "backward" };
1161
- return _safeParseAsync(_Err)(schema, value, ctx);
1162
- };
1163
- const _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
1164
- return _safeParseAsync(_Err)(schema, value, _ctx);
1165
- };
1166
- //#endregion
1167
- //#region ../../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/regexes.js
1168
- /**
1169
- * @deprecated CUID v1 is deprecated by its authors due to information leakage
1170
- * (timestamps embedded in the id). Use {@link cuid2} instead.
1171
- * See https://github.com/paralleldrive/cuid.
1172
- */
1173
- const cuid = /^[cC][0-9a-z]{6,}$/;
1174
- const cuid2 = /^[0-9a-z]+$/;
1175
- const ulid = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;
1176
- const xid = /^[0-9a-vA-V]{20}$/;
1177
- const ksuid = /^[A-Za-z0-9]{27}$/;
1178
- const nanoid = /^[a-zA-Z0-9_-]{21}$/;
1179
- /** ISO 8601-1 duration regex. Does not support the 8601-2 extensions like negative durations or fractional/negative components. */
1180
- const duration$1 = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
1181
- /** A regex for any UUID-like identifier: 8-4-4-4-12 hex pattern */
1182
- const guid = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/;
1183
- /** Returns a regex for validating an RFC 9562/4122 UUID.
1184
- *
1185
- * @param version Optionally specify a version 1-8. If no version is specified, all versions are supported. */
1186
- const uuid = (version) => {
1187
- if (!version) return /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;
1188
- return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${version}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);
1189
- };
1190
- /** Practical email validation */
1191
- const email = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
1192
- const _emoji$1 = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
1193
- function emoji() {
1194
- return new RegExp(_emoji$1, "u");
1195
- }
1196
- const ipv4 = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
1197
- const ipv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;
1198
- const cidrv4 = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/;
1199
- const cidrv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
1200
- const base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
1201
- const base64url = /^[A-Za-z0-9_-]*$/;
1202
- const httpProtocol = /^https?$/;
1203
- const e164 = /^\+[1-9]\d{6,14}$/;
1204
- const dateSource = `(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;
1205
- const date$1 = /*@__PURE__*/ new RegExp(`^${dateSource}$`);
1206
- function timeSource(args) {
1207
- const hhmm = `(?:[01]\\d|2[0-3]):[0-5]\\d`;
1208
- return typeof args.precision === "number" ? args.precision === -1 ? `${hhmm}` : args.precision === 0 ? `${hhmm}:[0-5]\\d` : `${hhmm}:[0-5]\\d\\.\\d{${args.precision}}` : `${hhmm}(?::[0-5]\\d(?:\\.\\d+)?)?`;
1209
- }
1210
- function time$1(args) {
1211
- return new RegExp(`^${timeSource(args)}$`);
1212
- }
1213
- function datetime$1(args) {
1214
- const time = timeSource({ precision: args.precision });
1215
- const opts = ["Z"];
1216
- if (args.local) opts.push("");
1217
- if (args.offset) opts.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);
1218
- const timeRegex = `${time}(?:${opts.join("|")})`;
1219
- return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
1220
- }
1221
- const string$1 = (params) => {
1222
- const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
1223
- return new RegExp(`^${regex}$`);
1224
- };
1225
- const integer = /^-?\d+$/;
1226
- const number$1 = /^-?\d+(?:\.\d+)?$/;
1227
- const lowercase = /^[^A-Z]*$/;
1228
- const uppercase = /^[^a-z]*$/;
1229
- //#endregion
1230
- //#region ../../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/checks.js
1231
- const $ZodCheck = /*@__PURE__*/ $constructor("$ZodCheck", (inst, def) => {
1232
- var _a;
1233
- inst._zod ?? (inst._zod = {});
1234
- inst._zod.def = def;
1235
- (_a = inst._zod).onattach ?? (_a.onattach = []);
1236
- });
1237
- const numericOriginMap = {
1238
- number: "number",
1239
- bigint: "bigint",
1240
- object: "date"
1241
- };
1242
- const $ZodCheckLessThan = /*@__PURE__*/ $constructor("$ZodCheckLessThan", (inst, def) => {
1243
- $ZodCheck.init(inst, def);
1244
- const origin = numericOriginMap[typeof def.value];
1245
- inst._zod.onattach.push((inst) => {
1246
- const bag = inst._zod.bag;
1247
- const curr = (def.inclusive ? bag.maximum : bag.exclusiveMaximum) ?? Number.POSITIVE_INFINITY;
1248
- if (def.value < curr) if (def.inclusive) bag.maximum = def.value;
1249
- else bag.exclusiveMaximum = def.value;
1250
- });
1251
- inst._zod.check = (payload) => {
1252
- if (def.inclusive ? payload.value <= def.value : payload.value < def.value) return;
1253
- payload.issues.push({
1254
- origin,
1255
- code: "too_big",
1256
- maximum: typeof def.value === "object" ? def.value.getTime() : def.value,
1257
- input: payload.value,
1258
- inclusive: def.inclusive,
1259
- inst,
1260
- continue: !def.abort
1261
- });
1262
- };
1263
- });
1264
- const $ZodCheckGreaterThan = /*@__PURE__*/ $constructor("$ZodCheckGreaterThan", (inst, def) => {
1265
- $ZodCheck.init(inst, def);
1266
- const origin = numericOriginMap[typeof def.value];
1267
- inst._zod.onattach.push((inst) => {
1268
- const bag = inst._zod.bag;
1269
- const curr = (def.inclusive ? bag.minimum : bag.exclusiveMinimum) ?? Number.NEGATIVE_INFINITY;
1270
- if (def.value > curr) if (def.inclusive) bag.minimum = def.value;
1271
- else bag.exclusiveMinimum = def.value;
1272
- });
1273
- inst._zod.check = (payload) => {
1274
- if (def.inclusive ? payload.value >= def.value : payload.value > def.value) return;
1275
- payload.issues.push({
1276
- origin,
1277
- code: "too_small",
1278
- minimum: typeof def.value === "object" ? def.value.getTime() : def.value,
1279
- input: payload.value,
1280
- inclusive: def.inclusive,
1281
- inst,
1282
- continue: !def.abort
1283
- });
1284
- };
1285
- });
1286
- const $ZodCheckMultipleOf = /*@__PURE__*/ $constructor("$ZodCheckMultipleOf", (inst, def) => {
1287
- $ZodCheck.init(inst, def);
1288
- inst._zod.onattach.push((inst) => {
1289
- var _a;
1290
- (_a = inst._zod.bag).multipleOf ?? (_a.multipleOf = def.value);
1291
- });
1292
- inst._zod.check = (payload) => {
1293
- if (typeof payload.value !== typeof def.value) throw new Error("Cannot mix number and bigint in multiple_of check.");
1294
- if (typeof payload.value === "bigint" ? payload.value % def.value === BigInt(0) : floatSafeRemainder(payload.value, def.value) === 0) return;
1295
- payload.issues.push({
1296
- origin: typeof payload.value,
1297
- code: "not_multiple_of",
1298
- divisor: def.value,
1299
- input: payload.value,
1300
- inst,
1301
- continue: !def.abort
1302
- });
1303
- };
1304
- });
1305
- const $ZodCheckNumberFormat = /*@__PURE__*/ $constructor("$ZodCheckNumberFormat", (inst, def) => {
1306
- $ZodCheck.init(inst, def);
1307
- def.format = def.format || "float64";
1308
- const isInt = def.format?.includes("int");
1309
- const origin = isInt ? "int" : "number";
1310
- const [minimum, maximum] = NUMBER_FORMAT_RANGES[def.format];
1311
- inst._zod.onattach.push((inst) => {
1312
- const bag = inst._zod.bag;
1313
- bag.format = def.format;
1314
- bag.minimum = minimum;
1315
- bag.maximum = maximum;
1316
- if (isInt) bag.pattern = integer;
1317
- });
1318
- inst._zod.check = (payload) => {
1319
- const input = payload.value;
1320
- if (isInt) {
1321
- if (!Number.isInteger(input)) {
1322
- payload.issues.push({
1323
- expected: origin,
1324
- format: def.format,
1325
- code: "invalid_type",
1326
- continue: false,
1327
- input,
1328
- inst
1329
- });
1330
- return;
1331
- }
1332
- if (!Number.isSafeInteger(input)) {
1333
- if (input > 0) payload.issues.push({
1334
- input,
1335
- code: "too_big",
1336
- maximum: Number.MAX_SAFE_INTEGER,
1337
- note: "Integers must be within the safe integer range.",
1338
- inst,
1339
- origin,
1340
- inclusive: true,
1341
- continue: !def.abort
1342
- });
1343
- else payload.issues.push({
1344
- input,
1345
- code: "too_small",
1346
- minimum: Number.MIN_SAFE_INTEGER,
1347
- note: "Integers must be within the safe integer range.",
1348
- inst,
1349
- origin,
1350
- inclusive: true,
1351
- continue: !def.abort
1352
- });
1353
- return;
1354
- }
1355
- }
1356
- if (input < minimum) payload.issues.push({
1357
- origin: "number",
1358
- input,
1359
- code: "too_small",
1360
- minimum,
1361
- inclusive: true,
1362
- inst,
1363
- continue: !def.abort
1364
- });
1365
- if (input > maximum) payload.issues.push({
1366
- origin: "number",
1367
- input,
1368
- code: "too_big",
1369
- maximum,
1370
- inclusive: true,
1371
- inst,
1372
- continue: !def.abort
1373
- });
1374
- };
1375
- });
1376
- const $ZodCheckMaxLength = /*@__PURE__*/ $constructor("$ZodCheckMaxLength", (inst, def) => {
1377
- var _a;
1378
- $ZodCheck.init(inst, def);
1379
- (_a = inst._zod.def).when ?? (_a.when = (payload) => {
1380
- const val = payload.value;
1381
- return !nullish(val) && val.length !== void 0;
1382
- });
1383
- inst._zod.onattach.push((inst) => {
1384
- const curr = inst._zod.bag.maximum ?? Number.POSITIVE_INFINITY;
1385
- if (def.maximum < curr) inst._zod.bag.maximum = def.maximum;
1386
- });
1387
- inst._zod.check = (payload) => {
1388
- const input = payload.value;
1389
- if (input.length <= def.maximum) return;
1390
- const origin = getLengthableOrigin(input);
1391
- payload.issues.push({
1392
- origin,
1393
- code: "too_big",
1394
- maximum: def.maximum,
1395
- inclusive: true,
1396
- input,
1397
- inst,
1398
- continue: !def.abort
1399
- });
1400
- };
1401
- });
1402
- const $ZodCheckMinLength = /*@__PURE__*/ $constructor("$ZodCheckMinLength", (inst, def) => {
1403
- var _a;
1404
- $ZodCheck.init(inst, def);
1405
- (_a = inst._zod.def).when ?? (_a.when = (payload) => {
1406
- const val = payload.value;
1407
- return !nullish(val) && val.length !== void 0;
1408
- });
1409
- inst._zod.onattach.push((inst) => {
1410
- const curr = inst._zod.bag.minimum ?? Number.NEGATIVE_INFINITY;
1411
- if (def.minimum > curr) inst._zod.bag.minimum = def.minimum;
1412
- });
1413
- inst._zod.check = (payload) => {
1414
- const input = payload.value;
1415
- if (input.length >= def.minimum) return;
1416
- const origin = getLengthableOrigin(input);
1417
- payload.issues.push({
1418
- origin,
1419
- code: "too_small",
1420
- minimum: def.minimum,
1421
- inclusive: true,
1422
- input,
1423
- inst,
1424
- continue: !def.abort
1425
- });
1426
- };
1427
- });
1428
- const $ZodCheckLengthEquals = /*@__PURE__*/ $constructor("$ZodCheckLengthEquals", (inst, def) => {
1429
- var _a;
1430
- $ZodCheck.init(inst, def);
1431
- (_a = inst._zod.def).when ?? (_a.when = (payload) => {
1432
- const val = payload.value;
1433
- return !nullish(val) && val.length !== void 0;
1434
- });
1435
- inst._zod.onattach.push((inst) => {
1436
- const bag = inst._zod.bag;
1437
- bag.minimum = def.length;
1438
- bag.maximum = def.length;
1439
- bag.length = def.length;
1440
- });
1441
- inst._zod.check = (payload) => {
1442
- const input = payload.value;
1443
- const length = input.length;
1444
- if (length === def.length) return;
1445
- const origin = getLengthableOrigin(input);
1446
- const tooBig = length > def.length;
1447
- payload.issues.push({
1448
- origin,
1449
- ...tooBig ? {
1450
- code: "too_big",
1451
- maximum: def.length
1452
- } : {
1453
- code: "too_small",
1454
- minimum: def.length
1455
- },
1456
- inclusive: true,
1457
- exact: true,
1458
- input: payload.value,
1459
- inst,
1460
- continue: !def.abort
1461
- });
1462
- };
1463
- });
1464
- const $ZodCheckStringFormat = /*@__PURE__*/ $constructor("$ZodCheckStringFormat", (inst, def) => {
1465
- var _a, _b;
1466
- $ZodCheck.init(inst, def);
1467
- inst._zod.onattach.push((inst) => {
1468
- const bag = inst._zod.bag;
1469
- bag.format = def.format;
1470
- if (def.pattern) {
1471
- bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
1472
- bag.patterns.add(def.pattern);
1473
- }
1474
- });
1475
- if (def.pattern) (_a = inst._zod).check ?? (_a.check = (payload) => {
1476
- def.pattern.lastIndex = 0;
1477
- if (def.pattern.test(payload.value)) return;
1478
- payload.issues.push({
1479
- origin: "string",
1480
- code: "invalid_format",
1481
- format: def.format,
1482
- input: payload.value,
1483
- ...def.pattern ? { pattern: def.pattern.toString() } : {},
1484
- inst,
1485
- continue: !def.abort
1486
- });
1487
- });
1488
- else (_b = inst._zod).check ?? (_b.check = () => {});
1489
- });
1490
- const $ZodCheckRegex = /*@__PURE__*/ $constructor("$ZodCheckRegex", (inst, def) => {
1491
- $ZodCheckStringFormat.init(inst, def);
1492
- inst._zod.check = (payload) => {
1493
- def.pattern.lastIndex = 0;
1494
- if (def.pattern.test(payload.value)) return;
1495
- payload.issues.push({
1496
- origin: "string",
1497
- code: "invalid_format",
1498
- format: "regex",
1499
- input: payload.value,
1500
- pattern: def.pattern.toString(),
1501
- inst,
1502
- continue: !def.abort
1503
- });
1504
- };
1505
- });
1506
- const $ZodCheckLowerCase = /*@__PURE__*/ $constructor("$ZodCheckLowerCase", (inst, def) => {
1507
- def.pattern ?? (def.pattern = lowercase);
1508
- $ZodCheckStringFormat.init(inst, def);
1509
- });
1510
- const $ZodCheckUpperCase = /*@__PURE__*/ $constructor("$ZodCheckUpperCase", (inst, def) => {
1511
- def.pattern ?? (def.pattern = uppercase);
1512
- $ZodCheckStringFormat.init(inst, def);
1513
- });
1514
- const $ZodCheckIncludes = /*@__PURE__*/ $constructor("$ZodCheckIncludes", (inst, def) => {
1515
- $ZodCheck.init(inst, def);
1516
- const escapedRegex = escapeRegex(def.includes);
1517
- const pattern = new RegExp(typeof def.position === "number" ? `^.{${def.position}}${escapedRegex}` : escapedRegex);
1518
- def.pattern = pattern;
1519
- inst._zod.onattach.push((inst) => {
1520
- const bag = inst._zod.bag;
1521
- bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
1522
- bag.patterns.add(pattern);
1523
- });
1524
- inst._zod.check = (payload) => {
1525
- if (payload.value.includes(def.includes, def.position)) return;
1526
- payload.issues.push({
1527
- origin: "string",
1528
- code: "invalid_format",
1529
- format: "includes",
1530
- includes: def.includes,
1531
- input: payload.value,
1532
- inst,
1533
- continue: !def.abort
1534
- });
1535
- };
1536
- });
1537
- const $ZodCheckStartsWith = /*@__PURE__*/ $constructor("$ZodCheckStartsWith", (inst, def) => {
1538
- $ZodCheck.init(inst, def);
1539
- const pattern = new RegExp(`^${escapeRegex(def.prefix)}.*`);
1540
- def.pattern ?? (def.pattern = pattern);
1541
- inst._zod.onattach.push((inst) => {
1542
- const bag = inst._zod.bag;
1543
- bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
1544
- bag.patterns.add(pattern);
1545
- });
1546
- inst._zod.check = (payload) => {
1547
- if (payload.value.startsWith(def.prefix)) return;
1548
- payload.issues.push({
1549
- origin: "string",
1550
- code: "invalid_format",
1551
- format: "starts_with",
1552
- prefix: def.prefix,
1553
- input: payload.value,
1554
- inst,
1555
- continue: !def.abort
1556
- });
1557
- };
1558
- });
1559
- const $ZodCheckEndsWith = /*@__PURE__*/ $constructor("$ZodCheckEndsWith", (inst, def) => {
1560
- $ZodCheck.init(inst, def);
1561
- const pattern = new RegExp(`.*${escapeRegex(def.suffix)}$`);
1562
- def.pattern ?? (def.pattern = pattern);
1563
- inst._zod.onattach.push((inst) => {
1564
- const bag = inst._zod.bag;
1565
- bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
1566
- bag.patterns.add(pattern);
1567
- });
1568
- inst._zod.check = (payload) => {
1569
- if (payload.value.endsWith(def.suffix)) return;
1570
- payload.issues.push({
1571
- origin: "string",
1572
- code: "invalid_format",
1573
- format: "ends_with",
1574
- suffix: def.suffix,
1575
- input: payload.value,
1576
- inst,
1577
- continue: !def.abort
1578
- });
1579
- };
1580
- });
1581
- const $ZodCheckOverwrite = /*@__PURE__*/ $constructor("$ZodCheckOverwrite", (inst, def) => {
1582
- $ZodCheck.init(inst, def);
1583
- inst._zod.check = (payload) => {
1584
- payload.value = def.tx(payload.value);
1585
- };
1586
- });
1587
- //#endregion
1588
- //#region ../../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/doc.js
1589
- var Doc = class {
1590
- constructor(args = []) {
1591
- this.content = [];
1592
- this.indent = 0;
1593
- if (this) this.args = args;
1594
- }
1595
- indented(fn) {
1596
- this.indent += 1;
1597
- fn(this);
1598
- this.indent -= 1;
1599
- }
1600
- write(arg) {
1601
- if (typeof arg === "function") {
1602
- arg(this, { execution: "sync" });
1603
- arg(this, { execution: "async" });
1604
- return;
1605
- }
1606
- const lines = arg.split("\n").filter((x) => x);
1607
- const minIndent = Math.min(...lines.map((x) => x.length - x.trimStart().length));
1608
- const dedented = lines.map((x) => x.slice(minIndent)).map((x) => " ".repeat(this.indent * 2) + x);
1609
- for (const line of dedented) this.content.push(line);
1610
- }
1611
- compile() {
1612
- const F = Function;
1613
- const args = this?.args;
1614
- const lines = [...(this?.content ?? [``]).map((x) => ` ${x}`)];
1615
- return new F(...args, lines.join("\n"));
1616
- }
1617
- };
1618
- //#endregion
1619
- //#region ../../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/versions.js
1620
- const version = {
1621
- major: 4,
1622
- minor: 4,
1623
- patch: 3
1624
- };
1625
- //#endregion
1626
- //#region ../../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/schemas.js
1627
- const $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
1628
- var _a;
1629
- inst ?? (inst = {});
1630
- inst._zod.def = def;
1631
- inst._zod.bag = inst._zod.bag || {};
1632
- inst._zod.version = version;
1633
- const checks = [...inst._zod.def.checks ?? []];
1634
- if (inst._zod.traits.has("$ZodCheck")) checks.unshift(inst);
1635
- for (const ch of checks) for (const fn of ch._zod.onattach) fn(inst);
1636
- if (checks.length === 0) {
1637
- (_a = inst._zod).deferred ?? (_a.deferred = []);
1638
- inst._zod.deferred?.push(() => {
1639
- inst._zod.run = inst._zod.parse;
1640
- });
1641
- } else {
1642
- const runChecks = (payload, checks, ctx) => {
1643
- let isAborted = aborted(payload);
1644
- let asyncResult;
1645
- for (const ch of checks) {
1646
- if (ch._zod.def.when) {
1647
- if (explicitlyAborted(payload)) continue;
1648
- if (!ch._zod.def.when(payload)) continue;
1649
- } else if (isAborted) continue;
1650
- const currLen = payload.issues.length;
1651
- const _ = ch._zod.check(payload);
1652
- if (_ instanceof Promise && ctx?.async === false) throw new $ZodAsyncError();
1653
- if (asyncResult || _ instanceof Promise) asyncResult = (asyncResult ?? Promise.resolve()).then(async () => {
1654
- await _;
1655
- if (payload.issues.length === currLen) return;
1656
- if (!isAborted) isAborted = aborted(payload, currLen);
1657
- });
1658
- else {
1659
- if (payload.issues.length === currLen) continue;
1660
- if (!isAborted) isAborted = aborted(payload, currLen);
1661
- }
1662
- }
1663
- if (asyncResult) return asyncResult.then(() => {
1664
- return payload;
1665
- });
1666
- return payload;
1667
- };
1668
- const handleCanaryResult = (canary, payload, ctx) => {
1669
- if (aborted(canary)) {
1670
- canary.aborted = true;
1671
- return canary;
1672
- }
1673
- const checkResult = runChecks(payload, checks, ctx);
1674
- if (checkResult instanceof Promise) {
1675
- if (ctx.async === false) throw new $ZodAsyncError();
1676
- return checkResult.then((checkResult) => inst._zod.parse(checkResult, ctx));
1677
- }
1678
- return inst._zod.parse(checkResult, ctx);
1679
- };
1680
- inst._zod.run = (payload, ctx) => {
1681
- if (ctx.skipChecks) return inst._zod.parse(payload, ctx);
1682
- if (ctx.direction === "backward") {
1683
- const canary = inst._zod.parse({
1684
- value: payload.value,
1685
- issues: []
1686
- }, {
1687
- ...ctx,
1688
- skipChecks: true
1689
- });
1690
- if (canary instanceof Promise) return canary.then((canary) => {
1691
- return handleCanaryResult(canary, payload, ctx);
1692
- });
1693
- return handleCanaryResult(canary, payload, ctx);
1694
- }
1695
- const result = inst._zod.parse(payload, ctx);
1696
- if (result instanceof Promise) {
1697
- if (ctx.async === false) throw new $ZodAsyncError();
1698
- return result.then((result) => runChecks(result, checks, ctx));
1699
- }
1700
- return runChecks(result, checks, ctx);
1701
- };
1702
- }
1703
- defineLazy(inst, "~standard", () => ({
1704
- validate: (value) => {
1705
- try {
1706
- const r = safeParse$1(inst, value);
1707
- return r.success ? { value: r.data } : { issues: r.error?.issues };
1708
- } catch (_) {
1709
- return safeParseAsync$1(inst, value).then((r) => r.success ? { value: r.data } : { issues: r.error?.issues });
1710
- }
1711
- },
1712
- vendor: "zod",
1713
- version: 1
1714
- }));
1715
- });
1716
- const $ZodString = /*@__PURE__*/ $constructor("$ZodString", (inst, def) => {
1717
- $ZodType.init(inst, def);
1718
- inst._zod.pattern = [...inst?._zod.bag?.patterns ?? []].pop() ?? string$1(inst._zod.bag);
1719
- inst._zod.parse = (payload, _) => {
1720
- if (def.coerce) try {
1721
- payload.value = String(payload.value);
1722
- } catch (_) {}
1723
- if (typeof payload.value === "string") return payload;
1724
- payload.issues.push({
1725
- expected: "string",
1726
- code: "invalid_type",
1727
- input: payload.value,
1728
- inst
1729
- });
1730
- return payload;
1731
- };
1732
- });
1733
- const $ZodStringFormat = /*@__PURE__*/ $constructor("$ZodStringFormat", (inst, def) => {
1734
- $ZodCheckStringFormat.init(inst, def);
1735
- $ZodString.init(inst, def);
1736
- });
1737
- const $ZodGUID = /*@__PURE__*/ $constructor("$ZodGUID", (inst, def) => {
1738
- def.pattern ?? (def.pattern = guid);
1739
- $ZodStringFormat.init(inst, def);
1740
- });
1741
- const $ZodUUID = /*@__PURE__*/ $constructor("$ZodUUID", (inst, def) => {
1742
- if (def.version) {
1743
- const v = {
1744
- v1: 1,
1745
- v2: 2,
1746
- v3: 3,
1747
- v4: 4,
1748
- v5: 5,
1749
- v6: 6,
1750
- v7: 7,
1751
- v8: 8
1752
- }[def.version];
1753
- if (v === void 0) throw new Error(`Invalid UUID version: "${def.version}"`);
1754
- def.pattern ?? (def.pattern = uuid(v));
1755
- } else def.pattern ?? (def.pattern = uuid());
1756
- $ZodStringFormat.init(inst, def);
1757
- });
1758
- const $ZodEmail = /*@__PURE__*/ $constructor("$ZodEmail", (inst, def) => {
1759
- def.pattern ?? (def.pattern = email);
1760
- $ZodStringFormat.init(inst, def);
1761
- });
1762
- const $ZodURL = /*@__PURE__*/ $constructor("$ZodURL", (inst, def) => {
1763
- $ZodStringFormat.init(inst, def);
1764
- inst._zod.check = (payload) => {
1765
- try {
1766
- const trimmed = payload.value.trim();
1767
- if (!def.normalize && def.protocol?.source === httpProtocol.source) {
1768
- if (!/^https?:\/\//i.test(trimmed)) {
1769
- payload.issues.push({
1770
- code: "invalid_format",
1771
- format: "url",
1772
- note: "Invalid URL format",
1773
- input: payload.value,
1774
- inst,
1775
- continue: !def.abort
1776
- });
1777
- return;
1778
- }
1779
- }
1780
- const url = new URL(trimmed);
1781
- if (def.hostname) {
1782
- def.hostname.lastIndex = 0;
1783
- if (!def.hostname.test(url.hostname)) payload.issues.push({
1784
- code: "invalid_format",
1785
- format: "url",
1786
- note: "Invalid hostname",
1787
- pattern: def.hostname.source,
1788
- input: payload.value,
1789
- inst,
1790
- continue: !def.abort
1791
- });
1792
- }
1793
- if (def.protocol) {
1794
- def.protocol.lastIndex = 0;
1795
- if (!def.protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol)) payload.issues.push({
1796
- code: "invalid_format",
1797
- format: "url",
1798
- note: "Invalid protocol",
1799
- pattern: def.protocol.source,
1800
- input: payload.value,
1801
- inst,
1802
- continue: !def.abort
1803
- });
1804
- }
1805
- if (def.normalize) payload.value = url.href;
1806
- else payload.value = trimmed;
1807
- return;
1808
- } catch (_) {
1809
- payload.issues.push({
1810
- code: "invalid_format",
1811
- format: "url",
1812
- input: payload.value,
1813
- inst,
1814
- continue: !def.abort
1815
- });
1816
- }
1817
- };
1818
- });
1819
- const $ZodEmoji = /*@__PURE__*/ $constructor("$ZodEmoji", (inst, def) => {
1820
- def.pattern ?? (def.pattern = emoji());
1821
- $ZodStringFormat.init(inst, def);
1822
- });
1823
- const $ZodNanoID = /*@__PURE__*/ $constructor("$ZodNanoID", (inst, def) => {
1824
- def.pattern ?? (def.pattern = nanoid);
1825
- $ZodStringFormat.init(inst, def);
1826
- });
1827
- /**
1828
- * @deprecated CUID v1 is deprecated by its authors due to information leakage
1829
- * (timestamps embedded in the id). Use {@link $ZodCUID2} instead.
1830
- * See https://github.com/paralleldrive/cuid.
1831
- */
1832
- const $ZodCUID = /*@__PURE__*/ $constructor("$ZodCUID", (inst, def) => {
1833
- def.pattern ?? (def.pattern = cuid);
1834
- $ZodStringFormat.init(inst, def);
1835
- });
1836
- const $ZodCUID2 = /*@__PURE__*/ $constructor("$ZodCUID2", (inst, def) => {
1837
- def.pattern ?? (def.pattern = cuid2);
1838
- $ZodStringFormat.init(inst, def);
1839
- });
1840
- const $ZodULID = /*@__PURE__*/ $constructor("$ZodULID", (inst, def) => {
1841
- def.pattern ?? (def.pattern = ulid);
1842
- $ZodStringFormat.init(inst, def);
1843
- });
1844
- const $ZodXID = /*@__PURE__*/ $constructor("$ZodXID", (inst, def) => {
1845
- def.pattern ?? (def.pattern = xid);
1846
- $ZodStringFormat.init(inst, def);
1847
- });
1848
- const $ZodKSUID = /*@__PURE__*/ $constructor("$ZodKSUID", (inst, def) => {
1849
- def.pattern ?? (def.pattern = ksuid);
1850
- $ZodStringFormat.init(inst, def);
1851
- });
1852
- const $ZodISODateTime = /*@__PURE__*/ $constructor("$ZodISODateTime", (inst, def) => {
1853
- def.pattern ?? (def.pattern = datetime$1(def));
1854
- $ZodStringFormat.init(inst, def);
1855
- });
1856
- const $ZodISODate = /*@__PURE__*/ $constructor("$ZodISODate", (inst, def) => {
1857
- def.pattern ?? (def.pattern = date$1);
1858
- $ZodStringFormat.init(inst, def);
1859
- });
1860
- const $ZodISOTime = /*@__PURE__*/ $constructor("$ZodISOTime", (inst, def) => {
1861
- def.pattern ?? (def.pattern = time$1(def));
1862
- $ZodStringFormat.init(inst, def);
1863
- });
1864
- const $ZodISODuration = /*@__PURE__*/ $constructor("$ZodISODuration", (inst, def) => {
1865
- def.pattern ?? (def.pattern = duration$1);
1866
- $ZodStringFormat.init(inst, def);
1867
- });
1868
- const $ZodIPv4 = /*@__PURE__*/ $constructor("$ZodIPv4", (inst, def) => {
1869
- def.pattern ?? (def.pattern = ipv4);
1870
- $ZodStringFormat.init(inst, def);
1871
- inst._zod.bag.format = `ipv4`;
1872
- });
1873
- const $ZodIPv6 = /*@__PURE__*/ $constructor("$ZodIPv6", (inst, def) => {
1874
- def.pattern ?? (def.pattern = ipv6);
1875
- $ZodStringFormat.init(inst, def);
1876
- inst._zod.bag.format = `ipv6`;
1877
- inst._zod.check = (payload) => {
1878
- try {
1879
- new URL(`http://[${payload.value}]`);
1880
- } catch {
1881
- payload.issues.push({
1882
- code: "invalid_format",
1883
- format: "ipv6",
1884
- input: payload.value,
1885
- inst,
1886
- continue: !def.abort
1887
- });
1888
- }
1889
- };
1890
- });
1891
- const $ZodCIDRv4 = /*@__PURE__*/ $constructor("$ZodCIDRv4", (inst, def) => {
1892
- def.pattern ?? (def.pattern = cidrv4);
1893
- $ZodStringFormat.init(inst, def);
1894
- });
1895
- const $ZodCIDRv6 = /*@__PURE__*/ $constructor("$ZodCIDRv6", (inst, def) => {
1896
- def.pattern ?? (def.pattern = cidrv6);
1897
- $ZodStringFormat.init(inst, def);
1898
- inst._zod.check = (payload) => {
1899
- const parts = payload.value.split("/");
1900
- try {
1901
- if (parts.length !== 2) throw new Error();
1902
- const [address, prefix] = parts;
1903
- if (!prefix) throw new Error();
1904
- const prefixNum = Number(prefix);
1905
- if (`${prefixNum}` !== prefix) throw new Error();
1906
- if (prefixNum < 0 || prefixNum > 128) throw new Error();
1907
- new URL(`http://[${address}]`);
1908
- } catch {
1909
- payload.issues.push({
1910
- code: "invalid_format",
1911
- format: "cidrv6",
1912
- input: payload.value,
1913
- inst,
1914
- continue: !def.abort
1915
- });
1916
- }
1917
- };
1918
- });
1919
- function isValidBase64(data) {
1920
- if (data === "") return true;
1921
- if (/\s/.test(data)) return false;
1922
- if (data.length % 4 !== 0) return false;
1923
- try {
1924
- atob(data);
1925
- return true;
1926
- } catch {
1927
- return false;
1928
- }
1929
- }
1930
- const $ZodBase64 = /*@__PURE__*/ $constructor("$ZodBase64", (inst, def) => {
1931
- def.pattern ?? (def.pattern = base64);
1932
- $ZodStringFormat.init(inst, def);
1933
- inst._zod.bag.contentEncoding = "base64";
1934
- inst._zod.check = (payload) => {
1935
- if (isValidBase64(payload.value)) return;
1936
- payload.issues.push({
1937
- code: "invalid_format",
1938
- format: "base64",
1939
- input: payload.value,
1940
- inst,
1941
- continue: !def.abort
1942
- });
1943
- };
1944
- });
1945
- function isValidBase64URL(data) {
1946
- if (!base64url.test(data)) return false;
1947
- const base64 = data.replace(/[-_]/g, (c) => c === "-" ? "+" : "/");
1948
- return isValidBase64(base64.padEnd(Math.ceil(base64.length / 4) * 4, "="));
1949
- }
1950
- const $ZodBase64URL = /*@__PURE__*/ $constructor("$ZodBase64URL", (inst, def) => {
1951
- def.pattern ?? (def.pattern = base64url);
1952
- $ZodStringFormat.init(inst, def);
1953
- inst._zod.bag.contentEncoding = "base64url";
1954
- inst._zod.check = (payload) => {
1955
- if (isValidBase64URL(payload.value)) return;
1956
- payload.issues.push({
1957
- code: "invalid_format",
1958
- format: "base64url",
1959
- input: payload.value,
1960
- inst,
1961
- continue: !def.abort
1962
- });
1963
- };
1964
- });
1965
- const $ZodE164 = /*@__PURE__*/ $constructor("$ZodE164", (inst, def) => {
1966
- def.pattern ?? (def.pattern = e164);
1967
- $ZodStringFormat.init(inst, def);
1968
- });
1969
- function isValidJWT(token, algorithm = null) {
1970
- try {
1971
- const tokensParts = token.split(".");
1972
- if (tokensParts.length !== 3) return false;
1973
- const [header] = tokensParts;
1974
- if (!header) return false;
1975
- const parsedHeader = JSON.parse(atob(header));
1976
- if ("typ" in parsedHeader && parsedHeader?.typ !== "JWT") return false;
1977
- if (!parsedHeader.alg) return false;
1978
- if (algorithm && (!("alg" in parsedHeader) || parsedHeader.alg !== algorithm)) return false;
1979
- return true;
1980
- } catch {
1981
- return false;
1982
- }
1983
- }
1984
- const $ZodJWT = /*@__PURE__*/ $constructor("$ZodJWT", (inst, def) => {
1985
- $ZodStringFormat.init(inst, def);
1986
- inst._zod.check = (payload) => {
1987
- if (isValidJWT(payload.value, def.alg)) return;
1988
- payload.issues.push({
1989
- code: "invalid_format",
1990
- format: "jwt",
1991
- input: payload.value,
1992
- inst,
1993
- continue: !def.abort
1994
- });
1995
- };
1996
- });
1997
- const $ZodNumber = /*@__PURE__*/ $constructor("$ZodNumber", (inst, def) => {
1998
- $ZodType.init(inst, def);
1999
- inst._zod.pattern = inst._zod.bag.pattern ?? number$1;
2000
- inst._zod.parse = (payload, _ctx) => {
2001
- if (def.coerce) try {
2002
- payload.value = Number(payload.value);
2003
- } catch (_) {}
2004
- const input = payload.value;
2005
- if (typeof input === "number" && !Number.isNaN(input) && Number.isFinite(input)) return payload;
2006
- const received = typeof input === "number" ? Number.isNaN(input) ? "NaN" : !Number.isFinite(input) ? "Infinity" : void 0 : void 0;
2007
- payload.issues.push({
2008
- expected: "number",
2009
- code: "invalid_type",
2010
- input,
2011
- inst,
2012
- ...received ? { received } : {}
2013
- });
2014
- return payload;
2015
- };
2016
- });
2017
- const $ZodNumberFormat = /*@__PURE__*/ $constructor("$ZodNumberFormat", (inst, def) => {
2018
- $ZodCheckNumberFormat.init(inst, def);
2019
- $ZodNumber.init(inst, def);
2020
- });
2021
- const $ZodUnknown = /*@__PURE__*/ $constructor("$ZodUnknown", (inst, def) => {
2022
- $ZodType.init(inst, def);
2023
- inst._zod.parse = (payload) => payload;
2024
- });
2025
- const $ZodNever = /*@__PURE__*/ $constructor("$ZodNever", (inst, def) => {
2026
- $ZodType.init(inst, def);
2027
- inst._zod.parse = (payload, _ctx) => {
2028
- payload.issues.push({
2029
- expected: "never",
2030
- code: "invalid_type",
2031
- input: payload.value,
2032
- inst
2033
- });
2034
- return payload;
2035
- };
2036
- });
2037
- function handleArrayResult(result, final, index) {
2038
- if (result.issues.length) final.issues.push(...prefixIssues(index, result.issues));
2039
- final.value[index] = result.value;
2040
- }
2041
- const $ZodArray = /*@__PURE__*/ $constructor("$ZodArray", (inst, def) => {
2042
- $ZodType.init(inst, def);
2043
- inst._zod.parse = (payload, ctx) => {
2044
- const input = payload.value;
2045
- if (!Array.isArray(input)) {
2046
- payload.issues.push({
2047
- expected: "array",
2048
- code: "invalid_type",
2049
- input,
2050
- inst
2051
- });
2052
- return payload;
2053
- }
2054
- payload.value = Array(input.length);
2055
- const proms = [];
2056
- for (let i = 0; i < input.length; i++) {
2057
- const item = input[i];
2058
- const result = def.element._zod.run({
2059
- value: item,
2060
- issues: []
2061
- }, ctx);
2062
- if (result instanceof Promise) proms.push(result.then((result) => handleArrayResult(result, payload, i)));
2063
- else handleArrayResult(result, payload, i);
2064
- }
2065
- if (proms.length) return Promise.all(proms).then(() => payload);
2066
- return payload;
2067
- };
2068
- });
2069
- function handlePropertyResult(result, final, key, input, isOptionalIn, isOptionalOut) {
2070
- const isPresent = key in input;
2071
- if (result.issues.length) {
2072
- if (isOptionalIn && isOptionalOut && !isPresent) return;
2073
- final.issues.push(...prefixIssues(key, result.issues));
2074
- }
2075
- if (!isPresent && !isOptionalIn) {
2076
- if (!result.issues.length) final.issues.push({
2077
- code: "invalid_type",
2078
- expected: "nonoptional",
2079
- input: void 0,
2080
- path: [key]
2081
- });
2082
- return;
2083
- }
2084
- if (result.value === void 0) {
2085
- if (isPresent) final.value[key] = void 0;
2086
- } else final.value[key] = result.value;
2087
- }
2088
- function normalizeDef(def) {
2089
- const keys = Object.keys(def.shape);
2090
- for (const k of keys) if (!def.shape?.[k]?._zod?.traits?.has("$ZodType")) throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
2091
- const okeys = optionalKeys(def.shape);
2092
- return {
2093
- ...def,
2094
- keys,
2095
- keySet: new Set(keys),
2096
- numKeys: keys.length,
2097
- optionalKeys: new Set(okeys)
2098
- };
2099
- }
2100
- function handleCatchall(proms, input, payload, ctx, def, inst) {
2101
- const unrecognized = [];
2102
- const keySet = def.keySet;
2103
- const _catchall = def.catchall._zod;
2104
- const t = _catchall.def.type;
2105
- const isOptionalIn = _catchall.optin === "optional";
2106
- const isOptionalOut = _catchall.optout === "optional";
2107
- for (const key in input) {
2108
- if (key === "__proto__") continue;
2109
- if (keySet.has(key)) continue;
2110
- if (t === "never") {
2111
- unrecognized.push(key);
2112
- continue;
2113
- }
2114
- const r = _catchall.run({
2115
- value: input[key],
2116
- issues: []
2117
- }, ctx);
2118
- if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut)));
2119
- else handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut);
2120
- }
2121
- if (unrecognized.length) payload.issues.push({
2122
- code: "unrecognized_keys",
2123
- keys: unrecognized,
2124
- input,
2125
- inst
2126
- });
2127
- if (!proms.length) return payload;
2128
- return Promise.all(proms).then(() => {
2129
- return payload;
2130
- });
2131
- }
2132
- const $ZodObject = /*@__PURE__*/ $constructor("$ZodObject", (inst, def) => {
2133
- $ZodType.init(inst, def);
2134
- if (!Object.getOwnPropertyDescriptor(def, "shape")?.get) {
2135
- const sh = def.shape;
2136
- Object.defineProperty(def, "shape", { get: () => {
2137
- const newSh = { ...sh };
2138
- Object.defineProperty(def, "shape", { value: newSh });
2139
- return newSh;
2140
- } });
2141
- }
2142
- const _normalized = cached(() => normalizeDef(def));
2143
- defineLazy(inst._zod, "propValues", () => {
2144
- const shape = def.shape;
2145
- const propValues = {};
2146
- for (const key in shape) {
2147
- const field = shape[key]._zod;
2148
- if (field.values) {
2149
- propValues[key] ?? (propValues[key] = /* @__PURE__ */ new Set());
2150
- for (const v of field.values) propValues[key].add(v);
2151
- }
2152
- }
2153
- return propValues;
2154
- });
2155
- const isObject$1 = isObject;
2156
- const catchall = def.catchall;
2157
- let value;
2158
- inst._zod.parse = (payload, ctx) => {
2159
- value ?? (value = _normalized.value);
2160
- const input = payload.value;
2161
- if (!isObject$1(input)) {
2162
- payload.issues.push({
2163
- expected: "object",
2164
- code: "invalid_type",
2165
- input,
2166
- inst
2167
- });
2168
- return payload;
2169
- }
2170
- payload.value = {};
2171
- const proms = [];
2172
- const shape = value.shape;
2173
- for (const key of value.keys) {
2174
- const el = shape[key];
2175
- const isOptionalIn = el._zod.optin === "optional";
2176
- const isOptionalOut = el._zod.optout === "optional";
2177
- const r = el._zod.run({
2178
- value: input[key],
2179
- issues: []
2180
- }, ctx);
2181
- if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut)));
2182
- else handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut);
2183
- }
2184
- if (!catchall) return proms.length ? Promise.all(proms).then(() => payload) : payload;
2185
- return handleCatchall(proms, input, payload, ctx, _normalized.value, inst);
2186
- };
2187
- });
2188
- const $ZodObjectJIT = /*@__PURE__*/ $constructor("$ZodObjectJIT", (inst, def) => {
2189
- $ZodObject.init(inst, def);
2190
- const superParse = inst._zod.parse;
2191
- const _normalized = cached(() => normalizeDef(def));
2192
- const generateFastpass = (shape) => {
2193
- const doc = new Doc([
2194
- "shape",
2195
- "payload",
2196
- "ctx"
2197
- ]);
2198
- const normalized = _normalized.value;
2199
- const parseStr = (key) => {
2200
- const k = esc(key);
2201
- return `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
2202
- };
2203
- doc.write(`const input = payload.value;`);
2204
- const ids = Object.create(null);
2205
- let counter = 0;
2206
- for (const key of normalized.keys) ids[key] = `key_${counter++}`;
2207
- doc.write(`const newResult = {};`);
2208
- for (const key of normalized.keys) {
2209
- const id = ids[key];
2210
- const k = esc(key);
2211
- const schema = shape[key];
2212
- const isOptionalIn = schema?._zod?.optin === "optional";
2213
- const isOptionalOut = schema?._zod?.optout === "optional";
2214
- doc.write(`const ${id} = ${parseStr(key)};`);
2215
- if (isOptionalIn && isOptionalOut) doc.write(`
2216
- if (${id}.issues.length) {
2217
- if (${k} in input) {
2218
- payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
2219
- ...iss,
2220
- path: iss.path ? [${k}, ...iss.path] : [${k}]
2221
- })));
2222
- }
2223
- }
2224
-
2225
- if (${id}.value === undefined) {
2226
- if (${k} in input) {
2227
- newResult[${k}] = undefined;
2228
- }
2229
- } else {
2230
- newResult[${k}] = ${id}.value;
2231
- }
2232
-
2233
- `);
2234
- else if (!isOptionalIn) doc.write(`
2235
- const ${id}_present = ${k} in input;
2236
- if (${id}.issues.length) {
2237
- payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
2238
- ...iss,
2239
- path: iss.path ? [${k}, ...iss.path] : [${k}]
2240
- })));
2241
- }
2242
- if (!${id}_present && !${id}.issues.length) {
2243
- payload.issues.push({
2244
- code: "invalid_type",
2245
- expected: "nonoptional",
2246
- input: undefined,
2247
- path: [${k}]
2248
- });
2249
- }
2250
-
2251
- if (${id}_present) {
2252
- if (${id}.value === undefined) {
2253
- newResult[${k}] = undefined;
2254
- } else {
2255
- newResult[${k}] = ${id}.value;
2256
- }
2257
- }
2258
-
2259
- `);
2260
- else doc.write(`
2261
- if (${id}.issues.length) {
2262
- payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
2263
- ...iss,
2264
- path: iss.path ? [${k}, ...iss.path] : [${k}]
2265
- })));
2266
- }
2267
-
2268
- if (${id}.value === undefined) {
2269
- if (${k} in input) {
2270
- newResult[${k}] = undefined;
2271
- }
2272
- } else {
2273
- newResult[${k}] = ${id}.value;
2274
- }
2275
-
2276
- `);
2277
- }
2278
- doc.write(`payload.value = newResult;`);
2279
- doc.write(`return payload;`);
2280
- const fn = doc.compile();
2281
- return (payload, ctx) => fn(shape, payload, ctx);
2282
- };
2283
- let fastpass;
2284
- const isObject$2 = isObject;
2285
- const jit = !globalConfig.jitless;
2286
- const fastEnabled = jit && allowsEval.value;
2287
- const catchall = def.catchall;
2288
- let value;
2289
- inst._zod.parse = (payload, ctx) => {
2290
- value ?? (value = _normalized.value);
2291
- const input = payload.value;
2292
- if (!isObject$2(input)) {
2293
- payload.issues.push({
2294
- expected: "object",
2295
- code: "invalid_type",
2296
- input,
2297
- inst
2298
- });
2299
- return payload;
2300
- }
2301
- if (jit && fastEnabled && ctx?.async === false && ctx.jitless !== true) {
2302
- if (!fastpass) fastpass = generateFastpass(def.shape);
2303
- payload = fastpass(payload, ctx);
2304
- if (!catchall) return payload;
2305
- return handleCatchall([], input, payload, ctx, value, inst);
2306
- }
2307
- return superParse(payload, ctx);
2308
- };
2309
- });
2310
- function handleUnionResults(results, final, inst, ctx) {
2311
- for (const result of results) if (result.issues.length === 0) {
2312
- final.value = result.value;
2313
- return final;
2314
- }
2315
- const nonaborted = results.filter((r) => !aborted(r));
2316
- if (nonaborted.length === 1) {
2317
- final.value = nonaborted[0].value;
2318
- return nonaborted[0];
2319
- }
2320
- final.issues.push({
2321
- code: "invalid_union",
2322
- input: final.value,
2323
- inst,
2324
- errors: results.map((result) => result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
2325
- });
2326
- return final;
2327
- }
2328
- const $ZodUnion = /*@__PURE__*/ $constructor("$ZodUnion", (inst, def) => {
2329
- $ZodType.init(inst, def);
2330
- defineLazy(inst._zod, "optin", () => def.options.some((o) => o._zod.optin === "optional") ? "optional" : void 0);
2331
- defineLazy(inst._zod, "optout", () => def.options.some((o) => o._zod.optout === "optional") ? "optional" : void 0);
2332
- defineLazy(inst._zod, "values", () => {
2333
- if (def.options.every((o) => o._zod.values)) return new Set(def.options.flatMap((option) => Array.from(option._zod.values)));
2334
- });
2335
- defineLazy(inst._zod, "pattern", () => {
2336
- if (def.options.every((o) => o._zod.pattern)) {
2337
- const patterns = def.options.map((o) => o._zod.pattern);
2338
- return new RegExp(`^(${patterns.map((p) => cleanRegex(p.source)).join("|")})$`);
2339
- }
2340
- });
2341
- const first = def.options.length === 1 ? def.options[0]._zod.run : null;
2342
- inst._zod.parse = (payload, ctx) => {
2343
- if (first) return first(payload, ctx);
2344
- let async = false;
2345
- const results = [];
2346
- for (const option of def.options) {
2347
- const result = option._zod.run({
2348
- value: payload.value,
2349
- issues: []
2350
- }, ctx);
2351
- if (result instanceof Promise) {
2352
- results.push(result);
2353
- async = true;
2354
- } else {
2355
- if (result.issues.length === 0) return result;
2356
- results.push(result);
2357
- }
2358
- }
2359
- if (!async) return handleUnionResults(results, payload, inst, ctx);
2360
- return Promise.all(results).then((results) => {
2361
- return handleUnionResults(results, payload, inst, ctx);
2362
- });
2363
- };
2364
- });
2365
- const $ZodIntersection = /*@__PURE__*/ $constructor("$ZodIntersection", (inst, def) => {
2366
- $ZodType.init(inst, def);
2367
- inst._zod.parse = (payload, ctx) => {
2368
- const input = payload.value;
2369
- const left = def.left._zod.run({
2370
- value: input,
2371
- issues: []
2372
- }, ctx);
2373
- const right = def.right._zod.run({
2374
- value: input,
2375
- issues: []
2376
- }, ctx);
2377
- if (left instanceof Promise || right instanceof Promise) return Promise.all([left, right]).then(([left, right]) => {
2378
- return handleIntersectionResults(payload, left, right);
2379
- });
2380
- return handleIntersectionResults(payload, left, right);
2381
- };
2382
- });
2383
- function mergeValues(a, b) {
2384
- if (a === b) return {
2385
- valid: true,
2386
- data: a
2387
- };
2388
- if (a instanceof Date && b instanceof Date && +a === +b) return {
2389
- valid: true,
2390
- data: a
2391
- };
2392
- if (isPlainObject(a) && isPlainObject(b)) {
2393
- const bKeys = Object.keys(b);
2394
- const sharedKeys = Object.keys(a).filter((key) => bKeys.indexOf(key) !== -1);
2395
- const newObj = {
2396
- ...a,
2397
- ...b
2398
- };
2399
- for (const key of sharedKeys) {
2400
- const sharedValue = mergeValues(a[key], b[key]);
2401
- if (!sharedValue.valid) return {
2402
- valid: false,
2403
- mergeErrorPath: [key, ...sharedValue.mergeErrorPath]
2404
- };
2405
- newObj[key] = sharedValue.data;
2406
- }
2407
- return {
2408
- valid: true,
2409
- data: newObj
2410
- };
2411
- }
2412
- if (Array.isArray(a) && Array.isArray(b)) {
2413
- if (a.length !== b.length) return {
2414
- valid: false,
2415
- mergeErrorPath: []
2416
- };
2417
- const newArray = [];
2418
- for (let index = 0; index < a.length; index++) {
2419
- const itemA = a[index];
2420
- const itemB = b[index];
2421
- const sharedValue = mergeValues(itemA, itemB);
2422
- if (!sharedValue.valid) return {
2423
- valid: false,
2424
- mergeErrorPath: [index, ...sharedValue.mergeErrorPath]
2425
- };
2426
- newArray.push(sharedValue.data);
2427
- }
2428
- return {
2429
- valid: true,
2430
- data: newArray
2431
- };
2432
- }
2433
- return {
2434
- valid: false,
2435
- mergeErrorPath: []
2436
- };
2437
- }
2438
- function handleIntersectionResults(result, left, right) {
2439
- const unrecKeys = /* @__PURE__ */ new Map();
2440
- let unrecIssue;
2441
- for (const iss of left.issues) if (iss.code === "unrecognized_keys") {
2442
- unrecIssue ?? (unrecIssue = iss);
2443
- for (const k of iss.keys) {
2444
- if (!unrecKeys.has(k)) unrecKeys.set(k, {});
2445
- unrecKeys.get(k).l = true;
2446
- }
2447
- } else result.issues.push(iss);
2448
- for (const iss of right.issues) if (iss.code === "unrecognized_keys") for (const k of iss.keys) {
2449
- if (!unrecKeys.has(k)) unrecKeys.set(k, {});
2450
- unrecKeys.get(k).r = true;
2451
- }
2452
- else result.issues.push(iss);
2453
- const bothKeys = [...unrecKeys].filter(([, f]) => f.l && f.r).map(([k]) => k);
2454
- if (bothKeys.length && unrecIssue) result.issues.push({
2455
- ...unrecIssue,
2456
- keys: bothKeys
2457
- });
2458
- if (aborted(result)) return result;
2459
- const merged = mergeValues(left.value, right.value);
2460
- if (!merged.valid) throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(merged.mergeErrorPath)}`);
2461
- result.value = merged.data;
2462
- return result;
2463
- }
2464
- const $ZodEnum = /*@__PURE__*/ $constructor("$ZodEnum", (inst, def) => {
2465
- $ZodType.init(inst, def);
2466
- const values = getEnumValues(def.entries);
2467
- const valuesSet = new Set(values);
2468
- inst._zod.values = valuesSet;
2469
- inst._zod.pattern = new RegExp(`^(${values.filter((k) => propertyKeyTypes.has(typeof k)).map((o) => typeof o === "string" ? escapeRegex(o) : o.toString()).join("|")})$`);
2470
- inst._zod.parse = (payload, _ctx) => {
2471
- const input = payload.value;
2472
- if (valuesSet.has(input)) return payload;
2473
- payload.issues.push({
2474
- code: "invalid_value",
2475
- values,
2476
- input,
2477
- inst
2478
- });
2479
- return payload;
2480
- };
2481
- });
2482
- const $ZodTransform = /*@__PURE__*/ $constructor("$ZodTransform", (inst, def) => {
2483
- $ZodType.init(inst, def);
2484
- inst._zod.optin = "optional";
2485
- inst._zod.parse = (payload, ctx) => {
2486
- if (ctx.direction === "backward") throw new $ZodEncodeError(inst.constructor.name);
2487
- const _out = def.transform(payload.value, payload);
2488
- if (ctx.async) return (_out instanceof Promise ? _out : Promise.resolve(_out)).then((output) => {
2489
- payload.value = output;
2490
- payload.fallback = true;
2491
- return payload;
2492
- });
2493
- if (_out instanceof Promise) throw new $ZodAsyncError();
2494
- payload.value = _out;
2495
- payload.fallback = true;
2496
- return payload;
2497
- };
2498
- });
2499
- function handleOptionalResult(result, input) {
2500
- if (input === void 0 && (result.issues.length || result.fallback)) return {
2501
- issues: [],
2502
- value: void 0
2503
- };
2504
- return result;
2505
- }
2506
- const $ZodOptional = /*@__PURE__*/ $constructor("$ZodOptional", (inst, def) => {
2507
- $ZodType.init(inst, def);
2508
- inst._zod.optin = "optional";
2509
- inst._zod.optout = "optional";
2510
- defineLazy(inst._zod, "values", () => {
2511
- return def.innerType._zod.values ? new Set([...def.innerType._zod.values, void 0]) : void 0;
2512
- });
2513
- defineLazy(inst._zod, "pattern", () => {
2514
- const pattern = def.innerType._zod.pattern;
2515
- return pattern ? new RegExp(`^(${cleanRegex(pattern.source)})?$`) : void 0;
2516
- });
2517
- inst._zod.parse = (payload, ctx) => {
2518
- if (def.innerType._zod.optin === "optional") {
2519
- const input = payload.value;
2520
- const result = def.innerType._zod.run(payload, ctx);
2521
- if (result instanceof Promise) return result.then((r) => handleOptionalResult(r, input));
2522
- return handleOptionalResult(result, input);
2523
- }
2524
- if (payload.value === void 0) return payload;
2525
- return def.innerType._zod.run(payload, ctx);
2526
- };
2527
- });
2528
- const $ZodExactOptional = /*@__PURE__*/ $constructor("$ZodExactOptional", (inst, def) => {
2529
- $ZodOptional.init(inst, def);
2530
- defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2531
- defineLazy(inst._zod, "pattern", () => def.innerType._zod.pattern);
2532
- inst._zod.parse = (payload, ctx) => {
2533
- return def.innerType._zod.run(payload, ctx);
2534
- };
2535
- });
2536
- const $ZodNullable = /*@__PURE__*/ $constructor("$ZodNullable", (inst, def) => {
2537
- $ZodType.init(inst, def);
2538
- defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
2539
- defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
2540
- defineLazy(inst._zod, "pattern", () => {
2541
- const pattern = def.innerType._zod.pattern;
2542
- return pattern ? new RegExp(`^(${cleanRegex(pattern.source)}|null)$`) : void 0;
2543
- });
2544
- defineLazy(inst._zod, "values", () => {
2545
- return def.innerType._zod.values ? new Set([...def.innerType._zod.values, null]) : void 0;
2546
- });
2547
- inst._zod.parse = (payload, ctx) => {
2548
- if (payload.value === null) return payload;
2549
- return def.innerType._zod.run(payload, ctx);
2550
- };
2551
- });
2552
- const $ZodDefault = /*@__PURE__*/ $constructor("$ZodDefault", (inst, def) => {
2553
- $ZodType.init(inst, def);
2554
- inst._zod.optin = "optional";
2555
- defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2556
- inst._zod.parse = (payload, ctx) => {
2557
- if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
2558
- if (payload.value === void 0) {
2559
- payload.value = def.defaultValue;
2560
- /**
2561
- * $ZodDefault returns the default value immediately in forward direction.
2562
- * It doesn't pass the default value into the validator ("prefault"). There's no reason to pass the default value through validation. The validity of the default is enforced by TypeScript statically. Otherwise, it's the responsibility of the user to ensure the default is valid. In the case of pipes with divergent in/out types, you can specify the default on the `in` schema of your ZodPipe to set a "prefault" for the pipe. */
2563
- return payload;
2564
- }
2565
- const result = def.innerType._zod.run(payload, ctx);
2566
- if (result instanceof Promise) return result.then((result) => handleDefaultResult(result, def));
2567
- return handleDefaultResult(result, def);
2568
- };
2569
- });
2570
- function handleDefaultResult(payload, def) {
2571
- if (payload.value === void 0) payload.value = def.defaultValue;
2572
- return payload;
2573
- }
2574
- const $ZodPrefault = /*@__PURE__*/ $constructor("$ZodPrefault", (inst, def) => {
2575
- $ZodType.init(inst, def);
2576
- inst._zod.optin = "optional";
2577
- defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2578
- inst._zod.parse = (payload, ctx) => {
2579
- if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
2580
- if (payload.value === void 0) payload.value = def.defaultValue;
2581
- return def.innerType._zod.run(payload, ctx);
2582
- };
2583
- });
2584
- const $ZodNonOptional = /*@__PURE__*/ $constructor("$ZodNonOptional", (inst, def) => {
2585
- $ZodType.init(inst, def);
2586
- defineLazy(inst._zod, "values", () => {
2587
- const v = def.innerType._zod.values;
2588
- return v ? new Set([...v].filter((x) => x !== void 0)) : void 0;
2589
- });
2590
- inst._zod.parse = (payload, ctx) => {
2591
- const result = def.innerType._zod.run(payload, ctx);
2592
- if (result instanceof Promise) return result.then((result) => handleNonOptionalResult(result, inst));
2593
- return handleNonOptionalResult(result, inst);
2594
- };
2595
- });
2596
- function handleNonOptionalResult(payload, inst) {
2597
- if (!payload.issues.length && payload.value === void 0) payload.issues.push({
2598
- code: "invalid_type",
2599
- expected: "nonoptional",
2600
- input: payload.value,
2601
- inst
2602
- });
2603
- return payload;
2604
- }
2605
- const $ZodCatch = /*@__PURE__*/ $constructor("$ZodCatch", (inst, def) => {
2606
- $ZodType.init(inst, def);
2607
- inst._zod.optin = "optional";
2608
- defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
2609
- defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2610
- inst._zod.parse = (payload, ctx) => {
2611
- if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
2612
- const result = def.innerType._zod.run(payload, ctx);
2613
- if (result instanceof Promise) return result.then((result) => {
2614
- payload.value = result.value;
2615
- if (result.issues.length) {
2616
- payload.value = def.catchValue({
2617
- ...payload,
2618
- error: { issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config())) },
2619
- input: payload.value
2620
- });
2621
- payload.issues = [];
2622
- payload.fallback = true;
2623
- }
2624
- return payload;
2625
- });
2626
- payload.value = result.value;
2627
- if (result.issues.length) {
2628
- payload.value = def.catchValue({
2629
- ...payload,
2630
- error: { issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config())) },
2631
- input: payload.value
2632
- });
2633
- payload.issues = [];
2634
- payload.fallback = true;
2635
- }
2636
- return payload;
2637
- };
2638
- });
2639
- const $ZodPipe = /*@__PURE__*/ $constructor("$ZodPipe", (inst, def) => {
2640
- $ZodType.init(inst, def);
2641
- defineLazy(inst._zod, "values", () => def.in._zod.values);
2642
- defineLazy(inst._zod, "optin", () => def.in._zod.optin);
2643
- defineLazy(inst._zod, "optout", () => def.out._zod.optout);
2644
- defineLazy(inst._zod, "propValues", () => def.in._zod.propValues);
2645
- inst._zod.parse = (payload, ctx) => {
2646
- if (ctx.direction === "backward") {
2647
- const right = def.out._zod.run(payload, ctx);
2648
- if (right instanceof Promise) return right.then((right) => handlePipeResult(right, def.in, ctx));
2649
- return handlePipeResult(right, def.in, ctx);
2650
- }
2651
- const left = def.in._zod.run(payload, ctx);
2652
- if (left instanceof Promise) return left.then((left) => handlePipeResult(left, def.out, ctx));
2653
- return handlePipeResult(left, def.out, ctx);
2654
- };
2655
- });
2656
- function handlePipeResult(left, next, ctx) {
2657
- if (left.issues.length) {
2658
- left.aborted = true;
2659
- return left;
2660
- }
2661
- return next._zod.run({
2662
- value: left.value,
2663
- issues: left.issues,
2664
- fallback: left.fallback
2665
- }, ctx);
2666
- }
2667
- const $ZodReadonly = /*@__PURE__*/ $constructor("$ZodReadonly", (inst, def) => {
2668
- $ZodType.init(inst, def);
2669
- defineLazy(inst._zod, "propValues", () => def.innerType._zod.propValues);
2670
- defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2671
- defineLazy(inst._zod, "optin", () => def.innerType?._zod?.optin);
2672
- defineLazy(inst._zod, "optout", () => def.innerType?._zod?.optout);
2673
- inst._zod.parse = (payload, ctx) => {
2674
- if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
2675
- const result = def.innerType._zod.run(payload, ctx);
2676
- if (result instanceof Promise) return result.then(handleReadonlyResult);
2677
- return handleReadonlyResult(result);
2678
- };
2679
- });
2680
- function handleReadonlyResult(payload) {
2681
- payload.value = Object.freeze(payload.value);
2682
- return payload;
2683
- }
2684
- const $ZodCustom = /*@__PURE__*/ $constructor("$ZodCustom", (inst, def) => {
2685
- $ZodCheck.init(inst, def);
2686
- $ZodType.init(inst, def);
2687
- inst._zod.parse = (payload, _) => {
2688
- return payload;
2689
- };
2690
- inst._zod.check = (payload) => {
2691
- const input = payload.value;
2692
- const r = def.fn(input);
2693
- if (r instanceof Promise) return r.then((r) => handleRefineResult(r, payload, input, inst));
2694
- handleRefineResult(r, payload, input, inst);
2695
- };
2696
- });
2697
- function handleRefineResult(result, payload, input, inst) {
2698
- if (!result) {
2699
- const _iss = {
2700
- code: "custom",
2701
- input,
2702
- inst,
2703
- path: [...inst._zod.def.path ?? []],
2704
- continue: !inst._zod.def.abort
2705
- };
2706
- if (inst._zod.def.params) _iss.params = inst._zod.def.params;
2707
- payload.issues.push(issue(_iss));
2708
- }
2709
- }
2710
- //#endregion
2711
- //#region ../../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/registries.js
2712
- var _a;
2713
- var $ZodRegistry = class {
2714
- constructor() {
2715
- this._map = /* @__PURE__ */ new WeakMap();
2716
- this._idmap = /* @__PURE__ */ new Map();
2717
- }
2718
- add(schema, ..._meta) {
2719
- const meta = _meta[0];
2720
- this._map.set(schema, meta);
2721
- if (meta && typeof meta === "object" && "id" in meta) this._idmap.set(meta.id, schema);
2722
- return this;
2723
- }
2724
- clear() {
2725
- this._map = /* @__PURE__ */ new WeakMap();
2726
- this._idmap = /* @__PURE__ */ new Map();
2727
- return this;
2728
- }
2729
- remove(schema) {
2730
- const meta = this._map.get(schema);
2731
- if (meta && typeof meta === "object" && "id" in meta) this._idmap.delete(meta.id);
2732
- this._map.delete(schema);
2733
- return this;
2734
- }
2735
- get(schema) {
2736
- const p = schema._zod.parent;
2737
- if (p) {
2738
- const pm = { ...this.get(p) ?? {} };
2739
- delete pm.id;
2740
- const f = {
2741
- ...pm,
2742
- ...this._map.get(schema)
2743
- };
2744
- return Object.keys(f).length ? f : void 0;
2745
- }
2746
- return this._map.get(schema);
2747
- }
2748
- has(schema) {
2749
- return this._map.has(schema);
2750
- }
2751
- };
2752
- function registry() {
2753
- return new $ZodRegistry();
2754
- }
2755
- (_a = globalThis).__zod_globalRegistry ?? (_a.__zod_globalRegistry = registry());
2756
- const globalRegistry = globalThis.__zod_globalRegistry;
2757
- //#endregion
2758
- //#region ../../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/api.js
2759
- // @__NO_SIDE_EFFECTS__
2760
- function _string(Class, params) {
2761
- return new Class({
2762
- type: "string",
2763
- ...normalizeParams(params)
2764
- });
2765
- }
2766
- // @__NO_SIDE_EFFECTS__
2767
- function _email(Class, params) {
2768
- return new Class({
2769
- type: "string",
2770
- format: "email",
2771
- check: "string_format",
2772
- abort: false,
2773
- ...normalizeParams(params)
2774
- });
2775
- }
2776
- // @__NO_SIDE_EFFECTS__
2777
- function _guid(Class, params) {
2778
- return new Class({
2779
- type: "string",
2780
- format: "guid",
2781
- check: "string_format",
2782
- abort: false,
2783
- ...normalizeParams(params)
2784
- });
2785
- }
2786
- // @__NO_SIDE_EFFECTS__
2787
- function _uuid(Class, params) {
2788
- return new Class({
2789
- type: "string",
2790
- format: "uuid",
2791
- check: "string_format",
2792
- abort: false,
2793
- ...normalizeParams(params)
2794
- });
2795
- }
2796
- // @__NO_SIDE_EFFECTS__
2797
- function _uuidv4(Class, params) {
2798
- return new Class({
2799
- type: "string",
2800
- format: "uuid",
2801
- check: "string_format",
2802
- abort: false,
2803
- version: "v4",
2804
- ...normalizeParams(params)
2805
- });
2806
- }
2807
- // @__NO_SIDE_EFFECTS__
2808
- function _uuidv6(Class, params) {
2809
- return new Class({
2810
- type: "string",
2811
- format: "uuid",
2812
- check: "string_format",
2813
- abort: false,
2814
- version: "v6",
2815
- ...normalizeParams(params)
2816
- });
2817
- }
2818
- // @__NO_SIDE_EFFECTS__
2819
- function _uuidv7(Class, params) {
2820
- return new Class({
2821
- type: "string",
2822
- format: "uuid",
2823
- check: "string_format",
2824
- abort: false,
2825
- version: "v7",
2826
- ...normalizeParams(params)
2827
- });
2828
- }
2829
- // @__NO_SIDE_EFFECTS__
2830
- function _url(Class, params) {
2831
- return new Class({
2832
- type: "string",
2833
- format: "url",
2834
- check: "string_format",
2835
- abort: false,
2836
- ...normalizeParams(params)
2837
- });
2838
- }
2839
- // @__NO_SIDE_EFFECTS__
2840
- function _emoji(Class, params) {
2841
- return new Class({
2842
- type: "string",
2843
- format: "emoji",
2844
- check: "string_format",
2845
- abort: false,
2846
- ...normalizeParams(params)
2847
- });
2848
- }
2849
- // @__NO_SIDE_EFFECTS__
2850
- function _nanoid(Class, params) {
2851
- return new Class({
2852
- type: "string",
2853
- format: "nanoid",
2854
- check: "string_format",
2855
- abort: false,
2856
- ...normalizeParams(params)
2857
- });
2858
- }
2859
- /**
2860
- * @deprecated CUID v1 is deprecated by its authors due to information leakage
2861
- * (timestamps embedded in the id). Use {@link _cuid2} instead.
2862
- * See https://github.com/paralleldrive/cuid.
2863
- */
2864
- // @__NO_SIDE_EFFECTS__
2865
- function _cuid(Class, params) {
2866
- return new Class({
2867
- type: "string",
2868
- format: "cuid",
2869
- check: "string_format",
2870
- abort: false,
2871
- ...normalizeParams(params)
2872
- });
2873
- }
2874
- // @__NO_SIDE_EFFECTS__
2875
- function _cuid2(Class, params) {
2876
- return new Class({
2877
- type: "string",
2878
- format: "cuid2",
2879
- check: "string_format",
2880
- abort: false,
2881
- ...normalizeParams(params)
2882
- });
2883
- }
2884
- // @__NO_SIDE_EFFECTS__
2885
- function _ulid(Class, params) {
2886
- return new Class({
2887
- type: "string",
2888
- format: "ulid",
2889
- check: "string_format",
2890
- abort: false,
2891
- ...normalizeParams(params)
2892
- });
2893
- }
2894
- // @__NO_SIDE_EFFECTS__
2895
- function _xid(Class, params) {
2896
- return new Class({
2897
- type: "string",
2898
- format: "xid",
2899
- check: "string_format",
2900
- abort: false,
2901
- ...normalizeParams(params)
2902
- });
2903
- }
2904
- // @__NO_SIDE_EFFECTS__
2905
- function _ksuid(Class, params) {
2906
- return new Class({
2907
- type: "string",
2908
- format: "ksuid",
2909
- check: "string_format",
2910
- abort: false,
2911
- ...normalizeParams(params)
2912
- });
2913
- }
2914
- // @__NO_SIDE_EFFECTS__
2915
- function _ipv4(Class, params) {
2916
- return new Class({
2917
- type: "string",
2918
- format: "ipv4",
2919
- check: "string_format",
2920
- abort: false,
2921
- ...normalizeParams(params)
2922
- });
2923
- }
2924
- // @__NO_SIDE_EFFECTS__
2925
- function _ipv6(Class, params) {
2926
- return new Class({
2927
- type: "string",
2928
- format: "ipv6",
2929
- check: "string_format",
2930
- abort: false,
2931
- ...normalizeParams(params)
2932
- });
2933
- }
2934
- // @__NO_SIDE_EFFECTS__
2935
- function _cidrv4(Class, params) {
2936
- return new Class({
2937
- type: "string",
2938
- format: "cidrv4",
2939
- check: "string_format",
2940
- abort: false,
2941
- ...normalizeParams(params)
2942
- });
2943
- }
2944
- // @__NO_SIDE_EFFECTS__
2945
- function _cidrv6(Class, params) {
2946
- return new Class({
2947
- type: "string",
2948
- format: "cidrv6",
2949
- check: "string_format",
2950
- abort: false,
2951
- ...normalizeParams(params)
2952
- });
2953
- }
2954
- // @__NO_SIDE_EFFECTS__
2955
- function _base64(Class, params) {
2956
- return new Class({
2957
- type: "string",
2958
- format: "base64",
2959
- check: "string_format",
2960
- abort: false,
2961
- ...normalizeParams(params)
2962
- });
2963
- }
2964
- // @__NO_SIDE_EFFECTS__
2965
- function _base64url(Class, params) {
2966
- return new Class({
2967
- type: "string",
2968
- format: "base64url",
2969
- check: "string_format",
2970
- abort: false,
2971
- ...normalizeParams(params)
2972
- });
2973
- }
2974
- // @__NO_SIDE_EFFECTS__
2975
- function _e164(Class, params) {
2976
- return new Class({
2977
- type: "string",
2978
- format: "e164",
2979
- check: "string_format",
2980
- abort: false,
2981
- ...normalizeParams(params)
2982
- });
2983
- }
2984
- // @__NO_SIDE_EFFECTS__
2985
- function _jwt(Class, params) {
2986
- return new Class({
2987
- type: "string",
2988
- format: "jwt",
2989
- check: "string_format",
2990
- abort: false,
2991
- ...normalizeParams(params)
2992
- });
2993
- }
2994
- // @__NO_SIDE_EFFECTS__
2995
- function _isoDateTime(Class, params) {
2996
- return new Class({
2997
- type: "string",
2998
- format: "datetime",
2999
- check: "string_format",
3000
- offset: false,
3001
- local: false,
3002
- precision: null,
3003
- ...normalizeParams(params)
3004
- });
3005
- }
3006
- // @__NO_SIDE_EFFECTS__
3007
- function _isoDate(Class, params) {
3008
- return new Class({
3009
- type: "string",
3010
- format: "date",
3011
- check: "string_format",
3012
- ...normalizeParams(params)
3013
- });
3014
- }
3015
- // @__NO_SIDE_EFFECTS__
3016
- function _isoTime(Class, params) {
3017
- return new Class({
3018
- type: "string",
3019
- format: "time",
3020
- check: "string_format",
3021
- precision: null,
3022
- ...normalizeParams(params)
3023
- });
3024
- }
3025
- // @__NO_SIDE_EFFECTS__
3026
- function _isoDuration(Class, params) {
3027
- return new Class({
3028
- type: "string",
3029
- format: "duration",
3030
- check: "string_format",
3031
- ...normalizeParams(params)
3032
- });
3033
- }
3034
- // @__NO_SIDE_EFFECTS__
3035
- function _number(Class, params) {
3036
- return new Class({
3037
- type: "number",
3038
- checks: [],
3039
- ...normalizeParams(params)
3040
- });
3041
- }
3042
- // @__NO_SIDE_EFFECTS__
3043
- function _int(Class, params) {
3044
- return new Class({
3045
- type: "number",
3046
- check: "number_format",
3047
- abort: false,
3048
- format: "safeint",
3049
- ...normalizeParams(params)
3050
- });
3051
- }
3052
- // @__NO_SIDE_EFFECTS__
3053
- function _unknown(Class) {
3054
- return new Class({ type: "unknown" });
3055
- }
3056
- // @__NO_SIDE_EFFECTS__
3057
- function _never(Class, params) {
3058
- return new Class({
3059
- type: "never",
3060
- ...normalizeParams(params)
3061
- });
3062
- }
3063
- // @__NO_SIDE_EFFECTS__
3064
- function _lt(value, params) {
3065
- return new $ZodCheckLessThan({
3066
- check: "less_than",
3067
- ...normalizeParams(params),
3068
- value,
3069
- inclusive: false
3070
- });
3071
- }
3072
- // @__NO_SIDE_EFFECTS__
3073
- function _lte(value, params) {
3074
- return new $ZodCheckLessThan({
3075
- check: "less_than",
3076
- ...normalizeParams(params),
3077
- value,
3078
- inclusive: true
3079
- });
3080
- }
3081
- // @__NO_SIDE_EFFECTS__
3082
- function _gt(value, params) {
3083
- return new $ZodCheckGreaterThan({
3084
- check: "greater_than",
3085
- ...normalizeParams(params),
3086
- value,
3087
- inclusive: false
3088
- });
3089
- }
3090
- // @__NO_SIDE_EFFECTS__
3091
- function _gte(value, params) {
3092
- return new $ZodCheckGreaterThan({
3093
- check: "greater_than",
3094
- ...normalizeParams(params),
3095
- value,
3096
- inclusive: true
3097
- });
3098
- }
3099
- // @__NO_SIDE_EFFECTS__
3100
- function _multipleOf(value, params) {
3101
- return new $ZodCheckMultipleOf({
3102
- check: "multiple_of",
3103
- ...normalizeParams(params),
3104
- value
3105
- });
3106
- }
3107
- // @__NO_SIDE_EFFECTS__
3108
- function _maxLength(maximum, params) {
3109
- return new $ZodCheckMaxLength({
3110
- check: "max_length",
3111
- ...normalizeParams(params),
3112
- maximum
3113
- });
3114
- }
3115
- // @__NO_SIDE_EFFECTS__
3116
- function _minLength(minimum, params) {
3117
- return new $ZodCheckMinLength({
3118
- check: "min_length",
3119
- ...normalizeParams(params),
3120
- minimum
3121
- });
3122
- }
3123
- // @__NO_SIDE_EFFECTS__
3124
- function _length(length, params) {
3125
- return new $ZodCheckLengthEquals({
3126
- check: "length_equals",
3127
- ...normalizeParams(params),
3128
- length
3129
- });
3130
- }
3131
- // @__NO_SIDE_EFFECTS__
3132
- function _regex(pattern, params) {
3133
- return new $ZodCheckRegex({
3134
- check: "string_format",
3135
- format: "regex",
3136
- ...normalizeParams(params),
3137
- pattern
3138
- });
3139
- }
3140
- // @__NO_SIDE_EFFECTS__
3141
- function _lowercase(params) {
3142
- return new $ZodCheckLowerCase({
3143
- check: "string_format",
3144
- format: "lowercase",
3145
- ...normalizeParams(params)
3146
- });
3147
- }
3148
- // @__NO_SIDE_EFFECTS__
3149
- function _uppercase(params) {
3150
- return new $ZodCheckUpperCase({
3151
- check: "string_format",
3152
- format: "uppercase",
3153
- ...normalizeParams(params)
3154
- });
3155
- }
3156
- // @__NO_SIDE_EFFECTS__
3157
- function _includes(includes, params) {
3158
- return new $ZodCheckIncludes({
3159
- check: "string_format",
3160
- format: "includes",
3161
- ...normalizeParams(params),
3162
- includes
3163
- });
3164
- }
3165
- // @__NO_SIDE_EFFECTS__
3166
- function _startsWith(prefix, params) {
3167
- return new $ZodCheckStartsWith({
3168
- check: "string_format",
3169
- format: "starts_with",
3170
- ...normalizeParams(params),
3171
- prefix
3172
- });
3173
- }
3174
- // @__NO_SIDE_EFFECTS__
3175
- function _endsWith(suffix, params) {
3176
- return new $ZodCheckEndsWith({
3177
- check: "string_format",
3178
- format: "ends_with",
3179
- ...normalizeParams(params),
3180
- suffix
3181
- });
3182
- }
3183
- // @__NO_SIDE_EFFECTS__
3184
- function _overwrite(tx) {
3185
- return new $ZodCheckOverwrite({
3186
- check: "overwrite",
3187
- tx
3188
- });
3189
- }
3190
- // @__NO_SIDE_EFFECTS__
3191
- function _normalize(form) {
3192
- return /* @__PURE__ */ _overwrite((input) => input.normalize(form));
3193
- }
3194
- // @__NO_SIDE_EFFECTS__
3195
- function _trim() {
3196
- return /* @__PURE__ */ _overwrite((input) => input.trim());
3197
- }
3198
- // @__NO_SIDE_EFFECTS__
3199
- function _toLowerCase() {
3200
- return /* @__PURE__ */ _overwrite((input) => input.toLowerCase());
3201
- }
3202
- // @__NO_SIDE_EFFECTS__
3203
- function _toUpperCase() {
3204
- return /* @__PURE__ */ _overwrite((input) => input.toUpperCase());
3205
- }
3206
- // @__NO_SIDE_EFFECTS__
3207
- function _slugify() {
3208
- return /* @__PURE__ */ _overwrite((input) => slugify(input));
3209
- }
3210
- // @__NO_SIDE_EFFECTS__
3211
- function _array(Class, element, params) {
3212
- return new Class({
3213
- type: "array",
3214
- element,
3215
- ...normalizeParams(params)
3216
- });
3217
- }
3218
- // @__NO_SIDE_EFFECTS__
3219
- function _refine(Class, fn, _params) {
3220
- return new Class({
3221
- type: "custom",
3222
- check: "custom",
3223
- fn,
3224
- ...normalizeParams(_params)
3225
- });
3226
- }
3227
- // @__NO_SIDE_EFFECTS__
3228
- function _superRefine(fn, params) {
3229
- const ch = /* @__PURE__ */ _check((payload) => {
3230
- payload.addIssue = (issue$2) => {
3231
- if (typeof issue$2 === "string") payload.issues.push(issue(issue$2, payload.value, ch._zod.def));
3232
- else {
3233
- const _issue = issue$2;
3234
- if (_issue.fatal) _issue.continue = false;
3235
- _issue.code ?? (_issue.code = "custom");
3236
- _issue.input ?? (_issue.input = payload.value);
3237
- _issue.inst ?? (_issue.inst = ch);
3238
- _issue.continue ?? (_issue.continue = !ch._zod.def.abort);
3239
- payload.issues.push(issue(_issue));
3240
- }
3241
- };
3242
- return fn(payload.value, payload);
3243
- }, params);
3244
- return ch;
3245
- }
3246
- // @__NO_SIDE_EFFECTS__
3247
- function _check(fn, params) {
3248
- const ch = new $ZodCheck({
3249
- check: "custom",
3250
- ...normalizeParams(params)
3251
- });
3252
- ch._zod.check = fn;
3253
- return ch;
3254
- }
3255
- //#endregion
3256
- //#region ../../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/to-json-schema.js
3257
- function initializeContext(params) {
3258
- let target = params?.target ?? "draft-2020-12";
3259
- if (target === "draft-4") target = "draft-04";
3260
- if (target === "draft-7") target = "draft-07";
3261
- return {
3262
- processors: params.processors ?? {},
3263
- metadataRegistry: params?.metadata ?? globalRegistry,
3264
- target,
3265
- unrepresentable: params?.unrepresentable ?? "throw",
3266
- override: params?.override ?? (() => {}),
3267
- io: params?.io ?? "output",
3268
- counter: 0,
3269
- seen: /* @__PURE__ */ new Map(),
3270
- cycles: params?.cycles ?? "ref",
3271
- reused: params?.reused ?? "inline",
3272
- external: params?.external ?? void 0
3273
- };
3274
- }
3275
- function process(schema, ctx, _params = {
3276
- path: [],
3277
- schemaPath: []
3278
- }) {
3279
- var _a;
3280
- const def = schema._zod.def;
3281
- const seen = ctx.seen.get(schema);
3282
- if (seen) {
3283
- seen.count++;
3284
- if (_params.schemaPath.includes(schema)) seen.cycle = _params.path;
3285
- return seen.schema;
3286
- }
3287
- const result = {
3288
- schema: {},
3289
- count: 1,
3290
- cycle: void 0,
3291
- path: _params.path
3292
- };
3293
- ctx.seen.set(schema, result);
3294
- const overrideSchema = schema._zod.toJSONSchema?.();
3295
- if (overrideSchema) result.schema = overrideSchema;
3296
- else {
3297
- const params = {
3298
- ..._params,
3299
- schemaPath: [..._params.schemaPath, schema],
3300
- path: _params.path
3301
- };
3302
- if (schema._zod.processJSONSchema) schema._zod.processJSONSchema(ctx, result.schema, params);
3303
- else {
3304
- const _json = result.schema;
3305
- const processor = ctx.processors[def.type];
3306
- if (!processor) throw new Error(`[toJSONSchema]: Non-representable type encountered: ${def.type}`);
3307
- processor(schema, ctx, _json, params);
3308
- }
3309
- const parent = schema._zod.parent;
3310
- if (parent) {
3311
- if (!result.ref) result.ref = parent;
3312
- process(parent, ctx, params);
3313
- ctx.seen.get(parent).isParent = true;
3314
- }
3315
- }
3316
- const meta = ctx.metadataRegistry.get(schema);
3317
- if (meta) Object.assign(result.schema, meta);
3318
- if (ctx.io === "input" && isTransforming(schema)) {
3319
- delete result.schema.examples;
3320
- delete result.schema.default;
3321
- }
3322
- if (ctx.io === "input" && "_prefault" in result.schema) (_a = result.schema).default ?? (_a.default = result.schema._prefault);
3323
- delete result.schema._prefault;
3324
- return ctx.seen.get(schema).schema;
3325
- }
3326
- function extractDefs(ctx, schema) {
3327
- const root = ctx.seen.get(schema);
3328
- if (!root) throw new Error("Unprocessed schema. This is a bug in Zod.");
3329
- const idToSchema = /* @__PURE__ */ new Map();
3330
- for (const entry of ctx.seen.entries()) {
3331
- const id = ctx.metadataRegistry.get(entry[0])?.id;
3332
- if (id) {
3333
- const existing = idToSchema.get(id);
3334
- if (existing && existing !== entry[0]) throw new Error(`Duplicate schema id "${id}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);
3335
- idToSchema.set(id, entry[0]);
3336
- }
3337
- }
3338
- const makeURI = (entry) => {
3339
- const defsSegment = ctx.target === "draft-2020-12" ? "$defs" : "definitions";
3340
- if (ctx.external) {
3341
- const externalId = ctx.external.registry.get(entry[0])?.id;
3342
- const uriGenerator = ctx.external.uri ?? ((id) => id);
3343
- if (externalId) return { ref: uriGenerator(externalId) };
3344
- const id = entry[1].defId ?? entry[1].schema.id ?? `schema${ctx.counter++}`;
3345
- entry[1].defId = id;
3346
- return {
3347
- defId: id,
3348
- ref: `${uriGenerator("__shared")}#/${defsSegment}/${id}`
3349
- };
3350
- }
3351
- if (entry[1] === root) return { ref: "#" };
3352
- const defUriPrefix = `#/${defsSegment}/`;
3353
- const defId = entry[1].schema.id ?? `__schema${ctx.counter++}`;
3354
- return {
3355
- defId,
3356
- ref: defUriPrefix + defId
3357
- };
3358
- };
3359
- const extractToDef = (entry) => {
3360
- if (entry[1].schema.$ref) return;
3361
- const seen = entry[1];
3362
- const { ref, defId } = makeURI(entry);
3363
- seen.def = { ...seen.schema };
3364
- if (defId) seen.defId = defId;
3365
- const schema = seen.schema;
3366
- for (const key in schema) delete schema[key];
3367
- schema.$ref = ref;
3368
- };
3369
- if (ctx.cycles === "throw") for (const entry of ctx.seen.entries()) {
3370
- const seen = entry[1];
3371
- if (seen.cycle) throw new Error(`Cycle detected: #/${seen.cycle?.join("/")}/<root>
3372
-
3373
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`);
3374
- }
3375
- for (const entry of ctx.seen.entries()) {
3376
- const seen = entry[1];
3377
- if (schema === entry[0]) {
3378
- extractToDef(entry);
3379
- continue;
3380
- }
3381
- if (ctx.external) {
3382
- const ext = ctx.external.registry.get(entry[0])?.id;
3383
- if (schema !== entry[0] && ext) {
3384
- extractToDef(entry);
3385
- continue;
3386
- }
3387
- }
3388
- if (ctx.metadataRegistry.get(entry[0])?.id) {
3389
- extractToDef(entry);
3390
- continue;
3391
- }
3392
- if (seen.cycle) {
3393
- extractToDef(entry);
3394
- continue;
3395
- }
3396
- if (seen.count > 1) {
3397
- if (ctx.reused === "ref") {
3398
- extractToDef(entry);
3399
- continue;
3400
- }
3401
- }
3402
- }
3403
- }
3404
- function finalize(ctx, schema) {
3405
- const root = ctx.seen.get(schema);
3406
- if (!root) throw new Error("Unprocessed schema. This is a bug in Zod.");
3407
- const flattenRef = (zodSchema) => {
3408
- const seen = ctx.seen.get(zodSchema);
3409
- if (seen.ref === null) return;
3410
- const schema = seen.def ?? seen.schema;
3411
- const _cached = { ...schema };
3412
- const ref = seen.ref;
3413
- seen.ref = null;
3414
- if (ref) {
3415
- flattenRef(ref);
3416
- const refSeen = ctx.seen.get(ref);
3417
- const refSchema = refSeen.schema;
3418
- if (refSchema.$ref && (ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0")) {
3419
- schema.allOf = schema.allOf ?? [];
3420
- schema.allOf.push(refSchema);
3421
- } else Object.assign(schema, refSchema);
3422
- Object.assign(schema, _cached);
3423
- if (zodSchema._zod.parent === ref) for (const key in schema) {
3424
- if (key === "$ref" || key === "allOf") continue;
3425
- if (!(key in _cached)) delete schema[key];
3426
- }
3427
- if (refSchema.$ref && refSeen.def) for (const key in schema) {
3428
- if (key === "$ref" || key === "allOf") continue;
3429
- if (key in refSeen.def && JSON.stringify(schema[key]) === JSON.stringify(refSeen.def[key])) delete schema[key];
3430
- }
3431
- }
3432
- const parent = zodSchema._zod.parent;
3433
- if (parent && parent !== ref) {
3434
- flattenRef(parent);
3435
- const parentSeen = ctx.seen.get(parent);
3436
- if (parentSeen?.schema.$ref) {
3437
- schema.$ref = parentSeen.schema.$ref;
3438
- if (parentSeen.def) for (const key in schema) {
3439
- if (key === "$ref" || key === "allOf") continue;
3440
- if (key in parentSeen.def && JSON.stringify(schema[key]) === JSON.stringify(parentSeen.def[key])) delete schema[key];
3441
- }
3442
- }
3443
- }
3444
- ctx.override({
3445
- zodSchema,
3446
- jsonSchema: schema,
3447
- path: seen.path ?? []
3448
- });
3449
- };
3450
- for (const entry of [...ctx.seen.entries()].reverse()) flattenRef(entry[0]);
3451
- const result = {};
3452
- if (ctx.target === "draft-2020-12") result.$schema = "https://json-schema.org/draft/2020-12/schema";
3453
- else if (ctx.target === "draft-07") result.$schema = "http://json-schema.org/draft-07/schema#";
3454
- else if (ctx.target === "draft-04") result.$schema = "http://json-schema.org/draft-04/schema#";
3455
- else if (ctx.target === "openapi-3.0") {}
3456
- if (ctx.external?.uri) {
3457
- const id = ctx.external.registry.get(schema)?.id;
3458
- if (!id) throw new Error("Schema is missing an `id` property");
3459
- result.$id = ctx.external.uri(id);
3460
- }
3461
- Object.assign(result, root.def ?? root.schema);
3462
- const rootMetaId = ctx.metadataRegistry.get(schema)?.id;
3463
- if (rootMetaId !== void 0 && result.id === rootMetaId) delete result.id;
3464
- const defs = ctx.external?.defs ?? {};
3465
- for (const entry of ctx.seen.entries()) {
3466
- const seen = entry[1];
3467
- if (seen.def && seen.defId) {
3468
- if (seen.def.id === seen.defId) delete seen.def.id;
3469
- defs[seen.defId] = seen.def;
3470
- }
3471
- }
3472
- if (ctx.external) {} else if (Object.keys(defs).length > 0) if (ctx.target === "draft-2020-12") result.$defs = defs;
3473
- else result.definitions = defs;
3474
- try {
3475
- const finalized = JSON.parse(JSON.stringify(result));
3476
- Object.defineProperty(finalized, "~standard", {
3477
- value: {
3478
- ...schema["~standard"],
3479
- jsonSchema: {
3480
- input: createStandardJSONSchemaMethod(schema, "input", ctx.processors),
3481
- output: createStandardJSONSchemaMethod(schema, "output", ctx.processors)
3482
- }
3483
- },
3484
- enumerable: false,
3485
- writable: false
3486
- });
3487
- return finalized;
3488
- } catch (_err) {
3489
- throw new Error("Error converting schema to JSON.");
3490
- }
3491
- }
3492
- function isTransforming(_schema, _ctx) {
3493
- const ctx = _ctx ?? { seen: /* @__PURE__ */ new Set() };
3494
- if (ctx.seen.has(_schema)) return false;
3495
- ctx.seen.add(_schema);
3496
- const def = _schema._zod.def;
3497
- if (def.type === "transform") return true;
3498
- if (def.type === "array") return isTransforming(def.element, ctx);
3499
- if (def.type === "set") return isTransforming(def.valueType, ctx);
3500
- if (def.type === "lazy") return isTransforming(def.getter(), ctx);
3501
- if (def.type === "promise" || def.type === "optional" || def.type === "nonoptional" || def.type === "nullable" || def.type === "readonly" || def.type === "default" || def.type === "prefault") return isTransforming(def.innerType, ctx);
3502
- if (def.type === "intersection") return isTransforming(def.left, ctx) || isTransforming(def.right, ctx);
3503
- if (def.type === "record" || def.type === "map") return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);
3504
- if (def.type === "pipe") {
3505
- if (_schema._zod.traits.has("$ZodCodec")) return true;
3506
- return isTransforming(def.in, ctx) || isTransforming(def.out, ctx);
3507
- }
3508
- if (def.type === "object") {
3509
- for (const key in def.shape) if (isTransforming(def.shape[key], ctx)) return true;
3510
- return false;
3511
- }
3512
- if (def.type === "union") {
3513
- for (const option of def.options) if (isTransforming(option, ctx)) return true;
3514
- return false;
3515
- }
3516
- if (def.type === "tuple") {
3517
- for (const item of def.items) if (isTransforming(item, ctx)) return true;
3518
- if (def.rest && isTransforming(def.rest, ctx)) return true;
3519
- return false;
3520
- }
3521
- return false;
3522
- }
3523
- /**
3524
- * Creates a toJSONSchema method for a schema instance.
3525
- * This encapsulates the logic of initializing context, processing, extracting defs, and finalizing.
3526
- */
3527
- const createToJSONSchemaMethod = (schema, processors = {}) => (params) => {
3528
- const ctx = initializeContext({
3529
- ...params,
3530
- processors
3531
- });
3532
- process(schema, ctx);
3533
- extractDefs(ctx, schema);
3534
- return finalize(ctx, schema);
3535
- };
3536
- const createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) => {
3537
- const { libraryOptions, target } = params ?? {};
3538
- const ctx = initializeContext({
3539
- ...libraryOptions ?? {},
3540
- target,
3541
- io,
3542
- processors
3543
- });
3544
- process(schema, ctx);
3545
- extractDefs(ctx, schema);
3546
- return finalize(ctx, schema);
3547
- };
3548
- //#endregion
3549
- //#region ../../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/json-schema-processors.js
3550
- const formatMap = {
3551
- guid: "uuid",
3552
- url: "uri",
3553
- datetime: "date-time",
3554
- json_string: "json-string",
3555
- regex: ""
3556
- };
3557
- const stringProcessor = (schema, ctx, _json, _params) => {
3558
- const json = _json;
3559
- json.type = "string";
3560
- const { minimum, maximum, format, patterns, contentEncoding } = schema._zod.bag;
3561
- if (typeof minimum === "number") json.minLength = minimum;
3562
- if (typeof maximum === "number") json.maxLength = maximum;
3563
- if (format) {
3564
- json.format = formatMap[format] ?? format;
3565
- if (json.format === "") delete json.format;
3566
- if (format === "time") delete json.format;
3567
- }
3568
- if (contentEncoding) json.contentEncoding = contentEncoding;
3569
- if (patterns && patterns.size > 0) {
3570
- const regexes = [...patterns];
3571
- if (regexes.length === 1) json.pattern = regexes[0].source;
3572
- else if (regexes.length > 1) json.allOf = [...regexes.map((regex) => ({
3573
- ...ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0" ? { type: "string" } : {},
3574
- pattern: regex.source
3575
- }))];
3576
- }
3577
- };
3578
- const numberProcessor = (schema, ctx, _json, _params) => {
3579
- const json = _json;
3580
- const { minimum, maximum, format, multipleOf, exclusiveMaximum, exclusiveMinimum } = schema._zod.bag;
3581
- if (typeof format === "string" && format.includes("int")) json.type = "integer";
3582
- else json.type = "number";
3583
- const exMin = typeof exclusiveMinimum === "number" && exclusiveMinimum >= (minimum ?? Number.NEGATIVE_INFINITY);
3584
- const exMax = typeof exclusiveMaximum === "number" && exclusiveMaximum <= (maximum ?? Number.POSITIVE_INFINITY);
3585
- const legacy = ctx.target === "draft-04" || ctx.target === "openapi-3.0";
3586
- if (exMin) if (legacy) {
3587
- json.minimum = exclusiveMinimum;
3588
- json.exclusiveMinimum = true;
3589
- } else json.exclusiveMinimum = exclusiveMinimum;
3590
- else if (typeof minimum === "number") json.minimum = minimum;
3591
- if (exMax) if (legacy) {
3592
- json.maximum = exclusiveMaximum;
3593
- json.exclusiveMaximum = true;
3594
- } else json.exclusiveMaximum = exclusiveMaximum;
3595
- else if (typeof maximum === "number") json.maximum = maximum;
3596
- if (typeof multipleOf === "number") json.multipleOf = multipleOf;
3597
- };
3598
- const neverProcessor = (_schema, _ctx, json, _params) => {
3599
- json.not = {};
3600
- };
3601
- const enumProcessor = (schema, _ctx, json, _params) => {
3602
- const def = schema._zod.def;
3603
- const values = getEnumValues(def.entries);
3604
- if (values.every((v) => typeof v === "number")) json.type = "number";
3605
- if (values.every((v) => typeof v === "string")) json.type = "string";
3606
- json.enum = values;
3607
- };
3608
- const customProcessor = (_schema, ctx, _json, _params) => {
3609
- if (ctx.unrepresentable === "throw") throw new Error("Custom types cannot be represented in JSON Schema");
3610
- };
3611
- const transformProcessor = (_schema, ctx, _json, _params) => {
3612
- if (ctx.unrepresentable === "throw") throw new Error("Transforms cannot be represented in JSON Schema");
3613
- };
3614
- const arrayProcessor = (schema, ctx, _json, params) => {
3615
- const json = _json;
3616
- const def = schema._zod.def;
3617
- const { minimum, maximum } = schema._zod.bag;
3618
- if (typeof minimum === "number") json.minItems = minimum;
3619
- if (typeof maximum === "number") json.maxItems = maximum;
3620
- json.type = "array";
3621
- json.items = process(def.element, ctx, {
3622
- ...params,
3623
- path: [...params.path, "items"]
3624
- });
3625
- };
3626
- const objectProcessor = (schema, ctx, _json, params) => {
3627
- const json = _json;
3628
- const def = schema._zod.def;
3629
- json.type = "object";
3630
- json.properties = {};
3631
- const shape = def.shape;
3632
- for (const key in shape) json.properties[key] = process(shape[key], ctx, {
3633
- ...params,
3634
- path: [
3635
- ...params.path,
3636
- "properties",
3637
- key
3638
- ]
3639
- });
3640
- const allKeys = new Set(Object.keys(shape));
3641
- const requiredKeys = new Set([...allKeys].filter((key) => {
3642
- const v = def.shape[key]._zod;
3643
- if (ctx.io === "input") return v.optin === void 0;
3644
- else return v.optout === void 0;
3645
- }));
3646
- if (requiredKeys.size > 0) json.required = Array.from(requiredKeys);
3647
- if (def.catchall?._zod.def.type === "never") json.additionalProperties = false;
3648
- else if (!def.catchall) {
3649
- if (ctx.io === "output") json.additionalProperties = false;
3650
- } else if (def.catchall) json.additionalProperties = process(def.catchall, ctx, {
3651
- ...params,
3652
- path: [...params.path, "additionalProperties"]
3653
- });
3654
- };
3655
- const unionProcessor = (schema, ctx, json, params) => {
3656
- const def = schema._zod.def;
3657
- const isExclusive = def.inclusive === false;
3658
- const options = def.options.map((x, i) => process(x, ctx, {
3659
- ...params,
3660
- path: [
3661
- ...params.path,
3662
- isExclusive ? "oneOf" : "anyOf",
3663
- i
3664
- ]
3665
- }));
3666
- if (isExclusive) json.oneOf = options;
3667
- else json.anyOf = options;
3668
- };
3669
- const intersectionProcessor = (schema, ctx, json, params) => {
3670
- const def = schema._zod.def;
3671
- const a = process(def.left, ctx, {
3672
- ...params,
3673
- path: [
3674
- ...params.path,
3675
- "allOf",
3676
- 0
3677
- ]
3678
- });
3679
- const b = process(def.right, ctx, {
3680
- ...params,
3681
- path: [
3682
- ...params.path,
3683
- "allOf",
3684
- 1
3685
- ]
3686
- });
3687
- const isSimpleIntersection = (val) => "allOf" in val && Object.keys(val).length === 1;
3688
- json.allOf = [...isSimpleIntersection(a) ? a.allOf : [a], ...isSimpleIntersection(b) ? b.allOf : [b]];
3689
- };
3690
- const nullableProcessor = (schema, ctx, json, params) => {
3691
- const def = schema._zod.def;
3692
- const inner = process(def.innerType, ctx, params);
3693
- const seen = ctx.seen.get(schema);
3694
- if (ctx.target === "openapi-3.0") {
3695
- seen.ref = def.innerType;
3696
- json.nullable = true;
3697
- } else json.anyOf = [inner, { type: "null" }];
3698
- };
3699
- const nonoptionalProcessor = (schema, ctx, _json, params) => {
3700
- const def = schema._zod.def;
3701
- process(def.innerType, ctx, params);
3702
- const seen = ctx.seen.get(schema);
3703
- seen.ref = def.innerType;
3704
- };
3705
- const defaultProcessor = (schema, ctx, json, params) => {
3706
- const def = schema._zod.def;
3707
- process(def.innerType, ctx, params);
3708
- const seen = ctx.seen.get(schema);
3709
- seen.ref = def.innerType;
3710
- json.default = JSON.parse(JSON.stringify(def.defaultValue));
3711
- };
3712
- const prefaultProcessor = (schema, ctx, json, params) => {
3713
- const def = schema._zod.def;
3714
- process(def.innerType, ctx, params);
3715
- const seen = ctx.seen.get(schema);
3716
- seen.ref = def.innerType;
3717
- if (ctx.io === "input") json._prefault = JSON.parse(JSON.stringify(def.defaultValue));
3718
- };
3719
- const catchProcessor = (schema, ctx, json, params) => {
3720
- const def = schema._zod.def;
3721
- process(def.innerType, ctx, params);
3722
- const seen = ctx.seen.get(schema);
3723
- seen.ref = def.innerType;
3724
- let catchValue;
3725
- try {
3726
- catchValue = def.catchValue(void 0);
3727
- } catch {
3728
- throw new Error("Dynamic catch values are not supported in JSON Schema");
3729
- }
3730
- json.default = catchValue;
3731
- };
3732
- const pipeProcessor = (schema, ctx, _json, params) => {
3733
- const def = schema._zod.def;
3734
- const inIsTransform = def.in._zod.traits.has("$ZodTransform");
3735
- const innerType = ctx.io === "input" ? inIsTransform ? def.out : def.in : def.out;
3736
- process(innerType, ctx, params);
3737
- const seen = ctx.seen.get(schema);
3738
- seen.ref = innerType;
3739
- };
3740
- const readonlyProcessor = (schema, ctx, json, params) => {
3741
- const def = schema._zod.def;
3742
- process(def.innerType, ctx, params);
3743
- const seen = ctx.seen.get(schema);
3744
- seen.ref = def.innerType;
3745
- json.readOnly = true;
3746
- };
3747
- const optionalProcessor = (schema, ctx, _json, params) => {
3748
- const def = schema._zod.def;
3749
- process(def.innerType, ctx, params);
3750
- const seen = ctx.seen.get(schema);
3751
- seen.ref = def.innerType;
3752
- };
3753
- //#endregion
3754
- //#region ../../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/iso.js
3755
- const ZodISODateTime = /*@__PURE__*/ $constructor("ZodISODateTime", (inst, def) => {
3756
- $ZodISODateTime.init(inst, def);
3757
- ZodStringFormat.init(inst, def);
3758
- });
3759
- function datetime(params) {
3760
- return /* @__PURE__ */ _isoDateTime(ZodISODateTime, params);
3761
- }
3762
- const ZodISODate = /*@__PURE__*/ $constructor("ZodISODate", (inst, def) => {
3763
- $ZodISODate.init(inst, def);
3764
- ZodStringFormat.init(inst, def);
3765
- });
3766
- function date(params) {
3767
- return /* @__PURE__ */ _isoDate(ZodISODate, params);
3768
- }
3769
- const ZodISOTime = /*@__PURE__*/ $constructor("ZodISOTime", (inst, def) => {
3770
- $ZodISOTime.init(inst, def);
3771
- ZodStringFormat.init(inst, def);
3772
- });
3773
- function time(params) {
3774
- return /* @__PURE__ */ _isoTime(ZodISOTime, params);
3775
- }
3776
- const ZodISODuration = /*@__PURE__*/ $constructor("ZodISODuration", (inst, def) => {
3777
- $ZodISODuration.init(inst, def);
3778
- ZodStringFormat.init(inst, def);
3779
- });
3780
- function duration(params) {
3781
- return /* @__PURE__ */ _isoDuration(ZodISODuration, params);
3782
- }
3783
- //#endregion
3784
- //#region ../../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/errors.js
3785
- const initializer = (inst, issues) => {
3786
- $ZodError.init(inst, issues);
3787
- inst.name = "ZodError";
3788
- Object.defineProperties(inst, {
3789
- format: { value: (mapper) => formatError(inst, mapper) },
3790
- flatten: { value: (mapper) => flattenError(inst, mapper) },
3791
- addIssue: { value: (issue) => {
3792
- inst.issues.push(issue);
3793
- inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
3794
- } },
3795
- addIssues: { value: (issues) => {
3796
- inst.issues.push(...issues);
3797
- inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
3798
- } },
3799
- isEmpty: { get() {
3800
- return inst.issues.length === 0;
3801
- } }
3802
- });
3803
- };
3804
- const ZodRealError = /*@__PURE__*/ $constructor("ZodError", initializer, { Parent: Error });
3805
- //#endregion
3806
- //#region ../../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/parse.js
3807
- const parse = /* @__PURE__ */ _parse(ZodRealError);
3808
- const parseAsync = /* @__PURE__ */ _parseAsync(ZodRealError);
3809
- const safeParse = /* @__PURE__ */ _safeParse(ZodRealError);
3810
- const safeParseAsync = /* @__PURE__ */ _safeParseAsync(ZodRealError);
3811
- const encode = /* @__PURE__ */ _encode(ZodRealError);
3812
- const decode = /* @__PURE__ */ _decode(ZodRealError);
3813
- const encodeAsync = /* @__PURE__ */ _encodeAsync(ZodRealError);
3814
- const decodeAsync = /* @__PURE__ */ _decodeAsync(ZodRealError);
3815
- const safeEncode = /* @__PURE__ */ _safeEncode(ZodRealError);
3816
- const safeDecode = /* @__PURE__ */ _safeDecode(ZodRealError);
3817
- const safeEncodeAsync = /* @__PURE__ */ _safeEncodeAsync(ZodRealError);
3818
- const safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
3819
- //#endregion
3820
- //#region ../../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/schemas.js
3821
- const _installedGroups = /* @__PURE__ */ new WeakMap();
3822
- function _installLazyMethods(inst, group, methods) {
3823
- const proto = Object.getPrototypeOf(inst);
3824
- let installed = _installedGroups.get(proto);
3825
- if (!installed) {
3826
- installed = /* @__PURE__ */ new Set();
3827
- _installedGroups.set(proto, installed);
3828
- }
3829
- if (installed.has(group)) return;
3830
- installed.add(group);
3831
- for (const key in methods) {
3832
- const fn = methods[key];
3833
- Object.defineProperty(proto, key, {
3834
- configurable: true,
3835
- enumerable: false,
3836
- get() {
3837
- const bound = fn.bind(this);
3838
- Object.defineProperty(this, key, {
3839
- configurable: true,
3840
- writable: true,
3841
- enumerable: true,
3842
- value: bound
3843
- });
3844
- return bound;
3845
- },
3846
- set(v) {
3847
- Object.defineProperty(this, key, {
3848
- configurable: true,
3849
- writable: true,
3850
- enumerable: true,
3851
- value: v
3852
- });
3853
- }
3854
- });
3855
- }
3856
- }
3857
- const ZodType = /*@__PURE__*/ $constructor("ZodType", (inst, def) => {
3858
- $ZodType.init(inst, def);
3859
- Object.assign(inst["~standard"], { jsonSchema: {
3860
- input: createStandardJSONSchemaMethod(inst, "input"),
3861
- output: createStandardJSONSchemaMethod(inst, "output")
3862
- } });
3863
- inst.toJSONSchema = createToJSONSchemaMethod(inst, {});
3864
- inst.def = def;
3865
- inst.type = def.type;
3866
- Object.defineProperty(inst, "_def", { value: def });
3867
- inst.parse = (data, params) => parse(inst, data, params, { callee: inst.parse });
3868
- inst.safeParse = (data, params) => safeParse(inst, data, params);
3869
- inst.parseAsync = async (data, params) => parseAsync(inst, data, params, { callee: inst.parseAsync });
3870
- inst.safeParseAsync = async (data, params) => safeParseAsync(inst, data, params);
3871
- inst.spa = inst.safeParseAsync;
3872
- inst.encode = (data, params) => encode(inst, data, params);
3873
- inst.decode = (data, params) => decode(inst, data, params);
3874
- inst.encodeAsync = async (data, params) => encodeAsync(inst, data, params);
3875
- inst.decodeAsync = async (data, params) => decodeAsync(inst, data, params);
3876
- inst.safeEncode = (data, params) => safeEncode(inst, data, params);
3877
- inst.safeDecode = (data, params) => safeDecode(inst, data, params);
3878
- inst.safeEncodeAsync = async (data, params) => safeEncodeAsync(inst, data, params);
3879
- inst.safeDecodeAsync = async (data, params) => safeDecodeAsync(inst, data, params);
3880
- _installLazyMethods(inst, "ZodType", {
3881
- check(...chks) {
3882
- const def = this.def;
3883
- return this.clone(mergeDefs(def, { checks: [...def.checks ?? [], ...chks.map((ch) => typeof ch === "function" ? { _zod: {
3884
- check: ch,
3885
- def: { check: "custom" },
3886
- onattach: []
3887
- } } : ch)] }), { parent: true });
3888
- },
3889
- with(...chks) {
3890
- return this.check(...chks);
3891
- },
3892
- clone(def, params) {
3893
- return clone(this, def, params);
3894
- },
3895
- brand() {
3896
- return this;
3897
- },
3898
- register(reg, meta) {
3899
- reg.add(this, meta);
3900
- return this;
3901
- },
3902
- refine(check, params) {
3903
- return this.check(refine(check, params));
3904
- },
3905
- superRefine(refinement, params) {
3906
- return this.check(superRefine(refinement, params));
3907
- },
3908
- overwrite(fn) {
3909
- return this.check(/* @__PURE__ */ _overwrite(fn));
3910
- },
3911
- optional() {
3912
- return optional(this);
3913
- },
3914
- exactOptional() {
3915
- return exactOptional(this);
3916
- },
3917
- nullable() {
3918
- return nullable(this);
3919
- },
3920
- nullish() {
3921
- return optional(nullable(this));
3922
- },
3923
- nonoptional(params) {
3924
- return nonoptional(this, params);
3925
- },
3926
- array() {
3927
- return array(this);
3928
- },
3929
- or(arg) {
3930
- return union([this, arg]);
3931
- },
3932
- and(arg) {
3933
- return intersection(this, arg);
3934
- },
3935
- transform(tx) {
3936
- return pipe(this, transform(tx));
3937
- },
3938
- default(d) {
3939
- return _default(this, d);
3940
- },
3941
- prefault(d) {
3942
- return prefault(this, d);
3943
- },
3944
- catch(params) {
3945
- return _catch(this, params);
3946
- },
3947
- pipe(target) {
3948
- return pipe(this, target);
3949
- },
3950
- readonly() {
3951
- return readonly(this);
3952
- },
3953
- describe(description) {
3954
- const cl = this.clone();
3955
- globalRegistry.add(cl, { description });
3956
- return cl;
3957
- },
3958
- meta(...args) {
3959
- if (args.length === 0) return globalRegistry.get(this);
3960
- const cl = this.clone();
3961
- globalRegistry.add(cl, args[0]);
3962
- return cl;
3963
- },
3964
- isOptional() {
3965
- return this.safeParse(void 0).success;
3966
- },
3967
- isNullable() {
3968
- return this.safeParse(null).success;
3969
- },
3970
- apply(fn) {
3971
- return fn(this);
3972
- }
3973
- });
3974
- Object.defineProperty(inst, "description", {
3975
- get() {
3976
- return globalRegistry.get(inst)?.description;
3977
- },
3978
- configurable: true
3979
- });
3980
- return inst;
3981
- });
3982
- /** @internal */
3983
- const _ZodString = /*@__PURE__*/ $constructor("_ZodString", (inst, def) => {
3984
- $ZodString.init(inst, def);
3985
- ZodType.init(inst, def);
3986
- inst._zod.processJSONSchema = (ctx, json, params) => stringProcessor(inst, ctx, json, params);
3987
- const bag = inst._zod.bag;
3988
- inst.format = bag.format ?? null;
3989
- inst.minLength = bag.minimum ?? null;
3990
- inst.maxLength = bag.maximum ?? null;
3991
- _installLazyMethods(inst, "_ZodString", {
3992
- regex(...args) {
3993
- return this.check(/* @__PURE__ */ _regex(...args));
3994
- },
3995
- includes(...args) {
3996
- return this.check(/* @__PURE__ */ _includes(...args));
3997
- },
3998
- startsWith(...args) {
3999
- return this.check(/* @__PURE__ */ _startsWith(...args));
4000
- },
4001
- endsWith(...args) {
4002
- return this.check(/* @__PURE__ */ _endsWith(...args));
4003
- },
4004
- min(...args) {
4005
- return this.check(/* @__PURE__ */ _minLength(...args));
4006
- },
4007
- max(...args) {
4008
- return this.check(/* @__PURE__ */ _maxLength(...args));
4009
- },
4010
- length(...args) {
4011
- return this.check(/* @__PURE__ */ _length(...args));
4012
- },
4013
- nonempty(...args) {
4014
- return this.check(/* @__PURE__ */ _minLength(1, ...args));
4015
- },
4016
- lowercase(params) {
4017
- return this.check(/* @__PURE__ */ _lowercase(params));
4018
- },
4019
- uppercase(params) {
4020
- return this.check(/* @__PURE__ */ _uppercase(params));
4021
- },
4022
- trim() {
4023
- return this.check(/* @__PURE__ */ _trim());
4024
- },
4025
- normalize(...args) {
4026
- return this.check(/* @__PURE__ */ _normalize(...args));
4027
- },
4028
- toLowerCase() {
4029
- return this.check(/* @__PURE__ */ _toLowerCase());
4030
- },
4031
- toUpperCase() {
4032
- return this.check(/* @__PURE__ */ _toUpperCase());
4033
- },
4034
- slugify() {
4035
- return this.check(/* @__PURE__ */ _slugify());
4036
- }
4037
- });
4038
- });
4039
- const ZodString = /*@__PURE__*/ $constructor("ZodString", (inst, def) => {
4040
- $ZodString.init(inst, def);
4041
- _ZodString.init(inst, def);
4042
- inst.email = (params) => inst.check(/* @__PURE__ */ _email(ZodEmail, params));
4043
- inst.url = (params) => inst.check(/* @__PURE__ */ _url(ZodURL, params));
4044
- inst.jwt = (params) => inst.check(/* @__PURE__ */ _jwt(ZodJWT, params));
4045
- inst.emoji = (params) => inst.check(/* @__PURE__ */ _emoji(ZodEmoji, params));
4046
- inst.guid = (params) => inst.check(/* @__PURE__ */ _guid(ZodGUID, params));
4047
- inst.uuid = (params) => inst.check(/* @__PURE__ */ _uuid(ZodUUID, params));
4048
- inst.uuidv4 = (params) => inst.check(/* @__PURE__ */ _uuidv4(ZodUUID, params));
4049
- inst.uuidv6 = (params) => inst.check(/* @__PURE__ */ _uuidv6(ZodUUID, params));
4050
- inst.uuidv7 = (params) => inst.check(/* @__PURE__ */ _uuidv7(ZodUUID, params));
4051
- inst.nanoid = (params) => inst.check(/* @__PURE__ */ _nanoid(ZodNanoID, params));
4052
- inst.guid = (params) => inst.check(/* @__PURE__ */ _guid(ZodGUID, params));
4053
- inst.cuid = (params) => inst.check(/* @__PURE__ */ _cuid(ZodCUID, params));
4054
- inst.cuid2 = (params) => inst.check(/* @__PURE__ */ _cuid2(ZodCUID2, params));
4055
- inst.ulid = (params) => inst.check(/* @__PURE__ */ _ulid(ZodULID, params));
4056
- inst.base64 = (params) => inst.check(/* @__PURE__ */ _base64(ZodBase64, params));
4057
- inst.base64url = (params) => inst.check(/* @__PURE__ */ _base64url(ZodBase64URL, params));
4058
- inst.xid = (params) => inst.check(/* @__PURE__ */ _xid(ZodXID, params));
4059
- inst.ksuid = (params) => inst.check(/* @__PURE__ */ _ksuid(ZodKSUID, params));
4060
- inst.ipv4 = (params) => inst.check(/* @__PURE__ */ _ipv4(ZodIPv4, params));
4061
- inst.ipv6 = (params) => inst.check(/* @__PURE__ */ _ipv6(ZodIPv6, params));
4062
- inst.cidrv4 = (params) => inst.check(/* @__PURE__ */ _cidrv4(ZodCIDRv4, params));
4063
- inst.cidrv6 = (params) => inst.check(/* @__PURE__ */ _cidrv6(ZodCIDRv6, params));
4064
- inst.e164 = (params) => inst.check(/* @__PURE__ */ _e164(ZodE164, params));
4065
- inst.datetime = (params) => inst.check(datetime(params));
4066
- inst.date = (params) => inst.check(date(params));
4067
- inst.time = (params) => inst.check(time(params));
4068
- inst.duration = (params) => inst.check(duration(params));
4069
- });
4070
- function string(params) {
4071
- return /* @__PURE__ */ _string(ZodString, params);
4072
- }
4073
- const ZodStringFormat = /*@__PURE__*/ $constructor("ZodStringFormat", (inst, def) => {
4074
- $ZodStringFormat.init(inst, def);
4075
- _ZodString.init(inst, def);
4076
- });
4077
- const ZodEmail = /*@__PURE__*/ $constructor("ZodEmail", (inst, def) => {
4078
- $ZodEmail.init(inst, def);
4079
- ZodStringFormat.init(inst, def);
4080
- });
4081
- const ZodGUID = /*@__PURE__*/ $constructor("ZodGUID", (inst, def) => {
4082
- $ZodGUID.init(inst, def);
4083
- ZodStringFormat.init(inst, def);
4084
- });
4085
- const ZodUUID = /*@__PURE__*/ $constructor("ZodUUID", (inst, def) => {
4086
- $ZodUUID.init(inst, def);
4087
- ZodStringFormat.init(inst, def);
4088
- });
4089
- const ZodURL = /*@__PURE__*/ $constructor("ZodURL", (inst, def) => {
4090
- $ZodURL.init(inst, def);
4091
- ZodStringFormat.init(inst, def);
4092
- });
4093
- const ZodEmoji = /*@__PURE__*/ $constructor("ZodEmoji", (inst, def) => {
4094
- $ZodEmoji.init(inst, def);
4095
- ZodStringFormat.init(inst, def);
4096
- });
4097
- const ZodNanoID = /*@__PURE__*/ $constructor("ZodNanoID", (inst, def) => {
4098
- $ZodNanoID.init(inst, def);
4099
- ZodStringFormat.init(inst, def);
4100
- });
4101
- /**
4102
- * @deprecated CUID v1 is deprecated by its authors due to information leakage
4103
- * (timestamps embedded in the id). Use {@link ZodCUID2} instead.
4104
- * See https://github.com/paralleldrive/cuid.
4105
- */
4106
- const ZodCUID = /*@__PURE__*/ $constructor("ZodCUID", (inst, def) => {
4107
- $ZodCUID.init(inst, def);
4108
- ZodStringFormat.init(inst, def);
4109
- });
4110
- const ZodCUID2 = /*@__PURE__*/ $constructor("ZodCUID2", (inst, def) => {
4111
- $ZodCUID2.init(inst, def);
4112
- ZodStringFormat.init(inst, def);
4113
- });
4114
- const ZodULID = /*@__PURE__*/ $constructor("ZodULID", (inst, def) => {
4115
- $ZodULID.init(inst, def);
4116
- ZodStringFormat.init(inst, def);
4117
- });
4118
- const ZodXID = /*@__PURE__*/ $constructor("ZodXID", (inst, def) => {
4119
- $ZodXID.init(inst, def);
4120
- ZodStringFormat.init(inst, def);
4121
- });
4122
- const ZodKSUID = /*@__PURE__*/ $constructor("ZodKSUID", (inst, def) => {
4123
- $ZodKSUID.init(inst, def);
4124
- ZodStringFormat.init(inst, def);
4125
- });
4126
- const ZodIPv4 = /*@__PURE__*/ $constructor("ZodIPv4", (inst, def) => {
4127
- $ZodIPv4.init(inst, def);
4128
- ZodStringFormat.init(inst, def);
4129
- });
4130
- const ZodIPv6 = /*@__PURE__*/ $constructor("ZodIPv6", (inst, def) => {
4131
- $ZodIPv6.init(inst, def);
4132
- ZodStringFormat.init(inst, def);
4133
- });
4134
- const ZodCIDRv4 = /*@__PURE__*/ $constructor("ZodCIDRv4", (inst, def) => {
4135
- $ZodCIDRv4.init(inst, def);
4136
- ZodStringFormat.init(inst, def);
4137
- });
4138
- const ZodCIDRv6 = /*@__PURE__*/ $constructor("ZodCIDRv6", (inst, def) => {
4139
- $ZodCIDRv6.init(inst, def);
4140
- ZodStringFormat.init(inst, def);
4141
- });
4142
- const ZodBase64 = /*@__PURE__*/ $constructor("ZodBase64", (inst, def) => {
4143
- $ZodBase64.init(inst, def);
4144
- ZodStringFormat.init(inst, def);
4145
- });
4146
- const ZodBase64URL = /*@__PURE__*/ $constructor("ZodBase64URL", (inst, def) => {
4147
- $ZodBase64URL.init(inst, def);
4148
- ZodStringFormat.init(inst, def);
4149
- });
4150
- const ZodE164 = /*@__PURE__*/ $constructor("ZodE164", (inst, def) => {
4151
- $ZodE164.init(inst, def);
4152
- ZodStringFormat.init(inst, def);
4153
- });
4154
- const ZodJWT = /*@__PURE__*/ $constructor("ZodJWT", (inst, def) => {
4155
- $ZodJWT.init(inst, def);
4156
- ZodStringFormat.init(inst, def);
4157
- });
4158
- const ZodNumber = /*@__PURE__*/ $constructor("ZodNumber", (inst, def) => {
4159
- $ZodNumber.init(inst, def);
4160
- ZodType.init(inst, def);
4161
- inst._zod.processJSONSchema = (ctx, json, params) => numberProcessor(inst, ctx, json, params);
4162
- _installLazyMethods(inst, "ZodNumber", {
4163
- gt(value, params) {
4164
- return this.check(/* @__PURE__ */ _gt(value, params));
4165
- },
4166
- gte(value, params) {
4167
- return this.check(/* @__PURE__ */ _gte(value, params));
4168
- },
4169
- min(value, params) {
4170
- return this.check(/* @__PURE__ */ _gte(value, params));
4171
- },
4172
- lt(value, params) {
4173
- return this.check(/* @__PURE__ */ _lt(value, params));
4174
- },
4175
- lte(value, params) {
4176
- return this.check(/* @__PURE__ */ _lte(value, params));
4177
- },
4178
- max(value, params) {
4179
- return this.check(/* @__PURE__ */ _lte(value, params));
4180
- },
4181
- int(params) {
4182
- return this.check(int(params));
4183
- },
4184
- safe(params) {
4185
- return this.check(int(params));
4186
- },
4187
- positive(params) {
4188
- return this.check(/* @__PURE__ */ _gt(0, params));
4189
- },
4190
- nonnegative(params) {
4191
- return this.check(/* @__PURE__ */ _gte(0, params));
4192
- },
4193
- negative(params) {
4194
- return this.check(/* @__PURE__ */ _lt(0, params));
4195
- },
4196
- nonpositive(params) {
4197
- return this.check(/* @__PURE__ */ _lte(0, params));
4198
- },
4199
- multipleOf(value, params) {
4200
- return this.check(/* @__PURE__ */ _multipleOf(value, params));
4201
- },
4202
- step(value, params) {
4203
- return this.check(/* @__PURE__ */ _multipleOf(value, params));
4204
- },
4205
- finite() {
4206
- return this;
4207
- }
4208
- });
4209
- const bag = inst._zod.bag;
4210
- inst.minValue = Math.max(bag.minimum ?? Number.NEGATIVE_INFINITY, bag.exclusiveMinimum ?? Number.NEGATIVE_INFINITY) ?? null;
4211
- inst.maxValue = Math.min(bag.maximum ?? Number.POSITIVE_INFINITY, bag.exclusiveMaximum ?? Number.POSITIVE_INFINITY) ?? null;
4212
- inst.isInt = (bag.format ?? "").includes("int") || Number.isSafeInteger(bag.multipleOf ?? .5);
4213
- inst.isFinite = true;
4214
- inst.format = bag.format ?? null;
4215
- });
4216
- function number(params) {
4217
- return /* @__PURE__ */ _number(ZodNumber, params);
4218
- }
4219
- const ZodNumberFormat = /*@__PURE__*/ $constructor("ZodNumberFormat", (inst, def) => {
4220
- $ZodNumberFormat.init(inst, def);
4221
- ZodNumber.init(inst, def);
4222
- });
4223
- function int(params) {
4224
- return /* @__PURE__ */ _int(ZodNumberFormat, params);
4225
- }
4226
- const ZodUnknown = /*@__PURE__*/ $constructor("ZodUnknown", (inst, def) => {
4227
- $ZodUnknown.init(inst, def);
4228
- ZodType.init(inst, def);
4229
- inst._zod.processJSONSchema = (ctx, json, params) => void 0;
4230
- });
4231
- function unknown() {
4232
- return /* @__PURE__ */ _unknown(ZodUnknown);
4233
- }
4234
- const ZodNever = /*@__PURE__*/ $constructor("ZodNever", (inst, def) => {
4235
- $ZodNever.init(inst, def);
4236
- ZodType.init(inst, def);
4237
- inst._zod.processJSONSchema = (ctx, json, params) => neverProcessor(inst, ctx, json, params);
4238
- });
4239
- function never(params) {
4240
- return /* @__PURE__ */ _never(ZodNever, params);
4241
- }
4242
- const ZodArray = /*@__PURE__*/ $constructor("ZodArray", (inst, def) => {
4243
- $ZodArray.init(inst, def);
4244
- ZodType.init(inst, def);
4245
- inst._zod.processJSONSchema = (ctx, json, params) => arrayProcessor(inst, ctx, json, params);
4246
- inst.element = def.element;
4247
- _installLazyMethods(inst, "ZodArray", {
4248
- min(n, params) {
4249
- return this.check(/* @__PURE__ */ _minLength(n, params));
4250
- },
4251
- nonempty(params) {
4252
- return this.check(/* @__PURE__ */ _minLength(1, params));
4253
- },
4254
- max(n, params) {
4255
- return this.check(/* @__PURE__ */ _maxLength(n, params));
4256
- },
4257
- length(n, params) {
4258
- return this.check(/* @__PURE__ */ _length(n, params));
4259
- },
4260
- unwrap() {
4261
- return this.element;
4262
- }
4263
- });
4264
- });
4265
- function array(element, params) {
4266
- return /* @__PURE__ */ _array(ZodArray, element, params);
4267
- }
4268
- const ZodObject = /*@__PURE__*/ $constructor("ZodObject", (inst, def) => {
4269
- $ZodObjectJIT.init(inst, def);
4270
- ZodType.init(inst, def);
4271
- inst._zod.processJSONSchema = (ctx, json, params) => objectProcessor(inst, ctx, json, params);
4272
- defineLazy(inst, "shape", () => {
4273
- return def.shape;
4274
- });
4275
- _installLazyMethods(inst, "ZodObject", {
4276
- keyof() {
4277
- return _enum(Object.keys(this._zod.def.shape));
4278
- },
4279
- catchall(catchall) {
4280
- return this.clone({
4281
- ...this._zod.def,
4282
- catchall
4283
- });
4284
- },
4285
- passthrough() {
4286
- return this.clone({
4287
- ...this._zod.def,
4288
- catchall: unknown()
4289
- });
4290
- },
4291
- loose() {
4292
- return this.clone({
4293
- ...this._zod.def,
4294
- catchall: unknown()
4295
- });
4296
- },
4297
- strict() {
4298
- return this.clone({
4299
- ...this._zod.def,
4300
- catchall: never()
4301
- });
4302
- },
4303
- strip() {
4304
- return this.clone({
4305
- ...this._zod.def,
4306
- catchall: void 0
4307
- });
4308
- },
4309
- extend(incoming) {
4310
- return extend(this, incoming);
4311
- },
4312
- safeExtend(incoming) {
4313
- return safeExtend(this, incoming);
4314
- },
4315
- merge(other) {
4316
- return merge(this, other);
4317
- },
4318
- pick(mask) {
4319
- return pick(this, mask);
4320
- },
4321
- omit(mask) {
4322
- return omit(this, mask);
4323
- },
4324
- partial(...args) {
4325
- return partial(ZodOptional, this, args[0]);
4326
- },
4327
- required(...args) {
4328
- return required(ZodNonOptional, this, args[0]);
4329
- }
4330
- });
4331
- });
4332
- function object(shape, params) {
4333
- return new ZodObject({
4334
- type: "object",
4335
- shape: shape ?? {},
4336
- ...normalizeParams(params)
4337
- });
4338
- }
4339
- const ZodUnion = /*@__PURE__*/ $constructor("ZodUnion", (inst, def) => {
4340
- $ZodUnion.init(inst, def);
4341
- ZodType.init(inst, def);
4342
- inst._zod.processJSONSchema = (ctx, json, params) => unionProcessor(inst, ctx, json, params);
4343
- inst.options = def.options;
4344
- });
4345
- function union(options, params) {
4346
- return new ZodUnion({
4347
- type: "union",
4348
- options,
4349
- ...normalizeParams(params)
4350
- });
4351
- }
4352
- const ZodIntersection = /*@__PURE__*/ $constructor("ZodIntersection", (inst, def) => {
4353
- $ZodIntersection.init(inst, def);
4354
- ZodType.init(inst, def);
4355
- inst._zod.processJSONSchema = (ctx, json, params) => intersectionProcessor(inst, ctx, json, params);
4356
- });
4357
- function intersection(left, right) {
4358
- return new ZodIntersection({
4359
- type: "intersection",
4360
- left,
4361
- right
4362
- });
4363
- }
4364
- const ZodEnum = /*@__PURE__*/ $constructor("ZodEnum", (inst, def) => {
4365
- $ZodEnum.init(inst, def);
4366
- ZodType.init(inst, def);
4367
- inst._zod.processJSONSchema = (ctx, json, params) => enumProcessor(inst, ctx, json, params);
4368
- inst.enum = def.entries;
4369
- inst.options = Object.values(def.entries);
4370
- const keys = new Set(Object.keys(def.entries));
4371
- inst.extract = (values, params) => {
4372
- const newEntries = {};
4373
- for (const value of values) if (keys.has(value)) newEntries[value] = def.entries[value];
4374
- else throw new Error(`Key ${value} not found in enum`);
4375
- return new ZodEnum({
4376
- ...def,
4377
- checks: [],
4378
- ...normalizeParams(params),
4379
- entries: newEntries
4380
- });
4381
- };
4382
- inst.exclude = (values, params) => {
4383
- const newEntries = { ...def.entries };
4384
- for (const value of values) if (keys.has(value)) delete newEntries[value];
4385
- else throw new Error(`Key ${value} not found in enum`);
4386
- return new ZodEnum({
4387
- ...def,
4388
- checks: [],
4389
- ...normalizeParams(params),
4390
- entries: newEntries
4391
- });
4392
- };
4393
- });
4394
- function _enum(values, params) {
4395
- return new ZodEnum({
4396
- type: "enum",
4397
- entries: Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values,
4398
- ...normalizeParams(params)
4399
- });
4400
- }
4401
- const ZodTransform = /*@__PURE__*/ $constructor("ZodTransform", (inst, def) => {
4402
- $ZodTransform.init(inst, def);
4403
- ZodType.init(inst, def);
4404
- inst._zod.processJSONSchema = (ctx, json, params) => transformProcessor(inst, ctx, json, params);
4405
- inst._zod.parse = (payload, _ctx) => {
4406
- if (_ctx.direction === "backward") throw new $ZodEncodeError(inst.constructor.name);
4407
- payload.addIssue = (issue$1) => {
4408
- if (typeof issue$1 === "string") payload.issues.push(issue(issue$1, payload.value, def));
4409
- else {
4410
- const _issue = issue$1;
4411
- if (_issue.fatal) _issue.continue = false;
4412
- _issue.code ?? (_issue.code = "custom");
4413
- _issue.input ?? (_issue.input = payload.value);
4414
- _issue.inst ?? (_issue.inst = inst);
4415
- payload.issues.push(issue(_issue));
4416
- }
4417
- };
4418
- const output = def.transform(payload.value, payload);
4419
- if (output instanceof Promise) return output.then((output) => {
4420
- payload.value = output;
4421
- payload.fallback = true;
4422
- return payload;
4423
- });
4424
- payload.value = output;
4425
- payload.fallback = true;
4426
- return payload;
4427
- };
4428
- });
4429
- function transform(fn) {
4430
- return new ZodTransform({
4431
- type: "transform",
4432
- transform: fn
4433
- });
4434
- }
4435
- const ZodOptional = /*@__PURE__*/ $constructor("ZodOptional", (inst, def) => {
4436
- $ZodOptional.init(inst, def);
4437
- ZodType.init(inst, def);
4438
- inst._zod.processJSONSchema = (ctx, json, params) => optionalProcessor(inst, ctx, json, params);
4439
- inst.unwrap = () => inst._zod.def.innerType;
4440
- });
4441
- function optional(innerType) {
4442
- return new ZodOptional({
4443
- type: "optional",
4444
- innerType
4445
- });
4446
- }
4447
- const ZodExactOptional = /*@__PURE__*/ $constructor("ZodExactOptional", (inst, def) => {
4448
- $ZodExactOptional.init(inst, def);
4449
- ZodType.init(inst, def);
4450
- inst._zod.processJSONSchema = (ctx, json, params) => optionalProcessor(inst, ctx, json, params);
4451
- inst.unwrap = () => inst._zod.def.innerType;
4452
- });
4453
- function exactOptional(innerType) {
4454
- return new ZodExactOptional({
4455
- type: "optional",
4456
- innerType
4457
- });
4458
- }
4459
- const ZodNullable = /*@__PURE__*/ $constructor("ZodNullable", (inst, def) => {
4460
- $ZodNullable.init(inst, def);
4461
- ZodType.init(inst, def);
4462
- inst._zod.processJSONSchema = (ctx, json, params) => nullableProcessor(inst, ctx, json, params);
4463
- inst.unwrap = () => inst._zod.def.innerType;
4464
- });
4465
- function nullable(innerType) {
4466
- return new ZodNullable({
4467
- type: "nullable",
4468
- innerType
4469
- });
4470
- }
4471
- const ZodDefault = /*@__PURE__*/ $constructor("ZodDefault", (inst, def) => {
4472
- $ZodDefault.init(inst, def);
4473
- ZodType.init(inst, def);
4474
- inst._zod.processJSONSchema = (ctx, json, params) => defaultProcessor(inst, ctx, json, params);
4475
- inst.unwrap = () => inst._zod.def.innerType;
4476
- inst.removeDefault = inst.unwrap;
4477
- });
4478
- function _default(innerType, defaultValue) {
4479
- return new ZodDefault({
4480
- type: "default",
4481
- innerType,
4482
- get defaultValue() {
4483
- return typeof defaultValue === "function" ? defaultValue() : shallowClone(defaultValue);
4484
- }
4485
- });
4486
- }
4487
- const ZodPrefault = /*@__PURE__*/ $constructor("ZodPrefault", (inst, def) => {
4488
- $ZodPrefault.init(inst, def);
4489
- ZodType.init(inst, def);
4490
- inst._zod.processJSONSchema = (ctx, json, params) => prefaultProcessor(inst, ctx, json, params);
4491
- inst.unwrap = () => inst._zod.def.innerType;
4492
- });
4493
- function prefault(innerType, defaultValue) {
4494
- return new ZodPrefault({
4495
- type: "prefault",
4496
- innerType,
4497
- get defaultValue() {
4498
- return typeof defaultValue === "function" ? defaultValue() : shallowClone(defaultValue);
4499
- }
4500
- });
4501
- }
4502
- const ZodNonOptional = /*@__PURE__*/ $constructor("ZodNonOptional", (inst, def) => {
4503
- $ZodNonOptional.init(inst, def);
4504
- ZodType.init(inst, def);
4505
- inst._zod.processJSONSchema = (ctx, json, params) => nonoptionalProcessor(inst, ctx, json, params);
4506
- inst.unwrap = () => inst._zod.def.innerType;
4507
- });
4508
- function nonoptional(innerType, params) {
4509
- return new ZodNonOptional({
4510
- type: "nonoptional",
4511
- innerType,
4512
- ...normalizeParams(params)
4513
- });
4514
- }
4515
- const ZodCatch = /*@__PURE__*/ $constructor("ZodCatch", (inst, def) => {
4516
- $ZodCatch.init(inst, def);
4517
- ZodType.init(inst, def);
4518
- inst._zod.processJSONSchema = (ctx, json, params) => catchProcessor(inst, ctx, json, params);
4519
- inst.unwrap = () => inst._zod.def.innerType;
4520
- inst.removeCatch = inst.unwrap;
4521
- });
4522
- function _catch(innerType, catchValue) {
4523
- return new ZodCatch({
4524
- type: "catch",
4525
- innerType,
4526
- catchValue: typeof catchValue === "function" ? catchValue : () => catchValue
4527
- });
4528
- }
4529
- const ZodPipe = /*@__PURE__*/ $constructor("ZodPipe", (inst, def) => {
4530
- $ZodPipe.init(inst, def);
4531
- ZodType.init(inst, def);
4532
- inst._zod.processJSONSchema = (ctx, json, params) => pipeProcessor(inst, ctx, json, params);
4533
- inst.in = def.in;
4534
- inst.out = def.out;
4535
- });
4536
- function pipe(in_, out) {
4537
- return new ZodPipe({
4538
- type: "pipe",
4539
- in: in_,
4540
- out
4541
- });
4542
- }
4543
- const ZodReadonly = /*@__PURE__*/ $constructor("ZodReadonly", (inst, def) => {
4544
- $ZodReadonly.init(inst, def);
4545
- ZodType.init(inst, def);
4546
- inst._zod.processJSONSchema = (ctx, json, params) => readonlyProcessor(inst, ctx, json, params);
4547
- inst.unwrap = () => inst._zod.def.innerType;
4548
- });
4549
- function readonly(innerType) {
4550
- return new ZodReadonly({
4551
- type: "readonly",
4552
- innerType
4553
- });
4554
- }
4555
- const ZodCustom = /*@__PURE__*/ $constructor("ZodCustom", (inst, def) => {
4556
- $ZodCustom.init(inst, def);
4557
- ZodType.init(inst, def);
4558
- inst._zod.processJSONSchema = (ctx, json, params) => customProcessor(inst, ctx, json, params);
4559
- });
4560
- function refine(fn, _params = {}) {
4561
- return /* @__PURE__ */ _refine(ZodCustom, fn, _params);
4562
- }
4563
- function superRefine(fn, params) {
4564
- return /* @__PURE__ */ _superRefine(fn, params);
4565
- }
4566
- //#endregion
4567
623
  //#region lib/types/client/overview-client.js
4568
624
  /** Validate the authenticated local overview response; never query a cloud account. */
4569
- const count = number().int().nonnegative().max(Number.MAX_SAFE_INTEGER);
4570
- const money = number().nonnegative();
4571
- const schema = object({
625
+ const count = zod.z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER);
626
+ const money = zod.z.number().nonnegative();
627
+ const schema = zod.z.object({
4572
628
  scannedAt: count,
4573
629
  sessions: count,
4574
630
  projects: count,
@@ -4579,9 +635,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
4579
635
  priced: count,
4580
636
  unpriced: count,
4581
637
  uncertain: count,
4582
- rows: array(object({
4583
- provider: string(),
4584
- model: string(),
638
+ rows: zod.z.array(zod.z.object({
639
+ provider: zod.z.string(),
640
+ model: zod.z.string(),
4585
641
  tokens: count,
4586
642
  total: money,
4587
643
  priced: count,